]>
git.wh0rd.org - tt-rss.git/blob - lib/dijit/MenuBar.js.uncompressed.js
2 'url:dijit/templates/MenuBar.html':"<div class=\"dijitMenuBar dijitMenuPassive\" data-dojo-attach-point=\"containerNode\" role=\"menubar\" tabIndex=\"${tabIndex}\" data-dojo-attach-event=\"onkeypress: _onKeyPress\"></div>\n"}});
3 define("dijit/MenuBar", [
4 "dojo/_base/declare", // declare
5 "dojo/_base/event", // event.stop
6 "dojo/keys", // keys.DOWN_ARROW
8 "dojo/text!./templates/MenuBar.html"
9 ], function(declare
, event
, keys
, _MenuBase
, template
){
14 return declare("dijit.MenuBar", _MenuBase
, {
16 // A menu bar, listing menu choices horizontally, like the "File" menu in most desktop applications
18 templateString
: template
,
20 baseClass
: "dijitMenuBar",
22 // _isMenuBar: [protected] Boolean
23 // This is a MenuBar widget, not a (vertical) Menu widget.
26 postCreate: function(){
27 this.inherited(arguments
);
28 var l
= this.isLeftToRight();
29 this.connectKeyNavHandlers(
30 l
? [keys
.LEFT_ARROW
] : [keys
.RIGHT_ARROW
],
31 l
? [keys
.RIGHT_ARROW
] : [keys
.LEFT_ARROW
]
34 // parameter to dijit.popup.open() about where to put popup (relative to this.domNode)
35 this._orient
= ["below"];
38 _moveToPopup: function(/*Event*/ evt
){
40 // This handles the down arrow key, opening a submenu if one exists.
41 // Unlike _MenuBase._moveToPopup(), will never move to the next item in the MenuBar.
45 if(this.focusedChild
&& this.focusedChild
.popup
&& !this.focusedChild
.disabled
){
46 this.onItemClick(this.focusedChild
, evt
);
50 focusChild: function(item
){
51 // overload focusChild so that whenever the focus is moved to a new item,
52 // check the previous focused whether it has its popup open, if so, after
53 // focusing the new item, open its submenu immediately
54 var prev_item
= this.focusedChild
,
55 showpopup
= prev_item
&& prev_item
.popup
&& prev_item
.popup
.isShowingNow
;
56 this.inherited(arguments
);
57 if(showpopup
&& item
.popup
&& !item
.disabled
){
58 this._openPopup(true); // TODO: on down arrow, _openPopup() is called here and in onItemClick()
62 _onKeyPress: function(/*Event*/ evt
){
64 // Handle keyboard based menu navigation.
68 if(evt
.ctrlKey
|| evt
.altKey
){ return; }
70 switch(evt
.charOrCode
){
72 this._moveToPopup(evt
);
77 onItemClick: function(/*dijit/_WidgetBase*/ item, /*Event*/ evt
){
79 // Handle clicks on an item. Also called by _moveToPopup() due to a down-arrow key on the item.
80 // Cancels a dropdown if already open and click is either mouse or space/enter.
81 // Don't close dropdown due to down arrow.
84 if(item
.popup
&& item
.popup
.isShowingNow
&& (evt
.type
!== "keypress" || evt
.keyCode
!== keys
.DOWN_ARROW
)){
85 item
.popup
.onCancel();
87 this.inherited(arguments
);