/** vim: et:ts=4:sw=4:sts=4 * @license RequireJS 2.1.5 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved. * Available via the MIT or new BSD license. * see: http://github.com/jrburke/requirejs for details */ //Not using strict: uneven strict support in browsers, #392, and causes //problems with requirejs.exec()/transpiler plugins that may not be strict. /*jslint regexp: true, nomen: true, sloppy: true */ /*global window, navigator, document, importScripts, setTimeout, opera */ var requirejs, require, define; (function (global) { var req, s, head, baseElement, dataMain, src, interactiveScript, currentlyAddingScript, mainScript, subPath, version = '2.1.5', commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg, cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g, jsSuffixRegExp = /\.js$/, currDirRegExp = /^\.\//, op = Object.prototype, ostring = op.toString, hasOwn = op.hasOwnProperty, ap = Array.prototype, apsp = ap.splice, isBrowser = !!(typeof window !== 'undefined' && navigator && document), isWebWorker = !isBrowser && typeof importScripts !== 'undefined', //PS3 indicates loaded and complete, but need to wait for complete //specifically. Sequence is 'loading', 'loaded', execution, // then 'complete'. The UA check is unfortunate, but not sure how //to feature test w/o causing perf issues. readyRegExp = isBrowser && navigator.platform === 'PLAYSTATION 3' ? /^complete$/ : /^(complete|loaded)$/, defContextName = '_', //Oh the tragedy, detecting opera. See the usage of isOpera for reason. isOpera = typeof opera !== 'undefined' && opera.toString() === '[object Opera]', contexts = {}, cfg = {}, globalDefQueue = [], useInteractive = false; function isFunction(it) { return ostring.call(it) === '[object Function]'; } function isArray(it) { return ostring.call(it) === '[object Array]'; } /** * Helper function for iterating over an array. If the func returns * a true value, it will break out of the loop. */ function each(ary, func) { if (ary) { var i; for (i = 0; i < ary.length; i += 1) { if (ary[i] && func(ary[i], i, ary)) { break; } } } } /** * Helper function for iterating over an array backwards. If the func * returns a true value, it will break out of the loop. */ function eachReverse(ary, func) { if (ary) { var i; for (i = ary.length - 1; i > -1; i -= 1) { if (ary[i] && func(ary[i], i, ary)) { break; } } } } function hasProp(obj, prop) { return hasOwn.call(obj, prop); } function getOwn(obj, prop) { return hasProp(obj, prop) && obj[prop]; } /** * Cycles over properties in an object and calls a function for each * property value. If the function returns a truthy value, then the * iteration is stopped. */ function eachProp(obj, func) { var prop; for (prop in obj) { if (hasProp(obj, prop)) { if (func(obj[prop], prop)) { break; } } } } /** * Simple function to mix in properties from source into target, * but only if target does not already have a property of the same name. */ function mixin(target, source, force, deepStringMixin) { if (source) { eachProp(source, function (value, prop) { if (force || !hasProp(target, prop)) { if (deepStringMixin && typeof value !== 'string') { if (!target[prop]) { target[prop] = {}; } mixin(target[prop], value, force, deepStringMixin); } else { target[prop] = value; } } }); } return target; } //Similar to Function.prototype.bind, but the 'this' object is specified //first, since it is easier to read/figure out what 'this' will be. function bind(obj, fn) { return function () { return fn.apply(obj, arguments); }; } function scripts() { return document.getElementsByTagName('script'); } //Allow getting a global that expressed in //dot notation, like 'a.b.c'. function getGlobal(value) { if (!value) { return value; } var g = global; each(value.split('.'), function (part) { g = g[part]; }); return g; } /** * Constructs an error with a pointer to an URL with more information. * @param {String} id the error ID that maps to an ID on a web page. * @param {String} message human readable error. * @param {Error} [err] the original error, if there is one. * * @returns {Error} */ function makeError(id, msg, err, requireModules) { var e = new Error(msg + '\nhttp://requirejs.org/docs/errors.html#' + id); e.requireType = id; e.requireModules = requireModules; if (err) { e.originalError = err; } return e; } if (typeof define !== 'undefined') { //If a define is already in play via another AMD loader, //do not overwrite. return; } if (typeof requirejs !== 'undefined') { if (isFunction(requirejs)) { //Do not overwrite and existing requirejs instance. return; } cfg = requirejs; requirejs = undefined; } //Allow for a require config object if (typeof require !== 'undefined' && !isFunction(require)) { //assume it is a config object. cfg = require; require = undefined; } function newContext(contextName) { var inCheckLoaded, Module, context, handlers, checkLoadedTimeoutId, config = { //Defaults. Do not set a default for map //config to speed up normalize(), which //will run faster if there is no default. waitSeconds: 7, baseUrl: './', paths: {}, pkgs: {}, shim: {}, config: {} }, registry = {}, //registry of just enabled modules, to speed //cycle breaking code when lots of modules //are registered, but not activated. enabledRegistry = {}, undefEvents = {}, defQueue = [], defined = {}, urlFetched = {}, requireCounter = 1, unnormalizedCounter = 1; /** * Trims the . and .. from an array of path segments. * It will keep a leading path segment if a .. will become * the first path segment, to help with module name lookups, * which act like paths, but can be remapped. But the end result, * all paths that use this function should look normalized. * NOTE: this method MODIFIES the input array. * @param {Array} ary the array of path segments. */ function trimDots(ary) { var i, part; for (i = 0; ary[i]; i += 1) { part = ary[i]; if (part === '.') { ary.splice(i, 1); i -= 1; } else if (part === '..') { if (i === 1 && (ary[2] === '..' || ary[0] === '..')) { //End of the line. Keep at least one non-dot //path segment at the front so it can be mapped //correctly to disk. Otherwise, there is likely //no path mapping for a path starting with '..'. //This can still fail, but catches the most reasonable //uses of .. break; } else if (i > 0) { ary.splice(i - 1, 2); i -= 2; } } } } /** * Given a relative module name, like ./something, normalize it to * a real name that can be mapped to a path. * @param {String} name the relative name * @param {String} baseName a real name that the name arg is relative * to. * @param {Boolean} applyMap apply the map config to the value. Should * only be done if this normalization is for a dependency ID. * @returns {String} normalized name */ function normalize(name, baseName, applyMap) { var pkgName, pkgConfig, mapValue, nameParts, i, j, nameSegment, foundMap, foundI, foundStarMap, starI, baseParts = baseName && baseName.split('/'), normalizedBaseParts = baseParts, map = config.map, starMap = map && map['*']; //Adjust any relative paths. if (name && name.charAt(0) === '.') { //If have a base name, try to normalize against it, //otherwise, assume it is a top-level require that will //be relative to baseUrl in the end. if (baseName) { if (getOwn(config.pkgs, baseName)) { //If the baseName is a package name, then just treat it as one //name to concat the name with. normalizedBaseParts = baseParts = [baseName]; } else { //Convert baseName to array, and lop off the last part, //so that . matches that 'directory' and not name of the baseName's //module. For instance, baseName of 'one/two/three', maps to //'one/two/three.js', but we want the directory, 'one/two' for //this normalization. normalizedBaseParts = baseParts.slice(0, baseParts.length - 1); } name = normalizedBaseParts.concat(name.split('/')); trimDots(name); //Some use of packages may use a . path to reference the //'main' module name, so normalize for that. pkgConfig = getOwn(config.pkgs, (pkgName = name[0])); name = name.join('/'); if (pkgConfig && name === pkgName + '/' + pkgConfig.main) { name = pkgName; } } else if (name.indexOf('./') === 0) { // No baseName, so this is ID is resolved relative // to baseUrl, pull off the leading dot. name = name.substring(2); } } //Apply map config if available. if (applyMap && map && (baseParts || starMap)) { nameParts = name.split('/'); for (i = nameParts.length; i > 0; i -= 1) { nameSegment = nameParts.slice(0, i).join('/'); if (baseParts) { //Find the longest baseName segment match in the config. //So, do joins on the biggest to smallest lengths of baseParts. for (j = baseParts.length; j > 0; j -= 1) { mapValue = getOwn(map, baseParts.slice(0, j).join('/')); //baseName segment has config, find if it has one for //this name. if (mapValue) { mapValue = getOwn(mapValue, nameSegment); if (mapValue) { //Match, update name to the new value. foundMap = mapValue; foundI = i; break; } } } } if (foundMap) { break; } //Check for a star map match, but just hold on to it, //if there is a shorter segment match later in a matching //config, then favor over this star map. if (!foundStarMap && starMap && getOwn(starMap, nameSegment)) { foundStarMap = getOwn(starMap, nameSegment); starI = i; } } if (!foundMap && foundStarMap) { foundMap = foundStarMap; foundI = starI; } if (foundMap) { nameParts.splice(0, foundI, foundMap); name = nameParts.join('/'); } } return name; } function removeScript(name) { if (isBrowser) { each(scripts(), function (scriptNode) { if (scriptNode.getAttribute('data-requiremodule') === name && scriptNode.getAttribute('data-requirecontext') === context.contextName) { scriptNode.parentNode.removeChild(scriptNode); return true; } }); } } function hasPathFallback(id) { var pathConfig = getOwn(config.paths, id); if (pathConfig && isArray(pathConfig) && pathConfig.length > 1) { removeScript(id); //Pop off the first array value, since it failed, and //retry pathConfig.shift(); context.require.undef(id); context.require([id]); return true; } } //Turns a plugin!resource to [plugin, resource] //with the plugin being undefined if the name //did not have a plugin prefix. function splitPrefix(name) { var prefix, index = name ? name.indexOf('!') : -1; if (index > -1) { prefix = name.substring(0, index); name = name.substring(index + 1, name.length); } return [prefix, name]; } /** * Creates a module mapping that includes plugin prefix, module * name, and path. If parentModuleMap is provided it will * also normalize the name via require.normalize() * * @param {String} name the module name * @param {String} [parentModuleMap] parent module map * for the module name, used to resolve relative names. * @param {Boolean} isNormalized: is the ID already normalized. * This is true if this call is done for a define() module ID. * @param {Boolean} applyMap: apply the map config to the ID. * Should only be true if this map is for a dependency. * * @returns {Object} */ function makeModuleMap(name, parentModuleMap, isNormalized, applyMap) { var url, pluginModule, suffix, nameParts, prefix = null, parentName = parentModuleMap ? parentModuleMap.name : null, originalName = name, isDefine = true, normalizedName = ''; //If no name, then it means it is a require call, generate an //internal name. if (!name) { isDefine = false; name = '_@r' + (requireCounter += 1); } nameParts = splitPrefix(name); prefix = nameParts[0]; name = nameParts[1]; if (prefix) { prefix = normalize(prefix, parentName, applyMap); pluginModule = getOwn(defined, prefix); } //Account for relative paths if there is a base name. if (name) { if (prefix) { if (pluginModule && pluginModule.normalize) { //Plugin is loaded, use its normalize method. normalizedName = pluginModule.normalize(name, function (name) { return normalize(name, parentName, applyMap); }); } else { normalizedName = normalize(name, parentName, applyMap); } } else { //A regular module. normalizedName = normalize(name, parentName, applyMap); //Normalized name may be a plugin ID due to map config //application in normalize. The map config values must //already be normalized, so do not need to redo that part. nameParts = splitPrefix(normalizedName); prefix = nameParts[0]; normalizedName = nameParts[1]; isNormalized = true; url = context.nameToUrl(normalizedName); } } //If the id is a plugin id that cannot be determined if it needs //normalization, stamp it with a unique ID so two matching relative //ids that may conflict can be separate. suffix = prefix && !pluginModule && !isNormalized ? '_unnormalized' + (unnormalizedCounter += 1) : ''; return { prefix: prefix, name: normalizedName, parentMap: parentModuleMap, unnormalized: !!suffix, url: url, originalName: originalName, isDefine: isDefine, id: (prefix ? prefix + '!' + normalizedName : normalizedName) + suffix }; } function getModule(depMap) { var id = depMap.id, mod = getOwn(registry, id); if (!mod) { mod = registry[id] = new context.Module(depMap); } return mod; } function on(depMap, name, fn) { var id = depMap.id, mod = getOwn(registry, id); if (hasProp(defined, id) && (!mod || mod.defineEmitComplete)) { if (name === 'defined') { fn(defined[id]); } } else { getModule(depMap).on(name, fn); } } function onError(err, errback) { var ids = err.requireModules, notified = false; if (errback) { errback(err); } else { each(ids, function (id) { var mod = getOwn(registry, id); if (mod) { //Set error on module, so it skips timeout checks. mod.error = err; if (mod.events.error) { notified = true; mod.emit('error', err); } } }); if (!notified) { req.onError(err); } } } /** * Internal method to transfer globalQueue items to this context's * defQueue. */ function takeGlobalQueue() { //Push all the globalDefQueue items into the context's defQueue if (globalDefQueue.length) { //Array splice in the values since the context code has a //local var ref to defQueue, so cannot just reassign the one //on context. apsp.apply(defQueue, [defQueue.length - 1, 0].concat(globalDefQueue)); globalDefQueue = []; } } handlers = { 'require': function (mod) { if (mod.require) { return mod.require; } else { return (mod.require = context.makeRequire(mod.map)); } }, 'exports': function (mod) { mod.usingExports = true; if (mod.map.isDefine) { if (mod.exports) { return mod.exports; } else { return (mod.exports = defined[mod.map.id] = {}); } } }, 'module': function (mod) { if (mod.module) { return mod.module; } else { return (mod.module = { id: mod.map.id, uri: mod.map.url, config: function () { return (config.config && getOwn(config.config, mod.map.id)) || {}; }, exports: defined[mod.map.id] }); } } }; function cleanRegistry(id) { //Clean up machinery used for waiting modules. delete registry[id]; delete enabledRegistry[id]; } function breakCycle(mod, traced, processed) { var id = mod.map.id; if (mod.error) { mod.emit('error', mod.error); } else { traced[id] = true; each(mod.depMaps, function (depMap, i) { var depId = depMap.id, dep = getOwn(registry, depId); //Only force things that have not completed //being defined, so still in the registry, //and only if it has not been matched up //in the module already. if (dep && !mod.depMatched[i] && !processed[depId]) { if (getOwn(traced, depId)) { mod.defineDep(i, defined[depId]); mod.check(); //pass false? } else { breakCycle(dep, traced, processed); } } }); processed[id] = true; } } function checkLoaded() { var map, modId, err, usingPathFallback, waitInterval = config.waitSeconds * 1000, //It is possible to disable the wait interval by using waitSeconds of 0. expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(), noLoads = [], reqCalls = [], stillLoading = false, needCycleCheck = true; //Do not bother if this call was a result of a cycle break. if (inCheckLoaded) { return; } inCheckLoaded = true; //Figure out the state of all the modules. eachProp(enabledRegistry, function (mod) { map = mod.map; modId = map.id; //Skip things that are not enabled or in error state. if (!mod.enabled) { return; } if (!map.isDefine) { reqCalls.push(mod); } if (!mod.error) { //If the module should be executed, and it has not //been inited and time is up, remember it. if (!mod.inited && expired) { if (hasPathFallback(modId)) { usingPathFallback = true; stillLoading = true; } else { noLoads.push(modId); removeScript(modId); } } else if (!mod.inited && mod.fetched && map.isDefine) { stillLoading = true; if (!map.prefix) { //No reason to keep looking for unfinished //loading. If the only stillLoading is a //plugin resource though, keep going, //because it may be that a plugin resource //is waiting on a non-plugin cycle. return (needCycleCheck = false); } } } }); if (expired && noLoads.length) { //If wait time expired, throw error of unloaded modules. err = makeError('timeout', 'Load timeout for modules: ' + noLoads, null, noLoads); err.contextName = context.contextName; return onError(err); } //Not expired, check for a cycle. if (needCycleCheck) { each(reqCalls, function (mod) { breakCycle(mod, {}, {}); }); } //If still waiting on loads, and the waiting load is something //other than a plugin resource, or there are still outstanding //scripts, then just try back later. if ((!expired || usingPathFallback) && stillLoading) { //Something is still waiting to load. Wait for it, but only //if a timeout is not already in effect. if ((isBrowser || isWebWorker) && !checkLoadedTimeoutId) { checkLoadedTimeoutId = setTimeout(function () { checkLoadedTimeoutId = 0; checkLoaded(); }, 50); } } inCheckLoaded = false; } Module = function (map) { this.events = getOwn(undefEvents, map.id) || {}; this.map = map; this.shim = getOwn(config.shim, map.id); this.depExports = []; this.depMaps = []; this.depMatched = []; this.pluginMaps = {}; this.depCount = 0; /* this.exports this.factory this.depMaps = [], this.enabled, this.fetched */ }; Module.prototype = { init: function (depMaps, factory, errback, options) { options = options || {}; //Do not do more inits if already done. Can happen if there //are multiple define calls for the same module. That is not //a normal, common case, but it is also not unexpected. if (this.inited) { return; } this.factory = factory; if (errback) { //Register for errors on this module. this.on('error', errback); } else if (this.events.error) { //If no errback already, but there are error listeners //on this module, set up an errback to pass to the deps. errback = bind(this, function (err) { this.emit('error', err); }); } //Do a copy of the dependency array, so that //source inputs are not modified. For example //"shim" deps are passed in here directly, and //doing a direct modification of the depMaps array //would affect that config. this.depMaps = depMaps && depMaps.slice(0); this.errback = errback; //Indicate this module has be initialized this.inited = true; this.ignore = options.ignore; //Could have option to init this module in enabled mode, //or could have been previously marked as enabled. However, //the dependencies are not known until init is called. So //if enabled previously, now trigger dependencies as enabled. if (options.enabled || this.enabled) { //Enable this module and dependencies. //Will call this.check() this.enable(); } else { this.check(); } }, defineDep: function (i, depExports) { //Because of cycles, defined callback for a given //export can be called more than once. if (!this.depMatched[i]) { this.depMatched[i] = true; this.depCount -= 1; this.depExports[i] = depExports; } }, fetch: function () { if (this.fetched) { return; } this.fetched = true; context.startTime = (new Date()).getTime(); var map = this.map; //If the manager is for a plugin managed resource, //ask the plugin to load it now. if (this.shim) { context.makeRequire(this.map, { enableBuildCallback: true })(this.shim.deps || [], bind(this, function () { return map.prefix ? this.callPlugin() : this.load(); })); } else { //Regular dependency. return map.prefix ? this.callPlugin() : this.load(); } }, load: function () { var url = this.map.url; //Regular dependency. if (!urlFetched[url]) { urlFetched[url] = true; context.load(this.map.id, url); } }, /** * Checks if the module is ready to define itself, and if so, * define it. */ check: function () { if (!this.enabled || this.enabling) { return; } var err, cjsModule, id = this.map.id, depExports = this.depExports, exports = this.exports, factory = this.factory; if (!this.inited) { this.fetch(); } else if (this.error) { this.emit('error', this.error); } else if (!this.defining) { //The factory could trigger another require call //that would result in checking this module to //define itself again. If already in the process //of doing that, skip this work. this.defining = true; if (this.depCount < 1 && !this.defined) { if (isFunction(factory)) { //If there is an error listener, favor passing //to that instead of throwing an error. if (this.events.error) { try { exports = context.execCb(id, factory, depExports, exports); } catch (e) { err = e; } } else { exports = context.execCb(id, factory, depExports, exports); } if (this.map.isDefine) { //If setting exports via 'module' is in play, //favor that over return value and exports. After that, //favor a non-undefined return value over exports use. cjsModule = this.module; if (cjsModule && cjsModule.exports !== undefined && //Make sure it is not already the exports value cjsModule.exports !== this.exports) { exports = cjsModule.exports; } else if (exports === undefined && this.usingExports) { //exports already set the defined value. exports = this.exports; } } if (err) { err.requireMap = this.map; err.requireModules = [this.map.id]; err.requireType = 'define'; return onError((this.error = err)); } } else { //Just a literal value exports = factory; } this.exports = exports; if (this.map.isDefine && !this.ignore) { defined[id] = exports; if (req.onResourceLoad) { req.onResourceLoad(context, this.map, this.depMaps); } } //Clean up cleanRegistry(id); this.defined = true; } //Finished the define stage. Allow calling check again //to allow define notifications below in the case of a //cycle. this.defining = false; if (this.defined && !this.defineEmitted) { this.defineEmitted = true; this.emit('defined', this.exports); this.defineEmitComplete = true; } } }, callPlugin: function () { var map = this.map, id = map.id, //Map already normalized the prefix. pluginMap = makeModuleMap(map.prefix); //Mark this as a dependency for this plugin, so it //can be traced for cycles. this.depMaps.push(pluginMap); on(pluginMap, 'defined', bind(this, function (plugin) { var load, normalizedMap, normalizedMod, name = this.map.name, parentName = this.map.parentMap ? this.map.parentMap.name : null, localRequire = context.makeRequire(map.parentMap, { enableBuildCallback: true }); //If current map is not normalized, wait for that //normalized name to load instead of continuing. if (this.map.unnormalized) { //Normalize the ID if the plugin allows it. if (plugin.normalize) { name = plugin.normalize(name, function (name) { return normalize(name, parentName, true); }) || ''; } //prefix and name should already be normalized, no need //for applying map config again either. normalizedMap = makeModuleMap(map.prefix + '!' + name, this.map.parentMap); on(normalizedMap, 'defined', bind(this, function (value) { this.init([], function () { return value; }, null, { enabled: true, ignore: true }); })); normalizedMod = getOwn(registry, normalizedMap.id); if (normalizedMod) { //Mark this as a dependency for this plugin, so it //can be traced for cycles. this.depMaps.push(normalizedMap); if (this.events.error) { normalizedMod.on('error', bind(this, function (err) { this.emit('error', err); })); } normalizedMod.enable(); } return; } load = bind(this, function (value) { this.init([], function () { return value; }, null, { enabled: true }); }); load.error = bind(this, function (err) { this.inited = true; this.error = err; err.requireModules = [id]; //Remove temp unnormalized modules for this module, //since they will never be resolved otherwise now. eachProp(registry, function (mod) { if (mod.map.id.indexOf(id + '_unnormalized') === 0) { cleanRegistry(mod.map.id); } }); onError(err); }); //Allow plugins to load other code without having to know the //context or how to 'complete' the load. load.fromText = bind(this, function (text, textAlt) { /*jslint evil: true */ var moduleName = map.name, moduleMap = makeModuleMap(moduleName), hasInteractive = useInteractive; //As of 2.1.0, support just passing the text, to reinforce //fromText only being called once per resource. Still //support old style of passing moduleName but discard //that moduleName in favor of the internal ref. if (textAlt) { text = textAlt; } //Turn off interactive script matching for IE for any define //calls in the text, then turn it back on at the end. if (hasInteractive) { useInteractive = false; } //Prime the system by creating a module instance for //it. getModule(moduleMap); //Transfer any config to this other module. if (hasProp(config.config, id)) { config.config[moduleName] = config.config[id]; } try { req.exec(text); } catch (e) { return onError(makeError('fromtexteval', 'fromText eval for ' + id + ' failed: ' + e, e, [id])); } if (hasInteractive) { useInteractive = true; } //Mark this as a dependency for the plugin //resource this.depMaps.push(moduleMap); //Support anonymous modules. context.completeLoad(moduleName); //Bind the value of that module to the value for this //resource ID. localRequire([moduleName], load); }); //Use parentName here since the plugin's name is not reliable, //could be some weird string with no path that actually wants to //reference the parentName's path. plugin.load(map.name, localRequire, load, config); })); context.enable(pluginMap, this); this.pluginMaps[pluginMap.id] = pluginMap; }, enable: function () { enabledRegistry[this.map.id] = this; this.enabled = true; //Set flag mentioning that the module is enabling, //so that immediate calls to the defined callbacks //for dependencies do not trigger inadvertent load //with the depCount still being zero. this.enabling = true; //Enable each dependency each(this.depMaps, bind(this, function (depMap, i) { var id, mod, handler; if (typeof depMap === 'string') { //Dependency needs to be converted to a depMap //and wired up to this module. depMap = makeModuleMap(depMap, (this.map.isDefine ? this.map : this.map.parentMap), false, !this.skipMap); this.depMaps[i] = depMap; handler = getOwn(handlers, depMap.id); if (handler) { this.depExports[i] = handler(this); return; } this.depCount += 1; on(depMap, 'defined', bind(this, function (depExports) { this.defineDep(i, depExports); this.check(); })); if (this.errback) { on(depMap, 'error', this.errback); } } id = depMap.id; mod = registry[id]; //Skip special modules like 'require', 'exports', 'module' //Also, don't call enable if it is already enabled, //important in circular dependency cases. if (!hasProp(handlers, id) && mod && !mod.enabled) { context.enable(depMap, this); } })); //Enable each plugin that is used in //a dependency eachProp(this.pluginMaps, bind(this, function (pluginMap) { var mod = getOwn(registry, pluginMap.id); if (mod && !mod.enabled) { context.enable(pluginMap, this); } })); this.enabling = false; this.check(); }, on: function (name, cb) { var cbs = this.events[name]; if (!cbs) { cbs = this.events[name] = []; } cbs.push(cb); }, emit: function (name, evt) { each(this.events[name], function (cb) { cb(evt); }); if (name === 'error') { //Now that the error handler was triggered, remove //the listeners, since this broken Module instance //can stay around for a while in the registry. delete this.events[name]; } } }; function callGetModule(args) { //Skip modules already defined. if (!hasProp(defined, args[0])) { getModule(makeModuleMap(args[0], null, true)).init(args[1], args[2]); } } function removeListener(node, func, name, ieName) { //Favor detachEvent because of IE9 //issue, see attachEvent/addEventListener comment elsewhere //in this file. if (node.detachEvent && !isOpera) { //Probably IE. If not it will throw an error, which will be //useful to know. if (ieName) { node.detachEvent(ieName, func); } } else { node.removeEventListener(name, func, false); } } /** * Given an event from a script node, get the requirejs info from it, * and then removes the event listeners on the node. * @param {Event} evt * @returns {Object} */ function getScriptData(evt) { //Using currentTarget instead of target for Firefox 2.0's sake. Not //all old browsers will be supported, but this one was easy enough //to support and still makes sense. var node = evt.currentTarget || evt.srcElement; //Remove the listeners once here. removeListener(node, context.onScriptLoad, 'load', 'onreadystatechange'); removeListener(node, context.onScriptError, 'error'); return { node: node, id: node && node.getAttribute('data-requiremodule') }; } function intakeDefines() { var args; //Any defined modules in the global queue, intake them now. takeGlobalQueue(); //Make sure any remaining defQueue items get properly processed. while (defQueue.length) { args = defQueue.shift(); if (args[0] === null) { return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' + args[args.length - 1])); } else { //args are id, deps, factory. Should be normalized by the //define() function. callGetModule(args); } } } context = { config: config, contextName: contextName, registry: registry, defined: defined, urlFetched: urlFetched, defQueue: defQueue, Module: Module, makeModuleMap: makeModuleMap, nextTick: req.nextTick, onError: onError, /** * Set a configuration for the context. * @param {Object} cfg config object to integrate. */ configure: function (cfg) { //Make sure the baseUrl ends in a slash. if (cfg.baseUrl) { if (cfg.baseUrl.charAt(cfg.baseUrl.length - 1) !== '/') { cfg.baseUrl += '/'; } } //Save off the paths and packages since they require special processing, //they are additive. var pkgs = config.pkgs, shim = config.shim, objs = { paths: true, config: true, map: true }; eachProp(cfg, function (value, prop) { if (objs[prop]) { if (prop === 'map') { if (!config.map) { config.map = {}; } mixin(config[prop], value, true, true); } else { mixin(config[prop], value, true); } } else { config[prop] = value; } }); //Merge shim if (cfg.shim) { eachProp(cfg.shim, function (value, id) { //Normalize the structure if (isArray(value)) { value = { deps: value }; } if ((value.exports || value.init) && !value.exportsFn) { value.exportsFn = context.makeShimExports(value); } shim[id] = value; }); config.shim = shim; } //Adjust packages if necessary. if (cfg.packages) { each(cfg.packages, function (pkgObj) { var location; pkgObj = typeof pkgObj === 'string' ? { name: pkgObj } : pkgObj; location = pkgObj.location; //Create a brand new object on pkgs, since currentPackages can //be passed in again, and config.pkgs is the internal transformed //state for all package configs. pkgs[pkgObj.name] = { name: pkgObj.name, location: location || pkgObj.name, //Remove leading dot in main, so main paths are normalized, //and remove any trailing .js, since different package //envs have different conventions: some use a module name, //some use a file name. main: (pkgObj.main || 'main') .replace(currDirRegExp, '') .replace(jsSuffixRegExp, '') }; }); //Done with modifications, assing packages back to context config config.pkgs = pkgs; } //If there are any "waiting to execute" modules in the registry, //update the maps for them, since their info, like URLs to load, //may have changed. eachProp(registry, function (mod, id) { //If module already has init called, since it is too //late to modify them, and ignore unnormalized ones //since they are transient. if (!mod.inited && !mod.map.unnormalized) { mod.map = makeModuleMap(id); } }); //If a deps array or a config callback is specified, then call //require with those args. This is useful when require is defined as a //config object before require.js is loaded. if (cfg.deps || cfg.callback) { context.require(cfg.deps || [], cfg.callback); } }, makeShimExports: function (value) { function fn() { var ret; if (value.init) { ret = value.init.apply(global, arguments); } return ret || (value.exports && getGlobal(value.exports)); } return fn; }, makeRequire: function (relMap, options) { options = options || {}; function localRequire(deps, callback, errback) { var id, map, requireMod; if (options.enableBuildCallback && callback && isFunction(callback)) { callback.__requireJsBuild = true; } if (typeof deps === 'string') { if (isFunction(callback)) { //Invalid call return onError(makeError('requireargs', 'Invalid require call'), errback); } //If require|exports|module are requested, get the //value for them from the special handlers. Caveat: //this only works while module is being defined. if (relMap && hasProp(handlers, deps)) { return handlers[deps](registry[relMap.id]); } //Synchronous access to one module. If require.get is //available (as in the Node adapter), prefer that. if (req.get) { return req.get(context, deps, relMap, localRequire); } //Normalize module name, if it contains . or .. map = makeModuleMap(deps, relMap, false, true); id = map.id; if (!hasProp(defined, id)) { return onError(makeError('notloaded', 'Module name "' + id + '" has not been loaded yet for context: ' + contextName + (relMap ? '' : '. Use require([])'))); } return defined[id]; } //Grab defines waiting in the global queue. intakeDefines(); //Mark all the dependencies as needing to be loaded. context.nextTick(function () { //Some defines could have been added since the //require call, collect them. intakeDefines(); requireMod = getModule(makeModuleMap(null, relMap)); //Store if map config should be applied to this require //call for dependencies. requireMod.skipMap = options.skipMap; requireMod.init(deps, callback, errback, { enabled: true }); checkLoaded(); }); return localRequire; } mixin(localRequire, { isBrowser: isBrowser, /** * Converts a module name + .extension into an URL path. * *Requires* the use of a module name. It does not support using * plain URLs like nameToUrl. */ toUrl: function (moduleNamePlusExt) { var ext, index = moduleNamePlusExt.lastIndexOf('.'), segment = moduleNamePlusExt.split('/')[0], isRelative = segment === '.' || segment === '..'; //Have a file extension alias, and it is not the //dots from a relative path. if (index !== -1 && (!isRelative || index > 1)) { ext = moduleNamePlusExt.substring(index, moduleNamePlusExt.length); moduleNamePlusExt = moduleNamePlusExt.substring(0, index); } return context.nameToUrl(normalize(moduleNamePlusExt, relMap && relMap.id, true), ext, true); }, defined: function (id) { return hasProp(defined, makeModuleMap(id, relMap, false, true).id); }, specified: function (id) { id = makeModuleMap(id, relMap, false, true).id; return hasProp(defined, id) || hasProp(registry, id); } }); //Only allow undef on top level require calls if (!relMap) { localRequire.undef = function (id) { //Bind any waiting define() calls to this context, //fix for #408 takeGlobalQueue(); var map = makeModuleMap(id, relMap, true), mod = getOwn(registry, id); delete defined[id]; delete urlFetched[map.url]; delete undefEvents[id]; if (mod) { //Hold on to listeners in case the //module will be attempted to be reloaded //using a different config. if (mod.events.defined) { undefEvents[id] = mod.events; } cleanRegistry(id); } }; } return localRequire; }, /** * Called to enable a module if it is still in the registry * awaiting enablement. A second arg, parent, the parent module, * is passed in for context, when this method is overriden by * the optimizer. Not shown here to keep code compact. */ enable: function (depMap) { var mod = getOwn(registry, depMap.id); if (mod) { getModule(depMap).enable(); } }, /** * Internal method used by environment adapters to complete a load event. * A load event could be a script load or just a load pass from a synchronous * load call. * @param {String} moduleName the name of the module to potentially complete. */ completeLoad: function (moduleName) { var found, args, mod, shim = getOwn(config.shim, moduleName) || {}, shExports = shim.exports; takeGlobalQueue(); while (defQueue.length) { args = defQueue.shift(); if (args[0] === null) { args[0] = moduleName; //If already found an anonymous module and bound it //to this name, then this is some other anon module //waiting for its completeLoad to fire. if (found) { break; } found = true; } else if (args[0] === moduleName) { //Found matching define call for this script! found = true; } callGetModule(args); } //Do this after the cycle of callGetModule in case the result //of those calls/init calls changes the registry. mod = getOwn(registry, moduleName); if (!found && !hasProp(defined, moduleName) && mod && !mod.inited) { if (config.enforceDefine && (!shExports || !getGlobal(shExports))) { if (hasPathFallback(moduleName)) { return; } else { return onError(makeError('nodefine', 'No define call for ' + moduleName, null, [moduleName])); } } else { //A script that does not call define(), so just simulate //the call for it. callGetModule([moduleName, (shim.deps || []), shim.exportsFn]); } } checkLoaded(); }, /** * Converts a module name to a file path. Supports cases where * moduleName may actually be just an URL. * Note that it **does not** call normalize on the moduleName, * it is assumed to have already been normalized. This is an * internal API, not a public one. Use toUrl for the public API. */ nameToUrl: function (moduleName, ext, skipExt) { var paths, pkgs, pkg, pkgPath, syms, i, parentModule, url, parentPath; //If a colon is in the URL, it indicates a protocol is used and it is just //an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?) //or ends with .js, then assume the user meant to use an url and not a module id. //The slash is important for protocol-less URLs as well as full paths. if (req.jsExtRegExp.test(moduleName)) { //Just a plain path, not module name lookup, so just return it. //Add extension if it is included. This is a bit wonky, only non-.js things pass //an extension, this method probably needs to be reworked. url = moduleName + (ext || ''); } else { //A module that needs to be converted to a path. paths = config.paths; pkgs = config.pkgs; syms = moduleName.split('/'); //For each module name segment, see if there is a path //registered for it. Start with most specific name //and work up from it. for (i = syms.length; i > 0; i -= 1) { parentModule = syms.slice(0, i).join('/'); pkg = getOwn(pkgs, parentModule); parentPath = getOwn(paths, parentModule); if (parentPath) { //If an array, it means there are a few choices, //Choose the one that is desired if (isArray(parentPath)) { parentPath = parentPath[0]; } syms.splice(0, i, parentPath); break; } else if (pkg) { //If module name is just the package name, then looking //for the main module. if (moduleName === pkg.name) { pkgPath = pkg.location + '/' + pkg.main; } else { pkgPath = pkg.location; } syms.splice(0, i, pkgPath); break; } } //Join the path parts together, then figure out if baseUrl is needed. url = syms.join('/'); url += (ext || (/\?/.test(url) || skipExt ? '' : '.js')); url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url; } return config.urlArgs ? url + ((url.indexOf('?') === -1 ? '?' : '&') + config.urlArgs) : url; }, //Delegates to req.load. Broken out as a separate function to //allow overriding in the optimizer. load: function (id, url) { req.load(context, id, url); }, /** * Executes a module callack function. Broken out as a separate function * solely to allow the build system to sequence the files in the built * layer in the right sequence. * * @private */ execCb: function (name, callback, args, exports) { return callback.apply(exports, args); }, /** * callback for script loads, used to check status of loading. * * @param {Event} evt the event from the browser for the script * that was loaded. */ onScriptLoad: function (evt) { //Using currentTarget instead of target for Firefox 2.0's sake. Not //all old browsers will be supported, but this one was easy enough //to support and still makes sense. if (evt.type === 'load' || (readyRegExp.test((evt.currentTarget || evt.srcElement).readyState))) { //Reset interactive script so a script node is not held onto for //to long. interactiveScript = null; //Pull out the name of the module and the context. var data = getScriptData(evt); context.completeLoad(data.id); } }, /** * Callback for script errors. */ onScriptError: function (evt) { var data = getScriptData(evt); if (!hasPathFallback(data.id)) { return onError(makeError('scripterror', 'Script error', evt, [data.id])); } } }; context.require = context.makeRequire(); return context; } /** * Main entry point. * * If the only argument to require is a string, then the module that * is represented by that string is fetched for the appropriate context. * * If the first argument is an array, then it will be treated as an array * of dependency string names to fetch. An optional function callback can * be specified to execute when all of those dependencies are available. * * Make a local req variable to help Caja compliance (it assumes things * on a require that are not standardized), and to give a short * name for minification/local scope use. */ req = requirejs = function (deps, callback, errback, optional) { //Find the right context, use default var context, config, contextName = defContextName; // Determine if have config object in the call. if (!isArray(deps) && typeof deps !== 'string') { // deps is a config object config = deps; if (isArray(callback)) { // Adjust args if there are dependencies deps = callback; callback = errback; errback = optional; } else { deps = []; } } if (config && config.context) { contextName = config.context; } context = getOwn(contexts, contextName); if (!context) { context = contexts[contextName] = req.s.newContext(contextName); } if (config) { context.configure(config); } return context.require(deps, callback, errback); }; /** * Support require.config() to make it easier to cooperate with other * AMD loaders on globally agreed names. */ req.config = function (config) { return req(config); }; /** * Execute something after the current tick * of the event loop. Override for other envs * that have a better solution than setTimeout. * @param {Function} fn function to execute later. */ req.nextTick = typeof setTimeout !== 'undefined' ? function (fn) { setTimeout(fn, 4); } : function (fn) { fn(); }; /** * Export require as a global, but only if it does not already exist. */ if (!require) { require = req; } req.version = version; //Used to filter out dependencies that are already paths. req.jsExtRegExp = /^\/|:|\?|\.js$/; req.isBrowser = isBrowser; s = req.s = { contexts: contexts, newContext: newContext }; //Create default context. req({}); //Exports some context-sensitive methods on global require. each([ 'toUrl', 'undef', 'defined', 'specified' ], function (prop) { //Reference from contexts instead of early binding to default context, //so that during builds, the latest instance of the default context //with its config gets used. req[prop] = function () { var ctx = contexts[defContextName]; return ctx.require[prop].apply(ctx, arguments); }; }); if (isBrowser) { head = s.head = document.getElementsByTagName('head')[0]; //If BASE tag is in play, using appendChild is a problem for IE6. //When that browser dies, this can be removed. Details in this jQuery bug: //http://dev.jquery.com/ticket/2709 baseElement = document.getElementsByTagName('base')[0]; if (baseElement) { head = s.head = baseElement.parentNode; } } /** * Any errors that require explicitly generates will be passed to this * function. Intercept/override it if you want custom error handling. * @param {Error} err the error object. */ req.onError = function (err) { throw err; }; /** * Does the request to load a module for the browser case. * Make this a separate function to allow other environments * to override it. * * @param {Object} context the require context to find state. * @param {String} moduleName the name of the module. * @param {Object} url the URL to the module. */ req.load = function (context, moduleName, url) { var config = (context && context.config) || {}, node; if (isBrowser) { //In the browser so use a script tag node = config.xhtml ? document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') : document.createElement('script'); node.type = config.scriptType || 'text/javascript'; node.charset = 'utf-8'; node.async = true; node.setAttribute('data-requirecontext', context.contextName); node.setAttribute('data-requiremodule', moduleName); //Set up load listener. Test attachEvent first because IE9 has //a subtle issue in its addEventListener and script onload firings //that do not match the behavior of all other browsers with //addEventListener support, which fire the onload event for a //script right after the script execution. See: //https://connect.microsoft.com/IE/feedback/details/648057/script-onload-event-is-not-fired-immediately-after-script-execution //UNFORTUNATELY Opera implements attachEvent but does not follow the script //script execution mode. if (node.attachEvent && //Check if node.attachEvent is artificially added by custom script or //natively supported by browser //read https://github.com/jrburke/requirejs/issues/187 //if we can NOT find [native code] then it must NOT natively supported. //in IE8, node.attachEvent does not have toString() //Note the test for "[native code" with no closing brace, see: //https://github.com/jrburke/requirejs/issues/273 !(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) && !isOpera) { //Probably IE. IE (at least 6-8) do not fire //script onload right after executing the script, so //we cannot tie the anonymous define call to a name. //However, IE reports the script as being in 'interactive' //readyState at the time of the define call. useInteractive = true; node.attachEvent('onreadystatechange', context.onScriptLoad); //It would be great to add an error handler here to catch //404s in IE9+. However, onreadystatechange will fire before //the error handler, so that does not help. If addEventListener //is used, then IE will fire error before load, but we cannot //use that pathway given the connect.microsoft.com issue //mentioned above about not doing the 'script execute, //then fire the script load event listener before execute //next script' that other browsers do. //Best hope: IE10 fixes the issues, //and then destroys all installs of IE 6-9. //node.attachEvent('onerror', context.onScriptError); } else { node.addEventListener('load', context.onScriptLoad, false); node.addEventListener('error', context.onScriptError, false); } node.src = url; //For some cache cases in IE 6-8, the script executes before the end //of the appendChild execution, so to tie an anonymous define //call to the module name (which is stored on the node), hold on //to a reference to this node, but clear after the DOM insertion. currentlyAddingScript = node; if (baseElement) { head.insertBefore(node, baseElement); } else { head.appendChild(node); } currentlyAddingScript = null; return node; } else if (isWebWorker) { try { //In a web worker, use importScripts. This is not a very //efficient use of importScripts, importScripts will block until //its script is downloaded and evaluated. However, if web workers //are in play, the expectation that a build has been done so that //only one script needs to be loaded anyway. This may need to be //reevaluated if other use cases become common. importScripts(url); //Account for anonymous modules context.completeLoad(moduleName); } catch (e) { context.onError(makeError('importscripts', 'importScripts failed for ' + moduleName + ' at ' + url, e, [moduleName])); } } }; function getInteractiveScript() { if (interactiveScript && interactiveScript.readyState === 'interactive') { return interactiveScript; } eachReverse(scripts(), function (script) { if (script.readyState === 'interactive') { return (interactiveScript = script); } }); return interactiveScript; } //Look for a data-main script attribute, which could also adjust the baseUrl. if (isBrowser) { //Figure out baseUrl. Get it from the script tag with require.js in it. eachReverse(scripts(), function (script) { //Set the 'head' where we can append children by //using the script's parent. if (!head) { head = script.parentNode; } //Look for a data-main attribute to set main script for the page //to load. If it is there, the path to data main becomes the //baseUrl, if it is not already set. dataMain = script.getAttribute('data-main'); if (dataMain) { //Set final baseUrl if there is not already an explicit one. if (!cfg.baseUrl) { //Pull off the directory of data-main for use as the //baseUrl. src = dataMain.split('/'); mainScript = src.pop(); subPath = src.length ? src.join('/') + '/' : './'; cfg.baseUrl = subPath; dataMain = mainScript; } //Strip off any trailing .js since dataMain is now //like a module name. dataMain = dataMain.replace(jsSuffixRegExp, ''); //Put the data-main script in the files to load. cfg.deps = cfg.deps ? cfg.deps.concat(dataMain) : [dataMain]; return true; } }); } /** * The function that handles definitions of modules. Differs from * require() in that a string for the module should be the first argument, * and the function to execute after dependencies are loaded should * return a value to define the module corresponding to the first argument's * name. */ define = function (name, deps, callback) { var node, context; //Allow for anonymous modules if (typeof name !== 'string') { //Adjust args appropriately callback = deps; deps = name; name = null; } //This module may not have dependencies if (!isArray(deps)) { callback = deps; deps = []; } //If no name, and callback is a function, then figure out if it a //CommonJS thing with dependencies. if (!deps.length && isFunction(callback)) { //Remove comments from the callback string, //look for require calls, and pull them into the dependencies, //but only if there are function args. if (callback.length) { callback .toString() .replace(commentRegExp, '') .replace(cjsRequireRegExp, function (match, dep) { deps.push(dep); }); //May be a CommonJS thing even without require calls, but still //could use exports, and module. Avoid doing exports and module //work though if it just needs require. //REQUIRES the function to expect the CommonJS variables in the //order listed below. deps = (callback.length === 1 ? ['require'] : ['require', 'exports', 'module']).concat(deps); } } //If in IE 6-8 and hit an anonymous define() call, do the interactive //work. if (useInteractive) { node = currentlyAddingScript || getInteractiveScript(); if (node) { if (!name) { name = node.getAttribute('data-requiremodule'); } context = contexts[node.getAttribute('data-requirecontext')]; } } //Always save off evaluating the def call until the script onload handler. //This allows multiple modules to be in a file without prematurely //tracing dependencies, and allows for anonymous module support, //where the module name is not known until the script onload event //occurs. If no context, use the global queue, and get it processed //in the onscript load callback. (context ? context.defQueue : globalDefQueue).push([name, deps, callback]); }; define.amd = { jQuery: true }; /** * Executes the text. Normally just uses eval, but can be modified * to use a better, environment-specific call. Only used for transpiling * loader plugins, not for plain JS modules. * @param {String} text the text to execute/evaluate. */ req.exec = function (text) { /*jslint evil: true */ return eval(text); }; //Set up with config info. req(cfg); }(this)); var components = { "packages": [ { "name": "elfinder", "main": "elfinder-built.js" }, { "name": "jquery", "main": "jquery-built.js" }, { "name": "jquery-ui", "main": "jquery-ui-built.js" } ], "shim": { "jquery-ui": { "deps": [ "jquery" ], "exports": "jQuery" } }, "baseUrl": "components" }; if (typeof require !== "undefined" && require.config) { require.config(components); } else { var require = components; } if (typeof exports !== "undefined" && typeof module !== "undefined") { module.exports = components; } define('elfinder', function (require, exports, module) { /*! * elFinder - file manager for web * Version 2.1.20 (2017-01-11) * http://elfinder.org * * Copyright 2009-2017, Studio 42 * Licensed under a 3-clauses BSD license */ !function(e,t){if("function"==typeof define&&define.amd)define(["jquery","jquery-ui"],t);else if("undefined"!=typeof exports){var n,i;try{n=require("jquery"),i=require("jquery-ui")}catch(a){}module.exports=t(n,i)}else t(e.jQuery,e.jQuery.ui,!0)}(this,function(e,t,n){n=n||!1;var i=function(t,n){var a,r,o,s=this,t=e(t),l=e("
").append(t.contents()),d=t.attr("style"),c=t.attr("id")||"",u="elfinder-"+(c?c:Math.random().toString().substr(2,7)),h="mousedown."+u,p="keydown."+u,f="keypress."+u,m=!0,g=!0,v=["enable","disable","load","open","reload","select","add","remove","change","dblclick","getfile","lockfiles","unlockfiles","selectfiles","unselectfiles","dragstart","dragstop","search","searchend","viewchange"],b="",y={path:"",url:"",tmbUrl:"",disabled:[],separator:"/",archives:[],extract:[],copyOverwrite:!0,uploadOverwrite:!0,uploadMaxSize:0,jpgQuality:100,tmbCrop:!1,tmb:!1},w={},k=[],x={},C={},T=[],z=[],A=[],I=[],S=new s.command(s),U="auto",M=400,O="./sounds/",D=e(document.createElement("audio")).hide().appendTo("body")[0],F=0,E="",P=function(n){var i,a,r,o,l,d,c,u,h={},p={};s.api>=2.1?(s.commandMap=n.options.uiCmdMap&&Object.keys(n.options.uiCmdMap).length?n.options.uiCmdMap:{},E!==JSON.stringify(s.commandMap)&&(E=JSON.stringify(s.commandMap),Object.keys(s.commandMap).length&&(a=s.getUI("contextmenu"),a.data("cmdMaps")||a.data("cmdMaps",{}),i=n.cwd?n.cwd.volumeid:null,i&&!a.data("cmdMaps")[i]&&(a.data("cmdMaps")[i]=s.commandMap)))):s.options.sync=0,n.init?w={}:(u=b,r="elfinder-subtree-loaded "+s.res("class","navexpand"),c=s.res("class","navcollapse"),o=Object.keys(w),l=function(t,n){if(!w[n])return!0;var i="directory"===w[n].mime,a=w[n].phash;(!i||h[a]||!p[a]&&e("#"+s.navHash2Id(w[n].hash)).is(":hidden")&&e("#"+s.navHash2Id(a)).next(".elfinder-navbar-subtree").children().length>100)&&(i||a!==b)&&-1===e.inArray(n,z)?(i&&!h[a]&&(h[a]=!0,e("#"+s.navHash2Id(a)).removeClass(r).next(".elfinder-navbar-subtree").empty()),delete w[n]):i&&(p[a]=!0)},d=function(){o.length&&(e.each(o.splice(0,100),l),o.length&&setTimeout(d,20))},s.trigger("filesgc").one("filesgc",function(){o=[]}),s.one("opendone",function(){u!==b&&(t.data("lazycnt")?s.one("lazydone",d):d())})),s.sorters=[],b=n.cwd.hash,R(n.files),w[b]||R([n.cwd]),s.lastDir(b),s.autoSync()},R=function(t){var n,i,a={name:!0,perm:!0,date:!0,size:!0,kind:!0},r=0===s.sorters.length,o=t.length;for(i=0;o>i;i++)n=t[i],n.name&&n.hash&&n.mime&&(r&&n.phash===b&&(e.each(s.sortRules,function(e){(a[e]||"undefined"!=typeof n[e]||"mode"===e&&"undefined"!=typeof n.perm)&&s.sorters.push(e)}),r=!1),n.isroot&&n.phash&&(s.leafRoots[n.phash]?-1===e.inArray(n.hash,s.leafRoots[n.phash])&&s.leafRoots[n.phash].push(n.hash):s.leafRoots[n.phash]=[n.hash],w[n.phash]&&(w[n.phash].dirs||(w[n.phash].dirs=1),n.ts&&(w[n.phash].ts||0) script[src$="js/elfinder.min.js"],script[src$="js/elfinder.full.js"]:first');s.length?(a=e(""),e("head").append(a),i=s.attr("src").replace(/js\/[^\/]+$/,""),n.loadCss([i+"css/elfinder.min.css",i+"css/theme.css"]),e.isArray(n.options.cssAutoLoad)&&n.loadCss(n.options.cssAutoLoad),o=1e3,r=setInterval(function(){--o>0&&"hidden"!==t.css("visibility")&&(clearInterval(r),a.remove(),n.trigger("cssloaded"))},10)):n.options.cssAutoLoad=!1}(this),this.optionProperties=["icon","csscls","tmbUrl","uiCmdMap","netkey"],n.ui&&(this.options.ui=n.ui),n.commands&&(this.options.commands=n.commands),n.uiOptions&&n.uiOptions.toolbar&&(this.options.uiOptions.toolbar=n.uiOptions.toolbar),n.uiOptions&&n.uiOptions.cwd&&n.uiOptions.cwd.listView&&n.uiOptions.cwd.listView.columns&&(this.options.uiOptions.cwd.listView.columns=n.uiOptions.cwd.listView.columns),n.uiOptions&&n.uiOptions.cwd&&n.uiOptions.cwd.listView&&n.uiOptions.cwd.listView.columnsCustomName&&(this.options.uiOptions.cwd.listView.columnsCustomName=n.uiOptions.cwd.listView.columnsCustomName),N||this.options.enableAlways||2!==e("body").children().length||(this.options.enableAlways=!0),this.isCORS=!1,function(){var t,i=document.createElement("a");i.href=n.url,n.urlUpload&&n.urlUpload!==n.url&&(t=document.createElement("a"),t.href=n.urlUpload),(window.location.host!==i.host||t&&window.location.host!==t.host)&&(s.isCORS=!0,e.isPlainObject(s.options.customHeaders)||(s.options.customHeaders={}),e.isPlainObject(s.options.xhrFields)||(s.options.xhrFields={}),s.options.requestType="post",s.options.customHeaders["X-Requested-With"]="XMLHttpRequest",s.options.xhrFields.withCredentials=!0)}(),e.extend(this.options.contextmenu,n.contextmenu),this.requestType=/^(get|post)$/i.test(this.options.requestType)?this.options.requestType.toLowerCase():"get",this.customData=e.isPlainObject(this.options.customData)?this.options.customData:{},this.customHeaders=e.isPlainObject(this.options.customHeaders)?this.options.customHeaders:{},this.xhrFields=e.isPlainObject(this.options.xhrFields)?this.options.xhrFields:{},this.abortCmdsOnOpen=this.options.abortCmdsOnOpen||["tmb"],this.id=c,this.navPrefix="nav"+(i.prototype.uniqueid?i.prototype.uniqueid:"")+"-",this.cwdPrefix=i.prototype.uniqueid?"cwd"+i.prototype.uniqueid+"-":"",++i.prototype.uniqueid,this.uploadURL=n.urlUpload||n.url,this.namespace=u,this.lang=this.i18[this.options.lang]&&this.i18[this.options.lang].messages?this.options.lang:"en",o="en"==this.lang?this.i18.en:e.extend(!0,{},this.i18.en,this.i18[this.lang]),this.direction=o.direction,this.messages=o.messages,this.dateFormat=this.options.dateFormat||o.dateFormat,this.fancyFormat=this.options.fancyDateFormat||o.fancyDateFormat,this.today=new Date(H.getFullYear(),H.getMonth(),H.getDate()).getTime()/1e3,this.yesterday=this.today-86400,r=this.options.UTCDate?"UTC":"",this.getHours="get"+r+"Hours",this.getMinutes="get"+r+"Minutes",this.getSeconds="get"+r+"Seconds",this.getDate="get"+r+"Date",this.getDay="get"+r+"Day",this.getMonth="get"+r+"Month",this.getFullYear="get"+r+"FullYear",this.cssClass="ui-helper-reset ui-helper-clearfix ui-widget ui-widget-content ui-corner-all elfinder elfinder-"+("rtl"==this.direction?"rtl":"ltr")+(this.UA.Touch?" elfinder-touch"+(this.options.resizable?" touch-punch":""):"")+(this.UA.Mobile?" elfinder-mobile":"")+" "+this.options.cssClass,this.zIndex,this.searchStatus={state:0,query:"",target:"",mime:"",mixed:!1,ininc:!1},this.storage=function(){try{return"localStorage"in window&&null!==window.localStorage?(s.UA.Safari&&(window.localStorage.setItem("elfstoragecheck",1),window.localStorage.removeItem("elfstoragecheck")),s.localStorage):s.cookie}catch(e){return s.cookie}}(),this.viewType=this.storage("view")||this.options.defaultView||"icons",this.sortType=this.storage("sortType")||this.options.sortType||"name",this.sortOrder=this.storage("sortOrder")||this.options.sortOrder||"asc",this.sortStickFolders=this.storage("sortStickFolders"),null===this.sortStickFolders?this.sortStickFolders=!!this.options.sortStickFolders:this.sortStickFolders=!!this.sortStickFolders,this.sortAlsoTreeview=this.storage("sortAlsoTreeview"),null===this.sortAlsoTreeview?this.sortAlsoTreeview=!!this.options.sortAlsoTreeview:this.sortAlsoTreeview=!!this.sortAlsoTreeview,this.sortRules=e.extend(!0,{},this._sortRules,this.options.sortRules),e.each(this.sortRules,function(e,t){"function"!=typeof t&&delete s.sortRules[e]}),this.compare=e.proxy(this.compare,this),this.notifyDelay=this.options.notifyDelay>0?parseInt(this.options.notifyDelay):500,this.draggingUiHelper=null,function(){var n,i,a,r,o=p+"draggable keyup."+u+"draggable";s.draggable={appendTo:t,addClasses:!1,distance:4,revert:!0,refreshPositions:!1,cursor:"crosshair",cursorAt:{left:50,top:47},scroll:!1,start:function(o,l){var d,c,u=l.helper,h=e.map(u.data("files")||[],function(e){return e||null}),p=!1;for(r=t.attr("style"),t.width(t.width()).height(t.height()),n="ltr"===s.direction,i=s.getUI("workzone").data("rectangle"),a=i.top+i.height,s.draggingUiHelper=u,d=h.length;d--;)if(c=h[d],w[c].locked){p=!0,u.data("locked",!0);break}!p&&s.trigger("lockfiles",{files:h}),u.data("autoScrTm",setInterval(function(){u.data("autoScr")&&s.autoScroll[u.data("autoScr")](u.data("autoScrVal"))},50))},drag:function(t,r){var o,s=r.helper;(o=i.top>t.pageY)||at.pageX?s.data("autoScr",(n?"navbar":"cwd")+(o?"Up":"Down")):s.data("autoScr",(n?"cwd":"navbar")+(o?"Up":"Down")),s.data("autoScrVal",Math.pow(o?i.top-t.pageY:t.pageY-a,1.3))):s.data("autoScr")&&s.data("refreshPositions",1).data("autoScr",null),s.data("refreshPositions")&&e(this).elfUiWidgetInstance("draggable")&&(s.data("refreshPositions")>0?(e(this).draggable("option",{refreshPositions:!0,elfRefresh:!0}),s.data("refreshPositions",-1)):(e(this).draggable("option",{refreshPositions:!1,elfRefresh:!1}),s.data("refreshPositions",null)))},stop:function(n,i){var a,l=i.helper;e(document).off(o),e(this).elfUiWidgetInstance("draggable")&&e(this).draggable("option",{refreshPositions:!1}),s.draggingUiHelper=null,s.trigger("focus").trigger("dragstop"),l.data("droped")||(a=e.map(l.data("files")||[],function(e){return e||null}),s.trigger("unlockfiles",{files:a}),s.trigger("selectfiles",{files:a})),s.enable(),t.attr("style",r),l.data("autoScrTm")&&clearInterval(l.data("autoScrTm"))},helper:function(t,n){var i,a,r,l=this.id?e(this):e(this).parents("[id]:first"),d=e('
'),c=function(t){var n,i=t.mime,a=s.tmb(t);return n='
',a&&(n=e(n).addClass(a.className).css("background-image","url('"+a.url+"')").get(0).outerHTML),n};return s.draggingUiHelper&&s.draggingUiHelper.stop(!0,!0),s.trigger("dragstart",{target:l[0],originalEvent:t}),i=l.hasClass(s.res("class","cwdfile"))?s.selected():[s.navId2Hash(l.attr("id"))],d.append(c(w[i[0]])).data("files",i).data("locked",!1).data("droped",!1).data("namespace",u).data("dropover",0),(a=i.length)>1&&d.append(c(w[i[a-1]])+''+a+""),e(document).on(o,function(e){var t=e.shiftKey||e.ctrlKey||e.metaKey;r!==t&&(r=t,d.is(":visible")&&d.data("dropover")&&!d.data("droped")&&(d.toggleClass("elfinder-drag-helper-plus",d.data("locked")?!0:r),s.trigger(r?"unlockfiles":"lockfiles",{files:i,helper:d})))}),d}}}(),this.droppable={greedy:!0,tolerance:"pointer",accept:".elfinder-cwd-file-wrapper,.elfinder-navbar-dir,.elfinder-cwd-file,.elfinder-cwd-filename",hoverClass:this.res("class","adroppable"),classes:{"ui-droppable-hover":this.res("class","adroppable")},autoDisable:!0,drop:function(t,n){var i,a,r,o=e(this),l=e.map(n.helper.data("files")||[],function(e){return e||null}),d=[],c=[],h=[],p=n.helper.hasClass("elfinder-drag-helper-plus"),f="class";if("undefined"==typeof t.button||n.helper.data("namespace")!==u||!s.insideWorkzone(t.pageX,t.pageY))return!1;for(a=o.hasClass(s.res(f,"cwdfile"))?s.cwdId2Hash(o.attr("id")):o.hasClass(s.res(f,"navdir"))?s.navId2Hash(o.attr("id")):b,i=l.length;i--;)r=l[i],r!=a&&w[r].phash!=a?d.push(r):(p&&r!==a&&w[a].write?c:h).push(r);return h.length?!1:(n.helper.data("droped",!0),c.length&&(n.helper.hide(),s.exec("duplicate",c)),void(d.length&&(n.helper.hide(),s.clipboard(d,!p),s.exec("paste",a,void 0,a).always(function(){s.clipboard([]),s.trigger("unlockfiles",{files:l})}),s.trigger("drop",{files:l}))))}},this.enabled=function(){return m&&this.visible()},this.visible=function(){return t[0].elfinder&&t.is(":visible")},this.isRoot=function(e){return!(!e.isroot&&e.phash)},this.root=function(t,n){t=t||b;var i,a;if(!n&&(e.each(s.roots,function(e,n){return 0===t.indexOf(e)?(i=n,!1):void 0}),i))return i;for(i=w[t];i&&i.phash&&(n||!i.isroot);)i=w[i.phash];if(i)return i.hash;for(;a in w&&w.hasOwnProperty(a);)if(i=w[a],!i.phash&&"directory"==!i.mime&&i.read)return i.hash;return""},this.cwd=function(){return w[b]||{}},this.option=function(t,n){var i;return n=n||b,s.optionsByHashes[n]&&"undefined"!=typeof s.optionsByHashes[n][t]?s.optionsByHashes[n][t]:b!==n?(i="",e.each(s.volOptions,function(e,a){return 0===n.indexOf(e)?(i=a[t]||"",!1):void 0}),i):y[t]||""},this.getDisabledCmds=function(t){var n=[];return e.isArray(t)||(t=[t]),e.each(t,function(t,i){var a=s.option("disabled",i);a&&e.each(a,function(t,i){-1===e.inArray(i,n)&&n.push(i)})}),n},this.file=function(e){return e?w[e]:void 0},this.files=function(){return e.extend(!0,{},w)},this.parents=function(e){for(var t,n=[];t=this.file(e);)n.unshift(t.hash),e=t.phash;return n},this.path2array=function(e,t){for(var n,i=[];e;){if(!(n=w[e])||!n.hash){i=[];break}i.unshift(t&&n.i18?n.i18:n.name),e=n.isroot?null:n.phash}return i},this.path=function(t,n,i){var a=w[t]&&w[t].path?w[t].path:this.path2array(t,n).join(y.separator);if(i&&w[t]){i=e.extend({notify:{type:"parents",cnt:1,hideCnt:!0}},i);var r,o=e.Deferred(),l=i.notify,d=!1,c=function(){s.request({data:{cmd:"parents",target:w[t].phash},notify:l,preventFail:!0}).done(u).fail(function(){o.reject()})},u=function(){s.one("parentsdone",function(){a=s.path(t,n),""===a&&d?(d=!1,c()):(l&&(clearTimeout(r),l.cnt=-parseInt(l.cnt||0),s.notify(l)),o.resolve(a))})};return a?o.resolve(a):(s.ui.tree?(l&&(r=setTimeout(function(){s.notify(l)},s.notifyDelay)),d=!0,u(!0)):c(),o)}return a},this.url=function(t){var n,i=w[t];if(!i||!i.read)return"";if("1"==i.url&&this.request({data:{cmd:"url",target:t},preventFail:!0,options:{async:!1}}).done(function(e){i.url=e.url||""}).fail(function(){i.url=""}),i.url)return i.url;if(n=0===i.hash.indexOf(s.cwd().volumeid)?y.url:this.option("url",i.hash))return n+e.map(this.path2array(t),function(e){return encodeURIComponent(e)}).slice(1).join("/");var a=e.extend({},this.customData,{cmd:"file",target:i.hash});return this.oldAPI&&(a.cmd="open",a.current=i.phash),this.options.url+(-1===this.options.url.indexOf("?")?"?":"&")+e.param(a,!0)},this.openUrl=function(t,n){var i=w[t],a="";if(!i||!i.read)return"";if(!n)if(i.url){if(1!=i.url)return i.url}else if(y.url&&0===i.hash.indexOf(s.cwd().volumeid))return y.url+e.map(this.path2array(t),function(e){return encodeURIComponent(e)}).slice(1).join("/");return a=this.options.url,a=a+(-1===a.indexOf("?")?"?":"&")+(this.oldAPI?"cmd=open¤t="+i.phash:"cmd=file")+"&target="+i.hash,n&&(a+="&download=1"),e.each(this.options.customData,function(e,t){a+="&"+encodeURIComponent(e)+"="+encodeURIComponent(t)}),a},this.tmb=function(t){var n,i,a="elfinder-cwd-bgurl",r="";return e.isPlainObject(t)&&(s.searchStatus.state&&0!==t.hash.indexOf(s.cwd().volumeid)?(n=s.option("tmbUrl",t.hash),i=s.option("tmbCrop",t.hash)):(n=y.tmbUrl,i=y.tmbCrop),i&&(a+=" elfinder-cwd-bgurl-crop"),"self"===n&&0===t.mime.indexOf("image/")?(r=s.openUrl(t.hash),a+=" elfinder-cwd-bgself"):(s.oldAPI||n)&&t&&t.tmb&&1!=t.tmb&&(r=n+t.tmb),r)?{url:r,className:a}:!1},this.selected=function(){return k.slice(0)},this.selectedFiles=function(){return e.map(k,function(t){return w[t]?e.extend({},w[t]):null})},this.fileByName=function(e,t){var n;for(n in w)if(w.hasOwnProperty(n)&&w[n].phash==t&&w[n].name==e)return w[n]},this.validResponse=function(e,t){return t.error||this.rules[this.rules[e]?e:"defaults"](t)},this.returnBytes=function(e){var t;return isNaN(e)?(e||(e=""),e=e.replace(/b$/i,""),t=e.charAt(e.length-1).toLowerCase(),e=e.replace(/[tgmk]$/i,""),"t"==t?e=1024*e*1024*1024*1024:"g"==t?e=1024*e*1024*1024:"m"==t?e=1024*e*1024:"k"==t&&(e=1024*e),e=isNaN(e)?0:parseInt(e)):(e=parseInt(e),1>e&&(e=0)),e},this.request=function(t){var n,i,a,r=this,o=this.options,s=e.Deferred(),l=e.extend({},o.customData,{mimes:o.onlyMimes},t.data||t),d=l.cmd,c="open"===d,u=!(t.preventDefault||t.preventFail),h=!(t.preventDefault||t.preventDone),p=e.extend({},t.notify),f=!!t.cancel,m=!!t.raw,g=t.syncOnFail,v=!!t.lazy,w=t.prepare,k=e.extend({url:o.url,async:!0,type:this.requestType,dataType:"json",cache:!1,data:l,headers:this.customHeaders,xhrFields:this.xhrFields},t.options||{}),x=function(e){e.warning&&r.error(e.warning),c&&P(e),r.lazy(function(){e.removed&&e.removed.length&&r.remove(e),e.added&&e.added.length&&r.add(e),e.changed&&e.changed.length&&r.change(e)}).then(function(){return r.lazy(function(){r.trigger(d,e)})}).then(function(){return r.lazy(function(){r.trigger(d+"done")})}).then(function(){e.sync&&r.sync()})},C=function(e,t){var n,i;switch(t){case"abort":n=e.quiet?"":["errConnect","errAbort"];break;case"timeout":n=["errConnect","errTimeout"];break;case"parsererror":n=["errResponse","errDataNotJSON"],e.responseText&&(r.debug("backend-debug",{debug:{phpErrors:[e.responseText]}}),b||e.responseText&&n.push(e.responseText));break;default:if(e.responseText)try{i=JSON.parse(e.responseText),i&&i.error&&(n=i.error)}catch(a){}if(!n)if(403==e.status)n=["errConnect","errAccess","HTTP error "+e.status];else if(404==e.status)n=["errConnect","errNotFound","HTTP error "+e.status];else{if(414==e.status&&"get"===k.type)return k.type="post",void(s.xhr=e=r.transport.send(k).fail(n).done(T));n=e.quiet?"":["errConnect","HTTP error "+e.status]}}r.trigger(d+"done"),s.reject(n,e,t)},T=function(t){if(r.currentReqCmd=d,m)return t&&t.debug&&r.debug("backend-debug",t),s.resolve(t);if(!t)return s.reject(["errResponse","errDataEmpty"],i,t);if(!e.isPlainObject(t))return s.reject(["errResponse","errDataNotJSON"],i,t);if(t.error)return s.reject(t.error,i,t);if(!r.validResponse(d,t))return s.reject("errResponse",i,t);var n=function(){var n=function(n){r.leafRoots[l.target]&&t[n]&&e.each(r.leafRoots[l.target],function(e,i){var a;(a=r.file(i))&&t[n].push(a)})};c?n("files"):"tree"===d&&n("tree"),t=r.normalize(t),r.api||(r.api=t.api||1,"2.0"==r.api&&"undefined"!=typeof t.options.uploadMaxSize&&(r.api="2.1"),r.newAPI=r.api>=2,r.oldAPI=!r.newAPI),t.options&&(y=e.extend({},y,t.options)),t.netDrivers&&(r.netDrivers=t.netDrivers),t.maxTargets&&(r.maxTargets=t.maxTargets),c&&l.init&&(r.uplMaxSize=r.returnBytes(t.uplMaxSize),r.uplMaxFile=t.uplMaxFile?parseInt(t.uplMaxFile):20),"function"==typeof w&&w(t),s.resolve(t),t.debug&&r.debug("backend-debug",t)};v?r.lazy(n):n()},z=function(e){if(r.trigger(d+"done"),"autosync"==e.type){if("stop"!=e.data.action)return}else if(!("unload"==e.type||"destroy"==e.type||"openxhrabort"==e.type||e.data.added&&e.data.added.length))return;"pending"==i.state()&&(i.quiet=!0,i.abort(),"unload"!=e.type&&"destroy"!=e.type&&r.autoSync())},S=function(){if(s.fail(function(e,t,n){r.trigger(d+"fail",n),e&&(u?r.error(e):r.debug("error",r.i18n(e))),g&&r.sync()}),!d)return g=!1,s.reject("errCmdReq");if(r.maxTargets&&l.targets&&l.targets.length>r.maxTargets)return g=!1,s.reject(["errMaxTargets",r.maxTargets]);if(h&&s.done(x),p.type&&p.cnt&&(f&&(p.cancel=s),n=setTimeout(function(){r.notify(p),s.always(function(){p.cnt=-(parseInt(p.cnt)||0),r.notify(p)})},r.notifyDelay),s.always(function(){clearTimeout(n)})),c){for(;a=A.pop();)"pending"==a.state()&&(a.quiet=!0,a.abort());if(b!==l.target)for(;a=I.pop();)"pending"==a.state()&&(a.quiet=!0,a.abort())}return-1!==e.inArray(d,(r.cmdsToAdd+" autosync").split(" "))&&("autosync"!==d&&(r.autoSync("stop"),s.always(function(){r.autoSync()})),r.trigger("openxhrabort")),delete k.preventFail,s.xhr=i=r.transport.send(k).fail(C).done(T),c||l.compare&&"info"===d?(A.unshift(i),l.compare&&r.bind(r.cmdsToAdd+" autosync openxhrabort",z),s.always(function(){var t=e.inArray(i,A);l.compare&&r.unbind(r.cmdsToAdd+" autosync openxhrabort",z),-1!==t&&A.splice(t,1)})):-1!==e.inArray(d,r.abortCmdsOnOpen)&&(I.unshift(i),s.always(function(){var t=e.inArray(i,I);-1!==t&&I.splice(t,1)})),r.bind("unload destroy",z),s.always(function(){r.unbind("unload destroy",z)}),s},U={opts:t,result:!0};return r.trigger("request."+d,U,!0),U.result?"object"==typeof U.result&&U.result.promise?(U.result.done(S).fail(function(){r.trigger(d+"done"),s.reject()}),s):S():(r.trigger(d+"done"),s.reject())},this.diff=function(t,n,i){var a={},r=[],o=[],s=[],l=function(e){for(var t=s.length;t--;)if(s[t].hash==e)return!0};return e.each(t,function(e,t){a[t.hash]=t}),e.each(w,function(e,t){a[e]||n&&t.phash!==n||o.push(e)}),e.each(a,function(t,n){var a=w[t];a?e.each(n,function(t){return i&&-1!==e.inArray(t,i)||n[t]===a[t]?void 0:(s.push(n),!1)}):r.push(n)}),e.each(o,function(t,n){var i=w[n],r=i.phash;r&&"directory"==i.mime&&-1===e.inArray(r,o)&&a[r]&&!l(r)&&s.push(a[r])}),{added:r,removed:o,changed:s}},this.sync=function(t,n){this.autoSync("stop");var i=this,a=function(){var i="",a=0,r=0;return t&&n&&e.each(w,function(e,n){n.phash&&n.phash===t&&(++a,r=Math.max(r,n.ts)),i=a+":"+r}),i},r=a(),o=e.Deferred().done(function(){i.trigger("sync")}),s=[this.request({data:{cmd:"open",reload:1,target:b,tree:!t&&this.ui.tree?1:0,compare:r},preventDefault:!0})],l=function(){for(var e,t=[],n=i.file(i.root(b)),a=n?n.volumeid:null,r=i.cwd().phash;r;)(e=i.file(r))?(0!==r.indexOf(a)&&(i.isRoot(e)||t.push({target:r,cmd:"tree"}),t.push({target:r,cmd:"parents"}),n=i.file(i.root(r)),a=n?n.volumeid:null),r=e.phash):r=null;return t};return t||(b!==this.root()&&s.push(this.request({data:{cmd:"parents",target:b},preventDefault:!0})),e.each(l(),function(e,t){s.push(i.request({data:{cmd:t.cmd,target:t.target},preventDefault:!0}))})),e.when.apply(e,s).fail(function(t,a){n&&-1===e.inArray("errOpen",t)?o.reject(t&&0!=a.status?t:void 0):(o.reject(t),t&&i.request({data:{cmd:"open",target:i.lastDir("")||i.root(),tree:1,init:1},notify:{type:"open",cnt:1,hideCnt:!0}}))}).done(function(e){var n,a,s;if(e.cwd.compare&&r===e.cwd.compare)return o.reject();if(n={tree:[]},a=arguments.length,a>1)for(s=1;a>s;s++)arguments[s].tree&&arguments[s].tree.length&&n.tree.push.apply(n.tree,arguments[s].tree);i.api<2.1&&(n.tree=(n.tree||[]).push(e.cwd)),e=i.normalize(e),n=i.normalize(n);var l=i.diff(e.files.concat(n&&n.tree?n.tree:[]),t);return l.added.push(e.cwd),l.removed.length&&i.remove(l),l.added.length&&i.add(l),l.changed.length&&i.change(l),o.resolve(l)}).always(function(){i.autoSync()}),o},this.upload=function(e){return this.transport.upload(e,this)},this.bind=function(e,t){var n;if("function"==typeof t)for(e=(""+e).toLowerCase().split(/\s+/),n=0;n-1&&a.splice(r,1);return n=null,this},this.trigger=function(t,n,i){var a,r,o,t=t.toLowerCase(),s="open"===t,l=x[t]||[];if(this.debug("event-"+t,n),s&&!i&&(o=JSON.stringify(n)),r=l.length)for(t=e.Event(t),i&&(t.data=n),a=0;r>a;a++)if(l[a]){l[a].length&&(i||(t.data=s?JSON.parse(o):e.extend(!0,{},n)));try{if(l[a](t,this)===!1||t.isDefaultPrevented()){this.debug("event-stoped",t.type);break}}catch(d){window.console&&window.console.log&&window.console.log(d)}}return this},this.getListeners=function(e){return e?x[e.toLowerCase()]:x},this.shortcut=function(t){var n,i,a,r,o;if(this.options.allowShortcuts&&t.pattern&&e.isFunction(t.callback))for(n=t.pattern.toUpperCase().split(/\s+/),r=0;r0?a:a.charCodeAt(0):a>0?a:e.ui.keyCode[a],a&&!C[i]&&(C[i]={keyCode:a,altKey:-1!=e.inArray("ALT",o),ctrlKey:-1!=e.inArray("CTRL",o),shiftKey:-1!=e.inArray("SHIFT",o),type:t.type||"keydown",callback:t.callback,description:t.description,pattern:i});return this},this.shortcuts=function(){var t=[];return e.each(C,function(e,n){t.push([n.pattern,s.i18n(n.description)])}),t},this.clipboard=function(t,n){var i=function(){return e.map(T,function(e){return e.hash})};return void 0!==t&&(T.length&&this.trigger("unlockfiles",{files:i()}),z=[],T=e.map(t||[],function(e){var t=w[e];return t?(z.push(e),{hash:e,phash:t.phash,name:t.name,mime:t.mime,read:t.read,locked:t.locked,cut:!!n}):null}),this.trigger("changeclipboard",{clipboard:T.slice(0,T.length)}),n&&this.trigger("lockfiles",{files:i()})),T.slice(0,T.length)},this.isCommandEnabled=function(t,n){var i,a=s.cwd().volumeid||"";return!n||a&&0===n.indexOf(a)?i=y.disabled:(i=s.option("disabled",n),i||(i=[])),this._commands[t]?-1===e.inArray(t,i):!1},this.exec=function(t,n,i,a){return"open"===t&&((this.searchStatus.state||this.searchStatus.ininc)&&this.trigger("searchend",{noupdate:!0}),this.autoSync("stop")),this._commands[t]&&this.isCommandEnabled(t,a)?this._commands[t].exec(n,i):e.Deferred().reject("No such command")},this.dialog=function(n,i){var a=e("
").append(n).appendTo(t).elfinderdialog(i,this),r=a.closest(".ui-dialog"),o=function(){!a.data("draged")&&a.is(":visible")&&a.elfinderdialog("posInit")};return r.length&&(s.bind("resize",o),r.on("remove",function(){s.unbind("resize",o)})),a},this.toast=function(t){return e('
').appendTo(this.ui.toast).elfindertoast(t||{},this)},this.getUI=function(e){return this.ui[e]||t},this.getCommand=function(e){return void 0===e?this._commands:this._commands[e]},this.resize=function(e,n){t.css("width",e).height(n).trigger("resize"),this.trigger("resize",{width:t.width(),height:t.height()})},this.restoreSize=function(){this.resize(U,M)},this.show=function(){t.show(),this.enable().trigger("show")},this.hide=function(){this.options.enableAlways&&(g=m,m=!1),this.disable().trigger("hide"),t.hide()},this.lazy=function(n,i,a){var r=function(e){var n,i=t.data("lazycnt");e?(n=t.data("lazyrepaint")?!1:a.repaint,i?t.data("lazycnt",++i):t.data("lazycnt",1).addClass("elfinder-processing"),n&&t.data("lazyrepaint",!0).css("display")):i&&i>1?t.data("lazycnt",--i):(n=t.data("lazyrepaint"),t.data("lazycnt",0).removeData("lazyrepaint").removeClass("elfinder-processing"),n&&t.css("display"),s.trigger("lazydone"))},o=e.Deferred();return i=i||0,a=a||{},r(!0),setTimeout(function(){o.resolve(n.call(o)),r(!1)},i),o},this.destroy=function(){t&&t[0].elfinder&&(this.options.syncStart=!1,this.autoSync("forcestop"),this.trigger("destroy").disable(),T=[],k=[],x={},C={},e(window).off("."+u),e(document).off("."+u),s.trigger=function(){},t.off(),t.removeData(),t.empty(),t[0].elfinder=null,e(D).remove(),t.append(l.contents()).removeClass(this.cssClass).attr("style",d))},this.autoSync=function(t){var n;if(s.options.sync>=1e3){if(a&&(clearTimeout(a),a=null,s.trigger("autosync",{action:"stop"})),"stop"===t?++F:F=Math.max(0,--F),F||"forcestop"===t||!s.options.syncStart)return;n=function(t){var i;y.syncMinMs&&(t||a)&&(t&&s.trigger("autosync",{action:"start"}),i=Math.max(s.options.sync,y.syncMinMs),a&&clearTimeout(a),a=setTimeout(function(){var t,r=!0,o=b;y.syncChkAsTs&&(t=w[o].ts)?s.request({data:{cmd:"info",targets:[o],compare:t,reload:1},preventDefault:!0}).done(function(e){var i;r=!0,e.compare&&(i=e.compare,i==t&&(r=!1)),r?s.sync(o).always(function(){i&&(w[o].ts=i),n()}):n()}).fail(function(t,r){t&&0!=r.status?(s.error(t),-1!==e.inArray("errOpen",t)&&s.request({data:{cmd:"open",target:s.lastDir("")||s.root(),tree:1,init:1},notify:{type:"open",cnt:1,hideCnt:!0}})):a=setTimeout(function(){n()},i)}):s.sync(b,!0).always(function(){n()})},i))},n(!0)}},this.insideWorkzone=function(e,t,n){var i=this.getUI("workzone").data("rectangle");return n=n||1,!(ei.left+i.width+n||ti.top+i.height+n)},this.toFront=function(n){var i=t.children(":last");n=e(n),i.get(0)!==n.get(0)&&i.after(n)},this.getMaximizeCss=function(){return{width:"100%",height:"100%",margin:0,padding:0,top:0,left:0,display:"block",position:"fixed",zIndex:Math.max(s.zIndex?s.zIndex+1:0,1e3)}},function(){N&&s.UA.Fullscreen&&(s.UA.Fullscreen=!1,q&&"undefined"!=typeof q.attr("allowfullscreen")&&(s.UA.Fullscreen=!0));var n,i,a,r="elfinder-fullscreen",o="elfinder-fullscreen-native",l=function(){var n=0,i=0;e.each(t.children(".ui-dialog,.ui-draggable"),function(t,a){var r=e(a),o=r.position();o.top<0&&(r.css("top",n),n+=20),o.left<0&&(r.css("left",i),i+=20)})},d=s.UA.Fullscreen?{fullElm:function(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||null},exitFull:function(){return document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen?document.msExitFullscreen():void 0},toFull:function(e){return e.requestFullscreen?e.requestFullscreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.msRequestFullscreen?e.msRequestFullscreen():!1}}:{fullElm:function(){var e;return t.hasClass(r)?t.get(0):(e=t.find("."+r),e.length?e.get(0):null)},exitFull:function(){var t;e(window).off("resize."+u,h),void 0!==i&&e("body").css("overflow",i),i=void 0,n&&(t=n.elm,c(t),e(t).trigger("resize",{fullscreen:"off"})),e(window).trigger("resize")},toFull:function(t){return i=e("body").css("overflow")||"",e("body").css("overflow","hidden"),e(t).css(s.getMaximizeCss()).addClass(r).trigger("resize",{fullscreen:"on"}),l(),e(window).on("resize."+u,h).trigger("resize"),!0}},c=function(t){n&&n.elm==t&&(e(t).removeClass(r+" "+o).attr("style",n.style),n=null)},h=function(t){var n;t.target===window&&(a&&clearTimeout(a),a=setTimeout(function(){(n=d.fullElm())&&e(n).trigger("resize",{fullscreen:"on"})},100))};e(document).on("fullscreenchange."+u+" webkitfullscreenchange."+u+" mozfullscreenchange."+u+" MSFullscreenChange."+u,function(t){if(s.UA.Fullscreen){var i=d.fullElm(),p=e(window);a&&clearTimeout(a),null===i?(p.off("resize."+u,h),n&&(i=n.elm,c(i),e(i).trigger("resize",{fullscreen:"off"}))):(e(i).addClass(r+" "+o).attr("style","width:100%; height:100%; margin:0; padding:0;").trigger("resize",{fullscreen:"on"}),p.on("resize."+u,h),l()),p.trigger("resize")}}),s.toggleFullscreen=function(t,i){var a=e(t).get(0),r=null;if(r=d.fullElm()){if(r==a){if(i===!0)return r}else if(i===!1)return r;return d.exitFull(),null}return i===!1?null:(n={elm:a,style:e(a).attr("style")},d.toFull(a)!==!1?a:(n=null,null))}}(),function(){var t,n="elfinder-maximized",i=function(e){if(e.target===window&&e.data&&e.data.elm){var n=e.data.elm;t&&clearTimeout(t),t=setTimeout(function(){n.trigger("resize",{maximize:"on"})},100)}},a=function(t){e(window).off("resize."+u,i),e("body").css("overflow",t.data("bodyOvf")),t.removeClass(n).attr("style",t.data("orgStyle")).removeData("bodyOvf").removeData("orgStyle"),t.trigger("resize",{maximize:"off"})},r=function(t){t.data("bodyOvf",e("body").css("overflow")||"").data("orgStyle",t.attr("style")).addClass(n).css(s.getMaximizeCss()),e("body").css("overflow","hidden"),e(window).on("resize."+u,{elm:t},i).trigger("resize")};s.toggleMaximize=function(t,i){var o=e(t),s=o.hasClass(n);if(s){if(i===!0)return;a(o)}else{if(i===!1)return;r(o)}}}(),e.fn.selectable&&e.fn.draggable&&e.fn.droppable?t.length?this.options.url?(e.extend(e.ui.keyCode,{F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,CONTEXTMENU:93}),this.dragUpload=!1,this.xhrUpload=("undefined"!=typeof XMLHttpRequestUpload||"undefined"!=typeof XMLHttpRequestEventTarget)&&"undefined"!=typeof File&&"undefined"!=typeof FormData,this.transport={},"object"==typeof this.options.transport&&(this.transport=this.options.transport,"function"==typeof this.transport.init&&this.transport.init(this)),"function"!=typeof this.transport.send&&(this.transport.send=function(t){ return e.ajax(t)}),"iframe"==this.transport.upload?this.transport.upload=e.proxy(this.uploads.iframe,this):"function"==typeof this.transport.upload?this.dragUpload=!!this.options.dragUploadAllow:this.xhrUpload&&this.options.dragUploadAllow?(this.transport.upload=e.proxy(this.uploads.xhr,this),this.dragUpload=!0):this.transport.upload=e.proxy(this.uploads.iframe,this),this.decodeRawString=e.isFunction(this.options.rawStringDecoder)?this.options.rawStringDecoder:function(e){var t=function(e){var t,n,i;for(t=0,n=e.length,i=[];n>t;t++)i.push(e.charCodeAt(t));return i},n=function(e){var n,i,a,r=[];for("string"==typeof e&&(e=t(e)),n=0,i=e.length;a=e[n],i>n;n++)a>=55296&&56319>=a?r.push((1023&a)+64<<10|1023&e[++n]):r.push(a);return r},i=function(e){var t,n,i,a,r=String.fromCharCode;for(t=0,n=e.length,a="";i=e[t],n>t;t++)a+=127>=i?r(i):223>=i&&i>=194?r((31&i)<<6|63&e[++t]):239>=i&&i>=224?r((15&i)<<12|(63&e[++t])<<6|63&e[++t]):247>=i&&i>=240?r(55296|((7&i)<<8|(63&e[++t])<<2|e[++t]>>>4&3)-64,56320|(15&e[t++])<<6|63&e[t]):r(65533);return a};return i(n(e))},this.error=function(){var e=arguments[0],t=arguments[1]||null;return 1==arguments.length&&"function"==typeof e?s.bind("error",e):e===!0?this:s.trigger("error",{error:e,opts:t})},e.each(v,function(t,n){s[n]=function(){var t=arguments[0];return 1==arguments.length&&"function"==typeof t?s.bind(n,t):s.trigger(n,e.isPlainObject(t)?t:{})}}),this.enable(function(){!m&&s.visible()&&s.ui.overlay.is(":hidden")&&!t.children(".elfinder-dialog").find("."+s.res("class","editing")).length&&(m=!0,document.activeElement&&document.activeElement.blur(),t.removeClass("elfinder-disabled"))}).disable(function(){g=m,m=!1,t.addClass("elfinder-disabled")}).open(function(){k=[]}).select(function(t){var n=0,i=[];k=e.map(t.data.selected||t.data.value||[],function(e){return i.length||s.maxTargets&&++n>s.maxTargets?(i.push(e),null):w[e]?e:null}),i.length&&(s.trigger("unselectfiles",{files:i,inselect:!0}),s.toast({mode:"warning",msg:s.i18n(["errMaxTargets",s.maxTargets])}))}).error(function(t){var n={cssClass:"elfinder-dialog-error",title:s.i18n(s.i18n("error")),resizable:!1,destroyOnClose:!0,buttons:{}};n.buttons[s.i18n(s.i18n("btnClose"))]=function(){e(this).elfinderdialog("close")},t.data.opts&&e.isPlainObject(t.data.opts)&&e.extend(n,t.data.opts),s.dialog(''+s.i18n(t.data.error),n)}).bind("tree parents",function(e){R(e.data.tree||[])}).bind("tmb",function(t){e.each(t.data.images||[],function(e,t){w[e]&&(w[e].tmb=t)})}).add(function(e){R(e.data.added||[])}).change(function(t){e.each(t.data.changed||[],function(t,n){var i=n.hash;w[i]&&e.each(["locked","hidden","width","height"],function(e,t){w[i][t]&&!n[t]&&delete w[i][t]}),w[i]=w[i]?e.extend(w[i],n):n})}).remove(function(t){var n=t.data.removed||[],i=n.length,a={},r=function(t){var n=w[t];n&&("directory"===n.mime&&(a[t]&&delete s.roots[a[t]],e.each(w,function(e,n){n.phash==t&&r(e)})),delete w[t])};for(e.each(s.roots,function(e,t){a[t]=e});i--;)r(n[i])}).bind("searchstart",function(t){e.extend(s.searchStatus,t.data),s.searchStatus.state=1}).bind("search",function(e){s.searchStatus.state=2,R(e.data.files||[])}).bind("searchend",function(){s.searchStatus.state=0,s.searchStatus.mixed=!1}),!0===this.options.sound&&this.bind("rm",function(t){var n=D.canPlayType&&D.canPlayType('audio/wav; codecs="1"');n&&""!=n&&"no"!=n&&e(D).html('')[0].play()}),e.each(this.options.handlers,function(e,t){s.bind(e,t)}),this.history=new this.history(this),this.commands.getfile&&("function"==typeof this.options.getFileCallback?(this.bind("dblclick",function(e){e.preventDefault(),s.exec("getfile").fail(function(){s.exec("open")})}),this.shortcut({pattern:"enter",description:this.i18n("cmdgetfile"),callback:function(){s.exec("getfile").fail(function(){s.exec("mac"==s.OS?"rename":"open")})}}).shortcut({pattern:"ctrl+enter",description:this.i18n("mac"==this.OS?"cmdrename":"cmdopen"),callback:function(){s.exec("mac"==s.OS?"rename":"open")}})):this.options.getFileCallback=null),this.roots={},this.leafRoots={},this._commands={},e.isArray(this.options.commands)||(this.options.commands=[]),-1!==e.inArray("*",this.options.commands)&&(this.options.commands=Object.keys(this.commands)),e.each(this.commands,function(t,n){var i,a,r=e.extend({},n.prototype);if(e.isFunction(n)&&!s._commands[t]&&(n.prototype.forceLoad||-1!==e.inArray(t,s.options.commands))){if(i=n.prototype.extendsCmd||""){if(!e.isFunction(s.commands[i]))return!0;n.prototype=e.extend({},S,new s.commands[i],n.prototype)}else n.prototype=e.extend({},S,n.prototype);s._commands[t]=new n,n.prototype=r,a=s.options.commandsOptions[t]||{},i&&s.options.commandsOptions[i]&&(a=e.extend(!0,{},s.options.commandsOptions[i],a)),s._commands[t].setup(t,a),s._commands[t].linkedCmds.length&&e.each(s._commands[t].linkedCmds,function(t,n){var i=s.commands[n];e.isFunction(i)&&!s._commands[n]&&(i.prototype=S,s._commands[n]=new i,s._commands[n].setup(n,s.options.commandsOptions[n]||{}))})}}),this.commandMap={},this.volOptions={},this.optionsByHashes={},t.addClass(this.cssClass).on(h,function(){!m&&s.enable()}),this.ui={workzone:e("
").appendTo(t).elfinderworkzone(this),navbar:e("
").appendTo(t).elfindernavbar(this,this.options.uiOptions.navbar||{}),contextmenu:e("
").appendTo(t).elfindercontextmenu(this),overlay:e("
").appendTo(t).elfinderoverlay({show:function(){s.disable()},hide:function(){g&&s.enable()}}),cwd:e("
").appendTo(t).elfindercwd(this,this.options.uiOptions.cwd||{}),notify:this.dialog("",{cssClass:"elfinder-dialog-notify",position:this.options.notifyDialog.position,absolute:!0,resizable:!1,autoOpen:!1,closeOnEscape:!1,title:" ",width:parseInt(this.options.notifyDialog.width)}),statusbar:e('
').hide().appendTo(t),toast:e('
').appendTo(t),bottomtray:e('
').appendTo(t)},this.uiAutoHide=[],this.one("open",function(){s.uiAutoHide.length&&setTimeout(function(){s.trigger("uiautohide")},500)}),this.bind("uiautohide",function(){s.uiAutoHide.length&&s.uiAutoHide.shift()()}),e.each(this.options.ui||[],function(n,i){var a="elfinder"+i,r=s.options.uiOptions[i]||{};!s.ui[i]&&e.fn[a]&&(s.ui[i]=e("<"+(r.tag||"div")+"/>").appendTo(t),s.ui[i][a](s,r))}),t[0].elfinder=this,this.options.resizable&&e.fn.resizable&&t.resizable({resize:function(e,t){s.resize(t.size.width,t.size.height)},handles:"se",minWidth:300,minHeight:200}),this.options.width&&(U=this.options.width),this.options.height&&(M=parseInt(this.options.height)),this.options.soundPath&&(O=this.options.soundPath.replace(/\/+$/,"")+"/"),s.resize(U,M),e(document).on("click."+u,function(n){m&&!s.options.enableAlways&&!e(n.target).closest(t).length&&s.disable()}).on(p+" "+f,j),s.options.useBrowserHistory&&e(window).on("popstate."+u,function(t){var n=t.originalEvent.state&&t.originalEvent.state.thash;n&&!e.isEmptyObject(s.files())&&s.request({data:{cmd:"open",target:n,onhistory:1},notify:{type:"open",cnt:1,hideCnt:!0},syncOnFail:!0})}),function(){var n;e(window).on("resize."+u,function(e){e.target===this&&(n&&clearTimeout(n),n=setTimeout(function(){s.trigger("resize",{width:t.width(),height:t.height()})},100))}).on("beforeunload."+u,function(n){var i,a;return t.is(":visible")&&(s.ui.notify.children().length&&-1!==e.inArray("hasNotifyDialog",s.options.windowCloseConfirm)?i=s.i18n("ntfsmth"):t.find("."+s.res("class","editing")).length&&-1!==e.inArray("editingFile",s.options.windowCloseConfirm)?i=s.i18n("editingFile"):(a=Object.keys(s.selected()).length)&&-1!==e.inArray("hasSelectedItem",s.options.windowCloseConfirm)?i=s.i18n("hasSelected",""+a):(a=Object.keys(s.clipboard()).length)&&-1!==e.inArray("hasClipboardData",s.options.windowCloseConfirm)&&(i=s.i18n("hasClipboard",""+a)),i)?(n.returnValue=i,i):void s.trigger("unload")})}(),e(window).on("message."+u,function(e){var t,n,i=e.originalEvent||null;if(i&&0===s.uploadURL.indexOf(i.origin))try{t=JSON.parse(i.data),n=t.data||null,n&&(n.error?(t.bind&&s.trigger(t.bind+"fail",n),s.error(n.error)):(n.warning&&s.error(n.warning),n.removed&&n.removed.length&&s.remove(n),n.added&&n.added.length&&s.add(n),n.changed&&n.changed.length&&s.change(n),t.bind&&(s.trigger(t.bind,n),s.trigger(t.bind+"done")),n.sync&&s.sync()))}catch(e){s.sync()}}),s.options.enableAlways?(e(window).on("focus."+u,function(e){e.target===this&&s.enable()}),N&&e(window.top).on("focus."+u,function(){!s.enable()||q&&!q.is(":visible")||setTimeout(function(){e(window).focus()},10)})):N&&e(window).on("blur."+u,function(e){m&&e.target===this&&s.disable()}),function(){var e=s.getUI("navbar"),t=s.getUI("cwd").parent();s.autoScroll={navbarUp:function(t){e.scrollTop(Math.max(0,e.scrollTop()-t))},navbarDown:function(t){e.scrollTop(e.scrollTop()+t)},cwdUp:function(e){t.scrollTop(Math.max(0,t.scrollTop()-e))},cwdDown:function(e){t.scrollTop(t.scrollTop()+e)}}}(),s.dragUpload&&!function(){var n,i,a=function(t){return"TEXTAREA"!==t.target.nodeName&&"INPUT"!==t.target.nodeName&&0===e(t.target).closest("div.ui-dialog-content").length},r="native-drag-enter",o="native-drag-disable",l="class",d=s.res(l,"navdir"),u=(s.res(l,"droppable"),s.res(l,"adroppable"),s.res(l,"navarrow"),s.res(l,"adroppable")),h=s.getUI("workzone"),p="ltr"===s.direction,f=function(){i&&clearTimeout(i),i=null};t.on("dragenter",function(e){f(),a(e)&&(e.preventDefault(),e.stopPropagation(),n=h.data("rectangle"))}).on("dragleave",function(e){f(),a(e)&&(e.preventDefault(),e.stopPropagation())}).on("dragover",function(e){var t;a(e)?(e.preventDefault(),e.stopPropagation(),e.originalEvent.dataTransfer.dropEffect="none",i||(i=setTimeout(function(){var a,r=n.top+n.height;((t=e.pageYr)&&(a=n.cwdEdge>e.pageX?(p?"navbar":"cwd")+(t?"Up":"Down"):(p?"cwd":"navbar")+(t?"Up":"Down"),s.autoScroll[a](Math.pow(t?n.top-e.pageY:e.pageY-r,1.3))),i=null},20))):f()}).on("drop",function(e){f(),a(e)&&(e.stopPropagation(),e.preventDefault())}),t.on("dragenter",".native-droppable",function(t){if(t.originalEvent.dataTransfer){var n,i=e(t.currentTarget),a=t.currentTarget.id||null,l=null;if(!a){l=s.cwd(),i.data(o,!1);try{e.each(t.originalEvent.dataTransfer.types,function(e,t){"elfinderfrom:"===t.substr(0,13)&&(n=t.substr(13).toLowerCase())})}catch(t){}}l&&(!l.write||n&&n===(window.location.href+l.hash).toLowerCase())?i.data(o,!0):(t.preventDefault(),t.stopPropagation(),i.data(r,!0),i.addClass(u))}}).on("dragleave",".native-droppable",function(t){if(t.originalEvent.dataTransfer){var n=e(t.currentTarget);t.preventDefault(),t.stopPropagation(),n.data(r)?n.data(r,!1):n.removeClass(u)}}).on("dragover",".native-droppable",function(t){if(t.originalEvent.dataTransfer){var n=e(t.currentTarget);t.preventDefault(),t.stopPropagation(),t.originalEvent.dataTransfer.dropEffect=n.data(o)?"none":"copy",n.data(r,!1)}}).on("drop",".native-droppable",function(t){if(t.originalEvent&&t.originalEvent.dataTransfer){var n=e(t.currentTarget);t.preventDefault(),t.stopPropagation(),n.removeClass(u),c=t.currentTarget.id?n.hasClass(d)?s.navId2Hash(t.currentTarget.id):s.cwdId2Hash(t.currentTarget.id):s.cwd().hash,t.originalEvent._target=c,s.exec("upload",{dropEvt:t.originalEvent,target:c},void 0,c)}})}(),s.UA.Touch&&!function(){var n,i,a,r,o,l,d,c,h=s.getUI("navbar"),p=s.getUI("toolbar"),f=function(e){e.preventDefault()},m=function(){e(document).off("touchmove",f)},g=50;t.on("touchstart touchmove touchend",function(v){if("touchend"===v.type)return n=!1,i=!1,void m();var b,y,w,k,x,C,T=v.originalEvent.touches||[{}],z=T[0].pageX||null,A=T[0].pageY||null,I="ltr"===s.direction;null===z||null===A||"touchstart"===v.type&&T.length>1||("touchstart"===v.type?(a=t.offset(),r=t.width(),h&&(n=!1,h.is(":hidden")?(c||(c=Math.max(50,r/10)),(I?z-a.left:r+a.left-z)a.left+r-l&&y+h.scrollLeft()-5<=l,w?(c=Math.max(50,r/10),n=z):n=!1)),p&&(d=p.height(),o=a.top,A-o<(p.is(":hidden")?g:d+30)?(i=A,e(document).on("touchmove."+u,f),setTimeout(function(){m()},500)):i=!1)):(h&&n!==!1&&(b=(I?n>z:z>n)?"navhide":"navshow",k=Math.abs(n-z),("navhide"===b&&k>.6*l||k>("navhide"===b?l/3:45)&&("navshow"===b||(I?za.left+r-20)))&&(s.getUI("navbar").trigger(b,{handleW:c}),n=!1)),p&&i!==!1&&(x=p.offset().top,Math.abs(i-A)>Math.min(45,d/3)&&(C=i>A?"slideUp":"slideDown",("slideDown"===C||x+20>A)&&(p.is("slideDown"===C?":hidden":":visible")&&(p.stop(!0,!0).trigger("toggle",{duration:100,handleH:g}),m()),i=!1)))))})}(),N&&t.on("click",function(t){e(window).focus()}),this.options.enableByMouseOver&&t.on("mouseenter",function(t){N&&e(window).focus(),!s.enabled()&&s.enable()}),this.options.cssAutoLoad||this.trigger("cssloaded"),void this.trigger("init").request({data:{cmd:"open",target:s.startDir(),init:1,tree:this.ui.tree?1:0},preventDone:!0,notify:{type:"open",cnt:1,hideCnt:!0},freeze:!0}).fail(function(){s.trigger("fail").disable().lastDir(""),x={},C={},e(document).add(t).off("."+u),s.trigger=function(){}}).done(function(n){var i=t.css("z-index");i&&"auto"!==i&&"inherit"!==i?s.zIndex=i:t.parents().each(function(t,n){var i=e(n).css("z-index");return"auto"!==i&&"inherit"!==i&&(i=parseInt(i))?(s.zIndex=i,!1):void 0}),s.load().debug("api",s.api),t.trigger("resize"),P(n),s.trigger("open",n),N&&s.options.enableAlways&&e(window).focus()})):alert(this.i18n("errURL")):alert(this.i18n("errNode")):alert(this.i18n("errJqui"))};("undefined"==typeof n||n)&&(window.elFinder=i),i.prototype={uniqueid:0,res:function(e,t){return this.resources[e]&&this.resources[e][t]},OS:-1!==navigator.userAgent.indexOf("Mac")?"mac":-1!==navigator.userAgent.indexOf("Win")?"win":"other",UA:function(){var e=!document.uniqueID&&!window.opera&&!window.sidebar&&window.localStorage&&"WebkitAppearance"in document.documentElement.style;return{ltIE6:"undefined"==typeof window.addEventListener&&"undefined"==typeof document.documentElement.style.maxHeight,ltIE7:"undefined"==typeof window.addEventListener&&"undefined"==typeof document.querySelectorAll,ltIE8:"undefined"==typeof window.addEventListener&&"undefined"==typeof document.getElementsByClassName,IE:document.uniqueID,Firefox:window.sidebar,Opera:window.opera,Webkit:e,Chrome:e&&window.chrome,Safari:e&&!window.chrome,Mobile:"undefined"!=typeof window.orientation,Touch:"undefined"!=typeof window.ontouchstart,iOS:navigator.platform.match(/^iP(?:[ao]d|hone)/),Fullscreen:"undefined"!=typeof(document.exitFullscreen||document.webkitExitFullscreen||document.mozCancelFullScreen||document.msExitFullscreen)}}(),currentReqCmd:"",i18:{en:{translator:"",language:"English",direction:"ltr",dateFormat:"d.m.Y H:i",fancyDateFormat:"$1 H:i",messages:{}},months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["msJan","msFeb","msMar","msApr","msMay","msJun","msJul","msAug","msSep","msOct","msNov","msDec"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],daysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]},kinds:{unknown:"Unknown",directory:"Folder",symlink:"Alias","symlink-broken":"AliasBroken","application/x-empty":"TextPlain","application/postscript":"Postscript","application/vnd.ms-office":"MsOffice","application/msword":"MsWord","application/vnd.ms-word":"MsWord","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"MsWord","application/vnd.ms-word.document.macroEnabled.12":"MsWord","application/vnd.openxmlformats-officedocument.wordprocessingml.template":"MsWord","application/vnd.ms-word.template.macroEnabled.12":"MsWord","application/vnd.ms-excel":"MsExcel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"MsExcel","application/vnd.ms-excel.sheet.macroEnabled.12":"MsExcel","application/vnd.openxmlformats-officedocument.spreadsheetml.template":"MsExcel","application/vnd.ms-excel.template.macroEnabled.12":"MsExcel","application/vnd.ms-excel.sheet.binary.macroEnabled.12":"MsExcel","application/vnd.ms-excel.addin.macroEnabled.12":"MsExcel","application/vnd.ms-powerpoint":"MsPP","application/vnd.openxmlformats-officedocument.presentationml.presentation":"MsPP","application/vnd.ms-powerpoint.presentation.macroEnabled.12":"MsPP","application/vnd.openxmlformats-officedocument.presentationml.slideshow":"MsPP","application/vnd.ms-powerpoint.slideshow.macroEnabled.12":"MsPP","application/vnd.openxmlformats-officedocument.presentationml.template":"MsPP","application/vnd.ms-powerpoint.template.macroEnabled.12":"MsPP","application/vnd.ms-powerpoint.addin.macroEnabled.12":"MsPP","application/vnd.openxmlformats-officedocument.presentationml.slide":"MsPP","application/vnd.ms-powerpoint.slide.macroEnabled.12":"MsPP","application/pdf":"PDF","application/xml":"XML","application/vnd.oasis.opendocument.text":"OO","application/vnd.oasis.opendocument.text-template":"OO","application/vnd.oasis.opendocument.text-web":"OO","application/vnd.oasis.opendocument.text-master":"OO","application/vnd.oasis.opendocument.graphics":"OO","application/vnd.oasis.opendocument.graphics-template":"OO","application/vnd.oasis.opendocument.presentation":"OO","application/vnd.oasis.opendocument.presentation-template":"OO","application/vnd.oasis.opendocument.spreadsheet":"OO","application/vnd.oasis.opendocument.spreadsheet-template":"OO","application/vnd.oasis.opendocument.chart":"OO","application/vnd.oasis.opendocument.formula":"OO","application/vnd.oasis.opendocument.database":"OO","application/vnd.oasis.opendocument.image":"OO","application/vnd.openofficeorg.extension":"OO","application/x-shockwave-flash":"AppFlash","application/flash-video":"Flash video","application/x-bittorrent":"Torrent","application/javascript":"JS","application/rtf":"RTF","application/rtfd":"RTF","application/x-font-ttf":"TTF","application/x-font-otf":"OTF","application/x-rpm":"RPM","application/x-web-config":"TextPlain","application/xhtml+xml":"HTML","application/docbook+xml":"DOCBOOK","application/x-awk":"AWK","application/x-gzip":"GZIP","application/x-bzip2":"BZIP","application/x-xz":"XZ","application/zip":"ZIP","application/x-zip":"ZIP","application/x-rar":"RAR","application/x-tar":"TAR","application/x-7z-compressed":"7z","application/x-jar":"JAR","text/plain":"TextPlain","text/x-php":"PHP","text/html":"HTML","text/javascript":"JS","text/css":"CSS","text/rtf":"RTF","text/rtfd":"RTF","text/x-c":"C","text/x-csrc":"C","text/x-chdr":"CHeader","text/x-c++":"CPP","text/x-c++src":"CPP","text/x-c++hdr":"CPPHeader","text/x-shellscript":"Shell","application/x-csh":"Shell","text/x-python":"Python","text/x-java":"Java","text/x-java-source":"Java","text/x-ruby":"Ruby","text/x-perl":"Perl","text/x-sql":"SQL","text/xml":"XML","text/x-comma-separated-values":"CSV","text/x-markdown":"Markdown","image/x-ms-bmp":"BMP","image/jpeg":"JPEG","image/gif":"GIF","image/png":"PNG","image/tiff":"TIFF","image/x-targa":"TGA","image/vnd.adobe.photoshop":"PSD","image/xbm":"XBITMAP","image/pxm":"PXM","audio/mpeg":"AudioMPEG","audio/midi":"AudioMIDI","audio/ogg":"AudioOGG","audio/mp4":"AudioMPEG4","audio/x-m4a":"AudioMPEG4","audio/wav":"AudioWAV","audio/x-mp3-playlist":"AudioPlaylist","video/x-dv":"VideoDV","video/mp4":"VideoMPEG4","video/mpeg":"VideoMPEG","video/x-msvideo":"VideoAVI","video/quicktime":"VideoMOV","video/x-ms-wmv":"VideoWM","video/x-flv":"VideoFlash","video/x-matroska":"VideoMKV","video/ogg":"VideoOGG"},rules:{defaults:function(t){return!(!t||t.added&&!e.isArray(t.added)||t.removed&&!e.isArray(t.removed)||t.changed&&!e.isArray(t.changed))},open:function(t){return t&&t.cwd&&t.files&&e.isPlainObject(t.cwd)&&e.isArray(t.files)},tree:function(t){return t&&t.tree&&e.isArray(t.tree)},parents:function(t){return t&&t.tree&&e.isArray(t.tree)},tmb:function(t){return t&&t.images&&(e.isPlainObject(t.images)||e.isArray(t.images))},upload:function(t){return t&&(e.isPlainObject(t.added)||e.isArray(t.added))},search:function(t){return t&&t.files&&e.isArray(t.files)}},commands:{},cmdsToAdd:"archive duplicate extract mkdir mkfile paste rm upload",parseUploadData:function(t){var n;if(!e.trim(t))return{error:["errResponse","errDataEmpty"]};try{n=JSON.parse(t)}catch(i){return{error:["errResponse","errDataNotJSON"]}}return this.validResponse("upload",n)?(n=this.normalize(n),n.removed=e.merge(n.removed||[],e.map(n.added||[],function(e){return e.hash})),n):{error:["errResponse"]}},iframeCnt:0,uploads:{xhrUploading:!1,checkExists:function(t,n,i){var a,r,o=e.Deferred(),s=function(){for(var e=t.length;--e>-1;)t[e]._remove=!0},l=function(){var l=[],d={},c=[],u=[],h=function(e){var n=e==u.length-1,a={title:i.i18n("cmdupload"),text:["errExists",u[e].name,"confirmRepl"],all:!n,accept:{label:"btnYes",callback:function(t){n||t?o.resolve(l,d):h(++e)}},reject:{label:"btnNo",callback:function(i){var a;if(i)for(a=u.length;e0&&delete a.reject,i.confirm(a)};return i.file(n).read?(a=e.map(t,function(e,t){return e.name?{i:t,name:e.name}:null}),r=e.map(a,function(e){return e.name}),void i.request({data:{cmd:"ls",target:n,intersect:r},notify:{type:"preupload",cnt:1,hideCnt:!0},preventFail:!0}).done(function(t){var r,l;t&&(t.error?s():i.options.overwriteUploadConfirm&&!i.UA.iOS&&i.option("uploadOverwrite",n)&&t.list&&(e.isArray(t.list)?c=t.list||[]:(r=[],c=e.map(t.list,function(e){return"string"==typeof e?e:(r=r.concat(e),null)}),r.length&&(c=c.concat(r)),d=t.list),u=e.map(a,function(t){return-1!==e.inArray(t.name,c)?t:null}),c.length&&n==i.cwd().hash&&(l=e.map(i.files(),function(e){return e.phash==n?e.name:null}),e.map(c,function(t){return-1===e.inArray(t,l)?!0:null}).length&&i.sync()))),u.length>0?h(0):o.resolve([])}).fail(function(e){s(),o.resolve([]),e&&i.error(e)})):void o.resolve([])};return i.api>=2.1&&"object"==typeof t[0]?(l(),o):o.resolve([])},checkFile:function(t,n,i){if(t.checked||"files"==t.type)return t.files;if("data"==t.type){var a,r=e.Deferred(),o=[],s=[],l=0,d=[],c=function(e){var t,i,a,r=[],u=function(e){return Array.prototype.slice.call(e||[],0)},h=n.options.folderUploadExclude[n.OS]||null;a=e.length;for(var p=0;a>p;p++)if(i=e[p])if(i.isFile)l++,i.file(function(e){h&&e.name.match(h)||(s.push(i.fullPath||""),o.push(e)),l--});else if(i.isDirectory&&n.api>=2.1){l++,d.push(i.fullPath),t=i.createReader();var r=[],f=function(){t.readEntries(function(e){if(e.length)r=r.concat(u(e)),f();else{for(var t=0;t0?(n.uploads.checkExists(a,i,n).done(function(t,u){var h,p=[];n.options.overwriteUploadConfirm&&!n.UA.iOS&&n.option("uploadOverwrite",i)&&(a=e.map(a,function(a){var r,o,s,l;return a.isDirectory&&(r=e.inArray(a.name,t),-1!==r&&(t.splice(r,1),o=n.uniqueName(a.name+n.options.backupSuffix,null,""),e.each(u,function(e,t){return a.name==t?(s=e,!1):void 0}),s||(s=n.fileByName(a.name,i).hash),n.lockfiles({files:[s]}),l=n.request({data:{cmd:"rename",target:s,name:o},notify:{type:"rename",cnt:1}}).fail(function(e){a._remove=!0,n.sync()}).always(function(){n.unlockfiles({files:[s]})}),p.push(l))),a._remove?null:a})),e.when.apply(e,p).done(function(){a.length>0?(h=setTimeout(function(){n.notify({type:"readdir",cnt:1,hideCnt:!0})},n.options.notifyDelay),c(a),setTimeout(function e(){l>0?setTimeout(e,10):(h&&clearTimeout(h),n.notify({type:"readdir",cnt:-1}),r.resolve([o,s,t,u,d]))},10)):r.reject()})}),r.promise()):r.reject()}var u=[],h=[],p=t.files[0];if("html"==t.type){var f,m=e("").append(e.parseHTML(p.replace(/ src=/gi," _elfsrc=")));e("img[_elfsrc]",m).each(function(){var t,n,i=e(this),a=i.closest("a");a&&a.attr("href")&&a.attr("href").match(/\.(?:jpe?g|gif|bmp|png)/i)&&(n=a.attr("href")),t=i.attr("_elfsrc"),t&&(n?(-1==e.inArray(n,u)&&u.push(n),-1==e.inArray(t,h)&&h.push(t)):-1==e.inArray(t,u)&&u.push(t))}),f=e("a[href]",m),f.each(function(){var t,n=function(e){var t=document.createElement("a");return t.href=e,t};e(this).text()&&(t=n(e(this).attr("href")),!t.href||1!==f.length&&t.pathname.match(/(?:\.html?|\/[^\/.]*)$/i)||-1==e.inArray(t.href,u)&&-1==e.inArray(t.href,h)&&u.push(t.href))})}else{var g,v,b;for(g=/(http[^<>"{}|\\^\[\]`\s]+)/gi;v=g.exec(p);)b=v[1].replace(/&/g,"&"),-1==e.inArray(b,u)&&u.push(b)}return u},xhr:function(t,n){var i=n?n:this,a=i.getUI(),r=new XMLHttpRequest,o=null,s=null,l=t.checked,d=t.isDataType||"data"==t.type,c=t.target||i.cwd().hash,u=t.dropEvt||null,h=-1!=i.option("uploadMaxConn",c),p=Math.min(5,Math.max(1,i.option("uploadMaxConn",c))),f=1e4,m=30,g=0,v=e.Deferred().fail(function(e){if(i.uploads.xhrUploading){setTimeout(function(){i.sync()},5e3);var t=y.length?d?y[0][0]:y[0]:{};t._cid&&(b=new FormData,y=[{_chunkfail:!0}],b.append("chunk",t._chunk),b.append("cid",t._cid),d=!1,R(y))}i.uploads.xhrUploading=!1,y=null,e&&i.error(e)}).done(function(e){r=null,i.uploads.xhrUploading=!1,y=null,e&&(i.currentReqCmd="upload",e.warning&&i.error(e.warning),e.removed&&i.remove(e),e.added&&i.add(e),e.changed&&i.change(e),i.trigger("upload",e),i.trigger("uploaddone"),e.sync&&i.sync(),e.debug&&n.debug("backend-debug",e))}).always(function(){a.off("uploadabort",U),e(window).off("unload",U),o&&clearTimeout(o),s&&clearTimeout(s),l&&!t.multiupload&&S()&&i.notify({type:"upload",cnt:-w,progress:0,size:0}),P&&z.children(".elfinder-notify-chunkmerge").length&&i.notify({type:"chunkmerge",cnt:-1})}),b=new FormData,y=t.input?t.input.files:i.uploads.checkFile(t,i,c),w=t.checked&&d?y[0].length:y.length,k=0,x=0,C=0,T=!1,z=i.ui.notify,A=!0,I=!1,S=function(){return T=T||z.children(".elfinder-notify-upload").length},U=function(){I=!0,r&&(r.quiet=!0,r.abort()),S()&&i.notify({type:"upload",cnt:-1*z.children(".elfinder-notify-upload").data("cnt"),progress:0,size:0})},M=function(e){z.children(".elfinder-notify-upload").children(".elfinder-notify-cancel")[e?"show":"hide"]()},O=function(e){return e||(e=C),setTimeout(function(){T=!0,i.notify({type:"upload",cnt:w,progress:k-x,size:e,cancel:function(){a.trigger("uploadabort"),v.resolve()}}),x=k,t.multiupload?A&&M(!0):M(A&&e>k)},i.options.notifyDelay)},D=function(){g++<=m?(S()&&x&&i.notify({type:"upload",cnt:0,progress:0,size:x}),r.quiet=!0,r.abort(),x=k=0,setTimeout(function(){I||(r.open("POST",i.uploadURL,!0),r.send(b))},f)):(a.trigger("uploadabort"),v.reject(["errAbort","errTimeout"]))},F=t.renames||null,E=t.hashes||null,P=!1;if(a.one("uploadabort",U),e(window).one("unload."+n.namespace,U),!P&&(x=k),!d&&!w)return v.reject(["errUploadNoFiles"]);r.addEventListener("error",function(){0==r.status?I?v.reject():!d&&t.files&&e.map(t.files,function(e){return e.type||e.size!==(i.UA.Safari?1802:0)?null:e}).length?(errors.push("errFolderUpload"),v.reject(["errAbort","errFolderUpload"])):t.input&&e.map(t.input.files,function(e){return e.type||e.size!==(i.UA.Safari?1802:0)?null:e}).length?v.reject(["errUploadNoFiles"]):D():(a.trigger("uploadabort"),v.reject("errConnect"))},!1),r.addEventListener("load",function(e){var n,l=r.status,c=0,u="";if(l>=400?u=l>500?"errResponse":"errConnect":r.responseText||(u=["errResponse","errDataEmpty"]),u){a.trigger("uploadabort");var h=d?y[0][0]:y[0];return v.reject(h._cid?null:u)}if(k=C,S()&&(c=k-x)&&i.notify({type:"upload",cnt:0,progress:c,size:0}),n=i.parseUploadData(r.responseText),n._chunkmerged){b=new FormData;var p=[{_chunkmerged:n._chunkmerged,_name:n._name,_mtime:n._mtime}];return P=!0,a.off("uploadabort",U),s=setTimeout(function(){i.notify({type:"chunkmerge",cnt:1})},i.options.notifyDelay),void(d?R(p,y[1]):R(p))}n._multiupload=!!t.multiupload,n.error?(i.trigger("uploadfail",n),n._chunkfailure||n._multiupload?(I=!0,i.uploads.xhrUploading=!1,o&&clearTimeout(o),z.children(".elfinder-notify-upload").length?(i.notify({type:"upload",cnt:-w,progress:0,size:0}),v.reject(n.error)):v.reject()):v.reject(n.error)):v.resolve(n)},!1),r.upload.addEventListener("loadstart",function(e){!P&&e.lengthComputable&&(k=e.loaded,g&&(k=0),C=e.total,k||(k=parseInt(.05*C)),S()&&(i.notify({type:"upload",cnt:0,progress:k-x,size:t.multiupload?0:C}),x=k))},!1),r.upload.addEventListener("progress",function(e){var n;e.lengthComputable&&!P&&r.readyState<2&&(k=e.loaded,!t.checked&&k>0&&!o&&(o=O(r._totalSize-k)),C||(C=e.total,k||(k=parseInt(.05*C))),n=k-x,S()&&n/e.total>=.05&&(i.notify({type:"upload",cnt:0,progress:n,size:0}),x=k),!t.multiupload&&k>=C&&(A=!1,M(!1)))},!1);var R=function(a,s){var f,m,g,y,k,x,C,T,z,U,D,P,R,j=0,H=1,N=[],q=0,_=w,L=0,W=[],B=(new Date).getTime().toString().substr(-9),V=Math.min((n.uplMaxSize?n.uplMaxSize:2097152)-8190,n.options.uploadMaxChunkSize),$=h?!1:"",K=function(a,r){var s,l,h=[],p=0;if(!I){for(;a.length&&h.lengthf&&!I;f++)s=d?h[f][0][0]._cid||null:h[f][0]._cid||null,R[s]?P--:n.exec("upload",{type:t.type,isDataType:d,files:h[f],checked:!0,target:c,dropEvt:u,renames:F,hashes:E,multiupload:!0},void 0,c).fail(function(e){e&&"No such command"===e&&(I=!0,n.error(["errUpload","errPerm"])),s&&(R[s]=!0)}).always(function(t){t&&t.added&&(U=e.merge(U,t.added)),P<=++D&&(n.trigger("multiupload",{added:U}),o&&clearTimeout(o),S()&&i.notify({type:"upload",cnt:-w,progress:0,size:0})),a.length?K(a,1):--l<=1&&(A=!1,M(!1))})}}(h.length<1||I)&&(I?(o&&clearTimeout(o),s&&(R[s]=!0),v.reject()):(v.resolve(),i.uploads.xhrUploading=!1))},G=function(){i.uploads.xhrUploading?setTimeout(function(){G()},100):(i.uploads.xhrUploading=!0,K(N,p))};if(!l&&(d||"files"==t.type)){for((f=n.option("uploadMaxSize",c))||(f=0),y=0;y=2.1&&("slice"in T?$="slice":"mozSlice"in T?$="mozSlice":"webkitSlice"in T&&($="webkitSlice")))}catch(J){w--,_--;continue}if(f&&m>f||!$&&n.uplMaxSize&&m>n.uplMaxSize)i.error(i.i18n("errUploadFile",T.name)+" "+i.i18n("errUploadFileSize")),w--,_--;else if(!T.type||i.uploadMimeCheck(T.type,c))if($&&m>V){for(k=0,x=V,C=-1,_=Math.floor(m/V),g=T.lastModified?Math.round(T.lastModified/1e3):0,L+=m,W[B]=0;m>=k;)z=T[$](k,x),z._chunk=T.name+"."+ ++C+"_"+_+".part",z._cid=B,z._range=k+","+z.size+","+m,z._mtime=g,W[B]++,j&&q++,"undefined"==typeof N[q]&&(N[q]=[],d&&(N[q][0]=[],N[q][1]=[])),j=V,H=1,d?(N[q][0].push(z),N[q][1].push(s[y])):N[q].push(z),k=x,x=k+V;null==z?(i.error(i.i18n("errUploadFile",T.name)+" "+i.i18n("errUploadFileSize")),w--,_--):(_+=C,j=0,H=1,q++)}else(n.uplMaxSize&&j+m>=n.uplMaxSize||H>n.uplMaxFile)&&(j=0,H=1,q++),"undefined"==typeof N[q]&&(N[q]=[],d&&(N[q][0]=[],N[q][1]=[])),d?(N[q][0].push(T),N[q][1].push(s[y])):N[q].push(T),j+=m,L+=m,H++;else i.error(i.i18n("errUploadFile",T.name)+" "+i.i18n("errUploadMime")+" ("+i.escape(T.type)+")"),w--,_--}if(0==N.length)return t.checked=!0,!1;if(N.length>1)return o=O(L),U=[],D=0,P=N.length,R=[],G(),!0;d?(a=N[0][0],s=N[0][1]):a=N[0]}return l||(n.UA.Safari&&t.files?r._totalSize=L:o=O(L)),l=!0,a.length||v.reject(["errUploadNoFiles"]),r.open("POST",i.uploadURL,!0),n.customHeaders&&e.each(n.customHeaders,function(e){r.setRequestHeader(e,this)}),n.xhrFields&&e.each(n.xhrFields,function(e){e in r&&(r[e]=this)}),b.append("cmd","upload"),b.append(i.newAPI?"target":"current",c),F&&F.length&&(e.each(F,function(e,t){b.append("renames[]",t)}),b.append("suffix",n.options.backupSuffix)),E&&e.each(E,function(e,t){b.append("hashes["+e+"]",t)}),e.each(i.options.customData,function(e,t){b.append(e,t)}),e.each(i.options.onlyMimes,function(e,t){b.append("mimes["+e+"]",t)}),e.each(a,function(e,t){t._chunkmerged?(b.append("chunk",t._chunkmerged),b.append("upload[]",t._name),b.append("mtime[]",t._mtime)):(t._chunkfail?(b.append("upload[]","chunkfail"),b.append("mimes","chunkfail")):b.append("upload[]",t), t._chunk?(b.append("chunk",t._chunk),b.append("cid",t._cid),b.append("range",t._range),b.append("mtime[]",t._mtime)):b.append("mtime[]",t.lastModified?Math.round(t.lastModified/1e3):0)),n.UA.iOS&&b.append("overwrite",0)}),d&&e.each(s,function(e,t){b.append("upload_path[]",t)}),u&&b.append("dropWith",parseInt((u.altKey?"1":"0")+(u.ctrlKey?"1":"0")+(u.metaKey?"1":"0")+(u.shiftKey?"1":"0"),2)),r.send(b),!0};if(d)l?R(y[0],y[1]):y.done(function(t){if(F=[],w=t[0].length){if(t[4]&&t[4].length)return void n.request({data:{cmd:"mkdir",target:c,dirs:t[4]},notify:{type:"mkdir",cnt:t[4].length}}).fail(function(e){e=e||["errUnknown"],"errCmdParams"===e[0]?p=1:(p=0,v.reject(e))}).done(function(n){n.hashes&&(t[1]=e.map(t[1],function(e){return e=e.replace(/\/[^\/]*$/,""),""===e?c:n.hashes[e]}))}).always(function(e){p&&(F=t[2],E=t[3],R(t[0],t[1]))});t[1]=e.map(t[1],function(){return c}),F=t[2],E=t[3],R(t[0],t[1])}else v.reject(["errUploadNoFiles"])}).fail(function(){v.reject()});else if(y.length>0)if(null==F){var j=[],H=[],N=n.options.folderUploadExclude[n.OS]||null;e.each(y,function(t,n){var i=n.webkitRelativePath||n.relativePath||"";return i?(N&&n.name.match(N)?(n._remove=!0,i=void 0):(i=i.replace(/\/[^\/]*$/,""),i&&-1===e.inArray(i,j)&&j.push(i)),void H.push(i)):!1}),n.getUI().find("div.elfinder-upload-dialog-wrapper").elfinderdialog("close"),F=[],E={},j.length?!function(){var t=e.map(j,function(e){return-1===e.indexOf("/")?{name:e}:null}),i=[];n.uploads.checkExists(t,c,n).done(function(a,r){var o,s,l,u=[];n.options.overwriteUploadConfirm&&!n.UA.iOS&&n.option("uploadOverwrite",c)&&(i=e.map(t,function(e){return e._remove?e.name:null}),t=e.map(t,function(e){return e._remove?null:e})),i.length&&e.each(H.concat(),function(t,n){0===e.inArray(n,i)&&(y[t]._remove=!0,delete H[t])}),y=e.map(y,function(e){return e._remove?null:e}),H=e.map(H,function(e){return void 0===e?null:e}),t.length?(o=e.Deferred(),a.length?e.each(a,function(t,i){s=n.uniqueName(i+n.options.backupSuffix,null,""),e.each(r,function(e,t){return a[0]==t?(l=e,!1):void 0}),l||(l=n.fileByName(a[0],c).hash),n.lockfiles({files:[l]}),u.push(n.request({data:{cmd:"rename",target:l,name:s},notify:{type:"rename",cnt:1}}).fail(function(e){v.reject(e),n.sync()}).always(function(){n.unlockfiles({files:[l]})}))}):u.push(null),e.when.apply(e,u).done(function(){n.request({data:{cmd:"mkdir",target:c,dirs:j},notify:{type:"mkdir",cnt:j.length}}).fail(function(e){e=e||["errUnknown"],"errCmdParams"===e[0]?p=1:(p=0,v.reject(e))}).done(function(t){t.hashes&&(H=e.map(H.concat(),function(e){return""===e?c:t.hashes["/"+e]}))}).always(function(e){p&&(d=!0,R(y,H)||v.reject())})})):v.reject()})}():n.uploads.checkExists(y,c,n).done(function(t,i){n.options.overwriteUploadConfirm&&!n.UA.iOS&&n.option("uploadOverwrite",c)&&(F=t,E=i,y=e.map(y,function(e){return e._remove?null:e})),w=y.length,w>0?R(y)||v.reject():v.reject()})}else R(y)||v.reject();else v.reject();return v},iframe:function(t,n){var i,a,r,o,s=n?n:this,l=t.input?t.input:!1,d=l?!1:s.uploads.checkFile(t,s),c=e.Deferred().fail(function(e){e&&s.error(e)}),u="iframe-"+n.namespace+ ++s.iframeCnt,h=e('
'),p=this.UA.IE,f=function(){o&&clearTimeout(o),r&&clearTimeout(r),a&&s.notify({type:"upload",cnt:-i}),setTimeout(function(){p&&e('