Browse Source

FEATURE: Add Check/Uncheck all feature in Web UI

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
bbac79c030
  1. 1
      Changelog
  2. BIN
      src/Icons/3-state-checkbox.gif
  3. BIN
      src/Icons/L.gif
  4. 2
      src/icons.qrc
  5. 15
      src/webui/css/style.css
  6. 105
      src/webui/prop-files.html

1
Changelog

@ -9,6 +9,7 @@
- FEATURE: Several torrents can be moved at once - FEATURE: Several torrents can be moved at once
- FEATURE: Added error state for torrents (error is displayed in a tooltip) - FEATURE: Added error state for torrents (error is displayed in a tooltip)
- FEATURE: Added filter for paused/error torrents - FEATURE: Added filter for paused/error torrents
- FEATURE: Add Check/Uncheck all feature in Web UI
- COSMETIC: Display peers country name in tooltip - COSMETIC: Display peers country name in tooltip
- COSMETIC: Display number of torrents in transfers tab label - COSMETIC: Display number of torrents in transfers tab label

BIN
src/Icons/3-state-checkbox.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 B

BIN
src/Icons/L.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 B

2
src/icons.qrc

@ -4,10 +4,12 @@
<file>Icons/sphere2.png</file> <file>Icons/sphere2.png</file>
<file>Icons/downarrow.png</file> <file>Icons/downarrow.png</file>
<file>Icons/url.png</file> <file>Icons/url.png</file>
<file>Icons/3-state-checkbox.gif</file>
<file>Icons/loading.png</file> <file>Icons/loading.png</file>
<file>Icons/slow.png</file> <file>Icons/slow.png</file>
<file>Icons/magnet.png</file> <file>Icons/magnet.png</file>
<file>Icons/sphere.png</file> <file>Icons/sphere.png</file>
<file>Icons/L.gif</file>
<file>Icons/slow_off.png</file> <file>Icons/slow_off.png</file>
<file>Icons/uparrow.png</file> <file>Icons/uparrow.png</file>
<file>Icons/rss16.png</file> <file>Icons/rss16.png</file>

15
src/webui/css/style.css

@ -248,3 +248,18 @@ a.propButton img {
padding-right: 3px; padding-right: 3px;
} }
/* Tri-state checkbox */
a.tristate {
background: url(../images/3-state-checkbox.gif) 0 0 no-repeat;
display: block;
float: left;
height: 13px;
margin: .15em 8px 5px 0px;
overflow: hidden;
text-indent: -999em;
width: 13px;
}
a.checked { background-position: 0 -13px; }
a.partial { background-position: 0 -26px; }

105
src/webui/prop-files.html

