Sha256: 8456650e3252e9e681b2fa5cae7648c6bcad9af9ea63e94f98b1a89ab2255dca

Contents?: true

Size: 1.75 KB

Versions: 236

Compression:

Stored size: 1.75 KB

Contents

(function() {
  if (!CodeMirror.modeURL) CodeMirror.modeURL = "../mode/%N/%N.js";

  var loading = {};
  function splitCallback(cont, n) {
    var countDown = n;
    return function() { if (--countDown == 0) cont(); };
  }
  function ensureDeps(mode, cont) {
    var deps = CodeMirror.modes[mode].dependencies;
    if (!deps) return cont();
    var missing = [];
    for (var i = 0; i < deps.length; ++i) {
      if (!CodeMirror.modes.hasOwnProperty(deps[i]))
        missing.push(deps[i]);
    }
    if (!missing.length) return cont();
    var split = splitCallback(cont, missing.length);
    for (var i = 0; i < missing.length; ++i)
      CodeMirror.requireMode(missing[i], split);
  }

  CodeMirror.requireMode = function(mode, cont) {
    if (typeof mode != "string") mode = mode.name;
    if (CodeMirror.modes.hasOwnProperty(mode)) return ensureDeps(mode, cont);
    if (loading.hasOwnProperty(mode)) return loading[mode].push(cont);

    var script = document.createElement("script");
    script.src = CodeMirror.modeURL.replace(/%N/g, mode);
    var others = document.getElementsByTagName("script")[0];
    others.parentNode.insertBefore(script, others);
    var list = loading[mode] = [cont];
    var count = 0, poll = setInterval(function() {
      if (++count > 100) return clearInterval(poll);
      if (CodeMirror.modes.hasOwnProperty(mode)) {
        clearInterval(poll);
        loading[mode] = null;
        ensureDeps(mode, function() {
          for (var i = 0; i < list.length; ++i) list[i]();
        });
      }
    }, 200);
  };

  CodeMirror.autoLoadMode = function(instance, mode) {
    if (!CodeMirror.modes.hasOwnProperty(mode))
      CodeMirror.requireMode(mode, function() {
        instance.setOption("mode", instance.getOption("mode"));
      });
  };
}());

Version data entries

236 entries across 235 versions & 12 rubygems

Version Path
overpass-doc-0.0.2 lib/overpass-doc/assets/util/loadmode.js
overpass-doc-0.0.1 lib/overpass-doc/assets/util/loadmode.js
marty-2.4.7 app/components/marty/script_form/client/util/loadmode.js
marty-2.4.6 app/components/marty/script_form/client/util/loadmode.js
marty-2.4.5 app/components/marty/script_form/client/util/loadmode.js
marty-2.4.4 app/components/marty/script_form/client/util/loadmode.js
marty-2.4.3 app/components/marty/script_form/client/util/loadmode.js
marty-2.4.2 app/components/marty/script_form/client/util/loadmode.js
marty-2.4.1 app/components/marty/script_form/client/util/loadmode.js
marty-2.4.0 app/components/marty/script_form/client/util/loadmode.js
marty-2.3.15 app/components/marty/script_form/client/util/loadmode.js
marty-2.3.14 app/components/marty/script_form/client/util/loadmode.js
marty-2.3.13 app/components/marty/script_form/client/util/loadmode.js
marty-2.3.12 app/components/marty/script_form/client/util/loadmode.js
marty-2.3.11 app/components/marty/script_form/client/util/loadmode.js
marty-2.3.10 app/components/marty/script_form/client/util/loadmode.js
marty-2.3.9 app/components/marty/script_form/client/util/loadmode.js
marty-2.3.8 app/components/marty/script_form/client/util/loadmode.js
marty-2.3.7 app/components/marty/script_form/client/util/loadmode.js
marty-2.3.5 app/components/marty/script_form/client/util/loadmode.js