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

View File

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