Repository: flex-asjs
Updated Branches:
  refs/heads/core_js_to_as 18f159c14 -> 2529f4bc4


Updated ImageButton to also have a JavaScript presence.


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/2529f4bc
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/2529f4bc
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/2529f4bc

Branch: refs/heads/core_js_to_as
Commit: 2529f4bc42ab21f07c1c80a185045fbf8454d7a0
Parents: 18f159c
Author: Peter Ent <[email protected]>
Authored: Thu Nov 12 16:53:37 2015 -0500
Committer: Peter Ent <[email protected]>
Committed: Thu Nov 12 16:53:37 2015 -0500

----------------------------------------------------------------------
 frameworks/projects/HTML/as/src/HTMLClasses.as  | 12 +--
 .../as/src/org/apache/flex/html/ImageButton.as  | 45 ++++++++++--
 .../apache/flex/html/beads/ImageButtonView.as   | 77 +++++++++++---------
 3 files changed, 87 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/2529f4bc/frameworks/projects/HTML/as/src/HTMLClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/as/src/HTMLClasses.as 
b/frameworks/projects/HTML/as/src/HTMLClasses.as
index 21e7e1d..5e90559 100644
--- a/frameworks/projects/HTML/as/src/HTMLClasses.as
+++ b/frameworks/projects/HTML/as/src/HTMLClasses.as
@@ -26,8 +26,8 @@ package
  *  from the classes specified in manifest.xml.
  */
 internal class HTMLClasses
