2
* Ext JS Library 3.0 RC2
3
* Copyright(c) 2006-2009, Ext JS, LLC.
6
* http://extjs.com/license
12
Ext.Element.addMethods(
14
var GETDOM = Ext.getDom,
18
return (el.nodeType || el.dom || typeof el == 'string');
23
* Appends the passed element(s) to this element
24
* @param {String/HTMLElement/Array/Element/CompositeElement} el
25
* @return {Ext.Element} this
27
appendChild: function(el){
28
return GET(el).appendTo(this);
32
* Appends this element to the passed element
33
* @param {Mixed} el The new parent element
34
* @return {Ext.Element} this
36
appendTo: function(el){
37
GETDOM(el).appendChild(this.dom);
42
* Inserts this element before the passed element in the DOM
43
* @param {Mixed} el The element before which this element will be inserted
44
* @return {Ext.Element} this
46
insertBefore: function(el){
47
(el = GETDOM(el)).parentNode.insertBefore(this.dom, el);
52
* Inserts this element after the passed element in the DOM
53
* @param {Mixed} el The element to insert after
54
* @return {Ext.Element} this
56
insertAfter: function(el){
57
(el = GETDOM(el)).parentNode.insertBefore(this.dom, el.nextSibling);
62
* Inserts (or creates) an element (or DomHelper config) as the first child of this element
63
* @param {Mixed/Object} el The id or element to insert or a DomHelper config to create and insert
64
* @return {Ext.Element} The new child
66
insertFirst: function(el, returnDom){
68
if(isEl(el)){ // element
70
this.dom.insertBefore(el, this.dom.firstChild);
71
return !returnDom ? GET(el) : el;
73
return this.createChild(el, this.dom.firstChild, returnDom);
78
* Replaces the passed element with this element
79
* @param {Mixed} el The element to replace
80
* @return {Ext.Element} this
82
replace: function(el){
84
this.insertBefore(el);
90
* Replaces this element with the passed element
91
* @param {Mixed/Object} el The new element or a DomHelper config of an element to create
92
* @return {Ext.Element} this
94
replaceWith: function(el){
96
Element = Ext.Element;
99
me.dom.parentNode.insertBefore(el, me.dom);
101
el = DH.insertBefore(me.dom, el);
104
delete Element.cache[me.id];
105
Ext.removeNode(me.dom);
106
me.id = Ext.id(me.dom = el);
107
return Element.cache[me.id] = me;
111
* Creates the passed DomHelper config and appends it to this element or optionally inserts it before the passed child element.
112
* @param {Object} config DomHelper element config object. If no tag is specified (e.g., {tag:'input'}) then a div will be
113
* automatically generated with the specified attributes.
114
* @param {HTMLElement} insertBefore (optional) a child element of this element
115
* @param {Boolean} returnDom (optional) true to return the dom node instead of creating an Element
116
* @return {Ext.Element} The new child element
118
createChild: function(config, insertBefore, returnDom){
119
config = config || {tag:'div'};
120
return insertBefore ?
121
DH.insertBefore(insertBefore, config, returnDom !== true) :
122
DH[!this.dom.firstChild ? 'overwrite' : 'append'](this.dom, config, returnDom !== true);
126
* Creates and wraps this element with another element
127
* @param {Object} config (optional) DomHelper element config object for the wrapper element or null for an empty div
128
* @param {Boolean} returnDom (optional) True to return the raw DOM element instead of Ext.Element
129
* @return {HTMLElement/Element} The newly created wrapper element
131
wrap: function(config, returnDom){
132
var newEl = DH.insertBefore(this.dom, config || {tag: "div"}, !returnDom);
133
newEl.dom ? newEl.dom.appendChild(this.dom) : newEl.appendChild(this.dom);
138
* Inserts an html fragment into this element
139
* @param {String} where Where to insert the html in relation to this element - beforeBegin, afterBegin, beforeEnd, afterEnd.
140
* @param {String} html The HTML fragment
141
* @param {Boolean} returnEl (optional) True to return an Ext.Element (defaults to false)
142
* @return {HTMLElement/Ext.Element} The inserted node (or nearest related if more than 1 inserted)
144
insertHtml : function(where, html, returnEl){
145
var el = DH.insertHtml(where, this.dom, html);
146
return returnEl ? Ext.get(el) : el;
b'\\ No newline at end of file'