flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From carlosrov...@apache.org
Subject git commit: [flex-asjs] [refs/heads/develop] - Table finish initial implementation. Now polish some aspects
Date Sat, 14 Jan 2017 23:48:08 GMT
Repository: flex-asjs
Updated Branches:
  refs/heads/develop d547fd49c -> 0a446f40c


Table finish initial implementation. Now polish some aspects


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

Branch: refs/heads/develop
Commit: 0a446f40c6a39af9b6c97a16f2691fd74820cbf7
Parents: d547fd4
Author: Carlos Rovira <carlosrovira@apache.org>
Authored: Sun Jan 15 00:48:04 2017 +0100
Committer: Carlos Rovira <carlosrovira@apache.org>
Committed: Sun Jan 15 00:48:04 2017 +0100

----------------------------------------------------------------------
 .../src/main/flex/org/apache/flex/mdl/THead.as  |  30 +---
 .../src/main/flex/org/apache/flex/mdl/Table.as  |  95 +++++++---
 .../flex/org/apache/flex/mdl/TableColumn.as     | 173 +++++++++++++++++++
 .../flex/mdl/itemRenderers/TableItemRenderer.as |  30 ++--
 .../src/main/resources/mdl-manifest.xml         |   2 +
 5 files changed, 269 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0a446f40/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/THead.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/THead.as
b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/THead.as
index 9b6e92a..f845d5a 100644
--- a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/THead.as
+++ b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/THead.as
@@ -27,7 +27,7 @@ package org.apache.flex.mdl
     
 	/**
 	 *  The THead class is a Container component capable of parenting
-	 *  TH Table Header Cells
+	 *  TableColumn for MDL Table
 	 *  
 	 *  @langversion 3.0
 	 *  @playerversion Flash 10.2
@@ -48,7 +48,7 @@ package org.apache.flex.mdl
 		{
 			super();
 
-			className = ""; //set to empty string avoid 'undefined' output when no class selector
is assigned by user;
+			//className = ""; //set to empty string avoid 'undefined' output when no class selector
is assigned by user;
 		}
 		
         /**
@@ -57,10 +57,7 @@ package org.apache.flex.mdl
         COMPILE::JS
         override protected function createElement():WrappedHTMLElement
         {
-			typeNames = "";
-
             element = document.createElement('thead') as WrappedHTMLElement;
-            element.className = typeNames;
             
 			positioner = element;
             
@@ -72,28 +69,5 @@ package org.apache.flex.mdl
 
             return element;
         }
-
-		protected var _ascending:Boolean;
-        /**
-		 *  A boolean flag to activate "mdl-data-table__header--sorted-ascending" effect selector.
-		 *  Applies all/individual selectable behavior (checkboxes)
-		 *  Optional; goes on table element
-		 *
-		 *  @langversion 3.0
-		 *  @playerversion Flash 10.2
-		 *  @playerversion AIR 2.6
-		 *  @productversion FlexJS 0.0
-		 */
-        public function get ascending():Boolean
-        {
-            return _ascending;
-        }
-        public function set selectable(value:Boolean):void
-        {
-			_ascending = value;
-
-			element.classList.toggle("mdl-data-table__header--sorted-ascending", _ascending);
-			element.classList.toggle("mdl-data-table__header--sorted-descending", _ascending == false);
-        }
 	}
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0a446f40/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/Table.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/Table.as
b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/Table.as
index c1e5240..a9043de 100644
--- a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/Table.as
+++ b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/Table.as
@@ -20,6 +20,9 @@ package org.apache.flex.mdl
 {
 	import org.apache.flex.events.Event;
 	import org.apache.flex.mdl.List;
+	import org.apache.flex.utils.StringUtil;
+	import org.apache.flex.core.IChild;
+	import org.apache.flex.core.IUIBase;
     
     COMPILE::JS
     {
@@ -58,7 +61,65 @@ package org.apache.flex.mdl
 
 			className = ""; //set to empty string avoid 'undefined' output when no class selector
is assigned by user;
 		}
+
+		private var _columns:Array;
+        /**
+		 *  columns. Optional
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+        public function get columns():Array
+        {
+            return _columns;
+        }
+        public function set columns(value:Array):void
+        {
+			_columns = value;
+
+			if(_columns != null && _columns.length > 0)
+			{
+				COMPILE::JS
+            	{
+					for each (var column:TableColumn in _columns){
+						head.addElement(column);
+					}
+				}
+			}
+        }
+
+		override public function addElement(c:IChild, dispatchEvent:Boolean = true):void
+		{
+			/*COMPILE::SWF
+            {
+                if(_elements == null)
+                    _elements = [];
+                _elements[_elements.length] = c;
+                $displayObjectContainer.addChild(c.$displayObject);
+                if (c is IUIBase)
+                {
+                    IUIBase(c).addedToParent();
+                }
+                    
+            }*/
+            COMPILE::JS
+            {
+				if(c is THead) {
+					positioner.appendChild(c.positioner);
+					(c as IUIBase).addedToParent();
+				} else
+				{
+					element.appendChild(c.positioner);
+					(c as IUIBase).addedToParent();
+				}
+            }
+		}
 		
