3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\r
4 <title>The source code</title>
\r
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
8 <body onload="prettyPrint();">
\r
9 <pre class="prettyprint lang-js">/**
12 Ext.Element.addMethods({
13 <div id="method-Ext.Element-swallowEvent"></div>/**
14 * Stops the specified event(s) from bubbling and optionally prevents the default action
15 * @param {String/Array} eventName an event / array of events to stop from bubbling
16 * @param {Boolean} preventDefault (optional) true to prevent the default action too
17 * @return {Ext.Element} this
19 swallowEvent : function(eventName, preventDefault){
27 if(Ext.isArray(eventName)){
28 Ext.each(eventName, function(e) {
37 <div id="method-Ext.Element-relayEvent"></div>/**
38 * Create an event handler on this element such that when the event fires and is handled by this element,
39 * it will be relayed to another object (i.e., fired again as if it originated from that object instead).
40 * @param {String} eventName The type of event to relay
41 * @param {Object} object Any object that extends {@link Ext.util.Observable} that will provide the context
42 * for firing the relayed event
44 relayEvent : function(eventName, observable){
45 this.on(eventName, function(e){
46 observable.fireEvent(eventName, e);
50 <div id="method-Ext.Element-clean"></div>/**
51 * Removes worthless text nodes
52 * @param {Boolean} forceReclean (optional) By default the element
53 * keeps track if it has been cleaned already so
54 * you can call this over and over. However, if you update the element and
55 * need to force a reclean, you can pass true.
57 clean : function(forceReclean){
63 if(Ext.Element.data(dom, 'isCleaned') && forceReclean !== true){
68 var nx = n.nextSibling;
69 if(n.nodeType == 3 && !/\S/.test(n.nodeValue)){
76 Ext.Element.data(dom, 'isCleaned', true);
80 <div id="method-Ext.Element-load"></div>/**
81 * Direct access to the Updater {@link Ext.Updater#update} method. The method takes the same object
82 * parameter as {@link Ext.Updater#update}
83 * @return {Ext.Element} this
86 var um = this.getUpdater();
87 um.update.apply(um, arguments);
91 <div id="method-Ext.Element-getUpdater"></div>/**
92 * Gets this element's {@link Ext.Updater Updater}
93 * @return {Ext.Updater} The Updater
95 getUpdater : function(){
96 return this.updateManager || (this.updateManager = new Ext.Updater(this));
99 <div id="method-Ext.Element-update"></div>/**
100 * Update the innerHTML of this element, optionally searching for and processing scripts
101 * @param {String} html The new HTML
102 * @param {Boolean} loadScripts (optional) True to look for and process scripts (defaults to false)
103 * @param {Function} callback (optional) For async script loading you can be notified when the update completes
104 * @return {Ext.Element} this
106 update : function(html, loadScripts, callback){
112 if(loadScripts !== true){
113 this.dom.innerHTML = html;
114 if(Ext.isFunction(callback)){
123 html += '<span id="' + id + '"></span>';
125 Ext.lib.Event.onAvailable(id, function(){
127 hd = DOC.getElementsByTagName("head")[0],
128 re = /(?:<script([^>]*)?>)((\n|\r|.)*?)(?:<\/script>)/ig,
129 srcRe = /\ssrc=([\'\"])(.*?)\1/i,
130 typeRe = /\stype=([\'\"])(.*?)\1/i,
138 while((match = re.exec(html))){
140 srcMatch = attrs ? attrs.match(srcRe) : false;
141 if(srcMatch && srcMatch[2]){
142 s = DOC.createElement("script");
144 typeMatch = attrs.match(typeRe);
145 if(typeMatch && typeMatch[2]){
146 s.type = typeMatch[2];
149 }else if(match[2] && match[2].length > 0){
150 if(window.execScript) {
151 window.execScript(match[2]);
153 window.eval(match[2]);
157 el = DOC.getElementById(id);
158 if(el){Ext.removeNode(el);}
159 if(Ext.isFunction(callback)){
163 dom.innerHTML = html.replace(/(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/ig, "");
167 // inherit docs, overridden so we can add removeAnchor
168 removeAllListeners : function(){
170 Ext.EventManager.removeAll(this.dom);
174 <div id="method-Ext.Element-createProxy"></div>/**
175 * Creates a proxy element of this element
176 * @param {String/Object} config The class name of the proxy element or a DomHelper config object
177 * @param {String/HTMLElement} renderTo (optional) The element or element id to render the proxy to (defaults to document.body)
178 * @param {Boolean} matchBox (optional) True to align and size the proxy to this element now (defaults to false)
179 * @return {Ext.Element} The new proxy element
181 createProxy : function(config, renderTo, matchBox){
182 config = Ext.isObject(config) ? config : {tag : "div", cls: config};
185 proxy = renderTo ? Ext.DomHelper.append(renderTo, config, true) :
186 Ext.DomHelper.insertBefore(me.dom, config, true);
188 if(matchBox && me.setBox && me.getBox){ // check to make sure Element.position.js is loaded
189 proxy.setBox(me.getBox());
195 Ext.Element.prototype.getUpdateManager = Ext.Element.prototype.getUpdater;