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.3.0
11 * Copyright(c) 2006-2010 Ext JS, Inc.
13 * http://www.extjs.com/license
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) {
34 if (Ext.isArray(eventName)) {
35 Ext.each(eventName, function(e) {
44 <div id="method-Ext.Element-relayEvent"></div>/**
45 * Create an event handler on this element such that when the event fires and is handled by this element,
46 * it will be relayed to another object (i.e., fired again as if it originated from that object instead).
47 * @param {String} eventName The type of event to relay
48 * @param {Object} object Any object that extends {@link Ext.util.Observable} that will provide the context
49 * for firing the relayed event
51 relayEvent : function(eventName, observable) {
52 this.on(eventName, function(e) {
53 observable.fireEvent(eventName, e);
57 <div id="method-Ext.Element-clean"></div>/**
58 * Removes worthless text nodes
59 * @param {Boolean} forceReclean (optional) By default the element
60 * keeps track if it has been cleaned already so
61 * you can call this over and over. However, if you update the element and
62 * need to force a reclean, you can pass true.
64 clean : function(forceReclean) {
70 if (Ext.Element.data(dom, 'isCleaned') && forceReclean !== true) {
75 var nx = n.nextSibling;
76 if (n.nodeType == 3 && !(/\S/.test(n.nodeValue))) {
84 Ext.Element.data(dom, 'isCleaned', true);
88 <div id="method-Ext.Element-load"></div>/**
89 * Direct access to the Updater {@link Ext.Updater#update} method. The method takes the same object
90 * parameter as {@link Ext.Updater#update}
91 * @return {Ext.Element} this
94 var updateManager = this.getUpdater();
95 updateManager.update.apply(updateManager, arguments);
100 <div id="method-Ext.Element-getUpdater"></div>/**
101 * Gets this element's {@link Ext.Updater Updater}
102 * @return {Ext.Updater} The Updater
104 getUpdater : function() {
105 return this.updateManager || (this.updateManager = new Ext.Updater(this));
108 <div id="method-Ext.Element-update"></div>/**
109 * Update the innerHTML of this element, optionally searching for and processing scripts
110 * @param {String} html The new HTML
111 * @param {Boolean} loadScripts (optional) True to look for and process scripts (defaults to false)
112 * @param {Function} callback (optional) For async script loading you can be notified when the update completes
113 * @return {Ext.Element} this
115 update : function(html, loadScripts, callback) {
121 if (loadScripts !== true) {
122 this.dom.innerHTML = html;
123 if (typeof callback == 'function') {
132 html += '<span id="' + id + '"></span>';
134 Ext.lib.Event.onAvailable(id, function() {
136 hd = DOC.getElementsByTagName("head")[0],
137 re = /(?:<script([^>]*)?>)((\n|\r|.)*?)(?:<\/script>)/ig,
138 srcRe = /\ssrc=([\'\"])(.*?)\1/i,
139 typeRe = /\stype=([\'\"])(.*?)\1/i,
147 while ((match = re.exec(html))) {
149 srcMatch = attrs ? attrs.match(srcRe) : false;
150 if (srcMatch && srcMatch[2]) {
151 s = DOC.createElement("script");
153 typeMatch = attrs.match(typeRe);
154 if (typeMatch && typeMatch[2]) {
155 s.type = typeMatch[2];
158 } else if (match[2] && match[2].length > 0) {
159 if (window.execScript) {
160 window.execScript(match[2]);
162 window.eval(match[2]);
167 el = DOC.getElementById(id);
172 if (typeof callback == 'function') {
176 dom.innerHTML = html.replace(/(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/ig, "");
180 // inherit docs, overridden so we can add removeAnchor
181 removeAllListeners : function() {
183 Ext.EventManager.removeAll(this.dom);
187 <div id="method-Ext.Element-createProxy"></div>/**
188 * Creates a proxy element of this element
189 * @param {String/Object} config The class name of the proxy element or a DomHelper config object
190 * @param {String/HTMLElement} renderTo (optional) The element or element id to render the proxy to (defaults to document.body)
191 * @param {Boolean} matchBox (optional) True to align and size the proxy to this element now (defaults to false)
192 * @return {Ext.Element} The new proxy element
194 createProxy : function(config, renderTo, matchBox) {
195 config = (typeof config == 'object') ? config : {tag : "div", cls: config};
198 proxy = renderTo ? Ext.DomHelper.append(renderTo, config, true) :
199 Ext.DomHelper.insertBefore(me.dom, config, true);
201 if (matchBox && me.setBox && me.getBox) { // check to make sure Element.position.js is loaded
202 proxy.setBox(me.getBox());
208 Ext.Element.prototype.getUpdateManager = Ext.Element.prototype.getUpdater;