core/domUtils.js 
Dom操作工具包
@file
@module UE.dom.domUtils
@since 1.2.6.1
 
Dom操作工具包
@unfile
@module UE.dom.domUtils
556310
function getDomNode(node, start, ltr, startFromChild, fn, guard) {
    var tmpNode = startFromChild && node[start],
        parent;
    !tmpNode && (tmpNode = node[ltr]);
    while (!tmpNode && (parent = (parent || node).parentNode)) {
        if (parent.tagName == 'BODY' || guard && !guard(parent)) {
            return null;
        }
        tmpNode = parent[ltr];
    }
    if (tmpNode && fn && !fn(tmpNode)) {
        return  getDomNode(tmpNode, start, ltr, false, fn);
    }
    return tmpNode;
}
890591
function modDefined( id ) {
        var listeners = modDefinedListeners[ id ] || [];
        var module = modModules[ id ];
        module.state = MODULE_DEFINED;

        var len = listeners.length;
        while ( len-- ) {
            // 这里不做function类型的检测
            // 因为listener都是通过modOn传入的，modOn为内部调用
            listeners[ len ]();
        }

        // 清理listeners
        listeners.length = 0;
        delete modDefinedListeners[ id ];
    }
631490
function( options ){
			var nodes = modules.domUtils.getDOMContext( options );
			this.rootNode = nodes.rootNode;
			this.document = nodes.document;
		}
