diff --git a/web/index.html b/web/index.html index 8327cb5bb..36f96bc2d 100755 --- a/web/index.html +++ b/web/index.html @@ -63,7 +63,7 @@ diff --git a/web/javascript/torrent.js b/web/javascript/torrent.js index 97b06c4f1..a1e2c354e 100644 --- a/web/javascript/torrent.js +++ b/web/javascript/torrent.js @@ -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() { diff --git a/web/javascript/transmission.js b/web/javascript/transmission.js index 3faad5087..6fe3b776e 100644 --- a/web/javascript/transmission.js +++ b/web/javascript/transmission.js @@ -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(); + } } }, diff --git a/web/javascript/transmission.remote.js b/web/javascript/transmission.remote.js index 38a4cc760..72d0f1ba8 100644 --- a/web/javascript/transmission.remote.js +++ b/web/javascript/transmission.remote.js @@ -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 ); } }; diff --git a/web/stylesheets/common.css b/web/stylesheets/common.css index 976146b85..f303df00d 100644 --- a/web/stylesheets/common.css +++ b/web/stylesheets/common.css @@ -566,7 +566,7 @@ div#inspector_tabs { background-position: left -26px; /* the highlighted part of the image */ } .inspector_container { - margin: 3%; + margin: 0 3%; width: 96%; } .inspector_group { @@ -601,6 +601,19 @@ div#inspector_tabs { cursor: default; overflow: hidden; } +#inspector_file_list #select_all_button_container { + margin: 0; +} +#inspector_file_list ul li.select_all_button { + background: transparent url(../images/buttons/tab_backgrounds.png) repeat-x scroll left -6px; + border: 1px solid #888888; + cursor: pointer; + float: right; + list-style-type: none; + margin: 2px; + padding: 2px 5px; +} + ul.inspector_torrent_file_list { width: 100%; margin: 0 0 0 0; @@ -611,6 +624,7 @@ ul.inspector_torrent_file_list { list-style-type: none; list-style: none; list-style-image: none; + clear: both; } li.inspector_torrent_file_list_entry { padding: 3px 0 3px 2px; @@ -633,9 +647,6 @@ div.inspector_torrent_file_list_entry_name { li.inspector_torrent_file_list_entry.skip>.inspector_torrent_file_list_entry_name { color: #666; } -li.inspector_torrent_file_list_entry.even { - background-color: #EEEEEE; -} div.inspector_torrent_file_list_entry_progress { font-size: 1em; color: #666;