forked from dojo/dijit-oldmirror
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDropDownMenu.js
59 lines (51 loc) · 1.35 KB
/
DropDownMenu.js
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
define([
"dojo/_base/declare", // declare
"dojo/keys", // keys
"dojo/text!./templates/Menu.html",
"./_OnDijitClickMixin",
"./_MenuBase"
], function(declare, keys, template, _OnDijitClickMixin, _MenuBase){
// module:
// dijit/DropDownMenu
return declare("dijit.DropDownMenu", [_MenuBase, _OnDijitClickMixin], {
// summary:
// A menu, without features for context menu (Meaning, drop down menu)
templateString: template,
baseClass: "dijitMenu",
postCreate: function(){
this.inherited(arguments);
var l = this.isLeftToRight();
this._openSubMenuKey = l ? keys.RIGHT_ARROW : keys.LEFT_ARROW;
this._closeSubMenuKey = l ? keys.LEFT_ARROW : keys.RIGHT_ARROW;
this.connectKeyNavHandlers([keys.UP_ARROW], [keys.DOWN_ARROW]);
},
_onKeyDown: function(/*Event*/ evt){
// summary:
// Handle keyboard based menu navigation.
// tags:
// protected
if(evt.ctrlKey || evt.altKey){
return;
}
switch(evt.keyCode){
case this._openSubMenuKey:
this._moveToPopup(evt);
evt.stopPropagation();
evt.preventDefault();
break;
case this._closeSubMenuKey:
if(this.parentMenu){
if(this.parentMenu._isMenuBar){
this.parentMenu.focusPrev();
}else{
this.onCancel(false);
}
}else{
evt.stopPropagation();
evt.preventDefault();
}
break;
}
}
});
});