X-Git-Url: https://git-public.kairo.at/?p=mandelbrot.git;a=blobdiff_plain;f=xulapp%2Fchrome%2Fmandelbrot%2Fcontent%2Fmandelbrot.js;h=bcc2df59110d7ea7adb4751ac8acc225a57c9041;hp=cf4927af4a961069b679135d1e86436104db96ad;hb=77a9dbf8a5658b590b70a9dfb6d5c1861ee86f34;hpb=7727ce46183a6fb4adaaf0e5b63cd06a6034a2a8 diff --git a/xulapp/chrome/mandelbrot/content/mandelbrot.js b/xulapp/chrome/mandelbrot/content/mandelbrot.js index cf4927a..bcc2df5 100644 --- a/xulapp/chrome/mandelbrot/content/mandelbrot.js +++ b/xulapp/chrome/mandelbrot/content/mandelbrot.js @@ -52,6 +52,8 @@ function drawImage() { let canvas = document.getElementById("mbrotImage"); let context = canvas.getContext("2d"); + document.getElementById("drawButton").hidden = true; + document.getElementById("statusLabel").value = document.getElementById("mbrotBundle").getString("statusDrawing"); @@ -458,6 +460,29 @@ function setAlgorithm(algoID) { gPref.setCharPref("mandelbrot.use_algorithm", algoID); } +function addonsManager(aPane) { + var theEM = Components.classes["@mozilla.org/appshell/window-mediator;1"] + .getService(Components.interfaces.nsIWindowMediator) + .getMostRecentWindow("Extension:Manager"); + if (theEM) { + theEM.focus(); + if (aPane) + theEM.showView(aPane); + return; + } + + const EMURL = "chrome://mozapps/content/extensions/extensions.xul"; + const EMFEATURES = "all,dialog=no"; + if (aPane) + window.openDialog(EMURL, "", EMFEATURES, aPane); + else + window.openDialog(EMURL, "", EMFEATURES); +} + +function errorConsole() { + toOpenWindowByType("global:console", "chrome://global/content/console.xul"); +} + /***** helper functions from external sources *****/ // function below is based on http://developer.mozilla.org/en/docs/Code_snippets:Canvas @@ -493,3 +518,40 @@ function quitApp(aForceQuit) { Components.interfaces.nsIAppStartup.eAttemptQuit; appStartup.quit(quitSeverity); } + +// functions below are from comm-central/suite/common/tasksOverlay.js +function toOpenWindow(aWindow) { + try { + // Try to focus the previously focused window e.g. message compose body + aWindow.document.commandDispatcher.focusedWindow.focus(); + } catch (e) { + // e.g. full-page plugin or non-XUL document; just raise the top window + aWindow.focus(); + } +} + +function toOpenWindowByType(inType, uri, features) { + // don't do several loads in parallel + if (uri in window) + return; + + var topWindow = Components.classes["@mozilla.org/appshell/window-mediator;1"] + .getService(Components.interfaces.nsIWindowMediator) + .getMostRecentWindow(inType); + if ( topWindow ) + toOpenWindow( topWindow ); + else { + // open the requested window, but block it until it's fully loaded + function newWindowLoaded(event) { + // make sure that this handler is called only once + window.removeEventListener("unload", newWindowLoaded, false); + window[uri].removeEventListener("load", newWindowLoaded, false); + delete window[uri]; + } + // remember the newly loading window until it's fully loaded + // or until the current window passes away + window[uri] = window.openDialog(uri, "", features || "all,dialog=no"); + window[uri].addEventListener("load", newWindowLoaded, false); + window.addEventListener("unload", newWindowLoaded, false); + } +}