#1940 Disable file wanted and priority selector when there is only one file.

This commit is contained in:
Mitchell Livingston 2009-03-19 12:46:53 +00:00
parent 9f4e42c4eb
commit 8158ec60b3
2 changed files with 11 additions and 12 deletions

View File

@ -88,7 +88,7 @@ Torrent.prototype =
// insert the element
$('#torrent_list').append(this._element);
this.initializeTorrentFilesInspectorGroup();
this.initializeTorrentFilesInspectorGroup(data.files.length);
for (var i = 0; i < data.files.length; i++) {
var file = data.files[i];
@ -107,14 +107,12 @@ Torrent.prototype =
this.refresh(data);
},
initializeTorrentFilesInspectorGroup: function() {
initializeTorrentFilesInspectorGroup: function(length) {
this._files = [];
this._fileList = $('<ul/>').addClass('inspector_torrent_file_list').addClass('inspector_group').hide().
append($('<li/>').addClass('inspector_group_label').append(
$('<div/>').append(this.name())
)
);
$('#inspector_file_list').append(this._fileList);
this._fileList = $('<ul/>').addClass('inspector_torrent_file_list').addClass('inspector_group').hide();
if(length == 1)
this._fileList.addClass('single_file');
$('#inspector_file_list').append(this._fileList);
},
fileList: function() {
@ -672,7 +670,7 @@ TorrentFile.prototype = {
},
setPriority: function(priority) {
if(this.element().hasClass('complete'))
if(this.element().hasClass('complete') || this._torrent._files.length == 1)
return;
var priority_level = { high: 1, normal: 0, low: -1 }[priority];
if (this._prio == priority_level) { return; }
@ -696,7 +694,7 @@ TorrentFile.prototype = {
},
toggleWanted: function() {
if(this.element().hasClass('complete'))
if(this.element().hasClass('complete') || this._torrent._files.length == 1)
return;
this.setWanted(!this._wanted);
},

View File

@ -645,6 +645,7 @@ li.inspector_torrent_file_list_entry.complete>.file_wanted_control {
background-position: left -19px;
}
ul.single_file li.inspector_torrent_file_list_entry>.file_wanted_control,
li.inspector_torrent_file_list_entry.complete>.file_wanted_control {
background-position: left -38px;
cursor: default;
@ -678,8 +679,8 @@ div.file_priority_control.low {
div.file_priority_control.low:hover {
background-position: right -38px;
}
li.inspector_torrent_file_list_entry.complete div.file_priority_control,
li.inspector_torrent_file_list_entry.complete div.file_priority_control:hover {
ul.single_file li.inspector_torrent_file_list_entry>.file_priority_control,
li.inspector_torrent_file_list_entry.complete div.file_priority_control {
background-position: left -57px;
cursor: default;
}