d&&(i.on("update."+t.namespace,h),void 0===n&&(u=0,p(),n=f(g.hash),void 0===n&&(n=0)),y=a.slice(n,n+d),$[m]=i,w=n?Math.max(-1,n-d):-1,x=n+d>=a.length?0:n+d,r=Math.ceil(a.length/d),s=Math.ceil(n/d)),e.each(y||a,function(e,t){z.push(V(t)),t.node&&(T[t.hash]=t.node)}),k=w>-1?e('').text(t.i18n("btnPrevious",s,r)).button({icons:{primary:"ui-icon-caret-1-n"}}).on("click",function(e){e.preventDefault(),e.stopPropagation(),v(w,"up")}):e(),C=x?e('').text(t.i18n("btnNext",s+2,r)).button({icons:{primary:"ui-icon-caret-1-s"}}).on("click",function(e){e.preventDefault(),e.stopPropagation(),v(x,"down")}):e(),b(),i.empty()[y?"addClass":"removeClass"]("elfinder-navbar-hasmore").append(k,z.join(""),C),e.each(T,function(n,i){e("#"+t.navHash2Id(n)).parent().replaceWith(i)}),o&&Z(t.navHash2Id(y["up"===o?y.length-1:0].hash)),!c&&t.lazy(function(){ie(null,i)})},b=function(){e.each(i.children(".elfinder-navbar-wrapper"),function(n,i){var o,r,l=e(i),c=l.children("[id]:first");c.hasClass(y)&&(o=t.navId2Hash(c.attr("id")),o&&void 0!==(r=s[o])&&(a[r].node=l.detach()))})};v()},b={},w=[],x=!0;h--;)a=i[h],m[a.hash]||e("#"+t.navHash2Id(a.hash)).length||(m[a.hash]=!0,(o=G(a.phash)).length?a.phash&&((s=!o.children().length)||o.hasClass("elfinder-navbar-hasmore")||(r=J(o,a)).length)?s?(b[a.phash]||(b[a.phash]=[]),b[a.phash].push(a)):r?(d=V(a),r.before(d),!c&&(f=f.add(d))):w.push(a):(d=V(a),o[x||a.phash?"append":"prepend"](d),x=!1,a.phash&&!a.isroot||(l=e("#"+t.navHash2Id(a.hash)).parent()),!c&&ie(null,l)):u.push(a));return Object.keys(b).length&&e.each(b,function(e,t){var n=G(e);t.sort(Q),v(n,t)}),w.length&&o.trigger("update."+t.namespace,{added:w}),u.length&&u.lengthc?r.animate({scrollTop:r.scrollTop()+d-s-l/3},{duration:n.durations.autoScroll,complete:function(){p.resolve()}}):p.resolve()):p.reject()},100),p},ee=function(n){var i,a,o,r=n||t.cwd(),s=r.hash?[r.hash]:[];for(a=t.root(r.hash),o=t.file(a);o&&(i=o.phash)&&(s.unshift(i),a=t.root(i),o=t.file(a),!e("#"+t.navHash2Id(o.hash)).hasClass(y)););return s},te=function(n){var i=n||t.cwd(),a=i.hash,o=e("#"+t.navHash2Id(a));if(!o.length){for(;i&&i.phash;)$[i.phash]&&!e("#"+t.navHash2Id(i.hash)).length&&$[i.phash].trigger("update."+t.namespace,{select:i.hash}),i=t.file(i.phash);o=e("#"+t.navHash2Id(a))}return o},ne=function(n,i){var a,o,s=t.cwd(),l=s.hash,c=void 0===i?h:i,d=function(n){var i,r,s=e.Deferred(),l=[],d=ee(n),p=function(e,n,i){var a={cmd:e,target:n};return i&&(a.until=i),t.request({data:a,preventFail:!0})};return l=e.map(d,function(n){var a,o,r=t.file(n),s=!!r&&t.isRoot(r),l=e("#"+t.navHash2Id(n)),c=function(e,n){var i,a,o=n||1;return a=!!(i=t.file(e))&&i.phash,a&&o>1?c(a,--o):a},d=function(){var i=c(n);for(a=i;i&&!e("#"+t.navHash2Id(i)).hasClass(y);)a=i,i=c(i);return i||(a=void 0,i=t.root(n)),i}();return l.hasClass(y)||!s&&r&&e("#"+t.navHash2Id(r.phash)).hasClass(y)?null:(s||d===c(n)||d===c(n,2)?(a=void 0,o="tree",s||(n=c(n))):o="parents",i||(i="tree"===o?n:d),p(o,n,a))}),l.length?(te(t.file(i)),r=t.navHash2Id(i),c&&Z(r),a=e("#"+r),o=e(t.res("tpl","navspinner")).insertBefore(a.children("."+x)),a.removeClass(v),e.when.apply(e,l).done(function(){var e,t,n,i={};if(t=arguments.length,t>0)for(n=0;n0}).addClass(i)})},oe=e(this).addClass(i).on("mouseenter mouseleave",g,function(n){var i="mouseenter"===n.type;if(!i||!re){var a=e(this);a.hasClass(C+" "+T)||(c||!i||a.data("dragRegisted")||a.hasClass(d+" "+A+" elfinder-na elfinder-wo")||(a.data("dragRegisted",!0),t.isCommandEnabled("copy",t.navId2Hash(a.attr("id")))&&a.draggable(t.draggable)),a.toggleClass(z,i))}}).on("dragenter",g,function(t){if(t.originalEvent.dataTransfer){var n=e(this);n.addClass(z),n.is("."+v+":not(."+b+")")&&n.data("expandTimer",setTimeout(function(){n.is("."+v+"."+z)&&n.children("."+x).trigger("click")},500))}}).on("dragleave",g,function(t){if(t.originalEvent.dataTransfer){var n=e(this);n.data("expandTimer")&&clearTimeout(n.data("expandTimer")),n.removeClass(z)}}).on("click",g,function(n){var i=e(this),a=t.navId2Hash(i.attr("id"));t.file(a);return i.data("longtap")?(i.removeData("longtap"),void n.stopPropagation()):(i.hasClass(k)||(oe.find(g+"."+k).removeClass(k),i.addClass(k)),void(a==t.cwd().hash||i.hasClass(T)?(i.hasClass(v)&&i.children("."+x).trigger("click"),t.select({selected:[a],origin:"navbar"})):t.exec("open",a).done(function(){t.one("opendone",function(){t.select({selected:[a],origin:"navbar"})})})))}).on("touchstart",g,function(n){if(!(n.originalEvent.touches.length>1)){var i,a=n.originalEvent;return"INPUT"===n.target.nodeName?void n.stopPropagation():void(i=e(this).addClass(z).removeData("longtap").data("tmlongtap",setTimeout(function(e){i.data("longtap",!0),t.trigger("contextmenu",{type:"navbar",targets:[t.navId2Hash(i.attr("id"))],x:a.touches[0].pageX,y:a.touches[0].pageY})},500)))}}).on("touchmove touchend",g,function(t){return"INPUT"===t.target.nodeName?void t.stopPropagation():(clearTimeout(e(this).data("tmlongtap")),void("touchmove"==t.type&&e(this).removeClass(z)))}).on("click",g+"."+v+" ."+x,function(i){var a,o=e(this),r=o.parent(g),s=r.next("."+f),l=e.Deferred(),c=30;i.stopPropagation(),r.hasClass(y)?(r.toggleClass(b),t.lazy(function(){a=r.hasClass(b)?s.children().length+s.find("div.elfinder-navbar-subtree[style*=block]").children().length:s.find("div:visible").length,a>c?(s.toggle(),t.draggingUiHelper&&t.draggingUiHelper.data("refreshPositions",1),P()):s.stop(!0,!0)[r.hasClass(b)?"slideDown":"slideUp"](n.durations.slideUpDown,function(){t.draggingUiHelper&&t.draggingUiHelper.data("refreshPositions",1),P()})}).always(function(){l.resolve()})):(_.insertBefore(o),r.removeClass(v),t.request({cmd:"tree",target:t.navId2Hash(r.attr("id"))}).done(function(e){Y(Object.assign([],X(e.tree))),s.children().length&&(r.addClass(v+" "+b),s.children().length>c?(s.show(),t.draggingUiHelper&&t.draggingUiHelper.data("refreshPositions",1),P()):s.stop(!0,!0).slideDown(n.durations.slideUpDown,function(){t.draggingUiHelper&&t.draggingUiHelper.data("refreshPositions",1),P()}))}).always(function(e){_.remove(),r.addClass(y),t.one("treedone",function(){l.resolve()})})),o.data("dfrd",l)}).on("contextmenu",g,function(n){var i=e(this);return i.find("input:text").length?void n.stopPropagation():(n.preventDefault(),t.trigger("contextmenu",{type:"navbar",targets:[t.navId2Hash(e(this).attr("id"))],x:n.pageX,y:n.pageY}),i.addClass("ui-state-hover"),t.getUI("contextmenu").children().on("mouseenter",function(){i.addClass("ui-state-hover")}),void t.bind("closecontextmenu",function(){i.removeClass("ui-state-hover")}))}).on("scrolltoview",g,function(n,i){var a=e(this);Z(a.attr("id")).done(function(){i&&"undefined"!==i.blink&&!i.blink||t.resources.blink(a,"lookme")})}).on("create."+t.namespace,function(n,i){var a=G(i.phash),o=i.move||!1,r=e(V(i)).addClass("elfinder-navbar-wrapper-tmp"),s=t.selected();o&&s.length&&t.trigger("lockfiles",{files:s}),a.prepend(r)}),re=!1,se=t.getUI("navbar").append(oe).show().on("scroll",function(){re=!0,s&&cancelAnimationFrame(s),s=requestAnimationFrame(function(){re=!1,P()})}),le=t.sortAlsoTreeview;t.open(function(e){var n=e.data,i=X(n.files),a=t.getUI("contextmenu");n.init&&oe.empty(),t.UA.iOS&&se.removeClass("overflow-scrolling-touch").addClass("overflow-scrolling-touch"),i.length?t.lazy(function(){a.data("cmdMaps")||a.data("cmdMaps",{}),Y(i),ae(i,y),ne(i)}):ne()}).add(function(e){var t=X(e.data.added);t.length&&(Y(t),ae(t,v))}).change(function(n){if(!r){var i,a,o,s,l,d,p,u,h,m,v,w,x=X(n.data.changed,!0),k=x.length,C=k;e();for(e.each($,function(e,n){n.trigger("update."+t.namespace,{change:"prepare"})});C--;)if(i=x[C],a=i.phash,(o=e("#"+t.navHash2Id(i.hash))).length){if(v=o.parent(),a){if(l=o.closest("."+f),d=G(a),p=o.parent().next(),u=J(d,i),!d.length)continue;d[0]===l[0]&&p.get(0)===u.get(0)||(u.length?u.before(v):d.append(v))}h=o.hasClass(b),m=o.hasClass(y),s=e(V(i)),o.replaceWith(s.children(g)),!c&&ie(null,v),i.dirs&&(h||m)&&(o=e("#"+t.navHash2Id(i.hash)))&&o.next("."+f).children().length&&(h&&o.addClass(b),m&&o.addClass(y)),w|=i.dirs==-1}w&&P(),e.each($,function(e,n){n.trigger("update."+t.namespace,{change:"done"})}),k&&ne(void 0,!1)}}).remove(function(n){var i,a,o,r=n.data.removed,s=r.length;for(e.each($,function(e,n){n.trigger("update."+t.namespace,{removed:r}),n.trigger("update."+t.namespace,{change:"prepare"})});s--;)(i=e("#"+t.navHash2Id(r[s]))).length&&(o=!0,a=i.closest("."+f),i.parent().detach(),a.children().length||a.hide().prev(g).removeClass(v+" "+b+" "+y));o&&t.getUI("navbar").children(".ui-resizable-handle").trigger("resize"),e.each($,function(e,n){n.trigger("update."+t.namespace,{change:"done"})})}).bind("lockfiles unlockfiles",function(n){var i="lockfiles"==n.type,a=!!n.data.helper&&n.data.helper.data("locked"),o=i&&!a?"disable":"enable",r=e.grep(n.data.files||[],function(e){var n=t.file(e);return!(!n||"directory"!=n.mime)});e.each(r,function(n,r){var s=e("#"+t.navHash2Id(r));s.length&&!a&&(s.hasClass(A)&&s.draggable(o),s.hasClass(I)&&s.droppable(o),s[i?"addClass":"removeClass"](T))})}).bind("sortchange",function(){if(t.sortAlsoTreeview||le!==t.sortAlsoTreeview){var n,i,a=[],o={},r={},s="",l=!1;t.lazy(function(){n=X(t.files()),le=t.sortAlsoTreeview,oe.empty(),Y(e.map(t.roots,function(e){var n=t.file(e);return n&&!n.phash?n:null})),Object.keys($).length?(a=ee(),a.length>1?(e.each(a,function(e,n){var i=t.file(t.root(n)).volumeid;0===e&&(s=i),r[i]=n,o[n]=[]}),e.each(n,function(e,t){return t.volumeid?void o[r[t.volumeid]||r[s]].push(t):(l=!0,!1)})):l=!0,l?e.each(a,function(e,a){Y(n),i=te(t.file(a)),ae(n,y)}):e.each(o,function(e,n){Y(n),i=te(t.file(e)),ae(n,y)})):(Y(n),i=te(),ae(n,y)),ne()},100)}})}),this},e.fn.elfinderuploadbutton=function(t){return this.each(function(){var n,i=t.fm,a=e(this).elfinderbutton(t).off("click"),o=e("").appendTo(a),r=e('').on("change",function(){var t=e(this);t.val()&&(i.exec("upload",{input:t.remove()[0]},void 0,i.cwd().hash),r.clone(!0).appendTo(o))}).on("dragover",function(e){e.originalEvent.dataTransfer.dropEffect="copy"});o.append(r.clone(!0)),t.change(function(){n&&cancelAnimationFrame(n),n=requestAnimationFrame(function(){var e=t.disabled();o.is("visible")?!e&&o.hide():e&&o.show()})}).change()})},e.fn.elfinderviewbutton=function(t){return this.each(function(){var n,i=e(this).elfinderbutton(t),a=i.children(".elfinder-button-icon"),o=i.children(".elfinder-button-text");t.change(function(){n&&cancelAnimationFrame(n),n=requestAnimationFrame(function(){var e="icons"==t.value;a.toggleClass("elfinder-button-icon-view-list",e),t.className=e?"view-list":"",t.title=t.fm.i18n(e?"viewlist":"viewicons"),i.attr("title",t.title),o.html(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(),o=Math.round(i.height()),r=i.parent(),s=function(s){var l=r.height()-a,c=r.attr("style"),d=Math.round(i.height());s&&(s.preventDefault(),s.stopPropagation()),r.css("overflow","hidden").children(":visible:not(."+n+")").each(function(){var t=e(this);"absolute"!=t.css("position")&&"fixed"!=t.css("position")&&(l-=t.outerHeight(!0))}),r.attr("style",c||""),l=Math.max(0,Math.round(l)),o===l&&d===l||(o=Math.round(i.height()),i.height(l),t.trigger("wzresize"))},l=function(){a=i.outerHeight(!0)-i.height(),s()};r.on("resize."+t.namespace,s),t.one("cssloaded",l).bind("uiresize",s)}),this},i.prototype.commands.archive=function(){var t,n=this,i=n.fm,a=[];this.variants=[],this.disableOnSearch=!1,this.nextAction={},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 o,r=this.files(n),s=r.length,l=s&&!i.isRoot(r[0])&&(i.file(r[0].phash)||{}).write&&!e.grep(r,function(e){return!e.read}).length;return l&&i.searchStatus.state>1&&(o=i.cwd().volumeid,l=s===e.grep(r,function(e){return!(!e.read||0!==e.hash.indexOf(o))}).length),l&&!this._disabled&&a.length&&(s||t&&"pending"==t.state())?0:-1},this.exec=function(o,r){var s,l,c=this.files(o),d=c.length,p=r||a[0],u=i.file(c[0].phash)||null,h=["errArchive","errPerm","errCreatingTempDir","errFtpDownloadFile","errFtpUploadFile","errFtpMkdir","errArchiveExec","errExtractExec","errRm"];if(t=e.Deferred().fail(function(e){e&&i.error(e)}),!d||!a.length||e.inArray(p,a)===-1)return t.reject();if(!u.write)return t.reject(h);for(s=0;s1?"Archive":c[0].name)+(i.option("archivers").createext?"."+i.option("archivers").createext[p]:""),n.data={targets:n.hashes(o),type:p},i.cwd().hash!==u.hash?l=i.exec("open",u.hash).done(function(){i.one("cwdrender",function(){i.selectfiles({files:o}),t=e.proxy(i.res("mixin","make"),n)()})}):(i.selectfiles({files:o}),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:'{title}
{dataTable}',itemTitle:'{name}{kind}',groupTitle:"{items}: {num}",dataTable:''+i.perm+':
',fieldset:'