// Global undefined variable
window.undefined = window.undefined;
+// Map over the $ in case of overwrite
+if ( $ ) var _$ = $;
+
/**
* Create a new jQuery Object
* @constructor
*/
-function jQuery(a,c) {
+var $ = jQuery = function(a,c) {
+ /*
+ * Handle support for overriding other $() functions. Way too many libraries
+ * provide this function to simply ignore it and overwrite it.
+ */
+
+ // Check to see if this is a possible collision case
+ if ( _$ && !c && ( a.constructor == String &&
+
+ // Make sure that the expression is a colliding one
+ !/[^a-zA-Z0-9_-]/.test(a) &&
+
+ // and that there are no elements that match it
+ // (this is the one truly ambiguous case)
+ !document.getElementsByTagName(a).length ) ||
+
+ // Watch for an array being passed in (Prototype 1.5)
+ a.constructor == Array )
+
+ // Use the default method, in case it works some voodoo
+ return _$( a );
+
// Watch for when a jQuery object is passed in as an arg
if ( a && a.jquery )
return a;
);
}
-/**
- * The jQuery query object.
- */
-if ( !window.$ )
- var $ = jQuery;
-
-/*
- * Handle support for overriding other $() functions. Way too many libraries
- * provide this function to simply ignore it and overwrite it.
- */
-else
- var $ = function(a,c) {
- // Check to see if this is a possible collision case
- if ( !c && a.constructor == String &&
-
- // Make sure that the expression is a colliding one
- !/[^a-zA-Z0-9_-]/.test(a) &&
-
- // and that there are no elements that match it
- // (this is the one truly ambiguous case)
- !document.getElementsByTagName(a).length ) {
-
- // Only return the element if it's found
- var obj = document.getElementById(a);
- if ( obj ) return obj;
-
- }
-
- return jQuery(a,c);
- };
-
jQuery.fn = jQuery.prototype = {
/**
* The current SVN version of jQuery.
text: function(e) {
e = e || this.get();
var t = "";
- for ( var j = 0; j < e.length; j++ )
- for ( var i = 0; i < e[j].childNodes.length; i++ )
- t += e[j].childNodes[i].nodeType != 1 ?
- e[j].childNodes[i].nodeValue :
- jQuery.fn.text(e[j].childNodes[i].childNodes);
+ for ( var j = 0; j < e.length; j++ ) {
+ var r = e[j].childNodes;
+ for ( var i = 0; i < r.length; i++ )
+ t += r[i].nodeType != 1 ?
+ r[i].nodeValue : jQuery.fn.text([ r[i] ]);
+ }
return t;
},
},
parent: function(a) {
- var ret = jQuery.map(this.cur,"d.parentNode");
+ var ret = jQuery.map(this.cur,"a.parentNode");
if ( a ) ret = jQuery.filter(a,ret).r;
return this.pushStack(ret);
},
var r = [];
for ( var i = 0; i < a.length; i++ ) {
var t = f(a[i],i);
- if ( t !== null ) {
+ if ( t !== null && t != undefined ) {
if ( t.constructor != Array ) t = [t];
r = jQuery.merge( t, r );
}
},
handle: function(event) {
- if ( !event && !window.event ) return;
+ // Handle adding events to items in IFrames, in IE
+ event = event ||
+ jQuery.event.fix( ((this.ownerDocument || this.document ||
+ this).parentWindow || window).event );
+
+ // If no correct event was found, fail
+ if ( !event ) return;
var returnValue = true, handlers = [];
- event = event || jQuery.event.fix(window.event);
for ( var j in this.events[event.type] )
handlers[handlers.length] = this.events[event.type][j];
- for ( var i = 0; i < handlers.length; i++ ) {
+ for ( var i = 0; i < handlers.length; i++ )
if ( handlers[i].constructor == Function ) {
this.handleEvent = handlers[i];
if (this.handleEvent(event) === false) {
returnValue = false;
}
}
- }
return returnValue;
},
fix: function(event) {
- event.preventDefault = function() {
- this.returnValue = false;
- };
+ if ( event ) {
+ event.preventDefault = function() {
+ this.returnValue = false;
+ };
- event.stopPropagation = function() {
- this.cancelBubble = true;
- };
+ event.stopPropagation = function() {
+ this.cancelBubble = true;
+ };
+ }
return event;
}