@ -2,7 +2,7 @@
<table class="torrentTable" cellpadding="0" cellspacing="0"> <table class="torrentTable" cellpadding="0" cellspacing="0">
<thead> <thead>
<tr> <tr>
<th>_(Downloaded)</th> <th><a id="all_files_cb" style="margin-right: 2px;" class="tristate" onclick="javascript:switchCBState()"></a>&nbsp;&nbsp;_(Downloaded)</th>
<th>_(Name)</th> <th>_(Name)</th>
<th>_(Size)</th> <th>_(Size)</th>
<th style="width: 90px;">_(Progress)</th> <th style="width: 90px;">_(Progress)</th>
@ -16,10 +16,85 @@
<script type="text/javascript"> <script type="text/javascript">
var waitingTorrentFiles=false; var waitingTorrentFiles=false;
var current_hash = ""; var current_hash = "";
var setCBState = function(state) {
if(state == "partial") {
if(!$("all_files_cb").hasClass("partial")) {
$("all_files_cb").removeClass("checked");
$("all_files_cb").addClass("partial");
}
return;
}
if(state == "checked") {
if(!$("all_files_cb").hasClass("checked")) {
$("all_files_cb").removeClass("partial");
$("all_files_cb").addClass("checked");
}
return;
}
$("all_files_cb").removeClass("partial");
$("all_files_cb").removeClass("checked");
}
var switchCBState = function() {
// Uncheck
if($("all_files_cb").hasClass("partial")) {
$("all_files_cb").removeClass("partial");
// Uncheck all checkboxes
$$('input.DownloadedCB').each(function(item, index) {
item.erase("checked");
setFilePriority(index, 0);
});
return;
}
if($("all_files_cb").hasClass("checked")) {
$("all_files_cb").removeClass("checked");
// Uncheck all checkboxes
$$('input.DownloadedCB').each(function(item, index) {
item.erase("checked");
setFilePriority(index, 0);
});
return;
}
// Check
$("all_files_cb").addClass("checked");
// Check all checkboxes
$$('input.DownloadedCB').each(function(item, index) {
item.set("checked", "checked");
setFilePriority(index, 1);
});
}
var allCBChecked = function() {
var CBs = $$('input.DownloadedCB');
for(var i=0; i<CBs.length; i+=1) {
var item = CBs[i];
if(!$defined(item.get('checked')) || !item.get('checked'))
return false;
}
return true;
}
var allCBUnchecked = function() {
var CBs = $$('input.DownloadedCB');
for(var i=0; i<CBs.length; i+=1) {
var item = CBs[i];
if($defined(item.get('checked')) && item.get('checked'))
return false;
}
return true;
}
var setFilePriority = function(id, priority) { var setFilePriority = function(id, priority) {
if(current_hash == "") return; if(current_hash == "") return;
new Request({url: '/command/setFilePrio', method: 'post', data: {'hash': current_hash, 'id': id, 'priority': priority}}).send(); new Request({url: '/command/setFilePrio', method: 'post', data: {'hash': current_hash, 'id': id, 'priority': priority}}).send();
// Display or add combobox
if(priority > 0) {
$('comboPrio'+id).set("value", 1);
$('comboPrio'+id).removeClass("invisible");
} else {
$('comboPrio'+id).addClass("invisible");
}
} }
var createDownloadedCB = function(id, downloaded) { var createDownloadedCB = function(id, downloaded) {
@ -28,17 +103,20 @@ var createDownloadedCB = function(id, downloaded) {
if(downloaded) if(downloaded)
CB.set('checked', 'checked'); CB.set('checked', 'checked');
CB.set('id', 'cbPrio'+id); CB.set('id', 'cbPrio'+id);
CB.set('class', 'DownloadedCB');
CB.addEvent('change', function(e){ CB.addEvent('change', function(e){
var checked = 0; var checked = 0;
if($defined($('cbPrio'+id).get('checked')) && $('cbPrio'+id).get('checked')) if($defined($('cbPrio'+id).get('checked')) && $('cbPrio'+id).get('checked'))
checked = 1; checked = 1;
setFilePriority(id, checked); setFilePriority(id, checked);
// Display or add combobox if(allCBChecked()) {
if(checked) { setCBState("checked");
$('comboPrio'+id).set("value", 1);
$('comboPrio'+id).removeClass("invisible");
} else { } else {
$('comboPrio'+id).addClass("invisible"); if(allCBUnchecked()) {
setCBState("unchecked");
} else {
setCBState("partial");
}
} }
}); });
return CB; return CB;
@ -113,7 +191,7 @@ var createPriorityCombo = function(id, selected_prio) {
if(row[i] > 0) if(row[i] > 0)
tds[i].getChildren('input')[0].set('checked', 'checked'); tds[i].getChildren('input')[0].set('checked', 'checked');
else else
tds[i].removeProperty('checked') tds[i].getChildren('input')[0].removeProperty('checked')
} else { } else {
if(i == 4) { if(i == 4) {
if(row[i] > 0) { if(row[i] > 0) {
@ -148,7 +226,8 @@ var createPriorityCombo = function(id, selected_prio) {
td.adopt(new ProgressBar(row[i].toFloat(), {'id': 'pbf_'+id, 'width':80})); td.adopt(new ProgressBar(row[i].toFloat(), {'id': 'pbf_'+id, 'width':80}));
} else { } else {
if(i == 0) { if(i == 0) {
td.adopt(createDownloadedCB(id,row[i])); var tree_img = new Element('img', {src: 'images/L.gif', style: 'margin-bottom: -2px'});
td.adopt(tree_img, createDownloadedCB(id,row[i]));
} else { } else {
if(i == 4) { if(i == 4) {
td.adopt(createPriorityCombo(id,row[i])); td.adopt(createPriorityCombo(id,row[i]));
@ -206,6 +285,16 @@ var createPriorityCombo = function(id, selected_prio) {
fTable.insertRow(i, row); fTable.insertRow(i, row);
i++; i++;
}.bind(this)); }.bind(this));
// Set global CB state
if(allCBChecked()) {
setCBState("checked");
} else {
if(allCBUnchecked()) {
setCBState("unchecked");
} else {
setCBState("partial");
}
}
} else { } else {
fTable.removeAllRows(); fTable.removeAllRows();
} }

Loading…
Cancel
Save