Minor JavaScript fixes
authorJesse Weaver <pianohacker@gmail.com>
Tue, 20 Oct 2009 18:18:09 +0000 (12:18 -0600)
committerJesse Weaver <pianohacker@gmail.com>
Tue, 20 Oct 2009 18:18:09 +0000 (12:18 -0600)
Move some JavaScript to the external file, and make sure that the
modified warning doesn't pop up when "Cancel" is used.

koha-tmpl/intranet-tmpl/prog/en/js/pages/preferences.js
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tmpl

index bbc0b1b..e1688bd 100644 (file)
@@ -57,4 +57,20 @@ $( document ).ready( function () {
             return _( "You have made changes to system preferences." );
         }
     }
             return _( "You have made changes to system preferences." );
         }
     }
+
+    $("h3").attr("class","expanded").attr("title",_("Click to expand this section"));
+    var collapsible = $(".collapsed,.expanded");
+
+    $(collapsible).toggle(
+        function () {
+            $(this).addClass("collapsed").removeClass("expanded").attr("title",_("Click to expand this section"));
+            $(this).next("table").hide();
+        },
+        function () {
+            $(this).addClass("expanded").removeClass("collapsed").attr("title",_("Click to collapse this section"));
+            $(this).next("table").show();
+        }
+    );
+
+    $( '.prefs-tab .action .cancel' ).click( function () { KOHA.Preferences.Modified = false } );
 } );
 } );
index 1e7c116..1f9c66c 100644 (file)
@@ -8,23 +8,8 @@
 <script src="<!-- TMPL_VAR NAME="themelang" -->/js/pages/preferences.js" type="text/javascript"></script>
 <script src="<!-- TMPL_VAR NAME="themelang" -->/lib/jquery/plugins/jquery.highlight-3.js" type="text/javascript"></script>
 <script type="text/javascript">
 <script src="<!-- TMPL_VAR NAME="themelang" -->/js/pages/preferences.js" type="text/javascript"></script>
 <script src="<!-- TMPL_VAR NAME="themelang" -->/lib/jquery/plugins/jquery.highlight-3.js" type="text/javascript"></script>
 <script type="text/javascript">
-//<![CDATA[
-       $(document).ready(function(){
-               $("h3").attr("class","expanded").attr("title",_("Click to expand this section"));
-               var collapsible = $(".collapsed,.expanded");
-       
-           $(collapsible).toggle(function () {
-            $(this).addClass("collapsed").removeClass("expanded").attr("title",_("Click to expand this section"));
-         $(this).next("table").hide();
-             },
-             function () {
-               $(this).addClass("expanded").removeClass("collapsed").attr("title",_("Click to collapse this section"));
-               $(this).next("table").show();
-             }
-    );
-
-               
-       });
+ //<![CDATA[
+    // This is here because of its dependence on template variables, everything else should go in js/pages/preferences.js - jpw
     <!-- TMPL_IF NAME="searchfield" -->
     var to_highlight = "<!-- TMPL_VAR NAME="searchfield" ESCAPE="JS"-->";
 
     <!-- TMPL_IF NAME="searchfield" -->
     var to_highlight = "<!-- TMPL_VAR NAME="searchfield" ESCAPE="JS"-->";