[Koha-patches] [PATCH] Bug 9424 [Revised] Move JavaScript out of header include

Owen Leonard oleonard at myacpl.org
Fri May 10 14:45:49 CEST 2013


This patch removes JavaScript "onlick" attributes from header.inc and
moves the functionality to staff-global.js. This is in keeping with the
idea of progressive enhancement.

To test, be sure to clear your browser cache after applying the patch.

- Test the help link.
- Test the logout link with the intranetbookbag preference on and off.
- Open a patron's account and click "search to hold." Log out, and log
  in again. Koha should not remember the patron you chose before
  logging out (as seen from a search results page).

Revised for current master.
---
 .../intranet-tmpl/prog/en/includes/header.inc      |   10 ++--------
 koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js |   18 ++++++++++++++++++
 2 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc
index 4a26d79..7b69a68 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc
@@ -72,21 +72,15 @@
                      <a class="toplinks" href="/cgi-bin/koha/circ/selectbranchprinter.pl">Set library</a>
                   </li>
            [% END %]
-           [% IF ( intranetbookbag ) %]
               <li>
-                  <a class="toplinks" href="/cgi-bin/koha/mainpage.pl?logout.x=1" onclick="clearHoldFor(); delBasket('main', true);">Log out</a>
+                  <a id="logout" class="toplinks" href="/cgi-bin/koha/mainpage.pl?logout.x=1">Log out</a>
               </li>
            [% ELSE %]
-              <li>
-                  <a class="toplinks" href="/cgi-bin/koha/mainpage.pl?logout.x=1" onclick="clearHoldFor();">Log out</a>
-              </li>
-           [% END %]
-           [% ELSE %]
               You are not logged in |
            [% END %]
           </ul>
           <li>
-         <a class="toplinks" href="/cgi-bin/koha/help.pl" id="helper" onclick="var link=window.open('','Koha_Help','width=600,height=600,toolbar=false,scrollbars=yes'); link.location='/cgi-bin/koha/help.pl'; return false;">Help</a>
+         <a class="toplinks" href="/cgi-bin/koha/help.pl" id="helper">Help</a>
           </li>
         </li>
       </ul>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js
index 2bf385f..8c50dca 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js
+++ b/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js
@@ -11,6 +11,13 @@ function _(s) { return s; } // dummy function for gettext
     if($("#header_search #catalog_search").length > 0){ $(document).bind('keydown','Alt+q',function (){ $("#header_search").tabs("select","#catalog_search"); $("#search-form").focus(); }); } else { $(document).bind('keydown','Alt+q',function(){ location.href="/cgi-bin/koha/catalogue/search.pl"; }); }
     $(".focus").focus();
     $(".validated").validate();
+    $("#logout").on("click",function(){
+        logOut();
+    });
+    $("#helper").on("click",function(){
+        openHelp();
+        return false;
+    });
 });
 
 
@@ -37,6 +44,17 @@ function clearHoldFor(){
 	$.cookie("holdfor",null, { path: "/", expires: 0 });
 }
 
+function logOut(){
+    if( typeof delBasket == 'function' ){
+        delBasket('main', true);
+    }
+    clearHoldFor();
+}
+
+function openHelp(){
+    openWindow("/cgi-bin/koha/help.pl","Koha help",600,600);
+}
+
 jQuery.fn.preventDoubleFormSubmit = function() {
     jQuery(this).submit(function() {
     $("body, form input[type='submit'], form button[type='submit'], form a").addClass('waiting');
-- 
1.7.9.5


More information about the Koha-patches mailing list