775556
function(fn) {
	/*!
	 * contentloaded.js
	 *
	 * Author: Diego Perini (diego.perini at gmail.com)
	 * Summary: cross-browser wrapper for DOMContentLoaded
	 * Updated: 20101020
	 * License: MIT
	 * Version: 1.2
	 *
	 * URL:
	 * http://javascript.nwbox.com/ContentLoaded/
	 * http://javascript.nwbox.com/ContentLoaded/MIT-LICENSE
	 *
	 */
	
	// @fn function reference

	var done = false,
		top = true,

		root = y.documentElement,
	
		add = y.attachEvent ? 'attachEvent' : 'addEventListener',
		rem = y.attachEvent ? 'detachEvent' : 'removeEventListener',
		pre = y.attachEvent ? 'on' : '',
	
		init = function(e) {
			if (e.type == 'readystatechange' && y.readyState != 'complete') return;
			(e.type == 'load' ? z : y)[rem](pre + e.type, init, false);
			if (!done && (done = true)) fn.call(z, e.type || e);
		},
	
		poll = function() {
			try { 
				if(!root.doScroll('left')){ 
					setTimeout(poll, 50); return;
				} 
			} catch(e) { setTimeout(poll, 50); return; }
			init('poll');
		};

	if (y.readyState == 'complete') fn.call(z, 'lazy');
	else {
		if (y.createEventObject && root.doScroll) {
			try { top = !z.frameElement; } catch(e) { }
			if (top) poll();
		}
		y[add](pre + 'DOMContentLoaded', init, false);
		y[add](pre + 'readystatechange', init, false);
		z[add](pre + 'load', init, false);
	}
}
1135810
function define (HTMLFile, utils) {
  const { callable } = utils;
  const { debug, error, strong } = utils.cnsl;
  const { regexpEscape, uniqueMatch } = utils.string;

  return class HANDLEBARSFile extends HTMLFile {
    /**
     * Constructor
     * @param {String} id
     * @param {String} filepath
     * @param {Object} options
     *  - {Object} caches
     *  - {Object} fileExtensions
     *  - {Function} fileFactory
     *  - {Object} globalAliases
     *  - {Array} npmModulepaths
     *  - {Object} pluginOptions
     *  - {Object} runtimeOptions
     */
    constructor (id, filepath, options) {
      super(id, filepath, options);

      this.workflows.writeable = WORKFLOW_WRITEABLE;
    }

    /**
     * Parse file contents for dependency references
     * @param {Object} buildOptions
     *  - {Boolean} batch
     *  - {Boolean} bootstrap
     *  - {Boolean} boilerplate
     *  - {Boolean} browser
     *  - {Boolean} bundle
     *  - {Boolean} compress
     *  - {Array} ignoredFiles
     *  - {Boolean} helpers
     *  - {Boolean} watchOnly
     * @param {Function} fn(err)
     */
    parse (buildOptions, fn) {
      super.parse(buildOptions, (err) => {
        if (err) return fn(err);
        // Add sidecar json file
        const sidecarData = super.parseSidecarDependency();
        // Parse includes
        let matches = uniqueMatch(this.content, RE_INCLUDE)
          .map((match) => {
            match.id = match.match;
            return match;
          });

        if (sidecarData) matches.push(sidecarData);
        super.addDependencies(matches, buildOptions);
        fn();
      });
    }

    /**
     * Inline css/img/js dependency content
     * @param {Object} buildOptions
     *  - {Boolean} batch
     *  - {Boolean} bootstrap
     *  - {Boolean} boilerplate
     *  - {Boolean} browser
     *  - {Boolean} bundle
     *  - {Boolean} compress
     *  - {Boolean} helpers
     *  - {Array} ignoredFiles
     *  - {Boolean} import
     *  - {Boolean} watchOnly
     * @param {Function} fn(err)
     */
    inlineInlineable (buildOptions, fn) {
      // Only dependencies
      parallel([...this.getAllDependencies()].reduce((inlineable, file) => {
        if (file instanceof HANDLEBARSFile && this.dependencyReferences.length) {
          inlineable.push(callable(file, 'inline', buildOptions));
        }
        return inlineable;
      }, []), fn);
    }

    /**
     * Inline partials content
     * @param {Object} buildOptions
     *  - {Boolean} batch
     *  - {Boolean} bootstrap
     *  - {Boolean} boilerplate
     *  - {Boolean} browser
     *  - {Boolean} bundle
     *  - {Boolean} compress
     *  - {Boolean} helpers
     *  - {Array} ignoredFiles
     *  - {Boolean} import
     *  - {Boolean} watchOnly
     * @param {Function} fn(err)
     */
    inlineIncludes (buildOptions, fn) {
      [...this.getAllDependencies(), this].forEach((file) => {
        if (file instanceof HANDLEBARSFile && file.dependencyReferences.length) {
          let content = file.content;

          file.dependencyReferences.forEach((reference) => {
            if (reference.file && reference.context) {
              content = content.replace(new RegExp(regexpEscape(reference.context), 'g'), reference.file.content);
            }
          });

          file.setContent(content);
        }
      });
      fn();
    }

    /**
     * Compile file contents
     * @param {Object} buildOptions
     *  - {Boolean} batch
     *  - {Boolean} bootstrap
     *  - {Boolean} boilerplate
     *  - {Boolean} browser
     *  - {Boolean} bundle
     *  - {Boolean} compress
     *  - {Array} ignoredFiles
     *  - {Boolean} helpers
     *  - {Boolean} watchOnly
     * @param {Function} fn(err)
     * @returns {null}
     */
    compile (buildOptions, fn) {
      try {
        const options = Object.assign({}, DEFAULT_OPTIONS, this.options.pluginOptions.handlebars);
        const template = handlebars.compile(this.content, options);

        this.setContent(template(this.findSidecarDependency()));
        debug(`compile: ${strong(this.relpath)}`, 4);
        fn();
      } catch (err) {
        if (!this.options.runtimeOptions.watch) return fn(err);
        error(err, 4, false);
      }
    }

    /**
     * Reparse file contents for dependency references
     * @param {Object} buildOptions
     *  - {Boolean} batch
     *  - {Boolean} bootstrap
     *  - {Boolean} boilerplate
     *  - {Boolean} browser
     *  - {Boolean} bundle
     *  - {Boolean} compress
     *  - {Array} ignoredFiles
     *  - {Boolean} helpers
     *  - {Boolean} watchOnly
     * @param {Function} fn(err)
     */
    reparse (buildOptions, fn) {
      this.allDependencies = null;
      this.allDependencyReferences = null;
      this.dependencies = [];
      this.dependencyReferences = [];

      super.parse(buildOptions, fn);
    }
  };
}
348682
function(callback) {
			fs.appendFileSync(outputFile,";(function(root,factory){\r\n")
			fs.appendFileSync(outputFile,"    if (typeof define === 'function' && define.amd) {\r\n")
			fs.appendFileSync(outputFile,"        define([], factory);\r\n")
			fs.appendFileSync(outputFile,"    } else if (typeof exports === 'object') {\r\n")
			fs.appendFileSync(outputFile,"        module.exports = factory();\r\n")
			fs.appendFileSync(outputFile,"    } else {\r\n")
			fs.appendFileSync(outputFile,"        if (typeof root === 'undefined' || root !== Object(root)) {\r\n")
			fs.appendFileSync(outputFile,"            throw new Error('puglatizer: window does not exist or is not an object');\r\n")
			fs.appendFileSync(outputFile,"        }\r\n")
			fs.appendFileSync(outputFile,"        root.puglatizer = factory();\r\n")
			fs.appendFileSync(outputFile,"    }\r\n")
			fs.appendFileSync(outputFile,"}(this, function () {\r\n")
			fs.appendFileSync(outputFile,"    function pug_classes_object(val) { var classString = '', padding = ''; for (var key in val) { if (key && val[key] && pug_has_own_property.call(val, key)) { var classString = classString + padding + key; var padding = ' '; } } return classString; }")
			fs.appendFileSync(outputFile,"    function pug_classes_array(val, escaping) { var classString = '', className, padding = '', escapeEnabled = Array.isArray(escaping); for (var i = 0; i < val.length; i++) { var className = pug_classes(val[i]); if (!className) continue; escapeEnabled && escaping[i] && (className = pug_escape(className)); var classString = classString + padding + className; var padding = ' '; } return classString; }")
			fs.appendFileSync(outputFile,"    " + minify.js(pug.runtime.merge.toString()) + '\r\n')
			fs.appendFileSync(outputFile,"    " + minify.js(pug.runtime.classes.toString()) + '\r\n')
			fs.appendFileSync(outputFile,"    " + minify.js(pug.runtime.style.toString()) + '\r\n')
			fs.appendFileSync(outputFile,"    " + minify.js(pug.runtime.attr.toString()) + '\r\n')
			fs.appendFileSync(outputFile,"    " + minify.js(pug.runtime.attrs.toString()) + '\r\n')
			fs.appendFileSync(outputFile,"    " + minify.js(pug.runtime.escape.toString()).replace('pug_match_html','(/[\"&<>]/)') + '\r\n')
			fs.appendFileSync(outputFile,"    " + minify.js(pug.runtime.rethrow.toString()) + '\r\n')
			fs.appendFileSync(outputFile,"    var pug = {\r\n")
			fs.appendFileSync(outputFile,"    	merge:" + minify.js(pug.runtime.merge.toString()) + ',\r\n')
			fs.appendFileSync(outputFile,"    	classes:" + minify.js(pug.runtime.classes.toString()) + ',\r\n')
			fs.appendFileSync(outputFile,"    	style:" + minify.js(pug.runtime.style.toString()) + ',\r\n')
			fs.appendFileSync(outputFile,"    	attr:" + minify.js(pug.runtime.attr.toString()) + ',\r\n')
			fs.appendFileSync(outputFile,"    	attrs:" + minify.js(pug.runtime.attrs.toString()) + ',\r\n')
			fs.appendFileSync(outputFile,"    	escape:" + minify.js(pug.runtime.escape.toString()).replace('pug_match_html','(/[\"&<>]/)') + ',\r\n')
			fs.appendFileSync(outputFile,"    	rethrow:" + minify.js(pug.runtime.rethrow.toString()) + '\r\n')
			fs.appendFileSync(outputFile,"    }\r\n")
			fs.appendFileSync(outputFile,"\r\n")
			fs.appendFileSync(outputFile,'    var puglatizer = {}')
			fs.appendFileSync(outputFile,"\r\n")
			return callback()
		}
