webgui/www/extras/yui-ext/docs/output/yui-bridge.jss.html
2007-07-05 04:23:55 +00:00

297 lines
No EOL
9.6 KiB
HTML

<html><head><title>yui-bridge.js</title><link rel="stylesheet" type="text/css" href="../resources/style.css" media="screen"/></head><body><h1>yui-bridge.js</h1><pre class="highlighted"><code>if(<b>typeof</b> YAHOO == &quot;undefined&quot;){
throw &quot;Unable to load Ext, core YUI utilities (yahoo, dom, event) not found.&quot;;
}
(<b>function</b>(){
<b>var</b> E = YAHOO.util.Event;
<b>var</b> D = YAHOO.util.Dom;
<b>var</b> CN = YAHOO.util.Connect;
<b>var</b> ES = YAHOO.util.Easing;
<b>var</b> A = YAHOO.util.Anim;
<b>var</b> libFlyweight;
Ext.lib.Dom = {
getViewWidth : <b>function</b>(full){
<b>return</b> full ? D.getDocumentWidth() : D.getViewportWidth();
},
getViewHeight : <b>function</b>(full){
<b>return</b> full ? D.getDocumentHeight() : D.getViewportHeight();
},
isAncestor : <b>function</b>(haystack, needle){
<b>return</b> D.isAncestor(haystack, needle);
},
getRegion : <b>function</b>(el){
<b>return</b> D.getRegion(el);
},
getY : <b>function</b>(el){
<b>return</b> this.getXY(el)[1];
},
getX : <b>function</b>(el){
<b>return</b> this.getXY(el)[0];
},
<i>// original version based on YahooUI getXY</i>
<i>// <b>this</b> version fixes several issues <b>in</b> Safari and FF</i>
<i>// and boosts performance by removing the batch overhead, repetitive dom lookups and array index calls</i>
getXY : <b>function</b>(el){
<b>var</b> p, pe, b, scroll, bd = document.body;
el = Ext.getDom(el);
<b>if</b>(el.getBoundingClientRect){ <i>// IE</i>
b = el.getBoundingClientRect();
scroll = fly(document).getScroll();
<b>return</b> [b.left + scroll.left, b.top + scroll.top];
} <b>else</b>{
<b>var</b> x = el.offsetLeft, y = el.offsetTop;
p = el.offsetParent;
<i>// ** flag <b>if</b> a parent is positioned <b>for</b> Safari</i>
<b>var</b> hasAbsolute = false;
<b>if</b>(p != el){
<b>while</b>(p){
x += p.offsetLeft;
y += p.offsetTop;
<i>// ** flag Safari abs position bug - only check <b>if</b> needed</i>
<b>if</b>(Ext.isSafari &amp;&amp; !hasAbsolute &amp;&amp; fly(p).getStyle(&quot;position&quot;) == &quot;absolute&quot;){
hasAbsolute = true;
}
<i>// ** Fix gecko borders measurements</i>
<i>// Credit jQuery dimensions plugin <b>for</b> the workaround</i>
<b>if</b>(Ext.isGecko){
pe = fly(p);
<b>var</b> bt = parseInt(pe.getStyle(&quot;borderTopWidth&quot;), 10) || 0;
<b>var</b> bl = parseInt(pe.getStyle(&quot;borderLeftWidth&quot;), 10) || 0;
<i>// add borders to offset</i>
x += bl;
y += bt;
<i>// Mozilla removes the border <b>if</b> the parent has overflow property other than visible</i>
<b>if</b>(p != el &amp;&amp; pe.getStyle('overflow') != 'visible'){
x += bl;
y += bt;
}
}
p = p.offsetParent;
}
}
<i>// ** safari doubles <b>in</b> some cases, use flag from offsetParent's as well</i>
<b>if</b>(Ext.isSafari &amp;&amp; (hasAbsolute || fly(el).getStyle(&quot;position&quot;) == &quot;absolute&quot;)){
x -= bd.offsetLeft;
y -= bd.offsetTop;
}
}
p = el.parentNode;
<b>while</b>(p &amp;&amp; p != bd){
<i>// ** opera TR has bad scroll values, so filter them jvs</i>
<b>if</b>(!Ext.isOpera || (Ext.isOpera &amp;&amp; p.tagName != 'TR' &amp;&amp; fly(p).getStyle(&quot;display&quot;) != &quot;inline&quot;)){
x -= p.scrollLeft;
y -= p.scrollTop;
}
p = p.parentNode;
}
<b>return</b> [x, y];
},
setXY : <b>function</b>(el, xy){
el = Ext.fly(el, '_setXY');
el.position();
<b>var</b> pts = el.translatePoints(xy);
<b>if</b>(xy[0] !== false){
el.dom.style.left = pts.left + &quot;px&quot;;
}
<b>if</b>(xy[1] !== false){
el.dom.style.top = pts.top + &quot;px&quot;;
}
},
setX : <b>function</b>(el, x){
<b>this</b>.setXY(el, [x, false]);
},
setY : <b>function</b>(el, y){
<b>this</b>.setXY(el, [false, y]);
}
};
Ext.lib.Event = {
getPageX : <b>function</b>(e){
<b>return</b> E.getPageX(e.browserEvent || e);
},
getPageY : <b>function</b>(e){
<b>return</b> E.getPageY(e.browserEvent || e);
},
getXY : <b>function</b>(e){
<b>return</b> E.getXY(e.browserEvent || e);
},
getTarget : <b>function</b>(e){
<b>return</b> E.getTarget(e.browserEvent || e);
},
getRelatedTarget : <b>function</b>(e){
<b>return</b> E.getRelatedTarget(e.browserEvent || e);
},
on : <b>function</b>(el, eventName, fn, scope, override){
E.on(el, eventName, fn, scope, override);
},
un : <b>function</b>(el, eventName, fn){
E.removeListener(el, eventName, fn);
},
purgeElement : <b>function</b>(el){
E.purgeElement(el);
},
preventDefault : <b>function</b>(e){
E.preventDefault(e.browserEvent || e);
},
stopPropagation : <b>function</b>(e){
E.stopPropagation(e.browserEvent || e);
},
stopEvent : <b>function</b>(e){
E.stopEvent(e.browserEvent || e);
},
onAvailable : <b>function</b>(el, fn, scope, override){
<b>return</b> E.onAvailable(el, fn, scope, override);
}
};
Ext.lib.Ajax = {
request : <b>function</b>(method, uri, cb, data){
<b>return</b> CN.asyncRequest(method, uri, cb, data);
},
formRequest : <b>function</b>(form, uri, cb, data, isUpload, sslUri){
CN.setForm(form, isUpload, sslUri);
<b>return</b> CN.asyncRequest(Ext.getDom(form).method ||'POST', uri, cb, data);
},
isCallInProgress : <b>function</b>(trans){
<b>return</b> CN.isCallInProgress(trans);
},
abort : <b>function</b>(trans){
<b>return</b> CN.abort(trans);
},
serializeForm : <b>function</b>(form){
<b>var</b> d = CN.setForm(form.dom || form);
CN.resetFormState();
<b>return</b> d;
}
};
Ext.lib.Region = YAHOO.util.Region;
Ext.lib.Point = YAHOO.util.Point;
Ext.lib.Anim = {
scroll : <b>function</b>(el, args, duration, easing, cb, scope){
<b>this</b>.run(el, args, duration, easing, cb, scope, YAHOO.util.Scroll);
},
motion : <b>function</b>(el, args, duration, easing, cb, scope){
<b>this</b>.run(el, args, duration, easing, cb, scope, YAHOO.util.Motion);
},
color : <b>function</b>(el, args, duration, easing, cb, scope){
<b>this</b>.run(el, args, duration, easing, cb, scope, YAHOO.util.ColorAnim);
},
run : <b>function</b>(el, args, duration, easing, cb, scope, type){
type = type || YAHOO.util.Anim;
<b>if</b>(typeof easing == &quot;string&quot;){
easing = YAHOO.util.Easing[easing];
}
<b>var</b> anim = <b>new</b> type(el, args, duration, easing);
anim.animateX(<b>function</b>(){
Ext.callback(cb, scope);
});
<b>return</b> anim;
}
};
<i>// all lib flyweight calls use their own flyweight to prevent collisions <b>with</b> developer flyweights</i>
<b>function</b> fly(el){
<b>if</b>(!libFlyweight){
libFlyweight = <b>new</b> Ext.Element.Flyweight();
}
libFlyweight.dom = el;
<b>return</b> libFlyweight;
}
<i>// prevent IE leaks</i>
<b>if</b>(Ext.isIE){
YAHOO.util.Event.on(window, &quot;unload&quot;, <b>function</b>(){
<b>var</b> p = Function.prototype;
<b>delete</b> p.createSequence;
<b>delete</b> p.defer;
<b>delete</b> p.createDelegate;
<b>delete</b> p.createCallback;
<b>delete</b> p.createInterceptor;
});
}
<i>// various overrides</i>
<i>// add ability <b>for</b> callbacks <b>with</b> animations</i>
<b>if</b>(YAHOO.util.Anim){
YAHOO.util.Anim.prototype.animateX = <b>function</b>(callback, scope){
<b>var</b> f = <b>function</b>(){
<b>this</b>.onComplete.unsubscribe(f);
<b>if</b>(typeof callback == &quot;<b>function</b>&quot;){
callback.call(scope || <b>this</b>, <b>this</b>);
}
};
<b>this</b>.onComplete.subscribe(f, <b>this</b>, true);
<b>this</b>.animate();
};
}
<b>if</b>(YAHOO.util.DragDrop &amp;&amp; Ext.dd.DragDrop){
YAHOO.util.DragDrop.defaultPadding = Ext.dd.DragDrop.defaultPadding;
YAHOO.util.DragDrop.constrainTo = Ext.dd.DragDrop.constrainTo;
}
YAHOO.util.Dom.getXY = <b>function</b>(el) {
<b>var</b> f = <b>function</b>(el) {
<b>return</b> Ext.lib.Dom.getXY(el);
};
<b>return</b> YAHOO.util.Dom.batch(el, f, YAHOO.util.Dom, true);
};
<i>// workaround <b>for</b> Safari anim duration speed problems</i>
<b>if</b>(YAHOO.util.AnimMgr){
YAHOO.util.AnimMgr.fps = 1000;
}
YAHOO.util.Region.prototype.adjust = <b>function</b>(t, l, b, r){
<b>this</b>.top += t;
<b>this</b>.left += l;
<b>this</b>.right += r;
<b>this</b>.bottom += b;
<b>return</b> this;
};
})();</code></pre><hr><div style="font-size:10px;text-align:center;color:gray;">Ext - Copyright &copy; 2006-2007 Ext JS, LLC<br />All rights reserved.</div>
</body></html>