1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The source code</title>
<link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../resources/prettify/prettify.js"></script>
</head>
<body onload="prettyPrint();">
<pre class="prettyprint lang-js">/*!
* Ext JS Library 3.4.0
* Copyright(c) 2006-2011 Sencha Inc.
* licensing@sencha.com
* http://www.sencha.com/license
*/
/**
* @class Ext.Element
*/
Ext.Element.addMethods(
function() {
var GETDOM = Ext.getDom,
GET = Ext.get,
DH = Ext.DomHelper;
return {
<div id="method-Ext.Element-appendChild"></div>/**
* Appends the passed element(s) to this element
* @param {String/HTMLElement/Array/Element/CompositeElement} el
* @return {Ext.Element} this
*/
appendChild: function(el){
return GET(el).appendTo(this);
},
<div id="method-Ext.Element-appendTo"></div>/**
* Appends this element to the passed element
* @param {Mixed} el The new parent element
* @return {Ext.Element} this
*/
appendTo: function(el){
GETDOM(el).appendChild(this.dom);
return this;
},
<div id="method-Ext.Element-insertBefore"></div>/**
* Inserts this element before the passed element in the DOM
* @param {Mixed} el The element before which this element will be inserted
* @return {Ext.Element} this
*/
insertBefore: function(el){
(el = GETDOM(el)).parentNode.insertBefore(this.dom, el);
return this;
},
<div id="method-Ext.Element-insertAfter"></div>/**
* Inserts this element after the passed element in the DOM
* @param {Mixed} el The element to insert after
* @return {Ext.Element} this
*/
insertAfter: function(el){
(el = GETDOM(el)).parentNode.insertBefore(this.dom, el.nextSibling);
return this;
},
<div id="method-Ext.Element-insertFirst"></div>/**
* Inserts (or creates) an element (or DomHelper config) as the first child of this element
* @param {Mixed/Object} el The id or element to insert or a DomHelper config to create and insert
* @return {Ext.Element} The new child
*/
insertFirst: function(el, returnDom){
el = el || {};
if(el.nodeType || el.dom || typeof el == 'string'){ // element
el = GETDOM(el);
this.dom.insertBefore(el, this.dom.firstChild);
return !returnDom ? GET(el) : el;
}else{ // dh config
return this.createChild(el, this.dom.firstChild, returnDom);
}
},
<div id="method-Ext.Element-replace"></div>/**
* Replaces the passed element with this element
* @param {Mixed} el The element to replace
* @return {Ext.Element} this
*/
replace: function(el){
el = GET(el);
this.insertBefore(el);
el.remove();
return this;
},
<div id="method-Ext.Element-replaceWith"></div>/**
* Replaces this element with the passed element
* @param {Mixed/Object} el The new element or a DomHelper config of an element to create
* @return {Ext.Element} this
*/
replaceWith: function(el){
var me = this;
if(el.nodeType || el.dom || typeof el == 'string'){
el = GETDOM(el);
me.dom.parentNode.insertBefore(el, me.dom);
}else{
el = DH.insertBefore(me.dom, el);
}
delete Ext.elCache[me.id];
Ext.removeNode(me.dom);
me.id = Ext.id(me.dom = el);
Ext.Element.addToCache(me.isFlyweight ? new Ext.Element(me.dom) : me);
return me;
},
<div id="method-Ext.Element-createChild"></div>/**
* Creates the passed DomHelper config and appends it to this element or optionally inserts it before the passed child element.
* @param {Object} config DomHelper element config object. If no tag is specified (e.g., {tag:'input'}) then a div will be
* automatically generated with the specified attributes.
* @param {HTMLElement} insertBefore (optional) a child element of this element
* @param {Boolean} returnDom (optional) true to return the dom node instead of creating an Element
* @return {Ext.Element} The new child element
*/
createChild: function(config, insertBefore, returnDom){
config = config || {tag:'div'};
return insertBefore ?
DH.insertBefore(insertBefore, config, returnDom !== true) :
DH[!this.dom.firstChild ? 'overwrite' : 'append'](this.dom, config, returnDom !== true);
},
<div id="method-Ext.Element-wrap"></div>/**
* Creates and wraps this element with another element
* @param {Object} config (optional) DomHelper element config object for the wrapper element or null for an empty div
* @param {Boolean} returnDom (optional) True to return the raw DOM element instead of Ext.Element
* @return {HTMLElement/Element} The newly created wrapper element
*/
wrap: function(config, returnDom){
var newEl = DH.insertBefore(this.dom, config || {tag: "div"}, !returnDom);
newEl.dom ? newEl.dom.appendChild(this.dom) : newEl.appendChild(this.dom);
return newEl;
},
<div id="method-Ext.Element-insertHtml"></div>/**
* Inserts an html fragment into this element
* @param {String} where Where to insert the html in relation to this element - beforeBegin, afterBegin, beforeEnd, afterEnd.
* @param {String} html The HTML fragment
* @param {Boolean} returnEl (optional) True to return an Ext.Element (defaults to false)
* @return {HTMLElement/Ext.Element} The inserted node (or nearest related if more than 1 inserted)
*/
insertHtml : function(where, html, returnEl){
var el = DH.insertHtml(where, this.dom, html);
return returnEl ? Ext.get(el) : el;
}
};
}());</pre>
</body>
</html>
|