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.

863 lines
34 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-Button-method-constructor'><span id='Ext-Button-cfg-repeat'><span id='Ext-Button-cfg-toggleGroup'><span id='Ext-Button-cfg-pressed'><span id='Ext-Button-cfg-disabled'><span id='Ext-Button-cfg-hidden'><span id='Ext-Button-cfg-tooltip'><span id='Ext-Button-cfg-minWidth'><span id='Ext-Button-cfg-handler'><span id='Ext-Button-cfg-icon'><span id='Ext-Button-cfg-text'><span id='Ext-Button'>/**
  19. </span></span></span></span></span></span></span></span></span></span></span></span> * @class Ext.Button
  20. * @extends Ext.BoxComponent
  21. * Simple Button class
  22. * @cfg {String} text The button text to be used as innerHTML (html tags are accepted)
  23. * @cfg {String} icon The path to an image to display in the button (the image will be set as the background-image
  24. * CSS property of the button by default, so if you want a mixed icon/text button, set cls:'x-btn-text-icon')
  25. * @cfg {Function} handler A function called when the button is clicked (can be used instead of click event).
  26. * The handler is passed the following parameters:&lt;div class=&quot;mdetail-params&quot;&gt;&lt;ul&gt;
  27. * &lt;li&gt;&lt;code&gt;b&lt;/code&gt; : Button&lt;div class=&quot;sub-desc&quot;&gt;This Button.&lt;/div&gt;&lt;/li&gt;
  28. * &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;
  29. * &lt;/ul&gt;&lt;/div&gt;
  30. * @cfg {Number} minWidth The minimum width for this button (used to give a set of buttons a common width).
  31. * See also {@link Ext.Panel}.&lt;tt&gt;{@link Ext.Panel#minButtonWidth minButtonWidth}&lt;/tt&gt;.
  32. * @cfg {String/Object} tooltip The tooltip for the button - can be a string to be used as innerHTML (html tags are accepted) or QuickTips config object
  33. * @cfg {Boolean} hidden True to start hidden (defaults to false)
  34. * @cfg {Boolean} disabled True to start disabled (defaults to false)
  35. * @cfg {Boolean} pressed True to start pressed (only if enableToggle = true)
  36. * @cfg {String} toggleGroup The group this toggle button is a member of (only 1 per group can be pressed)
  37. * @cfg {Boolean/Object} repeat True to repeat fire the click event while the mouse is down. This can also be
  38. * a {@link Ext.util.ClickRepeater ClickRepeater} config object (defaults to false).
  39. * @constructor
  40. * Create a new button
  41. * @param {Object} config The config object
  42. * @xtype button
  43. */
  44. Ext.Button = Ext.extend(Ext.BoxComponent, {
  45. <span id='Ext-Button-property-hidden'> /**
  46. </span> * Read-only. True if this button is hidden
  47. * @type Boolean
  48. */
  49. hidden : false,
  50. <span id='Ext-Button-property-disabled'> /**
  51. </span> * Read-only. True if this button is disabled
  52. * @type Boolean
  53. */
  54. disabled : false,
  55. <span id='Ext-Button-property-pressed'> /**
  56. </span> * Read-only. True if this button is pressed (only if enableToggle = true)
  57. * @type Boolean
  58. */
  59. pressed : false,
  60. <span id='Ext-Button-cfg-tabIndex'> /**
  61. </span> * @cfg {Number} tabIndex Set a DOM tabIndex for this button (defaults to undefined)
  62. */
  63. <span id='Ext-Button-cfg-allowDepress'> /**
  64. </span> * @cfg {Boolean} allowDepress
  65. * False to not allow a pressed Button to be depressed (defaults to undefined). Only valid when {@link #enableToggle} is true.
  66. */
  67. <span id='Ext-Button-cfg-enableToggle'> /**
  68. </span> * @cfg {Boolean} enableToggle
  69. * True to enable pressed/not pressed toggling (defaults to false)
  70. */
  71. enableToggle : false,
  72. <span id='Ext-Button-cfg-toggleHandler'> /**
  73. </span> * @cfg {Function} toggleHandler
  74. * Function called when a Button with {@link #enableToggle} set to true is clicked. Two arguments are passed:&lt;ul class=&quot;mdetail-params&quot;&gt;
  75. * &lt;li&gt;&lt;b&gt;button&lt;/b&gt; : Ext.Button&lt;div class=&quot;sub-desc&quot;&gt;this Button object&lt;/div&gt;&lt;/li&gt;
  76. * &lt;li&gt;&lt;b&gt;state&lt;/b&gt; : Boolean&lt;div class=&quot;sub-desc&quot;&gt;The next state of the Button, true means pressed.&lt;/div&gt;&lt;/li&gt;
  77. * &lt;/ul&gt;
  78. */
  79. <span id='Ext-Button-cfg-menu'> /**
  80. </span> * @cfg {Mixed} menu
  81. * Standard menu attribute consisting of a reference to a menu object, a menu id or a menu config blob (defaults to undefined).
  82. */
  83. <span id='Ext-Button-cfg-menuAlign'> /**
  84. </span> * @cfg {String} menuAlign
  85. * The position to align the menu to (see {@link Ext.Element#alignTo} for more details, defaults to 'tl-bl?').
  86. */
  87. menuAlign : 'tl-bl?',
  88. <span id='Ext-Button-cfg-overflowText'> /**
  89. </span> * @cfg {String} overflowText If used in a {@link Ext.Toolbar Toolbar}, the
  90. * text to be used if this item is shown in the overflow menu. See also
  91. * {@link Ext.Toolbar.Item}.&lt;code&gt;{@link Ext.Toolbar.Item#overflowText overflowText}&lt;/code&gt;.
  92. */
  93. <span id='Ext-Button-cfg-iconCls'> /**
  94. </span> * @cfg {String} iconCls
  95. * A css class which sets a background image to be used as the icon for this button
  96. */
  97. <span id='Ext-Button-cfg-type'> /**
  98. </span> * @cfg {String} type
  99. * submit, reset or button - defaults to 'button'
  100. */
  101. type : 'button',
  102. <span id='Ext-Button-property-menuClassTarget'> // private
  103. </span> menuClassTarget : 'tr:nth(2)',
  104. <span id='Ext-Button-cfg-clickEvent'> /**
  105. </span> * @cfg {String} clickEvent
  106. * The DOM event that will fire the handler of the button. This can be any valid event name (dblclick, contextmenu).
  107. * Defaults to &lt;tt&gt;'click'&lt;/tt&gt;.
  108. */
  109. clickEvent : 'click',
  110. <span id='Ext-Button-cfg-handleMouseEvents'> /**
  111. </span> * @cfg {Boolean} handleMouseEvents
  112. * False to disable visual cues on mouseover, mouseout and mousedown (defaults to true)
  113. */
  114. handleMouseEvents : true,
  115. <span id='Ext-Button-cfg-tooltipType'> /**
  116. </span> * @cfg {String} tooltipType
  117. * The type of tooltip to use. Either 'qtip' (default) for QuickTips or 'title' for title attribute.
  118. */
  119. tooltipType : 'qtip',
  120. <span id='Ext-Button-cfg-buttonSelector'> /**
  121. </span> * @cfg {String} buttonSelector
  122. * &lt;p&gt;(Optional) A {@link Ext.DomQuery DomQuery} selector which is used to extract the active, clickable element from the
  123. * DOM structure created.&lt;/p&gt;
  124. * &lt;p&gt;When a custom {@link #template} is used, you must ensure that this selector results in the selection of
  125. * a focussable element.&lt;/p&gt;
  126. * &lt;p&gt;Defaults to &lt;b&gt;&lt;tt&gt;'button:first-child'&lt;/tt&gt;&lt;/b&gt;.&lt;/p&gt;
  127. */
  128. buttonSelector : 'button:first-child',
  129. <span id='Ext-Button-cfg-scale'> /**
  130. </span> * @cfg {String} scale
  131. * &lt;p&gt;(Optional) The size of the Button. Three values are allowed:&lt;/p&gt;
  132. * &lt;ul class=&quot;mdetail-params&quot;&gt;
  133. * &lt;li&gt;'small'&lt;div class=&quot;sub-desc&quot;&gt;Results in the button element being 16px high.&lt;/div&gt;&lt;/li&gt;
  134. * &lt;li&gt;'medium'&lt;div class=&quot;sub-desc&quot;&gt;Results in the button element being 24px high.&lt;/div&gt;&lt;/li&gt;
  135. * &lt;li&gt;'large'&lt;div class=&quot;sub-desc&quot;&gt;Results in the button element being 32px high.&lt;/div&gt;&lt;/li&gt;
  136. * &lt;/ul&gt;
  137. * &lt;p&gt;Defaults to &lt;b&gt;&lt;tt&gt;'small'&lt;/tt&gt;&lt;/b&gt;.&lt;/p&gt;
  138. */
  139. scale : 'small',
  140. <span id='Ext-Button-cfg-scope'> /**
  141. </span> * @cfg {Object} scope The scope (&lt;tt&gt;&lt;b&gt;this&lt;/b&gt;&lt;/tt&gt; reference) in which the
  142. * &lt;code&gt;{@link #handler}&lt;/code&gt; and &lt;code&gt;{@link #toggleHandler}&lt;/code&gt; is
  143. * executed. Defaults to this Button.
  144. */
  145. <span id='Ext-Button-cfg-iconAlign'> /**
  146. </span> * @cfg {String} iconAlign
  147. * &lt;p&gt;(Optional) The side of the Button box to render the icon. Four values are allowed:&lt;/p&gt;
  148. * &lt;ul class=&quot;mdetail-params&quot;&gt;
  149. * &lt;li&gt;'top'&lt;div class=&quot;sub-desc&quot;&gt;&lt;/div&gt;&lt;/li&gt;
  150. * &lt;li&gt;'right'&lt;div class=&quot;sub-desc&quot;&gt;&lt;/div&gt;&lt;/li&gt;
  151. * &lt;li&gt;'bottom'&lt;div class=&quot;sub-desc&quot;&gt;&lt;/div&gt;&lt;/li&gt;
  152. * &lt;li&gt;'left'&lt;div class=&quot;sub-desc&quot;&gt;&lt;/div&gt;&lt;/li&gt;
  153. * &lt;/ul&gt;
  154. * &lt;p&gt;Defaults to &lt;b&gt;&lt;tt&gt;'left'&lt;/tt&gt;&lt;/b&gt;.&lt;/p&gt;
  155. */
  156. iconAlign : 'left',
  157. <span id='Ext-Button-cfg-arrowAlign'> /**
  158. </span> * @cfg {String} arrowAlign
  159. * &lt;p&gt;(Optional) The side of the Button box to render the arrow if the button has an associated {@link #menu}.
  160. * Two values are allowed:&lt;/p&gt;
  161. * &lt;ul class=&quot;mdetail-params&quot;&gt;
  162. * &lt;li&gt;'right'&lt;div class=&quot;sub-desc&quot;&gt;&lt;/div&gt;&lt;/li&gt;
  163. * &lt;li&gt;'bottom'&lt;div class=&quot;sub-desc&quot;&gt;&lt;/div&gt;&lt;/li&gt;
  164. * &lt;/ul&gt;
  165. * &lt;p&gt;Defaults to &lt;b&gt;&lt;tt&gt;'right'&lt;/tt&gt;&lt;/b&gt;.&lt;/p&gt;
  166. */
  167. arrowAlign : 'right',
  168. <span id='Ext-Button-property-template'> /**
  169. </span> * @cfg {Ext.Template} template (Optional)
  170. * &lt;p&gt;A {@link Ext.Template Template} used to create the Button's DOM structure.&lt;/p&gt;
  171. * Instances, or subclasses which need a different DOM structure may provide a different
  172. * template layout in conjunction with an implementation of {@link #getTemplateArgs}.
  173. * @type Ext.Template
  174. * @property template
  175. */
  176. <span id='Ext-Button-cfg-cls'> /**
  177. </span> * @cfg {String} cls
  178. * A CSS class string to apply to the button's main element.
  179. */
  180. <span id='Ext-Button-property-menu'> /**
  181. </span> * @property menu
  182. * @type Menu
  183. * The {@link Ext.menu.Menu Menu} object associated with this Button when configured with the {@link #menu} config option.
  184. */
  185. <span id='Ext-Button-cfg-autoWidth'> /**
  186. </span> * @cfg {Boolean} autoWidth
  187. * By default, if a width is not specified the button will attempt to stretch horizontally to fit its content.
  188. * If the button is being managed by a width sizing layout (hbox, fit, anchor), set this to false to prevent
  189. * the button from doing this automatic sizing.
  190. * Defaults to &lt;tt&gt;undefined&lt;/tt&gt;.
  191. */
  192. initComponent : function(){
  193. if(this.menu){
  194. // If array of items, turn it into an object config so we
  195. // can set the ownerCt property in the config
  196. if (Ext.isArray(this.menu)){
  197. this.menu = { items: this.menu };
  198. }
  199. // An object config will work here, but an instance of a menu
  200. // will have already setup its ref's and have no effect
  201. if (Ext.isObject(this.menu)){
  202. this.menu.ownerCt = this;
  203. }
  204. this.menu = Ext.menu.MenuMgr.get(this.menu);
  205. this.menu.ownerCt = undefined;
  206. }
  207. Ext.Button.superclass.initComponent.call(this);
  208. this.addEvents(
  209. <span id='Ext-Button-event-click'> /**
  210. </span> * @event click
  211. * Fires when this button is clicked
  212. * @param {Button} this
  213. * @param {EventObject} e The click event
  214. */
  215. 'click',
  216. <span id='Ext-Button-event-toggle'> /**
  217. </span> * @event toggle
  218. * Fires when the 'pressed' state of this button changes (only if enableToggle = true)
  219. * @param {Button} this
  220. * @param {Boolean} pressed
  221. */
  222. 'toggle',
  223. <span id='Ext-Button-event-mouseover'> /**
  224. </span> * @event mouseover
  225. * Fires when the mouse hovers over the button
  226. * @param {Button} this
  227. * @param {Event} e The event object
  228. */
  229. 'mouseover',
  230. <span id='Ext-Button-event-mouseout'> /**
  231. </span> * @event mouseout
  232. * Fires when the mouse exits the button
  233. * @param {Button} this
  234. * @param {Event} e The event object
  235. */
  236. 'mouseout',
  237. <span id='Ext-Button-event-menushow'> /**
  238. </span> * @event menushow
  239. * If this button has a menu, this event fires when it is shown
  240. * @param {Button} this
  241. * @param {Menu} menu
  242. */
  243. 'menushow',
  244. <span id='Ext-Button-event-menuhide'> /**
  245. </span> * @event menuhide
  246. * If this button has a menu, this event fires when it is hidden
  247. * @param {Button} this
  248. * @param {Menu} menu
  249. */
  250. 'menuhide',
  251. <span id='Ext-Button-event-menutriggerover'> /**
  252. </span> * @event menutriggerover
  253. * If this button has a menu, this event fires when the mouse enters the menu triggering element
  254. * @param {Button} this
  255. * @param {Menu} menu
  256. * @param {EventObject} e
  257. */
  258. 'menutriggerover',
  259. <span id='Ext-Button-event-menutriggerout'> /**
  260. </span> * @event menutriggerout
  261. * If this button has a menu, this event fires when the mouse leaves the menu triggering element
  262. * @param {Button} this
  263. * @param {Menu} menu
  264. * @param {EventObject} e
  265. */
  266. 'menutriggerout'
  267. );
  268. if(Ext.isString(this.toggleGroup)){
  269. this.enableToggle = true;
  270. }
  271. },
  272. <span id='Ext-Button-method-getTemplateArgs'>/**
  273. </span> * &lt;p&gt;This method returns an Array which provides substitution parameters for the {@link #template Template} used
  274. * to create this Button's DOM structure.&lt;/p&gt;
  275. * &lt;p&gt;Instances or subclasses which use a different Template to create a different DOM structure may need to provide their
  276. * own implementation of this method.&lt;/p&gt;
  277. * &lt;p&gt;The default implementation which provides data for the default {@link #template} returns an Array containing the
  278. * following items:&lt;/p&gt;&lt;div class=&quot;mdetail-params&quot;&gt;&lt;ul&gt;
  279. * &lt;li&gt;The &amp;lt;button&amp;gt;'s {@link #type}&lt;/li&gt;
  280. * &lt;li&gt;A CSS class name applied to the Button's main &amp;lt;tbody&amp;gt; element which determines the button's scale and icon alignment.&lt;/li&gt;
  281. * &lt;li&gt;A CSS class to determine the presence and position of an arrow icon. (&lt;code&gt;'x-btn-arrow'&lt;/code&gt; or &lt;code&gt;'x-btn-arrow-bottom'&lt;/code&gt; or &lt;code&gt;''&lt;/code&gt;)&lt;/li&gt;
  282. * &lt;li&gt;The {@link #cls} CSS class name applied to the button's wrapping &amp;lt;table&amp;gt; element.&lt;/li&gt;
  283. * &lt;li&gt;The Component id which is applied to the button's wrapping &amp;lt;table&amp;gt; element.&lt;/li&gt;
  284. * &lt;/ul&gt;&lt;/div&gt;
  285. * @return {Array} Substitution data for a Template.
  286. */
  287. getTemplateArgs : function(){
  288. return [this.type, 'x-btn-' + this.scale + ' x-btn-icon-' + this.scale + '-' + this.iconAlign, this.getMenuClass(), this.cls, this.id];
  289. },
  290. <span id='Ext-Button-method-setButtonClass'> // private
  291. </span> setButtonClass : function(){
  292. if(this.useSetClass){
  293. if(!Ext.isEmpty(this.oldCls)){
  294. this.el.removeClass([this.oldCls, 'x-btn-pressed']);
  295. }
  296. this.oldCls = (this.iconCls || this.icon) ? (this.text ? 'x-btn-text-icon' : 'x-btn-icon') : 'x-btn-noicon';
  297. this.el.addClass([this.oldCls, this.pressed ? 'x-btn-pressed' : null]);
  298. }
  299. },
  300. <span id='Ext-Button-method-getMenuClass'> // protected
  301. </span> getMenuClass : function(){
  302. return this.menu ? (this.arrowAlign != 'bottom' ? 'x-btn-arrow' : 'x-btn-arrow-bottom') : '';
  303. },
  304. <span id='Ext-Button-method-onRender'> // private
  305. </span> onRender : function(ct, position){
  306. if(!this.template){
  307. if(!Ext.Button.buttonTemplate){
  308. // hideous table template
  309. Ext.Button.buttonTemplate = new Ext.Template(
  310. '&lt;table id=&quot;{4}&quot; cellspacing=&quot;0&quot; class=&quot;x-btn {3}&quot;&gt;&lt;tbody class=&quot;{1}&quot;&gt;',
  311. '&lt;tr&gt;&lt;td class=&quot;x-btn-tl&quot;&gt;&lt;i&gt;&amp;#160;&lt;/i&gt;&lt;/td&gt;&lt;td class=&quot;x-btn-tc&quot;&gt;&lt;/td&gt;&lt;td class=&quot;x-btn-tr&quot;&gt;&lt;i&gt;&amp;#160;&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;',
  312. '&lt;tr&gt;&lt;td class=&quot;x-btn-ml&quot;&gt;&lt;i&gt;&amp;#160;&lt;/i&gt;&lt;/td&gt;&lt;td class=&quot;x-btn-mc&quot;&gt;&lt;em class=&quot;{2} x-unselectable&quot; unselectable=&quot;on&quot;&gt;&lt;button type=&quot;{0}&quot;&gt;&lt;/button&gt;&lt;/em&gt;&lt;/td&gt;&lt;td class=&quot;x-btn-mr&quot;&gt;&lt;i&gt;&amp;#160;&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;',
  313. '&lt;tr&gt;&lt;td class=&quot;x-btn-bl&quot;&gt;&lt;i&gt;&amp;#160;&lt;/i&gt;&lt;/td&gt;&lt;td class=&quot;x-btn-bc&quot;&gt;&lt;/td&gt;&lt;td class=&quot;x-btn-br&quot;&gt;&lt;i&gt;&amp;#160;&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;',
  314. '&lt;/tbody&gt;&lt;/table&gt;');
  315. Ext.Button.buttonTemplate.compile();
  316. }
  317. this.template = Ext.Button.buttonTemplate;
  318. }
  319. var btn, targs = this.getTemplateArgs();
  320. if(position){
  321. btn = this.template.insertBefore(position, targs, true);
  322. }else{
  323. btn = this.template.append(ct, targs, true);
  324. }
  325. <span id='Ext-Button-property-btnEl'> /**
  326. </span> * An {@link Ext.Element Element} encapsulating the Button's clickable element. By default,
  327. * this references a &lt;tt&gt;&amp;lt;button&amp;gt;&lt;/tt&gt; element. Read only.
  328. * @type Ext.Element
  329. * @property btnEl
  330. */
  331. this.btnEl = btn.child(this.buttonSelector);
  332. this.mon(this.btnEl, {
  333. scope: this,
  334. focus: this.onFocus,
  335. blur: this.onBlur
  336. });
  337. this.initButtonEl(btn, this.btnEl);
  338. Ext.ButtonToggleMgr.register(this);
  339. },
  340. <span id='Ext-Button-method-initButtonEl'> // private
  341. </span> initButtonEl : function(btn, btnEl){
  342. this.el = btn;
  343. this.setIcon(this.icon);
  344. this.setText(this.text);
  345. this.setIconClass(this.iconCls);
  346. if(Ext.isDefined(this.tabIndex)){
  347. btnEl.dom.tabIndex = this.tabIndex;
  348. }
  349. if(this.tooltip){
  350. this.setTooltip(this.tooltip, true);
  351. }
  352. if(this.handleMouseEvents){
  353. this.mon(btn, {
  354. scope: this,
  355. mouseover: this.onMouseOver,
  356. mousedown: this.onMouseDown
  357. });
  358. // new functionality for monitoring on the document level
  359. //this.mon(btn, 'mouseout', this.onMouseOut, this);
  360. }
  361. if(this.menu){
  362. this.mon(this.menu, {
  363. scope: this,
  364. show: this.onMenuShow,
  365. hide: this.onMenuHide
  366. });
  367. }
  368. if(this.repeat){
  369. var repeater = new Ext.util.ClickRepeater(btn, Ext.isObject(this.repeat) ? this.repeat : {});
  370. this.mon(repeater, 'click', this.onRepeatClick, this);
  371. }else{
  372. this.mon(btn, this.clickEvent, this.onClick, this);
  373. }
  374. },
  375. <span id='Ext-Button-method-afterRender'> // private
  376. </span> afterRender : function(){
  377. Ext.Button.superclass.afterRender.call(this);
  378. this.useSetClass = true;
  379. this.setButtonClass();
  380. this.doc = Ext.getDoc();
  381. this.doAutoWidth();
  382. },
  383. <span id='Ext-Button-method-setIconClass'> /**
  384. </span> * Sets the CSS class that provides a background image to use as the button's icon. This method also changes
  385. * the value of the {@link iconCls} config internally.
  386. * @param {String} cls The CSS class providing the icon image
  387. * @return {Ext.Button} this
  388. */
  389. setIconClass : function(cls){
  390. this.iconCls = cls;
  391. if(this.el){
  392. this.btnEl.dom.className = '';
  393. this.btnEl.addClass(['x-btn-text', cls || '']);
  394. this.setButtonClass();
  395. }
  396. return this;
  397. },
  398. <span id='Ext-Button-method-setTooltip'> /**
  399. </span> * Sets the tooltip for this Button.
  400. * @param {String/Object} tooltip. This may be:&lt;div class=&quot;mdesc-details&quot;&gt;&lt;ul&gt;
  401. * &lt;li&gt;&lt;b&gt;String&lt;/b&gt; : A string to be used as innerHTML (html tags are accepted) to show in a tooltip&lt;/li&gt;
  402. * &lt;li&gt;&lt;b&gt;Object&lt;/b&gt; : A configuration object for {@link Ext.QuickTips#register}.&lt;/li&gt;
  403. * &lt;/ul&gt;&lt;/div&gt;
  404. * @return {Ext.Button} this
  405. */
  406. setTooltip : function(tooltip, /* private */ initial){
  407. if(this.rendered){
  408. if(!initial){
  409. this.clearTip();
  410. }
  411. if(Ext.isObject(tooltip)){
  412. Ext.QuickTips.register(Ext.apply({
  413. target: this.btnEl.id
  414. }, tooltip));
  415. this.tooltip = tooltip;
  416. }else{
  417. this.btnEl.dom[this.tooltipType] = tooltip;
  418. }
  419. }else{
  420. this.tooltip = tooltip;
  421. }
  422. return this;
  423. },
  424. <span id='Ext-Button-method-clearTip'> // private
  425. </span> clearTip : function(){
  426. if(Ext.isObject(this.tooltip)){
  427. Ext.QuickTips.unregister(this.btnEl);
  428. }
  429. },
  430. <span id='Ext-Button-method-beforeDestroy'> // private
  431. </span> beforeDestroy : function(){
  432. if(this.rendered){
  433. this.clearTip();
  434. }
  435. if(this.menu &amp;&amp; this.destroyMenu !== false) {
  436. Ext.destroy(this.btnEl, this.menu);
  437. }
  438. Ext.destroy(this.repeater);
  439. },
  440. <span id='Ext-Button-method-onDestroy'> // private
  441. </span> onDestroy : function(){
  442. if(this.rendered){
  443. this.doc.un('mouseover', this.monitorMouseOver, this);
  444. this.doc.un('mouseup', this.onMouseUp, this);
  445. delete this.doc;
  446. delete this.btnEl;
  447. Ext.ButtonToggleMgr.unregister(this);
  448. }
  449. Ext.Button.superclass.onDestroy.call(this);
  450. },
  451. <span id='Ext-Button-method-doAutoWidth'> // private
  452. </span> doAutoWidth : function(){
  453. if(this.autoWidth !== false &amp;&amp; this.el &amp;&amp; this.text &amp;&amp; this.width === undefined){
  454. this.el.setWidth('auto');
  455. if(Ext.isIE7 &amp;&amp; Ext.isStrict){
  456. var ib = this.btnEl;
  457. if(ib &amp;&amp; ib.getWidth() &gt; 20){
  458. ib.clip();
  459. ib.setWidth(Ext.util.TextMetrics.measure(ib, this.text).width+ib.getFrameWidth('lr'));
  460. }
  461. }
  462. if(this.minWidth){
  463. if(this.el.getWidth() &lt; this.minWidth){
  464. this.el.setWidth(this.minWidth);
  465. }
  466. }
  467. }
  468. },
  469. <span id='Ext-Button-method-setHandler'> /**
  470. </span> * Assigns this Button's click handler
  471. * @param {Function} handler The function to call when the button is clicked
  472. * @param {Object} scope (optional) The scope (&lt;code&gt;this&lt;/code&gt; reference) in which the handler function is executed.
  473. * Defaults to this Button.
  474. * @return {Ext.Button} this
  475. */
  476. setHandler : function(handler, scope){
  477. this.handler = handler;
  478. this.scope = scope;
  479. return this;
  480. },
  481. <span id='Ext-Button-method-setText'> /**
  482. </span> * Sets this Button's text
  483. * @param {String} text The button text
  484. * @return {Ext.Button} this
  485. */
  486. setText : function(text){
  487. this.text = text;
  488. if(this.el){
  489. this.btnEl.update(text || '&amp;#160;');
  490. this.setButtonClass();
  491. }
  492. this.doAutoWidth();
  493. return this;
  494. },
  495. <span id='Ext-Button-method-setIcon'> /**
  496. </span> * Sets the background image (inline style) of the button. This method also changes
  497. * the value of the {@link icon} config internally.
  498. * @param {String} icon The path to an image to display in the button
  499. * @return {Ext.Button} this
  500. */
  501. setIcon : function(icon){
  502. this.icon = icon;
  503. if(this.el){
  504. this.btnEl.setStyle('background-image', icon ? 'url(' + icon + ')' : '');
  505. this.setButtonClass();
  506. }
  507. return this;
  508. },
  509. <span id='Ext-Button-method-getText'> /**
  510. </span> * Gets the text for this Button
  511. * @return {String} The button text
  512. */
  513. getText : function(){
  514. return this.text;
  515. },
  516. <span id='Ext-Button-method-toggle'> /**
  517. </span> * If a state it passed, it becomes the pressed state otherwise the current state is toggled.
  518. * @param {Boolean} state (optional) Force a particular state
  519. * @param {Boolean} supressEvent (optional) True to stop events being fired when calling this method.
  520. * @return {Ext.Button} this
  521. */
  522. toggle : function(state, suppressEvent){
  523. state = state === undefined ? !this.pressed : !!state;
  524. if(state != this.pressed){
  525. if(this.rendered){
  526. this.el[state ? 'addClass' : 'removeClass']('x-btn-pressed');
  527. }
  528. this.pressed = state;
  529. if(!suppressEvent){
  530. this.fireEvent('toggle', this, state);
  531. if(this.toggleHandler){
  532. this.toggleHandler.call(this.scope || this, this, state);
  533. }
  534. }
  535. }
  536. return this;
  537. },
  538. <span id='Ext-Button-method-onDisable'> // private
  539. </span> onDisable : function(){
  540. this.onDisableChange(true);
  541. },
  542. <span id='Ext-Button-method-onEnable'> // private
  543. </span> onEnable : function(){
  544. this.onDisableChange(false);
  545. },
  546. <span id='Ext-Button-method-onDisableChange'> onDisableChange : function(disabled){
  547. </span> if(this.el){
  548. if(!Ext.isIE6 || !this.text){
  549. this.el[disabled ? 'addClass' : 'removeClass'](this.disabledClass);
  550. }
  551. this.el.dom.disabled = disabled;
  552. }
  553. this.disabled = disabled;
  554. },
  555. <span id='Ext-Button-method-showMenu'> /**
  556. </span> * Show this button's menu (if it has one)
  557. */
  558. showMenu : function(){
  559. if(this.rendered &amp;&amp; this.menu){
  560. if(this.tooltip){
  561. Ext.QuickTips.getQuickTip().cancelShow(this.btnEl);
  562. }
  563. if(this.menu.isVisible()){
  564. this.menu.hide();
  565. }
  566. this.menu.ownerCt = this;
  567. this.menu.show(this.el, this.menuAlign);
  568. }
  569. return this;
  570. },
  571. <span id='Ext-Button-method-hideMenu'> /**
  572. </span> * Hide this button's menu (if it has one)
  573. */
  574. hideMenu : function(){
  575. if(this.hasVisibleMenu()){
  576. this.menu.hide();
  577. }
  578. return this;
  579. },
  580. <span id='Ext-Button-method-hasVisibleMenu'> /**
  581. </span> * Returns true if the button has a menu and it is visible
  582. * @return {Boolean}
  583. */
  584. hasVisibleMenu : function(){
  585. return this.menu &amp;&amp; this.menu.ownerCt == this &amp;&amp; this.menu.isVisible();
  586. },
  587. <span id='Ext-Button-method-onRepeatClick'> // private
  588. </span> onRepeatClick : function(repeat, e){
  589. this.onClick(e);
  590. },
  591. <span id='Ext-Button-method-onClick'> // private
  592. </span> onClick : function(e){
  593. if(e){
  594. e.preventDefault();
  595. }
  596. if(e.button !== 0){
  597. return;
  598. }
  599. if(!this.disabled){
  600. this.doToggle();
  601. if(this.menu &amp;&amp; !this.hasVisibleMenu() &amp;&amp; !this.ignoreNextClick){
  602. this.showMenu();
  603. }
  604. this.fireEvent('click', this, e);
  605. if(this.handler){
  606. //this.el.removeClass('x-btn-over');
  607. this.handler.call(this.scope || this, this, e);
  608. }
  609. }
  610. },
  611. <span id='Ext-Button-method-doToggle'> // private
  612. </span> doToggle: function(){
  613. if (this.enableToggle &amp;&amp; (this.allowDepress !== false || !this.pressed)) {
  614. this.toggle();
  615. }
  616. },
  617. <span id='Ext-Button-method-isMenuTriggerOver'> // private
  618. </span> isMenuTriggerOver : function(e, internal){
  619. return this.menu &amp;&amp; !internal;
  620. },
  621. <span id='Ext-Button-method-isMenuTriggerOut'> // private
  622. </span> isMenuTriggerOut : function(e, internal){
  623. return this.menu &amp;&amp; !internal;
  624. },
  625. <span id='Ext-Button-method-onMouseOver'> // private
  626. </span> onMouseOver : function(e){
  627. if(!this.disabled){
  628. var internal = e.within(this.el, true);
  629. if(!internal){
  630. this.el.addClass('x-btn-over');
  631. if(!this.monitoringMouseOver){
  632. this.doc.on('mouseover', this.monitorMouseOver, this);
  633. this.monitoringMouseOver = true;
  634. }
  635. this.fireEvent('mouseover', this, e);
  636. }
  637. if(this.isMenuTriggerOver(e, internal)){
  638. this.fireEvent('menutriggerover', this, this.menu, e);
  639. }
  640. }
  641. },
  642. <span id='Ext-Button-method-monitorMouseOver'> // private
  643. </span> monitorMouseOver : function(e){
  644. if(e.target != this.el.dom &amp;&amp; !e.within(this.el)){
  645. if(this.monitoringMouseOver){
  646. this.doc.un('mouseover', this.monitorMouseOver, this);
  647. this.monitoringMouseOver = false;
  648. }
  649. this.onMouseOut(e);
  650. }
  651. },
  652. <span id='Ext-Button-method-onMouseOut'> // private
  653. </span> onMouseOut : function(e){
  654. var internal = e.within(this.el) &amp;&amp; e.target != this.el.dom;
  655. this.el.removeClass('x-btn-over');
  656. this.fireEvent('mouseout', this, e);
  657. if(this.isMenuTriggerOut(e, internal)){
  658. this.fireEvent('menutriggerout', this, this.menu, e);
  659. }
  660. },
  661. <span id='Ext-Button-method-focus'> focus : function() {
  662. </span> this.btnEl.focus();
  663. },
  664. <span id='Ext-Button-method-blur'> blur : function() {
  665. </span> this.btnEl.blur();
  666. },
  667. <span id='Ext-Button-method-onFocus'> // private
  668. </span> onFocus : function(e){
  669. if(!this.disabled){
  670. this.el.addClass('x-btn-focus');
  671. }
  672. },
  673. <span id='Ext-Button-method-onBlur'> // private
  674. </span> onBlur : function(e){
  675. this.el.removeClass('x-btn-focus');
  676. },
  677. <span id='Ext-Button-method-getClickEl'> // private
  678. </span> getClickEl : function(e, isUp){
  679. return this.el;
  680. },
  681. <span id='Ext-Button-method-onMouseDown'> // private
  682. </span> onMouseDown : function(e){
  683. if(!this.disabled &amp;&amp; e.button === 0){
  684. this.getClickEl(e).addClass('x-btn-click');
  685. this.doc.on('mouseup', this.onMouseUp, this);
  686. }
  687. },
  688. <span id='Ext-Button-method-onMouseUp'> // private
  689. </span> onMouseUp : function(e){
  690. if(e.button === 0){
  691. this.getClickEl(e, true).removeClass('x-btn-click');
  692. this.doc.un('mouseup', this.onMouseUp, this);
  693. }
  694. },
  695. <span id='Ext-Button-method-onMenuShow'> // private
  696. </span> onMenuShow : function(e){
  697. if(this.menu.ownerCt == this){
  698. this.menu.ownerCt = this;
  699. this.ignoreNextClick = 0;
  700. this.el.addClass('x-btn-menu-active');
  701. this.fireEvent('menushow', this, this.menu);
  702. }
  703. },
  704. <span id='Ext-Button-method-onMenuHide'> // private
  705. </span> onMenuHide : function(e){
  706. if(this.menu.ownerCt == this){
  707. this.el.removeClass('x-btn-menu-active');
  708. this.ignoreNextClick = this.restoreClick.defer(250, this);
  709. this.fireEvent('menuhide', this, this.menu);
  710. delete this.menu.ownerCt;
  711. }
  712. },
  713. <span id='Ext-Button-method-restoreClick'> // private
  714. </span> restoreClick : function(){
  715. this.ignoreNextClick = 0;
  716. }
  717. <span id='Ext-Button-cfg-autoEl'> /**
  718. </span> * @cfg {String} autoEl @hide
  719. */
  720. <span id='Ext-Button-cfg-html'> /**
  721. </span> * @cfg {String/Object} html @hide
  722. */
  723. <span id='Ext-Button-cfg-contentEl'> /**
  724. </span> * @cfg {String} contentEl @hide
  725. */
  726. <span id='Ext-Button-cfg-data'> /**
  727. </span> * @cfg {Mixed} data @hide
  728. */
  729. <span id='Ext-Button-cfg-tpl'> /**
  730. </span> * @cfg {Mixed} tpl @hide
  731. */
  732. <span id='Ext-Button-cfg-tplWriteMode'> /**
  733. </span> * @cfg {String} tplWriteMode @hide
  734. */
  735. });
  736. Ext.reg('button', Ext.Button);
  737. // Private utility class used by Button
  738. Ext.ButtonToggleMgr = function(){
  739. var groups = {};
  740. function toggleGroup(btn, state){
  741. if(state){
  742. var g = groups[btn.toggleGroup];
  743. for(var i = 0, l = g.length; i &lt; l; i++){
  744. if(g[i] != btn){
  745. g[i].toggle(false);
  746. }
  747. }
  748. }
  749. }
  750. return {
  751. register : function(btn){
  752. if(!btn.toggleGroup){
  753. return;
  754. }
  755. var g = groups[btn.toggleGroup];
  756. if(!g){
  757. g = groups[btn.toggleGroup] = [];
  758. }
  759. g.push(btn);
  760. btn.on('toggle', toggleGroup);
  761. },
  762. unregister : function(btn){
  763. if(!btn.toggleGroup){
  764. return;
  765. }
  766. var g = groups[btn.toggleGroup];
  767. if(g){
  768. g.remove(btn);
  769. btn.un('toggle', toggleGroup);
  770. }
  771. },
  772. <span id='Ext-Button-method-getPressed'> /**
  773. </span> * Gets the pressed button in the passed group or null
  774. * @param {String} group
  775. * @return Button
  776. */
  777. getPressed : function(group){
  778. var g = groups[group];
  779. if(g){
  780. for(var i = 0, len = g.length; i &lt; len; i++){
  781. if(g[i].pressed === true){
  782. return g[i];
  783. }
  784. }
  785. }
  786. return null;
  787. }
  788. };
  789. }();
  790. </pre>
  791. </body>
  792. </html>