Merge branch 'bugfix/js-don-t-use-var-self-this-10703'

fixes #10703
This commit is contained in:
Eric Lippmann 2016-09-09 13:26:18 +02:00
commit 972358532d
13 changed files with 119 additions and 120 deletions

View File

@ -69,10 +69,10 @@
*/ */
this.modules = {}; this.modules = {};
var self = this; var _this = this;
$(document).ready(function () { $(document).ready(function () {
self.initialize(); _this.initialize();
self = null; _this = null;
}); });
}; };
@ -94,9 +94,9 @@
this.loader = new Icinga.Loader(this); this.loader = new Icinga.Loader(this);
this.events = new Icinga.Events(this); this.events = new Icinga.Events(this);
this.history = new Icinga.History(this); this.history = new Icinga.History(this);
var self = this; var _this = this;
$.each(Icinga.Behaviors, function(name, Behavior) { $.each(Icinga.Behaviors, function(name, Behavior) {
self.behaviors[name.toLowerCase()] = new Behavior(self); _this.behaviors[name.toLowerCase()] = new Behavior(_this);
}); });
this.timezone.initialize(); this.timezone.initialize();

View File

@ -185,12 +185,12 @@
filter.addClass('active'); filter.addClass('active');
return; return;
} }
var self = this; var _this = this;
this.rowActions() this.rowActions()
.filter( .filter(
function (i, el) { function (i, el) {
var params = self.getRowData($(el)); var params = _this.getRowData($(el));
if (self.icinga.utils.objectKeys(params).length !== self.icinga.utils.objectKeys(filter).length) { if (_this.icinga.utils.objectKeys(params).length !== _this.icinga.utils.objectKeys(filter).length) {
return false; return false;
} }
var equal = true; var equal = true;
@ -274,21 +274,21 @@
* @returns {String} The filter string * @returns {String} The filter string
*/ */
toQuery: function() { toQuery: function() {
var self = this; var _this = this;
var selections = this.selections(); var selections = this.selections();
var queries = []; var queries = [];
var utils = this.icinga.utils; var utils = this.icinga.utils;
if (selections.length === 1) { if (selections.length === 1) {
return $(selections[0]).attr('href'); return $(selections[0]).attr('href');
} else if (selections.length > 1 && self.hasMultiselection()) { } else if (selections.length > 1 && _this.hasMultiselection()) {
selections.each(function (i, el) { selections.each(function (i, el) {
var parts = []; var parts = [];
$.each(self.getRowData($(el)), function(key, value) { $.each(_this.getRowData($(el)), function(key, value) {
parts.push(utils.fixedEncodeURIComponent(key) + '=' + utils.fixedEncodeURIComponent(value)); parts.push(utils.fixedEncodeURIComponent(key) + '=' + utils.fixedEncodeURIComponent(value));
}); });
queries.push('(' + parts.join('&') + ')'); queries.push('(' + parts.join('&') + ')');
}); });
return self.getMultiselectionUrl() + '?(' + queries.join('|') + ')'; return _this.getMultiselectionUrl() + '?(' + queries.join('|') + ')';
} else { } else {
return ''; return '';
} }
@ -304,9 +304,9 @@
var query = parseSelectionQuery(hash); var query = parseSelectionQuery(hash);
if (query.length > 1 && this.hasMultiselectionUrl(this.icinga.utils.parseUrl(hash).path)) { if (query.length > 1 && this.hasMultiselectionUrl(this.icinga.utils.parseUrl(hash).path)) {
// select all rows with matching filters // select all rows with matching filters
var self = this; var _this = this;
$.each(query, function(i, selection) { $.each(query, function(i, selection) {
self.select(selection); _this.select(selection);
}); });
} }
if (query.length > 1) { if (query.length > 1) {
@ -351,10 +351,10 @@
* Handle clicks on table rows and update selection and history * Handle clicks on table rows and update selection and history
*/ */
ActionTable.prototype.onRowClicked = function (event) { ActionTable.prototype.onRowClicked = function (event) {
var self = event.data.self; var _this = event.data.self;
var $target = $(event.target); var $target = $(event.target);
var $tr = $target.closest('tr'); 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 // some rows may contain form actions that trigger a different action, pass those through
if (!$target.hasClass('rowaction') && $target.closest('form').length && if (!$target.hasClass('rowaction') && $target.closest('form').length &&
@ -390,18 +390,18 @@
var count = table.selections().length; var count = table.selections().length;
if (count > 0) { if (count > 0) {
var query = table.toQuery(); 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; state += '#!' + query;
} else { } else {
if (self.icinga.events.getLinkTargetFor($tr).attr('id') === 'col2') { if (_this.icinga.events.getLinkTargetFor($tr).attr('id') === 'col2') {
self.icinga.ui.layout1col(); _this.icinga.ui.layout1col();
} }
} }
self.icinga.history.pushUrl(state); _this.icinga.history.pushUrl(state);
// redraw all table selections // redraw all table selections
self.tables().each(function () { _this.tables().each(function () {
new Selection(this, self.icinga).refresh(); new Selection(this, _this.icinga).refresh();
}); });
// update selection info // update selection info
@ -414,7 +414,7 @@
*/ */
ActionTable.prototype.onRendered = function(evt) { ActionTable.prototype.onRendered = function(evt) {
var container = evt.target; var container = evt.target;
var self = 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) { $('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 // draw all active selections that have disappeared on reload
self.tables().each(function(i, el) { _this.tables().each(function(i, el) {
new Selection(el, self.icinga).refresh(); new Selection(el, _this.icinga).refresh();
}); });
// update displayed selection counter // 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()); $(container).find('.selection-info-count').text(table.selections().size());
}; };
ActionTable.prototype.clearAll = function () { ActionTable.prototype.clearAll = function () {
var self = this; var _this = this;
this.tables().each(function () { this.tables().each(function () {
new Selection(this, self.icinga).clear(); new Selection(this, _this.icinga).clear();
}); });
}; };

View File

@ -71,15 +71,15 @@
var origFocus = document.activeElement; var origFocus = document.activeElement;
var containerId = $container.attr('id'); var containerId = $container.attr('id');
var icinga = this.icinga; var icinga = this.icinga;
var self = this.icinga.behaviors.form; var _this = this.icinga.behaviors.form;
var changed = false; var changed = false;
$container.find('form').each(function () { $container.find('form').each(function () {
var form = self.uniqueFormName(this); var form = _this.uniqueFormName(this);
if (autorefresh) { if (autorefresh) {
// check if an element in this container was changed // check if an element in this container was changed
$(this).find('input').each(function () { $(this).find('input').each(function () {
var name = this.name; var name = this.name;
if (self.inputs[form] && self.inputs[form][name]) { if (_this.inputs[form] && _this.inputs[form][name]) {
icinga.logger.debug( icinga.logger.debug(
'form input: ' + form + '.' + name + ' was changed and aborts reload...' 'form input: ' + form + '.' + name + ' was changed and aborts reload...'
); );
@ -88,7 +88,7 @@
}); });
} else { } else {
// user-triggered reload, forget all changes to forms in this container // user-triggered reload, forget all changes to forms in this container
self.inputs[form] = null; _this.inputs[form] = null;
} }
}); });
if (changed) { if (changed) {

View File

@ -108,14 +108,14 @@
var $a = $(this); var $a = $(this);
var href = $a.attr('href'); var href = $a.attr('href');
var $li; var $li;
var self = event.data.self; var _this = event.data.self;
var icinga = self.icinga; var icinga = _this.icinga;
self.hovered = null; _this.hovered = null;
if (href.match(/#/)) { if (href.match(/#/)) {
// ...it may be a menu section without a dedicated link. // ...it may be a menu section without a dedicated link.
// Switch the active menu item: // Switch the active menu item:
self.setActive($a); _this.setActive($a);
$li = $a.closest('li'); $li = $a.closest('li');
if ($li.hasClass('hover')) { if ($li.hasClass('hover')) {
$li.removeClass('hover'); $li.removeClass('hover');
@ -128,7 +128,7 @@
return; return;
} }
} else { } else {
self.setActive($(event.target)); _this.setActive($(event.target));
} }
// update target url of the menu container to the clicked link // update target url of the menu container to the clicked link
var $menu = $('#menu'); var $menu = $('#menu');
@ -276,9 +276,9 @@
var $li = $(this), var $li = $(this),
delay = 800, delay = 800,
self = event.data.self; _this = event.data.self;
self.hovered = null; _this.hovered = null;
if ($li.hasClass('active')) { if ($li.hasClass('active')) {
$li.siblings().removeClass('hover'); $li.siblings().removeClass('hover');
return; return;
@ -315,14 +315,14 @@
$sibling.removeClass('hover'); $sibling.removeClass('hover');
} }
}); });
self.hoverElement($li); _this.hoverElement($li);
}, delay); }, delay);
}; };
Navigation.prototype.leaveSidebar = function (event) { Navigation.prototype.leaveSidebar = function (event) {
var $sidebar = $(this), var $sidebar = $(this),
$li = $sidebar.find('li.hover'), $li = $sidebar.find('li.hover'),
self = event.data.self; _this = event.data.self;
if (! $li.length) { if (! $li.length) {
$('#layout').removeClass('hoveredmenu'); $('#layout').removeClass('hoveredmenu');
return; return;
@ -337,7 +337,7 @@
$li.removeClass('hover'); $li.removeClass('hover');
$('#layout').removeClass('hoveredmenu'); $('#layout').removeClass('hoveredmenu');
}, 500); }, 500);
self.hovered = null; _this.hovered = null;
}; };
Navigation.prototype.hoverElement = function ($li) { Navigation.prototype.hoverElement = function ($li) {
@ -356,7 +356,7 @@
Navigation.prototype.dropdownLeave = function (event) { Navigation.prototype.dropdownLeave = function (event) {
var $li = $(this), var $li = $(this),
self = event.data.self; _this = event.data.self;
setTimeout(function () { setTimeout(function () {
// TODO: make this behave well together with keyboard navigation // TODO: make this behave well together with keyboard navigation
try { try {
@ -365,7 +365,7 @@
} }
} catch(e) { /* Bypass because if IE8 */ } } catch(e) { /* Bypass because if IE8 */ }
}, 300); }, 300);
self.hovered = null; _this.hovered = null;
}; };
Icinga.Behaviors.Navigation = Navigation; Icinga.Behaviors.Navigation = Navigation;

View File

@ -21,7 +21,7 @@
}; };
Tooltip.prototype.onRendered = function(evt) { 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 () { $('[title]', el).each(function () {
var $el = $(this); var $el = $(this);
@ -63,7 +63,7 @@
return; return;
} }
var title = $(this).find('.tipsy-inner').html(); 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]; var nearestTip = $(atMouse).closest('[original-title="' + title + '"]')[0];
if (nearestTip) { if (nearestTip) {
var tipsy = $.data(nearestTip, 'tipsy'); var tipsy = $.data(nearestTip, 'tipsy');

View File

@ -13,7 +13,7 @@
Tristate.prototype = new Icinga.EventListener(); Tristate.prototype = new Icinga.EventListener();
Tristate.prototype.clickTriState = function (event) { Tristate.prototype.clickTriState = function (event) {
var self = event.data.self; var _this = event.data.self;
var $tristate = $(this); var $tristate = $(this);
var triState = parseInt($tristate.data('icinga-tristate'), 10); var triState = parseInt($tristate.data('icinga-tristate'), 10);
@ -42,7 +42,7 @@
} else { } else {
$tristate.parent().find('b.tristate-changed').css('visibility', 'hidden'); $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; Icinga.Behaviors.Tristate = Tristate;

View File

@ -41,14 +41,14 @@
* 'on' to register listeners * 'on' to register listeners
*/ */
EventListener.prototype.bind = function (emitter) { EventListener.prototype.bind = function (emitter) {
var self = this; var _this = this;
$.each(this.handlers, function(i, handler) { $.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( emitter.on(
handler.evt, handler.cond, handler.evt, handler.cond,
{ {
self: handler.scope || emitter, self: handler.scope || emitter,
icinga: self.icinga icinga: _this.icinga
}, handler.fn }, handler.fn
); );
}); });
@ -61,9 +61,9 @@
* 'off' to un-register listeners. * 'off' to un-register listeners.
*/ */
EventListener.prototype.unbind = function (emitter) { EventListener.prototype.unbind = function (emitter) {
var self = this; var _this = this;
$.each(this.handlers, function(i, handler) { $.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); emitter.off(handler.evt, handler.cond, handler.fn);
}); });
}; };

View File

@ -33,8 +33,8 @@
// TODO: What's this? // TODO: What's this?
applyHandlers: function (event) { applyHandlers: function (event) {
var $target = $(event.target); var $target = $(event.target);
var self = event.data.self; var _this = event.data.self;
var icinga = self.icinga; var icinga = _this.icinga;
if (! icinga) { if (! icinga) {
// Attempt to catch a rare error, race condition, whatever // Attempt to catch a rare error, race condition, whatever
@ -42,7 +42,7 @@
return; return;
} }
if (self.initializeModules) { if (_this.initializeModules) {
var loaded = false; var loaded = false;
var moduleName = $target.data('icingaModule'); var moduleName = $target.data('icingaModule');
if (moduleName) { if (moduleName) {
@ -63,7 +63,7 @@
// so we need to ensure that it is called the first time they are // so we need to ensure that it is called the first time they are
// initialized // initialized
event.stopImmediatePropagation(); event.stopImmediatePropagation();
self.initializeModules = false; _this.initializeModules = false;
var $container = $target.closest('.container'); var $container = $target.closest('.container');
if (! $container.length) { if (! $container.length) {
@ -79,7 +79,7 @@
return false; return false;
} }
} else { } else {
self.initializeModules = true; _this.initializeModules = true;
} }
$('.dashboard > div', $target).each(function(idx, el) { $('.dashboard > div', $target).each(function(idx, el) {
@ -93,7 +93,7 @@
var $searchField = $('#menu input.search', $target); var $searchField = $('#menu input.search', $target);
// 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) {
self.searchValue = $searchField.val(); _this.searchValue = $searchField.val();
} }
}, },
@ -105,7 +105,7 @@
// Note: It is important that this is the first handler for this event! // Note: It is important that this is the first handler for this event!
$(document).on('rendered', { self: this }, this.applyHandlers); $(document).on('rendered', { self: this }, this.applyHandlers);
$.each(self.icinga.behaviors, function (name, behavior) { $.each(this.icinga.behaviors, function (name, behavior) {
behavior.bind($(document)); behavior.bind($(document));
}); });
@ -190,12 +190,12 @@
}, },
autoSubmitSearch: function(event) { autoSubmitSearch: function(event) {
var self = event.data.self; var _this = event.data.self;
if ($('#menu input.search').val() === self.searchValue) { if ($('#menu input.search').val() === _this.searchValue) {
return; return;
} }
self.searchValue = $('#menu input.search').val(); _this.searchValue = $('#menu input.search').val();
return self.autoSubmitForm(event); return _this.autoSubmitForm(event);
}, },
rememberSubmitButton: function(e) { rememberSubmitButton: function(e) {
@ -212,8 +212,8 @@
* *
*/ */
submitForm: function (event, autosubmit) { submitForm: function (event, autosubmit) {
var self = event.data.self; var _this = event.data.self;
var icinga = self.icinga; var icinga = _this.icinga;
// .closest is not required unless subelements to trigger this // .closest is not required unless subelements to trigger this
var $form = $(event.currentTarget).closest('form'); var $form = $(event.currentTarget).closest('form');
var url = $form.attr('action'); var url = $form.attr('action');
@ -277,9 +277,9 @@
$button.addClass('active'); $button.addClass('active');
} }
$target = self.getLinkTargetFor($button); $target = _this.getLinkTargetFor($button);
} else { } else {
$target = self.getLinkTargetFor($form); $target = _this.getLinkTargetFor($form);
} }
if (! url) { if (! url) {
@ -427,8 +427,8 @@
* Someone clicked a link or tr[href] * Someone clicked a link or tr[href]
*/ */
linkClicked: function (event) { linkClicked: function (event) {
var self = event.data.self; var _this = event.data.self;
var icinga = self.icinga; var icinga = _this.icinga;
var $a = $(this); var $a = $(this);
var $eventTarget = $(event.target); var $eventTarget = $(event.target);
var href = $a.attr('href'); var href = $a.attr('href');
@ -512,7 +512,7 @@
} }
return false; return false;
} }
$target = self.getLinkTargetFor($a); $target = _this.getLinkTargetFor($a);
formerUrl = $target.data('icingaUrl'); formerUrl = $target.data('icingaUrl');
if (typeof formerUrl !== 'undefined' && formerUrl.split(/#/)[0] === href.split(/#/)[0]) { if (typeof formerUrl !== 'undefined' && formerUrl.split(/#/)[0] === href.split(/#/)[0]) {
@ -524,7 +524,7 @@
return false; return false;
} }
} else { } else {
$target = self.getLinkTargetFor($a); $target = _this.getLinkTargetFor($a);
} }
// Load link URL // Load link URL
@ -577,11 +577,11 @@
} else if (targetId === '_main') { } else if (targetId === '_main') {
targetId = 'col1'; targetId = 'col1';
$target = $('#' + targetId); $target = $('#' + targetId);
self.icinga.ui.layout1col(); this.icinga.ui.layout1col();
} else { } else {
$target = $('#' + targetId); $target = $('#' + targetId);
if (! $target.length) { 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 () { unbindGlobalHandlers: function () {
$.each(self.icinga.behaviors, function (name, behavior) { $.each(this.icinga.behaviors, function (name, behavior) {
behavior.unbind($(document)); behavior.unbind($(document));
}); });
$(window).off('resize', this.onWindowResize); $(window).off('resize', this.onWindowResize);

View File

@ -144,8 +144,8 @@
*/ */
onHistoryChange: function (event) { onHistoryChange: function (event) {
var self = event.data.self, var _this = event.data.self,
icinga = self.icinga; icinga = _this.icinga;
icinga.logger.debug('Got a history change'); icinga.logger.debug('Got a history change');
@ -157,9 +157,9 @@
} }
// keep the last pushed url in sync with history changes // 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 // notify behaviors of the state change
$.each(this.icinga.behaviors, function (i, behavior) { $.each(this.icinga.behaviors, function (i, behavior) {

View File

@ -114,13 +114,13 @@
contentType = false; contentType = false;
} }
var self = this; var _this = this;
var req = $.ajax({ var req = $.ajax({
type : method, type : method,
url : url, url : url,
data : data, data : data,
headers: headers, headers: headers,
context: self, context: _this,
contentType: contentType, contentType: contentType,
processData: ! isFormData processData: ! isFormData
}); });
@ -153,9 +153,9 @@
* @param {object} $target The target container * @param {object} $target The target container
*/ */
submitFormToIframe: function ($form, action, $target) { 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 '_frameUpload': true
})); }));
$form.prop('target', 'fileupload-frame-target'); $form.prop('target', 'fileupload-frame-target');
@ -165,10 +165,10 @@
var $redirectMeta = $contents.find('meta[name="redirectUrl"]'); var $redirectMeta = $contents.find('meta[name="redirectUrl"]');
if ($redirectMeta.length) { if ($redirectMeta.length) {
self.redirectToUrl($redirectMeta.attr('content'), $target); _this.redirectToUrl($redirectMeta.attr('content'), $target);
} else { } else {
// Fetch the frame's new content and paste it into the target // Fetch the frame's new content and paste it into the target
self.renderContentToContainer( _this.renderContentToContainer(
$contents.find('body').html(), $contents.find('body').html(),
$target, $target,
'replace' 'replace'
@ -208,16 +208,16 @@
}, },
autorefresh: function () { autorefresh: function () {
var self = this; var _this = this;
if (self.autorefreshEnabled !== true) { if (_this.autorefreshEnabled !== true) {
return; return;
} }
$('.container').filter(this.filterAutorefreshingContainers).each(function (idx, el) { $('.container').filter(this.filterAutorefreshingContainers).each(function (idx, el) {
var $el = $(el); var $el = $(el);
var id = $el.attr('id'); var id = $el.attr('id');
if (typeof self.requests[id] !== 'undefined') { if (typeof _this.requests[id] !== 'undefined') {
self.icinga.logger.debug('No refresh, request pending for ', id); _this.icinga.logger.debug('No refresh, request pending for ', id);
return; return;
} }
@ -225,12 +225,12 @@
var lastUpdate = $el.data('lastUpdate'); var lastUpdate = $el.data('lastUpdate');
if (typeof interval === 'undefined' || ! interval) { 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; interval = 10;
} }
if (typeof lastUpdate === 'undefined' || ! lastUpdate) { 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()); $el.data('lastUpdate',(new Date()).getTime());
return; return;
} }
@ -248,12 +248,12 @@
return; return;
} }
if (self.loadUrl($el.data('icingaUrl'), $el, undefined, undefined, undefined, true) === false) { if (_this.loadUrl($el.data('icingaUrl'), $el, undefined, undefined, undefined, true) === false) {
self.icinga.logger.debug( _this.icinga.logger.debug(
'NOT autorefreshing ' + id + ', even if ' + interval + ' ms passed. Request pending?' 'NOT autorefreshing ' + id + ', even if ' + interval + ' ms passed. Request pending?'
); );
} else { } else {
self.icinga.logger.debug( _this.icinga.logger.debug(
'Autorefreshing ' + id + ' ' + interval + ' ms passed' 'Autorefreshing ' + id + ' ' + interval + ' ms passed'
); );
} }
@ -277,12 +277,12 @@
processNotificationHeader: function(req) { processNotificationHeader: function(req) {
var header = req.getResponseHeader('X-Icinga-Notification'); var header = req.getResponseHeader('X-Icinga-Notification');
var self = this; var _this = this;
if (! header) return false; if (! header) return false;
var list = header.split('&'); var list = header.split('&');
$.each(list, function(idx, el) { $.each(list, function(idx, el) {
var parts = decodeURIComponent(el).split(' '); var parts = decodeURIComponent(el).split(' ');
self.createNotice(parts.shift(), parts.join(' ')); _this.createNotice(parts.shift(), parts.join(' '));
}); });
return true; return true;
}, },
@ -406,15 +406,15 @@
// TODO: this is just a prototype, disabled for now // TODO: this is just a prototype, disabled for now
return; return;
var self = this; var _this = this;
$('img.icon', $container).each(function(idx, img) { $('img.icon', $container).each(function(idx, img) {
var src = $(img).attr('src'); var src = $(img).attr('src');
if (typeof self.iconCache[src] !== 'undefined') { if (typeof _this.iconCache[src] !== 'undefined') {
return; return;
} }
var cache = new Image(); var cache = new Image();
cache.src = src cache.src = src
self.iconCache[src] = cache; _this.iconCache[src] = cache;
}); });
}, },
@ -422,7 +422,7 @@
* Handle successful XHR response * Handle successful XHR response
*/ */
onResponse: function (data, textStatus, req) { onResponse: function (data, textStatus, req) {
var self = this; var _this = this;
if (this.failureNotice !== null) { if (this.failureNotice !== null) {
if (! this.failureNotice.hasClass('fading-out')) { if (! this.failureNotice.hasClass('fading-out')) {
this.failureNotice.remove(); this.failureNotice.remove();
@ -540,7 +540,7 @@
var title = $('h1', $el).first(); var title = $('h1', $el).first();
$('h1', targets[i]).first().replaceWith(title); $('h1', targets[i]).first().replaceWith(title);
self.loadUrl(url, targets[i]); _this.loadUrl(url, targets[i]);
i++; i++;
}); });
rendered = true; rendered = true;
@ -569,7 +569,7 @@
if (newBody) { if (newBody) {
this.icinga.ui.fixDebugVisibility().triggerWindowResize(); this.icinga.ui.fixDebugVisibility().triggerWindowResize();
} }
self.cacheLoadedIcons(req.$target); _this.cacheLoadedIcons(req.$target);
}, },
/** /**
@ -586,7 +586,7 @@
var url = req.url; var url = req.url;
if (req.$target[0].id === 'col1') { 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 + '"]'); var $forms = $('[action="' + this.icinga.utils.parseUrl(url).path + '"]');
@ -735,7 +735,7 @@
renderContentToContainer: function (content, $container, action, autorefresh, forceFocus) { renderContentToContainer: function (content, $container, action, autorefresh, forceFocus) {
// Container update happens here // Container update happens here
var scrollPos = false; var scrollPos = false;
var self = this; var _this = this;
var containerId = $container.attr('id'); var containerId = $container.attr('id');
var activeElementPath = false; var activeElementPath = false;
@ -772,7 +772,7 @@
$container.trigger('beforerender'); $container.trigger('beforerender');
var discard = false; var discard = false;
$.each(self.icinga.behaviors, function(name, behavior) { $.each(_this.icinga.behaviors, function(name, behavior) {
if (behavior.renderHook) { if (behavior.renderHook) {
var changed = behavior.renderHook(content, $container, action, autorefresh); var changed = behavior.renderHook(content, $container, action, autorefresh);
if (!changed) { if (!changed) {
@ -798,7 +798,7 @@
// }); // });
$('.container', $container).each(function() { $('.container', $container).each(function() {
self.stopPendingRequestsFor($(this)); _this.stopPendingRequestsFor($(this));
}); });
if (false && if (false &&

View File

@ -80,16 +80,16 @@
}, },
applyHandlers: function () { applyHandlers: function () {
var self = this; var _this = this;
$.each(this.registeredHandlers, function (key, on) { $.each(this.registeredHandlers, function (key, on) {
self.bindEventHandler( _this.bindEventHandler(
on.event, on.event,
on.filter, on.filter,
on.handler on.handler
); );
}); });
self = null; _this = null;
return this; return this;
}, },
@ -98,10 +98,10 @@
* Effectively bind the given event handler * Effectively bind the given event handler
*/ */
bindEventHandler: function (event, filter, handler) { bindEventHandler: function (event, filter, handler) {
var self = this; var _this = this;
this.icinga.logger.debug('Bound ' + filter + ' .' + event + '()'); this.icinga.logger.debug('Bound ' + filter + ' .' + event + '()');
this.handlers.push([event, filter, handler]); this.handlers.push([event, filter, handler]);
$(document).on(event, filter, handler.bind(self.object)); $(document).on(event, filter, handler.bind(_this.object));
}, },
/** /**

View File

@ -49,8 +49,8 @@
* The initialization function starts our ticker * The initialization function starts our ticker
*/ */
initialize: function () { initialize: function () {
var self = this; var _this = this;
this.ticker = setInterval(function () { self.tick(); }, this.interval); this.ticker = setInterval(function () { _this.tick(); }, this.interval);
}, },
/** /**

View File

@ -211,16 +211,16 @@
* Our window got resized, let's fix our UI * Our window got resized, let's fix our UI
*/ */
onWindowResize: function (event) { onWindowResize: function (event) {
var self = event.data.self; var _this = event.data.self;
if (self.layoutHasBeenChanged()) { if (_this.layoutHasBeenChanged()) {
self.icinga.logger.info( _this.icinga.logger.info(
'Layout change detected, switching to', 'Layout change detected, switching to',
self.currentLayout _this.currentLayout
); );
} }
self.fixControls(); _this.fixControls();
self.refreshDebug(); _this.refreshDebug();
}, },
/** /**
@ -458,7 +458,6 @@
* Initialize all TriStateCheckboxes in the given html * Initialize all TriStateCheckboxes in the given html
*/ */
initializeTriStates: function ($html) { initializeTriStates: function ($html) {
var self = this;
$('div.tristate', $html).each(function(index, item) { $('div.tristate', $html).each(function(index, item) {
var $target = $(item); var $target = $(item);