ave-cms/lib/redactor/elfinder/js/elfinder.min.js

20 lines
352 KiB
JavaScript
Raw Normal View History

2017-06-24 00:58:56 +03:00
/*!
* elFinder - file manager for web
* Version 2.1.23 (2017-03-31)
* http://elfinder.org
*
* Copyright 2009-2017, Studio 42
* Licensed under a 3-clauses BSD license
*/
!function(e,t){if("function"==typeof define&&define.amd)define(["jquery","jquery-ui"],t);else if("undefined"!=typeof exports){var n,i;try{n=require("jquery"),i=require("jquery-ui")}catch(a){}module.exports=t(n,i)}else t(e.jQuery,e.jQuery.ui,!0)}(this,function(e,t,n){n=n||!1;var i=function(t,n){var a,r,o,s=this,t=e(t),l=e("<div/>").append(t.contents()),d=t.attr("style"),c=t.attr("id")||"",u="elfinder-"+(c?c:Math.random().toString().substr(2,7)),h="mousedown."+u,p="keydown."+u,f="keypress."+u,m=!0,g=!0,v=["enable","disable","load","open","reload","select","add","remove","change","dblclick","getfile","lockfiles","unlockfiles","selectfiles","unselectfiles","dragstart","dragstop","search","searchend","viewchange"],b="",y={path:"",url:"",tmbUrl:"",disabled:[],separator:"/",archives:[],extract:[],copyOverwrite:!0,uploadOverwrite:!0,uploadMaxSize:0,jpgQuality:100,tmbCrop:!1,tmb:!1},w={},x=[],k={},C={},T=[],z=[],A=[],I=[],S=new s.command(s),M="auto",U=400,O="./sounds/",D=e(document.createElement("audio")).hide().appendTo("body")[0],E=0,F="",P=null,R=function(n){var i,a,r,o,l,d,c,u,h={},p={};s.api>=2.1?(s.commandMap=n.options.uiCmdMap&&Object.keys(n.options.uiCmdMap).length?n.options.uiCmdMap:{},F!==JSON.stringify(s.commandMap)&&(F=JSON.stringify(s.commandMap),Object.keys(s.commandMap).length&&(a=s.getUI("contextmenu"),a.data("cmdMaps")||a.data("cmdMaps",{}),i=n.cwd?n.cwd.volumeid:null,i&&!a.data("cmdMaps")[i]&&(a.data("cmdMaps")[i]=s.commandMap)))):s.options.sync=0,n.init?w={}:(u=b,r="elfinder-subtree-loaded "+s.res("class","navexpand"),c=s.res("class","navcollapse"),o=Object.keys(w),l=function(t){if(!w[t])return!0;var n="directory"===w[t].mime,i=w[t].phash;(!n||h[i]||!p[i]&&e("#"+s.navHash2Id(w[t].hash)).is(":hidden")&&e("#"+s.navHash2Id(i)).next(".elfinder-navbar-subtree").children().length>100)&&(n||i!==b)&&-1===e.inArray(t,z)?(n&&!h[i]&&(h[i]=!0,e("#"+s.navHash2Id(i)).removeClass(r).next(".elfinder-navbar-subtree").empty()),delete w[t]):n&&(p[i]=!0)},d=function(){o.length&&(P&&P._abort(),P=s.asyncJob(l,o,{interval:20,numPerOnce:100}))},s.trigger("filesgc").one("filesgc",function(){o=[]}),s.one("opendone",function(){u!==b&&(t.data("lazycnt")?s.one("lazydone",d):d())})),s.sorters=[],b=n.cwd.hash,H(n.files),w[b]||H([n.cwd]),s.lastDir(b),s.autoSync()},H=function(t){var n,i,a={name:!0,perm:!0,date:!0,size:!0,kind:!0},r=0===s.sorters.length,o=t.length;for(i=0;o>i;i++)n=t[i],n.name&&n.hash&&n.mime&&(r&&n.phash===b&&(e.each(s.sortRules,function(e){(a[e]||"undefined"!=typeof n[e]||"mode"===e&&"undefined"!=typeof n.perm)&&s.sorters.push(e)}),r=!1),n.isroot&&n.phash&&(s.leafRoots[n.phash]?-1===e.inArray(n.hash,s.leafRoots[n.phash])&&s.leafRoots[n.phash].push(n.hash):s.leafRoots[n.phash]=[n.hash],w[n.phash]&&(w[n.phash].dirs||(w[n.phash].dirs=1),n.ts&&(w[n.phash].ts||0)<n.ts&&(w[n.phash].ts=n.ts))),w[n.hash]=n)},j=function(n){var i,a=n.keyCode,r=!(!n.ctrlKey&&!n.metaKey);m&&(e.each(C,function(e,t){t.type==n.type&&t.keyCode==a&&t.shiftKey==n.shiftKey&&t.ctrlKey==r&&t.altKey==n.altKey&&(n.preventDefault(),n.stopPropagation(),t.callback(n,s),s.debug("shortcut-exec",e+" : "+t.description))}),a!=e.ui.keyCode.TAB||e(n.target).is(":input")||n.preventDefault(),"keydown"===n.type&&a==e.ui.keyCode.ESCAPE&&(t.find(".ui-widget:visible").length||s.clipboard().length&&s.clipboard([]),e.ui.ddmanager&&(i=e.ui.ddmanager.current,i&&i.helper&&i.cancel()),t.find(".ui-widget.elfinder-button-menu").hide(),s.trigger("keydownEsc",n)))},N=new Date,q=window.parent!==window,_=function(){var t,n;if(q)try{n=e("iframe",window.parent.document),n.length&&e.each(n,function(n,i){return i.contentWindow===window?(t=e(i),!1):void 0})}catch(i){}return t}();return this.api=null,this.newAPI=!1,this.oldAPI=!1,this.netDrivers=[],this.options=e.extend(!0,{},this._options,n||{}),this.options.cssAutoLoad&&!function(n){var i,a,r,o,s,l=e('head > script[src$="js/elfinder.min.js"],script[src$="js/elfinder.full.js"]:first');l.length?(r=e("<style>.elfinder{visibility:hidden;overflow:hidden}</style>"),e("head").append(r),a=l.attr("src").replace(/js\/[^\/]+$/,""),a.match(/^(https?\/\/|\/)
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(t){return e.ajax(t)}),"iframe"==this.transport.upload?this.transport.upload=e.proxy(this.uploads.iframe,this):"function"==typeof this.transport.upload?this.dragUpload=!!this.options.dragUploadAllow:this.xhrUpload&&this.options.dragUploadAllow?(this.transport.upload=e.proxy(this.uploads.xhr,this),this.dragUpload=!0):this.transport.upload=e.proxy(this.uploads.iframe,this),this.decodeRawString=e.isFunction(this.options.rawStringDecoder)?this.options.rawStringDecoder:function(e){var t=function(e){var t,n,i;for(t=0,n=e.length,i=[];n>t;t++)i.push(e.charCodeAt(t));return i},n=function(e){var n,i,a,r=[];for("string"==typeof e&&(e=t(e)),n=0,i=e.length;a=e[n],i>n;n++)a>=55296&&56319>=a?r.push((1023&a)+64<<10|1023&e[++n]):r.push(a);return r},i=function(e){var t,n,i,a,r=String.fromCharCode;for(t=0,n=e.length,a="";i=e[t],n>t;t++)a+=127>=i?r(i):223>=i&&i>=194?r((31&i)<<6|63&e[++t]):239>=i&&i>=224?r((15&i)<<12|(63&e[++t])<<6|63&e[++t]):247>=i&&i>=240?r(55296|((7&i)<<8|(63&e[++t])<<2|e[++t]>>>4&3)-64,56320|(15&e[t++])<<6|63&e[t]):r(65533);return a};return i(n(e))},this.error=function(){var e=arguments[0],t=arguments[1]||null;return 1==arguments.length&&"function"==typeof e?s.bind("error",e):e===!0?this:s.trigger("error",{error:e,opts:t})},e.each(v,function(t,n){s[n]=function(){var t=arguments[0];return 1==arguments.length&&"function"==typeof t?s.bind(n,t):s.trigger(n,e.isPlainObject(t)?t:{})}}),this.enable(function(){!m&&s.visible()&&s.ui.overlay.is(":hidden")&&!t.children(".elfinder-dialog").find("."+s.res("class","editing")).length&&(m=!0,document.activeElement&&document.activeElement.blur(),t.removeClass("elfinder-disabled"))}).disable(function(){g=m,m=!1,t.addClass("elfinder-disabled")}).open(function(){x=[]}).select(function(t){var n=0,i=[];x=e.map(t.data.selected||t.data.value||[],function(e){return i.length||s.maxTargets&&++n>s.maxTargets?(i.push(e),null):w[e]?e:null}),i.length&&(s.trigger("unselectfiles",{files:i,inselect:!0}),s.toast({mode:"warning",msg:s.i18n(["errMaxTargets",s.maxTargets])}))}).error(function(t){var n={cssClass:"elfinder-dialog-error",title:s.i18n(s.i18n("error")),resizable:!1,destroyOnClose:!0,buttons:{}};n.buttons[s.i18n(s.i18n("btnClose"))]=function(){e(this).elfinderdialog("close")},t.data.opts&&e.isPlainObject(t.data.opts)&&e.extend(n,t.data.opts),s.dialog('<span class="elfinder-dialog-icon elfinder-dialog-icon-error"/>'+s.i18n(t.data.error),n)}).bind("tree parents",function(e){H(e.data.tree||[])}).bind("tmb",function(t){e.each(t.data.images||[],function(e,t){w[e]&&(w[e].tmb=t)})}).add(function(e){H(e.data.added||[])}).change(function(t){e.each(t.data.changed||[],function(t,n){var i=n.hash;w[i]&&e.each(["locked","hidden","width","height"],function(e,t){w[i][t]&&!n[t]&&delete w[i][t]}),w[i]=w[i]?e.extend(w[i],n):n})}).remove(function(t){var n=t.data.removed||[],i=n.length,a={},r=function(t){var n=w[t];n&&("directory"===n.mime&&(a[t]&&delete s.roots[a[t]],e.each(w,function(e,n){n.phash==t&&r(e)})),delete w[t])};for(e.each(s.roots,function(e,t){a[t]=e});i--;)r(n[i])}).bind("searchstart",function(t){e.extend(s.searchStatus,t.data),s.searchStatus.state=1}).bind("search",function(e){s.searchStatus.state=2,H(e.data.files||[])}).bind("searchend",function(){s.searchStatus.state=0,s.searchStatus.mixed=!1}),!0===this.options.sound&&this.bind("rm",function(t){var n=D.canPlayType&&D.canPlayType('audio/wav; codecs="1"');n&&""!=n&&"no"!=n&&e(D).html('<source src="'+O+'rm.wav" type="audio/wav">')[0].play()}),e.each(this.options.handlers,function(e,t){s.bind(e,t)}),this.history=new this.history(this),this.commands.getfile&&("function"==typeof this.options.getFileCallback?(this.bind("dblclick",function(e){e.preventDefault(),s.exec("getfile").fail(function(){s.exec("open")})}),this.shortcut({pattern:"enter",description:this.i18n("cmdgetfile"),callback:function(){s.exec("getfile").fail(functi
b.append("mimes["+e+"]",t)}),e.each(a,function(e,t){t._chunkmerged?(b.append("chunk",t._chunkmerged),b.append("upload[]",t._name),b.append("mtime[]",t._mtime)):(t._chunkfail?(b.append("upload[]","chunkfail"),b.append("mimes","chunkfail")):b.append("upload[]",t),t._chunk?(b.append("chunk",t._chunk),b.append("cid",t._cid),b.append("range",t._range),b.append("mtime[]",t._mtime)):b.append("mtime[]",t.lastModified?Math.round(t.lastModified/1e3):0)),n.UA.iOS&&b.append("overwrite",0)}),d&&e.each(s,function(e,t){b.append("upload_path[]",t)}),u&&b.append("dropWith",parseInt((u.altKey?"1":"0")+(u.ctrlKey?"1":"0")+(u.metaKey?"1":"0")+(u.shiftKey?"1":"0"),2)),r.send(b),!0};if(d)l?R(y[0],y[1]):y.done(function(t){if(E=[],w=t[0].length){if(t[4]&&t[4].length)return void n.request({data:{cmd:"mkdir",target:c,dirs:t[4]},notify:{type:"mkdir",cnt:t[4].length}}).fail(function(e){e=e||["errUnknown"],"errCmdParams"===e[0]?p=1:(p=0,v.reject(e))}).done(function(n){n.hashes&&(t[1]=e.map(t[1],function(e){return e=e.replace(/\/[^\/]*$/,""),""===e?c:n.hashes[e]}))}).always(function(e){p&&(E=t[2],F=t[3],R(t[0],t[1]))});t[1]=e.map(t[1],function(){return c}),E=t[2],F=t[3],R(t[0],t[1])}else v.reject(["errUploadNoFiles"])}).fail(function(){v.reject()});else if(y.length>0)if(null==E){var H=[],j=[],N=n.options.folderUploadExclude[n.OS]||null;e.each(y,function(t,n){var i=n.webkitRelativePath||n.relativePath||"";return i?(N&&n.name.match(N)?(n._remove=!0,i=void 0):(i=i.replace(/\/[^\/]*$/,""),i&&-1===e.inArray(i,H)&&H.push(i)),void j.push(i)):!1}),n.getUI().find("div.elfinder-upload-dialog-wrapper").elfinderdialog("close"),E=[],F={},H.length?!function(){var t=e.map(H,function(e){return-1===e.indexOf("/")?{name:e}:null}),i=[];n.uploads.checkExists(t,c,n).done(function(a,r){var o,s,l,u=[];n.options.overwriteUploadConfirm&&!n.UA.iOS&&n.option("uploadOverwrite",c)&&(i=e.map(t,function(e){return e._remove?e.name:null}),t=e.map(t,function(e){return e._remove?null:e})),i.length&&e.each(j.concat(),function(t,n){0===e.inArray(n,i)&&(y[t]._remove=!0,delete j[t])}),y=e.map(y,function(e){return e._remove?null:e}),j=e.map(j,function(e){return void 0===e?null:e}),t.length?(o=e.Deferred(),a.length?e.each(a,function(t,i){s=n.uniqueName(i+n.options.backupSuffix,null,""),e.each(r,function(e,t){return a[0]==t?(l=e,!1):void 0}),l||(l=n.fileByName(a[0],c).hash),n.lockfiles({files:[l]}),u.push(n.request({data:{cmd:"rename",target:l,name:s},notify:{type:"rename",cnt:1}}).fail(function(e){v.reject(e),n.sync()}).always(function(){n.unlockfiles({files:[l]})}))}):u.push(null),e.when.apply(e,u).done(function(){n.request({data:{cmd:"mkdir",target:c,dirs:H},notify:{type:"mkdir",cnt:H.length}}).fail(function(e){e=e||["errUnknown"],"errCmdParams"===e[0]?p=1:(p=0,v.reject(e))}).done(function(t){t.hashes&&(j=e.map(j.concat(),function(e){return""===e?c:t.hashes["/"+e]}))}).always(function(e){p&&(d=!0,R(y,j)||v.reject())})})):v.reject()})}():n.uploads.checkExists(y,c,n).done(function(t,i){n.options.overwriteUploadConfirm&&!n.UA.iOS&&n.option("uploadOverwrite",c)&&(E=t,F=i,y=e.map(y,function(e){return e._remove?null:e})),w=y.length,w>0?R(y)||v.reject():v.reject()})}else R(y)||v.reject();else v.reject();return v},iframe:function(t,n){var i,a,r,o,s=n?n:this,l=t.input?t.input:!1,d=l?!1:s.uploads.checkFile(t,s),c=e.Deferred().fail(function(e){e&&s.error(e)}),u="iframe-"+n.namespace+ ++s.iframeCnt,h=e('<form action="'+s.uploadURL+'" method="post" enctype="multipart/form-data" encoding="multipart/form-data" target="'+u+'" style="display:none"><input type="hidden" name="cmd" value="upload" /></form>'),p=this.UA.IE,f=function(){o&&clearTimeout(o),r&&clearTimeout(r),a&&s.notify({type:"upload",cnt:-i}),setTimeout(function(){p&&e('<iframe src="javascript:false;"/>').appendTo(h),h.remove(),m.remove()},100)},m=e('<iframe src="'+(p?"javascript:false;":"about:blank")+'" name="'+u+'" style="position:absolute;left:-1000px;top:-1000px" />').on("load",function(){m.off("load").on("load",function(){f(),c.resolve()}),r=setTimeout(function(){a=!0,s.notify({type:"upload",cnt:i})},s.options.notifyDelay),s.options.ifra
sound:!0,ui:["toolbar","tree","path","stat"],uiOptions:{toolbar:[["back","forward"],["netmount"],["mkdir","mkfile","upload"],["open","download","getfile"],["info","chmod"],["quicklook"],["copy","cut","paste"],["rm"],["duplicate","rename","edit","resize"],["extract","archive"],["search"],["view","sort"],["help"],["fullscreen"],{displayTextLabel:!1,labelExcludeUA:["Mobile"],autoHideUA:["Mobile"]}],tree:{openRootOnLoad:!0,openCwdOnOpen:!0,syncTree:!0,subdirsMaxConn:3,subdirsAtOnce:5},navbar:{minWidth:150,maxWidth:500,autoHideUA:[]},cwd:{oldSchool:!1,showSelectCheckboxUA:["Touch"],listView:{columns:["perm","date","size","kind"],columnsCustomName:{},fixedHeader:!0}}},onlyMimes:[],sortRules:{},sortType:"name",sortOrder:"asc",sortStickFolders:!0,sortAlsoTreeview:!1,clientFormatDate:!0,UTCDate:!1,dateFormat:"",fancyDateFormat:"",fileModeStyle:"both",width:"auto",height:400,resizable:!0,notifyDelay:500,notifyDialog:{position:{top:"12px",right:"12px"},width:280},allowShortcuts:!0,rememberLastDir:!0,reloadClearHistory:!1,useBrowserHistory:!0,showFiles:50,showThreshold:50,validName:!1,backupSuffix:"~",sync:0,syncStart:!0,loadTmbs:5,cookie:{expires:30,domain:"",path:"/",secure:!1},contextmenu:{navbar:["open","download","|","upload","mkdir","|","copy","cut","paste","duplicate","|","rm","|","rename","|","archive","|","places","info","chmod","netunmount"],cwd:["reload","back","|","upload","mkdir","mkfile","paste","|","view","sort","colwidth","|","info","|","fullscreen"],files:["getfile","|","open","download","opendir","quicklook","|","upload","mkdir","|","copy","cut","paste","duplicate","|","rm","|","edit","rename","resize","|","archive","extract","|","places","info","chmod","netunmount"]},enableAlways:!1,enableByMouseOver:!0,windowCloseConfirm:["hasNotifyDialog","editingFile"],rawStringDecoder:"object"==typeof Encoding&&e.isFunction(Encoding.convert)?function(e){return Encoding.convert(e,{to:"UNICODE",type:"string"})}:null,debug:["error","warning","event-destroy"]},i.prototype._options.commandsOptions.netmount={ftp:{name:"FTP",inputs:{host:e('<input type="text"/>'),port:e('<input type="text" placeholder="21"/>'),path:e('<input type="text" value="/"/>'),user:e('<input type="text"/>'),pass:e('<input type="password" autocomplete="new-password"/>'),encoding:e('<input type="text" placeholder="Optional"/>'),locale:e('<input type="text" placeholder="Optional"/>')}},dropbox:{name:"Dropbox.com",inputs:{host:e('<span><span class="elfinder-info-spinner"/></span></span><input type="hidden"/>'),path:e('<input type="text" value="/"/>'),user:e('<input type="hidden"/>'),pass:e('<input type="hidden"/>')},select:function(e){var t=this;t.inputs.host.find("span").length&&e.request({data:{cmd:"netmount",protocol:"dropbox",host:"dropbox.com",user:"init",pass:"init",options:{url:e.uploadURL,id:e.id}},preventDefault:!0}).done(function(n){t.inputs.host.find("span").removeClass("elfinder-info-spinner"),t.inputs.host.find("span").html(n.body.replace(/\{msg:([^}]+)\}/g,function(t,n){return e.i18n(n,"Dropbox.com")}))}).fail(function(){})},done:function(t,n){var i=this;"makebtn"==n.mode?(i.inputs.host.find("span").removeClass("elfinder-info-spinner"),i.inputs.host.find("input").hover(function(){e(this).toggleClass("ui-state-hover")}),i.inputs.host[1].value=""):(i.inputs.host.find("span").removeClass("elfinder-info-spinner"),i.inputs.host.find("span").html("Dropbox.com"),i.inputs.host[1].value="dropbox",i.inputs.user.val("done"),i.inputs.pass.val("done"))}},dropbox2:i.prototype.makeNetmountOptionOauth("dropbox2","Dropbox","Dropbox",{noOffline:!0,root:"/",pathI18n:"path"}),googledrive:i.prototype.makeNetmountOptionOauth("googledrive","Google Drive","Google"),onedrive:i.prototype.makeNetmountOptionOauth("onedrive","One Drive","OneDrive"),box:i.prototype.makeNetmountOptionOauth("box","Box","Box",{noOffline:!0})},i.prototype.history=function(t){var n,i=this,a=!0,r=[],o=function(){r=[t.cwd().hash],n=0,a=!0},s=t.options.useBrowserHistory&&window.history&&window.history.pushState?window.history:null,l=function(s){return s&&i.canForward()||!s&&i.canBack()?(a=!1,t.exec("ope
e.stopPropagation(),e.preventDefault(),a()})},b=function(){var n="touchstart.contextmenuAutoToggle";p.data("hideTm")&&clearTimeout(p.data("hideTm")),p.is(":visible")&&p.on("touchstart",function(e){e.originalEvent.touches.length>1||(p.stop().show(),p.data("hideTm")&&clearTimeout(p.data("hideTm")))}).data("hideTm",setTimeout(function(){i.find(".elfinder-cwd-file").off(n),i.find(".elfinder-cwd-file.ui-selected").one(n,function(t){if(!(t.originalEvent.touches.length>1)){var a=e(t.target);return!p.first().length||a.is("input:checkbox")||a.hasClass("elfinder-cwd-select")?void i.find(".elfinder-cwd-file").off(n):(w(t.originalEvent.touches[0].pageX,t.originalEvent.touches[0].pageY),!1)}}).one("unselect."+t.namespace,function(){i.find(".elfinder-cwd-file").off(n)}),p.fadeOut({duration:300,fail:function(){p.css("opacity","1").show()}})},4500))},y=function(n){var i=n.keyCode,l=e.ui.keyCode.ESCAPE,d=e.ui.keyCode.ENTER,u=e.ui.keyCode.LEFT,h=e.ui.keyCode.RIGHT,p=e.ui.keyCode.UP,f=e.ui.keyCode.DOWN,m="ltr"===t.direction?h:u,g=m===h?u:h;-1!==e.inArray(i,[l,d,u,h,p,f])&&(n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation(),i==l||i===g?r&&o&&s?(s.trigger("mouseleave"),r.addClass("ui-state-hover"),o=null,s=null):i==l&&x():i==p||i==f?o?(s&&s.trigger("mouseleave"),i==f&&(!s||o.length<=++o._cur)?o._cur=0:i==p&&(!s||--o._cur<0)&&(o._cur=o.length-1),s=o.eq(o._cur).trigger("mouseenter")):(o=null,r&&r.trigger("mouseleave"),i==f&&(!r||a.length<=++a._cur)?a._cur=0:i==p&&(!r||--a._cur<0)&&(a._cur=a.length-1),r=a.eq(a._cur).addClass("ui-state-hover")):!r||i!=d&&i!==m||(r.hasClass("elfinder-contextmenu-group")?s?i==d&&s.click():(r.trigger("mouseenter"),o=r.find("div."+c),o._cur=0,s=o.first().addClass("ui-state-hover")):i==d&&r.click()))},w=function(i,a,d){var c,u=p.outerWidth(),h=p.outerHeight(),m=n.attr("style"),g=n.offset(),v=n.width(),w=n.height(),x=t.UA.Mobile?40:2,k=t.UA.Mobile?20:2,i=i-(g?g.left:0),a=a-(g?g.top:0),d=e.extend(d||{},{top:Math.max(0,w>a+k+h?a+k:a-(a+h-w)),left:Math.max(0,u+x>i||v>i+x+u?i+x:i-x-u),opacity:"1"});l=!0,t.autoSync("stop"),t.toFront(p),n.width(v),p.stop().removeAttr("style").css(d).show(),n.attr("style",m),d[f]=parseInt(p.width()),p.find(".elfinder-contextmenu-sub").css(d),t.UA.iOS&&e("div.elfinder div.overflow-scrolling-touch").css("-webkit-overflow-scrolling","auto"),r=null,o=null,s=null,e(document).on("keydown."+t.namespace,y),c=e._data(document).events,c&&c.keydown&&c.keydown.unshift(c.keydown.pop()),t.UA.Mobile&&b()},x=function(){if(e(document).off("keydown."+t.namespace,y),T=null,p.is(":visible")||p.children().length){p.removeAttr("style").hide().empty().removeData("submenuKeep");try{p.draggable("instance")||p.draggable(h)}catch(n){p.hasClass("ui-draggable")||p.draggable(h)}p.data("prevNode")&&(p.data("prevNode").after(p),p.removeData("prevNode")),t.trigger("closecontextmenu"),t.UA.iOS&&e("div.elfinder div.overflow-scrolling-touch").css("-webkit-overflow-scrolling","touch")}l&&t.searchStatus.state<1&&!t.searchStatus.ininc&&t.autoSync(),l=!1},k=function(i,r){var o=!1,s=!1,l={},u=[],h="cwd"===i,g=0;T=i,p.data("cmdMaps")&&e.each(p.data("cmdMaps"),function(e,t){return 0==r[0].indexOf(e,0)?(l=t,!1):void 0}),h||(u=t.getDisabledCmds(r)),"navbar"===i&&t.select({selected:r,origin:"navbar"}),g=t.selected().length,g>1&&p.append('<div class="ui-corner-top ui-widget-header elfinder-contextmenu-header"><span>'+t.i18n("selectedItems",""+g)+"</span></div>"),a=e(),e.each(m[i]||[],function(a,m){var g,b,y,w,k,C;if("|"===m)return void(o&&(s=!0));if(l[m]?(b=l[m],y=!0):b=m,g=t.getCommand(b),!g||h||t.searchStatus.state&&g.disableOnSearch||(g.__disabled=g._disabled,g._disabled=!(g.alwaysEnabled||(t._commands[b]?-1===e.inArray(m,u)&&(!y||-1===e.inArray(b,u)):!1)),e.each(g.linkedCmds,function(n,i){var a;(a=t.getCommand(i))&&(a.__disabled=a._disabled,a._disabled=!(a.alwaysEnabled||(t._commands[i]?-1===e.inArray(i,u):!1)))})),g&&!g._disabled&&-1!=g.getstate(r)){if(g.variants){if(!g.variants.length)return;w=v(g.title,g.className?g.className:g.name,function(){}),k=e('<div class="ui-front ui-corner-all elfinder-contextmenu-sub"/>
i.setData("elfinderfrom:"+i.getData("elfinderfrom"),"")}}).on("dragend",function(e){B(),s&&s.remove()}).draggable(t.draggable)}}}).on(o,h,function(n){var i=e(this),a=t.cwdId2Hash(i.attr("id"));N||i.hasClass(f)||($="#"+this.id,i.addClass(p).children().addClass(v).find("input:checkbox").prop("checked",!0),-1===e.inArray(a,_)&&_.push(a),j=we.find("[id]."+p+":last").next())}).on(s,h,function(n){var i,a=e(this),r=t.cwdId2Hash(a.attr("id"));N||(a.removeClass(p).children().removeClass(v).find("input:checkbox").prop("checked",!1),we.hasClass("elfinder-cwd-allselected")&&(M&&Ce.children("input").prop("checked",!1),we.removeClass("elfinder-cwd-allselected")),i=e.inArray(r,_),-1!==i&&($=void 0,_.splice(i,1)))}).on(l,h,function(){var t=e(this).removeClass(v+" "+p).addClass(f),n=t.children(),i=r?t:n.find("div.elfinder-cwd-file-wrapper,div.elfinder-cwd-filename");n.removeClass(v+" "+p),t.hasClass(g)&&t.droppable("disable"),i.hasClass(m)&&i.draggable("disable")}).on(d,h,function(){var t=e(this).removeClass(f),n=r?t:t.children("div.elfinder-cwd-file-wrapper,div.elfinder-cwd-filename");t.hasClass(g)&&t.droppable("enable"),n.hasClass(m)&&n.draggable("enable")}).on("scrolltoview",h,function(){G(e(this),!0)}).on("mouseenter."+t.namespace+" mouseleave."+t.namespace,h,function(n){var i="mouseenter"===n.type;i&&Q||(t.trigger("hover",{hash:t.cwdId2Hash(e(this).attr("id")),type:n.type}),e(this).toggleClass(v,"mouseenter"==n.type))}).on("contextmenu."+t.namespace,function(n){var i=e(n.target).closest("."+u);i.length&&("TD"!=n.target.nodeName||e.inArray(t.cwdId2Hash(i.get(0).id),t.selected())>-1)&&(n.stopPropagation(),n.preventDefault(),i.hasClass(f)||xe.data("touching")||(i.hasClass(p)||(B(),i.trigger(o),V()),t.trigger("contextmenu",{type:"files",targets:t.selected(),x:n.pageX,y:n.pageY})))}).on("click."+t.namespace,function(e){e.target!==this||we.data("longtap")||!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&B()}).on("create."+t.namespace,function(n,i){var a=r?we.find("tbody"):we,o=a.find(".elfinder-cwd-parent"),s=i.move||!1,i=e(H(i)).addClass(y),l=t.selected();l.length?s&&t.trigger("lockfiles",{files:l}):B(),o.length?o.after(i):a.prepend(i),le(),xe.scrollTop(0).scrollLeft(0)}).on("unselectall",B).on("selectfile",function(n,i){e("#"+t.cwdHash2Id(i)).trigger(o),V()}).on("colwidth",function(){r&&(we.find("table").css("table-layout","").find("td").css("width",""),se({fitWidth:!0}),t.storage("cwdColWidth",O=null))}),xe=e('<div class="elfinder-cwd-wrapper"/>').droppable(e.extend({},de,{autoDisable:!1})).on("contextmenu."+t.namespace,be.contextmenu).on("touchstart."+t.namespace,be.touchstart).on("touchmove."+t.namespace+" touchend."+t.namespace,be.touchend).on("click."+t.namespace,be.click).on("scroll."+t.namespace,function(){Q||(we.data("selectable")&&we.selectable("disable"),xe.trigger(X)),Q=!0,J.scrtm&&clearTimeout(J.scrtm),J.scrtm&&Math.abs((J.scrolltop||0)-(J.scrolltop=this.scrollTop||e(this).scrollTop()))<5&&(J.scrtm=0,xe.trigger(Z)),J.scrtm=setTimeout(function(){J.scrtm=0,xe.trigger(Z)},20)}).on(Z,function(){Q=!1,ne()}),ke=e("<div>&nbsp;</div>").css({position:"absolute",width:"1px",height:"1px"}).hide(),Ce=M?e('<div class="elfinder-cwd-selectall"><input type="checkbox"/></div>').attr("title",t.i18n("selectall")).on("touchstart mousedown click",function(t){return t.stopPropagation(),t.preventDefault(),e(this).data("pending")||"click"===t.type?!1:(Ce.data("pending",!0),void(we.hasClass("elfinder-cwd-allselected")?(Ce.find("input").prop("checked",!1),setTimeout(function(){B()},10)):W()))}):e(),Te=null,ze=function(t){var n=function(){var t=0;xe.siblings("div.elfinder-panel:visible").each(function(){t+=e(this).outerHeight(!0)}),xe.height(Ie.height()-t-xe._padding)};t&&n(),Te&&clearTimeout(Te),Te=setTimeout(function(){!t&&n();var e,i;we.css("height","auto"),e=xe[0].clientHeight-parseInt(xe.css("padding-top"))-parseInt(xe.css("padding-bottom"))-parseInt(we.css("margin-top")),i=we.outerHeight(!0),e>i&&we.height(e)},20),r&&!U&&se(),ne()},Ae=e(this).parent().resize(ze),Ie=Ae.children(".elfinder-workzone").append(xe.append(this).append(ke));R=e.extend(R,n.replace
t.trigger("unlockfiles",{files:r.data("files"),helper:r})):e(this).removeClass(c))},out:function(n,i){var a=i.helper,r=n.shiftKey||n.ctrlKey||n.metaKey;n.stopPropagation(),a.toggleClass("elfinder-drag-helper-move elfinder-drag-helper-plus",a.data("locked")?!0:r).data("dropover",Math.max(a.data("dropover")-1,0)),e(this).removeData("dropover").removeClass(c),t.trigger(r?"unlockfiles":"lockfiles",{files:a.data("files"),helper:a})},drop:function(n,a){var r=a.helper,o=!0;e.each(r.data("files"),function(e,n){var a=t.file(n);a&&"directory"==a.mime&&!i[a.hash]?w(a):o=!1}),b(),o&&r.hide()}}).on("touchstart","."+r+":not(."+d+")",function(n){if(!(n.originalEvent.touches.length>1))var i=e(this).attr("id").substr(6),a=e(this).addClass(l).data("longtap",null).data("tmlongtap",setTimeout(function(){a.data("longtap",!0),t.trigger("contextmenu",{raw:[{label:t.i18n("rmFromPlaces"),icon:"rm",callback:function(){x(i),b()}}],x:n.originalEvent.touches[0].pageX,y:n.originalEvent.touches[0].pageY})},500))}).on("touchmove touchend","."+r+":not(."+d+")",function(t){clearTimeout(e(this).data("tmlongtap")),"touchmove"==t.type&&e(this).removeClass(l)});e.fn.sortable&&S.addClass("touch-punch").sortable({appendTo:t.getUI(),revert:!1,helper:function(n){var i=e(n.target).parent();return i.children().removeClass("ui-state-hover"),e('<div class="ui-widget elfinder-place-drag elfinder-'+t.direction+'"/>').append(e('<div class="elfinder-navbar"/>').show().append(i.clone()))},stop:function(t,n){var i=e(n.item[0]),a=M.offset().top,r=M.offset().left,o=M.width(),s=M.height(),l=t.pageX,d=t.pageY;l>r&&r+o>l&&d>a&&d+s>d||(x(g(i.children(":first").attr("id"))),b())},update:function(e,t){b()}}),e(this).on("regist",function(t,n){var a=!1;e.each(n,function(e,t){t&&"directory"==t.mime&&!i[t.hash]&&w(t)&&(a=!0)}),a&&b()}),t.one("load",function(){var n,a;t.oldAPI||(M.show().parent().show(),i={},n=t.storage(f),"string"==typeof n?(n=e.map(n.split(","),function(e){return e||null}),e.each(n,function(e,t){var n=t.split("#");i[n[0]]=n[1]?n[1]:n[0]})):e.isPlainObject(n)&&(i=n),t.trigger("placesload",{dirs:i,storageKey:f},!0),a=Object.keys(i),a.length&&(I.prepend(p),t.request({data:{cmd:"info",targets:a},preventDefault:!0}).done(function(n){var a={};e.each(n.files,function(e,t){var n=t.hash;a[n]=t}),e.each(i,function(t,n){w(a[t]||e.extend({notfound:!0},n))}),t.storage("placesState")>0&&I.click()}).always(function(){p.remove()})),t.change(function(t){var n=!1;e.each(t.data.changed,function(e,t){i[t.hash]&&("directory"!==t.mime?x(t.hash)&&(n=!0):C(t)&&(n=!0))}),n&&b()}).bind("rename",function(t){var n=!1;t.data.removed&&e.each(t.data.removed,function(e,i){t.data.added[e]&&C(t.data.added[e],i)&&(n=!0)}),n&&b()}).bind("rm paste",function(t){var n=[],i=!1;t.data.removed&&e.each(t.data.removed,function(e,t){var i=x(t);i&&n.push(i)}),n.length&&(i=!0),t.data.added&&n.length&&e.each(t.data.added,function(t,i){1!==e.inArray(i.name,n)&&"directory"==i.mime&&w(i)}),i&&b()}).bind("sync netmount",function(n){var a=Object.keys(i);a.length&&(I.prepend(p),t.request({data:{cmd:"info",targets:a},preventDefault:!0}).done(function(a){var r={},o=!1,s=t.cwd().hash;e.each(a.files||[],function(e,n){var i=n.hash;r[i]=n,t.files().hasOwnProperty(n.hash)||t.trigger("tree",{tree:[n]})}),e.each(i,function(t,i){!i.notfound!=!!r[t]?i.phash===s&&"netmount"!==n.type||r[t]&&"directory"!==r[t].mime?x(t)&&(o=!0):C(r[t]||e.extend({notfound:!0},i))&&(o=!0):r[t]&&r[t].phash!=s&&C(r[t])}),o&&b()}).always(function(){p.remove()}))}))})})},e.fn.elfindersearchbutton=function(t){return this.each(function(){var n,i,a=!1,r=t.fm,o=t.options.incsearch||{enable:!1},s=function(e){return r.namespace+e},l=r.getUI("toolbar"),d=r.res("class","searchbtn"),c=e(this).hide().addClass("ui-widget-content elfinder-button "+d),u=function(){f.data("inctm")&&clearTimeout(f.data("inctm")),n&&n.slideUp();var i=e.trim(f.val()),o=!e("#"+s("SearchFromAll")).prop("checked"),l=e("#"+s("SearchMime")).prop("checked");o&&(o=e("#"+s("SearchFromVol")).prop("checked")?r.root(r.cwd().hash):r.cwd().hash),l&&(l=i,i="."),i?t.exec(i,o,l).done(function(){a=!0,f.f
t.className=e?"view-list":"",t.title=t.fm.i18n(e?"viewlist":"viewicons"),n.attr("title",t.title)})})},e.fn.elfinderworkzone=function(t){var n="elfinder-workzone";return this.not("."+n).each(function(){var i=e(this).addClass(n),a=i.outerHeight(!0)-i.height(),r=Math.round(i.height()),o=i.parent(),s=function(){var s=o.height()-a,l=o.attr("style"),d=Math.round(i.height());o.css("overflow","hidden").children(":visible:not(."+n+")").each(function(){var t=e(this);"absolute"!=t.css("position")&&"fixed"!=t.css("position")&&(s-=t.outerHeight(!0))}),o.attr("style",l||""),s=Math.max(0,Math.round(s)),r===s&&d===s||(r=Math.round(i.height()),i.height(s),t.trigger("wzresize"))};o.add(window).on("resize."+t.namespace,s),t.one("cssloaded",function(){a=i.outerHeight(!0)-i.height(),s()}).bind("uiresize",s)}),this},i.prototype.commands.archive=function(){var t,n=this,i=n.fm,a=[];this.variants=[],this.disableOnSearch=!1,i.bind("open reload",function(){n.variants=[],e.each(a=i.option("archivers").create||[],function(e,t){n.variants.push([t,i.mime2kind(t)])}),n.change()}),this.getstate=function(n){var r,n=this.files(n),o=n.length,s=o&&!i.isRoot(n[0])&&(i.file(n[0].phash)||{}).write&&!e.map(n,function(e){return e.read?null:!0}).length;return s&&i.searchStatus.state>1&&(r=i.cwd().volumeid,s=o===e.map(n,function(e){return e.read&&0===e.hash.indexOf(r)?e:null}).length),s&&!this._disabled&&a.length&&(o||t&&"pending"==t.state())?0:-1},this.exec=function(r,o){var s,l,d=this.files(r),c=d.length,u=o||a[0],h=i.file(d[0].phash)||null,p=["errArchive","errPerm","errCreatingTempDir","errFtpDownloadFile","errFtpUploadFile","errFtpMkdir","errArchiveExec","errExtractExec","errRm"];if(t=e.Deferred().fail(function(e){e&&i.error(e)}),!c||!a.length||-1===e.inArray(u,a))return t.reject();if(!h.write)return t.reject(p);for(s=0;c>s;s++)if(!d[s].read)return t.reject(p);return n.mime=u,n.prefix=(c>1?"Archive":d[0].name)+(i.option("archivers").createext?"."+i.option("archivers").createext[u]:""),n.data={targets:n.hashes(r),type:u},i.cwd().hash!==h.hash?l=i.exec("open",h.hash).done(function(){i.one("cwdrender",function(){i.selectfiles({files:r}),t=e.proxy(i.res("mixin","make"),n)()})}):(i.selectfiles({files:r}),t=e.proxy(i.res("mixin","make"),n)()),t}},(i.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()}}).prototype={forceLoad:!0},i.prototype.commands.chmod=function(){this.updateOnSelect=!1;var t=this.fm,n={0:"owner",1:"group",2:"other"},i={read:t.i18n("read"),write:t.i18n("write"),execute:t.i18n("execute"),perm:t.i18n("perm"),kind:t.i18n("kind"),files:t.i18n("files")},a=function(e){return!isNaN(parseInt(e,8)&&parseInt(e,8)<=511)||e.match(/^([r-][w-][x-]){3}$/i)};this.tpl={main:'<div class="ui-helper-clearfix elfinder-info-title"><span class="elfinder-cwd-icon {class} ui-corner-all"/>{title}</div>{dataTable}',itemTitle:'<strong>{name}</strong><span id="elfinder-info-kind">{kind}</span>',groupTitle:"<strong>{items}: {num}</strong>",dataTable:'<table id="{id}-table-perm"><tr><td>{0}</td><td>{1}</td><td>{2}</td></tr></table><div class="">'+i.perm+': <input id="{id}-perm" type="text" size="4" maxlength="3" value="{value}"></div>',fieldset:'<fieldset id="{id}-fieldset-{level}"><legend>{f_title}{name}</legend><input type="checkbox" value="4" id="{id}-read-{level}-perm"{checked-r}> <label for="{id}-read-{level}-perm">'+i.read+'</label><br><input type="checkbox" value="6" id="{id}-write-{level}-perm"{checked-w}> <label for="{id}-write-{level}-perm">'+i.write+'</label><br><input type="checkbox" value="5" id="{id}-execute-{level}-perm"{checked-x}> <label for="{id}-execute-{level}-perm">'+i.execute+"</label><br>"},this.shortcuts=[{}],this.getstate=function(e){var t=this.fm;return e=e||t.selected(),0==e.length&&(e=[t.cwd().hash]),this.checkstate(this.files(e))?0:-1},this.checkstate=function(t){var n=t.length;if(!n)return!1;var i=e.map(t,function(e){return e.isowner&&e.perm&&a(e.perm)&&(1==n|
}),a.state=0}),this.getstate=function(){return 0},this.exec=function(){this.dialog.elfinderdialog("open").find(".ui-tabs-nav li a:first").click()}}).prototype={forceLoad:!0},(i.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 e=this.fm.root(),t=this.fm.cwd().hash;return e&&t&&e!=t?0:-1},this.exec=function(){return this.fm.exec("open",this.fm.root())}}).prototype={forceLoad:!0},(i.prototype.commands.info=function(){var t=this.fm,n="elfinder-info-spinner",i="elfinder-info-button",a={calc:t.i18n("calc"),size:t.i18n("size"),unknown:t.i18n("unknown"),path:t.i18n("path"),aliasfor:t.i18n("aliasfor"),modify:t.i18n("modify"),perms:t.i18n("perms"),locked:t.i18n("locked"),dim:t.i18n("dim"),kind:t.i18n("kind"),files:t.i18n("files"),folders:t.i18n("folders"),roots:t.i18n("volumeRoots"),items:t.i18n("items"),yes:t.i18n("yes"),no:t.i18n("no"),link:t.i18n("link"),owner:t.i18n("owner"),group:t.i18n("group"),perm:t.i18n("perm"),getlink:t.i18n("getLink")};this.tpl={main:'<div class="ui-helper-clearfix elfinder-info-title {dirclass}"><span class="elfinder-cwd-icon {class} ui-corner-all"{style}/>{title}</div><table class="elfinder-info-tb">{content}</table>',itemTitle:'<strong>{name}</strong><span class="elfinder-info-kind">{kind}</span>',groupTitle:"<strong>{items}: {num}</strong>",row:"<tr><td>{label} : </td><td>{value}</td></tr>",spinner:'<span>{text}</span> <span class="'+n+" "+n+'-{name}"/>'},this.alwaysEnabled=!0,this.updateOnSelect=!1,this.shortcuts=[{pattern:"ctrl+i"}],this.init=function(){e.each(a,function(e,n){a[e]=t.i18n(n)})},this.getstate=function(){return 0},this.exec=function(t){var r=this.files(t);r.length||(r=this.files([this.fm.cwd().hash]));var o,s,l,d,c,u,h,p=this.fm,f=this.options,m=this.tpl,g=m.row,v=r.length,b=[],y=m.main,w="{label}",x="{value}",k=[],C={title:this.title,width:"auto",close:function(){e(this).elfinderdialog("destroy"),e.each(k,function(e,t){var n=t&&t.xhr?t.xhr:null;n&&"pending"==n.state()&&(n.quiet=!0,n.abort())})}},T=[],z=function(e,t){I.find("."+n+"-"+t).parent().html(e)},A=p.namespace+"-info-"+e.map(r,function(e){return e.hash}).join("-"),I=p.getUI().find("#"+A),S=[],M=function(t){var n=function(t){var n=[];return"directory"===t.mime&&e.each(p.leafRoots,function(e,i){var a;if(e===t.hash)n.push.apply(n,i);else for(a=(p.file(e)||{}).phash;a;)a===t.hash&&n.push.apply(n,i),a=(p.file(a)||{}).phash}),n},i=function(t){var n=e.Deferred(),i=p.file(t),a=i?i.phash:t;return a&&!p.file(a)?p.request({data:{cmd:"parents",target:a},preventFail:!0}).done(function(){p.one("parentsdone",function(){n.resolve()})}).fail(function(){n.resolve()}):n.resolve(),n},r=function(){var t=e.Deferred(),n=Object.keys(p.leafRoots).length;return n>0?e.each(p.leafRoots,function(e){i(e).done(function(){--n,1>n&&t.resolve()})}):t.resolve(),t};p.autoSync("stop"),r().done(function(){var i=[],r={},o=[];e.each(t,function(){i.push.apply(i,n(p.file(this)))}),t.push.apply(t,i),e.each(t,function(){var e=p.root(this);r[e]?r[e].push(this):r[e]=[this]}),e.each(r,function(){o.push(p.request({data:{cmd:"size",targets:this},preventDefault:!0}))}),k.push.apply(k,o),e.when.apply(e,o).fail(function(){z(a.unknown,"size")}).done(function(){var e,t=0,n=arguments.length;for(e=0;n>e;e++)t+=parseInt(arguments[e].size);z(t>=0?p.formatSize(t):a.unknown,"size")}),p.autoSync()})},U="";if(!v)return e.Deferred().reject();if(I.length)return I.elfinderdialog("toTop"),e.Deferred().resolve();if(1==v){if(l=r[0],l.icon&&(U=" "+p.getIconStyle(l)),y=y.replace("{dirclass}",l.csscls?p.escape(l.csscls):"").replace("{class}",p.mime2class(l.mime)).replace("{style}",U),d=m.itemTitle.replace("{name}",p.escape(l.i18||l.name)).replace("{kind}",'<span title="'+p.escape(l.mime)+'">'+p.mime2kind(l)+"</span>"),s=p.tmb(l),l.read?"directory"!=l.mime||l.alias?o=p.formatSize(l.size):(o=m.spinner.replace("{text}",a.calc).replace("{name}","size"),T.push(l.hash)):o=a.unknown,b.push(g.replace(w,a.size).replace(x,o)),l.alias&&b.push(g.replace(w,a.a
var o,s=r.file;t.dispInlineRegex.test(s.mime)&&s.mime==i&&(r.stopImmediatePropagation(),t.hideinfo(),o=e('<embed class="elfinder-quicklook-preview-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" src="'+n.url(s.hash)+'" quality="high" type="application/x-shockwave-flash" wmode="transparent" />').appendTo(a))})},function(t){var n,i=t.preview,a=!!t.options.autoplay,r={"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"},o=t.window,s=t.navbar;i.on("update",function(l){var d=l.file,c=r[d.mime],u=function(){s.css("bottom",o.hasClass("elfinder-quicklook-fullscreen")?"50px":"")};t.support.audio[c]&&(l.stopImmediatePropagation(),n=e('<audio class="elfinder-quicklook-preview-audio" controls preload="auto" autobuffer><source src="'+t.fm.openUrl(d.hash)+'" /></audio>').appendTo(i),a&&n[0].play(),o.on("viewchange.audio",u),u())}).on("change",function(){if(n&&n.parent().length){var e=n[0];o.off("viewchange.audio");try{e.pause(),e.src="",e.load()}catch(t){}n.remove(),n=null}})},function(t){var n,i=t.preview,a=!!t.options.autoplay,r={"video/mp4":"mp4","video/x-m4v":"mp4","video/quicktime":"mp4","video/ogg":"ogg","application/ogg":"ogg","video/webm":"webm"},o=t.window,s=t.navbar;i.on("update",function(l){var d=l.file,c=r[d.mime],u=function(){t.fm.UA.iOS?o.hasClass("elfinder-quicklook-fullscreen")?(i.css("height","-webkit-calc(100% - 50px)"),s._show()):i.css("height",""):s.css("bottom",o.hasClass("elfinder-quicklook-fullscreen")?"50px":"")};t.support.video[c]&&(l.stopImmediatePropagation(),t.hideinfo(),n=e('<video class="elfinder-quicklook-preview-video" controls preload="auto" autobuffer><source src="'+t.fm.openUrl(d.hash)+'" /></video>').appendTo(i),a&&n[0].play(),o.on("viewchange.video",u),u())}).on("change",function(){if(n&&n.parent().length){var e=n[0];o.off("viewchange.video");try{e.pause(),e.src="",e.load()}catch(t){}n.remove(),n=null}})},function(t){var n,i=t.preview,a=[],r=t.window,o=t.navbar;e.each(navigator.plugins,function(t,n){e.each(n,function(e,t){(0===t.type.indexOf("audio/")||0===t.type.indexOf("video/"))&&a.push(t.type)})}),i.on("update",function(s){var l,d=s.file,c=d.mime,u=function(){o.css("bottom",r.hasClass("elfinder-quicklook-fullscreen")?"50px":"")};-1!==e.inArray(d.mime,a)&&(s.stopImmediatePropagation(),(l=0===c.indexOf("video/"))&&t.hideinfo(),n=e('<embed src="'+t.fm.openUrl(d.hash)+'" type="'+c+'" class="elfinder-quicklook-preview-'+(l?"video":"audio")+'"/>').appendTo(i),r.on("viewchange.embed",u),u())}).on("change",function(){n&&n.parent().length&&(r.off("viewchange.embed"),n.remove(),n=null)})},function(t){var n=["application/zip","application/x-gzip","application/x-tar"],a=t.preview,r=t.fm;"undefined"!=typeof Uint8Array&&i.Zlib&&a.on("update",function(o){var s,l,d,c=o.file;-1!==e.inArray(c.mime,n)&&(o.stopImmediatePropagation(),d=e('<div class="elfinder-quicklook-info-data"> '+r.i18n("nowLoading")+'<span class="elfinder-info-spinner"></div>').appendTo(t.info.find(".elfinder-quicklook-info")),a.one("change",function(){d.remove(),l&&l.readyState<4&&l.abort()}),l=new XMLHttpRequest,l.onload=function(n){var o,u,h,p,f,m,g,v,b,y,w,x=[];4===this.readyState&&this.response?setTimeout(function(){try{if("application/zip"===c.mime)u=new i.Zlib.Unzip(new Uint8Array(l.response)),x=u.getFilenames();else for("application/x-gzip"===c.mime?(u=new i.Zlib.Gunzip(new Uint8Array(l.response)),h=u.decompress()):h=new Uint8Array(l.response),p=h.length,f=0,w=function(e){return String.fromCharCode.apply(null,e).replace(/\0+$/,"")};p>f&&0!==h[f];)m=h.subarray(f,f+512),g=w(m.subarray(0,100)),(v=w(m.subarray(345,500)))&&(g=v+g),b=parseInt(w(m.subarray(124,136)),8),y=512*Math.ceil(b/512),"././@LongLink"===g&&(g=w(h.subarray(f+512,f+512+y))),"pax_global_header"!==g&&x.push(g),f=f+512+y}catch(n){d.remove(),r.debug("error",n)}x&&x.length&&(x=e.map(x,function(e){return r.decodeRawString(e)}),x.sort(),d.remove(),o="<strong>"+r.escape(c.mime)+"</strong
(4294967295&l.length)!==o&&e(Error("invalid input size: "+(4294967295&l.length)+" / "+o)),this.m.push(a),this.c=b}this.s=!0;var y,w,x,k=this.m,C=0,T=0;for(y=0,w=k.length;w>y;++y)T+=k[y].data.length;if(h)for(x=new Uint8Array(T),y=0;w>y;++y)x.set(k[y].data,C),C+=k[y].data.length;else{for(x=[],y=0;w>y;++y)x[y]=k[y].data;x=Array.prototype.concat.apply([],x)}return x},t("Zlib.Gunzip",d),t("Zlib.Gunzip.prototype.decompress",d.prototype.g),t("Zlib.Gunzip.prototype.getMembers",d.prototype.G)}.call(this)}).bind(i)()}catch(a){}return(i.prototype.commands.reload=function(){var t=this,n=!1;this.alwaysEnabled=!0,this.updateOnSelect=!0,this.shortcuts=[{pattern:"ctrl+shift+r f5"}],this.getstate=function(){return 0},this.init=function(){this.fm.bind("search searchend",function(e){n="search"==e.type})},this.fm.bind("contextmenu",function(n){var i=t.fm;i.options.sync>=1e3&&(t.extra={icon:"accept",node:e("<span/>").attr({title:i.i18n("autoSync")}).on("click touchstart",function(t){"touchstart"===t.type&&t.originalEvent.touches.length>1||(t.stopPropagation(),t.preventDefault(),e(this).parent().toggleClass("ui-state-disabled",i.options.syncStart).parent().removeClass("ui-state-hover"),i.options.syncStart=!i.options.syncStart,i.autoSync(i.options.syncStart?null:"stop"))}).ready(function(){e(this).parent().toggleClass("ui-state-disabled",!i.options.syncStart).css("pointer-events","auto")})})}),this.exec=function(){var t=this.fm;if(!n){var i=t.sync(),a=setTimeout(function(){t.notify({type:"reload",cnt:1,hideCnt:!0}),i.always(function(){t.notify({type:"reload",cnt:-1})})},t.notifyDelay);return i.always(function(){clearTimeout(a),t.trigger("reload")})}e("div.elfinder-toolbar > div."+t.res("class","searchbtn")+" > span.ui-icon-search").click()}}).prototype={forceLoad:!0},i.prototype.commands.rename=function(){this.shortcuts=[{pattern:"f2"+("mac"==this.fm.OS?" enter":"")}],this.getstate=function(e){var e=this.files(e);return 1==e.length&&e[0].phash&&!e[0].locked?0:-1},this.exec=function(t,n){var i,a=this.fm,r=a.getUI("cwd"),o=t||(a.selected().length?a.selected():!1)||[a.cwd().hash],s=o.length,l=a.file(o.shift()),d=".elfinder-cwd-filename",n=n||{},c=a.cwd().hash==l.hash,u=n._currentType?n._currentType:c?"navbar":"files",h="navbar"===u,p=e("#"+a[h?"navHash2Id":"cwdHash2Id"](l.hash)),f="files"===u&&"list"!=a.storage("view"),m=function(){setTimeout(function(){y&&y.blur()},50)},g=function(){C.is(":hidden")||C.addClass("ui-front").elfinderoverlay("hide").off("click",T),k.removeClass("ui-front").css("position","").off("unselect."+a.namespace,m),f?x.css("max-height",""):h||k.css("width","").parent("td").css("overflow","")},v=e.Deferred().done(function(e){c&&a.exec("open",e.added[0].hash)}).fail(function(e){var t=y.parent(),n=a.escape(l.i18||l.name);f&&(n=n.replace(/([_.])/g,"&#8203;$1")),h?y.replaceWith(n):t.length?(y.remove(),t.html(n)):(p.find(d).html(n),setTimeout(function(){r.find("#"+a.cwdHash2Id(l.hash)).click()},50)),e&&a.error(e)}).always(function(){g(),a.unbind("resize",z),a.enable()}),b=function(){var t=e.trim(y.val()),n=(y.parent(),!0);if(!A&&k.length){if(y.off("blur"),y[0].setSelectionRange&&y[0].setSelectionRange(0,0),t==l.name)return v.reject();if(a.options.validName&&a.options.validName.test)try{n=a.options.validName.test(t)}catch(i){n=!1}if(!t||".."===t||!n)return A=!0,a.error("errInvName",{modal:!0,close:w}),!1;if(a.fileByName(t,l.phash))return A=!0,a.error(["errExists",t],{modal:!0,close:w}),!1;g(),(h?y:x).html(a.escape(t)),a.lockfiles({files:[l.hash]}),a.request({data:{cmd:"rename",target:l.hash,name:t},notify:{type:"rename",cnt:1}}).fail(function(e){v.reject(),e&&Array.isArray(e)&&"errRename"===e[0]||a.sync()}).done(function(e){if(v.resolve(e),!h&&e&&e.added&&e.added[0]){var t=a.findCwdNodes(e.added);t.length&&t.trigger("scrolltoview")}}).always(function(){a.unlockfiles({files:[l.hash]})})}},y=e(f?"<textarea/>":'<input type="text"/>').on("keyup text",function(){f?(this.style.height="1px",this.style.height=this.scrollHeight+"px"):i&&(this.style.width=i+"px",this.scrollWidth>i&&(this.style.width=this.scrollWidth+10+"px"))}).on("keydown",
e(o).on("click",function(i){e(this).data("dragging")||(i.stopPropagation(),n.getUI("cwd").data("longtap")||t.exec([],d))}).hover(function(){e(this).addClass("ui-state-hover")},function(){e(this).removeClass("ui-state-hover")})}})}),this.getstate=function(){return 0},this.exec=function(t,n){var i=this.fm,a=e.extend({type:i.sortType,order:i.sortOrder,stick:i.sortStickFolders,tree:i.sortAlsoTreeview},n);return i.lazy(function(){i.setSort(a.type,a.order,a.stick,a.tree),this.resolve()})}},(i.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(){var t=this.fm,n=t.cwd().hash;return this.fm.cwd().phash?this.fm.exec("open",this.fm.cwd().phash).done(function(){t.one("opendone",function(){t.selectfiles({files:[n]})})}):e.Deferred().reject()}}).prototype={forceLoad:!0},i.prototype.commands.upload=function(){var t=this.fm.res("class","hover");this.disableOnSearch=!0,this.updateOnSelect=!1,this.shortcuts=[{pattern:"ctrl+u"}],this.getstate=function(e){var t,n=this.fm,e=e||[n.cwd().hash];return this._disabled||1!=e.length||(t=n.file(e[0])),t&&"directory"==t.mime&&t.write?0:-1},this.exec=function(n){var i,a,r,o,s,l,d,c=this.fm,u=c.cwd().hash,h=function(){var e,t=n&&n instanceof Array?n:null;return n||(t=t||1!==(e=c.selected()).length||"directory"!==c.file(e[0]).mime?[u]:e),t},p=h(),f=p?p[0]:n&&n.target?n.target:null,m=f?c.file(f):c.cwd(),g=function(t){c.upload(t).fail(function(e){w.reject(e)}).done(function(t){var n;c.getUI("cwd");if(w.resolve(t),t&&t.added&&t.added[0]&&!c.ui.notify.children(".elfinder-notify-upload").length){var i=c.findCwdNodes(t.added);i.length?i.trigger("scrolltoview"):(m.hash!==u?n=e("<div/>").append(e('<button type="button" class="ui-button ui-widget ui-state-default ui-corner-all elfinder-tabstop"><span class="ui-button-text">'+c.i18n("cmdopendir")+"</span></button>").on("mouseenter mouseleave",function(t){e(this).toggleClass("ui-state-hover","mouseenter"==t.type)}).on("click",function(){c.exec("open",f).done(function(){c.one("opendone",function(){c.trigger("selectfiles",{files:e.map(t.added,function(e){return e.hash})})})})})):c.trigger("selectfiles",{files:e.map(t.added,function(e){return e.hash})}),c.toast({msg:c.i18n(["complete",c.i18n("cmdupload")]),extNode:n}))}})},v=function(e){"files"!==e.type&&i.elfinderdialog("close"),p&&(e.target=p[0]),g(e)},b=function(){var t=m.hash,n=e.map(c.files(),function(e){return"directory"===e.mime&&e.write&&e.phash&&e.phash===t?e:null});return n.length?e('<div class="elfinder-upload-dirselect elfinder-tabstop" title="'+c.i18n("folders")+'"/>').on("click",function(t){t.stopPropagation(),t.preventDefault(),n=c.sortFiles(n);var a=e(this),r=(c.cwd(),i.closest("div.ui-dialog")),o=function(e,t){return{label:c.escape(e.i18||e.name),icon:t,remain:!1,callback:function(){var t=r.children(".ui-dialog-titlebar:first").find("span.elfinder-upload-target");p=[e.hash],t.html(" - "+c.escape(e.i18||e.name)),a.focus()},options:{className:p&&p.length&&e.hash===p[0]?"ui-state-active":"",iconClass:e.csscls||"",iconImg:e.icon||""}}},s=[o(m,"opendir"),"|"];e.each(n,function(e,t){s.push(o(t,"dir"))}),a.blur(),c.trigger("contextmenu",{raw:s,x:t.pageX||e(this).offset().left,y:t.pageY||e(this).offset().top,prevNode:r,fitHeight:!0})}).append('<span class="elfinder-button-icon elfinder-button-icon-dir" />'):e()},y=function(n,i){var a=e('<input type="file" '+n+"/>").change(function(){v({input:a.get(0),type:"files"})}).on("dragover",function(e){e.originalEvent.dataTransfer.dropEffect="copy"});return e('<div class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only elfinder-tabstop elfinder-focus"><span class="ui-button-text">'+c.i18n(i)+"</span></div>").append(e("<form/>").append(a)).on("click",function(e){e.target===this&&(e.stopPropagation(),e.preventDefault(),a.click())}).hover(function(){e(this).toggleClass(t)})},w=e.Deferred();return o=function(t){t.stopPropagation(),t.preventDefault();var n,i=!1,a="",r=null,o="",s=null,l=t._target||null,d=t.data