source: Dev/trunk/src/client/dijit/MenuBar.js @ 485

Last change on this file since 485 was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 2.4 KB
Line 
1define([
2        "dojo/_base/declare", // declare
3        "dojo/keys", // keys.DOWN_ARROW
4        "./_MenuBase",
5        "dojo/text!./templates/MenuBar.html"
6], function(declare, keys, _MenuBase, template){
7
8        // module:
9        //              dijit/MenuBar
10
11        return declare("dijit.MenuBar", _MenuBase, {
12                // summary:
13                //              A menu bar, listing menu choices horizontally, like the "File" menu in most desktop applications
14
15                templateString: template,
16
17                baseClass: "dijitMenuBar",
18
19                // By default open popups for MenuBar instantly
20                popupDelay: 0,
21
22                // _isMenuBar: [protected] Boolean
23                //              This is a MenuBar widget, not a (vertical) Menu widget.
24                _isMenuBar: true,
25
26                // parameter to dijit.popup.open() about where to put popup (relative to this.domNode)
27                _orient: ["below"],
28
29                _moveToPopup: function(/*Event*/ evt){
30                        // summary:
31                        //              This handles the down arrow key, opening a submenu if one exists.
32                        //              Unlike _MenuBase._moveToPopup(), will never move to the next item in the MenuBar.
33                        // tags:
34                        //              private
35
36                        if(this.focusedChild && this.focusedChild.popup && !this.focusedChild.disabled){
37                                this.onItemClick(this.focusedChild, evt);
38                        }
39                },
40
41                focusChild: function(item){
42                        // Overload focusChild so that whenever a new item is focused and the menu is active, open its submenu immediately.
43
44                        this.inherited(arguments);
45                        if(this.activated && item.popup && !item.disabled){
46                                this._openItemPopup(item, true);
47                        }
48                },
49
50                _onChildDeselect: function(item){
51                        // override _MenuBase._onChildDeselect() to close submenu immediately
52
53                        if(this.currentPopupItem == item){
54                                this.currentPopupItem = null;
55                                item._closePopup(); // this calls onClose
56                        }
57
58                        this.inherited(arguments);
59                },
60
61                // Arrow key navigation
62                _onLeftArrow: function(){
63                        this.focusPrev();
64                },
65                _onRightArrow: function(){
66                        this.focusNext();
67                },
68                _onDownArrow: function(/*Event*/ evt){
69                        this._moveToPopup(evt);
70                },
71                _onUpArrow: function(){
72                },
73
74                onItemClick: function(/*dijit/_WidgetBase*/ item, /*Event*/ evt){
75                        // summary:
76                        //              Handle clicks on an item.   Also called by _moveToPopup() due to a down-arrow key on the item.
77                        //              Cancels a dropdown if already open and click is either mouse or space/enter.
78                        //              Don't close dropdown due to down arrow.
79                        // tags:
80                        //              private
81                        if(item.popup && item.popup.isShowingNow && (!/^key/.test(evt.type) || evt.keyCode !== keys.DOWN_ARROW)){
82                                item.focusNode.focus();
83                                this._cleanUp(true);
84                        }else{
85                                this.inherited(arguments);
86                        }
87                }
88        });
89});
Note: See TracBrowser for help on using the repository browser.