2019-02-04 13:45:22 +08:00
|
|
|
/*
|
|
|
|
* Bittorrent Client using Qt and libtorrent.
|
|
|
|
* Copyright (C) 2009 Christophe Dumez <chris@qbittorrent.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* In addition, as a special exception, the copyright holders give permission to
|
|
|
|
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
|
|
|
* modified versions of it that use the same license as the "OpenSSL" library),
|
|
|
|
* and distribute the linked executables. You must obey the GNU General Public
|
|
|
|
* License in all respects for all of the code used other than "OpenSSL". If you
|
|
|
|
* modify file(s), you may extend this exception to your version of the file(s),
|
|
|
|
* but you are not obligated to do so. If you do not wish to do so, delete this
|
|
|
|
* exception statement from your version.
|
|
|
|
*/
|
|
|
|
|
2018-11-30 18:30:26 +08:00
|
|
|
'use strict';
|
|
|
|
|
2016-01-23 12:14:05 +03:00
|
|
|
var lastShownContexMenu = null;
|
2009-11-24 19:41:31 +00:00
|
|
|
var ContextMenu = new Class({
|
2014-11-30 14:14:09 +01:00
|
|
|
//implements
|
|
|
|
Implements: [Options, Events],
|
|
|
|
|
|
|
|
//options
|
|
|
|
options: {
|
|
|
|
actions: {},
|
2016-01-20 16:13:54 +03:00
|
|
|
menu: 'menu_id',
|
2014-11-30 14:14:09 +01:00
|
|
|
stopEvent: true,
|
|
|
|
targets: 'body',
|
|
|
|
trigger: 'contextmenu',
|
|
|
|
offsets: {
|
|
|
|
x: 0,
|
|
|
|
y: 0
|
|
|
|
},
|
|
|
|
onShow: $empty,
|
|
|
|
onHide: $empty,
|
|
|
|
onClick: $empty,
|
|
|
|
fadeSpeed: 200
|
|
|
|
},
|
|
|
|
|
|
|
|
//initialization
|
|
|
|
initialize: function(options) {
|
|
|
|
//set options
|
2017-07-01 00:42:20 -04:00
|
|
|
this.setOptions(options);
|
2014-11-30 14:14:09 +01:00
|
|
|
|
|
|
|
//option diffs menu
|
|
|
|
this.menu = $(this.options.menu);
|
|
|
|
this.targets = $$(this.options.targets);
|
|
|
|
|
|
|
|
//fx
|
|
|
|
this.fx = new Fx.Tween(this.menu, {
|
|
|
|
property: 'opacity',
|
|
|
|
duration: this.options.fadeSpeed,
|
|
|
|
onComplete: function() {
|
|
|
|
if (this.getStyle('opacity')) {
|
|
|
|
this.setStyle('visibility', 'visible');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.setStyle('visibility', 'hidden');
|
|
|
|
}
|
|
|
|
}.bind(this.menu)
|
|
|
|
});
|
|
|
|
|
|
|
|
//hide and begin the listener
|
|
|
|
this.hide().startListener();
|
|
|
|
|
|
|
|
//hide the menu
|
|
|
|
this.menu.setStyles({
|
|
|
|
'position': 'absolute',
|
|
|
|
'top': '-900000px',
|
|
|
|
'display': 'block'
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2016-01-22 20:10:32 +03:00
|
|
|
adjustMenuPosition: function(e) {
|
|
|
|
this.updateMenuItems();
|
|
|
|
|
2016-07-18 22:33:16 +03:00
|
|
|
var scrollableMenuMaxHeight = document.documentElement.clientHeight * 0.75;
|
|
|
|
|
|
|
|
if (this.menu.hasClass('scrollableMenu'))
|
|
|
|
this.menu.setStyle('max-height', scrollableMenuMaxHeight);
|
|
|
|
|
2018-03-14 23:15:51 +08:00
|
|
|
// draw the menu off-screen to know the menu dimensions
|
2016-01-22 20:10:32 +03:00
|
|
|
this.menu.setStyles({
|
|
|
|
left: '-999em',
|
|
|
|
top: '-999em'
|
|
|
|
});
|
|
|
|
|
|
|
|
// position the menu
|
2017-07-01 00:42:20 -04:00
|
|
|
var xPosMenu = e.page.x + this.options.offsets.x;
|
|
|
|
var yPosMenu = e.page.y + this.options.offsets.y;
|
|
|
|
if (xPosMenu + this.menu.offsetWidth > document.documentElement.clientWidth)
|
|
|
|
xPosMenu -= this.menu.offsetWidth;
|
|
|
|
if (yPosMenu + this.menu.offsetHeight > document.documentElement.clientHeight)
|
|
|
|
yPosMenu = document.documentElement.clientHeight - this.menu.offsetHeight;
|
|
|
|
if (xPosMenu < 0)
|
|
|
|
xPosMenu = 0;
|
|
|
|
if (yPosMenu < 0)
|
|
|
|
yPosMenu = 0;
|
2016-01-22 20:10:32 +03:00
|
|
|
this.menu.setStyles({
|
2017-07-01 00:42:20 -04:00
|
|
|
left: xPosMenu,
|
|
|
|
top: yPosMenu,
|
2016-01-22 20:10:32 +03:00
|
|
|
position: 'absolute',
|
|
|
|
'z-index': '2000'
|
|
|
|
});
|
|
|
|
|
|
|
|
// position the sub-menu
|
|
|
|
var uls = this.menu.getElementsByTagName('ul');
|
2018-05-31 01:06:28 +08:00
|
|
|
for (var i = 0; i < uls.length; ++i) {
|
2016-01-22 20:10:32 +03:00
|
|
|
var ul = uls[i];
|
2016-07-18 22:33:16 +03:00
|
|
|
if (ul.hasClass('scrollableMenu'))
|
|
|
|
ul.setStyle('max-height', scrollableMenuMaxHeight);
|
2016-01-22 20:10:32 +03:00
|
|
|
var rectParent = ul.parentNode.getBoundingClientRect();
|
|
|
|
var xPosOrigin = rectParent.left;
|
|
|
|
var yPosOrigin = rectParent.bottom;
|
|
|
|
var xPos = xPosOrigin + rectParent.width - 1;
|
|
|
|
var yPos = yPosOrigin - rectParent.height - 1;
|
|
|
|
if (xPos + ul.offsetWidth > document.documentElement.clientWidth)
|
|
|
|
xPos -= (ul.offsetWidth + rectParent.width - 2);
|
|
|
|
if (yPos + ul.offsetHeight > document.documentElement.clientHeight)
|
2016-07-18 22:33:16 +03:00
|
|
|
yPos = document.documentElement.clientHeight - ul.offsetHeight;
|
2016-01-22 20:10:32 +03:00
|
|
|
if (xPos < 0)
|
|
|
|
xPos = 0;
|
|
|
|
if (yPos < 0)
|
|
|
|
yPos = 0;
|
|
|
|
ul.setStyles({
|
|
|
|
'margin-left': xPos - xPosOrigin,
|
|
|
|
'margin-top': yPos - yPosOrigin
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-11-30 14:14:09 +01:00
|
|
|
addTarget: function(t) {
|
|
|
|
this.targets[this.targets.length] = t;
|
|
|
|
t.addEvent(this.options.trigger, function(e) {
|
|
|
|
//enabled?
|
|
|
|
if (!this.options.disabled) {
|
|
|
|
//prevent default, if told to
|
|
|
|
if (this.options.stopEvent) {
|
|
|
|
e.stop();
|
|
|
|
}
|
|
|
|
//record this as the trigger
|
|
|
|
this.options.element = $(t);
|
2016-01-22 20:10:32 +03:00
|
|
|
this.adjustMenuPosition(e);
|
2014-11-30 14:14:09 +01:00
|
|
|
//show the menu
|
|
|
|
this.show();
|
|
|
|
}
|
|
|
|
}.bind(this));
|
|
|
|
t.addEvent('click', function(e) {
|
|
|
|
this.hide();
|
|
|
|
}.bind(this));
|
|
|
|
},
|
|
|
|
|
|
|
|
//get things started
|
|
|
|
startListener: function() {
|
|
|
|
/* all elements */
|
|
|
|
this.targets.each(function(el) {
|
|
|
|
/* show the menu */
|
|
|
|
el.addEvent(this.options.trigger, function(e) {
|
|
|
|
//enabled?
|
|
|
|
if (!this.options.disabled) {
|
|
|
|
//prevent default, if told to
|
|
|
|
if (this.options.stopEvent) {
|
|
|
|
e.stop();
|
|
|
|
}
|
|
|
|
//record this as the trigger
|
|
|
|
this.options.element = $(el);
|
2016-01-22 20:10:32 +03:00
|
|
|
this.adjustMenuPosition(e);
|
2014-11-30 14:14:09 +01:00
|
|
|
//show the menu
|
|
|
|
this.show();
|
|
|
|
}
|
|
|
|
}.bind(this));
|
|
|
|
el.addEvent('click', function(e) {
|
|
|
|
this.hide();
|
|
|
|
}.bind(this));
|
|
|
|
}, this);
|
|
|
|
|
|
|
|
/* menu items */
|
|
|
|
this.menu.getElements('a').each(function(item) {
|
|
|
|
item.addEvent('click', function(e) {
|
2014-12-14 10:00:00 +01:00
|
|
|
e.preventDefault();
|
2014-11-30 14:14:09 +01:00
|
|
|
if (!item.hasClass('disabled')) {
|
|
|
|
this.execute(item.get('href').split('#')[1], $(this.options.element));
|
|
|
|
this.fireEvent('click', [item, e]);
|
|
|
|
}
|
|
|
|
}.bind(this));
|
|
|
|
}, this);
|
|
|
|
|
|
|
|
//hide on body click
|
|
|
|
$(document.body).addEvent('click', function() {
|
|
|
|
this.hide();
|
|
|
|
}.bind(this));
|
|
|
|
},
|
|
|
|
|
2018-04-05 11:59:31 +08:00
|
|
|
updateMenuItems: function() {},
|
2016-01-20 16:13:54 +03:00
|
|
|
|
|
|
|
//show menu
|
2018-04-05 11:59:31 +08:00
|
|
|
show: function(trigger) {
|
2016-01-23 12:14:05 +03:00
|
|
|
if (lastShownContexMenu && lastShownContexMenu != this)
|
|
|
|
lastShownContexMenu.hide();
|
2016-01-20 16:13:54 +03:00
|
|
|
this.fx.start(1);
|
|
|
|
this.fireEvent('show');
|
|
|
|
this.shown = true;
|
2016-01-23 12:14:05 +03:00
|
|
|
lastShownContexMenu = this;
|
2016-01-20 16:13:54 +03:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
//hide the menu
|
2018-04-05 11:59:31 +08:00
|
|
|
hide: function(trigger) {
|
2016-01-20 16:13:54 +03:00
|
|
|
if (this.shown) {
|
|
|
|
this.fx.start(0);
|
|
|
|
//this.menu.fade('out');
|
|
|
|
this.fireEvent('hide');
|
|
|
|
this.shown = false;
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-04-05 11:59:31 +08:00
|
|
|
setItemChecked: function(item, checked) {
|
2016-01-20 16:13:54 +03:00
|
|
|
this.menu.getElement('a[href$=' + item + ']').firstChild.style.opacity =
|
2018-04-05 11:59:31 +08:00
|
|
|
checked ? '1' : '0';
|
2016-01-20 16:13:54 +03:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-04-05 11:59:31 +08:00
|
|
|
getItemChecked: function(item) {
|
2016-01-20 16:13:54 +03:00
|
|
|
return '0' != this.menu.getElement('a[href$=' + item + ']').firstChild.style.opacity;
|
|
|
|
},
|
|
|
|
|
|
|
|
//hide an item
|
2018-04-05 11:59:31 +08:00
|
|
|
hideItem: function(item) {
|
2016-01-20 16:13:54 +03:00
|
|
|
this.menu.getElement('a[href$=' + item + ']').parentNode.addClass('invisible');
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
//show an item
|
2018-04-05 11:59:31 +08:00
|
|
|
showItem: function(item) {
|
2016-01-20 16:13:54 +03:00
|
|
|
this.menu.getElement('a[href$=' + item + ']').parentNode.removeClass('invisible');
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
//disable the entire menu
|
2018-04-05 11:59:31 +08:00
|
|
|
disable: function() {
|
2016-01-20 16:13:54 +03:00
|
|
|
this.options.disabled = true;
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
//enable the entire menu
|
2018-04-05 11:59:31 +08:00
|
|
|
enable: function() {
|
2016-01-20 16:13:54 +03:00
|
|
|
this.options.disabled = false;
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
//execute an action
|
2018-04-05 11:59:31 +08:00
|
|
|
execute: function(action, element) {
|
2016-01-20 16:13:54 +03:00
|
|
|
if (this.options.actions[action]) {
|
2016-07-18 18:58:16 +03:00
|
|
|
this.options.actions[action](element, this, action);
|
2016-01-20 16:13:54 +03:00
|
|
|
}
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var TorrentsTableContextMenu = new Class({
|
|
|
|
Extends: ContextMenu,
|
|
|
|
|
2018-04-05 11:59:31 +08:00
|
|
|
updateMenuItems: function() {
|
2018-09-26 23:10:51 -04:00
|
|
|
var all_are_seq_dl = true;
|
|
|
|
var there_are_seq_dl = false;
|
|
|
|
var all_are_f_l_piece_prio = true;
|
|
|
|
var there_are_f_l_piece_prio = false;
|
|
|
|
var all_are_downloaded = true;
|
|
|
|
var all_are_paused = true;
|
|
|
|
var there_are_paused = false;
|
|
|
|
var all_are_force_start = true;
|
|
|
|
var there_are_force_start = false;
|
|
|
|
var all_are_super_seeding = true;
|
|
|
|
var all_are_auto_tmm = true;
|
|
|
|
var there_are_auto_tmm = false;
|
2014-12-09 19:54:35 +03:00
|
|
|
|
2015-11-11 22:58:30 +03:00
|
|
|
var h = torrentsTable.selectedRowsIds();
|
2018-04-05 11:59:31 +08:00
|
|
|
h.each(function(item, index) {
|
2015-11-11 22:58:30 +03:00
|
|
|
var data = torrentsTable.rows.get(item).full_data;
|
2014-12-09 21:03:14 +03:00
|
|
|
|
2017-07-01 00:42:20 -04:00
|
|
|
if (data['seq_dl'] !== true)
|
2014-12-09 19:54:35 +03:00
|
|
|
all_are_seq_dl = false;
|
2014-12-09 21:03:14 +03:00
|
|
|
else
|
|
|
|
there_are_seq_dl = true;
|
|
|
|
|
2017-07-01 00:42:20 -04:00
|
|
|
if (data['f_l_piece_prio'] !== true)
|
2014-12-09 19:54:35 +03:00
|
|
|
all_are_f_l_piece_prio = false;
|
2014-12-09 21:03:14 +03:00
|
|
|
else
|
|
|
|
there_are_f_l_piece_prio = true;
|
|
|
|
|
2014-12-24 04:39:18 +03:00
|
|
|
if (data['progress'] != 1.0) // not downloaded
|
2014-12-09 19:54:35 +03:00
|
|
|
all_are_downloaded = false;
|
2017-07-01 00:42:20 -04:00
|
|
|
else if (data['super_seeding'] !== true)
|
2015-01-30 15:58:27 -05:00
|
|
|
all_are_super_seeding = false;
|
2014-12-09 21:03:14 +03:00
|
|
|
|
2015-07-14 03:06:34 +02:00
|
|
|
if (data['state'] != 'pausedUP' && data['state'] != 'pausedDL')
|
2014-12-09 21:03:14 +03:00
|
|
|
all_are_paused = false;
|
|
|
|
else
|
|
|
|
there_are_paused = true;
|
2015-07-14 03:06:34 +02:00
|
|
|
|
2017-07-01 00:42:20 -04:00
|
|
|
if (data['force_start'] !== true)
|
2015-07-14 03:06:34 +02:00
|
|
|
all_are_force_start = false;
|
|
|
|
else
|
|
|
|
there_are_force_start = true;
|
2017-07-05 01:47:23 -04:00
|
|
|
|
2017-07-18 22:06:38 -04:00
|
|
|
if (data['auto_tmm'] === true)
|
2017-07-05 01:47:23 -04:00
|
|
|
there_are_auto_tmm = true;
|
2017-07-18 22:06:38 -04:00
|
|
|
else
|
|
|
|
all_are_auto_tmm = false;
|
2014-12-09 19:54:35 +03:00
|
|
|
});
|
|
|
|
|
2018-09-26 23:10:51 -04:00
|
|
|
var show_seq_dl = true;
|
2014-12-09 21:03:14 +03:00
|
|
|
|
|
|
|
if (!all_are_seq_dl && there_are_seq_dl)
|
|
|
|
show_seq_dl = false;
|
|
|
|
|
2018-09-26 23:10:51 -04:00
|
|
|
var show_f_l_piece_prio = true;
|
2014-12-09 21:03:14 +03:00
|
|
|
|
|
|
|
if (!all_are_f_l_piece_prio && there_are_f_l_piece_prio)
|
|
|
|
show_f_l_piece_prio = false;
|
|
|
|
|
2014-12-09 19:54:35 +03:00
|
|
|
if (all_are_downloaded) {
|
2016-01-10 12:11:54 +03:00
|
|
|
this.hideItem('DownloadLimit');
|
|
|
|
this.menu.getElement('a[href$=UploadLimit]').parentNode.addClass('separator');
|
2014-12-09 19:54:35 +03:00
|
|
|
this.hideItem('SequentialDownload');
|
|
|
|
this.hideItem('FirstLastPiecePrio');
|
2015-01-30 15:58:27 -05:00
|
|
|
this.showItem('SuperSeeding');
|
|
|
|
this.setItemChecked('SuperSeeding', all_are_super_seeding);
|
2018-04-05 11:59:31 +08:00
|
|
|
}
|
|
|
|
else {
|
2014-12-09 21:03:14 +03:00
|
|
|
if (!show_seq_dl && show_f_l_piece_prio)
|
|
|
|
this.menu.getElement('a[href$=FirstLastPiecePrio]').parentNode.addClass('separator');
|
|
|
|
else
|
|
|
|
this.menu.getElement('a[href$=FirstLastPiecePrio]').parentNode.removeClass('separator');
|
|
|
|
|
|
|
|
if (show_seq_dl)
|
|
|
|
this.showItem('SequentialDownload');
|
|
|
|
else
|
|
|
|
this.hideItem('SequentialDownload');
|
|
|
|
|
|
|
|
if (show_f_l_piece_prio)
|
|
|
|
this.showItem('FirstLastPiecePrio');
|
|
|
|
else
|
|
|
|
this.hideItem('FirstLastPiecePrio');
|
|
|
|
|
2014-12-09 19:54:35 +03:00
|
|
|
this.setItemChecked('SequentialDownload', all_are_seq_dl);
|
|
|
|
this.setItemChecked('FirstLastPiecePrio', all_are_f_l_piece_prio);
|
2015-01-30 15:58:27 -05:00
|
|
|
|
2016-01-10 12:11:54 +03:00
|
|
|
this.showItem('DownloadLimit');
|
|
|
|
this.menu.getElement('a[href$=UploadLimit]').parentNode.removeClass('separator');
|
2015-01-30 15:58:27 -05:00
|
|
|
this.hideItem('SuperSeeding');
|
2014-12-09 19:54:35 +03:00
|
|
|
}
|
2014-12-09 21:03:14 +03:00
|
|
|
|
2015-07-14 03:06:34 +02:00
|
|
|
this.showItem('Start');
|
|
|
|
this.showItem('Pause');
|
|
|
|
this.showItem('ForceStart');
|
|
|
|
if (all_are_paused)
|
2014-12-09 21:03:14 +03:00
|
|
|
this.hideItem('Pause');
|
2015-07-14 03:06:34 +02:00
|
|
|
else if (all_are_force_start)
|
|
|
|
this.hideItem('ForceStart');
|
|
|
|
else if (!there_are_paused && !there_are_force_start)
|
|
|
|
this.hideItem('Start');
|
2017-07-05 01:47:23 -04:00
|
|
|
|
2018-10-15 21:08:42 -04:00
|
|
|
if (!all_are_auto_tmm && there_are_auto_tmm) {
|
2017-07-05 01:47:23 -04:00
|
|
|
this.hideItem('AutoTorrentManagement');
|
2018-10-15 21:08:42 -04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.showItem('AutoTorrentManagement');
|
2017-07-05 01:47:23 -04:00
|
|
|
this.setItemChecked('AutoTorrentManagement', all_are_auto_tmm);
|
2018-10-15 21:08:42 -04:00
|
|
|
}
|
2017-07-05 01:47:23 -04:00
|
|
|
|
2015-01-30 15:58:27 -05:00
|
|
|
},
|
|
|
|
|
2018-04-05 11:59:31 +08:00
|
|
|
updateCategoriesSubMenu: function(category_list) {
|
2016-01-20 16:13:54 +03:00
|
|
|
var categoryList = $('contextCategoryList');
|
|
|
|
categoryList.empty();
|
2018-04-05 11:59:31 +08:00
|
|
|
categoryList.appendChild(new Element('li', {
|
2018-07-23 12:28:14 +08:00
|
|
|
html: '<a href="javascript:torrentNewCategoryFN();"><img src="images/qbt-theme/list-add.svg" alt="QBT_TR(New...)QBT_TR[CONTEXT=TransferListWidget]"/> QBT_TR(New...)QBT_TR[CONTEXT=TransferListWidget]</a>'
|
2018-04-05 11:59:31 +08:00
|
|
|
}));
|
|
|
|
categoryList.appendChild(new Element('li', {
|
2018-07-23 12:28:14 +08:00
|
|
|
html: '<a href="javascript:torrentSetCategoryFN(0);"><img src="images/qbt-theme/edit-clear.svg" alt="QBT_TR(Reset)QBT_TR[CONTEXT=TransferListWidget]"/> QBT_TR(Reset)QBT_TR[CONTEXT=TransferListWidget]</a>'
|
2018-04-05 11:59:31 +08:00
|
|
|
}));
|
2014-11-30 14:14:09 +01:00
|
|
|
|
2017-07-01 00:42:20 -04:00
|
|
|
var sortedCategories = [];
|
2018-04-05 11:59:31 +08:00
|
|
|
Object.each(category_list, function(category) {
|
2016-01-20 16:13:54 +03:00
|
|
|
sortedCategories.push(category.name);
|
|
|
|
});
|
|
|
|
sortedCategories.sort();
|
|
|
|
|
|
|
|
var first = true;
|
2018-04-05 11:59:31 +08:00
|
|
|
Object.each(sortedCategories, function(categoryName) {
|
2016-01-20 16:13:54 +03:00
|
|
|
var categoryHash = genHash(categoryName);
|
2018-04-05 11:59:31 +08:00
|
|
|
var el = new Element('li', {
|
2018-07-23 12:28:14 +08:00
|
|
|
html: '<a href="javascript:torrentSetCategoryFN(\'' + categoryHash + '\');"><img src="images/qbt-theme/inode-directory.svg"/> ' + escapeHtml(categoryName) + '</a>'
|
2018-04-05 11:59:31 +08:00
|
|
|
});
|
2016-01-20 16:13:54 +03:00
|
|
|
if (first) {
|
|
|
|
el.addClass('separator');
|
|
|
|
first = false;
|
|
|
|
}
|
|
|
|
categoryList.appendChild(el);
|
|
|
|
});
|
2014-11-30 14:14:09 +01:00
|
|
|
}
|
2015-07-14 03:06:34 +02:00
|
|
|
});
|
2016-01-20 22:57:42 +03:00
|
|
|
|
|
|
|
var CategoriesFilterContextMenu = new Class({
|
2016-01-21 16:42:20 +03:00
|
|
|
Extends: ContextMenu,
|
2018-04-05 11:59:31 +08:00
|
|
|
updateMenuItems: function() {
|
2016-01-21 16:42:20 +03:00
|
|
|
var id = this.options.element.id;
|
2018-07-23 01:49:34 -04:00
|
|
|
if ((id != CATEGORIES_ALL) && (id != CATEGORIES_UNCATEGORIZED)) {
|
|
|
|
this.showItem('EditCategory');
|
2016-01-21 16:42:20 +03:00
|
|
|
this.showItem('DeleteCategory');
|
2018-07-23 01:49:34 -04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.hideItem('EditCategory');
|
2016-01-21 16:42:20 +03:00
|
|
|
this.hideItem('DeleteCategory');
|
2018-07-23 01:49:34 -04:00
|
|
|
}
|
2016-01-21 16:42:20 +03:00
|
|
|
}
|
2016-01-20 22:57:42 +03:00
|
|
|
});
|
2017-12-28 13:05:36 -05:00
|
|
|
|
|
|
|
var SearchPluginsTableContextMenu = new Class({
|
|
|
|
Extends: ContextMenu,
|
|
|
|
|
2018-12-12 12:23:56 +08:00
|
|
|
updateMenuItems: function() {
|
2017-12-28 13:05:36 -05:00
|
|
|
var enabledColumnIndex = function(text) {
|
|
|
|
var columns = $("searchPluginsTableFixedHeaderRow").getChildren("th");
|
|
|
|
for (var i = 0; i < columns.length; ++i)
|
|
|
|
if (columns[i].get("html") === "Enabled")
|
|
|
|
return i;
|
|
|
|
};
|
|
|
|
|
|
|
|
this.showItem('Enabled');
|
|
|
|
this.setItemChecked('Enabled', this.options.element.getChildren("td")[enabledColumnIndex()].get("html") === "Yes");
|
|
|
|
|
|
|
|
this.showItem('Uninstall');
|
|
|
|
}
|
|
|
|
});
|