MediaWiki:Common.js
Jump to navigation
Jump to search
Note: After saving, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
/* Any JavaScript here will be loaded for all users on every page load. */
// When the document loads do everything inside here ...
$(document).ready(function(){
// hide all nav-level2 content
$(".nav-level2").hide();
/*
// determine current url's place within the site navigation
if (decodeURIComponent(window.location.pathname).toLowerCase().indexOf("/wiki/revising_legislation") != -1) {
$.cookie("currentNavParent", "nav-1", { path: "/" });
} else if (decodeURIComponent(window.location.pathname).toLowerCase().indexOf("/wiki/editorial_principles") != -1) {
$.cookie("currentNavParent", "nav-2", { path: "/" });
} else if (decodeURIComponent(window.location.pathname).toLowerCase().indexOf("/wiki/preparation_tasks") != -1) {
$.cookie("currentNavParent", "nav-3", { path: "/" });
} else if (decodeURIComponent(window.location.pathname).toLowerCase().indexOf("/wiki/editorial_update") != -1) {
$.cookie("currentNavParent", "nav-4", { path: "/" });
} else if (decodeURIComponent(window.location.pathname).toLowerCase().indexOf("/wiki/corrective_work") != -1) {
$.cookie("currentNavParent", "nav-5", { path: "/" });
} else {
$("ul.nav-level1 li a").removeClass("active");
$("ul.nav-level2").removeClass("active");
$.cookie("showNavigationDrawer", "false", { path: "/" });
}
*/
/*
// if cookie has been set to show navigation drawer then display relevant nav-level2 items
if ($.cookie("showNavigationDrawer") == "true") {
$("#"+$.cookie("currentNavParent")).addClass("active");
$("ul.nav-level2."+$.cookie("currentNavParent")).addClass("active");
$("ul.nav-level2."+$.cookie("currentNavParent")).show();
}
*/
// When a top-level link from the navigation is clicked
$("nav > ul > li > a").click(function() {
var active_link = $(this).attr("id");
// if the nav-level1 item clicked was already active then remove its active status, slide up navigation drawer, and update cookie
if ($(this).hasClass("active")) {
$("ul.nav-level1 li a").removeClass("active");
$("ul.nav-level2.active").removeClass("active");
$("ul.nav-level2").slideUp();
$.cookie('showNavigationDrawer', 'false', { path: "/" });
}
// else slide up previously active nav-level2 content, set the new active nav-level1 item, slide down navigation drawer, and update cookie
else {
$("ul.nav-level2.active").hide();
$("ul.nav-level1 li a").removeClass("active");
$("ul.nav-level2").removeClass("active");
$(this).addClass("active");
$("ul.nav-level2."+active_link).addClass("active");
$("ul.nav-level2."+active_link).slideDown();
$.cookie('showNavigationDrawer', 'true', { path: "/" });
}
});
});