582369
function unloadModule($module, $object_id = 'all')
    {
        //卸载全部
        if ($object_id == 'all')
        {
            //清除配置
            if (isset($this->config[$module]))
            {
                unset($this->config[$module]);
            }
            $find = false;
            foreach($this->objects as $key => $object)
            {
                list($name, $id) = explode('_', $key, 2);
                //找到了此模块
                if ($name === $module)
                {
                    $this->unloadModule($module, $id);
                    $find = true;
                }
            }
            return $find;
        }
        //卸载某个对象
        else
        {
            //清除配置
            if (isset($this->config[$module][$object_id]))
            {
                unset($this->config[$module][$object_id]);
            }
            $key = $module.'_'.$object_id;
            if (empty($this->objects[$key]))
            {
                return false;
            }
            $object = $this->objects[$key];
            //存在close方法，自动调用
            if (is_object($object) and method_exists($object, 'close'))
            {
                call_user_func(array($object, 'close'));
            }
            //删除对象
            unset($this->objects[$key]);
            //master
            if ($object_id == 'master')
            {
                $this->{$module} = null;
            }
            return true;
        }
    }
615421
function (modName, cfg) {
            modName = addIndexAndRemoveJsExtFromName(modName);

            var mods = Env.mods,
                module = mods[modName];

            if (module) {
                return module;
            }

            // 防止 cfg 里有 tag，构建 fullpath 需要
            mods[modName] = module = new Loader.Module(mix({
                name: modName
            }, cfg));

            return module;
        }
