royale-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From carlosrov...@apache.org
Subject [royale-asjs] branch develop updated: fix ClassSelectorList toggle method for IE11 since doesn't allow second param and fix contains in StyledUIBase
Date Wed, 04 Jul 2018 10:11:00 GMT
This is an automated email from the ASF dual-hosted git repository.

carlosrovira pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git


The following commit(s) were added to refs/heads/develop by this push:
     new 404ba21  fix ClassSelectorList toggle method for IE11 since doesn't allow second
param and fix contains in StyledUIBase
404ba21 is described below

commit 404ba21d9301cbb88c8d88069f029ccd25f56ba3
Author: Carlos Rovira <carlosrovira@apache.org>
AuthorDate: Wed Jul 4 12:10:56 2018 +0200

    fix ClassSelectorList toggle method for IE11 since doesn't allow second param
    and fix contains in StyledUIBase
---
 .../royale/org/apache/royale/core/StyledUIBase.as  |  4 +-
 .../org/apache/royale/utils/ClassSelectorList.as   |  8 ++-
 .../apache/royale/jewel/ApplicationMainContent.as  | 16 ++---
 .../main/royale/org/apache/royale/jewel/Button.as  | 68 +++++++++++++++++++++-
 .../royale/org/apache/royale/jewel/Container.as    |  8 +--
 .../main/royale/org/apache/royale/jewel/Group.as   |  8 +--
 .../org/apache/royale/jewel/SectionContent.as      |  5 +-
 .../royale/org/apache/royale/jewel/ToggleButton.as | 17 +++---
 .../royale/jewel/itemRenderers/ListItemRenderer.as |  5 +-
 .../royale/jewel/supportClasses/TextInputBase.as   |  9 +--
 10 files changed, 105 insertions(+), 43 deletions(-)

diff --git a/frameworks/projects/Core/src/main/royale/org/apache/royale/core/StyledUIBase.as
b/frameworks/projects/Core/src/main/royale/org/apache/royale/core/StyledUIBase.as
index 3f90a94..0a67d2b 100644
--- a/frameworks/projects/Core/src/main/royale/org/apache/royale/core/StyledUIBase.as
+++ b/frameworks/projects/Core/src/main/royale/org/apache/royale/core/StyledUIBase.as
@@ -47,8 +47,8 @@ package org.apache.royale.core
          */
 		public function StyledUIBase()
 		{
-            super();
             classSelectorList = new ClassSelectorList(this);
+            super();
 		}
 
         COMPILE::JS
