From 875d42c0a663a58cc198f3ef197474657550bd67 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 21 Nov 2016 14:34:58 +0100 Subject: [PATCH] Revert "Merge branch 'bugfix/always-use-the-jquery-find-method-w/-node-context-10704'" This reverts commit f517c62fdec880d5b905212ef4dbfe23a5cd033e, reversing changes made to d1fd7e4be78f3dda9734027dda53114b71a7a46d. refs #10704 --- modules/doc/public/js/module.js | 2 +- public/js/icinga/behavior/actiontable.js | 8 +++---- public/js/icinga/behavior/navigation.js | 6 ++--- public/js/icinga/behavior/tooltip.js | 10 ++++----- public/js/icinga/events.js | 18 +++++++-------- public/js/icinga/loader.js | 28 ++++++++++++------------ public/js/icinga/ui.js | 2 +- 7 files changed, 37 insertions(+), 37 deletions(-) diff --git a/modules/doc/public/js/module.js b/modules/doc/public/js/module.js index f187be503..d5571eedd 100644 --- a/modules/doc/public/js/module.js +++ b/modules/doc/public/js/module.js @@ -18,7 +18,7 @@ rendered: function(event) { var $container = $(event.currentTarget); - if ($($container).find('> .content.styleguide').length) { + if ($('> .content.styleguide', $container).length) { $container.removeClass('module-doc'); } } diff --git a/public/js/icinga/behavior/actiontable.js b/public/js/icinga/behavior/actiontable.js index 0fac0cabc..a7fc06a36 100644 --- a/public/js/icinga/behavior/actiontable.js +++ b/public/js/icinga/behavior/actiontable.js @@ -417,11 +417,11 @@ var _this = evt.data.self; // initialize all rows with the correct row action - $(container).find('table.action tr, table.table-row-selectable tr').each(function(idx, el) { + $('table.action tr, table.table-row-selectable tr', container).each(function(idx, el) { // decide which row action to use: links declared with the class rowaction take // the highest precedence before hrefs defined in the tr itself and regular links - var $a = $(el).find('a[href].rowaction').first(); + var $a = $('a[href].rowaction', el).first(); if ($a.length) { // TODO: Find out whether we leak memory on IE with this: $(el).attr('href', $a.attr('href')); @@ -430,14 +430,14 @@ if ($(el).attr('href') && $(el).attr('href').length) { return; } - $a = $(el).find('a[href]').first(); + $a = $('a[href]', el).first(); if ($a.length) { $(el).attr('href', $a.attr('href')); } }); // IE will not ignore user-select unless we cancel selectstart - $(container).find('table.action.multiselect tr, table.table-row-selectable.multiselect tr').each(function(idx, el) { + $('table.action.multiselect tr, table.table-row-selectable.multiselect tr', container).each(function(idx, el) { $(el).on('selectstart', false); }); diff --git a/public/js/icinga/behavior/navigation.js b/public/js/icinga/behavior/navigation.js index 3225c73db..2da6bc87d 100644 --- a/public/js/icinga/behavior/navigation.js +++ b/public/js/icinga/behavior/navigation.js @@ -56,7 +56,7 @@ // 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'); + var $menus = $('#menu li.active', e.target); if ($menus.length) { $menus.each(function() { _this.setActive($(this)); @@ -179,10 +179,10 @@ */ Navigation.prototype.clear = function() { // menu items - $(this.element).find('#menu li.active').removeClass('active'); + $('#menu li.active', this.element).removeClass('active'); // search fields - $(this.element).find('#menu input.active').removeClass('active'); + $('#menu input.active', this.element).removeClass('active'); }; /** diff --git a/public/js/icinga/behavior/tooltip.js b/public/js/icinga/behavior/tooltip.js index d9fa209e2..abc1d4952 100644 --- a/public/js/icinga/behavior/tooltip.js +++ b/public/js/icinga/behavior/tooltip.js @@ -23,13 +23,13 @@ Tooltip.prototype.onRendered = function(evt) { var _this = evt.data.self, icinga = evt.data.icinga, el = evt.target; - $(el).find('[title]').each(function () { + $('[title]', el).each(function () { var $el = $(this); $el.attr('title', $el.data('title-rich') || $el.attr('title')); }); - $(el).find('svg .chart-data').tipsy({ gravity: 'se', html: true }); - $(el).find('i[title]').tipsy({ gravity: $.fn.tipsy.autoNS, offset: 2 }); - $(el).find('[title]').each(function (i, el) { + $('svg .chart-data', el).tipsy({ gravity: 'se', html: true }); + $('i[title]', el).tipsy({ gravity: $.fn.tipsy.autoNS, offset: 2 }); + $('[title]', el).each(function (i, el) { var $el = $(el); var delay, gravity; if ($el.data('tooltip-delay') !== undefined) { @@ -54,7 +54,7 @@ // migrate or remove all orphaned tooltips $('.tipsy').each(function () { - var arrow = $(this).find('.tipsy-arrow')[0]; + var arrow = $('.tipsy-arrow', this)[0]; if (!icinga.utils.elementsOverlap(arrow, $('#main')[0])) { $(this).remove(); return; diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index 1d9a52d97..340d652b1 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -51,7 +51,7 @@ } } - $target.find('.icinga-module').each(function(idx, mod) { + $('.icinga-module', $target).each(function(idx, mod) { moduleName = $(mod).data('icingaModule'); if (icinga.hasModule(moduleName) && !icinga.isLoadedModule(moduleName)) { loaded |= icinga.loadModule(moduleName); @@ -82,7 +82,7 @@ _this.initializeModules = true; } - $target.find('.dashboard > div').each(function(idx, el) { + $('.dashboard > div', $target).each(function(idx, el) { var $element = $(el); var $url = $element.data('icingaUrl'); if (typeof $url !== 'undefined') { @@ -90,7 +90,7 @@ } }); - var $searchField = $target.find('#menu input.search'); + var $searchField = $('#menu input.search', $target); // Remember initial search field value if any if ($searchField.length && $searchField.val().length) { _this.searchValue = $searchField.val(); @@ -154,7 +154,7 @@ treeNodeToggle: function () { var $parent = $(this).closest('li'); if ($parent.hasClass('collapsed')) { - $parent.find('li').addClass('collapsed'); + $('li', $parent).addClass('collapsed'); $parent.removeClass('collapsed'); } else { $parent.addClass('collapsed'); @@ -219,7 +219,7 @@ var url = $form.attr('action'); var method = $form.attr('method'); var encoding = $form.attr('enctype'); - var $button = $form.find('input[type=submit]:focus').add('button[type=submit]:focus', $form); + var $button = $('input[type=submit]:focus', $form).add('button[type=submit]:focus', $form); var progressTimer; var $target; var data; @@ -268,7 +268,7 @@ } if ($button.length === 0) { - $button = $form.find('input[type=submit]').add('button[type=submit]', $form).first(); + $button = $('input[type=submit]', $form).add('button[type=submit]', $form).first(); } if ($button.length) { @@ -389,14 +389,14 @@ } }, null, 100); } else if ($button.length && $button.next().hasClass('spinner')) { - $button.next().find('i').addClass('active'); + $('i', $button.next()).addClass('active'); } else if ($form.attr('data-progress-element')) { var $progressElement = $('#' + $form.attr('data-progress-element')); if ($progressElement.length) { if ($progressElement.hasClass('spinner')) { - $progressElement.find('i').addClass('active'); + $('i', $progressElement).addClass('active'); } else { - $progressElement.find('i.spinner').addClass('active'); + $('i.spinner', $progressElement).addClass('active'); } } } diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index af44a572e..096606291 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -407,7 +407,7 @@ return; var _this = this; - $container.find('img.icon').each(function(idx, img) { + $('img.icon', $container).each(function(idx, img) { var src = $(img).attr('src'); if (typeof _this.iconCache[src] !== 'undefined') { return; @@ -453,7 +453,7 @@ if (req.autorefresh) { // TODO: next container url - active = req.$target.find('[href].active').attr('href'); + active = $('[href].active', req.$target).attr('href'); } var target = req.getResponseHeader('X-Icinga-Container'); @@ -519,26 +519,26 @@ // Handle search requests, still hardcoded. if (req.url.match(/^\/search/) && req.$target.data('icingaUrl').match(/^\/search/) && - $resp.find('.dashboard').length > 0 && - req.$target.find('.dashboard .container').length > 0) + $('.dashboard', $resp).length > 0 && + $('.dashboard .container', req.$target).length > 0) { // TODO: We need dashboard pane and container identifiers (not ids) var targets = []; - req.$target.find('.dashboard .container').each(function (idx, el) { + $('.dashboard .container', req.$target).each(function (idx, el) { targets.push($(el)); }); var i = 0; // Searching for '.dashboard .container' in $resp doesn't dork?! - $resp.find('.dashboard .container').each(function (idx, el) { + $('.dashboard .container', $resp).each(function (idx, el) { var $el = $(el); if ($el.hasClass('dashboard')) { return; } var url = $el.data('icingaUrl'); targets[i].data('icingaUrl', url); - var title = $el.find('h1').first(); - $(targets[i]).find('h1').first().replaceWith(title); + var title = $('h1', $el).first(); + $('h1', targets[i]).first().replaceWith(title); _this.loadUrl(url, targets[i]); i++; @@ -595,7 +595,7 @@ var $el = $(el); if ($el.closest('#menu').length) { if ($el.is('form')) { - $el.find('input').addClass('active'); + $('input', $el).addClass('active'); } // Interrupt .each, only one menu item shall be active return false; @@ -797,20 +797,20 @@ // event.preventDefault(); // }); - $container.find('.container').each(function() { + $('.container', $container).each(function() { _this.stopPendingRequestsFor($(this)); }); if (false && - $content.find('.dashboard').length > 0 && - $container.find('.dashboard').length === 0 + $('.dashboard', $content).length > 0 && + $('.dashboard', $container).length === 0 ) { - // $content.find('.dashboard') + // $('.dashboard', $content) // $container.html(content); } else { if ($container.closest('.dashboard').length) { - var title = $container.find('h1').first().detach(); + var title = $('h1', $container).first().detach(); $container.html(title).append(content); } else if (action === 'replace') { $container.html(content); diff --git a/public/js/icinga/ui.js b/public/js/icinga/ui.js index 08fbff07e..feaababd7 100644 --- a/public/js/icinga/ui.js +++ b/public/js/icinga/ui.js @@ -458,7 +458,7 @@ * Initialize all TriStateCheckboxes in the given html */ initializeTriStates: function ($html) { - $html.find('div.tristate').each(function(index, item) { + $('div.tristate', $html).each(function(index, item) { var $target = $(item); // hide input boxess and remove text nodes