[Pkg-mozext-commits] [nosquint] 02/47: Import of 0.9.1 release into git
David Prévot
taffit at moszumanska.debian.org
Tue Apr 28 01:41:16 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to annotated tag 2.1.6
in repository nosquint.
commit 52463cc51b2fe03bf5bb24f329e18ae19cf9239e
Author: Jason Tackaberry <tack at urandom.ca>
Date: Fri Jan 13 19:41:13 2012 -0500
Import of 0.9.1 release into git
---
src/content/icon-32.png | Bin 0 -> 2418 bytes
src/content/init.js | 5 +-
src/content/nosquint.js | 91 +++++++++++++++++++++++++----------
src/content/overlay.xul | 2 +-
src/content/prefs.css | 22 +++++++++
src/content/prefs.js | 24 +++++++++
src/content/prefs.xul | 78 ++++++++++++++++++++++++++----
src/defaults/preferences/nosquint.js | 1 +
src/install.rdf | 5 +-
src/locale/en-US/prefs.dtd | 14 ++++--
10 files changed, 198 insertions(+), 44 deletions(-)
diff --git a/src/content/icon-32.png b/src/content/icon-32.png
new file mode 100644
index 0000000..b465a31
Binary files /dev/null and b/src/content/icon-32.png differ
diff --git a/src/content/init.js b/src/content/init.js
index e4d0367..a3f8dde 100644
--- a/src/content/init.js
+++ b/src/content/init.js
@@ -8,11 +8,12 @@ ZoomManager.prototype.getInstance().reset = function() {
}
ZoomManager.prototype.getInstance().enlarge = function() {
- ZoomManager.prototype.getInstance().textZoom += 10;
+ // FIXME: do we want to update any other tabs of pages in this domain?
+ ZoomManager.prototype.getInstance().textZoom += NoSquint.zoomIncrement;
NoSquint.saveCurrentZoom();
}
ZoomManager.prototype.getInstance().reduce = function() {
- ZoomManager.prototype.getInstance().textZoom -= 10;
+ ZoomManager.prototype.getInstance().textZoom -= NoSquint.zoomIncrement;
NoSquint.saveCurrentZoom();
}
diff --git a/src/content/nosquint.js b/src/content/nosquint.js
index c856a49..e02dce8 100644
--- a/src/content/nosquint.js
+++ b/src/content/nosquint.js
@@ -1,3 +1,8 @@
+var SLDs = [
+ "ac.uk", "co.uk", "gov.uk", "ltd.uk", "me.uk", "mod.uk", "net.uk",
+ "nic.uk", "nhs.uk", "org.uk", "plc.uk", "police.uk", "sch.uk"
+];
+
var NoSquint = {
prefs: null,
@@ -14,6 +19,7 @@ var NoSquint = {
// Prefs
domains: {},
defaultZoomLevel: 120,
+ zoomIncrement: 10,
rememberDomains: true,
wheelZoomEnabled: true,
wheelActionSave: -1,
@@ -51,7 +57,7 @@ var NoSquint = {
NoSquint.listeners = [];
// Unregister the event listeners setup during init.
NoSquint.tabbrowser.removeEventListener("DOMNodeInserted", NoSquint.handleNewBrowser, false);
- window.removeEventListener("DOMMouseScroll", NoSquint.handleScrollWheel, false);
+ //window.removeEventListener("DOMMouseScroll", NoSquint.handleScrollWheel, false);
},
handleScrollWheel: function(event) {
@@ -74,7 +80,14 @@ var NoSquint = {
},
getDomainFromHost: function(host) {
- return host.replace(/^.*?([^.]*\.[^.]*$)/, "$1");
+ var domain = host.replace(/^.*?([^.]*\.[^.]*$)/, "$1");
+ // Check second-level domains list, if domain is one of these, then
+ // return third-level domain instead.
+ for (var n in SLDs) {
+ if (domain == SLDs[n])
+ return host.replace(/^.*?([^.]*\.[^.]*\.[^.]*$)/, "$1");
+ }
+ return domain;
},
handleNewBrowser: function(event) {
@@ -92,7 +105,15 @@ var NoSquint = {
//alert("Create new listener");
NoSquint.listeners[NoSquint.listeners.length] = listener;
last.addProgressListener(listener, Components.interfaces.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
- //window.setTimeout(function() { NoSquint.zoom(last, null); }, 1);
+
+ /* Sometimes the onLocationChange handler of the ProgressListener will
+ * get fired, and sometimes it won't. My best guess is this is a
+ * race condition, and the location sometimes gets changed before we
+ * attach the ProgressListener. So we call NoSquint.zoom() on this
+ * browser explicitly for this initial page, rather than rely on the
+ * progress handler.
+ */
+ window.setTimeout(function() { NoSquint.zoom(last, null); }, 1);
},
handleRemoveBrowser: function(event) {
@@ -114,24 +135,16 @@ var NoSquint = {
zoom: function(node, domain) {
if (!node)
return;
-
if (domain == null && node.currentURI)
domain = NoSquint.getDomainFromHost(node.currentURI.asciiHost);
- try {
- if (!domain)
- throw "blah";
- if (!NoSquint.domains[domain] || !NoSquint.rememberDomains)
- level = NoSquint.defaultZoomLevel;
- else
- level = NoSquint.domains[domain];
-
- //alert("Set zoom for host: " + host + " -- " + level + " -- " + NoSquint.rememberDomains);
- if (node.markupDocumentViewer.textZoom != level / 100.0)
- node.markupDocumentViewer.textZoom = level / 100.0;
- } catch(ex) {
- window.setTimeout(function() { NoSquint.zoom(node, domain); }, 100);
- }
+ if (!domain || !NoSquint.domains[domain] || !NoSquint.rememberDomains)
+ level = NoSquint.defaultZoomLevel;
+ else
+ level = NoSquint.domains[domain];
+
+ //alert("Set zoom for host: " + node + " -- " + domain + " -- " + level + " -- " + NoSquint.rememberDomains + " -- " + node.markupDocumentViewer.textZoom);
+ node.markupDocumentViewer.textZoom = level / 100.0;
},
zoomAll: function() {
@@ -147,7 +160,14 @@ var NoSquint = {
},
onMenuItemCommand: function() {
- window.openDialog("chrome://nosquint/content/prefs.xul", "", "chrome");
+ var browser = NoSquint.getCurrentBrowser();
+ var domain = NoSquint.getDomainFromHost(browser.currentURI.asciiHost);
+ var level;
+ if (domain && NoSquint.domains[domain])
+ level = NoSquint.domains[domain];
+ else
+ level = "default";
+ window.openDialog("chrome://nosquint/content/prefs.xul", "", "chrome", domain, level);
},
initPrefs: function() {
@@ -161,6 +181,8 @@ var NoSquint = {
try { NoSquint.prefs.getIntPref("zoomlevel"); }
catch (err) { NoSquint.prefs.setIntPref("zoomlevel", NoSquint.defaultZoomLevel); }
+ try { NoSquint.prefs.getIntPref("zoomIncrement"); }
+ catch (err) { NoSquint.prefs.setIntPref("zoomIncrement", NoSquint.zoomIncrement); }
try { NoSquint.prefs.getCharPref("domains"); }
catch (err) { NoSquint.prefs.setCharPref("domains", ""); }
@@ -187,16 +209,31 @@ var NoSquint = {
initPrefsDialog: function(doc) {
NoSquint.initPrefs();
doc.getElementById("defaultZoomLevel").value = NoSquint.defaultZoomLevel;
- doc.getElementById("rememberDomains").selectedIndex = NoSquint.rememberDomains ? 0 : 1;
- //doc.getElementById("wheelZoomEnabled").checked = NoSquint.wheelZoomEnabled;
+ doc.getElementById("zoomIncrement").value = NoSquint.zoomIncrement;
+ doc.getElementById("rememberDomains").selectedIndex = NoSquint.rememberDomains ? 1 : 0;
},
savePrefs: function(doc) {
if (doc) {
NoSquint.prefs.setIntPref("zoomlevel", doc.getElementById("defaultZoomLevel").value);
- var val = doc.getElementById("rememberDomains").selectedIndex == 0 ? true : false;
+ NoSquint.prefs.setIntPref("zoomIncrement", doc.getElementById("zoomIncrement").value);
+ var val = doc.getElementById("rememberDomains").selectedIndex == 0 ? false : true;
NoSquint.prefs.setBoolPref("rememberDomains", val);
- //NoSquint.prefs.setBoolPref("wheelZoomEnabled", doc.getElementById("wheelZoomEnabled").checked);
+ if (window.arguments && window.arguments[0]) {
+ var domain = window.arguments[0];
+ var level = doc.getElementById("domainZoom").value;
+ var domains = NoSquint.prefs.getCharPref("domains");
+ var re = new RegExp(domain + "\\b=\\d+\\b", "ig");
+ if (level == "default")
+ domains = domains.replace(re, "");
+ else if (domains.search(domain + "=") != -1)
+ domains = domains.replace(re, domain + "=" + level);
+ else
+ domains += " " + domain + "=" + level;
+
+ domains = domains.replace(/ +/g, " ");
+ NoSquint.prefs.setCharPref("domains", domains);
+ }
return;
}
@@ -217,22 +254,26 @@ var NoSquint = {
return;
}
NoSquint.defaultZoomLevel = NoSquint.prefs.getIntPref("zoomlevel");
+ NoSquint.zoomIncrement = NoSquint.prefs.getIntPref("zoomIncrement");
NoSquint.wheelZoomEnabled = NoSquint.prefs.getBoolPref("wheelZoomEnabled");
// TODO: if rememberDomains has been changed from false to true, iterate
// over current browsers and remember current zoom levels for these windows.
NoSquint.rememberDomains = NoSquint.prefs.getBoolPref("rememberDomains");
var domainList = NoSquint.prefs.getCharPref("domains");
- var domains = domainList.split(" ");
+ var domains = domainList.replace(/(^\s+|\s+$)/g, "").split(" ");
+ //var domains = domainList.split(" ");
NoSquint.domains = {};
for (var i = 0; i < domains.length; i++) {
var domain = domains[i].split("=");
+ if (domain.length != 2)
+ continue; // malformed
NoSquint.domains[domain[0]] = parseInt(domain[1]);
}
NoSquint.zoomAll();
},
locationChanged: function(browser, uri) {
- NoSquint.zoom(browser, NoSquint.getDomainFromHost(uri.asciiHost));
+ window.setTimeout(function() { NoSquint.zoom(browser, NoSquint.getDomainFromHost(uri.asciiHost)); }, 1);
},
saveCurrentZoom: function() {
diff --git a/src/content/overlay.xul b/src/content/overlay.xul
index e6287be..e2930aa 100644
--- a/src/content/overlay.xul
+++ b/src/content/overlay.xul
@@ -6,7 +6,7 @@
<menupopup id="menu_ToolsPopup">
<menuitem id="nosquint-menuitem" label="&nosquint;" oncommand="NoSquint.onMenuItemCommand(event);"
- insertbefore="devToolsSeparator" />
+ insertafter="devToolsSeparator" />
</menupopup>
</overlay>
diff --git a/src/content/prefs.css b/src/content/prefs.css
new file mode 100644
index 0000000..5d70b8f
--- /dev/null
+++ b/src/content/prefs.css
@@ -0,0 +1,22 @@
+dialog {
+ max-width: 35em;
+}
+
+label.percent {
+ margin-left: -0.18em;
+}
+
+.tip {
+ margin-left: 4.7em;
+ margin-bottom: 1.0em;
+ margin-right: 0.5em;
+ color: #666;
+}
+
+.indent {
+ margin-left: 2.5em;
+}
+
+#domainZoom-button {
+ margin-bottom: 0.75em;
+}
diff --git a/src/content/prefs.js b/src/content/prefs.js
new file mode 100644
index 0000000..6b022f6
--- /dev/null
+++ b/src/content/prefs.js
@@ -0,0 +1,24 @@
+function domains_rb_select(doc) {
+ var label = doc.getElementById("domainZoom-label");
+ if (!window.arguments || window.arguments[0] == "") {
+ if (label.value.search("\\(") == -1)
+ label.value = label.value.replace(":", " ([no domain in URL])");
+ return;
+ }
+ var box = doc.getElementById("domainZoom-box");
+ var disabled = doc.getElementById("rememberDomains").selectedIndex == 0;
+ if (label.value.search("\\(") == -1) {
+ label.value = label.value.replace(":", " (" + window.arguments[0] + "):");
+ doc.getElementById("domainZoom").value = window.arguments[1];
+ }
+
+ for (i = 0; i < box.childNodes.length; i++)
+ box.childNodes[i].disabled = disabled;
+ doc.getElementById("domainZoom-button").disabled = disabled;
+ //doc.getElementById("domainZoom-grid").hidden = false;
+}
+
+function domains_use_default(doc) {
+ window.arguments[1] = "default";
+ doc.getElementById("domainZoom").value = "default";
+}
diff --git a/src/content/prefs.xul b/src/content/prefs.xul
index 17960d2..be25a58 100644
--- a/src/content/prefs.xul
+++ b/src/content/prefs.xul
@@ -1,23 +1,81 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
+<?xml-stylesheet href="chrome://nosquint/content/prefs.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://nosquint/locale/prefs.dtd">
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
- title="&title.label;"
+ xmlns:html="http://www.w3.org/1999/xhtml"
+ title="&ns.pref.title;"
buttons="accept,cancel"
ondialogaccept="NoSquint.savePrefs(document)"
persist="screenX screenY"
onload="NoSquint.initPrefsDialog(document)">
<script src="nosquint.js" />
+ <script src="prefs.js" />
- <hbox align="center">
- <description flex="0">&level.label;</description>
- <textbox id="defaultZoomLevel" size="5"/>
- <description flex="0">%</description>
- </hbox>
- <radiogroup id="rememberDomains">
- <radio label="&rememberDomains;" />
- <radio label="&noRememberDomains;" />
- </radiogroup>
+ <groupbox id="global">
+ <caption label="&ns.pref.globalbox.label;" />
+ <!-- XUL's grid container doesn't quite cut it. -->
+ <html:table cellspacing="0" cellpadding="0" border="0">
+ <html:tr>
+ <html:td align="right" style="white-space: nowrap;">
+ <label>&ns.pref.level.label;:</label>
+ </html:td>
+ <html:td width="100%">
+ <hbox align="center">
+ <textbox id="defaultZoomLevel" size="5"/>
+ <label class="percent">%</label>
+ </hbox>
+ </html:td>
+ </html:tr>
+ <html:tr>
+ <html:td colspan="2" width="100%">
+ <html:div class="tip">&ns.pref.level.tip;</html:div>
+ </html:td>
+ </html:tr>
+ <html:tr>
+ <html:td align="right" style="white-space: nowrap;">
+ <label>&ns.pref.increment.label;:</label>
+ </html:td>
+ <html:td width="100%">
+ <hbox align="center">
+ <textbox id="zoomIncrement" size="5"/>
+ <label class="percent">%</label>
+ </hbox>
+ </html:td>
+ </html:tr>
+ <html:tr>
+ <html:td colspan="2" width="100%">
+ <html:div class="tip">&ns.pref.increment.tip;</html:div>
+ </html:td>
+ </html:tr>
+ </html:table>
+ </groupbox>
+
+ <groupbox id="domain">
+ <caption label="&ns.pref.domainbox.label;" />
+ <radiogroup id="rememberDomains" onselect="domains_rb_select(document)">
+ <radio label="&ns.pref.noRememberDomains;" />
+ <radio label="&ns.pref.rememberDomains;" />
+ </radiogroup>
+ <grid id="domainZoom-grid" class="indent">
+ <columns>
+ <column />
+ <column />
+ <column />
+ </columns>
+ <rows>
+ <row align="center" id="domainZoom-box">
+ <label disabled="true" id="domainZoom-label" value="&ns.pref.domainZoom.label;:" />
+ <textbox disabled="true" id="domainZoom" size="5"/>
+ <label disabled="true" class="percent">%</label>
+ </row>
+ <row>
+ <label />
+ <button disabled="true" label="Use Default" id="domainZoom-button" onclick="domains_use_default(document)" />
+ </row>
+ </rows>
+ </grid>
+ </groupbox>
</dialog>
diff --git a/src/defaults/preferences/nosquint.js b/src/defaults/preferences/nosquint.js
index 8f09068..9980b33 100644
--- a/src/defaults/preferences/nosquint.js
+++ b/src/defaults/preferences/nosquint.js
@@ -1,4 +1,5 @@
pref("extensions.nosquint.zoomlevel", 120);
+pref("extensions.nosquint.zoomIncrement", 10);
pref("extensions.nosquint.rememberDomains", true);
pref("extensions.nosquint.domains", "");
pref("extensions.nosquint.wheelZoomEnabled", true);
diff --git a/src/install.rdf b/src/install.rdf
index 4487aa6..a89bb7f 100644
--- a/src/install.rdf
+++ b/src/install.rdf
@@ -6,19 +6,20 @@
<em:id>nosquint at urandom.ca</em:id>
<em:name>No Squint</em:name>
- <em:version>0.9.0</em:version>
+ <em:version>0.9.1</em:version>
<em:description>Zooms text by user-configurable percentage</em:description>
<em:creator>Jason Tackaberry</em:creator>
<em:homepageURL>http://urandom.ca/nosquint/</em:homepageURL>
<em:optionsURL>chrome://nosquint/content/prefs.xul</em:optionsURL>
+ <em:iconURL>chrome://nosquint/content/icon-32.png</em:iconURL>
<!-- Firefox -->
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>1.5</em:minVersion>
- <em:maxVersion>1.5.0.*</em:maxVersion>
+ <em:maxVersion>2.0b2</em:maxVersion>
</Description>
</em:targetApplication>
diff --git a/src/locale/en-US/prefs.dtd b/src/locale/en-US/prefs.dtd
index 1b20f30..7a1cfc7 100644
--- a/src/locale/en-US/prefs.dtd
+++ b/src/locale/en-US/prefs.dtd
@@ -1,4 +1,10 @@
-<!ENTITY title.label "NoSquint Options">
-<!ENTITY level.label "Default text zoom level:">
-<!ENTITY rememberDomains "Remember text zoom level per domain">
-<!ENTITY noRememberDomains "Use the default text zoom level for all domains">
+<!ENTITY ns.pref.title "NoSquint Settings">
+<!ENTITY ns.pref.level.label "Default text zoom level">
+<!ENTITY ns.pref.level.tip "The zoom level applied to all pages by default. Modifying the text zoom when visiting a web page will override this value for that domain.">
+<!ENTITY ns.pref.globalbox.label "Global Options">
+<!ENTITY ns.pref.increment.label "Zoom increment">
+<!ENTITY ns.pref.increment.tip "You can change the text zoom for a page from the View menu or using one of the text zoom shortcuts (ctrl-plus/minus, or ctrl-mousewheel). NoSquint will remember these changes. This setting specifies what increment to use when changing the zoom level.">
+<!ENTITY ns.pref.domainbox.label "Domain Options">
+<!ENTITY ns.pref.rememberDomains "Remember text zoom level per domain">
+<!ENTITY ns.pref.noRememberDomains "Use the default text zoom level (set above) for all domains">
+<!ENTITY ns.pref.domainZoom.label "Zoom level for this domain">
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/nosquint.git
More information about the Pkg-mozext-commits
mailing list