Revize 2f31119d
Přidáno uživatelem Pavel Fidranský před asi 6 roky(ů)
sources/src/main/webapp/js/libs/jquery-1.8.3.js | ||
---|---|---|
1 |
|
|
2 |
/*! |
|
3 |
* jQuery JavaScript Library v1.8.3 |
|
4 |
* http://jquery.com/ |
|
5 |
* |
|
6 |
* Includes Sizzle.js |
|
7 |
* http://sizzlejs.com/ |
|
8 |
* |
|
9 |
* Copyright 2012 jQuery Foundation and other contributors |
|
10 |
* Released under the MIT license |
|
11 |
* http://jquery.org/license |
|
12 |
* |
|
13 |
* Date: Tue Nov 13 2012 08:20:33 GMT-0500 (Eastern Standard Time) |
|
14 |
*/ |
|
15 |
(function( window, undefined ) { |
|
16 |
var |
|
17 |
// A central reference to the root jQuery(document) |
|
18 |
rootjQuery, |
|
19 |
|
|
20 |
// The deferred used on DOM ready |
|
21 |
readyList, |
|
22 |
|
|
23 |
// Use the correct document accordingly with window argument (sandbox) |
|
24 |
document = window.document, |
|
25 |
location = window.location, |
|
26 |
navigator = window.navigator, |
|
27 |
|
|
28 |
// Map over jQuery in case of overwrite |
|
29 |
_jQuery = window.jQuery, |
|
30 |
|
|
31 |
// Map over the $ in case of overwrite |
|
32 |
_$ = window.$, |
|
33 |
|
|
34 |
// Save a reference to some core methods |
|
35 |
core_push = Array.prototype.push, |
|
36 |
core_slice = Array.prototype.slice, |
|
37 |
core_indexOf = Array.prototype.indexOf, |
|
38 |
core_toString = Object.prototype.toString, |
|
39 |
core_hasOwn = Object.prototype.hasOwnProperty, |
|
40 |
core_trim = String.prototype.trim, |
|
41 |
|
|
42 |
// Define a local copy of jQuery |
|
43 |
jQuery = function( selector, context ) { |
|
44 |
// The jQuery object is actually just the init constructor 'enhanced' |
|
45 |
return new jQuery.fn.init( selector, context, rootjQuery ); |
|
46 |
}, |
|
47 |
|
|
48 |
// Used for matching numbers |
|
49 |
core_pnum = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source, |
|
50 |
|
|
51 |
// Used for detecting and trimming whitespace |
|
52 |
core_rnotwhite = /\S/, |
|
53 |
core_rspace = /\s+/, |
|
54 |
|
|
55 |
// Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE) |
|
56 |
rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, |
|
57 |
|
|
58 |
// A simple way to check for HTML strings |
|
59 |
// Prioritize #id over <tag> to avoid XSS via location.hash (#9521) |
|
60 |
rquickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/, |
|
61 |
|
|
62 |
// Match a standalone tag |
|
63 |
rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/, |
|
64 |
|
|
65 |
// JSON RegExp |
|
66 |
rvalidchars = /^[\],:{}\s]*$/, |
|
67 |
rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, |
|
68 |
rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g, |
|
69 |
rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g, |
|
70 |
|
|
71 |
// Matches dashed string for camelizing |
|
72 |
rmsPrefix = /^-ms-/, |
|
73 |
rdashAlpha = /-([\da-z])/gi, |
|
74 |
|
|
75 |
// Used by jQuery.camelCase as callback to replace() |
|
76 |
fcamelCase = function( all, letter ) { |
|
77 |
return ( letter + "" ).toUpperCase(); |
|
78 |
}, |
|
79 |
|
|
80 |
// The ready event handler and self cleanup method |
|
81 |
DOMContentLoaded = function() { |
|
82 |
if ( document.addEventListener ) { |
|
83 |
document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false ); |
|
84 |
jQuery.ready(); |
|
85 |
} else if ( document.readyState === "complete" ) { |
|
86 |
// we're here because readyState === "complete" in oldIE |
|
87 |
// which is good enough for us to call the dom ready! |
|
88 |
document.detachEvent( "onreadystatechange", DOMContentLoaded ); |
|
89 |
jQuery.ready(); |
|
90 |
} |
|
91 |
}, |
|
92 |
|
|
93 |
// [[Class]] -> type pairs |
|
94 |
class2type = {}; |
|
95 |
|
|
96 |
jQuery.fn = jQuery.prototype = { |
|
97 |
constructor: jQuery, |
|
98 |
init: function( selector, context, rootjQuery ) { |
|
99 |
var match, elem, ret, doc; |
|
100 |
|
|
101 |
// Handle $(""), $(null), $(undefined), $(false) |
|
102 |
if ( !selector ) { |
|
103 |
return this; |
|
104 |
} |
|
105 |
|
|
106 |
// Handle $(DOMElement) |
|
107 |
if ( selector.nodeType ) { |
|
108 |
this.context = this[0] = selector; |
|
109 |
this.length = 1; |
|
110 |
return this; |
|
111 |
} |
|
112 |
|
|
113 |
// Handle HTML strings |
|
114 |
if ( typeof selector === "string" ) { |
|
115 |
if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { |
|
116 |
// Assume that strings that start and end with <> are HTML and skip the regex check |
|
117 |
match = [ null, selector, null ]; |
|
118 |
|
|
119 |
} else { |
|
120 |
match = rquickExpr.exec( selector ); |
|
121 |
} |
|
122 |
|
|
123 |
// Match html or make sure no context is specified for #id |
|
124 |
if ( match && (match[1] || !context) ) { |
|
125 |
|
|
126 |
// HANDLE: $(html) -> $(array) |
|
127 |
if ( match[1] ) { |
|
128 |
context = context instanceof jQuery ? context[0] : context; |
|
129 |
doc = ( context && context.nodeType ? context.ownerDocument || context : document ); |
|
130 |
|
|
131 |
// scripts is true for back-compat |
|
132 |
selector = jQuery.parseHTML( match[1], doc, true ); |
|
133 |
if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) { |
|
134 |
this.attr.call( selector, context, true ); |
|
135 |
} |
|
136 |
|
|
137 |
return jQuery.merge( this, selector ); |
|
138 |
|
|
139 |
// HANDLE: $(#id) |
|
140 |
} else { |
|
141 |
elem = document.getElementById( match[2] ); |
|
142 |
|
|
143 |
// Check parentNode to catch when Blackberry 4.6 returns |
|
144 |
// nodes that are no longer in the document #6963 |
|
145 |
if ( elem && elem.parentNode ) { |
|
146 |
// Handle the case where IE and Opera return items |
|
147 |
// by name instead of ID |
|
148 |
if ( elem.id !== match[2] ) { |
|
149 |
return rootjQuery.find( selector ); |
|
150 |
} |
|
151 |
|
|
152 |
// Otherwise, we inject the element directly into the jQuery object |
|
153 |
this.length = 1; |
|
154 |
this[0] = elem; |
|
155 |
} |
|
156 |
|
|
157 |
this.context = document; |
|
158 |
this.selector = selector; |
|
159 |
return this; |
|
160 |
} |
|
161 |
|
|
162 |
// HANDLE: $(expr, $(...)) |
|
163 |
} else if ( !context || context.jquery ) { |
|
164 |
return ( context || rootjQuery ).find( selector ); |
|
165 |
|
|
166 |
// HANDLE: $(expr, context) |
|
167 |
// (which is just equivalent to: $(context).find(expr) |
|
168 |
} else { |
|
169 |
return this.constructor( context ).find( selector ); |
|
170 |
} |
|
171 |
|
|
172 |
// HANDLE: $(function) |
|
173 |
// Shortcut for document ready |
|
174 |
} else if ( jQuery.isFunction( selector ) ) { |
|
175 |
return rootjQuery.ready( selector ); |
|
176 |
} |
|
177 |
|
|
178 |
if ( selector.selector !== undefined ) { |
|
179 |
this.selector = selector.selector; |
|
180 |
this.context = selector.context; |
|
181 |
} |
|
182 |
|
|
183 |
return jQuery.makeArray( selector, this ); |
|
184 |
}, |
|
185 |
|
|
186 |
// Start with an empty selector |
|
187 |
selector: "", |
|
188 |
|
|
189 |
// The current version of jQuery being used |
|
190 |
jquery: "1.8.3", |
|
191 |
|
|
192 |
// The default length of a jQuery object is 0 |
|
193 |
length: 0, |
|
194 |
|
|
195 |
// The number of elements contained in the matched element set |
|
196 |
size: function() { |
|
197 |
return this.length; |
|
198 |
}, |
|
199 |
|
|
200 |
toArray: function() { |
|
201 |
return core_slice.call( this ); |
|
202 |
}, |
|
203 |
|
|
204 |
// Get the Nth element in the matched element set OR |
|
205 |
// Get the whole matched element set as a clean array |
|
206 |
get: function( num ) { |
|
207 |
return num == null ? |
|
208 |
|
|
209 |
// Return a 'clean' array |
|
210 |
this.toArray() : |
|
211 |
|
|
212 |
// Return just the object |
|
213 |
( num < 0 ? this[ this.length + num ] : this[ num ] ); |
|
214 |
}, |
|
215 |
|
|
216 |
// Take an array of elements and push it onto the stack |
|
217 |
// (returning the new matched element set) |
|
218 |
pushStack: function( elems, name, selector ) { |
|
219 |
|
|
220 |
// Build a new jQuery matched element set |
|
221 |
var ret = jQuery.merge( this.constructor(), elems ); |
|
222 |
|
|
223 |
// Add the old object onto the stack (as a reference) |
|
224 |
ret.prevObject = this; |
|
225 |
|
|
226 |
ret.context = this.context; |
|
227 |
|
|
228 |
if ( name === "find" ) { |
|
229 |
ret.selector = this.selector + ( this.selector ? " " : "" ) + selector; |
|
230 |
} else if ( name ) { |
|
231 |
ret.selector = this.selector + "." + name + "(" + selector + ")"; |
|
232 |
} |
|
233 |
|
|
234 |
// Return the newly-formed element set |
|
235 |
return ret; |
|
236 |
}, |
|
237 |
|
|
238 |
// Execute a callback for every element in the matched set. |
|
239 |
// (You can seed the arguments with an array of args, but this is |
|
240 |
// only used internally.) |
|
241 |
each: function( callback, args ) { |
|
242 |
return jQuery.each( this, callback, args ); |
|
243 |
}, |
|
244 |
|
|
245 |
ready: function( fn ) { |
|
246 |
// Add the callback |
|
247 |
jQuery.ready.promise().done( fn ); |
|
248 |
|
|
249 |
return this; |
|
250 |
}, |
|
251 |
|
|
252 |
eq: function( i ) { |
|
253 |
i = +i; |
|
254 |
return i === -1 ? |
|
255 |
this.slice( i ) : |
|
256 |
this.slice( i, i + 1 ); |
|
257 |
}, |
|
258 |
|
|
259 |
first: function() { |
|
260 |
return this.eq( 0 ); |
|
261 |
}, |
|
262 |
|
|
263 |
last: function() { |
|
264 |
return this.eq( -1 ); |
|
265 |
}, |
|
266 |
|
|
267 |
slice: function() { |
|
268 |
return this.pushStack( core_slice.apply( this, arguments ), |
|
269 |
"slice", core_slice.call(arguments).join(",") ); |
|
270 |
}, |
|
271 |
|
|
272 |
map: function( callback ) { |
|
273 |
return this.pushStack( jQuery.map(this, function( elem, i ) { |
|
274 |
return callback.call( elem, i, elem ); |
|
275 |
})); |
|
276 |
}, |
|
277 |
|
|
278 |
end: function() { |
|
279 |
return this.prevObject || this.constructor(null); |
|
280 |
}, |
|
281 |
|
|
282 |
// For internal use only. |
|
283 |
// Behaves like an Array's method, not like a jQuery method. |
|
284 |
push: core_push, |
|
285 |
sort: [].sort, |
|
286 |
splice: [].splice |
|
287 |
}; |
|
288 |
|
|
289 |
// Give the init function the jQuery prototype for later instantiation |
|
290 |
jQuery.fn.init.prototype = jQuery.fn; |
|
291 |
|
|
292 |
jQuery.extend = jQuery.fn.extend = function() { |
|
293 |
var options, name, src, copy, copyIsArray, clone, |
|
294 |
target = arguments[0] || {}, |
|
295 |
i = 1, |
|
296 |
length = arguments.length, |
|
297 |
deep = false; |
|
298 |
|
|
299 |
// Handle a deep copy situation |
|
300 |
if ( typeof target === "boolean" ) { |
|
301 |
deep = target; |
|
302 |
target = arguments[1] || {}; |
|
303 |
// skip the boolean and the target |
|
304 |
i = 2; |
|
305 |
} |
|
306 |
|
|
307 |
// Handle case when target is a string or something (possible in deep copy) |
|
308 |
if ( typeof target !== "object" && !jQuery.isFunction(target) ) { |
|
309 |
target = {}; |
|
310 |
} |
|
311 |
|
|
312 |
// extend jQuery itself if only one argument is passed |
|
313 |
if ( length === i ) { |
|
314 |
target = this; |
|
315 |
--i; |
|
316 |
} |
|
317 |
|
|
318 |
for ( ; i < length; i++ ) { |
|
319 |
// Only deal with non-null/undefined values |
|
320 |
if ( (options = arguments[ i ]) != null ) { |
|
321 |
// Extend the base object |
|
322 |
for ( name in options ) { |
|
323 |
src = target[ name ]; |
|
324 |
copy = options[ name ]; |
|
325 |
|
|
326 |
// Prevent never-ending loop |
|
327 |
if ( target === copy ) { |
|
328 |
continue; |
|
329 |
} |
|
330 |
|
|
331 |
// Recurse if we're merging plain objects or arrays |
|
332 |
if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { |
|
333 |
if ( copyIsArray ) { |
|
334 |
copyIsArray = false; |
|
335 |
clone = src && jQuery.isArray(src) ? src : []; |
|
336 |
|
|
337 |
} else { |
|
338 |
clone = src && jQuery.isPlainObject(src) ? src : {}; |
|
339 |
} |
|
340 |
|
|
341 |
// Never move original objects, clone them |
|
342 |
target[ name ] = jQuery.extend( deep, clone, copy ); |
|
343 |
|
|
344 |
// Don't bring in undefined values |
|
345 |
} else if ( copy !== undefined ) { |
|
346 |
target[ name ] = copy; |
|
347 |
} |
|
348 |
} |
|
349 |
} |
|
350 |
} |
|
351 |
|
|
352 |
// Return the modified object |
|
353 |
return target; |
|
354 |
}; |
|
355 |
|
|
356 |
jQuery.extend({ |
|
357 |
noConflict: function( deep ) { |
|
358 |
if ( window.$ === jQuery ) { |
|
359 |
window.$ = _$; |
|
360 |
} |
|
361 |
|
|
362 |
if ( deep && window.jQuery === jQuery ) { |
|
363 |
window.jQuery = _jQuery; |
|
364 |
} |
|
365 |
|
|
366 |
return jQuery; |
|
367 |
}, |
|
368 |
|
|
369 |
// Is the DOM ready to be used? Set to true once it occurs. |
|
370 |
isReady: false, |
|
371 |
|
|
372 |
// A counter to track how many items to wait for before |
|
373 |
// the ready event fires. See #6781 |
|
374 |
readyWait: 1, |
|
375 |
|
|
376 |
// Hold (or release) the ready event |
|
377 |
holdReady: function( hold ) { |
|
378 |
if ( hold ) { |
|
379 |
jQuery.readyWait++; |
|
380 |
} else { |
|
381 |
jQuery.ready( true ); |
|
382 |
} |
|
383 |
}, |
|
384 |
|
|
385 |
// Handle when the DOM is ready |
|
386 |
ready: function( wait ) { |
|
387 |
|
|
388 |
// Abort if there are pending holds or we're already ready |
|
389 |
if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { |
|
390 |
return; |
|
391 |
} |
|
392 |
|
|
393 |
// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). |
|
394 |
if ( !document.body ) { |
|
395 |
return setTimeout( jQuery.ready, 1 ); |
|
396 |
} |
|
397 |
|
|
398 |
// Remember that the DOM is ready |
|
399 |
jQuery.isReady = true; |
|
400 |
|
|
401 |
// If a normal DOM Ready event fired, decrement, and wait if need be |
|
402 |
if ( wait !== true && --jQuery.readyWait > 0 ) { |
|
403 |
return; |
|
404 |
} |
|
405 |
|
|
406 |
// If there are functions bound, to execute |
|
407 |
readyList.resolveWith( document, [ jQuery ] ); |
|
408 |
|
|
409 |
// Trigger any bound ready events |
|
410 |
if ( jQuery.fn.trigger ) { |
|
411 |
jQuery( document ).trigger("ready").off("ready"); |
|
412 |
} |
|
413 |
}, |
|
414 |
|
|
415 |
// See test/unit/core.js for details concerning isFunction. |
|
416 |
// Since version 1.3, DOM methods and functions like alert |
|
417 |
// aren't supported. They return false on IE (#2968). |
|
418 |
isFunction: function( obj ) { |
|
419 |
return jQuery.type(obj) === "function"; |
|
420 |
}, |
|
421 |
|
|
422 |
isArray: Array.isArray || function( obj ) { |
|
423 |
return jQuery.type(obj) === "array"; |
|
424 |
}, |
|
425 |
|
|
426 |
isWindow: function( obj ) { |
|
427 |
return obj != null && obj == obj.window; |
|
428 |
}, |
|
429 |
|
|
430 |
isNumeric: function( obj ) { |
|
431 |
return !isNaN( parseFloat(obj) ) && isFinite( obj ); |
|
432 |
}, |
|
433 |
|
|
434 |
type: function( obj ) { |
|
435 |
return obj == null ? |
|
436 |
String( obj ) : |
|
437 |
class2type[ core_toString.call(obj) ] || "object"; |
|
438 |
}, |
|
439 |
|
|
440 |
isPlainObject: function( obj ) { |
|
441 |
// Must be an Object. |
|
442 |
// Because of IE, we also have to check the presence of the constructor property. |
|
443 |
// Make sure that DOM nodes and window objects don't pass through, as well |
|
444 |
if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { |
|
445 |
return false; |
|
446 |
} |
|
447 |
|
|
448 |
try { |
|
449 |
// Not own constructor property must be Object |
|
450 |
if ( obj.constructor && |
|
451 |
!core_hasOwn.call(obj, "constructor") && |
|
452 |
!core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { |
|
453 |
return false; |
|
454 |
} |
|
455 |
} catch ( e ) { |
|
456 |
// IE8,9 Will throw exceptions on certain host objects #9897 |
|
457 |
return false; |
|
458 |
} |
|
459 |
|
|
460 |
// Own properties are enumerated firstly, so to speed up, |
|
461 |
// if last one is own, then all properties are own. |
|
462 |
|
|
463 |
var key; |
|
464 |
for ( key in obj ) {} |
|
465 |
|
|
466 |
return key === undefined || core_hasOwn.call( obj, key ); |
|
467 |
}, |
|
468 |
|
|
469 |
isEmptyObject: function( obj ) { |
|
470 |
var name; |
|
471 |
for ( name in obj ) { |
|
472 |
return false; |
|
473 |
} |
|
474 |
return true; |
|
475 |
}, |
|
476 |
|
|
477 |
error: function( msg ) { |
|
478 |
throw new Error( msg ); |
|
479 |
}, |
|
480 |
|
|
481 |
// data: string of html |
|
482 |
// context (optional): If specified, the fragment will be created in this context, defaults to document |
|
483 |
// scripts (optional): If true, will include scripts passed in the html string |
|
484 |
parseHTML: function( data, context, scripts ) { |
|
485 |
var parsed; |
|
486 |
if ( !data || typeof data !== "string" ) { |
|
487 |
return null; |
|
488 |
} |
|
489 |
if ( typeof context === "boolean" ) { |
|
490 |
scripts = context; |
|
491 |
context = 0; |
|
492 |
} |
|
493 |
context = context || document; |
|
494 |
|
|
495 |
// Single tag |
|
496 |
if ( (parsed = rsingleTag.exec( data )) ) { |
|
497 |
return [ context.createElement( parsed[1] ) ]; |
|
498 |
} |
|
499 |
|
|
500 |
parsed = jQuery.buildFragment( [ data ], context, scripts ? null : [] ); |
|
501 |
return jQuery.merge( [], |
|
502 |
(parsed.cacheable ? jQuery.clone( parsed.fragment ) : parsed.fragment).childNodes ); |
|
503 |
}, |
|
504 |
|
|
505 |
parseJSON: function( data ) { |
|
506 |
if ( !data || typeof data !== "string") { |
|
507 |
return null; |
|
508 |
} |
|
509 |
|
|
510 |
// Make sure leading/trailing whitespace is removed (IE can't handle it) |
|
511 |
data = jQuery.trim( data ); |
|
512 |
|
|
513 |
// Attempt to parse using the native JSON parser first |
|
514 |
if ( window.JSON && window.JSON.parse ) { |
|
515 |
return window.JSON.parse( data ); |
|
516 |
} |
|
517 |
|
|
518 |
// Make sure the incoming data is actual JSON |
|
519 |
// Logic borrowed from http://json.org/json2.js |
|
520 |
if ( rvalidchars.test( data.replace( rvalidescape, "@" ) |
|
521 |
.replace( rvalidtokens, "]" ) |
|
522 |
.replace( rvalidbraces, "")) ) { |
|
523 |
|
|
524 |
return ( new Function( "return " + data ) )(); |
|
525 |
|
|
526 |
} |
|
527 |
jQuery.error( "Invalid JSON: " + data ); |
|
528 |
}, |
|
529 |
|
|
530 |
// Cross-browser xml parsing |
|
531 |
parseXML: function( data ) { |
|
532 |
var xml, tmp; |
|
533 |
if ( !data || typeof data !== "string" ) { |
|
534 |
return null; |
|
535 |
} |
|
536 |
try { |
|
537 |
if ( window.DOMParser ) { // Standard |
|
538 |
tmp = new DOMParser(); |
|
539 |
xml = tmp.parseFromString( data , "text/xml" ); |
|
540 |
} else { // IE |
|
541 |
xml = new ActiveXObject( "Microsoft.XMLDOM" ); |
|
542 |
xml.async = "false"; |
|
543 |
xml.loadXML( data ); |
|
544 |
} |
|
545 |
} catch( e ) { |
|
546 |
xml = undefined; |
|
547 |
} |
|
548 |
if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) { |
|
549 |
jQuery.error( "Invalid XML: " + data ); |
|
550 |
} |
|
551 |
return xml; |
|
552 |
}, |
|
553 |
|
|
554 |
noop: function() {}, |
|
555 |
|
|
556 |
// Evaluates a script in a global context |
|
557 |
// Workarounds based on findings by Jim Driscoll |
|
558 |
// http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context |
|
559 |
globalEval: function( data ) { |
|
560 |
if ( data && core_rnotwhite.test( data ) ) { |
|
561 |
// We use execScript on Internet Explorer |
|
562 |
// We use an anonymous function so that context is window |
|
563 |
// rather than jQuery in Firefox |
|
564 |
( window.execScript || function( data ) { |
|
565 |
window[ "eval" ].call( window, data ); |
|
566 |
} )( data ); |
|
567 |
} |
|
568 |
}, |
|
569 |
|
|
570 |
// Convert dashed to camelCase; used by the css and data modules |
|
571 |
// Microsoft forgot to hump their vendor prefix (#9572) |
|
572 |
camelCase: function( string ) { |
|
573 |
return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); |
|
574 |
}, |
|
575 |
|
|
576 |
nodeName: function( elem, name ) { |
|
577 |
return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); |
|
578 |
}, |
|
579 |
|
|
580 |
// args is for internal usage only |
|
581 |
each: function( obj, callback, args ) { |
|
582 |
var name, |
|
583 |
i = 0, |
|
584 |
length = obj.length, |
|
585 |
isObj = length === undefined || jQuery.isFunction( obj ); |
|
586 |
|
|
587 |
if ( args ) { |
|
588 |
if ( isObj ) { |
|
589 |
for ( name in obj ) { |
|
590 |
if ( callback.apply( obj[ name ], args ) === false ) { |
|
591 |
break; |
|
592 |
} |
|
593 |
} |
|
594 |
} else { |
|
595 |
for ( ; i < length; ) { |
|
596 |
if ( callback.apply( obj[ i++ ], args ) === false ) { |
|
597 |
break; |
|
598 |
} |
|
599 |
} |
|
600 |
} |
|
601 |
|
|
602 |
// A special, fast, case for the most common use of each |
|
603 |
} else { |
|
604 |
if ( isObj ) { |
|
605 |
for ( name in obj ) { |
|
606 |
if ( callback.call( obj[ name ], name, obj[ name ] ) === false ) { |
|
607 |
break; |
|
608 |
} |
|
609 |
} |
|
610 |
} else { |
|
611 |
for ( ; i < length; ) { |
|
612 |
if ( callback.call( obj[ i ], i, obj[ i++ ] ) === false ) { |
|
613 |
break; |
|
614 |
} |
|
615 |
} |
|
616 |
} |
|
617 |
} |
|
618 |
|
|
619 |
return obj; |
|
620 |
}, |
|
621 |
|
|
622 |
// Use native String.trim function wherever possible |
|
623 |
trim: core_trim && !core_trim.call("\uFEFF\xA0") ? |
|
624 |
function( text ) { |
|
625 |
return text == null ? |
|
626 |
"" : |
|
627 |
core_trim.call( text ); |
|
628 |
} : |
|
629 |
|
|
630 |
// Otherwise use our own trimming functionality |
|
631 |
function( text ) { |
|
632 |
return text == null ? |
|
633 |
"" : |
|
634 |
( text + "" ).replace( rtrim, "" ); |
|
635 |
}, |
|
636 |
|
|
637 |
// results is for internal usage only |
|
638 |
makeArray: function( arr, results ) { |
|
639 |
var type, |
|
640 |
ret = results || []; |
|
641 |
|
|
642 |
if ( arr != null ) { |
|
643 |
// The window, strings (and functions) also have 'length' |
|
644 |
// Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930 |
|
645 |
type = jQuery.type( arr ); |
|
646 |
|
|
647 |
if ( arr.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( arr ) ) { |
|
648 |
core_push.call( ret, arr ); |
|
649 |
} else { |
|
650 |
jQuery.merge( ret, arr ); |
|
651 |
} |
|
652 |
} |
|
653 |
|
|
654 |
return ret; |
|
655 |
}, |
|
656 |
|
|
657 |
inArray: function( elem, arr, i ) { |
|
658 |
var len; |
|
659 |
|
|
660 |
if ( arr ) { |
|
661 |
if ( core_indexOf ) { |
|
662 |
return core_indexOf.call( arr, elem, i ); |
|
663 |
} |
|
664 |
|
|
665 |
len = arr.length; |
|
666 |
i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0; |
|
667 |
|
|
668 |
for ( ; i < len; i++ ) { |
|
669 |
// Skip accessing in sparse arrays |
|
670 |
if ( i in arr && arr[ i ] === elem ) { |
|
671 |
return i; |
|
672 |
} |
|
673 |
} |
|
674 |
} |
|
675 |
|
|
676 |
return -1; |
|
677 |
}, |
|
678 |
|
|
679 |
merge: function( first, second ) { |
|
680 |
var l = second.length, |
|
681 |
i = first.length, |
|
682 |
j = 0; |
|
683 |
|
|
684 |
if ( typeof l === "number" ) { |
|
685 |
for ( ; j < l; j++ ) { |
|
686 |
first[ i++ ] = second[ j ]; |
|
687 |
} |
|
688 |
|
|
689 |
} else { |
|
690 |
while ( second[j] !== undefined ) { |
|
691 |
first[ i++ ] = second[ j++ ]; |
|
692 |
} |
|
693 |
} |
|
694 |
|
|
695 |
first.length = i; |
|
696 |
|
|
697 |
return first; |
|
698 |
}, |
|
699 |
|
|
700 |
grep: function( elems, callback, inv ) { |
|
701 |
var retVal, |
|
702 |
ret = [], |
|
703 |
i = 0, |
|
704 |
length = elems.length; |
|
705 |
inv = !!inv; |
|
706 |
|
|
707 |
// Go through the array, only saving the items |
|
708 |
// that pass the validator function |
|
709 |
for ( ; i < length; i++ ) { |
|
710 |
retVal = !!callback( elems[ i ], i ); |
|
711 |
if ( inv !== retVal ) { |
|
712 |
ret.push( elems[ i ] ); |
|
713 |
} |
|
714 |
} |
|
715 |
|
|
716 |
return ret; |
|
717 |
}, |
|
718 |
|
|
719 |
// arg is for internal usage only |
|
720 |
map: function( elems, callback, arg ) { |
|
721 |
var value, key, |
|
722 |
ret = [], |
|
723 |
i = 0, |
|
724 |
length = elems.length, |
|
725 |
// jquery objects are treated as arrays |
|
726 |
isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ; |
|
727 |
|
|
728 |
// Go through the array, translating each of the items to their |
|
729 |
if ( isArray ) { |
|
730 |
for ( ; i < length; i++ ) { |
|
731 |
value = callback( elems[ i ], i, arg ); |
|
732 |
|
|
733 |
if ( value != null ) { |
|
734 |
ret[ ret.length ] = value; |
|
735 |
} |
|
736 |
} |
|
737 |
|
|
738 |
// Go through every key on the object, |
|
739 |
} else { |
|
740 |
for ( key in elems ) { |
|
741 |
value = callback( elems[ key ], key, arg ); |
|
742 |
|
|
743 |
if ( value != null ) { |
|
744 |
ret[ ret.length ] = value; |
|
745 |
} |
|
746 |
} |
|
747 |
} |
|
748 |
|
|
749 |
// Flatten any nested arrays |
|
750 |
return ret.concat.apply( [], ret ); |
|
751 |
}, |
|
752 |
|
|
753 |
// A global GUID counter for objects |
|
754 |
guid: 1, |
|
755 |
|
|
756 |
// Bind a function to a context, optionally partially applying any |
|
757 |
// arguments. |
|
758 |
proxy: function( fn, context ) { |
|
759 |
var tmp, args, proxy; |
|
760 |
|
|
761 |
if ( typeof context === "string" ) { |
|
762 |
tmp = fn[ context ]; |
|
763 |
context = fn; |
|
764 |
fn = tmp; |
|
765 |
} |
|
766 |
|
|
767 |
// Quick check to determine if target is callable, in the spec |
|
768 |
// this throws a TypeError, but we will just return undefined. |
|
769 |
if ( !jQuery.isFunction( fn ) ) { |
|
770 |
return undefined; |
|
771 |
} |
|
772 |
|
|
773 |
// Simulated bind |
|
774 |
args = core_slice.call( arguments, 2 ); |
|
775 |
proxy = function() { |
|
776 |
return fn.apply( context, args.concat( core_slice.call( arguments ) ) ); |
|
777 |
}; |
|
778 |
|
|
779 |
// Set the guid of unique handler to the same of original handler, so it can be removed |
|
780 |
proxy.guid = fn.guid = fn.guid || jQuery.guid++; |
|
781 |
|
|
782 |
return proxy; |
|
783 |
}, |
|
784 |
|
|
785 |
// Multifunctional method to get and set values of a collection |
|
786 |
// The value/s can optionally be executed if it's a function |
|
787 |
access: function( elems, fn, key, value, chainable, emptyGet, pass ) { |
|
788 |
var exec, |
|
789 |
bulk = key == null, |
|
790 |
i = 0, |
|
791 |
length = elems.length; |
|
792 |
|
|
793 |
// Sets many values |
|
794 |
if ( key && typeof key === "object" ) { |
|
795 |
for ( i in key ) { |
|
796 |
jQuery.access( elems, fn, i, key[i], 1, emptyGet, value ); |
|
797 |
} |
|
798 |
chainable = 1; |
|
799 |
|
|
800 |
// Sets one value |
|
801 |
} else if ( value !== undefined ) { |
|
802 |
// Optionally, function values get executed if exec is true |
|
803 |
exec = pass === undefined && jQuery.isFunction( value ); |
|
804 |
|
|
805 |
if ( bulk ) { |
|
806 |
// Bulk operations only iterate when executing function values |
|
807 |
if ( exec ) { |
|
808 |
exec = fn; |
|
809 |
fn = function( elem, key, value ) { |
|
810 |
return exec.call( jQuery( elem ), value ); |
|
811 |
}; |
|
812 |
|
|
813 |
// Otherwise they run against the entire set |
|
814 |
} else { |
|
815 |
fn.call( elems, value ); |
|
816 |
fn = null; |
|
817 |
} |
|
818 |
} |
|
819 |
|
|
820 |
if ( fn ) { |
|
821 |
for (; i < length; i++ ) { |
|
822 |
fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass ); |
|
823 |
} |
|
824 |
} |
|
825 |
|
|
826 |
chainable = 1; |
|
827 |
} |
|
828 |
|
|
829 |
return chainable ? |
|
830 |
elems : |
|
831 |
|
|
832 |
// Gets |
|
833 |
bulk ? |
|
834 |
fn.call( elems ) : |
|
835 |
length ? fn( elems[0], key ) : emptyGet; |
|
836 |
}, |
|
837 |
|
|
838 |
now: function() { |
|
839 |
return ( new Date() ).getTime(); |
|
840 |
} |
|
841 |
}); |
|
842 |
|
|
843 |
jQuery.ready.promise = function( obj ) { |
|
844 |
if ( !readyList ) { |
|
845 |
|
|
846 |
readyList = jQuery.Deferred(); |
|
847 |
|
|
848 |
// Catch cases where $(document).ready() is called after the browser event has already occurred. |
|
849 |
// we once tried to use readyState "interactive" here, but it caused issues like the one |
|
850 |
// discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 |
|
851 |
if ( document.readyState === "complete" ) { |
|
852 |
// Handle it asynchronously to allow scripts the opportunity to delay ready |
|
853 |
setTimeout( jQuery.ready, 1 ); |
|
854 |
|
|
855 |
// Standards-based browsers support DOMContentLoaded |
|
856 |
} else if ( document.addEventListener ) { |
|
857 |
// Use the handy event callback |
|
858 |
document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); |
|
859 |
|
|
860 |
// A fallback to window.onload, that will always work |
|
861 |
window.addEventListener( "load", jQuery.ready, false ); |
|
862 |
|
|
863 |
// If IE event model is used |
|
864 |
} else { |
|
865 |
// Ensure firing before onload, maybe late but safe also for iframes |
|
866 |
document.attachEvent( "onreadystatechange", DOMContentLoaded ); |
|
867 |
|
|
868 |
// A fallback to window.onload, that will always work |
|
869 |
window.attachEvent( "onload", jQuery.ready ); |
|
870 |
|
|
871 |
// If IE and not a frame |
|
872 |
// continually check to see if the document is ready |
|
873 |
var top = false; |
|
874 |
|
|
875 |
try { |
|
876 |
top = window.frameElement == null && document.documentElement; |
|
877 |
} catch(e) {} |
|
878 |
|
|
879 |
if ( top && top.doScroll ) { |
|
880 |
(function doScrollCheck() { |
|
881 |
if ( !jQuery.isReady ) { |
|
882 |
|
|
883 |
try { |
|
884 |
// Use the trick by Diego Perini |
|
885 |
// http://javascript.nwbox.com/IEContentLoaded/ |
|
886 |
top.doScroll("left"); |
|
887 |
} catch(e) { |
|
888 |
return setTimeout( doScrollCheck, 50 ); |
|
889 |
} |
|
890 |
|
|
891 |
// and execute any waiting functions |
|
892 |
jQuery.ready(); |
|
893 |
} |
|
894 |
})(); |
|
895 |
} |
|
896 |
} |
|
897 |
} |
|
898 |
return readyList.promise( obj ); |
|
899 |
}; |
|
900 |
|
|
901 |
// Populate the class2type map |
|
902 |
jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) { |
|
903 |
class2type[ "[object " + name + "]" ] = name.toLowerCase(); |
|
904 |
}); |
|
905 |
|
|
906 |
// All jQuery objects should point back to these |
|
907 |
rootjQuery = jQuery(document); |
|
908 |
// String to Object options format cache |
|
909 |
var optionsCache = {}; |
|
910 |
|
|
911 |
// Convert String-formatted options into Object-formatted ones and store in cache |
|
912 |
function createOptions( options ) { |
|
913 |
var object = optionsCache[ options ] = {}; |
|
914 |
jQuery.each( options.split( core_rspace ), function( _, flag ) { |
|
915 |
object[ flag ] = true; |
|
916 |
}); |
|
917 |
return object; |
|
918 |
} |
|
919 |
|
|
920 |
/* |
|
921 |
* Create a callback list using the following parameters: |
|
922 |
* |
|
923 |
* options: an optional list of space-separated options that will change how |
|
924 |
* the callback list behaves or a more traditional option object |
|
925 |
* |
|
926 |
* By default a callback list will act like an event callback list and can be |
|
927 |
* "fired" multiple times. |
|
928 |
* |
|
929 |
* Possible options: |
|
930 |
* |
|
931 |
* once: will ensure the callback list can only be fired once (like a Deferred) |
|
932 |
* |
|
933 |
* memory: will keep track of previous values and will call any callback added |
|
934 |
* after the list has been fired right away with the latest "memorized" |
|
935 |
* values (like a Deferred) |
|
936 |
* |
|
937 |
* unique: will ensure a callback can only be added once (no duplicate in the list) |
|
938 |
* |
|
939 |
* stopOnFalse: interrupt callings when a callback returns false |
|
940 |
* |
|
941 |
*/ |
|
942 |
jQuery.Callbacks = function( options ) { |
|
943 |
|
|
944 |
// Convert options from String-formatted to Object-formatted if needed |
|
945 |
// (we check in cache first) |
|
946 |
options = typeof options === "string" ? |
|
947 |
( optionsCache[ options ] || createOptions( options ) ) : |
|
948 |
jQuery.extend( {}, options ); |
|
949 |
|
|
950 |
var // Last fire value (for non-forgettable lists) |
|
951 |
memory, |
|
952 |
// Flag to know if list was already fired |
|
953 |
fired, |
|
954 |
// Flag to know if list is currently firing |
|
955 |
firing, |
|
956 |
// First callback to fire (used internally by add and fireWith) |
|
957 |
firingStart, |
|
958 |
// End of the loop when firing |
|
959 |
firingLength, |
|
960 |
// Index of currently firing callback (modified by remove if needed) |
|
961 |
firingIndex, |
|
962 |
// Actual callback list |
|
963 |
list = [], |
|
964 |
// Stack of fire calls for repeatable lists |
|
965 |
stack = !options.once && [], |
|
966 |
// Fire callbacks |
|
967 |
fire = function( data ) { |
|
968 |
memory = options.memory && data; |
|
969 |
fired = true; |
|
970 |
firingIndex = firingStart || 0; |
|
971 |
firingStart = 0; |
|
972 |
firingLength = list.length; |
|
973 |
firing = true; |
|
974 |
for ( ; list && firingIndex < firingLength; firingIndex++ ) { |
|
975 |
if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) { |
|
976 |
memory = false; // To prevent further calls using add |
|
977 |
break; |
|
978 |
} |
|
979 |
} |
|
980 |
firing = false; |
|
981 |
if ( list ) { |
|
982 |
if ( stack ) { |
|
983 |
if ( stack.length ) { |
|
984 |
fire( stack.shift() ); |
|
985 |
} |
|
986 |
} else if ( memory ) { |
|
987 |
list = []; |
|
988 |
} else { |
|
989 |
self.disable(); |
|
990 |
} |
|
991 |
} |
|
992 |
}, |
|
993 |
// Actual Callbacks object |
|
994 |
self = { |
|
995 |
// Add a callback or a collection of callbacks to the list |
|
996 |
add: function() { |
|
997 |
if ( list ) { |
|
998 |
// First, we save the current length |
|
999 |
var start = list.length; |
|
1000 |
(function add( args ) { |
|
1001 |
jQuery.each( args, function( _, arg ) { |
|
1002 |
var type = jQuery.type( arg ); |
|
1003 |
if ( type === "function" ) { |
|
1004 |
if ( !options.unique || !self.has( arg ) ) { |
|
1005 |
list.push( arg ); |
|
1006 |
} |
|
1007 |
} else if ( arg && arg.length && type !== "string" ) { |
|
1008 |
// Inspect recursively |
|
1009 |
add( arg ); |
|
1010 |
} |
|
1011 |
}); |
|
1012 |
})( arguments ); |
|
1013 |
// Do we need to add the callbacks to the |
|
1014 |
// current firing batch? |
|
1015 |
if ( firing ) { |
|
1016 |
firingLength = list.length; |
|
1017 |
// With memory, if we're not firing then |
|
1018 |
// we should call right away |
|
1019 |
} else if ( memory ) { |
|
1020 |
firingStart = start; |
|
1021 |
fire( memory ); |
|
1022 |
} |
|
1023 |
} |
|
1024 |
return this; |
|
1025 |
}, |
|
1026 |
// Remove a callback from the list |
|
1027 |
remove: function() { |
|
1028 |
if ( list ) { |
|
1029 |
jQuery.each( arguments, function( _, arg ) { |
|
1030 |
var index; |
|
1031 |
while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { |
|
1032 |
list.splice( index, 1 ); |
|
1033 |
// Handle firing indexes |
|
1034 |
if ( firing ) { |
|
1035 |
if ( index <= firingLength ) { |
|
1036 |
firingLength--; |
|
1037 |
} |
|
1038 |
if ( index <= firingIndex ) { |
|
1039 |
firingIndex--; |
|
1040 |
} |
|
1041 |
} |
|
1042 |
} |
|
1043 |
}); |
|
1044 |
} |
|
1045 |
return this; |
|
1046 |
}, |
|
1047 |
// Control if a given callback is in the list |
|
1048 |
has: function( fn ) { |
|
1049 |
return jQuery.inArray( fn, list ) > -1; |
|
1050 |
}, |
|
1051 |
// Remove all callbacks from the list |
|
1052 |
empty: function() { |
|
1053 |
list = []; |
|
1054 |
return this; |
|
1055 |
}, |
|
1056 |
// Have the list do nothing anymore |
|
1057 |
disable: function() { |
|
1058 |
list = stack = memory = undefined; |
|
1059 |
return this; |
|
1060 |
}, |
|
1061 |
// Is it disabled? |
|
1062 |
disabled: function() { |
|
1063 |
return !list; |
|
1064 |
}, |
|
1065 |
// Lock the list in its current state |
|
1066 |
lock: function() { |
|
1067 |
stack = undefined; |
|
1068 |
if ( !memory ) { |
|
1069 |
self.disable(); |
|
1070 |
} |
|
1071 |
return this; |
|
1072 |
}, |
|
1073 |
// Is it locked? |
|
1074 |
locked: function() { |
|
1075 |
return !stack; |
|
1076 |
}, |
|
1077 |
// Call all callbacks with the given context and arguments |
|
1078 |
fireWith: function( context, args ) { |
|
1079 |
args = args || []; |
|
1080 |
args = [ context, args.slice ? args.slice() : args ]; |
|
1081 |
if ( list && ( !fired || stack ) ) { |
|
1082 |
if ( firing ) { |
|
1083 |
stack.push( args ); |
|
1084 |
} else { |
|
1085 |
fire( args ); |
|
1086 |
} |
|
1087 |
} |
|
1088 |
return this; |
|
1089 |
}, |
|
1090 |
// Call all the callbacks with the given arguments |
|
1091 |
fire: function() { |
|
1092 |
self.fireWith( this, arguments ); |
|
1093 |
return this; |
|
1094 |
}, |
|
1095 |
// To know if the callbacks have already been called at least once |
|
1096 |
fired: function() { |
|
1097 |
return !!fired; |
|
1098 |
} |
|
1099 |
}; |
|
1100 |
|
|
1101 |
return self; |
|
1102 |
}; |
|
1103 |
jQuery.extend({ |
|
1104 |
|
|
1105 |
Deferred: function( func ) { |
|
1106 |
var tuples = [ |
|
1107 |
// action, add listener, listener list, final state |
|
1108 |
[ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ], |
|
1109 |
[ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ], |
|
1110 |
[ "notify", "progress", jQuery.Callbacks("memory") ] |
|
1111 |
], |
|
1112 |
state = "pending", |
|
1113 |
promise = { |
|
1114 |
state: function() { |
|
1115 |
return state; |
|
1116 |
}, |
|
1117 |
always: function() { |
|
1118 |
deferred.done( arguments ).fail( arguments ); |
|
1119 |
return this; |
|
1120 |
}, |
|
1121 |
then: function( /* fnDone, fnFail, fnProgress */ ) { |
|
1122 |
var fns = arguments; |
|
1123 |
return jQuery.Deferred(function( newDefer ) { |
|
1124 |
jQuery.each( tuples, function( i, tuple ) { |
|
1125 |
var action = tuple[ 0 ], |
|
1126 |
fn = fns[ i ]; |
|
1127 |
// deferred[ done | fail | progress ] for forwarding actions to newDefer |
|
1128 |
deferred[ tuple[1] ]( jQuery.isFunction( fn ) ? |
|
1129 |
function() { |
|
1130 |
var returned = fn.apply( this, arguments ); |
|
1131 |
if ( returned && jQuery.isFunction( returned.promise ) ) { |
|
1132 |
returned.promise() |
|
1133 |
.done( newDefer.resolve ) |
|
1134 |
.fail( newDefer.reject ) |
|
1135 |
.progress( newDefer.notify ); |
|
1136 |
} else { |
|
1137 |
newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] ); |
|
1138 |
} |
|
1139 |
} : |
|
1140 |
newDefer[ action ] |
|
1141 |
); |
|
1142 |
}); |
|
1143 |
fns = null; |
|
1144 |
}).promise(); |
|
1145 |
}, |
|
1146 |
// Get a promise for this deferred |
|
1147 |
// If obj is provided, the promise aspect is added to the object |
|
1148 |
promise: function( obj ) { |
|
1149 |
return obj != null ? jQuery.extend( obj, promise ) : promise; |
|
1150 |
} |
|
1151 |
}, |
|
1152 |
deferred = {}; |
|
1153 |
|
|
1154 |
// Keep pipe for back-compat |
|
1155 |
promise.pipe = promise.then; |
|
1156 |
|
|
1157 |
// Add list-specific methods |
|
1158 |
jQuery.each( tuples, function( i, tuple ) { |
|
1159 |
var list = tuple[ 2 ], |
|
1160 |
stateString = tuple[ 3 ]; |
|
1161 |
|
|
1162 |
// promise[ done | fail | progress ] = list.add |
|
1163 |
promise[ tuple[1] ] = list.add; |
|
1164 |
|
|
1165 |
// Handle state |
|
1166 |
if ( stateString ) { |
|
1167 |
list.add(function() { |
|
1168 |
// state = [ resolved | rejected ] |
|
1169 |
state = stateString; |
|
1170 |
|
|
1171 |
// [ reject_list | resolve_list ].disable; progress_list.lock |
|
1172 |
}, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock ); |
|
1173 |
} |
|
1174 |
|
|
1175 |
// deferred[ resolve | reject | notify ] = list.fire |
|
1176 |
deferred[ tuple[0] ] = list.fire; |
|
1177 |
deferred[ tuple[0] + "With" ] = list.fireWith; |
|
1178 |
}); |
|
1179 |
|
|
1180 |
// Make the deferred a promise |
|
1181 |
promise.promise( deferred ); |
|
1182 |
|
|
1183 |
// Call given func if any |
|
1184 |
if ( func ) { |
|
1185 |
func.call( deferred, deferred ); |
|
1186 |
} |
|
1187 |
|
|
1188 |
// All done! |
|
1189 |
return deferred; |
|
1190 |
}, |
|
1191 |
|
|
1192 |
// Deferred helper |
|
1193 |
when: function( subordinate /* , ..., subordinateN */ ) { |
|
1194 |
var i = 0, |
|
1195 |
resolveValues = core_slice.call( arguments ), |
|
1196 |
length = resolveValues.length, |
|
1197 |
|
|
1198 |
// the count of uncompleted subordinates |
|
1199 |
remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0, |
|
1200 |
|
|
1201 |
// the master Deferred. If resolveValues consist of only a single Deferred, just use that. |
|
1202 |
deferred = remaining === 1 ? subordinate : jQuery.Deferred(), |
|
1203 |
|
|
1204 |
// Update function for both resolve and progress values |
|
1205 |
updateFunc = function( i, contexts, values ) { |
|
1206 |
return function( value ) { |
|
1207 |
contexts[ i ] = this; |
|
1208 |
values[ i ] = arguments.length > 1 ? core_slice.call( arguments ) : value; |
|
1209 |
if( values === progressValues ) { |
|
1210 |
deferred.notifyWith( contexts, values ); |
|
1211 |
} else if ( !( --remaining ) ) { |
|
1212 |
deferred.resolveWith( contexts, values ); |
|
1213 |
} |
|
1214 |
}; |
|
1215 |
}, |
|
1216 |
|
|
1217 |
progressValues, progressContexts, resolveContexts; |
|
1218 |
|
|
1219 |
// add listeners to Deferred subordinates; treat others as resolved |
|
1220 |
if ( length > 1 ) { |
|
1221 |
progressValues = new Array( length ); |
|
1222 |
progressContexts = new Array( length ); |
|
1223 |
resolveContexts = new Array( length ); |
|
1224 |
for ( ; i < length; i++ ) { |
|
1225 |
if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) { |
|
1226 |
resolveValues[ i ].promise() |
|
1227 |
.done( updateFunc( i, resolveContexts, resolveValues ) ) |
|
1228 |
.fail( deferred.reject ) |
|
1229 |
.progress( updateFunc( i, progressContexts, progressValues ) ); |
|
1230 |
} else { |
|
1231 |
--remaining; |
|
1232 |
} |
|
1233 |
} |
|
1234 |
} |
|
1235 |
|
|
1236 |
// if we're not waiting on anything, resolve the master |
|
1237 |
if ( !remaining ) { |
|
1238 |
deferred.resolveWith( resolveContexts, resolveValues ); |
|
1239 |
} |
|
1240 |
|
|
1241 |
return deferred.promise(); |
|
1242 |
} |
|
1243 |
}); |
|
1244 |
jQuery.support = (function() { |
|
1245 |
|
|
1246 |
var support, |
|
1247 |
all, |
|
1248 |
a, |
|
1249 |
select, |
|
1250 |
opt, |
|
1251 |
input, |
|
1252 |
fragment, |
|
1253 |
eventName, |
|
1254 |
i, |
|
1255 |
isSupported, |
|
1256 |
clickFn, |
|
1257 |
div = document.createElement("div"); |
|
1258 |
|
|
1259 |
// Setup |
|
1260 |
div.setAttribute( "className", "t" ); |
|
1261 |
div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>"; |
|
1262 |
|
|
1263 |
// Support tests won't run in some limited or non-browser environments |
|
1264 |
all = div.getElementsByTagName("*"); |
|
1265 |
a = div.getElementsByTagName("a")[ 0 ]; |
|
1266 |
if ( !all || !a || !all.length ) { |
|
1267 |
return {}; |
|
1268 |
} |
|
1269 |
|
|
1270 |
// First batch of tests |
|
1271 |
select = document.createElement("select"); |
|
1272 |
opt = select.appendChild( document.createElement("option") ); |
|
1273 |
input = div.getElementsByTagName("input")[ 0 ]; |
|
1274 |
|
|
1275 |
a.style.cssText = "top:1px;float:left;opacity:.5"; |
|
1276 |
support = { |
|
1277 |
// IE strips leading whitespace when .innerHTML is used |
|
1278 |
leadingWhitespace: ( div.firstChild.nodeType === 3 ), |
|
1279 |
|
|
1280 |
// Make sure that tbody elements aren't automatically inserted |
|
1281 |
// IE will insert them into empty tables |
|
1282 |
tbody: !div.getElementsByTagName("tbody").length, |
|
1283 |
|
|
1284 |
// Make sure that link elements get serialized correctly by innerHTML |
|
1285 |
// This requires a wrapper element in IE |
|
1286 |
htmlSerialize: !!div.getElementsByTagName("link").length, |
|
1287 |
|
|
1288 |
// Get the style information from getAttribute |
|
1289 |
// (IE uses .cssText instead) |
|
1290 |
style: /top/.test( a.getAttribute("style") ), |
|
1291 |
|
|
1292 |
// Make sure that URLs aren't manipulated |
|
1293 |
// (IE normalizes it by default) |
|
1294 |
hrefNormalized: ( a.getAttribute("href") === "/a" ), |
|
1295 |
|
|
1296 |
// Make sure that element opacity exists |
|
1297 |
// (IE uses filter instead) |
|
1298 |
// Use a regex to work around a WebKit issue. See #5145 |
|
1299 |
opacity: /^0.5/.test( a.style.opacity ), |
|
1300 |
|
|
1301 |
// Verify style float existence |
|
1302 |
// (IE uses styleFloat instead of cssFloat) |
|
1303 |
cssFloat: !!a.style.cssFloat, |
|
1304 |
|
|
1305 |
// Make sure that if no value is specified for a checkbox |
|
1306 |
// that it defaults to "on". |
|
1307 |
// (WebKit defaults to "" instead) |
|
1308 |
checkOn: ( input.value === "on" ), |
|
1309 |
|
|
1310 |
// Make sure that a selected-by-default option has a working selected property. |
|
1311 |
// (WebKit defaults to false instead of true, IE too, if it's in an optgroup) |
|
1312 |
optSelected: opt.selected, |
|
1313 |
|
|
1314 |
// Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) |
|
1315 |
getSetAttribute: div.className !== "t", |
|
1316 |
|
|
1317 |
// Tests for enctype support on a form (#6743) |
|
1318 |
enctype: !!document.createElement("form").enctype, |
|
1319 |
|
|
1320 |
// Makes sure cloning an html5 element does not cause problems |
|
1321 |
// Where outerHTML is undefined, this still works |
|
1322 |
html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>", |
|
1323 |
|
|
1324 |
// jQuery.support.boxModel DEPRECATED in 1.8 since we don't support Quirks Mode |
|
1325 |
boxModel: ( document.compatMode === "CSS1Compat" ), |
|
1326 |
|
|
1327 |
// Will be defined later |
|
1328 |
submitBubbles: true, |
|
1329 |
changeBubbles: true, |
|
1330 |
focusinBubbles: false, |
|
1331 |
deleteExpando: true, |
|
1332 |
noCloneEvent: true, |
|
1333 |
inlineBlockNeedsLayout: false, |
|
1334 |
shrinkWrapBlocks: false, |
|
1335 |
reliableMarginRight: true, |
|
1336 |
boxSizingReliable: true, |
|
1337 |
pixelPosition: false |
|
1338 |
}; |
|
1339 |
|
|
1340 |
// Make sure checked status is properly cloned |
|
1341 |
input.checked = true; |
|
1342 |
support.noCloneChecked = input.cloneNode( true ).checked; |
|
1343 |
|
|
1344 |
// Make sure that the options inside disabled selects aren't marked as disabled |
|
1345 |
// (WebKit marks them as disabled) |
|
1346 |
select.disabled = true; |
|
1347 |
support.optDisabled = !opt.disabled; |
|
1348 |
|
|
1349 |
// Test to see if it's possible to delete an expando from an element |
|
1350 |
// Fails in Internet Explorer |
|
1351 |
try { |
|
1352 |
delete div.test; |
|
1353 |
} catch( e ) { |
|
1354 |
support.deleteExpando = false; |
|
1355 |
} |
|
1356 |
|
|
1357 |
if ( !div.addEventListener && div.attachEvent && div.fireEvent ) { |
|
1358 |
div.attachEvent( "onclick", clickFn = function() { |
|
1359 |
// Cloning a node shouldn't copy over any |
|
1360 |
// bound event handlers (IE does this) |
|
1361 |
support.noCloneEvent = false; |
|
1362 |
}); |
|
1363 |
div.cloneNode( true ).fireEvent("onclick"); |
|
1364 |
div.detachEvent( "onclick", clickFn ); |
|
1365 |
} |
|
1366 |
|
|
1367 |
// Check if a radio maintains its value |
|
1368 |
// after being appended to the DOM |
|
1369 |
input = document.createElement("input"); |
|
1370 |
input.value = "t"; |
|
1371 |
input.setAttribute( "type", "radio" ); |
|
1372 |
support.radioValue = input.value === "t"; |
|
1373 |
|
|
1374 |
input.setAttribute( "checked", "checked" ); |
|
1375 |
|
|
1376 |
// #11217 - WebKit loses check when the name is after the checked attribute |
|
1377 |
input.setAttribute( "name", "t" ); |
|
1378 |
|
|
1379 |
div.appendChild( input ); |
|
1380 |
fragment = document.createDocumentFragment(); |
|
1381 |
fragment.appendChild( div.lastChild ); |
|
1382 |
|
|
1383 |
// WebKit doesn't clone checked state correctly in fragments |
|
1384 |
support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; |
|
1385 |
|
|
1386 |
// Check if a disconnected checkbox will retain its checked |
|
1387 |
// value of true after appended to the DOM (IE6/7) |
|
1388 |
support.appendChecked = input.checked; |
|
1389 |
|
|
1390 |
fragment.removeChild( input ); |
|
1391 |
fragment.appendChild( div ); |
|
1392 |
|
|
1393 |
// Technique from Juriy Zaytsev |
|
1394 |
// http://perfectionkills.com/detecting-event-support-without-browser-sniffing/ |
|
1395 |
// We only care about the case where non-standard event systems |
|
1396 |
// are used, namely in IE. Short-circuiting here helps us to |
|
1397 |
// avoid an eval call (in setAttribute) which can cause CSP |
|
1398 |
// to go haywire. See: https://developer.mozilla.org/en/Security/CSP |
|
1399 |
if ( div.attachEvent ) { |
|
1400 |
for ( i in { |
|
1401 |
submit: true, |
|
1402 |
change: true, |
|
1403 |
focusin: true |
|
1404 |
}) { |
|
1405 |
eventName = "on" + i; |
|
1406 |
isSupported = ( eventName in div ); |
|
1407 |
if ( !isSupported ) { |
|
1408 |
div.setAttribute( eventName, "return;" ); |
|
1409 |
isSupported = ( typeof div[ eventName ] === "function" ); |
|
1410 |
} |
|
1411 |
support[ i + "Bubbles" ] = isSupported; |
|
1412 |
} |
|
1413 |
} |
|
1414 |
|
|
1415 |
// Run tests that need a body at doc ready |
|
1416 |
jQuery(function() { |
|
1417 |
var container, div, tds, marginDiv, |
|
1418 |
divReset = "padding:0;margin:0;border:0;display:block;overflow:hidden;", |
|
1419 |
body = document.getElementsByTagName("body")[0]; |
|
1420 |
|
|
1421 |
if ( !body ) { |
|
1422 |
// Return for frameset docs that don't have a body |
|
1423 |
return; |
|
1424 |
} |
|
1425 |
|
|
1426 |
container = document.createElement("div"); |
|
1427 |
container.style.cssText = "visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px"; |
|
1428 |
body.insertBefore( container, body.firstChild ); |
|
1429 |
|
|
1430 |
// Construct the test element |
|
1431 |
div = document.createElement("div"); |
|
1432 |
container.appendChild( div ); |
|
1433 |
|
|
1434 |
// Check if table cells still have offsetWidth/Height when they are set |
|
1435 |
// to display:none and there are still other visible table cells in a |
|
1436 |
// table row; if so, offsetWidth/Height are not reliable for use when |
|
1437 |
// determining if an element has been hidden directly using |
|
1438 |
// display:none (it is still safe to use offsets if a parent element is |
|
1439 |
// hidden; don safety goggles and see bug #4512 for more information). |
|
1440 |
// (only IE 8 fails this test) |
|
1441 |
div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>"; |
|
1442 |
tds = div.getElementsByTagName("td"); |
|
1443 |
tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none"; |
|
1444 |
isSupported = ( tds[ 0 ].offsetHeight === 0 ); |
|
1445 |
|
|
1446 |
tds[ 0 ].style.display = ""; |
|
1447 |
tds[ 1 ].style.display = "none"; |
|
1448 |
|
|
1449 |
// Check if empty table cells still have offsetWidth/Height |
|
1450 |
// (IE <= 8 fail this test) |
|
1451 |
support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 ); |
|
1452 |
|
|
1453 |
// Check box-sizing and margin behavior |
|
1454 |
div.innerHTML = ""; |
|
1455 |
div.style.cssText = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;"; |
|
1456 |
support.boxSizing = ( div.offsetWidth === 4 ); |
|
1457 |
support.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== 1 ); |
|
1458 |
|
|
1459 |
// NOTE: To any future maintainer, we've window.getComputedStyle |
|
1460 |
// because jsdom on node.js will break without it. |
|
1461 |
if ( window.getComputedStyle ) { |
|
1462 |
support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%"; |
|
1463 |
support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px"; |
|
1464 |
|
|
1465 |
// Check if div with explicit width and no margin-right incorrectly |
|
1466 |
// gets computed margin-right based on width of container. For more |
|
1467 |
// info see bug #3333 |
|
1468 |
// Fails in WebKit before Feb 2011 nightlies |
|
1469 |
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right |
|
1470 |
marginDiv = document.createElement("div"); |
|
1471 |
marginDiv.style.cssText = div.style.cssText = divReset; |
|
1472 |
marginDiv.style.marginRight = marginDiv.style.width = "0"; |
|
1473 |
div.style.width = "1px"; |
|
1474 |
div.appendChild( marginDiv ); |
|
1475 |
support.reliableMarginRight = |
|
1476 |
!parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight ); |
|
1477 |
} |
|
1478 |
|
|
1479 |
if ( typeof div.style.zoom !== "undefined" ) { |
|
1480 |
// Check if natively block-level elements act like inline-block |
|
1481 |
// elements when setting their display to 'inline' and giving |
|
1482 |
// them layout |
|
1483 |
// (IE < 8 does this) |
|
1484 |
div.innerHTML = ""; |
|
1485 |
div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1"; |
|
1486 |
support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 ); |
|
1487 |
|
|
1488 |
// Check if elements with layout shrink-wrap their children |
|
1489 |
// (IE 6 does this) |
Také k dispozici: Unified diff
updated jQuery