- getWheelDelta : function(){
- var e = this.browserEvent;
- var delta = 0;
- if(e.wheelDelta){ /* IE/Opera. */
- delta = e.wheelDelta/120;
- }else if(e.detail){ /* Mozilla case. */
- delta = -e.detail/3;
- }
- return delta;
- },
-
- /**
- * Returns true if the target of this event is a child of el. Unless the allowEl parameter is set, it will return false if if the target is el.
- * Example usage:<pre><code>
- // Handle click on any child of an element
- Ext.getBody().on('click', function(e){
- if(e.within('some-el')){
- alert('Clicked on a child of some-el!');
- }
- });
-
- // Handle click directly on an element, ignoring clicks on child nodes
- Ext.getBody().on('click', function(e,t){
- if((t.id == 'some-el') && !e.within(t, true)){
- alert('Clicked directly on some-el!');
- }
- });
- </code></pre>
- * @param {Mixed} el The id, DOM element or Ext.Element to check
- * @param {Boolean} related (optional) true to test if the related target is within el instead of the target
- * @param {Boolean} allowEl {optional} true to also check if the passed element is the target or related target
- * @return {Boolean}
- */
- within : function(el, related, allowEl){
- if(el){
- var t = this[related ? "getRelatedTarget" : "getTarget"]();
- return t && ((allowEl ? (t == Ext.getDom(el)) : false) || Ext.fly(el).contains(t));
- }
- return false;
- }
- };
-
- return new Ext.EventObjectImpl();
-}();/**\r
- * @class Ext.EventManager\r
- */\r
-Ext.apply(Ext.EventManager, function(){\r
- var resizeEvent, \r
- resizeTask, \r
- textEvent, \r
- textSize,\r
- D = Ext.lib.Dom,\r
- E = Ext.lib.Event,\r
- propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/,\r
- curWidth = 0,\r
- curHeight = 0,\r
- // note 1: IE fires ONLY the keydown event on specialkey autorepeat\r
- // note 2: Safari < 3.1, Gecko (Mac/Linux) & Opera fire only the keypress event on specialkey autorepeat\r
- // (research done by @Jan Wolter at http://unixpapa.com/js/key.html)\r
- useKeydown = Ext.isSafari ? \r
- Ext.num(navigator.userAgent.toLowerCase().match(/version\/(\d+\.\d)/)[1] || 2) >= 3.1 :\r
- !((Ext.isGecko && !Ext.isWindows) || Ext.isOpera);\r
- \r
- return { \r
- // private\r
- doResizeEvent: function(){\r
- var h = D.getViewHeight(),\r
- w = D.getViewWidth();\r
- \r
- //whacky problem in IE where the resize event will fire even though the w/h are the same.\r
- if(curHeight != h || curWidth != w){\r
- resizeEvent.fire(curWidth = w, curHeight = h);\r
- }\r
- },\r
- \r
- /**\r
- * Fires when the window is resized and provides resize event buffering (50 milliseconds), passes new viewport width and height to handlers.\r
- * @param {Function} fn The method the event invokes\r
- * @param {Object} scope An object that becomes the scope of the handler\r
- * @param {boolean} options\r
- */\r
- onWindowResize : function(fn, scope, options){\r
- if(!resizeEvent){\r
- resizeEvent = new Ext.util.Event();\r
- resizeTask = new Ext.util.DelayedTask(this.doResizeEvent);\r
- E.on(window, "resize", this.fireWindowResize, this);\r
- }\r
- resizeEvent.addListener(fn, scope, options);\r
- },\r
- \r
- // exposed only to allow manual firing\r
- fireWindowResize : function(){\r
- if(resizeEvent){\r
- if((Ext.isIE||Ext.isAir) && resizeTask){\r
- resizeTask.delay(50);\r
- }else{\r
- resizeEvent.fire(D.getViewWidth(), D.getViewHeight());\r
- }\r
- }\r
- },\r
- \r
- /**\r
- * Fires when the user changes the active text size. Handler gets called with 2 params, the old size and the new size.\r
- * @param {Function} fn The method the event invokes\r
- * @param {Object} scope An object that becomes the scope of the handler\r
- * @param {boolean} options\r
- */\r
- onTextResize : function(fn, scope, options){\r
- if(!textEvent){\r
- textEvent = new Ext.util.Event();\r
- var textEl = new Ext.Element(document.createElement('div'));\r
- textEl.dom.className = 'x-text-resize';\r
- textEl.dom.innerHTML = 'X';\r
- textEl.appendTo(document.body);\r
- textSize = textEl.dom.offsetHeight;\r
- setInterval(function(){\r
- if(textEl.dom.offsetHeight != textSize){\r
- textEvent.fire(textSize, textSize = textEl.dom.offsetHeight);\r
- }\r
- }, this.textResizeInterval);\r
- }\r
- textEvent.addListener(fn, scope, options);\r
- },\r
- \r
- /**\r
- * Removes the passed window resize listener.\r
- * @param {Function} fn The method the event invokes\r
- * @param {Object} scope The scope of handler\r
- */\r
- removeResizeListener : function(fn, scope){\r
- if(resizeEvent){\r
- resizeEvent.removeListener(fn, scope);\r
- }\r
- },\r
- \r
- // private\r
- fireResize : function(){\r
- if(resizeEvent){\r
- resizeEvent.fire(D.getViewWidth(), D.getViewHeight());\r
- }\r
- },\r
- \r
- /**\r
- * The frequency, in milliseconds, to check for text resize events (defaults to 50)\r
- */\r
- textResizeInterval : 50,\r
- \r
- /**\r
- * Url used for onDocumentReady with using SSL (defaults to Ext.SSL_SECURE_URL)\r
- */\r
- ieDeferSrc : false,\r
- \r
- // protected for use inside the framework\r
- // detects whether we should use keydown or keypress based on the browser.\r
- useKeydown: useKeydown\r
- };\r
-}());\r
-\r
-Ext.EventManager.on = Ext.EventManager.addListener;\r
-\r
-\r
-Ext.apply(Ext.EventObjectImpl.prototype, {\r
- /** Key constant @type Number */\r
- BACKSPACE: 8,\r
- /** Key constant @type Number */\r
- TAB: 9,\r
- /** Key constant @type Number */\r
- NUM_CENTER: 12,\r
- /** Key constant @type Number */\r
- ENTER: 13,\r
- /** Key constant @type Number */\r
- RETURN: 13,\r
- /** Key constant @type Number */\r
- SHIFT: 16,\r
- /** Key constant @type Number */\r
- CTRL: 17,\r
- CONTROL : 17, // legacy\r
- /** Key constant @type Number */\r
- ALT: 18,\r
- /** Key constant @type Number */\r
- PAUSE: 19,\r
- /** Key constant @type Number */\r
- CAPS_LOCK: 20,\r
- /** Key constant @type Number */\r
- ESC: 27,\r
- /** Key constant @type Number */\r
- SPACE: 32,\r
- /** Key constant @type Number */\r
- PAGE_UP: 33,\r
- PAGEUP : 33, // legacy\r
- /** Key constant @type Number */\r
- PAGE_DOWN: 34,\r
- PAGEDOWN : 34, // legacy\r
- /** Key constant @type Number */\r
- END: 35,\r
- /** Key constant @type Number */\r
- HOME: 36,\r
- /** Key constant @type Number */\r
- LEFT: 37,\r
- /** Key constant @type Number */\r
- UP: 38,\r
- /** Key constant @type Number */\r
- RIGHT: 39,\r
- /** Key constant @type Number */\r
- DOWN: 40,\r
- /** Key constant @type Number */\r
- PRINT_SCREEN: 44,\r
- /** Key constant @type Number */\r
- INSERT: 45,\r
- /** Key constant @type Number */\r
- DELETE: 46,\r
- /** Key constant @type Number */\r
- ZERO: 48,\r
- /** Key constant @type Number */\r
- ONE: 49,\r
- /** Key constant @type Number */\r
- TWO: 50,\r
- /** Key constant @type Number */\r
- THREE: 51,\r
- /** Key constant @type Number */\r
- FOUR: 52,\r
- /** Key constant @type Number */\r
- FIVE: 53,\r
- /** Key constant @type Number */\r
- SIX: 54,\r
- /** Key constant @type Number */\r
- SEVEN: 55,\r
- /** Key constant @type Number */\r
- EIGHT: 56,\r
- /** Key constant @type Number */\r
- NINE: 57,\r
- /** Key constant @type Number */\r
- A: 65,\r
- /** Key constant @type Number */\r
- B: 66,\r
- /** Key constant @type Number */\r
- C: 67,\r
- /** Key constant @type Number */\r
- D: 68,\r
- /** Key constant @type Number */\r
- E: 69,\r
- /** Key constant @type Number */\r
- F: 70,\r
- /** Key constant @type Number */\r
- G: 71,\r
- /** Key constant @type Number */\r
- H: 72,\r
- /** Key constant @type Number */\r
- I: 73,\r
- /** Key constant @type Number */\r
- J: 74,\r
- /** Key constant @type Number */\r
- K: 75,\r
- /** Key constant @type Number */\r
- L: 76,\r
- /** Key constant @type Number */\r
- M: 77,\r
- /** Key constant @type Number */\r
- N: 78,\r
- /** Key constant @type Number */\r
- O: 79,\r
- /** Key constant @type Number */\r
- P: 80,\r
- /** Key constant @type Number */\r
- Q: 81,\r
- /** Key constant @type Number */\r
- R: 82,\r
- /** Key constant @type Number */\r
- S: 83,\r
- /** Key constant @type Number */\r
- T: 84,\r
- /** Key constant @type Number */\r
- U: 85,\r
- /** Key constant @type Number */\r
- V: 86,\r
- /** Key constant @type Number */\r
- W: 87,\r
- /** Key constant @type Number */\r
- X: 88,\r
- /** Key constant @type Number */\r
- Y: 89,\r
- /** Key constant @type Number */\r
- Z: 90,\r
- /** Key constant @type Number */\r
- CONTEXT_MENU: 93,\r
- /** Key constant @type Number */\r
- NUM_ZERO: 96,\r
- /** Key constant @type Number */\r
- NUM_ONE: 97,\r
- /** Key constant @type Number */\r
- NUM_TWO: 98,\r
- /** Key constant @type Number */\r
- NUM_THREE: 99,\r
- /** Key constant @type Number */\r
- NUM_FOUR: 100,\r
- /** Key constant @type Number */\r
- NUM_FIVE: 101,\r
- /** Key constant @type Number */\r
- NUM_SIX: 102,\r
- /** Key constant @type Number */\r
- NUM_SEVEN: 103,\r
- /** Key constant @type Number */\r
- NUM_EIGHT: 104,\r
- /** Key constant @type Number */\r
- NUM_NINE: 105,\r
- /** Key constant @type Number */\r
- NUM_MULTIPLY: 106,\r
- /** Key constant @type Number */\r
- NUM_PLUS: 107,\r
- /** Key constant @type Number */\r
- NUM_MINUS: 109,\r
- /** Key constant @type Number */\r
- NUM_PERIOD: 110,\r
- /** Key constant @type Number */\r
- NUM_DIVISION: 111,\r
- /** Key constant @type Number */\r
- F1: 112,\r
- /** Key constant @type Number */\r
- F2: 113,\r
- /** Key constant @type Number */\r
- F3: 114,\r
- /** Key constant @type Number */\r
- F4: 115,\r
- /** Key constant @type Number */\r
- F5: 116,\r
- /** Key constant @type Number */\r
- F6: 117,\r
- /** Key constant @type Number */\r
- F7: 118,\r
- /** Key constant @type Number */\r
- F8: 119,\r
- /** Key constant @type Number */\r
- F9: 120,\r
- /** Key constant @type Number */\r
- F10: 121,\r
- /** Key constant @type Number */\r
- F11: 122,\r
- /** Key constant @type Number */\r
- F12: 123, \r
- \r
- /** @private */\r
- isNavKeyPress : function(){\r
- var me = this,\r
- k = this.normalizeKey(me.keyCode); \r
- return (k >= 33 && k <= 40) || // Page Up/Down, End, Home, Left, Up, Right, Down\r
- k == me.RETURN ||\r
- k == me.TAB ||\r
- k == me.ESC;\r
- },\r
-\r
- isSpecialKey : function(){\r
- var k = this.normalizeKey(this.keyCode);\r
- return (this.type == 'keypress' && this.ctrlKey) ||\r
- this.isNavKeyPress() ||\r
- (k == this.BACKSPACE) || // Backspace\r
- (k >= 16 && k <= 20) || // Shift, Ctrl, Alt, Pause, Caps Lock\r
- (k >= 44 && k <= 45); // Print Screen, Insert\r
- },\r
- \r
- getPoint : function(){\r
- return new Ext.lib.Point(this.xy[0], this.xy[1]);\r
- },\r
-\r
- /**\r
- * Returns true if the control, meta, shift or alt key was pressed during this event.\r
- * @return {Boolean}\r
- */\r
- hasModifier : function(){\r
- return ((this.ctrlKey || this.altKey) || this.shiftKey);\r
- }\r
-});/**\r
- * @class Ext.Element\r
- * <p>Encapsulates a DOM element, adding simple DOM manipulation facilities, normalizing for browser differences.</p>\r
- * <p>All instances of this class inherit the methods of {@link Ext.Fx} making visual effects easily available to all DOM elements.</p>\r
- * <p>Note that the events documented in this class are not Ext events, they encapsulate browser events. To\r
- * access the underlying browser event, see {@link Ext.EventObject#browserEvent}. Some older\r
- * browsers may not support the full range of events. Which events are supported is beyond the control of ExtJs.</p>\r
- * Usage:<br>\r
-<pre><code>\r
-// by id\r
-var el = Ext.get("my-div");\r
-\r
-// by DOM element reference\r
-var el = Ext.get(myDivElement);\r
-</code></pre>\r
- * <b>Animations</b><br />\r
- * <p>When an element is manipulated, by default there is no animation.</p>\r
- * <pre><code>\r
-var el = Ext.get("my-div");\r
-\r
-// no animation\r
-el.setWidth(100);\r
- * </code></pre>\r
- * <p>Many of the functions for manipulating an element have an optional "animate" parameter. This\r
- * parameter can be specified as boolean (<tt>true</tt>) for default animation effects.</p>\r
- * <pre><code>\r
-// default animation\r
-el.setWidth(100, true);\r
- * </code></pre>\r
- * \r
- * <p>To configure the effects, an object literal with animation options to use as the Element animation\r
- * configuration object can also be specified. Note that the supported Element animation configuration\r
- * options are a subset of the {@link Ext.Fx} animation options specific to Fx effects. The supported\r
- * Element animation configuration options are:</p>\r
-<pre>\r
-Option Default Description\r
---------- -------- ---------------------------------------------\r
-{@link Ext.Fx#duration duration} .35 The duration of the animation in seconds\r
-{@link Ext.Fx#easing easing} easeOut The easing method\r
-{@link Ext.Fx#callback callback} none A function to execute when the anim completes\r
-{@link Ext.Fx#scope scope} this The scope (this) of the callback function\r
-</pre>\r
- * \r
- * <pre><code>\r
-// Element animation options object\r
-var opt = {\r
- {@link Ext.Fx#duration duration}: 1,\r
- {@link Ext.Fx#easing easing}: 'elasticIn',\r
- {@link Ext.Fx#callback callback}: this.foo,\r
- {@link Ext.Fx#scope scope}: this\r
-};\r
-// animation with some options set\r
-el.setWidth(100, opt);\r
- * </code></pre>\r
- * <p>The Element animation object being used for the animation will be set on the options\r
- * object as "anim", which allows you to stop or manipulate the animation. Here is an example:</p>\r
- * <pre><code>\r
-// using the "anim" property to get the Anim object\r
-if(opt.anim.isAnimated()){\r
- opt.anim.stop();\r
-}\r
- * </code></pre>\r
- * <p>Also see the <tt>{@link #animate}</tt> method for another animation technique.</p>\r
- * <p><b> Composite (Collections of) Elements</b></p>\r
- * <p>For working with collections of Elements, see {@link Ext.CompositeElement}</p>\r
- * @constructor Create a new Element directly.\r
- * @param {String/HTMLElement} element\r
- * @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).\r
- */\r
-(function(){\r
-var DOC = document;\r
-\r
-Ext.Element = function(element, forceNew){\r
- var dom = typeof element == "string" ?\r
- DOC.getElementById(element) : element,\r
- id;\r
-\r
- if(!dom) return null;\r
-\r
- id = dom.id;\r
-\r
- if(!forceNew && id && Ext.Element.cache[id]){ // element object already exists\r
- return Ext.Element.cache[id];\r
- }\r
-\r
- /**\r
- * The DOM element\r
- * @type HTMLElement\r
- */\r
- this.dom = dom;\r
-\r
- /**\r
- * The DOM element ID\r
- * @type String\r
- */\r
- this.id = id || Ext.id(dom);\r
-};\r
-\r
-var D = Ext.lib.Dom,\r
- DH = Ext.DomHelper,\r
- E = Ext.lib.Event,\r
- A = Ext.lib.Anim,\r
- El = Ext.Element;\r
-\r
-El.prototype = {\r
- /**\r
- * Sets the passed attributes as attributes of this element (a style attribute can be a string, object or function)\r
- * @param {Object} o The object with the attributes\r
- * @param {Boolean} useSet (optional) false to override the default setAttribute to use expandos.\r
- * @return {Ext.Element} this\r
- */\r
- set : function(o, useSet){\r
- var el = this.dom,\r
- attr,\r
- val; \r
- \r
- for(attr in o){\r
- val = o[attr];\r
- if (attr != "style" && !Ext.isFunction(val)) {\r
- if (attr == "cls" ) {\r
- el.className = val;\r
- } else if (o.hasOwnProperty(attr)) {\r
- if (useSet || !!el.setAttribute) el.setAttribute(attr, val);\r
- else el[attr] = val;\r
- }\r
- }\r
- }\r
- if(o.style){\r
- Ext.DomHelper.applyStyles(el, o.style);\r
- }\r
- return this;\r
- },\r
- \r
-// Mouse events\r
- /**\r
- * @event click\r
- * Fires when a mouse click is detected within the element.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
- /**\r
- * @event dblclick\r
- * Fires when a mouse double click is detected within the element.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
- /**\r
- * @event mousedown\r
- * Fires when a mousedown is detected within the element.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
- /**\r
- * @event mouseup\r
- * Fires when a mouseup is detected within the element.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
- /**\r
- * @event mouseover\r
- * Fires when a mouseover is detected within the element.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
- /**\r
- * @event mousemove\r
- * Fires when a mousemove is detected with the element.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
- /**\r
- * @event mouseout\r
- * Fires when a mouseout is detected with the element.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
- /**\r
- * @event mouseenter\r
- * Fires when the mouse enters the element.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
- /**\r
- * @event mouseleave\r
- * Fires when the mouse leaves the element.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
- \r
-// Keyboard events\r
- /**\r
- * @event keypress\r
- * Fires when a keypress is detected within the element.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
- /**\r
- * @event keydown\r
- * Fires when a keydown is detected within the element.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
- /**\r
- * @event keyup\r
- * Fires when a keyup is detected within the element.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
-\r
-\r
-// HTML frame/object events\r
- /**\r
- * @event load\r
- * Fires when the user agent finishes loading all content within the element. Only supported by window, frames, objects and images.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
- /**\r
- * @event unload\r
- * 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.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
- /**\r
- * @event abort\r
- * Fires when an object/image is stopped from loading before completely loaded.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
- /**\r
- * @event error\r
- * Fires when an object/image/frame cannot be loaded properly.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
- /**\r
- * @event resize\r
- * Fires when a document view is resized.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
- /**\r
- * @event scroll\r
- * Fires when a document view is scrolled.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
-\r
-// Form events\r
- /**\r
- * @event select\r
- * Fires when a user selects some text in a text field, including input and textarea.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
- /**\r
- * @event change\r
- * Fires when a control loses the input focus and its value has been modified since gaining focus.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
- /**\r
- * @event submit\r
- * Fires when a form is submitted.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
- /**\r
- * @event reset\r
- * Fires when a form is reset.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
- /**\r
- * @event focus\r
- * Fires when an element receives focus either via the pointing device or by tab navigation.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
- /**\r
- * @event blur\r
- * Fires when an element loses focus either via the pointing device or by tabbing navigation.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
-\r
-// User Interface events\r
- /**\r
- * @event DOMFocusIn\r
- * Where supported. Similar to HTML focus event, but can be applied to any focusable element.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
- /**\r
- * @event DOMFocusOut\r
- * Where supported. Similar to HTML blur event, but can be applied to any focusable element.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
- /**\r
- * @event DOMActivate\r
- * Where supported. Fires when an element is activated, for instance, through a mouse click or a keypress.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
-\r
-// DOM Mutation events\r
- /**\r
- * @event DOMSubtreeModified\r
- * Where supported. Fires when the subtree is modified.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
- /**\r
- * @event DOMNodeInserted\r
- * Where supported. Fires when a node has been added as a child of another node.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
- /**\r
- * @event DOMNodeRemoved\r
- * Where supported. Fires when a descendant node of the element is removed.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
- /**\r
- * @event DOMNodeRemovedFromDocument\r
- * Where supported. Fires when a node is being removed from a document.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
- /**\r
- * @event DOMNodeInsertedIntoDocument\r
- * Where supported. Fires when a node is being inserted into a document.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
- /**\r
- * @event DOMAttrModified\r
- * Where supported. Fires when an attribute has been modified.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
- /**\r
- * @event DOMCharacterDataModified\r
- * Where supported. Fires when the character data has been modified.\r
- * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.\r
- * @param {HtmlElement} t The target of the event.\r
- * @param {Object} o The options configuration passed to the {@link #addListener} call.\r
- */\r
-\r
- /**\r
- * The default unit to append to CSS values where a unit isn't provided (defaults to px).\r
- * @type String\r
- */\r
- defaultUnit : "px",\r
-\r
- /**\r
- * Returns true if this element matches the passed simple selector (e.g. div.some-class or span:first-child)\r
- * @param {String} selector The simple selector to test\r
- * @return {Boolean} True if this element matches the selector, else false\r
- */\r
- is : function(simpleSelector){\r
- return Ext.DomQuery.is(this.dom, simpleSelector);\r
- },\r
-\r
- /**\r
- * Tries to focus the element. Any exceptions are caught and ignored.\r
- * @param {Number} defer (optional) Milliseconds to defer the focus\r
- * @return {Ext.Element} this\r
- */\r
- focus : function(defer, /* private */ dom) {\r
- var me = this,\r
- dom = dom || me.dom;\r
- try{\r
- if(Number(defer)){\r
- me.focus.defer(defer, null, [null, dom]);\r
- }else{\r
- dom.focus();\r
- }\r
- }catch(e){}\r
- return me;\r
- },\r
-\r
- /**\r
- * Tries to blur the element. Any exceptions are caught and ignored.\r
- * @return {Ext.Element} this\r
- */\r
- blur : function() {\r
- try{\r
- this.dom.blur();\r
- }catch(e){}\r
- return this;\r
- },\r
-\r
- /**\r
- * Returns the value of the "value" attribute\r
- * @param {Boolean} asNumber true to parse the value as a number\r
- * @return {String/Number}\r
- */\r
- getValue : function(asNumber){\r
- var val = this.dom.value;\r
- return asNumber ? parseInt(val, 10) : val;\r
- },\r
-\r
- /**\r
- * Appends an event handler to this element. The shorthand version {@link #on} is equivalent.\r
- * @param {String} eventName The type of event to handle\r
- * @param {Function} fn The handler function the event invokes. This function is passed\r
- * the following parameters:<ul>\r
- * <li><b>evt</b> : EventObject<div class="sub-desc">The {@link Ext.EventObject EventObject} describing the event.</div></li>\r
- * <li><b>el</b> : Element<div class="sub-desc">The {@link Ext.Element Element} which was the target of the event.\r
- * Note that this may be filtered by using the <tt>delegate</tt> option.</div></li>\r
- * <li><b>o</b> : Object<div class="sub-desc">The options object from the addListener call.</div></li>\r
- * </ul>\r
- * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the handler function is executed.\r
- * <b>If omitted, defaults to this Element.</b>.\r
- * @param {Object} options (optional) An object containing handler configuration properties.\r
- * This may contain any of the following properties:<ul>\r
- * <li><b>scope</b> Object : <div class="sub-desc">The scope (<code><b>this</b></code> reference) in which the handler function is executed.\r
- * <b>If omitted, defaults to this Element.</b></div></li>\r
- * <li><b>delegate</b> String: <div class="sub-desc">A simple selector to filter the target or look for a descendant of the target. See below for additional details.</div></li>\r
- * <li><b>stopEvent</b> Boolean: <div class="sub-desc">True to stop the event. That is stop propagation, and prevent the default action.</div></li>\r
- * <li><b>preventDefault</b> Boolean: <div class="sub-desc">True to prevent the default action</div></li>\r
- * <li><b>stopPropagation</b> Boolean: <div class="sub-desc">True to prevent event propagation</div></li>\r
- * <li><b>normalized</b> Boolean: <div class="sub-desc">False to pass a browser event to the handler function instead of an Ext.EventObject</div></li>\r
- * <li><b>target</b> Ext.Element: <div class="sub-desc">Only call the handler if the event was fired on the target Element, <i>not</i> if the event was bubbled up from a child node.</div></li>\r
- * <li><b>delay</b> Number: <div class="sub-desc">The number of milliseconds to delay the invocation of the handler after the event fires.</div></li>\r
- * <li><b>single</b> Boolean: <div class="sub-desc">True to add a handler to handle just the next firing of the event, and then remove itself.</div></li>\r
- * <li><b>buffer</b> Number: <div class="sub-desc">Causes the handler to be scheduled to run in an {@link Ext.util.DelayedTask} delayed\r
- * by the specified number of milliseconds. If the event fires again within that time, the original\r
- * handler is <em>not</em> invoked, but the new handler is scheduled in its place.</div></li>\r
- * </ul><br>\r
- * <p>\r
- * <b>Combining Options</b><br>\r
- * In the following examples, the shorthand form {@link #on} is used rather than the more verbose\r
- * addListener. The two are equivalent. Using the options argument, it is possible to combine different\r
- * types of listeners:<br>\r
- * <br>\r
- * A delayed, one-time listener that auto stops the event and adds a custom argument (forumId) to the\r
- * options object. The options object is available as the third parameter in the handler function.<div style="margin: 5px 20px 20px;">\r
- * Code:<pre><code>\r
-el.on('click', this.onClick, this, {\r
- single: true,\r
- delay: 100,\r
- stopEvent : true,\r
- forumId: 4\r
-});</code></pre></p>\r
- * <p>\r
- * <b>Attaching multiple handlers in 1 call</b><br>\r
- * The method also allows for a single argument to be passed which is a config object containing properties\r
- * which specify multiple handlers.</p>\r
- * <p>\r
- * Code:<pre><code>\r
-el.on({\r
- 'click' : {\r
- fn: this.onClick,\r
- scope: this,\r
- delay: 100\r
- },\r
- 'mouseover' : {\r
- fn: this.onMouseOver,\r
- scope: this\r
- },\r
- 'mouseout' : {\r
- fn: this.onMouseOut,\r
- scope: this\r
- }\r
-});</code></pre>\r
- * <p>\r
- * Or a shorthand syntax:<br>\r
- * Code:<pre><code></p>\r
-el.on({\r
- 'click' : this.onClick,\r
- 'mouseover' : this.onMouseOver,\r
- 'mouseout' : this.onMouseOut,\r
- scope: this\r
-});\r
- * </code></pre></p>\r
- * <p><b>delegate</b></p>\r
- * <p>This is a configuration option that you can pass along when registering a handler for\r
- * an event to assist with event delegation. Event delegation is a technique that is used to\r
- * reduce memory consumption and prevent exposure to memory-leaks. By registering an event\r
- * for a container element as opposed to each element within a container. By setting this\r
- * configuration option to a simple selector, the target element will be filtered to look for\r
- * a descendant of the target.\r
- * For example:<pre><code>\r
-// using this markup:\r
-<div id='elId'>\r
- <p id='p1'>paragraph one</p>\r
- <p id='p2' class='clickable'>paragraph two</p>\r
- <p id='p3'>paragraph three</p>\r
-</div>\r
-// utilize event delegation to registering just one handler on the container element: \r
-el = Ext.get('elId');\r
-el.on(\r
- 'click',\r
- function(e,t) {\r
- // handle click\r
- console.info(t.id); // 'p2'\r
- },\r
- this,\r
- {\r
- // filter the target element to be a descendant with the class 'clickable'\r
- delegate: '.clickable' \r
- }\r
-);\r
- * </code></pre></p>\r
- * @return {Ext.Element} this\r
- */\r
- addListener : function(eventName, fn, scope, options){\r
- Ext.EventManager.on(this.dom, eventName, fn, scope || this, options);\r
- return this;\r
- },\r
-\r
- /**\r
- * Removes an event handler from this element. The shorthand version {@link #un} is equivalent.\r
- * <b>Note</b>: if a <i>scope</i> was explicitly specified when {@link #addListener adding} the\r
- * listener, the same scope must be specified here.\r
- * Example:\r
- * <pre><code>\r
-el.removeListener('click', this.handlerFn);\r
-// or\r
-el.un('click', this.handlerFn);\r
-</code></pre>\r
- * @param {String} eventName the type of event to remove\r
- * @param {Function} fn the method the event invokes\r
- * @param {Object} scope (optional) The scope (The <tt>this</tt> reference) of the handler function. Defaults\r
- * to this Element.\r
- * @return {Ext.Element} this\r
- */\r
- removeListener : function(eventName, fn, scope){\r
- Ext.EventManager.removeListener(this.dom, eventName, fn, scope || this);\r
- return this;\r
- },\r
-\r
- /**\r
- * Removes all previous added listeners from this element\r
- * @return {Ext.Element} this\r
- */\r
- removeAllListeners : function(){\r
- Ext.EventManager.removeAll(this.dom);\r
- return this;\r
- },\r
-\r
- /**\r
- * @private Test if size has a unit, otherwise appends the default\r
- */\r
- addUnits : function(size){\r
- if(size === "" || size == "auto" || size === undefined){\r
- size = size || '';\r
- } else if(!isNaN(size) || !unitPattern.test(size)){\r
- size = size + (this.defaultUnit || 'px');\r
- }\r
- return size;\r
- },\r
-\r
- /**\r
- * <p>Updates the <a href="http://developer.mozilla.org/en/DOM/element.innerHTML">innerHTML</a> of this Element\r
- * from a specified URL. Note that this is subject to the <a href="http://en.wikipedia.org/wiki/Same_origin_policy">Same Origin Policy</a></p>\r
- * <p>Updating innerHTML of an element will <b>not</b> execute embedded <tt><script></tt> elements. This is a browser restriction.</p>\r
- * @param {Mixed} options. Either a sring containing the URL from which to load the HTML, or an {@link Ext.Ajax#request} options object specifying\r
- * exactly how to request the HTML.\r
- * @return {Ext.Element} this\r
- */\r
- load : function(url, params, cb){\r
- Ext.Ajax.request(Ext.apply({\r
- params: params,\r
- url: url.url || url,\r
- callback: cb,\r
- el: this.dom,\r
- indicatorText: url.indicatorText || ''\r
- }, Ext.isObject(url) ? url : {}));\r
- return this;\r
- },\r
-\r
- /**\r
- * Tests various css rules/browsers to determine if this element uses a border box\r
- * @return {Boolean}\r
- */\r
- isBorderBox : function(){\r
- return noBoxAdjust[(this.dom.tagName || "").toLowerCase()] || Ext.isBorderBox;\r
- },\r
-\r
- /**\r
- * Removes this element from the DOM and deletes it from the cache\r
- */\r
- remove : function(){\r
- var me = this,\r
- dom = me.dom;\r
- \r
- me.removeAllListeners();\r
- delete El.cache[dom.id];\r
- delete El.dataCache[dom.id]\r
- Ext.removeNode(dom);\r
- },\r
-\r
- /**\r
- * Sets up event handlers to call the passed functions when the mouse is moved into and out of the Element.\r
- * @param {Function} overFn The function to call when the mouse enters the Element.\r
- * @param {Function} outFn The function to call when the mouse leaves the Element.\r
- * @param {Object} scope (optional) The scope (<tt>this</tt> reference) in which the functions are executed. Defaults to the Element's DOM element.\r
- * @param {Object} options (optional) Options for the listener. See {@link Ext.util.Observable#addListener the <tt>options</tt> parameter}.\r
- * @return {Ext.Element} this\r
- */\r
- hover : function(overFn, outFn, scope, options){\r
- var me = this;\r
- me.on('mouseenter', overFn, scope || me.dom, options);\r
- me.on('mouseleave', outFn, scope || me.dom, options);\r
- return me;\r
- },\r
-\r
- /**\r
- * Returns true if this element is an ancestor of the passed element\r
- * @param {HTMLElement/String} el The element to check\r
- * @return {Boolean} True if this element is an ancestor of el, else false\r
- */\r
- contains : function(el){\r
- return !el ? false : Ext.lib.Dom.isAncestor(this.dom, el.dom ? el.dom : el);\r
- },\r
-\r
- /**\r
- * Returns the value of a namespaced attribute from the element's underlying DOM node.\r
- * @param {String} namespace The namespace in which to look for the attribute\r
- * @param {String} name The attribute name\r
- * @return {String} The attribute value\r
- * @deprecated\r
- */\r
- getAttributeNS : function(ns, name){\r
- return this.getAttribute(name, ns); \r
- },\r
- \r
- /**\r
- * Returns the value of an attribute from the element's underlying DOM node.\r
- * @param {String} name The attribute name\r
- * @param {String} namespace (optional) The namespace in which to look for the attribute\r
- * @return {String} The attribute value\r
- */\r
- getAttribute : Ext.isIE ? function(name, ns){\r
- var d = this.dom,\r
- type = typeof d[ns + ":" + name];\r
-\r
- if(['undefined', 'unknown'].indexOf(type) == -1){\r
- return d[ns + ":" + name];\r
- }\r
- return d[name];\r
- } : function(name, ns){\r
- var d = this.dom;\r
- return d.getAttributeNS(ns, name) || d.getAttribute(ns + ":" + name) || d.getAttribute(name) || d[name];\r
- },\r
- \r
- /**\r
- * Update the innerHTML of this element\r
- * @param {String} html The new HTML\r
- * @return {Ext.Element} this\r
- */\r
- update : function(html) {\r
- this.dom.innerHTML = html;\r
- return this;\r
- }\r
-};\r
-\r
-var ep = El.prototype;\r
-\r
-El.addMethods = function(o){\r
- Ext.apply(ep, o);\r
-};\r
-\r
-/**\r
- * Appends an event handler (shorthand for {@link #addListener}).\r
- * @param {String} eventName The type of event to handle\r
- * @param {Function} fn The handler function the event invokes\r
- * @param {Object} scope (optional) The scope (this element) of the handler function\r
- * @param {Object} options (optional) An object containing standard {@link #addListener} options\r
- * @member Ext.Element\r
- * @method on\r
- */\r
-ep.on = ep.addListener;\r
-\r
-/**\r
- * Removes an event handler from this element (see {@link #removeListener} for additional notes).\r
- * @param {String} eventName the type of event to remove\r
- * @param {Function} fn the method the event invokes\r
- * @param {Object} scope (optional) The scope (The <tt>this</tt> reference) of the handler function. Defaults\r
- * to this Element.\r
- * @return {Ext.Element} this\r
- * @member Ext.Element\r
- * @method un\r
- */\r
-ep.un = ep.removeListener;\r
-\r
-/**\r
- * true to automatically adjust width and height settings for box-model issues (default to true)\r
- */\r
-ep.autoBoxAdjust = true;\r
-\r
-// private\r
-var unitPattern = /\d+(px|em|%|en|ex|pt|in|cm|mm|pc)$/i,\r
- docEl;\r
-\r
-/**\r
- * @private\r
- */\r
-El.cache = {};\r
-El.dataCache = {};\r
-\r
-/**\r
- * Retrieves Ext.Element objects.\r
- * <p><b>This method does not retrieve {@link Ext.Component Component}s.</b> This method\r
- * retrieves Ext.Element objects which encapsulate DOM elements. To retrieve a Component by\r
- * its ID, use {@link Ext.ComponentMgr#get}.</p>\r
- * <p>Uses simple caching to consistently return the same object. Automatically fixes if an\r
- * object was recreated with the same id via AJAX or DOM.</p>\r
- * @param {Mixed} el The id of the node, a DOM Node or an existing Element.\r
- * @return {Element} The Element object (or null if no matching element was found)\r
- * @static\r
- * @member Ext.Element\r
- * @method get\r
- */\r
-El.get = function(el){\r
- var ex,\r
- elm,\r
- id;\r
- if(!el){ return null; }\r
- if (typeof el == "string") { // element id\r
- if (!(elm = DOC.getElementById(el))) {\r
- return null;\r
- }\r
- if (ex = El.cache[el]) {\r
- ex.dom = elm;\r
- } else {\r
- ex = El.cache[el] = new El(elm);\r
- }\r
- return ex;\r
- } else if (el.tagName) { // dom element\r
- if(!(id = el.id)){\r
- id = Ext.id(el);\r
- }\r
- if(ex = El.cache[id]){\r
- ex.dom = el;\r
- }else{\r
- ex = El.cache[id] = new El(el);\r
- }\r
- return ex;\r
- } else if (el instanceof El) {\r
- if(el != docEl){\r
- el.dom = DOC.getElementById(el.id) || el.dom; // refresh dom element in case no longer valid,\r
- // catch case where it hasn't been appended\r
- El.cache[el.id] = el; // in case it was created directly with Element(), let's cache it\r
- }\r
- return el;\r
- } else if(el.isComposite) {\r
- return el;\r
- } else if(Ext.isArray(el)) {\r
- return El.select(el);\r
- } else if(el == DOC) {\r
- // create a bogus element object representing the document object\r
- if(!docEl){\r
- var f = function(){};\r
- f.prototype = El.prototype;\r
- docEl = new f();\r
- docEl.dom = DOC;\r
- }\r
- return docEl;\r
- }\r
- return null;\r
-};\r
-\r
-// private method for getting and setting element data\r
-El.data = function(el, key, value){\r
- var c = El.dataCache[el.id];\r
- if(!c){\r
- c = El.dataCache[el.id] = {};\r
- }\r
- if(arguments.length == 2){\r
- return c[key]; \r
- }else{\r
- c[key] = value;\r
- }\r
-};\r
-\r
-// private\r
-// Garbage collection - uncache elements/purge listeners on orphaned elements\r
-// so we don't hold a reference and cause the browser to retain them\r
-function garbageCollect(){\r
- if(!Ext.enableGarbageCollector){\r
- clearInterval(El.collectorThread);\r
- } else {\r
- var eid,\r
- el,\r
- d;\r
-\r
- for(eid in El.cache){\r
- el = El.cache[eid];\r
- d = el.dom;\r
- // -------------------------------------------------------\r
- // Determining what is garbage:\r
- // -------------------------------------------------------\r
- // !d\r
- // dom node is null, definitely garbage\r
- // -------------------------------------------------------\r
- // !d.parentNode\r
- // no parentNode == direct orphan, definitely garbage\r
- // -------------------------------------------------------\r
- // !d.offsetParent && !document.getElementById(eid)\r
- // display none elements have no offsetParent so we will\r
- // also try to look it up by it's id. However, check\r
- // offsetParent first so we don't do unneeded lookups.\r
- // This enables collection of elements that are not orphans\r
- // directly, but somewhere up the line they have an orphan\r
- // parent.\r
- // -------------------------------------------------------\r
- if(!d || !d.parentNode || (!d.offsetParent && !DOC.getElementById(eid))){\r
- delete El.cache[eid];\r
- if(d && Ext.enableListenerCollection){\r
- Ext.EventManager.removeAll(d);\r
- }\r
- }\r
- }\r
- }\r
-}\r
-El.collectorThreadId = setInterval(garbageCollect, 30000);\r
-\r
-var flyFn = function(){};\r
-flyFn.prototype = El.prototype;\r
-\r
-// dom is optional\r
-El.Flyweight = function(dom){\r
- this.dom = dom;\r
-};\r
-\r
-El.Flyweight.prototype = new flyFn();\r
-El.Flyweight.prototype.isFlyweight = true;\r
-El._flyweights = {};\r
-\r
-/**\r
- * <p>Gets the globally shared flyweight Element, with the passed node as the active element. Do not store a reference to this element -\r
- * the dom node can be overwritten by other code. Shorthand of {@link Ext.Element#fly}</p>\r
- * <p>Use this to make one-time references to DOM elements which are not going to be accessed again either by\r
- * application code, or by Ext's classes. If accessing an element which will be processed regularly, then {@link Ext#get}\r
- * will be more appropriate to take advantage of the caching provided by the Ext.Element class.</p>\r
- * @param {String/HTMLElement} el The dom node or id\r
- * @param {String} named (optional) Allows for creation of named reusable flyweights to prevent conflicts\r
- * (e.g. internally Ext uses "_global")\r
- * @return {Element} The shared Element object (or null if no matching element was found)\r
- * @member Ext.Element\r
- * @method fly\r
- */\r
-El.fly = function(el, named){\r
- var ret = null;\r
- named = named || '_global';\r
-\r
- if (el = Ext.getDom(el)) {\r
- (El._flyweights[named] = El._flyweights[named] || new El.Flyweight()).dom = el;\r
- ret = El._flyweights[named];\r
- }\r
- return ret;\r
-};\r
-\r
-/**\r
- * Retrieves Ext.Element objects.\r
- * <p><b>This method does not retrieve {@link Ext.Component Component}s.</b> This method\r
- * retrieves Ext.Element objects which encapsulate DOM elements. To retrieve a Component by\r
- * its ID, use {@link Ext.ComponentMgr#get}.</p>\r
- * <p>Uses simple caching to consistently return the same object. Automatically fixes if an\r
- * object was recreated with the same id via AJAX or DOM.</p>\r
- * Shorthand of {@link Ext.Element#get}\r
- * @param {Mixed} el The id of the node, a DOM Node or an existing Element.\r
- * @return {Element} The Element object (or null if no matching element was found)\r
- * @member Ext\r
- * @method get\r
- */\r
-Ext.get = El.get;\r
-\r
-/**\r
- * <p>Gets the globally shared flyweight Element, with the passed node as the active element. Do not store a reference to this element -\r
- * the dom node can be overwritten by other code. Shorthand of {@link Ext.Element#fly}</p>\r
- * <p>Use this to make one-time references to DOM elements which are not going to be accessed again either by\r
- * application code, or by Ext's classes. If accessing an element which will be processed regularly, then {@link Ext#get}\r
- * will be more appropriate to take advantage of the caching provided by the Ext.Element class.</p>\r
- * @param {String/HTMLElement} el The dom node or id\r
- * @param {String} named (optional) Allows for creation of named reusable flyweights to prevent conflicts\r
- * (e.g. internally Ext uses "_global")\r
- * @return {Element} The shared Element object (or null if no matching element was found)\r
- * @member Ext\r
- * @method fly\r
- */\r
-Ext.fly = El.fly;\r
-\r
-// speedy lookup for elements never to box adjust\r
-var noBoxAdjust = Ext.isStrict ? {\r
- select:1\r
-} : {\r
- input:1, select:1, textarea:1\r
-};\r
-if(Ext.isIE || Ext.isGecko){\r
- noBoxAdjust['button'] = 1;\r
-}\r
-\r
-\r
-Ext.EventManager.on(window, 'unload', function(){\r
- delete El.cache;\r
- delete El.dataCache;\r
- delete El._flyweights;\r
-});\r
-})();\r
-/**\r
- * @class Ext.Element\r
- */\r
-Ext.Element.addMethods({ \r
- /**\r
- * Stops the specified event(s) from bubbling and optionally prevents the default action\r
- * @param {String/Array} eventName an event / array of events to stop from bubbling\r
- * @param {Boolean} preventDefault (optional) true to prevent the default action too\r
- * @return {Ext.Element} this\r
- */\r
- swallowEvent : function(eventName, preventDefault){\r
- var me = this;\r
- function fn(e){\r
- e.stopPropagation();\r
- if(preventDefault){\r
- e.preventDefault();\r
- }\r
- }\r
- if(Ext.isArray(eventName)){ \r
- Ext.each(eventName, function(e) {\r
- me.on(e, fn);\r
- });\r
- return me;\r
- }\r
- me.on(eventName, fn);\r
- return me;\r
- },\r
- \r
- /**\r
- * Create an event handler on this element such that when the event fires and is handled by this element,\r
- * it will be relayed to another object (i.e., fired again as if it originated from that object instead).\r
- * @param {String} eventName The type of event to relay\r
- * @param {Object} object Any object that extends {@link Ext.util.Observable} that will provide the context\r
- * for firing the relayed event\r
- */\r
- relayEvent : function(eventName, observable){\r
- this.on(eventName, function(e){\r
- observable.fireEvent(eventName, e);\r
- });\r
- },\r
- \r
- /**\r
- * Removes worthless text nodes\r
- * @param {Boolean} forceReclean (optional) By default the element\r
- * keeps track if it has been cleaned already so\r
- * you can call this over and over. However, if you update the element and\r
- * need to force a reclean, you can pass true.\r
- */\r
- clean : function(forceReclean){\r
- var me = this, \r
- dom = me.dom,\r
- n = dom.firstChild, \r
- ni = -1;\r
- \r
- if(Ext.Element.data(dom, 'isCleaned') && forceReclean !== true){\r
- return me;\r
- } \r
- \r
- while(n){\r
- var nx = n.nextSibling;\r
- if(n.nodeType == 3 && !/\S/.test(n.nodeValue)){\r
- dom.removeChild(n);\r
- }else{\r
- n.nodeIndex = ++ni;\r
- }\r
- n = nx;\r
- }\r
- Ext.Element.data(dom, 'isCleaned', true);\r
- return me;\r
- },\r
- \r
- /**\r
- * Direct access to the Updater {@link Ext.Updater#update} method. The method takes the same object\r
- * parameter as {@link Ext.Updater#update}\r
- * @return {Ext.Element} this\r
- */\r
- load : function(){\r
- var um = this.getUpdater();\r
- um.update.apply(um, arguments);\r
- return this;\r
- },\r
-\r
- /**\r
- * Gets this element's {@link Ext.Updater Updater}\r
- * @return {Ext.Updater} The Updater\r
- */\r
- getUpdater : function(){\r
- return this.updateManager || (this.updateManager = new Ext.Updater(this));\r
- },\r
- \r
- /**\r
- * Update the innerHTML of this element, optionally searching for and processing scripts\r
- * @param {String} html The new HTML\r
- * @param {Boolean} loadScripts (optional) True to look for and process scripts (defaults to false)\r
- * @param {Function} callback (optional) For async script loading you can be notified when the update completes\r
- * @return {Ext.Element} this\r
- */\r
- update : function(html, loadScripts, callback){\r
- html = html || "";\r
- \r
- if(loadScripts !== true){\r
- this.dom.innerHTML = html;\r
- if(Ext.isFunction(callback)){\r
- callback();\r
- }\r
- return this;\r
- }\r
- \r
- var id = Ext.id(),\r
- dom = this.dom;\r
-\r
- html += '<span id="' + id + '"></span>';\r
-\r
- Ext.lib.Event.onAvailable(id, function(){\r
- var DOC = document,\r
- hd = DOC.getElementsByTagName("head")[0],\r
- re = /(?:<script([^>]*)?>)((\n|\r|.)*?)(?:<\/script>)/ig,\r
- srcRe = /\ssrc=([\'\"])(.*?)\1/i,\r
- typeRe = /\stype=([\'\"])(.*?)\1/i,\r
- match,\r
- attrs,\r
- srcMatch,\r
- typeMatch,\r
- el,\r
- s;\r
-\r
- while((match = re.exec(html))){\r
- attrs = match[1];\r
- srcMatch = attrs ? attrs.match(srcRe) : false;\r
- if(srcMatch && srcMatch[2]){\r
- s = DOC.createElement("script");\r
- s.src = srcMatch[2];\r
- typeMatch = attrs.match(typeRe);\r
- if(typeMatch && typeMatch[2]){\r
- s.type = typeMatch[2];\r
- }\r
- hd.appendChild(s);\r
- }else if(match[2] && match[2].length > 0){\r
- if(window.execScript) {\r
- window.execScript(match[2]);\r
- } else {\r
- window.eval(match[2]);\r
- }\r
- }\r
- }\r
- el = DOC.getElementById(id);\r
- if(el){Ext.removeNode(el);}\r
- if(Ext.isFunction(callback)){\r
- callback();\r
- }\r
- });\r
- dom.innerHTML = html.replace(/(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/ig, "");\r
- return this;\r
- },\r
- \r
- /**\r
- * Creates a proxy element of this element\r
- * @param {String/Object} config The class name of the proxy element or a DomHelper config object\r
- * @param {String/HTMLElement} renderTo (optional) The element or element id to render the proxy to (defaults to document.body)\r
- * @param {Boolean} matchBox (optional) True to align and size the proxy to this element now (defaults to false)\r
- * @return {Ext.Element} The new proxy element\r
- */\r
- createProxy : function(config, renderTo, matchBox){\r
- config = Ext.isObject(config) ? config : {tag : "div", cls: config};\r
-\r
- var me = this,\r
- proxy = renderTo ? Ext.DomHelper.append(renderTo, config, true) :\r
- Ext.DomHelper.insertBefore(me.dom, config, true); \r
- \r
- if(matchBox && me.setBox && me.getBox){ // check to make sure Element.position.js is loaded\r
- proxy.setBox(me.getBox());\r
- }\r
- return proxy;\r
- }\r
-});\r
-\r
-Ext.Element.prototype.getUpdateManager = Ext.Element.prototype.getUpdater;\r
-\r
-// private\r
-Ext.Element.uncache = function(el){\r
- for(var i = 0, a = arguments, len = a.length; i < len; i++) {\r
- if(a[i]){\r
- delete Ext.Element.cache[a[i].id || a[i]];\r
- }\r
- }\r
-};/**\r
- * @class Ext.Element\r
- */\r
-Ext.Element.addMethods({\r
- /**\r
- * Gets the x,y coordinates specified by the anchor position on the element.\r
- * @param {String} anchor (optional) The specified anchor position (defaults to "c"). See {@link #alignTo}\r
- * for details on supported anchor positions.\r
- * @param {Boolean} local (optional) True to get the local (element top/left-relative) anchor position instead\r
- * of page coordinates\r
- * @param {Object} size (optional) An object containing the size to use for calculating anchor position\r
- * {width: (target width), height: (target height)} (defaults to the element's current size)\r
- * @return {Array} [x, y] An array containing the element's x and y coordinates\r
- */\r
- getAnchorXY : function(anchor, local, s){\r
- //Passing a different size is useful for pre-calculating anchors,\r
- //especially for anchored animations that change the el size.\r
- anchor = (anchor || "tl").toLowerCase();\r
- s = s || {};\r
- \r
- var me = this, \r
- vp = me.dom == document.body || me.dom == document,\r
- w = s.width || vp ? Ext.lib.Dom.getViewWidth() : me.getWidth(),\r
- h = s.height || vp ? Ext.lib.Dom.getViewHeight() : me.getHeight(), \r
- xy, \r
- r = Math.round,\r
- o = me.getXY(),\r
- scroll = me.getScroll(),\r
- extraX = vp ? scroll.left : !local ? o[0] : 0,\r
- extraY = vp ? scroll.top : !local ? o[1] : 0,\r
- hash = {\r
- c : [r(w * 0.5), r(h * 0.5)],\r
- t : [r(w * 0.5), 0],\r
- l : [0, r(h * 0.5)],\r
- r : [w, r(h * 0.5)],\r
- b : [r(w * 0.5), h],\r
- tl : [0, 0], \r
- bl : [0, h],\r
- br : [w, h],\r
- tr : [w, 0]\r
- };\r
- \r
- xy = hash[anchor]; \r
- return [xy[0] + extraX, xy[1] + extraY]; \r
- },\r
-\r
- /**\r
- * Anchors an element to another element and realigns it when the window is resized.\r
- * @param {Mixed} element The element to align to.\r
- * @param {String} position The position to align to.\r
- * @param {Array} offsets (optional) Offset the positioning by [x, y]\r
- * @param {Boolean/Object} animate (optional) True for the default animation or a standard Element animation config object\r
- * @param {Boolean/Number} monitorScroll (optional) True to monitor body scroll and reposition. If this parameter\r
- * is a number, it is used as the buffer delay (defaults to 50ms).\r
- * @param {Function} callback The function to call after the animation finishes\r
- * @return {Ext.Element} this\r
- */\r
- anchorTo : function(el, alignment, offsets, animate, monitorScroll, callback){ \r
- var me = this,\r
- dom = me.dom;\r
- \r
- function action(){\r
- Ext.fly(dom).alignTo(el, alignment, offsets, animate);\r
- Ext.callback(callback, Ext.fly(dom));\r
- }\r
- \r
- Ext.EventManager.onWindowResize(action, me);\r
- \r
- if(!Ext.isEmpty(monitorScroll)){\r
- Ext.EventManager.on(window, 'scroll', action, me,\r
- {buffer: !isNaN(monitorScroll) ? monitorScroll : 50});\r
- }\r
- action.call(me); // align immediately\r
- return me;\r
- },\r
-\r
- /**\r
- * Gets the x,y coordinates to align this element with another element. See {@link #alignTo} for more info on the\r
- * supported position values.\r
- * @param {Mixed} element The element to align to.\r
- * @param {String} position The position to align to.\r
- * @param {Array} offsets (optional) Offset the positioning by [x, y]\r
- * @return {Array} [x, y]\r
- */\r
- getAlignToXY : function(el, p, o){ \r
- el = Ext.get(el);\r
- \r
- if(!el || !el.dom){\r
- throw "Element.alignToXY with an element that doesn't exist";\r
- }\r
- \r
- o = o || [0,0];\r
- p = (p == "?" ? "tl-bl?" : (!/-/.test(p) && p !== "" ? "tl-" + p : p || "tl-bl")).toLowerCase(); \r
- \r
- var me = this,\r
- d = me.dom,\r
- a1,\r
- a2,\r
- x,\r
- y,\r
- //constrain the aligned el to viewport if necessary\r
- w,\r
- h,\r
- r,\r
- dw = Ext.lib.Dom.getViewWidth() -10, // 10px of margin for ie\r
- dh = Ext.lib.Dom.getViewHeight()-10, // 10px of margin for ie\r
- p1y,\r
- p1x, \r
- p2y,\r
- p2x,\r
- swapY,\r
- swapX,\r
- doc = document,\r
- docElement = doc.documentElement,\r
- docBody = doc.body,\r
- scrollX = (docElement.scrollLeft || docBody.scrollLeft || 0)+5,\r
- scrollY = (docElement.scrollTop || docBody.scrollTop || 0)+5,\r
- c = false, //constrain to viewport\r
- p1 = "", \r
- p2 = "",\r
- m = p.match(/^([a-z]+)-([a-z]+)(\?)?$/);\r
- \r
- if(!m){\r
- throw "Element.alignTo with an invalid alignment " + p;\r
- }\r
- \r
- p1 = m[1]; \r
- p2 = m[2]; \r
- c = !!m[3];\r
-\r
- //Subtract the aligned el's internal xy from the target's offset xy\r
- //plus custom offset to get the aligned el's new offset xy\r
- a1 = me.getAnchorXY(p1, true);\r
- a2 = el.getAnchorXY(p2, false);\r
-\r
- x = a2[0] - a1[0] + o[0];\r
- y = a2[1] - a1[1] + o[1];\r
-\r
- if(c){ \r
- w = me.getWidth();\r
- h = me.getHeight();\r
- r = el.getRegion(); \r
- //If we are at a viewport boundary and the aligned el is anchored on a target border that is\r
- //perpendicular to the vp border, allow the aligned el to slide on that border,\r
- //otherwise swap the aligned el to the opposite border of the target.\r
- p1y = p1.charAt(0);\r
- p1x = p1.charAt(p1.length-1);\r
- p2y = p2.charAt(0);\r
- p2x = p2.charAt(p2.length-1);\r
- swapY = ((p1y=="t" && p2y=="b") || (p1y=="b" && p2y=="t"));\r
- swapX = ((p1x=="r" && p2x=="l") || (p1x=="l" && p2x=="r")); \r
- \r
-\r
- if (x + w > dw + scrollX) {\r
- x = swapX ? r.left-w : dw+scrollX-w;\r
- }\r
- if (x < scrollX) {\r
- x = swapX ? r.right : scrollX;\r
- }\r
- if (y + h > dh + scrollY) {\r
- y = swapY ? r.top-h : dh+scrollY-h;\r
- }\r
- if (y < scrollY){\r
- y = swapY ? r.bottom : scrollY;\r
- }\r
- }\r
- return [x,y];\r
- },\r
-\r
- /**\r
- * Aligns this element with another element relative to the specified anchor points. If the other element is the\r
- * document it aligns it to the viewport.\r
- * The position parameter is optional, and can be specified in any one of the following formats:\r
- * <ul>\r
- * <li><b>Blank</b>: Defaults to aligning the element's top-left corner to the target's bottom-left corner ("tl-bl").</li>\r
- * <li><b>One anchor (deprecated)</b>: The passed anchor position is used as the target element's anchor point.\r
- * The element being aligned will position its top-left corner (tl) to that point. <i>This method has been\r
- * deprecated in favor of the newer two anchor syntax below</i>.</li>\r
- * <li><b>Two anchors</b>: If two values from the table below are passed separated by a dash, the first value is used as the\r
- * element's anchor point, and the second value is used as the target's anchor point.</li>\r
- * </ul>\r
- * In addition to the anchor points, the position parameter also supports the "?" character. If "?" is passed at the end of\r
- * the position string, the element will attempt to align as specified, but the position will be adjusted to constrain to\r
- * the viewport if necessary. Note that the element being aligned might be swapped to align to a different position than\r
- * that specified in order to enforce the viewport constraints.\r
- * Following are all of the supported anchor positions:\r
-<pre>\r
-Value Description\r
------ -----------------------------\r
-tl The top left corner (default)\r
-t The center of the top edge\r
-tr The top right corner\r
-l The center of the left edge\r
-c In the center of the element\r
-r The center of the right edge\r
-bl The bottom left corner\r
-b The center of the bottom edge\r
-br The bottom right corner\r
-</pre>\r
-Example Usage:\r
-<pre><code>\r
-// align el to other-el using the default positioning ("tl-bl", non-constrained)\r
-el.alignTo("other-el");\r
-\r
-// align the top left corner of el with the top right corner of other-el (constrained to viewport)\r
-el.alignTo("other-el", "tr?");\r
-\r
-// align the bottom right corner of el with the center left edge of other-el\r
-el.alignTo("other-el", "br-l?");\r
-\r
-// align the center of el with the bottom left corner of other-el and\r
-// adjust the x position by -6 pixels (and the y position by 0)\r
-el.alignTo("other-el", "c-bl", [-6, 0]);\r
-</code></pre>\r
- * @param {Mixed} element The element to align to.\r
- * @param {String} position The position to align to.\r
- * @param {Array} offsets (optional) Offset the positioning by [x, y]\r
- * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object\r
- * @return {Ext.Element} this\r
- */\r
- alignTo : function(element, position, offsets, animate){\r
- var me = this;\r
- return me.setXY(me.getAlignToXY(element, position, offsets),\r
- me.preanim && !!animate ? me.preanim(arguments, 3) : false);\r
- },\r
- \r
- // private ==> used outside of core\r
- adjustForConstraints : function(xy, parent, offsets){\r
- return this.getConstrainToXY(parent || document, false, offsets, xy) || xy;\r
- },\r
-\r
- // private ==> used outside of core\r
- getConstrainToXY : function(el, local, offsets, proposedXY){ \r
- var os = {top:0, left:0, bottom:0, right: 0};\r
-\r
- return function(el, local, offsets, proposedXY){\r
- el = Ext.get(el);\r
- offsets = offsets ? Ext.applyIf(offsets, os) : os;\r
-\r
- var vw, vh, vx = 0, vy = 0;\r
- if(el.dom == document.body || el.dom == document){\r
- vw =Ext.lib.Dom.getViewWidth();\r
- vh = Ext.lib.Dom.getViewHeight();\r
- }else{\r
- vw = el.dom.clientWidth;\r
- vh = el.dom.clientHeight;\r
- if(!local){\r
- var vxy = el.getXY();\r
- vx = vxy[0];\r
- vy = vxy[1];\r
- }\r
- }\r
-\r
- var s = el.getScroll();\r
-\r
- vx += offsets.left + s.left;\r
- vy += offsets.top + s.top;\r
-\r
- vw -= offsets.right;\r
- vh -= offsets.bottom;\r
-\r
- var vr = vx+vw;\r
- var vb = vy+vh;\r
-\r
- var xy = proposedXY || (!local ? this.getXY() : [this.getLeft(true), this.getTop(true)]);\r
- var x = xy[0], y = xy[1];\r
- var w = this.dom.offsetWidth, h = this.dom.offsetHeight;\r
-\r
- // only move it if it needs it\r
- var moved = false;\r
-\r
- // first validate right/bottom\r
- if((x + w) > vr){\r
- x = vr - w;\r
- moved = true;\r
- }\r
- if((y + h) > vb){\r
- y = vb - h;\r
- moved = true;\r
- }\r
- // then make sure top/left isn't negative\r
- if(x < vx){\r
- x = vx;\r
- moved = true;\r
- }\r
- if(y < vy){\r
- y = vy;\r
- moved = true;\r
- }\r
- return moved ? [x, y] : false;\r
- };\r
- }(),\r
- \r
- \r
- \r
-// el = Ext.get(el);\r
-// offsets = Ext.applyIf(offsets || {}, {top : 0, left : 0, bottom : 0, right : 0});\r
-\r
-// var me = this,\r
-// doc = document,\r
-// s = el.getScroll(),\r
-// vxy = el.getXY(),\r
-// vx = offsets.left + s.left, \r
-// vy = offsets.top + s.top, \r
-// vw = -offsets.right, \r
-// vh = -offsets.bottom, \r
-// vr,\r
-// vb,\r
-// xy = proposedXY || (!local ? me.getXY() : [me.getLeft(true), me.getTop(true)]),\r
-// x = xy[0],\r
-// y = xy[1],\r
-// w = me.dom.offsetWidth, h = me.dom.offsetHeight,\r
-// moved = false; // only move it if it needs it\r
-// \r
-// \r
-// if(el.dom == doc.body || el.dom == doc){\r
-// vw += Ext.lib.Dom.getViewWidth();\r
-// vh += Ext.lib.Dom.getViewHeight();\r
-// }else{\r
-// vw += el.dom.clientWidth;\r
-// vh += el.dom.clientHeight;\r
-// if(!local){ \r
-// vx += vxy[0];\r
-// vy += vxy[1];\r
-// }\r
-// }\r
-\r
-// // first validate right/bottom\r
-// if(x + w > vx + vw){\r
-// x = vx + vw - w;\r
-// moved = true;\r
-// }\r
-// if(y + h > vy + vh){\r
-// y = vy + vh - h;\r
-// moved = true;\r
-// }\r
-// // then make sure top/left isn't negative\r
-// if(x < vx){\r
-// x = vx;\r
-// moved = true;\r
-// }\r
-// if(y < vy){\r
-// y = vy;\r
-// moved = true;\r
-// }\r
-// return moved ? [x, y] : false;\r
-// },\r
- \r
- /**\r
- * Calculates the x, y to center this element on the screen\r
- * @return {Array} The x, y values [x, y]\r
- */\r
- getCenterXY : function(){\r
- return this.getAlignToXY(document, 'c-c');\r
- },\r
-\r
- /**\r
- * Centers the Element in either the viewport, or another Element.\r
- * @param {Mixed} centerIn (optional) The element in which to center the element.\r
- */\r
- center : function(centerIn){\r
- return this.alignTo(centerIn || document, 'c-c'); \r
- } \r
-});\r
-/**\r
- * @class Ext.Element\r
- */\r
-Ext.Element.addMethods(function(){\r
- var PARENTNODE = 'parentNode',\r
- NEXTSIBLING = 'nextSibling',\r
- PREVIOUSSIBLING = 'previousSibling',\r
- DQ = Ext.DomQuery,\r
- GET = Ext.get;\r
- \r
- return {\r
- /**\r
- * Looks at this node and then at parent nodes for a match of the passed simple selector (e.g. div.some-class or span:first-child)\r
- * @param {String} selector The simple selector to test\r
- * @param {Number/Mixed} maxDepth (optional) The max depth to search as a number or element (defaults to 50 || document.body)\r
- * @param {Boolean} returnEl (optional) True to return a Ext.Element object instead of DOM node\r
- * @return {HTMLElement} The matching DOM node (or null if no match was found)\r
- */\r
- findParent : function(simpleSelector, maxDepth, returnEl){\r
- var p = this.dom,\r
- b = document.body, \r
- depth = 0, \r
- stopEl; \r
- if(Ext.isGecko && Object.prototype.toString.call(p) == '[object XULElement]') {\r
- return null;\r
- }\r
- maxDepth = maxDepth || 50;\r
- if (isNaN(maxDepth)) {\r
- stopEl = Ext.getDom(maxDepth);\r
- maxDepth = Number.MAX_VALUE;\r
- }\r
- while(p && p.nodeType == 1 && depth < maxDepth && p != b && p != stopEl){\r
- if(DQ.is(p, simpleSelector)){\r
- return returnEl ? GET(p) : p;\r
- }\r
- depth++;\r
- p = p.parentNode;\r
- }\r
- return null;\r
- },\r
- \r
- /**\r
- * Looks at parent nodes for a match of the passed simple selector (e.g. div.some-class or span:first-child)\r
- * @param {String} selector The simple selector to test\r
- * @param {Number/Mixed} maxDepth (optional) The max depth to\r
- search as a number or element (defaults to 10 || document.body)\r
- * @param {Boolean} returnEl (optional) True to return a Ext.Element object instead of DOM node\r
- * @return {HTMLElement} The matching DOM node (or null if no match was found)\r
- */\r
- findParentNode : function(simpleSelector, maxDepth, returnEl){\r
- var p = Ext.fly(this.dom.parentNode, '_internal');\r
- return p ? p.findParent(simpleSelector, maxDepth, returnEl) : null;\r
- },\r
- \r
- /**\r
- * Walks up the dom looking for a parent node that matches the passed simple selector (e.g. div.some-class or span:first-child).\r
- * This is a shortcut for findParentNode() that always returns an Ext.Element.\r
- * @param {String} selector The simple selector to test\r
- * @param {Number/Mixed} maxDepth (optional) The max depth to\r
- search as a number or element (defaults to 10 || document.body)\r
- * @return {Ext.Element} The matching DOM node (or null if no match was found)\r
- */\r
- up : function(simpleSelector, maxDepth){\r
- return this.findParentNode(simpleSelector, maxDepth, true);\r
- },\r
- \r
- /**\r
- * Creates a {@link Ext.CompositeElement} for child nodes based on the passed CSS selector (the selector should not contain an id).\r
- * @param {String} selector The CSS selector\r
- * @param {Boolean} unique (optional) True to create a unique Ext.Element for each child (defaults to false, which creates a single shared flyweight object)\r
- * @return {CompositeElement/CompositeElementLite} The composite element\r
- */\r
- select : function(selector, unique){\r
- return Ext.Element.select(selector, unique, this.dom);\r
- },\r
- \r
- /**\r
- * Selects child nodes based on the passed CSS selector (the selector should not contain an id).\r
- * @param {String} selector The CSS selector\r
- * @return {Array} An array of the matched nodes\r
- */\r
- query : function(selector, unique){\r
- return DQ.select(selector, this.dom);\r
- },\r
- \r
- /**\r
- * Selects a single child at any depth below this element based on the passed CSS selector (the selector should not contain an id).\r
- * @param {String} selector The CSS selector\r
- * @param {Boolean} returnDom (optional) True to return the DOM node instead of Ext.Element (defaults to false)\r
- * @return {HTMLElement/Ext.Element} The child Ext.Element (or DOM node if returnDom = true)\r
- */\r
- child : function(selector, returnDom){\r
- var n = DQ.selectNode(selector, this.dom);\r
- return returnDom ? n : GET(n);\r
- },\r
- \r
- /**\r
- * Selects a single *direct* child based on the passed CSS selector (the selector should not contain an id).\r
- * @param {String} selector The CSS selector\r
- * @param {Boolean} returnDom (optional) True to return the DOM node instead of Ext.Element (defaults to false)\r
- * @return {HTMLElement/Ext.Element} The child Ext.Element (or DOM node if returnDom = true)\r
- */\r
- down : function(selector, returnDom){\r
- var n = DQ.selectNode(" > " + selector, this.dom);\r
- return returnDom ? n : GET(n);\r
- },\r
- \r
- /**\r
- * Gets the parent node for this element, optionally chaining up trying to match a selector\r
- * @param {String} selector (optional) Find a parent node that matches the passed simple selector\r
- * @param {Boolean} returnDom (optional) True to return a raw dom node instead of an Ext.Element\r
- * @return {Ext.Element/HTMLElement} The parent node or null\r
- */\r
- parent : function(selector, returnDom){\r
- return this.matchNode(PARENTNODE, PARENTNODE, selector, returnDom);\r
- },\r
- \r
- /**\r
- * Gets the next sibling, skipping text nodes\r
- * @param {String} selector (optional) Find the next sibling that matches the passed simple selector\r
- * @param {Boolean} returnDom (optional) True to return a raw dom node instead of an Ext.Element\r
- * @return {Ext.Element/HTMLElement} The next sibling or null\r
- */\r
- next : function(selector, returnDom){\r
- return this.matchNode(NEXTSIBLING, NEXTSIBLING, selector, returnDom);\r
- },\r
- \r
- /**\r
- * Gets the previous sibling, skipping text nodes\r
- * @param {String} selector (optional) Find the previous sibling that matches the passed simple selector\r
- * @param {Boolean} returnDom (optional) True to return a raw dom node instead of an Ext.Element\r
- * @return {Ext.Element/HTMLElement} The previous sibling or null\r
- */\r
- prev : function(selector, returnDom){\r
- return this.matchNode(PREVIOUSSIBLING, PREVIOUSSIBLING, selector, returnDom);\r
- },\r
- \r
- \r
- /**\r
- * Gets the first child, skipping text nodes\r
- * @param {String} selector (optional) Find the next sibling that matches the passed simple selector\r
- * @param {Boolean} returnDom (optional) True to return a raw dom node instead of an Ext.Element\r
- * @return {Ext.Element/HTMLElement} The first child or null\r
- */\r
- first : function(selector, returnDom){\r
- return this.matchNode(NEXTSIBLING, 'firstChild', selector, returnDom);\r
- },\r
- \r
- /**\r
- * Gets the last child, skipping text nodes\r
- * @param {String} selector (optional) Find the previous sibling that matches the passed simple selector\r
- * @param {Boolean} returnDom (optional) True to return a raw dom node instead of an Ext.Element\r
- * @return {Ext.Element/HTMLElement} The last child or null\r
- */\r
- last : function(selector, returnDom){\r
- return this.matchNode(PREVIOUSSIBLING, 'lastChild', selector, returnDom);\r
- },\r
- \r
- matchNode : function(dir, start, selector, returnDom){\r
- var n = this.dom[start];\r
- while(n){\r
- if(n.nodeType == 1 && (!selector || DQ.is(n, selector))){\r
- return !returnDom ? GET(n) : n;\r
- }\r
- n = n[dir];\r
- }\r
- return null;\r
- } \r
- }\r
-}());/**\r
- * @class Ext.Element\r
- */\r
-Ext.Element.addMethods(\r
-function() {\r
- var GETDOM = Ext.getDom,\r
- GET = Ext.get,\r
- DH = Ext.DomHelper,\r
- isEl = function(el){\r
- return (el.nodeType || el.dom || typeof el == 'string'); \r
- };\r
- \r
- return {\r
- /**\r
- * Appends the passed element(s) to this element\r
- * @param {String/HTMLElement/Array/Element/CompositeElement} el\r
- * @return {Ext.Element} this\r
- */\r
- appendChild: function(el){ \r
- return GET(el).appendTo(this); \r
- },\r
- \r
- /**\r
- * Appends this element to the passed element\r
- * @param {Mixed} el The new parent element\r
- * @return {Ext.Element} this\r
- */\r
- appendTo: function(el){ \r
- GETDOM(el).appendChild(this.dom); \r
- return this;\r
- },\r
- \r
- /**\r
- * Inserts this element before the passed element in the DOM\r
- * @param {Mixed} el The element before which this element will be inserted\r
- * @return {Ext.Element} this\r
- */\r
- insertBefore: function(el){ \r
- (el = GETDOM(el)).parentNode.insertBefore(this.dom, el);\r
- return this;\r
- },\r
- \r
- /**\r
- * Inserts this element after the passed element in the DOM\r
- * @param {Mixed} el The element to insert after\r
- * @return {Ext.Element} this\r
- */\r
- insertAfter: function(el){\r
- (el = GETDOM(el)).parentNode.insertBefore(this.dom, el.nextSibling);\r
- return this;\r
- },\r
- \r
- /**\r
- * Inserts (or creates) an element (or DomHelper config) as the first child of this element\r
- * @param {Mixed/Object} el The id or element to insert or a DomHelper config to create and insert\r
- * @return {Ext.Element} The new child\r
- */\r
- insertFirst: function(el, returnDom){\r
- el = el || {};\r
- if(isEl(el)){ // element\r
- el = GETDOM(el);\r
- this.dom.insertBefore(el, this.dom.firstChild);\r
- return !returnDom ? GET(el) : el;\r
- }else{ // dh config\r
- return this.createChild(el, this.dom.firstChild, returnDom);\r
- }\r
- },\r
- \r
- /**\r
- * Replaces the passed element with this element\r
- * @param {Mixed} el The element to replace\r
- * @return {Ext.Element} this\r
- */\r
- replace: function(el){\r
- el = GET(el);\r
- this.insertBefore(el);\r
- el.remove();\r
- return this;\r
- },\r
- \r
- /**\r
- * Replaces this element with the passed element\r
- * @param {Mixed/Object} el The new element or a DomHelper config of an element to create\r
- * @return {Ext.Element} this\r
- */\r
- replaceWith: function(el){\r
- var me = this,\r
- Element = Ext.Element;\r
- if(isEl(el)){\r
- el = GETDOM(el);\r
- me.dom.parentNode.insertBefore(el, me.dom);\r
- }else{\r
- el = DH.insertBefore(me.dom, el);\r
- }\r
- \r
- delete Element.cache[me.id];\r
- Ext.removeNode(me.dom); \r
- me.id = Ext.id(me.dom = el);\r
- return Element.cache[me.id] = me; \r
- },\r
- \r
- /**\r
- * Creates the passed DomHelper config and appends it to this element or optionally inserts it before the passed child element.\r
- * @param {Object} config DomHelper element config object. If no tag is specified (e.g., {tag:'input'}) then a div will be\r
- * automatically generated with the specified attributes.\r
- * @param {HTMLElement} insertBefore (optional) a child element of this element\r
- * @param {Boolean} returnDom (optional) true to return the dom node instead of creating an Element\r
- * @return {Ext.Element} The new child element\r
- */\r
- createChild: function(config, insertBefore, returnDom){\r
- config = config || {tag:'div'};\r
- return insertBefore ? \r
- DH.insertBefore(insertBefore, config, returnDom !== true) : \r
- DH[!this.dom.firstChild ? 'overwrite' : 'append'](this.dom, config, returnDom !== true);\r
- },\r
- \r
- /**\r
- * Creates and wraps this element with another element\r
- * @param {Object} config (optional) DomHelper element config object for the wrapper element or null for an empty div\r
- * @param {Boolean} returnDom (optional) True to return the raw DOM element instead of Ext.Element\r
- * @return {HTMLElement/Element} The newly created wrapper element\r
- */\r
- wrap: function(config, returnDom){ \r
- var newEl = DH.insertBefore(this.dom, config || {tag: "div"}, !returnDom);\r
- newEl.dom ? newEl.dom.appendChild(this.dom) : newEl.appendChild(this.dom);\r
- return newEl;\r
- },\r
- \r
- /**\r
- * Inserts an html fragment into this element\r
- * @param {String} where Where to insert the html in relation to this element - beforeBegin, afterBegin, beforeEnd, afterEnd.\r
- * @param {String} html The HTML fragment\r
- * @param {Boolean} returnEl (optional) True to return an Ext.Element (defaults to false)\r
- * @return {HTMLElement/Ext.Element} The inserted node (or nearest related if more than 1 inserted)\r
- */\r
- insertHtml : function(where, html, returnEl){\r
- var el = DH.insertHtml(where, this.dom, html);\r
- return returnEl ? Ext.get(el) : el;\r
- }\r
- }\r
-}());/**\r
- * @class Ext.Element\r
- */\r
-Ext.apply(Ext.Element.prototype, function() {\r
- var GETDOM = Ext.getDom,\r
- GET = Ext.get,\r
- DH = Ext.DomHelper;\r
- \r
- return { \r
- /**\r
- * Inserts (or creates) the passed element (or DomHelper config) as a sibling of this element\r
- * @param {Mixed/Object/Array} el The id, element to insert or a DomHelper config to create and insert *or* an array of any of those.\r
- * @param {String} where (optional) 'before' or 'after' defaults to before\r
- * @param {Boolean} returnDom (optional) True to return the raw DOM element instead of Ext.Element\r
- * @return {Ext.Element} the inserted Element\r
- */\r
- insertSibling: function(el, where, returnDom){\r
- var me = this,\r
- rt;\r
- \r
- if(Ext.isArray(el)){ \r
- Ext.each(el, function(e) {\r
- rt = me.insertSibling(e, where, returnDom);\r
- });\r
- return rt;\r
- }\r
- \r
- where = (where || 'before').toLowerCase();\r
- el = el || {};\r
- \r
- if(el.nodeType || el.dom){\r
- rt = me.dom.parentNode.insertBefore(GETDOM(el), where == 'before' ? me.dom : me.dom.nextSibling);\r
- if (!returnDom) {\r
- rt = GET(rt);\r
- }\r
- }else{\r
- if (where == 'after' && !me.dom.nextSibling) {\r
- rt = DH.append(me.dom.parentNode, el, !returnDom);\r
- } else { \r
- rt = DH[where == 'after' ? 'insertAfter' : 'insertBefore'](me.dom, el, !returnDom);\r
- }\r
- }\r
- return rt;\r
- }\r
- };\r
-}());/**\r
- * @class Ext.Element\r
- */\r
-Ext.Element.addMethods(function(){ \r
- // local style camelizing for speed\r
- var propCache = {},\r
- camelRe = /(-[a-z])/gi,\r
- classReCache = {},\r
- view = document.defaultView,\r
- propFloat = Ext.isIE ? 'styleFloat' : 'cssFloat',\r
- opacityRe = /alpha\(opacity=(.*)\)/i,\r
- trimRe = /^\s+|\s+$/g,\r
- EL = Ext.Element, \r
- PADDING = "padding",\r
- MARGIN = "margin",\r
- BORDER = "border",\r
- LEFT = "-left",\r
- RIGHT = "-right",\r
- TOP = "-top",\r
- BOTTOM = "-bottom",\r
- WIDTH = "-width", \r
- MATH = Math,\r
- HIDDEN = 'hidden',\r
- ISCLIPPED = 'isClipped',\r
- OVERFLOW = 'overflow',\r
- OVERFLOWX = 'overflow-x',\r
- OVERFLOWY = 'overflow-y',\r
- ORIGINALCLIP = 'originalClip',\r
- // special markup used throughout Ext when box wrapping elements \r
- borders = {l: BORDER + LEFT + WIDTH, r: BORDER + RIGHT + WIDTH, t: BORDER + TOP + WIDTH, b: BORDER + BOTTOM + WIDTH},\r
- paddings = {l: PADDING + LEFT, r: PADDING + RIGHT, t: PADDING + TOP, b: PADDING + BOTTOM},\r
- margins = {l: MARGIN + LEFT, r: MARGIN + RIGHT, t: MARGIN + TOP, b: MARGIN + BOTTOM},\r
- data = Ext.Element.data;\r
- \r
- \r
- // private \r
- function camelFn(m, a) {\r
- return a.charAt(1).toUpperCase();\r
- }\r
- \r
- // private (needs to be called => addStyles.call(this, sides, styles))\r
- function addStyles(sides, styles){\r
- var val = 0; \r
- \r
- Ext.each(sides.match(/\w/g), function(s) {\r
- if (s = parseInt(this.getStyle(styles[s]), 10)) {\r
- val += MATH.abs(s); \r
- }\r
- },\r
- this);\r
- return val;\r
- }\r
-\r
- function chkCache(prop) {\r
- return propCache[prop] || (propCache[prop] = prop == 'float' ? propFloat : prop.replace(camelRe, camelFn));\r
-\r
- }\r
- \r
- return { \r
- // private ==> used by Fx \r
- adjustWidth : function(width) {\r
- var me = this;\r
- var isNum = (typeof width == "number");\r
- if(isNum && me.autoBoxAdjust && !me.isBorderBox()){\r
- width -= (me.getBorderWidth("lr") + me.getPadding("lr"));\r
- }\r
- return (isNum && width < 0) ? 0 : width;\r
- },\r
- \r
- // private ==> used by Fx \r
- adjustHeight : function(height) {\r
- var me = this;\r
- var isNum = (typeof height == "number");\r
- if(isNum && me.autoBoxAdjust && !me.isBorderBox()){\r
- height -= (me.getBorderWidth("tb") + me.getPadding("tb")); \r
- }\r
- return (isNum && height < 0) ? 0 : height;\r
- },\r
- \r
- \r
- /**\r
- * Adds one or more CSS classes to the element. Duplicate classes are automatically filtered out.\r
- * @param {String/Array} className The CSS class to add, or an array of classes\r
- * @return {Ext.Element} this\r
- */\r
- addClass : function(className){\r
- var me = this;\r
- Ext.each(className, function(v) {\r
- me.dom.className += (!me.hasClass(v) && v ? " " + v : ""); \r
- });\r
- return me;\r
- },\r
- \r
- /**\r
- * Adds one or more CSS classes to this element and removes the same class(es) from all siblings.\r
- * @param {String/Array} className The CSS class to add, or an array of classes\r
- * @return {Ext.Element} this\r
- */\r
- radioClass : function(className){\r
- Ext.each(this.dom.parentNode.childNodes, function(v) {\r
- if(v.nodeType == 1) {\r
- Ext.fly(v, '_internal').removeClass(className); \r
- }\r
- });\r
- return this.addClass(className);\r
- },\r
- \r
- /**\r
- * Removes one or more CSS classes from the element.\r
- * @param {String/Array} className The CSS class to remove, or an array of classes\r
- * @return {Ext.Element} this\r
- */\r
- removeClass : function(className){\r
- var me = this;\r
- if (me.dom.className) {\r
- Ext.each(className, function(v) { \r
- me.dom.className = me.dom.className.replace(\r
- classReCache[v] = classReCache[v] || new RegExp('(?:^|\\s+)' + v + '(?:\\s+|$)', "g"), \r
- " "); \r
- }); \r
- }\r
- return me;\r
- },\r
- \r
- /**\r
- * Toggles the specified CSS class on this element (removes it if it already exists, otherwise adds it).\r
- * @param {String} className The CSS class to toggle\r
- * @return {Ext.Element} this\r
- */\r
- toggleClass : function(className){\r
- return this.hasClass(className) ? this.removeClass(className) : this.addClass(className);\r
- },\r
- \r
- /**\r
- * Checks if the specified CSS class exists on this element's DOM node.\r
- * @param {String} className The CSS class to check for\r
- * @return {Boolean} True if the class exists, else false\r
- */\r
- hasClass : function(className){\r
- return className && (' '+this.dom.className+' ').indexOf(' '+className+' ') != -1;\r
- },\r
- \r
- /**\r
- * Replaces a CSS class on the element with another. If the old name does not exist, the new name will simply be added.\r
- * @param {String} oldClassName The CSS class to replace\r
- * @param {String} newClassName The replacement CSS class\r
- * @return {Ext.Element} this\r
- */\r
- replaceClass : function(oldClassName, newClassName){\r
- return this.removeClass(oldClassName).addClass(newClassName);\r
- },\r
- \r
- isStyle : function(style, val) {\r
- return this.getStyle(style) == val; \r
- },\r
- \r
- /**\r
- * Normalizes currentStyle and computedStyle.\r
- * @param {String} property The style property whose value is returned.\r
- * @return {String} The current value of the style property for this element.\r
- */\r
- getStyle : function(){ \r
- return view && view.getComputedStyle ?\r
- function(prop){\r
- var el = this.dom,\r
- v, \r
- cs;\r
- if(el == document) return null;\r
- prop = chkCache(prop);\r
- return (v = el.style[prop]) ? v : \r
- (cs = view.getComputedStyle(el, "")) ? cs[prop] : null;\r
- } :\r
- function(prop){ \r
- var el = this.dom, \r
- m, \r
- cs; \r
- \r
- if(el == document) return null; \r
- if (prop == 'opacity') {\r
- if (el.style.filter.match) { \r
- if(m = el.style.filter.match(opacityRe)){\r
- var fv = parseFloat(m[1]);\r
- if(!isNaN(fv)){\r
- return fv ? fv / 100 : 0;\r
- }\r
- }\r
- }\r
- return 1;\r
- }\r
- prop = chkCache(prop); \r
- return el.style[prop] || ((cs = el.currentStyle) ? cs[prop] : null);\r
- };\r
- }(),\r
- \r
- /**\r
- * Return the CSS color for the specified CSS attribute. rgb, 3 digit (like #fff) and valid values\r
- * are convert to standard 6 digit hex color.\r
- * @param {String} attr The css attribute\r
- * @param {String} defaultValue The default value to use when a valid color isn't found\r
- * @param {String} prefix (optional) defaults to #. Use an empty string when working with\r
- * color anims.\r
- */\r
- getColor : function(attr, defaultValue, prefix){\r
- var v = this.getStyle(attr),\r
- color = prefix || '#',\r
- h;\r
- \r
- if(!v || /transparent|inherit/.test(v)){\r
- return defaultValue;\r
- }\r
- if(/^r/.test(v)){\r
- Ext.each(v.slice(4, v.length -1).split(','), function(s){\r
- h = parseInt(s, 10);\r
- color += (h < 16 ? '0' : '') + h.toString(16); \r
- });\r
- }else{\r
- v = v.replace('#', '');\r
- color += v.length == 3 ? v.replace(/^(\w)(\w)(\w)$/, '$1$1$2$2$3$3') : v;\r
- }\r
- return(color.length > 5 ? color.toLowerCase() : defaultValue);\r
- },\r
- \r
- /**\r
- * Wrapper for setting style properties, also takes single object parameter of multiple styles.\r
- * @param {String/Object} property The style property to be set, or an object of multiple styles.\r
- * @param {String} value (optional) The value to apply to the given property, or null if an object was passed.\r
- * @return {Ext.Element} this\r
- */\r
- setStyle : function(prop, value){\r
- var tmp, \r
- style,\r
- camel;\r
- if (!Ext.isObject(prop)) {\r
- tmp = {};\r
- tmp[prop] = value; \r
- prop = tmp;\r
- }\r
- for (style in prop) {\r
- value = prop[style]; \r
- style == 'opacity' ? \r
- this.setOpacity(value) : \r
- this.dom.style[chkCache(style)] = value;\r
- }\r
- return this;\r
- },\r
- \r
- /**\r
- * Set the opacity of the element\r
- * @param {Float} opacity The new opacity. 0 = transparent, .5 = 50% visibile, 1 = fully visible, etc\r
- * @param {Boolean/Object} animate (optional) a standard Element animation config object or <tt>true</tt> for\r
- * the default animation (<tt>{duration: .35, easing: 'easeIn'}</tt>)\r
- * @return {Ext.Element} this\r
- */\r
- setOpacity : function(opacity, animate){\r
- var me = this,\r
- s = me.dom.style;\r
- \r
- if(!animate || !me.anim){ \r
- if(Ext.isIE){\r
- var opac = opacity < 1 ? 'alpha(opacity=' + opacity * 100 + ')' : '', \r
- val = s.filter.replace(opacityRe, '').replace(trimRe, '');\r
-\r
- s.zoom = 1;\r
- s.filter = val + (val.length > 0 ? ' ' : '') + opac;\r
- }else{\r
- s.opacity = opacity;\r
- }\r
- }else{\r
- me.anim({opacity: {to: opacity}}, me.preanim(arguments, 1), null, .35, 'easeIn');\r
- }\r
- return me;\r
- },\r
- \r
- /**\r
- * Clears any opacity settings from this element. Required in some cases for IE.\r
- * @return {Ext.Element} this\r
- */\r
- clearOpacity : function(){\r
- var style = this.dom.style;\r
- if(Ext.isIE){\r
- if(!Ext.isEmpty(style.filter)){\r
- style.filter = style.filter.replace(opacityRe, '').replace(trimRe, '');\r
- }\r
- }else{\r
- style.opacity = style['-moz-opacity'] = style['-khtml-opacity'] = '';\r
- }\r
- return this;\r
- },\r
- \r
- /**\r
- * Returns the offset height of the element\r
- * @param {Boolean} contentHeight (optional) true to get the height minus borders and padding\r
- * @return {Number} The element's height\r
- */\r
- getHeight : function(contentHeight){\r
- var me = this,\r
- dom = me.dom,\r
- h = MATH.max(dom.offsetHeight, dom.clientHeight) || 0;\r
- h = !contentHeight ? h : h - me.getBorderWidth("tb") - me.getPadding("tb");\r
- return h < 0 ? 0 : h;\r
- },\r
- \r
- /**\r
- * Returns the offset width of the element\r
- * @param {Boolean} contentWidth (optional) true to get the width minus borders and padding\r
- * @return {Number} The element's width\r
- */\r
- getWidth : function(contentWidth){\r
- var me = this,\r
- dom = me.dom,\r
- w = MATH.max(dom.offsetWidth, dom.clientWidth) || 0;\r
- w = !contentWidth ? w : w - me.getBorderWidth("lr") - me.getPadding("lr");\r
- return w < 0 ? 0 : w;\r
- },\r
- \r
- /**\r
- * Set the width of this Element.\r
- * @param {Mixed} width The new width. This may be one of:<div class="mdetail-params"><ul>\r
- * <li>A Number specifying the new width in this Element's {@link #defaultUnit}s (by default, pixels).</li>\r
- * <li>A String used to set the CSS width style. Animation may <b>not</b> be used.\r
- * </ul></div>\r
- * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object\r
- * @return {Ext.Element} this\r
- */\r
- setWidth : function(width, animate){\r
- var me = this;\r
- width = me.adjustWidth(width);\r
- !animate || !me.anim ? \r
- me.dom.style.width = me.addUnits(width) :\r
- me.anim({width : {to : width}}, me.preanim(arguments, 1));\r
- return me;\r
- },\r
- \r
- /**\r
- * Set the height of this Element.\r
- * <pre><code>\r
-// change the height to 200px and animate with default configuration\r
-Ext.fly('elementId').setHeight(200, true);\r
-\r
-// change the height to 150px and animate with a custom configuration\r
-Ext.fly('elId').setHeight(150, {\r
- duration : .5, // animation will have a duration of .5 seconds\r
- // will change the content to "finished"\r
- callback: function(){ this.{@link #update}("finished"); } \r
-});\r
- * </code></pre>\r
- * @param {Mixed} height The new height. This may be one of:<div class="mdetail-params"><ul>\r
- * <li>A Number specifying the new height in this Element's {@link #defaultUnit}s (by default, pixels.)</li>\r
- * <li>A String used to set the CSS height style. Animation may <b>not</b> be used.</li>\r
- * </ul></div>\r
- * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object\r
- * @return {Ext.Element} this\r
- */\r
- setHeight : function(height, animate){\r
- var me = this;\r
- height = me.adjustHeight(height);\r
- !animate || !me.anim ? \r
- me.dom.style.height = me.addUnits(height) :\r
- me.anim({height : {to : height}}, me.preanim(arguments, 1));\r
- return me;\r
- },\r
- \r
- /**\r
- * Gets the width of the border(s) for the specified side(s)\r
- * @param {String} side Can be t, l, r, b or any combination of those to add multiple values. For example,\r
- * passing <tt>'lr'</tt> would get the border <b><u>l</u></b>eft width + the border <b><u>r</u></b>ight width.\r
- * @return {Number} The width of the sides passed added together\r
- */\r
- getBorderWidth : function(side){\r
- return addStyles.call(this, side, borders);\r
- },\r
- \r
- /**\r
- * Gets the width of the padding(s) for the specified side(s)\r
- * @param {String} side Can be t, l, r, b or any combination of those to add multiple values. For example,\r
- * passing <tt>'lr'</tt> would get the padding <b><u>l</u></b>eft + the padding <b><u>r</u></b>ight.\r
- * @return {Number} The padding of the sides passed added together\r
- */\r
- getPadding : function(side){\r
- return addStyles.call(this, side, paddings);\r
- },\r
- \r
- /**\r
- * Store the current overflow setting and clip overflow on the element - use <tt>{@link #unclip}</tt> to remove\r
- * @return {Ext.Element} this\r
- */\r
- clip : function(){\r
- var me = this,\r
- dom = me.dom;\r
- \r
- if(!data(dom, ISCLIPPED)){\r
- data(dom, ISCLIPPED, true);\r
- data(dom, ORIGINALCLIP, {\r
- o: me.getStyle(OVERFLOW),\r
- x: me.getStyle(OVERFLOWX),\r
- y: me.getStyle(OVERFLOWY)\r
- });\r
- me.setStyle(OVERFLOW, HIDDEN);\r
- me.setStyle(OVERFLOWX, HIDDEN);\r
- me.setStyle(OVERFLOWY, HIDDEN);\r
- }\r
- return me;\r
- },\r
- \r
- /**\r
- * Return clipping (overflow) to original clipping before <tt>{@link #clip}</tt> was called\r
- * @return {Ext.Element} this\r
- */\r
- unclip : function(){\r
- var me = this,\r
- dom = me.dom;\r
- \r
- if(data(dom, ISCLIPPED)){\r
- data(dom, ISCLIPPED, false);\r
- var o = data(dom, ORIGINALCLIP);\r
- if(o.o){\r
- me.setStyle(OVERFLOW, o.o);\r
- }\r
- if(o.x){\r
- me.setStyle(OVERFLOWX, o.x);\r
- }\r
- if(o.y){\r
- me.setStyle(OVERFLOWY, o.y);\r
- }\r
- }\r
- return me;\r
- },\r
- \r
- addStyles : addStyles,\r
- margins : margins\r
- }\r
-}() \r
-);/**\r
- * @class Ext.Element\r
- */\r
-\r
-// special markup used throughout Ext when box wrapping elements\r
-Ext.Element.boxMarkup = '<div class="{0}-tl"><div class="{0}-tr"><div class="{0}-tc"></div></div></div><div class="{0}-ml"><div class="{0}-mr"><div class="{0}-mc"></div></div></div><div class="{0}-bl"><div class="{0}-br"><div class="{0}-bc"></div></div></div>';\r
-\r
-Ext.Element.addMethods(function(){\r
- var INTERNAL = "_internal";\r
- return {\r
- /**\r
- * More flexible version of {@link #setStyle} for setting style properties.\r
- * @param {String/Object/Function} styles A style specification string, e.g. "width:100px", or object in the form {width:"100px"}, or\r
- * a function which returns such a specification.\r
- * @return {Ext.Element} this\r
- */\r
- applyStyles : function(style){\r
- Ext.DomHelper.applyStyles(this.dom, style);\r
- return this;\r
- },\r
-\r
- /**\r
- * Returns an object with properties matching the styles requested.\r
- * For example, el.getStyles('color', 'font-size', 'width') might return\r
- * {'color': '#FFFFFF', 'font-size': '13px', 'width': '100px'}.\r
- * @param {String} style1 A style name\r
- * @param {String} style2 A style name\r
- * @param {String} etc.\r
- * @return {Object} The style object\r
- */\r
- getStyles : function(){\r
- var ret = {};\r
- Ext.each(arguments, function(v) {\r
- ret[v] = this.getStyle(v);\r
- },\r
- this);\r
- return ret;\r
- },\r
-\r
- getStyleSize : function(){\r
- var me = this,\r
- w,\r
- h,\r
- d = this.dom,\r
- s = d.style;\r
- if(s.width && s.width != 'auto'){\r
- w = parseInt(s.width, 10);\r
- if(me.isBorderBox()){\r
- w -= me.getFrameWidth('lr');\r
- }\r
- }\r
- if(s.height && s.height != 'auto'){\r
- h = parseInt(s.height, 10);\r
- if(me.isBorderBox()){\r
- h -= me.getFrameWidth('tb');\r
- }\r
- }\r
- return {width: w || me.getWidth(true), height: h || me.getHeight(true)};\r
- },\r
-\r
- // private ==> used by ext full\r
- setOverflow : function(v){\r
- var dom = this.dom;\r
- if(v=='auto' && Ext.isMac && Ext.isGecko2){ // work around stupid FF 2.0/Mac scroll bar bug\r
- dom.style.overflow = 'hidden';\r
- (function(){dom.style.overflow = 'auto';}).defer(1);\r
- }else{\r
- dom.style.overflow = v;\r
- }\r
- },\r
-\r
- /**\r
- * <p>Wraps the specified element with a special 9 element markup/CSS block that renders by default as\r
- * a gray container with a gradient background, rounded corners and a 4-way shadow.</p>\r
- * <p>This special markup is used throughout Ext when box wrapping elements ({@link Ext.Button},\r
- * {@link Ext.Panel} when <tt>{@link Ext.Panel#frame frame=true}</tt>, {@link Ext.Window}). The markup\r
- * is of this form:</p>\r
- * <pre><code>\r
-Ext.Element.boxMarkup =\r
- '<div class="{0}-tl"><div class="{0}-tr"><div class="{0}-tc"></div></div></div>\r
- <div class="{0}-ml"><div class="{0}-mr"><div class="{0}-mc"></div></div></div>\r
- <div class="{0}-bl"><div class="{0}-br"><div class="{0}-bc"></div></div></div>';\r
- * </code></pre>\r
- * <p>Example usage:</p>\r
- * <pre><code>\r
-// Basic box wrap\r
-Ext.get("foo").boxWrap();\r
-\r
-// You can also add a custom class and use CSS inheritance rules to customize the box look.\r
-// 'x-box-blue' is a built-in alternative -- look at the related CSS definitions as an example\r
-// for how to create a custom box wrap style.\r
-Ext.get("foo").boxWrap().addClass("x-box-blue");\r
- * </code></pre>\r
- * @param {String} class (optional) A base CSS class to apply to the containing wrapper element\r
- * (defaults to <tt>'x-box'</tt>). Note that there are a number of CSS rules that are dependent on\r
- * this name to make the overall effect work, so if you supply an alternate base class, make sure you\r
- * also supply all of the necessary rules.\r
- * @return {Ext.Element} this\r
- */\r
- boxWrap : function(cls){\r
- cls = cls || 'x-box';\r
- var el = Ext.get(this.insertHtml("beforeBegin", "<div class='" + cls + "'>" + String.format(Ext.Element.boxMarkup, cls) + "</div>")); //String.format('<div class="{0}">'+Ext.Element.boxMarkup+'</div>', cls)));\r
- Ext.DomQuery.selectNode('.' + cls + '-mc', el.dom).appendChild(this.dom);\r
- return el;\r
- },\r
-\r
- /**\r
- * Set the size of this Element. If animation is true, both width and height will be animated concurrently.\r
- * @param {Mixed} width The new width. This may be one of:<div class="mdetail-params"><ul>\r
- * <li>A Number specifying the new width in this Element's {@link #defaultUnit}s (by default, pixels).</li>\r
- * <li>A String used to set the CSS width style. Animation may <b>not</b> be used.\r
- * <li>A size object in the format <code>{width: widthValue, height: heightValue}</code>.</li>\r
- * </ul></div>\r
- * @param {Mixed} height The new height. This may be one of:<div class="mdetail-params"><ul>\r
- * <li>A Number specifying the new height in this Element's {@link #defaultUnit}s (by default, pixels).</li>\r
- * <li>A String used to set the CSS height style. Animation may <b>not</b> be used.</li>\r
- * </ul></div>\r
- * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object\r
- * @return {Ext.Element} this\r
- */\r
- setSize : function(width, height, animate){\r
- var me = this;\r
- if(Ext.isObject(width)){ // in case of object from getSize()\r
- height = width.height;\r
- width = width.width;\r
- }\r
- width = me.adjustWidth(width);\r
- height = me.adjustHeight(height);\r
- if(!animate || !me.anim){\r
- me.dom.style.width = me.addUnits(width);\r
- me.dom.style.height = me.addUnits(height);\r
- }else{\r
- me.anim({width: {to: width}, height: {to: height}}, me.preanim(arguments, 2));\r
- }\r
- return me;\r
- },\r
-\r
- /**\r
- * Returns either the offsetHeight or the height of this element based on CSS height adjusted by padding or borders\r
- * when needed to simulate offsetHeight when offsets aren't available. This may not work on display:none elements\r
- * if a height has not been set using CSS.\r
- * @return {Number}\r
- */\r
- getComputedHeight : function(){\r
- var me = this,\r
- h = Math.max(me.dom.offsetHeight, me.dom.clientHeight);\r
- if(!h){\r
- h = parseInt(me.getStyle('height'), 10) || 0;\r
- if(!me.isBorderBox()){\r
- h += me.getFrameWidth('tb');\r
- }\r
- }\r
- return h;\r
- },\r
-\r
- /**\r
- * Returns either the offsetWidth or the width of this element based on CSS width adjusted by padding or borders\r
- * when needed to simulate offsetWidth when offsets aren't available. This may not work on display:none elements\r
- * if a width has not been set using CSS.\r
- * @return {Number}\r
- */\r
- getComputedWidth : function(){\r
- var w = Math.max(this.dom.offsetWidth, this.dom.clientWidth);\r
- if(!w){\r
- w = parseInt(this.getStyle('width'), 10) || 0;\r
- if(!this.isBorderBox()){\r
- w += this.getFrameWidth('lr');\r
- }\r
- }\r
- return w;\r
- },\r
-\r
- /**\r
- * Returns the sum width of the padding and borders for the passed "sides". See getBorderWidth()\r
- for more information about the sides.\r
- * @param {String} sides\r
- * @return {Number}\r
- */\r
- getFrameWidth : function(sides, onlyContentBox){\r
- return onlyContentBox && this.isBorderBox() ? 0 : (this.getPadding(sides) + this.getBorderWidth(sides));\r
- },\r
-\r
- /**\r
- * Sets up event handlers to add and remove a css class when the mouse is over this element\r
- * @param {String} className\r
- * @return {Ext.Element} this\r
- */\r
- addClassOnOver : function(className){\r
- this.hover(\r
- function(){\r
- Ext.fly(this, INTERNAL).addClass(className);\r
- },\r
- function(){\r
- Ext.fly(this, INTERNAL).removeClass(className);\r
- }\r
- );\r
- return this;\r
- },\r
-\r
- /**\r
- * Sets up event handlers to add and remove a css class when this element has the focus\r
- * @param {String} className\r
- * @return {Ext.Element} this\r
- */\r
- addClassOnFocus : function(className){\r
- this.on("focus", function(){\r
- Ext.fly(this, INTERNAL).addClass(className);\r
- }, this.dom);\r
- this.on("blur", function(){\r
- Ext.fly(this, INTERNAL).removeClass(className);\r
- }, this.dom);\r
- return this;\r
- },\r
-\r
- /**\r
- * Sets up event handlers to add and remove a css class when the mouse is down and then up on this element (a click effect)\r
- * @param {String} className\r
- * @return {Ext.Element} this\r
- */\r
- addClassOnClick : function(className){\r
- var dom = this.dom;\r
- this.on("mousedown", function(){\r
- Ext.fly(dom, INTERNAL).addClass(className);\r
- var d = Ext.getDoc(),\r
- fn = function(){\r
- Ext.fly(dom, INTERNAL).removeClass(className);\r
- d.removeListener("mouseup", fn);\r
- };\r
- d.on("mouseup", fn);\r
- });\r
- return this;\r
- },\r
-\r
- /**\r
- * Returns the width and height of the viewport.\r
- * <pre><code>\r
- var vpSize = Ext.getBody().getViewSize();\r
-\r
- // all Windows created afterwards will have a default value of 90% height and 95% width\r
- Ext.Window.override({\r
- width: vpSize.width * 0.9,\r
- height: vpSize.height * 0.95\r
- });\r
- // To handle window resizing you would have to hook onto onWindowResize.\r
- </code></pre>\r
- * @return {Object} An object containing the viewport's size {width: (viewport width), height: (viewport height)}\r
- */\r
- getViewSize : function(){\r
- var doc = document,\r
- d = this.dom,\r
- extdom = Ext.lib.Dom,\r
- isDoc = (d == doc || d == doc.body);\r
- return { width : (isDoc ? extdom.getViewWidth() : d.clientWidth),\r
- height : (isDoc ? extdom.getViewHeight() : d.clientHeight) };\r
- },\r
-\r
- /**\r
- * Returns the size of the element.\r
- * @param {Boolean} contentSize (optional) true to get the width/size minus borders and padding\r
- * @return {Object} An object containing the element's size {width: (element width), height: (element height)}\r
- */\r
- getSize : function(contentSize){\r
- return {width: this.getWidth(contentSize), height: this.getHeight(contentSize)};\r
- },\r
-\r
- /**\r
- * Forces the browser to repaint this element\r
- * @return {Ext.Element} this\r
- */\r
- repaint : function(){\r
- var dom = this.dom;\r
- this.addClass("x-repaint");\r
- setTimeout(function(){\r
- Ext.fly(dom).removeClass("x-repaint");\r
- }, 1);\r
- return this;\r
- },\r
-\r
- /**\r
- * Disables text selection for this element (normalized across browsers)\r
- * @return {Ext.Element} this\r
- */\r
- unselectable : function(){\r
- this.dom.unselectable = "on";\r
- return this.swallowEvent("selectstart", true).\r
- applyStyles("-moz-user-select:none;-khtml-user-select:none;").\r
- addClass("x-unselectable");\r
- },\r
-\r
- /**\r
- * Returns an object with properties top, left, right and bottom representing the margins of this element unless sides is passed,\r
- * then it returns the calculated width of the sides (see getPadding)\r
- * @param {String} sides (optional) Any combination of l, r, t, b to get the sum of those sides\r
- * @return {Object/Number}\r
- */\r
- getMargins : function(side){\r
- var me = this,\r
- key,\r
- hash = {t:"top", l:"left", r:"right", b: "bottom"},\r
- o = {};\r
-\r
- if (!side) {\r
- for (key in me.margins){\r
- o[hash[key]] = parseInt(me.getStyle(me.margins[key]), 10) || 0;\r
- }\r
- return o;\r
- } else {\r
- return me.addStyles.call(me, side, me.margins);\r
- }\r
- }\r
- };\r
-}());/**\r
- * @class Ext.Element\r
- */\r
-(function(){\r
-var D = Ext.lib.Dom,\r
- LEFT = "left",\r
- RIGHT = "right",\r
- TOP = "top",\r
- BOTTOM = "bottom",\r
- POSITION = "position",\r
- STATIC = "static",\r
- RELATIVE = "relative",\r
- AUTO = "auto",\r
- ZINDEX = "z-index";\r
-\r
-function animTest(args, animate, i) {\r
- return this.preanim && !!animate ? this.preanim(args, i) : false \r
-}\r
-\r
-Ext.Element.addMethods({\r
- /**\r
- * Gets the current X position of the element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).\r
- * @return {Number} The X position of the element\r
- */\r
- getX : function(){\r
- return D.getX(this.dom);\r
- },\r
-\r
- /**\r
- * Gets the current Y position of the element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).\r
- * @return {Number} The Y position of the element\r
- */\r
- getY : function(){\r
- return D.getY(this.dom);\r
- },\r
-\r
- /**\r
- * Gets the current position of the element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).\r
- * @return {Array} The XY position of the element\r
- */\r
- getXY : function(){\r
- return D.getXY(this.dom);\r
- },\r
-\r
- /**\r
- * Returns the offsets of this element from the passed element. Both element must be part of the DOM tree and not have display:none to have page coordinates.\r
- * @param {Mixed} element The element to get the offsets from.\r
- * @return {Array} The XY page offsets (e.g. [100, -200])\r
- */\r
- getOffsetsTo : function(el){\r
- var o = this.getXY(),\r
- e = Ext.fly(el, '_internal').getXY();\r
- return [o[0]-e[0],o[1]-e[1]];\r
- },\r
-\r
- /**\r
- * Sets the X position of the element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).\r
- * @param {Number} The X position of the element\r
- * @param {Boolean/Object} animate (optional) True for the default animation, or a standard Element animation config object\r
- * @return {Ext.Element} this\r
- */\r
- setX : function(x, animate){ \r
- return this.setXY([x, this.getY()], animTest.call(this, arguments, animate, 1));\r
- },\r
-\r
- /**\r
- * Sets the Y position of the element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).\r
- * @param {Number} The Y position of the element\r
- * @param {Boolean/Object} animate (optional) True for the default animation, or a standard Element animation config object\r
- * @return {Ext.Element} this\r
- */\r
- setY : function(y, animate){ \r
- return this.setXY([this.getX(), y], animTest.call(this, arguments, animate, 1));\r
- },\r
-\r
- /**\r
- * Sets the element's left position directly using CSS style (instead of {@link #setX}).\r
- * @param {String} left The left CSS property value\r
- * @return {Ext.Element} this\r
- */\r
- setLeft : function(left){\r
- this.setStyle(LEFT, this.addUnits(left));\r
- return this;\r
- },\r
-\r
- /**\r
- * Sets the element's top position directly using CSS style (instead of {@link #setY}).\r
- * @param {String} top The top CSS property value\r
- * @return {Ext.Element} this\r
- */\r
- setTop : function(top){\r
- this.setStyle(TOP, this.addUnits(top));\r
- return this;\r
- },\r
-\r
- /**\r
- * Sets the element's CSS right style.\r
- * @param {String} right The right CSS property value\r
- * @return {Ext.Element} this\r
- */\r
- setRight : function(right){\r
- this.setStyle(RIGHT, this.addUnits(right));\r
- return this;\r
- },\r
-\r
- /**\r
- * Sets the element's CSS bottom style.\r
- * @param {String} bottom The bottom CSS property value\r
- * @return {Ext.Element} this\r
- */\r
- setBottom : function(bottom){\r
- this.setStyle(BOTTOM, this.addUnits(bottom));\r
- return this;\r
- },\r
-\r
- /**\r
- * Sets the position of the element in page coordinates, regardless of how the element is positioned.\r
- * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).\r
- * @param {Array} pos Contains X & Y [x, y] values for new position (coordinates are page-based)\r
- * @param {Boolean/Object} animate (optional) True for the default animation, or a standard Element animation config object\r
- * @return {Ext.Element} this\r
- */\r
- setXY : function(pos, animate){\r
- var me = this;\r
- if(!animate || !me.anim){\r
- D.setXY(me.dom, pos);\r
- }else{\r
- me.anim({points: {to: pos}}, me.preanim(arguments, 1), 'motion');\r
- }\r
- return me;\r
- },\r
-\r
- /**\r
- * Sets the position of the element in page coordinates, regardless of how the element is positioned.\r
- * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).\r
- * @param {Number} x X value for new position (coordinates are page-based)\r
- * @param {Number} y Y value for new position (coordinates are page-based)\r
- * @param {Boolean/Object} animate (optional) True for the default animation, or a standard Element animation config object\r
- * @return {Ext.Element} this\r
- */\r
- setLocation : function(x, y, animate){\r
- return this.setXY([x, y], animTest.call(this, arguments, animate, 2));\r
- },\r
-\r
- /**\r
- * Sets the position of the element in page coordinates, regardless of how the element is positioned.\r
- * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).\r
- * @param {Number} x X value for new position (coordinates are page-based)\r
- * @param {Number} y Y value for new position (coordinates are page-based)\r
- * @param {Boolean/Object} animate (optional) True for the default animation, or a standard Element animation config object\r
- * @return {Ext.Element} this\r
- */\r
- moveTo : function(x, y, animate){\r
- return this.setXY([x, y], animTest.call(this, arguments, animate, 2)); \r
- }, \r
- \r
- /**\r
- * Gets the left X coordinate\r
- * @param {Boolean} local True to get the local css position instead of page coordinate\r
- * @return {Number}\r
- */\r
- getLeft : function(local){\r
- return !local ? this.getX() : parseInt(this.getStyle(LEFT), 10) || 0;\r
- },\r
-\r
- /**\r
- * Gets the right X coordinate of the element (element X position + element width)\r
- * @param {Boolean} local True to get the local css position instead of page coordinate\r
- * @return {Number}\r
- */\r
- getRight : function(local){\r
- var me = this;\r
- return !local ? me.getX() + me.getWidth() : (me.getLeft(true) + me.getWidth()) || 0;\r
- },\r
-\r
- /**\r
- * Gets the top Y coordinate\r
- * @param {Boolean} local True to get the local css position instead of page coordinate\r
- * @return {Number}\r
- */\r
- getTop : function(local) {\r
- return !local ? this.getY() : parseInt(this.getStyle(TOP), 10) || 0;\r
- },\r
-\r
- /**\r
- * Gets the bottom Y coordinate of the element (element Y position + element height)\r
- * @param {Boolean} local True to get the local css position instead of page coordinate\r
- * @return {Number}\r
- */\r
- getBottom : function(local){\r
- var me = this;\r
- return !local ? me.getY() + me.getHeight() : (me.getTop(true) + me.getHeight()) || 0;\r
- },\r
-\r
- /**\r
- * Initializes positioning on this element. If a desired position is not passed, it will make the\r
- * the element positioned relative IF it is not already positioned.\r
- * @param {String} pos (optional) Positioning to use "relative", "absolute" or "fixed"\r
- * @param {Number} zIndex (optional) The zIndex to apply\r
- * @param {Number} x (optional) Set the page X position\r
- * @param {Number} y (optional) Set the page Y position\r
- */\r
- position : function(pos, zIndex, x, y){\r
- var me = this;\r
- \r
- if(!pos && me.isStyle(POSITION, STATIC)){ \r
- me.setStyle(POSITION, RELATIVE); \r
- } else if(pos) {\r
- me.setStyle(POSITION, pos);\r
- }\r
- if(zIndex){\r
- me.setStyle(ZINDEX, zIndex);\r
- }\r
- if(x || y) me.setXY([x || false, y || false]);\r
- },\r
-\r
- /**\r
- * Clear positioning back to the default when the document was loaded\r
- * @param {String} value (optional) The value to use for the left,right,top,bottom, defaults to '' (empty string). You could use 'auto'.\r
- * @return {Ext.Element} this\r
- */\r
- clearPositioning : function(value){\r
- value = value || '';\r
- this.setStyle({\r
- left : value,\r
- right : value,\r
- top : value,\r
- bottom : value,\r
- "z-index" : "",\r
- position : STATIC\r
- });\r
- return this;\r
- },\r
-\r
- /**\r
- * Gets an object with all CSS positioning properties. Useful along with setPostioning to get\r
- * snapshot before performing an update and then restoring the element.\r
- * @return {Object}\r
- */\r
- getPositioning : function(){\r
- var l = this.getStyle(LEFT);\r
- var t = this.getStyle(TOP);\r
- return {\r
- "position" : this.getStyle(POSITION),\r
- "left" : l,\r
- "right" : l ? "" : this.getStyle(RIGHT),\r
- "top" : t,\r
- "bottom" : t ? "" : this.getStyle(BOTTOM),\r
- "z-index" : this.getStyle(ZINDEX)\r
- };\r
- },\r
- \r
- /**\r
- * Set positioning with an object returned by getPositioning().\r
- * @param {Object} posCfg\r
- * @return {Ext.Element} this\r
- */\r
- setPositioning : function(pc){\r
- var me = this,\r
- style = me.dom.style;\r
- \r
- me.setStyle(pc);\r
- \r
- if(pc.right == AUTO){\r
- style.right = "";\r
- }\r
- if(pc.bottom == AUTO){\r
- style.bottom = "";\r
- }\r
- \r
- return me;\r
- }, \r
- \r
- /**\r
- * Translates the passed page coordinates into left/top css values for this element\r
- * @param {Number/Array} x The page x or an array containing [x, y]\r
- * @param {Number} y (optional) The page y, required if x is not an array\r
- * @return {Object} An object with left and top properties. e.g. {left: (value), top: (value)}\r
- */\r
- translatePoints : function(x, y){ \r
- y = isNaN(x[1]) ? y : x[1];\r
- x = isNaN(x[0]) ? x : x[0];\r
- var me = this,\r
- relative = me.isStyle(POSITION, RELATIVE),\r
- o = me.getXY(),\r
- l = parseInt(me.getStyle(LEFT), 10),\r
- t = parseInt(me.getStyle(TOP), 10);\r
- \r
- l = !isNaN(l) ? l : (relative ? 0 : me.dom.offsetLeft);\r
- t = !isNaN(t) ? t : (relative ? 0 : me.dom.offsetTop); \r
-\r
- return {left: (x - o[0] + l), top: (y - o[1] + t)}; \r
- },\r
- \r
- animTest : animTest\r
-});\r
-})();/**\r
- * @class Ext.Element\r
- */\r
-Ext.Element.addMethods({\r
- /**\r
- * Sets the element's box. Use getBox() on another element to get a box obj. If animate is true then width, height, x and y will be animated concurrently.\r
- * @param {Object} box The box to fill {x, y, width, height}\r
- * @param {Boolean} adjust (optional) Whether to adjust for box-model issues automatically\r
- * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object\r
- * @return {Ext.Element} this\r
- */\r
- setBox : function(box, adjust, animate){\r
- var me = this,\r
- w = box.width, \r
- h = box.height;\r
- if((adjust && !me.autoBoxAdjust) && !me.isBorderBox()){\r
- w -= (me.getBorderWidth("lr") + me.getPadding("lr"));\r
- h -= (me.getBorderWidth("tb") + me.getPadding("tb"));\r
- }\r
- me.setBounds(box.x, box.y, w, h, me.animTest.call(me, arguments, animate, 2));\r
- return me;\r
- },\r
- \r
- /**\r
- * Return a box {x, y, width, height} that can be used to set another elements\r
- * size/location to match this element.\r
- * @param {Boolean} contentBox (optional) If true a box for the content of the element is returned.\r
- * @param {Boolean} local (optional) If true the element's left and top are returned instead of page x/y.\r
- * @return {Object} box An object in the format {x, y, width, height}\r
- */\r
- getBox : function(contentBox, local) { \r
- var me = this,\r
- xy,\r
- left,\r
- top,\r
- getBorderWidth = me.getBorderWidth,\r
- getPadding = me.getPadding, \r
- l,\r
- r,\r
- t,\r
- b;\r
- if(!local){\r
- xy = me.getXY();\r
- }else{\r
- left = parseInt(me.getStyle("left"), 10) || 0;\r
- top = parseInt(me.getStyle("top"), 10) || 0;\r
- xy = [left, top];\r
- }\r
- var el = me.dom, w = el.offsetWidth, h = el.offsetHeight, bx;\r
- if(!contentBox){\r
- bx = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: w, height: h};\r
- }else{\r
- l = getBorderWidth.call(me, "l") + getPadding.call(me, "l");\r
- r = getBorderWidth.call(me, "r") + getPadding.call(me, "r");\r
- t = getBorderWidth.call(me, "t") + getPadding.call(me, "t");\r
- b = getBorderWidth.call(me, "b") + getPadding.call(me, "b");\r
- bx = {x: xy[0]+l, y: xy[1]+t, 0: xy[0]+l, 1: xy[1]+t, width: w-(l+r), height: h-(t+b)};\r
- }\r
- bx.right = bx.x + bx.width;\r
- bx.bottom = bx.y + bx.height;\r
- return bx;\r
- },\r
- \r
- /**\r
- * Move this element relative to its current position.\r
- * @param {String} direction Possible values are: "l" (or "left"), "r" (or "right"), "t" (or "top", or "up"), "b" (or "bottom", or "down").\r
- * @param {Number} distance How far to move the element in pixels\r
- * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object\r
- * @return {Ext.Element} this\r
- */\r
- move : function(direction, distance, animate){\r
- var me = this, \r
- xy = me.getXY(),\r
- x = xy[0],\r
- y = xy[1], \r
- left = [x - distance, y],\r
- right = [x + distance, y],\r
- top = [x, y - distance],\r
- bottom = [x, y + distance],\r
- hash = {\r
- l : left,\r
- left : left,\r
- r : right,\r
- right : right,\r
- t : top,\r
- top : top,\r
- up : top,\r
- b : bottom, \r
- bottom : bottom,\r
- down : bottom \r
- };\r
- \r
- direction = direction.toLowerCase(); \r
- me.moveTo(hash[direction][0], hash[direction][1], me.animTest.call(me, arguments, animate, 2));\r
- },\r
- \r
- /**\r
- * Quick set left and top adding default units\r
- * @param {String} left The left CSS property value\r
- * @param {String} top The top CSS property value\r
- * @return {Ext.Element} this\r
- */\r
- setLeftTop : function(left, top){\r
- var me = this,\r
- style = me.dom.style;\r
- style.left = me.addUnits(left);\r
- style.top = me.addUnits(top);\r
- return me;\r
- },\r
- \r
- /**\r
- * Returns the region of the given element.\r
- * The element must be part of the DOM tree to have a region (display:none or elements not appended return false).\r
- * @return {Region} A Ext.lib.Region containing "top, left, bottom, right" member data.\r
- */\r
- getRegion : function(){\r
- return Ext.lib.Dom.getRegion(this.dom);\r
- },\r
- \r
- /**\r
- * Sets the element's position and size in one shot. If animation is true then width, height, x and y will be animated concurrently.\r
- * @param {Number} x X value for new position (coordinates are page-based)\r
- * @param {Number} y Y value for new position (coordinates are page-based)\r
- * @param {Mixed} width The new width. This may be one of:<div class="mdetail-params"><ul>\r
- * <li>A Number specifying the new width in this Element's {@link #defaultUnit}s (by default, pixels)</li>\r
- * <li>A String used to set the CSS width style. Animation may <b>not</b> be used.\r
- * </ul></div>\r
- * @param {Mixed} height The new height. This may be one of:<div class="mdetail-params"><ul>\r
- * <li>A Number specifying the new height in this Element's {@link #defaultUnit}s (by default, pixels)</li>\r
- * <li>A String used to set the CSS height style. Animation may <b>not</b> be used.</li>\r
- * </ul></div>\r
- * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object\r
- * @return {Ext.Element} this\r
- */\r
- setBounds : function(x, y, width, height, animate){\r
- var me = this;\r
- if (!animate || !me.anim) {\r
- me.setSize(width, height);\r
- me.setLocation(x, y);\r
- } else {\r
- me.anim({points: {to: [x, y]}, \r
- width: {to: me.adjustWidth(width)}, \r
- height: {to: me.adjustHeight(height)}},\r
- me.preanim(arguments, 4), \r
- 'motion');\r
- }\r
- return me;\r
- },\r
-\r
- /**\r
- * Sets the element's position and size the specified region. If animation is true then width, height, x and y will be animated concurrently.\r
- * @param {Ext.lib.Region} region The region to fill\r
- * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object\r
- * @return {Ext.Element} this\r
- */\r
- setRegion : function(region, animate) {\r
- return this.setBounds(region.left, region.top, region.right-region.left, region.bottom-region.top, this.animTest.call(this, arguments, animate, 1));\r
- }\r
-});/**\r
- * @class Ext.Element\r
- */\r
-Ext.Element.addMethods({\r
- /**\r
- * Returns true if this element is scrollable.\r
- * @return {Boolean}\r
- */\r
- isScrollable : function(){\r
- var dom = this.dom;\r
- return dom.scrollHeight > dom.clientHeight || dom.scrollWidth > dom.clientWidth;\r
- },\r
-\r
- /**\r
- * Scrolls this element the specified scroll point. It does NOT do bounds checking so if you scroll to a weird value it will try to do it. For auto bounds checking, use scroll().\r
- * @param {String} side Either "left" for scrollLeft values or "top" for scrollTop values.\r
- * @param {Number} value The new scroll value.\r
- * @return {Element} this\r
- */\r
- scrollTo : function(side, value){\r
- this.dom["scroll" + (/top/i.test(side) ? "Top" : "Left")] = value;\r
- return this;\r
- },\r
-\r
- /**\r
- * Returns the current scroll position of the element.\r
- * @return {Object} An object containing the scroll position in the format {left: (scrollLeft), top: (scrollTop)}\r
- */\r
- getScroll : function(){\r
- var d = this.dom, \r
- doc = document,\r
- body = doc.body,\r
- docElement = doc.documentElement,\r
- l,\r
- t,\r
- ret;\r
-\r
- if(d == doc || d == body){\r
- if(Ext.isIE && Ext.isStrict){\r
- l = docElement.scrollLeft; \r
- t = docElement.scrollTop;\r
- }else{\r
- l = window.pageXOffset;\r
- t = window.pageYOffset;\r
- }\r
- ret = {left: l || (body ? body.scrollLeft : 0), top: t || (body ? body.scrollTop : 0)};\r
- }else{\r
- ret = {left: d.scrollLeft, top: d.scrollTop};\r
- }\r
- return ret;\r
- }\r
-});/**\r
- * @class Ext.Element\r
- */\r
-Ext.Element.addMethods({\r
- /**\r
- * Scrolls this element the specified scroll point. It does NOT do bounds checking so if you scroll to a weird value it will try to do it. For auto bounds checking, use scroll().\r
- * @param {String} side Either "left" for scrollLeft values or "top" for scrollTop values.\r
- * @param {Number} value The new scroll value\r
- * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object\r
- * @return {Element} this\r
- */\r
- scrollTo : function(side, value, animate){\r
- var tester = /top/i,\r
- prop = "scroll" + (tester.test(side) ? "Top" : "Left"),\r
- me = this,\r
- dom = me.dom;\r
- if (!animate || !me.anim) {\r
- dom[prop] = value;\r
- } else {\r
- me.anim({scroll: {to: tester.test(prop) ? [dom[prop], value] : [value, dom[prop]]}},\r
- me.preanim(arguments, 2), 'scroll');\r
- }\r
- return me;\r
- },\r
- \r
- /**\r
- * Scrolls this element into view within the passed container.\r
- * @param {Mixed} container (optional) The container element to scroll (defaults to document.body). Should be a\r
- * string (id), dom node, or Ext.Element.\r
- * @param {Boolean} hscroll (optional) False to disable horizontal scroll (defaults to true)\r
- * @return {Ext.Element} this\r
- */\r
- scrollIntoView : function(container, hscroll){\r
- var c = Ext.getDom(container) || Ext.getBody().dom,\r
- el = this.dom,\r
- o = this.getOffsetsTo(c),\r
- l = o[0] + c.scrollLeft,\r
- t = o[1] + c.scrollTop,\r
- b = t + el.offsetHeight,\r
- r = l + el.offsetWidth,\r
- ch = c.clientHeight,\r
- ct = parseInt(c.scrollTop, 10),\r
- cl = parseInt(c.scrollLeft, 10),\r
- cb = ct + ch,\r
- cr = cl + c.clientWidth;\r
-\r
- if (el.offsetHeight > ch || t < ct) {\r
- c.scrollTop = t;\r
- } else if (b > cb){\r
- c.scrollTop = b-ch;\r
- }\r
- c.scrollTop = c.scrollTop; // corrects IE, other browsers will ignore\r
-\r
- if(hscroll !== false){\r
- if(el.offsetWidth > c.clientWidth || l < cl){\r
- c.scrollLeft = l;\r
- }else if(r > cr){\r
- c.scrollLeft = r - c.clientWidth;\r
- }\r
- c.scrollLeft = c.scrollLeft;\r
- }\r
- return this;\r
- },\r
-\r
- // private\r
- scrollChildIntoView : function(child, hscroll){\r
- Ext.fly(child, '_scrollChildIntoView').scrollIntoView(this, hscroll);\r
- },\r
- \r
- /**\r
- * Scrolls this element the specified direction. Does bounds checking to make sure the scroll is\r
- * within this element's scrollable range.\r
- * @param {String} direction Possible values are: "l" (or "left"), "r" (or "right"), "t" (or "top", or "up"), "b" (or "bottom", or "down").\r
- * @param {Number} distance How far to scroll the element in pixels\r
- * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object\r
- * @return {Boolean} Returns true if a scroll was triggered or false if the element\r
- * was scrolled as far as it could go.\r
- */\r
- scroll : function(direction, distance, animate){\r
- if(!this.isScrollable()){\r
- return;\r
- }\r
- var el = this.dom,\r
- l = el.scrollLeft, t = el.scrollTop,\r
- w = el.scrollWidth, h = el.scrollHeight,\r
- cw = el.clientWidth, ch = el.clientHeight,\r
- scrolled = false, v,\r
- hash = {\r
- l: Math.min(l + distance, w-cw),\r
- r: v = Math.max(l - distance, 0),\r
- t: Math.max(t - distance, 0),\r
- b: Math.min(t + distance, h-ch)\r
- };\r
- hash.d = hash.b;\r
- hash.u = hash.t;\r
- \r
- direction = direction.substr(0, 1);\r
- if((v = hash[direction]) > -1){\r
- scrolled = true;\r
- this.scrollTo(direction == 'l' || direction == 'r' ? 'left' : 'top', v, this.preanim(arguments, 2));\r
- }\r
- return scrolled;\r
- }\r
-});/**\r
- * @class Ext.Element\r
- */\r
-/**\r
- * Visibility mode constant for use with {@link #setVisibilityMode}. Use visibility to hide element\r
- * @static\r
- * @type Number\r
- */\r
-Ext.Element.VISIBILITY = 1;\r
-/**\r
- * Visibility mode constant for use with {@link #setVisibilityMode}. Use display to hide element\r
- * @static\r
- * @type Number\r
- */\r
-Ext.Element.DISPLAY = 2;\r
-\r
-Ext.Element.addMethods(function(){\r
- var VISIBILITY = "visibility",\r
- DISPLAY = "display",\r
- HIDDEN = "hidden",\r
- NONE = "none", \r
- ORIGINALDISPLAY = 'originalDisplay',\r
- VISMODE = 'visibilityMode',\r
- ELDISPLAY = Ext.Element.DISPLAY,\r
- data = Ext.Element.data,\r
- getDisplay = function(dom){\r
- var d = data(dom, ORIGINALDISPLAY);\r
- if(d === undefined){\r
- data(dom, ORIGINALDISPLAY, d = '');\r
- }\r
- return d;\r
- },\r
- getVisMode = function(dom){\r
- var m = data(dom, VISMODE);\r
- if(m === undefined){\r
- data(dom, VISMODE, m = 1)\r
- }\r
- return m;\r
- };\r
- \r
- return {\r
- /**\r
- * The element's default display mode (defaults to "")\r
- * @type String\r
- */\r
- originalDisplay : "",\r
- visibilityMode : 1,\r
- \r
- /**\r
- * Sets the element's visibility mode. When setVisible() is called it\r
- * will use this to determine whether to set the visibility or the display property.\r
- * @param visMode Ext.Element.VISIBILITY or Ext.Element.DISPLAY\r
- * @return {Ext.Element} this\r
- */\r
- setVisibilityMode : function(visMode){ \r
- data(this.dom, VISMODE, visMode);\r
- return this;\r
- },\r
- \r
- /**\r
- * Perform custom animation on this element.\r
- * <div><ul class="mdetail-params">\r
- * <li><u>Animation Properties</u></li>\r
- * \r
- * <p>The Animation Control Object enables gradual transitions for any member of an\r
- * element's style object that takes a numeric value including but not limited to\r
- * these properties:</p><div><ul class="mdetail-params">\r
- * <li><tt>bottom, top, left, right</tt></li>\r
- * <li><tt>height, width</tt></li>\r
- * <li><tt>margin, padding</tt></li>\r
- * <li><tt>borderWidth</tt></li>\r
- * <li><tt>opacity</tt></li>\r
- * <li><tt>fontSize</tt></li>\r
- * <li><tt>lineHeight</tt></li>\r
- * </ul></div>\r
- * \r
- * \r
- * <li><u>Animation Property Attributes</u></li>\r
- * \r
- * <p>Each Animation Property is a config object with optional properties:</p>\r
- * <div><ul class="mdetail-params">\r
- * <li><tt>by</tt>* : relative change - start at current value, change by this value</li>\r
- * <li><tt>from</tt> : ignore current value, start from this value</li>\r
- * <li><tt>to</tt>* : start at current value, go to this value</li>\r
- * <li><tt>unit</tt> : any allowable unit specification</li>\r
- * <p>* do not specify both <tt>to</tt> and <tt>by</tt> for an animation property</p>\r
- * </ul></div>\r
- * \r
- * <li><u>Animation Types</u></li>\r
- * \r
- * <p>The supported animation types:</p><div><ul class="mdetail-params">\r
- * <li><tt>'run'</tt> : Default\r
- * <pre><code>\r
-var el = Ext.get('complexEl');\r
-el.animate(\r
- // animation control object\r
- {\r
- borderWidth: {to: 3, from: 0},\r
- opacity: {to: .3, from: 1},\r
- height: {to: 50, from: el.getHeight()},\r
- width: {to: 300, from: el.getWidth()},\r
- top : {by: - 100, unit: 'px'},\r
- },\r
- 0.35, // animation duration\r
- null, // callback\r
- 'easeOut', // easing method\r
- 'run' // animation type ('run','color','motion','scroll') \r
-);\r
- * </code></pre>\r
- * </li>\r
- * <li><tt>'color'</tt>\r
- * <p>Animates transition of background, text, or border colors.</p>\r
- * <pre><code>\r
-el.animate(\r
- // animation control object\r
- {\r
- color: { to: '#06e' },\r
- backgroundColor: { to: '#e06' }\r
- },\r
- 0.35, // animation duration\r
- null, // callback\r
- 'easeOut', // easing method\r
- 'color' // animation type ('run','color','motion','scroll') \r
-);\r
- * </code></pre> \r
- * </li>\r
- * \r
- * <li><tt>'motion'</tt>\r
- * <p>Animates the motion of an element to/from specific points using optional bezier\r
- * way points during transit.</p>\r
- * <pre><code>\r
-el.animate(\r
- // animation control object\r
- {\r
- borderWidth: {to: 3, from: 0},\r
- opacity: {to: .3, from: 1},\r
- height: {to: 50, from: el.getHeight()},\r
- width: {to: 300, from: el.getWidth()},\r
- top : {by: - 100, unit: 'px'},\r
- points: {\r
- to: [50, 100], // go to this point\r
- control: [ // optional bezier way points\r
- [ 600, 800],\r
- [-100, 200]\r
- ]\r
- }\r
- },\r
- 3000, // animation duration (milliseconds!)\r
- null, // callback\r
- 'easeOut', // easing method\r
- 'motion' // animation type ('run','color','motion','scroll') \r
-);\r
- * </code></pre> \r
- * </li>\r
- * <li><tt>'scroll'</tt>\r
- * <p>Animate horizontal or vertical scrolling of an overflowing page element.</p>\r
- * <pre><code>\r
-el.animate(\r
- // animation control object\r
- {\r
- scroll: {to: [400, 300]}\r
- },\r
- 0.35, // animation duration\r
- null, // callback\r
- 'easeOut', // easing method\r
- 'scroll' // animation type ('run','color','motion','scroll') \r
-);\r
- * </code></pre> \r
- * </li>\r
- * </ul></div>\r
- * \r
- * </ul></div>\r
- * \r
- * @param {Object} args The animation control args\r
- * @param {Float} duration (optional) How long the animation lasts in seconds (defaults to <tt>.35</tt>)\r
- * @param {Function} onComplete (optional) Function to call when animation completes\r
- * @param {String} easing (optional) {@link Ext.Fx#easing} method to use (defaults to <tt>'easeOut'</tt>)\r
- * @param {String} animType (optional) <tt>'run'</tt> is the default. Can also be <tt>'color'</tt>,\r
- * <tt>'motion'</tt>, or <tt>'scroll'</tt>\r
- * @return {Ext.Element} this\r
- */\r
- animate : function(args, duration, onComplete, easing, animType){ \r
- this.anim(args, {duration: duration, callback: onComplete, easing: easing}, animType);\r
- return this;\r
- },\r
- \r
- /*\r
- * @private Internal animation call\r
- */\r
- anim : function(args, opt, animType, defaultDur, defaultEase, cb){\r
- animType = animType || 'run';\r
- opt = opt || {};\r
- var me = this, \r
- anim = Ext.lib.Anim[animType](\r
- me.dom, \r
- args,\r
- (opt.duration || defaultDur) || .35,\r
- (opt.easing || defaultEase) || 'easeOut',\r
- function(){\r
- if(cb) cb.call(me);\r
- if(opt.callback) opt.callback.call(opt.scope || me, me, opt);\r
- },\r
- me\r
- );\r
- opt.anim = anim;\r
- return anim;\r
- },\r
- \r
- // private legacy anim prep\r
- preanim : function(a, i){\r
- return !a[i] ? false : (Ext.isObject(a[i]) ? a[i]: {duration: a[i+1], callback: a[i+2], easing: a[i+3]});\r
- },\r
- \r
- /**\r
- * Checks whether the element is currently visible using both visibility and display properties. \r
- * @return {Boolean} True if the element is currently visible, else false\r
- */\r
- isVisible : function() {\r
- return !this.isStyle(VISIBILITY, HIDDEN) && !this.isStyle(DISPLAY, NONE);\r
- },\r
- \r
- /**\r
- * Sets the visibility of the element (see details). If the visibilityMode is set to Element.DISPLAY, it will use\r
- * the display property to hide the element, otherwise it uses visibility. The default is to hide and show using the visibility property.\r
- * @param {Boolean} visible Whether the element is visible\r
- * @param {Boolean/Object} animate (optional) True for the default animation, or a standard Element animation config object\r
- * @return {Ext.Element} this\r
- */\r
- setVisible : function(visible, animate){\r
- var me = this,\r
- dom = me.dom,\r
- isDisplay = getVisMode(this.dom) == ELDISPLAY;\r
- \r
- if (!animate || !me.anim) {\r
- if(isDisplay){\r
- me.setDisplayed(visible);\r
- }else{\r
- me.fixDisplay();\r
- dom.style.visibility = visible ? "visible" : HIDDEN;\r
- }\r
- }else{\r
- // closure for composites \r
- if(visible){\r
- me.setOpacity(.01);\r
- me.setVisible(true);\r
- }\r
- me.anim({opacity: { to: (visible?1:0) }},\r
- me.preanim(arguments, 1),\r
- null,\r
- .35,\r
- 'easeIn',\r
- function(){\r
- if(!visible){\r
- dom.style[isDisplay ? DISPLAY : VISIBILITY] = (isDisplay) ? NONE : HIDDEN; \r
- Ext.fly(dom).setOpacity(1);\r
- }\r
- });\r
- }\r
- return me;\r
- },\r
- \r
- /**\r
- * Toggles the element's visibility or display, depending on visibility mode.\r
- * @param {Boolean/Object} animate (optional) True for the default animation, or a standard Element animation config object\r
- * @return {Ext.Element} this\r
- */\r
- toggle : function(animate){\r
- var me = this;\r
- me.setVisible(!me.isVisible(), me.preanim(arguments, 0));\r
- return me;\r
- },\r
- \r
- /**\r
- * Sets the CSS display property. Uses originalDisplay if the specified value is a boolean true.\r
- * @param {Mixed} value Boolean value to display the element using its default display, or a string to set the display directly.\r
- * @return {Ext.Element} this\r
- */\r
- setDisplayed : function(value) { \r
- if(typeof value == "boolean"){\r
- value = value ? getDisplay(this.dom) : NONE;\r
- }\r
- this.setStyle(DISPLAY, value);\r
- return this;\r
- },\r
- \r
- // private\r
- fixDisplay : function(){\r
- var me = this;\r
- if(me.isStyle(DISPLAY, NONE)){\r
- me.setStyle(VISIBILITY, HIDDEN);\r
- me.setStyle(DISPLAY, getDisplay(this.dom)); // first try reverting to default\r
- if(me.isStyle(DISPLAY, NONE)){ // if that fails, default to block\r
- me.setStyle(DISPLAY, "block");\r
- }\r
- }\r
- },\r
- \r
- /**\r
- * Hide this element - Uses display mode to determine whether to use "display" or "visibility". See {@link #setVisible}.\r
- * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object\r
- * @return {Ext.Element} this\r
- */\r
- hide : function(animate){\r
- this.setVisible(false, this.preanim(arguments, 0));\r
- return this;\r
- },\r
- \r
- /**\r
- * Show this element - Uses display mode to determine whether to use "display" or "visibility". See {@link #setVisible}.\r
- * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object\r
- * @return {Ext.Element} this\r
- */\r
- show : function(animate){\r
- this.setVisible(true, this.preanim(arguments, 0));\r
- return this;\r
- }\r
- }\r
-}());/**\r
- * @class Ext.Element\r
- */\r
-Ext.Element.addMethods(\r
-function(){\r
- var VISIBILITY = "visibility",\r
- DISPLAY = "display",\r
- HIDDEN = "hidden",\r
- NONE = "none",\r
- XMASKED = "x-masked",\r
- XMASKEDRELATIVE = "x-masked-relative",\r
- data = Ext.Element.data;\r
- \r
- return {\r
- /**\r
- * Checks whether the element is currently visible using both visibility and display properties.\r
- * @param {Boolean} deep (optional) True to walk the dom and see if parent elements are hidden (defaults to false)\r
- * @return {Boolean} True if the element is currently visible, else false\r
- */\r
- isVisible : function(deep) {\r
- var vis = !this.isStyle(VISIBILITY,HIDDEN) && !this.isStyle(DISPLAY,NONE),\r
- p = this.dom.parentNode;\r
- if(deep !== true || !vis){\r
- return vis;\r
- } \r
- while(p && !/body/i.test(p.tagName)){\r
- if(!Ext.fly(p, '_isVisible').isVisible()){\r
- return false;\r
- }\r
- p = p.parentNode;\r
- }\r
- return true;\r
- },\r
- \r
- /**\r
- * Returns true if display is not "none"\r
- * @return {Boolean}\r
- */\r
- isDisplayed : function() {\r
- return !this.isStyle(DISPLAY, NONE);\r
- },\r
- \r
- /**\r
- * Convenience method for setVisibilityMode(Element.DISPLAY)\r
- * @param {String} display (optional) What to set display to when visible\r
- * @return {Ext.Element} this\r
- */\r
- enableDisplayMode : function(display){ \r
- this.setVisibilityMode(Ext.Element.DISPLAY);\r
- if(!Ext.isEmpty(display)){\r
- data(this.dom, 'originalDisplay', display);\r
- }\r
- return this;\r
- },\r
- \r
- /**\r
- * Puts a mask over this element to disable user interaction. Requires core.css.\r
- * This method can only be applied to elements which accept child nodes.\r
- * @param {String} msg (optional) A message to display in the mask\r
- * @param {String} msgCls (optional) A css class to apply to the msg element\r
- * @return {Element} The mask element\r
- */\r
- mask : function(msg, msgCls){\r
- var me = this,\r
- dom = me.dom,\r
- dh = Ext.DomHelper,\r
- EXTELMASKMSG = "ext-el-mask-msg",\r
- el, \r
- mask;\r
- \r
- if(me.getStyle("position") == "static"){\r
- me.addClass(XMASKEDRELATIVE);\r
- }\r
- if((el = data(dom, 'maskMsg'))){\r
- el.remove();\r
- }\r
- if((el = data(dom, 'mask'))){\r
- el.remove();\r
- }\r
- \r
- mask = dh.append(dom, {cls : "ext-el-mask"}, true);\r
- data(dom, 'mask', mask);\r
- \r
- me.addClass(XMASKED);\r
- mask.setDisplayed(true);\r
- if(typeof msg == 'string'){\r
- var mm = dh.append(dom, {cls : EXTELMASKMSG, cn:{tag:'div'}}, true);\r
- data(dom, 'maskMsg', mm);\r
- mm.dom.className = msgCls ? EXTELMASKMSG + " " + msgCls : EXTELMASKMSG;\r
- mm.dom.firstChild.innerHTML = msg;\r
- mm.setDisplayed(true);\r
- mm.center(me);\r
- }\r
- if(Ext.isIE && !(Ext.isIE7 && Ext.isStrict) && me.getStyle('height') == 'auto'){ // ie will not expand full height automatically\r
- mask.setSize(undefined, me.getHeight());\r
- }\r
- return mask;\r
- },\r
- \r
- /**\r
- * Removes a previously applied mask.\r
- */\r
- unmask : function(){\r
- var me = this,\r
- dom = me.dom,\r
- mask = data(dom, 'mask'),\r
- maskMsg = data(dom, 'maskMsg');\r
- if(mask){\r
- if(maskMsg){\r
- maskMsg.remove();\r
- data(dom, 'maskMsg', undefined);\r
- }\r
- mask.remove();\r
- data(dom, 'mask', undefined);\r
- }\r
- me.removeClass([XMASKED, XMASKEDRELATIVE]);\r
- },\r
- \r
- /**\r
- * Returns true if this element is masked\r
- * @return {Boolean}\r
- */\r
- isMasked : function(){\r
- var m = data(this.dom, 'mask');\r
- return m && m.isVisible();\r
- },\r
- \r
- /**\r
- * Creates an iframe shim for this element to keep selects and other windowed objects from\r
- * showing through.\r
- * @return {Ext.Element} The new shim element\r
- */\r
- createShim : function(){\r
- var el = document.createElement('iframe'), \r
- shim;\r
- el.frameBorder = '0';\r
- el.className = 'ext-shim';\r
- if(Ext.isIE && Ext.isSecure){\r
- el.src = Ext.SSL_SECURE_URL;\r
- }\r
- shim = Ext.get(this.dom.parentNode.insertBefore(el, this.dom));\r
- shim.autoBoxAdjust = false;\r
- return shim;\r
- }\r
- };\r
-}());/**\r
- * @class Ext.Element\r
- */\r
-Ext.Element.addMethods({\r
- /**\r
- * Convenience method for constructing a KeyMap\r
- * @param {Number/Array/Object/String} key Either a string with the keys to listen for, the numeric key code, array of key codes or an object with the following options:\r
- * {key: (number or array), shift: (true/false), ctrl: (true/false), alt: (true/false)}\r
- * @param {Function} fn The function to call\r
- * @param {Object} scope (optional) The scope of the function\r
- * @return {Ext.KeyMap} The KeyMap created\r
- */\r
- addKeyListener : function(key, fn, scope){\r
- var config;\r
- if(!Ext.isObject(key) || Ext.isArray(key)){\r
- config = {\r
- key: key,\r
- fn: fn,\r
- scope: scope\r
- };\r
- }else{\r
- config = {\r
- key : key.key,\r
- shift : key.shift,\r
- ctrl : key.ctrl,\r
- alt : key.alt,\r
- fn: fn,\r
- scope: scope\r
- };\r
- }\r
- return new Ext.KeyMap(this, config);\r
- },\r
-\r
- /**\r
- * Creates a KeyMap for this element\r
- * @param {Object} config The KeyMap config. See {@link Ext.KeyMap} for more details\r
- * @return {Ext.KeyMap} The KeyMap created\r
- */\r
- addKeyMap : function(config){\r
- return new Ext.KeyMap(this, config);\r
- }\r
-});(function(){\r
- // contants\r
- var NULL = null,\r
- UNDEFINED = undefined,\r
- TRUE = true,\r
- FALSE = false,\r
- SETX = "setX",\r
- SETY = "setY",\r
- SETXY = "setXY",\r
- LEFT = "left",\r
- BOTTOM = "bottom",\r
- TOP = "top",\r
- RIGHT = "right",\r
- HEIGHT = "height",\r
- WIDTH = "width",\r
- POINTS = "points",\r
- HIDDEN = "hidden",\r
- ABSOLUTE = "absolute",\r
- VISIBLE = "visible",\r
- MOTION = "motion",\r
- POSITION = "position",\r
- EASEOUT = "easeOut",\r
- /*\r
- * Use a light flyweight here since we are using so many callbacks and are always assured a DOM element\r
- */\r
- flyEl = new Ext.Element.Flyweight(),\r
- queues = {},\r
- getObject = function(o){\r
- return o || {};\r
- },\r
- fly = function(dom){\r
- flyEl.dom = dom;\r
- flyEl.id = Ext.id(dom);\r
- return flyEl;\r
- },\r
- /*\r
- * Queueing now stored outside of the element due to closure issues\r
- */\r
- getQueue = function(id){\r
- if(!queues[id]){\r
- queues[id] = [];\r
- }\r
- return queues[id];\r
- },\r
- setQueue = function(id, value){\r
- queues[id] = value;\r
- };\r
- \r
-//Notifies Element that fx methods are available\r
-Ext.enableFx = TRUE;\r
-\r
-/**\r
- * @class Ext.Fx\r
- * <p>A class to provide basic animation and visual effects support. <b>Note:</b> This class is automatically applied\r
- * to the {@link Ext.Element} interface when included, so all effects calls should be performed via {@link Ext.Element}.\r
- * Conversely, since the effects are not actually defined in {@link Ext.Element}, Ext.Fx <b>must</b> be\r
- * {@link Ext#enableFx included} in order for the Element effects to work.</p><br/>\r
- * \r
- * <p><b><u>Method Chaining</u></b></p>\r
- * <p>It is important to note that although the Fx methods and many non-Fx Element methods support "method chaining" in that\r
- * they return the Element object itself as the method return value, it is not always possible to mix the two in a single\r
- * method chain. The Fx methods use an internal effects queue so that each effect can be properly timed and sequenced.\r
- * Non-Fx methods, on the other hand, have no such internal queueing and will always execute immediately. For this reason,\r
- * while it may be possible to mix certain Fx and non-Fx method calls in a single chain, it may not always provide the\r
- * expected results and should be done with care. Also see <tt>{@link #callback}</tt>.</p><br/>\r
- *\r
- * <p><b><u>Anchor Options for Motion Effects</u></b></p>\r
- * <p>Motion effects support 8-way anchoring, meaning that you can choose one of 8 different anchor points on the Element\r
- * that will serve as either the start or end point of the animation. Following are all of the supported anchor positions:</p>\r
-<pre>\r
-Value Description\r
------ -----------------------------\r
-tl The top left corner\r
-t The center of the top edge\r
-tr The top right corner\r
-l The center of the left edge\r
-r The center of the right edge\r
-bl The bottom left corner\r
-b The center of the bottom edge\r
-br The bottom right corner\r
-</pre>\r
- * <b>Note</b>: some Fx methods accept specific custom config parameters. The options shown in the Config Options\r
- * section below are common options that can be passed to any Fx method unless otherwise noted.</b>\r
- * \r
- * @cfg {Function} callback A function called when the effect is finished. Note that effects are queued internally by the\r
- * Fx class, so a callback is not required to specify another effect -- effects can simply be chained together\r
- * and called in sequence (see note for <b><u>Method Chaining</u></b> above), for example:<pre><code>\r
- * el.slideIn().highlight();\r
- * </code></pre>\r
- * The callback is intended for any additional code that should run once a particular effect has completed. The Element\r
- * being operated upon is passed as the first parameter.\r
- * \r
- * @cfg {Object} scope The scope of the <tt>{@link #callback}</tt> function\r
- * \r
- * @cfg {String} easing A valid Ext.lib.Easing value for the effect:</p><div class="mdetail-params"><ul>\r
- * <li><b><tt>backBoth</tt></b></li>\r
- * <li><b><tt>backIn</tt></b></li>\r
- * <li><b><tt>backOut</tt></b></li>\r
- * <li><b><tt>bounceBoth</tt></b></li>\r
- * <li><b><tt>bounceIn</tt></b></li>\r
- * <li><b><tt>bounceOut</tt></b></li>\r
- * <li><b><tt>easeBoth</tt></b></li>\r
- * <li><b><tt>easeBothStrong</tt></b></li>\r
- * <li><b><tt>easeIn</tt></b></li>\r
- * <li><b><tt>easeInStrong</tt></b></li>\r
- * <li><b><tt>easeNone</tt></b></li>\r
- * <li><b><tt>easeOut</tt></b></li>\r
- * <li><b><tt>easeOutStrong</tt></b></li>\r
- * <li><b><tt>elasticBoth</tt></b></li>\r
- * <li><b><tt>elasticIn</tt></b></li>\r
- * <li><b><tt>elasticOut</tt></b></li>\r
- * </ul></div>\r
- *\r
- * @cfg {String} afterCls A css class to apply after the effect\r
- * @cfg {Number} duration The length of time (in seconds) that the effect should last\r
- * \r
- * @cfg {Number} endOpacity Only applicable for {@link #fadeIn} or {@link #fadeOut}, a number between\r
- * <tt>0</tt> and <tt>1</tt> inclusive to configure the ending opacity value.\r
- * \r
- * @cfg {Boolean} remove Whether the Element should be removed from the DOM and destroyed after the effect finishes\r
- * @cfg {Boolean} useDisplay Whether to use the <i>display</i> CSS property instead of <i>visibility</i> when hiding Elements (only applies to \r
- * effects that end with the element being visually hidden, ignored otherwise)\r
- * @cfg {String/Object/Function} afterStyle A style specification string, e.g. <tt>"width:100px"</tt>, or an object\r
- * in the form <tt>{width:"100px"}</tt>, or a function which returns such a specification that will be applied to the\r
- * Element after the effect finishes.\r
- * @cfg {Boolean} block Whether the effect should block other effects from queueing while it runs\r
- * @cfg {Boolean} concurrent Whether to allow subsequently-queued effects to run at the same time as the current effect, or to ensure that they run in sequence\r
- * @cfg {Boolean} stopFx Whether preceding effects should be stopped and removed before running current effect (only applies to non blocking effects)\r
- */\r
-Ext.Fx = {\r
- \r
- // private - calls the function taking arguments from the argHash based on the key. Returns the return value of the function.\r
- // this is useful for replacing switch statements (for example).\r
- switchStatements : function(key, fn, argHash){\r
- return fn.apply(this, argHash[key]);\r
- },\r
- \r
- /**\r
- * Slides the element into view. An anchor point can be optionally passed to set the point of\r
- * origin for the slide effect. This function automatically handles wrapping the element with\r
- * a fixed-size container if needed. See the Fx class overview for valid anchor point options.\r
- * Usage:\r
- *<pre><code>\r
-// default: slide the element in from the top\r
-el.slideIn();\r
-\r
-// custom: slide the element in from the right with a 2-second duration\r
-el.slideIn('r', { duration: 2 });\r
-\r
-// common config options shown with default values\r
-el.slideIn('t', {\r
- easing: 'easeOut',\r
- duration: .5\r
-});\r
-</code></pre>\r
- * @param {String} anchor (optional) One of the valid Fx anchor positions (defaults to top: 't')\r
- * @param {Object} options (optional) Object literal with any of the Fx config options\r
- * @return {Ext.Element} The Element\r
- */\r
- slideIn : function(anchor, o){ \r
- o = getObject(o);\r
- var me = this,\r
- dom = me.dom,\r
- st = dom.style,\r
- xy,\r
- r,\r
- b, \r
- wrap, \r
- after,\r
- st,\r
- args, \r
- pt,\r
- bw,\r
- bh;\r
- \r
- anchor = anchor || "t";\r
-\r
- me.queueFx(o, function(){ \r
- xy = fly(dom).getXY();\r
- // fix display to visibility\r
- fly(dom).fixDisplay(); \r
- \r
- // restore values after effect\r
- r = fly(dom).getFxRestore(); \r
- b = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: dom.offsetWidth, height: dom.offsetHeight};\r
- b.right = b.x + b.width;\r
- b.bottom = b.y + b.height;\r
- \r
- // fixed size for slide\r
- fly(dom).setWidth(b.width).setHeight(b.height); \r
- \r
- // wrap if needed\r
- wrap = fly(dom).fxWrap(r.pos, o, HIDDEN);\r
- \r
- st.visibility = VISIBLE;\r
- st.position = ABSOLUTE;\r
- \r
- // clear out temp styles after slide and unwrap\r
- function after(){\r
- fly(dom).fxUnwrap(wrap, r.pos, o);\r
- st.width = r.width;\r
- st.height = r.height;\r
- fly(dom).afterFx(o);\r
- }\r
- \r
- // time to calculate the positions \r
- pt = {to: [b.x, b.y]}; \r
- bw = {to: b.width};\r
- bh = {to: b.height};\r
- \r
- function argCalc(wrap, style, ww, wh, sXY, sXYval, s1, s2, w, h, p){ \r
- var ret = {};\r
- fly(wrap).setWidth(ww).setHeight(wh);\r
- if(fly(wrap)[sXY]){\r
- fly(wrap)[sXY](sXYval); \r
- }\r
- style[s1] = style[s2] = "0"; \r
- if(w){\r
- ret.width = w\r
- };\r
- if(h){\r
- ret.height = h;\r
- }\r
- if(p){\r
- ret.points = p;\r
- }\r
- return ret;\r
- };\r
-\r
- args = fly(dom).switchStatements(anchor.toLowerCase(), argCalc, {\r
- t : [wrap, st, b.width, 0, NULL, NULL, LEFT, BOTTOM, NULL, bh, NULL],\r
- l : [wrap, st, 0, b.height, NULL, NULL, RIGHT, TOP, bw, NULL, NULL],\r
- r : [wrap, st, b.width, b.height, SETX, b.right, LEFT, TOP, NULL, NULL, pt],\r
- b : [wrap, st, b.width, b.height, SETY, b.bottom, LEFT, TOP, NULL, bh, pt],\r
- tl : [wrap, st, 0, 0, NULL, NULL, RIGHT, BOTTOM, bw, bh, pt],\r
- bl : [wrap, st, 0, 0, SETY, b.y + b.height, RIGHT, TOP, bw, bh, pt],\r
- br : [wrap, st, 0, 0, SETXY, [b.right, b.bottom], LEFT, TOP, bw, bh, pt],\r
- tr : [wrap, st, 0, 0, SETX, b.x + b.width, LEFT, BOTTOM, bw, bh, pt]\r
- });\r
- \r
- st.visibility = VISIBLE;\r
- fly(wrap).show();\r
-\r
- arguments.callee.anim = fly(wrap).fxanim(args,\r
- o,\r
- MOTION,\r
- .5,\r
- EASEOUT, \r
- after);\r
- });\r
- return me;\r
- },\r
- \r
- /**\r
- * Slides the element out of view. An anchor point can be optionally passed to set the end point\r
- * for the slide effect. When the effect is completed, the element will be hidden (visibility = \r
- * 'hidden') but block elements will still take up space in the document. The element must be removed\r
- * from the DOM using the 'remove' config option if desired. This function automatically handles \r
- * wrapping the element with a fixed-size container if needed. See the Fx class overview for valid anchor point options.\r
- * Usage:\r
- *<pre><code>\r
-// default: slide the element out to the top\r
-el.slideOut();\r
-\r
-// custom: slide the element out to the right with a 2-second duration\r
-el.slideOut('r', { duration: 2 });\r
-\r
-// common config options shown with default values\r
-el.slideOut('t', {\r
- easing: 'easeOut',\r
- duration: .5,\r
- remove: false,\r
- useDisplay: false\r
-});\r
-</code></pre>\r
- * @param {String} anchor (optional) One of the valid Fx anchor positions (defaults to top: 't')\r
- * @param {Object} options (optional) Object literal with any of the Fx config options\r
- * @return {Ext.Element} The Element\r
- */\r
- slideOut : function(anchor, o){\r
- o = getObject(o);\r
- var me = this,\r
- dom = me.dom,\r
- st = dom.style,\r
- xy = me.getXY(),\r
- wrap,\r
- r,\r
- b,\r
- a,\r
- zero = {to: 0}; \r
- \r
- anchor = anchor || "t";\r
-\r
- me.queueFx(o, function(){\r
- \r
- // restore values after effect\r
- r = fly(dom).getFxRestore(); \r
- b = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: dom.offsetWidth, height: dom.offsetHeight};\r
- b.right = b.x + b.width;\r
- b.bottom = b.y + b.height;\r
- \r
- // fixed size for slide \r
- fly(dom).setWidth(b.width).setHeight(b.height);\r
-\r
- // wrap if needed\r
- wrap = fly(dom).fxWrap(r.pos, o, VISIBLE);\r
- \r
- st.visibility = VISIBLE;\r
- st.position = ABSOLUTE;\r
- fly(wrap).setWidth(b.width).setHeight(b.height); \r
-\r
- function after(){\r
- o.useDisplay ? fly(dom).setDisplayed(FALSE) : fly(dom).hide(); \r
- fly(dom).fxUnwrap(wrap, r.pos, o);\r
- st.width = r.width;\r
- st.height = r.height;\r
- fly(dom).afterFx(o);\r
- } \r
- \r
- function argCalc(style, s1, s2, p1, v1, p2, v2, p3, v3){ \r
- var ret = {};\r
- \r
- style[s1] = style[s2] = "0";\r
- ret[p1] = v1; \r
- if(p2){\r
- ret[p2] = v2; \r
- }\r
- if(p3){\r
- ret[p3] = v3;\r
- }\r
- \r
- return ret;\r
- };\r
- \r
- a = fly(dom).switchStatements(anchor.toLowerCase(), argCalc, {\r
- t : [st, LEFT, BOTTOM, HEIGHT, zero],\r
- l : [st, RIGHT, TOP, WIDTH, zero],\r
- r : [st, LEFT, TOP, WIDTH, zero, POINTS, {to : [b.right, b.y]}],\r
- b : [st, LEFT, TOP, HEIGHT, zero, POINTS, {to : [b.x, b.bottom]}],\r
- tl : [st, RIGHT, BOTTOM, WIDTH, zero, HEIGHT, zero],\r
- bl : [st, RIGHT, TOP, WIDTH, zero, HEIGHT, zero, POINTS, {to : [b.x, b.bottom]}],\r
- br : [st, LEFT, TOP, WIDTH, zero, HEIGHT, zero, POINTS, {to : [b.x + b.width, b.bottom]}],\r
- tr : [st, LEFT, BOTTOM, WIDTH, zero, HEIGHT, zero, POINTS, {to : [b.right, b.y]}]\r
- });\r
- \r
- arguments.callee.anim = fly(wrap).fxanim(a,\r
- o,\r
- MOTION,\r
- .5,\r
- EASEOUT, \r
- after);\r
- });\r
- return me;\r
- },\r
-\r
- /**\r
- * Fades the element out while slowly expanding it in all directions. When the effect is completed, the \r
- * element will be hidden (visibility = 'hidden') but block elements will still take up space in the document. \r
- * The element must be removed from the DOM using the 'remove' config option if desired.\r
- * Usage:\r
- *<pre><code>\r
-// default\r
-el.puff();\r
-\r
-// common config options shown with default values\r
-el.puff({\r
- easing: 'easeOut',\r
- duration: .5,\r
- remove: false,\r
- useDisplay: false\r
-});\r
-</code></pre>\r
- * @param {Object} options (optional) Object literal with any of the Fx config options\r
- * @return {Ext.Element} The Element\r
- */\r
- puff : function(o){\r
- o = getObject(o);\r
- var me = this,\r
- dom = me.dom,\r
- st = dom.style,\r
- width,\r
- height,\r
- r;\r
-\r
- me.queueFx(o, function(){\r
- width = fly(dom).getWidth();\r
- height = fly(dom).getHeight();\r
- fly(dom).clearOpacity();\r
- fly(dom).show();\r
-\r
- // restore values after effect\r
- r = fly(dom).getFxRestore(); \r
- \r
- function after(){\r
- o.useDisplay ? fly(dom).setDisplayed(FALSE) : fly(dom).hide(); \r
- fly(dom).clearOpacity(); \r
- fly(dom).setPositioning(r.pos);\r
- st.width = r.width;\r
- st.height = r.height;\r
- st.fontSize = '';\r
- fly(dom).afterFx(o);\r
- } \r
-\r
- arguments.callee.anim = fly(dom).fxanim({\r
- width : {to : fly(dom).adjustWidth(width * 2)},\r
- height : {to : fly(dom).adjustHeight(height * 2)},\r
- points : {by : [-width * .5, -height * .5]},\r
- opacity : {to : 0},\r
- fontSize: {to : 200, unit: "%"}\r
- },\r
- o,\r
- MOTION,\r
- .5,\r
- EASEOUT,\r
- after);\r
- });\r
- return me;\r
- },\r
-\r
- /**\r
- * Blinks the element as if it was clicked and then collapses on its center (similar to switching off a television).\r
- * When the effect is completed, the element will be hidden (visibility = 'hidden') but block elements will still \r
- * take up space in the document. The element must be removed from the DOM using the 'remove' config option if desired.\r
- * Usage:\r
- *<pre><code>\r
-// default\r
-el.switchOff();\r
-\r
-// all config options shown with default values\r
-el.switchOff({\r
- easing: 'easeIn',\r
- duration: .3,\r
- remove: false,\r
- useDisplay: false\r
-});\r
-</code></pre>\r
- * @param {Object} options (optional) Object literal with any of the Fx config options\r
- * @return {Ext.Element} The Element\r
- */\r
- switchOff : function(o){\r
- o = getObject(o);\r
- var me = this,\r
- dom = me.dom,\r
- st = dom.style,\r
- r;\r
-\r
- me.queueFx(o, function(){\r
- fly(dom).clearOpacity();\r
- fly(dom).clip();\r
-\r
- // restore values after effect\r
- r = fly(dom).getFxRestore();\r
- \r
- function after(){\r
- o.useDisplay ? fly(dom).setDisplayed(FALSE) : fly(dom).hide(); \r
- fly(dom).clearOpacity();\r
- fly(dom).setPositioning(r.pos);\r
- st.width = r.width;\r
- st.height = r.height; \r
- fly(dom).afterFx(o);\r
- };\r
-\r
- fly(dom).fxanim({opacity : {to : 0.3}}, \r
- NULL, \r
- NULL, \r
- .1, \r
- NULL, \r
- function(){ \r
- fly(dom).clearOpacity();\r
- (function(){ \r
- fly(dom).fxanim({\r
- height : {to : 1},\r
- points : {by : [0, fly(dom).getHeight() * .5]}\r
- }, \r
- o, \r
- MOTION, \r
- 0.3, \r
- 'easeIn', \r
- after);\r
- }).defer(100);\r
- });\r
- });\r
- return me;\r
- },\r
-\r
- /**\r
- * Highlights the Element by setting a color (applies to the background-color by default, but can be\r
- * changed using the "attr" config option) and then fading back to the original color. If no original\r
- * color is available, you should provide the "endColor" config option which will be cleared after the animation.\r
- * Usage:\r
-<pre><code>\r
-// default: highlight background to yellow\r
-el.highlight();\r
-\r
-// custom: highlight foreground text to blue for 2 seconds\r
-el.highlight("0000ff", { attr: 'color', duration: 2 });\r
-\r
-// common config options shown with default values\r
-el.highlight("ffff9c", {\r
- attr: "background-color", //can be any valid CSS property (attribute) that supports a color value\r
- endColor: (current color) or "ffffff",\r
- easing: 'easeIn',\r
- duration: 1\r
-});\r
-</code></pre>\r
- * @param {String} color (optional) The highlight color. Should be a 6 char hex color without the leading # (defaults to yellow: 'ffff9c')\r
- * @param {Object} options (optional) Object literal with any of the Fx config options\r
- * @return {Ext.Element} The Element\r
- */ \r
- highlight : function(color, o){\r
- o = getObject(o);\r
- var me = this,\r
- dom = me.dom,\r
- attr = o.attr || "backgroundColor",\r
- a = {},\r
- restore;\r
-\r
- me.queueFx(o, function(){\r
- fly(dom).clearOpacity();\r
- fly(dom).show();\r
-\r
- function after(){\r
- dom.style[attr] = restore;\r
- fly(dom).afterFx(o);\r
- } \r
- restore = dom.style[attr];\r
- a[attr] = {from: color || "ffff9c", to: o.endColor || fly(dom).getColor(attr) || "ffffff"};\r
- arguments.callee.anim = fly(dom).fxanim(a,\r
- o,\r
- 'color',\r
- 1,\r
- 'easeIn', \r
- after);\r
- });\r
- return me;\r
- },\r
-\r
- /**\r
- * Shows a ripple of exploding, attenuating borders to draw attention to an Element.\r
- * Usage:\r
-<pre><code>\r
-// default: a single light blue ripple\r
-el.frame();\r
-\r
-// custom: 3 red ripples lasting 3 seconds total\r
-el.frame("ff0000", 3, { duration: 3 });\r
-\r
-// common config options shown with default values\r
-el.frame("C3DAF9", 1, {\r
- duration: 1 //duration of each individual ripple.\r
- // Note: Easing is not configurable and will be ignored if included\r
-});\r
-</code></pre>\r
- * @param {String} color (optional) The color of the border. Should be a 6 char hex color without the leading # (defaults to light blue: 'C3DAF9').\r
- * @param {Number} count (optional) The number of ripples to display (defaults to 1)\r
- * @param {Object} options (optional) Object literal with any of the Fx config options\r
- * @return {Ext.Element} The Element\r
- */\r
- frame : function(color, count, o){\r
- o = getObject(o);\r
- var me = this,\r
- dom = me.dom,\r
- proxy,\r
- active;\r
-\r
- me.queueFx(o, function(){\r
- color = color || "#C3DAF9"\r
- if(color.length == 6){\r
- color = "#" + color;\r
- } \r
- count = count || 1;\r
- fly(dom).show();\r
-\r
- var xy = fly(dom).getXY(),\r
- b = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: dom.offsetWidth, height: dom.offsetHeight},\r
- queue = function(){\r
- proxy = fly(document.body || document.documentElement).createChild({\r
- style:{\r
- visbility: HIDDEN,\r
- position : ABSOLUTE,\r
- "z-index": 35000, // yee haw\r
- border : "0px solid " + color\r
- }\r
- });\r
- return proxy.queueFx({}, animFn);\r
- };\r
- \r
- \r
- arguments.callee.anim = {\r
- isAnimated: true,\r
- stop: function() {\r
- count = 0;\r
- proxy.stopFx();\r
- }\r
- };\r
- \r
- function animFn(){\r
- var scale = Ext.isBorderBox ? 2 : 1;\r
- active = proxy.anim({\r
- top : {from : b.y, to : b.y - 20},\r
- left : {from : b.x, to : b.x - 20},\r
- borderWidth : {from : 0, to : 10},\r
- opacity : {from : 1, to : 0},\r
- height : {from : b.height, to : b.height + 20 * scale},\r
- width : {from : b.width, to : b.width + 20 * scale}\r
- },{\r
- duration: o.duration || 1,\r
- callback: function() {\r
- proxy.remove();\r
- --count > 0 ? queue() : fly(dom).afterFx(o);\r
- }\r
- });\r
- arguments.callee.anim = {\r
- isAnimated: true,\r
- stop: function(){\r
- active.stop();\r
- }\r
- };\r
- };\r
- queue();\r
- });\r
- return me;\r
- },\r
-\r
- /**\r
- * Creates a pause before any subsequent queued effects begin. If there are\r
- * no effects queued after the pause it will have no effect.\r
- * Usage:\r
-<pre><code>\r
-el.pause(1);\r
-</code></pre>\r
- * @param {Number} seconds The length of time to pause (in seconds)\r
- * @return {Ext.Element} The Element\r
- */\r
- pause : function(seconds){ \r
- var dom = this.dom,\r
- t;\r
-\r
- this.queueFx({}, function(){\r
- t = setTimeout(function(){\r
- fly(dom).afterFx({});\r
- }, seconds * 1000);\r
- arguments.callee.anim = {\r
- isAnimated: true,\r
- stop: function(){\r
- clearTimeout(t);\r
- fly(dom).afterFx({});\r
- }\r
- };\r
- });\r
- return this;\r
- },\r
-\r
- /**\r
- * Fade an element in (from transparent to opaque). The ending opacity can be specified\r
- * using the <tt>{@link #endOpacity}</tt> config option.\r
- * Usage:\r
-<pre><code>\r
-// default: fade in from opacity 0 to 100%\r
-el.fadeIn();\r
-\r
-// custom: fade in from opacity 0 to 75% over 2 seconds\r
-el.fadeIn({ endOpacity: .75, duration: 2});\r
-\r
-// common config options shown with default values\r
-el.fadeIn({\r
- endOpacity: 1, //can be any value between 0 and 1 (e.g. .5)\r
- easing: 'easeOut',\r
- duration: .5\r
-});\r
-</code></pre>\r
- * @param {Object} options (optional) Object literal with any of the Fx config options\r
- * @return {Ext.Element} The Element\r
- */\r
- fadeIn : function(o){\r
- o = getObject(o);\r
- var me = this,\r
- dom = me.dom,\r
- to = o.endOpacity || 1;\r
- \r
- me.queueFx(o, function(){\r
- fly(dom).setOpacity(0);\r
- fly(dom).fixDisplay();\r
- dom.style.visibility = VISIBLE;\r
- arguments.callee.anim = fly(dom).fxanim({opacity:{to:to}},\r
- o, NULL, .5, EASEOUT, function(){\r
- if(to == 1){\r
- fly(dom).clearOpacity();\r
- }\r
- fly(dom).afterFx(o);\r
- });\r
- });\r
- return me;\r
- },\r
-\r
- /**\r
- * Fade an element out (from opaque to transparent). The ending opacity can be specified\r
- * using the <tt>{@link #endOpacity}</tt> config option. Note that IE may require\r
- * <tt>{@link #useDisplay}:true</tt> in order to redisplay correctly.\r
- * Usage:\r
-<pre><code>\r
-// default: fade out from the element's current opacity to 0\r
-el.fadeOut();\r
-\r
-// custom: fade out from the element's current opacity to 25% over 2 seconds\r
-el.fadeOut({ endOpacity: .25, duration: 2});\r
-\r
-// common config options shown with default values\r
-el.fadeOut({\r
- endOpacity: 0, //can be any value between 0 and 1 (e.g. .5)\r
- easing: 'easeOut',\r
- duration: .5,\r
- remove: false,\r
- useDisplay: false\r
-});\r
-</code></pre>\r
- * @param {Object} options (optional) Object literal with any of the Fx config options\r
- * @return {Ext.Element} The Element\r
- */\r
- fadeOut : function(o){\r
- o = getObject(o);\r
- var me = this,\r
- dom = me.dom,\r
- style = dom.style,\r
- to = o.endOpacity || 0; \r
- \r
- me.queueFx(o, function(){ \r
- arguments.callee.anim = fly(dom).fxanim({ \r
- opacity : {to : to}},\r
- o, \r
- NULL, \r
- .5, \r
- EASEOUT, \r
- function(){\r
- if(to == 0){\r
- Ext.Element.data(dom, 'visibilityMode') == Ext.Element.DISPLAY || o.useDisplay ? \r
- style.display = "none" :\r
- style.visibility = HIDDEN;\r
- \r
- fly(dom).clearOpacity();\r
- }\r
- fly(dom).afterFx(o);\r
- });\r
- });\r
- return me;\r
- },\r
-\r
- /**\r
- * Animates the transition of an element's dimensions from a starting height/width\r
- * to an ending height/width. This method is a convenience implementation of {@link shift}.\r
- * Usage:\r
-<pre><code>\r
-// change height and width to 100x100 pixels\r
-el.scale(100, 100);\r
-\r
-// common config options shown with default values. The height and width will default to\r
-// the element's existing values if passed as null.\r
-el.scale(\r
- [element's width],\r
- [element's height], {\r
- easing: 'easeOut',\r
- duration: .35\r
- }\r
-);\r
-</code></pre>\r
- * @param {Number} width The new width (pass undefined to keep the original width)\r
- * @param {Number} height The new height (pass undefined to keep the original height)\r
- * @param {Object} options (optional) Object literal with any of the Fx config options\r
- * @return {Ext.Element} The Element\r
- */\r
- scale : function(w, h, o){\r
- this.shift(Ext.apply({}, o, {\r
- width: w,\r
- height: h\r
- }));\r
- return this;\r
- },\r
-\r
- /**\r
- * Animates the transition of any combination of an element's dimensions, xy position and/or opacity.\r
- * Any of these properties not specified in the config object will not be changed. This effect \r
- * requires that at least one new dimension, position or opacity setting must be passed in on\r
- * the config object in order for the function to have any effect.\r
- * Usage:\r
-<pre><code>\r
-// slide the element horizontally to x position 200 while changing the height and opacity\r
-el.shift({ x: 200, height: 50, opacity: .8 });\r
-\r
-// common config options shown with default values.\r
-el.shift({\r
- width: [element's width],\r
- height: [element's height],\r
- x: [element's x position],\r
- y: [element's y position],\r
- opacity: [element's opacity],\r
- easing: 'easeOut',\r
- duration: .35\r
-});\r
-</code></pre>\r
- * @param {Object} options Object literal with any of the Fx config options\r
- * @return {Ext.Element} The Element\r
- */\r
- shift : function(o){\r
- o = getObject(o);\r
- var dom = this.dom,\r
- a = {};\r
- \r
- this.queueFx(o, function(){\r
- for (var prop in o) {\r
- if (o[prop] != UNDEFINED) { \r
- a[prop] = {to : o[prop]}; \r
- }\r
- } \r
- \r
- a.width ? a.width.to = fly(dom).adjustWidth(o.width) : a;\r
- a.height ? a.height.to = fly(dom).adjustWidth(o.height) : a; \r
- \r
- if (a.x || a.y || a.xy) {\r
- a.points = a.xy || \r
- {to : [ a.x ? a.x.to : fly(dom).getX(),\r
- a.y ? a.y.to : fly(dom).getY()]}; \r
- }\r
-\r
- arguments.callee.anim = fly(dom).fxanim(a,\r
- o, \r
- MOTION, \r
- .35, \r
- EASEOUT, \r
- function(){\r
- fly(dom).afterFx(o);\r
- });\r
- });\r
- return this;\r
- },\r
-\r
- /**\r
- * Slides the element while fading it out of view. An anchor point can be optionally passed to set the \r
- * ending point of the effect.\r
- * Usage:\r
- *<pre><code>\r
-// default: slide the element downward while fading out\r
-el.ghost();\r
-\r
-// custom: slide the element out to the right with a 2-second duration\r
-el.ghost('r', { duration: 2 });\r
-\r
-// common config options shown with default values\r
-el.ghost('b', {\r
- easing: 'easeOut',\r
- duration: .5,\r
- remove: false,\r
- useDisplay: false\r
-});\r
-</code></pre>\r
- * @param {String} anchor (optional) One of the valid Fx anchor positions (defaults to bottom: 'b')\r
- * @param {Object} options (optional) Object literal with any of the Fx config options\r
- * @return {Ext.Element} The Element\r
- */\r
- ghost : function(anchor, o){\r
- o = getObject(o);\r
- var me = this,\r
- dom = me.dom,\r
- st = dom.style,\r
- a = {opacity: {to: 0}, points: {}},\r
- pt = a.points,\r
- r,\r
- w,\r
- h;\r
- \r
- anchor = anchor || "b";\r
-\r
- me.queueFx(o, function(){\r
- // restore values after effect\r
- r = fly(dom).getFxRestore();\r
- w = fly(dom).getWidth();\r
- h = fly(dom).getHeight();\r
- \r
- function after(){\r
- o.useDisplay ? fly(dom).setDisplayed(FALSE) : fly(dom).hide(); \r
- fly(dom).clearOpacity();\r
- fly(dom).setPositioning(r.pos);\r
- st.width = r.width;\r
- st.height = r.height;\r
- fly(dom).afterFx(o);\r
- }\r
- \r
- pt.by = fly(dom).switchStatements(anchor.toLowerCase(), function(v1,v2){ return [v1, v2];}, {\r
- t : [0, -h],\r
- l : [-w, 0],\r
- r : [w, 0],\r
- b : [0, h],\r
- tl : [-w, -h],\r
- bl : [-w, h],\r
- br : [w, h],\r
- tr : [w, -h] \r
- });\r
- \r
- arguments.callee.anim = fly(dom).fxanim(a,\r
- o,\r
- MOTION,\r
- .5,\r
- EASEOUT, after);\r
- });\r
- return me;\r
- },\r
-\r
- /**\r
- * Ensures that all effects queued after syncFx is called on the element are\r
- * run concurrently. This is the opposite of {@link #sequenceFx}.\r
- * @return {Ext.Element} The Element\r
- */\r
- syncFx : function(){\r
- var me = this;\r
- me.fxDefaults = Ext.apply(me.fxDefaults || {}, {\r
- block : FALSE,\r
- concurrent : TRUE,\r
- stopFx : FALSE\r
- });\r
- return me;\r
- },\r
-\r
- /**\r
- * Ensures that all effects queued after sequenceFx is called on the element are\r
- * run in sequence. This is the opposite of {@link #syncFx}.\r
- * @return {Ext.Element} The Element\r
- */\r
- sequenceFx : function(){\r
- var me = this;\r
- me.fxDefaults = Ext.apply(me.fxDefaults || {}, {\r
- block : FALSE,\r
- concurrent : FALSE,\r
- stopFx : FALSE\r
- });\r
- return me;\r
- },\r
-\r
- /* @private */\r
- nextFx : function(){ \r
- var ef = getQueue(this.dom.id)[0];\r
- if(ef){\r
- ef.call(this);\r
- }\r
- },\r
-\r
- /**\r
- * Returns true if the element has any effects actively running or queued, else returns false.\r
- * @return {Boolean} True if element has active effects, else false\r
- */\r
- hasActiveFx : function(){\r
- return getQueue(this.dom.id)[0];\r
- },\r
-\r
- /**\r
- * Stops any running effects and clears the element's internal effects queue if it contains\r
- * any additional effects that haven't started yet.\r
- * @return {Ext.Element} The Element\r
- */\r
- stopFx : function(finish){\r
- var me = this,\r
- id = me.dom.id;\r
- if(me.hasActiveFx()){\r
- var cur = getQueue(id)[0];\r
- if(cur && cur.anim){\r
- if(cur.anim.isAnimated){\r
- setQueue(id, [cur]); //clear\r
- cur.anim.stop(finish !== undefined ? finish : TRUE);\r
- }else{\r
- setQueue(id, []);\r
- }\r
- }\r
- }\r
- return me;\r
- },\r
-\r
- /* @private */\r
- beforeFx : function(o){\r
- if(this.hasActiveFx() && !o.concurrent){\r
- if(o.stopFx){\r
- this.stopFx();\r
- return TRUE;\r
- }\r
- return FALSE;\r
- }\r
- return TRUE;\r
- },\r
-\r
- /**\r
- * Returns true if the element is currently blocking so that no other effect can be queued\r
- * until this effect is finished, else returns false if blocking is not set. This is commonly\r
- * used to ensure that an effect initiated by a user action runs to completion prior to the\r
- * same effect being restarted (e.g., firing only one effect even if the user clicks several times).\r
- * @return {Boolean} True if blocking, else false\r
- */\r
- hasFxBlock : function(){\r
- var q = getQueue(this.dom.id);\r
- return q && q[0] && q[0].block;\r
- },\r
-\r
- /* @private */\r
- queueFx : function(o, fn){\r
- var me = this;\r
- if(!me.hasFxBlock()){\r
- Ext.applyIf(o, me.fxDefaults);\r
- if(!o.concurrent){\r
- var run = me.beforeFx(o);\r
- fn.block = o.block;\r
- getQueue(me.dom.id).push(fn);\r
- if(run){\r
- me.nextFx();\r
- }\r
- }else{\r
- fn.call(me);\r
- }\r
- }\r
- return me;\r
- },\r
-\r
- /* @private */\r
- fxWrap : function(pos, o, vis){ \r
- var dom = this.dom,\r
- wrap,\r
- wrapXY;\r
- if(!o.wrap || !(wrap = Ext.getDom(o.wrap))){ \r
- if(o.fixPosition){\r
- wrapXY = fly(dom).getXY();\r
- }\r
- var div = document.createElement("div");\r
- div.style.visibility = vis;\r
- wrap = dom.parentNode.insertBefore(div, dom);\r
- fly(wrap).setPositioning(pos);\r
- if(fly(wrap).isStyle(POSITION, "static")){\r
- fly(wrap).position("relative");\r
- }\r
- fly(dom).clearPositioning('auto');\r
- fly(wrap).clip();\r
- wrap.appendChild(dom);\r
- if(wrapXY){\r
- fly(wrap).setXY(wrapXY);\r
- }\r
- }\r
- return wrap;\r
- },\r
-\r
- /* @private */\r
- fxUnwrap : function(wrap, pos, o){ \r
- var dom = this.dom;\r
- fly(dom).clearPositioning();\r
- fly(dom).setPositioning(pos);\r
- if(!o.wrap){\r
- wrap.parentNode.insertBefore(dom, wrap);\r
- fly(wrap).remove();\r
- }\r
- },\r
-\r
- /* @private */\r
- getFxRestore : function(){\r
- var st = this.dom.style;\r
- return {pos: this.getPositioning(), width: st.width, height : st.height};\r
- },\r
-\r
- /* @private */\r
- afterFx : function(o){\r
- var dom = this.dom,\r
- id = dom.id,\r
- notConcurrent = !o.concurrent;\r
- if(o.afterStyle){\r
- fly(dom).setStyle(o.afterStyle); \r
- }\r
- if(o.afterCls){\r
- fly(dom).addClass(o.afterCls);\r
- }\r
- if(o.remove == TRUE){\r
- fly(dom).remove();\r
- }\r
- if(notConcurrent){\r
- getQueue(id).shift();\r
- }\r
- if(o.callback){\r
- o.callback.call(o.scope, fly(dom));\r
- }\r
- if(notConcurrent){\r
- fly(dom).nextFx();\r
- }\r
- },\r
-\r
- /* @private */\r
- fxanim : function(args, opt, animType, defaultDur, defaultEase, cb){\r
- animType = animType || 'run';\r
- opt = opt || {};\r
- var anim = Ext.lib.Anim[animType](\r
- this.dom, \r
- args,\r
- (opt.duration || defaultDur) || .35,\r
- (opt.easing || defaultEase) || EASEOUT,\r
- cb, \r
- this\r
- );\r
- opt.anim = anim;\r
- return anim;\r
- }\r
-};\r
-\r
-// backwards compat\r
-Ext.Fx.resize = Ext.Fx.scale;\r
-\r
-//When included, Ext.Fx is automatically applied to Element so that all basic\r
-//effects are available directly via the Element API\r
-Ext.Element.addMethods(Ext.Fx);\r
-})();/**\r
- * @class Ext.CompositeElementLite\r
- * Flyweight composite class. Reuses the same Ext.Element for element operations.\r
- <pre><code>\r
- var els = Ext.select("#some-el div.some-class");\r
- // or select directly from an existing element\r
- var el = Ext.get('some-el');\r
- el.select('div.some-class');\r
-\r
- els.setWidth(100); // all elements become 100 width\r
- els.hide(true); // all elements fade out and hide\r
- // or\r
- els.setWidth(100).hide(true);\r
- </code></pre><br><br>\r
- * <b>NOTE: Although they are not listed, this class supports all of the set/update methods of Ext.Element. All Ext.Element\r
- * actions will be performed on all the elements in this collection.</b>\r
- */\r
-Ext.CompositeElementLite = function(els, root){\r
- this.elements = [];\r
- this.add(els, root);\r
- this.el = new Ext.Element.Flyweight();\r
-};\r
-\r
-Ext.CompositeElementLite.prototype = {\r
- isComposite: true, \r
- /**\r
- * Returns the number of elements in this composite\r
- * @return Number\r
- */\r
- getCount : function(){\r
- return this.elements.length;\r
- }, \r
- add : function(els){\r
- if(els){\r
- if (Ext.isArray(els)) {\r
- this.elements = this.elements.concat(els);\r
- } else {\r
- var yels = this.elements; \r
- Ext.each(els, function(e) {\r
- yels.push(e);\r
- });\r
- }\r
- }\r
- return this;\r
- },\r
- invoke : function(fn, args){\r
- var els = this.elements,\r
- el = this.el; \r
- Ext.each(els, function(e) { \r
- el.dom = e;\r
- Ext.Element.prototype[fn].apply(el, args);\r
- });\r
- return this;\r
- },\r
- /**\r
- * Returns a flyweight Element of the dom element object at the specified index\r
- * @param {Number} index\r
- * @return {Ext.Element}\r
- */\r
- item : function(index){\r
- var me = this;\r
- if(!me.elements[index]){\r
- return null;\r
- }\r
- me.el.dom = me.elements[index];\r
- return me.el;\r
- },\r
-\r
- // fixes scope with flyweight\r
- addListener : function(eventName, handler, scope, opt){\r
- Ext.each(this.elements, function(e) {\r
- Ext.EventManager.on(e, eventName, handler, scope || e, opt);\r
- });\r
- return this;\r
- },\r
- /**\r
- * Calls the passed function passing (el, this, index) for each element in this composite. <b>The element\r
- * passed is the flyweight (shared) Ext.Element instance, so if you require a\r
- * a reference to the dom node, use el.dom.</b>\r
- * @param {Function} fn The function to call\r
- * @param {Object} scope (optional) The <i>this</i> object (defaults to the element)\r
- * @return {CompositeElement} this\r
- */\r
- each : function(fn, scope){ \r
- var me = this,\r
- el = me.el;\r
- \r
- Ext.each(me.elements, function(e,i) { \r
- el.dom = e;\r
- return fn.call(scope || el, el, me, i);\r
- });\r
- return me;\r
- },\r
- \r
- /**\r
- * Find the index of the passed element within the composite collection.\r
- * @param el {Mixed} The id of an element, or an Ext.Element, or an HtmlElement to find within the composite collection.\r
- * @return Number The index of the passed Ext.Element in the composite collection, or -1 if not found.\r
- */\r
- indexOf : function(el){\r
- return this.elements.indexOf(Ext.getDom(el));\r
- },\r
- \r
- /**\r
- * Replaces the specified element with the passed element.\r
- * @param {Mixed} el The id of an element, the Element itself, the index of the element in this composite\r
- * to replace.\r
- * @param {Mixed} replacement The id of an element or the Element itself.\r
- * @param {Boolean} domReplace (Optional) True to remove and replace the element in the document too.\r
- * @return {CompositeElement} this\r
- */ \r
- replaceElement : function(el, replacement, domReplace){\r
- var index = !isNaN(el) ? el : this.indexOf(el),\r
- d;\r
- if(index > -1){\r
- replacement = Ext.getDom(replacement);\r
- if(domReplace){\r
- d = this.elements[index];\r
- d.parentNode.insertBefore(replacement, d);\r
- Ext.removeNode(d);\r
- }\r
- this.elements.splice(index, 1, replacement);\r
- }\r
- return this;\r
- },\r
- \r
- /**\r
- * Removes all elements.\r
- */\r
- clear : function(){\r
- this.elements = [];\r
- }\r
-};\r
-\r
-Ext.CompositeElementLite.prototype.on = Ext.CompositeElementLite.prototype.addListener;\r
-\r
-(function(){\r
-var fnName,\r
- ElProto = Ext.Element.prototype,\r
- CelProto = Ext.CompositeElementLite.prototype;\r
- \r
-for(fnName in ElProto){\r
- if(Ext.isFunction(ElProto[fnName])){\r
- (function(fnName){ \r
- CelProto[fnName] = CelProto[fnName] || function(){\r
- return this.invoke(fnName, arguments);\r
- };\r
- }).call(CelProto, fnName);\r
- \r
- }\r
-}\r
-})();\r
-\r
-if(Ext.DomQuery){\r
- Ext.Element.selectorFunction = Ext.DomQuery.select;\r
-} \r
-\r
-/**\r
- * Selects elements based on the passed CSS selector to enable {@link Ext.Element Element} methods\r
- * to be applied to many related elements in one statement through the returned {@link Ext.CompositeElement CompositeElement} or\r
- * {@link Ext.CompositeElementLite CompositeElementLite} object.\r
- * @param {String/Array} selector The CSS selector or an array of elements\r
- * @param {Boolean} unique (optional) true to create a unique Ext.Element for each element (defaults to a shared flyweight object) <b>Not supported in core</b>\r
- * @param {HTMLElement/String} root (optional) The root element of the query or id of the root\r
- * @return {CompositeElementLite/CompositeElement}\r
- * @member Ext.Element\r
- * @method select\r
- */\r
-Ext.Element.select = function(selector, unique, root){\r
- var els;\r
- if(typeof selector == "string"){\r
- els = Ext.Element.selectorFunction(selector, root);\r
- }else if(selector.length !== undefined){\r
- els = selector;\r
- }else{\r
- throw "Invalid selector";\r
- }\r
- return new Ext.CompositeElementLite(els);\r
-};\r
-/**\r
- * Selects elements based on the passed CSS selector to enable {@link Ext.Element Element} methods\r
- * to be applied to many related elements in one statement through the returned {@link Ext.CompositeElement CompositeElement} or\r
- * {@link Ext.CompositeElementLite CompositeElementLite} object.\r
- * @param {String/Array} selector The CSS selector or an array of elements\r
- * @param {Boolean} unique (optional) true to create a unique Ext.Element for each element (defaults to a shared flyweight object)\r
- * @param {HTMLElement/String} root (optional) The root element of the query or id of the root\r
- * @return {CompositeElementLite/CompositeElement}\r
- * @member Ext\r
- * @method select\r
- */\r
-Ext.select = Ext.Element.select;/**\r
- * @class Ext.CompositeElementLite\r
- */\r
-Ext.apply(Ext.CompositeElementLite.prototype, { \r
- addElements : function(els, root){\r
- if(!els){\r
- return this;\r
- }\r
- if(typeof els == "string"){\r
- els = Ext.Element.selectorFunction(els, root);\r
- }\r
- var yels = this.elements; \r
- Ext.each(els, function(e) {\r
- yels.push(Ext.get(e));\r
- });\r
- return this;\r
- },\r
- \r
- /**\r
- * Clears this composite and adds the elements returned by the passed selector.\r
- * @param {String/Array} els A string CSS selector, an array of elements or an element\r
- * @return {CompositeElement} this\r
- */\r
- fill : function(els){\r
- this.elements = [];\r
- this.add(els);\r
- return this;\r
- },\r
- \r
- /**\r
- * Returns the first Element\r
- * @return {Ext.Element}\r
- */\r
- first : function(){\r
- return this.item(0);\r
- }, \r
- \r
- /**\r
- * Returns the last Element\r
- * @return {Ext.Element}\r
- */\r
- last : function(){\r
- return this.item(this.getCount()-1);\r
- },\r
- \r
- /**\r
- * Returns true if this composite contains the passed element\r
- * @param el {Mixed} The id of an element, or an Ext.Element, or an HtmlElement to find within the composite collection.\r
- * @return Boolean\r
- */\r
- contains : function(el){\r
- return this.indexOf(el) != -1;\r
- },\r
-\r
- /**\r
- * Filters this composite to only elements that match the passed selector.\r
- * @param {String} selector A string CSS selector\r
- * @return {CompositeElement} this\r
- */\r
- filter : function(selector){\r
- var els = [];\r
- this.each(function(el){\r
- if(el.is(selector)){\r
- els[els.length] = el.dom;\r
- }\r
- });\r
- this.fill(els);\r
- return this;\r
- },
-
- /**\r
- * Removes the specified element(s).\r
- * @param {Mixed} el The id of an element, the Element itself, the index of the element in this composite\r
- * or an array of any of those.\r
- * @param {Boolean} removeDom (optional) True to also remove the element from the document\r
- * @return {CompositeElement} this\r
- */\r
- removeElement : function(keys, removeDom){\r
- var me = this,\r
- els = this.elements, \r
- el; \r
- Ext.each(keys, function(val){\r
- if ((el = (els[val] || els[val = me.indexOf(val)]))) {\r
- if(removeDom){\r
- if(el.dom){\r
- el.remove();\r
- }else{\r
- Ext.removeNode(el);\r
- }\r
- }\r
- els.splice(val, 1); \r
- }\r
- });\r
- return this;\r
- } \r
-});
-/**\r
- * @class Ext.CompositeElement\r
- * @extends Ext.CompositeElementLite\r
- * Standard composite class. Creates a Ext.Element for every element in the collection.\r
- * <br><br>\r
- * <b>NOTE: Although they are not listed, this class supports all of the set/update methods of Ext.Element. All Ext.Element\r
- * actions will be performed on all the elements in this collection.</b>\r
- * <br><br>\r
- * All methods return <i>this</i> and can be chained.\r
- <pre><code>\r
- var els = Ext.select("#some-el div.some-class", true);\r
- // or select directly from an existing element\r
- var el = Ext.get('some-el');\r
- el.select('div.some-class', true);\r
-\r
- els.setWidth(100); // all elements become 100 width\r
- els.hide(true); // all elements fade out and hide\r
- // or\r
- els.setWidth(100).hide(true);\r
- </code></pre>\r
- */\r
-Ext.CompositeElement = function(els, root){\r
- this.elements = [];\r
- this.add(els, root);\r
-};\r
-\r
-Ext.extend(Ext.CompositeElement, Ext.CompositeElementLite, {\r
- invoke : function(fn, args){\r
- Ext.each(this.elements, function(e) {\r
- Ext.Element.prototype[fn].apply(e, args);\r
- });\r
- return this;\r
- },\r
- \r
- /**\r
- * Adds elements to this composite.\r
- * @param {String/Array} els A string CSS selector, an array of elements or an element\r
- * @return {CompositeElement} this\r
- */\r
- add : function(els, root){\r
- if(!els){\r
- return this;\r
- }\r
- if(typeof els == "string"){\r
- els = Ext.Element.selectorFunction(els, root);\r
- }\r
- var yels = this.elements; \r
- Ext.each(els, function(e) {\r
- yels.push(Ext.get(e));\r
- });\r
- return this;\r
- }, \r
- \r
- /**\r
- * Returns the Element object at the specified index\r
- * @param {Number} index\r
- * @return {Ext.Element}\r
- */\r
- item : function(index){\r
- return this.elements[index] || null;\r
- },\r
-\r
-\r
- indexOf : function(el){\r
- return this.elements.indexOf(Ext.get(el));\r
- },\r
- \r
- filter : function(selector){\r
- var me = this,\r
- out = [];\r
- \r
- Ext.each(me.elements, function(el) { \r
- if(el.is(selector)){\r
- out.push(Ext.get(el));\r
- }\r
- });\r
- me.elements = out;\r
- return me;\r
- },\r
- \r
- /**\r
- * Calls the passed function passing (el, this, index) for each element in this composite.\r
- * @param {Function} fn The function to call\r
- * @param {Object} scope (optional) The <i>this</i> object (defaults to the element)\r
- * @return {CompositeElement} this\r
- */\r
- each : function(fn, scope){ \r
- Ext.each(this.elements, function(e,i) {\r
- return fn.call(scope || e, e, this, i);\r
- }, this);\r
- return this;\r
- }\r
-});\r
-\r
-/**\r
- * Selects elements based on the passed CSS selector to enable {@link Ext.Element Element} methods\r
- * to be applied to many related elements in one statement through the returned {@link Ext.CompositeElement CompositeElement} or\r
- * {@link Ext.CompositeElementLite CompositeElementLite} object.\r
- * @param {String/Array} selector The CSS selector or an array of elements\r
- * @param {Boolean} unique (optional) true to create a unique Ext.Element for each element (defaults to a shared flyweight object)\r
- * @param {HTMLElement/String} root (optional) The root element of the query or id of the root\r
- * @return {CompositeElementLite/CompositeElement}\r
- * @member Ext.Element\r
- * @method select\r
- */\r
-Ext.Element.select = function(selector, unique, root){\r
- var els;\r
- if(typeof selector == "string"){\r
- els = Ext.Element.selectorFunction(selector, root);\r
- }else if(selector.length !== undefined){\r
- els = selector;\r
- }else{\r
- throw "Invalid selector";\r
- }\r
-\r
- return (unique === true) ? new Ext.CompositeElement(els) : new Ext.CompositeElementLite(els);\r
-};
-\r
-/**\r
- * Selects elements based on the passed CSS selector to enable {@link Ext.Element Element} methods\r
- * to be applied to many related elements in one statement through the returned {@link Ext.CompositeElement CompositeElement} or\r
- * {@link Ext.CompositeElementLite CompositeElementLite} object.\r
- * @param {String/Array} selector The CSS selector or an array of elements\r
- * @param {Boolean} unique (optional) true to create a unique Ext.Element for each element (defaults to a shared flyweight object)\r
- * @param {HTMLElement/String} root (optional) The root element of the query or id of the root\r
- * @return {CompositeElementLite/CompositeElement}\r
- * @member Ext.Element\r
- * @method select\r
- */\r
-Ext.select = Ext.Element.select;(function(){\r
- var BEFOREREQUEST = "beforerequest",\r
- REQUESTCOMPLETE = "requestcomplete",\r
- REQUESTEXCEPTION = "requestexception",\r
- UNDEFINED = undefined,\r
- LOAD = 'load',\r
- POST = 'POST',\r
- GET = 'GET',\r
- WINDOW = window;\r
- \r
- /**\r
- * @class Ext.data.Connection\r
- * @extends Ext.util.Observable\r
- * <p>The class encapsulates a connection to the page's originating domain, allowing requests to be made\r
- * either to a configured URL, or to a URL specified at request time.</p>\r
- * <p>Requests made by this class are asynchronous, and will return immediately. No data from\r
- * the server will be available to the statement immediately following the {@link #request} call.\r
- * To process returned data, use a\r
- * <a href="#request-option-success" ext:member="request-option-success" ext:cls="Ext.data.Connection">success callback</a>\r
- * in the request options object,\r
- * or an {@link #requestcomplete event listener}.</p>\r
- * <p><h3>File Uploads</h3><a href="#request-option-isUpload" ext:member="request-option-isUpload" ext:cls="Ext.data.Connection">File uploads</a> are not performed using normal "Ajax" techniques, that\r
- * is they are <b>not</b> performed using XMLHttpRequests. Instead the form is submitted in the standard\r
- * manner with the DOM <tt><form></tt> element temporarily modified to have its\r
- * <a href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-target">target</a> set to refer\r
- * to a dynamically generated, hidden <tt><iframe></tt> which is inserted into the document\r
- * but removed after the return data has been gathered.</p>\r
- * <p>The server response is parsed by the browser to create the document for the IFRAME. If the\r
- * server is using JSON to send the return object, then the\r
- * <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17">Content-Type</a> header\r
- * must be set to "text/html" in order to tell the browser to insert the text unchanged into the document body.</p>\r
- * <p>Characters which are significant to an HTML parser must be sent as HTML entities, so encode\r
- * "<" as "&lt;", "&" as "&amp;" etc.</p>\r
- * <p>The response text is retrieved from the document, and a fake XMLHttpRequest object\r
- * is created containing a <tt>responseText</tt> property in order to conform to the\r
- * requirements of event handlers and callbacks.</p>\r
- * <p>Be aware that file upload packets are sent with the content type <a href="http://www.faqs.org/rfcs/rfc2388.html">multipart/form</a>\r
- * and some server technologies (notably JEE) may require some custom processing in order to\r
- * retrieve parameter names and parameter values from the packet content.</p>\r
- * @constructor\r
- * @param {Object} config a configuration object.\r
- */\r
- Ext.data.Connection = function(config){ \r
- Ext.apply(this, config);\r
- this.addEvents(\r
- /**\r
- * @event beforerequest\r
- * Fires before a network request is made to retrieve a data object.\r
- * @param {Connection} conn This Connection object.\r
- * @param {Object} options The options config object passed to the {@link #request} method.\r
- */\r
- BEFOREREQUEST,\r
- /**\r
- * @event requestcomplete\r
- * Fires if the request was successfully completed.\r
- * @param {Connection} conn This Connection object.\r
- * @param {Object} response The XHR object containing the response data.\r
- * See <a href="http://www.w3.org/TR/XMLHttpRequest/">The XMLHttpRequest Object</a>\r
- * for details.\r
- * @param {Object} options The options config object passed to the {@link #request} method.\r
- */\r
- REQUESTCOMPLETE,\r
- /**\r
- * @event requestexception\r
- * Fires if an error HTTP status was returned from the server.\r
- * See <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html">HTTP Status Code Definitions</a>\r
- * for details of HTTP status codes.\r
- * @param {Connection} conn This Connection object.\r
- * @param {Object} response The XHR object containing the response data.\r
- * See <a href="http://www.w3.org/TR/XMLHttpRequest/">The XMLHttpRequest Object</a>\r
- * for details.\r
- * @param {Object} options The options config object passed to the {@link #request} method.\r
- */\r
- REQUESTEXCEPTION\r
- );\r
- Ext.data.Connection.superclass.constructor.call(this);\r
- };\r
-\r
- // private\r
- function handleResponse(response){\r
- this.transId = false;\r
- var options = response.argument.options;\r
- response.argument = options ? options.argument : null;\r
- this.fireEvent(REQUESTCOMPLETE, this, response, options);\r
- if(options.success){\r
- options.success.call(options.scope, response, options);\r
- }\r
- if(options.callback){\r
- options.callback.call(options.scope, options, true, response);\r
- }\r
- }\r
-\r
- // private\r
- function handleFailure(response, e){\r
- this.transId = false;\r
- var options = response.argument.options;\r
- response.argument = options ? options.argument : null;\r
- this.fireEvent(REQUESTEXCEPTION, this, response, options, e);\r
- if(options.failure){\r
- options.failure.call(options.scope, response, options);\r
- }\r
- if(options.callback){\r
- options.callback.call(options.scope, options, false, response);\r
- }\r
- }\r
-\r
- // private\r
- function doFormUpload(o, ps, url){\r
- var id = Ext.id(),\r
- doc = document,\r
- frame = doc.createElement('iframe'),\r
- form = Ext.getDom(o.form),\r
- hiddens = [],\r
- hd,\r
- encoding = 'multipart/form-data',\r
- buf = {\r
- target: form.target,\r
- method: form.method,\r
- encoding: form.encoding,\r
- enctype: form.enctype,\r
- action: form.action\r
- };\r
- \r
- Ext.apply(frame, {\r
- id: id,\r
- name: id,\r
- className: 'x-hidden',\r
- src: Ext.SSL_SECURE_URL // for IE\r
- }); \r
- doc.body.appendChild(frame);\r
- \r
- // This is required so that IE doesn't pop the response up in a new window.\r
- if(Ext.isIE){\r
- document.frames[id].name = id;\r
- }\r
- \r
- Ext.apply(form, {\r
- target: id,\r
- method: POST,\r
- enctype: encoding,\r
- encoding: encoding,\r
- action: url || buf.action\r
- });\r
- \r
- // add dynamic params \r
- ps = Ext.urlDecode(ps, false);\r
- for(var k in ps){\r
- if(ps.hasOwnProperty(k)){\r
- hd = doc.createElement('input');\r
- hd.type = 'hidden'; \r
- hd.value = ps[hd.name = k];\r
- form.appendChild(hd);\r
- hiddens.push(hd);\r
- }\r
- } \r
-\r
- function cb(){\r
- var me = this,\r
- // bogus response object\r
- r = {responseText : '',\r
- responseXML : null,\r
- argument : o.argument},\r
- doc,\r
- firstChild;\r
-\r
- try{ \r
- doc = frame.contentWindow.document || frame.contentDocument || WINDOW.frames[id].document;\r
- if(doc){\r
- if(doc.body){\r
- if(/textarea/i.test((firstChild = doc.body.firstChild || {}).tagName)){ // json response wrapped in textarea \r
- r.responseText = firstChild.value;\r
- }else{\r
- r.responseText = doc.body.innerHTML;\r
- }\r
- }\r
- //in IE the document may still have a body even if returns XML.\r
- r.responseXML = doc.XMLDocument || doc;\r
- }\r
- }\r
- catch(e) {}\r
-\r
- Ext.EventManager.removeListener(frame, LOAD, cb, me);\r
-\r
- me.fireEvent(REQUESTCOMPLETE, me, r, o);\r
- \r
- function runCallback(fn, scope, args){\r
- if(Ext.isFunction(fn)){\r
- fn.apply(scope, args);\r
- }\r
- }\r
-\r
- runCallback(o.success, o.scope, [r, o]);\r
- runCallback(o.callback, o.scope, [o, true, r]);\r
-\r
- if(!me.debugUploads){\r
- setTimeout(function(){Ext.removeNode(frame);}, 100);\r
- }\r
- }\r
-\r
- Ext.EventManager.on(frame, LOAD, cb, this);\r
- form.submit();\r
- \r
- Ext.apply(form, buf);\r
- Ext.each(hiddens, function(h) {\r
- Ext.removeNode(h);\r
- });\r
- }\r
-\r
- Ext.extend(Ext.data.Connection, Ext.util.Observable, {\r
- /**\r
- * @cfg {String} url (Optional) <p>The default URL to be used for requests to the server. Defaults to undefined.</p>\r
- * <p>The <code>url</code> config may be a function which <i>returns</i> the URL to use for the Ajax request. The scope\r
- * (<code><b>this</b></code> reference) of the function is the <code>scope</code> option passed to the {@link #request} method.</p>\r
- */\r
- /**\r
- * @cfg {Object} extraParams (Optional) An object containing properties which are used as\r
- * extra parameters to each request made by this object. (defaults to undefined)\r
- */\r
- /**\r
- * @cfg {Object} defaultHeaders (Optional) An object containing request headers which are added\r
- * to each request made by this object. (defaults to undefined)\r
- */\r
- /**\r
- * @cfg {String} method (Optional) The default HTTP method to be used for requests.\r
- * (defaults to undefined; if not set, but {@link #request} params are present, POST will be used;\r
- * otherwise, GET will be used.)\r
- */\r
- /**\r
- * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000)\r
- */\r
- timeout : 30000,\r
- /**\r
- * @cfg {Boolean} autoAbort (Optional) Whether this request should abort any pending requests. (defaults to false)\r
- * @type Boolean\r
- */\r
- autoAbort:false,\r
- \r
- /**\r
- * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true)\r
- * @type Boolean\r
- */\r
- disableCaching: true,\r
- \r
- /**\r
- * @cfg {String} disableCachingParam (Optional) Change the parameter which is sent went disabling caching\r
- * through a cache buster. Defaults to '_dc'\r
- * @type String\r
- */\r
- disableCachingParam: '_dc',\r
- \r
- /**\r
- * <p>Sends an HTTP request to a remote server.</p>\r
- * <p><b>Important:</b> Ajax server requests are asynchronous, and this call will\r
- * return before the response has been received. Process any returned data\r
- * in a callback function.</p>\r
- * <pre><code>\r
-Ext.Ajax.request({\r
- url: 'ajax_demo/sample.json',\r
- success: function(response, opts) {\r
- var obj = Ext.decode(response.responseText);\r
- console.dir(obj);\r
- },\r
- failure: function(response, opts) {\r
- console.log('server-side failure with status code ' + response.status);\r
- }\r
-});\r
- * </code></pre>\r
- * <p>To execute a callback function in the correct scope, use the <tt>scope</tt> option.</p>\r
- * @param {Object} options An object which may contain the following properties:<ul>\r
- * <li><b>url</b> : String/Function (Optional)<div class="sub-desc">The URL to\r
- * which to send the request, or a function to call which returns a URL string. The scope of the\r
- * function is specified by the <tt>scope</tt> option. Defaults to the configured\r
- * <tt>{@link #url}</tt>.</div></li>\r
- * <li><b>params</b> : Object/String/Function (Optional)<div class="sub-desc">\r
- * An object containing properties which are used as parameters to the\r
- * request, a url encoded string or a function to call to get either. The scope of the function\r
- * is specified by the <tt>scope</tt> option.</div></li>\r
- * <li><b>method</b> : String (Optional)<div class="sub-desc">The HTTP method to use\r
- * for the request. Defaults to the configured method, or if no method was configured,\r
- * "GET" if no parameters are being sent, and "POST" if parameters are being sent. Note that\r
- * the method name is case-sensitive and should be all caps.</div></li>\r
- * <li><b>callback</b> : Function (Optional)<div class="sub-desc">The\r
- * function to be called upon receipt of the HTTP response. The callback is\r
- * called regardless of success or failure and is passed the following\r
- * parameters:<ul>\r
- * <li><b>options</b> : Object<div class="sub-desc">The parameter to the request call.</div></li>\r
- * <li><b>success</b> : Boolean<div class="sub-desc">True if the request succeeded.</div></li>\r
- * <li><b>response</b> : Object<div class="sub-desc">The XMLHttpRequest object containing the response data. \r
- * See <a href="http://www.w3.org/TR/XMLHttpRequest/">http://www.w3.org/TR/XMLHttpRequest/</a> for details about \r
- * accessing elements of the response.</div></li>\r
- * </ul></div></li>\r
- * <li><a id="request-option-success"></a><b>success</b> : Function (Optional)<div class="sub-desc">The function\r
- * to be called upon success of the request. The callback is passed the following\r
- * parameters:<ul>\r
- * <li><b>response</b> : Object<div class="sub-desc">The XMLHttpRequest object containing the response data.</div></li>\r
- * <li><b>options</b> : Object<div class="sub-desc">The parameter to the request call.</div></li>\r
- * </ul></div></li>\r
- * <li><b>failure</b> : Function (Optional)<div class="sub-desc">The function\r
- * to be called upon failure of the request. The callback is passed the\r
- * following parameters:<ul>\r
- * <li><b>response</b> : Object<div class="sub-desc">The XMLHttpRequest object containing the response data.</div></li>\r
- * <li><b>options</b> : Object<div class="sub-desc">The parameter to the request call.</div></li>\r
- * </ul></div></li>\r
- * <li><b>scope</b> : Object (Optional)<div class="sub-desc">The scope in\r
- * which to execute the callbacks: The "this" object for the callback function. If the <tt>url</tt>, or <tt>params</tt> options were\r
- * specified as functions from which to draw values, then this also serves as the scope for those function calls.\r
- * Defaults to the browser window.</div></li>\r
- * <li><b>timeout</b> : Number (Optional)<div class="sub-desc">The timeout in milliseconds to be used for this request. Defaults to 30 seconds.</div></li>\r
- * <li><b>form</b> : Element/HTMLElement/String (Optional)<div class="sub-desc">The <tt><form></tt>\r
- * Element or the id of the <tt><form></tt> to pull parameters from.</div></li>\r
- * <li><a id="request-option-isUpload"></a><b>isUpload</b> : Boolean (Optional)<div class="sub-desc"><b>Only meaningful when used \r
- * with the <tt>form</tt> option</b>.\r
- * <p>True if the form object is a file upload (will be set automatically if the form was\r
- * configured with <b><tt>enctype</tt></b> "multipart/form-data").</p>\r
- * <p>File uploads are not performed using normal "Ajax" techniques, that is they are <b>not</b>\r
- * performed using XMLHttpRequests. Instead the form is submitted in the standard manner with the\r
- * DOM <tt><form></tt> element temporarily modified to have its\r
- * <a href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-target">target</a> set to refer\r
- * to a dynamically generated, hidden <tt><iframe></tt> which is inserted into the document\r
- * but removed after the return data has been gathered.</p>\r
- * <p>The server response is parsed by the browser to create the document for the IFRAME. If the\r
- * server is using JSON to send the return object, then the\r
- * <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17">Content-Type</a> header\r
- * must be set to "text/html" in order to tell the browser to insert the text unchanged into the document body.</p>\r
- * <p>The response text is retrieved from the document, and a fake XMLHttpRequest object\r
- * is created containing a <tt>responseText</tt> property in order to conform to the\r
- * requirements of event handlers and callbacks.</p>\r
- * <p>Be aware that file upload packets are sent with the content type <a href="http://www.faqs.org/rfcs/rfc2388.html">multipart/form</a>\r
- * and some server technologies (notably JEE) may require some custom processing in order to\r
- * retrieve parameter names and parameter values from the packet content.</p>\r
- * </div></li>\r
- * <li><b>headers</b> : Object (Optional)<div class="sub-desc">Request\r
- * headers to set for the request.</div></li>\r
- * <li><b>xmlData</b> : Object (Optional)<div class="sub-desc">XML document\r
- * to use for the post. Note: This will be used instead of params for the post\r
- * data. Any params will be appended to the URL.</div></li>\r
- * <li><b>jsonData</b> : Object/String (Optional)<div class="sub-desc">JSON\r
- * data to use as the post. Note: This will be used instead of params for the post\r
- * data. Any params will be appended to the URL.</div></li>\r
- * <li><b>disableCaching</b> : Boolean (Optional)<div class="sub-desc">True\r
- * to add a unique cache-buster param to GET requests.</div></li>\r
- * </ul></p>\r
- * <p>The options object may also contain any other property which might be needed to perform\r
- * postprocessing in a callback because it is passed to callback functions.</p>\r
- * @return {Number} transactionId The id of the server transaction. This may be used\r
- * to cancel the request.\r
- */\r
- request : function(o){\r
- var me = this;\r
- if(me.fireEvent(BEFOREREQUEST, me, o)){\r
- if (o.el) {\r
- if(!Ext.isEmpty(o.indicatorText)){\r
- me.indicatorText = '<div class="loading-indicator">'+o.indicatorText+"</div>";\r
- }\r
- if(me.indicatorText) {\r
- Ext.getDom(o.el).innerHTML = me.indicatorText; \r
- }\r
- o.success = (Ext.isFunction(o.success) ? o.success : function(){}).createInterceptor(function(response) {\r
- Ext.getDom(o.el).innerHTML = response.responseText;\r
- });\r
- }\r
- \r
- var p = o.params,\r
- url = o.url || me.url, \r
- method,\r
- cb = {success: handleResponse,\r
- failure: handleFailure,\r
- scope: me,\r
- argument: {options: o},\r
- timeout : o.timeout || me.timeout\r
- },\r
- form, \r
- serForm; \r
- \r
- \r
- if (Ext.isFunction(p)) {\r
- p = p.call(o.scope||WINDOW, o);\r
- }\r
- \r
- p = Ext.urlEncode(me.extraParams, Ext.isObject(p) ? Ext.urlEncode(p) : p); \r
- \r
- if (Ext.isFunction(url)) {\r
- url = url.call(o.scope || WINDOW, o);\r
- }\r
- \r
- if((form = Ext.getDom(o.form))){\r
- url = url || form.action;\r
- if(o.isUpload || /multipart\/form-data/i.test(form.getAttribute("enctype"))) { \r
- return doFormUpload.call(me, o, p, url);\r
- }\r
- serForm = Ext.lib.Ajax.serializeForm(form); \r
- p = p ? (p + '&' + serForm) : serForm;\r
- }\r
- \r
- method = o.method || me.method || ((p || o.xmlData || o.jsonData) ? POST : GET);\r
- \r
- if(method === GET && (me.disableCaching && o.disableCaching !== false) || o.disableCaching === true){\r
- var dcp = o.disableCachingParam || me.disableCachingParam;\r
- url = Ext.urlAppend(url, dcp + '=' + (new Date().getTime()));\r
- }\r
- \r
- o.headers = Ext.apply(o.headers || {}, me.defaultHeaders || {});\r
- \r
- if(o.autoAbort === true || me.autoAbort) {\r
- me.abort();\r
- }\r
- \r
- if((method == GET || o.xmlData || o.jsonData) && p){\r
- url = Ext.urlAppend(url, p); \r
- p = '';\r
- }\r
- return (me.transId = Ext.lib.Ajax.request(method, url, cb, p, o));\r
- }else{ \r
- return o.callback ? o.callback.apply(o.scope, [o,UNDEFINED,UNDEFINED]) : null;\r
- }\r
- },\r
- \r
- /**\r
- * Determine whether this object has a request outstanding.\r
- * @param {Number} transactionId (Optional) defaults to the last transaction\r
- * @return {Boolean} True if there is an outstanding request.\r
- */\r
- isLoading : function(transId){\r
- return transId ? Ext.lib.Ajax.isCallInProgress(transId) : !! this.transId; \r
- },\r
- \r
- /**\r
- * Aborts any outstanding request.\r
- * @param {Number} transactionId (Optional) defaults to the last transaction\r
- */\r
- abort : function(transId){\r
- if(transId || this.isLoading()){\r
- Ext.lib.Ajax.abort(transId || this.transId);\r
- }\r
- }\r
- });\r
-})();\r
-\r
-/**\r
- * @class Ext.Ajax\r
- * @extends Ext.data.Connection\r
- * <p>The global Ajax request class that provides a simple way to make Ajax requests\r
- * with maximum flexibility.</p>\r
- * <p>Since Ext.Ajax is a singleton, you can set common properties/events for it once\r
- * and override them at the request function level only if necessary.</p>\r
- * <p>Common <b>Properties</b> you may want to set are:<div class="mdetail-params"><ul>\r
- * <li><b><tt>{@link #method}</tt></b><p class="sub-desc"></p></li>\r
- * <li><b><tt>{@link #extraParams}</tt></b><p class="sub-desc"></p></li>\r
- * <li><b><tt>{@link #url}</tt></b><p class="sub-desc"></p></li>\r
- * </ul></div>\r
- * <pre><code>\r
-// Default headers to pass in every request\r
-Ext.Ajax.defaultHeaders = {\r
- 'Powered-By': 'Ext'\r
-};\r
- * </code></pre> \r
- * </p>\r
- * <p>Common <b>Events</b> you may want to set are:<div class="mdetail-params"><ul>\r
- * <li><b><tt>{@link Ext.data.Connection#beforerequest beforerequest}</tt></b><p class="sub-desc"></p></li>\r
- * <li><b><tt>{@link Ext.data.Connection#requestcomplete requestcomplete}</tt></b><p class="sub-desc"></p></li>\r
- * <li><b><tt>{@link Ext.data.Connection#requestexception requestexception}</tt></b><p class="sub-desc"></p></li>\r
- * </ul></div>\r
- * <pre><code>\r
-// Example: show a spinner during all Ajax requests\r
-Ext.Ajax.on('beforerequest', this.showSpinner, this);\r
-Ext.Ajax.on('requestcomplete', this.hideSpinner, this);\r
-Ext.Ajax.on('requestexception', this.hideSpinner, this);\r
- * </code></pre> \r
- * </p>\r
- * <p>An example request:</p>\r
- * <pre><code>\r
-// Basic request\r
-Ext.Ajax.{@link Ext.data.Connection#request request}({\r
- url: 'foo.php',\r
- success: someFn,\r
- failure: otherFn,\r
- headers: {\r
- 'my-header': 'foo'\r
- },\r
- params: { foo: 'bar' }\r
-});\r
-\r
-// Simple ajax form submission\r
-Ext.Ajax.{@link Ext.data.Connection#request request}({\r
- form: 'some-form',\r
- params: 'foo=bar'\r
-});\r
- * </code></pre> \r
- * </p>\r
- * @singleton\r
- */\r
-Ext.Ajax = new Ext.data.Connection({\r
- /**\r
- * @cfg {String} url @hide\r
- */\r
- /**\r
- * @cfg {Object} extraParams @hide\r
- */\r
- /**\r
- * @cfg {Object} defaultHeaders @hide\r
- */\r
- /**\r
- * @cfg {String} method (Optional) @hide\r
- */\r
- /**\r
- * @cfg {Number} timeout (Optional) @hide\r
- */\r
- /**\r
- * @cfg {Boolean} autoAbort (Optional) @hide\r
- */\r
-\r
- /**\r
- * @cfg {Boolean} disableCaching (Optional) @hide\r
- */\r
-\r
- /**\r
- * @property disableCaching\r
- * True to add a unique cache-buster param to GET requests. (defaults to true)\r
- * @type Boolean\r
- */\r
- /**\r
- * @property url\r
- * The default URL to be used for requests to the server. (defaults to undefined)\r
- * If the server receives all requests through one URL, setting this once is easier than\r
- * entering it on every request.\r
- * @type String\r
- */\r
- /**\r
- * @property extraParams\r
- * An object containing properties which are used as extra parameters to each request made\r
- * by this object (defaults to undefined). Session information and other data that you need\r
- * to pass with each request are commonly put here.\r
- * @type Object\r
- */\r
- /**\r
- * @property defaultHeaders\r
- * An object containing request headers which are added to each request made by this object\r
- * (defaults to undefined).\r
- * @type Object\r
- */\r
- /**\r
- * @property method\r
- * The default HTTP method to be used for requests. Note that this is case-sensitive and\r
- * should be all caps (defaults to undefined; if not set but params are present will use\r
- * <tt>"POST"</tt>, otherwise will use <tt>"GET"</tt>.)\r
- * @type String\r
- */\r
- /**\r
- * @property timeout\r
- * The timeout in milliseconds to be used for requests. (defaults to 30000)\r
- * @type Number\r
- */\r
-\r
- /**\r
- * @property autoAbort\r
- * Whether a new request should abort any pending requests. (defaults to false)\r
- * @type Boolean\r
- */\r
- autoAbort : false,\r
-\r
- /**\r
- * Serialize the passed form into a url encoded string\r
- * @param {String/HTMLElement} form\r
- * @return {String}\r
- */\r
- serializeForm : function(form){\r
- return Ext.lib.Ajax.serializeForm(form);\r
- }\r
-});\r
-/**
- * @class Ext.Updater
- * @extends Ext.util.Observable
- * Provides AJAX-style update capabilities for Element objects. Updater can be used to {@link #update}
- * an {@link Ext.Element} once, or you can use {@link #startAutoRefresh} to set up an auto-updating
- * {@link Ext.Element Element} on a specific interval.<br><br>
- * Usage:<br>
- * <pre><code>
- * var el = Ext.get("foo"); // Get Ext.Element object
- * var mgr = el.getUpdater();
- * mgr.update({
- url: "http://myserver.com/index.php",
- params: {
- param1: "foo",
- param2: "bar"
- }
- * });
- * ...
- * mgr.formUpdate("myFormId", "http://myserver.com/index.php");
- * <br>
- * // or directly (returns the same Updater instance)
- * var mgr = new Ext.Updater("myElementId");
- * mgr.startAutoRefresh(60, "http://myserver.com/index.php");
- * mgr.on("update", myFcnNeedsToKnow);
- * <br>
- * // short handed call directly from the element object
- * Ext.get("foo").load({
- url: "bar.php",
- scripts: true,
- params: "param1=foo&param2=bar",
- text: "Loading Foo..."
- * });
- * </code></pre>
- * @constructor
- * Create new Updater directly.
- * @param {Mixed} el The element to update
- * @param {Boolean} forceNew (optional) By default the constructor checks to see if the passed element already
- * has an Updater and if it does it returns the same instance. This will skip that check (useful for extending this class).
- */
-Ext.UpdateManager = Ext.Updater = Ext.extend(Ext.util.Observable,
-function() {
- var BEFOREUPDATE = "beforeupdate",
- UPDATE = "update",
- FAILURE = "failure";
-
- // private
- function processSuccess(response){
- var me = this;
- me.transaction = null;
- if (response.argument.form && response.argument.reset) {
- try { // put in try/catch since some older FF releases had problems with this
- response.argument.form.reset();
- } catch(e){}
- }
- if (me.loadScripts) {
- me.renderer.render(me.el, response, me,
- updateComplete.createDelegate(me, [response]));
- } else {
- me.renderer.render(me.el, response, me);
- updateComplete.call(me, response);
- }
- }
-
- // private
- function updateComplete(response, type, success){
- this.fireEvent(type || UPDATE, this.el, response);
- if(Ext.isFunction(response.argument.callback)){
- response.argument.callback.call(response.argument.scope, this.el, Ext.isEmpty(success) ? true : false, response, response.argument.options);
- }
- }
-
- // private
- function processFailure(response){
- updateComplete.call(this, response, FAILURE, !!(this.transaction = null));
- }
-
- return {
- constructor: function(el, forceNew){
- var me = this;
- el = Ext.get(el);
- if(!forceNew && el.updateManager){
- return el.updateManager;
- }
- /**
- * The Element object
- * @type Ext.Element
- */
- me.el = el;
- /**
- * Cached url to use for refreshes. Overwritten every time update() is called unless "discardUrl" param is set to true.
- * @type String
- */
- me.defaultUrl = null;
-
- me.addEvents(
- /**
- * @event beforeupdate
- * Fired before an update is made, return false from your handler and the update is cancelled.
- * @param {Ext.Element} el
- * @param {String/Object/Function} url
- * @param {String/Object} params
- */
- BEFOREUPDATE,
- /**
- * @event update
- * Fired after successful update is made.
- * @param {Ext.Element} el
- * @param {Object} oResponseObject The response Object
- */
- UPDATE,
- /**
- * @event failure
- * Fired on update failure.
- * @param {Ext.Element} el
- * @param {Object} oResponseObject The response Object
- */
- FAILURE
- );
-
- Ext.apply(me, Ext.Updater.defaults);
- /**
- * Blank page URL to use with SSL file uploads (defaults to {@link Ext.Updater.defaults#sslBlankUrl}).
- * @property sslBlankUrl
- * @type String
- */
- /**
- * Whether to append unique parameter on get request to disable caching (defaults to {@link Ext.Updater.defaults#disableCaching}).
- * @property disableCaching
- * @type Boolean
- */
- /**
- * Text for loading indicator (defaults to {@link Ext.Updater.defaults#indicatorText}).
- * @property indicatorText
- * @type String
- */
- /**
- * Whether to show indicatorText when loading (defaults to {@link Ext.Updater.defaults#showLoadIndicator}).
- * @property showLoadIndicator
- * @type String
- */
- /**
- * Timeout for requests or form posts in seconds (defaults to {@link Ext.Updater.defaults#timeout}).
- * @property timeout
- * @type Number
- */
- /**
- * True to process scripts in the output (defaults to {@link Ext.Updater.defaults#loadScripts}).
- * @property loadScripts
- * @type Boolean
- */
-
- /**
- * Transaction object of the current executing transaction, or null if there is no active transaction.
- */
- me.transaction = null;
- /**
- * Delegate for refresh() prebound to "this", use myUpdater.refreshDelegate.createCallback(arg1, arg2) to bind arguments
- * @type Function
- */
- me.refreshDelegate = me.refresh.createDelegate(me);
- /**
- * Delegate for update() prebound to "this", use myUpdater.updateDelegate.createCallback(arg1, arg2) to bind arguments
- * @type Function
- */
- me.updateDelegate = me.update.createDelegate(me);
- /**
- * Delegate for formUpdate() prebound to "this", use myUpdater.formUpdateDelegate.createCallback(arg1, arg2) to bind arguments
- * @type Function
- */
- me.formUpdateDelegate = (me.formUpdate || function(){}).createDelegate(me);
-
- /**
- * The renderer for this Updater (defaults to {@link Ext.Updater.BasicRenderer}).
- */
- me.renderer = me.renderer || me.getDefaultRenderer();
-
- Ext.Updater.superclass.constructor.call(me);
- },
-
- /**
- * Sets the content renderer for this Updater. See {@link Ext.Updater.BasicRenderer#render} for more details.
- * @param {Object} renderer The object implementing the render() method
- */
- setRenderer : function(renderer){
- this.renderer = renderer;
- },
-
- /**
- * Returns the current content renderer for this Updater. See {@link Ext.Updater.BasicRenderer#render} for more details.
- * @return {Object}
- */
- getRenderer : function(){
- return this.renderer;
- },
-
- /**
- * This is an overrideable method which returns a reference to a default
- * renderer class if none is specified when creating the Ext.Updater.
- * Defaults to {@link Ext.Updater.BasicRenderer}
- */
- getDefaultRenderer: function() {
- return new Ext.Updater.BasicRenderer();
- },
-
- /**
- * Sets the default URL used for updates.
- * @param {String/Function} defaultUrl The url or a function to call to get the url
- */
- setDefaultUrl : function(defaultUrl){
- this.defaultUrl = defaultUrl;
- },
-
- /**
- * Get the Element this Updater is bound to
- * @return {Ext.Element} The element
- */
- getEl : function(){
- return this.el;
- },
-
- /**
- * Performs an <b>asynchronous</b> request, updating this element with the response.
- * If params are specified it uses POST, otherwise it uses GET.<br><br>
- * <b>Note:</b> Due to the asynchronous nature of remote server requests, the Element
- * will not have been fully updated when the function returns. To post-process the returned
- * data, use the callback option, or an <b><tt>update</tt></b> event handler.
- * @param {Object} options A config object containing any of the following options:<ul>
- * <li>url : <b>String/Function</b><p class="sub-desc">The URL to request or a function which
- * <i>returns</i> the URL (defaults to the value of {@link Ext.Ajax#url} if not specified).</p></li>
- * <li>method : <b>String</b><p class="sub-desc">The HTTP method to
- * use. Defaults to POST if the <tt>params</tt> argument is present, otherwise GET.</p></li>
- * <li>params : <b>String/Object/Function</b><p class="sub-desc">The
- * parameters to pass to the server (defaults to none). These may be specified as a url-encoded
- * string, or as an object containing properties which represent parameters,
- * or as a function, which returns such an object.</p></li>
- * <li>scripts : <b>Boolean</b><p class="sub-desc">If <tt>true</tt>
- * any <script> tags embedded in the response text will be extracted
- * and executed (defaults to {@link Ext.Updater.defaults#loadScripts}). If this option is specified,
- * the callback will be called <i>after</i> the execution of the scripts.</p></li>
- * <li>callback : <b>Function</b><p class="sub-desc">A function to
- * be called when the response from the server arrives. The following
- * parameters are passed:<ul>
- * <li><b>el</b> : Ext.Element<p class="sub-desc">The Element being updated.</p></li>
- * <li><b>success</b> : Boolean<p class="sub-desc">True for success, false for failure.</p></li>
- * <li><b>response</b> : XMLHttpRequest<p class="sub-desc">The XMLHttpRequest which processed the update.</p></li>
- * <li><b>options</b> : Object<p class="sub-desc">The config object passed to the update call.</p></li></ul>
- * </p></li>
- * <li>scope : <b>Object</b><p class="sub-desc">The scope in which
- * to execute the callback (The callback's <tt>this</tt> reference.) If the
- * <tt>params</tt> argument is a function, this scope is used for that function also.</p></li>
- * <li>discardUrl : <b>Boolean</b><p class="sub-desc">By default, the URL of this request becomes
- * the default URL for this Updater object, and will be subsequently used in {@link #refresh}
- * calls. To bypass this behavior, pass <tt>discardUrl:true</tt> (defaults to false).</p></li>
- * <li>timeout : <b>Number</b><p class="sub-desc">The number of seconds to wait for a response before
- * timing out (defaults to {@link Ext.Updater.defaults#timeout}).</p></li>
- * <li>text : <b>String</b><p class="sub-desc">The text to use as the innerHTML of the
- * {@link Ext.Updater.defaults#indicatorText} div (defaults to 'Loading...'). To replace the entire div, not
- * just the text, override {@link Ext.Updater.defaults#indicatorText} directly.</p></li>
- * <li>nocache : <b>Boolean</b><p class="sub-desc">Only needed for GET
- * requests, this option causes an extra, auto-generated parameter to be appended to the request
- * to defeat caching (defaults to {@link Ext.Updater.defaults#disableCaching}).</p></li></ul>
- * <p>
- * For example:
- <pre><code>
- um.update({
- url: "your-url.php",
- params: {param1: "foo", param2: "bar"}, // or a URL encoded string
- callback: yourFunction,
- scope: yourObject, //(optional scope)
- discardUrl: true,
- nocache: true,
- text: "Loading...",
- timeout: 60,
- scripts: false // Save time by avoiding RegExp execution.
- });
- </code></pre>
- */
- update : function(url, params, callback, discardUrl){
- var me = this,
- cfg,
- callerScope;
-
- if(me.fireEvent(BEFOREUPDATE, me.el, url, params) !== false){
- if(Ext.isObject(url)){ // must be config object
- cfg = url;
- url = cfg.url;
- params = params || cfg.params;
- callback = callback || cfg.callback;
- discardUrl = discardUrl || cfg.discardUrl;
- callerScope = cfg.scope;
- if(!Ext.isEmpty(cfg.nocache)){me.disableCaching = cfg.nocache;};
- if(!Ext.isEmpty(cfg.text)){me.indicatorText = '<div class="loading-indicator">'+cfg.text+"</div>";};
- if(!Ext.isEmpty(cfg.scripts)){me.loadScripts = cfg.scripts;};
- if(!Ext.isEmpty(cfg.timeout)){me.timeout = cfg.timeout;};
- }
- me.showLoading();
-
- if(!discardUrl){
- me.defaultUrl = url;
- }
- if(Ext.isFunction(url)){
- url = url.call(me);
- }
-
- var o = Ext.apply({}, {
- url : url,
- params: (Ext.isFunction(params) && callerScope) ? params.createDelegate(callerScope) : params,
- success: processSuccess,
- failure: processFailure,
- scope: me,
- callback: undefined,
- timeout: (me.timeout*1000),
- disableCaching: me.disableCaching,
- argument: {
- "options": cfg,
- "url": url,
- "form": null,
- "callback": callback,
- "scope": callerScope || window,
- "params": params
- }
- }, cfg);
-
- me.transaction = Ext.Ajax.request(o);
- }
- },
-
- /**
- * <p>Performs an async form post, updating this element with the response. If the form has the attribute
- * enctype="<a href="http://www.faqs.org/rfcs/rfc2388.html">multipart/form-data</a>", it assumes it's a file upload.
- * Uses this.sslBlankUrl for SSL file uploads to prevent IE security warning.</p>
- * <p>File uploads are not performed using normal "Ajax" techniques, that is they are <b>not</b>
- * performed using XMLHttpRequests. Instead the form is submitted in the standard manner with the
- * DOM <tt><form></tt> element temporarily modified to have its
- * <a href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-target">target</a> set to refer
- * to a dynamically generated, hidden <tt><iframe></tt> which is inserted into the document
- * but removed after the return data has been gathered.</p>
- * <p>Be aware that file upload packets, sent with the content type <a href="http://www.faqs.org/rfcs/rfc2388.html">multipart/form-data</a>
- * and some server technologies (notably JEE) may require some custom processing in order to
- * retrieve parameter names and parameter values from the packet content.</p>
- * @param {String/HTMLElement} form The form Id or form element
- * @param {String} url (optional) The url to pass the form to. If omitted the action attribute on the form will be used.
- * @param {Boolean} reset (optional) Whether to try to reset the form after the update
- * @param {Function} callback (optional) Callback when transaction is complete. The following
- * parameters are passed:<ul>
- * <li><b>el</b> : Ext.Element<p class="sub-desc">The Element being updated.</p></li>
- * <li><b>success</b> : Boolean<p class="sub-desc">True for success, false for failure.</p></li>
- * <li><b>response</b> : XMLHttpRequest<p class="sub-desc">The XMLHttpRequest which processed the update.</p></li></ul>
- */
- formUpdate : function(form, url, reset, callback){
- var me = this;
- if(me.fireEvent(BEFOREUPDATE, me.el, form, url) !== false){
- if(Ext.isFunction(url)){
- url = url.call(me);
- }
- form = Ext.getDom(form)
- me.transaction = Ext.Ajax.request({
- form: form,
- url:url,
- success: processSuccess,
- failure: processFailure,
- scope: me,
- timeout: (me.timeout*1000),
- argument: {
- "url": url,
- "form": form,
- "callback": callback,
- "reset": reset
- }
- });
- me.showLoading.defer(1, me);
- }
- },
-
- /**
- * Set this element to auto refresh. Can be canceled by calling {@link #stopAutoRefresh}.
- * @param {Number} interval How often to update (in seconds).
- * @param {String/Object/Function} url (optional) The url for this request, a config object in the same format
- * supported by {@link #load}, or a function to call to get the url (defaults to the last used url). Note that while
- * the url used in a load call can be reused by this method, other load config options will not be reused and must be
- * sepcified as part of a config object passed as this paramter if needed.
- * @param {String/Object} params (optional) The parameters to pass as either a url encoded string
- * "¶m1=1¶m2=2" or as an object {param1: 1, param2: 2}
- * @param {Function} callback (optional) Callback when transaction is complete - called with signature (oElement, bSuccess)
- * @param {Boolean} refreshNow (optional) Whether to execute the refresh now, or wait the interval
- */
- startAutoRefresh : function(interval, url, params, callback, refreshNow){
- var me = this;
- if(refreshNow){
- me.update(url || me.defaultUrl, params, callback, true);
- }
- if(me.autoRefreshProcId){
- clearInterval(me.autoRefreshProcId);
- }
- me.autoRefreshProcId = setInterval(me.update.createDelegate(me, [url || me.defaultUrl, params, callback, true]), interval * 1000);
- },
-
- /**
- * Stop auto refresh on this element.
- */
- stopAutoRefresh : function(){
- if(this.autoRefreshProcId){
- clearInterval(this.autoRefreshProcId);
- delete this.autoRefreshProcId;
- }
- },
-
- /**
- * Returns true if the Updater is currently set to auto refresh its content (see {@link #startAutoRefresh}), otherwise false.
- */
- isAutoRefreshing : function(){
- return !!this.autoRefreshProcId;
- },
-
- /**
- * Display the element's "loading" state. By default, the element is updated with {@link #indicatorText}. This
- * method may be overridden to perform a custom action while this Updater is actively updating its contents.
- */
- showLoading : function(){
- if(this.showLoadIndicator){
- this.el.dom.innerHTML = this.indicatorText;
- }
- },
-
- /**
- * Aborts the currently executing transaction, if any.
- */
- abort : function(){
- if(this.transaction){
- Ext.Ajax.abort(this.transaction);
- }
- },
-
- /**
- * Returns true if an update is in progress, otherwise false.
- * @return {Boolean}
- */
- isUpdating : function(){
- return this.transaction ? Ext.Ajax.isLoading(this.transaction) : false;
- },
-
- /**
- * Refresh the element with the last used url or defaultUrl. If there is no url, it returns immediately
- * @param {Function} callback (optional) Callback when transaction is complete - called with signature (oElement, bSuccess)
- */
- refresh : function(callback){
- if(this.defaultUrl){
- this.update(this.defaultUrl, null, callback, true);
- }
- }
- }