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
parent 83ff72490c
commit 763a422a15
2 changed files with 188 additions and 122 deletions

View File

@ -21,127 +21,193 @@ 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) { constructor: function(config) {
config = Ext.apply({ config = Ext.apply({
title: _('Edit Trackers'), title: _('Add Tracker'),
width: 300, width: 300,
height: 220, height: 150,
bodyStyle: 'padding: 5px', bodyStyle: 'padding: 5px',
layout: 'fit', layout: 'fit',
buttonAlign: 'right', buttonAlign: 'right',
closeAction: 'hide', closeAction: 'hide',
closable: true, closable: true,
iconCls: 'x-deluge-edit-trackers', iconCls: 'x-deluge-edit-trackers',
plain: true, plain: true,
resizable: true resizable: false
}, config); }, config);
Ext.deluge.EditTrackers.superclass.constructor.call(this, config); Ext.deluge.AddTracker.superclass.constructor.call(this, config);
}, }
});
initComponent: function() { Ext.deluge.EditTracker = Ext.extend(Ext.Window, {
Ext.deluge.EditTrackers.superclass.initComponent.call(this); 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) {
config = Ext.apply({
title: _('Edit Trackers'),
width: 350,
height: 220,
bodyStyle: 'padding: 5px',
layout: 'fit',
buttonAlign: 'right',
closeAction: 'hide',
closable: true,
iconCls: 'x-deluge-edit-trackers',
plain: true,
resizable: true
}, config);
Ext.deluge.EditTrackers.superclass.constructor.call(this, config);
},
this.addButton(_('Cancel'), this.onCancel, this); initComponent: function() {
this.addButton(_('Ok'), this.onOk, this); Ext.deluge.EditTrackers.superclass.initComponent.call(this);
this.on('show', this.onShow, this); this.addButton(_('Cancel'), this.onCancel, this);
this.addButton(_('Ok'), this.onOk, this);
this.grid = this.add({
xtype: 'grid', this.on('show', this.onShow, this);
store: new Ext.data.SimpleStore({
fields: [ this.addWindow = new Ext.deluge.AddTracker();
{name: 'tier', mapping: 0}, this.editWindow = new Ext.deluge.EditTracker();
{name: 'url', mapping: 1}
] this.grid = this.add({
}), xtype: 'grid',
columns: [{ store: new Ext.data.SimpleStore({
header: _('Tier'), fields: [
width: 50, {name: 'tier', mapping: 0},
sortable: true, {name: 'url', mapping: 1}
renderer: fplain, ]
dataIndex: 'tier' }),
}, { columns: [{
id:'tracker', header: _('Tier'),
header: _('Tracker'), width: 50,
sortable: true, sortable: true,
renderer: fplain, renderer: fplain,
dataIndex: 'url' dataIndex: 'tier'
}], }, {
stripeRows: true, id:'tracker',
selModel: new Ext.grid.RowSelectionModel({ header: _('Tracker'),
singleSelect: true, sortable: true,
listeners: { renderer: fplain,
'rowselect': {fn: this.onSelect, scope: this} dataIndex: 'url'
} }],
}), stripeRows: true,
autoExpandColumn: 'tracker', selModel: new Ext.grid.RowSelectionModel({
deferredRender:false, singleSelect: true,
autoScroll:true, listeners: {
margins: '0 0 0 0', 'rowselect': {fn: this.onSelect, scope: this}
bbar: new Ext.Toolbar({
items: [
{
id: 'up',
cls: 'x-btn-text-icon',
text: _('Up'),
icon: '/icons/up.png',
handler: this.onUp,
scope: this
}, {
id: 'down',
cls: 'x-btn-text-icon',
text: _('Down'),
icon: '/icons/down.png',
handler: this.onDown,
scope: this
}, '->', {
id: 'add',
cls: 'x-btn-text-icon',
text: _('Add'),
icon: '/icons/add.png',
handler: this.onAdd,
scope: this
}, {
id: 'remove',
cls: 'x-btn-text-icon',
text: _('Remove'),
icon: '/icons/remove.png',
handler: this.onRemove,
scope: this
} }
] }),
}) autoExpandColumn: 'tracker',
}); deferredRender:false,
}, autoScroll:true,
margins: '0 0 0 0',
onCancel: function() { bbar: new Ext.Toolbar({
this.hide(); items: [
}, {
cls: 'x-btn-text-icon',
onHide: function() { text: _('Up'),
this.grid.getStore().removeAll(); icon: '/icons/up.png',
}, handler: this.onUp,
scope: this
onOk: function() { }, {
this.hide(); cls: 'x-btn-text-icon',
}, text: _('Down'),
icon: '/icons/down.png',
onRequestComplete: function(status) { handler: this.onDown,
var trackers = []; scope: this
Ext.each(status['trackers'], function(tracker) { }, '->', {
trackers.push([tracker['tier'], tracker['url']]); cls: 'x-btn-text-icon',
}); text: _('Add'),
this.grid.getStore().loadData(trackers); icon: '/icons/add.png',
}, handler: this.onAdd,
scope: this
onShow: function() { }, {
var r = Deluge.Torrents.getSelected(); cls: 'x-btn-text-icon',
Deluge.Client.core.get_torrent_status(r.id, ['trackers'], { text: _('Edit'),
success: this.onRequestComplete, icon: '/icons/edit_trackers.png',
scope: this handler: this.onEdit,
}); scope: this
} }, {
}); cls: 'x-btn-text-icon',
Deluge.EditTrackers = new Ext.deluge.EditTrackers(); text: _('Remove'),
icon: '/icons/remove.png',
handler: this.onRemove,
scope: this
}
]
})
});
},
onAdd: function() {
this.addWindow.show();
},
onCancel: function() {
this.hide();
},
onEdit: function() {
this.editWindow.show();
},
onHide: function() {
this.grid.getStore().removeAll();
},
onOk: function() {
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) {
var trackers = [];
Ext.each(status['trackers'], function(tracker) {
trackers.push([tracker['tier'], tracker['url']]);
});
this.grid.getStore().loadData(trackers);
},
onShow: function() {
var r = Deluge.Torrents.getSelected();
this.torrentId = r.id;
Deluge.Client.core.get_torrent_status(r.id, ['trackers'], {
success: this.onRequestComplete,
scope: this
});
}
});
Deluge.EditTrackers = new Ext.deluge.EditTrackers();
})();

File diff suppressed because one or more lines are too long