You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2015/11/26 19:14:46 UTC
[05/12] git commit: [flex-asjs] [refs/heads/core_js_to_as] - get more
of ToggleTextButton to work
get more of ToggleTextButton to work
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/8177f913
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/8177f913
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/8177f913
Branch: refs/heads/core_js_to_as
Commit: 8177f913ace55150f02e9dfe808989bae39dfe2e
Parents: c456a12
Author: Alex Harui <ah...@apache.org>
Authored: Tue Nov 24 15:46:05 2015 -0800
Committer: Alex Harui <ah...@apache.org>
Committed: Tue Nov 24 15:46:05 2015 -0800
----------------------------------------------------------------------
.../org/apache/flex/html/ToggleTextButton.as | 69 +++++++++++++++++++-
1 file changed, 67 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/8177f913/frameworks/projects/HTML/as/src/org/apache/flex/html/ToggleTextButton.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/ToggleTextButton.as b/frameworks/projects/HTML/as/src/org/apache/flex/html/ToggleTextButton.as
index c9731d1..ea9b0f9 100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/ToggleTextButton.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/ToggleTextButton.as
@@ -23,6 +23,11 @@ package org.apache.flex.html
import org.apache.flex.core.IUIBase;
import org.apache.flex.core.ValuesManager;
import org.apache.flex.events.IEventDispatcher;
+
+ COMPILE::JS
+ {
+ import org.apache.flex.core.WrappedHTMLElement;
+ }
//--------------------------------------
// Events
@@ -60,8 +65,18 @@ package org.apache.flex.html
public function ToggleTextButton()
{
super();
+ COMPILE::JS
+ {
+ this.typeNames = 'toggleTextButton';
+ }
}
+ COMPILE::JS
+ private var _selected:Boolean;
+
+ COMPILE::JS
+ private var SELECTED:String = "selected";
+
/**
* <code>true</code> if the Button is selected.
*
@@ -72,7 +87,14 @@ package org.apache.flex.html
*/
public function get selected():Boolean
{
- return IToggleButtonModel(model).selected;
+ COMPILE::AS3
+ {
+ return IToggleButtonModel(model).selected;
+ }
+ COMPILE::JS
+ {
+ return _selected;
+ }
}
/**
@@ -80,7 +102,38 @@ package org.apache.flex.html
*/
public function set selected(value:Boolean):void
{
- IToggleButtonModel(model).selected = value;
+ COMPILE::AS3
+ {
+ IToggleButtonModel(model).selected = value;
+ }
+ COMPILE::JS
+ {
+ if (_selected != value)
+ {
+ _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;
+ }
+ }
+ }
+ }
}
/**
@@ -100,6 +153,18 @@ package org.apache.flex.html
return "toggleTextButton" + (name ? " " + name : "");
}
+ COMPILE::JS
+ override protected function createElement():WrappedHTMLElement
+ {
+ super.createElement();
+ element.addEventListener("click", clickHandler, false);
+ return element;
+ }
+ COMPILE::JS
+ private function clickHandler(event:Event):void
+ {
+ selected = !selected;
+ }
}
}