diff options
author | Kris Maglione <kris@vimperator.org> | 2010-05-14 09:21:02 -0400 |
---|---|---|
committer | Kris Maglione <kris@vimperator.org> | 2010-05-14 09:21:02 -0400 |
commit | ae1d7fe5ea7d40661668a7bfc544011589f50f52 (patch) | |
tree | 59a49f1614eeb131af54a8e5a8fd08decf452f85 | |
parent | 7a3d35991cca325ac2caefb85ad034c798c5e25f (diff) | |
download | pentadactyl-ae1d7fe5ea7d40661668a7bfc544011589f50f52.tar.gz |
Get rid of silly zoom status messages.
--HG--
branch : testing
-rw-r--r-- | common/content/buffer.js | 42 | ||||
-rw-r--r-- | common/content/liberator.xul | 3 | ||||
-rw-r--r-- | common/content/statusline.js | 48 | ||||
-rw-r--r-- | common/locale/en-US/buffer.xml | 20 |
4 files changed, 70 insertions, 43 deletions
diff --git a/common/content/buffer.js b/common/content/buffer.js index 904d415f..cdcdba97 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -280,7 +280,10 @@ const Buffer = Module("buffer", { autocommands.trigger("LocationChange", { url: buffer.URL }); // 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 asyncUpdateUI: function () { @@ -385,19 +388,18 @@ const Buffer = Module("buffer", { get pageHeight() window.content.innerHeight, /** - * @property {number} The current browser's text zoom level, as a - * percentage with 100 as 'normal'. Only affects text size. + * @property {number} The current browser's zoom level, as a + * percentage with 100 as 'normal'. */ - get textZoom() config.browser.markupDocumentViewer.textZoom * 100, - set textZoom(value) { Buffer.setZoom(value, false); }, + get zoomLevel() config.browser.markupDocumentViewer[this.fullZoom ? "textZoom" : "fullZoom"] * 100, + set zoomLevel(value) { Buffer.setZoom(value, this.fullZoom); }, /** - * @property {number} The current browser's text zoom level, as a - * percentage with 100 as 'normal'. Affects text size, as well as - * image size and block size. + * @property {boolean} Whether the current browser is using full + * zoom, as opposed to text zoom. */ - get fullZoom() config.browser.markupDocumentViewer.fullZoom * 100, - set fullZoom(value) { Buffer.setZoom(value, true); }, + get fullZoom() ZoomManager.useFullZoom, + set fullZoom(value) { Buffer.setZoom(this.zoomLevel, value); }, /** * @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, "Zoom value out of range (" + Buffer.ZOOM_MIN + " - " + Buffer.ZOOM_MAX + "%)"); - ZoomManager.useFullZoom = fullZoom; + if (fullZoom !== undefined) + ZoomManager.useFullZoom = fullZoom; ZoomManager.zoom = value / 100; + if ("FullZoom" in window) FullZoom._applySettingToPref(); - liberator.echomsg((fullZoom ? "Full" : "Text") + " zoom: " + value + "%"); + + statusline.updateZoomLevel(value, ZoomManager.useFullZoom); }, bumpZoomLevel: function bumpZoomLevel(steps, fullZoom) { + if (fullZoom === undefined) + fullZoom = ZoomManager.useFullZoom; + let values = ZoomManager.zoomValues; let cur = values.indexOf(ZoomManager.snap(ZoomManager.zoom)); 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; }, { count: true }); - mappings.add(myModes, ["zI"], + mappings.add(myModes, ["ZI", "zI"], "Enlarge full zoom of current web page", function (count) { buffer.zoomIn(Math.max(count, 1), true); }, { count: true }); - mappings.add(myModes, ["zM"], + mappings.add(myModes, ["ZM", "zM"], "Enlarge full zoom of current web page by a larger amount", function (count) { buffer.zoomIn(Math.max(count, 1) * 3, true); }, { count: true }); - mappings.add(myModes, ["zO"], + mappings.add(myModes, ["ZO", "zO"], "Reduce full zoom of current web page", function (count) { buffer.zoomOut(Math.max(count, 1), true); }, { count: true }); - mappings.add(myModes, ["zR"], + mappings.add(myModes, ["ZR", "zR"], "Reduce full zoom of current web page by a larger amount", function (count) { buffer.zoomOut(Math.max(count, 1) * 3, true); }, { count: true }); - mappings.add(myModes, ["zZ"], + mappings.add(myModes, ["ZZ", "zZ"], "Set full zoom value of current web page", function (count) { buffer.fullZoom = count > 1 ? count : 100; }, { count: true }); diff --git a/common/content/liberator.xul b/common/content/liberator.xul index c1acf2bb..d2e9429d 100644 --- a/common/content/liberator.xul +++ b/common/content/liberator.xul @@ -86,12 +86,13 @@ <statusbar id="status-bar" liberator:highlight="StatusLine"> <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"/> <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-tabcount" flex="0"/> <label class="plain" id="liberator-statusline-field-bufferposition" flex="0"/> + <label class="plain" id="liberator-statusline-field-zoomlevel" flex="0"/> </hbox> <!-- just hide them since other elements expect them --> <statusbarpanel id="statusbar-display" hidden="true"/> diff --git a/common/content/statusline.js b/common/content/statusline.js index d8fbfe05..57baac40 100644 --- a/common/content/statusline.js +++ b/common/content/statusline.js @@ -13,12 +13,8 @@ const StatusLine = Module("statusline", { this._statusBar.collapsed = true; // it is later restored unless the user sets laststatus=0 // our status bar fields - this._statuslineWidget = document.getElementById("liberator-statusline"); - this._urlWidget = document.getElementById("liberator-statusline-field-url"); - 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"); + this.widgets = dict(["status", "url", "inputbuffer", "progress", "tabcount", "bufferposition", "zoomlevel"].map( + function (field) [field, document.getElementById("liberator-statusline-field-" + field)])); }, /** @@ -49,6 +45,7 @@ const StatusLine = Module("statusline", { this.updateProgress(); this.updateTabCount(); this.updateBufferPosition(); + this.updateZoomLevel(); }, /** @@ -116,7 +113,7 @@ const StatusLine = Module("statusline", { if (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") buffer = ""; - this._inputBufferWidget.value = buffer; + this.widgets.inputbuffer.value = buffer; }, /** @@ -148,7 +145,7 @@ const StatusLine = Module("statusline", { progress = ""; if (typeof progress == "string") - this._progressWidget.value = progress; + this.widgets.progress.value = progress; else if (typeof progress == "number") { let progressStr = ""; if (progress <= 0) @@ -161,7 +158,7 @@ const StatusLine = Module("statusline", { + " ".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)) 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 */ updateBufferPosition: function updateBufferPosition(percent) { - if (!percent || typeof percent != "number") { + if (typeof percent != "number") { let win = document.commandDispatcher.focusedWindow; if (!win) return; @@ -209,14 +206,35 @@ const StatusLine = Module("statusline", { bufferPositionStr = "All"; else if (percent == 0) bufferPositionStr = "Top"; - else if (percent < 10) - bufferPositionStr = " " + percent + "%"; else if (percent >= 100) bufferPositionStr = "Bot"; + else if (percent < 10) + bufferPositionStr = " " + percent + "%"; else 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 + "%)"; + } } }, { diff --git a/common/locale/en-US/buffer.xml b/common/locale/en-US/buffer.xml index a0e96318..da56c7bb 100644 --- a/common/locale/en-US/buffer.xml +++ b/common/locale/en-US/buffer.xml @@ -417,8 +417,8 @@ preference. <item> - <tags>zI</tags> - <spec><oa>count</oa>zI</spec> + <tags>ZI zI</tags> + <spec><oa>count</oa>ZI</spec> <description> <p>Enlarge full zoom of current web page. Mnemonic: zoom in.</p> </description> @@ -426,8 +426,8 @@ preference. <item> - <tags>zM</tags> - <spec><oa>count</oa>zM</spec> + <tags>ZM zM</tags> + <spec><oa>count</oa>ZM</spec> <description> <p>Enlarge full zoom of current web page by a larger amount. Mnemonic: zoom more.</p> </description> @@ -435,8 +435,8 @@ preference. <item> - <tags>zO</tags> - <spec><oa>count</oa>zO</spec> + <tags>ZO zO</tags> + <spec><oa>count</oa>ZO</spec> <description> <p>Reduce full zoom of current web page. Mnemonic: zoom out.</p> </description> @@ -444,8 +444,8 @@ preference. <item> - <tags>zR</tags> - <spec><oa>count</oa>zR</spec> + <tags>ZR zR</tags> + <spec><oa>count</oa>ZR</spec> <description> <p>Reduce full zoom of current web page by a larger amount. Mnemonic: zoom reduce.</p> </description> @@ -453,8 +453,8 @@ preference. <item> - <tags>zZ</tags> - <spec><oa>count</oa>zZ</spec> + <tags>ZZ zZ</tags> + <spec><oa>count</oa>ZZ</spec> <description> <p> Set full zoom value of current web page. Zoom value can be between 30 and |