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 YAHOO == "undefined"){
10 throw "Unable to load Ext, core YUI utilities (yahoo, dom, event) not found.";
14 var E = YAHOO.util.Event,
16 CN = YAHOO.util.Connect,
17 ES = YAHOO.util.Easing,
20 version = YAHOO.env.getVersion('yahoo').version.split('.'),
21 mouseEnterSupported = parseInt(version[0]) >= 3,
23 elContains = function(parent, child){
24 if(parent && parent.firstChild){
29 child = child.parentNode;
30 if(child && (child.nodeType != 1)){
36 }, checkRelatedTarget = function(e){
37 return !elContains(e.currentTarget, Ext.lib.Event.getRelatedTarget(e));
41 getViewWidth : function(full){
42 return full ? D.getDocumentWidth() : D.getViewportWidth();
45 getViewHeight : function(full){
46 return full ? D.getDocumentHeight() : D.getViewportHeight();
49 isAncestor : function(haystack, needle){
50 return D.isAncestor(haystack, needle);
53 getRegion : function(el){
54 return D.getRegion(el);
58 return this.getXY(el)[1];
62 return this.getXY(el)[0];
65 // original version based on YahooUI getXY
66 // this version fixes several issues in Safari and FF
67 // and boosts performance by removing the batch overhead, repetitive dom lookups and array index calls
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]);
159 getPageX : function(e){
160 return E.getPageX(e.browserEvent || e);
163 getPageY : function(e){
164 return E.getPageY(e.browserEvent || e);
168 return E.getXY(e.browserEvent || e);
171 getTarget : function(e){
172 return E.getTarget(e.browserEvent || e);
175 getRelatedTarget : function(e){
176 return E.getRelatedTarget(e.browserEvent || e);
179 on : function(el, eventName, fn, scope, override){
180 if((eventName == 'mouseenter' || eventName == 'mouseleave') && !mouseEnterSupported){
181 var item = mouseCache[el.id] || (mouseCache[el.id] = {});
182 item[eventName] = fn;
183 fn = fn.createInterceptor(checkRelatedTarget);
184 eventName = (eventName == 'mouseenter') ? 'mouseover' : 'mouseout';
186 E.on(el, eventName, fn, scope, override);
189 un : function(el, eventName, fn){
190 if((eventName == 'mouseenter' || eventName == 'mouseleave') && !mouseEnterSupported){
191 var item = mouseCache[el.id],
192 ev = item && item[eventName];
196 delete item[eventName];
197 eventName = (eventName == 'mouseenter') ? 'mouseover' : 'mouseout';
200 E.removeListener(el, eventName, fn);;
203 purgeElement : function(el){
207 preventDefault : function(e){
208 E.preventDefault(e.browserEvent || e);
211 stopPropagation : function(e){
212 E.stopPropagation(e.browserEvent || e);
215 stopEvent : function(e){
216 E.stopEvent(e.browserEvent || e);
219 onAvailable : function(el, fn, scope, override){
220 return E.onAvailable(el, fn, scope, override);
225 request : function(method, uri, cb, data, options){
227 var hs = options.headers;
230 if(hs.hasOwnProperty(h)){
231 CN.initHeader(h, hs[h], false);
236 if (!hs || !hs['Content-Type']){
237 CN.initHeader('Content-Type', 'text/xml', false);
239 method = (method ? method : (options.method ? options.method : 'POST'));
240 data = options.xmlData;
241 }else if(options.jsonData){
242 if (!hs || !hs['Content-Type']){
243 CN.initHeader('Content-Type', 'application/json', false);
245 method = (method ? method : (options.method ? options.method : 'POST'));
246 data = typeof options.jsonData == 'object' ? Ext.encode(options.jsonData) : options.jsonData;
249 return CN.asyncRequest(method, uri, cb, data);
252 formRequest : function(form, uri, cb, data, isUpload, sslUri){
253 CN.setForm(form, isUpload, sslUri);
254 return CN.asyncRequest(Ext.getDom(form).method ||'POST', uri, cb, data);
257 isCallInProgress : function(trans){
258 return CN.isCallInProgress(trans);
261 abort : function(trans){
262 return CN.abort(trans);
265 serializeForm : function(form){
266 var d = CN.setForm(form.dom || form);
272 Ext.lib.Region = YAHOO.util.Region;
273 Ext.lib.Point = YAHOO.util.Point;
277 scroll : function(el, args, duration, easing, cb, scope){
278 this.run(el, args, duration, easing, cb, scope, YAHOO.util.Scroll);
281 motion : function(el, args, duration, easing, cb, scope){
282 this.run(el, args, duration, easing, cb, scope, YAHOO.util.Motion);
285 color : function(el, args, duration, easing, cb, scope){
286 this.run(el, args, duration, easing, cb, scope, YAHOO.util.ColorAnim);
289 run : function(el, args, duration, easing, cb, scope, type){
290 type = type || YAHOO.util.Anim;
291 if(typeof easing == "string"){
292 easing = YAHOO.util.Easing[easing];
294 var anim = new type(el, args, duration, easing);
295 anim.animateX(function(){
296 Ext.callback(cb, scope);
302 // all lib flyweight calls use their own flyweight to prevent collisions with developer flyweights
305 libFlyweight = new Ext.Element.Flyweight();
307 libFlyweight.dom = el;
313 function fnCleanUp() {
314 var p = Function.prototype;
315 delete p.createSequence;
317 delete p.createDelegate;
318 delete p.createCallback;
319 delete p.createInterceptor;
321 window.detachEvent("onunload", fnCleanUp);
323 window.attachEvent("onunload", fnCleanUp);
327 // add ability for callbacks with animations
329 YAHOO.util.Anim.prototype.animateX = function(callback, scope){
331 this.onComplete.unsubscribe(f);
332 if(typeof callback == "function"){
333 callback.call(scope || this, this);
336 this.onComplete.subscribe(f, this, true);
341 if(YAHOO.util.DragDrop && Ext.dd.DragDrop){
342 YAHOO.util.DragDrop.defaultPadding = Ext.dd.DragDrop.defaultPadding;
343 YAHOO.util.DragDrop.constrainTo = Ext.dd.DragDrop.constrainTo;
346 YAHOO.util.Dom.getXY = function(el) {
347 var f = function(el) {
348 return Ext.lib.Dom.getXY(el);
350 return YAHOO.util.Dom.batch(el, f, YAHOO.util.Dom, true);
354 // workaround for Safari anim duration speed problems
355 if(YAHOO.util.AnimMgr){
356 YAHOO.util.AnimMgr.fps = 1000;
359 YAHOO.util.Region.prototype.adjust = function(t, l, b, r){
367 YAHOO.util.Region.prototype.constrainTo = function(r) {
368 this.top = this.top.constrain(r.top, r.bottom);
369 this.bottom = this.bottom.constrain(r.top, r.bottom);
370 this.left = this.left.constrain(r.left, r.right);
371 this.right = this.right.constrain(r.left, r.right);