Avoid local variable name `self' in actiontable.js

refs #10703
This commit is contained in:
Alexander A. Klimov 2016-09-01 15:21:45 +02:00
parent f72411c628
commit 311fd36326
1 changed files with 23 additions and 23 deletions

View File

@ -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();
});
};