forked from fex-team/ufinder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathufinder.min.js
4 lines (4 loc) · 102 KB
/
ufinder.min.js
1
2
3
4
!function($,window){var UFinder=window.UF=window.UFinder=function(){var a={},b=0;return{version:"1.0.0",createFinder:function(a,b){b=b||{},b.renderTo=Utils.isString(a)?document.getElementById(a):a;var c=new Finder(b);return this.addFinder(b.renderTo,c),c},addFinder:function(c,d){var e;e="string"==typeof c?c:c.id||"UF_INSTANCE_"+b++,a[e]=d},getFinder:function(c,d){var e;return e="string"==typeof c?c:c.id||"UF_INSTANCE_"+b++,a[e]||this.createFinder(c,d)},LANG:{}}}(),browser=UF.browser=function(){var a=navigator.userAgent.toLowerCase(),b=window.opera,c={ie:!!window.ActiveXObject,opera:!!b&&b.version,webkit:a.indexOf(" applewebkit/")>-1,mac:a.indexOf("macintosh")>-1,quirks:"BackCompat"==document.compatMode};c.gecko="Gecko"==navigator.product&&!c.webkit&&!c.opera;var d=0;if(c.ie&&(d=parseFloat(a.match(/msie (\d+)/)[1]),c.ie9Compat=9==document.documentMode,c.ie8=!!document.documentMode,c.ie8Compat=8==document.documentMode,c.ie7Compat=7==d&&!document.documentMode||7==document.documentMode,c.ie6Compat=7>d||c.quirks,c.ie9above=d>8,c.ie9below=9>d),c.gecko){var e=a.match(/rv:([\d\.]+)/);e&&(e=e[1].split("."),d=1e4*e[0]+100*(e[1]||0)+1*(e[2]||0))}return/chrome\/(\d+\.\d)/i.test(a)&&(c.chrome=+RegExp.$1),/(\d+\.\d)?(?:\.\d)?\s+safari\/?(\d+\.\d+)?/i.test(a)&&!/chrome/i.test(a)&&(c.safari=+(RegExp.$1||RegExp.$2)),c.opera&&(d=parseFloat(b.version())),c.webkit&&(d=parseFloat(a.match(/ applewebkit\/(\d+)/)[1])),c.version=d,c.isCompatible=!c.mobile&&(c.ie&&d>=6||c.gecko&&d>=10801||c.opera&&d>=9.5||c.air&&d>=1||c.webkit&&d>=522||!1),c}(),ie=browser.ie,webkit=browser.webkit,gecko=browser.gecko,opera=browser.opera;UF.defaultOptions={zIndex:10,lang:"zh-cn"},function(){var a;UF.registerModule=function(b,c){a||(a={}),a[b]=c},UF.getModules=function(){return a}}();var Utils=UFinder.Utils={isOverlap:function(a,b){var c=a.offset(),d=b.offset(),e=c.left,f=c.top,g=e+a.width(),h=f+a.height(),i=d.left,j=d.top,k=i+b.width(),l=j+b.height(),m=Math.abs(e+g-i-k),n=Math.abs(e-g)+Math.abs(i-k),o=Math.abs(f+h-j-l),p=Math.abs(f-h)+Math.abs(j-l);return n>=m&&p>=o},dateFormat:function(a,b){var c={"M+":a.getMonth()+1,"d+":a.getDate(),"h+":a.getHours(),"m+":a.getMinutes(),"s+":a.getSeconds(),"q+":Math.floor((a.getMonth()+3)/3),S:a.getMilliseconds()};/(y+)/.test(b)&&(b=b.replace(RegExp.$1,(a.getFullYear()+"").substr(4-RegExp.$1.length)));for(var d in c)new RegExp("("+d+")").test(b)&&(b=b.replace(RegExp.$1,1==RegExp.$1.length?c[d]:("00"+c[d]).substr((""+c[d]).length)));return b},argsToArray:function(a,b){return Array.prototype.slice.call(a,b||0)},regularDirPath:function(a){return a.replace(/([^\/])$/,"$1/").replace(/^([^\/])/,"/$1")},getParentPath:function(a){return a.replace(/[^\/]+\/?$/,"")},getPathExt:function(a){var b=a.lastIndexOf(".");return a.substr((-1==b?a.length:b)+1)},isImagePath:function(a){return a&&-1!="png gif bmp jpg jpeg".split(" ").indexOf(Utils.getPathExt(a))},isCodePath:function(a){return a&&-1!="txt md json js css html htm xml php asp jsp".split(" ").indexOf(Utils.getPathExt(a))},isWebPagePath:function(a){return a&&-1!="html php asp jsp".split(" ").indexOf(Utils.getPathExt(a))},extend:function(a,b,c){if(b)for(var d in b)c&&a.hasOwnProperty(d)||(a[d]=b[d]);return a},clone:function(a,b){var c;b=b||{};for(var d in a)a.hasOwnProperty(d)&&(c=a[d],"object"==typeof c?(b[d]=Utils.isArray(c)?[]:{},Utils.clone(a[d],b[d])):b[d]=c);return b},loadFile:function(){function a(a,c){try{for(var d,e=0;d=b[e++];)if(d.doc===a&&d.url==(c.src||c.href))return d}catch(f){return null}}var b=[];return function(c,d,e){var f,g=a(c,d);if(g)return void(g.ready?e&&e():g.funs.push(e));if(b.push({doc:c,url:d.src||d.href,funs:[e]}),!c.body){var h=[];for(f in d)"tag"!=f&&h.push(f+'="'+d[f]+'"');return void c.write("<"+d.tag+" "+h.join(" ")+" ></"+d.tag+">")}if(!d.id||!c.getElementById(d.id)){var i=c.createElement(d.tag);delete d.tag;for(f in d)i.setAttribute(f,d[f]);i.onload=i.onreadystatechange=function(){if(!this.readyState||/loaded|complete/.test(this.readyState)){if(g=a(c,d),g.funs.length>0){g.ready=1;for(var b;b=g.funs.pop();)b()}i.onload=i.onreadystatechange=null}},i.onerror=function(){throw new Error("The load "+(d.href||d.src)+" fails,check the url")},c.getElementsByTagName("head")[0].appendChild(i)}}}()};$.each(["String","Function","Array","Number","RegExp","Object","Boolean"],function(a,b){Utils["is"+b]=function(a){return Object.prototype.toString.apply(a)=="[object "+b+"]"}}),function(){function Class(){}function getCallerClass(a){a.constructor}function checkBaseConstructorCall(a,b){var c=a.toString();if(!/this\.callBase/.test(c))throw new Error(b+" : 类构造函数没有调用父类的构造函数!为了安全,请调用父类的构造函数")}function checkMixinConstructorCall(a,b){var c=a.toString();if(!/this\.callMixin/.test(c))throw new Error(b+" : 类构造函数没有调用父类的构造函数!为了安全,请调用父类的构造函数")}function inherit(constructor,BaseClass,classname){var UFinderClass=eval("(function UFinder"+classname+"( __inherit__flag ) {if( __inherit__flag != FINDER_INHERIT_FLAG ) {UFinderClass.__UFinderConstructor.apply(this, arguments);}this.__UFinderClassName = UFinderClass.__UFinderClassName;})");UFinderClass.__UFinderConstructor=constructor,UFinderClass.prototype=new BaseClass(FINDER_INHERIT_FLAG);for(var methodName in BaseClass.prototype)BaseClass.prototype.hasOwnProperty(methodName)&&0!==methodName.indexOf("__UFinder")&&(UFinderClass.prototype[methodName]=BaseClass.prototype[methodName]);return UFinderClass.prototype.constructor=UFinderClass,UFinderClass}function mixin(a,b){if(!1==b instanceof Array)return a;var c,d,e,f=b.length;for(a.__UFinderMixins={constructor:[]},c=0;f>c;c++){d=b[c].prototype;for(e in d)!1!==d.hasOwnProperty(e)&&0!==e.indexOf("__UFinder")&&("constructor"===e?a.__UFinderMixins.constructor.push(d[e]):a.prototype[e]=a.__UFinderMixins[e]=d[e])}return a}function extend(a,b){b.__UFinderClassName&&(b=b.prototype);for(var c in b)if(b.hasOwnProperty(c)&&c.indexOf("__UFinder")&&"constructor"!=c){var d=a.prototype[c]=b[c];d.__UFinderMethodClass=a,d.__UFinderMethodName=c}return a}var debug=!0;if(Function.prototype.bind=Function.prototype.bind||function(a){var b=Array.prototype.slice.call(arguments,1);return this.apply(a,b)},debug){var origin=Object.prototype.toString;Object.prototype.toString=function(){return this.__UFinderClassName||origin.call(this)}}Class.__UFinderClassName="Class",Class.prototype.base=function(a){var b=arguments.callee.caller,c=b.__UFinderMethodClass.__UFinderBaseClass.prototype[a];return c.apply(this,Array.prototype.slice.call(arguments,1))},Class.prototype.callBase=function(){var a=arguments.callee.caller,b=a.__UFinderMethodClass.__UFinderBaseClass.prototype[a.__UFinderMethodName];return b.apply(this,arguments)},Class.prototype.mixin=function(a){var b=arguments.callee.caller,c=b.__UFinderMethodClass.__UFinderMixins;if(!c)return this;var d=c[a];return d.apply(this,Array.prototype.slice.call(arguments,1))},Class.prototype.callMixin=function(){var a=arguments.callee.caller,b=a.__UFinderMethodName,c=a.__UFinderMethodClass.__UFinderMixins;if(!c)return this;var d=c[b];if("constructor"==b){for(var e=0,f=d.length;f>e;e++)d[e].call(this);return this}return d.apply(this,arguments)},Class.prototype.pipe=function(a){return"function"==typeof a&&a.call(this,this),this},Class.prototype.getType=function(){return this.__UFinderClassName};var FINDER_INHERIT_FLAG="__FINDER_INHERIT_FLAG_"+ +new Date;UF.createClass=function(a,b){var c,d,e;return 1===arguments.length&&(b=arguments[0],a="AnonymousClass"),e=b.base||Class,b.hasOwnProperty("constructor")?(c=b.constructor,e!=Class&&checkBaseConstructorCall(c,a)):c=function(){this.callBase.apply(this,arguments),this.callMixin.apply(this,arguments)},d=inherit(c,e,a),d=mixin(d,b.mixins),d.__UFinderClassName=c.__UFinderClassName=a,d.__UFinderBaseClass=c.__UFinderBaseClass=e,d.__UFinderMethodNames=c.__UFinderMethodName="constructor",d.__UFinderMethodClass=c.__UFinderMethodClass=d,delete b.mixins,delete b.constructor,delete b.base,d=extend(d,b)},UF.extendClass=extend}();var FileNode=UF.FileNode=UF.createClass("FileNode",{constructor:function(a){this.info={},this.parent=null,this.locked=!1,this.children=[],this.setInfo(a)},setInfo:function(a){var b=this,c=["path","name","type","read","write","time","mode","size"];$.each(c,function(c,d){a[d]&&b.setAttr(d,a[d])}),this._regularDirPath()},_regularDirPath:function(){var a=this.info.path.replace(/^([^\/])/,"/$1");this.info.path="dir"==this.getAttr("type")?a.replace(/([^\/])$/,"$1/"):a.replace(/([^\/])$/,"$1")},getInfo:function(){return this.info},setAttr:function(a,b){this.info[a]=b,this._regularDirPath()},getAttr:function(a){return this.info[a]},addChild:function(a){a.parent=this,this.children.push(a)},remove:function(){this.parent&&this.parent.removeChild(this)},removeChild:function(a){a.parent=this,this.children.pop(a)},getChild:function(a){for(var b in this.children)if(this.children[b].getAttr("name")==a)return this.children[b];return null},lock:function(){this.locked=!0},unLock:function(){this.locked=!1}}),Finder=UF.Finder=UF.createClass("Finder",{constructor:function(a){this._options=$.extend({},a,window.UFINDER_CONFIG),this.setDefaultOptions(UF.defaultOptions),this._initEvents(),this._initSelection(),this._initFinder(),this._initShortcutKey(),this._initModules(),this.fire("finderready")},_initFinder:function(){this.dataTree=new DataTree(this),this.proxy=new Proxy(this),this.isFocused=!1,this.serverOption={realRootUrl:this.getOption("realUrl")},this.setCurrentPath("/")},getCurrentPath:function(){return this._currentPath},setCurrentPath:function(a){"/"!=a.charAt(0)&&(a="/"+a),"/"!=a.charAt(a.length-1)&&(a+="/"),this._currentPath=a,this.fire("currentpathchange",this._currentPath)},setDefaultOptions:function(a,b){var c={};Utils.isString(a)?c[a]=b:c=a,$.extend(this._options,c,$.extend({},this._options))},getOption:function(a){return this._options[a]},getLang:function(a){var b=UF.LANG[this.getOption("lang")];if(!b)throw new Error("not import language file");a=(a||"").split(".");for(var c,d=0;(c=a[d++])&&(b=b[c],b););return b},getRealPath:function(a){return(this.serverOption.realRootUrl+a).replace(/([^:])\/\//g,"$1/")}});UF.extendClass(Finder,{_initEvents:function(){this._eventCallbacks={}},_initDomEvent:function(){var a=this,b=a.$container,c=$('<input class="ufui-key-listener">');b.append($('<div class="ufui-event-helper" style="position:absolute;left:0;top:0;height:0;width:0;overflow: hidden;"></div>').append(c)),a._proxyDomEvent=$.proxy(a._proxyDomEvent,a),a._initKeyListener(b,c),$(document).on("keydown keyup keypress",a._proxyDomEvent),b.on("click mousedown mouseup mousemove mouseover mouseout contextmenu selectstart",a._proxyDomEvent)},_proxyDomEvent:function(a){var b=this;if(a.originalEvent){var c=$(a.originalEvent.target);$.each(["tree","list","toolbar"],function(d,e){(c[0]==b["$"+e][0]||c.parents(".ufui-"+e)[0]==b["$"+e][0])&&b.fire(e+"."+a.type.replace(/^on/,""),a)})}return this.fire(a.type.replace(/^on/,""),a)},_initKeyListener:function(a,b){var c=this;a.on("click",function(a){var d=a.target;"INPUT"!=d.tagName&&"TEXTAREA"!=d.tagName&&1!=d.contentEditable&&(b.focus(),0==c.isFocused&&c.setFocus())}),$(document).on("click",function(d){if(d.originalEvent){var e=$(d.originalEvent.target).parents(".ufui-container");0==$(d.originalEvent.target).parents(".context-menu-list").length&&e[0]!=a[0]&&(b.blur(),1==c.isFocused&&c.setBlur())}}),c.on("afterexeccommand",function(a,c){-1==["rename","touch","mkdir","search","searchindex"].indexOf(c)&&b.focus()})},setFocus:function(){this.isFocused=!0,this.fire("focus")},setBlur:function(){this.isFocused=!1,this.fire("blur")},_listen:function(a,b){var c=this._eventCallbacks[a]||(this._eventCallbacks[a]=[]);c.push(b)},on:function(a,b){for(var c=a.split(" "),d=0;d<c.length;d++)this._listen(c[d].toLowerCase(),b);return this},one:function(a,b){var c=this,d=function(){b(),c.off(a,d)};return c.on(a,d),this},off:function(a,b){var c,d,e,f,g=a.split(" ");for(c=0;c<g.length;c++)if(e=this._eventCallbacks[g[c].toLowerCase()]){for(f=null,d=0;d<e.length;d++)e[d]==b&&(f=d);null!==f&&e.splice(f,1)}},fire:function(a){var b=this._eventCallbacks[a.toLowerCase()];if(b){for(var c=0;c<b.length;c++){var d=b[c].apply(this,arguments);if(0==d)break}return d}}}),UF.extendClass(Finder,{_initShortcutKey:function(){this._shortcutkeys={}},addShortcutKeys:function(a,b){var c={};b?c[a]=b:c=a,$.extend(this._shortcutkeys,c)},_bindshortcutKeys:function(){var a=this,b=a._shortcutkeys;a.on("keydown",function(c,d){if("true"==$(d.target).attr("contentEditable")||"text"==$(d.target).attr("type"))return!0;var e=d.keyCode||d.which;console.log(d.keyCode);for(var f in b)for(var g,h=b[f].split(","),i=0;g=h[i++];){g=g.split(":");var j=g[0],k=g[1];(/^(ctrl)(\+shift)?\+(\d+)$/.test(j.toLowerCase())||/^(\d+)$/.test(j))&&(("ctrl"==RegExp.$1?d.ctrlKey||d.metaKey:0)&&(""!=RegExp.$2?d[RegExp.$2.slice(1)+"Key"]:1)&&e==RegExp.$3||e==RegExp.$1)&&(-1!=a.queryCommandState(f,k)&&a.execCommand(f,k),d.preventDefault())}})}}),UF.extendClass(Finder,{_initSelection:function(){this._selectedFiles=[]},getSelection:function(){return new Selection(this)},setSelectedFiles:function(a){this._selectedFiles=$.isArray(a)?a:[a],this.fire("selectionchange")}}),UF.extendClass(Finder,{_initModules:function(){var a=UF.getModules();this._commands={},this._query={},this._modules={};var b,c,d,e,f=this;for(b in a)if(a.hasOwnProperty(b)){c=a[b].call(f),this._modules[b]=c,c.init&&c.init.call(f,this._options),d=c.commands;for(var g in d)f._commands[g.toLowerCase()]=d[g];if(c.defaultOptions&&f.setDefaultOptions(c.defaultOptions),e=c.events)for(var h in e)f.on(h,e[h]);c.shortcutKeys&&f.addShortcutKeys(c.shortcutKeys)}this._bindshortcutKeys()}}),UF.extendClass(Finder,{_getCommand:function(a){return this._commands[a.toLowerCase()]},_queryCommand:function(a,b,c){var d=this._getCommand(a);if(d){var e=d["query"+b];if(e)return e.apply(d,[this].concat(c))}return 0},queryCommandState:function(a){return this.isFocused?this._queryCommand(a,"State",Utils.argsToArray(1)):-1},queryCommandValue:function(a){return this._queryCommand(a,"Value",Utils.argsToArray(1))},execCommand:function(a){a=a.toLowerCase();var b,c,d=$.makeArray(arguments).slice(1),e=this;return(b=this._getCommand(a))?(e.fire("beforeexeccommand",a),c=b.execute.apply(e,d),e.fire("afterexeccommand",a),void 0===c?null:c):!1}});var Selection=UF.Selection=UF.createClass("Selection",{constructor:function(a){this.finder=a,this._selectedFiles=a._selectedFiles||[]},getSelectedFile:function(){return this._selectedFiles[0]},getSelectedFiles:function(){return this._selectedFiles},removeSelectedFiles:function(a){var b=this;$.each($.isArray(a)?a:[a],function(a,c){var d;-1!==(d=b._selectedFiles.indexOf(c))&&b._selectedFiles.splice(d,1)})},removeAllSelectedFiles:function(){this._selectedFiles=[]},isFileSelected:function(a){return-1!==this._selectedFiles.indexOf(a)},select:function(){this.finder.fire("selectfiles",this._selectedFiles)}}),DataTree=UF.DataTree=UF.createClass("DataTree",{constructor:function(a){this.finder=a,this.root=null},setRoot:function(a){this.root=new FileNode(a),this.finder.fire("dataReady",a)},getNearestNode:function(a){for(var b=this.root,c=a.split("/"),d=0;d<c.length;d++){var e=c[d];if(""!=e){var f=b;if(b=b.getChild(e),null==b)return f.getInfo().path}}return a},_getFileNode:function(a){for(var b=this.root,c=a.split("/"),d=0;d<c.length;d++){var e=c[d];if(""!=e){if(b=b.getChild(e),null==b)return b}}return b},getFileInfo:function(a){var b=this._getFileNode(a);return b?b.getInfo():null},_addFile:function(a){for(var b=this.root,c=$.trim(a.path).replace(/(^\/)|(\/$)/g,"").split("/"),d=0;d<c.length-1;d++){var e=c[d];""!=e&&(b=b.getChild(e))}b&&b.addChild(new FileNode(a))},addFile:function(a){this._addFile(a),this.finder.fire("addFiles",a)},updateFile:function(a,b){var c=this._getFileNode(a);c.path==a?c.setInfo(b):(c.remove(),this._addFile(b)),this.finder.fire("updateFile",a,b)},removeFile:function(a){var b=this._getFileNode(a);b&&b.remove(),this.finder.fire("removeFiles",a)},addFiles:function(a){var b=this;$.each(a,function(a,c){b.addFile(c)})},removeFiles:function(a){var b=this;$.each(a,function(a,c){b.removeFile(c)})},lockFile:function(a){var b=this._getFileNode(a);b&&b.lock(),this.finder.fire("lockfiles",[a])},unLockFile:function(a){var b=this._getFileNode(a);b&&b.unLock(),this.finder.fire("unlockfiles",[a])},lockFiles:function(a){var b=this;$.each(a,function(a,c){b.lockFile(c)})},unLockFiles:function(a){var b=this;$.each(a,function(a,c){b.unLockFile(c)})},listDirFileInfo:function(a){var b=[],c=this._getFileNode(a);return null==c?null:($.each(c.children,function(a,c){b.push(c.getInfo())}),b)},removeDirChilds:function(a){var b=[],c=this._getFileNode(a);null!=c&&($.each(c.children,function(a,c){b.push(c.getInfo().path)}),this.removeFiles(b),c.children.splice(0,c.children.length))},isFileLocked:function(a){return this._getFileNode(a).locked}}),Request=UF.Request=UF.createClass("Request",{constructor:function(a,b){this.id="r"+(+new Date).toString(36),this.data=a,this.jqXhr=null,this.callback=b},send:function(){var me=this;me.jqXhr=$.ajax(me.data).always(function(r){try{me.responseJson=JSON?JSON.parse(r):eval(r)}catch(e){me.responseJson=null}me.responseText=r,me.callback&&me.callback(me.responseJson)})},abort:function(){this.cancel()},cancel:function(){this.jqXhr&&this.jqXhr.abort()},callback:function(){}}),Uploader=UF.Uploader=UF.createClass("Uploader",{constructor:function(a,b){this.id="r"+(+new Date).toString(36),this.data=a,this.webuploader=a.webuploader,this.callback=b,this.process=a.process,this.file=a.data.file,this._initEvents()},_initEvents:function(){var me=this,r,handler=function(file){if(file.id==me.file.id){try{me.responseJson=JSON?JSON.parse(r):eval(r)}catch(e){me.responseJson=null}me.responseText=r,me.webuploader.stop(),me.callback&&me.callback(me.responseJson),me.webuploader.off("uploadComplete",handler)}};me.webuploader.on("uploadProgress",function(a,b){me.process&&me.process(b)}),me.webuploader.on("uploadSuccess",function(a,b){r=b._raw}),me.webuploader.on("uploadError",function(a,b){r=b._raw}),me.webuploader.on("uploadComplete",handler)},send:function(){this.webuploader.option("formdata",{cmd:"upload",target:this.data.data.target}),this.webuploader.upload(this.file)},pause:function(){this.webuploader.stop()},cancel:function(){this.webuploader.stop(!0)}}),Proxy=UF.Proxy=UF.createClass("Proxy",{constructor:function(a){this.finder=a,this._queue=[],this.active=!1,this.nextSendIndex=0,this._url=a.getOption("serverUrl")},init:function(a){return this._get({cmd:"init"},a)},getRequestUrl:function(a){var b=this._url+"?";return $.each(a||{},function(a,c){b+=a+"="+c+"&"}),"&"==b.charAt(b.length-1)&&(b=b.substr(0,b.length-1)),"?"==b.charAt(b.length-1)&&(b=b.substr(0,b.length-1)),b},ls:function(a,b){return this._get({cmd:"ls",target:a},b)},rename:function(a,b,c){return this._get({cmd:"rename",target:a,name:b},c)},touch:function(a,b){return this._get({cmd:"touch",target:a},b)},mkdir:function(a,b){return this._get({cmd:"mkdir",target:a},b)},rm:function(a,b){return this._get({cmd:"rm",target:a},b)},move:function(a,b){return this._get({cmd:"mv",target:a},b)},copy:function(a,b){return this._get({cmd:"copy",target:a},b)},upload:function(a,b,c){return this._upload({cmd:"upload",target:a,file:b},c,b)},preview:function(a,b){return this._get({cmd:"preview",target:a},b)},search:function(a,b){return this._get({cmd:"search",target:a},b)},info:function(a,b){return this._get({cmd:"info",target:a},b)},_get:function(a,b){return this._ajax("GET",a,b)},_post:function(a,b){return this._ajax("POST",a,b)},_upload:function(a,b){return this._ajax("UPLOAD",a,b)},_ajax:function(a,b,c){var d,e=this,f=function(a){e._beforeRequestComplete(a,d),c&&c(a,d),e._afterRequestComplete(a,d)};return d="UPLOAD"==a?new Uploader({url:e._url,type:a,webuploader:e.finder.webuploader,data:b,process:function(a){e.finder.fire("updatemessage",{loadedPercent:a,request:d,id:d.id})}},f):new Request({url:e._url,type:a,data:b},f),e._pushRequest(d),-1==["search","preview"].indexOf(b.cmd)&&e.finder.fire("showmessage",{icon:"loading",title:b.cmd+" loading...",loadedPercent:100,request:d,id:d.id}),d},_pushRequest:function(a){this._queue.push(a),this._sendRequest()},_sendRequest:function(){!this.active&&this.nextSendIndex<this._queue.length&&(this.active=!0,this._queue[this.nextSendIndex++].send())},_beforeRequestComplete:function(a,b){this.finder.fire("beforeRequestComplete",a,b),this.finder.fire("hidemessage",{id:b.id}),this.active=!1,this._sendRequest()},_afterRequestComplete:function(a,b){this.finder.fire("afterRequestComplete",a,b)}});UF.registerModule("openmodule",function(){var a=this,b=function(b,c){void 0===b?b=a.getSelection().getSelectedFile():""==b&&(b="/");var d="",e=a.dataTree.listDirFileInfo(b),f=function(e){var g=e&&e.data&&e.data.files||[];a.dataTree.addFiles(g);var h=a.dataTree.getNearestNode(b);d!=h?(d=h,a.proxy.ls(h,f)):c&&a.setCurrentPath(b)};if(e&&e.length)f(e);else{var d=a.dataTree.getNearestNode(b);a.proxy.ls(d,f)}},c=function(){var b,c;return b=a.getSelection().getSelectedFiles(),1==b.length?(c=a.dataTree.getFileInfo(b[0]),c&&c.read&&!a.dataTree.isFileLocked(b[0])?0:-1):-1};return{init:function(){},defaultOptions:{},commands:{open:{execute:function(c){void 0===c?c=a.getSelection().getSelectedFile():""==c&&(c="/"),a.setSelectedFiles([]),a.dataTree.removeDirChilds(c),b(c,!0)},queryState:c},refresh:{execute:function(){var a=this,c=a.getCurrentPath();a.dataTree.removeDirChilds(c),b(c,!0)},queryState:function(){return 0}},list:{execute:function(a){b(a,!1)},queryState:c}},shortcutKeys:{open:"13",refresh:"116"},events:{}}}),UF.registerModule("addfilemodule",function(){var a=this;return{init:function(){},defaultOptions:{},commands:{touch:{execute:function(){a.fire("newFileTitle","",function(b,c){console.log("|******** touch done ********|");var d=a.getCurrentPath()+b;b&&a.proxy.touch(d,function(b){if(c&&c(0==b.state),0==b.state){var d=b&&b.data&&b.data.file;a.dataTree.addFile(d),a.fire("selectfiles",d.path)}else a.fire("showmessage",{title:b.message,timeout:3e3})})})},queryState:function(){var b,c=a.getCurrentPath();return b=a.dataTree.getFileInfo(c),b&&b.write&&!a.dataTree.isFileLocked(c)?0:-1}},mkdir:{execute:function(){a.fire("newFileTitle","dir",function(b,c){console.log("|******** mkdir done ********|");var d=a.getCurrentPath()+b;b&&a.proxy.mkdir(d,function(b){if(c&&c(0==b.state),0==b.state){var d=b&&b.data&&b.data.file;a.dataTree.addFile(d),a.fire("selectfiles",d.path)}else a.fire("showmessage",{title:b.message,timeout:3e3})})})},queryState:function(){var b,c=a.getCurrentPath();return b=a.dataTree.getFileInfo(c),b&&b.write&&!a.dataTree.isFileLocked(c)?0:-1}}},shortcutKeys:{touch:"ctrl+78"},events:{}}}),UF.registerModule("removemodule",function(){var a=this;return{defaultOptions:{},commands:{remove:{execute:function(){if(confirm(a.getLang("warning").removebefore)){var b=a.getSelection().getSelectedFiles();if(b.length){a.dataTree.lockFiles(b);var c=a.proxy.rm(b,function(d){0==d.state?(a.dataTree.removeFiles(b),a.fire("removefiles",b)):a.fire("updatemessage",{title:d.message,timeout:3e3,id:c.id}),a.dataTree.unLockFiles(b)})}}},queryState:function(){var b=a.getSelection().getSelectedFiles();if(b.length>0){for(var c in b){var d=a.dataTree.getFileInfo(b[c]);if(d&&(!d.write||a.dataTree.isFileLocked(b[c])))return-1}return 0}return-1}}},shortcutKeys:{remove:"46"},events:{}}}),UF.registerModule("renamemodule",function(){var a=this;return{defaultOptions:{},commands:{rename:{execute:function(){var b,c=a.getSelection().getSelectedFile();c&&a.fire("renameFileTitle",c,function(d,e){if(console.log("|******** rename done ********|"),b=a.getCurrentPath()+d,d&&c!=b){a.dataTree.lockFile(c);var f=a.proxy.rename(c,b,function(b){if(e&&e(0==b.state),0==b.state){var d=b&&b.data&&b.data.file;a.dataTree.updateFile(c,d),a.fire("selectfiles",d.path)}else a.fire("updatemessage",{title:b.message,timeout:3e3,id:f.id});a.dataTree.unLockFile(c)})}})},queryState:function(){var b,c;return b=a.getSelection().getSelectedFiles(),1==b.length?(c=a.dataTree.getFileInfo(b[0]),c&&c.write&&!a.dataTree.isFileLocked(b[0])?0:-1):-1}}},shortcutKeys:{rename:browser.mac?"13":"113"},events:{}}}),UF.registerModule("selectmodule",function(){var a=this;return{init:function(){},defaultOptions:{},commands:{selectall:{execute:function(){var b=a.getCurrentPath(),c=a.dataTree.listDirFileInfo(b),d=[];$.each(c,function(a,b){d.push(b.path)}),a.fire("selectfiles",d)},queryState:function(){}},selectfile:{execute:function(b){a.fire("selectfiles",b)},queryState:function(){}},selectnext:{execute:function(){},queryState:function(){}},selectprevious:{execute:function(){},queryState:function(){}}},shortcutKeys:{selectall:"ctrl+65"},events:{"list.click":function(){}}}}),UF.registerModule("uploadmodule",function(){var a=this,b=function(){var b=((+new Date).toString(36),a.webuploader=WebUploader.create({dnd:".ufui-list-container",swf:a.getOption("uploaderSwfUrl"),server:a.getOption("serverUrl")+"?cmd=upload&target="+a.getCurrentPath(),resize:!1,threads:1,fileVal:a.getOption("uploaderFileName"),formdata:{},duplicate:!1}));b.on("fileQueued",function(b){a.execCommand("upload",b)}),a.fire("initUploader")};return{init:function(){},defaultOptions:{uploaderFileName:"file",uploaderSwfUrl:a.getOption("URL")+"/lib/webuploader/Uploader.swf",uploaderJsUrl:a.getOption("URL")+"/lib/webuploader/webuploader.js"},commands:{upload:{execute:function(b){b&&(aafile=b,a.proxy.upload(a.getCurrentPath(),b,function(b){if(0==b.state){var c=b&&b.data&&b.data.file;a.dataTree.addFile(c),a.fire("selectfiles",c.path)}else a.fire("showmessage",{title:b.message,timeout:3e3})}))},queryState:function(){var b,c=a.getCurrentPath();return b=a.dataTree.getFileInfo(c),b&&b.write&&!a.dataTree.isFileLocked(c)?0:-1}}},events:{ready:function(){var c=a.$container[0].ownerDocument;Utils.loadFile(c,{src:a.getOption("uploaderJsUrl"),tag:"script",type:"text/javascript",defer:"defer"},b)},currentpathchange:function(b,c){a.webuploader&&a.webuploader.option("server",a.getOption("serverUrl")+"?cmd=upload&target="+c)}}}}),UF.registerModule("lookimagemodule",function(){var a=this;return{commands:{lookimage:{execute:function(b){a.fire("selectFiles",b),a.$toolbar.find(".ufui-btn-lookimage").trigger("click")},queryState:function(){var b=a.getSelection().getSelectedFile();return Utils.isImagePath(b)?0:-1}}}}}),UF.registerModule("lookcodemodule",function(){var a=this;return{commands:{lookcode:{execute:function(b){a.fire("selectFiles",b),a.$toolbar.find(".ufui-btn-lookcode").trigger("click")},queryState:function(){var b=a.getSelection().getSelectedFile();return Utils.isCodePath(b)?0:-1}}}}}),UF.registerModule("pathchangemodule",function(){var a=this;return{init:function(){a._pathHistory=[],a._pathHistoryIndex=0},commands:{pathparent:{execute:function(){var b=a.getCurrentPath(),c=Utils.getParentPath(b);a.setCurrentPath(c)},queryState:function(){return a.getCurrentPath().length>2?0:-1}},pathbackward:{execute:function(){a._pathHistoryIndex>0&&a.setCurrentPath(a._pathHistory[a._pathHistoryIndex--])},queryState:function(){return a._pathHistoryIndex>1?0:-1}},pathforward:{execute:function(){},queryState:function(){return a._pathHistory.length>a._pathHistoryIndex+1?0:-1}}},shortcutKeys:{pathparent:"8"},events:{currentPathChange:function(b,c){a._pathHistory.splice(a._pathHistoryIndex,a._pathHistory.length,c)}}}}),UF.registerModule("downloadmodule",function(){var a=this;return{commands:{download:{execute:function(b){a.fire("selectFiles",b);var c=a.proxy.getRequestUrl({cmd:"download",target:b}),d=$('<iframe src="'+c+'">').hide().appendTo(document.body).load(function(){setTimeout(function(){d.remove()},3e3)})},queryState:function(){var b=a.getSelection().getSelectedFile(),c=a.dataTree.getFileInfo(b);return c&&"dir"!=c.type?0:-1}}}}}),UF.registerModule("initmodule",function(){var a=this;return{init:function(){},commands:{init:{execute:function(){a.proxy.init(function(b){a.dataTree.setRoot(b.data.root)})}}},events:{ready:function(){a.execCommand("init")},dataReady:function(){a.execCommand("open","/")}}}}),UF.registerModule("editmodule",function(){var a=this;return{defaultOptions:{},commands:{copy:{execute:function(b){a.fire("copy",b)},queryState:function(){return 0}},cut:{execute:function(b){a.fire("cut",b)},queryState:function(){return 0}},paste:{execute:function(b){a.fire("paste",b)},queryState:function(){return 0}},clear:{execute:function(){a.fire("clear")},queryState:function(){return 0}},checkall:{execute:function(){a.fire("checkall")},queryState:function(){return 0}}},shortcutKeys:{copy:"ctrl+67",cut:"ctrl+88",paste:"ctrl+86",clear:"27"},events:{}}}),UF.registerModule("liststylemodule",function(){var a=this;return{commands:{toggleliststyle:{execute:function(){a.$list.find(".ufui-list-container").toggleClass("list-style")},queryState:function(){return 0}},togglepreview:{execute:function(){a.$container.toggleClass("middleview")},queryState:function(){return 0}}}}}),UF.registerModule("previewmodule",function(){var a=this,b=function(b){var c=b.data.content;a.$preview.find(".display").html(c)};return{commands:{preview:{execute:function(c){a.proxy.preview(c,b)},queryState:function(){return 0}}}}}),UF.registerModule("searchmodule",function(){var a=this,b=function(b){var c=b.data.results,d=a.$toolbar.find(".search-ul"),e=10;for(var f in c.slice(0,e)){var g=c[f].substr(0,c[f].lastIndexOf("/")+1),h=c[f].substr(c[f].lastIndexOf("/")+1),i="<li data-path='<%=dir%>' filename='<%=file%>'><div class='title'><%=title%></div><div class='path'><%=dir%></div></li>",j={title:c[f].substr(c[f].lastIndexOf("/")+1),dir:g,file:h};d.append($.parseTmpl(i,j))}};return{commands:{search:{execute:function(c){a.proxy.search(c,b)},queryState:function(){return 0}},searchindex:{execute:function(){a.fire("searchindex")},queryState:function(){return 0}}},shortcutKeys:{searchindex:"ctrl+70"}}}),function(a){function b(b,c,d){if(b.prototype=a.extend2(a.extend({},c),(UF.ui[d]||e).prototype,!0),b.prototype.supper=(UF.ui[d]||e).prototype,UF.ui[d]&&UF.ui[d].prototype.defaultOpt){var f=UF.ui[d].prototype.defaultOpt,g=b.prototype.defaultOpt;b.prototype.defaultOpt=a.extend({},f,g||{})}return b}function c(b,c){a[f+c]=b,a.fn[f+c]=function(c){var d,e=Array.prototype.slice.call(arguments,1);return this.each(function(f,g){var h=a(g),i=h.ufui();if(i||(new b(c&&a.isPlainObject(c)?c:{},h),h.ufui(i)),"string"==a.type(c))if("this"==c)d=i;else{if(d=i[c].apply(i,e),d!==i&&void 0!==d)return!1;d=null}}),null!==d?d:this}}a.parseTmpl=function(a,b){var c="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/<%=([\s\S]+?)%>/g,function(a,b){return"',"+b.replace(/\\'/g,"'")+",'"}).replace(/<%([\s\S]+?)%>/g,function(a,b){return"');"+b.replace(/\\'/g,"'").replace(/[\r\n\t]/g," ")+"__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');",d=new Function("obj",c);return b?d(b):d},a.extend2=function(b){for(var c=arguments,d="boolean"==a.type(c[c.length-1])?c[c.length-1]:!1,e="boolean"==a.type(c[c.length-1])?c.length-1:c.length,f=1;e>f;f++){var g=c[f];for(var h in g)d&&b.hasOwnProperty(h)||(b[h]=g[h])}return b},a.IE6=!!window.ActiveXObject&&6==parseFloat(navigator.userAgent.match(/msie (\d+)/i)[1]);var d=[],e=function(){},f="ufui";e.prototype={on:function(b,c){return this.root().on(b,a.proxy(c,this)),this},off:function(b,c){return this.root().off(b,a.proxy(c,this)),this},trigger:function(a,b){return this.root().trigger(a,b)===!1?!1:this},root:function(a){return this._$el||(this._$el=a)},destroy:function(){},data:function(a,b){return void 0!==b?(this.root().data(f+a,b),this):this.root().data(f+a)},register:function(b,c,e){d.push({evtname:b,$els:a.isArray(c)?c:[c],handler:a.proxy(e,c)})}},a.fn.ufui=function(a){return a?this.data("ufuiwidget",a):this.data("ufuiwidget")};var g=1;UF.ui={define:function(d,e,h){var i=UF.ui[d]=b(function(b,c){var e=function(){};a.extend(e.prototype,i.prototype,{guid:d+g++,widgetName:d});var h=new e;if("string"==a.type(b))return h.init&&h.init({}),
h.root().ufui(h),h.root().find("a").click(function(a){a.preventDefault()}),h.root()[f+d].apply(h.root(),arguments);c&&h.root(c),h.init&&h.init(!b||a.isPlainObject(b)?a.extend2(b||{},h.defaultOpt||{},!0):b);try{h.root().find("a").click(function(a){a.preventDefault()})}catch(j){}return h.root().ufui(h)},e,h);c(i,d)}},a(function(){a(document).on("click mouseup mousedown dblclick mouseover",function(b){a.each(d,function(c,d){d.evtname==b.type&&a.each(d.$els,function(c,e){e[0]===b.target||a.contains(e[0],b.target)||d.handler(b)})})})})}(jQuery),UF.ui.define("button",{tpl:'<<%if(!texttype){%>div class="ufui-btn ufui-btn-<%=icon%> <%if(name){%>ufui-btn-name-<%=name%><%}%>" unselectable="on" onmousedown="return false" <%}else{%>a class="ufui-text-btn"<%}%><% if(title) {%>title="<%=title%>" data-original-title="<%=title%>" <%};%>> <% if(icon) {%><div unselectable="on" class="ufui-icon-<%=icon%> ufui-icon"></div><% }; %><%if(text) {%><span unselectable="on" onmousedown="return false" class="ufui-button-label"><%=text%></span><%}%><%if(caret && text){%><span class="ufui-button-spacing"></span><%}%><% if(caret) {%><span unselectable="on" onmousedown="return false" class="ufui-caret"></span><% };%></<%if(!texttype){%>div<%}else{%>a<%}%>>',defaultOpt:{text:"",title:"",icon:"",width:"",caret:!1,texttype:!1,click:function(){}},init:function(a){var b=this;return b.root($($.parseTmpl(b.tpl,a))).click(function(c){b.wrapclick(a.click,c)}),b.root().hover(function(){b.root().hasClass("ufui-disabled")||b.root().toggleClass("ufui-hover")}),b},wrapclick:function(a,b){return this.disabled()?void 0:(this.root().trigger("wrapclick"),$.proxy(a,this,b)())},label:function(a){return void 0===a?this.root().find(".ufui-button-label").text():(this.root().find(".ufui-button-label").text(a),this)},disabled:function(a){return void 0===a?this.root().hasClass("ufui-disabled"):(this.root().toggleClass("ufui-disabled",a),this.root().hasClass("ufui-disabled")&&this.root().removeClass("ufui-hover"),this)},active:function(a){return void 0===a?this.root().hasClass("ufui-active"):(this.root().toggleClass("ufui-active",a),this)},mergeWith:function(a){var b=this;b.data("$mergeObj",a),a.ufui().data("$mergeObj",b.root()),$.contains(document.body,a[0])||a.appendTo(b.root()),b.on("click",function(){b.wrapclick(function(){a.ufui().show()})}).register("click",b.root(),function(){a.hide()})}}),function(){var a="combobox",b="ufui-combobox-item",c="ufui-combobox-item-hover",d="ufui-combobox-checked-icon",e="ufui-combobox-item-label";UF.ui.define(a,function(){return{tpl:'<ul class="dropdown-menu ufui-combobox-menu<%if (comboboxName!==\'\') {%> ufui-combobox-<%=comboboxName%><%}%>" unselectable="on" onmousedown="return false" role="menu" aria-labelledby="dropdownMenu"><%if(autoRecord) {%><%for( var i=0, len = recordStack.length; i<len; i++ ) {%><%var index = recordStack[i];%><li class="<%=itemClassName%><%if( selected == index ) {%> ufui-combobox-checked<%}%>" data-item-index="<%=index%>" unselectable="on" onmousedown="return false"><span class="ufui-combobox-icon" unselectable="on" onmousedown="return false"></span><label class="<%=labelClassName%>" style="<%=itemStyles[ index ]%>" unselectable="on" onmousedown="return false"><%=items[index]%></label></li><%}%><%if( i ) {%><li class="ufui-combobox-item-separator"></li><%}%><%}%><%for( var i=0, label; label = items[i]; i++ ) {%><li class="<%=itemClassName%><%if( selected == i ) {%> ufui-combobox-checked<%}%> ufui-combobox-item-<%=i%>" data-item-index="<%=i%>" unselectable="on" onmousedown="return false"><span class="ufui-combobox-icon" unselectable="on" onmousedown="return false"></span><label class="<%=labelClassName%>" style="<%=itemStyles[ i ]%>" unselectable="on" onmousedown="return false"><%=label%></label></li><%}%></ul>',defaultOpt:{recordStack:[],items:[],value:[],comboboxName:"",selected:"",autoRecord:!0,recordCount:5},init:function(a){var c=this;$.extend(c._optionAdaptation(a),c._createItemMapping(a.recordStack,a.items),{itemClassName:b,iconClass:d,labelClassName:e}),this._transStack(a),c.root($($.parseTmpl(c.tpl,a))),this.data("options",a).initEvent()},initEvent:function(){var a=this;a.initSelectItem(),this.initItemActive()},initSelectItem:function(){var a=this,c="."+e;a.root().delegate("."+b,"click",function(){var b=$(this),d=b.attr("data-item-index");return a.trigger("comboboxselect",{index:d,label:b.find(c).text(),value:a.data("options").value[d]}).select(d),a.hide(),!1})},initItemActive:function(){var a={mouseenter:"addClass",mouseleave:"removeClass"};$.IE6&&this.root().delegate("."+b,"mouseenter mouseleave",function(b){$(this)[a[b.type]](c)}).one("afterhide",function(){})},select:function(a){var b=this.data("options").itemCount,c=this.data("options").autowidthitem;return c&&!c.length&&(c=this.data("options").items),0==b?null:(0>a?a=b+a%b:a>=b&&(a=b-1),this.trigger("changebefore",c[a]),this._update(a),this.trigger("changeafter",c[a]),null)},selectItemByLabel:function(a){var b=this.data("options").itemMapping,c=this,d=null;!$.isArray(a)&&(a=[a]),$.each(a,function(a,e){return d=b[e],void 0!==d?(c.select(d),!1):void 0})},_transStack:function(a){var b=[],c=-1,d=-1;$.each(a.recordStack,function(e,f){c=a.itemMapping[f],$.isNumeric(c)&&(b.push(c),f==a.selected&&(d=c))}),a.recordStack=b,a.selected=d,b=null},_optionAdaptation:function(a){if(!("itemStyles"in a)){a.itemStyles=[];for(var b=0,c=a.items.length;c>b;b++)a.itemStyles.push("")}return a.autowidthitem=a.autowidthitem||a.items,a.itemCount=a.items.length,a},_createItemMapping:function(a,b){var c={},d={recordStack:[],mapping:{}};return $.each(b,function(a,b){c[b]=a}),d.itemMapping=c,$.each(a,function(a,b){void 0!==c[b]&&(d.recordStack.push(c[b]),d.mapping[b]=c[b])}),d},_update:function(a){var b=this.data("options"),c=[],d=null;$.each(b.recordStack,function(b,d){d!=a&&c.push(d)}),c.unshift(a),c.length>b.recordCount&&(c.length=b.recordCount),b.recordStack=c,b.selected=a,d=$($.parseTmpl(this.tpl,b)),this.root().html(d.html()),d=null,c=null}}}(),"menu")}(),UF.ui.define("modal",{tpl:'<div class="ufui-modal" tabindex="-1" ><div class="ufui-modal-header"><div class="ufui-close" data-hide="modal"></div><h3 class="ufui-title"><%=title%></h3></div><div class="ufui-modal-body" style="<%if(width){%>width:<%=width%>px;<%}%><%if(height){%>height:<%=height%>px;<%}%>"> </div><% if(cancellabel || oklabel) {%><div class="ufui-modal-footer"><div class="ufui-modal-tip"></div><%if(oklabel){%><div class="ufui-btn ufui-btn-primary" data-ok="modal"><%=oklabel%></div><%}%><%if(cancellabel){%><div class="ufui-btn" data-hide="modal"><%=cancellabel%></div><%}%></div><%}%></div>',defaultOpt:{title:"",cancellabel:"",oklabel:"",width:"",height:"",backdrop:!0,keyboard:!0},init:function(a){var b=this;b.root($($.parseTmpl(b.tpl,a||{}))),b.data("options",a),a.okFn&&b.on("ok",$.proxy(a.okFn,b)),a.cancelFn&&b.on("beforehide",$.proxy(a.cancelFn,b)),b.root().delegate('[data-hide="modal"]',"click",$.proxy(b.hide,b)).delegate('[data-ok="modal"]',"click",$.proxy(b.ok,b)),$('[data-hide="modal"],[data-ok="modal"]',b.root()).hover(function(){$(this).toggleClass("ufui-hover")})},toggle:function(){var a=this;return a[a.data("isShown")?"hide":"show"]()},show:function(){var a=this;a.trigger("beforeshow"),a.data("isShown")||(a.data("isShown",!0),a.escape(),a.backdrop(function(){a.autoCenter(),a.root().show().focus().trigger("aftershow")}))},showTip:function(a){$(".ufui-modal-tip",this.root()).html(a).fadeIn()},hideTip:function(){$(".ufui-modal-tip",this.root()).fadeOut(function(){$(this).html("")})},autoCenter:function(){$.IE6||(this.root().css("margin-left",-(this.root().width()/2)),this.root().css("margin-top",-(this.root().height()/2)))},hide:function(){var a=this;a.trigger("beforehide"),a.data("isShown")&&(a.data("isShown",!1),a.escape(),a.hideModal())},escape:function(){var a=this;a.data("isShown")&&a.data("options").keyboard?a.root().on("keyup",function(b){27==b.which&&a.hide()}):a.data("isShown")||a.root().off("keyup")},hideModal:function(){var a=this;a.root().hide(),a.backdrop(function(){a.removeBackdrop(),a.trigger("afterhide")})},removeBackdrop:function(){this.$backdrop&&this.$backdrop.remove(),this.$backdrop=null},backdrop:function(a){var b=this;b.data("isShown")&&b.data("options").backdrop&&(b.$backdrop=$('<div class="ufui-modal-backdrop" />').click("static"==b.data("options").backdrop?$.proxy(b.root()[0].focus,b.root()[0]):$.proxy(b.hide,b))),b.trigger("afterbackdrop"),a&&a()},attachTo:function(a){var b=this;a.data("$mergeObj")||(a.data("$mergeObj",b.root()),a.on("click",function(){b.toggle(a)}),b.data("$mergeObj",a))},ok:function(){var a=this;a.trigger("beforeok"),a.trigger("ok",a)!==!1&&a.hide()},getBodyContainer:function(){return this.root().find(".ufui-modal-body")}}),UF.ui.define("scale",{tpl:'<div class="ufui-scale" unselectable="on"><span class="ufui-scale-hand0"></span><span class="ufui-scale-hand1"></span><span class="ufui-scale-hand2"></span><span class="ufui-scale-hand3"></span><span class="ufui-scale-hand4"></span><span class="ufui-scale-hand5"></span><span class="ufui-scale-hand6"></span><span class="ufui-scale-hand7"></span></div>',defaultOpt:{$doc:$(document),$wrap:$(document)},init:function(a){return a.$doc&&(this.defaultOpt.$doc=a.$doc),a.$wrap&&(this.defaultOpt.$wrap=a.$wrap),this.root($($.parseTmpl(this.tpl,a))),this.initStyle(),this.startPos=this.prePos={x:0,y:0},this.dragId=-1,this},initStyle:function(){utils.cssRule("ufui-style-scale",".ufui-scale{display:none;position:absolute;border:1px solid #38B2CE;cursor:hand;}.ufui-scale span{position:absolute;left:0;top:0;width:7px;height:7px;overflow:hidden;font-size:0px;display:block;background-color:#3C9DD0;}.ufui-scale .ufui-scale-hand0{cursor:nw-resize;top:0;margin-top:-4px;left:0;margin-left:-4px;}.ufui-scale .ufui-scale-hand1{cursor:n-resize;top:0;margin-top:-4px;left:50%;margin-left:-4px;}.ufui-scale .ufui-scale-hand2{cursor:ne-resize;top:0;margin-top:-4px;left:100%;margin-left:-3px;}.ufui-scale .ufui-scale-hand3{cursor:w-resize;top:50%;margin-top:-4px;left:0;margin-left:-4px;}.ufui-scale .ufui-scale-hand4{cursor:e-resize;top:50%;margin-top:-4px;left:100%;margin-left:-3px;}.ufui-scale .ufui-scale-hand5{cursor:sw-resize;top:100%;margin-top:-3px;left:0;margin-left:-4px;}.ufui-scale .ufui-scale-hand6{cursor:s-resize;top:100%;margin-top:-3px;left:50%;margin-left:-4px;}.ufui-scale .ufui-scale-hand7{cursor:se-resize;top:100%;margin-top:-3px;left:100%;margin-left:-3px;}")},_eventHandler:function(a){var b=this,c=b.defaultOpt.$doc;switch(a.type){case"mousedown":var d=a.target||a.srcElement;-1!=d.className.indexOf("ufui-scale-hand")&&(b.dragId=d.className.slice(-1),b.startPos.x=b.prePos.x=a.clientX,b.startPos.y=b.prePos.y=a.clientY,c.bind("mousemove",$.proxy(b._eventHandler,b)));break;case"mousemove":-1!=b.dragId&&(b.updateContainerStyle(b.dragId,{x:a.clientX-b.prePos.x,y:a.clientY-b.prePos.y}),b.prePos.x=a.clientX,b.prePos.y=a.clientY,b.updateTargetElement());break;case"mouseup":if(-1!=b.dragId){b.dragId=-1,b.updateTargetElement();var e=b.data("$scaleTarget");e.parent()&&b.attachTo(b.data("$scaleTarget"))}c.unbind("mousemove",$.proxy(b._eventHandler,b))}},updateTargetElement:function(){var a=this,b=a.root(),c=a.data("$scaleTarget");c.css({width:b.width(),height:b.height()}),a.attachTo(c)},updateContainerStyle:function(a,b){var c,d=this,e=d.root(),f=[[0,0,-1,-1],[0,0,0,-1],[0,0,1,-1],[0,0,-1,0],[0,0,1,0],[0,0,-1,1],[0,0,0,1],[0,0,1,1]];0!=f[a][0]&&(c=parseInt(e.offset().left)+b.x,e.css("left",d._validScaledProp("left",c))),0!=f[a][1]&&(c=parseInt(e.offset().top)+b.y,e.css("top",d._validScaledProp("top",c))),0!=f[a][2]&&(c=e.width()+f[a][2]*b.x,e.css("width",d._validScaledProp("width",c))),0!=f[a][3]&&(c=e.height()+f[a][3]*b.y,e.css("height",d._validScaledProp("height",c)))},_validScaledProp:function(a,b){var c=this.root(),d=this.defaultOpt.$doc,e=function(a,c,d){return a+c>d?d-c:b};switch(b=isNaN(b)?0:b,a){case"left":return 0>b?0:e(b,c.width(),d.width());case"top":return 0>b?0:e(b,c.height(),d.height());case"width":return 0>=b?1:e(b,c.offset().left,d.width());case"height":return 0>=b?1:e(b,c.offset().top,d.height())}},show:function(a){var b=this;a&&b.attachTo(a),b.root().bind("mousedown",$.proxy(b._eventHandler,b)),b.defaultOpt.$doc.bind("mouseup",$.proxy(b._eventHandler,b)),b.root().show(),b.trigger("aftershow")},hide:function(){var a=this;a.root().unbind("mousedown",$.proxy(a._eventHandler,a)),a.defaultOpt.$doc.unbind("mouseup",$.proxy(a._eventHandler,a)),a.root().hide(),a.trigger("afterhide")},attachTo:function(a){var b=this,c=a.offset(),d=b.root(),e=b.defaultOpt.$wrap,f=e.offset();b.data("$scaleTarget",a),b.root().css({position:"absolute",width:a.width(),height:a.height(),left:c.left-f.left-parseInt(e.css("border-left-width"))-parseInt(d.css("border-left-width")),top:c.top-f.top-parseInt(e.css("border-top-width"))-parseInt(d.css("border-top-width"))})},getScaleTarget:function(){return this.data("$scaleTarget")[0]}}),UF.ui.define("splitbutton",{tpl:'<div class="ufui-splitbutton <%if (name){%>ufui-splitbutton-<%= name %><%}%>" unselectable="on" <%if(title){%>data-original-title="<%=title%>"<%}%>><div class="ufui-btn" unselectable="on" ><%if(icon){%><div unselectable="on" class="ufui-icon-<%=icon%> ufui-icon"></div><%}%><%if(text){%><%=text%><%}%></div><div unselectable="on" class="ufui-btn ufui-dropdown-toggle" ><div unselectable="on" class="ufui-caret"></div></div></div>',defaultOpt:{text:"",title:"",click:function(){}},init:function(a){var b=this;return b.root($($.parseTmpl(b.tpl,a))),b.root().find(".ufui-btn:first").click(function(){b.disabled()||$.proxy(a.click,b)()}),b.root().find(".ufui-dropdown-toggle").click(function(){b.disabled()||b.trigger("arrowclick")}),b.root().hover(function(){b.root().hasClass("ufui-disabled")||b.root().toggleClass("ufui-hover")}),b},wrapclick:function(a,b){return this.disabled()||$.proxy(a,this,b)(),this},disabled:function(a){return void 0===a?this.root().hasClass("ufui-disabled"):(this.root().toggleClass("ufui-disabled",a).find(".ufui-btn").toggleClass("ufui-disabled",a),this)},active:function(a){return void 0===a?this.root().hasClass("ufui-active"):(this.root().toggleClass("ufui-active",a).find(".ufui-btn:first").toggleClass("ufui-active",a),this)},mergeWith:function(a){var b=this;b.data("$mergeObj",a),a.ufui().data("$mergeObj",b.root()),$.contains(document.body,a[0])||a.appendTo(b.root()),b.root().delegate(".ufui-dropdown-toggle","click",function(){b.wrapclick(function(){a.ufui().show()})}),b.register("click",b.root().find(".ufui-dropdown-toggle"),function(){a.hide()})}}),UF.ui.define("tooltip",{tpl:'<div class="ufui-tooltip" unselectable="on" onmousedown="return false"><div class="ufui-tooltip-arrow" unselectable="on" onmousedown="return false"></div><div class="ufui-tooltip-inner" unselectable="on" onmousedown="return false"></div></div>',init:function(a){var b=this;b.root($($.parseTmpl(b.tpl,a||{})))},content:function(a){var b=this,c=$(a.currentTarget).attr("data-original-title");b.root().find(".ufui-tooltip-inner").text(c)},position:function(a){var b=this,c=$(a.currentTarget);b.root().css($.extend({display:"block"},c?{top:c.outerHeight(),left:(c.outerWidth()-b.root().outerWidth())/2}:{}))},show:function(a){if(!$(a.currentTarget).hasClass("ufui-disabled")){var b=this;b.content(a),b.root().appendTo($(a.currentTarget)),b.position(a),b.root().css("display","block")}},hide:function(){var a=this;a.root().css("display","none")},attachTo:function(a){function b(a){var b=this;$.contains(document.body,b.root()[0])||b.root().appendTo(a),b.data("tooltip",b.root()),a.each(function(){$(this).attr("data-original-title")&&$(this).on("mouseenter",$.proxy(b.show,b)).on("mouseleave click",$.proxy(b.hide,b))})}var c=this;"undefined"===$.type(a)?$("[data-original-title]").each(function(a,d){b.call(c,$(d))}):a.data("tooltip")||b.call(c,a)}}),function(){var a="buttoncombobox";UF.ui.define(a,function(){return{defaultOpt:{label:"",title:""},init:function(a){var b=this,c=$.ufuibutton({caret:!0,name:a.comboboxName,title:a.title,text:a.label,click:function(){b.show(this.root())}});b.supper.init.call(b,a),b.on("changebefore",function(a,b){c.ufuibutton("label",b)}),b.data("button",c),b.attachTo(c)},button:function(){return this.data("button")}}}(),"combobox")}(),UF.ui.define("dropmenu",{tmpl:'<ul class="ufui-dropdown-menu" aria-labelledby="dropdownMenu" ><%for(var i=0,ci;ci=data[i++];){%><%if(ci.divider){%><li class="ufui-divider"></li><%}else{%><li <%if(ci.active||ci.disabled){%>class="<%= ci.active|| \'\' %> <%=ci.disabled||\'\' %>" <%}%> data-value="<%= ci.value%>"><a href="#" tabindex="-1"><em class="ufui-dropmenu-checkbox"><i class="ufui-icon-ok"></i></em><%= ci.label%></a></li><%}%><%}%></ul>',defaultOpt:{data:[],click:function(){}},init:function(a){var b=this,c={click:1,mouseover:1,mouseout:1};this.root($($.parseTmpl(this.tmpl,a))).on("click",'li[class!="ufui-disabled ufui-divider ufui-dropdown-submenu"]',function(c){$.proxy(a.click,b,c,$(this).data("value"),$(this))()}).find("li").each(function(d,e){var f=$(this);if(!f.hasClass("ufui-disabled ufui-divider ufui-dropdown-submenu")){var g=a.data[d];$.each(c,function(a){g[a]&&f[a](function(c){$.proxy(g[a],e)(c,g,b.root)})})}})},disabled:function(a){$("li[class!=ufui-divider]",this.root()).each(function(){var b=$(this);a===!0?b.addClass("ufui-disabled"):$.isFunction(a)?b.toggleClass("ufui-disabled",a(li)):b.removeClass("ufui-disabled")})},val:function(a){var b;return $('li[class!="ufui-divider ufui-disabled ufui-dropdown-submenu"]',this.root()).each(function(){var c=$(this);if(void 0===a){if(c.find("em.ufui-dropmenu-checked").length)return b=c.data("value"),!1}else c.find("em").toggleClass("ufui-dropmenu-checked",c.data("value")==a)}),void 0===a?b:void 0},addSubmenu:function(a,b,c){c=c||0;var d=$("li[class!=ufui-divider]",this.root()),e=$('<li class="ufui-dropdown-submenu"><a tabindex="-1" href="#">'+a+"</a></li>").append(b);c>=0&&c<d.length?e.insertBefore(d[c]):0>c?e.insertBefore(d[0]):c>=d.length&&e.appendTo(d)}},"menu"),UF.ui.define("menu",{show:function(a,b,c,d,e){c=c||"position",this.trigger("beforeshow")!==!1&&(this.root().css($.extend({display:"block"},a?{top:a[c]().top+("right"==b?0:a.outerHeight())-(d||0),left:a[c]().left+("right"==b?a.outerWidth():0)-(e||0)}:{})),this.trigger("aftershow"))},hide:function(a){var b;this.trigger("beforehide")!==!1&&((b=this.root().data("parentmenu"))&&(b.data("parentmenu")||a)&&b.ufui().hide(),this.root().css("display","none"),this.trigger("afterhide"))},attachTo:function(a){var b=this;a.data("$mergeObj")||(a.data("$mergeObj",b.root()),a.on("wrapclick",function(){b.show()}),b.register("click",a,function(){b.hide()}),b.data("$mergeObj",a))}}),UF.ui.define("popup",{tpl:'<div class="ufui-dropdown-menu ufui-popup"<%if(!<%=stopprop%>){%>onmousedown="return false"<%}%>><div class="ufui-popup-body" unselectable="on" onmousedown="return false"><%=subtpl%></div><div class="ufui-popup-caret"></div></div>',defaultOpt:{stopprop:!1,subtpl:"",width:"",height:""},init:function(a){return this.root($($.parseTmpl(this.tpl,a))),this},mergeTpl:function(a){return $.parseTmpl(this.tpl,{subtpl:a})},show:function(a,b){b||(b={});var c=b.fnname||"position";this.trigger("beforeshow")!==!1&&(this.root().css($.extend({display:"block"},a?{top:a[c]().top+("right"==b.dir?0:a.outerHeight())-(b.offsetTop||0),left:a[c]().left+("right"==b.dir?a.outerWidth():0)-(b.offsetLeft||0),position:"absolute"}:{})),this.root().find(".ufui-popup-caret").css({top:b.caretTop||0,left:b.caretLeft||0,position:"absolute"}).addClass(b.caretDir||"up"),this.trigger("aftershow"))},hide:function(){this.root().css("display","none"),this.trigger("afterhide")},attachTo:function(a,b){var c=this;a.data("$mergeObj")||(a.data("$mergeObj",c.root()),a.on("wrapclick",function(){c.show(a,b)}),c.register("click",a,function(){c.hide()}),c.data("$mergeObj",a))},getBodyContainer:function(){return this.root().find(".ufui-popup-body")}}),UF.ui.define("separator",{tpl:'<div class="ufui-separator" unselectable="on" onmousedown="return false" ></div>',init:function(a){var b=this;return b.root($($.parseTmpl(b.tpl,a))),b}}),function(){UF.ui.define("toolbar",{tpl:'<div class="ufui-toolbar" ><div class="ufui-btn-toolbar"></div></div>',init:function(){var a=this,b=$(a.tpl),c=this.root(b);this.data("$btnToolbar",c.find(".ufui-btn-toolbar"))},appendToBtnmenu:function(a){var b=this.data("$btnToolbar");a=$.isArray(a)?a:[a],$.each(a,function(a,c){b.append(c)})}})}(),UF.ui.define("file",{tpl:'<a draggable="true" filetype="<%=type%>" title="<%=title%>" dataurl="file/<%=type%>:<%=title%>:<%=link%>" class="ufui-file ufui-file-<%=pers%>" data-path="<%=path%>"><div class="ufui-file-icon" > <i class="ufui-file-icon-<%=type%>"></i> <span class="ufui-file-pers"></span></div><div class="ufui-file-title"><%=title%></div><div class="ufui-file-details"><%=details%></div></a>',defaultOpt:{type:"",title:"",path:"",details:"",pers:"wr",link:""},init:function(a){var b=this,c=$($.parseTmpl(b.tpl,a));return b.root(c),b.root().find(".ufui-file-title").on("focus blur",function(){}),b},editabled:function(a,b){var c=this,d=this.root().find(".ufui-file-title");if(void 0===a)return d.attr("contenteditable");if(a){if(c.renameFlag)return this;var e=!1,f=function(a){return b(d.text()),d.focus().off("blur keydown",g),c.editabled(!1),c.renameFlag=!1,a.preventDefault(),!1},g=function(a){if(console.log("---",a.type,a.keyCode),"blur"==a.type&&!e)return f(a);if("keydown"==a.type){if(46==a.keyCode);else if(27==a.keyCode)e=!0;else if(13==a.keyCode)return f(a)}else if("click"==a.type)return"false"==$(a.target).attr("contenteditable")?!0:(a.preventDefault(),!1)};d.addClass("ufui-file-title-editable").attr("contenteditable","true"),console.log("enter edit"),c.renameFlag=!0,setTimeout(function(){d.focus(),setTimeout(function(){d.on("keydown click blur",g)},100)},100)}else d.removeClass("ufui-file-title-editable").attr("contenteditable","false"),console.log("leave edit"),c.renameFlag=!1;return this},disabled:function(a){return void 0===a?this.root().hasClass("ufui-disabled"):(this.root().toggleClass("ufui-disabled",a),this.root().hasClass("ufui-disabled")&&this.root().removeClass("ufui-hover"),this)},active:function(a){return void 0===a?this.root().hasClass("ufui-active"):(this.root().toggleClass("ufui-active",a),this)},setTitle:function(a){return this.root().find(".ufui-file-title").text(a),this},getTitle:function(){return this.root().find(".ufui-file-title").text()},setType:function(a){return this.root().find(".ufui-file-icon i").attr("class","ufui-file-icon-"+a).attr("style",""),this},getType:function(){var a=this.root().find(".ufui-file-icon i"),b=a.attr("class").match(/ufui-file-icon-([\w]+)(\s|$)/);return b?b[1]:null},setPath:function(a){return this.root().attr("data-path",a),this},getPath:function(){return this.root().attr("data-path")},setPers:function(a){return this.root().addClass("ufui-file-"+(a?"w":"nw")+"r"),this},getPers:function(){var a=this.root(),b=a.hasClass("ufui-file-w-r")||a.hasClass("ufui-file-nw-r"),c=a.hasClass("ufui-file-w-r")||a.hasClass("ufui-file-w-nr");return{write:b,read:c}},setPreviewImg:function(a){var b=this;$('<img src="'+a+'" style="display:none;">').appendTo(document.body).on("load",function(){var c=$(this);b.root().find(".ufui-file-icon i").css({"background-image":'url("'+a+'")',"background-size":c.width()>c.height()?"auto 100%":"100% auto","background-position":"center center","background-repeat":"no-repeat no-repeat","border-radius":"3px",width:"60px",height:"60px",margin:"10px auto 0 auto"}),c.remove()})}}),UF.ui.define("list",{tpl:'<div class="ufui-list"><div class="ufui-list-container"></div><div class="ufui-select-box" style="display:none;"></div></div>',defaultOpt:{sort:"title"},init:function(a){var b=this;return b.root($($.parseTmpl(b.tpl,a))).append(b.$list),b.$list=b.root().find(".ufui-list-container"),b._ufItems=[],b},_compare:function(a,b){var c=a.getType(),d=b.getType(),e=a.getTitle(),f=b.getTitle();return"dir"==c&&"dir"!=d?0:"dir"!=c&&"dir"==d?1:c!=d?c>d:e>f},getItem:function(a){for(var b=0;b<this._ufItems.length;b++)if(this._ufItems[b].getPath()==a)return this._ufItems[b];return null},getItems:function(){return this._ufItems},addItem:function(a){var b,c=$.ufuifile(a),d=c.ufui();for(b=0;b<this._ufItems.length;b++){var e=this._ufItems[b];if(this._compare(e,d))break}return b>=this._ufItems.length?this.$list.append(c):c.insertBefore(this._ufItems[b].root()),this._ufItems.splice(b,0,d),this},removeItem:function(a,b){for(var c=0;c<this._ufItems.length;c++){var d=this._ufItems[c];if(d.getPath()==a){this._ufItems.splice(c,1),b?d.active(!1).root().fadeOut(b||0,function(){$(this).remove()}):d.root().remove();break}}return this},clearItems:function(){return $.each(this._ufItems,function(a,b){b.root().remove()}),this._ufItems=[],this},isItemInList:function(a){return this.getItem(a)?!0:!1}}),UF.ui.define("leaf",{tpl:'<li class="ufui-leaf" data-path="<%=path%>"> <div class="ufui-leaf-detail ufui-leaf-detail-closed"> <div class="ufui-leaf-expand"></div> <div class="ufui-leaf-folder"><i class="ufui-leaf-folder-<%=type%>"></i></div> <div class="ufui-leaf-title"><%=title%></div> </div> <ul class="ufui-tree-branch ufui-tree-branch-closed"></ul></li>',defaultOpt:{type:"dir",title:"",path:"/",pers:"wr"},init:function(a){var b=this;a.path=Utils.regularDirPath(a.path),b.root($($.parseTmpl(b.tpl,a)));var c=b.$detail=b.root().children().eq(0);return b.$branch=b.root().children().eq(1),c.find(".ufui-leaf-expand").on("click",function(){b.expand(c.hasClass("ufui-leaf-detail-opened")?!1:!0)}),b},disabled:function(a){return void 0===a?this.root().hasClass("ufui-disabled"):(this.root().toggleClass("ufui-disabled",a),this.root().hasClass("ufui-disabled")&&this.root().removeClass("ufui-hover"),this)},active:function(a){return void 0===a?this.root().hasClass("ufui-active"):(this.root().toggleClass("ufui-active",a),this)},expand:function(a){a?(this.$detail.removeClass("ufui-leaf-detail-closed").addClass("ufui-leaf-detail-opened"),this.$branch.removeClass("ufui-tree-branch-closed").addClass("ufui-tree-branch-opened")):(this.$detail.removeClass("ufui-leaf-detail-opened").addClass("ufui-leaf-detail-closed"),this.$branch.removeClass("ufui-tree-branch-opened").addClass("ufui-tree-branch-closed"))},_compare:function(a,b){var c=a.getType(),d=b.getType(),e=a.getTitle(),f=b.getTitle();return"dir"==c&&"dir"!=d?0:"dir"!=c&&"dir"==d?1:e>f},setPath:function(a){return this.root().attr("data-path",Utils.regularDirPath(a)),this},getPath:function(){return this.root().attr("data-path")},setType:function(a){return this.$detail.find(".ufui-leaf-folder i").attr("class","ufui-leaf-folder-"+a),this},getType:function(){var a=this.$detail.find(".ufui-leaf-folder i"),b=a.attr("class").match(/ufui-leaf-folder-([\w]+)(\s|$)/);return b?b[1]:null},setTitle:function(a){return this.$detail.find(".ufui-leaf-title").text(a),this},getTitle:function(){return this.$detail.find(".ufui-leaf-title").text()},addChild:function(a){for(var b=this.$branch.children(),c=0;c<b.length&&!this._compare($(b[c]).ufui(),a);c++);return 0==c?this.$branch.prepend(a.root()):$(b[c-1]).after(a.root()),this.expand(!0),this},removeChild:function(a){return a.remove(),this},getChildren:function(){return this.$branch.children()}}),UF.ui.define("tree",{tpl:'<div class="ufui-tree" ><ul class="ufui-tree-branch ufui-tree-branch-root"></ul></div>',defaultOpt:{},init:function(a){var b=this;return b.root($($.parseTmpl(b.tpl,a))),b.$branch=b.root().find(".ufui-tree-branch"),b._ufItems={},b},disabled:function(a){return void 0===a?this.root().hasClass("ufui-disabled"):(this.root().toggleClass("ufui-disabled",a),this.root().hasClass("ufui-disabled")&&this.root().removeClass("ufui-hover"),this)},active:function(a){return void 0===a?this.root().hasClass("ufui-active"):(this.root().toggleClass("ufui-active",a),this)},_compare:function(a,b){var c=a.getType(),d=b.getType(),e=a.getTitle(),f=b.getTitle();return"dir"==c&&"dir"!=d?0:"dir"!=c&&"dir"==d?1:e>f},getItem:function(a){return this._ufItems[Utils.regularDirPath(a)]},getItems:function(){return this._ufItems},addItem:function(a){var b=a.path,c=$.ufuileaf(a),d=c.ufui(),e=this.getItem(Utils.getParentPath(b));return this._ufItems[b]||(e?e.addChild(d):this.$branch.append(c),this._ufItems[b]=d),this},setRoot:function(a){a.name="Root";var b=$.ufuileaf(a),c=b.ufui();return this.$branch.append(b),this._ufItems[a.path]=c,b.addClass("ufui-tree-leaf-root"),this},removeItem:function(a){var b=this;return a=Utils.regularDirPath(a),b._ufItems[a]&&(b._ufItems[a].root().remove(),delete b._ufItems[a]),this},clearItems:function(){return $.each(this._ufItems,function(a,b){b.root().remove()}),this._ufItems=[],this},isItemInTree:function(a){return this.getItem(a)?!0:!1}}),UF.ui.define("panel",{tpl:'<div class="ufui-panel" ></div>',defaultOpt:{},init:function(a){var b=this;return b.root($($.parseTmpl(b.tpl,a))),b}}),UF.ui.define("message",{tpl:'<div class="ufui-message"> <div class="ufui-message-head"><div class="ufui-message-close"></div></div> <div class="ufui-message-body"> <div class="ufui-message-icon"><i class="ufui-message-icon-<%=icon%>"></i></div> <div class="ufui-message-info"> <div class="ufui-message-title"><%=title%></div> <div class="ufui-message-loadbar"><div class="ufui-message-loadbar-percent"></div></div> </div> </div></div>',defaultOpt:{icon:"",title:""},init:function(a){var b=this;return b.root($($.parseTmpl(b.tpl,a))),b.root().hide(),b.$title=b.root().find(".ufui-message-title"),b.$loadbar=b.root().find(".ufui-message-loadbar"),b.loadedPercent=a.loadedPercent||0,b.setLoadedPercent(b.loadedPercent),b.root().find(".ufui-message-close").on("click",function(){b.hide()}),void 0!==a.timeout&&a.timeout>=0&&(b.timer=setTimeout(function(){b.hide()},a.timeout)),b},show:function(){return this.root().fadeIn(400)},hide:function(){return this.root().fadeOut(400)},setIcon:function(a){return this.root().find(".ufui-message-icon i").attr("class","ufui-message-icon-"+a),this},getIcon:function(){var a=this.root().find(".ufui-message-icon i"),b=a.attr("class").match(/ufui-message-icon-([\w]+)(\s|$)/);return b?b[1]:null},setMessage:function(a){return this.$title.text(a),this},getMessage:function(){return this.$title.text()},setLoadedPercent:function(a){return this.root().find(".ufui-message-loadbar-percent").css("width",a+"%"),this},getLoadedPercent:function(){return this.root().find(".ufui-message-loadbar-percent").css("width")},setTimer:function(a){var b=this;return void 0!==a&&clearTimeout(b.timer),a>=0&&(b.timer=setTimeout(function(){b.hide()},a)),this},getTimer:function(){return this.timer}}),UF.ui.define("button",{tpl:'<<%if(!texttype){%>div class="ufui-btn ufui-btn-<%=icon%> <%if(name){%>ufui-btn-name-<%=name%><%}%>" unselectable="on" onmousedown="return false" <%}else{%>a class="ufui-text-btn"<%}%><% if(title) {%>title="<%=title%>" data-original-title="<%=title%>" <%};%>> <% if(icon) {%><div unselectable="on" class="ufui-icon-<%=icon%> ufui-icon"></div><% }; %><%if(text) {%><span unselectable="on" onmousedown="return false" class="ufui-button-label"><%=text%></span><%}%><%if(caret && text){%><span class="ufui-button-spacing"></span><%}%><% if(caret) {%><span unselectable="on" onmousedown="return false" class="ufui-caret"></span><% };%></<%if(!texttype){%>div<%}else{%>a<%}%>>',defaultOpt:{text:"",title:"",icon:"",width:"",caret:!1,texttype:!1,click:function(){}},init:function(a){var b=this;return b.root($($.parseTmpl(b.tpl,a))).click(function(c){b.wrapclick(a.click,c)}),b.root().hover(function(){b.root().hasClass("ufui-disabled")||b.root().toggleClass("ufui-hover")}),b},wrapclick:function(a,b){return this.disabled()||(this.root().trigger("wrapclick"),$.proxy(a,this,b)()),this},label:function(a){return void 0===a?this.root().find(".ufui-button-label").text():(this.root().find(".ufui-button-label").text(a),this)},disabled:function(a){return void 0===a?this.root().hasClass("ufui-disabled"):(this.root().toggleClass("ufui-disabled",a),
this.root().hasClass("ufui-disabled")&&this.root().removeClass("ufui-hover"),this)},active:function(a){return void 0===a?this.root().hasClass("ufui-active"):(this.root().toggleClass("ufui-active",a),this)},mergeWith:function(a){var b=this;b.data("$mergeObj",a),a.ufui().data("$mergeObj",b.root()),$.contains(document.body,a[0])||a.appendTo(b.root()),b.on("click",function(){b.wrapclick(function(){a.ufui().show()})}).register("click",b.root(),function(){a.hide()})}}),UF.ui.define("preview",{tpl:'<div class="ufui-preview"><div class="ufui-preview-container"><center style="margin-tops:50%;"><div class="display"><div style="margin-top:140px"><b>暂无预览</b></div></div></center></div></div>',defaultOpt:{sort:"title"},init:function(a){var b=this;return b.root($($.parseTmpl(b.tpl,a))),b},_compare:function(a,b){var c=a.getType(),d=b.getType(),e=a.getTitle(),f=b.getTitle();return"dir"==c&&"dir"!=d?0:"dir"!=c&&"dir"==d?1:c!=d?c>d:e>f},getItem:function(a){for(var b=0;b<this._ufItems.length;b++)if(this._ufItems[b].getPath()==a)return this._ufItems[b];return null},getItems:function(){return this._ufItems},addItem:function(a){var b,c=$.ufuifile(a),d=c.ufui();for(b=0;b<this._ufItems.length;b++){var e=this._ufItems[b];if(this._compare(e,d))break}return b>=this._ufItems.length?this.$list.append(c):c.insertBefore(this._ufItems[b].root()),this._ufItems.splice(b,0,d),this},removeItem:function(a,b){for(var c=0;c<this._ufItems.length;c++){var d=this._ufItems[c];if(d.getPath()==a){this._ufItems.splice(c,1),b?d.active(!1).root().fadeOut(b||0,function(){$(this).remove()}):d.root().remove();break}}return this},clearItems:function(){return $.each(this._ufItems,function(a,b){b.root().remove()}),this._ufItems=[],this},isItemInList:function(a){return this.getItem(a)?!0:!1}}),UF.ui.define("clipboard",{tpl:'<div class="ufui-clipboard"><div class="clipboard-clear"></div><div class="ufui-clipboard-container"></div></div>',defaultOpt:{sort:"title"},init:function(a){var b=this;return b.root($($.parseTmpl(b.tpl,a))).append(b.$list),b.$list=b.root().find(".ufui-list-container"),b.isCopy=!0,b._cacheFiles=[],b._ufItems=[],b},_generateFileOptionsFromPath:function(a){return{type:"/"==a.charAt(a.length-1)?"dir":a.substr(a.lastIndexOf(".")+1),title:"/"==a.charAt(a.length-1)?a.substring(a.lastIndexOf("/",a.length-2)+1,a.length-1):a.substr(a.lastIndexOf("/")+1),details:"",path:a,pers:"wr"}},_autoShow:function(){var a=this,b=a.root();0==a._cacheFiles.length?b.removeClass("filled"):b.addClass("filled")},setIsCopy:function(a){var b=this;this.isCopy!=a&&(b.clear(),this.isCopy=a),b.root().toggleClass("copy",this.isCopy)},getIsCopy:function(){return this.isCopy},addFiles:function(a){var b=this,c=b.root().find(".ufui-clipboard-container");$.each(a,function(a,d){if(-1==b._cacheFiles.indexOf(d)){b._cacheFiles=b._cacheFiles.concat(d);var e=$.ufuifile(b._generateFileOptionsFromPath(d));c.append(e)}}),b._autoShow()},paste:function(){return},getPasteTarget:function(a){return res=[a].concat(this._cacheFiles),res},clear:function(){var a=this,b=a.root().find(".ufui-clipboard-container");this._cacheFiles=[],b.empty(),a._autoShow()},_compare:function(a,b){var c=a.getType(),d=b.getType(),e=a.getTitle(),f=b.getTitle();return"dir"==c&&"dir"!=d?0:"dir"!=c&&"dir"==d?1:c!=d?c>d:e>f},getItem:function(a){for(var b=0;b<this._ufItems.length;b++)if(this._ufItems[b].getPath()==a)return this._ufItems[b];return null},getItems:function(){return this._ufItems},addItem:function(a){var b,c=$.ufuifile(a),d=c.ufui();for(b=0;b<this._ufItems.length;b++){var e=this._ufItems[b];if(this._compare(e,d))break}return b>=this._ufItems.length?this.$list.append(c):c.insertBefore(this._ufItems[b].root()),this._ufItems.splice(b,0,d),this},removeItem:function(a,b){for(var c=0;c<this._ufItems.length;c++){var d=this._ufItems[c];if(d.getPath()==a){this._ufItems.splice(c,1),b?d.active(!1).root().fadeOut(b||0,function(){$(this).remove()}):d.root().remove();break}}return this},clearItems:function(){return $.each(this._ufItems,function(a,b){b.root().remove()}),this._ufItems=[],this},isItemInList:function(a){return this.getItem(a)?!0:!1}}),function(){UF.ui.define("searchbox",{tpl:'<div class="searchbox blur" ><div class="ufui-icon-search"/><input style="float:right;" placeholder="<%=placeholder%>" type="text"/><ul class="search-ul"></ul></div>',init:function(a){{var b=this,c=$($.parseTmpl(b.tpl,{placeholder:a.placeholder}));this.root(c)}}})}(),function(a,b){function c(a){for(var b,c=a.split(/\s+/),d=[],e=0;b=c[e];e++)b=b[0].toUpperCase(),d.push(b);return d}function d(b){return b.id&&a('label[for="'+b.id+'"]').val()||b.name}function e(c,f,g){return g||(g=0),f.each(function(){var f,h,i=a(this),j=this,k=this.nodeName.toLowerCase();switch("label"==k&&i.find("input, textarea, select").length&&(f=i.text(),i=i.children().first(),j=i.get(0),k=j.nodeName.toLowerCase()),k){case"menu":h={name:i.attr("label"),items:{}},g=e(h.items,i.children(),g);break;case"a":case"button":h={name:i.text(),disabled:!!i.attr("disabled"),callback:function(){return function(){i.click()}}()};break;case"menuitem":case"command":switch(i.attr("type")){case b:case"command":case"menuitem":h={name:i.attr("label"),disabled:!!i.attr("disabled"),callback:function(){return function(){i.click()}}()};break;case"checkbox":h={type:"checkbox",disabled:!!i.attr("disabled"),name:i.attr("label"),selected:!!i.attr("checked")};break;case"radio":h={type:"radio",disabled:!!i.attr("disabled"),name:i.attr("label"),radio:i.attr("radiogroup"),value:i.attr("id"),selected:!!i.attr("checked")};break;default:h=b}break;case"hr":h="-------";break;case"input":switch(i.attr("type")){case"text":h={type:"text",name:f||d(j),disabled:!!i.attr("disabled"),value:i.val()};break;case"checkbox":h={type:"checkbox",name:f||d(j),disabled:!!i.attr("disabled"),selected:!!i.attr("checked")};break;case"radio":h={type:"radio",name:f||d(j),disabled:!!i.attr("disabled"),radio:!!i.attr("name"),value:i.val(),selected:!!i.attr("checked")};break;default:h=b}break;case"select":h={type:"select",name:f||d(j),disabled:!!i.attr("disabled"),selected:i.val(),options:{}},i.children().each(function(){h.options[this.value]=a(this).text()});break;case"textarea":h={type:"textarea",name:f||d(j),disabled:!!i.attr("disabled"),value:i.val()};break;case"label":break;default:h={type:"html",html:i.clone(!0)}}h&&(g++,c["key"+g]=h)}),g}if(a.support.htmlMenuitem="HTMLMenuItemElement"in window,a.support.htmlCommand="HTMLCommandElement"in window,a.support.eventSelectstart="onselectstart"in document.documentElement,!a.ui||!a.ui.widget){var f=a.cleanData;a.cleanData=function(b){for(var c,d=0;null!=(c=b[d]);d++)try{a(c).triggerHandler("remove")}catch(e){}f(b)}}var g=null,h=!1,i=a(window),j=0,k={},l={},m={},n={selector:null,appendTo:null,trigger:"right",autoHide:!1,delay:200,reposition:!0,determinePosition:function(b){if(a.ui&&a.ui.position)b.css("display","block").position({my:"center top",at:"center bottom",of:this,offset:"0 5",collision:"fit"}).css("display","none");else{var c=this.offset();c.top+=this.outerHeight(),c.left+=this.outerWidth()/2-b.outerWidth()/2,b.css(c)}},position:function(a,b,c){var d;if(!b&&!c)return void a.determinePosition.call(this,a.$menu);d="maintain"===b&&"maintain"===c?a.$menu.position():{top:c,left:b};var e=i.scrollTop()+i.height(),f=i.scrollLeft()+i.width(),g=a.$menu.height(),h=a.$menu.width();d.top+g>e&&(d.top-=g),d.left+h>f&&(d.left-=h),a.$menu.css(d)},positionSubmenu:function(b){if(a.ui&&a.ui.position)b.css("display","block").position({my:"left top",at:"right top",of:this,collision:"flipfit fit"}).css("display","");else{var c={top:0,left:this.outerWidth()};b.css(c)}},zIndex:1,animation:{duration:50,show:"slideDown",hide:"slideUp"},events:{show:a.noop,hide:a.noop},callback:null,items:{}},o={timer:null,pageX:null,pageY:null},p=function(a){for(var b=0,c=a;;)if(b=Math.max(b,parseInt(c.css("z-index"),10)||0),c=c.parent(),!c||!c.length||"html body".indexOf(c.prop("nodeName").toLowerCase())>-1)break;return b},q={abortevent:function(a){a.preventDefault(),a.stopImmediatePropagation()},contextmenu:function(b){var c=a(this);if(b.preventDefault(),b.stopImmediatePropagation(),!("right"!=b.data.trigger&&b.originalEvent||c.hasClass("context-menu-active")||c.hasClass("context-menu-disabled"))){if(g=c,b.data.build){var d=b.data.build(g,b);if(d===!1)return;if(b.data=a.extend(!0,{},n,b.data,d||{}),!b.data.items||a.isEmptyObject(b.data.items))throw window.console&&(console.error||console.log)("No items specified to show in contextMenu"),new Error("No Items specified");b.data.$trigger=g,r.create(b.data)}r.show.call(c,b.data,b.pageX,b.pageY)}},click:function(b){b.preventDefault(),b.stopImmediatePropagation(),a(this).trigger(a.Event("contextmenu",{data:b.data,pageX:b.pageX,pageY:b.pageY}))},mousedown:function(b){var c=a(this);g&&g.length&&!g.is(c)&&g.data("contextMenu").$menu.trigger("contextmenu:hide"),2==b.button&&(g=c.data("contextMenuActive",!0))},mouseup:function(b){var c=a(this);c.data("contextMenuActive")&&g&&g.length&&g.is(c)&&!c.hasClass("context-menu-disabled")&&(b.preventDefault(),b.stopImmediatePropagation(),g=c,c.trigger(a.Event("contextmenu",{data:b.data,pageX:b.pageX,pageY:b.pageY}))),c.removeData("contextMenuActive")},mouseenter:function(b){var c=a(this),d=a(b.relatedTarget),e=a(document);d.is(".context-menu-list")||d.closest(".context-menu-list").length||g&&g.length||(o.pageX=b.pageX,o.pageY=b.pageY,o.data=b.data,e.on("mousemove.contextMenuShow",q.mousemove),o.timer=setTimeout(function(){o.timer=null,e.off("mousemove.contextMenuShow"),g=c,c.trigger(a.Event("contextmenu",{data:o.data,pageX:o.pageX,pageY:o.pageY}))},b.data.delay))},mousemove:function(a){o.pageX=a.pageX,o.pageY=a.pageY},mouseleave:function(b){var c=a(b.relatedTarget);if(!c.is(".context-menu-list")&&!c.closest(".context-menu-list").length){try{clearTimeout(o.timer)}catch(b){}o.timer=null}},layerClick:function(b){var c,d,e=a(this),f=e.data("contextMenuRoot"),g=b.button,h=b.pageX,j=b.pageY;b.preventDefault(),b.stopImmediatePropagation(),setTimeout(function(){var e,k="left"==f.trigger&&0===g||"right"==f.trigger&&2===g;if(document.elementFromPoint&&(f.$layer.hide(),c=document.elementFromPoint(h-i.scrollLeft(),j-i.scrollTop()),f.$layer.show()),f.reposition&&k)if(document.elementFromPoint){if(f.$trigger.is(c)||f.$trigger.has(c).length)return void f.position.call(f.$trigger,f,h,j)}else if(d=f.$trigger.offset(),e=a(window),d.top+=e.scrollTop(),d.top<=b.pageY&&(d.left+=e.scrollLeft(),d.left<=b.pageX&&(d.bottom=d.top+f.$trigger.outerHeight(),d.bottom>=b.pageY&&(d.right=d.left+f.$trigger.outerWidth(),d.right>=b.pageX))))return void f.position.call(f.$trigger,f,h,j);c&&k&&f.$trigger.one("contextmenu:hidden",function(){a(c).contextMenu({x:h,y:j})}),f.$menu.trigger("contextmenu:hide")},50)},keyStop:function(a,b){b.isInput||a.preventDefault(),a.stopPropagation()},key:function(a){var b=g.data("contextMenu")||{};switch(a.keyCode){case 9:case 38:if(q.keyStop(a,b),b.isInput){if(9==a.keyCode&&a.shiftKey)return a.preventDefault(),b.$selected&&b.$selected.find("input, textarea, select").blur(),void b.$menu.trigger("prevcommand");if(38==a.keyCode&&"checkbox"==b.$selected.find("input, textarea, select").prop("type"))return void a.preventDefault()}else if(9!=a.keyCode||a.shiftKey)return void b.$menu.trigger("prevcommand");case 40:if(q.keyStop(a,b),!b.isInput)return void b.$menu.trigger("nextcommand");if(9==a.keyCode)return a.preventDefault(),b.$selected&&b.$selected.find("input, textarea, select").blur(),void b.$menu.trigger("nextcommand");if(40==a.keyCode&&"checkbox"==b.$selected.find("input, textarea, select").prop("type"))return void a.preventDefault();break;case 37:if(q.keyStop(a,b),b.isInput||!b.$selected||!b.$selected.length)break;if(!b.$selected.parent().hasClass("context-menu-root")){var c=b.$selected.parent().parent();return b.$selected.trigger("contextmenu:blur"),void(b.$selected=c)}break;case 39:if(q.keyStop(a,b),b.isInput||!b.$selected||!b.$selected.length)break;var d=b.$selected.data("contextMenu")||{};if(d.$menu&&b.$selected.hasClass("context-menu-submenu"))return b.$selected=null,d.$selected=null,void d.$menu.trigger("nextcommand");break;case 35:case 36:return b.$selected&&b.$selected.find("input, textarea, select").length?void 0:((b.$selected&&b.$selected.parent()||b.$menu).children(":not(.disabled, .not-selectable)")[36==a.keyCode?"first":"last"]().trigger("contextmenu:focus"),void a.preventDefault());case 13:if(q.keyStop(a,b),b.isInput){if(b.$selected&&!b.$selected.is("textarea, select"))return void a.preventDefault();break}return void(b.$selected&&b.$selected.trigger("mouseup"));case 32:case 33:case 34:return void q.keyStop(a,b);case 27:return q.keyStop(a,b),void b.$menu.trigger("contextmenu:hide");default:var e=String.fromCharCode(a.keyCode).toUpperCase();if(b.accesskeys[e])return void b.accesskeys[e].$node.trigger(b.accesskeys[e].$menu?"contextmenu:focus":"mouseup")}a.stopPropagation(),b.$selected&&b.$selected.trigger(a)},prevItem:function(b){b.stopPropagation();var c=a(this).data("contextMenu")||{};if(c.$selected){var d=c.$selected;c=c.$selected.parent().data("contextMenu")||{},c.$selected=d}for(var e=c.$menu.children(),f=c.$selected&&c.$selected.prev().length?c.$selected.prev():e.last(),g=f;f.hasClass("disabled")||f.hasClass("not-selectable");)if(f=f.prev().length?f.prev():e.last(),f.is(g))return;c.$selected&&q.itemMouseleave.call(c.$selected.get(0),b),q.itemMouseenter.call(f.get(0),b);var h=f.find("input, textarea, select");h.length&&h.focus()},nextItem:function(b){b.stopPropagation();var c=a(this).data("contextMenu")||{};if(c.$selected){var d=c.$selected;c=c.$selected.parent().data("contextMenu")||{},c.$selected=d}for(var e=c.$menu.children(),f=c.$selected&&c.$selected.next().length?c.$selected.next():e.first(),g=f;f.hasClass("disabled")||f.hasClass("not-selectable");)if(f=f.next().length?f.next():e.first(),f.is(g))return;c.$selected&&q.itemMouseleave.call(c.$selected.get(0),b),q.itemMouseenter.call(f.get(0),b);var h=f.find("input, textarea, select");h.length&&h.focus()},focusInput:function(){var b=a(this).closest(".context-menu-item"),c=b.data(),d=c.contextMenu,e=c.contextMenuRoot;e.$selected=d.$selected=b,e.isInput=d.isInput=!0},blurInput:function(){var b=a(this).closest(".context-menu-item"),c=b.data(),d=c.contextMenu,e=c.contextMenuRoot;e.isInput=d.isInput=!1},menuMouseenter:function(){var b=a(this).data().contextMenuRoot;b.hovering=!0},menuMouseleave:function(b){var c=a(this).data().contextMenuRoot;c.$layer&&c.$layer.is(b.relatedTarget)&&(c.hovering=!1)},itemMouseenter:function(b){var c=a(this),d=c.data(),e=d.contextMenu,f=d.contextMenuRoot;return f.hovering=!0,b&&f.$layer&&f.$layer.is(b.relatedTarget)&&(b.preventDefault(),b.stopImmediatePropagation()),(e.$menu?e:f).$menu.children(".hover").trigger("contextmenu:blur"),c.hasClass("disabled")||c.hasClass("not-selectable")?void(e.$selected=null):void c.trigger("contextmenu:focus")},itemMouseleave:function(b){var c=a(this),d=c.data(),e=d.contextMenu,f=d.contextMenuRoot;return f!==e&&f.$layer&&f.$layer.is(b.relatedTarget)?(f.$selected&&f.$selected.trigger("contextmenu:blur"),b.preventDefault(),b.stopImmediatePropagation(),void(f.$selected=e.$selected=e.$node)):void c.trigger("contextmenu:blur")},itemClick:function(b){var c,d=a(this),e=d.data(),f=e.contextMenu,g=e.contextMenuRoot,h=e.contextMenuKey;if(f.items[h]&&!d.is(".disabled, .context-menu-submenu, .context-menu-separator, .not-selectable")){if(b.preventDefault(),b.stopImmediatePropagation(),a.isFunction(g.callbacks[h])&&Object.prototype.hasOwnProperty.call(g.callbacks,h))c=g.callbacks[h];else{if(!a.isFunction(g.callback))return;c=g.callback}c.call(g.$trigger,h,g)!==!1?g.$menu.trigger("contextmenu:hide"):g.$menu.parent().length&&r.update.call(g.$trigger,g)}},inputClick:function(a){a.stopImmediatePropagation()},hideMenu:function(b,c){var d=a(this).data("contextMenuRoot");r.hide.call(d.$trigger,d,c&&c.force)},focusItem:function(b){b.stopPropagation();var c=a(this),d=c.data(),e=d.contextMenu,f=d.contextMenuRoot;c.addClass("hover").siblings(".hover").trigger("contextmenu:blur"),e.$selected=f.$selected=c,e.$node&&f.positionSubmenu.call(e.$node,e.$menu)},blurItem:function(b){b.stopPropagation();{var c=a(this),d=c.data(),e=d.contextMenu;d.contextMenuRoot}c.removeClass("hover"),e.$selected=null}},r={show:function(b,c,d){var e=a(this),f={};return a("#context-menu-layer").trigger("mousedown"),b.$trigger=e,b.events.show.call(e,b)===!1?void(g=null):(r.update.call(e,b),b.position.call(e,b,c,d),b.zIndex&&(f.zIndex=p(e)+b.zIndex),r.layer.call(b.$menu,b,f.zIndex),b.$menu.find("ul").css("zIndex",f.zIndex+1),b.$menu.css(f)[b.animation.show](b.animation.duration,function(){e.trigger("contextmenu:visible")}),e.data("contextMenu",b).addClass("context-menu-active"),a(document).off("keydown.contextMenu").on("keydown.contextMenu",q.key),void(b.autoHide&&a(document).on("mousemove.contextMenuAutoHide",function(a){var c=e.offset();c.right=c.left+e.outerWidth(),c.bottom=c.top+e.outerHeight(),!b.$layer||b.hovering||a.pageX>=c.left&&a.pageX<=c.right&&a.pageY>=c.top&&a.pageY<=c.bottom||b.$menu.trigger("contextmenu:hide")})))},hide:function(c,d){var e=a(this);if(c||(c=e.data("contextMenu")||{}),d||!c.events||c.events.hide.call(e,c)!==!1){if(e.removeData("contextMenu").removeClass("context-menu-active"),c.$layer){setTimeout(function(a){return function(){a.remove()}}(c.$layer),10);try{delete c.$layer}catch(f){c.$layer=null}}g=null,c.$menu.find(".hover").trigger("contextmenu:blur"),c.$selected=null,a(document).off(".contextMenuAutoHide").off("keydown.contextMenu"),c.$menu&&c.$menu[c.animation.hide](c.animation.duration,function(){c.build&&(c.$menu.remove(),a.each(c,function(a){switch(a){case"ns":case"selector":case"build":case"trigger":return!0;default:c[a]=b;try{delete c[a]}catch(d){}return!0}})),setTimeout(function(){e.trigger("contextmenu:hidden")},10)})}},create:function(d,e){e===b&&(e=d),d.$menu=a('<ul class="context-menu-list"></ul>').addClass(d.className||"").data({contextMenu:d,contextMenuRoot:e}),a.each(["callbacks","commands","inputs"],function(a,b){d[b]={},e[b]||(e[b]={})}),e.accesskeys||(e.accesskeys={}),a.each(d.items,function(b,f){var g=a('<li class="context-menu-item"></li>').addClass(f.className||""),h=null,i=null;if(g.on("click",a.noop),f.$node=g.data({contextMenu:d,contextMenuRoot:e,contextMenuKey:b}),f.accesskey)for(var j,k=c(f.accesskey),l=0;j=k[l];l++)if(!e.accesskeys[j]){e.accesskeys[j]=f,f._name=f.name.replace(new RegExp("("+j+")","i"),'<span class="context-menu-accesskey">$1</span>');break}if("string"==typeof f)g.addClass("context-menu-separator not-selectable");else if(f.type&&m[f.type])m[f.type].call(g,f,d,e),a.each([d,e],function(c,d){d.commands[b]=f,a.isFunction(f.callback)&&(d.callbacks[b]=f.callback)});else{switch("html"==f.type?g.addClass("context-menu-html not-selectable"):f.type?(h=a("<label></label>").appendTo(g),a("<span></span>").html(f._name||f.name).appendTo(h),g.addClass("context-menu-input"),d.hasTypes=!0,a.each([d,e],function(a,c){c.commands[b]=f,c.inputs[b]=f})):f.items&&(f.type="sub"),f.type){case"text":i=a('<input type="text" value="1" name="" value="">').attr("name","context-menu-input-"+b).val(f.value||"").appendTo(h);break;case"textarea":i=a('<textarea name=""></textarea>').attr("name","context-menu-input-"+b).val(f.value||"").appendTo(h),f.height&&i.height(f.height);break;case"checkbox":i=a('<input type="checkbox" value="1" name="" value="">').attr("name","context-menu-input-"+b).val(f.value||"").prop("checked",!!f.selected).prependTo(h);break;case"radio":i=a('<input type="radio" value="1" name="" value="">').attr("name","context-menu-input-"+f.radio).val(f.value||"").prop("checked",!!f.selected).prependTo(h);break;case"select":i=a('<select name="">').attr("name","context-menu-input-"+b).appendTo(h),f.options&&(a.each(f.options,function(b,c){a("<option></option>").val(b).text(c).appendTo(i)}),i.val(f.selected));break;case"sub":a("<span></span>").html(f._name||f.name).appendTo(g),f.appendTo=f.$node,r.create(f,e),g.data("contextMenu",f).addClass("context-menu-submenu"),f.callback=null;break;case"html":a(f.html).appendTo(g);break;default:a.each([d,e],function(c,d){d.commands[b]=f,a.isFunction(f.callback)&&(d.callbacks[b]=f.callback)}),a("<span></span>").html(f._name||f.name||"").appendTo(g)}f.type&&"sub"!=f.type&&"html"!=f.type&&(i.on("focus",q.focusInput).on("blur",q.blurInput),f.events&&i.on(f.events,d)),f.icon&&g.addClass("icon icon-"+f.icon)}f.$input=i,f.$label=h,g.appendTo(d.$menu),!d.hasTypes&&a.support.eventSelectstart&&g.on("selectstart.disableTextSelect",q.abortevent)}),d.$node||d.$menu.css("display","none").addClass("context-menu-root"),d.$menu.appendTo(d.appendTo||document.body)},resize:function(b,c){b.css({position:"absolute",display:"block"}),b.data("width",Math.ceil(b.width())+1),b.css({position:"static",minWidth:"0px",maxWidth:"100000px"}),b.find("> li > ul").each(function(){r.resize(a(this),!0)}),c||b.find("ul").andSelf().css({position:"",display:"",minWidth:"",maxWidth:""}).width(function(){return a(this).data("width")})},update:function(c,d){var e=this;d===b&&(d=c,r.resize(c.$menu)),c.$menu.children().each(function(){var b=a(this),f=b.data("contextMenuKey"),g=c.items[f],h=a.isFunction(g.disabled)&&g.disabled.call(e,f,d)||g.disabled===!0;if(b[h?"addClass":"removeClass"]("disabled"),g.type)switch(b.find("input, select, textarea").prop("disabled",h),g.type){case"text":case"textarea":g.$input.val(g.value||"");break;case"checkbox":case"radio":g.$input.val(g.value||"").prop("checked",!!g.selected);break;case"select":g.$input.val(g.selected||"")}g.$menu&&r.update.call(e,g,d)})},layer:function(b,c){var d=b.$layer=a('<div id="context-menu-layer" style="position:fixed; z-index:'+c+'; top:0; left:0; opacity: 0; filter: alpha(opacity=0); background-color: #000;"></div>').css({height:i.height(),width:i.width(),display:"block"}).data("contextMenuRoot",b).insertBefore(this).on("contextmenu",q.abortevent).on("mousedown",q.layerClick);return a.support.fixedPosition||d.css({position:"absolute",height:a(document).height()}),d}};a.fn.contextMenu=function(c){if(c===b)this.first().trigger("contextmenu");else if(c.x&&c.y)this.first().trigger(a.Event("contextmenu",{pageX:c.x,pageY:c.y}));else if("hide"===c){var d=this.data("contextMenu").$menu;d&&d.trigger("contextmenu:hide")}else"destroy"===c?a.contextMenu("destroy",{context:this}):a.isPlainObject(c)?(c.context=this,a.contextMenu("create",c)):c?this.removeClass("context-menu-disabled"):c||this.addClass("context-menu-disabled");return this},a.contextMenu=function(c,d){"string"!=typeof c&&(d=c,c="create"),"string"==typeof d?d={selector:d}:d===b&&(d={});var e=a.extend(!0,{},n,d||{}),f=a(document),g=f,i=!1;switch(e.context&&e.context.length?(g=a(e.context).first(),e.context=g.get(0),i=e.context!==document):e.context=document,c){case"create":if(!e.selector)throw new Error("No selector specified");if(e.selector.match(/.context-menu-(list|item|input)($|\s)/))throw new Error('Cannot bind to selector "'+e.selector+'" as it contains a reserved className');if(!e.build&&(!e.items||a.isEmptyObject(e.items)))throw new Error("No Items specified");switch(j++,e.ns=".contextMenu"+j,i||(k[e.selector]=e.ns),l[e.ns]=e,e.trigger||(e.trigger="right"),h||(f.on({"contextmenu:hide.contextMenu":q.hideMenu,"prevcommand.contextMenu":q.prevItem,"nextcommand.contextMenu":q.nextItem,"contextmenu.contextMenu":q.abortevent,"mouseenter.contextMenu":q.menuMouseenter,"mouseleave.contextMenu":q.menuMouseleave},".context-menu-list").on("mouseup.contextMenu",".context-menu-input",q.inputClick).on({"mouseup.contextMenu":q.itemClick,"contextmenu:focus.contextMenu":q.focusItem,"contextmenu:blur.contextMenu":q.blurItem,"contextmenu.contextMenu":q.abortevent,"mouseenter.contextMenu":q.itemMouseenter,"mouseleave.contextMenu":q.itemMouseleave},".context-menu-item"),h=!0),g.on("contextmenu"+e.ns,e.selector,e,q.contextmenu),i&&g.on("remove"+e.ns,function(){a(this).contextMenu("destroy")}),e.trigger){case"hover":g.on("mouseenter"+e.ns,e.selector,e,q.mouseenter).on("mouseleave"+e.ns,e.selector,e,q.mouseleave);break;case"left":g.on("click"+e.ns,e.selector,e,q.click)}e.build||r.create(e);break;case"destroy":var m;if(i){var o=e.context;a.each(l,function(b,c){if(c.context!==o)return!0;m=a(".context-menu-list").filter(":visible"),m.length&&m.data().contextMenuRoot.$trigger.is(a(c.context).find(c.selector))&&m.trigger("contextmenu:hide",{force:!0});try{l[c.ns].$menu&&l[c.ns].$menu.remove(),delete l[c.ns]}catch(d){l[c.ns]=null}return a(c.context).off(c.ns),!0})}else if(e.selector){if(k[e.selector]){m=a(".context-menu-list").filter(":visible"),m.length&&m.data().contextMenuRoot.$trigger.is(e.selector)&&m.trigger("contextmenu:hide",{force:!0});try{l[k[e.selector]].$menu&&l[k[e.selector]].$menu.remove(),delete l[k[e.selector]]}catch(p){l[k[e.selector]]=null}f.off(k[e.selector])}}else f.off(".contextMenu .contextMenuAutoHide"),a.each(l,function(b,c){a(c.context).off(c.ns)}),k={},l={},j=0,h=!1,a("#context-menu-layer, .context-menu-list").remove();break;case"html5":(!a.support.htmlCommand&&!a.support.htmlMenuitem||"boolean"==typeof d&&d)&&a('menu[type="context"]').each(function(){this.id&&a.contextMenu({selector:"[contextmenu="+this.id+"]",items:a.contextMenu.fromMenu(this)})}).css("display","none");break;default:throw new Error('Unknown operation "'+c+'"')}return this},a.contextMenu.setInputValues=function(c,d){d===b&&(d={}),a.each(c.inputs,function(a,b){switch(b.type){case"text":case"textarea":b.value=d[a]||"";break;case"checkbox":b.selected=d[a]?!0:!1;break;case"radio":b.selected=(d[b.radio]||"")==b.value?!0:!1;break;case"select":b.selected=d[a]||""}})},a.contextMenu.getInputValues=function(c,d){return d===b&&(d={}),a.each(c.inputs,function(a,b){switch(b.type){case"text":case"textarea":case"select":d[a]=b.$input.val();break;case"checkbox":d[a]=b.$input.prop("checked");break;case"radio":b.$input.prop("checked")&&(d[b.radio]=b.value)}}),d},a.contextMenu.fromMenu=function(b){var c=a(b),d={};return e(d,c.children()),d},a.contextMenu.defaults=n,a.contextMenu.types=m,a.contextMenu.handle=q,a.contextMenu.op=r,a.contextMenu.menus=l}(jQuery),$.extend(UFinder,function(){var a={},b={},c={};return{registerUI:function(b,c){$.each(b.split(/\s+/),function(b,d){a[d]=c})},_createContainer:function(a){var b=$('<div class="ufui-container"></div>');return $(Utils.isString(a)?"#"+a:a).append(b),b},_createToolbar:function(b){var c=b.getOption("toolbars"),d=$.ufuitoolbar();if(b.$container.append(d),b.$toolbar=d,c&&c.length){var e=[];$.each(c,function(c,f){$.each(f.split(/\s+/),function(c,d){if("|"==d)$.ufuiseparator&&e.push($.ufuiseparator());else if(a[d]){var f=a[d].call(b,d);f&&e.push(f)}}),e.length&&d.ufui().appendToBtnmenu(e)})}d.append($('<div class="ufui-dialog-container"></div>'))},_createSearchbox:function(b){var c=a.searchbox.call(b,"list");b.$toolbar.append(c),b.$searchbox=c},_createtree:function(b){var c=a.tree.call(b,"list");b.$container.append(c),b.$tree=c},_createlist:function(b){var c=a.list.call(b,"list");b.$container.append(c),b.$list=c},_createpreview:function(b){var c=a.preview.call(b,"list");b.$container.append(c),b.$preview=c},_createclipboard:function(b){var c=a.clipboard.call(b,"list");b.$list.append(c),b.$clipboard=c},_createContextmenu:function(a){$.contextMenu({selector:".ufui-list-container .ufui-file",callback:function(b,c){a.execCommand(c.items[b].cmd)},items:{edit:{name:a.getLang("menu").edit,icon:"edit",cmd:"edit"},cut:{name:a.getLang("menu").cut,icon:"cut",cmd:"cut"},copy:{name:a.getLang("menu").copy,icon:"copy",cmd:"copy"},rename:{name:a.getLang("menu").rename,icon:"rename",cmd:"rename"},"delete":{name:a.getLang("menu").remove,icon:"remove",cmd:"remove"}}}),$.contextMenu({selector:".ufui-list-container",callback:function(b,c){a.execCommand(c.items[b].cmd)},items:{edit:{name:a.getLang("menu").pathparent,icon:"pathparent",cmd:"pathparent"},checkall:{name:a.getLang("menu").selectall,icon:"selectall",cmd:"selectall"},paste:{name:a.getLang("menu").paste,icon:"paste",cmd:"paste"},refresh:{name:a.getLang("menu").refresh,icon:"refresh",cmd:"refresh"},touch:{name:a.getLang("menu").touch,icon:"touch",cmd:"touch"},mkdir:{name:a.getLang("menu").mkdir,icon:"mkdir",cmd:"mkdir"}}})},_createMessageHolder:function(b){var c=$('<div class="ufui-message-list"></div>');b.$container.append(c),b.$messageHolder=c;var d={};b.on("showmessage",function(e,f){var g=a.message.call(b,"message",{icon:f.icon||"warning",title:f.title||"",loadedPercent:f.loadedPercent||100,timeout:f.timeout,id:f.id||"m"+(+new Date).toString(36)});f.id&&(d[f.id]=g),c.append(g),g.ufui().show()}),b.on("updatemessage",function(a,b){var c;b.id&&(c=d[b.id])&&c.ufui().setIcon(b.icon).setMessage(b.title).setTimer(b.timeout).setLoadedPercent(b.loadedPercent)}),b.on("hidemessage",function(a,b){var c;(c=d[b.id])&&c.ufui().hide()})},getUFinder:function(a,b){var c=this._createContainer(a),d=this.getFinder(c,b);return d.$container=c,d.on("focus",function(){c.removeClass("ufui-disabled")}).on("blur",function(){c.addClass("ufui-disabled")}),this._createToolbar(d),this._createSearchbox(d),this._createtree(d),this._createlist(d),this._createpreview(d),this._createclipboard(d),this._createMessageHolder(d),this._createContextmenu(d),d._initDomEvent(),d.fire("ready"),d},delUFinder:function(){},registerWidget:function(a,d,e){b[a]=$.extend2(d,{$root:"",_preventDefault:!1,root:function(a){return this.$root||(this.$root=a)},preventDefault:function(){this._preventDefault=!0},clear:!1}),e&&(c[a]=e)},getWidgetData:function(a){return b[a]},setWidgetBody:function(a,d,e){e._widgetData||Utils.extend(e,{_widgetData:{},getWidgetData:function(a){return this._widgetData[a]},getWidgetCallback:function(a){var b=this;return function(){return c[a].apply(b,[b,d].concat(Array.prototype.slice.call(arguments,0)))}}});var f=b[a];return f?(f=e._widgetData[a],f||(f=b[a],f=e._widgetData[a]="function"==$.type(f)?f:Utils.clone(f)),f.root(d.ufui().getBodyContainer()),f.initContent(e,d),f._preventDefault||f.initEvent(e,d),void(f.width&&d.width(f.width))):null},createEditor:function(){},createToolbar:function(){}}}()),UF.registerUI("open pathparent pathbackward pathforward touch mkdir rename remove toggleliststyle togglepreview",function(a){var b=this,c=$.ufuibutton({icon:a,click:function(c){return b.execCommand(a),c.preventDefault(),!1},title:b.getLang("labelMap")[a]||""});return b.on("selectionchange ready focus blur currentpathchange",function(){var d=b.queryCommandState(a);c.ufui().disabled(-1==d).active(1==d)}),c}),UF.registerUI("list",function(){var a,b,c,d=this,e=$.ufuilist(),f=e.ufui(),g=function(a){var b=d.getCurrentPath();$.each($.isArray(a)?a:[a],function(a,c){if(Utils.getParentPath(c.path)==b){var e=Utils.getPathExt(c.path);if(f.addItem({type:"dir"==c.type?"dir":e,title:c.name,details:Utils.dateFormat(new Date(1e3*c.time),"yyyy-MM-dd hh:mm:ss"),path:c.path,pers:(c.write?"w":"nw")+(c.read?"r":"nr"),link:d.proxy.getRequestUrl({cmd:"download",target:c.path})}),Utils.isImagePath(c.path)){var g=d.getRealPath(c.path);f.getItem(c.path).setPreviewImg(g)}}})},h=function(){var a=[];return e.find(".ufui-file.ufui-active").each(function(b,c){a.push($(c).attr("data-path"))}),a},i=function(){d.setSelectedFiles(h())},j=function(a){e.find(".ufui-file").not(a).each(function(){$(this).ufui().active(!1)})},k=function(a){"undefined"!=typeof clearPreview&&clearPreview(),d.execCommand("preview",a)};e.delegate(".ufui-file","dblclick",function(){var a=$(this).ufui(),b=a.getPath();if("dir"==a.getType()){var c=d.dataTree.getFileInfo(b);c.read&&!c.locked&&d.execCommand("open",b)}else Utils.isImagePath(b)?d.execCommand("lookimage",b):Utils.isCodePath(b)?d.execCommand("lookcode",b):Utils.isWebPagePath(b)||d.execCommand("download",b)}),e.delegate(".ufui-file-title","dblclick",function(){return d.execCommand("rename"),!1}),e.delegate(".ufui-file","dragstart",function(a){a.originalEvent.dataTransfer.setData("DownloadURL",$(a.target).attr("dataurl"))});var l=e.find(".ufui-list-container");lcFileDragHover=function(a){a.stopPropagation(),
a.preventDefault(),"dragover"==a.type?l.addClass("hover"):l.removeClass("hover")},e.delegate(".ufui-file[filetype=dir]","dragenter",function(){$(this).parent().find(".ufui-file").removeClass("ufui-file-open"),$(this).addClass("ufui-file-open")}),e.delegate(".ufui-file[filetype=dir]","drop",function(){var a=$(this).attr("data-path"),b=function(){d.execCommand("refresh")};d.proxy.move([a].concat(d.getSelection().getSelectedFiles()),b)}),e.delegate(".ufui-file","mousedown",function(d){if(!b||c!=d.target||d.shiftKey||d.ctrlKey||d.metaKey){b=setTimeout(function(){b=0},500),c=d.target;var e=$(this),f=$(this).ufui(),g=f.active();if(d.shiftKey&&a){var l,m,n,o;for(e.index()>a.index()?(l=a,m=e):(l=e,m=a),o=m.index(),n=l;n.length&&(n.ufui().active(!0),n=n.next(),!(n.index()>o)););}else d.ctrlKey||d.metaKey?(f.active(!g),!g&&(a=e)):0==g&&(!g&&h().length>0||g&&h().length>1?(j(e),f.active(!0)):f.active(!g),f.active()&&(a=e),k(e.attr("data-path")));i()}});var m,n,o;return e.on("mousedown",function(a){var b=e.find(".ufui-select-box");if(a.originalEvent&&"mousedown"==a.type){if(!$(a.originalEvent.srcElement).hasClass("ufui-list-container"))return;a.ctrlKey||a.shiftKey||(j(),i()),b.show(),m={x:a.offsetX-a.pageX,y:a.offsetY-a.pageY},n={x:a.pageX,y:a.pageY}}}),$(document).on("mouseup mousemove",function(a){var b=e.find(".ufui-select-box");if("mousemove"==a.type){if(!m)return;o={x:a.pageX,y:a.pageY},xs=n.x>o.x?[o.x,n.x]:[n.x,o.x],ys=n.y>o.y?[o.y,n.y]:[n.y,o.y];var c=xs[0],f=ys[0],g=xs[1]-xs[0],h=ys[1]-ys[0];b.css({top:f+m.y,left:c+m.x,width:g,height:h});var j=0;e.find(".ufui-file").each(function(a,c){var e=$(c).ufui(),f=-1!=d.getSelection().getSelectedFiles().indexOf(e.getPath());Utils.isOverlap($(c),b)&&(j++,f=!f),e.active(f)})}else i(),b.css({width:0,height:0,left:-2e3,top:-2e3}),b.hide(),m=null}),d.on("searchindex",function(){d.$toolbar.find(".searchbox input").focus()}),d.on("currentPathChange",function(a,b){e.attr("data-path")!=b&&(e.attr("data-path",b),f.clearItems(),g(d.dataTree.listDirFileInfo(b)))}),d.on("addFiles",function(a,b){g(b)}),d.on("updateFile",function(a,b,c){f.isItemInList(b)&&f.removeItem(b),g(c)}),d.on("removeFiles",function(a,b){$.each($.isArray(b)?b:[b],function(a,b){f.isItemInList(b)&&f.removeItem(b,0),f.isItemInList(b)&&f.removeItem(b,0)})}),d.on("selectFiles",function(a,b){j(),$.each($.isArray(b)?b:[b],function(a,c){var d=f.getItem(c);d&&($.isArray(b)?d.active(!0):d.trigger("mousedown"))}),i()}),d.on("lockFiles",function(a,b){$.each($.isArray(b)?b:[b],function(a,b){var c=f.getItem(b);c&&c.disabled(!0)})}),d.on("unlockFiles",function(a,b){$.each($.isArray(b)?b:[b],function(a,b){var c=f.getItem(b);c&&c.disabled(!1)})}),d.on("renameFileTitle",function(a,b,c){var e=f.getItem(b);e&&e.editabled(!0,function(a){c(a,function(a){if(!a){var c=d.dataTree.getFileInfo(b);c&&e.setTitle(c.name)}})})}),d.on("newFileTitle",function(a,b,c){var e,h="dir"==b?"新建文件夹":"新建文件",i=d.getCurrentPath()+h;g({type:b,path:i,name:h,read:!0,write:!0}),e=f.getItem(i),e.editabled(!0,function(a){c(a,function(){f.removeItem(i)})})}),e}),UF.registerUI("message",function(a,b){var c=$.ufuimessage(b),d=b.request;return d&&c.find(".ufui-message-loadbar").on("click",function(){d.pause()}),c}),UF.registerUI("tree",function(){var a=this,b=$.ufuitree(),c=b.ufui(),d=function(a){"dir"==a.type&&(c.isItemInTree(a.path)||c.addItem({type:a.type,title:a.name,path:a.path}))};return b.delegate(".ufui-leaf-expand,.ufui-leaf-folder,.ufui-leaf-title","click",function(){var b=$(this),c=b.parent(),d=c.parent(),e=d.attr("data-path"),f=a.dataTree.getFileInfo(e);f.read&&!a.dataTree.isFileLocked(e)&&(b.hasClass("ufui-leaf-expand")?c.hasClass("ufui-leaf-detail-closed")||a.execCommand("list",e):a.execCommand("open",e))}),a.on("dataReady",function(a,b){c.setRoot({type:b.type,title:"Root",path:b.path})}),a.on("listFile",function(a,b){$.each(b,function(a,b){d(b)})}),a.on("addfiles",function(a,b){$.each($.isArray(b)?b:[b],function(a,b){d(b)})}),a.on("renamefile",function(a,b,e){if("dir"==e.type){var f=c.getItem(b);f&&(c.removeItem(b),d(e))}}),a.on("removefiles",function(a,b){$.each($.isArray(b)?b:[b],function(a,b){c.isItemInTree(b)&&c.removeItem(b)})}),b}),UF.registerUI("upload",function(a){var b=this,c="ufui-btn-upload-"+(+new Date).toString(36),d=$.ufuibutton({icon:a,click:function(){},title:b.getLang("labelMap")[a]||""});return b.on("selectionchange ready focus blur currentpathchange",function(){var c=b.queryCommandState(a);d.ufui().disabled(-1==c).active(1==c),b.webuploader&&(-1==c?b.webuploader.disable():b.webuploader.enable())}),d.attr("id",c),b.on("initUploader",function(){b.webuploader.addButton({id:"#"+c})}),d}),UF.registerUI("lookimage lookcode",function(a){var b,c=this,d=c.getOption("labelMap"),e={title:d&&d[a]||c.getLang("labelMap."+a),url:c.getOption("URL")+"/dialogs/"+a+"/"+a+".js"},f=$.ufuibutton({icon:a,title:this.getLang("labelMap")[a]||""});return Utils.loadFile(document,{src:e.url,tag:"script",type:"text/javascript",defer:"defer"},function(){var d=UF.getWidgetData(a);if(d.buttons){var g=d.buttons.ok;g&&(e.oklabel=g.label||c.getLang("ok"),g.exec&&(e.okFn=function(){return $.proxy(g.exec,null,c,b)()}));var h=d.buttons.cancel;h&&(e.cancellabel=h.label||c.getLang("cancel"),h.exec&&(e.cancelFn=function(){return $.proxy(h.exec,null,c,b)()}))}d.width&&(e.width=d.width),d.height&&(e.height=d.height),b=$.ufuimodal(e),b.attr("id","ufui-dialog-"+a).addClass("ufui-dialog-"+a).find(".ufui-modal-body").addClass("ufui-dialog-"+a+"-body"),b.ufui().on("beforehide",function(){}).on("beforeshow",function(){var d=this.root(),e=null,f=null;d.parent()[0]||c.$container.find(".ufui-dialog-container").append(d),$.IE6&&(e={width:$(window).width(),height:$(window).height()},f=d.parents(".ufui-toolbar")[0].getBoundingClientRect(),d.css({position:"absolute",margin:0,left:(e.width-d.width())/2-f.left,top:100-f.top})),UF.setWidgetBody(a,b,c)}).on("afterbackdrop",function(){this.$backdrop.css("zIndex",c.getOption("zIndex")+1).appendTo(c.$container.find(".ufui-dialog-container")),b.css("zIndex",c.getOption("zIndex")+2)}).on("beforeok",function(){}).attachTo(f)}),c.on("selectionchange ready focus blur currentpathchange",function(){var b=c.queryCommandState(a);f.ufui().disabled(-1==b).active(1==b)}),f}),UF.registerUI("preview",function(){var a=$.ufuipreview();return a}),UF.registerUI("searchbox",function(){var a=this,b=$.ufuisearchbox({placeholder:a.getLang("hint").search}),c=b;return sbox=c.find("input"),sres=c.find("ul"),sbox.on("input",function(b){var c=$(b.target).val();sres.empty(),c.length>0&&a.execCommand("search",c)}),sbox.on("keydown",function(a){if(27==a.keyCode)sbox.blur();else if(38==a.keyCode){var b=sres.find("li.focus").prev();0==b.length&&(b=sres.children().last()),sres.find("li.focus").removeClass("focus"),b.addClass("focus")}else if(40==a.keyCode){var b=sres.find("li.focus").next();0==b.length&&(b=sres.children().first()),sres.find("li.focus").removeClass("focus"),b.addClass("focus")}else 13==a.keyCode&&(sfocus=sres.find("li.focus"),0==sfocus.length&&(sfocus=sres.children().first()),sfocus.trigger("mousedown"))}),sbox.on("focus blur",function(a){"focus"==a.type&&sbox.select(),c.toggleClass("blur","blur"==a.type)}),b.delegate(".search-ul li","mousedown",function(b){var c="LI"==b.target.tagName?$(b.target):$(b.target).parents("li"),d=c.attr("data-path"),e=c.attr("filename");a.execCommand("open",d),setTimeout(function(){a.execCommand("selectfile",d+e),a.setFocus()},500)}),b}),UF.registerUI("clipboard",function(){var a=this,b=$.ufuiclipboard(),c=b.ufui(),a=this;return b.delegate(".clipboard-clear","click",function(){c.clear()}),a.on("copy",function(){c.setIsCopy(!0),c.addFiles(a.getSelection().getSelectedFiles())}),a.on("cut",function(){c.setIsCopy(!1),c.addFiles(a.getSelection().getSelectedFiles())}),a.on("paste",function(){var b=function(){a.execCommand("refresh"),c.clear()};c.getIsCopy()?a.proxy.copy(c.getPasteTarget(a.getCurrentPath()),b):a.proxy.move(c.getPasteTarget(a.getCurrentPath()),b)}),a.on("clear",function(){c.clear()}),b})}(jQuery,window);