mirror of
https://github.com/transmission/transmission.git
synced 2025-12-24 12:28:52 +00:00
(trunk web) Add Select / Deselect All buttons to the file listing. Patch from Grug. Fixes #2294
This commit is contained in:
@@ -808,18 +808,20 @@ TorrentFile.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
setWanted: function(wanted) {
|
||||
setWanted: function(wanted, process) {
|
||||
this._dirty = true;
|
||||
this._wanted = wanted;
|
||||
if(!iPhone)
|
||||
this.element().toggleClass( 'skip', !wanted );
|
||||
var command = wanted ? 'files-wanted' : 'files-unwanted';
|
||||
this._torrent._controller.changeFileCommand(command, this._torrent, this);
|
||||
if (process) {
|
||||
var command = wanted ? 'files-wanted' : 'files-unwanted';
|
||||
this._torrent._controller.changeFileCommand(command, this._torrent, this);
|
||||
}
|
||||
},
|
||||
|
||||
toggleWanted: function() {
|
||||
if (this.isEditable())
|
||||
this.setWanted( !this._wanted );
|
||||
this.setWanted( !this._wanted, true );
|
||||
},
|
||||
|
||||
refreshHTML: function() {
|
||||
|
||||
@@ -49,6 +49,8 @@ Transmission.prototype =
|
||||
$('.inspector_tab').bind('click', function(e){ tr.inspectorTabClicked(e, this); });
|
||||
$('.file_wanted_control').live('click', function(e){ tr.fileWantedClicked(e, this); });
|
||||
$('.file_priority_control').live('click', function(e){ tr.filePriorityClicked(e, this); });
|
||||
$('#files_select_all').live('click', function(e){ tr.filesSelectAllClicked(e, this); });
|
||||
$('#files_deselect_all').live('click', function(e){ tr.filesDeselectAllClicked(e, this); });
|
||||
$('#open_link').bind('click', function(e){ tr.openTorrentClicked(e); });
|
||||
$('#upload_confirm_button').bind('click', function(e){ tr.confirmUploadClicked(e); return false;});
|
||||
$('#upload_cancel_button').bind('click', function(e){ tr.cancelUploadClicked(e); return false; });
|
||||
@@ -687,6 +689,26 @@ Transmission.prototype =
|
||||
this.extractFileFromElement(element).filePriorityControlClicked(event, element);
|
||||
},
|
||||
|
||||
filesSelectAllClicked: function(event) {
|
||||
var tr = this;
|
||||
var ids = jQuery.map(this.getSelectedTorrents( ), function(t) { return t.id(); } );
|
||||
var files_list = this.toggleFilesWantedDisplay(ids, true);
|
||||
for (i = 0; i < ids.length; ++i) {
|
||||
if (files_list[i].length)
|
||||
this.remote.filesSelectAll( [ ids[i] ], files_list[i], function() { tr.refreshTorrents( ids ); } );
|
||||
}
|
||||
},
|
||||
|
||||
filesDeselectAllClicked: function(event) {
|
||||
var tr = this;
|
||||
var ids = jQuery.map(this.getSelectedTorrents( ), function(t) { return t.id(); } );
|
||||
var files_list = this.toggleFilesWantedDisplay(ids, false);
|
||||
for (i = 0; i < ids.length; ++i) {
|
||||
if (files_list[i].length)
|
||||
this.remote.filesDeselectAll( [ ids[i] ], files_list[i], function() { tr.refreshTorrents( ids ); } );
|
||||
}
|
||||
},
|
||||
|
||||
extractFileFromElement: function(element) {
|
||||
var match = $(element).closest('.inspector_torrent_file_list_entry').attr('id').match(/^t(\d+)f(\d+)$/);
|
||||
var torrent_id = match[1];
|
||||
@@ -695,6 +717,22 @@ Transmission.prototype =
|
||||
return torrent._file_view[file_id];
|
||||
},
|
||||
|
||||
toggleFilesWantedDisplay: function(ids, wanted) {
|
||||
var i, j, k, torrent, files_list = [ ];
|
||||
for (i = 0; i < ids.length; ++i) {
|
||||
torrent = this._torrents[ids[i]];
|
||||
files_list[i] = [ ];
|
||||
for (j = k = 0; j < torrent._file_view.length; ++j) {
|
||||
if (torrent._file_view[j].isEditable() && torrent._file_view[j]._wanted != wanted) {
|
||||
torrent._file_view[j].setWanted(wanted, false);
|
||||
files_list[i][k++] = j;
|
||||
}
|
||||
}
|
||||
torrent.refreshFileView;
|
||||
}
|
||||
return files_list;
|
||||
},
|
||||
|
||||
toggleFilterClicked: function(event) {
|
||||
if (this.isButtonEnabled(event))
|
||||
this.toggleFilter();
|
||||
@@ -1126,8 +1164,17 @@ Transmission.prototype =
|
||||
|
||||
updateVisibleFileLists: function() {
|
||||
if( this.fileListIsVisible( ) === true ) {
|
||||
jQuery.each( this.getSelectedTorrents(), function() { this.showFileList(); } );
|
||||
var selected = this.getSelectedTorrents();
|
||||
jQuery.each( selected, function() { this.showFileList(); } );
|
||||
jQuery.each( this.getDeselectedTorrents(), function() { this.hideFileList(); } );
|
||||
// Check if we need to display the select all buttions
|
||||
if ( !selected.length ) {
|
||||
if ( $("#select_all_button_container").is(':visible') )
|
||||
$("#select_all_button_container").hide();
|
||||
} else {
|
||||
if ( !$("#select_all_button_container").is(':visible') )
|
||||
$("#select_all_button_container").show();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -154,10 +154,12 @@ TransmissionRemote.prototype =
|
||||
} );
|
||||
},
|
||||
|
||||
sendTorrentActionRequests: function( method, torrent_ids, callback ) {
|
||||
sendTorrentSetRequests: function( method, torrent_ids, args, callback ) {
|
||||
if (!args) args = { };
|
||||
args['ids'] = torrent_ids;
|
||||
var o = {
|
||||
method: method,
|
||||
arguments: { ids: torrent_ids }
|
||||
arguments: args
|
||||
};
|
||||
|
||||
this.sendRequest( o, function( data ) {
|
||||
@@ -165,6 +167,10 @@ TransmissionRemote.prototype =
|
||||
});
|
||||
},
|
||||
|
||||
sendTorrentActionRequests: function( method, torrent_ids, callback ) {
|
||||
this.sendTorrentSetRequests( method, torrent_ids, null, callback );
|
||||
},
|
||||
|
||||
startTorrents: function( torrent_ids, callback ) {
|
||||
this.sendTorrentActionRequests( 'torrent-start', torrent_ids, callback );
|
||||
},
|
||||
@@ -217,5 +223,11 @@ TransmissionRemote.prototype =
|
||||
this.sendRequest( o, function() {
|
||||
remote._controller.loadDaemonPrefs();
|
||||
} );
|
||||
},
|
||||
filesSelectAll: function( torrent_ids, files, callback ) {
|
||||
this.sendTorrentSetRequests( 'torrent-set', torrent_ids, { 'files-wanted': files }, callback );
|
||||
},
|
||||
filesDeselectAll: function( torrent_ids, files, callback ) {
|
||||
this.sendTorrentSetRequests( 'torrent-set', torrent_ids, { 'files-unwanted': files }, callback );
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user