123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044 |
- (function() {
- // $source: com/ibm/rave/accessibility/internal/nativeImpl/ModuleHeader
- /************************************************************************
- ** IBM Confidential
- **
- ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
- **
- ** (C) Copyright IBM Corp. 2014, 2015
- **
- ** The source code for this program is not published or otherwise divested of its trade secrets,
- ** irrespective of what has been deposited with the U.S. Copyright Office.
- ************************************************************************/
- // setup
- var rave = window["rave"], rave_document = rave["_"]["rave_document"], rave_externs={},
- com_ibm_rave_core_Rave = rave,
- com_ibm_rave_core_nativeImpl_Declare = rave["_"]["com_ibm_rave_core_nativeImpl_Declare"],
- com_ibm_rave_core_selector_Selector = rave["internal"]["Selector"],
- com_ibm_rave_core_selector_SelectorDelegate = rave["internal"]["SelectorDelegate"],
- com_ibm_rave_navigation_focus_FocusController = rave["navigation"]["internal"]["FocusController"],
- com_ibm_rave_navigation_Navigation = rave["navigation"];
- // $source: com/ibm/rave/accessibility/AccessibilityConstants
- /************************************************************************
- ** IBM Confidential
- **
- ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
- **
- ** (C) Copyright IBM Corp. 2015
- **
- ** The source code for this program is not published or otherwise divested of its trade secrets,
- ** irrespective of what has been deposited with the U.S. Copyright Office.
- ************************************************************************/
- // GENERATED
- var com_ibm_rave_accessibility_AccessibilityConstants = rave_externs["AccessibilityConstants"] = {
- };
- /**
- * Key for the accessibility selector. To access accessibility methods on a selector, get the accessibility selector from the core selector this way: <code> AccessibilitySelector a11ySelector = (AccessibilitySelector) Rave.select("id").extension( Accessibility.SELECTOR_ID); </code>
- */
- /** @expose */
- com_ibm_rave_accessibility_AccessibilityConstants.SELECTOR_ID = "raveAccessibility";
- /**
- * Property key for accessible info. The accessible info must be of type {@link (Object) AccessibleInfo} .
- */
- /** @expose */
- com_ibm_rave_accessibility_AccessibilityConstants.ACCESSIBLE_INFO_KEY = "__accessibleInfo__";
- /**
- * Property key for shadow tree builder. The shadow tree builder must be of type {@link (com.ibm.rave.accessibility.ShadowTreeBuilder) ShadowTreeBuilder} .
- */
- /** @expose */
- com_ibm_rave_accessibility_AccessibilityConstants.SHADOW_TREE_BUILDER_KEY = "__shadowTreeBuilder__";
- // $source: com/ibm/rave/accessibility/internal/AccessibleNavigationSceneNodeExtension
- /************************************************************************
- ** IBM Confidential
- **
- ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
- **
- ** (C) Copyright IBM Corp. 2015
- **
- ** The source code for this program is not published or otherwise divested of its trade secrets,
- ** irrespective of what has been deposited with the U.S. Copyright Office.
- ************************************************************************/
- // GENERATED
- //@import com/ibm/rave/core/Rave (static) // Rave
- //@import com/ibm/rave/accessibility/internal/AccessibilityUtil (runtime) // getShadowTreeBuilder, recursiveSetShadowTreeBuilder
- //@import com/ibm/rave/accessibility/AccessibilityConstants (runtime) // AccessibilityConstants
- var com_ibm_rave_accessibility_internal_AccessibleNavigationSceneNodeExtension = {
- //constructor : function() {}
- };
- com_ibm_rave_accessibility_internal_AccessibleNavigationSceneNodeExtension.extend = function(baseNode) {
- var oriAppendChild = baseNode.appendChild;
- baseNode.appendChild = function(node) {
- oriAppendChild.call(this, node);
- com_ibm_rave_core_Rave.configuration.extendRecursive(node);
- var builder = com_ibm_rave_accessibility_internal_AccessibilityUtil.getShadowTreeBuilder(this);
- if (builder) {
- com_ibm_rave_accessibility_internal_AccessibilityUtil.recursiveSetShadowTreeBuilder(node, builder);
- builder.onAppend(this, node);
- }
- };
- var oriInsertBefore = baseNode.insertBefore;
- baseNode.insertBefore = function(node, before) {
- oriInsertBefore.call(this, node, before);
- com_ibm_rave_core_Rave.configuration.extendRecursive(node);
- var builder = com_ibm_rave_accessibility_internal_AccessibilityUtil.getShadowTreeBuilder(this);
- if (builder) {
- com_ibm_rave_accessibility_internal_AccessibilityUtil.recursiveSetShadowTreeBuilder(node, builder);
- builder.onInsert(this, node, before);
- }
- };
- var oriRemoveChild = baseNode.removeChild;
- baseNode.removeChild = function(node) {
- var i = this.rave_getChildNodes().indexOf(node);
- if (i != -1) {
- oriRemoveChild.call(this, node);
- com_ibm_rave_core_Rave.configuration.extendRecursive(node);
- var builder = com_ibm_rave_accessibility_internal_AccessibilityUtil.getShadowTreeBuilder(node);
- if (builder) {
- builder.onRemove(this, node, i);
- com_ibm_rave_accessibility_internal_AccessibilityUtil.recursiveSetShadowTreeBuilder(node, null);
- }
- return true;
- }
- return false;
- };
- var oriSetProperty = baseNode.rave_setProperty;
- baseNode.rave_setProperty = function(key, value) {
- oriSetProperty.call(this, key, value);
- if (com_ibm_rave_accessibility_AccessibilityConstants.ACCESSIBLE_INFO_KEY == key) {
- var builder = com_ibm_rave_accessibility_internal_AccessibilityUtil.getShadowTreeBuilder(this);
- if (builder) {
- builder.onChange(this);
- }
- }
- };
- };
- com_ibm_rave_accessibility_internal_AccessibleNavigationSceneNodeExtension.register = function() {
- com_ibm_rave_core_Rave.configuration.addSceneNodeExtensionFactory("http://www.w3.org/2000/svg", function(node, context) {
- if ((context && context.rave_hasProperty(com_ibm_rave_accessibility_AccessibilityConstants.SHADOW_TREE_BUILDER_KEY)) || node.rave_hasProperty(com_ibm_rave_accessibility_AccessibilityConstants.SHADOW_TREE_BUILDER_KEY)) {
- com_ibm_rave_accessibility_internal_AccessibleNavigationSceneNodeExtension.extend(node);
- }
- }, 0);
- };
- // $source: com/ibm/rave/accessibility/internal/AccessibilityUtil
- /************************************************************************
- ** IBM Confidential
- **
- ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
- **
- ** (C) Copyright IBM Corp. 2015
- **
- ** The source code for this program is not published or otherwise divested of its trade secrets,
- ** irrespective of what has been deposited with the U.S. Copyright Office.
- ************************************************************************/
- // GENERATED
- //@import com/ibm/rave/accessibility/AccessibilityConstants (static) // AccessibilityConstants
- //@import com/ibm/rave/core/selector/Selector (static) // extension
- //@import com/ibm/rave/accessibility/selector/AccessibilitySelector (runtime) // new
- var com_ibm_rave_accessibility_internal_AccessibilityUtil = {
- //constructor : function() {}
- };
- com_ibm_rave_accessibility_internal_AccessibilityUtil.getShadowTreeBuilder = function(node) {
- return node.rave_getProperty(com_ibm_rave_accessibility_AccessibilityConstants.SHADOW_TREE_BUILDER_KEY);
- };
- com_ibm_rave_accessibility_internal_AccessibilityUtil.hasAccessibleInfo = function(node) {
- return node.rave_getProperty(com_ibm_rave_accessibility_AccessibilityConstants.ACCESSIBLE_INFO_KEY) != null;
- };
- com_ibm_rave_accessibility_internal_AccessibilityUtil.recursiveSetShadowTreeBuilder = function(node, builder) {
- node.rave_setProperty(com_ibm_rave_accessibility_AccessibilityConstants.SHADOW_TREE_BUILDER_KEY, builder);
- if (node.rave_hasChildNodes()) {
- for (var __i_enFor0 = 0, __exp_enFor0 = node.rave_getChildNodes(), __len_enFor0 = __exp_enFor0.length;
- __i_enFor0 < __len_enFor0; ++__i_enFor0) {
- var child = __exp_enFor0[__i_enFor0];
- com_ibm_rave_accessibility_internal_AccessibilityUtil.recursiveSetShadowTreeBuilder(child, builder);
- }
- }
- };
- com_ibm_rave_accessibility_internal_AccessibilityUtil.registerSelector = function() {
- com_ibm_rave_core_selector_Selector.extension(com_ibm_rave_accessibility_AccessibilityConstants.SELECTOR_ID, function() {
- return new com_ibm_rave_accessibility_selector_AccessibilitySelector();
- });
- };
- // $source: com/ibm/rave/accessibility/selector/AccessibilitySelector
- /************************************************************************
- ** IBM Confidential
- **
- ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
- **
- ** (C) Copyright IBM Corp. 2015
- **
- ** The source code for this program is not published or otherwise divested of its trade secrets,
- ** irrespective of what has been deposited with the U.S. Copyright Office.
- ************************************************************************/
- // GENERATED
- //@import com/ibm/rave/core/nativeImpl/Declare (loadtime) // declare
- //@import com/ibm/rave/core/selector/SelectorDelegate (loadtime) // superclass
- //@import com/ibm/rave/accessibility/internal/nativeImpl/AccessibleContext (runtime) // getDescription, setDescription
- //@import com/ibm/rave/accessibility/AccessibilityConstants (runtime) // AccessibilityConstants
- /**
- * Accessibility extension to {@link (com.ibm.rave.core.selector.SelectorDelegate) SelectorDelegate} . Adds the ability to perform accessibility related functions to a selector.
- */
- var com_ibm_rave_accessibility_selector_AccessibilitySelector = rave_externs["AccessibilitySelector"] = com_ibm_rave_core_nativeImpl_Declare(com_ibm_rave_core_selector_SelectorDelegate, {
- /**
- * Constructor
- */
- /** @expose */
- constructor : function() {},
- /**
- * @see {@link this.SelectorDelegate#this.create}
- */
- /** @expose */
- create : function(s) {
- var as = new com_ibm_rave_accessibility_selector_AccessibilitySelector();
- return as.setDelegate(s);
- },
- /**
- * Get the accessible description for the first SceneNode in this Selector. In JavaScript, this gets the "aria-label".
- * @return (String) the accessible description of the first SceneNode in this Selector
- */
- description$0 : function() {
- var node = this.node();
- var owner = node ? node.rave_getOwner() : null;
- return !owner ? null : com_ibm_rave_accessibility_internal_nativeImpl_AccessibleContext.getDescription(owner);
- },
- /**
- * Set an accessible description for each owner of SceneNode in this Selector. In JavaScript, this sets the "aria-label".
- * @param (String) description the description
- * @return (com.ibm.rave.accessibility.selector.AccessibilitySelector) this {@link (com.ibm.rave.accessibility.selector.AccessibilitySelector) AccessibilitySelector}
- */
- description$1 : function(description) {
- this.each(function(data, index, groupIndex) {
- var owner = this.rave_getOwner();
- if (owner) {
- com_ibm_rave_accessibility_internal_nativeImpl_AccessibleContext.setDescription(owner, description);
- if (description != null) {
- var info = owner.rave_getProperty(com_ibm_rave_accessibility_AccessibilityConstants.ACCESSIBLE_INFO_KEY);
- if (!info) {
- info = {};
- info["label"] = description;
- owner.rave_setProperty(com_ibm_rave_accessibility_AccessibilityConstants.ACCESSIBLE_INFO_KEY, info);
- }
- }
- }
- });
- return this;
- },
- /**
- * Set an accessible description for each owner of SceneNode in this Selector. In JavaScript, this sets the "aria-label".
- * @param (com.ibm.rave.core.selector.ValueFunction) valueFunction a function which returns a description
- * @return (com.ibm.rave.core.selector.Selector) this {@link (com.ibm.rave.accessibility.selector.AccessibilitySelector) AccessibilitySelector}
- */
- description$2 : function(valueFunction) {
- this.each(function(data, index, groupIndex) {
- var owner = this.rave_getOwner();
- if (owner) {
- var value = valueFunction.call(owner, owner.rave_getData(), index, groupIndex);
- var description = value != null ? value + "" : "";
- com_ibm_rave_accessibility_internal_nativeImpl_AccessibleContext.setDescription(owner, description);
- if (description != null) {
- var info = owner.rave_getProperty(com_ibm_rave_accessibility_AccessibilityConstants.ACCESSIBLE_INFO_KEY);
- if (!info) {
- info = {};
- info["label"] = description;
- owner.rave_setProperty(com_ibm_rave_accessibility_AccessibilityConstants.ACCESSIBLE_INFO_KEY, info);
- }
- }
- }
- });
- return this;
- },
- /**
- * Get the accessible info for the first SceneNode in this Selector.
- * @return (Object) the accessible info of the first SceneNode in this Selector
- */
- info$0 : function() {
- var node = this.node();
- return !node ? null : node.rave_getProperty(com_ibm_rave_accessibility_AccessibilityConstants.ACCESSIBLE_INFO_KEY);
- },
- /**
- * Set an accessible info for each SceneNode in this Selector.
- * @param (Object) info the accessible info
- * @return (com.ibm.rave.accessibility.selector.AccessibilitySelector) this {@link (com.ibm.rave.accessibility.selector.AccessibilitySelector) AccessibilitySelector}
- */
- info$1 : function(info) {
- this.each(function(data, index, groupIndex) {
- this.rave_setProperty(com_ibm_rave_accessibility_AccessibilityConstants.ACCESSIBLE_INFO_KEY, info);
- });
- return this;
- },
- /**
- * Set an accessible info for each SceneNode in this Selector.
- * @param (com.ibm.rave.core.selector.ValueFunction) valueFunction a function which returns a {@link (Object) AccessibleInfo}
- * @return (com.ibm.rave.accessibility.selector.AccessibilitySelector) this {@link (com.ibm.rave.accessibility.selector.AccessibilitySelector) AccessibilitySelector}
- */
- info$2 : function(valueFunction) {
- this.each(function(data, index, groupIndex) {
- this.rave_setProperty(com_ibm_rave_accessibility_AccessibilityConstants.ACCESSIBLE_INFO_KEY, valueFunction.call(this, data, index, groupIndex));
- });
- return this;
- },
- /** @expose */
- description : function(a0) {
- var args = arguments;
- if (args.length == 0) {
- return this.description$0();
- }
- if (args.length == 1 && (a0 == null || typeof a0 === "string")) {
- return this.description$1(a0);
- }
- return this.description$2(a0);
- },
- /** @expose */
- info : function(a0) {
- var args = arguments;
- if (args.length == 0) {
- return this.info$0();
- }
- if (args.length == 1 && typeof a0 === "function") {
- return this.info$2(a0);
- }
- return this.info$1(a0);
- }
- });
- // $source: com/ibm/rave/accessibility/internal/nativeImpl/ShadowDOMBuilder
- /************************************************************************
- ** IBM Confidential
- **
- ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
- **
- ** (C) Copyright IBM Corp. 2014, 2015
- **
- ** The source code for this program is not published or otherwise divested of its trade secrets,
- ** irrespective of what has been deposited with the U.S. Copyright Office.
- ************************************************************************/
- // @import com/ibm/rave/core/nativeImpl/Declare
- // @import com/ibm/rave/accessibility/AccessibilityConstants
- // @import com/ibm/rave/core/internal/nativeImpl/event/Event
- var com_ibm_rave_accessibility_internal_nativeImpl_ShadowDOMBuilder = (function() {
-
- var shadowDomNodeKey = "__shadowDomNode__";
- var sceneNodeKey = "__sceneNode__";
-
- function removeShadowDomNode(domNode) {
- if (domNode[shadowDomNodeKey]) {
- delete domNode[shadowDomNodeKey][sceneNodeKey];
- delete domNode[shadowDomNodeKey];
- }
- var childNodes = domNode.childNodes;
- for (var i = 0; i < childNodes.length; i++) {
- removeShadowDomNode(childNodes[i]);
- }
- }
-
- function setAttributes(shadowDomNode, info) {
- // set the known properties
- shadowDomNode.setAttribute("aria-label", info["label"] || "");
- shadowDomNode.setAttribute("aria-hint", info["hint"] || "");
- shadowDomNode.setAttribute("role", info["role"] || "");
-
- // clear all custom properties
- for (var i = 0, nodeName, atts = shadowDomNode.attributes; i < atts.length; i++) {
- nodeName = atts[i].nodeName;
- if (nodeName.indexOf("data-") == 0) {
- shadowDomNode.removeAttribute(nodeName);
- }
- }
-
- // set all custom properties
- for (var key in info) {
- if (info.hasOwnProperty(key)) {
- switch (key) {
- case "label":
- case "hint":
- case "role":
- break;
- default:
- shadowDomNode.setAttribute("data-" + key, info[key]);
- }
- }
- }
-
- }
-
- function setText(shadowDomNode, info) {
- if (info && info["label"] && info["label"].length) {
- shadowDomNode.textContent = info["label"];
- }
- }
-
- function appendOrInsert(parent, child, before) {
- var info = child.rave_getProperty(com_ibm_rave_accessibility_AccessibilityConstants.ACCESSIBLE_INFO_KEY);
-
- if (info) {
- var shadowDomNode = child.rave_getProperty(shadowDomNodeKey),
- ps = rave.select(parent.rave_getProperty(shadowDomNodeKey)),
- ul = ps.select("ul");
- if (!shadowDomNode) {
- if (ul.empty()) {
- ul = ps.append("ul");
- }
-
- shadowDomNode = rave_document.createElement("li");
- shadowDomNode[sceneNodeKey] = child;
- child.rave_setProperty(shadowDomNodeKey, shadowDomNode);
-
- setAttributes(shadowDomNode, info);
- setText(shadowDomNode, info);
-
- // recursively add its children
- if (child.rave_hasChildNodes()) {
- var children = child.rave_getChildNodes();
- for (var i = 0; i < children.length; i++) {
- this.onAppend(child, children[i]);
- }
- }
- }
-
- // get the real ul dom node
- ul = ul.node();
-
- if (arguments.length == 3) {
- ul.insertBefore(shadowDomNode, before.rave_getProperty(shadowDomNodeKey));
- } else {
- ul.appendChild(shadowDomNode);
- }
- }
- }
-
- return com_ibm_rave_core_nativeImpl_Declare({
- onAppend : appendOrInsert,
-
- onInsert : appendOrInsert,
-
- onRemove : function(parent, child, index) {
- var shadowDomNode = child[shadowDomNodeKey], newFocus;
- if (shadowDomNode == this._currentFocus) {
- newFocus = shadowDomNode.previousElementSibling;
- if (!newFocus) {
- newFocus = shadowDomNode.nextElementSibling;
- if (!newFocus) {
- // -> ul -> next parent
- newFocus = shadowDomNode.parentNode.parentNode;
- }
- }
- }
-
- this.tearDown(child);
-
- if (newFocus) {
- // select the scene node
- this._focusEventHandler.fireFocus(newFocus[sceneNodeKey]);
- }
- },
-
- onChange : function(domNode) {
- var info = domNode.rave_getProperty(com_ibm_rave_accessibility_AccessibilityConstants.ACCESSIBLE_INFO_KEY),
- shadowDomNode = domNode.rave_getProperty(shadowDomNodeKey);
-
- if (!info) {
- // if no info remove the shadow dom node
- if (shadowDomNode) {
- this.tearDown(domNode);
- }
- } else if (!shadowDomNode) {
- var parentNode = domNode.parentNode;
- if (parentNode) {
- appendOrInsert(parentNode, domNode);
- }
- } else {
- // update attributes
- setAttributes(shadowDomNode, info);
-
- // cannot use #setText because text may be spread across multiple text nodes
- // remove all text nodes
- var childNodes = shadowDomNode.childNodes;
- for (var i = 0; i < childNodes.length; i++) {
- if (childNodes[i].nodeType == 3) {
- shadowDomNode.removeChild(childNodes[i]);
- }
- }
- if (info.label && info.label.length) {
- // add new text node
- shadowDomNode.insertBefore(rave_document.createTextNode(info.label), shadowDomNode.firstChild);
- }
- }
- },
-
- setUp : function(domNode, focusEventHandler) {
- this._focusEventHandler = focusEventHandler;
- var shadowDomNode = domNode[shadowDomNodeKey],
- info = domNode.rave_getProperty(com_ibm_rave_accessibility_AccessibilityConstants.ACCESSIBLE_INFO_KEY);
-
- if (!info) {
- info = {};
- domNode.rave_setProperty(com_ibm_rave_accessibility_AccessibilityConstants.ACCESSIBLE_INFO_KEY, info);
- }
-
- if (!shadowDomNode) {
- shadowDomNode = rave_document.createElement("div");
- shadowDomNode[sceneNodeKey] = domNode;
- shadowDomNode.setAttribute("class", "rave-a11y");
-
- rave.select(shadowDomNode).style({
- "width": 0,
- "height": 0,
- "left": -10000,
- "top": -10000,
- "position": "absolute",
- "overflow": "hidden"
- }, "important");
- domNode.parentNode.insertBefore(shadowDomNode, domNode);
- domNode[shadowDomNodeKey] = shadowDomNode;
-
- setAttributes(shadowDomNode, info);
- setText(shadowDomNode, info);
-
- if (domNode.rave_hasChildNodes()) {
- var children = domNode.rave_getChildNodes();
- for (var i = 0; i < children.length; i++) {
- this.onAppend(domNode, children[i]);
- }
- }
-
- // make the visualization focusable
- this._tabIndex = +domNode.getAttribute("tabindex");
- domNode.removeAttribute("tabindex");
-
- // set the current focus to the root shadow dom node
- this._currentFocus = shadowDomNode;
- this._currentFocus.setAttribute("tabindex", this._tabIndex);
- }
- },
-
- tearDown : function(domNode) {
- shadowDomNode = domNode[shadowDomNodeKey];
-
- if (shadowDomNode) {
- // remove from the DOM
- shadowDomNode.parentNode.removeChild(shadowDomNode);
- // remove stored data from the scene tree
- removeShadowDomNode(domNode);
- }
- },
-
- focus : function(domNode) {
- var shadowDomNode;
- if (domNode) {
- shadowDomNode = domNode[shadowDomNodeKey];
- }
- if (this._currentFocus != shadowDomNode) {
- var refocus = document.activeElement === this._currentFocus;
- if (this._currentFocus) {
- this._currentFocus.removeAttribute("tabindex");
- this._currentFocus.blur();
- }
- if (shadowDomNode) {
- shadowDomNode.setAttribute("tabindex", this._tabIndex);
- if (refocus) {
- shadowDomNode.focus();
- }
- }
- this._currentFocus = shadowDomNode;
- }
- }
- });
- })();
- // $source: com/ibm/rave/accessibility/internal/nativeImpl/AccessibleContext
- /************************************************************************
- ** IBM Confidential
- **
- ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
- **
- ** (C) Copyright IBM Corp. 2014
- **
- ** The source code for this program is not published or otherwise divested of its trade secrets,
- ** irrespective of what has been deposited with the U.S. Copyright Office.
- ************************************************************************/
- // Utility to setup accessible context on a scene node
- // @import ./ShadowDOMBuilder
- var com_ibm_rave_accessibility_internal_nativeImpl_AccessibleContext = {
- getDescription : function(node) {
- return node.getAttribute("aria-label");
- },
-
- setDescription : function(node, description) {
- node.setAttribute("aria-label", description);
- },
-
- createShadowTreeBuilder : function() {
- return new com_ibm_rave_accessibility_internal_nativeImpl_ShadowDOMBuilder();
- }
- };
- // $source: com/ibm/rave/accessibility/navigation/AccessibleNavigation
- /************************************************************************
- ** IBM Confidential
- **
- ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
- **
- ** (C) Copyright IBM Corp. 2015
- **
- ** The source code for this program is not published or otherwise divested of its trade secrets,
- ** irrespective of what has been deposited with the U.S. Copyright Office.
- ************************************************************************/
- // GENERATED
- //@import com/ibm/rave/core/nativeImpl/Declare (loadtime) // declare
- //@import com/ibm/rave/accessibility/navigation/AccessibleKeyboard (runtime) // new
- var com_ibm_rave_accessibility_navigation_AccessibleNavigation = com_ibm_rave_core_nativeImpl_Declare({
- /**
- * Creates a new instance of {@link (com.ibm.rave.accessibility.navigation.AccessibleKeyboard) AccessibleKeyboard} .
- * @return (com.ibm.rave.accessibility.navigation.AccessibleKeyboard) new instance of {@link (com.ibm.rave.accessibility.navigation.AccessibleKeyboard) AccessibleKeyboard}
- */
- /** @expose */
- keyboard : function() {
- return new com_ibm_rave_accessibility_navigation_AccessibleKeyboard();
- }
- //constructor : function() {}
- });
- /** @expose */
- com_ibm_rave_accessibility_navigation_AccessibleNavigation.INSTANCE = new com_ibm_rave_accessibility_navigation_AccessibleNavigation();
- // $source: com/ibm/rave/accessibility/Accessibility
- /************************************************************************
- ** IBM Confidential
- **
- ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
- **
- ** (C) Copyright IBM Corp. 2015
- **
- ** The source code for this program is not published or otherwise divested of its trade secrets,
- ** irrespective of what has been deposited with the U.S. Copyright Office.
- ************************************************************************/
- // GENERATED
- //@import com/ibm/rave/accessibility/internal/AccessibleNavigationSceneNodeExtension (static) // register
- //@import com/ibm/rave/accessibility/internal/AccessibilityUtil (static) // registerSelector
- //@import com/ibm/rave/accessibility/AccessibilityConstants (static) // AccessibilityConstants
- //@import com/ibm/rave/accessibility/navigation/AccessibleNavigation (static) // AccessibleNavigation
- /**
- * The accessibility layer. Provides entry points into functionality provided by the accessibility layer.
- */
- var com_ibm_rave_accessibility_Accessibility = rave_externs["Accessibility"] = {
- //constructor : function() {}
- };
- /**
- * Initialize the Accessibility feature. This needs to be called before using any accessibility features.
- */
- /** @expose */
- com_ibm_rave_accessibility_Accessibility.init = function() {
- com_ibm_rave_accessibility_internal_AccessibleNavigationSceneNodeExtension.register();
- com_ibm_rave_accessibility_internal_AccessibilityUtil.registerSelector();
- };
- /**
- * @see this.AccessibilityConstants#com_ibm_rave_accessibility_AccessibilityConstants.ACCESSIBLE_INFO_KEY
- */
- /** @expose */
- com_ibm_rave_accessibility_Accessibility.ACCESSIBLE_INFO_KEY = com_ibm_rave_accessibility_AccessibilityConstants.ACCESSIBLE_INFO_KEY;
- /**
- * @see this.AccessibilityConstants#com_ibm_rave_accessibility_AccessibilityConstants.SHADOW_TREE_BUILDER_KEY
- */
- /** @expose */
- com_ibm_rave_accessibility_Accessibility.SHADOW_TREE_BUILDER_KEY = com_ibm_rave_accessibility_AccessibilityConstants.SHADOW_TREE_BUILDER_KEY;
- /**
- * @see this.AccessibilityConstants#com_ibm_rave_accessibility_AccessibilityConstants.SELECTOR_ID
- */
- /** @expose */
- com_ibm_rave_accessibility_Accessibility.SELECTOR_ID = com_ibm_rave_accessibility_AccessibilityConstants.SELECTOR_ID;
- /**
- * @see (com.ibm.rave.accessibility.navigation.AccessibleNavigation) AccessibleNavigation
- */
- /** @expose */
- com_ibm_rave_accessibility_Accessibility.navigation = com_ibm_rave_accessibility_navigation_AccessibleNavigation.INSTANCE;
- // $source: com/ibm/rave/accessibility/internal/nativeImpl/Module
- /************************************************************************
- ** IBM Confidential
- **
- ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
- **
- ** (C) Copyright IBM Corp. 2014
- **
- ** The source code for this program is not published or otherwise divested of its trade secrets,
- ** irrespective of what has been deposited with the U.S. Copyright Office.
- ************************************************************************/
- // @OnDemandLoad("rave-accessibility")
- // Must be the first import
- // @import ./ModuleHeader
- // Other module dependencies
- // @import com/ibm/rave/navigation/internal/nativeImpl/Module
- // @import com/ibm/rave/accessibility/Accessibility
- com_ibm_rave_accessibility_Accessibility.init();
- // expose a11y class to the global variable rave
- rave["accessibility"] = com_ibm_rave_accessibility_Accessibility;
- // $source: com/ibm/rave/accessibility/navigation/AccessibleKeyboard
- /************************************************************************
- ** IBM Confidential
- **
- ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
- **
- ** (C) Copyright IBM Corp. 2015
- **
- ** The source code for this program is not published or otherwise divested of its trade secrets,
- ** irrespective of what has been deposited with the U.S. Copyright Office.
- ************************************************************************/
- // GENERATED
- //@import com/ibm/rave/core/nativeImpl/Declare (loadtime) // declare
- //@import com/ibm/rave/navigation/Navigation (runtime) // keybinding
- //@import com/ibm/rave/core/Rave (runtime) // select, Rave
- //@import com/ibm/rave/accessibility/internal/nativeImpl/AccessibleContext (runtime) // createShadowTreeBuilder
- //@import com/ibm/rave/navigation/focus/FocusController (runtime) // nextFocusableNode, nextLevelFocusableNode, previousFocusableNodeFromEnd, previousLevelFocusableNode, nextFocusableNodeFromStart, previousFocusableNode
- //@import com/ibm/rave/accessibility/internal/AccessibilityUtil (runtime) // getShadowTreeBuilder, recursiveSetShadowTreeBuilder, hasAccessibleInfo
- var com_ibm_rave_accessibility_navigation_AccessibleKeyboard = rave_externs["AccessibleKeyboard"] = com_ibm_rave_core_nativeImpl_Declare({
- //kb : null,
- //eventHandler : null,
- //treeBuilder : null,
- //next : null,
- //previous : null,
- //nextStep : null,
- //previousStep : null,
- //first : null,
- //last : null,
- //nextLevel : null,
- //previousLevel : null,
- _$functionClassMethod : function() {
- var _$self = function(args) {
- if (args !== null || arguments.length > 1){
- args = Array.prototype.slice.call(arguments, 0);
- }
- {
- _$self.bind(args[0]);
- return null;
- }
- };
- return _$self;
- },
- constructor : function() {
- this.kb = com_ibm_rave_navigation_Navigation.keybinding();
- this.eventHandler = com_ibm_rave_core_Rave.behavior.focusEventHandler();
- this.treeBuilder = function(data, index, groupIndex) {
- return com_ibm_rave_accessibility_internal_nativeImpl_AccessibleContext.createShadowTreeBuilder();
- };
- {
- var self = this;
- this.next = function(args) {
- if (args !== null || arguments.length > 1){
- args = Array.prototype.slice.call(arguments, 0);
- }
- {
- var focused = self.eventHandler.focusedNode;
- if (focused && !(com_ibm_rave_accessibility_navigation_AccessibleKeyboard.isNavigationRoot(focused))) {
- var nextSibling = focused;
- while ((nextSibling = com_ibm_rave_navigation_focus_FocusController.nextFocusableNode(nextSibling))) {
- if (com_ibm_rave_accessibility_internal_AccessibilityUtil.hasAccessibleInfo(nextSibling)) {
- self.eventHandler.fireFocus(nextSibling);
- break;
- }
- }
- }
- rave.event.preventDefault();
- return null;
- }
- };
- this.previous = function(args) {
- if (args !== null || arguments.length > 1){
- args = Array.prototype.slice.call(arguments, 0);
- }
- {
- var focused = self.eventHandler.focusedNode;
- if (focused && !(com_ibm_rave_accessibility_navigation_AccessibleKeyboard.isNavigationRoot(focused))) {
- var previousSibling = focused;
- while ((previousSibling = com_ibm_rave_navigation_focus_FocusController.previousFocusableNode(previousSibling))) {
- if (com_ibm_rave_accessibility_internal_AccessibilityUtil.hasAccessibleInfo(previousSibling)) {
- self.eventHandler.fireFocus(previousSibling);
- break;
- }
- }
- }
- rave.event.preventDefault();
- return null;
- }
- };
- this.nextStep = function(args) {
- if (args !== null || arguments.length > 1){
- args = Array.prototype.slice.call(arguments, 0);
- }
- {
- var focused = self.eventHandler.focusedNode;
- if (focused && !(com_ibm_rave_accessibility_navigation_AccessibleKeyboard.isNavigationRoot(focused))) {
- var stepCount = 0;
- var nextSibling = focused, temp = focused;
- while (stepCount < 20 && temp) {
- temp = com_ibm_rave_navigation_focus_FocusController.nextFocusableNode(temp);
- if (temp) {
- if (com_ibm_rave_accessibility_internal_AccessibilityUtil.hasAccessibleInfo(temp)) {
- nextSibling = temp;
- stepCount++;
- }
- }
- }
- if (nextSibling != focused) {
- self.eventHandler.fireFocus(nextSibling);
- }
- }
- rave.event.preventDefault();
- return null;
- }
- };
- this.previousStep = function(args) {
- if (args !== null || arguments.length > 1){
- args = Array.prototype.slice.call(arguments, 0);
- }
- {
- var focused = self.eventHandler.focusedNode;
- if (focused && !(com_ibm_rave_accessibility_navigation_AccessibleKeyboard.isNavigationRoot(focused))) {
- var stepCount = 0;
- var previousSibling = focused, temp = focused;
- while (stepCount < 20 && temp) {
- temp = com_ibm_rave_navigation_focus_FocusController.previousFocusableNode(temp);
- if (temp) {
- if (com_ibm_rave_accessibility_internal_AccessibilityUtil.hasAccessibleInfo(temp)) {
- previousSibling = temp;
- stepCount++;
- }
- }
- }
- if (previousSibling != focused) {
- self.eventHandler.fireFocus(previousSibling);
- }
- }
- rave.event.preventDefault();
- return null;
- }
- };
- this.first = function(args) {
- if (args !== null || arguments.length > 1){
- args = Array.prototype.slice.call(arguments, 0);
- }
- {
- var focused = self.eventHandler.focusedNode;
- if (focused && !(com_ibm_rave_accessibility_navigation_AccessibleKeyboard.isNavigationRoot(focused))) {
- var firstNode = com_ibm_rave_navigation_focus_FocusController.nextFocusableNodeFromStart(focused);
- if (!(com_ibm_rave_accessibility_internal_AccessibilityUtil.hasAccessibleInfo(firstNode))) {
- while ((firstNode = com_ibm_rave_navigation_focus_FocusController.nextFocusableNode(firstNode))) {
- if (com_ibm_rave_accessibility_internal_AccessibilityUtil.hasAccessibleInfo(firstNode)) {
- break;
- }
- }
- }
- if (firstNode && focused != firstNode) {
- self.eventHandler.fireFocus(firstNode);
- }
- }
- rave.event.preventDefault();
- return null;
- }
- };
- this.last = function(args) {
- if (args !== null || arguments.length > 1){
- args = Array.prototype.slice.call(arguments, 0);
- }
- {
- var focused = self.eventHandler.focusedNode;
- if (focused && !(com_ibm_rave_accessibility_navigation_AccessibleKeyboard.isNavigationRoot(focused))) {
- var lastNode = com_ibm_rave_navigation_focus_FocusController.previousFocusableNodeFromEnd(focused);
- if (!(com_ibm_rave_accessibility_internal_AccessibilityUtil.hasAccessibleInfo(lastNode))) {
- while ((lastNode = com_ibm_rave_navigation_focus_FocusController.previousFocusableNode(lastNode))) {
- if (com_ibm_rave_accessibility_internal_AccessibilityUtil.hasAccessibleInfo(lastNode)) {
- break;
- }
- }
- }
- if (lastNode && focused != lastNode) {
- self.eventHandler.fireFocus(lastNode);
- }
- }
- rave.event.preventDefault();
- return null;
- }
- };
- this.nextLevel = function(args) {
- if (args !== null || arguments.length > 1){
- args = Array.prototype.slice.call(arguments, 0);
- }
- {
- var focused = self.eventHandler.focusedNode;
- if (focused) {
- if (focused.rave_hasChildNodes()) {
- var child = com_ibm_rave_navigation_focus_FocusController.nextLevelFocusableNode(focused);
- if (!(com_ibm_rave_accessibility_internal_AccessibilityUtil.hasAccessibleInfo(child))) {
- while ((child = com_ibm_rave_navigation_focus_FocusController.nextFocusableNode(child))) {
- if (com_ibm_rave_accessibility_internal_AccessibilityUtil.hasAccessibleInfo(child)) {
- break;
- }
- }
- }
- if (child) {
- self.eventHandler.fireFocus(child);
- }
- }
- }
- rave.event.preventDefault();
- return null;
- }
- };
- this.previousLevel = function(args) {
- if (args !== null || arguments.length > 1){
- args = Array.prototype.slice.call(arguments, 0);
- }
- {
- var focused = self.eventHandler.focusedNode;
- if (focused && !(com_ibm_rave_accessibility_navigation_AccessibleKeyboard.isNavigationRoot(focused))) {
- var parent = com_ibm_rave_navigation_focus_FocusController.previousLevelFocusableNode(focused);
- if (parent) {
- self.eventHandler.fireFocus(parent);
- }
- }
- rave.event.preventDefault();
- return null;
- }
- };
- }
- {
- this.kb.on(40, this.next).on(38, this.previous).on(34, this.nextStep).on(33, this.previousStep).on(36, this.first).on(35, this.last).on(39, this.nextLevel).on(37, this.previousLevel);
- }
- },
- /** @expose */
- bind : function(g) {
- var self = this;
- g.each(function(data, index, groupIndex) {
- var s = com_ibm_rave_core_Rave.select(this);
- var stb = self.treeBuilder.call(this, data, index, groupIndex);
- com_ibm_rave_accessibility_internal_AccessibilityUtil.recursiveSetShadowTreeBuilder(this, stb);
- com_ibm_rave_core_Rave.configuration.extendRecursive(this);
- stb.setUp(this, self.eventHandler);
- s.on("ravefocus", com_ibm_rave_accessibility_navigation_AccessibleKeyboard.FOCUS_LISTENER);
- com_ibm_rave_core_Rave.select(this.rave_getOwner()).call(self.kb);
- s.property(com_ibm_rave_accessibility_navigation_AccessibleKeyboard.NATIVATION_ROOT, true);
- self.eventHandler.focusedNode = this;
- });
- },
- shadowTreeBuilder$0 : function() {
- return this.treeBuilder;
- },
- shadowTreeBuilder$1 : function(shadowTreeBuilder) {
- this.treeBuilder = shadowTreeBuilder;
- return this;
- },
- /** @expose */
- keyBinding : function() {
- return this.kb;
- },
- focusEventHandler$0 : function() {
- return this.eventHandler;
- },
- focusEventHandler$1 : function(handler) {
- this.eventHandler = handler;
- return this;
- },
- /** @expose */
- shadowTreeBuilder : function(a0) {
- var args = arguments;
- if (args.length == 0) {
- return this.shadowTreeBuilder$0();
- }
- return this.shadowTreeBuilder$1(a0);
- },
- /** @expose */
- focusEventHandler : function(a0) {
- var args = arguments;
- if (args.length == 0) {
- return this.focusEventHandler$0();
- }
- return this.focusEventHandler$1(a0);
- }
- });
- com_ibm_rave_accessibility_navigation_AccessibleKeyboard.isNavigationRoot = function(item) {
- return item.rave_getProperty(com_ibm_rave_accessibility_navigation_AccessibleKeyboard.NATIVATION_ROOT) != null;
- };
- com_ibm_rave_accessibility_navigation_AccessibleKeyboard.NATIVATION_ROOT = "__rave-kbnav-root__";
- com_ibm_rave_accessibility_navigation_AccessibleKeyboard.STEP = 20;
- com_ibm_rave_accessibility_navigation_AccessibleKeyboard.FOCUS_LISTENER = function(data, index, groupIndex, event) {
- var stb = com_ibm_rave_accessibility_internal_AccessibilityUtil.getShadowTreeBuilder(event.target);
- if (event.target) {
- stb.focus(event.target);
- } else {
- stb.focus(null);
- }
- };
- })();
|