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

391 lines
No EOL
13 KiB
HTML

<html><head><title>jquery-bridge.js</title><link rel="stylesheet" type="text/css" href="../resources/style.css" media="screen"/></head><body><h1>jquery-bridge.js</h1><pre class="highlighted"><code>if(<b>typeof</b> jQuery == &quot;undefined&quot;){
throw &quot;Unable to load Ext, jQuery not found.&quot;;
}
(<b>function</b>(){
Ext.lib.Dom = {
getViewWidth : <b>function</b>(full){
<i>// jQuery doesn't report full window size on document query, so max both</i>
<b>return</b> full ? Math.max(jQuery(document).width(),jQuery(window).width()) : jQuery(window).width();
},
getViewHeight : <b>function</b>(full){
<i>// jQuery doesn't report full window size on document query, so max both</i>
<b>return</b> full ? Math.max(jQuery(document).height(),jQuery(window).height()) : jQuery(window).height();
},
isAncestor : <b>function</b>(p, c){
p = Ext.getDom(p);
c = Ext.getDom(c);
<b>if</b> (!p || !c) {<b>return</b> false;}
<b>if</b>(p.contains &amp;&amp; !Ext.isSafari) {
<b>return</b> p.contains(c);
}<b>else</b> if(p.compareDocumentPosition) {
<b>return</b> !!(p.compareDocumentPosition(c) &amp; 16);
}<b>else</b>{
<b>var</b> parent = c.parentNode;
<b>while</b> (parent) {
<b>if</b> (parent == p) {
<b>return</b> true;
}
<b>else</b> if (!parent.tagName || parent.tagName.toUpperCase() == &quot;HTML&quot;) {
<b>return</b> false;
}
parent = parent.parentNode;
}
<b>return</b> false;
}
},
getRegion : <b>function</b>(el){
<b>return</b> Ext.lib.Region.getRegion(el);
},
getY : <b>function</b>(el){
<b>return</b> jQuery(el).offset({scroll:false}).top;
},
getX : <b>function</b>(el){
<b>return</b> jQuery(el).offset({scroll:false}).left;
},
getXY : <b>function</b>(el){
<b>var</b> o = jQuery(el).offset({scroll:false});
<b>return</b> [o.left, o.top];
},
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){
e = e.browserEvent || e;
<b>return</b> e.pageX;
},
getPageY : <b>function</b>(e){
e = e.browserEvent || e;
<b>return</b> e.pageY;
},
getXY : <b>function</b>(e){
e = e.browserEvent || e;
<b>return</b> [e.pageX, e.pageY];
},
getTarget : <b>function</b>(e){
<b>return</b> e.target;
},
<i>// all Ext events will go through event manager which provides scoping</i>
on : <b>function</b>(el, eventName, fn, scope, override){
jQuery(el).bind(eventName, fn);
},
un : <b>function</b>(el, eventName, fn){
jQuery(el).unbind(eventName, fn);
},
purgeElement : <b>function</b>(el){
jQuery(el).unbind();
},
preventDefault : <b>function</b>(e){
e = e.browserEvent || e;
e.preventDefault();
},
stopPropagation : <b>function</b>(e){
e = e.browserEvent || e;
e.stopPropagation();
},
stopEvent : <b>function</b>(e){
e = e.browserEvent || e;
e.preventDefault();
e.stopPropagation();
},
onAvailable : <b>function</b>(id, fn, scope){
<b>var</b> start = <b>new</b> Date();
<b>var</b> f = <b>function</b>(){
<b>if</b>(start.getElapsed() &gt; 10000){
clearInterval(iid);
}
<b>var</b> el = document.getElementById(id);
<b>if</b>(el){
clearInterval(iid);
fn.call(scope||window, el);
}
};
<b>var</b> iid = setInterval(f, 50);
},
resolveTextNode: <b>function</b>(node) {
<b>if</b> (node &amp;&amp; 3 == node.nodeType) {
<b>return</b> node.parentNode;
} <b>else</b> {
<b>return</b> node;
}
},
getRelatedTarget: <b>function</b>(ev) {
ev = ev.browserEvent || ev;
<b>var</b> t = ev.relatedTarget;
<b>if</b> (!t) {
<b>if</b> (ev.type == &quot;mouseout&quot;) {
t = ev.toElement;
} <b>else</b> if (ev.type == &quot;mouseover&quot;) {
t = ev.fromElement;
}
}
<b>return</b> this.resolveTextNode(t);
}
};
Ext.lib.Ajax = <b>function</b>(){
<b>var</b> createComplete = <b>function</b>(cb){
<b>return</b> function(xhr, status){
<b>if</b>((status == 'error' || status == 'timeout') &amp;&amp; cb.failure){
cb.failure.call(cb.scope||window, {
responseText: xhr.responseText,
responseXML : xhr.responseXML,
argument: cb.argument
});
}<b>else</b> if(cb.success){
cb.success.call(cb.scope||window, {
responseText: xhr.responseText,
responseXML : xhr.responseXML,
argument: cb.argument
});
}
};
};
<b>return</b> {
request : <b>function</b>(method, uri, cb, data){
jQuery.ajax({
type: method,
url: uri,
data: data,
timeout: cb.timeout,
complete: createComplete(cb)
});
},
formRequest : <b>function</b>(form, uri, cb, data, isUpload, sslUri){
jQuery.ajax({
type: Ext.getDom(form).method ||'POST',
url: uri,
data: jQuery(form).formSerialize()+(data?'&amp;'+data:''),
timeout: cb.timeout,
complete: createComplete(cb)
});
},
isCallInProgress : <b>function</b>(trans){
<b>return</b> false;
},
abort : <b>function</b>(trans){
<b>return</b> false;
},
serializeForm : <b>function</b>(form){
<b>return</b> jQuery(form.dom||form).formSerialize();
}
};
}();
Ext.lib.Anim = <b>function</b>(){
<b>var</b> createAnim = <b>function</b>(cb, scope){
<b>var</b> animated = true;
<b>return</b> {
stop : <b>function</b>(skipToLast){
<i>// <b>do</b> nothing</i>
},
isAnimated : <b>function</b>(){
<b>return</b> animated;
},
proxyCallback : <b>function</b>(){
animated = false;
Ext.callback(cb, scope);
}
};
};
<b>return</b> {
scroll : <b>function</b>(el, args, duration, easing, cb, scope){
<i>// scroll anim not supported so just scroll immediately</i>
<b>var</b> anim = createAnim(cb, scope);
el = Ext.getDom(el);
el.scrollLeft = args.scroll.to[0];
el.scrollTop = args.scroll.to[1];
anim.proxyCallback();
<b>return</b> anim;
},
motion : <b>function</b>(el, args, duration, easing, cb, scope){
<b>return</b> this.run(el, args, duration, easing, cb, scope);
},
color : <b>function</b>(el, args, duration, easing, cb, scope){
<i>// color anim not supported, so execute callback immediately</i>
<b>var</b> anim = createAnim(cb, scope);
anim.proxyCallback();
<b>return</b> anim;
},
run : <b>function</b>(el, args, duration, easing, cb, scope, type){
<b>var</b> anim = createAnim(cb, scope);
<b>var</b> o = {};
<b>for</b>(var k <b>in</b> args){
<b>switch</b>(k){ <i>// jquery doesn't support, so convert</i>
<b>case</b> 'points':
<b>var</b> by, pts, e = Ext.fly(el, '_animrun');
e.position();
<b>if</b>(by = args.points.by){
<b>var</b> xy = e.getXY();
pts = e.translatePoints([xy[0]+by[0], xy[1]+by[1]]);
}<b>else</b>{
pts = e.translatePoints(args.points.to);
}
o.left = pts.left;
o.top = pts.top;
<b>if</b>(!parseInt(e.getStyle('left'), 10)){ <i>// auto bug</i>
e.setLeft(0);
}
<b>if</b>(!parseInt(e.getStyle('top'), 10)){
e.setTop(0);
}
<b>break</b>;
<b>case</b> 'width':
o.width = args.width.to;
<b>break</b>;
<b>case</b> 'height':
o.height = args.height.to;
<b>break</b>;
<b>case</b> 'opacity':
o.opacity = args.opacity.to;
<b>break</b>;
<b>default</b>:
o[k] = args[k].to;
<b>break</b>;
}
}
<i>// TODO: find out about easing plug <b>in</b>?</i>
jQuery(el).animate(o, duration*1000, undefined, anim.proxyCallback);
<b>return</b> anim;
}
};
}();
Ext.lib.Region = <b>function</b>(t, r, b, l) {
<b>this</b>.top = t;
<b>this</b>[1] = t;
<b>this</b>.right = r;
<b>this</b>.bottom = b;
<b>this</b>.left = l;
<b>this</b>[0] = l;
};
Ext.lib.Region.prototype = {
contains : <b>function</b>(region) {
<b>return</b> ( region.left &gt;= <b>this</b>.left &amp;&amp;
region.right &lt;= <b>this</b>.right &amp;&amp;
region.top &gt;= <b>this</b>.top &amp;&amp;
region.bottom &lt;= <b>this</b>.bottom );
},
getArea : <b>function</b>() {
<b>return</b> ( (<b>this</b>.bottom - <b>this</b>.top) * (<b>this</b>.right - <b>this</b>.left) );
},
intersect : <b>function</b>(region) {
<b>var</b> t = Math.max( <b>this</b>.top, region.top );
<b>var</b> r = Math.min( <b>this</b>.right, region.right );
<b>var</b> b = Math.min( <b>this</b>.bottom, region.bottom );
<b>var</b> l = Math.max( <b>this</b>.left, region.left );
<b>if</b> (b &gt;= t &amp;&amp; r &gt;= l) {
<b>return</b> new Ext.lib.Region(t, r, b, l);
} <b>else</b> {
<b>return</b> null;
}
},
union : <b>function</b>(region) {
<b>var</b> t = Math.min( <b>this</b>.top, region.top );
<b>var</b> r = Math.max( <b>this</b>.right, region.right );
<b>var</b> b = Math.max( <b>this</b>.bottom, region.bottom );
<b>var</b> l = Math.min( <b>this</b>.left, region.left );
<b>return</b> new Ext.lib.Region(t, r, b, l);
},
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;
}
};
Ext.lib.Region.getRegion = <b>function</b>(el) {
<b>var</b> p = Ext.lib.Dom.getXY(el);
<b>var</b> t = p[1];
<b>var</b> r = p[0] + el.offsetWidth;
<b>var</b> b = p[1] + el.offsetHeight;
<b>var</b> l = p[0];
<b>return</b> new Ext.lib.Region(t, r, b, l);
};
Ext.lib.Point = <b>function</b>(x, y) {
<b>if</b> (x instanceof Array) {
y = x[1];
x = x[0];
}
<b>this</b>.x = <b>this</b>.right = <b>this</b>.left = <b>this</b>[0] = x;
<b>this</b>.y = <b>this</b>.top = <b>this</b>.bottom = <b>this</b>[1] = y;
};
Ext.lib.Point.prototype = <b>new</b> Ext.lib.Region();
<i>// prevent IE leaks</i>
<b>if</b>(Ext.isIE){
jQuery(window).unload(<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;
});
}
})();</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>