@ -28,497 +28,515 @@
@@ -28,497 +28,515 @@
'use strict' ;
let lastShownContextMenu = null ;
const ContextMenu = new Class ( {
//implements
Implements : [ Options , Events ] ,
//options
options : {
actions : { } ,
menu : 'menu_id' ,
stopEvent : true ,
targets : 'body' ,
offsets : {
x : 0 ,
y : 0
if ( window . qBittorrent === undefined ) {
window . qBittorrent = { } ;
}
window . qBittorrent . ContextMenu = ( function ( ) {
const exports = function ( ) {
return {
ContextMenu : ContextMenu ,
TorrentsTableContextMenu : TorrentsTableContextMenu ,
CategoriesFilterContextMenu : CategoriesFilterContextMenu ,
TagsFilterContextMenu : TagsFilterContextMenu ,
SearchPluginsTableContextMenu : SearchPluginsTableContextMenu
} ;
} ;
let lastShownContextMenu = null ;
const ContextMenu = new Class ( {
//implements
Implements : [ Options , Events ] ,
//options
options : {
actions : { } ,
menu : 'menu_id' ,
stopEvent : true ,
targets : 'body' ,
offsets : {
x : 0 ,
y : 0
} ,
onShow : $empty ,
onHide : $empty ,
onClick : $empty ,
fadeSpeed : 200 ,
touchTimer : 600
} ,
onShow : $empty ,
onHide : $empty ,
onClick : $empty ,
fadeSpeed : 200 ,
touchTimer : 600
} ,
//initialization
initialize : function ( options ) {
//set options
this . setOptions ( options ) ;
//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 ( ) ;
//initialization
initialize : function ( options ) {
//set options
this . setOptions ( options ) ;
//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 the menu
this . menu . setStyles ( {
'position' : 'absolute' ,
'top' : '-900000px' ,
'display' : 'block'
} ) ;
} ,
adjustMenuPosition : function ( e ) {
this . updateMenuItems ( ) ;
const scrollableMenuMaxHeight = document . documentElement . clientHeight * 0.75 ;
if ( this . menu . hasClass ( 'scrollableMenu' ) )
this . menu . setStyle ( 'max-height' , scrollableMenuMaxHeight ) ;
// draw the menu off-screen to know the menu dimensions
this . menu . setStyles ( {
left : '-999em' ,
top : '-999em'
} ) ;
// position the menu
let xPosMenu = e . page . x + this . options . offsets . x ;
let 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 ;
this . menu . setStyles ( {
left : xPosMenu ,
top : yPosMenu ,
position : 'absolute' ,
'z-index' : '2000'
} ) ;
// position the sub-menu
const uls = this . menu . getElementsByTagName ( 'ul' ) ;
for ( let i = 0 ; i < uls . length ; ++ i ) {
const ul = uls [ i ] ;
if ( ul . hasClass ( 'scrollableMenu' ) )
ul . setStyle ( 'max-height' , scrollableMenuMaxHeight ) ;
const rectParent = ul . parentNode . getBoundingClientRect ( ) ;
const xPosOrigin = rectParent . left ;
const yPosOrigin = rectParent . bottom ;
let xPos = xPosOrigin + rectParent . width - 1 ;
let 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 )
yPos = document . documentElement . clientHeight - ul . offsetHeight ;
if ( xPos < 0 )
xPos = 0 ;
if ( yPos < 0 )
yPos = 0 ;
ul . setStyles ( {
'margin-left' : xPos - xPosOrigin ,
'margin-top' : yPos - yPosOrigin
//hide and begin the listener
this . hide ( ) . startListener ( ) ;
//hide the menu
this . menu . setStyles ( {
'position' : 'absolute' ,
'top' : '-900000px' ,
'display' : 'block'
} ) ;
}
} ,
setupEventListeners : function ( elem ) {
elem . addEvent ( 'contextmenu' , function ( e ) {
this . triggerMenu ( e , elem ) ;
} . bind ( this ) ) ;
elem . addEvent ( 'click' , function ( e ) {
this . hide ( ) ;
} . bind ( this ) ) ;
elem . addEvent ( 'touchstart' , function ( e ) {
e . preventDefault ( ) ;
clearTimeout ( this . touchstartTimer ) ;
this . hide ( ) ;
const touchstartEvent = e ;
this . touchstartTimer = setTimeout ( function ( ) {
this . triggerMenu ( touchstartEvent , elem ) ;
} . bind ( this ) , this . options . touchTimer ) ;
} . bind ( this ) ) ;
elem . addEvent ( 'touchend' , function ( e ) {
e . preventDefault ( ) ;
clearTimeout ( this . touchstartTimer ) ;
} . bind ( this ) ) ;
} ,
addTarget : function ( t ) {
this . targets [ this . targets . length ] = t ;
this . setupEventListeners ( t ) ;
} ,
triggerMenu : function ( e , el ) {
if ( this . options . disabled )
return ;
//prevent default, if told to
if ( this . options . stopEvent ) {
e . stop ( ) ;
}
//record this as the trigger
this . options . element = $ ( el ) ;
this . adjustMenuPosition ( e ) ;
//show the menu
this . show ( ) ;
} ,
//get things started
startListener : function ( ) {
/* all elements */
this . targets . each ( function ( el ) {
this . setupEventListeners ( el ) ;
} . bind ( this ) , this ) ;
/* menu items */
this . menu . getElements ( 'a' ) . each ( function ( item ) {
item . addEvent ( 'click' , function ( e ) {
} ,
adjustMenuPosition : function ( e ) {
this . updateMenuItems ( ) ;
const scrollableMenuMaxHeight = document . documentElement . clientHeight * 0.75 ;
if ( this . menu . hasClass ( 'scrollableMenu' ) )
this . menu . setStyle ( 'max-height' , scrollableMenuMaxHeight ) ;
// draw the menu off-screen to know the menu dimensions
this . menu . setStyles ( {
left : '-999em' ,
top : '-999em'
} ) ;
// position the menu
let xPosMenu = e . page . x + this . options . offsets . x ;
let 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 ;
this . menu . setStyles ( {
left : xPosMenu ,
top : yPosMenu ,
position : 'absolute' ,
'z-index' : '2000'
} ) ;
// position the sub-menu
const uls = this . menu . getElementsByTagName ( 'ul' ) ;
for ( let i = 0 ; i < uls . length ; ++ i ) {
const ul = uls [ i ] ;
if ( ul . hasClass ( 'scrollableMenu' ) )
ul . setStyle ( 'max-height' , scrollableMenuMaxHeight ) ;
const rectParent = ul . parentNode . getBoundingClientRect ( ) ;
const xPosOrigin = rectParent . left ;
const yPosOrigin = rectParent . bottom ;
let xPos = xPosOrigin + rectParent . width - 1 ;
let 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 )
yPos = document . documentElement . clientHeight - ul . offsetHeight ;
if ( xPos < 0 )
xPos = 0 ;
if ( yPos < 0 )
yPos = 0 ;
ul . setStyles ( {
'margin-left' : xPos - xPosOrigin ,
'margin-top' : yPos - yPosOrigin
} ) ;
}
} ,
setupEventListeners : function ( elem ) {
elem . addEvent ( 'contextmenu' , function ( e ) {
this . triggerMenu ( e , elem ) ;
} . bind ( this ) ) ;
elem . addEvent ( 'click' , function ( e ) {
this . hide ( ) ;
} . bind ( this ) ) ;
elem . addEvent ( 'touchstart' , function ( e ) {
e . preventDefault ( ) ;
if ( ! item . hasClass ( 'disabled' ) ) {
this . execute ( item . get ( 'href' ) . split ( '#' ) [ 1 ] , $ ( this . options . element ) ) ;
this . fireEvent ( 'click' , [ item , e ] ) ;
}
clearTimeout ( this . touchstartTimer ) ;
this . hide ( ) ;
const touchstartEvent = e ;
this . touchstartTimer = setTimeout ( function ( ) {
this . triggerMenu ( touchstartEvent , elem ) ;
} . bind ( this ) , this . options . touchTimer ) ;
} . bind ( this ) ) ;
} , this ) ;
//hide on body click
$ ( document . body ) . addEvent ( 'click' , function ( ) {
this . hide ( ) ;
} . bind ( this ) ) ;
} ,
updateMenuItems : function ( ) { } ,
//show menu
show : function ( trigger ) {
if ( lastShownContextMenu && lastShownContextMenu != this )
lastShownContextMenu . hide ( ) ;
this . fx . start ( 1 ) ;
this . fireEvent ( 'show' ) ;
this . shown = true ;
lastShownContextMenu = this ;
return this ;
} ,
//hide the menu
hide : function ( trigger ) {
if ( this . shown ) {
this . fx . start ( 0 ) ;
//this.menu.fade('out');
this . fireEvent ( 'hide' ) ;
this . shown = false ;
}
return this ;
} ,
setItemChecked : function ( item , checked ) {
this . menu . getElement ( 'a[href$=' + item + ']' ) . firstChild . style . opacity =
checked ? '1' : '0' ;
return this ;
} ,
getItemChecked : function ( item ) {
return '0' != this . menu . getElement ( 'a[href$=' + item + ']' ) . firstChild . style . opacity ;
} ,
//hide an item
hideItem : function ( item ) {
this . menu . getElement ( 'a[href$=' + item + ']' ) . parentNode . addClass ( 'invisible' ) ;
return this ;
} ,
//show an item
showItem : function ( item ) {
this . menu . getElement ( 'a[href$=' + item + ']' ) . parentNode . removeClass ( 'invisible' ) ;
return this ;
} ,
//disable the entire menu
disable : function ( ) {
this . options . disabled = true ;
return this ;
} ,
//enable the entire menu
enable : function ( ) {
this . options . disabled = false ;
return this ;
} ,
//execute an action
execute : function ( action , element ) {
if ( this . options . actions [ action ] ) {
this . options . actions [ action ] ( element , this , action ) ;
}
return this ;
}
} ) ;
const TorrentsTableContextMenu = new Class ( {
Extends : ContextMenu ,
updateMenuItems : function ( ) {
let all _are _seq _dl = true ;
let there _are _seq _dl = false ;
let all _are _f _l _piece _prio = true ;
let there _are _f _l _piece _prio = false ;
let all _are _downloaded = true ;
let all _are _paused = true ;
let there _are _paused = false ;
let all _are _force _start = true ;
let there _are _force _start = false ;
let all _are _super _seeding = true ;
let all _are _auto _tmm = true ;
let there _are _auto _tmm = false ;
const tagsSelectionState = Object . clone ( tagList ) ;
const h = torrentsTable . selectedRowsIds ( ) ;
h . each ( function ( item , index ) {
const data = torrentsTable . rows . get ( item ) . full _data ;
if ( data [ 'seq_dl' ] !== true )
all _are _seq _dl = false ;
else
there _are _seq _dl = true ;
elem . addEvent ( 'touchend' , function ( e ) {
e . preventDefault ( ) ;
clearTimeout ( this . touchstartTimer ) ;
} . bind ( this ) ) ;
} ,
if ( data [ 'f_l_piece_prio' ] !== true )
all _are _f _l _piece _prio = false ;
else
there _are _f _l _piece _prio = true ;
addTarget : function ( t ) {
this . targets [ this . targets . length ] = t ;
this . setupEventListeners ( t ) ;
} ,
if ( data [ 'progress' ] != 1.0 ) // not downloaded
all _are _downloaded = false ;
else if ( data [ 'super_seeding' ] !== true )
all _are _super _seeding = false ;
triggerMenu : function ( e , el ) {
if ( this . options . disabled )
return ;
if ( data [ 'state' ] != 'pausedUP' && data [ 'state' ] != 'pausedDL' )
all _are _paused = false ;
else
there _are _paused = true ;
//prevent default, if told to
if ( this . options . stopEvent ) {
e . stop ( ) ;
}
//record this as the trigger
this . options . element = $ ( el ) ;
this . adjustMenuPosition ( e ) ;
//show the menu
this . show ( ) ;
} ,
if ( data [ 'force_start' ] !== true )
all _are _force _start = false ;
else
there _are _force _start = true ;
//get things started
startListener : function ( ) {
/* all elements */
this . targets . each ( function ( el ) {
this . setupEventListeners ( el ) ;
} . bind ( this ) , this ) ;
/* menu items */
this . menu . getElements ( 'a' ) . each ( function ( item ) {
item . addEvent ( 'click' , function ( e ) {
e . preventDefault ( ) ;
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 ) ) ;
} ,
if ( data [ 'auto_tmm' ] === true )
there _are _auto _tmm = true ;
else
all _are _auto _tmm = false ;
const torrentTags = data [ 'tags' ] . split ( ', ' ) ;
for ( const key in tagsSelectionState ) {
const tag = tagsSelectionState [ key ] ;
const tagExists = torrentTags . contains ( tag . name ) ;
if ( ( tag . checked !== undefined ) && ( tag . checked != tagExists ) )
tag . indeterminate = true ;
if ( tag . checked === undefined )
tag . checked = tagExists ;
else
tag . checked = tag . checked && tagExists ;
updateMenuItems : function ( ) { } ,
//show menu
show : function ( trigger ) {
if ( lastShownContextMenu && lastShownContextMenu != this )
lastShownContextMenu . hide ( ) ;
this . fx . start ( 1 ) ;
this . fireEvent ( 'show' ) ;
this . shown = true ;
lastShownContextMenu = this ;
return this ;
} ,
//hide the menu
hide : function ( trigger ) {
if ( this . shown ) {
this . fx . start ( 0 ) ;
//this.menu.fade('out');
this . fireEvent ( 'hide' ) ;
this . shown = false ;
}
} ) ;
return this ;
} ,
let show _seq _dl = true ;
setItemChecked : function ( item , checked ) {
this . menu . getElement ( 'a[href$=' + item + ']' ) . firstChild . style . opacity =
checked ? '1' : '0' ;
return this ;
} ,
if ( ! all _are _seq _dl && there _are _seq _dl )
show _seq _dl = false ;
getItemChecked : function ( item ) {
return '0' != this . menu . getElement ( 'a[href$=' + item + ']' ) . firstChild . style . opacity ;
} ,
let show _f _l _piece _prio = true ;
//hide an item
hideItem : function ( item ) {
this . menu . getElement ( 'a[href$=' + item + ']' ) . parentNode . addClass ( 'invisible' ) ;
return this ;
} ,
if ( ! all _are _f _l _piece _prio && there _are _f _l _piece _prio )
show _f _l _piece _prio = false ;
//show an item
showItem : function ( item ) {
this . menu . getElement ( 'a[href$=' + item + ']' ) . parentNode . removeClass ( 'invisible' ) ;
return this ;
} ,
//disable the entire menu
disable : function ( ) {
this . options . disabled = true ;
return this ;
} ,
if ( all _are _downloaded ) {
this . hideItem ( 'downloadLimit' ) ;
this . menu . getElement ( 'a[href$=uploadLimit]' ) . parentNode . addClass ( 'separator' ) ;
this . hideItem ( 'sequentialDownload' ) ;
this . hideItem ( 'firstLastPiecePrio' ) ;
this . showItem ( 'superSeeding' ) ;
this . setItemChecked ( 'superSeeding' , all _are _super _seeding ) ;
//enable the entire menu
enable : function ( ) {
this . options . disabled = false ;
return this ;
} ,
//execute an action
execute : function ( action , element ) {
if ( this . options . actions [ action ] ) {
this . options . actions [ action ] ( element , this , action ) ;
}
return this ;
}
else {
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' ) ;
} ) ;
const TorrentsTableContextMenu = new Class ( {
Extends : ContextMenu ,
updateMenuItems : function ( ) {
let all _are _seq _dl = true ;
let there _are _seq _dl = false ;
let all _are _f _l _piece _prio = true ;
let there _are _f _l _piece _prio = false ;
let all _are _downloaded = true ;
let all _are _paused = true ;
let there _are _paused = false ;
let all _are _force _start = true ;
let there _are _force _start = false ;
let all _are _super _seeding = true ;
let all _are _auto _tmm = true ;
let there _are _auto _tmm = false ;
const tagsSelectionState = Object . clone ( tagList ) ;
const h = torrentsTable . selectedRowsIds ( ) ;
h . each ( function ( item , index ) {
const data = torrentsTable . rows . get ( item ) . full _data ;
if ( data [ 'seq_dl' ] !== true )
all _are _seq _dl = false ;
else
there _are _seq _dl = true ;
if ( show _seq _dl )
this . showItem ( 'sequentialDownload' ) ;
else
this . hideItem ( 'sequentialDownload' ) ;
if ( data [ 'f_l_piece_prio' ] !== true )
all _are _f _l _piece _prio = false ;
else
there _are _f _l _piece _prio = true ;
if ( show _f _l _piece _prio )
this . showItem ( 'firstLastPiecePrio' ) ;
else
if ( data [ 'progress' ] != 1.0 ) // not downloaded
all _are _downloaded = false ;
else if ( data [ 'super_seeding' ] !== true )
all _are _super _seeding = false ;
if ( data [ 'state' ] != 'pausedUP' && data [ 'state' ] != 'pausedDL' )
all _are _paused = false ;
else
there _are _paused = true ;
if ( data [ 'force_start' ] !== true )
all _are _force _start = false ;
else
there _are _force _start = true ;
if ( data [ 'auto_tmm' ] === true )
there _are _auto _tmm = true ;
else
all _are _auto _tmm = false ;
const torrentTags = data [ 'tags' ] . split ( ', ' ) ;
for ( const key in tagsSelectionState ) {
const tag = tagsSelectionState [ key ] ;
const tagExists = torrentTags . contains ( tag . name ) ;
if ( ( tag . checked !== undefined ) && ( tag . checked != tagExists ) )
tag . indeterminate = true ;
if ( tag . checked === undefined )
tag . checked = tagExists ;
else
tag . checked = tag . checked && tagExists ;
}
} ) ;
let show _seq _dl = true ;
if ( ! all _are _seq _dl && there _are _seq _dl )
show _seq _dl = false ;
let show _f _l _piece _prio = true ;
if ( ! all _are _f _l _piece _prio && there _are _f _l _piece _prio )
show _f _l _piece _prio = false ;
if ( all _are _downloaded ) {
this . hideItem ( 'downloadLimit' ) ;
this . menu . getElement ( 'a[href$=uploadLimit]' ) . parentNode . addClass ( 'separator' ) ;
this . hideItem ( 'sequentialDownload' ) ;
this . hideItem ( 'firstLastPiecePrio' ) ;
this . showItem ( 'superSeeding' ) ;
this . setItemChecked ( 'superSeeding' , all _are _super _seeding ) ;
}
else {
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' ) ;
this . setItemChecked ( 'sequentialDownload' , all _are _seq _dl ) ;
this . setItemChecked ( 'firstLastPiecePrio' , all _are _f _l _piece _prio ) ;
if ( show _seq _dl )
this . showItem ( 'sequentialDownload' ) ;
else
this . hideItem ( 'sequentialDownload' ) ;
this . showItem ( 'downloadLimit' ) ;
this . menu . getElement ( 'a[href$=uploadLimit]' ) . parentNode . removeClass ( 'separator' ) ;
this . hideItem ( 'superSeeding' ) ;
}
if ( show _f _l _piece _prio )
this . showItem ( 'firstLastPiecePrio ') ;
else
this . hideItem ( 'firstLastPiecePrio' ) ;
this . showItem ( 'start' ) ;
this . showItem ( 'pause' ) ;
this . showItem ( 'forceStart' ) ;
if ( all _are _paused )
this . hideItem ( 'pause' ) ;
else if ( all _are _force _start )
this . hideItem ( 'forceStart' ) ;
else if ( ! there _are _paused && ! there _are _force _start )
this . hideItem ( 'start' ) ;
if ( ! all _are _auto _tmm && there _are _auto _tmm ) {
this . hideItem ( 'autoTorrentManagement' ) ;
}
else {
this . showItem ( 'autoTorrentManagement' ) ;
this . setItemChecked ( 'autoTorrentManagement' , all _are _auto _tmm ) ;
}
this . setItemChecked ( 'sequentialDownload' , all _are _seq _dl ) ;
this . setItemChecked ( 'firstLastPiecePrio' , all _are _f _l _piece _prio ) ;
const contextTagList = $ ( 'contextTagList' ) ;
for ( const tagHash in tagList ) {
const checkbox = contextTagList . getElement ( 'a[href=#Tag/' + tagHash + '] input[type=checkbox]' ) ;
const checkboxState = tagsSelectionState [ tagHash ] ;
checkbox . indeterminate = checkboxState . indeterminate ;
checkbox . checked = checkboxState . checked ;
}
} ,
updateCategoriesSubMenu : function ( category _list ) {
const categoryList = $ ( 'contextCategoryList' ) ;
categoryList . empty ( ) ;
categoryList . appendChild ( new Element ( 'li' , {
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>'
} ) ) ;
categoryList . appendChild ( new Element ( 'li' , {
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>'
} ) ) ;
const sortedCategories = [ ] ;
Object . each ( category _list , function ( category ) {
sortedCategories . push ( category . name ) ;
} ) ;
sortedCategories . sort ( ) ;
let first = true ;
Object . each ( sortedCategories , function ( categoryName ) {
const categoryHash = genHash ( categoryName ) ;
const el = new Element ( 'li' , {
html : '<a href="javascript:torrentSetCategoryFN(\'' + categoryHash + '\');"><img src="images/qbt-theme/inode-directory.svg"/> ' + escapeHtml ( categoryName ) + '</a>'
} ) ;
if ( first ) {
el . addClass ( 'separator' ) ;
first = false ;
this . showItem ( 'downloadLimit' ) ;
this . menu . getElement ( 'a[href$=uploadLimit]' ) . parentNode . removeClass ( 'separator' ) ;
this . hideItem ( 'superSeeding' ) ;
}
categoryList . appendChild ( el ) ;
} ) ;
} ,
updateTagsSubMenu : function ( tagList ) {
const contextTagList = $ ( 'contextTagList' ) ;
while ( contextTagList . firstChild !== null )
contextTagList . removeChild ( contextTagList . firstChild ) ;
contextTagList . appendChild ( new Element ( 'li' , {
html : '<a href="javascript:torrentAddTagsFN();">'
+ '<img src="images/qbt-theme/list-add.svg" alt="QBT_TR(Add...)QBT_TR[CONTEXT=TransferListWidget]"/>'
+ ' QBT_TR(Add...)QBT_TR[CONTEXT=TransferListWidget]'
+ '</a>'
} ) ) ;
contextTagList . appendChild ( new Element ( 'li' , {
html : '<a href="javascript:torrentRemoveAllTagsFN();">'
+ '<img src="images/qbt-theme/edit-clear.svg" alt="QBT_TR(Remove All)QBT_TR[CONTEXT=TransferListWidget]"/>'
+ ' QBT_TR(Remove All)QBT_TR[CONTEXT=TransferListWidget]'
+ '</a>'
} ) ) ;
const sortedTags = [ ] ;
for ( const key in tagList )
sortedTags . push ( tagList [ key ] . name ) ;
sortedTags . sort ( ) ;
for ( let i = 0 ; i < sortedTags . length ; ++ i ) {
const tagName = sortedTags [ i ] ;
const tagHash = genHash ( tagName ) ;
const el = new Element ( 'li' , {
html : '<a href="#Tag/' + tagHash + '" onclick="event.preventDefault(); torrentSetTagsFN(\'' + tagHash + '\', !event.currentTarget.getElement(\'input[type=checkbox]\').checked);">'
+ '<input type="checkbox" onclick="this.checked = !this.checked;"> ' + escapeHtml ( tagName )
+ '</a>'
this . showItem ( 'start' ) ;
this . showItem ( 'pause' ) ;
this . showItem ( 'forceStart' ) ;
if ( all _are _paused )
this . hideItem ( 'pause' ) ;
else if ( all _are _force _start )
this . hideItem ( 'forceStart' ) ;
else if ( ! there _are _paused && ! there _are _force _start )
this . hideItem ( 'start' ) ;
if ( ! all _are _auto _tmm && there _are _auto _tmm ) {
this . hideItem ( 'autoTorrentManagement' ) ;
}
else {
this . showItem ( 'autoTorrentManagement' ) ;
this . setItemChecked ( 'autoTorrentManagement' , all _are _auto _tmm ) ;
}
const contextTagList = $ ( 'contextTagList' ) ;
for ( const tagHash in tagList ) {
const checkbox = contextTagList . getElement ( 'a[href=#Tag/' + tagHash + '] input[type=checkbox]' ) ;
const checkboxState = tagsSelectionState [ tagHash ] ;
checkbox . indeterminate = checkboxState . indeterminate ;
checkbox . checked = checkboxState . checked ;
}
} ,
updateCategoriesSubMenu : function ( category _list ) {
const categoryList = $ ( 'contextCategoryList' ) ;
categoryList . empty ( ) ;
categoryList . appendChild ( new Element ( 'li' , {
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>'
} ) ) ;
categoryList . appendChild ( new Element ( 'li' , {
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>'
} ) ) ;
const sortedCategories = [ ] ;
Object . each ( category _list , function ( category ) {
sortedCategories . push ( category . name ) ;
} ) ;
if ( i === 0 )
el . addClass ( 'separator' ) ;
contextTagList . appendChild ( el ) ;
sortedCategories . sort ( ) ;
let first = true ;
Object . each ( sortedCategories , function ( categoryName ) {
const categoryHash = genHash ( categoryName ) ;
const el = new Element ( 'li' , {
html : '<a href="javascript:torrentSetCategoryFN(\'' + categoryHash + '\');"><img src="images/qbt-theme/inode-directory.svg"/> ' + window . qBittorrent . Misc . escapeHtml ( categoryName ) + '</a>'
} ) ;
if ( first ) {
el . addClass ( 'separator' ) ;
first = false ;
}
categoryList . appendChild ( el ) ;
} ) ;
} ,
updateTagsSubMenu : function ( tagList ) {
const contextTagList = $ ( 'contextTagList' ) ;
while ( contextTagList . firstChild !== null )
contextTagList . removeChild ( contextTagList . firstChild ) ;
contextTagList . appendChild ( new Element ( 'li' , {
html : '<a href="javascript:torrentAddTagsFN();">'
+ '<img src="images/qbt-theme/list-add.svg" alt="QBT_TR(Add...)QBT_TR[CONTEXT=TransferListWidget]"/>'
+ ' QBT_TR(Add...)QBT_TR[CONTEXT=TransferListWidget]'
+ '</a>'
} ) ) ;
contextTagList . appendChild ( new Element ( 'li' , {
html : '<a href="javascript:torrentRemoveAllTagsFN();">'
+ '<img src="images/qbt-theme/edit-clear.svg" alt="QBT_TR(Remove All)QBT_TR[CONTEXT=TransferListWidget]"/>'
+ ' QBT_TR(Remove All)QBT_TR[CONTEXT=TransferListWidget]'
+ '</a>'
} ) ) ;
const sortedTags = [ ] ;
for ( const key in tagList )
sortedTags . push ( tagList [ key ] . name ) ;
sortedTags . sort ( ) ;
for ( let i = 0 ; i < sortedTags . length ; ++ i ) {
const tagName = sortedTags [ i ] ;
const tagHash = genHash ( tagName ) ;
const el = new Element ( 'li' , {
html : '<a href="#Tag/' + tagHash + '" onclick="event.preventDefault(); torrentSetTagsFN(\'' + tagHash + '\', !event.currentTarget.getElement(\'input[type=checkbox]\').checked);">'
+ '<input type="checkbox" onclick="this.checked = !this.checked;"> ' + window . qBittorrent . Misc . escapeHtml ( tagName )
+ '</a>'
} ) ;
if ( i === 0 )
el . addClass ( 'separator' ) ;
contextTagList . appendChild ( el ) ;
}
}
}
} ) ;
const CategoriesFilterContextMenu = new Class ( {
Extends : ContextMenu ,
updateMenuItems : function ( ) {
const id = this . options . element . id ;
if ( ( id != CATEGORIES _ALL ) && ( id != CATEGORIES _UNCATEGORIZED ) ) {
this . showItem ( 'editCategory' ) ;
this . showItem ( 'deleteCategory' ) ;
} ) ;
const CategoriesFilterContextMenu = new Class ( {
Extends : ContextMenu ,
updateMenuItems : function ( ) {
const id = this . options . element . id ;
if ( ( id != CATEGORIES _ALL ) && ( id != CATEGORIES _UNCATEGORIZED ) ) {
this . showItem ( 'editCategory' ) ;
this . showItem ( 'deleteCategory' ) ;
}
else {
this . hideItem ( 'editCategory' ) ;
this . hideItem ( 'deleteCategory' ) ;
}
}
else {
this . hideItem ( 'editCategory' ) ;
this . hideItem ( 'deleteCategory' ) ;
} ) ;
const TagsFilterContextMenu = new Class ( {
Extends : ContextMenu ,
updateMenuItems : function ( ) {
const id = this . options . element . id ;
if ( ( id !== TAGS _ALL . toString ( ) ) && ( id !== TAGS _UNTAGGED . toString ( ) ) )
this . showItem ( 'deleteTag' ) ;
else
this . hideItem ( 'deleteTag' ) ;
}
}
} ) ;
const TagsFilterContextMenu = new Class ( {
Extends : ContextMenu ,
updateMenuItems : function ( ) {
const id = this . options . element . id ;
if ( ( id !== TAGS _ALL . toString ( ) ) && ( id !== TAGS _UNTAGGED . toString ( ) ) )
this . showItem ( 'deleteTag' ) ;
else
this . hideItem ( 'deleteTag' ) ;
}
} ) ;
const SearchPluginsTableContextMenu = new Class ( {
Extends : ContextMenu ,
updateMenuItems : function ( ) {
const enabledColumnIndex = function ( text ) {
const columns = $ ( "searchPluginsTableFixedHeaderRow" ) . getChildren ( "th" ) ;
for ( let i = 0 ; i < columns . length ; ++ i )
if ( columns [ i ] . get ( "html" ) === "Enabled" )
return i ;
} ;
} ) ;
const SearchPluginsTableContextMenu = new Class ( {
Extends : ContextMenu ,
this . showItem ( 'Enabled' ) ;
this . setItemChecked ( 'Enabled' , this . options . element . getChildren ( "td" ) [ enabledColumnIndex ( ) ] . get ( "html" ) === "Yes" ) ;
updateMenuItems : function ( ) {
const enabledColumnIndex = function ( text ) {
const columns = $ ( "searchPluginsTableFixedHeaderRow" ) . getChildren ( "th" ) ;
for ( let 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' ) ;
}
} ) ;
this . showItem ( 'Uninstall' ) ;
}
} ) ;
return exports ( ) ;
} ) ( ) ;