Web Interface For Lite Argus Control modules
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.

233 lines
8.1 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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.Item"></div>/**
  16. * @class Ext.menu.Item
  17. * @extends Ext.menu.BaseItem
  18. * A base class for all menu items that require menu-related functionality (like sub-menus) and are not static
  19. * display items. Item extends the base functionality of {@link Ext.menu.BaseItem} by adding menu-specific
  20. * activation and click handling.
  21. * @constructor
  22. * Creates a new Item
  23. * @param {Object} config Configuration options
  24. * @xtype menuitem
  25. */
  26. Ext.menu.Item = Ext.extend(Ext.menu.BaseItem, {
  27. <div id="prop-Ext.menu.Item-menu"></div>/**
  28. * @property menu
  29. * @type Ext.menu.Menu
  30. * The submenu associated with this Item if one was configured.
  31. */
  32. <div id="cfg-Ext.menu.Item-menu"></div>/**
  33. * @cfg {Mixed} menu (optional) Either an instance of {@link Ext.menu.Menu} or the config object for an
  34. * {@link Ext.menu.Menu} which acts as the submenu when this item is activated.
  35. */
  36. <div id="cfg-Ext.menu.Item-icon"></div>/**
  37. * @cfg {String} icon The path to an icon to display in this item (defaults to Ext.BLANK_IMAGE_URL). If
  38. * icon is specified {@link #iconCls} should not be.
  39. */
  40. <div id="cfg-Ext.menu.Item-iconCls"></div>/**
  41. * @cfg {String} iconCls A CSS class that specifies a background image that will be used as the icon for
  42. * this item (defaults to ''). If iconCls is specified {@link #icon} should not be.
  43. */
  44. <div id="cfg-Ext.menu.Item-text"></div>/**
  45. * @cfg {String} text The text to display in this item (defaults to '').
  46. */
  47. <div id="cfg-Ext.menu.Item-href"></div>/**
  48. * @cfg {String} href The href attribute to use for the underlying anchor link (defaults to '#').
  49. */
  50. <div id="cfg-Ext.menu.Item-hrefTarget"></div>/**
  51. * @cfg {String} hrefTarget The target attribute to use for the underlying anchor link (defaults to '').
  52. */
  53. <div id="cfg-Ext.menu.Item-itemCls"></div>/**
  54. * @cfg {String} itemCls The default CSS class to use for menu items (defaults to 'x-menu-item')
  55. */
  56. itemCls : 'x-menu-item',
  57. <div id="cfg-Ext.menu.Item-canActivate"></div>/**
  58. * @cfg {Boolean} canActivate True if this item can be visually activated (defaults to true)
  59. */
  60. canActivate : true,
  61. <div id="cfg-Ext.menu.Item-showDelay"></div>/**
  62. * @cfg {Number} showDelay Length of time in milliseconds to wait before showing this item (defaults to 200)
  63. */
  64. showDelay: 200,
  65. <div id="cfg-Ext.menu.Item-altText"></div>/**
  66. * @cfg {String} altText The altText to use for the icon, if it exists. Defaults to <tt>''</tt>.
  67. */
  68. altText: '',
  69. // doc'd in BaseItem
  70. hideDelay: 200,
  71. // private
  72. ctype: 'Ext.menu.Item',
  73. initComponent : function(){
  74. Ext.menu.Item.superclass.initComponent.call(this);
  75. if(this.menu){
  76. this.menu = Ext.menu.MenuMgr.get(this.menu);
  77. this.menu.ownerCt = this;
  78. }
  79. },
  80. // private
  81. onRender : function(container, position){
  82. if (!this.itemTpl) {
  83. this.itemTpl = Ext.menu.Item.prototype.itemTpl = new Ext.XTemplate(
  84. '<a id="{id}" class="{cls}" hidefocus="true" unselectable="on" href="{href}"',
  85. '<tpl if="hrefTarget">',
  86. ' target="{hrefTarget}"',
  87. '</tpl>',
  88. '>',
  89. '<img alt="{altText}" src="{icon}" class="x-menu-item-icon {iconCls}"/>',
  90. '<span class="x-menu-item-text">{text}</span>',
  91. '</a>'
  92. );
  93. }
  94. var a = this.getTemplateArgs();
  95. this.el = position ? this.itemTpl.insertBefore(position, a, true) : this.itemTpl.append(container, a, true);
  96. this.iconEl = this.el.child('img.x-menu-item-icon');
  97. this.textEl = this.el.child('.x-menu-item-text');
  98. if(!this.href) { // if no link defined, prevent the default anchor event
  99. this.mon(this.el, 'click', Ext.emptyFn, null, { preventDefault: true });
  100. }
  101. Ext.menu.Item.superclass.onRender.call(this, container, position);
  102. },
  103. getTemplateArgs: function() {
  104. return {
  105. id: this.id,
  106. cls: this.itemCls + (this.menu ? ' x-menu-item-arrow' : '') + (this.cls ? ' ' + this.cls : ''),
  107. href: this.href || '#',
  108. hrefTarget: this.hrefTarget,
  109. icon: this.icon || Ext.BLANK_IMAGE_URL,
  110. iconCls: this.iconCls || '',
  111. text: this.itemText||this.text||'&#160;',
  112. altText: this.altText || ''
  113. };
  114. },
  115. <div id="method-Ext.menu.Item-setText"></div>/**
  116. * Sets the text to display in this menu item
  117. * @param {String} text The text to display
  118. */
  119. setText : function(text){
  120. this.text = text||'&#160;';
  121. if(this.rendered){
  122. this.textEl.update(this.text);
  123. this.parentMenu.layout.doAutoSize();
  124. }
  125. },
  126. <div id="method-Ext.menu.Item-setIconClass"></div>/**
  127. * Sets the CSS class to apply to the item's icon element
  128. * @param {String} cls The CSS class to apply
  129. */
  130. setIconClass : function(cls){
  131. var oldCls = this.iconCls;
  132. this.iconCls = cls;
  133. if(this.rendered){
  134. this.iconEl.replaceClass(oldCls, this.iconCls);
  135. }
  136. },
  137. //private
  138. beforeDestroy: function(){
  139. if (this.menu){
  140. delete this.menu.ownerCt;
  141. this.menu.destroy();
  142. }
  143. Ext.menu.Item.superclass.beforeDestroy.call(this);
  144. },
  145. // private
  146. handleClick : function(e){
  147. if(!this.href){ // if no link defined, stop the event automatically
  148. e.stopEvent();
  149. }
  150. Ext.menu.Item.superclass.handleClick.apply(this, arguments);
  151. },
  152. // private
  153. activate : function(autoExpand){
  154. if(Ext.menu.Item.superclass.activate.apply(this, arguments)){
  155. this.focus();
  156. if(autoExpand){
  157. this.expandMenu();
  158. }
  159. }
  160. return true;
  161. },
  162. // private
  163. shouldDeactivate : function(e){
  164. if(Ext.menu.Item.superclass.shouldDeactivate.call(this, e)){
  165. if(this.menu && this.menu.isVisible()){
  166. return !this.menu.getEl().getRegion().contains(e.getPoint());
  167. }
  168. return true;
  169. }
  170. return false;
  171. },
  172. // private
  173. deactivate : function(){
  174. Ext.menu.Item.superclass.deactivate.apply(this, arguments);
  175. this.hideMenu();
  176. },
  177. // private
  178. expandMenu : function(autoActivate){
  179. if(!this.disabled && this.menu){
  180. clearTimeout(this.hideTimer);
  181. delete this.hideTimer;
  182. if(!this.menu.isVisible() && !this.showTimer){
  183. this.showTimer = this.deferExpand.defer(this.showDelay, this, [autoActivate]);
  184. }else if (this.menu.isVisible() && autoActivate){
  185. this.menu.tryActivate(0, 1);
  186. }
  187. }
  188. },
  189. // private
  190. deferExpand : function(autoActivate){
  191. delete this.showTimer;
  192. this.menu.show(this.container, this.parentMenu.subMenuAlign || 'tl-tr?', this.parentMenu);
  193. if(autoActivate){
  194. this.menu.tryActivate(0, 1);
  195. }
  196. },
  197. // private
  198. hideMenu : function(){
  199. clearTimeout(this.showTimer);
  200. delete this.showTimer;
  201. if(!this.hideTimer && this.menu && this.menu.isVisible()){
  202. this.hideTimer = this.deferHide.defer(this.hideDelay, this);
  203. }
  204. },
  205. // private
  206. deferHide : function(){
  207. delete this.hideTimer;
  208. if(this.menu.over){
  209. this.parentMenu.setActiveItem(this, false);
  210. }else{
  211. this.menu.hide();
  212. }
  213. }
  214. });
  215. Ext.reg('menuitem', Ext.menu.Item);</pre>
  216. </body>
  217. </html>