Merge branch 'bugfix/always-use-the-jquery-find-method-w/-node-context-10704'

fixes #10704
This commit is contained in:
Eric Lippmann 2016-11-21 14:33:43 +01:00
commit f517c62fde
7 changed files with 37 additions and 37 deletions

View File

@ -18,7 +18,7 @@
rendered: function(event) { rendered: function(event) {
var $container = $(event.currentTarget); var $container = $(event.currentTarget);
if ($('> .content.styleguide', $container).length) { if ($($container).find('> .content.styleguide').length) {
$container.removeClass('module-doc'); $container.removeClass('module-doc');
} }
} }

View File

@ -417,11 +417,11 @@
var _this = evt.data.self; var _this = evt.data.self;
// initialize all rows with the correct row action // initialize all rows with the correct row action
$('table.action tr, table.table-row-selectable tr', container).each(function(idx, el) { $(container).find('table.action tr, table.table-row-selectable tr').each(function(idx, el) {
// decide which row action to use: links declared with the class rowaction take // 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 // the highest precedence before hrefs defined in the tr itself and regular links
var $a = $('a[href].rowaction', el).first(); var $a = $(el).find('a[href].rowaction').first();
if ($a.length) { if ($a.length) {
// TODO: Find out whether we leak memory on IE with this: // TODO: Find out whether we leak memory on IE with this:
$(el).attr('href', $a.attr('href')); $(el).attr('href', $a.attr('href'));
@ -430,14 +430,14 @@
if ($(el).attr('href') && $(el).attr('href').length) { if ($(el).attr('href') && $(el).attr('href').length) {
return; return;
} }
$a = $('a[href]', el).first(); $a = $(el).find('a[href]').first();
if ($a.length) { if ($a.length) {
$(el).attr('href', $a.attr('href')); $(el).attr('href', $a.attr('href'));
} }
}); });
// IE will not ignore user-select unless we cancel selectstart // IE will not ignore user-select unless we cancel selectstart
$('table.action.multiselect tr, table.table-row-selectable.multiselect tr', container).each(function(idx, el) { $(container).find('table.action.multiselect tr, table.table-row-selectable.multiselect tr').each(function(idx, el) {
$(el).on('selectstart', false); $(el).on('selectstart', false);
}); });

View File

@ -56,7 +56,7 @@
// of the navigation after the page has been opened. // of the navigation after the page has been opened.
// initialise the menu selected by the backend as active. // initialise the menu selected by the backend as active.
var $menus = $('#menu li.active', e.target); var $menus = $(e.target).find('#menu li.active');
if ($menus.length) { if ($menus.length) {
$menus.each(function() { $menus.each(function() {
_this.setActive($(this)); _this.setActive($(this));
@ -179,10 +179,10 @@
*/ */
Navigation.prototype.clear = function() { Navigation.prototype.clear = function() {
// menu items // menu items
$('#menu li.active', this.element).removeClass('active'); $(this.element).find('#menu li.active').removeClass('active');
// search fields // search fields
$('#menu input.active', this.element).removeClass('active'); $(this.element).find('#menu input.active').removeClass('active');
}; };
/** /**

View File

@ -23,13 +23,13 @@
Tooltip.prototype.onRendered = function(evt) { Tooltip.prototype.onRendered = function(evt) {
var _this = evt.data.self, icinga = evt.data.icinga, el = evt.target; var _this = evt.data.self, icinga = evt.data.icinga, el = evt.target;
$('[title]', el).each(function () { $(el).find('[title]').each(function () {
var $el = $(this); var $el = $(this);
$el.attr('title', $el.data('title-rich') || $el.attr('title')); $el.attr('title', $el.data('title-rich') || $el.attr('title'));
}); });
$('svg .chart-data', el).tipsy({ gravity: 'se', html: true }); $(el).find('svg .chart-data').tipsy({ gravity: 'se', html: true });
$('i[title]', el).tipsy({ gravity: $.fn.tipsy.autoNS, offset: 2 }); $(el).find('i[title]').tipsy({ gravity: $.fn.tipsy.autoNS, offset: 2 });
$('[title]', el).each(function (i, el) { $(el).find('[title]').each(function (i, el) {
var $el = $(el); var $el = $(el);
var delay, gravity; var delay, gravity;
if ($el.data('tooltip-delay') !== undefined) { if ($el.data('tooltip-delay') !== undefined) {
@ -54,7 +54,7 @@
// migrate or remove all orphaned tooltips // migrate or remove all orphaned tooltips
$('.tipsy').each(function () { $('.tipsy').each(function () {
var arrow = $('.tipsy-arrow', this)[0]; var arrow = $(this).find('.tipsy-arrow')[0];
if (!icinga.utils.elementsOverlap(arrow, $('#main')[0])) { if (!icinga.utils.elementsOverlap(arrow, $('#main')[0])) {
$(this).remove(); $(this).remove();
return; return;

View File

@ -51,7 +51,7 @@
} }
} }
$('.icinga-module', $target).each(function(idx, mod) { $target.find('.icinga-module').each(function(idx, mod) {
moduleName = $(mod).data('icingaModule'); moduleName = $(mod).data('icingaModule');
if (icinga.hasModule(moduleName) && !icinga.isLoadedModule(moduleName)) { if (icinga.hasModule(moduleName) && !icinga.isLoadedModule(moduleName)) {
loaded |= icinga.loadModule(moduleName); loaded |= icinga.loadModule(moduleName);
@ -82,7 +82,7 @@
_this.initializeModules = true; _this.initializeModules = true;
} }
$('.dashboard > div', $target).each(function(idx, el) { $target.find('.dashboard > div').each(function(idx, el) {
var $element = $(el); var $element = $(el);
var $url = $element.data('icingaUrl'); var $url = $element.data('icingaUrl');
if (typeof $url !== 'undefined') { if (typeof $url !== 'undefined') {
@ -90,7 +90,7 @@
} }
}); });
var $searchField = $('#menu input.search', $target); var $searchField = $target.find('#menu input.search');
// Remember initial search field value if any // Remember initial search field value if any
if ($searchField.length && $searchField.val().length) { if ($searchField.length && $searchField.val().length) {
_this.searchValue = $searchField.val(); _this.searchValue = $searchField.val();
@ -154,7 +154,7 @@
treeNodeToggle: function () { treeNodeToggle: function () {
var $parent = $(this).closest('li'); var $parent = $(this).closest('li');
if ($parent.hasClass('collapsed')) { if ($parent.hasClass('collapsed')) {
$('li', $parent).addClass('collapsed'); $parent.find('li').addClass('collapsed');
$parent.removeClass('collapsed'); $parent.removeClass('collapsed');
} else { } else {
$parent.addClass('collapsed'); $parent.addClass('collapsed');
@ -219,7 +219,7 @@
var url = $form.attr('action'); var url = $form.attr('action');
var method = $form.attr('method'); var method = $form.attr('method');
var encoding = $form.attr('enctype'); var encoding = $form.attr('enctype');
var $button = $('input[type=submit]:focus', $form).add('button[type=submit]:focus', $form); var $button = $form.find('input[type=submit]:focus').add('button[type=submit]:focus', $form);
var progressTimer; var progressTimer;
var $target; var $target;
var data; var data;
@ -268,7 +268,7 @@
} }
if ($button.length === 0) { if ($button.length === 0) {
$button = $('input[type=submit]', $form).add('button[type=submit]', $form).first(); $button = $form.find('input[type=submit]').add('button[type=submit]', $form).first();
} }
if ($button.length) { if ($button.length) {
@ -389,14 +389,14 @@
} }
}, null, 100); }, null, 100);
} else if ($button.length && $button.next().hasClass('spinner')) { } else if ($button.length && $button.next().hasClass('spinner')) {
$('i', $button.next()).addClass('active'); $button.next().find('i').addClass('active');
} else if ($form.attr('data-progress-element')) { } else if ($form.attr('data-progress-element')) {
var $progressElement = $('#' + $form.attr('data-progress-element')); var $progressElement = $('#' + $form.attr('data-progress-element'));
if ($progressElement.length) { if ($progressElement.length) {
if ($progressElement.hasClass('spinner')) { if ($progressElement.hasClass('spinner')) {
$('i', $progressElement).addClass('active'); $progressElement.find('i').addClass('active');
} else { } else {
$('i.spinner', $progressElement).addClass('active'); $progressElement.find('i.spinner').addClass('active');
} }
} }
} }

View File

@ -407,7 +407,7 @@
return; return;
var _this = this; var _this = this;
$('img.icon', $container).each(function(idx, img) { $container.find('img.icon').each(function(idx, img) {
var src = $(img).attr('src'); var src = $(img).attr('src');
if (typeof _this.iconCache[src] !== 'undefined') { if (typeof _this.iconCache[src] !== 'undefined') {
return; return;
@ -453,7 +453,7 @@
if (req.autorefresh) { if (req.autorefresh) {
// TODO: next container url // TODO: next container url
active = $('[href].active', req.$target).attr('href'); active = req.$target.find('[href].active').attr('href');
} }
var target = req.getResponseHeader('X-Icinga-Container'); var target = req.getResponseHeader('X-Icinga-Container');
@ -519,26 +519,26 @@
// Handle search requests, still hardcoded. // Handle search requests, still hardcoded.
if (req.url.match(/^\/search/) && if (req.url.match(/^\/search/) &&
req.$target.data('icingaUrl').match(/^\/search/) && req.$target.data('icingaUrl').match(/^\/search/) &&
$('.dashboard', $resp).length > 0 && $resp.find('.dashboard').length > 0 &&
$('.dashboard .container', req.$target).length > 0) req.$target.find('.dashboard .container').length > 0)
{ {
// TODO: We need dashboard pane and container identifiers (not ids) // TODO: We need dashboard pane and container identifiers (not ids)
var targets = []; var targets = [];
$('.dashboard .container', req.$target).each(function (idx, el) { req.$target.find('.dashboard .container').each(function (idx, el) {
targets.push($(el)); targets.push($(el));
}); });
var i = 0; var i = 0;
// Searching for '.dashboard .container' in $resp doesn't dork?! // Searching for '.dashboard .container' in $resp doesn't dork?!
$('.dashboard .container', $resp).each(function (idx, el) { $resp.find('.dashboard .container').each(function (idx, el) {
var $el = $(el); var $el = $(el);
if ($el.hasClass('dashboard')) { if ($el.hasClass('dashboard')) {
return; return;
} }
var url = $el.data('icingaUrl'); var url = $el.data('icingaUrl');
targets[i].data('icingaUrl', url); targets[i].data('icingaUrl', url);
var title = $('h1', $el).first(); var title = $el.find('h1').first();
$('h1', targets[i]).first().replaceWith(title); $(targets[i]).find('h1').first().replaceWith(title);
_this.loadUrl(url, targets[i]); _this.loadUrl(url, targets[i]);
i++; i++;
@ -595,7 +595,7 @@
var $el = $(el); var $el = $(el);
if ($el.closest('#menu').length) { if ($el.closest('#menu').length) {
if ($el.is('form')) { if ($el.is('form')) {
$('input', $el).addClass('active'); $el.find('input').addClass('active');
} }
// Interrupt .each, only one menu item shall be active // Interrupt .each, only one menu item shall be active
return false; return false;
@ -797,20 +797,20 @@
// event.preventDefault(); // event.preventDefault();
// }); // });
$('.container', $container).each(function() { $container.find('.container').each(function() {
_this.stopPendingRequestsFor($(this)); _this.stopPendingRequestsFor($(this));
}); });
if (false && if (false &&
$('.dashboard', $content).length > 0 && $content.find('.dashboard').length > 0 &&
$('.dashboard', $container).length === 0 $container.find('.dashboard').length === 0
) { ) {
// $('.dashboard', $content) // $content.find('.dashboard')
// $container.html(content); // $container.html(content);
} else { } else {
if ($container.closest('.dashboard').length) { if ($container.closest('.dashboard').length) {
var title = $('h1', $container).first().detach(); var title = $container.find('h1').first().detach();
$container.html(title).append(content); $container.html(title).append(content);
} else if (action === 'replace') { } else if (action === 'replace') {
$container.html(content); $container.html(content);

View File

@ -458,7 +458,7 @@
* Initialize all TriStateCheckboxes in the given html * Initialize all TriStateCheckboxes in the given html
*/ */
initializeTriStates: function ($html) { initializeTriStates: function ($html) {
$('div.tristate', $html).each(function(index, item) { $html.find('div.tristate').each(function(index, item) {
var $target = $(item); var $target = $(item);
// hide input boxess and remove text nodes // hide input boxess and remove text nodes