deluge/deluge/ui/web/js/deluge-all/details/DetailsPanel.js
Calum Lind 610a1bb313 [Lint] Update pre-commit hook and isort versions
* Fixed black hook requiring Py3.6 to installed locally. Will now assume
Py3.6+ in installed.
 * Added isort traceback in pre-commit flake8 hook fails
 * Updated versions of Black, Prettier and isort
 * Keep Flake8 at 3.7.9 due to E402 issue: https://gitlab.com/pycqa/flake8/-/issues/638
 * New pyproject config for isort v5 with fixes for Python 2 imports.
 * Fixed travis config to run Python 3.6 for lint run. Replaced the
virtualenv with_system_site_packages config with Travis specific Python
config value so lint run doesn't attempt to append with_system_site_packages
to Python 3.6 command.
2021-01-24 20:40:20 +00:00

82 lines
2.3 KiB
JavaScript

/**
* Deluge.details.DetailsPanel.js
*
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com>
*
* This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with
* the additional special exception to link portions of this program with the OpenSSL library.
* See LICENSE for more details.
*/
Ext.namespace('Deluge.details');
/**
* @class Deluge.details.DetailsPanel
*/
Deluge.details.DetailsPanel = Ext.extend(Ext.TabPanel, {
id: 'torrentDetails',
activeTab: 0,
initComponent: function () {
Deluge.details.DetailsPanel.superclass.initComponent.call(this);
this.add(new Deluge.details.StatusTab());
this.add(new Deluge.details.DetailsTab());
this.add(new Deluge.details.FilesTab());
this.add(new Deluge.details.PeersTab());
this.add(new Deluge.details.OptionsTab());
},
clear: function () {
this.items.each(function (panel) {
if (panel.clear) {
panel.clear.defer(100, panel);
panel.disable();
}
});
},
update: function (tab) {
var torrent = deluge.torrents.getSelected();
if (!torrent) {
this.clear();
return;
}
this.items.each(function (tab) {
if (tab.disabled) tab.enable();
});
tab = tab || this.getActiveTab();
if (tab.update) tab.update(torrent.id);
},
/* Event Handlers */
// We need to add the events in onRender since Deluge.Torrents has not been created yet.
onRender: function (ct, position) {
Deluge.details.DetailsPanel.superclass.onRender.call(
this,
ct,
position
);
deluge.events.on('disconnect', this.clear, this);
deluge.torrents.on('rowclick', this.onTorrentsClick, this);
this.on('tabchange', this.onTabChange, this);
deluge.torrents.getSelectionModel().on(
'selectionchange',
function (selModel) {
if (!selModel.hasSelection()) this.clear();
},
this
);
},
onTabChange: function (panel, tab) {
this.update(tab);
},
onTorrentsClick: function (grid, rowIndex, e) {
this.update();
},
});