diff --git a/deluge/ui/webui/templates/ajax/static/js/deluge-bars.js b/deluge/ui/webui/templates/ajax/static/js/deluge-bars.js index 2621b87e1..2f2f4e4b7 100644 --- a/deluge/ui/webui/templates/ajax/static/js/deluge-bars.js +++ b/deluge/ui/webui/templates/ajax/static/js/deluge-bars.js @@ -106,10 +106,11 @@ Deluge.Widgets.Labels = new Class({ */ labelClicked: function(e) { this.currentFilter.removeClass('activestate'); - this.filterType = e.filter; - this.filterName = e.name; + this.filterType = e.name; + this.filterName = e.filter; this.currentFilter = e.target; e.target.addClass('activestate'); + this.fireEvent('filterChanged'); } }); diff --git a/deluge/ui/webui/templates/ajax/static/js/deluge-torrent-grid.js b/deluge/ui/webui/templates/ajax/static/js/deluge-torrent-grid.js index 973756505..302e8af31 100644 --- a/deluge/ui/webui/templates/ajax/static/js/deluge-torrent-grid.js +++ b/deluge/ui/webui/templates/ajax/static/js/deluge-torrent-grid.js @@ -51,19 +51,16 @@ Deluge.Widgets.TorrentGrid = new Class({ }, updateTorrents: function(torrents) { - torrents.getKeys().each(function(torrentId) { - var torrent = torrents[torrentId] - var torrentIds = torrents.getKeys() - if (torrent.queue == -1) {var queue = ''} - else {var queue = torrent.queue + 1} - var icon = this.icons[torrent.state] + torrents.each(function(torrent, id) { + torrent.queue = (torrent.queue > -1) ? torrent.queue + 1 : '' + torrent.icon = this.icons[torrent.state] row = { - id: torrentId, + id: id, data: { - number: queue, - name: {text: torrent.name, icon: icon}, + number: torrent.queue, + name: {text: torrent.name, icon: torrent.icon}, size: torrent.total_size, - progress: {percent: torrent.progress, text:torrent.state + ' ' + torrent.progress.toFixed(2) + '%'}, + progress: {percent: torrent.progress, text: torrent.state + ' ' + torrent.progress.toFixed(2) + '%'}, seeders: torrent.num_seeds + ' (' + torrent.total_seeds + ')', peers: torrent.num_peers + ' (' + torrent.total_peers + ')', down: torrent.download_payload_rate, @@ -75,18 +72,16 @@ Deluge.Widgets.TorrentGrid = new Class({ torrent: torrent } if (this.has(row.id)) { - this.updateRow(row, true) + this.updateRow(row, true); } else { - this.addRow(row, true) + this.addRow(row, true); } - - this.rows.each(function(row) { - if (!torrentIds.contains(row.id)) { - row.element.destroy() - this.rows.erase(row.id) - } - }, this) - }, this) - this.render() + }, this); + this.rows.each(function(row) { + if (!torrents.has(row.id)) { + delete this.rows[this.rows.indexOf(row)] + }; + }, this); + this.render(); } }); diff --git a/deluge/ui/webui/templates/ajax/static/js/deluge-ui.js b/deluge/ui/webui/templates/ajax/static/js/deluge-ui.js index 5af401b3e..a7c0d9065 100644 --- a/deluge/ui/webui/templates/ajax/static/js/deluge-ui.js +++ b/deluge/ui/webui/templates/ajax/static/js/deluge-ui.js @@ -21,7 +21,7 @@ Deluge.UI = { resized: this.resized.bindWithEvent(this), toolbarClick: this.toolbarClick.bindWithEvent(this), filePriorities: this.filePriorities.bindWithEvent(this), - labelsChanged: this.labelsChanged.bindWithEvent(this) + filterChanged: this.filterChanged.bindWithEvent(this) }; this.loadUi.delay(250, this); }, @@ -42,7 +42,7 @@ Deluge.UI = { this.initializeGrid() this.split_horz = new Widgets.SplitPane('top', this.labels, this.grid, { - pane1: {min: 150}, + pane1: {min: 180}, pane2: {min: 100, expand: true} }); var details = $W('details') @@ -59,11 +59,11 @@ Deluge.UI = { this.details.expand() this.toolbar.addEvent('buttonClick', this.bound.toolbarClick); - this.details.addEvent('filesAction', this.bound.filePriorities) - this.labels.addEvent('stateChanged', this.bound.labelsChanged) + this.details.addEvent('filesAction', this.bound.filePriorities); + this.labels.addEvent('filterChanged', this.bound.filterChanged); details.addEvent('resize', function(e) { - this.details.expand() - }.bindWithEvent(this)) + this.details.expand(); + }.bindWithEvent(this)); window.addEvent('resize', this.bound.resized); Deluge.UI.update(); @@ -136,7 +136,10 @@ Deluge.UI = { update: function() { filter = {}; - //if (this.labels.state != 'All') filter['state'] = this.labels.state; + var type = this.labels.filterType, name = this.labels.filterName + if (type && !(type == 'state' && name == 'All')) { + filter[this.labels.filterType] = this.labels.filterName; + } Deluge.Client.update_ui(Deluge.Keys.Grid, filter, { onSuccess: this.bound.updated }); @@ -186,8 +189,8 @@ Deluge.UI = { this.torrentAction(event.action); }, - labelsChanged: function(event) { - this.update() + filterChanged: function(event) { + this.update(); }, torrentAction: function(action, value) { diff --git a/deluge/ui/webui/templates/ajax/static/js/mooui.js b/deluge/ui/webui/templates/ajax/static/js/mooui.js index 3e456cae8..268ca0747 100644 --- a/deluge/ui/webui/templates/ajax/static/js/mooui.js +++ b/deluge/ui/webui/templates/ajax/static/js/mooui.js @@ -1357,13 +1357,11 @@ Widgets.DataGrid = new Class({ }, filter: function() { - if (!$chk(this.filterer)) { - this.filterer = $lambda(true) - } - this.displayRows.empty() - this.rows.each(function(r) { - if (this.filterer(r)) {this.displayRows.include(r)} - }.bind(this)) + this.filterer = (this.filterer) ? this.filterer : $lambda(true); + this.displayRows.empty(); + this.rows.each(function(row) { + if (this.filterer(row)) {this.displayRows.include(row)} + }.bind(this)); }, getById: function(id) { @@ -1390,8 +1388,8 @@ Widgets.DataGrid = new Class({ }, render: function() { - this.filter() - this.resort() + this.filter(); + this.resort(); var rows = [], rowIds = [] this.rows.each(function(row) { if (this.displayRows.contains(row)) {