3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js">if(typeof jQuery == "undefined"){
9 throw "Unable to load Ext, jQuery not found.";
16 getViewWidth : function(full){
17 // jQuery doesn't report full window size on document query, so max both
18 return full ? Math.max(jQuery(document).width(),jQuery(window).width()) : jQuery(window).width();
21 getViewHeight : function(full){
22 // jQuery doesn't report full window size on document query, so max both
23 return full ? Math.max(jQuery(document).height(),jQuery(window).height()) : jQuery(window).height();
26 isAncestor : function(p, c){
29 if (!p || !c) {return false;}
31 if(p.contains && !Ext.isSafari) {
33 }else if(p.compareDocumentPosition) {
34 return !!(p.compareDocumentPosition(c) & 16);
36 var parent = c.parentNode;
41 else if (!parent.tagName || parent.tagName.toUpperCase() == "HTML") {
44 parent = parent.parentNode;
50 getRegion : function(el){
51 return Ext.lib.Region.getRegion(el);
54 //////////////////////////////////////////////////////////////////////////////////////
55 // Use of jQuery.offset() removed to promote consistent behavior across libs.
57 //////////////////////////////////////////////////////////////////////////////////////
60 return this.getXY(el)[1];
64 return this.getXY(el)[0];
67 getXY : function(el) {
68 var p, pe, b, scroll, bd = (document.body || document.documentElement);
75 if (el.getBoundingClientRect) {
76 b = el.getBoundingClientRect();
77 scroll = fly(document).getScroll();
78 return [Math.round(b.left + scroll.left), Math.round(b.top + scroll.top)];
84 var hasAbsolute = fly(el).getStyle("position") == "absolute";
91 if (!hasAbsolute && fly(p).getStyle("position") == "absolute") {
98 var bt = parseInt(pe.getStyle("borderTopWidth"), 10) || 0;
99 var bl = parseInt(pe.getStyle("borderLeftWidth"), 10) || 0;
106 if (p != el && pe.getStyle('overflow') != 'visible') {
114 if (Ext.isSafari && hasAbsolute) {
119 if (Ext.isGecko && !hasAbsolute) {
121 x += parseInt(dbd.getStyle("borderLeftWidth"), 10) || 0;
122 y += parseInt(dbd.getStyle("borderTopWidth"), 10) || 0;
126 while (p && p != bd) {
127 if (!Ext.isOpera || (p.tagName != 'TR' && fly(p).getStyle("display") != "inline")) {
136 setXY : function(el, xy){
137 el = Ext.fly(el, '_setXY');
139 var pts = el.translatePoints(xy);
141 el.dom.style.left = pts.left + "px";
144 el.dom.style.top = pts.top + "px";
148 setX : function(el, x){
149 this.setXY(el, [x, false]);
152 setY : function(el, y){
153 this.setXY(el, [false, y]);
157 // all lib flyweight calls use their own flyweight to prevent collisions with developer flyweights
160 libFlyweight = new Ext.Element.Flyweight();
162 libFlyweight.dom = el;
166 getPageX : function(e){
167 e = e.browserEvent || e;
171 getPageY : function(e){
172 e = e.browserEvent || e;
177 e = e.browserEvent || e;
178 return [e.pageX, e.pageY];
181 getTarget : function(e){
185 // all Ext events will go through event manager which provides scoping
186 on : function(el, eventName, fn, scope, override){
187 jQuery(el).bind(eventName, fn);
190 un : function(el, eventName, fn){
191 jQuery(el).unbind(eventName, fn);
194 purgeElement : function(el){
198 preventDefault : function(e){
199 e = e.browserEvent || e;
200 if(e.preventDefault){
203 e.returnValue = false;
207 stopPropagation : function(e){
208 e = e.browserEvent || e;
209 if(e.stopPropagation){
212 e.cancelBubble = true;
216 stopEvent : function(e){
217 this.preventDefault(e);
218 this.stopPropagation(e);
221 onAvailable : function(id, fn, scope){
222 var start = new Date();
224 if(start.getElapsed() > 10000){
227 var el = document.getElementById(id);
230 fn.call(scope||window, el);
233 var iid = setInterval(f, 50);
236 resolveTextNode: function(node) {
237 if (node && 3 == node.nodeType) {
238 return node.parentNode;
244 getRelatedTarget: function(ev) {
245 ev = ev.browserEvent || ev;
246 var t = ev.relatedTarget;
248 if (ev.type == "mouseout") {
250 } else if (ev.type == "mouseover") {
255 return this.resolveTextNode(t);
259 Ext.lib.Ajax = function(){
260 var createComplete = function(cb){
261 return function(xhr, status){
262 if((status == 'error' || status == 'timeout') && cb.failure){
263 cb.failure.call(cb.scope||window, {
264 responseText: xhr.responseText,
265 responseXML : xhr.responseXML,
266 argument: cb.argument
268 }else if(cb.success){
269 cb.success.call(cb.scope||window, {
270 responseText: xhr.responseText,
271 responseXML : xhr.responseXML,
272 argument: cb.argument
278 request : function(method, uri, cb, data, options){
284 complete: createComplete(cb)
288 var hs = options.headers;
290 o.data = options.xmlData;
291 o.processData = false;
292 o.type = (method ? method : (options.method ? options.method : 'POST'));
293 if (!hs || !hs['Content-Type']){
294 o.contentType = 'text/xml';
296 }else if(options.jsonData){
297 o.data = typeof options.jsonData == 'object' ? Ext.encode(options.jsonData) : options.jsonData;
298 o.processData = false;
299 o.type = (method ? method : (options.method ? options.method : 'POST'));
300 if (!hs || !hs['Content-Type']){
301 o.contentType = 'application/json';
305 o.beforeSend = function(xhr){
307 if(hs.hasOwnProperty(h)){
308 xhr.setRequestHeader(h, hs[h]);
317 formRequest : function(form, uri, cb, data, isUpload, sslUri){
319 type: Ext.getDom(form).method ||'POST',
321 data: jQuery(form).serialize()+(data?'&'+data:''),
323 complete: createComplete(cb)
327 isCallInProgress : function(trans){
331 abort : function(trans){
335 serializeForm : function(form){
336 return jQuery(form.dom||form).serialize();
341 Ext.lib.Anim = function(){
342 var createAnim = function(cb, scope){
345 stop : function(skipToLast){
349 isAnimated : function(){
353 proxyCallback : function(){
355 Ext.callback(cb, scope);
360 scroll : function(el, args, duration, easing, cb, scope){
361 // scroll anim not supported so just scroll immediately
362 var anim = createAnim(cb, scope);
364 if(typeof args.scroll.to[0] == 'number'){
365 el.scrollLeft = args.scroll.to[0];
367 if(typeof args.scroll.to[1] == 'number'){
368 el.scrollTop = args.scroll.to[1];
370 anim.proxyCallback();
374 motion : function(el, args, duration, easing, cb, scope){
375 return this.run(el, args, duration, easing, cb, scope);
378 color : function(el, args, duration, easing, cb, scope){
379 // color anim not supported, so execute callback immediately
380 var anim = createAnim(cb, scope);
381 anim.proxyCallback();
385 run : function(el, args, duration, easing, cb, scope, type){
386 var anim = createAnim(cb, scope), e = Ext.fly(el, '_animrun');
389 switch(k){ // jquery doesn't support, so convert
393 if(by = args.points.by){
395 pts = e.translatePoints([xy[0]+by[0], xy[1]+by[1]]);
397 pts = e.translatePoints(args.points.to);
401 if(!parseInt(e.getStyle('left'), 10)){ // auto bug
404 if(!parseInt(e.getStyle('top'), 10)){
407 if(args.points.from){
408 e.setXY(args.points.from);
412 o.width = args.width.to;
414 e.setWidth(args.width.from);
417 o.height = args.height.to;
418 if (args.height.from)
419 e.setHeight(args.height.from);
422 o.opacity = args.opacity.to;
423 if (args.opacity.from)
424 e.setOpacity(args.opacity.from);
427 o.left = args.left.to;
429 e.setLeft(args.left.from);
434 e.setTop(args.top.from);
439 e.setStyle(k, args[k].from);
443 // TODO: find out about easing plug in?
444 jQuery(el).animate(o, duration*1000, undefined, anim.proxyCallback);
451 Ext.lib.Region = function(t, r, b, l) {
460 Ext.lib.Region.prototype = {
461 contains : function(region) {
462 return ( region.left >= this.left &&
463 region.right <= this.right &&
464 region.top >= this.top &&
465 region.bottom <= this.bottom );
469 getArea : function() {
470 return ( (this.bottom - this.top) * (this.right - this.left) );
473 intersect : function(region) {
474 var t = Math.max( this.top, region.top );
475 var r = Math.min( this.right, region.right );
476 var b = Math.min( this.bottom, region.bottom );
477 var l = Math.max( this.left, region.left );
479 if (b >= t && r >= l) {
480 return new Ext.lib.Region(t, r, b, l);
485 union : function(region) {
486 var t = Math.min( this.top, region.top );
487 var r = Math.max( this.right, region.right );
488 var b = Math.max( this.bottom, region.bottom );
489 var l = Math.min( this.left, region.left );
491 return new Ext.lib.Region(t, r, b, l);
494 constrainTo : function(r) {
495 this.top = this.top.constrain(r.top, r.bottom);
496 this.bottom = this.bottom.constrain(r.top, r.bottom);
497 this.left = this.left.constrain(r.left, r.right);
498 this.right = this.right.constrain(r.left, r.right);
502 adjust : function(t, l, b, r){
511 Ext.lib.Region.getRegion = function(el) {
512 var p = Ext.lib.Dom.getXY(el);
515 var r = p[0] + el.offsetWidth;
516 var b = p[1] + el.offsetHeight;
519 return new Ext.lib.Region(t, r, b, l);
522 Ext.lib.Point = function(x, y) {
523 if (Ext.isArray(x)) {
527 this.x = this.right = this.left = this[0] = x;
528 this.y = this.top = this.bottom = this[1] = y;
531 Ext.lib.Point.prototype = new Ext.lib.Region();
535 function fnCleanUp() {
536 var p = Function.prototype;
537 delete p.createSequence;
539 delete p.createDelegate;
540 delete p.createCallback;
541 delete p.createInterceptor;
543 window.detachEvent("onunload", fnCleanUp);
545 window.attachEvent("onunload", fnCleanUp);