]> git.wh0rd.org - tt-rss.git/blob - lib/dijit/form/_ComboBoxMenu.js.uncompressed.js
modify dojo rebuild script to remove uncompressed files
[tt-rss.git] / lib / dijit / form / _ComboBoxMenu.js.uncompressed.js
1 define("dijit/form/_ComboBoxMenu", [
2 "dojo/_base/declare", // declare
3 "dojo/dom-class", // domClass.add domClass.remove
4 "dojo/dom-style", // domStyle.get
5 "dojo/keys", // keys.DOWN_ARROW keys.PAGE_DOWN keys.PAGE_UP keys.UP_ARROW
6 "../_WidgetBase",
7 "../_TemplatedMixin",
8 "./_ComboBoxMenuMixin",
9 "./_ListMouseMixin"
10 ], function(declare, domClass, domStyle, keys,
11 _WidgetBase, _TemplatedMixin, _ComboBoxMenuMixin, _ListMouseMixin){
12
13
14 // module:
15 // dijit/form/_ComboBoxMenu
16
17 return declare("dijit.form._ComboBoxMenu",[_WidgetBase, _TemplatedMixin, _ListMouseMixin, _ComboBoxMenuMixin], {
18 // summary:
19 // Focus-less menu for internal use in `dijit/form/ComboBox`
20 // Abstract methods that must be defined externally:
21 //
22 // - onChange: item was explicitly chosen (mousedown somewhere on the menu and mouseup somewhere on the menu)
23 // - onPage: next(1) or previous(-1) button pressed
24 // tags:
25 // private
26
27 templateString: "<div class='dijitReset dijitMenu' data-dojo-attach-point='containerNode' style='overflow: auto; overflow-x: hidden;' role='listbox'>"
28 +"<div class='dijitMenuItem dijitMenuPreviousButton' data-dojo-attach-point='previousButton' role='option'></div>"
29 +"<div class='dijitMenuItem dijitMenuNextButton' data-dojo-attach-point='nextButton' role='option'></div>"
30 +"</div>",
31
32 baseClass: "dijitComboBoxMenu",
33
34 postCreate: function(){
35 this.inherited(arguments);
36 if(!this.isLeftToRight()){
37 domClass.add(this.previousButton, "dijitMenuItemRtl");
38 domClass.add(this.nextButton, "dijitMenuItemRtl");
39 }
40 },
41
42 _createMenuItem: function(){
43 // note: not using domConstruct.create() because need to specify document
44 var item = this.ownerDocument.createElement("div");
45 item.className = "dijitReset dijitMenuItem" +(this.isLeftToRight() ? "" : " dijitMenuItemRtl");
46 item.setAttribute("role", "option");
47 return item;
48 },
49
50 onHover: function(/*DomNode*/ node){
51 // summary:
52 // Add hover CSS
53 domClass.add(node, "dijitMenuItemHover");
54 },
55
56 onUnhover: function(/*DomNode*/ node){
57 // summary:
58 // Remove hover CSS
59 domClass.remove(node, "dijitMenuItemHover");
60 },
61
62 onSelect: function(/*DomNode*/ node){
63 // summary:
64 // Add selected CSS
65 domClass.add(node, "dijitMenuItemSelected");
66 },
67
68 onDeselect: function(/*DomNode*/ node){
69 // summary:
70 // Remove selected CSS
71 domClass.remove(node, "dijitMenuItemSelected");
72 },
73
74 _page: function(/*Boolean*/ up){
75 // summary:
76 // Handles page-up and page-down keypresses
77
78 var scrollamount = 0;
79 var oldscroll = this.domNode.scrollTop;
80 var height = domStyle.get(this.domNode, "height");
81 // if no item is highlighted, highlight the first option
82 if(!this.getHighlightedOption()){
83 this.selectNextNode();
84 }
85 while(scrollamount<height){
86 var highlighted_option = this.getHighlightedOption();
87 if(up){
88 // stop at option 1
89 if(!highlighted_option.previousSibling ||
90 highlighted_option.previousSibling.style.display == "none"){
91 break;
92 }
93 this.selectPreviousNode();
94 }else{
95 // stop at last option
96 if(!highlighted_option.nextSibling ||
97 highlighted_option.nextSibling.style.display == "none"){
98 break;
99 }
100 this.selectNextNode();
101 }
102 // going backwards
103 var newscroll = this.domNode.scrollTop;
104 scrollamount += (newscroll-oldscroll)*(up ? -1:1);
105 oldscroll = newscroll;
106 }
107 },
108
109 handleKey: function(evt){
110 // summary:
111 // Handle keystroke event forwarded from ComboBox, returning false if it's
112 // a keystroke I recognize and process, true otherwise.
113 switch(evt.keyCode){
114 case keys.DOWN_ARROW:
115 this.selectNextNode();
116 return false;
117 case keys.PAGE_DOWN:
118 this._page(false);
119 return false;
120 case keys.UP_ARROW:
121 this.selectPreviousNode();
122 return false;
123 case keys.PAGE_UP:
124 this._page(true);
125 return false;
126 default:
127 return true;
128 }
129 }
130 });
131 });