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