Bug 99501: JS error in viewZoomOverlay.js at startup. r=sfraser, sr=hewitt

This commit is contained in:
jaggernaut%netscape.com 2001-12-01 00:43:22 +00:00
Родитель cd9bf30f7f
Коммит b66ae518a2
4 изменённых файлов: 36 добавлений и 34 удалений

Просмотреть файл

@ -1165,8 +1165,8 @@ function hiddenWindowStartup()
// Disable menus which are not appropriate // Disable menus which are not appropriate
var disabledItems = ['cmd_close', 'Browser:SendPage', 'Browser:EditPage', 'Browser:PrintSetup', /*'Browser:PrintPreview',*/ var disabledItems = ['cmd_close', 'Browser:SendPage', 'Browser:EditPage', 'Browser:PrintSetup', /*'Browser:PrintPreview',*/
'Browser:Print', 'canGoBack', 'canGoForward', 'Browser:Home', 'Browser:AddBookmark', 'cmd_undo', 'Browser:Print', 'canGoBack', 'canGoForward', 'Browser:Home', 'Browser:AddBookmark', 'cmd_undo',
'cmd_redo', 'cmd_cut', 'cmd_copy','cmd_paste', 'cmd_delete', 'cmd_selectAll']; 'cmd_redo', 'cmd_cut', 'cmd_copy','cmd_paste', 'cmd_delete', 'cmd_selectAll', 'menu_textZoom'];
for (id in disabledItems) { for (var id in disabledItems) {
var broadcaster = document.getElementById(disabledItems[id]); var broadcaster = document.getElementById(disabledItems[id]);
if (broadcaster) if (broadcaster)
broadcaster.setAttribute("disabled", "true"); broadcaster.setAttribute("disabled", "true");

Просмотреть файл

@ -73,12 +73,17 @@ ZoomManager.prototype = {
steps : 0, steps : 0,
get textZoom() { get textZoom() {
var currentZoom = Math.round(getMarkupDocumentViewer().textZoom * 100); var currentZoom;
if (this.indexOf(currentZoom) == -1) { try {
if (currentZoom != this.factorOther) { currentZoom = Math.round(getMarkupDocumentViewer().textZoom * 100);
this.factorOther = currentZoom; if (this.indexOf(currentZoom) == -1) {
this.factorAnchor = this.factorOther; if (currentZoom != this.factorOther) {
this.factorOther = currentZoom;
this.factorAnchor = this.factorOther;
}
} }
} catch (e) {
currentZoom = 100;
} }
return currentZoom; return currentZoom;
}, },
@ -214,41 +219,36 @@ ZoomManager.prototype = {
} }
/***** init and helper functions for viewZoomOverlay.xul *****/ /***** init and helper functions for viewZoomOverlay.xul *****/
window.addEventListener("load", registerZoomManager, false); window.addEventListener("load", registerZoomManager, false);
function registerZoomManager() function registerZoomManager()
{ {
var textZoomMenu = document.getElementById("menu_textZoom"); var textZoomMenu = document.getElementById("menu_textZoom");
if (textZoomMenu) { var zoom = ZoomManager.prototype.getInstance();
var zoom = ZoomManager.prototype.getInstance();
textZoomMenu.removeAttribute("hidden"); var parentMenu = textZoomMenu.parentNode;
parentMenu.addEventListener("popupshowing", updateViewMenu, false);
var parentMenu = textZoomMenu.parentNode; var insertBefore = document.getElementById("menu_textZoomInsertBefore");
parentMenu.addEventListener("popupshowing", updateViewMenu, false); 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");
var insertBefore = document.getElementById("menu_textZoomInsertBefore"); var label;
var popup = insertBefore.parentNode; if (zoomFactors[i] == 100)
var accessKeys = zoom.bundle.getString("accessKeys").split(","); label = zoom.bundle.getString("labelOriginal");
var zoomFactors = zoom.getZoomFactors(); else
for (var i = 0; i < zoomFactors.length; ++i) { label = zoom.bundle.getString("label");
var menuItem = document.createElement("menuitem");
menuItem.setAttribute("type", "radio");
menuItem.setAttribute("name", "textZoom");
var label; menuItem.setAttribute("label", label.replace(/%zoom%/, zoomFactors[i]));
if (zoomFactors[i] == 100) menuItem.setAttribute("accesskey", accessKeys[i]);
label = zoom.bundle.getString("labelOriginal"); menuItem.setAttribute("oncommand", "ZoomManager.prototype.getInstance().textZoom = this.value;");
else menuItem.setAttribute("value", zoomFactors[i]);
label = zoom.bundle.getString("label"); popup.insertBefore(menuItem, insertBefore);
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);
}
} }
} }

Просмотреть файл

@ -58,7 +58,7 @@
<command id="cmd_textZoomReset" oncommand="ZoomManager.prototype.getInstance().reset();"/> <command id="cmd_textZoomReset" oncommand="ZoomManager.prototype.getInstance().reset();"/>
</commandset> </commandset>
<menu id="menu_textZoom" accesskey="&textZoomMenu.accesskey;" hidden="true"> <menu id="menu_textZoom" accesskey="&textZoomMenu.accesskey;">
<menupopup id="menu_textZoomPopup" onpopupshowing="updateTextZoomMenu();"> <menupopup id="menu_textZoomPopup" onpopupshowing="updateTextZoomMenu();">
<menuitem key="key_textZoomReduce" label="&textZoomReduceCmd.label;" accesskey="&textZoomReduceCmd.accesskey;" command="cmd_textZoomReduce"/> <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"/> <menuitem key="key_textZoomEnlarge" label="&textZoomEnlargeCmd.label;" accesskey="&textZoomEnlargeCmd.accesskey;" command="cmd_textZoomEnlarge"/>

Просмотреть файл

@ -55,6 +55,8 @@ Contributor(s): ______________________________________. -->
<script type="application/x-javascript" src="chrome://global/content/strres.js"/> <script type="application/x-javascript" src="chrome://global/content/strres.js"/>
<script type="application/x-javascript" src="chrome://navigator/content/navigator.js"/> <script type="application/x-javascript" src="chrome://navigator/content/navigator.js"/>
<stringbundleset id="stringbundleset"/>
<!-- keys are appended from the overlay --> <!-- keys are appended from the overlay -->
<keyset id="tasksKeys"/> <keyset id="tasksKeys"/>
<keyset id="navKeys"> <keyset id="navKeys">