[Pkg-mozext-commits] [adblock-plus-element-hiding-helper] 471/483: Issue 1091 - Implement a better templating approach for Element Hiding Helper
David Prévot
taffit at moszumanska.debian.org
Thu Jan 22 21:42:08 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository adblock-plus-element-hiding-helper.
commit ad6530b3b120a85518e9bff0f905426462696f0d
Author: Wladimir Palant <trev at adblockplus.org>
Date: Mon Jul 21 21:25:47 2014 +0200
Issue 1091 - Implement a better templating approach for Element Hiding Helper
--HG--
extra : rebase_source : 525fef9d356da789f210e741f6fad29314d85905
extra : amend_source : 38b566403ef3034052e5d2584929f42d2268aa9f
---
chrome/content/overlay.xul | 6 ------
lib/aardvark.js | 25 ++++++++++++++++++++++++-
lib/main.js | 3 ++-
lib/windowWrapper.js | 4 +---
4 files changed, 27 insertions(+), 11 deletions(-)
diff --git a/chrome/content/overlay.xul b/chrome/content/overlay.xul
index 1d231a2..307b8b0 100644
--- a/chrome/content/overlay.xul
+++ b/chrome/content/overlay.xul
@@ -28,10 +28,4 @@
</hbox>
</tooltip>
<tooltip id="ehh-viewsource" noautohide="true" orient="vertical"/>
- <tooltip id="ehh-elementmarker">
- <html:div>
- <html:div class="ehh-border"/>
- <html:div class="ehh-label"><html:span class="ehh-labelTag"/><html:span class="ehh-labelAddition"/></html:div>
- </html:div>
- </tooltip>
</popupset>
diff --git a/lib/aardvark.js b/lib/aardvark.js
index 52c5727..c36e33c 100644
--- a/lib/aardvark.js
+++ b/lib/aardvark.js
@@ -12,6 +12,22 @@ onShutdown.add(function() Aardvark.quit());
// To be replaced when selection starts
function E(id) {return null;}
+/*********************************
+ * Minimal element creation code *
+ *********************************/
+
+function createElement(doc, tagName, attrs, children)
+{
+ let el = doc.createElement(tagName);
+ if (attrs)
+ for (let key in attrs)
+ el.setAttribute(key, attrs[key]);
+ if (children)
+ for (let child of children)
+ el.appendChild(child)
+ return el;
+};
+
/**********************************
* General element selection code *
**********************************/
@@ -56,7 +72,14 @@ let Aardvark = exports.Aardvark =
this.browser.contentWindow.focus();
let doc = this.browser.contentDocument;
- this.boxElem = doc.importNode(E("ehh-elementmarker").firstElementChild.cloneNode(true), true);
+ let {elementMarkerClass} = require("main");
+ this.boxElem = createElement(doc, "div", {"class": elementMarkerClass}, [
+ createElement(doc, "div", {"class": "ehh-border"}),
+ createElement(doc, "div", {"class": "ehh-label"}, [
+ createElement(doc, "span", {"class": "ehh-labelTag"}),
+ createElement(doc, "span", {"class": "ehh-labelAddition"})
+ ])
+ ]);
this.initHelpBox();
diff --git a/lib/main.js b/lib/main.js
index ab7db39..c46480e 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -33,6 +33,7 @@ let elementMarkerClass = null;
elementMarkerClass = String.fromCharCode.apply(String, rnd);
}
+exports.elementMarkerClass = elementMarkerClass;
// Load CSS asynchronously
let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest);
@@ -75,7 +76,7 @@ request.addEventListener("load", function(event)
let style = window.document.createProcessingInstruction("xml-stylesheet", 'class="elemhidehelper-node" href="chrome://elemhidehelper/skin/overlay.css" type="text/css"');
window.document.insertBefore(style, window.document.firstChild);
- window._ehhWrapper = new WindowWrapper(window, elementMarkerClass);
+ window._ehhWrapper = new WindowWrapper(window);
},
removeFromWindow: function(window)
diff --git a/lib/windowWrapper.js b/lib/windowWrapper.js
index fa0aacd..7157a91 100644
--- a/lib/windowWrapper.js
+++ b/lib/windowWrapper.js
@@ -21,7 +21,7 @@ function getMenuItem()
}
exports.WindowWrapper = WindowWrapper;
-function WindowWrapper(wnd, elementMarkerClass)
+function WindowWrapper(wnd)
{
this.window = wnd;
@@ -31,8 +31,6 @@ function WindowWrapper(wnd, elementMarkerClass)
this.toggleSelection = this.toggleSelection.bind(this);
this.hideTooltips = this.hideTooltips.bind(this);
- this.E("ehh-elementmarker").firstElementChild.setAttribute("class", elementMarkerClass);
-
this.init();
}
WindowWrapper.prototype =
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus-element-hiding-helper.git
More information about the Pkg-mozext-commits
mailing list