1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 * @fileoverview Earcon utils.
9 goog.provide('cvox.EarconUtil');
11 goog.require('cvox.AbstractEarcons');
12 goog.require('cvox.AriaUtil');
13 goog.require('cvox.DomUtil');
16 * Returns the id of an earcon to play along with the description for a node.
18 * @param {Node} node The node to get the earcon for.
19 * @return {number?} The earcon id, or null if none applies.
21 cvox.EarconUtil.getEarcon = function(node) {
22 var earcon = cvox.AriaUtil.getEarcon(node);
27 switch (node.tagName) {
29 return cvox.AbstractEarcons.BUTTON;
31 if (node.hasAttribute('href')) {
32 return cvox.AbstractEarcons.LINK;
36 if (cvox.DomUtil.hasLongDesc(node)) {
37 return cvox.AbstractEarcons.LONG_DESC;
41 return cvox.AbstractEarcons.LIST_ITEM;
43 return cvox.AbstractEarcons.LISTBOX;
45 return cvox.AbstractEarcons.EDITABLE_TEXT;
51 return cvox.AbstractEarcons.BUTTON;
55 return cvox.AbstractEarcons.CHECK_ON;
57 return cvox.AbstractEarcons.CHECK_OFF;
60 if (cvox.DomUtil.isInputTypeText(node)) {
61 // 'text', 'password', etc.
62 return cvox.AbstractEarcons.EDITABLE_TEXT;