Bug 23410: Add submenus to system preferences sidebar menu
[koha.git] / koha-tmpl / intranet-tmpl / prog / js / pages / preferences.js
index 6db43b2..2e83327 100644 (file)
@@ -150,7 +150,8 @@ $( document ).ready( function () {
     var collapsible = $(".collapsed,.expanded");
 
     $(collapsible).on("click",function(){
-        var panel = $(this).next("div");
+        var h3Id = $(this).attr("id");
+        var panel = $("#collapse_" + h3Id);
         if(panel.is(":visible")){
             $(this).addClass("collapsed").removeClass("expanded").attr("title",MSG_CLICK_TO_EXPAND);
             panel.hide();
@@ -160,6 +161,18 @@ $( document ).ready( function () {
         }
     });
 
+    $(".pref_sublink").on("click", function(){
+        /* If the user clicks a sub-menu link in the sidebar,
+           check to see if it is collapsed. If so, expand it */
+        var href = $(this).attr("href");
+        href = href.replace("#","");
+        var panel = $("#collapse_" + href );
+        if( panel.is(":hidden") ){
+            $("#" + href ).addClass("expanded").removeClass("collapsed").attr("title",MSG_CLICK_TO_COLLAPSE);
+            panel.show();
+        }
+    });
+
     if ( to_highlight ) {
         var words = to_highlight.split( ' ' );
         $( '.prefs-tab table' ).find( 'td, th' ).not( '.name-cell' ).each( function ( i, td ) {