Repository: flex-asjs
Updated Branches:
  refs/heads/develop 74ea47cbc -> 36151f71c


Fixed ImageButton
It’s now a button instead of an input as input was causing lots of issues


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

Branch: refs/heads/develop
Commit: f14d6a0996e7b768186feeff4642641e0a14beba
Parents: 6f30fb2
Author: Harbs <ha...@in-tools.com>
Authored: Tue Feb 21 10:39:22 2017 +0200
Committer: Harbs <ha...@in-tools.com>
Committed: Tue Feb 21 10:39:22 2017 +0200

----------------------------------------------------------------------
 .../flex/org/apache/flex/html/ImageButton.as    | 45 +++++++++++---------
 .../HTML/src/main/resources/defaults.css        |  1 +
 2 files changed, 27 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f14d6a09/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/ImageButton.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/ImageButton.as 
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/ImageButton.as
index e5fc54c..5912a84 100644
--- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/ImageButton.as
+++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/ImageButton.as
@@ -20,6 +20,7 @@ package org.apache.flex.html
 {
     import org.apache.flex.core.SimpleCSSStyles;
        import org.apache.flex.events.Event;
+    import org.apache.flex.html.beads.models.ImageModel;
        
     COMPILE::JS
     {
@@ -55,18 +56,17 @@ package org.apache.flex.html
          * @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";
-                       inputElement.setAttribute("value", " ");
-
-                       return element;
-               }
+        override protected function createElement():WrappedHTMLElement
+        {
+            element = document.createElement('button') as WrappedHTMLElement;
+            element.setAttribute('type', 'button');
+            
+            positioner = element;
+            positioner.style.position = 'relative';
+            element.flexjs_wrapper = this;
+            
+            return element;
+        }        
 
                [Bindable("srcChanged")]
                /**
@@ -76,18 +76,25 @@ package org.apache.flex.html
                 */
         public function get src():String
         {
-            return style.backgroundImage;
+            return ImageModel(model).url;
         }
 
         public function set src(url:String):void
         {
-            if (!style)
-                style = new SimpleCSSStyles();
-            style.backgroundImage = url;
+            ImageModel(model).url = url;
+            COMPILE::SWF
+            {
+                if (!style)
+                    style = new SimpleCSSStyles();
+                style.backgroundImage = url;
+            }
 
-            COMPILE::JS {
-               var inputElement:HTMLInputElement = element as HTMLInputElement;
-                               inputElement.src = url;
+            COMPILE::JS
+            {
+                var inner:String = '';
+                if (url)
+                    inner = "<img src='" + url + "'/>";
+                element.innerHTML = inner;
             }
                        
                        dispatchEvent(new Event("srcChanged"));

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f14d6a09/frameworks/projects/HTML/src/main/resources/defaults.css
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/resources/defaults.css 
b/frameworks/projects/HTML/src/main/resources/defaults.css
index 4eb6de6..8abe5ee 100644
--- a/frameworks/projects/HTML/src/main/resources/defaults.css
+++ b/frameworks/projects/HTML/src/main/resources/defaults.css
@@ -291,6 +291,7 @@ ImageAndTextButton
 
 ImageButton
 {
+       IBeadModel: 
ClassReference("org.apache.flex.html.beads.models.ImageModel");
        border-style: none;
 }
 

Reply via email to