/*! * elFinder - file manager for web * Version 2.1.25 (2017-06-23) * 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,l=this,d=["button"],t=e(t),c=e("
").append(t.contents()).attr("class",t.attr("class")||"").attr("style",t.attr("style")||""),u=t.attr("id")||"",h="elfinder-"+(u?u:Math.random().toString().substr(2,7)),p="mousedown."+h,f="keydown."+h,m="keypress."+h,g=!0,v=!0,b=["enable","disable","load","open","reload","select","add","remove","change","dblclick","getfile","lockfiles","unlockfiles","selectfiles","unselectfiles","dragstart","dragstop","search","searchend","viewchange"],y="",w={path:"",url:"",tmbUrl:"",disabled:[],separator:"/",archives:[],extract:[],copyOverwrite:!0,uploadOverwrite:!0,uploadMaxSize:0,jpgQuality:100,tmbCrop:!1,tmb:!1},k={},x={},C={},T=[],A={},z={},I=[],O={},S=[],U=[],M=new l.command(l),D="auto",E=400,F=null,P="./sounds/",j=e(document.createElement("audio")).hide().appendTo("body")[0],R=0,H="",N=null,q=function(n){var i,a,r,o,s,d,c={},u={};l.api>=2.1?n.options.uiCmdMap&&(l.commandMap=n.options.uiCmdMap&&Object.keys(n.options.uiCmdMap).length?n.options.uiCmdMap:{},H!==JSON.stringify(l.commandMap)&&(H=JSON.stringify(l.commandMap))):l.options.sync=0,n.init?(x={},C={}):(d=y,i="elfinder-subtree-loaded "+l.res("class","navexpand"),s=l.res("class","navcollapse"),a=Object.keys(x),r=function(t){if(!x[t])return!0;var n="directory"===x[t].mime,a=x[t].phash;!(!n||c[a]||!u[a]&&e("#"+l.navHash2Id(x[t].hash)).is(":hidden")&&e("#"+l.navHash2Id(a)).next(".elfinder-navbar-subtree").children().length>100)||!n&&a===y||O[t]?n&&(u[a]=!0):(n&&!c[a]&&(c[a]=!0,e("#"+l.navHash2Id(a)).removeClass(i).next(".elfinder-navbar-subtree").empty()),$(x[t]))},o=function(){a.length&&(N&&N._abort(),N=l.asyncJob(r,a,{interval:20,numPerOnce:100}))},l.trigger("filesgc").one("filesgc",function(){a=[]}),l.one("opendone",function(){d!==y&&(t.data("lazycnt")?l.one("lazydone",o):o())})),l.sorters=[],y=n.cwd.hash,_(n.files),x[y]||_([n.cwd]),l.lastDir(y),l.autoSync()},_=function(t){var n,i,a={name:!0,perm:!0,date:!0,size:!0,kind:!0},r=0===l.sorters.length,o=t.length,s=function(t){var t=t||{};l.sorters=[],e.each(l.sortRules,function(e){(a[e]||"undefined"!=typeof t[e]||"mode"===e&&"undefined"!=typeof t.perm)&&l.sorters.push(e)})};for(i=0;o>i;i++)n=Object.assign({},t[i]),n.name&&n.hash&&n.mime&&(r&&n.phash===y&&(s(n),r=!1),n.isroot&&n.phash&&(l.leafRoots[n.phash]?-1===e.inArray(n.hash,l.leafRoots[n.phash])&&l.leafRoots[n.phash].push(n.hash):l.leafRoots[n.phash]=[n.hash],x[n.phash]&&(x[n.phash].dirs||(x[n.phash].dirs=1),n.ts&&(x[n.phash].ts||0) script[src$="js/elfinder.min.js"],script[src$="js/elfinder.full.js"]:first');l.length?(r=e(""),e("head").append(r),a=l.attr("src").replace(/js\/[^\/]+$/,""),a.match(/^(https?\/\/|\/)/)||(i=e("head > base[href]").attr("href"))&&(a=i.replace(/\/$/,"")+"/"+a),n.loadCss([a+"css/elfinder.min.css",a+"css/theme.css"]),n.baseUrl=a,Array.isArray(n.options.cssAutoLoad)&&n.loadCss(n.options.cssAutoLoad),s=1e3,o=setInterval(function(){--s>0&&"hidden"!==t.css("visibility")&&(clearInterval(o),r.remove(),n.trigger("cssloaded"))},10)):n.options.cssAutoLoad=!1}(this),this.optionProperties={icon:void 0,csscls:void 0,tmbUrl:void 0,uiCmdMap:{},netkey:void 0,disabled:[]},n.ui&&(this.options.ui=n.ui),n.commands&&(this.options.commands=n.commands),n.uiOptions&&(n.uiOptions.toolbar&&Array.isArray(n.uiOptions.toolbar)&&(e.isPlainObject(n.uiOptions.toolbar[n.uiOptions.toolbar.length-1])&&Object.assign(this.options.uiOptions.toolbarExtra,n.uiOptions.toolbar.pop()),this.options.uiOptions.toolbar=n.uiOptions.toolbar),n.uiOptions.toolbarExtra&&e.isPlainObject(n.uiOptions.toolbarExtra)&&Object.assign(this.options.uiOptions.toolbarExtra,n.uiOptions.toolbarExtra),n.uiOptions.cwd&&n.uiOptions.cwd.listView&&(n.uiOptions.cwd.listView.columns&&(this.options.uiOptions.cwd.listView.columns=n.uiOptions.cwd.listView.columns),n.uiOptions.cwd.listView.columnsCustomName&&(this.options.uiOptions.cwd.listView.columnsCustomName=n.uiOptions.cwd.listView.columnsCustomName))),this.options.uiOptions.toolbar.push(this.options.uiOptions.toolbarExtra),delete this.options.uiOptions.toolbarExtra,n.contextmenu&&Object.assign(this.options.contextmenu,n.contextmenu),Y||this.options.enableAlways||2!==e("body").children().length||(this.options.enableAlways=!0),""===this.baseUrl&&(this.baseUrl=this.options.baseUrl?this.options.baseUrl:""),this.options.debug===!0?this.options.debug="all":Array.isArray(this.options.debug)?!function(){var t={};e.each(l.options.debug,function(){t[this]=!0}),l.options.debug=t}():this.options.debug=!1,this.noConflicts={},this.noConflict=function(){e.each(d,function(t,n){e.fn[n]&&"function"==typeof e.fn[n].noConflict&&(l.noConflicts[n]=e.fn[n].noConflict())})},this.noConflict(),this.isCORS=!1,function(){var t,i=document.createElement("a");i.href=n.url,n.urlUpload&&n.urlUpload!==n.url&&(t=document.createElement("a"),t.href=n.urlUpload),(window.location.host!==i.host||t&&window.location.host!==t.host)&&(l.isCORS=!0,e.isPlainObject(l.options.customHeaders)||(l.options.customHeaders={}),e.isPlainObject(l.options.xhrFields)||(l.options.xhrFields={}),l.options.requestType="post",l.options.customHeaders["X-Requested-With"]="XMLHttpRequest",l.options.xhrFields.withCredentials=!0)}(),this.requestType=/^(get|post)$/i.test(this.options.requestType)?this.options.requestType.toLowerCase():"get",r=Math.max(parseInt(this.options.requestMaxConn),1),this.customData=e.isPlainObject(this.options.customData)?this.options.customData:{},this.customHeaders=e.isPlainObject(this.options.customHeaders)?this.options.customHeaders:{},this.xhrFields=e.isPlainObject(this.options.xhrFields)?this.options.xhrFields:{},this.abortCmdsOnOpen=this.options.abortCmdsOnOpen||["tmb","parents"],this.id=u,this.navPrefix="nav"+(i.prototype.uniqueid?i.prototype.uniqueid:"")+"-",this.cwdPrefix=i.prototype.uniqueid?"cwd"+i.prototype.uniqueid+"-":"",++i.prototype.uniqueid,this.uploadURL=n.urlUpload||n.url,this.namespace=h,this.lang=this.i18[this.options.lang]&&this.i18[this.options.lang].messages?this.options.lang:"en",s="en"==this.lang?this.i18.en:e.extend(!0,{},this.i18.en,this.i18[this.lang]),this.direction=s.direction,this.messages=s.messages,this.dateFormat=this.options.dateFormat||s.dateFormat,this.fancyFormat=this.options.fancyDateFormat||s.fancyDateFormat,this.nonameDateFormat=(this.options.nonameDateFormat||s.nonameDateFormat).replace(/[\/\\]/g,"_"),this.today=new Date(J.getFullYear(),J.getMonth(),J.getDate()).getTime()/1e3,this.yesterday=this.today-86400,o=this.options.UTCDate?"UTC":"",this.getHours="get"+o+"Hours",this.getMinutes="get"+o+"Minutes",this.getSeconds="get"+o+"Seconds",this.getDate="get"+o+"Date",this.getDay="get"+o+"Day",this.getMonth="get"+o+"Month",this.getFullYear="get"+o+"FullYear",this.cssClass="ui-helper-reset ui-helper-clearfix ui-widget ui-widget-content ui-corner-all elfinder elfinder-"+("rtl"==this.direction?"rtl":"ltr")+(this.UA.Touch?" elfinder-touch"+(this.options.resizable?" touch-punch":""):"")+(this.UA.Mobile?" elfinder-mobile":"")+" "+this.options.cssClass,this.zIndex,this.searchStatus={state:0,query:"",target:"",mime:"",mixed:!1,ininc:!1},this.storage=function(){try{return"localStorage"in window&&null!==window.localStorage?(l.UA.Safari&&(window.localStorage.setItem("elfstoragecheck",1),window.localStorage.removeItem("elfstoragecheck")),l.localStorage):l.cookie}catch(e){return l.cookie}}(),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"),null===this.sortStickFolders?this.sortStickFolders=!!this.options.sortStickFolders:this.sortStickFolders=!!this.sortStickFolders,this.sortAlsoTreeview=this.storage("sortAlsoTreeview"),null===this.sortAlsoTreeview?this.sortAlsoTreeview=!!this.options.sortAlsoTreeview:this.sortAlsoTreeview=!!this.sortAlsoTreeview,this.sortRules=e.extend(!0,{},this._sortRules,this.options.sortRules),e.each(this.sortRules,function(e,t){"function"!=typeof t&&delete l.sortRules[e]}),this.compare=e.proxy(this.compare,this),this.notifyDelay=this.options.notifyDelay>0?parseInt(this.options.notifyDelay):500,this.draggingUiHelper=null,function(){var n,i,a,r,o=f+"draggable keyup."+h+"draggable";l.draggable={appendTo:t,addClasses:!1,distance:4,revert:!0,refreshPositions:!1,cursor:"crosshair",cursorAt:{left:50,top:47},scroll:!1,start:function(o,s){var d,c,u=s.helper,h=e.map(u.data("files")||[],function(e){return e?(O[e]=!0,e):null}),p=!1;for(r=t.attr("style"),t.width(t.width()).height(t.height()),n="ltr"===l.direction,i=l.getUI("workzone").data("rectangle"),a=i.top+i.height,l.draggingUiHelper=u,d=h.length;d--;)if(c=h[d],x[c].locked){p=!0,u.data("locked",!0);break}!p&&l.trigger("lockfiles",{files:h}),u.data("autoScrTm",setInterval(function(){u.data("autoScr")&&l.autoScroll[u.data("autoScr")](u.data("autoScrVal"))},50))},drag:function(t,r){var o,s=r.helper;(o=i.top>t.pageY)||at.pageX?s.data("autoScr",(n?"navbar":"cwd")+(o?"Up":"Down")):s.data("autoScr",(n?"cwd":"navbar")+(o?"Up":"Down")),s.data("autoScrVal",Math.pow(o?i.top-t.pageY:t.pageY-a,1.3))):s.data("autoScr")&&s.data("refreshPositions",1).data("autoScr",null),s.data("refreshPositions")&&e(this).elfUiWidgetInstance("draggable")&&(s.data("refreshPositions")>0?(e(this).draggable("option",{refreshPositions:!0,elfRefresh:!0}),s.data("refreshPositions",-1)):(e(this).draggable("option",{refreshPositions:!1,elfRefresh:!1}),s.data("refreshPositions",null)))},stop:function(n,i){var a,s=i.helper;e(document).off(o),e(this).elfUiWidgetInstance("draggable")&&e(this).draggable("option",{refreshPositions:!1}),l.draggingUiHelper=null,l.trigger("focus").trigger("dragstop"),s.data("droped")||(a=e.map(s.data("files")||[],function(e){return e||null}),l.trigger("unlockfiles",{files:a}),l.trigger("selectfiles",{files:a})),l.enable(),t.attr("style",r),s.data("autoScrTm")&&clearInterval(s.data("autoScrTm"))},helper:function(t,n){var i,a,r,s=this.id?e(this):e(this).parents("[id]:first"),d=e('
'),c=function(t){var n,i=t.mime,a=l.tmb(t);return n='
',a&&(n=e(n).addClass(a.className).css("background-image","url('"+a.url+"')").get(0).outerHTML),n};return l.draggingUiHelper&&l.draggingUiHelper.stop(!0,!0),l.trigger("dragstart",{target:s[0],originalEvent:t}),i=s.hasClass(l.res("class","cwdfile"))?l.selected():[l.navId2Hash(s.attr("id"))],d.append(c(x[i[0]])).data("files",i).data("locked",!1).data("droped",!1).data("namespace",h).data("dropover",0),(a=i.length)>1&&d.append(c(x[i[a-1]])+''+a+""),e(document).on(o,function(e){var t=e.shiftKey||e.ctrlKey||e.metaKey;r!==t&&(r=t,d.is(":visible")&&d.data("dropover")&&!d.data("droped")&&(d.toggleClass("elfinder-drag-helper-plus",d.data("locked")?!0:r),l.trigger(r?"unlockfiles":"lockfiles",{files:i,helper:d})))}),d}}}(),this.droppable={greedy:!0,tolerance:"pointer",accept:".elfinder-cwd-file-wrapper,.elfinder-navbar-dir,.elfinder-cwd-file,.elfinder-cwd-filename",hoverClass:this.res("class","adroppable"),classes:{"ui-droppable-hover":this.res("class","adroppable")},autoDisable:!0,drop:function(t,n){var i,a,r,o=e(this),s=e.map(n.helper.data("files")||[],function(e){return e||null}),d=[],c=[],u=[],p=n.helper.hasClass("elfinder-drag-helper-plus"),f="class";if("undefined"==typeof t.button||n.helper.data("namespace")!==h||!l.insideWorkzone(t.pageX,t.pageY))return!1;for(a=o.hasClass(l.res(f,"cwdfile"))?l.cwdId2Hash(o.attr("id")):o.hasClass(l.res(f,"navdir"))?l.navId2Hash(o.attr("id")):y,i=s.length;i--;)r=s[i],r!=a&&x[r].phash!=a?d.push(r):(p&&r!==a&&x[a].write?c:u).push(r);return u.length?!1:(n.helper.data("droped",!0),c.length&&(n.helper.hide(),l.exec("duplicate",c)),void(d.length&&(n.helper.hide(),l.clipboard(d,!p),l.exec("paste",a,void 0,a).always(function(){l.clipboard([]),l.trigger("unlockfiles",{files:s})}),l.trigger("drop",{files:s}))))}},this.enabled=function(){return g&&this.visible()},this.visible=function(){return t[0].elfinder&&t.is(":visible")},this.isRoot=function(e){return!(!e.isroot&&e.phash)},this.root=function(t,n){t=t||y;var i,a;if(!n&&(e.each(l.roots,function(e,n){return 0===t.indexOf(e)?(i=n,!1):void 0}),i))return i;for(i=x[t];i&&i.phash&&(n||!i.isroot);)i=x[i.phash];if(i)return i.hash;for(;a in x&&x.hasOwnProperty(a);)if(i=x[a],!i.phash&&"directory"==!i.mime&&i.read)return i.hash;return""},this.cwd=function(){return x[y]||{}},this.option=function(t,n){var i;return n=n||y,l.optionsByHashes[n]&&"undefined"!=typeof l.optionsByHashes[n][t]?l.optionsByHashes[n][t]:y!==n?(i="",e.each(l.volOptions,function(e,a){return 0===n.indexOf(e)?(i=a[t]||"",!1):void 0}),i):k[t]||""},this.getDisabledCmds=function(t){var n=["hidden"];return Array.isArray(t)||(t=[t]),e.each(t,function(t,i){var a=l.option("disabled",i);a&&e.each(a,function(t,i){-1===e.inArray(i,n)&&n.push(i)})}),n},this.file=function(e){return e?x[e]:void 0},this.files=function(t){var n={};return t?C[t]?(e.each(C[t],function(e){x[e]?n[e]=x[e]:delete C[t][e]}),Object.assign({},n)):{}:Object.assign({},x)},this.parents=function(e){for(var t,n=[];t=this.file(e);)n.unshift(t.hash),e=t.phash;return n},this.path2array=function(e,t){for(var n,i=[];e;){if(!(n=x[e])||!n.hash){i=[];break}i.unshift(t&&n.i18?n.i18:n.name),e=n.isroot?null:n.phash}return i},this.path=function(t,n,i){var a=x[t]&&x[t].path?x[t].path:this.path2array(t,n).join(k.separator);if(i&&x[t]){i=Object.assign({notify:{type:"parents",cnt:1,hideCnt:!0}},i);var r,o=e.Deferred(),s=i.notify,d=!1,c=function(){l.request({data:{cmd:"parents",target:x[t].phash},notify:s,preventFail:!0}).done(u).fail(function(){o.reject()})},u=function(){l.one("parentsdone",function(){a=l.path(t,n),""===a&&d?(d=!1,c()):(s&&(clearTimeout(r),s.cnt=-parseInt(s.cnt||0),l.notify(s)),o.resolve(a))})};return a?o.resolve(a):(l.ui.tree?(s&&(r=setTimeout(function(){l.notify(s)},l.notifyDelay)),d=!0,u(!0)):c(),o)}return a},this.url=function(t,n){var i,a=x[t],n=n||{},r=n.async||!1,o=n.temporary||!1,s=r?e.Deferred():null,d=function(n){if(n)return n;if(a.url)return a.url;if(i=0===a.hash.indexOf(l.cwd().volumeid)?k.url:l.option("url",a.hash))return i+e.map(l.path2array(t),function(e){return encodeURIComponent(e)}).slice(1).join("/");var r=Object.assign({},l.customData,{cmd:"file",target:a.hash});return l.oldAPI&&(r.cmd="open",r.current=a.phash),l.options.url+(-1===l.options.url.indexOf("?")?"?":"&")+e.param(r,!0)};if(!a||!a.read)return r?s.resolve(""):"";if("1"==a.url)this.request({data:{cmd:"url",target:t,options:{temporary:o?1:0}},preventDefault:!0,options:{async:r},notify:r?{type:o?"file":"url",cnt:1,hideCnt:!0}:{}}).done(function(e){a.url=e.url||""}).fail(function(){a.url=""}).always(function(){var e;return a.url&&o&&(e=a.url,a.url="1"),r?void s.resolve(d(e)):d(e)});else{if(!r)return d();s.resolve(d())}return r?s:void 0},this.openUrl=function(t,n){var i=x[t],a="";if(!i||!i.read)return"";if(!n)if(i.url){if(1!=i.url)return i.url}else if(k.url&&0===i.hash.indexOf(l.cwd().volumeid))return k.url+e.map(this.path2array(t),function(e){return encodeURIComponent(e)}).slice(1).join("/");return a=this.options.url,a=a+(-1===a.indexOf("?")?"?":"&")+(this.oldAPI?"cmd=open¤t="+i.phash:"cmd=file")+"&target="+i.hash,n&&(a+="&download=1"),e.each(this.options.customData,function(e,t){a+="&"+encodeURIComponent(e)+"="+encodeURIComponent(t)}),a},this.tmb=function(t){var n,i,a="elfinder-cwd-bgurl",r="";return e.isPlainObject(t)&&(l.searchStatus.state&&0!==t.hash.indexOf(l.cwd().volumeid)?(n=l.option("tmbUrl",t.hash),i=l.option("tmbCrop",t.hash)):(n=k.tmbUrl,i=k.tmbCrop),i&&(a+=" elfinder-cwd-bgurl-crop"),"self"===n&&0===t.mime.indexOf("image/")?(r=l.openUrl(t.hash),a+=" elfinder-cwd-bgself"):(l.oldAPI||n)&&t&&t.tmb&&1!=t.tmb&&(r=n+t.tmb),r)?{url:r,className:a}:!1},this.selected=function(){return T.slice(0)},this.selectedFiles=function(){return e.map(T,function(e){return x[e]?Object.assign({},x[e]):null})},this.fileByName=function(e,t){var n;for(n in x)if(x.hasOwnProperty(n)&&x[n].phash==t&&x[n].name==e)return x[n]},this.validResponse=function(e,t){return t.error||this.rules[this.rules[e]?e:"defaults"](t)},this.returnBytes=function(e){var t;return isNaN(e)?(e||(e=""),e=e.replace(/b$/i,""),t=e.charAt(e.length-1).toLowerCase(),e=e.replace(/[tgmk]$/i,""),"t"==t?e=1024*e*1024*1024*1024:"g"==t?e=1024*e*1024*1024:"m"==t?e=1024*e*1024:"k"==t&&(e=1024*e),e=isNaN(e)?0:parseInt(e)):(e=parseInt(e),1>e&&(e=0)),e},this.request=function(t){var n,i,a,o=this,s=this.options,l=e.Deferred(),d=Object.assign({},s.customData,{mimes:s.onlyMimes},t.data||t),c=d.cmd,u=!t.asNotOpen&&"open"===c,h=!(t.preventDefault||t.preventFail),p=!(t.preventDefault||t.preventDone),f=Object.assign({},t.notify),m=!!t.cancel,g=!!t.raw,v=t.syncOnFail,b=!!t.lazy,x=t.prepare,C=t.navigate,T=Object.assign({url:s.url,async:!0,type:this.requestType,dataType:"json",cache:!1,data:d,headers:this.customHeaders,xhrFields:this.xhrFields},t.options||{}),A=function(e){e.warning&&o.error(e.warning),u?q(e):o.updateCache(e),e.changed&&e.changed.length&&W(e.changed),o.lazy(function(){e.removed&&e.removed.length&&o.remove(e),e.added&&e.added.length&&o.add(e),e.changed&&e.changed.length&&o.change(e)}).then(function(){return o.lazy(function(){o.trigger(c,e)})}).then(function(){return o.lazy(function(){o.trigger(c+"done")})}).then(function(){e.sync&&o.sync()})},z=function(e,t){var n,i,a=o.options.debug;switch(t){case"abort":n=e.quiet?"":["errConnect","errAbort"];break;case"timeout":n=["errConnect","errTimeout"];break;case"parsererror":n=["errResponse","errDataNotJSON"],e.responseText&&(!y||a&&("all"===a||a["backend-error"]))&&n.push(e.responseText);break;default:if(e.responseText)try{i=JSON.parse(e.responseText),i&&i.error&&(n=i.error)}catch(r){}if(!n)if(403==e.status)n=["errConnect","errAccess","HTTP error "+e.status];else if(404==e.status)n=["errConnect","errNotFound","HTTP error "+e.status];else if(e.status>=500)n=["errResponse","errServerError","HTTP error "+e.status];else{if(414==e.status&&"get"===T.type)return T.type="post",void(l.xhr=e=o.transport.send(T).fail(n).done(I));n=e.quiet?"":["errConnect","HTTP error "+e.status]}}o.trigger(c+"done"),l.reject(n,e,t)},I=function(t){var n=o.options.debug;if(o.currentReqCmd=c,!t.debug||n&&("all"===n||n["backend-error"])||(n||(o.options.debug={}),o.options.debug["backend-error"]=!0),g)return t&&t.debug&&o.debug("backend-debug",t),l.resolve(t);if(!t)return l.reject(["errResponse","errDataEmpty"],i,t);if(!e.isPlainObject(t))return l.reject(["errResponse","errDataNotJSON"],i,t);if(t.error)return l.reject(t.error,i,t);var a=function(){var n,a=function(n){o.leafRoots[d.target]&&t[n]&&e.each(o.leafRoots[d.target],function(e,i){var a;(a=o.file(i))&&t[n].push(a)})};return u?a("files"):"tree"===c&&a("tree"),t=o.normalize(t),o.validResponse(c,t)?(o.api||(o.api=t.api||1,"2.0"==o.api&&"undefined"!=typeof t.options.uploadMaxSize&&(o.api="2.1"),o.newAPI=o.api>=2,o.oldAPI=!o.newAPI),t.options&&(k=Object.assign({},w,t.options)),t.netDrivers&&(o.netDrivers=t.netDrivers),t.maxTargets&&(o.maxTargets=t.maxTargets),u&&d.init&&(o.uplMaxSize=o.returnBytes(t.uplMaxSize),o.uplMaxFile=t.uplMaxFile?parseInt(t.uplMaxFile):20),"function"==typeof x&&x(t),C&&(n=C.target||"added",t[n]&&t[n].length&&o.one(c+"done",function(){var i=t[n],a=o.findCwdNodes(i),r=function(){var t=o.cwd().hash;return e.map(i,function(e){return e.phash&&t===e.phash?e.hash:null})},s=r(),l=function(t){var n,i,a,l=void 0,d=t.action?t.action.data:void 0;return(d||s.length)&&t.action&&(i=t.action.msg)&&(n=t.action.cmd)&&(!t.action.cwdNot||t.action.cwdNot!==o.cwd().hash)&&(a=t.action.done,d=t.action.data,l=e("
").append(e('").on("mouseenter mouseleave",function(t){e(this).toggleClass("ui-state-hover","mouseenter"==t.type)}).on("click",function(){o.exec(n,d||s,{_currentType:"toast",_currentNode:e(this)}),a&&o.one(n+"done",function(){"function"==typeof a?a():"select"===a&&o.trigger("selectfiles",{files:r()})})}))),delete t.action,t.extNode=l,t};C.toast||(C.toast={}),!C.noselect&&o.trigger("selectfiles",{files:o.searchStatus.state>1?e.map(i,function(e){return e.hash}):s}),a.length?(C.noscroll||(a.first().trigger("scrolltoview",{blink:!1}),o.resources.blink(a,"lookme")),e.isPlainObject(C.toast.incwd)&&o.toast(l(C.toast.incwd))):e.isPlainObject(C.toast.inbuffer)&&o.toast(l(C.toast.inbuffer))})),l.resolve(t),void(t.debug&&o.debug("backend-debug",t))):l.reject(t.norError||"errResponse",i,t)};b?o.lazy(a):a()},O=function(e){i&&"pending"===i.state()&&(i.quiet=!0,i.abort(),e&&"unload"!=e.type&&"destroy"!=e.type&&o.autoSync())},M=function(e){if(o.trigger(c+"done"),"autosync"==e.type){if("stop"!=e.data.action)return}else if(!("unload"==e.type||"destroy"==e.type||"openxhrabort"==e.type||e.data.added&&e.data.added.length))return;O(e)},D=function(){if(u){if(K)return l.reject();K=!0}if(B++,l.fail(function(e,t,n){O(),o.trigger(c+"fail",n),e&&(h?o.error(e):o.debug("error",o.i18n(e))),v&&o.sync()}),!c)return v=!1,l.reject("errCmdReq");if(o.maxTargets&&d.targets&&d.targets.length>o.maxTargets)return v=!1,l.reject(["errMaxTargets",o.maxTargets]);if(p&&l.done(A),f.type&&f.cnt&&(m&&(f.cancel=l),n=setTimeout(function(){o.notify(f),l.always(function(){f.cnt=-(parseInt(f.cnt)||0),o.notify(f)})},o.notifyDelay),l.always(function(){clearTimeout(n)})),u){for(;a=S.pop();)"pending"==a.state()&&(a.quiet=!0,a.abort());if(y!==d.target)for(;a=U.pop();)"pending"==a.state()&&(a.quiet=!0,a.abort())}return-1!==e.inArray(c,(o.cmdsToAdd+" autosync").split(" "))&&("autosync"!==c&&(o.autoSync("stop"),l.always(function(){o.autoSync()})),o.trigger("openxhrabort")),delete T.preventFail,l.xhr=i=o.transport.send(T).always(function(){--B,V.length?V.shift()():K=!1}).fail(z).done(I),u||d.compare&&"info"===c?(S.unshift(i),d.compare&&o.bind(o.cmdsToAdd+" autosync openxhrabort",M),l.always(function(){var t=e.inArray(i,S);d.compare&&o.unbind(o.cmdsToAdd+" autosync openxhrabort",M),-1!==t&&S.splice(t,1)})):-1!==e.inArray(c,o.abortCmdsOnOpen)&&(U.unshift(i),l.always(function(){var t=e.inArray(i,U);-1!==t&&U.splice(t,1)})),o.bind("unload destroy",M),l.always(function(){o.unbind("unload destroy",M)}),l},E=function(){return u&&(K=!1),r>B?D():(u?V.unshift(D):V.push(D),l)},F={opts:t,result:!0};return o.trigger("request."+c,F,!0),F.result?"object"==typeof F.result&&F.result.promise?(F.result.done(E).fail(function(){o.trigger(c+"done"),l.reject()}),l):E():(o.trigger(c+"done"),l.reject())},this.cache=function(e){Array.isArray(e)||(e=[e]),_(e)},this.updateCache=function(t){e.isPlainObject(t)&&(t.files&&t.files.length&&_(t.files),t.tree&&t.tree.length&&_(t.tree),t.removed&&t.removed.length&&L(t.removed),t.added&&t.added.length&&_(t.added),t.changed&&t.changed.length&&W(t.changed))},this.diff=function(t,n,i){var a={},r=[],o=[],s=[],l=function(e){for(var t=s.length;t--;)if(s[t].hash==e)return!0};return e.each(t,function(e,t){a[t.hash]=t}),e.each(x,function(e,t){a[e]||n&&t.phash!==n||o.push(e)}),e.each(a,function(t,n){var a=x[t];a?e.each(n,function(t){return i&&-1!==e.inArray(t,i)||n[t]===a[t]?void 0:(s.push(n),!1)}):r.push(n)}),e.each(o,function(t,n){var i=x[n],r=i.phash;r&&"directory"==i.mime&&-1===e.inArray(r,o)&&a[r]&&!l(r)&&s.push(a[r])}),{added:r,removed:o,changed:s}},this.sync=function(t,n){this.autoSync("stop");var i=this,a=function(){var i="",a=0,r=0;return t&&n&&e.each(x,function(e,n){n.phash&&n.phash===t&&(++a,r=Math.max(r,n.ts)),i=a+":"+r}),i},r=a(),o=e.Deferred().done(function(){i.trigger("sync")}),s=[this.request({data:{cmd:"open",reload:1,target:y,tree:!t&&this.ui.tree?1:0,compare:r},preventDefault:!0})],l=function(){for(var e,t=[],n=i.file(i.root(y)),a=n?n.volumeid:null,r=i.cwd().phash;r;)(e=i.file(r))?(0!==r.indexOf(a)&&(t.push({target:r,cmd:"tree"}),i.isRoot(e)||t.push({target:r,cmd:"parents"}),n=i.file(i.root(r)),a=n?n.volumeid:null),r=e.phash):r=null;return t};return!t&&i.api>=2&&(y!==this.root()&&s.push(this.request({data:{cmd:"parents",target:y},preventDefault:!0})),e.each(l(),function(e,t){s.push(i.request({data:{cmd:t.cmd,target:t.target},preventDefault:!0}))})),e.when.apply(e,s).fail(function(t,a){n&&-1===e.inArray("errOpen",t)?o.reject(t&&0!=a.status?t:void 0):(o.reject(t),t&&i.request({data:{cmd:"open",target:i.lastDir("")||i.root(),tree:1,init:1},notify:{type:"open",cnt:1,hideCnt:!0}}))}).done(function(e){var n,a,s;if(e.cwd.compare&&r===e.cwd.compare)return o.reject();if(n={tree:[]},a=arguments.length,a>1)for(s=1;a>s;s++)arguments[s].tree&&arguments[s].tree.length&&n.tree.push.apply(n.tree,arguments[s].tree);if(i.api<2.1&&(n.tree||(n.tree=[]),n.tree.push(e.cwd)),e=i.normalize(e),!i.validResponse("open",e))return o.reject(e.norError||"errResponse");if(n=i.normalize(n),!i.validResponse("tree",n))return o.reject(n.norError||"errResponse");var l=i.diff(e.files.concat(n&&n.tree?n.tree:[]),t);return l.added.push(e.cwd),i.updateCache(l),l.removed.length&&i.remove(l),l.added.length&&i.add(l),l.changed.length&&i.change(l),o.resolve(l)}).always(function(){i.autoSync()}),o},this.upload=function(e){return this.transport.upload(e,this)},this.toUnbindEvents={},this.bind=function(e,t){var n,i;if("function"==typeof t)for(e=(""+e).toLowerCase().replace(/^\s+|\s+$/g,"").split(/\s+/),i=e.length,n=0;i>n;n++)void 0===A[e[n]]&&(A[e[n]]=[]),A[e[n]].push(t);return this},this.unbind=function(t,n){var i,a,r,o;for(t=(""+t).toLowerCase().split(/\s+/),a=t.length,i=0;a>i;i++)(r=A[t[i]])&&(o=e.inArray(n,r),o>-1&&r.splice(o,1));return n=null,this},this.trigger=function(t,n,i){var a,r,o,s,t=t.toLowerCase(),d="object"==typeof n,c=A[t]||[];if(this.debug("event-"+t,n),i=!0,r=c.length){for(s=e.Event(t),i&&(s.data=n),a=0;r>a;a++)if(c[a]){c[a].length&&(i||(d&&!o&&(o=JSON.stringify(n)),s.data=o?JSON.parse(o):n));try{if(c[a].call(s,s,this)===!1||s.isDefaultPrevented()){this.debug("event-stoped",s.type);break}}catch(u){window.console&&window.console.log&&window.console.log(u)}}this.toUnbindEvents[t]&&this.toUnbindEvents[t].length&&(e.each(this.toUnbindEvents[t],function(e,t){l.unbind(t.type,t.callback)}),delete this.toUnbindEvents[t])}return this},this.getListeners=function(e){return e?A[e.toLowerCase()]:A},this.shortcut=function(t){var n,i,a,r,o;if(this.options.allowShortcuts&&t.pattern&&e.isFunction(t.callback))for(n=t.pattern.toUpperCase().split(/\s+/),r=0;r0?a:a.charCodeAt(0):a>0?a:e.ui.keyCode[a],a&&!z[i]&&(z[i]={keyCode:a,altKey:-1!=e.inArray("ALT",o),ctrlKey:-1!=e.inArray("CTRL",o),shiftKey:-1!=e.inArray("SHIFT",o),type:t.type||"keydown",callback:t.callback,description:t.description,pattern:i});return this},this.shortcuts=function(){var t=[];return e.each(z,function(e,n){t.push([n.pattern,l.i18n(n.description)])}),t},this.clipboard=function(t,n){var i=function(){return e.map(I,function(e){return e.hash})};return void 0!==t&&(I.length&&this.trigger("unlockfiles",{files:i()}),O={},I=e.map(t||[],function(e){var t=x[e];return t?(O[e]=!0,{hash:e,phash:t.phash,name:t.name,mime:t.mime,read:t.read,locked:t.locked,cut:!!n}):null}),this.trigger("changeclipboard",{clipboard:I.slice(0,I.length)}),n&&this.trigger("lockfiles",{files:i()})),I.slice(0,I.length)},this.isCommandEnabled=function(t,n){var i,a=l.cwd().volumeid||"";return!n&&l.searchStatus.state>1&&l.selected().length&&(n=l.selected()[0]),!n||a&&0===n.indexOf(a)?i=k.disabled:(i=l.option("disabled",n),i||(i=[])),this._commands[t]?-1===e.inArray(t,i):!1},this.exec=function(t,n,i,a){return"open"===t&&((this.searchStatus.state||this.searchStatus.ininc)&&this.trigger("searchend",{noupdate:!0}),this.autoSync("stop")),this._commands[t]&&this.isCommandEnabled(t,a)?this._commands[t].exec(n,i):e.Deferred().reject("No such command")},this.dialog=function(n,i){var a=e("
").append(n).appendTo(t).elfinderdialog(i,this),r=a.closest(".ui-dialog"),o=function(){!a.data("draged")&&a.is(":visible")&&a.elfinderdialog("posInit")};return r.length&&(l.bind("resize",o),r.on("remove",function(){l.unbind("resize",o)})),a},this.toast=function(t){return e('
').appendTo(this.ui.toast).elfindertoast(t||{},this)},this.getUI=function(e){return this.ui[e]||t},this.getCommand=function(e){return void 0===e?this._commands:this._commands[e]},this.resize=function(n,i){var a,r=function(){for(var e=t.outerHeight(!0)-t.innerHeight(),n=t;n.get(0)!==F.get(0)&&(n=n.parent(),e+=n.outerHeight(!0)-n.innerHeight(),n.parent().length););return e},o=!t.hasClass("ui-resizable"),s=t.data("resizeSize")||{w:0,h:0},d={};F&&F.data("resizeTm")&&clearTimeout(F.data("resizeTm")),"string"==typeof i&&(a=i.match(/^([0-9.]+)%$/))&&(F&&F.length||(F=e(window)),F.data("marginToMyNode")||F.data("marginToMyNode",r()),F.data("fitToBaseFunc")||F.data("fitToBaseFunc",function(){var e=F.data("resizeTm");e&&clearTimeout(e),t.hasClass("elfinder-fullscreen")||F.data("resizeTm",setTimeout(function(){l.restoreSize()},100))}),i=F.height()*(a[1]/100)-F.data("marginToMyNode"),F.off("resize."+l.namespace,F.data("fitToBaseFunc")),o&&F.on("resize."+l.namespace,F.data("fitToBaseFunc"))),t.css({width:n,height:parseInt(i)}),d.w=t.width(),d.h=t.height(),t.data("resizeSize",d),d.w===s.w&&d.h===s.h||(t.trigger("resize"),this.trigger("resize",{width:d.w,height:d.h}))},this.restoreSize=function(){this.resize(D,E)},this.show=function(){t.show(),this.enable().trigger("show")},this.hide=function(){this.options.enableAlways&&(v=g,g=!1),this.disable().trigger("hide"),t.hide()},this.lazy=function(n,i,a){var r=function(e){var n,i=t.data("lazycnt");e?(n=t.data("lazyrepaint")?!1:a.repaint,i?t.data("lazycnt",++i):t.data("lazycnt",1).addClass("elfinder-processing"),n&&t.data("lazyrepaint",!0).css("display")):i&&i>1?t.data("lazycnt",--i):(n=t.data("lazyrepaint"), t.data("lazycnt",0).removeData("lazyrepaint").removeClass("elfinder-processing"),n&&t.css("display"),l.trigger("lazydone"))},o=e.Deferred();return i=i||0,a=a||{},r(!0),setTimeout(function(){o.resolve(n.call(o)),r(!1)},i),o},this.destroy=function(){t&&t[0].elfinder&&(this.options.syncStart=!1,this.autoSync("forcestop"),this.trigger("destroy").disable(),I=[],T=[],A={},z={},e(window).off("."+h),e(document).off("."+h),l.trigger=function(){},e(j).remove(),t.off().removeData().empty().append(c.contents()).attr("class",c.attr("class")).attr("style",c.attr("style")),delete t[0].elfinder)},this.autoSync=function(t){var n;if(l.options.sync>=1e3){if(a&&(clearTimeout(a),a=null,l.trigger("autosync",{action:"stop"})),"stop"===t?++R:R=Math.max(0,--R),R||"forcestop"===t||!l.options.syncStart)return;n=function(t){var i;k.syncMinMs&&(t||a)&&(t&&l.trigger("autosync",{action:"start"}),i=Math.max(l.options.sync,k.syncMinMs),a&&clearTimeout(a),a=setTimeout(function(){var t,r=!0,o=y;k.syncChkAsTs&&(t=x[o].ts)?l.request({data:{cmd:"info",targets:[o],compare:t,reload:1},preventDefault:!0}).done(function(e){var i;r=!0,e.compare&&(i=e.compare,i==t&&(r=!1)),r?l.sync(o).always(function(){i&&(x[o].ts=i),n()}):n()}).fail(function(t,r){t&&0!=r.status?(l.error(t),-1!==e.inArray("errOpen",t)&&l.request({data:{cmd:"open",target:l.lastDir("")||l.root(),tree:1,init:1},notify:{type:"open",cnt:1,hideCnt:!0}})):a=setTimeout(function(){n()},i)}):l.sync(y,!0).always(function(){n()})},i))},n(!0)}},this.insideWorkzone=function(e,t,n){var i=this.getUI("workzone").data("rectangle");return n=n||1,!(ei.left+i.width+n||ti.top+i.height+n)},this.toFront=function(n){var i=t.children(":last");n=e(n),i.get(0)!==n.get(0)&&n.trigger("beforedommove").insertAfter(i).trigger("dommove")},this.getMaximizeCss=function(){return{width:"100%",height:"100%",margin:0,padding:0,top:0,left:0,display:"block",position:"fixed",zIndex:Math.max(l.zIndex?l.zIndex+1:0,1e3)}},function(){Y&&l.UA.Fullscreen&&(l.UA.Fullscreen=!1,X&&"undefined"!=typeof X.attr("allowfullscreen")&&(l.UA.Fullscreen=!0));var n,i,a,r="elfinder-fullscreen",o="elfinder-fullscreen-native",s=function(){var n=0,i=0;e.each(t.children(".ui-dialog,.ui-draggable"),function(t,a){var r=e(a),o=r.position();o.top<0&&(r.css("top",n),n+=20),o.left<0&&(r.css("left",i),i+=20)})},d=l.UA.Fullscreen?{fullElm:function(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||null},exitFull:function(){return document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen?document.msExitFullscreen():void 0},toFull:function(e){return e.requestFullscreen?e.requestFullscreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.msRequestFullscreen?e.msRequestFullscreen():!1}}:{fullElm:function(){var e;return t.hasClass(r)?t.get(0):(e=t.find("."+r),e.length?e.get(0):null)},exitFull:function(){var t;e(window).off("resize."+h,u),void 0!==i&&e("body").css("overflow",i),i=void 0,n&&(t=n.elm,c(t),e(t).trigger("resize",{fullscreen:"off"})),e(window).trigger("resize")},toFull:function(t){return i=e("body").css("overflow")||"",e("body").css("overflow","hidden"),e(t).css(l.getMaximizeCss()).addClass(r).trigger("resize",{fullscreen:"on"}),s(),e(window).on("resize."+h,u).trigger("resize"),!0}},c=function(t){n&&n.elm==t&&(e(t).removeClass(r+" "+o).attr("style",n.style),n=null)},u=function(t){var n;t.target===window&&(a&&clearTimeout(a),a=setTimeout(function(){(n=d.fullElm())&&e(n).trigger("resize",{fullscreen:"on"})},100))};e(document).on("fullscreenchange."+h+" webkitfullscreenchange."+h+" mozfullscreenchange."+h+" MSFullscreenChange."+h,function(t){if(l.UA.Fullscreen){var i=d.fullElm(),p=e(window);a&&clearTimeout(a),null===i?(p.off("resize."+h,u),n&&(i=n.elm,c(i),e(i).trigger("resize",{fullscreen:"off"}))):(e(i).addClass(r+" "+o).attr("style","width:100%; height:100%; margin:0; padding:0;").trigger("resize",{fullscreen:"on"}),p.on("resize."+h,u),s()),p.trigger("resize")}}),l.toggleFullscreen=function(t,i){var a=e(t).get(0),r=null;if(r=d.fullElm()){if(r==a){if(i===!0)return r}else if(i===!1)return r;return d.exitFull(),null}return i===!1?null:(n={elm:a,style:e(a).attr("style")},d.toFull(a)!==!1?a:(n=null,null))}}(),function(){var t,n="elfinder-maximized",i=function(e){if(e.target===window&&e.data&&e.data.elm){var n=e.data.elm;t&&clearTimeout(t),t=setTimeout(function(){n.trigger("resize",{maximize:"on"})},100)}},a=function(t){e(window).off("resize."+h,i),e("body").css("overflow",t.data("bodyOvf")),t.removeClass(n).attr("style",t.data("orgStyle")).removeData("bodyOvf").removeData("orgStyle"),t.trigger("resize",{maximize:"off"})},r=function(t){t.data("bodyOvf",e("body").css("overflow")||"").data("orgStyle",t.attr("style")).addClass(n).css(l.getMaximizeCss()),e("body").css("overflow","hidden"),e(window).on("resize."+h,{elm:t},i).trigger("resize")};l.toggleMaximize=function(t,i){var o=e(t),s=o.hasClass(n);if(s){if(i===!0)return;a(o)}else{if(i===!1)return;r(o)}}}(),e.fn.selectable&&e.fn.draggable&&e.fn.droppable?t.length?this.options.url?(Object.assign(e.ui.keyCode,{F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,DIG0:48,DIG1:49,DIG2:50,DIG3:51,DIG4:52,DIG5:53,DIG6:54,DIG7:55,DIG8:56,DIG9:57,NUM0:96,NUM1:97,NUM2:98,NUM3:99,NUM4:100,NUM5:101,NUM6:102,NUM7:103,NUM8:104,NUM9:105,CONTEXTMENU:93}),this.dragUpload=!1,this.xhrUpload=("undefined"!=typeof XMLHttpRequestUpload||"undefined"!=typeof XMLHttpRequestEventTarget)&&"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(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?l.bind("error",e):e===!0?this:l.trigger("error",{error:e,opts:t})},e.each(b,function(t,n){l[n]=function(){var t=arguments[0];return 1==arguments.length&&"function"==typeof t?l.bind(n,t):l.trigger(n,e.isPlainObject(t)?t:{})}}),this.enable(function(){!g&&l.visible()&&l.ui.overlay.is(":hidden")&&!t.children(".elfinder-dialog").find("."+l.res("class","editing")).length&&(g=!0,document.activeElement&&document.activeElement.blur(),t.removeClass("elfinder-disabled"))}).disable(function(){v=g,g=!1,t.addClass("elfinder-disabled")}).open(function(){T=[]}).select(function(t){var n=0,i=[];T=e.map(t.data.selected||t.data.value||[],function(e){return i.length||l.maxTargets&&++n>l.maxTargets?(i.push(e),null):x[e]?e:null}),i.length&&(l.trigger("unselectfiles",{files:i,inselect:!0}),l.toast({mode:"warning",msg:l.i18n(["errMaxTargets",l.maxTargets])}))}).error(function(t){var n={cssClass:"elfinder-dialog-error",title:l.i18n(l.i18n("error")),resizable:!1,destroyOnClose:!0,buttons:{}};n.buttons[l.i18n(l.i18n("btnClose"))]=function(){e(this).elfinderdialog("close")},t.data.opts&&e.isPlainObject(t.data.opts)&&Object.assign(n,t.data.opts),l.dialog(''+l.i18n(t.data.error),n)}).bind("tmb",function(t){e.each(t.data.images||[],function(e,t){x[e]&&(x[e].tmb=t)})}).bind("searchstart",function(e){Object.assign(l.searchStatus,e.data),l.searchStatus.state=1}).bind("search",function(e){l.searchStatus.state=2}).bind("searchend",function(){l.searchStatus.state=0,l.searchStatus.ininc=!1,l.searchStatus.mixed=!1}),!0===this.options.sound&&this.bind("playsound",function(t){var n=j.canPlayType&&j.canPlayType('audio/wav; codecs="1"'),i=t.data&&t.data.soundFile;n&&i&&""!=n&&"no"!=n&&e(j).html('')[0].play()}),e.each(this.options.handlers,function(e,t){l.bind(e,t)}),this.history=new this.history(this),this.commands.getfile&&("function"==typeof this.options.getFileCallback?(this.bind("dblclick",function(e){this.preventDefault(),l.exec("getfile").fail(function(){l.exec("open",e.data&&e.data.file?[e.data.file]:void 0)})}),this.shortcut({pattern:"enter",description:this.i18n("cmdgetfile"),callback:function(){l.exec("getfile").fail(function(){l.exec("mac"==l.OS?"rename":"open")})}}).shortcut({pattern:"ctrl+enter",description:this.i18n("mac"==this.OS?"cmdrename":"cmdopen"),callback:function(){l.exec("mac"==l.OS?"rename":"open")}})):this.options.getFileCallback=null),this.roots={},this.leafRoots={},this._commands={},Array.isArray(this.options.commands)||(this.options.commands=[]),-1!==e.inArray("*",this.options.commands)&&(this.options.commands=Object.keys(this.commands)),e.each(this.commands,function(t,n){var i,a,r=Object.assign({},n.prototype);if(e.isFunction(n)&&!l._commands[t]&&(n.prototype.forceLoad||-1!==e.inArray(t,l.options.commands))){if(i=n.prototype.extendsCmd||""){if(!e.isFunction(l.commands[i]))return!0;n.prototype=Object.assign({},M,new l.commands[i],n.prototype)}else n.prototype=Object.assign({},M,n.prototype);l._commands[t]=new n,n.prototype=r,a=l.options.commandsOptions[t]||{},i&&l.options.commandsOptions[i]&&(a=e.extend(!0,{},l.options.commandsOptions[i],a)),l._commands[t].setup(t,a),l._commands[t].linkedCmds.length&&e.each(l._commands[t].linkedCmds,function(t,n){var i=l.commands[n];e.isFunction(i)&&!l._commands[n]&&(i.prototype=M,l._commands[n]=new i,l._commands[n].setup(n,l.options.commandsOptions[n]||{}))})}}),this.commandMap={},this.volOptions={},this.trashes={},this.optionsByHashes={},t.addClass(this.cssClass).on(p,function(){!g&&l.enable()}),this.ui={workzone:e("
").appendTo(t).elfinderworkzone(this),navbar:e("
").appendTo(t).elfindernavbar(this,this.options.uiOptions.navbar||{}),contextmenu:e("
").appendTo(t).elfindercontextmenu(this),overlay:e("
").appendTo(t).elfinderoverlay({show:function(){l.disable()},hide:function(){v&&l.enable()}}),cwd:e("
").appendTo(t).elfindercwd(this,this.options.uiOptions.cwd||{}),notify:this.dialog("",{cssClass:"elfinder-dialog-notify",position:this.options.notifyDialog.position,absolute:!0,resizable:!1,autoOpen:!1,closeOnEscape:!1,title:" ",width:parseInt(this.options.notifyDialog.width)}),statusbar:e('
').hide().appendTo(t),toast:e('
').appendTo(t),bottomtray:e('
').appendTo(t)},this.uiAutoHide=[],this.one("open",function(){l.uiAutoHide.length&&setTimeout(function(){l.trigger("uiautohide")},500)}),this.bind("uiautohide",function(){l.uiAutoHide.length&&l.uiAutoHide.shift()()}),e.each(this.options.ui||[],function(n,i){var a="elfinder"+i,r=l.options.uiOptions[i]||{};!l.ui[i]&&e.fn[a]&&(l.ui[i]=e("<"+(r.tag||"div")+"/>").appendTo(t),l.ui[i][a](l,r))}),t[0].elfinder=this,this.options.resizable&&e.fn.resizable&&t.resizable({resize:function(e,t){l.resize(t.size.width,t.size.height)},handles:"se",minWidth:300,minHeight:200}),this.options.width&&(D=this.options.width),this.options.height&&(E=this.options.height),this.options.heightBase&&(F=e(this.options.heightBase)),this.options.soundPath&&(P=this.options.soundPath.replace(/\/+$/,"")+"/"),l.resize(D,E),e(document).on("click."+h,function(n){g&&!l.options.enableAlways&&!e(n.target).closest(t).length&&l.disable()}).on(f+" "+m,G),l.options.useBrowserHistory&&e(window).on("popstate."+h,function(t){var n=t.originalEvent.state&&t.originalEvent.state.thash;n&&!e.isEmptyObject(l.files())&&l.request({data:{cmd:"open",target:n,onhistory:1},notify:{type:"open",cnt:1,hideCnt:!0},syncOnFail:!0})}),function(){var n;e(window).on("resize."+h,function(e){e.target===this&&(n&&clearTimeout(n),n=setTimeout(function(){l.trigger("resize",{width:t.width(),height:t.height()})},100))}).on("beforeunload."+h,function(n){var i,a;return t.is(":visible")&&(l.ui.notify.children().length&&-1!==e.inArray("hasNotifyDialog",l.options.windowCloseConfirm)?i=l.i18n("ntfsmth"):t.find("."+l.res("class","editing")).length&&-1!==e.inArray("editingFile",l.options.windowCloseConfirm)?i=l.i18n("editingFile"):(a=Object.keys(l.selected()).length)&&-1!==e.inArray("hasSelectedItem",l.options.windowCloseConfirm)?i=l.i18n("hasSelected",""+a):(a=Object.keys(l.clipboard()).length)&&-1!==e.inArray("hasClipboardData",l.options.windowCloseConfirm)&&(i=l.i18n("hasClipboard",""+a)),i)?(n.returnValue=i,i):void l.trigger("unload")})}(),e(window).on("message."+h,function(e){var t,n,i=e.originalEvent||null;if(i&&0===l.uploadURL.indexOf(i.origin))try{t=JSON.parse(i.data),n=t.data||null,n&&(n.error?(t.bind&&l.trigger(t.bind+"fail",n),l.error(n.error)):(n.warning&&l.error(n.warning),l.updateCache(n),n.removed&&n.removed.length&&l.remove(n),n.added&&n.added.length&&l.add(n),n.changed&&n.changed.length&&l.change(n),t.bind&&(l.trigger(t.bind,n),l.trigger(t.bind+"done")),n.sync&&l.sync()))}catch(e){l.sync()}}),l.options.enableAlways?(e(window).on("focus."+h,function(e){e.target===this&&l.enable()}),Y&&e(window.top).on("focus."+h,function(){!l.enable()||X&&!X.is(":visible")||setTimeout(function(){e(window).focus()},10)})):Y&&e(window).on("blur."+h,function(e){g&&e.target===this&&l.disable()}),function(){var e=l.getUI("navbar"),t=l.getUI("cwd").parent();l.autoScroll={navbarUp:function(t){e.scrollTop(Math.max(0,e.scrollTop()-t))},navbarDown:function(t){e.scrollTop(e.scrollTop()+t)},cwdUp:function(e){t.scrollTop(Math.max(0,t.scrollTop()-e))},cwdDown:function(e){t.scrollTop(t.scrollTop()+e)}}}(),l.dragUpload&&!function(){var n,i,a=function(t){return"TEXTAREA"!==t.target.nodeName&&"INPUT"!==t.target.nodeName&&0===e(t.target).closest("div.ui-dialog-content").length},r="native-drag-enter",o="native-drag-disable",s="class",d=l.res(s,"navdir"),c=(l.res(s,"droppable"),l.res(s,"adroppable"),l.res(s,"navarrow"),l.res(s,"adroppable")),h=l.getUI("workzone"),p="ltr"===l.direction,f=function(){i&&clearTimeout(i),i=null};t.on("dragenter",function(e){f(),a(e)&&(e.preventDefault(),e.stopPropagation(),n=h.data("rectangle"))}).on("dragleave",function(e){f(),a(e)&&(e.preventDefault(),e.stopPropagation())}).on("dragover",function(e){var t;a(e)?(e.preventDefault(),e.stopPropagation(),e.originalEvent.dataTransfer.dropEffect="none",i||(i=setTimeout(function(){var a,r=n.top+n.height;((t=e.pageYr)&&(a=n.cwdEdge>e.pageX?(p?"navbar":"cwd")+(t?"Up":"Down"):(p?"cwd":"navbar")+(t?"Up":"Down"),l.autoScroll[a](Math.pow(t?n.top-e.pageY:e.pageY-r,1.3))),i=null},20))):f()}).on("drop",function(e){f(),a(e)&&(e.stopPropagation(),e.preventDefault())}),t.on("dragenter",".native-droppable",function(t){if(t.originalEvent.dataTransfer){var n,i=e(t.currentTarget),a=t.currentTarget.id||null,s=null;if(!a){s=l.cwd(),i.data(o,!1);try{e.each(t.originalEvent.dataTransfer.types,function(e,t){"elfinderfrom:"===t.substr(0,13)&&(n=t.substr(13).toLowerCase())})}catch(t){}}s&&(!s.write||n&&n===(window.location.href+s.hash).toLowerCase())?i.data(o,!0):(t.preventDefault(),t.stopPropagation(),i.data(r,!0),i.addClass(c))}}).on("dragleave",".native-droppable",function(t){if(t.originalEvent.dataTransfer){var n=e(t.currentTarget);t.preventDefault(),t.stopPropagation(),n.data(r)?n.data(r,!1):n.removeClass(c)}}).on("dragover",".native-droppable",function(t){if(t.originalEvent.dataTransfer){var n=e(t.currentTarget);t.preventDefault(),t.stopPropagation(),t.originalEvent.dataTransfer.dropEffect=n.data(o)?"none":"copy",n.data(r,!1)}}).on("drop",".native-droppable",function(t){if(t.originalEvent&&t.originalEvent.dataTransfer){var n=e(t.currentTarget);t.preventDefault(),t.stopPropagation(),n.removeClass(c),u=t.currentTarget.id?n.hasClass(d)?l.navId2Hash(t.currentTarget.id):l.cwdId2Hash(t.currentTarget.id):l.cwd().hash,t.originalEvent._target=u,l.exec("upload",{dropEvt:t.originalEvent,target:u},void 0,u)}})}(),l.UA.Touch&&!function(){var n,i,a,r,o,s,d,c,u,h=l.getUI("navbar"),p=l.getUI("toolbar"),f="touchmove.stopscroll",m=function(e){e.preventDefault(),c&&clearTimeout(c)},g=function(){c=setTimeout(function(){t.off(f)},100)},v=50;t.on("touchstart touchmove touchend",function(c){if("touchend"===c.type)return n=!1,i=!1,void g();var b,y,w,k,x,C,T=c.originalEvent.touches||[{}],A=T[0].pageX||null,z=T[0].pageY||null,I="ltr"===l.direction;null===A||null===z||"touchstart"===c.type&&T.length>1||("touchstart"===c.type?(a=t.offset(),r=t.width(),h&&(n=!1,h.is(":hidden")?(u||(u=Math.max(50,r/10)),(I?A-a.left:r+a.left-A)a.left+r-s&&y+h.scrollLeft()-5<=s,w?(u=Math.max(50,r/10),n=A):n=!1)),p&&(d=p.height(),o=a.top,z-o<(p.is(":hidden")?v:d+30)?(i=z,t.on(f,m),g()):i=!1)):(h&&n!==!1&&(b=(I?n>A:A>n)?"navhide":"navshow",k=Math.abs(n-A),("navhide"===b&&k>.6*s||k>("navhide"===b?s/3:45)&&("navshow"===b||(I?Aa.left+r-20)))&&(l.getUI("navbar").trigger(b,{handleW:u}),n=!1)),p&&i!==!1&&(x=p.offset().top,Math.abs(i-z)>Math.min(45,d/3)&&(C=i>z?"slideUp":"slideDown",("slideDown"===C||x+20>z)&&(p.is("slideDown"===C?":hidden":":visible")&&(p.stop(!0,!0).trigger("toggle",{duration:100,handleH:v}),g()),i=!1)))))})}(),Y&&t.on("click",function(t){e(window).focus()}),this.options.enableByMouseOver&&t.on("mouseenter",function(t){Y&&e(window).focus(),!l.enabled()&&l.enable()}),this.options.cssAutoLoad||this.trigger("cssloaded"),this.zIndexCalc(),void this.trigger("init").request({data:{cmd:"open",target:l.startDir(),init:1,tree:l.ui.tree?1:0},preventDone:!0,notify:{type:"open",cnt:1,hideCnt:!0},freeze:!0}).fail(function(){l.trigger("fail").disable().lastDir(""),A={},z={},e(document).add(t).off("."+h),l.trigger=function(){}}).done(function(n){var i=function(e){var t=l.file(l.trashes[e]);l.options.debug;t&&t.volumeid&&delete l.volOptions[t.volumeid].trashHash,l.trashes[e]=!1,l.debug("backend-error",'Trash hash "'+e+'" was not found or not writable.')},a={};l.zIndexCalc(),l.load().debug("api",l.api),t.trigger("resize"),q(n),l.trigger("open",n),l.trigger("opendone"),Y&&l.options.enableAlways&&e(window).focus(),e.each(l.trashes,function(e){var t=l.file(e);t?"directory"===t.mime&&t.write||i(e):a[e]=!0}),Object.keys(a).length&&l.request({data:{cmd:"info",targets:Object.keys(a)},preventDefault:!0}).done(function(t){t&&t.files&&e.each(t.files,function(e,t){"directory"===t.mime&&t.write&&delete a[t.hash]})}).always(function(){e.each(a,i)})})):alert(this.i18n("errURL")):alert(this.i18n("errNode")):alert(this.i18n("errJqui"))};("undefined"==typeof n||n)&&(window.elFinder=i),i.prototype={uniqueid:0,res:function(e,t){return this.resources[e]&&this.resources[e][t]},OS:-1!==navigator.userAgent.indexOf("Mac")?"mac":-1!==navigator.userAgent.indexOf("Win")?"win":"other",UA:function(){var e=!document.uniqueID&&!window.opera&&!window.sidebar&&window.localStorage&&"WebkitAppearance"in document.documentElement.style;return{ltIE6:"undefined"==typeof window.addEventListener&&"undefined"==typeof document.documentElement.style.maxHeight,ltIE7:"undefined"==typeof window.addEventListener&&"undefined"==typeof document.querySelectorAll,ltIE8:"undefined"==typeof window.addEventListener&&"undefined"==typeof document.getElementsByClassName,IE:document.uniqueID,Firefox:window.sidebar,Opera:window.opera,Webkit:e,Chrome:e&&window.chrome,Safari:e&&!window.chrome,Mobile:"undefined"!=typeof window.orientation,Touch:"undefined"!=typeof window.ontouchstart,iOS:navigator.platform.match(/^iP(?:[ao]d|hone)/),Fullscreen:"undefined"!=typeof(document.exitFullscreen||document.webkitExitFullscreen||document.mozCancelFullScreen||document.msExitFullscreen)}}(),currentReqCmd:"",i18:{en:{translator:"",language:"English",direction:"ltr",dateFormat:"d.m.Y H:i",fancyDateFormat:"$1 H:i",nonameDateFormat:"ymd-His",messages:{}},months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["msJan","msFeb","msMar","msApr","msMay","msJun","msJul","msAug","msSep","msOct","msNov","msDec"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],daysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]},kinds:{unknown:"Unknown",directory:"Folder",symlink:"Alias","symlink-broken":"AliasBroken","application/x-empty":"TextPlain","application/postscript":"Postscript","application/vnd.ms-office":"MsOffice","application/msword":"MsWord","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.ms-excel":"MsExcel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"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/x-xz":"XZ","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","text/x-markdown":"Markdown","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"},rules:{defaults:function(e){return!(!e||e.added&&!Array.isArray(e.added)||e.removed&&!Array.isArray(e.removed)||e.changed&&!Array.isArray(e.changed))},open:function(t){return t&&t.cwd&&t.files&&e.isPlainObject(t.cwd)&&Array.isArray(t.files)},tree:function(e){return e&&e.tree&&Array.isArray(e.tree)},parents:function(e){return e&&e.tree&&Array.isArray(e.tree)},tmb:function(t){return t&&t.images&&(e.isPlainObject(t.images)||Array.isArray(t.images))},upload:function(t){return t&&(e.isPlainObject(t.added)||Array.isArray(t.added))},search:function(e){return e&&e.files&&Array.isArray(e.files)}},commands:{},cmdsToAdd:"archive duplicate extract mkdir mkfile paste rm upload",parseUploadData:function(t){var n;if(!e.trim(t))return{error:["errResponse","errDataEmpty"]};try{n=JSON.parse(t)}catch(i){return{error:["errResponse","errDataNotJSON"]}}return n=this.normalize(n),this.validResponse("upload",n)?(n.removed=e.merge(n.removed||[],e.map(n.added||[],function(e){return e.hash})),n):{error:response.norError||["errResponse"]}},iframeCnt:0,uploads:{xhrUploading:!1,checkExists:function(t,n,i,a){var r,o=e.Deferred(),s=[],l={},d=function(){for(var e=t.length;--e>-1;)t[e]._remove=!0},c=function(){o.resolve(s,l)},u=function(){var o=[],u=[],h=function(e){var n=e==u.length-1,r={title:i.i18n("cmdupload"),text:["errExists",u[e].name,"confirmRepl"],all:!n,accept:{label:"btnYes",callback:function(t){n||t?c():h(++e)}},reject:{label:"btnNo",callback:function(i){var a;if(i)for(a=u.length;e0&&delete r.reject,i.confirm(r)};return i.file(n).read?(r=e.map(t,function(e,t){return!e.name||i.UA.iOS&&"image.jpg"===e.name?null:{i:t,name:e.name}}),void i.request({data:{cmd:"ls",target:n,intersect:e.map(r,function(e){return e.name})},notify:{type:"preupload",cnt:1,hideCnt:!0},preventFail:!0}).done(function(t){var a,s;t&&(t.error?d():i.options.overwriteUploadConfirm&&i.option("uploadOverwrite",n)&&t.list&&(Array.isArray(t.list)?o=t.list||[]:(a=[],o=e.map(t.list,function(e){return"string"==typeof e?e:(a=a.concat(e),null)}),a.length&&(o=o.concat(a)),l=t.list),u=e.map(r,function(t){return-1!==e.inArray(t.name,o)?t:null}),o.length&&n==i.cwd().hash&&(s=e.map(i.files(n),function(e){return e.name}),e.map(o,function(t){return-1===e.inArray(t,s)?!0:null}).length&&i.sync()))),u.length>0?h(0):c()}).fail(function(e){d(),c(),e&&i.error(e)})):void c()};return i.api>=2.1&&"object"==typeof t[0]?u():c(),o},checkFile:function(t,n,i){if(t.checked||"files"==t.type)return t.files;if("data"==t.type){var a,r,o=e.Deferred(),s=[],l=[],d=0,c=[],u=function(e){var t,i,a,r=[],o=function(e){return Array.prototype.slice.call(e||[],0)},h=n.options.folderUploadExclude[n.OS]||null;a=e.length;for(var p=0;a>p;p++)if(i=e[p])if(i.isFile)d++,i.file(function(e){h&&e.name.match(h)||(l.push(i.fullPath||""),s.push(e)),d--});else if(i.isDirectory&&n.api>=2.1){d++,c.push(i.fullPath),t=i.createReader();var r=[],f=function(){t.readEntries(function(e){if(e.length)r=r.concat(o(e)),f();else{for(var t=0;t0?(n.uploads.checkExists(a,i,n,r).done(function(r,h){var p,f=[];n.options.overwriteUploadConfirm&&n.option("uploadOverwrite",i)&&(null===r&&(t.overwrite=0,r=[]),a=e.map(a,function(t){var a,o,s,l;return t.isDirectory&&r.length&&(a=e.inArray(t.name,r),-1!==a&&(r.splice(a,1),o=n.uniqueName(t.name+n.options.backupSuffix,null,""),e.each(h,function(e,n){return t.name==n?(s=e,!1):void 0}),s||(s=n.fileByName(t.name,i).hash),n.lockfiles({files:[s]}),l=n.request({data:{cmd:"rename",target:s,name:o},notify:{type:"rename",cnt:1}}).fail(function(e){t._remove=!0,n.sync()}).always(function(){n.unlockfiles({files:[s]})}),f.push(l))),t._remove?null:t})),e.when.apply(e,f).done(function(){a.length>0?(p=setTimeout(function(){n.notify({type:"readdir",cnt:1,hideCnt:!0})},n.options.notifyDelay),u(a),setTimeout(function e(){d>0?setTimeout(e,10):(p&&clearTimeout(p),n.notify({type:"readdir",cnt:-1}),o.resolve([s,l,r,h,c]))},10)):o.reject()})}),o.promise()):o.reject()}var h=[],p=[],f=t.files[0];if("html"==t.type){var m,g=e("").append(e.parseHTML(f.replace(/ src=/gi," _elfsrc=")));e("img[_elfsrc]",g).each(function(){var n,i,a=e(this),r=a.closest("a");r&&r.attr("href")&&r.attr("href").match(/\.(?:jpe?g|gif|bmp|png)/i)&&(i=r.attr("href")),n=a.attr("_elfsrc"),n&&(i?(-1==e.inArray(i,h)&&h.push(i),-1==e.inArray(n,p)&&p.push(n)):-1==e.inArray(n,h)&&h.push(n)),1===h.length&&h[0].match(/^data:image\/png/)&&(t.clipdata=!0)}),m=e("a[href]",g),m.each(function(){var t,n=function(e){var t=document.createElement("a");return t.href=e,t};e(this).text()&&(t=n(e(this).attr("href")),!t.href||1!==m.length&&t.pathname.match(/(?:\.html?|\/[^\/.]*)$/i)||-1==e.inArray(t.href,h)&&-1==e.inArray(t.href,p)&&h.push(t.href))})}else{var v,b,y;for(v=/(http[^<>"{}|\\^\[\]`\s]+)/gi;b=v.exec(f);)y=b[1].replace(/&/g,"&"),-1==e.inArray(y,h)&&h.push(y)}return h},xhr:function(t,n){var i=n?n:this,a=i.getUI(),r=new XMLHttpRequest,o=null,s=null,l=t.checked,d=t.isDataType||"data"==t.type,c=t.target||i.cwd().hash,u=t.dropEvt||null,h=-1!=i.option("uploadMaxConn",c),p=Math.min(5,Math.max(1,i.option("uploadMaxConn",c))),f=1e4,m=30,g=0,v=function(t){var n=e.Deferred();return t.promise?t.always(function(e){n.resolve(Array.isArray(e)&&e.length?d?e[0][0]:e[0]:{})}):n.resolve(t.length?d?t[0][0]:t[0]:{}),n},b=e.Deferred().fail(function(e){i.uploads.xhrUploading&&v(w).done(function(e){e._cid&&(setTimeout(function(){i.sync()},5e3),y=new FormData,w=[{_chunkfail:!0}],y.append("chunk",e._chunk),y.append("cid",e._cid),d=!1,R(w))}),i.sync(),i.uploads.xhrUploading=!1,w=null,e&&i.error(e)}).done(function(e){r=null,i.uploads.xhrUploading=!1,w=null,e&&(i.currentReqCmd="upload",e.warning&&i.error(e.warning),i.updateCache(e),e.removed&&i.remove(e),e.added&&i.add(e),e.changed&&i.change(e),i.trigger("upload",e),i.trigger("uploaddone"),e.sync&&i.sync(),e.debug&&n.debug("backend-debug",e)); }).always(function(){a.off("uploadabort",U),e(window).off("unload",U),o&&clearTimeout(o),s&&clearTimeout(s),l&&!t.multiupload&&S()&&i.notify({type:"upload",cnt:-k,progress:0,size:0}),j&&z.children(".elfinder-notify-chunkmerge").length&&i.notify({type:"chunkmerge",cnt:-1})}),y=new FormData,w=t.input?t.input.files:i.uploads.checkFile(t,i,c),k=t.checked&&d?w[0].length:w.length,x=0,C=0,T=0,A=!1,z=i.ui.notify,I=!0,O=!1,S=function(){return A=A||z.children(".elfinder-notify-upload").length},U=function(){O=!0,r&&(r.quiet=!0,r.abort()),S()&&i.notify({type:"upload",cnt:-1*z.children(".elfinder-notify-upload").data("cnt"),progress:0,size:0})},M=function(e){z.children(".elfinder-notify-upload").children(".elfinder-notify-cancel")[e?"show":"hide"]()},D=function(e){return e||(e=T),setTimeout(function(){A=!0,i.notify({type:"upload",cnt:k,progress:x-C,size:e,cancel:function(){a.trigger("uploadabort"),b.resolve()}}),C=x,t.multiupload?I&&M(!0):M(I&&e>x)},i.options.notifyDelay)},E=function(){g++<=m?(S()&&C&&i.notify({type:"upload",cnt:0,progress:0,size:C}),r.quiet=!0,r.abort(),C=x=0,setTimeout(function(){O||(r.open("POST",i.uploadURL,!0),r.send(y))},f)):(a.trigger("uploadabort"),b.reject(["errAbort","errTimeout"]))},F=t.renames||null,P=t.hashes||null,j=!1;if(a.one("uploadabort",U),e(window).one("unload."+n.namespace,U),!j&&(C=x),!d&&!k)return b.reject(["errUploadNoFiles"]);r.addEventListener("error",function(){0==r.status?O?b.reject():!d&&t.files&&e.map(t.files,function(e){return e.type||e.size!==(i.UA.Safari?1802:0)?null:e}).length?(errors.push("errFolderUpload"),b.reject(["errAbort","errFolderUpload"])):t.input&&e.map(t.input.files,function(e){return e.type||e.size!==(i.UA.Safari?1802:0)?null:e}).length?b.reject(["errUploadNoFiles"]):E():(a.trigger("uploadabort"),b.reject("errConnect"))},!1),r.addEventListener("load",function(e){var n,l=r.status,c=0,u="";if(l>=400?u=l>500?"errResponse":["errResponse","errServerError"]:r.responseText||(u=["errResponse","errDataEmpty"]),u&&(a.trigger("uploadabort"),v(w).done(function(e){return b.reject(e._cid?null:u)})),x=T,S()&&(c=x-C)&&i.notify({type:"upload",cnt:0,progress:c,size:0}),n=i.parseUploadData(r.responseText),n._chunkmerged){y=new FormData;var h=[{_chunkmerged:n._chunkmerged,_name:n._name,_mtime:n._mtime}];return j=!0,a.off("uploadabort",U),s=setTimeout(function(){i.notify({type:"chunkmerge",cnt:1})},i.options.notifyDelay),void(d?R(h,w[1]):R(h))}n._multiupload=!!t.multiupload,n.error?(i.trigger("uploadfail",n),n._chunkfailure||n._multiupload?(O=!0,i.uploads.xhrUploading=!1,o&&clearTimeout(o),z.children(".elfinder-notify-upload").length?(i.notify({type:"upload",cnt:-k,progress:0,size:0}),b.reject(n.error)):b.reject()):b.reject(n.error)):b.resolve(n)},!1),r.upload.addEventListener("loadstart",function(e){!j&&e.lengthComputable&&(x=e.loaded,g&&(x=0),T=e.total,x||(x=parseInt(.05*T)),S()&&(i.notify({type:"upload",cnt:0,progress:x-C,size:t.multiupload?0:T}),C=x))},!1),r.upload.addEventListener("progress",function(e){var n;e.lengthComputable&&!j&&r.readyState<2&&(x=e.loaded,!t.checked&&x>0&&!o&&(o=D(r._totalSize-x)),T||(T=e.total,x||(x=parseInt(.05*T))),n=x-C,S()&&n/e.total>=.05&&(i.notify({type:"upload",cnt:0,progress:n,size:0}),C=x),!t.multiupload&&x>=T&&(I=!1,M(!1)))},!1);var R=function(a,s){var f,m,g,v,w,x,C,T,A,z,U,E,j,R=0,H=1,N=[],q=0,_=k,L=0,W=[],$=(new Date).getTime().toString().substr(-9),B=Math.min((n.uplMaxSize?n.uplMaxSize:2097152)-8190,n.options.uploadMaxChunkSize),V=h?!1:"",K=function(a,r){var s,l,h=[],p=0;if(!O){for(;a.length&&h.lengthf&&!O;f++)s=d?h[f][0][0]._cid||null:h[f][0]._cid||null,j[s]?E--:n.exec("upload",{type:t.type,isDataType:d,files:h[f],checked:!0,target:c,dropEvt:u,renames:F,hashes:P,multiupload:!0,overwrite:0===t.overwrite?0:void 0},void 0,c).fail(function(e){e&&"No such command"===e&&(O=!0,n.error(["errUpload","errPerm"])),s&&(j[s]=!0)}).always(function(t){t&&t.added&&(z=e.merge(z,t.added)),E<=++U&&(n.trigger("multiupload",{added:z}),o&&clearTimeout(o),S()&&i.notify({type:"upload",cnt:-k,progress:0,size:0})),a.length?K(a,1):--l<=1&&(I=!1,M(!1))})}}(h.length<1||O)&&(O?(o&&clearTimeout(o),s&&(j[s]=!0),b.reject()):(b.resolve(),i.uploads.xhrUploading=!1))},G=function(){i.uploads.xhrUploading?setTimeout(function(){G()},100):(i.uploads.xhrUploading=!0,K(N,p))};if(!l&&(d||"files"==t.type)){for((f=n.option("uploadMaxSize",c))||(f=0),v=0;v=2.1&&("slice"in T?V="slice":"mozSlice"in T?V="mozSlice":"webkitSlice"in T&&(V="webkitSlice")))}catch(J){k--,_--;continue}if(f&&m>f||!V&&n.uplMaxSize&&m>n.uplMaxSize)i.error(i.i18n("errUploadFile",T.name)+" "+i.i18n("errUploadFileSize")),k--,_--;else if(!T.type||i.uploadMimeCheck(T.type,c))if(V&&m>B){for(w=0,x=B,C=-1,_=Math.floor(m/B),g=T.lastModified?Math.round(T.lastModified/1e3):0,L+=m,W[$]=0;m>=w;)A=T[V](w,x),A._chunk=T.name+"."+ ++C+"_"+_+".part",A._cid=$,A._range=w+","+A.size+","+m,A._mtime=g,W[$]++,R&&q++,"undefined"==typeof N[q]&&(N[q]=[],d&&(N[q][0]=[],N[q][1]=[])),R=B,H=1,d?(N[q][0].push(A),N[q][1].push(s[v])):N[q].push(A),w=x,x=w+B;null==A?(i.error(i.i18n("errUploadFile",T.name)+" "+i.i18n("errUploadFileSize")),k--,_--):(_+=C,R=0,H=1,q++)}else(n.uplMaxSize&&R+m>=n.uplMaxSize||H>n.uplMaxFile)&&(R=0,H=1,q++),"undefined"==typeof N[q]&&(N[q]=[],d&&(N[q][0]=[],N[q][1]=[])),d?(N[q][0].push(T),N[q][1].push(s[v])):N[q].push(T),R+=m,L+=m,H++;else i.error(i.i18n("errUploadFile",T.name)+" "+i.i18n("errUploadMime")+" ("+i.escape(T.type)+")"),k--,_--}if(0==N.length)return t.checked=!0,!1;if(N.length>1)return o=D(L),z=[],U=0,E=N.length,j=[],G(),!0;d?(a=N[0][0],s=N[0][1]):a=N[0]}return l||(n.UA.Safari&&t.files?r._totalSize=L:o=D(L)),l=!0,a.length||b.reject(["errUploadNoFiles"]),r.open("POST",i.uploadURL,!0),n.customHeaders&&e.each(n.customHeaders,function(e){r.setRequestHeader(e,this)}),n.xhrFields&&e.each(n.xhrFields,function(e){e in r&&(r[e]=this)}),y.append("cmd","upload"),y.append(i.newAPI?"target":"current",c),F&&F.length&&(e.each(F,function(e,t){y.append("renames[]",t)}),y.append("suffix",n.options.backupSuffix)),P&&e.each(P,function(e,t){y.append("hashes["+e+"]",t)}),e.each(i.options.customData,function(e,t){y.append(e,t)}),e.each(i.options.onlyMimes,function(e,t){y.append("mimes["+e+"]",t)}),e.each(a,function(e,i){i._chunkmerged?(y.append("chunk",i._chunkmerged),y.append("upload[]",i._name),y.append("mtime[]",i._mtime)):(i._chunkfail?(y.append("upload[]","chunkfail"),y.append("mimes","chunkfail")):(y.append("upload[]",i),t.clipdata&&(t.overwrite=0,y.append("name[]",n.date(n.nonameDateFormat)+".png")),n.UA.iOS&&"image.jpg"===i.name&&(t.overwrite=0,y.append("name[]",n.date(n.nonameDateFormat)+".jpg"))),i._chunk?(y.append("chunk",i._chunk),y.append("cid",i._cid),y.append("range",i._range),y.append("mtime[]",i._mtime)):y.append("mtime[]",i.lastModified?Math.round(i.lastModified/1e3):0))}),d&&e.each(s,function(e,t){y.append("upload_path[]",t)}),0===t.overwrite&&y.append("overwrite",0),u&&y.append("dropWith",parseInt((u.altKey?"1":"0")+(u.ctrlKey?"1":"0")+(u.metaKey?"1":"0")+(u.shiftKey?"1":"0"),2)),r.send(y),!0};if(d)l?R(w[0],w[1]):w.done(function(t){if(F=[],k=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},preventFail:!0}).fail(function(e){e=e||["errUnknown"],"errCmdParams"===e[0]?p=1:(p=0,b.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&&(F=t[2],P=t[3],R(t[0],t[1]))});t[1]=e.map(t[1],function(){return c}),F=t[2],P=t[3],R(t[0],t[1])}else b.reject(["errUploadNoFiles"])}).fail(function(){b.reject()});else if(w.length>0)if(t.clipdata||null!=F)R(w)||b.reject();else{var H=[],N=[],q=n.options.folderUploadExclude[n.OS]||null;e.each(w,function(t,n){var i=n.webkitRelativePath||n.relativePath||"";return i?(q&&n.name.match(q)?(n._remove=!0,i=void 0):(i=i.replace(/\/[^\/]*$/,""),i&&-1===e.inArray(i,H)&&H.push(i)),void N.push(i)):!1}),F=[],P={},H.length?!function(){var t=e.map(H,function(e){return-1===e.indexOf("/")?{name:e}:null}),i=[];n.uploads.checkExists(t,c,n,!0).done(function(a,r){var o,s,l,u=[];n.options.overwriteUploadConfirm&&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(N.concat(),function(t,n){0===e.inArray(n,i)&&(w[t]._remove=!0,delete N[t])}),w=e.map(w,function(e){return e._remove?null:e}),N=e.map(N,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){b.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},preventFail:!0}).fail(function(e){e=e||["errUnknown"],"errCmdParams"===e[0]?p=1:(p=0,b.reject(e))}).done(function(t){t.hashes&&(N=e.map(N.concat(),function(e){return""===e?c:t.hashes["/"+e]}))}).always(function(e){p&&(d=!0,R(w,N)||b.reject())})})):b.reject()})}():n.uploads.checkExists(w,c,n).done(function(i,a){n.options.overwriteUploadConfirm&&n.option("uploadOverwrite",c)&&(null===i?t.overwrite=0:(F=i,P=a),w=e.map(w,function(e){return e._remove?null:e})),k=w.length,k>0?R(w)||b.reject():b.reject()})}else b.reject();return b},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('
'),p=this.UA.IE,f=function(){o&&clearTimeout(o),r&&clearTimeout(r),a&&s.notify({type:"upload",cnt:-i}),setTimeout(function(){p&&e('