]> git.wh0rd.org - tt-rss.git/blob - lib/dijit/MenuBar.js.uncompressed.js
upgrade dojo to 1.8.3 (refs #570)
[tt-rss.git] / lib / dijit / MenuBar.js.uncompressed.js
1 require({cache:{
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
7 "./_MenuBase",
8 "dojo/text!./templates/MenuBar.html"
9 ], function(declare, event, keys, _MenuBase, template){
10
11 // module:
12 // dijit/MenuBar
13
14 return declare("dijit.MenuBar", _MenuBase, {
15 // summary:
16 // A menu bar, listing menu choices horizontally, like the "File" menu in most desktop applications
17
18 templateString: template,
19
20 baseClass: "dijitMenuBar",
21
22 // _isMenuBar: [protected] Boolean
23 // This is a MenuBar widget, not a (vertical) Menu widget.
24 _isMenuBar: true,
25
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]
32 );
33
34 // parameter to dijit.popup.open() about where to put popup (relative to this.domNode)
35 this._orient = ["below"];
36 },
37
38 _moveToPopup: function(/*Event*/ evt){
39 // summary:
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.
42 // tags:
43 // private
44
45 if(this.focusedChild && this.focusedChild.popup && !this.focusedChild.disabled){
46 this.onItemClick(this.focusedChild, evt);
47 }
48 },
49
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()
59 }
60 },
61
62 _onKeyPress: function(/*Event*/ evt){
63 // summary:
64 // Handle keyboard based menu navigation.
65 // tags:
66 // protected
67
68 if(evt.ctrlKey || evt.altKey){ return; }
69
70 switch(evt.charOrCode){
71 case keys.DOWN_ARROW:
72 this._moveToPopup(evt);
73 event.stop(evt);
74 }
75 },
76
77 onItemClick: function(/*dijit/_WidgetBase*/ item, /*Event*/ evt){
78 // summary:
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.
82 // tags:
83 // private
84 if(item.popup && item.popup.isShowingNow && (evt.type !== "keypress" || evt.keyCode !== keys.DOWN_ARROW)){
85 item.popup.onCancel();
86 }else{
87 this.inherited(arguments);
88 }
89 }
90 });
91
92 });