Koha/koha-tmpl/intranet-tmpl/prog/js/tools-menu.js
Owen Leonard 0254b4e87d Bug 20931: JS error "ReferenceError: $ is not defined" when CircSidebar is turned on
This patch reorganizes the way sidebar menus get highlighted based on
the current page. A global function is added to handle most cases.
Individual menu-handling scripts have been modified to handle only the
edge cases which aren't covered by the global one.

A new class is added to the global CSS file so that highlighted menu
links can be custom-styled.

To test, apply the patch and clear your cache if necessary.

View various pages to confirm that current-page-highlighting in the
sidebar menu is working correctly and that there are no JS errors in the
browser console. For example:

 - Administration -> Currencies and exchange rates.
 - Acquisitions -> Invoices
 - Tools -> Patron lists
 - Tools -> Export

And with CircSidebar turned on test various circulation pages, e.g.

 - Circulation -> Set library

Signed-off-by: Charles Farmer <charles.farmer@inLibro.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-07-02 11:10:00 +00:00

20 lines
1.3 KiB
JavaScript

$(document).ready(function() {
var path = location.pathname.substring(1);
if (path.indexOf("labels") >= 0 && path.indexOf("spine") < 0 ) {
$('#navmenulist a[href$="/cgi-bin/koha/labels/label-home.pl"]').addClass("current");
} else if (path.indexOf("patroncards") >= 0 ) {
$('#navmenulist a[href$="/cgi-bin/koha/patroncards/home.pl"]').addClass("current");
} else if (path.indexOf("clubs") >= 0 ) {
$('#navmenulist a[href$="/cgi-bin/koha/clubs/clubs.pl"]').addClass("current");
} else if (path.indexOf("patron_lists") >= 0 ) {
$('#navmenulist a[href$="/cgi-bin/koha/patron_lists/lists.pl"]').addClass("current");
} else if (path.indexOf("rotating_collections") >= 0 ){
$('#navmenulist a[href$="/cgi-bin/koha/rotating_collections/rotatingCollections.pl"]').addClass("current");
} else if ((path+location.search).indexOf("batchMod.pl?del=1") >= 0 ) {
$('#navmenulist a[href$="/cgi-bin/koha/tools/batchMod.pl?del=1"]').addClass("current");
} else if (path.indexOf("quotes-upload.pl") >= 0 ){
$('#navmenulist a[href$="/cgi-bin/koha/tools/quotes.pl"]').addClass("current");
} else if (path.indexOf("plugins") >= 0 ) {
$('#navmenulist a[href$="/cgi-bin/koha/plugins/plugins-home.pl?method=tool"]').addClass("current");
}
});