From: Robert Kaiser Date: Wed, 29 Jul 2009 12:09:16 +0000 (+0200) Subject: add prompts: bookmark name input, zoom loading confirm. base implementation, needs... X-Git-Url: https://git-public.kairo.at/?a=commitdiff_plain;h=9c2ca9fa0da990b69c278ae100ccd8dfb631f4eb;p=mandelbrot.git add prompts: bookmark name input, zoom loading confirm. base implementation, needs more work to be correct --- diff --git a/xulapp/chrome/mandelbrot/content/mandelbrot.js b/xulapp/chrome/mandelbrot/content/mandelbrot.js index 8bce0da..d887b82 100644 --- a/xulapp/chrome/mandelbrot/content/mandelbrot.js +++ b/xulapp/chrome/mandelbrot/content/mandelbrot.js @@ -348,10 +348,15 @@ function mouseevent(etype, event) { y: event.clientY - canvas.offsetTop}; break; case 'up': - if (event.button == 0) - alert(zoomstart.x + ',' + zoomstart.y + '-' + - (event.clientX - canvas.offsetLeft) + ',' + - (event.clientY - canvas.offsetTop)); + 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", + zoomstart.x + ',' + zoomstart.y + '-' + + (event.clientX - canvas.offsetLeft) + ',' + + (event.clientY - canvas.offsetTop)); + // ok is now true if OK was clicked, and false if cancel was clicked + } zoomstart = undefined; break; } @@ -419,8 +424,17 @@ function callBookmark(evtarget) { } function saveBookmark() { - // XXX: retrieve wanted bookmark name - var bmName = "mandelbrot bm test"; + // 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, {}); + // 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 + + var bmName = input.value; // Open or create the bookmarks database. var file = Components.classes["@mozilla.org/file/directory_service;1"]