1286877
function (element) {
/*Line 271 - 'AtomUI.js' */        while (element.hasChildNodes()) {
/*Line 272 - 'AtomUI.js' */            var lc = element.lastChild;
/*Line 273 - 'AtomUI.js' */            if (!lc)
/*Line 274 - 'AtomUI.js' */                break;
/*Line 275 - 'AtomUI.js' */            //element.removeChild(lc);
/*Line 276 - 'AtomUI.js' */            if (lc.atomControl) {
/*Line 277 - 'AtomUI.js' */                lc.atomControl.dispose();
/*Line 278 - 'AtomUI.js' */                delete lc.atomControl;
/*Line 279 - 'AtomUI.js' */            }
/*Line 280 - 'AtomUI.js' */            $(lc).remove();
/*Line 281 - 'AtomUI.js' */            //delete lc;
/*Line 282 - 'AtomUI.js' */        }
/*Line 283 - 'AtomUI.js' */    }
1119450
function () {

/*Line 57 - 'AtomDispatcher.js' */                //if (window.console) {
/*Line 58 - 'AtomDispatcher.js' */                //    window.console.log("Starting Web Atoms");
/*Line 59 - 'AtomDispatcher.js' */                //}

/*Line 61 - 'AtomDispatcher.js' */                var a = $('[data-atom-type],[atom-type]').first()[0];
/*Line 62 - 'AtomDispatcher.js' */                if (a.atomControl != undefined && a.atomControl != null)
/*Line 63 - 'AtomDispatcher.js' */                    return;
/*Line 64 - 'AtomDispatcher.js' */                var ct = AtomUI.getAtomType(a);
/*Line 65 - 'AtomDispatcher.js' */                $(a).removeAttr("atom-type");
/*Line 66 - 'AtomDispatcher.js' */                $(a).removeAttr("data-atom-type");
/*Line 67 - 'AtomDispatcher.js' */                var ctrl = new (WebAtoms[ct])(a);
/*Line 68 - 'AtomDispatcher.js' */                ctrl.setup();

/*Line 70 - 'AtomDispatcher.js' */            }
112361
function () {
/*Line 29 - 'AtomUIComponent.js' */                if (this._localScope === undefined) {
/*Line 30 - 'AtomUIComponent.js' */                    var ap = this.get_atomParent(this._element._logicalParent || this._element.parentNode);
/*Line 31 - 'AtomUIComponent.js' */                    if (ap) {
/*Line 32 - 'AtomUIComponent.js' */                        return ap.get_localScope();
/*Line 33 - 'AtomUIComponent.js' */                    } else {
/*Line 34 - 'AtomUIComponent.js' */                        throw new Error("Local Scope does not exist");
/*Line 35 - 'AtomUIComponent.js' */                    }
/*Line 36 - 'AtomUIComponent.js' */                }
/*Line 37 - 'AtomUIComponent.js' */                return this._localScope;
/*Line 38 - 'AtomUIComponent.js' */            }
942303
function () {

        var htmlFile = this.htmlFile;
        var htmlParser = this.htmlParser;
        var options = this.options;
        var resources = [];

        // 获取外链样式资源
        var cssFiles =  htmlParser.getCssFiles();

        // 获取 style 标签内容资源
        var cssContents =  htmlParser.getCssContents();


        cssFiles.forEach(function (cssFile, index) {

            if (!cssFile) {
                return;
            }

            var line = index + 1;
            var from = 'link:nth-of-type(' + line + ')';

            resources.push(
                new Resource(
                    cssFile,
                    null,
                    utils.options(options, {
                        cache: true,
                        from: from
                    })
                )
            );

        });


        cssContents.forEach(function (content, index) {

            if (!content) {
                return;
            }

            var line = index + 1;
            var from = 'style:nth-of-type(' + line + ')';
            var cssFile = htmlFile + '#' + from;
            resources.push(
                new Resource(
                    cssFile,
                    content,
                    utils.options(options, {
                        cache: false,
                        from: from
                    })
                )
            );
        });



        return Promise.all(resources.map(function (resource) {
            return new CssParser(resource);
        }))

        // 对二维数组扁平化处理
        .then(utils.reduce);
    }
