2010-09-09 12:23:10 +00:00
|
|
|
var jQuery = (function() {
|
2010-03-23 16:12:16 +00:00
|
|
|
|
2009-05-20 21:12:08 +00:00
|
|
|
// Define a local copy of jQuery
|
|
|
|
var jQuery = function( selector, context ) {
|
|
|
|
// The jQuery object is actually just the init constructor 'enhanced'
|
2010-10-10 00:32:54 +00:00
|
|
|
return new jQuery.fn.init( selector, context, rootjQuery );
|
2009-05-20 21:12:08 +00:00
|
|
|
},
|
2009-03-31 17:35:20 +00:00
|
|
|
|
2009-01-04 22:25:46 +00:00
|
|
|
// Map over jQuery in case of overwrite
|
|
|
|
_jQuery = window.jQuery,
|
2009-03-31 17:35:20 +00:00
|
|
|
|
2009-01-04 22:25:46 +00:00
|
|
|
// Map over the $ in case of overwrite
|
|
|
|
_$ = window.$,
|
|
|
|
|
2009-03-31 17:35:20 +00:00
|
|
|
// A central reference to the root jQuery(document)
|
|
|
|
rootjQuery,
|
|
|
|
|
2011-01-20 16:58:44 +00:00
|
|
|
// A simple way to check for HTML strings or ID strings
|
|
|
|
// (both of which we optimize for)
|
2011-01-01 22:13:04 +00:00
|
|
|
quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
|
2009-03-31 17:35:20 +00:00
|
|
|
|
2009-07-19 19:47:30 +00:00
|
|
|
// Check if a string has a non-whitespace character in it
|
|
|
|
rnotwhite = /\S/,
|
|
|
|
|
|
|
|
// Used for trimming whitespace
|
2010-03-09 14:14:27 +00:00
|
|
|
trimLeft = /^\s+/,
|
|
|
|
trimRight = /\s+$/,
|
2009-07-19 19:47:30 +00:00
|
|
|
|
2010-09-27 15:51:01 +00:00
|
|
|
// Check for digits
|
|
|
|
rdigit = /\d/,
|
|
|
|
|
2009-09-07 18:58:01 +00:00
|
|
|
// Match a standalone tag
|
2009-11-30 18:42:19 +00:00
|
|
|
rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
|
2009-09-07 18:58:01 +00:00
|
|
|
|
2010-09-22 13:16:28 +00:00
|
|
|
// JSON RegExp
|
|
|
|
rvalidchars = /^[\],:{}\s]*$/,
|
|
|
|
rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
|
|
|
|
rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
|
|
|
|
rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
|
|
|
|
|
|
|
|
// Useragent RegExp
|
2011-06-20 13:41:53 +00:00
|
|
|
rchrome = /(chrome)[ \/]([\w.]+)/,
|
2010-09-22 13:16:28 +00:00
|
|
|
rwebkit = /(webkit)[ \/]([\w.]+)/,
|
|
|
|
ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
|
|
|
|
rmsie = /(msie) ([\w.]+)/,
|
|
|
|
rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
|
|
|
|
|
2011-05-25 19:10:49 +00:00
|
|
|
// Matches dashed string for camelizing
|
2011-08-05 14:17:24 +00:00
|
|
|
rdashAlpha = /-([a-z]|[0-9])/ig,
|
2011-08-17 21:30:31 +00:00
|
|
|
rmsPrefix = /^-ms-/,
|
2011-05-25 19:10:49 +00:00
|
|
|
|
|
|
|
// Used by jQuery.camelCase as callback to replace()
|
|
|
|
fcamelCase = function( all, letter ) {
|
2011-08-05 14:17:24 +00:00
|
|
|
return ( letter + "" ).toUpperCase();
|
2011-05-25 19:10:49 +00:00
|
|
|
},
|
|
|
|
|
2009-03-31 17:35:20 +00:00
|
|
|
// Keep a UserAgent string for use with jQuery.browser
|
2010-01-05 22:01:20 +00:00
|
|
|
userAgent = navigator.userAgent,
|
|
|
|
|
2010-01-06 19:23:39 +00:00
|
|
|
// For matching the engine and version of the browser
|
2010-01-05 22:01:20 +00:00
|
|
|
browserMatch,
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2010-12-20 18:09:15 +00:00
|
|
|
// The deferred used on DOM ready
|
|
|
|
readyList,
|
2009-03-31 17:35:20 +00:00
|
|
|
|
2009-12-16 21:45:00 +00:00
|
|
|
// The ready event handler
|
|
|
|
DOMContentLoaded,
|
|
|
|
|
2009-07-19 19:50:45 +00:00
|
|
|
// Save a reference to some core methods
|
|
|
|
toString = Object.prototype.toString,
|
2010-03-01 23:19:29 +00:00
|
|
|
hasOwn = Object.prototype.hasOwnProperty,
|
2009-07-19 19:50:45 +00:00
|
|
|
push = Array.prototype.push,
|
2009-09-08 01:45:11 +00:00
|
|
|
slice = Array.prototype.slice,
|
2010-03-11 15:49:19 +00:00
|
|
|
trim = String.prototype.trim,
|
2010-08-27 23:14:59 +00:00
|
|
|
indexOf = Array.prototype.indexOf,
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2010-08-27 23:14:59 +00:00
|
|
|
// [[Class]] -> type pairs
|
2010-12-30 16:06:53 +00:00
|
|
|
class2type = {};
|
2009-03-31 17:35:20 +00:00
|
|
|
|
2008-01-14 22:30:48 +00:00
|
|
|
jQuery.fn = jQuery.prototype = {
|
2010-10-10 00:32:54 +00:00
|
|
|
constructor: jQuery,
|
|
|
|
init: function( selector, context, rootjQuery ) {
|
2009-12-17 19:17:05 +00:00
|
|
|
var match, elem, ret, doc;
|
2009-03-31 17:35:20 +00:00
|
|
|
|
|
|
|
// Handle $(""), $(null), or $(undefined)
|
2009-07-27 20:48:42 +00:00
|
|
|
if ( !selector ) {
|
|
|
|
return this;
|
|
|
|
}
|
2008-01-14 22:30:48 +00:00
|
|
|
|
|
|
|
// Handle $(DOMElement)
|
|
|
|
if ( selector.nodeType ) {
|
2009-07-17 17:33:44 +00:00
|
|
|
this.context = this[0] = selector;
|
2009-11-11 18:42:50 +00:00
|
|
|
this.length = 1;
|
2008-01-14 22:30:48 +00:00
|
|
|
return this;
|
2008-05-06 22:36:30 +00:00
|
|
|
}
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2011-01-20 16:58:44 +00:00
|
|
|
// The body element only exists once, optimize finding it
|
|
|
|
if ( selector === "body" && !context && document.body ) {
|
|
|
|
this.context = document;
|
|
|
|
this[0] = document.body;
|
2011-03-16 05:16:32 +00:00
|
|
|
this.selector = selector;
|
2011-01-20 16:58:44 +00:00
|
|
|
this.length = 1;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2008-01-14 22:30:48 +00:00
|
|
|
// Handle HTML strings
|
2008-11-17 16:32:05 +00:00
|
|
|
if ( typeof selector === "string" ) {
|
2011-01-20 16:58:44 +00:00
|
|
|
// Are we dealing with HTML string or an ID?
|
2011-05-02 17:31:23 +00:00
|
|
|
if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
|
2011-05-02 17:14:13 +00:00
|
|
|
// Assume that strings that start and end with <> are HTML and skip the regex check
|
2011-01-19 23:37:31 +00:00
|
|
|
match = [ null, selector, null ];
|
2011-05-02 17:14:13 +00:00
|
|
|
|
2011-01-19 23:37:31 +00:00
|
|
|
} else {
|
|
|
|
match = quickExpr.exec( selector );
|
|
|
|
}
|
2011-01-20 16:58:44 +00:00
|
|
|
|
|
|
|
// Verify a match, and that no context was specified for #id
|
|
|
|
if ( match && (match[1] || !context) ) {
|
2008-01-14 22:30:48 +00:00
|
|
|
|
2011-01-20 16:58:44 +00:00
|
|
|
// HANDLE: $(html) -> $(array)
|
|
|
|
if ( match[1] ) {
|
|
|
|
context = context instanceof jQuery ? context[0] : context;
|
|
|
|
doc = (context ? context.ownerDocument || context : document);
|
2009-09-07 18:58:01 +00:00
|
|
|
|
2011-01-20 16:58:44 +00:00
|
|
|
// If a single string is passed in and it's a single tag
|
|
|
|
// just do a createElement and skip the rest
|
|
|
|
ret = rsingleTag.exec( selector );
|
|
|
|
|
|
|
|
if ( ret ) {
|
|
|
|
if ( jQuery.isPlainObject( context ) ) {
|
|
|
|
selector = [ document.createElement( ret[1] ) ];
|
|
|
|
jQuery.fn.attr.call( selector, context, true );
|
|
|
|
|
|
|
|
} else {
|
|
|
|
selector = [ doc.createElement( ret[1] ) ];
|
|
|
|
}
|
2009-09-07 18:58:01 +00:00
|
|
|
|
|
|
|
} else {
|
2011-01-20 16:58:44 +00:00
|
|
|
ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
|
2011-01-20 20:25:04 +00:00
|
|
|
selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes;
|
2009-09-07 18:58:01 +00:00
|
|
|
}
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2011-01-20 16:58:44 +00:00
|
|
|
return jQuery.merge( this, selector );
|
2011-01-23 04:01:36 +00:00
|
|
|
|
2011-01-20 16:58:44 +00:00
|
|
|
// HANDLE: $("#id")
|
2009-02-25 04:57:00 +00:00
|
|
|
} else {
|
2011-01-20 16:58:44 +00:00
|
|
|
elem = document.getElementById( match[2] );
|
|
|
|
|
|
|
|
// Check parentNode to catch when Blackberry 4.6 returns
|
|
|
|
// nodes that are no longer in the document #6963
|
|
|
|
if ( elem && elem.parentNode ) {
|
|
|
|
// Handle the case where IE and Opera return items
|
|
|
|
// by name instead of ID
|
|
|
|
if ( elem.id !== match[2] ) {
|
|
|
|
return rootjQuery.find( selector );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise, we inject the element directly into the jQuery object
|
|
|
|
this.length = 1;
|
|
|
|
this[0] = elem;
|
|
|
|
}
|
2008-01-14 22:30:48 +00:00
|
|
|
|
2011-01-20 16:58:44 +00:00
|
|
|
this.context = document;
|
|
|
|
this.selector = selector;
|
|
|
|
return this;
|
|
|
|
}
|
2009-09-08 04:26:47 +00:00
|
|
|
|
2009-02-25 14:23:25 +00:00
|
|
|
// HANDLE: $(expr, $(...))
|
|
|
|
} else if ( !context || context.jquery ) {
|
|
|
|
return (context || rootjQuery).find( selector );
|
2009-02-25 04:57:00 +00:00
|
|
|
|
2009-02-25 14:23:25 +00:00
|
|
|
// HANDLE: $(expr, context)
|
2009-03-05 13:36:12 +00:00
|
|
|
// (which is just equivalent to: $(context).find(expr)
|
2009-02-25 04:57:00 +00:00
|
|
|
} else {
|
2010-10-10 00:32:54 +00:00
|
|
|
return this.constructor( context ).find( selector );
|
2009-02-25 04:57:00 +00:00
|
|
|
}
|
2008-01-14 22:30:48 +00:00
|
|
|
|
|
|
|
// HANDLE: $(function)
|
|
|
|
// Shortcut for document ready
|
2009-02-25 04:57:00 +00:00
|
|
|
} else if ( jQuery.isFunction( selector ) ) {
|
2009-02-25 14:23:25 +00:00
|
|
|
return rootjQuery.ready( selector );
|
2009-02-25 04:57:00 +00:00
|
|
|
}
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2009-09-09 16:33:16 +00:00
|
|
|
if (selector.selector !== undefined) {
|
2009-01-08 21:41:58 +00:00
|
|
|
this.selector = selector.selector;
|
|
|
|
this.context = selector.context;
|
|
|
|
}
|
|
|
|
|
2010-01-28 22:17:51 +00:00
|
|
|
return jQuery.makeArray( selector, this );
|
2008-01-14 22:30:48 +00:00
|
|
|
},
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2008-12-19 04:37:10 +00:00
|
|
|
// Start with an empty selector
|
|
|
|
selector: "",
|
|
|
|
|
2008-01-14 22:30:48 +00:00
|
|
|
// The current version of jQuery being used
|
|
|
|
jquery: "@VERSION",
|
|
|
|
|
2009-07-17 01:47:26 +00:00
|
|
|
// The default length of a jQuery object is 0
|
|
|
|
length: 0,
|
|
|
|
|
2008-01-14 22:30:48 +00:00
|
|
|
// The number of elements contained in the matched element set
|
|
|
|
size: function() {
|
|
|
|
return this.length;
|
|
|
|
},
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2009-12-22 00:58:13 +00:00
|
|
|
toArray: function() {
|
2009-07-23 13:22:55 +00:00
|
|
|
return slice.call( this, 0 );
|
|
|
|
},
|
2009-07-16 07:31:32 +00:00
|
|
|
|
2008-01-14 22:30:48 +00:00
|
|
|
// Get the Nth element in the matched element set OR
|
|
|
|
// Get the whole matched element set as a clean array
|
|
|
|
get: function( num ) {
|
2009-03-31 17:35:20 +00:00
|
|
|
return num == null ?
|
2008-01-14 22:30:48 +00:00
|
|
|
|
|
|
|
// Return a 'clean' array
|
2009-07-16 07:31:41 +00:00
|
|
|
this.toArray() :
|
2008-01-14 22:30:48 +00:00
|
|
|
|
|
|
|
// Return just the object
|
2010-11-19 11:28:13 +00:00
|
|
|
( num < 0 ? this[ this.length + num ] : this[ num ] );
|
2008-01-14 22:30:48 +00:00
|
|
|
},
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2008-01-14 22:30:48 +00:00
|
|
|
// Take an array of elements and push it onto the stack
|
|
|
|
// (returning the new matched element set)
|
2008-12-19 04:37:10 +00:00
|
|
|
pushStack: function( elems, name, selector ) {
|
2008-01-14 22:30:48 +00:00
|
|
|
// Build a new jQuery matched element set
|
2010-10-10 00:32:54 +00:00
|
|
|
var ret = this.constructor();
|
2010-02-13 06:45:09 +00:00
|
|
|
|
|
|
|
if ( jQuery.isArray( elems ) ) {
|
|
|
|
push.apply( ret, elems );
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2010-02-13 06:45:09 +00:00
|
|
|
} else {
|
|
|
|
jQuery.merge( ret, elems );
|
|
|
|
}
|
2008-01-14 22:30:48 +00:00
|
|
|
|
|
|
|
// Add the old object onto the stack (as a reference)
|
|
|
|
ret.prevObject = this;
|
|
|
|
|
2008-12-19 04:37:10 +00:00
|
|
|
ret.context = this.context;
|
|
|
|
|
2009-03-31 17:35:20 +00:00
|
|
|
if ( name === "find" ) {
|
2008-12-19 04:37:10 +00:00
|
|
|
ret.selector = this.selector + (this.selector ? " " : "") + selector;
|
2009-03-31 17:35:20 +00:00
|
|
|
} else if ( name ) {
|
2008-12-19 04:37:10 +00:00
|
|
|
ret.selector = this.selector + "." + name + "(" + selector + ")";
|
2009-03-31 17:35:20 +00:00
|
|
|
}
|
2008-12-19 04:37:10 +00:00
|
|
|
|
2008-01-14 22:30:48 +00:00
|
|
|
// Return the newly-formed element set
|
|
|
|
return ret;
|
|
|
|
},
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2008-01-14 22:30:48 +00:00
|
|
|
// Execute a callback for every element in the matched set.
|
|
|
|
// (You can seed the arguments with an array of args, but this is
|
|
|
|
// only used internally.)
|
|
|
|
each: function( callback, args ) {
|
|
|
|
return jQuery.each( this, callback, args );
|
|
|
|
},
|
2011-01-05 21:41:23 +00:00
|
|
|
|
2011-01-23 04:01:36 +00:00
|
|
|
ready: function( fn ) {
|
2009-12-08 00:34:55 +00:00
|
|
|
// Attach the listeners
|
|
|
|
jQuery.bindReady();
|
2011-01-05 21:41:23 +00:00
|
|
|
|
2011-01-23 04:01:36 +00:00
|
|
|
// Add the callback
|
|
|
|
readyList.done( fn );
|
|
|
|
|
|
|
|
return this;
|
2009-12-08 00:34:55 +00:00
|
|
|
},
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2009-12-10 17:25:25 +00:00
|
|
|
eq: function( i ) {
|
|
|
|
return i === -1 ?
|
|
|
|
this.slice( i ) :
|
|
|
|
this.slice( i, +i + 1 );
|
|
|
|
},
|
|
|
|
|
|
|
|
first: function() {
|
|
|
|
return this.eq( 0 );
|
|
|
|
},
|
|
|
|
|
|
|
|
last: function() {
|
|
|
|
return this.eq( -1 );
|
|
|
|
},
|
|
|
|
|
|
|
|
slice: function() {
|
|
|
|
return this.pushStack( slice.apply( this, arguments ),
|
|
|
|
"slice", slice.call(arguments).join(",") );
|
|
|
|
},
|
|
|
|
|
|
|
|
map: function( callback ) {
|
2009-12-22 00:58:13 +00:00
|
|
|
return this.pushStack( jQuery.map(this, function( elem, i ) {
|
2009-12-10 17:25:25 +00:00
|
|
|
return callback.call( elem, i, elem );
|
|
|
|
}));
|
|
|
|
},
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2009-12-10 17:25:25 +00:00
|
|
|
end: function() {
|
2010-10-10 00:32:54 +00:00
|
|
|
return this.prevObject || this.constructor(null);
|
2009-12-10 17:25:25 +00:00
|
|
|
},
|
2008-01-14 22:30:48 +00:00
|
|
|
|
2009-03-17 20:39:29 +00:00
|
|
|
// For internal use only.
|
|
|
|
// Behaves like an Array's method, not like a jQuery method.
|
2009-07-19 19:50:45 +00:00
|
|
|
push: push,
|
2009-03-17 20:39:29 +00:00
|
|
|
sort: [].sort,
|
2009-03-18 21:15:38 +00:00
|
|
|
splice: [].splice
|
2008-01-14 22:30:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Give the init function the jQuery prototype for later instantiation
|
2008-04-29 23:34:50 +00:00
|
|
|
jQuery.fn.init.prototype = jQuery.fn;
|
2008-01-14 22:30:48 +00:00
|
|
|
|
|
|
|
jQuery.extend = jQuery.fn.extend = function() {
|
2011-02-15 21:03:23 +00:00
|
|
|
var options, name, src, copy, copyIsArray, clone,
|
2010-11-09 16:09:07 +00:00
|
|
|
target = arguments[0] || {},
|
|
|
|
i = 1,
|
|
|
|
length = arguments.length,
|
|
|
|
deep = false;
|
2008-01-14 22:30:48 +00:00
|
|
|
|
|
|
|
// Handle a deep copy situation
|
2008-11-17 16:32:05 +00:00
|
|
|
if ( typeof target === "boolean" ) {
|
2008-01-14 22:30:48 +00:00
|
|
|
deep = target;
|
|
|
|
target = arguments[1] || {};
|
|
|
|
// skip the boolean and the target
|
|
|
|
i = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handle case when target is a string or something (possible in deep copy)
|
2009-03-31 17:35:20 +00:00
|
|
|
if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
|
2008-01-14 22:30:48 +00:00
|
|
|
target = {};
|
2009-03-31 17:35:20 +00:00
|
|
|
}
|
2008-01-14 22:30:48 +00:00
|
|
|
|
|
|
|
// extend jQuery itself if only one argument is passed
|
2009-03-31 17:35:20 +00:00
|
|
|
if ( length === i ) {
|
2008-01-14 22:30:48 +00:00
|
|
|
target = this;
|
2008-04-30 00:09:55 +00:00
|
|
|
--i;
|
2008-01-14 22:30:48 +00:00
|
|
|
}
|
|
|
|
|
2009-03-31 17:35:20 +00:00
|
|
|
for ( ; i < length; i++ ) {
|
2008-01-14 22:30:48 +00:00
|
|
|
// Only deal with non-null/undefined values
|
2009-03-31 17:35:20 +00:00
|
|
|
if ( (options = arguments[ i ]) != null ) {
|
2008-01-14 22:30:48 +00:00
|
|
|
// Extend the base object
|
2009-03-31 17:35:20 +00:00
|
|
|
for ( name in options ) {
|
|
|
|
src = target[ name ];
|
|
|
|
copy = options[ name ];
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2008-01-14 22:30:48 +00:00
|
|
|
// Prevent never-ending loop
|
2009-03-31 17:35:20 +00:00
|
|
|
if ( target === copy ) {
|
2008-01-14 22:30:48 +00:00
|
|
|
continue;
|
2009-03-31 17:35:20 +00:00
|
|
|
}
|
2008-01-14 22:30:48 +00:00
|
|
|
|
2010-01-30 18:50:49 +00:00
|
|
|
// Recurse if we're merging plain objects or arrays
|
|
|
|
if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
|
|
|
|
if ( copyIsArray ) {
|
|
|
|
copyIsArray = false;
|
|
|
|
clone = src && jQuery.isArray(src) ? src : [];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
clone = src && jQuery.isPlainObject(src) ? src : {};
|
|
|
|
}
|
2009-07-16 07:32:03 +00:00
|
|
|
|
|
|
|
// Never move original objects, clone them
|
|
|
|
target[ name ] = jQuery.extend( deep, clone, copy );
|
2008-01-14 22:30:48 +00:00
|
|
|
|
|
|
|
// Don't bring in undefined values
|
2009-03-31 17:35:20 +00:00
|
|
|
} else if ( copy !== undefined ) {
|
2008-04-30 00:09:55 +00:00
|
|
|
target[ name ] = copy;
|
2009-03-31 17:35:20 +00:00
|
|
|
}
|
2008-01-14 22:30:48 +00:00
|
|
|
}
|
2009-03-31 17:35:20 +00:00
|
|
|
}
|
|
|
|
}
|
2008-01-14 22:30:48 +00:00
|
|
|
|
|
|
|
// Return the modified object
|
|
|
|
return target;
|
|
|
|
};
|
|
|
|
|
|
|
|
jQuery.extend({
|
|
|
|
noConflict: function( deep ) {
|
2010-11-22 04:12:12 +00:00
|
|
|
if ( window.$ === jQuery ) {
|
|
|
|
window.$ = _$;
|
|
|
|
}
|
2008-01-14 22:30:48 +00:00
|
|
|
|
2010-10-19 05:29:20 +00:00
|
|
|
if ( deep && window.jQuery === jQuery ) {
|
2008-01-14 22:30:48 +00:00
|
|
|
window.jQuery = _jQuery;
|
2009-03-31 17:35:20 +00:00
|
|
|
}
|
2008-01-14 22:30:48 +00:00
|
|
|
|
|
|
|
return jQuery;
|
|
|
|
},
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2009-12-08 00:34:55 +00:00
|
|
|
// Is the DOM ready to be used? Set to true once it occurs.
|
|
|
|
isReady: false,
|
2010-09-20 18:53:29 +00:00
|
|
|
|
|
|
|
// A counter to track how many items to wait for before
|
|
|
|
// the ready event fires. See #6781
|
|
|
|
readyWait: 1,
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2011-02-03 02:57:44 +00:00
|
|
|
// Hold (or release) the ready event
|
|
|
|
holdReady: function( hold ) {
|
|
|
|
if ( hold ) {
|
|
|
|
jQuery.readyWait++;
|
|
|
|
} else {
|
|
|
|
jQuery.ready( true );
|
2010-09-20 18:53:29 +00:00
|
|
|
}
|
2011-02-03 02:57:44 +00:00
|
|
|
},
|
2010-09-20 18:53:29 +00:00
|
|
|
|
2011-02-03 02:57:44 +00:00
|
|
|
// Handle when the DOM is ready
|
|
|
|
ready: function( wait ) {
|
|
|
|
// Either a released hold or an DOMready/load event and not yet ready
|
|
|
|
if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) {
|
2009-12-16 21:45:00 +00:00
|
|
|
// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
|
2009-12-08 00:34:55 +00:00
|
|
|
if ( !document.body ) {
|
2010-09-24 14:06:36 +00:00
|
|
|
return setTimeout( jQuery.ready, 1 );
|
2009-12-08 00:34:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Remember that the DOM is ready
|
|
|
|
jQuery.isReady = true;
|
|
|
|
|
2010-09-20 18:53:29 +00:00
|
|
|
// If a normal DOM Ready event fired, decrement, and wait if need be
|
|
|
|
if ( wait !== true && --jQuery.readyWait > 0 ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-12-08 00:34:55 +00:00
|
|
|
// If there are functions bound, to execute
|
2011-01-23 04:01:36 +00:00
|
|
|
readyList.resolveWith( document, [ jQuery ] );
|
2011-01-05 21:41:23 +00:00
|
|
|
|
2010-12-20 18:09:15 +00:00
|
|
|
// Trigger any bound ready events
|
|
|
|
if ( jQuery.fn.trigger ) {
|
|
|
|
jQuery( document ).trigger( "ready" ).unbind( "ready" );
|
2009-12-08 00:34:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2009-12-08 00:34:55 +00:00
|
|
|
bindReady: function() {
|
2011-03-03 18:38:06 +00:00
|
|
|
if ( readyList ) {
|
2009-12-22 00:58:13 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-03-03 18:38:06 +00:00
|
|
|
readyList = jQuery._Deferred();
|
2009-12-08 00:34:55 +00:00
|
|
|
|
|
|
|
// Catch cases where $(document).ready() is called after the
|
|
|
|
// browser event has already occurred.
|
|
|
|
if ( document.readyState === "complete" ) {
|
2010-09-23 15:38:22 +00:00
|
|
|
// Handle it asynchronously to allow scripts the opportunity to delay ready
|
2010-09-24 14:06:36 +00:00
|
|
|
return setTimeout( jQuery.ready, 1 );
|
2009-12-08 00:34:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Mozilla, Opera and webkit nightlies currently support this event
|
|
|
|
if ( document.addEventListener ) {
|
|
|
|
// Use the handy event callback
|
2009-12-16 21:45:00 +00:00
|
|
|
document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2009-12-08 00:34:55 +00:00
|
|
|
// A fallback to window.onload, that will always work
|
|
|
|
window.addEventListener( "load", jQuery.ready, false );
|
|
|
|
|
|
|
|
// If IE event model is used
|
|
|
|
} else if ( document.attachEvent ) {
|
|
|
|
// ensure firing before onload,
|
|
|
|
// maybe late but safe also for iframes
|
2011-02-07 00:34:57 +00:00
|
|
|
document.attachEvent( "onreadystatechange", DOMContentLoaded );
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2009-12-08 00:34:55 +00:00
|
|
|
// A fallback to window.onload, that will always work
|
|
|
|
window.attachEvent( "onload", jQuery.ready );
|
|
|
|
|
|
|
|
// If IE and not a frame
|
|
|
|
// continually check to see if the document is ready
|
|
|
|
var toplevel = false;
|
|
|
|
|
|
|
|
try {
|
|
|
|
toplevel = window.frameElement == null;
|
2009-12-22 00:58:13 +00:00
|
|
|
} catch(e) {}
|
2009-12-08 00:34:55 +00:00
|
|
|
|
|
|
|
if ( document.documentElement.doScroll && toplevel ) {
|
2009-12-08 00:42:25 +00:00
|
|
|
doScrollCheck();
|
2009-12-08 00:34:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2008-01-14 22:30:48 +00:00
|
|
|
|
2008-11-17 16:32:05 +00:00
|
|
|
// See test/unit/core.js for details concerning isFunction.
|
2008-10-18 22:22:08 +00:00
|
|
|
// Since version 1.3, DOM methods and functions like alert
|
2008-07-23 16:18:05 +00:00
|
|
|
// aren't supported. They return false on IE (#2968).
|
2008-11-17 16:32:05 +00:00
|
|
|
isFunction: function( obj ) {
|
2010-08-25 16:57:34 +00:00
|
|
|
return jQuery.type(obj) === "function";
|
2008-01-14 22:30:48 +00:00
|
|
|
},
|
2008-11-17 16:32:05 +00:00
|
|
|
|
2010-08-27 17:15:48 +00:00
|
|
|
isArray: Array.isArray || function( obj ) {
|
2010-08-25 16:57:34 +00:00
|
|
|
return jQuery.type(obj) === "array";
|
|
|
|
},
|
|
|
|
|
2010-09-22 20:41:51 +00:00
|
|
|
// A crude way of determining if an object is a window
|
|
|
|
isWindow: function( obj ) {
|
2010-09-22 20:50:38 +00:00
|
|
|
return obj && typeof obj === "object" && "setInterval" in obj;
|
2010-09-22 20:41:51 +00:00
|
|
|
},
|
|
|
|
|
2010-09-27 15:51:01 +00:00
|
|
|
isNaN: function( obj ) {
|
|
|
|
return obj == null || !rdigit.test( obj ) || isNaN( obj );
|
|
|
|
},
|
|
|
|
|
2010-08-25 16:57:34 +00:00
|
|
|
type: function( obj ) {
|
2010-08-27 14:03:30 +00:00
|
|
|
return obj == null ?
|
|
|
|
String( obj ) :
|
2010-08-27 23:14:59 +00:00
|
|
|
class2type[ toString.call(obj) ] || "object";
|
2008-10-29 02:01:22 +00:00
|
|
|
},
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2009-12-06 22:11:51 +00:00
|
|
|
isPlainObject: function( obj ) {
|
2009-12-18 16:34:20 +00:00
|
|
|
// Must be an Object.
|
|
|
|
// Because of IE, we also have to check the presence of the constructor property.
|
2009-12-19 00:36:35 +00:00
|
|
|
// Make sure that DOM nodes and window objects don't pass through, as well
|
2010-09-22 20:41:51 +00:00
|
|
|
if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
|
2009-11-08 23:26:01 +00:00
|
|
|
return false;
|
|
|
|
}
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2009-12-18 16:34:20 +00:00
|
|
|
// Not own constructor property must be Object
|
2010-03-01 23:19:29 +00:00
|
|
|
if ( obj.constructor &&
|
|
|
|
!hasOwn.call(obj, "constructor") &&
|
|
|
|
!hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
|
2009-11-12 04:50:40 +00:00
|
|
|
return false;
|
|
|
|
}
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2009-12-18 16:34:20 +00:00
|
|
|
// Own properties are enumerated firstly, so to speed up,
|
|
|
|
// if last one is own, then all properties are own.
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2009-11-08 23:26:01 +00:00
|
|
|
var key;
|
|
|
|
for ( key in obj ) {}
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2010-03-01 23:19:29 +00:00
|
|
|
return key === undefined || hasOwn.call( obj, key );
|
2009-07-16 07:32:03 +00:00
|
|
|
},
|
|
|
|
|
2009-07-16 07:32:31 +00:00
|
|
|
isEmptyObject: function( obj ) {
|
2009-07-19 19:55:21 +00:00
|
|
|
for ( var name in obj ) {
|
2009-07-16 15:16:44 +00:00
|
|
|
return false;
|
2009-07-19 19:55:21 +00:00
|
|
|
}
|
2009-07-16 15:16:44 +00:00
|
|
|
return true;
|
2009-07-16 07:32:31 +00:00
|
|
|
},
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2010-01-23 21:48:47 +00:00
|
|
|
error: function( msg ) {
|
|
|
|
throw msg;
|
|
|
|
},
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2010-01-23 21:51:51 +00:00
|
|
|
parseJSON: function( data ) {
|
2010-01-23 22:08:26 +00:00
|
|
|
if ( typeof data !== "string" || !data ) {
|
|
|
|
return null;
|
|
|
|
}
|
2010-02-13 07:14:23 +00:00
|
|
|
|
|
|
|
// Make sure leading/trailing whitespace is removed (IE can't handle it)
|
|
|
|
data = jQuery.trim( data );
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2011-04-05 08:43:14 +00:00
|
|
|
// Attempt to parse using the native JSON parser first
|
|
|
|
if ( window.JSON && window.JSON.parse ) {
|
|
|
|
return window.JSON.parse( data );
|
|
|
|
}
|
|
|
|
|
2010-01-23 21:51:51 +00:00
|
|
|
// Make sure the incoming data is actual JSON
|
|
|
|
// Logic borrowed from http://json.org/json2.js
|
2011-04-05 08:43:14 +00:00
|
|
|
if ( rvalidchars.test( data.replace( rvalidescape, "@" )
|
|
|
|
.replace( rvalidtokens, "]" )
|
|
|
|
.replace( rvalidbraces, "")) ) {
|
|
|
|
|
|
|
|
return (new Function( "return " + data ))();
|
2010-01-23 21:51:51 +00:00
|
|
|
|
|
|
|
}
|
2011-04-05 14:20:58 +00:00
|
|
|
jQuery.error( "Invalid JSON: " + data );
|
2010-01-23 21:51:51 +00:00
|
|
|
},
|
2011-01-05 21:41:23 +00:00
|
|
|
|
2010-12-24 17:02:00 +00:00
|
|
|
// Cross-browser xml parsing
|
2011-07-23 01:26:36 +00:00
|
|
|
parseXML: function( data ) {
|
|
|
|
var xml, tmp;
|
|
|
|
try {
|
|
|
|
if ( window.DOMParser ) { // Standard
|
|
|
|
tmp = new DOMParser();
|
|
|
|
xml = tmp.parseFromString( data , "text/xml" );
|
|
|
|
} else { // IE
|
|
|
|
xml = new ActiveXObject( "Microsoft.XMLDOM" );
|
|
|
|
xml.async = "false";
|
|
|
|
xml.loadXML( data );
|
|
|
|
}
|
|
|
|
} catch( e ) {
|
|
|
|
xml = undefined;
|
2010-12-24 17:02:00 +00:00
|
|
|
}
|
2011-07-23 01:26:36 +00:00
|
|
|
if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
|
2010-12-24 17:02:00 +00:00
|
|
|
jQuery.error( "Invalid XML: " + data );
|
|
|
|
}
|
|
|
|
return xml;
|
|
|
|
},
|
2009-07-16 07:32:31 +00:00
|
|
|
|
2009-12-31 14:50:49 +00:00
|
|
|
noop: function() {},
|
|
|
|
|
2011-04-07 04:47:15 +00:00
|
|
|
// Evaluates a script in a global context
|
|
|
|
// Workarounds based on findings by Jim Driscoll
|
|
|
|
// http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
|
2008-01-14 22:30:48 +00:00
|
|
|
globalEval: function( data ) {
|
2011-04-07 04:47:15 +00:00
|
|
|
if ( data && rnotwhite.test( data ) ) {
|
|
|
|
// We use execScript on Internet Explorer
|
|
|
|
// We use an anonymous function so that context is window
|
|
|
|
// rather than jQuery in Firefox
|
|
|
|
( window.execScript || function( data ) {
|
|
|
|
window[ "eval" ].call( window, data );
|
|
|
|
} )( data );
|
2008-01-14 22:30:48 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-08-17 21:30:31 +00:00
|
|
|
// Convert dashed to camelCase; used by the css and data modules
|
|
|
|
// Microsoft forgot to hump their vendor prefix (#9572)
|
2011-05-25 19:10:49 +00:00
|
|
|
camelCase: function( string ) {
|
2011-08-17 21:30:31 +00:00
|
|
|
return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
|
2011-05-25 19:10:49 +00:00
|
|
|
},
|
|
|
|
|
2008-01-14 22:30:48 +00:00
|
|
|
nodeName: function( elem, name ) {
|
2009-03-31 17:35:20 +00:00
|
|
|
return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
|
2008-01-14 22:30:48 +00:00
|
|
|
},
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2008-01-14 22:30:48 +00:00
|
|
|
// args is for internal usage only
|
|
|
|
each: function( object, callback, args ) {
|
2009-07-16 07:31:32 +00:00
|
|
|
var name, i = 0,
|
2009-06-20 15:51:19 +00:00
|
|
|
length = object.length,
|
2011-02-07 00:34:57 +00:00
|
|
|
isObj = length === undefined || jQuery.isFunction( object );
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2008-01-14 22:30:48 +00:00
|
|
|
if ( args ) {
|
2009-06-20 15:51:19 +00:00
|
|
|
if ( isObj ) {
|
2009-03-31 17:35:20 +00:00
|
|
|
for ( name in object ) {
|
|
|
|
if ( callback.apply( object[ name ], args ) === false ) {
|
2008-01-14 22:30:48 +00:00
|
|
|
break;
|
2009-03-31 17:35:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for ( ; i < length; ) {
|
|
|
|
if ( callback.apply( object[ i++ ], args ) === false ) {
|
2008-01-14 22:30:48 +00:00
|
|
|
break;
|
2009-03-31 17:35:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-01-14 22:30:48 +00:00
|
|
|
|
|
|
|
// A special, fast, case for the most common use of each
|
|
|
|
} else {
|
2009-06-20 15:51:19 +00:00
|
|
|
if ( isObj ) {
|
2009-03-31 17:35:20 +00:00
|
|
|
for ( name in object ) {
|
|
|
|
if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
|
2008-01-14 22:30:48 +00:00
|
|
|
break;
|
2009-03-31 17:35:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2011-03-30 17:17:48 +00:00
|
|
|
for ( ; i < length; ) {
|
2011-03-30 17:26:20 +00:00
|
|
|
if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) {
|
2011-03-30 17:17:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-03-31 17:35:20 +00:00
|
|
|
}
|
2008-01-14 22:30:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return object;
|
|
|
|
},
|
2008-05-13 01:45:58 +00:00
|
|
|
|
2010-03-09 14:14:27 +00:00
|
|
|
// Use native String.trim function wherever possible
|
2010-03-11 15:49:19 +00:00
|
|
|
trim: trim ?
|
2010-03-09 14:14:27 +00:00
|
|
|
function( text ) {
|
|
|
|
return text == null ?
|
|
|
|
"" :
|
2010-03-11 15:49:19 +00:00
|
|
|
trim.call( text );
|
2010-03-09 14:14:27 +00:00
|
|
|
} :
|
|
|
|
|
|
|
|
// Otherwise use our own trimming functionality
|
|
|
|
function( text ) {
|
|
|
|
return text == null ?
|
|
|
|
"" :
|
|
|
|
text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
|
|
|
|
},
|
2008-01-14 22:30:48 +00:00
|
|
|
|
2009-11-18 02:26:42 +00:00
|
|
|
// results is for internal usage only
|
|
|
|
makeArray: function( array, results ) {
|
|
|
|
var ret = results || [];
|
2008-01-14 22:30:48 +00:00
|
|
|
|
2009-03-31 17:35:20 +00:00
|
|
|
if ( array != null ) {
|
2008-08-12 19:34:30 +00:00
|
|
|
// The window, strings (and functions) also have 'length'
|
2009-12-07 04:20:49 +00:00
|
|
|
// The extra typeof function check is to prevent crashes
|
|
|
|
// in Safari 2 (See: #3039)
|
2010-08-23 19:38:55 +00:00
|
|
|
// Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
|
2011-02-07 00:34:57 +00:00
|
|
|
var type = jQuery.type( array );
|
2010-08-25 16:27:30 +00:00
|
|
|
|
2010-09-22 20:41:51 +00:00
|
|
|
if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
|
2009-11-18 02:26:42 +00:00
|
|
|
push.call( ret, array );
|
2009-03-31 17:35:20 +00:00
|
|
|
} else {
|
2009-11-18 02:26:42 +00:00
|
|
|
jQuery.merge( ret, array );
|
2009-03-31 17:35:20 +00:00
|
|
|
}
|
2008-04-25 03:48:07 +00:00
|
|
|
}
|
2008-01-14 22:30:48 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
},
|
|
|
|
|
|
|
|
inArray: function( elem, array ) {
|
2011-04-10 18:31:31 +00:00
|
|
|
|
|
|
|
if ( indexOf ) {
|
|
|
|
return indexOf.call( array, elem );
|
2009-11-11 20:15:58 +00:00
|
|
|
}
|
|
|
|
|
2009-03-31 17:35:20 +00:00
|
|
|
for ( var i = 0, length = array.length; i < length; i++ ) {
|
|
|
|
if ( array[ i ] === elem ) {
|
2008-01-14 22:30:48 +00:00
|
|
|
return i;
|
2009-03-31 17:35:20 +00:00
|
|
|
}
|
|
|
|
}
|
2008-01-14 22:30:48 +00:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
},
|
|
|
|
|
|
|
|
merge: function( first, second ) {
|
2010-11-09 16:09:07 +00:00
|
|
|
var i = first.length,
|
|
|
|
j = 0;
|
2009-05-02 19:22:55 +00:00
|
|
|
|
2009-12-10 05:43:20 +00:00
|
|
|
if ( typeof second.length === "number" ) {
|
|
|
|
for ( var l = second.length; j < l; j++ ) {
|
|
|
|
first[ i++ ] = second[ j ];
|
|
|
|
}
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2009-12-10 05:43:20 +00:00
|
|
|
} else {
|
|
|
|
while ( second[j] !== undefined ) {
|
|
|
|
first[ i++ ] = second[ j++ ];
|
|
|
|
}
|
2009-03-31 17:35:20 +00:00
|
|
|
}
|
2008-01-14 22:30:48 +00:00
|
|
|
|
2009-12-10 05:43:20 +00:00
|
|
|
first.length = i;
|
|
|
|
|
2008-01-14 22:30:48 +00:00
|
|
|
return first;
|
|
|
|
},
|
|
|
|
|
|
|
|
grep: function( elems, callback, inv ) {
|
2010-03-02 02:24:49 +00:00
|
|
|
var ret = [], retVal;
|
|
|
|
inv = !!inv;
|
2008-01-14 22:30:48 +00:00
|
|
|
|
|
|
|
// Go through the array, only saving the items
|
|
|
|
// that pass the validator function
|
2009-03-31 17:35:20 +00:00
|
|
|
for ( var i = 0, length = elems.length; i < length; i++ ) {
|
2010-03-02 02:24:49 +00:00
|
|
|
retVal = !!callback( elems[ i ], i );
|
|
|
|
if ( inv !== retVal ) {
|
2008-01-14 22:30:48 +00:00
|
|
|
ret.push( elems[ i ] );
|
2009-03-31 17:35:20 +00:00
|
|
|
}
|
|
|
|
}
|
2008-01-14 22:30:48 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
},
|
|
|
|
|
2009-12-04 17:28:47 +00:00
|
|
|
// arg is for internal usage only
|
|
|
|
map: function( elems, callback, arg ) {
|
2011-04-05 15:33:14 +00:00
|
|
|
var value, key, ret = [],
|
2011-04-05 06:59:54 +00:00
|
|
|
i = 0,
|
2011-03-21 19:24:53 +00:00
|
|
|
length = elems.length,
|
2011-04-05 06:59:54 +00:00
|
|
|
// jquery objects are treated as arrays
|
2011-05-02 17:25:53 +00:00
|
|
|
isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
|
2008-01-14 22:30:48 +00:00
|
|
|
|
|
|
|
// Go through the array, translating each of the items to their
|
2011-03-21 19:12:31 +00:00
|
|
|
if ( isArray ) {
|
|
|
|
for ( ; i < length; i++ ) {
|
|
|
|
value = callback( elems[ i ], i, arg );
|
|
|
|
|
2011-02-27 18:47:35 +00:00
|
|
|
if ( value != null ) {
|
|
|
|
ret[ ret.length ] = value;
|
|
|
|
}
|
|
|
|
}
|
2008-01-14 22:30:48 +00:00
|
|
|
|
2011-04-22 01:51:23 +00:00
|
|
|
// Go through every key on the object,
|
2011-04-05 06:59:54 +00:00
|
|
|
} else {
|
2011-03-21 15:39:53 +00:00
|
|
|
for ( key in elems ) {
|
2011-03-21 19:12:31 +00:00
|
|
|
value = callback( elems[ key ], key, arg );
|
|
|
|
|
|
|
|
if ( value != null ) {
|
|
|
|
ret[ ret.length ] = value;
|
|
|
|
}
|
2009-03-31 17:35:20 +00:00
|
|
|
}
|
2008-01-14 22:30:48 +00:00
|
|
|
}
|
|
|
|
|
2010-11-27 22:15:33 +00:00
|
|
|
// Flatten any nested arrays
|
2008-05-06 14:54:53 +00:00
|
|
|
return ret.concat.apply( [], ret );
|
2009-03-31 17:35:20 +00:00
|
|
|
},
|
|
|
|
|
2009-12-31 20:06:45 +00:00
|
|
|
// A global GUID counter for objects
|
|
|
|
guid: 1,
|
|
|
|
|
2010-12-15 02:53:04 +00:00
|
|
|
// Bind a function to a context, optionally partially applying any
|
|
|
|
// arguments.
|
|
|
|
proxy: function( fn, context ) {
|
2011-01-21 15:33:50 +00:00
|
|
|
if ( typeof context === "string" ) {
|
2011-04-17 21:11:40 +00:00
|
|
|
var tmp = fn[ context ];
|
|
|
|
context = fn;
|
|
|
|
fn = tmp;
|
2009-12-31 20:06:45 +00:00
|
|
|
}
|
|
|
|
|
2010-12-15 02:53:04 +00:00
|
|
|
// Quick check to determine if target is callable, in the spec
|
|
|
|
// this throws a TypeError, but we will just return undefined.
|
2011-04-17 21:11:40 +00:00
|
|
|
if ( !jQuery.isFunction( fn ) ) {
|
2010-12-15 02:53:04 +00:00
|
|
|
return undefined;
|
2009-12-31 20:17:52 +00:00
|
|
|
}
|
2009-12-31 20:06:45 +00:00
|
|
|
|
2011-04-17 21:11:40 +00:00
|
|
|
// Simulated bind
|
|
|
|
var args = slice.call( arguments, 2 ),
|
|
|
|
proxy = function() {
|
|
|
|
return fn.apply( context, args.concat( slice.call( arguments ) ) );
|
|
|
|
};
|
2009-12-31 20:06:45 +00:00
|
|
|
|
|
|
|
// Set the guid of unique handler to the same of original handler, so it can be removed
|
2010-12-15 02:53:04 +00:00
|
|
|
proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
|
2009-12-31 20:06:45 +00:00
|
|
|
|
|
|
|
return proxy;
|
|
|
|
},
|
|
|
|
|
2010-03-23 16:12:16 +00:00
|
|
|
// Mutifunctional method to get and set values to a collection
|
2011-06-14 20:01:50 +00:00
|
|
|
// The value/s can optionally be executed if it's a function
|
2010-03-23 16:12:16 +00:00
|
|
|
access: function( elems, key, value, exec, fn, pass ) {
|
|
|
|
var length = elems.length;
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2010-03-23 16:12:16 +00:00
|
|
|
// Setting many attributes
|
|
|
|
if ( typeof key === "object" ) {
|
|
|
|
for ( var k in key ) {
|
|
|
|
jQuery.access( elems, k, key[k], exec, fn, value );
|
|
|
|
}
|
|
|
|
return elems;
|
|
|
|
}
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2010-03-23 16:12:16 +00:00
|
|
|
// Setting one attribute
|
|
|
|
if ( value !== undefined ) {
|
|
|
|
// Optionally, function values get executed if exec is true
|
|
|
|
exec = !pass && exec && jQuery.isFunction(value);
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2010-03-23 16:12:16 +00:00
|
|
|
for ( var i = 0; i < length; i++ ) {
|
|
|
|
fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
|
|
|
|
}
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2010-03-23 16:12:16 +00:00
|
|
|
return elems;
|
|
|
|
}
|
2010-12-30 06:34:48 +00:00
|
|
|
|
2010-03-23 16:12:16 +00:00
|
|
|
// Getting an attribute
|
|
|
|
return length ? fn( elems[0], key ) : undefined;
|
|
|
|
},
|
|
|
|
|
|
|
|
now: function() {
|
|
|
|
return (new Date()).getTime();
|
|
|
|
},
|
2011-01-05 21:41:23 +00:00
|
|
|
|
2009-12-09 06:52:32 +00:00
|
|
|
// Use of jQuery.browser is frowned upon.
|
2009-12-09 23:07:16 +00:00
|
|
|
// More details: http://docs.jquery.com/Utilities/jQuery.browser
|
2010-01-05 22:01:20 +00:00
|
|
|
uaMatch: function( ua ) {
|
|
|
|
ua = ua.toLowerCase();
|
|
|
|
|
2011-06-20 13:41:53 +00:00
|
|
|
var match = rchrome.exec( ua ) ||
|
|
|
|
rwebkit.exec( ua ) ||
|
2010-09-22 13:16:28 +00:00
|
|
|
ropera.exec( ua ) ||
|
|
|
|
rmsie.exec( ua ) ||
|
|
|
|
ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
|
2010-03-01 17:44:56 +00:00
|
|
|
[];
|
2010-01-05 22:01:20 +00:00
|
|
|
|
2010-01-23 17:13:46 +00:00
|
|
|
return { browser: match[1] || "", version: match[2] || "0" };
|
2010-01-05 22:01:20 +00:00
|
|
|
},
|
|
|
|
|
2011-01-31 13:21:42 +00:00
|
|
|
sub: function() {
|
2011-02-07 00:34:57 +00:00
|
|
|
function jQuerySub( selector, context ) {
|
|
|
|
return new jQuerySub.fn.init( selector, context );
|
2010-10-10 00:32:54 +00:00
|
|
|
}
|
2011-02-07 00:34:57 +00:00
|
|
|
jQuery.extend( true, jQuerySub, this );
|
|
|
|
jQuerySub.superclass = this;
|
|
|
|
jQuerySub.fn = jQuerySub.prototype = this();
|
|
|
|
jQuerySub.fn.constructor = jQuerySub;
|
|
|
|
jQuerySub.sub = this.sub;
|
|
|
|
jQuerySub.fn.init = function init( selector, context ) {
|
|
|
|
if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
|
|
|
|
context = jQuerySub( context );
|
2010-10-10 00:32:54 +00:00
|
|
|
}
|
2011-01-27 18:35:06 +00:00
|
|
|
|
2011-02-07 00:34:57 +00:00
|
|
|
return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
|
2010-10-10 00:32:54 +00:00
|
|
|
};
|
2011-02-07 00:34:57 +00:00
|
|
|
jQuerySub.fn.init.prototype = jQuerySub.fn;
|
|
|
|
var rootjQuerySub = jQuerySub(document);
|
|
|
|
return jQuerySub;
|
2010-10-10 00:32:54 +00:00
|
|
|
},
|
|
|
|
|
2010-01-05 22:01:20 +00:00
|
|
|
browser: {}
|
2008-01-14 22:30:48 +00:00
|
|
|
});
|
|
|
|
|
2010-08-27 23:14:59 +00:00
|
|
|
// Populate the class2type map
|
|
|
|
jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
|
|
|
|
class2type[ "[object " + name + "]" ] = name.toLowerCase();
|
|
|
|
});
|
|
|
|
|
2010-01-05 22:01:20 +00:00
|
|
|
browserMatch = jQuery.uaMatch( userAgent );
|
|
|
|
if ( browserMatch.browser ) {
|
|
|
|
jQuery.browser[ browserMatch.browser ] = true;
|
|
|
|
jQuery.browser.version = browserMatch.version;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Deprecated, use jQuery.browser.webkit instead
|
|
|
|
if ( jQuery.browser.webkit ) {
|
|
|
|
jQuery.browser.safari = true;
|
|
|
|
}
|
2009-12-09 06:52:32 +00:00
|
|
|
|
2011-01-18 23:15:28 +00:00
|
|
|
// IE doesn't match non-breaking spaces with \s
|
|
|
|
if ( rnotwhite.test( "\xA0" ) ) {
|
2010-03-09 14:14:27 +00:00
|
|
|
trimLeft = /^[\s\xA0]+/;
|
|
|
|
trimRight = /[\s\xA0]+$/;
|
|
|
|
}
|
|
|
|
|
2009-02-25 14:23:25 +00:00
|
|
|
// All jQuery objects should point back to these
|
2009-03-31 17:35:20 +00:00
|
|
|
rootjQuery = jQuery(document);
|
|
|
|
|
2009-12-16 21:45:00 +00:00
|
|
|
// Cleanup functions for the document ready method
|
|
|
|
if ( document.addEventListener ) {
|
|
|
|
DOMContentLoaded = function() {
|
|
|
|
document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
|
|
|
|
jQuery.ready();
|
|
|
|
};
|
|
|
|
|
|
|
|
} else if ( document.attachEvent ) {
|
|
|
|
DOMContentLoaded = function() {
|
|
|
|
// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
|
|
|
|
if ( document.readyState === "complete" ) {
|
|
|
|
document.detachEvent( "onreadystatechange", DOMContentLoaded );
|
|
|
|
jQuery.ready();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
// The DOM ready check for Internet Explorer
|
|
|
|
function doScrollCheck() {
|
|
|
|
if ( jQuery.isReady ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
// If IE is used, use the trick by Diego Perini
|
|
|
|
// http://javascript.nwbox.com/IEContentLoaded/
|
|
|
|
document.documentElement.doScroll("left");
|
2010-03-02 02:24:49 +00:00
|
|
|
} catch(e) {
|
2009-12-16 21:45:00 +00:00
|
|
|
setTimeout( doScrollCheck, 1 );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// and execute any waiting functions
|
|
|
|
jQuery.ready();
|
|
|
|
}
|
|
|
|
|
2011-01-24 03:19:33 +00:00
|
|
|
return jQuery;
|
2009-09-09 21:14:28 +00:00
|
|
|
|
2010-03-23 16:12:16 +00:00
|
|
|
})();
|