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">if(typeof jQuery == "undefined"){
10 throw "Unable to load Ext, jQuery not found.";
17 getViewWidth : function(full){
18 // jQuery doesn't report full window size on document query, so max both
19 return full ? Math.max(jQuery(document).width(),jQuery(window).width()) : jQuery(window).width();
22 getViewHeight : function(full){
23 // jQuery doesn't report full window size on document query, so max both
24 return full ? Math.max(jQuery(document).height(),jQuery(window).height()) : jQuery(window).height();
27 isAncestor : function(p, c){
35 } else if (p.compareDocumentPosition) {
36 return !!(p.compareDocumentPosition(c) & 16);
38 while (c = c.parentNode) {
46 getRegion : function(el){
47 return Ext.lib.Region.getRegion(el);
50 //////////////////////////////////////////////////////////////////////////////////////
51 // Use of jQuery.offset() removed to promote consistent behavior across libs.
53 //////////////////////////////////////////////////////////////////////////////////////
56 return this.getXY(el)[1];
60 return this.getXY(el)[0];
63 getXY : function(el) {
64 var p, pe, b, scroll, bd = (document.body || document.documentElement);
71 if (el.getBoundingClientRect) {
72 b = el.getBoundingClientRect();
73 scroll = fly(document).getScroll();
74 return [Math.round(b.left + scroll.left), Math.round(b.top + scroll.top)];
80 var hasAbsolute = fly(el).getStyle("position") == "absolute";
87 if (!hasAbsolute && fly(p).getStyle("position") == "absolute") {
94 var bt = parseInt(pe.getStyle("borderTopWidth"), 10) || 0;
95 var bl = parseInt(pe.getStyle("borderLeftWidth"), 10) || 0;
102 if (p != el && pe.getStyle('overflow') != 'visible') {
110 if (Ext.isSafari && hasAbsolute) {
115 if (Ext.isGecko && !hasAbsolute) {
117 x += parseInt(dbd.getStyle("borderLeftWidth"), 10) || 0;
118 y += parseInt(dbd.getStyle("borderTopWidth"), 10) || 0;
122 while (p && p != bd) {
123 if (!Ext.isOpera || (p.tagName != 'TR' && fly(p).getStyle("display") != "inline")) {
132 setXY : function(el, xy){
133 el = Ext.fly(el, '_setXY');
135 var pts = el.translatePoints(xy);
137 el.dom.style.left = pts.left + "px";
140 el.dom.style.top = pts.top + "px";
144 setX : function(el, x){
145 this.setXY(el, [x, false]);
148 setY : function(el, y){
149 this.setXY(el, [false, y]);
153 // all lib flyweight calls use their own flyweight to prevent collisions with developer flyweights
156 libFlyweight = new Ext.Element.Flyweight();
158 libFlyweight.dom = el;
162 getPageX : function(e){
163 e = e.browserEvent || e;
167 getPageY : function(e){
168 e = e.browserEvent || e;
173 e = e.browserEvent || e;
174 return [e.pageX, e.pageY];
177 getTarget : function(e){
181 // all Ext events will go through event manager which provides scoping
182 on : function(el, eventName, fn, scope, override){
183 jQuery(el).bind(eventName, fn);
186 un : function(el, eventName, fn){
187 jQuery(el).unbind(eventName, fn);
190 purgeElement : function(el){
194 preventDefault : function(e){
195 e = e.browserEvent || e;
196 if(e.preventDefault){
199 e.returnValue = false;
203 stopPropagation : function(e){
204 e = e.browserEvent || e;
205 if(e.stopPropagation){
208 e.cancelBubble = true;
212 stopEvent : function(e){
213 this.preventDefault(e);
214 this.stopPropagation(e);
217 onAvailable : function(id, fn, scope){
218 var start = new Date();
220 if(start.getElapsed() > 10000){
223 var el = document.getElementById(id);
226 fn.call(scope||window, el);
229 var iid = setInterval(f, 50);
232 resolveTextNode: Ext.isGecko ? function(node){
236 var s = HTMLElement.prototype.toString.call(node);
237 if(s == '[xpconnect wrapped native prototype]' || s == '[object XULElement]'){
240 return node.nodeType == 3 ? node.parentNode : node;
242 return node && node.nodeType == 3 ? node.parentNode : node;
245 getRelatedTarget: function(ev) {
246 ev = ev.browserEvent || ev;
247 var t = ev.relatedTarget;
249 if (ev.type == "mouseout") {
251 } else if (ev.type == "mouseover") {
256 return this.resolveTextNode(t);
260 Ext.lib.Ajax = function(){
261 var createComplete = function(cb){
262 return function(xhr, status){
263 if((status == 'error' || status == 'timeout') && cb.failure){
264 cb.failure.call(cb.scope||window, createResponse(cb, xhr));
265 }else if(cb.success){
266 cb.success.call(cb.scope||window, createResponse(cb, xhr));
271 var createResponse = function(cb, xhr){
278 headerStr = xhr.getAllResponseHeaders();
279 Ext.each(headerStr.replace(/\r\n/g, '\n').split('\n'), function(v){
282 s = v.substr(0, t).toLowerCase();
283 if(v.charAt(t + 1) == ' '){
286 headerObj[s] = v.substr(t + 1);
292 responseText: xhr.responseText,
293 responseXML : xhr.responseXML,
294 argument: cb.argument,
296 statusText: xhr.statusText,
297 getResponseHeader : function(header){return headerObj[header.toLowerCase()];},
298 getAllResponseHeaders : function(){return headerStr}
302 request : function(method, uri, cb, data, options){
308 complete: createComplete(cb)
312 var hs = options.headers;
314 o.data = options.xmlData;
315 o.processData = false;
316 o.type = (method ? method : (options.method ? options.method : 'POST'));
317 if (!hs || !hs['Content-Type']){
318 o.contentType = 'text/xml';
320 }else if(options.jsonData){
321 o.data = typeof options.jsonData == 'object' ? Ext.encode(options.jsonData) : options.jsonData;
322 o.processData = false;
323 o.type = (method ? method : (options.method ? options.method : 'POST'));
324 if (!hs || !hs['Content-Type']){
325 o.contentType = 'application/json';
329 o.beforeSend = function(xhr){
331 if(hs.hasOwnProperty(h)){
332 xhr.setRequestHeader(h, hs[h]);
341 formRequest : function(form, uri, cb, data, isUpload, sslUri){
343 type: Ext.getDom(form).method ||'POST',
345 data: jQuery(form).serialize()+(data?'&'+data:''),
347 complete: createComplete(cb)
351 isCallInProgress : function(trans){
355 abort : function(trans){
359 serializeForm : function(form){
360 return jQuery(form.dom||form).serialize();
365 Ext.lib.Anim = function(){
366 var createAnim = function(cb, scope){
369 stop : function(skipToLast){
373 isAnimated : function(){
377 proxyCallback : function(){
379 Ext.callback(cb, scope);
384 scroll : function(el, args, duration, easing, cb, scope){
385 // scroll anim not supported so just scroll immediately
386 var anim = createAnim(cb, scope);
388 if(typeof args.scroll.to[0] == 'number'){
389 el.scrollLeft = args.scroll.to[0];
391 if(typeof args.scroll.to[1] == 'number'){
392 el.scrollTop = args.scroll.to[1];
394 anim.proxyCallback();
398 motion : function(el, args, duration, easing, cb, scope){
399 return this.run(el, args, duration, easing, cb, scope);
402 color : function(el, args, duration, easing, cb, scope){
403 // color anim not supported, so execute callback immediately
404 var anim = createAnim(cb, scope);
405 anim.proxyCallback();
409 run : function(el, args, duration, easing, cb, scope, type){
410 var anim = createAnim(cb, scope), e = Ext.fly(el, '_animrun');
413 switch(k){ // jquery doesn't support, so convert
417 if(by = args.points.by){
419 pts = e.translatePoints([xy[0]+by[0], xy[1]+by[1]]);
421 pts = e.translatePoints(args.points.to);
425 if(!parseInt(e.getStyle('left'), 10)){ // auto bug
428 if(!parseInt(e.getStyle('top'), 10)){
431 if(args.points.from){
432 e.setXY(args.points.from);
436 o.width = args.width.to;
438 e.setWidth(args.width.from);
441 o.height = args.height.to;
442 if (args.height.from)
443 e.setHeight(args.height.from);
446 o.opacity = args.opacity.to;
447 if (args.opacity.from)
448 e.setOpacity(args.opacity.from);
451 o.left = args.left.to;
453 e.setLeft(args.left.from);
458 e.setTop(args.top.from);
462 // jQuery can't handle callback and scope arguments, so break here
468 e.setStyle(k, args[k].from);
472 // TODO: find out about easing plug in?
473 jQuery(el).animate(o, duration*1000, undefined, anim.proxyCallback);
480 Ext.lib.Region = function(t, r, b, l) {
489 Ext.lib.Region.prototype = {
490 contains : function(region) {
491 return ( region.left >= this.left &&
492 region.right <= this.right &&
493 region.top >= this.top &&
494 region.bottom <= this.bottom );
498 getArea : function() {
499 return ( (this.bottom - this.top) * (this.right - this.left) );
502 intersect : function(region) {
503 var t = Math.max( this.top, region.top );
504 var r = Math.min( this.right, region.right );
505 var b = Math.min( this.bottom, region.bottom );
506 var l = Math.max( this.left, region.left );
508 if (b >= t && r >= l) {
509 return new Ext.lib.Region(t, r, b, l);
514 union : function(region) {
515 var t = Math.min( this.top, region.top );
516 var r = Math.max( this.right, region.right );
517 var b = Math.max( this.bottom, region.bottom );
518 var l = Math.min( this.left, region.left );
520 return new Ext.lib.Region(t, r, b, l);
523 constrainTo : function(r) {
524 this.top = this.top.constrain(r.top, r.bottom);
525 this.bottom = this.bottom.constrain(r.top, r.bottom);
526 this.left = this.left.constrain(r.left, r.right);
527 this.right = this.right.constrain(r.left, r.right);
531 adjust : function(t, l, b, r){
540 Ext.lib.Region.getRegion = function(el) {
541 var p = Ext.lib.Dom.getXY(el);
544 var r = p[0] + el.offsetWidth;
545 var b = p[1] + el.offsetHeight;
548 return new Ext.lib.Region(t, r, b, l);
551 Ext.lib.Point = function(x, y) {
552 if (Ext.isArray(x)) {
556 this.x = this.right = this.left = this[0] = x;
557 this.y = this.top = this.bottom = this[1] = y;
560 Ext.lib.Point.prototype = new Ext.lib.Region();
564 function fnCleanUp() {
565 var p = Function.prototype;
566 delete p.createSequence;
568 delete p.createDelegate;
569 delete p.createCallback;
570 delete p.createInterceptor;
572 window.detachEvent("onunload", fnCleanUp);
574 window.attachEvent("onunload", fnCleanUp);