window.Finder=function(a,c){this.time("load");var b=this,a=$(a),d=$("<div/>").append(a.contents()),e=a.attr("style"),f=a.attr("id")||"",g="finder-"+(f||Math.random().toString().substr(2,7)),h="keydown."+g,i="keypress."+g,j=!0,m=!0,k="",l={path:"",url:"",tmbUrl:"",disabled:[],separator:"/",archives:[],extract:[],copyOverwrite:!0,tmb:!1},n={},q=[],s={},r={},t=[],y=[],C=[],G=new b.command(b),L="auto",I=400,J,F=function(a){if(a.init)n={};else for(var c in n)n.hasOwnProperty(c)&&"directory"!=n[c].mime&&
(n[c].phash==k&&-1===$.inArray(c,y))&&delete n[c];k=a.cwd.hash;A(a.files);n[k]||A([a.cwd]);b.lastDir(k)},A=function(a){for(var b=a.length,c;b--;)c=a[b],c.name&&c.hash&&c.mime&&(n[c.hash]=c)},v=new Date;this.api=null;this.oldAPI=this.newAPI=!1;this.OS=-1!==navigator.userAgent.indexOf("Mac")?"mac":-1!==navigator.userAgent.indexOf("Win")?"win":"other";this.options=$.extend(!0,{},this._options,c||{});c.ui&&(this.options.ui=c.ui);c.commands&&(this.options.commands=c.commands);c.uiOptions&&c.uiOptions.toolbar&&
(this.options.uiOptions.toolbar=c.uiOptions.toolbar);$.extend(this.options.contextmenu,c.contextmenu);this.requestType=/^(get|post)$/i.test(this.options.requestType)?this.options.requestType.toLowerCase():"get";this.customData=$.isPlainObject(this.options.customData)?this.options.customData:{};this.id=f;this.uploadURL=c.urlUpload||c.url;this.namespace=g;this.lang=this.i18[this.options.lang]&&this.i18[this.options.lang].messages?this.options.lang:"en";f="en"==this.lang?this.i18.en:$.extend(!0,{},this.i18.en,
this.i18[this.lang]);this.direction=f.direction;this.messages=f.messages;this.dateFormat=this.options.dateFormat||f.dateFormat;this.fancyFormat=this.options.fancyDateFormat||f.fancyDateFormat;this.today=(new Date(v.getFullYear(),v.getMonth(),v.getDate())).getTime()/1E3;this.yesterday=this.today-86400;v=this.options.UTCDate?"UTC":"";this.getHours="get"+v+"Hours";this.getMinutes="get"+v+"Minutes";this.getSeconds="get"+v+"Seconds";this.getDate="get"+v+"Date";this.getDay="get"+v+"Day";this.getMonth="get"+
v+"Month";this.getFullYear="get"+v+"FullYear";this.cssClass="ui-helper-reset ui-helper-clearfix ui-widget ui-widget-content ui-corner-all finder finder-"+("rtl"==this.direction?"rtl":"ltr")+" "+this.options.cssClass;var u;try{u="localStorage"in window&&null!==window.localStorage?b.localStorage:b.cookie}catch(D){u=b.cookie}this.storage=u;this.viewType=this.storage("view")||this.options.defaultView||"icons";this.sortType=this.storage("sortType")||this.options.sortType||"name";this.sortOrder=this.storage("sortOrder")||
this.options.sortOrder||"asc";this.sortStickFolders=this.storage("sortStickFolders");this.sortStickFolders=null===this.sortStickFolders?!!this.options.sortStickFolders:!!this.sortStickFolders;this.sortRules=$.extend(!0,{},this._sortRules,this.options.sortsRules);$.each(this.sortRules,function(a,c){"function"!=typeof c&&delete b.sortRules[a]});this.compare=$.proxy(this.compare,this);this.notifyDelay=0<this.options.notifyDelay?parseInt(this.options.notifyDelay):500;this.draggable={appendTo:"body",addClasses:!0,
delay:30,revert:!0,refreshPositions:!0,cursor:"move",cursorAt:{left:50,top:47},drag:function(a,b){b.helper.data("locked")||b.helper.toggleClass("finder-drag-helper-plus",a.shiftKey||a.ctrlKey||a.metaKey)},start:function(a,b){var c=$.map(b.helper.data("files")||[],function(a){return a||null}),d,e;for(d=c.length;d--;)if(e=c[d],n[e].locked){b.helper.addClass("finder-drag-helper-plus").data("locked",!0);break}},stop:function(){b.trigger("focus").trigger("dragstop")},helper:function(a){var c=this.id?$(this):
$(this).parents("[id]:first"),d=$('<div class="finder-drag-helper"><span class="finder-drag-helper-icon-plus"/></div>'),e=function(a){return'<div class="finder-cwd-icon '+b.mime2class(a)+' ui-corner-all"/>'},f;b.trigger("dragstart",{target:c[0],originalEvent:a});a=c.is("."+b.res("class","cwdfile"))?b.selected():[b.navId2Hash(c.attr("id"))];d.append(e(n[a[0]].mime)).data("files",a).data("locked",!1);1<(f=a.length)&&d.append(e(n[a[f-1]].mime)+'<span class="finder-drag-num">'+f+"</span>");return d}};
this.droppable={tolerance:"pointer",accept:".finder-cwd-file-wrapper,.finder-navbar-dir,.finder-cwd-file",hoverClass:this.res("class","adroppable"),drop:function(a,c){var d=$(this),e=$.map(c.helper.data("files")||[],function(a){return a||null}),f=[],g,h;d.is("."+b.res("class","cwd"))?g=k:d.is("."+b.res("class","cwdfile"))?g=d.attr("id"):d.is("."+b.res("class","navdir"))&&(g=b.navId2Hash(d.attr("id")));for(d=e.length;d--;)h=e[d],h!=g&&n[h].phash!=g&&f.push(h);f.length&&(c.helper.hide(),b.clipboard(f,
!(a.ctrlKey||a.shiftKey||a.metaKey||c.helper.data("locked"))),b.exec("paste",g),b.trigger("drop",{files:e}))}};this.enabled=function(){return a.is(":visible")&&j};this.visible=function(){return a.is(":visible")};this.root=function(a){for(a=n[a||k];a&&a.phash;)a=n[a.phash];if(a)return a.hash;for(;void 0 in n&&n.hasOwnProperty(void 0);)if(a=n[void 0],!a.phash&&"directory"==!a.mime&&a.read)return a.hash;return""};this.cwd=function(){return n[k]||{}};this.option=function(a){return l[a]||""};this.file=
function(a){return n[a]};this.files=function(){return $.extend(!0,{},n)};this.parents=function(a){for(var b=[];a=this.file(a);)b.unshift(a.hash),a=a.phash;return b};this.path2array=function(a){for(var b,c=[];a&&(b=n[a])&&b.hash;)c.unshift(b.name),a=b.phash;return c};this.path=function(a){return n[a]&&n[a].path?n[a].path:this.path2array(a).join(l.separator)};this.url=function(a){var b=n[a];if(!b||!b.read)return"";if(b.url)return b.url;if(l.url)return l.url+$.map(this.path2array(a),function(a){return encodeURIComponent(a)}).slice(1).join("/");
a=$.extend({},this.customData,{cmd:"file",target:b.hash});this.oldAPI&&(a.cmd="open",a.current=b.phash);return this.options.url+(-1===this.options.url.indexOf("?")?"?":"&")+$.param(a,!0)};this.tmb=function(a){if((a=(a=n[a])&&a.tmb&&1!=a.tmb?l.tmbUrl+a.tmb:"")&&($.browser.opera||$.browser.msie))a+="?_="+(new Date).getTime();return a};this.selected=function(){return q.slice(0)};this.selectedFiles=function(){return $.map(q,function(a){return n[a]?$.extend({},n[a]):null})};this.fileByName=function(a,
b){for(var c in n)if(n.hasOwnProperty(c)&&n[c].phash==b&&n[c].name==a)return n[c]};this.validResponse=function(a,b){return b.error||this.rules[this.rules[a]?a:"defaults"](b)};this.request=function(a){var b=this,c=this.options,d=$.Deferred(),e=$.extend({},c.customData,{mimes:c.onlyMimes},a.data||a),f=e.cmd,g=!(a.preventDefault||a.preventFail),h=!(a.preventDefault||a.preventDone),i=$.extend({},a.notify),j=a.syncOnFail,n,a=$.extend({url:c.url,async:!0,type:this.requestType,dataType:"json",cache:!1,data:e},
a.options||{}),c=function(a){a.warning&&b.error(a.warning);"netmount"==f&&(f="open");"open"==f&&F($.extend(!0,{},a));a.removed&&a.removed.length&&b.remove(a);a.added&&a.added.length&&b.add(a);a.changed&&a.changed.length&&b.change(a);b.trigger(f,a);a.sync&&b.sync()},k;h&&d.done(c);d.fail(function(a){a&&(g?b.error(a):b.debug("error",b.i18n(a)))});if(!f)return d.reject("errCmdReq");j&&d.fail(function(a){a&&b.sync()});i.type&&i.cnt&&(n=setTimeout(function(){b.notify(i);d.always(function(){i.cnt=-(parseInt(i.cnt)||
0);b.notify(i)})},b.notifyDelay),d.always(function(){clearTimeout(n)}));if("open"==f)for(;h=C.pop();)"resolved"!=h.state()&&"rejected"!=h.state()&&(h.quiet=!0,h.abort());delete a.preventFail;k=this.transport.send(a).fail(function(a,b){var c;switch(b){case "abort":c=a.quiet?"":["errConnect","errAbort"];break;case "timeout":c=["errConnect","errTimeout"];break;case "parsererror":c="";"string"==typeof a.responseText&&(c="Response: "+a.responseText.substr(0,300));c=["errResponse","errDataNotJSON","",c];
break;default:c=403==a.status?["errConnect","errAccess"]:404==a.status?["errConnect","errNotFound"]:"errConnect"}d.reject(c,a,b)}).done(function(a){if(a)if($.isPlainObject(a)){if(a.error)return d.reject(a.error,k);if(!b.validResponse(f,a))return d.reject("errResponse",k)}else return d.reject(["errResponse","errDataNotJSON"],k);else return d.reject(["errResponse","errDataEmpty"],k);b.api||(b.api=a.api||1,b.newAPI=2<=b.api,b.oldAPI=!b.newAPI);a.options&&(l=$.extend({},l,a.options));a.netDrivers&&(b.netDrivers=
a.netDrivers);d.resolve(a);a.debug&&b.debug("backend-debug",a.debug)});"open"==f&&(C.unshift(k),d.always(function(){var a=$.inArray(k,C);-1!==a&&C.splice(a,1)}));return d};this.diff=function(a){var b={},c=[],d=[],e=[];$.each(a,function(a,c){b[c.hash]=c});$.each(n,function(a){!b[a]&&d.push(a)});$.each(b,function(a,b){var d=n[a];d?$.each(b,function(a){if(b[a]!=d[a])return e.push(b),!1}):c.push(b)});$.each(d,function(a,c){var f=n[c],g=f.phash,h;if(h=g){if(f="directory"==f.mime)if(f=-1===$.inArray(g,
d))if(f=b[g]){a:{for(f=e.length;f--;)if(e[f].hash==g){f=!0;break a}f=void 0}f=!f}h=f}h&&e.push(b[g])});return{added:c,removed:d,changed:e}};this.sync=function(){var a=this,b=$.Deferred().done(function(){a.trigger("sync")}),c={data:{cmd:"parents",target:k},preventDefault:!0};$.when(this.request({data:{cmd:"open",init:1,target:k,tree:this.ui.tree?1:0},preventDefault:!0}),this.request(c)).fail(function(c){b.reject(c);c&&a.request({data:{cmd:"open",target:a.lastDir(""),tree:1,init:1},notify:{type:"open",
cnt:1,hideCnt:!0}})}).done(function(c,d){var e=a.diff(c.files.concat(d&&d.tree?d.tree:[]));e.removed.length&&a.remove(e);e.added.length&&a.add(e);e.changed.length&&a.change(e);return b.resolve(e)});return b};this.upload=function(a){return this.transport.upload(a,this)};this.bind=function(a,b){var c;if("function"==typeof b){a=(""+a).toLowerCase().split(/\s+/);for(c=0;c<a.length;c++)void 0===s[a[c]]&&(s[a[c]]=[]),s[a[c]].push(b)}return this};this.unbind=function(a,b){var c=s[(""+a).toLowerCase()]||
[],d=c.indexOf(b);-1<d&&c.splice(d,1);return this};this.trigger=function(a,b){var a=a.toLowerCase(),c=s[a]||[],d;if(c.length){a=$.Event(a);for(d=0;d<c.length;d++){a.data=$.extend(!0,{},b);try{if(!1===c[d](a,this)||a.isDefaultPrevented()){this.debug("event-stoped",a.type);break}}catch(e){window.console&&window.console.log&&window.console.log(e)}}}return this};this.shortcut=function(a){var b,c,d,e,f;if(this.options.allowShortcuts&&a.pattern&&$.isFunction(a.callback)){b=a.pattern.toUpperCase().split(/\s+/);
for(e=0;e<b.length;e++)c=b[e],f=c.split("+"),(d=1==(d=f.pop()).length?0<d?d:d.charCodeAt(0):$.ui.keyCode[d])&&!r[c]&&(r[c]={keyCode:d,altKey:-1!=$.inArray("ALT",f),ctrlKey:-1!=$.inArray("CTRL",f),shiftKey:-1!=$.inArray("SHIFT",f),type:a.type||"keydown",callback:a.callback,description:a.description,pattern:c})}return this};this.shortcuts=function(){var a=[];$.each(r,function(c,d){a.push([d.pattern,b.i18n(d.description)])});return a};this.clipboard=function(a,b){var c=function(){return $.map(t,function(a){return a.hash})};
void 0!==a&&(t.length&&this.trigger("unlockfiles",{files:c()}),y=[],t=$.map(a||[],function(a){var c=n[a];return c?(y.push(a),{hash:a,phash:c.phash,name:c.name,mime:c.mime,read:c.read,locked:c.locked,cut:!!b}):null}),this.trigger("changeclipboard",{clipboard:t.slice(0,t.length)}),b&&this.trigger("lockfiles",{files:c()}));return t.slice(0,t.length)};this.isCommandEnabled=function(a){return this._commands[a]?-1===$.inArray(a,l.disabled):!1};this.exec=function(a,b,c){return this._commands[a]&&this.isCommandEnabled(a)?
this._commands[a].exec(b,c):$.Deferred().reject("No such command")};this.dialog=function(b,c){return $("<div/>").append(b).appendTo(a).finderdialog(c)};this.getUI=function(b){return this.ui[b]||a};this.command=function(a){return void 0===a?this._commands:this._commands[a]};this.resize=function(b,c){a.css("width",b).height(c).trigger("resize");this.trigger("resize",{width:a.width(),height:a.height()})};this.restoreSize=function(){this.resize(L,I)};this.show=function(){a.show();this.enable().trigger("show")};
this.hide=function(){this.disable().trigger("hide");a.hide()};this.destroy=function(){a&&a[0].finder&&(this.trigger("destroy").disable(),s={},r={},$(document).add(a).unbind("."+this.namespace),b.trigger=function(){},a.children().remove(),a.append(d.contents()).removeClass(this.cssClass).attr("style",e),a[0].finder=null,J&&clearInterval(J))};if(!$.fn.selectable||!$.fn.draggable||!$.fn.droppable)return alert(this.i18n("errJqui"));if(!a.length)return alert(this.i18n("errNode"));if(!this.options.url)return alert(this.i18n("errURL"));
$.extend($.ui.keyCode,{F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120});this.dragUpload=!1;this.xhrUpload="undefined"!=typeof XMLHttpRequestUpload&&"undefined"!=typeof File&&"undefined"!=typeof FormData;this.transport={};"object"==typeof this.options.transport&&(this.transport=this.options.transport,"function"==typeof this.transport.init&&this.transport.init(this));"function"!=typeof this.transport.send&&(this.transport.send=function(a){return $.ajax(a)});"iframe"==this.transport.upload?
this.transport.upload=$.proxy(this.uploads.iframe,this):"function"==typeof this.transport.upload?this.dragUpload=!!this.options.dragUploadAllow:this.xhrUpload?(this.transport.upload=$.proxy(this.uploads.xhr,this),this.dragUpload=!0):this.transport.upload=$.proxy(this.uploads.iframe,this);this.error=function(){var a=arguments[0];return 1==arguments.length&&"function"==typeof a?b.bind("error",a):b.trigger("error",{error:a})};$.each("enable disable load open reload select add remove change dblclick getfile lockfiles unlockfiles dragstart dragstop search searchend viewchange".split(" "),
function(a,c){b[c]=function(){var a=arguments[0];return 1==arguments.length&&"function"==typeof a?b.bind(c,a):b.trigger(c,$.isPlainObject(a)?a:{})}});this.enable(function(){!j&&b.visible()&&b.ui.overlay.is(":hidden")&&(j=!0,$("texarea:focus,input:focus,button").blur(),a.removeClass("finder-disabled"))}).disable(function(){m=j;j=!1;a.addClass("finder-disabled")}).open(function(){q=[]}).select(function(a){q=$.map(a.data.selected||a.data.value||[],function(a){return n[a]?a:null})}).error(function(a){var c=
{cssClass:"finder-dialog-error",title:b.i18n(b.i18n("error")),resizable:!1,destroyOnClose:!0,buttons:{}};c.buttons[b.i18n(b.i18n("btnClose"))]=function(){$(this).finderdialog("close")};b.dialog('<span class="finder-dialog-icon finder-dialog-icon-error"/>'+b.i18n(a.data.error),c)}).bind("tree parents",function(a){A(a.data.tree||[])}).bind("tmb",function(a){$.each(a.data.images||[],function(a,b){n[a]&&(n[a].tmb=b)})}).add(function(a){A(a.data.added||[])}).change(function(a){$.each(a.data.changed||[],
function(a,b){var c=b.hash;n[c]=n[c]?$.extend(n[c],b):b})}).remove(function(a){for(var a=a.data.removed||[],b=a.length,c=function(a){var b=n[a];b&&("directory"==b.mime&&b.dirs&&$.each(n,function(b,d){d.phash==a&&c(b)}),delete n[a])};b--;)c(a[b])}).bind("search",function(a){A(a.data.files)});$.each(this.options.handlers,function(a,c){b.bind(a,c)});this.history=new this.history(this);"function"==typeof this.options.getFileCallback&&this.commands.getfile&&(this.bind("dblclick",function(a){a.preventDefault();
b.exec("getfile").fail(function(){b.exec("open")})}),this.shortcut({pattern:"enter",description:this.i18n("cmdgetfile"),callback:function(){b.exec("getfile").fail(function(){b.exec("mac"==b.OS?"rename":"open")})}}).shortcut({pattern:"ctrl+enter",description:this.i18n("mac"==this.OS?"cmdrename":"cmdopen"),callback:function(){b.exec("mac"==b.OS?"rename":"open")}}));this._commands={};$.isArray(this.options.commands)||(this.options.commands=[]);$.each("open reload back forward up home info quicklook getfile help".split(" "),
function(a,c){-1===$.inArray(c,b.options.commands)&&b.options.commands.push(c)});$.each(this.options.commands,function(a,c){var d=b.commands[c];$.isFunction(d)&&!b._commands[c]&&(d.prototype=G,b._commands[c]=new d,b._commands[c].setup(c,b.options.commandsOptions[c]||{}))});a.addClass(this.cssClass);this.ui={workzone:$("<div/>").appendTo(a).finderworkzone(this),navbar:$("<div/>").appendTo(a).findernavbar(this,this.options.uiOptions.navbar||{}),contextmenu:$("<div/>").appendTo(a).findercontextmenu(this),
overlay:$("<div/>").appendTo(a).finderoverlay({show:function(){b.disable()},hide:function(){m&&b.enable()}}),cwd:$("<div/>").appendTo(a).findercwd(this,this.options.uiOptions.cwd||{}),notify:this.dialog("",{cssClass:"finder-dialog-notify",position:{top:"12px",right:"12px"},resizable:!1,autoOpen:!1,title:"&nbsp;",width:280}),statusbar:$('<div class="ui-widget-header ui-helper-clearfix ui-corner-bottom finder-statusbar"/>').hide().appendTo(a)};$.each(this.options.ui||[],function(c,d){var e="finder"+
d,f=b.options.uiOptions[d]||{};!b.ui[d]&&$.fn[e]&&(b.ui[d]=$("<"+(f.tag||"div")+"/>").appendTo(a)[e](b,f))});a[0].finder=this;this.options.resizable&&$.fn.resizable&&a.resizable({handles:"se",minWidth:300,minHeight:200});this.options.width&&(L=this.options.width);this.options.height&&(I=parseInt(this.options.height));b.resize(L,I);$(document).bind(h+" "+i,function(a){var c=a.keyCode,d=!(!a.ctrlKey&&!a.metaKey);j&&($.each(r,function(e,f){f.type==a.type&&f.keyCode==c&&(f.shiftKey==a.shiftKey&&f.ctrlKey==
d&&f.altKey==a.altKey)&&(a.preventDefault(),a.stopPropagation(),f.callback(a,b),b.debug("shortcut-exec",e+" : "+f.description))}),9==c&&!$(a.target).is(":input")&&a.preventDefault())});this.trigger("init").request({data:{cmd:"open",target:b.lastDir(),init:1,tree:this.ui.tree?1:0},preventDone:!0,notify:{type:"open",cnt:1,hideCnt:!0},freeze:!0}).fail(function(){b.trigger("fail").disable().lastDir("");s={};r={};$(document).add(a).unbind("."+this.namespace);b.trigger=function(){}}).done(function(a){b.load();
a=$.extend(!0,{},a);F(a);b.trigger("open",a)});this.one("load",function(){a.trigger("resize");1E3<b.options.sync&&(J=setInterval(function(){b.sync()},b.options.sync))})};
Finder.prototype={res:function(a,c){return this.resources[a]&&this.resources[a][c]},i18:{en:{translator:"",language:"English",direction:"ltr",dateFormat:"d.m.Y H:i",fancyDateFormat:"$1 H:i",messages:{}},months:"January February March April May June July August September October November December".split(" "),monthsShort:"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),days:"Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),daysShort:"Sun Mon Tue Wed Thu Fri Sat".split(" ")},
rules:{defaults:function(a){return!a||a.added&&!$.isArray(a.added)||a.removed&&!$.isArray(a.removed)||a.changed&&!$.isArray(a.changed)?!1:!0},open:function(a){return a&&a.cwd&&a.files&&$.isPlainObject(a.cwd)&&$.isArray(a.files)},tree:function(a){return a&&a.tree&&$.isArray(a.tree)},parents:function(a){return a&&a.tree&&$.isArray(a.tree)},tmb:function(a){return a&&a.images&&($.isPlainObject(a.images)||$.isArray(a.images))},upload:function(a){return a&&($.isPlainObject(a.added)||$.isArray(a.added))},
search:function(a){return a&&a.files&&$.isArray(a.files)}},commands:{},parseUploadData:function(a){var c;if(!$.trim(a))return{error:["errResponse","errDataEmpty"]};try{c=$.parseJSON(a)}catch(b){return{error:["errResponse","errDataNotJSON"]}}if(!this.validResponse("upload",c))return{error:["errResponse"]};c.removed=$.map(c.added||[],function(a){return a.hash});return c},iframeCnt:0,uploads:{iframe:function(a,c){var b=c?c:this,d=a.input,e=$.Deferred().fail(function(a){a&&b.error(a)}).done(function(a){a.warning&&
b.error(a.warning);a.removed&&b.remove(a);a.added&&b.add(a);a.changed&&b.change(a);b.trigger("upload",a);a.sync&&b.sync()}),f="iframe-"+b.namespace+ ++b.iframeCnt,g=$('<form action="'+b.uploadURL+'" method="post" enctype="multipart/form-data" encoding="multipart/form-data" target="'+f+'" style="display:none"><input type="hidden" name="cmd" value="upload" /></form>'),h=$.browser.msie,i=function(){n&&clearTimeout(n);l&&clearTimeout(l);k&&b.notify({type:"upload",cnt:-m});setTimeout(function(){h&&$('<iframe src="javascript:false;"/>').appendTo(g);
g.remove();j.remove()},100)},j=$('<iframe src="'+(h?"javascript:false;":"about:blank")+'" name="'+f+'" style="position:absolute;left:-1000px;top:-1000px" />').bind("load",function(){j.unbind("load").bind("load",function(){var a=b.parseUploadData(j.contents().text());i();a.error?e.reject(a.error):e.resolve(a)});l=setTimeout(function(){k=!0;b.notify({type:"upload",cnt:m})},b.options.notifyDelay);0<b.options.iframeTimeout&&(n=setTimeout(function(){i();e.reject([errors.connect,errors.timeout])},b.options.iframeTimeout));
g.submit()}),m,k,l,n;if(d&&$(d).is(":file")&&$(d).val())g.append(d);else return e.reject();m=d.files?d.files.length:1;g.append('<input type="hidden" name="'+(b.newAPI?"target":"current")+'" value="'+b.cwd().hash+'"/>').append('<input type="hidden" name="html" value="1"/>').append($(d).attr("name","upload[]"));$.each(b.options.onlyMimes||[],function(a,b){g.append('<input type="hidden" name="mimes[]" value="'+b+'"/>')});$.each(b.options.customData,function(a,b){g.append('<input type="hidden" name="'+
a+'" value="'+b+'"/>')});g.appendTo("body");j.appendTo("body");return e},xhr:function(a,c){var b=c?c:this,d=$.Deferred().fail(function(a){a&&b.error(a)}).done(function(a){a.warning&&b.error(a.warning);a.removed&&b.remove(a);a.added&&b.add(a);a.changed&&b.change(a);b.trigger("upload",a);a.sync&&b.sync()}).always(function(){k&&clearTimeout(k);j&&b.notify({type:"upload",cnt:-h,progress:100*h})}),e=new XMLHttpRequest,f=new FormData,g=a.input?a.input.files:a.files,h=g.length,i=5,j=!1,m=function(){return setTimeout(function(){j=
!0;b.notify({type:"upload",cnt:h,progress:i*h})},b.options.notifyDelay)},k;if(!h)return d.reject();e.addEventListener("error",function(){d.reject("errConnect")},!1);e.addEventListener("abort",function(){d.reject(["errConnect","errAbort"])},!1);e.addEventListener("load",function(){var a=e.status;if(500<a)return d.reject("errResponse");if(200!=a)return d.reject("errConnect");if(4!=e.readyState)return d.reject(["errConnect","errTimeout"]);if(!e.responseText)return d.reject(["errResponse","errDataEmpty"]);
a=b.parseUploadData(e.responseText);a.error?d.reject(a.error):d.resolve(a)},!1);e.upload.addEventListener("progress",function(a){var c=i;a.lengthComputable&&(a=parseInt(100*a.loaded/a.total),0<a&&!k&&(k=m()),4<a-c&&(i=a,j&&b.notify({type:"upload",cnt:0,progress:(i-c)*h})))},!1);e.open("POST",b.uploadURL,!0);f.append("cmd","upload");f.append(b.newAPI?"target":"current",b.cwd().hash);$.each(b.options.customData,function(a,b){f.append(a,b)});$.each(b.options.onlyMimes,function(a,b){f.append("mimes["+
a+"]",b)});$.each(g,function(a,b){f.append("upload[]",b)});e.onreadystatechange=function(){4==e.readyState&&0==e.status&&d.reject(["errConnect","errAbort"])};e.send(f);if(!$.browser.safari||!a.files)k=m();return d}},one:function(a,c){var b=this,d=$.proxy(c,function(a){setTimeout(function(){b.unbind(a.type,d)},3);return c.apply(this,arguments)});return this.bind(a,d)},localStorage:function(a,c){var b=window.localStorage,a="finder-"+a+this.id;if(null===c)return console.log("remove",a),b.removeItem(a);
if(void 0!==c)try{b.setItem(a,c)}catch(d){b.clear(),b.setItem(a,c)}return b.getItem(a)},cookie:function(a,c){var b,d,a="finder-"+a+this.id;if(void 0===c){if(document.cookie&&""!=document.cookie){b=document.cookie.split(";");a+="=";for(d=0;d<b.length;d++)if(b[d]=$.trim(b[d]),b[d].substring(0,a.length)==a)return decodeURIComponent(b[d].substring(a.length))}return""}d=$.extend({},this.options.cookie);null===c&&(c="",d.expires=-1);"number"==typeof d.expires&&(b=new Date,b.setTime(b.getTime()+864E5*d.expires),
d.expires=b);document.cookie=a+"="+encodeURIComponent(c)+"; expires="+d.expires.toUTCString()+(d.path?"; path="+d.path:"")+(d.domain?"; domain="+d.domain:"")+(d.secure?"; secure":"");return c},lastDir:function(a){return this.options.rememberLastDir?this.storage("lastdir",a):""},_node:$("<span/>"),escape:function(a){return this._node.text(a).html()},setSort:function(a,c,b){this.storage("sortType",this.sortType=this.sortRules[a]?a:"name");this.storage("sortOrder",this.sortOrder=/asc|desc/.test(c)?c:
"asc");this.storage("sortStickFolders",(this.sortStickFolders=!!b)?1:"");this.trigger("sortchange")},_sortRules:{name:function(a,c){return a.name.toLowerCase().localeCompare(c.name.toLowerCase())},size:function(a,c){var b=parseInt(a.size)||0,d=parseInt(c.size)||0;return b==d?0:b>d?1:-1},kind:function(a,c){return a.mime.localeCompare(c.mime)},date:function(a,c){var b=a.ts||a.date,d=c.ts||c.date;return b==d?0:b>d?1:-1}},compare:function(a,c){var b=this.sortType,d="asc"==this.sortOrder,e=this.sortRules,
f=e[b],g="directory"==a.mime,h="directory"==c.mime;if(this.sortStickFolders){if(g&&!h)return-1;if(!g&&h)return 1}f=d?f(a,c):f(c,a);return"name"!=b&&0==f?d?e.name(a,c):e.name(c,a):f},sortFiles:function(a){return a.sort(this.compare)},notify:function(a){var c=a.type,b=this.messages["ntf"+c]?this.i18n("ntf"+c):this.i18n("ntfsmth"),d=this.ui.notify,e=d.children(".finder-notify-"+c),f=a.cnt,g=0<=a.progress&&100>=a.progress?a.progress:0,h;if(!c)return this;e.length||(e=$('<div class="finder-notify finder-notify-{type}"><span class="finder-dialog-icon finder-dialog-icon-{type}"/><span class="finder-notify-msg">{msg}</span> <span class="finder-notify-cnt"/><div class="finder-notify-progressbar"><div class="finder-notify-progress"/></div></div>'.replace(/\{type\}/g,
c).replace(/\{msg\}/g,b)).appendTo(d).data("cnt",0),g&&e.data({progress:0,total:0}));c=f+parseInt(e.data("cnt"));if(0<c){if(!a.hideCnt&&e.children(".finder-notify-cnt").text("("+c+")"),d.is(":hidden")&&d.finderdialog("open"),e.data("cnt",c),100>g&&0<=e.data("total")&&0<=(h=e.data("progress")))a=f+parseInt(e.data("total")),h=g+h,g=parseInt(h/a),e.data({progress:h,total:a}),d.find(".finder-notify-progress").animate({width:(100>g?g:100)+"%"},20)}else e.remove(),!d.children().length&&d.finderdialog("close");
return this},confirm:function(a){var c=!1,b={cssClass:"finder-dialog-confirm",modal:!0,resizable:!1,title:this.i18n(a.title||"confirmReq"),buttons:{},close:function(){!c&&a.cancel.callback();$(this).finderdialog("destroy")}},d=this.i18n("apllyAll"),e;a.reject&&(b.buttons[this.i18n(a.reject.label)]=function(){a.reject.callback(!(!e||!e.prop("checked")));c=!0;$(this).finderdialog("close")});b.buttons[this.i18n(a.accept.label)]=function(){a.accept.callback(!(!e||!e.prop("checked")));c=!0;$(this).finderdialog("close")};
b.buttons[this.i18n(a.cancel.label)]=function(){$(this).finderdialog("close")};a.all&&(a.reject&&(b.width=370),b.create=function(){e=$('<input type="checkbox" />');$(this).next().children().before($("<label>"+d+"</label>").prepend(e))},b.open=function(){var a=$(this).next(),b=parseInt(a.children(":first").outerWidth()+a.children(":last").outerWidth());b>parseInt(a.width())&&$(this).closest(".finder-dialog").width(b+30)});return this.dialog('<span class="finder-dialog-icon finder-dialog-icon-confirm"/>'+
this.i18n(a.text),b)},uniqueName:function(a,c){var b=0,d="",e,a=this.i18n(a),c=c||this.cwd().hash;if(-1!=(e=a.indexOf(".txt")))d=".txt",a=a.substr(0,e);e=a+d;if(!this.fileByName(e,c))return e;for(;1E4>b;)if(e=a+" "+ ++b+d,!this.fileByName(e,c))return e;return a+Math.random()+d},i18n:function(){var a=this,c=this.messages,b=[],d=[],e=function(b){var c;return 0===b.indexOf("#")&&(c=a.file(b.substr(1)))?c.name:b},f,g,h;for(f=0;f<arguments.length;f++)if(h=arguments[f],"string"==typeof h)b.push(e(h));else if($.isArray(h))for(g=
0;g<h.length;g++)"string"==typeof h[g]&&b.push(e(h[g]));for(f=0;f<b.length;f++)-1===$.inArray(f,d)&&(h=b[f],h=c[h]||h,h=h.replace(/\$(\d+)/g,function(a,c){c=f+parseInt(c);0<c&&b[c]&&d.push(c);return b[c]||""}),b[f]=h);return $.map(b,function(a,b){return-1===$.inArray(b,d)?a:null}).join("<br>")},formatDate:function(a,c){var b=this,c=c||a.ts,d=b.i18,e,f,g,h,i,j,m,k,l;return b.options.clientFormatDate&&0<c?(e=new Date(1E3*c),j=e[b.getHours](),m=12<j?j-12:j,k=e[b.getMinutes](),l=e[b.getSeconds](),f=e[b.getDate](),
g=e[b.getDay](),h=e[b.getMonth]()+1,i=e[b.getFullYear](),e=c>=this.yesterday?this.fancyFormat:this.dateFormat,e=e.replace(/[a-z]/gi,function(a){switch(a){case "d":return 9<f?f:"0"+f;case "j":return f;case "D":return b.i18n(d.daysShort[g]);case "l":return b.i18n(d.days[g]);case "m":return 9<h?h:"0"+h;case "n":return h;case "M":return b.i18n(d.monthsShort[h-1]);case "F":return b.i18n(d.months[h-1]);case "Y":return i;case "y":return(""+i).substr(2);case "H":return 9<j?j:"0"+j;case "G":return j;case "g":return m;
case "h":return 9<m?m:"0"+m;case "a":return 12<j?"pm":"am";case "A":return 12<j?"PM":"AM";case "i":return 9<k?k:"0"+k;case "s":return 9<l?l:"0"+l}return a}),c>=this.yesterday?e.replace("$1",this.i18n(c>=this.today?"Today":"Yesterday")):e):a.date?a.date.replace(/([a-z]+)\s/i,function(a,c){return b.i18n(c)+" "}):b.i18n("dateUnknown")},perms2class:function(a){var c="";!a.read&&!a.write?c="finder-na":a.read?a.write||(c="finder-ro"):c="finder-wo";return c},formatPermissions:function(a){var c=[];a.read&&
c.push(this.i18n("read"));a.write&&c.push(this.i18n("write"));return c.length?c.join(" "+this.i18n("and")+" "):this.i18n("noaccess")},formatSize:function(a){var c=1,b="b";if("unknown"==a)return this.i18n("unknown");1073741824<a?(c=1073741824,b="GB"):1048576<a?(c=1048576,b="MB"):1024<a&&(c=1024,b="KB");a/=c;return(0<a?1048576<=c?a.toFixed(2):Math.round(a):0)+" "+b},navHash2Id:function(a){return"nav-"+a},navId2Hash:function(a){return"string"==typeof a?a.substr(4):!1},log:function(a){window.console&&
window.console.log&&window.console.log(a);return this},debug:function(a,c){var b=this.options.debug;("all"==b||!0===b||$.isArray(b)&&-1!=$.inArray(a,b))&&window.console&&window.console.log&&window.console.log("finder debug: ["+a+"] ["+this.id+"]",c);return this},time:function(a){window.console&&window.console.time&&window.console.time(a)},timeEnd:function(a){window.console&&window.console.timeEnd&&window.console.timeEnd(a)}};Finder.prototype.version="2.0 rc3";
$.fn.finder=function(a){return"instance"==a?this.getFinder():this.each(function(){var c="string"==typeof a?a:"";this.finder||new Finder(this,"object"==typeof a?a:{});switch(c){case "close":case "hide":this.finder.hide();break;case "open":case "show":this.finder.show();break;case "destroy":this.finder.destroy()}})};$.fn.getFinder=function(){var a;this.each(function(){if(this.finder)return a=this.finder,!1});return a};
Finder.prototype._options={url:"",requestType:"get",transport:{},urlUpload:"",dragUploadAllow:"auto",iframeTimeout:0,customData:{},handlers:{},lang:"en",cssClass:"",commands:"open reload home up back forward getfile quicklook download rm duplicate rename mkdir mkfile upload copy cut paste edit extract archive search info view help resize sort netmount unmount".split(" "),commandsOptions:{getfile:{onlyURL:!1,multiple:!1,folders:!1,oncomplete:""},upload:{ui:"uploadbutton"},quicklook:{autoplay:!0,jplayer:"extensions/jplayer"},
edit:{mimes:[],editors:[]},help:{view:["about","shortcuts","help"]}},getFileCallback:null,defaultView:"icons",ui:["toolbar","tree","path","stat"],uiOptions:{toolbar:[["back","forward","up","reload"],["home","netmount"],["mkdir","mkfile","upload"],["open","download","getfile"],["info","quicklook"],["copy","cut","paste"],["rm"],["duplicate","rename","edit","resize"],["extract","archive"],["view","sort"],["help"],["search"]],tree:{openRootOnLoad:!0,syncTree:!0},navbar:{minWidth:150,maxWidth:500},cwd:{oldSchool:!1}},
onlyMimes:[],sortRules:{},sortType:"name",sortOrder:"asc",sortStickFolders:!0,clientFormatDate:!0,UTCDate:!1,dateFormat:"",fancyDateFormat:"",width:"auto",height:400,resizable:!0,notifyDelay:500,allowShortcuts:!0,rememberLastDir:!0,showFiles:30,showThreshold:50,validName:!1,sync:0,loadTmbs:5,cookie:{expires:30,domain:"",path:"/",secure:!1},contextmenu:{navbar:"open | copy cut paste duplicate | rm | info | unmount".split(" "),cwd:"reload back | upload mkdir mkfile paste | sort | info".split(" "),files:"getfile | open quicklook | download | copy cut paste duplicate | rm | edit rename resize | archive extract | info".split(" ")},
debug:["error","warning","event-destroy"]};
Finder.prototype.history=function(a){var c=this,b=!0,d=[],e,f=function(){d=[a.cwd().hash];e=0;b=!0},g=function(g){return g&&c.canForward()||!g&&c.canBack()?(b=!1,a.exec("open",d[g?++e:--e]).fail(f)):$.Deferred().reject()};this.canBack=function(){return 0<e};this.canForward=function(){return e<d.length-1};this.back=g;this.forward=function(){return g(!0)};a.open(function(){var c=d.length,f=a.cwd().hash;b&&(0<=e&&c>e+1&&d.splice(e+1),d[d.length-1]!=f&&d.push(f),e=d.length-1);b=!0}).reload(f)};
Finder.prototype.command=function(a){this.fm=a;this.title=this.name="";this.state=-1;this.disableOnSearch=this._disabled=this.alwaysEnabled=!1;this.updateOnSelect=!0;this._handlers={enable:function(){this.update(void 0,this.value)},disable:function(){this.update(-1,this.value)},"open reload load":function(){this._disabled=!(this.alwaysEnabled||this.fm.isCommandEnabled(this.name));this.update(void 0,this.value);this.change()}};this.handlers={};this.shortcuts=[];this.options={ui:"button"};this.setup=
function(a,b){var d=this,e=this.fm,f,g;this.name=a;this.title=e.messages["cmd"+a]?e.i18n("cmd"+a):a;this.options=$.extend({},this.options,b);this.listeners=[];this.updateOnSelect&&(this._handlers.select=function(){this.update(void 0,this.value)});$.each($.extend({},d._handlers,d.handlers),function(a,b){e.bind(a,$.proxy(b,d))});for(f=0;f<this.shortcuts.length;f++)g=this.shortcuts[f],g.callback=$.proxy(g.callback||function(){this.exec()},this),!g.description&&(g.description=this.title),e.shortcut(g);
this.disableOnSearch&&e.bind("search searchend",function(a){d._disabled="search"==a.type;d.update(void 0,d.value)});this.init()};this.init=function(){};this.exec=function(){return $.Deferred().reject()};this.disabled=function(){return 0>this.state};this.enabled=function(){return-1<this.state};this.active=function(){return 0<this.state};this.getstate=function(){return-1};this.update=function(a,b){var d=this.state,e=this.value;this.state=this._disabled?-1:void 0!==a?a:this.getstate();this.value=b;(d!=
this.state||e!=this.value)&&this.change()};this.change=function(a){var b;if("function"===typeof a)this.listeners.push(a);else for(b=0;b<this.listeners.length;b++){a=this.listeners[b];try{a(this.state,this.value)}catch(d){this.fm.debug("error",d)}}return this};this.hashes=function(c){return c?$.map($.isArray(c)?c:[c],function(b){return a.file(b)?b:null}):a.selected()};this.files=function(a){var b=this.fm;return a?$.map($.isArray(a)?a:[a],function(a){return b.file(a)||null}):b.selectedFiles()}};
Finder.prototype.resources={"class":{hover:"ui-state-hover",active:"ui-state-active",disabled:"ui-state-disabled",draggable:"ui-draggable",droppable:"ui-droppable",adroppable:"finder-droppable-active",cwdfile:"finder-cwd-file",cwd:"finder-cwd",tree:"finder-tree",treeroot:"finder-navbar-root",navdir:"finder-navbar-dir",navdirwrap:"finder-navbar-dir-wrapper",navarrow:"finder-navbar-arrow",navsubtree:"finder-navbar-subtree",navcollapse:"finder-navbar-collapsed",navexpand:"finder-navbar-expanded",treedir:"finder-tree-dir",
placedir:"finder-place-dir",searchbtn:"finder-button-search"},tpl:{perms:'<span class="finder-perms"/>',symlink:'<span class="finder-symlink"/>',navicon:'<span class="finder-nav-icon"/>',navspinner:'<span class="finder-navbar-spinner"/>',navdir:'<div class="finder-navbar-wrapper"><span id="{id}" class="ui-corner-all finder-navbar-dir {cssclass}"><span class="finder-navbar-arrow"/><span class="finder-navbar-icon"/>{symlink}{permissions}{name}</span><div class="finder-navbar-subtree"/></div>'},mimes:{text:"application/x-empty application/javascript application/xhtml+xml audio/x-mp3-playlist application/x-web-config application/docbook+xml application/x-php application/x-perl application/x-awk application/x-config application/x-csh application/xml".split(" ")},
mixin:{make:function(){var a=this.fm,c=this.name,b=a.getUI("cwd"),d=$.Deferred().fail(function(c){b.trigger("unselectall");c&&a.error(c)}).always(function(){i.remove();h.remove();a.enable()}),e="tmp_"+parseInt(1E5*Math.random()),f=a.cwd().hash,g=new Date,g={hash:e,name:a.uniqueName(this.prefix),mime:this.mime,read:!0,write:!0,date:"Today "+g.getHours()+":"+g.getMinutes()},h=b.trigger("create."+a.namespace,g).find("#"+e),i=$('<input type="text"/>').keydown(function(a){a.stopImmediatePropagation();
a.keyCode==$.ui.keyCode.ESCAPE?d.reject():a.keyCode==$.ui.keyCode.ENTER&&i.blur()}).mousedown(function(a){a.stopPropagation()}).blur(function(){var b=$.trim(i.val()),g=i.parent();if(g.length){if(!b)return d.reject("errInvName");if(a.fileByName(b,f))return d.reject(["errExists",b]);g.html(a.escape(b));a.lockfiles({files:[e]});a.request({data:{cmd:c,name:b,target:f},notify:{type:c,cnt:1},preventFail:!0,syncOnFail:!0}).fail(function(a){d.reject(a)}).done(function(a){d.resolve(a)})}});if(this.disabled()||
!h.length)return d.reject();a.disable();h.find(".finder-cwd-filename").empty("").append(i.val(g.name));i.select().focus();return d}}};
Finder.prototype.kinds={unknown:"Unknown",directory:"Folder",symlink:"Alias","symlink-broken":"AliasBroken","application/x-empty":"TextPlain","application/postscript":"Postscript","application/vnd.ms-office":"MsOffice","application/vnd.ms-word":"MsWord","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"MsWord","application/vnd.ms-word.document.macroEnabled.12":"MsWord","application/vnd.openxmlformats-officedocument.wordprocessingml.template":"MsWord","application/vnd.ms-word.template.macroEnabled.12":"MsWord",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"MsWord","application/vnd.ms-excel":"MsExcel","application/vnd.ms-excel.sheet.macroEnabled.12":"MsExcel","application/vnd.openxmlformats-officedocument.spreadsheetml.template":"MsExcel","application/vnd.ms-excel.template.macroEnabled.12":"MsExcel","application/vnd.ms-excel.sheet.binary.macroEnabled.12":"MsExcel","application/vnd.ms-excel.addin.macroEnabled.12":"MsExcel","application/vnd.ms-powerpoint":"MsPP","application/vnd.openxmlformats-officedocument.presentationml.presentation":"MsPP",
"application/vnd.ms-powerpoint.presentation.macroEnabled.12":"MsPP","application/vnd.openxmlformats-officedocument.presentationml.slideshow":"MsPP","application/vnd.ms-powerpoint.slideshow.macroEnabled.12":"MsPP","application/vnd.openxmlformats-officedocument.presentationml.template":"MsPP","application/vnd.ms-powerpoint.template.macroEnabled.12":"MsPP","application/vnd.ms-powerpoint.addin.macroEnabled.12":"MsPP","application/vnd.openxmlformats-officedocument.presentationml.slide":"MsPP","application/vnd.ms-powerpoint.slide.macroEnabled.12":"MsPP",
"application/pdf":"PDF","application/xml":"XML","application/vnd.oasis.opendocument.text":"OO","application/vnd.oasis.opendocument.text-template":"OO","application/vnd.oasis.opendocument.text-web":"OO","application/vnd.oasis.opendocument.text-master":"OO","application/vnd.oasis.opendocument.graphics":"OO","application/vnd.oasis.opendocument.graphics-template":"OO","application/vnd.oasis.opendocument.presentation":"OO","application/vnd.oasis.opendocument.presentation-template":"OO","application/vnd.oasis.opendocument.spreadsheet":"OO",
"application/vnd.oasis.opendocument.spreadsheet-template":"OO","application/vnd.oasis.opendocument.chart":"OO","application/vnd.oasis.opendocument.formula":"OO","application/vnd.oasis.opendocument.database":"OO","application/vnd.oasis.opendocument.image":"OO","application/vnd.openofficeorg.extension":"OO","application/x-shockwave-flash":"AppFlash","application/flash-video":"Flash video","application/x-bittorrent":"Torrent","application/javascript":"JS","application/rtf":"RTF","application/rtfd":"RTF",
"application/x-font-ttf":"TTF","application/x-font-otf":"OTF","application/x-rpm":"RPM","application/x-web-config":"TextPlain","application/xhtml+xml":"HTML","application/docbook+xml":"DOCBOOK","application/x-awk":"AWK","application/x-gzip":"GZIP","application/x-bzip2":"BZIP","application/zip":"ZIP","application/x-zip":"ZIP","application/x-rar":"RAR","application/x-tar":"TAR","application/x-7z-compressed":"7z","application/x-jar":"JAR","text/plain":"TextPlain","text/x-php":"PHP","text/html":"HTML",
"text/javascript":"JS","text/css":"CSS","text/rtf":"RTF","text/rtfd":"RTF","text/x-c":"C","text/x-csrc":"C","text/x-chdr":"CHeader","text/x-c++":"CPP","text/x-c++src":"CPP","text/x-c++hdr":"CPPHeader","text/x-shellscript":"Shell","application/x-csh":"Shell","text/x-python":"Python","text/x-java":"Java","text/x-java-source":"Java","text/x-ruby":"Ruby","text/x-perl":"Perl","text/x-sql":"SQL","text/xml":"XML","text/x-comma-separated-values":"CSV","image/x-ms-bmp":"BMP","image/jpeg":"JPEG","image/gif":"GIF",
"image/png":"PNG","image/tiff":"TIFF","image/x-targa":"TGA","image/vnd.adobe.photoshop":"PSD","image/xbm":"XBITMAP","image/pxm":"PXM","audio/mpeg":"AudioMPEG","audio/midi":"AudioMIDI","audio/ogg":"AudioOGG","audio/mp4":"AudioMPEG4","audio/x-m4a":"AudioMPEG4","audio/wav":"AudioWAV","audio/x-mp3-playlist":"AudioPlaylist","video/x-dv":"VideoDV","video/mp4":"VideoMPEG4","video/mpeg":"VideoMPEG","video/x-msvideo":"VideoAVI","video/quicktime":"VideoMOV","video/x-ms-wmv":"VideoWM","video/x-flv":"VideoFlash",
"video/x-matroska":"VideoMKV","video/ogg":"VideoOGG"};Finder.prototype.mime2kind=function(a){var c="object"==typeof a?a.mime:a,a=a.alias?"Alias":this.kinds[c]?this.kinds[c]:0===c.indexOf("text")?"Text":0===c.indexOf("image")?"Image":0===c.indexOf("audio")?"Audio":0===c.indexOf("video")?"Video":0===c.indexOf("application")?"App":c;return this.messages["kind"+a]?this.i18n("kind"+a):c};
Finder.prototype.mime2class=function(a){a=a.split("/");return"finder-cwd-icon-"+a[0]+("image"!=a[0]&&a[1]?" finder-cwd-icon-"+a[1].replace(/(\.|\+)/g,"-"):"")};
$.fn.dialogfinder=function(a){this.not(".finder").each(function(){$(document);var b=$('<div class="ui-widget-header dialogfinder-drag ui-corner-top">'+(a.title||"Files")+"</div>");$('<a href="#" class="dialogfinder-drag-close ui-corner-all"><span class="ui-icon ui-icon-closethick"/></a>').appendTo(b).click(function(a){a.preventDefault();c.dialogfinder("close")});var c=$(this).addClass("dialogfinder").css("position","absolute").hide().appendTo("body").draggable({handle:".dialogfinder-drag",containment:"window"}).finder(a).prepend(b);
c.finder("instance");c.width(parseInt(c.width())||840).data("finderDestroyOnClose",!!a.destroyOnClose).find(".finder-toolbar").removeClass("ui-corner-top");a.position&&c.data("finderPosition",a.position);!1!==a.autoOpen&&$(this).dialogfinder("open")});if("open"==a){var c=$(this),b=c.data("finderPosition")||{top:parseInt($(document).scrollTop()+($(window).height()<c.height()?2:($(window).height()-c.height())/2)),left:parseInt($(document).scrollLeft()+($(window).width()<c.width()?2:($(window).width()-
c.width())/2))},d=100;c.is(":hidden")&&($("body").find(":visible").each(function(){var a=$(this),b;if(this!==c[0]&&"absolute"==a.css("position")&&(b=parseInt(a.zIndex()))>d)d=b+1}),c.zIndex(d).css(b).show().trigger("resize"),setTimeout(function(){c.trigger("resize").mousedown()},200))}else if("close"==a)c=$(this),c.is(":visible")&&(c.data("finderDestroyOnClose")?c.finder("destroy").remove():c.finder("close"));else if("instance"==a)return $(this).getFinder();return this};
Finder&&Finder.prototype&&"object"==typeof Finder.prototype.i18&&(Finder.prototype.i18.en={translator:"Troex Nevelin &lt;troex@fury.scancode.ru&gt;",language:"English",direction:"ltr",dateFormat:"M d, Y h:i A",fancyDateFormat:"$1 h:i A",messages:{error:"Error",errUnknown:"Unknown error.",errUnknownCmd:"Unknown command.",errJqui:"Invalid jQuery UI configuration. Selectable, draggable and droppable components must be included.",errNode:"gpFinder requires DOM Element to be created.",errURL:"Invalid gpFinder configuration! URL option is not set.",
errAccess:"Access denied.",errConnect:"Unable to connect to backend.",errAbort:"Connection aborted.",errTimeout:"Connection timeout.",errNotFound:"Backend not found.",errResponse:"Invalid backend response.",errConf:"Invalid backend configuration.",errJSON:"PHP JSON module not installed.",errNoVolumes:"Readable volumes not available.",errCmdParams:'Invalid parameters for command "$1".',errDataNotJSON:"Data is not JSON.",errDataEmpty:"Data is empty.",errCmdReq:"Backend request requires command name.",
errOpen:'Unable to open "$1".',errNotFolder:"Object is not a folder.",errNotFile:"Object is not a file.",errRead:'Unable to read "$1".',errWrite:'Unable to write into "$1".',errPerm:"Permission denied.",errLocked:'"$1" is locked and can not be renamed, moved or removed.',errExists:'File named "$1" already exists.',errInvName:"Invalid file name.",errFolderNotFound:"Folder not found.",errFileNotFound:"File not found.",errTrgFolderNotFound:'Target folder "$1" not found.',errPopup:"Browser prevented opening popup window. To open file enable it in browser options.",
errMkdir:'Unable to create folder "$1".',errMkfile:'Unable to create file "$1".',errRename:'Unable to rename "$1".',errCopyFrom:'Copying files from volume "$1" not allowed.',errCopyTo:'Copying files to volume "$1" not allowed.',errUpload:"Upload error.",errUploadFile:'Unable to upload "$1".',errUploadNoFiles:"No files found for upload.",errUploadTotalSize:"Data exceeds the maximum allowed size.",errUploadFileSize:"File exceeds maximum allowed size.",errUploadMime:"File type not allowed.",errUploadTransfer:'"$1" transfer error.',
errNotReplace:'Object "$1" already exists at this location and can not be replaced by object with another type.',errReplace:'Unable to replace "$1".',errSave:'Unable to save "$1".',errCopy:'Unable to copy "$1".',errMove:'Unable to move "$1".',errCopyInItself:'Unable to copy "$1" into itself.',errRm:'Unable to remove "$1".',errRmSrc:"Unable remove source file(s).",errExtract:'Unable to extract files from "$1".',errArchive:"Unable to create archive.",errArcType:"Unsupported archive type.",errNoArchive:"File is not archive or has unsupported archive type.",
errCmdNoSupport:"Backend does not support this command.",errReplByChild:"The folder \u201c$1\u201d can\u2019t be replaced by an item it contains.",errArcSymlinks:"For security reason denied to unpack archives contains symlinks or files with not allowed names.",errArcMaxSize:"Archive files exceeds maximum allowed size.",errResize:'Unable to resize "$1".',errUsupportType:"Unsupported file type.",errNotUTF8Content:'File "$1" is not in UTF-8 and cannot be edited.',errNetMount:'Unable to mount "$1".',
errNetMountNoDriver:"Unsupported protocol.",errNetMountFailed:"Mount failed.",errNetMountHostReq:"Host required.",cmdarchive:"Create archive",cmdback:"Back",cmdcopy:"Copy",cmdcut:"Cut",cmddownload:"Download",cmdduplicate:"Duplicate",cmdedit:"Edit file",cmdextract:"Extract files from archive",cmdforward:"Forward",cmdgetfile:"Select files",cmdhelp:"About this software",cmdhome:"Home",cmdinfo:"Get info",cmdmkdir:"New folder",cmdmkfile:"New text file",cmdopen:"Open",cmdpaste:"Paste",cmdquicklook:"Preview",
cmdreload:"Reload",cmdrename:"Rename",cmdrm:"Delete",cmdsearch:"Find files",cmdup:"Go to parent directory",cmdupload:"Upload files",cmdview:"View",cmdresize:"Resize & Rotate",cmdsort:"Sort",cmdnetmount:"Mount network volume",btnClose:"Close",btnSave:"Save",btnRm:"Remove",btnApply:"Apply",btnCancel:"Cancel",btnNo:"No",btnYes:"Yes",btnMount:"Mount",ntfopen:"Open folder",ntffile:"Open file",ntfreload:"Reload folder content",ntfmkdir:"Creating directory",ntfmkfile:"Creating files",ntfrm:"Delete files",
ntfcopy:"Copy files",ntfmove:"Move files",ntfprepare:"Prepare to copy files",ntfrename:"Rename files",ntfupload:"Uploading files",ntfdownload:"Downloading files",ntfsave:"Save files",ntfarchive:"Creating archive",ntfextract:"Extracting files from archive",ntfsearch:"Searching files",ntfresize:"Resizing images",ntfsmth:"Loading",ntfloadimg:"Loading image",ntfnetmount:"Mounting network volume",dateUnknown:"unknown",Today:"Today",Yesterday:"Yesterday",Jan:"Jan",Feb:"Feb",Mar:"Mar",Apr:"Apr",May:"May",
Jun:"Jun",Jul:"Jul",Aug:"Aug",Sep:"Sep",Oct:"Oct",Nov:"Nov",Dec:"Dec",sortname:"by name",sortkind:"by kind",sortsize:"by size",sortdate:"by date",sortFoldersFirst:"Folders first",confirmReq:"Confirmation required",confirmRm:"Are you sure you want to remove files?<br/>This cannot be undone!",confirmRepl:"Replace old file with new one?",apllyAll:"Apply to all",name:"Name",size:"Size",perms:"Permissions",modify:"Modified",kind:"Kind",read:"read",write:"write",noaccess:"no access",and:"and",unknown:"unknown",
selectall:"Select all files",selectfiles:"Select file(s)",selectffile:"Select first file",selectlfile:"Select last file",viewlist:"List view",viewicons:"Icons view",places:"Places",calc:"Calculate",path:"Path",aliasfor:"Alias for",locked:"Locked",dim:"Dimensions",files:"Files",folders:"Folders",items:"Items",yes:"yes",no:"no",link:"Link",searcresult:"Search results",selected:"selected items",about:"About",shortcuts:"Shortcuts",help:"Help",webfm:"Web file manager",ver:"Version",protocolver:"protocol version",
homepage:"Project home",docs:"Documentation",github:"Fork us on Github",twitter:"Follow us on twitter",facebook:"Join us on facebook",team:"Team",chiefdev:"chief developer",developer:"developer",contributor:"contributor",maintainer:"maintainer",translator:"translator",icons:"Icons",dontforget:"and don't forget to take your towel",shortcutsof:"Shortcuts disabled",dropFiles:"Drop files here",or:"or",selectForUpload:"Select files to upload",moveFiles:"Move files",copyFiles:"Copy files",rmFromPlaces:"Remove from places",
aspectRatio:"Aspect ratio",scale:"Scale",width:"Width",height:"Height",resize:"Resize",crop:"Crop",rotate:"Rotate","rotate-cw":"Rotate 90 degrees CW","rotate-ccw":"Rotate 90 degrees CCW",degree:"\u00b0",netMountDialogTitle:"Mount network volume",protocol:"Protocol",host:"Host",port:"Port",user:"User",pass:"Password",kindUnknown:"Unknown",kindFolder:"Folder",kindAlias:"Alias",kindAliasBroken:"Broken alias",kindApp:"Application",kindPostscript:"Postscript document",kindMsOffice:"Microsoft Office document",
kindMsWord:"Microsoft Word document",kindMsExcel:"Microsoft Excel document",kindMsPP:"Microsoft Powerpoint presentation",kindOO:"Open Office document",kindAppFlash:"Flash application",kindPDF:"Portable Document Format (PDF)",kindTorrent:"Bittorrent file",kind7z:"7z archive",kindTAR:"TAR archive",kindGZIP:"GZIP archive",kindBZIP:"BZIP archive",kindZIP:"ZIP archive",kindRAR:"RAR archive",kindJAR:"Java JAR file",kindTTF:"True Type font",kindOTF:"Open Type font",kindRPM:"RPM package",kindText:"Text document",
kindTextPlain:"Plain text",kindPHP:"PHP source",kindCSS:"Cascading style sheet",kindHTML:"HTML document",kindJS:"Javascript source",kindRTF:"Rich Text Format",kindC:"C source",kindCHeader:"C header source",kindCPP:"C++ source",kindCPPHeader:"C++ header source",kindShell:"Unix shell script",kindPython:"Python source",kindJava:"Java source",kindRuby:"Ruby source",kindPerl:"Perl script",kindSQL:"SQL source",kindXML:"XML document",kindAWK:"AWK source",kindCSV:"Comma separated values",kindDOCBOOK:"Docbook XML document",
kindImage:"Image",kindBMP:"BMP image",kindJPEG:"JPEG image",kindGIF:"GIF Image",kindPNG:"PNG Image",kindTIFF:"TIFF image",kindTGA:"TGA image",kindPSD:"Adobe Photoshop image",kindXBITMAP:"X bitmap image",kindPXM:"Pixelmator image",kindAudio:"Audio media",kindAudioMPEG:"MPEG audio",kindAudioMPEG4:"MPEG-4 audio",kindAudioMIDI:"MIDI audio",kindAudioOGG:"Ogg Vorbis audio",kindAudioWAV:"WAV audio",AudioPlaylist:"MP3 playlist",kindVideo:"Video media",kindVideoDV:"DV movie",kindVideoMPEG:"MPEG movie",kindVideoMPEG4:"MPEG-4 movie",
kindVideoAVI:"AVI movie",kindVideoMOV:"Quick Time movie",kindVideoWM:"Windows Media movie",kindVideoFlash:"Flash movie",kindVideoMKV:"Matroska movie",kindVideoOGG:"Ogg movie"}});
$.fn.finderbutton=function(a){return this.each(function(){var c=a.fm,b=c.res("class","disabled"),d=c.res("class","active"),e=c.res("class","hover"),f,g=$(this).addClass("ui-state-default finder-button").attr("title",a.title).append('<span class="finder-button-icon finder-button-icon-'+a.name+'"/>').hover(function(a){!g.is("."+b)&&g["mouseleave"==a.type?"removeClass":"addClass"](e)}).click(function(c){g.is("."+b)||(f&&1<a.variants.length?(f.is(":hidden")&&a.fm.getUI().click(),c.stopPropagation(),f.slideToggle(100)):
a.exec())}),c=function(){f.hide()};$.isArray(a.variants)&&(g.addClass("finder-menubutton"),f=$('<div class="ui-widget ui-widget-content finder-button-menu ui-corner-all"/>').hide().appendTo(g).zIndex(12+g.zIndex()).delegate(".finder-button-menu-item","hover",function(){$(this).toggleClass(e)}).delegate(".finder-button-menu-item","click",function(b){b.preventDefault();b.stopPropagation();g.removeClass(e);a.exec(a.fm.selected(),$(this).data("value"))}),a.fm.bind("disable select",c).getUI().click(c),
a.change(function(){f.html("");$.each(a.variants,function(b,c){f.append($('<div class="finder-button-menu-item">'+c[1]+"</div>").data("value",c[0]).addClass(c[0]==a.value?"finder-button-menu-item-selected":""))})}));a.change(function(){a.disabled()?g.removeClass(d+" "+e).addClass(b):(g.removeClass(b),g[a.active()?"addClass":"removeClass"](d))}).change()})};
$.fn.findercontextmenu=function(a){return this.each(function(){var c=$(this).addClass("ui-helper-reset ui-widget ui-state-default ui-corner-all finder-contextmenu finder-contextmenu-"+a.direction).hide().appendTo("body").delegate(".finder-contextmenu-item","hover",function(){$(this).toggleClass("ui-state-hover")}),b="ltr"==a.direction?"left":"right",d=$.extend({},a.options.contextmenu),e=function(a,b,c){return $('<div class="finder-contextmenu-item"><span class="finder-button-icon {icon} finder-contextmenu-icon"/><span>{label}</span></div>'.replace("{icon}",
b?"finder-button-icon-"+b:"").replace("{label}",a)).click(function(a){a.stopPropagation();a.stopPropagation();c()})},f=function(){c.hide().empty()};a.one("load",function(){a.bind("contextmenu",function(g){var h=g.data;f();if(h.type&&h.targets){var i=h.targets,j=!1;$.each(d[h.type]||[],function(b,d){var g,h,k;if("|"==d&&j)c.append('<div class="finder-contextmenu-separator"/>'),j=!1;else if((g=a.command(d))&&-1!=g.getstate(i)){if(g.variants){if(!g.variants.length)return;h=e(g.title,g.name,function(){});
k=$('<div class="ui-corner-all finder-contextmenu-sub"/>').appendTo(h.append('<span class="finder-contextmenu-arrow"/>'));h.addClass("finder-contextmenu-group").hover(function(){k.toggle()});$.each(g.variants,function(a,b){k.append($('<div class="finder-contextmenu-item"><span>'+b[1]+"</span></div>").click(function(a){a.stopPropagation();f();g.exec(i,b[0])}))})}else h=e(g.title,g.name,function(){f();g.exec(i)});c.append(h);j=!0}})}if(c.children().length){var g=h.x,h=h.y,m=$(window),k=c.outerWidth(),
l=c.outerHeight(),n=m.width(),q=m.height(),s=m.scrollTop(),m=m.scrollLeft(),g={top:(h+l<q?h:0<h-l?h-l:h)+s,left:(g+k<n?g:g-k)+m,"z-index":100+a.getUI("workzone").zIndex()};c.css(g).show();g={"z-index":g["z-index"]+10};g[b]=parseInt(c.width());c.find(".finder-contextmenu-sub").css(g)}}).one("destroy",function(){c.remove()}).bind("disable select",f).getUI().click(f)})})};
$.fn.findercwd=function(a,c){this.not(".finder-cwd").each(function(){var b="list"==a.viewType,d="select."+a.namespace,e="unselect."+a.namespace,f="disable."+a.namespace,g="enable."+a.namespace,h=a.res("class","cwdfile"),i="."+h,j=a.res("class","disabled"),m=a.res("class","draggable"),k=a.res("class","droppable"),l=a.res("class","hover"),n=a.res("class","adroppable"),q=h+"-tmp",s=0<a.options.loadTmbs?a.options.loadTmbs:5,r="",t=[],y={icon:'<div id="{hash}" class="'+h+' {permsclass} {dirclass} ui-corner-all" title="{tooltip}"><div class="finder-cwd-file-wrapper ui-corner-all"><div class="finder-cwd-icon {mime} ui-corner-all" unselectable="on" {style}/>{marker}</div><div class="finder-cwd-filename" title="{name}">{name}</div></div>',
row:'<tr id="{hash}" class="'+h+' {permsclass} {dirclass}" title="{tooltip}"><td><div class="finder-cwd-file-wrapper"><span class="finder-cwd-icon {mime}"/>{marker}<span class="finder-cwd-filename">{name}</span></div></td><td>{perms}</td><td>{date}</td><td>{size}</td><td>{kind}</td></tr>'},C=a.res("tpl","perms"),G=a.res("tpl","symlink"),L={permsclass:function(b){return a.perms2class(b)},perms:function(b){return a.formatPermissions(b)},dirclass:function(a){return"directory"==a.mime?"directory":""},
mime:function(b){return a.mime2class(b.mime)},size:function(b){return a.formatSize(b.size)},date:function(b){return a.formatDate(b)},kind:function(b){return a.mime2kind(b)},marker:function(a){return(a.alias||"symlink-broken"==a.mime?G:"")+(!a.read||!a.write?C:"")},tooltip:function(b){var c=a.formatDate(b)+(0<b.size?" ("+a.formatSize(b.size)+")":"");return b.tooltip?a.escape(b.tooltip).replace(/"/g,"&quot;").replace(/\r/g,"&#13;")+"&#13;"+c:c}},I=function(c){c.name=a.escape(c.name);return y[b?"row":
"icon"].replace(/\{([a-z]+)\}/g,function(a,b){return L[b]?L[b](c):c[b]?c[b]:""})},J=!1,F=[],A=function(a){p.find("#"+a).trigger(d)},v=function(){F=[];p.find("[id].ui-selected").trigger(e);u()},u=function(){a.trigger("select",{selected:F})},D=function(a){var b=a.position().top,a=a.outerHeight(!0),c=z.scrollTop(),d=z.innerHeight();b+a>c+d?z.scrollTop(parseInt(b+a-d)):b<c&&z.scrollTop(b)},w=[],H=function(a){for(var b=w.length;b--;)if(w[b].hash==a)return b;return-1},K="scroll."+a.namespace,B=function(){var c=
[],e=!1,f=[],g={},c=p.find("[id]:last"),h=!c.length,i=b?p.children("table").children("tbody"):p,j;if(!w.length)return z.unbind(K);for(;(!c.length||c.position().top<=z.height()+z.scrollTop()+a.options.showThreshold)&&(j=w.splice(0,a.options.showFiles)).length;)c=$.map(j,function(a){return a.hash&&a.name?("directory"==a.mime&&(e=!0),a.tmb&&(1===a.tmb?f.push(a.hash):g[a.hash]=a.tmb),I(a)):null}),i.append(c.join("")),c=p.find("[id]:last"),h&&p.scrollTop(0);R(g);f.length&&M(f);e&&U();F.length&&i.find("[id]:not(.ui-selected):not(.finder-cwd-parent)").each(function(){-1!==
$.inArray(this.id,F)&&$(this).trigger(d)})},O=$.extend({},a.droppable,{over:function(b,c){var d=a.cwd().hash;$.each(c.helper.data("files"),function(b,c){if(a.file(c).phash==d)return p.removeClass(n),!1})}}),U=function(){setTimeout(function(){p.find(".directory:not(."+k+",.finder-na,.finder-ro)").droppable(a.droppable)},20)},R=function(b){var c=a.option("tmbUrl"),d=!0,e;$.each(b,function(a,b){var f=p.find("#"+a);if(f.length){var g=c+b;$("<img/>").load(function(){f.find(".finder-cwd-icon").css("background",
"url('"+g+"') center center no-repeat")}).attr("src",g)}else if(d=!1,-1!=(e=H(a)))w[e].tmb=b});return d},M=function(b){var c=[];a.oldAPI?a.request({data:{cmd:"tmb",current:a.cwd().hash},preventFail:!0}).done(function(a){R(a.images||[])&&a.tmb&&M()}):(c=c=b.splice(0,s),c.length&&a.request({data:{cmd:"tmb",targets:c},preventFail:!0}).done(function(a){R(a.images||[])&&M(b)}))},x=function(c){for(var d=b?p.find("tbody"):p,e=c.length,f=[],g={},h=!1,i,j,k,n;e--;)if(i=c[e],j=i.hash,!p.find("#"+j).length){var l;
a:{l=i;for(var m=p.find("[id]:first"),y=void 0;m.length;){y=a.file(m.attr("id"));if(!m.is(".finder-cwd-parent")&&y&&0>a.compare(l,y)){l=m;break a}m=m.next("[id]")}l=void 0}if((k=l)&&k.length)k.before(I(i));else{a:{l=i;m=w.length;for(y=0;y<m;y++)if(0>a.compare(l,w[y])){l=y;break a}l=m||-1}0<=(n=l)?w.splice(n,0,i):d.append(I(i))}p.find("#"+j).length&&("directory"==i.mime?h=!0:i.tmb&&(1===i.tmb?f.push(j):g[j]=i.tmb))}R(g);f.length&&M(f);h&&U()},S=function(b){for(var c=b.length,d,e,f;c--;)if(d=b[c],(e=
p.find("#"+d)).length)try{e.detach()}catch(g){a.debug("error",g)}else-1!=(f=H(d))&&w.splice(f,1)},P=a.i18n("name"),T=a.i18n("perms"),E=a.i18n("modify"),W=a.i18n("size"),N=a.i18n("kind"),Q=function(d,e){var f=a.cwd().hash;v();try{p.children("table,"+i).remove()}catch(g){p.html("")}p.removeClass("finder-cwd-view-icons finder-cwd-view-list").addClass("finder-cwd-view-"+(b?"list":"icons"));z[b?"addClass":"removeClass"]("finder-cwd-wrapper-list");b&&p.html('<table><thead><tr class="ui-state-default"><td >'+
P+"</td><td>"+T+"</td><td>"+E+"</td><td>"+W+"</td><td>"+N+"</td></tr></thead><tbody/></table>");w=$.map(d,function(a){return e||a.phash==f?a:null});w=a.sortFiles(w);z.bind(K,B).trigger(K);f=a.cwd().phash;if(c.oldSchool&&f&&!r){var h=$.extend(!0,{},a.file(f),{name:"..",mime:"directory"}),h=$(I(h)).addClass("finder-cwd-parent").bind("mousedown click mouseup dblclick mouseenter",function(a){a.preventDefault();a.stopPropagation()}).dblclick(function(){a.exec("open",this.id)});(b?p.find("tbody"):p).prepend(h)}},
p=$(this).addClass("ui-helper-clearfix finder-cwd").attr("unselectable","on").delegate(i,"click."+a.namespace,function(a){var b=this.id?$(this):$(this).parents("[id]:first"),c=b.prevAll(".ui-selected:first"),f=b.nextAll(".ui-selected:first"),g=c.length,h=f.length;a.stopImmediatePropagation();a.shiftKey&&(g||h)?(a=g?b.prevUntil("#"+c.attr("id")):b.nextUntil("#"+f.attr("id")),a.add(b).trigger(d)):a.ctrlKey||a.metaKey?b.trigger(b.is(".ui-selected")?e:d):(v(),b.trigger(d));u()}).delegate(i,"dblclick."+
a.namespace,function(){a.dblclick({file:this.id})}).delegate(i,"mouseenter."+a.namespace,function(){var c=$(this),d=b?c:c.children();!c.is("."+q)&&!d.is("."+m+",."+j)&&d.draggable(a.draggable)}).delegate(i,d,function(){var a=$(this),b=a.attr("id");!J&&!a.is("."+j)&&(a.addClass("ui-selected").children().addClass(l),-1===$.inArray(b,F)&&F.push(b))}).delegate(i,e,function(){var a=$(this).attr("id");J||($(this).removeClass("ui-selected").children().removeClass(l),a=$.inArray(a,F),-1!==a&&F.splice(a,1))}).delegate(i,
f,function(){var a=$(this).removeClass("ui-selected").addClass(j),c=(b?a:a.children()).removeClass(l);a.is("."+k)&&a.droppable("disable");c.is("."+m)&&c.draggable("disable");!b&&c.removeClass(j)}).delegate(i,g,function(){var a=$(this).removeClass(j),c=b?a:a.children();a.is("."+k)&&a.droppable("enable");c.is("."+m)&&c.draggable("enable")}).delegate(i,"scrolltoview",function(){D($(this))}).delegate(i,"hover",function(b){a.trigger("hover",{hash:$(this).attr("id"),type:b.type})}).bind("contextmenu."+
a.namespace,function(b){var c=$(b.target).closest("."+h);c.length&&(b.stopPropagation(),b.preventDefault(),c.is("."+j)||(c.is(".ui-selected")||(v(),c.trigger(d),u()),a.trigger("contextmenu",{type:"files",targets:a.selected(),x:b.clientX,y:b.clientY})))}).selectable({filter:i,stop:u,selected:function(a,b){$(b.selected).trigger(d)},unselected:function(a,b){$(b.unselected).trigger(e)}}).droppable(O).bind("create."+a.namespace,function(a,c){var d=b?p.find("tbody"):p,e=d.find(".finder-cwd-parent"),c=$(I(c)).addClass(q);
v();e.length?e.after(c):d.prepend(c);p.scrollTop(0)}).bind("unselectall",v).bind("selectfile",function(a,b){p.find("#"+b).trigger(d);u()}),z=$('<div class="finder-cwd-wrapper"/>').bind("contextmenu",function(b){b.preventDefault();a.trigger("contextmenu",{type:"cwd",targets:[a.cwd().hash],x:b.clientX,y:b.clientY})}),V=function(){var a=0;z.siblings(".finder-panel:visible").each(function(){a+=$(this).outerHeight(!0)});z.height(X.height()-a)},X=$(this).parent().resize(V).children(".finder-workzone").append(z.append(this));
a.dragUpload&&(z[0].addEventListener("dragenter",function(a){a.preventDefault();a.stopPropagation();z.addClass(n)},!1),z[0].addEventListener("dragleave",function(a){a.preventDefault();a.stopPropagation();a.target==p[0]&&z.removeClass(n)},!1),z[0].addEventListener("dragover",function(a){a.preventDefault();a.stopPropagation()},!1),z[0].addEventListener("drop",function(b){b.preventDefault();z.removeClass(n);b.dataTransfer&&b.dataTransfer.files&&b.dataTransfer.files.length&&a.exec("upload",{files:b.dataTransfer.files})},
!1));a.bind("open",function(a){Q(a.data.files)}).bind("search",function(a){t=a.data.files;Q(t,!0)}).bind("searchend",function(){t=[];r&&(r="",Q(a.files()))}).bind("searchstart",function(a){r=a.data.query}).bind("sortchange",function(){Q(r?t:a.files(),!!r)}).bind("viewchange",function(){var c=a.selected(),d="list"==a.storage("view");d!=b&&(b=d,Q(a.files()),$.each(c,function(a,b){A(b)}),u());V()}).add(function(b){var c=a.cwd().hash,b=r?$.map(b.data.added||[],function(a){return-1===a.name.indexOf(r)?
null:a}):$.map(b.data.added||[],function(a){return a.phash==c?a:null});x(b)}).change(function(b){var c=a.cwd().hash,d=a.selected();r?$.each(b.data.changed||[],function(a,b){S([b.hash]);-1!==b.name.indexOf(r)&&(x([b]),-1!==$.inArray(b.hash,d)&&A(b.hash))}):$.each($.map(b.data.changed||[],function(a){return a.phash==c?a:null}),function(a,b){S([b.hash]);x([b]);-1!==$.inArray(b.hash,d)&&A(b.hash)});u()}).remove(function(a){S(a.data.removed||[]);u()}).bind("open add search searchend",function(){p.css("height",
"auto");p.outerHeight(!0)<z.height()&&p.height(z.height()-(p.outerHeight(!0)-p.height())-2)}).dragstart(function(a){var b=$(a.data.target),a=a.data.originalEvent;b.is(i)&&(b.is(".ui-selected")||(!a.ctrlKey&&!a.metaKey&&!a.shiftKey&&v(),b.trigger(d),u()),p.droppable("disable"));p.selectable("disable").removeClass(j);J=!0}).dragstop(function(){p.selectable("enable").droppable("enable");J=!1}).bind("lockfiles unlockfiles",function(a){for(var b="lockfiles"==a.type?f:g,a=a.data.files||[],c=a.length;c--;)p.find("#"+
a[c]).trigger(b);u()}).bind("mkdir mkfile duplicate upload rename archive extract",function(b){var c=a.cwd().hash;v();$.each(b.data.added||[],function(a,b){b&&b.phash==c&&A(b.hash)});u()}).shortcut({pattern:"ctrl+a",description:"selectall",callback:function(){var b=a.cwd().hash;p.find("[id]:not(.ui-selected):not(.finder-cwd-parent)").trigger(d);F=$.map(a.files(),function(a){return a.phash==b?a.hash:null});u()}}).shortcut({pattern:"left right up down shift+left shift+right shift+up shift+down",description:"selectfiles",
type:"keydown",callback:function(a){var c=a.keyCode,a=a.shiftKey,f=function(a,b){return a[b+"All"]("[id]:not(."+j+"):not(.finder-cwd-parent):first")},g=$.ui.keyCode,h=c==g.LEFT||c==g.UP,i=p.find("[id].ui-selected"),k,l;if(i.length)if(k=i.filter(h?":first":":last"),l=f(k,h?"prev":"next"),l.length)if(b||c==g.LEFT||c==g.RIGHT)c=l;else if(g=k.position().top,l=k.position().left,c=k,h){do c=c.prev("[id]");while(c.length&&!(c.position().top<g&&c.position().left<=l));c.is("."+j)&&(c=f(c,"next"))}else{do c=
c.next("[id]");while(c.length&&!(c.position().top>g&&c.position().left>=l));c.is("."+j)&&(c=f(c,"prev"));c.length||(l=p.find("[id]:not(."+j+"):last"),l.position().top>g&&(c=l))}else c=k.siblings("[id]:not(."+j+"):not(.finder-cwd-parent):"+(h?"last":"first"));else c=p.find("[id]:not(."+j+"):not(.finder-cwd-parent):"+(h?"last":"first"));c&&c.length&&!c.is(".finder-cwd-parent")&&(a?c=k.add(k[h?"prevUntil":"nextUntil"]("#"+c.attr("id"))).add(c):i.trigger(e),c.trigger(d),D(c.filter(h?":first":":last")),
u())}}).shortcut({pattern:"home",description:"selectffile",callback:function(){v();D(p.find("[id]:first").trigger(d));u()}}).shortcut({pattern:"end",description:"selectlfile",callback:function(){v();D(p.find("[id]:last").trigger(d));u()}})});return this};
$.fn.finderdialog=function(a){var c;if("string"==typeof a&&(c=this.closest(".ui-dialog")).length)"open"==a?"none"==c.css("display")&&c.fadeIn(120,function(){c.trigger("open")}):"close"==a?"none"!=c.css("display")&&c.hide().trigger("close"):"destroy"==a?c.hide().remove():"toTop"==a&&c.trigger("totop");a=$.extend({},$.fn.finderdialog.defaults,a);this.filter(":not(.ui-dialog-content)").each(function(){var b=$(this).addClass("ui-dialog-content ui-widget-content"),c=b.parent(),e=parseInt(1E6*Math.random()),
f=c.children(".finder-overlay"),g=$('<div class="ui-dialog-buttonset"/>'),h=$('<div class=" ui-helper-clearfix ui-dialog-buttonpane ui-widget-content"/>').append(g),i=$('<div class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-draggable std42-dialog  finder-dialog '+a.cssClass+'"/>').hide().append(b).appendTo(c).draggable({handle:".ui-dialog-titlebar",containment:$("body")}).css({width:a.width,height:a.height}).mousedown(function(a){a.stopPropagation();$(document).mousedown();i.is(".finder-dialog-active")||
(c.find(".finder-dialog:visible").removeClass("finder-dialog-active"),i.addClass("finder-dialog-active").zIndex(j()+1))}).bind("open",function(){a.modal&&f.finderoverlay("show");i.trigger("totop");"function"==typeof a.open&&$.proxy(a.open,b[0])();i.is(".finder-dialog-notify")||c.find(".finder-dialog:visible").not(".finder-dialog-notify").each(function(){var a=$(this),b=parseInt(a.css("top")),c=parseInt(a.css("left")),d=parseInt(i.css("top")),e=parseInt(i.css("left"));a[0]!=i[0]&&(b==d||c==e)&&i.css({top:b+
10+"px",left:c+10+"px"})})}).bind("close",function(){var e=c.find(".finder-dialog:visible"),g=j();a.modal&&f.finderoverlay("hide");e.length?e.each(function(){var a=$(this);if(a.zIndex()>=g)return a.trigger("totop"),!1}):setTimeout(function(){c.mousedown().click()},10);"function"==typeof a.close?$.proxy(a.close,b[0])():a.destroyOnClose&&i.hide().remove()}).bind("totop",function(){$(this).mousedown().find(".ui-button:first").focus().end().find(":text:first").focus()}),j=function(){var a=c.zIndex()+
10;c.find(".finder-dialog:visible").each(function(){var b;this!=i[0]&&(b=$(this).zIndex(),b>a&&(a=b))});return a},m;a.position||(m=parseInt((c.height()-i.outerHeight())/2-42),a.position={top:(0<m?m:0)+"px",left:parseInt((c.width()-i.outerWidth())/2)+"px"});i.css(a.position);a.closeOnEscape&&$(document).bind("keyup."+e,function(a){a.keyCode==$.ui.keyCode.ESCAPE&&i.is(".finder-dialog-active")&&(b.finderdialog("close"),$(document).unbind("keyup."+e))});i.prepend($('<div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix">'+
a.title+"</div>").prepend($('<a href="#" class="ui-dialog-titlebar-close ui-corner-all"><span class="ui-icon ui-icon-closethick"/></a>').mousedown(function(a){a.preventDefault();b.finderdialog("close")})));$.each(a.buttons,function(a,c){var d=$('<button type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"><span class="ui-button-text">'+a+"</span></button>").click($.proxy(c,b[0])).hover(function(a){$(this)["mouseenter"==a.type?"focus":"blur"]()}).focus(function(){$(this).addClass("ui-state-hover")}).blur(function(){$(this).removeClass("ui-state-hover")}).keydown(function(a){a.keyCode==
$.ui.keyCode.ENTER?$(this).click():a.keyCode==$.ui.keyCode.TAB&&(a=$(this).next(".ui-button"),a.length?a.focus():$(this).parent().children(".ui-button:first").focus())});g.append(d)});g.children().length&&i.append(h);a.resizable&&$.fn.resizable&&i.resizable({minWidth:a.minWidth,minHeight:a.minHeight,alsoResize:this});"function"==typeof a.create&&$.proxy(a.create,this)();a.autoOpen&&b.finderdialog("open")});return this};
$.fn.finderdialog.defaults={cssClass:"",title:"",modal:!1,resizable:!0,autoOpen:!0,closeOnEscape:!0,destroyOnClose:!1,buttons:{},position:null,width:320,height:"auto",minWidth:200,minHeight:110};
$.fn.findernavbar=function(a,c){this.not(".finder-navbar").each(function(){var b=$(this).addClass("ui-state-default finder-navbar"),d=b.parent().resize(function(){b.height(d.height()-e)}).children(".finder-workzone").append(b),e=b.outerHeight()-b.height(),f;$.fn.resizable&&(f=b.resizable({handles:"ltr"==a.direction?"e":"w",minWidth:c.minWidth||150,maxWidth:c.maxWidth||500}).bind("resize scroll",function(){f.css({top:parseInt(b.scrollTop())+"px"})}).find(".ui-resizable-handle").zIndex(b.zIndex()+10),
a.one("open",function(){setTimeout(function(){b.trigger("resize")},150)}))});return this};
$.fn.finderoverlay=function(a){this.filter(":not(.finder-overlay)").each(function(){a=$.extend({},a);$(this).addClass("ui-widget-overlay finder-overlay").hide().mousedown(function(a){a.preventDefault();a.stopPropagation()}).data({cnt:0,show:"function"==typeof a.show?a.show:function(){},hide:"function"==typeof a.hide?a.hide:function(){}})});if("show"==a){var c=this.eq(0),b=c.data("cnt")+1,d=c.data("show");c.data("cnt",b);c.is(":hidden")&&(c.zIndex(c.parent().zIndex()+1),c.show(),d())}"hide"==a&&(c=
this.eq(0),b=c.data("cnt")-1,d=c.data("hide"),c.data("cnt",b),0==b&&c.is(":visible")&&(c.hide(),d()));return this};$.fn.finderpanel=function(a){return this.each(function(){var c=$(this).addClass("finder-panel ui-state-default ui-corner-all"),b="margin-"+("ltr"==a.direction?"left":"right");a.one("load",function(){var d=a.getUI("navbar");c.css(b,parseInt(d.outerWidth(!0)));d.bind("resize",function(){c.is(":visible")&&c.css(b,parseInt(d.outerWidth(!0)))})})})};
$.fn.finderpath=function(a){return this.each(function(){var c=$(this).addClass("finder-path").html("&nbsp;").delegate("a","click",function(b){var c=$(this).attr("href").substr(1);b.preventDefault();c!=a.cwd().hash&&a.exec("open",c)}).prependTo(a.getUI("statusbar").show());a.bind("open searchend",function(){var b=[];$.each(a.parents(a.cwd().hash),function(c,e){b.push('<a href="#'+e+'">'+a.escape(a.file(e).name)+"</a>")});c.html(b.join(a.option("separator")))}).bind("search",function(){c.html(a.i18n("searcresult"))})})};
$.fn.finderplaces=function(a,c){return this.each(function(){var b=[],d=a.res("class","navdir"),e=a.res("class","navcollapse"),f=a.res("class","navexpand");a.res("class","hover");var g=a.res("class","treeroot"),h=a.res("tpl","navdir"),i=a.res("tpl","perms"),j=$(a.res("tpl","navspinner")),m=function(a){return a.substr(6)},k=function(){a.storage("places",b.join(","))},l=function(b){return $(h.replace(/\{id\}/,"place-"+b.hash).replace(/\{name\}/,a.escape(b.name)).replace(/\{cssclass\}/,a.perms2class(b)).replace(/\{permissions\}/,
!b.read||!b.write?i:"").replace(/\{symlink\}/,""))},n=function(c){var f=l(c);t.children().length&&$.each(t.children(),function(){var a=$(this);if(0>c.name.localeCompare(a.children("."+d).text()))return!f.insertBefore(a)});b.push(c.hash);!f.parent().length&&t.append(f);r.addClass(e);f.draggable({appendTo:"body",revert:!1,helper:function(){var b=$(this);b.children().removeClass("ui-state-hover");return $('<div class="finder-place-drag finder-'+a.direction+'"/>').append(b.clone()).data("hash",m(b.children(":first").attr("id")))},
start:function(){$(this).hide()},stop:function(a,b){var c=y.offset().top,d=y.offset().left,e=y.width(),f=y.height(),g=a.clientX,h=a.clientY;g>d&&g<d+e&&h>c&&h<h+f?$(this).show():(q(b.helper.data("hash")),k())}})},q=function(a){var c=$.inArray(a,b);-1!==c&&(b.splice(c,1),t.find("#place-"+a).parent().remove(),!t.children().length&&r.removeClass(e+" "+f))},s=l({hash:"root-"+a.namespace,name:a.i18n(c.name,"places"),read:!0,write:!0}),r=s.children("."+d).addClass(g).click(function(){r.is("."+e)&&(y.toggleClass(f),
t.slideToggle(),a.storage("placesState",y.is("."+f)?1:0))}),t=s.children("."+a.res("class","navsubtree")),y=$(this).addClass(a.res("class","tree")+" finder-places ui-corner-all").hide().append(s).appendTo(a.getUI("navbar")).delegate("."+d,"hover",function(){$(this).toggleClass("ui-state-hover")}).delegate("."+d,"click",function(){a.exec("open",$(this).attr("id").substr(6))}).delegate("."+d+":not(."+g+")","contextmenu",function(b){var c=$(this).attr("id").substr(6);b.preventDefault();a.trigger("contextmenu",
{raw:[{label:a.i18n("rmFromPlaces"),icon:"rm",callback:function(){q(c);k()}}],x:b.clientX,y:b.clientY})}).droppable({tolerance:"pointer",accept:".finder-cwd-file-wrapper,.finder-tree-dir,.finder-cwd-file",hoverClass:a.res("class","adroppable"),drop:function(c,d){var e=!0;$.each(d.helper.data("files"),function(c,d){var f=a.file(d);f&&"directory"==f.mime&&-1===$.inArray(f.hash,b)?n(f):e=!1});k();e&&d.helper.hide()}});a.one("load",function(){a.oldAPI||(y.show().parent().show(),b=$.map(a.storage("places").split(","),
function(a){return a||null}),b.length&&(r.prepend(j),a.request({data:{cmd:"info",targets:b},preventDefault:!0}).done(function(c){b=[];$.each(c.files,function(a,b){"directory"==b.mime&&n(b)});k();0<a.storage("placesState")&&r.click()}).always(function(){j.remove()})),a.remove(function(a){$.each(a.data.removed,function(a,b){q(b)});k()}).change(function(a){$.each(a.data.changed,function(a,c){-1!==$.inArray(c.hash,b)&&(q(c.hash),"directory"==c.mime&&n(c))});k()}).bind("sync",function(){b.length&&(r.prepend(j),
a.request({data:{cmd:"info",targets:b},preventDefault:!0}).done(function(a){$.each(a.files||[],function(a,c){-1===$.inArray(c.hash,b)&&q(c.hash)});k()}).always(function(){j.remove()}))}))})})};
$.fn.findersearchbutton=function(a){return this.each(function(){var c=!1,b=$(this).hide().addClass("ui-widget-content finder-button "+a.fm.res("class","searchbtn")+""),d=function(){a.exec($.trim(f.val())).done(function(){c=!0;f.focus()})},e=function(){f.val("");c&&(c=!1,a.fm.trigger("searchend"))},f=$('<input type="text" size="42"/>').appendTo(b).keypress(function(a){a.stopPropagation()}).keydown(function(a){a.stopPropagation();13==a.keyCode&&d();27==a.keyCode&&(a.preventDefault(),e())});$('<span class="ui-icon ui-icon-search" title="'+
a.title+'"/>').appendTo(b).click(d);$('<span class="ui-icon ui-icon-close"/>').appendTo(b).click(e);setTimeout(function(){b.parent().detach();a.fm.getUI("toolbar").prepend(b.show());if($.browser.msie){var c=b.children("ltr"==a.fm.direction?".ui-icon-close":".ui-icon-search");c.css({right:"",left:parseInt(b.width())-c.outerWidth(!0)})}},200);a.fm.error(function(){f.unbind("keydown")}).select(function(){f.blur()}).bind("searchend",function(){f.val("")}).viewchange(e).shortcut({pattern:"ctrl+f f3",description:a.title,
callback:function(){f.select().focus()}})})};
$.fn.findersortbutton=function(a){return this.each(function(){var c=a.fm,b=a.name,d=c.res("class","disabled"),e=c.res("class","hover"),f=$(this).addClass("ui-state-default finder-button finder-menubutton elfiner-button-"+b).attr("title",a.title).append('<span class="finder-button-icon finder-button-icon-'+b+'"/>').hover(function(){!f.is("."+d)&&f.toggleClass(e)}).click(function(b){f.is("."+d)||(b.stopPropagation(),g.is(":hidden")&&a.fm.getUI().click(),g.slideToggle(100))}),g=$('<div class="ui-widget ui-widget-content finder-button-menu ui-corner-all"/>').hide().appendTo(f).zIndex(12+
f.zIndex()).delegate(".finder-button-menu-item","hover",function(){$(this).toggleClass(e)}).delegate(".finder-button-menu-item","click",function(a){a.preventDefault();a.stopPropagation();i()}),h=function(){g.children(":not(:last)").removeClass("finder-button-menu-item-selected finder-button-menu-item-selected-asc finder-button-menu-item-selected-desc").filter('[rel="'+c.sortType+'"]').addClass("finder-button-menu-item-selected "+("asc"==c.sortOrder?"finder-button-menu-item-selected-asc":"finder-button-menu-item-selected-desc"));
g.children(":last").toggleClass("finder-button-menu-item-selected",c.sortStickFolders)},i=function(){g.hide()};$.each(c.sortRules,function(a){g.append($('<div class="finder-button-menu-item" rel="'+a+'"><span class="ui-icon ui-icon-arrowthick-1-n"/><span class="ui-icon ui-icon-arrowthick-1-s"/>'+c.i18n("sort"+a)+"</div>").data("type",a))});g.children().click(function(){var b=$(this).attr("rel");a.exec([],{type:b,order:b==c.sortType?"asc"==c.sortOrder?"desc":"asc":c.sortOrder,stick:c.sortStickFolders})});
$('<div class="finder-button-menu-item finder-button-menu-item-separated"><span class="ui-icon ui-icon-check"/>'+c.i18n("sortFoldersFirst")+"</div>").appendTo(g).click(function(){a.exec([],{type:c.sortType,order:c.sortOrder,stick:!c.sortStickFolders})});c.bind("disable select",i).getUI().click(i);c.bind("sortchange",h);1<g.children().length?a.change(function(){f.toggleClass(d,a.disabled());h()}).change():f.addClass(d)})};
$.fn.finderstat=function(a){return this.each(function(){var c=$(this).addClass("finder-stat-size"),b=$('<div class="finder-stat-selected"/>'),d=a.i18n("size").toLowerCase(),e=a.i18n("items").toLowerCase(),f=a.i18n("selected"),g=function(b,f){var g=0,m=0;$.each(b,function(a,b){if(!f||b.phash==f)g++,m+=parseInt(b.size)||0});c.html(e+": "+g+", "+d+": "+a.formatSize(m))};a.getUI("statusbar").prepend(c).append(b).show();a.bind("open reload add remove change searchend",function(){g(a.files(),a.cwd().hash)}).search(function(a){g(a.data.files)}).select(function(){var c=
0,e=0,g=a.selectedFiles();1==g.length?(c=g[0].size,b.html(a.escape(g[0].name)+(0<c?", "+a.formatSize(c):""))):($.each(g,function(a,b){e++;c+=parseInt(b.size)||0}),b.html(e?f+": "+e+", "+d+": "+a.formatSize(c):"&nbsp;"))})})};
$.fn.findertoolbar=function(a,c){this.not(".finder-toolbar").each(function(){var b=a._commands,d=$(this).addClass("ui-helper-clearfix ui-widget-header ui-corner-top finder-toolbar"),e=c||[],f=e.length,g,h,i,j;for(d.prev().length&&d.parent().prepend(this);f--;)if(e[f]){i=$('<div class="ui-widget-content ui-corner-all finder-buttonset"/>');for(g=e[f].length;g--;)if(h=b[e[f][g]])j="finder"+h.options.ui,$.fn[j]&&i.prepend($("<div/>")[j](h));i.children().length&&d.prepend(i);i.children(":gt(0)").before('<span class="ui-widget-content finder-toolbar-button-separator"/>')}d.children().length&&
d.show()});return this};
$.fn.findertree=function(a,c){var b=a.res("class","tree");this.not("."+b).each(function(){var d=a.res("class","treeroot"),e=c.openRootOnLoad,f=a.res("class","navsubtree"),g=a.res("class","treedir"),h=a.res("class","navcollapse"),i=a.res("class","navexpand"),j=a.res("class","navarrow"),m=a.res("class","active"),k=a.res("class","adroppable"),l=a.res("class","hover"),n=a.res("class","disabled"),q=a.res("class","draggable"),s=a.res("class","droppable"),r=function(a){var b=O.offset().left;return b<=a&&
a<=b+O.width()},t=a.droppable.drop,y=$.extend(!0,{},a.droppable,{over:function(a){var b=$(this),c=l+" "+k;r(a.clientX)?(b.addClass(c),b.is("."+h+":not(."+i+")")&&setTimeout(function(){b.is("."+k)&&b.children("."+j).click()},500)):b.removeClass(c)},out:function(){$(this).removeClass(l+" "+k)},drop:function(a,b){r(a.clientX)&&t.call(this,a,b)}}),C=$(a.res("tpl","navspinner")),G=a.res("tpl","navdir"),L=a.res("tpl","perms"),I=a.res("tpl","symlink"),J={id:function(b){return a.navHash2Id(b.hash)},cssclass:function(b){return(b.phash?
"":d)+" "+(b.net?"finder-navbar-net":"")+" "+g+" "+a.perms2class(b)+" "+(b.dirs&&!b.link?h:"")},permissions:function(a){return!a.read||!a.write?L:""},symlink:function(a){return a.alias?I:""}},F=function(b){b.name=a.escape(b.name);return G.replace(/(?:\{([a-z]+)\})/ig,function(a,c){return b[c]||(J[c]?J[c](b):"")})},A=function(a){return $.map(a||[],function(a){return"directory"==a.mime?a:null})},v=function(b){return b?B.find("#"+a.navHash2Id(b)).next("."+f):B},u=function(b,c){for(var d=b.children(":first"),
e;d.length;){e=a.file(a.navId2Hash(d.children("[id]").attr("id")));if((e=a.file(a.navId2Hash(d.children("[id]").attr("id"))))&&0>c.name.toLowerCase().localeCompare(e.name.toLowerCase()))return d;d=d.next()}return $("")},D=function(b){for(var c=b.length,d=[],e=b.length,f,g,h,i;e--;)if(f=b[e],!B.find("#"+a.navHash2Id(f.hash)).length)if((h=v(f.phash)).length)if(g=F(f),f.phash&&(i=u(h,f)).length)i.before(g);else h[f.phash?"append":"prepend"](g);else d.push(f);if(d.length&&d.length<c)return D(d);setTimeout(function(){H()},
10)},w=function(b){var h=a.cwd().hash,j=B.find("#"+a.navHash2Id(h)),l,k;e&&(l=B.find("#"+a.navHash2Id(a.root())),l.is(".finder-subtree-loaded")&&l.addClass(i).next("."+f).show(),e=!1);j.is("."+m)||(B.find("."+g+"."+m).removeClass(m),j.addClass(m));if(c.syncTree)if(j.length)j.parentsUntil("."+d).filter("."+f).show().prev("."+g).addClass(i);else if(a.newAPI&&!b&&(k=a.file(h)).phash&&B.find("#"+a.navHash2Id(k.phash)).length)D([k]),a.request({data:{cmd:"parents",target:h},preventFail:!0}).done(function(b){b=
A(b.tree);D(b);K(b,"finder-subtree-loaded");h==a.cwd().hash&&w(!0)})},H=function(){B.find("."+g+":not(."+s+",.finder-ro,.finder-na)").droppable(y)},K=function(b,c){var d="finder-subtree-loaded"==c?"."+h+":not(.finder-subtree-loaded)":":not(."+h+")";$.each(b,function(b,e){B.find("#"+a.navHash2Id(e.phash)+d).filter(function(){return 0<$(this).next("."+f).children().length}).addClass(c)})},B=$(this).addClass(b).delegate("."+g,"hover",function(b){var c=$(this),b="mouseenter"==b.type;c.is("."+k+" ,."+
n)||(b&&!c.is("."+d+",."+q+",.finder-na,.finder-wo")&&c.draggable(a.draggable),c.toggleClass(l,b))}).delegate("."+g,"dropover dropout drop",function(a){$(this)["dropover"==a.type?"addClass":"removeClass"](k+" "+l)}).delegate("."+g,"click",function(){var b=$(this),c=a.navId2Hash(b.attr("id")),d=a.file(c);a.trigger("searchend");c!=a.cwd().hash&&!b.is("."+n)?a.exec("open",d.thash||c):b.is("."+h)&&b.children("."+j).click()}).delegate("."+g+"."+h+" ."+j,"click",function(b){var c=$(this),d=c.parent("."+
g),e=d.next("."+f);b.stopPropagation();d.is(".finder-subtree-loaded")?(d.toggleClass(i),e.slideToggle()):(C.insertBefore(c),d.removeClass(h),a.request({cmd:"tree",target:a.navId2Hash(d.attr("id"))}).done(function(a){D(A(a.tree));e.children().length&&(d.addClass(h+" "+i),e.slideDown());w()}).always(function(){C.remove();d.addClass("finder-subtree-loaded")}))}).delegate("."+g,"contextmenu",function(b){b.preventDefault();a.trigger("contextmenu",{type:"navbar",targets:[a.navId2Hash($(this).attr("id"))],
x:b.clientX,y:b.clientY})}),O=a.getUI("navbar").append(B).show();a.open(function(a){var a=a.data,b=A(a.files);a.init&&B.empty();b.length&&(D(b),K(b,"finder-subtree-loaded"));w()}).add(function(a){a=A(a.data.added);a.length&&(D(a),K(a,h))}).change(function(b){for(var b=A(b.data.changed),c=b.length,d,e,h,j,l,k;c--;)if(d=b[c],(e=B.find("#"+a.navHash2Id(d.hash))).length){if(d.phash){h=e.closest("."+f);j=v(d.phash);l=e.parent().next();k=u(j,d);if(!j.length)continue;if(j[0]!==h[0]||l.get(0)!==k.get(0))k.length?
k.before(e):j.append(e)}j=e.is("."+i);l=e.is(".finder-subtree-loaded");h=$(F(d));e.replaceWith(h.children("."+g));if(d.dirs&&(j||l)&&(e=B.find("#"+a.navHash2Id(d.hash)))&&e.next("."+f).children().length)j&&e.addClass(i),l&&e.addClass("finder-subtree-loaded")}w();H()}).remove(function(b){for(var b=b.data.removed,c=b.length,d,e;c--;)if((d=B.find("#"+a.navHash2Id(b[c]))).length)e=d.closest("."+f),d.parent().detach(),e.children().length||e.hide().prev("."+g).removeClass(h+" "+i+" finder-subtree-loaded")}).bind("search searchend",
function(b){B.find("#"+a.navHash2Id(a.cwd().hash))["search"==b.type?"removeClass":"addClass"](m)}).bind("lockfiles unlockfiles",function(b){var c="lockfiles"==b.type,d=c?"disable":"enable",b=$.map(b.data.files||[],function(b){var c=a.file(b);return c&&"directory"==c.mime?b:null});$.each(b,function(b,e){var f=B.find("#"+a.navHash2Id(e));f.length&&(f.is("."+q)&&f.draggable(d),f.is("."+s)&&f.droppable(m),f[c?"addClass":"removeClass"](n))})})});return this};
$.fn.finderuploadbutton=function(a){return this.each(function(){var c=$(this).finderbutton(a).unbind("click"),b=$("<form/>").appendTo(c),d=$('<input type="file" multiple="true"/>').change(function(){var c=$(this);c.val()&&(a.exec({input:c.remove()[0]}),d.clone(!0).appendTo(b))});b.append(d.clone(!0));a.change(function(){b[a.disabled()?"hide":"show"]()}).change()})};
$.fn.finderviewbutton=function(a){return this.each(function(){var c=$(this).finderbutton(a),b=c.children(".finder-button-icon");a.change(function(){var d="icons"==a.value;b.toggleClass("finder-button-icon-view-list",d);c.attr("title",a.fm.i18n(d?"viewlist":"viewicons"))})})};
$.fn.finderworkzone=function(){this.not(".finder-workzone").each(function(){var a=$(this).addClass("finder-workzone"),c=a.outerHeight(!0)-a.height(),b=a.parent();b.add(window).bind("resize",function(){var d=b.height();b.children(":visible:not(.finder-workzone)").each(function(){var a=$(this);"absolute"!=a.css("position")&&(d-=a.outerHeight(!0))});a.height(d-c)})});return this};
Finder.prototype.commands.archive=function(){var a=this,c=a.fm,b=[];this.variants=[];this.disableOnSearch=!0;c.bind("open reload",function(){a.variants=[];$.each(b=c.option("archivers").create||[],function(b,e){a.variants.push([e,c.mime2kind(e)])});a.change()});this.getstate=function(){return!this._disabled&&b.length&&c.selected().length&&c.cwd().write?0:-1};this.exec=function(a,e){var f=this.files(a),g=f.length,h=e||b[0],i=c.cwd(),j=["errArchive","errPerm"],m=$.Deferred().fail(function(a){a&&c.error(a)});
if(!this.enabled()||!g||!(b.length&&-1!==$.inArray(h,b)))return m.reject();if(!i.write)return m.reject(j);for(i=0;i<g;i++)if(!f[i].read)return m.reject(j);return c.request({data:{cmd:"archive",targets:this.hashes(a),type:h},notify:{type:"archive",cnt:1},syncOnFail:!0})}};Finder.prototype.commands.back=function(){this.alwaysEnabled=!0;this.updateOnSelect=!1;this.shortcuts=[{pattern:"ctrl+left backspace"}];this.getstate=function(){return this.fm.history.canBack()?0:-1};this.exec=function(){return this.fm.history.back()}};
Finder.prototype.commands.copy=function(){this.shortcuts=[{pattern:"ctrl+c ctrl+insert"}];this.getstate=function(a){var a=this.files(a),c=a.length;return c&&$.map(a,function(a){return a.phash&&a.read?a:null}).length==c?0:-1};this.exec=function(a){var c=this.fm,b=$.Deferred().fail(function(a){c.error(a)});$.each(this.files(a),function(a,c){if(!c.read||!c.phash)return!b.reject(["errCopy",c.name,"errPerm"])});return"rejected"==b.state()?b:b.resolve(c.clipboard(this.hashes(a)))}};
Finder.prototype.commands.cut=function(){this.shortcuts=[{pattern:"ctrl+x shift+insert"}];this.getstate=function(a){var a=this.files(a),c=a.length;return c&&$.map(a,function(a){return a.phash&&a.read&&!a.locked?a:null}).length==c?0:-1};this.exec=function(a){var c=this.fm,b=$.Deferred().fail(function(a){c.error(a)});$.each(this.files(a),function(a,c){if(!c.read||!c.phash)return!b.reject(["errCopy",c.name,"errPerm"]);if(c.locked)return!b.reject(["errLocked",c.name])});return"rejected"==b.state()?b:
b.resolve(c.clipboard(this.hashes(a),!0))}};
Finder.prototype.commands.download=function(){var a=this,c=function(b){return $.map(a.files(b),function(a){return"directory"==a.mime?null:a})};this.shortcuts=[{pattern:"shift+enter"}];this.getstate=function(){var a=this.fm.selected(),d=a.length;return!this._disabled&&d&&(!$.browser.msie||1==d)&&d==c(a).length?0:-1};this.exec=function(a){var d=this.fm,e=d.options.url,f=c(a),g=$.Deferred(),h="",i="",j;if(this.disabled())return g.reject();if(d.oldAPI)return d.error("errCmdNoSupport"),g.reject();$.each(d.options.customData||
{},function(a,b){i+="&"+a+"="+b});e+=-1===e.indexOf("?")?"?":"&";for(j=0;j<f.length;j++)h+='<iframe class="downloader" id="downloader-'+f[j].hash+'" style="display:none" src="'+e+"cmd=file&target="+f[j].hash+"&download=1"+i+'"/>';$(h).appendTo("body").ready(function(){setTimeout(function(){$(h).each(function(){$("#"+$(this).attr("id")).remove()})},$.browser.mozilla?2E4+1E4*j:1E3)});d.trigger("download",{files:f});return g.resolve(a)}};
Finder.prototype.commands.duplicate=function(){var a=this.fm;this.getstate=function(c){var c=this.files(c),b=c.length;return!this._disabled&&b&&a.cwd().write&&$.map(c,function(a){return a.phash&&a.read?a:null}).length==b?0:-1};this.exec=function(a){var b=this.fm,d=this.files(a),e=d.length,f=$.Deferred().fail(function(a){a&&b.error(a)});if(!e||this._disabled)return f.reject();$.each(d,function(a,c){if(!c.read||!b.file(c.phash).write)return!f.reject(["errCopy",c.name,"errPerm"])});return"rejected"==
f.state()?f:b.request({data:{cmd:"duplicate",targets:this.hashes(a)},notify:{type:"copy",cnt:e}})}};
Finder.prototype.commands.edit=function(){var a=this,c=this.fm,b=c.res("mimes","text")||[],d=function(c){return $.map(c,function(c){return(0===c.mime.indexOf("text/")||-1!==$.inArray(c.mime,b))&&c.mime.indexOf("text/rtf")&&(!a.onlyMimes.length||-1!==$.inArray(c.mime,a.onlyMimes))&&c.read&&c.write?c:null})},e=function(b){var d=b.hash,e=$.Deferred();c.url(d);var i="edit-"+c.namespace+"-"+b.hash,j=c.getUI().find("#"+i);if(j.length)return j.finderdialog("toTop"),e.resolve();if(!b.read||!b.write)return j=
["errOpen",b.name,"errPerm"],c.error(j),e.reject(j);c.request({data:{cmd:"get",target:d},notify:{type:"openfile",cnt:1},syncOnFail:!0}).done(function(j){var j=j.content,k=$.Deferred(),l=$('<textarea class="finder-file-edit" rows="20" id="'+i+'-ta">'+c.escape(j)+"</textarea>"),n=function(){l.editor&&l.editor.save(l[0],l.editor.instance);k.resolve(l.getContent());l.finderdialog("close")},q=function(){k.reject();l.finderdialog("close")},j={title:b.name,width:a.options.dialogWidth||450,buttons:{},close:function(){l.editor&&
l.editor.close(l[0],l.editor.instance);$(this).finderdialog("destroy")},open:function(){c.disable();l.focus();l[0].setSelectionRange&&l[0].setSelectionRange(0,0);l.editor&&l.editor.load(l[0])}};l.getContent=function(){return l.val()};$.each(a.options.editors||[],function(a,c){if(-1!==$.inArray(b.mime,c.mimes||[])&&"function"==typeof c.load&&"function"==typeof c.save)return l.editor={load:c.load,save:c.save,close:"function"==typeof c.close?c.close:function(){},instance:null},!1});l.editor||l.keydown(function(a){var b=
a.keyCode,c,d;a.stopPropagation();9==b&&(a.preventDefault(),this.setSelectionRange&&(c=this.value,d=this.selectionStart,this.value=c.substr(0,d)+"\t"+c.substr(this.selectionEnd),d+=1,this.setSelectionRange(d,d)));if(a.ctrlKey||a.metaKey){if(81==b||87==b)a.preventDefault(),q();83==b&&(a.preventDefault(),n())}});j.buttons[c.i18n("Save")]=n;j.buttons[c.i18n("Cancel")]=q;c.dialog(l,j).attr("id",i);k.promise().done(function(a){c.request({options:{type:"post"},data:{cmd:"put",target:d,content:a},notify:{type:"save",
cnt:1},syncOnFail:!0}).fail(function(a){e.reject(a)}).done(function(a){a.changed&&a.changed.length&&c.change(a);e.resolve(a)})})}).fail(function(a){e.reject(a)});return e.promise()};this.shortcuts=[{pattern:"ctrl+e"}];this.init=function(){this.onlyMimes=this.options.mimes||[]};this.getstate=function(a){var a=this.files(a),b=a.length;return!this._disabled&&b&&d(a).length==b?0:-1};this.exec=function(a){var a=d(this.files(a)),b=[],c;if(this.disabled())return $.Deferred().reject();for(;c=a.shift();)b.push(e(c));
return b.length?$.when.apply(null,b):$.Deferred().reject()}};
Finder.prototype.commands.extract=function(){var a=this,c=a.fm,b=[];this.disableOnSearch=!0;c.bind("open reload",function(){b=c.option("archivers").extract||[];a.change()});this.getstate=function(a){var a=this.files(a),c=a.length;return!this._disabled&&c&&this.fm.cwd().write&&$.map(a,function(a){return a.read&&-1!==$.inArray(a.mime,b)?a:null}).length==c?0:-1};this.exec=function(a){var a=this.files(a),e=$.Deferred(),f=a.length,g=f,h,i;if(!this.enabled()||!f||!b.length)return e.reject();for(h=0;h<f;h++){i=
a[h];if(!i.read||!c.file(i.phash).write)return a=["errExtract",i.name,"errPerm"],c.error(a),e.reject(a);if(-1===$.inArray(i.mime,b))return a=["errExtract",i.name,"errNoArchive"],c.error(a),e.reject(a);c.request({data:{cmd:"extract",target:i.hash},notify:{type:"extract",cnt:1},syncOnFail:!0}).fail(function(a){"rejected"!=e.state()&&e.reject(a)}).done(function(){g--;0==g&&e.resolve()})}return e}};
Finder.prototype.commands.forward=function(){this.updateOnSelect=this.alwaysEnabled=!0;this.shortcuts=[{pattern:"ctrl+right"}];this.getstate=function(){return this.fm.history.canForward()?0:-1};this.exec=function(){return this.fm.history.forward()}};
Finder.prototype.commands.getfile=function(){var a=this,c=this.fm;this.alwaysEnabled=!0;this.callback=c.options.getFileCallback;this._disabled="function"==typeof this.callback;this.getstate=function(b){var b=this.files(b),c=b.length,e;if(e=this.callback)if(e=c){var f=a.options,b=$.map(b,function(a){return"directory"!=a.mime||f.folders?a:null});e=(f.multiple||1==b.length?b:[]).length==c}return e?0:-1};this.exec=function(b){var c=this.fm,e=this.options,f=this.files(b),b=f.length,g=c.option("url"),h=
c.option("tmbUrl"),i=$.Deferred().done(function(b){c.trigger("getfile",{files:b});a.callback(b,c);"close"==e.oncomplete?c.hide():"destroy"==e.oncomplete&&c.destroy()}),j=function(){return e.onlyURL?e.multiple?$.map(f,function(a){return a.url}):f[0].url:e.multiple?f:f[0]},m=[],k,l,n;if(-1==this.getstate())return i.reject();for(k=0;k<b;k++){l=f[k];if("directory"==l.mime&&!e.folders)return i.reject();l.baseUrl=g;l.url=c.url(l.hash);l.path=c.path(l.hash);l.tmb&&1!=l.tmb&&(l.tmb=h+l.tmb);!l.width&&!l.height&&
(l.dim?(n=l.dim.split("x"),l.width=n[0],l.height=n[1]):-1!==l.mime.indexOf("image")&&m.push(c.request({data:{cmd:"dim",target:l.hash},preventDefault:!0}).done($.proxy(function(a){a.dim&&(n=a.dim.split("x"),this.width=n[0],this.height=n[1]);this.dim=a.dim},f[k]))))}return m.length?($.when.apply(null,m).always(function(){i.resolve(j(f))}),i):i.resolve(j(f))}};
Finder.prototype.commands.help=function(){var a=this.fm,c=this,b=/\{url\}/,d=/\{link\}/,e=['<div class="ui-tabs ui-widget ui-widget-content ui-corner-all finder-help">','<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">'],f;this.alwaysEnabled=!0;this.updateOnSelect=!1;this.state=0;this.shortcuts=[{pattern:"f1",description:this.title}];setTimeout(function(){var g=c.options.view||["about","shortcuts","help"];$.each(g,function(b,c){e.push('<li class="ui-state-default ui-corner-top"><a href="#{id}">{title}</a></li>'.replace(/\{id\}/,
c).replace(/\{title\}/,a.i18n(c)))});e.push("</ul>");-1!==$.inArray("about",g)&&(e.push('<div id="about" class="ui-tabs-panel ui-widget-content ui-corner-bottom">'),e.push("<h3>gpFinder</h3>"),e.push('<div class="ui-priority-primary">'+a.i18n("webfm")+"</div>"),e.push('<div class="ui-priority-secondary">'+a.i18n("ver")+": "+a.version+", "+a.i18n("protocolver")+': <span id="apiver"></span></div>'),e.push('<div class="ui-priority-secondary">jQuery/jQuery UI: '+$().jquery+"/"+$.ui.version+"</div>"),
e.push('<div class="finder-help-separator"/>'),e.push('<div class="finder-help-link"> <a href="{url}">{link}</a></div>'.replace(b,"https://github.com/oyejorge/gpFinder/wiki").replace(d,a.i18n("docs"))),e.push('<div class="finder-help-link"> <a href="{url}">{link}</a></div>'.replace(b,"https://github.com/oyejorge/gpFinder/issues").replace(d,"Issues")),e.push('<div class="finder-help-link"> <a href="{url}">{link}</a></div>'.replace(b,"https://github.com/oyejorge/gpFinder").replace(d,a.i18n("github"))),
e.push('<div class="finder-help-link"> <a href="{url}">{link}</a></div>'.replace(b,"https://elfinder.org").replace(d,"gpFinder is an adaptation of elFinder")),e.push('<div class="finder-help-separator"/>'),e.push('<div class="finder-help-separator"/>'),e.push('<div class="finder-help-license">'+a.i18n("icons")+': <a href="http://pixelmixer.ru/" target="_blank">Pixelmixer</a>, <a href="http://p.yusukekamiyamane.com" target="_blank">Fugue</a></div>'),e.push('<div class="finder-help-separator"/>'),e.push('<div class="finder-help-license">Licence: BSD Licence</div>'),
e.push('<div class="finder-help-license">Copyright \u00a9 2009-2011, Studio 42</div>'),e.push('<div class="finder-help-license">\u201e \u2026'+a.i18n("dontforget")+" \u201d</div>"),e.push("</div>"));if(-1!==$.inArray("shortcuts",g)){var h=a.shortcuts();e.push('<div id="shortcuts" class="ui-tabs-panel ui-widget-content ui-corner-bottom">');h.length?(e.push('<div class="ui-widget-content finder-help-shortcuts">'),$.each(h,function(a,b){e.push('<div class="finder-help-shortcut"><div class="finder-help-shortcut-pattern">{pattern}</div> {descrip}</div>'.replace(/\{pattern\}/,
b[0]).replace(/\{descrip\}/,b[1]))}),e.push("</div>")):e.push('<div class="finder-help-disabled">'+a.i18n("shortcutsof")+"</div>");e.push("</div>")}-1!==$.inArray("help",g)&&(e.push('<div id="help" class="ui-tabs-panel ui-widget-content ui-corner-bottom">'),e.push('<a href="http://gpfinder.org/index.php/Forum" target="_blank" class="finder-dont-panic"><span>DON\'T PANIC</span></a>'),e.push("</div>"));e.push("</div>");f=$(e.join(""));a.one("load",function(){f.find("#apiver").text(a.api)});f.find(".ui-tabs-nav li").hover(function(){$(this).toggleClass("ui-state-hover")}).children().click(function(a){var b=
$(this);a.preventDefault();a.stopPropagation();b.is(".ui-tabs-selected")||(b.parent().addClass("ui-tabs-selected ui-state-active").siblings().removeClass("ui-tabs-selected").removeClass("ui-state-active"),f.find(".ui-tabs-panel").hide().filter(b.attr("href")).show())}).filter(":first").click()},200);this.getstate=function(){return 0};this.exec=function(){this.dialog||(this.dialog=this.fm.dialog(f,{title:this.title,width:530,autoOpen:!1,destroyOnClose:!1}));this.dialog.finderdialog("open").find(".ui-tabs-nav li a:first").click()}};
Finder.prototype.commands.home=function(){this.title="Home";this.alwaysEnabled=!0;this.updateOnSelect=!1;this.shortcuts=[{pattern:"ctrl+home ctrl+shift+up",description:"Home"}];this.getstate=function(){var a=this.fm.root(),c=this.fm.cwd().hash;return a&&c&&a!=c?0:-1};this.exec=function(){return this.fm.exec("open",this.fm.root())}};
Finder.prototype.commands.info=function(){var a=this.fm,c={calc:a.i18n("calc"),size:a.i18n("size"),unknown:a.i18n("unknown"),path:a.i18n("path"),aliasfor:a.i18n("aliasfor"),modify:a.i18n("modify"),perms:a.i18n("perms"),locked:a.i18n("locked"),dim:a.i18n("dim"),kind:a.i18n("kind"),files:a.i18n("files"),folders:a.i18n("folders"),items:a.i18n("items"),yes:a.i18n("yes"),no:a.i18n("no"),link:a.i18n("link")};this.tpl={main:'<div class="ui-helper-clearfix finder-info-title"><span class="finder-cwd-icon {class} ui-corner-all"/>{title}</div><table class="finder-info-tb">{content}</table>',
itemTitle:'<strong>{name}</strong><span class="finder-info-kind">{kind}</span>',groupTitle:"<strong>{items}: {num}</strong>",row:"<tr><td>{label} : </td><td>{value}</td></tr>",spinner:'<span>{text}</span> <span class="finder-info-spinner"/>'};this.alwaysEnabled=!0;this.updateOnSelect=!1;this.shortcuts=[{pattern:"ctrl+i"}];this.init=function(){$.each(c,function(b,d){c[b]=a.i18n(d)})};this.getstate=function(a){a=this.files(a);return a.length?0:-1};this.exec=function(a){var d=this.fm,e=this.tpl,f=e.row,
g=this.files(a),h=g.length,a=[],i=e.main,j={title:this.title,width:"auto",close:function(){$(this).finderdialog("destroy")}},m=[],k=function(a){n.find(".finder-info-spinner").parent().text(a)},l=d.namespace+"-info-"+$.map(g,function(a){return a.hash}).join("-"),n=d.getUI().find("#"+l),q,s,r,t;if(!h)return $.Deferred().reject();if(n.length)return n.finderdialog("toTop"),$.Deferred().resolve();1==h?(g=g[0],i=i.replace("{class}",d.mime2class(g.mime)),r=e.itemTitle.replace("{name}",g.name).replace("{kind}",
d.mime2kind(g)),g.tmb&&(s=d.option("tmbUrl")+g.tmb),g.read?"directory"!=g.mime||g.alias?q=d.formatSize(g.size):(q=e.spinner.replace("{text}",c.calc),m.push(g.hash)):q=c.unknown,a.push(f.replace("{label}",c.size).replace("{value}",q)),g.alias&&a.push(f.replace("{label}",c.aliasfor).replace("{value}",g.alias)),a.push(f.replace("{label}",c.path).replace("{value}",d.escape(d.path(g.hash)))),g.read&&a.push(f.replace("{label}",c.link).replace("{value}",'<a href="'+d.url(g.hash)+'" target="_blank">'+g.name+
"</a>")),g.dim?a.push(f.replace("{label}",c.dim).replace("{value}",g.dim)):-1!==g.mime.indexOf("image")&&(g.width&&g.height?a.push(f.replace("{label}",c.dim).replace("{value}",g.width+"x"+g.height)):(a.push(f.replace("{label}",c.dim).replace("{value}",e.spinner.replace("{text}",c.calc))),d.request({data:{cmd:"dim",target:g.hash},preventDefault:!0}).fail(function(){k(c.unknown)}).done(function(a){k(a.dim||c.unknown)}))),a.push(f.replace("{label}",c.modify).replace("{value}",d.formatDate(g))),a.push(f.replace("{label}",
c.perms).replace("{value}",d.formatPermissions(g))),a.push(f.replace("{label}",c.locked).replace("{value}",g.locked?c.yes:c.no))):(i=i.replace("{class}","finder-cwd-icon-group"),r=e.groupTitle.replace("{items}",c.items).replace("{num}",h),(t=$.map(g,function(a){return"directory"==a.mime?1:null}).length)?(a.push(f.replace("{label}",c.kind).replace("{value}",t==h?c.folders:c.folders+" "+t+", "+c.files+" "+(h-t))),a.push(f.replace("{label}",c.size).replace("{value}",e.spinner.replace("{text}",c.calc))),
m=$.map(g,function(a){return a.hash})):(q=0,$.each(g,function(a,b){var c=parseInt(b.size);q=0<=c&&0<=q?q+c:"unknown"}),a.push(f.replace("{label}",c.kind).replace("{value}",c.files)),a.push(f.replace("{label}",c.size).replace("{value}",d.formatSize(q)))));i=i.replace("{title}",r).replace("{content}",a.join(""));n=d.dialog(i,j);n.attr("id",l);s&&$("<img/>").load(function(){n.find(".finder-cwd-icon").css("background",'url("'+s+'") center center no-repeat')}).attr("src",s);m.length&&d.request({data:{cmd:"size",
targets:m},preventDefault:!0}).fail(function(){k(c.unknown)}).done(function(a){a=parseInt(a.size);k(0<=a?d.formatSize(a):c.unknown)})}};Finder.prototype.commands.mkdir=function(){this.disableOnSearch=!0;this.updateOnSelect=!1;this.mime="directory";this.prefix="untitled folder";this.exec=$.proxy(this.fm.res("mixin","make"),this);this.shortcuts=[{pattern:"ctrl+shift+n"}];this.getstate=function(){return!this._disabled&&this.fm.cwd().write?0:-1}};
Finder.prototype.commands.mkfile=function(){this.disableOnSearch=!0;this.updateOnSelect=!1;this.mime="text/plain";this.prefix="untitled file.txt";this.exec=$.proxy(this.fm.res("mixin","make"),this);this.getstate=function(){return!this._disabled&&this.fm.cwd().write?0:-1}};
Finder.prototype.commands.netmount=function(){var a=this;this.alwaysEnabled=!0;this.updateOnSelect=!1;this.drivers=[];this.handlers={load:function(){this.drivers=this.fm.netDrivers}};this.getstate=function(){return this.drivers.length?0:-1};this.exec=function(){var c=a.fm,b=$.Deferred();if(!a.dialog){var d,e={protocol:$("<select/>"),host:$('<input type="text"/>'),port:$('<input type="text"/>'),path:$('<input type="text" value="/"/>'),user:$('<input type="text"/>'),pass:$('<input type="password"/>')};
d={title:c.i18n("netMountDialogTitle"),resizable:!1,modal:!0,destroyOnClose:!0,close:function(){delete a.dialog;"resolved"!=b.state()&&"rejected"!=b.state()&&b.reject()},buttons:{}};var f=$('<table class="finder-info-tb finder-netmount-tb"/>');$.each(a.drivers,function(a,b){e.protocol.append('<option value="'+b+'">'+c.i18n(b)+"</option>")});$.each(e,function(a,b){"protocol"!=a&&b.addClass("ui-corner-all");f.append($("<tr/>").append($("<td>"+c.i18n(a)+"</td>")).append($("<td/>").append(b)))});d.buttons[c.i18n("btnMount")]=
function(){var c={cmd:"netmount"};$.each(e,function(a,b){var d=$.trim(b.val());d&&(c[a]=d)});if(!c.host)return a.fm.trigger("error",{error:"errNetMountHostReq"});a.fm.request({data:c,notify:{type:"netmount",cnt:1}}).done(function(){b.resolve()}).fail(function(a){b.reject(a)});a.dialog.finderdialog("close")};d.buttons[c.i18n("btnCancel")]=function(){a.dialog.finderdialog("close")};d=c.dialog(f,d);a.dialog=d}return b.promise()}};
Finder.prototype.commands.open=function(){this.alwaysEnabled=!0;this._handlers={dblclick:function(a){a.preventDefault();this.exec()},"select enable disable reload":function(a){this.update("disable"==a.type?-1:void 0)}};this.shortcuts=[{pattern:"ctrl+down numpad_enter"+("mac"!=this.fm.OS&&" enter")}];this.getstate=function(a){var a=this.files(a),c=a.length;return 1==c?0:c?$.map(a,function(a){return"directory"==a.mime?null:a}).length==c?0:-1:-1};this.exec=function(a){var c=this.fm,b=$.Deferred().fail(function(a){a&&
c.error(a)}),d=this.files(a),e=d.length,f,g,h;if(!e)return b.reject();if(1==e&&(f=d[0])&&"directory"==f.mime)return f&&!f.read?b.reject(["errOpen",f.name,"errPerm"]):c.request({data:{cmd:"open",target:f.thash||f.hash},notify:{type:"open",cnt:1,hideCnt:!0},syncOnFail:!0});d=$.map(d,function(a){return"directory"!=a.mime?a:null});if(e!=d.length)return b.reject();for(e=d.length;e--;){f=d[e];if(!f.read)return b.reject(["errOpen",f.name,"errPerm"]);if(!(g=c.url(f.hash)))g=c.options.url,g=g+(-1===g.indexOf("?")?
"?":"&")+(c.oldAPI?"cmd=open&current="+f.phash:"cmd=file")+"&target="+f.hash;h="";f.dim&&(f=f.dim.split("x"),h="width="+(parseInt(f[0])+20)+",height="+(parseInt(f[1])+20));if(!window.open(g,"_blank",h+",top=50,left=50,scrollbars=yes,resizable=yes"))return b.reject("errPopup")}return b.resolve(a)}};
Finder.prototype.commands.paste=function(){this.updateOnSelect=!1;this.handlers={changeclipboard:function(){this.update()}};this.shortcuts=[{pattern:"ctrl+v shift+insert"}];this.getstate=function(a){if(this._disabled)return-1;if(a){if($.isArray(a)){if(1!=a.length)return-1;a=this.fm.file(a[0])}}else a=this.fm.cwd();return this.fm.clipboard().length&&"directory"==a.mime&&a.write?0:-1};this.exec=function(a){var c=this,b=c.fm,a=a?this.files(a)[0]:b.cwd(),d=b.clipboard(),e=d.length,f=e?d[0].cut:!1,g=f?
"errMove":"errCopy",h=[],i=[],j=$.Deferred().fail(function(a){a&&b.error(a)}),m,k;if(!e||!a||"directory"!=a.mime)return j.reject();if(!a.write)return j.reject([g,d[0].name,"errPerm"]);m=b.parents(a.hash);$.each(d,function(c,e){if(!e.read)return!j.reject([g,d[0].name,"errPerm"]);if(f&&e.locked)return!j.reject(["errLocked",e.name]);if(-1!==$.inArray(e.hash,m))return!j.reject(["errCopyInItself",e.name]);k=b.parents(e.hash);if(-1!==$.inArray(a.hash,k)&&$.map(k,function(c){c=b.file(c);return c.phash==
a.hash&&c.name==e.name?c:null}).length)return!j.reject(["errReplByChild",e.name]);e.phash==a.hash?i.push(e.hash):h.push({hash:e.hash,phash:e.phash,name:e.name})});return"rejected"==j.state()?j:$.when(i.length&&b._commands.duplicate?b.exec("duplicate",i):$.Deferred().resolve(),function(d){var e=$.Deferred(),g=[],h=function(a){var c=d[g[a]],i=a==g.length-1;c&&b.confirm({title:b.i18n(f?"moveFiles":"copyFiles"),text:b.i18n(["errExists",c.name,"confirmRepl"]),all:!i,accept:{label:"btnYes",callback:function(b){!i&&
!b?h(++a):j(d)}},reject:{label:"btnNo",callback:function(b){var c;if(b)for(c=g.length;a<c--;)d[g[c]].remove=!0;else d[g[a]].remove=!0;!i&&!b?h(++a):j(d)}},cancel:{label:"btnCancel",callback:function(){e.resolve()}}})},i=function(a){for(var b=[],c=d.length;c--;)-1!==$.inArray(d[c].name,a)&&b.unshift(c);g=b;g.length?h(0):j(d)},j=function(c){var c=$.map(c,function(a){return!a.remove?a:null}),d=c.length,g;if(!d)return e.resolve();g=c[0].phash;c=$.map(c,function(a){return a.hash});b.request({data:{cmd:"paste",
dst:a.hash,targets:c,cut:f?1:0,src:g},notify:{type:f?"move":"copy",cnt:d}}).always(function(){e.resolve();b.unlockfiles({files:c})})};if(c._disabled||!d.length)return e.resolve();b.oldAPI?j(d):b.option("copyOverwrite")?a.hash==b.cwd().hash?i($.map(b.files(),function(b){return b.phash==a.hash?b.name:null})):b.request({data:{cmd:"ls",target:a.hash},notify:{type:"prepare",cnt:1,hideCnt:!0},preventFail:!0}).always(function(a){i(a.list||[])}):j(d);return e}(h)).always(function(){f&&b.clipboard([])})}};
Finder.prototype.commands.quicklook=function(){var a=this,c=a.fm,b=0,d=function(a){$(document).trigger($.Event("keydown",{keyCode:a,ctrlKey:!1,shiftKey:!1,altKey:!1,metaKey:!1}))},e=function(a){return{opacity:0,width:20,height:"list"==c.view?1:20,top:a.offset().top+"px",left:a.offset().left+"px"}},f=function(){var a=$(window);return{opacity:1,width:h,height:i,top:parseInt((a.height()-i)/2+a.scrollTop()),left:parseInt((a.width()-h)/2+a.scrollLeft())}},g=function(a){var b=document.createElement(a.substr(0,
a.indexOf("/"))),c=!1;try{c=b.canPlayType&&b.canPlayType(a)}catch(d){}return c&&""!==c&&"no"!=c},h,i,j,m,k=$('<div class="finder-quicklook-title"/>'),l=$("<div/>"),n=$('<div class="finder-quicklook-info"/>'),q=$('<div class="finder-quicklook-navbar-icon finder-quicklook-navbar-icon-fullscreen"/>').mousedown(function(b){var d=a.window,e=d.is(".finder-quicklook-fullscreen"),f="scroll."+c.namespace,g=$(window);b.stopPropagation();e?(d.css(d.data("position")).unbind("mousemove"),g.unbind(f).trigger(a.resize).unbind(a.resize),
s.unbind("mouseenter").unbind("mousemove")):(d.data("position",{left:d.css("left"),top:d.css("top"),width:d.width(),height:d.height()}).css({width:"100%",height:"100%"}),$(window).bind(f,function(){d.css({left:parseInt($(window).scrollLeft())+"px",top:parseInt($(window).scrollTop())+"px"})}).bind(a.resize,function(){a.preview.trigger("changesize")}).trigger(f).trigger(a.resize),d.bind("mousemove",function(){s.stop(!0,!0).show().delay(3E3).fadeOut("slow")}).mousemove(),s.mouseenter(function(){s.stop(!0,
!0).show()}).mousemove(function(a){a.stopPropagation()}));s.attr("style","").draggable(e?"destroy":{});d.toggleClass("finder-quicklook-fullscreen");$(this).toggleClass("finder-quicklook-navbar-icon-fullscreen-off");$.fn.resizable&&j.add(d).resizable(e?"enable":"disable").removeClass("ui-state-disabled")}),s=$('<div class="finder-quicklook-navbar"/>').append($('<div class="finder-quicklook-navbar-icon finder-quicklook-navbar-icon-prev"/>').mousedown(function(){d(37)})).append(q).append($('<div class="finder-quicklook-navbar-icon finder-quicklook-navbar-icon-next"/>').mousedown(function(){d(39)})).append('<div class="finder-quicklook-navbar-separator"/>').append($('<div class="finder-quicklook-navbar-icon finder-quicklook-navbar-icon-close"/>').mousedown(function(){a.window.trigger("close")}));
this.resize="resize."+c.namespace;this.info=$('<div class="finder-quicklook-info-wrapper"/>').append(l).append(n);this.preview=$('<div class="finder-quicklook-preview ui-helper-clearfix"/>').bind("change",function(){a.info.attr("style","").hide();l.removeAttr("class").attr("style","");n.html("")}).bind("update",function(b){var c=a.fm,d=b.file,e;d?(!d.read&&b.stopImmediatePropagation(),a.window.data("hash",d.hash),a.preview.unbind("changesize").trigger("change").children().remove(),k.html(c.escape(d.name)),
n.html('<div class="finder-quicklook-info-data">{value}</div>'.replace(/\{value\}/,d.name)+'<div class="finder-quicklook-info-data">{value}</div>'.replace(/\{value\}/,c.mime2kind(d))+("directory"==d.mime?"":'<div class="finder-quicklook-info-data">{value}</div>'.replace(/\{value\}/,c.formatSize(d.size)))+'<div class="finder-quicklook-info-data">{value}</div>'.replace(/\{value\}/,c.i18n("modify")+": "+c.formatDate(d))),l.addClass("finder-cwd-icon ui-corner-all "+c.mime2class(d.mime)),d.tmb&&$("<img/>").hide().appendTo(a.preview).load(function(){l.css("background",
'url("'+e+'") center center no-repeat');$(this).remove()}).attr("src",e=c.tmb(d.hash)),a.info.delay(100).fadeIn(10)):b.stopImmediatePropagation()});this.window=$('<div class="ui-helper-reset ui-widget finder-quicklook" style="position:absolute"/>').click(function(a){a.stopPropagation()}).append($('<div class="finder-quicklook-titlebar"/>').append(k).append($('<span class="ui-icon ui-icon-circle-close"/>').mousedown(function(b){b.stopPropagation();a.window.trigger("close")}))).append(this.preview.add(s)).append(a.info.hide()).draggable({handle:"div.finder-quicklook-titlebar"}).bind("open",
function(){var c=a.window,d=a.value,g;if(a.closed()&&d&&(g=m.find("#"+d.hash)).length)b=1,g.trigger("scrolltoview"),c.css(e(g)).show().animate(f(),550,function(){b=2;a.update(1,a.value)})}).bind("close",function(){var c=a.window,d=a.preview.trigger("change"),f=m.find("#"+c.data("hash")),g=function(){b=0;c.hide();d.children().remove();a.update(0,a.value)};a.opened()&&(b=1,c.is(".finder-quicklook-fullscreen")&&q.mousedown(),f.length?c.animate(e(f),500,g):g())});this.alwaysEnabled=!0;this.value=null;
this.handlers={select:function(){this.update(void 0,this.fm.selectedFiles()[0])},error:function(){a.window.is(":visible")&&a.window.data("hash","").trigger("close")},"searchshow searchhide":function(){this.opened()&&this.window.trigger("close")}};this.shortcuts=[{pattern:"space"}];this.support={audio:{ogg:g('audio/ogg; codecs="vorbis"'),mp3:g("audio/mpeg;"),wav:g('audio/wav; codecs="1"'),m4a:g("audio/x-m4a;")||g("audio/aac;")},video:{ogg:g('video/ogg; codecs="theora"'),webm:g('video/webm; codecs="vp8, vorbis"'),
mp4:g('video/mp4; codecs="avc1.42E01E"')||g('video/mp4; codecs="avc1.42E01E, mp4a.40.2"')}};this.closed=function(){return 0==b};this.opened=function(){return 2==b};this.init=function(){var b=this.options,d=this.window,e=this.preview;h=0<b.width?parseInt(b.width):450;i=0<b.height?parseInt(b.height):300;c.one("load",function(){j=c.getUI();m=c.getUI("cwd");d.appendTo("body").zIndex(100+j.zIndex());$(document).keydown(function(b){27==b.keyCode&&a.opened()&&d.trigger("close")});$.fn.resizable&&d.resizable({handles:"se",
minWidth:350,minHeight:120,resize:function(){e.trigger("changesize")}});a.change(function(){a.opened()&&(a.value?e.trigger($.Event("update",{file:a.value})):d.trigger("close"))});$.each(c.commands.quicklook.plugins||[],function(b,c){"function"==typeof c&&new c(a)});e.bind("update",function(){a.info.show()})})};this.getstate=function(){return 1==this.fm.selected().length?2==b?1:0:-1};this.exec=function(){this.enabled()&&this.window.trigger(this.opened()?"close":"open")};this.hideinfo=function(){this.info.stop(!0).hide()}};
Finder.prototype.commands.quicklook.plugins=[function(a){var c=["image/jpeg","image/png","image/gif"],b=a.preview;$.each(navigator.mimeTypes,function(a,b){var f=b.type;0===f.indexOf("image/")&&$.inArray(f,c)&&c.push(f)});b.bind("update",function(d){var e=d.file,f;-1!==$.inArray(e.mime,c)&&(d.stopImmediatePropagation(),f=$("<img/>").hide().appendTo(b).load(function(){setTimeout(function(){var c=(f.width()/f.height()).toFixed(2);b.bind("changesize",function(){var a=parseInt(b.width()),d=parseInt(b.height()),
e;c<(a/d).toFixed(2)?(e=d,a=Math.floor(e*c)):e=Math.floor(a/c);f.width(a).height(e).css("margin-top",e<d?Math.floor((d-e)/2):0)}).trigger("changesize");a.hideinfo();f.fadeIn(100)},1)}).attr("src",a.fm.url(e.hash)))})},function(a){var c=["text/html","application/xhtml+xml"],b=a.preview,d=a.fm;b.bind("update",function(e){var f=e.file,g;-1!==$.inArray(f.mime,c)&&(e.stopImmediatePropagation(),b.one("change",function(){"resolved"!=g.state()&&"rejected"!=g.state()&&g.reject()}),g=d.request({data:{cmd:"get",
target:f.hash,current:f.phash},preventDefault:!0}).done(function(c){a.hideinfo();doc=$('<iframe class="finder-quicklook-preview-html"/>').appendTo(b)[0].contentWindow.document;doc.open();doc.write(c.content);doc.close()}))})},function(a){var c=a.fm,b=c.res("mimes","text"),d=a.preview;d.bind("update",function(e){var f=e.file,g=f.mime,h;if(0===g.indexOf("text/")||-1!==$.inArray(g,b))e.stopImmediatePropagation(),d.one("change",function(){"resolved"!=h.state()&&"rejected"!=h.state()&&h.reject()}),h=c.request({data:{cmd:"get",
target:f.hash},preventDefault:!0}).done(function(b){a.hideinfo();$('<div class="finder-quicklook-preview-text-wrapper"><pre class="finder-quicklook-preview-text">'+c.escape(b.content)+"</pre></div>").appendTo(d)})})},function(a){var c=a.fm,b=a.preview,d=!1;$.browser.safari&&-1!=navigator.platform.indexOf("Mac")||$.browser.msie?d=!0:$.each(navigator.plugins,function(a,b){$.each(b,function(a,b){if("application/pdf"==b.type)return!(d=!0)})});d&&b.bind("update",function(d){var f=d.file,g;"application/pdf"==
f.mime&&(d.stopImmediatePropagation(),b.one("change",function(){g.unbind("load").remove()}),g=$('<iframe class="finder-quicklook-preview-pdf"/>').hide().appendTo(b).load(function(){a.hideinfo();g.show()}).attr("src",c.url(f.hash)))})},function(a){var c=a.fm,b=a.preview,d=!1;$.each(navigator.plugins,function(a,b){$.each(b,function(a,b){if("application/x-shockwave-flash"==b.type)return!(d=!0)})});d&&b.bind("update",function(d){var f=d.file;"application/x-shockwave-flash"==f.mime&&(d.stopImmediatePropagation(),
a.hideinfo(),b.append($('<embed class="finder-quicklook-preview-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" src="'+c.url(f.hash)+'" quality="high" type="application/x-shockwave-flash" />')))})},function(a){var c=a.preview,b=!!a.options.autoplay,d={"audio/mpeg":"mp3","audio/mpeg3":"mp3","audio/mp3":"mp3","audio/x-mpeg3":"mp3","audio/x-mp3":"mp3","audio/x-wav":"wav","audio/wav":"wav","audio/x-m4a":"m4a","audio/aac":"m4a","audio/mp4":"m4a","audio/x-mp4":"m4a","audio/ogg":"ogg"},
e;c.bind("update",function(f){var g=f.file;a.support.audio[d[g.mime]]&&(f.stopImmediatePropagation(),e=$('<audio class="finder-quicklook-preview-audio" controls preload="auto" autobuffer><source src="'+a.fm.url(g.hash)+'" /></audio>').appendTo(c),b&&e[0].play())}).bind("change",function(){e&&e.parent().length&&(e[0].pause(),e.remove(),e=null)})},function(a){var c=a.preview,b=!!a.options.autoplay,d={"video/mp4":"mp4","video/x-m4v":"mp4","video/ogg":"ogg","application/ogg":"ogg","video/webm":"webm"},
e;c.bind("update",function(f){var g=f.file;a.support.video[d[g.mime]]&&(f.stopImmediatePropagation(),a.hideinfo(),e=$('<video class="finder-quicklook-preview-video" controls preload="auto" autobuffer><source src="'+a.fm.url(g.hash)+'" /></video>').appendTo(c),b&&e[0].play())}).bind("change",function(){e&&e.parent().length&&(e[0].pause(),e.remove(),e=null)})},function(a){var c=a.preview,b=[],d;$.each(navigator.plugins,function(a,c){$.each(c,function(a,c){(0===c.type.indexOf("audio/")||0===c.type.indexOf("video/"))&&
b.push(c.type)})});c.bind("update",function(e){var f=e.file,g=f.mime;-1!==$.inArray(f.mime,b)&&(e.stopImmediatePropagation(),(e=0===g.indexOf("video/"))&&a.hideinfo(),d=$('<embed src="'+a.fm.url(f.hash)+'" type="'+g+'" class="finder-quicklook-preview-'+(e?"video":"audio")+'"/>').appendTo(c))}).bind("change",function(){d&&d.parent().length&&(d.remove(),d=null)})}];
Finder.prototype.commands.reload=function(){this.updateOnSelect=this.alwaysEnabled=!0;this.shortcuts=[{pattern:"ctrl+shift+r f5"}];this.getstate=function(){return 0};this.exec=function(){var a=this.fm,c=a.sync(),b=setTimeout(function(){a.notify({type:"reload",cnt:1,hideCnt:!0});c.always(function(){a.notify({type:"reload",cnt:-1})})},a.notifyDelay);return c.always(function(){clearTimeout(b);a.trigger("reload")})}};
Finder.prototype.commands.rename=function(){this.shortcuts=[{pattern:"f2"+("mac"==this.fm.OS?" enter":"")}];this.getstate=function(){var a=this.fm.selectedFiles();return!this._disabled&&1==a.length&&a[0].phash&&!a[0].locked?0:-1};this.exec=function(){var a=this.fm,c=a.getUI("cwd"),b=a.selected(),d=b.length,e=a.file(b.shift()),f=$.Deferred().fail(function(b){var d=g.parent(),f=a.escape(e.name);d.length?(g.remove(),d.html(f)):(c.find("#"+e.hash).find(".finder-cwd-filename").html(f),setTimeout(function(){c.find("#"+
e.hash).click()},50));b&&a.error(b)}).always(function(){a.enable()}),g=$('<input type="text"/>').keydown(function(a){a.stopPropagation();a.stopImmediatePropagation();a.keyCode==$.ui.keyCode.ESCAPE?f.reject():a.keyCode==$.ui.keyCode.ENTER&&g.blur()}).mousedown(function(a){a.stopPropagation()}).dblclick(function(a){a.stopPropagation();a.preventDefault()}).blur(function(){var b=$.trim(g.val()),c=g.parent();if(c.length){g[0].setSelectionRange&&g[0].setSelectionRange(0,0);if(b==e.name)return f.reject();
if(!b)return f.reject("errInvName");if(a.fileByName(b,e.phash))return f.reject(["errExists",b]);c.html(a.escape(b));a.lockfiles({files:[e.hash]});a.request({data:{cmd:"rename",target:e.hash,name:b},notify:{type:"rename",cnt:1}}).fail(function(){f.reject();a.sync()}).done(function(a){f.resolve(a)}).always(function(){a.unlockfiles({files:[e.hash]})})}}),b=c.find("#"+e.hash).find(".finder-cwd-filename").empty().append(g.val(e.name)),h=g.val().replace(/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/ig,
"");if(this.disabled())return f.reject();if(!e||1<d||!b.length)return f.reject("errCmdParams",this.title);if(e.locked)return f.reject(["errLocked",e.name]);a.one("select",function(){g.parent().length&&e&&-1===$.inArray(e.hash,a.selected())&&g.blur()});g.select().focus();g[0].setSelectionRange&&g[0].setSelectionRange(0,h.length);return f}};
Finder.prototype.commands.resize=function(){this.updateOnSelect=!1;this.getstate=function(){var a=this.fm.selectedFiles();return!this._disabled&&1==a.length&&a[0].read&&a[0].write&&-1!==a[0].mime.indexOf("image/")?0:-1};this.exec=function(a){var c=this.fm,b=this.files(a),d=$.Deferred(),e;if(!b.length||-1===b[0].mime.indexOf("image/"))return d.reject();a="resize-"+c.namespace+"-"+b[0].hash;e=c.getUI().find("#"+a);if(e.length)return e.finderdialog("toTop"),d.resolve();var f=b[0],g=$('<div class="finder-dialog-resize"/>'),
h=$('<div class="finder-resize-control"/>'),i=$('<div class="finder-resize-preview"/>'),j=$('<div class="finder-resize-spinner">'+c.i18n("ntfloadimg")+"</div>"),m=$('<div class="finder-resize-handle"/>'),k=$('<div class="finder-resize-handle"/>'),l=$('<div class="finder-resize-uiresize"/>'),n=$('<div class="finder-resize-uicrop"/>'),q=$('<div class="finder-resize-rotate"/>'),b=$('<div class="ui-state-default finder-button"/>').attr("title",c.i18n("rotate-cw")).append($('<span class="finder-button-icon finder-button-icon-rotate-l"/>').click(function(){M-=
90;p.update(M)}));e=$('<div class="ui-state-default finder-button"/>').attr("title",c.i18n("rotate-ccw")).append($('<span class="finder-button-icon finder-button-icon-rotate-r"/>').click(function(){M+=90;p.update(M)}));var s=$("<span />"),r=$('<div class="ui-state-default ui-corner-all finder-resize-reset"><span class="ui-icon ui-icon-arrowreturnthick-1-w"/></div>'),t=$('<div class="finder-resize-type"/>').append('<input type="radio" name="type" id="type-resize" value="resize" checked="checked" /><label for="type-resize">'+
c.i18n("resize")+"</label>").append('<input type="radio" name="type" id="type-crop"   value="crop"/><label for="type-crop">'+c.i18n("crop")+"</label>").append('<input type="radio" name="type" id="type-rotate" value="rotate"/><label for="type-rotate">'+c.i18n("rotate")+"</label>");$("input",t).change(function(){var a=$("input:checked",t).val();W();z(!0);V(!0);X(!0);"resize"==a?(l.show(),q.hide(),n.hide(),z()):"crop"==a?(q.hide(),l.hide(),n.show(),V()):"rotate"==a&&(l.hide(),n.hide(),q.show(),X())});
var y=$('<input type="checkbox" checked="checked"/>').change(function(){K=!!y.prop("checked");N.fixHeight();z(!0);z()}),C=$('<input type="text" size="5"/>').change(function(){var a=parseInt(C.val()),b=parseInt(K?a/u:G.val());0<a&&0<b&&(N.updateView(a,b),G.val(b))}),G=$('<input type="text" size="5"/>').change(function(){var a=parseInt(G.val()),b=parseInt(K?a*u:C.val());0<b&&0<a&&(N.updateView(b,a),C.val(b))}),L=$('<input type="text" size="5"/>'),I=$('<input type="text" size="5"/>'),J=$('<input type="text" size="5"/>'),
F=$('<input type="text" size="5"/>'),A=$('<input type="text" size="3" maxlength="3" value="0" />').change(function(){p.update()}),v=$('<div class="finder-resize-rotate-slider"/>').slider({min:0,max:359,value:A.val(),animate:!0,change:function(a,b){b.value!=v.slider("value")&&p.update(b.value)},slide:function(a,b){p.update(b.value,!1)}}),u=1,D=1,w=0,H=0,K=!0,B=0,O=0,U=0,R=0,M=0,x=$("<img/>").load(function(){j.remove();w=x.width();H=x.height();u=w/H;N.updateView(w,H);m.append(x.show()).show();C.val(w);
G.val(H);var a=Math.min(B,O)/Math.sqrt(Math.pow(w,2)+Math.pow(H,2));U=w*a;R=H*a;h.find("input,select").removeAttr("disabled").filter(":text").keydown(function(a){var b=a.keyCode,c;a.stopPropagation();37<=b&&40>=b||b==$.ui.keyCode.BACKSPACE||(b==$.ui.keyCode.DELETE||65==b&&(a.ctrlKey||a.metaKey)||27==b)||(9==b&&(c=$(this).parent()[a.shiftKey?"prev":"next"](".finder-resize-row").children(":text"),c.length&&c.focus()),13==b?Z():48<=b&&57>=b||96<=b&&105>=b||a.preventDefault())}).filter(":first").focus();
z();r.hover(function(){r.toggleClass("ui-state-hover")}).click(W)}).error(function(){j.text("Unable to load image").css("background","transparent")}),S=$("<div/>"),P=$("<img/>"),T=$("<div/>"),E=$("<img/>"),W=function(){C.val(w);G.val(H);N.updateView(w,H)},N={update:function(){C.val(parseInt(x.width()/D));G.val(parseInt(x.height()/D))},updateView:function(a,b){a>B||b>O?a/B>b/O?x.width(B).height(Math.ceil(x.width()/u)):x.height(O).width(Math.ceil(x.height()*u)):x.width(a).height(b);D=x.width()/a;s.text("1 : "+
(1/D).toFixed(2));N.updateHandle()},updateHandle:function(){m.width(x.width()).height(x.height())},fixWidth:function(){var a;K&&(a=G.val(),a=parseInt(a*u),N.updateView(void 0,a),C.val(void 0))},fixHeight:function(){var a,b;K&&(a=C.val(),b=parseInt(a/u),N.updateView(a,b),G.val(b))}},Q={update:function(){J.val(parseInt(k.width()/D));F.val(parseInt(k.height()/D));L.val(parseInt((k.offset().left-P.offset().left)/D));I.val(parseInt((k.offset().top-P.offset().top)/D))},resize_update:function(){Q.update();
T.width(k.width());T.height(k.height())}},p={mouseStartAngle:0,imageStartAngle:0,imageBeingRotated:!1,update:function(a,b){"undefined"==typeof a&&(M=a=parseInt(A.val()));"undefined"==typeof b&&(b=!0);!b||$.browser.opera||$.browser.msie&&9>parseInt($.browser.version)?E.rotate(a):E.animate({rotate:a+"deg"});a%=360;0>a&&(a+=360);A.val(parseInt(a));v.slider("value",A.val())},execute:function(a){if(p.imageBeingRotated){var b=p.getCenter(E),b=Math.atan2(a.pageY-b[1],a.pageX-b[0])-p.mouseStartAngle+p.imageStartAngle,
b=Math.round(180*parseFloat(b)/Math.PI);a.shiftKey&&(b=15*Math.round((b+6)/15));E.rotate(b);b%=360;0>b&&(b+=360);A.val(b);v.slider("value",A.val());return!1}},start:function(a){p.imageBeingRotated=!0;var b=p.getCenter(E);p.mouseStartAngle=Math.atan2(a.pageY-b[1],a.pageX-b[0]);p.imageStartAngle=parseFloat(E.rotate())*Math.PI/180;$(document).mousemove(p.execute);return!1},stop:function(){if(p.imageBeingRotated)return $(document).unbind("mousemove",p.execute),setTimeout(function(){p.imageBeingRotated=
!1},10),!1},getCenter:function(){var a=E.rotate();E.rotate(0);var b=E.offset(),c=b.left+E.width()/2,b=b.top+E.height()/2;E.rotate(a);return[c,b]}},z=function(a){$.fn.resizable&&(a?(m.resizable("destroy"),m.hide()):(m.show(),m.resizable({alsoResize:x,aspectRatio:K,resize:N.update,stop:N.fixHeight})))},V=function(a){$.fn.draggable&&$.fn.resizable&&(a?(k.resizable("destroy"),k.draggable("destroy"),S.hide()):(P.width(x.width()).height(x.height()),T.width(x.width()).height(x.height()),k.width(P.width()).height(P.height()).offset(P.offset()).resizable({containment:S,
resize:Q.resize_update,handles:"all"}).draggable({handle:k,containment:P,drag:Q.update}),S.show().width(x.width()).height(x.height()),Q.update()))},X=function(a){$.fn.draggable&&$.fn.resizable&&(a?E.hide():E.show().width(U).height(R).css("margin-top",(O-R)/2+"px").css("margin-left",(B-U)/2+"px"))},Z=function(){var a,b,e,h,i,j=$("input:checked",t).val();C.add(G).change();if("resize"==j)a=parseInt(C.val())||0,b=parseInt(G.val())||0;else if("crop"==j)a=parseInt(J.val())||0,b=parseInt(F.val())||0,e=parseInt(L.val())||
0,h=parseInt(I.val())||0;else{j="rotate";a=w;b=H;i=parseInt(A.val())||0;if(0>i||360<i)return c.error("Invalid rotate degree");if(0==i||360==i)return c.error("Image dose not rotated")}if("rotate"!=j){if(0>=a||0>=b)return c.error("Invalid image size");if(a==w&&b==H)return c.error("Image size not changed")}g.finderdialog("close");c.request({data:{cmd:"resize",target:f.hash,width:a,height:b,x:e,y:h,degree:i,mode:j},notify:{type:"resize",cnt:1}}).fail(function(a){d.reject(a)}).done(function(){d.resolve()})},
Y={},aa=c.url(f.hash);E.mousedown(p.start);$(document).mouseup(p.stop);l.append($('<div class="finder-resize-row"/>').append($('<div class="finder-resize-label"/>').text(c.i18n("width"))).append(C).append(r)).append($('<div class="finder-resize-row"/>').append($('<div class="finder-resize-label"/>').text(c.i18n("height"))).append(G)).append($('<div class="finder-resize-row"/>').append($("<label/>").text(c.i18n("aspectRatio")).prepend(y))).append($('<div class="finder-resize-row"/>').append(c.i18n("scale")+
" ").append(s));n.append($('<div class="finder-resize-row"/>').append($('<div class="finder-resize-label"/>').text("X")).append(L)).append($('<div class="finder-resize-row"/>').append($('<div class="finder-resize-label"/>').text("Y")).append(I)).append($('<div class="finder-resize-row"/>').append($('<div class="finder-resize-label"/>').text(c.i18n("width"))).append(J)).append($('<div class="finder-resize-row"/>').append($('<div class="finder-resize-label"/>').text(c.i18n("height"))).append(F));q.append($('<div class="finder-resize-row"/>').append($('<div class="finder-resize-label"/>').text(c.i18n("rotate"))).append($('<div style="float:left; width: 130px;">').append($('<div style="float:left;">').append(A).append($("<span/>").text(c.i18n("degree")))).append($('<div class="ui-widget-content ui-corner-all finder-buttonset"/>').append(b).append($('<span class="ui-widget-content finder-toolbar-button-separator"/>')).append(e))).append(v));
g.append(t);h.append($('<div class="finder-resize-row"/>')).append(l).append(n.hide()).append(q.hide()).find("input,select").attr("disabled","disabled");m.append('<div class="finder-resize-handle-hline finder-resize-handle-hline-top"/>').append('<div class="finder-resize-handle-hline finder-resize-handle-hline-bottom"/>').append('<div class="finder-resize-handle-vline finder-resize-handle-vline-left"/>').append('<div class="finder-resize-handle-vline finder-resize-handle-vline-right"/>').append('<div class="finder-resize-handle-point finder-resize-handle-point-e"/>').append('<div class="finder-resize-handle-point finder-resize-handle-point-se"/>').append('<div class="finder-resize-handle-point finder-resize-handle-point-s"/>');
i.append(j).append(m.hide()).append(x.hide());k.css("position","absolute").append('<div class="finder-resize-handle-hline finder-resize-handle-hline-top"/>').append('<div class="finder-resize-handle-hline finder-resize-handle-hline-bottom"/>').append('<div class="finder-resize-handle-vline finder-resize-handle-vline-left"/>').append('<div class="finder-resize-handle-vline finder-resize-handle-vline-right"/>').append('<div class="finder-resize-handle-point finder-resize-handle-point-n"/>').append('<div class="finder-resize-handle-point finder-resize-handle-point-e"/>').append('<div class="finder-resize-handle-point finder-resize-handle-point-s"/>').append('<div class="finder-resize-handle-point finder-resize-handle-point-w"/>').append('<div class="finder-resize-handle-point finder-resize-handle-point-ne"/>').append('<div class="finder-resize-handle-point finder-resize-handle-point-se"/>').append('<div class="finder-resize-handle-point finder-resize-handle-point-sw"/>').append('<div class="finder-resize-handle-point finder-resize-handle-point-nw"/>');
i.append(S.css("position","absolute").hide().append(P).append(k.append(T)));i.append(E.hide());i.css("overflow","hidden");g.append(i).append(h);Y[c.i18n("btnCancel")]=function(){g.finderdialog("close")};Y[c.i18n("btnApply")]=Z;c.dialog(g,{title:f.name,width:650,resizable:!1,destroyOnClose:!0,buttons:Y,open:function(){i.zIndex(1+$(this).parent().zIndex())}}).attr("id",a);$.browser.msie&&9>parseInt($.browser.version)&&$(".finder-dialog").css("filter","");r.css("left",C.position().left+C.width()+12);
T.css({opacity:0.2,"background-color":"#fff",position:"absolute"});k.css("cursor","move");k.find(".finder-resize-handle-point").css({"background-color":"#fff",opacity:0.5,"border-color":"#000"});E.css("cursor","pointer");t.buttonset();B=i.width()-(m.outerWidth()-m.width());O=i.height()-(m.outerHeight()-m.height());x.attr("src",aa+(-1===aa.indexOf("?")?"?":"&")+"_="+Math.random());P.attr("src",x.attr("src"));E.attr("src",x.attr("src"));return d}};
(function(a){var c=function(a,b){var c=0;for(c in b)if("undefined"!=typeof a[b[c]])return b[c];a[b[c]]="";return b[c]};a.cssHooks.rotate={get:function(b){return a(b).rotate()},set:function(b,c){a(b).rotate(c);return c}};a.cssHooks.transform={get:function(a){var b=c(a.style,["WebkitTransform","MozTransform","OTransform","msTransform","transform"]);return a.style[b]},set:function(a,b){var f=c(a.style,["WebkitTransform","MozTransform","OTransform","msTransform","transform"]);return a.style[f]=b}};a.fn.rotate=
function(b){if("undefined"==typeof b)return a.browser.opera?(b=this.css("transform").match(/rotate\((.*?)\)/))&&b[1]?Math.round(180*parseFloat(b[1])/Math.PI):0:(b=this.css("transform").match(/rotate\((.*?)\)/))&&b[1]?parseInt(b[1]):0;this.css("transform",this.css("transform").replace(/none|rotate\(.*?\)/,"")+"rotate("+parseInt(b)+"deg)");return this};a.fx.step.rotate=function(b){0==b.state&&(b.start=a(b.elem).rotate(),b.now=b.start);a(b.elem).rotate(b.now)};if(a.browser.msie&&9>parseInt(a.browser.version)){var b=
a.cssHooks.transform.set;a.cssHooks.transform.set=function(a,c){b.apply(this,[a,c]);var f,g=1,h=1,i=1,j=1;if("undefined"==typeof a.style.msTransform){if("static"==a.currentStyle.position){f=a;for(var m=f.offsetLeft,k=f.offsetTop;f.offsetParent;){f=f.offsetParent;if(f!=document.body&&"static"!=f.currentStyle.position)break;f!=document.body&&f!=document.documentElement&&(m-=f.scrollLeft,k-=f.scrollTop);m+=f.offsetLeft;k+=f.offsetTop}a.style.position="absolute";a.style.left=m+"px";a.style.top=k+"px"}f=
(f=c.match(/rotate\((.*?)\)/))&&f[1]?parseInt(f[1]):0;f%=360;0>f&&(f=360+f);m=f*Math.PI/180;k=Math.cos(m);m=Math.sin(m);g*=k;h*=-m;i*=m;j*=k;a.style.filter=(a.style.filter||"").replace(/progid:DXImageTransform\.Microsoft\.Matrix\([^)]*\)/,"")+("progid:DXImageTransform.Microsoft.Matrix(M11="+g+",M12="+h+",M21="+i+",M22="+j+",FilterType='bilinear',sizingMethod='auto expand')");g=parseInt(a.style.width||a.width||0);h=parseInt(a.style.height||a.height||0);m=f*Math.PI/180;i=Math.abs(Math.cos(m));j=Math.abs(Math.sin(m));
a.style.marginLeft=Math.floor((g-(g*i+h*j))/2)+"px";a.style.marginTop=Math.floor((h-(g*j+h*i))/2)+"px"}return c}}})(jQuery);
Finder.prototype.commands.rm=function(){this.shortcuts=[{pattern:"delete ctrl+backspace"}];this.getstate=function(a){var c=this.fm,a=a||c.selected();return!this._disabled&&a.length&&$.map(a,function(a){var d=c.file(a);return d&&d.phash&&!d.locked?a:null}).length==a.length?0:-1};this.exec=function(a){var c=this.fm,b=$.Deferred().fail(function(a){a&&c.error(a)}),d=this.files(a),e=d.length,f=c.cwd().hash,g=!1;if(!e||this._disabled)return b.reject();$.each(d,function(a,d){if(!d.phash)return!b.reject(["errRm",
d.name,"errPerm"]);if(d.locked)return!b.reject(["errLocked",d.name]);d.hash==f&&(g=c.root(d.hash))});"rejected"!=b.state()&&(d=this.hashes(a),c.confirm({title:this.title,text:"confirmRm",accept:{label:"btnRm",callback:function(){c.lockfiles({files:d});c.request({data:{cmd:"rm",targets:d},notify:{type:"rm",cnt:e},preventFail:!0}).fail(function(a){b.reject(a)}).done(function(a){b.done(a);g&&c.exec("open",g)}).always(function(){c.unlockfiles({files:d})})}},cancel:{label:"btnCancel",callback:function(){b.reject()}}}));
return b}};Finder.prototype.commands.search=function(){this.title="Find files";this.options={ui:"searchbutton"};this.alwaysEnabled=!0;this.updateOnSelect=!1;this.getstate=function(){return 0};this.exec=function(a){var c=this.fm;if("string"==typeof a&&a)return c.trigger("searchstart",{query:a}),c.request({data:{cmd:"search",q:a},notify:{type:"search",cnt:1,hideCnt:!0}});c.getUI("toolbar").find("."+c.res("class","searchbtn")+" :text").focus();return $.Deferred().reject()}};
Finder.prototype.commands.sort=function(){this.options={ui:"sortbutton"};this.getstate=function(){return 0};this.exec=function(a,c){var b=this.fm,c=$.extend({type:b.sortType,order:b.sortOrder,stick:b.sortStickFolders},c);this.fm.setSort(c.type,c.order,c.stick);return $.Deferred().resolve()}};
Finder.prototype.commands.unmount=function(){var a=this.fm;this.alwaysEnabled=!0;this.updateOnSelect=!1;this.getstate=function(c){return!c||1<c.length?-1:a.file(c[0]).net?0:-1};this.exec=function(c){var b=c[0],d=$.Deferred();return a.request({data:{cmd:"unmount",target:b},notify:{type:"unmount",cnt:1}}).fail(function(a){d.reject(a)}).done(function(){d.resolve();$("#nav-"+b).closest(".finder-navbar-wrapper").detach();$(".finder-navbar-wrapper:first span:first").click()})}};
Finder.prototype.commands.up=function(){this.alwaysEnabled=!0;this.updateOnSelect=!1;this.shortcuts=[{pattern:"ctrl+up"}];this.getstate=function(){return this.fm.cwd().phash?0:-1};this.exec=function(){return this.fm.cwd().phash?this.fm.exec("open",this.fm.cwd().phash):$.Deferred().reject()}};
Finder.prototype.commands.upload=function(){var a=this.fm.res("class","hover");this.disableOnSearch=!0;this.updateOnSelect=!1;this.shortcuts=[{pattern:"ctrl+u"}];this.getstate=function(){return!this._disabled&&this.fm.cwd().write?0:-1};this.exec=function(c){var b=this.fm,d=function(a){f.finderdialog("close");b.upload(a).fail(function(a){e.reject(a)}).done(function(a){e.resolve(a)})},e,f,g,h,i;if(this.disabled())return $.Deferred().reject();if(c&&(c.input||c.files))return b.upload(c);e=$.Deferred();
g=$('<input type="file" multiple="true"/>').change(function(){d({input:g[0]})});h=$('<div class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"><span class="ui-button-text">'+b.i18n("selectForUpload")+"</span></div>").append($("<form/>").append(g)).hover(function(){h.toggleClass(a)});f=$('<div class="finder-upload-dialog-wrapper"/>').append(h);b.dragUpload&&(i=$('<div class="ui-corner-all finder-upload-dropbox">'+b.i18n("dropFiles")+"</div>").prependTo(f).after('<div class="finder-upload-dialog-or">'+
b.i18n("or")+"</div>")[0],i.addEventListener("dragenter",function(b){b.stopPropagation();b.preventDefault();$(i).addClass(a)},!1),i.addEventListener("dragleave",function(b){b.stopPropagation();b.preventDefault();$(i).removeClass(a)},!1),i.addEventListener("dragover",function(a){a.stopPropagation();a.preventDefault()},!1),i.addEventListener("drop",function(a){a.stopPropagation();a.preventDefault();d({files:a.dataTransfer.files})},!1));b.dialog(f,{title:this.title,modal:!0,resizable:!1,destroyOnClose:!0});
return e}};Finder.prototype.commands.view=function(){this.value=this.fm.viewType;this.alwaysEnabled=!0;this.updateOnSelect=!1;this.options={ui:"viewbutton"};this.getstate=function(){return 0};this.exec=function(){var a=this.fm.storage("view","list"==this.value?"icons":"list");this.fm.viewchange();this.update(void 0,a)}};