ClassBase.define({
init: function(param){
this.webdavPath = G.webdavOption.host;
this.initParentView(param);
this.initFormView(this.formData());
this.initPath();
},
initPath: function(){
var self = this;
if(G.webdavOption.pathAllow == 'self'){
this.$('.item-openMore').remove();
return;
}
var tpl = '{{each dataList item}}\
\
{{item.title}}:\
\
\
{{LNG["explorer.copy"]}}\
\
{{/each}}';
var data = [
{
title:LNG['explorer.file.address']+"(all)",
value:this.webdavPath
},
{
title:LNG['explorer.toolbar.fav'],
value:this.webdavPath+urlEncode(LNG['explorer.toolbar.fav'])+'/'
},
{
title:LNG['explorer.toolbar.myGroup'],
value:this.webdavPath + urlEncode(LNG['explorer.toolbar.myGroup'])+'/'
}
];
var $input = this.$('.item-detailAddress input');
var $content = this.$('.item-pathAllowMore .info-alert');
$input.val(this.webdavPath + 'my/');
this.renderHtml(tpl,{dataList:data},$content);
this.$('[action]').bind('click',function(){
var $btn = $(this);
var action = $btn.attr('action');
switch (action) {
case 'copy':
$.copyText($btn.prev().val());
Tips.tips(LNG['explorer.share.copied']);
break;
case 'selectPath':self.pathSelect();break;
default:break;
}
});
this.$('.item-openMore .btn').trigger('click');
},
pathSelect:function(){
var allowType = [
LNG['explorer.toolbar.fav'],
LNG['explorer.toolbar.rootPath'],
LNG['explorer.toolbar.myGroup'],
LNG['explorer.toolbar.shareToMe'],
];
var allowPath = ['{block:files}','{shareToMe}',_.trim(G.user.myhome,'/'),'{userFav}'];
var allowCheck = function(pathInfo){
var pathParse = kodApp.pathData.parse(pathInfo.path);
var pathView = pathInfo.pathDisplay || pathInfo.path;
var pathViewArr = _.trim(pathView,'/').split('/');
if(allowPath.indexOf(_.trim(pathInfo.path,'/')) != -1) return true;
if(pathParse.type == '{shareItem}') return true;
//console.log(1232,pathView,pathViewArr,pathParse,pathInfo);
if(allowType.indexOf(pathViewArr[0]) === -1){return false;}
return true;
};
var selectFinish = function(pathInfo){
if(!allowCheck(pathInfo)){return Tips.tips(LNG['explorer.pathNotSupport'],'warning',4000);}
var pathParse = kodApp.pathData.parse(pathInfo.path);
var pathView = pathInfo.pathDisplay || pathInfo.path;
if(pathParse.type == '{shareItem}'){
pathView = LNG['explorer.toolbar.shareToMe'] + '/' + _.trim(pathView,'/');
}
var pathViewArr = _.trim(pathView,'/').split('/');
if(pathViewArr[0] == allowType[1]){pathViewArr[0] = 'my';}
if(_.trim(pathInfo.path,'/') == '{block:files}'){pathViewArr = [];}
var url = G.webdavOption.host + urlEncode(pathViewArr.join('/')).replace(/%2F/g,'/');
Tips.tips(LNG['explorer.share.copied']+';
'+url);
$.copyText(url);
};
new kodApi.pathSelect({
type:'folder',single:true,
title:LNG['explorer.selectFolder']+'(support:'+allowType.join(',')+')',
pathOpen:G.user.myhome,pathTree:'{block:files}/',
//pathCheckAllow:function(pathInfo){},
callback:selectFinish
});
},
formData:function(){
var pluginApi = API_HOST+'plugin/webdav/download';
return {
"formStyle":{"hideSave":"1",className:"form-box-title-block "},
"detailAddress":{
"type":"html",
"display":"webdav "+LNG['common.address']+" ("+LNG['explorer.toolbar.rootPath']+")",
"value":"\
"+LNG['explorer.copy']+"\
\
"+LNG['explorer.selectFolder']+""
},
"openMore":{
"type":"button",
"className":"form-button-line",//横线腰线
"value":"",//默认值;同checkbox
"info":{
"1":{ //按钮名称
"display":LNG['webdav.user.morePath']+" ",
"className":"btn-default btn-sm btn",
}
},
"switchItem":{"1":"pathAllowMore"}
},
"pathAllowMore":{
"display":"",
"value":"
",
},
"help":{
"display":""+LNG['webdav.help.title']+"","value":
""
},
"detail":{
"display":""+LNG['common.tipsDesc']+"","value":
""
},
}
}
});