PluginProbe
Easy Hotel – Powerful Hotel Booking / trunk
Easy Hotel – Powerful Hotel Booking vtrunk
2.0.8 2.0.7 2.0.6 2.0.5 2.0.4 2.0.3 2.0.2 2.0.1 2.0.0 1.9.9 1.9.8 1.9.7 1.9.6 1.9.5 1.9.4 1.9.3 1.9.2 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 All 110 releases
easy-hotel / admin / includes / framework / assets / js / loadmode.js

loadmode.js in Easy Hotel – Powerful Hotel Booking trunk, at admin/includes/framework/assets/js/loadmode.js

67 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: https://codemirror.net/5/LICENSE
3
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"), "cjs");
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror"], function(CM) { mod(CM, "amd"); });
9 else // Plain browser env
10 mod(CodeMirror, "plain");
11 })(function(CodeMirror, env) {
12 if (!CodeMirror.modeURL) CodeMirror.modeURL = "../mode/%N/%N.js";
13
14 var loading = {};
15 function splitCallback(cont, n) {
16 var countDown = n;
17 return function() { if (--countDown == 0) cont(); };
18 }
19 function ensureDeps(mode, cont, options) {
20 var modeObj = CodeMirror.modes[mode], deps = modeObj && modeObj.dependencies;
21 if (!deps) return cont();
22 var missing = [];
23 for (var i = 0; i < deps.length; ++i) {
24 if (!CodeMirror.modes.hasOwnProperty(deps[i]))
25 missing.push(deps[i]);
26 }
27 if (!missing.length) return cont();
28 var split = splitCallback(cont, missing.length);
29 for (var i = 0; i < missing.length; ++i)
30 CodeMirror.requireMode(missing[i], split, options);
31 }
32
33 CodeMirror.requireMode = function(mode, cont, options) {
34 if (typeof mode != "string") mode = mode.name;
35 if (CodeMirror.modes.hasOwnProperty(mode)) return ensureDeps(mode, cont, options);
36 if (loading.hasOwnProperty(mode)) return loading[mode].push(cont);
37
38 var file = options && options.path ? options.path(mode) : CodeMirror.modeURL.replace(/%N/g, mode);
39 if (options && options.loadMode) {
40 options.loadMode(file, function() { ensureDeps(mode, cont, options) })
41 } else if (env == "plain") {
42 var script = document.createElement("script");
43 script.src = file;
44 var others = document.getElementsByTagName("script")[0];
45 var list = loading[mode] = [cont];
46 CodeMirror.on(script, "load", function() {
47 ensureDeps(mode, function() {
48 for (var i = 0; i < list.length; ++i) list[i]();
49 }, options);
50 });
51 others.parentNode.insertBefore(script, others);
52 } else if (env == "cjs") {
53 require(file);
54 cont();
55 } else if (env == "amd") {
56 requirejs([file], cont);
57 }
58 };
59
60 CodeMirror.autoLoadMode = function(instance, mode, options) {
61 if (!CodeMirror.modes.hasOwnProperty(mode))
62 CodeMirror.requireMode(mode, function() {
63 instance.setOption("mode", instance.getOption("mode"));
64 }, options);
65 };
66 });
67