1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-12 07:03:44 +00:00

(trunk web) Add option to remove data when removing torrent from web interface

This commit is contained in:
Duncan Beevers 2009-02-12 17:20:43 +00:00
parent dabfe98200
commit 03b8d8a4b7
5 changed files with 66 additions and 1 deletions

View file

@ -30,6 +30,7 @@
<ul>
<li id="open"><div id="open_link"><div class="toolbar_image"></div>Open</div></li>
<li id="remove" class="disabled"><div id="remove_link"><div class="toolbar_image"></div>Remove</div></li>
<li id="removedata" class="disabled"><div id="removedata_link"><div class="toolbar_image"></div>Remove Data</div></li>
<li class="divider">&nbsp;</li>
<li id="pause_selected" class="disabled"><div id="pause_selected_link"><div class="toolbar_image"></div>Pause</div></li>
<li id="resume_selected" class="disabled"><div id="resume_selected_link"><div class="toolbar_image"></div>Resume</div></li>
@ -347,6 +348,7 @@
<li id="context_pause_selected" class="disabled context_pause_selected">Pause Selected</li>
<li id="context_resume_selected" class="disabled context_resume_selected">Resume Selected</li>
<li id="context_remove">Remove From List...</li>
<li id="context_removedata">Delete Data And Remove From List...</li>
<li id="context_toggle_inspector">Show Inspector</li>
<li class="separator"></li>
<li id="context_select_all" class="context_select_all">Select All</li>

View file

@ -11,7 +11,7 @@ Menu = {
context: {
menu_style: {
width: '210px',
width: '310px',
backgroundColor: '#fff',
border: 'none',
padding: '5px 0',

View file

@ -46,6 +46,7 @@ Transmission.prototype =
$('#pause_selected_link').bind('click', this.stopSelectedClicked );
$('#resume_selected_link').bind('click', this.startSelectedClicked);
$('#remove_link').bind('click', this.removeClicked);
$('#removedata_link').bind('click', this.removeDataClicked);
$('#filter_all_link').parent().bind('click', this.showAllClicked);
$('#filter_downloading_link').parent().bind('click', this.showDownloadingClicked);
$('#filter_seeding_link').parent().bind('click', this.showSeedingClicked);
@ -197,6 +198,9 @@ Transmission.prototype =
contextRemoveSelected: function( ) {
transmission.removeSelectedTorrents( );
},
contextRemoveDataSelected: function( ) {
transmission.removeSelectedTorrentsAndData( );
},
contextToggleInspector: function( ) {
transmission.toggleInspector( );
},
@ -216,6 +220,7 @@ Transmission.prototype =
context_pause_selected: this.contextStopSelected,
context_resume_selected: this.contextStartSelected,
context_remove: this.contextRemoveSelected,
context_removedata: this.contextRemoveDataSelected,
context_toggle_inspector: this.contextToggleInspector,
context_select_all: this.contextSelectAll,
context_deselect_all: this.contextDeselectAll
@ -547,6 +552,14 @@ Transmission.prototype =
}
},
removeDataClicked: function( event ) {
var tr = transmission;
if( tr.isButtonEnabled( event ) ) {
tr.removeSelectedTorrentsAndData( );
tr.hideiPhoneAddressbar( );
}
},
toggleInspectorClicked: function( event ) {
var tr = transmission;
if( tr.isButtonEnabled( event ) )
@ -1187,6 +1200,12 @@ Transmission.prototype =
this.promptToRemoveTorrents( torrents );
},
removeSelectedTorrentsAndData: function() {
var torrents = this.getSelectedTorrents( );
if( torrents.length )
this.promptToRemoveTorrentsAndData( torrents );
},
promptToRemoveTorrents:function( torrents )
{
if( torrents.length == 1 )
@ -1204,10 +1223,31 @@ Transmission.prototype =
}
},
promptToRemoveTorrentsAndData:function( torrents )
{
if( torrents.length == 1 )
{
var torrent = torrents[0],
header = 'Remove ' + torrent.name() + ' and delete data?',
message = 'All data downloaded for this torrent will be deleted. Are you sure you want to remove it?';
dialog.confirm( header, message, 'Remove', 'transmission.removeTorrentsAndData', torrents );
}
else
{
var header = 'Remove ' + torrents.length + ' transfers and delete data?',
message = 'All data downloaded for these torrents will be deleted. Are you sure you want to remove them?';
dialog.confirm( header, message, 'Remove', 'transmission.removeTorrentsAndData', torrents );
}
},
removeTorrents: function( torrents ) {
this.remote.removeTorrents( torrents );
},
removeTorrentsAndData: function( torrents ) {
this.remote.removeTorrentsAndData( torrents );
},
startSelectedTorrents: function( ) {
this.startTorrents( this.getSelectedTorrents( ) );
},
@ -1336,6 +1376,7 @@ Transmission.prototype =
this.setEnabled( 'li#resume_selected', havePausedSelection );
this.setEnabled( 'li.context_resume_selected', havePausedSelection );
this.setEnabled( 'li#remove', haveSelection );
this.setEnabled( 'li#removedata', haveSelection );
this.setEnabled( 'li#pause_all', haveActive );
this.setEnabled( 'li#resume_all', havePaused );
}

View file

@ -121,6 +121,20 @@ TransmissionRemote.prototype =
removeTorrents: function( torrents ) {
this.sendTorrentCommand( 'torrent-remove', torrents );
},
removeTorrentsAndData: function( torrents ) {
var remote = this,
o = { };
o.method = 'torrent-remove';
o.arguments = { };
o.arguments['delete-local-data'] = true;
o.arguments.ids = [ ];
if( torrents != null )
for( var i=0, len=torrents.length; i<len; ++i )
o.arguments.ids.push( torrents[i].id() );
this.sendRequest( RPC._Root, $.toJSON(o), function( ) {
remote.loadTorrents();
}, "json" );
},
addTorrentByUrl: function( url, options ) {
this.sendRequest( RPC._Root, $.toJSON({
method: 'torrent-add',

View file

@ -113,10 +113,18 @@ li#remove div div.toolbar_image, li#remove.disabled div:active div.toolbar_image
background-position: left -32px;
}
li#removedata div div.toolbar_image, li#removedata.disabled div:active div.toolbar_image {
background-position: left -32px;
}
li#remove div:active div.toolbar_image {
background-position: right -32px;
}
li#removedata div:active div.toolbar_image {
background-position: right -32px;
}
li#resume_selected div div.toolbar_image, li#resume_selected.disabled div:active div.toolbar_image {
background-position: left -96px;
}