increase window side and add stubs for the add/edit windows

This commit is contained in:
Damien Churchill 2009-05-05 20:23:10 +00:00
commit 763a422a15
2 changed files with 188 additions and 122 deletions

View file

@ -21,12 +21,51 @@ Copyright:
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
Ext.deluge.EditTrackers = Ext.extend(Ext.Window, { (function() {
Ext.deluge.AddTracker = Ext.extend(Ext.Window, {
constructor: function(config) {
config = Ext.apply({
title: _('Add Tracker'),
width: 300,
height: 150,
bodyStyle: 'padding: 5px',
layout: 'fit',
buttonAlign: 'right',
closeAction: 'hide',
closable: true,
iconCls: 'x-deluge-edit-trackers',
plain: true,
resizable: false
}, config);
Ext.deluge.AddTracker.superclass.constructor.call(this, config);
}
});
Ext.deluge.EditTracker = Ext.extend(Ext.Window, {
constructor: function(config) {
config = Ext.apply({
title: _('Edit Tracker'),
width: 300,
height: 150,
bodyStyle: 'padding: 5px',
layout: 'fit',
buttonAlign: 'right',
closeAction: 'hide',
closable: true,
iconCls: 'x-deluge-edit-trackers',
plain: true,
resizable: false
}, config);
Ext.deluge.EditTracker.superclass.constructor.call(this, config);
}
});
Ext.deluge.EditTrackers = Ext.extend(Ext.Window, {
constructor: function(config) { constructor: function(config) {
config = Ext.apply({ config = Ext.apply({
title: _('Edit Trackers'), title: _('Edit Trackers'),
width: 300, width: 350,
height: 220, height: 220,
bodyStyle: 'padding: 5px', bodyStyle: 'padding: 5px',
layout: 'fit', layout: 'fit',
@ -48,6 +87,9 @@ Ext.deluge.EditTrackers = Ext.extend(Ext.Window, {
this.on('show', this.onShow, this); this.on('show', this.onShow, this);
this.addWindow = new Ext.deluge.AddTracker();
this.editWindow = new Ext.deluge.EditTracker();
this.grid = this.add({ this.grid = this.add({
xtype: 'grid', xtype: 'grid',
store: new Ext.data.SimpleStore({ store: new Ext.data.SimpleStore({
@ -83,28 +125,30 @@ Ext.deluge.EditTrackers = Ext.extend(Ext.Window, {
bbar: new Ext.Toolbar({ bbar: new Ext.Toolbar({
items: [ items: [
{ {
id: 'up',
cls: 'x-btn-text-icon', cls: 'x-btn-text-icon',
text: _('Up'), text: _('Up'),
icon: '/icons/up.png', icon: '/icons/up.png',
handler: this.onUp, handler: this.onUp,
scope: this scope: this
}, { }, {
id: 'down',
cls: 'x-btn-text-icon', cls: 'x-btn-text-icon',
text: _('Down'), text: _('Down'),
icon: '/icons/down.png', icon: '/icons/down.png',
handler: this.onDown, handler: this.onDown,
scope: this scope: this
}, '->', { }, '->', {
id: 'add',
cls: 'x-btn-text-icon', cls: 'x-btn-text-icon',
text: _('Add'), text: _('Add'),
icon: '/icons/add.png', icon: '/icons/add.png',
handler: this.onAdd, handler: this.onAdd,
scope: this scope: this
}, { }, {
id: 'remove', cls: 'x-btn-text-icon',
text: _('Edit'),
icon: '/icons/edit_trackers.png',
handler: this.onEdit,
scope: this
}, {
cls: 'x-btn-text-icon', cls: 'x-btn-text-icon',
text: _('Remove'), text: _('Remove'),
icon: '/icons/remove.png', icon: '/icons/remove.png',
@ -116,10 +160,18 @@ Ext.deluge.EditTrackers = Ext.extend(Ext.Window, {
}); });
}, },
onAdd: function() {
this.addWindow.show();
},
onCancel: function() { onCancel: function() {
this.hide(); this.hide();
}, },
onEdit: function() {
this.editWindow.show();
},
onHide: function() { onHide: function() {
this.grid.getStore().removeAll(); this.grid.getStore().removeAll();
}, },
@ -128,6 +180,18 @@ Ext.deluge.EditTrackers = Ext.extend(Ext.Window, {
this.hide(); this.hide();
}, },
onRemove: function() {
// Remove from the grid
Deluge.Client.core.set_torrent_trackers(this.torrentId, trackers, {
failure: this.onRemoveFail,
scope: this
});
},
onRemoveFail: function() {
},
onRequestComplete: function(status) { onRequestComplete: function(status) {
var trackers = []; var trackers = [];
Ext.each(status['trackers'], function(tracker) { Ext.each(status['trackers'], function(tracker) {
@ -138,10 +202,12 @@ Ext.deluge.EditTrackers = Ext.extend(Ext.Window, {
onShow: function() { onShow: function() {
var r = Deluge.Torrents.getSelected(); var r = Deluge.Torrents.getSelected();
this.torrentId = r.id;
Deluge.Client.core.get_torrent_status(r.id, ['trackers'], { Deluge.Client.core.get_torrent_status(r.id, ['trackers'], {
success: this.onRequestComplete, success: this.onRequestComplete,
scope: this scope: this
}); });
} }
}); });
Deluge.EditTrackers = new Ext.deluge.EditTrackers(); Deluge.EditTrackers = new Ext.deluge.EditTrackers();
})();

File diff suppressed because one or more lines are too long