Add alt bead for images alt tag on JS / tooltip on AS

Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/eafb8111
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/eafb8111
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/eafb8111

Branch: refs/heads/develop
Commit: eafb81111b556e413d314d4826ef3f16eac63df8
Parents: c0d218f
Author: Justin Mclean <jmcl...@apache.org>
Authored: Tue Jul 11 15:40:05 2017 +1000
Committer: Justin Mclean <jmcl...@apache.org>
Committed: Tue Jul 11 15:40:05 2017 +1000

----------------------------------------------------------------------
 .../flex/html/beads/AccessibilityAltBead.as     | 114 +++++++++++++++++++
 .../Basic/src/main/resources/basic-manifest.xml |   1 +
 2 files changed, 115 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/eafb8111/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/AccessibilityAltBead.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/AccessibilityAltBead.as
 
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/AccessibilityAltBead.as
new file mode 100644
index 0000000..3bb3580
--- /dev/null
+++ 
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/AccessibilityAltBead.as
@@ -0,0 +1,114 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.html.beads
+{
+
+       import org.apache.flex.core.IBead;
+       import org.apache.flex.core.IStrand;
+       import org.apache.flex.events.IEventDispatcher;
+       import org.apache.flex.events.ValueEvent;
+
+       COMPILE::SWF {
+               import org.apache.flex.html.accessories.ToolTipBead;
+       }
+
+/**
+        *  The AccessibilityAltBead class is a bead that can be used with
+        *  any Image control. The bead places add an alt text attribute
+        *  on a image.
+        *  
+        *  @langversion 3.0
+        *  @playerversion Flash 10.2
+        *  @playerversion AIR 2.6
+        *  @productversion FlexJS 0.9
+        */
+       public class AccessibilityAltBead implements IBead
+       {
+               /**
+                *  constructor.
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion FlexJS 0.9
+                */
+               public function AccessibilityAltBead()
+               {
+               }
+               
+               private var _strand:IStrand;
+               private var _alt:String;
+               
+               /**
+                *  @copy org.apache.flex.core.IBead#strand
+                *  
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion FlexJS 0.9
+                *  @flexjsignorecoercion HTMLInputElement
+                *  @flexjsignorecoercion org.apache.flex.core.UIBase;
+                */
+               public function set strand(value:IStrand):void
+               {       
+                       _strand = value;
+                       updateHost();
+               }
+               
+               public function get alt():String
+               {
+                       return _alt;
+               }
+
+               /**
+                *  @private
+                */
+               public function set alt(value:String):void
+               {
+                       if (value != _alt)
+                       {
+                               _alt = value;
+                               updateHost();
+                       }
+               }
+
+               private function updateHost():void
+               {
+                       if(!_strand)
+                               return;
+
+                       COMPILE::SWF {
+                               //TODO may want to do something else on he AS 
side
+                               var toolTip:ToolTipBead = 
_strand.getBeadByType(ToolTipBead) as ToolTipBead;
+
+                               if (toolTip) {
+                    toolTip.toolTip = _alt;
+                }
+                       }
+                       
+                       COMPILE::JS {
+                (_strand as Object).element.alt = _alt;
+            }
+
+                       IEventDispatcher(_strand).dispatchEvent(new 
ValueEvent("altChange", alt));
+                               
+               }
+               
+       }
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/eafb8111/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml 
b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
index 3908e93..625f9bc 100644
--- a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
+++ b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
@@ -79,6 +79,7 @@
     <component id="ListView" class="org.apache.flex.html.beads.ListView"/>
     <component id="AccordionView" 
class="org.apache.flex.html.beads.AccordionView"/>
     <component id="CenterElement" 
class="org.apache.flex.html.beads.CenterElement"/>
+    <component id="AccessibilityAltBead" 
class="org.apache.flex.html.beads.AccessibilityAltBead" />
     <!--<component id="MultilineTextFieldView" 
class="org.apache.flex.html.beads.MultilineTextFieldView"/>-->
 
     <component id="SimpleAlert" class="org.apache.flex.html.SimpleAlert"/>

Reply via email to