3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js">/**
\r
11 Ext.Element.addMethods({
\r
12 <div id="method-Ext.Element-swallowEvent"></div>/**
\r
13 * Stops the specified event(s) from bubbling and optionally prevents the default action
\r
14 * @param {String/Array} eventName an event / array of events to stop from bubbling
\r
15 * @param {Boolean} preventDefault (optional) true to prevent the default action too
\r
16 * @return {Ext.Element} this
\r
18 swallowEvent : function(eventName, preventDefault){
\r
21 e.stopPropagation();
\r
26 if(Ext.isArray(eventName)){
\r
27 Ext.each(eventName, function(e) {
\r
32 me.on(eventName, fn);
\r
36 <div id="method-Ext.Element-relayEvent"></div>/**
\r
37 * Create an event handler on this element such that when the event fires and is handled by this element,
\r
38 * it will be relayed to another object (i.e., fired again as if it originated from that object instead).
\r
39 * @param {String} eventName The type of event to relay
\r
40 * @param {Object} object Any object that extends {@link Ext.util.Observable} that will provide the context
\r
41 * for firing the relayed event
\r
43 relayEvent : function(eventName, observable){
\r
44 this.on(eventName, function(e){
\r
45 observable.fireEvent(eventName, e);
\r
49 <div id="method-Ext.Element-clean"></div>/**
\r
50 * Removes worthless text nodes
\r
51 * @param {Boolean} forceReclean (optional) By default the element
\r
52 * keeps track if it has been cleaned already so
\r
53 * you can call this over and over. However, if you update the element and
\r
54 * need to force a reclean, you can pass true.
\r
56 clean : function(forceReclean){
\r
59 n = dom.firstChild,
\r
62 if(Ext.Element.data(dom, 'isCleaned') && forceReclean !== true){
\r
67 var nx = n.nextSibling;
\r
68 if(n.nodeType == 3 && !/\S/.test(n.nodeValue)){
\r
75 Ext.Element.data(dom, 'isCleaned', true);
\r
79 <div id="method-Ext.Element-load"></div>/**
\r
80 * Direct access to the Updater {@link Ext.Updater#update} method. The method takes the same object
\r
81 * parameter as {@link Ext.Updater#update}
\r
82 * @return {Ext.Element} this
\r
85 var um = this.getUpdater();
\r
86 um.update.apply(um, arguments);
\r
90 <div id="method-Ext.Element-getUpdater"></div>/**
\r
91 * Gets this element's {@link Ext.Updater Updater}
\r
92 * @return {Ext.Updater} The Updater
\r
94 getUpdater : function(){
\r
95 return this.updateManager || (this.updateManager = new Ext.Updater(this));
\r
98 <div id="method-Ext.Element-update"></div>/**
\r
99 * Update the innerHTML of this element, optionally searching for and processing scripts
\r
100 * @param {String} html The new HTML
\r
101 * @param {Boolean} loadScripts (optional) True to look for and process scripts (defaults to false)
\r
102 * @param {Function} callback (optional) For async script loading you can be notified when the update completes
\r
103 * @return {Ext.Element} this
\r
105 update : function(html, loadScripts, callback){
\r
108 if(loadScripts !== true){
\r
109 this.dom.innerHTML = html;
\r
110 if(Ext.isFunction(callback)){
\r
119 html += '<span id="' + id + '"></span>';
\r
121 Ext.lib.Event.onAvailable(id, function(){
\r
122 var DOC = document,
\r
123 hd = DOC.getElementsByTagName("head")[0],
\r
124 re = /(?:<script([^>]*)?>)((\n|\r|.)*?)(?:<\/script>)/ig,
\r
125 srcRe = /\ssrc=([\'\"])(.*?)\1/i,
\r
126 typeRe = /\stype=([\'\"])(.*?)\1/i,
\r
134 while((match = re.exec(html))){
\r
136 srcMatch = attrs ? attrs.match(srcRe) : false;
\r
137 if(srcMatch && srcMatch[2]){
\r
138 s = DOC.createElement("script");
\r
139 s.src = srcMatch[2];
\r
140 typeMatch = attrs.match(typeRe);
\r
141 if(typeMatch && typeMatch[2]){
\r
142 s.type = typeMatch[2];
\r
145 }else if(match[2] && match[2].length > 0){
\r
146 if(window.execScript) {
\r
147 window.execScript(match[2]);
\r
149 window.eval(match[2]);
\r
153 el = DOC.getElementById(id);
\r
154 if(el){Ext.removeNode(el);}
\r
155 if(Ext.isFunction(callback)){
\r
159 dom.innerHTML = html.replace(/(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/ig, "");
\r
163 <div id="method-Ext.Element-createProxy"></div>/**
\r
164 * Creates a proxy element of this element
\r
165 * @param {String/Object} config The class name of the proxy element or a DomHelper config object
\r
166 * @param {String/HTMLElement} renderTo (optional) The element or element id to render the proxy to (defaults to document.body)
\r
167 * @param {Boolean} matchBox (optional) True to align and size the proxy to this element now (defaults to false)
\r
168 * @return {Ext.Element} The new proxy element
\r
170 createProxy : function(config, renderTo, matchBox){
\r
171 config = Ext.isObject(config) ? config : {tag : "div", cls: config};
\r
174 proxy = renderTo ? Ext.DomHelper.append(renderTo, config, true) :
\r
175 Ext.DomHelper.insertBefore(me.dom, config, true);
\r
177 if(matchBox && me.setBox && me.getBox){ // check to make sure Element.position.js is loaded
\r
178 proxy.setBox(me.getBox());
\r
184 Ext.Element.prototype.getUpdateManager = Ext.Element.prototype.getUpdater;
\r
187 Ext.Element.uncache = function(el){
\r
188 for(var i = 0, a = arguments, len = a.length; i < len; i++) {
\r
190 delete Ext.Element.cache[a[i].id || a[i]];
\r