880715
function(id, file, dum, fm) {
				var ta = this,
					ifm = $(this).hide(),
					spnr = $('<div/>')
						.css({
							position: 'absolute',
							top: '50%',
							textAlign: 'center',
							width: '100%',
							fontSize: '16pt'
						})
						.html(fm.i18n('nowLoading') + '<span class="elfinder-spinner"/>')
						.appendTo(ifm.parent()),
					cdata = function() {
						var data = '';
						$.each(fm.customData, function(key, val) {
							data += '&' + encodeURIComponent(key) + '=' + encodeURIComponent(val);
						});
						return data;
					};
				
				$(ta).data('xhr', fm.request({
					data: {
						cmd: 'editor',
						name: 'ZohoOffice',
						method: 'init',
						'args[target]': file.hash,
						'args[lang]' : fm.lang,
						'args[cdata]' : cdata
					},
					preventDefault : true
				}).done(function(data) {
					var opts;
					if (data.zohourl) {
						opts = {
							css: {
								height: '100%'
							}
						};
						// trigger event 'editEditorPrepare'
						ta.editor.trigger('Prepare', {
							node: ta,
							editorObj: void(0),
							instance: ifm,
							opts: opts
						});

						ifm.attr('src', data.zohourl).show().css(opts.css);
					} else {
						data.error && fm.error(data.error);
						ta.elfinderdialog('destroy');
					}
				}).fail(function(error) {
					error && fm.error(error);
					ta.elfinderdialog('destroy');
				}).always(function() {
					spnr.remove();
				}));
			}
