Repository: flex-asjs Updated Branches: refs/heads/develop c90180e60 -> 300938934
Add DeletableLinkChip - it's represents "a" like delete button in Chip component Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/30093893 Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/30093893 Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/30093893 Branch: refs/heads/develop Commit: 3009389346804fdd9149acff123fca9fa05b4b1b Parents: c90180e Author: piotrz <pio...@apache.org> Authored: Tue Dec 6 22:19:47 2016 +0100 Committer: piotrz <pio...@apache.org> Committed: Tue Dec 6 22:19:47 2016 +0100 ---------------------------------------------------------------------- .../flexjs/MDLExample/src/main/flex/Chips.mxml | 9 ++ .../apache/flex/mdl/beads/DeletableLinkChip.as | 118 +++++++++++++++++++ .../src/main/resources/mdl-manifest.xml | 1 + 3 files changed, 128 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/30093893/examples/flexjs/MDLExample/src/main/flex/Chips.mxml ---------------------------------------------------------------------- diff --git a/examples/flexjs/MDLExample/src/main/flex/Chips.mxml b/examples/flexjs/MDLExample/src/main/flex/Chips.mxml index 7adc2ff..a0861e3 100644 --- a/examples/flexjs/MDLExample/src/main/flex/Chips.mxml +++ b/examples/flexjs/MDLExample/src/main/flex/Chips.mxml @@ -58,5 +58,14 @@ limitations under the License. </mdl:beads> </mdl:Chip> </mdl:GridCell> + <mdl:GridCell column="5"> + <mdl:Chip text="Contact Link Chip"> + <mdl:beads> + <mdl:ContactChip contactText="L" color="teal" textColor="white"/> + <mdl:MaterialIconCancel /> + <mdl:DeletableLinkChip href="http://flex.apache.org/"/> + </mdl:beads> + </mdl:Chip> + </mdl:GridCell> </mdl:Grid> </mdl:TabBarPanel> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/30093893/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/DeletableLinkChip.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/DeletableLinkChip.as b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/DeletableLinkChip.as new file mode 100644 index 0000000..19cf733 --- /dev/null +++ b/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/DeletableLinkChip.as @@ -0,0 +1,118 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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.NavigationLink; + import org.apache.flex.mdl.supportClasses.MaterialIconBase; + import org.apache.flex.utils.StrandUtils; + + /** + * The DeletableLinkChip bead class is a specialty bead that can be used to add additional + * link button to Chip MDL control. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class DeletableLinkChip implements IBead + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function DeletableLinkChip() + { + } + + private var linkElement:NavigationLink; + private var _href:String; + private var _strand:IStrand; + + /** + * @flexjsignorecoercion HTMLElement + * @flexjsignorecoercion HTMLSpanElement + * @flexjsignorecoercion HTMLButtonElement + * + * @param value + */ + public function set strand(value:IStrand):void + { + _strand = value; + + COMPILE::JS + { + var host:UIBase = value as UIBase; + var element:HTMLElement = host.element as HTMLElement; + var isValidElement:Boolean = element is HTMLSpanElement || element is HTMLButtonElement; + + if (isValidElement && element.className.search("mdl-chip") > -1) + { + element.classList.add("mdl-chip--deletable"); + + linkElement = createLinkElement(); + linkElement.href = _href; + + element.appendChild(linkElement.element as HTMLElement); + } + else + { + throw new Error("Host component must be an MDL Host for Chips."); + } + } + } + + + public function set href(value:String):void + { + _href = value; + } + + /** + * @flexjsignorecoercion HTMLElement + * + * @return Link represents cancel icon + */ + COMPILE::JS + private function createLinkElement():NavigationLink + { + var iconBead:IBead = StrandUtils.loadBead(MaterialIconBase, "MaterialIconBase", _strand); + if (iconBead == null) + { + throw new Error("Missing material icon bead"); + } + + var link:NavigationLink = new NavigationLink(); + link.addBead(iconBead); + + var linkElement:HTMLElement = (link.element as HTMLElement); + linkElement.classList.remove("mdl-navigation__link"); + linkElement.classList.add("mdl-chip__action"); + + return link; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/30093893/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 e033fcb..5810af8 100644 --- a/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml +++ b/frameworks/projects/MaterialDesignLite/src/main/resources/mdl-manifest.xml @@ -63,6 +63,7 @@ <component id="Chip" class="org.apache.flex.mdl.Chip"/> <component id="ButtonChip" class="org.apache.flex.mdl.ButtonChip"/> <component id="DeletableChip" class="org.apache.flex.mdl.beads.DeletableChip"/> + <component id="DeletableLinkChip" class="org.apache.flex.mdl.beads.DeletableLinkChip"/> <component id="MaterialIconCancel" class="org.apache.flex.mdl.beads.materialIcons.MaterialIconCancel"/> <component id="MaterialIconAdd" class="org.apache.flex.mdl.beads.materialIcons.MaterialIconAdd"/> <component id="Tooltip" class="org.apache.flex.mdl.Tooltip"/>