diff options
Diffstat (limited to 'plugins/CoreHome/templates/menu.js')
-rw-r--r-- | plugins/CoreHome/templates/menu.js | 64 |
1 files changed, 27 insertions, 37 deletions
diff --git a/plugins/CoreHome/templates/menu.js b/plugins/CoreHome/templates/menu.js index d9067268c5..3be160b1ca 100644 --- a/plugins/CoreHome/templates/menu.js +++ b/plugins/CoreHome/templates/menu.js @@ -5,81 +5,72 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ -function menu() -{ +function menu() { this.param = {}; } menu.prototype = -{ +{ resetTimer: null, - - overMainLI: function () - { + + overMainLI: function () { $(this).siblings().removeClass('sfHover'); $(this).addClass('sfHover'); clearTimeout(menu.prototype.resetTimer); }, - - outMainLI: function () - { + + outMainLI: function () { clearTimeout(menu.prototype.resetTimer); - menu.prototype.resetTimer = setTimeout(function(){ + menu.prototype.resetTimer = setTimeout(function () { $('.nav>.sfHover').removeClass('sfHover'); $('.nav>.sfActive').addClass('sfHover'); }, 2000); }, - - onItemClick: function (item) - { + + onItemClick: function (item) { $('ul.nav').trigger('piwikSwitchPage', item); broadcast.propagateAjax($(item).attr('name')); return false; }, - - init: function() - { + + init: function () { this.menuNode = $('.nav'); - + //sub LI auto height - $('.nav li li a').each(function(){$(this).css({width:$(this).width()+30, paddingLeft:0, paddingRight:0});}); - + $('.nav li li a').each(function () {$(this).css({width: $(this).width() + 30, paddingLeft: 0, paddingRight: 0});}); + this.menuNode.find("li:has(ul)").hover(this.overMainLI, this.outMainLI); - + // add id to all li menu to support menu identification. // for all sub menu we want to have a unique id based on their module and action // for main menu we want to add just the module as its id. - this.menuNode.find('li').each(function(){ + this.menuNode.find('li').each(function () { var url = $(this).find('a').attr('name'); - var module = broadcast.getValueFromUrl("module",url); - var action = broadcast.getValueFromUrl("action",url); - var moduleId = broadcast.getValueFromUrl("idGoal",url) || broadcast.getValueFromUrl("idDashboard",url); + var module = broadcast.getValueFromUrl("module", url); + var action = broadcast.getValueFromUrl("action", url); + var moduleId = broadcast.getValueFromUrl("idGoal", url) || broadcast.getValueFromUrl("idDashboard", url); var main_menu = $(this).parent().hasClass('nav') ? true : false; - if(main_menu) - { + if (main_menu) { $(this).attr({id: module}); } // if there's a idGoal or idDashboard, use this in the ID - else if(moduleId != '') - { + else if (moduleId != '') { $(this).attr({id: module + '_' + action + '_' + moduleId}); } - else - { + else { $(this).attr({id: module + '_' + action}); } }); }, - activateMenu : function(module,action,id) - { + activateMenu: function (module, action, id) { this.menuNode.find('li').removeClass('sfHover').removeClass('sfActive'); var $li = this.getSubmenuID(module, id, action); var mainLi = $("#" + module); - if(!mainLi.length) { + if (!mainLi.length) { mainLi = $li.parents('li'); } - + mainLi.addClass('sfActive').addClass('sfHover'); $li.addClass('sfHover'); @@ -101,9 +92,8 @@ menu.prototype = return $li; }, - loadFirstSection: function() - { - if(broadcast.isHashExists() == false) { + loadFirstSection: function () { + if (broadcast.isHashExists() == false) { $('li:first a:first', this.menuNode).click().addClass('sfHover').addClass('sfActive'); } } |