add index page link to stexaminer and relmapper
Tara L Andrews [Wed, 5 Sep 2012 09:53:35 +0000 (11:53 +0200)]
lib/stemmaweb/Controller/Root.pm
lib/stemmaweb/Controller/Stexaminer.pm
root/src/directory.tt
root/src/index.tt
root/src/relate.tt
root/src/stexaminer.tt

index d4184aa..c3812e7 100644 (file)
@@ -33,6 +33,10 @@ components will be loaded.
 sub index :Path :Args(0) {
     my ( $self, $c ) = @_;
 
+       # Are we being asked to load a text immediately? If so 
+       if( $c->req->param('withtradition') ) {
+               $c->stash->{'withtradition'} = $c->req->param('withtradition');
+       }
     $c->stash->{template} = 'index.tt';
 }
 
index 80d8827..37c2dea 100644 (file)
@@ -40,6 +40,7 @@ sub index :Path :Args(2) {
                my $stemma = $tradition->stemma( $stemid );
                $c->stash->{svg} = $stemma->as_svg( { size => [ 600, 350 ] } );
                $c->stash->{graphdot} = $stemma->editable({ linesep => ' ' });
+               $c->stash->{text_id} = $textid;
                $c->stash->{text_title} = $tradition->name;
                $c->stash->{template} = 'stexaminer.tt'; 
                
index d7d6266..dbe1547 100644 (file)
@@ -5,7 +5,7 @@
       <ul>
 [% SET i = 0 -%]
 [% FOREACH t IN usertexts -%]
-        <li><span class="traditionname" onClick="$('.traditionname').removeClass('selected');$(this).addClass('selected');loadTradition('[% t.id %]','[% t.name %]', 1)">[% t.name %]</span></li>
+        <li><span id="[% t.id %]" class="traditionname" onClick="$('.traditionname').removeClass('selected');$(this).addClass('selected');loadTradition('[% t.id %]','[% t.name %]', 1)">[% t.name %]</span></li>
 [% i = i + 1 -%]
 [% END -%]
      </ul>
@@ -18,7 +18,7 @@
       <ul>
 [% SET i = 0 -%]
 [% FOREACH t IN publictexts -%]
-        <li><span class="traditionname" onClick="$('.traditionname').removeClass('selected');$(this).addClass('selected');loadTradition('[% t.id %]','[% t.name %]', 0)">[% t.name %]</span></li>
+        <li><span id="[% t.id %]" class="traditionname" onClick="$('.traditionname').removeClass('selected');$(this).addClass('selected');loadTradition('[% t.id %]','[% t.name %]', 0)">[% t.name %]</span></li>
 [% i = i + 1 -%]
 [% END -%]
      </ul>
index e2e8192..53bf324 100644 (file)
@@ -7,6 +7,7 @@ var basepath = window.location.pathname
 if( basepath.lastIndexOf('/') == basepath.length - 1 ) { 
        basepath = basepath.slice( 0, basepath.length - 1) 
 };
+var textOnLoad = "[% withtradition %]";
 var selectedTextID;
 var selectedTextInfo;
 var selectedStemmaID = -1;
@@ -20,6 +21,13 @@ function refreshDirectory () {
                        if (status == "error") {
                                var msg = "An error occurred: ";
                                $("#directory").html(msg + xhr.status + " " + xhr.statusText);
+                       } else {
+                               if( textOnLoad != "" ) {
+                                       // Call the click callback for the relevant text, if it is
+                                       // in the page.
+                                       $('#'+textOnLoad).click();
+                                       textOnLoad = "";
+                               }
                        }
                }
        );
@@ -232,7 +240,7 @@ $(document).ready( function() {
 
     <div id="topbanner">
       <h1>Stemmaweb - a collection of tools for analysis of collated texts</h1>
-      <span class="mainnav">[% IF c.user_exists %]Hello! [% c.user.get_object.email %] <a class="navlink" href="[% c.uri_for( '/logout' ) %]">Sign out</a> | [% ELSE %]<a class="navlink" onclick="window.open('[% c.uri_for( '/login' ) %]', 'loginwindow', 'height=385,width=445')">Login</a> | <a class="navlink" onclick="window.open('[% c.uri_for( '/register' ) %]', 'regwindow', 'height=385,width=445')">Register</a> | [% END %]<a class="navlink" href="[% c.uri_for( 'about.html' ) %]">About</a> </span>
+      <span class="mainnav">[% IF c.user_exists %]Hello! [% c.user.get_object.email %] <a class="navlink" href="[% c.uri_for( '/logout' ) %]">Sign out</a> | [% ELSE %]<a class="navlink" onclick="window.open('[% c.uri_for( '/login' ) %]', 'loginwindow', 'height=385,width=445')">Login</a> | [% END %]<a class="navlink" href="[% c.uri_for( 'about.html' ) %]">About</a> </span>
     </div>
     <div id="directory_container">
       <h2>Text directory</h2>
index f71282d..95af6d6 100644 (file)
@@ -13,7 +13,7 @@ $(document).ready(function () {
 
        <div id="topbanner">
                <div id="bannerinfo">
-                       <a href="help/[% text_lang %]" title="Relationship mapper help" class="helptag">Help / About</a>
+                       <a href="help/[% text_lang %]" title="Relationship mapper help" class="helptag">Help / About</a> | <a href="[% c.uri_for( '/' ) %]?withtradition=[% textid %]" class="navlink">Return to index</a>
                </div>
                <h1>Relationship mapper</h1>
                <h2>[% text_title %]</h2>
index 379e9f9..2f1a117 100644 (file)
@@ -10,7 +10,7 @@ var graphdot = '[% graphdot %]';
 [% END -%]
        <div id="topbanner">
                <div id="bannerinfo">
-                       <a href="help" title="Stexaminer help" class="navlink" id="aboutlink">Help / About</a>
+                       <a href="help" title="Stexaminer help" class="navlink" id="aboutlink">Help / About</a> | <a href="[% c.uri_for( '/' ) %]?withtradition=[% text_id %]" title="Index" class="navlink">Return to index</a>
                </div>
            <h1>Stexaminer</h1>
        <h2>[% text_title %]</h2>