2 * Ext JS Library 2.2.1
\r
3 * Copyright(c) 2006-2009, Ext JS, LLC.
\r
4 * licensing@extjs.com
\r
6 * http://extjs.com/license
\r
9 if(typeof YAHOO == "undefined"){
\r
10 throw "Unable to load Ext, core YUI utilities (yahoo, dom, event) not found.";
\r
14 var E = YAHOO.util.Event;
\r
15 var D = YAHOO.util.Dom;
\r
16 var CN = YAHOO.util.Connect;
\r
18 var ES = YAHOO.util.Easing;
\r
19 var A = YAHOO.util.Anim;
\r
23 getViewWidth : function(full){
\r
24 return full ? D.getDocumentWidth() : D.getViewportWidth();
\r
27 getViewHeight : function(full){
\r
28 return full ? D.getDocumentHeight() : D.getViewportHeight();
\r
31 isAncestor : function(haystack, needle){
\r
32 return D.isAncestor(haystack, needle);
\r
35 getRegion : function(el){
\r
36 return D.getRegion(el);
\r
39 getY : function(el){
\r
40 return this.getXY(el)[1];
\r
43 getX : function(el){
\r
44 return this.getXY(el)[0];
\r
47 // original version based on YahooUI getXY
\r
48 // this version fixes several issues in Safari and FF
\r
49 // and boosts performance by removing the batch overhead, repetitive dom lookups and array index calls
\r
50 getXY : function(el){
\r
51 var p, pe, b, scroll, bd = (document.body || document.documentElement);
\r
52 el = Ext.getDom(el);
\r
58 if (el.getBoundingClientRect) {
\r
59 b = el.getBoundingClientRect();
\r
60 scroll = fly(document).getScroll();
\r
61 return [b.left + scroll.left, b.top + scroll.top];
\r
67 var hasAbsolute = fly(el).getStyle("position") == "absolute";
\r
74 if (!hasAbsolute && fly(p).getStyle("position") == "absolute") {
\r
81 var bt = parseInt(pe.getStyle("borderTopWidth"), 10) || 0;
\r
82 var bl = parseInt(pe.getStyle("borderLeftWidth"), 10) || 0;
\r
89 if (p != el && pe.getStyle('overflow') != 'visible') {
\r
97 if (Ext.isSafari && hasAbsolute) {
\r
102 if (Ext.isGecko && !hasAbsolute) {
\r
104 x += parseInt(dbd.getStyle("borderLeftWidth"), 10) || 0;
\r
105 y += parseInt(dbd.getStyle("borderTopWidth"), 10) || 0;
\r
109 while (p && p != bd) {
\r
110 if (!Ext.isOpera || (p.tagName != 'TR' && fly(p).getStyle("display") != "inline")) {
\r
119 setXY : function(el, xy){
\r
120 el = Ext.fly(el, '_setXY');
\r
122 var pts = el.translatePoints(xy);
\r
123 if(xy[0] !== false){
\r
124 el.dom.style.left = pts.left + "px";
\r
126 if(xy[1] !== false){
\r
127 el.dom.style.top = pts.top + "px";
\r
131 setX : function(el, x){
\r
132 this.setXY(el, [x, false]);
\r
135 setY : function(el, y){
\r
136 this.setXY(el, [false, y]);
\r
141 getPageX : function(e){
\r
142 return E.getPageX(e.browserEvent || e);
\r
145 getPageY : function(e){
\r
146 return E.getPageY(e.browserEvent || e);
\r
149 getXY : function(e){
\r
150 return E.getXY(e.browserEvent || e);
\r
153 getTarget : function(e){
\r
154 return E.getTarget(e.browserEvent || e);
\r
157 getRelatedTarget : function(e){
\r
158 return E.getRelatedTarget(e.browserEvent || e);
\r
161 on : function(el, eventName, fn, scope, override){
\r
162 E.on(el, eventName, fn, scope, override);
\r
165 un : function(el, eventName, fn){
\r
166 E.removeListener(el, eventName, fn);
\r
169 purgeElement : function(el){
\r
170 E.purgeElement(el);
\r
173 preventDefault : function(e){
\r
174 E.preventDefault(e.browserEvent || e);
\r
177 stopPropagation : function(e){
\r
178 E.stopPropagation(e.browserEvent || e);
\r
181 stopEvent : function(e){
\r
182 E.stopEvent(e.browserEvent || e);
\r
185 onAvailable : function(el, fn, scope, override){
\r
186 return E.onAvailable(el, fn, scope, override);
\r
191 request : function(method, uri, cb, data, options){
\r
193 var hs = options.headers;
\r
196 if(hs.hasOwnProperty(h)){
\r
197 CN.initHeader(h, hs[h], false);
\r
201 if(options.xmlData){
\r
202 if (!hs || !hs['Content-Type']){
\r
203 CN.initHeader('Content-Type', 'text/xml', false);
\r
205 method = (method ? method : (options.method ? options.method : 'POST'));
\r
206 data = options.xmlData;
\r
207 }else if(options.jsonData){
\r
208 if (!hs || !hs['Content-Type']){
\r
209 CN.initHeader('Content-Type', 'application/json', false);
\r
211 method = (method ? method : (options.method ? options.method : 'POST'));
\r
212 data = typeof options.jsonData == 'object' ? Ext.encode(options.jsonData) : options.jsonData;
\r
215 return CN.asyncRequest(method, uri, cb, data);
\r
218 formRequest : function(form, uri, cb, data, isUpload, sslUri){
\r
219 CN.setForm(form, isUpload, sslUri);
\r
220 return CN.asyncRequest(Ext.getDom(form).method ||'POST', uri, cb, data);
\r
223 isCallInProgress : function(trans){
\r
224 return CN.isCallInProgress(trans);
\r
227 abort : function(trans){
\r
228 return CN.abort(trans);
\r
231 serializeForm : function(form){
\r
232 var d = CN.setForm(form.dom || form);
\r
233 CN.resetFormState();
\r
238 Ext.lib.Region = YAHOO.util.Region;
\r
239 Ext.lib.Point = YAHOO.util.Point;
\r
243 scroll : function(el, args, duration, easing, cb, scope){
\r
244 this.run(el, args, duration, easing, cb, scope, YAHOO.util.Scroll);
\r
247 motion : function(el, args, duration, easing, cb, scope){
\r
248 this.run(el, args, duration, easing, cb, scope, YAHOO.util.Motion);
\r
251 color : function(el, args, duration, easing, cb, scope){
\r
252 this.run(el, args, duration, easing, cb, scope, YAHOO.util.ColorAnim);
\r
255 run : function(el, args, duration, easing, cb, scope, type){
\r
256 type = type || YAHOO.util.Anim;
\r
257 if(typeof easing == "string"){
\r
258 easing = YAHOO.util.Easing[easing];
\r
260 var anim = new type(el, args, duration, easing);
\r
261 anim.animateX(function(){
\r
262 Ext.callback(cb, scope);
\r
268 // all lib flyweight calls use their own flyweight to prevent collisions with developer flyweights
\r
271 libFlyweight = new Ext.Element.Flyweight();
\r
273 libFlyweight.dom = el;
\r
274 return libFlyweight;
\r
277 // prevent IE leaks
\r
279 function fnCleanUp() {
\r
280 var p = Function.prototype;
\r
281 delete p.createSequence;
\r
283 delete p.createDelegate;
\r
284 delete p.createCallback;
\r
285 delete p.createInterceptor;
\r
287 window.detachEvent("onunload", fnCleanUp);
\r
289 window.attachEvent("onunload", fnCleanUp);
\r
291 // various overrides
\r
293 // add ability for callbacks with animations
\r
294 if(YAHOO.util.Anim){
\r
295 YAHOO.util.Anim.prototype.animateX = function(callback, scope){
\r
296 var f = function(){
\r
297 this.onComplete.unsubscribe(f);
\r
298 if(typeof callback == "function"){
\r
299 callback.call(scope || this, this);
\r
302 this.onComplete.subscribe(f, this, true);
\r
307 if(YAHOO.util.DragDrop && Ext.dd.DragDrop){
\r
308 YAHOO.util.DragDrop.defaultPadding = Ext.dd.DragDrop.defaultPadding;
\r
309 YAHOO.util.DragDrop.constrainTo = Ext.dd.DragDrop.constrainTo;
\r
312 YAHOO.util.Dom.getXY = function(el) {
\r
313 var f = function(el) {
\r
314 return Ext.lib.Dom.getXY(el);
\r
316 return YAHOO.util.Dom.batch(el, f, YAHOO.util.Dom, true);
\r
320 // workaround for Safari anim duration speed problems
\r
321 if(YAHOO.util.AnimMgr){
\r
322 YAHOO.util.AnimMgr.fps = 1000;
\r
325 YAHOO.util.Region.prototype.adjust = function(t, l, b, r){
\r
333 YAHOO.util.Region.prototype.constrainTo = function(r) {
\r
334 this.top = this.top.constrain(r.top, r.bottom);
\r
335 this.bottom = this.bottom.constrain(r.top, r.bottom);
\r
336 this.left = this.left.constrain(r.left, r.right);
\r
337 this.right = this.right.constrain(r.left, r.right);
\r