Avoid local variable name `self' in loader.js

refs #10703
This commit is contained in:
Alexander A. Klimov 2016-09-01 16:28:57 +02:00
parent e726f10e68
commit 56c10ffdd5
1 changed files with 26 additions and 26 deletions

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);
}, },
/** /**
@ -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 &&