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/08/15 09:46:41 UTC

git commit: [flex-asjs] [refs/heads/develop] - FLEX-35350 - Make HTML element "table" as main element of MDL Table component which allows to add bead to it instead of "tbody" - TableCell and TableColumnt now extends existing classes in Basic module - acc

Repository: flex-asjs
Updated Branches:
  refs/heads/develop 003ccc46b -> 1d4eb6373


FLEX-35350 - Make HTML element "table" as main element of MDL Table component which allows to add bead to it instead of "tbody"
- TableCell and TableColumnt now extends existing classes in Basic module - accordingly TableCell and TableHeader


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

Branch: refs/heads/develop
Commit: 1d4eb6373c2e84594feea4a5b4247e752153a616
Parents: 003ccc4
Author: piotrz <pi...@apache.org>
Authored: Tue Aug 15 11:46:37 2017 +0200
Committer: piotrz <pi...@apache.org>
Committed: Tue Aug 15 11:46:37 2017 +0200

----------------------------------------------------------------------
 .../src/main/flex/org/apache/flex/mdl/TBody.as  | 67 +++++++++++++++++
 .../src/main/flex/org/apache/flex/mdl/Table.as  | 78 +++++++++++---------
 .../main/flex/org/apache/flex/mdl/TableCell.as  | 14 ++--
 .../flex/org/apache/flex/mdl/TableColumn.as     | 14 ++--
 4 files changed, 125 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1d4eb637/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/TBody.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/TBody.as b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/TBody.as
