Allow two javascript functions to be specified which will maximise and
authorTom Hughes <tom@compton.nu>
Tue, 30 Nov 2010 10:48:56 +0000 (10:48 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 30 Nov 2010 10:48:56 +0000 (10:48 +0000)
minimise the editing area and make the M key toggle between states.

net/systemeD/potlatch2/EditController.as

index e1f1d52..fa2d93c 100644 (file)
@@ -6,7 +6,8 @@ package net.systemeD.potlatch2 {
     import net.systemeD.potlatch2.controller.*;
     import net.systemeD.potlatch2.FunctionKeyManager;
        import mx.managers.CursorManager;
-       import flash.events.*;
+    import flash.external.ExternalInterface;
+    import flash.events.*;
        import flash.geom.*;
 
     public class EditController implements MapController {
@@ -21,6 +22,9 @@ package net.systemeD.potlatch2 {
                private var keys:Object={};
                public var clipboards:Object={};
                public var cursorsEnabled:Boolean=true;
+        private var maximised:Boolean=false;
+        private var maximiseFunction:String;
+        private var minimiseFunction:String;
 
                [Embed(source="../../../embedded/pen.png")]             public var pen:Class;
                [Embed(source="../../../embedded/pen_x.png")]           public var pen_x:Class;
@@ -34,7 +38,8 @@ package net.systemeD.potlatch2 {
             this.tagViewer = tagViewer;
                        this.toolbox = toolbox;
                        this.toolbox.init(this);
-
+            this.maximiseFunction = Connection.getParam("maximise_function", null);
+            this.minimiseFunction = Connection.getParam("minimise_function", null);
             
             map.parent.addEventListener(MouseEvent.MOUSE_MOVE, mapMouseEvent);
             map.parent.addEventListener(MouseEvent.MOUSE_UP, mapMouseEvent);
@@ -77,6 +82,7 @@ package net.systemeD.potlatch2 {
             trace("key code "+event.keyCode);
                        if (keys[event.keyCode]) { delete keys[event.keyCode]; }
                        if (FunctionKeyManager.instance().handleKeypress(event.keyCode)) { return; }
+            if (event.keyCode == 77) { toggleSize(); }
             var newState:ControllerState = state.processKeyboardEvent(event);
             setState(newState);            
                }
@@ -139,8 +145,22 @@ package net.systemeD.potlatch2 {
                        if (cursor && cursorsEnabled) { CursorManager.setCursor(cursor,2,-4,0); }
                }
 
-    }
+        private function toggleSize():void {
+            if (maximised) {
+                if (minimiseFunction) {
+                    ExternalInterface.call(minimiseFunction);
+                }
 
+                maximised = false;
+            } else {
+                if (maximiseFunction) {
+                    ExternalInterface.call(maximiseFunction);
+                }
+
+                maximised = true;
+            }
+        }
+
+    }
     
 }
-