3
* Copyright(c) 2006-2010 Ext JS, Inc.
5
* http://www.extjs.com/license
10
version = Prototype.Version.split('.'),
11
mouseEnterSupported = (parseInt(version[0]) >= 2) || (parseInt(version[1]) >= 7) || (parseInt(version[2]) >= 1),
13
elContains = function(parent, child) {
14
if(parent && parent.firstChild){
16
if(child === parent) {
19
child = child.parentNode;
20
if(child && (child.nodeType != 1)) {
27
checkRelatedTarget = function(e) {
28
return !elContains(e.currentTarget, Ext.lib.Event.getRelatedTarget(e));
32
getViewWidth : function(full){
33
return full ? this.getDocumentWidth() : this.getViewportWidth();
36
getViewHeight : function(full){
37
return full ? this.getDocumentHeight() : this.getViewportHeight();
40
getDocumentHeight: function() { // missing from prototype?
41
var scrollHeight = (document.compatMode != "CSS1Compat") ? document.body.scrollHeight : document.documentElement.scrollHeight;
42
return Math.max(scrollHeight, this.getViewportHeight());
45
getDocumentWidth: function() { // missing from prototype?
46
var scrollWidth = (document.compatMode != "CSS1Compat") ? document.body.scrollWidth : document.documentElement.scrollWidth;
47
return Math.max(scrollWidth, this.getViewportWidth());
50
getViewportHeight: function() { // missing from prototype?
51
var height = self.innerHeight;
52
var mode = document.compatMode;
54
if ( (mode || Ext.isIE) && !Ext.isOpera ) {
55
height = (mode == "CSS1Compat") ?
56
document.documentElement.clientHeight : // Standards
57
document.body.clientHeight; // Quirks
63
getViewportWidth: function() { // missing from prototype?
64
var width = self.innerWidth; // Safari
65
var mode = document.compatMode;
67
if (mode || Ext.isIE) { // IE, Gecko, Opera
68
width = (mode == "CSS1Compat") ?
69
document.documentElement.clientWidth : // Standards
70
document.body.clientWidth; // Quirks
75
isAncestor : function(p, c){ // missing from prototype?
83
} else if (p.compareDocumentPosition) {
84
return !!(p.compareDocumentPosition(c) & 16);
86
while (c = c.parentNode) {
94
getRegion : function(el){
95
return Ext.lib.Region.getRegion(el);
99
return this.getXY(el)[1];
103
return this.getXY(el)[0];
106
getXY : function(el){ // this initially used Position.cumulativeOffset but it is not accurate enough
107
var p, pe, b, scroll, bd = (document.body || document.documentElement);
114
if (el.getBoundingClientRect) {
115
b = el.getBoundingClientRect();
116
scroll = fly(document).getScroll();
117
return [Math.round(b.left + scroll.left), Math.round(b.top + scroll.top)];
123
var hasAbsolute = fly(el).getStyle("position") == "absolute";
130
if (!hasAbsolute && fly(p).getStyle("position") == "absolute") {
137
var bt = parseInt(pe.getStyle("borderTopWidth"), 10) || 0;
138
var bl = parseInt(pe.getStyle("borderLeftWidth"), 10) || 0;
145
if (p != el && pe.getStyle('overflow') != 'visible') {
153
if (Ext.isSafari && hasAbsolute) {
158
if (Ext.isGecko && !hasAbsolute) {
160
x += parseInt(dbd.getStyle("borderLeftWidth"), 10) || 0;
161
y += parseInt(dbd.getStyle("borderTopWidth"), 10) || 0;
165
while (p && p != bd) {
166
if (!Ext.isOpera || (p.tagName != 'TR' && fly(p).getStyle("display") != "inline")) {
175
setXY : function(el, xy){ // this initially used Position.cumulativeOffset but it is not accurate enough
176
el = Ext.fly(el, '_setXY');
178
var pts = el.translatePoints(xy);
180
el.dom.style.left = pts.left + "px";
183
el.dom.style.top = pts.top + "px";
187
setX : function(el, x){
188
this.setXY(el, [x, false]);
191
setY : function(el, y){
192
this.setXY(el, [false, y]);
197
getPageX : function(e){
198
return Event.pointerX(e.browserEvent || e);
201
getPageY : function(e){
202
return Event.pointerY(e.browserEvent || e);
206
e = e.browserEvent || e;
207
return [Event.pointerX(e), Event.pointerY(e)];
210
getTarget : function(e){
211
return Event.element(e.browserEvent || e);
214
resolveTextNode: Ext.isGecko ? function(node){
218
var s = HTMLElement.prototype.toString.call(node);
219
if(s == '[xpconnect wrapped native prototype]' || s == '[object XULElement]'){
222
return node.nodeType == 3 ? node.parentNode : node;
224
return node && node.nodeType == 3 ? node.parentNode : node;
227
getRelatedTarget: function(ev) { // missing from prototype?
228
ev = ev.browserEvent || ev;
229
var t = ev.relatedTarget;
231
if (ev.type == "mouseout") {
233
} else if (ev.type == "mouseover") {
238
return this.resolveTextNode(t);
241
on : function(el, eventName, fn){
242
if((eventName == 'mouseenter' || eventName == 'mouseleave') && !mouseEnterSupported){
243
var item = mouseCache[el.id] || (mouseCache[el.id] = {});
244
item[eventName] = fn;
245
fn = fn.createInterceptor(checkRelatedTarget);
246
eventName = (eventName == 'mouseenter') ? 'mouseover' : 'mouseout';
248
Event.observe(el, eventName, fn, false);
251
un : function(el, eventName, fn){
252
if((eventName == 'mouseenter' || eventName == 'mouseleave') && !mouseEnterSupported){
253
var item = mouseCache[el.id],
254
ev = item && item[eventName];
258
delete item[eventName];
259
eventName = (eventName == 'mouseenter') ? 'mouseover' : 'mouseout';
262
Event.stopObserving(el, eventName, fn, false);
265
purgeElement : function(el){
269
preventDefault : function(e){ // missing from prototype?
270
e = e.browserEvent || e;
271
if(e.preventDefault) {
274
e.returnValue = false;
278
stopPropagation : function(e){ // missing from prototype?
279
e = e.browserEvent || e;
280
if(e.stopPropagation) {
283
e.cancelBubble = true;
287
stopEvent : function(e){
288
Event.stop(e.browserEvent || e);
291
onAvailable : function(id, fn, scope){ // no equiv
292
var start = new Date(), iid;
294
if(start.getElapsed() > 10000){
297
var el = document.getElementById(id);
300
fn.call(scope||window, el);
303
iid = setInterval(f, 50);
307
Ext.lib.Ajax = function(){
308
var createSuccess = function(cb){
309
return cb.success ? function(xhr){
310
cb.success.call(cb.scope||window, createResponse(cb, xhr));
313
var createFailure = function(cb){
314
return cb.failure ? function(xhr){
315
cb.failure.call(cb.scope||window, createResponse(cb, xhr));
318
var createResponse = function(cb, xhr){
325
headerStr = xhr.getAllResponseHeaders();
326
Ext.each(headerStr.replace(/\r\n/g, '\n').split('\n'), function(v){
329
s = v.substr(0, t).toLowerCase();
330
if(v.charAt(t + 1) == ' '){
333
headerObj[s] = v.substr(t + 1);
339
responseText: xhr.responseText,
340
responseXML : xhr.responseXML,
341
argument: cb.argument,
343
statusText: xhr.statusText,
344
getResponseHeader : function(header){return headerObj[header.toLowerCase()];},
345
getAllResponseHeaders : function(){return headerStr}
349
request : function(method, uri, cb, data, options){
352
parameters: data || '',
354
onSuccess: createSuccess(cb),
355
onFailure: createFailure(cb)
358
var hs = options.headers;
360
o.requestHeaders = hs;
363
method = (method ? method : (options.method ? options.method : 'POST'));
364
if (!hs || !hs['Content-Type']){
365
o.contentType = 'text/xml';
367
o.postBody = options.xmlData;
370
if(options.jsonData){
371
method = (method ? method : (options.method ? options.method : 'POST'));
372
if (!hs || !hs['Content-Type']){
373
o.contentType = 'application/json';
375
o.postBody = typeof options.jsonData == 'object' ? Ext.encode(options.jsonData) : options.jsonData;
379
new Ajax.Request(uri, o);
382
formRequest : function(form, uri, cb, data, isUpload, sslUri){
383
new Ajax.Request(uri, {
384
method: Ext.getDom(form).method ||'POST',
385
parameters: Form.serialize(form)+(data?'&'+data:''),
387
onSuccess: createSuccess(cb),
388
onFailure: createFailure(cb)
392
isCallInProgress : function(trans){
396
abort : function(trans){
400
serializeForm : function(form){
401
return Form.serialize(form.dom||form);
407
Ext.lib.Anim = function(){
410
easeOut: function(pos) {
411
return 1-Math.pow(1-pos,2);
413
easeIn: function(pos) {
414
return 1-Math.pow(1-pos,2);
417
var createAnim = function(cb, scope){
419
stop : function(skipToLast){
420
this.effect.cancel();
423
isAnimated : function(){
424
return this.effect.state == 'running';
427
proxyCallback : function(){
428
Ext.callback(cb, scope);
433
scroll : function(el, args, duration, easing, cb, scope){
434
// not supported so scroll immediately?
435
var anim = createAnim(cb, scope);
437
if(typeof args.scroll.to[0] == 'number'){
438
el.scrollLeft = args.scroll.to[0];
440
if(typeof args.scroll.to[1] == 'number'){
441
el.scrollTop = args.scroll.to[1];
443
anim.proxyCallback();
447
motion : function(el, args, duration, easing, cb, scope){
448
return this.run(el, args, duration, easing, cb, scope);
451
color : function(el, args, duration, easing, cb, scope){
452
return this.run(el, args, duration, easing, cb, scope);
455
run : function(el, args, duration, easing, cb, scope, type){
458
switch(k){ // scriptaculous doesn't support, so convert these
460
var by, pts, e = Ext.fly(el, '_animrun');
462
if(by = args.points.by){
464
pts = e.translatePoints([xy[0]+by[0], xy[1]+by[1]]);
466
pts = e.translatePoints(args.points.to);
468
o.left = pts.left+'px';
469
o.top = pts.top+'px';
472
o.width = args.width.to+'px';
475
o.height = args.height.to+'px';
478
o.opacity = String(args.opacity.to);
481
o[k] = String(args[k].to);
485
var anim = createAnim(cb, scope);
486
anim.effect = new Effect.Morph(Ext.id(el), {
488
afterFinish: anim.proxyCallback,
489
transition: easings[easing] || Effect.Transitions.linear,
498
// all lib flyweight calls use their own flyweight to prevent collisions with developer flyweights
501
libFlyweight = new Ext.Element.Flyweight();
503
libFlyweight.dom = el;
507
Ext.lib.Region = function(t, r, b, l) {
516
Ext.lib.Region.prototype = {
517
contains : function(region) {
518
return ( region.left >= this.left &&
519
region.right <= this.right &&
520
region.top >= this.top &&
521
region.bottom <= this.bottom );
525
getArea : function() {
526
return ( (this.bottom - this.top) * (this.right - this.left) );
529
intersect : function(region) {
530
var t = Math.max( this.top, region.top );
531
var r = Math.min( this.right, region.right );
532
var b = Math.min( this.bottom, region.bottom );
533
var l = Math.max( this.left, region.left );
535
if (b >= t && r >= l) {
536
return new Ext.lib.Region(t, r, b, l);
541
union : function(region) {
542
var t = Math.min( this.top, region.top );
543
var r = Math.max( this.right, region.right );
544
var b = Math.max( this.bottom, region.bottom );
545
var l = Math.min( this.left, region.left );
547
return new Ext.lib.Region(t, r, b, l);
550
constrainTo : function(r) {
551
this.top = this.top.constrain(r.top, r.bottom);
552
this.bottom = this.bottom.constrain(r.top, r.bottom);
553
this.left = this.left.constrain(r.left, r.right);
554
this.right = this.right.constrain(r.left, r.right);
558
adjust : function(t, l, b, r){
567
Ext.lib.Region.getRegion = function(el) {
568
var p = Ext.lib.Dom.getXY(el);
571
var r = p[0] + el.offsetWidth;
572
var b = p[1] + el.offsetHeight;
575
return new Ext.lib.Region(t, r, b, l);
578
Ext.lib.Point = function(x, y) {
579
if (Ext.isArray(x)) {
583
this.x = this.right = this.left = this[0] = x;
584
this.y = this.top = this.bottom = this[1] = y;
587
Ext.lib.Point.prototype = new Ext.lib.Region();
592
function fnCleanUp() {
593
var p = Function.prototype;
594
delete p.createSequence;
596
delete p.createDelegate;
597
delete p.createCallback;
598
delete p.createInterceptor;
600
window.detachEvent("onunload", fnCleanUp);
602
window.attachEvent("onunload", fnCleanUp);
b'\\ No newline at end of file'