diff --git a/deluge/ui/web/js/deluge-all/add/FilesTab.js b/deluge/ui/web/js/deluge-all/add/FilesTab.js index 128ff3aca..e1eccc063 100644 --- a/deluge/ui/web/js/deluge-all/add/FilesTab.js +++ b/deluge/ui/web/js/deluge-all/add/FilesTab.js @@ -84,18 +84,24 @@ Deluge.add.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, { }); }, - setDownload: function(node, value) { + setDownload: function(node, value, suppress) { node.attributes.download = value; node.ui.updateColumns(); if (node.isLeaf()) { - return this.fireEvent('filechecked', node, value, !value); + if (!suppress) { + return this.fireEvent('fileschecked', [node], value, !value); + } } else { + var nodes = [node]; node.cascade(function(n) { n.attributes.download = value; n.ui.updateColumns(); - return this.fireEvent('filechecked', n, value, !value); + nodes.push(n); }, this); + if (!suppress) { + return this.fireEvent('fileschecked', nodes, value, !value); + } } }, diff --git a/deluge/ui/web/js/deluge-all/add/OptionsPanel.js b/deluge/ui/web/js/deluge-all/add/OptionsPanel.js index b6e1a55fd..2d37bde91 100644 --- a/deluge/ui/web/js/deluge-all/add/OptionsPanel.js +++ b/deluge/ui/web/js/deluge-all/add/OptionsPanel.js @@ -46,7 +46,7 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, { this.files = this.add(new Deluge.add.FilesTab()); this.form = this.add(new Deluge.add.OptionsTab()); - this.files.on('filechecked', this.onFileChecked, this); + this.files.on('fileschecked', this.onFilesChecked, this); }, addTorrent: function(torrent) { @@ -125,34 +125,35 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, { } }, - onFileChecked: function(node, newValue, oldValue) { - if (!Ext.isNumber(node.attributes.fileindex)) return; - -// if (this.form.optionsManager.get('compact_allocation')) { -// Ext.Msg.show({ -// title: _('Unable to set file priority!'), -// msg: _('File prioritization is unavailable when using Compact allocation. Would you like to switch to Full allocation?'), -// buttons: Ext.Msg.YESNO, -// fn: function(result) { -// if (result == 'yes') { -// var priorities = this.form.optionsManager.get('file_priorities'); -// priorities[node.attributes.fileindex] = (result) ? newValue : oldValue; -// this.form.optionsManager.update('file_priorities', priorities); -// } else { -// node.attributes.download = oldValue; -// node.ui.updateColumns(); -// } -// }, -// scope: this, -// icon: Ext.MessageBox.QUESTION -// }); -// } else { -// var priorities = this.form.optionsManager.get('file_priorities'); -// priorities[node.attributes.fileindex] = newValue; -// this.form.optionsManager.update('file_priorities', priorities); -// } - var priorities = this.form.optionsManager.get('file_priorities'); - priorities[node.attributes.fileindex] = newValue; - this.form.optionsManager.update('file_priorities', priorities); + onFilesChecked: function(nodes, newValue, oldValue) { + if (this.form.optionsManager.get('compact_allocation')) { + Ext.Msg.show({ + title: _('Unable to set file priority!'), + msg: _('File prioritization is unavailable when using Compact allocation. Would you like to switch to Full allocation?'), + buttons: Ext.Msg.YESNO, + fn: function(result) { + if (result == 'yes') { + this.form.optionsManager.update('compact_allocation', false); + Ext.each(nodes, function(node) { + if (node.attributes.fileindex < 0) return; + var priorities = this.form.optionsManager.get('file_priorities'); + priorities[node.attributes.fileindex] = newValue; + this.form.optionsManager.update('file_priorities', priorities); + }, this); + } else { + this.files.setDownload(nodes[0], oldValue, true); + } + }, + scope: this, + icon: Ext.MessageBox.QUESTION + }); + } else { + Ext.each(nodes, function(node) { + if (node.attributes.fileindex < 0) return; + var priorities = this.form.optionsManager.get('file_priorities'); + priorities[node.attributes.fileindex] = newValue; + this.form.optionsManager.update('file_priorities', priorities); + }, this); + } } });