3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\r
4 <title>The source code</title>
\r
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
8 <body onload="prettyPrint();">
\r
9 <pre class="prettyprint lang-js">/**
\r
10 * @class Ext.Element
\r
12 Ext.Element.addMethods(
\r
14 var GETDOM = Ext.getDom,
\r
19 <div id="method-Ext.Element-appendChild"></div>/**
\r
20 * Appends the passed element(s) to this element
\r
21 * @param {String/HTMLElement/Array/Element/CompositeElement} el
\r
22 * @return {Ext.Element} this
\r
24 appendChild: function(el){
\r
25 return GET(el).appendTo(this);
\r
28 <div id="method-Ext.Element-appendTo"></div>/**
\r
29 * Appends this element to the passed element
\r
30 * @param {Mixed} el The new parent element
\r
31 * @return {Ext.Element} this
\r
33 appendTo: function(el){
\r
34 GETDOM(el).appendChild(this.dom);
\r
38 <div id="method-Ext.Element-insertBefore"></div>/**
\r
39 * Inserts this element before the passed element in the DOM
\r
40 * @param {Mixed} el The element before which this element will be inserted
\r
41 * @return {Ext.Element} this
\r
43 insertBefore: function(el){
\r
44 (el = GETDOM(el)).parentNode.insertBefore(this.dom, el);
\r
48 <div id="method-Ext.Element-insertAfter"></div>/**
\r
49 * Inserts this element after the passed element in the DOM
\r
50 * @param {Mixed} el The element to insert after
\r
51 * @return {Ext.Element} this
\r
53 insertAfter: function(el){
\r
54 (el = GETDOM(el)).parentNode.insertBefore(this.dom, el.nextSibling);
\r
58 <div id="method-Ext.Element-insertFirst"></div>/**
\r
59 * Inserts (or creates) an element (or DomHelper config) as the first child of this element
\r
60 * @param {Mixed/Object} el The id or element to insert or a DomHelper config to create and insert
\r
61 * @return {Ext.Element} The new child
\r
63 insertFirst: function(el, returnDom){
\r
65 if(el.nodeType || el.dom || typeof el == 'string'){ // element
\r
67 this.dom.insertBefore(el, this.dom.firstChild);
\r
68 return !returnDom ? GET(el) : el;
\r
70 return this.createChild(el, this.dom.firstChild, returnDom);
\r
74 <div id="method-Ext.Element-replace"></div>/**
\r
75 * Replaces the passed element with this element
\r
76 * @param {Mixed} el The element to replace
\r
77 * @return {Ext.Element} this
\r
79 replace: function(el){
\r
81 this.insertBefore(el);
\r
86 <div id="method-Ext.Element-replaceWith"></div>/**
\r
87 * Replaces this element with the passed element
\r
88 * @param {Mixed/Object} el The new element or a DomHelper config of an element to create
\r
89 * @return {Ext.Element} this
\r
91 replaceWith: function(el){
\r
94 if(el.nodeType || el.dom || typeof el == 'string'){
\r
96 me.dom.parentNode.insertBefore(el, me.dom);
\r
98 el = DH.insertBefore(me.dom, el);
\r
101 delete Ext.elCache[me.id];
\r
102 Ext.removeNode(me.dom);
\r
103 me.id = Ext.id(me.dom = el);
\r
104 Ext.Element.addToCache(me.isFlyweight ? new Ext.Element(me.dom) : me);
\r
108 <div id="method-Ext.Element-createChild"></div>/**
\r
109 * Creates the passed DomHelper config and appends it to this element or optionally inserts it before the passed child element.
\r
110 * @param {Object} config DomHelper element config object. If no tag is specified (e.g., {tag:'input'}) then a div will be
\r
111 * automatically generated with the specified attributes.
\r
112 * @param {HTMLElement} insertBefore (optional) a child element of this element
\r
113 * @param {Boolean} returnDom (optional) true to return the dom node instead of creating an Element
\r
114 * @return {Ext.Element} The new child element
\r
116 createChild: function(config, insertBefore, returnDom){
\r
117 config = config || {tag:'div'};
\r
118 return insertBefore ?
\r
119 DH.insertBefore(insertBefore, config, returnDom !== true) :
\r
120 DH[!this.dom.firstChild ? 'overwrite' : 'append'](this.dom, config, returnDom !== true);
\r
123 <div id="method-Ext.Element-wrap"></div>/**
\r
124 * Creates and wraps this element with another element
\r
125 * @param {Object} config (optional) DomHelper element config object for the wrapper element or null for an empty div
\r
126 * @param {Boolean} returnDom (optional) True to return the raw DOM element instead of Ext.Element
\r
127 * @return {HTMLElement/Element} The newly created wrapper element
\r
129 wrap: function(config, returnDom){
\r
130 var newEl = DH.insertBefore(this.dom, config || {tag: "div"}, !returnDom);
\r
131 newEl.dom ? newEl.dom.appendChild(this.dom) : newEl.appendChild(this.dom);
\r
135 <div id="method-Ext.Element-insertHtml"></div>/**
\r
136 * Inserts an html fragment into this element
\r
137 * @param {String} where Where to insert the html in relation to this element - beforeBegin, afterBegin, beforeEnd, afterEnd.
\r
138 * @param {String} html The HTML fragment
\r
139 * @param {Boolean} returnEl (optional) True to return an Ext.Element (defaults to false)
\r
140 * @return {HTMLElement/Ext.Element} The inserted node (or nearest related if more than 1 inserted)
\r
142 insertHtml : function(where, html, returnEl){
\r
143 var el = DH.insertHtml(where, this.dom, html);
\r
144 return returnEl ? Ext.get(el) : el;
\r