Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 59CBA200BC6 for ; Sun, 6 Nov 2016 02:30:21 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 589B5160B15; Sun, 6 Nov 2016 01:30:21 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 679C4160B09 for ; Sun, 6 Nov 2016 02:30:20 +0100 (CET) Received: (qmail 12926 invoked by uid 500); 6 Nov 2016 01:30:17 -0000 Mailing-List: contact commits-help@flex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flex.apache.org Delivered-To: mailing list commits@flex.apache.org Received: (qmail 12515 invoked by uid 99); 6 Nov 2016 01:30:17 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 Nov 2016 01:30:17 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id A200AF16A9; Sun, 6 Nov 2016 01:30:17 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: carlosrovira@apache.org To: commits@flex.apache.org Date: Sun, 06 Nov 2016 01:30:41 -0000 Message-Id: <692fd18728f44f9ab9abb279fec6aa42@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [25/41] git commit: [flex-asjs] [refs/heads/feature/mdl] - MDL TextPromptBead in place archived-at: Sun, 06 Nov 2016 01:30:21 -0000 MDL TextPromptBead in place Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/1eda23b0 Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/1eda23b0 Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/1eda23b0 Branch: refs/heads/feature/mdl Commit: 1eda23b0d47e3a90403ef2f7bd4c4699924b101a Parents: 6cb7a83 Author: Carlos Rovira Authored: Wed Oct 26 12:29:26 2016 +0200 Committer: Carlos Rovira Committed: Sun Nov 6 02:28:52 2016 +0100 ---------------------------------------------------------------------- .../flexjs/MDLExample/src/main/flex/App.mxml | 12 +- .../src/main/flex/MDLClasses.as | 2 +- .../main/flex/org/apache/flex/mdl/TextInput.as | 16 +- .../org/apache/flex/mdl/beads/TextPromptBead.as | 151 +++++++++++++++++++ .../src/main/resources/mdl-manifest.xml | 1 + 5 files changed, 178 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1eda23b0/examples/flexjs/MDLExample/src/main/flex/App.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/MDLExample/src/main/flex/App.mxml b/examples/flexjs/MDLExample/src/main/flex/App.mxml index 3924dba..9f1be78 100644 --- a/examples/flexjs/MDLExample/src/main/flex/App.mxml +++ b/examples/flexjs/MDLExample/src/main/flex/App.mxml @@ -55,8 +55,16 @@ limitations under the License. - - + + + + + + + + + + http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1eda23b0/frameworks/projects/MaterialDesignLite/src/main/flex/MDLClasses.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/MDLClasses.as b/frameworks/projects/MaterialDesignLite/src/main/flex/MDLClasses.as index 733728e..c0ea571 100644 --- a/frameworks/projects/MaterialDesignLite/src/main/flex/MDLClasses.as +++ b/frameworks/projects/MaterialDesignLite/src/main/flex/MDLClasses.as @@ -29,7 +29,7 @@ internal class MDLClasses { COMPILE::SWF { - //import org.apache.flex.flat.beads.CSSScrollBarView; CSSScrollBarView; + //import org.apache.flex.mdl.beads.TextPromptBead; TextPromptBead; } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1eda23b0/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 index 87f9c5a..c8244a4 100644 --- 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 @@ -17,6 +17,8 @@ //////////////////////////////////////////////////////////////////////////////// package org.apache.flex.mdl { + import org.apache.flex.core.ITextModel; + import org.apache.flex.events.Event; import org.apache.flex.html.TextInput; COMPILE::JS @@ -52,6 +54,16 @@ package org.apache.flex.mdl COMPILE::JS { private var _textNode:Text; + + public function get textNode():Text + { + return _textNode; + } + + public function set textNode(value:Text):void + { + _textNode = value; + } } /** @@ -78,7 +90,7 @@ package org.apache.flex.mdl var label:HTMLLabelElement = document.createElement('label') as HTMLLabelElement; label.className = "mdl-textfield__label"; - var textNode:Text = document.createTextNode('') as Text; + textNode = document.createTextNode('') as Text; label.appendChild(textNode); div.appendChild(input); @@ -110,5 +122,7 @@ package org.apache.flex.mdl positioner.className = positioner.className + " " + _mdlEffect; } } + + } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1eda23b0/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/TextPromptBead.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/TextPromptBead.as b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/TextPromptBead.as new file mode 100644 index 0000000..1c1e8fb --- /dev/null +++ b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/TextPromptBead.as @@ -0,0 +1,151 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.beads +{ + COMPILE::SWF + { + import flash.text.TextFieldType; + + import org.apache.flex.core.CSSTextField; + } + + import org.apache.flex.core.IBead; + import org.apache.flex.core.IStrand; + import org.apache.flex.core.UIBase; + import org.apache.flex.events.Event; + import org.apache.flex.events.IEventDispatcher; + + import org.apache.flex.mdl.TextInput; + + /** + * The TextPromptBead class is a specialty bead that can be used with + * any TextInput control. The bead places a string into the input field + * when there is no value associated with the text property. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class TextPromptBead implements IBead + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function TextPromptBead() + { + } + + private var _prompt:String; + + /** + * The string to use as the placeholder prompt. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get prompt():String + { + return _prompt; + } + public function set prompt(value:String):void + { + _prompt = value; + } + + private var _strand:IStrand; + + /** + * @copy org.apache.flex.core.IBead#strand + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + * @flexjsignorecoercion HTMLInputElement + * @flexjsignorecoercion org.apache.flex.core.UIBase; + */ + public function set strand(value:IStrand):void + { + _strand = value; + + COMPILE::SWF + { + // listen for changes in text to hide or show the prompt + var model:Object = UIBase(_strand).model; + if (!model.hasOwnProperty("text")) { + throw new Error("Model requires a text property when used with TextPromptBead"); + } + IEventDispatcher(model).addEventListener("textChange", handleTextChange); + + // create a TextField that displays the prompt - it shows + // and hides based on the model's content + promptField = new CSSTextField(); + promptField.selectable = false; + promptField.type = TextFieldType.DYNAMIC; + promptField.mouseEnabled = false; + promptField.multiline = false; + promptField.wordWrap = false; + promptField.textColor = 0xBBBBBB; + + // trigger the event handler to display if needed + handleTextChange(null); + } + COMPILE::JS + { + var mdlTi:TextInput = value as TextInput; + mdlTi.textNode.nodeValue = prompt; + //var e:HTMLInputElement = host.element as HTMLInputElement; + //e.placeholder = prompt; + } + } + + COMPILE::SWF + private var promptField:CSSTextField; + private var promptAdded:Boolean; + + /** + * @private + */ + COMPILE::SWF + private function handleTextChange( event:Event ):void + { + // see what the model currently has to determine if the prompt should be + // displayed or not. + var model:Object = UIBase(_strand).model; + + if (model.text != null && model.text.length > 0 ) { + if (promptAdded) UIBase(_strand).removeChild(promptField); + promptAdded = false; + } + else { + if (!promptAdded) UIBase(_strand).addChild(promptField); + promptField.text = prompt; + promptAdded = true; + } + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/1eda23b0/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 6dcb073..9f47fea 100644 --- a/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml +++ b/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml @@ -25,5 +25,6 @@ +