Web UI for ARGUS server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

216 lines
6.0 KiB

6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>The source code</title>
  5. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  6. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  7. </head>
  8. <body onload="prettyPrint();">
  9. <pre class="prettyprint lang-js">/*!
  10. * Ext JS Library 3.3.1
  11. * Copyright(c) 2006-2010 Sencha Inc.
  12. * licensing@sencha.com
  13. * http://www.sencha.com/license
  14. */
  15. <div id="cls-Ext.menu.MenuMgr"></div>/**
  16. * @class Ext.menu.MenuMgr
  17. * Provides a common registry of all menu items on a page so that they can be easily accessed by id.
  18. * @singleton
  19. */
  20. Ext.menu.MenuMgr = function(){
  21. var menus, active, groups = {}, attached = false, lastShow = new Date();
  22. // private - called when first menu is created
  23. function init(){
  24. menus = {};
  25. active = new Ext.util.MixedCollection();
  26. Ext.getDoc().addKeyListener(27, function(){
  27. if(active.length > 0){
  28. hideAll();
  29. }
  30. });
  31. }
  32. // private
  33. function hideAll(){
  34. if(active && active.length > 0){
  35. var c = active.clone();
  36. c.each(function(m){
  37. m.hide();
  38. });
  39. return true;
  40. }
  41. return false;
  42. }
  43. // private
  44. function onHide(m){
  45. active.remove(m);
  46. if(active.length < 1){
  47. Ext.getDoc().un("mousedown", onMouseDown);
  48. attached = false;
  49. }
  50. }
  51. // private
  52. function onShow(m){
  53. var last = active.last();
  54. lastShow = new Date();
  55. active.add(m);
  56. if(!attached){
  57. Ext.getDoc().on("mousedown", onMouseDown);
  58. attached = true;
  59. }
  60. if(m.parentMenu){
  61. m.getEl().setZIndex(parseInt(m.parentMenu.getEl().getStyle("z-index"), 10) + 3);
  62. m.parentMenu.activeChild = m;
  63. }else if(last && !last.isDestroyed && last.isVisible()){
  64. m.getEl().setZIndex(parseInt(last.getEl().getStyle("z-index"), 10) + 3);
  65. }
  66. }
  67. // private
  68. function onBeforeHide(m){
  69. if(m.activeChild){
  70. m.activeChild.hide();
  71. }
  72. if(m.autoHideTimer){
  73. clearTimeout(m.autoHideTimer);
  74. delete m.autoHideTimer;
  75. }
  76. }
  77. // private
  78. function onBeforeShow(m){
  79. var pm = m.parentMenu;
  80. if(!pm && !m.allowOtherMenus){
  81. hideAll();
  82. }else if(pm && pm.activeChild){
  83. pm.activeChild.hide();
  84. }
  85. }
  86. // private
  87. function onMouseDown(e){
  88. if(lastShow.getElapsed() > 50 && active.length > 0 && !e.getTarget(".x-menu")){
  89. hideAll();
  90. }
  91. }
  92. return {
  93. <div id="method-Ext.menu.MenuMgr-hideAll"></div>/**
  94. * Hides all menus that are currently visible
  95. * @return {Boolean} success True if any active menus were hidden.
  96. */
  97. hideAll : function(){
  98. return hideAll();
  99. },
  100. // private
  101. register : function(menu){
  102. if(!menus){
  103. init();
  104. }
  105. menus[menu.id] = menu;
  106. menu.on({
  107. beforehide: onBeforeHide,
  108. hide: onHide,
  109. beforeshow: onBeforeShow,
  110. show: onShow
  111. });
  112. },
  113. <div id="method-Ext.menu.MenuMgr-get"></div>/**
  114. * Returns a {@link Ext.menu.Menu} object
  115. * @param {String/Object} menu The string menu id, an existing menu object reference, or a Menu config that will
  116. * be used to generate and return a new Menu instance.
  117. * @return {Ext.menu.Menu} The specified menu, or null if none are found
  118. */
  119. get : function(menu){
  120. if(typeof menu == "string"){ // menu id
  121. if(!menus){ // not initialized, no menus to return
  122. return null;
  123. }
  124. return menus[menu];
  125. }else if(menu.events){ // menu instance
  126. return menu;
  127. }else if(typeof menu.length == 'number'){ // array of menu items?
  128. return new Ext.menu.Menu({items:menu});
  129. }else{ // otherwise, must be a config
  130. return Ext.create(menu, 'menu');
  131. }
  132. },
  133. // private
  134. unregister : function(menu){
  135. delete menus[menu.id];
  136. menu.un("beforehide", onBeforeHide);
  137. menu.un("hide", onHide);
  138. menu.un("beforeshow", onBeforeShow);
  139. menu.un("show", onShow);
  140. },
  141. // private
  142. registerCheckable : function(menuItem){
  143. var g = menuItem.group;
  144. if(g){
  145. if(!groups[g]){
  146. groups[g] = [];
  147. }
  148. groups[g].push(menuItem);
  149. }
  150. },
  151. // private
  152. unregisterCheckable : function(menuItem){
  153. var g = menuItem.group;
  154. if(g){
  155. groups[g].remove(menuItem);
  156. }
  157. },
  158. // private
  159. onCheckChange: function(item, state){
  160. if(item.group && state){
  161. var group = groups[item.group],
  162. i = 0,
  163. len = group.length,
  164. current;
  165. for(; i < len; i++){
  166. current = group[i];
  167. if(current != item){
  168. current.setChecked(false);
  169. }
  170. }
  171. }
  172. },
  173. getCheckedItem : function(groupId){
  174. var g = groups[groupId];
  175. if(g){
  176. for(var i = 0, l = g.length; i < l; i++){
  177. if(g[i].checked){
  178. return g[i];
  179. }
  180. }
  181. }
  182. return null;
  183. },
  184. setCheckedItem : function(groupId, itemId){
  185. var g = groups[groupId];
  186. if(g){
  187. for(var i = 0, l = g.length; i < l; i++){
  188. if(g[i].id == itemId){
  189. g[i].setChecked(true);
  190. }
  191. }
  192. }
  193. return null;
  194. }
  195. };
  196. }();
  197. </pre>
  198. </body>
  199. </html>