+		COMPILE::JS
+		private var head:THead;
+
         /**
          * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement
          */
@@ -68,34 +129,24 @@ package org.apache.flex.mdl
 			typeNames = "mdl-data-table mdl-js-data-table";
 
             positioner = document.createElement('table') as WrappedHTMLElement;
-			element = document.createElement('tbody') as WrappedHTMLElement;
+			
+			head = new THead();
+			addElement(head);
 
+			element = document.createElement('tbody') as WrappedHTMLElement;
+			
 			positioner.appendChild(element);
-            
 			element.flexjs_wrapper = this;
 
-            return positioner;
+            return element;
         }
-
-		private var _className:String;
-
-        /**
-         * since we have a div surronding the main input, we need to 
-         * route the class assignaments to div
-         */
-        override public function set className(value:String):void
+		
+		COMPILE::JS
+		override protected function setClassName(value:String):void
 		{
-			if (_className != value)
-			{
-                COMPILE::JS
-                {
-                    positioner.className = typeNames ? value + ' ' + typeNames : value; 
           
-                }
-				_className = value;
-				dispatchEvent(new Event("classNameChanged"));
-			}
+			positioner.className = value;
 		}
-		
+        
 		protected var _shadow:Number = 0;
         /**
 		 *  A boolean flag to activate "mdl-shadow--Xdp" effect selector.
@@ -121,6 +172,7 @@ package org.apache.flex.mdl
 					_shadow = value;
 
 					positioner.classList.add("mdl-shadow--" + _shadow + "dp");
+					typeNames = positioner.className;
 				}
 			}
         }
@@ -147,6 +199,7 @@ package org.apache.flex.mdl
 			COMPILE::JS
             {
 				positioner.classList.toggle("mdl-data-table--selectable", _selectable);
+				typeNames = positioner.className;
 			}
         }
 	}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0a446f40/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/TableColumn.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/TableColumn.as
b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/TableColumn.as
new file mode 100644
index 0000000..e26298a
--- /dev/null
+++ b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/TableColumn.as
@@ -0,0 +1,173 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.mdl
+{
+	import org.apache.flex.core.ContainerBase;
+
+    COMPILE::JS
+    {
+        import org.apache.flex.core.WrappedHTMLElement;            
+    }
+    
+	/**
+	 *  The TableColumn class represents an HTML <th> element that
+     *  be inside a <thead> in a MLD Table
+	 *  
+     *  @toplevel
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion FlexJS 0.0
+	 */
+	public class TableColumn extends ContainerBase
+	{
+		/**
+		 *  constructor.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		public function TableColumn()
+		{
+			super();
+		}
+
+        private var _headerText:String = "";
+
+        /**
+         *  The text of the td
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+		public function get headerText():String
+		{
+            return _headerText;
+		}
+		public function set headerText(value:String):void
+		{
+            _headerText = value;
+
+			COMPILE::JS
+			{
+                if(textNode == null)
+                {
+                    textNode = document.createTextNode('') as Text;
+                    element.appendChild(textNode);
+                }
+                
+                textNode.nodeValue = value;	
+			}
+		}
+		
+        COMPILE::JS
+        protected var textNode:Text;
+
+        /**
+         * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement
+         */
+        COMPILE::JS
+        override protected function createElement():WrappedHTMLElement
+        {
+			element = document.createElement('th') as WrappedHTMLElement;
+
+            positioner = element;
+            element.flexjs_wrapper = this;
+            
+            return element;
+        }
+
+        private var _nonNumeric:Boolean;
+        /**
+         * Activate "mdl-data-table__cell--non-numeric" class selector, for use in table
td item.
+         * Applies text formatting to data cell
+		 * Optional; goes on both table header and table data cells 
+         */
+        public function get nonNumeric():Boolean
+        {
+            return _nonNumeric;
+        }
+        public function set nonNumeric(value:Boolean):void
+        {
+            _nonNumeric = value;
+
+            COMPILE::JS
+            {
+                element.classList.toggle("mdl-data-table__cell--non-numeric", _nonNumeric);
+                typeNames = element.className;
+            }
+        }
+
+        protected var _ascending:Boolean;
+        /**
+		 *  A boolean flag to activate "mdl-data-table__header--sorted-ascending" effect selector.
+		 *  Applies visual styling to indicate the column is sorted in ascending order
+		 *  Optional;
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+        public function get ascending():Boolean
+        {
+            return _ascending;
+        }
+        public function set ascending(value:Boolean):void
+        {
+			_ascending = value;
+
+			COMPILE::JS
+			{
+				element.classList.toggle("mdl-data-table__header--sorted-ascending", _ascending);
+				typeNames = element.className;
+			}
+        }
+
+        protected var _descending:Boolean;
+        /**
+		 *  A boolean flag to activate "mdl-data-table__header--sorted-descending" effect selector.
+		 *  Applies visual styling to indicate the column is sorted in descending order
+		 *  Optional;
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+        public function get descending():Boolean
+        {
+            return _descending;
+        }
+        public function set descending(value:Boolean):void
+        {
+			_descending = value;
+
+			COMPILE::JS
+			{
+				element.classList.toggle("mdl-data-table__header--sorted-descending", _descending);
+				typeNames = element.className;
+			}
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0a446f40/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/itemRenderers/TableItemRenderer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/itemRenderers/TableItemRenderer.as
b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/itemRenderers/TableItemRenderer.as
index 9d1e7e2..c8a76f0 100644
--- a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/itemRenderers/TableItemRenderer.as
+++ b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/itemRenderers/TableItemRenderer.as
@@ -109,27 +109,32 @@ package org.apache.flex.mdl.itemRenderers
         COMPILE::JS
         override protected function createElement():WrappedHTMLElement
         {
-            positioner = document.createElement('tr') as WrappedHTMLElement;
-            element = document.createElement('td') as WrappedHTMLElement;
-
-            positioner.appendChild(element);
-            
-			if(MXMLDescriptor == null)
+            if(MXMLDescriptor == null)
 			{
+                positioner = document.createElement('tr') as WrappedHTMLElement;
+                element = document.createElement('td') as WrappedHTMLElement;
+
+                positioner.appendChild(element);
+
 				textNode = document.createTextNode('') as Text;
 				element.appendChild(textNode);
-			}
+                element.flexjs_wrapper = this;
+                return positioner;
+			} else {
+                element = document.createElement('tr') as WrappedHTMLElement;
+                
+                positioner = element;
 
-            //positioner = element;
-            element.flexjs_wrapper = this;
-            
-            return positioner;
+                element.flexjs_wrapper = this;
+
+                return element;
+            }
         }
 
 		private var _nonNumeric:Boolean;
         /**
          * Activate "mdl-data-table__cell--non-numeric" class selector, for use in table
td item.
-         * Applies text formatting to data cell
+         * Applies text formatting to data cell. Numeric is the default
 		 * Optional; goes on both table header and table data cells 
          */
         public function get nonNumeric():Boolean
@@ -143,6 +148,7 @@ package org.apache.flex.mdl.itemRenderers
             COMPILE::JS
             {
                 element.classList.toggle("mdl-data-table__cell--non-numeric", _nonNumeric);
+				typeNames = element.className;
             }
         }
 	}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0a446f40/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml b/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml
index 269da0c..5eae819 100644
--- a/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml
+++ b/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml
@@ -57,6 +57,8 @@
     <component id="ListItemSecondaryInfo" class="org.apache.flex.mdl.beads.ListItemSecondaryInfo"/>
     <component id="ListItemTextBody" class="org.apache.flex.mdl.beads.ListItemTextBody"/>
     <component id="Table" class="org.apache.flex.mdl.Table"/>
+    <component id="THead" class="org.apache.flex.mdl.THead"/>
+    <component id="TableColumn" class="org.apache.flex.mdl.TableColumn"/>
     <component id="TableItemRenderer" class="org.apache.flex.mdl.itemRenderers.TableItemRenderer"/>
     <component id="TableView" class="org.apache.flex.mdl.beads.views.TableView"/>
     <component id="NavigationLayout" class="org.apache.flex.mdl.NavigationLayout"/>


Mime
View raw message