summaryrefslogtreecommitdiff
path: root/chromium/chrome/browser/resources/chromeos/chromevox/chromevox/injected/ui/node_search_widget.js
blob: 93adad76da48cd20600c6b7f3ce06e05f73d3ab5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/**
 * @fileoverview A search Widget presenting a list of nodes with the ability
 * to sync selection when chosen.
 */

goog.provide('cvox.NodeSearchWidget');

goog.require('cvox.ChromeVox');
goog.require('cvox.DomUtil');
goog.require('cvox.SearchWidget');


/**
 * @constructor
 * @param {string} typeMsg A message id identifying the type of items
 * contained in the list.
 * @param {?function(Array<Node>)} predicate A predicate; if null, no predicate
 * applies.
 * @extends {cvox.SearchWidget}
 */
cvox.NodeSearchWidget = function(typeMsg, predicate) {
  this.typeMsg_ = typeMsg;
  this.predicate_ = predicate;
  goog.base(this);
};
goog.inherits(cvox.NodeSearchWidget, cvox.SearchWidget);


/**
 * @override
 */
cvox.NodeSearchWidget.prototype.getNameMsg = function() {
  return ['choice_widget_name', [Msgs.getMsg(this.typeMsg_)]];
};


/**
 * @override
 */
cvox.NodeSearchWidget.prototype.getHelpMsg = function() {
  return 'choice_widget_help';
};


/**
 * @override
 */
cvox.NodeSearchWidget.prototype.getPredicate = function() {
  return this.predicate_;
};


/**
 * Shows a list generated dynamic satisfying some predicate.
 * @param {string} typeMsg The message id of the type contained in nodes.
 * @param {function(Array<Node>)} predicate The predicate.
 * @return {cvox.NodeSearchWidget} The widget.
 */
cvox.NodeSearchWidget.create = function(typeMsg, predicate) {
  return new cvox.NodeSearchWidget(typeMsg, predicate);
};