Subversion Repositories eFlore/Applications.cel

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
27 jpm 1
/*
2
 * Ext JS Library 2.0.2
3
 * Copyright(c) 2006-2008, Ext JS, LLC.
4
 * licensing@extjs.com
5
 *
6
 * http://extjs.com/license
7
 */
8
 
9
if(typeof YAHOO == "undefined"){
10
    throw "Unable to load Ext, core YUI utilities (yahoo, dom, event) not found.";
11
}
12
 
13
(function(){
14
var E = YAHOO.util.Event;
15
var D = YAHOO.util.Dom;
16
var CN = YAHOO.util.Connect;
17
 
18
var ES = YAHOO.util.Easing;
19
var A = YAHOO.util.Anim;
20
var libFlyweight;
21
 
22
Ext.lib.Dom = {
23
    getViewWidth : function(full){
24
        return full ? D.getDocumentWidth() : D.getViewportWidth();
25
    },
26
 
27
    getViewHeight : function(full){
28
        return full ? D.getDocumentHeight() : D.getViewportHeight();
29
    },
30
 
31
    isAncestor : function(haystack, needle){
32
        return D.isAncestor(haystack, needle);
33
    },
34
 
35
    getRegion : function(el){
36
        return D.getRegion(el);
37
    },
38
 
39
    getY : function(el){
40
        return this.getXY(el)[1];
41
    },
42
 
43
    getX : function(el){
44
        return this.getXY(el)[0];
45
    },
46
 
47
    // original version based on YahooUI getXY
48
    // this version fixes several issues in Safari and FF
49
    // and boosts performance by removing the batch overhead, repetitive dom lookups and array index calls
50
    getXY : function(el){
51
        var p, pe, b, scroll, bd = (document.body || document.documentElement);
52
        el = Ext.getDom(el);
53
 
54
        if(el == bd){
55
            return [0, 0];
56
        }
57
 
58
        if (el.getBoundingClientRect) {
59
            b = el.getBoundingClientRect();
60
            scroll = fly(document).getScroll();
61
            return [b.left + scroll.left, b.top + scroll.top];
62
        }
63
        var x = 0, y = 0;
64
 
65
        p = el;
66
 
67
        var hasAbsolute = fly(el).getStyle("position") == "absolute";
68
 
69
        while (p) {
70
 
71
            x += p.offsetLeft;
72
            y += p.offsetTop;
73
 
74
            if (!hasAbsolute && fly(p).getStyle("position") == "absolute") {
75
                hasAbsolute = true;
76
            }
77
 
78
            if (Ext.isGecko) {
79
                pe = fly(p);
80
 
81
                var bt = parseInt(pe.getStyle("borderTopWidth"), 10) || 0;
82
                var bl = parseInt(pe.getStyle("borderLeftWidth"), 10) || 0;
83
 
84
 
85
                x += bl;
86
                y += bt;
87
 
88
 
89
                if (p != el && pe.getStyle('overflow') != 'visible') {
90
                    x += bl;
91
                    y += bt;
92
                }
93
            }
94
            p = p.offsetParent;
95
        }
96
 
97
        if (Ext.isSafari && hasAbsolute) {
98
            x -= bd.offsetLeft;
99
            y -= bd.offsetTop;
100
        }
101
 
102
        if (Ext.isGecko && !hasAbsolute) {
103
            var dbd = fly(bd);
104
            x += parseInt(dbd.getStyle("borderLeftWidth"), 10) || 0;
105
            y += parseInt(dbd.getStyle("borderTopWidth"), 10) || 0;
106
        }
107
 
108
        p = el.parentNode;
109
        while (p && p != bd) {
110
            if (!Ext.isOpera || (p.tagName != 'TR' && fly(p).getStyle("display") != "inline")) {
111
                x -= p.scrollLeft;
112
                y -= p.scrollTop;
113
            }
114
            p = p.parentNode;
115
        }
116
        return [x, y];
117
    },
118
 
119
    setXY : function(el, xy){
120
        el = Ext.fly(el, '_setXY');
121
        el.position();
122
        var pts = el.translatePoints(xy);
123
        if(xy[0] !== false){
124
            el.dom.style.left = pts.left + "px";
125
        }
126
        if(xy[1] !== false){
127
            el.dom.style.top = pts.top + "px";
128
        }
129
    },
130
 
131
    setX : function(el, x){
132
        this.setXY(el, [x, false]);
133
    },
134
 
135
    setY : function(el, y){
136
        this.setXY(el, [false, y]);
137
    }
138
};
139
 
140
Ext.lib.Event = {
141
    getPageX : function(e){
142
        return E.getPageX(e.browserEvent || e);
143
    },
144
 
145
    getPageY : function(e){
146
        return E.getPageY(e.browserEvent || e);
147
    },
148
 
149
    getXY : function(e){
150
        return E.getXY(e.browserEvent || e);
151
    },
152
 
153
    getTarget : function(e){
154
        return E.getTarget(e.browserEvent || e);
155
    },
156
 
157
    getRelatedTarget : function(e){
158
        return E.getRelatedTarget(e.browserEvent || e);
159
    },
160
 
161
    on : function(el, eventName, fn, scope, override){
162
        E.on(el, eventName, fn, scope, override);
163
    },
164
 
165
    un : function(el, eventName, fn){
166
        E.removeListener(el, eventName, fn);
167
    },
168
 
169
    purgeElement : function(el){
170
        E.purgeElement(el);
171
    },
172
 
173
    preventDefault : function(e){
174
        E.preventDefault(e.browserEvent || e);
175
    },
176
 
177
    stopPropagation : function(e){
178
        E.stopPropagation(e.browserEvent || e);
179
    },
180
 
181
    stopEvent : function(e){
182
        E.stopEvent(e.browserEvent || e);
183
    },
184
 
185
    onAvailable : function(el, fn, scope, override){
186
        return E.onAvailable(el, fn, scope, override);
187
    }
188
};
189
 
190
Ext.lib.Ajax = {
191
    request : function(method, uri, cb, data, options){
192
        if(options){
193
            var hs = options.headers;
194
            if(hs){
195
                for(var h in hs){
196
                    if(hs.hasOwnProperty(h)){
197
                        CN.initHeader(h, hs[h], false);
198
                    }
199
                }
200
            }
201
            if(options.xmlData){
202
                CN.initHeader('Content-Type', 'text/xml', false);
203
                method = 'POST';
204
                data = options.xmlData;
205
            }else if(options.jsonData){
206
                CN.initHeader('Content-Type', 'text/javascript', false);
207
                method = 'POST';
208
                data = typeof options.jsonData == 'object' ? Ext.encode(options.jsonData) : options.jsonData;
209
            }
210
        }
211
        return CN.asyncRequest(method, uri, cb, data);
212
    },
213
 
214
    formRequest : function(form, uri, cb, data, isUpload, sslUri){
215
        CN.setForm(form, isUpload, sslUri);
216
        return CN.asyncRequest(Ext.getDom(form).method ||'POST', uri, cb, data);
217
    },
218
 
219
    isCallInProgress : function(trans){
220
        return CN.isCallInProgress(trans);
221
    },
222
 
223
    abort : function(trans){
224
        return CN.abort(trans);
225
    },
226
 
227
    serializeForm : function(form){
228
        var d = CN.setForm(form.dom || form);
229
        CN.resetFormState();
230
        return d;
231
    }
232
};
233
 
234
Ext.lib.Region = YAHOO.util.Region;
235
Ext.lib.Point = YAHOO.util.Point;
236
 
237
 
238
Ext.lib.Anim = {
239
    scroll : function(el, args, duration, easing, cb, scope){
240
        this.run(el, args, duration, easing, cb, scope, YAHOO.util.Scroll);
241
    },
242
 
243
    motion : function(el, args, duration, easing, cb, scope){
244
        this.run(el, args, duration, easing, cb, scope, YAHOO.util.Motion);
245
    },
246
 
247
    color : function(el, args, duration, easing, cb, scope){
248
        this.run(el, args, duration, easing, cb, scope, YAHOO.util.ColorAnim);
249
    },
250
 
251
    run : function(el, args, duration, easing, cb, scope, type){
252
        type = type || YAHOO.util.Anim;
253
        if(typeof easing == "string"){
254
            easing = YAHOO.util.Easing[easing];
255
        }
256
        var anim = new type(el, args, duration, easing);
257
        anim.animateX(function(){
258
            Ext.callback(cb, scope);
259
        });
260
        return anim;
261
    }
262
};
263
 
264
// all lib flyweight calls use their own flyweight to prevent collisions with developer flyweights
265
function fly(el){
266
    if(!libFlyweight){
267
        libFlyweight = new Ext.Element.Flyweight();
268
    }
269
    libFlyweight.dom = el;
270
    return libFlyweight;
271
}
272
 
273
// prevent IE leaks
274
if(Ext.isIE) {
275
    function fnCleanUp() {
276
        var p = Function.prototype;
277
        delete p.createSequence;
278
        delete p.defer;
279
        delete p.createDelegate;
280
        delete p.createCallback;
281
        delete p.createInterceptor;
282
 
283
        window.detachEvent("onunload", fnCleanUp);
284
    }
285
    window.attachEvent("onunload", fnCleanUp);
286
}
287
// various overrides
288
 
289
// add ability for callbacks with animations
290
if(YAHOO.util.Anim){
291
    YAHOO.util.Anim.prototype.animateX = function(callback, scope){
292
        var f = function(){
293
            this.onComplete.unsubscribe(f);
294
            if(typeof callback == "function"){
295
                callback.call(scope || this, this);
296
            }
297
        };
298
        this.onComplete.subscribe(f, this, true);
299
        this.animate();
300
    };
301
}
302
 
303
if(YAHOO.util.DragDrop && Ext.dd.DragDrop){
304
    YAHOO.util.DragDrop.defaultPadding = Ext.dd.DragDrop.defaultPadding;
305
    YAHOO.util.DragDrop.constrainTo = Ext.dd.DragDrop.constrainTo;
306
}
307
 
308
YAHOO.util.Dom.getXY = function(el) {
309
    var f = function(el) {
310
        return Ext.lib.Dom.getXY(el);
311
    };
312
    return YAHOO.util.Dom.batch(el, f, YAHOO.util.Dom, true);
313
};
314
 
315
 
316
// workaround for Safari anim duration speed problems
317
if(YAHOO.util.AnimMgr){
318
    YAHOO.util.AnimMgr.fps = 1000;
319
}
320
 
321
YAHOO.util.Region.prototype.adjust = function(t, l, b, r){
322
    this.top += t;
323
    this.left += l;
324
    this.right += r;
325
    this.bottom += b;
326
    return this;
327
};
328
 
329
YAHOO.util.Region.prototype.constrainTo = function(r) {
330
    this.top = this.top.constrain(r.top, r.bottom);
331
    this.bottom = this.bottom.constrain(r.top, r.bottom);
332
    this.left = this.left.constrain(r.left, r.right);
333
    this.right = this.right.constrain(r.left, r.right);
334
    return this;
335
};
336
 
337
 
338
})();