3 <title>The source code</title>
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7 <body onload="prettyPrint();">
8 <pre class="prettyprint lang-js">/*!
10 * Copyright(c) 2006-2009 Ext JS, LLC
12 * http://www.extjs.com/license
14 if(typeof jQuery == "undefined"){
15 throw "Unable to load Ext, jQuery not found.";
22 getViewWidth : function(full){
23 // jQuery doesn't report full window size on document query, so max both
24 return full ? Math.max(jQuery(document).width(),jQuery(window).width()) : jQuery(window).width();
27 getViewHeight : function(full){
28 // jQuery doesn't report full window size on document query, so max both
29 return full ? Math.max(jQuery(document).height(),jQuery(window).height()) : jQuery(window).height();
32 isAncestor : function(p, c){
40 } else if (p.compareDocumentPosition) {
41 return !!(p.compareDocumentPosition(c) & 16);
43 while (c = c.parentNode) {
51 getRegion : function(el){
52 return Ext.lib.Region.getRegion(el);
55 //////////////////////////////////////////////////////////////////////////////////////
56 // Use of jQuery.offset() removed to promote consistent behavior across libs.
58 //////////////////////////////////////////////////////////////////////////////////////
61 return this.getXY(el)[1];
65 return this.getXY(el)[0];
68 getXY : function(el) {
69 var p, pe, b, scroll, bd = (document.body || document.documentElement);
76 if (el.getBoundingClientRect) {
77 b = el.getBoundingClientRect();
78 scroll = fly(document).getScroll();
79 return [Math.round(b.left + scroll.left), Math.round(b.top + scroll.top)];
85 var hasAbsolute = fly(el).getStyle("position") == "absolute";
92 if (!hasAbsolute && fly(p).getStyle("position") == "absolute") {
99 var bt = parseInt(pe.getStyle("borderTopWidth"), 10) || 0;
100 var bl = parseInt(pe.getStyle("borderLeftWidth"), 10) || 0;
107 if (p != el && pe.getStyle('overflow') != 'visible') {
115 if (Ext.isSafari && hasAbsolute) {
120 if (Ext.isGecko && !hasAbsolute) {
122 x += parseInt(dbd.getStyle("borderLeftWidth"), 10) || 0;
123 y += parseInt(dbd.getStyle("borderTopWidth"), 10) || 0;
127 while (p && p != bd) {
128 if (!Ext.isOpera || (p.tagName != 'TR' && fly(p).getStyle("display") != "inline")) {
137 setXY : function(el, xy){
138 el = Ext.fly(el, '_setXY');
140 var pts = el.translatePoints(xy);
142 el.dom.style.left = pts.left + "px";
145 el.dom.style.top = pts.top + "px";
149 setX : function(el, x){
150 this.setXY(el, [x, false]);
153 setY : function(el, y){
154 this.setXY(el, [false, y]);
158 // all lib flyweight calls use their own flyweight to prevent collisions with developer flyweights
161 libFlyweight = new Ext.Element.Flyweight();
163 libFlyweight.dom = el;
167 getPageX : function(e){
168 e = e.browserEvent || e;
172 getPageY : function(e){
173 e = e.browserEvent || e;
178 e = e.browserEvent || e;
179 return [e.pageX, e.pageY];
182 getTarget : function(e){
186 // all Ext events will go through event manager which provides scoping
187 on : function(el, eventName, fn, scope, override){
188 jQuery(el).bind(eventName, fn);
191 un : function(el, eventName, fn){
192 jQuery(el).unbind(eventName, fn);
195 purgeElement : function(el){
199 preventDefault : function(e){
200 e = e.browserEvent || e;
201 if(e.preventDefault){
204 e.returnValue = false;
208 stopPropagation : function(e){
209 e = e.browserEvent || e;
210 if(e.stopPropagation){
213 e.cancelBubble = true;
217 stopEvent : function(e){
218 this.preventDefault(e);
219 this.stopPropagation(e);
222 onAvailable : function(id, fn, scope){
223 var start = new Date();
225 if(start.getElapsed() > 10000){
228 var el = document.getElementById(id);
231 fn.call(scope||window, el);
234 var iid = setInterval(f, 50);
237 resolveTextNode: Ext.isGecko ? function(node){
241 var s = HTMLElement.prototype.toString.call(node);
242 if(s == '[xpconnect wrapped native prototype]' || s == '[object XULElement]'){
245 return node.nodeType == 3 ? node.parentNode : node;
247 return node && node.nodeType == 3 ? node.parentNode : node;
250 getRelatedTarget: function(ev) {
251 ev = ev.browserEvent || ev;
252 var t = ev.relatedTarget;
254 if (ev.type == "mouseout") {
256 } else if (ev.type == "mouseover") {
261 return this.resolveTextNode(t);
265 Ext.lib.Ajax = function(){
266 var createComplete = function(cb){
267 return function(xhr, status){
268 if((status == 'error' || status == 'timeout') && cb.failure){
269 cb.failure.call(cb.scope||window, createResponse(cb, xhr));
270 }else if(cb.success){
271 cb.success.call(cb.scope||window, createResponse(cb, xhr));
276 var createResponse = function(cb, xhr){
283 headerStr = xhr.getAllResponseHeaders();
284 Ext.each(headerStr.replace(/\r\n/g, '\n').split('\n'), function(v){
287 s = v.substr(0, t).toLowerCase();
288 if(v.charAt(t + 1) == ' '){
291 headerObj[s] = v.substr(t + 1);
297 responseText: xhr.responseText,
298 responseXML : xhr.responseXML,
299 argument: cb.argument,
301 statusText: xhr.statusText,
302 getResponseHeader : function(header){return headerObj[header.toLowerCase()];},
303 getAllResponseHeaders : function(){return headerStr}
307 request : function(method, uri, cb, data, options){
313 complete: createComplete(cb)
317 var hs = options.headers;
319 o.data = options.xmlData;
320 o.processData = false;
321 o.type = (method ? method : (options.method ? options.method : 'POST'));
322 if (!hs || !hs['Content-Type']){
323 o.contentType = 'text/xml';
325 }else if(options.jsonData){
326 o.data = typeof options.jsonData == 'object' ? Ext.encode(options.jsonData) : options.jsonData;
327 o.processData = false;
328 o.type = (method ? method : (options.method ? options.method : 'POST'));
329 if (!hs || !hs['Content-Type']){
330 o.contentType = 'application/json';
334 o.beforeSend = function(xhr){
336 if(hs.hasOwnProperty(h)){
337 xhr.setRequestHeader(h, hs[h]);
346 formRequest : function(form, uri, cb, data, isUpload, sslUri){
348 type: Ext.getDom(form).method ||'POST',
350 data: jQuery(form).serialize()+(data?'&'+data:''),
352 complete: createComplete(cb)
356 isCallInProgress : function(trans){
360 abort : function(trans){
364 serializeForm : function(form){
365 return jQuery(form.dom||form).serialize();
370 Ext.lib.Anim = function(){
371 var createAnim = function(cb, scope){
374 stop : function(skipToLast){
378 isAnimated : function(){
382 proxyCallback : function(){
384 Ext.callback(cb, scope);
389 scroll : function(el, args, duration, easing, cb, scope){
390 // scroll anim not supported so just scroll immediately
391 var anim = createAnim(cb, scope);
393 if(typeof args.scroll.to[0] == 'number'){
394 el.scrollLeft = args.scroll.to[0];
396 if(typeof args.scroll.to[1] == 'number'){
397 el.scrollTop = args.scroll.to[1];
399 anim.proxyCallback();
403 motion : function(el, args, duration, easing, cb, scope){
404 return this.run(el, args, duration, easing, cb, scope);
407 color : function(el, args, duration, easing, cb, scope){
408 // color anim not supported, so execute callback immediately
409 var anim = createAnim(cb, scope);
410 anim.proxyCallback();
414 run : function(el, args, duration, easing, cb, scope, type){
415 var anim = createAnim(cb, scope), e = Ext.fly(el, '_animrun');
418 switch(k){ // jquery doesn't support, so convert
422 if(by = args.points.by){
424 pts = e.translatePoints([xy[0]+by[0], xy[1]+by[1]]);
426 pts = e.translatePoints(args.points.to);
430 if(!parseInt(e.getStyle('left'), 10)){ // auto bug
433 if(!parseInt(e.getStyle('top'), 10)){
436 if(args.points.from){
437 e.setXY(args.points.from);
441 o.width = args.width.to;
443 e.setWidth(args.width.from);
446 o.height = args.height.to;
447 if (args.height.from)
448 e.setHeight(args.height.from);
451 o.opacity = args.opacity.to;
452 if (args.opacity.from)
453 e.setOpacity(args.opacity.from);
456 o.left = args.left.to;
458 e.setLeft(args.left.from);
463 e.setTop(args.top.from);
467 // jQuery can't handle callback and scope arguments, so break here
473 e.setStyle(k, args[k].from);
477 // TODO: find out about easing plug in?
478 jQuery(el).animate(o, duration*1000, undefined, anim.proxyCallback);
485 Ext.lib.Region = function(t, r, b, l) {
494 Ext.lib.Region.prototype = {
495 contains : function(region) {
496 return ( region.left >= this.left &&
497 region.right <= this.right &&
498 region.top >= this.top &&
499 region.bottom <= this.bottom );
503 getArea : function() {
504 return ( (this.bottom - this.top) * (this.right - this.left) );
507 intersect : function(region) {
508 var t = Math.max( this.top, region.top );
509 var r = Math.min( this.right, region.right );
510 var b = Math.min( this.bottom, region.bottom );
511 var l = Math.max( this.left, region.left );
513 if (b >= t && r >= l) {
514 return new Ext.lib.Region(t, r, b, l);
519 union : function(region) {
520 var t = Math.min( this.top, region.top );
521 var r = Math.max( this.right, region.right );
522 var b = Math.max( this.bottom, region.bottom );
523 var l = Math.min( this.left, region.left );
525 return new Ext.lib.Region(t, r, b, l);
528 constrainTo : function(r) {
529 this.top = this.top.constrain(r.top, r.bottom);
530 this.bottom = this.bottom.constrain(r.top, r.bottom);
531 this.left = this.left.constrain(r.left, r.right);
532 this.right = this.right.constrain(r.left, r.right);
536 adjust : function(t, l, b, r){
545 Ext.lib.Region.getRegion = function(el) {
546 var p = Ext.lib.Dom.getXY(el);
549 var r = p[0] + el.offsetWidth;
550 var b = p[1] + el.offsetHeight;
553 return new Ext.lib.Region(t, r, b, l);
556 Ext.lib.Point = function(x, y) {
557 if (Ext.isArray(x)) {
561 this.x = this.right = this.left = this[0] = x;
562 this.y = this.top = this.bottom = this[1] = y;
565 Ext.lib.Point.prototype = new Ext.lib.Region();
569 function fnCleanUp() {
570 var p = Function.prototype;
571 delete p.createSequence;
573 delete p.createDelegate;
574 delete p.createCallback;
575 delete p.createInterceptor;
577 window.detachEvent("onunload", fnCleanUp);
579 window.attachEvent("onunload", fnCleanUp);