1 |
/*! |
2 |
* jQuery JavaScript Library v1.8.1 |
3 |
* http://jquery.com/ |
4 |
* |
5 |
* Includes Sizzle.js |
6 |
* http://sizzlejs.com/ |
7 |
* |
8 |
* Copyright 2012 jQuery Foundation and other contributors |
9 |
* Released under the MIT license |
10 |
* http://jquery.org/license |
11 |
* |
12 |
* Date: Thu Aug 30 2012 17:17:22 GMT-0400 (Eastern Daylight Time) |
13 |
*/ |
14 |
(function( window, undefined ) { |
15 |
var |
16 |
// A central reference to the root jQuery(document) |
17 |
rootjQuery, |
18 |
|
19 |
// The deferred used on DOM ready |
20 |
readyList, |
21 |
|
22 |
// Use the correct document accordingly with window argument (sandbox) |
23 |
document = window.document, |
24 |
location = window.location, |
25 |
navigator = window.navigator, |
26 |
|
27 |
// Map over jQuery in case of overwrite |
28 |
_jQuery = window.jQuery, |
29 |
|
30 |
// Map over the $ in case of overwrite |
31 |
_$ = window.$, |
32 |
|
33 |
// Save a reference to some core methods |
34 |
core_push = Array.prototype.push, |
35 |
core_slice = Array.prototype.slice, |
36 |
core_indexOf = Array.prototype.indexOf, |
37 |
core_toString = Object.prototype.toString, |
38 |
core_hasOwn = Object.prototype.hasOwnProperty, |
39 |
core_trim = String.prototype.trim, |
40 |
|
41 |
// Define a local copy of jQuery |
42 |
jQuery = function( selector, context ) { |
43 |
// The jQuery object is actually just the init constructor 'enhanced' |
44 |
return new jQuery.fn.init( selector, context, rootjQuery ); |
45 |
}, |
46 |
|
47 |
// Used for matching numbers |
48 |
core_pnum = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source, |
49 |
|
50 |
// Used for detecting and trimming whitespace |
51 |
core_rnotwhite = /\S/, |
52 |
core_rspace = /\s+/, |
53 |
|
54 |
// Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE) |
55 |
rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, |
56 |
|
57 |
// A simple way to check for HTML strings |
58 |
// Prioritize #id over <tag> to avoid XSS via location.hash (#9521) |
59 |
rquickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/, |
60 |
|
61 |
// Match a standalone tag |
62 |
rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/, |
63 |
|
64 |
// JSON RegExp |
65 |
rvalidchars = /^[\],:{}\s]*$/, |
66 |
rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, |
67 |
rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g, |
68 |
rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g, |
69 |
|
70 |
// Matches dashed string for camelizing |
71 |
rmsPrefix = /^-ms-/, |
72 |
rdashAlpha = /-([\da-z])/gi, |
73 |
|
74 |
// Used by jQuery.camelCase as callback to replace() |
75 |
fcamelCase = function( all, letter ) { |
76 |
return ( letter + "" ).toUpperCase(); |
77 |
}, |
78 |
|
79 |
// The ready event handler and self cleanup method |
80 |
DOMContentLoaded = function() { |
81 |
if ( document.addEventListener ) { |
82 |
document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false ); |
83 |
jQuery.ready(); |
84 |
} else if ( document.readyState === "complete" ) { |
85 |
// we're here because readyState === "complete" in oldIE |
86 |
// which is good enough for us to call the dom ready! |
87 |
document.detachEvent( "onreadystatechange", DOMContentLoaded ); |
88 |
jQuery.ready(); |
89 |
} |
90 |
}, |
91 |
|
92 |
// [[Class]] -> type pairs |
93 |
class2type = {}; |
94 |
|
95 |
jQuery.fn = jQuery.prototype = { |
96 |
constructor: jQuery, |
97 |
init: function( selector, context, rootjQuery ) { |
98 |
var match, elem, ret, doc; |
99 |
|
100 |
// Handle $(""), $(null), $(undefined), $(false) |
101 |
if ( !selector ) { |
102 |
return this; |
103 |
} |
104 |
|
105 |
// Handle $(DOMElement) |
106 |
if ( selector.nodeType ) { |
107 |
this.context = this[0] = selector; |
108 |
this.length = 1; |
109 |
return this; |
110 |
} |
111 |
|
112 |
// Handle HTML strings |
113 |
if ( typeof selector === "string" ) { |
114 |
if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { |
115 |
// Assume that strings that start and end with <> are HTML and skip the regex check |
116 |
match = [ null, selector, null ]; |
117 |
|
118 |
} else { |
119 |
match = rquickExpr.exec( selector ); |
120 |
} |
121 |
|
122 |
// Match html or make sure no context is specified for #id |
123 |
if ( match && (match[1] || !context) ) { |
124 |
|
125 |
// HANDLE: $(html) -> $(array) |
126 |
if ( match[1] ) { |
127 |
context = context instanceof jQuery ? context[0] : context; |
128 |
doc = ( context && context.nodeType ? context.ownerDocument || context : document ); |
129 |
|
130 |
// scripts is true for back-compat |
131 |
selector = jQuery.parseHTML( match[1], doc, true ); |
132 |
if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) { |
133 |
this.attr.call( selector, context, true ); |
134 |
} |
135 |
|
136 |
return jQuery.merge( this, selector ); |
137 |
|
138 |
// HANDLE: $(#id) |
139 |
} else { |
140 |
elem = document.getElementById( match[2] ); |
141 |
|
142 |
// Check parentNode to catch when Blackberry 4.6 returns |
143 |
// nodes that are no longer in the document #6963 |
144 |
if ( elem && elem.parentNode ) { |
145 |
// Handle the case where IE and Opera return items |
146 |
// by name instead of ID |
147 |
if ( elem.id !== match[2] ) { |
148 |
return rootjQuery.find( selector ); |
149 |
} |
150 |
|
151 |
// Otherwise, we inject the element directly into the jQuery object |
152 |
this.length = 1; |
153 |
this[0] = elem; |
154 |
} |
155 |
|
156 |
this.context = document; |
157 |
this.selector = selector; |
158 |
return this; |
159 |
} |
160 |
|
161 |
// HANDLE: $(expr, $(...)) |
162 |
} else if ( !context || context.jquery ) { |
163 |
return ( context || rootjQuery ).find( selector ); |
164 |
|
165 |
// HANDLE: $(expr, context) |
166 |
// (which is just equivalent to: $(context).find(expr) |
167 |
} else { |
168 |
return this.constructor( context ).find( selector ); |
169 |
} |
170 |
|
171 |
// HANDLE: $(function) |
172 |
// Shortcut for document ready |
173 |
} else if ( jQuery.isFunction( selector ) ) { |
174 |
return rootjQuery.ready( selector ); |
175 |
} |
176 |
|
177 |
if ( selector.selector !== undefined ) { |
178 |
this.selector = selector.selector; |
179 |
this.context = selector.context; |
180 |
} |
181 |
|
182 |
return jQuery.makeArray( selector, this ); |
183 |
}, |
184 |
|
185 |
// Start with an empty selector |
186 |
selector: "", |
187 |
|
188 |
// The current version of jQuery being used |
189 |
jquery: "1.8.1", |
190 |
|
191 |
// The default length of a jQuery object is 0 |
192 |
length: 0, |
193 |
|
194 |
// The number of elements contained in the matched element set |
195 |
size: function() { |
196 |
return this.length; |
197 |
}, |
198 |
|
199 |
toArray: function() { |
200 |
return core_slice.call( this ); |
201 |
}, |
202 |
|
203 |
// Get the Nth element in the matched element set OR |
204 |
// Get the whole matched element set as a clean array |
205 |
get: function( num ) { |
206 |
return num == null ? |
207 |
|
208 |
// Return a 'clean' array |
209 |
this.toArray() : |
210 |
|
211 |
// Return just the object |
212 |
( num < 0 ? this[ this.length + num ] : this[ num ] ); |
213 |
}, |
214 |
|
215 |
// Take an array of elements and push it onto the stack |
216 |
// (returning the new matched element set) |
217 |
pushStack: function( elems, name, selector ) { |
218 |
|
219 |
// Build a new jQuery matched element set |
220 |
var ret = jQuery.merge( this.constructor(), elems ); |
221 |
|
222 |
// Add the old object onto the stack (as a reference) |
223 |
ret.prevObject = this; |
224 |
|
225 |
ret.context = this.context; |
226 |
|
227 |
if ( name === "find" ) { |
228 |
ret.selector = this.selector + ( this.selector ? " " : "" ) + selector; |
229 |
} else if ( name ) { |
230 |
ret.selector = this.selector + "." + name + "(" + selector + ")"; |
231 |
} |
232 |
|
233 |
// Return the newly-formed element set |
234 |
return ret; |
235 |
}, |
236 |
|
237 |
// Execute a callback for every element in the matched set. |
238 |
// (You can seed the arguments with an array of args, but this is |
239 |
// only used internally.) |
240 |
each: function( callback, args ) { |
241 |
return jQuery.each( this, callback, args ); |
242 |
}, |
243 |
|
244 |
ready: function( fn ) { |
245 |
// Add the callback |
246 |
jQuery.ready.promise().done( fn ); |
247 |
|
248 |
return this; |
249 |
}, |
250 |
|
251 |
eq: function( i ) { |
252 |
i = +i; |
253 |
return i === -1 ? |
254 |
this.slice( i ) : |
255 |
this.slice( i, i + 1 ); |
256 |
}, |
257 |
|
258 |
first: function() { |
259 |
return this.eq( 0 ); |
260 |
}, |
261 |
|
262 |
last: function() { |
263 |
return this.eq( -1 ); |
264 |
}, |
265 |
|
266 |
slice: function() { |
267 |
return this.pushStack( core_slice.apply( this, arguments ), |
268 |
"slice", core_slice.call(arguments).join(",") ); |
269 |
}, |
270 |
|
271 |
map: function( callback ) { |
272 |
return this.pushStack( jQuery.map(this, function( elem, i ) { |
273 |
return callback.call( elem, i, elem ); |
274 |
})); |
275 |
}, |
276 |
|
277 |
end: function() { |
278 |
return this.prevObject || this.constructor(null); |
279 |
}, |
280 |
|
281 |
// For internal use only. |
282 |
// Behaves like an Array's method, not like a jQuery method. |
283 |
push: core_push, |
284 |
sort: [].sort, |
285 |
splice: [].splice |
286 |
}; |
287 |
|
288 |
// Give the init function the jQuery prototype for later instantiation |
289 |
jQuery.fn.init.prototype = jQuery.fn; |
290 |
|
291 |
jQuery.extend = jQuery.fn.extend = function() { |
292 |
var options, name, src, copy, copyIsArray, clone, |
293 |
target = arguments[0] || {}, |
294 |
i = 1, |
295 |
length = arguments.length, |
296 |
deep = false; |
297 |
|
298 |
// Handle a deep copy situation |
299 |
if ( typeof target === "boolean" ) { |
300 |
deep = target; |
301 |
target = arguments[1] || {}; |
302 |
// skip the boolean and the target |
303 |
i = 2; |
304 |
} |
305 |
|
306 |
// Handle case when target is a string or something (possible in deep copy) |
307 |
if ( typeof target !== "object" && !jQuery.isFunction(target) ) { |
308 |
target = {}; |
309 |
} |
310 |
|
311 |
// extend jQuery itself if only one argument is passed |
312 |
if ( length === i ) { |
313 |
target = this; |
314 |
--i; |
315 |
} |
316 |
|
317 |
for ( ; i < length; i++ ) { |
318 |
// Only deal with non-null/undefined values |
319 |
if ( (options = arguments[ i ]) != null ) { |
320 |
// Extend the base object |
321 |
for ( name in options ) { |
322 |
src = target[ name ]; |
323 |
copy = options[ name ]; |
324 |
|
325 |
// Prevent never-ending loop |
326 |
if ( target === copy ) { |
327 |
continue; |
328 |
} |
329 |
|
330 |
// Recurse if we're merging plain objects or arrays |
331 |
if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { |
332 |
if ( copyIsArray ) { |
333 |
copyIsArray = false; |
334 |
clone = src && jQuery.isArray(src) ? src : []; |
335 |
|
336 |
} else { |
337 |
clone = src && jQuery.isPlainObject(src) ? src : {}; |
338 |
} |
339 |
|
340 |
// Never move original objects, clone them |
341 |
target[ name ] = jQuery.extend( deep, clone, copy ); |
342 |
|
343 |
// Don't bring in undefined values |
344 |
} else if ( copy !== undefined ) { |
345 |
target[ name ] = copy; |
346 |
} |
347 |
} |
348 |
} |
349 |
} |
350 |
|
351 |
// Return the modified object |
352 |
return target; |
353 |
}; |
354 |
|
355 |
jQuery.extend({ |
356 |
noConflict: function( deep ) { |
357 |
if ( window.$ === jQuery ) { |
358 |
window.$ = _$; |
359 |
} |
360 |
|
361 |
if ( deep && window.jQuery === jQuery ) { |
362 |
window.jQuery = _jQuery; |
363 |
} |
364 |
|
365 |
return jQuery; |
366 |
}, |
367 |
|
368 |
// Is the DOM ready to be used? Set to true once it occurs. |
369 |
isReady: false, |
370 |
|
371 |
// A counter to track how many items to wait for before |
372 |
// the ready event fires. See #6781 |
373 |
readyWait: 1, |
374 |
|
375 |
// Hold (or release) the ready event |
376 |
holdReady: function( hold ) { |
377 |
if ( hold ) { |
378 |
jQuery.readyWait++; |
379 |
} else { |
380 |
jQuery.ready( true ); |
381 |
} |
382 |
}, |
383 |
|
384 |
// Handle when the DOM is ready |
385 |
ready: function( wait ) { |
386 |
|
387 |
// Abort if there are pending holds or we're already ready |
388 |
if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { |
389 |
return; |
390 |
} |
391 |
|
392 |
// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). |
393 |
if ( !document.body ) { |
394 |
return setTimeout( jQuery.ready, 1 ); |
395 |
} |
396 |
|
397 |
// Remember that the DOM is ready |
398 |
jQuery.isReady = true; |
399 |
|
400 |
// If a normal DOM Ready event fired, decrement, and wait if need be |
401 |
if ( wait !== true && --jQuery.readyWait > 0 ) { |
402 |
return; |
403 |
} |
404 |
|
405 |
// If there are functions bound, to execute |
406 |
readyList.resolveWith( document, [ jQuery ] ); |
407 |
|
408 |
// Trigger any bound ready events |
409 |
if ( jQuery.fn.trigger ) { |
410 |
jQuery( document ).trigger("ready").off("ready"); |
411 |
} |
412 |
}, |
413 |
|
414 |
// See test/unit/core.js for details concerning isFunction. |
415 |
// Since version 1.3, DOM methods and functions like alert |
416 |
// aren't supported. They return false on IE (#2968). |
417 |
isFunction: function( obj ) { |
418 |
return jQuery.type(obj) === "function"; |
419 |
}, |
420 |
|
421 |
isArray: Array.isArray || function( obj ) { |
422 |
return jQuery.type(obj) === "array"; |
423 |
}, |
424 |
|
425 |
isWindow: function( obj ) { |
426 |
return obj != null && obj == obj.window; |
427 |
}, |
428 |
|
429 |
isNumeric: function( obj ) { |
430 |
return !isNaN( parseFloat(obj) ) && isFinite( obj ); |
431 |
}, |
432 |
|
433 |
type: function( obj ) { |
434 |
return obj == null ? |
435 |
String( obj ) : |
436 |
class2type[ core_toString.call(obj) ] || "object"; |
437 |
}, |
438 |
|
439 |
isPlainObject: function( obj ) { |
440 |
// Must be an Object. |
441 |
// Because of IE, we also have to check the presence of the constructor property. |
442 |
// Make sure that DOM nodes and window objects don't pass through, as well |
443 |
if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { |
444 |
return false; |
445 |
} |
446 |
|
447 |
try { |
448 |
// Not own constructor property must be Object |
449 |
if ( obj.constructor && |
450 |
!core_hasOwn.call(obj, "constructor") && |
451 |
!core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { |
452 |
return false; |
453 |
} |
454 |
} catch ( e ) { |
455 |
// IE8,9 Will throw exceptions on certain host objects #9897 |
456 |
return false; |
457 |
} |
458 |
|
459 |
// Own properties are enumerated firstly, so to speed up, |
460 |
// if last one is own, then all properties are own. |
461 |
|
462 |
var key; |
463 |
for ( key in obj ) {} |
464 |
|
465 |
return key === undefined || core_hasOwn.call( obj, key ); |
466 |
}, |
467 |
|
468 |
isEmptyObject: function( obj ) { |
469 |
var name; |
470 |
for ( name in obj ) { |
471 |
return false; |
472 |
} |
473 |
return true; |
474 |
}, |
475 |
|
476 |
error: function( msg ) { |
477 |
throw new Error( msg ); |
478 |
}, |
479 |
|
480 |
// data: string of html |
481 |
// context (optional): If specified, the fragment will be created in this context, defaults to document |
482 |
// scripts (optional): If true, will include scripts passed in the html string |
483 |
parseHTML: function( data, context, scripts ) { |
484 |
var parsed; |
485 |
if ( !data || typeof data !== "string" ) { |
486 |
return null; |
487 |
} |
488 |
if ( typeof context === "boolean" ) { |
489 |
scripts = context; |
490 |
context = 0; |
491 |
} |
492 |
context = context || document; |
493 |
|
494 |
// Single tag |
495 |
if ( (parsed = rsingleTag.exec( data )) ) { |
496 |
return [ context.createElement( parsed[1] ) ]; |
497 |
} |
498 |
|
499 |
parsed = jQuery.buildFragment( [ data ], context, scripts ? null : [] ); |
500 |
return jQuery.merge( [], |
501 |
(parsed.cacheable ? jQuery.clone( parsed.fragment ) : parsed.fragment).childNodes ); |
502 |
}, |
503 |
|
504 |
parseJSON: function( data ) { |
505 |
if ( !data || typeof data !== "string") { |
506 |
return null; |
507 |
} |
508 |
|
509 |
// Make sure leading/trailing whitespace is removed (IE can't handle it) |
510 |
data = jQuery.trim( data ); |
511 |
|
512 |
// Attempt to parse using the native JSON parser first |
513 |
if ( window.JSON && window.JSON.parse ) { |
514 |
return window.JSON.parse( data ); |
515 |
} |
516 |
|
517 |
// Make sure the incoming data is actual JSON |
518 |
// Logic borrowed from http://json.org/json2.js |
519 |
if ( rvalidchars.test( data.replace( rvalidescape, "@" ) |
520 |
.replace( rvalidtokens, "]" ) |
521 |
.replace( rvalidbraces, "")) ) { |
522 |
|
523 |
return ( new Function( "return " + data ) )(); |
524 |
|
525 |
} |
526 |
jQuery.error( "Invalid JSON: " + data ); |
527 |
}, |
528 |
|
529 |
// Cross-browser xml parsing |
530 |
parseXML: function( data ) { |
531 |
var xml, tmp; |
532 |
if ( !data || typeof data !== "string" ) { |
533 |
return null; |
534 |
} |
535 |
try { |
536 |
if ( window.DOMParser ) { // Standard |
537 |
tmp = new DOMParser(); |
538 |
xml = tmp.parseFromString( data , "text/xml" ); |
539 |
} else { // IE |
540 |
xml = new ActiveXObject( "Microsoft.XMLDOM" ); |
541 |
xml.async = "false"; |
542 |
xml.loadXML( data ); |
543 |
} |
544 |
} catch( e ) { |
545 |
xml = undefined; |
546 |
} |
547 |
if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) { |
548 |
jQuery.error( "Invalid XML: " + data ); |
549 |
} |
550 |
return xml; |
551 |
}, |
552 |
|
553 |
noop: function() {}, |
554 |
|
555 |
// Evaluates a script in a global context |
556 |
// Workarounds based on findings by Jim Driscoll |
557 |
// http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context |
558 |
globalEval: function( data ) { |
559 |
if ( data && core_rnotwhite.test( data ) ) { |
560 |
// We use execScript on Internet Explorer |
561 |
// We use an anonymous function so that context is window |
562 |
// rather than jQuery in Firefox |
563 |
( window.execScript || function( data ) { |
564 |
window[ "eval" ].call( window, data ); |
565 |
} )( data ); |
566 |
} |
567 |
}, |
568 |
|
569 |
// Convert dashed to camelCase; used by the css and data modules |
570 |
// Microsoft forgot to hump their vendor prefix (#9572) |
571 |
camelCase: function( string ) { |
572 |
return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); |
573 |
}, |
574 |
|
575 |
nodeName: function( elem, name ) { |
576 |
return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase(); |
577 |
}, |
578 |
|
579 |
// args is for internal usage only |
580 |
each: function( obj, callback, args ) { |
581 |
var name, |
582 |
i = 0, |
583 |
length = obj.length, |
584 |
isObj = length === undefined || jQuery.isFunction( obj ); |
585 |
|
586 |
if ( args ) { |
587 |
if ( isObj ) { |
588 |
for ( name in obj ) { |
589 |
if ( callback.apply( obj[ name ], args ) === false ) { |
590 |
break; |
591 |
} |
592 |
} |
593 |
} else { |
594 |
for ( ; i < length; ) { |
595 |
if ( callback.apply( obj[ i++ ], args ) === false ) { |
596 |
break; |
597 |
} |
598 |
} |
599 |
} |
600 |
|
601 |
// A special, fast, case for the most common use of each |
602 |
} else { |
603 |
if ( isObj ) { |
604 |
for ( name in obj ) { |
605 |
if ( callback.call( obj[ name ], name, obj[ name ] ) === false ) { |
606 |
break; |
607 |
} |
608 |
} |
609 |
} else { |
610 |
for ( ; i < length; ) { |
611 |
if ( callback.call( obj[ i ], i, obj[ i++ ] ) === false ) { |
612 |
break; |
613 |
} |
614 |
} |
615 |
} |
616 |
} |
617 |
|
618 |
return obj; |
619 |
}, |
620 |
|
621 |
// Use native String.trim function wherever possible |
622 |
trim: core_trim && !core_trim.call("\uFEFF\xA0") ? |
623 |
function( text ) { |
624 |
return text == null ? |
625 |
"" : |
626 |
core_trim.call( text ); |
627 |
} : |
628 |
|
629 |
// Otherwise use our own trimming functionality |
630 |
function( text ) { |
631 |
return text == null ? |
632 |
"" : |
633 |
text.toString().replace( rtrim, "" ); |
634 |
}, |
635 |
|
636 |
// results is for internal usage only |
637 |
makeArray: function( arr, results ) { |
638 |
var type, |
639 |
ret = results || []; |
640 |
|
641 |
if ( arr != null ) { |
642 |
// The window, strings (and functions) also have 'length' |
643 |
// Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930 |
644 |
type = jQuery.type( arr ); |
645 |
|
646 |
if ( arr.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( arr ) ) { |
647 |
core_push.call( ret, arr ); |
648 |
} else { |
649 |
jQuery.merge( ret, arr ); |
650 |
} |
651 |
} |
652 |
|
653 |
return ret; |
654 |
}, |
655 |
|
656 |
inArray: function( elem, arr, i ) { |
657 |
var len; |
658 |
|
659 |
if ( arr ) { |
660 |
if ( core_indexOf ) { |
661 |
return core_indexOf.call( arr, elem, i ); |
662 |
} |
663 |
|
664 |
len = arr.length; |
665 |
i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0; |
666 |
|
667 |
for ( ; i < len; i++ ) { |
668 |
// Skip accessing in sparse arrays |
669 |
if ( i in arr && arr[ i ] === elem ) { |
670 |
return i; |
671 |
} |
672 |
} |
673 |
} |
674 |
|
675 |
return -1; |
676 |
}, |
677 |
|
678 |
merge: function( first, second ) { |
679 |
var l = second.length, |
680 |
i = first.length, |
681 |
j = 0; |
682 |
|
683 |
if ( typeof l === "number" ) { |
684 |
for ( ; j < l; j++ ) { |
685 |
first[ i++ ] = second[ j ]; |
686 |
} |
687 |
|
688 |
} else { |
689 |
while ( second[j] !== undefined ) { |
690 |
first[ i++ ] = second[ j++ ]; |
691 |
} |
692 |
} |
693 |
|
694 |
first.length = i; |
695 |
|
696 |
return first; |
697 |
}, |
698 |
|
699 |
grep: function( elems, callback, inv ) { |
700 |
var retVal, |
701 |
ret = [], |
702 |
i = 0, |
703 |
length = elems.length; |
704 |
inv = !!inv; |
705 |
|
706 |
// Go through the array, only saving the items |
707 |
// that pass the validator function |
708 |
for ( ; i < length; i++ ) { |
709 |
retVal = !!callback( elems[ i ], i ); |
710 |
if ( inv !== retVal ) { |
711 |
ret.push( elems[ i ] ); |
712 |
} |
713 |
} |
714 |
|
715 |
return ret; |
716 |
}, |
717 |
|
718 |
// arg is for internal usage only |
719 |
map: function( elems, callback, arg ) { |
720 |
var value, key, |
721 |
ret = [], |
722 |
i = 0, |
723 |
length = elems.length, |
724 |
// jquery objects are treated as arrays |
725 |
isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ; |
726 |
|
727 |
// Go through the array, translating each of the items to their |
728 |
if ( isArray ) { |
729 |
for ( ; i < length; i++ ) { |
730 |
value = callback( elems[ i ], i, arg ); |
731 |
|
732 |
if ( value != null ) { |
733 |
ret[ ret.length ] = value; |
734 |
} |
735 |
} |
736 |
|
737 |
// Go through every key on the object, |
738 |
} else { |
739 |
for ( key in elems ) { |
740 |
value = callback( elems[ key ], key, arg ); |
741 |
|
742 |
if ( value != null ) { |
743 |
ret[ ret.length ] = value; |
744 |
} |
745 |
} |
746 |
} |
747 |
|
748 |
// Flatten any nested arrays |
749 |
return ret.concat.apply( [], ret ); |
750 |
}, |
751 |
|
752 |
// A global GUID counter for objects |
753 |
guid: 1, |
754 |
|
755 |
// Bind a function to a context, optionally partially applying any |
756 |
// arguments. |
757 |
proxy: function( fn, context ) { |
758 |
var tmp, args, proxy; |
759 |
|
760 |
if ( typeof context === "string" ) { |
761 |
tmp = fn[ context ]; |
762 |
context = fn; |
763 |
fn = tmp; |
764 |
} |
765 |
|
766 |
// Quick check to determine if target is callable, in the spec |
767 |
// this throws a TypeError, but we will just return undefined. |
768 |
if ( !jQuery.isFunction( fn ) ) { |
769 |
return undefined; |
770 |
} |
771 |
|
772 |
// Simulated bind |
773 |
args = core_slice.call( arguments, 2 ); |
774 |
proxy = function() { |
775 |
return fn.apply( context, args.concat( core_slice.call( arguments ) ) ); |
776 |
}; |
777 |
|
778 |
// Set the guid of unique handler to the same of original handler, so it can be removed |
779 |
proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++; |
780 |
|
781 |
return proxy; |
782 |
}, |
783 |
|
784 |
// Multifunctional method to get and set values of a collection |
785 |
// The value/s can optionally be executed if it's a function |
786 |
access: function( elems, fn, key, value, chainable, emptyGet, pass ) { |
787 |
var exec, |
788 |
bulk = key == null, |
789 |
i = 0, |
790 |
length = elems.length; |
791 |
|
792 |
// Sets many values |
793 |
if ( key && typeof key === "object" ) { |
794 |
for ( i in key ) { |
795 |
jQuery.access( elems, fn, i, key[i], 1, emptyGet, value ); |
796 |
} |
797 |
chainable = 1; |
798 |
|
799 |
// Sets one value |
800 |
} else if ( value !== undefined ) { |
801 |
// Optionally, function values get executed if exec is true |
802 |
exec = pass === undefined && jQuery.isFunction( value ); |
803 |
|
804 |
if ( bulk ) { |
805 |
// Bulk operations only iterate when executing function values |
806 |
if ( exec ) { |
807 |
exec = fn; |
808 |
fn = function( elem, key, value ) { |
809 |
return exec.call( jQuery( elem ), value ); |
810 |
}; |
811 |
|
812 |
// Otherwise they run against the entire set |
813 |
} else { |
814 |
fn.call( elems, value ); |
815 |
fn = null; |
816 |
} |
817 |
} |
818 |
|
819 |
if ( fn ) { |
820 |
for (; i < length; i++ ) { |
821 |
fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass ); |
822 |
} |
823 |
} |
824 |
|
825 |
chainable = 1; |
826 |
} |
827 |
|
828 |
return chainable ? |
829 |
elems : |
830 |
|
831 |
// Gets |
832 |
bulk ? |
833 |
fn.call( elems ) : |
834 |
length ? fn( elems[0], key ) : emptyGet; |
835 |
}, |
836 |
|
837 |
now: function() { |
838 |
return ( new Date() ).getTime(); |
839 |
} |
840 |
}); |
841 |
|
842 |
jQuery.ready.promise = function( obj ) { |
843 |
if ( !readyList ) { |
844 |
|
845 |
readyList = jQuery.Deferred(); |
846 |
|
847 |
// Catch cases where $(document).ready() is called after the browser event has already occurred. |
848 |
// we once tried to use readyState "interactive" here, but it caused issues like the one |
849 |
// discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 |
850 |
if ( document.readyState === "complete" ) { |
851 |
// Handle it asynchronously to allow scripts the opportunity to delay ready |
852 |
setTimeout( jQuery.ready, 1 ); |
853 |
|
854 |
// Standards-based browsers support DOMContentLoaded |
855 |
} else if ( document.addEventListener ) { |
856 |
// Use the handy event callback |
857 |
document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); |
858 |
|
859 |
// A fallback to window.onload, that will always work |
860 |
window.addEventListener( "load", jQuery.ready, false ); |
861 |
|
862 |
// If IE event model is used |
863 |
} else { |
864 |
// Ensure firing before onload, maybe late but safe also for iframes |
865 |
document.attachEvent( "onreadystatechange", DOMContentLoaded ); |
866 |
|
867 |
// A fallback to window.onload, that will always work |
868 |
window.attachEvent( "onload", jQuery.ready ); |
869 |
|
870 |
// If IE and not a frame |
871 |
// continually check to see if the document is ready |
872 |
var top = false; |
873 |
|
874 |
try { |
875 |
top = window.frameElement == null && document.documentElement; |
876 |
} catch(e) {} |
877 |
|
878 |
if ( top && top.doScroll ) { |
879 |
(function doScrollCheck() { |
880 |
if ( !jQuery.isReady ) { |
881 |
|
882 |
try { |
883 |
// Use the trick by Diego Perini |
884 |
// http://javascript.nwbox.com/IEContentLoaded/ |
885 |
top.doScroll("left"); |
886 |
} catch(e) { |
887 |
return setTimeout( doScrollCheck, 50 ); |
888 |
} |
889 |
|
890 |
// and execute any waiting functions |
891 |
jQuery.ready(); |
892 |
} |
893 |
})(); |
894 |
} |
895 |
} |
896 |
} |
897 |
return readyList.promise( obj ); |
898 |
}; |
899 |
|
900 |
// Populate the class2type map |
901 |
jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) { |
902 |
class2type[ "[object " + name + "]" ] = name.toLowerCase(); |
903 |
}); |
904 |
|
905 |
// All jQuery objects should point back to these |
906 |
rootjQuery = jQuery(document); |
907 |
// String to Object options format cache |
908 |
var optionsCache = {}; |
909 |
|
910 |
// Convert String-formatted options into Object-formatted ones and store in cache |
911 |
function createOptions( options ) { |
912 |
var object = optionsCache[ options ] = {}; |
913 |
jQuery.each( options.split( core_rspace ), function( _, flag ) { |
914 |
object[ flag ] = true; |
915 |
}); |
916 |
return object; |
917 |
} |
918 |
|
919 |
/* |
920 |
* Create a callback list using the following parameters: |
921 |
* |
922 |
* options: an optional list of space-separated options that will change how |
923 |
* the callback list behaves or a more traditional option object |
924 |
* |
925 |
* By default a callback list will act like an event callback list and can be |
926 |
* "fired" multiple times. |
927 |
* |
928 |
* Possible options: |
929 |
* |
930 |
* once: will ensure the callback list can only be fired once (like a Deferred) |
931 |
* |
932 |
* memory: will keep track of previous values and will call any callback added |
933 |
* after the list has been fired right away with the latest "memorized" |
934 |
* values (like a Deferred) |
935 |
* |
936 |
* unique: will ensure a callback can only be added once (no duplicate in the list) |
937 |
* |
938 |
* stopOnFalse: interrupt callings when a callback returns false |
939 |
* |
940 |
*/ |
941 |
jQuery.Callbacks = function( options ) { |
942 |
|
943 |
// Convert options from String-formatted to Object-formatted if needed |
944 |
// (we check in cache first) |
945 |
options = typeof options === "string" ? |
946 |
( optionsCache[ options ] || createOptions( options ) ) : |
947 |
jQuery.extend( {}, options ); |
948 |
|
949 |
var // Last fire value (for non-forgettable lists) |
950 |
memory, |
951 |
// Flag to know if list was already fired |
952 |
fired, |
953 |
// Flag to know if list is currently firing |
954 |
firing, |
955 |
// First callback to fire (used internally by add and fireWith) |
956 |
firingStart, |
957 |
// End of the loop when firing |
958 |
firingLength, |
959 |
// Index of currently firing callback (modified by remove if needed) |
960 |
firingIndex, |
961 |
// Actual callback list |
962 |
list = [], |
963 |
// Stack of fire calls for repeatable lists |
964 |
stack = !options.once && [], |
965 |
// Fire callbacks |
966 |
fire = function( data ) { |
967 |
memory = options.memory && data; |
968 |
fired = true; |
969 |
firingIndex = firingStart || 0; |
970 |
firingStart = 0; |
971 |
firingLength = list.length; |
972 |
firing = true; |
973 |
for ( ; list && firingIndex < firingLength; firingIndex++ ) { |
974 |
if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) { |
975 |
memory = false; // To prevent further calls using add |
976 |
break; |
977 |
} |
978 |
} |
979 |
firing = false; |
980 |
if ( list ) { |
981 |
if ( stack ) { |
982 |
if ( stack.length ) { |
983 |
fire( stack.shift() ); |
984 |
} |
985 |
} else if ( memory ) { |
986 |
list = []; |
987 |
} else { |
988 |
self.disable(); |
989 |
} |
990 |
} |
991 |
}, |
992 |
// Actual Callbacks object |
993 |
self = { |
994 |
// Add a callback or a collection of callbacks to the list |
995 |
add: function() { |
996 |
if ( list ) { |
997 |
// First, we save the current length |
998 |
var start = list.length; |
999 |
(function add( args ) { |
1000 |
jQuery.each( args, function( _, arg ) { |
1001 |
var type = jQuery.type( arg ); |
1002 |
if ( type === "function" && ( !options.unique || !self.has( arg ) ) ) { |
1003 |
list.push( arg ); |
1004 |
} else if ( arg && arg.length && type !== "string" ) { |
1005 |
// Inspect recursively |
1006 |
add( arg ); |
1007 |
} |
1008 |
}); |
1009 |
})( arguments ); |
1010 |
// Do we need to add the callbacks to the |
1011 |
// current firing batch? |
1012 |
if ( firing ) { |
1013 |
firingLength = list.length; |
1014 |
// With memory, if we're not firing then |
1015 |
// we should call right away |
1016 |
} else if ( memory ) { |
1017 |
firingStart = start; |
1018 |
fire( memory ); |
1019 |
} |
1020 |
} |
1021 |
return this; |
1022 |
}, |
1023 |
// Remove a callback from the list |
1024 |
remove: function() { |
1025 |
if ( list ) { |
1026 |
jQuery.each( arguments, function( _, arg ) { |
1027 |
var index; |
1028 |
while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { |
1029 |
list.splice( index, 1 ); |
1030 |
// Handle firing indexes |
1031 |
if ( firing ) { |
1032 |
if ( index <= firingLength ) { |
1033 |
firingLength--; |
1034 |
} |
1035 |
if ( index <= firingIndex ) { |
1036 |
firingIndex--; |
1037 |
} |
1038 |
} |
1039 |
} |
1040 |
}); |
1041 |
} |
1042 |
return this; |
1043 |
}, |
1044 |
// Control if a given callback is in the list |
1045 |
has: function( fn ) { |
1046 |
return jQuery.inArray( fn, list ) > -1; |
1047 |
}, |
1048 |
// Remove all callbacks from the list |
1049 |
empty: function() { |
1050 |
list = []; |
1051 |
return this; |
1052 |
}, |
1053 |
// Have the list do nothing anymore |
1054 |
disable: function() { |
1055 |
list = stack = memory = undefined; |
1056 |
return this; |
1057 |
}, |
1058 |
// Is it disabled? |
1059 |
disabled: function() { |
1060 |
return !list; |
1061 |
}, |
1062 |
// Lock the list in its current state |
1063 |
lock: function() { |
1064 |
stack = undefined; |
1065 |
if ( !memory ) { |
1066 |
self.disable(); |
1067 |
} |
1068 |
return this; |
1069 |
}, |
1070 |
// Is it locked? |
1071 |
locked: function() { |
1072 |
return !stack; |
1073 |
}, |
1074 |
// Call all callbacks with the given context and arguments |
1075 |
fireWith: function( context, args ) { |
1076 |
args = args || []; |
1077 |
args = [ context, args.slice ? args.slice() : args ]; |
1078 |
if ( list && ( !fired || stack ) ) { |
1079 |
if ( firing ) { |
1080 |
stack.push( args ); |
1081 |
} else { |
1082 |
fire( args ); |
1083 |
} |
1084 |
} |
1085 |
return this; |
1086 |
}, |
1087 |
// Call all the callbacks with the given arguments |
1088 |
fire: function() { |
1089 |
self.fireWith( this, arguments ); |
1090 |
return this; |
1091 |
}, |
1092 |
// To know if the callbacks have already been called at least once |
1093 |
fired: function() { |
1094 |
return !!fired; |
1095 |
} |
1096 |
}; |
1097 |
|
1098 |
return self; |
1099 |
}; |
1100 |
jQuery.extend({ |
1101 |
|
1102 |
Deferred: function( func ) { |
1103 |
var tuples = [ |
1104 |
// action, add listener, listener list, final state |
1105 |
[ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ], |
1106 |
[ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ], |
1107 |
[ "notify", "progress", jQuery.Callbacks("memory") ] |
1108 |
], |
1109 |
state = "pending", |
1110 |
promise = { |
1111 |
state: function() { |
1112 |
return state; |
1113 |
}, |
1114 |
always: function() { |
1115 |
deferred.done( arguments ).fail( arguments ); |
1116 |
return this; |
1117 |
}, |
1118 |
then: function( /* fnDone, fnFail, fnProgress */ ) { |
1119 |
var fns = arguments; |
1120 |
return jQuery.Deferred(function( newDefer ) { |
1121 |
jQuery.each( tuples, function( i, tuple ) { |
1122 |
var action = tuple[ 0 ], |
1123 |
fn = fns[ i ]; |
1124 |
// deferred[ done | fail | progress ] for forwarding actions to newDefer |
1125 |
deferred[ tuple[1] ]( jQuery.isFunction( fn ) ? |
1126 |
function() { |
1127 |
var returned = fn.apply( this, arguments ); |
1128 |
if ( returned && jQuery.isFunction( returned.promise ) ) { |
1129 |
returned.promise() |
1130 |
.done( newDefer.resolve ) |
1131 |
.fail( newDefer.reject ) |
1132 |
.progress( newDefer.notify ); |
1133 |
} else { |
1134 |
newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] ); |
1135 |
} |
1136 |
} : |
1137 |
newDefer[ action ] |
1138 |
); |
1139 |
}); |
1140 |
fns = null; |
1141 |
}).promise(); |
1142 |
}, |
1143 |
// Get a promise for this deferred |
1144 |
// If obj is provided, the promise aspect is added to the object |
1145 |
promise: function( obj ) { |
1146 |
return typeof obj === "object" ? jQuery.extend( obj, promise ) : promise; |
1147 |
} |
1148 |
}, |
1149 |
deferred = {}; |
1150 |
|
1151 |
// Keep pipe for back-compat |
1152 |
promise.pipe = promise.then; |
1153 |
|
1154 |
// Add list-specific methods |
1155 |
jQuery.each( tuples, function( i, tuple ) { |
1156 |
var list = tuple[ 2 ], |
1157 |
stateString = tuple[ 3 ]; |
1158 |
|
1159 |
// promise[ done | fail | progress ] = list.add |
1160 |
promise[ tuple[1] ] = list.add; |
1161 |
|
1162 |
// Handle state |
1163 |
if ( stateString ) { |
1164 |
list.add(function() { |
1165 |
// state = [ resolved | rejected ] |
1166 |
state = stateString; |
1167 |
|
1168 |
// [ reject_list | resolve_list ].disable; progress_list.lock |
1169 |
}, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock ); |
1170 |
} |
1171 |
|
1172 |
// deferred[ resolve | reject | notify ] = list.fire |
1173 |
deferred[ tuple[0] ] = list.fire; |
1174 |
deferred[ tuple[0] + "With" ] = list.fireWith; |
1175 |
}); |
1176 |
|
1177 |
// Make the deferred a promise |
1178 |
promise.promise( deferred ); |
1179 |
|
1180 |
// Call given func if any |
1181 |
if ( func ) { |
1182 |
func.call( deferred, deferred ); |
1183 |
} |
1184 |
|
1185 |
// All done! |
1186 |
return deferred; |
1187 |
}, |
1188 |
|
1189 |
// Deferred helper |
1190 |
when: function( subordinate /* , ..., subordinateN */ ) { |
1191 |
var i = 0, |
1192 |
resolveValues = core_slice.call( arguments ), |
1193 |
length = resolveValues.length, |
1194 |
|
1195 |
// the count of uncompleted subordinates |
1196 |
remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0, |
1197 |
|
1198 |
// the master Deferred. If resolveValues consist of only a single Deferred, just use that. |
1199 |
deferred = remaining === 1 ? subordinate : jQuery.Deferred(), |
1200 |
|
1201 |
// Update function for both resolve and progress values |
1202 |
updateFunc = function( i, contexts, values ) { |
1203 |
return function( value ) { |
1204 |
contexts[ i ] = this; |
1205 |
values[ i ] = arguments.length > 1 ? core_slice.call( arguments ) : value; |
1206 |
if( values === progressValues ) { |
1207 |
deferred.notifyWith( contexts, values ); |
1208 |
} else if ( !( --remaining ) ) { |
1209 |
deferred.resolveWith( contexts, values ); |
1210 |
} |
1211 |
}; |
1212 |
}, |
1213 |
|
1214 |
progressValues, progressContexts, resolveContexts; |
1215 |
|
1216 |
// add listeners to Deferred subordinates; treat others as resolved |
1217 |
if ( length > 1 ) { |
1218 |
progressValues = new Array( length ); |
1219 |
progressContexts = new Array( length ); |
1220 |
resolveContexts = new Array( length ); |
1221 |
for ( ; i < length; i++ ) { |
1222 |
if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) { |
1223 |
resolveValues[ i ].promise() |
1224 |
.done( updateFunc( i, resolveContexts, resolveValues ) ) |
1225 |
.fail( deferred.reject ) |
1226 |
.progress( updateFunc( i, progressContexts, progressValues ) ); |
1227 |
} else { |
1228 |
--remaining; |
1229 |
} |
1230 |
} |
1231 |
} |
1232 |
|
1233 |
// if we're not waiting on anything, resolve the master |
1234 |
if ( !remaining ) { |
1235 |
deferred.resolveWith( resolveContexts, resolveValues ); |
1236 |
} |
1237 |
|
1238 |
return deferred.promise(); |
1239 |
} |
1240 |
}); |
1241 |
jQuery.support = (function() { |
1242 |
|
1243 |
var support, |
1244 |
all, |
1245 |
a, |
1246 |
select, |
1247 |
opt, |
1248 |
input, |
1249 |
fragment, |
1250 |
eventName, |
1251 |
i, |
1252 |
isSupported, |
1253 |
clickFn, |
1254 |
div = document.createElement("div"); |
1255 |
|
1256 |
// Preliminary tests |
1257 |
div.setAttribute( "className", "t" ); |
1258 |
div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>"; |
1259 |
|
1260 |
all = div.getElementsByTagName("*"); |
1261 |
a = div.getElementsByTagName("a")[ 0 ]; |
1262 |
a.style.cssText = "top:1px;float:left;opacity:.5"; |
1263 |
|
1264 |
// Can't get basic test support |
1265 |
if ( !all || !all.length || !a ) { |
1266 |
return {}; |
1267 |
} |
1268 |
|
1269 |
// First batch of supports tests |
1270 |
select = document.createElement("select"); |
1271 |
opt = select.appendChild( document.createElement("option") ); |
1272 |
input = div.getElementsByTagName("input")[ 0 ]; |
1273 |
|
1274 |
support = { |
1275 |
// IE strips leading whitespace when .innerHTML is used |
1276 |
leadingWhitespace: ( div.firstChild.nodeType === 3 ), |
1277 |
|
1278 |
// Make sure that tbody elements aren't automatically inserted |
1279 |
// IE will insert them into empty tables |
1280 |
tbody: !div.getElementsByTagName("tbody").length, |
1281 |
|
1282 |
// Make sure that link elements get serialized correctly by innerHTML |
1283 |
// This requires a wrapper element in IE |
1284 |
htmlSerialize: !!div.getElementsByTagName("link").length, |
1285 |
|
1286 |
// Get the style information from getAttribute |
1287 |
// (IE uses .cssText instead) |
1288 |
style: /top/.test( a.getAttribute("style") ), |
1289 |
|
1290 |
// Make sure that URLs aren't manipulated |
1291 |
// (IE normalizes it by default) |
1292 |
hrefNormalized: ( a.getAttribute("href") === "/a" ), |
1293 |
|
1294 |
// Make sure that element opacity exists |
1295 |
// (IE uses filter instead) |
1296 |
// Use a regex to work around a WebKit issue. See #5145 |
1297 |
opacity: /^0.5/.test( a.style.opacity ), |
1298 |
|
1299 |
// Verify style float existence |
1300 |
// (IE uses styleFloat instead of cssFloat) |
1301 |
cssFloat: !!a.style.cssFloat, |
1302 |
|
1303 |
// Make sure that if no value is specified for a checkbox |
1304 |
// that it defaults to "on". |
1305 |
// (WebKit defaults to "" instead) |
1306 |
checkOn: ( input.value === "on" ), |
1307 |
|
1308 |
// Make sure that a selected-by-default option has a working selected property. |
1309 |
// (WebKit defaults to false instead of true, IE too, if it's in an optgroup) |
1310 |
optSelected: opt.selected, |
1311 |
|
1312 |
// Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) |
1313 |
getSetAttribute: div.className !== "t", |
1314 |
|
1315 |
// Tests for enctype support on a form(#6743) |
1316 |
enctype: !!document.createElement("form").enctype, |
1317 |
|
1318 |
// Makes sure cloning an html5 element does not cause problems |
1319 |
// Where outerHTML is undefined, this still works |
1320 |
html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>", |
1321 |
|
1322 |
// jQuery.support.boxModel DEPRECATED in 1.8 since we don't support Quirks Mode |
1323 |
boxModel: ( document.compatMode === "CSS1Compat" ), |
1324 |
|
1325 |
// Will be defined later |
1326 |
submitBubbles: true, |
1327 |
changeBubbles: true, |
1328 |
focusinBubbles: false, |
1329 |
deleteExpando: true, |
1330 |
noCloneEvent: true, |
1331 |
inlineBlockNeedsLayout: false, |
1332 |
shrinkWrapBlocks: false, |
1333 |
reliableMarginRight: true, |
1334 |
boxSizingReliable: true, |
1335 |
pixelPosition: false |
1336 |
}; |
1337 |
|
1338 |
// Make sure checked status is properly cloned |
1339 |
input.checked = true; |
1340 |
support.noCloneChecked = input.cloneNode( true ).checked; |
1341 |
|
1342 |
// Make sure that the options inside disabled selects aren't marked as disabled |
1343 |
// (WebKit marks them as disabled) |
1344 |
select.disabled = true; |
1345 |
support.optDisabled = !opt.disabled; |
1346 |
|
1347 |
// Test to see if it's possible to delete an expando from an element |
1348 |
// Fails in Internet Explorer |
1349 |
try { |
1350 |
delete div.test; |
1351 |
} catch( e ) { |
1352 |
support.deleteExpando = false; |
1353 |
} |
1354 |
|
1355 |
if ( !div.addEventListener && div.attachEvent && div.fireEvent ) { |
1356 |
div.attachEvent( "onclick", clickFn = function() { |
1357 |
// Cloning a node shouldn't copy over any |
1358 |
// bound event handlers (IE does this) |
1359 |
support.noCloneEvent = false; |
1360 |
}); |
1361 |
div.cloneNode( true ).fireEvent("onclick"); |
1362 |
div.detachEvent( "onclick", clickFn ); |
1363 |
} |
1364 |
|
1365 |
// Check if a radio maintains its value |
1366 |
// after being appended to the DOM |
1367 |
input = document.createElement("input"); |
1368 |
input.value = "t"; |
1369 |
input.setAttribute( "type", "radio" ); |
1370 |
support.radioValue = input.value === "t"; |
1371 |
|
1372 |
input.setAttribute( "checked", "checked" ); |
1373 |
|
1374 |
// #11217 - WebKit loses check when the name is after the checked attribute |
1375 |
input.setAttribute( "name", "t" ); |
1376 |
|
1377 |
div.appendChild( input ); |
1378 |
fragment = document.createDocumentFragment(); |
1379 |
fragment.appendChild( div.lastChild ); |
1380 |
|
1381 |
// WebKit doesn't clone checked state correctly in fragments |
1382 |
support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; |
1383 |
|
1384 |
// Check if a disconnected checkbox will retain its checked |
1385 |
// value of true after appended to the DOM (IE6/7) |
1386 |
support.appendChecked = input.checked; |
1387 |
|
1388 |
fragment.removeChild( input ); |
1389 |
fragment.appendChild( div ); |
1390 |
|
1391 |
// Technique from Juriy Zaytsev |
1392 |
// http://perfectionkills.com/detecting-event-support-without-browser-sniffing/ |
1393 |
// We only care about the case where non-standard event systems |
1394 |
// are used, namely in IE. Short-circuiting here helps us to |
1395 |
// avoid an eval call (in setAttribute) which can cause CSP |
1396 |
// to go haywire. See: https://developer.mozilla.org/en/Security/CSP |
1397 |
if ( div.attachEvent ) { |
1398 |
for ( i in { |
1399 |
submit: true, |
1400 |
change: true, |
1401 |
focusin: true |
1402 |
}) { |
1403 |
eventName = "on" + i; |
1404 |
isSupported = ( eventName in div ); |
1405 |
if ( !isSupported ) { |
1406 |
div.setAttribute( eventName, "return;" ); |
1407 |
isSupported = ( typeof div[ eventName ] === "function" ); |
1408 |
} |
1409 |
support[ i + "Bubbles" ] = isSupported; |
1410 |
} |
1411 |
} |
1412 |
|
1413 |
// Run tests that need a body at doc ready |
1414 |
jQuery(function() { |
1415 |
var container, div, tds, marginDiv, |
1416 |
divReset = "padding:0;margin:0;border:0;display:block;overflow:hidden;", |
1417 |
body = document.getElementsByTagName("body")[0]; |
1418 |
|
1419 |
if ( !body ) { |
1420 |
// Return for frameset docs that don't have a body |
1421 |
return; |
1422 |
} |
1423 |
|
1424 |
container = document.createElement("div"); |
1425 |
container.style.cssText = "visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px"; |
1426 |
body.insertBefore( container, body.firstChild ); |
1427 |
|
1428 |
// Construct the test element |
1429 |
div = document.createElement("div"); |
1430 |
container.appendChild( div ); |
1431 |
|
1432 |
// Check if table cells still have offsetWidth/Height when they are set |
1433 |
// to display:none and there are still other visible table cells in a |
1434 |
// table row; if so, offsetWidth/Height are not reliable for use when |
1435 |
// determining if an element has been hidden directly using |
1436 |
// display:none (it is still safe to use offsets if a parent element is |
1437 |
// hidden; don safety goggles and see bug #4512 for more information). |
1438 |
// (only IE 8 fails this test) |
1439 |
div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>"; |
1440 |
tds = div.getElementsByTagName("td"); |
1441 |
tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none"; |
1442 |
isSupported = ( tds[ 0 ].offsetHeight === 0 ); |
1443 |
|
1444 |
tds[ 0 ].style.display = ""; |
1445 |
tds[ 1 ].style.display = "none"; |
1446 |
|
1447 |
// Check if empty table cells still have offsetWidth/Height |
1448 |
// (IE <= 8 fail this test) |
1449 |
support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 ); |
1450 |
|
1451 |
// Check box-sizing and margin behavior |
1452 |
div.innerHTML = ""; |
1453 |
div.style.cssText = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;"; |
1454 |
support.boxSizing = ( div.offsetWidth === 4 ); |
1455 |
support.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== 1 ); |
1456 |
|
1457 |
// NOTE: To any future maintainer, we've window.getComputedStyle |
1458 |
// because jsdom on node.js will break without it. |
1459 |
if ( window.getComputedStyle ) { |
1460 |
support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%"; |
1461 |
support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px"; |
1462 |
|
1463 |
// Check if div with explicit width and no margin-right incorrectly |
1464 |
// gets computed margin-right based on width of container. For more |
1465 |
// info see bug #3333 |
1466 |
// Fails in WebKit before Feb 2011 nightlies |
1467 |
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right |
1468 |
marginDiv = document.createElement("div"); |
1469 |
marginDiv.style.cssText = div.style.cssText = divReset; |
1470 |
marginDiv.style.marginRight = marginDiv.style.width = "0"; |
1471 |
div.style.width = "1px"; |
1472 |
div.appendChild( marginDiv ); |
1473 |
support.reliableMarginRight = |
1474 |
!parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight ); |
1475 |
} |
1476 |
|
1477 |
if ( typeof div.style.zoom !== "undefined" ) { |
1478 |
// Check if natively block-level elements act like inline-block |
1479 |
// elements when setting their display to 'inline' and giving |
1480 |
// them layout |
1481 |
// (IE < 8 does this) |
1482 |
div.innerHTML = ""; |
1483 |
div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1"; |
1484 |
support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 ); |
1485 |
|
1486 |
// Check if elements with layout shrink-wrap their children |
1487 |
// (IE 6 does this) |
1488 |
div.style.display = "block"; |
1489 |
div.style.overflow = "visible"; |
1490 |
div.innerHTML = "<div></div>"; |
1491 |
div.firstChild.style.width = "5px"; |
1492 |
support.shrinkWrapBlocks = ( div.offsetWidth !== 3 ); |
1493 |
|
1494 |
container.style.zoom = 1; |
1495 |
} |
1496 |
|
1497 |
// Null elements to avoid leaks in IE |
1498 |
body.removeChild( container ); |
1499 |
container = div = tds = marginDiv = null; |
1500 |
}); |
1501 |
|
1502 |
// Null elements to avoid leaks in IE |
1503 |
fragment.removeChild( div ); |
1504 |
all = a = select = opt = input = fragment = div = null; |
1505 |
|
1506 |
return support; |
1507 |
})(); |
1508 |
var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/, |
1509 |
rmultiDash = /([A-Z])/g; |
1510 |
|
1511 |
jQuery.extend({ |
1512 |
cache: {}, |
1513 |
|
1514 |
deletedIds: [], |
1515 |
|
1516 |
// Please use with caution |
1517 |
uuid: 0, |
1518 |
|
1519 |
// Unique for each copy of jQuery on the page |
1520 |
// Non-digits removed to match rinlinejQuery |
1521 |
expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ), |
1522 |
|
1523 |
// The following elements throw uncatchable exceptions if you |
1524 |
// attempt to add expando properties to them. |
1525 |
noData: { |
1526 |
"embed": true, |
1527 |
// Ban all objects except for Flash (which handle expandos) |
1528 |
"object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", |
1529 |
"applet": true |
1530 |
}, |
1531 |
|
1532 |
hasData: function( elem ) { |
1533 |
elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; |
1534 |
return !!elem && !isEmptyDataObject( elem ); |
1535 |
}, |
1536 |
|
1537 |
data: function( elem, name, data, pvt /* Internal Use Only */ ) { |
1538 |
if ( !jQuery.acceptData( elem ) ) { |
1539 |
return; |
1540 |
} |
1541 |
|
1542 |
var thisCache, ret, |
1543 |
internalKey = jQuery.expando, |
1544 |
getByName = typeof name === "string", |
1545 |
|
1546 |
// We have to handle DOM nodes and JS objects differently because IE6-7 |
1547 |
// can't GC object references properly across the DOM-JS boundary |
1548 |
isNode = elem.nodeType, |
1549 |
|
1550 |
// Only DOM nodes need the global jQuery cache; JS object data is |
1551 |
// attached directly to the object so GC can occur automatically |
1552 |
cache = isNode ? jQuery.cache : elem, |
1553 |
|
1554 |
// Only defining an ID for JS objects if its cache already exists allows |
1555 |
// the code to shortcut on the same path as a DOM node with no cache |
1556 |
id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey; |
1557 |
|
1558 |
// Avoid doing any more work than we need to when trying to get data on an |
1559 |
// object that has no data at all |
1560 |
if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && getByName && data === undefined ) { |
1561 |
return; |
1562 |
} |
1563 |
|
1564 |
if ( !id ) { |
1565 |
// Only DOM nodes need a new unique ID for each element since their data |
1566 |
// ends up in the global cache |
1567 |
if ( isNode ) { |
1568 |
elem[ internalKey ] = id = jQuery.deletedIds.pop() || ++jQuery.uuid; |
1569 |
} else { |
1570 |
id = internalKey; |
1571 |
} |
1572 |
} |
1573 |
|
1574 |
if ( !cache[ id ] ) { |
1575 |
cache[ id ] = {}; |
1576 |
|
1577 |
// Avoids exposing jQuery metadata on plain JS objects when the object |
1578 |
// is serialized using JSON.stringify |
1579 |
if ( !isNode ) { |
1580 |
cache[ id ].toJSON = jQuery.noop; |
1581 |
} |
1582 |
} |
1583 |
|
1584 |
// An object can be passed to jQuery.data instead of a key/value pair; this gets |
1585 |
// shallow copied over onto the existing cache |
1586 |
if ( typeof name === "object" || typeof name === "function" ) { |
1587 |
if ( pvt ) { |
1588 |
cache[ id ] = jQuery.extend( cache[ id ], name ); |
1589 |
} else { |
1590 |
cache[ id ].data = jQuery.extend( cache[ id ].data, name ); |
1591 |
} |
1592 |
} |
1593 |
|
1594 |
thisCache = cache[ id ]; |
1595 |
|
1596 |
// jQuery data() is stored in a separate object inside the object's internal data |
1597 |
// cache in order to avoid key collisions between internal data and user-defined |
1598 |
// data. |
1599 |
if ( !pvt ) { |
1600 |
if ( !thisCache.data ) { |
1601 |
thisCache.data = {}; |
1602 |
} |
1603 |
|
1604 |
thisCache = thisCache.data; |
1605 |
} |
1606 |
|
1607 |
if ( data !== undefined ) { |
1608 |
thisCache[ jQuery.camelCase( name ) ] = data; |
1609 |
} |
1610 |
|
1611 |
// Check for both converted-to-camel and non-converted data property names |
1612 |
// If a data property was specified |
1613 |
if ( getByName ) { |
1614 |
|
1615 |
// First Try to find as-is property data |
1616 |
ret = thisCache[ name ]; |
1617 |
|
1618 |
// Test for null|undefined property data |
1619 |
if ( ret == null ) { |
1620 |
|
1621 |
// Try to find the camelCased property |
1622 |
ret = thisCache[ jQuery.camelCase( name ) ]; |
1623 |
} |
1624 |
} else { |
1625 |
ret = thisCache; |
1626 |
} |
1627 |
|
1628 |
return ret; |
1629 |
}, |
1630 |
|
1631 |
removeData: function( elem, name, pvt /* Internal Use Only */ ) { |
1632 |
if ( !jQuery.acceptData( elem ) ) { |
1633 |
return; |
1634 |
} |
1635 |
|
1636 |
var thisCache, i, l, |
1637 |
|
1638 |
isNode = elem.nodeType, |
1639 |
|
1640 |
// See jQuery.data for more information |
1641 |
cache = isNode ? jQuery.cache : elem, |
1642 |
id = isNode ? elem[ jQuery.expando ] : jQuery.expando; |
1643 |
|
1644 |
// If there is already no cache entry for this object, there is no |
1645 |
// purpose in continuing |
1646 |
if ( !cache[ id ] ) { |
1647 |
return; |
1648 |
} |
1649 |
|
1650 |
if ( name ) { |
1651 |
|
1652 |
thisCache = pvt ? cache[ id ] : cache[ id ].data; |
1653 |
|
1654 |
if ( thisCache ) { |
1655 |
|
1656 |
// Support array or space separated string names for data keys |
1657 |
if ( !jQuery.isArray( name ) ) { |
1658 |
|
1659 |
// try the string as a key before any manipulation |
1660 |
if ( name in thisCache ) { |
1661 |
name = [ name ]; |
1662 |
} else { |
1663 |
|
1664 |
// split the camel cased version by spaces unless a key with the spaces exists |
1665 |
name = jQuery.camelCase( name ); |
1666 |
if ( name in thisCache ) { |
1667 |
name = [ name ]; |
1668 |
} else { |
1669 |
name = name.split(" "); |
1670 |
} |
1671 |
} |
1672 |
} |
1673 |
|
1674 |
for ( i = 0, l = name.length; i < l; i++ ) { |
1675 |
delete thisCache[ name[i] ]; |
1676 |
} |
1677 |
|
1678 |
// If there is no data left in the cache, we want to continue |
1679 |
// and let the cache object itself get destroyed |
1680 |
if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) { |
1681 |
return; |
1682 |
} |
1683 |
} |
1684 |
} |
1685 |
|
1686 |
// See jQuery.data for more information |
1687 |
if ( !pvt ) { |
1688 |
delete cache[ id ].data; |
1689 |
|
1690 |
// Don't destroy the parent cache unless the internal data object |
1691 |
// had been the only thing left in it |
1692 |
if ( !isEmptyDataObject( cache[ id ] ) ) { |
1693 |
return; |
1694 |
} |
1695 |
} |
1696 |
|
1697 |
// Destroy the cache |
1698 |
if ( isNode ) { |
1699 |
jQuery.cleanData( [ elem ], true ); |
1700 |
|
1701 |
// Use delete when supported for expandos or `cache` is not a window per isWindow (#10080) |
1702 |
} else if ( jQuery.support.deleteExpando || cache != cache.window ) { |
1703 |
delete cache[ id ]; |
1704 |
|
1705 |
// When all else fails, null |
1706 |
} else { |
1707 |
cache[ id ] = null; |
1708 |
} |
1709 |
}, |
1710 |
|
1711 |
// For internal use only. |
1712 |
_data: function( elem, name, data ) { |
1713 |
return jQuery.data( elem, name, data, true ); |
1714 |
}, |
1715 |
|
1716 |
// A method for determining if a DOM node can handle the data expando |
1717 |
acceptData: function( elem ) { |
1718 |
var noData = elem.nodeName && jQuery.noData[ elem.nodeName.toLowerCase() ]; |
1719 |
|
1720 |
// nodes accept data unless otherwise specified; rejection can be conditional |
1721 |
return !noData || noData !== true && elem.getAttribute("classid") === noData; |
1722 |
} |
1723 |
}); |
1724 |
|
1725 |
jQuery.fn.extend({ |
1726 |
data: function( key, value ) { |
1727 |
var parts, part, attr, name, l, |
1728 |
elem = this[0], |
1729 |
i = 0, |
1730 |
data = null; |
1731 |
|
1732 |
// Gets all values |
1733 |
if ( key === undefined ) { |
1734 |
if ( this.length ) { |
1735 |
data = jQuery.data( elem ); |
1736 |
|
1737 |
if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) { |
1738 |
attr = elem.attributes; |
1739 |
for ( l = attr.length; i < l; i++ ) { |
1740 |
name = attr[i].name; |
1741 |
|
1742 |
if ( name.indexOf( "data-" ) === 0 ) { |
1743 |
name = jQuery.camelCase( name.substring(5) ); |
1744 |
|
1745 |
dataAttr( elem, name, data[ name ] ); |
1746 |
} |
1747 |
} |
1748 |
jQuery._data( elem, "parsedAttrs", true ); |
1749 |
} |
1750 |
} |
1751 |
|
1752 |
return data; |
1753 |
} |
1754 |
|
1755 |
// Sets multiple values |
1756 |
if ( typeof key === "object" ) { |
1757 |
return this.each(function() { |
1758 |
jQuery.data( this, key ); |
1759 |
}); |
1760 |
} |
1761 |
|
1762 |
parts = key.split( ".", 2 ); |
1763 |
parts[1] = parts[1] ? "." + parts[1] : ""; |
1764 |
part = parts[1] + "!"; |
1765 |
|
1766 |
return jQuery.access( this, function( value ) { |
1767 |
|
1768 |
if ( value === undefined ) { |
1769 |
data = this.triggerHandler( "getData" + part, [ parts[0] ] ); |
1770 |
|
1771 |
// Try to fetch any internally stored data first |
1772 |
if ( data === undefined && elem ) { |
1773 |
data = jQuery.data( elem, key ); |
1774 |
data = dataAttr( elem, key, data ); |
1775 |
} |
1776 |
|
1777 |
return data === undefined && parts[1] ? |
1778 |
this.data( parts[0] ) : |
1779 |
data; |
1780 |
} |
1781 |
|
1782 |
parts[1] = value; |
1783 |
this.each(function() { |
1784 |
var self = jQuery( this ); |
1785 |
|
1786 |
self.triggerHandler( "setData" + part, parts ); |
1787 |
jQuery.data( this, key, value ); |
1788 |
self.triggerHandler( "changeData" + part, parts ); |
1789 |
}); |
1790 |
}, null, value, arguments.length > 1, null, false ); |
1791 |
}, |
1792 |
|
1793 |
removeData: function( key ) { |
1794 |
return this.each(function() { |
1795 |
jQuery.removeData( this, key ); |
1796 |
}); |
1797 |
} |
1798 |
}); |
1799 |
|
1800 |
function dataAttr( elem, key, data ) { |
1801 |
// If nothing was found internally, try to fetch any |
1802 |
// data from the HTML5 data-* attribute |
1803 |
if ( data === undefined && elem.nodeType === 1 ) { |
1804 |
|
1805 |
var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); |
1806 |
|
1807 |
data = elem.getAttribute( name ); |
1808 |
|
1809 |
if ( typeof data === "string" ) { |
1810 |
try { |
1811 |
data = data === "true" ? true : |
1812 |
data === "false" ? false : |
1813 |
data === "null" ? null : |
1814 |
// Only convert to a number if it doesn't change the string |
1815 |
+data + "" === data ? +data : |
1816 |
rbrace.test( data ) ? jQuery.parseJSON( data ) : |
1817 |
data; |
1818 |
} catch( e ) {} |
1819 |
|
1820 |
// Make sure we set the data so it isn't changed later |
1821 |
jQuery.data( elem, key, data ); |
1822 |
|
1823 |
} else { |
1824 |
data = undefined; |
1825 |
} |
1826 |
} |
1827 |
|
1828 |
return data; |
1829 |
} |
1830 |
|
1831 |
// checks a cache object for emptiness |
1832 |
function isEmptyDataObject( obj ) { |
1833 |
var name; |
1834 |
for ( name in obj ) { |
1835 |
|
1836 |
// if the public data object is empty, the private is still empty |
1837 |
if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) { |
1838 |
continue; |
1839 |
} |
1840 |
if ( name !== "toJSON" ) { |
1841 |
return false; |
1842 |
} |
1843 |
} |
1844 |
|
1845 |
return true; |
1846 |
} |
1847 |
jQuery.extend({ |
1848 |
queue: function( elem, type, data ) { |
1849 |
var queue; |
1850 |
|
1851 |
if ( elem ) { |
1852 |
type = ( type || "fx" ) + "queue"; |
1853 |
queue = jQuery._data( elem, type ); |
1854 |
|
1855 |
// Speed up dequeue by getting out quickly if this is just a lookup |
1856 |
if ( data ) { |
1857 |
if ( !queue || jQuery.isArray(data) ) { |
1858 |
queue = jQuery._data( elem, type, jQuery.makeArray(data) ); |
1859 |
} else { |
1860 |
queue.push( data ); |
1861 |
} |
1862 |
} |
1863 |
return queue || []; |
1864 |
} |
1865 |
}, |
1866 |
|
1867 |
dequeue: function( elem, type ) { |
1868 |
type = type || "fx"; |
1869 |
|
1870 |
var queue = jQuery.queue( elem, type ), |
1871 |
startLength = queue.length, |
1872 |
fn = queue.shift(), |
1873 |
hooks = jQuery._queueHooks( elem, type ), |
1874 |
next = function() { |
1875 |
jQuery.dequeue( elem, type ); |
1876 |
}; |
1877 |
|
1878 |
// If the fx queue is dequeued, always remove the progress sentinel |
1879 |
if ( fn === "inprogress" ) { |
1880 |
fn = queue.shift(); |
1881 |
startLength--; |
1882 |
} |
1883 |
|
1884 |
if ( fn ) { |
1885 |
|
1886 |
// Add a progress sentinel to prevent the fx queue from being |
1887 |
// automatically dequeued |
1888 |
if ( type === "fx" ) { |
1889 |
queue.unshift( "inprogress" ); |
1890 |
} |
1891 |
|
1892 |
// clear up the last queue stop function |
1893 |
delete hooks.stop; |
1894 |
fn.call( elem, next, hooks ); |
1895 |
} |
1896 |
|
1897 |
if ( !startLength && hooks ) { |
1898 |
hooks.empty.fire(); |
1899 |
} |
1900 |
}, |
1901 |
|
1902 |
// not intended for public consumption - generates a queueHooks object, or returns the current one |
1903 |
_queueHooks: function( elem, type ) { |
1904 |
var key = type + "queueHooks"; |
1905 |
return jQuery._data( elem, key ) || jQuery._data( elem, key, { |
1906 |
empty: jQuery.Callbacks("once memory").add(function() { |
1907 |
jQuery.removeData( elem, type + "queue", true ); |
1908 |
jQuery.removeData( elem, key, true ); |
1909 |
}) |
1910 |
}); |
1911 |
} |
1912 |
}); |
1913 |
|
1914 |
jQuery.fn.extend({ |
1915 |
queue: function( type, data ) { |
1916 |
var setter = 2; |
1917 |
|
1918 |
if ( typeof type !== "string" ) { |
1919 |
data = type; |
1920 |
type = "fx"; |
1921 |
setter--; |
1922 |
} |
1923 |
|
1924 |
if ( arguments.length < setter ) { |
1925 |
return jQuery.queue( this[0], type ); |
1926 |
} |
1927 |
|
1928 |
return data === undefined ? |
1929 |
this : |
1930 |
this.each(function() { |
1931 |
var queue = jQuery.queue( this, type, data ); |
1932 |
|
1933 |
// ensure a hooks for this queue |
1934 |
jQuery._queueHooks( this, type ); |
1935 |
|
1936 |
if ( type === "fx" && queue[0] !== "inprogress" ) { |
1937 |
jQuery.dequeue( this, type ); |
1938 |
} |
1939 |
}); |
1940 |
}, |
1941 |
dequeue: function( type ) { |
1942 |
return this.each(function() { |
1943 |
jQuery.dequeue( this, type ); |
1944 |
}); |
1945 |
}, |
1946 |
// Based off of the plugin by Clint Helfers, with permission. |
1947 |
// http://blindsignals.com/index.php/2009/07/jquery-delay/ |
1948 |
delay: function( time, type ) { |
1949 |
time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; |
1950 |
type = type || "fx"; |
1951 |
|
1952 |
return this.queue( type, function( next, hooks ) { |
1953 |
var timeout = setTimeout( next, time ); |
1954 |
hooks.stop = function() { |
1955 |
clearTimeout( timeout ); |
1956 |
}; |
1957 |
}); |
1958 |
}, |
1959 |
clearQueue: function( type ) { |
1960 |
return this.queue( type || "fx", [] ); |
1961 |
}, |
1962 |
// Get a promise resolved when queues of a certain type |
1963 |
// are emptied (fx is the type by default) |
1964 |
promise: function( type, obj ) { |
1965 |
var tmp, |
1966 |
count = 1, |
1967 |
defer = jQuery.Deferred(), |
1968 |
elements = this, |
1969 |
i = this.length, |
1970 |
resolve = function() { |
1971 |
if ( !( --count ) ) { |
1972 |
defer.resolveWith( elements, [ elements ] ); |
1973 |
} |
1974 |
}; |
1975 |
|
1976 |
if ( typeof type !== "string" ) { |
1977 |
obj = type; |
1978 |
type = undefined; |
1979 |
} |
1980 |
type = type || "fx"; |
1981 |
|
1982 |
while( i-- ) { |
1983 |
tmp = jQuery._data( elements[ i ], type + "queueHooks" ); |
1984 |
if ( tmp && tmp.empty ) { |
1985 |
count++; |
1986 |
tmp.empty.add( resolve ); |
1987 |
} |
1988 |
} |
1989 |
resolve(); |
1990 |
return defer.promise( obj ); |
1991 |
} |
1992 |
}); |
1993 |
var nodeHook, boolHook, fixSpecified, |
1994 |
rclass = /[\t\r\n]/g, |
1995 |
rreturn = /\r/g, |
1996 |
rtype = /^(?:button|input)$/i, |
1997 |
rfocusable = /^(?:button|input|object|select|textarea)$/i, |
1998 |
rclickable = /^a(?:rea|)$/i, |
1999 |
rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, |
2000 |
getSetAttribute = jQuery.support.getSetAttribute; |
2001 |
|
2002 |
jQuery.fn.extend({ |
2003 |
attr: function( name, value ) { |
2004 |
return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 ); |
2005 |
}, |
2006 |
|
2007 |
removeAttr: function( name ) { |
2008 |
return this.each(function() { |
2009 |
jQuery.removeAttr( this, name ); |
2010 |
}); |
2011 |
}, |
2012 |
|
2013 |
prop: function( name, value ) { |
2014 |
return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 ); |
2015 |
}, |
2016 |
|
2017 |
removeProp: function( name ) { |
2018 |
name = jQuery.propFix[ name ] || name; |
2019 |
return this.each(function() { |
2020 |
// try/catch handles cases where IE balks (such as removing a property on window) |
2021 |
try { |
2022 |
this[ name ] = undefined; |
2023 |
delete this[ name ]; |
2024 |
} catch( e ) {} |
2025 |
}); |
2026 |
}, |
2027 |
|
2028 |
addClass: function( value ) { |
2029 |
var classNames, i, l, elem, |
2030 |
setClass, c, cl; |
2031 |
|
2032 |
if ( jQuery.isFunction( value ) ) { |
2033 |
return this.each(function( j ) { |
2034 |
jQuery( this ).addClass( value.call(this, j, this.className) ); |
2035 |
}); |
2036 |
} |
2037 |
|
2038 |
if ( value && typeof value === "string" ) { |
2039 |
classNames = value.split( core_rspace ); |
2040 |
|
2041 |
for ( i = 0, l = this.length; i < l; i++ ) { |
2042 |
elem = this[ i ]; |
2043 |
|
2044 |
if ( elem.nodeType === 1 ) { |
2045 |
if ( !elem.className && classNames.length === 1 ) { |
2046 |
elem.className = value; |
2047 |
|
2048 |
} else { |
2049 |
setClass = " " + elem.className + " "; |
2050 |
|
2051 |
for ( c = 0, cl = classNames.length; c < cl; c++ ) { |
2052 |
if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) { |
2053 |
setClass += classNames[ c ] + " "; |
2054 |
} |
2055 |
} |
2056 |
elem.className = jQuery.trim( setClass ); |
2057 |
} |
2058 |
} |
2059 |
} |
2060 |
} |
2061 |
|
2062 |
return this; |
2063 |
}, |
2064 |
|
2065 |
removeClass: function( value ) { |
2066 |
var removes, className, elem, c, cl, i, l; |
2067 |
|
2068 |
if ( jQuery.isFunction( value ) ) { |
2069 |
return this.each(function( j ) { |
2070 |
jQuery( this ).removeClass( value.call(this, j, this.className) ); |
2071 |
}); |
2072 |
} |
2073 |
if ( (value && typeof value === "string") || value === undefined ) { |
2074 |
removes = ( value || "" ).split( core_rspace ); |
2075 |
|
2076 |
for ( i = 0, l = this.length; i < l; i++ ) { |
2077 |
elem = this[ i ]; |
2078 |
if ( elem.nodeType === 1 && elem.className ) { |
2079 |
|
2080 |
className = (" " + elem.className + " ").replace( rclass, " " ); |
2081 |
|
2082 |
// loop over each item in the removal list |
2083 |
for ( c = 0, cl = removes.length; c < cl; c++ ) { |
2084 |
// Remove until there is nothing to remove, |
2085 |
while ( className.indexOf(" " + removes[ c ] + " ") > -1 ) { |
2086 |
className = className.replace( " " + removes[ c ] + " " , " " ); |
2087 |
} |
2088 |
} |
2089 |
elem.className = value ? jQuery.trim( className ) : ""; |
2090 |
} |
2091 |
} |
2092 |
} |
2093 |
|
2094 |
return this; |
2095 |
}, |
2096 |
|
2097 |
toggleClass: function( value, stateVal ) { |
2098 |
var type = typeof value, |
2099 |
isBool = typeof stateVal === "boolean"; |
2100 |
|
2101 |
if ( jQuery.isFunction( value ) ) { |
2102 |
return this.each(function( i ) { |
2103 |
jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); |
2104 |
}); |
2105 |
} |
2106 |
|
2107 |
return this.each(function() { |
2108 |
if ( type === "string" ) { |
2109 |
// toggle individual class names |
2110 |
var className, |
2111 |
i = 0, |
2112 |
self = jQuery( this ), |
2113 |
state = stateVal, |
2114 |
classNames = value.split( core_rspace ); |
2115 |
|
2116 |
while ( (className = classNames[ i++ ]) ) { |
2117 |
// check each className given, space separated list |
2118 |
state = isBool ? state : !self.hasClass( className ); |
2119 |
self[ state ? "addClass" : "removeClass" ]( className ); |
2120 |
} |
2121 |
|
2122 |
} else if ( type === "undefined" || type === "boolean" ) { |
2123 |
if ( this.className ) { |
2124 |
// store className if set |
2125 |
jQuery._data( this, "__className__", this.className ); |
2126 |
} |
2127 |
|
2128 |
// toggle whole className |
2129 |
this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; |
2130 |
} |
2131 |
}); |
2132 |
}, |
2133 |
|
2134 |
hasClass: function( selector ) { |
2135 |
var className = " " + selector + " ", |
2136 |
i = 0, |
2137 |
l = this.length; |
2138 |
for ( ; i < l; i++ ) { |
2139 |
if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) { |
2140 |
return true; |
2141 |
} |
2142 |
} |
2143 |
|
2144 |
return false; |
2145 |
}, |
2146 |
|
2147 |
val: function( value ) { |
2148 |
var hooks, ret, isFunction, |
2149 |
elem = this[0]; |
2150 |
|
2151 |
if ( !arguments.length ) { |
2152 |
if ( elem ) { |
2153 |
hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ]; |
2154 |
|
2155 |
if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { |
2156 |
return ret; |
2157 |
} |
2158 |
|
2159 |
ret = elem.value; |
2160 |
|
2161 |
return typeof ret === "string" ? |
2162 |
// handle most common string cases |
2163 |
ret.replace(rreturn, "") : |
2164 |
// handle cases where value is null/undef or number |
2165 |
ret == null ? "" : ret; |
2166 |
} |
2167 |
|
2168 |
return; |
2169 |
} |
2170 |
|
2171 |
isFunction = jQuery.isFunction( value ); |
2172 |
|
2173 |
return this.each(function( i ) { |
2174 |
var val, |
2175 |
self = jQuery(this); |
2176 |
|
2177 |
if ( this.nodeType !== 1 ) { |
2178 |
return; |
2179 |
} |
2180 |
|
2181 |
if ( isFunction ) { |
2182 |
val = value.call( this, i, self.val() ); |
2183 |
} else { |
2184 |
val = value; |
2185 |
} |
2186 |
|
2187 |
// Treat null/undefined as ""; convert numbers to string |
2188 |
if ( val == null ) { |
2189 |
val = ""; |
2190 |
} else if ( typeof val === "number" ) { |
2191 |
val += ""; |
2192 |
} else if ( jQuery.isArray( val ) ) { |
2193 |
val = jQuery.map(val, function ( value ) { |
2194 |
return value == null ? "" : value + ""; |
2195 |
}); |
2196 |
} |
2197 |
|
2198 |
hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; |
2199 |
|
2200 |
// If set returns undefined, fall back to normal setting |
2201 |
if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { |
2202 |
this.value = val; |
2203 |
} |
2204 |
}); |
2205 |
} |
2206 |
}); |
2207 |
|
2208 |
jQuery.extend({ |
2209 |
valHooks: { |
2210 |
option: { |
2211 |
get: function( elem ) { |
2212 |
// attributes.value is undefined in Blackberry 4.7 but |
2213 |
// uses .value. See #6932 |
2214 |
var val = elem.attributes.value; |
2215 |
return !val || val.specified ? elem.value : elem.text; |
2216 |
} |
2217 |
}, |
2218 |
select: { |
2219 |
get: function( elem ) { |
2220 |
var value, i, max, option, |
2221 |
index = elem.selectedIndex, |
2222 |
values = [], |
2223 |
options = elem.options, |
2224 |
one = elem.type === "select-one"; |
2225 |
|
2226 |
// Nothing was selected |
2227 |
if ( index < 0 ) { |
2228 |
return null; |
2229 |
} |
2230 |
|
2231 |
// Loop through all the selected options |
2232 |
i = one ? index : 0; |
2233 |
max = one ? index + 1 : options.length; |
2234 |
for ( ; i < max; i++ ) { |
2235 |
option = options[ i ]; |
2236 |
|
2237 |
// Don't return options that are disabled or in a disabled optgroup |
2238 |
if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && |
2239 |
(!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) { |
2240 |
|
2241 |
// Get the specific value for the option |
2242 |
value = jQuery( option ).val(); |
2243 |
|
2244 |
// We don't need an array for one selects |
2245 |
if ( one ) { |
2246 |
return value; |
2247 |
} |
2248 |
|
2249 |
// Multi-Selects return an array |
2250 |
values.push( value ); |
2251 |
} |
2252 |
} |
2253 |
|
2254 |
// Fixes Bug #2551 -- select.val() broken in IE after form.reset() |
2255 |
if ( one && !values.length && options.length ) { |
2256 |
return jQuery( options[ index ] ).val(); |
2257 |
} |
2258 |
|
2259 |
return values; |
2260 |
}, |
2261 |
|
2262 |
set: function( elem, value ) { |
2263 |
var values = jQuery.makeArray( value ); |
2264 |
|
2265 |
jQuery(elem).find("option").each(function() { |
2266 |
this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0; |
2267 |
}); |
2268 |
|
2269 |
if ( !values.length ) { |
2270 |
elem.selectedIndex = -1; |
2271 |
} |
2272 |
return values; |
2273 |
} |
2274 |
} |
2275 |
}, |
2276 |
|
2277 |
// Unused in 1.8, left in so attrFn-stabbers won't die; remove in 1.9 |
2278 |
attrFn: {}, |
2279 |
|
2280 |
attr: function( elem, name, value, pass ) { |
2281 |
var ret, hooks, notxml, |
2282 |
nType = elem.nodeType; |
2283 |
|
2284 |
// don't get/set attributes on text, comment and attribute nodes |
2285 |
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { |
2286 |
return; |
2287 |
} |
2288 |
|
2289 |
if ( pass && jQuery.isFunction( jQuery.fn[ name ] ) ) { |
2290 |
return jQuery( elem )[ name ]( value ); |
2291 |
} |
2292 |
|
2293 |
// Fallback to prop when attributes are not supported |
2294 |
if ( typeof elem.getAttribute === "undefined" ) { |
2295 |
return jQuery.prop( elem, name, value ); |
2296 |
} |
2297 |
|
2298 |
notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); |
2299 |
|
2300 |
// All attributes are lowercase |
2301 |
// Grab necessary hook if one is defined |
2302 |
if ( notxml ) { |
2303 |
name = name.toLowerCase(); |
2304 |
hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook ); |
2305 |
} |
2306 |
|
2307 |
if ( value !== undefined ) { |
2308 |
|
2309 |
if ( value === null ) { |
2310 |
jQuery.removeAttr( elem, name ); |
2311 |
return; |
2312 |
|
2313 |
} else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) { |
2314 |
return ret; |
2315 |
|
2316 |
} else { |
2317 |
elem.setAttribute( name, "" + value ); |
2318 |
return value; |
2319 |
} |
2320 |
|
2321 |
} else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) { |
2322 |
return ret; |
2323 |
|
2324 |
} else { |
2325 |
|
2326 |
ret = elem.getAttribute( name ); |
2327 |
|
2328 |
// Non-existent attributes return null, we normalize to undefined |
2329 |
return ret === null ? |
2330 |
undefined : |
2331 |
ret; |
2332 |
} |
2333 |
}, |
2334 |
|
2335 |
removeAttr: function( elem, value ) { |
2336 |
var propName, attrNames, name, isBool, |
2337 |
i = 0; |
2338 |
|
2339 |
if ( value && elem.nodeType === 1 ) { |
2340 |
|
2341 |
attrNames = value.split( core_rspace ); |
2342 |
|
2343 |
for ( ; i < attrNames.length; i++ ) { |
2344 |
name = attrNames[ i ]; |
2345 |
|
2346 |
if ( name ) { |
2347 |
propName = jQuery.propFix[ name ] || name; |
2348 |
isBool = rboolean.test( name ); |
2349 |
|
2350 |
// See #9699 for explanation of this approach (setting first, then removal) |
2351 |
// Do not do this for boolean attributes (see #10870) |
2352 |
if ( !isBool ) { |
2353 |
jQuery.attr( elem, name, "" ); |
2354 |
} |
2355 |
elem.removeAttribute( getSetAttribute ? name : propName ); |
2356 |
|
2357 |
// Set corresponding property to false for boolean attributes |
2358 |
if ( isBool && propName in elem ) { |
2359 |
elem[ propName ] = false; |
2360 |
} |
2361 |
} |
2362 |
} |
2363 |
} |
2364 |
}, |
2365 |
|
2366 |
attrHooks: { |
2367 |
type: { |
2368 |
set: function( elem, value ) { |
2369 |
// We can't allow the type property to be changed (since it causes problems in IE) |
2370 |
if ( rtype.test( elem.nodeName ) && elem.parentNode ) { |
2371 |
jQuery.error( "type property can't be changed" ); |
2372 |
} else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) { |
2373 |
// Setting the type on a radio button after the value resets the value in IE6-9 |
2374 |
// Reset value to it's default in case type is set after value |
2375 |
// This is for element creation |
2376 |
var val = elem.value; |
2377 |
elem.setAttribute( "type", value ); |
2378 |
if ( val ) { |
2379 |
elem.value = val; |
2380 |
} |
2381 |
return value; |
2382 |
} |
2383 |
} |
2384 |
}, |
2385 |
// Use the value property for back compat |
2386 |
// Use the nodeHook for button elements in IE6/7 (#1954) |
2387 |
value: { |
2388 |
get: function( elem, name ) { |
2389 |
if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { |
2390 |
return nodeHook.get( elem, name ); |
2391 |
} |
2392 |
return name in elem ? |
2393 |
elem.value : |
2394 |
null; |
2395 |
}, |
2396 |
set: function( elem, value, name ) { |
2397 |
if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { |
2398 |
return nodeHook.set( elem, value, name ); |
2399 |
} |
2400 |
// Does not return so that setAttribute is also used |
2401 |
elem.value = value; |
2402 |
} |
2403 |
} |
2404 |
}, |
2405 |
|
2406 |
propFix: { |
2407 |
tabindex: "tabIndex", |
2408 |
readonly: "readOnly", |
2409 |
"for": "htmlFor", |
2410 |
"class": "className", |
2411 |
maxlength: "maxLength", |
2412 |
cellspacing: "cellSpacing", |
2413 |
cellpadding: "cellPadding", |
2414 |
rowspan: "rowSpan", |
2415 |
colspan: "colSpan", |
2416 |
usemap: "useMap", |
2417 |
frameborder: "frameBorder", |
2418 |
contenteditable: "contentEditable" |
2419 |
}, |
2420 |
|
2421 |
prop: function( elem, name, value ) { |
2422 |
var ret, hooks, notxml, |
2423 |
nType = elem.nodeType; |
2424 |
|
2425 |
// don't get/set properties on text, comment and attribute nodes |
2426 |
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { |
2427 |
return; |
2428 |
} |
2429 |
|
2430 |
notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); |
2431 |
|
2432 |
if ( notxml ) { |
2433 |
// Fix name and attach hooks |
2434 |
name = jQuery.propFix[ name ] || name; |
2435 |
hooks = jQuery.propHooks[ name ]; |
2436 |
} |
2437 |
|
2438 |
if ( value !== undefined ) { |
2439 |
if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { |
2440 |
return ret; |
2441 |
|
2442 |
} else { |
2443 |
return ( elem[ name ] = value ); |
2444 |
} |
2445 |
|
2446 |
} else { |
2447 |
if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { |
2448 |
return ret; |
2449 |
|
2450 |
} else { |
2451 |
return elem[ name ]; |
2452 |
} |
2453 |
} |
2454 |
}, |
2455 |
|
2456 |
propHooks: { |
2457 |
tabIndex: { |
2458 |
get: function( elem ) { |
2459 |
// elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set |
2460 |
// http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ |
2461 |
var attributeNode = elem.getAttributeNode("tabindex"); |
2462 |
|
2463 |
return attributeNode && attributeNode.specified ? |
2464 |
parseInt( attributeNode.value, 10 ) : |
2465 |
rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? |
2466 |
0 : |
2467 |
undefined; |
2468 |
} |
2469 |
} |
2470 |
} |
2471 |
}); |
2472 |
|
2473 |
// Hook for boolean attributes |
2474 |
boolHook = { |
2475 |
get: function( elem, name ) { |
2476 |
// Align boolean attributes with corresponding properties |
2477 |
// Fall back to attribute presence where some booleans are not supported |
2478 |
var attrNode, |
2479 |
property = jQuery.prop( elem, name ); |
2480 |
return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ? |
2481 |
name.toLowerCase() : |
2482 |
undefined; |
2483 |
}, |
2484 |
set: function( elem, value, name ) { |
2485 |
var propName; |
2486 |
if ( value === false ) { |
2487 |
// Remove boolean attributes when set to false |
2488 |
jQuery.removeAttr( elem, name ); |
2489 |
} else { |
2490 |
// value is true since we know at this point it's type boolean and not false |
2491 |
// Set boolean attributes to the same name and set the DOM property |
2492 |
propName = jQuery.propFix[ name ] || name; |
2493 |
if ( propName in elem ) { |
2494 |
// Only set the IDL specifically if it already exists on the element |
2495 |
elem[ propName ] = true; |
2496 |
} |
2497 |
|
2498 |
elem.setAttribute( name, name.toLowerCase() ); |
2499 |
} |
2500 |
return name; |
2501 |
} |
2502 |
}; |
2503 |
|
2504 |
// IE6/7 do not support getting/setting some attributes with get/setAttribute |
2505 |
if ( !getSetAttribute ) { |
2506 |
|
2507 |
fixSpecified = { |
2508 |
name: true, |
2509 |
id: true, |
2510 |
coords: true |
2511 |
}; |
2512 |
|
2513 |
// Use this for any attribute in IE6/7 |
2514 |
// This fixes almost every IE6/7 issue |
2515 |
nodeHook = jQuery.valHooks.button = { |
2516 |
get: function( elem, name ) { |
2517 |
var ret; |
2518 |
ret = elem.getAttributeNode( name ); |
2519 |
return ret && ( fixSpecified[ name ] ? ret.value !== "" : ret.specified ) ? |
2520 |
ret.value : |
2521 |
undefined; |
2522 |
}, |
2523 |
set: function( elem, value, name ) { |
2524 |
// Set the existing or create a new attribute node |
2525 |
var ret = elem.getAttributeNode( name ); |
2526 |
if ( !ret ) { |
2527 |
ret = document.createAttribute( name ); |
2528 |
elem.setAttributeNode( ret ); |
2529 |
} |
2530 |
return ( ret.value = value + "" ); |
2531 |
} |
2532 |
}; |
2533 |
|
2534 |
// Set width and height to auto instead of 0 on empty string( Bug #8150 ) |
2535 |
// This is for removals |
2536 |
jQuery.each([ "width", "height" ], function( i, name ) { |
2537 |
jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { |
2538 |
set: function( elem, value ) { |
2539 |
if ( value === "" ) { |
2540 |
elem.setAttribute( name, "auto" ); |
2541 |
return value; |
2542 |
} |
2543 |
} |
2544 |
}); |
2545 |
}); |
2546 |
|
2547 |
// Set contenteditable to false on removals(#10429) |
2548 |
// Setting to empty string throws an error as an invalid value |
2549 |
jQuery.attrHooks.contenteditable = { |
2550 |
get: nodeHook.get, |
2551 |
set: function( elem, value, name ) { |
2552 |
if ( value === "" ) { |
2553 |
value = "false"; |
2554 |
} |
2555 |
nodeHook.set( elem, value, name ); |
2556 |
} |
2557 |
}; |
2558 |
} |
2559 |
|
2560 |
|
2561 |
// Some attributes require a special call on IE |
2562 |
if ( !jQuery.support.hrefNormalized ) { |
2563 |
jQuery.each([ "href", "src", "width", "height" ], function( i, name ) { |
2564 |
jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { |
2565 |
get: function( elem ) { |
2566 |
var ret = elem.getAttribute( name, 2 ); |
2567 |
return ret === null ? undefined : ret; |
2568 |
} |
2569 |
}); |
2570 |
}); |
2571 |
} |
2572 |
|
2573 |
if ( !jQuery.support.style ) { |
2574 |
jQuery.attrHooks.style = { |
2575 |
get: function( elem ) { |
2576 |
// Return undefined in the case of empty string |
2577 |
// Normalize to lowercase since IE uppercases css property names |
2578 |
return elem.style.cssText.toLowerCase() || undefined; |
2579 |
}, |
2580 |
set: function( elem, value ) { |
2581 |
return ( elem.style.cssText = "" + value ); |
2582 |
} |
2583 |
}; |
2584 |
} |
2585 |
|
2586 |
// Safari mis-reports the default selected property of an option |
2587 |
// Accessing the parent's selectedIndex property fixes it |
2588 |
if ( !jQuery.support.optSelected ) { |
2589 |
jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, { |
2590 |
get: function( elem ) { |
2591 |
var parent = elem.parentNode; |
2592 |
|
2593 |
if ( parent ) { |
2594 |
parent.selectedIndex; |
2595 |
|
2596 |
// Make sure that it also works with optgroups, see #5701 |
2597 |
if ( parent.parentNode ) { |
2598 |
parent.parentNode.selectedIndex; |
2599 |
} |
2600 |
} |
2601 |
return null; |
2602 |
} |
2603 |
}); |
2604 |
} |
2605 |
|
2606 |
// IE6/7 call enctype encoding |
2607 |
if ( !jQuery.support.enctype ) { |
2608 |
jQuery.propFix.enctype = "encoding"; |
2609 |
} |
2610 |
|
2611 |
// Radios and checkboxes getter/setter |
2612 |
if ( !jQuery.support.checkOn ) { |
2613 |
jQuery.each([ "radio", "checkbox" ], function() { |
2614 |
jQuery.valHooks[ this ] = { |
2615 |
get: function( elem ) { |
2616 |
// Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified |
2617 |
return elem.getAttribute("value") === null ? "on" : elem.value; |
2618 |
} |
2619 |
}; |
2620 |
}); |
2621 |
} |
2622 |
jQuery.each([ "radio", "checkbox" ], function() { |
2623 |
jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], { |
2624 |
set: function( elem, value ) { |
2625 |
if ( jQuery.isArray( value ) ) { |
2626 |
return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); |
2627 |
} |
2628 |
} |
2629 |
}); |
2630 |
}); |
2631 |
var rformElems = /^(?:textarea|input|select)$/i, |
2632 |
rtypenamespace = /^([^\.]*|)(?:\.(.+)|)$/, |
2633 |
rhoverHack = /(?:^|\s)hover(\.\S+|)\b/, |
2634 |
rkeyEvent = /^key/, |
2635 |
rmouseEvent = /^(?:mouse|contextmenu)|click/, |
2636 |
rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, |
2637 |
hoverHack = function( events ) { |
2638 |
return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" ); |
2639 |
}; |
2640 |
|
2641 |
/* |
2642 |
* Helper functions for managing events -- not part of the public interface. |
2643 |
* Props to Dean Edwards' addEvent library for many of the ideas. |
2644 |
*/ |
2645 |
jQuery.event = { |
2646 |
|
2647 |
add: function( elem, types, handler, data, selector ) { |
2648 |
|
2649 |
var elemData, eventHandle, events, |
2650 |
t, tns, type, namespaces, handleObj, |
2651 |
handleObjIn, handlers, special; |
2652 |
|
2653 |
// Don't attach events to noData or text/comment nodes (allow plain objects tho) |
2654 |
if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) { |
2655 |
return; |
2656 |
} |
2657 |
|
2658 |
// Caller can pass in an object of custom data in lieu of the handler |
2659 |
if ( handler.handler ) { |
2660 |
handleObjIn = handler; |
2661 |
handler = handleObjIn.handler; |
2662 |
selector = handleObjIn.selector; |
2663 |
} |
2664 |
|
2665 |
// Make sure that the handler has a unique ID, used to find/remove it later |
2666 |
if ( !handler.guid ) { |
2667 |
handler.guid = jQuery.guid++; |
2668 |
} |
2669 |
|
2670 |
// Init the element's event structure and main handler, if this is the first |
2671 |
events = elemData.events; |
2672 |
if ( !events ) { |
2673 |
elemData.events = events = {}; |
2674 |
} |
2675 |
eventHandle = elemData.handle; |
2676 |
if ( !eventHandle ) { |
2677 |
elemData.handle = eventHandle = function( e ) { |
2678 |
// Discard the second event of a jQuery.event.trigger() and |
2679 |
// when an event is called after a page has unloaded |
2680 |
return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ? |
2681 |
jQuery.event.dispatch.apply( eventHandle.elem, arguments ) : |
2682 |
undefined; |
2683 |
}; |
2684 |
// Add elem as a property of the handle fn to prevent a memory leak with IE non-native events |
2685 |
eventHandle.elem = elem; |
2686 |
} |
2687 |
|
2688 |
// Handle multiple events separated by a space |
2689 |
// jQuery(...).bind("mouseover mouseout", fn); |
2690 |
types = jQuery.trim( hoverHack(types) ).split( " " ); |
2691 |
for ( t = 0; t < types.length; t++ ) { |
2692 |
|
2693 |
tns = rtypenamespace.exec( types[t] ) || []; |
2694 |
type = tns[1]; |
2695 |
namespaces = ( tns[2] || "" ).split( "." ).sort(); |
2696 |
|
2697 |
// If event changes its type, use the special event handlers for the changed type |
2698 |
special = jQuery.event.special[ type ] || {}; |
2699 |
|
2700 |
// If selector defined, determine special event api type, otherwise given type |
2701 |
type = ( selector ? special.delegateType : special.bindType ) || type; |
2702 |
|
2703 |
// Update special based on newly reset type |
2704 |
special = jQuery.event.special[ type ] || {}; |
2705 |
|
2706 |
// handleObj is passed to all event handlers |
2707 |
handleObj = jQuery.extend({ |
2708 |
type: type, |
2709 |
origType: tns[1], |
2710 |
data: data, |
2711 |
handler: handler, |
2712 |
guid: handler.guid, |
2713 |
selector: selector, |
2714 |
namespace: namespaces.join(".") |
2715 |
}, handleObjIn ); |
2716 |
|
2717 |
// Init the event handler queue if we're the first |
2718 |
handlers = events[ type ]; |
2719 |
if ( !handlers ) { |
2720 |
handlers = events[ type ] = []; |
2721 |
handlers.delegateCount = 0; |
2722 |
|
2723 |
// Only use addEventListener/attachEvent if the special events handler returns false |
2724 |
if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { |
2725 |
// Bind the global event handler to the element |
2726 |
if ( elem.addEventListener ) { |
2727 |
elem.addEventListener( type, eventHandle, false ); |
2728 |
|
2729 |
} else if ( elem.attachEvent ) { |
2730 |
elem.attachEvent( "on" + type, eventHandle ); |
2731 |
} |
2732 |
} |
2733 |
} |
2734 |
|
2735 |
if ( special.add ) { |
2736 |
special.add.call( elem, handleObj ); |
2737 |
|
2738 |
if ( !handleObj.handler.guid ) { |
2739 |
handleObj.handler.guid = handler.guid; |
2740 |
} |
2741 |
} |
2742 |
|
2743 |
// Add to the element's handler list, delegates in front |
2744 |
if ( selector ) { |
2745 |
handlers.splice( handlers.delegateCount++, 0, handleObj ); |
2746 |
} else { |
2747 |
handlers.push( handleObj ); |
2748 |
} |
2749 |
|
2750 |
// Keep track of which events have ever been used, for event optimization |
2751 |
jQuery.event.global[ type ] = true; |
2752 |
} |
2753 |
|
2754 |
// Nullify elem to prevent memory leaks in IE |
2755 |
elem = null; |
2756 |
}, |
2757 |
|
2758 |
global: {}, |
2759 |
|
2760 |
// Detach an event or set of events from an element |
2761 |
remove: function( elem, types, handler, selector, mappedTypes ) { |
2762 |
|
2763 |
var t, tns, type, origType, namespaces, origCount, |
2764 |
j, events, special, eventType, handleObj, |
2765 |
elemData = jQuery.hasData( elem ) && jQuery._data( elem ); |
2766 |
|
2767 |
if ( !elemData || !(events = elemData.events) ) { |
2768 |
return; |
2769 |
} |
2770 |
|
2771 |
// Once for each type.namespace in types; type may be omitted |
2772 |
types = jQuery.trim( hoverHack( types || "" ) ).split(" "); |
2773 |
for ( t = 0; t < types.length; t++ ) { |
2774 |
tns = rtypenamespace.exec( types[t] ) || []; |
2775 |
type = origType = tns[1]; |
2776 |
namespaces = tns[2]; |
2777 |
|
2778 |
// Unbind all events (on this namespace, if provided) for the element |
2779 |
if ( !type ) { |
2780 |
for ( type in events ) { |
2781 |
jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); |
2782 |
} |
2783 |
continue; |
2784 |
} |
2785 |
|
2786 |
special = jQuery.event.special[ type ] || {}; |
2787 |
type = ( selector? special.delegateType : special.bindType ) || type; |
2788 |
eventType = events[ type ] || []; |
2789 |
origCount = eventType.length; |
2790 |
namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.|)") + "(\\.|$)") : null; |
2791 |
|
2792 |
// Remove matching events |
2793 |
for ( j = 0; j < eventType.length; j++ ) { |
2794 |
handleObj = eventType[ j ]; |
2795 |
|
2796 |
if ( ( mappedTypes || origType === handleObj.origType ) && |
2797 |
( !handler || handler.guid === handleObj.guid ) && |
2798 |
( !namespaces || namespaces.test( handleObj.namespace ) ) && |
2799 |
( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { |
2800 |
eventType.splice( j--, 1 ); |
2801 |
|
2802 |
if ( handleObj.selector ) { |
2803 |
eventType.delegateCount--; |
2804 |
} |
2805 |
if ( special.remove ) { |
2806 |
special.remove.call( elem, handleObj ); |
2807 |
} |
2808 |
} |
2809 |
} |
2810 |
|
2811 |
// Remove generic event handler if we removed something and no more handlers exist |
2812 |
// (avoids potential for endless recursion during removal of special event handlers) |
2813 |
if ( eventType.length === 0 && origCount !== eventType.length ) { |
2814 |
if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) { |
2815 |
jQuery.removeEvent( elem, type, elemData.handle ); |
2816 |
} |
2817 |
|
2818 |
delete events[ type ]; |
2819 |
} |
2820 |
} |
2821 |
|
2822 |
// Remove the expando if it's no longer used |
2823 |
if ( jQuery.isEmptyObject( events ) ) { |
2824 |
delete elemData.handle; |
2825 |
|
2826 |
// removeData also checks for emptiness and clears the expando if empty |
2827 |
// so use it instead of delete |
2828 |
jQuery.removeData( elem, "events", true ); |
2829 |
} |
2830 |
}, |
2831 |
|
2832 |
// Events that are safe to short-circuit if no handlers are attached. |
2833 |
// Native DOM events should not be added, they may have inline handlers. |
2834 |
customEvent: { |
2835 |
"getData": true, |
2836 |
"setData": true, |
2837 |
"changeData": true |
2838 |
}, |
2839 |
|
2840 |
trigger: function( event, data, elem, onlyHandlers ) { |
2841 |
// Don't do events on text and comment nodes |
2842 |
if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) { |
2843 |
return; |
2844 |
} |
2845 |
|
2846 |
// Event object or event type |
2847 |
var cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType, |
2848 |
type = event.type || event, |
2849 |
namespaces = []; |
2850 |
|
2851 |
// focus/blur morphs to focusin/out; ensure we're not firing them right now |
2852 |
if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { |
2853 |
return; |
2854 |
} |
2855 |
|
2856 |
if ( type.indexOf( "!" ) >= 0 ) { |
2857 |
// Exclusive events trigger only for the exact event (no namespaces) |
2858 |
type = type.slice(0, -1); |
2859 |
exclusive = true; |
2860 |
} |
2861 |
|
2862 |
if ( type.indexOf( "." ) >= 0 ) { |
2863 |
// Namespaced trigger; create a regexp to match event type in handle() |
2864 |
namespaces = type.split("."); |
2865 |
type = namespaces.shift(); |
2866 |
namespaces.sort(); |
2867 |
} |
2868 |
|
2869 |
if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) { |
2870 |
// No jQuery handlers for this event type, and it can't have inline handlers |
2871 |
return; |
2872 |
} |
2873 |
|
2874 |
// Caller can pass in an Event, Object, or just an event type string |
2875 |
event = typeof event === "object" ? |
2876 |
// jQuery.Event object |
2877 |
event[ jQuery.expando ] ? event : |
2878 |
// Object literal |
2879 |
new jQuery.Event( type, event ) : |
2880 |
// Just the event type (string) |
2881 |
new jQuery.Event( type ); |
2882 |
|
2883 |
event.type = type; |
2884 |
event.isTrigger = true; |
2885 |
event.exclusive = exclusive; |
2886 |
event.namespace = namespaces.join( "." ); |
2887 |
event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)") : null; |
2888 |
ontype = type.indexOf( ":" ) < 0 ? "on" + type : ""; |
2889 |
|
2890 |
// Handle a global trigger |
2891 |
if ( !elem ) { |
2892 |
|
2893 |
// TODO: Stop taunting the data cache; remove global events and always attach to document |
2894 |
cache = jQuery.cache; |
2895 |
for ( i in cache ) { |
2896 |
if ( cache[ i ].events && cache[ i ].events[ type ] ) { |
2897 |
jQuery.event.trigger( event, data, cache[ i ].handle.elem, true ); |
2898 |
} |
2899 |
} |
2900 |
return; |
2901 |
} |
2902 |
|
2903 |
// Clean up the event in case it is being reused |
2904 |
event.result = undefined; |
2905 |
if ( !event.target ) { |
2906 |
event.target = elem; |
2907 |
} |
2908 |
|
2909 |
// Clone any incoming data and prepend the event, creating the handler arg list |
2910 |
data = data != null ? jQuery.makeArray( data ) : []; |
2911 |
data.unshift( event ); |
2912 |
|
2913 |
// Allow special events to draw outside the lines |
2914 |
special = jQuery.event.special[ type ] || {}; |
2915 |
if ( special.trigger && special.trigger.apply( elem, data ) === false ) { |
2916 |
return; |
2917 |
} |
2918 |
|
2919 |
// Determine event propagation path in advance, per W3C events spec (#9951) |
2920 |
// Bubble up to document, then to window; watch for a global ownerDocument var (#9724) |
2921 |
eventPath = [[ elem, special.bindType || type ]]; |
2922 |
if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { |
2923 |
|
2924 |
bubbleType = special.delegateType || type; |
2925 |
cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode; |
2926 |
for ( old = elem; cur; cur = cur.parentNode ) { |
2927 |
eventPath.push([ cur, bubbleType ]); |
2928 |
old = cur; |
2929 |
} |
2930 |
|
2931 |
// Only add window if we got to document (e.g., not plain obj or detached DOM) |
2932 |
if ( old === (elem.ownerDocument || document) ) { |
2933 |
eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]); |
2934 |
} |
2935 |
} |
2936 |
|
2937 |
// Fire handlers on the event path |
2938 |
for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) { |
2939 |
|
2940 |
cur = eventPath[i][0]; |
2941 |
event.type = eventPath[i][1]; |
2942 |
|
2943 |
handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" ); |
2944 |
if ( handle ) { |
2945 |
handle.apply( cur, data ); |
2946 |
} |
2947 |
// Note that this is a bare JS function and not a jQuery handler |
2948 |
handle = ontype && cur[ ontype ]; |
2949 |
if ( handle && jQuery.acceptData( cur ) && handle.apply( cur, data ) === false ) { |
2950 |
event.preventDefault(); |
2951 |
} |
2952 |
} |
2953 |
event.type = type; |
2954 |
|
2955 |
// If nobody prevented the default action, do it now |
2956 |
if ( !onlyHandlers && !event.isDefaultPrevented() ) { |
2957 |
|
2958 |
if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) && |
2959 |
!(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) { |
2960 |
|
2961 |
// Call a native DOM method on the target with the same name name as the event. |
2962 |
// Can't use an .isFunction() check here because IE6/7 fails that test. |
2963 |
// Don't do default actions on window, that's where global variables be (#6170) |
2964 |
// IE<9 dies on focus/blur to hidden element (#1486) |
2965 |
if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) { |
2966 |
|
2967 |
// Don't re-trigger an onFOO event when we call its FOO() method |
2968 |
old = elem[ ontype ]; |
2969 |
|
2970 |
if ( old ) { |
2971 |
elem[ ontype ] = null; |
2972 |
} |
2973 |
|
2974 |
// Prevent re-triggering of the same event, since we already bubbled it above |
2975 |
jQuery.event.triggered = type; |
2976 |
elem[ type ](); |
2977 |
jQuery.event.triggered = undefined; |
2978 |
|
2979 |
if ( old ) { |
2980 |
elem[ ontype ] = old; |
2981 |
} |
2982 |
} |
2983 |
} |
2984 |
} |
2985 |
|
2986 |
return event.result; |
2987 |
}, |
2988 |
|
2989 |
dispatch: function( event ) { |
2990 |
|
2991 |
// Make a writable jQuery.Event from the native event object |
2992 |
event = jQuery.event.fix( event || window.event ); |
2993 |
|
2994 |
var i, j, cur, ret, selMatch, matched, matches, handleObj, sel, related, |
2995 |
handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []), |
2996 |
delegateCount = handlers.delegateCount, |
2997 |
args = [].slice.call( arguments ), |
2998 |
run_all = !event.exclusive && !event.namespace, |
2999 |
special = jQuery.event.special[ event.type ] || {}, |
3000 |
handlerQueue = []; |
3001 |
|
3002 |
// Use the fix-ed jQuery.Event rather than the (read-only) native event |
3003 |
args[0] = event; |
3004 |
event.delegateTarget = this; |
3005 |
|
3006 |
// Call the preDispatch hook for the mapped type, and let it bail if desired |
3007 |
if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { |
3008 |
return; |
3009 |
} |
3010 |
|
3011 |
// Determine handlers that should run if there are delegated events |
3012 |
// Avoid non-left-click bubbling in Firefox (#3861) |
3013 |
if ( delegateCount && !(event.button && event.type === "click") ) { |
3014 |
|
3015 |
for ( cur = event.target; cur != this; cur = cur.parentNode || this ) { |
3016 |
|
3017 |
// Don't process clicks (ONLY) on disabled elements (#6911, #8165, #11382, #11764) |
3018 |
if ( cur.disabled !== true || event.type !== "click" ) { |
3019 |
selMatch = {}; |
3020 |
matches = []; |
3021 |
for ( i = 0; i < delegateCount; i++ ) { |
3022 |
handleObj = handlers[ i ]; |
3023 |
sel = handleObj.selector; |
3024 |
|
3025 |
if ( selMatch[ sel ] === undefined ) { |
3026 |
selMatch[ sel ] = jQuery( sel, this ).index( cur ) >= 0; |
3027 |
} |
3028 |
if ( selMatch[ sel ] ) { |
3029 |
matches.push( handleObj ); |
3030 |
} |
3031 |
} |
3032 |
if ( matches.length ) { |
3033 |
handlerQueue.push({ elem: cur, matches: matches }); |
3034 |
} |
3035 |
} |
3036 |
} |
3037 |
} |
3038 |
|
3039 |
// Add the remaining (directly-bound) handlers |
3040 |
if ( handlers.length > delegateCount ) { |
3041 |
handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) }); |
3042 |
} |
3043 |
|
3044 |
// Run delegates first; they may want to stop propagation beneath us |
3045 |
for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) { |
3046 |
matched = handlerQueue[ i ]; |
3047 |
event.currentTarget = matched.elem; |
3048 |
|
3049 |
for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) { |
3050 |
handleObj = matched.matches[ j ]; |
3051 |
|
3052 |
// Triggered event must either 1) be non-exclusive and have no namespace, or |
3053 |
// 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). |
3054 |
if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) { |
3055 |
|
3056 |
event.data = handleObj.data; |
3057 |
event.handleObj = handleObj; |
3058 |
|
3059 |
ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) |
3060 |
.apply( matched.elem, args ); |
3061 |
|
3062 |
if ( ret !== undefined ) { |
3063 |
event.result = ret; |
3064 |
if ( ret === false ) { |
3065 |
event.preventDefault(); |
3066 |
event.stopPropagation(); |
3067 |
} |
3068 |
} |
3069 |
} |
3070 |
} |
3071 |
} |
3072 |
|
3073 |
// Call the postDispatch hook for the mapped type |
3074 |
if ( special.postDispatch ) { |
3075 |
special.postDispatch.call( this, event ); |
3076 |
} |
3077 |
|
3078 |
return event.result; |
3079 |
}, |
3080 |
|
3081 |
// Includes some event props shared by KeyEvent and MouseEvent |
3082 |
// *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 *** |
3083 |
props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), |
3084 |
|
3085 |
fixHooks: {}, |
3086 |
|
3087 |
keyHooks: { |
3088 |
props: "char charCode key keyCode".split(" "), |
3089 |
filter: function( event, original ) { |
3090 |
|
3091 |
// Add which for key events |
3092 |
if ( event.which == null ) { |
3093 |
event.which = original.charCode != null ? original.charCode : original.keyCode; |
3094 |
} |
3095 |
|
3096 |
return event; |
3097 |
} |
3098 |
}, |
3099 |
|
3100 |
mouseHooks: { |
3101 |
props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "), |
3102 |
filter: function( event, original ) { |
3103 |
var eventDoc, doc, body, |
3104 |
button = original.button, |
3105 |
fromElement = original.fromElement; |
3106 |
|
3107 |
// Calculate pageX/Y if missing and clientX/Y available |
3108 |
if ( event.pageX == null && original.clientX != null ) { |
3109 |
eventDoc = event.target.ownerDocument || document; |
3110 |
doc = eventDoc.documentElement; |
3111 |
body = eventDoc.body; |
3112 |
|
3113 |
event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); |
3114 |
event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); |
3115 |
} |
3116 |
|
3117 |
// Add relatedTarget, if necessary |
3118 |
if ( !event.relatedTarget && fromElement ) { |
3119 |
event.relatedTarget = fromElement === event.target ? original.toElement : fromElement; |
3120 |
} |
3121 |
|
3122 |
// Add which for click: 1 === left; 2 === middle; 3 === right |
3123 |
// Note: button is not normalized, so don't use it |
3124 |
if ( !event.which && button !== undefined ) { |
3125 |
event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); |
3126 |
} |
3127 |
|
3128 |
return event; |
3129 |
} |
3130 |
}, |
3131 |
|
3132 |
fix: function( event ) { |
3133 |
if ( event[ jQuery.expando ] ) { |
3134 |
return event; |
3135 |
} |
3136 |
|
3137 |
// Create a writable copy of the event object and normalize some properties |
3138 |
var i, prop, |
3139 |
originalEvent = event, |
3140 |
fixHook = jQuery.event.fixHooks[ event.type ] || {}, |
3141 |
copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; |
3142 |
|
3143 |
event = jQuery.Event( originalEvent ); |
3144 |
|
3145 |
for ( i = copy.length; i; ) { |
3146 |
prop = copy[ --i ]; |
3147 |
event[ prop ] = originalEvent[ prop ]; |
3148 |
} |
3149 |
|
3150 |
// Fix target property, if necessary (#1925, IE 6/7/8 & Safari2) |
3151 |
if ( !event.target ) { |
3152 |
event.target = originalEvent.srcElement || document; |
3153 |
} |
3154 |
|
3155 |
// Target should not be a text node (#504, Safari) |
3156 |
if ( event.target.nodeType === 3 ) { |
3157 |
event.target = event.target.parentNode; |
3158 |
} |
3159 |
|
3160 |
// For mouse/key events, metaKey==false if it's undefined (#3368, #11328; IE6/7/8) |
3161 |
event.metaKey = !!event.metaKey; |
3162 |
|
3163 |
return fixHook.filter? fixHook.filter( event, originalEvent ) : event; |
3164 |
}, |
3165 |
|
3166 |
special: { |
3167 |
load: { |
3168 |
// Prevent triggered image.load events from bubbling to window.load |
3169 |
noBubble: true |
3170 |
}, |
3171 |
|
3172 |
focus: { |
3173 |
delegateType: "focusin" |
3174 |
}, |
3175 |
blur: { |
3176 |
delegateType: "focusout" |
3177 |
}, |
3178 |
|
3179 |
beforeunload: { |
3180 |
setup: function( data, namespaces, eventHandle ) { |
3181 |
// We only want to do this special case on windows |
3182 |
if ( jQuery.isWindow( this ) ) { |
3183 |
this.onbeforeunload = eventHandle; |
3184 |
} |
3185 |
}, |
3186 |
|
3187 |
teardown: function( namespaces, eventHandle ) { |
3188 |
if ( this.onbeforeunload === eventHandle ) { |
3189 |
this.onbeforeunload = null; |
3190 |
} |
3191 |
} |
3192 |
} |
3193 |
}, |
3194 |
|
3195 |
simulate: function( type, elem, event, bubble ) { |
3196 |
// Piggyback on a donor event to simulate a different one. |
3197 |
// Fake originalEvent to avoid donor's stopPropagation, but if the |
3198 |
// simulated event prevents default then we do the same on the donor. |
3199 |
var e = jQuery.extend( |
3200 |
new jQuery.Event(), |
3201 |
event, |
3202 |
{ type: type, |
3203 |
isSimulated: true, |
3204 |
originalEvent: {} |
3205 |
} |
3206 |
); |
3207 |
if ( bubble ) { |
3208 |
jQuery.event.trigger( e, null, elem ); |
3209 |
} else { |
3210 |
jQuery.event.dispatch.call( elem, e ); |
3211 |
} |
3212 |
if ( e.isDefaultPrevented() ) { |
3213 |
event.preventDefault(); |
3214 |
} |
3215 |
} |
3216 |
}; |
3217 |
|
3218 |
// Some plugins are using, but it's undocumented/deprecated and will be removed. |
3219 |
// The 1.7 special event interface should provide all the hooks needed now. |
3220 |
jQuery.event.handle = jQuery.event.dispatch; |
3221 |
|
3222 |
jQuery.removeEvent = document.removeEventListener ? |
3223 |
function( elem, type, handle ) { |
3224 |
if ( elem.removeEventListener ) { |
3225 |
elem.removeEventListener( type, handle, false ); |
3226 |
} |
3227 |
} : |
3228 |
function( elem, type, handle ) { |
3229 |
var name = "on" + type; |
3230 |
|
3231 |
if ( elem.detachEvent ) { |
3232 |
|
3233 |
// #8545, #7054, preventing memory leaks for custom events in IE6-8 – |
3234 |
// detachEvent needed property on element, by name of that event, to properly expose it to GC |
3235 |
if ( typeof elem[ name ] === "undefined" ) { |
3236 |
elem[ name ] = null; |
3237 |
} |
3238 |
|
3239 |
elem.detachEvent( name, handle ); |
3240 |
} |
3241 |
}; |
3242 |
|
3243 |
jQuery.Event = function( src, props ) { |
3244 |
// Allow instantiation without the 'new' keyword |
3245 |
if ( !(this instanceof jQuery.Event) ) { |
3246 |
return new jQuery.Event( src, props ); |
3247 |
} |
3248 |
|
3249 |
// Event object |
3250 |
if ( src && src.type ) { |
3251 |
this.originalEvent = src; |
3252 |
this.type = src.type; |
3253 |
|
3254 |
// Events bubbling up the document may have been marked as prevented |
3255 |
// by a handler lower down the tree; reflect the correct value. |
3256 |
this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false || |
3257 |
src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse; |
3258 |
|
3259 |
// Event type |
3260 |
} else { |
3261 |
this.type = src; |
3262 |
} |
3263 |
|
3264 |
// Put explicitly provided properties onto the event object |
3265 |
if ( props ) { |
3266 |
jQuery.extend( this, props ); |
3267 |
} |
3268 |
|
3269 |
// Create a timestamp if incoming event doesn't have one |
3270 |
this.timeStamp = src && src.timeStamp || jQuery.now(); |
3271 |
|
3272 |
// Mark it as fixed |
3273 |
this[ jQuery.expando ] = true; |
3274 |
}; |
3275 |
|
3276 |
function returnFalse() { |
3277 |
return false; |
3278 |
} |
3279 |
function returnTrue() { |
3280 |
return true; |
3281 |
} |
3282 |
|
3283 |
// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding |
3284 |
// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html |
3285 |
jQuery.Event.prototype = { |
3286 |
preventDefault: function() { |
3287 |
this.isDefaultPrevented = returnTrue; |
3288 |
|
3289 |
var e = this.originalEvent; |
3290 |
if ( !e ) { |
3291 |
return; |
3292 |
} |
3293 |
|
3294 |
// if preventDefault exists run it on the original event |
3295 |
if ( e.preventDefault ) { |
3296 |
e.preventDefault(); |
3297 |
|
3298 |
// otherwise set the returnValue property of the original event to false (IE) |
3299 |
} else { |
3300 |
e.returnValue = false; |
3301 |
} |
3302 |
}, |
3303 |
stopPropagation: function() { |
3304 |
this.isPropagationStopped = returnTrue; |
3305 |
|
3306 |
var e = this.originalEvent; |
3307 |
if ( !e ) { |
3308 |
return; |
3309 |
} |
3310 |
// if stopPropagation exists run it on the original event |
3311 |
if ( e.stopPropagation ) { |
3312 |
e.stopPropagation(); |
3313 |
} |
3314 |
// otherwise set the cancelBubble property of the original event to true (IE) |
3315 |
e.cancelBubble = true; |
3316 |
}, |
3317 |
stopImmediatePropagation: function() { |
3318 |
this.isImmediatePropagationStopped = returnTrue; |
3319 |
this.stopPropagation(); |
3320 |
}, |
3321 |
isDefaultPrevented: returnFalse, |
3322 |
isPropagationStopped: returnFalse, |
3323 |
isImmediatePropagationStopped: returnFalse |
3324 |
}; |
3325 |
|
3326 |
// Create mouseenter/leave events using mouseover/out and event-time checks |
3327 |
jQuery.each({ |
3328 |
mouseenter: "mouseover", |
3329 |
mouseleave: "mouseout" |
3330 |
}, function( orig, fix ) { |
3331 |
jQuery.event.special[ orig ] = { |
3332 |
delegateType: fix, |
3333 |
bindType: fix, |
3334 |
|
3335 |
handle: function( event ) { |
3336 |
var ret, |
3337 |
target = this, |
3338 |
related = event.relatedTarget, |
3339 |
handleObj = event.handleObj, |
3340 |
selector = handleObj.selector; |
3341 |
|
3342 |
// For mousenter/leave call the handler if related is outside the target. |
3343 |
// NB: No relatedTarget if the mouse left/entered the browser window |
3344 |
if ( !related || (related !== target && !jQuery.contains( target, related )) ) { |
3345 |
event.type = handleObj.origType; |
3346 |
ret = handleObj.handler.apply( this, arguments ); |
3347 |
event.type = fix; |
3348 |
} |
3349 |
return ret; |
3350 |
} |
3351 |
}; |
3352 |
}); |
3353 |
|
3354 |
// IE submit delegation |
3355 |
if ( !jQuery.support.submitBubbles ) { |
3356 |
|
3357 |
jQuery.event.special.submit = { |
3358 |
setup: function() { |
3359 |
// Only need this for delegated form submit events |
3360 |
if ( jQuery.nodeName( this, "form" ) ) { |
3361 |
return false; |
3362 |
} |
3363 |
|
3364 |
// Lazy-add a submit handler when a descendant form may potentially be submitted |
3365 |
jQuery.event.add( this, "click._submit keypress._submit", function( e ) { |
3366 |
// Node name check avoids a VML-related crash in IE (#9807) |
3367 |
var elem = e.target, |
3368 |
form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined; |
3369 |
if ( form && !jQuery._data( form, "_submit_attached" ) ) { |
3370 |
jQuery.event.add( form, "submit._submit", function( event ) { |
3371 |
event._submit_bubble = true; |
3372 |
}); |
3373 |
jQuery._data( form, "_submit_attached", true ); |
3374 |
} |
3375 |
}); |
3376 |
// return undefined since we don't need an event listener |
3377 |
}, |
3378 |
|
3379 |
postDispatch: function( event ) { |
3380 |
// If form was submitted by the user, bubble the event up the tree |
3381 |
if ( event._submit_bubble ) { |
3382 |
delete event._submit_bubble; |
3383 |
if ( this.parentNode && !event.isTrigger ) { |
3384 |
jQuery.event.simulate( "submit", this.parentNode, event, true ); |
3385 |
} |
3386 |
} |
3387 |
}, |
3388 |
|
3389 |
teardown: function() { |
3390 |
// Only need this for delegated form submit events |
3391 |
if ( jQuery.nodeName( this, "form" ) ) { |
3392 |
return false; |
3393 |
} |
3394 |
|
3395 |
// Remove delegated handlers; cleanData eventually reaps submit handlers attached above |
3396 |
jQuery.event.remove( this, "._submit" ); |
3397 |
} |
3398 |
}; |
3399 |
} |
3400 |
|
3401 |
// IE change delegation and checkbox/radio fix |
3402 |
if ( !jQuery.support.changeBubbles ) { |
3403 |
|
3404 |
jQuery.event.special.change = { |
3405 |
|
3406 |
setup: function() { |
3407 |
|
3408 |
if ( rformElems.test( this.nodeName ) ) { |
3409 |
// IE doesn't fire change on a check/radio until blur; trigger it on click |
3410 |
// after a propertychange. Eat the blur-change in special.change.handle. |
3411 |
// This still fires onchange a second time for check/radio after blur. |
3412 |
if ( this.type === "checkbox" || this.type === "radio" ) { |
3413 |
jQuery.event.add( this, "propertychange._change", function( event ) { |
3414 |
if ( event.originalEvent.propertyName === "checked" ) { |
3415 |
this._just_changed = true; |
3416 |
} |
3417 |
}); |
3418 |
jQuery.event.add( this, "click._change", function( event ) { |
3419 |
if ( this._just_changed && !event.isTrigger ) { |
3420 |
this._just_changed = false; |
3421 |
} |
3422 |
// Allow triggered, simulated change events (#11500) |
3423 |
jQuery.event.simulate( "change", this, event, true ); |
3424 |
}); |
3425 |
} |
3426 |
return false; |
3427 |
} |
3428 |
// Delegated event; lazy-add a change handler on descendant inputs |
3429 |
jQuery.event.add( this, "beforeactivate._change", function( e ) { |
3430 |
var elem = e.target; |
3431 |
|
3432 |
if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "_change_attached" ) ) { |
3433 |
jQuery.event.add( elem, "change._change", function( event ) { |
3434 |
if ( this.parentNode && !event.isSimulated && !event.isTrigger ) { |
3435 |
jQuery.event.simulate( "change", this.parentNode, event, true ); |
3436 |
} |
3437 |
}); |
3438 |
jQuery._data( elem, "_change_attached", true ); |
3439 |
} |
3440 |
}); |
3441 |
}, |
3442 |
|
3443 |
handle: function( event ) { |
3444 |
var elem = event.target; |
3445 |
|
3446 |
// Swallow native change events from checkbox/radio, we already triggered them above |
3447 |
if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) { |
3448 |
return event.handleObj.handler.apply( this, arguments ); |
3449 |
} |
3450 |
}, |
3451 |
|
3452 |
teardown: function() { |
3453 |
jQuery.event.remove( this, "._change" ); |
3454 |
|
3455 |
return !rformElems.test( this.nodeName ); |
3456 |
} |
3457 |
}; |
3458 |
} |
3459 |
|
3460 |
// Create "bubbling" focus and blur events |
3461 |
if ( !jQuery.support.focusinBubbles ) { |
3462 |
jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { |
3463 |
|
3464 |
// Attach a single capturing handler while someone wants focusin/focusout |
3465 |
var attaches = 0, |
3466 |
handler = function( event ) { |
3467 |
jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); |
3468 |
}; |
3469 |
|
3470 |
jQuery.event.special[ fix ] = { |
3471 |
setup: function() { |
3472 |
if ( attaches++ === 0 ) { |
3473 |
document.addEventListener( orig, handler, true ); |
3474 |
} |
3475 |
}, |
3476 |
teardown: function() { |
3477 |
if ( --attaches === 0 ) { |
3478 |
document.removeEventListener( orig, handler, true ); |
3479 |
} |
3480 |
} |
3481 |
}; |
3482 |
}); |
3483 |
} |
3484 |
|
3485 |
jQuery.fn.extend({ |
3486 |
|
3487 |
on: function( types, selector, data, fn, /*INTERNAL*/ one ) { |
3488 |
var origFn, type; |
3489 |
|
3490 |
// Types can be a map of types/handlers |
3491 |
if ( typeof types === "object" ) { |
3492 |
// ( types-Object, selector, data ) |
3493 |
if ( typeof selector !== "string" ) { // && selector != null |
3494 |
// ( types-Object, data ) |
3495 |
data = data || selector; |
3496 |
selector = undefined; |
3497 |
} |
3498 |
for ( type in types ) { |
3499 |
this.on( type, selector, data, types[ type ], one ); |
3500 |
} |
3501 |
return this; |
3502 |
} |
3503 |
|
3504 |
if ( data == null && fn == null ) { |
3505 |
// ( types, fn ) |
3506 |
fn = selector; |
3507 |
data = selector = undefined; |
3508 |
} else if ( fn == null ) { |
3509 |
if ( typeof selector === "string" ) { |
3510 |
// ( types, selector, fn ) |
3511 |
fn = data; |
3512 |
data = undefined; |
3513 |
} else { |
3514 |
// ( types, data, fn ) |
3515 |
fn = data; |
3516 |
data = selector; |
3517 |
selector = undefined; |
3518 |
} |
3519 |
} |
3520 |
if ( fn === false ) { |
3521 |
fn = returnFalse; |
3522 |
} else if ( !fn ) { |
3523 |
return this; |
3524 |
} |
3525 |
|
3526 |
if ( one === 1 ) { |
3527 |
origFn = fn; |
3528 |
fn = function( event ) { |
3529 |
// Can use an empty set, since event contains the info |
3530 |
jQuery().off( event ); |
3531 |
return origFn.apply( this, arguments ); |
3532 |
}; |
3533 |
// Use same guid so caller can remove using origFn |
3534 |
fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); |
3535 |
} |
3536 |
return this.each( function() { |
3537 |
jQuery.event.add( this, types, fn, data, selector ); |
3538 |
}); |
3539 |
}, |
3540 |
one: function( types, selector, data, fn ) { |
3541 |
return this.on( types, selector, data, fn, 1 ); |
3542 |
}, |
3543 |
off: function( types, selector, fn ) { |
3544 |
var handleObj, type; |
3545 |
if ( types && types.preventDefault && types.handleObj ) { |
3546 |
// ( event ) dispatched jQuery.Event |
3547 |
handleObj = types.handleObj; |
3548 |
jQuery( types.delegateTarget ).off( |
3549 |
handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, |
3550 |
handleObj.selector, |
3551 |
handleObj.handler |
3552 |
); |
3553 |
return this; |
3554 |
} |
3555 |
if ( typeof types === "object" ) { |
3556 |
// ( types-object [, selector] ) |
3557 |
for ( type in types ) { |
3558 |
this.off( type, selector, types[ type ] ); |
3559 |
} |
3560 |
return this; |
3561 |
} |
3562 |
if ( selector === false || typeof selector === "function" ) { |
3563 |
// ( types [, fn] ) |
3564 |
fn = selector; |
3565 |
selector = undefined; |
3566 |
} |
3567 |
if ( fn === false ) { |
3568 |
fn = returnFalse; |
3569 |
} |
3570 |
return this.each(function() { |
3571 |
jQuery.event.remove( this, types, fn, selector ); |
3572 |
}); |
3573 |
}, |
3574 |
|
3575 |
bind: function( types, data, fn ) { |
3576 |
return this.on( types, null, data, fn ); |
3577 |
}, |
3578 |
unbind: function( types, fn ) { |
3579 |
return this.off( types, null, fn ); |
3580 |
}, |
3581 |
|
3582 |
live: function( types, data, fn ) { |
3583 |
jQuery( this.context ).on( types, this.selector, data, fn ); |
3584 |
return this; |
3585 |
}, |
3586 |
die: function( types, fn ) { |
3587 |
jQuery( this.context ).off( types, this.selector || "**", fn ); |
3588 |
return this; |
3589 |
}, |
3590 |
|
3591 |
delegate: function( selector, types, data, fn ) { |
3592 |
return this.on( types, selector, data, fn ); |
3593 |
}, |
3594 |
undelegate: function( selector, types, fn ) { |
3595 |
// ( namespace ) or ( selector, types [, fn] ) |
3596 |
return arguments.length == 1? this.off( selector, "**" ) : this.off( types, selector || "**", fn ); |
3597 |
}, |
3598 |
|
3599 |
trigger: function( type, data ) { |
3600 |
return this.each(function() { |
3601 |
jQuery.event.trigger( type, data, this ); |
3602 |
}); |
3603 |
}, |
3604 |
triggerHandler: function( type, data ) { |
3605 |
if ( this[0] ) { |
3606 |
return jQuery.event.trigger( type, data, this[0], true ); |
3607 |
} |
3608 |
}, |
3609 |
|
3610 |
toggle: function( fn ) { |
3611 |
// Save reference to arguments for access in closure |
3612 |
var args = arguments, |
3613 |
guid = fn.guid || jQuery.guid++, |
3614 |
i = 0, |
3615 |
toggler = function( event ) { |
3616 |
// Figure out which function to execute |
3617 |
var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i; |
3618 |
jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 ); |
3619 |
|
3620 |
// Make sure that clicks stop |
3621 |
event.preventDefault(); |
3622 |
|
3623 |
// and execute the function |
3624 |
return args[ lastToggle ].apply( this, arguments ) || false; |
3625 |
}; |
3626 |
|
3627 |
// link all the functions, so any of them can unbind this click handler |
3628 |
toggler.guid = guid; |
3629 |
while ( i < args.length ) { |
3630 |
args[ i++ ].guid = guid; |
3631 |
} |
3632 |
|
3633 |
return this.click( toggler ); |
3634 |
}, |
3635 |
|
3636 |
hover: function( fnOver, fnOut ) { |
3637 |
return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); |
3638 |
} |
3639 |
}); |
3640 |
|
3641 |
jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + |
3642 |
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + |
3643 |
"change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) { |
3644 |
|
3645 |
// Handle event binding |
3646 |
jQuery.fn[ name ] = function( data, fn ) { |
3647 |
if ( fn == null ) { |
3648 |
fn = data; |
3649 |
data = null; |
3650 |
} |
3651 |
|
3652 |
return arguments.length > 0 ? |
3653 |
this.on( name, null, data, fn ) : |
3654 |
this.trigger( name ); |
3655 |
}; |
3656 |
|
3657 |
if ( rkeyEvent.test( name ) ) { |
3658 |
jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks; |
3659 |
} |
3660 |
|
3661 |
if ( rmouseEvent.test( name ) ) { |
3662 |
jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks; |
3663 |
} |
3664 |
}); |
3665 |
/*! |
3666 |
* Sizzle CSS Selector Engine |
3667 |
* Copyright 2012 jQuery Foundation and other contributors |
3668 |
* Released under the MIT license |
3669 |
* http://sizzlejs.com/ |
3670 |
*/ |
3671 |
(function( window, undefined ) { |
3672 |
|
3673 |
var dirruns, |
3674 |
cachedruns, |
3675 |
assertGetIdNotName, |
3676 |
Expr, |
3677 |
getText, |
3678 |
isXML, |
3679 |
contains, |
3680 |
compile, |
3681 |
sortOrder, |
3682 |
hasDuplicate, |
3683 |
|
3684 |
baseHasDuplicate = true, |
3685 |
strundefined = "undefined", |
3686 |
|
3687 |
expando = ( "sizcache" + Math.random() ).replace( ".", "" ), |
3688 |
|
3689 |
document = window.document, |
3690 |
docElem = document.documentElement, |
3691 |
done = 0, |
3692 |
slice = [].slice, |
3693 |
push = [].push, |
3694 |
|
3695 |
// Augment a function for special use by Sizzle |
3696 |
markFunction = function( fn, value ) { |
3697 |
fn[ expando ] = value || true; |
3698 |
return fn; |
3699 |
}, |
3700 |
|
3701 |
createCache = function() { |
3702 |
var cache = {}, |
3703 |
keys = []; |
3704 |
|
3705 |
return markFunction(function( key, value ) { |
3706 |
// Only keep the most recent entries |
3707 |
if ( keys.push( key ) > Expr.cacheLength ) { |
3708 |
delete cache[ keys.shift() ]; |
3709 |
} |
3710 |
|
3711 |
return (cache[ key ] = value); |
3712 |
}, cache ); |
3713 |
}, |
3714 |
|
3715 |
classCache = createCache(), |
3716 |
tokenCache = createCache(), |
3717 |
compilerCache = createCache(), |
3718 |
|
3719 |
// Regex |
3720 |
|
3721 |
// Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace |
3722 |
whitespace = "[\\x20\\t\\r\\n\\f]", |
3723 |
// http://www.w3.org/TR/css3-syntax/#characters |
3724 |
characterEncoding = "(?:\\\\.|[-\\w]|[^\\x00-\\xa0])+", |
3725 |
|
3726 |
// Loosely modeled on CSS identifier characters |
3727 |
// An unquoted value should be a CSS identifier (http://www.w3.org/TR/css3-selectors/#attribute-selectors) |
3728 |
// Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier |
3729 |
identifier = characterEncoding.replace( "w", "w#" ), |
3730 |
|
3731 |
// Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors |
3732 |
operators = "([*^$|!~]?=)", |
3733 |
attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace + |
3734 |
"*(?:" + operators + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]", |
3735 |
|
3736 |
// Prefer arguments not in parens/brackets, |
3737 |
// then attribute selectors and non-pseudos (denoted by :), |
3738 |
// then anything else |
3739 |
// These preferences are here to reduce the number of selectors |
3740 |
// needing tokenize in the PSEUDO preFilter |
3741 |
pseudos = ":(" + characterEncoding + ")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|([^()[\\]]*|(?:(?:" + attributes + ")|[^:]|\\\\.)*|.*))\\)|)", |
3742 |
|
3743 |
// For matchExpr.POS and matchExpr.needsContext |
3744 |
pos = ":(nth|eq|gt|lt|first|last|even|odd)(?:\\(((?:-\\d)?\\d*)\\)|)(?=[^-]|$)", |
3745 |
|
3746 |
// Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter |
3747 |
rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), |
3748 |
|
3749 |
rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), |
3750 |
rcombinators = new RegExp( "^" + whitespace + "*([\\x20\\t\\r\\n\\f>+~])" + whitespace + "*" ), |
3751 |
rpseudo = new RegExp( pseudos ), |
3752 |
|
3753 |
// Easily-parseable/retrievable ID or TAG or CLASS selectors |
3754 |
rquickExpr = /^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/, |
3755 |
|
3756 |
rnot = /^:not/, |
3757 |
rsibling = /[\x20\t\r\n\f]*[+~]/, |
3758 |
rendsWithNot = /:not\($/, |
3759 |
|
3760 |
rheader = /h\d/i, |
3761 |
rinputs = /input|select|textarea|button/i, |
3762 |
|
3763 |
rbackslash = /\\(?!\\)/g, |
3764 |
|
3765 |
matchExpr = { |
3766 |
"ID": new RegExp( "^#(" + characterEncoding + ")" ), |
3767 |
"CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ), |
3768 |
"NAME": new RegExp( "^\\[name=['\"]?(" + characterEncoding + ")['\"]?\\]" ), |
3769 |
"TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ), |
3770 |
"ATTR": new RegExp( "^" + attributes ), |
3771 |
"PSEUDO": new RegExp( "^" + pseudos ), |
3772 |
"CHILD": new RegExp( "^:(only|nth|last|first)-child(?:\\(" + whitespace + |
3773 |
"*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + |
3774 |
"*(\\d+)|))" + whitespace + "*\\)|)", "i" ), |
3775 |
"POS": new RegExp( pos, "ig" ), |
3776 |
// For use in libraries implementing .is() |
3777 |
"needsContext": new RegExp( "^" + whitespace + "*[>+~]|" + pos, "i" ) |
3778 |
}, |
3779 |
|
3780 |
// Support |
3781 |
|
3782 |
// Used for testing something on an element |
3783 |
assert = function( fn ) { |
3784 |
var div = document.createElement("div"); |
3785 |
|
3786 |
try { |
3787 |
return fn( div ); |
3788 |
} catch (e) { |
3789 |
return false; |
3790 |
} finally { |
3791 |
// release memory in IE |
3792 |
div = null; |
3793 |
} |
3794 |
}, |
3795 |
|
3796 |
// Check if getElementsByTagName("*") returns only elements |
3797 |
assertTagNameNoComments = assert(function( div ) { |
3798 |
div.appendChild( document.createComment("") ); |
3799 |
return !div.getElementsByTagName("*").length; |
3800 |
}), |
3801 |
|
3802 |
// Check if getAttribute returns normalized href attributes |
3803 |
assertHrefNotNormalized = assert(function( div ) { |
3804 |
div.innerHTML = "<a href='#'></a>"; |
3805 |
return div.firstChild && typeof div.firstChild.getAttribute !== strundefined && |
3806 |
div.firstChild.getAttribute("href") === "#"; |
3807 |
}), |
3808 |
|
3809 |
// Check if attributes should be retrieved by attribute nodes |
3810 |
assertAttributes = assert(function( div ) { |
3811 |
div.innerHTML = "<select></select>"; |
3812 |
var type = typeof div.lastChild.getAttribute("multiple"); |
3813 |
// IE8 returns a string for some attributes even when not present |
3814 |
return type !== "boolean" && type !== "string"; |
3815 |
}), |
3816 |
|
3817 |
// Check if getElementsByClassName can be trusted |
3818 |
assertUsableClassName = assert(function( div ) { |
3819 |
// Opera can't find a second classname (in 9.6) |
3820 |
div.innerHTML = "<div class='hidden e'></div><div class='hidden'></div>"; |
3821 |
if ( !div.getElementsByClassName || !div.getElementsByClassName("e").length ) { |
3822 |
return false; |
3823 |
} |
3824 |
|
3825 |
// Safari 3.2 caches class attributes and doesn't catch changes |
3826 |
div.lastChild.className = "e"; |
3827 |
return div.getElementsByClassName("e").length === 2; |
3828 |
}), |
3829 |
|
3830 |
// Check if getElementById returns elements by name |
3831 |
// Check if getElementsByName privileges form controls or returns elements by ID |
3832 |
assertUsableName = assert(function( div ) { |
3833 |
// Inject content |
3834 |
div.id = expando + 0; |
3835 |
div.innerHTML = "<a name='" + expando + "'></a><div name='" + expando + "'></div>"; |
3836 |
docElem.insertBefore( div, docElem.firstChild ); |
3837 |
|
3838 |
// Test |
3839 |
var pass = document.getElementsByName && |
3840 |
// buggy browsers will return fewer than the correct 2 |
3841 |
document.getElementsByName( expando ).length === 2 + |
3842 |
// buggy browsers will return more than the correct 0 |
3843 |
document.getElementsByName( expando + 0 ).length; |
3844 |
assertGetIdNotName = !document.getElementById( expando ); |
3845 |
|
3846 |
// Cleanup |
3847 |
docElem.removeChild( div ); |
3848 |
|
3849 |
return pass; |
3850 |
}); |
3851 |
|
3852 |
// If slice is not available, provide a backup |
3853 |
try { |
3854 |
slice.call( docElem.childNodes, 0 )[0].nodeType; |
3855 |
} catch ( e ) { |
3856 |
slice = function( i ) { |
3857 |
var elem, results = []; |
3858 |
for ( ; (elem = this[i]); i++ ) { |
3859 |
results.push( elem ); |
3860 |
} |
3861 |
return results; |
3862 |
}; |
3863 |
} |
3864 |
|
3865 |
function Sizzle( selector, context, results, seed ) { |
3866 |
results = results || []; |
3867 |
context = context || document; |
3868 |
var match, elem, xml, m, |
3869 |
nodeType = context.nodeType; |
3870 |
|
3871 |
if ( nodeType !== 1 && nodeType !== 9 ) { |
3872 |
return []; |
3873 |
} |
3874 |
|
3875 |
if ( !selector || typeof selector !== "string" ) { |
3876 |
return results; |
3877 |
} |
3878 |
|
3879 |
xml = isXML( context ); |
3880 |
|
3881 |
if ( !xml && !seed ) { |
3882 |
if ( (match = rquickExpr.exec( selector )) ) { |
3883 |
// Speed-up: Sizzle("#ID") |
3884 |
if ( (m = match[1]) ) { |
3885 |
if ( nodeType === 9 ) { |
3886 |
elem = context.getElementById( m ); |
3887 |
// Check parentNode to catch when Blackberry 4.6 returns |
3888 |
// nodes that are no longer in the document #6963 |
3889 |
if ( elem && elem.parentNode ) { |
3890 |
// Handle the case where IE, Opera, and Webkit return items |
3891 |
// by name instead of ID |
3892 |
if ( elem.id === m ) { |
3893 |
results.push( elem ); |
3894 |
return results; |
3895 |
} |
3896 |
} else { |
3897 |
return results; |
3898 |
} |
3899 |
} else { |
3900 |
// Context is not a document |
3901 |
if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) && |
3902 |
contains( context, elem ) && elem.id === m ) { |
3903 |
results.push( elem ); |
3904 |
return results; |
3905 |
} |
3906 |
} |
3907 |
|
3908 |
// Speed-up: Sizzle("TAG") |
3909 |
} else if ( match[2] ) { |
3910 |
push.apply( results, slice.call(context.getElementsByTagName( selector ), 0) ); |
3911 |
return results; |
3912 |
|
3913 |
// Speed-up: Sizzle(".CLASS") |
3914 |
} else if ( (m = match[3]) && assertUsableClassName && context.getElementsByClassName ) { |
3915 |
push.apply( results, slice.call(context.getElementsByClassName( m ), 0) ); |
3916 |
return results; |
3917 |
} |
3918 |
} |
3919 |
} |
3920 |
|
3921 |
// All others |
3922 |
return select( selector, context, results, seed, xml ); |
3923 |
} |
3924 |
|
3925 |
Sizzle.matches = function( expr, elements ) { |
3926 |
return Sizzle( expr, null, null, elements ); |
3927 |
}; |
3928 |
|
3929 |
Sizzle.matchesSelector = function( elem, expr ) { |
3930 |
return Sizzle( expr, null, null, [ elem ] ).length > 0; |
3931 |
}; |
3932 |
|
3933 |
// Returns a function to use in pseudos for input types |
3934 |
function createInputPseudo( type ) { |
3935 |
return function( elem ) { |
3936 |
var name = elem.nodeName.toLowerCase(); |
3937 |
return name === "input" && elem.type === type; |
3938 |
}; |
3939 |
} |
3940 |
|
3941 |
// Returns a function to use in pseudos for buttons |
3942 |
function createButtonPseudo( type ) { |
3943 |
return function( elem ) { |
3944 |
var name = elem.nodeName.toLowerCase(); |
3945 |
return (name === "input" || name === "button") && elem.type === type; |
3946 |
}; |
3947 |
} |
3948 |
|
3949 |
/** |
3950 |
* Utility function for retrieving the text value of an array of DOM nodes |
3951 |
* @param {Array|Element} elem |
3952 |
*/ |
3953 |
getText = Sizzle.getText = function( elem ) { |
3954 |
var node, |
3955 |
ret = "", |
3956 |
i = 0, |
3957 |
nodeType = elem.nodeType; |
3958 |
|
3959 |
if ( nodeType ) { |
3960 |
if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { |
3961 |
// Use textContent for elements |
3962 |
// innerText usage removed for consistency of new lines (see #11153) |
3963 |
if ( typeof elem.textContent === "string" ) { |
3964 |
return elem.textContent; |
3965 |
} else { |
3966 |
// Traverse its children |
3967 |
for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { |
3968 |
ret += getText( elem ); |
3969 |
} |
3970 |
} |
3971 |
} else if ( nodeType === 3 || nodeType === 4 ) { |
3972 |
return elem.nodeValue; |
3973 |
} |
3974 |
// Do not include comment or processing instruction nodes |
3975 |
} else { |
3976 |
|
3977 |
// If no nodeType, this is expected to be an array |
3978 |
for ( ; (node = elem[i]); i++ ) { |
3979 |
// Do not traverse comment nodes |
3980 |
ret += getText( node ); |
3981 |
} |
3982 |
} |
3983 |
return ret; |
3984 |
}; |
3985 |
|
3986 |
isXML = Sizzle.isXML = function isXML( elem ) { |
3987 |
// documentElement is verified for cases where it doesn't yet exist |
3988 |
// (such as loading iframes in IE - #4833) |
3989 |
var documentElement = elem && (elem.ownerDocument || elem).documentElement; |
3990 |
return documentElement ? documentElement.nodeName !== "HTML" : false; |
3991 |
}; |
3992 |
|
3993 |
// Element contains another |
3994 |
contains = Sizzle.contains = docElem.contains ? |
3995 |
function( a, b ) { |
3996 |
var adown = a.nodeType === 9 ? a.documentElement : a, |
3997 |
bup = b && b.parentNode; |
3998 |
return a === bup || !!( bup && bup.nodeType === 1 && adown.contains && adown.contains(bup) ); |
3999 |
} : |
4000 |
docElem.compareDocumentPosition ? |
4001 |
function( a, b ) { |
4002 |
return b && !!( a.compareDocumentPosition( b ) & 16 ); |
4003 |
} : |
4004 |
function( a, b ) { |
4005 |
while ( (b = b.parentNode) ) { |
4006 |
if ( b === a ) { |
4007 |
return true; |
4008 |
} |
4009 |
} |
4010 |
return false; |
4011 |
}; |
4012 |
|
4013 |
Sizzle.attr = function( elem, name ) { |
4014 |
var attr, |
4015 |
xml = isXML( elem ); |
4016 |
|
4017 |
if ( !xml ) { |
4018 |
name = name.toLowerCase(); |
4019 |
} |
4020 |
if ( Expr.attrHandle[ name ] ) { |
4021 |
return Expr.attrHandle[ name ]( elem ); |
4022 |
} |
4023 |
if ( assertAttributes || xml ) { |
4024 |
return elem.getAttribute( name ); |
4025 |
} |
4026 |
attr = elem.getAttributeNode( name ); |
4027 |
return attr ? |
4028 |
typeof elem[ name ] === "boolean" ? |
4029 |
elem[ name ] ? name : null : |
4030 |
attr.specified ? attr.value : null : |
4031 |
null; |
4032 |
}; |
4033 |
|
4034 |
Expr = Sizzle.selectors = { |
4035 |
|
4036 |
// Can be adjusted by the user |
4037 |
cacheLength: 50, |
4038 |
|
4039 |
createPseudo: markFunction, |
4040 |
|
4041 |
match: matchExpr, |
4042 |
|
4043 |
order: new RegExp( "ID|TAG" + |
4044 |
(assertUsableName ? "|NAME" : "") + |
4045 |
(assertUsableClassName ? "|CLASS" : "") |
4046 |
), |
4047 |
|
4048 |
// IE6/7 return a modified href |
4049 |
attrHandle: assertHrefNotNormalized ? |
4050 |
{} : |
4051 |
{ |
4052 |
"href": function( elem ) { |
4053 |
return elem.getAttribute( "href", 2 ); |
4054 |
}, |
4055 |
"type": function( elem ) { |
4056 |
return elem.getAttribute("type"); |
4057 |
} |
4058 |
}, |
4059 |
|
4060 |
find: { |
4061 |
"ID": assertGetIdNotName ? |
4062 |
function( id, context, xml ) { |
4063 |
if ( typeof context.getElementById !== strundefined && !xml ) { |
4064 |
var m = context.getElementById( id ); |
4065 |
// Check parentNode to catch when Blackberry 4.6 returns |
4066 |
// nodes that are no longer in the document #6963 |
4067 |
return m && m.parentNode ? [m] : []; |
4068 |
} |
4069 |
} : |
4070 |
function( id, context, xml ) { |
4071 |
if ( typeof context.getElementById !== strundefined && !xml ) { |
4072 |
var m = context.getElementById( id ); |
4073 |
|
4074 |
return m ? |
4075 |
m.id === id || typeof m.getAttributeNode !== strundefined && m.getAttributeNode("id").value === id ? |
4076 |
[m] : |
4077 |
undefined : |
4078 |
[]; |
4079 |
} |
4080 |
}, |
4081 |
|
4082 |
"TAG": assertTagNameNoComments ? |
4083 |
function( tag, context ) { |
4084 |
if ( typeof context.getElementsByTagName !== strundefined ) { |
4085 |
return context.getElementsByTagName( tag ); |
4086 |
} |
4087 |
} : |
4088 |
function( tag, context ) { |
4089 |
var results = context.getElementsByTagName( tag ); |
4090 |
|
4091 |
// Filter out possible comments |
4092 |
if ( tag === "*" ) { |
4093 |
var elem, |
4094 |
tmp = [], |
4095 |
i = 0; |
4096 |
|
4097 |
for ( ; (elem = results[i]); i++ ) { |
4098 |
if ( elem.nodeType === 1 ) { |
4099 |
tmp.push( elem ); |
4100 |
} |
4101 |
} |
4102 |
|
4103 |
return tmp; |
4104 |
} |
4105 |
return results; |
4106 |
}, |
4107 |
|
4108 |
"NAME": function( tag, context ) { |
4109 |
if ( typeof context.getElementsByName !== strundefined ) { |
4110 |
return context.getElementsByName( name ); |
4111 |
} |
4112 |
}, |
4113 |
|
4114 |
"CLASS": function( className, context, xml ) { |
4115 |
if ( typeof context.getElementsByClassName !== strundefined && !xml ) { |
4116 |
return context.getElementsByClassName( className ); |
4117 |
} |
4118 |
} |
4119 |
}, |
4120 |
|
4121 |
relative: { |
4122 |
">": { dir: "parentNode", first: true }, |
4123 |
" ": { dir: "parentNode" }, |
4124 |
"+": { dir: "previousSibling", first: true }, |
4125 |
"~": { dir: "previousSibling" } |
4126 |
}, |
4127 |
|
4128 |
preFilter: { |
4129 |
"ATTR": function( match ) { |
4130 |
match[1] = match[1].replace( rbackslash, "" ); |
4131 |
|
4132 |
// Move the given value to match[3] whether quoted or unquoted |
4133 |
match[3] = ( match[4] || match[5] || "" ).replace( rbackslash, "" ); |
4134 |
|
4135 |
if ( match[2] === "~=" ) { |
4136 |
match[3] = " " + match[3] + " "; |
4137 |
} |
4138 |
|
4139 |
return match.slice( 0, 4 ); |
4140 |
}, |
4141 |
|
4142 |
"CHILD": function( match ) { |
4143 |
/* matches from matchExpr.CHILD |
4144 |
1 type (only|nth|...) |
4145 |
2 argument (even|odd|\d*|\d*n([+-]\d+)?|...) |
4146 |
3 xn-component of xn+y argument ([+-]?\d*n|) |
4147 |
4 sign of xn-component |
4148 |
5 x of xn-component |
4149 |
6 sign of y-component |
4150 |
7 y of y-component |
4151 |
*/ |
4152 |
match[1] = match[1].toLowerCase(); |
4153 |
|
4154 |
if ( match[1] === "nth" ) { |
4155 |
// nth-child requires argument |
4156 |
if ( !match[2] ) { |
4157 |
Sizzle.error( match[0] ); |
4158 |
} |
4159 |
|
4160 |
// numeric x and y parameters for Expr.filter.CHILD |
4161 |
// remember that false/true cast respectively to 0/1 |
4162 |
match[3] = +( match[3] ? match[4] + (match[5] || 1) : 2 * ( match[2] === "even" || match[2] === "odd" ) ); |
4163 |
match[4] = +( ( match[6] + match[7] ) || match[2] === "odd" ); |
4164 |
|
4165 |
// other types prohibit arguments |
4166 |
} else if ( match[2] ) { |
4167 |
Sizzle.error( match[0] ); |
4168 |
} |
4169 |
|
4170 |
return match; |
4171 |
}, |
4172 |
|
4173 |
"PSEUDO": function( match, context, xml ) { |
4174 |
var unquoted, excess; |
4175 |
if ( matchExpr["CHILD"].test( match[0] ) ) { |
4176 |
return null; |
4177 |
} |
4178 |
|
4179 |
if ( match[3] ) { |
4180 |
match[2] = match[3]; |
4181 |
} else if ( (unquoted = match[4]) ) { |
4182 |
// Only check arguments that contain a pseudo |
4183 |
if ( rpseudo.test(unquoted) && |
4184 |
// Get excess from tokenize (recursively) |
4185 |
(excess = tokenize( unquoted, context, xml, true )) && |
4186 |
// advance to the next closing parenthesis |
4187 |
(excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) { |
4188 |
|
4189 |
// excess is a negative index |
4190 |
unquoted = unquoted.slice( 0, excess ); |
4191 |
match[0] = match[0].slice( 0, excess ); |
4192 |
} |
4193 |
match[2] = unquoted; |
4194 |
} |
4195 |
|
4196 |
// Return only captures needed by the pseudo filter method (type and argument) |
4197 |
return match.slice( 0, 3 ); |
4198 |
} |
4199 |
}, |
4200 |
|
4201 |
filter: { |
4202 |
"ID": assertGetIdNotName ? |
4203 |
function( id ) { |
4204 |
id = id.replace( rbackslash, "" ); |
4205 |
return function( elem ) { |
4206 |
return elem.getAttribute("id") === id; |
4207 |
}; |
4208 |
} : |
4209 |
function( id ) { |
4210 |
id = id.replace( rbackslash, "" ); |
4211 |
return function( elem ) { |
4212 |
var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id"); |
4213 |
return node && node.value === id; |
4214 |
}; |
4215 |
}, |
4216 |
|
4217 |
"TAG": function( nodeName ) { |
4218 |
if ( nodeName === "*" ) { |
4219 |
return function() { return true; }; |
4220 |
} |
4221 |
nodeName = nodeName.replace( rbackslash, "" ).toLowerCase(); |
4222 |
|
4223 |
return function( elem ) { |
4224 |
return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; |
4225 |
}; |
4226 |
}, |
4227 |
|
4228 |
"CLASS": function( className ) { |
4229 |
var pattern = classCache[ expando ][ className ]; |
4230 |
if ( !pattern ) { |
4231 |
pattern = classCache( className, new RegExp("(^|" + whitespace + ")" + className + "(" + whitespace + "|$)") ); |
4232 |
} |
4233 |
return function( elem ) { |
4234 |
return pattern.test( elem.className || (typeof elem.getAttribute !== strundefined && elem.getAttribute("class")) || "" ); |
4235 |
}; |
4236 |
}, |
4237 |
|
4238 |
"ATTR": function( name, operator, check ) { |
4239 |
if ( !operator ) { |
4240 |
return function( elem ) { |
4241 |
return Sizzle.attr( elem, name ) != null; |
4242 |
}; |
4243 |
} |
4244 |
|
4245 |
return function( elem ) { |
4246 |
var result = Sizzle.attr( elem, name ), |
4247 |
value = result + ""; |
4248 |
|
4249 |
if ( result == null ) { |
4250 |
return operator === "!="; |
4251 |
} |
4252 |
|
4253 |
switch ( operator ) { |
4254 |
case "=": |
4255 |
return value === check; |
4256 |
case "!=": |
4257 |
return value !== check; |
4258 |
case "^=": |
4259 |
return check && value.indexOf( check ) === 0; |
4260 |
case "*=": |
4261 |
return check && value.indexOf( check ) > -1; |
4262 |
case "$=": |
4263 |
return check && value.substr( value.length - check.length ) === check; |
4264 |
case "~=": |
4265 |
return ( " " + value + " " ).indexOf( check ) > -1; |
4266 |
case "|=": |
4267 |
return value === check || value.substr( 0, check.length + 1 ) === check + "-"; |
4268 |
} |
4269 |
}; |
4270 |
}, |
4271 |
|
4272 |
"CHILD": function( type, argument, first, last ) { |
4273 |
|
4274 |
if ( type === "nth" ) { |
4275 |
var doneName = done++; |
4276 |
|
4277 |
return function( elem ) { |
4278 |
var parent, diff, |
4279 |
count = 0, |
4280 |
node = elem; |
4281 |
|
4282 |
if ( first === 1 && last === 0 ) { |
4283 |
return true; |
4284 |
} |
4285 |
|
4286 |
parent = elem.parentNode; |
4287 |
|
4288 |
if ( parent && (parent[ expando ] !== doneName || !elem.sizset) ) { |
4289 |
for ( node = parent.firstChild; node; node = node.nextSibling ) { |
4290 |
if ( node.nodeType === 1 ) { |
4291 |
node.sizset = ++count; |
4292 |
if ( node === elem ) { |
4293 |
break; |
4294 |
} |
4295 |
} |
4296 |
} |
4297 |
|
4298 |
parent[ expando ] = doneName; |
4299 |
} |
4300 |
|
4301 |
diff = elem.sizset - last; |
4302 |
|
4303 |
if ( first === 0 ) { |
4304 |
return diff === 0; |
4305 |
|
4306 |
} else { |
4307 |
return ( diff % first === 0 && diff / first >= 0 ); |
4308 |
} |
4309 |
}; |
4310 |
} |
4311 |
|
4312 |
return function( elem ) { |
4313 |
var node = elem; |
4314 |
|
4315 |
switch ( type ) { |
4316 |
case "only": |
4317 |
case "first": |
4318 |
while ( (node = node.previousSibling) ) { |
4319 |
if ( node.nodeType === 1 ) { |
4320 |
return false; |
4321 |
} |
4322 |
} |
4323 |
|
4324 |
if ( type === "first" ) { |
4325 |
return true; |
4326 |
} |
4327 |
|
4328 |
node = elem; |
4329 |
|
4330 |
/* falls through */ |
4331 |
case "last": |
4332 |
while ( (node = node.nextSibling) ) { |
4333 |
if ( node.nodeType === 1 ) { |
4334 |
return false; |
4335 |
} |
4336 |
} |
4337 |
|
4338 |
return true; |
4339 |
} |
4340 |
}; |
4341 |
}, |
4342 |
|
4343 |
"PSEUDO": function( pseudo, argument, context, xml ) { |
4344 |
// pseudo-class names are case-insensitive |
4345 |
// http://www.w3.org/TR/selectors/#pseudo-classes |
4346 |
// Prioritize by case sensitivity in case custom pseudos are added with uppercase letters |
4347 |
var args, |
4348 |
fn = Expr.pseudos[ pseudo ] || Expr.pseudos[ pseudo.toLowerCase() ]; |
4349 |
|
4350 |
if ( !fn ) { |
4351 |
Sizzle.error( "unsupported pseudo: " + pseudo ); |
4352 |
} |
4353 |
|
4354 |
// The user may use createPseudo to indicate that |
4355 |
// arguments are needed to create the filter function |
4356 |
// just as Sizzle does |
4357 |
if ( !fn[ expando ] ) { |
4358 |
if ( fn.length > 1 ) { |
4359 |
args = [ pseudo, pseudo, "", argument ]; |
4360 |
return function( elem ) { |
4361 |
return fn( elem, 0, args ); |
4362 |
}; |
4363 |
} |
4364 |
return fn; |
4365 |
} |
4366 |
|
4367 |
return fn( argument, context, xml ); |
4368 |
} |
4369 |
}, |
4370 |
|
4371 |
pseudos: { |
4372 |
"not": markFunction(function( selector, context, xml ) { |
4373 |
// Trim the selector passed to compile |
4374 |
// to avoid treating leading and trailing |
4375 |
// spaces as combinators |
4376 |
var matcher = compile( selector.replace( rtrim, "$1" ), context, xml ); |
4377 |
return function( elem ) { |
4378 |
return !matcher( elem ); |
4379 |
}; |
4380 |
}), |
4381 |
|
4382 |
"enabled": function( elem ) { |
4383 |
return elem.disabled === false; |
4384 |
}, |
4385 |
|
4386 |
"disabled": function( elem ) { |
4387 |
return elem.disabled === true; |
4388 |
}, |
4389 |
|
4390 |
"checked": function( elem ) { |
4391 |
// In CSS3, :checked should return both checked and selected elements |
4392 |
// http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked |
4393 |
var nodeName = elem.nodeName.toLowerCase(); |
4394 |
return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected); |
4395 |
}, |
4396 |
|
4397 |
"selected": function( elem ) { |
4398 |
// Accessing this property makes selected-by-default |
4399 |
// options in Safari work properly |
4400 |
if ( elem.parentNode ) { |
4401 |
elem.parentNode.selectedIndex; |
4402 |
} |
4403 |
|
4404 |
return elem.selected === true; |
4405 |
}, |
4406 |
|
4407 |
"parent": function( elem ) { |
4408 |
return !Expr.pseudos["empty"]( elem ); |
4409 |
}, |
4410 |
|
4411 |
"empty": function( elem ) { |
4412 |
// http://www.w3.org/TR/selectors/#empty-pseudo |
4413 |
// :empty is only affected by element nodes and content nodes(including text(3), cdata(4)), |
4414 |
// not comment, processing instructions, or others |
4415 |
// Thanks to Diego Perini for the nodeName shortcut |
4416 |
// Greater than "@" means alpha characters (specifically not starting with "#" or "?") |
4417 |
var nodeType; |
4418 |
elem = elem.firstChild; |
4419 |
while ( elem ) { |
4420 |
if ( elem.nodeName > "@" || (nodeType = elem.nodeType) === 3 || nodeType === 4 ) { |
4421 |
return false; |
4422 |
} |
4423 |
elem = elem.nextSibling; |
4424 |
} |
4425 |
return true; |
4426 |
}, |
4427 |
|
4428 |
"contains": markFunction(function( text ) { |
4429 |
return function( elem ) { |
4430 |
return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1; |
4431 |
}; |
4432 |
}), |
4433 |
|
4434 |
"has": markFunction(function( selector ) { |
4435 |
return function( elem ) { |
4436 |
return Sizzle( selector, elem ).length > 0; |
4437 |
}; |
4438 |
}), |
4439 |
|
4440 |
"header": function( elem ) { |
4441 |
return rheader.test( elem.nodeName ); |
4442 |
}, |
4443 |
|
4444 |
"text": function( elem ) { |
4445 |
var type, attr; |
4446 |
// IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) |
4447 |
// use getAttribute instead to test this case |
4448 |
return elem.nodeName.toLowerCase() === "input" && |
4449 |
(type = elem.type) === "text" && |
4450 |
( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === type ); |
4451 |
}, |
4452 |
|
4453 |
// Input types |
4454 |
"radio": createInputPseudo("radio"), |
4455 |
"checkbox": createInputPseudo("checkbox"), |
4456 |
"file": createInputPseudo("file"), |
4457 |
"password": createInputPseudo("password"), |
4458 |
"image": createInputPseudo("image"), |
4459 |
|
4460 |
"submit": createButtonPseudo("submit"), |
4461 |
"reset": createButtonPseudo("reset"), |
4462 |
|
4463 |
"button": function( elem ) { |
4464 |
var name = elem.nodeName.toLowerCase(); |
4465 |
return name === "input" && elem.type === "button" || name === "button"; |
4466 |
}, |
4467 |
|
4468 |
"input": function( elem ) { |
4469 |
return rinputs.test( elem.nodeName ); |
4470 |
}, |
4471 |
|
4472 |
"focus": function( elem ) { |
4473 |
var doc = elem.ownerDocument; |
4474 |
return elem === doc.activeElement && (!doc.hasFocus || doc.hasFocus()) && !!(elem.type || elem.href); |
4475 |
}, |
4476 |
|
4477 |
"active": function( elem ) { |
4478 |
return elem === elem.ownerDocument.activeElement; |
4479 |
} |
4480 |
}, |
4481 |
|
4482 |
setFilters: { |
4483 |
"first": function( elements, argument, not ) { |
4484 |
return not ? elements.slice( 1 ) : [ elements[0] ]; |
4485 |
}, |
4486 |
|
4487 |
"last": function( elements, argument, not ) { |
4488 |
var elem = elements.pop(); |
4489 |
return not ? elements : [ elem ]; |
4490 |
}, |
4491 |
|
4492 |
"even": function( elements, argument, not ) { |
4493 |
var results = [], |
4494 |
i = not ? 1 : 0, |
4495 |
len = elements.length; |
4496 |
for ( ; i < len; i = i + 2 ) { |
4497 |
results.push( elements[i] ); |
4498 |
} |
4499 |
return results; |
4500 |
}, |
4501 |
|
4502 |
"odd": function( elements, argument, not ) { |
4503 |
var results = [], |
4504 |
i = not ? 0 : 1, |
4505 |
len = elements.length; |
4506 |
for ( ; i < len; i = i + 2 ) { |
4507 |
results.push( elements[i] ); |
4508 |
} |
4509 |
return results; |
4510 |
}, |
4511 |
|
4512 |
"lt": function( elements, argument, not ) { |
4513 |
return not ? elements.slice( +argument ) : elements.slice( 0, +argument ); |
4514 |
}, |
4515 |
|
4516 |
"gt": function( elements, argument, not ) { |
4517 |
return not ? elements.slice( 0, +argument + 1 ) : elements.slice( +argument + 1 ); |
4518 |
}, |
4519 |
|
4520 |
"eq": function( elements, argument, not ) { |
4521 |
var elem = elements.splice( +argument, 1 ); |
4522 |
return not ? elements : elem; |
4523 |
} |
4524 |
} |
4525 |
}; |
4526 |
|
4527 |
function siblingCheck( a, b, ret ) { |
4528 |
if ( a === b ) { |
4529 |
return ret; |
4530 |
} |
4531 |
|
4532 |
var cur = a.nextSibling; |
4533 |
|
4534 |
while ( cur ) { |
4535 |
if ( cur === b ) { |
4536 |
return -1; |
4537 |
} |
4538 |
|
4539 |
cur = cur.nextSibling; |
4540 |
} |
4541 |
|
4542 |
return 1; |
4543 |
} |
4544 |
|
4545 |
sortOrder = docElem.compareDocumentPosition ? |
4546 |
function( a, b ) { |
4547 |
if ( a === b ) { |
4548 |
hasDuplicate = true; |
4549 |
return 0; |
4550 |
} |
4551 |
|
4552 |
return ( !a.compareDocumentPosition || !b.compareDocumentPosition ? |
4553 |
a.compareDocumentPosition : |
4554 |
a.compareDocumentPosition(b) & 4 |
4555 |
) ? -1 : 1; |
4556 |
} : |
4557 |
function( a, b ) { |
4558 |
// The nodes are identical, we can exit early |
4559 |
if ( a === b ) { |
4560 |
hasDuplicate = true; |
4561 |
return 0; |
4562 |
|
4563 |
// Fallback to using sourceIndex (in IE) if it's available on both nodes |
4564 |
} else if ( a.sourceIndex && b.sourceIndex ) { |
4565 |
return a.sourceIndex - b.sourceIndex; |
4566 |
} |
4567 |
|
4568 |
var al, bl, |
4569 |
ap = [], |
4570 |
bp = [], |
4571 |
aup = a.parentNode, |
4572 |
bup = b.parentNode, |
4573 |
cur = aup; |
4574 |
|
4575 |
// If the nodes are siblings (or identical) we can do a quick check |
4576 |
if ( aup === bup ) { |
4577 |
return siblingCheck( a, b ); |
4578 |
|
4579 |
// If no parents were found then the nodes are disconnected |
4580 |
} else if ( !aup ) { |
4581 |
return -1; |
4582 |
|
4583 |
} else if ( !bup ) { |
4584 |
return 1; |
4585 |
} |
4586 |
|
4587 |
// Otherwise they're somewhere else in the tree so we need |
4588 |
// to build up a full list of the parentNodes for comparison |
4589 |
while ( cur ) { |
4590 |
ap.unshift( cur ); |
4591 |
cur = cur.parentNode; |
4592 |
} |
4593 |
|
4594 |
cur = bup; |
4595 |
|
4596 |
while ( cur ) { |
4597 |
bp.unshift( cur ); |
4598 |
cur = cur.parentNode; |
4599 |
} |
4600 |
|
4601 |
al = ap.length; |
4602 |
bl = bp.length; |
4603 |
|
4604 |
// Start walking down the tree looking for a discrepancy |
4605 |
for ( var i = 0; i < al && i < bl; i++ ) { |
4606 |
if ( ap[i] !== bp[i] ) { |
4607 |
return siblingCheck( ap[i], bp[i] ); |
4608 |
} |
4609 |
} |
4610 |
|
4611 |
// We ended someplace up the tree so do a sibling check |
4612 |
return i === al ? |
4613 |
siblingCheck( a, bp[i], -1 ) : |
4614 |
siblingCheck( ap[i], b, 1 ); |
4615 |
}; |
4616 |
|
4617 |
// Always assume the presence of duplicates if sort doesn't |
4618 |
// pass them to our comparison function (as in Google Chrome). |
4619 |
[0, 0].sort( sortOrder ); |
4620 |
baseHasDuplicate = !hasDuplicate; |
4621 |
|
4622 |
// Document sorting and removing duplicates |
4623 |
Sizzle.uniqueSort = function( results ) { |
4624 |
var elem, |
4625 |
i = 1; |
4626 |
|
4627 |
hasDuplicate = baseHasDuplicate; |
4628 |
results.sort( sortOrder ); |
4629 |
|
4630 |
if ( hasDuplicate ) { |
4631 |
for ( ; (elem = results[i]); i++ ) { |
4632 |
if ( elem === results[ i - 1 ] ) { |
4633 |
results.splice( i--, 1 ); |
4634 |
} |
4635 |
} |
4636 |
} |
4637 |
|
4638 |
return results; |
4639 |
}; |
4640 |
|
4641 |
Sizzle.error = function( msg ) { |
4642 |
throw new Error( "Syntax error, unrecognized expression: " + msg ); |
4643 |
}; |
4644 |
|
4645 |
function tokenize( selector, context, xml, parseOnly ) { |
4646 |
var matched, match, tokens, type, |
4647 |
soFar, groups, group, i, |
4648 |
preFilters, filters, |
4649 |
checkContext = !xml && context !== document, |
4650 |
// Token cache should maintain spaces |
4651 |
key = ( checkContext ? "<s>" : "" ) + selector.replace( rtrim, "$1<s>" ), |
4652 |
cached = tokenCache[ expando ][ key ]; |
4653 |
|
4654 |
if ( cached ) { |
4655 |
return parseOnly ? 0 : slice.call( cached, 0 ); |
4656 |
} |
4657 |
|
4658 |
soFar = selector; |
4659 |
groups = []; |
4660 |
i = 0; |
4661 |
preFilters = Expr.preFilter; |
4662 |
filters = Expr.filter; |
4663 |
|
4664 |
while ( soFar ) { |
4665 |
|
4666 |
// Comma and first run |
4667 |
if ( !matched || (match = rcomma.exec( soFar )) ) { |
4668 |
if ( match ) { |
4669 |
soFar = soFar.slice( match[0].length ); |
4670 |
tokens.selector = group; |
4671 |
} |
4672 |
groups.push( tokens = [] ); |
4673 |
group = ""; |
4674 |
|
4675 |
// Need to make sure we're within a narrower context if necessary |
4676 |
// Adding a descendant combinator will generate what is needed |
4677 |
if ( checkContext ) { |
4678 |
soFar = " " + soFar; |
4679 |
} |
4680 |
} |
4681 |
|
4682 |
matched = false; |
4683 |
|
4684 |
// Combinators |
4685 |
if ( (match = rcombinators.exec( soFar )) ) { |
4686 |
group += match[0]; |
4687 |
soFar = soFar.slice( match[0].length ); |
4688 |
|
4689 |
// Cast descendant combinators to space |
4690 |
matched = tokens.push({ |
4691 |
part: match.pop().replace( rtrim, " " ), |
4692 |
string: match[0], |
4693 |
captures: match |
4694 |
}); |
4695 |
} |
4696 |
|
4697 |
// Filters |
4698 |
for ( type in filters ) { |
4699 |
if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] || |
4700 |
( match = preFilters[ type ](match, context, xml) )) ) { |
4701 |
|
4702 |
group += match[0]; |
4703 |
soFar = soFar.slice( match[0].length ); |
4704 |
matched = tokens.push({ |
4705 |
part: type, |
4706 |
string: match.shift(), |
4707 |
captures: match |
4708 |
}); |
4709 |
} |
4710 |
} |
4711 |
|
4712 |
if ( !matched ) { |
4713 |
break; |
4714 |
} |
4715 |
} |
4716 |
|
4717 |
// Attach the full group as a selector |
4718 |
if ( group ) { |
4719 |
tokens.selector = group; |
4720 |
} |
4721 |
|
4722 |
// Return the length of the invalid excess |
4723 |
// if we're just parsing |
4724 |
// Otherwise, throw an error or return tokens |
4725 |
return parseOnly ? |
4726 |
soFar.length : |
4727 |
soFar ? |
4728 |
Sizzle.error( selector ) : |
4729 |
// Cache the tokens |
4730 |
slice.call( tokenCache(key, groups), 0 ); |
4731 |
} |
4732 |
|
4733 |
function addCombinator( matcher, combinator, context, xml ) { |
4734 |
var dir = combinator.dir, |
4735 |
doneName = done++; |
4736 |
|
4737 |
if ( !matcher ) { |
4738 |
// If there is no matcher to check, check against the context |
4739 |
matcher = function( elem ) { |
4740 |
return elem === context; |
4741 |
}; |
4742 |
} |
4743 |
return combinator.first ? |
4744 |
function( elem ) { |
4745 |
while ( (elem = elem[ dir ]) ) { |
4746 |
if ( elem.nodeType === 1 ) { |
4747 |
return matcher( elem ) && elem; |
4748 |
} |
4749 |
} |
4750 |
} : |
4751 |
xml ? |
4752 |
function( elem ) { |
4753 |
while ( (elem = elem[ dir ]) ) { |
4754 |
if ( elem.nodeType === 1 ) { |
4755 |
if ( matcher( elem ) ) { |
4756 |
return elem; |
4757 |
} |
4758 |
} |
4759 |
} |
4760 |
} : |
4761 |
function( elem ) { |
4762 |
var cache, |
4763 |
dirkey = doneName + "." + dirruns, |
4764 |
cachedkey = dirkey + "." + cachedruns; |
4765 |
while ( (elem = elem[ dir ]) ) { |
4766 |
if ( elem.nodeType === 1 ) { |
4767 |
if ( (cache = elem[ expando ]) === cachedkey ) { |
4768 |
return elem.sizset; |
4769 |
} else if ( typeof cache === "string" && cache.indexOf(dirkey) === 0 ) { |
4770 |
if ( elem.sizset ) { |
4771 |
return elem; |
4772 |
} |
4773 |
} else { |
4774 |
elem[ expando ] = cachedkey; |
4775 |
if ( matcher( elem ) ) { |
4776 |
elem.sizset = true; |
4777 |
return elem; |
4778 |
} |
4779 |
elem.sizset = false; |
4780 |
} |
4781 |
} |
4782 |
} |
4783 |
}; |
4784 |
} |
4785 |
|
4786 |
function addMatcher( higher, deeper ) { |
4787 |
return higher ? |
4788 |
function( elem ) { |
4789 |
var result = deeper( elem ); |
4790 |
return result && higher( result === true ? elem : result ); |
4791 |
} : |
4792 |
deeper; |
4793 |
} |
4794 |
|
4795 |
// ["TAG", ">", "ID", " ", "CLASS"] |
4796 |
function matcherFromTokens( tokens, context, xml ) { |
4797 |
var token, matcher, |
4798 |
i = 0; |
4799 |
|
4800 |
for ( ; (token = tokens[i]); i++ ) { |
4801 |
if ( Expr.relative[ token.part ] ) { |
4802 |
matcher = addCombinator( matcher, Expr.relative[ token.part ], context, xml ); |
4803 |
} else { |
4804 |
matcher = addMatcher( matcher, Expr.filter[ token.part ].apply(null, token.captures.concat( context, xml )) ); |
4805 |
} |
4806 |
} |
4807 |
|
4808 |
return matcher; |
4809 |
} |
4810 |
|
4811 |
function matcherFromGroupMatchers( matchers ) { |
4812 |
return function( elem ) { |
4813 |
var matcher, |
4814 |
j = 0; |
4815 |
for ( ; (matcher = matchers[j]); j++ ) { |
4816 |
if ( matcher(elem) ) { |
4817 |
return true; |
4818 |
} |
4819 |
} |
4820 |
return false; |
4821 |
}; |
4822 |
} |
4823 |
|
4824 |
compile = Sizzle.compile = function( selector, context, xml ) { |
4825 |
var group, i, len, |
4826 |
cached = compilerCache[ expando ][ selector ]; |
4827 |
|
4828 |
// Return a cached group function if already generated (context dependent) |
4829 |
if ( cached && cached.context === context ) { |
4830 |
return cached; |
4831 |
} |
4832 |
|
4833 |
// Generate a function of recursive functions that can be used to check each element |
4834 |
group = tokenize( selector, context, xml ); |
4835 |
for ( i = 0, len = group.length; i < len; i++ ) { |
4836 |
group[i] = matcherFromTokens(group[i], context, xml); |
4837 |
} |
4838 |
|
4839 |
// Cache the compiled function |
4840 |
cached = compilerCache( selector, matcherFromGroupMatchers(group) ); |
4841 |
cached.context = context; |
4842 |
cached.runs = cached.dirruns = 0; |
4843 |
return cached; |
4844 |
}; |
4845 |
|
4846 |
function multipleContexts( selector, contexts, results, seed ) { |
4847 |
var i = 0, |
4848 |
len = contexts.length; |
4849 |
for ( ; i < len; i++ ) { |
4850 |
Sizzle( selector, contexts[i], results, seed ); |
4851 |
} |
4852 |
} |
4853 |
|
4854 |
function handlePOSGroup( selector, posfilter, argument, contexts, seed, not ) { |
4855 |
var results, |
4856 |
fn = Expr.setFilters[ posfilter.toLowerCase() ]; |
4857 |
|
4858 |
if ( !fn ) { |
4859 |
Sizzle.error( posfilter ); |
4860 |
} |
4861 |
|
4862 |
if ( selector || !(results = seed) ) { |
4863 |
multipleContexts( selector || "*", contexts, (results = []), seed ); |
4864 |
} |
4865 |
|
4866 |
return results.length > 0 ? fn( results, argument, not ) : []; |
4867 |
} |
4868 |
|
4869 |
function handlePOS( groups, context, results, seed ) { |
4870 |
var group, part, j, groupLen, token, selector, |
4871 |
anchor, elements, match, matched, |
4872 |
lastIndex, currentContexts, not, |
4873 |
i = 0, |
4874 |
len = groups.length, |
4875 |
rpos = matchExpr["POS"], |
4876 |
// This is generated here in case matchExpr["POS"] is extended |
4877 |
rposgroups = new RegExp( "^" + rpos.source + "(?!" + whitespace + ")", "i" ), |
4878 |
// This is for making sure non-participating |
4879 |
// matching groups are represented cross-browser (IE6-8) |
4880 |
setUndefined = function() { |
4881 |
var i = 1, |
4882 |
len = arguments.length - 2; |
4883 |
for ( ; i < len; i++ ) { |
4884 |
if ( arguments[i] === undefined ) { |
4885 |
match[i] = undefined; |
4886 |
} |
4887 |
} |
4888 |
}; |
4889 |
|
4890 |
for ( ; i < len; i++ ) { |
4891 |
group = groups[i]; |
4892 |
part = ""; |
4893 |
elements = seed; |
4894 |
for ( j = 0, groupLen = group.length; j < groupLen; j++ ) { |
4895 |
token = group[j]; |
4896 |
selector = token.string; |
4897 |
if ( token.part === "PSEUDO" ) { |
4898 |
// Reset regex index to 0 |
4899 |
rpos.exec(""); |
4900 |
anchor = 0; |
4901 |
while ( (match = rpos.exec( selector )) ) { |
4902 |
matched = true; |
4903 |
lastIndex = rpos.lastIndex = match.index + match[0].length; |
4904 |
if ( lastIndex > anchor ) { |
4905 |
part += selector.slice( anchor, match.index ); |
4906 |
anchor = lastIndex; |
4907 |
currentContexts = [ context ]; |
4908 |
|
4909 |
if ( rcombinators.test(part) ) { |
4910 |
if ( elements ) { |
4911 |
currentContexts = elements; |
4912 |
} |
4913 |
elements = seed; |
4914 |
} |
4915 |
|
4916 |
if ( (not = rendsWithNot.test( part )) ) { |
4917 |
part = part.slice( 0, -5 ).replace( rcombinators, "$&*" ); |
4918 |
anchor++; |
4919 |
} |
4920 |
|
4921 |
if ( match.length > 1 ) { |
4922 |
match[0].replace( rposgroups, setUndefined ); |
4923 |
} |
4924 |
elements = handlePOSGroup( part, match[1], match[2], currentContexts, elements, not ); |
4925 |
} |
4926 |
part = ""; |
4927 |
} |
4928 |
|
4929 |
} |
4930 |
|
4931 |
if ( !matched ) { |
4932 |
part += selector; |
4933 |
} |
4934 |
matched = false; |
4935 |
} |
4936 |
|
4937 |
if ( part ) { |
4938 |
if ( rcombinators.test(part) ) { |
4939 |
multipleContexts( part, elements || [ context ], results, seed ); |
4940 |
} else { |
4941 |
Sizzle( part, context, results, seed ? seed.concat(elements) : elements ); |
4942 |
} |
4943 |
} else { |
4944 |
push.apply( results, elements ); |
4945 |
} |
4946 |
} |
4947 |
|
4948 |
// Do not sort if this is a single filter |
4949 |
return len === 1 ? results : Sizzle.uniqueSort( results ); |
4950 |
} |
4951 |
|
4952 |
function select( selector, context, results, seed, xml ) { |
4953 |
// Remove excessive whitespace |
4954 |
selector = selector.replace( rtrim, "$1" ); |
4955 |
var elements, matcher, cached, elem, |
4956 |
i, tokens, token, lastToken, findContext, type, |
4957 |
match = tokenize( selector, context, xml ), |
4958 |
contextNodeType = context.nodeType; |
4959 |
|
4960 |
// POS handling |
4961 |
if ( matchExpr["POS"].test(selector) ) { |
4962 |
return handlePOS( match, context, results, seed ); |
4963 |
} |
4964 |
|
4965 |
if ( seed ) { |
4966 |
elements = slice.call( seed, 0 ); |
4967 |
|
4968 |
// To maintain document order, only narrow the |
4969 |
// set if there is one group |
4970 |
} else if ( match.length === 1 ) { |
4971 |
|
4972 |
// Take a shortcut and set the context if the root selector is an ID |
4973 |
if ( (tokens = slice.call( match[0], 0 )).length > 2 && |
4974 |
(token = tokens[0]).part === "ID" && |
4975 |
contextNodeType === 9 && !xml && |
4976 |
Expr.relative[ tokens[1].part ] ) { |
4977 |
|
4978 |
context = Expr.find["ID"]( token.captures[0].replace( rbackslash, "" ), context, xml )[0]; |
4979 |
if ( !context ) { |
4980 |
return results; |
4981 |
} |
4982 |
|
4983 |
selector = selector.slice( tokens.shift().string.length ); |
4984 |
} |
4985 |
|
4986 |
findContext = ( (match = rsibling.exec( tokens[0].string )) && !match.index && context.parentNode ) || context; |
4987 |
|
4988 |
// Reduce the set if possible |
4989 |
lastToken = ""; |
4990 |
for ( i = tokens.length - 1; i >= 0; i-- ) { |
4991 |
token = tokens[i]; |
4992 |
type = token.part; |
4993 |
lastToken = token.string + lastToken; |
4994 |
if ( Expr.relative[ type ] ) { |
4995 |
break; |
4996 |
} |
4997 |
if ( Expr.order.test(type) ) { |
4998 |
elements = Expr.find[ type ]( token.captures[0].replace( rbackslash, "" ), findContext, xml ); |
4999 |
if ( elements == null ) { |
5000 |
continue; |
5001 |
} else { |
5002 |
selector = selector.slice( 0, selector.length - lastToken.length ) + |
5003 |
lastToken.replace( matchExpr[ type ], "" ); |
5004 |
|
5005 |
if ( !selector ) { |
5006 |
push.apply( results, slice.call(elements, 0) ); |
5007 |
} |
5008 |
|
5009 |
break; |
5010 |
} |
5011 |
} |
5012 |
} |
5013 |
} |
5014 |
|
5015 |
// Only loop over the given elements once |
5016 |
if ( selector ) { |
5017 |
matcher = compile( selector, context, xml ); |
5018 |
dirruns = matcher.dirruns++; |
5019 |
if ( elements == null ) { |
5020 |
elements = Expr.find["TAG"]( "*", (rsibling.test( selector ) && context.parentNode) || context ); |
5021 |
} |
5022 |
|
5023 |
for ( i = 0; (elem = elements[i]); i++ ) { |
5024 |
cachedruns = matcher.runs++; |
5025 |
if ( matcher(elem) ) { |
5026 |
results.push( elem ); |
5027 |
} |
5028 |
} |
5029 |
} |
5030 |
|
5031 |
return results; |
5032 |
} |
5033 |
|
5034 |
if ( document.querySelectorAll ) { |
5035 |
(function() { |
5036 |
var disconnectedMatch, |
5037 |
oldSelect = select, |
5038 |
rescape = /'|\\/g, |
5039 |
rattributeQuotes = /\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g, |
5040 |
rbuggyQSA = [], |
5041 |
// matchesSelector(:active) reports false when true (IE9/Opera 11.5) |
5042 |
// A support test would require too much code (would include document ready) |
5043 |
// just skip matchesSelector for :active |
5044 |
rbuggyMatches = [":active"], |
5045 |
matches = docElem.matchesSelector || |
5046 |
docElem.mozMatchesSelector || |
5047 |
docElem.webkitMatchesSelector || |
5048 |
docElem.oMatchesSelector || |
5049 |
docElem.msMatchesSelector; |
5050 |
|
5051 |
// Build QSA regex |
5052 |
// Regex strategy adopted from Diego Perini |
5053 |
assert(function( div ) { |
5054 |
// Select is set to empty string on purpose |
5055 |
// This is to test IE's treatment of not explictly |
5056 |
// setting a boolean content attribute, |
5057 |
// since its presence should be enough |
5058 |
// http://bugs.jquery.com/ticket/12359 |
5059 |
div.innerHTML = "<select><option selected=''></option></select>"; |
5060 |
|
5061 |
// IE8 - Some boolean attributes are not treated correctly |
5062 |
if ( !div.querySelectorAll("[selected]").length ) { |
5063 |
rbuggyQSA.push( "\\[" + whitespace + "*(?:checked|disabled|ismap|multiple|readonly|selected|value)" ); |
5064 |
} |
5065 |
|
5066 |
// Webkit/Opera - :checked should return selected option elements |
5067 |
// http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked |
5068 |
// IE8 throws error here (do not put tests after this one) |
5069 |
if ( !div.querySelectorAll(":checked").length ) { |
5070 |
rbuggyQSA.push(":checked"); |
5071 |
} |
5072 |
}); |
5073 |
|
5074 |
assert(function( div ) { |
5075 |
|
5076 |
// Opera 10-12/IE9 - ^= $= *= and empty values |
5077 |
// Should not select anything |
5078 |
div.innerHTML = "<p test=''></p>"; |
5079 |
if ( div.querySelectorAll("[test^='']").length ) { |
5080 |
rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:\"\"|'')" ); |
5081 |
} |
5082 |
|
5083 |
// FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) |
5084 |
// IE8 throws error here (do not put tests after this one) |
5085 |
div.innerHTML = "<input type='hidden'/>"; |
5086 |
if ( !div.querySelectorAll(":enabled").length ) { |
5087 |
rbuggyQSA.push(":enabled", ":disabled"); |
5088 |
} |
5089 |
}); |
5090 |
|
5091 |
rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") ); |
5092 |
|
5093 |
select = function( selector, context, results, seed, xml ) { |
5094 |
// Only use querySelectorAll when not filtering, |
5095 |
// when this is not xml, |
5096 |
// and when no QSA bugs apply |
5097 |
if ( !seed && !xml && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) { |
5098 |
if ( context.nodeType === 9 ) { |
5099 |
try { |
5100 |
push.apply( results, slice.call(context.querySelectorAll( selector ), 0) ); |
5101 |
return results; |
5102 |
} catch(qsaError) {} |
5103 |
// qSA works strangely on Element-rooted queries |
5104 |
// We can work around this by specifying an extra ID on the root |
5105 |
// and working up from there (Thanks to Andrew Dupont for the technique) |
5106 |
// IE 8 doesn't work on object elements |
5107 |
} else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { |
5108 |
var groups, i, len, |
5109 |
old = context.getAttribute("id"), |
5110 |
nid = old || expando, |
5111 |
newContext = rsibling.test( selector ) && context.parentNode || context; |
5112 |
|
5113 |
if ( old ) { |
5114 |
nid = nid.replace( rescape, "\\$&" ); |
5115 |
} else { |
5116 |
context.setAttribute( "id", nid ); |
5117 |
} |
5118 |
|
5119 |
groups = tokenize(selector, context, xml); |
5120 |
// Trailing space is unnecessary |
5121 |
// There is always a context check |
5122 |
nid = "[id='" + nid + "']"; |
5123 |
for ( i = 0, len = groups.length; i < len; i++ ) { |
5124 |
groups[i] = nid + groups[i].selector; |
5125 |
} |
5126 |
try { |
5127 |
push.apply( results, slice.call( newContext.querySelectorAll( |
5128 |
groups.join(",") |
5129 |
), 0 ) ); |
5130 |
return results; |
5131 |
} catch(qsaError) { |
5132 |
} finally { |
5133 |
if ( !old ) { |
5134 |
context.removeAttribute("id"); |
5135 |
} |
5136 |
} |
5137 |
} |
5138 |
} |
5139 |
|
5140 |
return oldSelect( selector, context, results, seed, xml ); |
5141 |
}; |
5142 |
|
5143 |
if ( matches ) { |
5144 |
assert(function( div ) { |
5145 |
// Check to see if it's possible to do matchesSelector |
5146 |
// on a disconnected node (IE 9) |
5147 |
disconnectedMatch = matches.call( div, "div" ); |
5148 |
|
5149 |
// This should fail with an exception |
5150 |
// Gecko does not error, returns false instead |
5151 |
try { |
5152 |
matches.call( div, "[test!='']:sizzle" ); |
5153 |
rbuggyMatches.push( matchExpr["PSEUDO"].source, matchExpr["POS"].source, "!=" ); |
5154 |
} catch ( e ) {} |
5155 |
}); |
5156 |
|
5157 |
// rbuggyMatches always contains :active, so no need for a length check |
5158 |
rbuggyMatches = /* rbuggyMatches.length && */ new RegExp( rbuggyMatches.join("|") ); |
5159 |
|
5160 |
Sizzle.matchesSelector = function( elem, expr ) { |
5161 |
// Make sure that attribute selectors are quoted |
5162 |
expr = expr.replace( rattributeQuotes, "='$1']" ); |
5163 |
|
5164 |
// rbuggyMatches always contains :active, so no need for an existence check |
5165 |
if ( !isXML( elem ) && !rbuggyMatches.test( expr ) && (!rbuggyQSA || !rbuggyQSA.test( expr )) ) { |
5166 |
try { |
5167 |
var ret = matches.call( elem, expr ); |
5168 |
|
5169 |
// IE 9's matchesSelector returns false on disconnected nodes |
5170 |
if ( ret || disconnectedMatch || |
5171 |
// As well, disconnected nodes are said to be in a document |
5172 |
// fragment in IE 9 |
5173 |
elem.document && elem.document.nodeType !== 11 ) { |
5174 |
return ret; |
5175 |
} |
5176 |
} catch(e) {} |
5177 |
} |
5178 |
|
5179 |
return Sizzle( expr, null, null, [ elem ] ).length > 0; |
5180 |
}; |
5181 |
} |
5182 |
})(); |
5183 |
} |
5184 |
|
5185 |
// Deprecated |
5186 |
Expr.setFilters["nth"] = Expr.setFilters["eq"]; |
5187 |
|
5188 |
// Back-compat |
5189 |
Expr.filters = Expr.pseudos; |
5190 |
|
5191 |
// Override sizzle attribute retrieval |
5192 |
Sizzle.attr = jQuery.attr; |
5193 |
jQuery.find = Sizzle; |
5194 |
jQuery.expr = Sizzle.selectors; |
5195 |
jQuery.expr[":"] = jQuery.expr.pseudos; |
5196 |
jQuery.unique = Sizzle.uniqueSort; |
5197 |
jQuery.text = Sizzle.getText; |
5198 |
jQuery.isXMLDoc = Sizzle.isXML; |
5199 |
jQuery.contains = Sizzle.contains; |
5200 |
|
5201 |
|
5202 |
})( window ); |
5203 |
var runtil = /Until$/, |
5204 |
rparentsprev = /^(?:parents|prev(?:Until|All))/, |
5205 |
isSimple = /^.[^:#\[\.,]*$/, |
5206 |
rneedsContext = jQuery.expr.match.needsContext, |
5207 |
// methods guaranteed to produce a unique set when starting from a unique set |
5208 |
guaranteedUnique = { |
5209 |
children: true, |
5210 |
contents: true, |
5211 |
next: true, |
5212 |
prev: true |
5213 |
}; |
5214 |
|
5215 |
jQuery.fn.extend({ |
5216 |
find: function( selector ) { |
5217 |
var i, l, length, n, r, ret, |
5218 |
self = this; |
5219 |
|
5220 |
if ( typeof selector !== "string" ) { |
5221 |
return jQuery( selector ).filter(function() { |
5222 |
for ( i = 0, l = self.length; i < l; i++ ) { |
5223 |
if ( jQuery.contains( self[ i ], this ) ) { |
5224 |
return true; |
5225 |
} |
5226 |
} |
5227 |
}); |
5228 |
} |
5229 |
|
5230 |
ret = this.pushStack( "", "find", selector ); |
5231 |
|
5232 |
for ( i = 0, l = this.length; i < l; i++ ) { |
5233 |
length = ret.length; |
5234 |
jQuery.find( selector, this[i], ret ); |
5235 |
|
5236 |
if ( i > 0 ) { |
5237 |
// Make sure that the results are unique |
5238 |
for ( n = length; n < ret.length; n++ ) { |
5239 |
for ( r = 0; r < length; r++ ) { |
5240 |
if ( ret[r] === ret[n] ) { |
5241 |
ret.splice(n--, 1); |
5242 |
break; |
5243 |
} |
5244 |
} |
5245 |
} |
5246 |
} |
5247 |
} |
5248 |
|
5249 |
return ret; |
5250 |
}, |
5251 |
|
5252 |
has: function( target ) { |
5253 |
var i, |
5254 |
targets = jQuery( target, this ), |
5255 |
len = targets.length; |
5256 |
|
5257 |
return this.filter(function() { |
5258 |
for ( i = 0; i < len; i++ ) { |
5259 |
if ( jQuery.contains( this, targets[i] ) ) { |
5260 |
return true; |
5261 |
} |
5262 |
} |
5263 |
}); |
5264 |
}, |
5265 |
|
5266 |
not: function( selector ) { |
5267 |
return this.pushStack( winnow(this, selector, false), "not", selector); |
5268 |
}, |
5269 |
|
5270 |
filter: function( selector ) { |
5271 |
return this.pushStack( winnow(this, selector, true), "filter", selector ); |
5272 |
}, |
5273 |
|
5274 |
is: function( selector ) { |
5275 |
return !!selector && ( |
5276 |
typeof selector === "string" ? |
5277 |
// If this is a positional/relative selector, check membership in the returned set |
5278 |
// so $("p:first").is("p:last") won't return true for a doc with two "p". |
5279 |
rneedsContext.test( selector ) ? |
5280 |
jQuery( selector, this.context ).index( this[0] ) >= 0 : |
5281 |
jQuery.filter( selector, this ).length > 0 : |
5282 |
this.filter( selector ).length > 0 ); |
5283 |
}, |
5284 |
|
5285 |
closest: function( selectors, context ) { |
5286 |
var cur, |
5287 |
i = 0, |
5288 |
l = this.length, |
5289 |
ret = [], |
5290 |
pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ? |
5291 |
jQuery( selectors, context || this.context ) : |
5292 |
0; |
5293 |
|
5294 |
for ( ; i < l; i++ ) { |
5295 |
cur = this[i]; |
5296 |
|
5297 |
while ( cur && cur.ownerDocument && cur !== context && cur.nodeType !== 11 ) { |
5298 |
if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) { |
5299 |
ret.push( cur ); |
5300 |
break; |
5301 |
} |
5302 |
cur = cur.parentNode; |
5303 |
} |
5304 |
} |
5305 |
|
5306 |
ret = ret.length > 1 ? jQuery.unique( ret ) : ret; |
5307 |
|
5308 |
return this.pushStack( ret, "closest", selectors ); |
5309 |
}, |
5310 |
|
5311 |
// Determine the position of an element within |
5312 |
// the matched set of elements |
5313 |
index: function( elem ) { |
5314 |
|
5315 |
// No argument, return index in parent |
5316 |
if ( !elem ) { |
5317 |
return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1; |
5318 |
} |
5319 |
|
5320 |
// index in selector |
5321 |
if ( typeof elem === "string" ) { |
5322 |
return jQuery.inArray( this[0], jQuery( elem ) ); |
5323 |
} |
5324 |
|
5325 |
// Locate the position of the desired element |
5326 |
return jQuery.inArray( |
5327 |
// If it receives a jQuery object, the first element is used |
5328 |
elem.jquery ? elem[0] : elem, this ); |
5329 |
}, |
5330 |
|
5331 |
add: function( selector, context ) { |
5332 |
var set = typeof selector === "string" ? |
5333 |
jQuery( selector, context ) : |
5334 |
jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ), |
5335 |
all = jQuery.merge( this.get(), set ); |
5336 |
|
5337 |
return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ? |
5338 |
all : |
5339 |
jQuery.unique( all ) ); |
5340 |
}, |
5341 |
|
5342 |
addBack: function( selector ) { |
5343 |
return this.add( selector == null ? |
5344 |
this.prevObject : this.prevObject.filter(selector) |
5345 |
); |
5346 |
} |
5347 |
}); |
5348 |
|
5349 |
jQuery.fn.andSelf = jQuery.fn.addBack; |
5350 |
|
5351 |
// A painfully simple check to see if an element is disconnected |
5352 |
// from a document (should be improved, where feasible). |
5353 |
function isDisconnected( node ) { |
5354 |
return !node || !node.parentNode || node.parentNode.nodeType === 11; |
5355 |
} |
5356 |
|
5357 |
function sibling( cur, dir ) { |
5358 |
do { |
5359 |
cur = cur[ dir ]; |
5360 |
} while ( cur && cur.nodeType !== 1 ); |
5361 |
|
5362 |
return cur; |
5363 |
} |
5364 |
|
5365 |
jQuery.each({ |
5366 |
parent: function( elem ) { |
5367 |
var parent = elem.parentNode; |
5368 |
return parent && parent.nodeType !== 11 ? parent : null; |
5369 |
}, |
5370 |
parents: function( elem ) { |
5371 |
return jQuery.dir( elem, "parentNode" ); |
5372 |
}, |
5373 |
parentsUntil: function( elem, i, until ) { |
5374 |
return jQuery.dir( elem, "parentNode", until ); |
5375 |
}, |
5376 |
next: function( elem ) { |
5377 |
return sibling( elem, "nextSibling" ); |
5378 |
}, |
5379 |
prev: function( elem ) { |
5380 |
return sibling( elem, "previousSibling" ); |
5381 |
}, |
5382 |
nextAll: function( elem ) { |
5383 |
return jQuery.dir( elem, "nextSibling" ); |
5384 |
}, |
5385 |
prevAll: function( elem ) { |
5386 |
return jQuery.dir( elem, "previousSibling" ); |
5387 |
}, |
5388 |
nextUntil: function( elem, i, until ) { |
5389 |
return jQuery.dir( elem, "nextSibling", until ); |
5390 |
}, |
5391 |
prevUntil: function( elem, i, until ) { |
5392 |
return jQuery.dir( elem, "previousSibling", until ); |
5393 |
}, |
5394 |
siblings: function( elem ) { |
5395 |
return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem ); |
5396 |
}, |
5397 |
children: function( elem ) { |
5398 |
return jQuery.sibling( elem.firstChild ); |
5399 |
}, |
5400 |
contents: function( elem ) { |
5401 |
return jQuery.nodeName( elem, "iframe" ) ? |
5402 |
elem.contentDocument || elem.contentWindow.document : |
5403 |
jQuery.merge( [], elem.childNodes ); |
5404 |
} |
5405 |
}, function( name, fn ) { |
5406 |
jQuery.fn[ name ] = function( until, selector ) { |
5407 |
var ret = jQuery.map( this, fn, until ); |
5408 |
|
5409 |
if ( !runtil.test( name ) ) { |
5410 |
selector = until; |
5411 |
} |
5412 |
|
5413 |
if ( selector && typeof selector === "string" ) { |
5414 |
ret = jQuery.filter( selector, ret ); |
5415 |
} |
5416 |
|
5417 |
ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret; |
5418 |
|
5419 |
if ( this.length > 1 && rparentsprev.test( name ) ) { |
5420 |
ret = ret.reverse(); |
5421 |
} |
5422 |
|
5423 |
return this.pushStack( ret, name, core_slice.call( arguments ).join(",") ); |
5424 |
}; |
5425 |
}); |
5426 |
|
5427 |
jQuery.extend({ |
5428 |
filter: function( expr, elems, not ) { |
5429 |
if ( not ) { |
5430 |
expr = ":not(" + expr + ")"; |
5431 |
} |
5432 |
|
5433 |
return elems.length === 1 ? |
5434 |
jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] : |
5435 |
jQuery.find.matches(expr, elems); |
5436 |
}, |
5437 |
|
5438 |
dir: function( elem, dir, until ) { |
5439 |
var matched = [], |
5440 |
cur = elem[ dir ]; |
5441 |
|
5442 |
while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) { |
5443 |
if ( cur.nodeType === 1 ) { |
5444 |
matched.push( cur ); |
5445 |
} |
5446 |
cur = cur[dir]; |
5447 |
} |
5448 |
return matched; |
5449 |
}, |
5450 |
|
5451 |
sibling: function( n, elem ) { |
5452 |
var r = []; |
5453 |
|
5454 |
for ( ; n; n = n.nextSibling ) { |
5455 |
if ( n.nodeType === 1 && n !== elem ) { |
5456 |
r.push( n ); |
5457 |
} |
5458 |
} |
5459 |
|
5460 |
return r; |
5461 |
} |
5462 |
}); |
5463 |
|
5464 |
// Implement the identical functionality for filter and not |
5465 |
function winnow( elements, qualifier, keep ) { |
5466 |
|
5467 |
// Can't pass null or undefined to indexOf in Firefox 4 |
5468 |
// Set to 0 to skip string check |
5469 |
qualifier = qualifier || 0; |
5470 |
|
5471 |
if ( jQuery.isFunction( qualifier ) ) { |
5472 |
return jQuery.grep(elements, function( elem, i ) { |
5473 |
var retVal = !!qualifier.call( elem, i, elem ); |
5474 |
return retVal === keep; |
5475 |
}); |
5476 |
|
5477 |
} else if ( qualifier.nodeType ) { |
5478 |
return jQuery.grep(elements, function( elem, i ) { |
5479 |
return ( elem === qualifier ) === keep; |
5480 |
}); |
5481 |
|
5482 |
} else if ( typeof qualifier === "string" ) { |
5483 |
var filtered = jQuery.grep(elements, function( elem ) { |
5484 |
return elem.nodeType === 1; |
5485 |
}); |
5486 |
|
5487 |
if ( isSimple.test( qualifier ) ) { |
5488 |
return jQuery.filter(qualifier, filtered, !keep); |
5489 |
} else { |
5490 |
qualifier = jQuery.filter( qualifier, filtered ); |
5491 |
} |
5492 |
} |
5493 |
|
5494 |
return jQuery.grep(elements, function( elem, i ) { |
5495 |
return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep; |
5496 |
}); |
5497 |
} |
5498 |
function createSafeFragment( document ) { |
5499 |
var list = nodeNames.split( "|" ), |
5500 |
safeFrag = document.createDocumentFragment(); |
5501 |
|
5502 |
if ( safeFrag.createElement ) { |
5503 |
while ( list.length ) { |
5504 |
safeFrag.createElement( |
5505 |
list.pop() |
5506 |
); |
5507 |
} |
5508 |
} |
5509 |
return safeFrag; |
5510 |
} |
5511 |
|
5512 |
var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" + |
5513 |
"header|hgroup|mark|meter|nav|output|progress|section|summary|time|video", |
5514 |
rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g, |
5515 |
rleadingWhitespace = /^\s+/, |
5516 |
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, |
5517 |
rtagName = /<([\w:]+)/, |
5518 |
rtbody = /<tbody/i, |
5519 |
rhtml = /<|&#?\w+;/, |
5520 |
rnoInnerhtml = /<(?:script|style|link)/i, |
5521 |
rnocache = /<(?:script|object|embed|option|style)/i, |
5522 |
rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"), |
5523 |
rcheckableType = /^(?:checkbox|radio)$/, |
5524 |
// checked="checked" or checked |
5525 |
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, |
5526 |
rscriptType = /\/(java|ecma)script/i, |
5527 |
rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)|[\]\-]{2}>\s*$/g, |
5528 |
wrapMap = { |
5529 |
option: [ 1, "<select multiple='multiple'>", "</select>" ], |
5530 |
legend: [ 1, "<fieldset>", "</fieldset>" ], |
5531 |
thead: [ 1, "<table>", "</table>" ], |
5532 |
tr: [ 2, "<table><tbody>", "</tbody></table>" ], |
5533 |
td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], |
5534 |
col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ], |
5535 |
area: [ 1, "<map>", "</map>" ], |
5536 |
_default: [ 0, "", "" ] |
5537 |
}, |
5538 |
safeFragment = createSafeFragment( document ), |
5539 |
fragmentDiv = safeFragment.appendChild( document.createElement("div") ); |
5540 |
|
5541 |
wrapMap.optgroup = wrapMap.option; |
5542 |
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; |
5543 |
wrapMap.th = wrapMap.td; |
5544 |
|
5545 |
// IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags, |
5546 |
// unless wrapped in a div with non-breaking characters in front of it. |
5547 |
if ( !jQuery.support.htmlSerialize ) { |
5548 |
wrapMap._default = [ 1, "X<div>", "</div>" ]; |
5549 |
} |
5550 |
|
5551 |
jQuery.fn.extend({ |
5552 |
text: function( value ) { |
5553 |
return jQuery.access( this, function( value ) { |
5554 |
return value === undefined ? |
5555 |
jQuery.text( this ) : |
5556 |
this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) ); |
5557 |
}, null, value, arguments.length ); |
5558 |
}, |
5559 |
|
5560 |
wrapAll: function( html ) { |
5561 |
if ( jQuery.isFunction( html ) ) { |
5562 |
return this.each(function(i) { |
5563 |
jQuery(this).wrapAll( html.call(this, i) ); |
5564 |
}); |
5565 |
} |
5566 |
|
5567 |
if ( this[0] ) { |
5568 |
// The elements to wrap the target around |
5569 |
var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true); |
5570 |
|
5571 |
if ( this[0].parentNode ) { |
5572 |
wrap.insertBefore( this[0] ); |
5573 |
} |
5574 |
|
5575 |
wrap.map(function() { |
5576 |
var elem = this; |
5577 |
|
5578 |
while ( elem.firstChild && elem.firstChild.nodeType === 1 ) { |
5579 |
elem = elem.firstChild; |
5580 |
} |
5581 |
|
5582 |
return elem; |
5583 |
}).append( this ); |
5584 |
} |
5585 |
|
5586 |
return this; |
5587 |
}, |
5588 |
|
5589 |
wrapInner: function( html ) { |
5590 |
if ( jQuery.isFunction( html ) ) { |
5591 |
return this.each(function(i) { |
5592 |
jQuery(this).wrapInner( html.call(this, i) ); |
5593 |
}); |
5594 |
} |
5595 |
|
5596 |
return this.each(function() { |
5597 |
var self = jQuery( this ), |
5598 |
contents = self.contents(); |
5599 |
|
5600 |
if ( contents.length ) { |
5601 |
contents.wrapAll( html ); |
5602 |
|
5603 |
} else { |
5604 |
self.append( html ); |
5605 |
} |
5606 |
}); |
5607 |
}, |
5608 |
|
5609 |
wrap: function( html ) { |
5610 |
var isFunction = jQuery.isFunction( html ); |
5611 |
|
5612 |
return this.each(function(i) { |
5613 |
jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html ); |
5614 |
}); |
5615 |
}, |
5616 |
|
5617 |
unwrap: function() { |
5618 |
return this.parent().each(function() { |
5619 |
if ( !jQuery.nodeName( this, "body" ) ) { |
5620 |
jQuery( this ).replaceWith( this.childNodes ); |
5621 |
} |
5622 |
}).end(); |
5623 |
}, |
5624 |
|
5625 |
append: function() { |
5626 |
return this.domManip(arguments, true, function( elem ) { |
5627 |
if ( this.nodeType === 1 || this.nodeType === 11 ) { |
5628 |
this.appendChild( elem ); |
5629 |
} |
5630 |
}); |
5631 |
}, |
5632 |
|
5633 |
prepend: function() { |
5634 |
return this.domManip(arguments, true, function( elem ) { |
5635 |
if ( this.nodeType === 1 || this.nodeType === 11 ) { |
5636 |
this.insertBefore( elem, this.firstChild ); |
5637 |
} |
5638 |
}); |
5639 |
}, |
5640 |
|
5641 |
before: function() { |
5642 |
if ( !isDisconnected( this[0] ) ) { |
5643 |
return this.domManip(arguments, false, function( elem ) { |
5644 |
this.parentNode.insertBefore( elem, this ); |
5645 |
}); |
5646 |
} |
5647 |
|
5648 |
if ( arguments.length ) { |
5649 |
var set = jQuery.clean( arguments ); |
5650 |
return this.pushStack( jQuery.merge( set, this ), "before", this.selector ); |
5651 |
} |
5652 |
}, |
5653 |
|
5654 |
after: function() { |
5655 |
if ( !isDisconnected( this[0] ) ) { |
5656 |
return this.domManip(arguments, false, function( elem ) { |
5657 |
this.parentNode.insertBefore( elem, this.nextSibling ); |
5658 |
}); |
5659 |
} |
5660 |
|
5661 |
if ( arguments.length ) { |
5662 |
var set = jQuery.clean( arguments ); |
5663 |
return this.pushStack( jQuery.merge( this, set ), "after", this.selector ); |
5664 |
} |
5665 |
}, |
5666 |
|
5667 |
// keepData is for internal use only--do not document |
5668 |
remove: function( selector, keepData ) { |
5669 |
var elem, |
5670 |
i = 0; |
5671 |
|
5672 |
for ( ; (elem = this[i]) != null; i++ ) { |
5673 |
if ( !selector || jQuery.filter( selector, [ elem ] ).length ) { |
5674 |
if ( !keepData && elem.nodeType === 1 ) { |
5675 |
jQuery.cleanData( elem.getElementsByTagName("*") ); |
5676 |
jQuery.cleanData( [ elem ] ); |
5677 |
} |
5678 |
|
5679 |
if ( elem.parentNode ) { |
5680 |
elem.parentNode.removeChild( elem ); |
5681 |
} |
5682 |
} |
5683 |
} |
5684 |
|
5685 |
return this; |
5686 |
}, |
5687 |
|
5688 |
empty: function() { |
5689 |
var elem, |
5690 |
i = 0; |
5691 |
|
5692 |
for ( ; (elem = this[i]) != null; i++ ) { |
5693 |
// Remove element nodes and prevent memory leaks |
5694 |
if ( elem.nodeType === 1 ) { |
5695 |
jQuery.cleanData( elem.getElementsByTagName("*") ); |
5696 |
} |
5697 |
|
5698 |
// Remove any remaining nodes |
5699 |
while ( elem.firstChild ) { |
5700 |
elem.removeChild( elem.firstChild ); |
5701 |
} |
5702 |
} |
5703 |
|
5704 |
return this; |
5705 |
}, |
5706 |
|
5707 |
clone: function( dataAndEvents, deepDataAndEvents ) { |
5708 |
dataAndEvents = dataAndEvents == null ? false : dataAndEvents; |
5709 |
deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; |
5710 |
|
5711 |
return this.map( function () { |
5712 |
return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); |
5713 |
}); |
5714 |
}, |
5715 |
|
5716 |
html: function( value ) { |
5717 |
return jQuery.access( this, function( value ) { |
5718 |
var elem = this[0] || {}, |
5719 |
i = 0, |
5720 |
l = this.length; |
5721 |
|
5722 |
if ( value === undefined ) { |
5723 |
return elem.nodeType === 1 ? |
5724 |
elem.innerHTML.replace( rinlinejQuery, "" ) : |
5725 |
undefined; |
5726 |
} |
5727 |
|
5728 |
// See if we can take a shortcut and just use innerHTML |
5729 |
if ( typeof value === "string" && !rnoInnerhtml.test( value ) && |
5730 |
( jQuery.support.htmlSerialize || !rnoshimcache.test( value ) ) && |
5731 |
( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) && |
5732 |
!wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) { |
5733 |
|
5734 |
value = value.replace( rxhtmlTag, "<$1></$2>" ); |
5735 |
|
5736 |
try { |
5737 |
for (; i < l; i++ ) { |
5738 |
// Remove element nodes and prevent memory leaks |
5739 |
elem = this[i] || {}; |
5740 |
if ( elem.nodeType === 1 ) { |
5741 |
jQuery.cleanData( elem.getElementsByTagName( "*" ) ); |
5742 |
elem.innerHTML = value; |
5743 |
} |
5744 |
} |
5745 |
|
5746 |
elem = 0; |
5747 |
|
5748 |
// If using innerHTML throws an exception, use the fallback method |
5749 |
} catch(e) {} |
5750 |
} |
5751 |
|
5752 |
if ( elem ) { |
5753 |
this.empty().append( value ); |
5754 |
} |
5755 |
}, null, value, arguments.length ); |
5756 |
}, |
5757 |
|
5758 |
replaceWith: function( value ) { |
5759 |
if ( !isDisconnected( this[0] ) ) { |
5760 |
// Make sure that the elements are removed from the DOM before they are inserted |
5761 |
// this can help fix replacing a parent with child elements |
5762 |
if ( jQuery.isFunction( value ) ) { |
5763 |
return this.each(function(i) { |
5764 |
var self = jQuery(this), old = self.html(); |
5765 |
self.replaceWith( value.call( this, i, old ) ); |
5766 |
}); |
5767 |
} |
5768 |
|
5769 |
if ( typeof value !== "string" ) { |
5770 |
value = jQuery( value ).detach(); |
5771 |
} |
5772 |
|
5773 |
return this.each(function() { |
5774 |
var next = this.nextSibling, |
5775 |
parent = this.parentNode; |
5776 |
|
5777 |
jQuery( this ).remove(); |
5778 |
|
5779 |
if ( next ) { |
5780 |
jQuery(next).before( value ); |
5781 |
} else { |
5782 |
jQuery(parent).append( value ); |
5783 |
} |
5784 |
}); |
5785 |
} |
5786 |
|
5787 |
return this.length ? |
5788 |
this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) : |
5789 |
this; |
5790 |
}, |
5791 |
|
5792 |
detach: function( selector ) { |
5793 |
return this.remove( selector, true ); |
5794 |
}, |
5795 |
|
5796 |
domManip: function( args, table, callback ) { |
5797 |
|
5798 |
// Flatten any nested arrays |
5799 |
args = [].concat.apply( [], args ); |
5800 |
|
5801 |
var results, first, fragment, iNoClone, |
5802 |
i = 0, |
5803 |
value = args[0], |
5804 |
scripts = [], |
5805 |
l = this.length; |
5806 |
|
5807 |
// We can't cloneNode fragments that contain checked, in WebKit |
5808 |
if ( !jQuery.support.checkClone && l > 1 && typeof value === "string" && rchecked.test( value ) ) { |
5809 |
return this.each(function() { |
5810 |
jQuery(this).domManip( args, table, callback ); |
5811 |
}); |
5812 |
} |
5813 |
|
5814 |
if ( jQuery.isFunction(value) ) { |
5815 |
return this.each(function(i) { |
5816 |
var self = jQuery(this); |
5817 |
args[0] = value.call( this, i, table ? self.html() : undefined ); |
5818 |
self.domManip( args, table, callback ); |
5819 |
}); |
5820 |
} |
5821 |
|
5822 |
if ( this[0] ) { |
5823 |
results = jQuery.buildFragment( args, this, scripts ); |
5824 |
fragment = results.fragment; |
5825 |
first = fragment.firstChild; |
5826 |
|
5827 |
if ( fragment.childNodes.length === 1 ) { |
5828 |
fragment = first; |
5829 |
} |
5830 |
|
5831 |
if ( first ) { |
5832 |
table = table && jQuery.nodeName( first, "tr" ); |
5833 |
|
5834 |
// Use the original fragment for the last item instead of the first because it can end up |
5835 |
// being emptied incorrectly in certain situations (#8070). |
5836 |
// Fragments from the fragment cache must always be cloned and never used in place. |
5837 |
for ( iNoClone = results.cacheable || l - 1; i < l; i++ ) { |
5838 |
callback.call( |
5839 |
table && jQuery.nodeName( this[i], "table" ) ? |
5840 |
findOrAppend( this[i], "tbody" ) : |
5841 |
this[i], |
5842 |
i === iNoClone ? |
5843 |
fragment : |
5844 |
jQuery.clone( fragment, true, true ) |
5845 |
); |
5846 |
} |
5847 |
} |
5848 |
|
5849 |
// Fix #11809: Avoid leaking memory |
5850 |
fragment = first = null; |
5851 |
|
5852 |
if ( scripts.length ) { |
5853 |
jQuery.each( scripts, function( i, elem ) { |
5854 |
if ( elem.src ) { |
5855 |
if ( jQuery.ajax ) { |
5856 |
jQuery.ajax({ |
5857 |
url: elem.src, |
5858 |
type: "GET", |
5859 |
dataType: "script", |
5860 |
async: false, |
5861 |
global: false, |
5862 |
"throws": true |
5863 |
}); |
5864 |
} else { |
5865 |
jQuery.error("no ajax"); |
5866 |
} |
5867 |
} else { |
5868 |
jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "" ) ); |
5869 |
} |
5870 |
|
5871 |
if ( elem.parentNode ) { |
5872 |
elem.parentNode.removeChild( elem ); |
5873 |
} |
5874 |
}); |
5875 |
} |
5876 |
} |
5877 |
|
5878 |
return this; |
5879 |
} |
5880 |
}); |
5881 |
|
5882 |
function findOrAppend( elem, tag ) { |
5883 |
return elem.getElementsByTagName( tag )[0] || elem.appendChild( elem.ownerDocument.createElement( tag ) ); |
5884 |
} |
5885 |
|
5886 |
function cloneCopyEvent( src, dest ) { |
5887 |
|
5888 |
if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) { |
5889 |
return; |
5890 |
} |
5891 |
|
5892 |
var type, i, l, |
5893 |
oldData = jQuery._data( src ), |
5894 |
curData = jQuery._data( dest, oldData ), |
5895 |
events = oldData.events; |
5896 |
|
5897 |
if ( events ) { |
5898 |
delete curData.handle; |
5899 |
curData.events = {}; |
5900 |
|
5901 |
for ( type in events ) { |
5902 |
for ( i = 0, l = events[ type ].length; i < l; i++ ) { |
5903 |
jQuery.event.add( dest, type, events[ type ][ i ] ); |
5904 |
} |
5905 |
} |
5906 |
} |
5907 |
|
5908 |
// make the cloned public data object a copy from the original |
5909 |
if ( curData.data ) { |
5910 |
curData.data = jQuery.extend( {}, curData.data ); |
5911 |
} |
5912 |
} |
5913 |
|
5914 |
function cloneFixAttributes( src, dest ) { |
5915 |
var nodeName; |
5916 |
|
5917 |
// We do not need to do anything for non-Elements |
5918 |
if ( dest.nodeType !== 1 ) { |
5919 |
return; |
5920 |
} |
5921 |
|
5922 |
// clearAttributes removes the attributes, which we don't want, |
5923 |
// but also removes the attachEvent events, which we *do* want |
5924 |
if ( dest.clearAttributes ) { |
5925 |
dest.clearAttributes(); |
5926 |
} |
5927 |
|
5928 |
// mergeAttributes, in contrast, only merges back on the |
5929 |
// original attributes, not the events |
5930 |
if ( dest.mergeAttributes ) { |
5931 |
dest.mergeAttributes( src ); |
5932 |
} |
5933 |
|
5934 |
nodeName = dest.nodeName.toLowerCase(); |
5935 |
|
5936 |
if ( nodeName === "object" ) { |
5937 |
// IE6-10 improperly clones children of object elements using classid. |
5938 |
// IE10 throws NoModificationAllowedError if parent is null, #12132. |
5939 |
if ( dest.parentNode ) { |
5940 |
dest.outerHTML = src.outerHTML; |
5941 |
} |
5942 |
|
5943 |
// This path appears unavoidable for IE9. When cloning an object |
5944 |
// element in IE9, the outerHTML strategy above is not sufficient. |
5945 |
// If the src has innerHTML and the destination does not, |
5946 |
// copy the src.innerHTML into the dest.innerHTML. #10324 |
5947 |
if ( jQuery.support.html5Clone && (src.innerHTML && !jQuery.trim(dest.innerHTML)) ) { |
5948 |
dest.innerHTML = src.innerHTML; |
5949 |
} |
5950 |
|
5951 |
} else if ( nodeName === "input" && rcheckableType.test( src.type ) ) { |
5952 |
// IE6-8 fails to persist the checked state of a cloned checkbox |
5953 |
// or radio button. Worse, IE6-7 fail to give the cloned element |
5954 |
// a checked appearance if the defaultChecked value isn't also set |
5955 |
|
5956 |
dest.defaultChecked = dest.checked = src.checked; |
5957 |
|
5958 |
// IE6-7 get confused and end up setting the value of a cloned |
5959 |
// checkbox/radio button to an empty string instead of "on" |
5960 |
if ( dest.value !== src.value ) { |
5961 |
dest.value = src.value; |
5962 |
} |
5963 |
|
5964 |
// IE6-8 fails to return the selected option to the default selected |
5965 |
// state when cloning options |
5966 |
} else if ( nodeName === "option" ) { |
5967 |
dest.selected = src.defaultSelected; |
5968 |
|
5969 |
// IE6-8 fails to set the defaultValue to the correct value when |
5970 |
// cloning other types of input fields |
5971 |
} else if ( nodeName === "input" || nodeName === "textarea" ) { |
5972 |
dest.defaultValue = src.defaultValue; |
5973 |
|
5974 |
// IE blanks contents when cloning scripts |
5975 |
} else if ( nodeName === "script" && dest.text !== src.text ) { |
5976 |
dest.text = src.text; |
5977 |
} |
5978 |
|
5979 |
// Event data gets referenced instead of copied if the expando |
5980 |
// gets copied too |
5981 |
dest.removeAttribute( jQuery.expando ); |
5982 |
} |
5983 |
|
5984 |
jQuery.buildFragment = function( args, context, scripts ) { |
5985 |
var fragment, cacheable, cachehit, |
5986 |
first = args[ 0 ]; |
5987 |
|
5988 |
// Set context from what may come in as undefined or a jQuery collection or a node |
5989 |
// Updated to fix #12266 where accessing context[0] could throw an exception in IE9/10 & |
5990 |
// also doubles as fix for #8950 where plain objects caused createDocumentFragment exception |
5991 |
context = context || document; |
5992 |
context = !context.nodeType && context[0] || context; |
5993 |
context = context.ownerDocument || context; |
5994 |
|
5995 |
// Only cache "small" (1/2 KB) HTML strings that are associated with the main document |
5996 |
// Cloning options loses the selected state, so don't cache them |
5997 |
// IE 6 doesn't like it when you put <object> or <embed> elements in a fragment |
5998 |
// Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache |
5999 |
// Lastly, IE6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501 |
6000 |
if ( args.length === 1 && typeof first === "string" && first.length < 512 && context === document && |
6001 |
first.charAt(0) === "<" && !rnocache.test( first ) && |
6002 |
(jQuery.support.checkClone || !rchecked.test( first )) && |
6003 |
(jQuery.support.html5Clone || !rnoshimcache.test( first )) ) { |
6004 |
|
6005 |
// Mark cacheable and look for a hit |
6006 |
cacheable = true; |
6007 |
fragment = jQuery.fragments[ first ]; |
6008 |
cachehit = fragment !== undefined; |
6009 |
} |
6010 |
|
6011 |
if ( !fragment ) { |
6012 |
fragment = context.createDocumentFragment(); |
6013 |
jQuery.clean( args, context, fragment, scripts ); |
6014 |
|
6015 |
// Update the cache, but only store false |
6016 |
// unless this is a second parsing of the same content |
6017 |
if ( cacheable ) { |
6018 |
jQuery.fragments[ first ] = cachehit && fragment; |
6019 |
} |
6020 |
} |
6021 |
|
6022 |
return { fragment: fragment, cacheable: cacheable }; |
6023 |
}; |
6024 |
|
6025 |
jQuery.fragments = {}; |
6026 |
|
6027 |
jQuery.each({ |
6028 |
appendTo: "append", |
6029 |
prependTo: "prepend", |
6030 |
insertBefore: "before", |
6031 |
insertAfter: "after", |
6032 |
replaceAll: "replaceWith" |
6033 |
}, function( name, original ) { |
6034 |
jQuery.fn[ name ] = function( selector ) { |
6035 |
var elems, |
6036 |
i = 0, |
6037 |
ret = [], |
6038 |
insert = jQuery( selector ), |
6039 |
l = insert.length, |
6040 |
parent = this.length === 1 && this[0].parentNode; |
6041 |
|
6042 |
if ( (parent == null || parent && parent.nodeType === 11 && parent.childNodes.length === 1) && l === 1 ) { |
6043 |
insert[ original ]( this[0] ); |
6044 |
return this; |
6045 |
} else { |
6046 |
for ( ; i < l; i++ ) { |
6047 |
elems = ( i > 0 ? this.clone(true) : this ).get(); |
6048 |
jQuery( insert[i] )[ original ]( elems ); |
6049 |
ret = ret.concat( elems ); |
6050 |
} |
6051 |
|
6052 |
return this.pushStack( ret, name, insert.selector ); |
6053 |
} |
6054 |
}; |
6055 |
}); |
6056 |
|
6057 |
function getAll( elem ) { |
6058 |
if ( typeof elem.getElementsByTagName !== "undefined" ) { |
6059 |
return elem.getElementsByTagName( "*" ); |
6060 |
|
6061 |
} else if ( typeof elem.querySelectorAll !== "undefined" ) { |
6062 |
return elem.querySelectorAll( "*" ); |
6063 |
|
6064 |
} else { |
6065 |
return []; |
6066 |
} |
6067 |
} |
6068 |
|
6069 |
// Used in clean, fixes the defaultChecked property |
6070 |
function fixDefaultChecked( elem ) { |
6071 |
if ( rcheckableType.test( elem.type ) ) { |
6072 |
elem.defaultChecked = elem.checked; |
6073 |
} |
6074 |
} |
6075 |
|
6076 |
jQuery.extend({ |
6077 |
clone: function( elem, dataAndEvents, deepDataAndEvents ) { |
6078 |
var srcElements, |
6079 |
destElements, |
6080 |
i, |
6081 |
clone; |
6082 |
|
6083 |
if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) { |
6084 |
clone = elem.cloneNode( true ); |
6085 |
|
6086 |
// IE<=8 does not properly clone detached, unknown element nodes |
6087 |
} else { |
6088 |
fragmentDiv.innerHTML = elem.outerHTML; |
6089 |
fragmentDiv.removeChild( clone = fragmentDiv.firstChild ); |
6090 |
} |
6091 |
|
6092 |
if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) && |
6093 |
(elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) { |
6094 |
// IE copies events bound via attachEvent when using cloneNode. |
6095 |
// Calling detachEvent on the clone will also remove the events |
6096 |
// from the original. In order to get around this, we use some |
6097 |
// proprietary methods to clear the events. Thanks to MooTools |
6098 |
// guys for this hotness. |
6099 |
|
6100 |
cloneFixAttributes( elem, clone ); |
6101 |
|
6102 |
// Using Sizzle here is crazy slow, so we use getElementsByTagName instead |
6103 |
srcElements = getAll( elem ); |
6104 |
destElements = getAll( clone ); |
6105 |
|
6106 |
// Weird iteration because IE will replace the length property |
6107 |
// with an element if you are cloning the body and one of the |
6108 |
// elements on the page has a name or id of "length" |
6109 |
for ( i = 0; srcElements[i]; ++i ) { |
6110 |
// Ensure that the destination node is not null; Fixes #9587 |
6111 |
if ( destElements[i] ) { |
6112 |
cloneFixAttributes( srcElements[i], destElements[i] ); |
6113 |
} |
6114 |
} |
6115 |
} |
6116 |
|
6117 |
// Copy the events from the original to the clone |
6118 |
if ( dataAndEvents ) { |
6119 |
cloneCopyEvent( elem, clone ); |
6120 |
|
6121 |
if ( deepDataAndEvents ) { |
6122 |
srcElements = getAll( elem ); |
6123 |
destElements = getAll( clone ); |
6124 |
|
6125 |
for ( i = 0; srcElements[i]; ++i ) { |
6126 |
cloneCopyEvent( srcElements[i], destElements[i] ); |
6127 |
} |
6128 |
} |
6129 |
} |
6130 |
|
6131 |
srcElements = destElements = null; |
6132 |
|
6133 |
// Return the cloned set |
6134 |
return clone; |
6135 |
}, |
6136 |
|
6137 |
clean: function( elems, context, fragment, scripts ) { |
6138 |
var i, j, elem, tag, wrap, depth, div, hasBody, tbody, len, handleScript, jsTags, |
6139 |
safe = context === document && safeFragment, |
6140 |
ret = []; |
6141 |
|
6142 |
// Ensure that context is a document |
6143 |
if ( !context || typeof context.createDocumentFragment === "undefined" ) { |
6144 |
context = document; |
6145 |
} |
6146 |
|
6147 |
// Use the already-created safe fragment if context permits |
6148 |
for ( i = 0; (elem = elems[i]) != null; i++ ) { |
6149 |
if ( typeof elem === "number" ) { |
6150 |
elem += ""; |
6151 |
} |
6152 |
|
6153 |
if ( !elem ) { |
6154 |
continue; |
6155 |
} |
6156 |
|
6157 |
// Convert html string into DOM nodes |
6158 |
if ( typeof elem === "string" ) { |
6159 |
if ( !rhtml.test( elem ) ) { |
6160 |
elem = context.createTextNode( elem ); |
6161 |
} else { |
6162 |
// Ensure a safe container in which to render the html |
6163 |
safe = safe || createSafeFragment( context ); |
6164 |
div = context.createElement("div"); |
6165 |
safe.appendChild( div ); |
6166 |
|
6167 |
// Fix "XHTML"-style tags in all browsers |
6168 |
elem = elem.replace(rxhtmlTag, "<$1></$2>"); |
6169 |
|
6170 |
// Go to html and back, then peel off extra wrappers |
6171 |
tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase(); |
6172 |
wrap = wrapMap[ tag ] || wrapMap._default; |
6173 |
depth = wrap[0]; |
6174 |
div.innerHTML = wrap[1] + elem + wrap[2]; |
6175 |
|
6176 |
// Move to the right depth |
6177 |
while ( depth-- ) { |
6178 |
div = div.lastChild; |
6179 |
} |
6180 |
|
6181 |
// Remove IE's autoinserted <tbody> from table fragments |
6182 |
if ( !jQuery.support.tbody ) { |
6183 |
|
6184 |
// String was a <table>, *may* have spurious <tbody> |
6185 |
hasBody = rtbody.test(elem); |
6186 |
tbody = tag === "table" && !hasBody ? |
6187 |
div.firstChild && div.firstChild.childNodes : |
6188 |
|
6189 |
// String was a bare <thead> or <tfoot> |
6190 |
wrap[1] === "<table>" && !hasBody ? |
6191 |
div.childNodes : |
6192 |
[]; |
6193 |
|
6194 |
for ( j = tbody.length - 1; j >= 0 ; --j ) { |
6195 |
if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) { |
6196 |
tbody[ j ].parentNode.removeChild( tbody[ j ] ); |
6197 |
} |
6198 |
} |
6199 |
} |
6200 |
|
6201 |
// IE completely kills leading whitespace when innerHTML is used |
6202 |
if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) { |
6203 |
div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild ); |
6204 |
} |
6205 |
|
6206 |
elem = div.childNodes; |
6207 |
|
6208 |
// Take out of fragment container (we need a fresh div each time) |
6209 |
div.parentNode.removeChild( div ); |
6210 |
} |
6211 |
} |
6212 |
|
6213 |
if ( elem.nodeType ) { |
6214 |
ret.push( elem ); |
6215 |
} else { |
6216 |
jQuery.merge( ret, elem ); |
6217 |
} |
6218 |
} |
6219 |
|
6220 |
// Fix #11356: Clear elements from safeFragment |
6221 |
if ( div ) { |
6222 |
elem = div = safe = null; |
6223 |
} |
6224 |
|
6225 |
// Reset defaultChecked for any radios and checkboxes |
6226 |
// about to be appended to the DOM in IE 6/7 (#8060) |
6227 |
if ( !jQuery.support.appendChecked ) { |
6228 |
for ( i = 0; (elem = ret[i]) != null; i++ ) { |
6229 |
if ( jQuery.nodeName( elem, "input" ) ) { |
6230 |
fixDefaultChecked( elem ); |
6231 |
} else if ( typeof elem.getElementsByTagName !== "undefined" ) { |
6232 |
jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked ); |
6233 |
} |
6234 |
} |
6235 |
} |
6236 |
|
6237 |
// Append elements to a provided document fragment |
6238 |
if ( fragment ) { |
6239 |
// Special handling of each script element |
6240 |
handleScript = function( elem ) { |
6241 |
// Check if we consider it executable |
6242 |
if ( !elem.type || rscriptType.test( elem.type ) ) { |
6243 |
// Detach the script and store it in the scripts array (if provided) or the fragment |
6244 |
// Return truthy to indicate that it has been handled |
6245 |
return scripts ? |
6246 |
scripts.push( elem.parentNode ? elem.parentNode.removeChild( elem ) : elem ) : |
6247 |
fragment.appendChild( elem ); |
6248 |
} |
6249 |
}; |
6250 |
|
6251 |
for ( i = 0; (elem = ret[i]) != null; i++ ) { |
6252 |
// Check if we're done after handling an executable script |
6253 |
if ( !( jQuery.nodeName( elem, "script" ) && handleScript( elem ) ) ) { |
6254 |
// Append to fragment and handle embedded scripts |
6255 |
fragment.appendChild( elem ); |
6256 |
if ( typeof elem.getElementsByTagName !== "undefined" ) { |
6257 |
// handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration |
6258 |
jsTags = jQuery.grep( jQuery.merge( [], elem.getElementsByTagName("script") ), handleScript ); |
6259 |
|
6260 |
// Splice the scripts into ret after their former ancestor and advance our index beyond them |
6261 |
ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) ); |
6262 |
i += jsTags.length; |
6263 |
} |
6264 |
} |
6265 |
} |
6266 |
} |
6267 |
|
6268 |
return ret; |
6269 |
}, |
6270 |
|
6271 |
cleanData: function( elems, /* internal */ acceptData ) { |
6272 |
var data, id, elem, type, |
6273 |
i = 0, |
6274 |
internalKey = jQuery.expando, |
6275 |
cache = jQuery.cache, |
6276 |
deleteExpando = jQuery.support.deleteExpando, |
6277 |
special = jQuery.event.special; |
6278 |
|
6279 |
for ( ; (elem = elems[i]) != null; i++ ) { |
6280 |
|
6281 |
if ( acceptData || jQuery.acceptData( elem ) ) { |
6282 |
|
6283 |
id = elem[ internalKey ]; |
6284 |
data = id && cache[ id ]; |
6285 |
|
6286 |
if ( data ) { |
6287 |
if ( data.events ) { |
6288 |
for ( type in data.events ) { |
6289 |
if ( special[ type ] ) { |
6290 |
jQuery.event.remove( elem, type ); |
6291 |
|
6292 |
// This is a shortcut to avoid jQuery.event.remove's overhead |
6293 |
} else { |
6294 |
jQuery.removeEvent( elem, type, data.handle ); |
6295 |
} |
6296 |
} |
6297 |
} |
6298 |
|
6299 |
// Remove cache only if it was not already removed by jQuery.event.remove |
6300 |
if ( cache[ id ] ) { |
6301 |
|
6302 |
delete cache[ id ]; |
6303 |
|
6304 |
// IE does not allow us to delete expando properties from nodes, |
6305 |
// nor does it have a removeAttribute function on Document nodes; |
6306 |
// we must handle all of these cases |
6307 |
if ( deleteExpando ) { |
6308 |
delete elem[ internalKey ]; |
6309 |
|
6310 |
} else if ( elem.removeAttribute ) { |
6311 |
elem.removeAttribute( internalKey ); |
6312 |
|
6313 |
} else { |
6314 |
elem[ internalKey ] = null; |
6315 |
} |
6316 |
|
6317 |
jQuery.deletedIds.push( id ); |
6318 |
} |
6319 |
} |
6320 |
} |
6321 |
} |
6322 |
} |
6323 |
}); |
6324 |
// Limit scope pollution from any deprecated API |
6325 |
(function() { |
6326 |
|
6327 |
var matched, browser; |
6328 |
|
6329 |
// Use of jQuery.browser is frowned upon. |
6330 |
// More details: http://api.jquery.com/jQuery.browser |
6331 |
// jQuery.uaMatch maintained for back-compat |
6332 |
jQuery.uaMatch = function( ua ) { |
6333 |
ua = ua.toLowerCase(); |
6334 |
|
6335 |
var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) || |
6336 |
/(webkit)[ \/]([\w.]+)/.exec( ua ) || |
6337 |
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) || |
6338 |
/(msie) ([\w.]+)/.exec( ua ) || |
6339 |
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) || |
6340 |
[]; |
6341 |
|
6342 |
return { |
6343 |
browser: match[ 1 ] || "", |
6344 |
version: match[ 2 ] || "0" |
6345 |
}; |
6346 |
}; |
6347 |
|
6348 |
matched = jQuery.uaMatch( navigator.userAgent ); |
6349 |
browser = {}; |
6350 |
|
6351 |
if ( matched.browser ) { |
6352 |
browser[ matched.browser ] = true; |
6353 |
browser.version = matched.version; |
6354 |
} |
6355 |
|
6356 |
// Chrome is Webkit, but Webkit is also Safari. |
6357 |
if ( browser.chrome ) { |
6358 |
browser.webkit = true; |
6359 |
} else if ( browser.webkit ) { |
6360 |
browser.safari = true; |
6361 |
} |
6362 |
|
6363 |
jQuery.browser = browser; |
6364 |
|
6365 |
jQuery.sub = function() { |
6366 |
function jQuerySub( selector, context ) { |
6367 |
return new jQuerySub.fn.init( selector, context ); |
6368 |
} |
6369 |
jQuery.extend( true, jQuerySub, this ); |
6370 |
jQuerySub.superclass = this; |
6371 |
jQuerySub.fn = jQuerySub.prototype = this(); |
6372 |
jQuerySub.fn.constructor = jQuerySub; |
6373 |
jQuerySub.sub = this.sub; |
6374 |
jQuerySub.fn.init = function init( selector, context ) { |
6375 |
if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) { |
6376 |
context = jQuerySub( context ); |
6377 |
} |
6378 |
|
6379 |
return jQuery.fn.init.call( this, selector, context, rootjQuerySub ); |
6380 |
}; |
6381 |
jQuerySub.fn.init.prototype = jQuerySub.fn; |
6382 |
var rootjQuerySub = jQuerySub(document); |
6383 |
return jQuerySub; |
6384 |
}; |
6385 |
|
6386 |
})(); |
6387 |
var curCSS, iframe, iframeDoc, |
6388 |
ralpha = /alpha\([^)]*\)/i, |
6389 |
ropacity = /opacity=([^)]*)/, |
6390 |
rposition = /^(top|right|bottom|left)$/, |
6391 |
// swappable if display is none or starts with table except "table", "table-cell", or "table-caption" |
6392 |
// see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display |
6393 |
rdisplayswap = /^(none|table(?!-c[ea]).+)/, |
6394 |
rmargin = /^margin/, |
6395 |
rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ), |
6396 |
rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ), |
6397 |
rrelNum = new RegExp( "^([-+])=(" + core_pnum + ")", "i" ), |
6398 |
elemdisplay = {}, |
6399 |
|
6400 |
cssShow = { position: "absolute", visibility: "hidden", display: "block" }, |
6401 |
cssNormalTransform = { |
6402 |
letterSpacing: 0, |
6403 |
fontWeight: 400 |
6404 |
}, |
6405 |
|
6406 |
cssExpand = [ "Top", "Right", "Bottom", "Left" ], |
6407 |
cssPrefixes = [ "Webkit", "O", "Moz", "ms" ], |
6408 |
|
6409 |
eventsToggle = jQuery.fn.toggle; |
6410 |
|
6411 |
// return a css property mapped to a potentially vendor prefixed property |
6412 |
function vendorPropName( style, name ) { |
6413 |
|
6414 |
// shortcut for names that are not vendor prefixed |
6415 |
if ( name in style ) { |
6416 |
return name; |
6417 |
} |
6418 |
|
6419 |
// check for vendor prefixed names |
6420 |
var capName = name.charAt(0).toUpperCase() + name.slice(1), |
6421 |
origName = name, |
6422 |
i = cssPrefixes.length; |
6423 |
|
6424 |
while ( i-- ) { |
6425 |
name = cssPrefixes[ i ] + capName; |
6426 |
if ( name in style ) { |
6427 |
return name; |
6428 |
} |
6429 |
} |
6430 |
|
6431 |
return origName; |
6432 |
} |
6433 |
|
6434 |
function isHidden( elem, el ) { |
6435 |
elem = el || elem; |
6436 |
return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem ); |
6437 |
} |
6438 |
|
6439 |
function showHide( elements, show ) { |
6440 |
var elem, display, |
6441 |
values = [], |
6442 |
index = 0, |
6443 |
length = elements.length; |
6444 |
|
6445 |
for ( ; index < length; index++ ) { |
6446 |
elem = elements[ index ]; |
6447 |
if ( !elem.style ) { |
6448 |
continue; |
6449 |
} |
6450 |
values[ index ] = jQuery._data( elem, "olddisplay" ); |
6451 |
if ( show ) { |
6452 |
// Reset the inline display of this element to learn if it is |
6453 |
// being hidden by cascaded rules or not |
6454 |
if ( !values[ index ] && elem.style.display === "none" ) { |
6455 |
elem.style.display = ""; |
6456 |
} |
6457 |
|
6458 |
// Set elements which have been overridden with display: none |
6459 |
// in a stylesheet to whatever the default browser style is |
6460 |
// for such an element |
6461 |
if ( elem.style.display === "" && isHidden( elem ) ) { |
6462 |
values[ index ] = jQuery._data( elem, "olddisplay", css_defaultDisplay(elem.nodeName) ); |
6463 |
} |
6464 |
} else { |
6465 |
display = curCSS( elem, "display" ); |
6466 |
|
6467 |
if ( !values[ index ] && display !== "none" ) { |
6468 |
jQuery._data( elem, "olddisplay", display ); |
6469 |
} |
6470 |
} |
6471 |
} |
6472 |
|
6473 |
// Set the display of most of the elements in a second loop |
6474 |
// to avoid the constant reflow |
6475 |
for ( index = 0; index < length; index++ ) { |
6476 |
elem = elements[ index ]; |
6477 |
if ( !elem.style ) { |
6478 |
continue; |
6479 |
} |
6480 |
if ( !show || elem.style.display === "none" || elem.style.display === "" ) { |
6481 |
elem.style.display = show ? values[ index ] || "" : "none"; |
6482 |
} |
6483 |
} |
6484 |
|
6485 |
return elements; |
6486 |
} |
6487 |
|
6488 |
jQuery.fn.extend({ |
6489 |
css: function( name, value ) { |
6490 |
return jQuery.access( this, function( elem, name, value ) { |
6491 |
return value !== undefined ? |
6492 |
jQuery.style( elem, name, value ) : |
6493 |
jQuery.css( elem, name ); |
6494 |
}, name, value, arguments.length > 1 ); |
6495 |
}, |
6496 |
show: function() { |
6497 |
return showHide( this, true ); |
6498 |
}, |
6499 |
hide: function() { |
6500 |
return showHide( this ); |
6501 |
}, |
6502 |
toggle: function( state, fn2 ) { |
6503 |
var bool = typeof state === "boolean"; |
6504 |
|
6505 |
if ( jQuery.isFunction( state ) && jQuery.isFunction( fn2 ) ) { |
6506 |
return eventsToggle.apply( this, arguments ); |
6507 |
} |
6508 |
|
6509 |
return this.each(function() { |
6510 |
if ( bool ? state : isHidden( this ) ) { |
6511 |
jQuery( this ).show(); |
6512 |
} else { |
6513 |
jQuery( this ).hide(); |
6514 |
} |
6515 |
}); |
6516 |
} |
6517 |
}); |
6518 |
|
6519 |
jQuery.extend({ |
6520 |
// Add in style property hooks for overriding the default |
6521 |
// behavior of getting and setting a style property |
6522 |
cssHooks: { |
6523 |
opacity: { |
6524 |
get: function( elem, computed ) { |
6525 |
if ( computed ) { |
6526 |
// We should always get a number back from opacity |
6527 |
var ret = curCSS( elem, "opacity" ); |
6528 |
return ret === "" ? "1" : ret; |
6529 |
|
6530 |
} |
6531 |
} |
6532 |
} |
6533 |
}, |
6534 |
|
6535 |
// Exclude the following css properties to add px |
6536 |
cssNumber: { |
6537 |
"fillOpacity": true, |
6538 |
"fontWeight": true, |
6539 |
"lineHeight": true, |
6540 |
"opacity": true, |
6541 |
"orphans": true, |
6542 |
"widows": true, |
6543 |
"zIndex": true, |
6544 |
"zoom": true |
6545 |
}, |
6546 |
|
6547 |
// Add in properties whose names you wish to fix before |
6548 |
// setting or getting the value |
6549 |
cssProps: { |
6550 |
// normalize float css property |
6551 |
"float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat" |
6552 |
}, |
6553 |
|
6554 |
// Get and set the style property on a DOM Node |
6555 |
style: function( elem, name, value, extra ) { |
6556 |
// Don't set styles on text and comment nodes |
6557 |
if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { |
6558 |
return; |
6559 |
} |
6560 |
|
6561 |
// Make sure that we're working with the right name |
6562 |
var ret, type, hooks, |
6563 |
origName = jQuery.camelCase( name ), |
6564 |
style = elem.style; |
6565 |
|
6566 |
name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) ); |
6567 |
|
6568 |
// gets hook for the prefixed version |
6569 |
// followed by the unprefixed version |
6570 |
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; |
6571 |
|
6572 |
// Check if we're setting a value |
6573 |
if ( value !== undefined ) { |
6574 |
type = typeof value; |
6575 |
|
6576 |
// convert relative number strings (+= or -=) to relative numbers. #7345 |
6577 |
if ( type === "string" && (ret = rrelNum.exec( value )) ) { |
6578 |
value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) ); |
6579 |
// Fixes bug #9237 |
6580 |
type = "number"; |
6581 |
} |
6582 |
|
6583 |
// Make sure that NaN and null values aren't set. See: #7116 |
6584 |
if ( value == null || type === "number" && isNaN( value ) ) { |
6585 |
return; |
6586 |
} |
6587 |
|
6588 |
// If a number was passed in, add 'px' to the (except for certain CSS properties) |
6589 |
if ( type === "number" && !jQuery.cssNumber[ origName ] ) { |
6590 |
value += "px"; |
6591 |
} |
6592 |
|
6593 |
// If a hook was provided, use that value, otherwise just set the specified value |
6594 |
if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) { |
6595 |
// Wrapped to prevent IE from throwing errors when 'invalid' values are provided |
6596 |
// Fixes bug #5509 |
6597 |
try { |
6598 |
style[ name ] = value; |
6599 |
} catch(e) {} |
6600 |
} |
6601 |
|
6602 |
} else { |
6603 |
// If a hook was provided get the non-computed value from there |
6604 |
if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) { |
6605 |
return ret; |
6606 |
} |
6607 |
|
6608 |
// Otherwise just get the value from the style object |
6609 |
return style[ name ]; |
6610 |
} |
6611 |
}, |
6612 |
|
6613 |
css: function( elem, name, numeric, extra ) { |
6614 |
var val, num, hooks, |
6615 |
origName = jQuery.camelCase( name ); |
6616 |
|
6617 |
// Make sure that we're working with the right name |
6618 |
name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) ); |
6619 |
|
6620 |
// gets hook for the prefixed version |
6621 |
// followed by the unprefixed version |
6622 |
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; |
6623 |
|
6624 |
// If a hook was provided get the computed value from there |
6625 |
if ( hooks && "get" in hooks ) { |
6626 |
val = hooks.get( elem, true, extra ); |
6627 |
} |
6628 |
|
6629 |
// Otherwise, if a way to get the computed value exists, use that |
6630 |
if ( val === undefined ) { |
6631 |
val = curCSS( elem, name ); |
6632 |
} |
6633 |
|
6634 |
//convert "normal" to computed value |
6635 |
if ( val === "normal" && name in cssNormalTransform ) { |
6636 |
val = cssNormalTransform[ name ]; |
6637 |
} |
6638 |
|
6639 |
// Return, converting to number if forced or a qualifier was provided and val looks numeric |
6640 |
if ( numeric || extra !== undefined ) { |
6641 |
num = parseFloat( val ); |
6642 |
return numeric || jQuery.isNumeric( num ) ? num || 0 : val; |
6643 |
} |
6644 |
return val; |
6645 |
}, |
6646 |
|
6647 |
// A method for quickly swapping in/out CSS properties to get correct calculations |
6648 |
swap: function( elem, options, callback ) { |
6649 |
var ret, name, |
6650 |
old = {}; |
6651 |
|
6652 |
// Remember the old values, and insert the new ones |
6653 |
for ( name in options ) { |
6654 |
old[ name ] = elem.style[ name ]; |
6655 |
elem.style[ name ] = options[ name ]; |
6656 |
} |
6657 |
|
6658 |
ret = callback.call( elem ); |
6659 |
|
6660 |
// Revert the old values |
6661 |
for ( name in options ) { |
6662 |
elem.style[ name ] = old[ name ]; |
6663 |
} |
6664 |
|
6665 |
return ret; |
6666 |
} |
6667 |
}); |
6668 |
|
6669 |
// NOTE: To any future maintainer, we've window.getComputedStyle |
6670 |
// because jsdom on node.js will break without it. |
6671 |
if ( window.getComputedStyle ) { |
6672 |
curCSS = function( elem, name ) { |
6673 |
var ret, width, minWidth, maxWidth, |
6674 |
computed = window.getComputedStyle( elem, null ), |
6675 |
style = elem.style; |
6676 |
|
6677 |
if ( computed ) { |
6678 |
|
6679 |
ret = computed[ name ]; |
6680 |
if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) { |
6681 |
ret = jQuery.style( elem, name ); |
6682 |
} |
6683 |
|
6684 |
// A tribute to the "awesome hack by Dean Edwards" |
6685 |
// Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right |
6686 |
// Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels |
6687 |
// this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values |
6688 |
if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) { |
6689 |
width = style.width; |
6690 |
minWidth = style.minWidth; |
6691 |
maxWidth = style.maxWidth; |
6692 |
|
6693 |
style.minWidth = style.maxWidth = style.width = ret; |
6694 |
ret = computed.width; |
6695 |
|
6696 |
style.width = width; |
6697 |
style.minWidth = minWidth; |
6698 |
style.maxWidth = maxWidth; |
6699 |
} |
6700 |
} |
6701 |
|
6702 |
return ret; |
6703 |
}; |
6704 |
} else if ( document.documentElement.currentStyle ) { |
6705 |
curCSS = function( elem, name ) { |
6706 |
var left, rsLeft, |
6707 |
ret = elem.currentStyle && elem.currentStyle[ name ], |
6708 |
style = elem.style; |
6709 |
|
6710 |
// Avoid setting ret to empty string here |
6711 |
// so we don't default to auto |
6712 |
if ( ret == null && style && style[ name ] ) { |
6713 |
ret = style[ name ]; |
6714 |
} |
6715 |
|
6716 |
// From the awesome hack by Dean Edwards |
6717 |
// http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 |
6718 |
|
6719 |
// If we're not dealing with a regular pixel number |
6720 |
// but a number that has a weird ending, we need to convert it to pixels |
6721 |
// but not position css attributes, as those are proportional to the parent element instead |
6722 |
// and we can't measure the parent instead because it might trigger a "stacking dolls" problem |
6723 |
if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) { |
6724 |
|
6725 |
// Remember the original values |
6726 |
left = style.left; |
6727 |
rsLeft = elem.runtimeStyle && elem.runtimeStyle.left; |
6728 |
|
6729 |
// Put in the new values to get a computed value out |
6730 |
if ( rsLeft ) { |
6731 |
elem.runtimeStyle.left = elem.currentStyle.left; |
6732 |
} |
6733 |
style.left = name === "fontSize" ? "1em" : ret; |
6734 |
ret = style.pixelLeft + "px"; |
6735 |
|
6736 |
// Revert the changed values |
6737 |
style.left = left; |
6738 |
if ( rsLeft ) { |
6739 |
elem.runtimeStyle.left = rsLeft; |
6740 |
} |
6741 |
} |
6742 |
|
6743 |
return ret === "" ? "auto" : ret; |
6744 |
}; |
6745 |
} |
6746 |
|
6747 |
function setPositiveNumber( elem, value, subtract ) { |
6748 |
var matches = rnumsplit.exec( value ); |
6749 |
return matches ? |
6750 |
Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) : |
6751 |
value; |
6752 |
} |
6753 |
|
6754 |
function augmentWidthOrHeight( elem, name, extra, isBorderBox ) { |
6755 |
var i = extra === ( isBorderBox ? "border" : "content" ) ? |
6756 |
// If we already have the right measurement, avoid augmentation |
6757 |
4 : |
6758 |
// Otherwise initialize for horizontal or vertical properties |
6759 |
name === "width" ? 1 : 0, |
6760 |
|
6761 |
val = 0; |
6762 |
|
6763 |
for ( ; i < 4; i += 2 ) { |
6764 |
// both box models exclude margin, so add it if we want it |
6765 |
if ( extra === "margin" ) { |
6766 |
// we use jQuery.css instead of curCSS here |
6767 |
// because of the reliableMarginRight CSS hook! |
6768 |
val += jQuery.css( elem, extra + cssExpand[ i ], true ); |
6769 |
} |
6770 |
|
6771 |
// From this point on we use curCSS for maximum performance (relevant in animations) |
6772 |
if ( isBorderBox ) { |
6773 |
// border-box includes padding, so remove it if we want content |
6774 |
if ( extra === "content" ) { |
6775 |
val -= parseFloat( curCSS( elem, "padding" + cssExpand[ i ] ) ) || 0; |
6776 |
} |
6777 |
|
6778 |
// at this point, extra isn't border nor margin, so remove border |
6779 |
if ( extra !== "margin" ) { |
6780 |
val -= parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0; |
6781 |
} |
6782 |
} else { |
6783 |
// at this point, extra isn't content, so add padding |
6784 |
val += parseFloat( curCSS( elem, "padding" + cssExpand[ i ] ) ) || 0; |
6785 |
|
6786 |
// at this point, extra isn't content nor padding, so add border |
6787 |
if ( extra !== "padding" ) { |
6788 |
val += parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0; |
6789 |
} |
6790 |
} |
6791 |
} |
6792 |
|
6793 |
return val; |
6794 |
} |
6795 |
|
6796 |
function getWidthOrHeight( elem, name, extra ) { |
6797 |
|
6798 |
// Start with offset property, which is equivalent to the border-box value |
6799 |
var val = name === "width" ? elem.offsetWidth : elem.offsetHeight, |
6800 |
valueIsBorderBox = true, |
6801 |
isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box"; |
6802 |
|
6803 |
// some non-html elements return undefined for offsetWidth, so check for null/undefined |
6804 |
// svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 |
6805 |
// MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668 |
6806 |
if ( val <= 0 || val == null ) { |
6807 |
// Fall back to computed then uncomputed css if necessary |
6808 |
val = curCSS( elem, name ); |
6809 |
if ( val < 0 || val == null ) { |
6810 |
val = elem.style[ name ]; |
6811 |
} |
6812 |
|
6813 |
// Computed unit is not pixels. Stop here and return. |
6814 |
if ( rnumnonpx.test(val) ) { |
6815 |
return val; |
6816 |
} |
6817 |
|
6818 |
// we need the check for style in case a browser which returns unreliable values |
6819 |
// for getComputedStyle silently falls back to the reliable elem.style |
6820 |
valueIsBorderBox = isBorderBox && ( jQuery.support.boxSizingReliable || val === elem.style[ name ] ); |
6821 |
|
6822 |
// Normalize "", auto, and prepare for extra |
6823 |
val = parseFloat( val ) || 0; |
6824 |
} |
6825 |
|
6826 |
// use the active box-sizing model to add/subtract irrelevant styles |
6827 |
return ( val + |
6828 |
augmentWidthOrHeight( |
6829 |
elem, |
6830 |
name, |
6831 |
extra || ( isBorderBox ? "border" : "content" ), |
6832 |
valueIsBorderBox |
6833 |
) |
6834 |
) + "px"; |
6835 |
} |
6836 |
|
6837 |
|
6838 |
// Try to determine the default display value of an element |
6839 |
function css_defaultDisplay( nodeName ) { |
6840 |
if ( elemdisplay[ nodeName ] ) { |
6841 |
return elemdisplay[ nodeName ]; |
6842 |
} |
6843 |
|
6844 |
var elem = jQuery( "<" + nodeName + ">" ).appendTo( document.body ), |
6845 |
display = elem.css("display"); |
6846 |
elem.remove(); |
6847 |
|
6848 |
// If the simple way fails, |
6849 |
// get element's real default display by attaching it to a temp iframe |
6850 |
if ( display === "none" || display === "" ) { |
6851 |
// Use the already-created iframe if possible |
6852 |
iframe = document.body.appendChild( |
6853 |
iframe || jQuery.extend( document.createElement("iframe"), { |
6854 |
frameBorder: 0, |
6855 |
width: 0, |
6856 |
height: 0 |
6857 |
}) |
6858 |
); |
6859 |
|
6860 |
// Create a cacheable copy of the iframe document on first call. |
6861 |
// IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML |
6862 |
// document to it; WebKit & Firefox won't allow reusing the iframe document. |
6863 |
if ( !iframeDoc || !iframe.createElement ) { |
6864 |
iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document; |
6865 |
iframeDoc.write("<!doctype html><html><body>"); |
6866 |
iframeDoc.close(); |
6867 |
} |
6868 |
|
6869 |
elem = iframeDoc.body.appendChild( iframeDoc.createElement(nodeName) ); |
6870 |
|
6871 |
display = curCSS( elem, "display" ); |
6872 |
document.body.removeChild( iframe ); |
6873 |
} |
6874 |
|
6875 |
// Store the correct default display |
6876 |
elemdisplay[ nodeName ] = display; |
6877 |
|
6878 |
return display; |
6879 |
} |
6880 |
|
6881 |
jQuery.each([ "height", "width" ], function( i, name ) { |
6882 |
jQuery.cssHooks[ name ] = { |
6883 |
get: function( elem, computed, extra ) { |
6884 |
if ( computed ) { |
6885 |
// certain elements can have dimension info if we invisibly show them |
6886 |
// however, it must have a current display style that would benefit from this |
6887 |
if ( elem.offsetWidth === 0 && rdisplayswap.test( curCSS( elem, "display" ) ) ) { |
6888 |
return jQuery.swap( elem, cssShow, function() { |
6889 |
return getWidthOrHeight( elem, name, extra ); |
6890 |
}); |
6891 |
} else { |
6892 |
return getWidthOrHeight( elem, name, extra ); |
6893 |
} |
6894 |
} |
6895 |
}, |
6896 |
|
6897 |
set: function( elem, value, extra ) { |
6898 |
return setPositiveNumber( elem, value, extra ? |
6899 |
augmentWidthOrHeight( |
6900 |
elem, |
6901 |
name, |
6902 |
extra, |
6903 |
jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box" |
6904 |
) : 0 |
6905 |
); |
6906 |
} |
6907 |
}; |
6908 |
}); |
6909 |
|
6910 |
if ( !jQuery.support.opacity ) { |
6911 |
jQuery.cssHooks.opacity = { |
6912 |
get: function( elem, computed ) { |
6913 |
// IE uses filters for opacity |
6914 |
return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ? |
6915 |
( 0.01 * parseFloat( RegExp.$1 ) ) + "" : |
6916 |
computed ? "1" : ""; |
6917 |
}, |
6918 |
|
6919 |
set: function( elem, value ) { |
6920 |
var style = elem.style, |
6921 |
currentStyle = elem.currentStyle, |
6922 |
opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "", |
6923 |
filter = currentStyle && currentStyle.filter || style.filter || ""; |
6924 |
|
6925 |
// IE has trouble with opacity if it does not have layout |
6926 |
// Force it by setting the zoom level |
6927 |
style.zoom = 1; |
6928 |
|
6929 |
// if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652 |
6930 |
if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" && |
6931 |
style.removeAttribute ) { |
6932 |
|
6933 |
// Setting style.filter to null, "" & " " still leave "filter:" in the cssText |
6934 |
// if "filter:" is present at all, clearType is disabled, we want to avoid this |
6935 |
// style.removeAttribute is IE Only, but so apparently is this code path... |
6936 |
style.removeAttribute( "filter" ); |
6937 |
|
6938 |
// if there there is no filter style applied in a css rule, we are done |
6939 |
if ( currentStyle && !currentStyle.filter ) { |
6940 |
return; |
6941 |
} |
6942 |
} |
6943 |
|
6944 |
// otherwise, set new filter values |
6945 |
style.filter = ralpha.test( filter ) ? |
6946 |
filter.replace( ralpha, opacity ) : |
6947 |
filter + " " + opacity; |
6948 |
} |
6949 |
}; |
6950 |
} |
6951 |
|
6952 |
// These hooks cannot be added until DOM ready because the support test |
6953 |
// for it is not run until after DOM ready |
6954 |
jQuery(function() { |
6955 |
if ( !jQuery.support.reliableMarginRight ) { |
6956 |
jQuery.cssHooks.marginRight = { |
6957 |
get: function( elem, computed ) { |
6958 |
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right |
6959 |
// Work around by temporarily setting element display to inline-block |
6960 |
return jQuery.swap( elem, { "display": "inline-block" }, function() { |
6961 |
if ( computed ) { |
6962 |
return curCSS( elem, "marginRight" ); |
6963 |
} |
6964 |
}); |
6965 |
} |
6966 |
}; |
6967 |
} |
6968 |
|
6969 |
// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084 |
6970 |
// getComputedStyle returns percent when specified for top/left/bottom/right |
6971 |
// rather than make the css module depend on the offset module, we just check for it here |
6972 |
if ( !jQuery.support.pixelPosition && jQuery.fn.position ) { |
6973 |
jQuery.each( [ "top", "left" ], function( i, prop ) { |
6974 |
jQuery.cssHooks[ prop ] = { |
6975 |
get: function( elem, computed ) { |
6976 |
if ( computed ) { |
6977 |
var ret = curCSS( elem, prop ); |
6978 |
// if curCSS returns percentage, fallback to offset |
6979 |
return rnumnonpx.test( ret ) ? jQuery( elem ).position()[ prop ] + "px" : ret; |
6980 |
} |
6981 |
} |
6982 |
}; |
6983 |
}); |
6984 |
} |
6985 |
|
6986 |
}); |
6987 |
|
6988 |
if ( jQuery.expr && jQuery.expr.filters ) { |
6989 |
jQuery.expr.filters.hidden = function( elem ) { |
6990 |
return ( elem.offsetWidth === 0 && elem.offsetHeight === 0 ) || (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || curCSS( elem, "display" )) === "none"); |
6991 |
}; |
6992 |
|
6993 |
jQuery.expr.filters.visible = function( elem ) { |
6994 |
return !jQuery.expr.filters.hidden( elem ); |
6995 |
}; |
6996 |
} |
6997 |
|
6998 |
// These hooks are used by animate to expand properties |
6999 |
jQuery.each({ |
7000 |
margin: "", |
7001 |
padding: "", |
7002 |
border: "Width" |
7003 |
}, function( prefix, suffix ) { |
7004 |
jQuery.cssHooks[ prefix + suffix ] = { |
7005 |
expand: function( value ) { |
7006 |
var i, |
7007 |
|
7008 |
// assumes a single number if not a string |
7009 |
parts = typeof value === "string" ? value.split(" ") : [ value ], |
7010 |
expanded = {}; |
7011 |
|
7012 |
for ( i = 0; i < 4; i++ ) { |
7013 |
expanded[ prefix + cssExpand[ i ] + suffix ] = |
7014 |
parts[ i ] || parts[ i - 2 ] || parts[ 0 ]; |
7015 |
} |
7016 |
|
7017 |
return expanded; |
7018 |
} |
7019 |
}; |
7020 |
|
7021 |
if ( !rmargin.test( prefix ) ) { |
7022 |
jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; |
7023 |
} |
7024 |
}); |
7025 |
var r20 = /%20/g, |
7026 |
rbracket = /\[\]$/, |
7027 |
rCRLF = /\r?\n/g, |
7028 |
rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i, |
7029 |
rselectTextarea = /^(?:select|textarea)/i; |
7030 |
|
7031 |
jQuery.fn.extend({ |
7032 |
serialize: function() { |
7033 |
return jQuery.param( this.serializeArray() ); |
7034 |
}, |
7035 |
serializeArray: function() { |
7036 |
return this.map(function(){ |
7037 |
return this.elements ? jQuery.makeArray( this.elements ) : this; |
7038 |
}) |
7039 |
.filter(function(){ |
7040 |
return this.name && !this.disabled && |
7041 |
( this.checked || rselectTextarea.test( this.nodeName ) || |
7042 |
rinput.test( this.type ) ); |
7043 |
}) |
7044 |
.map(function( i, elem ){ |
7045 |
var val = jQuery( this ).val(); |
7046 |
|
7047 |
return val == null ? |
7048 |
null : |
7049 |
jQuery.isArray( val ) ? |
7050 |
jQuery.map( val, function( val, i ){ |
7051 |
return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; |
7052 |
}) : |
7053 |
{ name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; |
7054 |
}).get(); |
7055 |
} |
7056 |
}); |
7057 |
|
7058 |
//Serialize an array of form elements or a set of |
7059 |
//key/values into a query string |
7060 |
jQuery.param = function( a, traditional ) { |
7061 |
var prefix, |
7062 |
s = [], |
7063 |
add = function( key, value ) { |
7064 |
// If value is a function, invoke it and return its value |
7065 |
value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value ); |
7066 |
s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value ); |
7067 |
}; |
7068 |
|
7069 |
// Set traditional to true for jQuery <= 1.3.2 behavior. |
7070 |
if ( traditional === undefined ) { |
7071 |
traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional; |
7072 |
} |
7073 |
|
7074 |
// If an array was passed in, assume that it is an array of form elements. |
7075 |
if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { |
7076 |
// Serialize the form elements |
7077 |
jQuery.each( a, function() { |
7078 |
add( this.name, this.value ); |
7079 |
}); |
7080 |
|
7081 |
} else { |
7082 |
// If traditional, encode the "old" way (the way 1.3.2 or older |
7083 |
// did it), otherwise encode params recursively. |
7084 |
for ( prefix in a ) { |
7085 |
buildParams( prefix, a[ prefix ], traditional, add ); |
7086 |
} |
7087 |
} |
7088 |
|
7089 |
// Return the resulting serialization |
7090 |
return s.join( "&" ).replace( r20, "+" ); |
7091 |
}; |
7092 |
|
7093 |
function buildParams( prefix, obj, traditional, add ) { |
7094 |
var name; |
7095 |
|
7096 |
if ( jQuery.isArray( obj ) ) { |
7097 |
// Serialize array item. |
7098 |
jQuery.each( obj, function( i, v ) { |
7099 |
if ( traditional || rbracket.test( prefix ) ) { |
7100 |
// Treat each array item as a scalar. |
7101 |
add( prefix, v ); |
7102 |
|
7103 |
} else { |
7104 |
// If array item is non-scalar (array or object), encode its |
7105 |
// numeric index to resolve deserialization ambiguity issues. |
7106 |
// Note that rack (as of 1.0.0) can't currently deserialize |
7107 |
// nested arrays properly, and attempting to do so may cause |
7108 |
// a server error. Possible fixes are to modify rack's |
7109 |
// deserialization algorithm or to provide an option or flag |
7110 |
// to force array serialization to be shallow. |
7111 |
buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add ); |
7112 |
} |
7113 |
}); |
7114 |
|
7115 |
} else if ( !traditional && jQuery.type( obj ) === "object" ) { |
7116 |
// Serialize object item. |
7117 |
for ( name in obj ) { |
7118 |
buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); |
7119 |
} |
7120 |
|
7121 |
} else { |
7122 |
// Serialize scalar item. |
7123 |
add( prefix, obj ); |
7124 |
} |
7125 |
} |
7126 |
var // Document location |
7127 |
ajaxLocation, |
7128 |
// Document location segments |
7129 |
ajaxLocParts, |
7130 |
|
7131 |
rhash = /#.*$/, |
7132 |
rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL |
7133 |
// #7653, #8125, #8152: local protocol detection |
7134 |
rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/, |
7135 |
rnoContent = /^(?:GET|HEAD)$/, |
7136 |
rprotocol = /^\/\//, |
7137 |
rquery = /\?/, |
7138 |
rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, |
7139 |
rts = /([?&])_=[^&]*/, |
7140 |
rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/, |
7141 |
|
7142 |
// Keep a copy of the old load method |
7143 |
_load = jQuery.fn.load, |
7144 |
|
7145 |
/* Prefilters |
7146 |
* 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) |
7147 |
* 2) These are called: |
7148 |
* - BEFORE asking for a transport |
7149 |
* - AFTER param serialization (s.data is a string if s.processData is true) |
7150 |
* 3) key is the dataType |
7151 |
* 4) the catchall symbol "*" can be used |
7152 |
* 5) execution will start with transport dataType and THEN continue down to "*" if needed |
7153 |
*/ |
7154 |
prefilters = {}, |
7155 |
|
7156 |
/* Transports bindings |
7157 |
* 1) key is the dataType |
7158 |
* 2) the catchall symbol "*" can be used |
7159 |
* 3) selection will start with transport dataType and THEN go to "*" if needed |
7160 |
*/ |
7161 |
transports = {}, |
7162 |
|
7163 |
// Avoid comment-prolog char sequence (#10098); must appease lint and evade compression |
7164 |
allTypes = ["*/"] + ["*"]; |
7165 |
|
7166 |
// #8138, IE may throw an exception when accessing |
7167 |
// a field from window.location if document.domain has been set |
7168 |
try { |
7169 |
ajaxLocation = location.href; |
7170 |
} catch( e ) { |
7171 |
// Use the href attribute of an A element |
7172 |
// since IE will modify it given document.location |
7173 |
ajaxLocation = document.createElement( "a" ); |
7174 |
ajaxLocation.href = ""; |
7175 |
ajaxLocation = ajaxLocation.href; |
7176 |
} |
7177 |
|
7178 |
// Segment location into parts |
7179 |
ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || []; |
7180 |
|
7181 |
// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport |
7182 |
function addToPrefiltersOrTransports( structure ) { |
7183 |
|
7184 |
// dataTypeExpression is optional and defaults to "*" |
7185 |
return function( dataTypeExpression, func ) { |
7186 |
|
7187 |
if ( typeof dataTypeExpression !== "string" ) { |
7188 |
func = dataTypeExpression; |
7189 |
dataTypeExpression = "*"; |
7190 |
} |
7191 |
|
7192 |
var dataType, list, placeBefore, |
7193 |
dataTypes = dataTypeExpression.toLowerCase().split( core_rspace ), |
7194 |
i = 0, |
7195 |
length = dataTypes.length; |
7196 |
|
7197 |
if ( jQuery.isFunction( func ) ) { |
7198 |
// For each dataType in the dataTypeExpression |
7199 |
for ( ; i < length; i++ ) { |
7200 |
dataType = dataTypes[ i ]; |
7201 |
// We control if we're asked to add before |
7202 |
// any existing element |
7203 |
placeBefore = /^\+/.test( dataType ); |
7204 |
if ( placeBefore ) { |
7205 |
dataType = dataType.substr( 1 ) || "*"; |
7206 |
} |
7207 |
list = structure[ dataType ] = structure[ dataType ] || []; |
7208 |
// then we add to the structure accordingly |
7209 |
list[ placeBefore ? "unshift" : "push" ]( func ); |
7210 |
} |
7211 |
} |
7212 |
}; |
7213 |
} |
7214 |
|
7215 |
// Base inspection function for prefilters and transports |
7216 |
function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR, |
7217 |
dataType /* internal */, inspected /* internal */ ) { |
7218 |
|
7219 |
dataType = dataType || options.dataTypes[ 0 ]; |
7220 |
inspected = inspected || {}; |
7221 |
|
7222 |
inspected[ dataType ] = true; |
7223 |
|
7224 |
var selection, |
7225 |
list = structure[ dataType ], |
7226 |
i = 0, |
7227 |
length = list ? list.length : 0, |
7228 |
executeOnly = ( structure === prefilters ); |
7229 |
|
7230 |
for ( ; i < length && ( executeOnly || !selection ); i++ ) { |
7231 |
selection = list[ i ]( options, originalOptions, jqXHR ); |
7232 |
// If we got redirected to another dataType |
7233 |
// we try there if executing only and not done already |
7234 |
if ( typeof selection === "string" ) { |
7235 |
if ( !executeOnly || inspected[ selection ] ) { |
7236 |
selection = undefined; |
7237 |
} else { |
7238 |
options.dataTypes.unshift( selection ); |
7239 |
selection = inspectPrefiltersOrTransports( |
7240 |
structure, options, originalOptions, jqXHR, selection, inspected ); |
7241 |
} |
7242 |
} |
7243 |
} |
7244 |
// If we're only executing or nothing was selected |
7245 |
// we try the catchall dataType if not done already |
7246 |
if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) { |
7247 |
selection = inspectPrefiltersOrTransports( |
7248 |
structure, options, originalOptions, jqXHR, "*", inspected ); |
7249 |
} |
7250 |
// unnecessary when only executing (prefilters) |
7251 |
// but it'll be ignored by the caller in that case |
7252 |
return selection; |
7253 |
} |
7254 |
|
7255 |
// A special extend for ajax options |
7256 |
// that takes "flat" options (not to be deep extended) |
7257 |
// Fixes #9887 |
7258 |
function ajaxExtend( target, src ) { |
7259 |
var key, deep, |
7260 |
flatOptions = jQuery.ajaxSettings.flatOptions || {}; |
7261 |
for ( key in src ) { |
7262 |
if ( src[ key ] !== undefined ) { |
7263 |
( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ]; |
7264 |
} |
7265 |
} |
7266 |
if ( deep ) { |
7267 |
jQuery.extend( true, target, deep ); |
7268 |
} |
7269 |
} |
7270 |
|
7271 |
jQuery.fn.load = function( url, params, callback ) { |
7272 |
if ( typeof url !== "string" && _load ) { |
7273 |
return _load.apply( this, arguments ); |
7274 |
} |
7275 |
|
7276 |
// Don't do a request if no elements are being requested |
7277 |
if ( !this.length ) { |
7278 |
return this; |
7279 |
} |
7280 |
|
7281 |
var selector, type, response, |
7282 |
self = this, |
7283 |
off = url.indexOf(" "); |
7284 |
|
7285 |
if ( off >= 0 ) { |
7286 |
selector = url.slice( off, url.length ); |
7287 |
url = url.slice( 0, off ); |
7288 |
} |
7289 |
|
7290 |
// If it's a function |
7291 |
if ( jQuery.isFunction( params ) ) { |
7292 |
|
7293 |
// We assume that it's the callback |
7294 |
callback = params; |
7295 |
params = undefined; |
7296 |
|
7297 |
// Otherwise, build a param string |
7298 |
} else if ( params && typeof params === "object" ) { |
7299 |
type = "POST"; |
7300 |
} |
7301 |
|
7302 |
// Request the remote document |
7303 |
jQuery.ajax({ |
7304 |
url: url, |
7305 |
|
7306 |
// if "type" variable is undefined, then "GET" method will be used |
7307 |
type: type, |
7308 |
dataType: "html", |
7309 |
data: params, |
7310 |
complete: function( jqXHR, status ) { |
7311 |
if ( callback ) { |
7312 |
self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] ); |
7313 |
} |
7314 |
} |
7315 |
}).done(function( responseText ) { |
7316 |
|
7317 |
// Save response for use in complete callback |
7318 |
response = arguments; |
7319 |
|
7320 |
// See if a selector was specified |
7321 |
self.html( selector ? |
7322 |
|
7323 |
// Create a dummy div to hold the results |
7324 |
jQuery("<div>") |
7325 |
|
7326 |
// inject the contents of the document in, removing the scripts |
7327 |
// to avoid any 'Permission Denied' errors in IE |
7328 |
.append( responseText.replace( rscript, "" ) ) |
7329 |
|
7330 |
// Locate the specified elements |
7331 |
.find( selector ) : |
7332 |
|
7333 |
// If not, just inject the full result |
7334 |
responseText ); |
7335 |
|
7336 |
}); |
7337 |
|
7338 |
return this; |
7339 |
}; |
7340 |
|
7341 |
// Attach a bunch of functions for handling common AJAX events |
7342 |
jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){ |
7343 |
jQuery.fn[ o ] = function( f ){ |
7344 |
return this.on( o, f ); |
7345 |
}; |
7346 |
}); |
7347 |
|
7348 |
jQuery.each( [ "get", "post" ], function( i, method ) { |
7349 |
jQuery[ method ] = function( url, data, callback, type ) { |
7350 |
// shift arguments if data argument was omitted |
7351 |
if ( jQuery.isFunction( data ) ) { |
7352 |
type = type || callback; |
7353 |
callback = data; |
7354 |
data = undefined; |
7355 |
} |
7356 |
|
7357 |
return jQuery.ajax({ |
7358 |
type: method, |
7359 |
url: url, |
7360 |
data: data, |
7361 |
success: callback, |
7362 |
dataType: type |
7363 |
}); |
7364 |
}; |
7365 |
}); |
7366 |
|
7367 |
jQuery.extend({ |
7368 |
|
7369 |
getScript: function( url, callback ) { |
7370 |
return jQuery.get( url, undefined, callback, "script" ); |
7371 |
}, |
7372 |
|
7373 |
getJSON: function( url, data, callback ) { |
7374 |
return jQuery.get( url, data, callback, "json" ); |
7375 |
}, |
7376 |
|
7377 |
// Creates a full fledged settings object into target |
7378 |
// with both ajaxSettings and settings fields. |
7379 |
// If target is omitted, writes into ajaxSettings. |
7380 |
ajaxSetup: function( target, settings ) { |
7381 |
if ( settings ) { |
7382 |
// Building a settings object |
7383 |
ajaxExtend( target, jQuery.ajaxSettings ); |
7384 |
} else { |
7385 |
// Extending ajaxSettings |
7386 |
settings = target; |
7387 |
target = jQuery.ajaxSettings; |
7388 |
} |
7389 |
ajaxExtend( target, settings ); |
7390 |
return target; |
7391 |
}, |
7392 |
|
7393 |
ajaxSettings: { |
7394 |
url: ajaxLocation, |
7395 |
isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ), |
7396 |
global: true, |
7397 |
type: "GET", |
7398 |
contentType: "application/x-www-form-urlencoded; charset=UTF-8", |
7399 |
processData: true, |
7400 |
async: true, |
7401 |
/* |
7402 |
timeout: 0, |
7403 |
data: null, |
7404 |
dataType: null, |
7405 |
username: null, |
7406 |
password: null, |
7407 |
cache: null, |
7408 |
throws: false, |
7409 |
traditional: false, |
7410 |
headers: {}, |
7411 |
*/ |
7412 |
|
7413 |
accepts: { |
7414 |
xml: "application/xml, text/xml", |
7415 |
html: "text/html", |
7416 |
text: "text/plain", |
7417 |
json: "application/json, text/javascript", |
7418 |
"*": allTypes |
7419 |
}, |
7420 |
|
7421 |
contents: { |
7422 |
xml: /xml/, |
7423 |
html: /html/, |
7424 |
json: /json/ |
7425 |
}, |
7426 |
|
7427 |
responseFields: { |
7428 |
xml: "responseXML", |
7429 |
text: "responseText" |
7430 |
}, |
7431 |
|
7432 |
// List of data converters |
7433 |
// 1) key format is "source_type destination_type" (a single space in-between) |
7434 |
// 2) the catchall symbol "*" can be used for source_type |
7435 |
converters: { |
7436 |
|
7437 |
// Convert anything to text |
7438 |
"* text": window.String, |
7439 |
|
7440 |
// Text to html (true = no transformation) |
7441 |
"text html": true, |
7442 |
|
7443 |
// Evaluate text as a json expression |
7444 |
"text json": jQuery.parseJSON, |
7445 |
|
7446 |
// Parse text as xml |
7447 |
"text xml": jQuery.parseXML |
7448 |
}, |
7449 |
|
7450 |
// For options that shouldn't be deep extended: |
7451 |
// you can add your own custom options here if |
7452 |
// and when you create one that shouldn't be |
7453 |
// deep extended (see ajaxExtend) |
7454 |
flatOptions: { |
7455 |
context: true, |
7456 |
url: true |
7457 |
} |
7458 |
}, |
7459 |
|
7460 |
ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), |
7461 |
ajaxTransport: addToPrefiltersOrTransports( transports ), |
7462 |
|
7463 |
// Main method |
7464 |
ajax: function( url, options ) { |
7465 |
|
7466 |
// If url is an object, simulate pre-1.5 signature |
7467 |
if ( typeof url === "object" ) { |
7468 |
options = url; |
7469 |
url = undefined; |
7470 |
} |
7471 |
|
7472 |
// Force options to be an object |
7473 |
options = options || {}; |
7474 |
|
7475 |
var // ifModified key |
7476 |
ifModifiedKey, |
7477 |
// Response headers |
7478 |
responseHeadersString, |
7479 |
responseHeaders, |
7480 |
// transport |
7481 |
transport, |
7482 |
// timeout handle |
7483 |
timeoutTimer, |
7484 |
// Cross-domain detection vars |
7485 |
parts, |
7486 |
// To know if global events are to be dispatched |
7487 |
fireGlobals, |
7488 |
// Loop variable |
7489 |
i, |
7490 |
// Create the final options object |
7491 |
s = jQuery.ajaxSetup( {}, options ), |
7492 |
// Callbacks context |
7493 |
callbackContext = s.context || s, |
7494 |
// Context for global events |
7495 |
// It's the callbackContext if one was provided in the options |
7496 |
// and if it's a DOM node or a jQuery collection |
7497 |
globalEventContext = callbackContext !== s && |
7498 |
( callbackContext.nodeType || callbackContext instanceof jQuery ) ? |
7499 |
jQuery( callbackContext ) : jQuery.event, |
7500 |
// Deferreds |
7501 |
deferred = jQuery.Deferred(), |
7502 |
completeDeferred = jQuery.Callbacks( "once memory" ), |
7503 |
// Status-dependent callbacks |
7504 |
statusCode = s.statusCode || {}, |
7505 |
// Headers (they are sent all at once) |
7506 |
requestHeaders = {}, |
7507 |
requestHeadersNames = {}, |
7508 |
// The jqXHR state |
7509 |
state = 0, |
7510 |
// Default abort message |
7511 |
strAbort = "canceled", |
7512 |
// Fake xhr |
7513 |
jqXHR = { |
7514 |
|
7515 |
readyState: 0, |
7516 |
|
7517 |
// Caches the header |
7518 |
setRequestHeader: function( name, value ) { |
7519 |
if ( !state ) { |
7520 |
var lname = name.toLowerCase(); |
7521 |
name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name; |
7522 |
requestHeaders[ name ] = value; |
7523 |
} |
7524 |
return this; |
7525 |
}, |
7526 |
|
7527 |
// Raw string |
7528 |
getAllResponseHeaders: function() { |
7529 |
return state === 2 ? responseHeadersString : null; |
7530 |
}, |
7531 |
|
7532 |
// Builds headers hashtable if needed |
7533 |
getResponseHeader: function( key ) { |
7534 |
var match; |
7535 |
if ( state === 2 ) { |
7536 |
if ( !responseHeaders ) { |
7537 |
responseHeaders = {}; |
7538 |
while( ( match = rheaders.exec( responseHeadersString ) ) ) { |
7539 |
responseHeaders[ match[1].toLowerCase() ] = match[ 2 ]; |
7540 |
} |
7541 |
} |
7542 |
match = responseHeaders[ key.toLowerCase() ]; |
7543 |
} |
7544 |
return match === undefined ? null : match; |
7545 |
}, |
7546 |
|
7547 |
// Overrides response content-type header |
7548 |
overrideMimeType: function( type ) { |
7549 |
if ( !state ) { |
7550 |
s.mimeType = type; |
7551 |
} |
7552 |
return this; |
7553 |
}, |
7554 |
|
7555 |
// Cancel the request |
7556 |
abort: function( statusText ) { |
7557 |
statusText = statusText || strAbort; |
7558 |
if ( transport ) { |
7559 |
transport.abort( statusText ); |
7560 |
} |
7561 |
done( 0, statusText ); |
7562 |
return this; |
7563 |
} |
7564 |
}; |
7565 |
|
7566 |
// Callback for when everything is done |
7567 |
// It is defined here because jslint complains if it is declared |
7568 |
// at the end of the function (which would be more logical and readable) |
7569 |
function done( status, nativeStatusText, responses, headers ) { |
7570 |
var isSuccess, success, error, response, modified, |
7571 |
statusText = nativeStatusText; |
7572 |
|
7573 |
// Called once |
7574 |
if ( state === 2 ) { |
7575 |
return; |
7576 |
} |
7577 |
|
7578 |
// State is "done" now |
7579 |
state = 2; |
7580 |
|
7581 |
// Clear timeout if it exists |
7582 |
if ( timeoutTimer ) { |
7583 |
clearTimeout( timeoutTimer ); |
7584 |
} |
7585 |
|
7586 |
// Dereference transport for early garbage collection |
7587 |
// (no matter how long the jqXHR object will be used) |
7588 |
transport = undefined; |
7589 |
|
7590 |
// Cache response headers |
7591 |
responseHeadersString = headers || ""; |
7592 |
|
7593 |
// Set readyState |
7594 |
jqXHR.readyState = status > 0 ? 4 : 0; |
7595 |
|
7596 |
// Get response data |
7597 |
if ( responses ) { |
7598 |
response = ajaxHandleResponses( s, jqXHR, responses ); |
7599 |
} |
7600 |
|
7601 |
// If successful, handle type chaining |
7602 |
if ( status >= 200 && status < 300 || status === 304 ) { |
7603 |
|
7604 |
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. |
7605 |
if ( s.ifModified ) { |
7606 |
|
7607 |
modified = jqXHR.getResponseHeader("Last-Modified"); |
7608 |
if ( modified ) { |
7609 |
jQuery.lastModified[ ifModifiedKey ] = modified; |
7610 |
} |
7611 |
modified = jqXHR.getResponseHeader("Etag"); |
7612 |
if ( modified ) { |
7613 |
jQuery.etag[ ifModifiedKey ] = modified; |
7614 |
} |
7615 |
} |
7616 |
|
7617 |
// If not modified |
7618 |
if ( status === 304 ) { |
7619 |
|
7620 |
statusText = "notmodified"; |
7621 |
isSuccess = true; |
7622 |
|
7623 |
// If we have data |
7624 |
} else { |
7625 |
|
7626 |
isSuccess = ajaxConvert( s, response ); |
7627 |
statusText = isSuccess.state; |
7628 |
success = isSuccess.data; |
7629 |
error = isSuccess.error; |
7630 |
isSuccess = !error; |
7631 |
} |
7632 |
} else { |
7633 |
// We extract error from statusText |
7634 |
// then normalize statusText and status for non-aborts |
7635 |
error = statusText; |
7636 |
if ( !statusText || status ) { |
7637 |
statusText = "error"; |
7638 |
if ( status < 0 ) { |
7639 |
status = 0; |
7640 |
} |
7641 |
} |
7642 |
} |
7643 |
|
7644 |
// Set data for the fake xhr object |
7645 |
jqXHR.status = status; |
7646 |
jqXHR.statusText = "" + ( nativeStatusText || statusText ); |
7647 |
|
7648 |
// Success/Error |
7649 |
if ( isSuccess ) { |
7650 |
deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); |
7651 |
} else { |
7652 |
deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); |
7653 |
} |
7654 |
|
7655 |
// Status-dependent callbacks |
7656 |
jqXHR.statusCode( statusCode ); |
7657 |
statusCode = undefined; |
7658 |
|
7659 |
if ( fireGlobals ) { |
7660 |
globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ), |
7661 |
[ jqXHR, s, isSuccess ? success : error ] ); |
7662 |
} |
7663 |
|
7664 |
// Complete |
7665 |
completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] ); |
7666 |
|
7667 |
if ( fireGlobals ) { |
7668 |
globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); |
7669 |
// Handle the global AJAX counter |
7670 |
if ( !( --jQuery.active ) ) { |
7671 |
jQuery.event.trigger( "ajaxStop" ); |
7672 |
} |
7673 |
} |
7674 |
} |
7675 |
|
7676 |
// Attach deferreds |
7677 |
deferred.promise( jqXHR ); |
7678 |
jqXHR.success = jqXHR.done; |
7679 |
jqXHR.error = jqXHR.fail; |
7680 |
jqXHR.complete = completeDeferred.add; |
7681 |
|
7682 |
// Status-dependent callbacks |
7683 |
jqXHR.statusCode = function( map ) { |
7684 |
if ( map ) { |
7685 |
var tmp; |
7686 |
if ( state < 2 ) { |
7687 |
for ( tmp in map ) { |
7688 |
statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ]; |
7689 |
} |
7690 |
} else { |
7691 |
tmp = map[ jqXHR.status ]; |
7692 |
jqXHR.always( tmp ); |
7693 |
} |
7694 |
} |
7695 |
return this; |
7696 |
}; |
7697 |
|
7698 |
// Remove hash character (#7531: and string promotion) |
7699 |
// Add protocol if not provided (#5866: IE7 issue with protocol-less urls) |
7700 |
// We also use the url parameter if available |
7701 |
s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" ); |
7702 |
|
7703 |
// Extract dataTypes list |
7704 |
s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( core_rspace ); |
7705 |
|
7706 |
// Determine if a cross-domain request is in order |
7707 |
if ( s.crossDomain == null ) { |
7708 |
parts = rurl.exec( s.url.toLowerCase() ); |
7709 |
s.crossDomain = !!( parts && |
7710 |
( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] || |
7711 |
( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) != |
7712 |
( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) ) |
7713 |
); |
7714 |
} |
7715 |
|
7716 |
// Convert data if not already a string |
7717 |
if ( s.data && s.processData && typeof s.data !== "string" ) { |
7718 |
s.data = jQuery.param( s.data, s.traditional ); |
7719 |
} |
7720 |
|
7721 |
// Apply prefilters |
7722 |
inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); |
7723 |
|
7724 |
// If request was aborted inside a prefilter, stop there |
7725 |
if ( state === 2 ) { |
7726 |
return jqXHR; |
7727 |
} |
7728 |
|
7729 |
// We can fire global events as of now if asked to |
7730 |
fireGlobals = s.global; |
7731 |
|
7732 |
// Uppercase the type |
7733 |
s.type = s.type.toUpperCase(); |
7734 |
|
7735 |
// Determine if request has content |
7736 |
s.hasContent = !rnoContent.test( s.type ); |
7737 |
|
7738 |
// Watch for a new set of requests |
7739 |
if ( fireGlobals && jQuery.active++ === 0 ) { |
7740 |
jQuery.event.trigger( "ajaxStart" ); |
7741 |
} |
7742 |
|
7743 |
// More options handling for requests with no content |
7744 |
if ( !s.hasContent ) { |
7745 |
|
7746 |
// If data is available, append data to url |
7747 |
if ( s.data ) { |
7748 |
s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data; |
7749 |
// #9682: remove data so that it's not used in an eventual retry |
7750 |
delete s.data; |
7751 |
} |
7752 |
|
7753 |
// Get ifModifiedKey before adding the anti-cache parameter |
7754 |
ifModifiedKey = s.url; |
7755 |
|
7756 |
// Add anti-cache in url if needed |
7757 |
if ( s.cache === false ) { |
7758 |
|
7759 |
var ts = jQuery.now(), |
7760 |
// try replacing _= if it is there |
7761 |
ret = s.url.replace( rts, "$1_=" + ts ); |
7762 |
|
7763 |
// if nothing was replaced, add timestamp to the end |
7764 |
s.url = ret + ( ( ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" ); |
7765 |
} |
7766 |
} |
7767 |
|
7768 |
// Set the correct header, if data is being sent |
7769 |
if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { |
7770 |
jqXHR.setRequestHeader( "Content-Type", s.contentType ); |
7771 |
} |
7772 |
|
7773 |
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. |
7774 |
if ( s.ifModified ) { |
7775 |
ifModifiedKey = ifModifiedKey || s.url; |
7776 |
if ( jQuery.lastModified[ ifModifiedKey ] ) { |
7777 |
jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] ); |
7778 |
} |
7779 |
if ( jQuery.etag[ ifModifiedKey ] ) { |
7780 |
jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] ); |
7781 |
} |
7782 |
} |
7783 |
|
7784 |
// Set the Accepts header for the server, depending on the dataType |
7785 |
jqXHR.setRequestHeader( |
7786 |
"Accept", |
7787 |
s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ? |
7788 |
s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) : |
7789 |
s.accepts[ "*" ] |
7790 |
); |
7791 |
|
7792 |
// Check for headers option |
7793 |
for ( i in s.headers ) { |
7794 |
jqXHR.setRequestHeader( i, s.headers[ i ] ); |
7795 |
} |
7796 |
|
7797 |
// Allow custom headers/mimetypes and early abort |
7798 |
if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) { |
7799 |
// Abort if not done already and return |
7800 |
return jqXHR.abort(); |
7801 |
|
7802 |
} |
7803 |
|
7804 |
// aborting is no longer a cancellation |
7805 |
strAbort = "abort"; |
7806 |
|
7807 |
// Install callbacks on deferreds |
7808 |
for ( i in { success: 1, error: 1, complete: 1 } ) { |
7809 |
jqXHR[ i ]( s[ i ] ); |
7810 |
} |
7811 |
|
7812 |
// Get transport |
7813 |
transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); |
7814 |
|
7815 |
// If no transport, we auto-abort |
7816 |
if ( !transport ) { |
7817 |
done( -1, "No Transport" ); |
7818 |
} else { |
7819 |
jqXHR.readyState = 1; |
7820 |
// Send global event |
7821 |
if ( fireGlobals ) { |
7822 |
globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); |
7823 |
} |
7824 |
// Timeout |
7825 |
if ( s.async && s.timeout > 0 ) { |
7826 |
timeoutTimer = setTimeout( function(){ |
7827 |
jqXHR.abort( "timeout" ); |
7828 |
}, s.timeout ); |
7829 |
} |
7830 |
|
7831 |
try { |
7832 |
state = 1; |
7833 |
transport.send( requestHeaders, done ); |
7834 |
} catch (e) { |
7835 |
// Propagate exception as error if not done |
7836 |
if ( state < 2 ) { |
7837 |
done( -1, e ); |
7838 |
// Simply rethrow otherwise |
7839 |
} else { |
7840 |
throw e; |
7841 |
} |
7842 |
} |
7843 |
} |
7844 |
|
7845 |
return jqXHR; |
7846 |
}, |
7847 |
|
7848 |
// Counter for holding the number of active queries |
7849 |
active: 0, |
7850 |
|
7851 |
// Last-Modified header cache for next request |
7852 |
lastModified: {}, |
7853 |
etag: {} |
7854 |
|
7855 |
}); |
7856 |
|
7857 |
/* Handles responses to an ajax request: |
7858 |
* - sets all responseXXX fields accordingly |
7859 |
* - finds the right dataType (mediates between content-type and expected dataType) |
7860 |
* - returns the corresponding response |
7861 |
*/ |
7862 |
function ajaxHandleResponses( s, jqXHR, responses ) { |
7863 |
|
7864 |
var ct, type, finalDataType, firstDataType, |
7865 |
contents = s.contents, |
7866 |
dataTypes = s.dataTypes, |
7867 |
responseFields = s.responseFields; |
7868 |
|
7869 |
// Fill responseXXX fields |
7870 |
for ( type in responseFields ) { |
7871 |
if ( type in responses ) { |
7872 |
jqXHR[ responseFields[type] ] = responses[ type ]; |
7873 |
} |
7874 |
} |
7875 |
|
7876 |
// Remove auto dataType and get content-type in the process |
7877 |
while( dataTypes[ 0 ] === "*" ) { |
7878 |
dataTypes.shift(); |
7879 |
if ( ct === undefined ) { |
7880 |
ct = s.mimeType || jqXHR.getResponseHeader( "content-type" ); |
7881 |
} |
7882 |
} |
7883 |
|
7884 |
// Check if we're dealing with a known content-type |
7885 |
if ( ct ) { |
7886 |
for ( type in contents ) { |
7887 |
if ( contents[ type ] && contents[ type ].test( ct ) ) { |
7888 |
dataTypes.unshift( type ); |
7889 |
break; |
7890 |
} |
7891 |
} |
7892 |
} |
7893 |
|
7894 |
// Check to see if we have a response for the expected dataType |
7895 |
if ( dataTypes[ 0 ] in responses ) { |
7896 |
finalDataType = dataTypes[ 0 ]; |
7897 |
} else { |
7898 |
// Try convertible dataTypes |
7899 |
for ( type in responses ) { |
7900 |
if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) { |
7901 |
finalDataType = type; |
7902 |
break; |
7903 |
} |
7904 |
if ( !firstDataType ) { |
7905 |
firstDataType = type; |
7906 |
} |
7907 |
} |
7908 |
// Or just use first one |
7909 |
finalDataType = finalDataType || firstDataType; |
7910 |
} |
7911 |
|
7912 |
// If we found a dataType |
7913 |
// We add the dataType to the list if needed |
7914 |
// and return the corresponding response |
7915 |
if ( finalDataType ) { |
7916 |
if ( finalDataType !== dataTypes[ 0 ] ) { |
7917 |
dataTypes.unshift( finalDataType ); |
7918 |
} |
7919 |
return responses[ finalDataType ]; |
7920 |
} |
7921 |
} |
7922 |
|
7923 |
// Chain conversions given the request and the original response |
7924 |
function ajaxConvert( s, response ) { |
7925 |
|
7926 |
var conv, conv2, current, tmp, |
7927 |
// Work with a copy of dataTypes in case we need to modify it for conversion |
7928 |
dataTypes = s.dataTypes.slice(), |
7929 |
prev = dataTypes[ 0 ], |
7930 |
converters = {}, |
7931 |
i = 0; |
7932 |
|
7933 |
// Apply the dataFilter if provided |
7934 |
if ( s.dataFilter ) { |
7935 |
response = s.dataFilter( response, s.dataType ); |
7936 |
} |
7937 |
|
7938 |
// Create converters map with lowercased keys |
7939 |
if ( dataTypes[ 1 ] ) { |
7940 |
for ( conv in s.converters ) { |
7941 |
converters[ conv.toLowerCase() ] = s.converters[ conv ]; |
7942 |
} |
7943 |
} |
7944 |
|
7945 |
// Convert to each sequential dataType, tolerating list modification |
7946 |
for ( ; (current = dataTypes[++i]); ) { |
7947 |
|
7948 |
// There's only work to do if current dataType is non-auto |
7949 |
if ( current !== "*" ) { |
7950 |
|
7951 |
// Convert response if prev dataType is non-auto and differs from current |
7952 |
if ( prev !== "*" && prev !== current ) { |
7953 |
|
7954 |
// Seek a direct converter |
7955 |
conv = converters[ prev + " " + current ] || converters[ "* " + current ]; |
7956 |
|
7957 |
// If none found, seek a pair |
7958 |
if ( !conv ) { |
7959 |
for ( conv2 in converters ) { |
7960 |
|
7961 |
// If conv2 outputs current |
7962 |
tmp = conv2.split(" "); |
7963 |
if ( tmp[ 1 ] === current ) { |
7964 |
|
7965 |
// If prev can be converted to accepted input |
7966 |
conv = converters[ prev + " " + tmp[ 0 ] ] || |
7967 |
converters[ "* " + tmp[ 0 ] ]; |
7968 |
if ( conv ) { |
7969 |
// Condense equivalence converters |
7970 |
if ( conv === true ) { |
7971 |
conv = converters[ conv2 ]; |
7972 |
|
7973 |
// Otherwise, insert the intermediate dataType |
7974 |
} else if ( converters[ conv2 ] !== true ) { |
7975 |
current = tmp[ 0 ]; |
7976 |
dataTypes.splice( i--, 0, current ); |
7977 |
} |
7978 |
|
7979 |
break; |
7980 |
} |
7981 |
} |
7982 |
} |
7983 |
} |
7984 |
|
7985 |
// Apply converter (if not an equivalence) |
7986 |
if ( conv !== true ) { |
7987 |
|
7988 |
// Unless errors are allowed to bubble, catch and return them |
7989 |
if ( conv && s["throws"] ) { |
7990 |
response = conv( response ); |
7991 |
} else { |
7992 |
try { |
7993 |
response = conv( response ); |
7994 |
} catch ( e ) { |
7995 |
return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current }; |
7996 |
} |
7997 |
} |
7998 |
} |
7999 |
} |
8000 |
|
8001 |
// Update prev for next iteration |
8002 |
prev = current; |
8003 |
} |
8004 |
} |
8005 |
|
8006 |
return { state: "success", data: response }; |
8007 |
} |
8008 |
var oldCallbacks = [], |
8009 |
rquestion = /\?/, |
8010 |
rjsonp = /(=)\?(?=&|$)|\?\?/, |
8011 |
nonce = jQuery.now(); |
8012 |
|
8013 |
// Default jsonp settings |
8014 |
jQuery.ajaxSetup({ |
8015 |
jsonp: "callback", |
8016 |
jsonpCallback: function() { |
8017 |
var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) ); |
8018 |
this[ callback ] = true; |
8019 |
return callback; |
8020 |
} |
8021 |
}); |
8022 |
|
8023 |
// Detect, normalize options and install callbacks for jsonp requests |
8024 |
jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { |
8025 |
|
8026 |
var callbackName, overwritten, responseContainer, |
8027 |
data = s.data, |
8028 |
url = s.url, |
8029 |
hasCallback = s.jsonp !== false, |
8030 |
replaceInUrl = hasCallback && rjsonp.test( url ), |
8031 |
replaceInData = hasCallback && !replaceInUrl && typeof data === "string" && |
8032 |
!( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && |
8033 |
rjsonp.test( data ); |
8034 |
|
8035 |
// Handle iff the expected data type is "jsonp" or we have a parameter to set |
8036 |
if ( s.dataTypes[ 0 ] === "jsonp" || replaceInUrl || replaceInData ) { |
8037 |
|
8038 |
// Get callback name, remembering preexisting value associated with it |
8039 |
callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ? |
8040 |
s.jsonpCallback() : |
8041 |
s.jsonpCallback; |
8042 |
overwritten = window[ callbackName ]; |
8043 |
|
8044 |
// Insert callback into url or form data |
8045 |
if ( replaceInUrl ) { |
8046 |
s.url = url.replace( rjsonp, "$1" + callbackName ); |
8047 |
} else if ( replaceInData ) { |
8048 |
s.data = data.replace( rjsonp, "$1" + callbackName ); |
8049 |
} else if ( hasCallback ) { |
8050 |
s.url += ( rquestion.test( url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName; |
8051 |
} |
8052 |
|
8053 |
// Use data converter to retrieve json after script execution |
8054 |
s.converters["script json"] = function() { |
8055 |
if ( !responseContainer ) { |
8056 |
jQuery.error( callbackName + " was not called" ); |
8057 |
} |
8058 |
return responseContainer[ 0 ]; |
8059 |
}; |
8060 |
|
8061 |
// force json dataType |
8062 |
s.dataTypes[ 0 ] = "json"; |
8063 |
|
8064 |
// Install callback |
8065 |
window[ callbackName ] = function() { |
8066 |
responseContainer = arguments; |
8067 |
}; |
8068 |
|
8069 |
// Clean-up function (fires after converters) |
8070 |
jqXHR.always(function() { |
8071 |
// Restore preexisting value |
8072 |
window[ callbackName ] = overwritten; |
8073 |
|
8074 |
// Save back as free |
8075 |
if ( s[ callbackName ] ) { |
8076 |
// make sure that re-using the options doesn't screw things around |
8077 |
s.jsonpCallback = originalSettings.jsonpCallback; |
8078 |
|
8079 |
// save the callback name for future use |
8080 |
oldCallbacks.push( callbackName ); |
8081 |
} |
8082 |
|
8083 |
// Call if it was a function and we have a response |
8084 |
if ( responseContainer && jQuery.isFunction( overwritten ) ) { |
8085 |
overwritten( responseContainer[ 0 ] ); |
8086 |
} |
8087 |
|
8088 |
responseContainer = overwritten = undefined; |
8089 |
}); |
8090 |
|
8091 |
// Delegate to script |
8092 |
return "script"; |
8093 |
} |
8094 |
}); |
8095 |
// Install script dataType |
8096 |
jQuery.ajaxSetup({ |
8097 |
accepts: { |
8098 |
script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript" |
8099 |
}, |
8100 |
contents: { |
8101 |
script: /javascript|ecmascript/ |
8102 |
}, |
8103 |
converters: { |
8104 |
"text script": function( text ) { |
8105 |
jQuery.globalEval( text ); |
8106 |
return text; |
8107 |
} |
8108 |
} |
8109 |
}); |
8110 |
|
8111 |
// Handle cache's special case and global |
8112 |
jQuery.ajaxPrefilter( "script", function( s ) { |
8113 |
if ( s.cache === undefined ) { |
8114 |
s.cache = false; |
8115 |
} |
8116 |
if ( s.crossDomain ) { |
8117 |
s.type = "GET"; |
8118 |
s.global = false; |
8119 |
} |
8120 |
}); |
8121 |
|
8122 |
// Bind script tag hack transport |
8123 |
jQuery.ajaxTransport( "script", function(s) { |
8124 |
|
8125 |
// This transport only deals with cross domain requests |
8126 |
if ( s.crossDomain ) { |
8127 |
|
8128 |
var script, |
8129 |
head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement; |
8130 |
|
8131 |
return { |
8132 |
|
8133 |
send: function( _, callback ) { |
8134 |
|
8135 |
script = document.createElement( "script" ); |
8136 |
|
8137 |
script.async = "async"; |
8138 |
|
8139 |
if ( s.scriptCharset ) { |
8140 |
script.charset = s.scriptCharset; |
8141 |
} |
8142 |
|
8143 |
script.src = s.url; |
8144 |
|
8145 |
// Attach handlers for all browsers |
8146 |
script.onload = script.onreadystatechange = function( _, isAbort ) { |
8147 |
|
8148 |
if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) { |
8149 |
|
8150 |
// Handle memory leak in IE |
8151 |
script.onload = script.onreadystatechange = null; |
8152 |
|
8153 |
// Remove the script |
8154 |
if ( head && script.parentNode ) { |
8155 |
head.removeChild( script ); |
8156 |
} |
8157 |
|
8158 |
// Dereference the script |
8159 |
script = undefined; |
8160 |
|
8161 |
// Callback if not abort |
8162 |
if ( !isAbort ) { |
8163 |
callback( 200, "success" ); |
8164 |
} |
8165 |
} |
8166 |
}; |
8167 |
// Use insertBefore instead of appendChild to circumvent an IE6 bug. |
8168 |
// This arises when a base node is used (#2709 and #4378). |
8169 |
head.insertBefore( script, head.firstChild ); |
8170 |
}, |
8171 |
|
8172 |
abort: function() { |
8173 |
if ( script ) { |
8174 |
script.onload( 0, 1 ); |
8175 |
} |
8176 |
} |
8177 |
}; |
8178 |
} |
8179 |
}); |
8180 |
var xhrCallbacks, |
8181 |
// #5280: Internet Explorer will keep connections alive if we don't abort on unload |
8182 |
xhrOnUnloadAbort = window.ActiveXObject ? function() { |
8183 |
// Abort all pending requests |
8184 |
for ( var key in xhrCallbacks ) { |
8185 |
xhrCallbacks[ key ]( 0, 1 ); |
8186 |
} |
8187 |
} : false, |
8188 |
xhrId = 0; |
8189 |
|
8190 |
// Functions to create xhrs |
8191 |
function createStandardXHR() { |
8192 |
try { |
8193 |
return new window.XMLHttpRequest(); |
8194 |
} catch( e ) {} |
8195 |
} |
8196 |
|
8197 |
function createActiveXHR() { |
8198 |
try { |
8199 |
return new window.ActiveXObject( "Microsoft.XMLHTTP" ); |
8200 |
} catch( e ) {} |
8201 |
} |
8202 |
|
8203 |
// Create the request object |
8204 |
// (This is still attached to ajaxSettings for backward compatibility) |
8205 |
jQuery.ajaxSettings.xhr = window.ActiveXObject ? |
8206 |
/* Microsoft failed to properly |
8207 |
* implement the XMLHttpRequest in IE7 (can't request local files), |
8208 |
* so we use the ActiveXObject when it is available |
8209 |
* Additionally XMLHttpRequest can be disabled in IE7/IE8 so |
8210 |
* we need a fallback. |
8211 |
*/ |
8212 |
function() { |
8213 |
return !this.isLocal && createStandardXHR() || createActiveXHR(); |
8214 |
} : |
8215 |
// For all other browsers, use the standard XMLHttpRequest object |
8216 |
createStandardXHR; |
8217 |
|
8218 |
// Determine support properties |
8219 |
(function( xhr ) { |
8220 |
jQuery.extend( jQuery.support, { |
8221 |
ajax: !!xhr, |
8222 |
cors: !!xhr && ( "withCredentials" in xhr ) |
8223 |
}); |
8224 |
})( jQuery.ajaxSettings.xhr() ); |
8225 |
|
8226 |
// Create transport if the browser can provide an xhr |
8227 |
if ( jQuery.support.ajax ) { |
8228 |
|
8229 |
jQuery.ajaxTransport(function( s ) { |
8230 |
// Cross domain only allowed if supported through XMLHttpRequest |
8231 |
if ( !s.crossDomain || jQuery.support.cors ) { |
8232 |
|
8233 |
var callback; |
8234 |
|
8235 |
return { |
8236 |
send: function( headers, complete ) { |
8237 |
|
8238 |
// Get a new xhr |
8239 |
var handle, i, |
8240 |
xhr = s.xhr(); |
8241 |
|
8242 |
// Open the socket |
8243 |
// Passing null username, generates a login popup on Opera (#2865) |
8244 |
if ( s.username ) { |
8245 |
xhr.open( s.type, s.url, s.async, s.username, s.password ); |
8246 |
} else { |
8247 |
xhr.open( s.type, s.url, s.async ); |
8248 |
} |
8249 |
|
8250 |
// Apply custom fields if provided |
8251 |
if ( s.xhrFields ) { |
8252 |
for ( i in s.xhrFields ) { |
8253 |
xhr[ i ] = s.xhrFields[ i ]; |
8254 |
} |
8255 |
} |
8256 |
|
8257 |
// Override mime type if needed |
8258 |
if ( s.mimeType && xhr.overrideMimeType ) { |
8259 |
xhr.overrideMimeType( s.mimeType ); |
8260 |
} |
8261 |
|
8262 |
// X-Requested-With header |
8263 |
// For cross-domain requests, seeing as conditions for a preflight are |
8264 |
// akin to a jigsaw puzzle, we simply never set it to be sure. |
8265 |
// (it can always be set on a per-request basis or even using ajaxSetup) |
8266 |
// For same-domain requests, won't change header if already provided. |
8267 |
if ( !s.crossDomain && !headers["X-Requested-With"] ) { |
8268 |
headers[ "X-Requested-With" ] = "XMLHttpRequest"; |
8269 |
} |
8270 |
|
8271 |
// Need an extra try/catch for cross domain requests in Firefox 3 |
8272 |
try { |
8273 |
for ( i in headers ) { |
8274 |
xhr.setRequestHeader( i, headers[ i ] ); |
8275 |
} |
8276 |
} catch( _ ) {} |
8277 |
|
8278 |
// Do send the request |
8279 |
// This may raise an exception which is actually |
8280 |
// handled in jQuery.ajax (so no try/catch here) |
8281 |
xhr.send( ( s.hasContent && s.data ) || null ); |
8282 |
|
8283 |
// Listener |
8284 |
callback = function( _, isAbort ) { |
8285 |
|
8286 |
var status, |
8287 |
statusText, |
8288 |
responseHeaders, |
8289 |
responses, |
8290 |
xml; |
8291 |
|
8292 |
// Firefox throws exceptions when accessing properties |
8293 |
// of an xhr when a network error occurred |
8294 |
// http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE) |
8295 |
try { |
8296 |
|
8297 |
// Was never called and is aborted or complete |
8298 |
if ( callback && ( isAbort || xhr.readyState === 4 ) ) { |
8299 |
|
8300 |
// Only called once |
8301 |
callback = undefined; |
8302 |
|
8303 |
// Do not keep as active anymore |
8304 |
if ( handle ) { |
8305 |
xhr.onreadystatechange = jQuery.noop; |
8306 |
if ( xhrOnUnloadAbort ) { |
8307 |
delete xhrCallbacks[ handle ]; |
8308 |
} |
8309 |
} |
8310 |
|
8311 |
// If it's an abort |
8312 |
if ( isAbort ) { |
8313 |
// Abort it manually if needed |
8314 |
if ( xhr.readyState !== 4 ) { |
8315 |
xhr.abort(); |
8316 |
} |
8317 |
} else { |
8318 |
status = xhr.status; |
8319 |
responseHeaders = xhr.getAllResponseHeaders(); |
8320 |
responses = {}; |
8321 |
xml = xhr.responseXML; |
8322 |
|
8323 |
// Construct response list |
8324 |
if ( xml && xml.documentElement /* #4958 */ ) { |
8325 |
responses.xml = xml; |
8326 |
} |
8327 |
|
8328 |
// When requesting binary data, IE6-9 will throw an exception |
8329 |
// on any attempt to access responseText (#11426) |
8330 |
try { |
8331 |
responses.text = xhr.responseText; |
8332 |
} catch( _ ) { |
8333 |
} |
8334 |
|
8335 |
// Firefox throws an exception when accessing |
8336 |
// statusText for faulty cross-domain requests |
8337 |
try { |
8338 |
statusText = xhr.statusText; |
8339 |
} catch( e ) { |
8340 |
// We normalize with Webkit giving an empty statusText |
8341 |
statusText = ""; |
8342 |
} |
8343 |
|
8344 |
// Filter status for non standard behaviors |
8345 |
|
8346 |
// If the request is local and we have data: assume a success |
8347 |
// (success with no data won't get notified, that's the best we |
8348 |
// can do given current implementations) |
8349 |
if ( !status && s.isLocal && !s.crossDomain ) { |
8350 |
status = responses.text ? 200 : 404; |
8351 |
// IE - #1450: sometimes returns 1223 when it should be 204 |
8352 |
} else if ( status === 1223 ) { |
8353 |
status = 204; |
8354 |
} |
8355 |
} |
8356 |
} |
8357 |
} catch( firefoxAccessException ) { |
8358 |
if ( !isAbort ) { |
8359 |
complete( -1, firefoxAccessException ); |
8360 |
} |
8361 |
} |
8362 |
|
8363 |
// Call complete if needed |
8364 |
if ( responses ) { |
8365 |
complete( status, statusText, responses, responseHeaders ); |
8366 |
} |
8367 |
}; |
8368 |
|
8369 |
if ( !s.async ) { |
8370 |
// if we're in sync mode we fire the callback |
8371 |
callback(); |
8372 |
} else if ( xhr.readyState === 4 ) { |
8373 |
// (IE6 & IE7) if it's in cache and has been |
8374 |
// retrieved directly we need to fire the callback |
8375 |
setTimeout( callback, 0 ); |
8376 |
} else { |
8377 |
handle = ++xhrId; |
8378 |
if ( xhrOnUnloadAbort ) { |
8379 |
// Create the active xhrs callbacks list if needed |
8380 |
// and attach the unload handler |
8381 |
if ( !xhrCallbacks ) { |
8382 |
xhrCallbacks = {}; |
8383 |
jQuery( window ).unload( xhrOnUnloadAbort ); |
8384 |
} |
8385 |
// Add to list of active xhrs callbacks |
8386 |
xhrCallbacks[ handle ] = callback; |
8387 |
} |
8388 |
xhr.onreadystatechange = callback; |
8389 |
} |
8390 |
}, |
8391 |
|
8392 |
abort: function() { |
8393 |
if ( callback ) { |
8394 |
callback(0,1); |
8395 |
} |
8396 |
} |
8397 |
}; |
8398 |
} |
8399 |
}); |
8400 |
} |
8401 |
var fxNow, timerId, |
8402 |
rfxtypes = /^(?:toggle|show|hide)$/, |
8403 |
rfxnum = new RegExp( "^(?:([-+])=|)(" + core_pnum + ")([a-z%]*)$", "i" ), |
8404 |
rrun = /queueHooks$/, |
8405 |
animationPrefilters = [ defaultPrefilter ], |
8406 |
tweeners = { |
8407 |
"*": [function( prop, value ) { |
8408 |
var end, unit, prevScale, |
8409 |
tween = this.createTween( prop, value ), |
8410 |
parts = rfxnum.exec( value ), |
8411 |
target = tween.cur(), |
8412 |
start = +target || 0, |
8413 |
scale = 1; |
8414 |
|
8415 |
if ( parts ) { |
8416 |
end = +parts[2]; |
8417 |
unit = parts[3] || ( jQuery.cssNumber[ prop ] ? "" : "px" ); |
8418 |
|
8419 |
// We need to compute starting value |
8420 |
if ( unit !== "px" && start ) { |
8421 |
// Iteratively approximate from a nonzero starting point |
8422 |
// Prefer the current property, because this process will be trivial if it uses the same units |
8423 |
// Fallback to end or a simple constant |
8424 |
start = jQuery.css( tween.elem, prop, true ) || end || 1; |
8425 |
|
8426 |
do { |
8427 |
// If previous iteration zeroed out, double until we get *something* |
8428 |
// Use a string for doubling factor so we don't accidentally see scale as unchanged below |
8429 |
prevScale = scale = scale || ".5"; |
8430 |
|
8431 |
// Adjust and apply |
8432 |
start = start / scale; |
8433 |
jQuery.style( tween.elem, prop, start + unit ); |
8434 |
|
8435 |
// Update scale, tolerating zeroes from tween.cur() |
8436 |
scale = tween.cur() / target; |
8437 |
|
8438 |
// Stop looping if we've hit the mark or scale is unchanged |
8439 |
} while ( scale !== 1 && scale !== prevScale ); |
8440 |
} |
8441 |
|
8442 |
tween.unit = unit; |
8443 |
tween.start = start; |
8444 |
// If a +=/-= token was provided, we're doing a relative animation |
8445 |
tween.end = parts[1] ? start + ( parts[1] + 1 ) * end : end; |
8446 |
} |
8447 |
return tween; |
8448 |
}] |
8449 |
}; |
8450 |
|
8451 |
// Animations created synchronously will run synchronously |
8452 |
function createFxNow() { |
8453 |
setTimeout(function() { |
8454 |
fxNow = undefined; |
8455 |
}, 0 ); |
8456 |
return ( fxNow = jQuery.now() ); |
8457 |
} |
8458 |
|
8459 |
function createTweens( animation, props ) { |
8460 |
jQuery.each( props, function( prop, value ) { |
8461 |
var collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ), |
8462 |
index = 0, |
8463 |
length = collection.length; |
8464 |
for ( ; index < length; index++ ) { |
8465 |
if ( collection[ index ].call( animation, prop, value ) ) { |
8466 |
|
8467 |
// we're done with this property |
8468 |
return; |
8469 |
} |
8470 |
} |
8471 |
}); |
8472 |
} |
8473 |
|
8474 |
function Animation( elem, properties, options ) { |
8475 |
var result, |
8476 |
index = 0, |
8477 |
tweenerIndex = 0, |
8478 |
length = animationPrefilters.length, |
8479 |
deferred = jQuery.Deferred().always( function() { |
8480 |
// don't match elem in the :animated selector |
8481 |
delete tick.elem; |
8482 |
}), |
8483 |
tick = function() { |
8484 |
var currentTime = fxNow || createFxNow(), |
8485 |
remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), |
8486 |
percent = 1 - ( remaining / animation.duration || 0 ), |
8487 |
index = 0, |
8488 |
length = animation.tweens.length; |
8489 |
|
8490 |
for ( ; index < length ; index++ ) { |
8491 |
animation.tweens[ index ].run( percent ); |
8492 |
} |
8493 |
|
8494 |
deferred.notifyWith( elem, [ animation, percent, remaining ]); |
8495 |
|
8496 |
if ( percent < 1 && length ) { |
8497 |
return remaining; |
8498 |
} else { |
8499 |
deferred.resolveWith( elem, [ animation ] ); |
8500 |
return false; |
8501 |
} |
8502 |
}, |
8503 |
animation = deferred.promise({ |
8504 |
elem: elem, |
8505 |
props: jQuery.extend( {}, properties ), |
8506 |
opts: jQuery.extend( true, { specialEasing: {} }, options ), |
8507 |
originalProperties: properties, |
8508 |
originalOptions: options, |
8509 |
startTime: fxNow || createFxNow(), |
8510 |
duration: options.duration, |
8511 |
tweens: [], |
8512 |
createTween: function( prop, end, easing ) { |
8513 |
var tween = jQuery.Tween( elem, animation.opts, prop, end, |
8514 |
animation.opts.specialEasing[ prop ] || animation.opts.easing ); |
8515 |
animation.tweens.push( tween ); |
8516 |
return tween; |
8517 |
}, |
8518 |
stop: function( gotoEnd ) { |
8519 |
var index = 0, |
8520 |
// if we are going to the end, we want to run all the tweens |
8521 |
// otherwise we skip this part |
8522 |
length = gotoEnd ? animation.tweens.length : 0; |
8523 |
|
8524 |
for ( ; index < length ; index++ ) { |
8525 |
animation.tweens[ index ].run( 1 ); |
8526 |
} |
8527 |
|
8528 |
// resolve when we played the last frame |
8529 |
// otherwise, reject |
8530 |
if ( gotoEnd ) { |
8531 |
deferred.resolveWith( elem, [ animation, gotoEnd ] ); |
8532 |
} else { |
8533 |
deferred.rejectWith( elem, [ animation, gotoEnd ] ); |
8534 |
} |
8535 |
return this; |
8536 |
} |
8537 |
}), |
8538 |
props = animation.props; |
8539 |
|
8540 |
propFilter( props, animation.opts.specialEasing ); |
8541 |
|
8542 |
for ( ; index < length ; index++ ) { |
8543 |
result = animationPrefilters[ index ].call( animation, elem, props, animation.opts ); |
8544 |
if ( result ) { |
8545 |
return result; |
8546 |
} |
8547 |
} |
8548 |
|
8549 |
createTweens( animation, props ); |
8550 |
|
8551 |
if ( jQuery.isFunction( animation.opts.start ) ) { |
8552 |
animation.opts.start.call( elem, animation ); |
8553 |
} |
8554 |
|
8555 |
jQuery.fx.timer( |
8556 |
jQuery.extend( tick, { |
8557 |
anim: animation, |
8558 |
queue: animation.opts.queue, |
8559 |
elem: elem |
8560 |
}) |
8561 |
); |
8562 |
|
8563 |
// attach callbacks from options |
8564 |
return animation.progress( animation.opts.progress ) |
8565 |
.done( animation.opts.done, animation.opts.complete ) |
8566 |
.fail( animation.opts.fail ) |
8567 |
.always( animation.opts.always ); |
8568 |
} |
8569 |
|
8570 |
function propFilter( props, specialEasing ) { |
8571 |
var index, name, easing, value, hooks; |
8572 |
|
8573 |
// camelCase, specialEasing and expand cssHook pass |
8574 |
for ( index in props ) { |
8575 |
name = jQuery.camelCase( index ); |
8576 |
easing = specialEasing[ name ]; |
8577 |
value = props[ index ]; |
8578 |
if ( jQuery.isArray( value ) ) { |
8579 |
easing = value[ 1 ]; |
8580 |
value = props[ index ] = value[ 0 ]; |
8581 |
} |
8582 |
|
8583 |
if ( index !== name ) { |
8584 |
props[ name ] = value; |
8585 |
delete props[ index ]; |
8586 |
} |
8587 |
|
8588 |
hooks = jQuery.cssHooks[ name ]; |
8589 |
if ( hooks && "expand" in hooks ) { |
8590 |
value = hooks.expand( value ); |
8591 |
delete props[ name ]; |
8592 |
|
8593 |
// not quite $.extend, this wont overwrite keys already present. |
8594 |
// also - reusing 'index' from above because we have the correct "name" |
8595 |
for ( index in value ) { |
8596 |
if ( !( index in props ) ) { |
8597 |
props[ index ] = value[ index ]; |
8598 |
specialEasing[ index ] = easing; |
8599 |
} |
8600 |
} |
8601 |
} else { |
8602 |
specialEasing[ name ] = easing; |
8603 |
} |
8604 |
} |
8605 |
} |
8606 |
|
8607 |
jQuery.Animation = jQuery.extend( Animation, { |
8608 |
|
8609 |
tweener: function( props, callback ) { |
8610 |
if ( jQuery.isFunction( props ) ) { |
8611 |
callback = props; |
8612 |
props = [ "*" ]; |
8613 |
} else { |
8614 |
props = props.split(" "); |
8615 |
} |
8616 |
|
8617 |
var prop, |
8618 |
index = 0, |
8619 |
length = props.length; |
8620 |
|
8621 |
for ( ; index < length ; index++ ) { |
8622 |
prop = props[ index ]; |
8623 |
tweeners[ prop ] = tweeners[ prop ] || []; |
8624 |
tweeners[ prop ].unshift( callback ); |
8625 |
} |
8626 |
}, |
8627 |
|
8628 |
prefilter: function( callback, prepend ) { |
8629 |
if ( prepend ) { |
8630 |
animationPrefilters.unshift( callback ); |
8631 |
} else { |
8632 |
animationPrefilters.push( callback ); |
8633 |
} |
8634 |
} |
8635 |
}); |
8636 |
|
8637 |
function defaultPrefilter( elem, props, opts ) { |
8638 |
var index, prop, value, length, dataShow, tween, hooks, oldfire, |
8639 |
anim = this, |
8640 |
style = elem.style, |
8641 |
orig = {}, |
8642 |
handled = [], |
8643 |
hidden = elem.nodeType && isHidden( elem ); |
8644 |
|
8645 |
// handle queue: false promises |
8646 |
if ( !opts.queue ) { |
8647 |
hooks = jQuery._queueHooks( elem, "fx" ); |
8648 |
if ( hooks.unqueued == null ) { |
8649 |
hooks.unqueued = 0; |
8650 |
oldfire = hooks.empty.fire; |
8651 |
hooks.empty.fire = function() { |
8652 |
if ( !hooks.unqueued ) { |
8653 |
oldfire(); |
8654 |
} |
8655 |
}; |
8656 |
} |
8657 |
hooks.unqueued++; |
8658 |
|
8659 |
anim.always(function() { |
8660 |
// doing this makes sure that the complete handler will be called |
8661 |
// before this completes |
8662 |
anim.always(function() { |
8663 |
hooks.unqueued--; |
8664 |
if ( !jQuery.queue( elem, "fx" ).length ) { |
8665 |
hooks.empty.fire(); |
8666 |
} |
8667 |
}); |
8668 |
}); |
8669 |
} |
8670 |
|
8671 |
// height/width overflow pass |
8672 |
if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) { |
8673 |
// Make sure that nothing sneaks out |
8674 |
// Record all 3 overflow attributes because IE does not |
8675 |
// change the overflow attribute when overflowX and |
8676 |
// overflowY are set to the same value |
8677 |
opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; |
8678 |
|
8679 |
// Set display property to inline-block for height/width |
8680 |
// animations on inline elements that are having width/height animated |
8681 |
if ( jQuery.css( elem, "display" ) === "inline" && |
8682 |
jQuery.css( elem, "float" ) === "none" ) { |
8683 |
|
8684 |
// inline-level elements accept inline-block; |
8685 |
// block-level elements need to be inline with layout |
8686 |
if ( !jQuery.support.inlineBlockNeedsLayout || css_defaultDisplay( elem.nodeName ) === "inline" ) { |
8687 |
style.display = "inline-block"; |
8688 |
|
8689 |
} else { |
8690 |
style.zoom = 1; |
8691 |
} |
8692 |
} |
8693 |
} |
8694 |
|
8695 |
if ( opts.overflow ) { |
8696 |
style.overflow = "hidden"; |
8697 |
if ( !jQuery.support.shrinkWrapBlocks ) { |
8698 |
anim.done(function() { |
8699 |
style.overflow = opts.overflow[ 0 ]; |
8700 |
style.overflowX = opts.overflow[ 1 ]; |
8701 |
style.overflowY = opts.overflow[ 2 ]; |
8702 |
}); |
8703 |
} |
8704 |
} |
8705 |
|
8706 |
|
8707 |
// show/hide pass |
8708 |
for ( index in props ) { |
8709 |
value = props[ index ]; |
8710 |
if ( rfxtypes.exec( value ) ) { |
8711 |
delete props[ index ]; |
8712 |
if ( value === ( hidden ? "hide" : "show" ) ) { |
8713 |
continue; |
8714 |
} |
8715 |
handled.push( index ); |
8716 |
} |
8717 |
} |
8718 |
|
8719 |
length = handled.length; |
8720 |
if ( length ) { |
8721 |
dataShow = jQuery._data( elem, "fxshow" ) || jQuery._data( elem, "fxshow", {} ); |
8722 |
if ( hidden ) { |
8723 |
jQuery( elem ).show(); |
8724 |
} else { |
8725 |
anim.done(function() { |
8726 |
jQuery( elem ).hide(); |
8727 |
}); |
8728 |
} |
8729 |
anim.done(function() { |
8730 |
var prop; |
8731 |
jQuery.removeData( elem, "fxshow", true ); |
8732 |
for ( prop in orig ) { |
8733 |
jQuery.style( elem, prop, orig[ prop ] ); |
8734 |
} |
8735 |
}); |
8736 |
for ( index = 0 ; index < length ; index++ ) { |
8737 |
prop = handled[ index ]; |
8738 |
tween = anim.createTween( prop, hidden ? dataShow[ prop ] : 0 ); |
8739 |
orig[ prop ] = dataShow[ prop ] || jQuery.style( elem, prop ); |
8740 |
|
8741 |
if ( !( prop in dataShow ) ) { |
8742 |
dataShow[ prop ] = tween.start; |
8743 |
if ( hidden ) { |
8744 |
tween.end = tween.start; |
8745 |
tween.start = prop === "width" || prop === "height" ? 1 : 0; |
8746 |
} |
8747 |
} |
8748 |
} |
8749 |
} |
8750 |
} |
8751 |
|
8752 |
function Tween( elem, options, prop, end, easing ) { |
8753 |
return new Tween.prototype.init( elem, options, prop, end, easing ); |
8754 |
} |
8755 |
jQuery.Tween = Tween; |
8756 |
|
8757 |
Tween.prototype = { |
8758 |
constructor: Tween, |
8759 |
init: function( elem, options, prop, end, easing, unit ) { |
8760 |
this.elem = elem; |
8761 |
this.prop = prop; |
8762 |
this.easing = easing || "swing"; |
8763 |
this.options = options; |
8764 |
this.start = this.now = this.cur(); |
8765 |
this.end = end; |
8766 |
this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" ); |
8767 |
}, |
8768 |
cur: function() { |
8769 |
var hooks = Tween.propHooks[ this.prop ]; |
8770 |
|
8771 |
return hooks && hooks.get ? |
8772 |
hooks.get( this ) : |
8773 |
Tween.propHooks._default.get( this ); |
8774 |
}, |
8775 |
run: function( percent ) { |
8776 |
var eased, |
8777 |
hooks = Tween.propHooks[ this.prop ]; |
8778 |
|
8779 |
if ( this.options.duration ) { |
8780 |
this.pos = eased = jQuery.easing[ this.easing ]( |
8781 |
percent, this.options.duration * percent, 0, 1, this.options.duration |
8782 |
); |
8783 |
} else { |
8784 |
this.pos = eased = percent; |
8785 |
} |
8786 |
this.now = ( this.end - this.start ) * eased + this.start; |
8787 |
|
8788 |
if ( this.options.step ) { |
8789 |
this.options.step.call( this.elem, this.now, this ); |
8790 |
} |
8791 |
|
8792 |
if ( hooks && hooks.set ) { |
8793 |
hooks.set( this ); |
8794 |
} else { |
8795 |
Tween.propHooks._default.set( this ); |
8796 |
} |
8797 |
return this; |
8798 |
} |
8799 |
}; |
8800 |
|
8801 |
Tween.prototype.init.prototype = Tween.prototype; |
8802 |
|
8803 |
Tween.propHooks = { |
8804 |
_default: { |
8805 |
get: function( tween ) { |
8806 |
var result; |
8807 |
|
8808 |
if ( tween.elem[ tween.prop ] != null && |
8809 |
(!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) { |
8810 |
return tween.elem[ tween.prop ]; |
8811 |
} |
8812 |
|
8813 |
// passing any value as a 4th parameter to .css will automatically |
8814 |
// attempt a parseFloat and fallback to a string if the parse fails |
8815 |
// so, simple values such as "10px" are parsed to Float. |
8816 |
// complex values such as "rotate(1rad)" are returned as is. |
8817 |
result = jQuery.css( tween.elem, tween.prop, false, "" ); |
8818 |
// Empty strings, null, undefined and "auto" are converted to 0. |
8819 |
return !result || result === "auto" ? 0 : result; |
8820 |
}, |
8821 |
set: function( tween ) { |
8822 |
// use step hook for back compat - use cssHook if its there - use .style if its |
8823 |
// available and use plain properties where available |
8824 |
if ( jQuery.fx.step[ tween.prop ] ) { |
8825 |
jQuery.fx.step[ tween.prop ]( tween ); |
8826 |
} else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) { |
8827 |
jQuery.style( tween.elem, tween.prop, tween.now + tween.unit ); |
8828 |
} else { |
8829 |
tween.elem[ tween.prop ] = tween.now; |
8830 |
} |
8831 |
} |
8832 |
} |
8833 |
}; |
8834 |
|
8835 |
// Remove in 2.0 - this supports IE8's panic based approach |
8836 |
// to setting things on disconnected nodes |
8837 |
|
8838 |
Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = { |
8839 |
set: function( tween ) { |
8840 |
if ( tween.elem.nodeType && tween.elem.parentNode ) { |
8841 |
tween.elem[ tween.prop ] = tween.now; |
8842 |
} |
8843 |
} |
8844 |
}; |
8845 |
|
8846 |
jQuery.each([ "toggle", "show", "hide" ], function( i, name ) { |
8847 |
var cssFn = jQuery.fn[ name ]; |
8848 |
jQuery.fn[ name ] = function( speed, easing, callback ) { |
8849 |
return speed == null || typeof speed === "boolean" || |
8850 |
// special check for .toggle( handler, handler, ... ) |
8851 |
( !i && jQuery.isFunction( speed ) && jQuery.isFunction( easing ) ) ? |
8852 |
cssFn.apply( this, arguments ) : |
8853 |
this.animate( genFx( name, true ), speed, easing, callback ); |
8854 |
}; |
8855 |
}); |
8856 |
|
8857 |
jQuery.fn.extend({ |
8858 |
fadeTo: function( speed, to, easing, callback ) { |
8859 |
|
8860 |
// show any hidden elements after setting opacity to 0 |
8861 |
return this.filter( isHidden ).css( "opacity", 0 ).show() |
8862 |
|
8863 |
// animate to the value specified |
8864 |
.end().animate({ opacity: to }, speed, easing, callback ); |
8865 |
}, |
8866 |
animate: function( prop, speed, easing, callback ) { |
8867 |
var empty = jQuery.isEmptyObject( prop ), |
8868 |
optall = jQuery.speed( speed, easing, callback ), |
8869 |
doAnimation = function() { |
8870 |
// Operate on a copy of prop so per-property easing won't be lost |
8871 |
var anim = Animation( this, jQuery.extend( {}, prop ), optall ); |
8872 |
|
8873 |
// Empty animations resolve immediately |
8874 |
if ( empty ) { |
8875 |
anim.stop( true ); |
8876 |
} |
8877 |
}; |
8878 |
|
8879 |
return empty || optall.queue === false ? |
8880 |
this.each( doAnimation ) : |
8881 |
this.queue( optall.queue, doAnimation ); |
8882 |
}, |
8883 |
stop: function( type, clearQueue, gotoEnd ) { |
8884 |
var stopQueue = function( hooks ) { |
8885 |
var stop = hooks.stop; |
8886 |
delete hooks.stop; |
8887 |
stop( gotoEnd ); |
8888 |
}; |
8889 |
|
8890 |
if ( typeof type !== "string" ) { |
8891 |
gotoEnd = clearQueue; |
8892 |
clearQueue = type; |
8893 |
type = undefined; |
8894 |
} |
8895 |
if ( clearQueue && type !== false ) { |
8896 |
this.queue( type || "fx", [] ); |
8897 |
} |
8898 |
|
8899 |
return this.each(function() { |
8900 |
var dequeue = true, |
8901 |
index = type != null && type + "queueHooks", |
8902 |
timers = jQuery.timers, |
8903 |
data = jQuery._data( this ); |
8904 |
|
8905 |
if ( index ) { |
8906 |
if ( data[ index ] && data[ index ].stop ) { |
8907 |
stopQueue( data[ index ] ); |
8908 |
} |
8909 |
} else { |
8910 |
for ( index in data ) { |
8911 |
if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) { |
8912 |
stopQueue( data[ index ] ); |
8913 |
} |
8914 |
} |
8915 |
} |
8916 |
|
8917 |
for ( index = timers.length; index--; ) { |
8918 |
if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) { |
8919 |
timers[ index ].anim.stop( gotoEnd ); |
8920 |
dequeue = false; |
8921 |
timers.splice( index, 1 ); |
8922 |
} |
8923 |
} |
8924 |
|
8925 |
// start the next in the queue if the last step wasn't forced |
8926 |
// timers currently will call their complete callbacks, which will dequeue |
8927 |
// but only if they were gotoEnd |
8928 |
if ( dequeue || !gotoEnd ) { |
8929 |
jQuery.dequeue( this, type ); |
8930 |
} |
8931 |
}); |
8932 |
} |
8933 |
}); |
8934 |
|
8935 |
// Generate parameters to create a standard animation |
8936 |
function genFx( type, includeWidth ) { |
8937 |
var which, |
8938 |
attrs = { height: type }, |
8939 |
i = 0; |
8940 |
|
8941 |
// if we include width, step value is 1 to do all cssExpand values, |
8942 |
// if we don't include width, step value is 2 to skip over Left and Right |
8943 |
includeWidth = includeWidth? 1 : 0; |
8944 |
for( ; i < 4 ; i += 2 - includeWidth ) { |
8945 |
which = cssExpand[ i ]; |
8946 |
attrs[ "margin" + which ] = attrs[ "padding" + which ] = type; |
8947 |
} |
8948 |
|
8949 |
if ( includeWidth ) { |
8950 |
attrs.opacity = attrs.width = type; |
8951 |
} |
8952 |
|
8953 |
return attrs; |
8954 |
} |
8955 |
|
8956 |
// Generate shortcuts for custom animations |
8957 |
jQuery.each({ |
8958 |
slideDown: genFx("show"), |
8959 |
slideUp: genFx("hide"), |
8960 |
slideToggle: genFx("toggle"), |
8961 |
fadeIn: { opacity: "show" }, |
8962 |
fadeOut: { opacity: "hide" }, |
8963 |
fadeToggle: { opacity: "toggle" } |
8964 |
}, function( name, props ) { |
8965 |
jQuery.fn[ name ] = function( speed, easing, callback ) { |
8966 |
return this.animate( props, speed, easing, callback ); |
8967 |
}; |
8968 |
}); |
8969 |
|
8970 |
jQuery.speed = function( speed, easing, fn ) { |
8971 |
var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { |
8972 |
complete: fn || !fn && easing || |
8973 |
jQuery.isFunction( speed ) && speed, |
8974 |
duration: speed, |
8975 |
easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing |
8976 |
}; |
8977 |
|
8978 |
opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : |
8979 |
opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default; |
8980 |
|
8981 |
// normalize opt.queue - true/undefined/null -> "fx" |
8982 |
if ( opt.queue == null || opt.queue === true ) { |
8983 |
opt.queue = "fx"; |
8984 |
} |
8985 |
|
8986 |
// Queueing |
8987 |
opt.old = opt.complete; |
8988 |
|
8989 |
opt.complete = function() { |
8990 |
if ( jQuery.isFunction( opt.old ) ) { |
8991 |
opt.old.call( this ); |
8992 |
} |
8993 |
|
8994 |
if ( opt.queue ) { |
8995 |
jQuery.dequeue( this, opt.queue ); |
8996 |
} |
8997 |
}; |
8998 |
|
8999 |
return opt; |
9000 |
}; |
9001 |
|
9002 |
jQuery.easing = { |
9003 |
linear: function( p ) { |
9004 |
return p; |
9005 |
}, |
9006 |
swing: function( p ) { |
9007 |
return 0.5 - Math.cos( p*Math.PI ) / 2; |
9008 |
} |
9009 |
}; |
9010 |
|
9011 |
jQuery.timers = []; |
9012 |
jQuery.fx = Tween.prototype.init; |
9013 |
jQuery.fx.tick = function() { |
9014 |
var timer, |
9015 |
timers = jQuery.timers, |
9016 |
i = 0; |
9017 |
|
9018 |
for ( ; i < timers.length; i++ ) { |
9019 |
timer = timers[ i ]; |
9020 |
// Checks the timer has not already been removed |
9021 |
if ( !timer() && timers[ i ] === timer ) { |
9022 |
timers.splice( i--, 1 ); |
9023 |
} |
9024 |
} |
9025 |
|
9026 |
if ( !timers.length ) { |
9027 |
jQuery.fx.stop(); |
9028 |
} |
9029 |
}; |
9030 |
|
9031 |
jQuery.fx.timer = function( timer ) { |
9032 |
if ( timer() && jQuery.timers.push( timer ) && !timerId ) { |
9033 |
timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval ); |
9034 |
} |
9035 |
}; |
9036 |
|
9037 |
jQuery.fx.interval = 13; |
9038 |
|
9039 |
jQuery.fx.stop = function() { |
9040 |
clearInterval( timerId ); |
9041 |
timerId = null; |
9042 |
}; |
9043 |
|
9044 |
jQuery.fx.speeds = { |
9045 |
slow: 600, |
9046 |
fast: 200, |
9047 |
// Default speed |
9048 |
_default: 400 |
9049 |
}; |
9050 |
|
9051 |
// Back Compat <1.8 extension point |
9052 |
jQuery.fx.step = {}; |
9053 |
|
9054 |
if ( jQuery.expr && jQuery.expr.filters ) { |
9055 |
jQuery.expr.filters.animated = function( elem ) { |
9056 |
return jQuery.grep(jQuery.timers, function( fn ) { |
9057 |
return elem === fn.elem; |
9058 |
}).length; |
9059 |
}; |
9060 |
} |
9061 |
var rroot = /^(?:body|html)$/i; |
9062 |
|
9063 |
jQuery.fn.offset = function( options ) { |
9064 |
if ( arguments.length ) { |
9065 |
return options === undefined ? |
9066 |
this : |
9067 |
this.each(function( i ) { |
9068 |
jQuery.offset.setOffset( this, options, i ); |
9069 |
}); |
9070 |
} |
9071 |
|
9072 |
var box, docElem, body, win, clientTop, clientLeft, scrollTop, scrollLeft, top, left, |
9073 |
elem = this[ 0 ], |
9074 |
doc = elem && elem.ownerDocument; |
9075 |
|
9076 |
if ( !doc ) { |
9077 |
return; |
9078 |
} |
9079 |
|
9080 |
if ( (body = doc.body) === elem ) { |
9081 |
return jQuery.offset.bodyOffset( elem ); |
9082 |
} |
9083 |
|
9084 |
docElem = doc.documentElement; |
9085 |
|
9086 |
// Make sure we're not dealing with a disconnected DOM node |
9087 |
if ( !jQuery.contains( docElem, elem ) ) { |
9088 |
return { top: 0, left: 0 }; |
9089 |
} |
9090 |
|
9091 |
box = elem.getBoundingClientRect(); |
9092 |
win = getWindow( doc ); |
9093 |
clientTop = docElem.clientTop || body.clientTop || 0; |
9094 |
clientLeft = docElem.clientLeft || body.clientLeft || 0; |
9095 |
scrollTop = win.pageYOffset || docElem.scrollTop; |
9096 |
scrollLeft = win.pageXOffset || docElem.scrollLeft; |
9097 |
top = box.top + scrollTop - clientTop; |
9098 |
left = box.left + scrollLeft - clientLeft; |
9099 |
|
9100 |
return { top: top, left: left }; |
9101 |
}; |
9102 |
|
9103 |
jQuery.offset = { |
9104 |
|
9105 |
bodyOffset: function( body ) { |
9106 |
var top = body.offsetTop, |
9107 |
left = body.offsetLeft; |
9108 |
|
9109 |
if ( jQuery.support.doesNotIncludeMarginInBodyOffset ) { |
9110 |
top += parseFloat( jQuery.css(body, "marginTop") ) || 0; |
9111 |
left += parseFloat( jQuery.css(body, "marginLeft") ) || 0; |
9112 |
} |
9113 |
|
9114 |
return { top: top, left: left }; |
9115 |
}, |
9116 |
|
9117 |
setOffset: function( elem, options, i ) { |
9118 |
var position = jQuery.css( elem, "position" ); |
9119 |
|
9120 |
// set position first, in-case top/left are set even on static elem |
9121 |
if ( position === "static" ) { |
9122 |
elem.style.position = "relative"; |
9123 |
} |
9124 |
|
9125 |
var curElem = jQuery( elem ), |
9126 |
curOffset = curElem.offset(), |
9127 |
curCSSTop = jQuery.css( elem, "top" ), |
9128 |
curCSSLeft = jQuery.css( elem, "left" ), |
9129 |
calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1, |
9130 |
props = {}, curPosition = {}, curTop, curLeft; |
9131 |
|
9132 |
// need to be able to calculate position if either top or left is auto and position is either absolute or fixed |
9133 |
if ( calculatePosition ) { |
9134 |
curPosition = curElem.position(); |
9135 |
curTop = curPosition.top; |
9136 |
curLeft = curPosition.left; |
9137 |
} else { |
9138 |
curTop = parseFloat( curCSSTop ) || 0; |
9139 |
curLeft = parseFloat( curCSSLeft ) || 0; |
9140 |
} |
9141 |
|
9142 |
if ( jQuery.isFunction( options ) ) { |
9143 |
options = options.call( elem, i, curOffset ); |
9144 |
} |
9145 |
|
9146 |
if ( options.top != null ) { |
9147 |
props.top = ( options.top - curOffset.top ) + curTop; |
9148 |
} |
9149 |
if ( options.left != null ) { |
9150 |
props.left = ( options.left - curOffset.left ) + curLeft; |
9151 |
} |
9152 |
|
9153 |
if ( "using" in options ) { |
9154 |
options.using.call( elem, props ); |
9155 |
} else { |
9156 |
curElem.css( props ); |
9157 |
} |
9158 |
} |
9159 |
}; |
9160 |
|
9161 |
|
9162 |
jQuery.fn.extend({ |
9163 |
|
9164 |
position: function() { |
9165 |
if ( !this[0] ) { |
9166 |
return; |
9167 |
} |
9168 |
|
9169 |
var elem = this[0], |
9170 |
|
9171 |
// Get *real* offsetParent |
9172 |
offsetParent = this.offsetParent(), |
9173 |
|
9174 |
// Get correct offsets |
9175 |
offset = this.offset(), |
9176 |
parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset(); |
9177 |
|
9178 |
// Subtract element margins |
9179 |
// note: when an element has margin: auto the offsetLeft and marginLeft |
9180 |
// are the same in Safari causing offset.left to incorrectly be 0 |
9181 |
offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0; |
9182 |
offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0; |
9183 |
|
9184 |
// Add offsetParent borders |
9185 |
parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0; |
9186 |
parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0; |
9187 |
|
9188 |
// Subtract the two offsets |
9189 |
return { |
9190 |
top: offset.top - parentOffset.top, |
9191 |
left: offset.left - parentOffset.left |
9192 |
}; |
9193 |
}, |
9194 |
|
9195 |
offsetParent: function() { |
9196 |
return this.map(function() { |
9197 |
var offsetParent = this.offsetParent || document.body; |
9198 |
while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) { |
9199 |
offsetParent = offsetParent.offsetParent; |
9200 |
} |
9201 |
return offsetParent || document.body; |
9202 |
}); |
9203 |
} |
9204 |
}); |
9205 |
|
9206 |
|
9207 |
// Create scrollLeft and scrollTop methods |
9208 |
jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) { |
9209 |
var top = /Y/.test( prop ); |
9210 |
|
9211 |
jQuery.fn[ method ] = function( val ) { |
9212 |
return jQuery.access( this, function( elem, method, val ) { |
9213 |
var win = getWindow( elem ); |
9214 |
|
9215 |
if ( val === undefined ) { |
9216 |
return win ? (prop in win) ? win[ prop ] : |
9217 |
win.document.documentElement[ method ] : |
9218 |
elem[ method ]; |
9219 |
} |
9220 |
|
9221 |
if ( win ) { |
9222 |
win.scrollTo( |
9223 |
!top ? val : jQuery( win ).scrollLeft(), |
9224 |
top ? val : jQuery( win ).scrollTop() |
9225 |
); |
9226 |
|
9227 |
} else { |
9228 |
elem[ method ] = val; |
9229 |
} |
9230 |
}, method, val, arguments.length, null ); |
9231 |
}; |
9232 |
}); |
9233 |
|
9234 |
function getWindow( elem ) { |
9235 |
return jQuery.isWindow( elem ) ? |
9236 |
elem : |
9237 |
elem.nodeType === 9 ? |
9238 |
elem.defaultView || elem.parentWindow : |
9239 |
false; |
9240 |
} |
9241 |
// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods |
9242 |
jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { |
9243 |
jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) { |
9244 |
// margin is only for outerHeight, outerWidth |
9245 |
jQuery.fn[ funcName ] = function( margin, value ) { |
9246 |
var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ), |
9247 |
extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" ); |
9248 |
|
9249 |
return jQuery.access( this, function( elem, type, value ) { |
9250 |
var doc; |
9251 |
|
9252 |
if ( jQuery.isWindow( elem ) ) { |
9253 |
// As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there |
9254 |
// isn't a whole lot we can do. See pull request at this URL for discussion: |
9255 |
// https://github.com/jquery/jquery/pull/764 |
9256 |
return elem.document.documentElement[ "client" + name ]; |
9257 |
} |
9258 |
|
9259 |
// Get document width or height |
9260 |
if ( elem.nodeType === 9 ) { |
9261 |
doc = elem.documentElement; |
9262 |
|
9263 |
// Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest |
9264 |
// unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it. |
9265 |
return Math.max( |
9266 |
elem.body[ "scroll" + name ], doc[ "scroll" + name ], |
9267 |
elem.body[ "offset" + name ], doc[ "offset" + name ], |
9268 |
doc[ "client" + name ] |
9269 |
); |
9270 |
} |
9271 |
|
9272 |
return value === undefined ? |
9273 |
// Get width or height on the element, requesting but not forcing parseFloat |
9274 |
jQuery.css( elem, type, value, extra ) : |
9275 |
|
9276 |
// Set width or height on the element |
9277 |
jQuery.style( elem, type, value, extra ); |
9278 |
}, type, chainable ? margin : undefined, chainable, null ); |
9279 |
}; |
9280 |
}); |
9281 |
}); |
9282 |
// Expose jQuery to the global object |
9283 |
window.jQuery = window.$ = jQuery; |
9284 |
|
9285 |
// Expose jQuery as an AMD module, but only for AMD loaders that |
9286 |
// understand the issues with loading multiple versions of jQuery |
9287 |
// in a page that all might call define(). The loader will indicate |
9288 |
// they have special allowances for multiple jQuery versions by |
9289 |
// specifying define.amd.jQuery = true. Register as a named module, |
9290 |
// since jQuery can be concatenated with other files that may use define, |
9291 |
// but not use a proper concatenation script that understands anonymous |
9292 |
// AMD modules. A named AMD is safest and most robust way to register. |
9293 |
// Lowercase jquery is used because AMD module names are derived from |
9294 |
// file names, and jQuery is normally delivered in a lowercase file name. |
9295 |
// Do this after creating the global so that if an AMD module wants to call |
9296 |
// noConflict to hide this version of jQuery, it will work. |
9297 |
if ( typeof define === "function" && define.amd && define.amd.jQuery ) { |
9298 |
define( "jquery", [], function () { return jQuery; } ); |
9299 |
} |
9300 |
|
9301 |
})( window ); |