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
8 "./_ComboBoxMenuMixin",
10 ], function(declare, domClass, domStyle, keys,
11 _WidgetBase, _TemplatedMixin, _ComboBoxMenuMixin, _ListMouseMixin){
15 // dijit/form/_ComboBoxMenu
17 return declare("dijit.form._ComboBoxMenu",[_WidgetBase, _TemplatedMixin, _ListMouseMixin, _ComboBoxMenuMixin], {
19 // Focus-less menu for internal use in `dijit/form/ComboBox`
20 // Abstract methods that must be defined externally:
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
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>"
32 baseClass: "dijitComboBoxMenu",
34 postCreate: function(){
35 this.inherited(arguments);
36 if(!this.isLeftToRight()){
37 domClass.add(this.previousButton, "dijitMenuItemRtl");
38 domClass.add(this.nextButton, "dijitMenuItemRtl");
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");
50 onHover: function(/*DomNode*/ node){
53 domClass.add(node, "dijitMenuItemHover");
56 onUnhover: function(/*DomNode*/ node){
59 domClass.remove(node, "dijitMenuItemHover");
62 onSelect: function(/*DomNode*/ node){
65 domClass.add(node, "dijitMenuItemSelected");
68 onDeselect: function(/*DomNode*/ node){
70 // Remove selected CSS
71 domClass.remove(node, "dijitMenuItemSelected");
74 _page: function(/*Boolean*/ up){
76 // Handles page-up and page-down keypresses
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();
85 while(scrollamount<height){
86 var highlighted_option = this.getHighlightedOption();
89 if(!highlighted_option.previousSibling ||
90 highlighted_option.previousSibling.style.display == "none"){
93 this.selectPreviousNode();
95 // stop at last option
96 if(!highlighted_option.nextSibling ||
97 highlighted_option.nextSibling.style.display == "none"){
100 this.selectNextNode();
103 var newscroll = this.domNode.scrollTop;
104 scrollamount += (newscroll-oldscroll)*(up ? -1:1);
105 oldscroll = newscroll;
109 handleKey: function(evt){
111 // Handle keystroke event forwarded from ComboBox, returning false if it's
112 // a keystroke I recognize and process, true otherwise.
114 case keys.DOWN_ARROW:
115 this.selectNextNode();
121 this.selectPreviousNode();