]> git.wh0rd.org - tt-rss.git/blob - lib/dijit/MenuBar.js.uncompressed.js
update dojo to 1.7.3
[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 /*=====
12 var _MenuBase = dijit._MenuBase;
13 =====*/
14
15 // module:
16 // dijit/MenuBar
17 // summary:
18 // A menu bar, listing menu choices horizontally, like the "File" menu in most desktop applications
19
20 return declare("dijit.MenuBar", _MenuBase, {
21 // summary:
22 // A menu bar, listing menu choices horizontally, like the "File" menu in most desktop applications
23
24 templateString: template,
25
26 baseClass: "dijitMenuBar",
27
28 // _isMenuBar: [protected] Boolean
29 // This is a MenuBar widget, not a (vertical) Menu widget.
30 _isMenuBar: true,
31
32 postCreate: function(){
33 var l = this.isLeftToRight();
34 this.connectKeyNavHandlers(
35 l ? [keys.LEFT_ARROW] : [keys.RIGHT_ARROW],
36 l ? [keys.RIGHT_ARROW] : [keys.LEFT_ARROW]
37 );
38
39 // parameter to dijit.popup.open() about where to put popup (relative to this.domNode)
40 this._orient = ["below"];
41 },
42
43 focusChild: function(item){
44 // overload focusChild so that whenever the focus is moved to a new item,
45 // check the previous focused whether it has its popup open, if so, after
46 // focusing the new item, open its submenu immediately
47 var prev_item = this.focusedChild,
48 showpopup = prev_item && prev_item.popup && prev_item.popup.isShowingNow;
49 this.inherited(arguments);
50 if(showpopup && item.popup && !item.disabled){
51 this._openPopup(); // TODO: on down arrow, _openPopup() is called here and in onItemClick()
52 }
53 },
54
55 _onKeyPress: function(/*Event*/ evt){
56 // summary:
57 // Handle keyboard based menu navigation.
58 // tags:
59 // protected
60
61 if(evt.ctrlKey || evt.altKey){ return; }
62
63 switch(evt.charOrCode){
64 case keys.DOWN_ARROW:
65 this._moveToPopup(evt);
66 event.stop(evt);
67 }
68 },
69
70 onItemClick: function(/*dijit._Widget*/ item, /*Event*/ evt){
71 // summary:
72 // Handle clicks on an item. Cancels a dropdown if already open.
73 // tags:
74 // private
75 if(item.popup && item.popup.isShowingNow){
76 item.popup.onCancel();
77 }else{
78 this.inherited(arguments);
79 }
80 }
81 });
82
83 });