flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pio...@apache.org
Subject git commit: [flex-asjs] [refs/heads/develop] - FLEX-35243 - Fix problem with unselecting ToggleTextButton - Use classList.toggle api in order to switch between selected and unselected state - Make ToggleTextButton responsive in case of selecting it from
Date Sun, 15 Jan 2017 21:09:23 GMT
Repository: flex-asjs
Updated Branches:
  refs/heads/develop 8018076b5 -> f29c2a480


FLEX-35243 - Fix problem with unselecting ToggleTextButton
- Use classList.toggle api in order to switch between selected and unselected state
- Make ToggleTextButton responsive in case of selecting it from code


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

Branch: refs/heads/develop
Commit: f29c2a480c8b9080516cb180bb2c30650420d092
Parents: 8018076
Author: piotrz <piotrz@apache.org>
Authored: Sun Jan 15 22:09:17 2017 +0100
Committer: piotrz <piotrz@apache.org>
Committed: Sun Jan 15 22:09:17 2017 +0100

----------------------------------------------------------------------
 .../org/apache/flex/html/ToggleTextButton.as    | 55 +++++---------------
 1 file changed, 12 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f29c2a48/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/ToggleTextButton.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/ToggleTextButton.as
b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/ToggleTextButton.as
index 53f4a7b..b9d1050 100644
--- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/ToggleTextButton.as
+++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/ToggleTextButton.as
@@ -94,10 +94,7 @@ package org.apache.flex.html
 		}
 
         COMPILE::JS
-        private var _selected:Boolean;
-
-        COMPILE::JS
-        private var SELECTED:String = "selected";
+        private var _selected:Boolean = false;
 
         [Bindable("change")]
         /**
@@ -128,6 +125,8 @@ package org.apache.flex.html
             COMPILE::SWF
             {
                 IToggleButtonModel(model).selected = value;
+
+                dispatchEvent(new Event("change"));
             }
             COMPILE::JS
             {
@@ -135,52 +134,24 @@ package org.apache.flex.html
                 {
                     _selected = value;
 
-                    var className:String = this.className;
-                    var typeNames:String = this.typeNames;
-                    if (value) {
-                        if (typeNames.indexOf(SELECTED) == -1) {
-                            typeNames = typeNames + SELECTED;
-                            if (className)
-                                element.className = typeNames + ' ' + className;
-                            else
-                                element.className = typeNames;
-                        }
-                    }
-                    else {
-                        if (typeNames.indexOf(SELECTED) == typeNames.length - SELECTED.length)
{
-                            typeNames = typeNames.substring(0, typeNames.length - SELECTED.length);
-                            if (className)
-                                element.className = typeNames + ' ' + className;
-                            else
-                                element.className = typeNames;
-                        }
-                    }
+                    element.classList.toggle("toggleTextButton_Selected", _selected == true);
+                    element.classList.toggle("toggleTextButton", _selected == false);
+                    typeNames = element.className;
+
+                    dispatchEvent(new Event("change"));
                 }
             }
         }
 
-        /**
-         *  @private
-         *  add another class selector
-         */
-        override public function get className():String
-        {
-            // we don't have a model yet so just pass through otherwise you will loop
-            if (!parent)
-                return super.className;
-
-            var name:String = super.className;
-            if (selected)
-                return "toggleTextButton_Selected" + (name ? " " + name : "");
-            else
-                return "toggleTextButton" + (name ? " " + name : "");
-        }
-
         COMPILE::JS
         override protected function createElement():WrappedHTMLElement
         {
             super.createElement();
             element.addEventListener("click", clickHandler, false);
+            element.classList.toggle("toggleTextButton_Selected", _selected == true);
+            element.classList.toggle("toggleTextButton", _selected == false);
+            typeNames = element.className;
+
             return element;
         }
 
@@ -188,14 +159,12 @@ package org.apache.flex.html
         private function clickHandler(event:Event):void
         {
             selected = !selected;
-            dispatchEvent(new Event("change"));
         }
 
         COMPILE::SWF
         private function internalMouseHandler(event:MouseEvent) : void
         {
             selected = !selected;
-            dispatchEvent(new Event("change"));
         }
 	}
 }


Mime
View raw message