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.

175 lines
6.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.BaseItem"></div>/**
  16. * @class Ext.menu.BaseItem
  17. * @extends Ext.Component
  18. * The base class for all items that render into menus. BaseItem provides default rendering, activated state
  19. * management and base configuration options shared by all menu components.
  20. * @constructor
  21. * Creates a new BaseItem
  22. * @param {Object} config Configuration options
  23. * @xtype menubaseitem
  24. */
  25. Ext.menu.BaseItem = Ext.extend(Ext.Component, {
  26. <div id="prop-Ext.menu.BaseItem-parentMenu"></div>/**
  27. * @property parentMenu
  28. * @type Ext.menu.Menu
  29. * The parent Menu of this Item.
  30. */
  31. <div id="cfg-Ext.menu.BaseItem-handler"></div>/**
  32. * @cfg {Function} handler
  33. * A function that will handle the click event of this menu item (optional).
  34. * The handler is passed the following parameters:<div class="mdetail-params"><ul>
  35. * <li><code>b</code> : Item<div class="sub-desc">This menu Item.</div></li>
  36. * <li><code>e</code> : EventObject<div class="sub-desc">The click event.</div></li>
  37. * </ul></div>
  38. */
  39. <div id="cfg-Ext.menu.BaseItem-scope"></div>/**
  40. * @cfg {Object} scope
  41. * The scope (<tt><b>this</b></tt> reference) in which the handler function will be called.
  42. */
  43. <div id="cfg-Ext.menu.BaseItem-canActivate"></div>/**
  44. * @cfg {Boolean} canActivate True if this item can be visually activated (defaults to false)
  45. */
  46. canActivate : false,
  47. <div id="cfg-Ext.menu.BaseItem-activeClass"></div>/**
  48. * @cfg {String} activeClass The CSS class to use when the item becomes activated (defaults to "x-menu-item-active")
  49. */
  50. activeClass : "x-menu-item-active",
  51. <div id="cfg-Ext.menu.BaseItem-hideOnClick"></div>/**
  52. * @cfg {Boolean} hideOnClick True to hide the containing menu after this item is clicked (defaults to true)
  53. */
  54. hideOnClick : true,
  55. <div id="cfg-Ext.menu.BaseItem-clickHideDelay"></div>/**
  56. * @cfg {Number} clickHideDelay Length of time in milliseconds to wait before hiding after a click (defaults to 1)
  57. */
  58. clickHideDelay : 1,
  59. // private
  60. ctype : "Ext.menu.BaseItem",
  61. // private
  62. actionMode : "container",
  63. initComponent : function(){
  64. Ext.menu.BaseItem.superclass.initComponent.call(this);
  65. this.addEvents(
  66. <div id="event-Ext.menu.BaseItem-click"></div>/**
  67. * @event click
  68. * Fires when this item is clicked
  69. * @param {Ext.menu.BaseItem} this
  70. * @param {Ext.EventObject} e
  71. */
  72. 'click',
  73. <div id="event-Ext.menu.BaseItem-activate"></div>/**
  74. * @event activate
  75. * Fires when this item is activated
  76. * @param {Ext.menu.BaseItem} this
  77. */
  78. 'activate',
  79. <div id="event-Ext.menu.BaseItem-deactivate"></div>/**
  80. * @event deactivate
  81. * Fires when this item is deactivated
  82. * @param {Ext.menu.BaseItem} this
  83. */
  84. 'deactivate'
  85. );
  86. if(this.handler){
  87. this.on("click", this.handler, this.scope);
  88. }
  89. },
  90. // private
  91. onRender : function(container, position){
  92. Ext.menu.BaseItem.superclass.onRender.apply(this, arguments);
  93. if(this.ownerCt && this.ownerCt instanceof Ext.menu.Menu){
  94. this.parentMenu = this.ownerCt;
  95. }else{
  96. this.container.addClass('x-menu-list-item');
  97. this.mon(this.el, {
  98. scope: this,
  99. click: this.onClick,
  100. mouseenter: this.activate,
  101. mouseleave: this.deactivate
  102. });
  103. }
  104. },
  105. <div id="method-Ext.menu.BaseItem-setHandler"></div>/**
  106. * Sets the function that will handle click events for this item (equivalent to passing in the {@link #handler}
  107. * config property). If an existing handler is already registered, it will be unregistered for you.
  108. * @param {Function} handler The function that should be called on click
  109. * @param {Object} scope The scope (<code>this</code> reference) in which the handler function is executed. Defaults to this menu item.
  110. */
  111. setHandler : function(handler, scope){
  112. if(this.handler){
  113. this.un("click", this.handler, this.scope);
  114. }
  115. this.on("click", this.handler = handler, this.scope = scope);
  116. },
  117. // private
  118. onClick : function(e){
  119. if(!this.disabled && this.fireEvent("click", this, e) !== false
  120. && (this.parentMenu && this.parentMenu.fireEvent("itemclick", this, e) !== false)){
  121. this.handleClick(e);
  122. }else{
  123. e.stopEvent();
  124. }
  125. },
  126. // private
  127. activate : function(){
  128. if(this.disabled){
  129. return false;
  130. }
  131. var li = this.container;
  132. li.addClass(this.activeClass);
  133. this.region = li.getRegion().adjust(2, 2, -2, -2);
  134. this.fireEvent("activate", this);
  135. return true;
  136. },
  137. // private
  138. deactivate : function(){
  139. this.container.removeClass(this.activeClass);
  140. this.fireEvent("deactivate", this);
  141. },
  142. // private
  143. shouldDeactivate : function(e){
  144. return !this.region || !this.region.contains(e.getPoint());
  145. },
  146. // private
  147. handleClick : function(e){
  148. var pm = this.parentMenu;
  149. if(this.hideOnClick){
  150. if(pm.floating){
  151. pm.hide.defer(this.clickHideDelay, pm, [true]);
  152. }else{
  153. pm.deactivateActive();
  154. }
  155. }
  156. },
  157. // private. Do nothing
  158. expandMenu : Ext.emptyFn,
  159. // private. Do nothing
  160. hideMenu : Ext.emptyFn
  161. });
  162. Ext.reg('menubaseitem', Ext.menu.BaseItem);</pre>
  163. </body>
  164. </html>