/*! * Ext JS Library 3.0.3 * Copyright(c) 2006-2009 Ext JS, LLC * licensing@extjs.com * http://www.extjs.com/license */ /** * @class Ext.Element */ Ext.Element.addMethods({ /** * Stops the specified event(s) from bubbling and optionally prevents the default action * @param {String/Array} eventName an event / array of events to stop from bubbling * @param {Boolean} preventDefault (optional) true to prevent the default action too * @return {Ext.Element} this */ swallowEvent : function(eventName, preventDefault){ var me = this; function fn(e){ e.stopPropagation(); if(preventDefault){ e.preventDefault(); } } if(Ext.isArray(eventName)){ Ext.each(eventName, function(e) { me.on(e, fn); }); return me; } me.on(eventName, fn); return me; }, /** * Create an event handler on this element such that when the event fires and is handled by this element, * it will be relayed to another object (i.e., fired again as if it originated from that object instead). * @param {String} eventName The type of event to relay * @param {Object} object Any object that extends {@link Ext.util.Observable} that will provide the context * for firing the relayed event */ relayEvent : function(eventName, observable){ this.on(eventName, function(e){ observable.fireEvent(eventName, e); }); }, /** * Removes worthless text nodes * @param {Boolean} forceReclean (optional) By default the element * keeps track if it has been cleaned already so * you can call this over and over. However, if you update the element and * need to force a reclean, you can pass true. */ clean : function(forceReclean){ var me = this, dom = me.dom, n = dom.firstChild, ni = -1; if(Ext.Element.data(dom, 'isCleaned') && forceReclean !== true){ return me; } while(n){ var nx = n.nextSibling; if(n.nodeType == 3 && !/\S/.test(n.nodeValue)){ dom.removeChild(n); }else{ n.nodeIndex = ++ni; } n = nx; } Ext.Element.data(dom, 'isCleaned', true); return me; }, /** * Direct access to the Updater {@link Ext.Updater#update} method. The method takes the same object * parameter as {@link Ext.Updater#update} * @return {Ext.Element} this */ load : function(){ var um = this.getUpdater(); um.update.apply(um, arguments); return this; }, /** * Gets this element's {@link Ext.Updater Updater} * @return {Ext.Updater} The Updater */ getUpdater : function(){ return this.updateManager || (this.updateManager = new Ext.Updater(this)); }, /** * Update the innerHTML of this element, optionally searching for and processing scripts * @param {String} html The new HTML * @param {Boolean} loadScripts (optional) True to look for and process scripts (defaults to false) * @param {Function} callback (optional) For async script loading you can be notified when the update completes * @return {Ext.Element} this */ update : function(html, loadScripts, callback){ html = html || ""; if(loadScripts !== true){ this.dom.innerHTML = html; if(Ext.isFunction(callback)){ callback(); } return this; } var id = Ext.id(), dom = this.dom; html += ''; Ext.lib.Event.onAvailable(id, function(){ var DOC = document, hd = DOC.getElementsByTagName("head")[0], re = /(?: