3
* Copyright(c) 2006-2010 Ext JS, Inc.
5
* http://www.extjs.com/license
10
Ext.Element.addMethods(
12
var GETDOM = Ext.getDom,
18
* Appends the passed element(s) to this element
19
* @param {String/HTMLElement/Array/Element/CompositeElement} el
20
* @return {Ext.Element} this
22
appendChild: function(el){
23
return GET(el).appendTo(this);
27
* Appends this element to the passed element
28
* @param {Mixed} el The new parent element
29
* @return {Ext.Element} this
31
appendTo: function(el){
32
GETDOM(el).appendChild(this.dom);
37
* Inserts this element before the passed element in the DOM
38
* @param {Mixed} el The element before which this element will be inserted
39
* @return {Ext.Element} this
41
insertBefore: function(el){
42
(el = GETDOM(el)).parentNode.insertBefore(this.dom, el);
47
* Inserts this element after the passed element in the DOM
48
* @param {Mixed} el The element to insert after
49
* @return {Ext.Element} this
51
insertAfter: function(el){
52
(el = GETDOM(el)).parentNode.insertBefore(this.dom, el.nextSibling);
57
* Inserts (or creates) an element (or DomHelper config) as the first child of this element
58
* @param {Mixed/Object} el The id or element to insert or a DomHelper config to create and insert
59
* @return {Ext.Element} The new child
61
insertFirst: function(el, returnDom){
63
if(el.nodeType || el.dom || typeof el == 'string'){ // element
65
this.dom.insertBefore(el, this.dom.firstChild);
66
return !returnDom ? GET(el) : el;
68
return this.createChild(el, this.dom.firstChild, returnDom);
73
* Replaces the passed element with this element
74
* @param {Mixed} el The element to replace
75
* @return {Ext.Element} this
77
replace: function(el){
79
this.insertBefore(el);
85
* Replaces this element with the passed element
86
* @param {Mixed/Object} el The new element or a DomHelper config of an element to create
87
* @return {Ext.Element} this
89
replaceWith: function(el){
92
if(el.nodeType || el.dom || typeof el == 'string'){
94
me.dom.parentNode.insertBefore(el, me.dom);
96
el = DH.insertBefore(me.dom, el);
99
delete Ext.elCache[me.id];
100
Ext.removeNode(me.dom);
101
me.id = Ext.id(me.dom = el);
102
Ext.Element.addToCache(me.isFlyweight ? new Ext.Element(me.dom) : me);
107
* Creates the passed DomHelper config and appends it to this element or optionally inserts it before the passed child element.
108
* @param {Object} config DomHelper element config object. If no tag is specified (e.g., {tag:'input'}) then a div will be
109
* automatically generated with the specified attributes.
110
* @param {HTMLElement} insertBefore (optional) a child element of this element
111
* @param {Boolean} returnDom (optional) true to return the dom node instead of creating an Element
112
* @return {Ext.Element} The new child element
114
createChild: function(config, insertBefore, returnDom){
115
config = config || {tag:'div'};
116
return insertBefore ?
117
DH.insertBefore(insertBefore, config, returnDom !== true) :
118
DH[!this.dom.firstChild ? 'overwrite' : 'append'](this.dom, config, returnDom !== true);
122
* Creates and wraps this element with another element
123
* @param {Object} config (optional) DomHelper element config object for the wrapper element or null for an empty div
124
* @param {Boolean} returnDom (optional) True to return the raw DOM element instead of Ext.Element
125
* @return {HTMLElement/Element} The newly created wrapper element
127
wrap: function(config, returnDom){
128
var newEl = DH.insertBefore(this.dom, config || {tag: "div"}, !returnDom);
129
newEl.dom ? newEl.dom.appendChild(this.dom) : newEl.appendChild(this.dom);
134
* Inserts an html fragment into this element
135
* @param {String} where Where to insert the html in relation to this element - beforeBegin, afterBegin, beforeEnd, afterEnd.
136
* @param {String} html The HTML fragment
137
* @param {Boolean} returnEl (optional) True to return an Ext.Element (defaults to false)
138
* @return {HTMLElement/Ext.Element} The inserted node (or nearest related if more than 1 inserted)
140
insertHtml : function(where, html, returnEl){
141
var el = DH.insertHtml(where, this.dom, html);
142
return returnEl ? Ext.get(el) : el;
b'\\ No newline at end of file'