[Pkg-mozext-commits] [firebug] 42/59: Just adding loadmode addon.
David Prévot
taffit at moszumanska.debian.org
Thu Aug 14 14:52:56 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository firebug.
commit 62210720f023c810a7c367749ab9870b4139fed1
Author: Farshid Beheshti <farshid.beheshti at gmail.com>
Date: Sat Aug 9 14:51:52 2014 +0430
Just adding loadmode addon.
---
.../editor/codemirror/addon/mode/loadmode.js | 61 ++++++++++++++++++++++
1 file changed, 61 insertions(+)
diff --git a/extension/content/firebug/editor/codemirror/addon/mode/loadmode.js b/extension/content/firebug/editor/codemirror/addon/mode/loadmode.js
new file mode 100644
index 0000000..65e51bf
--- /dev/null
+++ b/extension/content/firebug/editor/codemirror/addon/mode/loadmode.js
@@ -0,0 +1,61 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+(function (mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function (CodeMirror) {
+ 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"));
+ });
+ };
+});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/firebug.git
More information about the Pkg-mozext-commits
mailing list