% environment.context_class.instance_eval { include ApplicationHelper } %> jQuery(document).ready(function($) { // rejigger the main-menu sub-menu functionality. $("#main-menu .toggler").remove(); // remove the togglers so they're inserted properly later. var toggler = $('' + I18n.t("label_menu_item_toggle") + '') .click(function(event) { var target = $(this); if (target.hasClass('toggler')) { var menuItemWrapper = target.parent(); var menuParent = menuItemWrapper.toggleClass('open').parent().find('ul').not('ul ul ul'); menuParent.mySlide(); if (menuItemWrapper.hasClass('open')) { menuParent.find('li > a:first').focus(); } } return false; }); $('#main-menu li > a').not('ul ul a').wrap('
'); $('#main-menu li:has(ul) .main-item-wrapper > a').not('ul ul a') // 1. unbind the current click functions .unbind('click') // 2. wrap each in a span that we'll use for the new click element .wrapInner('') // 3. reinsert the so that it sits outside of the above .after(toggler); // project menu // Users of some old IEs are out of luck ATM. A userData implementation // could be provided though, that would be great! var remember_menu_state; if (typeof window.sessionStorage !== 'undefined') { remember_menu_state = function (match) { if (typeof match === 'undefined') { return sessionStorage.getItem('openproject:navigation-toggle'); } else { return sessionStorage.setItem('openproject:navigation-toggle', match.length > 0 ? 'collapsed' : 'expanded'); } }; } else { remember_menu_state = function (match) { return false; }; } var toggle_navigation = function() { $('#wrapper').toggleClass('hidden-navigation'); $('#content, #breadcrumb').toggleClass('hidden-navigation'); $('#toggle-project-menu').removeAttr("style").toggleClass('show'); remember_menu_state($('#toggle-project-menu.show')); }; // register toggler, and toggle for the first time if remembered to be closed. jQuery('#toggle-project-menu .navigation-toggler').click(toggle_navigation); if ($('#main-menu').length > 0 && remember_menu_state() === "collapsed") { toggle_navigation(); } });