transmission-web-control/template/dialog-torrent-changeDownloadDir.html
ronggang.zhou@gmail.com 95334d8b20 更新0.1 版本代码
2013-01-09 02:32:19 +00:00

114 lines
3.8 KiB
HTML

<div class="easyui-layout" data-options="fit:true" style="width:100%;height:100%;">
<div data-options="region:'center'" style="padding:3px;border:0px;">
<div id="" class="dialog" style="width:100%;padding:0px;">
<table style="width:100%;">
<tr>
<td width="20%" class="title"><span id="dialog-torrent-changeDownloadDir-old-download-dir"></span></td>
<td width="80%">
<span id="old-download-dir"></span>
</td>
</tr>
<tr>
<td class="title"><span id="dialog-torrent-changeDownloadDir-new-download-dir"></span></td>
<td>
<select id="download-dir" style="width:400px;"></select>
</td>
</tr>
<tr>
<td class="title"></td>
<td>
<input type="checkbox" id="move-data" style="width:20px;"/><label for="move-data" id="dialog-torrent-changeDownloadDir-move-data"></label>
</td>
</tr>
<tr>
<td colspan="2"><hr/></td>
</tr>
</table>
</div>
</div>
<div data-options="region:'south',border:false" style="text-align:right;padding:6px;">
<span id="text-nochange" style="display:none;"></span>
<a id="torrent-button-ok" class="easyui-linkbutton" data-options="iconCls:'icon-ok',plain:true" href="javascript:void(0);">Ok</a>
<a id="torrent-button-cancel" class="easyui-linkbutton" data-options="iconCls:'icon-cancel',plain:true" href="javascript:void(0);">Cancel</a>
</div>
</div>
<script type="text/javascript">
(function(thisDialog){
var title = "old-download-dir,new-download-dir,move-data".split(",");
var torrent = transmission.torrents.all[system.currentTorrentId];
$.each(title, function(i, item){
thisDialog.find("#dialog-torrent-changeDownloadDir-"+item).html(system.lang.dialog["torrent-changeDownloadDir"][item]);
});
thisDialog.find(".title").css({background:"#e6e6e6"});
title = "button-ok,button-cancel".split(",");
$.each(title, function(i, item){
thisDialog.find("#torrent-"+item).html(system.lang.dialog["public"][item]);
});
thisDialog.find("#text-nochange").html(system.lang.dialog["public"]["text-nochange"]);
thisDialog.find("#old-download-dir").text(torrent.downloadDir);
thisDialog.find("#download-dir").val(torrent.downloadDir);
$.each(transmission.downloadDirs, function(i, item){
$("<option/>").text(item).val(item).attr("selected",(item==torrent.downloadDir?true:false)).appendTo(thisDialog.find("#download-dir"));
});
if (transmission.downloadDirs.length==0)
{
$("<option/>").text(torrent.downloadDir).val(torrent.downloadDir).attr("selected",true).appendTo(thisDialog.find("#download-dir"));
}
thisDialog.find("#download-dir").combobox();
// 确认
thisDialog.find("#torrent-button-ok").click(function()
{
var dir = thisDialog.find("#download-dir").combobox("getValue");
var olddir = torrent.downloadDir;
var isnewdir =olddir!=dir;
var movedata = thisDialog.find("#move-data").prop("checked");
var button = $(this);
var icon = button.linkbutton("options").iconCls;
// 新目录
if (isnewdir)
{
button.linkbutton({disabled:true,iconCls:"icon-loading"});
// 开始设置参数
transmission.exec(
{
method:"torrent-set-location"
,arguments:{
ids:torrent.id
,location:dir
,move:movedata
}
}
,function(data){
button.linkbutton({iconCls:icon,disabled:false});
if (data.result=="success")
{
system.getTorrentInfos(torrent.id);
torrent.downloadDir = dir;
thisDialog.dialog("close");
}
}
);
}
else
{
thisDialog.find("#text-nochange").fadeInAndOut();
}
});
thisDialog.find("#torrent-button-cancel").click(function()
{
thisDialog.dialog("close");
});
})($("#dialog-torrent-changeDownloadDir"));
</script>