Hi Carlos,

I've added ContactChip, but for some reason it won't work in Example.
Basically "strand" property in ContactChip has never been raised. I think I
missed something obvious - If you could look into the ContactChip bead.

Thanks,
Piotr

2016-12-04 15:39 GMT+01:00 <pio...@apache.org>:

> Repository: flex-asjs
> Updated Branches:
>   refs/heads/develop c18821a99 -> d7a3778a6
>
>
> Add ContactChip bead - not working
> - Throw error if deletable chip do not have any material icons bead
>
>
> Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
> Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/d7a3778a
> Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/d7a3778a
> Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/d7a3778a
>
> Branch: refs/heads/develop
> Commit: d7a3778a69d48d6bb4c8145458f3ef81939c286c
> Parents: c18821a
> Author: piotrz <pio...@apache.org>
> Authored: Sun Dec 4 15:39:44 2016 +0100
> Committer: piotrz <pio...@apache.org>
> Committed: Sun Dec 4 15:39:44 2016 +0100
>
> ----------------------------------------------------------------------
>  .../flexjs/MDLExample/src/main/flex/Chips.mxml  |  13 +-
>  .../org/apache/flex/mdl/beads/ContactChip.as    | 126 +++++++++++++++++++
>  .../org/apache/flex/mdl/beads/DeletableChip.as  |  20 +--
>  .../src/main/resources/mdl-manifest.xml         |   5 +-
>  4 files changed, 151 insertions(+), 13 deletions(-)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/
> d7a3778a/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 b354809..d55a0d7 100644
> --- a/examples/flexjs/MDLExample/src/main/flex/Chips.mxml
> +++ b/examples/flexjs/MDLExample/src/main/flex/Chips.mxml
> @@ -23,10 +23,10 @@ limitations under the License.
>          <mdl:GridCell column="1">
>              <mdl:Chip text="Basic Chip" />
>          </mdl:GridCell>
> -        <mdl:GridCell column="2">
> +        <mdl:GridCell column="1">
>              <mdl:ButtonChip text="Button Chip" />
>          </mdl:GridCell>
> -        <mdl:GridCell column="3">
> +        <mdl:GridCell column="1">
>              <mdl:Chip text="Deletable Chip">
>                  <mdl:beads>
>                      <mdl:MaterialIconCancel />
> @@ -34,7 +34,7 @@ limitations under the License.
>                  </mdl:beads>
>              </mdl:Chip>
>          </mdl:GridCell>
> -        <mdl:GridCell column="4">
> +        <mdl:GridCell column="1">
>              <mdl:ButtonChip text="Deletable Button Chip">
>                  <mdl:beads>
>                      <mdl:MaterialIconCancel />
> @@ -42,5 +42,12 @@ limitations under the License.
>                  </mdl:beads>
>              </mdl:ButtonChip>
>          </mdl:GridCell>
> +        <mdl:GridCell column="1">
> +            <mdl:Chip text="Contact Chip">
> +                <mdl:beads>
> +                    <mdl:ContactChip contactText="A"/>
> +                </mdl:beads>
> +            </mdl:Chip>
> +        </mdl:GridCell>
>      </mdl:Grid>
>  </mdl:TabBarPanel>
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/
> d7a3778a/frameworks/projects/MaterialDesignLite/src/main/
> flex/org/apache/flex/mdl/beads/ContactChip.as
> ----------------------------------------------------------------------
> diff --git a/frameworks/projects/MaterialDesignLite/src/main/
> flex/org/apache/flex/mdl/beads/ContactChip.as b/frameworks/projects/
> MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/ContactChip.as
> new file mode 100644
> index 0000000..7af8703
> --- /dev/null
> +++ b/frameworks/projects/MaterialDesignLite/src/main/
> flex/org/apache/flex/mdl/beads/ContactChip.as
> @@ -0,0 +1,126 @@
> +///////////////////////////////////////////////////////////
> /////////////////////
> +//
> +//  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;
> +
> +    /**
> +     *  The ContactChip bead class is a specialty bead that can be used
> to add additional
> +     *  button to Chip MDL control.
> +     *
> +     *  @langversion 3.0
> +     *  @playerversion Flash 10.2
> +     *  @playerversion AIR 2.6
> +     *  @productversion FlexJS 0.0
> +     */
> +    public class ContactChip implements IBead
> +    {
> +        /**
> +         *  constructor.
> +         *
> +         *  @langversion 3.0
> +         *  @playerversion Flash 10.2
> +         *  @playerversion AIR 2.6
> +         *  @productversion FlexJS 0.0
> +         */
> +        public function ContactChip()
> +        {
> +        }
> +
> +        private var _contactText:String = "";
> +
> +        COMPILE::JS
> +        private var contact:HTMLSpanElement;
> +        COMPILE::JS
> +        private var textNode:Text;
> +
> +        private var _strand:IStrand;
> +
> +        /**
> +         * @flexjsignorecoercion HTMLElement
> +         * @flexjsignorecoercion HTMLSpanElement
> +         * @flexjsignorecoercion Text
> +         * @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--contact");
> +
> +                    textNode = document.createTextNode('') as Text;
> +
> +                    contact = document.createElement("span") as
> HTMLSpanElement;
> +                    contact.classList.add("mdl-chip__contact");
> +                    contact.appendChild(textNode);
> +
> +                    element.appendChild(contact);
> +                }
> +                else
> +                {
> +                    throw new Error("Host component must be an MDL Host
> for Chips.");
> +                }
> +            }
> +        }
> +
> +        /**
> +         *  The text for contact
> +         *
> +         *  @langversion 3.0
> +         *  @playerversion Flash 10.2
> +         *  @playerversion AIR 2.6
> +         *  @productversion FlexJS 0.0
> +         */
> +        public function get contactText():String
> +        {
> +            COMPILE::SWF
> +            {
> +                return _contactText;
> +            }
> +            COMPILE::JS
> +            {
> +                return textNode.nodeValue;
> +            }
> +        }
> +
> +        public function set contactText(value:String):void
> +        {
> +            COMPILE::SWF
> +            {
> +                _contactText = value;
> +            }
> +            COMPILE::JS
> +            {
> +                textNode.nodeValue = value;
> +            }
> +        }
> +    }
> +}
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/
> d7a3778a/frameworks/projects/MaterialDesignLite/src/main/
> flex/org/apache/flex/mdl/beads/DeletableChip.as
> ----------------------------------------------------------------------
> diff --git a/frameworks/projects/MaterialDesignLite/src/main/
> flex/org/apache/flex/mdl/beads/DeletableChip.as b/frameworks/projects/
> MaterialDesignLite/src/main/flex/org/apache/flex/mdl/
> beads/DeletableChip.as
> index 8c2ddcd..e21a0d3 100644
> --- a/frameworks/projects/MaterialDesignLite/src/main/
> flex/org/apache/flex/mdl/beads/DeletableChip.as
> +++ b/frameworks/projects/MaterialDesignLite/src/main/
> flex/org/apache/flex/mdl/beads/DeletableChip.as
> @@ -22,7 +22,6 @@ package org.apache.flex.mdl.beads
>      import org.apache.flex.core.IStrand;
>      import org.apache.flex.core.UIBase;
>      import org.apache.flex.mdl.Button;
> -    import org.apache.flex.mdl.beads.materialIcons.MaterialIconCancel;
>      import org.apache.flex.mdl.supportClasses.MaterialIconBase;
>      import org.apache.flex.utils.StrandUtils;
>
> @@ -50,6 +49,7 @@ package org.apache.flex.mdl.beads
>
>          }
>
> +        private var deleteButton:Button;
>          private var _strand:IStrand;
>
>          /**
> @@ -73,9 +73,9 @@ package org.apache.flex.mdl.beads
>                  {
>                      element.classList.add("mdl-chip--deletable");
>
> -                    var deleteButton:HTMLElement = createDeleteButton();
> +                    deleteButton = createDeleteButton();
>
> -                    element.appendChild(deleteButton);
> +                    element.appendChild(deleteButton.element as
> HTMLElement);
>                  }
>                  else
>                  {
> @@ -90,18 +90,22 @@ package org.apache.flex.mdl.beads
>           * @return Button represents cancel icon
>           */
>          COMPILE::JS
> -        private function createDeleteButton():HTMLElement
> +        private function createDeleteButton():Button
>          {
>              var iconBead:IBead = StrandUtils.loadBead(MaterialIconBase,
> "MaterialIconBase", _strand);
> +            if (iconBead == null)
> +            {
> +                throw new Error("MaterialIconBase bead does not exists");
> +            }
>
> -            var deleteButton:Button = new Button();
> -            deleteButton.addBead(iconBead);
> +            var delButton:Button = new Button();
> +            delButton.addBead(iconBead);
>
> -            var htmlButton:HTMLElement = (deleteButton.element as
> HTMLElement);
> +            var htmlButton:HTMLElement = (delButton.element as
> HTMLElement);
>              htmlButton.classList.remove("mdl-button", "mdl-js-button");
>              htmlButton.classList.add("mdl-chip__action");
>
> -            return htmlButton;
> +            return delButton;
>          }
>      }
>  }
>
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/
> d7a3778a/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 0199248..e033fcb 100644
> --- a/frameworks/projects/MaterialDesignLite/src/main/
> resources/mdl-manifest.xml
> +++ b/frameworks/projects/MaterialDesignLite/src/main/
> resources/mdl-manifest.xml
> @@ -43,8 +43,8 @@
>      <component id="CardMenu" class="org.apache.flex.mdl.CardMenu"/>
>      <component id="Spacer" class="org.apache.flex.mdl.Spacer"/>
>      <component id="List" class="org.apache.flex.mdl.List"/>
> -        <component id="ListView" class="org.apache.flex.mdl.
> beads.views.ListView"/>
> -        <component id="ItemRendererFactoryForArrayData"
> class="org.apache.flex.mdl.supportClasses.ItemRendererFactoryForArrayDat
> a"/>
> +    <component id="ListView" class="org.apache.flex.mdl.
> beads.views.ListView"/>
> +    <component id="ItemRendererFactoryForArrayData"
> class="org.apache.flex.mdl.supportClasses.ItemRendererFactoryForArrayDat
> a"/>
>      <component id="NavigationLayout" class="org.apache.flex.mdl.
> NavigationLayout"/>
>      <component id="LayoutTitle" class="org.apache.flex.mdl.LayoutTitle"/>
>      <component id="Navigation" class="org.apache.flex.mdl.Navigation"/>
> @@ -66,4 +66,5 @@
>      <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"/>
> +    <component id="ContactChip" class="org.apache.flex.mdl.
> beads.ContactChip"/>
>  </componentPackage>
>
>


-- 

Greetings
Piotr Zarzycki

Flex/AIR/.NET Developer

mobile: +48 880 859 557
e-mail: piotrzarzyck...@gmail.com
skype: zarzycki10

LinkedIn: http://www.linkedin.com/piotrzarzycki
<https://pl.linkedin.com/in/piotr-zarzycki-92a53552>

Reply via email to