Browse Source

Dynamically show 'Start' and 'Pause' menu items

adaptive-webui-19844
buinsky 10 years ago
parent
commit
76e30ecf78
  1. 57
      src/webui/www/public/scripts/contextmenu.js

57
src/webui/www/public/scripts/contextmenu.js

@ -129,29 +129,82 @@ var ContextMenu = new Class({
updateMenuItems: function () { updateMenuItems: function () {
all_are_seq_dl = true; all_are_seq_dl = true;
there_are_seq_dl = false;
all_are_f_l_piece_prio = true; all_are_f_l_piece_prio = true;
there_are_f_l_piece_prio = false;
all_are_downloaded = true; all_are_downloaded = true;
all_are_paused = true;
there_are_paused = false;
var h = myTable.selectedIds(); var h = myTable.selectedIds();
h.each(function(item, index){ h.each(function(item, index){
tr = myTable.rows.get(item); tr = myTable.rows.get(item);
if (tr.getAttribute('seq_dl') != 'true') if (tr.getAttribute('seq_dl') != 'true')
all_are_seq_dl = false; all_are_seq_dl = false;
else
there_are_seq_dl = true;
if (tr.getAttribute('f_l_piece_prio') != 'true') if (tr.getAttribute('f_l_piece_prio') != 'true')
all_are_f_l_piece_prio = false; all_are_f_l_piece_prio = false;
else
there_are_f_l_piece_prio = true;
if (tr.getAttribute('downloaded') != 'true') if (tr.getAttribute('downloaded') != 'true')
all_are_downloaded = false; all_are_downloaded = false;
state = tr.getAttribute('state');
if ((state != 'pausedUP') && (state != 'pausedDL'))
all_are_paused = false;
else
there_are_paused = true;
}); });
show_seq_dl = true;
if (!all_are_seq_dl && there_are_seq_dl)
show_seq_dl = false;
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) { if (all_are_downloaded) {
this.hideItem('SequentialDownload'); this.hideItem('SequentialDownload');
this.hideItem('FirstLastPiecePrio'); this.hideItem('FirstLastPiecePrio');
} else { } else {
this.showItem('SequentialDownload'); if (!show_seq_dl && show_f_l_piece_prio)
this.showItem('FirstLastPiecePrio'); 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');
this.setItemChecked('SequentialDownload', all_are_seq_dl); this.setItemChecked('SequentialDownload', all_are_seq_dl);
this.setItemChecked('FirstLastPiecePrio', all_are_f_l_piece_prio); this.setItemChecked('FirstLastPiecePrio', all_are_f_l_piece_prio);
} }
if (all_are_paused) {
this.showItem('Start');
this.hideItem('Pause');
} else {
if (there_are_paused) {
this.showItem('Start');
this.showItem('Pause');
} else {
this.hideItem('Start');
this.showItem('Pause');
}
}
}, },
//show menu //show menu

Loading…
Cancel
Save