1 <!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-menu.Manager'>/**
2 </span> * @class Ext.menu.Manager
3 * Provides a common registry of all menus on a page.
6 Ext.define('Ext.menu.Manager', {
9 'Ext.util.MixedCollection',
12 alternateClassName: 'Ext.menu.MenuMgr',
14 uses: ['Ext.menu.Menu'],
24 me.active = Ext.create('Ext.util.MixedCollection');
25 Ext.getDoc().addKeyListener(27, function() {
26 if (me.active.length > 0) {
32 <span id='Ext-menu.Manager-method-hideAll'> /**
33 </span> * Hides all menus that are currently visible
34 * @return {Boolean} success True if any active menus were hidden.
37 var active = this.active,
39 if (active && active.length > 0) {
53 if (active.length < 1) {
54 Ext.getDoc().un('mousedown', me.onMouseDown, me);
63 attached = me.attached,
67 me.lastShow = new Date();
70 Ext.getDoc().on('mousedown', me.onMouseDown, me);
76 onBeforeHide: function(m) {
80 if (m.autoHideTimer) {
81 clearTimeout(m.autoHideTimer);
82 delete m.autoHideTimer;
86 onBeforeShow: function(m) {
87 var active = this.active,
88 parentMenu = m.parentMenu;
91 if (!parentMenu && !m.allowOtherMenus) {
94 else if (parentMenu && parentMenu.activeChild && m != parentMenu.activeChild) {
95 parentMenu.activeChild.hide();
100 onMouseDown: function(e) {
103 lastShow = me.lastShow;
105 if (Ext.Date.getElapsed(lastShow) > 50 && active.length > 0 && !e.getTarget('.' + Ext.baseCSSPrefix + 'menu')) {
111 register: function(menu) {
119 me.menus[menu.id] = menu;
121 beforehide: me.onBeforeHide,
123 beforeshow: me.onBeforeShow,
130 <span id='Ext-menu.Manager-method-get'> /**
131 </span> * Returns a {@link Ext.menu.Menu} object
132 * @param {String/Object} menu The string menu id, an existing menu object reference, or a Menu config that will
133 * be used to generate and return a new Menu this.
134 * @return {Ext.menu.Menu} The specified menu, or null if none are found
136 get: function(menu) {
137 var menus = this.menus;
139 if (typeof menu == 'string') { // menu id
140 if (!menus) { // not initialized, no menus to return
144 } else if (menu.isMenu) { // menu instance
146 } else if (Ext.isArray(menu)) { // array of menu items
147 return Ext.create('Ext.menu.Menu', {items:menu});
148 } else { // otherwise, must be a config
149 return Ext.ComponentManager.create(menu, 'menu');
154 unregister: function(menu) {
159 delete menus[menu.id];
162 beforehide: me.onBeforeHide,
164 beforeshow: me.onBeforeShow,
171 registerCheckable: function(menuItem) {
172 var groups = this.groups,
173 groupId = menuItem.group;
176 if (!groups[groupId]) {
177 groups[groupId] = [];
180 groups[groupId].push(menuItem);
185 unregisterCheckable: function(menuItem) {
186 var groups = this.groups,
187 groupId = menuItem.group;
190 Ext.Array.remove(groups[groupId], menuItem);
194 onCheckChange: function(menuItem, state) {
195 var groups = this.groups,
196 groupId = menuItem.group,
200 if (groupId && state) {
201 group = groups[groupId];
203 for (; i < ln; i++) {
205 if (curr != menuItem) {
206 curr.setChecked(false);
211 });</pre></pre></body></html>