1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 18:42:27 +01:00

fix #15 (browser.zoom.siteSpecific resets to false)

This commit is contained in:
Doug Kearns
2008-10-29 06:10:03 +00:00
parent c501945ee1
commit cdf10aecfc
2 changed files with 42 additions and 64 deletions

View File

@@ -48,9 +48,6 @@ function Buffer() //{{{
var highlight = storage.newMap("highlight", false);
var zoomLevels = [ 1, 10, 25, 50, 75, 90, 100,
120, 150, 200, 300, 500, 1000, 2000 ];
const util = modules.util;
const arrayIter = util.Array.iterator;
@@ -282,64 +279,34 @@ function Buffer() //{{{
let error = styles.addSheet("font-size", "chrome://liberator/content/buffer.xhtml",
"body { font-size: " + fontSize + "; }", true);
const ZOOM_MIN = Math.round(ZoomManager.MIN * 100);
const ZOOM_MAX = Math.round(ZoomManager.MAX * 100);
function setZoom(value, fullZoom)
{
if (value < 1 || value > 2000)
if (value < ZOOM_MIN || value > ZOOM_MAX)
{
liberator.echoerr("Zoom value out of range (1-2000%)");
liberator.echoerr("Zoom value out of range (" + ZOOM_MIN + " - " + ZOOM_MAX + "%)");
return;
}
if (fullZoom)
getBrowser().markupDocumentViewer.fullZoom = value / 100.0;
else
getBrowser().markupDocumentViewer.textZoom = value / 100.0;
liberator.echo((fullZoom ? "Full zoom: " : "Text zoom: ") + value + "%");
// TODO: shouldn't this just recalculate hint coords, rather than
// unsuccessfully attempt to reshow hints? i.e. isn't it just relying
// on the recalculation side effect? -- djk
// NOTE: we could really do with a zoom event...
// hints.reshowHints();
ZoomManager.useFullZoom = fullZoom;
ZoomManager.zoom = value / 100;
FullZoom._applySettingToPref();
liberator.echo((fullZoom ? "Full" : "Text") + " zoom: " + value + "%");
}
function bumpZoomLevel(steps, fullZoom)
{
if (fullZoom)
var value = getBrowser().markupDocumentViewer.fullZoom * 100.0;
else
var value = getBrowser().markupDocumentViewer.textZoom * 100.0;
let values = ZoomManager.zoomValues;
let i = values.indexOf(ZoomManager.snap(ZoomManager.zoom)) + steps;
var index = -1;
if (steps <= 0)
{
for (let i = zoomLevels.length - 1; i >= 0; i--)
{
if ((zoomLevels[i] + 0.01) < value) // 0.01 for float comparison
{
index = i + 1 + steps;
break;
}
}
}
if (i >= 0 && i < values.length)
setZoom(Math.round(values[i] * 100), fullZoom);
// TODO: I'll leave the behaviour as is for now, but I think this
// should probably just take you to the respective bounds -- djk
else
{
for (let i = 0; i < zoomLevels.length; i++)
{
if ((zoomLevels[i] - 0.01) > value) // 0.01 for float comparison
{
index = i - 1 + steps;
break;
}
}
}
if (index < 0 || index >= zoomLevels.length)
{
liberator.beep();
return;
}
setZoom(zoomLevels[index], fullZoom);
}
function checkScrollYBounds(win, direction)
@@ -396,9 +363,6 @@ function Buffer() //{{{
////////////////////// OPTIONS /////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
// override this stupid pref, because otherwise zoom is lost after switching tabs
options.setPref("browser.zoom.siteSpecific", false);
options.add(["fullscreen", "fs"],
"Show the current window fullscreen",
"boolean", false,
@@ -953,7 +917,7 @@ function Buffer() //{{{
{
args = args.string;
var level;
let level;
if (!args)
{
@@ -971,10 +935,10 @@ function Buffer() //{{{
level = buffer.textZoom + parseInt(args, 10);
// relative args shouldn't take us out of range
if (level < 1)
level = 1;
if (level > 2000)
level = 2000;
if (level < ZOOM_MIN)
level = ZOOM_MIN;
if (level > ZOOM_MAX)
level = ZOOM_MAX;
}
else
{

View File

@@ -215,7 +215,21 @@ browsing forums or documentation. Change 'previouspattern' to modify its
behavior. It follows relations between files too.
________________________________________________________________________________
section:Zooming[zooming]
section:Zooming[zooming,zoom]
The zooming commands are dependent on two properties - a zoom range and a
series of levels within that range.
The absolute value of the page zoom is limited to a value within the configured
zoom range (default: 30% - 300%). The zoom levels are used by
[m]zi[m]/[m]zo[m], and similar commands, to change the zoom value in steps. The
default zoom levels are 30%, 50%, 67%, 80%, 90%, 100%, 110%, 120%, 133%, 150%,
170%, 200%, 240%, 300%.
The available zoom range can be changed by setting the \'zoom.minPercent' and
\'zoom.maxPercent' Firefox preferences. The zoom levels can be changed using
the \'toolkit.ZoomManager.zoomLevels' preference. Note: The latter is specified
as a list of values between 0 and 1, not as a percentage.
|+| |zi| +
||[count]zi||
@@ -248,8 +262,8 @@ ________________________________________________________________________________
|zz| +
||[count]zz||
________________________________________________________________________________
Set text zoom value of current web page. Zoom value can be between 1 and
2000%. If it is omitted, text zoom is reset to 100%.
Set text zoom value of current web page. Zoom value can be between 30 and 300%.
If it is omitted, text zoom is reset to 100%.
________________________________________________________________________________
@@ -284,8 +298,8 @@ ________________________________________________________________________________
|zZ| +
||[count]zZ||
________________________________________________________________________________
Set full zoom value of current web page. Zoom value can be between 1 and
2000%. If it is omitted, full zoom is reset to 100%.
Set full zoom value of current web page. Zoom value can be between 30 and
300%. If it is omitted, full zoom is reset to 100%.
________________________________________________________________________________
@@ -293,9 +307,9 @@ ________________________________________________________________________________
||:zo[om][!] [value]|| +
||:zo[om][!] +{value} | -{value}|| +
________________________________________________________________________________
Set zoom value of current web page. If [value] can be an absolute value
between 1 and 2000% or a relative value if prefixed with "-" or "+". If
[value] is omitted, zoom is reset to 100%.
Set zoom value of current web page. [value] can be an absolute value between 30
and 300% or a relative value if prefixed with "-" or "+". If [value] is
omitted, zoom is reset to 100%.
Normally this command operates on the text zoom, if used with [!] it operates
on full zoom.