[Pkg-mozext-commits] [adblock-plus-element-hiding-helper] 38/483: Show warning when required ABP version is not installed
David Prévot
taffit at moszumanska.debian.org
Thu Jan 22 21:41:24 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 a6d8ad9405f9f1093d61126b8fd0c4b0e1f9d10e
Author: Wladimir Palant <trev at gtchat.de>
Date: Wed Jan 17 23:25:02 2007 +0000
Show warning when required ABP version is not installed
--HG--
extra : convert_revision : svn%3Ad8bf93c1-8190-44a8-bb31-1ea94378a4df/trunk%40638
---
chrome/content/composer.xul | 1 +
chrome/content/overlay.js | 71 ++++++++++++++++++++++++++++++++--
chrome/locale/en-US/composer.dtd | 1 +
chrome/locale/en-US/global.properties | 4 ++
defaults/preferences/elemhidehelper.js | 1 +
5 files changed, 74 insertions(+), 4 deletions(-)
diff --git a/chrome/content/composer.xul b/chrome/content/composer.xul
index 82dcf6e..386f2eb 100644
--- a/chrome/content/composer.xul
+++ b/chrome/content/composer.xul
@@ -80,6 +80,7 @@
<scrollbox id="attributes-list" orient="vertical" flex="1"
_labeltagname="&attributes.tagname.label;"
_labelfirstchild="&attributes.firstchild.label;"
+ _labellastchild="&attributes.lastchild.label;"
_labelcustom="&attributes.custom.label;"/>
</hbox>
</groupbox>
diff --git a/chrome/content/overlay.js b/chrome/content/overlay.js
index 7e51f40..1b52206 100644
--- a/chrome/content/overlay.js
+++ b/chrome/content/overlay.js
@@ -25,6 +25,72 @@
window.addEventListener("load", ehhInit, false);
function ehhInit() {
+ var prefService = Components.classes["@mozilla.org/preferences-service;1"]
+ .getService(Components.interfaces.nsIPrefService);
+ var branch = prefService.getBranch("extensions.adblockplus.");
+
+ // Check whether ABP is installed and has at least the required version
+ var requiredVersion = "0.7.2.3";
+ var installedVersion = "0";
+ try {
+ var abp = Components.classes["@mozilla.org/adblockplus;1"]
+ .createInstance(Components.interfaces.nsIAdblockPlus);
+ installedVersion = abp.getInstalledVersion();
+ } catch(e) {}
+
+ var parts1 = requiredVersion.split(".");
+ var parts2 = installedVersion.split(".");
+ var mustUpdate = false;
+ for (var i = 0; i < parts1.length; i++) {
+ if (parts2.length <= i || parseInt(parts1[i]) > parseInt(parts2[i])) {
+ mustUpdate = true;
+ break;
+ }
+ if (parseInt(parts1[i]) < parseInt(parts2[i]))
+ break;
+ }
+
+ // Show warning about required ABP update if necessary
+ if (mustUpdate) {
+ var noWarning = {value: false};
+ try {
+ noWarning.value = branch.getBoolPref("ehh.norequirementswarning");
+ } catch(e) {}
+
+ if (!noWarning.value) {
+ // Make sure we don't show the warning twice
+ var hiddenWnd = Components.classes["@mozilla.org/appshell/appShellService;1"]
+ .getService(Components.interfaces.nsIAppShellService)
+ .hiddenDOMWindow;
+ if ("ehhNoRequirementsWarning" in hiddenWnd)
+ noWarning.value = true;
+ else
+ hiddenWnd.ehhNoRequirementsWarning = true;
+ }
+
+ if (!noWarning.value) {
+ setTimeout(function() {
+ var stringService = Components.classes["@mozilla.org/intl/stringbundle;1"]
+ .getService(Components.interfaces.nsIStringBundleService);
+ var strings = stringService.createBundle("chrome://elemhidehelper/locale/global.properties");
+ var promptService = Components.classes['@mozilla.org/embedcomp/prompt-service;1']
+ .getService(Components.interfaces.nsIPromptService);
+ promptService.alertCheck(window,
+ strings.GetStringFromName("noabp_warning_title"),
+ strings.formatStringFromName("noabp_warning_text", [requiredVersion], 1),
+ strings.GetStringFromName("noabp_warning_disable"),
+ noWarning);
+
+ if (noWarning.value) {
+ try {
+ branch.setBoolPref("ehh.norequirementswarning", true);
+ } catch(e) {}
+ }
+ }, 0);
+ }
+ return;
+ }
+
if (document.getElementById("abp-status-popup"))
document.getElementById("abp-status-popup").addEventListener("popupshowing", ehhFillPopup, false);
if (document.getElementById("abp-toolbar-popup"))
@@ -33,9 +99,6 @@ function ehhInit() {
ehhGetBrowser().addEventListener("select", ehhStop, false);
// Make sure we configure the shortcut key even if the default pref isn't there
- var prefService = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefService);
- var branch = prefService.getBranch("extensions.adblockplus.");
if (window.abpConfigureKey) {
var defaultBranch = prefService.getDefaultBranch("extensions.adblockplus.");
try {
@@ -54,7 +117,7 @@ function ehhInit() {
// Make sure chrome protection works in SeaMonkey
if (branch.getPrefType("protectchrome.ehh") != branch.PREF_STRING) {
try {
- key = branch.setCharPref("protectchrome.ehh", "elemhidehelper");
+ branch.setCharPref("protectchrome.ehh", "elemhidehelper");
} catch(e) {}
}
}
diff --git a/chrome/locale/en-US/composer.dtd b/chrome/locale/en-US/composer.dtd
index b799b11..81c6386 100644
--- a/chrome/locale/en-US/composer.dtd
+++ b/chrome/locale/en-US/composer.dtd
@@ -36,4 +36,5 @@
<!ENTITY attributes.label "Require attributes">
<!ENTITY attributes.tagname.label "Tag name:">
<!ENTITY attributes.firstchild.label "First child">
+<!ENTITY attributes.lastchild.label "Last child">
<!ENTITY attributes.custom.label "Custom CSS:">
diff --git a/chrome/locale/en-US/global.properties b/chrome/locale/en-US/global.properties
index 9b98716..0c5d2d3 100644
--- a/chrome/locale/en-US/global.properties
+++ b/chrome/locale/en-US/global.properties
@@ -14,3 +14,7 @@ command.viewSourceWindow.key=u
command.viewSourceWindow.label=view source (in separate window)
command.showMenu.key=h
command.showMenu.label=show/hide help
+
+noabp_warning_title=Element Hiding Helper
+noabp_warning_text=The extension Element Hiding Helper you installed requires Adblock Plus %S or higher. Please install or update Adblock Plus, until then Element Hiding Helper will remain inactive.
+noabp_warning_disable=Do not show this warning again
diff --git a/defaults/preferences/elemhidehelper.js b/defaults/preferences/elemhidehelper.js
index e7ac493..9d5eef0 100644
--- a/defaults/preferences/elemhidehelper.js
+++ b/defaults/preferences/elemhidehelper.js
@@ -1,2 +1,3 @@
pref("extensions.adblockplus.ehh-selectelement_key", "Accel Shift H");
pref("extensions.adblockplus.protectchrome.ehh", "elemhidehelper");
+pref("extensions.adblockplus.ehh.norequirementswarning", false);
--
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