From f72411c6285a539ec234b5aaec5755ce614b41fb Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 1 Sep 2016 15:09:50 +0200 Subject: [PATCH 01/13] Avoid local variable name `self' in icinga.js refs #10703 --- public/js/icinga.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/public/js/icinga.js b/public/js/icinga.js index b52c19afc..6c5035912 100644 --- a/public/js/icinga.js +++ b/public/js/icinga.js @@ -69,10 +69,10 @@ */ this.modules = {}; - var self = this; + var _this = this; $(document).ready(function () { - self.initialize(); - self = null; + _this.initialize(); + _this = null; }); }; @@ -94,9 +94,9 @@ this.loader = new Icinga.Loader(this); this.events = new Icinga.Events(this); this.history = new Icinga.History(this); - var self = this; + var _this = this; $.each(Icinga.Behaviors, function(name, Behavior) { - self.behaviors[name.toLowerCase()] = new Behavior(self); + _this.behaviors[name.toLowerCase()] = new Behavior(_this); }); this.timezone.initialize(); From 311fd36326a83849fd49f8e71ff30a66606c4a46 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 1 Sep 2016 15:21:45 +0200 Subject: [PATCH 02/13] Avoid local variable name `self' in actiontable.js refs #10703 --- public/js/icinga/behavior/actiontable.js | 46 ++++++++++++------------ 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/public/js/icinga/behavior/actiontable.js b/public/js/icinga/behavior/actiontable.js index 8d8424999..155e549a0 100644 --- a/public/js/icinga/behavior/actiontable.js +++ b/public/js/icinga/behavior/actiontable.js @@ -185,12 +185,12 @@ filter.addClass('active'); return; } - var self = this; + var _this = this; this.rowActions() .filter( function (i, el) { - var params = self.getRowData($(el)); - if (self.icinga.utils.objectKeys(params).length !== self.icinga.utils.objectKeys(filter).length) { + var params = _this.getRowData($(el)); + if (_this.icinga.utils.objectKeys(params).length !== _this.icinga.utils.objectKeys(filter).length) { return false; } var equal = true; @@ -274,21 +274,21 @@ * @returns {String} The filter string */ toQuery: function() { - var self = this; + var _this = this; var selections = this.selections(); var queries = []; var utils = this.icinga.utils; if (selections.length === 1) { return $(selections[0]).attr('href'); - } else if (selections.length > 1 && self.hasMultiselection()) { + } else if (selections.length > 1 && _this.hasMultiselection()) { selections.each(function (i, el) { var parts = []; - $.each(self.getRowData($(el)), function(key, value) { + $.each(_this.getRowData($(el)), function(key, value) { parts.push(utils.fixedEncodeURIComponent(key) + '=' + utils.fixedEncodeURIComponent(value)); }); queries.push('(' + parts.join('&') + ')'); }); - return self.getMultiselectionUrl() + '?(' + queries.join('|') + ')'; + return _this.getMultiselectionUrl() + '?(' + queries.join('|') + ')'; } else { return ''; } @@ -304,9 +304,9 @@ var query = parseSelectionQuery(hash); if (query.length > 1 && this.hasMultiselectionUrl(this.icinga.utils.parseUrl(hash).path)) { // select all rows with matching filters - var self = this; + var _this = this; $.each(query, function(i, selection) { - self.select(selection); + _this.select(selection); }); } if (query.length > 1) { @@ -351,10 +351,10 @@ * Handle clicks on table rows and update selection and history */ ActionTable.prototype.onRowClicked = function (event) { - var self = event.data.self; + var _this = event.data.self; var $target = $(event.target); var $tr = $target.closest('tr'); - var table = new Selection($tr.closest('table.action, table.table-row-selectable')[0], self.icinga); + var table = new Selection($tr.closest('table.action, table.table-row-selectable')[0], _this.icinga); // some rows may contain form actions that trigger a different action, pass those through if (!$target.hasClass('rowaction') && $target.closest('form').length && @@ -390,18 +390,18 @@ var count = table.selections().length; if (count > 0) { var query = table.toQuery(); - self.icinga.loader.loadUrl(query, self.icinga.events.getLinkTargetFor($tr)); + _this.icinga.loader.loadUrl(query, _this.icinga.events.getLinkTargetFor($tr)); state += '#!' + query; } else { - if (self.icinga.events.getLinkTargetFor($tr).attr('id') === 'col2') { - self.icinga.ui.layout1col(); + if (_this.icinga.events.getLinkTargetFor($tr).attr('id') === 'col2') { + _this.icinga.ui.layout1col(); } } - self.icinga.history.pushUrl(state); + _this.icinga.history.pushUrl(state); // redraw all table selections - self.tables().each(function () { - new Selection(this, self.icinga).refresh(); + _this.tables().each(function () { + new Selection(this, _this.icinga).refresh(); }); // update selection info @@ -414,7 +414,7 @@ */ ActionTable.prototype.onRendered = function(evt) { var container = evt.target; - var self = evt.data.self; + var _this = evt.data.self; // initialize all rows with the correct row action $('table.action tr, table.table-row-selectable tr', container).each(function(idx, el) { @@ -442,19 +442,19 @@ }); // draw all active selections that have disappeared on reload - self.tables().each(function(i, el) { - new Selection(el, self.icinga).refresh(); + _this.tables().each(function(i, el) { + new Selection(el, _this.icinga).refresh(); }); // update displayed selection counter - var table = new Selection(self.tables(container).first()); + var table = new Selection(_this.tables(container).first()); $(container).find('.selection-info-count').text(table.selections().size()); }; ActionTable.prototype.clearAll = function () { - var self = this; + var _this = this; this.tables().each(function () { - new Selection(this, self.icinga).clear(); + new Selection(this, _this.icinga).clear(); }); }; From 0059622bba987663515f7fe034b7a7a1dcade549 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 1 Sep 2016 15:42:54 +0200 Subject: [PATCH 03/13] Avoid local variable name `self' in form.js refs #10703 --- public/js/icinga/behavior/form.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/public/js/icinga/behavior/form.js b/public/js/icinga/behavior/form.js index eae75168d..0acb3d3c6 100644 --- a/public/js/icinga/behavior/form.js +++ b/public/js/icinga/behavior/form.js @@ -71,15 +71,15 @@ var origFocus = document.activeElement; var containerId = $container.attr('id'); var icinga = this.icinga; - var self = this.icinga.behaviors.form; + var _this = this.icinga.behaviors.form; var changed = false; $container.find('form').each(function () { - var form = self.uniqueFormName(this); + var form = _this.uniqueFormName(this); if (autorefresh) { // check if an element in this container was changed $(this).find('input').each(function () { var name = this.name; - if (self.inputs[form] && self.inputs[form][name]) { + if (_this.inputs[form] && _this.inputs[form][name]) { icinga.logger.debug( 'form input: ' + form + '.' + name + ' was changed and aborts reload...' ); @@ -88,7 +88,7 @@ }); } else { // user-triggered reload, forget all changes to forms in this container - self.inputs[form] = null; + _this.inputs[form] = null; } }); if (changed) { From 0d7f8148dedea4abab88a5304b38c2c62fc020cc Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 1 Sep 2016 15:49:39 +0200 Subject: [PATCH 04/13] Avoid local variable name `self' in navigation.js refs #10703 --- public/js/icinga/behavior/navigation.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/public/js/icinga/behavior/navigation.js b/public/js/icinga/behavior/navigation.js index 539639685..2da6bc87d 100644 --- a/public/js/icinga/behavior/navigation.js +++ b/public/js/icinga/behavior/navigation.js @@ -108,14 +108,14 @@ var $a = $(this); var href = $a.attr('href'); var $li; - var self = event.data.self; - var icinga = self.icinga; + var _this = event.data.self; + var icinga = _this.icinga; - self.hovered = null; + _this.hovered = null; if (href.match(/#/)) { // ...it may be a menu section without a dedicated link. // Switch the active menu item: - self.setActive($a); + _this.setActive($a); $li = $a.closest('li'); if ($li.hasClass('hover')) { $li.removeClass('hover'); @@ -128,7 +128,7 @@ return; } } else { - self.setActive($(event.target)); + _this.setActive($(event.target)); } // update target url of the menu container to the clicked link var $menu = $('#menu'); @@ -276,9 +276,9 @@ var $li = $(this), delay = 800, - self = event.data.self; + _this = event.data.self; - self.hovered = null; + _this.hovered = null; if ($li.hasClass('active')) { $li.siblings().removeClass('hover'); return; @@ -315,14 +315,14 @@ $sibling.removeClass('hover'); } }); - self.hoverElement($li); + _this.hoverElement($li); }, delay); }; Navigation.prototype.leaveSidebar = function (event) { var $sidebar = $(this), $li = $sidebar.find('li.hover'), - self = event.data.self; + _this = event.data.self; if (! $li.length) { $('#layout').removeClass('hoveredmenu'); return; @@ -337,7 +337,7 @@ $li.removeClass('hover'); $('#layout').removeClass('hoveredmenu'); }, 500); - self.hovered = null; + _this.hovered = null; }; Navigation.prototype.hoverElement = function ($li) { @@ -356,7 +356,7 @@ Navigation.prototype.dropdownLeave = function (event) { var $li = $(this), - self = event.data.self; + _this = event.data.self; setTimeout(function () { // TODO: make this behave well together with keyboard navigation try { @@ -365,7 +365,7 @@ } } catch(e) { /* Bypass because if IE8 */ } }, 300); - self.hovered = null; + _this.hovered = null; }; Icinga.Behaviors.Navigation = Navigation; From 060a82fa4a4a09075c28609a6ae45febe6d4fe11 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 1 Sep 2016 15:58:32 +0200 Subject: [PATCH 05/13] Avoid local variable name `self' in tooltip.js and tristate.js refs #10703 --- public/js/icinga/behavior/tooltip.js | 4 ++-- public/js/icinga/behavior/tristate.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/public/js/icinga/behavior/tooltip.js b/public/js/icinga/behavior/tooltip.js index 98cc1ff59..abc1d4952 100644 --- a/public/js/icinga/behavior/tooltip.js +++ b/public/js/icinga/behavior/tooltip.js @@ -21,7 +21,7 @@ }; Tooltip.prototype.onRendered = function(evt) { - var self = 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 () { var $el = $(this); @@ -63,7 +63,7 @@ return; } var title = $(this).find('.tipsy-inner').html(); - var atMouse = document.elementFromPoint(self.mouseX, self.mouseY); + var atMouse = document.elementFromPoint(_this.mouseX, _this.mouseY); var nearestTip = $(atMouse).closest('[original-title="' + title + '"]')[0]; if (nearestTip) { var tipsy = $.data(nearestTip, 'tipsy'); diff --git a/public/js/icinga/behavior/tristate.js b/public/js/icinga/behavior/tristate.js index 88c07102d..77dad14e1 100644 --- a/public/js/icinga/behavior/tristate.js +++ b/public/js/icinga/behavior/tristate.js @@ -13,7 +13,7 @@ Tristate.prototype = new Icinga.EventListener(); Tristate.prototype.clickTriState = function (event) { - var self = event.data.self; + var _this = event.data.self; var $tristate = $(this); var triState = parseInt($tristate.data('icinga-tristate'), 10); @@ -42,7 +42,7 @@ } else { $tristate.parent().find('b.tristate-changed').css('visibility', 'hidden'); } - self.icinga.ui.setTriState(value.toString(), $tristate); + _this.icinga.ui.setTriState(value.toString(), $tristate); }; Icinga.Behaviors.Tristate = Tristate; From 4e2c626ae0e5602e38bed47baf6531cbf00ca812 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 1 Sep 2016 16:02:13 +0200 Subject: [PATCH 06/13] Avoid local variable name `self' in eventlistener.js refs #10703 --- public/js/icinga/eventlistener.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/public/js/icinga/eventlistener.js b/public/js/icinga/eventlistener.js index a7415e2f8..786441fa5 100644 --- a/public/js/icinga/eventlistener.js +++ b/public/js/icinga/eventlistener.js @@ -41,14 +41,14 @@ * 'on' to register listeners */ EventListener.prototype.bind = function (emitter) { - var self = this; + var _this = this; $.each(this.handlers, function(i, handler) { - self.icinga.logger.debug('bind: ' + handler.evt + '(' + handler.cond + ')'); + _this.icinga.logger.debug('bind: ' + handler.evt + '(' + handler.cond + ')'); emitter.on( handler.evt, handler.cond, { self: handler.scope || emitter, - icinga: self.icinga + icinga: _this.icinga }, handler.fn ); }); @@ -61,9 +61,9 @@ * 'off' to un-register listeners. */ EventListener.prototype.unbind = function (emitter) { - var self = this; + var _this = this; $.each(this.handlers, function(i, handler) { - self.icinga.logger.debug('unbind: ' + handler.evt + '(' + handler.cond + ')'); + _this.icinga.logger.debug('unbind: ' + handler.evt + '(' + handler.cond + ')'); emitter.off(handler.evt, handler.cond, handler.fn); }); }; From 3c43d38171a1967c48919153e4e2dfad9870ab85 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 1 Sep 2016 16:13:38 +0200 Subject: [PATCH 07/13] Avoid local variable name `self' in events.js refs #10703 --- public/js/icinga/events.js | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index aeca60db4..85dbdd87d 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -33,8 +33,8 @@ // TODO: What's this? applyHandlers: function (event) { var $target = $(event.target); - var self = event.data.self; - var icinga = self.icinga; + var _this = event.data.self; + var icinga = _this.icinga; if (! icinga) { // Attempt to catch a rare error, race condition, whatever @@ -42,7 +42,7 @@ return; } - if (self.initializeModules) { + if (_this.initializeModules) { var loaded = false; var moduleName = $target.data('icingaModule'); if (moduleName) { @@ -63,7 +63,7 @@ // so we need to ensure that it is called the first time they are // initialized event.stopImmediatePropagation(); - self.initializeModules = false; + _this.initializeModules = false; var $container = $target.closest('.container'); if (! $container.length) { @@ -79,7 +79,7 @@ return false; } } else { - self.initializeModules = true; + _this.initializeModules = true; } $('.dashboard > div', $target).each(function(idx, el) { @@ -93,7 +93,7 @@ var $searchField = $('#menu input.search', $target); // Remember initial search field value if any if ($searchField.length && $searchField.val().length) { - self.searchValue = $searchField.val(); + _this.searchValue = $searchField.val(); } }, @@ -190,12 +190,12 @@ }, autoSubmitSearch: function(event) { - var self = event.data.self; - if ($('#menu input.search').val() === self.searchValue) { + var _this = event.data.self; + if ($('#menu input.search').val() === _this.searchValue) { return; } - self.searchValue = $('#menu input.search').val(); - return self.autoSubmitForm(event); + _this.searchValue = $('#menu input.search').val(); + return _this.autoSubmitForm(event); }, rememberSubmitButton: function(e) { @@ -212,8 +212,8 @@ * */ submitForm: function (event, autosubmit) { - var self = event.data.self; - var icinga = self.icinga; + var _this = event.data.self; + var icinga = _this.icinga; // .closest is not required unless subelements to trigger this var $form = $(event.currentTarget).closest('form'); var url = $form.attr('action'); @@ -277,9 +277,9 @@ $button.addClass('active'); } - $target = self.getLinkTargetFor($button); + $target = _this.getLinkTargetFor($button); } else { - $target = self.getLinkTargetFor($form); + $target = _this.getLinkTargetFor($form); } if (! url) { @@ -427,8 +427,8 @@ * Someone clicked a link or tr[href] */ linkClicked: function (event) { - var self = event.data.self; - var icinga = self.icinga; + var _this = event.data.self; + var icinga = _this.icinga; var $a = $(this); var $eventTarget = $(event.target); var href = $a.attr('href'); @@ -512,7 +512,7 @@ } return false; } - $target = self.getLinkTargetFor($a); + $target = _this.getLinkTargetFor($a); formerUrl = $target.data('icingaUrl'); if (typeof formerUrl !== 'undefined' && formerUrl.split(/#/)[0] === href.split(/#/)[0]) { @@ -524,7 +524,7 @@ return false; } } else { - $target = self.getLinkTargetFor($a); + $target = _this.getLinkTargetFor($a); } // Load link URL From e726f10e6817adcfec080a62de7d83907a1f5988 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 1 Sep 2016 16:15:10 +0200 Subject: [PATCH 08/13] Avoid local variable name `self' in history.js and timer.js refs #10703 --- public/js/icinga/history.js | 8 ++++---- public/js/icinga/timer.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/public/js/icinga/history.js b/public/js/icinga/history.js index a0ebffa32..d0f6f6612 100644 --- a/public/js/icinga/history.js +++ b/public/js/icinga/history.js @@ -144,8 +144,8 @@ */ onHistoryChange: function (event) { - var self = event.data.self, - icinga = self.icinga; + var _this = event.data.self, + icinga = _this.icinga; icinga.logger.debug('Got a history change'); @@ -157,9 +157,9 @@ } // keep the last pushed url in sync with history changes - self.lastPushUrl = location.href; + _this.lastPushUrl = location.href; - self.applyLocationBar(); + _this.applyLocationBar(); // notify behaviors of the state change $.each(this.icinga.behaviors, function (i, behavior) { diff --git a/public/js/icinga/timer.js b/public/js/icinga/timer.js index 153e5325f..e16c5fe1d 100644 --- a/public/js/icinga/timer.js +++ b/public/js/icinga/timer.js @@ -49,8 +49,8 @@ * The initialization function starts our ticker */ initialize: function () { - var self = this; - this.ticker = setInterval(function () { self.tick(); }, this.interval); + var _this = this; + this.ticker = setInterval(function () { _this.tick(); }, this.interval); }, /** From 56c10ffdd591c20ae900a085c1cbea73706e87df Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 1 Sep 2016 16:28:57 +0200 Subject: [PATCH 09/13] Avoid local variable name `self' in loader.js refs #10703 --- public/js/icinga/loader.js | 52 +++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index 2ff4d7f6f..d4b84cbb1 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -114,13 +114,13 @@ contentType = false; } - var self = this; + var _this = this; var req = $.ajax({ type : method, url : url, data : data, headers: headers, - context: self, + context: _this, contentType: contentType, processData: ! isFormData }); @@ -153,9 +153,9 @@ * @param {object} $target The target container */ submitFormToIframe: function ($form, action, $target) { - var self = this; + var _this = this; - $form.prop('action', self.icinga.utils.addUrlParams(action, { + $form.prop('action', _this.icinga.utils.addUrlParams(action, { '_frameUpload': true })); $form.prop('target', 'fileupload-frame-target'); @@ -165,10 +165,10 @@ var $redirectMeta = $contents.find('meta[name="redirectUrl"]'); if ($redirectMeta.length) { - self.redirectToUrl($redirectMeta.attr('content'), $target); + _this.redirectToUrl($redirectMeta.attr('content'), $target); } else { // Fetch the frame's new content and paste it into the target - self.renderContentToContainer( + _this.renderContentToContainer( $contents.find('body').html(), $target, 'replace' @@ -208,16 +208,16 @@ }, autorefresh: function () { - var self = this; - if (self.autorefreshEnabled !== true) { + var _this = this; + if (_this.autorefreshEnabled !== true) { return; } $('.container').filter(this.filterAutorefreshingContainers).each(function (idx, el) { var $el = $(el); var id = $el.attr('id'); - if (typeof self.requests[id] !== 'undefined') { - self.icinga.logger.debug('No refresh, request pending for ', id); + if (typeof _this.requests[id] !== 'undefined') { + _this.icinga.logger.debug('No refresh, request pending for ', id); return; } @@ -225,12 +225,12 @@ var lastUpdate = $el.data('lastUpdate'); if (typeof interval === 'undefined' || ! interval) { - self.icinga.logger.info('No interval, setting default', id); + _this.icinga.logger.info('No interval, setting default', id); interval = 10; } if (typeof lastUpdate === 'undefined' || ! lastUpdate) { - self.icinga.logger.info('No lastUpdate, setting one', id); + _this.icinga.logger.info('No lastUpdate, setting one', id); $el.data('lastUpdate',(new Date()).getTime()); return; } @@ -248,12 +248,12 @@ return; } - if (self.loadUrl($el.data('icingaUrl'), $el, undefined, undefined, undefined, true) === false) { - self.icinga.logger.debug( + if (_this.loadUrl($el.data('icingaUrl'), $el, undefined, undefined, undefined, true) === false) { + _this.icinga.logger.debug( 'NOT autorefreshing ' + id + ', even if ' + interval + ' ms passed. Request pending?' ); } else { - self.icinga.logger.debug( + _this.icinga.logger.debug( 'Autorefreshing ' + id + ' ' + interval + ' ms passed' ); } @@ -277,12 +277,12 @@ processNotificationHeader: function(req) { var header = req.getResponseHeader('X-Icinga-Notification'); - var self = this; + var _this = this; if (! header) return false; var list = header.split('&'); $.each(list, function(idx, el) { var parts = decodeURIComponent(el).split(' '); - self.createNotice(parts.shift(), parts.join(' ')); + _this.createNotice(parts.shift(), parts.join(' ')); }); return true; }, @@ -406,15 +406,15 @@ // TODO: this is just a prototype, disabled for now return; - var self = this; + var _this = this; $('img.icon', $container).each(function(idx, img) { var src = $(img).attr('src'); - if (typeof self.iconCache[src] !== 'undefined') { + if (typeof _this.iconCache[src] !== 'undefined') { return; } var cache = new Image(); cache.src = src - self.iconCache[src] = cache; + _this.iconCache[src] = cache; }); }, @@ -422,7 +422,7 @@ * Handle successful XHR response */ onResponse: function (data, textStatus, req) { - var self = this; + var _this = this; if (this.failureNotice !== null) { if (! this.failureNotice.hasClass('fading-out')) { this.failureNotice.remove(); @@ -540,7 +540,7 @@ var title = $('h1', $el).first(); $('h1', targets[i]).first().replaceWith(title); - self.loadUrl(url, targets[i]); + _this.loadUrl(url, targets[i]); i++; }); rendered = true; @@ -569,7 +569,7 @@ if (newBody) { this.icinga.ui.fixDebugVisibility().triggerWindowResize(); } - self.cacheLoadedIcons(req.$target); + _this.cacheLoadedIcons(req.$target); }, /** @@ -735,7 +735,7 @@ renderContentToContainer: function (content, $container, action, autorefresh, forceFocus) { // Container update happens here var scrollPos = false; - var self = this; + var _this = this; var containerId = $container.attr('id'); var activeElementPath = false; @@ -772,7 +772,7 @@ $container.trigger('beforerender'); var discard = false; - $.each(self.icinga.behaviors, function(name, behavior) { + $.each(_this.icinga.behaviors, function(name, behavior) { if (behavior.renderHook) { var changed = behavior.renderHook(content, $container, action, autorefresh); if (!changed) { @@ -798,7 +798,7 @@ // }); $('.container', $container).each(function() { - self.stopPendingRequestsFor($(this)); + _this.stopPendingRequestsFor($(this)); }); if (false && From 4f52beb32a125c65780a043e3c3b2ff1e647d9ca Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 1 Sep 2016 16:30:01 +0200 Subject: [PATCH 10/13] Avoid local variable name `self' in module.js refs #10703 --- public/js/icinga/module.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/public/js/icinga/module.js b/public/js/icinga/module.js index 83700eb39..2c2368e5b 100644 --- a/public/js/icinga/module.js +++ b/public/js/icinga/module.js @@ -80,16 +80,16 @@ }, applyHandlers: function () { - var self = this; + var _this = this; $.each(this.registeredHandlers, function (key, on) { - self.bindEventHandler( + _this.bindEventHandler( on.event, on.filter, on.handler ); }); - self = null; + _this = null; return this; }, @@ -98,10 +98,10 @@ * Effectively bind the given event handler */ bindEventHandler: function (event, filter, handler) { - var self = this; + var _this = this; this.icinga.logger.debug('Bound ' + filter + ' .' + event + '()'); this.handlers.push([event, filter, handler]); - $(document).on(event, filter, handler.bind(self.object)); + $(document).on(event, filter, handler.bind(_this.object)); }, /** From cf5e26c56c15f4e9bb1b79082c8591e4c2941769 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 1 Sep 2016 16:32:31 +0200 Subject: [PATCH 11/13] Avoid local variable name `self' in ui.js refs #10703 --- public/js/icinga/ui.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/public/js/icinga/ui.js b/public/js/icinga/ui.js index af60a3ce9..feaababd7 100644 --- a/public/js/icinga/ui.js +++ b/public/js/icinga/ui.js @@ -211,16 +211,16 @@ * Our window got resized, let's fix our UI */ onWindowResize: function (event) { - var self = event.data.self; + var _this = event.data.self; - if (self.layoutHasBeenChanged()) { - self.icinga.logger.info( + if (_this.layoutHasBeenChanged()) { + _this.icinga.logger.info( 'Layout change detected, switching to', - self.currentLayout + _this.currentLayout ); } - self.fixControls(); - self.refreshDebug(); + _this.fixControls(); + _this.refreshDebug(); }, /** @@ -458,7 +458,6 @@ * Initialize all TriStateCheckboxes in the given html */ initializeTriStates: function ($html) { - var self = this; $('div.tristate', $html).each(function(index, item) { var $target = $(item); From 7e47a2965ce7ed1a26d3273b202aec2bcd0a65b5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 9 Sep 2016 13:18:00 +0200 Subject: [PATCH 12/13] JS: Fix usage of global variable self used to reference icinga in loader.js::onComplete() refs #10703 --- public/js/icinga/loader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index d4b84cbb1..73df66c79 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -586,7 +586,7 @@ var url = req.url; if (req.$target[0].id === 'col1') { - self.icinga.behaviors.navigation.trySetActiveByUrl(url); + this.icinga.behaviors.navigation.trySetActiveByUrl(url); } var $forms = $('[action="' + this.icinga.utils.parseUrl(url).path + '"]'); From 118c435bc58086680ead7d1f569e14db13b88450 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 9 Sep 2016 13:20:55 +0200 Subject: [PATCH 13/13] JS: Fix usage of global variable self used to reference icinga in events.js refs #10703 --- public/js/icinga/events.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index 85dbdd87d..340d652b1 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -105,7 +105,7 @@ // Note: It is important that this is the first handler for this event! $(document).on('rendered', { self: this }, this.applyHandlers); - $.each(self.icinga.behaviors, function (name, behavior) { + $.each(this.icinga.behaviors, function (name, behavior) { behavior.bind($(document)); }); @@ -577,11 +577,11 @@ } else if (targetId === '_main') { targetId = 'col1'; $target = $('#' + targetId); - self.icinga.ui.layout1col(); + this.icinga.ui.layout1col(); } else { $target = $('#' + targetId); if (! $target.length) { - self.icinga.logger.warn('Link target "#' + targetId + '" does not exist in DOM.'); + this.icinga.logger.warn('Link target "#' + targetId + '" does not exist in DOM.'); } } @@ -596,7 +596,7 @@ }, unbindGlobalHandlers: function () { - $.each(self.icinga.behaviors, function (name, behavior) { + $.each(this.icinga.behaviors, function (name, behavior) { behavior.unbind($(document)); }); $(window).off('resize', this.onWindowResize);