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.

214 lines
7.7 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'>/**
  19. </span> * @class Ext.Element
  20. */
  21. Ext.Element.addMethods({
  22. <span id='Ext-Element-method-swallowEvent'> /**
  23. </span> * Stops the specified event(s) from bubbling and optionally prevents the default action
  24. * @param {String/Array} eventName an event / array of events to stop from bubbling
  25. * @param {Boolean} preventDefault (optional) true to prevent the default action too
  26. * @return {Ext.Element} this
  27. */
  28. swallowEvent : function(eventName, preventDefault) {
  29. var me = this;
  30. function fn(e) {
  31. e.stopPropagation();
  32. if (preventDefault) {
  33. e.preventDefault();
  34. }
  35. }
  36. if (Ext.isArray(eventName)) {
  37. Ext.each(eventName, function(e) {
  38. me.on(e, fn);
  39. });
  40. return me;
  41. }
  42. me.on(eventName, fn);
  43. return me;
  44. },
  45. <span id='Ext-Element-method-relayEvent'> /**
  46. </span> * Create an event handler on this element such that when the event fires and is handled by this element,
  47. * it will be relayed to another object (i.e., fired again as if it originated from that object instead).
  48. * @param {String} eventName The type of event to relay
  49. * @param {Object} object Any object that extends {@link Ext.util.Observable} that will provide the context
  50. * for firing the relayed event
  51. */
  52. relayEvent : function(eventName, observable) {
  53. this.on(eventName, function(e) {
  54. observable.fireEvent(eventName, e);
  55. });
  56. },
  57. <span id='Ext-Element-method-clean'> /**
  58. </span> * Removes worthless text nodes
  59. * @param {Boolean} forceReclean (optional) By default the element
  60. * keeps track if it has been cleaned already so
  61. * you can call this over and over. However, if you update the element and
  62. * need to force a reclean, you can pass true.
  63. */
  64. clean : function(forceReclean) {
  65. var me = this,
  66. dom = me.dom,
  67. n = dom.firstChild,
  68. ni = -1;
  69. if (Ext.Element.data(dom, 'isCleaned') &amp;&amp; forceReclean !== true) {
  70. return me;
  71. }
  72. while (n) {
  73. var nx = n.nextSibling;
  74. if (n.nodeType == 3 &amp;&amp; !(/\S/.test(n.nodeValue))) {
  75. dom.removeChild(n);
  76. } else {
  77. n.nodeIndex = ++ni;
  78. }
  79. n = nx;
  80. }
  81. Ext.Element.data(dom, 'isCleaned', true);
  82. return me;
  83. },
  84. <span id='Ext-Element-method-load'> /**
  85. </span> * Direct access to the Updater {@link Ext.Updater#update} method. The method takes the same object
  86. * parameter as {@link Ext.Updater#update}
  87. * @return {Ext.Element} this
  88. */
  89. load : function() {
  90. var updateManager = this.getUpdater();
  91. updateManager.update.apply(updateManager, arguments);
  92. return this;
  93. },
  94. <span id='Ext-Element-method-getUpdater'> /**
  95. </span> * Gets this element's {@link Ext.Updater Updater}
  96. * @return {Ext.Updater} The Updater
  97. */
  98. getUpdater : function() {
  99. return this.updateManager || (this.updateManager = new Ext.Updater(this));
  100. },
  101. <span id='Ext-Element-method-update'> /**
  102. </span> * Update the innerHTML of this element, optionally searching for and processing scripts
  103. * @param {String} html The new HTML
  104. * @param {Boolean} loadScripts (optional) True to look for and process scripts (defaults to false)
  105. * @param {Function} callback (optional) For async script loading you can be notified when the update completes
  106. * @return {Ext.Element} this
  107. */
  108. update : function(html, loadScripts, callback) {
  109. if (!this.dom) {
  110. return this;
  111. }
  112. html = html || &quot;&quot;;
  113. if (loadScripts !== true) {
  114. this.dom.innerHTML = html;
  115. if (typeof callback == 'function') {
  116. callback();
  117. }
  118. return this;
  119. }
  120. var id = Ext.id(),
  121. dom = this.dom;
  122. html += '&lt;span id=&quot;' + id + '&quot;&gt;&lt;/span&gt;';
  123. Ext.lib.Event.onAvailable(id, function() {
  124. var DOC = document,
  125. hd = DOC.getElementsByTagName(&quot;head&quot;)[0],
  126. re = /(?:&lt;script([^&gt;]*)?&gt;)((\n|\r|.)*?)(?:&lt;\/script&gt;)/ig,
  127. srcRe = /\ssrc=([\'\&quot;])(.*?)\1/i,
  128. typeRe = /\stype=([\'\&quot;])(.*?)\1/i,
  129. match,
  130. attrs,
  131. srcMatch,
  132. typeMatch,
  133. el,
  134. s;
  135. while ((match = re.exec(html))) {
  136. attrs = match[1];
  137. srcMatch = attrs ? attrs.match(srcRe) : false;
  138. if (srcMatch &amp;&amp; srcMatch[2]) {
  139. s = DOC.createElement(&quot;script&quot;);
  140. s.src = srcMatch[2];
  141. typeMatch = attrs.match(typeRe);
  142. if (typeMatch &amp;&amp; typeMatch[2]) {
  143. s.type = typeMatch[2];
  144. }
  145. hd.appendChild(s);
  146. } else if (match[2] &amp;&amp; match[2].length &gt; 0) {
  147. if (window.execScript) {
  148. window.execScript(match[2]);
  149. } else {
  150. window.eval(match[2]);
  151. }
  152. }
  153. }
  154. el = DOC.getElementById(id);
  155. if (el) {
  156. Ext.removeNode(el);
  157. }
  158. if (typeof callback == 'function') {
  159. callback();
  160. }
  161. });
  162. dom.innerHTML = html.replace(/(?:&lt;script.*?&gt;)((\n|\r|.)*?)(?:&lt;\/script&gt;)/ig, &quot;&quot;);
  163. return this;
  164. },
  165. // inherit docs, overridden so we can add removeAnchor
  166. removeAllListeners : function() {
  167. this.removeAnchor();
  168. Ext.EventManager.removeAll(this.dom);
  169. return this;
  170. },
  171. <span id='Ext-Element-method-createProxy'> /**
  172. </span> * Creates a proxy element of this element
  173. * @param {String/Object} config The class name of the proxy element or a DomHelper config object
  174. * @param {String/HTMLElement} renderTo (optional) The element or element id to render the proxy to (defaults to document.body)
  175. * @param {Boolean} matchBox (optional) True to align and size the proxy to this element now (defaults to false)
  176. * @return {Ext.Element} The new proxy element
  177. */
  178. createProxy : function(config, renderTo, matchBox) {
  179. config = (typeof config == 'object') ? config : {tag : &quot;div&quot;, cls: config};
  180. var me = this,
  181. proxy = renderTo ? Ext.DomHelper.append(renderTo, config, true) :
  182. Ext.DomHelper.insertBefore(me.dom, config, true);
  183. if (matchBox &amp;&amp; me.setBox &amp;&amp; me.getBox) { // check to make sure Element.position.js is loaded
  184. proxy.setBox(me.getBox());
  185. }
  186. return proxy;
  187. }
  188. });
  189. Ext.Element.prototype.getUpdateManager = Ext.Element.prototype.getUpdater;
  190. </pre>
  191. </body>
  192. </html>