You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by pi...@apache.org on 2017/05/21 21:09:08 UTC

git commit: [flex-asjs] [refs/heads/release0.8.0] - Allow create DropDownList with width less than 124px which is forced by MDL library

Repository: flex-asjs
Updated Branches:
  refs/heads/release0.8.0 839a64883 -> d1a3b36f6


Allow create DropDownList with width less than 124px which is forced by MDL library


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

Branch: refs/heads/release0.8.0
Commit: d1a3b36f636defefa20dfac6128817e911c4450b
Parents: 839a648
Author: piotrz <pi...@apache.org>
Authored: Sun May 21 23:09:03 2017 +0200
Committer: piotrz <pi...@apache.org>
Committed: Sun May 21 23:09:03 2017 +0200

----------------------------------------------------------------------
 .../flex/mdl/beads/views/DropDownListView.as    | 40 ++++++++++++++++----
 1 file changed, 33 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d1a3b36f/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/views/DropDownListView.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/views/DropDownListView.as b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/views/DropDownListView.as
index 552edf3..ae1d2df 100644
--- a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/views/DropDownListView.as
+++ b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/views/DropDownListView.as
@@ -69,7 +69,7 @@ package org.apache.flex.mdl.beads.views
         override public function set strand(value:IStrand):void
         {
             super.strand = value;
-            
+
             var dropDownList:DropDownList = (value as DropDownList);
 
             _dropDown = new Menu();
@@ -77,9 +77,10 @@ package org.apache.flex.mdl.beads.views
 
             COMPILE::JS
             {
+                _dropDown.element.addEventListener("mdl-componentupgraded", onElementMdlComponentUpgraded, false);
                 setIdForDisplayList();
             }
-            
+
             _labelDisplay = new Div();
 
             if (!dropDownList.icon)
@@ -97,16 +98,16 @@ package org.apache.flex.mdl.beads.views
             dropDownList.addElement(_dropDown);
         }
 
-        override protected function handleInitComplete(event:org.apache.flex.events.Event):void
+        override protected function handleInitComplete(event:Event):void
         {
             super.handleInitComplete(event);
 
             COMPILE::JS
             {
                 host.element.classList.add("DropDownList");
+
+                setWidthForDropDownListComponents();
             }
-            _dropDown.width = isNaN(host.width) ? 100 : host.width - 1;
-            _labelDisplay.width = isNaN(host.width) ? 100 : host.width - 25;
         }
 
         COMPILE::JS
@@ -114,10 +115,35 @@ package org.apache.flex.mdl.beads.views
         {
             if (!host.element.id)
             {
-               host.element.id = "dropDownList" + Math.random();
+                host.element.id = "dropDownList" + Math.random();
             }
 
             _dropDown.dataMdlFor = host.element.id;
         }
+
+        COMPILE::JS
+        private function setWidthForDropDownListComponents():void
+        {
+            if (!isNaN(host.width))
+            {
+                _dropDown.width = host.width - 1;
+                _labelDisplay.width = host.width - 25;
+            }
+            else
+            {
+                _labelDisplay.width = 30;
+            }
+        }
+
+        COMPILE::JS
+        private function onElementMdlComponentUpgraded(event:Event):void
+        {
+            if (!event.currentTarget) return;
+            if (_dropDown)
+            {
+                _dropDown.element.removeEventListener("mdl-componentupgraded", onElementMdlComponentUpgraded, false);
+                _dropDown.element.style.minWidth = "40px";
+            }
+        }
     }
-}
+}
\ No newline at end of file