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.

184 lines
7.4 KiB

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