mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 21:14:33 +00:00
Rename variables in DynamicTable class
This commit is contained in:
parent
f4fa000ba3
commit
afd4f89693
@ -35,14 +35,14 @@ var DynamicTable = new Class({
|
|||||||
|
|
||||||
initialize : function () {},
|
initialize : function () {},
|
||||||
|
|
||||||
setup : function (tableId, tableHeaderId, context_menu) {
|
setup : function (tableId, tableHeaderId, contextMenu) {
|
||||||
this.tableId = tableId;
|
this.tableId = tableId;
|
||||||
this.tableHeaderId = tableHeaderId;
|
this.tableHeaderId = tableHeaderId;
|
||||||
this.table = $(tableId);
|
this.table = $(tableId);
|
||||||
this.rows = new Hash();
|
this.rows = new Hash();
|
||||||
this.cur = new Array();
|
this.selectedRows = new Array();
|
||||||
this.columns = new Array();
|
this.columns = new Array();
|
||||||
this.context_menu = context_menu;
|
this.contextMenu = contextMenu;
|
||||||
this.sortedColumn = getLocalStorageItem('sorted_column_' + this.tableId, 0);
|
this.sortedColumn = getLocalStorageItem('sorted_column_' + this.tableId, 0);
|
||||||
this.reverseSort = getLocalStorageItem('reverse_sort_' + this.tableId, '0');
|
this.reverseSort = getLocalStorageItem('reverse_sort_' + this.tableId, '0');
|
||||||
this.initColumns();
|
this.initColumns();
|
||||||
@ -163,8 +163,8 @@ var DynamicTable = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getSelectedRowId : function () {
|
getSelectedRowId : function () {
|
||||||
if (this.cur.length > 0)
|
if (this.selectedRows.length > 0)
|
||||||
return this.cur[0];
|
return this.selectedRows[0];
|
||||||
return '';
|
return '';
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -183,24 +183,24 @@ var DynamicTable = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
selectAll : function () {
|
selectAll : function () {
|
||||||
this.cur.empty();
|
this.selectedRows.empty();
|
||||||
|
|
||||||
var trs = this.table.getElements('tr');
|
var trs = this.table.getElements('tr');
|
||||||
for (var i = 0; i < trs.length; i++) {
|
for (var i = 0; i < trs.length; i++) {
|
||||||
var tr = trs[i];
|
var tr = trs[i];
|
||||||
this.cur.push(tr.rowId);
|
this.selectedRows.push(tr.rowId);
|
||||||
if (!tr.hasClass('selected'))
|
if (!tr.hasClass('selected'))
|
||||||
tr.addClass('selected');
|
tr.addClass('selected');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
deselectAll : function () {
|
deselectAll : function () {
|
||||||
this.cur.empty();
|
this.selectedRows.empty();
|
||||||
},
|
},
|
||||||
|
|
||||||
selectRow : function (rowId) {
|
selectRow : function (rowId) {
|
||||||
this.cur.empty();
|
this.selectedRows.empty();
|
||||||
this.cur.push(rowId);
|
this.selectedRows.push(rowId);
|
||||||
var trs = this.table.getElements('tr');
|
var trs = this.table.getElements('tr');
|
||||||
for (var i = 0; i < trs.length; i++) {
|
for (var i = 0; i < trs.length; i++) {
|
||||||
var tr = trs[i];
|
var tr = trs[i];
|
||||||
@ -272,9 +272,9 @@ var DynamicTable = new Class({
|
|||||||
|
|
||||||
var rows = this.getFilteredAndSortedRows();
|
var rows = this.getFilteredAndSortedRows();
|
||||||
|
|
||||||
for (var i = 0; i < this.cur.length; i++)
|
for (var i = 0; i < this.selectedRows.length; i++)
|
||||||
if (!(this.cur[i] in rows)) {
|
if (!(this.selectedRows[i] in rows)) {
|
||||||
this.cur.splice(i, 1);
|
this.selectedRows.splice(i, 1);
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,7 +304,7 @@ var DynamicTable = new Class({
|
|||||||
|
|
||||||
tr._this = this;
|
tr._this = this;
|
||||||
tr.addEvent('contextmenu', function (e) {
|
tr.addEvent('contextmenu', function (e) {
|
||||||
if (!this._this.cur.contains(this.rowId))
|
if (!this._this.selectedRows.contains(this.rowId))
|
||||||
this._this.selectRow(this.rowId);
|
this._this.selectRow(this.rowId);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
@ -312,37 +312,37 @@ var DynamicTable = new Class({
|
|||||||
e.stop();
|
e.stop();
|
||||||
if (e.control) {
|
if (e.control) {
|
||||||
// CTRL key was pressed
|
// CTRL key was pressed
|
||||||
if (this._this.cur.contains(this.rowId)) {
|
if (this._this.selectedRows.contains(this.rowId)) {
|
||||||
// remove it
|
// remove it
|
||||||
this._this.cur.erase(this.rowId);
|
this._this.selectedRows.erase(this.rowId);
|
||||||
// Remove selected style
|
// Remove selected style
|
||||||
this.removeClass('selected');
|
this.removeClass('selected');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this._this.cur.push(this.rowId);
|
this._this.selectedRows.push(this.rowId);
|
||||||
// Add selected style
|
// Add selected style
|
||||||
this.addClass('selected');
|
this.addClass('selected');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (e.shift && this._this.cur.length == 1) {
|
if (e.shift && this._this.selectedRows.length == 1) {
|
||||||
// Shift key was pressed
|
// Shift key was pressed
|
||||||
var first_row_id = this._this.cur[0];
|
var first_row_id = this._this.selectedRows[0];
|
||||||
var last_row_id = this.rowId;
|
var last_row_id = this.rowId;
|
||||||
this._this.cur.empty();
|
this._this.selectedRows.empty();
|
||||||
var trs = this._this.table.getElements('tr');
|
var trs = this._this.table.getElements('tr');
|
||||||
var select = false;
|
var select = false;
|
||||||
for (var i = 0; i < trs.length; i++) {
|
for (var i = 0; i < trs.length; i++) {
|
||||||
var tr = trs[i];
|
var tr = trs[i];
|
||||||
|
|
||||||
if ((tr.rowId == first_row_id) || (tr.rowId == last_row_id)) {
|
if ((tr.rowId == first_row_id) || (tr.rowId == last_row_id)) {
|
||||||
this._this.cur.push(tr.rowId);
|
this._this.selectedRows.push(tr.rowId);
|
||||||
tr.addClass('selected');
|
tr.addClass('selected');
|
||||||
select = !select;
|
select = !select;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (select) {
|
if (select) {
|
||||||
this._this.cur.push(tr.rowId);
|
this._this.selectedRows.push(tr.rowId);
|
||||||
tr.addClass('selected');
|
tr.addClass('selected');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -377,8 +377,8 @@ var DynamicTable = new Class({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update context menu
|
// Update context menu
|
||||||
if (this.context_menu)
|
if (this.contextMenu)
|
||||||
this.context_menu.addTarget(tr);
|
this.contextMenu.addTarget(tr);
|
||||||
|
|
||||||
this.updateRow(tr, true);
|
this.updateRow(tr, true);
|
||||||
}
|
}
|
||||||
@ -407,7 +407,7 @@ var DynamicTable = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
removeRow : function (rowId) {
|
removeRow : function (rowId) {
|
||||||
this.cur.erase(rowId);
|
this.selectedRows.erase(rowId);
|
||||||
var tr = this.getTrByRowId(rowId);
|
var tr = this.getTrByRowId(rowId);
|
||||||
if (tr != null) {
|
if (tr != null) {
|
||||||
tr.dispose();
|
tr.dispose();
|
||||||
@ -418,7 +418,7 @@ var DynamicTable = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
clear : function () {
|
clear : function () {
|
||||||
this.cur.empty();
|
this.selectedRows.empty();
|
||||||
this.rows.empty();
|
this.rows.empty();
|
||||||
var trs = this.table.getElements('tr');
|
var trs = this.table.getElements('tr');
|
||||||
while (trs.length > 0) {
|
while (trs.length > 0) {
|
||||||
@ -428,7 +428,7 @@ var DynamicTable = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
selectedRowsIds : function () {
|
selectedRowsIds : function () {
|
||||||
return this.cur.slice();
|
return this.selectedRows.slice();
|
||||||
},
|
},
|
||||||
|
|
||||||
getRowIds : function () {
|
getRowIds : function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user