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