-{      
-       
+{
+
     import org.apache.flex.html.ToolTip; ToolTip;
        import org.apache.flex.html.accessories.NumericOnlyTextInputBead; 
NumericOnlyTextInputBead;
        import org.apache.flex.html.accessories.PasswordInputBead; 
PasswordInputBead;
@@ -53,10 +53,10 @@ internal class HTMLClasses
            import org.apache.flex.html.beads.CSSTextToggleButtonView; 
CSSTextToggleButtonView;
                import org.apache.flex.html.beads.DropDownListView; 
DropDownListView;
                import org.apache.flex.html.beads.CloseButtonView; 
CloseButtonView;
-           import org.apache.flex.html.beads.ImageButtonView; ImageButtonView;
        import org.apache.flex.html.beads.ImageAndTextButtonView; 
ImageAndTextButtonView;
                import org.apache.flex.html.beads.ImageView; ImageView;
        }
+       import org.apache.flex.html.beads.ImageButtonView; ImageButtonView;
        import org.apache.flex.html.beads.ListView; ListView;
        COMPILE::AS3
        {
@@ -129,7 +129,7 @@ internal class HTMLClasses
                import 
org.apache.flex.html.beads.controllers.HScrollBarMouseController; 
HScrollBarMouseController;
        }
        import org.apache.flex.html.beads.layouts.ButtonBarLayout; 
ButtonBarLayout;
-    import org.apache.flex.html.beads.layouts.VerticalLayout; VerticalLayout;  
+    import org.apache.flex.html.beads.layouts.VerticalLayout; VerticalLayout;
        import org.apache.flex.html.beads.layouts.HorizontalLayout; 
HorizontalLayout;
     import org.apache.flex.html.beads.layouts.BasicLayout; BasicLayout;
        COMPILE::AS3
@@ -143,7 +143,7 @@ internal class HTMLClasses
        import org.apache.flex.html.supportClasses.DataGroup; DataGroup;
        import org.apache.flex.html.supportClasses.Viewport; Viewport;
        import org.apache.flex.html.supportClasses.ScrollingViewport; 
ScrollingViewport;
-       
+
        import org.apache.flex.html.beads.DataGridColumnView; 
DataGridColumnView;
        import org.apache.flex.html.beads.DataGridView; DataGridView;
        import org.apache.flex.html.beads.DateChooserView; DateChooserView;
@@ -158,7 +158,7 @@ internal class HTMLClasses
        import org.apache.flex.html.supportClasses.DataGridColumn; 
DataGridColumn;
        import org.apache.flex.html.supportClasses.DateChooserButton; 
DateChooserButton;
        import org.apache.flex.html.supportClasses.GraphicsItemRenderer; 
GraphicsItemRenderer;
-    
+
     import org.apache.flex.html.MXMLBeadViewBase; MXMLBeadViewBase;
     import org.apache.flex.html.beads.TitleBarView; TitleBarView;
     import org.apache.flex.html.beads.TitleBarMeasurementBead; 
TitleBarMeasurementBead;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/2529f4bc/frameworks/projects/HTML/as/src/org/apache/flex/html/ImageButton.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/HTML/as/src/org/apache/flex/html/ImageButton.as 
b/frameworks/projects/HTML/as/src/org/apache/flex/html/ImageButton.as
index dd92019..de563a1 100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/ImageButton.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/ImageButton.as
@@ -19,11 +19,14 @@
 package org.apache.flex.html
 {
     import org.apache.flex.core.SimpleCSSStyles;
+    COMPILE::JS
+    {
+        import org.apache.flex.core.WrappedHTMLElement;
+    }
 
     /**
-     *  The CloseButton class is Button that displays an X
-     *  and is commonly used in a Panel's TitleBar.
-     *  
+     *  The ImageButton class presents an image as a button.
+     *
      *  @langversion 3.0
      *  @playerversion Flash 10.2
      *  @playerversion AIR 2.6
@@ -33,7 +36,7 @@ package org.apache.flex.html
        {
         /**
          *  Constructor.
-         *  
+         *
          *  @langversion 3.0
          *  @playerversion Flash 10.2
          *  @playerversion AIR 2.6
@@ -44,17 +47,43 @@ package org.apache.flex.html
                        super();
             typeNames = "ImageButton";
                }
-        
-        public function get backgroundImage():String
+
+               /**
+         * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement
+         */
+               COMPILE::JS
+               override protected function createElement():WrappedHTMLElement
+               {
+                       element = document.createElement("input") as 
WrappedHTMLElement;
+                       positioner = element;
+                       element.flexjs_wrapper = this;
+
+                       var inputElement:HTMLInputElement = element as 
HTMLInputElement;
+                       inputElement.type = "image";
+
+                       return element;
+               }
+
+               /**
+                * Sets the image for the button. This is a URL.
+                * TODO: figure out how to set the source in the style, rather 
than using
+                * backgroundImage behind the scenes.
+                */
+        public function get source():String
         {
             return style.backgroundImage;
         }
-        
-        public function set backgroundImage(url:String):void
+
+        public function set source(url:String):void
         {
             if (!style)
                 style = new SimpleCSSStyles();
             style.backgroundImage = url;
+
+            COMPILE::JS {
+               var inputElement:HTMLInputElement = element as HTMLInputElement;
+                               inputElement.src = url;
+            }
         }
        }
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/2529f4bc/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ImageButtonView.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ImageButtonView.as 
b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ImageButtonView.as
index 972c1de..7e81263 100644
--- 
a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ImageButtonView.as
+++ 
b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ImageButtonView.as
@@ -18,6 +18,7 @@
 
////////////////////////////////////////////////////////////////////////////////
 package org.apache.flex.html.beads
 {
+COMPILE::AS3 {
        import flash.display.Loader;
        import flash.display.Shape;
        import flash.display.SimpleButton;
@@ -25,21 +26,23 @@ package org.apache.flex.html.beads
        import flash.events.Event;
     import flash.events.IOErrorEvent;
        import flash.net.URLRequest;
-       
+
+       import org.apache.flex.core.UIButtonBase;
+}
+
     import org.apache.flex.core.BeadViewBase;
        import org.apache.flex.core.IBead;
        import org.apache.flex.core.IBeadView;
        import org.apache.flex.core.IStrand;
-       import org.apache.flex.core.UIButtonBase;
     import org.apache.flex.core.ValuesManager;
     import org.apache.flex.events.Event;
-       
+
        /**
         *  The ImageButtonView class provides an image-only view
         *  for the standard Button. Unlike the CSSButtonView, this
         *  class does not support background and border; only images
         *  for the up, over, and active states.
-        *  
+        *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
@@ -49,7 +52,7 @@ package org.apache.flex.html.beads
        {
                /**
                 *  Constructor.
-                *  
+                *
                 *  @langversion 3.0
                 *  @playerversion Flash 10.2
                 *  @playerversion AIR 2.6
@@ -57,14 +60,16 @@ package org.apache.flex.html.beads
                 */
                public function ImageButtonView()
                {
-                       upSprite = new Sprite();
-                       downSprite = new Sprite();
-                       overSprite = new Sprite();
+                       COMPILE::AS3 {
+                               upSprite = new Sprite();
+                               downSprite = new Sprite();
+                               overSprite = new Sprite();
+                       }
                }
-               
+
                /**
                 *  @copy org.apache.flex.core.IBead#strand
-                *  
+                *
                 *  @langversion 3.0
                 *  @playerversion Flash 10.2
                 *  @playerversion AIR 2.6
@@ -73,29 +78,34 @@ package org.apache.flex.html.beads
                override public function set strand(value:IStrand):void
                {
                        super.strand = value;
-                       
-                       shape = new Shape();
-                       shape.graphics.beginFill(0xCCCCCC);
-                       shape.graphics.drawRect(0, 0, 10, 10);
-                       shape.graphics.endFill();
-                       SimpleButton(value).upState = upSprite;
-                       SimpleButton(value).downState = downSprite;
-                       SimpleButton(value).overState = overSprite;
-                       SimpleButton(value).hitTestState = shape;
-                       
-                       setupBackground(upSprite);
-                       setupBackground(overSprite, "hover");
-                       setupBackground(downSprite, "active");
+
+                       COMPILE::AS3 {
+                               shape = new Shape();
+                               shape.graphics.beginFill(0xCCCCCC);
+                               shape.graphics.drawRect(0, 0, 10, 10);
+                               shape.graphics.endFill();
+                               SimpleButton(value).upState = upSprite;
+                               SimpleButton(value).downState = downSprite;
+                               SimpleButton(value).overState = overSprite;
+                               SimpleButton(value).hitTestState = shape;
+
+                               setupBackground(upSprite);
+                               setupBackground(overSprite, "hover");
+                               setupBackground(downSprite, "active");
+                       }
+               }
+
+               COMPILE::AS3 {
+                       private var upSprite:Sprite;
+                       private var downSprite:Sprite;
+                       private var overSprite:Sprite;
+                       private var shape:Shape;
                }
-               
-               private var upSprite:Sprite;
-               private var downSprite:Sprite;
-               private var overSprite:Sprite;
-               private var shape:Shape;
-               
+
                /**
                 * @private
                 */
+               COMPILE::AS3
                private function setupBackground(sprite:Sprite, state:String = 
null):void
                {
                        var backgroundImage:Object = 
ValuesManager.valuesImpl.getValue(_strand, "background-image", state);
@@ -109,7 +119,7 @@ package org.apache.flex.html.beads
                     trace(e);
                     e.preventDefault();
                 });
-                               
loader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE, function 
(e:flash.events.Event):void { 
+                               
loader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE, function 
(e:flash.events.Event):void {
                     var host:UIButtonBase = UIButtonBase(_strand);
                     if (isNaN(host.explicitWidth) && isNaN(host.percentWidth))
                     {
@@ -119,7 +129,7 @@ package org.apache.flex.html.beads
                     }
                     else
                         loader.content.width = host.width;
-                    
+
                     if (isNaN(host.explicitHeight) && 
isNaN(host.percentHeight))
                     {
                         host.setHeight(loader.content.height);
@@ -132,10 +142,11 @@ package org.apache.flex.html.beads
                                });
                        }
                }
-               
+
                /**
                 * @private
                 */
+               COMPILE::AS3
                private function updateHitArea():void
                {
                        shape.graphics.clear();
@@ -144,4 +155,4 @@ package org.apache.flex.html.beads
                        shape.graphics.endFill();
                }
        }
-}
\ No newline at end of file
+}

Reply via email to