Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: chrome/content/composer.js

Issue 29323107: Issue 2816 - Restore Preview functionality (Closed)
Patch Set: Added comment linking to bug report Created July 31, 2015, 3:09 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/content/actor.jsm ('k') | chrome/content/composer.xul » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/content/composer.js
===================================================================
--- a/chrome/content/composer.js
+++ b/chrome/content/composer.js
@@ -3,22 +3,22 @@
* version 2.0 (the "License"). You can obtain a copy of the License at
* http://mozilla.org/MPL/2.0/.
*/
let {Prefs} = require("prefs");
let domainData;
let nodeData;
+let nodeID;
let selectedNode = null;
let advancedMode = false;
let treeView = null;
let stylesheetData;
let previewStyle = null;
-let doc;
let abpURL = Cc["@adblockplus.org/abp/public;1"].getService(Ci.nsIURI);
Cu.import(abpURL.spec);
/*******************
* TreeView object *
*******************/
@@ -79,18 +79,18 @@ function TreeView_getCellProperties(row,
}
/*********************
* General functions *
*********************/
function init()
{
- nodeData = window.arguments[0];
- let host = window.arguments[1];
+ let host;
+ ({host, nodeData, nodeID} = window.arguments[0]);
// Check whether element hiding group is disabled
let subscription = AdblockPlus.getSubscription("~eh~");
if (subscription && subscription.disabled)
{
let warning = document.getElementById("groupDisabledWarning");
if (/\?1\?/.test(warning.textContent))
warning.textContent = warning.textContent.replace(/\?1\?/g, subscription.title);
@@ -306,18 +306,18 @@ function updateExpression()
expression = domainData.selected + "##" + expression;
document.getElementById("expression").value = expression;
var tree = document.getElementById("nodes-tree");
if (tree.view && tree.view.selection)
tree.treeBoxObject.invalidateRow(tree.view.selection.currentIndex);
- if (previewStyle)
- previewStyle.textContent = stylesheetData;
+ if (document.getElementById("preview").checked)
+ togglePreview(true);
}
function escapeChar(dummy, match)
{
return "\\" + match.charCodeAt(0).toString(16) + " ";
}
function fillDomains(domainData) {
@@ -486,39 +486,23 @@ function fillAttributes(nodeData)
if (advancedMode)
{
// Add custom CSS entry
node = createAttribute("advanced", nodeData.customCSS, list.getAttribute("_labelcustom"), nodeData.customCSS.selected);
list.appendChild(node);
}
}
-function togglePreview(preview) {
- if (preview) {
- if (!previewStyle || !previewStyle.parentNode) {
- previewStyle = doc.createElementNS("http://www.w3.org/1999/xhtml", "style");
- previewStyle.setAttribute("type", "text/css");
- doc.documentElement.appendChild(previewStyle);
- }
- previewStyle.textContent = stylesheetData;
- }
- else {
- try
- {
- if (previewStyle && previewStyle.parentNode)
- previewStyle.parentNode.removeChild(previewStyle);
- }
- catch (e)
- {
- // if the window was closed (reloaded) we end up with dead object reference
- // https://bugzilla.mozilla.org/show_bug.cgi?id=695480
- // just ignore this case
- }
- previewStyle = null;
- }
+function togglePreview(preview, forgetNode)
+{
+ Services.mm.broadcastAsyncMessage("ElemHideHelper:Preview", {
+ nodeID: nodeID,
+ stylesheetData: preview ? stylesheetData : null,
+ forgetNode: !!forgetNode
+ });
}
function changeDomain(node) {
domainData.selected = node.getAttribute("value");
updateExpression();
}
function toggleAttr(node) {
« no previous file with comments | « chrome/content/actor.jsm ('k') | chrome/content/composer.xul » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld