Add HTMLText component that displays HTML content
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/cac07e4c Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/cac07e4c Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/cac07e4c Branch: refs/heads/develop Commit: cac07e4c566681684e59c74d8e6ed926e82f2544 Parents: d10a392 Author: OmPrakash Muppirala <bigosma...@gmail.com> Authored: Tue Jan 3 02:17:26 2017 -0800 Committer: OmPrakash Muppirala <bigosma...@gmail.com> Committed: Tue Jan 3 02:17:26 2017 -0800 ---------------------------------------------------------------------- .../main/flex/org/apache/flex/html/HTMLText.as | 119 +++++++++++++++++++ .../HTML/src/main/resources/basic-manifest.xml | 1 + 2 files changed, 120 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/cac07e4c/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/HTMLText.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/HTMLText.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/HTMLText.as new file mode 100644 index 0000000..ea60de8 --- /dev/null +++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/HTMLText.as @@ -0,0 +1,119 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 +{ + import org.apache.flex.core.ITextModel; + import org.apache.flex.core.UIBase; + import org.apache.flex.core.ValuesManager; + import org.apache.flex.events.Event; + import org.apache.flex.events.IEventDispatcher; + COMPILE::JS + { + import org.apache.flex.core.WrappedHTMLElement; + } + + /** + * The HTMLText class implements the basic control for adding + * HTML formatted text. + * + * @toplevel + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class HTMLText extends UIBase + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function HTMLText() + { + super(); + } + + [Bindable("htmlChange")] + /** + * The html-formatted text to display in the HTMLText. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get html():String + { + COMPILE::SWF + { + return ITextModel(model).html; + } + COMPILE::JS + { + return element.innerHTML; + } + } + + /** + * @private + */ + public function set html(value:String):void + { + COMPILE::SWF + { + ITextModel(model).html = value; + } + COMPILE::JS + { + this.element.innerHTML = value; + this.dispatchEvent('textChange'); + } + } + + /** + * @private + */ + COMPILE::SWF + override public function addedToParent():void + { + super.addedToParent(); + model.addEventListener("htmlChange", repeaterListener); + } + + /** + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + */ + COMPILE::JS + override protected function createElement():WrappedHTMLElement + { + element = document.createElement('span') as WrappedHTMLElement; + positioner = element; + element.flexjs_wrapper = this; + + className = "HTMLText"; + typeNames = "HTMLText"; + return element; + } + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/cac07e4c/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 c283cb1..116f086 100644 --- a/frameworks/projects/HTML/src/main/resources/basic-manifest.xml +++ b/frameworks/projects/HTML/src/main/resources/basic-manifest.xml @@ -31,6 +31,7 @@ <component id="Image" class="org.apache.flex.html.Image"/> <component id="BinaryImage" class="org.apache.flex.html.BinaryImage"/> <component id="Label" class="org.apache.flex.html.Label"/> + <component id="HTMLText" class="org.apache.flex.html.HTMLText"/> <component id="MultilineLabel" class="org.apache.flex.html.MultilineLabel"/> <component id="ImageAndTextButton" class="org.apache.flex.html.ImageAndTextButton"/> <component id="TextButton" class="org.apache.flex.html.TextButton"/>