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.

469 lines
20 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-DomHelper'>/**
  19. </span> * @class Ext.DomHelper
  20. * &lt;p&gt;The DomHelper class provides a layer of abstraction from DOM and transparently supports creating
  21. * elements via DOM or using HTML fragments. It also has the ability to create HTML fragment templates
  22. * from your DOM building code.&lt;/p&gt;
  23. *
  24. * &lt;p&gt;&lt;b&gt;&lt;u&gt;DomHelper element specification object&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;
  25. * &lt;p&gt;A specification object is used when creating elements. Attributes of this object
  26. * are assumed to be element attributes, except for 4 special attributes:
  27. * &lt;div class=&quot;mdetail-params&quot;&gt;&lt;ul&gt;
  28. * &lt;li&gt;&lt;b&gt;&lt;tt&gt;tag&lt;/tt&gt;&lt;/b&gt; : &lt;div class=&quot;sub-desc&quot;&gt;The tag name of the element&lt;/div&gt;&lt;/li&gt;
  29. * &lt;li&gt;&lt;b&gt;&lt;tt&gt;children&lt;/tt&gt;&lt;/b&gt; : or &lt;tt&gt;cn&lt;/tt&gt;&lt;div class=&quot;sub-desc&quot;&gt;An array of the
  30. * same kind of element definition objects to be created and appended. These can be nested
  31. * as deep as you want.&lt;/div&gt;&lt;/li&gt;
  32. * &lt;li&gt;&lt;b&gt;&lt;tt&gt;cls&lt;/tt&gt;&lt;/b&gt; : &lt;div class=&quot;sub-desc&quot;&gt;The class attribute of the element.
  33. * This will end up being either the &quot;class&quot; attribute on a HTML fragment or className
  34. * for a DOM node, depending on whether DomHelper is using fragments or DOM.&lt;/div&gt;&lt;/li&gt;
  35. * &lt;li&gt;&lt;b&gt;&lt;tt&gt;html&lt;/tt&gt;&lt;/b&gt; : &lt;div class=&quot;sub-desc&quot;&gt;The innerHTML for the element&lt;/div&gt;&lt;/li&gt;
  36. * &lt;/ul&gt;&lt;/div&gt;&lt;/p&gt;
  37. *
  38. * &lt;p&gt;&lt;b&gt;&lt;u&gt;Insertion methods&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;
  39. * &lt;p&gt;Commonly used insertion methods:
  40. * &lt;div class=&quot;mdetail-params&quot;&gt;&lt;ul&gt;
  41. * &lt;li&gt;&lt;b&gt;&lt;tt&gt;{@link #append}&lt;/tt&gt;&lt;/b&gt; : &lt;div class=&quot;sub-desc&quot;&gt;&lt;/div&gt;&lt;/li&gt;
  42. * &lt;li&gt;&lt;b&gt;&lt;tt&gt;{@link #insertBefore}&lt;/tt&gt;&lt;/b&gt; : &lt;div class=&quot;sub-desc&quot;&gt;&lt;/div&gt;&lt;/li&gt;
  43. * &lt;li&gt;&lt;b&gt;&lt;tt&gt;{@link #insertAfter}&lt;/tt&gt;&lt;/b&gt; : &lt;div class=&quot;sub-desc&quot;&gt;&lt;/div&gt;&lt;/li&gt;
  44. * &lt;li&gt;&lt;b&gt;&lt;tt&gt;{@link #overwrite}&lt;/tt&gt;&lt;/b&gt; : &lt;div class=&quot;sub-desc&quot;&gt;&lt;/div&gt;&lt;/li&gt;
  45. * &lt;li&gt;&lt;b&gt;&lt;tt&gt;{@link #createTemplate}&lt;/tt&gt;&lt;/b&gt; : &lt;div class=&quot;sub-desc&quot;&gt;&lt;/div&gt;&lt;/li&gt;
  46. * &lt;li&gt;&lt;b&gt;&lt;tt&gt;{@link #insertHtml}&lt;/tt&gt;&lt;/b&gt; : &lt;div class=&quot;sub-desc&quot;&gt;&lt;/div&gt;&lt;/li&gt;
  47. * &lt;/ul&gt;&lt;/div&gt;&lt;/p&gt;
  48. *
  49. * &lt;p&gt;&lt;b&gt;&lt;u&gt;Example&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;
  50. * &lt;p&gt;This is an example, where an unordered list with 3 children items is appended to an existing
  51. * element with id &lt;tt&gt;'my-div'&lt;/tt&gt;:&lt;br&gt;
  52. &lt;pre&gt;&lt;code&gt;
  53. var dh = Ext.DomHelper; // create shorthand alias
  54. // specification object
  55. var spec = {
  56. id: 'my-ul',
  57. tag: 'ul',
  58. cls: 'my-list',
  59. // append children after creating
  60. children: [ // may also specify 'cn' instead of 'children'
  61. {tag: 'li', id: 'item0', html: 'List Item 0'},
  62. {tag: 'li', id: 'item1', html: 'List Item 1'},
  63. {tag: 'li', id: 'item2', html: 'List Item 2'}
  64. ]
  65. };
  66. var list = dh.append(
  67. 'my-div', // the context element 'my-div' can either be the id or the actual node
  68. spec // the specification object
  69. );
  70. &lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;
  71. * &lt;p&gt;Element creation specification parameters in this class may also be passed as an Array of
  72. * specification objects. This can be used to insert multiple sibling nodes into an existing
  73. * container very efficiently. For example, to add more list items to the example above:&lt;pre&gt;&lt;code&gt;
  74. dh.append('my-ul', [
  75. {tag: 'li', id: 'item3', html: 'List Item 3'},
  76. {tag: 'li', id: 'item4', html: 'List Item 4'}
  77. ]);
  78. * &lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;
  79. *
  80. * &lt;p&gt;&lt;b&gt;&lt;u&gt;Templating&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;
  81. * &lt;p&gt;The real power is in the built-in templating. Instead of creating or appending any elements,
  82. * &lt;tt&gt;{@link #createTemplate}&lt;/tt&gt; returns a Template object which can be used over and over to
  83. * insert new elements. Revisiting the example above, we could utilize templating this time:
  84. * &lt;pre&gt;&lt;code&gt;
  85. // create the node
  86. var list = dh.append('my-div', {tag: 'ul', cls: 'my-list'});
  87. // get template
  88. var tpl = dh.createTemplate({tag: 'li', id: 'item{0}', html: 'List Item {0}'});
  89. for(var i = 0; i &lt; 5, i++){
  90. tpl.append(list, [i]); // use template to append to the actual node
  91. }
  92. * &lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;
  93. * &lt;p&gt;An example using a template:&lt;pre&gt;&lt;code&gt;
  94. var html = '&lt;a id=&quot;{0}&quot; href=&quot;{1}&quot; class=&quot;nav&quot;&gt;{2}&lt;/a&gt;';
  95. var tpl = new Ext.DomHelper.createTemplate(html);
  96. tpl.append('blog-roll', ['link1', 'http://www.jackslocum.com/', &quot;Jack&amp;#39;s Site&quot;]);
  97. tpl.append('blog-roll', ['link2', 'http://www.dustindiaz.com/', &quot;Dustin&amp;#39;s Site&quot;]);
  98. * &lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;
  99. *
  100. * &lt;p&gt;The same example using named parameters:&lt;pre&gt;&lt;code&gt;
  101. var html = '&lt;a id=&quot;{id}&quot; href=&quot;{url}&quot; class=&quot;nav&quot;&gt;{text}&lt;/a&gt;';
  102. var tpl = new Ext.DomHelper.createTemplate(html);
  103. tpl.append('blog-roll', {
  104. id: 'link1',
  105. url: 'http://www.jackslocum.com/',
  106. text: &quot;Jack&amp;#39;s Site&quot;
  107. });
  108. tpl.append('blog-roll', {
  109. id: 'link2',
  110. url: 'http://www.dustindiaz.com/',
  111. text: &quot;Dustin&amp;#39;s Site&quot;
  112. });
  113. * &lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;
  114. *
  115. * &lt;p&gt;&lt;b&gt;&lt;u&gt;Compiling Templates&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;
  116. * &lt;p&gt;Templates are applied using regular expressions. The performance is great, but if
  117. * you are adding a bunch of DOM elements using the same template, you can increase
  118. * performance even further by {@link Ext.Template#compile &quot;compiling&quot;} the template.
  119. * The way &quot;{@link Ext.Template#compile compile()}&quot; works is the template is parsed and
  120. * broken up at the different variable points and a dynamic function is created and eval'ed.
  121. * The generated function performs string concatenation of these parts and the passed
  122. * variables instead of using regular expressions.
  123. * &lt;pre&gt;&lt;code&gt;
  124. var html = '&lt;a id=&quot;{id}&quot; href=&quot;{url}&quot; class=&quot;nav&quot;&gt;{text}&lt;/a&gt;';
  125. var tpl = new Ext.DomHelper.createTemplate(html);
  126. tpl.compile();
  127. //... use template like normal
  128. * &lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;
  129. *
  130. * &lt;p&gt;&lt;b&gt;&lt;u&gt;Performance Boost&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;
  131. * &lt;p&gt;DomHelper will transparently create HTML fragments when it can. Using HTML fragments instead
  132. * of DOM can significantly boost performance.&lt;/p&gt;
  133. * &lt;p&gt;Element creation specification parameters may also be strings. If {@link #useDom} is &lt;tt&gt;false&lt;/tt&gt;,
  134. * then the string is used as innerHTML. If {@link #useDom} is &lt;tt&gt;true&lt;/tt&gt;, a string specification
  135. * results in the creation of a text node. Usage:&lt;/p&gt;
  136. * &lt;pre&gt;&lt;code&gt;
  137. Ext.DomHelper.useDom = true; // force it to use DOM; reduces performance
  138. * &lt;/code&gt;&lt;/pre&gt;
  139. * @singleton
  140. */
  141. Ext.DomHelper = function(){
  142. var tempTableEl = null,
  143. emptyTags = /^(?:br|frame|hr|img|input|link|meta|range|spacer|wbr|area|param|col)$/i,
  144. tableRe = /^table|tbody|tr|td$/i,
  145. confRe = /tag|children|cn|html$/i,
  146. tableElRe = /td|tr|tbody/i,
  147. cssRe = /([a-z0-9-]+)\s*:\s*([^;\s]+(?:\s*[^;\s]+)*);?/gi,
  148. endRe = /end/i,
  149. pub,
  150. // kill repeat to save bytes
  151. afterbegin = 'afterbegin',
  152. afterend = 'afterend',
  153. beforebegin = 'beforebegin',
  154. beforeend = 'beforeend',
  155. ts = '&lt;table&gt;',
  156. te = '&lt;/table&gt;',
  157. tbs = ts+'&lt;tbody&gt;',
  158. tbe = '&lt;/tbody&gt;'+te,
  159. trs = tbs + '&lt;tr&gt;',
  160. tre = '&lt;/tr&gt;'+tbe;
  161. // private
  162. function doInsert(el, o, returnElement, pos, sibling, append){
  163. var newNode = pub.insertHtml(pos, Ext.getDom(el), createHtml(o));
  164. return returnElement ? Ext.get(newNode, true) : newNode;
  165. }
  166. // build as innerHTML where available
  167. function createHtml(o){
  168. var b = '',
  169. attr,
  170. val,
  171. key,
  172. cn;
  173. if(typeof o == &quot;string&quot;){
  174. b = o;
  175. } else if (Ext.isArray(o)) {
  176. for (var i=0; i &lt; o.length; i++) {
  177. if(o[i]) {
  178. b += createHtml(o[i]);
  179. }
  180. };
  181. } else {
  182. b += '&lt;' + (o.tag = o.tag || 'div');
  183. for (attr in o) {
  184. val = o[attr];
  185. if(!confRe.test(attr)){
  186. if (typeof val == &quot;object&quot;) {
  187. b += ' ' + attr + '=&quot;';
  188. for (key in val) {
  189. b += key + ':' + val[key] + ';';
  190. };
  191. b += '&quot;';
  192. }else{
  193. b += ' ' + ({cls : 'class', htmlFor : 'for'}[attr] || attr) + '=&quot;' + val + '&quot;';
  194. }
  195. }
  196. };
  197. // Now either just close the tag or try to add children and close the tag.
  198. if (emptyTags.test(o.tag)) {
  199. b += '/&gt;';
  200. } else {
  201. b += '&gt;';
  202. if ((cn = o.children || o.cn)) {
  203. b += createHtml(cn);
  204. } else if(o.html){
  205. b += o.html;
  206. }
  207. b += '&lt;/' + o.tag + '&gt;';
  208. }
  209. }
  210. return b;
  211. }
  212. function ieTable(depth, s, h, e){
  213. tempTableEl.innerHTML = [s, h, e].join('');
  214. var i = -1,
  215. el = tempTableEl,
  216. ns;
  217. while(++i &lt; depth){
  218. el = el.firstChild;
  219. }
  220. // If the result is multiple siblings, then encapsulate them into one fragment.
  221. if(ns = el.nextSibling){
  222. var df = document.createDocumentFragment();
  223. while(el){
  224. ns = el.nextSibling;
  225. df.appendChild(el);
  226. el = ns;
  227. }
  228. el = df;
  229. }
  230. return el;
  231. }
  232. <span id='global-method-insertIntoTable'> /**
  233. </span> * @ignore
  234. * Nasty code for IE's broken table implementation
  235. */
  236. function insertIntoTable(tag, where, el, html) {
  237. var node,
  238. before;
  239. tempTableEl = tempTableEl || document.createElement('div');
  240. if(tag == 'td' &amp;&amp; (where == afterbegin || where == beforeend) ||
  241. !tableElRe.test(tag) &amp;&amp; (where == beforebegin || where == afterend)) {
  242. return;
  243. }
  244. before = where == beforebegin ? el :
  245. where == afterend ? el.nextSibling :
  246. where == afterbegin ? el.firstChild : null;
  247. if (where == beforebegin || where == afterend) {
  248. el = el.parentNode;
  249. }
  250. if (tag == 'td' || (tag == 'tr' &amp;&amp; (where == beforeend || where == afterbegin))) {
  251. node = ieTable(4, trs, html, tre);
  252. } else if ((tag == 'tbody' &amp;&amp; (where == beforeend || where == afterbegin)) ||
  253. (tag == 'tr' &amp;&amp; (where == beforebegin || where == afterend))) {
  254. node = ieTable(3, tbs, html, tbe);
  255. } else {
  256. node = ieTable(2, ts, html, te);
  257. }
  258. el.insertBefore(node, before);
  259. return node;
  260. }
  261. <span id='global-method-createContextualFragment'> /**
  262. </span> * @ignore
  263. * Fix for IE9 createContextualFragment missing method
  264. */
  265. function createContextualFragment(html){
  266. var div = document.createElement(&quot;div&quot;),
  267. fragment = document.createDocumentFragment(),
  268. i = 0,
  269. length, childNodes;
  270. div.innerHTML = html;
  271. childNodes = div.childNodes;
  272. length = childNodes.length;
  273. for (; i &lt; length; i++) {
  274. fragment.appendChild(childNodes[i].cloneNode(true));
  275. }
  276. return fragment;
  277. }
  278. pub = {
  279. <span id='Ext-DomHelper-method-markup'> /**
  280. </span> * Returns the markup for the passed Element(s) config.
  281. * @param {Object} o The DOM object spec (and children)
  282. * @return {String}
  283. */
  284. markup : function(o){
  285. return createHtml(o);
  286. },
  287. <span id='Ext-DomHelper-method-applyStyles'> /**
  288. </span> * Applies a style specification to an element.
  289. * @param {String/HTMLElement} el The element to apply styles to
  290. * @param {String/Object/Function} styles A style specification string e.g. 'width:100px', or object in the form {width:'100px'}, or
  291. * a function which returns such a specification.
  292. */
  293. applyStyles : function(el, styles){
  294. if (styles) {
  295. var matches;
  296. el = Ext.fly(el);
  297. if (typeof styles == &quot;function&quot;) {
  298. styles = styles.call();
  299. }
  300. if (typeof styles == &quot;string&quot;) {
  301. <span id='Ext-DomHelper-property-lastIndex'> /**
  302. </span> * Since we're using the g flag on the regex, we need to set the lastIndex.
  303. * This automatically happens on some implementations, but not others, see:
  304. * http://stackoverflow.com/questions/2645273/javascript-regular-expression-literal-persists-between-function-calls
  305. * http://blog.stevenlevithan.com/archives/fixing-javascript-regexp
  306. */
  307. cssRe.lastIndex = 0;
  308. while ((matches = cssRe.exec(styles))) {
  309. el.setStyle(matches[1], matches[2]);
  310. }
  311. } else if (typeof styles == &quot;object&quot;) {
  312. el.setStyle(styles);
  313. }
  314. }
  315. },
  316. <span id='Ext-DomHelper-method-insertHtml'> /**
  317. </span> * Inserts an HTML fragment into the DOM.
  318. * @param {String} where Where to insert the html in relation to el - beforeBegin, afterBegin, beforeEnd, afterEnd.
  319. * @param {HTMLElement} el The context element
  320. * @param {String} html The HTML fragment
  321. * @return {HTMLElement} The new node
  322. */
  323. insertHtml : function(where, el, html){
  324. var hash = {},
  325. hashVal,
  326. range,
  327. rangeEl,
  328. setStart,
  329. frag,
  330. rs;
  331. where = where.toLowerCase();
  332. // add these here because they are used in both branches of the condition.
  333. hash[beforebegin] = ['BeforeBegin', 'previousSibling'];
  334. hash[afterend] = ['AfterEnd', 'nextSibling'];
  335. if (el.insertAdjacentHTML) {
  336. if(tableRe.test(el.tagName) &amp;&amp; (rs = insertIntoTable(el.tagName.toLowerCase(), where, el, html))){
  337. return rs;
  338. }
  339. // add these two to the hash.
  340. hash[afterbegin] = ['AfterBegin', 'firstChild'];
  341. hash[beforeend] = ['BeforeEnd', 'lastChild'];
  342. if ((hashVal = hash[where])) {
  343. el.insertAdjacentHTML(hashVal[0], html);
  344. return el[hashVal[1]];
  345. }
  346. } else {
  347. range = el.ownerDocument.createRange();
  348. setStart = 'setStart' + (endRe.test(where) ? 'After' : 'Before');
  349. if (hash[where]) {
  350. range[setStart](el);
  351. if (!range.createContextualFragment) {
  352. frag = createContextualFragment(html);
  353. }
  354. else {
  355. frag = range.createContextualFragment(html);
  356. }
  357. el.parentNode.insertBefore(frag, where == beforebegin ? el : el.nextSibling);
  358. return el[(where == beforebegin ? 'previous' : 'next') + 'Sibling'];
  359. } else {
  360. rangeEl = (where == afterbegin ? 'first' : 'last') + 'Child';
  361. if (el.firstChild) {
  362. range[setStart](el[rangeEl]);
  363. if (!range.createContextualFragment) {
  364. frag = createContextualFragment(html);
  365. }
  366. else {
  367. frag = range.createContextualFragment(html);
  368. }
  369. if(where == afterbegin){
  370. el.insertBefore(frag, el.firstChild);
  371. }else{
  372. el.appendChild(frag);
  373. }
  374. } else {
  375. el.innerHTML = html;
  376. }
  377. return el[rangeEl];
  378. }
  379. }
  380. throw 'Illegal insertion point -&gt; &quot;' + where + '&quot;';
  381. },
  382. <span id='Ext-DomHelper-method-insertBefore'> /**
  383. </span> * Creates new DOM element(s) and inserts them before el.
  384. * @param {Mixed} el The context element
  385. * @param {Object/String} o The DOM object spec (and children) or raw HTML blob
  386. * @param {Boolean} returnElement (optional) true to return a Ext.Element
  387. * @return {HTMLElement/Ext.Element} The new node
  388. */
  389. insertBefore : function(el, o, returnElement){
  390. return doInsert(el, o, returnElement, beforebegin);
  391. },
  392. <span id='Ext-DomHelper-method-insertAfter'> /**
  393. </span> * Creates new DOM element(s) and inserts them after el.
  394. * @param {Mixed} el The context element
  395. * @param {Object} o The DOM object spec (and children)
  396. * @param {Boolean} returnElement (optional) true to return a Ext.Element
  397. * @return {HTMLElement/Ext.Element} The new node
  398. */
  399. insertAfter : function(el, o, returnElement){
  400. return doInsert(el, o, returnElement, afterend, 'nextSibling');
  401. },
  402. <span id='Ext-DomHelper-method-insertFirst'> /**
  403. </span> * Creates new DOM element(s) and inserts them as the first child of el.
  404. * @param {Mixed} el The context element
  405. * @param {Object/String} o The DOM object spec (and children) or raw HTML blob
  406. * @param {Boolean} returnElement (optional) true to return a Ext.Element
  407. * @return {HTMLElement/Ext.Element} The new node
  408. */
  409. insertFirst : function(el, o, returnElement){
  410. return doInsert(el, o, returnElement, afterbegin, 'firstChild');
  411. },
  412. <span id='Ext-DomHelper-method-append'> /**
  413. </span> * Creates new DOM element(s) and appends them to el.
  414. * @param {Mixed} el The context element
  415. * @param {Object/String} o The DOM object spec (and children) or raw HTML blob
  416. * @param {Boolean} returnElement (optional) true to return a Ext.Element
  417. * @return {HTMLElement/Ext.Element} The new node
  418. */
  419. append : function(el, o, returnElement){
  420. return doInsert(el, o, returnElement, beforeend, '', true);
  421. },
  422. <span id='Ext-DomHelper-method-overwrite'> /**
  423. </span> * Creates new DOM element(s) and overwrites the contents of el with them.
  424. * @param {Mixed} el The context element
  425. * @param {Object/String} o The DOM object spec (and children) or raw HTML blob
  426. * @param {Boolean} returnElement (optional) true to return a Ext.Element
  427. * @return {HTMLElement/Ext.Element} The new node
  428. */
  429. overwrite : function(el, o, returnElement){
  430. el = Ext.getDom(el);
  431. el.innerHTML = createHtml(o);
  432. return returnElement ? Ext.get(el.firstChild) : el.firstChild;
  433. },
  434. createHtml : createHtml
  435. };
  436. return pub;
  437. }();
  438. </pre>
  439. </body>
  440. </html>