[Pkg-mozext-commits] [adblock-plus-element-hiding-helper] 11/483: Add custom CSS field and fix tree selection when switching to advanced mode
David Prévot
taffit at moszumanska.debian.org
Thu Jan 22 21:41:22 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 32f370789577615f7bcd3f7f063d9c8235d2e122
Author: Wladimir Palant <trev at gtchat.de>
Date: Mon Jan 8 19:29:44 2007 +0000
Add custom CSS field and fix tree selection when switching to advanced mode
--HG--
extra : convert_revision : svn%3Ad8bf93c1-8190-44a8-bb31-1ea94378a4df/trunk%40608
---
chrome/content/composer.js | 55 ++++++++++++++++++++++++++++------------
chrome/content/composer.xul | 4 +++
chrome/locale/en-US/composer.dtd | 1 +
chrome/skin/classic/composer.css | 3 ++-
4 files changed, 46 insertions(+), 17 deletions(-)
diff --git a/chrome/content/composer.js b/chrome/content/composer.js
index 422f58c..e94deb1 100644
--- a/chrome/content/composer.js
+++ b/chrome/content/composer.js
@@ -235,7 +235,6 @@ function fillDomains(domainData) {
function fillNodes(nodeData) {
var curContainer = document.createElement("treechildren");
var curChildren = null;
- var selectedItem = null;
while (nodeData) {
var id = "";
var className = "";
@@ -262,8 +261,7 @@ function fillNodes(nodeData) {
item.appendChild(row);
item.nodeData = nodeData;
- if (!selectedItem)
- selectedItem = item;
+ nodeData.treeItem = item;
if (curChildren) {
item.appendChild(curChildren);
@@ -292,25 +290,23 @@ function fillNodes(nodeData) {
var body = document.getElementById("nodes-tree-children");
while (curContainer.firstChild)
body.appendChild(curContainer.firstChild);
-
- // Select current item
- if (selectedItem) {
- var selectedIndex = tree.view.getIndexOfItem(selectedItem);
- tree.treeBoxObject.ensureRowIsVisible(selectedIndex);
- tree.view.selection.select(selectedIndex);
- }
}
function fillAttributes(nodeData) {
var template = document.getElementById("attribute-template");
+ var customCSS = document.getElementById("attribute-custom");
+ var customCSSCheck = document.getElementById("attribute-custom-check");
+ var customCSSField = document.getElementById("attribute-custom-field");
selectedNode = nodeData;
- // Remove everything but our template
- var child = template.parentNode.firstChild;
+ // Remove everything between our template and the custom CSS field
+ var child = template.nextSibling;
while (child) {
var nextChild = child.nextSibling;
- if (child != template)
- template.parentNode.removeChild(child);
+ if (child == customCSS)
+ break;
+
+ child.parentNode.removeChild(child);
child = nextChild;
}
@@ -319,7 +315,7 @@ function fillAttributes(nodeData) {
node.hidden = false;
node.setAttribute("label", node.getAttribute("label") + " " + nodeData.tagName.value);
node.setAttribute("checked", nodeData.tagName.checked);
- template.parentNode.appendChild(node);
+ template.parentNode.insertBefore(node, customCSS);
// Add attribute checkboxes
for (var i = 0; i < nodeData.attributes.length; i++) {
@@ -330,8 +326,12 @@ function fillAttributes(nodeData) {
node.setAttribute("label", attr.name + ": " + attr.value);
node.setAttribute("checked", attr.checked);
node.setAttribute("value", attr.name);
- template.parentNode.appendChild(node);
+ template.parentNode.insertBefore(node, customCSS);
}
+
+ // Initialize custom CSS field
+ customCSSCheck.setAttribute("checked", nodeData.customCSS.checked);
+ customCSSField.value = nodeData.customCSS.selected;
}
function changeDomain(node) {
@@ -355,6 +355,23 @@ function toggleAttr(node) {
updateExpression();
}
+function toggleCustomCSS(node) {
+ if (selectedNode == null)
+ return;
+
+ selectedNode.customCSS.checked = node.checked;
+ updateExpression();
+}
+
+function setCustomCSS(customCSS) {
+ if (selectedNode == null)
+ return;
+
+ selectedNode.customCSS.selected = customCSS;
+ if (selectedNode.customCSS.checked)
+ updateExpression();
+}
+
function setAdvancedMode(mode) {
advancedMode = mode;
@@ -365,6 +382,12 @@ function setAdvancedMode(mode) {
button.setAttribute("label", dialog.getAttribute(advancedMode ? "buttonlabeldisclosure_off" : "buttonlabeldisclosure_on"));
fillAttributes(nodeData);
+
+ if (advancedMode && selectedNode) {
+ var tree = document.getElementById("nodes-tree");
+ var index = tree.view.getIndexOfItem(selectedNode.treeItem);
+ tree.view.selection.select(index);
+ }
}
function updateNodeSelection() {
diff --git a/chrome/content/composer.xul b/chrome/content/composer.xul
index 6f7cdf5..9640ea1 100644
--- a/chrome/content/composer.xul
+++ b/chrome/content/composer.xul
@@ -76,6 +76,10 @@
<splitter id="nodes-tree-splitter"/>
<scrollbox flex="1" orient="vertical">
<checkbox id="attribute-template" label="&attributes.tagname.label;" hidden="true" oncommand="toggleAttr(this)"/>
+ <hbox id="attribute-custom">
+ <checkbox id="attribute-custom-check" label="&attributes.custom.label;" oncommand="toggleCustomCSS(this)"/>
+ <textbox id="attribute-custom-field" flex="1" oninput="setCustomCSS(this.value)"/>
+ </hbox>
</scrollbox>
</groupbox>
</hbox>
diff --git a/chrome/locale/en-US/composer.dtd b/chrome/locale/en-US/composer.dtd
index 5dbe919..613aa42 100644
--- a/chrome/locale/en-US/composer.dtd
+++ b/chrome/locale/en-US/composer.dtd
@@ -34,3 +34,4 @@
<!ENTITY nodes-tree.class.label "class">
<!ENTITY attributes.label "Require attributes">
<!ENTITY attributes.tagname.label "Tag name:">
+<!ENTITY attributes.custom.label "Custom CSS:">
diff --git a/chrome/skin/classic/composer.css b/chrome/skin/classic/composer.css
index a576b21..85f44e7 100644
--- a/chrome/skin/classic/composer.css
+++ b/chrome/skin/classic/composer.css
@@ -30,7 +30,8 @@ scrollbox
}
dialog:not([advancedMode=true]) #nodes-tree,
-dialog:not([advancedMode=true]) #nodes-tree-splitter
+dialog:not([advancedMode=true]) #nodes-tree-splitter,
+dialog:not([advancedMode=true]) #attribute-custom
{
display: none;
}
--
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