From e9e66930d56b8e07c1465462bf7e7be76d328855 Mon Sep 17 00:00:00 2001 From: Eric Lippmann <eric.lippmann@icinga.com> Date: Mon, 28 Nov 2016 12:13:10 +0100 Subject: [PATCH 1/3] Remove obsolete dropdown methods from the navigation behavior --- public/js/icinga/behavior/navigation.js | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/public/js/icinga/behavior/navigation.js b/public/js/icinga/behavior/navigation.js index 48f192347..8ac0d3161 100644 --- a/public/js/icinga/behavior/navigation.js +++ b/public/js/icinga/behavior/navigation.js @@ -10,8 +10,6 @@ Icinga.EventListener.call(this, icinga); this.on('click', '#menu a', this.linkClicked, this); this.on('click', '#menu tr[href]', this.linkClicked, this); - this.on('mouseenter', 'li.dropdown', this.dropdownHover, this); - this.on('mouseleave', 'li.dropdown', this.dropdownLeave, this); this.on('mouseenter', '#menu > nav > ul > li', this.menuTitleHovered, this); this.on('mouseleave', '#sidebar', this.leaveSidebar, this); this.on('rendered', this.onRendered, this); @@ -350,23 +348,6 @@ } }; - Navigation.prototype.dropdownHover = function () { - $(this).addClass('hover'); - }; - - Navigation.prototype.dropdownLeave = function (event) { - var $li = $(this), - self = event.data.self; - setTimeout(function () { - // TODO: make this behave well together with keyboard navigation - try { - if (!$li.is('li:hover') /*&& ! $li.find('a:focus')*/) { - $li.removeClass('hover'); - } - } catch(e) { /* Bypass because if IE8 */ } - }, 300); - self.hovered = null; - }; Icinga.Behaviors.Navigation = Navigation; }) (Icinga, jQuery); From 0e69ce4544f6c41b3272f372882b84a1b8f02d6d Mon Sep 17 00:00:00 2001 From: Eric Lippmann <eric.lippmann@icinga.com> Date: Thu, 8 Dec 2016 16:55:33 +0100 Subject: [PATCH 2/3] Remove obsolete class dropdown from the close-container-control --- library/Icinga/Web/Widget/Tabs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Icinga/Web/Widget/Tabs.php b/library/Icinga/Web/Widget/Tabs.php index 69a8fd396..2bc296939 100644 --- a/library/Icinga/Web/Widget/Tabs.php +++ b/library/Icinga/Web/Widget/Tabs.php @@ -49,7 +49,7 @@ EOT; * @var string */ private $closeTpl = <<< 'EOT' -<li class="dropdown" style="float: right;"> +<li style="float: right;"> <a href="#" title="{TITLE}" aria-label="{TITLE}" class="close-container-control"> <i aria-hidden="true" class="icon-cancel"></i> </a> From 177d4c770d31074235e828cfe1d95887850abd7a Mon Sep 17 00:00:00 2001 From: Eric Lippmann <eric.lippmann@icinga.com> Date: Thu, 8 Dec 2016 16:56:25 +0100 Subject: [PATCH 3/3] JS: Optimize navigation behavior by using the #menu selector for the onRendered event refs #10704 --- public/js/icinga/behavior/navigation.js | 28 ++++++++++++++----------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/public/js/icinga/behavior/navigation.js b/public/js/icinga/behavior/navigation.js index 8ac0d3161..77e542efa 100644 --- a/public/js/icinga/behavior/navigation.js +++ b/public/js/icinga/behavior/navigation.js @@ -12,7 +12,7 @@ this.on('click', '#menu tr[href]', this.linkClicked, this); this.on('mouseenter', '#menu > nav > ul > li', this.menuTitleHovered, this); this.on('mouseleave', '#sidebar', this.leaveSidebar, this); - this.on('rendered', this.onRendered, this); + this.on('rendered', '#menu', this.onRendered, this); /** * The DOM-Path of the active item @@ -33,9 +33,11 @@ this.hovered = null; /** - * @type {HTMLElement} + * The menu + * + * @type {jQuery} */ - this.element = null; + this.$menu = null; }; Navigation.prototype = new Icinga.EventListener(); @@ -47,16 +49,18 @@ Navigation.prototype.onRendered = function(e) { var _this = e.data.self; - this.element = e.target; + if (! _this.$menu) { + _this.$menu = $(e.target); + } if (! _this.active) { // There is no stored menu item, therefore it is assumed that this is the first rendering // of the navigation after the page has been opened. // initialise the menu selected by the backend as active. - var $menus = $(e.target).find('#menu li.active'); - if ($menus.length) { - $menus.each(function() { + var $active = _this.$menu.find('li.active'); + if ($active.length) { + $active.each(function() { _this.setActive($(this)); }); } else { @@ -145,17 +149,17 @@ Navigation.prototype.setActiveByUrl = function(url) { // try to active the first item that has an exact URL match - this.setActive($('#menu [href="' + url + '"]')); + this.setActive(this.$menu.find('[href="' + url + '"]')); // the url may point to the search field, which must be activated too if (! this.active) { - this.setActive($('#menu form[action="' + this.icinga.utils.parseUrl(url).path + '"]')); + this.setActive(this.$menu.find('form[action="' + this.icinga.utils.parseUrl(url).path + '"]')); } // some urls may have custom filters which won't match any menu item, in that case search // for a menu item that points to the base action without any filters if (! this.active) { - this.setActive($('#menu [href="' + this.icinga.utils.parseUrl(url).path + '"]').first()); + this.setActive(this.$menu.find('[href="' + this.icinga.utils.parseUrl(url).path + '"]').first()); } }; @@ -177,10 +181,10 @@ */ Navigation.prototype.clear = function() { // menu items - $(this.element).find('#menu li.active').removeClass('active'); + this.$menu.find('li.active').removeClass('active'); // search fields - $(this.element).find('#menu input.active').removeClass('active'); + this.$menu.find('input.active').removeClass('active'); }; /**