Fix File
•
/
home
/
sportsfe...
/
httpdocs
/
wp-conte...
/
plugins
/
wp-file-...
/
lib
/
js
•
File:
elfinder.full.js
•
Content:
// main part. But anyway, most current (August 2014) browsers can't handle // strings 1 << 28 chars or longer, so: if (str.length * count >= 1 << 28) { throw new RangeError('repeat count must not overflow maximum string size'); } var rpt = ''; for (var i = 0; i < count; i++) { rpt += str; } return rpt; }; } // String.trim if (!String.prototype.trim) { String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); }; } // Array.apply (function () { try { Array.apply(null, {}); return; } catch (e) { } var toString = Object.prototype.toString, arrayType = '[object Array]', _apply = Function.prototype.apply, slice = /*@cc_on @if (@_jscript_version <= 5.8) function () { var a = [], i = this.length; while (i-- > 0) a[i] = this[i]; return a; }@else@*/Array.prototype.slice/*@end@*/; Function.prototype.apply = function apply(thisArg, argArray) { return _apply.call(this, thisArg, toString.call(argArray) === arrayType ? argArray : slice.call(argArray)); }; })(); // Array.from if (!Array.from) { Array.from = function(obj) { return obj.length === 1 ? [obj[0]] : Array.apply(null, obj); }; } // window.requestAnimationFrame and window.cancelAnimationFrame if (!window.cancelAnimationFrame) { // http://paulirish.com/2011/requestanimationframe-for-smart-animating/ // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating // requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel // MIT license (function() { var lastTime = 0; var vendors = ['ms', 'moz', 'webkit', 'o']; for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame']; } if (!window.requestAnimationFrame) window.requestAnimationFrame = function(callback, element) { var currTime = new Date().getTime(); var timeToCall = Math.max(0, 16 - (currTime - lastTime)); var id = window.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall); lastTime = currTime + timeToCall; return id; }; if (!window.cancelAnimationFrame) window.cancelAnimationFrame = function(id) { clearTimeout(id); }; }()); } /* * File: /js/elFinder.version.js */ /** * Application version * * @type String **/ elFinder.prototype.version = '2.1.49'; /* * File: /js/jquery.elfinder.js */ /*** jQuery UI droppable performance tune for elFinder ***/ (function(){ if (jQuery.ui) { if (jQuery.ui.ddmanager) { var origin = jQuery.ui.ddmanager.prepareOffsets; jQuery.ui.ddmanager.prepareOffsets = function( t, event ) { var isOutView = function(elem) { if (elem.is(':hidden')) { return true; } var rect = elem[0].getBoundingClientRect(); return document.elementFromPoint(rect.left, rect.top) || document.elementFromPoint(rect.left + rect.width, rect.top + rect.height)? false : true; }; if (event.type === 'mousedown' || t.options.elfRefresh) { var i, d, m = jQuery.ui.ddmanager.droppables[ t.options.scope ] || [], l = m.length; for ( i = 0; i < l; i++ ) { d = m[ i ]; if (d.options.autoDisable && (!d.options.disabled || d.options.autoDisable > 1)) { d.options.disabled = isOutView(d.element); d.options.autoDisable = d.options.disabled? 2 : 1; } } } // call origin function return origin( t, event ); }; } } })(); /** * * jquery.binarytransport.js * * @description. jQuery ajax transport for making binary data type requests. * @version 1.0 * @author Henry Algus <henryalgus@gmail.com> * */ // use this transport for "binary" data type jQuery.ajaxTransport('+binary', function(options, originalOptions, jqXHR) { // check for conditions and support for blob / arraybuffer response type if (window.FormData && ((options.dataType && (options.dataType == 'binary')) || (options.data && ((window.ArrayBuffer && options.data instanceof ArrayBuffer) || (window.Blob && options.data instanceof Blob))))) { var xhr; return { // create new XMLHttpRequest send: function(headers, callback){ // setup all variables xhr = new XMLHttpRequest(); var url = options.url, type = options.type, async = options.async || true, // blob or arraybuffer. Default is blob dataType = options.responseType || 'blob', data = options.data || null, username = options.username, password = options.password; xhr.addEventListener('load', function(){ var data = {}; data[options.dataType] = xhr.response; // make callback and send data callback(xhr.status, xhr.statusText, data, xhr.getAllResponseHeaders()); }); xhr.open(type, url, async, username, password); // setup custom headers for (var i in headers ) { xhr.setRequestHeader(i, headers[i] ); } // setuo xhrFields if (options.xhrFields) { for (var key in options.xhrFields) { if (key in xhr) { xhr[key] = options.xhrFields[key]; } } } xhr.responseType = dataType; xhr.send(data); }, abort: function(){ xhr.abort(); } }; } }); /*! * jQuery UI Touch Punch 0.2.3 * * Copyright 2011–2014, Dave Furfero * Dual licensed under the MIT or GPL Version 2 licenses. * * Depends: * jquery.ui.widget.js * jquery.ui.mouse.js */ (function ($) { // Detect touch support jQuery.support.touch = 'ontouchend' in document; // Ignore browsers without touch support if (!jQuery.support.touch) { return; } var mouseProto = jQuery.ui.mouse.prototype, _mouseInit = mouseProto._mouseInit, _mouseDestroy = mouseProto._mouseDestroy, touchHandled, posX, posY; /** * Simulate a mouse event based on a corresponding touch event * @param {Object} event A touch event * @param {String} simulatedType The corresponding mouse event */ function simulateMouseEvent (event, simulatedType) { // Ignore multi-touch events if (event.originalEvent.touches.length > 1) { return; } if (! jQuery(event.currentTarget).hasClass('touch-punch-keep-default')) { event.preventDefault(); } var touch = event.originalEvent.changedTouches[0], simulatedEvent = document.createEvent('MouseEvents'); // Initialize the simulated mouse event using the touch event's coordinates simulatedEvent.initMouseEvent( simulatedType, // type true, // bubbles true, // cancelable window, // view 1, // detail touch.screenX, // screenX touch.screenY, // screenY touch.clientX, // clientX touch.clientY, // clientY false, // ctrlKey false, // altKey false, // shiftKey false, // metaKey 0, // button null // relatedTarget ); // Dispatch the simulated event to the target element event.target.dispatchEvent(simulatedEvent); } /** * Handle the jQuery UI widget's touchstart events * @param {Object} event The widget element's touchstart event */ mouseProto._touchStart = function (event) { var self = this; // Ignore the event if another widget is already being handled if (touchHandled || !self._mouseCapture(event.originalEvent.changedTouches[0])) { return; } // Track element position to avoid "false" move posX = event.originalEvent.changedTouches[0].screenX.toFixed(0); posY = event.originalEvent.changedTouches[0].screenY.toFixed(0); // Set the flag to prevent other widgets from inheriting the touch event touchHandled = true; // Track movement to determine if interaction was a click self._touchMoved = false; // Simulate the mouseover event simulateMouseEvent(event, 'mouseover'); // Simulate the mousemove event simulateMouseEvent(event, 'mousemove'); // Simulate the mousedown event simulateMouseEvent(event, 'mousedown'); }; /** * Handle the jQuery UI widget's touchmove events * @param {Object} event The document's touchmove event */ mouseProto._touchMove = function (event) { // Ignore event if not handled if (!touchHandled) { return; } // Ignore if it's a "false" move (position not changed) var x = event.originalEvent.changedTouches[0].screenX.toFixed(0); var y = event.originalEvent.changedTouches[0].screenY.toFixed(0); // Ignore if it's a "false" move (position not changed) if (Math.abs(posX - x) <= 4 && Math.abs(posY - y) <= 4) { return; } // Interaction was not a click this._touchMoved = true; // Simulate the mousemove event simulateMouseEvent(event, 'mousemove'); }; /** * Handle the jQuery UI widget's touchend events * @param {Object} event The document's touchend event */ mouseProto._touchEnd = function (event) { // Ignore event if not handled if (!touchHandled) { return; } // Simulate the mouseup event simulateMouseEvent(event, 'mouseup'); // Simulate the mouseout event simulateMouseEvent(event, 'mouseout'); // If the touch interaction did not move, it should trigger a click if (!this._touchMoved) { // Simulate the click event simulateMouseEvent(event, 'click'); } // Unset the flag to allow other widgets to inherit the touch event touchHandled = false; this._touchMoved = false; }; /** * A duck punch of the jQuery.ui.mouse _mouseInit method to support touch events. * This method extends the widget with bound touch event handlers that * translate touch events to mouse events and pass them to the widget's * original mouse event handling methods. */ mouseProto._mouseInit = function () { var self = this; if (self.element.hasClass('touch-punch')) { // Delegate the touch handlers to the widget's element self.element.on({ touchstart: jQuery.proxy(self, '_touchStart'), touchmove: jQuery.proxy(self, '_touchMove'), touchend: jQuery.proxy(self, '_touchEnd') }); } // Call the original jQuery.ui.mouse init method _mouseInit.call(self); }; /** * Remove the touch event handlers */ mouseProto._mouseDestroy = function () { var self = this; if (self.element.hasClass('touch-punch')) { // Delegate the touch handlers to the widget's element self.element.off({ touchstart: jQuery.proxy(self, '_touchStart'), touchmove: jQuery.proxy(self, '_touchMove'), touchend: jQuery.proxy(self, '_touchEnd') }); } // Call the original jQuery.ui.mouse destroy method _mouseDestroy.call(self); }; })(jQuery); jQuery.fn.elfinder = function(o, o2) { if (o === 'instance') { return this.getElFinder(); } return this.each(function() { var cmd = typeof o === 'string' ? o : '', bootCallback = typeof o2 === 'function'? o2 : void(0), opts; if (!this.elfinder) { if (jQuery.isPlainObject(o)) { new elFinder(this, o, bootCallback); } } else { switch(cmd) { case 'close': case 'hide': this.elfinder.hide(); break; case 'open': case 'show': this.elfinder.show(); break; case 'destroy': this.elfinder.destroy(); break; case 'reload': case 'restart': if (this.elfinder) { opts = this.elfinder.options; bootCallback = this.elfinder.bootCallback; this.elfinder.destroy(); new elFinder(this, jQuery.extend(true, opts, jQuery.isPlainObject(o2)? o2 : {}), bootCallback); } break; } } }); }; jQuery.fn.getElFinder = function() { var instance; this.each(function() { if (this.elfinder) { instance = this.elfinder; return false; } }); return instance; }; jQuery.fn.elfUiWidgetInstance = function(name) { try { return this[name]('instance'); } catch(e) { // fallback for jQuery UI < 1.11 var data = this.data('ui-' + name); if (data && typeof data === 'object' && data.widgetFullName === 'ui-' + name) { return data; } return null; } }; // function scrollRight if (! jQuery.fn.scrollRight) { jQuery.fn.extend({ scrollRight: function (val) { var node = this.get(0); if (val === undefined) { return Math.max(0, node.scrollWidth - (node.scrollLeft + node.clientWidth)); } return this.scrollLeft(node.scrollWidth - node.clientWidth - val); } }); } // function scrollBottom if (! jQuery.fn.scrollBottom) { jQuery.fn.extend({ scrollBottom: function(val) { var node = this.get(0); if (val === undefined) { return Math.max(0, node.scrollHeight - (node.scrollTop + node.clientHeight)); } return this.scrollTop(node.scrollHeight - node.clientHeight - val); } }); } /* * File: /js/elFinder.mimetypes.js */ elFinder.prototype.mimeTypes = {"application\/x-executable":"exe","application\/x-jar":"jar","application\/x-gzip":"gz","application\/x-bzip2":"tbz","application\/x-rar":"rar","text\/x-php":"php","text\/javascript":"js","application\/rtfd":"rtfd","text\/x-python":"py","text\/x-ruby":"rb","text\/x-shellscript":"sh","text\/x-perl":"pl","text\/xml":"xml","text\/x-csrc":"c","text\/x-chdr":"h","text\/x-c++src":"cpp","text\/x-c++hdr":"hh","text\/x-markdown":"md","text\/x-yaml":"yml","image\/x-ms-bmp":"bmp","image\/x-targa":"tga","image\/xbm":"xbm","image\/pxm":"pxm","audio\/wav":"wav","video\/x-dv":"dv","video\/x-ms-wmv":"wm","video\/ogg":"ogm","video\/MP2T":"m2ts","application\/x-mpegURL":"m3u8","application\/dash+xml":"mpd","application\/andrew-inset":"ez","application\/applixware":"aw","application\/atom+xml":"atom","application\/atomcat+xml":"atomcat","application\/atomsvc+xml":"atomsvc","application\/ccxml+xml":"ccxml","application\/cdmi-capability":"cdmia","application\/cdmi-container":"cdmic","application\/cdmi-domain":"cdmid","application\/cdmi-object":"cdmio","application\/cdmi-queue":"cdmiq","application\/cu-seeme":"cu","application\/davmount+xml":"davmount","application\/docbook+xml":"dbk","application\/dssc+der":"dssc","application\/dssc+xml":"xdssc","application\/ecmascript":"ecma","application\/emma+xml":"emma","application\/epub+zip":"epub","application\/exi":"exi","application\/font-tdpfr":"pfr","application\/gml+xml":"gml","application\/gpx+xml":"gpx","application\/gxf":"gxf","application\/hyperstudio":"stk","application\/inkml+xml":"ink","application\/ipfix":"ipfix","application\/java-serialized-object":"ser","application\/java-vm":"class","application\/json":"json","application\/jsonml+json":"jsonml","application\/lost+xml":"lostxml","application\/mac-binhex40":"hqx","application\/mac-compactpro":"cpt","application\/mads+xml":"mads","application\/marc":"mrc","application\/marcxml+xml":"mrcx","application\/mathematica":"ma","application\/mathml+xml":"mathml","application\/mbox":"mbox","application\/mediaservercontrol+xml":"mscml","application\/metalink+xml":"metalink","application\/metalink4+xml":"meta4","application\/mets+xml":"mets","application\/mods+xml":"mods","application\/mp21":"m21","application\/mp4":"mp4s","application\/msword":"doc","application\/mxf":"mxf","application\/octet-stream":"bin","application\/oda":"oda","application\/oebps-package+xml":"opf","application\/ogg":"ogx","application\/omdoc+xml":"omdoc","application\/onenote":"onetoc","application\/oxps":"oxps","application\/patch-ops-error+xml":"xer","application\/pdf":"pdf","application\/pgp-encrypted":"pgp","application\/pgp-signature":"asc","application\/pics-rules":"prf","application\/pkcs10":"p10","application\/pkcs7-mime":"p7m","application\/pkcs7-signature":"p7s","application\/pkcs8":"p8","application\/pkix-attr-cert":"ac","application\/pkix-cert":"cer","application\/pkix-crl":"crl","application\/pkix-pkipath":"pkipath","application\/pkixcmp":"pki","application\/pls+xml":"pls","application\/postscript":"ai","application\/prs.cww":"cww","application\/pskc+xml":"pskcxml","application\/rdf+xml":"rdf","application\/reginfo+xml":"rif","application\/relax-ng-compact-syntax":"rnc","application\/resource-lists+xml":"rl","application\/resource-lists-diff+xml":"rld","application\/rls-services+xml":"rs","application\/rpki-ghostbusters":"gbr","application\/rpki-manifest":"mft","application\/rpki-roa":"roa","application\/rsd+xml":"rsd","application\/rss+xml":"rss","application\/rtf":"rtf","application\/sbml+xml":"sbml","application\/scvp-cv-request":"scq","application\/scvp-cv-response":"scs","application\/scvp-vp-request":"spq","application\/scvp-vp-response":"spp","application\/sdp":"sdp","application\/set-payment-initiation":"setpay","application\/set-registration-initiation":"setreg","application\/shf+xml":"shf","application\/smil+xml":"smi","application\/sparql-query":"rq","application\/sparql-results+xml":"srx","application\/srgs":"gram","application\/srgs+xml":"grxml","application\/sru+xml":"sru","application\/ssdl+xml":"ssdl","application\/ssml+xml":"ssml","application\/tei+xml":"tei","application\/thraud+xml":"tfi","application\/timestamped-data":"tsd","application\/vnd.3gpp.pic-bw-large":"plb","application\/vnd.3gpp.pic-bw-small":"psb","application\/vnd.3gpp.pic-bw-var":"pvb","application\/vnd.3gpp2.tcap":"tcap","application\/vnd.3m.post-it-notes":"pwn","application\/vnd.accpac.simply.aso":"aso","application\/vnd.accpac.simply.imp":"imp","application\/vnd.acucobol":"acu","application\/vnd.acucorp":"atc","application\/vnd.adobe.air-application-installer-package+zip":"air","application\/vnd.adobe.formscentral.fcdt":"fcdt","application\/vnd.adobe.fxp":"fxp","application\/vnd.adobe.xdp+xml":"xdp","application\/vnd.adobe.xfdf":"xfdf","application\/vnd.ahead.space":"ahead","application\/vnd.airzip.filesecure.azf":"azf","application\/vnd.airzip.filesecure.azs":"azs","application\/vnd.amazon.ebook":"azw","application\/vnd.americandynamics.acc":"acc","application\/vnd.amiga.ami":"ami","application\/vnd.android.package-archive":"apk","application\/vnd.anser-web-certificate-issue-initiation":"cii","application\/vnd.anser-web-funds-transfer-initiation":"fti","application\/vnd.antix.game-component":"atx","application\/vnd.apple.installer+xml":"mpkg","application\/vnd.aristanetworks.swi":"swi","application\/vnd.astraea-software.iota":"iota","application\/vnd.audiograph":"aep","application\/vnd.blueice.multipass":"mpm","application\/vnd.bmi":"bmi","application\/vnd.businessobjects":"rep","application\/vnd.chemdraw+xml":"cdxml","application\/vnd.chipnuts.karaoke-mmd":"mmd","application\/vnd.cinderella":"cdy","application\/vnd.claymore":"cla","application\/vnd.cloanto.rp9":"rp9","application\/vnd.clonk.c4group":"c4g","application\/vnd.cluetrust.cartomobile-config":"c11amc","application\/vnd.cluetrust.cartomobile-config-pkg":"c11amz","application\/vnd.commonspace":"csp","application\/vnd.contact.cmsg":"cdbcmsg","application\/vnd.cosmocaller":"cmc","application\/vnd.crick.clicker":"clkx","application\/vnd.crick.clicker.keyboard":"clkk","application\/vnd.crick.clicker.palette":"clkp","application\/vnd.crick.clicker.template":"clkt","application\/vnd.crick.clicker.wordbank":"clkw","application\/vnd.criticaltools.wbs+xml":"wbs","application\/vnd.ctc-posml":"pml","application\/vnd.cups-ppd":"ppd","application\/vnd.curl.car":"car","application\/vnd.curl.pcurl":"pcurl","application\/vnd.dart":"dart","application\/vnd.data-vision.rdz":"rdz","application\/vnd.dece.data":"uvf","application\/vnd.dece.ttml+xml":"uvt","application\/vnd.dece.unspecified":"uvx","application\/vnd.dece.zip":"uvz","application\/vnd.denovo.fcselayout-link":"fe_launch","application\/vnd.dna":"dna","application\/vnd.dolby.mlp":"mlp","application\/vnd.dpgraph":"dpg","application\/vnd.dreamfactory":"dfac","application\/vnd.ds-keypoint":"kpxx","application\/vnd.dvb.ait":"ait","application\/vnd.dvb.service":"svc","application\/vnd.dynageo":"geo","application\/vnd.ecowin.chart":"mag","application\/vnd.enliven":"nml","application\/vnd.epson.esf":"esf","application\/vnd.epson.msf":"msf","application\/vnd.epson.quickanime":"qam","application\/vnd.epson.salt":"slt","application\/vnd.epson.ssf":"ssf","application\/vnd.eszigno3+xml":"es3","application\/vnd.ezpix-album":"ez2","application\/vnd.ezpix-package":"ez3","application\/vnd.fdf":"fdf","application\/vnd.fdsn.mseed":"mseed","application\/vnd.fdsn.seed":"seed","application\/vnd.flographit":"gph","application\/vnd.fluxtime.clip":"ftc","application\/vnd.framemaker":"fm","application\/vnd.frogans.fnc":"fnc","application\/vnd.frogans.ltf":"ltf","application\/vnd.fsc.weblaunch":"fsc","application\/vnd.fujitsu.oasys":"oas","application\/vnd.fujitsu.oasys2":"oa2","application\/vnd.fujitsu.oasys3":"oa3","application\/vnd.fujitsu.oasysgp":"fg5","application\/vnd.fujitsu.oasysprs":"bh2","application\/vnd.fujixerox.ddd":"ddd","application\/vnd.fujixerox.docuworks":"xdw","application\/vnd.fujixerox.docuworks.binder":"xbd","application\/vnd.fuzzysheet":"fzs","application\/vnd.genomatix.tuxedo":"txd","application\/vnd.geogebra.file":"ggb","application\/vnd.geogebra.tool":"ggt","application\/vnd.geometry-explorer":"gex","application\/vnd.geonext":"gxt","application\/vnd.geoplan":"g2w","application\/vnd.geospace":"g3w","application\/vnd.gmx":"gmx","application\/vnd.google-earth.kml+xml":"kml","application\/vnd.google-earth.kmz":"kmz","application\/vnd.grafeq":"gqf","application\/vnd.groove-account":"gac","application\/vnd.groove-help":"ghf","application\/vnd.groove-identity-message":"gim","application\/vnd.groove-injector":"grv","application\/vnd.groove-tool-message":"gtm","application\/vnd.groove-tool-template":"tpl","application\/vnd.groove-vcard":"vcg","application\/vnd.hal+xml":"hal","application\/vnd.handheld-entertainment+xml":"zmm","application\/vnd.hbci":"hbci","application\/vnd.hhe.lesson-player":"les","application\/vnd.hp-hpgl":"hpgl","application\/vnd.hp-hpid":"hpid","application\/vnd.hp-hps":"hps","application\/vnd.hp-jlyt":"jlt","application\/vnd.hp-pcl":"pcl","application\/vnd.hp-pclxl":"pclxl","application\/vnd.hydrostatix.sof-data":"sfd-hdstx","application\/vnd.ibm.minipay":"mpy","application\/vnd.ibm.modcap":"afp","application\/vnd.ibm.rights-management":"irm","application\/vnd.ibm.secure-container":"sc","application\/vnd.iccprofile":"icc","application\/vnd.igloader":"igl","application\/vnd.immervision-ivp":"ivp","application\/vnd.immervision-ivu":"ivu","application\/vnd.insors.igm":"igm","application\/vnd.intercon.formnet":"xpw","application\/vnd.intergeo":"i2g","application\/vnd.intu.qbo":"qbo","application\/vnd.intu.qfx":"qfx","application\/vnd.ipunplugged.rcprofile":"rcprofile","application\/vnd.irepository.package+xml":"irp","application\/vnd.is-xpr":"xpr","application\/vnd.isac.fcs":"fcs","application\/vnd.jam":"jam","application\/vnd.jcp.javame.midlet-rms":"rms","application\/vnd.jisp":"jisp","application\/vnd.joost.joda-archive":"joda","application\/vnd.kahootz":"ktz","application\/vnd.kde.karbon":"karbon","application\/vnd.kde.kchart":"chrt","application\/vnd.kde.kformula":"kfo","application\/vnd.kde.kivio":"flw","application\/vnd.kde.kontour":"kon","application\/vnd.kde.kpresenter":"kpr","application\/vnd.kde.kspread":"ksp","application\/vnd.kde.kword":"kwd","application\/vnd.kenameaapp":"htke","application\/vnd.kidspiration":"kia","application\/vnd.kinar":"kne","application\/vnd.koan":"skp","application\/vnd.kodak-descriptor":"sse","application\/vnd.las.las+xml":"lasxml","application\/vnd.llamagraphics.life-balance.desktop":"lbd","application\/vnd.llamagraphics.life-balance.exchange+xml":"lbe","application\/vnd.lotus-1-2-3":123,"application\/vnd.lotus-approach":"apr","application\/vnd.lotus-freelance":"pre","application\/vnd.lotus-notes":"nsf","application\/vnd.lotus-organizer":"org","application\/vnd.lotus-screencam":"scm","application\/vnd.lotus-wordpro":"lwp","application\/vnd.macports.portpkg":"portpkg","application\/vnd.mcd":"mcd","application\/vnd.medcalcdata":"mc1","application\/vnd.mediastation.cdkey":"cdkey","application\/vnd.mfer":"mwf","application\/vnd.mfmp":"mfm","application\/vnd.micrografx.flo":"flo","application\/vnd.micrografx.igx":"igx","application\/vnd.mif":"mif","application\/vnd.mobius.daf":"daf","application\/vnd.mobius.dis":"dis","application\/vnd.mobius.mbk":"mbk","application\/vnd.mobius.mqy":"mqy","application\/vnd.mobius.msl":"msl","application\/vnd.mobius.plc":"plc","application\/vnd.mobius.txf":"txf","application\/vnd.mophun.application":"mpn","application\/vnd.mophun.certificate":"mpc","application\/vnd.mozilla.xul+xml":"xul","application\/vnd.ms-artgalry":"cil","application\/vnd.ms-cab-compressed":"cab","application\/vnd.ms-excel":"xls","application\/vnd.ms-excel.addin.macroenabled.12":"xlam","application\/vnd.ms-excel.sheet.binary.macroenabled.12":"xlsb","application\/vnd.ms-excel.sheet.macroenabled.12":"xlsm","application\/vnd.ms-excel.template.macroenabled.12":"xltm","application\/vnd.ms-fontobject":"eot","application\/vnd.ms-htmlhelp":"chm","application\/vnd.ms-ims":"ims","application\/vnd.ms-lrm":"lrm","application\/vnd.ms-officetheme":"thmx","application\/vnd.ms-pki.seccat":"cat","application\/vnd.ms-pki.stl":"stl","application\/vnd.ms-powerpoint":"ppt","application\/vnd.ms-powerpoint.addin.macroenabled.12":"ppam","application\/vnd.ms-powerpoint.presentation.macroenabled.12":"pptm","application\/vnd.ms-powerpoint.slide.macroenabled.12":"sldm","application\/vnd.ms-powerpoint.slideshow.macroenabled.12":"ppsm","application\/vnd.ms-powerpoint.template.macroenabled.12":"potm","application\/vnd.ms-project":"mpp","application\/vnd.ms-word.document.macroenabled.12":"docm","application\/vnd.ms-word.template.macroenabled.12":"dotm","application\/vnd.ms-works":"wps","application\/vnd.ms-wpl":"wpl","application\/vnd.ms-xpsdocument":"xps","application\/vnd.mseq":"mseq","application\/vnd.musician":"mus","application\/vnd.muvee.style":"msty","application\/vnd.mynfc":"taglet","application\/vnd.neurolanguage.nlu":"nlu","application\/vnd.nitf":"ntf","application\/vnd.noblenet-directory":"nnd","application\/vnd.noblenet-sealer":"nns","application\/vnd.noblenet-web":"nnw","application\/vnd.nokia.n-gage.data":"ngdat","application\/vnd.nokia.n-gage.symbian.install":"n-gage","application\/vnd.nokia.radio-preset":"rpst","application\/vnd.nokia.radio-presets":"rpss","application\/vnd.novadigm.edm":"edm","application\/vnd.novadigm.edx":"edx","application\/vnd.novadigm.ext":"ext","application\/vnd.oasis.opendocument.chart":"odc","application\/vnd.oasis.opendocument.chart-template":"otc","application\/vnd.oasis.opendocument.database":"odb","application\/vnd.oasis.opendocument.formula":"odf","application\/vnd.oasis.opendocument.formula-template":"odft","application\/vnd.oasis.opendocument.graphics":"odg","application\/vnd.oasis.opendocument.graphics-template":"otg","application\/vnd.oasis.opendocument.image":"odi","application\/vnd.oasis.opendocument.image-template":"oti","application\/vnd.oasis.opendocument.presentation":"odp","application\/vnd.oasis.opendocument.presentation-template":"otp","application\/vnd.oasis.opendocument.spreadsheet":"ods","application\/vnd.oasis.opendocument.spreadsheet-template":"ots","application\/vnd.oasis.opendocument.text":"odt","application\/vnd.oasis.opendocument.text-master":"odm","application\/vnd.oasis.opendocument.text-template":"ott","application\/vnd.oasis.opendocument.text-web":"oth","application\/vnd.olpc-sugar":"xo","application\/vnd.oma.dd2+xml":"dd2","application\/vnd.openofficeorg.extension":"oxt","application\/vnd.openxmlformats-officedocument.presentationml.presentation":"pptx","application\/vnd.openxmlformats-officedocument.presentationml.slide":"sldx","application\/vnd.openxmlformats-officedocument.presentationml.slideshow":"ppsx","application\/vnd.openxmlformats-officedocument.presentationml.template":"potx","application\/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"xlsx","application\/vnd.openxmlformats-officedocument.spreadsheetml.template":"xltx","application\/vnd.openxmlformats-officedocument.wordprocessingml.document":"docx","application\/vnd.openxmlformats-officedocument.wordprocessingml.template":"dotx","application\/vnd.osgeo.mapguide.package":"mgp","application\/vnd.osgi.dp":"dp","application\/vnd.osgi.subsystem":"esa","application\/vnd.palm":"pdb","application\/vnd.pawaafile":"paw","application\/vnd.pg.format":"str","application\/vnd.pg.osasli":"ei6","application\/vnd.picsel":"efif","application\/vnd.pmi.widget":"wg","application\/vnd.pocketlearn":"plf","application\/vnd.powerbuilder6":"pbd","application\/vnd.previewsystems.box":"box","application\/vnd.proteus.magazine":"mgz","application\/vnd.publishare-delta-tree":"qps","application\/vnd.pvi.ptid1":"ptid","application\/vnd.quark.quarkxpress":"qxd","application\/vnd.realvnc.bed":"bed","application\/vnd.recordare.musicxml":"mxl","application\/vnd.recordare.musicxml+xml":"musicxml","application\/vnd.rig.cryptonote":"cryptonote","application\/vnd.rim.cod":"cod","application\/vnd.rn-realmedia":"rm","application\/vnd.rn-realmedia-vbr":"rmvb","application\/vnd.route66.link66+xml":"link66","application\/vnd.sailingtracker.track":"st","application\/vnd.seemail":"see","application\/vnd.sema":"sema","application\/vnd.semd":"semd","application\/vnd.semf":"semf","application\/vnd.shana.informed.formdata":"ifm","application\/vnd.shana.informed.formtemplate":"itp","application\/vnd.shana.informed.interchange":"iif","application\/vnd.shana.informed.package":"ipk","application\/vnd.simtech-mindmapper":"twd","application\/vnd.smaf":"mmf","application\/vnd.smart.teacher":"teacher","application\/vnd.solent.sdkm+xml":"sdkm","application\/vnd.spotfire.dxp":"dxp","application\/vnd.spotfire.sfs":"sfs","application\/vnd.stardivision.calc":"sdc","application\/vnd.stardivision.draw":"sda","application\/vnd.stardivision.impress":"sdd","application\/vnd.stardivision.math":"smf","application\/vnd.stardivision.writer":"sdw","application\/vnd.stardivision.writer-global":"sgl","application\/vnd.stepmania.package":"smzip","application\/vnd.stepmania.stepchart":"sm","application\/vnd.sun.xml.calc":"sxc","application\/vnd.sun.xml.calc.template":"stc","application\/vnd.sun.xml.draw":"sxd","application\/vnd.sun.xml.draw.template":"std","application\/vnd.sun.xml.impress":"sxi","application\/vnd.sun.xml.impress.template":"sti","application\/vnd.sun.xml.math":"sxm","application\/vnd.sun.xml.writer":"sxw","application\/vnd.sun.xml.writer.global":"sxg","application\/vnd.sun.xml.writer.template":"stw","application\/vnd.sus-calendar":"sus","application\/vnd.svd":"svd","application\/vnd.symbian.install":"sis","application\/vnd.syncml+xml":"xsm","application\/vnd.syncml.dm+wbxml":"bdm","application\/vnd.syncml.dm+xml":"xdm","application\/vnd.tao.intent-module-archive":"tao","application\/vnd.tcpdump.pcap":"pcap","application\/vnd.tmobile-livetv":"tmo","application\/vnd.trid.tpt":"tpt","application\/vnd.triscape.mxs":"mxs","application\/vnd.trueapp":"tra","application\/vnd.ufdl":"ufd","application\/vnd.uiq.theme":"utz","application\/vnd.umajin":"umj","application\/vnd.unity":"unityweb","application\/vnd.uoml+xml":"uoml","application\/vnd.vcx":"vcx","application\/vnd.visio":"vsd","application\/vnd.visionary":"vis","application\/vnd.vsf":"vsf","application\/vnd.wap.wbxml":"wbxml","application\/vnd.wap.wmlc":"wmlc","application\/vnd.wap.wmlscriptc":"wmlsc","application\/vnd.webturbo":"wtb","application\/vnd.wolfram.player":"nbp","application\/vnd.wordperfect":"wpd","application\/vnd.wqd":"wqd","application\/vnd.wt.stf":"stf","application\/vnd.xara":"xar","application\/vnd.xfdl":"xfdl","application\/vnd.yamaha.hv-dic":"hvd","application\/vnd.yamaha.hv-script":"hvs","application\/vnd.yamaha.hv-voice":"hvp","application\/vnd.yamaha.openscoreformat":"osf","application\/vnd.yamaha.openscoreformat.osfpvg+xml":"osfpvg","application\/vnd.yamaha.smaf-audio":"saf","application\/vnd.yamaha.smaf-phrase":"spf","application\/vnd.yellowriver-custom-menu":"cmp","application\/vnd.zul":"zir","application\/vnd.zzazz.deck+xml":"zaz","application\/voicexml+xml":"vxml","application\/widget":"wgt","application\/winhlp":"hlp","application\/wsdl+xml":"wsdl","application\/wspolicy+xml":"wspolicy","application\/x-7z-compressed":"7z","application\/x-abiword":"abw","application\/x-ace-compressed":"ace","application\/x-apple-diskimage":"dmg","application\/x-authorware-bin":"aab","application\/x-authorware-map":"aam","application\/x-authorware-seg":"aas","application\/x-bcpio":"bcpio","application\/x-bittorrent":"torrent","application\/x-blorb":"blb","application\/x-bzip":"bz","application\/x-cbr":"cbr","application\/x-cdlink":"vcd","application\/x-cfs-compressed":"cfs","application\/x-chat":"chat","application\/x-chess-pgn":"pgn","application\/x-conference":"nsc","application\/x-cpio":"cpio","application\/x-csh":"csh","application\/x-debian-package":"deb","application\/x-dgc-compressed":"dgc","application\/x-director":"dir","application\/x-doom":"wad","application\/x-dtbncx+xml":"ncx","application\/x-dtbook+xml":"dtb","application\/x-dtbresource+xml":"res","application\/x-dvi":"dvi","application\/x-envoy":"evy","application\/x-eva":"eva","application\/x-font-bdf":"bdf","application\/x-font-ghostscript":"gsf","application\/x-font-linux-psf":"psf","application\/x-font-pcf":"pcf","application\/x-font-snf":"snf","application\/x-font-type1":"pfa","application\/x-freearc":"arc","application\/x-futuresplash":"spl","application\/x-gca-compressed":"gca","application\/x-glulx":"ulx","application\/x-gnumeric":"gnumeric","application\/x-gramps-xml":"gramps","application\/x-gtar":"gtar","application\/x-hdf":"hdf","application\/x-install-instructions":"install","application\/x-iso9660-image":"iso","application\/x-java-jnlp-file":"jnlp","application\/x-latex":"latex","application\/x-lzh-compressed":"lzh","application\/x-mie":"mie","application\/x-mobipocket-ebook":"prc","application\/x-ms-application":"application","application\/x-ms-shortcut":"lnk","application\/x-ms-wmd":"wmd","application\/x-ms-wmz":"wmz","application\/x-ms-xbap":"xbap","application\/x-msaccess":"mdb","application\/x-msbinder":"obd","application\/x-mscardfile":"crd","application\/x-msclip":"clp","application\/x-msdownload":"dll","application\/x-msmediaview":"mvb","application\/x-msmetafile":"wmf","application\/x-msmoney":"mny","application\/x-mspublisher":"pub","application\/x-msschedule":"scd","application\/x-msterminal":"trm","application\/x-mswrite":"wri","application\/x-netcdf":"nc","application\/x-nzb":"nzb","application\/x-pkcs12":"p12","application\/x-pkcs7-certificates":"p7b","application\/x-pkcs7-certreqresp":"p7r","application\/x-research-info-systems":"ris","application\/x-shar":"shar","application\/x-shockwave-flash":"swf","application\/x-silverlight-app":"xap","application\/x-sql":"sql","application\/x-stuffit":"sit","application\/x-stuffitx":"sitx","application\/x-subrip":"srt","application\/x-sv4cpio":"sv4cpio","application\/x-sv4crc":"sv4crc","application\/x-t3vm-image":"t3","application\/x-tads":"gam","application\/x-tar":"tar","application\/x-tcl":"tcl","application\/x-tex":"tex","application\/x-tex-tfm":"tfm","application\/x-texinfo":"texinfo","application\/x-tgif":"obj","application\/x-ustar":"ustar","application\/x-wais-source":"src","application\/x-x509-ca-cert":"der","application\/x-xfig":"fig","application\/x-xliff+xml":"xlf","application\/x-xpinstall":"xpi","application\/x-xz":"xz","application\/x-zmachine":"z1","application\/xaml+xml":"xaml","application\/xcap-diff+xml":"xdf","application\/xenc+xml":"xenc","application\/xhtml+xml":"xhtml","application\/xml":"xsl","application\/xml-dtd":"dtd","application\/xop+xml":"xop","application\/xproc+xml":"xpl","application\/xslt+xml":"xslt","application\/xspf+xml":"xspf","application\/xv+xml":"mxml","application\/yang":"yang","application\/yin+xml":"yin","application\/zip":"zip","audio\/adpcm":"adp","audio\/basic":"au","audio\/midi":"mid","audio\/mp4":"m4a","audio\/mpeg":"mpga","audio\/ogg":"oga","audio\/s3m":"s3m","audio\/silk":"sil","audio\/vnd.dece.audio":"uva","audio\/vnd.digital-winds":"eol","audio\/vnd.dra":"dra","audio\/vnd.dts":"dts","audio\/vnd.dts.hd":"dtshd","audio\/vnd.lucent.voice":"lvp","audio\/vnd.ms-playready.media.pya":"pya","audio\/vnd.nuera.ecelp4800":"ecelp4800","audio\/vnd.nuera.ecelp7470":"ecelp7470","audio\/vnd.nuera.ecelp9600":"ecelp9600","audio\/vnd.rip":"rip","audio\/webm":"weba","audio\/x-aac":"aac","audio\/x-aiff":"aif","audio\/x-caf":"caf","audio\/x-flac":"flac","audio\/x-matroska":"mka","audio\/x-mpegurl":"m3u","audio\/x-ms-wax":"wax","audio\/x-ms-wma":"wma","audio\/x-pn-realaudio":"ram","audio\/x-pn-realaudio-plugin":"rmp","audio\/xm":"xm","chemical\/x-cdx":"cdx","chemical\/x-cif":"cif","chemical\/x-cmdf":"cmdf","chemical\/x-cml":"cml","chemical\/x-csml":"csml","chemical\/x-xyz":"xyz","font\/collection":"ttc","font\/otf":"otf","font\/ttf":"ttf","font\/woff":"woff","font\/woff2":"woff2","image\/cgm":"cgm","image\/g3fax":"g3","image\/gif":"gif","image\/ief":"ief","image\/jpeg":"jpeg","image\/ktx":"ktx","image\/png":"png","image\/prs.btif":"btif","image\/sgi":"sgi","image\/svg+xml":"svg","image\/tiff":"tiff","image\/vnd.adobe.photoshop":"psd","image\/vnd.dece.graphic":"uvi","image\/vnd.djvu":"djvu","image\/vnd.dvb.subtitle":"sub","image\/vnd.dwg":"dwg","image\/vnd.dxf":"dxf","image\/vnd.fastbidsheet":"fbs","image\/vnd.fpx":"fpx","image\/vnd.fst":"fst","image\/vnd.fujixerox.edmics-mmr":"mmr","image\/vnd.fujixerox.edmics-rlc":"rlc","image\/vnd.ms-modi":"mdi","image\/vnd.ms-photo":"wdp","image\/vnd.net-fpx":"npx","image\/vnd.wap.wbmp":"wbmp","image\/vnd.xiff":"xif","image\/webp":"webp","image\/x-3ds":"3ds","image\/x-cmu-raster":"ras","image\/x-cmx":"cmx","image\/x-freehand":"fh","image\/x-icon":"ico","image\/x-mrsid-image":"sid","image\/x-pcx":"pcx","image\/x-pict":"pic","image\/x-portable-anymap":"pnm","image\/x-portable-bitmap":"pbm","image\/x-portable-graymap":"pgm","image\/x-portable-pixmap":"ppm","image\/x-rgb":"rgb","image\/x-xpixmap":"xpm","image\/x-xwindowdump":"xwd","message\/rfc822":"eml","model\/iges":"igs","model\/mesh":"msh","model\/vnd.collada+xml":"dae","model\/vnd.dwf":"dwf","model\/vnd.gdl":"gdl","model\/vnd.gtw":"gtw","model\/vnd.vtu":"vtu","model\/vrml":"wrl","model\/x3d+binary":"x3db","model\/x3d+vrml":"x3dv","model\/x3d+xml":"x3d","text\/cache-manifest":"appcache","text\/calendar":"ics","text\/css":"css","text\/csv":"csv","text\/html":"html","text\/n3":"n3","text\/plain":"txt","text\/prs.lines.tag":"dsc","text\/richtext":"rtx","text\/sgml":"sgml","text\/tab-separated-values":"tsv","text\/troff":"t","text\/turtle":"ttl","text\/uri-list":"uri","text\/vcard":"vcard","text\/vnd.curl":"curl","text\/vnd.curl.dcurl":"dcurl","text\/vnd.curl.mcurl":"mcurl","text\/vnd.curl.scurl":"scurl","text\/vnd.fly":"fly","text\/vnd.fmi.flexstor":"flx","text\/vnd.graphviz":"gv","text\/vnd.in3d.3dml":"3dml","text\/vnd.in3d.spot":"spot","text\/vnd.sun.j2me.app-descriptor":"jad","text\/vnd.wap.wml":"wml","text\/vnd.wap.wmlscript":"wmls","text\/x-asm":"s","text\/x-c":"cc","text\/x-fortran":"f","text\/x-java-source":"java","text\/x-nfo":"nfo","text\/x-opml":"opml","text\/x-pascal":"p","text\/x-setext":"etx","text\/x-sfv":"sfv","text\/x-uuencode":"uu","text\/x-vcalendar":"vcs","text\/x-vcard":"vcf","video\/3gpp":"3gp","video\/3gpp2":"3g2","video\/h261":"h261","video\/h263":"h263","video\/h264":"h264","video\/jpeg":"jpgv","video\/jpm":"jpm","video\/mj2":"mj2","video\/mp4":"mp4","video\/mpeg":"mpeg","video\/quicktime":"qt","video\/vnd.dece.hd":"uvh","video\/vnd.dece.mobile":"uvm","video\/vnd.dece.pd":"uvp","video\/vnd.dece.sd":"uvs","video\/vnd.dece.video":"uvv","video\/vnd.dvb.file":"dvb","video\/vnd.fvt":"fvt","video\/vnd.mpegurl":"mxu","video\/vnd.ms-playready.media.pyv":"pyv","video\/vnd.uvvu.mp4":"uvu","video\/vnd.vivo":"viv","video\/webm":"webm","video\/x-f4v":"f4v","video\/x-fli":"fli","video\/x-flv":"flv","video\/x-m4v":"m4v","video\/x-matroska":"mkv","video\/x-mng":"mng","video\/x-ms-asf":"asf","video\/x-ms-vob":"vob","video\/x-ms-wmx":"wmx","video\/x-ms-wvx":"wvx","video\/x-msvideo":"avi","video\/x-sgi-movie":"movie","video\/x-smv":"smv","x-conference\/x-cooltalk":"ice","text\/x-sql":"sql","image\/x-pixlr-data":"pxd","image\/x-adobe-dng":"dng","image\/x-sketch":"sketch","image\/x-xcf":"xcf","audio\/amr":"amr","application\/plt":"plt","application\/sat":"sat","application\/step":"step","text\/x-httpd-cgi":"cgi","text\/x-asap":"asp","text\/x-jsp":"jsp"}; /* * File: /js/elFinder.options.js */ /** * Default elFinder config * * @type Object * @autor Dmitry (dio) Levashov */ elFinder.prototype._options = { /** * URLs of 3rd party libraries CDN * * @type Object */ cdns : { // for editor etc. ace : 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.1', codemirror : 'https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.40.2', ckeditor : 'https://cdnjs.cloudflare.com/ajax/libs/ckeditor/4.10.0', ckeditor5 : 'https://cdn.ckeditor.com/ckeditor5/11.1.1', tinymce : 'https://cdnjs.cloudflare.com/ajax/libs/tinymce/4.8.3', simplemde : 'https://cdnjs.cloudflare.com/ajax/libs/simplemde/1.11.2', fabric16 : 'https://cdnjs.cloudflare.com/ajax/libs/fabric.js/1.6.7', tui : 'https://uicdn.toast.com', // for quicklook etc. hls : 'https://cdnjs.cloudflare.com/ajax/libs/hls.js/0.10.1/hls.min.js', dash : 'https://cdnjs.cloudflare.com/ajax/libs/dashjs/2.9.1/dash.all.min.js', flv : 'https://cdnjs.cloudflare.com/ajax/libs/flv.js/1.4.2/flv.min.js', prettify : 'https://cdn.jsdelivr.net/gh/google/code-prettify@453bd5f51e61245339b738b1bbdd42d7848722ba/loader/run_prettify.js', psd : 'https://cdnjs.cloudflare.com/ajax/libs/psd.js/3.2.0/psd.min.js', rar : 'https://cdn.jsdelivr.net/gh/nao-pon/rar.js@6cef13ec66dd67992fc7f3ea22f132d770ebaf8b/rar.min.js', zlibUnzip : 'https://cdn.jsdelivr.net/gh/imaya/zlib.js@0.3.1/bin/unzip.min.js', // need check unzipFiles() in quicklook.plugins.js when update zlibGunzip : 'https://cdn.jsdelivr.net/gh/imaya/zlib.js@0.3.1/bin/gunzip.min.js', marked : 'https://cdnjs.cloudflare.com/ajax/libs/marked/0.5.1/marked.min.js', sparkmd5 : 'https://cdnjs.cloudflare.com/ajax/libs/spark-md5/3.0.0/spark-md5.min.js', jssha : 'https://cdnjs.cloudflare.com/ajax/libs/jsSHA/2.3.1/sha.js', amr : 'https://cdn.jsdelivr.net/gh/yxl/opencore-amr-js@dcf3d2b5f384a1d9ded2a54e4c137a81747b222b/js/amrnb.js' }, /** * Connector url. Required! * * @type String */ url : '', /** * Ajax request type. * * @type String * @default "get" */ requestType : 'get', /** * Use CORS to connector url * * @type Boolean|null true|false|null(Auto detect) */ cors : null, /** * Maximum number of concurrent connections on request * * @type Number * @default 3 */ requestMaxConn : 3, /** * Transport to send request to backend. * Required for future extensions using websockets/webdav etc. * Must be an object with "send" method. * transport.send must return jQuery.Deferred() object * * @type Object * @default null * @example * transport : { * init : function(elfinderInstance) { }, * send : function(options) { * var dfrd = jQuery.Deferred(); * // connect to backend ... * return dfrd; * }, * upload : function(data) { * var dfrd = jQuery.Deferred(); * // upload ... * return dfrd; * } * * } **/ transport : {}, /** * URL to upload file to. * If not set - connector URL will be used * * @type String * @default '' */ urlUpload : '', /** * Allow to drag and drop to upload files * * @type Boolean|String * @default 'auto' */ dragUploadAllow : 'auto', /** * Confirmation dialog displayed at the time of overwriting upload * * @type Boolean * @default true */ overwriteUploadConfirm : true, /** * Max size of chunked data of file upload * * @type Number * @default 10485760(10MB) */ uploadMaxChunkSize : 10485760, /** * Regular expression of file name to exclude when uploading folder * * @type Object * @default { win: /^(?:desktop\.ini|thumbs\.db)$/i, mac: /^\.ds_store$/i } */ folderUploadExclude : { win: /^(?:desktop\.ini|thumbs\.db)$/i, mac: /^\.ds_store$/i }, /** * Timeout for upload using iframe * * @type Number * @default 0 - no timeout */ iframeTimeout : 0, /** * Data to append to all requests and to upload files * * @type Object * @default {} */ customData : {}, /** * Event listeners to bind on elFinder init * * @type Object * @default {} */ handlers : {}, /** * Any custom headers to send across every ajax request * * @type Object * @default {} */ customHeaders : {}, /** * Any custom xhrFields to send across every ajax request * * @type Object * @default {} */ xhrFields : {}, /** * Interface language * * @type String * @default "en" */ lang : 'en', /** * Base URL of elfFinder library starting from Manager HTML * Auto detect when empty value * * @type String * @default "" */ baseUrl : '', /** * Base URL of i18n js files * baseUrl + "js/i18n/" when empty value * * @type String * @default "" */ i18nBaseUrl : '', /** * Auto load required CSS * `false` to disable this function or * CSS URL Array to load additional CSS files * * @type Boolean|Array * @default true */ cssAutoLoad : true, /** * Theme to load * {"themeid" : "Theme CSS URL"} or * {"themeid" : "Theme manifesto.json URL"} or * Theme manifesto.json Object * { * "themeid" : { * "name":"Theme Name", * "cssurls":"Theme CSS URL", * "author":"Author Name", * "email":"Author Email", * "license":"License", * "link":"Web Site URL", * "image":"Screen Shot URL", * "description":"Description" * } * } * * @type Object */ themes : {}, /** * Theme id to initial theme * * @type String|Null */ theme : null, /** * Maximum value of error dialog open at the same time * * @type Number */ maxErrorDialogs : 5, /** * Additional css class for filemanager node. * * @type String */ cssClass : '', /** * Active commands list. '*' means all of the commands that have been load. * If some required commands will be missed here, elFinder will add its * * @type Array */ commands : ['*'], // Available commands list //commands : [ // 'archive', 'back', 'chmod', 'colwidth', 'copy', 'cut', 'download', 'duplicate', 'edit', 'extract', // 'forward', 'fullscreen', 'getfile', 'help', 'home', 'info', 'mkdir', 'mkfile', 'netmount', 'netunmount', // 'open', 'opendir', 'paste', 'places', 'quicklook', 'reload', 'rename', 'resize', 'restore', 'rm', // 'search', 'sort', 'up', 'upload', 'view', 'zipdl' //], /** * Commands options. * * @type Object **/ commandsOptions : { // // configure shortcuts of any command // // add `shortcuts` property into each command // any_command_name : { // shortcuts : [] // for disable this command's shortcuts // }, // any_command_name : { // shortcuts : function(fm, shortcuts) { // // for add `CTRL + E` for this command action // shortcuts[0]['pattern'] += ' ctrl+e'; // return shortcuts; // } // }, // any_command_name : { // shortcuts : function(fm, shortcuts) { // // for full customize of this command's shortcuts // return [ { pattern: 'ctrl+e ctrl+down numpad_enter' + (fm.OS != 'mac' && ' enter') } ]; // } // }, // "getfile" command options. getfile : { onlyURL : false, // allow to return multiple files info multiple : false, // allow to return filers info folders : false, // action after callback (""/"close"/"destroy") oncomplete : '', // action when callback is fail (""/"close"/"destroy") onerror : '', // get path before callback call getPath : true, // get image sizes before callback call getImgSize : false }, open : { // HTTP method that request to the connector when item URL is not valid URL. // If you set to "get" will be displayed request parameter in the browser's location field // so if you want to conceal its parameters should be given "post". // Nevertheless, please specify "get" if you want to enable the partial request by HTTP Range header. method : 'post', // Where to open into : 'window'(default), 'tab' or 'tabs' // 'tabs' opens in each tabs into : 'window', // Default command list of action when select file // String value that is 'Command Name' or 'Command Name1/CommandName2...' selectAction : 'open' }, opennew : { // URL of to open elFinder manager // Default '' : Origin URL url : '', // Use search query of origin URL useOriginQuery : true }, // "upload" command options. upload : { // Open elFinder upload dialog: 'button' OR Open system OS upload dialog: 'uploadbutton' ui : 'button' }, // "download" command options. download : { // max request to download files when zipdl disabled maxRequests : 10, // minimum count of files to use zipdl minFilesZipdl : 2 }, // "quicklook" command options. quicklook : { autoplay : true, width : 450, height : 300, // ControlsList of HTML5 audio/video preview // see https://googlechrome.github.io/samples/media/controlslist.html mediaControlsList : '', // e.g. 'nodownload nofullscreen noremoteplayback' // Show toolbar of PDF preview (with <embed> tag) pdfToolbar : true, // Maximum characters length to preview textMaxlen : 2000, // quicklook window must be contained in elFinder node on window open (true|false) contain : false, // preview window into NavDock (0 : undocked | 1 : docked(show) | 2 : docked(hide)) docked : 0, // Docked preview height ('auto' or Number of pixel) 'auto' is setted to the Navbar width dockHeight : 'auto', // media auto play when docked dockAutoplay : false, // Google Maps API key (Require Maps JavaScript API) googleMapsApiKey : '', // Google Maps API Options googleMapsOpts : { maps : {}, kml : { suppressInfoWindows : false, preserveViewport : false } }, // ViewerJS (https://viewerjs.org/) Options // To enable this you need to place ViewerJS on the same server as elFinder and specify that URL in `url`. viewerjs : { url: '', // Example '/ViewerJS/index.html' mimes: ['application/pdf', 'application/vnd.oasis.opendocument.text', 'application/vnd.oasis.opendocument.spreadsheet', 'application/vnd.oasis.opendocument.presentation'] }, // MIME types to CAD-Files and 3D-Models online viewer on sharecad.org // Example ['image/vnd.dwg', 'image/vnd.dxf', 'model/vnd.dwf', 'application/vnd.hp-hpgl', 'application/plt', 'application/step', 'model/iges', 'application/vnd.ms-pki.stl', 'application/sat', 'image/cgm', 'application/x-msmetafile'] sharecadMimes : [], // MIME types to use Google Docs online viewer // Example ['application/pdf', 'image/tiff', 'application/vnd.ms-office', 'application/msword', 'application/vnd.ms-word', 'application/vnd.ms-excel', 'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/postscript', 'application/rtf'] googleDocsMimes : [], // MIME types to use Microsoft Office Online viewer // Example ['application/msword', 'application/vnd.ms-word', 'application/vnd.ms-excel', 'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/vnd.oasis.opendocument.text', 'application/vnd.oasis.opendocument.spreadsheet', 'application/vnd.oasis.opendocument.presentation'] // These MIME types override "googleDocsMimes" officeOnlineMimes : [], // File size (byte) threshold when using the dim command for obtain the image size necessary to image preview getDimThreshold : 200000, // MIME-Type regular expression that does not check empty files mimeRegexNotEmptyCheck : /^application\/vnd\.google-apps\./ }, // "quicklook" command options. edit : { // dialog width, integer(px) or integer+'%' (example: 650, '80%' ...) dialogWidth : void(0), // list of allowed mimetypes to edit of text files // if empty - any text files can be edited mimes : [], // MIME-types of text file to make as empty files makeTextMimes : ['text/plain', 'text/css', 'text/html'], // Use the editor stored in the browser // This value allowd overwrite with user preferences useStoredEditor : false, // Open the maximized editor window // This value allowd overwrite with user preferences editorMaximized : false, // edit files in wysisyg's editors : [ // { // /** // * editor info // * @type Object // */ // info : { name: 'Editor Name' }, // /** // * files mimetypes allowed to edit in current wysisyg // * @type Array // */ // mimes : ['text/html'], // /** // * HTML element for editing area (optional for text editor) // * @type String // */ // html : '<textarea></textarea>', // /** // * Initialize editing area node (optional for text editor) // * // * @param String dialog DOM id // * @param Object target file object // * @param String target file content (text or Data URI Scheme(binary file)) // * @param Object elFinder instance // * @type Function // */ // init : function(id, file, content, fm) { // jQuery(this).attr('id', id + '-text').val(content); // }, // /** // * Get edited contents (optional for text editor) // * @type Function // */ // getContent : function() { // return jQuery(this).val(); // }, // /** // * Called when "edit" dialog loaded. // * Place to init wysisyg. // * Can return wysisyg instance // * // * @param DOMElement textarea node // * @return Object editor instance|jQuery.Deferred(return instance on resolve()) // */ // load : function(textarea) { }, // /** // * Called before "edit" dialog closed. // * Place to destroy wysisyg instance. // * // * @param DOMElement textarea node // * @param Object wysisyg instance (if was returned by "load" callback) // * @return void // */ // close : function(textarea, instance) { }, // /** // * Called before file content send to backend. // * Place to update textarea content if needed. // * // * @param DOMElement textarea node // * @param Object wysisyg instance (if was returned by "load" callback) // * @return void // */ // save : function(textarea, instance) {}, // /** // * Called after load() or save(). // * Set focus to wysisyg editor. // * // * @param DOMElement textarea node // * @param Object wysisyg instance (if was returned by "load" callback) // * @return void // */ // focus : function(textarea, instance) {} // /** // * Called after dialog resized.. // * // * @param DOMElement textarea node // * @param Object wysisyg instance (if was returned by "load" callback) // * @param Object resize event object // * @param Object data object // * @return void // */ // resize : function(textarea, instance, event, data) {} // // } ], // Character encodings of select box encodings : ['Big5', 'Big5-HKSCS', 'Cp437', 'Cp737', 'Cp775', 'Cp850', 'Cp852', 'Cp855', 'Cp857', 'Cp858', 'Cp862', 'Cp866', 'Cp874', 'EUC-CN', 'EUC-JP', 'EUC-KR', 'GB18030', 'ISO-2022-CN', 'ISO-2022-JP', 'ISO-2022-KR', 'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3', 'ISO-8859-4', 'ISO-8859-5', 'ISO-8859-6', 'ISO-8859-7', 'ISO-8859-8', 'ISO-8859-9', 'ISO-8859-13', 'ISO-8859-15', 'KOI8-R', 'KOI8-U', 'Shift-JIS', 'Windows-1250', 'Windows-1251', 'Windows-1252', 'Windows-1253', 'Windows-1254', 'Windows-1257'], // options for extra editors extraOptions : { // TUI Image Editor's options tuiImgEditOpts : { // Path prefix of icon-a.svg, icon-b.svg, icon-c.svg and icon-d.svg in the Theme. // `iconsPath` MUST follow the same origin policy. iconsPath : void(0), // default is "./img/tui-" // Theme object theme : {} }, // Pixo image editor constructor options - https://pixoeditor.com/ // Require 'apikey' to enable it pixo: { apikey: '' }, // Specify the Creative Cloud API key when using Creative SDK image editor of Creative Cloud. // You can get the API key at https://console.adobe.io/. creativeCloudApiKey : '', // Browsing manager URL for CKEditor, TinyMCE // Uses self location with the empty value or not defined. //managerUrl : 'elfinder.html' managerUrl : null, // CKEditor5' builds mode - 'classic', 'inline' or 'balloon' ckeditor5Mode : 'balloon', // Setting for Online-Convert.com onlineConvert : { maxSize : 100, // (MB) Max 100MB on free account showLink : true // It must be enabled with free account } } }, search : { // Incremental search from the current view incsearch : { enable : true, // is enable true or false minlen : 1, // minimum number of characters wait : 500 // wait milliseconds }, // Additional search types searchTypes : { // "SearchMime" is implemented in default SearchMime : { // The key is search type that send to the connector name : 'btnMime', // Button text to be processed in i18n() title : 'searchMime' // Button title to be processed in i18n() } } }, // "info" command options. info : { // If the URL of the Directory is null, // it is assumed that the link destination is a URL to open the folder in elFinder nullUrlDirLinkSelf : true, // Information items to be hidden by default // These name are 'size', 'aliasfor', 'path', 'link', 'dim', 'modify', 'perms', 'locked', 'owner', 'group', 'perm' and your custom info items label hideItems : [], // Maximum file size (byte) to get file contents hash (md5, sha256 ...) showHashMaxsize : 104857600, // 100 MB // Array of hash algorisms to show on info dialog // These name are 'md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'sha3-224', 'sha3-256', 'sha3-384', 'sha3-512', 'shake128' and 'shake256' showHashAlgorisms : ['md5', 'sha256'], custom : { // /** // * Example of custom info `desc` // */ // desc : { // /** // * Lable (require) // * It is filtered by the `fm.i18n()` // * // * @type String // */ // label : 'Description', // // /** // * Template (require) // * `{id}` is replaced in dialog.id // * // * @type String // */ // tpl : '<div class="elfinder-info-desc"><span class="elfinder-spinner"></span></div>', // // /** // * Restricts to mimetypes (optional) // * Exact match or category match // * // * @type Array // */ // mimes : ['text', 'image/jpeg', 'directory'], // // /** // * Restricts to file.hash (optional) // * // * @ type Regex // */ // hashRegex : /^l\d+_/, // // /** // * Request that asks for the description and sets the field (optional) // * // * @type Function // */ // action : function(file, fm, dialog) { // fm.request({ // data : { cmd : 'desc', target: file.hash }, // preventDefault: true, // }) // .fail(function() { // dialog.find('div.elfinder-info-desc').html(fm.i18n('unknown')); // }) // .done(function(data) { // dialog.find('div.elfinder-info-desc').html(data.desc); // }); // } // } } }, mkdir: { // Enable automatic switching function ["New Folder" / "Into New Folder"] of toolbar buttton intoNewFolderToolbtn: false }, resize: { // defalt status of snap to 8px grid of the jpeg image ("enable" or "disable") grid8px : 'disable', // Preset size array [width, height] presetSize : [[320, 240], [400, 400], [640, 480], [800,600]], // File size (bytes) threshold when using the `dim` command for obtain the image size necessary to start editing getDimThreshold : 204800, // File size (bytes) to request to get substitute image (400px) with the `dim` command dimSubImgSize : 307200 }, rm: { // If trash is valid, items moves immediately to the trash holder without confirm. quickTrash : true, // Maximum wait seconds when checking the number of items to into the trash infoCheckWait : 10, // Maximum number of items that can be placed into the Trash at one time toTrashMaxItems : 1000 }, help : { // Tabs to show view : ['about', 'shortcuts', 'help', 'integrations', 'debug'], // HTML source URL of the heip tab helpSource : '' }, preference : { // dialog width width: 600, // dialog height height: 400, // tabs setting see preference.js : build() categories: null, // preference setting see preference.js : build() prefs: null, // language setting see preference.js : build() langs: null, // Command list of action when select file // Array value are 'Command Name' or 'Command Name1/CommandName2...' selectActions : ['open', 'edit/download', 'resize/edit/download', 'download', 'quicklook'] } }, /** * Callback for prepare boot up * * - The this object in the function is an elFinder node * - The first parameter is elFinder Instance * - The second parameter is an object of other parameters * For now it can use `dfrdsBeforeBootup` Array * * @type Function * @default null * @return void */ bootCallback : null, /** * Callback for "getfile" commands. * Required to use elFinder with WYSIWYG editors etc.. * * @type Function * @default null (command not active) */ getFileCallback : null, /** * Default directory view. icons/list * * @type String * @default "icons" */ defaultView : 'icons', /** * Hash of default directory path to open * * NOTE: This setting will be disabled if the target folder is specified in location.hash. * * If you want to find the hash in Javascript * can be obtained with the following code. (In the case of a standard hashing method) * * var volumeId = 'l1_'; // volume id * var path = 'path/to/target'; // without root path * //var path = 'path\\to\\target'; // use \ on windows server * var hash = volumeId + btoa(path).replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '.').replace(/\.+$/, ''); * * @type String * @default "" */ startPathHash : '', /** * Emit a sound when a file is deleted * Sounds are in sounds/ folder * * @type Boolean * @default true */ sound : true, /** * UI plugins to load. * Current dir ui and dialogs loads always. * Here set not required plugins as folders tree/toolbar/statusbar etc. * * @type Array * @default ['toolbar', 'tree', 'path', 'stat'] * @full ['toolbar', 'places', 'tree', 'path', 'stat'] */ ui : ['toolbar', 'tree', 'path', 'stat'], /** * Some UI plugins options. * @type Object */ uiOptions : { // toolbar configuration toolbar : [ ['home', 'back', 'forward', 'up', 'reload'], ['netmount'], ['mkdir', 'mkfile', 'upload'], ['open', 'download', 'getfile'], ['undo', 'redo'], ['copy', 'cut', 'paste', 'rm', 'empty', 'hide'], ['duplicate', 'rename', 'edit', 'resize', 'chmod'], ['selectall', 'selectnone', 'selectinvert'], ['quicklook', 'info'], ['extract', 'archive'], ['search'], ['view', 'sort'], ['help'], ['fullscreen'] ], // toolbar extra options toolbarExtra : { // also displays the text label on the button (true / false / 'none') displayTextLabel: false, // Exclude `displayTextLabel` setting UA type labelExcludeUA: ['Mobile'], // auto hide on initial open autoHideUA: ['Mobile'], // Initial setting value of hide button in toolbar setting defaultHides: ['home', 'reload'], // show Preference button ('none', 'auto', 'always') // If you do not include 'preference' in the context menu you should specify 'auto' or 'always' showPreferenceButton: 'none', // show Preference button into contextmenu of the toolbar (true / false) preferenceInContextmenu: true }, // directories tree options tree : { // expand current root on init openRootOnLoad : true, // expand current work directory on open openCwdOnOpen : true, // auto loading current directory parents and do expand their node. syncTree : true, // Maximum number of display of each child trees // The tree of directories with children exceeding this number will be split subTreeMax : 100, // Numbar of max connctions of subdirs request subdirsMaxConn : 2, // Number of max simultaneous processing directory of subdirs subdirsAtOnce : 5, // Durations of each animations durations : { slideUpDown : 'fast', autoScroll : 'fast' } // , // /** // * Add CSS class name to navbar directories (optional) // * see: https://github.com/Studio-42/elFinder/pull/1061, // * https://github.com/Studio-42/elFinder/issues/1231 // * // * @type Function // */ // getClass: function(dir) { // // e.g. This adds the directory's name (lowercase) with prefix as a CSS class // return 'elfinder-tree-' + dir.name.replace(/[ "]/g, '').toLowerCase(); // } }, // navbar options navbar : { minWidth : 150, maxWidth : 500, // auto hide on initial open autoHideUA: [] // e.g. ['Mobile'] }, navdock : { // disabled navdock ui disabled : false, // percentage of initial maximum height to work zone initMaxHeight : '50%', // percentage of maximum height to work zone by user resize action maxHeight : '90%' }, cwd : { // display parent folder with ".." name :) oldSchool : false, // fm.UA types array to show item select checkboxes e.g. ['All'] or ['Mobile'] etc. default: ['Touch'] showSelectCheckboxUA : ['Touch'], // file info columns displayed listView : { // name is always displayed, cols are ordered // e.g. ['perm', 'date', 'size', 'kind', 'owner', 'group', 'mode'] // mode: 'mode'(by `fileModeStyle` setting), 'modestr'(rwxr-xr-x) , 'modeoct'(755), 'modeboth'(rwxr-xr-x (755)) // 'owner', 'group' and 'mode', It's necessary set volume driver option "statOwner" to `true` // for custom, characters that can be used in the name is `a-z0-9_` columns : ['perm', 'date', 'size', 'kind'], // override this if you want custom columns name // example // columnsCustomName : { // date : 'Last modification', // kind : 'Mime type' // } columnsCustomName : {}, // fixed list header colmun fixedHeader : true }, // icons view setting iconsView : { // default icon size (0-3 in default CSS (cwd.css - elfinder-cwd-size[number])) size: 0, // number of maximum size (3 in default CSS (cwd.css - elfinder-cwd-size[number])) // uses in preference.js sizeMax: 3, // Name of each size sizeNames: { 0: 'viewSmall', 1: 'viewMedium', 2: 'viewLarge', 3: 'viewExtraLarge' } }, // /** // * Add CSS class name to cwd directories (optional) // * see: https://github.com/Studio-42/elFinder/pull/1061, // * https://github.com/Studio-42/elFinder/issues/1231 // * // * @type Function // */ // , // getClass: function(file) { // // e.g. This adds the directory's name (lowercase) with prefix as a CSS class // return 'elfinder-cwd-' + file.name.replace(/[ "]/g, '').toLowerCase(); //} //, //// Template placeholders replacement rules for overwrite. see ui/cwd.js replacement //replacement : { // tooltip : function(f, fm) { // var list = fm.viewType == 'list', // current view type // query = fm.searchStatus.state == 2, // is in search results // title = fm.formatDate(f) + (f.size > 0 ? ' ('+fm.formatSize(f.size)+')' : ''), // info = ''; // if (query && f.path) { // info = fm.escape(f.path.replace(/\/[^\/]*$/, '')); // } else { // info = f.tooltip? fm.escape(f.tooltip).replace(/\r/g, ' ') : ''; // } // if (list) { // info += (info? ' ' : '') + fm.escape(f.name); // } // return info? info + ' ' + title : title; // } //} }, path : { // Move to head of work zone without UI navbar toWorkzoneWithoutNavbar : true }, dialog : { // Enable to auto focusing on mouse over in the target form element focusOnMouseOver : true }, toast : { animate : { // to show showMethod: 'fadeIn', // fadeIn, slideDown, and show are built into jQuery showDuration: 300, // milliseconds showEasing: 'swing', // swing and linear are built into jQuery // timeout to hide timeOut: 3000, // to hide hideMethod: 'fadeOut', hideDuration: 1500, hideEasing: 'swing' } } }, /** * MIME regex of send HTTP header "Content-Disposition: inline" or allow preview in quicklook * This option will overwrite by connector configuration * * @type String * @default '^(?:(?:image|video|audio)|text/plain|application/pdf$)' * @example * dispInlineRegex : '.', // is allow inline of all of MIME types * dispInlineRegex : '$^', // is not allow inline of all of MIME types */ dispInlineRegex : '^(?:(?:image|video|audio)|application/(?:x-mpegURL|dash\+xml)|(?:text/plain|application/pdf)$)', /** * Display only required files by types * * @type Array * @default [] * @example * onlyMimes : ["image"] - display all images * onlyMimes : ["image/png", "application/x-shockwave-flash"] - display png and flash */ onlyMimes : [], /** * Custom files sort rules. * All default rules (name/size/kind/date/perm/mode/owner/group) set in elFinder._sortRules * * @type {Object} * @example * sortRules : { * name : function(file1, file2) { return file1.name.toLowerCase().localeCompare(file2.name.toLowerCase()); } * } */ sortRules : {}, /** * Default sort type. * * @type {String} */ sortType : 'name', /** * Default sort order. * * @type {String} * @default "asc" */ sortOrder : 'asc', /** * Display folders first? * * @type {Boolean} * @default true */ sortStickFolders : true, /** * Sort also applies to the treeview (null: disable this feature) * * @type Boolean|null * @default false */ sortAlsoTreeview : false, /** * If true - elFinder will formating dates itself, * otherwise - backend date will be used. * * @type Boolean */ clientFormatDate : true, /** * Show UTC dates. * Required set clientFormatDate to true * * @type Boolean */ UTCDate : false, /** * File modification datetime format. * Value from selected language data is used by default. * Set format here to overwrite it. * * @type String * @default "" */ dateFormat : '', /** * File modification datetime format in form "Yesterday 12:23:01". * Value from selected language data is used by default. * Set format here to overwrite it. * Use $1 for "Today"/"Yesterday" placeholder * * @type String * @default "" * @example "$1 H:m:i" */ fancyDateFormat : '', /** * Style of file mode at cwd-list, info dialog * 'string' (ex. rwxr-xr-x) or 'octal' (ex. 755) or 'both' (ex. rwxr-xr-x (755)) * * @type {String} * @default 'both' */ fileModeStyle : 'both', /** * elFinder width * * @type String|Number * @default "auto" */ width : 'auto', /** * elFinder node height * Number: pixcel or String: Number + "%" * * @type Number | String * @default 400 */ height : 400, /** * Base node object or selector * Element which is the reference of the height percentage * * @type Object|String * @default null | jQuery(window) (if height is percentage) **/ heightBase : null, /** * Make elFinder resizable if jquery ui resizable available * * @type Boolean * @default true */ resizable : true, /** * Timeout before open notifications dialogs * * @type Number * @default 500 (.5 sec) */ notifyDelay : 500, /** * Position CSS, Width of notifications dialogs * * @type Object * @default {position: {}, width : null} - Apply CSS definition * position: CSS object | null (null: position center & middle) */ notifyDialog : {position: {}, width : null}, /** * Dialog contained in the elFinder node * * @type Boolean * @default false */ dialogContained : false, /** * Allow shortcuts * * @type Boolean * @default true */ allowShortcuts : true, /** * Remeber last opened dir to open it after reload or in next session * * @type Boolean * @default true */ rememberLastDir : true, /** * Clear historys(elFinder) on reload(not browser) function * Historys was cleared on Reload function on elFinder 2.0 (value is true) * * @type Boolean * @default false */ reloadClearHistory : false, /** * Use browser native history with supported browsers * * @type Boolean * @default true */ useBrowserHistory : true, /** * Lazy load config. * How many files display at once? * * @type Number * @default 50 */ showFiles : 50, /** * Lazy load config. * Distance in px to cwd bottom edge to start display files * * @type Number * @default 50 */ showThreshold : 50, /** * Additional rule to valid new file name. * By default not allowed empty names or '..' * This setting does not have a sense of security. * * @type false|RegExp|function * @default false * @example * disable names with spaces: * validName : /^[^\s]+$/, */ validName : false, /** * Additional rule to filtering for browsing. * This setting does not have a sense of security. * * The object `this` is elFinder instance object in this function * * @type false|RegExp|function * @default false * @example * show only png and jpg files: * fileFilter : /.*\.(png|jpg)$/i, * * show only image type files: * fileFilter : function(file) { return file.mime && file.mime.match(/^image\//i); }, */ fileFilter : false, /** * Backup name suffix. * * @type String * @default "~" */ backupSuffix : '~', /** * Sync content interval * * @type Number * @default 0 (do not sync) */ sync : 0, /** * Sync start on load if sync value >= 1000 * * @type Bool * @default true */ syncStart : true, /** * How many thumbnails create in one request * * @type Number * @default 5 */ loadTmbs : 5, /** * Cookie option for browsersdoes not suppot localStorage * * @type Object */ cookie : { expires : 30, domain : '', path : '/', secure : false }, /** * Contextmenu config * * @type Object */ contextmenu : { // navbarfolder menu navbar : ['open', 'opennew', 'download', '|', 'upload', 'mkdir', '|', 'copy', 'cut', 'paste', 'duplicate', '|', 'rm', 'empty', 'hide', '|', 'rename', '|', 'archive', '|', 'places', 'info', 'chmod', 'netunmount'], // current directory menu cwd : ['undo', 'redo', '|', 'back', 'up', 'reload', '|', 'upload', 'mkdir', 'mkfile', 'paste', '|', 'empty', 'hide', '|', 'view', 'sort', 'selectall', 'colwidth', '|', 'places', 'info', 'chmod', 'netunmount', '|', 'fullscreen'], // current directory file menu files : ['getfile', '|' ,'open', 'opennew', 'download', 'opendir', 'quicklook', '|', 'upload', 'mkdir', '|', 'copy', 'cut', 'paste', 'duplicate', '|', 'rm', 'empty', 'hide', '|', 'rename', 'edit', 'resize', '|', 'archive', 'extract', '|', 'selectall', 'selectinvert', '|', 'places', 'info', 'chmod', 'netunmount'] }, /** * elFinder node enable always * This value will set to `true` if <body> has elFinder node only * * @type Bool * @default false */ enableAlways : false, /** * elFinder node enable by mouse over * * @type Bool * @default true */ enableByMouseOver : true, /** * Show window close confirm dialog * Value is which state to show * 'hasNotifyDialog', 'editingFile', 'hasSelectedItem' and 'hasClipboardData' * * @type Array * @default ['hasNotifyDialog', 'editingFile'] */ windowCloseConfirm : ['hasNotifyDialog', 'editingFile'], /** * Function decoding 'raw' string converted to unicode * It is used instead of fm.decodeRawString(str) * * @type Null|Function */ rawStringDecoder : typeof Encoding === 'object' && jQuery.isFunction(Encoding.convert)? function(str) { return Encoding.convert(str, { to: 'UNICODE', type: 'string' }); } : null, /** * Debug config * * @type Array|String('auto')|Boolean(true|false) */ // debug : true debug : ['error', 'warning', 'event-destroy'] }; /* * File: /js/elFinder.options.netmount.js */ /** * Default elFinder config of commandsOptions.netmount * * @type Object */ elFinder.prototype._options.commandsOptions.netmount = { ftp: { name : 'FTP', inputs: { host : jQuery('<input type="text"/>'), port : jQuery('<input type="number" placeholder="21" class="elfinder-input-optional"/>'), path : jQuery('<input type="text" value="/"/>'), user : jQuery('<input type="text"/>'), pass : jQuery('<input type="password" autocomplete="new-password"/>'), FTPS : jQuery('<input type="checkbox" value="1" title="File Transfer Protocol over SSL/TLS"/>'), encoding : jQuery('<input type="text" placeholder="Optional" class="elfinder-input-optional"/>'), locale : jQuery('<input type="text" placeholder="Optional" class="elfinder-input-optional"/>') } }, dropbox2: elFinder.prototype.makeNetmountOptionOauth('dropbox2', 'Dropbox', 'Dropbox', {noOffline : true, root : '/', pathI18n : 'path', integrate : { title: 'Dropbox.com', link: 'https://www.dropbox.com' } }), googledrive: elFinder.prototype.makeNetmountOptionOauth('googledrive', 'Google Drive', 'Google', { integrate : { title: 'Google Drive', link: 'https://www.google.com/drive/' } }), onedrive: elFinder.prototype.makeNetmountOptionOauth('onedrive', 'One Drive', 'OneDrive', { integrate : { title: 'Microsoft OneDrive', link: 'https://onedrive.live.com' } }), box: elFinder.prototype.makeNetmountOptionOauth('box', 'Box', 'Box', { noOffline : true, integrate : { title: 'Box.com', link: 'https://www.box.com' } }) }; /* * File: /js/elFinder.history.js */ /** * @class elFinder.history * Store visited folders * and provide "back" and "forward" methods * * @author Dmitry (dio) Levashov */ elFinder.prototype.history = function(fm) { var self = this, /** * Update history on "open" event? * * @type Boolean */ update = true, /** * Directories hashes storage * * @type Array */ history = [], /** * Current directory index in history * * @type Number */ current, /** * Clear history * * @return void */ reset = function() { history = [fm.cwd().hash]; current = 0; update = true; }, /** * Browser native history object */ nativeHistory = (fm.options.useBrowserHistory && window.history && window.history.pushState)? window.history : null, /** * Open prev/next folder * * @Boolen open next folder? * @return jQuery.Deferred */ go = function(fwd) { if ((fwd && self.canForward()) || (!fwd && self.canBack())) { update = false; return fm.exec('open', history[fwd ? ++current : --current]).fail(reset); } return jQuery.Deferred().reject(); }, /** * Sets the native history. * * @param String thash target hash */ setNativeHistory = function(thash) { if (nativeHistory && (! nativeHistory.state || nativeHistory.state.thash !== thash)) { nativeHistory.pushState({thash: thash}, null, location.pathname + location.search + (thash? '#elf_' + thash : '')); } }; /** * Return true if there is previous visited directories * * @return Boolen */ this.canBack = function() { return current > 0; }; /** * Return true if can go forward * * @return Boolen */ this.canForward = function() { return current < history.length - 1; }; /** * Go back * * @return void */ this.back = go; /** * Go forward * * @return void */ this.forward = function() { return go(true); }; // bind to elfinder events fm.bind('init', function() { if (nativeHistory && !nativeHistory.state) { setNativeHistory(fm.startDir()); } }) .open(function() { var l = history.length, cwd = fm.cwd().hash; if (update) { current >= 0 && l > current + 1 && history.splice(current+1); history[history.length-1] != cwd && history.push(cwd); current = history.length - 1; } update = true; setNativeHistory(cwd); }) .reload(fm.options.reloadClearHistory && reset); }; /* * File: /js/elFinder.command.js */ /** * elFinder command prototype * * @type elFinder.command * @author Dmitry (dio) Levashov */ elFinder.prototype.command = function(fm) { /** * elFinder instance * * @type elFinder */ this.fm = fm; /** * Command name, same as class name * * @type String */ this.name = ''; /** * Dialog class name * * @type String */ this.dialogClass = ''; /** * Command icon class name with out 'elfinder-button-icon-' * Use this.name if it is empty * * @type String */ this.className = ''; /** * Short command description * * @type String */ this.title = ''; /** * Linked(Child) commands name * They are loaded together when tthis command is loaded. * * @type Array */ this.linkedCmds = []; /** * Current command state * * @example * this.state = -1; // command disabled * this.state = 0; // command enabled * this.state = 1; // command active (for example "fullscreen" command while elfinder in fullscreen mode) * @default -1 * @type Number */ this.state = -1; /** * If true, command can not be disabled by connector. * @see this.update() * * @type Boolen */ this.alwaysEnabled = false; /** * Do not change dirctory on removed current work directory * * @type Boolen */ this.noChangeDirOnRemovedCwd = false; /** * If true, this means command was disabled by connector. * @see this.update() * * @type Boolen */ this._disabled = false; /** * If true, this command is disabled on serach results * * @type Boolean */ this.disableOnSearch = false; /** * Call update() when event select fired * * @type Boolean */ this.updateOnSelect = true; /** * Sync toolbar button title on change * * @type Boolean */ this.syncTitleOnChange = false; /** * Keep display of the context menu when command execution * * @type Boolean */ this.keepContextmenu = false; /** * elFinder events defaults handlers. * Inside handlers "this" is current command object * * @type Object */ this._handlers = { enable : function() { this.update(void(0), this.value); }, disable : function() { this.update(-1, this.value); }, 'open reload load sync' : function() { this._disabled = !(this.alwaysEnabled || this.fm.isCommandEnabled(this.name)); this.update(void(0), this.value); this.change(); } }; /** * elFinder events handlers. * Inside handlers "this" is current command object * * @type Object */ this.handlers = {}; /** * Shortcuts * * @type Array */ this.shortcuts = []; /** * Command options * * @type Object */ this.options = {ui : 'button'}; /** * Callback functions on `change` event * * @type Array */ this.listeners = []; /** * Prepare object - * bind events and shortcuts * * @return void */ this.setup = function(name, opts) { var self = this, fm = this.fm, setCallback = function(s) { var cb = s.callback || function(e) { fm.exec(self.name, void(0), { _userAction: true, _currentType: 'shortcut' }); }; s.callback = function(e) { var enabled, checks = {}; if (self.enabled()) { if (fm.searchStatus.state < 2) { enabled = fm.isCommandEnabled(self.name); } else { jQuery.each(fm.selected(), function(i, h) { if (fm.optionsByHashes[h]) { checks[h] = true; } else { jQuery.each(fm.volOptions, function(id) { if (!checks[id] && h.indexOf(id) === 0) { checks[id] = true; return false; } }); } }); jQuery.each(checks, function(h) { enabled = fm.isCommandEnabled(self.name, h); if (! enabled) { return false; } }); } if (enabled) { self.event = e; cb.call(self); delete self.event; } } }; }, i, s, sc; this.name = name; this.title = fm.messages['cmd'+name] ? fm.i18n('cmd'+name) : ((this.extendsCmd && fm.messages['cmd'+this.extendsCmd]) ? fm.i18n('cmd'+this.extendsCmd) : name); this.options = Object.assign({}, this.options, opts); this.listeners = []; this.dialogClass = 'elfinder-dialog-' + name; if (opts.shortcuts) { if (typeof opts.shortcuts === 'function') { sc = opts.shortcuts(this.fm, this.shortcuts); } else if (Array.isArray(opts.shortcuts)) { sc = opts.shortcuts; } this.shortcuts = sc || []; } if (this.updateOnSelect) { this._handlers.select = function() { this.update(void(0), this.value); }; } jQuery.each(Object.assign({}, self._handlers, self.handlers), function(cmd, handler) { fm.bind(cmd, jQuery.proxy(handler, self)); }); for (i = 0; i < this.shortcuts.length; i++) { s = this.shortcuts[i]; setCallback(s); !s.description && (s.description = this.title); fm.shortcut(s); } if (this.disableOnSearch) { fm.bind('search searchend', function() { self._disabled = this.type === 'search'? true : ! (this.alwaysEnabled || fm.isCommandEnabled(name)); self.update(void(0), self.value); }); } this.init(); }; /** * Command specific init stuffs * * @return void */ this.init = function() {}; /** * Exec command * * @param Array target files hashes * @param Array|Object command value * @return jQuery.Deferred */ this.exec = function(files, opts) { return jQuery.Deferred().reject(); }; this.getUndo = function(opts, resData) { return false; }; /** * Return true if command disabled. * * @return Boolen */ this.disabled = function() { return this.state < 0; }; /** * Return true if command enabled. * * @return Boolen */ this.enabled = function() { return this.state > -1; }; /** * Return true if command active. * * @return Boolen */ this.active = function() { return this.state > 0; }; /** * Return current command state. * Must be overloaded in most commands * * @return Number */ this.getstate = function() { return -1; }; /** * Update command state/value * and rize 'change' event if smth changed * * @param Number new state or undefined to auto update state * @param mixed new value * @return void */ this.update = function(s, v) { var state = this.state, value = this.value; if (this._disabled && this.fm.searchStatus === 0) { this.state = -1; } else { this.state = s !== void(0) ? s : this.getstate(); } this.value = v; if (state != this.state || value != this.value) { this.change(); } }; /** * Bind handler / fire 'change' event. * * @param Function|undefined event callback * @return void */ this.change = function(c) { var cmd, i; if (typeof(c) === 'function') { this.listeners.push(c); } else { for (i = 0; i < this.listeners.length; i++) { cmd = this.listeners[i]; try { cmd(this.state, this.value); } catch (e) { this.fm.debug('error', e); } } } return this; }; /** * With argument check given files hashes and return list of existed files hashes. * Without argument return selected files hashes. * * @param Array|String|void hashes * @return Array */ this.hashes = function(hashes) { return hashes ? jQuery.grep(Array.isArray(hashes) ? hashes : [hashes], function(hash) { return fm.file(hash) ? true : false; }) : fm.selected(); }; /** * Return only existed files from given fils hashes | selected files * * @param Array|String|void hashes * @return Array */ this.files = function(hashes) { var fm = this.fm; return hashes ? jQuery.map(Array.isArray(hashes) ? hashes : [hashes], function(hash) { return fm.file(hash) || null; }) : fm.selectedFiles(); }; /** * Wrapper to fm.dialog() * * @param String|DOMElement content * @param Object options * @return Object jQuery element object */ this.fmDialog = function(content, options) { if (options.cssClass) { options.cssClass += ' ' + this.dialogClass; } else { options.cssClass = this.dialogClass; } return this.fm.dialog(content, options); }; }; /* * File: /js/elFinder.resources.js */ /** * elFinder resources registry. * Store shared data * * @type Object * @author Dmitry (dio) Levashov **/ elFinder.prototype.resources = { 'class' : { hover : 'ui-state-hover', active : 'ui-state-active', disabled : 'ui-state-disabled', draggable : 'ui-draggable', droppable : 'ui-droppable', adroppable : 'elfinder-droppable-active', cwdfile : 'elfinder-cwd-file', cwd : 'elfinder-cwd', tree : 'elfinder-tree', treeroot : 'elfinder-navbar-root', navdir : 'elfinder-navbar-dir', navdirwrap : 'elfinder-navbar-dir-wrapper', navarrow : 'elfinder-navbar-arrow', navsubtree : 'elfinder-navbar-subtree', navcollapse : 'elfinder-navbar-collapsed', navexpand : 'elfinder-navbar-expanded', treedir : 'elfinder-tree-dir', placedir : 'elfinder-place-dir', searchbtn : 'elfinder-button-search', editing : 'elfinder-to-editing', preventback : 'elfinder-prevent-back', tabstab : 'ui-state-default ui-tabs-tab ui-corner-top ui-tab', tabsactive : 'ui-tabs-active ui-state-active' }, tpl : { perms : '<span class="elfinder-perms"/>', lock : '<span class="elfinder-lock"/>', symlink : '<span class="elfinder-symlink"/>', navicon : '<span class="elfinder-nav-icon"/>', navspinner : '<span class="elfinder-spinner elfinder-navbar-spinner"/>', navdir : '<div class="elfinder-navbar-wrapper{root}"><span id="{id}" class="ui-corner-all elfinder-navbar-dir {cssclass}"><span class="elfinder-navbar-arrow"/><span class="elfinder-navbar-icon" {style}/>{symlink}{permissions}{name}</span><div class="elfinder-navbar-subtree" style="display:none"/></div>', placedir : '<div class="elfinder-navbar-wrapper"><span id="{id}" class="ui-corner-all elfinder-navbar-dir {cssclass}" title="{title}"><span class="elfinder-navbar-arrow"/><span class="elfinder-navbar-icon" {style}/>{symlink}{permissions}{name}</span><div class="elfinder-navbar-subtree" style="display:none"/></div>' }, // mimes.text will be overwritten with connector config if `textMimes` is included in initial response // @see php/elFInder.class.php `public static $textMimes` mimes : { text : [ 'application/dash+xml', 'application/docbook+xml', 'application/javascript', 'application/json', 'application/plt', 'application/sat', 'application/sql', 'application/step', 'application/vnd.hp-hpgl', 'application/x-awk', 'application/x-config', 'application/x-csh', 'application/x-empty', 'application/x-mpegurl', 'application/x-perl', 'application/x-php', 'application/x-web-config', 'application/xhtml+xml', 'application/xml', 'audio/x-mp3-playlist', 'image/cgm', 'image/svg+xml', 'image/vnd.dxf', 'model/iges' ] }, mixin : { make : function() { var self = this, fm = this.fm, cmd = this.name, req = this.requestCmd || cmd, wz = fm.getUI('workzone'), org = (this.origin && this.origin === 'navbar')? 'tree' : 'cwd', tree = (org === 'tree'), find = tree? 'navHash2Elm' : 'cwdHash2Elm', tarea= (! tree && fm.storage('view') != 'list'), sel = fm.selected(), move = this.move || false, empty= wz.hasClass('elfinder-cwd-wrapper-empty'), unselect = function() { requestAnimationFrame(function() { input && input.trigger('blur'); }); }, rest = function(){ if (!overlay.is(':hidden')) { overlay.elfinderoverlay('hide').off('click close', cancel); } pnode.removeClass('ui-front') .css('position', '') .off('unselect.'+fm.namespace, unselect); if (tarea) { nnode && nnode.css('max-height', ''); } else if (!tree) { pnode.css('width', '') .parent('td').css('overflow', ''); } }, colwidth, dfrd = jQuery.Deferred() .fail(function(error) { dstCls && dst.attr('class', dstCls); empty && wz.addClass('elfinder-cwd-wrapper-empty'); if (sel) { move && fm.trigger('unlockfiles', {files: sel}); fm.clipboard([]); fm.trigger('selectfiles', { files: sel }); } error && fm.error(error); }) .always(function() { rest(); cleanup(); fm.enable().unbind('open', openCallback).trigger('resMixinMake'); }), id = 'tmp_'+parseInt(Math.random()*100000), phash = this.data && this.data.target? this.data.target : (tree? fm.file(sel[0]).hash : fm.cwd().hash), date = new Date(), file = { hash : id, phash : phash, name : fm.uniqueName(this.prefix, phash), mime : this.mime, read : true, write : true, date : 'Today '+date.getHours()+':'+date.getMinutes(), move : move }, dum = fm.getUI(org).trigger('create.'+fm.namespace, file), data = this.data || {}, node = fm[find](id), nnode, pnode, overlay = fm.getUI('overlay'), cleanup = function() { if (node && node.length) { input.off(); node.hide(); fm.unselectfiles({files : [id]}).unbind('resize', resize); requestAnimationFrame(function() { if (tree) { node.closest('.elfinder-navbar-wrapper').remove(); } else { node.remove(); } }); } }, cancel = function(e) { if (!overlay.is(':hidden')) { pnode.css('z-index', ''); } if (! inError) { cleanup(); dfrd.reject(); if (e) { e.stopPropagation(); e.preventDefault(); } } }, input = jQuery(tarea? '<textarea/>' : '<input type="text"/>') .on('keyup text', function(){ if (tarea) { this.style.height = '1px'; this.style.height = this.scrollHeight + 'px'; } else if (colwidth) { this.style.width = colwidth + 'px'; if (this.scrollWidth > colwidth) { this.style.width = this.scrollWidth + 10 + 'px'; } } }) .on('keydown', function(e) { e.stopImmediatePropagation(); if (e.keyCode == jQuery.ui.keyCode.ESCAPE) { dfrd.reject(); } else if (e.keyCode == jQuery.ui.keyCode.ENTER) { e.preventDefault(); input.trigger('blur'); } }) .on('mousedown click dblclick', function(e) { e.stopPropagation(); if (e.type === 'dblclick') { e.preventDefault(); } }) .on('blur', function() { var name = jQuery.trim(input.val()), parent = input.parent(), valid = true, cut; if (!overlay.is(':hidden')) { pnode.css('z-index', ''); } if (name === '') { return cancel(); } if (!inError && parent.length) { if (fm.options.validName && fm.options.validName.test) { try { valid = fm.options.validName.test(name); } catch(e) { valid = false; } } if (!name || name === '.' || name === '..' || !valid) { inError = true; fm.error(file.mime === 'directory'? 'errInvDirname' : 'errInvName', {modal: true, close: function(){setTimeout(select, 120);}}); return false; } if (fm.fileByName(name, phash)) { inError = true; fm.error(['errExists', name], {modal: true, close: function(){setTimeout(select, 120);}}); return false; } cut = (sel && move)? fm.exec('cut', sel) : null; jQuery.when(cut) .done(function() { var toast = {}, nextAct = {}; rest(); input.hide().before(jQuery('<span>').text(name)); fm.lockfiles({files : [id]}); fm.request({ data : Object.assign({cmd : req, name : name, target : phash}, data || {}), notify : {type : req, cnt : 1}, preventFail : true, syncOnFail : true, navigate : {toast : toast}, }) .fail(function(error) { fm.unlockfiles({files : [id]}); inError = true; input.show().prev().remove(); fm.error(error, { modal: true, close: function() { if (Array.isArray(error) && jQuery.inArray('errUploadMime', error) !== -1) { dfrd.notify('errUploadMime').reject(); } else { setTimeout(select, 120); } } }); }) .done(function(data) { if (data && data.added && data.added[0]) { var item = data.added[0], dirhash = item.hash, newItem = fm[find](dirhash), acts = { 'directory' : { cmd: 'open', msg: 'cmdopendir' }, 'text' : { cmd: 'edit', msg: 'cmdedit' }, 'default' : { cmd: 'open', msg: 'cmdopen' } }, tmpMimes; if (sel && move) { fm.one(req+'done', function() { fm.exec('paste', dirhash); }); } if (!move) { if (fm.mimeIsText(item.mime) && !fm.mimesCanMakeEmpty[item.mime] && fm.mimeTypes[item.mime]) { fm.trigger('canMakeEmptyFile', {mimes: [item.mime], unshift: true}); tmpMimes = {}; tmpMimes[item.mime] = fm.mimeTypes[item.mime]; fm.storage('mkfileTextMimes', Object.assign(tmpMimes, fm.storage('mkfileTextMimes') || {})); } Object.assign(nextAct, nextAction || acts[item.mime] || acts[item.mime.split('/')[0]] || acts[(fm.mimesCanMakeEmpty[item.mime] || jQuery.inArray(item.mime, fm.resources.mimes.text) !== -1) ? 'text' : 'none'] || acts['default']); Object.assign(toast, nextAct.cmd ? { incwd : {msg: fm.i18n(['complete', fm.i18n('cmd'+cmd)]), action: nextAct}, inbuffer : {msg: fm.i18n(['complete', fm.i18n('cmd'+cmd)]), action: nextAct} } : { inbuffer : {msg: fm.i18n(['complete', fm.i18n('cmd'+cmd)])} }); } } dfrd.resolve(data); }); }) .fail(function() { dfrd.reject(); }); } }) .on('dragenter dragleave dragover drop', function(e) { // stop bubbling to prevent upload with native drop event e.stopPropagation(); }), select = function() { var name = fm.splitFileExtention(input.val())[0]; if (!inError && fm.UA.Mobile && !fm.UA.iOS) { // since iOS has a bug? (z-index not effect) so disable it overlay.on('click close', cancel).elfinderoverlay('show'); pnode.css('z-index', overlay.css('z-index') + 1); } inError = false; ! fm.enabled() && fm.enable(); input.trigger('focus').trigger('select'); input[0].setSelectionRange && input[0].setSelectionRange(0, name.length); }, resize = function() { node.trigger('scrolltoview', {blink : false}); }, openCallback = function() { dfrd && (dfrd.state() === 'pending') && dfrd.reject(); }, inError = false, nextAction, // for tree dst, dstCls, collapsed, expanded, arrow, subtree; if (!fm.isCommandEnabled(req, phash) || !node.length) { return dfrd.reject(); } if (jQuery.isPlainObject(self.nextAction)){ nextAction = Object.assign({}, self.nextAction); } if (tree) { dst = fm[find](phash); collapsed = fm.res('class', 'navcollapse'); expanded = fm.res('class', 'navexpand'); arrow = fm.res('class', 'navarrow'); subtree = fm.res('class', 'navsubtree'); node.closest('.'+subtree).show(); if (! dst.hasClass(collapsed)) { dstCls = dst.attr('class'); dst.addClass(collapsed+' '+expanded+' elfinder-subtree-loaded'); } if (dst.is('.'+collapsed+':not(.'+expanded+')')) { dst.children('.'+arrow).trigger('click').data('dfrd').done(function() { if (input.val() === file.name) { input.val(fm.uniqueName(self.prefix, phash)).trigger('select').trigger('focus'); } }); } nnode = node.contents().filter(function(){ return this.nodeType==3 && jQuery(this).parent().attr('id') === fm.navHash2Id(file.hash); }); pnode = nnode.parent(); nnode.replaceWith(input.val(file.name)); } else { empty && wz.removeClass('elfinder-cwd-wrapper-empty'); nnode = node.find('.elfinder-cwd-filename'); pnode = nnode.parent(); if (tarea) { nnode.css('max-height', 'none'); } else { colwidth = pnode.width(); pnode.width(colwidth - 15) .parent('td').css('overflow', 'visible'); } nnode.empty().append(input.val(file.name)); } pnode.addClass('ui-front') .css('position', 'relative') .on('unselect.'+fm.namespace, unselect); fm.bind('resize', resize).one('open', openCallback); input.trigger('keyup'); select(); return dfrd; } }, blink: function(elm, mode) { var acts = { slowonce : function(){elm.hide().delay(250).fadeIn(750).delay(500).fadeOut(3500);}, lookme : function(){elm.show().fadeOut(500).fadeIn(750);} }, func; mode = mode || 'slowonce'; func = acts[mode] || acts['lookme']; elm.stop(true, true); func(); } }; /* * File: /js/jquery.dialogelfinder.js */ /** * @class dialogelfinder - open elFinder in dialog window * * @param Object elFinder options with dialog options * @example * jQuery(selector).dialogelfinder({ * // some elfinder options * title : 'My files', // dialog title, default = "Files" * width : 850, // dialog width, default 840 * autoOpen : false, // if false - dialog will not be opened after init, default = true * destroyOnClose : true // destroy elFinder on close dialog, default = false * }) * @author Dmitry (dio) Levashov **/ jQuery.fn.dialogelfinder = function(opts) { var position = 'elfinderPosition', destroy = 'elfinderDestroyOnClose', node; this.not('.elfinder').each(function() { var doc = jQuery(document), toolbar = jQuery('<div class="ui-widget-header dialogelfinder-drag ui-corner-top">'+(opts.title || 'Files')+'</div>'), button = jQuery('<a href="#" class="dialogelfinder-drag-close ui-corner-all"><span class="ui-icon ui-icon-closethick"> </span></a>') .appendTo(toolbar) .on('click', function(e) { e.preventDefault(); node.dialogelfinder('close'); }), node = jQuery(this).addClass('dialogelfinder') .css('position', 'absolute') .hide() .appendTo('body') .draggable({ handle : '.dialogelfinder-drag', containment : 'window', stop : function() { node.trigger('resize'); elfinder.trigger('resize'); } }) .elfinder(opts) .prepend(toolbar), elfinder = node.elfinder('instance'); node.width(parseInt(node.width()) || 840) // fix width if set to "auto" .data(destroy, !!opts.destroyOnClose) .find('.elfinder-toolbar').removeClass('ui-corner-top'); opts.position && node.data(position, opts.position); opts.autoOpen !== false && jQuery(this).dialogelfinder('open'); }); if (opts == 'open') { var node = jQuery(this), pos = node.data(position) || { top : parseInt(jQuery(document).scrollTop() + (jQuery(window).height() < node.height() ? 2 : (jQuery(window).height() - node.height())/2)), left : parseInt(jQuery(document).scrollLeft() + (jQuery(window).width() < node.width() ? 2 : (jQuery(window).width() - node.width())/2)) }; if (node.is(':hidden')) { node.addClass('ui-front').css(pos).show().trigger('resize'); setTimeout(function() { // fix resize icon position and make elfinder active node.trigger('resize').trigger('mousedown'); }, 200); } } else if (opts == 'close') { node = jQuery(this).removeClass('ui-front'); if (node.is(':visible')) { !!node.data(destroy) ? node.elfinder('destroy').remove() : node.elfinder('close'); } } else if (opts == 'instance') { return jQuery(this).getElFinder(); } return this; }; /* * File: /js/i18n/elfinder.en.js */ /** * English translation * @author Troex Nevelin <troex@fury.scancode.ru> * @author Naoki Sawada <hypweb+elfinder@gmail.com> * @version 2018-12-09 */ // elfinder.en.js is integrated into elfinder.(full|min).js by jake build if (typeof elFinder === 'function' && elFinder.prototype.i18) { elFinder.prototype.i18.en = { translator : 'Troex Nevelin <troex@fury.scancode.ru>, Naoki Sawada <hypweb+elfinder@gmail.com>', language : 'English', direction : 'ltr', dateFormat : 'M d, Y h:i A', // will show like: Aug 24, 2018 04:39 PM fancyDateFormat : '$1 h:i A', // will show like: Today 04:39 PM nonameDateFormat : 'ymd-His', // noname upload will show like: 180824-163916 messages : { /********************************** errors **********************************/ 'error' : 'Error', 'errUnknown' : 'Unknown error.', 'errUnknownCmd' : 'Unknown command.', 'errJqui' : 'Invalid jQuery UI configuration. Selectable, draggable and droppable components must be included.', 'errNode' : 'elFinder requires DOM Element to be created.', 'errURL' : 'Invalid elFinder configuration! URL option is not set.', 'errAccess' : 'Access denied.', 'errConnect' : 'Unable to connect to backend.', 'errAbort' : 'Connection aborted.', 'errTimeout' : 'Connection timeout.', 'errNotFound' : 'Backend not found.', 'errResponse' : 'Invalid backend response.', 'errConf' : 'Invalid backend configuration.', 'errJSON' : 'PHP JSON module not installed.', 'errNoVolumes' : 'Readable volumes not available.', 'errCmdParams' : 'Invalid parameters for command "$1".', 'errDataNotJSON' : 'Data is not JSON.', 'errDataEmpty' : 'Data is empty.', 'errCmdReq' : 'Backend request requires command name.', 'errOpen' : 'Unable to open "$1".', 'errNotFolder' : 'Object is not a folder.', 'errNotFile' : 'Object is not a file.', 'errRead' : 'Unable to read "$1".', 'errWrite' : 'Unable to write into "$1".', 'errPerm' : 'Permission denied.', 'errLocked' : '"$1" is locked and can not be renamed, moved or removed.', 'errExists' : 'Item named "$1" already exists.', 'errInvName' : 'Invalid file name.', 'errInvDirname' : 'Invalid folder name.', // from v2.1.24 added 12.4.2017 'errFolderNotFound' : 'Folder not found.', 'errFileNotFound' : 'File not found.', 'errTrgFolderNotFound' : 'Target folder "$1" not found.', 'errPopup' : 'Browser prevented opening popup window. To open file enable it in browser options.', 'errMkdir' : 'Unable to create folder "$1".', 'errMkfile' : 'Unable to create file "$1".', 'errRename' : 'Unable to rename "$1".', 'errCopyFrom' : 'Copying files from volume "$1" not allowed.', 'errCopyTo' : 'Copying files to volume "$1" not allowed.', 'errMkOutLink' : 'Unable to create a link to outside the volume root.', // from v2.1 added 03.10.2015 'errUpload' : 'Upload error.', // old name - errUploadCommon 'errUploadFile' : 'Unable to upload "$1".', // old name - errUpload 'errUploadNoFiles' : 'No files found for upload.', 'errUploadTotalSize' : 'Data exceeds the maximum allowed size.', // old name - errMaxSize 'errUploadFileSize' : 'File exceeds maximum allowed size.', // old name - errFileMaxSize 'errUploadMime' : 'File type not allowed.', 'errUploadTransfer' : '"$1" transfer error.', 'errUploadTemp' : 'Unable to make temporary file for upload.', // from v2.1 added 26.09.2015 'errNotReplace' : 'Object "$1" already exists at this location and can not be replaced by object with another type.', // new 'errReplace' : 'Unable to replace "$1".', 'errSave' : 'Unable to save "$1".', 'errCopy' : 'Unable to copy "$1".', 'errMove' : 'Unable to move "$1".', 'errCopyInItself' : 'Unable to copy "$1" into itself.', 'errRm' : 'Unable to remove "$1".', 'errTrash' : 'Unable into trash.', // from v2.1.24 added 30.4.2017 'errRmSrc' : 'Unable remove source file(s).', 'errExtract' : 'Unable to extract files from "$1".', 'errArchive' : 'Unable to create archive.', 'errArcType' : 'Unsupported archive type.', 'errNoArchive' : 'File is not archive or has unsupported archive type.', 'errCmdNoSupport' : 'Backend does not support this command.', 'errReplByChild' : 'The folder "$1" can\'t be replaced by an item it contains.', 'errArcSymlinks' : 'For security reason denied to unpack archives contains symlinks or files with not allowed names.', // edited 24.06.2012 'errArcMaxSize' : 'Archive files exceeds maximum allowed size.', 'errResize' : 'Unable to resize "$1".', 'errResizeDegree' : 'Invalid rotate degree.', // added 7.3.2013 'errResizeRotate' : 'Unable to rotate image.', // added 7.3.2013 'errResizeSize' : 'Invalid image size.', // added 7.3.2013 'errResizeNoChange' : 'Image size not changed.', // added 7.3.2013 'errUsupportType' : 'Unsupported file type.', 'errNotUTF8Content' : 'File "$1" is not in UTF-8 and cannot be edited.', // added 9.11.2011 'errNetMount' : 'Unable to mount "$1".', // added 17.04.2012 'errNetMountNoDriver' : 'Unsupported protocol.', // added 17.04.2012 'errNetMountFailed' : 'Mount failed.', // added 17.04.2012 'errNetMountHostReq' : 'Host required.', // added 18.04.2012 'errSessionExpires' : 'Your session has expired due to inactivity.', 'errCreatingTempDir' : 'Unable to create temporary directory: "$1"', 'errFtpDownloadFile' : 'Unable to download file from FTP: "$1"', 'errFtpUploadFile' : 'Unable to upload file to FTP: "$1"', 'errFtpMkdir' : 'Unable to create remote directory on FTP: "$1"', 'errArchiveExec' : 'Error while archiving files: "$1"', 'errExtractExec' : 'Error while extracting files: "$1"', 'errNetUnMount' : 'Unable to unmount.', // from v2.1 added 30.04.2012 'errConvUTF8' : 'Not convertible to UTF-8', // from v2.1 added 08.04.2014 'errFolderUpload' : 'Try the modern browser, If you\'d like to upload the folder.', // from v2.1 added 26.6.2015 'errSearchTimeout' : 'Timed out while searching "$1". Search result is partial.', // from v2.1 added 12.1.2016 'errReauthRequire' : 'Re-authorization is required.', // from v2.1.10 added 24.3.2016 'errMaxTargets' : 'Max number of selectable items is $1.', // from v2.1.17 added 17.10.2016 'errRestore' : 'Unable to restore from the trash. Can\'t identify the restore destination.', // from v2.1.24 added 3.5.2017 'errEditorNotFound' : 'Editor not found to this file type.', // from v2.1.25 added 23.5.2017 'errServerError' : 'Error occurred on the server side.', // from v2.1.25 added 16.6.2017 'errEmpty' : 'Unable to empty folder "$1".', // from v2.1.25 added 22.6.2017 'moreErrors' : 'There are $1 more errors.', // from v2.1.44 added 9.12.2018 /******************************* commands names ********************************/ 'cmdarchive' : 'Create archive', 'cmdback' : 'Back', 'cmdcopy' : 'Copy', 'cmdcut' : 'Cut', 'cmddownload' : 'Download', 'cmdduplicate' : 'Duplicate', 'cmdedit' : 'Edit file', 'cmdextract' : 'Extract files from archive', 'cmdforward' : 'Forward', 'cmdgetfile' : 'Select files', 'cmdhelp' : 'About this software', 'cmdhome' : 'Root', 'cmdinfo' : 'Get info & Share', 'cmdmkdir' : 'New folder', 'cmdmkdirin' : 'Into New Folder', // from v2.1.7 added 19.2.2016 'cmdmkfile' : 'New file', 'cmdopen' : 'Open', 'cmdpaste' : 'Paste', 'cmdquicklook' : 'Preview', 'cmdreload' : 'Reload', 'cmdrename' : 'Rename', 'cmdrm' : 'Delete', 'cmdtrash' : 'Into trash', //from v2.1.24 added 29.4.2017 'cmdrestore' : 'Restore', //from v2.1.24 added 3.5.2017 'cmdsearch' : 'Find files', 'cmdup' : 'Go to parent folder', 'cmdupload' : 'Upload files', 'cmdview' : 'View', 'cmdresize' : 'Resize & Rotate', 'cmdsort' : 'Sort', 'cmdnetmount' : 'Mount network volume', // added 18.04.2012 'cmdnetunmount': 'Unmount', // from v2.1 added 30.04.2012 'cmdplaces' : 'To Places', // added 28.12.2014 'cmdchmod' : 'Change mode', // from v2.1 added 20.6.2015 'cmdopendir' : 'Open a folder', // from v2.1 added 13.1.2016 'cmdcolwidth' : 'Reset column width', // from v2.1.13 added 12.06.2016 'cmdfullscreen': 'Full Screen', // from v2.1.15 added 03.08.2016 'cmdmove' : 'Move', // from v2.1.15 added 21.08.2016 'cmdempty' : 'Empty the folder', // from v2.1.25 added 22.06.2017 'cmdundo' : 'Undo', // from v2.1.27 added 31.07.2017 'cmdredo' : 'Redo', // from v2.1.27 added 31.07.2017 'cmdpreference': 'Preferences', // from v2.1.27 added 03.08.2017 'cmdselectall' : 'Select all', // from v2.1.28 added 15.08.2017 'cmdselectnone': 'Select none', // from v2.1.28 added 15.08.2017 'cmdselectinvert': 'Invert selection', // from v2.1.28 added 15.08.2017 'cmdopennew' : 'Open in new window', // from v2.1.38 added 3.4.2018 'cmdhide' : 'Hide (Preference)', // from v2.1.41 added 24.7.2018 /*********************************** buttons ***********************************/ 'btnClose' : 'Close', 'btnSave' : 'Save', 'btnRm' : 'Remove', 'btnApply' : 'Apply', 'btnCancel' : 'Cancel', 'btnNo' : 'No', 'btnYes' : 'Yes', 'btnMount' : 'Mount', // added 18.04.2012 'btnApprove': 'Goto $1 & approve', // from v2.1 added 26.04.2012 'btnUnmount': 'Unmount', // from v2.1 added 30.04.2012 'btnConv' : 'Convert', // from v2.1 added 08.04.2014 'btnCwd' : 'Here', // from v2.1 added 22.5.2015 'btnVolume' : 'Volume', // from v2.1 added 22.5.2015 'btnAll' : 'All', // from v2.1 added 22.5.2015 'btnMime' : 'MIME Type', // from v2.1 added 22.5.2015 'btnFileName':'Filename', // from v2.1 added 22.5.2015 'btnSaveClose': 'Save & Close', // from v2.1 added 12.6.2015 'btnBackup' : 'Backup', // fromv2.1 added 28.11.2015 'btnRename' : 'Rename', // from v2.1.24 added 6.4.2017 'btnRenameAll' : 'Rename(All)', // from v2.1.24 added 6.4.2017 'btnPrevious' : 'Prev ($1/$2)', // from v2.1.24 added 11.5.2017 'btnNext' : 'Next ($1/$2)', // from v2.1.24 added 11.5.2017 'btnSaveAs' : 'Save As', // from v2.1.25 added 24.5.2017 /******************************** notifications ********************************/ 'ntfopen' : 'Open folder', 'ntffile' : 'Open file', 'ntfreload' : 'Reload folder content', 'ntfmkdir' : 'Creating folder', 'ntfmkfile' : 'Creating files', 'ntfrm' : 'Delete items', 'ntfcopy' : 'Copy items', 'ntfmove' : 'Move items', 'ntfprepare' : 'Checking existing items', 'ntfrename' : 'Rename files', 'ntfupload' : 'Uploading files', 'ntfdownload' : 'Downloading files', 'ntfsave' : 'Save files', 'ntfarchive' : 'Creating archive', 'ntfextract' : 'Extracting files from archive', 'ntfsearch' : 'Searching files', 'ntfresize' : 'Resizing images', 'ntfsmth' : 'Doing something', 'ntfloadimg' : 'Loading image', 'ntfnetmount' : 'Mounting network volume', // added 18.04.2012 'ntfnetunmount': 'Unmounting network volume', // from v2.1 added 30.04.2012 'ntfdim' : 'Acquiring image dimension', // added 20.05.2013 'ntfreaddir' : 'Reading folder infomation', // from v2.1 added 01.07.2013 'ntfurl' : 'Getting URL of link', // from v2.1 added 11.03.2014 'ntfchmod' : 'Changing file mode', // from v2.1 added 20.6.2015 'ntfpreupload': 'Verifying upload file name', // from v2.1 added 31.11.2015 'ntfzipdl' : 'Creating a file for download', // from v2.1.7 added 23.1.2016 'ntfparents' : 'Getting path infomation', // from v2.1.17 added 2.11.2016 'ntfchunkmerge': 'Processing the uploaded file', // from v2.1.17 added 2.11.2016 'ntftrash' : 'Doing throw in the trash', // from v2.1.24 added 2.5.2017 'ntfrestore' : 'Doing restore from the trash', // from v2.1.24 added 3.5.2017 'ntfchkdir' : 'Checking destination folder', // from v2.1.24 added 3.5.2017 'ntfundo' : 'Undoing previous operation', // from v2.1.27 added 31.07.2017 'ntfredo' : 'Redoing previous undone', // from v2.1.27 added 31.07.2017 'ntfchkcontent' : 'Checking contents', // from v2.1.41 added 3.8.2018 /*********************************** volumes *********************************/ 'volume_Trash' : 'Trash', //from v2.1.24 added 29.4.2017 /************************************ dates **********************************/ 'dateUnknown' : 'unknown', 'Today' : 'Today', 'Yesterday' : 'Yesterday', 'msJan' : 'Jan', 'msFeb' : 'Feb', 'msMar' : 'Mar', 'msApr' : 'Apr', 'msMay' : 'May', 'msJun' : 'Jun', 'msJul' : 'Jul', 'msAug' : 'Aug', 'msSep' : 'Sep', 'msOct' : 'Oct', 'msNov' : 'Nov', 'msDec' : 'Dec', 'January' : 'January', 'February' : 'February', 'March' : 'March', 'April' : 'April', 'May' : 'May', 'June' : 'June', 'July' : 'July', 'August' : 'August', 'September' : 'September', 'October' : 'October', 'November' : 'November', 'December' : 'December', 'Sunday' : 'Sunday', 'Monday' : 'Monday', 'Tuesday' : 'Tuesday', 'Wednesday' : 'Wednesday', 'Thursday' : 'Thursday', 'Friday' : 'Friday', 'Saturday' : 'Saturday', 'Sun' : 'Sun', 'Mon' : 'Mon', 'Tue' : 'Tue', 'Wed' : 'Wed', 'Thu' : 'Thu', 'Fri' : 'Fri', 'Sat' : 'Sat', /******************************** sort variants ********************************/ 'sortname' : 'by name', 'sortkind' : 'by kind', 'sortsize' : 'by size', 'sortdate' : 'by date', 'sortFoldersFirst' : 'Folders first', 'sortperm' : 'by permission', // from v2.1.13 added 13.06.2016 'sortmode' : 'by mode', // from v2.1.13 added 13.06.2016 'sortowner' : 'by owner', // from v2.1.13 added 13.06.2016 'sortgroup' : 'by group', // from v2.1.13 added 13.06.2016 'sortAlsoTreeview' : 'Also Treeview', // from v2.1.15 added 01.08.2016 /********************************** new items **********************************/ 'untitled file.txt' : 'NewFile.txt', // added 10.11.2015 'untitled folder' : 'NewFolder', // added 10.11.2015 'Archive' : 'NewArchive', // from v2.1 added 10.11.2015 'untitled file' : 'NewFile.$1', // from v2.1.41 added 6.8.2018 'extentionfile' : '$1: File', // from v2.1.41 added 6.8.2018 'extentiontype' : '$1: $2', // from v2.1.43 added 17.10.2018 /********************************** messages **********************************/ 'confirmReq' : 'Confirmation required', 'confirmRm' : 'Are you sure you want to permanently remove items?<br/>This cannot be undone!', 'confirmRepl' : 'Replace old file with new one? (If it contains folders, it will be merged. To backup and replace, select Backup.)', 'confirmRest' : 'Replace existing item with the item in trash?', // fromv2.1.24 added 5.5.2017 'confirmConvUTF8' : 'Not in UTF-8<br/>Convert to UTF-8?<br/>Contents become UTF-8 by saving after conversion.', // from v2.1 added 08.04.2014 'confirmNonUTF8' : 'Character encoding of this file couldn\'t be detected. It need to temporarily convert to UTF-8 for editting.<br/>Please select character encoding of this file.', // from v2.1.19 added 28.11.2016 'confirmNotSave' : 'It has been modified.<br/>Losing work if you do not save changes.', // from v2.1 added 15.7.2015 'confirmTrash' : 'Are you sure you want to move items to trash bin?', //from v2.1.24 added 29.4.2017 'apllyAll' : 'Apply to all', 'name' : 'Name', 'size' : 'Size', 'perms' : 'Permissions', 'modify' : 'Modified', 'kind' : 'Kind', 'read' : 'read', 'write' : 'write', 'noaccess' : 'no access', 'and' : 'and', 'unknown' : 'unknown', 'selectall' : 'Select all items', 'selectfiles' : 'Select item(s)', 'selectffile' : 'Select first item', 'selectlfile' : 'Select last item', 'viewlist' : 'List view', 'viewicons' : 'Icons view', 'viewSmall' : 'Small icons', // from v2.1.39 added 22.5.2018 'viewMedium' : 'Medium icons', // from v2.1.39 added 22.5.2018 'viewLarge' : 'Large icons', // from v2.1.39 added 22.5.2018 'viewExtraLarge' : 'Extra large icons', // from v2.1.39 added 22.5.2018 'places' : 'Places', 'calc' : 'Calculate', 'path' : 'Path', 'aliasfor' : 'Alias for', 'locked' : 'Locked', 'dim' : 'Dimensions', 'files' : 'Files', 'folders' : 'Folders', 'items' : 'Items', 'yes' : 'yes', 'no' : 'no', 'link' : 'Link', 'searcresult' : 'Search results', 'selected' : 'selected items', 'about' : 'About', 'shortcuts' : 'Shortcuts', 'help' : 'Help', 'webfm' : 'Web file manager', 'ver' : 'Version', 'protocolver' : 'protocol version', 'homepage' : 'Project home', 'docs' : 'Documentation', 'github' : 'Fork us on GitHub', 'twitter' : 'Follow us on Twitter', 'facebook' : 'Join us on Facebook', 'team' : 'Team', 'chiefdev' : 'chief developer', 'developer' : 'developer', 'contributor' : 'contributor', 'maintainer' : 'maintainer', 'translator' : 'translator', 'icons' : 'Icons', 'dontforget' : 'and don\'t forget to take your towel', 'shortcutsof' : 'Shortcuts disabled', 'dropFiles' : 'Drop files here', 'or' : 'or', 'selectForUpload' : 'Select files', 'moveFiles' : 'Move items', 'copyFiles' : 'Copy items', 'restoreFiles' : 'Restore items', // from v2.1.24 added 5.5.2017 'rmFromPlaces' : 'Remove from places', 'aspectRatio' : 'Aspect ratio', 'scale' : 'Scale', 'width' : 'Width', 'height' : 'Height', 'resize' : 'Resize', 'crop' : 'Crop', 'rotate' : 'Rotate', 'rotate-cw' : 'Rotate 90 degrees CW', 'rotate-ccw' : 'Rotate 90 degrees CCW', 'degree' : '°', 'netMountDialogTitle' : 'Mount network volume', // added 18.04.2012 'protocol' : 'Protocol', // added 18.04.2012 'host' : 'Host', // added 18.04.2012 'port' : 'Port', // added 18.04.2012 'user' : 'User', // added 18.04.2012 'pass' : 'Password', // added 18.04.2012 'confirmUnmount' : 'Are you sure to unmount $1?', // from v2.1 added 30.04.2012 'dropFilesBrowser': 'Drop or Paste files from browser', // from v2.1 added 30.05.2012 'dropPasteFiles' : 'Drop files, Paste URLs or images(clipboard) here', // from v2.1 added 07.04.2014 'encoding' : 'Encoding', // from v2.1 added 19.12.2014 'locale' : 'Locale', // from v2.1 added 19.12.2014 'searchTarget' : 'Target: $1', // from v2.1 added 22.5.2015 'searchMime' : 'Search by input MIME Type', // from v2.1 added 22.5.2015 'owner' : 'Owner', // from v2.1 added 20.6.2015 'group' : 'Group', // from v2.1 added 20.6.2015 'other' : 'Other', // from v2.1 added 20.6.2015 'execute' : 'Execute', // from v2.1 added 20.6.2015 'perm' : 'Permission', // from v2.1 added 20.6.2015 'mode' : 'Mode', // from v2.1 added 20.6.2015 'emptyFolder' : 'Folder is empty', // from v2.1.6 added 30.12.2015 'emptyFolderDrop' : 'Folder is empty\\A Drop to add items', // from v2.1.6 added 30.12.2015 'emptyFolderLTap' : 'Folder is empty\\A Long tap to add items', // from v2.1.6 added 30.12.2015 'quality' : 'Quality', // from v2.1.6 added 5.1.2016 'autoSync' : 'Auto sync', // from v2.1.6 added 10.1.2016 'moveUp' : 'Move up', // from v2.1.6 added 18.1.2016 'getLink' : 'Get URL link', // from v2.1.7 added 9.2.2016 'selectedItems' : 'Selected items ($1)', // from v2.1.7 added 2.19.2016 'folderId' : 'Folder ID', // from v2.1.10 added 3.25.2016 'offlineAccess' : 'Allow offline access', // from v2.1.10 added 3.25.2016 'reAuth' : 'To re-authenticate', // from v2.1.10 added 3.25.2016 'nowLoading' : 'Now loading...', // from v2.1.12 added 4.26.2016 'openMulti' : 'Open multiple files', // from v2.1.12 added 5.14.2016 'openMultiConfirm': 'You are trying to open the $1 files. Are you sure you want to open in browser?', // from v2.1.12 added 5.14.2016 'emptySearch' : 'Search results is empty in search target.', // from v2.1.12 added 5.16.2016 'editingFile' : 'It is editing a file.', // from v2.1.13 added 6.3.2016 'hasSelected' : 'You have selected $1 items.', // from v2.1.13 added 6.3.2016 'hasClipboard' : 'You have $1 items in the clipboard.', // from v2.1.13 added 6.3.2016 'incSearchOnly' : 'Incremental search is only from the current view.', // from v2.1.13 added 6.30.2016 'reinstate' : 'Reinstate', // from v2.1.15 added 3.8.2016 'complete' : '$1 complete', // from v2.1.15 added 21.8.2016 'contextmenu' : 'Context menu', // from v2.1.15 added 9.9.2016 'pageTurning' : 'Page turning', // from v2.1.15 added 10.9.2016 'volumeRoots' : 'Volume roots', // from v2.1.16 added 16.9.2016 'reset' : 'Reset', // from v2.1.16 added 1.10.2016 'bgcolor' : 'Background color', // from v2.1.16 added 1.10.2016 'colorPicker' : 'Color picker', // from v2.1.16 added 1.10.2016 '8pxgrid' : '8px Grid', // from v2.1.16 added 4.10.2016 'enabled' : 'Enabled', // from v2.1.16 added 4.10.2016 'disabled' : 'Disabled', // from v2.1.16 added 4.10.2016 'emptyIncSearch' : 'Search results is empty in current view.\\A Press [Enter] to expand search target.', // from v2.1.16 added 5.10.2016 'emptyLetSearch' : 'First letter search results is empty in current view.', // from v2.1.23 added 24.3.2017 'textLabel' : 'Text label', // from v2.1.17 added 13.10.2016 'minsLeft' : '$1 mins left', // from v2.1.17 added 13.11.2016 'openAsEncoding' : 'Reopen with selected encoding', // from v2.1.19 added 2.12.2016 'saveAsEncoding' : 'Save with the selected encoding', // from v2.1.19 added 2.12.2016 'selectFolder' : 'Select folder', // from v2.1.20 added 13.12.2016 'firstLetterSearch': 'First letter search', // from v2.1.23 added 24.3.2017 'presets' : 'Presets', // from v2.1.25 added 26.5.2017 'tooManyToTrash' : 'It\'s too many items so it can\'t into trash.', // from v2.1.25 added 9.6.2017 'TextArea' : 'TextArea', // from v2.1.25 added 14.6.2017 'folderToEmpty' : 'Empty the folder "$1".', // from v2.1.25 added 22.6.2017 'filderIsEmpty' : 'There are no items in a folder "$1".', // from v2.1.25 added 22.6.2017 'preference' : 'Preference', // from v2.1.26 added 28.6.2017 'language' : 'Language', // from v2.1.26 added 28.6.2017 'clearBrowserData': 'Initialize the settings saved in this browser', // from v2.1.26 added 28.6.2017 'toolbarPref' : 'Toolbar settings', // from v2.1.27 added 2.8.2017 'charsLeft' : '... $1 chars left.', // from v2.1.29 added 30.8.2017 'sum' : 'Sum', // from v2.1.29 added 28.9.2017 'roughFileSize' : 'Rough file size', // from v2.1.30 added 2.11.2017 'autoFocusDialog' : 'Focus on the element of dialog with mouseover', // from v2.1.30 added 2.11.2017 'select' : 'Select', // from v2.1.30 added 23.11.2017 'selectAction' : 'Action when select file', // from v2.1.30 added 23.11.2017 'useStoredEditor' : 'Open with the editor used last time', // from v2.1.30 added 23.11.2017 'selectinvert' : 'Invert selection', // from v2.1.30 added 25.11.2017 'renameMultiple' : 'Are you sure you want to rename $1 selected items like $2?<br/>This cannot be undone!', // from v2.1.31 added 4.12.2017 'batchRename' : 'Batch rename', // from v2.1.31 added 8.12.2017 'plusNumber' : '+ Number', // from v2.1.31 added 8.12.2017 'asPrefix' : 'Add prefix', // from v2.1.31 added 8.12.2017 'asSuffix' : 'Add suffix', // from v2.1.31 added 8.12.2017 'changeExtention' : 'Change extention', // from v2.1.31 added 8.12.2017 'columnPref' : 'Columns settings (List view)', // from v2.1.32 added 6.2.2018 'reflectOnImmediate' : 'All changes will reflect immediately to the archive.', // from v2.1.33 added 2.3.2018 'reflectOnUnmount' : 'Any changes will not reflect until un-mount this volume.', // from v2.1.33 added 2.3.2018 'unmountChildren' : 'The following volume(s) mounted on this volume also unmounted. Are you sure to unmount it?', // from v2.1.33 added 5.3.2018 'selectionInfo' : 'Selection Info', // from v2.1.33 added 7.3.2018 'hashChecker' : 'Algorithms to show the file hash', // from v2.1.33 added 10.3.2018 'infoItems' : 'Info Items (Selection Info Panel)', // from v2.1.38 added 28.3.2018 'pressAgainToExit': 'Press again to exit.', // from v2.1.38 added 1.4.2018 'toolbar' : 'Toolbar', // from v2.1.38 added 4.4.2018 'workspace' : 'Work Space', // from v2.1.38 added 4.4.2018 'dialog' : 'Dialog', // from v2.1.38 added 4.4.2018 'all' : 'All', // from v2.1.38 added 4.4.2018 'iconSize' : 'Icon Size (Icons view)', // from v2.1.39 added 7.5.2018 'editorMaximized' : 'Open the maximized editor window', // from v2.1.40 added 30.6.2018 'editorConvNoApi' : 'Because conversion by API is not currently available, please convert on the website.', //from v2.1.40 added 8.7.2018 'editorConvNeedUpload' : 'After conversion, you must be upload with the item URL or a downloaded file to save the converted file.', //from v2.1.40 added 8.7.2018 'convertOn' : 'Convert on the site of $1', // from v2.1.40 added 10.7.2018 'integrations' : 'Integrations', // from v2.1.40 added 11.7.2018 'integrationWith' : 'This elFinder has the following external services integrated. Please check the terms of use, privacy policy, etc. before using it.', // from v2.1.40 added 11.7.2018 'showHidden' : 'Show hidden items', // from v2.1.41 added 24.7.2018 'hideHidden' : 'Hide hidden items', // from v2.1.41 added 24.7.2018 'toggleHidden' : 'Show/Hide hidden items', // from v2.1.41 added 24.7.2018 'makefileTypes' : 'File types to enable with "New file"', // from v2.1.41 added 7.8.2018 'typeOfTextfile' : 'Type of the Text file', // from v2.1.41 added 7.8.2018 'add' : 'Add', // from v2.1.41 added 7.8.2018 'theme' : 'Theme', // from v2.1.43 added 19.10.2018 'default' : 'Default', // from v2.1.43 added 19.10.2018 'description' : 'Description', // from v2.1.43 added 19.10.2018 'website' : 'Website', // from v2.1.43 added 19.10.2018 'author' : 'Author', // from v2.1.43 added 19.10.2018 'email' : 'Email', // from v2.1.43 added 19.10.2018 'license' : 'License', // from v2.1.43 added 19.10.2018 'exportToSave' : 'This item can\'t be saved. To avoid losing the edits you need to export to your PC.', // from v2.1.44 added 1.12.2018 /********************************** mimetypes **********************************/ 'kindUnknown' : 'Unknown', 'kindRoot' : 'Volume Root', // from v2.1.16 added 16.10.2016 'kindFolder' : 'Folder', 'kindSelects' : 'Selections', // from v2.1.29 added 29.8.2017 'kindAlias' : 'Alias', 'kindAliasBroken' : 'Broken alias', // applications 'kindApp' : 'Application', 'kindPostscript' : 'Postscript document', 'kindMsOffice' : 'Microsoft Office document', 'kindMsWord' : 'Microsoft Word document', 'kindMsExcel' : 'Microsoft Excel document', 'kindMsPP' : 'Microsoft Powerpoint presentation', 'kindOO' : 'Open Office document', 'kindAppFlash' : 'Flash application', 'kindPDF' : 'Portable Document Format (PDF)', 'kindTorrent' : 'Bittorrent file', 'kind7z' : '7z archive', 'kindTAR' : 'TAR archive', 'kindGZIP' : 'GZIP archive', 'kindBZIP' : 'BZIP archive', 'kindXZ' : 'XZ archive', 'kindZIP' : 'ZIP archive', 'kindRAR' : 'RAR archive', 'kindJAR' : 'Java JAR file', 'kindTTF' : 'True Type font', 'kindOTF' : 'Open Type font', 'kindRPM' : 'RPM package', // texts 'kindText' : 'Text document', 'kindTextPlain' : 'Plain text', 'kindPHP' : 'PHP source', 'kindCSS' : 'Cascading style sheet', 'kindHTML' : 'HTML document', 'kindJS' : 'Javascript source', 'kindRTF' : 'Rich Text Format', 'kindC' : 'C source', 'kindCHeader' : 'C header source', 'kindCPP' : 'C++ source', 'kindCPPHeader' : 'C++ header source', 'kindShell' : 'Unix shell script', 'kindPython' : 'Python source', 'kindJava' : 'Java source', 'kindRuby' : 'Ruby source', 'kindPerl' : 'Perl script', 'kindSQL' : 'SQL source', 'kindXML' : 'XML document', 'kindAWK' : 'AWK source', 'kindCSV' : 'Comma separated values', 'kindDOCBOOK' : 'Docbook XML document', 'kindMarkdown' : 'Markdown text', // added 20.7.2015 // images 'kindImage' : 'Image', 'kindBMP' : 'BMP image', 'kindJPEG' : 'JPEG image', 'kindGIF' : 'GIF Image', 'kindPNG' : 'PNG Image', 'kindTIFF' : 'TIFF image', 'kindTGA' : 'TGA image', 'kindPSD' : 'Adobe Photoshop image', 'kindXBITMAP' : 'X bitmap image', 'kindPXM' : 'Pixelmator image', // media 'kindAudio' : 'Audio media', 'kindAudioMPEG' : 'MPEG audio', 'kindAudioMPEG4' : 'MPEG-4 audio', 'kindAudioMIDI' : 'MIDI audio', 'kindAudioOGG' : 'Ogg Vorbis audio', 'kindAudioWAV' : 'WAV audio', 'AudioPlaylist' : 'MP3 playlist', 'kindVideo' : 'Video media', 'kindVideoDV' : 'DV movie', 'kindVideoMPEG' : 'MPEG movie', 'kindVideoMPEG4' : 'MPEG-4 movie', 'kindVideoAVI' : 'AVI movie', 'kindVideoMOV' : 'Quick Time movie', 'kindVideoWM' : 'Windows Media movie', 'kindVideoFlash' : 'Flash movie', 'kindVideoMKV' : 'Matroska movie', 'kindVideoOGG' : 'Ogg movie' } }; } /* * File: /js/ui/button.js */ /** * @class elFinder toolbar button widget. * If command has variants - create menu * * @author Dmitry (dio) Levashov **/ jQuery.fn.elfinderbutton = function(cmd) { return this.each(function() { var c = 'class', fm = cmd.fm, disabled = fm.res(c, 'disabled'), active = fm.res(c, 'active'), hover = fm.res(c, 'hover'), item = 'elfinder-button-menu-item', selected = 'elfinder-button-menu-item-selected', menu, text = jQuery('<span class="elfinder-button-text">'+cmd.title+'</span>'), prvCname = 'elfinder-button-icon-' + (cmd.className? cmd.className : cmd.name), button = jQuery(this).addClass('ui-state-default elfinder-button') .attr('title', cmd.title) .append('<span class="elfinder-button-icon ' + prvCname + '"/>', text) .on('mouseenter mouseleave', function(e) { !button.hasClass(disabled) && button[e.type == 'mouseleave' ? 'removeClass' : 'addClass'](hover);}) .on('click', function(e) { if (!button.hasClass(disabled)) { if (menu && cmd.variants.length >= 1) { // close other menus menu.is(':hidden') && fm.getUI().click(); e.stopPropagation(); menu.css(getMenuOffset()).slideToggle({ duration: 100, done: function(e) { fm[menu.is(':visible')? 'toFront' : 'toHide'](menu); } }); } else { fm.exec(cmd.name, getSelected(), {_userAction: true, _currentType: 'toolbar', _currentNode: button }); } } }), hideMenu = function() { fm.toHide(menu); }, getMenuOffset = function() { var fmNode = fm.getUI(), baseOffset = fmNode.offset(), buttonOffset = button.offset(); return { top : buttonOffset.top - baseOffset.top, left : buttonOffset.left - baseOffset.left, maxHeight : fmNode.height() - 40 }; }, getSelected = function() { var sel = fm.selected(), cwd; if (!sel.length) { if (cwd = fm.cwd()) { sel = [ fm.cwd().hash ]; } else { sel = void(0); } } return sel; }, tm; text.hide(); // set self button object to cmd object cmd.button = button; // if command has variants create menu if (Array.isArray(cmd.variants)) { button.addClass('elfinder-menubutton'); menu = jQuery('<div class="ui-front ui-widget ui-widget-content elfinder-button-menu ui-corner-all"/>') .hide() .appendTo(fm.getUI()) .on('mouseenter mouseleave', '.'+item, function() { jQuery(this).toggleClass(hover); }) .on('click', '.'+item, function(e) { var opts = jQuery(this).data('value'); e.preventDefault(); e.stopPropagation(); button.removeClass(hover); fm.toHide(menu); if (typeof opts === 'undefined') { opts = {}; } if (typeof opts === 'object') { opts._userAction = true; } fm.exec(cmd.name, getSelected(), opts); }) .on('close', hideMenu); fm.bind('disable select', hideMenu).getUI().on('click', hideMenu); cmd.change(function() { menu.html(''); jQuery.each(cmd.variants, function(i, variant) { menu.append(jQuery('<div class="'+item+'">'+variant[1]+'</div>').data('value', variant[0]).addClass(variant[0] == cmd.value ? selected : '')); }); }); } cmd.change(function() { var cName; tm && cancelAnimationFrame(tm); tm = requestAnimationFrame(function() { if (cmd.disabled()) { button.removeClass(active+' '+hover).addClass(disabled); } else { button.removeClass(disabled); button[cmd.active() ? 'addClass' : 'removeClass'](active); } if (cmd.syncTitleOnChange) { cName = 'elfinder-button-icon-' + (cmd.className? cmd.className : cmd.name); if (prvCname !== cName) { button.children('.elfinder-button-icon').removeClass(prvCname).addClass(cName); prvCname = cName; } text.html(cmd.title); button.attr('title', cmd.title); } }); }) .change(); }); }; /* * File: /js/ui/contextmenu.js */ /** * @class elFinder contextmenu * * @author Dmitry (dio) Levashov **/ jQuery.fn.elfindercontextmenu = function(fm) { return this.each(function() { var self = jQuery(this), cmItem = 'elfinder-contextmenu-item', smItem = 'elfinder-contextsubmenu-item', exIcon = 'elfinder-contextmenu-extra-icon', cHover = fm.res('class', 'hover'), dragOpt = { distance: 8, start: function() { menu.data('drag', true).data('touching') && menu.find('.'+cHover).removeClass(cHover); }, stop: function() { menu.data('draged', true).removeData('drag'); } }, menu = jQuery(this).addClass('touch-punch ui-helper-reset ui-front ui-widget ui-state-default ui-corner-all elfinder-contextmenu elfinder-contextmenu-'+fm.direction) .hide() .on('touchstart', function(e) { menu.data('touching', true).children().removeClass(cHover); }) .on('touchend', function(e) { menu.removeData('touching'); }) .on('mouseenter mouseleave', '.'+cmItem, function(e) { jQuery(this).toggleClass(cHover, (e.type === 'mouseenter' || (! menu.data('draged') && menu.data('submenuKeep'))? true : false)); if (menu.data('draged') && menu.data('submenuKeep')) { menu.find('.elfinder-contextmenu-sub:visible').parent().addClass(cHover); } }) .on('mouseenter mouseleave', '.'+exIcon, function(e) { jQuery(this).parent().toggleClass(cHover, e.type === 'mouseleave'); }) .on('mouseenter mouseleave', '.'+cmItem+',.'+smItem, function(e) { var setIndex = function(target, sub) { jQuery.each(sub? subnodes : nodes, function(i, n) { if (target[0] === n) { (sub? subnodes : nodes)._cur = i; if (sub) { subselected = target; } else { selected = target; } return false; } }); }; if (e.originalEvent) { var target = jQuery(this), unHover = function() { if (selected && !selected.children('div.elfinder-contextmenu-sub:visible').length) { selected.removeClass(cHover); } }; if (e.type === 'mouseenter') { // mouseenter if (target.hasClass(smItem)) { // submenu if (subselected) { subselected.removeClass(cHover); } if (selected) { subnodes = selected.find('div.'+smItem); } setIndex(target, true); } else { // menu unHover(); setIndex(target); } } else { // mouseleave if (target.hasClass(smItem)) { //submenu subselected = null; subnodes = null; } else { // menu unHover(); (function(sel) { setTimeout(function() { if (sel === selected) { selected = null; } }, 250); })(selected); } } } }) .on('contextmenu', function(){return false;}) .on('mouseup', function() { setTimeout(function() { menu.removeData('draged'); }, 100); }) .draggable(dragOpt), ltr = fm.direction === 'ltr', subpos = ltr? 'left' : 'right', types = Object.assign({}, fm.options.contextmenu), tpl = '<div class="'+cmItem+'{className}"><span class="elfinder-button-icon {icon} elfinder-contextmenu-icon"{style}/><span>{label}</span></div>', item = function(label, icon, callback, opts) { var className = '', style = '', iconClass = '', v, pos; if (opts) { if (opts.className) { className = ' ' + opts.className; } if (opts.iconClass) { iconClass = opts.iconClass; icon = ''; } if (opts.iconImg) { v = opts.iconImg.split(/ +/); pos = v[1] && v[2]? fm.escape(v[1] + 'px ' + v[2] + 'px') : ''; style = ' style="background:url(\''+fm.escape(v[0])+'\') '+(pos? pos : '0 0')+' no-repeat;'+(pos? '' : 'posbackground-size:contain;')+'"'; } } return jQuery(tpl.replace('{icon}', icon ? 'elfinder-button-icon-'+icon : (iconClass? iconClass : '')) .replace('{label}', label) .replace('{style}', style) .replace('{className}', className)) .on('click', function(e) { e.stopPropagation(); e.preventDefault(); callback(); }); }, urlIcon = function(iconUrl) { var v = iconUrl.split(/ +/), pos = v[1] && v[2]? (v[1] + 'px ' + v[2] + 'px') : ''; return { backgroundImage: 'url("'+v[0]+'")', backgroundRepeat: 'no-repeat', backgroundPosition: pos? pos : '', backgroundSize: pos? '' : 'contain' }; }, base, cwd, nodes, selected, subnodes, subselected, autoSyncStop, subHoverTm, autoToggle = function() { var evTouchStart = 'touchstart.contextmenuAutoToggle'; menu.data('hideTm') && clearTimeout(menu.data('hideTm')); if (menu.is(':visible')) { menu.on('touchstart', function(e) { if (e.originalEvent.touches.length > 1) { return; } menu.stop(); fm.toFront(menu); menu.data('hideTm') && clearTimeout(menu.data('hideTm')); }) .data('hideTm', setTimeout(function() { if (menu.is(':visible')) { cwd.find('.elfinder-cwd-file').off(evTouchStart); cwd.find('.elfinder-cwd-file.ui-selected') .one(evTouchStart, function(e) { if (e.originalEvent.touches.length > 1) { return; } var tgt = jQuery(e.target); if (menu.first().length && !tgt.is('input:checkbox') && !tgt.hasClass('elfinder-cwd-select')) { e.stopPropagation(); //e.preventDefault(); open(e.originalEvent.touches[0].pageX, e.originalEvent.touches[0].pageY); cwd.data('longtap', true) tgt.one('touchend', function() { setTimeout(function() { cwd.removeData('longtap'); }, 80); }); return; } cwd.find('.elfinder-cwd-file').off(evTouchStart); }) .one('unselect.'+fm.namespace, function() { cwd.find('.elfinder-cwd-file').off(evTouchStart); }); menu.fadeOut({ duration: 300, fail: function() { menu.css('opacity', '1').show(); }, done: function() { fm.toHide(menu); } }); } }, 4500)); } }, keyEvts = function(e) { var code = e.keyCode, ESC = jQuery.ui.keyCode.ESCAPE, ENT = jQuery.ui.keyCode.ENTER, LEFT = jQuery.ui.keyCode.LEFT, RIGHT = jQuery.ui.keyCode.RIGHT, UP = jQuery.ui.keyCode.UP, DOWN = jQuery.ui.keyCode.DOWN, subent = fm.direction === 'ltr'? RIGHT : LEFT, sublev = subent === RIGHT? LEFT : RIGHT; if (jQuery.inArray(code, [ESC, ENT, LEFT, RIGHT, UP, DOWN]) !== -1) { e.preventDefault(); e.stopPropagation(); e.stopImmediatePropagation(); if (code == ESC || code === sublev) { if (selected && subnodes && subselected) { subselected.trigger('mouseleave').trigger('submenuclose'); selected.addClass(cHover); subnodes = null; subselected = null; } else { code == ESC && close(); } } else if (code == UP || code == DOWN) { if (subnodes) { if (subselected) { subselected.trigger('mouseleave'); } if (code == DOWN && (! subselected || subnodes.length <= ++subnodes._cur)) { subnodes._cur = 0; } else if (code == UP && (! subselected || --subnodes._cur < 0)) { subnodes._cur = subnodes.length - 1; } subselected = subnodes.eq(subnodes._cur).trigger('mouseenter'); } else { subnodes = null; if (selected) { selected.trigger('mouseleave'); } if (code == DOWN && (! selected || nodes.length <= ++nodes._cur)) { nodes._cur = 0; } else if (code == UP && (! selected || --nodes._cur < 0)) { nodes._cur = nodes.length - 1; } selected = nodes.eq(nodes._cur).addClass(cHover); } } else if (selected && (code == ENT || code === subent)) { if (selected.hasClass('elfinder-contextmenu-group')) { if (subselected) { code == ENT && subselected.click(); } else { selected.trigger('mouseenter'); subnodes = selected.find('div.'+smItem); subnodes._cur = 0; subselected = subnodes.first().addClass(cHover); } } else { code == ENT && selected.click(); } } } }, open = function(x, y, css) { var width = menu.outerWidth(), height = menu.outerHeight(), bstyle = base.attr('style'), bpos = base.offset(), bwidth = base.width(), bheight = base.height(), mw = fm.UA.Mobile? 40 : 2, mh = fm.UA.Mobile? 20 : 2, x = x - (bpos? bpos.left : 0), y = y - (bpos? bpos.top : 0), css = Object.assign(css || {}, { top : Math.max(0, y + mh + height < bheight ? y + mh : y - (y + height - bheight)), left : Math.max(0, (x < width + mw || x + mw + width < bwidth)? x + mw : x - mw - width), opacity : '1' }), evts; autoSyncStop = true; fm.autoSync('stop'); base.width(bwidth); menu.stop().removeAttr('style').css(css); fm.toFront(menu); menu.show(); base.attr('style', bstyle); css[subpos] = parseInt(menu.width()); menu.find('.elfinder-contextmenu-sub').css(css); if (fm.UA.iOS) { jQuery('div.elfinder div.overflow-scrolling-touch').css('-webkit-overflow-scrolling', 'auto'); } selected = null; subnodes = null; subselected = null; jQuery(document).on('keydown.' + fm.namespace, keyEvts); evts = jQuery._data(document).events; if (evts && evts.keydown) { evts.keydown.unshift(evts.keydown.pop()); } fm.UA.Mobile && autoToggle(); requestAnimationFrame(function() { fm.getUI().one('click.' + fm.namespace, close); }); }, close = function() { fm.getUI().off('click.' + fm.namespace, close); jQuery(document).off('keydown.' + fm.namespace, keyEvts); currentType = currentTargets = null; if (menu.is(':visible') || menu.children().length) { fm.toHide(menu.removeAttr('style').empty().removeData('submenuKeep')); try { if (! menu.draggable('instance')) { menu.draggable(dragOpt); } } catch(e) { if (! menu.hasClass('ui-draggable')) { menu.draggable(dragOpt); } } if (menu.data('prevNode')) { menu.data('prevNode').after(menu); menu.removeData('prevNode'); } fm.trigger('closecontextmenu'); if (fm.UA.iOS) { jQuery('div.elfinder div.overflow-scrolling-touch').css('-webkit-overflow-scrolling', 'touch'); } } autoSyncStop && fm.searchStatus.state < 1 && ! fm.searchStatus.ininc && fm.autoSync(); autoSyncStop = false; }, create = function(type, targets) { var sep = false, insSep = false, disabled = [], isCwd = type === 'cwd', selcnt = 0, cmdMap; currentType = type; currentTargets = targets; // get current uiCmdMap option if (!(cmdMap = fm.option('uiCmdMap', isCwd? void(0) : targets[0]))) { cmdMap = {}; } if (!isCwd) { disabled = fm.getDisabledCmds(targets); } selcnt = fm.selected().length; if (selcnt > 1) { menu.append('<div class="ui-corner-top ui-widget-header elfinder-contextmenu-header"><span>' + fm.i18n('selectedItems', ''+selcnt) + '</span></div>'); } nodes = jQuery(); jQuery.each(types[type]||[], function(i, name) { var cmd, cmdName, useMap, node, submenu, hover; if (name === '|') { if (sep) { insSep = true; } return; } if (cmdMap[name]) { cmdName = cmdMap[name]; useMap = true; } else { cmdName = name; } cmd = fm.getCommand(cmdName); if (cmd && !isCwd && (!fm.searchStatus.state || !cmd.disableOnSearch)) { cmd.__disabled = cmd._disabled; cmd._disabled = !(cmd.alwaysEnabled || (fm._commands[cmdName] ? jQuery.inArray(name, disabled) === -1 && (!useMap || !disabled[cmdName]) : false)); jQuery.each(cmd.linkedCmds, function(i, n) { var c; if (c = fm.getCommand(n)) { c.__disabled = c._disabled; c._disabled = !(c.alwaysEnabled || (fm._commands[n] ? !disabled[n] : false)); } }); } if (cmd && !cmd._disabled && cmd.getstate(targets) != -1) { if (cmd.variants) { if (!cmd.variants.length) { return; } node = item(cmd.title, cmd.className? cmd.className : cmd.name, function(){}, cmd.contextmenuOpts); submenu = jQuery('<div class="ui-front ui-corner-all elfinder-contextmenu-sub"/>') .hide() .css('max-height', fm.getUI().height() - 30) .appendTo(node.append('<span class="elfinder-contextmenu-arrow"/>')); hover = function(show){ if (! show) { submenu.hide(); } else { var bstyle = base.attr('style'); base.width(base.width()); // top: '-1000px' to prevent visible scrollbar of window with the elFinder option `height: '100%'` submenu.css({ top: '-1000px', left: 'auto', right: 'auto' }); var nodeOffset = node.offset(), nodeleft = nodeOffset.left, nodetop = nodeOffset.top, nodewidth = node.outerWidth(), width = submenu.outerWidth(true), height = submenu.outerHeight(true), baseOffset = base.offset(), wwidth = baseOffset.left + base.width(), wheight = baseOffset.top + base.height(), cltr = ltr, x = nodewidth, y, over; if (ltr) { over = (nodeleft + nodewidth + width) - wwidth; if (over > 10) { if (nodeleft > width - 5) { x = x - 5; cltr = false; } else { if (!fm.UA.Mobile) { x = nodewidth - over; } } } } else { over = width - nodeleft; if (over > 0) { if ((nodeleft + nodewidth + width - 15) < wwidth) { x = x - 5; cltr = true; } else { if (!fm.UA.Mobile) { x = nodewidth - over; } } } } over = (nodetop + 5 + height) - wheight; y = (over > 0 && nodetop < wheight)? 5 - over : (over > 0? 30 - height : 5); menu.find('.elfinder-contextmenu-sub:visible').hide(); submenu.css({ top : y, left : cltr? x : 'auto', right: cltr? 'auto' : x, overflowY: 'auto' }).show(); base.attr('style', bstyle); } }; node.addClass('elfinder-contextmenu-group') .on('mouseleave', '.elfinder-contextmenu-sub', function(e) { if (! menu.data('draged')) { menu.removeData('submenuKeep'); } }) .on('submenuclose', '.elfinder-contextmenu-sub', function(e) { hover(false); }) .on('click', '.'+smItem, function(e){ var opts, $this; e.stopPropagation(); if (! menu.data('draged')) { $this = jQuery(this); if (!cmd.keepContextmenu) { menu.hide(); } else { $this.removeClass(cHover); node.addClass(cHover); } opts = $this.data('exec'); if (typeof opts === 'undefined') { opts = {}; } if (typeof opts === 'object') { opts._userAction = true; opts._currentType = type; opts._currentNode = $this; } !cmd.keepContextmenu && close(); fm.exec(cmd.name, targets, opts); } }) .on('touchend', function(e) { if (! menu.data('drag')) { hover(true); menu.data('submenuKeep', true); } }) .on('mouseenter mouseleave', function(e){ if (! menu.data('touching')) { if (node.data('timer')) { clearTimeout(node.data('timer')); node.removeData('timer'); } if (!jQuery(e.target).closest('.elfinder-contextmenu-sub', menu).length) { if (e.type === 'mouseleave') { if (! menu.data('submenuKeep')) { node.data('timer', setTimeout(function() { node.removeData('timer'); hover(false); }, 250)); } } else { node.data('timer', setTimeout(function() { node.removeData('timer'); hover(true); }, nodes.find('div.elfinder-contextmenu-sub:visible').length? 250 : 0)); } } } }); jQuery.each(cmd.variants, function(i, variant) { var item = variant === '|' ? '<div class="elfinder-contextmenu-separator"/>' : jQuery('<div class="'+cmItem+' '+smItem+'"><span>'+variant[1]+'</span></div>').data('exec', variant[0]), iconClass, icon; if (typeof variant[2] !== 'undefined') { icon = jQuery('<span/>').addClass('elfinder-button-icon elfinder-contextmenu-icon'); if (! /\//.test(variant[2])) { icon.addClass('elfinder-button-icon-'+variant[2]); } else { icon.css(urlIcon(variant[2])); } item.prepend(icon).addClass(smItem+'-icon'); } submenu.append(item); }); } else { node = item(cmd.title, cmd.className? cmd.className : cmd.name, function() { if (! menu.data('draged')) { !cmd.keepContextmenu && close(); fm.exec(cmd.name, targets, {_userAction: true, _currentType: type, _currentNode: node}); } }, cmd.contextmenuOpts); if (cmd.extra && cmd.extra.node) { jQuery('<span class="elfinder-button-icon elfinder-button-icon-'+(cmd.extra.icon || '')+' '+exIcon+'"/>') .append(cmd.extra.node).appendTo(node); jQuery(cmd.extra.node).trigger('ready', {targets: targets}); } else { node.remove('.'+exIcon); } } if (cmd.extendsCmd) { node.children('span.elfinder-button-icon').addClass('elfinder-button-icon-' + cmd.extendsCmd); } if (insSep) { menu.append('<div class="elfinder-contextmenu-separator"/>'); } menu.append(node); sep = true; insSep = false; } if (cmd && typeof cmd.__disabled !== 'undefined') { cmd._disabled = cmd.__disabled; delete cmd.__disabled; jQuery.each(cmd.linkedCmds, function(i, n) { var c; if (c = fm.getCommand(n)) { c._disabled = c.__disabled; delete c.__disabled; } }); } }); nodes = menu.children('div.'+cmItem); }, createFromRaw = function(raw) { currentType = 'raw'; jQuery.each(raw, function(i, data) { var node; if (data === '|') { menu.append('<div class="elfinder-contextmenu-separator"/>'); } else if (data.label && typeof data.callback == 'function') { node = item(data.label, data.icon, function() { if (! menu.data('draged')) { !data.remain && close(); data.callback(); } }, data.options || null); menu.append(node); } }); nodes = menu.children('div.'+cmItem); }, currentType = null, currentTargets = null; fm.one('load', function() { base = fm.getUI(); cwd = fm.getUI('cwd'); fm.bind('contextmenu', function(e) { var data = e.data, css = {}, prevNode; if (data.type && data.type !== 'files') { cwd.trigger('unselectall'); } close(); if (data.type && data.targets) { fm.trigger('contextmenucreate', data); create(data.type, data.targets); fm.trigger('contextmenucreatedone', data); } else if (data.raw) { createFromRaw(data.raw); } if (menu.children().length) { prevNode = data.prevNode || null; if (prevNode) { menu.data('prevNode', menu.prev()); prevNode.after(menu); } if (data.fitHeight) { css = {maxHeight: Math.min(fm.getUI().height(), jQuery(window).height()), overflowY: 'auto'}; menu.draggable('destroy').removeClass('ui-draggable'); } open(data.x, data.y, css); // call opened callback function if (data.opened && typeof data.opened === 'function') { data.opened.call(menu); } } }) .one('destroy', function() { menu.remove(); }) .bind('disable', close) .bind('select', function(e){ (currentType === 'files' && (!e.data || e.data.selected.toString() !== currentTargets.toString())) && close(); }); }) .shortcut({ pattern : fm.OS === 'mac' ? 'ctrl+m' : 'contextmenu shift+f10', description : 'contextmenu', callback : function(e) { e.stopPropagation(); e.preventDefault(); jQuery(document).one('contextmenu.' + fm.namespace, function(e) { e.preventDefault(); e.stopPropagation(); }); var sel = fm.selected(), type, targets, pos, elm; if (sel.length) { type = 'files'; targets = sel; elm = fm.cwdHash2Elm(sel[0]); } else { type = 'cwd'; targets = [ fm.cwd().hash ]; pos = fm.getUI('workzone').offset(); } if (! elm || ! elm.length) { elm = fm.getUI('workzone'); } pos = elm.offset(); pos.top += (elm.height() / 2); pos.left += (elm.width() / 2); fm.trigger('contextmenu', { 'type' : type, 'targets' : targets, 'x' : pos.left, 'y' : pos.top }); } }); }); }; /* * File: /js/ui/cwd.js */ /** * elFinder current working directory ui. * * @author Dmitry (dio) Levashov **/ jQuery.fn.elfindercwd = function(fm, options) { this.not('.elfinder-cwd').each(function() { // fm.time('cwdLoad'); var mobile = fm.UA.Mobile, list = fm.viewType == 'list', undef = 'undefined', /** * Select event full name * * @type String **/ evtSelect = 'select.'+fm.namespace, /** * Unselect event full name * * @type String **/ evtUnselect = 'unselect.'+fm.namespace, /** * Disable event full name * * @type String **/ evtDisable = 'disable.'+fm.namespace, /** * Disable event full name * * @type String **/ evtEnable = 'enable.'+fm.namespace, c = 'class', /** * File css class * * @type String **/ clFile = fm.res(c, 'cwdfile'), /** * Selected css class * * @type String **/ fileSelector = '.'+clFile, /** * Selected css class * * @type String **/ clSelected = 'ui-selected', /** * Disabled css class * * @type String **/ clDisabled = fm.res(c, 'disabled'), /** * Draggable css class * * @type String **/ clDraggable = fm.res(c, 'draggable'), /** * Droppable css class * * @type String **/ clDroppable = fm.res(c, 'droppable'), /** * Hover css class * * @type String **/ clHover = fm.res(c, 'hover'), /** * Active css class * * @type String **/ clActive = fm.res(c, 'active'), /** * Hover css class * * @type String **/ clDropActive = fm.res(c, 'adroppable'), /** * Css class for temporary nodes (for mkdir/mkfile) commands * * @type String **/ clTmp = clFile+'-tmp', /** * Select checkbox css class * * @type String */ clSelChk = 'elfinder-cwd-selectchk', /** * Number of thumbnails to load in one request (new api only) * * @type Number **/ tmbNum = fm.options.loadTmbs > 0 ? fm.options.loadTmbs : 5, /** * Current search query. * * @type String */ query = '', /** * Currect clipboard(cut) hashes as object key * * @type Object */ clipCuts = {}, /** * Parents hashes of cwd * * @type Array */ cwdParents = [], /** * cwd current hashes * * @type Array */ cwdHashes = [], /** * incsearch current hashes * * @type Array */ incHashes = void 0, /** * Custom columns name and order * * @type Array */ customCols = [], /** * Current clicked element id of first time for dblclick * * @type String */ curClickId = '', /** * Custom columns builder * * @type Function */ customColsBuild = function() { var cols = ''; for (var i = 0; i < customCols.length; i++) { cols += '<td class="elfinder-col-'+customCols[i]+'">{' + customCols[i] + '}</td>'; } return cols; }, /** * Make template.row from customCols * * @type Function */ makeTemplateRow = function() { return '<tr id="{id}" class="'+clFile+' {permsclass} {dirclass}" title="{tooltip}"{css}><td class="elfinder-col-name"><div class="elfinder-cwd-file-wrapper"><span class="elfinder-cwd-icon {mime}"{style}/>{marker}<span class="elfinder-cwd-filename">{name}</span></div>'+selectCheckbox+'</td>'+customColsBuild()+'</tr>'; }, selectCheckbox = (jQuery.map(options.showSelectCheckboxUA, function(t) {return (fm.UA[t] || t.match(/^all$/i))? true : null;}).length)? '<div class="elfinder-cwd-select"><input type="checkbox" class="'+clSelChk+'"></div>' : '', colResizing = false, colWidth = null, /** * Table header height */ thHeight, /** * File templates * * @type Object **/ templates = { icon : '<div id="{id}" class="'+clFile+' {permsclass} {dirclass} ui-corner-all" title="{tooltip}"><div class="elfinder-cwd-file-wrapper ui-corner-all"><div class="elfinder-cwd-icon {mime} ui-corner-all" unselectable="on"{style}/>{marker}</div><div class="elfinder-cwd-filename" title="{nametitle}">{name}</div>'+selectCheckbox+'</div>', row : '' }, permsTpl = fm.res('tpl', 'perms'), lockTpl = fm.res('tpl', 'lock'), symlinkTpl = fm.res('tpl', 'symlink'), /** * Template placeholders replacement rules * * @type Object **/ replacement = { id : function(f) { return fm.cwdHash2Id(f.hash); }, name : function(f) { var name = fm.escape(f.i18 || f.name); !list && (name = name.replace(/([_.])/g, '​$1')); return name; }, nametitle : function(f) { return fm.escape(f.i18 || f.name); }, permsclass : function(f) { return fm.perms2class(f); }, perm : function(f) { return fm.formatPermissions(f); }, dirclass : function(f) { var cName = f.mime == 'directory' ? 'directory' : ''; f.isroot && (cName += ' isroot'); f.csscls && (cName += ' ' + fm.escape(f.csscls)); options.getClass && (cName += ' ' + options.getClass(f)); return cName; }, style : function(f) { return f.icon? fm.getIconStyle(f) : ''; }, mime : function(f) { var cName = fm.mime2class(f.mime); f.icon && (cName += ' elfinder-cwd-bgurl'); return cName; }, size : function(f) { return (f.mime === 'directory' && !f.size)? '-' : fm.formatSize(f.size); }, date : function(f) { return fm.formatDate(f); }, kind : function(f) { return fm.mime2kind(f); }, mode : function(f) { return f.perm? fm.formatFileMode(f.perm) : ''; }, modestr : function(f) { return f.perm? fm.formatFileMode(f.perm, 'string') : ''; }, modeoct : function(f) { return f.perm? fm.formatFileMode(f.perm, 'octal') : ''; }, modeboth : function(f) { return f.perm? fm.formatFileMode(f.perm, 'both') : ''; }, marker : function(f) { return (f.alias || f.mime == 'symlink-broken' ? symlinkTpl : '')+(!f.read || !f.write ? permsTpl : '')+(f.locked ? lockTpl : ''); }, tooltip : function(f) { var title = fm.formatDate(f) + (f.size > 0 ? ' ('+fm.formatSize(f.size)+')' : ''), info = ''; if (query && f.path) { info = fm.escape(f.path.replace(/\/[^\/]*$/, '')); } else { info = f.tooltip? fm.escape(f.tooltip).replace(/\r/g, ' ') : ''; } if (list) { info += (info? ' ' : '') + fm.escape(f.i18 || f.name); } return info? info + ' ' + title : title; } }, /** * Type badge CSS added flag * * @type Object */ addedBadges = {}, /** * Type badge style sheet element * * @type Object */ addBadgeStyleSheet, /** * Add type badge CSS into 'head' * * @type Fundtion */ addBadgeStyle = function(mime, name) { var sel, ext, type; if (mime && ! addedBadges[mime]) { if (typeof addBadgeStyleSheet === 'undefined') { if (jQuery('#elfinderAddBadgeStyle'+fm.namespace).length) { jQuery('#elfinderAddBadgeStyle'+fm.namespace).remove(); } addBadgeStyleSheet = jQuery('<style id="addBadgeStyle'+fm.namespace+'"/>').insertBefore(jQuery('head').children(':first')).get(0).sheet || null; } if (addBadgeStyleSheet) { mime = mime.toLowerCase(); type = mime.split('/'); ext = fm.escape(fm.mimeTypes[mime] || (name.replace(/.bac?k$/i, '').match(/\.([^.]+)$/) || ['',''])[1]); if (ext) { sel = '.elfinder-cwd-icon-' + type[0].replace(/(\.|\+)/g, '-'); if (typeof type[1] !== 'undefined') { sel += '.elfinder-cwd-icon-' + type[1].replace(/(\.|\+)/g, '-'); } try { addBadgeStyleSheet.insertRule(sel + ':before{content:"' + ext.toLowerCase() + '"}', 0); } catch(e) {} } addedBadges[mime] = true; } } }, /** * Return file html * * @param Object file info * @return String **/ itemhtml = function(f) { f.mime && f.mime !== 'directory' && !addedBadges[f.mime] && addBadgeStyle(f.mime, f.name); return templates[list ? 'row' : 'icon'] .replace(/\{([a-z0-9_]+)\}/g, function(s, e) { return replacement[e] ? replacement[e](f, fm) : (f[e] ? f[e] : ''); }); }, /** * jQueery node that will be selected next * * @type Object jQuery node */ selectedNext = jQuery(), /** * Flag. Required for msie to avoid unselect files on dragstart * * @type Boolean **/ selectLock = false, /** * Move selection to prev/next file * * @param String move direction * @param Boolean append to current selection * @return void * @rise select */ select = function(keyCode, append) { var code = jQuery.ui.keyCode, prev = keyCode == code.LEFT || keyCode == code.UP, sel = cwd.find('[id].'+clSelected), selector = prev ? 'first:' : 'last', s, n, sib, top, left; function sibling(n, direction) { return n[direction+'All']('[id]:not(.'+clDisabled+'):not(.elfinder-cwd-parent):first'); } if (sel.length) { s = sel.filter(prev ? ':first' : ':last'); sib = sibling(s, prev ? 'prev' : 'next'); if (!sib.length) { // there is no sibling on required side - do not move selection n = s; } else if (list || keyCode == code.LEFT || keyCode == code.RIGHT) { // find real prevoius file n = sib; } else { // find up/down side file in icons view top = s.position().top; left = s.position().left; n = s; if (prev) { do { n = n.prev('[id]'); } while (n.length && !(n.position().top < top && n.position().left <= left)); if (n.hasClass(clDisabled)) { n = sibling(n, 'next'); } } else { do { n = n.next('[id]'); } while (n.length && !(n.position().top > top && n.position().left >= left)); if (n.hasClass(clDisabled)) { n = sibling(n, 'prev'); } // there is row before last one - select last file if (!n.length) { sib = cwd.find('[id]:not(.'+clDisabled+'):last'); if (sib.position().top > top) { n = sib; } } } } // !append && unselectAll(); } else { if (selectedNext.length) { n = prev? selectedNext.prev() : selectedNext; } else { // there are no selected file - select first/last one n = cwd.find('[id]:not(.'+clDisabled+'):not(.elfinder-cwd-parent):'+(prev ? 'last' : 'first')); } } if (n && n.length && !n.hasClass('elfinder-cwd-parent')) { if (s && append) { // append new files to selected n = s.add(s[prev ? 'prevUntil' : 'nextUntil']('#'+n.attr('id'))).add(n); } else { // unselect selected files sel.trigger(evtUnselect); } // select file(s) n.trigger(evtSelect); // set its visible scrollToView(n.filter(prev ? ':first' : ':last')); // update cache/view trigger(); } }, selectedFiles = {}, selectFile = function(hash) { fm.cwdHash2Elm(hash).trigger(evtSelect); }, allSelected = false, selectAll = function() { var phash = fm.cwd().hash; selectCheckbox && selectAllCheckbox.find('input').prop('checked', true); fm.lazy(function() { var files; if (fm.maxTargets && (incHashes || cwdHashes).length > fm.maxTargets) { unselectAll({ notrigger: true }); files = jQuery.map(incHashes || cwdHashes, function(hash) { return fm.file(hash) || null; }); files = files.slice(0, fm.maxTargets); selectedFiles = {}; jQuery.each(files, function(i, v) { selectedFiles[v.hash] = true; fm.cwdHash2Elm(v.hash).trigger(evtSelect); }); fm.toast({mode: 'warning', msg: fm.i18n(['errMaxTargets', fm.maxTargets])}); } else { cwd.find('[id]:not(.'+clSelected+'):not(.elfinder-cwd-parent)').trigger(evtSelect); selectedFiles = fm.arrayFlip(incHashes || cwdHashes, true); } trigger(); selectCheckbox && selectAllCheckbox.data('pending', false); }, 0, {repaint: true}); }, /** * Unselect all files * * @param Object options * @return void */ unselectAll = function(opts) { var o = opts || {}; selectCheckbox && selectAllCheckbox.find('input').prop('checked', false); if (Object.keys(selectedFiles).length) { selectLock = false; selectedFiles = {}; cwd.find('[id].'+clSelected).trigger(evtUnselect); selectCheckbox && cwd.find('input:checkbox.'+clSelChk).prop('checked', false); } !o.notrigger && trigger(); selectCheckbox && selectAllCheckbox.data('pending', false); cwd.removeClass('elfinder-cwd-allselected'); }, selectInvert = function() { var invHashes = {}; if (allSelected) { unselectAll(); } else if (! Object.keys(selectedFiles).length) { selectAll(); } else { jQuery.each((incHashes || cwdHashes), function(i, h) { var itemNode = fm.cwdHash2Elm(h); if (! selectedFiles[h]) { invHashes[h] = true; itemNode.length && itemNode.trigger(evtSelect); } else { itemNode.length && itemNode.trigger(evtUnselect); } }); selectedFiles = invHashes; trigger(); } }, /** * Return selected files hashes list * * @return Array */ selected = function() { return Object.keys(selectedFiles); }, /** * Last selected node id * * @type String|Void */ lastSelect = void 0, /** * Fire elfinder "select" event and pass selected files to it * * @return void */ trigger = function() { var selected = Object.keys(selectedFiles), opts = { selected : selected, origin : 'cwd' }; if (oldSchoolItem && (selected.length > 1 || selected[0] !== fm.cwdId2Hash( oldSchoolItem.attr('id'))) && oldSchoolItem.hasClass(clSelected)) { oldSchoolItem.trigger(evtUnselect); } allSelected = selected.length && (selected.length === (incHashes || cwdHashes).length) && (!fm.maxTargets || selected.length <= fm.maxTargets); if (selectCheckbox) { selectAllCheckbox.find('input').prop('checked', allSelected); cwd[allSelected? 'addClass' : 'removeClass']('elfinder-cwd-allselected'); } if (allSelected) { opts.selectall = true; } else if (! selected.length) { opts.unselectall = true; } fm.trigger('select', opts); }, /** * Scroll file to set it visible * * @param DOMElement file/dir node * @return void */ scrollToView = function(o, blink) { if (! o.length) { return; } var ftop = o.position().top, fheight = o.outerHeight(true), wtop = wrapper.scrollTop(), wheight = wrapper.get(0).clientHeight, thheight = tableHeader? tableHeader.outerHeight(true) : 0; if (ftop + thheight + fheight > wtop + wheight) { wrapper.scrollTop(parseInt(ftop + thheight + fheight - wheight)); } else if (ftop < wtop) { wrapper.scrollTop(ftop); } list && wrapper.scrollLeft(0); !!blink && fm.resources.blink(o, 'lookme'); }, /** * Files we get from server but not show yet * * @type Array **/ buffer = [], /** * Extra data of buffer * * @type Object **/ bufferExt = {}, /** * Return index of elements with required hash in buffer * * @param String file hash * @return Number */ index = function(hash) { var l = buffer.length; while (l--) { if (buffer[l].hash == hash) { return l; } } return -1; }, /** * Scroll start event name * * @type String **/ scrollStartEvent = 'elfscrstart', /** * Scroll stop event name * * @type String **/ scrollEvent = 'elfscrstop', scrolling = false, /** * jQuery UI selectable option * * @type Object */ selectableOption = { disabled : true, filter : '[id]:first', stop : trigger, delay : 250, appendTo : 'body', autoRefresh: false, selected : function(e, ui) { jQuery(ui.selected).trigger(evtSelect); }, unselected : function(e, ui) { jQuery(ui.unselected).trigger(evtUnselect); } }, /** * hashes of items displayed in current view * * @type Object ItemHash => DomId */ inViewHashes = {}, /** * Processing when the current view is changed (On open, search, scroll, resize etc.) * * @return void */ wrapperRepaint = function(init, recnt) { if (!bufferExt.renderd) { return; } var firstNode = (list? cwd.find('tbody:first') : cwd).children('[id]'+(options.oldSchool? ':not(.elfinder-cwd-parent)' : '')+':first'); if (!firstNode.length) { return; } var selectable = cwd.data('selectable'), rec = (function() { var wos = wrapper.offset(), ww = wrapper.width(), w = jQuery(window), x = firstNode.width() / 2, l = Math.min(wos.left - w.scrollLeft() + (fm.direction === 'ltr'? x : ww - x), wos.left + ww - 10), t = wos.top - w.scrollTop() + 10 + (list? thHeight : 0); return {left: Math.max(0, Math.round(l)), top: Math.max(0, Math.round(t))}; })(), tgt = init? firstNode : jQuery(document.elementFromPoint(rec.left , rec.top)), ids = {}, tmbs = {}, multi = 5, cnt = Math.ceil((bufferExt.hpi? Math.ceil((wz.data('rectangle').height / bufferExt.hpi) * 1.5) : showFiles) / multi), chk = function() { var id, hash, file, i; for (i = 0; i < multi; i++) { id = tgt.attr('id'); if (id) { bufferExt.getTmbs = []; hash = fm.cwdId2Hash(id); inViewHashes[hash] = id; // for tmbs if (bufferExt.attachTmbs[hash]) { tmbs[hash] = bufferExt.attachTmbs[hash]; } // for selectable selectable && (ids[id] = true); } // next node tgt = tgt.next(); if (!tgt.length) { break; } } }, done = function() { var idsArr; if (cwd.data('selectable')) { Object.assign(ids, selectedFiles); idsArr = Object.keys(ids); if (idsArr.length) { selectableOption.filter = '#'+idsArr.join(', #'); cwd.selectable('enable').selectable('option', {filter : selectableOption.filter}).selectable('refresh'); } } if (Object.keys(tmbs).length) { bufferExt.getTmbs = []; attachThumbnails(tmbs); } }, setTarget = function() { if (!tgt.hasClass(clFile)) { tgt = tgt.closest(fileSelector); } }, arr, widget; inViewHashes = {}; selectable && cwd.selectable('option', 'disabled'); if (tgt.length) { if (!tgt.hasClass(clFile) && !tgt.closest(fileSelector).length) { // dialog, serach button etc. widget = fm.getUI().find('.ui-dialog:visible,.ui-widget:visible'); if (widget.length) { widget.hide(); tgt = jQuery(document.elementFromPoint(rec.left , rec.top)); widget.show(); } else { widget = null; } } setTarget(); if (!tgt.length) { // try search 5px down widget && widget.hide(); tgt = jQuery(document.elementFromPoint(rec.left , rec.top + 5)); widget && widget.show(); setTarget(); } } if (tgt.length) { if (tgt.attr('id')) { if (init) { for (var i = 0; i < cnt; i++) { chk(); if (! tgt.length) { break; } } done(); } else { bufferExt.repaintJob && bufferExt.repaintJob.state() === 'pending' && bufferExt.repaintJob.reject(); arr = new Array(cnt); bufferExt.repaintJob = fm.asyncJob(function() { chk(); if (! tgt.length) { done(); bufferExt.repaintJob && bufferExt.repaintJob.state() === 'pending' && bufferExt.repaintJob.reject(); } }, arr).done(done); } } } else if (init && bufferExt.renderd) { // In initial request, cwd DOM not renderd so doing lazy check recnt = recnt || 0; if (recnt < 10) { // Prevent infinite loop requestAnimationFrame(function() { wrapperRepaint(init, ++recnt); }); } } }, /** * Item node of oldScholl ".." */ oldSchoolItem = null, /** * display parent folder with ".." name * * @param String phash * @return void */ oldSchool = function(p) { var phash = fm.cwd().phash, pdir = fm.file(phash) || null, set = function(pdir) { if (pdir) { oldSchoolItem = jQuery(itemhtml(jQuery.extend(true, {}, pdir, {name : '..', i18 : '..', mime : 'directory'}))) .addClass('elfinder-cwd-parent') .on('dblclick', function() { var hash = fm.cwdId2Hash(this.id); fm.trigger('select', {selected : [hash]}).exec('open', hash); }); (list ? oldSchoolItem.children('td:first') : oldSchoolItem).children('.elfinder-cwd-select').remove(); (list ? cwd.find('tbody') : cwd).prepend(oldSchoolItem); fm.draggingUiHelper && fm.draggingUiHelper.data('refreshPositions', 1); } }; if (pdir) { set(pdir); } else { if (fm.getUI('tree').length) { fm.one('parents', function() { set(fm.file(phash) || null); wrapper.trigger(scrollEvent); }); } else { fm.request({ data : {cmd : 'parents', target : fm.cwd().hash}, preventFail : true }) .done(function(data) { set(fm.file(phash) || null); wrapper.trigger(scrollEvent); }); } } }, showFiles = fm.options.showFiles, /** * Cwd scroll event handler. * Lazy load - append to cwd not shown files * * @return void */ render = function() { if (bufferExt.rendering || (bufferExt.renderd && ! buffer.length)) { return; } var place = (list ? cwd.children('table').children('tbody') : cwd), phash, chk, // created document fragment for jQuery >= 1.12, 2.2, 3.0 // see Studio-42/elFinder#1544 @ github docFlag = jQuery.htmlPrefilter? true : false, tempDom = docFlag? jQuery(document.createDocumentFragment()) : jQuery('<div/>'), go = function(o){ var over = o || null, html = [], dirs = false, atmb = {}, stmb = (fm.option('tmbUrl') === 'self'), init = bufferExt.renderd? false : true, files, locks, selected; files = buffer.splice(0, showFiles + (over || 0) / (bufferExt.hpi || 1)); bufferExt.renderd += files.length; if (! buffer.length) { bottomMarker.hide(); wrapper.off(scrollEvent, render); } locks = []; html = jQuery.map(files, function(f) { if (f.hash && f.name) { if (f.mime == 'directory') { dirs = true; } if ((f.tmb && (f.tmb != 1 || f.size > 0)) || (stmb && f.mime.indexOf('image/') === 0)) { atmb[f.hash] = f.tmb || 'self'; } clipCuts[f.hash] && locks.push(f.hash); return itemhtml(f); } return null; }); // html into temp node tempDom.empty().append(html.join('')); // make directory droppable dirs && !mobile && makeDroppable(tempDom); // check selected items selected = []; if (Object.keys(selectedFiles).length) { tempDom.find('[id]:not(.'+clSelected+'):not(.elfinder-cwd-parent)').each(function() { selectedFiles[fm.cwdId2Hash(this.id)] && selected.push(jQuery(this)); }); } // append to cwd place.append(docFlag? tempDom : tempDom.children()); // trigger select if (selected.length) { jQuery.each(selected, function(i, n) { n.trigger(evtSelect); }); trigger(); } locks.length && fm.trigger('lockfiles', {files: locks}); !bufferExt.hpi && bottomMarkerShow(place, files.length); if (list) { // show thead cwd.find('thead').show(); // fixed table header fixTableHeader({fitWidth: ! colWidth}); } if (Object.keys(atmb).length) { Object.assign(bufferExt.attachTmbs, atmb); } if (init) { if (! mobile && ! cwd.data('selectable')) { // make files selectable cwd.selectable(selectableOption).data('selectable', true); } } ! scrolling && wrapper.trigger(scrollEvent); }; if (! bufferExt.renderd) { // first time to go() bufferExt.rendering = true; // scroll top on dir load to avoid scroll after page reload wrapper.scrollTop(0); phash = fm.cwd().phash; go(); if (options.oldSchool) { if (phash && !query) { oldSchool(phash); } else { oldSchoolItem = jQuery(); } } if (list) { colWidth && setColwidth(); fixTableHeader({fitWidth: true}); } bufferExt.itemH = (list? place.find('tr:first') : place.find('[id]:first')).outerHeight(true); fm.trigger('cwdrender'); bufferExt.rendering = false; wrapperRepaint(true); } if (! bufferExt.rendering && buffer.length) { // next go() if ((chk = (wrapper.height() + wrapper.scrollTop() + fm.options.showThreshold + bufferExt.row) - (bufferExt.renderd * bufferExt.hpi)) > 0) { bufferExt.rendering = true; fm.lazy(function() { go(chk); bufferExt.rendering = false; }); } else { !fm.enabled() && resize(); } } else { resize(); } }, // fixed table header jQuery object tableHeader = null, // Is UA support CSS sticky cssSticky = fm.UA.CSS.positionSticky && fm.UA.CSS.widthMaxContent, // To fixed table header colmun fixTableHeader = function(optsArg) { thHeight = 0; if (! options.listView.fixedHeader) { return; } var setPos = function() { var val, pos; pos = (fm.direction === 'ltr')? 'left' : 'right'; val = ((fm.direction === 'ltr')? wrapper.scrollLeft() : table.outerWidth(true) - wrapper.width() - wrapper.scrollLeft()) * -1; if (base.css(pos) !== val) { base.css(pos, val); } }, opts = optsArg || {}, cnt, base, table, htable, thead, tbody, hheight, htr, btr, htd, btd, htw, btw, init; tbody = cwd.find('tbody'); btr = tbody.children('tr:first'); if (btr.length && btr.is(':visible')) { table = tbody.parent(); if (! tableHeader) { init = true; tbody.addClass('elfinder-cwd-fixheader'); thead = cwd.find('thead').attr('id', fm.namespace+'-cwd-thead'); htr = thead.children('tr:first'); hheight = htr.outerHeight(true); cwd.css('margin-top', hheight - parseInt(table.css('padding-top'))); if (cssSticky) { tableHeader = jQuery('<div class="elfinder-table-header-sticky"/>').addClass(cwd.attr('class')).append(jQuery('<table/>').append(thead)); cwd.after(tableHeader); wrapper.on('resize.fixheader', function(e) { e.stopPropagation(); fixTableHeader({fitWidth: true}); }); } else { base = jQuery('<div/>').addClass(cwd.attr('class')).append(jQuery('<table/>').append(thead)); tableHeader = jQuery('<div/>').addClass(wrapper.attr('class') + ' elfinder-cwd-fixheader') .removeClass('ui-droppable native-droppable') .css(wrapper.position()) .css({ height: hheight, width: cwd.outerWidth() }) .append(base); if (fm.direction === 'rtl') { tableHeader.css('left', (wrapper.data('width') - wrapper.width()) + 'px'); } setPos(); wrapper.after(tableHeader) .on('scroll.fixheader resize.fixheader', function(e) { setPos(); if (e.type === 'resize') { e.stopPropagation(); tableHeader.css(wrapper.position()); wrapper.data('width', wrapper.css('overflow', 'hidden').width()); wrapper.css('overflow', 'auto'); fixTableHeader(); } }); } } else { thead = jQuery('#'+fm.namespace+'-cwd-thead'); htr = thead.children('tr:first'); } if (init || opts.fitWidth || Math.abs(btr.outerWidth() - htr.outerWidth()) > 2) { cnt = customCols.length + 1; for (var i = 0; i < cnt; i++) { htd = htr.children('td:eq('+i+')'); btd = btr.children('td:eq('+i+')'); htw = htd.width(); btw = btd.width(); if (typeof htd.data('delta') === 'undefined') { htd.data('delta', (htd.outerWidth() - htw) - (btd.outerWidth() - btw)); } btw -= htd.data('delta'); if (! init && ! opts.fitWidth && htw === btw) { break; } htd.css('width', btw + 'px'); } } if (!cssSticky) { tableHeader.data('widthTimer') && cancelAnimationFrame(tableHeader.data('widthTimer')); tableHeader.data('widthTimer', requestAnimationFrame(function() { if (tableHeader) { tableHeader.css('width', mBoard.width() + 'px'); if (fm.direction === 'rtl') { tableHeader.css('left', (wrapper.data('width') - wrapper.width()) + 'px'); } } })); } thHeight = thead.height(); } }, // Set colmun width setColwidth = function() { if (list && colWidth) { var cl = 'elfinder-cwd-colwidth', first = cwd.find('tr[id]:first'), former; if (! first.hasClass(cl)) { former = cwd.find('tr.'+cl); former.removeClass(cl).find('td').css('width', ''); first.addClass(cl); cwd.find('table:first').css('table-layout', 'fixed'); jQuery.each(jQuery.merge(['name'], customCols), function(i, k) { var w = colWidth[k] || first.find('td.elfinder-col-'+k).width(); first.find('td.elfinder-col-'+k).width(w); }); } } }, /** * Droppable options for cwd. * Drop target is `wrapper` * Do not add class on childs file over * * @type Object */ droppable = Object.assign({}, fm.droppable, { over : function(e, ui) { var dst = jQuery(this), helper = ui.helper, ctr = (e.shiftKey || e.ctrlKey || e.metaKey), hash, status, inParent; e.stopPropagation(); helper.data('dropover', helper.data('dropover') + 1); dst.data('dropover', true); helper.removeClass('elfinder-drag-helper-move elfinder-drag-helper-plus'); if (helper.data('namespace') !== fm.namespace || ! fm.insideWorkzone(e.pageX, e.pageY)) { dst.removeClass(clDropActive); //helper.removeClass('elfinder-drag-helper-move elfinder-drag-helper-plus'); return; } if (dst.hasClass(fm.res(c, 'cwdfile'))) { hash = fm.cwdId2Hash(dst.attr('id')); dst.data('dropover', hash); } else { hash = fm.cwd().hash; fm.cwd().write && dst.data('dropover', hash); } inParent = (fm.file(helper.data('files')[0]).phash === hash); if (dst.data('dropover') === hash) { jQuery.each(helper.data('files'), function(i, h) { if (h === hash || (inParent && !ctr && !helper.hasClass('elfinder-drag-helper-plus'))) { dst.removeClass(clDropActive); return false; // break jQuery.each } }); } else { dst.removeClass(clDropActive); } if (helper.data('locked') || inParent) { status = 'elfinder-drag-helper-plus'; } else { status = 'elfinder-drag-helper-move'; if (ctr) { status += ' elfinder-drag-helper-plus'; } } dst.hasClass(clDropActive) && helper.addClass(status); requestAnimationFrame(function(){ dst.hasClass(clDropActive) && helper.addClass(status); }); }, out : function(e, ui) { var helper = ui.helper; e.stopPropagation(); helper.removeClass('elfinder-drag-helper-move elfinder-drag-helper-plus').data('dropover', Math.max(helper.data('dropover') - 1, 0)); jQuery(this).removeData('dropover') .removeClass(clDropActive); }, deactivate : function() { jQuery(this).removeData('dropover') .removeClass(clDropActive); }, drop : function(e, ui) { unselectAll({ notrigger: true }); fm.droppable.drop.call(this, e, ui); } }), /** * Make directory droppable * * @return void */ makeDroppable = function(place) { place = place? place : (list ? cwd.find('tbody') : cwd); var targets = place.children('.directory:not(.'+clDroppable+',.elfinder-na,.elfinder-ro)'); if (fm.isCommandEnabled('paste')) { targets.droppable(droppable); } if (fm.isCommandEnabled('upload')) { targets.addClass('native-droppable'); } place.children('.isroot').each(function(i, n) { var $n = jQuery(n), hash = fm.cwdId2Hash(n.id); if (fm.isCommandEnabled('paste', hash)) { if (! $n.hasClass(clDroppable+',elfinder-na,elfinder-ro')) { $n.droppable(droppable); } } else { if ($n.hasClass(clDroppable)) { $n.droppable('destroy'); } } if (fm.isCommandEnabled('upload', hash)) { if (! $n.hasClass('native-droppable,elfinder-na,elfinder-ro')) { $n.addClass('native-droppable'); } } else { if ($n.hasClass('native-droppable')) { $n.removeClass('native-droppable'); } } }); }, /** * Preload required thumbnails and on load add css to files. * Return false if required file is not visible yet (in buffer) - * required for old api to stop loading thumbnails. * * @param Object file hash -> thumbnail map * @param Bool reload * @return void */ attachThumbnails = function(tmbs, reload) { var attach = function(node, tmb) { jQuery('<img/>') .on('load', function() { node.find('.elfinder-cwd-icon').addClass(tmb.className).css('background-image', "url('"+tmb.url+"')"); }) .attr('src', tmb.url); }, chk = function(hash, tmb) { var node = fm.cwdHash2Elm(hash), file, tmbObj, reloads = []; if (node.length) { if (tmb != '1') { file = fm.file(hash); if (file.tmb !== tmb) { file.tmb = tmb; } tmbObj = fm.tmb(file); if (reload) { node.find('.elfinder-cwd-icon').addClass(tmbObj.className).css('background-image', "url('"+tmbObj.url+"')"); } else { attach(node, tmbObj); } delete bufferExt.attachTmbs[hash]; } else { if (reload) { loadThumbnails([hash]); } else if (! bufferExt.tmbLoading[hash]) { bufferExt.getTmbs.push(hash); } } } }; if (jQuery.isPlainObject(tmbs) && Object.keys(tmbs).length) { Object.assign(bufferExt.attachTmbs, tmbs); jQuery.each(tmbs, chk); if (! reload && bufferExt.getTmbs.length && ! Object.keys(bufferExt.tmbLoading).length) { loadThumbnails(); } } }, /** * Load thumbnails from backend. * * @param Array|void reloads hashes list for reload thumbnail items * @return void */ loadThumbnails = function(reloads) { var tmbs = [], reload = false; if (fm.oldAPI) { fm.request({ data : {cmd : 'tmb', current : fm.cwd().hash}, preventFail : true }) .done(function(data) { if (data.images && Object.keys(data.images).length) { attachThumbnails(data.images); } if (data.tmb) { loadThumbnails(); } }); return; } if (reloads) { reload = true; tmbs = reloads.splice(0, tmbNum); } else { tmbs = bufferExt.getTmbs.splice(0, tmbNum); } if (tmbs.length) { if (reload || inViewHashes[tmbs[0]] || inViewHashes[tmbs[tmbs.length-1]]) { jQuery.each(tmbs, function(i, h) { bufferExt.tmbLoading[h] = true; }); fm.request({ data : {cmd : 'tmb', targets : tmbs}, preventFail : true }) .done(function(data) { var errs = [], resLen; if (data.images) { if (resLen = Object.keys(data.images).length) { if (resLen < tmbs.length) { jQuery.each(tmbs, function(i, h) { if (! data.images[h]) { errs.push(h); } }); } attachThumbnails(data.images, reload); } else { errs = tmbs; } // unset error items from bufferExt.attachTmbs if (errs.length) { jQuery.each(errs, function(i, h) { delete bufferExt.attachTmbs[h]; }); } } if (reload) { if (reloads.length) { loadThumbnails(reloads); } } }) .always(function() { bufferExt.tmbLoading = {}; if (! reload && bufferExt.getTmbs.length) { loadThumbnails(); } }); } } }, /** * Add new files to cwd/buffer * * @param Array new files * @return void */ add = function(files, mode) { var place = list ? cwd.find('tbody') : cwd, l = files.length, atmb = {}, findNode = function(file) { var pointer = cwd.find('[id]:first'), file2; while (pointer.length) { file2 = fm.file(fm.cwdId2Hash(pointer.attr('id'))); if (!pointer.hasClass('elfinder-cwd-parent') && file2 && fm.compare(file, file2) < 0) { return pointer; } pointer = pointer.next('[id]'); } }, findIndex = function(file) { var l = buffer.length, i; for (i =0; i < l; i++) { if (fm.compare(file, buffer[i]) < 0) { return i; } } return l || -1; }, // created document fragment for jQuery >= 1.12, 2.2, 3.0 // see Studio-42/elFinder#1544 @ github docFlag = jQuery.htmlPrefilter? true : false, tempDom = docFlag? jQuery(document.createDocumentFragment()) : jQuery('<div/>'), file, hash, node, nodes, ndx, stmb; if (l > showFiles) { // re-render for performance tune content(); selectedFiles = fm.arrayFlip(jQuery.map(files, function(f) { return f.hash; }), true); trigger(); } else { // add the item immediately l && wz.removeClass('elfinder-cwd-wrapper-empty'); // Self thumbnail stmb = (fm.option('tmbUrl') === 'self'); while (l--) { file = files[l]; hash = file.hash; if (fm.cwdHash2Elm(hash).length) { continue; } if ((node = findNode(file)) && ! node.length) { node = null; } if (! node && (ndx = findIndex(file)) >= 0) { buffer.splice(ndx, 0, file); } else { tempDom.empty().append(itemhtml(file)); (file.mime === 'directory') && !mobile && makeDroppable(tempDom); nodes = docFlag? tempDom : tempDom.children(); if (node) { node.before(nodes); } else { place.append(nodes); } } if (fm.cwdHash2Elm(hash).length) { if ((file.tmb && (file.tmb != 1 || file.size > 0)) || (stmb && file.mime.indexOf('image/') === 0)) { atmb[hash] = file.tmb || 'self'; } } } if (list) { setColwidth(); fixTableHeader({fitWidth: ! colWidth}); } bottomMarkerShow(place); if (Object.keys(atmb).length) { Object.assign(bufferExt.attachTmbs, atmb); } } }, /** * Remove files from cwd/buffer * * @param Array files hashes * @return void */ remove = function(files) { var l = files.length, inSearch = fm.searchStatus.state > 1, curCmd = fm.getCommand(fm.currentReqCmd) || {}, hash, n, ndx, found; // removed cwd if (!fm.cwd().hash && !curCmd.noChangeDirOnRemovedCwd) { jQuery.each(cwdParents.reverse(), function(i, h) { if (fm.file(h)) { found = true; fm.one(fm.currentReqCmd + 'done', function() { !fm.cwd().hash && fm.exec('open', h); }); return false; } }); // fallback to fm.roots[0] !found && !fm.cwd().hash && fm.exec('open', fm.roots[Object.keys(fm.roots)[0]]); return; } while (l--) { hash = files[l]; if ((n = fm.cwdHash2Elm(hash)).length) { try { n.remove(); --bufferExt.renderd; } catch(e) { fm.debug('error', e); } } else if ((ndx = index(hash)) !== -1) { buffer.splice(ndx, 1); } selectedFiles[hash] && delete selectedFiles[hash]; if (inSearch) { if ((ndx = jQuery.inArray(hash, cwdHashes)) !== -1) { cwdHashes.splice(ndx, 1); } } } inSearch && fm.trigger('cwdhasheschange', cwdHashes); if (list) { setColwidth(); fixTableHeader({fitWidth: ! colWidth}); } }, customColsNameBuild = function() { var name = '', customColsName = ''; for (var i = 0; i < customCols.length; i++) { name = fm.getColumnName(customCols[i]); customColsName +='<td class="elfinder-cwd-view-th-'+customCols[i]+' sortable-item">'+name+'</td>'; } return customColsName; }, setItemBoxSize = function(boxSize) { var place, elm; if (!boxSize.height) { place = (list ? cwd.find('tbody') : cwd); elm = place.find(list? 'tr:first' : '[id]:first'); boxSize.height = elm.outerHeight(true); if (!list) { boxSize.width = elm.outerWidth(true); } } }, bottomMarkerShow = function(cur, cnt) { var place = cur || (list ? cwd.find('tbody') : cwd), boxSize = itemBoxSize[fm.viewType], col = 1, row; if (buffer.length > 0) { if (!bufferExt.hpi) { setItemBoxSize(boxSize); if (! list) { col = Math.floor(place.width() / boxSize.width); bufferExt.row = boxSize.height; bufferExt.hpi = bufferExt.row / col; } else { bufferExt.row = bufferExt.hpi = boxSize.height; } } else if (!list) { col = Math.floor(place.width() / boxSize.width); } row = Math.ceil((buffer.length + (cnt || 0)) / col); if (list && tableHeader) { ++row; } bottomMarker.css({top: (bufferExt.row * row) + 'px'}).show(); } }, wrapperContextMenu = { contextmenu : function(e) { e.preventDefault(); if (cwd.data('longtap') !== void(0)) { e.stopPropagation(); return; } fm.trigger('contextmenu', { 'type' : 'cwd', 'targets' : [fm.cwd().hash], 'x' : e.pageX, 'y' : e.pageY }); }, touchstart : function(e) { if (e.originalEvent.touches.length > 1) { return; } if (cwd.data('longtap') !== false) { wrapper.data('touching', {x: e.originalEvent.touches[0].pageX, y: e.originalEvent.touches[0].pageY}); cwd.data('tmlongtap', setTimeout(function(){ // long tap cwd.data('longtap', true); fm.trigger('contextmenu', { 'type' : 'cwd', 'targets' : [fm.cwd().hash], 'x' : wrapper.data('touching').x, 'y' : wrapper.data('touching').y }); }, 500)); } cwd.data('longtap', null); }, touchend : function(e) { if (e.type === 'touchmove') { if (! wrapper.data('touching') || ( Math.abs(wrapper.data('touching').x - e.originalEvent.touches[0].pageX) + Math.abs(wrapper.data('touching').y - e.originalEvent.touches[0].pageY)) > 4) { wrapper.data('touching', null); } } else { setTimeout(function() { cwd.removeData('longtap'); }, 80); } clearTimeout(cwd.data('tmlongtap')); }, click : function(e) { if (cwd.data('longtap')) { e.preventDefault(); e.stopPropagation(); } } }, /** * Update directory content * * @return void */ content = function() { fm.lazy(function() { var phash, emptyMethod, thtr; wz.append(selectAllCheckbox).removeClass('elfinder-cwd-wrapper-empty elfinder-search-result elfinder-incsearch-result elfinder-letsearch-result'); if (fm.searchStatus.state > 1 || fm.searchStatus.ininc) { wz.addClass('elfinder-search-result' + (fm.searchStatus.ininc? ' elfinder-'+(query.substr(0,1) === '/' ? 'let':'inc')+'search-result' : '')); } // abort attachThumbJob bufferExt.attachThumbJob && bufferExt.attachThumbJob._abort(); // destroy selectable for GC cwd.data('selectable') && cwd.selectable('disable').selectable('destroy').removeData('selectable'); // notify cwd init fm.trigger('cwdinit'); selectedNext = jQuery(); try { // to avoid problem with draggable cwd.empty(); } catch (e) { cwd.html(''); } if (tableHeader) { wrapper.off('scroll.fixheader resize.fixheader'); tableHeader.remove(); tableHeader = null; } cwd.removeClass('elfinder-cwd-view-icons elfinder-cwd-view-list') .addClass('elfinder-cwd-view-'+(list ? 'list' :'icons')) .attr('style', '') .css('height', 'auto'); bottomMarker.hide(); wrapper[list ? 'addClass' : 'removeClass']('elfinder-cwd-wrapper-list')._padding = parseInt(wrapper.css('padding-top')) + parseInt(wrapper.css('padding-bottom')); if (fm.UA.iOS) { wrapper.removeClass('overflow-scrolling-touch').addClass('overflow-scrolling-touch'); } if (list) { cwd.html('<table><thead/><tbody/></table>'); thtr = jQuery('<tr class="ui-state-default"><td class="elfinder-cwd-view-th-name">'+fm.getColumnName('name')+'</td>'+customColsNameBuild()+'</tr>'); cwd.find('thead').hide().append(thtr).find('td:first').append(selectAllCheckbox); if (jQuery.fn.sortable) { thtr.addClass('touch-punch touch-punch-keep-default') .sortable({ axis: 'x', distance: 8, items: '> .sortable-item', start: function(e, ui) { jQuery(ui.item[0]).data('dragging', true); ui.placeholder .width(ui.helper.removeClass('ui-state-hover').width()) .removeClass('ui-state-active') .addClass('ui-state-hover') .css('visibility', 'visible'); }, update: function(e, ui){ var target = jQuery(ui.item[0]).attr('class').split(' ')[0].replace('elfinder-cwd-view-th-', ''), prev, done; customCols = jQuery.map(jQuery(this).children(), function(n) { var name = jQuery(n).attr('class').split(' ')[0].replace('elfinder-cwd-view-th-', ''); if (! done) { if (target === name) { done = true; } else { prev = name; } } return (name === 'name')? null : name; }); templates.row = makeTemplateRow(); fm.storage('cwdCols', customCols); prev = '.elfinder-col-'+prev+':first'; target = '.elfinder-col-'+target+':first'; fm.lazy(function() { cwd.find('tbody tr').each(function() { var $this = jQuery(this); $this.children(prev).after($this.children(target)); }); }); }, stop: function(e, ui) { setTimeout(function() { jQuery(ui.item[0]).removeData('dragging'); }, 100); } }); } thtr.find('td').addClass('touch-punch').resizable({ handles: fm.direction === 'ltr'? 'e' : 'w', start: function(e, ui) { var target = cwd.find('td.elfinder-col-' + ui.element.attr('class').split(' ')[0].replace('elfinder-cwd-view-th-', '') + ':first'); ui.element .data('dragging', true) .data('resizeTarget', target) .data('targetWidth', target.width()); colResizing = true; if (cwd.find('table').css('table-layout') !== 'fixed') { cwd.find('tbody tr:first td').each(function() { jQuery(this).width(jQuery(this).width()); }); cwd.find('table').css('table-layout', 'fixed'); } }, resize: function(e, ui) { ui.element.data('resizeTarget').width(ui.element.data('targetWidth') - (ui.originalSize.width - ui.size.width)); }, stop : function(e, ui) { colResizing = false; fixTableHeader({fitWidth: true}); colWidth = {}; cwd.find('tbody tr:first td').each(function() { var name = jQuery(this).attr('class').split(' ')[0].replace('elfinder-col-', ''); colWidth[name] = jQuery(this).width(); }); fm.storage('cwdColWidth', colWidth); setTimeout(function() { ui.element.removeData('dragging'); }, 100); } }) .find('.ui-resizable-handle').addClass('ui-icon ui-icon-grip-dotted-vertical'); } buffer = jQuery.map(incHashes || cwdHashes, function(hash) { return fm.file(hash) || null; }); buffer = fm.sortFiles(buffer); if (incHashes) { incHashes = jQuery.map(buffer, function(f) { return f.hash; }); } else { cwdHashes = jQuery.map(buffer, function(f) { return f.hash; }); } bufferExt = { renderd: 0, attachTmbs: {}, getTmbs: [], tmbLoading: {}, lazyOpts: { tm : 0 } }; wz[(buffer.length < 1) ? 'addClass' : 'removeClass']('elfinder-cwd-wrapper-empty'); wrapper.off(scrollEvent, render).on(scrollEvent, render).trigger(scrollEvent); // set droppable if (!fm.cwd().write) { wrapper.removeClass('native-droppable') .droppable('disable') .removeClass('ui-state-disabled'); // for old jQueryUI see https://bugs.jqueryui.com/ticket/5974 } else { wrapper[fm.isCommandEnabled('upload')? 'addClass' : 'removeClass']('native-droppable'); wrapper.droppable(fm.isCommandEnabled('paste')? 'enable' : 'disable'); } }); }, /** * CWD node itself * * @type JQuery **/ cwd = jQuery(this) .addClass('ui-helper-clearfix elfinder-cwd') .attr('unselectable', 'on') // fix ui.selectable bugs and add shift+click support .on('click.'+fm.namespace, fileSelector, function(e) { var p = this.id ? jQuery(this) : jQuery(this).parents('[id]:first'), tgt = jQuery(e.target), prev, next, pl, nl, sib; if (selectCheckbox && (tgt.is('input:checkbox.'+clSelChk) || tgt.hasClass('elfinder-cwd-select'))) { e.stopPropagation(); e.preventDefault(); p.trigger(p.hasClass(clSelected) ? evtUnselect : evtSelect); trigger(); requestAnimationFrame(function() { tgt.prop('checked', p.hasClass(clSelected)); }); return; } if (cwd.data('longtap') || tgt.hasClass('elfinder-cwd-nonselect')) { e.stopPropagation(); return; } if (!curClickId) { curClickId = p.attr('id'); setTimeout(function() { curClickId = ''; }, 500); } if (e.shiftKey) { prev = p.prevAll(lastSelect || '.'+clSelected+':first'); next = p.nextAll(lastSelect || '.'+clSelected+':first'); pl = prev.length; nl = next.length; } if (e.shiftKey && (pl || nl)) { sib = pl ? p.prevUntil('#'+prev.attr('id')) : p.nextUntil('#'+next.attr('id')); sib.add(p).trigger(evtSelect); } else if (e.ctrlKey || e.metaKey) { p.trigger(p.hasClass(clSelected) ? evtUnselect : evtSelect); } else { if (wrapper.data('touching') && p.hasClass(clSelected)) { wrapper.data('touching', null); fm.dblclick({file : fm.cwdId2Hash(this.id)}); return; } else { unselectAll({ notrigger: true }); p.trigger(evtSelect); } } trigger(); }) // call fm.open() .on('dblclick.'+fm.namespace, fileSelector, function(e) { if (curClickId) { var hash = fm.cwdId2Hash(curClickId); e.stopPropagation(); if (this.id !== curClickId) { jQuery(this).trigger(evtUnselect); jQuery('#'+curClickId).trigger(evtSelect); trigger(); } fm.dblclick({file : hash}); } }) // for touch device .on('touchstart.'+fm.namespace, fileSelector, function(e) { if (e.originalEvent.touches.length > 1) { return; } var p = this.id ? jQuery(this) : jQuery(this).parents('[id]:first'), tgt = jQuery(e.target), nodeName = e.target.nodeName, sel; if ((nodeName === 'INPUT' && e.target.type === 'text') || nodeName === 'TEXTAREA' || tgt.hasClass('elfinder-cwd-nonselect')) { e.stopPropagation(); return; } // now name editing if (p.find('input:text,textarea').length) { e.stopPropagation(); e.preventDefault(); return; } wrapper.data('touching', {x: e.originalEvent.touches[0].pageX, y: e.originalEvent.touches[0].pageY}); if (selectCheckbox && (tgt.is('input:checkbox.'+clSelChk) || tgt.hasClass('elfinder-cwd-select'))) { return; } sel = p.prevAll('.'+clSelected+':first').length + p.nextAll('.'+clSelected+':first').length; cwd.data('longtap', null); if (Object.keys(selectedFiles).length || (list && e.target.nodeName !== 'TD') || (!list && this !== e.target) ) { cwd.data('longtap', false); p.addClass(clHover); p.data('tmlongtap', setTimeout(function(){ // long tap cwd.data('longtap', true); p.trigger(evtSelect); trigger(); fm.trigger('contextmenu', { 'type' : 'files', 'targets' : fm.selected(), 'x' : e.originalEvent.touches[0].pageX, 'y' : e.originalEvent.touches[0].pageY }); }, 500)); } }) .on('touchmove.'+fm.namespace+' touchend.'+fm.namespace, fileSelector, function(e) { var tgt = jQuery(e.target), p; if (selectCheckbox && (tgt.is('input:checkbox.'+clSelChk) || tgt.hasClass('elfinder-cwd-select'))) { return; } if (e.target.nodeName == 'INPUT' || e.target.nodeName == 'TEXTAREA') { e.stopPropagation(); return; } p = this.id ? jQuery(this) : jQuery(this).parents('[id]:first'); clearTimeout(p.data('tmlongtap')); if (e.type === 'touchmove') { wrapper.data('touching', null); p.removeClass(clHover); } else { if (wrapper.data('touching') && !cwd.data('longtap') && p.hasClass(clSelected)) { e.preventDefault(); wrapper.data('touching', null); fm.dblclick({file : fm.cwdId2Hash(this.id)}); } setTimeout(function() { cwd.removeData('longtap'); }, 80); } }) // attach draggable .on('mouseenter.'+fm.namespace, fileSelector, function(e) { if (scrolling) { return; } var $this = jQuery(this), helper = null; if (!mobile && !$this.data('dragRegisted') && !$this.hasClass(clTmp) && !$this.hasClass(clDraggable) && !$this.hasClass(clDisabled)) { $this.data('dragRegisted', true); if (!fm.isCommandEnabled('copy', fm.searchStatus.state > 1 || $this.hasClass('isroot')? fm.cwdId2Hash($this.attr('id')) : void 0)) { return; } $this.on('mousedown', function(e) { // shiftKey or altKey + drag start for HTML5 native drag function // Note: can no use shiftKey with the Google Chrome var metaKey = e.shiftKey || e.altKey, disable = false; if (metaKey && !fm.UA.IE && cwd.data('selectable')) { // destroy jQuery-ui selectable while trigger native drag cwd.selectable('disable').selectable('destroy').removeData('selectable'); requestAnimationFrame(function(){ cwd.selectable(selectableOption).selectable('option', {disabled: false}).selectable('refresh').data('selectable', true); }); } $this.removeClass('ui-state-disabled'); if (metaKey) { $this.draggable('option', 'disabled', true).attr('draggable', 'true'); } else { if (!$this.hasClass(clSelected)) { if (list) { disable = jQuery(e.target).closest('span,tr').is('tr'); } else { disable = jQuery(e.target).hasClass('elfinder-cwd-file'); } } if (disable) { $this.draggable('option', 'disabled', true); } else { $this.draggable('option', 'disabled', false) .removeAttr('draggable') .draggable('option', 'cursorAt', {left: 50 - parseInt(jQuery(e.currentTarget).css('margin-left')), top: 47}); } } }) .on('dragstart', function(e) { var dt = e.dataTransfer || e.originalEvent.dataTransfer || null; helper = null; if (dt && !fm.UA.IE) { var p = this.id ? jQuery(this) : jQuery(this).parents('[id]:first'), elm = jQuery('<span>'), url = '', durl = null, murl = null, files = [], icon = function(f) { var mime = f.mime, i, tmb = fm.tmb(f); i = '<div class="elfinder-cwd-icon elfinder-cwd-icon-drag '+fm.mime2class(mime)+' ui-corner-all"/>'; if (tmb) { i = jQuery(i).addClass(tmb.className).css('background-image', "url('"+tmb.url+"')").get(0).outerHTML; } return i; }, l, geturl = []; p.trigger(evtSelect); trigger(); jQuery.each(selectedFiles, function(v){ var file = fm.file(v), furl = file.url; if (file && file.mime !== 'directory') { if (!furl) { furl = fm.url(file.hash); } else if (furl == '1') { geturl.push(v); return true; } if (furl) { furl = fm.convAbsUrl(furl); files.push(v); jQuery('<a>').attr('href', furl).text(furl).appendTo(elm); url += furl + "\n"; if (!durl) { durl = file.mime + ':' + file.name + ':' + furl; } if (!murl) { murl = furl + "\n" + file.name; } } } }); if (geturl.length) { jQuery.each(geturl, function(i, v){ var rfile = fm.file(v); rfile.url = ''; fm.request({ data : {cmd : 'url', target : v}, notify : {type : 'url', cnt : 1}, preventDefault : true }) .always(function(data) { rfile.url = data.url? data.url : '1'; }); }); return false; } else if (url) { if (dt.setDragImage) { helper = jQuery('<div class="elfinder-drag-helper html5-native"></div>').append(icon(fm.file(files[0]))).appendTo(jQuery(document.body)); if ((l = files.length) > 1) { helper.append(icon(fm.file(files[l-1])) + '<span class="elfinder-drag-num">'+l+'</span>'); } dt.setDragImage(helper.get(0), 50, 47); } dt.effectAllowed = 'copyLink'; dt.setData('DownloadURL', durl); dt.setData('text/x-moz-url', murl); dt.setData('text/uri-list', url); dt.setData('text/plain', url); dt.setData('text/html', elm.html()); dt.setData('elfinderfrom', window.location.href + fm.cwd().hash); dt.setData('elfinderfrom:' + dt.getData('elfinderfrom'), ''); } else { return false; } } }) .on('dragend', function(e){ unselectAll({ notrigger: true }); helper && helper.remove(); }) .draggable(fm.draggable); } }) // add hover class to selected file .on(evtSelect, fileSelector, function(e) { var $this = jQuery(this), id = fm.cwdId2Hash($this.attr('id')); if (!selectLock && !$this.hasClass(clDisabled)) { lastSelect = '#'+ this.id; $this.addClass(clSelected).children().addClass(clHover).find('input:checkbox.'+clSelChk).prop('checked', true); if (! selectedFiles[id]) { selectedFiles[id] = true; } // will be selected next selectedNext = cwd.find('[id].'+clSelected+':last').next(); } }) // remove hover class from unselected file .on(evtUnselect, fileSelector, function(e) { var $this = jQuery(this), id = fm.cwdId2Hash($this.attr('id')); if (!selectLock) { $this.removeClass(clSelected).children().removeClass(clHover).find('input:checkbox.'+clSelChk).prop('checked', false); if (cwd.hasClass('elfinder-cwd-allselected')) { selectCheckbox && selectAllCheckbox.children('input').prop('checked', false); cwd.removeClass('elfinder-cwd-allselected'); } selectedFiles[id] && delete selectedFiles[id]; } }) // disable files wich removing or moving .on(evtDisable, fileSelector, function() { var $this = jQuery(this).removeClass(clHover+' '+clSelected).addClass(clDisabled), child = $this.children(), target = (list ? $this : child.find('div.elfinder-cwd-file-wrapper,div.elfinder-cwd-filename')); child.removeClass(clHover+' '+clSelected); $this.hasClass(clDroppable) && $this.droppable('disable'); target.hasClass(clDraggable) && target.draggable('disable'); }) // if any files was not removed/moved - unlock its .on(evtEnable, fileSelector, function() { var $this = jQuery(this).removeClass(clDisabled), target = list ? $this : $this.children('div.elfinder-cwd-file-wrapper,div.elfinder-cwd-filename'); $this.hasClass(clDroppable) && $this.droppable('enable'); target.hasClass(clDraggable) && target.draggable('enable'); }) .on('scrolltoview', fileSelector, function(e, data) { scrollToView(jQuery(this), (data && typeof data.blink !== 'undefined')? data.blink : true); }) .on('mouseenter.'+fm.namespace+' mouseleave.'+fm.namespace, fileSelector, function(e) { var enter = (e.type === 'mouseenter'); if (enter && (scrolling || fm.UA.Mobile)) { return; } fm.trigger('hover', {hash : fm.cwdId2Hash(jQuery(this).attr('id')), type : e.type}); jQuery(this).toggleClass(clHover, (e.type == 'mouseenter')); }) // for file contextmenu .on('mouseenter.'+fm.namespace+' mouseleave.'+fm.namespace, '.elfinder-cwd-file-wrapper,.elfinder-cwd-filename', function(e) { var enter = (e.type === 'mouseenter'); if (enter && scrolling) { return; } jQuery(this).closest(fileSelector).children('.elfinder-cwd-file-wrapper,.elfinder-cwd-filename').toggleClass(clActive, (e.type == 'mouseenter')); }) .on('contextmenu.'+fm.namespace, function(e) { var file = jQuery(e.target).closest(fileSelector); if (file.get(0) === e.target && !selectedFiles[fm.cwdId2Hash(file.get(0).id)]) { return; } // now filename editing if (file.find('input:text,textarea').length) { e.stopPropagation(); return; } if (file.length && (e.target.nodeName != 'TD' || selectedFiles[fm.cwdId2Hash(file.get(0).id)])) { e.stopPropagation(); e.preventDefault(); if (!file.hasClass(clDisabled) && !wrapper.data('touching')) { if (!file.hasClass(clSelected)) { unselectAll({ notrigger: true }); file.trigger(evtSelect); trigger(); } fm.trigger('contextmenu', { 'type' : 'files', 'targets' : fm.selected(), 'x' : e.pageX, 'y' : e.pageY }); } } }) // unselect all on cwd click .on('click.'+fm.namespace, function(e) { if (e.target === this && ! cwd.data('longtap')) { !e.shiftKey && !e.ctrlKey && !e.metaKey && unselectAll(); } }) // prepend fake file/dir .on('create.'+fm.namespace, function(e, f) { var parent = list ? cwd.find('tbody') : cwd, p = parent.find('.elfinder-cwd-parent'), lock = f.move || false, file = jQuery(itemhtml(f)).addClass(clTmp), selected = fm.selected(); if (selected.length) { lock && fm.trigger('lockfiles', {files: selected}); } else { unselectAll(); } if (p.length) { p.after(file); } else { parent.prepend(file); } setColwidth(); wrapper.scrollTop(0).scrollLeft(0); }) // unselect all selected files .on('unselectall', unselectAll) .on('selectfile', function(e, id) { fm.cwdHash2Elm(id).trigger(evtSelect); trigger(); }) .on('colwidth', function() { if (list) { cwd.find('table').css('table-layout', '') .find('td').css('width', ''); fixTableHeader({fitWidth: true}); fm.storage('cwdColWidth', colWidth = null); } }) .on('iconpref', function(e, data) { cwd.removeClass(function(i, cName) { return (cName.match(/\belfinder-cwd-size\S+/g) || []).join(' '); }); iconSize = data? (parseInt(data.size) || 0) : 0; if (!list) { if (iconSize > 0) { cwd.addClass('elfinder-cwd-size' + iconSize); } if (bufferExt.renderd) { requestAnimationFrame(function() { itemBoxSize.icons = {}; bufferExt.hpi = null; bottomMarkerShow(cwd, bufferExt.renderd); wrapperRepaint(); }); } } }) // Change icon size with mouse wheel event .on('onwheel' in document ? 'wheel' : 'mousewheel', function(e) { var tm, size, delta; if (!list && ((e.ctrlKey && !e.metaKey) || (!e.ctrlKey && e.metaKey))) { e.stopPropagation(); e.preventDefault(); tm = cwd.data('wheelTm'); if (typeof tm !== 'undefined') { clearTimeout(tm); cwd.data('wheelTm', setTimeout(function() { cwd.removeData('wheelTm'); }, 200)); } else { cwd.data('wheelTm', false); size = iconSize || 0; delta = e.originalEvent.deltaY ? e.originalEvent.deltaY : -(e.originalEvent.wheelDelta); if (delta > 0) { if (iconSize > 0) { size = iconSize - 1; } } else { if (iconSize < options.iconsView.sizeMax) { size = iconSize + 1; } } if (size !== iconSize) { fm.storage('iconsize', size); cwd.trigger('iconpref', {size: size}); } } } }), wrapper = jQuery('<div class="elfinder-cwd-wrapper"/>') // make cwd itself droppable for folders from nav panel .droppable(Object.assign({}, droppable, {autoDisable: false})) .on('contextmenu.'+fm.namespace, wrapperContextMenu.contextmenu) .on('touchstart.'+fm.namespace, wrapperContextMenu.touchstart) .on('touchmove.'+fm.namespace+' touchend.'+fm.namespace, wrapperContextMenu.touchend) .on('click.'+fm.namespace, wrapperContextMenu.click) .on('scroll.'+fm.namespace, function() { if (! scrolling) { cwd.data('selectable') && cwd.selectable('disable'); wrapper.trigger(scrollStartEvent); } scrolling = true; bufferExt.scrtm && cancelAnimationFrame(bufferExt.scrtm); if (bufferExt.scrtm && Math.abs((bufferExt.scrolltop || 0) - (bufferExt.scrolltop = (this.scrollTop || jQuery(this).scrollTop()))) < 5) { bufferExt.scrtm = 0; wrapper.trigger(scrollEvent); } bufferExt.scrtm = requestAnimationFrame(function() { bufferExt.scrtm = 0; wrapper.trigger(scrollEvent); }); }) .on(scrollEvent, function() { scrolling = false; wrapperRepaint(); }), bottomMarker = jQuery('<div> </div>') .css({position: 'absolute', width: '1px', height: '1px'}) .hide(), selectAllCheckbox = selectCheckbox? jQuery('<div class="elfinder-cwd-selectall"><input type="checkbox"/></div>') .attr('title', fm.i18n('selectall')) .on('touchstart mousedown click', function(e) { e.stopPropagation(); e.preventDefault(); if (jQuery(this).data('pending') || e.type === 'click') { return false; } selectAllCheckbox.data('pending', true); if (cwd.hasClass('elfinder-cwd-allselected')) { selectAllCheckbox.find('input').prop('checked', false); requestAnimationFrame(function() { unselectAll(); }); } else { selectAll(); } }) : jQuery(), restm = null, resize = function(init) { var initHeight = function() { if (typeof bufferExt.renderd !== 'undefined') { var h = 0; wrapper.siblings('div.elfinder-panel:visible').each(function() { h += jQuery(this).outerHeight(true); }); wrapper.height(wz.height() - h - wrapper._padding); } }; init && initHeight(); restm && cancelAnimationFrame(restm); restm = requestAnimationFrame(function(){ !init && initHeight(); var wph, cwdoh; // fix cwd height if it less then wrapper cwd.css('height', 'auto'); wph = wrapper[0].clientHeight - parseInt(wrapper.css('padding-top')) - parseInt(wrapper.css('padding-bottom')) - parseInt(cwd.css('margin-top')), cwdoh = cwd.outerHeight(true); if (cwdoh < wph) { cwd.height(wph); } }); list && ! colResizing && (init? wrapper.trigger('resize.fixheader') : fixTableHeader()); wrapperRepaint(); }, // elfinder node parent = jQuery(this).parent().on('resize', resize), // workzone node wz = parent.children('.elfinder-workzone').append(wrapper.append(this).append(bottomMarker)), // message board mBoard = jQuery('<div class="elfinder-cwd-message-board"/>').insertAfter(cwd), // Volume expires vExpires = jQuery('<div class="elfinder-cwd-expires" />'), vExpiresTm, showVolumeExpires = function() { var remain, sec, int; vExpiresTm && clearTimeout(vExpiresTm); if (curVolId && fm.volumeExpires[curVolId]) { sec = fm.volumeExpires[curVolId] - ((+new Date()) / 1000); int = (sec % 60) + 0.1; remain = Math.floor(sec / 60); vExpires.html(fm.i18n(['minsLeft', remain])).show(); if (remain) { vExpiresTm = setTimeout(showVolumeExpires, int * 1000); } } }, // each item box size itemBoxSize = { icons : {}, list : {} }, // has UI tree hasUiTree, // Icon size of icons view iconSize, // Current volume id curVolId, winScrTm; // IE < 11 not support CSS `pointer-events: none` if (!fm.UA.ltIE10) { mBoard.append(jQuery('<div class="elfinder-cwd-trash" />').html(fm.i18n('volume_Trash'))) .append(vExpires); } // setup by options replacement = Object.assign(replacement, options.replacement || {}); try { colWidth = fm.storage('cwdColWidth')? fm.storage('cwdColWidth') : null; } catch(e) { colWidth = null; } // setup costomCols fm.bind('columnpref', function(e) { var opts = e.data || {}; if (customCols = fm.storage('cwdCols')) { customCols = jQuery.grep(customCols, function(n) { return (options.listView.columns.indexOf(n) !== -1)? true : false; }); if (options.listView.columns.length > customCols.length) { jQuery.each(options.listView.columns, function(i, n) { if (customCols.indexOf(n) === -1) { customCols.push(n); } }); } } else { customCols = options.listView.columns; } // column names array that hidden var columnhides = fm.storage('columnhides') || null; if (columnhides && Object.keys(columnhides).length) customCols = jQuery.grep(customCols, function(n) { return columnhides[n]? false : true; }); // make template with customCols templates.row = makeTemplateRow(); // repaint if need it list && opts.repaint && content(); }).trigger('columnpref'); if (mobile) { // for iOS5 bug jQuery('body').on('touchstart touchmove touchend', function(e){}); } selectCheckbox && cwd.addClass('elfinder-has-checkbox'); jQuery(window).on('scroll.'+fm.namespace, function() { winScrTm && cancelAnimationFrame(winScrTm); winScrTm = requestAnimationFrame(function() { wrapper.trigger(scrollEvent); }); }); jQuery(document).on('keydown.'+fm.namespace, function(e) { if (e.keyCode == jQuery.ui.keyCode.ESCAPE) { if (! fm.getUI().find('.ui-widget:visible').length) { unselectAll(); } } }); fm .one('init', function(){ var style = document.createElement('style'), sheet, node, base, resizeTm, iconSize, i = 0; if (document.head) { document.head.appendChild(style); sheet = style.sheet; sheet.insertRule('.elfinder-cwd-wrapper-empty .elfinder-cwd:not(.elfinder-table-header-sticky):after{ content:"'+fm.i18n('emptyFolder')+'" }', i++); sheet.insertRule('.elfinder-cwd-wrapper-empty .native-droppable .elfinder-cwd:not(.elfinder-table-header-sticky):after{ content:"'+fm.i18n('emptyFolder'+(mobile? 'LTap' : 'Drop'))+'" }', i++); sheet.insertRule('.elfinder-cwd-wrapper-empty .ui-droppable-disabled .elfinder-cwd:not(.elfinder-table-header-sticky):after{ content:"'+fm.i18n('emptyFolder')+'" }', i++); sheet.insertRule('.elfinder-cwd-wrapper-empty.elfinder-search-result .elfinder-cwd:not(.elfinder-table-header-sticky):after{ content:"'+fm.i18n('emptySearch')+'" }', i++); sheet.insertRule('.elfinder-cwd-wrapper-empty.elfinder-search-result.elfinder-incsearch-result .elfinder-cwd:not(.elfinder-table-header-sticky):after{ content:"'+fm.i18n('emptyIncSearch')+'" }', i++); sheet.insertRule('.elfinder-cwd-wrapper-empty.elfinder-search-result.elfinder-letsearch-result .elfinder-cwd:not(.elfinder-table-header-sticky):after{ content:"'+fm.i18n('emptyLetSearch')+'" }', i++); } if (iconSize = fm.storage('iconsize') || 0) { cwd.trigger('iconpref', {size: iconSize}); } if (! mobile) { fm.one('open', function() { sheet && fm.zIndex && sheet.insertRule('.ui-selectable-helper{z-index:'+fm.zIndex+';}', i++); }); base = jQuery('<div style="position:absolute"/>'); node = fm.getUI(); node.on('resize', function(e, data) { var offset; e.preventDefault(); e.stopPropagation(); if (data && data.fullscreen) { offset = node.offset(); if (data.fullscreen === 'on') { base.css({top:offset.top * -1 , left:offset.left * -1 }).appendTo(node); selectableOption.appendTo = base; } else { base.detach(); selectableOption.appendTo = 'body'; } cwd.data('selectable') && cwd.selectable('option', {appendTo : selectableOption.appendTo}); } }); } hasUiTree = fm.getUI('tree').length; }) .bind('enable', function() { resize(); }) .bind('request.open', function() { bufferExt.getTmbs = []; }) .one('open', function() { if (fm.maxTargets) { tmbNum = Math.min(fm.maxTargets, tmbNum); } }) .bind('open add remove searchend', function() { var phash = fm.cwd().hash, type = this.type; if (type === 'open' || type === 'searchend' || fm.searchStatus.state < 2) { cwdHashes = jQuery.map(fm.files(phash), function(f) { return f.hash; }); fm.trigger('cwdhasheschange', cwdHashes); } if (type === 'open') { var inTrash = function() { var isIn = false; jQuery.each(cwdParents, function(i, h) { if (fm.trashes[h]) { isIn = true; return false; } }); return isIn; }, req = phash? (! fm.file(phash) || hasUiTree? (! hasUiTree? fm.request({ data: { cmd : 'parents', target : fm.cwd().hash }, preventFail : true }) : (function() { var dfd = jQuery.Deferred(); fm.one('treesync', function(e) { e.data.always(function() { dfd.resolve(); }); }); return dfd; })() ) : null ) : null, cwdObj = fm.cwd(); // add/remove volume id class if (cwdObj.volumeid !== curVolId) { vExpires.empty().hide(); if (curVolId) { wrapper.removeClass('elfinder-cwd-wrapper-' + curVolId); } curVolId = cwdObj.volumeid; showVolumeExpires(); wrapper.addClass('elfinder-cwd-wrapper-' + curVolId); } // add/remove trash class jQuery.when(req).done(function() { cwdParents = fm.parents(cwdObj.hash); wrapper[inTrash()? 'addClass':'removeClass']('elfinder-cwd-wrapper-trash'); }); incHashes = void 0; unselectAll({ notrigger: true }); content(); } }) .bind('search', function(e) { cwdHashes = jQuery.map(e.data.files, function(f) { return f.hash; }); fm.trigger('cwdhasheschange', cwdHashes); incHashes = void 0; fm.searchStatus.ininc = false; content(); fm.autoSync('stop'); }) .bind('searchend', function(e) { if (query || incHashes) { query = ''; if (incHashes) { fm.trigger('incsearchend', e.data); } else { if (!e.data || !e.data.noupdate) { content(); } } } fm.autoSync(); }) .bind('searchstart', function(e) { unselectAll(); query = e.data.query; }) .bind('incsearchstart', function(e) { selectedFiles = {}; fm.lazy(function() { // incremental search var regex, q, fst = ''; q = query = e.data.query || ''; if (q) { if (q.substr(0,1) === '/') { q = q.substr(1); fst = '^'; } regex = new RegExp(fst + q.replace(/([\\*\;\.\?\[\]\{\}\(\)\^\$\-\|])/g, '\\$1'), 'i'); incHashes = jQuery.grep(cwdHashes, function(hash) { var file = fm.file(hash); return (file && (file.name.match(regex) || (file.i18 && file.i18.match(regex))))? true : false; }); fm.trigger('incsearch', { hashes: incHashes, query: q }) .searchStatus.ininc = true; content(); fm.autoSync('stop'); } else { fm.trigger('incsearchend'); } }); }) .bind('incsearchend', function(e) { query = ''; fm.searchStatus.ininc = false; incHashes = void 0; if (!e.data || !e.data.noupdate) { content(); } fm.autoSync(); }) .bind('sortchange', function() { var lastScrollLeft = wrapper.scrollLeft(), allsel = cwd.hasClass('elfinder-cwd-allselected'); content(); fm.one('cwdrender', function() { wrapper.scrollLeft(lastScrollLeft); if (allsel) { selectedFiles = fm.arrayFlip(incHashes || cwdHashes, true); } (allsel || Object.keys(selectedFiles).length) && trigger(); }); }) .bind('viewchange', function() { var l = fm.storage('view') == 'list', allsel = cwd.hasClass('elfinder-cwd-allselected'); if (l != list) { list = l; fm.viewType = list? 'list' : 'icons'; if (iconSize) { fm.one('cwdinit', function() { cwd.trigger('iconpref', {size: iconSize}); }); } content(); resize(); if (allsel) { cwd.addClass('elfinder-cwd-allselected'); selectAllCheckbox.find('input').prop('checked', true); } Object.keys(selectedFiles).length && trigger(); } }) .bind('wzresize', function() { var place = list ? cwd.find('tbody') : cwd, cwdOffset; resize(true); if (bufferExt.hpi) { bottomMarkerShow(place, place.find('[id]').length); } cwdOffset = cwd.offset(); wz.data('rectangle', Object.assign( { width: wz.width(), height: wz.height(), cwdEdge: (fm.direction === 'ltr')? cwdOffset.left : cwdOffset.left + cwd.width() }, wz.offset()) ); bufferExt.itemH = (list? place.find('tr:first') : place.find('[id]:first')).outerHeight(true); }) .bind('changeclipboard', function(e) { clipCuts = {}; if (e.data && e.data.clipboard && e.data.clipboard.length) { jQuery.each(e.data.clipboard, function(i, f) { if (f.cut) { clipCuts[f.hash] = true; } }); } }) .bind('resMixinMake', function() { setColwidth(); }) .bind('tmbreload', function(e) { var imgs = {}, files = (e.data && e.data.files)? e.data.files : null; jQuery.each(files, function(i, f) { if (f.tmb && f.tmb != '1') { imgs[f.hash] = f.tmb; } }); if (Object.keys(imgs).length) { attachThumbnails(imgs, true); } }) .add(function(e) { var regex = query? new RegExp(query.replace(/([\\*\;\.\?\[\]\{\}\(\)\^\$\-\|])/g, '\\$1'), 'i') : null, mime = fm.searchStatus.mime, inSearch = fm.searchStatus.state > 1, phash = inSearch && fm.searchStatus.target? fm.searchStatus.target : fm.cwd().hash, curPath = fm.path(phash), inTarget = function(f) { var res, parents, path; res = (f.phash === phash); if (!res && inSearch) { path = f.path || fm.path(f.hash); res = (curPath && path.indexOf(curPath) === 0); if (! res && fm.searchStatus.mixed) { res = jQuery.grep(fm.searchStatus.mixed, function(vid) { return f.hash.indexOf(vid) === 0? true : false; }).length? true : false; } } if (res && inSearch) { if (mime) { res = (f.mime.indexOf(mime) === 0); } else { res = (f.name.match(regex) || (f.i18 && f.i18.match(regex)))? true : false; } } return res; }, files = jQuery.grep(e.data.added || [], function(f) { return inTarget(f)? true : false ;}); add(files); if (fm.searchStatus.state === 2) { jQuery.each(files, function(i, f) { if (jQuery.inArray(f.hash, cwdHashes) === -1) { cwdHashes.push(f.hash); } }); fm.trigger('cwdhasheschange', cwdHashes); } list && resize(); wrapper.trigger(scrollEvent); }) .change(function(e) { var phash = fm.cwd().hash, sel = fm.selected(), files, added; if (query) { jQuery.each(e.data.changed || [], function(i, file) { if (fm.cwdHash2Elm(file.hash).length) { remove([file.hash]); add([file], 'change'); jQuery.inArray(file.hash, sel) !== -1 && selectFile(file.hash); added = true; } }); } else { jQuery.each(jQuery.grep(e.data.changed || [], function(f) { return f.phash == phash ? true : false; }), function(i, file) { if (fm.cwdHash2Elm(file.hash).length) { remove([file.hash]); add([file], 'change'); jQuery.inArray(file.hash, sel) !== -1 && selectFile(file.hash); added = true; } }); } if (added) { fm.trigger('cwdhasheschange', cwdHashes); list && resize(); wrapper.trigger(scrollEvent); } trigger(); }) .remove(function(e) { var place = list ? cwd.find('tbody') : cwd; remove(e.data.removed || []); trigger(); if (buffer.length < 1 && place.children(fileSelector).length < 1) { wz.addClass('elfinder-cwd-wrapper-empty'); selectCheckbox && selectAllCheckbox.find('input').prop('checked', false); bottomMarker.hide(); wrapper.off(scrollEvent, render); resize(); } else { bottomMarkerShow(place); wrapper.trigger(scrollEvent); } }) // select dragged file if no selected, disable selectable .dragstart(function(e) { var target = jQuery(e.data.target), oe = e.data.originalEvent; if (target.hasClass(clFile)) { if (!target.hasClass(clSelected)) { !(oe.ctrlKey || oe.metaKey || oe.shiftKey) && unselectAll({ notrigger: true }); target.trigger(evtSelect); trigger(); } } cwd.removeClass(clDisabled).data('selectable') && cwd.selectable('disable'); selectLock = true; }) // enable selectable .dragstop(function() { cwd.data('selectable') && cwd.selectable('enable'); selectLock = false; }) .bind('lockfiles unlockfiles selectfiles unselectfiles', function(e) { var events = { lockfiles : evtDisable , unlockfiles : evtEnable , selectfiles : evtSelect, unselectfiles : evtUnselect }, event = events[e.type], files = e.data.files || [], l = files.length, helper = e.data.helper || jQuery(), parents, ctr, add; if (l > 0) { parents = fm.parents(files[0]); } if (event === evtSelect || event === evtUnselect) { add = (event === evtSelect), jQuery.each(files, function(i, hash) { var all = cwd.hasClass('elfinder-cwd-allselected'); if (! selectedFiles[hash]) { add && (selectedFiles[hash] = true); } else { if (all) { selectCheckbox && selectAllCheckbox.children('input').prop('checked', false); cwd.removeClass('elfinder-cwd-allselected'); all = false; } ! add && delete selectedFiles[hash]; } }); } if (!helper.data('locked')) { while (l--) { try { fm.cwdHash2Elm(files[l]).trigger(event); } catch(e) {} } ! e.data.inselect && trigger(); } if (wrapper.data('dropover') && parents.indexOf(wrapper.data('dropover')) !== -1) { ctr = e.type !== 'lockfiles'; helper.toggleClass('elfinder-drag-helper-plus', ctr); wrapper.toggleClass(clDropActive, ctr); } }) // select new files after some actions .bind('mkdir mkfile duplicate upload rename archive extract paste multiupload', function(e) { if (e.type == 'upload' && e.data._multiupload) return; var phash = fm.cwd().hash, files; unselectAll({ notrigger: true }); jQuery.each((e.data.added || []).concat(e.data.changed || []), function(i, file) { file && file.phash == phash && selectFile(file.hash); }); trigger(); }) .shortcut({ pattern :'ctrl+a', description : 'selectall', callback : selectAll }) .shortcut({ pattern :'ctrl+shift+i', description : 'selectinvert', callback : selectInvert }) .shortcut({ pattern : 'left right up down shift+left shift+right shift+up shift+down', description : 'selectfiles', type : 'keydown' , //fm.UA.Firefox || fm.UA.Opera ? 'keypress' : 'keydown', callback : function(e) { select(e.keyCode, e.shiftKey); } }) .shortcut({ pattern : 'home', description : 'selectffile', callback : function(e) { unselectAll({ notrigger: true }); scrollToView(cwd.find('[id]:first').trigger(evtSelect)); trigger(); } }) .shortcut({ pattern : 'end', description : 'selectlfile', callback : function(e) { unselectAll({ notrigger: true }); scrollToView(cwd.find('[id]:last').trigger(evtSelect)) ; trigger(); } }) .shortcut({ pattern : 'page_up', description : 'pageTurning', callback : function(e) { if (bufferExt.itemH) { wrapper.scrollTop( Math.round( wrapper.scrollTop() - (Math.floor((wrapper.height() + (list? bufferExt.itemH * -1 : 16)) / bufferExt.itemH)) * bufferExt.itemH ) ); } } }).shortcut({ pattern : 'page_down', description : 'pageTurning', callback : function(e) { if (bufferExt.itemH) { wrapper.scrollTop( Math.round( wrapper.scrollTop() + (Math.floor((wrapper.height() + (list? bufferExt.itemH * -1 : 16)) / bufferExt.itemH)) * bufferExt.itemH ) ); } } }); }); // fm.timeEnd('cwdLoad') return this; }; /* * File: /js/ui/dialog.js */ /** * @class elFinder dialog * * @author Dmitry (dio) Levashov **/ jQuery.fn.elfinderdialog = function(opts, fm) { var platformWin = (window.navigator.platform.indexOf('Win') != -1), delta = {}, syncSize = { enabled: false, width: false, height: false, defaultSize: null }, fitSize = function(dialog) { var opts, node; if (syncSize.enabled) { node = fm.options.dialogContained? elfNode : jQuery(window); opts = { maxWidth : syncSize.width? node.width() - delta.width : null, maxHeight: syncSize.height? node.height() - delta.height : null }; Object.assign(restoreStyle, opts); dialog.css(opts).trigger('resize'); if (dialog.data('hasResizable') && (dialog.resizable('option', 'maxWidth') < opts.maxWidth || dialog.resizable('option', 'maxHeight') < opts.maxHeight)) { dialog.resizable('option', opts); } } }, syncFunc = function(e) { var dialog = e.data; syncTm && cancelAnimationFrame(syncTm); syncTm = requestAnimationFrame(function() { var opts, offset; if (syncSize.enabled) { fitSize(dialog); } }); }, checkEditing = function() { var cldialog = 'elfinder-dialog', dialogs = elfNode.children('.' + cldialog + '.' + fm.res('class', 'editing') + ':visible'); fm[dialogs.length? 'disable' : 'enable'](); }, propagationEvents = {}, syncTm, dialog, elfNode, restoreStyle; if (fm && fm.ui) { elfNode = fm.getUI(); } else { elfNode = this.closest('.elfinder'); if (! fm) { fm = elfNode.elfinder('instance'); } } if (typeof opts === 'string') { if ((dialog = this.closest('.ui-dialog')).length) { if (opts === 'open') { if (dialog.css('display') === 'none') { // Need dialog.show() and hide() to detect elements size in open() callbacks dialog.trigger('posinit').show().trigger('open').hide(); dialog.fadeIn(120, function() { fm.trigger('dialogopened', {dialog: dialog}); }); } } else if (opts === 'close' || opts === 'destroy') { dialog.stop(true); if (dialog.is(':visible') || elfNode.is(':hidden')) { dialog.trigger('close'); fm.trigger('dialogclosed', {dialog: dialog}); } if (opts === 'destroy') { dialog.remove(); fm.trigger('dialogremoved', {dialog: dialog}); } } else if (opts === 'toTop') { dialog.trigger('totop'); fm.trigger('dialogtotoped', {dialog: dialog}); } else if (opts === 'posInit') { dialog.trigger('posinit'); fm.trigger('dialogposinited', {dialog: dialog}); } else if (opts === 'tabstopsInit') { dialog.trigger('tabstopsInit'); fm.trigger('dialogtabstopsinited', {dialog: dialog}); } else if (opts === 'checkEditing') { checkEditing(); } } return this; } opts = Object.assign({}, jQuery.fn.elfinderdialog.defaults, opts); if (opts.allowMinimize && opts.allowMinimize === 'auto') { opts.allowMinimize = this.find('textarea,input').length? true : false; } opts.openMaximized = opts.allowMinimize && opts.openMaximized; if (opts.headerBtnPos && opts.headerBtnPos === 'auto') { opts.headerBtnPos = platformWin? 'right' : 'left'; } if (opts.headerBtnOrder && opts.headerBtnOrder === 'auto') { opts.headerBtnOrder = platformWin? 'close:maximize:minimize' : 'close:minimize:maximize'; } if (opts.modal && opts.allowMinimize) { opts.allowMinimize = false; } if (fm.options.dialogContained) { syncSize.width = syncSize.height = syncSize.enabled = true; } else { syncSize.width = (opts.maxWidth === 'window'); syncSize.height = (opts.maxHeight === 'window'); if (syncSize.width || syncSize.height) { syncSize.enabled = true; } } propagationEvents = fm.arrayFlip(opts.propagationEvents, true); this.filter(':not(.ui-dialog-content)').each(function() { var self = jQuery(this).addClass('ui-dialog-content ui-widget-content'), clactive = 'elfinder-dialog-active', cldialog = 'elfinder-dialog', clnotify = 'elfinder-dialog-notify', clhover = 'ui-state-hover', cltabstop = 'elfinder-tabstop', cl1stfocus = 'elfinder-focus', clmodal = 'elfinder-dialog-modal', id = parseInt(Math.random()*1000000), titlebar = jQuery('<div class="ui-dialog-titlebar ui-widget-header ui-corner-top ui-helper-clearfix"><span class="elfinder-dialog-title">'+opts.title+'</span></div>'), buttonset = jQuery('<div class="ui-dialog-buttonset"/>'), buttonpane = jQuery('<div class=" ui-helper-clearfix ui-dialog-buttonpane ui-widget-content"/>') .append(buttonset), btnWidth = 0, btnCnt = 0, tabstops = jQuery(), evCover = jQuery('<div style="width:100%;height:100%;position:absolute;top:0px;left:0px;"/>').hide(), numberToTel = function() { if (opts.optimizeNumber) { dialog.find('input[type=number]').each(function() { jQuery(this).attr('inputmode', 'numeric'); jQuery(this).attr('pattern', '[0-9]*'); }); } }, tabstopsInit = function() { tabstops = dialog.find('.'+cltabstop); if (tabstops.length) { tabstops.attr('tabindex', '-1'); if (! tabstops.filter('.'+cl1stfocus).length) { buttonset.children('.'+cltabstop+':'+(platformWin? 'first' : 'last')).addClass(cl1stfocus); } } }, tabstopNext = function(cur) { var elms = tabstops.filter(':visible:enabled'), node = cur? null : elms.filter('.'+cl1stfocus+':first'); if (! node || ! node.length) { node = elms.first(); } if (cur) { jQuery.each(elms, function(i, elm) { if (elm === cur && elms[i+1]) { node = elms.eq(i+1); return false; } }); } return node; }, tabstopPrev = function(cur) { var elms = tabstops.filter(':visible:enabled'), node = elms.last(); jQuery.each(elms, function(i, elm) { if (elm === cur && elms[i-1]) { node = elms.eq(i-1); return false; } }); return node; }, makeHeaderBtn = function() { jQuery.each(opts.headerBtnOrder.split(':').reverse(), function(i, v) { headerBtns[v] && headerBtns[v](); }); if (platformWin) { titlebar.children('.elfinder-titlebar-button').addClass('elfinder-titlebar-button-right'); } }, headerBtns = { close: function() { titlebar.prepend(jQuery('<span class="ui-widget-header ui-dialog-titlebar-close ui-corner-all elfinder-titlebar-button"><span class="ui-icon ui-icon-closethick"/></span>') .on('mousedown', function(e) { e.preventDefault(); e.stopPropagation(); self.elfinderdialog('close'); }) ); }, maximize: function() { if (opts.allowMaximize) { dialog.on('resize', function(e, data) { var full, elm; e.preventDefault(); e.stopPropagation(); if (data && data.maximize) { elm = titlebar.find('.elfinder-titlebar-full'); full = (data.maximize === 'on'); elm.children('span.ui-icon') .toggleClass('ui-icon-plusthick', ! full) .toggleClass('ui-icon-arrowreturnthick-1-s', full); if (full) { try { dialog.hasClass('ui-draggable') && dialog.draggable('disable'); dialog.hasClass('ui-resizable') && dialog.resizable('disable'); } catch(e) {} self.css('width', '100%').css('height', dialog.height() - dialog.children('.ui-dialog-titlebar').outerHeight(true) - buttonpane.outerHeight(true)); } else { self.attr('style', elm.data('style')); elm.removeData('style'); posCheck(); try { dialog.hasClass('ui-draggable') && dialog.draggable('enable'); dialog.hasClass('ui-resizable') && dialog.resizable('enable'); } catch(e) {} } dialog.trigger('resize', {init: true}); } }); titlebar.prepend(jQuery('<span class="ui-widget-header ui-corner-all elfinder-titlebar-button elfinder-titlebar-full"><span class="ui-icon ui-icon-plusthick"/></span>') .on('mousedown', function(e) { var elm = jQuery(this); e.preventDefault(); e.stopPropagation(); if (!dialog.hasClass('elfinder-maximized') && typeof elm.data('style') === 'undefined') { self.height(self.height()); elm.data('style', self.attr('style') || ''); } fm.toggleMaximize(dialog); typeof(opts.maximize) === 'function' && opts.maximize.call(self[0]); }) ); } }, minimize: function() { var btn, mnode, doffset; if (opts.allowMinimize) { btn = jQuery('<span class="ui-widget-header ui-corner-all elfinder-titlebar-button elfinder-titlebar-minimize"><span class="ui-icon ui-icon-minusthick"/></span>') .on('mousedown', function(e) { var $this = jQuery(this), tray = fm.getUI('bottomtray'), dumStyle = { width: 70, height: 24 }, dum = jQuery('<div/>').css(dumStyle).addClass(dialog.get(0).className + ' elfinder-dialog-minimized'), pos = {}; e.preventDefault(); e.stopPropagation(); if (!dialog.data('minimized')) { // minimize doffset = dialog.data('minimized', true).position(); mnode = dialog.clone().on('mousedown', function() { $this.trigger('mousedown'); }).removeClass('ui-draggable ui-resizable elfinder-frontmost'); tray.append(dum); Object.assign(pos, dum.offset(), dumStyle); dum.remove(); mnode.height(dialog.height()).children('.ui-dialog-content:first').empty(); fm.toHide(dialog.before(mnode)); mnode.children('.ui-dialog-content:first,.ui-dialog-buttonpane,.ui-resizable-handle').remove(); mnode.find('.elfinder-titlebar-minimize,.elfinder-titlebar-full').remove(); mnode.find('.ui-dialog-titlebar-close').on('mousedown', function(e) { e.stopPropagation(); e.preventDefault(); mnode.remove(); dialog.show(); self.elfinderdialog('close'); }); mnode.animate(pos, function() { mnode.attr('style', '') .css({ maxWidth: dialog.width() }) .addClass('elfinder-dialog-minimized') .appendTo(tray); checkEditing(); typeof(opts.minimize) === 'function' && opts.minimize.call(self[0]); }); } else { //restore dialog.removeData('minimized').before(mnode.css(Object.assign({'position': 'absolute'}, mnode.offset()))); fm.toFront(mnode); mnode.animate(Object.assign({ width: dialog.width(), height: dialog.height() }, doffset), function() { dialog.show(); fm.toFront(dialog); mnode.remove(); posCheck(); checkEditing(); dialog.trigger('resize', {init: true}); typeof(opts.minimize) === 'function' && opts.minimize.call(self[0]); }); } }); titlebar.on('dblclick', function(e) { jQuery(this).children('.elfinder-titlebar-minimize').trigger('mousedown'); }).prepend(btn); dialog.on('togleminimize', function() { btn.trigger('mousedown'); }); } } }, dialog = jQuery('<div class="ui-front ui-dialog ui-widget ui-widget-content ui-corner-all ui-draggable std42-dialog touch-punch '+cldialog+' '+opts.cssClass+'"/>') .hide() .append(self) .appendTo(elfNode) .draggable({ containment : fm.options.dialogContained? elfNode : null, handle : '.ui-dialog-titlebar', start : function() { evCover.show(); }, drag : function(e, ui) { var top = ui.offset.top, left = ui.offset.left; if (top < 0) { ui.position.top = ui.position.top - top; } if (left < 0) { ui.position.left = ui.position.left - left; } if (fm.options.dialogContained) { ui.position.top < 0 && (ui.position.top = 0); ui.position.left < 0 && (ui.position.left = 0); } }, stop : function(e, ui) { evCover.hide(); dialog.css({height : opts.height}); self.data('draged', true); } }) .css({ width : opts.width, height : opts.height, minWidth : opts.minWidth, minHeight : opts.minHeight, maxWidth : opts.maxWidth, maxHeight : opts.maxHeight }) .on('touchstart touchmove touchend click dblclick mouseup mouseenter mouseleave mouseout mouseover mousemove', function(e) { // stopPropagation of user action events !propagationEvents[e.type] && e.stopPropagation(); }) .on('mousedown', function(e) { !propagationEvents[e.type] && e.stopPropagation(); requestAnimationFrame(function() { if (dialog.is(':visible') && !dialog.hasClass('elfinder-frontmost')) { toFocusNode = jQuery(':focus'); if (!toFocusNode.length) { toFocusNode = void(0); } dialog.trigger('totop'); } }); }) .on('open', function() { dialog.data('margin-y', self.outerHeight(true) - self.height()); if (syncSize.enabled) { if (opts.height && opts.height !== 'auto') { dialog.trigger('resize', {init: true}); } if (!syncSize.defaultSize) { syncSize.defaultSize = { width: self.width(), height: self.height() }; } fitSize(dialog); dialog.trigger('resize').trigger('posinit'); elfNode.on('resize.'+fm.namespace, dialog, syncFunc); } if (!dialog.hasClass(clnotify)) { elfNode.children('.'+cldialog+':visible:not(.'+clnotify+')').each(function() { var d = jQuery(this), top = parseInt(d.css('top')), left = parseInt(d.css('left')), _top = parseInt(dialog.css('top')), _left = parseInt(dialog.css('left')), ct = Math.abs(top - _top) < 10, cl = Math.abs(left - _left) < 10; if (d[0] != dialog[0] && (ct || cl)) { dialog.css({ top : ct ? (top + 10) : _top, left : cl ? (left + 10) : _left }); } }); } if (dialog.data('modal')) { dialog.addClass(clmodal); fm.getUI('overlay').elfinderoverlay('show'); } dialog.trigger('totop'); opts.openMaximized && fm.toggleMaximize(dialog); fm.trigger('dialogopen', {dialog: dialog}); typeof(opts.open) == 'function' && jQuery.proxy(opts.open, self[0])(); if (opts.closeOnEscape) { jQuery(document).on('keydown.'+id, function(e) { if (e.keyCode == jQuery.ui.keyCode.ESCAPE && dialog.hasClass('elfinder-frontmost')) { self.elfinderdialog('close'); } }); } dialog.hasClass(fm.res('class', 'editing')) && checkEditing(); }) .on('close', function(e) { var dialogs, dfd; if (opts.beforeclose && typeof opts.beforeclose === 'function') { dfd = opts.beforeclose(); if (!dfd || !dfd.promise) { dfd = !dfd? jQuery.Deferred().reject() : jQuery.Deferred().resolve(); } } else { dfd = jQuery.Deferred().resolve(); } dfd.done(function() { syncSize.enabled && elfNode.off('resize.'+fm.namespace, syncFunc); if (opts.closeOnEscape) { jQuery(document).off('keyup.'+id); } if (opts.allowMaximize) { fm.toggleMaximize(dialog, false); } fm.toHide(dialog); dialog.data('modal') && fm.getUI('overlay').elfinderoverlay('hide'); if (typeof(opts.close) == 'function') { jQuery.proxy(opts.close, self[0])(); } if (opts.destroyOnClose && dialog.parent().length) { dialog.hide().remove(); } // get focus to next dialog dialogs = elfNode.children('.'+cldialog+':visible'); dialog.hasClass(fm.res('class', 'editing')) && checkEditing(); }); }) .on('totop frontmost', function() { var s = fm.storage('autoFocusDialog'); dialog.data('focusOnMouseOver', s? (s > 0) : fm.options.uiOptions.dialog.focusOnMouseOver); if (dialog.data('minimized')) { titlebar.children('.elfinder-titlebar-minimize').trigger('mousedown'); } if (!dialog.data('modal') && fm.getUI('overlay').is(':visible')) { fm.getUI('overlay').before(dialog); } else { fm.toFront(dialog); } elfNode.children('.'+cldialog+':not(.'+clmodal+')').removeClass(clactive); dialog.addClass(clactive); ! fm.UA.Mobile && (toFocusNode || tabstopNext()).trigger('focus'); toFocusNode = void(0); }) .on('posinit', function() { var css = opts.position, nodeOffset, minTop, minLeft, outerSize, win, winSize, nodeFull; if (dialog.hasClass('elfinder-maximized')) { return; } if (! css && ! dialog.data('resizing')) { nodeFull = elfNode.hasClass('elfinder-fullscreen'); dialog.css(nodeFull? { maxWidth : '100%', maxHeight : '100%', overflow : 'auto' } : restoreStyle); if (fm.UA.Mobile && !nodeFull && dialog.data('rotated') === fm.UA.Rotated) { return; } dialog.data('rotated', fm.UA.Rotated); win = jQuery(window); nodeOffset = elfNode.offset(); outerSize = { width : dialog.outerWidth(true), height: dialog.outerHeight(true) }; outerSize.right = nodeOffset.left + outerSize.width; outerSize.bottom = nodeOffset.top + outerSize.height; winSize = { scrLeft: win.scrollLeft(), scrTop : win.scrollTop(), width : win.width(), height : win.height() }; winSize.right = winSize.scrLeft + winSize.width; winSize.bottom = winSize.scrTop + winSize.height; if (fm.options.dialogContained || nodeFull) { minTop = 0; minLeft = 0; } else { minTop = nodeOffset.top * -1 + winSize.scrTop; minLeft = nodeOffset.left * -1 + winSize.scrLeft; } css = { top : outerSize.height >= winSize.height? minTop : Math.max(minTop, parseInt((elfNode.height() - outerSize.height)/2 - 42)), left : outerSize.width >= winSize.width ? minLeft : Math.max(minLeft, parseInt((elfNode.width() - outerSize.width)/2)) }; if (outerSize.right + css.left > winSize.right) { css.left = Math.max(minLeft, winSize.right - outerSize.right); } if (outerSize.bottom + css.top > winSize.bottom) { css.top = Math.max(minTop, winSize.bottom - outerSize.bottom); } } if (opts.absolute) { css.position = 'absolute'; } css && dialog.css(css); }) .on('resize', function(e, data) { var oh = 0, init = data && data.init, h, minH; if ((data && (data.minimize || data.maxmize)) || dialog.data('minimized')) { return; } e.stopPropagation(); e.preventDefault(); dialog.children('.ui-widget-header,.ui-dialog-buttonpane').each(function() { oh += jQuery(this).outerHeight(true); }); if (!init && syncSize.enabled && !e.originalEvent && !dialog.hasClass('elfinder-maximized')) { h = Math.min(syncSize.defaultSize.height, Math.max(parseInt(dialog.css('max-height')), parseInt(dialog.css('min-height'))) - oh - dialog.data('margin-y')); } else { h = dialog.height() - oh - dialog.data('margin-y'); } self.height(h); if (init) { return; } posCheck(); minH = self.height(); minH = (h < minH)? (minH + oh + dialog.data('margin-y')) : opts.minHeight; dialog.css('min-height', minH); dialog.data('hasResizable') && dialog.resizable('option', { minHeight: minH }); if (typeof(opts.resize) === 'function') { jQuery.proxy(opts.resize, self[0])(e, data); } }) .on('tabstopsInit', tabstopsInit) .on('focus', '.'+cltabstop, function() { jQuery(this).addClass(clhover).parent('label').addClass(clhover); this.id && jQuery(this).parent().find('label[for='+this.id+']').addClass(clhover); }) .on('click', 'select.'+cltabstop, function() { var node = jQuery(this); node.data('keepFocus')? node.removeData('keepFocus') : node.data('keepFocus', true); }) .on('blur', '.'+cltabstop, function() { jQuery(this).removeClass(clhover).removeData('keepFocus').parent('label').removeClass(clhover); this.id && jQuery(this).parent().find('label[for='+this.id+']').removeClass(clhover); }) .on('mouseenter mouseleave', '.'+cltabstop+',label', function(e) { var $this = jQuery(this), labelfor; if (this.nodeName === 'LABEL') { if (!$this.children('.'+cltabstop).length && (!(labelfor = $this.attr('for')) || !jQuery('#'+labelfor).hasClass(cltabstop))) { return; } } if (opts.btnHoverFocus && dialog.data('focusOnMouseOver')) { if (e.type === 'mouseenter' && ! jQuery(':focus').data('keepFocus')) { $this.trigger('focus'); } } else { $this.toggleClass(clhover, e.type == 'mouseenter'); } }) .on('keydown', '.'+cltabstop, function(e) { var $this = jQuery(this), esc, move, moveTo; if ($this.is(':focus')) { esc = e.keyCode === jQuery.ui.keyCode.ESCAPE; if (e.keyCode === jQuery.ui.keyCode.ENTER) { e.preventDefault(); $this.trigger('click'); } else if (((e.keyCode === jQuery.ui.keyCode.TAB) && e.shiftKey) || e.keyCode === jQuery.ui.keyCode.LEFT || e.keyCode == jQuery.ui.keyCode.UP) { move = 'prev'; } else if (e.keyCode === jQuery.ui.keyCode.TAB || e.keyCode == jQuery.ui.keyCode.RIGHT || e.keyCode == jQuery.ui.keyCode.DOWN) { move = 'next'; } if (move && ( ($this.is('textarea') && !(e.ctrlKey || e.metaKey)) || ($this.is('select,span.ui-slider-handle') && e.keyCode !== jQuery.ui.keyCode.TAB) || ($this.is('input:not(:checkbox,:radio)') && (!(e.ctrlKey || e.metaKey) && e.keyCode === jQuery.ui.keyCode[move === 'prev'? 'LEFT':'RIGHT'])) ) ) { e.stopPropagation(); return; } if (!esc) { e.stopPropagation(); } else if ($this.is('input:not(:checkbox,:radio),textarea')) { if ($this.val() !== '') { $this.val(''); e.stopPropagation(); } } if (move) { e.preventDefault(); (move === 'prev'? tabstopPrev : tabstopNext)(this).trigger('focus'); } } }) .data({modal: opts.modal}), posCheck = function() { var node = fm.getUI(), pos; if (node.hasClass('elfinder-fullscreen')) { pos = dialog.position(); dialog.css('top', Math.max(Math.min(Math.max(pos.top, 0), node.height() - 100), 0)); dialog.css('left', Math.max(Math.min(Math.max(pos.left, 0), node.width() - 200), 0)); } }, maxSize, toFocusNode; dialog.prepend(titlebar); makeHeaderBtn(); jQuery.each(opts.buttons, function(name, cb) { var button = jQuery('<button type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only ' +'elfinder-btncnt-'+(btnCnt++)+' ' +cltabstop +'"><span class="ui-button-text">'+name+'</span></button>') .on('click', jQuery.proxy(cb, self[0])); if (cb._cssClass) { button.addClass(cb._cssClass); } if (platformWin) { buttonset.append(button); } else { buttonset.prepend(button); } }); if (buttonset.children().length) { dialog.append(buttonpane); dialog.show(); buttonpane.find('button').each(function(i, btn) { btnWidth += jQuery(btn).outerWidth(true); }); dialog.hide(); btnWidth += 20; if (dialog.width() < btnWidth) { dialog.width(btnWidth); } } dialog.append(evCover); if (syncSize.enabled) { delta.width = dialog.outerWidth(true) - dialog.width() + ((dialog.outerWidth() - dialog.width()) / 2); delta.height = dialog.outerHeight(true) - dialog.height() + ((dialog.outerHeight() - dialog.height()) / 2); } if (fm.options.dialogContained) { maxSize = { maxWidth: elfNode.width() - delta.width, maxHeight: elfNode.height() - delta.height }; opts.maxWidth = opts.maxWidth? Math.min(maxSize.maxWidth, opts.maxWidth) : maxSize.maxWidth; opts.maxHeight = opts.maxHeight? Math.min(maxSize.maxHeight, opts.maxHeight) : maxSize.maxHeight; dialog.css(maxSize); } restoreStyle = { maxWidth : dialog.css('max-width'), maxHeight : dialog.css('max-height'), overflow : dialog.css('overflow') }; if (opts.resizable) { dialog.resizable({ minWidth : opts.minWidth, minHeight : opts.minHeight, maxWidth : opts.maxWidth, maxHeight : opts.maxHeight, start : function() { evCover.show(); if (dialog.data('resizing') !== true && dialog.data('resizing')) { clearTimeout(dialog.data('resizing')); } dialog.data('resizing', true); }, stop : function(e, ui) { evCover.hide(); dialog.data('resizing', setTimeout(function() { dialog.data('resizing', false); }, 200)); if (syncSize.enabled) { syncSize.defaultSize = { width: self.width(), height: self.height() }; } } }).data('hasResizable', true); } numberToTel(); tabstopsInit(); typeof(opts.create) == 'function' && jQuery.proxy(opts.create, this)(); if (opts.autoOpen) { if (opts.open) { requestAnimationFrame(function() { self.elfinderdialog('open'); }); } else { self.elfinderdialog('open'); } } if (opts.resize) { fm.bind('themechange', function() { setTimeout(function() { dialog.data('margin-y', self.outerHeight(true) - self.height()); dialog.trigger('resize', {init: true}); }, 300); }); } }); return this; }; jQuery.fn.elfinderdialog.defaults = { cssClass : '', title : '', modal : false, resizable : true, autoOpen : true, closeOnEscape : true, destroyOnClose : false, buttons : {}, btnHoverFocus : true, position : null, absolute : false, width : 320, height : 'auto', minWidth : 200, minHeight : 70, maxWidth : null, maxHeight : null, allowMinimize : 'auto', allowMaximize : false, openMaximized : false, headerBtnPos : 'auto', headerBtnOrder : 'auto', optimizeNumber : true, propagationEvents : ['mousemove', 'mouseup'] }; /* * File: /js/ui/fullscreenbutton.js */ /** * @class elFinder toolbar button to switch full scrren mode. * * @author Naoki Sawada **/ jQuery.fn.elfinderfullscreenbutton = function(cmd) { return this.each(function() { var button = jQuery(this).elfinderbutton(cmd), icon = button.children('.elfinder-button-icon'), tm; cmd.change(function() { tm && cancelAnimationFrame(tm); tm = requestAnimationFrame(function() { var fullscreen = cmd.value; icon.addClass('elfinder-button-icon-fullscreen').toggleClass('elfinder-button-icon-unfullscreen', fullscreen); cmd.className = fullscreen? 'unfullscreen' : ''; }); }); }); }; /* * File: /js/ui/navbar.js */ /** * @class elfindernav - elFinder container for diretories tree and places * * @author Dmitry (dio) Levashov **/ jQuery.fn.elfindernavbar = function(fm, opts) { this.not('.elfinder-navbar').each(function() { var nav = jQuery(this).hide().addClass('ui-state-default elfinder-navbar'), parent = nav.css('overflow', 'hidden').parent(), wz = parent.children('.elfinder-workzone').append(nav), ltr = fm.direction == 'ltr', delta, deltaW, handle, swipeHandle, autoHide, setWidth, navdock, setWzRect = function() { var cwd = fm.getUI('cwd'), wz = fm.getUI('workzone'), wzRect = wz.data('rectangle'), cwdOffset = cwd.offset(); wz.data('rectangle', Object.assign(wzRect, { cwdEdge: (fm.direction === 'ltr')? cwdOffset.left : cwdOffset.left + cwd.width() })); }, setDelta = function() { nav.css('overflow', 'hidden'); delta = Math.round(nav.outerHeight() - nav.height()); deltaW = Math.round(navdock.outerWidth() - navdock.innerWidth()); nav.css('overflow', 'auto'); }; fm.one('init', function() { navdock = fm.getUI('navdock'); var set = function() { setDelta(); fm.bind('wzresize', function() { var navdockH = 0; navdock.width(nav.outerWidth() - deltaW); if (navdock.children().length > 1) { navdockH = navdock.outerHeight(true); } nav.height(wz.height() - navdockH - delta); }).trigger('wzresize'); }; if (fm.cssloaded) { set(); } else { fm.one('cssloaded', set); } }) .one('opendone',function() { handle && handle.trigger('resize'); nav.css('overflow', 'auto'); }).bind('themechange', setDelta); if (fm.UA.Touch) { autoHide = fm.storage('autoHide') || {}; if (typeof autoHide.navbar === 'undefined') { autoHide.navbar = (opts.autoHideUA && opts.autoHideUA.length > 0 && jQuery.grep(opts.autoHideUA, function(v){ return fm.UA[v]? true : false; }).length); fm.storage('autoHide', autoHide); } if (autoHide.navbar) { fm.one('init', function() { if (nav.children().length) { fm.uiAutoHide.push(function(){ nav.stop(true, true).trigger('navhide', { duration: 'slow', init: true }); }); } }); } fm.bind('load', function() { if (nav.children().length) { swipeHandle = jQuery('<div class="elfinder-navbar-swipe-handle"/>').hide().appendTo(wz); if (swipeHandle.css('pointer-events') !== 'none') { swipeHandle.remove(); swipeHandle = null; } } }); nav.on('navshow navhide', function(e, data) { var mode = (e.type === 'navshow')? 'show' : 'hide', duration = (data && data.duration)? data.duration : 'fast', handleW = (data && data.handleW)? data.handleW : Math.max(50, fm.getUI().width() / 10); nav.stop(true, true)[mode]({ duration: duration, step : function() { fm.trigger('wzresize'); }, complete: function() { if (swipeHandle) { if (mode === 'show') { swipeHandle.stop(true, true).hide(); } else { swipeHandle.width(handleW? handleW : ''); fm.resources.blink(swipeHandle, 'slowonce'); } } fm.trigger('navbar'+ mode); data.init && fm.trigger('uiautohide'); setWzRect(); } }); autoHide.navbar = (mode !== 'show'); fm.storage('autoHide', Object.assign(fm.storage('autoHide'), {navbar: autoHide.navbar})); }).on('touchstart', function(e) { if (jQuery(this)['scroll' + (fm.direction === 'ltr'? 'Right' : 'Left')]() > 5) { e.originalEvent._preventSwipeX = true; } }); } if (! fm.UA.Mobile) { handle = nav.resizable({ handles : ltr ? 'e' : 'w', minWidth : opts.minWidth || 150, maxWidth : opts.maxWidth || 500, resize : function() { fm.trigger('wzresize'); }, stop : function(e, ui) { fm.storage('navbarWidth', ui.size.width); setWzRect(); } }) .on('resize scroll', function(e) { var $this = jQuery(this), tm = $this.data('posinit'); e.preventDefault(); e.stopPropagation(); if (! ltr && e.type === 'resize') { nav.css('left', 0); } tm && cancelAnimationFrame(tm); $this.data('posinit', requestAnimationFrame(function() { var offset = (fm.UA.Opera && nav.scrollLeft())? 20 : 2; handle.css('top', 0).css({ top : parseInt(nav.scrollTop())+'px', left : ltr ? 'auto' : parseInt(nav.scrollRight() - offset) * -1, right: ltr ? parseInt(nav.scrollLeft() - offset) * -1 : 'auto' }); if (e.type === 'resize') { fm.getUI('cwd').trigger('resize'); } })); }) .children('.ui-resizable-handle').addClass('ui-front'); } if (setWidth = fm.storage('navbarWidth')) { nav.width(setWidth); } else { if (fm.UA.Mobile) { fm.one('cssloaded', function() { var set = function() { setWidth = nav.parent().width() / 2; if (nav.data('defWidth') > setWidth) { nav.width(setWidth); } else { nav.width(nav.data('defWidth')); } nav.data('width', nav.width()); fm.trigger('wzresize'); }; nav.data('defWidth', nav.width()); jQuery(window).on('resize.' + fm.namespace, set); set(); }); } } }); return this; }; /* * File: /js/ui/navdock.js */ /** * @class elfindernavdock - elFinder container for preview etc at below the navbar * * @author Naoki Sawada **/ jQuery.fn.elfindernavdock = function(fm, opts) { this.not('.elfinder-navdock').each(function() { var self = jQuery(this).hide().addClass('ui-state-default elfinder-navdock touch-punch'), node = self.parent(), wz = node.children('.elfinder-workzone').append(self), resize = function(to, h) { var curH = h || self.height(), diff = to - curH, len = Object.keys(sizeSyncs).length, calc = len? diff / len : 0, ovf; if (diff) { ovf = self.css('overflow'); self.css('overflow', 'hidden'); self.height(to); jQuery.each(sizeSyncs, function(id, n) { n.height(n.height() + calc).trigger('resize.' + fm.namespace); }); fm.trigger('wzresize'); self.css('overflow', ovf); } }, handle = jQuery('<div class="ui-front ui-resizable-handle ui-resizable-n"/>').appendTo(self), sizeSyncs = {}, resizeFn = [], initMaxHeight = (parseInt(opts.initMaxHeight) || 50) / 100, maxHeight = (parseInt(opts.maxHeight) || 90) / 100, basicHeight, hasNode; self.data('addNode', function(cNode, opts) { var wzH = fm.getUI('workzone').height(), imaxH = wzH * initMaxHeight, curH, tH, mH; opts = Object.assign({ first: false, sizeSync: true, init: false }, opts); if (!cNode.attr('id')) { cNode.attr('id', fm.namespace+'-navdock-' + (+new Date())); } opts.sizeSync && (sizeSyncs[cNode.attr('id')] = cNode); curH = self.height(); tH = curH + cNode.outerHeight(true); if (opts.first) { handle.after(cNode); } else { self.append(cNode); } hasNode = true; self.resizable('enable').height(tH).show(); fm.trigger('wzresize'); if (opts.init) { mH = fm.storage('navdockHeight'); if (mH) { tH = mH; } else { tH = tH > imaxH? imaxH : tH; } basicHeight = tH; } resize(Math.min(tH, wzH * maxHeight)); return self; }).data('removeNode', function(nodeId, appendTo) { var cNode = jQuery('#'+nodeId); delete sizeSyncs[nodeId]; self.height(self.height() - jQuery('#'+nodeId).outerHeight(true)); if (appendTo) { if (appendTo === 'detach') { cNode = cNode.detach(); } else { appendTo.append(cNode); } } else { cNode.remove(); } if (self.children().length <= 1) { hasNode = false; self.resizable('disable').height(0).hide(); } fm.trigger('wzresize'); return cNode; }); if (! opts.disabled) { fm.one('init', function() { var ovf; if (fm.getUI('navbar').children().not('.ui-resizable-handle').length) { self.data('dockEnabled', true); self.resizable({ maxHeight: fm.getUI('workzone').height() * maxHeight, handles: { n: handle }, start: function(e, ui) { ovf = self.css('overflow'); self.css('overflow', 'hidden'); fm.trigger('navdockresizestart', {event: e, ui: ui}, true); }, resize: function(e, ui) { self.css('top', ''); fm.trigger('wzresize', { inNavdockResize : true }); }, stop: function(e, ui) { fm.trigger('navdockresizestop', {event: e, ui: ui}, true); self.css('top', ''); basicHeight = ui.size.height; fm.storage('navdockHeight', basicHeight); resize(basicHeight, ui.originalSize.height); self.css('overflow', ovf); } }); fm.bind('wzresize', function(e) { var minH, maxH, h; if (self.is(':visible')) { maxH = fm.getUI('workzone').height() * maxHeight; if (! e.data || ! e.data.inNavdockResize) { h = self.height(); if (maxH < basicHeight) { if (Math.abs(h - maxH) > 1) { resize(maxH); } } else { if (Math.abs(h - basicHeight) > 1) { resize(basicHeight); } } } self.resizable('option', 'maxHeight', maxH); } }).bind('themechange', function() { var oldH = Math.round(self.height()); requestAnimationFrame(function() { var curH = Math.round(self.height()), diff = oldH - curH; if (diff !== 0) { resize(self.height(), curH - diff); } }); }); } fm.bind('navbarshow navbarhide', function(e) { self[hasNode && e.type === 'navbarshow'? 'show' : 'hide'](); }); }); } }); return this; }; /* * File: /js/ui/overlay.js */ jQuery.fn.elfinderoverlay = function(opts) { var fm = this.parent().elfinder('instance'), o, cnt, show, hide; this.filter(':not(.elfinder-overlay)').each(function() { opts = Object.assign({}, opts); jQuery(this).addClass('ui-front ui-widget-overlay elfinder-overlay') .hide() .on('mousedown', function(e) { e.preventDefault(); e.stopPropagation(); }) .data({ cnt : 0, show : typeof(opts.show) == 'function' ? opts.show : function() { }, hide : typeof(opts.hide) == 'function' ? opts.hide : function() { } }); }); if (opts == 'show') { o = this.eq(0); cnt = o.data('cnt') + 1; show = o.data('show'); fm.toFront(o); o.data('cnt', cnt); if (o.is(':hidden')) { o.show(); show(); } } if (opts == 'hide') { o = this.eq(0); cnt = o.data('cnt') - 1; hide = o.data('hide'); o.data('cnt', cnt); if (cnt <= 0) { o.hide(); hide(); } } return this; }; /* * File: /js/ui/panel.js */ jQuery.fn.elfinderpanel = function(fm) { return this.each(function() { var panel = jQuery(this).addClass('elfinder-panel ui-state-default ui-corner-all'), margin = 'margin-'+(fm.direction == 'ltr' ? 'left' : 'right'); fm.one('load', function(e) { var navbar = fm.getUI('navbar'); panel.css(margin, parseInt(navbar.outerWidth(true))); navbar.on('resize', function(e) { e.preventDefault(); e.stopPropagation(); panel.is(':visible') && panel.css(margin, parseInt(navbar.outerWidth(true))); }); }); }); }; /* * File: /js/ui/path.js */ /** * @class elFinder ui * Display current folder path in statusbar. * Click on folder name in path - open folder * * @author Dmitry (dio) Levashov **/ jQuery.fn.elfinderpath = function(fm, options) { return this.each(function() { var query = '', target = '', mimes = [], place = 'statusbar', clHover= fm.res('class', 'hover'), prefix = 'path' + (elFinder.prototype.uniqueid? elFinder.prototype.uniqueid : '') + '-', wzbase = jQuery('<div class="ui-widget-header ui-helper-clearfix elfinder-workzone-path"/>'), path = jQuery(this).addClass('elfinder-path').html(' ') .on('mousedown', 'span.elfinder-path-dir', function(e) { var hash = jQuery(this).attr('id').substr(prefix.length); e.preventDefault(); if (hash != fm.cwd().hash) { jQuery(this).addClass(clHover); if (query) { fm.exec('search', query, { target: hash, mime: mimes.join(' ') }); } else { fm.trigger('select', {selected : [hash]}).exec('open', hash); } } }) .prependTo(fm.getUI('statusbar').show()), roots = jQuery('<div class="elfinder-path-roots"/>').on('click', function(e) { e.stopPropagation(); e.preventDefault(); var roots = jQuery.map(fm.roots, function(h) { return fm.file(h); }), raw = []; jQuery.each(roots, function(i, f) { if (! f.phash && fm.root(fm.cwd().hash, true) !== f.hash) { raw.push({ label : fm.escape(f.i18 || f.name), icon : 'home', callback : function() { fm.exec('open', f.hash); }, options : { iconClass : f.csscls || '', iconImg : f.icon || '' } }); } }); fm.trigger('contextmenu', { raw: raw, x: e.pageX, y: e.pageY }); }).append('<span class="elfinder-button-icon elfinder-button-icon-menu" />').appendTo(wzbase), render = function(cwd) { var dirs = [], names = []; jQuery.each(fm.parents(cwd), function(i, hash) { var c = (cwd === hash)? 'elfinder-path-dir elfinder-path-cwd' : 'elfinder-path-dir', f = fm.file(hash), name = fm.escape(f.i18 || f.name); names.push(name); dirs.push('<span id="'+prefix+hash+'" class="'+c+'" title="'+names.join(fm.option('separator'))+'">'+name+'</span>'); }); return dirs.join('<span class="elfinder-path-other">'+fm.option('separator')+'</span>'); }, toWorkzone = function() { var prev; path.children('span.elfinder-path-dir').attr('style', ''); prev = fm.direction === 'ltr'? jQuery('#'+prefix + fm.cwd().hash).prevAll('span.elfinder-path-dir:first') : jQuery(); path.scrollLeft(prev.length? prev.position().left : 0); }, fit = function() { if (fm.UA.CSS.flex) { return; } var dirs = path.children('span.elfinder-path-dir'), cnt = dirs.length, m, bg = 0, ids; if (place === 'workzone' || cnt < 2) { dirs.attr('style', ''); return; } path.width(path.css('max-width')); dirs.css({maxWidth: (100/cnt)+'%', display: 'inline-block'}); m = path.width() - 9; path.children('span.elfinder-path-other').each(function() { m -= jQuery(this).width(); }); ids = []; dirs.each(function(i) { var dir = jQuery(this), w = dir.width(); m -= w; if (w < this.scrollWidth) { ids.push(i); } }); path.width(''); if (ids.length) { if (m > 0) { m = m / ids.length; jQuery.each(ids, function(i, k) { var d = jQuery(dirs[k]); d.css('max-width', d.width() + m); }); } dirs.last().attr('style', ''); } else { dirs.attr('style', ''); } }, hasUiTree, hasUiStat; fm.one('init', function() { hasUiTree = fm.getUI('tree').length; hasUiStat = fm.getUI('stat').length; if (! hasUiTree && options.toWorkzoneWithoutNavbar) { wzbase.append(path).insertBefore(fm.getUI('workzone')); place = 'workzone'; fm.bind('open', toWorkzone) .one('opendone', function() { fm.getUI().trigger('resize'); }); } }) .bind('open searchend parents', function() { var dirs = []; query = ''; target = ''; mimes = []; path.html(render(fm.cwd().hash)); if (Object.keys(fm.roots).length > 1) { path.css('margin', ''); roots.show(); } else { path.css('margin', 0); roots.hide(); } !hasUiStat && fit(); }) .bind('searchstart', function(e) { if (e.data) { query = e.data.query || ''; target = e.data.target || ''; mimes = e.data.mimes || []; } }) .bind('search', function(e) { var dirs = [], html = ''; if (target) { html = render(target); } else { html = fm.i18n('btnAll'); } path.html('<span class="elfinder-path-other">'+fm.i18n('searcresult') + ': </span>' + html); fit(); }) // on swipe to navbar show/hide .bind('navbarshow navbarhide', function() { var wz = fm.getUI('workzone'); if (this.type === 'navbarshow') { fm.unbind('open', toWorkzone); path.prependTo(fm.getUI('statusbar')); wzbase.detach(); place = 'statusbar'; } else { wzbase.append(path).insertBefore(wz); place = 'workzone'; toWorkzone(); fm.bind('open', toWorkzone); } fm.trigger('uiresize'); }) .bind('resize uistatchange', fit); }); }; /* * File: /js/ui/places.js */ /** * @class elFinder places/favorites ui * * @author Dmitry (dio) Levashov * @author Naoki Sawada **/ jQuery.fn.elfinderplaces = function(fm, opts) { return this.each(function() { var dirs = {}, c = 'class', navdir = fm.res(c, 'navdir'), collapsed = fm.res(c, 'navcollapse'), expanded = fm.res(c, 'navexpand'), hover = fm.res(c, 'hover'), clroot = fm.res(c, 'treeroot'), dropover = fm.res(c, 'adroppable'), tpl = fm.res('tpl', 'placedir'), ptpl = fm.res('tpl', 'perms'), spinner = jQuery(fm.res('tpl', 'navspinner')), suffix = opts.suffix? opts.suffix : '', key = 'places' + suffix, menuTimer = null, /** * Convert places dir node into dir hash * * @param String directory id * @return String **/ id2hash = function(id) { return id.substr(6); }, /** * Convert places dir hash into dir node id * * @param String directory id * @return String **/ hash2id = function(hash) { return 'place-'+hash; }, /** * Convert places dir hash into dir node elment (jQuery object) * * @param String directory id * @return Object **/ hash2elm = function(hash) { return jQuery(document.getElementById(hash2id(hash))); }, /** * Save current places state * * @return void **/ save = function() { var hashes = [], data = {}; hashes = jQuery.map(subtree.children().find('[id]'), function(n) { return id2hash(n.id); }); if (hashes.length) { jQuery.each(hashes.reverse(), function(i, h) { data[h] = dirs[h]; }); } else { data = null; } fm.storage(key, data); }, /** * Init dir at places * * @return void **/ init = function() { var dat, hashes; key = 'places'+(opts.suffix? opts.suffix : ''), dirs = {}; dat = fm.storage(key); if (typeof dat === 'string') { // old data type elFinder <= 2.1.12 dat = jQuery.grep(dat.split(','), function(hash) { return hash? true : false;}); jQuery.each(dat, function(i, d) { var dir = d.split('#'); dirs[dir[0]] = dir[1]? dir[1] : dir[0]; }); } else if (jQuery.isPlainObject(dat)) { dirs = dat; } // allow modify `dirs` /** * example for preset places * * elfinderInstance.bind('placesload', function(e, fm) { * //if (fm.storage(e.data.storageKey) === null) { // for first time only * if (!fm.storage(e.data.storageKey)) { // for empty places * e.data.dirs[targetHash] = fallbackName; // preset folder * } * } **/ fm.trigger('placesload', {dirs: dirs, storageKey: key}, true); hashes = Object.keys(dirs); if (hashes.length) { root.prepend(spinner); fm.request({ data : {cmd : 'info', targets : hashes}, preventDefault : true }) .done(function(data) { var exists = {}; data.files && data.files.length && fm.cache(data.files); jQuery.each(data.files, function(i, f) { var hash = f.hash; exists[hash] = f; }); jQuery.each(dirs, function(h, f) { add(exists[h] || Object.assign({notfound: true}, f)); }); if (fm.storage('placesState') > 0) { root.trigger('click'); } }) .always(function() { spinner.remove(); }); } }, /** * Return node for given dir object * * @param Object directory object * @return jQuery **/ create = function(dir, hash) { return jQuery(tpl.replace(/\{id\}/, hash2id(dir? dir.hash : hash)) .replace(/\{name\}/, fm.escape(dir? dir.i18 || dir.name : hash)) .replace(/\{cssclass\}/, dir? (fm.perms2class(dir) + (dir.notfound? ' elfinder-na' : '') + (dir.csscls? ' '+dir.csscls : '')) : '') .replace(/\{permissions\}/, (dir && (!dir.read || !dir.write || dir.notfound))? ptpl : '') .replace(/\{title\}/, (dir && dir.path)? fm.escape(dir.path) : '') .replace(/\{symlink\}/, '') .replace(/\{style\}/, (dir && dir.icon)? fm.getIconStyle(dir) : '')); }, /** * Add new node into places * * @param Object directory object * @return void **/ add = function(dir) { var node, hash; if (dir.mime !== 'directory') { return false; } hash = dir.hash; if (!fm.files().hasOwnProperty(hash)) { // update cache fm.trigger('tree', {tree: [dir]}); } node = create(dir, hash); dirs[hash] = dir; subtree.prepend(node); root.addClass(collapsed); sortBtn.toggle(subtree.children().length > 1); return true; }, /** * Remove dir from places * * @param String directory hash * @return String removed name **/ remove = function(hash) { var name = null, tgt, cnt; if (dirs[hash]) { delete dirs[hash]; tgt = hash2elm(hash); if (tgt.length) { name = tgt.text(); tgt.parent().remove(); cnt = subtree.children().length; sortBtn.toggle(cnt > 1); if (! cnt) { root.removeClass(collapsed); places.removeClass(expanded); subtree.slideToggle(false); } } } return name; }, /** * Move up dir on places * * @param String directory hash * @return void **/ moveup = function(hash) { var self = hash2elm(hash), tgt = self.parent(), prev = tgt.prev('div'), cls = 'ui-state-hover', ctm = fm.getUI('contextmenu'); menuTimer && clearTimeout(menuTimer); if (prev.length) { ctm.find(':first').data('placesHash', hash); self.addClass(cls); tgt.insertBefore(prev); prev = tgt.prev('div'); menuTimer = setTimeout(function() { self.removeClass(cls); if (ctm.find(':first').data('placesHash') === hash) { ctm.hide().empty(); } }, 1500); } if(!prev.length) { self.removeClass(cls); ctm.hide().empty(); } }, /** * Update dir at places * * @param Object directory * @param String previous hash * @return Boolean **/ update = function(dir, preHash) { var hash = dir.hash, tgt = hash2elm(preHash || hash), node = create(dir, hash); if (tgt.length > 0) { tgt.parent().replaceWith(node); dirs[hash] = dir; return true; } else { return false; } }, /** * Remove all dir from places * * @return void **/ clear = function() { subtree.empty(); root.removeClass(collapsed); places.removeClass(expanded); subtree.slideToggle(false); }, /** * Sort places dirs A-Z * * @return void **/ sort = function() { jQuery.each(dirs, function(h, f) { var dir = fm.file(h) || f, node = create(dir, h), ret = null; if (!dir) { node.hide(); } if (subtree.children().length) { jQuery.each(subtree.children(), function() { var current = jQuery(this); if ((dir.i18 || dir.name).localeCompare(current.children('.'+navdir).text()) < 0) { ret = !node.insertBefore(current); return ret; } }); if (ret !== null) { return true; } } !hash2elm(h).length && subtree.append(node); }); save(); }, // sort button sortBtn = jQuery('<span class="elfinder-button-icon elfinder-button-icon-sort elfinder-places-root-icon" title="'+fm.i18n('cmdsort')+'"/>') .hide() .on('click', function(e) { e.stopPropagation(); subtree.empty(); sort(); } ), /** * Node - wrapper for places root * * @type jQuery **/ wrapper = create({ hash : 'root-'+fm.namespace, name : fm.i18n(opts.name, 'places'), read : true, write : true }), /** * Places root node * * @type jQuery **/ root = wrapper.children('.'+navdir) .addClass(clroot) .on('click', function(e) { e.stopPropagation(); if (root.hasClass(collapsed)) { places.toggleClass(expanded); subtree.slideToggle(); fm.storage('placesState', places.hasClass(expanded)? 1 : 0); } }) .append(sortBtn), /** * Container for dirs * * @type jQuery **/ subtree = wrapper.children('.'+fm.res(c, 'navsubtree')), /** * Main places container * * @type jQuery **/ places = jQuery(this).addClass(fm.res(c, 'tree')+' elfinder-places ui-corner-all') .hide() .append(wrapper) .appendTo(fm.getUI('navbar')) .on('mouseenter mouseleave', '.'+navdir, function(e) { jQuery(this).toggleClass('ui-state-hover', (e.type == 'mouseenter')); }) .on('click', '.'+navdir, function(e) { var p = jQuery(this); if (p.data('longtap')) { e.stopPropagation(); return; } ! p.hasClass('elfinder-na') && fm.exec('open', p.attr('id').substr(6)); }) .on('contextmenu', '.'+navdir+':not(.'+clroot+')', function(e) { var self = jQuery(this), hash = self.attr('id').substr(6); e.preventDefault(); fm.trigger('contextmenu', { raw : [{ label : fm.i18n('moveUp'), icon : 'up', remain : true, callback : function() { moveup(hash); save(); } },'|',{ label : fm.i18n('rmFromPlaces'), icon : 'rm', callback : function() { remove(hash); save(); } }], 'x' : e.pageX, 'y' : e.pageY }); self.addClass('ui-state-hover'); fm.getUI('contextmenu').children().on('mouseenter', function() { self.addClass('ui-state-hover'); }); fm.bind('closecontextmenu', function() { self.removeClass('ui-state-hover'); }); }) .droppable({ tolerance : 'pointer', accept : '.elfinder-cwd-file-wrapper,.elfinder-tree-dir,.elfinder-cwd-file', hoverClass : fm.res('class', 'adroppable'), classes : { // Deprecated hoverClass jQueryUI>=1.12.0 'ui-droppable-hover': fm.res('class', 'adroppable') }, over : function(e, ui) { var helper = ui.helper, dir = jQuery.grep(helper.data('files'), function(h) { return (fm.file(h).mime === 'directory' && !dirs[h])? true : false; }); e.stopPropagation(); helper.data('dropover', helper.data('dropover') + 1); if (fm.insideWorkzone(e.pageX, e.pageY)) { if (dir.length > 0) { helper.addClass('elfinder-drag-helper-plus'); fm.trigger('unlockfiles', {files : helper.data('files'), helper: helper}); } else { jQuery(this).removeClass(dropover); } } }, out : function(e, ui) { var helper = ui.helper; e.stopPropagation(); helper.removeClass('elfinder-drag-helper-move elfinder-drag-helper-plus').data('dropover', Math.max(helper.data('dropover') - 1, 0)); jQuery(this).removeData('dropover') .removeClass(dropover); }, drop : function(e, ui) { var helper = ui.helper, resolve = true; jQuery.each(helper.data('files'), function(i, hash) { var dir = fm.file(hash); if (dir && dir.mime == 'directory' && !dirs[dir.hash]) { add(dir); } else { resolve = false; } }); save(); resolve && helper.hide(); } }) // for touch device .on('touchstart', '.'+navdir+':not(.'+clroot+')', function(e) { if (e.originalEvent.touches.length > 1) { return; } var hash = jQuery(this).attr('id').substr(6), p = jQuery(this) .addClass(hover) .data('longtap', null) .data('tmlongtap', setTimeout(function(){ // long tap p.data('longtap', true); fm.trigger('contextmenu', { raw : [{ label : fm.i18n('rmFromPlaces'), icon : 'rm', callback : function() { remove(hash); save(); } }], 'x' : e.originalEvent.touches[0].pageX, 'y' : e.originalEvent.touches[0].pageY }); }, 500)); }) .on('touchmove touchend', '.'+navdir+':not(.'+clroot+')', function(e) { clearTimeout(jQuery(this).data('tmlongtap')); if (e.type == 'touchmove') { jQuery(this).removeClass(hover); } }); if (jQuery.fn.sortable) { subtree.addClass('touch-punch') .sortable({ appendTo : fm.getUI(), revert : false, helper : function(e) { var dir = jQuery(e.target).parent(); dir.children().removeClass('ui-state-hover'); return jQuery('<div class="ui-widget elfinder-place-drag elfinder-'+fm.direction+'"/>') .append(jQuery('<div class="elfinder-navbar"/>').show().append(dir.clone())); }, stop : function(e, ui) { var target = jQuery(ui.item[0]), top = places.offset().top, left = places.offset().left, width = places.width(), height = places.height(), x = e.pageX, y = e.pageY; if (!(x > left && x < left+width && y > top && y < y+height)) { remove(id2hash(target.children(':first').attr('id'))); save(); } }, update : function(e, ui) { save(); } }); } // "on regist" for command exec jQuery(this).on('regist', function(e, files){ var added = false; jQuery.each(files, function(i, dir) { if (dir && dir.mime == 'directory' && !dirs[dir.hash]) { if (add(dir)) { added = true; } } }); added && save(); }); // on fm load - show places and load files from backend fm.one('load', function() { var dat, hashes; if (fm.oldAPI) { return; } places.show().parent().show(); init(); fm.change(function(e) { var changed = false; jQuery.each(e.data.changed, function(i, file) { if (dirs[file.hash]) { if (file.mime !== 'directory') { if (remove(file.hash)) { changed = true; } } else { if (update(file)) { changed = true; } } } }); changed && save(); }) .bind('rename', function(e) { var changed = false; if (e.data.removed) { jQuery.each(e.data.removed, function(i, hash) { if (e.data.added[i]) { if (update(e.data.added[i], hash)) { changed = true; } } }); } changed && save(); }) .bind('rm paste', function(e) { var names = [], changed = false; if (e.data.removed) { jQuery.each(e.data.removed, function(i, hash) { var name = remove(hash); name && names.push(name); }); } if (names.length) { changed = true; } if (e.data.added && names.length) { jQuery.each(e.data.added, function(i, file) { if (jQuery.inArray(file.name, names) !== 1) { file.mime == 'directory' && add(file); } }); } changed && save(); }) .bind('sync netmount', function() { var ev = this, opSuffix = opts.suffix? opts.suffix : '', hashes; if (ev.type === 'sync') { // check is change of opts.suffix if (suffix !== opSuffix) { suffix = opSuffix; clear(); init(); return; } } hashes = Object.keys(dirs); if (hashes.length) { root.prepend(spinner); fm.request({ data : {cmd : 'info', targets : hashes}, preventDefault : true }) .done(function(data) { var exists = {}, updated = false, cwd = fm.cwd().hash; jQuery.each(data.files || [], function(i, file) { var hash = file.hash; exists[hash] = file; if (!fm.files().hasOwnProperty(file.hash)) { // update cache fm.trigger('tree', {tree: [file]}); } }); jQuery.each(dirs, function(h, f) { if (f.notfound === Boolean(exists[h])) { if ((f.phash === cwd && ev.type !== 'netmount') || (exists[h] && exists[h].mime !== 'directory')) { if (remove(h)) { updated = true; } } else { if (update(exists[h] || Object.assign({notfound: true}, f))) { updated = true; } } } else if (exists[h] && exists[h].phash != cwd) { // update permission of except cwd update(exists[h]); } }); updated && save(); }) .always(function() { spinner.remove(); }); } }); }); }); }; /* * File: /js/ui/searchbutton.js */ /** * @class elFinder toolbar search button widget. * * @author Dmitry (dio) Levashov **/ jQuery.fn.elfindersearchbutton = function(cmd) { return this.each(function() { var result = false, fm = cmd.fm, disabled = fm.res('class', 'disabled'), isopts = cmd.options.incsearch || { enable: false }, sTypes = cmd.options.searchTypes, id = function(name){return fm.namespace + fm.escape(name);}, toolbar= fm.getUI('toolbar'), btnCls = fm.res('class', 'searchbtn'), button = jQuery(this) .hide() .addClass('ui-widget-content elfinder-button '+btnCls) .on('click', function(e) { e.stopPropagation(); }), getMenuOffset = function() { var fmNode = fm.getUI(), baseOffset = fmNode.offset(), buttonOffset = button.offset(); return { top : buttonOffset.top - baseOffset.top, maxHeight : fmNode.height() - 40 }; }, search = function() { input.data('inctm') && clearTimeout(input.data('inctm')); var val = jQuery.trim(input.val()), from = !jQuery('#' + id('SearchFromAll')).prop('checked'), mime = jQuery('#' + id('SearchMime')).prop('checked'), type = ''; if (from) { if (jQuery('#' + id('SearchFromVol')).prop('checked')) { from = fm.root(fm.cwd().hash); } else { from = fm.cwd().hash; } } if (mime) { mime = val; val = '.'; } if (typeSet) { type = typeSet.children('input:checked').val(); } if (val) { input.trigger('focus'); cmd.exec(val, from, mime, type).done(function() { result = true; }).fail(function() { abort(); }); } else { fm.trigger('searchend'); } }, abort = function() { input.data('inctm') && clearTimeout(input.data('inctm')); input.val('').trigger('blur'); if (result || incVal) { result = false; incVal = ''; fm.lazy(function() { fm.trigger('searchend'); }); } }, incVal = '', input = jQuery('<input type="text" size="42"/>') .on('focus', function() { // close other menus !button.hasClass('ui-state-active') && fm.getUI().click(); inFocus = true; incVal = ''; button.addClass('ui-state-active'); fm.trigger('uiresize'); opts && opts.css(getMenuOffset()).slideDown(function() { // Care for on browser window re-active button.addClass('ui-state-active'); fm.toFront(opts); }); }) .on('blur', function() { inFocus = false; if (opts) { if (!opts.data('infocus')) { opts.slideUp(function() { button.removeClass('ui-state-active'); fm.trigger('uiresize'); fm.toHide(opts); }); } else { opts.data('infocus', false); } } else { button.removeClass('ui-state-active'); } }) .appendTo(button) // to avoid fm shortcuts on arrows .on('keypress', function(e) { e.stopPropagation(); }) .on('keydown', function(e) { e.stopPropagation(); if (e.keyCode === jQuery.ui.keyCode.ENTER) { search(); } else if (e.keyCode === jQuery.ui.keyCode.ESCAPE) { e.preventDefault(); abort(); } }), opts, typeSet, cwdReady, inFocus; if (isopts.enable) { isopts.minlen = isopts.minlen || 2; isopts.wait = isopts.wait || 500; input .attr('title', fm.i18n('incSearchOnly')) .on('compositionstart', function() { input.data('composing', true); }) .on('compositionend', function() { input.removeData('composing'); input.trigger('input'); // for IE, edge }) .on('input', function() { if (! input.data('composing')) { input.data('inctm') && clearTimeout(input.data('inctm')); input.data('inctm', setTimeout(function() { var val = input.val(); if (val.length === 0 || val.length >= isopts.minlen) { (incVal !== val) && fm.trigger('incsearchstart', { query: val }); incVal = val; if (val === '' && fm.searchStatus.state > 1 && fm.searchStatus.query) { input.val(fm.searchStatus.query).trigger('select'); } } }, isopts.wait)); } }); if (fm.UA.ltIE8) { input.on('keydown', function(e) { if (e.keyCode === 229) { input.data('imetm') && clearTimeout(input.data('imetm')); input.data('composing', true); input.data('imetm', setTimeout(function() { input.removeData('composing'); }, 100)); } }) .on('keyup', function(e) { input.data('imetm') && clearTimeout(input.data('imetm')); if (input.data('composing')) { e.keyCode === jQuery.ui.keyCode.ENTER && input.trigger('compositionend'); } else { input.trigger('input'); } }); } } jQuery('<span class="ui-icon ui-icon-search" title="'+cmd.title+'"/>') .appendTo(button) .on('mousedown', function(e) { e.stopPropagation(); e.preventDefault(); if (button.hasClass('ui-state-active')) { search(); } else { input.trigger('focus'); } }); jQuery('<span class="ui-icon ui-icon-close"/>') .appendTo(button) .on('mousedown', function(e) { e.stopPropagation(); e.preventDefault(); if (input.val() === '' && !button.hasClass('ui-state-active')) { input.trigger('focus'); } else { abort(); } }); // wait when button will be added to DOM fm.bind('toolbarload', function(){ var parent = button.parent(); if (parent.length) { toolbar.prepend(button.show()); parent.remove(); // position icons for ie7 if (fm.UA.ltIE7) { var icon = button.children(fm.direction == 'ltr' ? '.ui-icon-close' : '.ui-icon-search'); icon.css({ right : '', left : parseInt(button.width())-icon.outerWidth(true) }); } } }); fm .one('init', function() { fm.getUI('cwd').on('touchstart click', function() { inFocus && input.trigger('blur'); }); }) .one('open', function() { opts = (fm.api < 2.1)? null : jQuery('<div class="ui-front ui-widget ui-widget-content elfinder-button-menu elfinder-button-search-menu ui-corner-all"/>') .append( jQuery('<div class="buttonset"/>') .append( jQuery('<input id="'+id('SearchFromCwd')+'" name="serchfrom" type="radio" checked="checked"/><label for="'+id('SearchFromCwd')+'">'+fm.i18n('btnCwd')+'</label>'), jQuery('<input id="'+id('SearchFromVol')+'" name="serchfrom" type="radio"/><label for="'+id('SearchFromVol')+'">'+fm.i18n('btnVolume')+'</label>'), jQuery('<input id="'+id('SearchFromAll')+'" name="serchfrom" type="radio"/><label for="'+id('SearchFromAll')+'">'+fm.i18n('btnAll')+'</label>') ), jQuery('<div class="buttonset elfinder-search-type"/>') .append( jQuery('<input id="'+id('SearchName')+'" name="serchcol" type="radio" checked="checked" value="SearchName"/><label for="'+id('SearchName')+'">'+fm.i18n('btnFileName')+'</label>') ) ) .hide() .appendTo(fm.getUI()); if (opts) { if (sTypes) { typeSet = opts.find('.elfinder-search-type'); jQuery.each(cmd.options.searchTypes, function(i, v) { typeSet.append(jQuery('<input id="'+id(i)+'" name="serchcol" type="radio" value="'+fm.escape(i)+'"/><label for="'+id(i)+'">'+fm.i18n(v.name)+'</label>')); }); } opts.find('div.buttonset').buttonset(); jQuery('#'+id('SearchFromAll')).next('label').attr('title', fm.i18n('searchTarget', fm.i18n('btnAll'))); if (sTypes) { jQuery.each(sTypes, function(i, v) { if (v.title) { jQuery('#'+id(i)).next('label').attr('title', fm.i18n(v.title)); } }); } opts.on('mousedown', 'div.buttonset', function(e){ e.stopPropagation(); opts.data('infocus', true); }) .on('click', 'input', function(e) { e.stopPropagation(); jQuery.trim(input.val())? search() : input.trigger('focus'); }) .on('close', function() { input.trigger('blur'); }); } }) .bind('searchend', function() { input.val(''); }) .bind('open parents', function() { var dirs = [], volroot = fm.file(fm.root(fm.cwd().hash)); if (volroot) { jQuery.each(fm.parents(fm.cwd().hash), function(i, hash) { dirs.push(fm.file(hash).name); }); jQuery('#'+id('SearchFromCwd')).next('label').attr('title', fm.i18n('searchTarget', dirs.join(fm.option('separator')))); jQuery('#'+id('SearchFromVol')).next('label').attr('title', fm.i18n('searchTarget', volroot.name)); } }) .bind('open', function() { incVal && abort(); }) .bind('cwdinit', function() { cwdReady = false; }) .bind('cwdrender',function() { cwdReady = true; }) .bind('keydownEsc', function() { if (incVal && incVal.substr(0, 1) === '/') { incVal = ''; input.val(''); fm.trigger('searchend'); } }) .shortcut({ pattern : 'ctrl+f f3', description : cmd.title, callback : function() { input.trigger('select').trigger('focus'); } }) .shortcut({ pattern : 'a b c d e f g h i j k l m n o p q r s t u v w x y z dig0 dig1 dig2 dig3 dig4 dig5 dig6 dig7 dig8 dig9 num0 num1 num2 num3 num4 num5 num6 num7 num8 num9', description : fm.i18n('firstLetterSearch'), callback : function(e) { if (! cwdReady) { return; } var code = e.originalEvent.keyCode, next = function() { var sel = fm.selected(), key = jQuery.ui.keyCode[(!sel.length || fm.cwdHash2Elm(sel[0]).next('[id]').length)? 'RIGHT' : 'HOME']; jQuery(document).trigger(jQuery.Event('keydown', { keyCode: key, ctrlKey : false, shiftKey : false, altKey : false, metaKey : false })); }, val; if (code >= 96 && code <= 105) { code -= 48; } val = '/' + String.fromCharCode(code); if (incVal !== val) { input.val(val); incVal = val; fm .trigger('incsearchstart', { query: val }) .one('cwdrender', next); } else{ next(); } } }); }); }; /* * File: /js/ui/sortbutton.js */ /** * @class elFinder toolbar button menu with sort variants. * * @author Dmitry (dio) Levashov **/ jQuery.fn.elfindersortbutton = function(cmd) { return this.each(function() { var fm = cmd.fm, name = cmd.name, c = 'class', disabled = fm.res(c, 'disabled'), hover = fm.res(c, 'hover'), item = 'elfinder-button-menu-item', selected = item+'-selected', asc = selected+'-asc', desc = selected+'-desc', text = jQuery('<span class="elfinder-button-text">'+cmd.title+'</span>'), button = jQuery(this).addClass('ui-state-default elfinder-button elfinder-menubutton elfiner-button-'+name) .attr('title', cmd.title) .append('<span class="elfinder-button-icon elfinder-button-icon-'+name+'"/>', text) .on('mouseenter mouseleave', function(e) { !button.hasClass(disabled) && button.toggleClass(hover, e.type === 'mouseenter'); }) .on('click', function(e) { if (!button.hasClass(disabled)) { e.stopPropagation(); menu.is(':hidden') && fm.getUI().click(); menu.css(getMenuOffset()).slideToggle({ duration: 100, done: function(e) { fm[menu.is(':visible')? 'toFront' : 'toHide'](menu); } }); } }), hide = function() { fm.toHide(menu); }, menu = jQuery('<div class="ui-front ui-widget ui-widget-content elfinder-button-menu ui-corner-all"/>') .hide() .appendTo(fm.getUI()) .on('mouseenter mouseleave', '.'+item, function(e) { jQuery(this).toggleClass(hover, e.type === 'mouseenter'); }) .on('click', function(e) { e.preventDefault(); e.stopPropagation(); }) .on('close', hide), update = function() { menu.children('[rel]').removeClass(selected+' '+asc+' '+desc) .filter('[rel="'+fm.sortType+'"]') .addClass(selected+' '+(fm.sortOrder == 'asc' ? asc : desc)); menu.children('.elfinder-sort-stick').toggleClass(selected, fm.sortStickFolders); menu.children('.elfinder-sort-tree').toggleClass(selected, fm.sortAlsoTreeview); }, getMenuOffset = function() { var baseOffset = fm.getUI().offset(), buttonOffset = button.offset(); return { top : buttonOffset.top - baseOffset.top, left : buttonOffset.left - baseOffset.left }; }, tm; text.hide(); jQuery.each(fm.sortRules, function(name, value) { menu.append(jQuery('<div class="'+item+'" rel="'+name+'"><span class="ui-icon ui-icon-arrowthick-1-n"/><span class="ui-icon ui-icon-arrowthick-1-s"/>'+fm.i18n('sort'+name)+'</div>').data('type', name)); }); menu.children().on('click', function(e) { cmd.exec([], jQuery(this).removeClass(hover).attr('rel')); }); jQuery('<div class="'+item+' '+item+'-separated elfinder-sort-ext elfinder-sort-stick"><span class="ui-icon ui-icon-check"/>'+fm.i18n('sortFoldersFirst')+'</div>') .appendTo(menu) .on('click', function() { cmd.exec([], 'stick'); }); fm.one('init', function() { if (fm.ui.tree && fm.options.sortAlsoTreeview !== null) { jQuery('<div class="'+item+' '+item+'-separated elfinder-sort-ext elfinder-sort-tree"><span class="ui-icon ui-icon-check"/>'+fm.i18n('sortAlsoTreeview')+'</div>') .appendTo(menu) .on('click', function() { cmd.exec([], 'tree'); }); } }) .bind('disable select', hide) .bind('open', function() { menu.children('[rel]').each(function() { var $this = jQuery(this); $this.toggle(fm.sorters[$this.attr('rel')]); }); }).bind('sortchange', update).getUI().on('click', hide); if (menu.children().length > 1) { cmd.change(function() { tm && cancelAnimationFrame(tm); tm = requestAnimationFrame(function() { button.toggleClass(disabled, cmd.disabled()); update(); }); }) .change(); } else { button.addClass(disabled); } }); }; /* * File: /js/ui/stat.js */ /** * @class elFinder ui * Display number of files/selected files and its size in statusbar * * @author Dmitry (dio) Levashov **/ jQuery.fn.elfinderstat = function(fm) { return this.each(function() { var size = jQuery(this).addClass('elfinder-stat-size'), sel = jQuery('<div class="elfinder-stat-selected"/>') .on('click', 'a', function(e) { var hash = jQuery(this).data('hash'); e.preventDefault(); fm.exec('opendir', [ hash ]); }), titleitems = fm.i18n('items'), titlesel = fm.i18n('selected'), titlesize = fm.i18n('size'), setstat = function(files) { var c = 0, s = 0, cwd = fm.cwd(), calc = true, hasSize = true; if (cwd.sizeInfo || cwd.size) { s = cwd.size; calc = false; } jQuery.each(files, function(i, file) { c++; if (calc) { s += parseInt(file.size) || 0; if (hasSize === true && file.mime === 'directory' && !file.sizeInfo) { hasSize = false; } } }); size.html(titleitems+': <span class="elfinder-stat-incsearch"></span>'+c+', <span class="elfinder-stat-size'+(hasSize? ' elfinder-stat-size-recursive' : '')+'">'+fm.i18n(hasSize? 'sum' : 'size')+': '+fm.formatSize(s)+'</span>') .attr('title', size.text()); fm.trigger('uistatchange'); }, setIncsearchStat = function(data) { size.find('span.elfinder-stat-incsearch').html(data? data.hashes.length + ' / ' : ''); size.attr('title', size.text()); fm.trigger('uistatchange'); }, setSelect = function(files) { var s = 0, c = 0, dirs = [], path, file; if (files.length === 1) { file = files[0]; s = file.size; if (fm.searchStatus.state === 2) { path = fm.escape(file.path? file.path.replace(/\/[^\/]*$/, '') : '..'); dirs.push('<a href="#elf_'+file.phash+'" data-hash="'+file.hash+'" title="'+path+'">'+path+'</a>'); } dirs.push(fm.escape(file.i18 || file.name)); sel.html(dirs.join('/') + (s > 0 ? ', '+fm.formatSize(s) : '')); } else if (files.length) { jQuery.each(files, function(i, file) { c++; s += parseInt(file.size)||0; }); sel.html(c ? titlesel+': '+c+', '+titlesize+': '+fm.formatSize(s) : ' '); } else { sel.html(''); } sel.attr('title', sel.text()); fm.trigger('uistatchange'); }; fm.getUI('statusbar').prepend(size).append(sel).show(); if (fm.UA.Mobile && jQuery.fn.tooltip) { fm.getUI('statusbar').tooltip({ classes: { 'ui-tooltip': 'elfinder-ui-tooltip ui-widget-shadow' }, tooltipClass: 'elfinder-ui-tooltip ui-widget-shadow', track: true }); } fm .bind('cwdhasheschange', function(e) { setstat(jQuery.map(e.data, function(h) { return fm.file(h); })); }) .change(function(e) { var files = e.data.changed || [], cwdHash = fm.cwd().hash; jQuery.each(files, function() { if (this.hash === cwdHash) { if (this.size) { size.children('.elfinder-stat-size').addClass('elfinder-stat-size-recursive').html(fm.i18n('sum')+': '+fm.formatSize(this.size)); size.attr('title', size.text()); } return false; } }); }) .select(function() { setSelect(fm.selectedFiles()); }) .bind('open', function() { setSelect([]); }) .bind('incsearch', function(e) { setIncsearchStat(e.data); }) .bind('incsearchend', function() { setIncsearchStat(); }) ; }); }; /* * File: /js/ui/toast.js */ /** * @class elFinder toast * * This was created inspired by the toastr. Thanks to developers of toastr. * CodeSeven/toastr: http://johnpapa.net <https://github.com/CodeSeven/toastr> * * @author Naoki Sawada **/ jQuery.fn.elfindertoast = function(opts, fm) { var defOpts = Object.assign({ mode: 'success', // or 'info', 'warning' and 'error' msg: '', showMethod: 'fadeIn', //fadeIn, slideDown, and show are built into jQuery showDuration: 300, showEasing: 'swing', //swing and linear are built into jQuery onShown: undefined, hideMethod: 'fadeOut', hideDuration: 1500, hideEasing: 'swing', onHidden: undefined, timeOut: 3000, extNode: undefined, button: undefined, width: undefined }, jQuery.isPlainObject(fm.options.uiOptions.toast.defaults)? fm.options.uiOptions.toast.defaults : {}); return this.each(function() { opts = Object.assign({}, defOpts, opts || {}); var self = jQuery(this), show = function(notm) { self.stop(); fm.toFront(self); self[opts.showMethod]({ duration: opts.showDuration, easing: opts.showEasing, complete: function() { opts.onShown && opts.onShown(); if (!notm && opts.timeOut) { rmTm = setTimeout(rm, opts.timeOut); } } }); }, rm = function() { self[opts.hideMethod]({ duration: opts.hideDuration, easing: opts.hideEasing, complete: function() { opts.onHidden && opts.onHidden(); self.remove(); } }); }, rmTm; self.on('click', function(e) { e.stopPropagation(); e.preventDefault(); rmTm && clearTimeout(rmTm); opts.onHidden && opts.onHidden(); self.stop().remove(); }).on('mouseenter mouseleave', function(e) { if (opts.timeOut) { rmTm && clearTimeout(rmTm); rmTm = null; if (e.type === 'mouseenter') { show(true); } else { rmTm = setTimeout(rm, opts.timeOut); } } }).hide().addClass('toast-' + opts.mode).append(jQuery('<div class="elfinder-toast-msg"/>').html(opts.msg.replace(/%([a-zA-Z0-9]+)%/g, function(m, m1) { return fm.i18n(m1); }))); if (opts.extNode) { self.append(opts.extNode); } if (opts.button) { self.append( jQuery('<button class="ui-button ui-widget ui-state-default ui-corner-all elfinder-tabstop"/>') .append(jQuery('<span class="ui-button-text"/>').text(fm.i18n(opts.button.text))) .on('mouseenter mouseleave', function(e) { jQuery(this).toggleClass('ui-state-hover', e.type == 'mouseenter'); }) .on('click', opts.button.click || function(){}) ); } if (opts.width) { self.css('max-width', opts.width); } show(); }); }; /* * File: /js/ui/toolbar.js */ /** * @class elFinder toolbar * * @author Dmitry (dio) Levashov **/ jQuery.fn.elfindertoolbar = function(fm, opts) { this.not('.elfinder-toolbar').each(function() { var commands = fm._commands, self = jQuery(this).addClass('ui-helper-clearfix ui-widget-header elfinder-toolbar'), options = { // default options displayTextLabel: false, labelExcludeUA: ['Mobile'], autoHideUA: ['Mobile'], showPreferenceButton: 'none' }, filter = function(opts) { return jQuery.grep(opts, function(v) { if (jQuery.isPlainObject(v)) { options = Object.assign(options, v); return false; } return true; }); }, render = function(disabled){ var name,cmdPref; jQuery.each(buttons, function(i, b) { b.detach(); }); self.empty(); l = panels.length; while (l--) { if (panels[l]) { panel = jQuery('<div class="ui-widget-content ui-corner-all elfinder-buttonset"/>'); i = panels[l].length; while (i--) { name = panels[l][i]; if ((!disabled || !disabled[name]) && (cmd = commands[name])) { button = 'elfinder'+cmd.options.ui; if (! buttons[name] && jQuery.fn[button]) {
•
Search:
•
Replace:
1
2
3
4
Function
Edit by line
Download
Information
Rename
Copy
Move
Delete
Chmod
List