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