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

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