Browse Source

- Allow the user to use CTRL key to select multiple item in Web UI transfer list

adaptive-webui-19844
Christophe Dumez 16 years ago
parent
commit
56885cc914
  1. 1
      Changelog
  2. 38
      src/webui/scripts/dynamicTable.js
  3. 17
      src/webui/scripts/mocha-events.js

1
Changelog

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
- FEATURE: RSS can now be disabled from program preferences
- FEATURE: Added collapse/expand all buttons in addition dialog
- FEATURE: Can have different proxies for Bittorrent and search engine
- FEATURE: Allow multiple item selection in Web UI transfer list
- BUGFIX: Disable ETA calculation when ETA column is hidden
- BUGFIX: Removed "disconnected" connection state, detection was far from perfect
- COSMETIC: Transfer speed, ratio, connection status and DHT nodes are displayed in status bar

38
src/webui/scripts/dynamicTable.js

@ -41,7 +41,7 @@ var dynamicTable = new Class ({ @@ -41,7 +41,7 @@ var dynamicTable = new Class ({
}, options);
this.table = $(table);
this.rows = new Object();
this.cur = false;
this.cur = new Array();
},
altRow: function()
@ -79,15 +79,41 @@ var dynamicTable = new Class ({ @@ -79,15 +79,41 @@ var dynamicTable = new Class ({
}.bind(this));
}
tr.addEvent('click', function(e){
var temptr = this.rows[this.cur];
if(e.control) {
found = false;
if(this.cur.contains(id)) {
// remove it
this.cur.erase(id);
// Remove selected style
temptr = this.rows[id];
if(temptr){
temptr.removeClass(this.options.selectCls);
}
} else {
this.cur[this.cur.length] = id;
// Add selected style
temptr = this.rows[id];
if(temptr){
temptr.addClass(this.options.selectCls);
}
this.cur = id;
}
} else {
//TODO: handle alt key
// Control key is not pressed
// Remove selected style from previous ones
for(i=0; i<this.cur.length; i++) {
var temptr = this.rows[this.cur[i]];
if(temptr){
temptr.removeClass(this.options.selectCls);
}
}
// Add selected style to new one
temptr = this.rows[id];
if(temptr){
temptr.addClass(this.options.selectCls);
}
this.cur[0] = id;
}
}.bind(this));
tr.injectInside(this.table);
@ -108,9 +134,9 @@ var dynamicTable = new Class ({ @@ -108,9 +134,9 @@ var dynamicTable = new Class ({
},
removeRow: function(id){
if(this.cur === id)
if(this.cur.contains(id))
{
this.cur = false;
this.cur.erase(id);
}
var tr = this.rows[id];
if($defined(tr))
@ -122,7 +148,7 @@ var dynamicTable = new Class ({ @@ -122,7 +148,7 @@ var dynamicTable = new Class ({
return false;
},
selectedId: function(){
selectedIds: function(){
return this.cur;
},

17
src/webui/scripts/mocha-events.js

@ -55,17 +55,22 @@ function attachMochaLinkEvents(){ @@ -55,17 +55,22 @@ function attachMochaLinkEvents(){
addClickEvent('delete', function(e){
new Event(e).stop();
var h = myTable.selectedId();
if(h && confirm('Are you sure you want to delete the selected item in download list?'))
new Request({url: '/command/delete', method: 'post', data: {hash: h}}).send();
var h = myTable.selectedIds();
if(h.length && confirm('Are you sure you want to delete the selected item in download list?')) {
h.each(function(item, index){
new Request({url: '/command/delete', method: 'post', data: {hash: item}}).send();
});
}
});
['pause','resume'].each(function(item) {
addClickEvent(item, function(e){
new Event(e).stop();
var h = myTable.selectedId();
if(h){
new Request({url: '/command/'+item, method: 'post', data: {hash: h}}).send();
var h = myTable.selectedIds();
if(h.length){
h.each(function(item, index){
new Request({url: '/command/'+item, method: 'post', data: {hash: item}}).send();
});
}
});

Loading…
Cancel
Save