You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@royale.apache.org by GitBox <gi...@apache.org> on 2018/08/23 11:48:18 UTC

[GitHub] carlosrovira closed pull request #274: itemsExpand still not work, fix again

carlosrovira closed pull request #274: itemsExpand still not work, fix again
URL: https://github.com/apache/royale-asjs/pull/274
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/StyledLayoutBase.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/StyledLayoutBase.as
index fae56634f..2cff94e0c 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/StyledLayoutBase.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/StyledLayoutBase.as
@@ -22,6 +22,8 @@ package org.apache.royale.jewel.beads.layouts
 	import org.apache.royale.core.IBeadLayout;
 	import org.apache.royale.core.IStrand;
 	import org.apache.royale.core.UIBase;
+	import org.apache.royale.core.IUIBase;
+	import org.apache.royale.core.ValuesManager;
 
 
     /**
@@ -77,6 +79,58 @@ package org.apache.royale.jewel.beads.layouts
 			{
 				hostComponent = host as UIBase;
 				hostClassList = hostComponent.positioner.classList;
+
+				initStyleToLayout(hostComponent, "itemsExpand");
+				setHostClassList("itemsExpand", _itemsExpand ? "itemsExpand":"");
+
+				initStyleToLayout(hostComponent, "itemsHorizontalAlign");
+				setHostClassList(_itemsHorizontalAlign, _itemsHorizontalAlign);
+
+				initStyleToLayout(hostComponent, "itemsVerticalAlign");
+				setHostClassList(_itemsVerticalAlign, _itemsVerticalAlign);
+			}
+		}
+
+		/**
+		 *  Get the component layout style and init to if exists
+		 * 
+		 *  @param component the IUIBase component that host this layout
+		 *  @param cssProperty the style property in css set for the component to retrieve
+		 * 
+ 		 *  @langversion 3.0
+ 		 *  @playerversion Flash 10.2
+ 		 *  @playerversion AIR 2.6
+ 		 *  @productversion Royale 0.9.3
+ 		 */
+		protected function initStyleToLayout(component:IUIBase, cssProperty:String):void
+		{	
+			///-----------------------------------------
+			/// This function works as the same as 
+			/// org.apache.royale.core.layout.ILayoutStyleProperties#applyStyleToLayout(component:IUIBase, cssProperty:String):void
+			/// Because StyledLayoutBase does not implement ILayoutStyleProperties
+			/// To avoid conflict with subclass like HorizontalLayout.applyStyleToLayout
+			/// Names this function - initStyleToLayout
+			///-----------------------------------------
+			var cssValue:* = ValuesManager.valuesImpl.getValue(component, cssProperty);
+			if (cssValue !== undefined)
+			{
+				switch(cssProperty)
+				{
+					case "itemsExpand":
+						if(!itemsExpandInitialized)
+							itemsExpand = "true" == cssValue;
+						break;
+					case "itemsHorizontalAlign":
+						if (!itemsHorizontalAlign)
+							itemsHorizontalAlign = String(cssValue);
+						break;
+					case "itemsVerticalAlign":
+						if (!itemsVerticalAlign)
+							itemsVerticalAlign = String(cssValue);
+						break;
+					default:
+						break;
+				}	
 			}
 		}
 
@@ -106,16 +160,8 @@ package org.apache.royale.jewel.beads.layouts
             {
                 COMPILE::JS
                 {
-					if(hostComponent)
-					{
-						if (hostClassList.contains(_itemsHorizontalAlign))
-							hostClassList.remove(_itemsHorizontalAlign);
-				}
-						_itemsHorizontalAlign = value;
-				COMPILE::JS
-                {
-						hostClassList.add(_itemsHorizontalAlign);
-					}
+					setHostClassList(_itemsHorizontalAlign, value);
+					_itemsHorizontalAlign = value;
 				}
 			}
         }
@@ -145,20 +191,13 @@ package org.apache.royale.jewel.beads.layouts
             {
                 COMPILE::JS
                 {
-					if(hostComponent)
-					{
-						if (hostClassList.contains(_itemsVerticalAlign))
-							hostClassList.remove(_itemsVerticalAlign);
-				}
-						_itemsVerticalAlign = value;
-				COMPILE::JS
-                {
-						hostClassList.add(_itemsVerticalAlign);
-					}
+					setHostClassList(_itemsVerticalAlign, value);
+					_itemsVerticalAlign = value;
 				}
 			}
         }
 
+		private var itemsExpandInitialized:Boolean;
 		private var _itemsExpand:Boolean = false;
         /**
 		 *  A boolean flag to activate "itemsExpand" effect selector.
@@ -178,18 +217,26 @@ package org.apache.royale.jewel.beads.layouts
         {
             if (_itemsExpand != value)
             {
-                _itemsExpand = value;
+                
 				COMPILE::JS
                 {
-				if(_itemsExpand)
-				{
-					hostClassList.add("itemsExpand");
-				} else
-				{
-					hostClassList.remove("itemsExpand");
-				}
+				    setHostClassList("itemsExpand", value ? "itemsExpand" : "");
+					_itemsExpand = value;
+					itemsExpandInitialized = true;
 				}
             }
         }
+
+        COMPILE::JS
+        protected function setHostClassList(oldValue:String, newValue:String):void {
+            if (!hostComponent) return;
+			
+            if (oldValue && hostClassList.contains(oldValue)) {
+				if (oldValue == newValue) return;
+                hostClassList.remove(oldValue);
+			}
+        
+            if (newValue) hostClassList.add(newValue);
+        }
 	}
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services