[Pkg-mozext-commits] [itsalltext] 114/459: Incorporated Jason's suggestions for the API: * detect class better * change documents to reflect reality better Fixed bug with openEditor() not working right.
David Prévot
taffit at moszumanska.debian.org
Tue Feb 24 23:26:12 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository itsalltext.
commit 73d2c9e10dccadb654bb1fb506bfa0ffdcdc219e
Author: docwhat at gerf.org <docwhat at gerf.org>
Date: Thu Feb 8 11:18:48 2007 -0500
Incorporated Jason's suggestions for the API:
* detect class better
* change documents to reflect reality better
Fixed bug with openEditor() not working right.
---
chrome/content/API.js | 78 +++++++++++++++++++++-----------------------
chrome/content/itsalltext.js | 19 +++++++++++
2 files changed, 56 insertions(+), 41 deletions(-)
diff --git a/chrome/content/API.js b/chrome/content/API.js
index 50c26d3..e797aa6 100644
--- a/chrome/content/API.js
+++ b/chrome/content/API.js
@@ -1,28 +1,32 @@
/*
- This file is used to allow external editors to work inside your XUL chrome://
+ This file is used to allow external editors to work inside your chrome XUL.
***** How To Use This API *****
- At the top of your .xul file, put this script line:
+ Add this script line to your .xul file:
<script type="application/javascript" src="chrome://itsalltext/content/API.js"/>
- It will fail with only an info message in the Error Console
- if It's All Text! doesn't exist.
+ If "It's All Text!" isn't installed in the browser, it will fail safely.
+ It only generates an info message in the error console.
- Then you need to create a button for the user to click to execute
- the editor. This button must have four properties:
- 1) It must be a 'button' element.
- 2) The class must be "ItsAllTextEditButton".
- 3) The onclick attribute must be the JavaScript snippet:
- ItsAllText.openEditor('id-of-your-textbox');
- The string 'id-of-your-textbox' should be the id of the textbox
- you want to be editable.
- 4) The style should include "display: none" so that the button won't
- show up if It's All Text! isn't installed.
+ Then you need to create a way to call ItsAllText.openEditor().
+ Usage:
+ ItsAllText.openEditor('id-of-your-textbox');
+ or
+ ItsAllText.openEditor('id-of-your-textbox', '.extension');
+ The string 'id-of-your-textbox' should be the id of the textbox
+ you want to be editable.
+ The optional string '.extension' should be the suggested extension
+ for the textfile. Include the dot at the beginning.
+
+ If you don't want your button or menu item to show up when It's All Text!
+ isn't installed, then give it the class "ShowForItsAllText" and set
+ the style (on the element, not in a stylesheet) to none. This only works
+ for nodes in the main document.
Example:
<hbox>
<spacer flex="1"/>
- <button label="It's All Text!" class="ItsAllTextEditButton" style="display: none;" onclick="ItsAllText.openEditor('code');"/>
+ <button label="It's All Text!" class="ShowForItsAllText" style="display: none;" oncommand="ItsAllText.openEditor('code', '.c');"/>
</hbox>
*/
@@ -31,39 +35,31 @@
/* Load up the main It's All Text! file */
var objScriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader);
objScriptLoader.loadSubScript('chrome://itsalltext/content/itsalltext.js');
-
+
var onload = function (event) {
/* Start watching the document, but force it. */
ItsAllText.monitor.watch(document, true);
- /* Turn on all the buttons */
- var nodes = document.getElementsByTagName('button');
- for(var i=0; i < nodes.length; i++) {
- var button = nodes[i];
- if (button.className == "ItsAllTextEditButton") {
- button.style.display = '';
+ /* Turn on all the hidden CSS */
+ var nodes = [];
+ var nodesIter = document.evaluate("//node()[@class]", document, null, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);
+ var node = nodesIter.iterateNext();
+ while (node) {
+ nodes.push(node);
+ node = nodesIter.iterateNext();
+ }
+ for(i in nodes) {
+ node = nodes[i];
+ var classes = node.className.split(/ +/);
+ for(i in classes) {
+ if(classes[i] == "ShowForItsAllText") {
+ node.style.display = '';
+ break;
+ }
}
}
+
};
window.addEventListener("load", onload, true);
-
})();
-/**
- * Use this to open an editor for a specific textarea or textbox with
- * the id 'id'. The file will have the extension 'extension'. Include
- * the leading dot in the extension.
- * @param {String} id The id of textarea or textbody that should be opened in the editor.
- * @param {String} extension The extension of the file used as a temporary file. Example: '.css' (optional)
- */
-ItsAllText.openEditor = function(id, extension) {
- var node = document.getElementById(id);
- /* The only way I can adjust the background of the textbox is
- * to turn off the -moz-appearance attribute.
- */
- node.style.MozAppearance = 'none';
- var cache_object = node && ItsAllText.getCacheObj(node);
- if(!cache_object) { return; }
- cache_object.edit(extension);
-};
-
diff --git a/chrome/content/itsalltext.js b/chrome/content/itsalltext.js
index 8c822cd..b696f01 100644
--- a/chrome/content/itsalltext.js
+++ b/chrome/content/itsalltext.js
@@ -285,6 +285,25 @@ var ItsAllText = function() {
};
/**
+ * This is part of the public XUL API.
+ * Use this to open an editor for a specific textarea or textbox with
+ * the id 'id'. The file will have the extension 'extension'. Include
+ * the leading dot in the extension.
+ * @param {String} id The id of textarea or textbody that should be opened in the editor.
+ * @param {String} extension The extension of the file used as a temporary file. Example: '.css' (optional)
+ */
+ that.openEditor = function(id, extension) {
+ var node = document.getElementById(id);
+ /* The only way I can adjust the background of the textbox is
+ * to turn off the -moz-appearance attribute.
+ */
+ node.style.MozAppearance = 'none';
+ var cache_object = node && ItsAllText.getCacheObj(node);
+ if(!cache_object) { return; }
+ cache_object.edit(extension);
+ };
+
+ /**
* Refresh Textarea.
* @param {Object} node A specific textarea dom object to update.
*/
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/itsalltext.git
More information about the Pkg-mozext-commits
mailing list