3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.2.2
11 * Copyright(c) 2006-2010 Ext JS, Inc.
13 * http://www.extjs.com/license
15 <div id="cls-Ext.Element"></div>/**
18 Ext.Element.addMethods({
19 <div id="method-Ext.Element-swallowEvent"></div>/**
20 * Stops the specified event(s) from bubbling and optionally prevents the default action
21 * @param {String/Array} eventName an event / array of events to stop from bubbling
22 * @param {Boolean} preventDefault (optional) true to prevent the default action too
23 * @return {Ext.Element} this
25 swallowEvent : function(eventName, preventDefault){
33 if(Ext.isArray(eventName)){
34 Ext.each(eventName, function(e) {
43 <div id="method-Ext.Element-relayEvent"></div>/**
44 * Create an event handler on this element such that when the event fires and is handled by this element,
45 * it will be relayed to another object (i.e., fired again as if it originated from that object instead).
46 * @param {String} eventName The type of event to relay
47 * @param {Object} object Any object that extends {@link Ext.util.Observable} that will provide the context
48 * for firing the relayed event
50 relayEvent : function(eventName, observable){
51 this.on(eventName, function(e){
52 observable.fireEvent(eventName, e);
56 <div id="method-Ext.Element-clean"></div>/**
57 * Removes worthless text nodes
58 * @param {Boolean} forceReclean (optional) By default the element
59 * keeps track if it has been cleaned already so
60 * you can call this over and over. However, if you update the element and
61 * need to force a reclean, you can pass true.
63 clean : function(forceReclean){
69 if(Ext.Element.data(dom, 'isCleaned') && forceReclean !== true){
74 var nx = n.nextSibling;
75 if(n.nodeType == 3 && !/\S/.test(n.nodeValue)){
82 Ext.Element.data(dom, 'isCleaned', true);
86 <div id="method-Ext.Element-load"></div>/**
87 * Direct access to the Updater {@link Ext.Updater#update} method. The method takes the same object
88 * parameter as {@link Ext.Updater#update}
89 * @return {Ext.Element} this
92 var um = this.getUpdater();
93 um.update.apply(um, arguments);
97 <div id="method-Ext.Element-getUpdater"></div>/**
98 * Gets this element's {@link Ext.Updater Updater}
99 * @return {Ext.Updater} The Updater
101 getUpdater : function(){
102 return this.updateManager || (this.updateManager = new Ext.Updater(this));
105 <div id="method-Ext.Element-update"></div>/**
106 * Update the innerHTML of this element, optionally searching for and processing scripts
107 * @param {String} html The new HTML
108 * @param {Boolean} loadScripts (optional) True to look for and process scripts (defaults to false)
109 * @param {Function} callback (optional) For async script loading you can be notified when the update completes
110 * @return {Ext.Element} this
112 update : function(html, loadScripts, callback){
118 if(loadScripts !== true){
119 this.dom.innerHTML = html;
120 if(typeof callback == 'function'){
129 html += '<span id="' + id + '"></span>';
131 Ext.lib.Event.onAvailable(id, function(){
133 hd = DOC.getElementsByTagName("head")[0],
134 re = /(?:<script([^>]*)?>)((\n|\r|.)*?)(?:<\/script>)/ig,
135 srcRe = /\ssrc=([\'\"])(.*?)\1/i,
136 typeRe = /\stype=([\'\"])(.*?)\1/i,
144 while((match = re.exec(html))){
146 srcMatch = attrs ? attrs.match(srcRe) : false;
147 if(srcMatch && srcMatch[2]){
148 s = DOC.createElement("script");
150 typeMatch = attrs.match(typeRe);
151 if(typeMatch && typeMatch[2]){
152 s.type = typeMatch[2];
155 }else if(match[2] && match[2].length > 0){
156 if(window.execScript) {
157 window.execScript(match[2]);
159 window.eval(match[2]);
163 el = DOC.getElementById(id);
164 if(el){Ext.removeNode(el);}
165 if(typeof callback == 'function'){
169 dom.innerHTML = html.replace(/(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/ig, "");
173 // inherit docs, overridden so we can add removeAnchor
174 removeAllListeners : function(){
176 Ext.EventManager.removeAll(this.dom);
180 <div id="method-Ext.Element-createProxy"></div>/**
181 * Creates a proxy element of this element
182 * @param {String/Object} config The class name of the proxy element or a DomHelper config object
183 * @param {String/HTMLElement} renderTo (optional) The element or element id to render the proxy to (defaults to document.body)
184 * @param {Boolean} matchBox (optional) True to align and size the proxy to this element now (defaults to false)
185 * @return {Ext.Element} The new proxy element
187 createProxy : function(config, renderTo, matchBox){
188 config = (typeof config == 'object') ? config : {tag : "div", cls: config};
191 proxy = renderTo ? Ext.DomHelper.append(renderTo, config, true) :
192 Ext.DomHelper.insertBefore(me.dom, config, true);
194 if(matchBox && me.setBox && me.getBox){ // check to make sure Element.position.js is loaded
195 proxy.setBox(me.getBox());
201 Ext.Element.prototype.getUpdateManager = Ext.Element.prototype.getUpdater;