MDL TextInput
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/1a11e870 Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/1a11e870 Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/1a11e870 Branch: refs/heads/feature/mdl Commit: 1a11e8701dab726bb430a7de696f0b048c79042a Parents: 830bfe4 Author: Carlos Rovira <carlosrov...@apache.org> Authored: Mon Oct 17 13:40:29 2016 +0200 Committer: Carlos Rovira <carlosrov...@apache.org> Committed: Wed Oct 26 10:59:07 2016 +0200 ---------------------------------------------------------------------- .../main/flex/org/apache/flex/mdl/TextInput.as | 99 ++++++++++++++++++++ .../src/main/resources/mdl-manifest.xml | 2 +- 2 files changed, 100 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1a11e870/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/TextInput.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/TextInput.as b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/TextInput.as new file mode 100644 index 0000000..dace484 --- /dev/null +++ b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/TextInput.as @@ -0,0 +1,99 @@ +// +// 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.mdl +{ + import org.apache.flex.html.TextInput; + + COMPILE::JS + { + import goog.events; + import org.apache.flex.core.WrappedHTMLElement; + } + + /** + * The TextInput class provides a Material Design Library UI-like appearance for + * a TextInput. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class TextInput extends org.apache.flex.html.TextInput + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function TextInput() + { + super(); + } + + /** + * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement + */ + COMPILE::JS + override protected function createElement():WrappedHTMLElement + { + var div:HTMLDivElement; + var input:HTMLInputElement; + var label:HTMLLabelElement; + var textNode:Text; + //element = document.createElement('input') as WrappedHTMLElement; + + div = document.createElement('div') as HTMLDivElement; + div.className = "mdl-textfield mdl-js-textfield"; + + input = document.createElement('input') as HTMLInputElement; + input.setAttribute('type', 'text'); + input.className = 'mdl-textfield__input'; + + label = document.createElement('label') as HTMLLabelElement; + label.className = "mdl-textfield__label"; + + textNode = document.createTextNode('Text...') as Text; + label.appendChild(textNode); + //element.className = 'TextInput'; + //typeNames = 'TextInput'; + + div.appendChild(input); + div.appendChild(label); + + element = div as WrappedHTMLElement; + + //attach input handler to dispatch flexjs change event when user write in textinput + //goog.events.listen(element, 'change', killChangeHandler); + goog.events.listen(input, 'input', textChangeHandler); + + positioner = element; + positioner.style.position = 'relative'; + (div as WrappedHTMLElement).flexjs_wrapper = this; + (input as WrappedHTMLElement).flexjs_wrapper = this; + (label as WrappedHTMLElement).flexjs_wrapper = this; + element.flexjs_wrapper = this; + + return element; + } + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1a11e870/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml ---------------------------------------------------------------------- diff --git a/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml b/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml index 897aab5..eb65435 100644 --- a/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml +++ b/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml @@ -22,6 +22,6 @@ <componentPackage> <component id="Button" class="org.apache.flex.mdl.Button"/> - <component id="TextInput" class="org.apache.flex.html.TextInput" lookupOnly="true" /> + <component id="TextInput" class="org.apache.flex.mdl.TextInput"/> </componentPackage>