0 | |
/*!
|
1 | |
* jQuery JavaScript Library v1.7.1
|
2 | |
* http://jquery.com/
|
3 | |
*
|
4 | |
* Copyright 2011, John Resig
|
5 | |
* Dual licensed under the MIT or GPL Version 2 licenses.
|
6 | |
* http://jquery.org/license
|
7 | |
*
|
8 | |
* Includes Sizzle.js
|
9 | |
* http://sizzlejs.com/
|
10 | |
* Copyright 2011, The Dojo Foundation
|
11 | |
* Released under the MIT, BSD, and GPL Licenses.
|
12 | |
*
|
13 | |
* Date: Mon Nov 21 22.0:03 2011 -0500
|
14 | |
*/
|
15 | |
(function( window, undefined ) {
|
16 | |
|
17 | |
// Use the correct document accordingly with window argument (sandbox)
|
18 | |
var document = window.document,
|
19 | |
navigator = window.navigator,
|
20 | |
location = window.location;
|
21 | |
var jQuery = (function() {
|
22 | |
|
23 | |
// Define a local copy of jQuery
|
24 | |
var jQuery = function( selector, context ) {
|
25 | |
// The jQuery object is actually just the init constructor 'enhanced'
|
26 | |
return new jQuery.fn.init( selector, context, rootjQuery );
|
27 | |
},
|
28 | |
|
29 | |
// Map over jQuery in case of overwrite
|
30 | |
_jQuery = window.jQuery,
|
31 | |
|
32 | |
// Map over the $ in case of overwrite
|
33 | |
_$ = window.$,
|
34 | |
|
35 | |
// A central reference to the root jQuery(document)
|
36 | |
rootjQuery,
|
37 | |
|
38 | |
// A simple way to check for HTML strings or ID strings
|
39 | |
// Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
|
40 | |
quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
|
41 | |
|
42 | |
// Check if a string has a non-whitespace character in it
|
43 | |
rnotwhite = /\S/,
|
44 | |
|
45 | |
// Used for trimming whitespace
|
46 | |
trimLeft = /^\s+/,
|
47 | |
trimRight = /\s+$/,
|
48 | |
|
49 | |
// Match a standalone tag
|
50 | |
rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
|
51 | |
|
52 | |
// JSON RegExp
|
53 | |
rvalidchars = /^[\],:{}\s]*$/,
|
54 | |
rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
|
55 | |
rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
|
56 | |
rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
|
57 | |
|
58 | |
// Useragent RegExp
|
59 | |
rwebkit = /(webkit)[ \/]([\w.]+)/,
|
60 | |
ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
|
61 | |
rmsie = /(msie) ([\w.]+)/,
|
62 | |
rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
|
63 | |
|
64 | |
// Matches dashed string for camelizing
|
65 | |
rdashAlpha = /-([a-z]|[0-9])/ig,
|
66 | |
rmsPrefix = /^-ms-/,
|
67 | |
|
68 | |
// Used by jQuery.camelCase as callback to replace()
|
69 | |
fcamelCase = function( all, letter ) {
|
70 | |
return ( letter + "" ).toUpperCase();
|
71 | |
},
|
72 | |
|
73 | |
// Keep a UserAgent string for use with jQuery.browser
|
74 | |
userAgent = navigator.userAgent,
|
75 | |
|
76 | |
// For matching the engine and version of the browser
|
77 | |
browserMatch,
|
78 | |
|
79 | |
// The deferred used on DOM ready
|
80 | |
readyList,
|
81 | |
|
82 | |
// The ready event handler
|
83 | |
DOMContentLoaded,
|
84 | |
|
85 | |
// Save a reference to some core methods
|
86 | |
toString = Object.prototype.toString,
|
87 | |
hasOwn = Object.prototype.hasOwnProperty,
|
88 | |
push = Array.prototype.push,
|
89 | |
slice = Array.prototype.slice,
|
90 | |
trim = String.prototype.trim,
|
91 | |
indexOf = Array.prototype.indexOf,
|
92 | |
|
93 | |
// [[Class]] -> type pairs
|
94 | |
class2type = {};
|
95 | |
|
96 | |
jQuery.fn = jQuery.prototype = {
|
97 | |
constructor: jQuery,
|
98 | |
init: function( selector, context, rootjQuery ) {
|
99 | |
var match, elem, ret, doc;
|
100 | |
|
101 | |
// Handle $(""), $(null), or $(undefined)
|
102 | |
if ( !selector ) {
|
103 | |
return this;
|
104 | |
}
|
105 | |
|
106 | |
// Handle $(DOMElement)
|
107 | |
if ( selector.nodeType ) {
|
108 | |
this.context = this[0] = selector;
|
109 | |
this.length = 1;
|
110 | |
return this;
|
111 | |
}
|
112 | |
|
113 | |
// The body element only exists once, optimize finding it
|
114 | |
if ( selector === "body" && !context && document.body ) {
|
115 | |
this.context = document;
|
116 | |
this[0] = document.body;
|
117 | |
this.selector = selector;
|
118 | |
this.length = 1;
|
119 | |
return this;
|
120 | |
}
|
121 | |
|
122 | |
// Handle HTML strings
|
123 | |
if ( typeof selector === "string" ) {
|
124 | |
// Are we dealing with HTML string or an ID?
|
125 | |
if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
|
126 | |
// Assume that strings that start and end with <> are HTML and skip the regex check
|
127 | |
match = [ null, selector, null ];
|
128 | |
|
129 | |
} else {
|
130 | |
match = quickExpr.exec( selector );
|
131 | |
}
|
132 | |
|
133 | |
// Verify a match, and that no context was specified for #id
|
134 | |
if ( match && (match[1] || !context) ) {
|
135 | |
|
136 | |
// HANDLE: $(html) -> $(array)
|
137 | |
if ( match[1] ) {
|
138 | |
context = context instanceof jQuery ? context[0] : context;
|
139 | |
doc = ( context ? context.ownerDocument || context : document );
|
140 | |
|
141 | |
// If a single string is passed in and it's a single tag
|
142 | |
// just do a createElement and skip the rest
|
143 | |
ret = rsingleTag.exec( selector );
|
144 | |
|
145 | |
if ( ret ) {
|
146 | |
if ( jQuery.isPlainObject( context ) ) {
|
147 | |
selector = [ document.createElement( ret[1] ) ];
|
148 | |
jQuery.fn.attr.call( selector, context, true );
|
149 | |
|
150 | |
} else {
|
151 | |
selector = [ doc.createElement( ret[1] ) ];
|
152 | |
}
|
153 | |
|
154 | |
} else {
|
155 | |
ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
|
156 | |
selector = ( ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment ).childNodes;
|
157 | |
}
|
158 | |
|
159 | |
return jQuery.merge( this, selector );
|
160 | |
|
161 | |
// HANDLE: $("#id")
|
162 | |
} else {
|
163 | |
elem = document.getElementById( match[2] );
|
164 | |
|
165 | |
// Check parentNode to catch when Blackberry 4.6 returns
|
166 | |
// nodes that are no longer in the document #6963
|
167 | |
if ( elem && elem.parentNode ) {
|
168 | |
// Handle the case where IE and Opera return items
|
169 | |
// by name instead of ID
|
170 | |
if ( elem.id !== match[2] ) {
|
171 | |
return rootjQuery.find( selector );
|
172 | |
}
|
173 | |
|
174 | |
// Otherwise, we inject the element directly into the jQuery object
|
175 | |
this.length = 1;
|
176 | |
this[0] = elem;
|
177 | |
}
|
178 | |
|
179 | |
this.context = document;
|
180 | |
this.selector = selector;
|
181 | |
return this;
|
182 | |
}
|
183 | |
|
184 | |
// HANDLE: $(expr, $(...))
|
185 | |
} else if ( !context || context.jquery ) {
|
186 | |
return ( context || rootjQuery ).find( selector );
|
187 | |
|
188 | |
// HANDLE: $(expr, context)
|
189 | |
// (which is just equivalent to: $(context).find(expr)
|
190 | |
} else {
|
191 | |
return this.constructor( context ).find( selector );
|
192 | |
}
|
193 | |
|
194 | |
// HANDLE: $(function)
|
195 | |
// Shortcut for document ready
|
196 | |
} else if ( jQuery.isFunction( selector ) ) {
|
197 | |
return rootjQuery.ready( selector );
|
198 | |
}
|
199 | |
|
200 | |
if ( selector.selector !== undefined ) {
|
201 | |
this.selector = selector.selector;
|
202 | |
this.context = selector.context;
|
203 | |
}
|
204 | |
|
205 | |
return jQuery.makeArray( selector, this );
|
206 | |
},
|
207 | |
|
208 | |
// Start with an empty selector
|
209 | |
selector: "",
|
210 | |
|
211 | |
// The current version of jQuery being used
|
212 | |
jquery: "1.7.1",
|
213 | |
|
214 | |
// The default length of a jQuery object is 0
|
215 | |
length: 0,
|
216 | |
|
217 | |
// The number of elements contained in the matched element set
|
218 | |
size: function() {
|
219 | |
return this.length;
|
220 | |
},
|
221 | |
|
222 | |
toArray: function() {
|
223 | |
return slice.call( this, 0 );
|
224 | |
},
|
225 | |
|
226 | |
// Get the Nth element in the matched element set OR
|
227 | |
// Get the whole matched element set as a clean array
|
228 | |
get: function( num ) {
|
229 | |
return num == null ?
|
230 | |
|
231 | |
// Return a 'clean' array
|
232 | |
this.toArray() :
|
233 | |
|
234 | |
// Return just the object
|
235 | |
( num < 0 ? this[ this.length + num ] : this[ num ] );
|
236 | |
},
|
237 | |
|
238 | |
// Take an array of elements and push it onto the stack
|
239 | |
// (returning the new matched element set)
|
240 | |
pushStack: function( elems, name, selector ) {
|
241 | |
// Build a new jQuery matched element set
|
242 | |
var ret = this.constructor();
|
243 | |
|
244 | |
if ( jQuery.isArray( elems ) ) {
|
245 | |
push.apply( ret, elems );
|
246 | |
|
247 | |
} else {
|
248 | |
jQuery.merge( ret, elems );
|
249 | |
}
|
250 | |
|
251 | |
// Add the old object onto the stack (as a reference)
|
252 | |
ret.prevObject = this;
|
253 | |
|
254 | |
ret.context = this.context;
|
255 | |
|
256 | |
if ( name === "find" ) {
|
257 | |
ret.selector = this.selector + ( this.selector ? " " : "" ) + selector;
|
258 | |
} else if ( name ) {
|
259 | |
ret.selector = this.selector + "." + name + "(" + selector + ")";
|
260 | |
}
|
261 | |
|
262 | |
// Return the newly-formed element set
|
263 | |
return ret;
|
264 | |
},
|
265 | |
|
266 | |
// Execute a callback for every element in the matched set.
|
267 | |
// (You can seed the arguments with an array of args, but this is
|
268 | |
// only used internally.)
|
269 | |
each: function( callback, args ) {
|
270 | |
return jQuery.each( this, callback, args );
|
271 | |
},
|
272 | |
|
273 | |
ready: function( fn ) {
|
274 | |
// Attach the listeners
|
275 | |
jQuery.bindReady();
|
276 | |
|
277 | |
// Add the callback
|
278 | |
readyList.add( fn );
|
279 | |
|
280 | |
return this;
|
281 | |
},
|
282 | |
|
283 | |
eq: function( i ) {
|
284 | |
i = +i;
|
285 | |
return i === -1 ?
|
286 | |
this.slice( i ) :
|
287 | |
this.slice( i, i + 1 );
|
288 | |
},
|
289 | |
|
290 | |
first: function() {
|
291 | |
return this.eq( 0 );
|
292 | |
},
|
293 | |
|
294 | |
last: function() {
|
295 | |
return this.eq( -1 );
|
296 | |
},
|
297 | |
|
298 | |
slice: function() {
|
299 | |
return this.pushStack( slice.apply( this, arguments ),
|
300 | |
"slice", slice.call(arguments).join(",") );
|
301 | |
},
|
302 | |
|
303 | |
map: function( callback ) {
|
304 | |
return this.pushStack( jQuery.map(this, function( elem, i ) {
|
305 | |
return callback.call( elem, i, elem );
|
306 | |
}));
|
307 | |
},
|
308 | |
|
309 | |
end: function() {
|
310 | |
return this.prevObject || this.constructor(null);
|
311 | |
},
|
312 | |
|
313 | |
// For internal use only.
|
314 | |
// Behaves like an Array's method, not like a jQuery method.
|
315 | |
push: push,
|
316 | |
sort: [].sort,
|
317 | |
splice: [].splice
|
318 | |
};
|
319 | |
|
320 | |
// Give the init function the jQuery prototype for later instantiation
|
321 | |
jQuery.fn.init.prototype = jQuery.fn;
|
322 | |
|
323 | |
jQuery.extend = jQuery.fn.extend = function() {
|
324 | |
var options, name, src, copy, copyIsArray, clone,
|
325 | |
target = arguments[0] || {},
|
326 | |
i = 1,
|
327 | |
length = arguments.length,
|
328 | |
deep = false;
|
329 | |
|
330 | |
// Handle a deep copy situation
|
331 | |
if ( typeof target === "boolean" ) {
|
332 | |
deep = target;
|
333 | |
target = arguments[1] || {};
|
334 | |
// skip the boolean and the target
|
335 | |
i = 2;
|
336 | |
}
|
337 | |
|
338 | |
// Handle case when target is a string or something (possible in deep copy)
|
339 | |
if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
|
340 | |
target = {};
|
341 | |
}
|
342 | |
|
343 | |
// extend jQuery itself if only one argument is passed
|
344 | |
if ( length === i ) {
|
345 | |
target = this;
|
346 | |
--i;
|
347 | |
}
|
348 | |
|
349 | |
for ( ; i < length; i++ ) {
|
350 | |
// Only deal with non-null/undefined values
|
351 | |
if ( (options = arguments[ i ]) != null ) {
|
352 | |
// Extend the base object
|
353 | |
for ( name in options ) {
|
354 | |
src = target[ name ];
|
355 | |
copy = options[ name ];
|
356 | |
|
357 | |
// Prevent never-ending loop
|
358 | |
if ( target === copy ) {
|
359 | |
continue;
|
360 | |
}
|
361 | |
|
362 | |
// Recurse if we're merging plain objects or arrays
|
363 | |
if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
|
364 | |
if ( copyIsArray ) {
|
365 | |
copyIsArray = false;
|
366 | |
clone = src && jQuery.isArray(src) ? src : [];
|
367 | |
|
368 | |
} else {
|
369 | |
clone = src && jQuery.isPlainObject(src) ? src : {};
|
370 | |
}
|
371 | |
|
372 | |
// Never move original objects, clone them
|
373 | |
target[ name ] = jQuery.extend( deep, clone, copy );
|
374 | |
|
375 | |
// Don't bring in undefined values
|
376 | |
} else if ( copy !== undefined ) {
|
377 | |
target[ name ] = copy;
|
378 | |
}
|
379 | |
}
|
380 | |
}
|
381 | |
}
|
382 | |
|
383 | |
// Return the modified object
|
384 | |
return target;
|
385 | |
};
|
386 | |
|
387 | |
jQuery.extend({
|
388 | |
noConflict: function( deep ) {
|
389 | |
if ( window.$ === jQuery ) {
|
390 | |
window.$ = _$;
|
391 | |
}
|
392 | |
|
393 | |
if ( deep && window.jQuery === jQuery ) {
|
394 | |
window.jQuery = _jQuery;
|
395 | |
}
|
396 | |
|
397 | |
return jQuery;
|
398 | |
},
|
399 | |
|
400 | |
// Is the DOM ready to be used? Set to true once it occurs.
|
401 | |
isReady: false,
|
402 | |
|
403 | |
// A counter to track how many items to wait for before
|
404 | |
// the ready event fires. See #6781
|
405 | |
readyWait: 1,
|
406 | |
|
407 | |
// Hold (or release) the ready event
|
408 | |
holdReady: function( hold ) {
|
409 | |
if ( hold ) {
|
410 | |
jQuery.readyWait++;
|
411 | |
} else {
|
412 | |
jQuery.ready( true );
|
413 | |
}
|
414 | |
},
|
415 | |
|
416 | |
// Handle when the DOM is ready
|
417 | |
ready: function( wait ) {
|
418 | |
// Either a released hold or an DOMready/load event and not yet ready
|
419 | |
if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) {
|
420 | |
// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
|
421 | |
if ( !document.body ) {
|
422 | |
return setTimeout( jQuery.ready, 1 );
|
423 | |
}
|
424 | |
|
425 | |
// Remember that the DOM is ready
|
426 | |
jQuery.isReady = true;
|
427 | |
|
428 | |
// If a normal DOM Ready event fired, decrement, and wait if need be
|
429 | |
if ( wait !== true && --jQuery.readyWait > 0 ) {
|
430 | |
return;
|
431 | |
}
|
432 | |
|
433 | |
// If there are functions bound, to execute
|
434 | |
readyList.fireWith( document, [ jQuery ] );
|
435 | |
|
436 | |
// Trigger any bound ready events
|
437 | |
if ( jQuery.fn.trigger ) {
|
438 | |
jQuery( document ).trigger( "ready" ).off( "ready" );
|
439 | |
}
|
440 | |
}
|
441 | |
},
|
442 | |
|
443 | |
bindReady: function() {
|
444 | |
if ( readyList ) {
|
445 | |
return;
|
446 | |
}
|
447 | |
|
448 | |
readyList = jQuery.Callbacks( "once memory" );
|
449 | |
|
450 | |
// Catch cases where $(document).ready() is called after the
|
451 | |
// browser event has already occurred.
|
452 | |
if ( document.readyState === "complete" ) {
|
453 | |
// Handle it asynchronously to allow scripts the opportunity to delay ready
|
454 | |
return setTimeout( jQuery.ready, 1 );
|
455 | |
}
|
456 | |
|
457 | |
// Mozilla, Opera and webkit nightlies currently support this event
|
458 | |
if ( document.addEventListener ) {
|
459 | |
// Use the handy event callback
|
460 | |
document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
|
461 | |
|
462 | |
// A fallback to window.onload, that will always work
|
463 | |
window.addEventListener( "load", jQuery.ready, false );
|
464 | |
|
465 | |
// If IE event model is used
|
466 | |
} else if ( document.attachEvent ) {
|
467 | |
// ensure firing before onload,
|
468 | |
// maybe late but safe also for iframes
|
469 | |
document.attachEvent( "onreadystatechange", DOMContentLoaded );
|
470 | |
|
471 | |
// A fallback to window.onload, that will always work
|
472 | |
window.attachEvent( "onload", jQuery.ready );
|
473 | |
|
474 | |
// If IE and not a frame
|
475 | |
// continually check to see if the document is ready
|
476 | |
var toplevel = false;
|
477 | |
|
478 | |
try {
|
479 | |
toplevel = window.frameElement == null;
|
480 | |
} catch(e) {}
|
481 | |
|
482 | |
if ( document.documentElement.doScroll && toplevel ) {
|
483 | |
doScrollCheck();
|
484 | |
}
|
485 | |
}
|
486 | |
},
|
487 | |
|
488 | |
// See test/unit/core.js for details concerning isFunction.
|
489 | |
// Since version 1.3, DOM methods and functions like alert
|
490 | |
// aren't supported. They return false on IE (#2968).
|
491 | |
isFunction: function( obj ) {
|
492 | |
return jQuery.type(obj) === "function";
|
493 | |
},
|
494 | |
|
495 | |
isArray: Array.isArray || function( obj ) {
|
496 | |
return jQuery.type(obj) === "array";
|
497 | |
},
|
498 | |
|
499 | |
// A crude way of determining if an object is a window
|
500 | |
isWindow: function( obj ) {
|
501 | |
return obj && typeof obj === "object" && "setInterval" in obj;
|
502 | |
},
|
503 | |
|
504 | |
isNumeric: function( obj ) {
|
505 | |
return !isNaN( parseFloat(obj) ) && isFinite( obj );
|
506 | |
},
|
507 | |
|
508 | |
type: function( obj ) {
|
509 | |
return obj == null ?
|
510 | |
String( obj ) :
|
511 | |
class2type[ toString.call(obj) ] || "object";
|
512 | |
},
|
513 | |
|
514 | |
isPlainObject: function( obj ) {
|
515 | |
// Must be an Object.
|
516 | |
// Because of IE, we also have to check the presence of the constructor property.
|
517 | |
// Make sure that DOM nodes and window objects don't pass through, as well
|
518 | |
if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
|
519 | |
return false;
|
520 | |
}
|
521 | |
|
522 | |
try {
|
523 | |
// Not own constructor property must be Object
|
524 | |
if ( obj.constructor &&
|
525 | |
!hasOwn.call(obj, "constructor") &&
|
526 | |
!hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
|
527 | |
return false;
|
528 | |
}
|
529 | |
} catch ( e ) {
|
530 | |
// IE8,9 Will throw exceptions on certain host objects #9897
|
531 | |
return false;
|
532 | |
}
|
533 | |
|
534 | |
// Own properties are enumerated firstly, so to speed up,
|
535 | |
// if last one is own, then all properties are own.
|
536 | |
|
537 | |
var key;
|
538 | |
for ( key in obj ) {}
|
539 | |
|
540 | |
return key === undefined || hasOwn.call( obj, key );
|
541 | |
},
|
542 | |
|
543 | |
isEmptyObject: function( obj ) {
|
544 | |
for ( var name in obj ) {
|
545 | |
return false;
|
546 | |
}
|
547 | |
return true;
|
548 | |
},
|
549 | |
|
550 | |
error: function( msg ) {
|
551 | |
throw new Error( msg );
|
552 | |
},
|
553 | |
|
554 | |
parseJSON: function( data ) {
|
555 | |
if ( typeof data !== "string" || !data ) {
|
556 | |
return null;
|
557 | |
}
|
558 | |
|
559 | |
// Make sure leading/trailing whitespace is removed (IE can't handle it)
|
560 | |
data = jQuery.trim( data );
|
561 | |
|
562 | |
// Attempt to parse using the native JSON parser first
|
563 | |
if ( window.JSON && window.JSON.parse ) {
|
564 | |
return window.JSON.parse( data );
|
565 | |
}
|
566 | |
|
567 | |
// Make sure the incoming data is actual JSON
|
568 | |
// Logic borrowed from http://json.org/json2.js
|
569 | |
if ( rvalidchars.test( data.replace( rvalidescape, "@" )
|
570 | |
.replace( rvalidtokens, "]" )
|
571 | |
.replace( rvalidbraces, "")) ) {
|
572 | |
|
573 | |
return ( new Function( "return " + data ) )();
|
574 | |
|
575 | |
}
|
576 | |
jQuery.error( "Invalid JSON: " + data );
|
577 | |
},
|
578 | |
|
579 | |
// Cross-browser xml parsing
|
580 | |
parseXML: function( data ) {
|
581 | |
var xml, tmp;
|
582 | |
try {
|
583 | |
if ( window.DOMParser ) { // Standard
|
584 | |
tmp = new DOMParser();
|
585 | |
xml = tmp.parseFromString( data , "text/xml" );
|
586 | |
} else { // IE
|
587 | |
xml = new ActiveXObject( "Microsoft.XMLDOM" );
|
588 | |
xml.async = "false";
|
589 | |
xml.loadXML( data );
|
590 | |
}
|
591 | |
} catch( e ) {
|
592 | |
xml = undefined;
|
593 | |
}
|
594 | |
if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
|
595 | |
jQuery.error( "Invalid XML: " + data );
|
596 | |
}
|
597 | |
return xml;
|
598 | |
},
|
599 | |
|
600 | |
noop: function() {},
|
601 | |
|
602 | |
// Evaluates a script in a global context
|
603 | |
// Workarounds based on findings by Jim Driscoll
|
604 | |
// http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
|
605 | |
globalEval: function( data ) {
|
606 | |
if ( data && rnotwhite.test( data ) ) {
|
607 | |
// We use execScript on Internet Explorer
|
608 | |
// We use an anonymous function so that context is window
|
609 | |
// rather than jQuery in Firefox
|
610 | |
( window.execScript || function( data ) {
|
611 | |
window[ "eval" ].call( window, data );
|
612 | |
} )( data );
|
613 | |
}
|
614 | |
},
|
615 | |
|
616 | |
// Convert dashed to camelCase; used by the css and data modules
|
617 | |
// Microsoft forgot to hump their vendor prefix (#9572)
|
618 | |
camelCase: function( string ) {
|
619 | |
return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
|
620 | |
},
|
621 | |
|
622 | |
nodeName: function( elem, name ) {
|
623 | |
return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
|
624 | |
},
|
625 | |
|
626 | |
// args is for internal usage only
|
627 | |
each: function( object, callback, args ) {
|
628 | |
var name, i = 0,
|
629 | |
length = object.length,
|
630 | |
isObj = length === undefined || jQuery.isFunction( object );
|
631 | |
|
632 | |
if ( args ) {
|
633 | |
if ( isObj ) {
|
634 | |
for ( name in object ) {
|
635 | |
if ( callback.apply( object[ name ], args ) === false ) {
|
636 | |
break;
|
637 | |
}
|
638 | |
}
|
639 | |
} else {
|
640 | |
for ( ; i < length; ) {
|
641 | |
if ( callback.apply( object[ i++ ], args ) === false ) {
|
642 | |
break;
|
643 | |
}
|
644 | |
}
|
645 | |
}
|
646 | |
|
647 | |
// A special, fast, case for the most common use of each
|
648 | |
} else {
|
649 | |
if ( isObj ) {
|
650 | |
for ( name in object ) {
|
651 | |
if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
|
652 | |
break;
|
653 | |
}
|
654 | |
}
|
655 | |
} else {
|
656 | |
for ( ; i < length; ) {
|
657 | |
if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) {
|
658 | |
break;
|
659 | |
}
|
660 | |
}
|
661 | |
}
|
662 | |
}
|
663 | |
|
664 | |
return object;
|
665 | |
},
|
666 | |
|
667 | |
// Use native String.trim function wherever possible
|
668 | |
trim: trim ?
|
669 | |
function( text ) {
|
670 | |
return text == null ?
|
671 | |
"" :
|
672 | |
trim.call( text );
|
673 | |
} :
|
674 | |
|
675 | |
// Otherwise use our own trimming functionality
|
676 | |
function( text ) {
|
677 | |
return text == null ?
|
678 | |
"" :
|
679 | |
text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
|
680 | |
},
|
681 | |
|
682 | |
// results is for internal usage only
|
683 | |
makeArray: function( array, results ) {
|
684 | |
var ret = results || [];
|
685 | |
|
686 | |
if ( array != null ) {
|
687 | |
// The window, strings (and functions) also have 'length'
|
688 | |
// Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
|
689 | |
var type = jQuery.type( array );
|
690 | |
|
691 | |
if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
|
692 | |
push.call( ret, array );
|
693 | |
} else {
|
694 | |
jQuery.merge( ret, array );
|
695 | |
}
|
696 | |
}
|
697 | |
|
698 | |
return ret;
|
699 | |
},
|
700 | |
|
701 | |
inArray: function( elem, array, i ) {
|
702 | |
var len;
|
703 | |
|
704 | |
if ( array ) {
|
705 | |
if ( indexOf ) {
|
706 | |
return indexOf.call( array, elem, i );
|
707 | |
}
|
708 | |
|
709 | |
len = array.length;
|
710 | |
i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
|
711 | |
|
712 | |
for ( ; i < len; i++ ) {
|
713 | |
// Skip accessing in sparse arrays
|
714 | |
if ( i in array && array[ i ] === elem ) {
|
715 | |
return i;
|
716 | |
}
|
717 | |
}
|
718 | |
}
|
719 | |
|
720 | |
return -1;
|
721 | |
},
|
722 | |
|
723 | |
merge: function( first, second ) {
|
724 | |
var i = first.length,
|
725 | |
j = 0;
|
726 | |
|
727 | |
if ( typeof second.length === "number" ) {
|
728 | |
for ( var l = second.length; j < l; j++ ) {
|
729 | |
first[ i++ ] = second[ j ];
|
730 | |
}
|
731 | |
|
732 | |
} else {
|
733 | |
while ( second[j] !== undefined ) {
|
734 | |
first[ i++ ] = second[ j++ ];
|
735 | |
}
|
736 | |
}
|
737 | |
|
738 | |
first.length = i;
|
739 | |
|
740 | |
return first;
|
741 | |
},
|
742 | |
|
743 | |
grep: function( elems, callback, inv ) {
|
744 | |
var ret = [], retVal;
|
745 | |
inv = !!inv;
|
746 | |
|
747 | |
// Go through the array, only saving the items
|
748 | |
// that pass the validator function
|
749 | |
for ( var i = 0, length = elems.length; i < length; i++ ) {
|
750 | |
retVal = !!callback( elems[ i ], i );
|
751 | |
if ( inv !== retVal ) {
|
752 | |
ret.push( elems[ i ] );
|
753 | |
}
|
754 | |
}
|
755 | |
|
756 | |
return ret;
|
757 | |
},
|
758 | |
|
759 | |
// arg is for internal usage only
|
760 | |
map: function( elems, callback, arg ) {
|
761 | |
var value, key, ret = [],
|
762 | |
i = 0,
|
763 | |
length = elems.length,
|
764 | |
// jquery objects are treated as arrays
|
765 | |
isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
|
766 | |
|
767 | |
// Go through the array, translating each of the items to their
|
768 | |
if ( isArray ) {
|
769 | |
for ( ; i < length; i++ ) {
|
770 | |
value = callback( elems[ i ], i, arg );
|
771 | |
|
772 | |
if ( value != null ) {
|
773 | |
ret[ ret.length ] = value;
|
774 | |
}
|
775 | |
}
|
776 | |
|
777 | |
// Go through every key on the object,
|
778 | |
} else {
|
779 | |
for ( key in elems ) {
|
780 | |
value = callback( elems[ key ], key, arg );
|
781 | |
|
782 | |
if ( value != null ) {
|
783 | |
ret[ ret.length ] = value;
|
784 | |
}
|
785 | |
}
|
786 | |
}
|
787 | |
|
788 | |
// Flatten any nested arrays
|
789 | |
return ret.concat.apply( [], ret );
|
790 | |
},
|
791 | |
|
792 | |
// A global GUID counter for objects
|
793 | |
guid: 1,
|
794 | |
|
795 | |
// Bind a function to a context, optionally partially applying any
|
796 | |
// arguments.
|
797 | |
proxy: function( fn, context ) {
|
798 | |
if ( typeof context === "string" ) {
|
799 | |
var tmp = fn[ context ];
|
800 | |
context = fn;
|
801 | |
fn = tmp;
|
802 | |
}
|
803 | |
|
804 | |
// Quick check to determine if target is callable, in the spec
|
805 | |
// this throws a TypeError, but we will just return undefined.
|
806 | |
if ( !jQuery.isFunction( fn ) ) {
|
807 | |
return undefined;
|
808 | |
}
|
809 | |
|
810 | |
// Simulated bind
|
811 | |
var args = slice.call( arguments, 2 ),
|
812 | |
proxy = function() {
|
813 | |
return fn.apply( context, args.concat( slice.call( arguments ) ) );
|
814 | |
};
|
815 | |
|
816 | |
// Set the guid of unique handler to the same of original handler, so it can be removed
|
817 | |
proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
|
818 | |
|
819 | |
return proxy;
|
820 | |
},
|
821 | |
|
822 | |
// Mutifunctional method to get and set values to a collection
|
823 | |
// The value/s can optionally be executed if it's a function
|
824 | |
access: function( elems, key, value, exec, fn, pass ) {
|
825 | |
var length = elems.length;
|
826 | |
|
827 | |
// Setting many attributes
|
828 | |
if ( typeof key === "object" ) {
|
829 | |
for ( var k in key ) {
|
830 | |
jQuery.access( elems, k, key[k], exec, fn, value );
|
831 | |
}
|
832 | |
return elems;
|
833 | |
}
|
834 | |
|
835 | |
// Setting one attribute
|
836 | |
if ( value !== undefined ) {
|
837 | |
// Optionally, function values get executed if exec is true
|
838 | |
exec = !pass && exec && jQuery.isFunction(value);
|
839 | |
|
840 | |
for ( var i = 0; i < length; i++ ) {
|
841 | |
fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
|
842 | |
}
|
843 | |
|
844 | |
return elems;
|
845 | |
}
|
846 | |
|
847 | |
// Getting an attribute
|
848 | |
return length ? fn( elems[0], key ) : undefined;
|
849 | |
},
|
850 | |
|
851 | |
now: function() {
|
852 | |
return ( new Date() ).getTime();
|
853 | |
},
|
854 | |
|
855 | |
// Use of jQuery.browser is frowned upon.
|
856 | |
// More details: http://docs.jquery.com/Utilities/jQuery.browser
|
857 | |
uaMatch: function( ua ) {
|
858 | |
ua = ua.toLowerCase();
|
859 | |
|
860 | |
var match = rwebkit.exec( ua ) ||
|
861 | |
ropera.exec( ua ) ||
|
862 | |
rmsie.exec( ua ) ||
|
863 | |
ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
|
864 | |
[];
|
865 | |
|
866 | |
return { browser: match[1] || "", version: match[2] || "0" };
|
867 | |
},
|
868 | |
|
869 | |
sub: function() {
|
870 | |
function jQuerySub( selector, context ) {
|
871 | |
return new jQuerySub.fn.init( selector, context );
|
872 | |
}
|
873 | |
jQuery.extend( true, jQuerySub, this );
|
874 | |
jQuerySub.superclass = this;
|
875 | |
jQuerySub.fn = jQuerySub.prototype = this();
|
876 | |
jQuerySub.fn.constructor = jQuerySub;
|
877 | |
jQuerySub.sub = this.sub;
|
878 | |
jQuerySub.fn.init = function init( selector, context ) {
|
879 | |
if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
|
880 | |
context = jQuerySub( context );
|
881 | |
}
|
882 | |
|
883 | |
return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
|
884 | |
};
|
885 | |
jQuerySub.fn.init.prototype = jQuerySub.fn;
|
886 | |
var rootjQuerySub = jQuerySub(document);
|
887 | |
return jQuerySub;
|
888 | |
},
|
889 | |
|
890 | |
browser: {}
|
891 | |
});
|
892 | |
|
893 | |
// Populate the class2type map
|
894 | |
jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
|
895 | |
class2type[ "[object " + name + "]" ] = name.toLowerCase();
|
896 | |
});
|
897 | |
|
898 | |
browserMatch = jQuery.uaMatch( userAgent );
|
899 | |
if ( browserMatch.browser ) {
|
900 | |
jQuery.browser[ browserMatch.browser ] = true;
|
901 | |
jQuery.browser.version = browserMatch.version;
|
902 | |
}
|
903 | |
|
904 | |
// Deprecated, use jQuery.browser.webkit instead
|
905 | |
if ( jQuery.browser.webkit ) {
|
906 | |
jQuery.browser.safari = true;
|
907 | |
}
|
908 | |
|
909 | |
// IE doesn't match non-breaking spaces with \s
|
910 | |
if ( rnotwhite.test( "\xA0" ) ) {
|
911 | |
trimLeft = /^[\s\xA0]+/;
|
912 | |
trimRight = /[\s\xA0]+$/;
|
913 | |
}
|
914 | |
|
915 | |
// All jQuery objects should point back to these
|
916 | |
rootjQuery = jQuery(document);
|
917 | |
|
918 | |
// Cleanup functions for the document ready method
|
919 | |
if ( document.addEventListener ) {
|
920 | |
DOMContentLoaded = function() {
|
921 | |
document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
|
922 | |
jQuery.ready();
|
923 | |
};
|
924 | |
|
925 | |
} else if ( document.attachEvent ) {
|
926 | |
DOMContentLoaded = function() {
|
927 | |
// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
|
928 | |
if ( document.readyState === "complete" ) {
|
929 | |
document.detachEvent( "onreadystatechange", DOMContentLoaded );
|
930 | |
jQuery.ready();
|
931 | |
}
|
932 | |
};
|
933 | |
}
|
934 | |
|
935 | |
// The DOM ready check for Internet Explorer
|
936 | |
function doScrollCheck() {
|
937 | |
if ( jQuery.isReady ) {
|
938 | |
return;
|
939 | |
}
|
940 | |
|
941 | |
try {
|
942 | |
// If IE is used, use the trick by Diego Perini
|
943 | |
// http://javascript.nwbox.com/IEContentLoaded/
|
944 | |
document.documentElement.doScroll("left");
|
945 | |
} catch(e) {
|
946 | |
setTimeout( doScrollCheck, 1 );
|
947 | |
return;
|
948 | |
}
|
949 | |
|
950 | |
// and execute any waiting functions
|
951 | |
jQuery.ready();
|
952 | |
}
|
953 | |
|
954 | |
return jQuery;
|
955 | |
|
956 | |
})();
|
957 | |
|
958 | |
|
959 | |
// String to Object flags format cache
|
960 | |
var flagsCache = {};
|
961 | |
|
962 | |
// Convert String-formatted flags into Object-formatted ones and store in cache
|
963 | |
function createFlags( flags ) {
|
964 | |
var object = flagsCache[ flags ] = {},
|
965 | |
i, length;
|
966 | |
flags = flags.split( /\s+/ );
|
967 | |
for ( i = 0, length = flags.length; i < length; i++ ) {
|
968 | |
object[ flags[i] ] = true;
|
969 | |
}
|
970 | |
return object;
|
971 | |
}
|
972 | |
|
973 | |
/*
|
974 | |
* Create a callback list using the following parameters:
|
975 | |
*
|
976 | |
* flags: an optional list of space-separated flags that will change how
|
977 | |
* the callback list behaves
|
978 | |
*
|
979 | |
* By default a callback list will act like an event callback list and can be
|
980 | |
* "fired" multiple times.
|
981 | |
*
|
982 | |
* Possible flags:
|
983 | |
*
|
984 | |
* once: will ensure the callback list can only be fired once (like a Deferred)
|
985 | |
*
|
986 | |
* memory: will keep track of previous values and will call any callback added
|
987 | |
* after the list has been fired right away with the latest "memorized"
|
988 | |
* values (like a Deferred)
|
989 | |
*
|
990 | |
* unique: will ensure a callback can only be added once (no duplicate in the list)
|
991 | |
*
|
992 | |
* stopOnFalse: interrupt callings when a callback returns false
|
993 | |
*
|
994 | |
*/
|
995 | |
jQuery.Callbacks = function( flags ) {
|
996 | |
|
997 | |
// Convert flags from String-formatted to Object-formatted
|
998 | |
// (we check in cache first)
|
999 | |
flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {};
|
1000 | |
|
1001 | |
var // Actual callback list
|
1002 | |
list = [],
|
1003 | |
// Stack of fire calls for repeatable lists
|
1004 | |
stack = [],
|
1005 | |
// Last fire value (for non-forgettable lists)
|
1006 | |
memory,
|
1007 | |
// Flag to know if list is currently firing
|
1008 | |
firing,
|
1009 | |
// First callback to fire (used internally by add and fireWith)
|
1010 | |
firingStart,
|
1011 | |
// End of the loop when firing
|
1012 | |
firingLength,
|
1013 | |
// Index of currently firing callback (modified by remove if needed)
|
1014 | |
firingIndex,
|
1015 | |
// Add one or several callbacks to the list
|
1016 | |
add = function( args ) {
|
1017 | |
var i,
|
1018 | |
length,
|
1019 | |
elem,
|
1020 | |
type,
|
1021 | |
actual;
|
1022 | |
for ( i = 0, length = args.length; i < length; i++ ) {
|
1023 | |
elem = args[ i ];
|
1024 | |
type = jQuery.type( elem );
|
1025 | |
if ( type === "array" ) {
|
1026 | |
// Inspect recursively
|
1027 | |
add( elem );
|
1028 | |
} else if ( type === "function" ) {
|
1029 | |
// Add if not in unique mode and callback is not in
|
1030 | |
if ( !flags.unique || !self.has( elem ) ) {
|
1031 | |
list.push( elem );
|
1032 | |
}
|
1033 | |
}
|
1034 | |
}
|
1035 | |
},
|
1036 | |
// Fire callbacks
|
1037 | |
fire = function( context, args ) {
|
1038 | |
args = args || [];
|
1039 | |
memory = !flags.memory || [ context, args ];
|
1040 | |
firing = true;
|
1041 | |
firingIndex = firingStart || 0;
|
1042 | |
firingStart = 0;
|
1043 | |
firingLength = list.length;
|
1044 | |
for ( ; list && firingIndex < firingLength; firingIndex++ ) {
|
1045 | |
if ( list[ firingIndex ].apply( context, args ) === false && flags.stopOnFalse ) {
|
1046 | |
memory = true; // Mark as halted
|
1047 | |
break;
|
1048 | |
}
|
1049 | |
}
|
1050 | |
firing = false;
|
1051 | |
if ( list ) {
|
1052 | |
if ( !flags.once ) {
|
1053 | |
if ( stack && stack.length ) {
|
1054 | |
memory = stack.shift();
|
1055 | |
self.fireWith( memory[ 0 ], memory[ 1 ] );
|
1056 | |
}
|
1057 | |
} else if ( memory === true ) {
|
1058 | |
self.disable();
|
1059 | |
} else {
|
1060 | |
list = [];
|
1061 | |
}
|
1062 | |
}
|
1063 | |
},
|
1064 | |
// Actual Callbacks object
|
1065 | |
self = {
|
1066 | |
// Add a callback or a collection of callbacks to the list
|
1067 | |
add: function() {
|
1068 | |
if ( list ) {
|
1069 | |
var length = list.length;
|
1070 | |
add( arguments );
|
1071 | |
// Do we need to add the callbacks to the
|
1072 | |
// current firing batch?
|
1073 | |
if ( firing ) {
|
1074 | |
firingLength = list.length;
|
1075 | |
// With memory, if we're not firing then
|
1076 | |
// we should call right away, unless previous
|
1077 | |
// firing was halted (stopOnFalse)
|
1078 | |
} else if ( memory && memory !== true ) {
|
1079 | |
firingStart = length;
|
1080 | |
fire( memory[ 0 ], memory[ 1 ] );
|
1081 | |
}
|
1082 | |
}
|
1083 | |
return this;
|
1084 | |
},
|
1085 | |
// Remove a callback from the list
|
1086 | |
remove: function() {
|
1087 | |
if ( list ) {
|
1088 | |
var args = arguments,
|
1089 | |
argIndex = 0,
|
1090 | |
argLength = args.length;
|
1091 | |
for ( ; argIndex < argLength ; argIndex++ ) {
|
1092 | |
for ( var i = 0; i < list.length; i++ ) {
|
1093 | |
if ( args[ argIndex ] === list[ i ] ) {
|
1094 | |
// Handle firingIndex and firingLength
|
1095 | |
if ( firing ) {
|
1096 | |
if ( i <= firingLength ) {
|
1097 | |
firingLength--;
|
1098 | |
if ( i <= firingIndex ) {
|
1099 | |
firingIndex--;
|
1100 | |
}
|
1101 | |
}
|
1102 | |
}
|
1103 | |
// Remove the element
|
1104 | |
list.splice( i--, 1 );
|
1105 | |
// If we have some unicity property then
|
1106 | |
// we only need to do this once
|
1107 | |
if ( flags.unique ) {
|
1108 | |
break;
|
1109 | |
}
|
1110 | |
}
|
1111 | |
}
|
1112 | |
}
|
1113 | |
}
|
1114 | |
return this;
|
1115 | |
},
|
1116 | |
// Control if a given callback is in the list
|
1117 | |
has: function( fn ) {
|
1118 | |
if ( list ) {
|
1119 | |
var i = 0,
|
1120 | |
length = list.length;
|
1121 | |
for ( ; i < length; i++ ) {
|
1122 | |
if ( fn === list[ i ] ) {
|
1123 | |
return true;
|
1124 | |
}
|
1125 | |
}
|
1126 | |
}
|
1127 | |
return false;
|
1128 | |
},
|
1129 | |
// Remove all callbacks from the list
|
1130 | |
empty: function() {
|
1131 | |
list = [];
|
1132 | |
return this;
|
1133 | |
},
|
1134 | |
// Have the list do nothing anymore
|
1135 | |
disable: function() {
|
1136 | |
list = stack = memory = undefined;
|
1137 | |
return this;
|
1138 | |
},
|
1139 | |
// Is it disabled?
|
1140 | |
disabled: function() {
|
1141 | |
return !list;
|
1142 | |
},
|
1143 | |
// Lock the list in its current state
|
1144 | |
lock: function() {
|
1145 | |
stack = undefined;
|
1146 | |
if ( !memory || memory === true ) {
|
1147 | |
self.disable();
|
1148 | |
}
|
1149 | |
return this;
|
1150 | |
},
|
1151 | |
// Is it locked?
|
1152 | |
locked: function() {
|
1153 | |
return !stack;
|
1154 | |
},
|
1155 | |
// Call all callbacks with the given context and arguments
|
1156 | |
fireWith: function( context, args ) {
|
1157 | |
if ( stack ) {
|
1158 | |
if ( firing ) {
|
1159 | |
if ( !flags.once ) {
|
1160 | |
stack.push( [ context, args ] );
|
1161 | |
}
|
1162 | |
} else if ( !( flags.once && memory ) ) {
|
1163 | |
fire( context, args );
|
1164 | |
}
|
1165 | |
}
|
1166 | |
return this;
|
1167 | |
},
|
1168 | |
// Call all the callbacks with the given arguments
|
1169 | |
fire: function() {
|
1170 | |
self.fireWith( this, arguments );
|
1171 | |
return this;
|
1172 | |
},
|
1173 | |
// To know if the callbacks have already been called at least once
|
1174 | |
fired: function() {
|
1175 | |
return !!memory;
|
1176 | |
}
|
1177 | |
};
|
1178 | |
|
1179 | |
return self;
|
1180 | |
};
|
1181 | |
|
1182 | |
|
1183 | |
|
1184 | |
|
1185 | |
var // Static reference to slice
|
1186 | |
sliceDeferred = [].slice;
|
1187 | |
|
1188 | |
jQuery.extend({
|
1189 | |
|
1190 | |
Deferred: function( func ) {
|
1191 | |
var doneList = jQuery.Callbacks( "once memory" ),
|
1192 | |
failList = jQuery.Callbacks( "once memory" ),
|
1193 | |
progressList = jQuery.Callbacks( "memory" ),
|
1194 | |
state = "pending",
|
1195 | |
lists = {
|
1196 | |
resolve: doneList,
|
1197 | |
reject: failList,
|
1198 | |
notify: progressList
|
1199 | |
},
|
1200 | |
promise = {
|
1201 | |
done: doneList.add,
|
1202 | |
fail: failList.add,
|
1203 | |
progress: progressList.add,
|
1204 | |
|
1205 | |
state: function() {
|
1206 | |
return state;
|
1207 | |
},
|
1208 | |
|
1209 | |
// Deprecated
|
1210 | |
isResolved: doneList.fired,
|
1211 | |
isRejected: failList.fired,
|
1212 | |
|
1213 | |
then: function( doneCallbacks, failCallbacks, progressCallbacks ) {
|
1214 | |
deferred.done( doneCallbacks ).fail( failCallbacks ).progress( progressCallbacks );
|
1215 | |
return this;
|
1216 | |
},
|
1217 | |
always: function() {
|
1218 | |
deferred.done.apply( deferred, arguments ).fail.apply( deferred, arguments );
|
1219 | |
return this;
|
1220 | |
},
|
1221 | |
pipe: function( fnDone, fnFail, fnProgress ) {
|
1222 | |
return jQuery.Deferred(function( newDefer ) {
|
1223 | |
jQuery.each( {
|
1224 | |
done: [ fnDone, "resolve" ],
|
1225 | |
fail: [ fnFail, "reject" ],
|
1226 | |
progress: [ fnProgress, "notify" ]
|
1227 | |
}, function( handler, data ) {
|
1228 | |
var fn = data[ 0 ],
|
1229 | |
action = data[ 1 ],
|
1230 | |
returned;
|
1231 | |
if ( jQuery.isFunction( fn ) ) {
|
1232 | |
deferred[ handler ](function() {
|
1233 | |
returned = fn.apply( this, arguments );
|
1234 | |
if ( returned && jQuery.isFunction( returned.promise ) ) {
|
1235 | |
returned.promise().then( newDefer.resolve, newDefer.reject, newDefer.notify );
|
1236 | |
} else {
|
1237 | |
newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
|
1238 | |
}
|
1239 | |
});
|
1240 | |
} else {
|
1241 | |
deferred[ handler ]( newDefer[ action ] );
|
1242 | |
}
|
1243 | |
});
|
1244 | |
}).promise();
|
1245 | |
},
|
1246 | |
// Get a promise for this deferred
|
1247 | |
// If obj is provided, the promise aspect is added to the object
|
1248 | |
promise: function( obj ) {
|
1249 | |
if ( obj == null ) {
|
1250 | |
obj = promise;
|
1251 | |
} else {
|
1252 | |
for ( var key in promise ) {
|
1253 | |
obj[ key ] = promise[ key ];
|
1254 | |
}
|
1255 | |
}
|
1256 | |
return obj;
|
1257 | |
}
|
1258 | |
},
|
1259 | |
deferred = promise.promise({}),
|
1260 | |
key;
|
1261 | |
|
1262 | |
for ( key in lists ) {
|
1263 | |
deferred[ key ] = lists[ key ].fire;
|
1264 | |
deferred[ key + "With" ] = lists[ key ].fireWith;
|
1265 | |
}
|
1266 | |
|
1267 | |
// Handle state
|
1268 | |
deferred.done( function() {
|
1269 | |
state = "resolved";
|
1270 | |
}, failList.disable, progressList.lock ).fail( function() {
|
1271 | |
state = "rejected";
|
1272 | |
}, doneList.disable, progressList.lock );
|
1273 | |
|
1274 | |
// Call given func if any
|
1275 | |
if ( func ) {
|
1276 | |
func.call( deferred, deferred );
|
1277 | |
}
|
1278 | |
|
1279 | |
// All done!
|
1280 | |
return deferred;
|
1281 | |
},
|
1282 | |
|
1283 | |
// Deferred helper
|
1284 | |
when: function( firstParam ) {
|
1285 | |
var args = sliceDeferred.call( arguments, 0 ),
|
1286 | |
i = 0,
|
1287 | |
length = args.length,
|
1288 | |
pValues = new Array( length ),
|
1289 | |
count = length,
|
1290 | |
pCount = length,
|
1291 | |
deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ?
|
1292 | |
firstParam :
|
1293 | |
jQuery.Deferred(),
|
1294 | |
promise = deferred.promise();
|
1295 | |
function resolveFunc( i ) {
|
1296 | |
return function( value ) {
|
1297 | |
args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
|
1298 | |
if ( !( --count ) ) {
|
1299 | |
deferred.resolveWith( deferred, args );
|
1300 | |
}
|
1301 | |
};
|
1302 | |
}
|
1303 | |
function progressFunc( i ) {
|
1304 | |
return function( value ) {
|
1305 | |
pValues[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
|
1306 | |
deferred.notifyWith( promise, pValues );
|
1307 | |
};
|
1308 | |
}
|
1309 | |
if ( length > 1 ) {
|
1310 | |
for ( ; i < length; i++ ) {
|
1311 | |
if ( args[ i ] && args[ i ].promise && jQuery.isFunction( args[ i ].promise ) ) {
|
1312 | |
args[ i ].promise().then( resolveFunc(i), deferred.reject, progressFunc(i) );
|
1313 | |
} else {
|
1314 | |
--count;
|
1315 | |
}
|
1316 | |
}
|
1317 | |
if ( !count ) {
|
1318 | |
deferred.resolveWith( deferred, args );
|
1319 | |
}
|
1320 | |
} else if ( deferred !== firstParam ) {
|
1321 | |
deferred.resolveWith( deferred, length ? [ firstParam ] : [] );
|
1322 | |
}
|
1323 | |
return promise;
|
1324 | |
}
|
1325 | |
});
|
1326 | |
|
1327 | |
|
1328 | |
|
1329 | |
|
1330 | |
jQuery.support = (function() {
|
1331 | |
|
1332 | |
var support,
|
1333 | |
all,
|
1334 | |
a,
|
1335 | |
select,
|
1336 | |
opt,
|
1337 | |
input,
|
1338 | |
marginDiv,
|
1339 | |
fragment,
|
1340 | |
tds,
|
1341 | |
events,
|
1342 | |
eventName,
|
1343 | |
i,
|
1344 | |
isSupported,
|
1345 | |
div = document.createElement( "div" ),
|
1346 | |
documentElement = document.documentElement;
|
1347 | |
|
1348 | |
// Preliminary tests
|
1349 | |
div.setAttribute("className", "t");
|
1350 | |
div.innerHTML = " <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
|
1351 | |
|
1352 | |
all = div.getElementsByTagName( "*" );
|
1353 | |
a = div.getElementsByTagName( "a" )[ 0 ];
|
1354 | |
|
1355 | |
// Can't get basic test support
|
1356 | |
if ( !all || !all.length || !a ) {
|
1357 | |
return {};
|
1358 | |
}
|
1359 | |
|
1360 | |
// First batch of supports tests
|
1361 | |
select = document.createElement( "select" );
|
1362 | |
opt = select.appendChild( document.createElement("option") );
|
1363 | |
input = div.getElementsByTagName( "input" )[ 0 ];
|
1364 | |
|
1365 | |
support = {
|
1366 | |
// IE strips leading whitespace when .innerHTML is used
|
1367 | |
leadingWhitespace: ( div.firstChild.nodeType === 3 ),
|
1368 | |
|
1369 | |
// Make sure that tbody elements aren't automatically inserted
|
1370 | |
// IE will insert them into empty tables
|
1371 | |
tbody: !div.getElementsByTagName("tbody").length,
|
1372 | |
|
1373 | |
// Make sure that link elements get serialized correctly by innerHTML
|
1374 | |
// This requires a wrapper element in IE
|
1375 | |
htmlSerialize: !!div.getElementsByTagName("link").length,
|
1376 | |
|
1377 | |
// Get the style information from getAttribute
|
1378 | |
// (IE uses .cssText instead)
|
1379 | |
style: /top/.test( a.getAttribute("style") ),
|
1380 | |
|
1381 | |
// Make sure that URLs aren't manipulated
|
1382 | |
// (IE normalizes it by default)
|
1383 | |
hrefNormalized: ( a.getAttribute("href") === "/a" ),
|
1384 | |
|
1385 | |
// Make sure that element opacity exists
|
1386 | |
// (IE uses filter instead)
|
1387 | |
// Use a regex to work around a WebKit issue. See #5145
|
1388 | |
opacity: /^0.55/.test( a.style.opacity ),
|
1389 | |
|
1390 | |
// Verify style float existence
|
1391 | |
// (IE uses styleFloat instead of cssFloat)
|
1392 | |
cssFloat: !!a.style.cssFloat,
|
1393 | |
|
1394 | |
// Make sure that if no value is specified for a checkbox
|
1395 | |
// that it defaults to "on".
|
1396 | |
// (WebKit defaults to "" instead)
|
1397 | |
checkOn: ( input.value === "on" ),
|
1398 | |
|
1399 | |
// Make sure that a selected-by-default option has a working selected property.
|
1400 | |
// (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
|
1401 | |
optSelected: opt.selected,
|
1402 | |
|
1403 | |
// Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
|
1404 | |
getSetAttribute: div.className !== "t",
|
1405 | |
|
1406 | |
// Tests for enctype support on a form(#6743)
|
1407 | |
enctype: !!document.createElement("form").enctype,
|
1408 | |
|
1409 | |
// Makes sure cloning an html5 element does not cause problems
|
1410 | |
// Where outerHTML is undefined, this still works
|
1411 | |
html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>",
|
1412 | |
|
1413 | |
// Will be defined later
|
1414 | |
submitBubbles: true,
|
1415 | |
changeBubbles: true,
|
1416 | |
focusinBubbles: false,
|
1417 | |
deleteExpando: true,
|
1418 | |
noCloneEvent: true,
|
1419 | |
inlineBlockNeedsLayout: false,
|
1420 | |
shrinkWrapBlocks: false,
|
1421 | |
reliableMarginRight: true
|
1422 | |
};
|
1423 | |
|
1424 | |
// Make sure checked status is properly cloned
|
1425 | |
input.checked = true;
|
1426 | |
support.noCloneChecked = input.cloneNode( true ).checked;
|
1427 | |
|
1428 | |
// Make sure that the options inside disabled selects aren't marked as disabled
|
1429 | |
// (WebKit marks them as disabled)
|
1430 | |
select.disabled = true;
|
1431 | |
support.optDisabled = !opt.disabled;
|
1432 | |
|
1433 | |
// Test to see if it's possible to delete an expando from an element
|
1434 | |
// Fails in Internet Explorer
|
1435 | |
try {
|
1436 | |
delete div.test;
|
1437 | |
} catch( e ) {
|
1438 | |
support.deleteExpando = false;
|
1439 | |
}
|
1440 | |
|
1441 | |
if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
|
1442 | |
div.attachEvent( "onclick", function() {
|
1443 | |
// Cloning a node shouldn't copy over any
|
1444 | |
// bound event handlers (IE does this)
|
1445 | |
support.noCloneEvent = false;
|
1446 | |
});
|
1447 | |
div.cloneNode( true ).fireEvent( "onclick" );
|
1448 | |
}
|
1449 | |
|
1450 | |
// Check if a radio maintains its value
|
1451 | |
// after being appended to the DOM
|
1452 | |
input = document.createElement("input");
|
1453 | |
input.value = "t";
|
1454 | |
input.setAttribute("type", "radio");
|
1455 | |
support.radioValue = input.value === "t";
|
1456 | |
|
1457 | |
input.setAttribute("checked", "checked");
|
1458 | |
div.appendChild( input );
|
1459 | |
fragment = document.createDocumentFragment();
|
1460 | |
fragment.appendChild( div.lastChild );
|
1461 | |
|
1462 | |
// WebKit doesn't clone checked state correctly in fragments
|
1463 | |
support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
|
1464 | |
|
1465 | |
// Check if a disconnected checkbox will retain its checked
|
1466 | |
// value of true after appended to the DOM (IE6/7)
|
1467 | |
support.appendChecked = input.checked;
|
1468 | |
|
1469 | |
fragment.removeChild( input );
|
1470 | |
fragment.appendChild( div );
|
1471 | |
|
1472 | |
div.innerHTML = "";
|
1473 | |
|
1474 | |
// Check if div with explicit width and no margin-right incorrectly
|
1475 | |
// gets computed margin-right based on width of container. For more
|
1476 | |
// info see bug #3333
|
1477 | |
// Fails in WebKit before Feb 2011 nightlies
|
1478 | |
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
|
1479 | |
if ( window.getComputedStyle ) {
|
1480 | |
marginDiv = document.createElement( "div" );
|
1481 | |
marginDiv.style.width = "0";
|
1482 | |
marginDiv.style.marginRight = "0";
|
1483 | |
div.style.width = "2px";
|
1484 | |
div.appendChild( marginDiv );
|
1485 | |
support.reliableMarginRight =
|
1486 | |
( parseInt( ( window.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;
|
1487 | |
}
|
1488 | |
|
1489 | |
// Technique from Juriy Zaytsev
|
1490 | |
// http://perfectionkills.com/detecting-event-support-without-browser-sniffing/
|
1491 | |
// We only care about the case where non-standard event systems
|
1492 | |
// are used, namely in IE. Short-circuiting here helps us to
|
1493 | |
// avoid an eval call (in setAttribute) which can cause CSP
|
1494 | |
// to go haywire. See: https://developer.mozilla.org/en/Security/CSP
|
1495 | |
if ( div.attachEvent ) {
|
1496 | |
for( i in {
|
1497 | |
submit: 1,
|
1498 | |
change: 1,
|
1499 | |
focusin: 1
|
1500 | |
}) {
|
1501 | |
eventName = "on" + i;
|
1502 | |
isSupported = ( eventName in div );
|
1503 | |
if ( !isSupported ) {
|
1504 | |
div.setAttribute( eventName, "return;" );
|
1505 | |
isSupported = ( typeof div[ eventName ] === "function" );
|
1506 | |
}
|
1507 | |
support[ i + "Bubbles" ] = isSupported;
|
1508 | |
}
|
1509 | |
}
|
1510 | |
|
1511 | |
fragment.removeChild( div );
|
1512 | |
|
1513 | |
// Null elements to avoid leaks in IE
|
1514 | |
fragment = select = opt = marginDiv = div = input = null;
|
1515 | |
|
1516 | |
// Run tests that need a body at doc ready
|
1517 | |
jQuery(function() {
|
1518 | |
var container, outer, inner, table, td, offsetSupport,
|
1519 | |
conMarginTop, ptlm, vb, style, html,
|
1520 | |
body = document.getElementsByTagName("body")[0];
|
1521 | |
|
1522 | |
if ( !body ) {
|
1523 | |
// Return for frameset docs that don't have a body
|
1524 | |
return;
|
1525 | |
}
|
1526 | |
|
1527 | |
conMarginTop = 1;
|
1528 | |
ptlm = "position:absolute;top:0;left:0;width:1px;height:1px;margin:0;";
|
1529 | |
vb = "visibility:hidden;border:0;";
|
1530 | |
style = "style='" + ptlm + "border:5px solid #000;padding:0;'";
|
1531 | |
html = "<div " + style + "><div></div></div>" +
|
1532 | |
"<table " + style + " cellpadding='0' cellspacing='0'>" +
|
1533 | |
"<tr><td></td></tr></table>";
|
1534 | |
|
1535 | |
container = document.createElement("div");
|
1536 | |
container.style.cssText = vb + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px";
|
1537 | |
body.insertBefore( container, body.firstChild );
|
1538 | |
|
1539 | |
// Construct the test element
|
1540 | |
div = document.createElement("div");
|
1541 | |
container.appendChild( div );
|
1542 | |
|
1543 | |
// Check if table cells still have offsetWidth/Height when they are set
|
1544 | |
// to display:none and there are still other visible table cells in a
|
1545 | |
// table row; if so, offsetWidth/Height are not reliable for use when
|
1546 | |
// determining if an element has been hidden directly using
|
1547 | |
// display:none (it is still safe to use offsets if a parent element is
|
1548 | |
// hidden; don safety goggles and see bug #4512 for more information).
|
1549 | |
// (only IE 8 fails this test)
|
1550 | |
div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";
|
1551 | |
tds = div.getElementsByTagName( "td" );
|
1552 | |
isSupported = ( tds[ 0 ].offsetHeight === 0 );
|
1553 | |
|
1554 | |
tds[ 0 ].style.display = "";
|
1555 | |
tds[ 1 ].style.display = "none";
|
1556 | |
|
1557 | |
// Check if empty table cells still have offsetWidth/Height
|
1558 | |
// (IE <= 8 fail this test)
|
1559 | |
support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
|
1560 | |
|
1561 | |
// Figure out if the W3C box model works as expected
|
1562 | |
div.innerHTML = "";
|
1563 | |
div.style.width = div.style.paddingLeft = "1px";
|
1564 | |
jQuery.boxModel = support.boxModel = div.offsetWidth === 2;
|
1565 | |
|
1566 | |
if ( typeof div.style.zoom !== "undefined" ) {
|
1567 | |
// Check if natively block-level elements act like inline-block
|
1568 | |
// elements when setting their display to 'inline' and giving
|
1569 | |
// them layout
|
1570 | |
// (IE < 8 does this)
|
1571 | |
div.style.display = "inline";
|
1572 | |
div.style.zoom = 1;
|
1573 | |
support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 );
|
1574 | |
|
1575 | |
// Check if elements with layout shrink-wrap their children
|
1576 | |
// (IE 6 does this)
|
1577 | |
div.style.display = "";
|
1578 | |
div.innerHTML = "<div style='width:4px;'></div>";
|
1579 | |
support.shrinkWrapBlocks = ( div.offsetWidth !== 2 );
|
1580 | |
}
|
1581 | |
|
1582 | |
div.style.cssText = ptlm + vb;
|
1583 | |
div.innerHTML = html;
|
1584 | |
|
1585 | |
outer = div.firstChild;
|
1586 | |
inner = outer.firstChild;
|
1587 | |
td = outer.nextSibling.firstChild.firstChild;
|
1588 | |
|
1589 | |
offsetSupport = {
|
1590 | |
doesNotAddBorder: ( inner.offsetTop !== 5 ),
|
1591 | |
doesAddBorderForTableAndCells: ( td.offsetTop === 5 )
|
1592 | |
};
|
1593 | |
|
1594 | |
inner.style.position = "fixed";
|
1595 | |
inner.style.top = "20px";
|
1596 | |
|
1597 | |
// safari subtracts parent border width here which is 5px
|
1598 | |
offsetSupport.fixedPosition = ( inner.offsetTop === 20 || inner.offsetTop === 15 );
|
1599 | |
inner.style.position = inner.style.top = "";
|
1600 | |
|
1601 | |
outer.style.overflow = "hidden";
|
1602 | |
outer.style.position = "relative";
|
1603 | |
|
1604 | |
offsetSupport.subtractsBorderForOverflowNotVisible = ( inner.offsetTop === -5 );
|
1605 | |
offsetSupport.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== conMarginTop );
|
1606 | |
|
1607 | |
body.removeChild( container );
|
1608 | |
div = container = null;
|
1609 | |
|
1610 | |
jQuery.extend( support, offsetSupport );
|
1611 | |
});
|
1612 | |
|
1613 | |
return support;
|
1614 | |
})();
|
1615 | |
|
1616 | |
|
1617 | |
|
1618 | |
|
1619 | |
var rbrace = /^(?:\{.*\}|\[.*\])$/,
|
1620 | |
rmultiDash = /([A-Z])/g;
|
1621 | |
|
1622 | |
jQuery.extend({
|
1623 | |
cache: {},
|
1624 | |
|
1625 | |
// Please use with caution
|
1626 | |
uuid: 0,
|
1627 | |
|
1628 | |
// Unique for each copy of jQuery on the page
|
1629 | |
// Non-digits removed to match rinlinejQuery
|
1630 | |
expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
|
1631 | |
|
1632 | |
// The following elements throw uncatchable exceptions if you
|
1633 | |
// attempt to add expando properties to them.
|
1634 | |
noData: {
|
1635 | |
"embed": true,
|
1636 | |
// Ban all objects except for Flash (which handle expandos)
|
1637 | |
"object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
|
1638 | |
"applet": true
|
1639 | |
},
|
1640 | |
|
1641 | |
hasData: function( elem ) {
|
1642 | |
elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
|
1643 | |
return !!elem && !isEmptyDataObject( elem );
|
1644 | |
},
|
1645 | |
|
1646 | |
data: function( elem, name, data, pvt /* Internal Use Only */ ) {
|
1647 | |
if ( !jQuery.acceptData( elem ) ) {
|
1648 | |
return;
|
1649 | |
}
|
1650 | |
|
1651 | |
var privateCache, thisCache, ret,
|
1652 | |
internalKey = jQuery.expando,
|
1653 | |
getByName = typeof name === "string",
|
1654 | |
|
1655 | |
// We have to handle DOM nodes and JS objects differently because IE6-7
|
1656 | |
// can't GC object references properly across the DOM-JS boundary
|
1657 | |
isNode = elem.nodeType,
|
1658 | |
|
1659 | |
// Only DOM nodes need the global jQuery cache; JS object data is
|
1660 | |
// attached directly to the object so GC can occur automatically
|
1661 | |
cache = isNode ? jQuery.cache : elem,
|
1662 | |
|
1663 | |
// Only defining an ID for JS objects if its cache already exists allows
|
1664 | |
// the code to shortcut on the same path as a DOM node with no cache
|
1665 | |
id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey,
|
1666 | |
isEvents = name === "events";
|
1667 | |
|
1668 | |
// Avoid doing any more work than we need to when trying to get data on an
|
1669 | |
// object that has no data at all
|
1670 | |
if ( (!id || !cache[id] || (!isEvents && !pvt && !cache[id].data)) && getByName && data === undefined ) {
|
1671 | |
return;
|
1672 | |
}
|
1673 | |
|
1674 | |
if ( !id ) {
|
1675 | |
// Only DOM nodes need a new unique ID for each element since their data
|
1676 | |
// ends up in the global cache
|
1677 | |
if ( isNode ) {
|
1678 | |
elem[ internalKey ] = id = ++jQuery.uuid;
|
1679 | |
} else {
|
1680 | |
id = internalKey;
|
1681 | |
}
|
1682 | |
}
|
1683 | |
|
1684 | |
if ( !cache[ id ] ) {
|
1685 | |
cache[ id ] = {};
|
1686 | |
|
1687 | |
// Avoids exposing jQuery metadata on plain JS objects when the object
|
1688 | |
// is serialized using JSON.stringify
|
1689 | |
if ( !isNode ) {
|
1690 | |
cache[ id ].toJSON = jQuery.noop;
|
1691 | |
}
|
1692 | |
}
|
1693 | |
|
1694 | |
// An object can be passed to jQuery.data instead of a key/value pair; this gets
|
1695 | |
// shallow copied over onto the existing cache
|
1696 | |
if ( typeof name === "object" || typeof name === "function" ) {
|
1697 | |
if ( pvt ) {
|
1698 | |
cache[ id ] = jQuery.extend( cache[ id ], name );
|
1699 | |
} else {
|
1700 | |
cache[ id ].data = jQuery.extend( cache[ id ].data, name );
|
1701 | |
}
|
1702 | |
}
|
1703 | |
|
1704 | |
privateCache = thisCache = cache[ id ];
|
1705 | |
|
1706 | |
// jQuery data() is stored in a separate object inside the object's internal data
|
1707 | |
// cache in order to avoid key collisions between internal data and user-defined
|
1708 | |
// data.
|
1709 | |
if ( !pvt ) {
|
1710 | |
if ( !thisCache.data ) {
|
1711 | |
thisCache.data = {};
|
1712 | |
}
|
1713 | |
|
1714 | |
thisCache = thisCache.data;
|
1715 | |
}
|
1716 | |
|
1717 | |
if ( data !== undefined ) {
|
1718 | |
thisCache[ jQuery.camelCase( name ) ] = data;
|
1719 | |
}
|
1720 | |
|
1721 | |
// Users should not attempt to inspect the internal events object using jQuery.data,
|
1722 | |
// it is undocumented and subject to change. But does anyone listen? No.
|
1723 | |
if ( isEvents && !thisCache[ name ] ) {
|
1724 | |
return privateCache.events;
|
1725 | |
}
|
1726 | |
|
1727 | |
// Check for both converted-to-camel and non-converted data property names
|
1728 | |
// If a data property was specified
|
1729 | |
if ( getByName ) {
|
1730 | |
|
1731 | |
// First Try to find as-is property data
|
1732 | |
ret = thisCache[ name ];
|
1733 | |
|
1734 | |
// Test for null|undefined property data
|
1735 | |
if ( ret == null ) {
|
1736 | |
|
1737 | |
// Try to find the camelCased property
|
1738 | |
ret = thisCache[ jQuery.camelCase( name ) ];
|
1739 | |
}
|
1740 | |
} else {
|
1741 | |
ret = thisCache;
|
1742 | |
}
|
1743 | |
|
1744 | |
return ret;
|
1745 | |
},
|
1746 | |
|
1747 | |
removeData: function( elem, name, pvt /* Internal Use Only */ ) {
|
1748 | |
if ( !jQuery.acceptData( elem ) ) {
|
1749 | |
return;
|
1750 | |
}
|
1751 | |
|
1752 | |
var thisCache, i, l,
|
1753 | |
|
1754 | |
// Reference to internal data cache key
|
1755 | |
internalKey = jQuery.expando,
|
1756 | |
|
1757 | |
isNode = elem.nodeType,
|
1758 | |
|
1759 | |
// See jQuery.data for more information
|
1760 | |
cache = isNode ? jQuery.cache : elem,
|
1761 | |
|
1762 | |
// See jQuery.data for more information
|
1763 | |
id = isNode ? elem[ internalKey ] : internalKey;
|
1764 | |
|
1765 | |
// If there is already no cache entry for this object, there is no
|
1766 | |
// purpose in continuing
|
1767 | |
if ( !cache[ id ] ) {
|
1768 | |
return;
|
1769 | |
}
|
1770 | |
|
1771 | |
if ( name ) {
|
1772 | |
|
1773 | |
thisCache = pvt ? cache[ id ] : cache[ id ].data;
|
1774 | |
|
1775 | |
if ( thisCache ) {
|
1776 | |
|
1777 | |
// Support array or space separated string names for data keys
|
1778 | |
if ( !jQuery.isArray( name ) ) {
|
1779 | |
|
1780 | |
// try the string as a key before any manipulation
|
1781 | |
if ( name in thisCache ) {
|
1782 | |
name = [ name ];
|
1783 | |
} else {
|
1784 | |
|
1785 | |
// split the camel cased version by spaces unless a key with the spaces exists
|
1786 | |
name = jQuery.camelCase( name );
|
1787 | |
if ( name in thisCache ) {
|
1788 | |
name = [ name ];
|
1789 | |
} else {
|
1790 | |
name = name.split( " " );
|
1791 | |
}
|
1792 | |
}
|
1793 | |
}
|
1794 | |
|
1795 | |
for ( i = 0, l = name.length; i < l; i++ ) {
|
1796 | |
delete thisCache[ name[i] ];
|
1797 | |
}
|
1798 | |
|
1799 | |
// If there is no data left in the cache, we want to continue
|
1800 | |
// and let the cache object itself get destroyed
|
1801 | |
if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) {
|
1802 | |
return;
|
1803 | |
}
|
1804 | |
}
|
1805 | |
}
|
1806 | |
|
1807 | |
// See jQuery.data for more information
|
1808 | |
if ( !pvt ) {
|
1809 | |
delete cache[ id ].data;
|
1810 | |
|
1811 | |
// Don't destroy the parent cache unless the internal data object
|
1812 | |
// had been the only thing left in it
|
1813 | |
if ( !isEmptyDataObject(cache[ id ]) ) {
|
1814 | |
return;
|
1815 | |
}
|
1816 | |
}
|
1817 | |
|
1818 | |
// Browsers that fail expando deletion also refuse to delete expandos on
|
1819 | |
// the window, but it will allow it on all other JS objects; other browsers
|
1820 | |
// don't care
|
1821 | |
// Ensure that `cache` is not a window object #10080
|
1822 | |
if ( jQuery.support.deleteExpando || !cache.setInterval ) {
|
1823 | |
delete cache[ id ];
|
1824 | |
} else {
|
1825 | |
cache[ id ] = null;
|
1826 | |
}
|
1827 | |
|
1828 | |
// We destroyed the cache and need to eliminate the expando on the node to avoid
|
1829 | |
// false lookups in the cache for entries that no longer exist
|
1830 | |
if ( isNode ) {
|
1831 | |
// IE does not allow us to delete expando properties from nodes,
|
1832 | |
// nor does it have a removeAttribute function on Document nodes;
|
1833 | |
// we must handle all of these cases
|
1834 | |
if ( jQuery.support.deleteExpando ) {
|
1835 | |
delete elem[ internalKey ];
|
1836 | |
} else if ( elem.removeAttribute ) {
|
1837 | |
elem.removeAttribute( internalKey );
|
1838 | |
} else {
|
1839 | |
elem[ internalKey ] = null;
|
1840 | |
}
|
1841 | |
}
|
1842 | |
},
|
1843 | |
|
1844 | |
// For internal use only.
|
1845 | |
_data: function( elem, name, data ) {
|
1846 | |
return jQuery.data( elem, name, data, true );
|
1847 | |
},
|
1848 | |
|
1849 | |
// A method for determining if a DOM node can handle the data expando
|
1850 | |
acceptData: function( elem ) {
|
1851 | |
if ( elem.nodeName ) {
|
1852 | |
var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
|
1853 | |
|
1854 | |
if ( match ) {
|
1855 | |
return !(match === true || elem.getAttribute("classid") !== match);
|
1856 | |
}
|
1857 | |
}
|
1858 | |
|
1859 | |
return true;
|
1860 | |
}
|
1861 | |
});
|
1862 | |
|
1863 | |
jQuery.fn.extend({
|
1864 | |
data: function( key, value ) {
|
1865 | |
var parts, attr, name,
|
1866 | |
data = null;
|
1867 | |
|
1868 | |
if ( typeof key === "undefined" ) {
|
1869 | |
if ( this.length ) {
|
1870 | |
data = jQuery.data( this[0] );
|
1871 | |
|
1872 | |
if ( this[0].nodeType === 1 && !jQuery._data( this[0], "parsedAttrs" ) ) {
|
1873 | |
attr = this[0].attributes;
|
1874 | |
for ( var i = 0, l = attr.length; i < l; i++ ) {
|
1875 | |
name = attr[i].name;
|
1876 | |
|
1877 | |
if ( name.indexOf( "data-" ) === 0 ) {
|
1878 | |
name = jQuery.camelCase( name.substring(5) );
|
1879 | |
|
1880 | |
dataAttr( this[0], name, data[ name ] );
|
1881 | |
}
|
1882 | |
}
|
1883 | |
jQuery._data( this[0], "parsedAttrs", true );
|
1884 | |
}
|
1885 | |
}
|
1886 | |
|
1887 | |
return data;
|
1888 | |
|
1889 | |
} else if ( typeof key === "object" ) {
|
1890 | |
return this.each(function() {
|
1891 | |
jQuery.data( this, key );
|
1892 | |
});
|
1893 | |
}
|
1894 | |
|
1895 | |
parts = key.split(".");
|
1896 | |
parts[1] = parts[1] ? "." + parts[1] : "";
|
1897 | |
|
1898 | |
if ( value === undefined ) {
|
1899 | |
data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
|
1900 | |
|
1901 | |
// Try to fetch any internally stored data first
|
1902 | |
if ( data === undefined && this.length ) {
|
1903 | |
data = jQuery.data( this[0], key );
|
1904 | |
data = dataAttr( this[0], key, data );
|
1905 | |
}
|
1906 | |
|
1907 | |
return data === undefined && parts[1] ?
|
1908 | |
this.data( parts[0] ) :
|
1909 | |
data;
|
1910 | |
|
1911 | |
} else {
|
1912 | |
return this.each(function() {
|
1913 | |
var self = jQuery( this ),
|
1914 | |
args = [ parts[0], value ];
|
1915 | |
|
1916 | |
self.triggerHandler( "setData" + parts[1] + "!", args );
|
1917 | |
jQuery.data( this, key, value );
|
1918 | |
self.triggerHandler( "changeData" + parts[1] + "!", args );
|
1919 | |
});
|
1920 | |
}
|
1921 | |
},
|
1922 | |
|
1923 | |
removeData: function( key ) {
|
1924 | |
return this.each(function() {
|
1925 | |
jQuery.removeData( this, key );
|
1926 | |
});
|
1927 | |
}
|
1928 | |
});
|
1929 | |
|
1930 | |
function dataAttr( elem, key, data ) {
|
1931 | |
// If nothing was found internally, try to fetch any
|
1932 | |
// data from the HTML5 data-* attribute
|
1933 | |
if ( data === undefined && elem.nodeType === 1 ) {
|
1934 | |
|
1935 | |
var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
|
1936 | |
|
1937 | |
data = elem.getAttribute( name );
|
1938 | |
|
1939 | |
if ( typeof data === "string" ) {
|
1940 | |
try {
|
1941 | |
data = data === "true" ? true :
|
1942 | |
data === "false" ? false :
|
1943 | |
data === "null" ? null :
|
1944 | |
jQuery.isNumeric( data ) ? parseFloat( data ) :
|
1945 | |
rbrace.test( data ) ? jQuery.parseJSON( data ) :
|
1946 | |
data;
|
1947 | |
} catch( e ) {}
|
1948 | |
|
1949 | |
// Make sure we set the data so it isn't changed later
|
1950 | |
jQuery.data( elem, key, data );
|
1951 | |
|
1952 | |
} else {
|
1953 | |
data = undefined;
|
1954 | |
}
|
1955 | |
}
|
1956 | |
|
1957 | |
return data;
|
1958 | |
}
|
1959 | |
|
1960 | |
// checks a cache object for emptiness
|
1961 | |
function isEmptyDataObject( obj ) {
|
1962 | |
for ( var name in obj ) {
|
1963 | |
|
1964 | |
// if the public data object is empty, the private is still empty
|
1965 | |
if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
|
1966 | |
continue;
|
1967 | |
}
|
1968 | |
if ( name !== "toJSON" ) {
|
1969 | |
return false;
|
1970 | |
}
|
1971 | |
}
|
1972 | |
|
1973 | |
return true;
|
1974 | |
}
|
1975 | |
|
1976 | |
|
1977 | |
|
1978 | |
|
1979 | |
function handleQueueMarkDefer( elem, type, src ) {
|
1980 | |
var deferDataKey = type + "defer",
|
1981 | |
queueDataKey = type + "queue",
|
1982 | |
markDataKey = type + "mark",
|
1983 | |
defer = jQuery._data( elem, deferDataKey );
|
1984 | |
if ( defer &&
|
1985 | |
( src === "queue" || !jQuery._data(elem, queueDataKey) ) &&
|
1986 | |
( src === "mark" || !jQuery._data(elem, markDataKey) ) ) {
|
1987 | |
// Give room for hard-coded callbacks to fire first
|
1988 | |
// and eventually mark/queue something else on the element
|
1989 | |
setTimeout( function() {
|
1990 | |
if ( !jQuery._data( elem, queueDataKey ) &&
|
1991 | |
!jQuery._data( elem, markDataKey ) ) {
|
1992 | |
jQuery.removeData( elem, deferDataKey, true );
|
1993 | |
defer.fire();
|
1994 | |
}
|
1995 | |
}, 0 );
|
1996 | |
}
|
1997 | |
}
|
1998 | |
|
1999 | |
jQuery.extend({
|
2000 | |
|
2001 | |
_mark: function( elem, type ) {
|
2002 | |
if ( elem ) {
|
2003 | |
type = ( type || "fx" ) + "mark";
|
2004 | |
jQuery._data( elem, type, (jQuery._data( elem, type ) || 0) + 1 );
|
2005 | |
}
|
2006 | |
},
|
2007 | |
|
2008 | |
_unmark: function( force, elem, type ) {
|
2009 | |
if ( force !== true ) {
|
2010 | |
type = elem;
|
2011 | |
elem = force;
|
2012 | |
force = false;
|
2013 | |
}
|
2014 | |
if ( elem ) {
|
2015 | |
type = type || "fx";
|
2016 | |
var key = type + "mark",
|
2017 | |
count = force ? 0 : ( (jQuery._data( elem, key ) || 1) - 1 );
|
2018 | |
if ( count ) {
|
2019 | |
jQuery._data( elem, key, count );
|
2020 | |
} else {
|
2021 | |
jQuery.removeData( elem, key, true );
|
2022 | |
handleQueueMarkDefer( elem, type, "mark" );
|
2023 | |
}
|
2024 | |
}
|
2025 | |
},
|
2026 | |
|
2027 | |
queue: function( elem, type, data ) {
|
2028 | |
var q;
|
2029 | |
if ( elem ) {
|
2030 | |
type = ( type || "fx" ) + "queue";
|
2031 | |
q = jQuery._data( elem, type );
|
2032 | |
|
2033 | |
// Speed up dequeue by getting out quickly if this is just a lookup
|
2034 | |
if ( data ) {
|
2035 | |
if ( !q || jQuery.isArray(data) ) {
|
2036 | |
q = jQuery._data( elem, type, jQuery.makeArray(data) );
|
2037 | |
} else {
|
2038 | |
q.push( data );
|
2039 | |
}
|
2040 | |
}
|
2041 | |
return q || [];
|
2042 | |
}
|
2043 | |
},
|
2044 | |
|
2045 | |
dequeue: function( elem, type ) {
|
2046 | |
type = type || "fx";
|
2047 | |
|
2048 | |
var queue = jQuery.queue( elem, type ),
|
2049 | |
fn = queue.shift(),
|
2050 | |
hooks = {};
|
2051 | |
|
2052 | |
// If the fx queue is dequeued, always remove the progress sentinel
|
2053 | |
if ( fn === "inprogress" ) {
|
2054 | |
fn = queue.shift();
|
2055 | |
}
|
2056 | |
|
2057 | |
if ( fn ) {
|
2058 | |
// Add a progress sentinel to prevent the fx queue from being
|
2059 | |
// automatically dequeued
|
2060 | |
if ( type === "fx" ) {
|
2061 | |
queue.unshift( "inprogress" );
|
2062 | |
}
|
2063 | |
|
2064 | |
jQuery._data( elem, type + ".run", hooks );
|
2065 | |
fn.call( elem, function() {
|
2066 | |
jQuery.dequeue( elem, type );
|
2067 | |
}, hooks );
|
2068 | |
}
|
2069 | |
|
2070 | |
if ( !queue.length ) {
|
2071 | |
jQuery.removeData( elem, type + "queue " + type + ".run", true );
|
2072 | |
handleQueueMarkDefer( elem, type, "queue" );
|
2073 | |
}
|
2074 | |
}
|
2075 | |
});
|
2076 | |
|
2077 | |
jQuery.fn.extend({
|
2078 | |
queue: function( type, data ) {
|
2079 | |
if ( typeof type !== "string" ) {
|
2080 | |
data = type;
|
2081 | |
type = "fx";
|
2082 | |
}
|
2083 | |
|
2084 | |
if ( data === undefined ) {
|
2085 | |
return jQuery.queue( this[0], type );
|
2086 | |
}
|
2087 | |
return this.each(function() {
|
2088 | |
var queue = jQuery.queue( this, type, data );
|
2089 | |
|
2090 | |
if ( type === "fx" && queue[0] !== "inprogress" ) {
|
2091 | |
jQuery.dequeue( this, type );
|
2092 | |
}
|
2093 | |
});
|
2094 | |
},
|
2095 | |
dequeue: function( type ) {
|
2096 | |
return this.each(function() {
|
2097 | |
jQuery.dequeue( this, type );
|
2098 | |
});
|
2099 | |
},
|
2100 | |
// Based off of the plugin by Clint Helfers, with permission.
|
2101 | |
// http://blindsignals.com/index.php/2009/07/jquery-delay/
|
2102 | |
delay: function( time, type ) {
|
2103 | |
time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
|
2104 | |
type = type || "fx";
|
2105 | |
|
2106 | |
return this.queue( type, function( next, hooks ) {
|
2107 | |
var timeout = setTimeout( next, time );
|
2108 | |
hooks.stop = function() {
|
2109 | |
clearTimeout( timeout );
|
2110 | |
};
|
2111 | |
});
|
2112 | |
},
|
2113 | |
clearQueue: function( type ) {
|
2114 | |
return this.queue( type || "fx", [] );
|
2115 | |
},
|
2116 | |
// Get a promise resolved when queues of a certain type
|
2117 | |
// are emptied (fx is the type by default)
|
2118 | |
promise: function( type, object ) {
|
2119 | |
if ( typeof type !== "string" ) {
|
2120 | |
object = type;
|
2121 | |
type = undefined;
|
2122 | |
}
|
2123 | |
type = type || "fx";
|
2124 | |
var defer = jQuery.Deferred(),
|
2125 | |
elements = this,
|
2126 | |
i = elements.length,
|
2127 | |
count = 1,
|
2128 | |
deferDataKey = type + "defer",
|
2129 | |
queueDataKey = type + "queue",
|
2130 | |
markDataKey = type + "mark",
|
2131 | |
tmp;
|
2132 | |
function resolve() {
|
2133 | |
if ( !( --count ) ) {
|
2134 | |
defer.resolveWith( elements, [ elements ] );
|
2135 | |
}
|
2136 | |
}
|
2137 | |
while( i-- ) {
|
2138 | |
if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) ||
|
2139 | |
( jQuery.data( elements[ i ], queueDataKey, undefined, true ) ||
|
2140 | |
jQuery.data( elements[ i ], markDataKey, undefined, true ) ) &&
|
2141 | |
jQuery.data( elements[ i ], deferDataKey, jQuery.Callbacks( "once memory" ), true ) )) {
|
2142 | |
count++;
|
2143 | |
tmp.add( resolve );
|
2144 | |
}
|
2145 | |
}
|
2146 | |
resolve();
|
2147 | |
return defer.promise();
|
2148 | |
}
|
2149 | |
});
|
2150 | |
|
2151 | |
|
2152 | |
|
2153 | |
|
2154 | |
var rclass = /[\n\t\r]/g,
|
2155 | |
rspace = /\s+/,
|
2156 | |
rreturn = /\r/g,
|
2157 | |
rtype = /^(?:button|input)$/i,
|
2158 | |
rfocusable = /^(?:button|input|object|select|textarea)$/i,
|
2159 | |
rclickable = /^a(?:rea)?$/i,
|
2160 | |
rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
|
2161 | |
getSetAttribute = jQuery.support.getSetAttribute,
|
2162 | |
nodeHook, boolHook, fixSpecified;
|
2163 | |
|
2164 | |
jQuery.fn.extend({
|
2165 | |
attr: function( name, value ) {
|
2166 | |
return jQuery.access( this, name, value, true, jQuery.attr );
|
2167 | |
},
|
2168 | |
|
2169 | |
removeAttr: function( name ) {
|
2170 | |
return this.each(function() {
|
2171 | |
jQuery.removeAttr( this, name );
|
2172 | |
});
|
2173 | |
},
|
2174 | |
|
2175 | |
prop: function( name, value ) {
|
2176 | |
return jQuery.access( this, name, value, true, jQuery.prop );
|
2177 | |
},
|
2178 | |
|
2179 | |
removeProp: function( name ) {
|
2180 | |
name = jQuery.propFix[ name ] || name;
|
2181 | |
return this.each(function() {
|
2182 | |
// try/catch handles cases where IE balks (such as removing a property on window)
|
2183 | |
try {
|
2184 | |
this[ name ] = undefined;
|
2185 | |
delete this[ name ];
|
2186 | |
} catch( e ) {}
|
2187 | |
});
|
2188 | |
},
|
2189 | |
|
2190 | |
addClass: function( value ) {
|
2191 | |
var classNames, i, l, elem,
|
2192 | |
setClass, c, cl;
|
2193 | |
|
2194 | |
if ( jQuery.isFunction( value ) ) {
|
2195 | |
return this.each(function( j ) {
|
2196 | |
jQuery( this ).addClass( value.call(this, j, this.className) );
|
2197 | |
});
|
2198 | |
}
|
2199 | |
|
2200 | |
if ( value && typeof value === "string" ) {
|
2201 | |
classNames = value.split( rspace );
|
2202 | |
|
2203 | |
for ( i = 0, l = this.length; i < l; i++ ) {
|
2204 | |
elem = this[ i ];
|
2205 | |
|
2206 | |
if ( elem.nodeType === 1 ) {
|
2207 | |
if ( !elem.className && classNames.length === 1 ) {
|
2208 | |
elem.className = value;
|
2209 | |
|
2210 | |
} else {
|
2211 | |
setClass = " " + elem.className + " ";
|
2212 | |
|
2213 | |
for ( c = 0, cl = classNames.length; c < cl; c++ ) {
|
2214 | |
if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) {
|
2215 | |
setClass += classNames[ c ] + " ";
|
2216 | |
}
|
2217 | |
}
|
2218 | |
elem.className = jQuery.trim( setClass );
|
2219 | |
}
|
2220 | |
}
|
2221 | |
}
|
2222 | |
}
|
2223 | |
|
2224 | |
return this;
|
2225 | |
},
|
2226 | |
|
2227 | |
removeClass: function( value ) {
|
2228 | |
var classNames, i, l, elem, className, c, cl;
|
2229 | |
|
2230 | |
if ( jQuery.isFunction( value ) ) {
|
2231 | |
return this.each(function( j ) {
|
2232 | |
jQuery( this ).removeClass( value.call(this, j, this.className) );
|
2233 | |
});
|
2234 | |
}
|
2235 | |
|
2236 | |
if ( (value && typeof value === "string") || value === undefined ) {
|
2237 | |
classNames = ( value || "" ).split( rspace );
|
2238 | |
|
2239 | |
for ( i = 0, l = this.length; i < l; i++ ) {
|
2240 | |
elem = this[ i ];
|
2241 | |
|
2242 | |
if ( elem.nodeType === 1 && elem.className ) {
|
2243 | |
if ( value ) {
|
2244 | |
className = (" " + elem.className + " ").replace( rclass, " " );
|
2245 | |
for ( c = 0, cl = classNames.length; c < cl; c++ ) {
|
2246 | |
className = className.replace(" " + classNames[ c ] + " ", " ");
|
2247 | |
}
|
2248 | |
elem.className = jQuery.trim( className );
|
2249 | |
|
2250 | |
} else {
|
2251 | |
elem.className = "";
|
2252 | |
}
|
2253 | |
}
|
2254 | |
}
|
2255 | |
}
|
2256 | |
|
2257 | |
return this;
|
2258 | |
},
|
2259 | |
|
2260 | |
toggleClass: function( value, stateVal ) {
|
2261 | |
var type = typeof value,
|
2262 | |
isBool = typeof stateVal === "boolean";
|
2263 | |
|
2264 | |
if ( jQuery.isFunction( value ) ) {
|
2265 | |
return this.each(function( i ) {
|
2266 | |
jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
|
2267 | |
});
|
2268 | |
}
|
2269 | |
|
2270 | |
return this.each(function() {
|
2271 | |
if ( type === "string" ) {
|
2272 | |
// toggle individual class names
|
2273 | |
var className,
|
2274 | |
i = 0,
|
2275 | |
self = jQuery( this ),
|
2276 | |
state = stateVal,
|
2277 | |
classNames = value.split( rspace );
|
2278 | |
|
2279 | |
while ( (className = classNames[ i++ ]) ) {
|
2280 | |
// check each className given, space seperated list
|
2281 | |
state = isBool ? state : !self.hasClass( className );
|
2282 | |
self[ state ? "addClass" : "removeClass" ]( className );
|
2283 | |
}
|
2284 | |
|
2285 | |
} else if ( type === "undefined" || type === "boolean" ) {
|
2286 | |
if ( this.className ) {
|
2287 | |
// store className if set
|
2288 | |
jQuery._data( this, "__className__", this.className );
|
2289 | |
}
|
2290 | |
|
2291 | |
// toggle whole className
|
2292 | |
this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
|
2293 | |
}
|
2294 | |
});
|
2295 | |
},
|
2296 | |
|
2297 | |
hasClass: function( selector ) {
|
2298 | |
var className = " " + selector + " ",
|
2299 | |
i = 0,
|
2300 | |
l = this.length;
|
2301 | |
for ( ; i < l; i++ ) {
|
2302 | |
if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
|
2303 | |
return true;
|
2304 | |
}
|
2305 | |
}
|
2306 | |
|
2307 | |
return false;
|
2308 | |
},
|
2309 | |
|
2310 | |
val: function( value ) {
|
2311 | |
var hooks, ret, isFunction,
|
2312 | |
elem = this[0];
|
2313 | |
|
2314 | |
if ( !arguments.length ) {
|
2315 | |
if ( elem ) {
|
2316 | |
hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ];
|
2317 | |
|
2318 | |
if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
|
2319 | |
return ret;
|
2320 | |
}
|
2321 | |
|
2322 | |
ret = elem.value;
|
2323 | |
|
2324 | |
return typeof ret === "string" ?
|
2325 | |
// handle most common string cases
|
2326 | |
ret.replace(rreturn, "") :
|
2327 | |
// handle cases where value is null/undef or number
|
2328 | |
ret == null ? "" : ret;
|
2329 | |
}
|
2330 | |
|
2331 | |
return;
|
2332 | |
}
|
2333 | |
|
2334 | |
isFunction = jQuery.isFunction( value );
|
2335 | |
|
2336 | |
return this.each(function( i ) {
|
2337 | |
var self = jQuery(this), val;
|
2338 | |
|
2339 | |
if ( this.nodeType !== 1 ) {
|
2340 | |
return;
|
2341 | |
}
|
2342 | |
|
2343 | |
if ( isFunction ) {
|
2344 | |
val = value.call( this, i, self.val() );
|
2345 | |
} else {
|
2346 | |
val = value;
|
2347 | |
}
|
2348 | |
|
2349 | |
// Treat null/undefined as ""; convert numbers to string
|
2350 | |
if ( val == null ) {
|
2351 | |
val = "";
|
2352 | |
} else if ( typeof val === "number" ) {
|
2353 | |
val += "";
|
2354 | |
} else if ( jQuery.isArray( val ) ) {
|
2355 | |
val = jQuery.map(val, function ( value ) {
|
2356 | |
return value == null ? "" : value + "";
|
2357 | |
});
|
2358 | |
}
|
2359 | |
|
2360 | |
hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ];
|
2361 | |
|
2362 | |
// If set returns undefined, fall back to normal setting
|
2363 | |
if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
|
2364 | |
this.value = val;
|
2365 | |
}
|
2366 | |
});
|
2367 | |
}
|
2368 | |
});
|
2369 | |
|
2370 | |
jQuery.extend({
|
2371 | |
valHooks: {
|
2372 | |
option: {
|
2373 | |
get: function( elem ) {
|
2374 | |
// attributes.value is undefined in Blackberry 4.7 but
|
2375 | |
// uses .value. See #6932
|
2376 | |
var val = elem.attributes.value;
|
2377 | |
return !val || val.specified ? elem.value : elem.text;
|
2378 | |
}
|
2379 | |
},
|
2380 | |
select: {
|
2381 | |
get: function( elem ) {
|
2382 | |
var value, i, max, option,
|
2383 | |
index = elem.selectedIndex,
|
2384 | |
values = [],
|
2385 | |
options = elem.options,
|
2386 | |
one = elem.type === "select-one";
|
2387 | |
|
2388 | |
// Nothing was selected
|
2389 | |
if ( index < 0 ) {
|
2390 | |
return null;
|
2391 | |
}
|
2392 | |
|
2393 | |
// Loop through all the selected options
|
2394 | |
i = one ? index : 0;
|
2395 | |
max = one ? index + 1 : options.length;
|
2396 | |
for ( ; i < max; i++ ) {
|
2397 | |
option = options[ i ];
|
2398 | |
|
2399 | |
// Don't return options that are disabled or in a disabled optgroup
|
2400 | |
if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
|
2401 | |
(!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
|
2402 | |
|
2403 | |
// Get the specific value for the option
|
2404 | |
value = jQuery( option ).val();
|
2405 | |
|
2406 | |
// We don't need an array for one selects
|
2407 | |
if ( one ) {
|
2408 | |
return value;
|
2409 | |
}
|
2410 | |
|
2411 | |
// Multi-Selects return an array
|
2412 | |
values.push( value );
|
2413 | |
}
|
2414 | |
}
|
2415 | |
|
2416 | |
// Fixes Bug #2551 -- select.val() broken in IE after form.reset()
|
2417 | |
if ( one && !values.length && options.length ) {
|
2418 | |
return jQuery( options[ index ] ).val();
|
2419 | |
}
|
2420 | |
|
2421 | |
return values;
|
2422 | |
},
|
2423 | |
|
2424 | |
set: function( elem, value ) {
|
2425 | |
var values = jQuery.makeArray( value );
|
2426 | |
|
2427 | |
jQuery(elem).find("option").each(function() {
|
2428 | |
this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
|
2429 | |
});
|
2430 | |
|
2431 | |
if ( !values.length ) {
|
2432 | |
elem.selectedIndex = -1;
|
2433 | |
}
|
2434 | |
return values;
|
2435 | |
}
|
2436 | |
}
|
2437 | |
},
|
2438 | |
|
2439 | |
attrFn: {
|
2440 | |
val: true,
|
2441 | |
css: true,
|
2442 | |
html: true,
|
2443 | |
text: true,
|
2444 | |
data: true,
|
2445 | |
width: true,
|
2446 | |
height: true,
|
2447 | |
offset: true
|
2448 | |
},
|
2449 | |
|
2450 | |
attr: function( elem, name, value, pass ) {
|
2451 | |
var ret, hooks, notxml,
|
2452 | |
nType = elem.nodeType;
|
2453 | |
|
2454 | |
// don't get/set attributes on text, comment and attribute nodes
|
2455 | |
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
|
2456 | |
return;
|
2457 | |
}
|
2458 | |
|
2459 | |
if ( pass && name in jQuery.attrFn ) {
|
2460 | |
return jQuery( elem )[ name ]( value );
|
2461 | |
}
|
2462 | |
|
2463 | |
// Fallback to prop when attributes are not supported
|
2464 | |
if ( typeof elem.getAttribute === "undefined" ) {
|
2465 | |
return jQuery.prop( elem, name, value );
|
2466 | |
}
|
2467 | |
|
2468 | |
notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
|
2469 | |
|
2470 | |
// All attributes are lowercase
|
2471 | |
// Grab necessary hook if one is defined
|
2472 | |
if ( notxml ) {
|
2473 | |
name = name.toLowerCase();
|
2474 | |
hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook );
|
2475 | |
}
|
2476 | |
|
2477 | |
if ( value !== undefined ) {
|
2478 | |
|
2479 | |
if ( value === null ) {
|
2480 | |
jQuery.removeAttr( elem, name );
|
2481 | |
return;
|
2482 | |
|
2483 | |
} else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) {
|
2484 | |
return ret;
|
2485 | |
|
2486 | |
} else {
|
2487 | |
elem.setAttribute( name, "" + value );
|
2488 | |
return value;
|
2489 | |
}
|
2490 | |
|
2491 | |
} else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) {
|
2492 | |
return ret;
|
2493 | |
|
2494 | |
} else {
|
2495 | |
|
2496 | |
ret = elem.getAttribute( name );
|
2497 | |
|
2498 | |
// Non-existent attributes return null, we normalize to undefined
|
2499 | |
return ret === null ?
|
2500 | |
undefined :
|
2501 | |
ret;
|
2502 | |
}
|
2503 | |
},
|
2504 | |
|
2505 | |
removeAttr: function( elem, value ) {
|
2506 | |
var propName, attrNames, name, l,
|
2507 | |
i = 0;
|
2508 | |
|
2509 | |
if ( value && elem.nodeType === 1 ) {
|
2510 | |
attrNames = value.toLowerCase().split( rspace );
|
2511 | |
l = attrNames.length;
|
2512 | |
|
2513 | |
for ( ; i < l; i++ ) {
|
2514 | |
name = attrNames[ i ];
|
2515 | |
|
2516 | |
if ( name ) {
|
2517 | |
propName = jQuery.propFix[ name ] || name;
|
2518 | |
|
2519 | |
// See #9699 for explanation of this approach (setting first, then removal)
|
2520 | |
jQuery.attr( elem, name, "" );
|
2521 | |
elem.removeAttribute( getSetAttribute ? name : propName );
|
2522 | |
|
2523 | |
// Set corresponding property to false for boolean attributes
|
2524 | |
if ( rboolean.test( name ) && propName in elem ) {
|
2525 | |
elem[ propName ] = false;
|
2526 | |
}
|
2527 | |
}
|
2528 | |
}
|
2529 | |
}
|
2530 | |
},
|
2531 | |
|
2532 | |
attrHooks: {
|
2533 | |
type: {
|
2534 | |
set: function( elem, value ) {
|
2535 | |
// We can't allow the type property to be changed (since it causes problems in IE)
|
2536 | |
if ( rtype.test( elem.nodeName ) && elem.parentNode ) {
|
2537 | |
jQuery.error( "type property can't be changed" );
|
2538 | |
} else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
|
2539 | |
// Setting the type on a radio button after the value resets the value in IE6-9
|
2540 | |
// Reset value to it's default in case type is set after value
|
2541 | |
// This is for element creation
|
2542 | |
var val = elem.value;
|
2543 | |
elem.setAttribute( "type", value );
|
2544 | |
if ( val ) {
|
2545 | |
elem.value = val;
|
2546 | |
}
|
2547 | |
return value;
|
2548 | |
}
|
2549 | |
}
|
2550 | |
},
|
2551 | |
// Use the value property for back compat
|
2552 | |
// Use the nodeHook for button elements in IE6/7 (#1954)
|
2553 | |
value: {
|
2554 | |
get: function( elem, name ) {
|
2555 | |
if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
|
2556 | |
return nodeHook.get( elem, name );
|
2557 | |
}
|
2558 | |
return name in elem ?
|
2559 | |
elem.value :
|
2560 | |
null;
|
2561 | |
},
|
2562 | |
set: function( elem, value, name ) {
|
2563 | |
if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
|
2564 | |
return nodeHook.set( elem, value, name );
|
2565 | |
}
|
2566 | |
// Does not return so that setAttribute is also used
|
2567 | |
elem.value = value;
|
2568 | |
}
|
2569 | |
}
|
2570 | |
},
|
2571 | |
|
2572 | |
propFix: {
|
2573 | |
tabindex: "tabIndex",
|
2574 | |
readonly: "readOnly",
|
2575 | |
"for": "htmlFor",
|
2576 | |
"class": "className",
|
2577 | |
maxlength: "maxLength",
|
2578 | |
cellspacing: "cellSpacing",
|
2579 | |
cellpadding: "cellPadding",
|
2580 | |
rowspan: "rowSpan",
|
2581 | |
colspan: "colSpan",
|
2582 | |
usemap: "useMap",
|
2583 | |
frameborder: "frameBorder",
|
2584 | |
contenteditable: "contentEditable"
|
2585 | |
},
|
2586 | |
|
2587 | |
prop: function( elem, name, value ) {
|
2588 | |
var ret, hooks, notxml,
|
2589 | |
nType = elem.nodeType;
|
2590 | |
|
2591 | |
// don't get/set properties on text, comment and attribute nodes
|
2592 | |
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
|
2593 | |
return;
|
2594 | |
}
|
2595 | |
|
2596 | |
notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
|
2597 | |
|
2598 | |
if ( notxml ) {
|
2599 | |
// Fix name and attach hooks
|
2600 | |
name = jQuery.propFix[ name ] || name;
|
2601 | |
hooks = jQuery.propHooks[ name ];
|
2602 | |
}
|
2603 | |
|
2604 | |
if ( value !== undefined ) {
|
2605 | |
if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
|
2606 | |
return ret;
|
2607 | |
|
2608 | |
} else {
|
2609 | |
return ( elem[ name ] = value );
|
2610 | |
}
|
2611 | |
|
2612 | |
} else {
|
2613 | |
if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
|
2614 | |
return ret;
|
2615 | |
|
2616 | |
} else {
|
2617 | |
return elem[ name ];
|
2618 | |
}
|
2619 | |
}
|
2620 | |
},
|
2621 | |
|
2622 | |
propHooks: {
|
2623 | |
tabIndex: {
|
2624 | |
get: function( elem ) {
|
2625 | |
// elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
|
2626 | |
// http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
|
2627 | |
var attributeNode = elem.getAttributeNode("tabindex");
|
2628 | |
|
2629 | |
return attributeNode && attributeNode.specified ?
|
2630 | |
parseInt( attributeNode.value, 10 ) :
|
2631 | |
rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
|
2632 | |
0 :
|
2633 | |
undefined;
|
2634 | |
}
|
2635 | |
}
|
2636 | |
}
|
2637 | |
});
|
2638 | |
|
2639 | |
// Add the tabIndex propHook to attrHooks for back-compat (different case is intentional)
|
2640 | |
jQuery.attrHooks.tabindex = jQuery.propHooks.tabIndex;
|
2641 | |
|
2642 | |
// Hook for boolean attributes
|
2643 | |
boolHook = {
|
2644 | |
get: function( elem, name ) {
|
2645 | |
// Align boolean attributes with corresponding properties
|
2646 | |
// Fall back to attribute presence where some booleans are not supported
|
2647 | |
var attrNode,
|
2648 | |
property = jQuery.prop( elem, name );
|
2649 | |
return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?
|
2650 | |
name.toLowerCase() :
|
2651 | |
undefined;
|
2652 | |
},
|
2653 | |
set: function( elem, value, name ) {
|
2654 | |
var propName;
|
2655 | |
if ( value === false ) {
|
2656 | |
// Remove boolean attributes when set to false
|
2657 | |
jQuery.removeAttr( elem, name );
|
2658 | |
} else {
|
2659 | |
// value is true since we know at this point it's type boolean and not false
|
2660 | |
// Set boolean attributes to the same name and set the DOM property
|
2661 | |
propName = jQuery.propFix[ name ] || name;
|
2662 | |
if ( propName in elem ) {
|
2663 | |
// Only set the IDL specifically if it already exists on the element
|
2664 | |
elem[ propName ] = true;
|
2665 | |
}
|
2666 | |
|
2667 | |
elem.setAttribute( name, name.toLowerCase() );
|
2668 | |
}
|
2669 | |
return name;
|
2670 | |
}
|
2671 | |
};
|
2672 | |
|
2673 | |
// IE6/7 do not support getting/setting some attributes with get/setAttribute
|
2674 | |
if ( !getSetAttribute ) {
|
2675 | |
|
2676 | |
fixSpecified = {
|
2677 | |
name: true,
|
2678 | |
id: true
|
2679 | |
};
|
2680 | |
|
2681 | |
// Use this for any attribute in IE6/7
|
2682 | |
// This fixes almost every IE6/7 issue
|
2683 | |
nodeHook = jQuery.valHooks.button = {
|
2684 | |
get: function( elem, name ) {
|
2685 | |
var ret;
|
2686 | |
ret = elem.getAttributeNode( name );
|
2687 | |
return ret && ( fixSpecified[ name ] ? ret.nodeValue !== "" : ret.specified ) ?
|
2688 | |
ret.nodeValue :
|
2689 | |
undefined;
|
2690 | |
},
|
2691 | |
set: function( elem, value, name ) {
|
2692 | |
// Set the existing or create a new attribute node
|
2693 | |
var ret = elem.getAttributeNode( name );
|
2694 | |
if ( !ret ) {
|
2695 | |
ret = document.createAttribute( name );
|
2696 | |
elem.setAttributeNode( ret );
|
2697 | |
}
|
2698 | |
return ( ret.nodeValue = value + "" );
|
2699 | |
}
|
2700 | |
};
|
2701 | |
|
2702 | |
// Apply the nodeHook to tabindex
|
2703 | |
jQuery.attrHooks.tabindex.set = nodeHook.set;
|
2704 | |
|
2705 | |
// Set width and height to auto instead of 0 on empty string( Bug #8150 )
|
2706 | |
// This is for removals
|
2707 | |
jQuery.each([ "width", "height" ], function( i, name ) {
|
2708 | |
jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
|
2709 | |
set: function( elem, value ) {
|
2710 | |
if ( value === "" ) {
|
2711 | |
elem.setAttribute( name, "auto" );
|
2712 | |
return value;
|
2713 | |
}
|
2714 | |
}
|
2715 | |
});
|
2716 | |
});
|
2717 | |
|
2718 | |
// Set contenteditable to false on removals(#10429)
|
2719 | |
// Setting to empty string throws an error as an invalid value
|
2720 | |
jQuery.attrHooks.contenteditable = {
|
2721 | |
get: nodeHook.get,
|
2722 | |
set: function( elem, value, name ) {
|
2723 | |
if ( value === "" ) {
|
2724 | |
value = "false";
|
2725 | |
}
|
2726 | |
nodeHook.set( elem, value, name );
|
2727 | |
}
|
2728 | |
};
|
2729 | |
}
|
2730 | |
|
2731 | |
|
2732 | |
// Some attributes require a special call on IE
|
2733 | |
if ( !jQuery.support.hrefNormalized ) {
|
2734 | |
jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
|
2735 | |
jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
|
2736 | |
get: function( elem ) {
|
2737 | |
var ret = elem.getAttribute( name, 2 );
|
2738 | |
return ret === null ? undefined : ret;
|
2739 | |
}
|
2740 | |
});
|
2741 | |
});
|
2742 | |
}
|
2743 | |
|
2744 | |
if ( !jQuery.support.style ) {
|
2745 | |
jQuery.attrHooks.style = {
|
2746 | |
get: function( elem ) {
|
2747 | |
// Return undefined in the case of empty string
|
2748 | |
// Normalize to lowercase since IE uppercases css property names
|
2749 | |
return elem.style.cssText.toLowerCase() || undefined;
|
2750 | |
},
|
2751 | |
set: function( elem, value ) {
|
2752 | |
return ( elem.style.cssText = "" + value );
|
2753 | |
}
|
2754 | |
};
|
2755 | |
}
|
2756 | |
|
2757 | |
// Safari mis-reports the default selected property of an option
|
2758 | |
// Accessing the parent's selectedIndex property fixes it
|
2759 | |
if ( !jQuery.support.optSelected ) {
|
2760 | |
jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
|
2761 | |
get: function( elem ) {
|
2762 | |
var parent = elem.parentNode;
|
2763 | |
|
2764 | |
if ( parent ) {
|
2765 | |
parent.selectedIndex;
|
2766 | |
|
2767 | |
// Make sure that it also works with optgroups, see #5701
|
2768 | |
if ( parent.parentNode ) {
|
2769 | |
parent.parentNode.selectedIndex;
|
2770 | |
}
|
2771 | |
}
|
2772 | |
return null;
|
2773 | |
}
|
2774 | |
});
|
2775 | |
}
|
2776 | |
|
2777 | |
// IE6/7 call enctype encoding
|
2778 | |
if ( !jQuery.support.enctype ) {
|
2779 | |
jQuery.propFix.enctype = "encoding";
|
2780 | |
}
|
2781 | |
|
2782 | |
// Radios and checkboxes getter/setter
|
2783 | |
if ( !jQuery.support.checkOn ) {
|
2784 | |
jQuery.each([ "radio", "checkbox" ], function() {
|
2785 | |
jQuery.valHooks[ this ] = {
|
2786 | |
get: function( elem ) {
|
2787 | |
// Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
|
2788 | |
return elem.getAttribute("value") === null ? "on" : elem.value;
|
2789 | |
}
|
2790 | |
};
|
2791 | |
});
|
2792 | |
}
|
2793 | |
jQuery.each([ "radio", "checkbox" ], function() {
|
2794 | |
jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
|
2795 | |
set: function( elem, value ) {
|
2796 | |
if ( jQuery.isArray( value ) ) {
|
2797 | |
return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
|
2798 | |
}
|
2799 | |
}
|
2800 | |
});
|
2801 | |
});
|
2802 | |
|
2803 | |
|
2804 | |
|
2805 | |
|
2806 | |
var rformElems = /^(?:textarea|input|select)$/i,
|
2807 | |
rtypenamespace = /^([^\.]*)?(?:\.(.+))?$/,
|
2808 | |
rhoverHack = /\bhover(\.\S+)?\b/,
|
2809 | |
rkeyEvent = /^key/,
|
2810 | |
rmouseEvent = /^(?:mouse|contextmenu)|click/,
|
2811 | |
rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
|
2812 | |
rquickIs = /^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,
|
2813 | |
quickParse = function( selector ) {
|
2814 | |
var quick = rquickIs.exec( selector );
|
2815 | |
if ( quick ) {
|
2816 | |
// 0 1 2 3
|
2817 | |
// [ _, tag, id, class ]
|
2818 | |
quick[1] = ( quick[1] || "" ).toLowerCase();
|
2819 | |
quick[3] = quick[3] && new RegExp( "(?:^|\\s)" + quick[3] + "(?:\\s|$)" );
|
2820 | |
}
|
2821 | |
return quick;
|
2822 | |
},
|
2823 | |
quickIs = function( elem, m ) {
|
2824 | |
var attrs = elem.attributes || {};
|
2825 | |
return (
|
2826 | |
(!m[1] || elem.nodeName.toLowerCase() === m[1]) &&
|
2827 | |
(!m[2] || (attrs.id || {}).value === m[2]) &&
|
2828 | |
(!m[3] || m[3].test( (attrs[ "class" ] || {}).value ))
|
2829 | |
);
|
2830 | |
},
|
2831 | |
hoverHack = function( events ) {
|
2832 | |
return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
|
2833 | |
};
|
2834 | |
|
2835 | |
/*
|
2836 | |
* Helper functions for managing events -- not part of the public interface.
|
2837 | |
* Props to Dean Edwards' addEvent library for many of the ideas.
|
2838 | |
*/
|
2839 | |
jQuery.event = {
|
2840 | |
|
2841 | |
add: function( elem, types, handler, data, selector ) {
|
2842 | |
|
2843 | |
var elemData, eventHandle, events,
|
2844 | |
t, tns, type, namespaces, handleObj,
|
2845 | |
handleObjIn, quick, handlers, special;
|
2846 | |
|
2847 | |
// Don't attach events to noData or text/comment nodes (allow plain objects tho)
|
2848 | |
if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) {
|
2849 | |
return;
|
2850 | |
}
|
2851 | |
|
2852 | |
// Caller can pass in an object of custom data in lieu of the handler
|
2853 | |
if ( handler.handler ) {
|
2854 | |
handleObjIn = handler;
|
2855 | |
handler = handleObjIn.handler;
|
2856 | |
}
|
2857 | |
|
2858 | |
// Make sure that the handler has a unique ID, used to find/remove it later
|
2859 | |
if ( !handler.guid ) {
|
2860 | |
handler.guid = jQuery.guid++;
|
2861 | |
}
|
2862 | |
|
2863 | |
// Init the element's event structure and main handler, if this is the first
|
2864 | |
events = elemData.events;
|
2865 | |
if ( !events ) {
|
2866 | |
elemData.events = events = {};
|
2867 | |
}
|
2868 | |
eventHandle = elemData.handle;
|
2869 | |
if ( !eventHandle ) {
|
2870 | |
elemData.handle = eventHandle = function( e ) {
|
2871 | |
// Discard the second event of a jQuery.event.trigger() and
|
2872 | |
// when an event is called after a page has unloaded
|
2873 | |
return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
|
2874 | |
jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
|
2875 | |
undefined;
|
2876 | |
};
|
2877 | |
// Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
|
2878 | |
eventHandle.elem = elem;
|
2879 | |
}
|
2880 | |
|
2881 | |
// Handle multiple events separated by a space
|
2882 | |
// jQuery(...).bind("mouseover mouseout", fn);
|
2883 | |
types = jQuery.trim( hoverHack(types) ).split( " " );
|
2884 | |
for ( t = 0; t < types.length; t++ ) {
|
2885 | |
|
2886 | |
tns = rtypenamespace.exec( types[t] ) || [];
|
2887 | |
type = tns[1];
|
2888 | |
namespaces = ( tns[2] || "" ).split( "." ).sort();
|
2889 | |
|
2890 | |
// If event changes its type, use the special event handlers for the changed type
|
2891 | |
special = jQuery.event.special[ type ] || {};
|
2892 | |
|
2893 | |
// If selector defined, determine special event api type, otherwise given type
|
2894 | |
type = ( selector ? special.delegateType : special.bindType ) || type;
|
2895 | |
|
2896 | |
// Update special based on newly reset type
|
2897 | |
special = jQuery.event.special[ type ] || {};
|
2898 | |
|
2899 | |
// handleObj is passed to all event handlers
|
2900 | |
handleObj = jQuery.extend({
|
2901 | |
type: type,
|
2902 | |
origType: tns[1],
|
2903 | |
data: data,
|
2904 | |
handler: handler,
|
2905 | |
guid: handler.guid,
|
2906 | |
selector: selector,
|
2907 | |
quick: quickParse( selector ),
|
2908 | |
namespace: namespaces.join(".")
|
2909 | |
}, handleObjIn );
|
2910 | |
|
2911 | |
// Init the event handler queue if we're the first
|
2912 | |
handlers = events[ type ];
|
2913 | |
if ( !handlers ) {
|
2914 | |
handlers = events[ type ] = [];
|
2915 | |
handlers.delegateCount = 0;
|
2916 | |
|
2917 | |
// Only use addEventListener/attachEvent if the special events handler returns false
|
2918 | |
if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
|
2919 | |
// Bind the global event handler to the element
|
2920 | |
if ( elem.addEventListener ) {
|
2921 | |
elem.addEventListener( type, eventHandle, false );
|
2922 | |
|
2923 | |
} else if ( elem.attachEvent ) {
|
2924 | |
elem.attachEvent( "on" + type, eventHandle );
|
2925 | |
}
|
2926 | |
}
|
2927 | |
}
|
2928 | |
|
2929 | |
if ( special.add ) {
|
2930 | |
special.add.call( elem, handleObj );
|
2931 | |
|
2932 | |
if ( !handleObj.handler.guid ) {
|
2933 | |
handleObj.handler.guid = handler.guid;
|
2934 | |
}
|
2935 | |
}
|
2936 | |
|
2937 | |
// Add to the element's handler list, delegates in front
|
2938 | |
if ( selector ) {
|
2939 | |
handlers.splice( handlers.delegateCount++, 0, handleObj );
|
2940 | |
} else {
|
2941 | |
handlers.push( handleObj );
|
2942 | |
}
|
2943 | |
|
2944 | |
// Keep track of which events have ever been used, for event optimization
|
2945 | |
jQuery.event.global[ type ] = true;
|
2946 | |
}
|
2947 | |
|
2948 | |
// Nullify elem to prevent memory leaks in IE
|
2949 | |
elem = null;
|
2950 | |
},
|
2951 | |
|
2952 | |
global: {},
|
2953 | |
|
2954 | |
// Detach an event or set of events from an element
|
2955 | |
remove: function( elem, types, handler, selector, mappedTypes ) {
|
2956 | |
|
2957 | |
var elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
|
2958 | |
t, tns, type, origType, namespaces, origCount,
|
2959 | |
j, events, special, handle, eventType, handleObj;
|
2960 | |
|
2961 | |
if ( !elemData || !(events = elemData.events) ) {
|
2962 | |
return;
|
2963 | |
}
|
2964 | |
|
2965 | |
// Once for each type.namespace in types; type may be omitted
|
2966 | |
types = jQuery.trim( hoverHack( types || "" ) ).split(" ");
|
2967 | |
for ( t = 0; t < types.length; t++ ) {
|
2968 | |
tns = rtypenamespace.exec( types[t] ) || [];
|
2969 | |
type = origType = tns[1];
|
2970 | |
namespaces = tns[2];
|
2971 | |
|
2972 | |
// Unbind all events (on this namespace, if provided) for the element
|
2973 | |
if ( !type ) {
|
2974 | |
for ( type in events ) {
|
2975 | |
jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
|
2976 | |
}
|
2977 | |
continue;
|
2978 | |
}
|
2979 | |
|
2980 | |
special = jQuery.event.special[ type ] || {};
|
2981 | |
type = ( selector? special.delegateType : special.bindType ) || type;
|
2982 | |
eventType = events[ type ] || [];
|
2983 | |
origCount = eventType.length;
|
2984 | |
namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)") : null;
|
2985 | |
|
2986 | |
// Remove matching events
|
2987 | |
for ( j = 0; j < eventType.length; j++ ) {
|
2988 | |
handleObj = eventType[ j ];
|
2989 | |
|
2990 | |
if ( ( mappedTypes || origType === handleObj.origType ) &&
|
2991 | |
( !handler || handler.guid === handleObj.guid ) &&
|
2992 | |
( !namespaces || namespaces.test( handleObj.namespace ) ) &&
|
2993 | |
( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
|
2994 | |
eventType.splice( j--, 1 );
|
2995 | |
|
2996 | |
if ( handleObj.selector ) {
|
2997 | |
eventType.delegateCount--;
|
2998 | |
}
|
2999 | |
if ( special.remove ) {
|
3000 | |
special.remove.call( elem, handleObj );
|
3001 | |
}
|
3002 | |
}
|
3003 | |
}
|
3004 | |
|
3005 | |
// Remove generic event handler if we removed something and no more handlers exist
|
3006 | |
// (avoids potential for endless recursion during removal of special event handlers)
|
3007 | |
if ( eventType.length === 0 && origCount !== eventType.length ) {
|
3008 | |
if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
|
3009 | |
jQuery.removeEvent( elem, type, elemData.handle );
|
3010 | |
}
|
3011 | |
|
3012 | |
delete events[ type ];
|
3013 | |
}
|
3014 | |
}
|
3015 | |
|
3016 | |
// Remove the expando if it's no longer used
|
3017 | |
if ( jQuery.isEmptyObject( events ) ) {
|
3018 | |
handle = elemData.handle;
|
3019 | |
if ( handle ) {
|
3020 | |
handle.elem = null;
|
3021 | |
}
|
3022 | |
|
3023 | |
// removeData also checks for emptiness and clears the expando if empty
|
3024 | |
// so use it instead of delete
|
3025 | |
jQuery.removeData( elem, [ "events", "handle" ], true );
|
3026 | |
}
|
3027 | |
},
|
3028 | |
|
3029 | |
// Events that are safe to short-circuit if no handlers are attached.
|
3030 | |
// Native DOM events should not be added, they may have inline handlers.
|
3031 | |
customEvent: {
|
3032 | |
"getData": true,
|
3033 | |
"setData": true,
|
3034 | |
"changeData": true
|
3035 | |
},
|
3036 | |
|
3037 | |
trigger: function( event, data, elem, onlyHandlers ) {
|
3038 | |
// Don't do events on text and comment nodes
|
3039 | |
if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) {
|
3040 | |
return;
|
3041 | |
}
|
3042 | |
|
3043 | |
// Event object or event type
|
3044 | |
var type = event.type || event,
|
3045 | |
namespaces = [],
|
3046 | |
cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType;
|
3047 | |
|
3048 | |
// focus/blur morphs to focusin/out; ensure we're not firing them right now
|
3049 | |
if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
|
3050 | |
return;
|
3051 | |
}
|
3052 | |
|
3053 | |
if ( type.indexOf( "!" ) >= 0 ) {
|
3054 | |
// Exclusive events trigger only for the exact event (no namespaces)
|
3055 | |
type = type.slice(0, -1);
|
3056 | |
exclusive = true;
|
3057 | |
}
|
3058 | |
|
3059 | |
if ( type.indexOf( "." ) >= 0 ) {
|
3060 | |
// Namespaced trigger; create a regexp to match event type in handle()
|
3061 | |
namespaces = type.split(".");
|
3062 | |
type = namespaces.shift();
|
3063 | |
namespaces.sort();
|
3064 | |
}
|
3065 | |
|
3066 | |
if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) {
|
3067 | |
// No jQuery handlers for this event type, and it can't have inline handlers
|
3068 | |
return;
|
3069 | |
}
|
3070 | |
|
3071 | |
// Caller can pass in an Event, Object, or just an event type string
|
3072 | |
event = typeof event === "object" ?
|
3073 | |
// jQuery.Event object
|
3074 | |
event[ jQuery.expando ] ? event :
|
3075 | |
// Object literal
|
3076 | |
new jQuery.Event( type, event ) :
|
3077 | |
// Just the event type (string)
|
3078 | |
new jQuery.Event( type );
|
3079 | |
|
3080 | |
event.type = type;
|
3081 | |
event.isTrigger = true;
|
3082 | |
event.exclusive = exclusive;
|
3083 | |
event.namespace = namespaces.join( "." );
|
3084 | |
event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") : null;
|
3085 | |
ontype = type.indexOf( ":" ) < 0 ? "on" + type : "";
|
3086 | |
|
3087 | |
// Handle a global trigger
|
3088 | |
if ( !elem ) {
|
3089 | |
|
3090 | |
// TODO: Stop taunting the data cache; remove global events and always attach to document
|
3091 | |
cache = jQuery.cache;
|
3092 | |
for ( i in cache ) {
|
3093 | |
if ( cache[ i ].events && cache[ i ].events[ type ] ) {
|
3094 | |
jQuery.event.trigger( event, data, cache[ i ].handle.elem, true );
|
3095 | |
}
|
3096 | |
}
|
3097 | |
return;
|
3098 | |
}
|
3099 | |
|
3100 | |
// Clean up the event in case it is being reused
|
3101 | |
event.result = undefined;
|
3102 | |
if ( !event.target ) {
|
3103 | |
event.target = elem;
|
3104 | |
}
|
3105 | |
|
3106 | |
// Clone any incoming data and prepend the event, creating the handler arg list
|
3107 | |
data = data != null ? jQuery.makeArray( data ) : [];
|
3108 | |
data.unshift( event );
|
3109 | |
|
3110 | |
// Allow special events to draw outside the lines
|
3111 | |
special = jQuery.event.special[ type ] || {};
|
3112 | |
if ( special.trigger && special.trigger.apply( elem, data ) === false ) {
|
3113 | |
return;
|
3114 | |
}
|
3115 | |
|
3116 | |
// Determine event propagation path in advance, per W3C events spec (#9951)
|
3117 | |
// Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
|
3118 | |
eventPath = [[ elem, special.bindType || type ]];
|
3119 | |
if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
|
3120 | |
|
3121 | |
bubbleType = special.delegateType || type;
|
3122 | |
cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode;
|
3123 | |
old = null;
|
3124 | |
for ( ; cur; cur = cur.parentNode ) {
|
3125 | |
eventPath.push([ cur, bubbleType ]);
|
3126 | |
old = cur;
|
3127 | |
}
|
3128 | |
|
3129 | |
// Only add window if we got to document (e.g., not plain obj or detached DOM)
|
3130 | |
if ( old && old === elem.ownerDocument ) {
|
3131 | |
eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]);
|
3132 | |
}
|
3133 | |
}
|
3134 | |
|
3135 | |
// Fire handlers on the event path
|
3136 | |
for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) {
|
3137 | |
|
3138 | |
cur = eventPath[i][0];
|
3139 | |
event.type = eventPath[i][1];
|
3140 | |
|
3141 | |
handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
|
3142 | |
if ( handle ) {
|
3143 | |
handle.apply( cur, data );
|
3144 | |
}
|
3145 | |
// Note that this is a bare JS function and not a jQuery handler
|
3146 | |
handle = ontype && cur[ ontype ];
|
3147 | |
if ( handle && jQuery.acceptData( cur ) && handle.apply( cur, data ) === false ) {
|
3148 | |
event.preventDefault();
|
3149 | |
}
|
3150 | |
}
|
3151 | |
event.type = type;
|
3152 | |
|
3153 | |
// If nobody prevented the default action, do it now
|
3154 | |
if ( !onlyHandlers && !event.isDefaultPrevented() ) {
|
3155 | |
|
3156 | |
if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) &&
|
3157 | |
!(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) {
|
3158 | |
|
3159 | |
// Call a native DOM method on the target with the same name name as the event.
|
3160 | |
// Can't use an .isFunction() check here because IE6/7 fails that test.
|
3161 | |
// Don't do default actions on window, that's where global variables be (#6170)
|
3162 | |
// IE<9 dies on focus/blur to hidden element (#1486)
|
3163 | |
if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) {
|
3164 | |
|
3165 | |
// Don't re-trigger an onFOO event when we call its FOO() method
|
3166 | |
old = elem[ ontype ];
|
3167 | |
|
3168 | |
if ( old ) {
|
3169 | |
elem[ ontype ] = null;
|
3170 | |
}
|
3171 | |
|
3172 | |
// Prevent re-triggering of the same event, since we already bubbled it above
|
3173 | |
jQuery.event.triggered = type;
|
3174 | |
elem[ type ]();
|
3175 | |
jQuery.event.triggered = undefined;
|
3176 | |
|
3177 | |
if ( old ) {
|
3178 | |
elem[ ontype ] = old;
|
3179 | |
}
|
3180 | |
}
|
3181 | |
}
|
3182 | |
}
|
3183 | |
|
3184 | |
return event.result;
|
3185 | |
},
|
3186 | |
|
3187 | |
dispatch: function( event ) {
|
3188 | |
|
3189 | |
// Make a writable jQuery.Event from the native event object
|
3190 | |
event = jQuery.event.fix( event || window.event );
|
3191 | |
|
3192 | |
var handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []),
|
3193 | |
delegateCount = handlers.delegateCount,
|
3194 | |
args = [].slice.call( arguments, 0 ),
|
3195 | |
run_all = !event.exclusive && !event.namespace,
|
3196 | |
handlerQueue = [],
|
3197 | |
i, j, cur, jqcur, ret, selMatch, matched, matches, handleObj, sel, related;
|
3198 | |
|
3199 | |
// Use the fix-ed jQuery.Event rather than the (read-only) native event
|
3200 | |
args[0] = event;
|
3201 | |
event.delegateTarget = this;
|
3202 | |
|
3203 | |
// Determine handlers that should run if there are delegated events
|
3204 | |
// Avoid disabled elements in IE (#6911) and non-left-click bubbling in Firefox (#3861)
|
3205 | |
if ( delegateCount && !event.target.disabled && !(event.button && event.type === "click") ) {
|
3206 | |
|
3207 | |
// Pregenerate a single jQuery object for reuse with .is()
|
3208 | |
jqcur = jQuery(this);
|
3209 | |
jqcur.context = this.ownerDocument || this;
|
3210 | |
|
3211 | |
for ( cur = event.target; cur != this; cur = cur.parentNode || this ) {
|
3212 | |
selMatch = {};
|
3213 | |
matches = [];
|
3214 | |
jqcur[0] = cur;
|
3215 | |
for ( i = 0; i < delegateCount; i++ ) {
|
3216 | |
handleObj = handlers[ i ];
|
3217 | |
sel = handleObj.selector;
|
3218 | |
|
3219 | |
if ( selMatch[ sel ] === undefined ) {
|
3220 | |
selMatch[ sel ] = (
|
3221 | |
handleObj.quick ? quickIs( cur, handleObj.quick ) : jqcur.is( sel )
|
3222 | |
);
|
3223 | |
}
|
3224 | |
if ( selMatch[ sel ] ) {
|
3225 | |
matches.push( handleObj );
|
3226 | |
}
|
3227 | |
}
|
3228 | |
if ( matches.length ) {
|
3229 | |
handlerQueue.push({ elem: cur, matches: matches });
|
3230 | |
}
|
3231 | |
}
|
3232 | |
}
|
3233 | |
|
3234 | |
// Add the remaining (directly-bound) handlers
|
3235 | |
if ( handlers.length > delegateCount ) {
|
3236 | |
handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) });
|
3237 | |
}
|
3238 | |
|
3239 | |
// Run delegates first; they may want to stop propagation beneath us
|
3240 | |
for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) {
|
3241 | |
matched = handlerQueue[ i ];
|
3242 | |
event.currentTarget = matched.elem;
|
3243 | |
|
3244 | |
for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) {
|
3245 | |
handleObj = matched.matches[ j ];
|
3246 | |
|
3247 | |
// Triggered event must either 1) be non-exclusive and have no namespace, or
|
3248 | |
// 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
|
3249 | |
if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) {
|
3250 | |
|
3251 | |
event.data = handleObj.data;
|
3252 | |
event.handleObj = handleObj;
|
3253 | |
|
3254 | |
ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
|
3255 | |
.apply( matched.elem, args );
|
3256 | |
|
3257 | |
if ( ret !== undefined ) {
|
3258 | |
event.result = ret;
|
3259 | |
if ( ret === false ) {
|
3260 | |
event.preventDefault();
|
3261 | |
event.stopPropagation();
|
3262 | |
}
|
3263 | |
}
|
3264 | |
}
|
3265 | |
}
|
3266 | |
}
|
3267 | |
|
3268 | |
return event.result;
|
3269 | |
},
|
3270 | |
|
3271 | |
// Includes some event props shared by KeyEvent and MouseEvent
|
3272 | |
// *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 ***
|
3273 | |
props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
|
3274 | |
|
3275 | |
fixHooks: {},
|
3276 | |
|
3277 | |
keyHooks: {
|
3278 | |
props: "char charCode key keyCode".split(" "),
|
3279 | |
filter: function( event, original ) {
|
3280 | |
|
3281 | |
// Add which for key events
|
3282 | |
if ( event.which == null ) {
|
3283 | |
event.which = original.charCode != null ? original.charCode : original.keyCode;
|
3284 | |
}
|
3285 | |
|
3286 | |
return event;
|
3287 | |
}
|
3288 | |
},
|
3289 | |
|
3290 | |
mouseHooks: {
|
3291 | |
props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
|
3292 | |
filter: function( event, original ) {
|
3293 | |
var eventDoc, doc, body,
|
3294 | |
button = original.button,
|
3295 | |
fromElement = original.fromElement;
|
3296 | |
|
3297 | |
// Calculate pageX/Y if missing and clientX/Y available
|
3298 | |
if ( event.pageX == null && original.clientX != null ) {
|
3299 | |
eventDoc = event.target.ownerDocument || document;
|
3300 | |
doc = eventDoc.documentElement;
|
3301 | |
body = eventDoc.body;
|
3302 | |
|
3303 | |
event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
|
3304 | |
event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
|
3305 | |
}
|
3306 | |
|
3307 | |
// Add relatedTarget, if necessary
|
3308 | |
if ( !event.relatedTarget && fromElement ) {
|
3309 | |
event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
|
3310 | |
}
|
3311 | |
|
3312 | |
// Add which for click: 1 === left; 2 === middle; 3 === right
|
3313 | |
// Note: button is not normalized, so don't use it
|
3314 | |
if ( !event.which && button !== undefined ) {
|
3315 | |
event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
|
3316 | |
}
|
3317 | |
|
3318 | |
return event;
|
3319 | |
}
|
3320 | |
},
|
3321 | |
|
3322 | |
fix: function( event ) {
|
3323 | |
if ( event[ jQuery.expando ] ) {
|
3324 | |
return event;
|
3325 | |
}
|
3326 | |
|
3327 | |
// Create a writable copy of the event object and normalize some properties
|
3328 | |
var i, prop,
|
3329 | |
originalEvent = event,
|
3330 | |
fixHook = jQuery.event.fixHooks[ event.type ] || {},
|
3331 | |
copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
|
3332 | |
|
3333 | |
event = jQuery.Event( originalEvent );
|
3334 | |
|
3335 | |
for ( i = copy.length; i; ) {
|
3336 | |
prop = copy[ --i ];
|
3337 | |
event[ prop ] = originalEvent[ prop ];
|
3338 | |
}
|
3339 | |
|
3340 | |
// Fix target property, if necessary (#1925, IE 6/7/8 & Safari2)
|
3341 | |
if ( !event.target ) {
|
3342 | |
event.target = originalEvent.srcElement || document;
|
3343 | |
}
|
3344 | |
|
3345 | |
// Target should not be a text node (#504, Safari)
|
3346 | |
if ( event.target.nodeType === 3 ) {
|
3347 | |
event.target = event.target.parentNode;
|
3348 | |
}
|
3349 | |
|
3350 | |
// For mouse/key events; add metaKey if it's not there (#3368, IE6/7/8)
|
3351 | |
if ( event.metaKey === undefined ) {
|
3352 | |
event.metaKey = event.ctrlKey;
|
3353 | |
}
|
3354 | |
|
3355 | |
return fixHook.filter? fixHook.filter( event, originalEvent ) : event;
|
3356 | |
},
|
3357 | |
|
3358 | |
special: {
|
3359 | |
ready: {
|
3360 | |
// Make sure the ready event is setup
|
3361 | |
setup: jQuery.bindReady
|
3362 | |
},
|
3363 | |
|
3364 | |
load: {
|
3365 | |
// Prevent triggered image.load events from bubbling to window.load
|
3366 | |
noBubble: true
|
3367 | |
},
|
3368 | |
|
3369 | |
focus: {
|
3370 | |
delegateType: "focusin"
|
3371 | |
},
|
3372 | |
blur: {
|
3373 | |
delegateType: "focusout"
|
3374 | |
},
|
3375 | |
|
3376 | |
beforeunload: {
|
3377 | |
setup: function( data, namespaces, eventHandle ) {
|
3378 | |
// We only want to do this special case on windows
|
3379 | |
if ( jQuery.isWindow( this ) ) {
|
3380 | |
this.onbeforeunload = eventHandle;
|
3381 | |
}
|
3382 | |
},
|
3383 | |
|
3384 | |
teardown: function( namespaces, eventHandle ) {
|
3385 | |
if ( this.onbeforeunload === eventHandle ) {
|
3386 | |
this.onbeforeunload = null;
|
3387 | |
}
|
3388 | |
}
|
3389 | |
}
|
3390 | |
},
|
3391 | |
|
3392 | |
simulate: function( type, elem, event, bubble ) {
|
3393 | |
// Piggyback on a donor event to simulate a different one.
|
3394 | |
// Fake originalEvent to avoid donor's stopPropagation, but if the
|
3395 | |
// simulated event prevents default then we do the same on the donor.
|
3396 | |
var e = jQuery.extend(
|
3397 | |
new jQuery.Event(),
|
3398 | |
event,
|
3399 | |
{ type: type,
|
3400 | |
isSimulated: true,
|
3401 | |
originalEvent: {}
|
3402 | |
}
|
3403 | |
);
|
3404 | |
if ( bubble ) {
|
3405 | |
jQuery.event.trigger( e, null, elem );
|
3406 | |
} else {
|
3407 | |
jQuery.event.dispatch.call( elem, e );
|
3408 | |
}
|
3409 | |
if ( e.isDefaultPrevented() ) {
|
3410 | |
event.preventDefault();
|
3411 | |
}
|
3412 | |
}
|
3413 | |
};
|
3414 | |
|
3415 | |
// Some plugins are using, but it's undocumented/deprecated and will be removed.
|
3416 | |
// The 1.7 special event interface should provide all the hooks needed now.
|
3417 | |
jQuery.event.handle = jQuery.event.dispatch;
|
3418 | |
|
3419 | |
jQuery.removeEvent = document.removeEventListener ?
|
3420 | |
function( elem, type, handle ) {
|
3421 | |
if ( elem.removeEventListener ) {
|
3422 | |
elem.removeEventListener( type, handle, false );
|
3423 | |
}
|
3424 | |
} :
|
3425 | |
function( elem, type, handle ) {
|
3426 | |
if ( elem.detachEvent ) {
|
3427 | |
elem.detachEvent( "on" + type, handle );
|
3428 | |
}
|
3429 | |
};
|
3430 | |
|
3431 | |
jQuery.Event = function( src, props ) {
|
3432 | |
// Allow instantiation without the 'new' keyword
|
3433 | |
if ( !(this instanceof jQuery.Event) ) {
|
3434 | |
return new jQuery.Event( src, props );
|
3435 | |
}
|
3436 | |
|
3437 | |
// Event object
|
3438 | |
if ( src && src.type ) {
|
3439 | |
this.originalEvent = src;
|
3440 | |
this.type = src.type;
|
3441 | |
|
3442 | |
// Events bubbling up the document may have been marked as prevented
|
3443 | |
// by a handler lower down the tree; reflect the correct value.
|
3444 | |
this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false ||
|
3445 | |
src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse;
|
3446 | |
|
3447 | |
// Event type
|
3448 | |
} else {
|
3449 | |
this.type = src;
|
3450 | |
}
|
3451 | |
|
3452 | |
// Put explicitly provided properties onto the event object
|
3453 | |
if ( props ) {
|
3454 | |
jQuery.extend( this, props );
|
3455 | |
}
|
3456 | |
|
3457 | |
// Create a timestamp if incoming event doesn't have one
|
3458 | |
this.timeStamp = src && src.timeStamp || jQuery.now();
|
3459 | |
|
3460 | |
// Mark it as fixed
|
3461 | |
this[ jQuery.expando ] = true;
|
3462 | |
};
|
3463 | |
|
3464 | |
function returnFalse() {
|
3465 | |
return false;
|
3466 | |
}
|
3467 | |
function returnTrue() {
|
3468 | |
return true;
|
3469 | |
}
|
3470 | |
|
3471 | |
// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
|
3472 | |
// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
|
3473 | |
jQuery.Event.prototype = {
|
3474 | |
preventDefault: function() {
|
3475 | |
this.isDefaultPrevented = returnTrue;
|
3476 | |
|
3477 | |
var e = this.originalEvent;
|
3478 | |
if ( !e ) {
|
3479 | |
return;
|
3480 | |
}
|
3481 | |
|
3482 | |
// if preventDefault exists run it on the original event
|
3483 | |
if ( e.preventDefault ) {
|
3484 | |
e.preventDefault();
|
3485 | |
|
3486 | |
// otherwise set the returnValue property of the original event to false (IE)
|
3487 | |
} else {
|
3488 | |
e.returnValue = false;
|
3489 | |
}
|
3490 | |
},
|
3491 | |
stopPropagation: function() {
|
3492 | |
this.isPropagationStopped = returnTrue;
|
3493 | |
|
3494 | |
var e = this.originalEvent;
|
3495 | |
if ( !e ) {
|
3496 | |
return;
|
3497 | |
}
|
3498 | |
// if stopPropagation exists run it on the original event
|
3499 | |
if ( e.stopPropagation ) {
|
3500 | |
e.stopPropagation();
|
3501 | |
}
|
3502 | |
// otherwise set the cancelBubble property of the original event to true (IE)
|
3503 | |
e.cancelBubble = true;
|
3504 | |
},
|
3505 | |
stopImmediatePropagation: function() {
|
3506 | |
this.isImmediatePropagationStopped = returnTrue;
|
3507 | |
this.stopPropagation();
|
3508 | |
},
|
3509 | |
isDefaultPrevented: returnFalse,
|
3510 | |
isPropagationStopped: returnFalse,
|
3511 | |
isImmediatePropagationStopped: returnFalse
|
3512 | |
};
|
3513 | |
|
3514 | |
// Create mouseenter/leave events using mouseover/out and event-time checks
|
3515 | |
jQuery.each({
|
3516 | |
mouseenter: "mouseover",
|
3517 | |
mouseleave: "mouseout"
|
3518 | |
}, function( orig, fix ) {
|
3519 | |
jQuery.event.special[ orig ] = {
|
3520 | |
delegateType: fix,
|
3521 | |
bindType: fix,
|
3522 | |
|
3523 | |
handle: function( event ) {
|
3524 | |
var target = this,
|
3525 | |
related = event.relatedTarget,
|
3526 | |
handleObj = event.handleObj,
|
3527 | |
selector = handleObj.selector,
|
3528 | |
ret;
|
3529 | |
|
3530 | |
// For mousenter/leave call the handler if related is outside the target.
|
3531 | |
// NB: No relatedTarget if the mouse left/entered the browser window
|
3532 | |
if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
|
3533 | |
event.type = handleObj.origType;
|
3534 | |
ret = handleObj.handler.apply( this, arguments );
|
3535 | |
event.type = fix;
|
3536 | |
}
|
3537 | |
return ret;
|
3538 | |
}
|
3539 | |
};
|
3540 | |
});
|
3541 | |
|
3542 | |
// IE submit delegation
|
3543 | |
if ( !jQuery.support.submitBubbles ) {
|
3544 | |
|
3545 | |
jQuery.event.special.submit = {
|
3546 | |
setup: function() {
|
3547 | |
// Only need this for delegated form submit events
|
3548 | |
if ( jQuery.nodeName( this, "form" ) ) {
|
3549 | |
return false;
|
3550 | |
}
|
3551 | |
|
3552 | |
// Lazy-add a submit handler when a descendant form may potentially be submitted
|
3553 | |
jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
|
3554 | |
// Node name check avoids a VML-related crash in IE (#9807)
|
3555 | |
var elem = e.target,
|
3556 | |
form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
|
3557 | |
if ( form && !form._submit_attached ) {
|
3558 | |
jQuery.event.add( form, "submit._submit", function( event ) {
|
3559 | |
// If form was submitted by the user, bubble the event up the tree
|
3560 | |
if ( this.parentNode && !event.isTrigger ) {
|
3561 | |
jQuery.event.simulate( "submit", this.parentNode, event, true );
|
3562 | |
}
|
3563 | |
});
|
3564 | |
form._submit_attached = true;
|
3565 | |
}
|
3566 | |
});
|
3567 | |
// return undefined since we don't need an event listener
|
3568 | |
},
|
3569 | |
|
3570 | |
teardown: function() {
|
3571 | |
// Only need this for delegated form submit events
|
3572 | |
if ( jQuery.nodeName( this, "form" ) ) {
|
3573 | |
return false;
|
3574 | |
}
|
3575 | |
|
3576 | |
// Remove delegated handlers; cleanData eventually reaps submit handlers attached above
|
3577 | |
jQuery.event.remove( this, "._submit" );
|
3578 | |
}
|
3579 | |
};
|
3580 | |
}
|
3581 | |
|
3582 | |
// IE change delegation and checkbox/radio fix
|
3583 | |
if ( !jQuery.support.changeBubbles ) {
|
3584 | |
|
3585 | |
jQuery.event.special.change = {
|
3586 | |
|
3587 | |
setup: function() {
|
3588 | |
|
3589 | |
if ( rformElems.test( this.nodeName ) ) {
|
3590 | |
// IE doesn't fire change on a check/radio until blur; trigger it on click
|
3591 | |
// after a propertychange. Eat the blur-change in special.change.handle.
|
3592 | |
// This still fires onchange a second time for check/radio after blur.
|
3593 | |
if ( this.type === "checkbox" || this.type === "radio" ) {
|
3594 | |
jQuery.event.add( this, "propertychange._change", function( event ) {
|
3595 | |
if ( event.originalEvent.propertyName === "checked" ) {
|
3596 | |
this._just_changed = true;
|
3597 | |
}
|
3598 | |
});
|
3599 | |
jQuery.event.add( this, "click._change", function( event ) {
|
3600 | |
if ( this._just_changed && !event.isTrigger ) {
|
3601 | |
this._just_changed = false;
|
3602 | |
jQuery.event.simulate( "change", this, event, true );
|
3603 | |
}
|
3604 | |
});
|
3605 | |
}
|
3606 | |
return false;
|
3607 | |
}
|
3608 | |
// Delegated event; lazy-add a change handler on descendant inputs
|
3609 | |
jQuery.event.add( this, "beforeactivate._change", function( e ) {
|
3610 | |
var elem = e.target;
|
3611 | |
|
3612 | |
if ( rformElems.test( elem.nodeName ) && !elem._change_attached ) {
|
3613 | |
jQuery.event.add( elem, "change._change", function( event ) {
|
3614 | |
if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
|
3615 | |
jQuery.event.simulate( "change", this.parentNode, event, true );
|
3616 | |
}
|
3617 | |
});
|
3618 | |
elem._change_attached = true;
|
3619 | |
}
|
3620 | |
});
|
3621 | |
},
|
3622 | |
|
3623 | |
handle: function( event ) {
|
3624 | |
var elem = event.target;
|
3625 | |
|
3626 | |
// Swallow native change events from checkbox/radio, we already triggered them above
|
3627 | |
if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
|
3628 | |
return event.handleObj.handler.apply( this, arguments );
|
3629 | |
}
|
3630 | |
},
|
3631 | |
|
3632 | |
teardown: function() {
|
3633 | |
jQuery.event.remove( this, "._change" );
|
3634 | |
|
3635 | |
return rformElems.test( this.nodeName );
|
3636 | |
}
|
3637 | |
};
|
3638 | |
}
|
3639 | |
|
3640 | |
// Create "bubbling" focus and blur events
|
3641 | |
if ( !jQuery.support.focusinBubbles ) {
|
3642 | |
jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
|
3643 | |
|
3644 | |
// Attach a single capturing handler while someone wants focusin/focusout
|
3645 | |
var attaches = 0,
|
3646 | |
handler = function( event ) {
|
3647 | |
jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
|
3648 | |
};
|
3649 | |
|
3650 | |
jQuery.event.special[ fix ] = {
|
3651 | |
setup: function() {
|
3652 | |
if ( attaches++ === 0 ) {
|
3653 | |
document.addEventListener( orig, handler, true );
|
3654 | |
}
|
3655 | |
},
|
3656 | |
teardown: function() {
|
3657 | |
if ( --attaches === 0 ) {
|
3658 | |
document.removeEventListener( orig, handler, true );
|
3659 | |
}
|
3660 | |
}
|
3661 | |
};
|
3662 | |
});
|
3663 | |
}
|
3664 | |
|
3665 | |
jQuery.fn.extend({
|
3666 | |
|
3667 | |
on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
|
3668 | |
var origFn, type;
|
3669 | |
|
3670 | |
// Types can be a map of types/handlers
|
3671 | |
if ( typeof types === "object" ) {
|
3672 | |
// ( types-Object, selector, data )
|
3673 | |
if ( typeof selector !== "string" ) {
|
3674 | |
// ( types-Object, data )
|
3675 | |
data = selector;
|
3676 | |
selector = undefined;
|
3677 | |
}
|
3678 | |
for ( type in types ) {
|
3679 | |
this.on( type, selector, data, types[ type ], one );
|
3680 | |
}
|
3681 | |
return this;
|
3682 | |
}
|
3683 | |
|
3684 | |
if ( data == null && fn == null ) {
|
3685 | |
// ( types, fn )
|
3686 | |
fn = selector;
|
3687 | |
data = selector = undefined;
|
3688 | |
} else if ( fn == null ) {
|
3689 | |
if ( typeof selector === "string" ) {
|
3690 | |
// ( types, selector, fn )
|
3691 | |
fn = data;
|
3692 | |
data = undefined;
|
3693 | |
} else {
|
3694 | |
// ( types, data, fn )
|
3695 | |
fn = data;
|
3696 | |
data = selector;
|
3697 | |
selector = undefined;
|
3698 | |
}
|
3699 | |
}
|
3700 | |
if ( fn === false ) {
|
3701 | |
fn = returnFalse;
|
3702 | |
} else if ( !fn ) {
|
3703 | |
return this;
|
3704 | |
}
|
3705 | |
|
3706 | |
if ( one === 1 ) {
|
3707 | |
origFn = fn;
|
3708 | |
fn = function( event ) {
|
3709 | |
// Can use an empty set, since event contains the info
|
3710 | |
jQuery().off( event );
|
3711 | |
return origFn.apply( this, arguments );
|
3712 | |
};
|
3713 | |
// Use same guid so caller can remove using origFn
|
3714 | |
fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
|
3715 | |
}
|
3716 | |
return this.each( function() {
|
3717 | |
jQuery.event.add( this, types, fn, data, selector );
|
3718 | |
});
|
3719 | |
},
|
3720 | |
one: function( types, selector, data, fn ) {
|
3721 | |
return this.on.call( this, types, selector, data, fn, 1 );
|
3722 | |
},
|
3723 | |
off: function( types, selector, fn ) {
|
3724 | |
if ( types && types.preventDefault && types.handleObj ) {
|
3725 | |
// ( event ) dispatched jQuery.Event
|
3726 | |
var handleObj = types.handleObj;
|
3727 | |
jQuery( types.delegateTarget ).off(
|
3728 | |
handleObj.namespace? handleObj.type + "." + handleObj.namespace : handleObj.type,
|
3729 | |
handleObj.selector,
|
3730 | |
handleObj.handler
|
3731 | |
);
|
3732 | |
return this;
|
3733 | |
}
|
3734 | |
if ( typeof types === "object" ) {
|
3735 | |
// ( types-object [, selector] )
|
3736 | |
for ( var type in types ) {
|
3737 | |
this.off( type, selector, types[ type ] );
|
3738 | |
}
|
3739 | |
return this;
|
3740 | |
}
|
3741 | |
if ( selector === false || typeof selector === "function" ) {
|
3742 | |
// ( types [, fn] )
|
3743 | |
fn = selector;
|
3744 | |
selector = undefined;
|
3745 | |
}
|
3746 | |
if ( fn === false ) {
|
3747 | |
fn = returnFalse;
|
3748 | |
}
|
3749 | |
return this.each(function() {
|
3750 | |
jQuery.event.remove( this, types, fn, selector );
|
3751 | |
});
|
3752 | |
},
|
3753 | |
|
3754 | |
bind: function( types, data, fn ) {
|
3755 | |
return this.on( types, null, data, fn );
|
3756 | |
},
|
3757 | |
unbind: function( types, fn ) {
|
3758 | |
return this.off( types, null, fn );
|
3759 | |
},
|
3760 | |
|
3761 | |
live: function( types, data, fn ) {
|
3762 | |
jQuery( this.context ).on( types, this.selector, data, fn );
|
3763 | |
return this;
|
3764 | |
},
|
3765 | |
die: function( types, fn ) {
|
3766 | |
jQuery( this.context ).off( types, this.selector || "**", fn );
|
3767 | |
return this;
|
3768 | |
},
|
3769 | |
|
3770 | |
delegate: function( selector, types, data, fn ) {
|
3771 | |
return this.on( types, selector, data, fn );
|
3772 | |
},
|
3773 | |
undelegate: function( selector, types, fn ) {
|
3774 | |
// ( namespace ) or ( selector, types [, fn] )
|
3775 | |
return arguments.length == 1? this.off( selector, "**" ) : this.off( types, selector, fn );
|
3776 | |
},
|
3777 | |
|
3778 | |
trigger: function( type, data ) {
|
3779 | |
return this.each(function() {
|
3780 | |
jQuery.event.trigger( type, data, this );
|
3781 | |
});
|
3782 | |
},
|
3783 | |
triggerHandler: function( type, data ) {
|
3784 | |
if ( this[0] ) {
|
3785 | |
return jQuery.event.trigger( type, data, this[0], true );
|
3786 | |
}
|
3787 | |
},
|
3788 | |
|
3789 | |
toggle: function( fn ) {
|
3790 | |
// Save reference to arguments for access in closure
|
3791 | |
var args = arguments,
|
3792 | |
guid = fn.guid || jQuery.guid++,
|
3793 | |
i = 0,
|
3794 | |
toggler = function( event ) {
|
3795 | |
// Figure out which function to execute
|
3796 | |
var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
|
3797 | |
jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
|
3798 | |
|
3799 | |
// Make sure that clicks stop
|
3800 | |
event.preventDefault();
|
3801 | |
|
3802 | |
// and execute the function
|
3803 | |
return args[ lastToggle ].apply( this, arguments ) || false;
|
3804 | |
};
|
3805 | |
|
3806 | |
// link all the functions, so any of them can unbind this click handler
|
3807 | |
toggler.guid = guid;
|
3808 | |
while ( i < args.length ) {
|
3809 | |
args[ i++ ].guid = guid;
|
3810 | |
}
|
3811 | |
|
3812 | |
return this.click( toggler );
|
3813 | |
},
|
3814 | |
|
3815 | |
hover: function( fnOver, fnOut ) {
|
3816 | |
return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
|
3817 | |
}
|
3818 | |
});
|
3819 | |
|
3820 | |
jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
|
3821 | |
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
|
3822 | |
"change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
|
3823 | |
|
3824 | |
// Handle event binding
|
3825 | |
jQuery.fn[ name ] = function( data, fn ) {
|
3826 | |
if ( fn == null ) {
|
3827 | |
fn = data;
|
3828 | |
data = null;
|
3829 | |
}
|
3830 | |
|
3831 | |
return arguments.length > 0 ?
|
3832 | |
this.on( name, null, data, fn ) :
|
3833 | |
this.trigger( name );
|
3834 | |
};
|
3835 | |
|
3836 | |
if ( jQuery.attrFn ) {
|
3837 | |
jQuery.attrFn[ name ] = true;
|
3838 | |
}
|
3839 | |
|
3840 | |
if ( rkeyEvent.test( name ) ) {
|
3841 | |
jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks;
|
3842 | |
}
|
3843 | |
|
3844 | |
if ( rmouseEvent.test( name ) ) {
|
3845 | |
jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks;
|
3846 | |
}
|
3847 | |
});
|
3848 | |
|
3849 | |
|
3850 | |
|
3851 | |
/*!
|
3852 | |
* Sizzle CSS Selector Engine
|
3853 | |
* Copyright 2011, The Dojo Foundation
|
3854 | |
* Released under the MIT, BSD, and GPL Licenses.
|
3855 | |
* More information: http://sizzlejs.com/
|
3856 | |
*/
|
3857 | |
(function(){
|
3858 | |
|
3859 | |
var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
|
3860 | |
expando = "sizcache" + (Math.random() + '').replace('.', ''),
|
3861 | |
done = 0,
|
3862 | |
toString = Object.prototype.toString,
|
3863 | |
hasDuplicate = false,
|
3864 | |
baseHasDuplicate = true,
|
3865 | |
rBackslash = /\\/g,
|
3866 | |
rReturn = /\r\n/g,
|
3867 | |
rNonWord = /\W/;
|
3868 | |
|
3869 | |
// Here we check if the JavaScript engine is using some sort of
|
3870 | |
// optimization where it does not always call our comparision
|
3871 | |
// function. If that is the case, discard the hasDuplicate value.
|
3872 | |
// Thus far that includes Google Chrome.
|
3873 | |
[0, 0].sort(function() {
|
3874 | |
baseHasDuplicate = false;
|
3875 | |
return 0;
|
3876 | |
});
|
3877 | |
|
3878 | |
var Sizzle = function( selector, context, results, seed ) {
|
3879 | |
results = results || [];
|
3880 | |
context = context || document;
|
3881 | |
|
3882 | |
var origContext = context;
|
3883 | |
|
3884 | |
if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
|
3885 | |
return [];
|
3886 | |
}
|
3887 | |
|
3888 | |
if ( !selector || typeof selector !== "string" ) {
|
3889 | |
return results;
|
3890 | |
}
|
3891 | |
|
3892 | |
var m, set, checkSet, extra, ret, cur, pop, i,
|
3893 | |
prune = true,
|
3894 | |
contextXML = Sizzle.isXML( context ),
|
3895 | |
parts = [],
|
3896 | |
soFar = selector;
|
3897 | |
|
3898 | |
// Reset the position of the chunker regexp (start from head)
|
3899 | |
do {
|
3900 | |
chunker.exec( "" );
|
3901 | |
m = chunker.exec( soFar );
|
3902 | |
|
3903 | |
if ( m ) {
|
3904 | |
soFar = m[3];
|
3905 | |
|
3906 | |
parts.push( m[1] );
|
3907 | |
|
3908 | |
if ( m[2] ) {
|
3909 | |
extra = m[3];
|
3910 | |
break;
|
3911 | |
}
|
3912 | |
}
|
3913 | |
} while ( m );
|
3914 | |
|
3915 | |
if ( parts.length > 1 && origPOS.exec( selector ) ) {
|
3916 | |
|
3917 | |
if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
|
3918 | |
set = posProcess( parts[0] + parts[1], context, seed );
|
3919 | |
|
3920 | |
} else {
|
3921 | |
set = Expr.relative[ parts[0] ] ?
|
3922 | |
[ context ] :
|
3923 | |
Sizzle( parts.shift(), context );
|
3924 | |
|
3925 | |
while ( parts.length ) {
|
3926 | |
selector = parts.shift();
|
3927 | |
|
3928 | |
if ( Expr.relative[ selector ] ) {
|
3929 | |
selector += parts.shift();
|
3930 | |
}
|
3931 | |
|
3932 | |
set = posProcess( selector, set, seed );
|
3933 | |
}
|
3934 | |
}
|
3935 | |
|
3936 | |
} else {
|
3937 | |
// Take a shortcut and set the context if the root selector is an ID
|
3938 | |
// (but not if it'll be faster if the inner selector is an ID)
|
3939 | |
if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
|
3940 | |
Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
|
3941 | |
|
3942 | |
ret = Sizzle.find( parts.shift(), context, contextXML );
|
3943 | |
context = ret.expr ?
|
3944 | |
Sizzle.filter( ret.expr, ret.set )[0] :
|
3945 | |
ret.set[0];
|
3946 | |
}
|
3947 | |
|
3948 | |
if ( context ) {
|
3949 | |
ret = seed ?
|
3950 | |
{ expr: parts.pop(), set: makeArray(seed) } :
|
3951 | |
Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
|
3952 | |
|
3953 | |
set = ret.expr ?
|
3954 | |
Sizzle.filter( ret.expr, ret.set ) :
|
3955 | |
ret.set;
|
3956 | |
|
3957 | |
if ( parts.length > 0 ) {
|
3958 | |
checkSet = makeArray( set );
|
3959 | |
|
3960 | |
} else {
|
3961 | |
prune = false;
|
3962 | |
}
|
3963 | |
|
3964 | |
while ( parts.length ) {
|
3965 | |
cur = parts.pop();
|
3966 | |
pop = cur;
|
3967 | |
|
3968 | |
if ( !Expr.relative[ cur ] ) {
|
3969 | |
cur = "";
|
3970 | |
} else {
|
3971 | |
pop = parts.pop();
|
3972 | |
}
|
3973 | |
|
3974 | |
if ( pop == null ) {
|
3975 | |
pop = context;
|
3976 | |
}
|
3977 | |
|
3978 | |
Expr.relative[ cur ]( checkSet, pop, contextXML );
|
3979 | |
}
|
3980 | |
|
3981 | |
} else {
|
3982 | |
checkSet = parts = [];
|
3983 | |
}
|
3984 | |
}
|
3985 | |
|
3986 | |
if ( !checkSet ) {
|
3987 | |
checkSet = set;
|
3988 | |
}
|
3989 | |
|
3990 | |
if ( !checkSet ) {
|
3991 | |
Sizzle.error( cur || selector );
|
3992 | |
}
|
3993 | |
|
3994 | |
if ( toString.call(checkSet) === "[object Array]" ) {
|
3995 | |
if ( !prune ) {
|
3996 | |
results.push.apply( results, checkSet );
|
3997 | |
|
3998 | |
} else if ( context && context.nodeType === 1 ) {
|
3999 | |
for ( i = 0; checkSet[i] != null; i++ ) {
|
4000 | |
if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {
|
4001 | |
results.push( set[i] );
|
4002 | |
}
|
4003 | |
}
|
4004 | |
|
4005 | |
} else {
|
4006 | |
for ( i = 0; checkSet[i] != null; i++ ) {
|
4007 | |
if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
|
4008 | |
results.push( set[i] );
|
4009 | |
}
|
4010 | |
}
|
4011 | |
}
|
4012 | |
|
4013 | |
} else {
|
4014 | |
makeArray( checkSet, results );
|
4015 | |
}
|
4016 | |
|
4017 | |
if ( extra ) {
|
4018 | |
Sizzle( extra, origContext, results, seed );
|
4019 | |
Sizzle.uniqueSort( results );
|
4020 | |
}
|
4021 | |
|
4022 | |
return results;
|
4023 | |
};
|
4024 | |
|
4025 | |
Sizzle.uniqueSort = function( results ) {
|
4026 | |
if ( sortOrder ) {
|
4027 | |
hasDuplicate = baseHasDuplicate;
|
4028 | |
results.sort( sortOrder );
|
4029 | |
|
4030 | |
if ( hasDuplicate ) {
|
4031 | |
for ( var i = 1; i < results.length; i++ ) {
|
4032 | |
if ( results[i] === results[ i - 1 ] ) {
|
4033 | |
results.splice( i--, 1 );
|
4034 | |
}
|
4035 | |
}
|
4036 | |
}
|
4037 | |
}
|
4038 | |
|
4039 | |
return results;
|
4040 | |
};
|
4041 | |
|
4042 | |
Sizzle.matches = function( expr, set ) {
|
4043 | |
return Sizzle( expr, null, null, set );
|
4044 | |
};
|
4045 | |
|
4046 | |
Sizzle.matchesSelector = function( node, expr ) {
|
4047 | |
return Sizzle( expr, null, null, [node] ).length > 0;
|
4048 | |
};
|
4049 | |
|
4050 | |
Sizzle.find = function( expr, context, isXML ) {
|
4051 | |
var set, i, len, match, type, left;
|
4052 | |
|
4053 | |
if ( !expr ) {
|
4054 | |
return [];
|
4055 | |
}
|
4056 | |
|
4057 | |
for ( i = 0, len = Expr.order.length; i < len; i++ ) {
|
4058 | |
type = Expr.order[i];
|
4059 | |
|
4060 | |
if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
|
4061 | |
left = match[1];
|
4062 | |
match.splice( 1, 1 );
|
4063 | |
|
4064 | |
if ( left.substr( left.length - 1 ) !== "\\" ) {
|
4065 | |
match[1] = (match[1] || "").replace( rBackslash, "" );
|
4066 | |
set = Expr.find[ type ]( match, context, isXML );
|
4067 | |
|
4068 | |
if ( set != null ) {
|
4069 | |
expr = expr.replace( Expr.match[ type ], "" );
|
4070 | |
break;
|
4071 | |
}
|
4072 | |
}
|
4073 | |
}
|
4074 | |
}
|
4075 | |
|
4076 | |
if ( !set ) {
|
4077 | |
set = typeof context.getElementsByTagName !== "undefined" ?
|
4078 | |
context.getElementsByTagName( "*" ) :
|
4079 | |
[];
|
4080 | |
}
|
4081 | |
|
4082 | |
return { set: set, expr: expr };
|
4083 | |
};
|
4084 | |
|
4085 | |
Sizzle.filter = function( expr, set, inplace, not ) {
|
4086 | |
var match, anyFound,
|
4087 | |
type, found, item, filter, left,
|
4088 | |
i, pass,
|
4089 | |
old = expr,
|
4090 | |
result = [],
|
4091 | |
curLoop = set,
|
4092 | |
isXMLFilter = set && set[0] && Sizzle.isXML( set[0] );
|
4093 | |
|
4094 | |
while ( expr && set.length ) {
|
4095 | |
for ( type in Expr.filter ) {
|
4096 | |
if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
|
4097 | |
filter = Expr.filter[ type ];
|
4098 | |
left = match[1];
|
4099 | |
|
4100 | |
anyFound = false;
|
4101 | |
|
4102 | |
match.splice(1,1);
|
4103 | |
|
4104 | |
if ( left.substr( left.length - 1 ) === "\\" ) {
|
4105 | |
continue;
|
4106 | |
}
|
4107 | |
|
4108 | |
if ( curLoop === result ) {
|
4109 | |
result = [];
|
4110 | |
}
|
4111 | |
|
4112 | |
if ( Expr.preFilter[ type ] ) {
|
4113 | |
match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
|
4114 | |
|
4115 | |
if ( !match ) {
|
4116 | |
anyFound = found = true;
|
4117 | |
|
4118 | |
} else if ( match === true ) {
|
4119 | |
continue;
|
4120 | |
}
|
4121 | |
}
|
4122 | |
|
4123 | |
if ( match ) {
|
4124 | |
for ( i = 0; (item = curLoop[i]) != null; i++ ) {
|
4125 | |
if ( item ) {
|
4126 | |
found = filter( item, match, i, curLoop );
|
4127 | |
pass = not ^ found;
|
4128 | |
|
4129 | |
if ( inplace && found != null ) {
|
4130 | |
if ( pass ) {
|
4131 | |
anyFound = true;
|
4132 | |
|
4133 | |
} else {
|
4134 | |
curLoop[i] = false;
|
4135 | |
}
|
4136 | |
|
4137 | |
} else if ( pass ) {
|
4138 | |
result.push( item );
|
4139 | |
anyFound = true;
|
4140 | |
}
|
4141 | |
}
|
4142 | |
}
|
4143 | |
}
|
4144 | |
|
4145 | |
if ( found !== undefined ) {
|
4146 | |
if ( !inplace ) {
|
4147 | |
curLoop = result;
|
4148 | |
}
|
4149 | |
|
4150 | |
expr = expr.replace( Expr.match[ type ], "" );
|
4151 | |
|
4152 | |
if ( !anyFound ) {
|
4153 | |
return [];
|
4154 | |
}
|
4155 | |
|
4156 | |
break;
|
4157 | |
}
|
4158 | |
}
|
4159 | |
}
|
4160 | |
|
4161 | |
// Improper expression
|
4162 | |
if ( expr === old ) {
|
4163 | |
if ( anyFound == null ) {
|
4164 | |
Sizzle.error( expr );
|
4165 | |
|
4166 | |
} else {
|
4167 | |
break;
|
4168 | |
}
|
4169 | |
}
|
4170 | |
|
4171 | |
old = expr;
|
4172 | |
}
|
4173 | |
|
4174 | |
return curLoop;
|
4175 | |
};
|
4176 | |
|
4177 | |
Sizzle.error = function( msg ) {
|
4178 | |
throw new Error( "Syntax error, unrecognized expression: " + msg );
|
4179 | |
};
|
4180 | |
|
4181 | |
/**
|
4182 | |
* Utility function for retreiving the text value of an array of DOM nodes
|
4183 | |
* @param {Array|Element} elem
|
4184 | |
*/
|
4185 | |
var getText = Sizzle.getText = function( elem ) {
|
4186 | |
var i, node,
|
4187 | |
nodeType = elem.nodeType,
|
4188 | |
ret = "";
|
4189 | |
|
4190 | |
if ( nodeType ) {
|
4191 | |
if ( nodeType === 1 || nodeType === 9 ) {
|
4192 | |
// Use textContent || innerText for elements
|
4193 | |
if ( typeof elem.textContent === 'string' ) {
|
4194 | |
return elem.textContent;
|
4195 | |
} else if ( typeof elem.innerText === 'string' ) {
|
4196 | |
// Replace IE's carriage returns
|
4197 | |
return elem.innerText.replace( rReturn, '' );
|
4198 | |
} else {
|
4199 | |
// Traverse it's children
|
4200 | |
for ( elem = elem.firstChild; elem; elem = elem.nextSibling) {
|
4201 | |
ret += getText( elem );
|
4202 | |
}
|
4203 | |
}
|
4204 | |
} else if ( nodeType === 3 || nodeType === 4 ) {
|
4205 | |
return elem.nodeValue;
|
4206 | |
}
|
4207 | |
} else {
|
4208 | |
|
4209 | |
// If no nodeType, this is expected to be an array
|
4210 | |
for ( i = 0; (node = elem[i]); i++ ) {
|
4211 | |
// Do not traverse comment nodes
|
4212 | |
if ( node.nodeType !== 8 ) {
|
4213 | |
ret += getText( node );
|
4214 | |
}
|
4215 | |
}
|
4216 | |
}
|
4217 | |
return ret;
|
4218 | |
};
|
4219 | |
|
4220 | |
var Expr = Sizzle.selectors = {
|
4221 | |
order: [ "ID", "NAME", "TAG" ],
|
4222 | |
|
4223 | |
match: {
|
4224 | |
ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
|
4225 | |
CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
|
4226 | |
NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
|
4227 | |
ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,
|
4228 | |
TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
|
4229 | |
CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,
|
4230 | |
POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
|
4231 | |
PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
|
4232 | |
},
|
4233 | |
|
4234 | |
leftMatch: {},
|
4235 | |
|
4236 | |
attrMap: {
|
4237 | |
"class": "className",
|
4238 | |
"for": "htmlFor"
|
4239 | |
},
|
4240 | |
|
4241 | |
attrHandle: {
|
4242 | |
href: function( elem ) {
|
4243 | |
return elem.getAttribute( "href" );
|
4244 | |
},
|
4245 | |
type: function( elem ) {
|
4246 | |
return elem.getAttribute( "type" );
|
4247 | |
}
|
4248 | |
},
|
4249 | |
|
4250 | |
relative: {
|
4251 | |
"+": function(checkSet, part){
|
4252 | |
var isPartStr = typeof part === "string",
|
4253 | |
isTag = isPartStr && !rNonWord.test( part ),
|
4254 | |
isPartStrNotTag = isPartStr && !isTag;
|
4255 | |
|
4256 | |
if ( isTag ) {
|
4257 | |
part = part.toLowerCase();
|
4258 | |
}
|
4259 | |
|
4260 | |
for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
|
4261 | |
if ( (elem = checkSet[i]) ) {
|
4262 | |
while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
|
4263 | |
|
4264 | |
checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
|
4265 | |
elem || false :
|
4266 | |
elem === part;
|
4267 | |
}
|
4268 | |
}
|
4269 | |
|
4270 | |
if ( isPartStrNotTag ) {
|
4271 | |
Sizzle.filter( part, checkSet, true );
|
4272 | |
}
|
4273 | |
},
|
4274 | |
|
4275 | |
">": function( checkSet, part ) {
|
4276 | |
var elem,
|
4277 | |
isPartStr = typeof part === "string",
|
4278 | |
i = 0,
|
4279 | |
l = checkSet.length;
|
4280 | |
|
4281 | |
if ( isPartStr && !rNonWord.test( part ) ) {
|
4282 | |
part = part.toLowerCase();
|
4283 | |
|
4284 | |
for ( ; i < l; i++ ) {
|
4285 | |
elem = checkSet[i];
|
4286 | |
|
4287 | |
if ( elem ) {
|
4288 | |
var parent = elem.parentNode;
|
4289 | |
checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
|
4290 | |
}
|
4291 | |
}
|
4292 | |
|
4293 | |
} else {
|
4294 | |
for ( ; i < l; i++ ) {
|
4295 | |
elem = checkSet[i];
|
4296 | |
|
4297 | |
if ( elem ) {
|
4298 | |
checkSet[i] = isPartStr ?
|
4299 | |
elem.parentNode :
|
4300 | |
elem.parentNode === part;
|
4301 | |
}
|
4302 | |
}
|
4303 | |
|
4304 | |
if ( isPartStr ) {
|
4305 | |
Sizzle.filter( part, checkSet, true );
|
4306 | |
}
|
4307 | |
}
|
4308 | |
},
|
4309 | |
|
4310 | |
"": function(checkSet, part, isXML){
|
4311 | |
var nodeCheck,
|
4312 | |
doneName = done++,
|
4313 | |
checkFn = dirCheck;
|
4314 | |
|
4315 | |
if ( typeof part === "string" && !rNonWord.test( part ) ) {
|
4316 | |
part = part.toLowerCase();
|
4317 | |
nodeCheck = part;
|
4318 | |
checkFn = dirNodeCheck;
|
4319 | |
}
|
4320 | |
|
4321 | |
checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML );
|
4322 | |
},
|
4323 | |
|
4324 | |
"~": function( checkSet, part, isXML ) {
|
4325 | |
var nodeCheck,
|
4326 | |
doneName = done++,
|
4327 | |
checkFn = dirCheck;
|
4328 | |
|
4329 | |
if ( typeof part === "string" && !rNonWord.test( part ) ) {
|
4330 | |
part = part.toLowerCase();
|
4331 | |
nodeCheck = part;
|
4332 | |
checkFn = dirNodeCheck;
|
4333 | |
}
|
4334 | |
|
4335 | |
checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML );
|
4336 | |
}
|
4337 | |
},
|
4338 | |
|
4339 | |
find: {
|
4340 | |
ID: function( match, context, isXML ) {
|
4341 | |
if ( typeof context.getElementById !== "undefined" && !isXML ) {
|
4342 | |
var m = context.getElementById(match[1]);
|
4343 | |
// Check parentNode to catch when Blackberry 4.6 returns
|
4344 | |
// nodes that are no longer in the document #6963
|
4345 | |
return m && m.parentNode ? [m] : [];
|
4346 | |
}
|
4347 | |
},
|
4348 | |
|
4349 | |
NAME: function( match, context ) {
|
4350 | |
if ( typeof context.getElementsByName !== "undefined" ) {
|
4351 | |
var ret = [],
|
4352 | |
results = context.getElementsByName( match[1] );
|
4353 | |
|
4354 | |
for ( var i = 0, l = results.length; i < l; i++ ) {
|
4355 | |
if ( results[i].getAttribute("name") === match[1] ) {
|
4356 | |
ret.push( results[i] );
|
4357 | |
}
|
4358 | |
}
|
4359 | |
|
4360 | |
return ret.length === 0 ? null : ret;
|
4361 | |
}
|
4362 | |
},
|
4363 | |
|
4364 | |
TAG: function( match, context ) {
|
4365 | |
if ( typeof context.getElementsByTagName !== "undefined" ) {
|
4366 | |
return context.getElementsByTagName( match[1] );
|
4367 | |
}
|
4368 | |
}
|
4369 | |
},
|
4370 | |
preFilter: {
|
4371 | |
CLASS: function( match, curLoop, inplace, result, not, isXML ) {
|
4372 | |
match = " " + match[1].replace( rBackslash, "" ) + " ";
|
4373 | |
|
4374 | |
if ( isXML ) {
|
4375 | |
return match;
|
4376 | |
}
|
4377 | |
|
4378 | |
for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
|
4379 | |
if ( elem ) {
|
4380 | |
if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) {
|
4381 | |
if ( !inplace ) {
|
4382 | |
result.push( elem );
|
4383 | |
}
|
4384 | |
|
4385 | |
} else if ( inplace ) {
|
4386 | |
curLoop[i] = false;
|
4387 | |
}
|
4388 | |
}
|
4389 | |
}
|
4390 | |
|
4391 | |
return false;
|
4392 | |
},
|
4393 | |
|
4394 | |
ID: function( match ) {
|
4395 | |
return match[1].replace( rBackslash, "" );
|
4396 | |
},
|
4397 | |
|
4398 | |
TAG: function( match, curLoop ) {
|
4399 | |
return match[1].replace( rBackslash, "" ).toLowerCase();
|
4400 | |
},
|
4401 | |
|
4402 | |
CHILD: function( match ) {
|
4403 | |
if ( match[1] === "nth" ) {
|
4404 | |
if ( !match[2] ) {
|
4405 | |
Sizzle.error( match[0] );
|
4406 | |
}
|
4407 | |
|
4408 | |
match[2] = match[2].replace(/^\+|\s*/g, '');
|
4409 | |
|
4410 | |
// parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
|
4411 | |
var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec(
|
4412 | |
match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
|
4413 | |
!/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
|
4414 | |
|
4415 | |
// calculate the numbers (first)n+(last) including if they are negative
|
4416 | |
match[2] = (test[1] + (test[2] || 1)) - 0;
|
4417 | |
match[3] = test[3] - 0;
|
4418 | |
}
|
4419 | |
else if ( match[2] ) {
|
4420 | |
Sizzle.error( match[0] );
|
4421 | |
}
|
4422 | |
|
4423 | |
// TODO: Move to normal caching system
|
4424 | |
match[0] = done++;
|
4425 | |
|
4426 | |
return match;
|
4427 | |
},
|
4428 | |
|
4429 | |
ATTR: function( match, curLoop, inplace, result, not, isXML ) {
|
4430 | |
var name = match[1] = match[1].replace( rBackslash, "" );
|
4431 | |
|
4432 | |
if ( !isXML && Expr.attrMap[name] ) {
|
4433 | |
match[1] = Expr.attrMap[name];
|
4434 | |
}
|
4435 | |
|
4436 | |
// Handle if an un-quoted value was used
|
4437 | |
match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" );
|
4438 | |
|
4439 | |
if ( match[2] === "~=" ) {
|
4440 | |
match[4] = " " + match[4] + " ";
|
4441 | |
}
|
4442 | |
|
4443 | |
return match;
|
4444 | |
},
|
4445 | |
|
4446 | |
PSEUDO: function( match, curLoop, inplace, result, not ) {
|
4447 | |
if ( match[1] === "not" ) {
|
4448 | |
// If we're dealing with a complex expression, or a simple one
|
4449 | |
if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
|
4450 | |
match[3] = Sizzle(match[3], null, null, curLoop);
|
4451 | |
|
4452 | |
} else {
|
4453 | |
var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
|
4454 | |
|
4455 | |
if ( !inplace ) {
|
4456 | |
result.push.apply( result, ret );
|
4457 | |
}
|
4458 | |
|
4459 | |
return false;
|
4460 | |
}
|
4461 | |
|
4462 | |
} else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
|
4463 | |
return true;
|
4464 | |
}
|
4465 | |
|
4466 | |
return match;
|
4467 | |
},
|
4468 | |
|
4469 | |
POS: function( match ) {
|
4470 | |
match.unshift( true );
|
4471 | |
|
4472 | |
return match;
|
4473 | |
}
|
4474 | |
},
|
4475 | |
|
4476 | |
filters: {
|
4477 | |
enabled: function( elem ) {
|
4478 | |
return elem.disabled === false && elem.type !== "hidden";
|
4479 | |
},
|
4480 | |
|
4481 | |
disabled: function( elem ) {
|
4482 | |
return elem.disabled === true;
|
4483 | |
},
|
4484 | |
|
4485 | |
checked: function( elem ) {
|
4486 | |
return elem.checked === true;
|
4487 | |
},
|
4488 | |
|
4489 | |
selected: function( elem ) {
|
4490 | |
// Accessing this property makes selected-by-default
|
4491 | |
// options in Safari work properly
|
4492 | |
if ( elem.parentNode ) {
|
4493 | |
elem.parentNode.selectedIndex;
|
4494 | |
}
|
4495 | |
|
4496 | |
return elem.selected === true;
|
4497 | |
},
|
4498 | |
|
4499 | |
parent: function( elem ) {
|
4500 | |
return !!elem.firstChild;
|
4501 | |
},
|
4502 | |
|
4503 | |
empty: function( elem ) {
|
4504 | |
return !elem.firstChild;
|
4505 | |
},
|
4506 | |
|
4507 | |
has: function( elem, i, match ) {
|
4508 | |
return !!Sizzle( match[3], elem ).length;
|
4509 | |
},
|
4510 | |
|
4511 | |
header: function( elem ) {
|
4512 | |
return (/h\d/i).test( elem.nodeName );
|
4513 | |
},
|
4514 | |
|
4515 | |
text: function( elem ) {
|
4516 | |
var attr = elem.getAttribute( "type" ), type = elem.type;
|
4517 | |
// IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
|
4518 | |
// use getAttribute instead to test this case
|
4519 | |
return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null );
|
4520 | |
},
|
4521 | |
|
4522 | |
radio: function( elem ) {
|
4523 | |
return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type;
|
4524 | |
},
|
4525 | |
|
4526 | |
checkbox: function( elem ) {
|
4527 | |
return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type;
|
4528 | |
},
|
4529 | |
|
4530 | |
file: function( elem ) {
|
4531 | |
return elem.nodeName.toLowerCase() === "input" && "file" === elem.type;
|
4532 | |
},
|
4533 | |
|
4534 | |
password: function( elem ) {
|
4535 | |
return elem.nodeName.toLowerCase() === "input" && "password" === elem.type;
|
4536 | |
},
|
4537 | |
|
4538 | |
submit: function( elem ) {
|
4539 | |
var name = elem.nodeName.toLowerCase();
|
4540 | |
return (name === "input" || name === "button") && "submit" === elem.type;
|
4541 | |
},
|
4542 | |
|
4543 | |
image: function( elem ) {
|
4544 | |
return elem.nodeName.toLowerCase() === "input" && "image" === elem.type;
|
4545 | |
},
|
4546 | |
|
4547 | |
reset: function( elem ) {
|
4548 | |
var name = elem.nodeName.toLowerCase();
|
4549 | |
return (name === "input" || name === "button") && "reset" === elem.type;
|
4550 | |
},
|
4551 | |
|
4552 | |
button: function( elem ) {
|
4553 | |
var name = elem.nodeName.toLowerCase();
|
4554 | |
return name === "input" && "button" === elem.type || name === "button";
|
4555 | |
},
|
4556 | |
|
4557 | |
input: function( elem ) {
|
4558 | |
return (/input|select|textarea|button/i).test( elem.nodeName );
|
4559 | |
},
|
4560 | |
|
4561 | |
focus: function( elem ) {
|
4562 | |
return elem === elem.ownerDocument.activeElement;
|
4563 | |
}
|
4564 | |
},
|
4565 | |
setFilters: {
|
4566 | |
first: function( elem, i ) {
|
4567 | |
return i === 0;
|
4568 | |
},
|
4569 | |
|
4570 | |
last: function( elem, i, match, array ) {
|
4571 | |
return i === array.length - 1;
|
4572 | |
},
|
4573 | |
|
4574 | |
even: function( elem, i ) {
|
4575 | |
return i % 2 === 0;
|
4576 | |
},
|
4577 | |
|
4578 | |
odd: function( elem, i ) {
|
4579 | |
return i % 2 === 1;
|
4580 | |
},
|
4581 | |
|
4582 | |
lt: function( elem, i, match ) {
|
4583 | |
return i < match[3] - 0;
|
4584 | |
},
|
4585 | |
|
4586 | |
gt: function( elem, i, match ) {
|
4587 | |
return i > match[3] - 0;
|
4588 | |
},
|
4589 | |
|
4590 | |
nth: function( elem, i, match ) {
|
4591 | |
return match[3] - 0 === i;
|
4592 | |
},
|
4593 | |
|
4594 | |
eq: function( elem, i, match ) {
|
4595 | |
return match[3] - 0 === i;
|
4596 | |
}
|
4597 | |
},
|
4598 | |
filter: {
|
4599 | |
PSEUDO: function( elem, match, i, array ) {
|
4600 | |
var name = match[1],
|
4601 | |
filter = Expr.filters[ name ];
|
4602 | |
|
4603 | |
if ( filter ) {
|
4604 | |
return filter( elem, i, match, array );
|
4605 | |
|
4606 | |
} else if ( name === "contains" ) {
|
4607 | |
return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0;
|
4608 | |
|
4609 | |
} else if ( name === "not" ) {
|
4610 | |
var not = match[3];
|
4611 | |
|
4612 | |
for ( var j = 0, l = not.length; j < l; j++ ) {
|
4613 | |
if ( not[j] === elem ) {
|
4614 | |
return false;
|
4615 | |
}
|
4616 | |
}
|
4617 | |
|
4618 | |
return true;
|
4619 | |
|
4620 | |
} else {
|
4621 | |
Sizzle.error( name );
|
4622 | |
}
|
4623 | |
},
|
4624 | |
|
4625 | |
CHILD: function( elem, match ) {
|
4626 | |
var first, last,
|
4627 | |
doneName, parent, cache,
|
4628 | |
count, diff,
|
4629 | |
type = match[1],
|
4630 | |
node = elem;
|
4631 | |
|
4632 | |
switch ( type ) {
|
4633 | |
case "only":
|
4634 | |
case "first":
|
4635 | |
while ( (node = node.previousSibling) ) {
|
4636 | |
if ( node.nodeType === 1 ) {
|
4637 | |
return false;
|
4638 | |
}
|
4639 | |
}
|
4640 | |
|
4641 | |
if ( type === "first" ) {
|
4642 | |
return true;
|
4643 | |
}
|
4644 | |
|
4645 | |
node = elem;
|
4646 | |
|
4647 | |
case "last":
|
4648 | |
while ( (node = node.nextSibling) ) {
|
4649 | |
if ( node.nodeType === 1 ) {
|
4650 | |
return false;
|
4651 | |
}
|
4652 | |
}
|
4653 | |
|
4654 | |
return true;
|
4655 | |
|
4656 | |
case "nth":
|
4657 | |
first = match[2];
|
4658 | |
last = match[3];
|
4659 | |
|
4660 | |
if ( first === 1 && last === 0 ) {
|
4661 | |
return true;
|
4662 | |
}
|
4663 | |
|
4664 | |
doneName = match[0];
|
4665 | |
parent = elem.parentNode;
|
4666 | |
|
4667 | |
if ( parent && (parent[ expando ] !== doneName || !elem.nodeIndex) ) {
|
4668 | |
count = 0;
|
4669 | |
|
4670 | |
for ( node = parent.firstChild; node; node = node.nextSibling ) {
|
4671 | |
if ( node.nodeType === 1 ) {
|
4672 | |
node.nodeIndex = ++count;
|
4673 | |
}
|
4674 | |
}
|
4675 | |
|
4676 | |
parent[ expando ] = doneName;
|
4677 | |
}
|
4678 | |
|
4679 | |
diff = elem.nodeIndex - last;
|
4680 | |
|
4681 | |
if ( first === 0 ) {
|
4682 | |
return diff === 0;
|
4683 | |
|
4684 | |
} else {
|
4685 | |
return ( diff % first === 0 && diff / first >= 0 );
|
4686 | |
}
|
4687 | |
}
|
4688 | |
},
|
4689 | |
|
4690 | |
ID: function( elem, match ) {
|
4691 | |
return elem.nodeType === 1 && elem.getAttribute("id") === match;
|
4692 | |
},
|
4693 | |
|
4694 | |
TAG: function( elem, match ) {
|
4695 | |
return (match === "*" && elem.nodeType === 1) || !!elem.nodeName && elem.nodeName.toLowerCase() === match;
|
4696 | |
},
|
4697 | |
|
4698 | |
CLASS: function( elem, match ) {
|
4699 | |
return (" " + (elem.className || elem.getAttribute("class")) + " ")
|
4700 | |
.indexOf( match ) > -1;
|
4701 | |
},
|
4702 | |
|
4703 | |
ATTR: function( elem, match ) {
|
4704 | |
var name = match[1],
|
4705 | |
result = Sizzle.attr ?
|
4706 | |
Sizzle.attr( elem, name ) :
|
4707 | |
Expr.attrHandle[ name ] ?
|
4708 | |
Expr.attrHandle[ name ]( elem ) :
|
4709 | |
elem[ name ] != null ?
|
4710 | |
elem[ name ] :
|
4711 | |
elem.getAttribute( name ),
|
4712 | |
value = result + "",
|
4713 | |
type = match[2],
|
4714 | |
check = match[4];
|
4715 | |
|
4716 | |
return result == null ?
|
4717 | |
type === "!=" :
|
4718 | |
!type && Sizzle.attr ?
|
4719 | |
result != null :
|
4720 | |
type === "=" ?
|
4721 | |
value === check :
|
4722 | |
type === "*=" ?
|
4723 | |
value.indexOf(check) >= 0 :
|
4724 | |
type === "~=" ?
|
4725 | |
(" " + value + " ").indexOf(check) >= 0 :
|
4726 | |
!check ?
|
4727 | |
value && result !== false :
|
4728 | |
type === "!=" ?
|
4729 | |
value !== check :
|
4730 | |
type === "^=" ?
|
4731 | |
value.indexOf(check) === 0 :
|
4732 | |
type === "$=" ?
|
4733 | |
value.substr(value.length - check.length) === check :
|
4734 | |
type === "|=" ?
|
4735 | |
value === check || value.substr(0, check.length + 1) === check + "-" :
|
4736 | |
false;
|
4737 | |
},
|
4738 | |
|
4739 | |
POS: function( elem, match, i, array ) {
|
4740 | |
var name = match[2],
|
4741 | |
filter = Expr.setFilters[ name ];
|
4742 | |
|
4743 | |
if ( filter ) {
|
4744 | |
return filter( elem, i, match, array );
|
4745 | |
}
|
4746 | |
}
|
4747 | |
}
|
4748 | |
};
|
4749 | |
|
4750 | |
var origPOS = Expr.match.POS,
|
4751 | |
fescape = function(all, num){
|
4752 | |
return "\\" + (num - 0 + 1);
|
4753 | |
};
|
4754 | |
|
4755 | |
for ( var type in Expr.match ) {
|
4756 | |
Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
|
4757 | |
Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
|
4758 | |
}
|
4759 | |
|
4760 | |
var makeArray = function( array, results ) {
|
4761 | |
array = Array.prototype.slice.call( array, 0 );
|
4762 | |
|
4763 | |
if ( results ) {
|
4764 | |
results.push.apply( results, array );
|
4765 | |
return results;
|
4766 | |
}
|
4767 | |
|
4768 | |
return array;
|
4769 | |
};
|
4770 | |
|
4771 | |
// Perform a simple check to determine if the browser is capable of
|
4772 | |
// converting a NodeList to an array using builtin methods.
|
4773 | |
// Also verifies that the returned array holds DOM nodes
|
4774 | |
// (which is not the case in the Blackberry browser)
|
4775 | |
try {
|
4776 | |
Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
|
4777 | |
|
4778 | |
// Provide a fallback method if it does not work
|
4779 | |
} catch( e ) {
|
4780 | |
makeArray = function( array, results ) {
|
4781 | |
var i = 0,
|
4782 | |
ret = results || [];
|
4783 | |
|
4784 | |
if ( toString.call(array) === "[object Array]" ) {
|
4785 | |
Array.prototype.push.apply( ret, array );
|
4786 | |
|
4787 | |
} else {
|
4788 | |
if ( typeof array.length === "number" ) {
|
4789 | |
for ( var l = array.length; i < l; i++ ) {
|
4790 | |
ret.push( array[i] );
|
4791 | |
}
|
4792 | |
|
4793 | |
} else {
|
4794 | |
for ( ; array[i]; i++ ) {
|
4795 | |
ret.push( array[i] );
|
4796 | |
}
|
4797 | |
}
|
4798 | |
}
|
4799 | |
|
4800 | |
return ret;
|
4801 | |
};
|
4802 | |
}
|
4803 | |
|
4804 | |
var sortOrder, siblingCheck;
|
4805 | |
|
4806 | |
if ( document.documentElement.compareDocumentPosition ) {
|
4807 | |
sortOrder = function( a, b ) {
|
4808 | |
if ( a === b ) {
|
4809 | |
hasDuplicate = true;
|
4810 | |
return 0;
|
4811 | |
}
|
4812 | |
|
4813 | |
if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
|
4814 | |
return a.compareDocumentPosition ? -1 : 1;
|
4815 | |
}
|
4816 | |
|
4817 | |
return a.compareDocumentPosition(b) & 4 ? -1 : 1;
|
4818 | |
};
|
4819 | |
|
4820 | |
} else {
|
4821 | |
sortOrder = function( a, b ) {
|
4822 | |
// The nodes are identical, we can exit early
|
4823 | |
if ( a === b ) {
|
4824 | |
hasDuplicate = true;
|
4825 | |
return 0;
|
4826 | |
|
4827 | |
// Fallback to using sourceIndex (in IE) if it's available on both nodes
|
4828 | |
} else if ( a.sourceIndex && b.sourceIndex ) {
|
4829 | |
return a.sourceIndex - b.sourceIndex;
|
4830 | |
}
|
4831 | |
|
4832 | |
var al, bl,
|
4833 | |
ap = [],
|
4834 | |
bp = [],
|
4835 | |
aup = a.parentNode,
|
4836 | |
bup = b.parentNode,
|
4837 | |
cur = aup;
|
4838 | |
|
4839 | |
// If the nodes are siblings (or identical) we can do a quick check
|
4840 | |
if ( aup === bup ) {
|
4841 | |
return siblingCheck( a, b );
|
4842 | |
|
4843 | |
// If no parents were found then the nodes are disconnected
|
4844 | |
} else if ( !aup ) {
|
4845 | |
return -1;
|
4846 | |
|
4847 | |
} else if ( !bup ) {
|
4848 | |
return 1;
|
4849 | |
}
|
4850 | |
|
4851 | |
// Otherwise they're somewhere else in the tree so we need
|
4852 | |
// to build up a full list of the parentNodes for comparison
|
4853 | |
while ( cur ) {
|
4854 | |
ap.unshift( cur );
|
4855 | |
cur = cur.parentNode;
|
4856 | |
}
|
4857 | |
|
4858 | |
cur = bup;
|
4859 | |
|
4860 | |
while ( cur ) {
|
4861 | |
bp.unshift( cur );
|
4862 | |
cur = cur.parentNode;
|
4863 | |
}
|
4864 | |
|
4865 | |
al = ap.length;
|
4866 | |
bl = bp.length;
|
4867 | |
|
4868 | |
// Start walking down the tree looking for a discrepancy
|
4869 | |
for ( var i = 0; i < al && i < bl; i++ ) {
|
4870 | |
if ( ap[i] !== bp[i] ) {
|
4871 | |
return siblingCheck( ap[i], bp[i] );
|
4872 | |
}
|
4873 | |
}
|
4874 | |
|
4875 | |
// We ended someplace up the tree so do a sibling check
|
4876 | |
return i === al ?
|
4877 | |
siblingCheck( a, bp[i], -1 ) :
|
4878 | |
siblingCheck( ap[i], b, 1 );
|
4879 | |
};
|
4880 | |
|
4881 | |
siblingCheck = function( a, b, ret ) {
|
4882 | |
if ( a === b ) {
|
4883 | |
return ret;
|
4884 | |
}
|
4885 | |
|
4886 | |
var cur = a.nextSibling;
|
4887 | |
|
4888 | |
while ( cur ) {
|
4889 | |
if ( cur === b ) {
|
4890 | |
return -1;
|
4891 | |
}
|
4892 | |
|
4893 | |
cur = cur.nextSibling;
|
4894 | |
}
|
4895 | |
|
4896 | |
return 1;
|
4897 | |
};
|
4898 | |
}
|
4899 | |
|
4900 | |
// Check to see if the browser returns elements by name when
|
4901 | |
// querying by getElementById (and provide a workaround)
|
4902 | |
(function(){
|
4903 | |
// We're going to inject a fake input element with a specified name
|
4904 | |
var form = document.createElement("div"),
|
4905 | |
id = "script" + (new Date()).getTime(),
|
4906 | |
root = document.documentElement;
|
4907 | |
|
4908 | |
form.innerHTML = "<a name='" + id + "'/>";
|
4909 | |
|
4910 | |
// Inject it into the root element, check its status, and remove it quickly
|
4911 | |
root.insertBefore( form, root.firstChild );
|
4912 | |
|
4913 | |
// The workaround has to do additional checks after a getElementById
|
4914 | |
// Which slows things down for other browsers (hence the branching)
|
4915 | |
if ( document.getElementById( id ) ) {
|
4916 | |
Expr.find.ID = function( match, context, isXML ) {
|
4917 | |
if ( typeof context.getElementById !== "undefined" && !isXML ) {
|
4918 | |
var m = context.getElementById(match[1]);
|
4919 | |
|
4920 | |
return m ?
|
4921 | |
m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ?
|
4922 | |
[m] :
|
4923 | |
undefined :
|
4924 | |
[];
|
4925 | |
}
|
4926 | |
};
|
4927 | |
|
4928 | |
Expr.filter.ID = function( elem, match ) {
|
4929 | |
var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
|
4930 | |
|
4931 | |
return elem.nodeType === 1 && node && node.nodeValue === match;
|
4932 | |
};
|
4933 | |
}
|
4934 | |
|
4935 | |
root.removeChild( form );
|
4936 | |
|
4937 | |
// release memory in IE
|
4938 | |
root = form = null;
|
4939 | |
})();
|
4940 | |
|
4941 | |
(function(){
|
4942 | |
// Check to see if the browser returns only elements
|
4943 | |
// when doing getElementsByTagName("*")
|
4944 | |
|
4945 | |
// Create a fake element
|
4946 | |
var div = document.createElement("div");
|
4947 | |
div.appendChild( document.createComment("") );
|
4948 | |
|
4949 | |
// Make sure no comments are found
|
4950 | |
if ( div.getElementsByTagName("*").length > 0 ) {
|
4951 | |
Expr.find.TAG = function( match, context ) {
|
4952 | |
var results = context.getElementsByTagName( match[1] );
|
4953 | |
|
4954 | |
// Filter out possible comments
|
4955 | |
if ( match[1] === "*" ) {
|
4956 | |
var tmp = [];
|
4957 | |
|
4958 | |
for ( var i = 0; results[i]; i++ ) {
|
4959 | |
if ( results[i].nodeType === 1 ) {
|
4960 | |
tmp.push( results[i] );
|
4961 | |
}
|
4962 | |
}
|
4963 | |
|
4964 | |
results = tmp;
|
4965 | |
}
|
4966 | |
|
4967 | |
return results;
|
4968 | |
};
|
4969 | |
}
|
4970 | |
|
4971 | |
// Check to see if an attribute returns normalized href attributes
|
4972 | |
div.innerHTML = "<a href='#'></a>";
|
4973 | |
|
4974 | |
if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
|
4975 | |
div.firstChild.getAttribute("href") !== "#" ) {
|
4976 | |
|
4977 | |
Expr.attrHandle.href = function( elem ) {
|
4978 | |
return elem.getAttribute( "href", 2 );
|
4979 | |
};
|
4980 | |
}
|
4981 | |
|
4982 | |
// release memory in IE
|
4983 | |
div = null;
|
4984 | |
})();
|
4985 | |
|
4986 | |
if ( document.querySelectorAll ) {
|
4987 | |
(function(){
|
4988 | |
var oldSizzle = Sizzle,
|
4989 | |
div = document.createElement("div"),
|
4990 | |
id = "__sizzle__";
|
4991 | |
|
4992 | |
div.innerHTML = "<p class='TEST'></p>";
|
4993 | |
|
4994 | |
// Safari can't handle uppercase or unicode characters when
|
4995 | |
// in quirks mode.
|
4996 | |
if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
|
4997 | |
return;
|
4998 | |
}
|
4999 | |
|
5000 | |
Sizzle = function( query, context, extra, seed ) {
|
5001 | |
context = context || document;
|
5002 | |
|
5003 | |
// Only use querySelectorAll on non-XML documents
|
5004 | |
// (ID selectors don't work in non-HTML documents)
|
5005 | |
if ( !seed && !Sizzle.isXML(context) ) {
|
5006 | |
// See if we find a selector to speed up
|
5007 | |
var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
|
5008 | |
|
5009 | |
if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
|
5010 | |
// Speed-up: Sizzle("TAG")
|
5011 | |
if ( match[1] ) {
|
5012 | |
return makeArray( context.getElementsByTagName( query ), extra );
|
5013 | |
|
5014 | |
// Speed-up: Sizzle(".CLASS")
|
5015 | |
} else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
|
5016 | |
return makeArray( context.getElementsByClassName( match[2] ), extra );
|
5017 | |
}
|
5018 | |
}
|
5019 | |
|
5020 | |
if ( context.nodeType === 9 ) {
|
5021 | |
// Speed-up: Sizzle("body")
|
5022 | |
// The body element only exists once, optimize finding it
|
5023 | |
if ( query === "body" && context.body ) {
|
5024 | |
return makeArray( [ context.body ], extra );
|
5025 | |
|
5026 | |
// Speed-up: Sizzle("#ID")
|
5027 | |
} else if ( match && match[3] ) {
|
5028 | |
var elem = context.getElementById( match[3] );
|
5029 | |
|
5030 | |
// Check parentNode to catch when Blackberry 4.6 returns
|
5031 | |
// nodes that are no longer in the document #6963
|
5032 | |
if ( elem && elem.parentNode ) {
|
5033 | |
// Handle the case where IE and Opera return items
|
5034 | |
// by name instead of ID
|
5035 | |
if ( elem.id === match[3] ) {
|
5036 | |
return makeArray( [ elem ], extra );
|
5037 | |
}
|
5038 | |
|
5039 | |
} else {
|
5040 | |
return makeArray( [], extra );
|
5041 | |
}
|
5042 | |
}
|
5043 | |
|
5044 | |
try {
|
5045 | |
return makeArray( context.querySelectorAll(query), extra );
|
5046 | |
} catch(qsaError) {}
|
5047 | |
|
5048 | |
// qSA works strangely on Element-rooted queries
|
5049 | |
// We can work around this by specifying an extra ID on the root
|
5050 | |
// and working up from there (Thanks to Andrew Dupont for the technique)
|
5051 | |
// IE 8 doesn't work on object elements
|
5052 | |
} else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
|
5053 | |
var oldContext = context,
|
5054 | |
old = context.getAttribute( "id" ),
|
5055 | |
nid = old || id,
|
5056 | |
hasParent = context.parentNode,
|
5057 | |
relativeHierarchySelector = /^\s*[+~]/.test( query );
|
5058 | |
|
5059 | |
if ( !old ) {
|
5060 | |
context.setAttribute( "id", nid );
|
5061 | |
} else {
|
5062 | |
nid = nid.replace( /'/g, "\\$&" );
|
5063 | |
}
|
5064 | |
if ( relativeHierarchySelector && hasParent ) {
|
5065 | |
context = context.parentNode;
|
5066 | |
}
|
5067 | |
|
5068 | |
try {
|
5069 | |
if ( !relativeHierarchySelector || hasParent ) {
|
5070 | |
return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra );
|
5071 | |
}
|
5072 | |
|
5073 | |
} catch(pseudoError) {
|
5074 | |
} finally {
|
5075 | |
if ( !old ) {
|
5076 | |
oldContext.removeAttribute( "id" );
|
5077 | |
}
|
5078 | |
}
|
5079 | |
}
|
5080 | |
}
|
5081 | |
|
5082 | |
return oldSizzle(query, context, extra, seed);
|
5083 | |
};
|
5084 | |
|
5085 | |
for ( var prop in oldSizzle ) {
|
5086 | |
Sizzle[ prop ] = oldSizzle[ prop ];
|
5087 | |
}
|
5088 | |
|
5089 | |
// release memory in IE
|
5090 | |
div = null;
|
5091 | |
})();
|
5092 | |
}
|
5093 | |
|
5094 | |
(function(){
|
5095 | |
var html = document.documentElement,
|
5096 | |
matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector;
|
5097 | |
|
5098 | |
if ( matches ) {
|
5099 | |
// Check to see if it's possible to do matchesSelector
|
5100 | |
// on a disconnected node (IE 9 fails this)
|
5101 | |
var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ),
|
5102 | |
pseudoWorks = false;
|
5103 | |
|
5104 | |
try {
|
5105 | |
// This should fail with an exception
|
5106 | |
// Gecko does not error, returns false instead
|
5107 | |
matches.call( document.documentElement, "[test!='']:sizzle" );
|
5108 | |
|
5109 | |
} catch( pseudoError ) {
|
5110 | |
pseudoWorks = true;
|
5111 | |
}
|
5112 | |
|
5113 | |
Sizzle.matchesSelector = function( node, expr ) {
|
5114 | |
// Make sure that attribute selectors are quoted
|
5115 | |
expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
|
5116 | |
|
5117 | |
if ( !Sizzle.isXML( node ) ) {
|
5118 | |
try {
|
5119 | |
if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
|
5120 | |
var ret = matches.call( node, expr );
|
5121 | |
|
5122 | |
// IE 9's matchesSelector returns false on disconnected nodes
|
5123 | |
if ( ret || !disconnectedMatch ||
|
5124 | |
// As well, disconnected nodes are said to be in a document
|
5125 | |
// fragment in IE 9, so check for that
|
5126 | |
node.document && node.document.nodeType !== 11 ) {
|
5127 | |
return ret;
|
5128 | |
}
|
5129 | |
}
|
5130 | |
} catch(e) {}
|
5131 | |
}
|
5132 | |
|
5133 | |
return Sizzle(expr, null, null, [node]).length > 0;
|
5134 | |
};
|
5135 | |
}
|
5136 | |
})();
|
5137 | |
|
5138 | |
(function(){
|
5139 | |
var div = document.createElement("div");
|
5140 | |
|
5141 | |
div.innerHTML = "<div class='test e'></div><div class='test'></div>";
|
5142 | |
|
5143 | |
// Opera can't find a second classname (in 9.6)
|
5144 | |
// Also, make sure that getElementsByClassName actually exists
|
5145 | |
if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
|
5146 | |
return;
|
5147 | |
}
|
5148 | |
|
5149 | |
// Safari caches class attributes, doesn't catch changes (in 3.2)
|
5150 | |
div.lastChild.className = "e";
|
5151 | |
|
5152 | |
if ( div.getElementsByClassName("e").length === 1 ) {
|
5153 | |
return;
|
5154 | |
}
|
5155 | |
|
5156 | |
Expr.order.splice(1, 0, "CLASS");
|
5157 | |
Expr.find.CLASS = function( match, context, isXML ) {
|
5158 | |
if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
|
5159 | |
return context.getElementsByClassName(match[1]);
|
5160 | |
}
|
5161 | |
};
|
5162 | |
|
5163 | |
// release memory in IE
|
5164 | |
div = null;
|
5165 | |
})();
|
5166 | |
|
5167 | |
function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
|
5168 | |
for ( var i = 0, l = checkSet.length; i < l; i++ ) {
|
5169 | |
var elem = checkSet[i];
|
5170 | |
|
5171 | |
if ( elem ) {
|
5172 | |
var match = false;
|
5173 | |
|
5174 | |
elem = elem[dir];
|
5175 | |
|
5176 | |
while ( elem ) {
|
5177 | |
if ( elem[ expando ] === doneName ) {
|
5178 | |
match = checkSet[elem.sizset];
|
5179 | |
break;
|
5180 | |
}
|
5181 | |
|
5182 | |
if ( elem.nodeType === 1 && !isXML ){
|
5183 | |
elem[ expando ] = doneName;
|
5184 | |
elem.sizset = i;
|
5185 | |
}
|
5186 | |
|
5187 | |
if ( elem.nodeName.toLowerCase() === cur ) {
|
5188 | |
match = elem;
|
5189 | |
break;
|
5190 | |
}
|
5191 | |
|
5192 | |
elem = elem[dir];
|
5193 | |
}
|
5194 | |
|
5195 | |
checkSet[i] = match;
|
5196 | |
}
|
5197 | |
}
|
5198 | |
}
|
5199 | |
|
5200 | |
function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
|
5201 | |
for ( var i = 0, l = checkSet.length; i < l; i++ ) {
|
5202 | |
var elem = checkSet[i];
|
5203 | |
|
5204 | |
if ( elem ) {
|
5205 | |
var match = false;
|
5206 | |
|
5207 | |
elem = elem[dir];
|
5208 | |
|
5209 | |
while ( elem ) {
|
5210 | |
if ( elem[ expando ] === doneName ) {
|
5211 | |
match = checkSet[elem.sizset];
|
5212 | |
break;
|
5213 | |
}
|
5214 | |
|
5215 | |
if ( elem.nodeType === 1 ) {
|
5216 | |
if ( !isXML ) {
|
5217 | |
elem[ expando ] = doneName;
|
5218 | |
elem.sizset = i;
|
5219 | |
}
|
5220 | |
|
5221 | |
if ( typeof cur !== "string" ) {
|
5222 | |
if ( elem === cur ) {
|
5223 | |
match = true;
|
5224 | |
break;
|
5225 | |
}
|
5226 | |
|
5227 | |
} else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
|
5228 | |
match = elem;
|
5229 | |
break;
|
5230 | |
}
|
5231 | |
}
|
5232 | |
|
5233 | |
elem = elem[dir];
|
5234 | |
}
|
5235 | |
|
5236 | |
checkSet[i] = match;
|
5237 | |
}
|
5238 | |
}
|
5239 | |
}
|
5240 | |
|
5241 | |
if ( document.documentElement.contains ) {
|
5242 | |
Sizzle.contains = function( a, b ) {
|
5243 | |
return a !== b && (a.contains ? a.contains(b) : true);
|
5244 | |
};
|
5245 | |
|
5246 | |
} else if ( document.documentElement.compareDocumentPosition ) {
|
5247 | |
Sizzle.contains = function( a, b ) {
|
5248 | |
return !!(a.compareDocumentPosition(b) & 16);
|
5249 | |
};
|
5250 | |
|
5251 | |
} else {
|
5252 | |
Sizzle.contains = function() {
|
5253 | |
return false;
|
5254 | |
};
|
5255 | |
}
|
5256 | |
|
5257 | |
Sizzle.isXML = function( elem ) {
|
5258 | |
// documentElement is verified for cases where it doesn't yet exist
|
5259 | |
// (such as loading iframes in IE - #4833)
|
5260 | |
var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
|
5261 | |
|
5262 | |
return documentElement ? documentElement.nodeName !== "HTML" : false;
|
5263 | |
};
|
5264 | |
|
5265 | |
var posProcess = function( selector, context, seed ) {
|
5266 | |
var match,
|
5267 | |
tmpSet = [],
|
5268 | |
later = "",
|
5269 | |
root = context.nodeType ? [context] : context;
|
5270 | |
|
5271 | |
// Position selectors must be done after the filter
|
5272 | |
// And so must :not(positional) so we move all PSEUDOs to the end
|
5273 | |
while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
|
5274 | |
later += match[0];
|
5275 | |
selector = selector.replace( Expr.match.PSEUDO, "" );
|
5276 | |
}
|
5277 | |
|
5278 | |
selector = Expr.relative[selector] ? selector + "*" : selector;
|
5279 | |
|
5280 | |
for ( var i = 0, l = root.length; i < l; i++ ) {
|
5281 | |
Sizzle( selector, root[i], tmpSet, seed );
|
5282 | |
}
|
5283 | |
|
5284 | |
return Sizzle.filter( later, tmpSet );
|
5285 | |
};
|
5286 | |
|
5287 | |
// EXPOSE
|
5288 | |
// Override sizzle attribute retrieval
|
5289 | |
Sizzle.attr = jQuery.attr;
|
5290 | |
Sizzle.selectors.attrMap = {};
|
5291 | |
jQuery.find = Sizzle;
|
5292 | |
jQuery.expr = Sizzle.selectors;
|
5293 | |
jQuery.expr[":"] = jQuery.expr.filters;
|
5294 | |
jQuery.unique = Sizzle.uniqueSort;
|
5295 | |
jQuery.text = Sizzle.getText;
|
5296 | |
jQuery.isXMLDoc = Sizzle.isXML;
|
5297 | |
jQuery.contains = Sizzle.contains;
|
5298 | |
|
5299 | |
|
5300 | |
})();
|
5301 | |
|
5302 | |
|
5303 | |
var runtil = /Until$/,
|
5304 | |
rparentsprev = /^(?:parents|prevUntil|prevAll)/,
|
5305 | |
// Note: This RegExp should be improved, or likely pulled from Sizzle
|
5306 | |
rmultiselector = /,/,
|
5307 | |
isSimple = /^.[^:#\[\.,]*$/,
|
5308 | |
slice = Array.prototype.slice,
|
5309 | |
POS = jQuery.expr.match.POS,
|
5310 | |
// methods guaranteed to produce a unique set when starting from a unique set
|
5311 | |
guaranteedUnique = {
|
5312 | |
children: true,
|
5313 | |
contents: true,
|
5314 | |
next: true,
|
5315 | |
prev: true
|
5316 | |
};
|
5317 | |
|
5318 | |
jQuery.fn.extend({
|
5319 | |
find: function( selector ) {
|
5320 | |
var self = this,
|
5321 | |
i, l;
|
5322 | |
|
5323 | |
if ( typeof selector !== "string" ) {
|
5324 | |
return jQuery( selector ).filter(function() {
|
5325 | |
for ( i = 0, l = self.length; i < l; i++ ) {
|
5326 | |
if ( jQuery.contains( self[ i ], this ) ) {
|
5327 | |
return true;
|
5328 | |
}
|
5329 | |
}
|
5330 | |
});
|
5331 | |
}
|
5332 | |
|
5333 | |
var ret = this.pushStack( "", "find", selector ),
|
5334 | |
length, n, r;
|
5335 | |
|
5336 | |
for ( i = 0, l = this.length; i < l; i++ ) {
|
5337 | |
length = ret.length;
|
5338 | |
jQuery.find( selector, this[i], ret );
|
5339 | |
|
5340 | |
if ( i > 0 ) {
|
5341 | |
// Make sure that the results are unique
|
5342 | |
for ( n = length; n < ret.length; n++ ) {
|
5343 | |
for ( r = 0; r < length; r++ ) {
|
5344 | |
if ( ret[r] === ret[n] ) {
|
5345 | |
ret.splice(n--, 1);
|
5346 | |
break;
|
5347 | |
}
|
5348 | |
}
|
5349 | |
}
|
5350 | |
}
|
5351 | |
}
|
5352 | |
|
5353 | |
return ret;
|
5354 | |
},
|
5355 | |
|
5356 | |
has: function( target ) {
|
5357 | |
var targets = jQuery( target );
|
5358 | |
return this.filter(function() {
|
5359 | |
for ( var i = 0, l = targets.length; i < l; i++ ) {
|
5360 | |
if ( jQuery.contains( this, targets[i] ) ) {
|
5361 | |
return true;
|
5362 | |
}
|
5363 | |
}
|
5364 | |
});
|
5365 | |
},
|
5366 | |
|
5367 | |
not: function( selector ) {
|
5368 | |
return this.pushStack( winnow(this, selector, false), "not", selector);
|
5369 | |
},
|
5370 | |
|
5371 | |
filter: function( selector ) {
|
5372 | |
return this.pushStack( winnow(this, selector, true), "filter", selector );
|
5373 | |
},
|
5374 | |
|
5375 | |
is: function( selector ) {
|
5376 | |
return !!selector && (
|
5377 | |
typeof selector === "string" ?
|
5378 | |
// If this is a positional selector, check membership in the returned set
|
5379 | |
// so $("p:first").is("p:last") won't return true for a doc with two "p".
|
5380 | |
POS.test( selector ) ?
|
5381 | |
jQuery( selector, this.context ).index( this[0] ) >= 0 :
|
5382 | |
jQuery.filter( selector, this ).length > 0 :
|
5383 | |
this.filter( selector ).length > 0 );
|
5384 | |
},
|
5385 | |
|
5386 | |
closest: function( selectors, context ) {
|
5387 | |
var ret = [], i, l, cur = this[0];
|
5388 | |
|
5389 | |
// Array (deprecated as of jQuery 1.7)
|
5390 | |
if ( jQuery.isArray( selectors ) ) {
|
5391 | |
var level = 1;
|
5392 | |
|
5393 | |
while ( cur && cur.ownerDocument && cur !== context ) {
|
5394 | |
for ( i = 0; i < selectors.length; i++ ) {
|
5395 | |
|
5396 | |
if ( jQuery( cur ).is( selectors[ i ] ) ) {
|
5397 | |
ret.push({ selector: selectors[ i ], elem: cur, level: level });
|
5398 | |
}
|
5399 | |
}
|
5400 | |
|
5401 | |
cur = cur.parentNode;
|
5402 | |
level++;
|
5403 | |
}
|
5404 | |
|
5405 | |
return ret;
|
5406 | |
}
|
5407 | |
|
5408 | |
// String
|
5409 | |
var pos = POS.test( selectors ) || typeof selectors !== "string" ?
|
5410 | |
jQuery( selectors, context || this.context ) :
|
5411 | |
0;
|
5412 | |
|
5413 | |
for ( i = 0, l = this.length; i < l; i++ ) {
|
5414 | |
cur = this[i];
|
5415 | |
|
5416 | |
while ( cur ) {
|
5417 | |
if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
|
5418 | |
ret.push( cur );
|
5419 | |
break;
|
5420 | |
|
5421 | |
} else {
|
5422 | |
cur = cur.parentNode;
|
5423 | |
if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) {
|
5424 | |
break;
|
5425 | |
}
|
5426 | |
}
|
5427 | |
}
|
5428 | |
}
|
5429 | |
|
5430 | |
ret = ret.length > 1 ? jQuery.unique( ret ) : ret;
|
5431 | |
|
5432 | |
return this.pushStack( ret, "closest", selectors );
|
5433 | |
},
|
5434 | |
|
5435 | |
// Determine the position of an element within
|
5436 | |
// the matched set of elements
|
5437 | |
index: function( elem ) {
|
5438 | |
|
5439 | |
// No argument, return index in parent
|
5440 | |
if ( !elem ) {
|
5441 | |
return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1;
|
5442 | |
}
|
5443 | |
|
5444 | |
// index in selector
|
5445 | |
if ( typeof elem === "string" ) {
|
5446 | |
return jQuery.inArray( this[0], jQuery( elem ) );
|
5447 | |
}
|
5448 | |
|
5449 | |
// Locate the position of the desired element
|
5450 | |
return jQuery.inArray(
|
5451 | |
// If it receives a jQuery object, the first element is used
|
5452 | |
elem.jquery ? elem[0] : elem, this );
|
5453 | |
},
|
5454 | |
|
5455 | |
add: function( selector, context ) {
|
5456 | |
var set = typeof selector === "string" ?
|
5457 | |
jQuery( selector, context ) :
|
5458 | |
jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
|
5459 | |
all = jQuery.merge( this.get(), set );
|
5460 | |
|
5461 | |
return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
|
5462 | |
all :
|
5463 | |
jQuery.unique( all ) );
|
5464 | |
},
|
5465 | |
|
5466 | |
andSelf: function() {
|
5467 | |
return this.add( this.prevObject );
|
5468 | |
}
|
5469 | |
});
|
5470 | |
|
5471 | |
// A painfully simple check to see if an element is disconnected
|
5472 | |
// from a document (should be improved, where feasible).
|
5473 | |
function isDisconnected( node ) {
|
5474 | |
return !node || !node.parentNode || node.parentNode.nodeType === 11;
|
5475 | |
}
|
5476 | |
|
5477 | |
jQuery.each({
|
5478 | |
parent: function( elem ) {
|
5479 | |
var parent = elem.parentNode;
|
5480 | |
return parent && parent.nodeType !== 11 ? parent : null;
|
5481 | |
},
|
5482 | |
parents: function( elem ) {
|
5483 | |
return jQuery.dir( elem, "parentNode" );
|
5484 | |
},
|
5485 | |
parentsUntil: function( elem, i, until ) {
|
5486 | |
return jQuery.dir( elem, "parentNode", until );
|
5487 | |
},
|
5488 | |
next: function( elem ) {
|
5489 | |
return jQuery.nth( elem, 2, "nextSibling" );
|
5490 | |
},
|
5491 | |
prev: function( elem ) {
|
5492 | |
return jQuery.nth( elem, 2, "previousSibling" );
|
5493 | |
},
|
5494 | |
nextAll: function( elem ) {
|
5495 | |
return jQuery.dir( elem, "nextSibling" );
|
5496 | |
},
|
5497 | |
prevAll: function( elem ) {
|
5498 | |
return jQuery.dir( elem, "previousSibling" );
|
5499 | |
},
|
5500 | |
nextUntil: function( elem, i, until ) {
|
5501 | |
return jQuery.dir( elem, "nextSibling", until );
|
5502 | |
},
|
5503 | |
prevUntil: function( elem, i, until ) {
|
5504 | |
return jQuery.dir( elem, "previousSibling", until );
|
5505 | |
},
|
5506 | |
siblings: function( elem ) {
|
5507 | |
return jQuery.sibling( elem.parentNode.firstChild, elem );
|
5508 | |
},
|
5509 | |
children: function( elem ) {
|
5510 | |
return jQuery.sibling( elem.firstChild );
|
5511 | |
},
|
5512 | |
contents: function( elem ) {
|
5513 | |
return jQuery.nodeName( elem, "iframe" ) ?
|
5514 | |
elem.contentDocument || elem.contentWindow.document :
|
5515 | |
jQuery.makeArray( elem.childNodes );
|
5516 | |
}
|
5517 | |
}, function( name, fn ) {
|
5518 | |
jQuery.fn[ name ] = function( until, selector ) {
|
5519 | |
var ret = jQuery.map( this, fn, until );
|
5520 | |
|
5521 | |
if ( !runtil.test( name ) ) {
|
5522 | |
selector = until;
|
5523 | |
}
|
5524 | |
|
5525 | |
if ( selector && typeof selector === "string" ) {
|
5526 | |
ret = jQuery.filter( selector, ret );
|
5527 | |
}
|
5528 | |
|
5529 | |
ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
|
5530 | |
|
5531 | |
if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
|
5532 | |
ret = ret.reverse();
|
5533 | |
}
|
5534 | |
|
5535 | |
return this.pushStack( ret, name, slice.call( arguments ).join(",") );
|
5536 | |
};
|
5537 | |
});
|
5538 | |
|
5539 | |
jQuery.extend({
|
5540 | |
filter: function( expr, elems, not ) {
|
5541 | |
if ( not ) {
|
5542 | |
expr = ":not(" + expr + ")";
|
5543 | |
}
|
5544 | |
|
5545 | |
return elems.length === 1 ?
|
5546 | |
jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
|
5547 | |
jQuery.find.matches(expr, elems);
|
5548 | |
},
|
5549 | |
|
5550 | |
dir: function( elem, dir, until ) {
|
5551 | |
var matched = [],
|
5552 | |
cur = elem[ dir ];
|
5553 | |
|
5554 | |
while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
|
5555 | |
if ( cur.nodeType === 1 ) {
|
5556 | |
matched.push( cur );
|
5557 | |
}
|
5558 | |
cur = cur[dir];
|
5559 | |
}
|
5560 | |
return matched;
|
5561 | |
},
|
5562 | |
|
5563 | |
nth: function( cur, result, dir, elem ) {
|
5564 | |
result = result || 1;
|
5565 | |
var num = 0;
|
5566 | |
|
5567 | |
for ( ; cur; cur = cur[dir] ) {
|
5568 | |
if ( cur.nodeType === 1 && ++num === result ) {
|
5569 | |
break;
|
5570 | |
}
|
5571 | |
}
|
5572 | |
|
5573 | |
return cur;
|
5574 | |
},
|
5575 | |
|
5576 | |
sibling: function( n, elem ) {
|
5577 | |
var r = [];
|
5578 | |
|
5579 | |
for ( ; n; n = n.nextSibling ) {
|
5580 | |
if ( n.nodeType === 1 && n !== elem ) {
|
5581 | |
r.push( n );
|
5582 | |
}
|
5583 | |
}
|
5584 | |
|
5585 | |
return r;
|
5586 | |
}
|
5587 | |
});
|
5588 | |
|
5589 | |
// Implement the identical functionality for filter and not
|
5590 | |
function winnow( elements, qualifier, keep ) {
|
5591 | |
|
5592 | |
// Can't pass null or undefined to indexOf in Firefox 4
|
5593 | |
// Set to 0 to skip string check
|
5594 | |
qualifier = qualifier || 0;
|
5595 | |
|
5596 | |
if ( jQuery.isFunction( qualifier ) ) {
|
5597 | |
return jQuery.grep(elements, function( elem, i ) {
|
5598 | |
var retVal = !!qualifier.call( elem, i, elem );
|
5599 | |
return retVal === keep;
|
5600 | |
});
|
5601 | |
|
5602 | |
} else if ( qualifier.nodeType ) {
|
5603 | |
return jQuery.grep(elements, function( elem, i ) {
|
5604 | |
return ( elem === qualifier ) === keep;
|
5605 | |
});
|
5606 | |
|
5607 | |
} else if ( typeof qualifier === "string" ) {
|
5608 | |
var filtered = jQuery.grep(elements, function( elem ) {
|
5609 | |
return elem.nodeType === 1;
|
5610 | |
});
|
5611 | |
|
5612 | |
if ( isSimple.test( qualifier ) ) {
|
5613 | |
return jQuery.filter(qualifier, filtered, !keep);
|
5614 | |
} else {
|
5615 | |
qualifier = jQuery.filter( qualifier, filtered );
|
5616 | |
}
|
5617 | |
}
|
5618 | |
|
5619 | |
return jQuery.grep(elements, function( elem, i ) {
|
5620 | |
return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep;
|
5621 | |
});
|
5622 | |
}
|
5623 | |
|
5624 | |
|
5625 | |
|
5626 | |
|
5627 | |
function createSafeFragment( document ) {
|
5628 | |
var list = nodeNames.split( "|" ),
|
5629 | |
safeFrag = document.createDocumentFragment();
|
5630 | |
|
5631 | |
if ( safeFrag.createElement ) {
|
5632 | |
while ( list.length ) {
|
5633 | |
safeFrag.createElement(
|
5634 | |
list.pop()
|
5635 | |
);
|
5636 | |
}
|
5637 | |
}
|
5638 | |
return safeFrag;
|
5639 | |
}
|
5640 | |
|
5641 | |
var nodeNames = "abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|" +
|
5642 | |
"header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
|
5643 | |
rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
|
5644 | |
rleadingWhitespace = /^\s+/,
|
5645 | |
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
|
5646 | |
rtagName = /<([\w:]+)/,
|
5647 | |
rtbody = /<tbody/i,
|
5648 | |
rhtml = /<|&#?\w+;/,
|
5649 | |
rnoInnerhtml = /<(?:script|style)/i,
|
5650 | |
rnocache = /<(?:script|object|embed|option|style)/i,
|
5651 | |
rnoshimcache = new RegExp("<(?:" + nodeNames + ")", "i"),
|
5652 | |
// checked="checked" or checked
|
5653 | |
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
|
5654 | |
rscriptType = /\/(java|ecma)script/i,
|
5655 | |
rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)/,
|
5656 | |
wrapMap = {
|
5657 | |
option: [ 1, "<select multiple='multiple'>", "</select>" ],
|
5658 | |
legend: [ 1, "<fieldset>", "</fieldset>" ],
|
5659 | |
thead: [ 1, "<table>", "</table>" ],
|
5660 | |
tr: [ 2, "<table><tbody>", "</tbody></table>" ],
|
5661 | |
td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
|
5662 | |
col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
|
5663 | |
area: [ 1, "<map>", "</map>" ],
|
5664 | |
_default: [ 0, "", "" ]
|
5665 | |
},
|
5666 | |
safeFragment = createSafeFragment( document );
|
5667 | |
|
5668 | |
wrapMap.optgroup = wrapMap.option;
|
5669 | |
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
|
5670 | |
wrapMap.th = wrapMap.td;
|
5671 | |
|
5672 | |
// IE can't serialize <link> and <script> tags normally
|
5673 | |
if ( !jQuery.support.htmlSerialize ) {
|
5674 | |
wrapMap._default = [ 1, "div<div>", "</div>" ];
|
5675 | |
}
|
5676 | |
|
5677 | |
jQuery.fn.extend({
|
5678 | |
text: function( text ) {
|
5679 | |
if ( jQuery.isFunction(text) ) {
|
5680 | |
return this.each(function(i) {
|
5681 | |
var self = jQuery( this );
|
5682 | |
|
5683 | |
self.text( text.call(this, i, self.text()) );
|
5684 | |
});
|
5685 | |
}
|
5686 | |
|
5687 | |
if ( typeof text !== "object" && text !== undefined ) {
|
5688 | |
return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
|
5689 | |
}
|
5690 | |
|
5691 | |
return jQuery.text( this );
|
5692 | |
},
|
5693 | |
|
5694 | |
wrapAll: function( html ) {
|
5695 | |
if ( jQuery.isFunction( html ) ) {
|
5696 | |
return this.each(function(i) {
|
5697 | |
jQuery(this).wrapAll( html.call(this, i) );
|
5698 | |
});
|
5699 | |
}
|
5700 | |
|
5701 | |
if ( this[0] ) {
|
5702 | |
// The elements to wrap the target around
|
5703 | |
var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
|
5704 | |
|
5705 | |
if ( this[0].parentNode ) {
|
5706 | |
wrap.insertBefore( this[0] );
|
5707 | |
}
|
5708 | |
|
5709 | |
wrap.map(function() {
|
5710 | |
var elem = this;
|
5711 | |
|
5712 | |
while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
|
5713 | |
elem = elem.firstChild;
|
5714 | |
}
|
5715 | |
|
5716 | |
return elem;
|
5717 | |
}).append( this );
|
5718 | |
}
|
5719 | |
|
5720 | |
return this;
|
5721 | |
},
|
5722 | |
|
5723 | |
wrapInner: function( html ) {
|
5724 | |
if ( jQuery.isFunction( html ) ) {
|
5725 | |
return this.each(function(i) {
|
5726 | |
jQuery(this).wrapInner( html.call(this, i) );
|
5727 | |
});
|
5728 | |
}
|
5729 | |
|
5730 | |
return this.each(function() {
|
5731 | |
var self = jQuery( this ),
|
5732 | |
contents = self.contents();
|
5733 | |
|
5734 | |
if ( contents.length ) {
|
5735 | |
contents.wrapAll( html );
|
5736 | |
|
5737 | |
} else {
|
5738 | |
self.append( html );
|
5739 | |
}
|
5740 | |
});
|
5741 | |
},
|
5742 | |
|
5743 | |
wrap: function( html ) {
|
5744 | |
var isFunction = jQuery.isFunction( html );
|
5745 | |
|
5746 | |
return this.each(function(i) {
|
5747 | |
jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
|
5748 | |
});
|
5749 | |
},
|
5750 | |
|
5751 | |
unwrap: function() {
|
5752 | |
return this.parent().each(function() {
|
5753 | |
if ( !jQuery.nodeName( this, "body" ) ) {
|
5754 | |
jQuery( this ).replaceWith( this.childNodes );
|
5755 | |
}
|
5756 | |
}).end();
|
5757 | |
},
|
5758 | |
|
5759 | |
append: function() {
|
5760 | |
return this.domManip(arguments, true, function( elem ) {
|
5761 | |
if ( this.nodeType === 1 ) {
|
5762 | |
this.appendChild( elem );
|
5763 | |
}
|
5764 | |
});
|
5765 | |
},
|
5766 | |
|
5767 | |
prepend: function() {
|
5768 | |
return this.domManip(arguments, true, function( elem ) {
|
5769 | |
if ( this.nodeType === 1 ) {
|
5770 | |
this.insertBefore( elem, this.firstChild );
|
5771 | |
}
|
5772 | |
});
|
5773 | |
},
|
5774 | |
|
5775 | |
before: function() {
|
5776 | |
if ( this[0] && this[0].parentNode ) {
|
5777 | |
return this.domManip(arguments, false, function( elem ) {
|
5778 | |
this.parentNode.insertBefore( elem, this );
|
5779 | |
});
|
5780 | |
} else if ( arguments.length ) {
|
5781 | |
var set = jQuery.clean( arguments );
|
5782 | |
set.push.apply( set, this.toArray() );
|
5783 | |
return this.pushStack( set, "before", arguments );
|
5784 | |
}
|
5785 | |
},
|
5786 | |
|
5787 | |
after: function() {
|
5788 | |
if ( this[0] && this[0].parentNode ) {
|
5789 | |
return this.domManip(arguments, false, function( elem ) {
|
5790 | |
this.parentNode.insertBefore( elem, this.nextSibling );
|
5791 | |
});
|
5792 | |
} else if ( arguments.length ) {
|
5793 | |
var set = this.pushStack( this, "after", arguments );
|
5794 | |
set.push.apply( set, jQuery.clean(arguments) );
|
5795 | |
return set;
|
5796 | |
}
|
5797 | |
},
|
5798 | |
|
5799 | |
// keepData is for internal use only--do not document
|
5800 | |
remove: function( selector, keepData ) {
|
5801 | |
for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
|
5802 | |
if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {
|
5803 | |
if ( !keepData && elem.nodeType === 1 ) {
|
5804 | |
jQuery.cleanData( elem.getElementsByTagName("*") );
|
5805 | |
jQuery.cleanData( [ elem ] );
|
5806 | |
}
|
5807 | |
|
5808 | |
if ( elem.parentNode ) {
|
5809 | |
elem.parentNode.removeChild( elem );
|
5810 | |
}
|
5811 | |
}
|
5812 | |
}
|
5813 | |
|
5814 | |
return this;
|
5815 | |
},
|
5816 | |
|
5817 | |
empty: function() {
|
5818 | |
for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
|
5819 | |
// Remove element nodes and prevent memory leaks
|
5820 | |
if ( elem.nodeType === 1 ) {
|
5821 | |
jQuery.cleanData( elem.getElementsByTagName("*") );
|
5822 | |
}
|
5823 | |
|
5824 | |
// Remove any remaining nodes
|
5825 | |
while ( elem.firstChild ) {
|
5826 | |
elem.removeChild( elem.firstChild );
|
5827 | |
}
|
5828 | |
}
|
5829 | |
|
5830 | |
return this;
|
5831 | |
},
|
5832 | |
|
5833 | |
clone: function( dataAndEvents, deepDataAndEvents ) {
|
5834 | |
dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
|
5835 | |
deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
|
5836 | |
|
5837 | |
return this.map( function () {
|
5838 | |
return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
|
5839 | |
});
|
5840 | |
},
|
5841 | |
|
5842 | |
html: function( value ) {
|
5843 | |
if ( value === undefined ) {
|
5844 | |
return this[0] && this[0].nodeType === 1 ?
|
5845 | |
this[0].innerHTML.replace(rinlinejQuery, "") :
|
5846 | |
null;
|
5847 | |
|
5848 | |
// See if we can take a shortcut and just use innerHTML
|
5849 | |
} else if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
|
5850 | |
(jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
|
5851 | |
!wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
|
5852 | |
|
5853 | |
value = value.replace(rxhtmlTag, "<$1></$2>");
|
5854 | |
|
5855 | |
try {
|
5856 | |
for ( var i = 0, l = this.length; i < l; i++ ) {
|
5857 | |
// Remove element nodes and prevent memory leaks
|
5858 | |
if ( this[i].nodeType === 1 ) {
|
5859 | |
jQuery.cleanData( this[i].getElementsByTagName("*") );
|
5860 | |
this[i].innerHTML = value;
|
5861 | |
}
|
5862 | |
}
|
5863 | |
|
5864 | |
// If using innerHTML throws an exception, use the fallback method
|
5865 | |
} catch(e) {
|
5866 | |
this.empty().append( value );
|
5867 | |
}
|
5868 | |
|
5869 | |
} else if ( jQuery.isFunction( value ) ) {
|
5870 | |
this.each(function(i){
|
5871 | |
var self = jQuery( this );
|
5872 | |
|
5873 | |
self.html( value.call(this, i, self.html()) );
|
5874 | |
});
|
5875 | |
|
5876 | |
} else {
|
5877 | |
this.empty().append( value );
|
5878 | |
}
|
5879 | |
|
5880 | |
return this;
|
5881 | |
},
|
5882 | |
|
5883 | |
replaceWith: function( value ) {
|
5884 | |
if ( this[0] && this[0].parentNode ) {
|
5885 | |
// Make sure that the elements are removed from the DOM before they are inserted
|
5886 | |
// this can help fix replacing a parent with child elements
|
5887 | |
if ( jQuery.isFunction( value ) ) {
|
5888 | |
return this.each(function(i) {
|
5889 | |
var self = jQuery(this), old = self.html();
|
5890 | |
self.replaceWith( value.call( this, i, old ) );
|
5891 | |
});
|
5892 | |
}
|
5893 | |
|
5894 | |
if ( typeof value !== "string" ) {
|
5895 | |
value = jQuery( value ).detach();
|
5896 | |
}
|
5897 | |
|
5898 | |
return this.each(function() {
|
5899 | |
var next = this.nextSibling,
|
5900 | |
parent = this.parentNode;
|
5901 | |
|
5902 | |
jQuery( this ).remove();
|
5903 | |
|
5904 | |
if ( next ) {
|
5905 | |
jQuery(next).before( value );
|
5906 | |
} else {
|
5907 | |
jQuery(parent).append( value );
|
5908 | |
}
|
5909 | |
});
|
5910 | |
} else {
|
5911 | |
return this.length ?
|
5912 | |
this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) :
|
5913 | |
this;
|
5914 | |
}
|
5915 | |
},
|
5916 | |
|
5917 | |
detach: function( selector ) {
|
5918 | |
return this.remove( selector, true );
|
5919 | |
},
|
5920 | |
|
5921 | |
domManip: function( args, table, callback ) {
|
5922 | |
var results, first, fragment, parent,
|
5923 | |
value = args[0],
|
5924 | |
scripts = [];
|
5925 | |
|
5926 | |
// We can't cloneNode fragments that contain checked, in WebKit
|
5927 | |
if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) {
|
5928 | |
return this.each(function() {
|
5929 | |
jQuery(this).domManip( args, table, callback, true );
|
5930 | |
});
|
5931 | |
}
|
5932 | |
|
5933 | |
if ( jQuery.isFunction(value) ) {
|
5934 | |
return this.each(function(i) {
|
5935 | |
var self = jQuery(this);
|
5936 | |
args[0] = value.call(this, i, table ? self.html() : undefined);
|
5937 | |
self.domManip( args, table, callback );
|
5938 | |
});
|
5939 | |
}
|
5940 | |
|
5941 | |
if ( this[0] ) {
|
5942 | |
parent = value && value.parentNode;
|
5943 | |
|
5944 | |
// If we're in a fragment, just use that instead of building a new one
|
5945 | |
if ( jQuery.support.parentNode && parent && parent.nodeType === 11 && parent.childNodes.length === this.length ) {
|
5946 | |
results = { fragment: parent };
|
5947 | |
|
5948 | |
} else {
|
5949 | |
results = jQuery.buildFragment( args, this, scripts );
|
5950 | |
}
|
5951 | |
|
5952 | |
fragment = results.fragment;
|
5953 | |
|
5954 | |
if ( fragment.childNodes.length === 1 ) {
|
5955 | |
first = fragment = fragment.firstChild;
|
5956 | |
} else {
|
5957 | |
first = fragment.firstChild;
|
5958 | |
}
|
5959 | |
|
5960 | |
if ( first ) {
|
5961 | |
table = table && jQuery.nodeName( first, "tr" );
|
5962 | |
|
5963 | |
for ( var i = 0, l = this.length, lastIndex = l - 1; i < l; i++ ) {
|
5964 | |
callback.call(
|
5965 | |
table ?
|
5966 | |
root(this[i], first) :
|
5967 | |
this[i],
|
5968 | |
// Make sure that we do not leak memory by inadvertently discarding
|
5969 | |
// the original fragment (which might have attached data) instead of
|
5970 | |
// using it; in addition, use the original fragment object for the last
|
5971 | |
// item instead of first because it can end up being emptied incorrectly
|
5972 | |
// in certain situations (Bug #8070).
|
5973 | |
// Fragments from the fragment cache must always be cloned and never used
|
5974 | |
// in place.
|
5975 | |
results.cacheable || ( l > 1 && i < lastIndex ) ?
|
5976 | |
jQuery.clone( fragment, true, true ) :
|
5977 | |
fragment
|
5978 | |
);
|
5979 | |
}
|
5980 | |
}
|
5981 | |
|
5982 | |
if ( scripts.length ) {
|
5983 | |
jQuery.each( scripts, evalScript );
|
5984 | |
}
|
5985 | |
}
|
5986 | |
|
5987 | |
return this;
|
5988 | |
}
|
5989 | |
});
|
5990 | |
|
5991 | |
function root( elem, cur ) {
|
5992 | |
return jQuery.nodeName(elem, "table") ?
|
5993 | |
(elem.getElementsByTagName("tbody")[0] ||
|
5994 | |
elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
|
5995 | |
elem;
|
5996 | |
}
|
5997 | |
|
5998 | |
function cloneCopyEvent( src, dest ) {
|
5999 | |
|
6000 | |
if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
|
6001 | |
return;
|
6002 | |
}
|
6003 | |
|
6004 | |
var type, i, l,
|
6005 | |
oldData = jQuery._data( src ),
|
6006 | |
curData = jQuery._data( dest, oldData ),
|
6007 | |
events = oldData.events;
|
6008 | |
|
6009 | |
if ( events ) {
|
6010 | |
delete curData.handle;
|
6011 | |
curData.events = {};
|
6012 | |
|
6013 | |
for ( type in events ) {
|
6014 | |
for ( i = 0, l = events[ type ].length; i < l; i++ ) {
|
6015 | |
jQuery.event.add( dest, type + ( events[ type ][ i ].namespace ? "." : "" ) + events[ type ][ i ].namespace, events[ type ][ i ], events[ type ][ i ].data );
|
6016 | |
}
|
6017 | |
}
|
6018 | |
}
|
6019 | |
|
6020 | |
// make the cloned public data object a copy from the original
|
6021 | |
if ( curData.data ) {
|
6022 | |
curData.data = jQuery.extend( {}, curData.data );
|
6023 | |
}
|
6024 | |
}
|
6025 | |
|
6026 | |
function cloneFixAttributes( src, dest ) {
|
6027 | |
var nodeName;
|
6028 | |
|
6029 | |
// We do not need to do anything for non-Elements
|
6030 | |
if ( dest.nodeType !== 1 ) {
|
6031 | |
return;
|
6032 | |
}
|
6033 | |
|
6034 | |
// clearAttributes removes the attributes, which we don't want,
|
6035 | |
// but also removes the attachEvent events, which we *do* want
|
6036 | |
if ( dest.clearAttributes ) {
|
6037 | |
dest.clearAttributes();
|
6038 | |
}
|
6039 | |
|
6040 | |
// mergeAttributes, in contrast, only merges back on the
|
6041 | |
// original attributes, not the events
|
6042 | |
if ( dest.mergeAttributes ) {
|
6043 | |
dest.mergeAttributes( src );
|
6044 | |
}
|
6045 | |
|
6046 | |
nodeName = dest.nodeName.toLowerCase();
|
6047 | |
|
6048 | |
// IE6-8 fail to clone children inside object elements that use
|
6049 | |
// the proprietary classid attribute value (rather than the type
|
6050 | |
// attribute) to identify the type of content to display
|
6051 | |
if ( nodeName === "object" ) {
|
6052 | |
dest.outerHTML = src.outerHTML;
|
6053 | |
|
6054 | |
} else if ( nodeName === "input" && (src.type === "checkbox" || src.type === "radio") ) {
|
6055 | |
// IE6-8 fails to persist the checked state of a cloned checkbox
|
6056 | |
// or radio button. Worse, IE6-7 fail to give the cloned element
|
6057 | |
// a checked appearance if the defaultChecked value isn't also set
|
6058 | |
if ( src.checked ) {
|
6059 | |
dest.defaultChecked = dest.checked = src.checked;
|
6060 | |
}
|
6061 | |
|
6062 | |
// IE6-7 get confused and end up setting the value of a cloned
|
6063 | |
// checkbox/radio button to an empty string instead of "on"
|
6064 | |
if ( dest.value !== src.value ) {
|
6065 | |
dest.value = src.value;
|
6066 | |
}
|
6067 | |
|
6068 | |
// IE6-8 fails to return the selected option to the default selected
|
6069 | |
// state when cloning options
|
6070 | |
} else if ( nodeName === "option" ) {
|
6071 | |
dest.selected = src.defaultSelected;
|
6072 | |
|
6073 | |
// IE6-8 fails to set the defaultValue to the correct value when
|
6074 | |
// cloning other types of input fields
|
6075 | |
} else if ( nodeName === "input" || nodeName === "textarea" ) {
|
6076 | |
dest.defaultValue = src.defaultValue;
|
6077 | |
}
|
6078 | |
|
6079 | |
// Event data gets referenced instead of copied if the expando
|
6080 | |
// gets copied too
|
6081 | |
dest.removeAttribute( jQuery.expando );
|
6082 | |
}
|
6083 | |
|
6084 | |
jQuery.buildFragment = function( args, nodes, scripts ) {
|
6085 | |
var fragment, cacheable, cacheresults, doc,
|
6086 | |
first = args[ 0 ];
|
6087 | |
|
6088 | |
// nodes may contain either an explicit document object,
|
6089 | |
// a jQuery collection or context object.
|
6090 | |
// If nodes[0] contains a valid object to assign to doc
|
6091 | |
if ( nodes && nodes[0] ) {
|
6092 | |
doc = nodes[0].ownerDocument || nodes[0];
|
6093 | |
}
|
6094 | |
|
6095 | |
// Ensure that an attr object doesn't incorrectly stand in as a document object
|
6096 | |
// Chrome and Firefox seem to allow this to occur and will throw exception
|
6097 | |
// Fixes #8950
|
6098 | |
if ( !doc.createDocumentFragment ) {
|
6099 | |
doc = document;
|
6100 | |
}
|
6101 | |
|
6102 | |
// Only cache "small" (1/2 KB) HTML strings that are associated with the main document
|
6103 | |
// Cloning options loses the selected state, so don't cache them
|
6104 | |
// IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
|
6105 | |
// Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
|
6106 | |
// Lastly, IE6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501
|
6107 | |
if ( args.length === 1 && typeof first === "string" && first.length < 512 && doc === document &&
|
6108 | |
first.charAt(0) === "<" && !rnocache.test( first ) &&
|
6109 | |
(jQuery.support.checkClone || !rchecked.test( first )) &&
|
6110 | |
(jQuery.support.html5Clone || !rnoshimcache.test( first )) ) {
|
6111 | |
|
6112 | |
cacheable = true;
|
6113 | |
|
6114 | |
cacheresults = jQuery.fragments[ first ];
|
6115 | |
if ( cacheresults && cacheresults !== 1 ) {
|
6116 | |
fragment = cacheresults;
|
6117 | |
}
|
6118 | |
}
|
6119 | |
|
6120 | |
if ( !fragment ) {
|
6121 | |
fragment = doc.createDocumentFragment();
|
6122 | |
jQuery.clean( args, doc, fragment, scripts );
|
6123 | |
}
|
6124 | |
|
6125 | |
if ( cacheable ) {
|
6126 | |
jQuery.fragments[ first ] = cacheresults ? fragment : 1;
|
6127 | |
}
|
6128 | |
|
6129 | |
return { fragment: fragment, cacheable: cacheable };
|
6130 | |
};
|
6131 | |
|
6132 | |
jQuery.fragments = {};
|
6133 | |
|
6134 | |
jQuery.each({
|
6135 | |
appendTo: "append",
|
6136 | |
prependTo: "prepend",
|
6137 | |
insertBefore: "before",
|
6138 | |
insertAfter: "after",
|
6139 | |
replaceAll: "replaceWith"
|
6140 | |
}, function( name, original ) {
|
6141 | |
jQuery.fn[ name ] = function( selector ) {
|
6142 | |
var ret = [],
|
6143 | |
insert = jQuery( selector ),
|
6144 | |
parent = this.length === 1 && this[0].parentNode;
|
6145 | |
|
6146 | |
if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {
|
6147 | |
insert[ original ]( this[0] );
|
6148 | |
return this;
|
6149 | |
|
6150 | |
} else {
|
6151 | |
for ( var i = 0, l = insert.length; i < l; i++ ) {
|
6152 | |
var elems = ( i > 0 ? this.clone(true) : this ).get();
|
6153 | |
jQuery( insert[i] )[ original ]( elems );
|
6154 | |
ret = ret.concat( elems );
|
6155 | |
}
|
6156 | |
|
6157 | |
return this.pushStack( ret, name, insert.selector );
|
6158 | |
}
|
6159 | |
};
|
6160 | |
});
|
6161 | |
|
6162 | |
function getAll( elem ) {
|
6163 | |
if ( typeof elem.getElementsByTagName !== "undefined" ) {
|
6164 | |
return elem.getElementsByTagName( "*" );
|
6165 | |
|
6166 | |
} else if ( typeof elem.querySelectorAll !== "undefined" ) {
|
6167 | |
return elem.querySelectorAll( "*" );
|
6168 | |
|
6169 | |
} else {
|
6170 | |
return [];
|
6171 | |
}
|
6172 | |
}
|
6173 | |
|
6174 | |
// Used in clean, fixes the defaultChecked property
|
6175 | |
function fixDefaultChecked( elem ) {
|
6176 | |
if ( elem.type === "checkbox" || elem.type === "radio" ) {
|
6177 | |
elem.defaultChecked = elem.checked;
|
6178 | |
}
|
6179 | |
}
|
6180 | |
// Finds all inputs and passes them to fixDefaultChecked
|
6181 | |
function findInputs( elem ) {
|
6182 | |
var nodeName = ( elem.nodeName || "" ).toLowerCase();
|
6183 | |
if ( nodeName === "input" ) {
|
6184 | |
fixDefaultChecked( elem );
|
6185 | |
// Skip scripts, get other children
|
6186 | |
} else if ( nodeName !== "script" && typeof elem.getElementsByTagName !== "undefined" ) {
|
6187 | |
jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked );
|
6188 | |
}
|
6189 | |
}
|
6190 | |
|
6191 | |
// Derived From: http://www.iecss.com/shimprove/javascript/shimprove.1-0-1.js
|
6192 | |
function shimCloneNode( elem ) {
|
6193 | |
var div = document.createElement( "div" );
|
6194 | |
safeFragment.appendChild( div );
|
6195 | |
|
6196 | |
div.innerHTML = elem.outerHTML;
|
6197 | |
return div.firstChild;
|
6198 | |
}
|
6199 | |
|
6200 | |
jQuery.extend({
|
6201 | |
clone: function( elem, dataAndEvents, deepDataAndEvents ) {
|
6202 | |
var srcElements,
|
6203 | |
destElements,
|
6204 | |
i,
|
6205 | |
// IE<=8 does not properly clone detached, unknown element nodes
|
6206 | |
clone = jQuery.support.html5Clone || !rnoshimcache.test( "<" + elem.nodeName ) ?
|
6207 | |
elem.cloneNode( true ) :
|
6208 | |
shimCloneNode( elem );
|
6209 | |
|
6210 | |
if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
|
6211 | |
(elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
|
6212 | |
// IE copies events bound via attachEvent when using cloneNode.
|
6213 | |
// Calling detachEvent on the clone will also remove the events
|
6214 | |
// from the original. In order to get around this, we use some
|
6215 | |
// proprietary methods to clear the events. Thanks to MooTools
|
6216 | |
// guys for this hotness.
|
6217 | |
|
6218 | |
cloneFixAttributes( elem, clone );
|
6219 | |
|
6220 | |
// Using Sizzle here is crazy slow, so we use getElementsByTagName instead
|
6221 | |
srcElements = getAll( elem );
|
6222 | |
destElements = getAll( clone );
|
6223 | |
|
6224 | |
// Weird iteration because IE will replace the length property
|
6225 | |
// with an element if you are cloning the body and one of the
|
6226 | |
// elements on the page has a name or id of "length"
|
6227 | |
for ( i = 0; srcElements[i]; ++i ) {
|
6228 | |
// Ensure that the destination node is not null; Fixes #9587
|
6229 | |
if ( destElements[i] ) {
|
6230 | |
cloneFixAttributes( srcElements[i], destElements[i] );
|
6231 | |
}
|
6232 | |
}
|
6233 | |
}
|
6234 | |
|
6235 | |
// Copy the events from the original to the clone
|
6236 | |
if ( dataAndEvents ) {
|
6237 | |
cloneCopyEvent( elem, clone );
|
6238 | |
|
6239 | |
if ( deepDataAndEvents ) {
|
6240 | |
srcElements = getAll( elem );
|
6241 | |
destElements = getAll( clone );
|
6242 | |
|
6243 | |
for ( i = 0; srcElements[i]; ++i ) {
|
6244 | |
cloneCopyEvent( srcElements[i], destElements[i] );
|
6245 | |
}
|
6246 | |
}
|
6247 | |
}
|
6248 | |
|
6249 | |
srcElements = destElements = null;
|
6250 | |
|
6251 | |
// Return the cloned set
|
6252 | |
return clone;
|
6253 | |
},
|
6254 | |
|
6255 | |
clean: function( elems, context, fragment, scripts ) {
|
6256 | |
var checkScriptType;
|
6257 | |
|
6258 | |
context = context || document;
|
6259 | |
|
6260 | |
// !context.createElement fails in IE with an error but returns typeof 'object'
|
6261 | |
if ( typeof context.createElement === "undefined" ) {
|
6262 | |
context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
|
6263 | |
}
|
6264 | |
|
6265 | |
var ret = [], j;
|
6266 | |
|
6267 | |
for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
|
6268 | |
if ( typeof elem === "number" ) {
|
6269 | |
elem += "";
|
6270 | |
}
|
6271 | |
|
6272 | |
if ( !elem ) {
|
6273 | |
continue;
|
6274 | |
}
|
6275 | |
|
6276 | |
// Convert html string into DOM nodes
|
6277 | |
if ( typeof elem === "string" ) {
|
6278 | |
if ( !rhtml.test( elem ) ) {
|
6279 | |
elem = context.createTextNode( elem );
|
6280 | |
} else {
|
6281 | |
// Fix "XHTML"-style tags in all browsers
|
6282 | |
elem = elem.replace(rxhtmlTag, "<$1></$2>");
|
6283 | |
|
6284 | |
// Trim whitespace, otherwise indexOf won't work as expected
|
6285 | |
var tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase(),
|
6286 | |
wrap = wrapMap[ tag ] || wrapMap._default,
|
6287 | |
depth = wrap[0],
|
6288 | |
div = context.createElement("div");
|
6289 | |
|
6290 | |
// Append wrapper element to unknown element safe doc fragment
|
6291 | |
if ( context === document ) {
|
6292 | |
// Use the fragment we've already created for this document
|
6293 | |
safeFragment.appendChild( div );
|
6294 | |
} else {
|
6295 | |
// Use a fragment created with the owner document
|
6296 | |
createSafeFragment( context ).appendChild( div );
|
6297 | |
}
|
6298 | |
|
6299 | |
// Go to html and back, then peel off extra wrappers
|
6300 | |
div.innerHTML = wrap[1] + elem + wrap[2];
|
6301 | |
|
6302 | |
// Move to the right depth
|
6303 | |
while ( depth-- ) {
|
6304 | |
div = div.lastChild;
|
6305 | |
}
|
6306 | |
|
6307 | |
// Remove IE's autoinserted <tbody> from table fragments
|
6308 | |
if ( !jQuery.support.tbody ) {
|
6309 | |
|
6310 | |
// String was a <table>, *may* have spurious <tbody>
|
6311 | |
var hasBody = rtbody.test(elem),
|
6312 | |
tbody = tag === "table" && !hasBody ?
|
6313 | |
div.firstChild && div.firstChild.childNodes :
|
6314 | |
|
6315 | |
// String was a bare <thead> or <tfoot>
|
6316 | |
wrap[1] === "<table>" && !hasBody ?
|
6317 | |
div.childNodes :
|
6318 | |
[];
|
6319 | |
|
6320 | |
for ( j = tbody.length - 1; j >= 0 ; --j ) {
|
6321 | |
if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
|
6322 | |
tbody[ j ].parentNode.removeChild( tbody[ j ] );
|
6323 | |
}
|
6324 | |
}
|
6325 | |
}
|
6326 | |
|
6327 | |
// IE completely kills leading whitespace when innerHTML is used
|
6328 | |
if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
|
6329 | |
div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
|
6330 | |
}
|
6331 | |
|
6332 | |
elem = div.childNodes;
|
6333 | |
}
|
6334 | |
}
|
6335 | |
|
6336 | |
// Resets defaultChecked for any radios and checkboxes
|
6337 | |
// about to be appended to the DOM in IE 6/7 (#8060)
|
6338 | |
var len;
|
6339 | |
if ( !jQuery.support.appendChecked ) {
|
6340 | |
if ( elem[0] && typeof (len = elem.length) === "number" ) {
|
6341 | |
for ( j = 0; j < len; j++ ) {
|
6342 | |
findInputs( elem[j] );
|
6343 | |
}
|
6344 | |
} else {
|
6345 | |
findInputs( elem );
|
6346 | |
}
|
6347 | |
}
|
6348 | |
|
6349 | |
if ( elem.nodeType ) {
|
6350 | |
ret.push( elem );
|
6351 | |
} else {
|
6352 | |
ret = jQuery.merge( ret, elem );
|
6353 | |
}
|
6354 | |
}
|
6355 | |
|
6356 | |
if ( fragment ) {
|
6357 | |
checkScriptType = function( elem ) {
|
6358 | |
return !elem.type || rscriptType.test( elem.type );
|
6359 | |
};
|
6360 | |
for ( i = 0; ret[i]; i++ ) {
|
6361 | |
if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
|
6362 | |
scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
|
6363 | |
|
6364 | |
} else {
|
6365 | |
if ( ret[i].nodeType === 1 ) {
|
6366 | |
var jsTags = jQuery.grep( ret[i].getElementsByTagName( "script" ), checkScriptType );
|
6367 | |
|
6368 | |
ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
|
6369 | |
}
|
6370 | |
fragment.appendChild( ret[i] );
|
6371 | |
}
|
6372 | |
}
|
6373 | |
}
|
6374 | |
|
6375 | |
return ret;
|
6376 | |
},
|
6377 | |
|
6378 | |
cleanData: function( elems ) {
|
6379 | |
var data, id,
|
6380 | |
cache = jQuery.cache,
|
6381 | |
special = jQuery.event.special,
|
6382 | |
deleteExpando = jQuery.support.deleteExpando;
|
6383 | |
|
6384 | |
for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
|
6385 | |
if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
|
6386 | |
continue;
|
6387 | |
}
|
6388 | |
|
6389 | |
id = elem[ jQuery.expando ];
|
6390 | |
|
6391 | |
if ( id ) {
|
6392 | |
data = cache[ id ];
|
6393 | |
|
6394 | |
if ( data && data.events ) {
|
6395 | |
for ( var type in data.events ) {
|
6396 | |
if ( special[ type ] ) {
|
6397 | |
jQuery.event.remove( elem, type );
|
6398 | |
|
6399 | |
// This is a shortcut to avoid jQuery.event.remove's overhead
|
6400 | |
} else {
|
6401 | |
jQuery.removeEvent( elem, type, data.handle );
|
6402 | |
}
|
6403 | |
}
|
6404 | |
|
6405 | |
// Null the DOM reference to avoid IE6/7/8 leak (#7054)
|
6406 | |
if ( data.handle ) {
|
6407 | |
data.handle.elem = null;
|
6408 | |
}
|
6409 | |
}
|
6410 | |
|
6411 | |
if ( deleteExpando ) {
|
6412 | |
delete elem[ jQuery.expando ];
|
6413 | |
|
6414 | |
} else if ( elem.removeAttribute ) {
|
6415 | |
elem.removeAttribute( jQuery.expando );
|
6416 | |
}
|
6417 | |
|
6418 | |
delete cache[ id ];
|
6419 | |
}
|
6420 | |
}
|
6421 | |
}
|
6422 | |
});
|
6423 | |
|
6424 | |
function evalScript( i, elem ) {
|
6425 | |
if ( elem.src ) {
|
6426 | |
jQuery.ajax({
|
6427 | |
url: elem.src,
|
6428 | |
async: false,
|
6429 | |
dataType: "script"
|
6430 | |
});
|
6431 | |
} else {
|
6432 | |
jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "/*$0*/" ) );
|
6433 | |
}
|
6434 | |
|
6435 | |
if ( elem.parentNode ) {
|
6436 | |
elem.parentNode.removeChild( elem );
|
6437 | |
}
|
6438 | |
}
|
6439 | |
|
6440 | |
|
6441 | |
|
6442 | |
|
6443 | |
var ralpha = /alpha\([^)]*\)/i,
|
6444 | |
ropacity = /opacity=([^)]*)/,
|
6445 | |
// fixed for IE9, see #8346
|
6446 | |
rupper = /([A-Z]|^ms)/g,
|
6447 | |
rnumpx = /^-?\d+(?:px)?$/i,
|
6448 | |
rnum = /^-?\d/,
|
6449 | |
rrelNum = /^([\-+])=([\-+.\de]+)/,
|
6450 | |
|
6451 | |
cssShow = { position: "absolute", visibility: "hidden", display: "block" },
|
6452 | |
cssWidth = [ "Left", "Right" ],
|
6453 | |
cssHeight = [ "Top", "Bottom" ],
|
6454 | |
curCSS,
|
6455 | |
|
6456 | |
getComputedStyle,
|
6457 | |
currentStyle;
|
6458 | |
|
6459 | |
jQuery.fn.css = function( name, value ) {
|
6460 | |
// Setting 'undefined' is a no-op
|
6461 | |
if ( arguments.length === 2 && value === undefined ) {
|
6462 | |
return this;
|
6463 | |
}
|
6464 | |
|
6465 | |
return jQuery.access( this, name, value, true, function( elem, name, value ) {
|
6466 | |
return value !== undefined ?
|
6467 | |
jQuery.style( elem, name, value ) :
|
6468 | |
jQuery.css( elem, name );
|
6469 | |
});
|
6470 | |
};
|
6471 | |
|
6472 | |
jQuery.extend({
|
6473 | |
// Add in style property hooks for overriding the default
|
6474 | |
// behavior of getting and setting a style property
|
6475 | |
cssHooks: {
|
6476 | |
opacity: {
|
6477 | |
get: function( elem, computed ) {
|
6478 | |
if ( computed ) {
|
6479 | |
// We should always get a number back from opacity
|
6480 | |
var ret = curCSS( elem, "opacity", "opacity" );
|
6481 | |
return ret === "" ? "1" : ret;
|
6482 | |
|
6483 | |
} else {
|
6484 | |
return elem.style.opacity;
|
6485 | |
}
|
6486 | |
}
|
6487 | |
}
|
6488 | |
},
|
6489 | |
|
6490 | |
// Exclude the following css properties to add px
|
6491 | |
cssNumber: {
|
6492 | |
"fillOpacity": true,
|
6493 | |
"fontWeight": true,
|
6494 | |
"lineHeight": true,
|
6495 | |
"opacity": true,
|
6496 | |
"orphans": true,
|
6497 | |
"widows": true,
|
6498 | |
"zIndex": true,
|
6499 | |
"zoom": true
|
6500 | |
},
|
6501 | |
|
6502 | |
// Add in properties whose names you wish to fix before
|
6503 | |
// setting or getting the value
|
6504 | |
cssProps: {
|
6505 | |
// normalize float css property
|
6506 | |
"float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
|
6507 | |
},
|
6508 | |
|
6509 | |
// Get and set the style property on a DOM Node
|
6510 | |
style: function( elem, name, value, extra ) {
|
6511 | |
// Don't set styles on text and comment nodes
|
6512 | |
if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
|
6513 | |
return;
|
6514 | |
}
|
6515 | |
|
6516 | |
// Make sure that we're working with the right name
|
6517 | |
var ret, type, origName = jQuery.camelCase( name ),
|
6518 | |
style = elem.style, hooks = jQuery.cssHooks[ origName ];
|
6519 | |
|
6520 | |
name = jQuery.cssProps[ origName ] || origName;
|
6521 | |
|
6522 | |
// Check if we're setting a value
|
6523 | |
if ( value !== undefined ) {
|
6524 | |
type = typeof value;
|
6525 | |
|
6526 | |
// convert relative number strings (+= or -=) to relative numbers. #7345
|
6527 | |
if ( type === "string" && (ret = rrelNum.exec( value )) ) {
|
6528 | |
value = ( +( ret[1] + 1) * +ret[2] ) + parseFloat( jQuery.css( elem, name ) );
|
6529 | |
// Fixes bug #9237
|
6530 | |
type = "number";
|
6531 | |
}
|
6532 | |
|
6533 | |
// Make sure that NaN and null values aren't set. See: #7116
|
6534 | |
if ( value == null || type === "number" && isNaN( value ) ) {
|
6535 | |
return;
|
6536 | |
}
|
6537 | |
|
6538 | |
// If a number was passed in, add 'px' to the (except for certain CSS properties)
|
6539 | |
if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
|
6540 | |
value += "px";
|
6541 | |
}
|
6542 | |
|
6543 | |
// If a hook was provided, use that value, otherwise just set the specified value
|
6544 | |
if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value )) !== undefined ) {
|
6545 | |
// Wrapped to prevent IE from throwing errors when 'invalid' values are provided
|
6546 | |
// Fixes bug #5509
|
6547 | |
try {
|
6548 | |
style[ name ] = value;
|
6549 | |
} catch(e) {}
|
6550 | |
}
|
6551 | |
|
6552 | |
} else {
|
6553 | |
// If a hook was provided get the non-computed value from there
|
6554 | |
if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
|
6555 | |
return ret;
|
6556 | |
}
|
6557 | |
|
6558 | |
// Otherwise just get the value from the style object
|
6559 | |
return style[ name ];
|
6560 | |
}
|
6561 | |
},
|
6562 | |
|
6563 | |
css: function( elem, name, extra ) {
|
6564 | |
var ret, hooks;
|
6565 | |
|
6566 | |
// Make sure that we're working with the right name
|
6567 | |
name = jQuery.camelCase( name );
|
6568 | |
hooks = jQuery.cssHooks[ name ];
|
6569 | |
name = jQuery.cssProps[ name ] || name;
|
6570 | |
|
6571 | |
// cssFloat needs a special treatment
|
6572 | |
if ( name === "cssFloat" ) {
|
6573 | |
name = "float";
|
6574 | |
}
|
6575 | |
|
6576 | |
// If a hook was provided get the computed value from there
|
6577 | |
if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) {
|
6578 | |
return ret;
|
6579 | |
|
6580 | |
// Otherwise, if a way to get the computed value exists, use that
|
6581 | |
} else if ( curCSS ) {
|
6582 | |
return curCSS( elem, name );
|
6583 | |
}
|
6584 | |
},
|
6585 | |
|
6586 | |
// A method for quickly swapping in/out CSS properties to get correct calculations
|
6587 | |
swap: function( elem, options, callback ) {
|
6588 | |
var old = {};
|
6589 | |
|
6590 | |
// Remember the old values, and insert the new ones
|
6591 | |
for ( var name in options ) {
|
6592 | |
old[ name ] = elem.style[ name ];
|
6593 | |
elem.style[ name ] = options[ name ];
|
6594 | |
}
|
6595 | |
|
6596 | |
callback.call( elem );
|
6597 | |
|
6598 | |
// Revert the old values
|
6599 | |
for ( name in options ) {
|
6600 | |
elem.style[ name ] = old[ name ];
|
6601 | |
}
|
6602 | |
}
|
6603 | |
});
|
6604 | |
|
6605 | |
// DEPRECATED, Use jQuery.css() instead
|
6606 | |
jQuery.curCSS = jQuery.css;
|
6607 | |
|
6608 | |
jQuery.each(["height", "width"], function( i, name ) {
|
6609 | |
jQuery.cssHooks[ name ] = {
|
6610 | |
get: function( elem, computed, extra ) {
|
6611 | |
var val;
|
6612 | |
|
6613 | |
if ( computed ) {
|
6614 | |
if ( elem.offsetWidth !== 0 ) {
|
6615 | |
return getWH( elem, name, extra );
|
6616 | |
} else {
|
6617 | |
jQuery.swap( elem, cssShow, function() {
|
6618 | |
val = getWH( elem, name, extra );
|
6619 | |
});
|
6620 | |
}
|
6621 | |
|
6622 | |
return val;
|
6623 | |
}
|
6624 | |
},
|
6625 | |
|
6626 | |
set: function( elem, value ) {
|
6627 | |
if ( rnumpx.test( value ) ) {
|
6628 | |
// ignore negative width and height values #1599
|
6629 | |
value = parseFloat( value );
|
6630 | |
|
6631 | |
if ( value >= 0 ) {
|
6632 | |
return value + "px";
|
6633 | |
}
|
6634 | |
|
6635 | |
} else {
|
6636 | |
return value;
|
6637 | |
}
|
6638 | |
}
|
6639 | |
};
|
6640 | |
});
|
6641 | |
|
6642 | |
if ( !jQuery.support.opacity ) {
|
6643 | |
jQuery.cssHooks.opacity = {
|
6644 | |
get: function( elem, computed ) {
|
6645 | |
// IE uses filters for opacity
|
6646 | |
return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
|
6647 | |
( parseFloat( RegExp.$1 ) / 100 ) + "" :
|
6648 | |
computed ? "1" : "";
|
6649 | |
},
|
6650 | |
|
6651 | |
set: function( elem, value ) {
|
6652 | |
var style = elem.style,
|
6653 | |
currentStyle = elem.currentStyle,
|
6654 | |
opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
|
6655 | |
filter = currentStyle && currentStyle.filter || style.filter || "";
|
6656 | |
|
6657 | |
// IE has trouble with opacity if it does not have layout
|
6658 | |
// Force it by setting the zoom level
|
6659 | |
style.zoom = 1;
|
6660 | |
|
6661 | |
// if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
|
6662 | |
if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" ) {
|
6663 | |
|
6664 | |
// Setting style.filter to null, "" & " " still leave "filter:" in the cssText
|
6665 | |
// if "filter:" is present at all, clearType is disabled, we want to avoid this
|
6666 | |
// style.removeAttribute is IE Only, but so apparently is this code path...
|
6667 | |
style.removeAttribute( "filter" );
|
6668 | |
|
6669 | |
// if there there is no filter style applied in a css rule, we are done
|
6670 | |
if ( currentStyle && !currentStyle.filter ) {
|
6671 | |
return;
|
6672 | |
}
|
6673 | |
}
|
6674 | |
|
6675 | |
// otherwise, set new filter values
|
6676 | |
style.filter = ralpha.test( filter ) ?
|
6677 | |
filter.replace( ralpha, opacity ) :
|
6678 | |
filter + " " + opacity;
|
6679 | |
}
|
6680 | |
};
|
6681 | |
}
|
6682 | |
|
6683 | |
jQuery(function() {
|
6684 | |
// This hook cannot be added until DOM ready because the support test
|
6685 | |
// for it is not run until after DOM ready
|
6686 | |
if ( !jQuery.support.reliableMarginRight ) {
|
6687 | |
jQuery.cssHooks.marginRight = {
|
6688 | |
get: function( elem, computed ) {
|
6689 | |
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
|
6690 | |
// Work around by temporarily setting element display to inline-block
|
6691 | |
var ret;
|
6692 | |
jQuery.swap( elem, { "display": "inline-block" }, function() {
|
6693 | |
if ( computed ) {
|
6694 | |
ret = curCSS( elem, "margin-right", "marginRight" );
|
6695 | |
} else {
|
6696 | |
ret = elem.style.marginRight;
|
6697 | |
}
|
6698 | |
});
|
6699 | |
return ret;
|
6700 | |
}
|
6701 | |
};
|
6702 | |
}
|
6703 | |
});
|
6704 | |
|
6705 | |
if ( document.defaultView && document.defaultView.getComputedStyle ) {
|
6706 | |
getComputedStyle = function( elem, name ) {
|
6707 | |
var ret, defaultView, computedStyle;
|
6708 | |
|
6709 | |
name = name.replace( rupper, "-$1" ).toLowerCase();
|
6710 | |
|
6711 | |
if ( (defaultView = elem.ownerDocument.defaultView) &&
|
6712 | |
(computedStyle = defaultView.getComputedStyle( elem, null )) ) {
|
6713 | |
ret = computedStyle.getPropertyValue( name );
|
6714 | |
if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
|
6715 | |
ret = jQuery.style( elem, name );
|
6716 | |
}
|
6717 | |
}
|
6718 | |
|
6719 | |
return ret;
|
6720 | |
};
|
6721 | |
}
|
6722 | |
|
6723 | |
if ( document.documentElement.currentStyle ) {
|
6724 | |
currentStyle = function( elem, name ) {
|
6725 | |
var left, rsLeft, uncomputed,
|
6726 | |
ret = elem.currentStyle && elem.currentStyle[ name ],
|
6727 | |
style = elem.style;
|
6728 | |
|
6729 | |
// Avoid setting ret to empty string here
|
6730 | |
// so we don't default to auto
|
6731 | |
if ( ret === null && style && (uncomputed = style[ name ]) ) {
|
6732 | |
ret = uncomputed;
|
6733 | |
}
|
6734 | |
|
6735 | |
// From the awesome hack by Dean Edwards
|
6736 | |
// http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
|
6737 | |
|
6738 | |
// If we're not dealing with a regular pixel number
|
6739 | |
// but a number that has a weird ending, we need to convert it to pixels
|
6740 | |
if ( !rnumpx.test( ret ) && rnum.test( ret ) ) {
|
6741 | |
|
6742 | |
// Remember the original values
|
6743 | |
left = style.left;
|
6744 | |
rsLeft = elem.runtimeStyle && elem.runtimeStyle.left;
|
6745 | |
|
6746 | |
// Put in the new values to get a computed value out
|
6747 | |
if ( rsLeft ) {
|
6748 | |
elem.runtimeStyle.left = elem.currentStyle.left;
|
6749 | |
}
|
6750 | |
style.left = name === "fontSize" ? "1em" : ( ret || 0 );
|
6751 | |
ret = style.pixelLeft + "px";
|
6752 | |
|
6753 | |
// Revert the changed values
|
6754 | |
style.left = left;
|
6755 | |
if ( rsLeft ) {
|
6756 | |
elem.runtimeStyle.left = rsLeft;
|
6757 | |
}
|
6758 | |
}
|
6759 | |
|
6760 | |
return ret === "" ? "auto" : ret;
|
6761 | |
};
|
6762 | |
}
|
6763 | |
|
6764 | |
curCSS = getComputedStyle || currentStyle;
|
6765 | |
|
6766 | |
function getWH( elem, name, extra ) {
|
6767 | |
|
6768 | |
// Start with offset property
|
6769 | |
var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
|
6770 | |
which = name === "width" ? cssWidth : cssHeight,
|
6771 | |
i = 0,
|
6772 | |
len = which.length;
|
6773 | |
|
6774 | |
if ( val > 0 ) {
|
6775 | |
if ( extra !== "border" ) {
|
6776 | |
for ( ; i < len; i++ ) {
|
6777 | |
if ( !extra ) {
|
6778 | |
val -= parseFloat( jQuery.css( elem, "padding" + which[ i ] ) ) || 0;
|
6779 | |
}
|
6780 | |
if ( extra === "margin" ) {
|
6781 | |
val += parseFloat( jQuery.css( elem, extra + which[ i ] ) ) || 0;
|
6782 | |
} else {
|
6783 | |
val -= parseFloat( jQuery.css( elem, "border" + which[ i ] + "Width" ) ) || 0;
|
6784 | |
}
|
6785 | |
}
|
6786 | |
}
|
6787 | |
|
6788 | |
return val + "px";
|
6789 | |
}
|
6790 | |
|
6791 | |
// Fall back to computed then uncomputed css if necessary
|
6792 | |
val = curCSS( elem, name, name );
|
6793 | |
if ( val < 0 || val == null ) {
|
6794 | |
val = elem.style[ name ] || 0;
|
6795 | |
}
|
6796 | |
// Normalize "", auto, and prepare for extra
|
6797 | |
val = parseFloat( val ) || 0;
|
6798 | |
|
6799 | |
// Add padding, border, margin
|
6800 | |
if ( extra ) {
|
6801 | |
for ( ; i < len; i++ ) {
|
6802 | |
val += parseFloat( jQuery.css( elem, "padding" + which[ i ] ) ) || 0;
|
6803 | |
if ( extra !== "padding" ) {
|
6804 | |
val += parseFloat( jQuery.css( elem, "border" + which[ i ] + "Width" ) ) || 0;
|
6805 | |
}
|
6806 | |
if ( extra === "margin" ) {
|
6807 | |
val += parseFloat( jQuery.css( elem, extra + which[ i ] ) ) || 0;
|
6808 | |
}
|
6809 | |
}
|
6810 | |
}
|
6811 | |
|
6812 | |
return val + "px";
|
6813 | |
}
|
6814 | |
|
6815 | |
if ( jQuery.expr && jQuery.expr.filters ) {
|
6816 | |
jQuery.expr.filters.hidden = function( elem ) {
|
6817 | |
var width = elem.offsetWidth,
|
6818 | |
height = elem.offsetHeight;
|
6819 | |
|
6820 | |
return ( width === 0 && height === 0 ) || (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none");
|
6821 | |
};
|
6822 | |
|
6823 | |
jQuery.expr.filters.visible = function( elem ) {
|
6824 | |
return !jQuery.expr.filters.hidden( elem );
|
6825 | |
};
|
6826 | |
}
|
6827 | |
|
6828 | |
|
6829 | |
|
6830 | |
|
6831 | |
var r20 = /%20/g,
|
6832 | |
rbracket = /\[\]$/,
|
6833 | |
rCRLF = /\r?\n/g,
|
6834 | |
rhash = /#.*$/,
|
6835 | |
rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
|
6836 | |
rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
|
6837 | |
// #7653, #8125, #8152: local protocol detection
|
6838 | |
rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,
|
6839 | |
rnoContent = /^(?:GET|HEAD)$/,
|
6840 | |
rprotocol = /^\/\//,
|
6841 | |
rquery = /\?/,
|
6842 | |
rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
|
6843 | |
rselectTextarea = /^(?:select|textarea)/i,
|
6844 | |
rspacesAjax = /\s+/,
|
6845 | |
rts = /([?&])_=[^&]*/,
|
6846 | |
rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,
|
6847 | |
|
6848 | |
// Keep a copy of the old load method
|
6849 | |
_load = jQuery.fn.load,
|
6850 | |
|
6851 | |
/* Prefilters
|
6852 | |
* 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
|
6853 | |
* 2) These are called:
|
6854 | |
* - BEFORE asking for a transport
|
6855 | |
* - AFTER param serialization (s.data is a string if s.processData is true)
|
6856 | |
* 3) key is the dataType
|
6857 | |
* 4) the catchall symbol "*" can be used
|
6858 | |
* 5) execution will start with transport dataType and THEN continue down to "*" if needed
|
6859 | |
*/
|
6860 | |
prefilters = {},
|
6861 | |
|
6862 | |
/* Transports bindings
|
6863 | |
* 1) key is the dataType
|
6864 | |
* 2) the catchall symbol "*" can be used
|
6865 | |
* 3) selection will start with transport dataType and THEN go to "*" if needed
|
6866 | |
*/
|
6867 | |
transports = {},
|
6868 | |
|
6869 | |
// Document location
|
6870 | |
ajaxLocation,
|
6871 | |
|
6872 | |
// Document location segments
|
6873 | |
ajaxLocParts,
|
6874 | |
|
6875 | |
// Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
|
6876 | |
allTypes = ["*/"] + ["*"];
|
6877 | |
|
6878 | |
// #8138, IE may throw an exception when accessing
|
6879 | |
// a field from window.location if document.domain has been set
|
6880 | |
try {
|
6881 | |
ajaxLocation = location.href;
|
6882 | |
} catch( e ) {
|
6883 | |
// Use the href attribute of an A element
|
6884 | |
// since IE will modify it given document.location
|
6885 | |
ajaxLocation = document.createElement( "a" );
|
6886 | |
ajaxLocation.href = "";
|
6887 | |
ajaxLocation = ajaxLocation.href;
|
6888 | |
}
|
6889 | |
|
6890 | |
// Segment location into parts
|
6891 | |
ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
|
6892 | |
|
6893 | |
// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
|
6894 | |
function addToPrefiltersOrTransports( structure ) {
|
6895 | |
|
6896 | |
// dataTypeExpression is optional and defaults to "*"
|
6897 | |
return function( dataTypeExpression, func ) {
|
6898 | |
|
6899 | |
if ( typeof dataTypeExpression !== "string" ) {
|
6900 | |
func = dataTypeExpression;
|
6901 | |
dataTypeExpression = "*";
|
6902 | |
}
|
6903 | |
|
6904 | |
if ( jQuery.isFunction( func ) ) {
|
6905 | |
var dataTypes = dataTypeExpression.toLowerCase().split( rspacesAjax ),
|
6906 | |
i = 0,
|
6907 | |
length = dataTypes.length,
|
6908 | |
dataType,
|
6909 | |
list,
|
6910 | |
placeBefore;
|
6911 | |
|
6912 | |
// For each dataType in the dataTypeExpression
|
6913 | |
for ( ; i < length; i++ ) {
|
6914 | |
dataType = dataTypes[ i ];
|
6915 | |
// We control if we're asked to add before
|
6916 | |
// any existing element
|
6917 | |
placeBefore = /^\+/.test( dataType );
|
6918 | |
if ( placeBefore ) {
|
6919 | |
dataType = dataType.substr( 1 ) || "*";
|
6920 | |
}
|
6921 | |
list = structure[ dataType ] = structure[ dataType ] || [];
|
6922 | |
// then we add to the structure accordingly
|
6923 | |
list[ placeBefore ? "unshift" : "push" ]( func );
|
6924 | |
}
|
6925 | |
}
|
6926 | |
};
|
6927 | |
}
|
6928 | |
|
6929 | |
// Base inspection function for prefilters and transports
|
6930 | |
function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,
|
6931 | |
dataType /* internal */, inspected /* internal */ ) {
|
6932 | |
|
6933 | |
dataType = dataType || options.dataTypes[ 0 ];
|
6934 | |
inspected = inspected || {};
|
6935 | |
|
6936 | |
inspected[ dataType ] = true;
|
6937 | |
|
6938 | |
var list = structure[ dataType ],
|
6939 | |
i = 0,
|
6940 | |
length = list ? list.length : 0,
|
6941 | |
executeOnly = ( structure === prefilters ),
|
6942 | |
selection;
|
6943 | |
|
6944 | |
for ( ; i < length && ( executeOnly || !selection ); i++ ) {
|
6945 | |
selection = list[ i ]( options, originalOptions, jqXHR );
|
6946 | |
// If we got redirected to another dataType
|
6947 | |
// we try there if executing only and not done already
|
6948 | |
if ( typeof selection === "string" ) {
|
6949 | |
if ( !executeOnly || inspected[ selection ] ) {
|
6950 | |
selection = undefined;
|
6951 | |
} else {
|
6952 | |
options.dataTypes.unshift( selection );
|
6953 | |
selection = inspectPrefiltersOrTransports(
|
6954 | |
structure, options, originalOptions, jqXHR, selection, inspected );
|
6955 | |
}
|
6956 | |
}
|
6957 | |
}
|
6958 | |
// If we're only executing or nothing was selected
|
6959 | |
// we try the catchall dataType if not done already
|
6960 | |
if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) {
|
6961 | |
selection = inspectPrefiltersOrTransports(
|
6962 | |
structure, options, originalOptions, jqXHR, "*", inspected );
|
6963 | |
}
|
6964 | |
// unnecessary when only executing (prefilters)
|
6965 | |
// but it'll be ignored by the caller in that case
|
6966 | |
return selection;
|
6967 | |
}
|
6968 | |
|
6969 | |
// A special extend for ajax options
|
6970 | |
// that takes "flat" options (not to be deep extended)
|
6971 | |
// Fixes #9887
|
6972 | |
function ajaxExtend( target, src ) {
|
6973 | |
var key, deep,
|
6974 | |
flatOptions = jQuery.ajaxSettings.flatOptions || {};
|
6975 | |
for ( key in src ) {
|
6976 | |
if ( src[ key ] !== undefined ) {
|
6977 | |
( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
|
6978 | |
}
|
6979 | |
}
|
6980 | |
if ( deep ) {
|
6981 | |
jQuery.extend( true, target, deep );
|
6982 | |
}
|
6983 | |
}
|
6984 | |
|
6985 | |
jQuery.fn.extend({
|
6986 | |
load: function( url, params, callback ) {
|
6987 | |
if ( typeof url !== "string" && _load ) {
|
6988 | |
return _load.apply( this, arguments );
|
6989 | |
|
6990 | |
// Don't do a request if no elements are being requested
|
6991 | |
} else if ( !this.length ) {
|
6992 | |
return this;
|
6993 | |
}
|
6994 | |
|
6995 | |
var off = url.indexOf( " " );
|
6996 | |
if ( off >= 0 ) {
|
6997 | |
var selector = url.slice( off, url.length );
|
6998 | |
url = url.slice( 0, off );
|
6999 | |
}
|
7000 | |
|
7001 | |
// Default to a GET request
|
7002 | |
var type = "GET";
|
7003 | |
|
7004 | |
// If the second parameter was provided
|
7005 | |
if ( params ) {
|
7006 | |
// If it's a function
|
7007 | |
if ( jQuery.isFunction( params ) ) {
|
7008 | |
// We assume that it's the callback
|
7009 | |
callback = params;
|
7010 | |
params = undefined;
|
7011 | |
|
7012 | |
// Otherwise, build a param string
|
7013 | |
} else if ( typeof params === "object" ) {
|
7014 | |
params = jQuery.param( params, jQuery.ajaxSettings.traditional );
|
7015 | |
type = "POST";
|
7016 | |
}
|
7017 | |
}
|
7018 | |
|
7019 | |
var self = this;
|
7020 | |
|
7021 | |
// Request the remote document
|
7022 | |
jQuery.ajax({
|
7023 | |
url: url,
|
7024 | |
type: type,
|
7025 | |
dataType: "html",
|
7026 | |
data: params,
|
7027 | |
// Complete callback (responseText is used internally)
|
7028 | |
complete: function( jqXHR, status, responseText ) {
|
7029 | |
// Store the response as specified by the jqXHR object
|
7030 | |
responseText = jqXHR.responseText;
|
7031 | |
// If successful, inject the HTML into all the matched elements
|
7032 | |
if ( jqXHR.isResolved() ) {
|
7033 | |
// #4825: Get the actual response in case
|
7034 | |
// a dataFilter is present in ajaxSettings
|
7035 | |
jqXHR.done(function( r ) {
|
7036 | |
responseText = r;
|
7037 | |
});
|
7038 | |
// See if a selector was specified
|
7039 | |
self.html( selector ?
|
7040 | |
// Create a dummy div to hold the results
|
7041 | |
jQuery("<div>")
|
7042 | |
// inject the contents of the document in, removing the scripts
|
7043 | |
// to avoid any 'Permission Denied' errors in IE
|
7044 | |
.append(responseText.replace(rscript, ""))
|
7045 | |
|
7046 | |
// Locate the specified elements
|
7047 | |
.find(selector) :
|
7048 | |
|
7049 | |
// If not, just inject the full result
|
7050 | |
responseText );
|
7051 | |
}
|
7052 | |
|
7053 | |
if ( callback ) {
|
7054 | |
self.each( callback, [ responseText, status, jqXHR ] );
|
7055 | |
}
|
7056 | |
}
|
7057 | |
});
|
7058 | |
|
7059 | |
return this;
|
7060 | |
},
|
7061 | |
|
7062 | |
serialize: function() {
|
7063 | |
return jQuery.param( this.serializeArray() );
|
7064 | |
},
|
7065 | |
|
7066 | |
serializeArray: function() {
|
7067 | |
return this.map(function(){
|
7068 | |
return this.elements ? jQuery.makeArray( this.elements ) : this;
|
7069 | |
})
|
7070 | |
.filter(function(){
|
7071 | |
return this.name && !this.disabled &&
|
7072 | |
( this.checked || rselectTextarea.test( this.nodeName ) ||
|
7073 | |
rinput.test( this.type ) );
|
7074 | |
})
|
7075 | |
.map(function( i, elem ){
|
7076 | |
var val = jQuery( this ).val();
|
7077 | |
|
7078 | |
return val == null ?
|
7079 | |
null :
|
7080 | |
jQuery.isArray( val ) ?
|
7081 | |
jQuery.map( val, function( val, i ){
|
7082 | |
return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
|
7083 | |
}) :
|
7084 | |
{ name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
|
7085 | |
}).get();
|
7086 | |
}
|
7087 | |
});
|
7088 | |
|
7089 | |
// Attach a bunch of functions for handling common AJAX events
|
7090 | |
jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){
|
7091 | |
jQuery.fn[ o ] = function( f ){
|
7092 | |
return this.on( o, f );
|
7093 | |
};
|
7094 | |
});
|
7095 | |
|
7096 | |
jQuery.each( [ "get", "post" ], function( i, method ) {
|
7097 | |
jQuery[ method ] = function( url, data, callback, type ) {
|
7098 | |
// shift arguments if data argument was omitted
|
7099 | |
if ( jQuery.isFunction( data ) ) {
|
7100 | |
type = type || callback;
|
7101 | |
callback = data;
|
7102 | |
data = undefined;
|
7103 | |
}
|
7104 | |
|
7105 | |
return jQuery.ajax({
|
7106 | |
type: method,
|
7107 | |
url: url,
|
7108 | |
data: data,
|
7109 | |
success: callback,
|
7110 | |
dataType: type
|
7111 | |
});
|
7112 | |
};
|
7113 | |
});
|
7114 | |
|
7115 | |
jQuery.extend({
|
7116 | |
|
7117 | |
getScript: function( url, callback ) {
|
7118 | |
return jQuery.get( url, undefined, callback, "script" );
|
7119 | |
},
|
7120 | |
|
7121 | |
getJSON: function( url, data, callback ) {
|
7122 | |
return jQuery.get( url, data, callback, "json" );
|
7123 | |
},
|
7124 | |
|
7125 | |
// Creates a full fledged settings object into target
|
7126 | |
// with both ajaxSettings and settings fields.
|
7127 | |
// If target is omitted, writes into ajaxSettings.
|
7128 | |
ajaxSetup: function( target, settings ) {
|
7129 | |
if ( settings ) {
|
7130 | |
// Building a settings object
|
7131 | |
ajaxExtend( target, jQuery.ajaxSettings );
|
7132 | |
} else {
|
7133 | |
// Extending ajaxSettings
|
7134 | |
settings = target;
|
7135 | |
target = jQuery.ajaxSettings;
|
7136 | |
}
|
7137 | |
ajaxExtend( target, settings );
|
7138 | |
return target;
|
7139 | |
},
|
7140 | |
|
7141 | |
ajaxSettings: {
|
7142 | |
url: ajaxLocation,
|
7143 | |
isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
|
7144 | |
global: true,
|
7145 | |
type: "GET",
|
7146 | |
contentType: "application/x-www-form-urlencoded",
|
7147 | |
processData: true,
|
7148 | |
async: true,
|
7149 | |
/*
|
7150 | |
timeout: 0,
|
7151 | |
data: null,
|
7152 | |
dataType: null,
|
7153 | |
username: null,
|
7154 | |
password: null,
|
7155 | |
cache: null,
|
7156 | |
traditional: false,
|
7157 | |
headers: {},
|
7158 | |
*/
|
7159 | |
|
7160 | |
accepts: {
|
7161 | |
xml: "application/xml, text/xml",
|
7162 | |
html: "text/html",
|
7163 | |
text: "text/plain",
|
7164 | |
json: "application/json, text/javascript",
|
7165 | |
"*": allTypes
|
7166 | |
},
|
7167 | |
|
7168 | |
contents: {
|
7169 | |
xml: /xml/,
|
7170 | |
html: /html/,
|
7171 | |
json: /json/
|
7172 | |
},
|
7173 | |
|
7174 | |
responseFields: {
|
7175 | |
xml: "responseXML",
|
7176 | |
text: "responseText"
|
7177 | |
},
|
7178 | |
|
7179 | |
// List of data converters
|
7180 | |
// 1) key format is "source_type destination_type" (a single space in-between)
|
7181 | |
// 2) the catchall symbol "*" can be used for source_type
|
7182 | |
converters: {
|
7183 | |
|
7184 | |
// Convert anything to text
|
7185 | |
"* text": window.String,
|
7186 | |
|
7187 | |
// Text to html (true = no transformation)
|
7188 | |
"text html": true,
|
7189 | |
|
7190 | |
// Evaluate text as a json expression
|
7191 | |
"text json": jQuery.parseJSON,
|
7192 | |
|
7193 | |
// Parse text as xml
|
7194 | |
"text xml": jQuery.parseXML
|
7195 | |
},
|
7196 | |
|
7197 | |
// For options that shouldn't be deep extended:
|
7198 | |
// you can add your own custom options here if
|
7199 | |
// and when you create one that shouldn't be
|
7200 | |
// deep extended (see ajaxExtend)
|
7201 | |
flatOptions: {
|
7202 | |
context: true,
|
7203 | |
url: true
|
7204 | |
}
|
7205 | |
},
|
7206 | |
|
7207 | |
ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
|
7208 | |
ajaxTransport: addToPrefiltersOrTransports( transports ),
|
7209 | |
|
7210 | |
// Main method
|
7211 | |
ajax: function( url, options ) {
|
7212 | |
|
7213 | |
// If url is an object, simulate pre-1.5 signature
|
7214 | |
if ( typeof url === "object" ) {
|
7215 | |
options = url;
|
7216 | |
url = undefined;
|
7217 | |
}
|
7218 | |
|
7219 | |
// Force options to be an object
|
7220 | |
options = options || {};
|
7221 | |
|
7222 | |
var // Create the final options object
|
7223 | |
s = jQuery.ajaxSetup( {}, options ),
|
7224 | |
// Callbacks context
|
7225 | |
callbackContext = s.context || s,
|
7226 | |
// Context for global events
|
7227 | |
// It's the callbackContext if one was provided in the options
|
7228 | |
// and if it's a DOM node or a jQuery collection
|
7229 | |
globalEventContext = callbackContext !== s &&
|
7230 | |
( callbackContext.nodeType || callbackContext instanceof jQuery ) ?
|
7231 | |
jQuery( callbackContext ) : jQuery.event,
|
7232 | |
// Deferreds
|
7233 | |
deferred = jQuery.Deferred(),
|
7234 | |
completeDeferred = jQuery.Callbacks( "once memory" ),
|
7235 | |
// Status-dependent callbacks
|
7236 | |
statusCode = s.statusCode || {},
|
7237 | |
// ifModified key
|
7238 | |
ifModifiedKey,
|
7239 | |
// Headers (they are sent all at once)
|
7240 | |
requestHeaders = {},
|
7241 | |
requestHeadersNames = {},
|
7242 | |
// Response headers
|
7243 | |
responseHeadersString,
|
7244 | |
responseHeaders,
|
7245 | |
// transport
|
7246 | |
transport,
|
7247 | |
// timeout handle
|
7248 | |
timeoutTimer,
|
7249 | |
// Cross-domain detection vars
|
7250 | |
parts,
|
7251 | |
// The jqXHR state
|
7252 | |
state = 0,
|
7253 | |
// To know if global events are to be dispatched
|
7254 | |
fireGlobals,
|
7255 | |
// Loop variable
|
7256 | |
i,
|
7257 | |
// Fake xhr
|
7258 | |
jqXHR = {
|
7259 | |
|
7260 | |
readyState: 0,
|
7261 | |
|
7262 | |
// Caches the header
|
7263 | |
setRequestHeader: function( name, value ) {
|
7264 | |
if ( !state ) {
|
7265 | |
var lname = name.toLowerCase();
|
7266 | |
name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
|
7267 | |
requestHeaders[ name ] = value;
|
7268 | |
}
|
7269 | |
return this;
|
7270 | |
},
|
7271 | |
|
7272 | |
// Raw string
|
7273 | |
getAllResponseHeaders: function() {
|
7274 | |
return state === 2 ? responseHeadersString : null;
|
7275 | |
},
|
7276 | |
|
7277 | |
// Builds headers hashtable if needed
|
7278 | |
getResponseHeader: function( key ) {
|
7279 | |
var match;
|
7280 | |
if ( state === 2 ) {
|
7281 | |
if ( !responseHeaders ) {
|
7282 | |
responseHeaders = {};
|
7283 | |
while( ( match = rheaders.exec( responseHeadersString ) ) ) {
|
7284 | |
responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
|
7285 | |
}
|
7286 | |
}
|
7287 | |
match = responseHeaders[ key.toLowerCase() ];
|
7288 | |
}
|
7289 | |
return match === undefined ? null : match;
|
7290 | |
},
|
7291 | |
|
7292 | |
// Overrides response content-type header
|
7293 | |
overrideMimeType: function( type ) {
|
7294 | |
if ( !state ) {
|
7295 | |
s.mimeType = type;
|
7296 | |
}
|
7297 | |
return this;
|
7298 | |
},
|
7299 | |
|
7300 | |
// Cancel the request
|
7301 | |
abort: function( statusText ) {
|
7302 | |
statusText = statusText || "abort";
|
7303 | |
if ( transport ) {
|
7304 | |
transport.abort( statusText );
|
7305 | |
}
|
7306 | |
done( 0, statusText );
|
7307 | |
return this;
|
7308 | |
}
|
7309 | |
};
|
7310 | |
|
7311 | |
// Callback for when everything is done
|
7312 | |
// It is defined here because jslint complains if it is declared
|
7313 | |
// at the end of the function (which would be more logical and readable)
|
7314 | |
function done( status, nativeStatusText, responses, headers ) {
|
7315 | |
|
7316 | |
// Called once
|
7317 | |
if ( state === 2 ) {
|
7318 | |
return;
|
7319 | |
}
|
7320 | |
|
7321 | |
// State is "done" now
|
7322 | |
state = 2;
|
7323 | |
|
7324 | |
// Clear timeout if it exists
|
7325 | |
if ( timeoutTimer ) {
|
7326 | |
clearTimeout( timeoutTimer );
|
7327 | |
}
|
7328 | |
|
7329 | |
// Dereference transport for early garbage collection
|
7330 | |
// (no matter how long the jqXHR object will be used)
|
7331 | |
transport = undefined;
|
7332 | |
|
7333 | |
// Cache response headers
|
7334 | |
responseHeadersString = headers || "";
|
7335 | |
|
7336 | |
// Set readyState
|
7337 | |
jqXHR.readyState = status > 0 ? 4 : 0;
|
7338 | |
|
7339 | |
var isSuccess,
|
7340 | |
success,
|
7341 | |
error,
|
7342 | |
statusText = nativeStatusText,
|
7343 | |
response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined,
|
7344 | |
lastModified,
|
7345 | |
etag;
|
7346 | |
|
7347 | |
// If successful, handle type chaining
|
7348 | |
if ( status >= 200 && status < 300 || status === 304 ) {
|
7349 | |
|
7350 | |
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
|
7351 | |
if ( s.ifModified ) {
|
7352 | |
|
7353 | |
if ( ( lastModified = jqXHR.getResponseHeader( "Last-Modified" ) ) ) {
|
7354 | |
jQuery.lastModified[ ifModifiedKey ] = lastModified;
|
7355 | |
}
|
7356 | |
if ( ( etag = jqXHR.getResponseHeader( "Etag" ) ) ) {
|
7357 | |
jQuery.etag[ ifModifiedKey ] = etag;
|
7358 | |
}
|
7359 | |
}
|
7360 | |
|
7361 | |
// If not modified
|
7362 | |
if ( status === 304 ) {
|
7363 | |
|
7364 | |
statusText = "notmodified";
|
7365 | |
isSuccess = true;
|
7366 | |
|
7367 | |
// If we have data
|
7368 | |
} else {
|
7369 | |
|
7370 | |
try {
|
7371 | |
success = ajaxConvert( s, response );
|
7372 | |
statusText = "success";
|
7373 | |
isSuccess = true;
|
7374 | |
} catch(e) {
|
7375 | |
// We have a parsererror
|
7376 | |
statusText = "parsererror";
|
7377 | |
error = e;
|
7378 | |
}
|
7379 | |
}
|
7380 | |
} else {
|
7381 | |
// We extract error from statusText
|
7382 | |
// then normalize statusText and status for non-aborts
|
7383 | |
error = statusText;
|
7384 | |
if ( !statusText || status ) {
|
7385 | |
statusText = "error";
|
7386 | |
if ( status < 0 ) {
|
7387 | |
status = 0;
|
7388 | |
}
|
7389 | |
}
|
7390 | |
}
|
7391 | |
|
7392 | |
// Set data for the fake xhr object
|
7393 | |
jqXHR.status = status;
|
7394 | |
jqXHR.statusText = "" + ( nativeStatusText || statusText );
|
7395 | |
|
7396 | |
// Success/Error
|
7397 | |
if ( isSuccess ) {
|
7398 | |
deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
|
7399 | |
} else {
|
7400 | |
deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
|
7401 | |
}
|
7402 | |
|
7403 | |
// Status-dependent callbacks
|
7404 | |
jqXHR.statusCode( statusCode );
|
7405 | |
statusCode = undefined;
|
7406 | |
|
7407 | |
if ( fireGlobals ) {
|
7408 | |
globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ),
|
7409 | |
[ jqXHR, s, isSuccess ? success : error ] );
|
7410 | |
}
|
7411 | |
|
7412 | |
// Complete
|
7413 | |
completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
|
7414 | |
|
7415 | |
if ( fireGlobals ) {
|
7416 | |
globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
|
7417 | |
// Handle the global AJAX counter
|
7418 | |
if ( !( --jQuery.active ) ) {
|
7419 | |
jQuery.event.trigger( "ajaxStop" );
|
7420 | |
}
|
7421 | |
}
|
7422 | |
}
|
7423 | |
|
7424 | |
// Attach deferreds
|
7425 | |
deferred.promise( jqXHR );
|
7426 | |
jqXHR.success = jqXHR.done;
|
7427 | |
jqXHR.error = jqXHR.fail;
|
7428 | |
jqXHR.complete = completeDeferred.add;
|
7429 | |
|
7430 | |
// Status-dependent callbacks
|
7431 | |
jqXHR.statusCode = function( map ) {
|
7432 | |
if ( map ) {
|
7433 | |
var tmp;
|
7434 | |
if ( state < 2 ) {
|
7435 | |
for ( tmp in map ) {
|
7436 | |
statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ];
|
7437 | |
}
|
7438 | |
} else {
|
7439 | |
tmp = map[ jqXHR.status ];
|
7440 | |
jqXHR.then( tmp, tmp );
|
7441 | |
}
|
7442 | |
}
|
7443 | |
return this;
|
7444 | |
};
|
7445 | |
|
7446 | |
// Remove hash character (#7531: and string promotion)
|
7447 | |
// Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
|
7448 | |
// We also use the url parameter if available
|
7449 | |
s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
|
7450 | |
|
7451 | |
// Extract dataTypes list
|
7452 | |
s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( rspacesAjax );
|
7453 | |
|
7454 | |
// Determine if a cross-domain request is in order
|
7455 | |
if ( s.crossDomain == null ) {
|
7456 | |
parts = rurl.exec( s.url.toLowerCase() );
|
7457 | |
s.crossDomain = !!( parts &&
|
7458 | |
( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] ||
|
7459 | |
( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
|
7460 | |
( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
|
7461 | |
);
|
7462 | |
}
|
7463 | |
|
7464 | |
// Convert data if not already a string
|
7465 | |
if ( s.data && s.processData && typeof s.data !== "string" ) {
|
7466 | |
s.data = jQuery.param( s.data, s.traditional );
|
7467 | |
}
|
7468 | |
|
7469 | |
// Apply prefilters
|
7470 | |
inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
|
7471 | |
|
7472 | |
// If request was aborted inside a prefiler, stop there
|
7473 | |
if ( state === 2 ) {
|
7474 | |
return false;
|
7475 | |
}
|
7476 | |
|
7477 | |
// We can fire global events as of now if asked to
|
7478 | |
fireGlobals = s.global;
|
7479 | |
|
7480 | |
// Uppercase the type
|
7481 | |
s.type = s.type.toUpperCase();
|
7482 | |
|
7483 | |
// Determine if request has content
|
7484 | |
s.hasContent = !rnoContent.test( s.type );
|
7485 | |
|
7486 | |
// Watch for a new set of requests
|
7487 | |
if ( fireGlobals && jQuery.active++ === 0 ) {
|
7488 | |
jQuery.event.trigger( "ajaxStart" );
|
7489 | |
}
|
7490 | |
|
7491 | |
// More options handling for requests with no content
|
7492 | |
if ( !s.hasContent ) {
|
7493 | |
|
7494 | |
// If data is available, append data to url
|
7495 | |
if ( s.data ) {
|
7496 | |
s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
|
7497 | |
// #9682: remove data so that it's not used in an eventual retry
|
7498 | |
delete s.data;
|
7499 | |
}
|
7500 | |
|
7501 | |
// Get ifModifiedKey before adding the anti-cache parameter
|
7502 | |
ifModifiedKey = s.url;
|
7503 | |
|
7504 | |
// Add anti-cache in url if needed
|
7505 | |
if ( s.cache === false ) {
|
7506 | |
|
7507 | |
var ts = jQuery.now(),
|
7508 | |
// try replacing _= if it is there
|
7509 | |
ret = s.url.replace( rts, "$1_=" + ts );
|
7510 | |
|
7511 | |
// if nothing was replaced, add timestamp to the end
|
7512 | |
s.url = ret + ( ( ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" );
|
7513 | |
}
|
7514 | |
}
|
7515 | |
|
7516 | |
// Set the correct header, if data is being sent
|
7517 | |
if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
|
7518 | |
jqXHR.setRequestHeader( "Content-Type", s.contentType );
|
7519 | |
}
|
7520 | |
|
7521 | |
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
|
7522 | |
if ( s.ifModified ) {
|
7523 | |
ifModifiedKey = ifModifiedKey || s.url;
|
7524 | |
if ( jQuery.lastModified[ ifModifiedKey ] ) {
|
7525 | |
jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] );
|
7526 | |
}
|
7527 | |
if ( jQuery.etag[ ifModifiedKey ] ) {
|
7528 | |
jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] );
|
7529 | |
}
|
7530 | |
}
|
7531 | |
|
7532 | |
// Set the Accepts header for the server, depending on the dataType
|
7533 | |
jqXHR.setRequestHeader(
|
7534 | |
"Accept",
|
7535 | |
s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
|
7536 | |
s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
|
7537 | |
s.accepts[ "*" ]
|
7538 | |
);
|
7539 | |
|
7540 | |
// Check for headers option
|
7541 | |
for ( i in s.headers ) {
|
7542 | |
jqXHR.setRequestHeader( i, s.headers[ i ] );
|
7543 | |
}
|
7544 | |
|
7545 | |
// Allow custom headers/mimetypes and early abort
|
7546 | |
if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
|
7547 | |
// Abort if not done already
|
7548 | |
jqXHR.abort();
|
7549 | |
return false;
|
7550 | |
|
7551 | |
}
|
7552 | |
|
7553 | |
// Install callbacks on deferreds
|
7554 | |
for ( i in { success: 1, error: 1, complete: 1 } ) {
|
7555 | |
jqXHR[ i ]( s[ i ] );
|
7556 | |
}
|
7557 | |
|
7558 | |
// Get transport
|
7559 | |
transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
|
7560 | |
|
7561 | |
// If no transport, we auto-abort
|
7562 | |
if ( !transport ) {
|
7563 | |
done( -1, "No Transport" );
|
7564 | |
} else {
|
7565 | |
jqXHR.readyState = 1;
|
7566 | |
// Send global event
|
7567 | |
if ( fireGlobals ) {
|
7568 | |
globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
|
7569 | |
}
|
7570 | |
// Timeout
|
7571 | |
if ( s.async && s.timeout > 0 ) {
|
7572 | |
timeoutTimer = setTimeout( function(){
|
7573 | |
jqXHR.abort( "timeout" );
|
7574 | |
}, s.timeout );
|
7575 | |
}
|
7576 | |
|
7577 | |
try {
|
7578 | |
state = 1;
|
7579 | |
transport.send( requestHeaders, done );
|
7580 | |
} catch (e) {
|
7581 | |
// Propagate exception as error if not done
|
7582 | |
if ( state < 2 ) {
|
7583 | |
done( -1, e );
|
7584 | |
// Simply rethrow otherwise
|
7585 | |
} else {
|
7586 | |
throw e;
|
7587 | |
}
|
7588 | |
}
|
7589 | |
}
|
7590 | |
|
7591 | |
return jqXHR;
|
7592 | |
},
|
7593 | |
|
7594 | |
// Serialize an array of form elements or a set of
|
7595 | |
// key/values into a query string
|
7596 | |
param: function( a, traditional ) {
|
7597 | |
var s = [],
|
7598 | |
add = function( key, value ) {
|
7599 | |
// If value is a function, invoke it and return its value
|
7600 | |
value = jQuery.isFunction( value ) ? value() : value;
|
7601 | |
s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
|
7602 | |
};
|
7603 | |
|
7604 | |
// Set traditional to true for jQuery <= 1.3.2 behavior.
|
7605 | |
if ( traditional === undefined ) {
|
7606 | |
traditional = jQuery.ajaxSettings.traditional;
|
7607 | |
}
|
7608 | |
|
7609 | |
// If an array was passed in, assume that it is an array of form elements.
|
7610 | |
if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
|
7611 | |
// Serialize the form elements
|
7612 | |
jQuery.each( a, function() {
|
7613 | |
add( this.name, this.value );
|
7614 | |
});
|
7615 | |
|
7616 | |
} else {
|
7617 | |
// If traditional, encode the "old" way (the way 1.3.2 or older
|
7618 | |
// did it), otherwise encode params recursively.
|
7619 | |
for ( var prefix in a ) {
|
7620 | |
buildParams( prefix, a[ prefix ], traditional, add );
|
7621 | |
}
|
7622 | |
}
|
7623 | |
|
7624 | |
// Return the resulting serialization
|
7625 | |
return s.join( "&" ).replace( r20, "+" );
|
7626 | |
}
|
7627 | |
});
|
7628 | |
|
7629 | |
function buildParams( prefix, obj, traditional, add ) {
|
7630 | |
if ( jQuery.isArray( obj ) ) {
|
7631 | |
// Serialize array item.
|
7632 | |
jQuery.each( obj, function( i, v ) {
|
7633 | |
if ( traditional || rbracket.test( prefix ) ) {
|
7634 | |
// Treat each array item as a scalar.
|
7635 | |
add( prefix, v );
|
7636 | |
|
7637 | |
} else {
|
7638 | |
// If array item is non-scalar (array or object), encode its
|
7639 | |
// numeric index to resolve deserialization ambiguity issues.
|
7640 | |
// Note that rack (as of 1.0.0) can't currently deserialize
|
7641 | |
// nested arrays properly, and attempting to do so may cause
|
7642 | |
// a server error. Possible fixes are to modify rack's
|
7643 | |
// deserialization algorithm or to provide an option or flag
|
7644 | |
// to force array serialization to be shallow.
|
7645 | |
buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v, traditional, add );
|
7646 | |
}
|
7647 | |
});
|
7648 | |
|
7649 | |
} else if ( !traditional && obj != null && typeof obj === "object" ) {
|
7650 | |
// Serialize object item.
|
7651 | |
for ( var name in obj ) {
|
7652 | |
buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
|
7653 | |
}
|
7654 | |
|
7655 | |
} else {
|
7656 | |
// Serialize scalar item.
|
7657 | |
add( prefix, obj );
|
7658 | |
}
|
7659 | |
}
|
7660 | |
|
7661 | |
// This is still on the jQuery object... for now
|
7662 | |
// Want to move this to jQuery.ajax some day
|
7663 | |
jQuery.extend({
|
7664 | |
|
7665 | |
// Counter for holding the number of active queries
|
7666 | |
active: 0,
|
7667 | |
|
7668 | |
// Last-Modified header cache for next request
|
7669 | |
lastModified: {},
|
7670 | |
etag: {}
|
7671 | |
|
7672 | |
});
|
7673 | |
|
7674 | |
/* Handles responses to an ajax request:
|
7675 | |
* - sets all responseXXX fields accordingly
|
7676 | |
* - finds the right dataType (mediates between content-type and expected dataType)
|
7677 | |
* - returns the corresponding response
|
7678 | |
*/
|
7679 | |
function ajaxHandleResponses( s, jqXHR, responses ) {
|
7680 | |
|
7681 | |
var contents = s.contents,
|
7682 | |
dataTypes = s.dataTypes,
|
7683 | |
responseFields = s.responseFields,
|
7684 | |
ct,
|
7685 | |
type,
|
7686 | |
finalDataType,
|
7687 | |
firstDataType;
|
7688 | |
|
7689 | |
// Fill responseXXX fields
|
7690 | |
for ( type in responseFields ) {
|
7691 | |
if ( type in responses ) {
|
7692 | |
jqXHR[ responseFields[type] ] = responses[ type ];
|
7693 | |
}
|
7694 | |
}
|
7695 | |
|
7696 | |
// Remove auto dataType and get content-type in the process
|
7697 | |
while( dataTypes[ 0 ] === "*" ) {
|
7698 | |
dataTypes.shift();
|
7699 | |
if ( ct === undefined ) {
|
7700 | |
ct = s.mimeType || jqXHR.getResponseHeader( "content-type" );
|
7701 | |
}
|
7702 | |
}
|
7703 | |
|
7704 | |
// Check if we're dealing with a known content-type
|
7705 | |
if ( ct ) {
|
7706 | |
for ( type in contents ) {
|
7707 | |
if ( contents[ type ] && contents[ type ].test( ct ) ) {
|
7708 | |
dataTypes.unshift( type );
|
7709 | |
break;
|
7710 | |
}
|
7711 | |
}
|
7712 | |
}
|
7713 | |
|
7714 | |
// Check to see if we have a response for the expected dataType
|
7715 | |
if ( dataTypes[ 0 ] in responses ) {
|
7716 | |
finalDataType = dataTypes[ 0 ];
|
7717 | |
} else {
|
7718 | |
// Try convertible dataTypes
|
7719 | |
for ( type in responses ) {
|
7720 | |
if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
|
7721 | |
finalDataType = type;
|
7722 | |
break;
|
7723 | |
}
|
7724 | |
if ( !firstDataType ) {
|
7725 | |
firstDataType = type;
|
7726 | |
}
|
7727 | |
}
|
7728 | |
// Or just use first one
|
7729 | |
finalDataType = finalDataType || firstDataType;
|
7730 | |
}
|
7731 | |
|
7732 | |
// If we found a dataType
|
7733 | |
// We add the dataType to the list if needed
|
7734 | |
// and return the corresponding response
|
7735 | |
if ( finalDataType ) {
|
7736 | |
if ( finalDataType !== dataTypes[ 0 ] ) {
|
7737 | |
dataTypes.unshift( finalDataType );
|
7738 | |
}
|
7739 | |
return responses[ finalDataType ];
|
7740 | |
}
|
7741 | |
}
|
7742 | |
|
7743 | |
// Chain conversions given the request and the original response
|
7744 | |
function ajaxConvert( s, response ) {
|
7745 | |
|
7746 | |
// Apply the dataFilter if provided
|
7747 | |
if ( s.dataFilter ) {
|
7748 | |
response = s.dataFilter( response, s.dataType );
|
7749 | |
}
|
7750 | |
|
7751 | |
var dataTypes = s.dataTypes,
|
7752 | |
converters = {},
|
7753 | |
i,
|
7754 | |
key,
|
7755 | |
length = dataTypes.length,
|
7756 | |
tmp,
|
7757 | |
// Current and previous dataTypes
|
7758 | |
current = dataTypes[ 0 ],
|
7759 | |
prev,
|
7760 | |
// Conversion expression
|
7761 | |
conversion,
|
7762 | |
// Conversion function
|
7763 | |
conv,
|
7764 | |
// Conversion functions (transitive conversion)
|
7765 | |
conv1,
|
7766 | |
conv2;
|
7767 | |
|
7768 | |
// For each dataType in the chain
|
7769 | |
for ( i = 1; i < length; i++ ) {
|
7770 | |
|
7771 | |
// Create converters map
|
7772 | |
// with lowercased keys
|
7773 | |
if ( i === 1 ) {
|
7774 | |
for ( key in s.converters ) {
|
7775 | |
if ( typeof key === "string" ) {
|
7776 | |
converters[ key.toLowerCase() ] = s.converters[ key ];
|
7777 | |
}
|
7778 | |
}
|
7779 | |
}
|
7780 | |
|
7781 | |
// Get the dataTypes
|
7782 | |
prev = current;
|
7783 | |
current = dataTypes[ i ];
|
7784 | |
|
7785 | |
// If current is auto dataType, update it to prev
|
7786 | |
if ( current === "*" ) {
|
7787 | |
current = prev;
|
7788 | |
// If no auto and dataTypes are actually different
|
7789 | |
} else if ( prev !== "*" && prev !== current ) {
|
7790 | |
|
7791 | |
// Get the converter
|
7792 | |
conversion = prev + " " + current;
|
7793 | |
conv = converters[ conversion ] || converters[ "* " + current ];
|
7794 | |
|
7795 | |
// If there is no direct converter, search transitively
|
7796 | |
if ( !conv ) {
|
7797 | |
conv2 = undefined;
|
7798 | |
for ( conv1 in converters ) {
|
7799 | |
tmp = conv1.split( " " );
|
7800 | |
if ( tmp[ 0 ] === prev || tmp[ 0 ] === "*" ) {
|
7801 | |
conv2 = converters[ tmp[1] + " " + current ];
|
7802 | |
if ( conv2 ) {
|
7803 | |
conv1 = converters[ conv1 ];
|
7804 | |
if ( conv1 === true ) {
|
7805 | |
conv = conv2;
|
7806 | |
} else if ( conv2 === true ) {
|
7807 | |
conv = conv1;
|
7808 | |
}
|
7809 | |
break;
|
7810 | |
}
|
7811 | |
}
|
7812 | |
}
|
7813 | |
}
|
7814 | |
// If we found no converter, dispatch an error
|
7815 | |
if ( !( conv || conv2 ) ) {
|
7816 | |
jQuery.error( "No conversion from " + conversion.replace(" "," to ") );
|
7817 | |
}
|
7818 | |
// If found converter is not an equivalence
|
7819 | |
if ( conv !== true ) {
|
7820 | |
// Convert with 1 or 2 converters accordingly
|
7821 | |
response = conv ? conv( response ) : conv2( conv1(response) );
|
7822 | |
}
|
7823 | |
}
|
7824 | |
}
|
7825 | |
return response;
|
7826 | |
}
|
7827 | |
|
7828 | |
|
7829 | |
|
7830 | |
|
7831 | |
var jsc = jQuery.now(),
|
7832 | |
jsre = /(\=)\?(&|$)|\?\?/i;
|
7833 | |
|
7834 | |
// Default jsonp settings
|
7835 | |
jQuery.ajaxSetup({
|
7836 | |
jsonp: "callback",
|
7837 | |
jsonpCallback: function() {
|
7838 | |
return jQuery.expando + "_" + ( jsc++ );
|
7839 | |
}
|
7840 | |
});
|
7841 | |
|
7842 | |
// Detect, normalize options and install callbacks for jsonp requests
|
7843 | |
jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
|
7844 | |
|
7845 | |
var inspectData = s.contentType === "application/x-www-form-urlencoded" &&
|
7846 | |
( typeof s.data === "string" );
|
7847 | |
|
7848 | |
if ( s.dataTypes[ 0 ] === "jsonp" ||
|
7849 | |
s.jsonp !== false && ( jsre.test( s.url ) ||
|
7850 | |
inspectData && jsre.test( s.data ) ) ) {
|
7851 | |
|
7852 | |
var responseContainer,
|
7853 | |
jsonpCallback = s.jsonpCallback =
|
7854 | |
jQuery.isFunction( s.jsonpCallback ) ? s.jsonpCallback() : s.jsonpCallback,
|
7855 | |
previous = window[ jsonpCallback ],
|
7856 | |
url = s.url,
|
7857 | |
data = s.data,
|
7858 | |
replace = "$1" + jsonpCallback + "$2";
|
7859 | |
|
7860 | |
if ( s.jsonp !== false ) {
|
7861 | |
url = url.replace( jsre, replace );
|
7862 | |
if ( s.url === url ) {
|
7863 | |
if ( inspectData ) {
|
7864 | |
data = data.replace( jsre, replace );
|
7865 | |
}
|
7866 | |
if ( s.data === data ) {
|
7867 | |
// Add callback manually
|
7868 | |
url += (/\?/.test( url ) ? "&" : "?") + s.jsonp + "=" + jsonpCallback;
|
7869 | |
}
|
7870 | |
}
|
7871 | |
}
|
7872 | |
|
7873 | |
s.url = url;
|
7874 | |
s.data = data;
|
7875 | |
|
7876 | |
// Install callback
|
7877 | |
window[ jsonpCallback ] = function( response ) {
|
7878 | |
responseContainer = [ response ];
|
7879 | |
};
|
7880 | |
|
7881 | |
// Clean-up function
|
7882 | |
jqXHR.always(function() {
|
7883 | |
// Set callback back to previous value
|
7884 | |
window[ jsonpCallback ] = previous;
|
7885 | |
// Call if it was a function and we have a response
|
7886 | |
if ( responseContainer && jQuery.isFunction( previous ) ) {
|
7887 | |
window[ jsonpCallback ]( responseContainer[ 0 ] );
|
7888 | |
}
|
7889 | |
});
|
7890 | |
|
7891 | |
// Use data converter to retrieve json after script execution
|
7892 | |
s.converters["script json"] = function() {
|
7893 | |
if ( !responseContainer ) {
|
7894 | |
jQuery.error( jsonpCallback + " was not called" );
|
7895 | |
}
|
7896 | |
return responseContainer[ 0 ];
|
7897 | |
};
|
7898 | |
|
7899 | |
// force json dataType
|
7900 | |
s.dataTypes[ 0 ] = "json";
|
7901 | |
|
7902 | |
// Delegate to script
|
7903 | |
return "script";
|
7904 | |
}
|
7905 | |
});
|
7906 | |
|
7907 | |
|
7908 | |
|
7909 | |
|
7910 | |
// Install script dataType
|
7911 | |
jQuery.ajaxSetup({
|
7912 | |
accepts: {
|
7913 | |
script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
|
7914 | |
},
|
7915 | |
contents: {
|
7916 | |
script: /javascript|ecmascript/
|
7917 | |
},
|
7918 | |
converters: {
|
7919 | |
"text script": function( text ) {
|
7920 | |
jQuery.globalEval( text );
|
7921 | |
return text;
|
7922 | |
}
|
7923 | |
}
|
7924 | |
});
|
7925 | |
|
7926 | |
// Handle cache's special case and global
|
7927 | |
jQuery.ajaxPrefilter( "script", function( s ) {
|
7928 | |
if ( s.cache === undefined ) {
|
7929 | |
s.cache = false;
|
7930 | |
}
|
7931 | |
if ( s.crossDomain ) {
|
7932 | |
s.type = "GET";
|
7933 | |
s.global = false;
|
7934 | |
}
|
7935 | |
});
|
7936 | |
|
7937 | |
// Bind script tag hack transport
|
7938 | |
jQuery.ajaxTransport( "script", function(s) {
|
7939 | |
|
7940 | |
// This transport only deals with cross domain requests
|
7941 | |
if ( s.crossDomain ) {
|
7942 | |
|
7943 | |
var script,
|
7944 | |
head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;
|
7945 | |
|
7946 | |
return {
|
7947 | |
|
7948 | |
send: function( _, callback ) {
|
7949 | |
|
7950 | |
script = document.createElement( "script" );
|
7951 | |
|
7952 | |
script.async = "async";
|
7953 | |
|
7954 | |
if ( s.scriptCharset ) {
|
7955 | |
script.charset = s.scriptCharset;
|
7956 | |
}
|
7957 | |
|
7958 | |
script.src = s.url;
|
7959 | |
|
7960 | |
// Attach handlers for all browsers
|
7961 | |
script.onload = script.onreadystatechange = function( _, isAbort ) {
|
7962 | |
|
7963 | |
if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
|
7964 | |
|
7965 | |
// Handle memory leak in IE
|
7966 | |
script.onload = script.onreadystatechange = null;
|
7967 | |
|
7968 | |
// Remove the script
|
7969 | |
if ( head && script.parentNode ) {
|
7970 | |
head.removeChild( script );
|
7971 | |
}
|
7972 | |
|
7973 | |
// Dereference the script
|
7974 | |
script = undefined;
|
7975 | |
|
7976 | |
// Callback if not abort
|
7977 | |
if ( !isAbort ) {
|
7978 | |
callback( 200, "success" );
|
7979 | |
}
|
7980 | |
}
|
7981 | |
};
|
7982 | |
// Use insertBefore instead of appendChild to circumvent an IE6 bug.
|
7983 | |
// This arises when a base node is used (#2709 and #4378).
|
7984 | |
head.insertBefore( script, head.firstChild );
|
7985 | |
},
|
7986 | |
|
7987 | |
abort: function() {
|
7988 | |
if ( script ) {
|
7989 | |
script.onload( 0, 1 );
|
7990 | |
}
|
7991 | |
}
|
7992 | |
};
|
7993 | |
}
|
7994 | |
});
|
7995 | |
|
7996 | |
|
7997 | |
|
7998 | |
|
7999 | |
var // #5280: Internet Explorer will keep connections alive if we don't abort on unload
|
8000 | |
xhrOnUnloadAbort = window.ActiveXObject ? function() {
|
8001 | |
// Abort all pending requests
|
8002 | |
for ( var key in xhrCallbacks ) {
|
8003 | |
xhrCallbacks[ key ]( 0, 1 );
|
8004 | |
}
|
8005 | |
} : false,
|
8006 | |
xhrId = 0,
|
8007 | |
xhrCallbacks;
|
8008 | |
|
8009 | |
// Functions to create xhrs
|
8010 | |
function createStandardXHR() {
|
8011 | |
try {
|
8012 | |
return new window.XMLHttpRequest();
|
8013 | |
} catch( e ) {}
|
8014 | |
}
|
8015 | |
|
8016 | |
function createActiveXHR() {
|
8017 | |
try {
|
8018 | |
return new window.ActiveXObject( "Microsoft.XMLHTTP" );
|
8019 | |
} catch( e ) {}
|
8020 | |
}
|
8021 | |
|
8022 | |
// Create the request object
|
8023 | |
// (This is still attached to ajaxSettings for backward compatibility)
|
8024 | |
jQuery.ajaxSettings.xhr = window.ActiveXObject ?
|
8025 | |
/* Microsoft failed to properly
|
8026 | |
* implement the XMLHttpRequest in IE7 (can't request local files),
|
8027 | |
* so we use the ActiveXObject when it is available
|
8028 | |
* Additionally XMLHttpRequest can be disabled in IE7/IE8 so
|
8029 | |
* we need a fallback.
|
8030 | |
*/
|
8031 | |
function() {
|
8032 | |
return !this.isLocal && createStandardXHR() || createActiveXHR();
|
8033 | |
} :
|
8034 | |
// For all other browsers, use the standard XMLHttpRequest object
|
8035 | |
createStandardXHR;
|
8036 | |
|
8037 | |
// Determine support properties
|
8038 | |
(function( xhr ) {
|
8039 | |
jQuery.extend( jQuery.support, {
|
8040 | |
ajax: !!xhr,
|
8041 | |
cors: !!xhr && ( "withCredentials" in xhr )
|
8042 | |
});
|
8043 | |
})( jQuery.ajaxSettings.xhr() );
|
8044 | |
|
8045 | |
// Create transport if the browser can provide an xhr
|
8046 | |
if ( jQuery.support.ajax ) {
|
8047 | |
|
8048 | |
jQuery.ajaxTransport(function( s ) {
|
8049 | |
// Cross domain only allowed if supported through XMLHttpRequest
|
8050 | |
if ( !s.crossDomain || jQuery.support.cors ) {
|
8051 | |
|
8052 | |
var callback;
|
8053 | |
|
8054 | |
return {
|
8055 | |
send: function( headers, complete ) {
|
8056 | |
|
8057 | |
// Get a new xhr
|
8058 | |
var xhr = s.xhr(),
|
8059 | |
handle,
|
8060 | |
i;
|
8061 | |
|
8062 | |
// Open the socket
|
8063 | |
// Passing null username, generates a login popup on Opera (#2865)
|
8064 | |
if ( s.username ) {
|
8065 | |
xhr.open( s.type, s.url, s.async, s.username, s.password );
|
8066 | |
} else {
|
8067 | |
xhr.open( s.type, s.url, s.async );
|
8068 | |
}
|
8069 | |
|
8070 | |
// Apply custom fields if provided
|
8071 | |
if ( s.xhrFields ) {
|
8072 | |
for ( i in s.xhrFields ) {
|
8073 | |
xhr[ i ] = s.xhrFields[ i ];
|
8074 | |
}
|
8075 | |
}
|
8076 | |
|
8077 | |
// Override mime type if needed
|
8078 | |
if ( s.mimeType && xhr.overrideMimeType ) {
|
8079 | |
xhr.overrideMimeType( s.mimeType );
|
8080 | |
}
|
8081 | |
|
8082 | |
// X-Requested-With header
|
8083 | |
// For cross-domain requests, seeing as conditions for a preflight are
|
8084 | |
// akin to a jigsaw puzzle, we simply never set it to be sure.
|
8085 | |
// (it can always be set on a per-request basis or even using ajaxSetup)
|
8086 | |
// For same-domain requests, won't change header if already provided.
|
8087 | |
if ( !s.crossDomain && !headers["X-Requested-With"] ) {
|
8088 | |
headers[ "X-Requested-With" ] = "XMLHttpRequest";
|
8089 | |
}
|
8090 | |
|
8091 | |
// Need an extra try/catch for cross domain requests in Firefox 3
|
8092 | |
try {
|
8093 | |
for ( i in headers ) {
|
8094 | |
xhr.setRequestHeader( i, headers[ i ] );
|
8095 | |
}
|
8096 | |
} catch( _ ) {}
|
8097 | |
|
8098 | |
// Do send the request
|
8099 | |
// This may raise an exception which is actually
|
8100 | |
// handled in jQuery.ajax (so no try/catch here)
|
8101 | |
xhr.send( ( s.hasContent && s.data ) || null );
|
8102 | |
|
8103 | |
// Listener
|
8104 | |
callback = function( _, isAbort ) {
|
8105 | |
|
8106 | |
var status,
|
8107 | |
statusText,
|
8108 | |
responseHeaders,
|
8109 | |
responses,
|
8110 | |
xml;
|
8111 | |
|
8112 | |
// Firefox throws exceptions when accessing properties
|
8113 | |
// of an xhr when a network error occured
|
8114 | |
// http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
|
8115 | |
try {
|
8116 | |
|
8117 | |
// Was never called and is aborted or complete
|
8118 | |
if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
|
8119 | |
|
8120 | |
// Only called once
|
8121 | |
callback = undefined;
|
8122 | |
|
8123 | |
// Do not keep as active anymore
|
8124 | |
if ( handle ) {
|
8125 | |
xhr.onreadystatechange = jQuery.noop;
|
8126 | |
if ( xhrOnUnloadAbort ) {
|
8127 | |
delete xhrCallbacks[ handle ];
|
8128 | |
}
|
8129 | |
}
|
8130 | |
|
8131 | |
// If it's an abort
|
8132 | |
if ( isAbort ) {
|
8133 | |
// Abort it manually if needed
|
8134 | |
if ( xhr.readyState !== 4 ) {
|
8135 | |
xhr.abort();
|
8136 | |
}
|
8137 | |
} else {
|
8138 | |
status = xhr.status;
|
8139 | |
responseHeaders = xhr.getAllResponseHeaders();
|
8140 | |
responses = {};
|
8141 | |
xml = xhr.responseXML;
|
8142 | |
|
8143 | |
// Construct response list
|
8144 | |
if ( xml && xml.documentElement /* #4958 */ ) {
|
8145 | |
responses.xml = xml;
|
8146 | |
}
|
8147 | |
responses.text = xhr.responseText;
|
8148 | |
|
8149 | |
// Firefox throws an exception when accessing
|
8150 | |
// statusText for faulty cross-domain requests
|
8151 | |
try {
|
8152 | |
statusText = xhr.statusText;
|
8153 | |
} catch( e ) {
|
8154 | |
// We normalize with Webkit giving an empty statusText
|
8155 | |
statusText = "";
|
8156 | |
}
|
8157 | |
|
8158 | |
// Filter status for non standard behaviors
|
8159 | |
|
8160 | |
// If the request is local and we have data: assume a success
|
8161 | |
// (success with no data won't get notified, that's the best we
|
8162 | |
// can do given current implementations)
|
8163 | |
if ( !status && s.isLocal && !s.crossDomain ) {
|
8164 | |
status = responses.text ? 200 : 404;
|
8165 | |
// IE - #1450: sometimes returns 1223 when it should be 204
|
8166 | |
} else if ( status === 1223 ) {
|
8167 | |
status = 204;
|
8168 | |
}
|
8169 | |
}
|
8170 | |
}
|
8171 | |
} catch( firefoxAccessException ) {
|
8172 | |
if ( !isAbort ) {
|
8173 | |
complete( -1, firefoxAccessException );
|
8174 | |
}
|
8175 | |
}
|
8176 | |
|
8177 | |
// Call complete if needed
|
8178 | |
if ( responses ) {
|
8179 | |
complete( status, statusText, responses, responseHeaders );
|
8180 | |
}
|
8181 | |
};
|
8182 | |
|
8183 | |
// if we're in sync mode or it's in cache
|
8184 | |
// and has been retrieved directly (IE6 & IE7)
|
8185 | |
// we need to manually fire the callback
|
8186 | |
if ( !s.async || xhr.readyState === 4 ) {
|
8187 | |
callback();
|
8188 | |
} else {
|
8189 | |
handle = ++xhrId;
|
8190 | |
if ( xhrOnUnloadAbort ) {
|
8191 | |
// Create the active xhrs callbacks list if needed
|
8192 | |
// and attach the unload handler
|
8193 | |
if ( !xhrCallbacks ) {
|
8194 | |
xhrCallbacks = {};
|
8195 | |
jQuery( window ).unload( xhrOnUnloadAbort );
|
8196 | |
}
|
8197 | |
// Add to list of active xhrs callbacks
|
8198 | |
xhrCallbacks[ handle ] = callback;
|
8199 | |
}
|
8200 | |
xhr.onreadystatechange = callback;
|
8201 | |
}
|
8202 | |
},
|
8203 | |
|
8204 | |
abort: function() {
|
8205 | |
if ( callback ) {
|
8206 | |
callback(0,1);
|
8207 | |
}
|
8208 | |
}
|
8209 | |
};
|
8210 | |
}
|
8211 | |
});
|
8212 | |
}
|
8213 | |
|
8214 | |
|
8215 | |
|
8216 | |
|
8217 | |
var elemdisplay = {},
|
8218 | |
iframe, iframeDoc,
|
8219 | |
rfxtypes = /^(?:toggle|show|hide)$/,
|
8220 | |
rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,
|
8221 | |
timerId,
|
8222 | |
fxAttrs = [
|
8223 | |
// height animations
|
8224 | |
[ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
|
8225 | |
// width animations
|
8226 | |
[ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
|
8227 | |
// opacity animations
|
8228 | |
[ "opacity" ]
|
8229 | |
],
|
8230 | |
fxNow;
|
8231 | |
|
8232 | |
jQuery.fn.extend({
|
8233 | |
show: function( speed, easing, callback ) {
|
8234 | |
var elem, display;
|
8235 | |
|
8236 | |
if ( speed || speed === 0 ) {
|
8237 | |
return this.animate( genFx("show", 3), speed, easing, callback );
|
8238 | |
|
8239 | |
} else {
|
8240 | |
for ( var i = 0, j = this.length; i < j; i++ ) {
|
8241 | |
elem = this[ i ];
|
8242 | |
|
8243 | |
if ( elem.style ) {
|
8244 | |
display = elem.style.display;
|
8245 | |
|
8246 | |
// Reset the inline display of this element to learn if it is
|
8247 | |
// being hidden by cascaded rules or not
|
8248 | |
if ( !jQuery._data(elem, "olddisplay") && display === "none" ) {
|
8249 | |
display = elem.style.display = "";
|
8250 | |
}
|
8251 | |
|
8252 | |
// Set elements which have been overridden with display: none
|
8253 | |
// in a stylesheet to whatever the default browser style is
|
8254 | |
// for such an element
|
8255 | |
if ( display === "" && jQuery.css(elem, "display") === "none" ) {
|
8256 | |
jQuery._data( elem, "olddisplay", defaultDisplay(elem.nodeName) );
|
8257 | |
}
|
8258 | |
}
|
8259 | |
}
|
8260 | |
|
8261 | |
// Set the display of most of the elements in a second loop
|
8262 | |
// to avoid the constant reflow
|
8263 | |
for ( i = 0; i < j; i++ ) {
|
8264 | |
elem = this[ i ];
|
8265 | |
|
8266 | |
if ( elem.style ) {
|
8267 | |
display = elem.style.display;
|
8268 | |
|
8269 | |
if ( display === "" || display === "none" ) {
|
8270 | |
elem.style.display = jQuery._data( elem, "olddisplay" ) || "";
|
8271 | |
}
|
8272 | |
}
|
8273 | |
}
|
8274 | |
|
8275 | |
return this;
|
8276 | |
}
|
8277 | |
},
|
8278 | |
|
8279 | |
hide: function( speed, easing, callback ) {
|
8280 | |
if ( speed || speed === 0 ) {
|
8281 | |
return this.animate( genFx("hide", 3), speed, easing, callback);
|
8282 | |
|
8283 | |
} else {
|
8284 | |
var elem, display,
|
8285 | |
i = 0,
|
8286 | |
j = this.length;
|
8287 | |
|
8288 | |
for ( ; i < j; i++ ) {
|
8289 | |
elem = this[i];
|
8290 | |
if ( elem.style ) {
|
8291 | |
display = jQuery.css( elem, "display" );
|
8292 | |
|
8293 | |
if ( display !== "none" && !jQuery._data( elem, "olddisplay" ) ) {
|
8294 | |
jQuery._data( elem, "olddisplay", display );
|
8295 | |
}
|
8296 | |
}
|
8297 | |
}
|
8298 | |
|
8299 | |
// Set the display of the elements in a second loop
|
8300 | |
// to avoid the constant reflow
|
8301 | |
for ( i = 0; i < j; i++ ) {
|
8302 | |
if ( this[i].style ) {
|
8303 | |
this[i].style.display = "none";
|
8304 | |
}
|
8305 | |
}
|
8306 | |
|
8307 | |
return this;
|
8308 | |
}
|
8309 | |
},
|
8310 | |
|
8311 | |
// Save the old toggle function
|
8312 | |
_toggle: jQuery.fn.toggle,
|
8313 | |
|
8314 | |
toggle: function( fn, fn2, callback ) {
|
8315 | |
var bool = typeof fn === "boolean";
|
8316 | |
|
8317 | |
if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) {
|
8318 | |
this._toggle.apply( this, arguments );
|
8319 | |
|
8320 | |
} else if ( fn == null || bool ) {
|
8321 | |
this.each(function() {
|
8322 | |
var state = bool ? fn : jQuery(this).is(":hidden");
|
8323 | |
jQuery(this)[ state ? "show" : "hide" ]();
|
8324 | |
});
|
8325 | |
|
8326 | |
} else {
|
8327 | |
this.animate(genFx("toggle", 3), fn, fn2, callback);
|
8328 | |
}
|
8329 | |
|
8330 | |
return this;
|
8331 | |
},
|
8332 | |
|
8333 | |
fadeTo: function( speed, to, easing, callback ) {
|
8334 | |
return this.filter(":hidden").css("opacity", 0).show().end()
|
8335 | |
.animate({opacity: to}, speed, easing, callback);
|
8336 | |
},
|
8337 | |
|
8338 | |
animate: function( prop, speed, easing, callback ) {
|
8339 | |
var optall = jQuery.speed( speed, easing, callback );
|
8340 | |
|
8341 | |
if ( jQuery.isEmptyObject( prop ) ) {
|
8342 | |
return this.each( optall.complete, [ false ] );
|
8343 | |
}
|
8344 | |
|
8345 | |
// Do not change referenced properties as per-property easing will be lost
|
8346 | |
prop = jQuery.extend( {}, prop );
|
8347 | |
|
8348 | |
function doAnimation() {
|
8349 | |
// XXX 'this' does not always have a nodeName when running the
|
8350 | |
// test suite
|
8351 | |
|
8352 | |
if ( optall.queue === false ) {
|
8353 | |
jQuery._mark( this );
|
8354 | |
}
|
8355 | |
|
8356 | |
var opt = jQuery.extend( {}, optall ),
|
8357 | |
isElement = this.nodeType === 1,
|
8358 | |
hidden = isElement && jQuery(this).is(":hidden"),
|
8359 | |
name, val, p, e,
|
8360 | |
parts, start, end, unit,
|
8361 | |
method;
|
8362 | |
|
8363 | |
// will store per property easing and be used to determine when an animation is complete
|
8364 | |
opt.animatedProperties = {};
|
8365 | |
|
8366 | |
for ( p in prop ) {
|
8367 | |
|
8368 | |
// property name normalization
|
8369 | |
name = jQuery.camelCase( p );
|
8370 | |
if ( p !== name ) {
|
8371 | |
prop[ name ] = prop[ p ];
|
8372 | |
delete prop[ p ];
|
8373 | |
}
|
8374 | |
|
8375 | |
val = prop[ name ];
|
8376 | |
|
8377 | |
// easing resolution: per property > opt.specialEasing > opt.easing > 'swing' (default)
|
8378 | |
if ( jQuery.isArray( val ) ) {
|
8379 | |
opt.animatedProperties[ name ] = val[ 1 ];
|
8380 | |
val = prop[ name ] = val[ 0 ];
|
8381 | |
} else {
|
8382 | |
opt.animatedProperties[ name ] = opt.specialEasing && opt.specialEasing[ name ] || opt.easing || 'swing';
|
8383 | |
}
|
8384 | |
|
8385 | |
if ( val === "hide" && hidden || val === "show" && !hidden ) {
|
8386 | |
return opt.complete.call( this );
|
8387 | |
}
|
8388 | |
|
8389 | |
if ( isElement && ( name === "height" || name === "width" ) ) {
|
8390 | |
// Make sure that nothing sneaks out
|
8391 | |
// Record all 3 overflow attributes because IE does not
|
8392 | |
// change the overflow attribute when overflowX and
|
8393 | |
// overflowY are set to the same value
|
8394 | |
opt.overflow = [ this.style.overflow, this.style.overflowX, this.style.overflowY ];
|
8395 | |
|
8396 | |
// Set display property to inline-block for height/width
|
8397 | |
// animations on inline elements that are having width/height animated
|
8398 | |
if ( jQuery.css( this, "display" ) === "inline" &&
|
8399 | |
jQuery.css( this, "float" ) === "none" ) {
|
8400 | |
|
8401 | |
// inline-level elements accept inline-block;
|
8402 | |
// block-level elements need to be inline with layout
|
8403 | |
if ( !jQuery.support.inlineBlockNeedsLayout || defaultDisplay( this.nodeName ) === "inline" ) {
|
8404 | |
this.style.display = "inline-block";
|
8405 | |
|
8406 | |
} else {
|
8407 | |
this.style.zoom = 1;
|
8408 | |
}
|
8409 | |
}
|
8410 | |
}
|
8411 | |
}
|
8412 | |
|
8413 | |
if ( opt.overflow != null ) {
|
8414 | |
this.style.overflow = "hidden";
|
8415 | |
}
|
8416 | |
|
8417 | |
for ( p in prop ) {
|
8418 | |
e = new jQuery.fx( this, opt, p );
|
8419 | |
val = prop[ p ];
|
8420 | |
|
8421 | |
if ( rfxtypes.test( val ) ) {
|
8422 | |
|
8423 | |
// Tracks whether to show or hide based on private
|
8424 | |
// data attached to the element
|
8425 | |
method = jQuery._data( this, "toggle" + p ) || ( val === "toggle" ? hidden ? "show" : "hide" : 0 );
|
8426 | |
if ( method ) {
|
8427 | |
jQuery._data( this, "toggle" + p, method === "show" ? "hide" : "show" );
|
8428 | |
e[ method ]();
|
8429 | |
} else {
|
8430 | |
e[ val ]();
|
8431 | |
}
|
8432 | |
|
8433 | |
} else {
|
8434 | |
parts = rfxnum.exec( val );
|
8435 | |
start = e.cur();
|
8436 | |
|
8437 | |
if ( parts ) {
|
8438 | |
end = parseFloat( parts[2] );
|
8439 | |
unit = parts[3] || ( jQuery.cssNumber[ p ] ? "" : "px" );
|
8440 | |
|
8441 | |
// We need to compute starting value
|
8442 | |
if ( unit !== "px" ) {
|
8443 | |
jQuery.style( this, p, (end || 1) + unit);
|
8444 | |
start = ( (end || 1) / e.cur() ) * start;
|
8445 | |
jQuery.style( this, p, start + unit);
|
8446 | |
}
|
8447 | |
|
8448 | |
// If a +=/-= token was provided, we're doing a relative animation
|
8449 | |
if ( parts[1] ) {
|
8450 | |
end = ( (parts[ 1 ] === "-=" ? -1 : 1) * end ) + start;
|
8451 | |
}
|
8452 | |
|
8453 | |
e.custom( start, end, unit );
|
8454 | |
|
8455 | |
} else {
|
8456 | |
e.custom( start, val, "" );
|
8457 | |
}
|
8458 | |
}
|
8459 | |
}
|
8460 | |
|
8461 | |
// For JS strict compliance
|
8462 | |
return true;
|
8463 | |
}
|
8464 | |
|
8465 | |
return optall.queue === false ?
|
8466 | |
this.each( doAnimation ) :
|
8467 | |
this.queue( optall.queue, doAnimation );
|
8468 | |
},
|
8469 | |
|
8470 | |
stop: function( type, clearQueue, gotoEnd ) {
|
8471 | |
if ( typeof type !== "string" ) {
|
8472 | |
gotoEnd = clearQueue;
|
8473 | |
clearQueue = type;
|
8474 | |
type = undefined;
|
8475 | |
}
|
8476 | |
if ( clearQueue && type !== false ) {
|
8477 | |
this.queue( type || "fx", [] );
|
8478 | |
}
|
8479 | |
|
8480 | |
return this.each(function() {
|
8481 | |
var index,
|
8482 | |
hadTimers = false,
|
8483 | |
timers = jQuery.timers,
|
8484 | |
data = jQuery._data( this );
|
8485 | |
|
8486 | |
// clear marker counters if we know they won't be
|
8487 | |
if ( !gotoEnd ) {
|
8488 | |
jQuery._unmark( true, this );
|
8489 | |
}
|
8490 | |
|
8491 | |
function stopQueue( elem, data, index ) {
|
8492 | |
var hooks = data[ index ];
|
8493 | |
jQuery.removeData( elem, index, true );
|
8494 | |
hooks.stop( gotoEnd );
|
8495 | |
}
|
8496 | |
|
8497 | |
if ( type == null ) {
|
8498 | |
for ( index in data ) {
|
8499 | |
if ( data[ index ] && data[ index ].stop && index.indexOf(".run") === index.length - 4 ) {
|
8500 | |
stopQueue( this, data, index );
|
8501 | |
}
|
8502 | |
}
|
8503 | |
} else if ( data[ index = type + ".run" ] && data[ index ].stop ){
|
8504 | |
stopQueue( this, data, index );
|
8505 | |
}
|
8506 | |
|
8507 | |
for ( index = timers.length; index--; ) {
|
8508 | |
if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
|
8509 | |
if ( gotoEnd ) {
|
8510 | |
|
8511 | |
// force the next step to be the last
|
8512 | |
timers[ index ]( true );
|
8513 | |
} else {
|
8514 | |
timers[ index ].saveState();
|
8515 | |
}
|
8516 | |
hadTimers = true;
|
8517 | |
timers.splice( index, 1 );
|
8518 | |
}
|
8519 | |
}
|
8520 | |
|
8521 | |
// start the next in the queue if the last step wasn't forced
|
8522 | |
// timers currently will call their complete callbacks, which will dequeue
|
8523 | |
// but only if they were gotoEnd
|
8524 | |
if ( !( gotoEnd && hadTimers ) ) {
|
8525 | |
jQuery.dequeue( this, type );
|
8526 | |
}
|
8527 | |
});
|
8528 | |
}
|
8529 | |
|
8530 | |
});
|
8531 | |
|
8532 | |
// Animations created synchronously will run synchronously
|
8533 | |
function createFxNow() {
|
8534 | |
setTimeout( clearFxNow, 0 );
|
8535 | |
return ( fxNow = jQuery.now() );
|
8536 | |
}
|
8537 | |
|
8538 | |
function clearFxNow() {
|
8539 | |
fxNow = undefined;
|
8540 | |
}
|
8541 | |
|
8542 | |
// Generate parameters to create a standard animation
|
8543 | |
function genFx( type, num ) {
|
8544 | |
var obj = {};
|
8545 | |
|
8546 | |
jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice( 0, num )), function() {
|
8547 | |
obj[ this ] = type;
|
8548 | |
});
|
8549 | |
|
8550 | |
return obj;
|
8551 | |
}
|
8552 | |
|
8553 | |
// Generate shortcuts for custom animations
|
8554 | |
jQuery.each({
|
8555 | |
slideDown: genFx( "show", 1 ),
|
8556 | |
slideUp: genFx( "hide", 1 ),
|
8557 | |
slideToggle: genFx( "toggle", 1 ),
|
8558 | |
fadeIn: { opacity: "show" },
|
8559 | |
fadeOut: { opacity: "hide" },
|
8560 | |
fadeToggle: { opacity: "toggle" }
|
8561 | |
}, function( name, props ) {
|
8562 | |
jQuery.fn[ name ] = function( speed, easing, callback ) {
|
8563 | |
return this.animate( props, speed, easing, callback );
|
8564 | |
};
|
8565 | |
});
|
8566 | |
|
8567 | |
jQuery.extend({
|
8568 | |
speed: function( speed, easing, fn ) {
|
8569 | |
var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
|
8570 | |
complete: fn || !fn && easing ||
|
8571 | |
jQuery.isFunction( speed ) && speed,
|
8572 | |
duration: speed,
|
8573 | |
easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
|
8574 | |
};
|
8575 | |
|
8576 | |
opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
|
8577 | |
opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
|
8578 | |
|
8579 | |
// normalize opt.queue - true/undefined/null -> "fx"
|
8580 | |
if ( opt.queue == null || opt.queue === true ) {
|
8581 | |
opt.queue = "fx";
|
8582 | |
}
|
8583 | |
|
8584 | |
// Queueing
|
8585 | |
opt.old = opt.complete;
|
8586 | |
|
8587 | |
opt.complete = function( noUnmark ) {
|
8588 | |
if ( jQuery.isFunction( opt.old ) ) {
|
8589 | |
opt.old.call( this );
|
8590 | |
}
|
8591 | |
|
8592 | |
if ( opt.queue ) {
|
8593 | |
jQuery.dequeue( this, opt.queue );
|
8594 | |
} else if ( noUnmark !== false ) {
|
8595 | |
jQuery._unmark( this );
|
8596 | |
}
|
8597 | |
};
|
8598 | |
|
8599 | |
return opt;
|
8600 | |
},
|
8601 | |
|
8602 | |
easing: {
|
8603 | |
linear: function( p, n, firstNum, diff ) {
|
8604 | |
return firstNum + diff * p;
|
8605 | |
},
|
8606 | |
swing: function( p, n, firstNum, diff ) {
|
8607 | |
return ( ( -Math.cos( p*Math.PI ) / 2 ) + 0.5 ) * diff + firstNum;
|
8608 | |
}
|
8609 | |
},
|
8610 | |
|
8611 | |
timers: [],
|
8612 | |
|
8613 | |
fx: function( elem, options, prop ) {
|
8614 | |
this.options = options;
|
8615 | |
this.elem = elem;
|
8616 | |
this.prop = prop;
|
8617 | |
|
8618 | |
options.orig = options.orig || {};
|
8619 | |
}
|
8620 | |
|
8621 | |
});
|
8622 | |
|
8623 | |
jQuery.fx.prototype = {
|
8624 | |
// Simple function for setting a style value
|
8625 | |
update: function() {
|
8626 | |
if ( this.options.step ) {
|
8627 | |
this.options.step.call( this.elem, this.now, this );
|
8628 | |
}
|
8629 | |
|
8630 | |
( jQuery.fx.step[ this.prop ] || jQuery.fx.step._default )( this );
|
8631 | |
},
|
8632 | |
|
8633 | |
// Get the current size
|
8634 | |
cur: function() {
|
8635 | |
if ( this.elem[ this.prop ] != null && (!this.elem.style || this.elem.style[ this.prop ] == null) ) {
|
8636 | |
return this.elem[ this.prop ];
|
8637 | |
}
|
8638 | |
|
8639 | |
var parsed,
|
8640 | |
r = jQuery.css( this.elem, this.prop );
|
8641 | |
// Empty strings, null, undefined and "auto" are converted to 0,
|
8642 | |
// complex values such as "rotate(1rad)" are returned as is,
|
8643 | |
// simple values such as "10px" are parsed to Float.
|
8644 | |
return isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" ? 0 : r : parsed;
|
8645 | |
},
|
8646 | |
|
8647 | |
// Start an animation from one number to another
|
8648 | |
custom: function( from, to, unit ) {
|
8649 | |
var self = this,
|
8650 | |
fx = jQuery.fx;
|
8651 | |
|
8652 | |
this.startTime = fxNow || createFxNow();
|
8653 | |
this.end = to;
|
8654 | |
this.now = this.start = from;
|
8655 | |
this.pos = this.state = 0;
|
8656 | |
this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" );
|
8657 | |
|
8658 | |
function t( gotoEnd ) {
|
8659 | |
return self.step( gotoEnd );
|
8660 | |
}
|
8661 | |
|
8662 | |
t.queue = this.options.queue;
|
8663 | |
t.elem = this.elem;
|
8664 | |
t.saveState = function() {
|
8665 | |
if ( self.options.hide && jQuery._data( self.elem, "fxshow" + self.prop ) === undefined ) {
|
8666 | |
jQuery._data( self.elem, "fxshow" + self.prop, self.start );
|
8667 | |
}
|
8668 | |
};
|
8669 | |
|
8670 | |
if ( t() && jQuery.timers.push(t) && !timerId ) {
|
8671 | |
timerId = setInterval( fx.tick, fx.interval );
|
8672 | |
}
|
8673 | |
},
|
8674 | |
|
8675 | |
// Simple 'show' function
|
8676 | |
show: function() {
|
8677 | |
var dataShow = jQuery._data( this.elem, "fxshow" + this.prop );
|
8678 | |
|
8679 | |
// Remember where we started, so that we can go back to it later
|
8680 | |
this.options.orig[ this.prop ] = dataShow || jQuery.style( this.elem, this.prop );
|
8681 | |
this.options.show = true;
|
8682 | |
|
8683 | |
// Begin the animation
|
8684 | |
// Make sure that we start at a small width/height to avoid any flash of content
|
8685 | |
if ( dataShow !== undefined ) {
|
8686 | |
// This show is picking up where a previous hide or show left off
|
8687 | |
this.custom( this.cur(), dataShow );
|
8688 | |
} else {
|
8689 | |
this.custom( this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur() );
|
8690 | |
}
|
8691 | |
|
8692 | |
// Start by showing the element
|
8693 | |
jQuery( this.elem ).show();
|
8694 | |
},
|
8695 | |
|
8696 | |
// Simple 'hide' function
|
8697 | |
hide: function() {
|
8698 | |
// Remember where we started, so that we can go back to it later
|
8699 | |
this.options.orig[ this.prop ] = jQuery._data( this.elem, "fxshow" + this.prop ) || jQuery.style( this.elem, this.prop );
|
8700 | |
this.options.hide = true;
|
8701 | |
|
8702 | |
// Begin the animation
|
8703 | |
this.custom( this.cur(), 0 );
|
8704 | |
},
|
8705 | |
|
8706 | |
// Each step of an animation
|
8707 | |
step: function( gotoEnd ) {
|
8708 | |
var p, n, complete,
|
8709 | |
t = fxNow || createFxNow(),
|
8710 | |
done = true,
|
8711 | |
elem = this.elem,
|
8712 | |
options = this.options;
|
8713 | |
|
8714 | |
if ( gotoEnd || t >= options.duration + this.startTime ) {
|
8715 | |
this.now = this.end;
|
8716 | |
this.pos = this.state = 1;
|
8717 | |
this.update();
|
8718 | |
|
8719 | |
options.animatedProperties[ this.prop ] = true;
|
8720 | |
|
8721 | |
for ( p in options.animatedProperties ) {
|
8722 | |
if ( options.animatedProperties[ p ] !== true ) {
|
8723 | |
done = false;
|
8724 | |
}
|
8725 | |
}
|
8726 | |
|
8727 | |
if ( done ) {
|
8728 | |
// Reset the overflow
|
8729 | |
if ( options.overflow != null && !jQuery.support.shrinkWrapBlocks ) {
|
8730 | |
|
8731 | |
jQuery.each( [ "", "X", "Y" ], function( index, value ) {
|
8732 | |
elem.style[ "overflow" + value ] = options.overflow[ index ];
|
8733 | |
});
|
8734 | |
}
|
8735 | |
|
8736 | |
// Hide the element if the "hide" operation was done
|
8737 | |
if ( options.hide ) {
|
8738 | |
jQuery( elem ).hide();
|
8739 | |
}
|
8740 | |
|
8741 | |
// Reset the properties, if the item has been hidden or shown
|
8742 | |
if ( options.hide || options.show ) {
|
8743 | |
for ( p in options.animatedProperties ) {
|
8744 | |
jQuery.style( elem, p, options.orig[ p ] );
|
8745 | |
jQuery.removeData( elem, "fxshow" + p, true );
|
8746 | |
// Toggle data is no longer needed
|
8747 | |
jQuery.removeData( elem, "toggle" + p, true );
|
8748 | |
}
|
8749 | |
}
|
8750 | |
|
8751 | |
// Execute the complete function
|
8752 | |
// in the event that the complete function throws an exception
|
8753 | |
// we must ensure it won't be called twice. #5684
|
8754 | |
|
8755 | |
complete = options.complete;
|
8756 | |
if ( complete ) {
|
8757 | |
|
8758 | |
options.complete = false;
|
8759 | |
complete.call( elem );
|
8760 | |
}
|
8761 | |
}
|
8762 | |
|
8763 | |
return false;
|
8764 | |
|
8765 | |
} else {
|
8766 | |
// classical easing cannot be used with an Infinity duration
|
8767 | |
if ( options.duration == Infinity ) {
|
8768 | |
this.now = t;
|
8769 | |
} else {
|
8770 | |
n = t - this.startTime;
|
8771 | |
this.state = n / options.duration;
|
8772 | |
|
8773 | |
// Perform the easing function, defaults to swing
|
8774 | |
this.pos = jQuery.easing[ options.animatedProperties[this.prop] ]( this.state, n, 0, 1, options.duration );
|
8775 | |
this.now = this.start + ( (this.end - this.start) * this.pos );
|
8776 | |
}
|
8777 | |
// Perform the next step of the animation
|
8778 | |
this.update();
|
8779 | |
}
|
8780 | |
|
8781 | |
return true;
|
8782 | |
}
|
8783 | |
};
|
8784 | |
|
8785 | |
jQuery.extend( jQuery.fx, {
|
8786 | |
tick: function() {
|
8787 | |
var timer,
|
8788 | |
timers = jQuery.timers,
|
8789 | |
i = 0;
|
8790 | |
|
8791 | |
for ( ; i < timers.length; i++ ) {
|
8792 | |
timer = timers[ i ];
|
8793 | |
// Checks the timer has not already been removed
|
8794 | |
if ( !timer() && timers[ i ] === timer ) {
|
8795 | |
timers.splice( i--, 1 );
|
8796 | |
}
|
8797 | |
}
|
8798 | |
|
8799 | |
if ( !timers.length ) {
|
8800 | |
jQuery.fx.stop();
|
8801 | |
}
|
8802 | |
},
|
8803 | |
|
8804 | |
interval: 13,
|
8805 | |
|
8806 | |
stop: function() {
|
8807 | |
clearInterval( timerId );
|
8808 | |
timerId = null;
|
8809 | |
},
|
8810 | |
|
8811 | |
speeds: {
|
8812 | |
slow: 600,
|
8813 | |
fast: 200,
|
8814 | |
// Default speed
|
8815 | |
_default: 400
|
8816 | |
},
|
8817 | |
|
8818 | |
step: {
|
8819 | |
opacity: function( fx ) {
|
8820 | |
jQuery.style( fx.elem, "opacity", fx.now );
|
8821 | |
},
|
8822 | |
|
8823 | |
_default: function( fx ) {
|
8824 | |
if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
|
8825 | |
fx.elem.style[ fx.prop ] = fx.now + fx.unit;
|
8826 | |
} else {
|
8827 | |
fx.elem[ fx.prop ] = fx.now;
|
8828 | |
}
|
8829 | |
}
|
8830 | |
}
|
8831 | |
});
|
8832 | |
|
8833 | |
// Adds width/height step functions
|
8834 | |
// Do not set anything below 0
|
8835 | |
jQuery.each([ "width", "height" ], function( i, prop ) {
|
8836 | |
jQuery.fx.step[ prop ] = function( fx ) {
|
8837 | |
jQuery.style( fx.elem, prop, Math.max(0, fx.now) + fx.unit );
|
8838 | |
};
|
8839 | |
});
|
8840 | |
|
8841 | |
if ( jQuery.expr && jQuery.expr.filters ) {
|
8842 | |
jQuery.expr.filters.animated = function( elem ) {
|
8843 | |
return jQuery.grep(jQuery.timers, function( fn ) {
|
8844 | |
return elem === fn.elem;
|
8845 | |
}).length;
|
8846 | |
};
|
8847 | |
}
|
8848 | |
|
8849 | |
// Try to restore the default display value of an element
|
8850 | |
function defaultDisplay( nodeName ) {
|
8851 | |
|
8852 | |
if ( !elemdisplay[ nodeName ] ) {
|
8853 | |
|
8854 | |
var body = document.body,
|
8855 | |
elem = jQuery( "<" + nodeName + ">" ).appendTo( body ),
|
8856 | |
display = elem.css( "display" );
|
8857 | |
elem.remove();
|
8858 | |
|
8859 | |
// If the simple way fails,
|
8860 | |
// get element's real default display by attaching it to a temp iframe
|
8861 | |
if ( display === "none" || display === "" ) {
|
8862 | |
// No iframe to use yet, so create it
|
8863 | |
if ( !iframe ) {
|
8864 | |
iframe = document.createElement( "iframe" );
|
8865 | |
iframe.frameBorder = iframe.width = iframe.height = 0;
|
8866 | |
}
|
8867 | |
|
8868 | |
body.appendChild( iframe );
|
8869 | |
|
8870 | |
// Create a cacheable copy of the iframe document on first call.
|
8871 | |
// IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML
|
8872 | |
// document to it; WebKit & Firefox won't allow reusing the iframe document.
|
8873 | |
if ( !iframeDoc || !iframe.createElement ) {
|
8874 | |
iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
|
8875 | |
iframeDoc.write( ( document.compatMode === "CSS1Compat" ? "<!doctype html>" : "" ) + "<html><body>" );
|
8876 | |
iframeDoc.close();
|
8877 | |
}
|
8878 | |
|
8879 | |
elem = iframeDoc.createElement( nodeName );
|
8880 | |
|
8881 | |
iframeDoc.body.appendChild( elem );
|
8882 | |
|
8883 | |
display = jQuery.css( elem, "display" );
|
8884 | |
body.removeChild( iframe );
|
8885 | |
}
|
8886 | |
|
8887 | |
// Store the correct default display
|
8888 | |
elemdisplay[ nodeName ] = display;
|
8889 | |
}
|
8890 | |
|
8891 | |
return elemdisplay[ nodeName ];
|
8892 | |
}
|
8893 | |
|
8894 | |
|
8895 | |
|
8896 | |
|
8897 | |
var rtable = /^t(?:able|d|h)$/i,
|
8898 | |
rroot = /^(?:body|html)$/i;
|
8899 | |
|
8900 | |
if ( "getBoundingClientRect" in document.documentElement ) {
|
8901 | |
jQuery.fn.offset = function( options ) {
|
8902 | |
var elem = this[0], box;
|
8903 | |
|
8904 | |
if ( options ) {
|
8905 | |
return this.each(function( i ) {
|
8906 | |
jQuery.offset.setOffset( this, options, i );
|
8907 | |
});
|
8908 | |
}
|
8909 | |
|
8910 | |
if ( !elem || !elem.ownerDocument ) {
|
8911 | |
return null;
|
8912 | |
}
|
8913 | |
|
8914 | |
if ( elem === elem.ownerDocument.body ) {
|
8915 | |
return jQuery.offset.bodyOffset( elem );
|
8916 | |
}
|
8917 | |
|
8918 | |
try {
|
8919 | |
box = elem.getBoundingClientRect();
|
8920 | |
} catch(e) {}
|
8921 | |
|
8922 | |
var doc = elem.ownerDocument,
|
8923 | |
docElem = doc.documentElement;
|
8924 | |
|
8925 | |
// Make sure we're not dealing with a disconnected DOM node
|
8926 | |
if ( !box || !jQuery.contains( docElem, elem ) ) {
|
8927 | |
return box ? { top: box.top, left: box.left } : { top: 0, left: 0 };
|
8928 | |
}
|
8929 | |
|
8930 | |
var body = doc.body,
|
8931 | |
win = getWindow(doc),
|
8932 | |
clientTop = docElem.clientTop || body.clientTop || 0,
|
8933 | |
clientLeft = docElem.clientLeft || body.clientLeft || 0,
|
8934 | |
scrollTop = win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop,
|
8935 | |
scrollLeft = win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft,
|
8936 | |
top = box.top + scrollTop - clientTop,
|
8937 | |
left = box.left + scrollLeft - clientLeft;
|
8938 | |
|
8939 | |
return { top: top, left: left };
|
8940 | |
};
|
8941 | |
|
8942 | |
} else {
|
8943 | |
jQuery.fn.offset = function( options ) {
|
8944 | |
var elem = this[0];
|
8945 | |
|
8946 | |
if ( options ) {
|
8947 | |
return this.each(function( i ) {
|
8948 | |
jQuery.offset.setOffset( this, options, i );
|
8949 | |
});
|
8950 | |
}
|
8951 | |
|
8952 | |
if ( !elem || !elem.ownerDocument ) {
|
8953 | |
return null;
|
8954 | |
}
|
8955 | |
|
8956 | |
if ( elem === elem.ownerDocument.body ) {
|
8957 | |
return jQuery.offset.bodyOffset( elem );
|
8958 | |
}
|
8959 | |
|
8960 | |
var computedStyle,
|
8961 | |
offsetParent = elem.offsetParent,
|
8962 | |
prevOffsetParent = elem,
|
8963 | |
doc = elem.ownerDocument,
|
8964 | |
docElem = doc.documentElement,
|
8965 | |
body = doc.body,
|
8966 | |
defaultView = doc.defaultView,
|
8967 | |
prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
|
8968 | |
top = elem.offsetTop,
|
8969 | |
left = elem.offsetLeft;
|
8970 | |
|
8971 | |
while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
|
8972 | |
if ( jQuery.support.fixedPosition && prevComputedStyle.position === "fixed" ) {
|
8973 | |
break;
|
8974 | |
}
|
8975 | |
|
8976 | |
computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
|
8977 | |
top -= elem.scrollTop;
|
8978 | |
left -= elem.scrollLeft;
|
8979 | |
|
8980 | |
if ( elem === offsetParent ) {
|
8981 | |
top += elem.offsetTop;
|
8982 | |
left += elem.offsetLeft;
|
8983 | |
|
8984 | |
if ( jQuery.support.doesNotAddBorder && !(jQuery.support.doesAddBorderForTableAndCells && rtable.test(elem.nodeName)) ) {
|
8985 | |
top += parseFloat( computedStyle.borderTopWidth ) || 0;
|
8986 | |
left += parseFloat( computedStyle.borderLeftWidth ) || 0;
|
8987 | |
}
|
8988 | |
|
8989 | |
prevOffsetParent = offsetParent;
|
8990 | |
offsetParent = elem.offsetParent;
|
8991 | |
}
|
8992 | |
|
8993 | |
if ( jQuery.support.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
|
8994 | |
top += parseFloat( computedStyle.borderTopWidth ) || 0;
|
8995 | |
left += parseFloat( computedStyle.borderLeftWidth ) || 0;
|
8996 | |
}
|
8997 | |
|
8998 | |
prevComputedStyle = computedStyle;
|
8999 | |
}
|
9000 | |
|
9001 | |
if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {
|
9002 | |
top += body.offsetTop;
|
9003 | |
left += body.offsetLeft;
|
9004 | |
}
|
9005 | |
|
9006 | |
if ( jQuery.support.fixedPosition && prevComputedStyle.position === "fixed" ) {
|
9007 | |
top += Math.max( docElem.scrollTop, body.scrollTop );
|
9008 | |
left += Math.max( docElem.scrollLeft, body.scrollLeft );
|
9009 | |
}
|
9010 | |
|
9011 | |
return { top: top, left: left };
|
9012 | |
};
|
9013 | |
}
|
9014 | |
|
9015 | |
jQuery.offset = {
|
9016 | |
|
9017 | |
bodyOffset: function( body ) {
|
9018 | |
var top = body.offsetTop,
|
9019 | |
left = body.offsetLeft;
|
9020 | |
|
9021 | |
if ( jQuery.support.doesNotIncludeMarginInBodyOffset ) {
|
9022 | |
top += parseFloat( jQuery.css(body, "marginTop") ) || 0;
|
9023 | |
left += parseFloat( jQuery.css(body, "marginLeft") ) || 0;
|
9024 | |
}
|
9025 | |
|
9026 | |
return { top: top, left: left };
|
9027 | |
},
|
9028 | |
|
9029 | |
setOffset: function( elem, options, i ) {
|
9030 | |
var position = jQuery.css( elem, "position" );
|
9031 | |
|
9032 | |
// set position first, in-case top/left are set even on static elem
|
9033 | |
if ( position === "static" ) {
|
9034 | |
elem.style.position = "relative";
|
9035 | |
}
|
9036 | |
|
9037 | |
var curElem = jQuery( elem ),
|
9038 | |
curOffset = curElem.offset(),
|
9039 | |
curCSSTop = jQuery.css( elem, "top" ),
|
9040 | |
curCSSLeft = jQuery.css( elem, "left" ),
|
9041 | |
calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
|
9042 | |
props = {}, curPosition = {}, curTop, curLeft;
|
9043 | |
|
9044 | |
// need to be able to calculate position if either top or left is auto and position is either absolute or fixed
|
9045 | |
if ( calculatePosition ) {
|
9046 | |
curPosition = curElem.position();
|
9047 | |
curTop = curPosition.top;
|
9048 | |
curLeft = curPosition.left;
|
9049 | |
} else {
|
9050 | |
curTop = parseFloat( curCSSTop ) || 0;
|
9051 | |
curLeft = parseFloat( curCSSLeft ) || 0;
|
9052 | |
}
|
9053 | |
|
9054 | |
if ( jQuery.isFunction( options ) ) {
|
9055 | |
options = options.call( elem, i, curOffset );
|
9056 | |
}
|
9057 | |
|
9058 | |
if ( options.top != null ) {
|
9059 | |
props.top = ( options.top - curOffset.top ) + curTop;
|
9060 | |
}
|
9061 | |
if ( options.left != null ) {
|
9062 | |
props.left = ( options.left - curOffset.left ) + curLeft;
|
9063 | |
}
|
9064 | |
|
9065 | |
if ( "using" in options ) {
|
9066 | |
options.using.call( elem, props );
|
9067 | |
} else {
|
9068 | |
curElem.css( props );
|
9069 | |
}
|
9070 | |
}
|
9071 | |
};
|
9072 | |
|
9073 | |
|
9074 | |
jQuery.fn.extend({
|
9075 | |
|
9076 | |
position: function() {
|
9077 | |
if ( !this[0] ) {
|
9078 | |
return null;
|
9079 | |
}
|
9080 | |
|
9081 | |
var elem = this[0],
|
9082 | |
|
9083 | |
// Get *real* offsetParent
|
9084 | |
offsetParent = this.offsetParent(),
|
9085 | |
|
9086 | |
// Get correct offsets
|
9087 | |
offset = this.offset(),
|
9088 | |
parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
|
9089 | |
|
9090 | |
// Subtract element margins
|
9091 | |
// note: when an element has margin: auto the offsetLeft and marginLeft
|
9092 | |
// are the same in Safari causing offset.left to incorrectly be 0
|
9093 | |
offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0;
|
9094 | |
offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0;
|
9095 | |
|
9096 | |
// Add offsetParent borders
|
9097 | |
parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0;
|
9098 | |
parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0;
|
9099 | |
|
9100 | |
// Subtract the two offsets
|
9101 | |
return {
|
9102 | |
top: offset.top - parentOffset.top,
|
9103 | |
left: offset.left - parentOffset.left
|
9104 | |
};
|
9105 | |
},
|
9106 | |
|
9107 | |
offsetParent: function() {
|
9108 | |
return this.map(function() {
|
9109 | |
var offsetParent = this.offsetParent || document.body;
|
9110 | |
while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
|
9111 | |
offsetParent = offsetParent.offsetParent;
|
9112 | |
}
|
9113 | |
return offsetParent;
|
9114 | |
});
|
9115 | |
}
|
9116 | |
});
|
9117 | |
|
9118 | |
|
9119 | |
// Create scrollLeft and scrollTop methods
|
9120 | |
jQuery.each( ["Left", "Top"], function( i, name ) {
|
9121 | |
var method = "scroll" + name;
|
9122 | |
|
9123 | |
jQuery.fn[ method ] = function( val ) {
|
9124 | |
var elem, win;
|
9125 | |
|
9126 | |
if ( val === undefined ) {
|
9127 | |
elem = this[ 0 ];
|
9128 | |
|
9129 | |
if ( !elem ) {
|
9130 | |
return null;
|
9131 | |
}
|
9132 | |
|
9133 | |
win = getWindow( elem );
|
9134 | |
|
9135 | |
// Return the scroll offset
|
9136 | |
return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
|
9137 | |
jQuery.support.boxModel && win.document.documentElement[ method ] ||
|
9138 | |
win.document.body[ method ] :
|
9139 | |
elem[ method ];
|
9140 | |
}
|
9141 | |
|
9142 | |
// Set the scroll offset
|
9143 | |
return this.each(function() {
|
9144 | |
win = getWindow( this );
|
9145 | |
|
9146 | |
if ( win ) {
|
9147 | |
win.scrollTo(
|
9148 | |
!i ? val : jQuery( win ).scrollLeft(),
|
9149 | |
i ? val : jQuery( win ).scrollTop()
|
9150 | |
);
|
9151 | |
|
9152 | |
} else {
|
9153 | |
this[ method ] = val;
|
9154 | |
}
|
9155 | |
});
|
9156 | |
};
|
9157 | |
});
|
9158 | |
|
9159 | |
function getWindow( elem ) {
|
9160 | |
return jQuery.isWindow( elem ) ?
|
9161 | |
elem :
|
9162 | |
elem.nodeType === 9 ?
|
9163 | |
elem.defaultView || elem.parentWindow :
|
9164 | |
false;
|
9165 | |
}
|
9166 | |
|
9167 | |
|
9168 | |
|
9169 | |
|
9170 | |
// Create width, height, innerHeight, innerWidth, outerHeight and outerWidth methods
|
9171 | |
jQuery.each([ "Height", "Width" ], function( i, name ) {
|
9172 | |
|
9173 | |
var type = name.toLowerCase();
|
9174 | |
|
9175 | |
// innerHeight and innerWidth
|
9176 | |
jQuery.fn[ "inner" + name ] = function() {
|
9177 | |
var elem = this[0];
|
9178 | |
return elem ?
|
9179 | |
elem.style ?
|
9180 | |
parseFloat( jQuery.css( elem, type, "padding" ) ) :
|
9181 | |
this[ type ]() :
|
9182 | |
null;
|
9183 | |
};
|
9184 | |
|
9185 | |
// outerHeight and outerWidth
|
9186 | |
jQuery.fn[ "outer" + name ] = function( margin ) {
|
9187 | |
var elem = this[0];
|
9188 | |
return elem ?
|
9189 | |
elem.style ?
|
9190 | |
parseFloat( jQuery.css( elem, type, margin ? "margin" : "border" ) ) :
|
9191 | |
this[ type ]() :
|
9192 | |
null;
|
9193 | |
};
|
9194 | |
|
9195 | |
jQuery.fn[ type ] = function( size ) {
|
9196 | |
// Get window width or height
|
9197 | |
var elem = this[0];
|
9198 | |
if ( !elem ) {
|
9199 | |
return size == null ? null : this;
|
9200 | |
}
|
9201 | |
|
9202 | |
if ( jQuery.isFunction( size ) ) {
|
9203 | |
return this.each(function( i ) {
|
9204 | |
var self = jQuery( this );
|
9205 | |
self[ type ]( size.call( this, i, self[ type ]() ) );
|
9206 | |
});
|
9207 | |
}
|
9208 | |
|
9209 | |
if ( jQuery.isWindow( elem ) ) {
|
9210 | |
// Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
|
9211 | |
// 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat
|
9212 | |
var docElemProp = elem.document.documentElement[ "client" + name ],
|
9213 | |
body = elem.document.body;
|
9214 | |
return elem.document.compatMode === "CSS1Compat" && docElemProp ||
|
9215 | |
body && body[ "client" + name ] || docElemProp;
|
9216 | |
|
9217 | |
// Get document width or height
|
9218 | |
} else if ( elem.nodeType === 9 ) {
|
9219 | |
// Either scroll[Width/Height] or offset[Width/Height], whichever is greater
|
9220 | |
return Math.max(
|
9221 | |
elem.documentElement["client" + name],
|
9222 | |
elem.body["scroll" + name], elem.documentElement["scroll" + name],
|
9223 | |
elem.body["offset" + name], elem.documentElement["offset" + name]
|
9224 | |
);
|
9225 | |
|
9226 | |
// Get or set width or height on the element
|
9227 | |
} else if ( size === undefined ) {
|
9228 | |
var orig = jQuery.css( elem, type ),
|
9229 | |
ret = parseFloat( orig );
|
9230 | |
|
9231 | |
return jQuery.isNumeric( ret ) ? ret : orig;
|
9232 | |
|
9233 | |
// Set the width or height on the element (default to pixels if value is unitless)
|
9234 | |
} else {
|
9235 | |
return this.css( type, typeof size === "string" ? size : size + "px" );
|
9236 | |
}
|
9237 | |
};
|
9238 | |
|
9239 | |
});
|
9240 | |
|
9241 | |
|
9242 | |
|
9243 | |
|
9244 | |
// Expose jQuery to the global object
|
9245 | |
window.jQuery = window.$ = jQuery;
|
9246 | |
|
9247 | |
// Expose jQuery as an AMD module, but only for AMD loaders that
|
9248 | |
// understand the issues with loading multiple versions of jQuery
|
9249 | |
// in a page that all might call define(). The loader will indicate
|
9250 | |
// they have special allowances for multiple jQuery versions by
|
9251 | |
// specifying define.amd.jQuery = true. Register as a named module,
|
9252 | |
// since jQuery can be concatenated with other files that may use define,
|
9253 | |
// but not use a proper concatenation script that understands anonymous
|
9254 | |
// AMD modules. A named AMD is safest and most robust way to register.
|
9255 | |
// Lowercase jquery is used because AMD module names are derived from
|
9256 | |
// file names, and jQuery is normally delivered in a lowercase file name.
|
9257 | |
// Do this after creating the global so that if an AMD module wants to call
|
9258 | |
// noConflict to hide this version of jQuery, it will work.
|
9259 | |
if ( typeof define === "function" && define.amd && define.amd.jQuery ) {
|
9260 | |
define( "jquery", [], function () { return jQuery; } );
|
9261 | |
}
|
9262 | |
|
9263 | |
|
9264 | |
|
9265 | |
})( window );
|