mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-09 05:14:23 +00:00
Merge pull request #9059 from Piccirello/meta-key
Add WebUI support for Mac ⌘ (Command) key
This commit is contained in:
commit
dc20fff6e4
@ -465,6 +465,10 @@ var DynamicTable = new Class({
|
|||||||
return '';
|
return '';
|
||||||
},
|
},
|
||||||
|
|
||||||
|
isRowSelected: function(rowId) {
|
||||||
|
return this.selectedRows.contains(rowId);
|
||||||
|
},
|
||||||
|
|
||||||
altRow: function() {
|
altRow: function() {
|
||||||
if (!MUI.ieLegacySupport)
|
if (!MUI.ieLegacySupport)
|
||||||
return;
|
return;
|
||||||
@ -481,7 +485,7 @@ var DynamicTable = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
selectAll: function() {
|
selectAll: function() {
|
||||||
this.selectedRows.empty();
|
this.deselectAll();
|
||||||
|
|
||||||
var trs = this.tableBody.getElements('tr');
|
var trs = this.tableBody.getElements('tr');
|
||||||
for (var i = 0; i < trs.length; ++i) {
|
for (var i = 0; i < trs.length; ++i) {
|
||||||
@ -497,14 +501,36 @@ var DynamicTable = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
selectRow: function(rowId) {
|
selectRow: function(rowId) {
|
||||||
this.deselectAll();
|
|
||||||
this.selectedRows.push(rowId);
|
this.selectedRows.push(rowId);
|
||||||
|
this.setRowClass();
|
||||||
|
this.onSelectedRowChanged();
|
||||||
|
},
|
||||||
|
|
||||||
|
deselectRow: function(rowId) {
|
||||||
|
this.selectedRows.erase(rowId);
|
||||||
|
this.setRowClass();
|
||||||
|
this.onSelectedRowChanged();
|
||||||
|
},
|
||||||
|
|
||||||
|
selectRows: function(rowId1, rowId2) {
|
||||||
|
this.deselectAll();
|
||||||
|
if (rowId1 === rowId2) {
|
||||||
|
this.selectRow(rowId1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var select = false;
|
||||||
|
var that = this;
|
||||||
this.tableBody.getElements('tr').each(function(tr) {
|
this.tableBody.getElements('tr').each(function(tr) {
|
||||||
if (tr.rowId == rowId)
|
if ((tr.rowId == rowId1) || (tr.rowId == rowId2)) {
|
||||||
tr.addClass('selected');
|
select = !select;
|
||||||
else
|
that.selectedRows.push(tr.rowId);
|
||||||
tr.removeClass('selected');
|
}
|
||||||
|
else if (select) {
|
||||||
|
that.selectedRows.push(tr.rowId);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
this.setRowClass();
|
||||||
this.onSelectedRowChanged();
|
this.onSelectedRowChanged();
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -517,6 +543,16 @@ var DynamicTable = new Class({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setRowClass: function() {
|
||||||
|
var that = this;
|
||||||
|
this.tableBody.getElements('tr').each(function(tr) {
|
||||||
|
if (that.isRowSelected(tr.rowId))
|
||||||
|
tr.addClass('selected');
|
||||||
|
else
|
||||||
|
tr.removeClass('selected');
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
onSelectedRowChanged: function() {},
|
onSelectedRowChanged: function() {},
|
||||||
|
|
||||||
updateRowData: function(data) {
|
updateRowData: function(data) {
|
||||||
@ -604,56 +640,29 @@ var DynamicTable = new Class({
|
|||||||
|
|
||||||
tr._this = this;
|
tr._this = this;
|
||||||
tr.addEvent('contextmenu', function(e) {
|
tr.addEvent('contextmenu', function(e) {
|
||||||
if (!this._this.selectedRows.contains(this.rowId))
|
if (!this._this.isRowSelected(this.rowId)) {
|
||||||
|
this._this.deselectAll();
|
||||||
this._this.selectRow(this.rowId);
|
this._this.selectRow(this.rowId);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
tr.addEvent('click', function(e) {
|
tr.addEvent('click', function(e) {
|
||||||
e.stop();
|
e.stop();
|
||||||
if (e.control) {
|
if (e.control || e.meta) {
|
||||||
// CTRL key was pressed
|
// CTRL/CMD ⌘ key was pressed
|
||||||
if (this._this.selectedRows.contains(this.rowId)) {
|
if (this._this.isRowSelected(this.rowId))
|
||||||
// remove it
|
this._this.deselectRow(this.rowId);
|
||||||
this._this.selectedRows.erase(this.rowId);
|
else
|
||||||
// Remove selected style
|
this._this.selectRow(this.rowId);
|
||||||
this.removeClass('selected');
|
}
|
||||||
}
|
else if (e.shift && (this._this.selectedRows.length == 1)) {
|
||||||
else {
|
// Shift key was pressed
|
||||||
this._this.selectedRows.push(this.rowId);
|
this._this.selectRows(this._this.getSelectedRowId(), this.rowId);
|
||||||
// Add selected style
|
|
||||||
this.addClass('selected');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (e.shift && this._this.selectedRows.length == 1) {
|
// Simple selection
|
||||||
// Shift key was pressed
|
this._this.deselectAll();
|
||||||
var first_row_id = this._this.selectedRows[0];
|
this._this.selectRow(this.rowId);
|
||||||
var last_row_id = this.rowId;
|
|
||||||
this._this.selectedRows.empty();
|
|
||||||
var trs = this._this.tableBody.getElements('tr');
|
|
||||||
var select = false;
|
|
||||||
for (var i = 0; i < trs.length; ++i) {
|
|
||||||
var tr = trs[i];
|
|
||||||
|
|
||||||
if ((tr.rowId == first_row_id) || (tr.rowId == last_row_id)) {
|
|
||||||
this._this.selectedRows.push(tr.rowId);
|
|
||||||
tr.addClass('selected');
|
|
||||||
select = !select;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (select) {
|
|
||||||
this._this.selectedRows.push(tr.rowId);
|
|
||||||
tr.addClass('selected');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
tr.removeClass('selected');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Simple selection
|
|
||||||
this._this.selectRow(this.rowId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
@ -719,7 +728,7 @@ var DynamicTable = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
clear: function() {
|
clear: function() {
|
||||||
this.selectedRows.empty();
|
this.deselectAll();
|
||||||
this.rows.empty();
|
this.rows.empty();
|
||||||
var trs = this.tableBody.getElements('tr');
|
var trs = this.tableBody.getElements('tr');
|
||||||
while (trs.length > 0) {
|
while (trs.length > 0) {
|
||||||
@ -1199,6 +1208,7 @@ var TorrentsTable = new Class({
|
|||||||
setupTr: function(tr) {
|
setupTr: function(tr) {
|
||||||
tr.addEvent('dblclick', function(e) {
|
tr.addEvent('dblclick', function(e) {
|
||||||
e.stop();
|
e.stop();
|
||||||
|
this._this.deselectAll();
|
||||||
this._this.selectRow(this.rowId);
|
this._this.selectRow(this.rowId);
|
||||||
var row = this._this.rows.get(this.rowId);
|
var row = this._this.rows.get(this.rowId);
|
||||||
var state = row['full_data'].state;
|
var state = row['full_data'].state;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user