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.

168 lines
6.2 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. */
  21. Ext.apply(Ext.DomHelper,
  22. function(){
  23. var pub,
  24. afterbegin = 'afterbegin',
  25. afterend = 'afterend',
  26. beforebegin = 'beforebegin',
  27. beforeend = 'beforeend',
  28. confRe = /tag|children|cn|html$/i;
  29. // private
  30. function doInsert(el, o, returnElement, pos, sibling, append){
  31. el = Ext.getDom(el);
  32. var newNode;
  33. if (pub.useDom) {
  34. newNode = createDom(o, null);
  35. if (append) {
  36. el.appendChild(newNode);
  37. } else {
  38. (sibling == 'firstChild' ? el : el.parentNode).insertBefore(newNode, el[sibling] || el);
  39. }
  40. } else {
  41. newNode = Ext.DomHelper.insertHtml(pos, el, Ext.DomHelper.createHtml(o));
  42. }
  43. return returnElement ? Ext.get(newNode, true) : newNode;
  44. }
  45. // build as dom
  46. <span id='global-method-createDom'> /** @ignore */
  47. </span> function createDom(o, parentNode){
  48. var el,
  49. doc = document,
  50. useSet,
  51. attr,
  52. val,
  53. cn;
  54. if (Ext.isArray(o)) { // Allow Arrays of siblings to be inserted
  55. el = doc.createDocumentFragment(); // in one shot using a DocumentFragment
  56. for (var i = 0, l = o.length; i &lt; l; i++) {
  57. createDom(o[i], el);
  58. }
  59. } else if (typeof o == 'string') { // Allow a string as a child spec.
  60. el = doc.createTextNode(o);
  61. } else {
  62. el = doc.createElement( o.tag || 'div' );
  63. useSet = !!el.setAttribute; // In IE some elements don't have setAttribute
  64. for (var attr in o) {
  65. if(!confRe.test(attr)){
  66. val = o[attr];
  67. if(attr == 'cls'){
  68. el.className = val;
  69. }else{
  70. if(useSet){
  71. el.setAttribute(attr, val);
  72. }else{
  73. el[attr] = val;
  74. }
  75. }
  76. }
  77. }
  78. Ext.DomHelper.applyStyles(el, o.style);
  79. if ((cn = o.children || o.cn)) {
  80. createDom(cn, el);
  81. } else if (o.html) {
  82. el.innerHTML = o.html;
  83. }
  84. }
  85. if(parentNode){
  86. parentNode.appendChild(el);
  87. }
  88. return el;
  89. }
  90. pub = {
  91. <span id='Ext-DomHelper-method-createTemplate'> /**
  92. </span> * Creates a new Ext.Template from the DOM object spec.
  93. * @param {Object} o The DOM object spec (and children)
  94. * @return {Ext.Template} The new template
  95. */
  96. createTemplate : function(o){
  97. var html = Ext.DomHelper.createHtml(o);
  98. return new Ext.Template(html);
  99. },
  100. <span id='Ext-DomHelper-property-useDom'> /** True to force the use of DOM instead of html fragments @type Boolean */
  101. </span> useDom : false,
  102. <span id='Ext-DomHelper-method-insertBefore'> /**
  103. </span> * Creates new DOM element(s) and inserts them before el.
  104. * @param {Mixed} el The context element
  105. * @param {Object/String} o The DOM object spec (and children) or raw HTML blob
  106. * @param {Boolean} returnElement (optional) true to return a Ext.Element
  107. * @return {HTMLElement/Ext.Element} The new node
  108. * @hide (repeat)
  109. */
  110. insertBefore : function(el, o, returnElement){
  111. return doInsert(el, o, returnElement, beforebegin);
  112. },
  113. <span id='Ext-DomHelper-method-insertAfter'> /**
  114. </span> * Creates new DOM element(s) and inserts them after el.
  115. * @param {Mixed} el The context element
  116. * @param {Object} o The DOM object spec (and children)
  117. * @param {Boolean} returnElement (optional) true to return a Ext.Element
  118. * @return {HTMLElement/Ext.Element} The new node
  119. * @hide (repeat)
  120. */
  121. insertAfter : function(el, o, returnElement){
  122. return doInsert(el, o, returnElement, afterend, 'nextSibling');
  123. },
  124. <span id='Ext-DomHelper-method-insertFirst'> /**
  125. </span> * Creates new DOM element(s) and inserts them as the first child of el.
  126. * @param {Mixed} el The context element
  127. * @param {Object/String} o The DOM object spec (and children) or raw HTML blob
  128. * @param {Boolean} returnElement (optional) true to return a Ext.Element
  129. * @return {HTMLElement/Ext.Element} The new node
  130. * @hide (repeat)
  131. */
  132. insertFirst : function(el, o, returnElement){
  133. return doInsert(el, o, returnElement, afterbegin, 'firstChild');
  134. },
  135. <span id='Ext-DomHelper-method-append'> /**
  136. </span> * Creates new DOM element(s) and appends them to el.
  137. * @param {Mixed} el The context element
  138. * @param {Object/String} o The DOM object spec (and children) or raw HTML blob
  139. * @param {Boolean} returnElement (optional) true to return a Ext.Element
  140. * @return {HTMLElement/Ext.Element} The new node
  141. * @hide (repeat)
  142. */
  143. append: function(el, o, returnElement){
  144. return doInsert(el, o, returnElement, beforeend, '', true);
  145. },
  146. <span id='Ext-DomHelper-method-createDom'> /**
  147. </span> * Creates new DOM element(s) without inserting them to the document.
  148. * @param {Object/String} o The DOM object spec (and children) or raw HTML blob
  149. * @return {HTMLElement} The new uninserted node
  150. */
  151. createDom: createDom
  152. };
  153. return pub;
  154. }());
  155. </pre>
  156. </body>
  157. </html>