new file mode 100644
index 0000000..8452c48
--- /dev/null
+++ b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/TBody.as
@@ -0,0 +1,67 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.html.Group;
+
+    COMPILE::JS
+    {
+        import org.apache.flex.core.WrappedHTMLElement;
+    }
+
+	/**
+	 *  The TBody class is a Container component capable of presenting content of MDL Table
+	 *
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion FlexJS 0.8
+	 */
+	public class TBody extends Group
+	{
+		/**
+		 *  constructor.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.8
+		 */
+		public function TBody()
+		{
+			super();
+
+			//className = ""; //set to empty string avoid 'undefined' output when no class selector is assigned by user;
+		}
+
+        /**
+         * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement
+         */
+        COMPILE::JS
+        override protected function createElement():WrappedHTMLElement
+        {
+            element = document.createElement('tbody') as WrappedHTMLElement;
+
+			positioner = element;
+            element.flexjs_wrapper = this;
+
+            return element;
+        }
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1d4eb637/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 e08465b..22dbfe5 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
@@ -19,8 +19,7 @@
 package org.apache.flex.mdl
 {
 	import org.apache.flex.core.IChild;
-	import org.apache.flex.core.IUIBase;
-    
+
     COMPILE::JS
     {
         import org.apache.flex.core.WrappedHTMLElement;
@@ -82,7 +81,7 @@ package org.apache.flex.mdl
 				COMPILE::JS
             	{
 					for each (var column:TableColumn in _columns){
-						head.addElement(column);
+						thead.addElement(column);
 					}
 				}
 			}
@@ -99,34 +98,25 @@ package org.apache.flex.mdl
          */
 		override public function addElement(c:IChild, dispatchEvent:Boolean = true):void
 		{
-			COMPILE::SWF
-            {
-				// this part is not done for Table
-                /*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();
-				}
+				addTHeadToParent();
+				addTBodyToParent();
+
+				if (_isTheadAddedToParent && _isTbodyAddedToParent)
+                {
+                    tbody.addElement(c);
+                }
             }
 		}
 		
 		COMPILE::JS
-		private var head:THead;
+		private var thead:THead;
+		private var _isTheadAddedToParent:Boolean = false;
+
+		COMPILE::JS
+		private var tbody:TBody;
+        private var _isTbodyAddedToParent:Boolean = false;
 
         /**
          * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement
@@ -136,15 +126,13 @@ package org.apache.flex.mdl
         {
 			typeNames = "mdl-data-table mdl-js-data-table";
 
-            positioner = document.createElement('table') as WrappedHTMLElement;
-			
-			head = new THead();
-			addElement(head);
+			element = document.createElement('table') as WrappedHTMLElement;
+
+            thead = new THead();
+			tbody = new TBody();
 
-			element = document.createElement('tbody') as WrappedHTMLElement;
-			
-			positioner.appendChild(element);
-			element.flexjs_wrapper = this;
+			positioner = element;
+            element.flexjs_wrapper = this;
 
             return element;
         }
@@ -210,5 +198,29 @@ package org.apache.flex.mdl
 				typeNames = positioner.className;
 			}
         }
+
+		COMPILE::JS
+        private function addTHeadToParent():void
+        {
+            if (_isTheadAddedToParent) return;
+
+            if (thead)
+            {
+                super.addElement(thead);
+				_isTheadAddedToParent = true;
+            }
+        }
+
+        COMPILE::JS
+		private function addTBodyToParent():void
+		{
+			if (_isTbodyAddedToParent) return;
+
+			if (tbody)
+            {
+                super.addElement(tbody);
+				_isTbodyAddedToParent = true;
+            }
+		}
 	}
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1d4eb637/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/TableCell.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/TableCell.as b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/TableCell.as
index b4abd7f..c90039f 100644
--- a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/TableCell.as
+++ b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/TableCell.as
@@ -18,7 +18,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.flex.mdl
 {
-	import org.apache.flex.html.Group;
+	import org.apache.flex.html.TableCell;
 
     COMPILE::JS
     {
@@ -33,7 +33,7 @@ package org.apache.flex.mdl
 	 *  @playerversion AIR 2.6
 	 *  @productversion FlexJS 0.8
 	 */
-	public class TableCell extends Group
+	public class TableCell extends org.apache.flex.html.TableCell
 	{
 		/**
 		 *  constructor.
@@ -46,6 +46,8 @@ package org.apache.flex.mdl
 		public function TableCell()
 		{
 			super();
+
+			className = "";
 		}
 
 		private var _text:String = "";
@@ -87,13 +89,11 @@ package org.apache.flex.mdl
         COMPILE::JS
         override protected function createElement():WrappedHTMLElement
         {
-			element = document.createElement('td') as WrappedHTMLElement;
-            element.classList.add("mdl-data-table__cell--non-numeric");
+            typeNames = "mdl-data-table__cell--non-numeric";
 
-            positioner = element;
-            element.flexjs_wrapper = this;
+           // element.classList.add("mdl-data-table__cell--non-numeric");
 
-            return element;
+            return super.createElement();;
         }
 	}
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1d4eb637/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
index 2e67c28..d79eb66 100644
--- 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
@@ -18,7 +18,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.flex.mdl
 {
-	import org.apache.flex.html.Group;
+    import org.apache.flex.html.TableHeader;
 
     COMPILE::JS
     {
@@ -36,7 +36,7 @@ package org.apache.flex.mdl
 	 *  @playerversion AIR 2.6
 	 *  @productversion FlexJS 0.8
 	 */
-	public class TableColumn extends Group
+	public class TableColumn extends TableHeader
 	{
 		/**
 		 *  constructor.
@@ -49,6 +49,8 @@ package org.apache.flex.mdl
 		public function TableColumn()
 		{
 			super();
+
+			className = "";
 		}
 
         private var _headerText:String = "";
@@ -90,13 +92,9 @@ package org.apache.flex.mdl
         COMPILE::JS
         override protected function createElement():WrappedHTMLElement
         {
-			element = document.createElement('th') as WrappedHTMLElement;
-            element.classList.add("mdl-data-table__cell--non-numeric");
-
-            positioner = element;
-            element.flexjs_wrapper = this;
+			typeNames = "mdl-data-table__cell--non-numeric";
 
-            return element;
+            return super.createElement();;
         }
 		
         protected var _ascending:Boolean;