Effect Bead classes for various components
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/3cfdd6ec Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/3cfdd6ec Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/3cfdd6ec Branch: refs/heads/feature/mdl Commit: 3cfdd6ecde8d4eb5c013490a570d3b2c2039fd3a Parents: 6ed3b28 Author: Carlos Rovira <carlosrov...@apache.org> Authored: Wed Oct 26 20:57:57 2016 +0200 Committer: Carlos Rovira <carlosrov...@apache.org> Committed: Sat Nov 5 00:18:33 2016 +0100 ---------------------------------------------------------------------- .../flexjs/MDLExample/src/main/flex/App.mxml | 20 +- .../org/apache/flex/mdl/beads/ButtonEffect.as | 228 +++++++++++++++++ .../apache/flex/mdl/beads/ButtonEffectBead.as | 253 ------------------- .../org/apache/flex/mdl/beads/EffectBead.as | 98 ------- .../flex/org/apache/flex/mdl/beads/MDLEffect.as | 105 ++++++++ .../apache/flex/mdl/beads/TextInputEffect.as | 97 +++++++ .../org/apache/flex/mdl/beads/TextPrompt.as | 151 +++++++++++ .../org/apache/flex/mdl/beads/TextPromptBead.as | 151 ----------- .../src/main/resources/mdl-manifest.xml | 7 +- 9 files changed, 595 insertions(+), 515 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3cfdd6ec/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 e618658..0507f21 100644 --- a/examples/flexjs/MDLExample/src/main/flex/App.mxml +++ b/examples/flexjs/MDLExample/src/main/flex/App.mxml @@ -39,7 +39,7 @@ limitations under the License. <!-- Fab button --> <mdl:Button> <js:beads> - <mdl:ButtonEffectBead fab="true" colored="true"/> + <mdl:ButtonEffect fab="true" colored="true"/> </js:beads> <i class="material-icons">add</i> </mdl:Button> @@ -47,7 +47,7 @@ limitations under the License. <!-- Fab with Ripple --> <mdl:Button> <js:beads> - <mdl:ButtonEffectBead fab="true" ripple="true"/> + <mdl:ButtonEffect fab="true" ripple="true"/> </js:beads> <i class="material-icons md-48">face</i> </mdl:Button> @@ -55,20 +55,20 @@ limitations under the License. <!-- Raised button --> <mdl:Button text="BUTTON"> <js:beads> - <mdl:ButtonEffectBead raised="true" colored="true"/> + <mdl:ButtonEffect raised="true" colored="true"/> </js:beads> </mdl:Button> <!-- Raised button with ripple --> <mdl:Button text="BUTTON"> <js:beads> - <mdl:ButtonEffectBead raised="true" ripple="true" accent="true"/> + <mdl:ButtonEffect raised="true" ripple="true" accent="true"/> </js:beads> </mdl:Button> <!-- Raised disabled button ... it seems we don't have "disabled" implemented yet--> <mdl:Button text="BUTTON"> <js:beads> - <mdl:ButtonEffectBead raised="true"/> + <mdl:ButtonEffect raised="true"/> </js:beads> </mdl:Button> </js:HContainer> @@ -76,13 +76,13 @@ limitations under the License. <!-- Text Fields :: https://getmdl.io/components/index.html#textfields-section --> <mdl:TextInput id="mdlti" change="mdlchk.text = mdlti.text"> <js:beads> - <mdl:TextPromptBead prompt="Normal Text Field..."/> + <mdl:TextPrompt prompt="Normal Text Field..."/> </js:beads> </mdl:TextInput> <mdl:TextInput> <js:beads> - <mdl:EffectBead mdlEffect="mdl-textfield--floating-label"/> - <mdl:TextPromptBead prompt="Floating Label"/> + <mdl:TextInputEffect floatingLabel= "true"/> + <mdl:TextPrompt prompt="Floating Label"/> </js:beads> </mdl:TextInput> @@ -90,13 +90,13 @@ limitations under the License. <mdl:CheckBox id="mdlchk" text="Disabled at start" /> <mdl:CheckBox id="mdlchk1" text="Selected and with Ripple" selected="true"> <js:beads> - <mdl:EffectBead mdlEffect="mdl-js-ripple-effect"/> + <mdl:MDLEffect ripple="true"/> </js:beads> </mdl:CheckBox> <mdl:RadioButton groupName="g1" text="Black"/> <mdl:RadioButton groupName="g1" text="Ripple"> <js:beads> - <mdl:EffectBead mdlEffect="mdl-js-ripple-effect"/> + <mdl:MDLEffect ripple="true"/> </js:beads> </mdl:RadioButton> <mdl:RadioButton groupName="g1" text="Red"/> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3cfdd6ec/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/ButtonEffect.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/ButtonEffect.as b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/ButtonEffect.as new file mode 100644 index 0000000..e33d5ef --- /dev/null +++ b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/ButtonEffect.as @@ -0,0 +1,228 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 +{ + import org.apache.flex.core.IStrand; + import org.apache.flex.mdl.beads.MDLEffect; + import org.apache.flex.mdl.Button; + + /** + * The ButtonEffect class is a specialty bead that can be used with + * an MDL button control to apply some MDL complementary effect. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class ButtonEffect extends MDLEffect + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function ButtonEffect() + { + } + + private var _fab:String = ""; + /** + * A boolean flag to activate "mdl-button--fab" effect selector. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get fab():Boolean + { + return _fab; + } + public function set fab(value:Boolean):void + { + if(value) { + _fab = " mdl-button--fab"; + } else { + _fab = ""; + } + } + + private var _raised:String = ""; + /** + * A boolean flag to activate "mdl-button--raised" effect selector. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get raised():Boolean + { + return _raised; + } + public function set raised(value:Boolean):void + { + if(value) { + _raised = " mdl-button--raised"; + } else { + _raised = ""; + } + } + + private var _colored:String = ""; + /** + * A boolean flag to activate "mdl-button--colored" effect selector. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get colored():Boolean + { + return _colored; + } + public function set colored(value:Boolean):void + { + if(value) { + _colored = " mdl-button--colored"; + } else { + _colored = ""; + } + } + + private var _accent:String = ""; + /** + * A boolean flag to activate "mdl-button--accent" effect selector. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get accent():Boolean + { + return _accent; + } + public function set accent(value:Boolean):void + { + if(value) { + _accent = " mdl-button--accent"; + } else { + _accent = ""; + } + } + + private var _primary:String = ""; + /** + * A boolean flag to activate "mdl-button--primary" effect selector. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get primary():Boolean + { + return _primary; + } + public function set primary(value:Boolean):void + { + if(value) { + _primary = " mdl-button--primary"; + } else { + _primary = ""; + } + } + + private var _minifab:String = ""; + /** + * A boolean flag to activate "mdl-button--mini-fab" effect selector. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get minifab():Boolean + { + return _minifab; + } + public function set minifab(value:Boolean):void + { + if(value) { + _minifab = " mdl-button--mini-fab"; + } else { + _minifab = ""; + } + } + + private var _icon:String = ""; + /** + * A boolean flag to activate "mdl-button--icon" effect selector. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get icon():Boolean + { + return _icon; + } + public function set icon(value:Boolean):void + { + if(value) { + _icon = " mdl-button--icon"; + } else { + _icon = ""; + } + } + + 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 org.apache.flex.mdl.Button; + */ + override public function set strand(value:IStrand):void + { + _strand = value; + + COMPILE::JS + { + if (value is Button) { + var button:Button = value as Button; + button.className = _fab + _raised + _colored + _ripple + _accent + _primary + _minifab + _icon; + } else { + throw new Error("Host component must be an MDL Button."); + } + } + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3cfdd6ec/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/ButtonEffectBead.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/ButtonEffectBead.as b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/ButtonEffectBead.as deleted file mode 100644 index de999f9..0000000 --- a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/ButtonEffectBead.as +++ /dev/null @@ -1,253 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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 -{ - import org.apache.flex.core.IBead; - import org.apache.flex.core.IStrand; - import org.apache.flex.core.UIBase; - - import org.apache.flex.mdl.Button; - - /** - * The ButtonEffectBead class is a specialty bead that can be used with - * an MDL button control to apply some MDL complementary effect. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public class ButtonEffectBead implements IBead - { - /** - * constructor. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function ButtonEffectBead() - { - } - - private var _fab:String = ""; - /** - * A boolean flag to activate "mdl-button--fab" effect selector. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get fab():Boolean - { - return _fab; - } - public function set fab(value:Boolean):void - { - if(value) { - _fab = " mdl-button--fab"; - } else { - _fab = ""; - } - } - - private var _raised:String = ""; - /** - * A boolean flag to activate "mdl-button--raised" effect selector. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get raised():Boolean - { - return _raised; - } - public function set raised(value:Boolean):void - { - if(value) { - _raised = " mdl-button--raised"; - } else { - _raised = ""; - } - } - - private var _colored:String = ""; - /** - * A boolean flag to activate "mdl-button--colored" effect selector. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get colored():Boolean - { - return _colored; - } - public function set colored(value:Boolean):void - { - if(value) { - _colored = " mdl-button--colored"; - } else { - _colored = ""; - } - } - - private var _ripple:String = ""; - /** - * A boolean flag to activate "mdl-js-ripple-effect" effect selector. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get ripple():Boolean - { - return _ripple; - } - public function set ripple(value:Boolean):void - { - if(value) { - _ripple = " mdl-js-ripple-effect"; - } else { - _ripple = ""; - } - } - - private var _accent:String = ""; - /** - * A boolean flag to activate "mdl-button--accent" effect selector. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get accent():Boolean - { - return _accent; - } - public function set accent(value:Boolean):void - { - if(value) { - _accent = " mdl-button--accent"; - } else { - _accent = ""; - } - } - - private var _primary:String = ""; - /** - * A boolean flag to activate "mdl-button--primary" effect selector. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get primary():Boolean - { - return _primary; - } - public function set primary(value:Boolean):void - { - if(value) { - _primary = " mdl-button--primary"; - } else { - _primary = ""; - } - } - - private var _minifab:String = ""; - /** - * A boolean flag to activate "mdl-button--mini-fab" effect selector. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get minifab():Boolean - { - return _minifab; - } - public function set minifab(value:Boolean):void - { - if(value) { - _minifab = " mdl-button--mini-fab"; - } else { - _minifab = ""; - } - } - - private var _icon:String = ""; - /** - * A boolean flag to activate "mdl-button--icon" effect selector. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get icon():Boolean - { - return _icon; - } - public function set icon(value:Boolean):void - { - if(value) { - _icon = " mdl-button--icon"; - } else { - _icon = ""; - } - } - - 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::JS - { - if (value is Button) { - var button:Button = value as Button; - button.className = _fab + _raised + _colored + _ripple + _accent + _primary + _minifab + _icon; - } else { - throw new Error("Host component must be an MDL Button."); - } - } - } - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3cfdd6ec/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/EffectBead.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/EffectBead.as b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/EffectBead.as deleted file mode 100644 index d7ddcc0..0000000 --- a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/EffectBead.as +++ /dev/null @@ -1,98 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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 -{ - import org.apache.flex.core.IBead; - import org.apache.flex.core.IStrand; - import org.apache.flex.core.UIBase; - - import org.apache.flex.mdl.TextInput; - - /** - * The EffectBead class is a specialty bead that can be used with - * any MDL control to apply some MDL complementary effect. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public class EffectBead implements IBead - { - /** - * constructor. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function EffectBead() - { - } - - private var _mdlEffect:String = ""; - - /** - * The string to use as the MDL effect. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get mdlEffect():String - { - return _mdlEffect; - } - - public function set mdlEffect(value:String):void - { - _mdlEffect = 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::JS - { - if (value is TextInput) { - var mdTi:TextInput = value as TextInput; - mdTi.positioner.className = mdTi.positioner.className + " " + mdlEffect; - } else { - var host:UIBase = value as UIBase; - host.className = mdlEffect; - } - } - } - } -} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3cfdd6ec/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/MDLEffect.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/MDLEffect.as b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/MDLEffect.as new file mode 100644 index 0000000..4694507 --- /dev/null +++ b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/MDLEffect.as @@ -0,0 +1,105 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 +{ + import org.apache.flex.core.IBead; + import org.apache.flex.core.IStrand; + import org.apache.flex.core.UIBase; + import org.apache.flex.mdl.Button; + import org.apache.flex.mdl.TextInput; + + /** + * The EffectBead class is a specialty bead that can be used with + * any MDL control to apply some MDL complementary effect. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class MDLEffect implements IBead + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function MDLEffect() + { + } + + protected var _ripple:String = ""; + /** + * A boolean flag to activate "mdl-js-ripple-effect" effect selector. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get ripple():Boolean + { + return _ripple; + } + public function set ripple(value:Boolean):void + { + if(value) { + _ripple = " mdl-js-ripple-effect"; + } else { + _ripple = ""; + } + } + + 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::JS + { + if (value is Button) { + var button:Button = value as Button; + button.className = _ripple; + } else if (value is TextInput) { + var mdTi:TextInput = value as TextInput; + mdTi.positioner.className = mdTi.positioner.className + _ripple; + } else if (value is UIBase) { + var host:UIBase = value as UIBase; + host.className = _ripple; + } else { + throw new Error("Host component must be an MDL control."); + } + } + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3cfdd6ec/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/TextInputEffect.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/TextInputEffect.as b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/TextInputEffect.as new file mode 100644 index 0000000..c66c49a --- /dev/null +++ b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/TextInputEffect.as @@ -0,0 +1,97 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 +{ + import org.apache.flex.core.IStrand; + import org.apache.flex.mdl.beads.MDLEffect; + import org.apache.flex.mdl.TextInput; + + + /** + * The TextInputEffect class is a specialty bead that can be used with + * a MDL TextInput control to apply some MDL complementary effect. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class TextInputEffect extends MDLEffect + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function TextInputEffect() + { + } + + private var _floatingLabel:String = ""; + /** + * A boolean flag to activate "mdl-textfield--floating-label" effect selector. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function get floatingLabel():Boolean + { + return _floatingLabel; + } + public function set floatingLabel(value:Boolean):void + { + if(value) { + _floatingLabel = " mdl-textfield--floating-label"; + } else { + _floatingLabel = ""; + } + } + + 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 org.apache.flex.mdl.TextInput; + */ + override public function set strand(value:IStrand):void + { + _strand = value; + + COMPILE::JS + { + if (value is TextInput) { + var textinput:TextInput = value as TextInput; + textinput.positioner.className = textinput.positioner.className + _floatingLabel; + } else { + throw new Error("Host component must be an MDL TextInput."); + } + } + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3cfdd6ec/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/TextPrompt.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/TextPrompt.as b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/TextPrompt.as new file mode 100644 index 0000000..e3142b2 --- /dev/null +++ b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/TextPrompt.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 TextPrompt 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 TextPrompt implements IBead + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function TextPrompt() + { + } + + 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/3cfdd6ec/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 deleted file mode 100644 index 1c1e8fb..0000000 --- a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/TextPromptBead.as +++ /dev/null @@ -1,151 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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/3cfdd6ec/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 a4d62f2..8d30325 100644 --- a/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml +++ b/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml @@ -25,8 +25,9 @@ <component id="TextInput" class="org.apache.flex.mdl.TextInput"/> <component id="CheckBox" class="org.apache.flex.mdl.CheckBox"/> <component id="RadioButton" class="org.apache.flex.mdl.RadioButton"/> - <component id="TextPromptBead" class="org.apache.flex.mdl.beads.TextPromptBead"/> - <component id="EffectBead" class="org.apache.flex.mdl.beads.EffectBead"/> - <component id="ButtonEffectBead" class="org.apache.flex.mdl.beads.ButtonEffectBead"/> + <component id="TextPrompt" class="org.apache.flex.mdl.beads.TextPrompt"/> + <component id="MDLEffect" class="org.apache.flex.mdl.beads.MDLEffect"/> + <component id="ButtonEffect" class="org.apache.flex.mdl.beads.ButtonEffect"/> + <component id="TextInputEffect" class="org.apache.flex.mdl.beads.TextInputEffect"/> </componentPackage>