@@ -147,7 +147,7 @@ package org.apache.royale.core
         {
             COMPILE::JS
             {
-            return classSelectorList.contains(name);
+            return classSelectorList.contains(name);    
             }
             COMPILE::SWF
             {//not implemented
diff --git a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/ClassSelectorList.as
b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/ClassSelectorList.as
index edbe151..4a06468 100644
--- a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/ClassSelectorList.as
+++ b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/ClassSelectorList.as
@@ -104,7 +104,13 @@ package org.apache.royale.utils
         {
             COMPILE::JS
             {
-            component.positioner.classList.toggle(name, value);
+            //IE11 does not support second value so instead of
+            //component.positioner.classList.toggle(name, value);
+            if(value)
+                component.positioner.classList.add(name);
+            else
+                component.positioner.classList.remove(name);
+
             if (!component.parent && value)
                 startIndex++;
             }
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/ApplicationMainContent.as
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/ApplicationMainContent.as
index e47e169..0e267c1 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/ApplicationMainContent.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/ApplicationMainContent.as
@@ -94,12 +94,12 @@ package org.apache.royale.jewel
 		 */
         public function showContent(id:String):void
         {
-			for (var i:int = 0; i < numElements; i++)
+			try
 			{
-				var content:IActivable = getElementAt(i) as IActivable;
-
-				try
+				for (var i:int = 0; i < numElements; i++)
 				{
+					var content:IActivable = getElementAt(i) as IActivable;
+					
 					if(content.id == id)
 					{
 						content.isActive = true;
@@ -109,10 +109,10 @@ package org.apache.royale.jewel
 						content.isActive = false;
 					}
 				}
-				catch (error:Error)
-				{
-					throw new Error ("One or more content in ApplicationMainContent is not implementing
IActivable interface.");	
-				}
+			}
+			catch (error:Error)
+			{
+				throw new Error ("One or more content in ApplicationMainContent is not implementing IActivable
interface.");	
 			}
         }
 
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Button.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Button.as
index 1630850..72287e6 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Button.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Button.as
@@ -29,6 +29,7 @@ package org.apache.royale.jewel
     COMPILE::SWF
     {
     	import org.apache.royale.core.UIButtonBase;
+        import org.apache.royale.utils.IClassSelectorListSupport;
     }
 
     COMPILE::JS
@@ -171,7 +172,7 @@ package org.apache.royale.jewel
      *  @productversion Royale 0.9.3
      */
     COMPILE::SWF
-	public class Button extends UIButtonBase implements IStrand, IEventDispatcher, IUIBase,
IIconSupport
+	public class Button extends UIButtonBase implements IStrand, IEventDispatcher, IUIBase,
IIconSupport, IClassSelectorListSupport
 	{
         public static const PRIMARY:String = "primary";
         public static const SECONDARY:String = "secondary";
@@ -289,6 +290,71 @@ package org.apache.royale.jewel
             classSelectorList.toggle("icon", (_icon != null));
             // todo set up icon on swf
         }
+
+        /**
+         * Add a class selector to the list.
+         * 
+         * @param name Name of selector to add.
+         * 
+         * @langversion 3.0
+         * @playerversion Flash 10.2
+         * @playerversion AIR 2.6
+         * @productversion Royale 0.9.3
+         */
+        public function addClass(name:String):void
+        {
+            // To implement.need to implement this interface or extensions will not compile
+        }
+
+        /**
+         * Removes a class selector from the list.
+         * 
+         * @param name Name of selector to remove.
+         *
+         * @royaleignorecoercion HTMLElement
+         * @royaleignorecoercion DOMTokenList
+         * 
+         * @langversion 3.0
+         * @playerversion Flash 10.2
+         * @playerversion AIR 2.6
+         * @productversion Royale 0.9.3
+         */
+        public function removeClass(name:String):void
+        {
+            // To implement.need to implement this interface or extensions will not compile
+        }
+
+        /**
+         * Add or remove a class selector to/from the list.
+         * 
+         * @param name Name of selector to add or remove.
+         * @param value True to add, False to remove.
+         * 
+         * @langversion 3.0
+         * @playerversion Flash 10.2
+         * @playerversion AIR 2.6
+         * @productversion Royale 0.9.3
+         */
+        public function toggleClass(name:String, value:Boolean):void
+        {
+            // To implement.need to implement this interface or extensions will not compile
+        }
+
+        /**
+		 *  Search for the name in the element class list 
+		 *
+         *  @param name Name of selector to find.
+         *  @return return true if the name is found or false otherwise.
+         * 
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.3
+		 */
+		public function containsClass(name:String):Boolean
+        {
+            return false;
+        }
     }
 
     /**
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Container.as
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Container.as
index 3d2f347..f9ddfb7 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Container.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Container.as
@@ -165,14 +165,14 @@ package org.apache.royale.jewel
 		 */
 		public function containsClass(name:String):Boolean
         {
-            COMPILE::SWF
-            {//not implemented
-            return false;
-            }
             COMPILE::JS
             {
             return classSelectorList.contains(name);
             }
+            COMPILE::SWF
+            {//not implemented
+            return false;
+            }
         }
 
 		private var _mxmlDescriptor:Array;
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Group.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Group.as
index fa51adf..278ea2c 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Group.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Group.as
@@ -131,14 +131,14 @@ package org.apache.royale.jewel
 		 */
 		public function containsClass(name:String):Boolean
         {
-            COMPILE::SWF
-            {//not implemented
-            return false;
-            }
             COMPILE::JS
             {
             return classSelectorList.contains(name);
             }
+            COMPILE::SWF
+            {//not implemented
+            return false;
+            }
         }
 	}
 }
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/SectionContent.as
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/SectionContent.as
index 101a3b7..59b5780 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/SectionContent.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/SectionContent.as
@@ -84,10 +84,7 @@ package org.apache.royale.jewel
             {
                 _isActive = value;
 
-                COMPILE::JS
-                {
-                    toggleClass("is-active", _isActive);
-                }
+                toggleClass("is-active", _isActive);
             }
 		}
 	}
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/ToggleButton.as
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/ToggleButton.as
index 0bbf46e..1aef80c 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/ToggleButton.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/ToggleButton.as
@@ -154,8 +154,10 @@ package org.apache.royale.jewel
         {
             selected = !selected;
         }
+
         COMPILE::SWF
         private var savedClassName:String;
+
         private function internalSelected():void
         {
             COMPILE::SWF
@@ -172,15 +174,12 @@ package org.apache.royale.jewel
                     className = (name ? " " + name : "");
                 }
             }
-            COMPILE::JS
-            {
-                var isToggleTextButtonSelected:Boolean = element.classList.contains("selected");
-                //sync the class with the state
-                if(isToggleTextButtonSelected != _selected)
-                    toggleClass("selected", _selected);
-                                
-            }
-
+            
+            var isToggleTextButtonSelected:Boolean = containsClass("selected");
+            //sync the class with the state
+            if(isToggleTextButtonSelected != _selected)
+                toggleClass("selected", _selected);
+            
             if(icon && icon is ISelectable)
             {
                var selectableIcon:ISelectable = icon as ISelectable;
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/itemRenderers/ListItemRenderer.as
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/itemRenderers/ListItemRenderer.as
index 9777945..7bfca40 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/itemRenderers/ListItemRenderer.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/itemRenderers/ListItemRenderer.as
@@ -137,10 +137,7 @@ package org.apache.royale.jewel.itemRenderers
 			//else
 			// 	useColor = backgroundColor;
 
-            COMPILE::JS
-            {
-                toggleClass("selected", selected);
-            }
+            toggleClass("selected", selected);
 		}
 	}
 }
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/supportClasses/TextInputBase.as
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/supportClasses/TextInputBase.as
index d50a1e3..9951828 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/supportClasses/TextInputBase.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/supportClasses/TextInputBase.as
@@ -248,12 +248,9 @@ package org.apache.royale.jewel.supportClasses
         {
             _isInvalid = value;
 
-            COMPILE::JS
-            {
-                toggleClass("is-invalid", _isInvalid);
-                //positioner.classList.toggle("is-invalid", _isInvalid);
-                //typeNames = positioner.className;
-            }
+            toggleClass("is-invalid", _isInvalid);
+            //positioner.classList.toggle("is-invalid", _isInvalid);
+            //typeNames = positioner.className;
         }
 	}
 }


Mime
View raw message