[Extensions] Make extension message bubble factory platform-abstract
[chromium-blink-merge.git] / chrome / browser / resources / chromeos / chromevox / common / earcon_util.js
blobc938d9b7d7c861356bd46a1fb132bbe693a68202
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.
5 /**
6 * @fileoverview Earcon utils.
7 */
9 goog.provide('cvox.EarconUtil');
11 goog.require('cvox.AbstractEarcons');
12 goog.require('cvox.AriaUtil');
13 goog.require('cvox.DomUtil');
15 /**
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);
23 if (earcon != null) {
24 return earcon;
27 switch (node.tagName) {
28 case 'BUTTON':
29 return cvox.AbstractEarcons.BUTTON;
30 case 'A':
31 if (node.hasAttribute('href')) {
32 return cvox.AbstractEarcons.LINK;
34 break;
35 case 'IMG':
36 if (cvox.DomUtil.hasLongDesc(node)) {
37 return cvox.AbstractEarcons.LONG_DESC;
39 break;
40 case 'LI':
41 return cvox.AbstractEarcons.LIST_ITEM;
42 case 'SELECT':
43 return cvox.AbstractEarcons.LISTBOX;
44 case 'TEXTAREA':
45 return cvox.AbstractEarcons.EDITABLE_TEXT;
46 case 'INPUT':
47 switch (node.type) {
48 case 'button':
49 case 'submit':
50 case 'reset':
51 return cvox.AbstractEarcons.BUTTON;
52 case 'checkbox':
53 case 'radio':
54 if (node.checked) {
55 return cvox.AbstractEarcons.CHECK_ON;
56 } else {
57 return cvox.AbstractEarcons.CHECK_OFF;
59 default:
60 if (cvox.DomUtil.isInputTypeText(node)) {
61 // 'text', 'password', etc.
62 return cvox.AbstractEarcons.EDITABLE_TEXT;
66 return null;