3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.2.1
11 * Copyright(c) 2006-2010 Ext JS, Inc.
13 * http://www.extjs.com/license
18 version = Prototype.Version.split('.'),
19 mouseEnterSupported = (parseInt(version[0]) >= 2) || (parseInt(version[1]) >= 7) || (parseInt(version[2]) >= 1),
21 elContains = function(parent, child) {
22 if(parent && parent.firstChild){
24 if(child === parent) {
27 child = child.parentNode;
28 if(child && (child.nodeType != 1)) {
35 checkRelatedTarget = function(e) {
36 return !elContains(e.currentTarget, Ext.lib.Event.getRelatedTarget(e));
40 getViewWidth : function(full){
41 return full ? this.getDocumentWidth() : this.getViewportWidth();
44 getViewHeight : function(full){
45 return full ? this.getDocumentHeight() : this.getViewportHeight();
48 getDocumentHeight: function() { // missing from prototype?
49 var scrollHeight = (document.compatMode != "CSS1Compat") ? document.body.scrollHeight : document.documentElement.scrollHeight;
50 return Math.max(scrollHeight, this.getViewportHeight());
53 getDocumentWidth: function() { // missing from prototype?
54 var scrollWidth = (document.compatMode != "CSS1Compat") ? document.body.scrollWidth : document.documentElement.scrollWidth;
55 return Math.max(scrollWidth, this.getViewportWidth());
58 getViewportHeight: function() { // missing from prototype?
59 var height = self.innerHeight;
60 var mode = document.compatMode;
62 if ( (mode || Ext.isIE) && !Ext.isOpera ) {
63 height = (mode == "CSS1Compat") ?
64 document.documentElement.clientHeight : // Standards
65 document.body.clientHeight; // Quirks
71 getViewportWidth: function() { // missing from prototype?
72 var width = self.innerWidth; // Safari
73 var mode = document.compatMode;
75 if (mode || Ext.isIE) { // IE, Gecko, Opera
76 width = (mode == "CSS1Compat") ?
77 document.documentElement.clientWidth : // Standards
78 document.body.clientWidth; // Quirks
83 isAncestor : function(p, c){ // missing from prototype?
91 } else if (p.compareDocumentPosition) {
92 return !!(p.compareDocumentPosition(c) & 16);
94 while (c = c.parentNode) {
102 getRegion : function(el){
103 return Ext.lib.Region.getRegion(el);
107 return this.getXY(el)[1];
111 return this.getXY(el)[0];
114 getXY : function(el){ // this initially used Position.cumulativeOffset but it is not accurate enough
115 var p, pe, b, scroll, bd = (document.body || document.documentElement);
122 if (el.getBoundingClientRect) {
123 b = el.getBoundingClientRect();
124 scroll = fly(document).getScroll();
125 return [Math.round(b.left + scroll.left), Math.round(b.top + scroll.top)];
131 var hasAbsolute = fly(el).getStyle("position") == "absolute";
138 if (!hasAbsolute && fly(p).getStyle("position") == "absolute") {
145 var bt = parseInt(pe.getStyle("borderTopWidth"), 10) || 0;
146 var bl = parseInt(pe.getStyle("borderLeftWidth"), 10) || 0;
153 if (p != el && pe.getStyle('overflow') != 'visible') {
161 if (Ext.isSafari && hasAbsolute) {
166 if (Ext.isGecko && !hasAbsolute) {
168 x += parseInt(dbd.getStyle("borderLeftWidth"), 10) || 0;
169 y += parseInt(dbd.getStyle("borderTopWidth"), 10) || 0;
173 while (p && p != bd) {
174 if (!Ext.isOpera || (p.tagName != 'TR' && fly(p).getStyle("display") != "inline")) {
183 setXY : function(el, xy){ // this initially used Position.cumulativeOffset but it is not accurate enough
184 el = Ext.fly(el, '_setXY');
186 var pts = el.translatePoints(xy);
188 el.dom.style.left = pts.left + "px";
191 el.dom.style.top = pts.top + "px";
195 setX : function(el, x){
196 this.setXY(el, [x, false]);
199 setY : function(el, y){
200 this.setXY(el, [false, y]);
205 getPageX : function(e){
206 return Event.pointerX(e.browserEvent || e);
209 getPageY : function(e){
210 return Event.pointerY(e.browserEvent || e);
214 e = e.browserEvent || e;
215 return [Event.pointerX(e), Event.pointerY(e)];
218 getTarget : function(e){
219 return Event.element(e.browserEvent || e);
222 resolveTextNode: Ext.isGecko ? function(node){
226 var s = HTMLElement.prototype.toString.call(node);
227 if(s == '[xpconnect wrapped native prototype]' || s == '[object XULElement]'){
230 return node.nodeType == 3 ? node.parentNode : node;
232 return node && node.nodeType == 3 ? node.parentNode : node;
235 getRelatedTarget: function(ev) { // missing from prototype?
236 ev = ev.browserEvent || ev;
237 var t = ev.relatedTarget;
239 if (ev.type == "mouseout") {
241 } else if (ev.type == "mouseover") {
246 return this.resolveTextNode(t);
249 on : function(el, eventName, fn){
250 if((eventName == 'mouseenter' || eventName == 'mouseleave') && !mouseEnterSupported){
251 var item = mouseCache[el.id] || (mouseCache[el.id] = {});
252 item[eventName] = fn;
253 fn = fn.createInterceptor(checkRelatedTarget);
254 eventName = (eventName == 'mouseenter') ? 'mouseover' : 'mouseout';
256 Event.observe(el, eventName, fn, false);
259 un : function(el, eventName, fn){
260 if((eventName == 'mouseenter' || eventName == 'mouseleave') && !mouseEnterSupported){
261 var item = mouseCache[el.id],
262 ev = item && item[eventName];
266 delete item[eventName];
267 eventName = (eventName == 'mouseenter') ? 'mouseover' : 'mouseout';
270 Event.stopObserving(el, eventName, fn, false);
273 purgeElement : function(el){
277 preventDefault : function(e){ // missing from prototype?
278 e = e.browserEvent || e;
279 if(e.preventDefault) {
282 e.returnValue = false;
286 stopPropagation : function(e){ // missing from prototype?
287 e = e.browserEvent || e;
288 if(e.stopPropagation) {
291 e.cancelBubble = true;
295 stopEvent : function(e){
296 Event.stop(e.browserEvent || e);
299 onAvailable : function(id, fn, scope){ // no equiv
300 var start = new Date(), iid;
302 if(start.getElapsed() > 10000){
305 var el = document.getElementById(id);
308 fn.call(scope||window, el);
311 iid = setInterval(f, 50);
315 Ext.lib.Ajax = function(){
316 var createSuccess = function(cb){
317 return cb.success ? function(xhr){
318 cb.success.call(cb.scope||window, createResponse(cb, xhr));
321 var createFailure = function(cb){
322 return cb.failure ? function(xhr){
323 cb.failure.call(cb.scope||window, createResponse(cb, xhr));
326 var createResponse = function(cb, xhr){
333 headerStr = xhr.getAllResponseHeaders();
334 Ext.each(headerStr.replace(/\r\n/g, '\n').split('\n'), function(v){
337 s = v.substr(0, t).toLowerCase();
338 if(v.charAt(t + 1) == ' '){
341 headerObj[s] = v.substr(t + 1);
347 responseText: xhr.responseText,
348 responseXML : xhr.responseXML,
349 argument: cb.argument,
351 statusText: xhr.statusText,
352 getResponseHeader : function(header){return headerObj[header.toLowerCase()];},
353 getAllResponseHeaders : function(){return headerStr}
357 request : function(method, uri, cb, data, options){
360 parameters: data || '',
362 onSuccess: createSuccess(cb),
363 onFailure: createFailure(cb)
366 var hs = options.headers;
368 o.requestHeaders = hs;
371 method = (method ? method : (options.method ? options.method : 'POST'));
372 if (!hs || !hs['Content-Type']){
373 o.contentType = 'text/xml';
375 o.postBody = options.xmlData;
378 if(options.jsonData){
379 method = (method ? method : (options.method ? options.method : 'POST'));
380 if (!hs || !hs['Content-Type']){
381 o.contentType = 'application/json';
383 o.postBody = typeof options.jsonData == 'object' ? Ext.encode(options.jsonData) : options.jsonData;
387 new Ajax.Request(uri, o);
390 formRequest : function(form, uri, cb, data, isUpload, sslUri){
391 new Ajax.Request(uri, {
392 method: Ext.getDom(form).method ||'POST',
393 parameters: Form.serialize(form)+(data?'&'+data:''),
395 onSuccess: createSuccess(cb),
396 onFailure: createFailure(cb)
400 isCallInProgress : function(trans){
404 abort : function(trans){
408 serializeForm : function(form){
409 return Form.serialize(form.dom||form);
415 Ext.lib.Anim = function(){
418 easeOut: function(pos) {
419 return 1-Math.pow(1-pos,2);
421 easeIn: function(pos) {
422 return 1-Math.pow(1-pos,2);
425 var createAnim = function(cb, scope){
427 stop : function(skipToLast){
428 this.effect.cancel();
431 isAnimated : function(){
432 return this.effect.state == 'running';
435 proxyCallback : function(){
436 Ext.callback(cb, scope);
441 scroll : function(el, args, duration, easing, cb, scope){
442 // not supported so scroll immediately?
443 var anim = createAnim(cb, scope);
445 if(typeof args.scroll.to[0] == 'number'){
446 el.scrollLeft = args.scroll.to[0];
448 if(typeof args.scroll.to[1] == 'number'){
449 el.scrollTop = args.scroll.to[1];
451 anim.proxyCallback();
455 motion : function(el, args, duration, easing, cb, scope){
456 return this.run(el, args, duration, easing, cb, scope);
459 color : function(el, args, duration, easing, cb, scope){
460 return this.run(el, args, duration, easing, cb, scope);
463 run : function(el, args, duration, easing, cb, scope, type){
466 switch(k){ // scriptaculous doesn't support, so convert these
468 var by, pts, e = Ext.fly(el, '_animrun');
470 if(by = args.points.by){
472 pts = e.translatePoints([xy[0]+by[0], xy[1]+by[1]]);
474 pts = e.translatePoints(args.points.to);
476 o.left = pts.left+'px';
477 o.top = pts.top+'px';
480 o.width = args.width.to+'px';
483 o.height = args.height.to+'px';
486 o.opacity = String(args.opacity.to);
489 o[k] = String(args[k].to);
493 var anim = createAnim(cb, scope);
494 anim.effect = new Effect.Morph(Ext.id(el), {
496 afterFinish: anim.proxyCallback,
497 transition: easings[easing] || Effect.Transitions.linear,
506 // all lib flyweight calls use their own flyweight to prevent collisions with developer flyweights
509 libFlyweight = new Ext.Element.Flyweight();
511 libFlyweight.dom = el;
515 Ext.lib.Region = function(t, r, b, l) {
524 Ext.lib.Region.prototype = {
525 contains : function(region) {
526 return ( region.left >= this.left &&
527 region.right <= this.right &&
528 region.top >= this.top &&
529 region.bottom <= this.bottom );
533 getArea : function() {
534 return ( (this.bottom - this.top) * (this.right - this.left) );
537 intersect : function(region) {
538 var t = Math.max( this.top, region.top );
539 var r = Math.min( this.right, region.right );
540 var b = Math.min( this.bottom, region.bottom );
541 var l = Math.max( this.left, region.left );
543 if (b >= t && r >= l) {
544 return new Ext.lib.Region(t, r, b, l);
549 union : function(region) {
550 var t = Math.min( this.top, region.top );
551 var r = Math.max( this.right, region.right );
552 var b = Math.max( this.bottom, region.bottom );
553 var l = Math.min( this.left, region.left );
555 return new Ext.lib.Region(t, r, b, l);
558 constrainTo : function(r) {
559 this.top = this.top.constrain(r.top, r.bottom);
560 this.bottom = this.bottom.constrain(r.top, r.bottom);
561 this.left = this.left.constrain(r.left, r.right);
562 this.right = this.right.constrain(r.left, r.right);
566 adjust : function(t, l, b, r){
575 Ext.lib.Region.getRegion = function(el) {
576 var p = Ext.lib.Dom.getXY(el);
579 var r = p[0] + el.offsetWidth;
580 var b = p[1] + el.offsetHeight;
583 return new Ext.lib.Region(t, r, b, l);
586 Ext.lib.Point = function(x, y) {
587 if (Ext.isArray(x)) {
591 this.x = this.right = this.left = this[0] = x;
592 this.y = this.top = this.bottom = this[1] = y;
595 Ext.lib.Point.prototype = new Ext.lib.Region();
600 function fnCleanUp() {
601 var p = Function.prototype;
602 delete p.createSequence;
604 delete p.createDelegate;
605 delete p.createCallback;
606 delete p.createInterceptor;
608 window.detachEvent("onunload", fnCleanUp);
610 window.attachEvent("onunload", fnCleanUp);