3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\r
4 <title>The source code</title>
\r
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
8 <body onload="prettyPrint();">
\r
9 <pre class="prettyprint lang-js">(function(){
12 version = Prototype.Version.split('.'),
13 mouseEnterSupported = (parseInt(version[0]) >= 2) || (parseInt(version[1]) >= 7) || (parseInt(version[2]) >= 1),
15 elContains = function(parent, child) {
16 if(parent && parent.firstChild){
18 if(child === parent) {
21 child = child.parentNode;
22 if(child && (child.nodeType != 1)) {
29 checkRelatedTarget = function(e) {
30 return !elContains(e.currentTarget, Ext.lib.Event.getRelatedTarget(e));
34 getViewWidth : function(full){
35 return full ? this.getDocumentWidth() : this.getViewportWidth();
38 getViewHeight : function(full){
39 return full ? this.getDocumentHeight() : this.getViewportHeight();
42 getDocumentHeight: function() { // missing from prototype?
43 var scrollHeight = (document.compatMode != "CSS1Compat") ? document.body.scrollHeight : document.documentElement.scrollHeight;
44 return Math.max(scrollHeight, this.getViewportHeight());
47 getDocumentWidth: function() { // missing from prototype?
48 var scrollWidth = (document.compatMode != "CSS1Compat") ? document.body.scrollWidth : document.documentElement.scrollWidth;
49 return Math.max(scrollWidth, this.getViewportWidth());
52 getViewportHeight: function() { // missing from prototype?
53 var height = self.innerHeight;
54 var mode = document.compatMode;
56 if ( (mode || Ext.isIE) && !Ext.isOpera ) {
57 height = (mode == "CSS1Compat") ?
58 document.documentElement.clientHeight : // Standards
59 document.body.clientHeight; // Quirks
65 getViewportWidth: function() { // missing from prototype?
66 var width = self.innerWidth; // Safari
67 var mode = document.compatMode;
69 if (mode || Ext.isIE) { // IE, Gecko, Opera
70 width = (mode == "CSS1Compat") ?
71 document.documentElement.clientWidth : // Standards
72 document.body.clientWidth; // Quirks
77 isAncestor : function(p, c){ // missing from prototype?
85 } else if (p.compareDocumentPosition) {
86 return !!(p.compareDocumentPosition(c) & 16);
88 while (c = c.parentNode) {
96 getRegion : function(el){
97 return Ext.lib.Region.getRegion(el);
101 return this.getXY(el)[1];
105 return this.getXY(el)[0];
108 getXY : function(el){ // this initially used Position.cumulativeOffset but it is not accurate enough
109 var p, pe, b, scroll, bd = (document.body || document.documentElement);
116 if (el.getBoundingClientRect) {
117 b = el.getBoundingClientRect();
118 scroll = fly(document).getScroll();
119 return [Math.round(b.left + scroll.left), Math.round(b.top + scroll.top)];
125 var hasAbsolute = fly(el).getStyle("position") == "absolute";
132 if (!hasAbsolute && fly(p).getStyle("position") == "absolute") {
139 var bt = parseInt(pe.getStyle("borderTopWidth"), 10) || 0;
140 var bl = parseInt(pe.getStyle("borderLeftWidth"), 10) || 0;
147 if (p != el && pe.getStyle('overflow') != 'visible') {
155 if (Ext.isSafari && hasAbsolute) {
160 if (Ext.isGecko && !hasAbsolute) {
162 x += parseInt(dbd.getStyle("borderLeftWidth"), 10) || 0;
163 y += parseInt(dbd.getStyle("borderTopWidth"), 10) || 0;
167 while (p && p != bd) {
168 if (!Ext.isOpera || (p.tagName != 'TR' && fly(p).getStyle("display") != "inline")) {
177 setXY : function(el, xy){ // this initially used Position.cumulativeOffset but it is not accurate enough
178 el = Ext.fly(el, '_setXY');
180 var pts = el.translatePoints(xy);
182 el.dom.style.left = pts.left + "px";
185 el.dom.style.top = pts.top + "px";
189 setX : function(el, x){
190 this.setXY(el, [x, false]);
193 setY : function(el, y){
194 this.setXY(el, [false, y]);
199 getPageX : function(e){
200 return Event.pointerX(e.browserEvent || e);
203 getPageY : function(e){
204 return Event.pointerY(e.browserEvent || e);
208 e = e.browserEvent || e;
209 return [Event.pointerX(e), Event.pointerY(e)];
212 getTarget : function(e){
213 return Event.element(e.browserEvent || e);
216 resolveTextNode: Ext.isGecko ? function(node){
220 var s = HTMLElement.prototype.toString.call(node);
221 if(s == '[xpconnect wrapped native prototype]' || s == '[object XULElement]'){
224 return node.nodeType == 3 ? node.parentNode : node;
226 return node && node.nodeType == 3 ? node.parentNode : node;
229 getRelatedTarget: function(ev) { // missing from prototype?
230 ev = ev.browserEvent || ev;
231 var t = ev.relatedTarget;
233 if (ev.type == "mouseout") {
235 } else if (ev.type == "mouseover") {
240 return this.resolveTextNode(t);
243 on : function(el, eventName, fn){
244 if((eventName == 'mouseenter' || eventName == 'mouseleave') && !mouseEnterSupported){
245 var item = mouseCache[el.id] || (mouseCache[el.id] = {});
246 item[eventName] = fn;
247 fn = fn.createInterceptor(checkRelatedTarget);
248 eventName = (eventName == 'mouseenter') ? 'mouseover' : 'mouseout';
250 Event.observe(el, eventName, fn, false);
253 un : function(el, eventName, fn){
254 if((eventName == 'mouseenter' || eventName == 'mouseleave') && !mouseEnterSupported){
255 var item = mouseCache[el.id],
256 ev = item && item[eventName];
260 delete item[eventName];
261 eventName = (eventName == 'mouseenter') ? 'mouseover' : 'mouseout';
264 Event.stopObserving(el, eventName, fn, false);
267 purgeElement : function(el){
271 preventDefault : function(e){ // missing from prototype?
272 e = e.browserEvent || e;
273 if(e.preventDefault) {
276 e.returnValue = false;
280 stopPropagation : function(e){ // missing from prototype?
281 e = e.browserEvent || e;
282 if(e.stopPropagation) {
285 e.cancelBubble = true;
289 stopEvent : function(e){
290 Event.stop(e.browserEvent || e);
293 onAvailable : function(id, fn, scope){ // no equiv
294 var start = new Date(), iid;
296 if(start.getElapsed() > 10000){
299 var el = document.getElementById(id);
302 fn.call(scope||window, el);
305 iid = setInterval(f, 50);
309 Ext.lib.Ajax = function(){
310 var createSuccess = function(cb){
311 return cb.success ? function(xhr){
312 cb.success.call(cb.scope||window, createResponse(cb, xhr));
315 var createFailure = function(cb){
316 return cb.failure ? function(xhr){
317 cb.failure.call(cb.scope||window, createResponse(cb, xhr));
320 var createResponse = function(cb, xhr){
327 headerStr = xhr.getAllResponseHeaders();
328 Ext.each(headerStr.replace(/\r\n/g, '\n').split('\n'), function(v){
331 s = v.substr(0, t).toLowerCase();
332 if(v.charAt(t + 1) == ' '){
335 headerObj[s] = v.substr(t + 1);
341 responseText: xhr.responseText,
342 responseXML : xhr.responseXML,
343 argument: cb.argument,
345 statusText: xhr.statusText,
346 getResponseHeader : function(header){return headerObj[header.toLowerCase()];},
347 getAllResponseHeaders : function(){return headerStr}
351 request : function(method, uri, cb, data, options){
354 parameters: data || '',
356 onSuccess: createSuccess(cb),
357 onFailure: createFailure(cb)
360 var hs = options.headers;
362 o.requestHeaders = hs;
365 method = (method ? method : (options.method ? options.method : 'POST'));
366 if (!hs || !hs['Content-Type']){
367 o.contentType = 'text/xml';
369 o.postBody = options.xmlData;
372 if(options.jsonData){
373 method = (method ? method : (options.method ? options.method : 'POST'));
374 if (!hs || !hs['Content-Type']){
375 o.contentType = 'application/json';
377 o.postBody = typeof options.jsonData == 'object' ? Ext.encode(options.jsonData) : options.jsonData;
381 new Ajax.Request(uri, o);
384 formRequest : function(form, uri, cb, data, isUpload, sslUri){
385 new Ajax.Request(uri, {
386 method: Ext.getDom(form).method ||'POST',
387 parameters: Form.serialize(form)+(data?'&'+data:''),
389 onSuccess: createSuccess(cb),
390 onFailure: createFailure(cb)
394 isCallInProgress : function(trans){
398 abort : function(trans){
402 serializeForm : function(form){
403 return Form.serialize(form.dom||form);
409 Ext.lib.Anim = function(){
412 easeOut: function(pos) {
413 return 1-Math.pow(1-pos,2);
415 easeIn: function(pos) {
416 return 1-Math.pow(1-pos,2);
419 var createAnim = function(cb, scope){
421 stop : function(skipToLast){
422 this.effect.cancel();
425 isAnimated : function(){
426 return this.effect.state == 'running';
429 proxyCallback : function(){
430 Ext.callback(cb, scope);
435 scroll : function(el, args, duration, easing, cb, scope){
436 // not supported so scroll immediately?
437 var anim = createAnim(cb, scope);
439 if(typeof args.scroll.to[0] == 'number'){
440 el.scrollLeft = args.scroll.to[0];
442 if(typeof args.scroll.to[1] == 'number'){
443 el.scrollTop = args.scroll.to[1];
445 anim.proxyCallback();
449 motion : function(el, args, duration, easing, cb, scope){
450 return this.run(el, args, duration, easing, cb, scope);
453 color : function(el, args, duration, easing, cb, scope){
454 return this.run(el, args, duration, easing, cb, scope);
457 run : function(el, args, duration, easing, cb, scope, type){
460 switch(k){ // scriptaculous doesn't support, so convert these
462 var by, pts, e = Ext.fly(el, '_animrun');
464 if(by = args.points.by){
466 pts = e.translatePoints([xy[0]+by[0], xy[1]+by[1]]);
468 pts = e.translatePoints(args.points.to);
470 o.left = pts.left+'px';
471 o.top = pts.top+'px';
474 o.width = args.width.to+'px';
477 o.height = args.height.to+'px';
480 o.opacity = String(args.opacity.to);
483 o[k] = String(args[k].to);
487 var anim = createAnim(cb, scope);
488 anim.effect = new Effect.Morph(Ext.id(el), {
490 afterFinish: anim.proxyCallback,
491 transition: easings[easing] || Effect.Transitions.linear,
500 // all lib flyweight calls use their own flyweight to prevent collisions with developer flyweights
503 libFlyweight = new Ext.Element.Flyweight();
505 libFlyweight.dom = el;
509 Ext.lib.Region = function(t, r, b, l) {
518 Ext.lib.Region.prototype = {
519 contains : function(region) {
520 return ( region.left >= this.left &&
521 region.right <= this.right &&
522 region.top >= this.top &&
523 region.bottom <= this.bottom );
527 getArea : function() {
528 return ( (this.bottom - this.top) * (this.right - this.left) );
531 intersect : function(region) {
532 var t = Math.max( this.top, region.top );
533 var r = Math.min( this.right, region.right );
534 var b = Math.min( this.bottom, region.bottom );
535 var l = Math.max( this.left, region.left );
537 if (b >= t && r >= l) {
538 return new Ext.lib.Region(t, r, b, l);
543 union : function(region) {
544 var t = Math.min( this.top, region.top );
545 var r = Math.max( this.right, region.right );
546 var b = Math.max( this.bottom, region.bottom );
547 var l = Math.min( this.left, region.left );
549 return new Ext.lib.Region(t, r, b, l);
552 constrainTo : function(r) {
553 this.top = this.top.constrain(r.top, r.bottom);
554 this.bottom = this.bottom.constrain(r.top, r.bottom);
555 this.left = this.left.constrain(r.left, r.right);
556 this.right = this.right.constrain(r.left, r.right);
560 adjust : function(t, l, b, r){
569 Ext.lib.Region.getRegion = function(el) {
570 var p = Ext.lib.Dom.getXY(el);
573 var r = p[0] + el.offsetWidth;
574 var b = p[1] + el.offsetHeight;
577 return new Ext.lib.Region(t, r, b, l);
580 Ext.lib.Point = function(x, y) {
581 if (Ext.isArray(x)) {
585 this.x = this.right = this.left = this[0] = x;
586 this.y = this.top = this.bottom = this[1] = y;
589 Ext.lib.Point.prototype = new Ext.lib.Region();
594 function fnCleanUp() {
595 var p = Function.prototype;
596 delete p.createSequence;
598 delete p.createDelegate;
599 delete p.createCallback;
600 delete p.createInterceptor;
602 window.detachEvent("onunload", fnCleanUp);
604 window.attachEvent("onunload", fnCleanUp);