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.

1040 lines
46 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-Element-method-constructor'><span id='Ext-Element'>/**
  19. </span></span> * @class Ext.Element
  20. * &lt;p&gt;Encapsulates a DOM element, adding simple DOM manipulation facilities, normalizing for browser differences.&lt;/p&gt;
  21. * &lt;p&gt;All instances of this class inherit the methods of {@link Ext.Fx} making visual effects easily available to all DOM elements.&lt;/p&gt;
  22. * &lt;p&gt;Note that the events documented in this class are not Ext events, they encapsulate browser events. To
  23. * access the underlying browser event, see {@link Ext.EventObject#browserEvent}. Some older
  24. * browsers may not support the full range of events. Which events are supported is beyond the control of ExtJs.&lt;/p&gt;
  25. * Usage:&lt;br&gt;
  26. &lt;pre&gt;&lt;code&gt;
  27. // by id
  28. var el = Ext.get(&quot;my-div&quot;);
  29. // by DOM element reference
  30. var el = Ext.get(myDivElement);
  31. &lt;/code&gt;&lt;/pre&gt;
  32. * &lt;b&gt;Animations&lt;/b&gt;&lt;br /&gt;
  33. * &lt;p&gt;When an element is manipulated, by default there is no animation.&lt;/p&gt;
  34. * &lt;pre&gt;&lt;code&gt;
  35. var el = Ext.get(&quot;my-div&quot;);
  36. // no animation
  37. el.setWidth(100);
  38. * &lt;/code&gt;&lt;/pre&gt;
  39. * &lt;p&gt;Many of the functions for manipulating an element have an optional &quot;animate&quot; parameter. This
  40. * parameter can be specified as boolean (&lt;tt&gt;true&lt;/tt&gt;) for default animation effects.&lt;/p&gt;
  41. * &lt;pre&gt;&lt;code&gt;
  42. // default animation
  43. el.setWidth(100, true);
  44. * &lt;/code&gt;&lt;/pre&gt;
  45. *
  46. * &lt;p&gt;To configure the effects, an object literal with animation options to use as the Element animation
  47. * configuration object can also be specified. Note that the supported Element animation configuration
  48. * options are a subset of the {@link Ext.Fx} animation options specific to Fx effects. The supported
  49. * Element animation configuration options are:&lt;/p&gt;
  50. &lt;pre&gt;
  51. Option Default Description
  52. --------- -------- ---------------------------------------------
  53. {@link Ext.Fx#duration duration} .35 The duration of the animation in seconds
  54. {@link Ext.Fx#easing easing} easeOut The easing method
  55. {@link Ext.Fx#callback callback} none A function to execute when the anim completes
  56. {@link Ext.Fx#scope scope} this The scope (this) of the callback function
  57. &lt;/pre&gt;
  58. *
  59. * &lt;pre&gt;&lt;code&gt;
  60. // Element animation options object
  61. var opt = {
  62. {@link Ext.Fx#duration duration}: 1,
  63. {@link Ext.Fx#easing easing}: 'elasticIn',
  64. {@link Ext.Fx#callback callback}: this.foo,
  65. {@link Ext.Fx#scope scope}: this
  66. };
  67. // animation with some options set
  68. el.setWidth(100, opt);
  69. * &lt;/code&gt;&lt;/pre&gt;
  70. * &lt;p&gt;The Element animation object being used for the animation will be set on the options
  71. * object as &quot;anim&quot;, which allows you to stop or manipulate the animation. Here is an example:&lt;/p&gt;
  72. * &lt;pre&gt;&lt;code&gt;
  73. // using the &quot;anim&quot; property to get the Anim object
  74. if(opt.anim.isAnimated()){
  75. opt.anim.stop();
  76. }
  77. * &lt;/code&gt;&lt;/pre&gt;
  78. * &lt;p&gt;Also see the &lt;tt&gt;{@link #animate}&lt;/tt&gt; method for another animation technique.&lt;/p&gt;
  79. * &lt;p&gt;&lt;b&gt; Composite (Collections of) Elements&lt;/b&gt;&lt;/p&gt;
  80. * &lt;p&gt;For working with collections of Elements, see {@link Ext.CompositeElement}&lt;/p&gt;
  81. * @constructor Create a new Element directly.
  82. * @param {String/HTMLElement} element
  83. * @param {Boolean} forceNew (optional) By default the constructor checks to see if there is already an instance of this element in the cache and if there is it returns the same instance. This will skip that check (useful for extending this class).
  84. */
  85. (function(){
  86. var DOC = document;
  87. Ext.Element = function(element, forceNew){
  88. var dom = typeof element == &quot;string&quot; ?
  89. DOC.getElementById(element) : element,
  90. id;
  91. if(!dom) return null;
  92. id = dom.id;
  93. if(!forceNew &amp;&amp; id &amp;&amp; Ext.elCache[id]){ // element object already exists
  94. return Ext.elCache[id].el;
  95. }
  96. <span id='Ext-Element-property-dom'> /**
  97. </span> * The DOM element
  98. * @type HTMLElement
  99. */
  100. this.dom = dom;
  101. <span id='Ext-Element-property-id'> /**
  102. </span> * The DOM element ID
  103. * @type String
  104. */
  105. this.id = id || Ext.id(dom);
  106. };
  107. var DH = Ext.DomHelper,
  108. El = Ext.Element,
  109. EC = Ext.elCache;
  110. El.prototype = {
  111. <span id='Ext-Element-method-set'> /**
  112. </span> * Sets the passed attributes as attributes of this element (a style attribute can be a string, object or function)
  113. * @param {Object} o The object with the attributes
  114. * @param {Boolean} useSet (optional) false to override the default setAttribute to use expandos.
  115. * @return {Ext.Element} this
  116. */
  117. set : function(o, useSet){
  118. var el = this.dom,
  119. attr,
  120. val,
  121. useSet = (useSet !== false) &amp;&amp; !!el.setAttribute;
  122. for (attr in o) {
  123. if (o.hasOwnProperty(attr)) {
  124. val = o[attr];
  125. if (attr == 'style') {
  126. DH.applyStyles(el, val);
  127. } else if (attr == 'cls') {
  128. el.className = val;
  129. } else if (useSet) {
  130. el.setAttribute(attr, val);
  131. } else {
  132. el[attr] = val;
  133. }
  134. }
  135. }
  136. return this;
  137. },
  138. // Mouse events
  139. <span id='Ext-Element-event-click'> /**
  140. </span> * @event click
  141. * Fires when a mouse click is detected within the element.
  142. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  143. * @param {HtmlElement} t The target of the event.
  144. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  145. */
  146. <span id='Ext-Element-event-contextmenu'> /**
  147. </span> * @event contextmenu
  148. * Fires when a right click is detected within the element.
  149. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  150. * @param {HtmlElement} t The target of the event.
  151. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  152. */
  153. <span id='Ext-Element-event-dblclick'> /**
  154. </span> * @event dblclick
  155. * Fires when a mouse double click is detected within the element.
  156. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  157. * @param {HtmlElement} t The target of the event.
  158. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  159. */
  160. <span id='Ext-Element-event-mousedown'> /**
  161. </span> * @event mousedown
  162. * Fires when a mousedown is detected within the element.
  163. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  164. * @param {HtmlElement} t The target of the event.
  165. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  166. */
  167. <span id='Ext-Element-event-mouseup'> /**
  168. </span> * @event mouseup
  169. * Fires when a mouseup is detected within the element.
  170. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  171. * @param {HtmlElement} t The target of the event.
  172. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  173. */
  174. <span id='Ext-Element-event-mouseover'> /**
  175. </span> * @event mouseover
  176. * Fires when a mouseover is detected within the element.
  177. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  178. * @param {HtmlElement} t The target of the event.
  179. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  180. */
  181. <span id='Ext-Element-event-mousemove'> /**
  182. </span> * @event mousemove
  183. * Fires when a mousemove is detected with the element.
  184. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  185. * @param {HtmlElement} t The target of the event.
  186. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  187. */
  188. <span id='Ext-Element-event-mouseout'> /**
  189. </span> * @event mouseout
  190. * Fires when a mouseout is detected with the element.
  191. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  192. * @param {HtmlElement} t The target of the event.
  193. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  194. */
  195. <span id='Ext-Element-event-mouseenter'> /**
  196. </span> * @event mouseenter
  197. * Fires when the mouse enters the element.
  198. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  199. * @param {HtmlElement} t The target of the event.
  200. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  201. */
  202. <span id='Ext-Element-event-mouseleave'> /**
  203. </span> * @event mouseleave
  204. * Fires when the mouse leaves the element.
  205. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  206. * @param {HtmlElement} t The target of the event.
  207. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  208. */
  209. // Keyboard events
  210. <span id='Ext-Element-event-keypress'> /**
  211. </span> * @event keypress
  212. * Fires when a keypress is detected within the element.
  213. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  214. * @param {HtmlElement} t The target of the event.
  215. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  216. */
  217. <span id='Ext-Element-event-keydown'> /**
  218. </span> * @event keydown
  219. * Fires when a keydown is detected within the element.
  220. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  221. * @param {HtmlElement} t The target of the event.
  222. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  223. */
  224. <span id='Ext-Element-event-keyup'> /**
  225. </span> * @event keyup
  226. * Fires when a keyup is detected within the element.
  227. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  228. * @param {HtmlElement} t The target of the event.
  229. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  230. */
  231. // HTML frame/object events
  232. <span id='Ext-Element-event-load'> /**
  233. </span> * @event load
  234. * Fires when the user agent finishes loading all content within the element. Only supported by window, frames, objects and images.
  235. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  236. * @param {HtmlElement} t The target of the event.
  237. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  238. */
  239. <span id='Ext-Element-event-unload'> /**
  240. </span> * @event unload
  241. * Fires when the user agent removes all content from a window or frame. For elements, it fires when the target element or any of its content has been removed.
  242. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  243. * @param {HtmlElement} t The target of the event.
  244. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  245. */
  246. <span id='Ext-Element-event-abort'> /**
  247. </span> * @event abort
  248. * Fires when an object/image is stopped from loading before completely loaded.
  249. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  250. * @param {HtmlElement} t The target of the event.
  251. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  252. */
  253. <span id='Ext-Element-event-error'> /**
  254. </span> * @event error
  255. * Fires when an object/image/frame cannot be loaded properly.
  256. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  257. * @param {HtmlElement} t The target of the event.
  258. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  259. */
  260. <span id='Ext-Element-event-resize'> /**
  261. </span> * @event resize
  262. * Fires when a document view is resized.
  263. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  264. * @param {HtmlElement} t The target of the event.
  265. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  266. */
  267. <span id='Ext-Element-event-scroll'> /**
  268. </span> * @event scroll
  269. * Fires when a document view is scrolled.
  270. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  271. * @param {HtmlElement} t The target of the event.
  272. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  273. */
  274. // Form events
  275. <span id='Ext-Element-event-select'> /**
  276. </span> * @event select
  277. * Fires when a user selects some text in a text field, including input and textarea.
  278. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  279. * @param {HtmlElement} t The target of the event.
  280. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  281. */
  282. <span id='Ext-Element-event-change'> /**
  283. </span> * @event change
  284. * Fires when a control loses the input focus and its value has been modified since gaining focus.
  285. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  286. * @param {HtmlElement} t The target of the event.
  287. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  288. */
  289. <span id='Ext-Element-event-submit'> /**
  290. </span> * @event submit
  291. * Fires when a form is submitted.
  292. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  293. * @param {HtmlElement} t The target of the event.
  294. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  295. */
  296. <span id='Ext-Element-event-reset'> /**
  297. </span> * @event reset
  298. * Fires when a form is reset.
  299. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  300. * @param {HtmlElement} t The target of the event.
  301. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  302. */
  303. <span id='Ext-Element-event-focus'> /**
  304. </span> * @event focus
  305. * Fires when an element receives focus either via the pointing device or by tab navigation.
  306. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  307. * @param {HtmlElement} t The target of the event.
  308. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  309. */
  310. <span id='Ext-Element-event-blur'> /**
  311. </span> * @event blur
  312. * Fires when an element loses focus either via the pointing device or by tabbing navigation.
  313. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  314. * @param {HtmlElement} t The target of the event.
  315. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  316. */
  317. // User Interface events
  318. <span id='Ext-Element-event-DOMFocusIn'> /**
  319. </span> * @event DOMFocusIn
  320. * Where supported. Similar to HTML focus event, but can be applied to any focusable element.
  321. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  322. * @param {HtmlElement} t The target of the event.
  323. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  324. */
  325. <span id='Ext-Element-event-DOMFocusOut'> /**
  326. </span> * @event DOMFocusOut
  327. * Where supported. Similar to HTML blur event, but can be applied to any focusable element.
  328. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  329. * @param {HtmlElement} t The target of the event.
  330. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  331. */
  332. <span id='Ext-Element-event-DOMActivate'> /**
  333. </span> * @event DOMActivate
  334. * Where supported. Fires when an element is activated, for instance, through a mouse click or a keypress.
  335. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  336. * @param {HtmlElement} t The target of the event.
  337. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  338. */
  339. // DOM Mutation events
  340. <span id='Ext-Element-event-DOMSubtreeModified'> /**
  341. </span> * @event DOMSubtreeModified
  342. * Where supported. Fires when the subtree is modified.
  343. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  344. * @param {HtmlElement} t The target of the event.
  345. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  346. */
  347. <span id='Ext-Element-event-DOMNodeInserted'> /**
  348. </span> * @event DOMNodeInserted
  349. * Where supported. Fires when a node has been added as a child of another node.
  350. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  351. * @param {HtmlElement} t The target of the event.
  352. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  353. */
  354. <span id='Ext-Element-event-DOMNodeRemoved'> /**
  355. </span> * @event DOMNodeRemoved
  356. * Where supported. Fires when a descendant node of the element is removed.
  357. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  358. * @param {HtmlElement} t The target of the event.
  359. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  360. */
  361. <span id='Ext-Element-event-DOMNodeRemovedFromDocument'> /**
  362. </span> * @event DOMNodeRemovedFromDocument
  363. * Where supported. Fires when a node is being removed from a document.
  364. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  365. * @param {HtmlElement} t The target of the event.
  366. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  367. */
  368. <span id='Ext-Element-event-DOMNodeInsertedIntoDocument'> /**
  369. </span> * @event DOMNodeInsertedIntoDocument
  370. * Where supported. Fires when a node is being inserted into a document.
  371. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  372. * @param {HtmlElement} t The target of the event.
  373. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  374. */
  375. <span id='Ext-Element-event-DOMAttrModified'> /**
  376. </span> * @event DOMAttrModified
  377. * Where supported. Fires when an attribute has been modified.
  378. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  379. * @param {HtmlElement} t The target of the event.
  380. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  381. */
  382. <span id='Ext-Element-event-DOMCharacterDataModified'> /**
  383. </span> * @event DOMCharacterDataModified
  384. * Where supported. Fires when the character data has been modified.
  385. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  386. * @param {HtmlElement} t The target of the event.
  387. * @param {Object} o The options configuration passed to the {@link #addListener} call.
  388. */
  389. <span id='Ext-Element-property-defaultUnit'> /**
  390. </span> * The default unit to append to CSS values where a unit isn't provided (defaults to px).
  391. * @type String
  392. */
  393. defaultUnit : &quot;px&quot;,
  394. <span id='Ext-Element-method-is'> /**
  395. </span> * Returns true if this element matches the passed simple selector (e.g. div.some-class or span:first-child)
  396. * @param {String} selector The simple selector to test
  397. * @return {Boolean} True if this element matches the selector, else false
  398. */
  399. is : function(simpleSelector){
  400. return Ext.DomQuery.is(this.dom, simpleSelector);
  401. },
  402. <span id='Ext-Element-method-focus'> /**
  403. </span> * Tries to focus the element. Any exceptions are caught and ignored.
  404. * @param {Number} defer (optional) Milliseconds to defer the focus
  405. * @return {Ext.Element} this
  406. */
  407. focus : function(defer, /* private */ dom) {
  408. var me = this,
  409. dom = dom || me.dom;
  410. try{
  411. if(Number(defer)){
  412. me.focus.defer(defer, null, [null, dom]);
  413. }else{
  414. dom.focus();
  415. }
  416. }catch(e){}
  417. return me;
  418. },
  419. <span id='Ext-Element-method-blur'> /**
  420. </span> * Tries to blur the element. Any exceptions are caught and ignored.
  421. * @return {Ext.Element} this
  422. */
  423. blur : function() {
  424. try{
  425. this.dom.blur();
  426. }catch(e){}
  427. return this;
  428. },
  429. <span id='Ext-Element-method-getValue'> /**
  430. </span> * Returns the value of the &quot;value&quot; attribute
  431. * @param {Boolean} asNumber true to parse the value as a number
  432. * @return {String/Number}
  433. */
  434. getValue : function(asNumber){
  435. var val = this.dom.value;
  436. return asNumber ? parseInt(val, 10) : val;
  437. },
  438. <span id='Ext-Element-method-addListener'> /**
  439. </span> * Appends an event handler to this element. The shorthand version {@link #on} is equivalent.
  440. * @param {String} eventName The name of event to handle.
  441. * @param {Function} fn The handler function the event invokes. This function is passed
  442. * the following parameters:&lt;ul&gt;
  443. * &lt;li&gt;&lt;b&gt;evt&lt;/b&gt; : EventObject&lt;div class=&quot;sub-desc&quot;&gt;The {@link Ext.EventObject EventObject} describing the event.&lt;/div&gt;&lt;/li&gt;
  444. * &lt;li&gt;&lt;b&gt;el&lt;/b&gt; : HtmlElement&lt;div class=&quot;sub-desc&quot;&gt;The DOM element which was the target of the event.
  445. * Note that this may be filtered by using the &lt;tt&gt;delegate&lt;/tt&gt; option.&lt;/div&gt;&lt;/li&gt;
  446. * &lt;li&gt;&lt;b&gt;o&lt;/b&gt; : Object&lt;div class=&quot;sub-desc&quot;&gt;The options object from the addListener call.&lt;/div&gt;&lt;/li&gt;
  447. * &lt;/ul&gt;
  448. * @param {Object} scope (optional) The scope (&lt;code&gt;&lt;b&gt;this&lt;/b&gt;&lt;/code&gt; reference) in which the handler function is executed.
  449. * &lt;b&gt;If omitted, defaults to this Element.&lt;/b&gt;.
  450. * @param {Object} options (optional) An object containing handler configuration properties.
  451. * This may contain any of the following properties:&lt;ul&gt;
  452. * &lt;li&gt;&lt;b&gt;scope&lt;/b&gt; Object : &lt;div class=&quot;sub-desc&quot;&gt;The scope (&lt;code&gt;&lt;b&gt;this&lt;/b&gt;&lt;/code&gt; reference) in which the handler function is executed.
  453. * &lt;b&gt;If omitted, defaults to this Element.&lt;/b&gt;&lt;/div&gt;&lt;/li&gt;
  454. * &lt;li&gt;&lt;b&gt;delegate&lt;/b&gt; String: &lt;div class=&quot;sub-desc&quot;&gt;A simple selector to filter the target or look for a descendant of the target. See below for additional details.&lt;/div&gt;&lt;/li&gt;
  455. * &lt;li&gt;&lt;b&gt;stopEvent&lt;/b&gt; Boolean: &lt;div class=&quot;sub-desc&quot;&gt;True to stop the event. That is stop propagation, and prevent the default action.&lt;/div&gt;&lt;/li&gt;
  456. * &lt;li&gt;&lt;b&gt;preventDefault&lt;/b&gt; Boolean: &lt;div class=&quot;sub-desc&quot;&gt;True to prevent the default action&lt;/div&gt;&lt;/li&gt;
  457. * &lt;li&gt;&lt;b&gt;stopPropagation&lt;/b&gt; Boolean: &lt;div class=&quot;sub-desc&quot;&gt;True to prevent event propagation&lt;/div&gt;&lt;/li&gt;
  458. * &lt;li&gt;&lt;b&gt;normalized&lt;/b&gt; Boolean: &lt;div class=&quot;sub-desc&quot;&gt;False to pass a browser event to the handler function instead of an Ext.EventObject&lt;/div&gt;&lt;/li&gt;
  459. * &lt;li&gt;&lt;b&gt;target&lt;/b&gt; Ext.Element: &lt;div class=&quot;sub-desc&quot;&gt;Only call the handler if the event was fired on the target Element, &lt;i&gt;not&lt;/i&gt; if the event was bubbled up from a child node.&lt;/div&gt;&lt;/li&gt;
  460. * &lt;li&gt;&lt;b&gt;delay&lt;/b&gt; Number: &lt;div class=&quot;sub-desc&quot;&gt;The number of milliseconds to delay the invocation of the handler after the event fires.&lt;/div&gt;&lt;/li&gt;
  461. * &lt;li&gt;&lt;b&gt;single&lt;/b&gt; Boolean: &lt;div class=&quot;sub-desc&quot;&gt;True to add a handler to handle just the next firing of the event, and then remove itself.&lt;/div&gt;&lt;/li&gt;
  462. * &lt;li&gt;&lt;b&gt;buffer&lt;/b&gt; Number: &lt;div class=&quot;sub-desc&quot;&gt;Causes the handler to be scheduled to run in an {@link Ext.util.DelayedTask} delayed
  463. * by the specified number of milliseconds. If the event fires again within that time, the original
  464. * handler is &lt;em&gt;not&lt;/em&gt; invoked, but the new handler is scheduled in its place.&lt;/div&gt;&lt;/li&gt;
  465. * &lt;/ul&gt;&lt;br&gt;
  466. * &lt;p&gt;
  467. * &lt;b&gt;Combining Options&lt;/b&gt;&lt;br&gt;
  468. * In the following examples, the shorthand form {@link #on} is used rather than the more verbose
  469. * addListener. The two are equivalent. Using the options argument, it is possible to combine different
  470. * types of listeners:&lt;br&gt;
  471. * &lt;br&gt;
  472. * A delayed, one-time listener that auto stops the event and adds a custom argument (forumId) to the
  473. * options object. The options object is available as the third parameter in the handler function.&lt;div style=&quot;margin: 5px 20px 20px;&quot;&gt;
  474. * Code:&lt;pre&gt;&lt;code&gt;
  475. el.on('click', this.onClick, this, {
  476. single: true,
  477. delay: 100,
  478. stopEvent : true,
  479. forumId: 4
  480. });&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;
  481. * &lt;p&gt;
  482. * &lt;b&gt;Attaching multiple handlers in 1 call&lt;/b&gt;&lt;br&gt;
  483. * The method also allows for a single argument to be passed which is a config object containing properties
  484. * which specify multiple handlers.&lt;/p&gt;
  485. * &lt;p&gt;
  486. * Code:&lt;pre&gt;&lt;code&gt;
  487. el.on({
  488. 'click' : {
  489. fn: this.onClick,
  490. scope: this,
  491. delay: 100
  492. },
  493. 'mouseover' : {
  494. fn: this.onMouseOver,
  495. scope: this
  496. },
  497. 'mouseout' : {
  498. fn: this.onMouseOut,
  499. scope: this
  500. }
  501. });&lt;/code&gt;&lt;/pre&gt;
  502. * &lt;p&gt;
  503. * Or a shorthand syntax:&lt;br&gt;
  504. * Code:&lt;pre&gt;&lt;code&gt;&lt;/p&gt;
  505. el.on({
  506. 'click' : this.onClick,
  507. 'mouseover' : this.onMouseOver,
  508. 'mouseout' : this.onMouseOut,
  509. scope: this
  510. });
  511. * &lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;
  512. * &lt;p&gt;&lt;b&gt;delegate&lt;/b&gt;&lt;/p&gt;
  513. * &lt;p&gt;This is a configuration option that you can pass along when registering a handler for
  514. * an event to assist with event delegation. Event delegation is a technique that is used to
  515. * reduce memory consumption and prevent exposure to memory-leaks. By registering an event
  516. * for a container element as opposed to each element within a container. By setting this
  517. * configuration option to a simple selector, the target element will be filtered to look for
  518. * a descendant of the target.
  519. * For example:&lt;pre&gt;&lt;code&gt;
  520. // using this markup:
  521. &amp;lt;div id='elId'&gt;
  522. &amp;lt;p id='p1'&gt;paragraph one&amp;lt;/p&gt;
  523. &amp;lt;p id='p2' class='clickable'&gt;paragraph two&amp;lt;/p&gt;
  524. &amp;lt;p id='p3'&gt;paragraph three&amp;lt;/p&gt;
  525. &amp;lt;/div&gt;
  526. // utilize event delegation to registering just one handler on the container element:
  527. el = Ext.get('elId');
  528. el.on(
  529. 'click',
  530. function(e,t) {
  531. // handle click
  532. console.info(t.id); // 'p2'
  533. },
  534. this,
  535. {
  536. // filter the target element to be a descendant with the class 'clickable'
  537. delegate: '.clickable'
  538. }
  539. );
  540. * &lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;
  541. * @return {Ext.Element} this
  542. */
  543. addListener : function(eventName, fn, scope, options){
  544. Ext.EventManager.on(this.dom, eventName, fn, scope || this, options);
  545. return this;
  546. },
  547. <span id='Ext-Element-method-removeListener'> /**
  548. </span> * Removes an event handler from this element. The shorthand version {@link #un} is equivalent.
  549. * &lt;b&gt;Note&lt;/b&gt;: if a &lt;i&gt;scope&lt;/i&gt; was explicitly specified when {@link #addListener adding} the
  550. * listener, the same scope must be specified here.
  551. * Example:
  552. * &lt;pre&gt;&lt;code&gt;
  553. el.removeListener('click', this.handlerFn);
  554. // or
  555. el.un('click', this.handlerFn);
  556. &lt;/code&gt;&lt;/pre&gt;
  557. * @param {String} eventName The name of the event from which to remove the handler.
  558. * @param {Function} fn The handler function to remove. &lt;b&gt;This must be a reference to the function passed into the {@link #addListener} call.&lt;/b&gt;
  559. * @param {Object} scope If a scope (&lt;b&gt;&lt;code&gt;this&lt;/code&gt;&lt;/b&gt; reference) was specified when the listener was added,
  560. * then this must refer to the same object.
  561. * @return {Ext.Element} this
  562. */
  563. removeListener : function(eventName, fn, scope){
  564. Ext.EventManager.removeListener(this.dom, eventName, fn, scope || this);
  565. return this;
  566. },
  567. <span id='Ext-Element-method-removeAllListeners'> /**
  568. </span> * Removes all previous added listeners from this element
  569. * @return {Ext.Element} this
  570. */
  571. removeAllListeners : function(){
  572. Ext.EventManager.removeAll(this.dom);
  573. return this;
  574. },
  575. <span id='Ext-Element-method-purgeAllListeners'> /**
  576. </span> * Recursively removes all previous added listeners from this element and its children
  577. * @return {Ext.Element} this
  578. */
  579. purgeAllListeners : function() {
  580. Ext.EventManager.purgeElement(this, true);
  581. return this;
  582. },
  583. <span id='Ext-Element-method-addUnits'> /**
  584. </span> * @private Test if size has a unit, otherwise appends the default
  585. */
  586. addUnits : function(size){
  587. if(size === &quot;&quot; || size == &quot;auto&quot; || size === undefined){
  588. size = size || '';
  589. } else if(!isNaN(size) || !unitPattern.test(size)){
  590. size = size + (this.defaultUnit || 'px');
  591. }
  592. return size;
  593. },
  594. <span id='Ext-Element-method-load'> /**
  595. </span> * &lt;p&gt;Updates the &lt;a href=&quot;http://developer.mozilla.org/en/DOM/element.innerHTML&quot;&gt;innerHTML&lt;/a&gt; of this Element
  596. * from a specified URL. Note that this is subject to the &lt;a href=&quot;http://en.wikipedia.org/wiki/Same_origin_policy&quot;&gt;Same Origin Policy&lt;/a&gt;&lt;/p&gt;
  597. * &lt;p&gt;Updating innerHTML of an element will &lt;b&gt;not&lt;/b&gt; execute embedded &lt;tt&gt;&amp;lt;script&gt;&lt;/tt&gt; elements. This is a browser restriction.&lt;/p&gt;
  598. * @param {Mixed} options. Either a sring containing the URL from which to load the HTML, or an {@link Ext.Ajax#request} options object specifying
  599. * exactly how to request the HTML.
  600. * @return {Ext.Element} this
  601. */
  602. load : function(url, params, cb){
  603. Ext.Ajax.request(Ext.apply({
  604. params: params,
  605. url: url.url || url,
  606. callback: cb,
  607. el: this.dom,
  608. indicatorText: url.indicatorText || ''
  609. }, Ext.isObject(url) ? url : {}));
  610. return this;
  611. },
  612. <span id='Ext-Element-method-isBorderBox'> /**
  613. </span> * Tests various css rules/browsers to determine if this element uses a border box
  614. * @return {Boolean}
  615. */
  616. isBorderBox : function(){
  617. return Ext.isBorderBox || Ext.isForcedBorderBox || noBoxAdjust[(this.dom.tagName || &quot;&quot;).toLowerCase()];
  618. },
  619. <span id='Ext-Element-method-remove'> /**
  620. </span> * &lt;p&gt;Removes this element's dom reference. Note that event and cache removal is handled at {@link Ext#removeNode}&lt;/p&gt;
  621. */
  622. remove : function(){
  623. var me = this,
  624. dom = me.dom;
  625. if (dom) {
  626. delete me.dom;
  627. Ext.removeNode(dom);
  628. }
  629. },
  630. <span id='Ext-Element-method-hover'> /**
  631. </span> * Sets up event handlers to call the passed functions when the mouse is moved into and out of the Element.
  632. * @param {Function} overFn The function to call when the mouse enters the Element.
  633. * @param {Function} outFn The function to call when the mouse leaves the Element.
  634. * @param {Object} scope (optional) The scope (&lt;code&gt;this&lt;/code&gt; reference) in which the functions are executed. Defaults to the Element's DOM element.
  635. * @param {Object} options (optional) Options for the listener. See {@link Ext.util.Observable#addListener the &lt;tt&gt;options&lt;/tt&gt; parameter}.
  636. * @return {Ext.Element} this
  637. */
  638. hover : function(overFn, outFn, scope, options){
  639. var me = this;
  640. me.on('mouseenter', overFn, scope || me.dom, options);
  641. me.on('mouseleave', outFn, scope || me.dom, options);
  642. return me;
  643. },
  644. <span id='Ext-Element-method-contains'> /**
  645. </span> * Returns true if this element is an ancestor of the passed element
  646. * @param {HTMLElement/String} el The element to check
  647. * @return {Boolean} True if this element is an ancestor of el, else false
  648. */
  649. contains : function(el){
  650. return !el ? false : Ext.lib.Dom.isAncestor(this.dom, el.dom ? el.dom : el);
  651. },
  652. <span id='Ext-Element-method-getAttributeNS'> /**
  653. </span> * Returns the value of a namespaced attribute from the element's underlying DOM node.
  654. * @param {String} namespace The namespace in which to look for the attribute
  655. * @param {String} name The attribute name
  656. * @return {String} The attribute value
  657. * @deprecated
  658. */
  659. getAttributeNS : function(ns, name){
  660. return this.getAttribute(name, ns);
  661. },
  662. <span id='Ext-Element-method-getAttribute'> /**
  663. </span> * Returns the value of an attribute from the element's underlying DOM node.
  664. * @param {String} name The attribute name
  665. * @param {String} namespace (optional) The namespace in which to look for the attribute
  666. * @return {String} The attribute value
  667. */
  668. getAttribute: (function(){
  669. var test = document.createElement('table'),
  670. isBrokenOnTable = false,
  671. hasGetAttribute = 'getAttribute' in test,
  672. unknownRe = /undefined|unknown/;
  673. if (hasGetAttribute) {
  674. try {
  675. test.getAttribute('ext:qtip');
  676. } catch (e) {
  677. isBrokenOnTable = true;
  678. }
  679. return function(name, ns) {
  680. var el = this.dom,
  681. value;
  682. if (el.getAttributeNS) {
  683. value = el.getAttributeNS(ns, name) || null;
  684. }
  685. if (value == null) {
  686. if (ns) {
  687. if (isBrokenOnTable &amp;&amp; el.tagName.toUpperCase() == 'TABLE') {
  688. try {
  689. value = el.getAttribute(ns + ':' + name);
  690. } catch (e) {
  691. value = '';
  692. }
  693. } else {
  694. value = el.getAttribute(ns + ':' + name);
  695. }
  696. } else {
  697. value = el.getAttribute(name) || el[name];
  698. }
  699. }
  700. return value || '';
  701. };
  702. } else {
  703. return function(name, ns) {
  704. var el = this.om,
  705. value,
  706. attribute;
  707. if (ns) {
  708. attribute = el[ns + ':' + name];
  709. value = unknownRe.test(typeof attribute) ? undefined : attribute;
  710. } else {
  711. value = el[name];
  712. }
  713. return value || '';
  714. };
  715. }
  716. test = null;
  717. })(),
  718. <span id='Ext-Element-method-update'> /**
  719. </span> * Update the innerHTML of this element
  720. * @param {String} html The new HTML
  721. * @return {Ext.Element} this
  722. */
  723. update : function(html) {
  724. if (this.dom) {
  725. this.dom.innerHTML = html;
  726. }
  727. return this;
  728. }
  729. };
  730. var ep = El.prototype;
  731. El.addMethods = function(o){
  732. Ext.apply(ep, o);
  733. };
  734. <span id='Ext-Element-method-on'>/**
  735. </span> * Appends an event handler (shorthand for {@link #addListener}).
  736. * @param {String} eventName The name of event to handle.
  737. * @param {Function} fn The handler function the event invokes.
  738. * @param {Object} scope (optional) The scope (&lt;code&gt;this&lt;/code&gt; reference) in which the handler function is executed.
  739. * @param {Object} options (optional) An object containing standard {@link #addListener} options
  740. * @member Ext.Element
  741. * @method on
  742. */
  743. ep.on = ep.addListener;
  744. <span id='Ext-Element-method-un'>/**
  745. </span> * Removes an event handler from this element (see {@link #removeListener} for additional notes).
  746. * @param {String} eventName The name of the event from which to remove the handler.
  747. * @param {Function} fn The handler function to remove. &lt;b&gt;This must be a reference to the function passed into the {@link #addListener} call.&lt;/b&gt;
  748. * @param {Object} scope If a scope (&lt;b&gt;&lt;code&gt;this&lt;/code&gt;&lt;/b&gt; reference) was specified when the listener was added,
  749. * then this must refer to the same object.
  750. * @return {Ext.Element} this
  751. * @member Ext.Element
  752. * @method un
  753. */
  754. ep.un = ep.removeListener;
  755. <span id='Ext-Element-property-autoBoxAdjust'>/**
  756. </span> * true to automatically adjust width and height settings for box-model issues (default to true)
  757. */
  758. ep.autoBoxAdjust = true;
  759. // private
  760. var unitPattern = /\d+(px|em|%|en|ex|pt|in|cm|mm|pc)$/i,
  761. docEl;
  762. <span id='Ext-Element-static-method-get'>/**
  763. </span> * Retrieves Ext.Element objects.
  764. * &lt;p&gt;&lt;b&gt;This method does not retrieve {@link Ext.Component Component}s.&lt;/b&gt; This method
  765. * retrieves Ext.Element objects which encapsulate DOM elements. To retrieve a Component by
  766. * its ID, use {@link Ext.ComponentMgr#get}.&lt;/p&gt;
  767. * &lt;p&gt;Uses simple caching to consistently return the same object. Automatically fixes if an
  768. * object was recreated with the same id via AJAX or DOM.&lt;/p&gt;
  769. * @param {Mixed} el The id of the node, a DOM Node or an existing Element.
  770. * @return {Element} The Element object (or null if no matching element was found)
  771. * @static
  772. * @member Ext.Element
  773. * @method get
  774. */
  775. El.get = function(el){
  776. var ex,
  777. elm,
  778. id;
  779. if(!el){ return null; }
  780. if (typeof el == &quot;string&quot;) { // element id
  781. if (!(elm = DOC.getElementById(el))) {
  782. return null;
  783. }
  784. if (EC[el] &amp;&amp; EC[el].el) {
  785. ex = EC[el].el;
  786. ex.dom = elm;
  787. } else {
  788. ex = El.addToCache(new El(elm));
  789. }
  790. return ex;
  791. } else if (el.tagName) { // dom element
  792. if(!(id = el.id)){
  793. id = Ext.id(el);
  794. }
  795. if (EC[id] &amp;&amp; EC[id].el) {
  796. ex = EC[id].el;
  797. ex.dom = el;
  798. } else {
  799. ex = El.addToCache(new El(el));
  800. }
  801. return ex;
  802. } else if (el instanceof El) {
  803. if(el != docEl){
  804. // refresh dom element in case no longer valid,
  805. // catch case where it hasn't been appended
  806. // If an el instance is passed, don't pass to getElementById without some kind of id
  807. if (Ext.isIE &amp;&amp; (el.id == undefined || el.id == '')) {
  808. el.dom = el.dom;
  809. } else {
  810. el.dom = DOC.getElementById(el.id) || el.dom;
  811. }
  812. }
  813. return el;
  814. } else if(el.isComposite) {
  815. return el;
  816. } else if(Ext.isArray(el)) {
  817. return El.select(el);
  818. } else if(el == DOC) {
  819. // create a bogus element object representing the document object
  820. if(!docEl){
  821. var f = function(){};
  822. f.prototype = El.prototype;
  823. docEl = new f();
  824. docEl.dom = DOC;
  825. }
  826. return docEl;
  827. }
  828. return null;
  829. };
  830. El.addToCache = function(el, id){
  831. id = id || el.id;
  832. EC[id] = {
  833. el: el,
  834. data: {},
  835. events: {}
  836. };
  837. return el;
  838. };
  839. // private method for getting and setting element data
  840. El.data = function(el, key, value){
  841. el = El.get(el);
  842. if (!el) {
  843. return null;
  844. }
  845. var c = EC[el.id].data;
  846. if(arguments.length == 2){
  847. return c[key];
  848. }else{
  849. return (c[key] = value);
  850. }
  851. };
  852. // private
  853. // Garbage collection - uncache elements/purge listeners on orphaned elements
  854. // so we don't hold a reference and cause the browser to retain them
  855. function garbageCollect(){
  856. if(!Ext.enableGarbageCollector){
  857. clearInterval(El.collectorThreadId);
  858. } else {
  859. var eid,
  860. el,
  861. d,
  862. o;
  863. for(eid in EC){
  864. o = EC[eid];
  865. if(o.skipGC){
  866. Ext.EventManager.removeFromSpecialCache(o.el);
  867. continue;
  868. }
  869. el = o.el;
  870. d = el.dom;
  871. // -------------------------------------------------------
  872. // Determining what is garbage:
  873. // -------------------------------------------------------
  874. // !d
  875. // dom node is null, definitely garbage
  876. // -------------------------------------------------------
  877. // !d.parentNode
  878. // no parentNode == direct orphan, definitely garbage
  879. // -------------------------------------------------------
  880. // !d.offsetParent &amp;&amp; !document.getElementById(eid)
  881. // display none elements have no offsetParent so we will
  882. // also try to look it up by it's id. However, check
  883. // offsetParent first so we don't do unneeded lookups.
  884. // This enables collection of elements that are not orphans
  885. // directly, but somewhere up the line they have an orphan
  886. // parent.
  887. // -------------------------------------------------------
  888. if(!d || !d.parentNode || (!d.offsetParent &amp;&amp; !DOC.getElementById(eid))){
  889. if(Ext.enableListenerCollection){
  890. Ext.EventManager.removeAll(d);
  891. }
  892. delete EC[eid];
  893. }
  894. }
  895. // Cleanup IE Object leaks
  896. if (Ext.isIE) {
  897. var t = {};
  898. for (eid in EC) {
  899. t[eid] = EC[eid];
  900. }
  901. EC = Ext.elCache = t;
  902. }
  903. }
  904. }
  905. El.collectorThreadId = setInterval(garbageCollect, 30000);
  906. var flyFn = function(){};
  907. flyFn.prototype = El.prototype;
  908. // dom is optional
  909. El.Flyweight = function(dom){
  910. this.dom = dom;
  911. };
  912. El.Flyweight.prototype = new flyFn();
  913. El.Flyweight.prototype.isFlyweight = true;
  914. El._flyweights = {};
  915. <span id='Ext-Element-method-fly'>/**
  916. </span> * &lt;p&gt;Gets the globally shared flyweight Element, with the passed node as the active element. Do not store a reference to this element -
  917. * the dom node can be overwritten by other code. Shorthand of {@link Ext.Element#fly}&lt;/p&gt;
  918. * &lt;p&gt;Use this to make one-time references to DOM elements which are not going to be accessed again either by
  919. * application code, or by Ext's classes. If accessing an element which will be processed regularly, then {@link Ext#get}
  920. * will be more appropriate to take advantage of the caching provided by the Ext.Element class.&lt;/p&gt;
  921. * @param {String/HTMLElement} el The dom node or id
  922. * @param {String} named (optional) Allows for creation of named reusable flyweights to prevent conflicts
  923. * (e.g. internally Ext uses &quot;_global&quot;)
  924. * @return {Element} The shared Element object (or null if no matching element was found)
  925. * @member Ext.Element
  926. * @method fly
  927. */
  928. El.fly = function(el, named){
  929. var ret = null;
  930. named = named || '_global';
  931. if (el = Ext.getDom(el)) {
  932. (El._flyweights[named] = El._flyweights[named] || new El.Flyweight()).dom = el;
  933. ret = El._flyweights[named];
  934. }
  935. return ret;
  936. };
  937. <span id='Ext-method-get'>/**
  938. </span> * Retrieves Ext.Element objects.
  939. * &lt;p&gt;&lt;b&gt;This method does not retrieve {@link Ext.Component Component}s.&lt;/b&gt; This method
  940. * retrieves Ext.Element objects which encapsulate DOM elements. To retrieve a Component by
  941. * its ID, use {@link Ext.ComponentMgr#get}.&lt;/p&gt;
  942. * &lt;p&gt;Uses simple caching to consistently return the same object. Automatically fixes if an
  943. * object was recreated with the same id via AJAX or DOM.&lt;/p&gt;
  944. * Shorthand of {@link Ext.Element#get}
  945. * @param {Mixed} el The id of the node, a DOM Node or an existing Element.
  946. * @return {Element} The Element object (or null if no matching element was found)
  947. * @member Ext
  948. * @method get
  949. */
  950. Ext.get = El.get;
  951. <span id='Ext-method-fly'>/**
  952. </span> * &lt;p&gt;Gets the globally shared flyweight Element, with the passed node as the active element. Do not store a reference to this element -
  953. * the dom node can be overwritten by other code. Shorthand of {@link Ext.Element#fly}&lt;/p&gt;
  954. * &lt;p&gt;Use this to make one-time references to DOM elements which are not going to be accessed again either by
  955. * application code, or by Ext's classes. If accessing an element which will be processed regularly, then {@link Ext#get}
  956. * will be more appropriate to take advantage of the caching provided by the Ext.Element class.&lt;/p&gt;
  957. * @param {String/HTMLElement} el The dom node or id
  958. * @param {String} named (optional) Allows for creation of named reusable flyweights to prevent conflicts
  959. * (e.g. internally Ext uses &quot;_global&quot;)
  960. * @return {Element} The shared Element object (or null if no matching element was found)
  961. * @member Ext
  962. * @method fly
  963. */
  964. Ext.fly = El.fly;
  965. // speedy lookup for elements never to box adjust
  966. var noBoxAdjust = Ext.isStrict ? {
  967. select:1
  968. } : {
  969. input:1, select:1, textarea:1
  970. };
  971. if(Ext.isIE || Ext.isGecko){
  972. noBoxAdjust['button'] = 1;
  973. }
  974. })();
  975. </pre>
  976. </body>
  977. </html>