You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by pi...@apache.org on 2018/03/18 18:43:11 UTC

[royale-asjs] branch develop updated: MDL Menu: Fix issue where position of Menu wasn't setup at all

This is an automated email from the ASF dual-hosted git repository.

piotrz 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 c520bd8  MDL Menu: Fix issue where position of Menu wasn't setup at all
c520bd8 is described below

commit c520bd8298b987e2586d83b2c872cc37df6c905a
Author: Piotr Zarzycki <pi...@gmail.com>
AuthorDate: Sun Mar 18 19:43:05 2018 +0100

    MDL Menu: Fix issue where position of Menu wasn't setup at all
---
 .../src/main/royale/org/apache/royale/mdl/Menu.as  | 56 ++++++++++++----------
 1 file changed, 30 insertions(+), 26 deletions(-)

diff --git a/frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/Menu.as b/frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/Menu.as
index 5652c04..4c9bbd1 100644
--- a/frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/Menu.as
+++ b/frameworks/projects/MaterialDesignLite/src/main/royale/org/apache/royale/mdl/Menu.as
@@ -60,12 +60,16 @@ package org.apache.royale.mdl
 		{
 			super();
 
+            currentMenuPosition = "mdl-menu--bottom-left";
+
             COMPILE::JS
             {
                 _classList = new CSSClassList();
+                _classList.add(currentMenuPosition);
             }
 
             typeNames = "mdl-menu mdl-js-menu";
+
 			addEventListener("beadsAdded", addUpgradeBead);
         }
 
@@ -85,7 +89,7 @@ package org.apache.royale.mdl
          *  @playerversion AIR 2.6
          *  @productversion Royale 0.8
          */
-        private var currentMenuPosition:String = "";
+        private var currentMenuPosition:String;
 
 
         /**
@@ -98,6 +102,7 @@ package org.apache.royale.mdl
         }
 
         private var _bottom:Boolean = true;
+
 		/**
 		 *  Position the menu relative to the associated button.
          *  Used in conjunction with "left"
@@ -114,21 +119,21 @@ package org.apache.royale.mdl
 		}
 		public function set bottom(value:Boolean):void
 		{
-			_bottom = value;
+            if (_bottom != value)
+            {
+                _bottom = value;
+
+                COMPILE::JS
+                {
+                    _classList.remove(currentMenuPosition);
 
-            var newMenuPosition:String;
+                    currentMenuPosition = "mdl-menu--" + (_bottom ? "bottom" : "top") + "-" + (_left ? "left" : "right");
 
-            if(currentMenuPosition == "")
-            {
-                currentMenuPosition = " mdl-menu--" + (_bottom ? "bottom" : "top") + "-" + (_left ? "left" : "right");
-                className += currentMenuPosition;
-            } else
-            {
-                newMenuPosition = " mdl-menu--" + (_bottom ? "bottom" : "top") + "-" + (_left ? "left" : "right");
-                className = className.replace( "/(?:^|\s)" + currentMenuPosition + "(?!\S)/g" , newMenuPosition);
-            }
+                    _classList.add(currentMenuPosition);
 
-            currentMenuPosition = newMenuPosition;
+                    setClassName(computeFinalClassNames());
+                }
+            }
 		}
 
         private var _left:Boolean = true;
@@ -149,22 +154,21 @@ package org.apache.royale.mdl
 
 		public function set left(value:Boolean):void
 		{
-			_left = value;
+            if (_left != value)
+            {
+                _left = value;
 
-            var newMenuPosition:String;
+                COMPILE::JS
+                {
+                    _classList.remove(currentMenuPosition);
 
-            if(currentMenuPosition == "")
-            {
-                currentMenuPosition = " mdl-menu--" + (_bottom ? "bottom" : "top") + "-" + (_left ? "left" : "right");
-                className += currentMenuPosition;
-            }
-			else
-            {
-                newMenuPosition = " mdl-menu--" + (_bottom ? "bottom" : "top") + "-" + (_left ? "left" : "right");
-                className = className.replace( "/(?:^|\s)" + currentMenuPosition + "(?!\S)/g" , newMenuPosition);
-            }
+                    currentMenuPosition = "mdl-menu--" + (_bottom ? "bottom" : "top") + "-" + (_left ? "left" : "right");
+
+                    _classList.add(currentMenuPosition);
 
-            currentMenuPosition = newMenuPosition;
+                    setClassName(computeFinalClassNames());
+                }
+            }
 		}
 
         private var _dataMdlFor:String;

-- 
To stop receiving notification emails like this one, please contact
piotrz@apache.org.