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.3.1
11 * Copyright(c) 2006-2010 Sencha Inc.
12 * licensing@sencha.com
13 * http://www.sencha.com/license
18 version = Prototype.Version.split('.'),
19 mouseEnterSupported = (parseInt(version[0], 10) >= 2) || (parseInt(version[1], 10) >= 7) || (parseInt(version[2], 10) >= 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){
353 return headerObj[header.toLowerCase()];
355 getAllResponseHeaders : function(){
361 request : function(method, uri, cb, data, options){
364 parameters: data || '',
366 onSuccess: createSuccess(cb),
367 onFailure: createFailure(cb)
370 var hs = options.headers;
372 o.requestHeaders = hs;
375 method = (method ? method : (options.method ? options.method : 'POST'));
376 if (!hs || !hs['Content-Type']){
377 o.contentType = 'text/xml';
379 o.postBody = options.xmlData;
382 if(options.jsonData){
383 method = (method ? method : (options.method ? options.method : 'POST'));
384 if (!hs || !hs['Content-Type']){
385 o.contentType = 'application/json';
387 o.postBody = typeof options.jsonData == 'object' ? Ext.encode(options.jsonData) : options.jsonData;
391 new Ajax.Request(uri, o);
394 formRequest : function(form, uri, cb, data, isUpload, sslUri){
395 new Ajax.Request(uri, {
396 method: Ext.getDom(form).method ||'POST',
397 parameters: Form.serialize(form)+(data?'&'+data:''),
399 onSuccess: createSuccess(cb),
400 onFailure: createFailure(cb)
404 isCallInProgress : function(trans){
408 abort : function(trans){
412 serializeForm : function(form){
413 return Form.serialize(form.dom||form);
419 Ext.lib.Anim = function(){
422 easeOut: function(pos) {
423 return 1-Math.pow(1-pos,2);
425 easeIn: function(pos) {
426 return 1-Math.pow(1-pos,2);
429 var createAnim = function(cb, scope){
431 stop : function(skipToLast){
432 this.effect.cancel();
435 isAnimated : function(){
436 return this.effect.state == 'running';
439 proxyCallback : function(){
440 Ext.callback(cb, scope);
445 scroll : function(el, args, duration, easing, cb, scope){
446 // not supported so scroll immediately?
447 var anim = createAnim(cb, scope);
449 if(typeof args.scroll.to[0] == 'number'){
450 el.scrollLeft = args.scroll.to[0];
452 if(typeof args.scroll.to[1] == 'number'){
453 el.scrollTop = args.scroll.to[1];
455 anim.proxyCallback();
459 motion : function(el, args, duration, easing, cb, scope){
460 return this.run(el, args, duration, easing, cb, scope);
463 color : function(el, args, duration, easing, cb, scope){
464 return this.run(el, args, duration, easing, cb, scope);
467 run : function(el, args, duration, easing, cb, scope, type){
470 switch(k){ // scriptaculous doesn't support, so convert these
472 var by, pts, e = Ext.fly(el, '_animrun');
474 if(by = args.points.by){
476 pts = e.translatePoints([xy[0]+by[0], xy[1]+by[1]]);
478 pts = e.translatePoints(args.points.to);
480 o.left = pts.left+'px';
481 o.top = pts.top+'px';
484 o.width = args.width.to+'px';
487 o.height = args.height.to+'px';
490 o.opacity = String(args.opacity.to);
493 o[k] = String(args[k].to);
497 var anim = createAnim(cb, scope);
498 anim.effect = new Effect.Morph(Ext.id(el), {
500 afterFinish: anim.proxyCallback,
501 transition: easings[easing] || Effect.Transitions.linear,
510 // all lib flyweight calls use their own flyweight to prevent collisions with developer flyweights
513 libFlyweight = new Ext.Element.Flyweight();
515 libFlyweight.dom = el;
519 Ext.lib.Region = function(t, r, b, l) {
528 Ext.lib.Region.prototype = {
529 contains : function(region) {
530 return ( region.left >= this.left &&
531 region.right <= this.right &&
532 region.top >= this.top &&
533 region.bottom <= this.bottom );
537 getArea : function() {
538 return ( (this.bottom - this.top) * (this.right - this.left) );
541 intersect : function(region) {
542 var t = Math.max( this.top, region.top );
543 var r = Math.min( this.right, region.right );
544 var b = Math.min( this.bottom, region.bottom );
545 var l = Math.max( this.left, region.left );
547 if (b >= t && r >= l) {
548 return new Ext.lib.Region(t, r, b, l);
553 union : function(region) {
554 var t = Math.min( this.top, region.top );
555 var r = Math.max( this.right, region.right );
556 var b = Math.max( this.bottom, region.bottom );
557 var l = Math.min( this.left, region.left );
559 return new Ext.lib.Region(t, r, b, l);
562 constrainTo : function(r) {
563 this.top = this.top.constrain(r.top, r.bottom);
564 this.bottom = this.bottom.constrain(r.top, r.bottom);
565 this.left = this.left.constrain(r.left, r.right);
566 this.right = this.right.constrain(r.left, r.right);
570 adjust : function(t, l, b, r){
579 Ext.lib.Region.getRegion = function(el) {
580 var p = Ext.lib.Dom.getXY(el);
583 var r = p[0] + el.offsetWidth;
584 var b = p[1] + el.offsetHeight;
587 return new Ext.lib.Region(t, r, b, l);
590 Ext.lib.Point = function(x, y) {
591 if (Ext.isArray(x)) {
595 this.x = this.right = this.left = this[0] = x;
596 this.y = this.top = this.bottom = this[1] = y;
599 Ext.lib.Point.prototype = new Ext.lib.Region();
604 function fnCleanUp() {
605 var p = Function.prototype;
606 delete p.createSequence;
608 delete p.createDelegate;
609 delete p.createCallback;
610 delete p.createInterceptor;
612 window.detachEvent("onunload", fnCleanUp);
614 window.attachEvent("onunload", fnCleanUp);