From: Robert Kaiser Date: Thu, 30 Jul 2009 10:27:31 +0000 (+0200) Subject: use a global var for the bundle, make prompts use correct strings from that bundle... X-Git-Url: https://git-public.kairo.at/?p=mandelbrot.git;a=commitdiff_plain;h=fa4ecb249ee06df34c4604172d81084f4111e766;hp=9c2ca9fa0da990b69c278ae100ccd8dfb631f4eb use a global var for the bundle, make prompts use correct strings from that bundle, add an overview menu item that will act like a bookmark for the toplevel --- diff --git a/xulapp/chrome/mandelbrot/content/mandelbrot.js b/xulapp/chrome/mandelbrot/content/mandelbrot.js index d887b82..28b443c 100644 --- a/xulapp/chrome/mandelbrot/content/mandelbrot.js +++ b/xulapp/chrome/mandelbrot/content/mandelbrot.js @@ -40,12 +40,13 @@ var gPref = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefService) .getBranch(null); var gStartTime = 0; +var gMbrotBundle; function Startup() { updateIterMenu(); updatePaletteMenu(); - document.getElementById("statusLabel").value = - document.getElementById("mbrotBundle").getString("statusEmpty"); + gMbrotBundle = document.getElementById("mbrotBundle"); + document.getElementById("statusLabel").value = gMbrotBundle.getString("statusEmpty"); } function drawImage() { @@ -54,8 +55,7 @@ function drawImage() { document.getElementById("drawButton").hidden = true; - document.getElementById("statusLabel").value = - document.getElementById("mbrotBundle").getString("statusDrawing"); + document.getElementById("statusLabel").value = gMbrotBundle.getString("statusDrawing"); let Cr_min = -2.0; let Cr_max = 1.0; @@ -147,7 +147,7 @@ function EndCalc() { let endTime = new Date(); let timeUsed = (endTime.getTime() - gStartTime.getTime()) / 1000; document.getElementById("statusLabel").value = - document.getElementById("mbrotBundle").getFormattedString("statusTime", [timeUsed.toFixed(3)]); + gMbrotBundle.getFormattedString("statusTime", [timeUsed.toFixed(3)]); gStartTime = 0; } @@ -351,7 +351,8 @@ function mouseevent(etype, event) { if (event.button == 0) { var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] .getService(Components.interfaces.nsIPromptService); - var ok = prompts.confirm(null, "XXX Zoom in", + var ok = prompts.confirm(null, gMbrotBundle.getString("zoomConfirmTitle"), + gMbrotBundle.getString("zoomConfirmLabel") + ' --- ' + zoomstart.x + ',' + zoomstart.y + '-' + (event.clientX - canvas.offsetLeft) + ',' + (event.clientY - canvas.offsetTop)); @@ -363,7 +364,6 @@ function mouseevent(etype, event) { } function saveImage() { - const bundle = document.getElementById("mbrotBundle"); const nsIFilePicker = Components.interfaces.nsIFilePicker; var fp = null; try { @@ -371,9 +371,9 @@ function saveImage() { .createInstance(nsIFilePicker); } catch (e) {} if (!fp) return; - var promptString = bundle.getString("savePrompt"); + var promptString = gMbrotBundle.getString("savePrompt"); fp.init(window, promptString, nsIFilePicker.modeSave); - fp.appendFilter(bundle.getString("pngFilterName"), "*.png"); + fp.appendFilter(gMbrotBundle.getString("pngFilterName"), "*.png"); fp.defaultString = "mandelbrot.png"; var fpResult = fp.show(); @@ -415,8 +415,7 @@ function updateBookmarkMenu(aParent) { } // Create the "Nothing Available" Menu item and disable it. var na = aParent.appendChild(document.createElement("menuitem")); - na.setAttribute("label", - document.getElementById("mbrotBundle").getString("noBookmarks")); + na.setAttribute("label", gMbrotBundle.getString("noBookmarks")); na.setAttribute("disabled", "true"); } @@ -425,11 +424,10 @@ function callBookmark(evtarget) { function saveBookmark() { // retrieve wanted bookmark name with a prompt - var mbrotBundle = document.getElementById("mbrotBundle"); var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] .getService(Components.interfaces.nsIPromptService); var input = {value: ""}; // empty default value - var ok = prompts.prompt(null, "XXX Title", "XXX Please enter a name for the bookmark", input, null, {}); + var ok = prompts.prompt(null, gMbrotBundle.getString("saveBookmarkTitle"), gMbrotBundle.getString("saveBookmarkLabel"), input, null, {}); // ok is true if OK is pressed, false if Cancel. input.value holds the value of the edit field if "OK" was pressed. if (!ok || !input.value) return diff --git a/xulapp/chrome/mandelbrot/content/mandelbrot.xul b/xulapp/chrome/mandelbrot/content/mandelbrot.xul index 18b65b0..9f7c258 100644 --- a/xulapp/chrome/mandelbrot/content/mandelbrot.xul +++ b/xulapp/chrome/mandelbrot/content/mandelbrot.xul @@ -74,6 +74,7 @@ + diff --git a/xulapp/chrome/mandelbrot/locales/en-US/mandelbrot.dtd b/xulapp/chrome/mandelbrot/locales/en-US/mandelbrot.dtd index a8ef6b1..738b7fb 100644 --- a/xulapp/chrome/mandelbrot/locales/en-US/mandelbrot.dtd +++ b/xulapp/chrome/mandelbrot/locales/en-US/mandelbrot.dtd @@ -42,7 +42,8 @@ - + + diff --git a/xulapp/chrome/mandelbrot/locales/en-US/mandelbrot.properties b/xulapp/chrome/mandelbrot/locales/en-US/mandelbrot.properties index f604a1e..d5f2d39 100644 --- a/xulapp/chrome/mandelbrot/locales/en-US/mandelbrot.properties +++ b/xulapp/chrome/mandelbrot/locales/en-US/mandelbrot.properties @@ -41,3 +41,7 @@ statusTime=Time: %S seconds savePrompt=Save Image As… pngFilterName=PNG Files noBookmarks=[No bookmarks found] +saveBookmarkTitle=Bookmark This Location +saveBookmarkLabel=Please enter a name for bookmarking the current location +zoomConfirmTitle=Confirm zooming +zoomConfirmLabel=Zoom in on the area you dragged your mouse over?