2010-09-09 14:23:10 +02:00
|
|
|
var jQuery = (function() {
|
2010-03-23 17:12:16 +01:00
|
|
|
|
2009-05-20 23:12:08 +02:00
|
|
|
// Define a local copy of jQuery
|
|
|
|
var jQuery = function( selector, context ) {
|
|
|
|
// The jQuery object is actually just the init constructor 'enhanced'
|
2009-12-10 05:36:07 +01:00
|
|
|
return new jQuery.fn.init( selector, context );
|
2009-05-20 23:12:08 +02:00
|
|
|
},
|
2009-03-31 19:35:20 +02:00
|
|
|
|
2009-01-04 23:25:46 +01:00
|
|
|
// Map over jQuery in case of overwrite
|
|
|
|
_jQuery = window.jQuery,
|
2009-03-31 19:35:20 +02:00
|
|
|
|
2009-01-04 23:25:46 +01:00
|
|
|
// Map over the $ in case of overwrite
|
|
|
|
_$ = window.$,
|
|
|
|
|
2009-03-31 19:35:20 +02:00
|
|
|
// A central reference to the root jQuery(document)
|
|
|
|
rootjQuery,
|
|
|
|
|
2009-01-04 23:25:46 +01:00
|
|
|
// A simple way to check for HTML strings or ID strings
|
|
|
|
// (both of which we optimize for)
|
2010-09-22 15:46:21 +02:00
|
|
|
quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,
|
2009-03-31 19:35:20 +02:00
|
|
|
|
2009-01-04 23:25:46 +01:00
|
|
|
// Is it a simple selector
|
2009-03-31 19:35:20 +02:00
|
|
|
isSimple = /^.[^:#\[\.,]*$/,
|
|
|
|
|
2009-07-19 21:47:30 +02:00
|
|
|
// Check if a string has a non-whitespace character in it
|
|
|
|
rnotwhite = /\S/,
|
2010-09-22 15:16:28 +02:00
|
|
|
rwhite = /\s/,
|
2009-07-19 21:47:30 +02:00
|
|
|
|
|
|
|
// Used for trimming whitespace
|
2010-03-09 15:14:27 +01:00
|
|
|
trimLeft = /^\s+/,
|
|
|
|
trimRight = /\s+$/,
|
2009-07-19 21:47:30 +02:00
|
|
|
|
2010-09-22 15:16:28 +02:00
|
|
|
// Check for non-word characters
|
|
|
|
rnonword = /\W/,
|
|
|
|
|
2010-09-27 17:51:01 +02:00
|
|
|
// Check for digits
|
|
|
|
rdigit = /\d/,
|
|
|
|
|
2009-09-07 20:58:01 +02:00
|
|
|
// Match a standalone tag
|
2009-11-30 19:42:19 +01:00
|
|
|
rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
|
2009-09-07 20:58:01 +02:00
|
|
|
|
2010-09-22 15:16:28 +02: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
|
|
|
|
rwebkit = /(webkit)[ \/]([\w.]+)/,
|
|
|
|
ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
|
|
|
|
rmsie = /(msie) ([\w.]+)/,
|
|
|
|
rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
|
|
|
|
|
2009-03-31 19:35:20 +02:00
|
|
|
// Keep a UserAgent string for use with jQuery.browser
|
2010-01-05 23:01:20 +01:00
|
|
|
userAgent = navigator.userAgent,
|
|
|
|
|
2010-01-06 20:23:39 +01:00
|
|
|
// For matching the engine and version of the browser
|
2010-01-05 23:01:20 +01:00
|
|
|
browserMatch,
|
2010-12-30 07:34:48 +01:00
|
|
|
|
2009-12-08 01:34:55 +01:00
|
|
|
// Has the ready events already been bound?
|
|
|
|
readyBound = false,
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-20 19:09:15 +01:00
|
|
|
// The deferred used on DOM ready
|
|
|
|
readyList,
|
2009-03-31 19:35:20 +02:00
|
|
|
|
2009-12-16 22:45:00 +01:00
|
|
|
// The ready event handler
|
|
|
|
DOMContentLoaded,
|
|
|
|
|
2009-07-19 21:50:45 +02:00
|
|
|
// Save a reference to some core methods
|
|
|
|
toString = Object.prototype.toString,
|
2010-03-02 00:19:29 +01:00
|
|
|
hasOwn = Object.prototype.hasOwnProperty,
|
2009-07-19 21:50:45 +02:00
|
|
|
push = Array.prototype.push,
|
2009-09-08 03:45:11 +02:00
|
|
|
slice = Array.prototype.slice,
|
2010-03-11 16:49:19 +01:00
|
|
|
trim = String.prototype.trim,
|
2010-08-28 01:14:59 +02:00
|
|
|
indexOf = Array.prototype.indexOf,
|
2010-12-30 07:34:48 +01:00
|
|
|
|
2010-08-28 01:14:59 +02:00
|
|
|
// [[Class]] -> type pairs
|
2010-12-30 17:06:53 +01:00
|
|
|
class2type = {};
|
2009-03-31 19:35:20 +02:00
|
|
|
|
2008-01-14 23:30:48 +01:00
|
|
|
jQuery.fn = jQuery.prototype = {
|
|
|
|
init: function( selector, context ) {
|
2009-12-17 20:17:05 +01:00
|
|
|
var match, elem, ret, doc;
|
2009-03-31 19:35:20 +02:00
|
|
|
|
|
|
|
// Handle $(""), $(null), or $(undefined)
|
2009-07-27 22:48:42 +02:00
|
|
|
if ( !selector ) {
|
|
|
|
return this;
|
|
|
|
}
|
2008-01-14 23:30:48 +01:00
|
|
|
|
|
|
|
// Handle $(DOMElement)
|
|
|
|
if ( selector.nodeType ) {
|
2009-07-17 19:33:44 +02:00
|
|
|
this.context = this[0] = selector;
|
2009-11-11 19:42:50 +01:00
|
|
|
this.length = 1;
|
2008-01-14 23:30:48 +01:00
|
|
|
return this;
|
2008-05-07 00:36:30 +02:00
|
|
|
}
|
2010-12-30 07:34:48 +01:00
|
|
|
|
2010-01-28 23:17:51 +01:00
|
|
|
// The body element only exists once, optimize finding it
|
2010-09-24 21:53:38 +02:00
|
|
|
if ( selector === "body" && !context && document.body ) {
|
2010-01-29 21:04:26 +01:00
|
|
|
this.context = document;
|
|
|
|
this[0] = document.body;
|
2010-01-28 23:17:51 +01:00
|
|
|
this.selector = "body";
|
|
|
|
this.length = 1;
|
|
|
|
return this;
|
|
|
|
}
|
2009-02-25 05:57:00 +01:00
|
|
|
|
2008-01-14 23:30:48 +01:00
|
|
|
// Handle HTML strings
|
2008-11-17 17:32:05 +01:00
|
|
|
if ( typeof selector === "string" ) {
|
2008-01-14 23:30:48 +01:00
|
|
|
// Are we dealing with HTML string or an ID?
|
2009-03-31 19:35:20 +02:00
|
|
|
match = quickExpr.exec( selector );
|
2008-01-14 23:30:48 +01:00
|
|
|
|
|
|
|
// Verify a match, and that no context was specified for #id
|
|
|
|
if ( match && (match[1] || !context) ) {
|
|
|
|
|
|
|
|
// HANDLE: $(html) -> $(array)
|
2009-02-25 05:57:00 +01:00
|
|
|
if ( match[1] ) {
|
2009-09-07 20:58:01 +02:00
|
|
|
doc = (context ? context.ownerDocument || context : document);
|
|
|
|
|
|
|
|
// 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 ) {
|
2009-12-18 18:41:53 +01:00
|
|
|
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 20:58:01 +02:00
|
|
|
|
|
|
|
} else {
|
2010-09-09 00:13:35 +02:00
|
|
|
ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
|
2011-01-10 01:38:44 +01:00
|
|
|
selector = (ret.cacheable ? jQuery(ret.fragment).clone()[0] : ret.fragment).childNodes;
|
2009-09-07 20:58:01 +02:00
|
|
|
}
|
2010-12-30 07:34:48 +01:00
|
|
|
|
2010-01-28 22:30:37 +01:00
|
|
|
return jQuery.merge( this, selector );
|
2010-12-30 07:34:48 +01:00
|
|
|
|
2008-01-14 23:30:48 +01:00
|
|
|
// HANDLE: $("#id")
|
2009-02-25 05:57:00 +01:00
|
|
|
} else {
|
2009-07-27 22:47:32 +02:00
|
|
|
elem = document.getElementById( match[2] );
|
2008-01-14 23:30:48 +01:00
|
|
|
|
2010-08-27 21:14:30 +02:00
|
|
|
// Check parentNode to catch when Blackberry 4.6 returns
|
|
|
|
// nodes that are no longer in the document #6963
|
|
|
|
if ( elem && elem.parentNode ) {
|
2009-07-17 03:47:26 +02:00
|
|
|
// Handle the case where IE and Opera return items
|
|
|
|
// by name instead of ID
|
2009-07-27 22:48:42 +02:00
|
|
|
if ( elem.id !== match[2] ) {
|
|
|
|
return rootjQuery.find( selector );
|
|
|
|
}
|
2009-07-17 03:47:26 +02:00
|
|
|
|
|
|
|
// Otherwise, we inject the element directly into the jQuery object
|
2009-11-11 19:42:50 +01:00
|
|
|
this.length = 1;
|
2009-07-11 15:44:44 +02:00
|
|
|
this[0] = elem;
|
|
|
|
}
|
2009-07-17 03:47:26 +02:00
|
|
|
|
2009-07-11 15:44:44 +02:00
|
|
|
this.context = document;
|
|
|
|
this.selector = selector;
|
|
|
|
return this;
|
2008-01-14 23:30:48 +01:00
|
|
|
}
|
|
|
|
|
2009-09-08 06:26:47 +02:00
|
|
|
// HANDLE: $("TAG")
|
2010-09-22 15:16:28 +02:00
|
|
|
} else if ( !context && !rnonword.test( selector ) ) {
|
2009-09-09 18:33:16 +02:00
|
|
|
this.selector = selector;
|
2009-09-09 18:50:58 +02:00
|
|
|
this.context = document;
|
2009-09-08 06:26:47 +02:00
|
|
|
selector = document.getElementsByTagName( selector );
|
2010-01-28 23:17:51 +01:00
|
|
|
return jQuery.merge( this, selector );
|
2009-09-08 06:26:47 +02:00
|
|
|
|
2009-02-25 15:23:25 +01:00
|
|
|
// HANDLE: $(expr, $(...))
|
|
|
|
} else if ( !context || context.jquery ) {
|
|
|
|
return (context || rootjQuery).find( selector );
|
2009-02-25 05:57:00 +01:00
|
|
|
|
2009-02-25 15:23:25 +01:00
|
|
|
// HANDLE: $(expr, context)
|
2009-03-05 14:36:12 +01:00
|
|
|
// (which is just equivalent to: $(context).find(expr)
|
2009-02-25 05:57:00 +01:00
|
|
|
} else {
|
2009-02-25 15:23:25 +01:00
|
|
|
return jQuery( context ).find( selector );
|
2009-02-25 05:57:00 +01:00
|
|
|
}
|
2008-01-14 23:30:48 +01:00
|
|
|
|
|
|
|
// HANDLE: $(function)
|
|
|
|
// Shortcut for document ready
|
2009-02-25 05:57:00 +01:00
|
|
|
} else if ( jQuery.isFunction( selector ) ) {
|
2009-02-25 15:23:25 +01:00
|
|
|
return rootjQuery.ready( selector );
|
2009-02-25 05:57:00 +01:00
|
|
|
}
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2009-09-09 18:33:16 +02:00
|
|
|
if (selector.selector !== undefined) {
|
2009-01-08 22:41:58 +01:00
|
|
|
this.selector = selector.selector;
|
|
|
|
this.context = selector.context;
|
|
|
|
}
|
|
|
|
|
2010-01-28 23:17:51 +01:00
|
|
|
return jQuery.makeArray( selector, this );
|
2008-01-14 23:30:48 +01:00
|
|
|
},
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2008-12-19 05:37:10 +01:00
|
|
|
// Start with an empty selector
|
|
|
|
selector: "",
|
|
|
|
|
2008-01-14 23:30:48 +01:00
|
|
|
// The current version of jQuery being used
|
|
|
|
jquery: "@VERSION",
|
|
|
|
|
2009-07-17 03:47:26 +02:00
|
|
|
// The default length of a jQuery object is 0
|
|
|
|
length: 0,
|
|
|
|
|
2008-01-14 23:30:48 +01:00
|
|
|
// The number of elements contained in the matched element set
|
|
|
|
size: function() {
|
|
|
|
return this.length;
|
|
|
|
},
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2009-12-22 01:58:13 +01:00
|
|
|
toArray: function() {
|
2009-07-23 15:22:55 +02:00
|
|
|
return slice.call( this, 0 );
|
|
|
|
},
|
2009-07-16 09:31:32 +02:00
|
|
|
|
2008-01-14 23:30:48 +01: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 19:35:20 +02:00
|
|
|
return num == null ?
|
2008-01-14 23:30:48 +01:00
|
|
|
|
|
|
|
// Return a 'clean' array
|
2009-07-16 09:31:41 +02:00
|
|
|
this.toArray() :
|
2008-01-14 23:30:48 +01:00
|
|
|
|
|
|
|
// Return just the object
|
2010-11-19 12:28:13 +01:00
|
|
|
( num < 0 ? this[ this.length + num ] : this[ num ] );
|
2008-01-14 23:30:48 +01:00
|
|
|
},
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2008-01-14 23:30:48 +01:00
|
|
|
// Take an array of elements and push it onto the stack
|
|
|
|
// (returning the new matched element set)
|
2008-12-19 05:37:10 +01:00
|
|
|
pushStack: function( elems, name, selector ) {
|
2008-01-14 23:30:48 +01:00
|
|
|
// Build a new jQuery matched element set
|
2010-02-13 07:45:09 +01:00
|
|
|
var ret = jQuery();
|
|
|
|
|
|
|
|
if ( jQuery.isArray( elems ) ) {
|
|
|
|
push.apply( ret, elems );
|
2010-12-30 07:34:48 +01:00
|
|
|
|
2010-02-13 07:45:09 +01:00
|
|
|
} else {
|
|
|
|
jQuery.merge( ret, elems );
|
|
|
|
}
|
2008-01-14 23:30:48 +01:00
|
|
|
|
|
|
|
// Add the old object onto the stack (as a reference)
|
|
|
|
ret.prevObject = this;
|
|
|
|
|
2008-12-19 05:37:10 +01:00
|
|
|
ret.context = this.context;
|
|
|
|
|
2009-03-31 19:35:20 +02:00
|
|
|
if ( name === "find" ) {
|
2008-12-19 05:37:10 +01:00
|
|
|
ret.selector = this.selector + (this.selector ? " " : "") + selector;
|
2009-03-31 19:35:20 +02:00
|
|
|
} else if ( name ) {
|
2008-12-19 05:37:10 +01:00
|
|
|
ret.selector = this.selector + "." + name + "(" + selector + ")";
|
2009-03-31 19:35:20 +02:00
|
|
|
}
|
2008-12-19 05:37:10 +01:00
|
|
|
|
2008-01-14 23:30:48 +01:00
|
|
|
// Return the newly-formed element set
|
|
|
|
return ret;
|
|
|
|
},
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2008-01-14 23:30:48 +01: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 22:41:23 +01:00
|
|
|
|
2010-12-20 19:09:15 +01:00
|
|
|
ready: function() {
|
2009-12-08 01:34:55 +01:00
|
|
|
// Attach the listeners
|
|
|
|
jQuery.bindReady();
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-20 19:09:15 +01:00
|
|
|
// Change ready & apply
|
2011-01-06 01:26:06 +01:00
|
|
|
return ( jQuery.fn.ready = readyList.done ).apply( this , arguments );
|
2009-12-08 01:34:55 +01:00
|
|
|
},
|
2010-12-30 07:34:48 +01:00
|
|
|
|
2009-12-10 18:25:25 +01: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 01:58:13 +01:00
|
|
|
return this.pushStack( jQuery.map(this, function( elem, i ) {
|
2009-12-10 18:25:25 +01:00
|
|
|
return callback.call( elem, i, elem );
|
|
|
|
}));
|
|
|
|
},
|
2010-12-30 07:34:48 +01:00
|
|
|
|
2009-12-10 18:25:25 +01:00
|
|
|
end: function() {
|
|
|
|
return this.prevObject || jQuery(null);
|
|
|
|
},
|
2008-01-14 23:30:48 +01:00
|
|
|
|
2009-03-17 21:39:29 +01:00
|
|
|
// For internal use only.
|
|
|
|
// Behaves like an Array's method, not like a jQuery method.
|
2009-07-19 21:50:45 +02:00
|
|
|
push: push,
|
2009-03-17 21:39:29 +01:00
|
|
|
sort: [].sort,
|
2009-03-18 22:15:38 +01:00
|
|
|
splice: [].splice
|
2008-01-14 23:30:48 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// Give the init function the jQuery prototype for later instantiation
|
2008-04-30 01:34:50 +02:00
|
|
|
jQuery.fn.init.prototype = jQuery.fn;
|
2008-01-14 23:30:48 +01:00
|
|
|
|
|
|
|
jQuery.extend = jQuery.fn.extend = function() {
|
2010-11-09 17:09:07 +01:00
|
|
|
var options, name, src, copy, copyIsArray, clone,
|
|
|
|
target = arguments[0] || {},
|
|
|
|
i = 1,
|
|
|
|
length = arguments.length,
|
|
|
|
deep = false;
|
2008-01-14 23:30:48 +01:00
|
|
|
|
|
|
|
// Handle a deep copy situation
|
2008-11-17 17:32:05 +01:00
|
|
|
if ( typeof target === "boolean" ) {
|
2008-01-14 23:30:48 +01: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 19:35:20 +02:00
|
|
|
if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
|
2008-01-14 23:30:48 +01:00
|
|
|
target = {};
|
2009-03-31 19:35:20 +02:00
|
|
|
}
|
2008-01-14 23:30:48 +01:00
|
|
|
|
|
|
|
// extend jQuery itself if only one argument is passed
|
2009-03-31 19:35:20 +02:00
|
|
|
if ( length === i ) {
|
2008-01-14 23:30:48 +01:00
|
|
|
target = this;
|
2008-04-30 02:09:55 +02:00
|
|
|
--i;
|
2008-01-14 23:30:48 +01:00
|
|
|
}
|
|
|
|
|
2009-03-31 19:35:20 +02:00
|
|
|
for ( ; i < length; i++ ) {
|
2008-01-14 23:30:48 +01:00
|
|
|
// Only deal with non-null/undefined values
|
2009-03-31 19:35:20 +02:00
|
|
|
if ( (options = arguments[ i ]) != null ) {
|
2008-01-14 23:30:48 +01:00
|
|
|
// Extend the base object
|
2009-03-31 19:35:20 +02:00
|
|
|
for ( name in options ) {
|
|
|
|
src = target[ name ];
|
|
|
|
copy = options[ name ];
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2008-01-14 23:30:48 +01:00
|
|
|
// Prevent never-ending loop
|
2009-03-31 19:35:20 +02:00
|
|
|
if ( target === copy ) {
|
2008-01-14 23:30:48 +01:00
|
|
|
continue;
|
2009-03-31 19:35:20 +02:00
|
|
|
}
|
2008-01-14 23:30:48 +01:00
|
|
|
|
2010-01-30 19:50:49 +01: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 09:32:03 +02:00
|
|
|
|
|
|
|
// Never move original objects, clone them
|
|
|
|
target[ name ] = jQuery.extend( deep, clone, copy );
|
2008-01-14 23:30:48 +01:00
|
|
|
|
|
|
|
// Don't bring in undefined values
|
2009-03-31 19:35:20 +02:00
|
|
|
} else if ( copy !== undefined ) {
|
2008-04-30 02:09:55 +02:00
|
|
|
target[ name ] = copy;
|
2009-03-31 19:35:20 +02:00
|
|
|
}
|
2008-01-14 23:30:48 +01:00
|
|
|
}
|
2009-03-31 19:35:20 +02:00
|
|
|
}
|
|
|
|
}
|
2008-01-14 23:30:48 +01:00
|
|
|
|
|
|
|
// Return the modified object
|
|
|
|
return target;
|
|
|
|
};
|
|
|
|
|
|
|
|
jQuery.extend({
|
|
|
|
noConflict: function( deep ) {
|
|
|
|
window.$ = _$;
|
|
|
|
|
2009-03-31 19:35:20 +02:00
|
|
|
if ( deep ) {
|
2008-01-14 23:30:48 +01:00
|
|
|
window.jQuery = _jQuery;
|
2009-03-31 19:35:20 +02:00
|
|
|
}
|
2008-01-14 23:30:48 +01:00
|
|
|
|
|
|
|
return jQuery;
|
|
|
|
},
|
2010-12-30 07:34:48 +01:00
|
|
|
|
2009-12-08 01:34:55 +01:00
|
|
|
// Is the DOM ready to be used? Set to true once it occurs.
|
|
|
|
isReady: false,
|
2010-09-20 20:53:29 +02:00
|
|
|
|
|
|
|
// A counter to track how many items to wait for before
|
|
|
|
// the ready event fires. See #6781
|
|
|
|
readyWait: 1,
|
2010-12-30 07:34:48 +01:00
|
|
|
|
2009-12-08 01:34:55 +01:00
|
|
|
// Handle when the DOM is ready
|
2010-09-20 20:53:29 +02:00
|
|
|
ready: function( wait ) {
|
|
|
|
// A third-party is pushing the ready event forwards
|
|
|
|
if ( wait === true ) {
|
|
|
|
jQuery.readyWait--;
|
|
|
|
}
|
|
|
|
|
2009-12-08 01:34:55 +01:00
|
|
|
// Make sure that the DOM is not already loaded
|
2010-09-21 22:26:36 +02:00
|
|
|
if ( !jQuery.readyWait || (wait !== true && !jQuery.isReady) ) {
|
2009-12-16 22:45:00 +01:00
|
|
|
// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
|
2009-12-08 01:34:55 +01:00
|
|
|
if ( !document.body ) {
|
2010-09-24 16:06:36 +02:00
|
|
|
return setTimeout( jQuery.ready, 1 );
|
2009-12-08 01:34:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Remember that the DOM is ready
|
|
|
|
jQuery.isReady = true;
|
|
|
|
|
2010-09-20 20:53:29 +02:00
|
|
|
// If a normal DOM Ready event fired, decrement, and wait if need be
|
|
|
|
if ( wait !== true && --jQuery.readyWait > 0 ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-12-08 01:34:55 +01:00
|
|
|
// If there are functions bound, to execute
|
2010-12-20 19:09:15 +01:00
|
|
|
readyList.fire( document , [ jQuery ] );
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-20 19:09:15 +01:00
|
|
|
// Trigger any bound ready events
|
|
|
|
if ( jQuery.fn.trigger ) {
|
|
|
|
jQuery( document ).trigger( "ready" ).unbind( "ready" );
|
2009-12-08 01:34:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2010-12-30 07:34:48 +01:00
|
|
|
|
2009-12-08 01:34:55 +01:00
|
|
|
bindReady: function() {
|
2009-12-22 01:58:13 +01:00
|
|
|
if ( readyBound ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-12-08 01:34:55 +01:00
|
|
|
readyBound = true;
|
|
|
|
|
|
|
|
// Catch cases where $(document).ready() is called after the
|
|
|
|
// browser event has already occurred.
|
|
|
|
if ( document.readyState === "complete" ) {
|
2010-09-23 17:38:22 +02:00
|
|
|
// Handle it asynchronously to allow scripts the opportunity to delay ready
|
2010-09-24 16:06:36 +02:00
|
|
|
return setTimeout( jQuery.ready, 1 );
|
2009-12-08 01:34:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Mozilla, Opera and webkit nightlies currently support this event
|
|
|
|
if ( document.addEventListener ) {
|
|
|
|
// Use the handy event callback
|
2009-12-16 22:45:00 +01:00
|
|
|
document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
|
2010-12-30 07:34:48 +01:00
|
|
|
|
2009-12-08 01:34:55 +01: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
|
2009-12-16 22:45:00 +01:00
|
|
|
document.attachEvent("onreadystatechange", DOMContentLoaded);
|
2010-12-30 07:34:48 +01:00
|
|
|
|
2009-12-08 01:34:55 +01: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 01:58:13 +01:00
|
|
|
} catch(e) {}
|
2009-12-08 01:34:55 +01:00
|
|
|
|
|
|
|
if ( document.documentElement.doScroll && toplevel ) {
|
2009-12-08 01:42:25 +01:00
|
|
|
doScrollCheck();
|
2009-12-08 01:34:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2008-01-14 23:30:48 +01:00
|
|
|
|
2008-11-17 17:32:05 +01:00
|
|
|
// See test/unit/core.js for details concerning isFunction.
|
2008-10-19 00:22:08 +02:00
|
|
|
// Since version 1.3, DOM methods and functions like alert
|
2008-07-23 18:18:05 +02:00
|
|
|
// aren't supported. They return false on IE (#2968).
|
2008-11-17 17:32:05 +01:00
|
|
|
isFunction: function( obj ) {
|
2010-08-25 18:57:34 +02:00
|
|
|
return jQuery.type(obj) === "function";
|
2008-01-14 23:30:48 +01:00
|
|
|
},
|
2008-11-17 17:32:05 +01:00
|
|
|
|
2010-08-27 19:15:48 +02:00
|
|
|
isArray: Array.isArray || function( obj ) {
|
2010-08-25 18:57:34 +02:00
|
|
|
return jQuery.type(obj) === "array";
|
|
|
|
},
|
|
|
|
|
2010-09-22 22:41:51 +02:00
|
|
|
// A crude way of determining if an object is a window
|
|
|
|
isWindow: function( obj ) {
|
2010-09-22 22:50:38 +02:00
|
|
|
return obj && typeof obj === "object" && "setInterval" in obj;
|
2010-09-22 22:41:51 +02:00
|
|
|
},
|
|
|
|
|
2010-09-27 17:51:01 +02:00
|
|
|
isNaN: function( obj ) {
|
|
|
|
return obj == null || !rdigit.test( obj ) || isNaN( obj );
|
|
|
|
},
|
|
|
|
|
2010-08-25 18:57:34 +02:00
|
|
|
type: function( obj ) {
|
2010-08-27 16:03:30 +02:00
|
|
|
return obj == null ?
|
|
|
|
String( obj ) :
|
2010-08-28 01:14:59 +02:00
|
|
|
class2type[ toString.call(obj) ] || "object";
|
2008-10-29 03:01:22 +01:00
|
|
|
},
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2009-12-06 23:11:51 +01:00
|
|
|
isPlainObject: function( obj ) {
|
2009-12-18 17:34:20 +01:00
|
|
|
// Must be an Object.
|
|
|
|
// Because of IE, we also have to check the presence of the constructor property.
|
2009-12-19 01:36:35 +01:00
|
|
|
// Make sure that DOM nodes and window objects don't pass through, as well
|
2010-09-22 22:41:51 +02:00
|
|
|
if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
|
2009-11-09 00:26:01 +01:00
|
|
|
return false;
|
|
|
|
}
|
2010-12-30 07:34:48 +01:00
|
|
|
|
2009-12-18 17:34:20 +01:00
|
|
|
// Not own constructor property must be Object
|
2010-03-02 00:19:29 +01:00
|
|
|
if ( obj.constructor &&
|
|
|
|
!hasOwn.call(obj, "constructor") &&
|
|
|
|
!hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
|
2009-11-12 05:50:40 +01:00
|
|
|
return false;
|
|
|
|
}
|
2010-12-30 07:34:48 +01:00
|
|
|
|
2009-12-18 17:34:20 +01:00
|
|
|
// Own properties are enumerated firstly, so to speed up,
|
|
|
|
// if last one is own, then all properties are own.
|
2010-12-30 07:34:48 +01:00
|
|
|
|
2009-11-09 00:26:01 +01:00
|
|
|
var key;
|
|
|
|
for ( key in obj ) {}
|
2010-12-30 07:34:48 +01:00
|
|
|
|
2010-03-02 00:19:29 +01:00
|
|
|
return key === undefined || hasOwn.call( obj, key );
|
2009-07-16 09:32:03 +02:00
|
|
|
},
|
|
|
|
|
2009-07-16 09:32:31 +02:00
|
|
|
isEmptyObject: function( obj ) {
|
2009-07-19 21:55:21 +02:00
|
|
|
for ( var name in obj ) {
|
2009-07-16 17:16:44 +02:00
|
|
|
return false;
|
2009-07-19 21:55:21 +02:00
|
|
|
}
|
2009-07-16 17:16:44 +02:00
|
|
|
return true;
|
2009-07-16 09:32:31 +02:00
|
|
|
},
|
2010-12-30 07:34:48 +01:00
|
|
|
|
2010-01-23 22:48:47 +01:00
|
|
|
error: function( msg ) {
|
|
|
|
throw msg;
|
|
|
|
},
|
2010-12-30 07:34:48 +01:00
|
|
|
|
2010-01-23 22:51:51 +01:00
|
|
|
parseJSON: function( data ) {
|
2010-01-23 23:08:26 +01:00
|
|
|
if ( typeof data !== "string" || !data ) {
|
|
|
|
return null;
|
|
|
|
}
|
2010-02-13 08:14:23 +01:00
|
|
|
|
|
|
|
// Make sure leading/trailing whitespace is removed (IE can't handle it)
|
|
|
|
data = jQuery.trim( data );
|
2010-12-30 07:34:48 +01:00
|
|
|
|
2010-01-23 22:51:51 +01:00
|
|
|
// Make sure the incoming data is actual JSON
|
|
|
|
// Logic borrowed from http://json.org/json2.js
|
2010-09-22 15:16:28 +02:00
|
|
|
if ( rvalidchars.test(data.replace(rvalidescape, "@")
|
|
|
|
.replace(rvalidtokens, "]")
|
|
|
|
.replace(rvalidbraces, "")) ) {
|
2010-01-23 22:51:51 +01:00
|
|
|
|
|
|
|
// Try to use the native JSON parser first
|
2010-01-23 23:08:26 +01:00
|
|
|
return window.JSON && window.JSON.parse ?
|
|
|
|
window.JSON.parse( data ) :
|
|
|
|
(new Function("return " + data))();
|
2010-01-23 22:51:51 +01:00
|
|
|
|
|
|
|
} else {
|
|
|
|
jQuery.error( "Invalid JSON: " + data );
|
|
|
|
}
|
|
|
|
},
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-24 18:02:00 +01:00
|
|
|
// Cross-browser xml parsing
|
|
|
|
// (xml & tmp used internally)
|
|
|
|
parseXML: function( data , xml , tmp ) {
|
|
|
|
|
|
|
|
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 );
|
|
|
|
}
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-24 18:02:00 +01:00
|
|
|
tmp = xml.documentElement;
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-24 18:02:00 +01:00
|
|
|
if ( ! tmp || ! tmp.nodeName || tmp.nodeName === "parsererror" ) {
|
|
|
|
jQuery.error( "Invalid XML: " + data );
|
|
|
|
}
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-24 18:02:00 +01:00
|
|
|
return xml;
|
|
|
|
},
|
2009-07-16 09:32:31 +02:00
|
|
|
|
2009-12-31 15:50:49 +01:00
|
|
|
noop: function() {},
|
|
|
|
|
2008-01-14 23:30:48 +01:00
|
|
|
// Evalulates a script in a global context
|
|
|
|
globalEval: function( data ) {
|
2009-07-19 21:47:30 +02:00
|
|
|
if ( data && rnotwhite.test(data) ) {
|
2008-01-14 23:30:48 +01:00
|
|
|
// Inspired by code by Andrea Giammarchi
|
|
|
|
// http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
|
|
|
|
var head = document.getElementsByTagName("head")[0] || document.documentElement,
|
|
|
|
script = document.createElement("script");
|
|
|
|
|
|
|
|
script.type = "text/javascript";
|
2009-07-19 21:55:21 +02:00
|
|
|
|
2009-03-31 19:35:20 +02:00
|
|
|
if ( jQuery.support.scriptEval ) {
|
2008-01-14 23:30:48 +01:00
|
|
|
script.appendChild( document.createTextNode( data ) );
|
2009-03-31 19:35:20 +02:00
|
|
|
} else {
|
2008-12-21 22:22:44 +01:00
|
|
|
script.text = data;
|
2009-03-31 19:35:20 +02:00
|
|
|
}
|
2008-01-14 23:30:48 +01:00
|
|
|
|
2009-12-10 06:15:49 +01:00
|
|
|
// Use insertBefore instead of appendChild to circumvent an IE6 bug.
|
2008-05-16 20:37:11 +02:00
|
|
|
// This arises when a base node is used (#2709).
|
|
|
|
head.insertBefore( script, head.firstChild );
|
2008-01-14 23:30:48 +01:00
|
|
|
head.removeChild( script );
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
nodeName: function( elem, name ) {
|
2009-03-31 19:35:20 +02:00
|
|
|
return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
|
2008-01-14 23:30:48 +01:00
|
|
|
},
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2008-01-14 23:30:48 +01:00
|
|
|
// args is for internal usage only
|
|
|
|
each: function( object, callback, args ) {
|
2009-07-16 09:31:32 +02:00
|
|
|
var name, i = 0,
|
2009-06-20 17:51:19 +02:00
|
|
|
length = object.length,
|
|
|
|
isObj = length === undefined || jQuery.isFunction(object);
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2008-01-14 23:30:48 +01:00
|
|
|
if ( args ) {
|
2009-06-20 17:51:19 +02:00
|
|
|
if ( isObj ) {
|
2009-03-31 19:35:20 +02:00
|
|
|
for ( name in object ) {
|
|
|
|
if ( callback.apply( object[ name ], args ) === false ) {
|
2008-01-14 23:30:48 +01:00
|
|
|
break;
|
2009-03-31 19:35:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for ( ; i < length; ) {
|
|
|
|
if ( callback.apply( object[ i++ ], args ) === false ) {
|
2008-01-14 23:30:48 +01:00
|
|
|
break;
|
2009-03-31 19:35:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-01-14 23:30:48 +01:00
|
|
|
|
|
|
|
// A special, fast, case for the most common use of each
|
|
|
|
} else {
|
2009-06-20 17:51:19 +02:00
|
|
|
if ( isObj ) {
|
2009-03-31 19:35:20 +02:00
|
|
|
for ( name in object ) {
|
|
|
|
if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
|
2008-01-14 23:30:48 +01:00
|
|
|
break;
|
2009-03-31 19:35:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2008-05-13 03:45:58 +02:00
|
|
|
for ( var value = object[0];
|
2009-03-31 19:35:20 +02:00
|
|
|
i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
|
|
|
|
}
|
2008-01-14 23:30:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return object;
|
|
|
|
},
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2010-03-09 15:14:27 +01:00
|
|
|
// Use native String.trim function wherever possible
|
2010-03-11 16:49:19 +01:00
|
|
|
trim: trim ?
|
2010-03-09 15:14:27 +01:00
|
|
|
function( text ) {
|
|
|
|
return text == null ?
|
|
|
|
"" :
|
2010-03-11 16:49:19 +01:00
|
|
|
trim.call( text );
|
2010-03-09 15:14:27 +01:00
|
|
|
} :
|
|
|
|
|
|
|
|
// Otherwise use our own trimming functionality
|
|
|
|
function( text ) {
|
|
|
|
return text == null ?
|
|
|
|
"" :
|
|
|
|
text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
|
|
|
|
},
|
2008-01-14 23:30:48 +01:00
|
|
|
|
2009-11-18 03:26:42 +01:00
|
|
|
// results is for internal usage only
|
|
|
|
makeArray: function( array, results ) {
|
|
|
|
var ret = results || [];
|
2008-01-14 23:30:48 +01:00
|
|
|
|
2009-03-31 19:35:20 +02:00
|
|
|
if ( array != null ) {
|
2008-08-12 21:34:30 +02:00
|
|
|
// The window, strings (and functions) also have 'length'
|
2009-12-07 05:20:49 +01:00
|
|
|
// The extra typeof function check is to prevent crashes
|
|
|
|
// in Safari 2 (See: #3039)
|
2010-08-23 21:38:55 +02:00
|
|
|
// Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
|
2010-08-25 18:57:34 +02:00
|
|
|
var type = jQuery.type(array);
|
2010-08-25 18:27:30 +02:00
|
|
|
|
2010-09-22 22:41:51 +02:00
|
|
|
if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
|
2009-11-18 03:26:42 +01:00
|
|
|
push.call( ret, array );
|
2009-03-31 19:35:20 +02:00
|
|
|
} else {
|
2009-11-18 03:26:42 +01:00
|
|
|
jQuery.merge( ret, array );
|
2009-03-31 19:35:20 +02:00
|
|
|
}
|
2008-04-25 05:48:07 +02:00
|
|
|
}
|
2008-01-14 23:30:48 +01:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
},
|
|
|
|
|
|
|
|
inArray: function( elem, array ) {
|
2009-11-11 21:15:58 +01:00
|
|
|
if ( array.indexOf ) {
|
|
|
|
return array.indexOf( elem );
|
|
|
|
}
|
|
|
|
|
2009-03-31 19:35:20 +02:00
|
|
|
for ( var i = 0, length = array.length; i < length; i++ ) {
|
|
|
|
if ( array[ i ] === elem ) {
|
2008-01-14 23:30:48 +01:00
|
|
|
return i;
|
2009-03-31 19:35:20 +02:00
|
|
|
}
|
|
|
|
}
|
2008-01-14 23:30:48 +01:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
},
|
|
|
|
|
|
|
|
merge: function( first, second ) {
|
2010-11-09 17:09:07 +01:00
|
|
|
var i = first.length,
|
|
|
|
j = 0;
|
2009-05-02 21:22:55 +02:00
|
|
|
|
2009-12-10 06:43:20 +01:00
|
|
|
if ( typeof second.length === "number" ) {
|
|
|
|
for ( var l = second.length; j < l; j++ ) {
|
|
|
|
first[ i++ ] = second[ j ];
|
|
|
|
}
|
2010-12-30 07:34:48 +01:00
|
|
|
|
2009-12-10 06:43:20 +01:00
|
|
|
} else {
|
|
|
|
while ( second[j] !== undefined ) {
|
|
|
|
first[ i++ ] = second[ j++ ];
|
|
|
|
}
|
2009-03-31 19:35:20 +02:00
|
|
|
}
|
2008-01-14 23:30:48 +01:00
|
|
|
|
2009-12-10 06:43:20 +01:00
|
|
|
first.length = i;
|
|
|
|
|
2008-01-14 23:30:48 +01:00
|
|
|
return first;
|
|
|
|
},
|
|
|
|
|
|
|
|
grep: function( elems, callback, inv ) {
|
2010-03-02 03:24:49 +01:00
|
|
|
var ret = [], retVal;
|
|
|
|
inv = !!inv;
|
2008-01-14 23:30:48 +01:00
|
|
|
|
|
|
|
// Go through the array, only saving the items
|
|
|
|
// that pass the validator function
|
2009-03-31 19:35:20 +02:00
|
|
|
for ( var i = 0, length = elems.length; i < length; i++ ) {
|
2010-03-02 03:24:49 +01:00
|
|
|
retVal = !!callback( elems[ i ], i );
|
|
|
|
if ( inv !== retVal ) {
|
2008-01-14 23:30:48 +01:00
|
|
|
ret.push( elems[ i ] );
|
2009-03-31 19:35:20 +02:00
|
|
|
}
|
|
|
|
}
|
2008-01-14 23:30:48 +01:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
},
|
|
|
|
|
2009-12-04 18:28:47 +01:00
|
|
|
// arg is for internal usage only
|
|
|
|
map: function( elems, callback, arg ) {
|
2009-03-31 19:35:20 +02:00
|
|
|
var ret = [], value;
|
2008-01-14 23:30:48 +01:00
|
|
|
|
|
|
|
// Go through the array, translating each of the items to their
|
|
|
|
// new value (or values).
|
|
|
|
for ( var i = 0, length = elems.length; i < length; i++ ) {
|
2009-12-04 18:28:47 +01:00
|
|
|
value = callback( elems[ i ], i, arg );
|
2008-01-14 23:30:48 +01:00
|
|
|
|
2009-03-31 19:35:20 +02:00
|
|
|
if ( value != null ) {
|
2008-05-06 16:54:53 +02:00
|
|
|
ret[ ret.length ] = value;
|
2009-03-31 19:35:20 +02:00
|
|
|
}
|
2008-01-14 23:30:48 +01:00
|
|
|
}
|
|
|
|
|
2010-11-27 23:15:33 +01:00
|
|
|
// Flatten any nested arrays
|
2008-05-06 16:54:53 +02:00
|
|
|
return ret.concat.apply( [], ret );
|
2009-03-31 19:35:20 +02:00
|
|
|
},
|
|
|
|
|
2009-12-31 21:06:45 +01:00
|
|
|
// A global GUID counter for objects
|
|
|
|
guid: 1,
|
|
|
|
|
|
|
|
proxy: function( fn, proxy, thisObject ) {
|
2009-12-31 21:17:52 +01:00
|
|
|
if ( arguments.length === 2 ) {
|
|
|
|
if ( typeof proxy === "string" ) {
|
|
|
|
thisObject = fn;
|
|
|
|
fn = thisObject[ proxy ];
|
|
|
|
proxy = undefined;
|
|
|
|
|
|
|
|
} else if ( proxy && !jQuery.isFunction( proxy ) ) {
|
|
|
|
thisObject = proxy;
|
|
|
|
proxy = undefined;
|
|
|
|
}
|
2009-12-31 21:06:45 +01:00
|
|
|
}
|
|
|
|
|
2009-12-31 21:17:52 +01:00
|
|
|
if ( !proxy && fn ) {
|
|
|
|
proxy = function() {
|
|
|
|
return fn.apply( thisObject || this, arguments );
|
|
|
|
};
|
|
|
|
}
|
2009-12-31 21:06:45 +01:00
|
|
|
|
|
|
|
// Set the guid of unique handler to the same of original handler, so it can be removed
|
2009-12-31 21:17:52 +01:00
|
|
|
if ( fn ) {
|
|
|
|
proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
|
|
|
|
}
|
2009-12-31 21:06:45 +01:00
|
|
|
|
|
|
|
// So proxy can be declared as an argument
|
|
|
|
return proxy;
|
|
|
|
},
|
|
|
|
|
2010-03-23 17:12:16 +01:00
|
|
|
// Mutifunctional method to get and set values to a collection
|
|
|
|
// The value/s can be optionally by executed if its a function
|
|
|
|
access: function( elems, key, value, exec, fn, pass ) {
|
|
|
|
var length = elems.length;
|
2010-12-30 07:34:48 +01:00
|
|
|
|
2010-03-23 17:12:16 +01: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 07:34:48 +01:00
|
|
|
|
2010-03-23 17:12:16 +01: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 07:34:48 +01:00
|
|
|
|
2010-03-23 17:12:16 +01: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 07:34:48 +01:00
|
|
|
|
2010-03-23 17:12:16 +01:00
|
|
|
return elems;
|
|
|
|
}
|
2010-12-30 07:34:48 +01:00
|
|
|
|
2010-03-23 17:12:16 +01:00
|
|
|
// Getting an attribute
|
|
|
|
return length ? fn( elems[0], key ) : undefined;
|
|
|
|
},
|
|
|
|
|
|
|
|
now: function() {
|
|
|
|
return (new Date()).getTime();
|
|
|
|
},
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-20 19:09:15 +01:00
|
|
|
// Create a simple deferred (one callbacks list)
|
2010-12-25 01:29:04 +01:00
|
|
|
_Deferred: function() {
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-20 19:09:15 +01:00
|
|
|
var // callbacks list
|
|
|
|
callbacks = [],
|
|
|
|
// stored [ context , args ]
|
|
|
|
fired,
|
|
|
|
// to avoid firing when already doing so
|
|
|
|
firing,
|
|
|
|
// flag to know if the deferred has been cancelled
|
|
|
|
cancelled,
|
|
|
|
// the deferred itself
|
|
|
|
deferred = {
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2011-01-06 01:26:06 +01:00
|
|
|
// done( f1, f2, ...)
|
|
|
|
done: function () {
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-20 19:09:15 +01:00
|
|
|
if ( ! cancelled ) {
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-20 19:09:15 +01:00
|
|
|
var args = arguments,
|
|
|
|
i,
|
2010-12-21 00:56:00 +01:00
|
|
|
length,
|
|
|
|
elem,
|
2010-12-20 19:09:15 +01:00
|
|
|
type,
|
|
|
|
_fired;
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-20 19:09:15 +01:00
|
|
|
if ( fired ) {
|
|
|
|
_fired = fired;
|
|
|
|
fired = 0;
|
|
|
|
}
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-21 00:56:00 +01:00
|
|
|
for ( i = 0, length = args.length ; i < length ; i++ ) {
|
|
|
|
elem = args[ i ];
|
|
|
|
type = jQuery.type( elem );
|
2010-12-20 19:09:15 +01:00
|
|
|
if ( type === "array" ) {
|
2011-01-06 01:26:06 +01:00
|
|
|
deferred.done.apply( deferred , elem );
|
2010-12-20 19:09:15 +01:00
|
|
|
} else if ( type === "function" ) {
|
2010-12-21 00:56:00 +01:00
|
|
|
callbacks.push( elem );
|
2010-12-20 19:09:15 +01:00
|
|
|
}
|
|
|
|
}
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-20 19:09:15 +01:00
|
|
|
if ( _fired ) {
|
|
|
|
deferred.fire( _fired[ 0 ] , _fired[ 1 ] );
|
|
|
|
}
|
|
|
|
}
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-20 19:09:15 +01:00
|
|
|
return this;
|
|
|
|
},
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-20 19:09:15 +01:00
|
|
|
// resolve with given context and args
|
2010-12-25 01:29:04 +01:00
|
|
|
fire: function( context , args ) {
|
2010-12-20 19:09:15 +01:00
|
|
|
if ( ! cancelled && ! fired && ! firing ) {
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-20 19:09:15 +01:00
|
|
|
firing = 1;
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-20 19:09:15 +01:00
|
|
|
try {
|
2010-12-25 01:29:04 +01:00
|
|
|
while( callbacks[ 0 ] ) {
|
|
|
|
callbacks.shift().apply( context , args );
|
2010-12-20 19:09:15 +01:00
|
|
|
}
|
2010-12-25 01:29:04 +01:00
|
|
|
}
|
|
|
|
finally {
|
2010-12-20 19:09:15 +01:00
|
|
|
fired = [ context , args ];
|
|
|
|
firing = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
},
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-20 19:09:15 +01:00
|
|
|
// resolve with this as context and given arguments
|
|
|
|
resolve: function() {
|
2010-12-30 17:06:53 +01:00
|
|
|
deferred.fire( jQuery.isFunction( this.promise ) ? this.promise() : this , arguments );
|
2010-12-20 19:09:15 +01:00
|
|
|
return this;
|
|
|
|
},
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-25 01:29:04 +01:00
|
|
|
// Has this deferred been resolved?
|
|
|
|
isResolved: function() {
|
|
|
|
return !!( firing || fired );
|
|
|
|
},
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-25 01:29:04 +01:00
|
|
|
// Cancel
|
2010-12-20 19:09:15 +01:00
|
|
|
cancel: function() {
|
2010-12-25 01:29:04 +01:00
|
|
|
cancelled = 1;
|
|
|
|
callbacks = [];
|
2010-12-20 19:09:15 +01:00
|
|
|
return this;
|
2010-12-25 01:29:04 +01:00
|
|
|
}
|
2010-12-20 19:09:15 +01:00
|
|
|
};
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-20 19:09:15 +01:00
|
|
|
return deferred;
|
|
|
|
},
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-20 19:09:15 +01:00
|
|
|
// Full fledged deferred (two callbacks list)
|
|
|
|
// Typical success/error system
|
2010-12-25 01:29:04 +01:00
|
|
|
Deferred: function( func ) {
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-30 17:06:53 +01:00
|
|
|
var deferred = jQuery._Deferred(),
|
|
|
|
failDeferred = jQuery._Deferred();
|
2011-01-05 22:41:23 +01:00
|
|
|
|
|
|
|
// Add errorDeferred methods and redefine cancel
|
2010-12-20 19:09:15 +01:00
|
|
|
jQuery.extend( deferred , {
|
|
|
|
|
2011-01-06 01:26:06 +01:00
|
|
|
then: function( doneCallbacks , failCallbacks ) {
|
|
|
|
deferred.done( doneCallbacks ).fail( failCallbacks );
|
2011-01-06 01:18:03 +01:00
|
|
|
return this;
|
|
|
|
},
|
2011-01-06 01:26:06 +01:00
|
|
|
fail: failDeferred.done,
|
2011-01-05 04:29:30 +01:00
|
|
|
fireReject: failDeferred.fire,
|
|
|
|
reject: failDeferred.resolve,
|
|
|
|
isRejected: failDeferred.isResolved,
|
|
|
|
// Get a promise for this deferred
|
|
|
|
// If obj is provided, the promise aspect is added to the object
|
|
|
|
promise: function( obj ) {
|
|
|
|
obj = obj || {};
|
2011-01-06 01:26:06 +01:00
|
|
|
jQuery.each( "then done fail isResolved isRejected".split( " " ) , function( _ , method ) {
|
2011-01-05 04:29:30 +01:00
|
|
|
obj[ method ] = deferred[ method ];
|
|
|
|
});
|
|
|
|
obj.promise = function() {
|
2010-12-28 04:13:44 +01:00
|
|
|
return obj;
|
2011-01-05 04:29:30 +01:00
|
|
|
};
|
|
|
|
return obj;
|
|
|
|
}
|
2010-12-20 19:09:15 +01:00
|
|
|
|
|
|
|
} );
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-20 19:09:15 +01:00
|
|
|
// Make sure only one callback list will be used
|
2011-01-05 04:29:30 +01:00
|
|
|
deferred.then( failDeferred.cancel , deferred.cancel );
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-30 17:06:53 +01:00
|
|
|
// Unexpose cancel
|
|
|
|
delete deferred.cancel;
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-20 19:09:15 +01:00
|
|
|
// Call given func if any
|
|
|
|
if ( func ) {
|
|
|
|
func.call( deferred , deferred );
|
|
|
|
}
|
2011-01-05 22:41:23 +01:00
|
|
|
|
2010-12-20 19:09:15 +01:00
|
|
|
return deferred;
|
|
|
|
},
|
|
|
|
|
|
|
|
// Deferred helper
|
2010-12-25 12:52:53 +01:00
|
|
|
when: function( object ) {
|
2010-12-30 17:06:53 +01:00
|
|
|
object = object && jQuery.isFunction( object.promise ) ?
|
2010-12-20 19:09:15 +01:00
|
|
|
object :
|
2010-12-24 18:53:55 +01:00
|
|
|
jQuery.Deferred().resolve( object );
|
2010-12-28 04:13:44 +01:00
|
|
|
return object.promise();
|
2010-12-20 19:09:15 +01:00
|
|
|
},
|
2010-03-23 17:12:16 +01:00
|
|
|
|
2009-12-09 07:52:32 +01:00
|
|
|
// Use of jQuery.browser is frowned upon.
|
2009-12-10 00:07:16 +01:00
|
|
|
// More details: http://docs.jquery.com/Utilities/jQuery.browser
|
2010-01-05 23:01:20 +01:00
|
|
|
uaMatch: function( ua ) {
|
|
|
|
ua = ua.toLowerCase();
|
|
|
|
|
2010-09-22 15:16:28 +02:00
|
|
|
var match = rwebkit.exec( ua ) ||
|
|
|
|
ropera.exec( ua ) ||
|
|
|
|
rmsie.exec( ua ) ||
|
|
|
|
ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
|
2010-03-01 18:44:56 +01:00
|
|
|
[];
|
2010-01-05 23:01:20 +01:00
|
|
|
|
2010-01-23 18:13:46 +01:00
|
|
|
return { browser: match[1] || "", version: match[2] || "0" };
|
2010-01-05 23:01:20 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
browser: {}
|
2008-01-14 23:30:48 +01:00
|
|
|
});
|
|
|
|
|
2010-12-20 19:09:15 +01:00
|
|
|
// Create readyList deferred
|
2010-12-25 01:29:04 +01:00
|
|
|
readyList = jQuery._Deferred();
|
2010-12-20 19:09:15 +01:00
|
|
|
|
2010-08-28 01:14:59 +02: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 23:01:20 +01: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 07:52:32 +01:00
|
|
|
|
2009-09-08 03:45:11 +02:00
|
|
|
if ( indexOf ) {
|
|
|
|
jQuery.inArray = function( elem, array ) {
|
|
|
|
return indexOf.call( array, elem );
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2010-03-09 15:14:27 +01:00
|
|
|
// Verify that \s matches non-breaking spaces
|
|
|
|
// (IE fails on this test)
|
2010-09-22 15:16:28 +02:00
|
|
|
if ( !rwhite.test( "\xA0" ) ) {
|
2010-03-09 15:14:27 +01:00
|
|
|
trimLeft = /^[\s\xA0]+/;
|
|
|
|
trimRight = /[\s\xA0]+$/;
|
|
|
|
}
|
|
|
|
|
2009-02-25 15:23:25 +01:00
|
|
|
// All jQuery objects should point back to these
|
2009-03-31 19:35:20 +02:00
|
|
|
rootjQuery = jQuery(document);
|
|
|
|
|
2009-12-16 22:45:00 +01: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 03:24:49 +01:00
|
|
|
} catch(e) {
|
2009-12-16 22:45:00 +01:00
|
|
|
setTimeout( doScrollCheck, 1 );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// and execute any waiting functions
|
|
|
|
jQuery.ready();
|
|
|
|
}
|
|
|
|
|
2010-03-23 17:12:16 +01:00
|
|
|
// Expose jQuery to the global object
|
2010-09-14 15:57:26 +02:00
|
|
|
return (window.jQuery = window.$ = jQuery);
|
2009-09-09 23:14:28 +02:00
|
|
|
|
2010-03-23 17:12:16 +01:00
|
|
|
})();
|