Debian Codegraph @

dijit/form/ComboButton.js

raw symbols SCIP
1 define([
2 "dojo/_base/declare", // declare
3 "dojo/keys", // keys
4 "../focus", // focus.focus()
5 "./DropDownButton",
6 "dojo/text!./templates/ComboButton.html",
7 "../a11yclick" // template uses ondijitclick
8 ], function(declare, keys, focus, DropDownButton, template){
9
10 // module:
11 // dijit/form/ComboButton
12
13 return declare("dijit.form.ComboButton", DropDownButton, {
14 // summary:
15 // A combination button and drop-down button.
16 // Users can click one side to "press" the button, or click an arrow
17 // icon to display the drop down.
18 //
19 // example:
20 // | <button data-dojo-type="dijit/form/ComboButton" onClick="...">
21 // | <span>Hello world</span>
22 // | <div data-dojo-type="dijit/Menu">...</div>
23 // | </button>
24 //
25 // example:
26 // | var button1 = new ComboButton({label: "hello world", onClick: foo, dropDown: "myMenu"});
27 // | dojo.body().appendChild(button1.domNode);
28 //
29
30 templateString: template,
31
32 // Map widget attributes to DOMNode attributes.
33 _setIdAttr: "", // override _FormWidgetMixin which puts id on the focusNode
34 _setTabIndexAttr: ["focusNode", "titleNode"],
35 _setTitleAttr: "titleNode",
36
37 // optionsTitle: String
38 // Text that describes the options menu (accessibility)
39 optionsTitle: "",
40
41 baseClass: "dijitComboButton",
42
43 // Set classes like dijitButtonContentsHover or dijitArrowButtonActive depending on
44 // mouse action over specified node
45 cssStateNodes: {
46 "buttonNode": "dijitButtonNode",
47 "titleNode": "dijitButtonContents",
48 "_popupStateNode": "dijitDownArrowButton"
49 },
50
51 _focusedNode: null,
52
53 _onButtonKeyDown: function(/*Event*/ evt){
54 // summary:
55 // Handler for right arrow key when focus is on left part of button
56 if(evt.keyCode == keys[this.isLeftToRight() ? "RIGHT_ARROW" : "LEFT_ARROW"]){
57 focus.focus(this._popupStateNode);
58 evt.stopPropagation();
59 evt.preventDefault();
60 }
61 },
62
63 _onArrowKeyDown: function(/*Event*/ evt){
64 // summary:
65 // Handler for left arrow key when focus is on right part of button
66 if(evt.keyCode == keys[this.isLeftToRight() ? "LEFT_ARROW" : "RIGHT_ARROW"]){
67 focus.focus(this.titleNode);
68 evt.stopPropagation();
69 evt.preventDefault();
70 }
71 },
72
73 focus: function(/*String*/ position){
74 // summary:
75 // Focuses this widget to according to position, if specified,
76 // otherwise on arrow node
77 // position:
78 // "start" or "end"
79 if(!this.disabled){
80 focus.focus(position == "start" ? this.titleNode : this._popupStateNode);
81 }
82 }
83 });
84 });