flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ha...@apache.org
Subject git commit: [flex-asjs] [refs/heads/develop] - Added CSSCheckBox
Date Mon, 27 Mar 2017 13:42:39 GMT
Repository: flex-asjs
Updated Branches:
  refs/heads/develop 6714cff23 -> ce25c4722


Added CSSCheckBox


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

Branch: refs/heads/develop
Commit: ce25c4722f67a7f9bbba316490c8b6c9a3d6c234
Parents: 6714cff
Author: Harbs <harbs@in-tools.com>
Authored: Mon Mar 27 16:42:34 2017 +0300
Committer: Harbs <harbs@in-tools.com>
Committed: Mon Mar 27 16:42:34 2017 +0300

----------------------------------------------------------------------
 .../flex/org/apache/flex/html/CSSCheckBox.as    | 219 +++++++++++++++++++
 .../HTML/src/main/resources/basic-manifest.xml  |   1 +
 .../HTML/src/main/resources/defaults.css        |   6 +
 3 files changed, 226 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ce25c472/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/CSSCheckBox.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/CSSCheckBox.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/CSSCheckBox.as
new file mode 100644
index 0000000..40c0b7a
--- /dev/null
+++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/CSSCheckBox.as
@@ -0,0 +1,219 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.html
+{
+    COMPILE::SWF
+    {
+        import flash.events.MouseEvent;
+    }
+
+	import org.apache.flex.core.IStrand;
+	import org.apache.flex.core.IToggleButtonModel;
+	import org.apache.flex.core.IUIBase;
+    COMPILE::SWF
+    {
+        import org.apache.flex.core.UIButtonBase;
+    }
+    COMPILE::JS
+    {
+        import org.apache.flex.core.UIBase;
+        import org.apache.flex.core.WrappedHTMLElement;
+		import org.apache.flex.html.supportClasses.CheckBoxIcon;
+    }
+	import org.apache.flex.events.Event;
+	import org.apache.flex.events.MouseEvent;
+
+    //--------------------------------------
+    //  Events
+    //--------------------------------------
+
+    /**
+     *  Dispatched when the user checks or un-checks the CSSCheckBox.
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion FlexJS 0.0
+     */
+	[Event(name="change", type="org.apache.flex.events.Event")]
+
+    /**
+     *  The CSSCheckBox class implements the common user interface
+     *  control.  The CSSCheckBox includes its text label and is styleable using CSS.
+     * To style the checkbox control, a `checkClassName` should be specified which corresponds
to a CSS class name.
+     *
+     *  @toplevel
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion FlexJS 0.0
+     */
+    COMPILE::SWF
+	public class CSSCheckBox extends UIButtonBase implements IStrand
+	{
+        /**
+         *  Constructor.
+         *
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+		public function CSSCheckBox()
+		{
+			super();
+
+			addEventListener(org.apache.flex.events.MouseEvent.CLICK, internalMouseHandler);
+		}
+
+        /**
+         *  The text label for the CSSCheckBox.
+         *
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+		public function get text():String
+		{
+			return IToggleButtonModel(model).text;
+		}
+
+        /**
+         *  @private
+         */
+		public function set text(value:String):void
+		{
+			IToggleButtonModel(model).text = value;
+		}
+
+        [Bindable("change")]
+        /**
+         *  <code>true</code> if the check mark is displayed.
+         *
+         *  @default false
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+		public function get selected():Boolean
+		{
+			return IToggleButtonModel(model).selected;
+		}
+
+        /**
+         *  @private
+         */
+		public function set selected(value:Boolean):void
+		{
+			IToggleButtonModel(model).selected = value;
+		}
+
+		private function internalMouseHandler(event:org.apache.flex.events.MouseEvent) : void
+		{
+			selected = !selected;
+			dispatchEvent(new Event("change"));
+		}
+        private var _checkClassName:String;
+        public function get checkClassName():String
+        {
+            return _checkClassName;
+        }
+        public function set checkClassName(value:String):void
+        {
+            _checkClassName = value;
+        }
+        
+	}
+
+    COMPILE::JS
+    public class CSSCheckBox extends UIBase
+    {
+
+		private var _label:WrappedHTMLElement;
+		private var _icon:CheckBoxIcon;
+		private var _styleDiv:WrappedHTMLElement;
+        private var _textNode:WrappedHTMLElement
+
+		private static var _checkNumber:Number = 0;
+
+        /**
+         * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement
+         */
+        override protected function createElement():WrappedHTMLElement
+        {
+            element = document.createElement('label') as WrappedHTMLElement;
+			_label = element;
+			_icon = new CheckBoxIcon();
+            element.appendChild(_icon.element);
+            // Add a span to allow checkbox styling
+            _styleDiv = document.createElement('div') as WrappedHTMLElement;
+            if(_checkClassName)
+                _styleDiv.setAttribute("class",_checkClassName)
+            element.appendChild(_styleDiv);
+            _textNode = document.createTextNode('') as WrappedHTMLElement;
+            element.appendChild(_textNode);
+
+            positioner = element;
+            //positioner.style.position = 'relative';
+            element.flexjs_wrapper = this;
+			_icon.element.flexjs_wrapper = this;
+            _styleDiv.flexjs_wrapper = this;
+
+            className = 'CSSCheckBox';
+            typeNames = 'CSSCheckBox';
+
+            return element;
+        }
+
+        private var _checkClassName:String;
+        public function get checkClassName():String
+        {
+            return _checkClassName;
+        }
+        public function set checkClassName(value:String):void
+        {
+            _checkClassName = value;
+            if(_styleDiv)
+                _styleDiv.setAttribute("class",_checkClassName);
+        }
+
+        public function get text():String
+        {
+            return _textNode.nodeValue;
+        }
+
+        public function set text(value:String):void
+        {
+            _textNode.nodeValue = value;
+        }
+
+        public function get selected():Boolean
+        {
+            return (_icon.element as HTMLInputElement).checked;
+        }
+
+        public function set selected(value:Boolean):void
+        {
+           (_icon.element as HTMLInputElement).checked = value;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ce25c472/frameworks/projects/HTML/src/main/resources/basic-manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/resources/basic-manifest.xml b/frameworks/projects/HTML/src/main/resources/basic-manifest.xml
index 8f132a6..53e4a63 100644
--- a/frameworks/projects/HTML/src/main/resources/basic-manifest.xml
+++ b/frameworks/projects/HTML/src/main/resources/basic-manifest.xml
@@ -42,6 +42,7 @@
     <component id="List" class="org.apache.flex.html.List"/>
     <component id="SimpleList" class="org.apache.flex.html.SimpleList"/>
     <component id="CheckBox" class="org.apache.flex.html.CheckBox"/>
+    <component id="CSSCheckBox" class="org.apache.flex.html.CSSCheckBox"/>
     <component id="RadioButton" class="org.apache.flex.html.RadioButton"/>
     <component id="ComboBox" class="org.apache.flex.html.ComboBox"/>
     <component id="ComboBoxList" class="org.apache.flex.html.supportClasses.ComboBoxList"/>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/ce25c472/frameworks/projects/HTML/src/main/resources/defaults.css
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/resources/defaults.css b/frameworks/projects/HTML/src/main/resources/defaults.css
index e7f211d..8158d02 100644
--- a/frameworks/projects/HTML/src/main/resources/defaults.css
+++ b/frameworks/projects/HTML/src/main/resources/defaults.css
@@ -598,6 +598,12 @@ global
 		IBeadView:  ClassReference("org.apache.flex.html.beads.CheckBoxView");			
 	}
 	
+	CSSCheckBox
+	{
+		IBeadModel: ClassReference("org.apache.flex.html.beads.models.ToggleButtonModel");
+		IBeadView:  ClassReference("org.apache.flex.html.beads.CheckBoxView");			
+	}
+	
 	CloseButton
 	{
 		IBeadView: ClassReference("org.apache.flex.html.beads.CloseButtonView");


Mime
View raw message