flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pio...@apache.org
Subject [05/23] git commit: [flex-asjs] [refs/heads/develop] - FLEX-35328 - Use Select and Option in MDL DropDownList from HTML module
Date Thu, 29 Jun 2017 19:22:41 GMT
FLEX-35328 - Use Select and Option in MDL DropDownList from HTML module


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

Branch: refs/heads/develop
Commit: ec944a7a90fbcd2b17f055488413a739abfbfbcf
Parents: 486a243
Author: piotrz <piotrz@apache.org>
Authored: Fri Jun 23 08:52:06 2017 +0200
Committer: piotrz <piotrz@apache.org>
Committed: Fri Jun 23 08:52:06 2017 +0200

----------------------------------------------------------------------
 .../flex/org/apache/flex/mdl/DropDownList.as    | 44 ++++++-------
 .../beads/controllers/DropDownListController.as |  5 +-
 .../flex/mdl/beads/views/DropDownListView.as    | 18 +++---
 .../itemRenderers/DropDownListItemRenderer.as   | 65 +++-----------------
 4 files changed, 38 insertions(+), 94 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ec944a7a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/DropDownList.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/DropDownList.as
b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/DropDownList.as
index 8b2c430..2dddaf3 100644
--- a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/DropDownList.as
+++ b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/DropDownList.as
@@ -20,8 +20,11 @@ package org.apache.flex.mdl
 {
     import org.apache.flex.core.IItemRenderer;
     import org.apache.flex.core.ISelectionModel;
+    import org.apache.flex.core.UIBase;
     import org.apache.flex.events.ItemAddedEvent;
     import org.apache.flex.html.DataContainer;
+    import org.apache.flex.html.Option;
+    import org.apache.flex.html.Select;
 
     COMPILE::JS
     {
@@ -60,28 +63,21 @@ package org.apache.flex.mdl
             super();
         }
 
-        COMPILE::JS
-        protected var _labelDisplay:HTMLLabelElement;
-        COMPILE::JS
-        protected var _dropDown:HTMLSelectElement;
+        protected var _dropDown:Select;
 
-        COMPILE::JS
+        public function get dropDown():Select
         {
-            /**
-             * @flexjsignorecoercion HTMLSelectElement
-             */
-            public function get dropDown():HTMLSelectElement
-            {
-                return _dropDown;
-            }
+            return _dropDown;
+        }
 
-            /**
-             * @flexjsignorecoercion HTMLSelectElement
-             */
-            public function set dropDown(value:HTMLSelectElement):void
-            {
-                _dropDown = value;
-            }
+        public function set dropDown(value:Select):void
+        {
+            _dropDown = value;
+        }
+        
+        COMPILE::JS
+        {
+            protected var _labelDisplay:HTMLLabelElement;
 
             /**
              * @flexjsignorecoercion HTMLLabelElement
@@ -140,12 +136,12 @@ package org.apache.flex.mdl
         {
             COMPILE::JS
             {
-                var options:HTMLOptionsCollection = dropDown.options;
-                var optionsCount:int = options.length;
-
+                var optionsCount:int = dropDown.numElements;
+                
                 for (var i:int = 1; i < optionsCount; i++)
                 {
-                   dropDown.remove(i);
+                   var item:UIBase = dropDown.getElementAt(i) as UIBase;
+                   dropDown.removeElement(item);
                 }
             }
         }
@@ -154,7 +150,7 @@ package org.apache.flex.mdl
         {
             COMPILE::JS
             {
-                dropDown.appendChild(renderer.element);
+                dropDown.addElement(renderer);
             }
             
             var newEvent:ItemAddedEvent = new ItemAddedEvent("itemAdded");

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ec944a7a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/controllers/DropDownListController.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/controllers/DropDownListController.as
b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/controllers/DropDownListController.as
index 53c37ef..bd9bf3b 100644
--- a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/controllers/DropDownListController.as
+++ b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/controllers/DropDownListController.as
@@ -23,7 +23,6 @@ package org.apache.flex.mdl.beads.controllers
     import org.apache.flex.core.IStrand;
     import org.apache.flex.events.IEventDispatcher;
     import org.apache.flex.mdl.DropDownList;
-    import org.apache.flex.mdl.beads.views.DropDownListView;
     import org.apache.flex.events.Event;
 
 	/**
@@ -58,8 +57,6 @@ package org.apache.flex.mdl.beads.controllers
 		 *  @productversion FlexJS 0.8
          */
 		protected var model:ISelectionModel;
-        protected var dropDownListView:DropDownListView;
-
 		protected var _strand:IStrand;
 
 		/**
@@ -80,7 +77,7 @@ package org.apache.flex.mdl.beads.controllers
 
 			COMPILE::JS
             {
-                dropDownList.dropDown.addEventListener("onchange", onDisplayItemClick, false);
+                dropDownList.dropDown.element.addEventListener("onchange", onDisplayItemClick,
false);
             }
 		}
 

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ec944a7a/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 51960d6..e3c1658 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
@@ -19,6 +19,8 @@
 package org.apache.flex.mdl.beads.views
 {
     import org.apache.flex.core.IStrand;
+    import org.apache.flex.html.Option;
+    import org.apache.flex.html.Select;
     import org.apache.flex.html.beads.DataContainerView;
     import org.apache.flex.mdl.DropDownList;
     import org.apache.flex.events.Event;
@@ -45,8 +47,6 @@ package org.apache.flex.mdl.beads.views
          *  @copy org.apache.flex.core.IBead#strand
          *
          *  @flexjsignorecoercion HTMLLabelElement
-         *  @flexjsignorecoercion HTMLSelectElement
-         *  @flexjsignorecoercion HTMLOptionElement
          *     
          *  @langversion 3.0
          *  @playerversion Flash 10.2
@@ -64,18 +64,18 @@ package org.apache.flex.mdl.beads.views
                 dropDownList.labelDisplay = document.createElement('label') as HTMLLabelElement;
                 dropDownList.labelDisplay.classList.add("mdl-textfield__label");
 
-                dropDownList.dropDown = document.createElement('select') as HTMLSelectElement;
-                dropDownList.dropDown.classList.add("mdl-textfield__input");
+                dropDownList.dropDown = new Select();
+                dropDownList.dropDown.element.classList.add("mdl-textfield__input");
 
-                var emptyOption:HTMLOptionElement = document.createElement('option') as HTMLOptionElement;
-                emptyOption.style.display = "none";
+                var emptyOption:Option = new Option();
+                emptyOption.element.style.display = "none";
 
-                dropDownList.dropDown.appendChild(emptyOption);
+                dropDownList.dropDown.addElement(emptyOption);
                 
                 setNameForDropDownList();
 
                 dropDownList.element.appendChild(dropDownList.labelDisplay);
-                dropDownList.element.appendChild(dropDownList.dropDown);
+                dropDownList.addElement(dropDownList.dropDown);
             }
         }
 
@@ -96,7 +96,7 @@ package org.apache.flex.mdl.beads.views
 
             var name:String = "dropDownList" + Math.random();
             dropDownList.labelDisplay.htmlFor = name;
-            dropDownList.dropDown.name = name;
+            dropDownList.dropDown.element.name = name;
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ec944a7a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/itemRenderers/DropDownListItemRenderer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/itemRenderers/DropDownListItemRenderer.as
b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/itemRenderers/DropDownListItemRenderer.as
index 65e13e1..d8ba333 100644
--- a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/itemRenderers/DropDownListItemRenderer.as
+++ b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/itemRenderers/DropDownListItemRenderer.as
@@ -18,6 +18,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.flex.mdl.itemRenderers
 {
+    import org.apache.flex.html.Option;
     import org.apache.flex.html.supportClasses.MXMLItemRenderer;
 
     COMPILE::JS
@@ -49,46 +50,8 @@ package org.apache.flex.mdl.itemRenderers
 
             className = ""; //set to empty string avoid 'undefined' output when no class
selector is assigned by user;
         }
-        
-        private var _text:String = "";
 
-        /**
-         *  The text of the menu item
-         *  
-         *  @langversion 3.0
-         *  @playerversion Flash 10.2
-         *  @playerversion AIR 2.6
-         *  @productversion FlexJS 0.8
-         */
-		public function get text():String
-		{
-            COMPILE::SWF
-            {
-                return _text;
-            }
-            COMPILE::JS
-            {
-                return textNode.nodeValue;
-            }
-		}
-
-		public function set text(value:String):void
-		{
-            COMPILE::SWF
-            {
-                _text = value;
-            }
-            COMPILE::JS
-            {
-                textNode.nodeValue = value;
-            }
-		}
-
-        COMPILE::JS
-        private var textNode:Text;
-
-        COMPILE::JS
-        private var item:HTMLOptionElement;
+        private var item:Option;
 
         /**
          *  Sets the data value and uses the String version of the data for display.
@@ -104,49 +67,37 @@ package org.apache.flex.mdl.itemRenderers
         {
             super.data = value;
 
-            var text:String;
             if (labelField)
             {
-                text = String(value[labelField]);
+                item.text = String(value[labelField]);
             }
             else
             {
-                text = String(value);
+                item.text = String(value);
             }
 
             COMPILE::JS
             {
                 if (dataField)
                 {
-                    item.value = String(value[dataField]);
+                    item.element["value"] = String(value[dataField]);
                 }
                 else
                 {
-                    item.value = String(value);
-                }
-
-                if(textNode != null)
-                {
-                    textNode.nodeValue = text;
+                    item.element["value"] = String(value);
                 }
             }
         }
 
         /**
          * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement
-         * @flexjsignorecoercion HTMLOptionElement
-         *
-		 * @flexjsignorecoercion Text
          */
         COMPILE::JS
         override protected function createElement():WrappedHTMLElement
         {
-            item = document.createElement('option') as HTMLOptionElement;
-            
-            textNode = document.createTextNode('') as Text;
-            item.appendChild(textNode);
+            item = new Option();
 
-            element = item as WrappedHTMLElement;
+            element = item.element as WrappedHTMLElement;
 
             positioner = element;
             element.flexjs_wrapper = this;


Mime
View raw message