let canvas = document.getElementById("mbrotImage");
let context = canvas.getContext("2d");
+ document.getElementById("drawButton").hidden = true;
+
document.getElementById("statusLabel").value =
document.getElementById("mbrotBundle").getString("statusDrawing");
/***** pure UI functions *****/
+var zoomstart;
+
+function mouseevent(etype, event) {
+ let canvas = document.getElementById("mbrotImage");
+ switch (etype) {
+ case 'down':
+ if (event.button == 0)
+ // left button - start dragzoom
+ zoomstart = {x: event.clientX - canvas.offsetLeft,
+ 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));
+ zoomstart = undefined;
+ break;
+ }
+}
+
function saveImage() {
const bundle = document.getElementById("mbrotBundle");
const nsIFilePicker = Components.interfaces.nsIFilePicker;
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
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);
+ }
+}