From 21701cb096cb83218c6b657e05246ce4e7ae65a8 Mon Sep 17 00:00:00 2001 From: Damien Churchill Date: Tue, 20 Oct 2009 22:33:18 +0000 Subject: [PATCH] fix setting bandwidth limits via the statusbar --- deluge/ui/web/js/Deluge.Menus.js | 21 ++++++++++++++++----- deluge/ui/web/js/Deluge.Statusbar.js | 14 +++----------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/deluge/ui/web/js/Deluge.Menus.js b/deluge/ui/web/js/Deluge.Menus.js index c20f64d35..3ede856bb 100644 --- a/deluge/ui/web/js/Deluge.Menus.js +++ b/deluge/ui/web/js/Deluge.Menus.js @@ -243,7 +243,18 @@ Deluge.Menus.Torrent = new Ext.menu.Menu({ }] }); -Deluge.Menus.Connections = new Ext.menu.Menu({ +Ext.deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, { + + setValue: function(value) { + var item = this.items.get(value); + if (!item) item = this.items.get('other') + item.suspendEvents(); + item.setChecked(true); + item.resumeEvents(); + } +}); + +Deluge.Menus.Connections = new Ext.deluge.StatusbarMenu({ id: 'connectionsMenu', items: [{ id: '50', @@ -290,7 +301,7 @@ Deluge.Menus.Connections = new Ext.menu.Menu({ }] }); -Deluge.Menus.Download = new Ext.menu.Menu({ +Deluge.Menus.Download = new Ext.deluge.StatusbarMenu({ id: 'downspeedMenu', items: [{ id: '5', @@ -337,7 +348,7 @@ Deluge.Menus.Download = new Ext.menu.Menu({ }] }); -Deluge.Menus.Upload = new Ext.menu.Menu({ +Deluge.Menus.Upload = new Ext.deluge.StatusbarMenu({ id: 'upspeedMenu', items: [{ id: '5', @@ -414,7 +425,7 @@ Deluge.Menus.FilePriorities = new Ext.menu.Menu({ }); function onLimitChanged(item, checked) { - /*if (item.id == "other") { + if (item.id == "other") { } else { config = {} config[item.group] = item.id @@ -423,5 +434,5 @@ function onLimitChanged(item, checked) { Deluge.UI.update(); } }); - }*/ + } } \ No newline at end of file diff --git a/deluge/ui/web/js/Deluge.Statusbar.js b/deluge/ui/web/js/Deluge.Statusbar.js index 378aef74b..81befe81a 100644 --- a/deluge/ui/web/js/Deluge.Statusbar.js +++ b/deluge/ui/web/js/Deluge.Statusbar.js @@ -131,18 +131,10 @@ }); this.items.get('statusbar-dht').setText(stats.dht_nodes); - - function updateMenu(menu, stat) { - var item = menu.items.get(stat) - if (!item) { - item = menu.items.get('other') - } - item.setChecked(true); - } - updateMenu(Deluge.Menus.Connections, stats.max_num_connections); - updateMenu(Deluge.Menus.Download, stats.max_download); - updateMenu(Deluge.Menus.Upload, stats.max_upload); + Deluge.Menus.Connections.setValue(stats.max_num_connections); + Deluge.Menus.Download.setValue(stats.max_download); + Deluge.Menus.Upload.setValue(stats.max_upload); } }); Deluge.Statusbar = new Ext.deluge.Statusbar();