1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-21 10:57:58 +01:00

Get rid of silly zoom status messages.

--HG--
branch : testing
This commit is contained in:
Kris Maglione
2010-05-14 09:21:02 -04:00
parent 7a3d35991c
commit ae1d7fe5ea
4 changed files with 70 additions and 43 deletions

View File

@@ -280,7 +280,10 @@ const Buffer = Module("buffer", {
autocommands.trigger("LocationChange", { url: buffer.URL }); autocommands.trigger("LocationChange", { url: buffer.URL });
// if this is not delayed we get the position of the old buffer // if this is not delayed we get the position of the old buffer
setTimeout(function () { statusline.updateBufferPosition(); }, 500); setTimeout(function () {
statusline.updateBufferPosition();
statusline.updateZoomLevel();
}, 500);
}, },
// called at the very end of a page load // called at the very end of a page load
asyncUpdateUI: function () { asyncUpdateUI: function () {
@@ -385,19 +388,18 @@ const Buffer = Module("buffer", {
get pageHeight() window.content.innerHeight, get pageHeight() window.content.innerHeight,
/** /**
* @property {number} The current browser's text zoom level, as a * @property {number} The current browser's zoom level, as a
* percentage with 100 as 'normal'. Only affects text size. * percentage with 100 as 'normal'.
*/ */
get textZoom() config.browser.markupDocumentViewer.textZoom * 100, get zoomLevel() config.browser.markupDocumentViewer[this.fullZoom ? "textZoom" : "fullZoom"] * 100,
set textZoom(value) { Buffer.setZoom(value, false); }, set zoomLevel(value) { Buffer.setZoom(value, this.fullZoom); },
/** /**
* @property {number} The current browser's text zoom level, as a * @property {boolean} Whether the current browser is using full
* percentage with 100 as 'normal'. Affects text size, as well as * zoom, as opposed to text zoom.
* image size and block size.
*/ */
get fullZoom() config.browser.markupDocumentViewer.fullZoom * 100, get fullZoom() ZoomManager.useFullZoom,
set fullZoom(value) { Buffer.setZoom(value, true); }, set fullZoom(value) { Buffer.setZoom(this.zoomLevel, value); },
/** /**
* @property {string} The current document's title. * @property {string} The current document's title.
@@ -961,14 +963,20 @@ const Buffer = Module("buffer", {
liberator.assert(value >= Buffer.ZOOM_MIN || value <= Buffer.ZOOM_MAX, liberator.assert(value >= Buffer.ZOOM_MIN || value <= Buffer.ZOOM_MAX,
"Zoom value out of range (" + Buffer.ZOOM_MIN + " - " + Buffer.ZOOM_MAX + "%)"); "Zoom value out of range (" + Buffer.ZOOM_MIN + " - " + Buffer.ZOOM_MAX + "%)");
ZoomManager.useFullZoom = fullZoom; if (fullZoom !== undefined)
ZoomManager.useFullZoom = fullZoom;
ZoomManager.zoom = value / 100; ZoomManager.zoom = value / 100;
if ("FullZoom" in window) if ("FullZoom" in window)
FullZoom._applySettingToPref(); FullZoom._applySettingToPref();
liberator.echomsg((fullZoom ? "Full" : "Text") + " zoom: " + value + "%");
statusline.updateZoomLevel(value, ZoomManager.useFullZoom);
}, },
bumpZoomLevel: function bumpZoomLevel(steps, fullZoom) { bumpZoomLevel: function bumpZoomLevel(steps, fullZoom) {
if (fullZoom === undefined)
fullZoom = ZoomManager.useFullZoom;
let values = ZoomManager.zoomValues; let values = ZoomManager.zoomValues;
let cur = values.indexOf(ZoomManager.snap(ZoomManager.zoom)); let cur = values.indexOf(ZoomManager.snap(ZoomManager.zoom));
let i = util.Math.constrain(cur + steps, 0, values.length - 1); let i = util.Math.constrain(cur + steps, 0, values.length - 1);
@@ -1555,27 +1563,27 @@ const Buffer = Module("buffer", {
function (count) { buffer.textZoom = count > 1 ? count : 100; }, function (count) { buffer.textZoom = count > 1 ? count : 100; },
{ count: true }); { count: true });
mappings.add(myModes, ["zI"], mappings.add(myModes, ["ZI", "zI"],
"Enlarge full zoom of current web page", "Enlarge full zoom of current web page",
function (count) { buffer.zoomIn(Math.max(count, 1), true); }, function (count) { buffer.zoomIn(Math.max(count, 1), true); },
{ count: true }); { count: true });
mappings.add(myModes, ["zM"], mappings.add(myModes, ["ZM", "zM"],
"Enlarge full zoom of current web page by a larger amount", "Enlarge full zoom of current web page by a larger amount",
function (count) { buffer.zoomIn(Math.max(count, 1) * 3, true); }, function (count) { buffer.zoomIn(Math.max(count, 1) * 3, true); },
{ count: true }); { count: true });
mappings.add(myModes, ["zO"], mappings.add(myModes, ["ZO", "zO"],
"Reduce full zoom of current web page", "Reduce full zoom of current web page",
function (count) { buffer.zoomOut(Math.max(count, 1), true); }, function (count) { buffer.zoomOut(Math.max(count, 1), true); },
{ count: true }); { count: true });
mappings.add(myModes, ["zR"], mappings.add(myModes, ["ZR", "zR"],
"Reduce full zoom of current web page by a larger amount", "Reduce full zoom of current web page by a larger amount",
function (count) { buffer.zoomOut(Math.max(count, 1) * 3, true); }, function (count) { buffer.zoomOut(Math.max(count, 1) * 3, true); },
{ count: true }); { count: true });
mappings.add(myModes, ["zZ"], mappings.add(myModes, ["ZZ", "zZ"],
"Set full zoom value of current web page", "Set full zoom value of current web page",
function (count) { buffer.fullZoom = count > 1 ? count : 100; }, function (count) { buffer.fullZoom = count > 1 ? count : 100; },
{ count: true }); { count: true });

View File

@@ -86,12 +86,13 @@
<statusbar id="status-bar" liberator:highlight="StatusLine"> <statusbar id="status-bar" liberator:highlight="StatusLine">
<hbox insertbefore="&liberator.statusBefore;" insertafter="&liberator.statusAfter;" <hbox insertbefore="&liberator.statusBefore;" insertafter="&liberator.statusAfter;"
id="liberator-statusline" flex="1" hidden="false" align="center"> id="liberator-statusline-field-status" flex="1" hidden="false" align="center">
<textbox class="plain" id="liberator-statusline-field-url" readonly="false" flex="1" crop="end"/> <textbox class="plain" id="liberator-statusline-field-url" readonly="false" flex="1" crop="end"/>
<label class="plain" id="liberator-statusline-field-inputbuffer" flex="0"/> <label class="plain" id="liberator-statusline-field-inputbuffer" flex="0"/>
<label class="plain" id="liberator-statusline-field-progress" flex="0"/> <label class="plain" id="liberator-statusline-field-progress" flex="0"/>
<label class="plain" id="liberator-statusline-field-tabcount" flex="0"/> <label class="plain" id="liberator-statusline-field-tabcount" flex="0"/>
<label class="plain" id="liberator-statusline-field-bufferposition" flex="0"/> <label class="plain" id="liberator-statusline-field-bufferposition" flex="0"/>
<label class="plain" id="liberator-statusline-field-zoomlevel" flex="0"/>
</hbox> </hbox>
<!-- just hide them since other elements expect them --> <!-- just hide them since other elements expect them -->
<statusbarpanel id="statusbar-display" hidden="true"/> <statusbarpanel id="statusbar-display" hidden="true"/>

View File

@@ -13,12 +13,8 @@ const StatusLine = Module("statusline", {
this._statusBar.collapsed = true; // it is later restored unless the user sets laststatus=0 this._statusBar.collapsed = true; // it is later restored unless the user sets laststatus=0
// our status bar fields // our status bar fields
this._statuslineWidget = document.getElementById("liberator-statusline"); this.widgets = dict(["status", "url", "inputbuffer", "progress", "tabcount", "bufferposition", "zoomlevel"].map(
this._urlWidget = document.getElementById("liberator-statusline-field-url"); function (field) [field, document.getElementById("liberator-statusline-field-" + field)]));
this._inputBufferWidget = document.getElementById("liberator-statusline-field-inputbuffer");
this._progressWidget = document.getElementById("liberator-statusline-field-progress");
this._tabCountWidget = document.getElementById("liberator-statusline-field-tabcount");
this._bufferPositionWidget = document.getElementById("liberator-statusline-field-bufferposition");
}, },
/** /**
@@ -49,6 +45,7 @@ const StatusLine = Module("statusline", {
this.updateProgress(); this.updateProgress();
this.updateTabCount(); this.updateTabCount();
this.updateBufferPosition(); this.updateBufferPosition();
this.updateZoomLevel();
}, },
/** /**
@@ -116,7 +113,7 @@ const StatusLine = Module("statusline", {
if (modified) if (modified)
url += " [" + modified + "]"; url += " [" + modified + "]";
this._urlWidget.value = url; this.widgets.url.value = url;
}, },
/** /**
@@ -131,7 +128,7 @@ const StatusLine = Module("statusline", {
if (!buffer || typeof buffer != "string") if (!buffer || typeof buffer != "string")
buffer = ""; buffer = "";
this._inputBufferWidget.value = buffer; this.widgets.inputbuffer.value = buffer;
}, },
/** /**
@@ -148,7 +145,7 @@ const StatusLine = Module("statusline", {
progress = ""; progress = "";
if (typeof progress == "string") if (typeof progress == "string")
this._progressWidget.value = progress; this.widgets.progress.value = progress;
else if (typeof progress == "number") { else if (typeof progress == "number") {
let progressStr = ""; let progressStr = "";
if (progress <= 0) if (progress <= 0)
@@ -161,7 +158,7 @@ const StatusLine = Module("statusline", {
+ " ".substr(0, 19 - progress) + " ".substr(0, 19 - progress)
+ "]"; + "]";
} }
this._progressWidget.value = progressStr; this.widgets.progress.value = progressStr;
} }
}, },
@@ -185,7 +182,7 @@ const StatusLine = Module("statusline", {
for (let [i, tab] in util.Array.iteritems(config.browser.mTabs)) for (let [i, tab] in util.Array.iteritems(config.browser.mTabs))
tab.setAttribute("ordinal", i + 1); tab.setAttribute("ordinal", i + 1);
this._tabCountWidget.value = "[" + (tabs.index() + 1) + "/" + tabs.count + "]"; this.widgets.tabcount.value = "[" + (tabs.index() + 1) + "/" + tabs.count + "]";
} }
}, },
@@ -196,7 +193,7 @@ const StatusLine = Module("statusline", {
* @param {number} percent The position, as a percentage. @optional * @param {number} percent The position, as a percentage. @optional
*/ */
updateBufferPosition: function updateBufferPosition(percent) { updateBufferPosition: function updateBufferPosition(percent) {
if (!percent || typeof percent != "number") { if (typeof percent != "number") {
let win = document.commandDispatcher.focusedWindow; let win = document.commandDispatcher.focusedWindow;
if (!win) if (!win)
return; return;
@@ -209,14 +206,35 @@ const StatusLine = Module("statusline", {
bufferPositionStr = "All"; bufferPositionStr = "All";
else if (percent == 0) else if (percent == 0)
bufferPositionStr = "Top"; bufferPositionStr = "Top";
else if (percent < 10)
bufferPositionStr = " " + percent + "%";
else if (percent >= 100) else if (percent >= 100)
bufferPositionStr = "Bot"; bufferPositionStr = "Bot";
else if (percent < 10)
bufferPositionStr = " " + percent + "%";
else else
bufferPositionStr = percent + "%"; bufferPositionStr = percent + "%";
this._bufferPositionWidget.value = bufferPositionStr; this.widgets.bufferposition.value = bufferPositionStr;
},
/**
* Display the main content's zoom level.
*
* @param {number} percent The zoom level, as a percentage. @optional
* @param {boolean} full True if full zoom is in operation. @optional
*/
updateZoomLevel: function updateZoomLevel(percent, full) {
if (arguments.length == 0)
[percent, full] = [buffer.zoomLevel, buffer.fullZoom];
if (percent == 100)
this.widgets.zoomlevel.value = "";
else {
percent = (" " + percent).substr(-3);
if (full)
this.widgets.zoomlevel.value = " [" + percent + "%]";
else
this.widgets.zoomlevel.value = " (" + percent + "%)";
}
} }
}, { }, {

View File

@@ -417,8 +417,8 @@ preference.
<item> <item>
<tags>zI</tags> <tags>ZI zI</tags>
<spec><oa>count</oa>zI</spec> <spec><oa>count</oa>ZI</spec>
<description> <description>
<p>Enlarge full zoom of current web page. Mnemonic: zoom in.</p> <p>Enlarge full zoom of current web page. Mnemonic: zoom in.</p>
</description> </description>
@@ -426,8 +426,8 @@ preference.
<item> <item>
<tags>zM</tags> <tags>ZM zM</tags>
<spec><oa>count</oa>zM</spec> <spec><oa>count</oa>ZM</spec>
<description> <description>
<p>Enlarge full zoom of current web page by a larger amount. Mnemonic: zoom more.</p> <p>Enlarge full zoom of current web page by a larger amount. Mnemonic: zoom more.</p>
</description> </description>
@@ -435,8 +435,8 @@ preference.
<item> <item>
<tags>zO</tags> <tags>ZO zO</tags>
<spec><oa>count</oa>zO</spec> <spec><oa>count</oa>ZO</spec>
<description> <description>
<p>Reduce full zoom of current web page. Mnemonic: zoom out.</p> <p>Reduce full zoom of current web page. Mnemonic: zoom out.</p>
</description> </description>
@@ -444,8 +444,8 @@ preference.
<item> <item>
<tags>zR</tags> <tags>ZR zR</tags>
<spec><oa>count</oa>zR</spec> <spec><oa>count</oa>ZR</spec>
<description> <description>
<p>Reduce full zoom of current web page by a larger amount. Mnemonic: zoom reduce.</p> <p>Reduce full zoom of current web page by a larger amount. Mnemonic: zoom reduce.</p>
</description> </description>
@@ -453,8 +453,8 @@ preference.
<item> <item>
<tags>zZ</tags> <tags>ZZ zZ</tags>
<spec><oa>count</oa>zZ</spec> <spec><oa>count</oa>ZZ</spec>
<description> <description>
<p> <p>
Set full zoom value of current web page. Zoom value can be between 30 and Set full zoom value of current web page. Zoom value can be between 30 and