263964
function (name, factory, config) {
            name = addIndexAndRemoveJsExtFromName(name);

            var mods = Env.mods,
                module = mods[name];

            if (module && module.factory !== undefined) {
                S.log(name + ' is defined more than once', 'warn');
                return;
            }

            // 没有 use，静态载入的 add 可能执行
            Utils.createModuleInfo(name);

            module = mods[name];

            // 注意：通过 S.add(name[, factory[, config]]) 注册的代码，无论是页面中的代码，
            // 还是 js 文件里的代码，add 执行时，都意味着该模块已经 LOADED
            mix(module, {
                name: name,
                status: LOADED,
                factory: factory
            });

            mix(module, config);
        }
808886
function (url) {
/*Line 114 - 'AtomUI.js' */        var r = {};

/*Line 116 - 'AtomUI.js' */        var plist = url.split('&');

/*Line 118 - 'AtomUI.js' */        var ae = new AtomEnumerator(plist);
/*Line 119 - 'AtomUI.js' */        while (ae.next()) {
/*Line 120 - 'AtomUI.js' */            var p = ae.current().split('=');
/*Line 121 - 'AtomUI.js' */            var key = p[0];
/*Line 122 - 'AtomUI.js' */            var val = p[1];
/*Line 123 - 'AtomUI.js' */            if (val) {
/*Line 124 - 'AtomUI.js' */                val = decodeURIComponent(val);
/*Line 125 - 'AtomUI.js' */            }
/*Line 126 - 'AtomUI.js' */            val = AtomUI.parseValue(val);
/*Line 127 - 'AtomUI.js' */            r[key] = val;
/*Line 128 - 'AtomUI.js' */        }
/*Line 129 - 'AtomUI.js' */        return r;
/*Line 130 - 'AtomUI.js' */    }
661906
function (e) {
/*Line 7 - 'AtomUploadButton.js' */            if (/input/gi.test(e.nodeName) && /file/gi.test(AtomUI.attr(e,"type"))) {
/*Line 8 - 'AtomUploadButton.js' */                this._filePresenter = e;
/*Line 9 - 'AtomUploadButton.js' */                return;
/*Line 10 - 'AtomUploadButton.js' */            }

/*Line 12 - 'AtomUploadButton.js' */            var fp = this._filePresenter = document.createElement("input");
/*Line 13 - 'AtomUploadButton.js' */            AtomUI.attr(fp, "type", "file");
/*Line 14 - 'AtomUploadButton.js' */            $(fp).css({
/*Line 15 - 'AtomUploadButton.js' */                left: "-500px",
/*Line 16 - 'AtomUploadButton.js' */                position: "absolute",
/*Line 17 - 'AtomUploadButton.js' */                top: "0"
/*Line 18 - 'AtomUploadButton.js' */            });
/*Line 19 - 'AtomUploadButton.js' */            document.body.appendChild(this._filePresenter);
/*Line 20 - 'AtomUploadButton.js' */        }
614303
function () {
        var self = this;

        var input = DomUtils.create('input', {
          type: 'file',
          id: self._id + '-browse',
          accept: self.settings.accept
        });

        self._super();

        $(input).on('change', function (e) {
          var files = e.target.files;

          self.value = function () {
            if (!files.length) {
              return null;
            } else if (self.settings.multiple) {
              return files;
            } else {
              return files[0];
            }
          };

          e.preventDefault();

          if (files.length) {
            self.fire('change', e);
          }
        });

        // ui.Button prevents default on click, so we shouldn't let the click to propagate up to it
        $(input).on('click', function (e) {
          e.stopPropagation();
        });

        $(self.getEl('button')).on('click', function (e) {
          e.stopPropagation();
          input.click();
        });

        // in newer browsers input doesn't have to be attached to dom to trigger browser dialog
        // however older IE11 (< 11.1358.14393.0) still requires this
        self.getEl().appendChild(input);
      }