[Pkg-mozext-commits] [firebug] 48/59: Applying the modes after loading the mode files asynchronously.
David Prévot
taffit at moszumanska.debian.org
Thu Aug 14 14:52:57 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 90dd69524119f7b4349bd0f8b3efa56d911744ab
Author: Farshid Beheshti <farshid.beheshti at gmail.com>
Date: Sat Aug 9 18:55:42 2014 +0430
Applying the modes after loading the mode files asynchronously.
---
extension/content/firebug/editor/sourceEditor.js | 29 ++++++++++++++++++++----
extension/content/firebug/lib/dom.js | 14 ++++++++++++
2 files changed, 38 insertions(+), 5 deletions(-)
diff --git a/extension/content/firebug/editor/sourceEditor.js b/extension/content/firebug/editor/sourceEditor.js
index 3242292..abba40b 100644
--- a/extension/content/firebug/editor/sourceEditor.js
+++ b/extension/content/firebug/editor/sourceEditor.js
@@ -421,24 +421,43 @@ SourceEditor.prototype =
// xxxHonza: the default 'mixedmode' mode should be set only if the text
// is actually a markup (first letter == '<'?). Note that applying mixed mode
// on plain JS doesn't work (no color syntax at all).
- var mode = "htmlmixed";
+ var mode = {
+ name: "htmlmixed",
+ src: htmlMixedModeSrc
+ };
switch (type)
{
case "js":
- mode = "javascript";
+ mode.name = "javascript";
+ mode.src = jsModeSrc;
break;
case "css":
- mode = "css";
+ mode.name = "css";
+ mode.src = cssModeSrc;
break;
case "xml":
- mode = "xml";
+ mode.name = "xml";
+ mode.src = xmlModeSrc;
break;
}
- this.editorObject.setOption("mode", mode);
+
+ // When no mode is still set for the text, it seems that CM applies the
+ // first mode that was found and causes loading the text slowly.
+ this.editorObject.setOption("mode", "text/plain");
text = text || "";
this.editorObject.setValue(text);
+
+ Dom.addScriptAsync(this.parentNode.ownerDocument,
+ mode.src,
+ this.onLoadedModeFile.bind(this, mode.name));
},
+
+ onLoadedModeFile: function(modeName)
+ {
+ this.editorObject.setOption("mode", modeName);
+ },
+
getText: function()
{
return this.editorObject.getValue();
diff --git a/extension/content/firebug/lib/dom.js b/extension/content/firebug/lib/dom.js
index 6c6fe0f..a480807 100644
--- a/extension/content/firebug/lib/dom.js
+++ b/extension/content/firebug/lib/dom.js
@@ -256,6 +256,20 @@ Dom.addScript = function(doc, id, src)
return element;
};
+Dom.addScriptAsync = function(doc, src, successCallback)
+{
+ var script = doc.createElement("script");
+ script.type = "text/javascript";
+ script.async = true;
+ script.src = src;
+ script.addEventListener("load", function (event)
+ {
+ successCallback();
+ });
+
+ doc.documentElement.appendChild(script);
+};
+
Dom.setOuterHTML = function(element, html)
{
try
--
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