⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 element.js

📁 Ext JS是一个创建丰富互联网应用程序的跨浏览器的JavaScrip库。它包含:高效率
💻 JS
📖 第 1 页 / 共 3 页
字号:
/*
 * Ext JS Library 3.0 Pre-alpha
 * Copyright(c) 2006-2008, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */

/** * @class Ext.Element * <p>Encapsulates a DOM element, adding simple DOM manipulation facilities, normalizing for browser differences.</p> * <p>All instances of this class inherit the methods of {@link Ext.Fx} making visual effects easily available to all DOM elements.</p> * <p>Note that the events documented in this class are not Ext events, they encapsulate browser events. To * access the underlying browser event, see {@link Ext.EventObject#browserEvent}. Some older * browsers may not support the full range of events. Which events are supported is beyond the control of ExtJs.</p> * Usage:<br><pre><code>// by idvar el = Ext.get("my-div");// by DOM element referencevar el = Ext.get(myDivElement);</code></pre> * <b>Animations</b><br /> * <p>When an element is manipulated, by default there is no animation.</p> * <pre><code>var el = Ext.get("my-div");// no animationel.setWidth(100); * </code></pre> * <p>Many of the functions for manipulating an element have an optional "animate" parameter.  This * parameter can be specified as boolean (<tt>true</tt>) for default animation effects.</p> * <pre><code>// default animationel.setWidth(100, true); * </code></pre> *  * <p>To configure the effects, an object literal with animation options to use as the Element animation * configuration object can also be specified. Note that the supported Element animation configuration * options are a subset of the {@link Ext.Fx} animation options specific to Fx effects.  The supported * Element animation configuration options are:</p><pre>Option    Default   Description--------- --------  ---------------------------------------------{@link Ext.Fx#duration duration}  .35       The duration of the animation in seconds{@link Ext.Fx#easing easing}    easeOut   The easing method{@link Ext.Fx#callback callback}  none      A function to execute when the anim completes{@link Ext.Fx#scope scope}     this      The scope (this) of the callback function</pre> *  * <pre><code>// Element animation options objectvar opt = {    {@link Ext.Fx#duration duration}: 1,    {@link Ext.Fx#easing easing}: 'elasticIn',    {@link Ext.Fx#callback callback}: this.foo,    {@link Ext.Fx#scope scope}: this};// animation with some options setel.setWidth(100, opt); * </code></pre> * <p>The Element animation object being used for the animation will be set on the options * object as "anim", which allows you to stop or manipulate the animation. Here is an example:</p> * <pre><code>// using the "anim" property to get the Anim objectif(opt.anim.isAnimated()){    opt.anim.stop();} * </code></pre> * <p>Also see the <tt>{@link #animate}</tt> method for another animation technique.</p> * <p><b> Composite (Collections of) Elements</b></p> * <p>For working with collections of Elements, see {@link Ext.CompositeElement}</p> * @constructor Create a new Element directly. * @param {String/HTMLElement} element * @param {Boolean} forceNew (optional) By default the constructor checks to see if there is already an instance of this element in the cache and if there is it returns the same instance. This will skip that check (useful for extending this class). */(function(){var DOC = document;Ext.Element = function(element, forceNew){    var dom = typeof element == "string" ?              DOC.getElementById(element) : element,    	id;    if(!dom) return null;    id = dom.id;    if(!forceNew && id && Ext.Element.cache[id]){ // element object already exists        return Ext.Element.cache[id];    }    /**     * The DOM element     * @type HTMLElement     */    this.dom = dom;    /**     * The DOM element ID     * @type String     */    this.id = id || Ext.id(dom);};var	D = Ext.lib.Dom,	DH = Ext.DomHelper,	E = Ext.lib.Event,	A = Ext.lib.Anim,	El = Ext.Element;El.prototype = {	/**     * Sets the passed attributes as attributes of this element (a style attribute can be a string, object or function)     * @param {Object} o The object with the attributes     * @param {Boolean} useSet (optional) false to override the default setAttribute to use expandos.     * @return {Ext.Element} this     */    set : function(o, useSet){        var el = this.dom,        	attr,        	val;       	               for(attr in o){	        val = o[attr];            if (attr != "style" && !Ext.isFunction(val)) {	            if (attr == "cls" ) {	                el.className = val;	            } else if (o.hasOwnProperty(attr)) {	                if (useSet || !!el.setAttribute) el.setAttribute(attr, val);	                else el[attr] = val;	            }            }        }        if(o.style){            Ext.DomHelper.applyStyles(el, o.style);        }        return this;    },	//  Mouse events    /**     * @event click     * Fires when a mouse click is detected with the element.     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event     */    /**     * @event dblclick     * Fires when a mouse double click is detected with the element.     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event     */    /**     * @event mousedown     * Fires when a mousedown is detected with the element.     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event     */    /**     * @event mouseup     * Fires when a mouseup is detected with the element.     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event     */    /**     * @event mouseover     * Fires when a mouseover is detected with the element.     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event     */    /**     * @event mousemove     * Fires when a mousemove is detected with the element.     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event     */    /**     * @event mouseout     * Fires when a mouseout is detected with the element.     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event     */    /**     * @event mouseenter     * Fires when a mouseenter is detected with the element.     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event     */    /**     * @event mouseleave     * Fires when a mouseleave is detected with the element.     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event     */    //  Keyboard events    /**     * @event keypress     * Fires when a keypress is detected with the element.     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event     */    /**     * @event keydown     * Fires when a keydown is detected with the element.     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event     */    /**     * @event keyup     * Fires when a keyup is detected with the element.     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event     *///  HTML frame/object events    /**     * @event load     * Fires when the user agent finishes loading all content within the element. Only supported by window, frames, objects and images.     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event     */    /**     * @event unload     * Fires when the user agent removes all content from a window or frame. For elements, it fires when the target element or any of its content has been removed.     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event     */    /**     * @event abort     * Fires when an object/image is stopped from loading before completely loaded.     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event     */    /**     * @event error     * Fires when an object/image/frame cannot be loaded properly.     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event     */    /**     * @event resize     * Fires when a document view is resized.     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event     */    /**     * @event scroll     * Fires when a document view is scrolled.     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event     *///  Form events    /**     * @event select     * Fires when a user selects some text in a text field, including input and textarea.     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event     */    /**     * @event change     * Fires when a control loses the input focus and its value has been modified since gaining focus.     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event     */    /**     * @event submit     * Fires when a form is submitted.     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event     */    /**     * @event reset     * Fires when a form is reset.     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event     */    /**     * @event focus     * Fires when an element receives focus either via the pointing device or by tab navigation.     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event     */    /**     * @event blur     * Fires when an element loses focus either via the pointing device or by tabbing navigation.     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event     *///  User Interface events    /**     * @event DOMFocusIn     * Where supported. Similar to HTML focus event, but can be applied to any focusable element.     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.     */    /**     * @event DOMFocusOut     * Where supported. Similar to HTML blur event, but can be applied to any focusable element.     * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event     */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -