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

Unified Diff: lib/elemHide.js

Issue 6751077990924288: Issue 2161 - Add an option for disabling element hiding filters (Closed)
Patch Set: Don't even add filters when disabled Created June 17, 2015, 10:41 a.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 | « defaults/prefs.json ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/elemHide.js
===================================================================
--- a/lib/elemHide.js
+++ b/lib/elemHide.js
@@ -78,17 +78,17 @@ let ElemHide = exports.ElemHide =
/**
* Called on module startup.
*/
init: function()
{
Prefs.addListener(function(name)
{
- if (name == "enabled")
+ if (name == "enabled" || name == "element_hiding_enabled")
ElemHide.apply();
});
onShutdown.add(function()
{
ElemHide.unapply();
});
let styleFile = IO.resolveFilePath(Prefs.data_directory);
@@ -110,16 +110,19 @@ let ElemHide = exports.ElemHide =
},
/**
* Add a new element hiding filter
* @param {ElemHideFilter} filter
*/
add: function(filter)
{
+ if (!Prefs.element_hiding_enabled)
+ return;
+
if (filter instanceof ElemHideException)
{
if (filter.text in knownExceptions)
return;
let selector = filter.selector;
if (!(selector in exceptions))
exceptions[selector] = [];
@@ -207,32 +210,34 @@ let ElemHide = exports.ElemHide =
apply: function()
{
if (this._applying)
{
this._needsApply = true;
return;
}
- if (!ElemHide.isDirty || !Prefs.enabled)
+ let enabled = Prefs.enabled && Prefs.element_hiding_enabled;
+
+ if (!ElemHide.isDirty || !enabled)
{
// Nothing changed, looks like we merely got enabled/disabled
- if (Prefs.enabled && !ElemHide.applied)
+ if (enabled && !ElemHide.applied)
{
try
{
Utils.styleService.loadAndRegisterSheet(styleURL, Ci.nsIStyleSheetService.USER_SHEET);
ElemHide.applied = true;
}
catch (e)
{
Cu.reportError(e);
}
}
- else if (!Prefs.enabled && ElemHide.applied)
+ else if (!enabled && ElemHide.applied)
{
ElemHide.unapply();
}
return;
}
IO.writeToFile(styleURL.file, this._generateCSSContent(), function(e)
« no previous file with comments | « defaults/prefs.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld