From f73256e0ea3cc312a7588108bda9f5caa9ea2225 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sun, 28 Sep 2008 16:23:08 +0000 Subject: [PATCH] - Fixed shift selection from bottom to top (Web UI) - Fixed bug where current selection was not cleared correctly (Web Ui) - Allow to select all torrents using CRTL+A (Web Ui) --- TODO | 1 + src/webui/scripts/client.js | 10 ++++++++++ src/webui/scripts/dynamicTable.js | 20 ++++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/TODO b/TODO index ba47193c3..ca5716c9c 100644 --- a/TODO +++ b/TODO @@ -4,3 +4,4 @@ See https://blueprints.launchpad.net/qbittorrent/ - french - chinese traditional - chinese simplified +- finish diff --git a/src/webui/scripts/client.js b/src/webui/scripts/client.js index 6793324ec..1abba58c8 100644 --- a/src/webui/scripts/client.js +++ b/src/webui/scripts/client.js @@ -147,3 +147,13 @@ window.addEvent('domready', function(){ ajaxfn(); // ajaxfn.periodical(5000); }); + +window.addEvent('keydown', function(event){ + if (event.key == 'a' && event.control) { + if($("Tab1").hasClass('active')) { + myTable.selectAll(); + } else { + myTableUP.selectAll(); + } + } +}); \ No newline at end of file diff --git a/src/webui/scripts/dynamicTable.js b/src/webui/scripts/dynamicTable.js index efeb90d6b..ae69cc700 100644 --- a/src/webui/scripts/dynamicTable.js +++ b/src/webui/scripts/dynamicTable.js @@ -106,6 +106,12 @@ var dynamicTable = new Class ({ ids = this.getRowIds(); beginIndex = ids.indexOf(this.cur[0]); endIndex = ids.indexOf(id); + if(beginIndex > endIndex) { + // Backward shift + tmp = beginIndex; + beginIndex = endIndex-1; + endIndex = tmp-1; + } for(i=beginIndex+1; i<(endIndex+1); i++) { curID = ids[i]; this.cur[this.cur.length] = curID; @@ -124,6 +130,7 @@ var dynamicTable = new Class ({ temptr.removeClass(this.options.selectCls); } } + this.cur.empty(); // Add selected style to new one temptr = this.rows[id]; if(temptr){ @@ -137,6 +144,19 @@ var dynamicTable = new Class ({ tr.injectInside(this.table); this.altRow(); }, + + selectAll: function() { + this.cur.empty(); + for (var id in this.rows) { + this.cur[this.cur.length] = id; + temptr = this.rows[id]; + if(temptr){ + if(!temptr.hasClass(this.options.selectCls)) { + temptr.addClass(this.options.selectCls); + } + } + } + }, updateRow: function(id, row){ var tr = this.rows[id];