зеркало из https://github.com/mozilla/pjs.git
Implement backend to toggle between text and full zoom b=405133 r=ajschult
This commit is contained in:
Родитель
1b13ff3481
Коммит
6c87accce2
|
@ -1334,7 +1334,7 @@
|
|||
<menuitem label="&reloadCmd.label;" accesskey="&reloadCmd.accesskey;" command="cmd_reload"/>
|
||||
<menuseparator/>
|
||||
<!-- overlayed from viewZoomOverlay.xul -->
|
||||
<menu id="menu_textZoom"/>
|
||||
<menu id="menu_zoom"/>
|
||||
<menu id="mailviewCharsetMenu" />
|
||||
<menuseparator/>
|
||||
<menuitem id="pageSourceMenuItem" label="&pageSourceCmd.label;" key="key_viewPageSource" accesskey="&pageSourceCmd.accesskey;" command="cmd_viewPageSource"/>
|
||||
|
|
|
@ -155,6 +155,8 @@ pref("browser.search.defaultenginename", "chrome://communicator-region/locale/re
|
|||
// 2 and other values, nothing
|
||||
pref("browser.backspace_action", 0);
|
||||
|
||||
pref("browser.zoom.full", true);
|
||||
|
||||
pref("javascript.options.showInConsole", true);
|
||||
|
||||
pref("offline.startup_state", 0);
|
||||
|
|
|
@ -1752,7 +1752,7 @@ function hiddenWindowStartup()
|
|||
'BlockCookies', 'UseCookiesDefault',
|
||||
'AllowSessionCookies', 'AllowCookies', 'BlockImages',
|
||||
'UseImagesDefault', 'AllowImages', 'AllowPopups',
|
||||
'menu_textZoom', 'cmd_minimizeWindow', 'cmd_zoomWindow'];
|
||||
'menu_zoom', 'cmd_minimizeWindow', 'cmd_zoomWindow'];
|
||||
var broadcaster;
|
||||
|
||||
for (var id in disabledItems) {
|
||||
|
|
|
@ -417,7 +417,7 @@
|
|||
<menuseparator />
|
||||
|
||||
<!-- overlayed from viewZoomOverlay.xul -->
|
||||
<menu id="menu_textZoom" observes="isImage"/>
|
||||
<menu id="menu_zoom" observes="isImage"/>
|
||||
|
||||
<menu id="menu_UseStyleSheet" label="&useStyleSheetMenu.label;" accesskey="&useStyleSheetMenu.accesskey;" disabled="false" observes="isImage">
|
||||
<menupopup onpopupshowing="stylesheetFillPopup(this);"
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
<menupopup id="menu_View_Popup">
|
||||
<menuitem accesskey="&reloadCmd.accesskey;" key="key_reload" label="&reloadCmd.label;" oncommand="BrowserReload();"/>
|
||||
<menuseparator />
|
||||
<menu id="menu_textZoom"/>
|
||||
<menu id="menu_zoom"/>
|
||||
<menuseparator/>
|
||||
<!-- <menuitem key="key_viewInfo" observes="View:PageInfo"
|
||||
label="&pageInfoCmd.label;" accesskey="&pageInfoCmd.accesskey;"/>
|
||||
|
|
|
@ -78,7 +78,7 @@
|
|||
<menupopup id="menu_View_Popup">
|
||||
<menuitem accesskey="&reloadCmd.accesskey;" key="key_reload" label="&reloadCmd.label;" oncommand="BrowserReload();"/>
|
||||
<menuseparator />
|
||||
<menu id="menu_textZoom"/>
|
||||
<menu id="menu_zoom"/>
|
||||
<menuseparator/>
|
||||
<!-- <menuitem key="key_viewInfo" observes="View:PageInfo"
|
||||
label="&pageInfoCmd.label;" accesskey="&pageInfoCmd.accesskey;"/>
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
|
||||
/** Document Zoom Management Code
|
||||
*
|
||||
* To use this, you'll need to have a <menu id="menu_textZoom"/>
|
||||
* To use this, you'll need to have a <menu id="menu_zoom"/>
|
||||
* and a getMarkupDocumentViewer() function which returns a
|
||||
* nsIMarkupDocumentViewer.
|
||||
*
|
||||
|
@ -76,10 +76,18 @@ ZoomManager.prototype = {
|
|||
factorAnchor : 300,
|
||||
steps : 0,
|
||||
|
||||
get textZoom() {
|
||||
pref : Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefService)
|
||||
.getBranch(null),
|
||||
|
||||
get zoomType() {
|
||||
return this.pref.getBoolPref("browser.zoom.full") ? "fullZoom" : "textZoom";
|
||||
},
|
||||
|
||||
get currentZoom() {
|
||||
var currentZoom;
|
||||
try {
|
||||
currentZoom = Math.round(getMarkupDocumentViewer().textZoom * 100);
|
||||
currentZoom = Math.round(getMarkupDocumentViewer()[this.zoomType] * 100);
|
||||
if (this.indexOf(currentZoom) == -1) {
|
||||
if (currentZoom != this.factorOther) {
|
||||
this.factorOther = currentZoom;
|
||||
|
@ -92,11 +100,11 @@ ZoomManager.prototype = {
|
|||
return currentZoom;
|
||||
},
|
||||
|
||||
set textZoom(aZoom) {
|
||||
set currentZoom(aZoom) {
|
||||
if (aZoom < this.MIN || aZoom > this.MAX)
|
||||
throw Components.results.NS_ERROR_INVALID_ARG;
|
||||
|
||||
getMarkupDocumentViewer().textZoom = aZoom / 100;
|
||||
getMarkupDocumentViewer()[this.zoomType] = aZoom / 100;
|
||||
},
|
||||
|
||||
enlarge : function() {
|
||||
|
@ -108,7 +116,7 @@ ZoomManager.prototype = {
|
|||
},
|
||||
|
||||
reset : function() {
|
||||
this.textZoom = 100;
|
||||
this.currentZoom = 100;
|
||||
},
|
||||
|
||||
getZoomFactors : function() {
|
||||
|
@ -156,7 +164,7 @@ ZoomManager.prototype = {
|
|||
|
||||
this.ensureZoomFactors();
|
||||
|
||||
var currentZoom = this.textZoom;
|
||||
var currentZoom = this.currentZoom;
|
||||
var insertIndex = -1;
|
||||
var stepFactor = parseFloat(this.bundle.getString("stepFactor"));
|
||||
|
||||
|
@ -202,7 +210,7 @@ ZoomManager.prototype = {
|
|||
if (insertIndex != -1)
|
||||
this.zoomFactors.splice(insertIndex, 1);
|
||||
|
||||
this.textZoom = factor;
|
||||
this.currentZoom = factor;
|
||||
},
|
||||
|
||||
snap : function(aZoom) {
|
||||
|
@ -227,32 +235,31 @@ window.addEventListener("load", registerZoomManager, false);
|
|||
|
||||
function registerZoomManager()
|
||||
{
|
||||
var textZoomMenu = document.getElementById("menu_textZoom");
|
||||
var zoomMenu = document.getElementById("menu_zoom");
|
||||
var zoom = ZoomManager.prototype.getInstance();
|
||||
|
||||
var parentMenu = textZoomMenu.parentNode;
|
||||
var parentMenu = zoomMenu.parentNode;
|
||||
parentMenu.addEventListener("popupshowing", updateViewMenu, false);
|
||||
|
||||
var insertBefore = document.getElementById("menu_textZoomInsertBefore");
|
||||
var insertBefore = document.getElementById("menu_zoomInsertBefore");
|
||||
var popup = insertBefore.parentNode;
|
||||
var accessKeys = zoom.bundle.getString("accessKeys").split(",");
|
||||
var zoomFactors = zoom.getZoomFactors();
|
||||
for (var i = 0; i < zoomFactors.length; ++i) {
|
||||
var menuItem = document.createElement("menuitem");
|
||||
menuItem.setAttribute("type", "radio");
|
||||
menuItem.setAttribute("name", "textZoom");
|
||||
menuItem.setAttribute("name", "zoom");
|
||||
|
||||
var label;
|
||||
if (zoomFactors[i] == 100) {
|
||||
label = zoom.bundle.getString("labelOriginal");
|
||||
menuItem.setAttribute("key", "key_textZoomReset");
|
||||
menuItem.setAttribute("key", "key_zoomReset");
|
||||
}
|
||||
else
|
||||
label = zoom.bundle.getString("label");
|
||||
|
||||
menuItem.setAttribute("label", label.replace(/%zoom%/, zoomFactors[i]));
|
||||
menuItem.setAttribute("accesskey", accessKeys[i]);
|
||||
menuItem.setAttribute("oncommand", "ZoomManager.prototype.getInstance().textZoom = this.value;");
|
||||
menuItem.setAttribute("value", zoomFactors[i]);
|
||||
popup.insertBefore(menuItem, insertBefore);
|
||||
}
|
||||
|
@ -262,26 +269,26 @@ function updateViewMenu()
|
|||
{
|
||||
var zoom = ZoomManager.prototype.getInstance();
|
||||
|
||||
var textZoomMenu = document.getElementById("menu_textZoom");
|
||||
var menuLabel = zoom.bundle.getString("menuLabel").replace(/%zoom%/, zoom.textZoom);
|
||||
textZoomMenu.setAttribute("label", menuLabel);
|
||||
var zoomMenu = document.getElementById("menu_zoom");
|
||||
var menuLabel = zoom.bundle.getString(zoom.zoomType).replace(/%zoom%/, zoom.currentZoom);
|
||||
zoomMenu.setAttribute("label", menuLabel);
|
||||
}
|
||||
|
||||
function updateTextZoomMenu()
|
||||
function updateZoomMenu()
|
||||
{
|
||||
var zoom = ZoomManager.prototype.getInstance();
|
||||
|
||||
var currentZoom = zoom.textZoom;
|
||||
var currentZoom = zoom.currentZoom;
|
||||
|
||||
var textZoomOther = document.getElementById("menu_textZoomOther");
|
||||
var zoomOther = document.getElementById("menu_zoomOther");
|
||||
var label = zoom.bundle.getString("labelOther");
|
||||
textZoomOther.setAttribute("label", label.replace(/%zoom%/, zoom.factorOther));
|
||||
textZoomOther.setAttribute("value", zoom.factorOther);
|
||||
zoomOther.setAttribute("label", label.replace(/%zoom%/, zoom.factorOther));
|
||||
zoomOther.setAttribute("value", zoom.factorOther);
|
||||
|
||||
var popup = document.getElementById("menu_textZoomPopup");
|
||||
var popup = document.getElementById("menu_zoomPopup");
|
||||
var item = popup.firstChild;
|
||||
while (item) {
|
||||
if (item.getAttribute("name") == "textZoom") {
|
||||
if (item.getAttribute("name") == "zoom") {
|
||||
if (item.getAttribute("value") == currentZoom)
|
||||
item.setAttribute("checked","true");
|
||||
else
|
||||
|
@ -291,7 +298,7 @@ function updateTextZoomMenu()
|
|||
}
|
||||
}
|
||||
|
||||
function setTextZoomOther()
|
||||
function setZoomOther()
|
||||
{
|
||||
var zoom = ZoomManager.prototype.getInstance();
|
||||
|
||||
|
@ -299,5 +306,5 @@ function setTextZoomOther()
|
|||
var o = {value: zoom.factorOther, zoomMin: zoom.MIN, zoomMax: zoom.MAX};
|
||||
window.openDialog("chrome://communicator/content/askViewZoom.xul", "AskViewZoom", "chrome,modal,titlebar", o);
|
||||
if (o.zoomOK)
|
||||
zoom.textZoom = o.value;
|
||||
zoom.currentZoom = o.value;
|
||||
}
|
||||
|
|
|
@ -48,26 +48,27 @@
|
|||
<stringbundle id="bundle_viewZoom" src="chrome://communicator/locale/viewZoomOverlay.properties"/>
|
||||
|
||||
<keyset id="viewZoomKeys">
|
||||
<key id="key_textZoomReduce" key="&textZoomReduceCmd.commandkey;" command="cmd_textZoomReduce" modifiers="accel"/>
|
||||
<key id="key_textZoomEnlarge" key="&textZoomEnlargeCmd.commandkey;" command="cmd_textZoomEnlarge" modifiers="accel"/>
|
||||
<key key="&textZoomEnlargeCmd.commandkey;" command="cmd_textZoomEnlarge" modifiers="accel,shift"/>
|
||||
<key key="&textZoomEnlargeCmd.commandkey2;" command="cmd_textZoomEnlarge" modifiers="accel"/>
|
||||
<key id="key_textZoomReset" key="&textZoomResetCmd.commandkey;" command="cmd_textZoomReset" modifiers="accel"/>
|
||||
<key id="key_zoomReduce" key="&zoomReduceCmd.commandkey;" command="cmd_zoomReduce" modifiers="accel"/>
|
||||
<key id="key_zoomEnlarge" key="&zoomEnlargeCmd.commandkey;" command="cmd_zoomEnlarge" modifiers="accel"/>
|
||||
<key key="&zoomEnlargeCmd.commandkey;" command="cmd_zoomEnlarge" modifiers="accel,shift"/>
|
||||
<key key="&zoomEnlargeCmd.commandkey2;" command="cmd_zoomEnlarge" modifiers="accel"/>
|
||||
<key id="key_zoomReset" key="&zoomResetCmd.commandkey;" command="cmd_zoomReset" modifiers="accel"/>
|
||||
</keyset>
|
||||
|
||||
<commandset id="viewZoomCommands">
|
||||
<command id="cmd_textZoomReduce" oncommand="ZoomManager.prototype.getInstance().reduce();"/>
|
||||
<command id="cmd_textZoomEnlarge" oncommand="ZoomManager.prototype.getInstance().enlarge();"/>
|
||||
<command id="cmd_textZoomReset" oncommand="ZoomManager.prototype.getInstance().reset();"/>
|
||||
<command id="cmd_zoomReduce" oncommand="ZoomManager.prototype.getInstance().reduce();"/>
|
||||
<command id="cmd_zoomEnlarge" oncommand="ZoomManager.prototype.getInstance().enlarge();"/>
|
||||
<command id="cmd_zoomReset" oncommand="ZoomManager.prototype.getInstance().reset();"/>
|
||||
<command id="cmd_zoomOther" oncommand="setZoomOther();"/>
|
||||
</commandset>
|
||||
|
||||
<menu id="menu_textZoom" accesskey="&textZoomMenu.accesskey;">
|
||||
<menupopup id="menu_textZoomPopup" onpopupshowing="updateTextZoomMenu();">
|
||||
<menuitem key="key_textZoomReduce" label="&textZoomReduceCmd.label;" accesskey="&textZoomReduceCmd.accesskey;" command="cmd_textZoomReduce"/>
|
||||
<menuitem key="key_textZoomEnlarge" label="&textZoomEnlargeCmd.label;" accesskey="&textZoomEnlargeCmd.accesskey;" command="cmd_textZoomEnlarge"/>
|
||||
<menu id="menu_zoom" accesskey="&zoomMenu.accesskey;">
|
||||
<menupopup id="menu_zoomPopup" onpopupshowing="updateZoomMenu();" oncommand="ZoomManager.prototype.getInstance().currentZoom = event.target.value;">
|
||||
<menuitem key="key_zoomReduce" label="&zoomReduceCmd.label;" accesskey="&zoomReduceCmd.accesskey;" command="cmd_zoomReduce"/>
|
||||
<menuitem key="key_zoomEnlarge" label="&zoomEnlargeCmd.label;" accesskey="&zoomEnlargeCmd.accesskey;" command="cmd_zoomEnlarge"/>
|
||||
<menuseparator/>
|
||||
<menuseparator id="menu_textZoomInsertBefore"/>
|
||||
<menuitem id="menu_textZoomOther" type="radio" name="textZoom" accesskey="&textZoomOtherCmd.accesskey;" oncommand="setTextZoomOther();"/>
|
||||
<menuseparator id="menu_zoomInsertBefore"/>
|
||||
<menuitem id="menu_zoomOther" type="radio" name="zoom" accesskey="&zoomOtherCmd.accesskey;" command="cmd_zoomOther"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
|
||||
|
|
|
@ -35,6 +35,5 @@
|
|||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!-- hopefully this will become view zoom, not just text zoom -->
|
||||
<!ENTITY askViewZoom.title "Text Zoom">
|
||||
<!ENTITY selectZoom.label "Select text zoom (%):">
|
||||
<!ENTITY askViewZoom.title "Zoom">
|
||||
<!ENTITY selectZoom.label "Select zoom (%):">
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
<!ENTITY textZoomEnlargeCmd.label "Larger">
|
||||
<!ENTITY textZoomEnlargeCmd.accesskey "L">
|
||||
<!ENTITY textZoomEnlargeCmd.commandkey "+">
|
||||
<!ENTITY textZoomEnlargeCmd.commandkey2 "="> <!-- + is above this key on many keyboards -->
|
||||
<!ENTITY zoomEnlargeCmd.label "Larger">
|
||||
<!ENTITY zoomEnlargeCmd.accesskey "L">
|
||||
<!ENTITY zoomEnlargeCmd.commandkey "+">
|
||||
<!ENTITY zoomEnlargeCmd.commandkey2 "="> <!-- + is above this key on many keyboards -->
|
||||
|
||||
<!ENTITY textZoomReduceCmd.label "Smaller">
|
||||
<!ENTITY textZoomReduceCmd.accesskey "S">
|
||||
<!ENTITY textZoomReduceCmd.commandkey "-">
|
||||
<!ENTITY zoomReduceCmd.label "Smaller">
|
||||
<!ENTITY zoomReduceCmd.accesskey "S">
|
||||
<!ENTITY zoomReduceCmd.commandkey "-">
|
||||
|
||||
<!ENTITY textZoomResetCmd.commandkey "0">
|
||||
<!ENTITY zoomResetCmd.commandkey "0">
|
||||
|
||||
<!-- see textZoomOtherLabel in navigator.properties -->
|
||||
<!ENTITY textZoomMenu.accesskey "z">
|
||||
<!ENTITY textZoomOtherCmd.accesskey "o">
|
||||
<!-- see zoomOtherLabel in viewZoomOverlay.properties -->
|
||||
<!ENTITY zoomMenu.accesskey "z">
|
||||
<!ENTITY zoomOtherCmd.accesskey "o">
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
#
|
||||
# don't translate %zoom%
|
||||
|
||||
menuLabel=Text Zoom (%zoom% %)
|
||||
fullZoom=Zoom (%zoom% %)
|
||||
textZoom=Text Zoom (%zoom% %)
|
||||
label=%zoom% %
|
||||
labelOriginal=%zoom% % (Original Size)
|
||||
labelOther=Other (%zoom% %) ...
|
||||
|
|
Загрузка…
Ссылка в новой задаче