1 | (function(){ |
---|
2 | /* |
---|
3 | * jQuery 1.2.2b - New Wave Javascript |
---|
4 | * |
---|
5 | * Copyright (c) 2007 John Resig (jquery.com) |
---|
6 | * Dual licensed under the MIT (MIT-LICENSE.txt) |
---|
7 | * and GPL (GPL-LICENSE.txt) licenses. |
---|
8 | * |
---|
9 | * $Date: 2007-12-18 04:53:09 +0100 (Tue, 18 Dec 2007) $ |
---|
10 | * $Rev: 4217 $ |
---|
11 | */ |
---|
12 | |
---|
13 | // Map over jQuery in case of overwrite |
---|
14 | if ( window.jQuery ) |
---|
15 | var _jQuery = window.jQuery; |
---|
16 | |
---|
17 | var jQuery = window.jQuery = function( selector, context ) { |
---|
18 | // The jQuery object is actually just the init constructor 'enhanced' |
---|
19 | return new jQuery.prototype.init( selector, context ); |
---|
20 | }; |
---|
21 | |
---|
22 | // Map over the $ in case of overwrite |
---|
23 | if ( window.$ ) |
---|
24 | var _$ = window.$; |
---|
25 | |
---|
26 | // Map the jQuery namespace to the '$' one |
---|
27 | window.$ = jQuery; |
---|
28 | |
---|
29 | // A simple way to check for HTML strings or ID strings |
---|
30 | // (both of which we optimize for) |
---|
31 | var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/; |
---|
32 | |
---|
33 | // Is it a simple selector |
---|
34 | var isSimple = /^.[^:#\[\.]*$/; |
---|
35 | |
---|
36 | jQuery.fn = jQuery.prototype = { |
---|
37 | init: function( selector, context ) { |
---|
38 | // Make sure that a selection was provided |
---|
39 | selector = selector || document; |
---|
40 | |
---|
41 | // Handle $(DOMElement) |
---|
42 | if ( selector.nodeType ) { |
---|
43 | this[0] = selector; |
---|
44 | this.length = 1; |
---|
45 | return this; |
---|
46 | |
---|
47 | // Handle HTML strings |
---|
48 | } else if ( typeof selector == "string" ) { |
---|
49 | // Are we dealing with HTML string or an ID? |
---|
50 | var match = quickExpr.exec( selector ); |
---|
51 | |
---|
52 | // Verify a match, and that no context was specified for #id |
---|
53 | if ( match && (match[1] || !context) ) { |
---|
54 | |
---|
55 | // HANDLE: $(html) -> $(array) |
---|
56 | if ( match[1] ) |
---|
57 | selector = jQuery.clean( [ match[1] ], context ); |
---|
58 | |
---|
59 | // HANDLE: $("#id") |
---|
60 | else { |
---|
61 | var elem = document.getElementById( match[3] ); |
---|
62 | |
---|
63 | // Make sure an element was located |
---|
64 | if ( elem ) |
---|
65 | // Handle the case where IE and Opera return items |
---|
66 | // by name instead of ID |
---|
67 | if ( elem.id != match[3] ) |
---|
68 | return jQuery().find( selector ); |
---|
69 | |
---|
70 | // Otherwise, we inject the element directly into the jQuery object |
---|
71 | else { |
---|
72 | this[0] = elem; |
---|
73 | this.length = 1; |
---|
74 | return this; |
---|
75 | } |
---|
76 | |
---|
77 | else |
---|
78 | selector = []; |
---|
79 | } |
---|
80 | |
---|
81 | // HANDLE: $(expr, [context]) |
---|
82 | // (which is just equivalent to: $(content).find(expr) |
---|
83 | } else |
---|
84 | return new jQuery( context ).find( selector ); |
---|
85 | |
---|
86 | // HANDLE: $(function) |
---|
87 | // Shortcut for document ready |
---|
88 | } else if ( jQuery.isFunction( selector ) ) |
---|
89 | return new jQuery( document )[ jQuery.fn.ready ? "ready" : "load" ]( selector ); |
---|
90 | |
---|
91 | return this.setArray( |
---|
92 | // HANDLE: $(array) |
---|
93 | selector.constructor == Array && selector || |
---|
94 | |
---|
95 | // HANDLE: $(arraylike) |
---|
96 | // Watch for when an array-like object, contains DOM nodes, is passed in as the selector |
---|
97 | (selector.jquery || selector.length && selector != window && !selector.nodeType && selector[0] != undefined && selector[0].nodeType) && jQuery.makeArray( selector ) || |
---|
98 | |
---|
99 | // HANDLE: $(*) |
---|
100 | [ selector ] ); |
---|
101 | }, |
---|
102 | |
---|
103 | // The current version of jQuery being used |
---|
104 | jquery: "1.2.2b", |
---|
105 | |
---|
106 | // The number of elements contained in the matched element set |
---|
107 | size: function() { |
---|
108 | return this.length; |
---|
109 | }, |
---|
110 | |
---|
111 | // The number of elements contained in the matched element set |
---|
112 | length: 0, |
---|
113 | |
---|
114 | // Get the Nth element in the matched element set OR |
---|
115 | // Get the whole matched element set as a clean array |
---|
116 | get: function( num ) { |
---|
117 | return num == undefined ? |
---|
118 | |
---|
119 | // Return a 'clean' array |
---|
120 | jQuery.makeArray( this ) : |
---|
121 | |
---|
122 | // Return just the object |
---|
123 | this[ num ]; |
---|
124 | }, |
---|
125 | |
---|
126 | // Take an array of elements and push it onto the stack |
---|
127 | // (returning the new matched element set) |
---|
128 | pushStack: function( elems ) { |
---|
129 | // Build a new jQuery matched element set |
---|
130 | var ret = jQuery( elems ); |
---|
131 | |
---|
132 | // Add the old object onto the stack (as a reference) |
---|
133 | ret.prevObject = this; |
---|
134 | |
---|
135 | // Return the newly-formed element set |
---|
136 | return ret; |
---|
137 | }, |
---|
138 | |
---|
139 | // Force the current matched set of elements to become |
---|
140 | // the specified array of elements (destroying the stack in the process) |
---|
141 | // You should use pushStack() in order to do this, but maintain the stack |
---|
142 | setArray: function( elems ) { |
---|
143 | // Resetting the length to 0, then using the native Array push |
---|
144 | // is a super-fast way to populate an object with array-like properties |
---|
145 | this.length = 0; |
---|
146 | Array.prototype.push.apply( this, elems ); |
---|
147 | |
---|
148 | return this; |
---|
149 | }, |
---|
150 | |
---|
151 | // Execute a callback for every element in the matched set. |
---|
152 | // (You can seed the arguments with an array of args, but this is |
---|
153 | // only used internally.) |
---|
154 | each: function( callback, args ) { |
---|
155 | return jQuery.each( this, callback, args ); |
---|
156 | }, |
---|
157 | |
---|
158 | // Determine the position of an element within |
---|
159 | // the matched set of elements |
---|
160 | index: function( elem ) { |
---|
161 | var ret = -1; |
---|
162 | |
---|
163 | // Locate the position of the desired element |
---|
164 | this.each(function(i){ |
---|
165 | if ( this == elem ) |
---|
166 | ret = i; |
---|
167 | }); |
---|
168 | |
---|
169 | return ret; |
---|
170 | }, |
---|
171 | |
---|
172 | attr: function( name, value, type ) { |
---|
173 | var options = name; |
---|
174 | |
---|
175 | // Look for the case where we're accessing a style value |
---|
176 | if ( name.constructor == String ) |
---|
177 | if ( value == undefined ) |
---|
178 | return this.length && jQuery[ type || "attr" ]( this[0], name ) || undefined; |
---|
179 | |
---|
180 | else { |
---|
181 | options = {}; |
---|
182 | options[ name ] = value; |
---|
183 | } |
---|
184 | |
---|
185 | // Check to see if we're setting style values |
---|
186 | return this.each(function(i){ |
---|
187 | // Set all the styles |
---|
188 | for ( name in options ) |
---|
189 | jQuery.attr( |
---|
190 | type ? |
---|
191 | this.style : |
---|
192 | this, |
---|
193 | name, jQuery.prop( this, options[ name ], type, i, name ) |
---|
194 | ); |
---|
195 | }); |
---|
196 | }, |
---|
197 | |
---|
198 | css: function( key, value ) { |
---|
199 | // ignore negative width and height values |
---|
200 | if ( (key == 'width' || key == 'height') && parseFloat(value) < 0 ) |
---|
201 | value = undefined; |
---|
202 | return this.attr( key, value, "curCSS" ); |
---|
203 | }, |
---|
204 | |
---|
205 | text: function( text ) { |
---|
206 | if ( typeof text != "object" && text != null ) |
---|
207 | return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); |
---|
208 | |
---|
209 | var ret = ""; |
---|
210 | |
---|
211 | jQuery.each( text || this, function(){ |
---|
212 | jQuery.each( this.childNodes, function(){ |
---|
213 | if ( this.nodeType != 8 ) |
---|
214 | ret += this.nodeType != 1 ? |
---|
215 | this.nodeValue : |
---|
216 | jQuery.fn.text( [ this ] ); |
---|
217 | }); |
---|
218 | }); |
---|
219 | |
---|
220 | return ret; |
---|
221 | }, |
---|
222 | |
---|
223 | wrapAll: function( html ) { |
---|
224 | if ( this[0] ) |
---|
225 | // The elements to wrap the target around |
---|
226 | jQuery( html, this[0].ownerDocument ) |
---|
227 | .clone() |
---|
228 | .insertBefore( this[0] ) |
---|
229 | .map(function(){ |
---|
230 | var elem = this; |
---|
231 | |
---|
232 | while ( elem.firstChild ) |
---|
233 | elem = elem.firstChild; |
---|
234 | |
---|
235 | return elem; |
---|
236 | }) |
---|
237 | .append(this); |
---|
238 | |
---|
239 | return this; |
---|
240 | }, |
---|
241 | |
---|
242 | wrapInner: function( html ) { |
---|
243 | return this.each(function(){ |
---|
244 | jQuery( this ).contents().wrapAll( html ); |
---|
245 | }); |
---|
246 | }, |
---|
247 | |
---|
248 | wrap: function( html ) { |
---|
249 | return this.each(function(){ |
---|
250 | jQuery( this ).wrapAll( html ); |
---|
251 | }); |
---|
252 | }, |
---|
253 | |
---|
254 | append: function() { |
---|
255 | return this.domManip(arguments, true, false, function(elem){ |
---|
256 | if (this.nodeType == 1) |
---|
257 | this.appendChild( elem ); |
---|
258 | }); |
---|
259 | }, |
---|
260 | |
---|
261 | prepend: function() { |
---|
262 | return this.domManip(arguments, true, true, function(elem){ |
---|
263 | if (this.nodeType == 1) |
---|
264 | this.insertBefore( elem, this.firstChild ); |
---|
265 | }); |
---|
266 | }, |
---|
267 | |
---|
268 | before: function() { |
---|
269 | return this.domManip(arguments, false, false, function(elem){ |
---|
270 | this.parentNode.insertBefore( elem, this ); |
---|
271 | }); |
---|
272 | }, |
---|
273 | |
---|
274 | after: function() { |
---|
275 | return this.domManip(arguments, false, true, function(elem){ |
---|
276 | this.parentNode.insertBefore( elem, this.nextSibling ); |
---|
277 | }); |
---|
278 | }, |
---|
279 | |
---|
280 | end: function() { |
---|
281 | return this.prevObject || jQuery( [] ); |
---|
282 | }, |
---|
283 | |
---|
284 | find: function( selector ) { |
---|
285 | var elems = jQuery.map(this, function(elem){ |
---|
286 | return jQuery.find( selector, elem ); |
---|
287 | }); |
---|
288 | |
---|
289 | return this.pushStack( /[^+>] [^+>]/.test( selector ) || selector.indexOf("..") > -1 ? |
---|
290 | jQuery.unique( elems ) : |
---|
291 | elems ); |
---|
292 | }, |
---|
293 | |
---|
294 | clone: function( events ) { |
---|
295 | // Do the clone |
---|
296 | var ret = this.map(function(){ |
---|
297 | if ( jQuery.browser.msie && !jQuery.isXMLDoc(this) ) { |
---|
298 | // IE copies events bound via attachEvent when |
---|
299 | // using cloneNode. Calling detachEvent on the |
---|
300 | // clone will also remove the events from the orignal |
---|
301 | // In order to get around this, we use innerHTML. |
---|
302 | // Unfortunately, this means some modifications to |
---|
303 | // attributes in IE that are actually only stored |
---|
304 | // as properties will not be copied (such as the |
---|
305 | // the name attribute on an input). |
---|
306 | var clone = this.cloneNode(true), |
---|
307 | container = document.createElement("div"), |
---|
308 | container2 = document.createElement("div"); |
---|
309 | container.appendChild(clone); |
---|
310 | container2.innerHTML = container.innerHTML; |
---|
311 | return container2.firstChild; |
---|
312 | } else |
---|
313 | return this.cloneNode(true); |
---|
314 | }); |
---|
315 | |
---|
316 | // Need to set the expando to null on the cloned set if it exists |
---|
317 | // removeData doesn't work here, IE removes it from the original as well |
---|
318 | // this is primarily for IE but the data expando shouldn't be copied over in any browser |
---|
319 | var clone = ret.find("*").andSelf().each(function(){ |
---|
320 | if ( this[ expando ] != undefined ) |
---|
321 | this[ expando ] = null; |
---|
322 | }); |
---|
323 | |
---|
324 | // Copy the events from the original to the clone |
---|
325 | if ( events === true ) |
---|
326 | this.find("*").andSelf().each(function(i){ |
---|
327 | var events = jQuery.data( this, "events" ); |
---|
328 | |
---|
329 | for ( var type in events ) |
---|
330 | for ( var handler in events[ type ] ) |
---|
331 | jQuery.event.add( clone[ i ], type, events[ type ][ handler ], events[ type ][ handler ].data ); |
---|
332 | }); |
---|
333 | |
---|
334 | // Return the cloned set |
---|
335 | return ret; |
---|
336 | }, |
---|
337 | |
---|
338 | filter: function( selector ) { |
---|
339 | return this.pushStack( |
---|
340 | jQuery.isFunction( selector ) && |
---|
341 | jQuery.grep(this, function(elem, i){ |
---|
342 | return selector.call( elem, i ); |
---|
343 | }) || |
---|
344 | |
---|
345 | jQuery.multiFilter( selector, this ) ); |
---|
346 | }, |
---|
347 | |
---|
348 | not: function( selector ) { |
---|
349 | if ( selector.constructor == String ) |
---|
350 | // test special case where just one selector is passed in |
---|
351 | if ( isSimple.test( selector ) ) |
---|
352 | return this.pushStack( jQuery.multiFilter( selector, this, true ) ); |
---|
353 | else |
---|
354 | selector = jQuery.multiFilter( selector, this ); |
---|
355 | |
---|
356 | var isArrayLike = selector.length && selector[selector.length - 1] !== undefined && !selector.nodeType; |
---|
357 | return this.filter(function() { |
---|
358 | return isArrayLike ? jQuery.inArray( this, selector ) < 0 : this != selector; |
---|
359 | }); |
---|
360 | }, |
---|
361 | |
---|
362 | add: function( selector ) { |
---|
363 | return !selector ? this : this.pushStack( jQuery.merge( |
---|
364 | this.get(), |
---|
365 | selector.constructor == String ? |
---|
366 | jQuery( selector ).get() : |
---|
367 | selector.length != undefined && (!selector.nodeName || jQuery.nodeName(selector, "form")) ? |
---|
368 | selector : [selector] ) ); |
---|
369 | }, |
---|
370 | |
---|
371 | is: function( selector ) { |
---|
372 | return selector ? |
---|
373 | jQuery.multiFilter( selector, this ).length > 0 : |
---|
374 | false; |
---|
375 | }, |
---|
376 | |
---|
377 | hasClass: function( selector ) { |
---|
378 | return this.is( "." + selector ); |
---|
379 | }, |
---|
380 | |
---|
381 | val: function( value ) { |
---|
382 | if ( value == undefined ) { |
---|
383 | |
---|
384 | if ( this.length ) { |
---|
385 | var elem = this[0]; |
---|
386 | |
---|
387 | // We need to handle select boxes special |
---|
388 | if ( jQuery.nodeName( elem, "select" ) ) { |
---|
389 | var index = elem.selectedIndex, |
---|
390 | values = [], |
---|
391 | options = elem.options, |
---|
392 | one = elem.type == "select-one"; |
---|
393 | |
---|
394 | // Nothing was selected |
---|
395 | if ( index < 0 ) |
---|
396 | return null; |
---|
397 | |
---|
398 | // Loop through all the selected options |
---|
399 | for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { |
---|
400 | var option = options[ i ]; |
---|
401 | |
---|
402 | if ( option.selected ) { |
---|
403 | // Get the specifc value for the option |
---|
404 | value = jQuery.browser.msie && !option.attributes.value.specified ? option.text : option.value; |
---|
405 | |
---|
406 | // We don't need an array for one selects |
---|
407 | if ( one ) |
---|
408 | return value; |
---|
409 | |
---|
410 | // Multi-Selects return an array |
---|
411 | values.push( value ); |
---|
412 | } |
---|
413 | } |
---|
414 | |
---|
415 | return values; |
---|
416 | |
---|
417 | // Everything else, we just grab the value |
---|
418 | } else |
---|
419 | return (this[0].value || "").replace(/\r/g, ""); |
---|
420 | |
---|
421 | } |
---|
422 | |
---|
423 | } |
---|
424 | |
---|
425 | return this.each(function(){ |
---|
426 | if ( this.nodeType != 1 ) |
---|
427 | return; |
---|
428 | |
---|
429 | if ( value.constructor == Array && /radio|checkbox/.test( this.type ) ) |
---|
430 | this.checked = (jQuery.inArray(this.value, value) >= 0 || |
---|
431 | jQuery.inArray(this.name, value) >= 0); |
---|
432 | |
---|
433 | else if ( jQuery.nodeName( this, "select" ) ) { |
---|
434 | var values = value.constructor == Array ? |
---|
435 | value : |
---|
436 | [ value ]; |
---|
437 | |
---|
438 | jQuery( "option", this ).each(function(){ |
---|
439 | this.selected = (jQuery.inArray( this.value, values ) >= 0 || |
---|
440 | jQuery.inArray( this.text, values ) >= 0); |
---|
441 | }); |
---|
442 | |
---|
443 | if ( !values.length ) |
---|
444 | this.selectedIndex = -1; |
---|
445 | |
---|
446 | } else |
---|
447 | this.value = value; |
---|
448 | }); |
---|
449 | }, |
---|
450 | |
---|
451 | html: function( value ) { |
---|
452 | return value == undefined ? |
---|
453 | (this.length ? |
---|
454 | this[0].innerHTML : |
---|
455 | null) : |
---|
456 | this.empty().append( value ); |
---|
457 | }, |
---|
458 | |
---|
459 | replaceWith: function( value ) { |
---|
460 | return this.after( value ).remove(); |
---|
461 | }, |
---|
462 | |
---|
463 | eq: function( i ) { |
---|
464 | return this.slice( i, i + 1 ); |
---|
465 | }, |
---|
466 | |
---|
467 | slice: function() { |
---|
468 | return this.pushStack( Array.prototype.slice.apply( this, arguments ) ); |
---|
469 | }, |
---|
470 | |
---|
471 | map: function( callback ) { |
---|
472 | return this.pushStack( jQuery.map(this, function(elem, i){ |
---|
473 | return callback.call( elem, i, elem ); |
---|
474 | })); |
---|
475 | }, |
---|
476 | |
---|
477 | andSelf: function() { |
---|
478 | return this.add( this.prevObject ); |
---|
479 | }, |
---|
480 | |
---|
481 | domManip: function( args, table, reverse, callback ) { |
---|
482 | var clone = this.length > 1, elems; |
---|
483 | |
---|
484 | return this.each(function(){ |
---|
485 | if ( !elems ) { |
---|
486 | elems = jQuery.clean( args, this.ownerDocument ); |
---|
487 | |
---|
488 | if ( reverse ) |
---|
489 | elems.reverse(); |
---|
490 | } |
---|
491 | |
---|
492 | var obj = this; |
---|
493 | |
---|
494 | if ( table && jQuery.nodeName( this, "table" ) && jQuery.nodeName( elems[0], "tr" ) ) |
---|
495 | obj = this.getElementsByTagName("tbody")[0] || this.appendChild( this.ownerDocument.createElement("tbody") ); |
---|
496 | |
---|
497 | var scripts = jQuery( [] ); |
---|
498 | |
---|
499 | jQuery.each(elems, function(){ |
---|
500 | var elem = clone ? |
---|
501 | this.cloneNode( true ) : |
---|
502 | this; |
---|
503 | |
---|
504 | // execute all scripts after the elements have been injected |
---|
505 | if ( jQuery.nodeName( elem, "script" ) ) { |
---|
506 | scripts = scripts.add( elem ); |
---|
507 | } else { |
---|
508 | // Remove any inner scripts for later evaluation |
---|
509 | if ( elem.nodeType == 1 ) |
---|
510 | scripts = scripts.add( jQuery( "script", elem ).remove() ); |
---|
511 | |
---|
512 | // Inject the elements into the document |
---|
513 | callback.call( obj, elem ); |
---|
514 | } |
---|
515 | }); |
---|
516 | |
---|
517 | scripts.each( evalScript ); |
---|
518 | }); |
---|
519 | } |
---|
520 | }; |
---|
521 | |
---|
522 | // Give the init function the jQuery prototype for later instantiation |
---|
523 | jQuery.prototype.init.prototype = jQuery.prototype; |
---|
524 | |
---|
525 | function evalScript( i, elem ) { |
---|
526 | if ( elem.src ) |
---|
527 | jQuery.ajax({ |
---|
528 | url: elem.src, |
---|
529 | async: false, |
---|
530 | dataType: "script" |
---|
531 | }); |
---|
532 | |
---|
533 | else |
---|
534 | jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" ); |
---|
535 | |
---|
536 | if ( elem.parentNode ) |
---|
537 | elem.parentNode.removeChild( elem ); |
---|
538 | } |
---|
539 | |
---|
540 | jQuery.extend = jQuery.fn.extend = function() { |
---|
541 | // copy reference to target object |
---|
542 | var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options; |
---|
543 | |
---|
544 | // Handle a deep copy situation |
---|
545 | if ( target.constructor == Boolean ) { |
---|
546 | deep = target; |
---|
547 | target = arguments[1] || {}; |
---|
548 | // skip the boolean and the target |
---|
549 | i = 2; |
---|
550 | } |
---|
551 | |
---|
552 | // Handle case when target is a string or something (possible in deep copy) |
---|
553 | if ( typeof target != "object" && typeof target != "function" ) |
---|
554 | target = {}; |
---|
555 | |
---|
556 | // extend jQuery itself if only one argument is passed |
---|
557 | if ( length == 1 ) { |
---|
558 | target = this; |
---|
559 | i = 0; |
---|
560 | } |
---|
561 | |
---|
562 | for ( ; i < length; i++ ) |
---|
563 | // Only deal with non-null/undefined values |
---|
564 | if ( (options = arguments[ i ]) != null ) |
---|
565 | // Extend the base object |
---|
566 | for ( var name in options ) { |
---|
567 | // Prevent never-ending loop |
---|
568 | if ( target === options[ name ] ) |
---|
569 | continue; |
---|
570 | |
---|
571 | // Recurse if we're merging object values |
---|
572 | if ( deep && options[ name ] && typeof options[ name ] == "object" && target[ name ] && !options[ name ].nodeType ) |
---|
573 | target[ name ] = jQuery.extend( target[ name ], options[ name ] ); |
---|
574 | |
---|
575 | // Don't bring in undefined values |
---|
576 | else if ( options[ name ] != undefined ) |
---|
577 | target[ name ] = options[ name ]; |
---|
578 | |
---|
579 | } |
---|
580 | |
---|
581 | // Return the modified object |
---|
582 | return target; |
---|
583 | }; |
---|
584 | |
---|
585 | var expando = "jQuery" + (new Date()).getTime(), uuid = 0, windowData = {}; |
---|
586 | |
---|
587 | // exclude the following css properties to add px |
---|
588 | var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i; |
---|
589 | |
---|
590 | jQuery.extend({ |
---|
591 | noConflict: function( deep ) { |
---|
592 | window.$ = _$; |
---|
593 | |
---|
594 | if ( deep ) |
---|
595 | window.jQuery = _jQuery; |
---|
596 | |
---|
597 | return jQuery; |
---|
598 | }, |
---|
599 | |
---|
600 | // This may seem like some crazy code, but trust me when I say that this |
---|
601 | // is the only cross-browser way to do this. --John |
---|
602 | isFunction: function( fn ) { |
---|
603 | return !!fn && typeof fn != "string" && !fn.nodeName && |
---|
604 | fn.constructor != Array && /function/i.test( fn + "" ); |
---|
605 | }, |
---|
606 | |
---|
607 | // check if an element is in a (or is an) XML document |
---|
608 | isXMLDoc: function( elem ) { |
---|
609 | return elem.documentElement && !elem.body || |
---|
610 | elem.tagName && elem.ownerDocument && !elem.ownerDocument.body; |
---|
611 | }, |
---|
612 | |
---|
613 | // Evalulates a script in a global context |
---|
614 | globalEval: function( data ) { |
---|
615 | data = jQuery.trim( data ); |
---|
616 | |
---|
617 | if ( data ) { |
---|
618 | // Inspired by code by Andrea Giammarchi |
---|
619 | // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html |
---|
620 | var head = document.getElementsByTagName("head")[0] || document.documentElement, |
---|
621 | script = document.createElement("script"); |
---|
622 | |
---|
623 | script.type = "text/javascript"; |
---|
624 | if ( jQuery.browser.msie ) |
---|
625 | script.text = data; |
---|
626 | else |
---|
627 | script.appendChild( document.createTextNode( data ) ); |
---|
628 | |
---|
629 | head.appendChild( script ); |
---|
630 | head.removeChild( script ); |
---|
631 | } |
---|
632 | }, |
---|
633 | |
---|
634 | nodeName: function( elem, name ) { |
---|
635 | return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase(); |
---|
636 | }, |
---|
637 | |
---|
638 | cache: {}, |
---|
639 | |
---|
640 | data: function( elem, name, data ) { |
---|
641 | elem = elem == window ? |
---|
642 | windowData : |
---|
643 | elem; |
---|
644 | |
---|
645 | var id = elem[ expando ]; |
---|
646 | |
---|
647 | // Compute a unique ID for the element |
---|
648 | if ( !id ) |
---|
649 | id = elem[ expando ] = ++uuid; |
---|
650 | |
---|
651 | // Only generate the data cache if we're |
---|
652 | // trying to access or manipulate it |
---|
653 | if ( name && !jQuery.cache[ id ] ) |
---|
654 | jQuery.cache[ id ] = {}; |
---|
655 | |
---|
656 | // Prevent overriding the named cache with undefined values |
---|
657 | if ( data != undefined ) |
---|
658 | jQuery.cache[ id ][ name ] = data; |
---|
659 | |
---|
660 | // Return the named cache data, or the ID for the element |
---|
661 | return name ? |
---|
662 | jQuery.cache[ id ][ name ] : |
---|
663 | id; |
---|
664 | }, |
---|
665 | |
---|
666 | removeData: function( elem, name ) { |
---|
667 | elem = elem == window ? |
---|
668 | windowData : |
---|
669 | elem; |
---|
670 | |
---|
671 | var id = elem[ expando ]; |
---|
672 | |
---|
673 | // If we want to remove a specific section of the element's data |
---|
674 | if ( name ) { |
---|
675 | if ( jQuery.cache[ id ] ) { |
---|
676 | // Remove the section of cache data |
---|
677 | delete jQuery.cache[ id ][ name ]; |
---|
678 | |
---|
679 | // If we've removed all the data, remove the element's cache |
---|
680 | name = ""; |
---|
681 | |
---|
682 | for ( name in jQuery.cache[ id ] ) |
---|
683 | break; |
---|
684 | |
---|
685 | if ( !name ) |
---|
686 | jQuery.removeData( elem ); |
---|
687 | } |
---|
688 | |
---|
689 | // Otherwise, we want to remove all of the element's data |
---|
690 | } else { |
---|
691 | // Clean up the element expando |
---|
692 | try { |
---|
693 | delete elem[ expando ]; |
---|
694 | } catch(e){ |
---|
695 | // IE has trouble directly removing the expando |
---|
696 | // but it's ok with using removeAttribute |
---|
697 | if ( elem.removeAttribute ) |
---|
698 | elem.removeAttribute( expando ); |
---|
699 | } |
---|
700 | |
---|
701 | // Completely remove the data cache |
---|
702 | delete jQuery.cache[ id ]; |
---|
703 | } |
---|
704 | }, |
---|
705 | |
---|
706 | // args is for internal usage only |
---|
707 | each: function( object, callback, args ) { |
---|
708 | if ( args ) { |
---|
709 | if ( object.length == undefined ) |
---|
710 | for ( var name in object ) |
---|
711 | callback.apply( object[ name ], args ); |
---|
712 | else |
---|
713 | for ( var i = 0, length = object.length; i < length; i++ ) |
---|
714 | if ( callback.apply( object[ i ], args ) === false ) |
---|
715 | break; |
---|
716 | |
---|
717 | // A special, fast, case for the most common use of each |
---|
718 | } else { |
---|
719 | if ( object.length == undefined ) |
---|
720 | for ( var name in object ) |
---|
721 | callback.call( object[ name ], name, object[ name ] ); |
---|
722 | else |
---|
723 | for ( var i = 0, length = object.length, value = object[0]; |
---|
724 | i < length && callback.call( value, i, value ) !== false; value = object[++i] ){} |
---|
725 | } |
---|
726 | |
---|
727 | return object; |
---|
728 | }, |
---|
729 | |
---|
730 | prop: function( elem, value, type, i, name ) { |
---|
731 | // Handle executable functions |
---|
732 | if ( jQuery.isFunction( value ) ) |
---|
733 | value = value.call( elem, i ); |
---|
734 | |
---|
735 | // Handle passing in a number to a CSS property |
---|
736 | return value && value.constructor == Number && type == "curCSS" && !exclude.test( name ) ? |
---|
737 | value + "px" : |
---|
738 | value; |
---|
739 | }, |
---|
740 | |
---|
741 | className: { |
---|
742 | // internal only, use addClass("class") |
---|
743 | add: function( elem, classNames ) { |
---|
744 | jQuery.each((classNames || "").split(/\s+/), function(i, className){ |
---|
745 | if ( elem.nodeType == 1 && !jQuery.className.has( elem.className, className ) ) |
---|
746 | elem.className += (elem.className ? " " : "") + className; |
---|
747 | }); |
---|
748 | }, |
---|
749 | |
---|
750 | // internal only, use removeClass("class") |
---|
751 | remove: function( elem, classNames ) { |
---|
752 | if (elem.nodeType == 1) |
---|
753 | elem.className = classNames != undefined ? |
---|
754 | jQuery.grep(elem.className.split(/\s+/), function(className){ |
---|
755 | return !jQuery.className.has( classNames, className ); |
---|
756 | }).join(" ") : |
---|
757 | ""; |
---|
758 | }, |
---|
759 | |
---|
760 | // internal only, use is(".class") |
---|
761 | has: function( elem, className ) { |
---|
762 | return jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1; |
---|
763 | } |
---|
764 | }, |
---|
765 | |
---|
766 | // A method for quickly swapping in/out CSS properties to get correct calculations |
---|
767 | swap: function( elem, options, callback ) { |
---|
768 | var old = {}; |
---|
769 | // Remember the old values, and insert the new ones |
---|
770 | for ( var name in options ) { |
---|
771 | old[ name ] = elem.style[ name ]; |
---|
772 | elem.style[ name ] = options[ name ]; |
---|
773 | } |
---|
774 | |
---|
775 | callback.call( elem ); |
---|
776 | |
---|
777 | // Revert the old values |
---|
778 | for ( var name in options ) |
---|
779 | elem.style[ name ] = old[ name ]; |
---|
780 | }, |
---|
781 | |
---|
782 | css: function( elem, name, force ) { |
---|
783 | if ( name == "width" || name == "height" ) { |
---|
784 | var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ]; |
---|
785 | |
---|
786 | function getWH() { |
---|
787 | val = name == "width" ? elem.offsetWidth : elem.offsetHeight; |
---|
788 | var padding = 0, border = 0; |
---|
789 | jQuery.each( which, function() { |
---|
790 | padding += parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0; |
---|
791 | border += parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0; |
---|
792 | }); |
---|
793 | val -= Math.round(padding + border); |
---|
794 | } |
---|
795 | |
---|
796 | if ( jQuery(elem).is(":visible") ) |
---|
797 | getWH(); |
---|
798 | else |
---|
799 | jQuery.swap( elem, props, getWH ); |
---|
800 | |
---|
801 | return val; |
---|
802 | } |
---|
803 | |
---|
804 | return jQuery.curCSS( elem, name, force ); |
---|
805 | }, |
---|
806 | |
---|
807 | curCSS: function( elem, name, force ) { |
---|
808 | var ret; |
---|
809 | |
---|
810 | // A helper method for determining if an element's values are broken |
---|
811 | function color( elem ) { |
---|
812 | if ( !jQuery.browser.safari ) |
---|
813 | return false; |
---|
814 | |
---|
815 | var ret = document.defaultView.getComputedStyle( elem, null ); |
---|
816 | return !ret || ret.getPropertyValue("color") == ""; |
---|
817 | } |
---|
818 | |
---|
819 | // We need to handle opacity special in IE |
---|
820 | if ( name == "opacity" && jQuery.browser.msie ) { |
---|
821 | ret = jQuery.attr( elem.style, "opacity" ); |
---|
822 | |
---|
823 | return ret == "" ? |
---|
824 | "1" : |
---|
825 | ret; |
---|
826 | } |
---|
827 | // Opera sometimes will give the wrong display answer, this fixes it, see #2037 |
---|
828 | if ( jQuery.browser.opera && name == "display" ) { |
---|
829 | var save = elem.style.display; |
---|
830 | elem.style.display = "block"; |
---|
831 | elem.style.display = save; |
---|
832 | } |
---|
833 | |
---|
834 | // Make sure we're using the right name for getting the float value |
---|
835 | if ( name.match( /float/i ) ) |
---|
836 | name = styleFloat; |
---|
837 | |
---|
838 | if ( !force && elem.style[ name ] ) |
---|
839 | ret = elem.style[ name ]; |
---|
840 | |
---|
841 | else if ( document.defaultView && document.defaultView.getComputedStyle ) { |
---|
842 | |
---|
843 | // Only "float" is needed here |
---|
844 | if ( name.match( /float/i ) ) |
---|
845 | name = "float"; |
---|
846 | |
---|
847 | name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase(); |
---|
848 | |
---|
849 | var getComputedStyle = document.defaultView.getComputedStyle( elem, null ); |
---|
850 | |
---|
851 | if ( getComputedStyle && !color( elem ) ) |
---|
852 | ret = getComputedStyle.getPropertyValue( name ); |
---|
853 | |
---|
854 | // If the element isn't reporting its values properly in Safari |
---|
855 | // then some display: none elements are involved |
---|
856 | else { |
---|
857 | var swap = [], stack = []; |
---|
858 | |
---|
859 | // Locate all of the parent display: none elements |
---|
860 | for ( var a = elem; a && color(a); a = a.parentNode ) |
---|
861 | stack.unshift(a); |
---|
862 | |
---|
863 | // Go through and make them visible, but in reverse |
---|
864 | // (It would be better if we knew the exact display type that they had) |
---|
865 | for ( var i = 0; i < stack.length; i++ ) |
---|
866 | if ( color( stack[ i ] ) ) { |
---|
867 | swap[ i ] = stack[ i ].style.display; |
---|
868 | stack[ i ].style.display = "block"; |
---|
869 | } |
---|
870 | |
---|
871 | // Since we flip the display style, we have to handle that |
---|
872 | // one special, otherwise get the value |
---|
873 | ret = name == "display" && swap[ stack.length - 1 ] != null ? |
---|
874 | "none" : |
---|
875 | ( getComputedStyle && getComputedStyle.getPropertyValue( name ) ) || ""; |
---|
876 | |
---|
877 | // Finally, revert the display styles back |
---|
878 | for ( var i = 0; i < swap.length; i++ ) |
---|
879 | if ( swap[ i ] != null ) |
---|
880 | stack[ i ].style.display = swap[ i ]; |
---|
881 | } |
---|
882 | |
---|
883 | // We should always get a number back from opacity |
---|
884 | if ( name == "opacity" && ret == "" ) |
---|
885 | ret = "1"; |
---|
886 | |
---|
887 | } else if ( elem.currentStyle ) { |
---|
888 | var camelCase = name.replace(/\-(\w)/g, function(all, letter){ |
---|
889 | return letter.toUpperCase(); |
---|
890 | }); |
---|
891 | |
---|
892 | ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ]; |
---|
893 | |
---|
894 | // From the awesome hack by Dean Edwards |
---|
895 | // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 |
---|
896 | |
---|
897 | // If we're not dealing with a regular pixel number |
---|
898 | // but a number that has a weird ending, we need to convert it to pixels |
---|
899 | if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) { |
---|
900 | // Remember the original values |
---|
901 | var style = elem.style.left, runtimeStyle = elem.runtimeStyle.left; |
---|
902 | |
---|
903 | // Put in the new values to get a computed value out |
---|
904 | elem.runtimeStyle.left = elem.currentStyle.left; |
---|
905 | elem.style.left = ret || 0; |
---|
906 | ret = elem.style.pixelLeft + "px"; |
---|
907 | |
---|
908 | // Revert the changed values |
---|
909 | elem.style.left = style; |
---|
910 | elem.runtimeStyle.left = runtimeStyle; |
---|
911 | } |
---|
912 | } |
---|
913 | |
---|
914 | return ret; |
---|
915 | }, |
---|
916 | |
---|
917 | clean: function( elems, context ) { |
---|
918 | var ret = []; |
---|
919 | context = context || document; |
---|
920 | // !context.createElement fails in IE with an error but returns typeof 'object' |
---|
921 | if (typeof context.createElement == 'undefined') |
---|
922 | context = context.ownerDocument || context[0] && context[0].ownerDocument || document; |
---|
923 | |
---|
924 | jQuery.each(elems, function(i, elem){ |
---|
925 | if ( !elem ) |
---|
926 | return; |
---|
927 | |
---|
928 | if ( elem.constructor == Number ) |
---|
929 | elem = elem.toString(); |
---|
930 | |
---|
931 | // Convert html string into DOM nodes |
---|
932 | if ( typeof elem == "string" ) { |
---|
933 | // Fix "XHTML"-style tags in all browsers |
---|
934 | elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){ |
---|
935 | return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area)$/i) ? |
---|
936 | all : |
---|
937 | front + "></" + tag + ">"; |
---|
938 | }); |
---|
939 | |
---|
940 | // Trim whitespace, otherwise indexOf won't work as expected |
---|
941 | var tags = jQuery.trim( elem ).toLowerCase(), div = context.createElement("div"); |
---|
942 | |
---|
943 | var wrap = |
---|
944 | // option or optgroup |
---|
945 | !tags.indexOf("<opt") && |
---|
946 | [ 1, "<select multiple='multiple'>", "</select>" ] || |
---|
947 | |
---|
948 | !tags.indexOf("<leg") && |
---|
949 | [ 1, "<fieldset>", "</fieldset>" ] || |
---|
950 | |
---|
951 | tags.match(/^<(thead|tbody|tfoot|colg|cap)/) && |
---|
952 | [ 1, "<table>", "</table>" ] || |
---|
953 | |
---|
954 | !tags.indexOf("<tr") && |
---|
955 | [ 2, "<table><tbody>", "</tbody></table>" ] || |
---|
956 | |
---|
957 | // <thead> matched above |
---|
958 | (!tags.indexOf("<td") || !tags.indexOf("<th")) && |
---|
959 | [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ] || |
---|
960 | |
---|
961 | !tags.indexOf("<col") && |
---|
962 | [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ] || |
---|
963 | |
---|
964 | // IE can't serialize <link> and <script> tags normally |
---|
965 | jQuery.browser.msie && |
---|
966 | [ 1, "div<div>", "</div>" ] || |
---|
967 | |
---|
968 | [ 0, "", "" ]; |
---|
969 | |
---|
970 | // Go to html and back, then peel off extra wrappers |
---|
971 | div.innerHTML = wrap[1] + elem + wrap[2]; |
---|
972 | |
---|
973 | // Move to the right depth |
---|
974 | while ( wrap[0]-- ) |
---|
975 | div = div.lastChild; |
---|
976 | |
---|
977 | // Remove IE's autoinserted <tbody> from table fragments |
---|
978 | if ( jQuery.browser.msie ) { |
---|
979 | |
---|
980 | // String was a <table>, *may* have spurious <tbody> |
---|
981 | var tbody = !tags.indexOf("<table") && tags.indexOf("<tbody") < 0 ? |
---|
982 | div.firstChild && div.firstChild.childNodes : |
---|
983 | |
---|
984 | // String was a bare <thead> or <tfoot> |
---|
985 | wrap[1] == "<table>" && tags.indexOf("<tbody") < 0 ? |
---|
986 | div.childNodes : |
---|
987 | []; |
---|
988 | |
---|
989 | for ( var j = tbody.length - 1; j >= 0 ; --j ) |
---|
990 | if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) |
---|
991 | tbody[ j ].parentNode.removeChild( tbody[ j ] ); |
---|
992 | |
---|
993 | // IE completely kills leading whitespace when innerHTML is used |
---|
994 | if ( /^\s/.test( elem ) ) |
---|
995 | div.insertBefore( context.createTextNode( elem.match(/^\s*/)[0] ), div.firstChild ); |
---|
996 | |
---|
997 | } |
---|
998 | |
---|
999 | elem = jQuery.makeArray( div.childNodes ); |
---|
1000 | } |
---|
1001 | |
---|
1002 | if ( elem.length === 0 && (!jQuery.nodeName( elem, "form" ) && !jQuery.nodeName( elem, "select" )) ) |
---|
1003 | return; |
---|
1004 | |
---|
1005 | if ( elem[0] == undefined || jQuery.nodeName( elem, "form" ) || elem.options ) |
---|
1006 | ret.push( elem ); |
---|
1007 | |
---|
1008 | else |
---|
1009 | ret = jQuery.merge( ret, elem ); |
---|
1010 | |
---|
1011 | }); |
---|
1012 | |
---|
1013 | return ret; |
---|
1014 | }, |
---|
1015 | |
---|
1016 | attr: function( elem, name, value ) { |
---|
1017 | // don't set attributes on text and comment nodes |
---|
1018 | if (!elem || elem.nodeType == 3 || elem.nodeType == 8) |
---|
1019 | return undefined; |
---|
1020 | |
---|
1021 | var fix = jQuery.isXMLDoc( elem ) ? |
---|
1022 | {} : |
---|
1023 | jQuery.props; |
---|
1024 | |
---|
1025 | // Safari mis-reports the default selected property of a hidden option |
---|
1026 | // Accessing the parent's selectedIndex property fixes it |
---|
1027 | if ( name == "selected" && jQuery.browser.safari ) |
---|
1028 | elem.parentNode.selectedIndex; |
---|
1029 | |
---|
1030 | // Certain attributes only work when accessed via the old DOM 0 way |
---|
1031 | if ( fix[ name ] ) { |
---|
1032 | if ( value != undefined ) |
---|
1033 | elem[ fix[ name ] ] = value; |
---|
1034 | |
---|
1035 | return elem[ fix[ name ] ]; |
---|
1036 | |
---|
1037 | } else if ( jQuery.browser.msie && name == "style" ) |
---|
1038 | return jQuery.attr( elem.style, "cssText", value ); |
---|
1039 | |
---|
1040 | else if ( value == undefined && jQuery.browser.msie && jQuery.nodeName( elem, "form" ) && (name == "action" || name == "method") ) |
---|
1041 | return elem.getAttributeNode( name ).nodeValue; |
---|
1042 | |
---|
1043 | // IE elem.getAttribute passes even for style |
---|
1044 | else if ( elem.tagName ) { |
---|
1045 | |
---|
1046 | if ( value != undefined ) { |
---|
1047 | // We can't allow the type property to be changed (since it causes problems in IE) |
---|
1048 | if ( name == "type" && jQuery.nodeName( elem, "input" ) && elem.parentNode ) |
---|
1049 | throw "type property can't be changed"; |
---|
1050 | |
---|
1051 | // convert the value to a string (all browsers do this but IE) see #1070 |
---|
1052 | elem.setAttribute( name, "" + value ); |
---|
1053 | } |
---|
1054 | |
---|
1055 | if ( jQuery.browser.msie && /href|src/.test( name ) && !jQuery.isXMLDoc( elem ) ) |
---|
1056 | return elem.getAttribute( name, 2 ); |
---|
1057 | |
---|
1058 | return elem.getAttribute( name ); |
---|
1059 | |
---|
1060 | // elem is actually elem.style ... set the style |
---|
1061 | } else { |
---|
1062 | // IE actually uses filters for opacity |
---|
1063 | if ( name == "opacity" && jQuery.browser.msie ) { |
---|
1064 | if ( value != undefined ) { |
---|
1065 | // IE has trouble with opacity if it does not have layout |
---|
1066 | // Force it by setting the zoom level |
---|
1067 | elem.zoom = 1; |
---|
1068 | |
---|
1069 | // Set the alpha filter to set the opacity |
---|
1070 | elem.filter = (elem.filter || "").replace( /alpha\([^)]*\)/, "" ) + |
---|
1071 | (parseFloat( value ).toString() == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")"); |
---|
1072 | } |
---|
1073 | |
---|
1074 | return elem.filter && elem.filter.indexOf("opacity=") >= 0 ? |
---|
1075 | (parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100).toString() : |
---|
1076 | ""; |
---|
1077 | } |
---|
1078 | |
---|
1079 | name = name.replace(/-([a-z])/ig, function(all, letter){ |
---|
1080 | return letter.toUpperCase(); |
---|
1081 | }); |
---|
1082 | |
---|
1083 | if ( value != undefined ) |
---|
1084 | elem[ name ] = value; |
---|
1085 | |
---|
1086 | return elem[ name ]; |
---|
1087 | } |
---|
1088 | }, |
---|
1089 | |
---|
1090 | trim: function( text ) { |
---|
1091 | return (text || "").replace( /^\s+|\s+$/g, "" ); |
---|
1092 | }, |
---|
1093 | |
---|
1094 | makeArray: function( array ) { |
---|
1095 | var ret = []; |
---|
1096 | |
---|
1097 | // Need to use typeof to fight Safari childNodes crashes |
---|
1098 | if ( typeof array != "array" ) |
---|
1099 | for ( var i = 0, length = array.length; i < length; i++ ) |
---|
1100 | ret.push( array[ i ] ); |
---|
1101 | else |
---|
1102 | ret = array.slice( 0 ); |
---|
1103 | |
---|
1104 | return ret; |
---|
1105 | }, |
---|
1106 | |
---|
1107 | inArray: function( elem, array ) { |
---|
1108 | for ( var i = 0, length = array.length; i < length; i++ ) |
---|
1109 | if ( array[ i ] == elem ) |
---|
1110 | return i; |
---|
1111 | |
---|
1112 | return -1; |
---|
1113 | }, |
---|
1114 | |
---|
1115 | merge: function( first, second ) { |
---|
1116 | // We have to loop this way because IE & Opera overwrite the length |
---|
1117 | // expando of getElementsByTagName |
---|
1118 | |
---|
1119 | // Also, we need to make sure that the correct elements are being returned |
---|
1120 | // (IE returns comment nodes in a '*' query) |
---|
1121 | if ( jQuery.browser.msie ) { |
---|
1122 | for ( var i = 0; second[ i ]; i++ ) |
---|
1123 | if ( second[ i ].nodeType != 8 ) |
---|
1124 | first.push( second[ i ] ); |
---|
1125 | |
---|
1126 | } else |
---|
1127 | for ( var i = 0; second[ i ]; i++ ) |
---|
1128 | first.push( second[ i ] ); |
---|
1129 | |
---|
1130 | return first; |
---|
1131 | }, |
---|
1132 | |
---|
1133 | unique: function( array ) { |
---|
1134 | var ret = [], done = {}; |
---|
1135 | |
---|
1136 | try { |
---|
1137 | |
---|
1138 | for ( var i = 0, length = array.length; i < length; i++ ) { |
---|
1139 | var id = jQuery.data( array[ i ] ); |
---|
1140 | |
---|
1141 | if ( !done[ id ] ) { |
---|
1142 | done[ id ] = true; |
---|
1143 | ret.push( array[ i ] ); |
---|
1144 | } |
---|
1145 | } |
---|
1146 | |
---|
1147 | } catch( e ) { |
---|
1148 | ret = array; |
---|
1149 | } |
---|
1150 | |
---|
1151 | return ret; |
---|
1152 | }, |
---|
1153 | |
---|
1154 | grep: function( elems, callback, inv ) { |
---|
1155 | // If a string is passed in for the function, make a function |
---|
1156 | // for it (a handy shortcut) |
---|
1157 | if ( typeof callback == "string" ) |
---|
1158 | callback = eval("false||function(a,i){return " + callback + "}"); |
---|
1159 | |
---|
1160 | var ret = []; |
---|
1161 | |
---|
1162 | // Go through the array, only saving the items |
---|
1163 | // that pass the validator function |
---|
1164 | for ( var i = 0, length = elems.length; i < length; i++ ) |
---|
1165 | if ( !inv && callback( elems[ i ], i ) || inv && !callback( elems[ i ], i ) ) |
---|
1166 | ret.push( elems[ i ] ); |
---|
1167 | |
---|
1168 | return ret; |
---|
1169 | }, |
---|
1170 | |
---|
1171 | map: function( elems, callback ) { |
---|
1172 | var ret = []; |
---|
1173 | |
---|
1174 | // Go through the array, translating each of the items to their |
---|
1175 | // new value (or values). |
---|
1176 | for ( var i = 0, length = elems.length; i < length; i++ ) { |
---|
1177 | var value = callback( elems[ i ], i ); |
---|
1178 | |
---|
1179 | if ( value !== null && value != undefined ) { |
---|
1180 | if ( value.constructor != Array ) |
---|
1181 | value = [ value ]; |
---|
1182 | |
---|
1183 | ret = ret.concat( value ); |
---|
1184 | } |
---|
1185 | } |
---|
1186 | |
---|
1187 | return ret; |
---|
1188 | } |
---|
1189 | }); |
---|
1190 | |
---|
1191 | var userAgent = navigator.userAgent.toLowerCase(); |
---|
1192 | |
---|
1193 | // Figure out what browser is being used |
---|
1194 | jQuery.browser = { |
---|
1195 | version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1], |
---|
1196 | safari: /webkit/.test( userAgent ), |
---|
1197 | opera: /opera/.test( userAgent ), |
---|
1198 | msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ), |
---|
1199 | mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent ) |
---|
1200 | }; |
---|
1201 | |
---|
1202 | var styleFloat = jQuery.browser.msie ? |
---|
1203 | "styleFloat" : |
---|
1204 | "cssFloat"; |
---|
1205 | |
---|
1206 | jQuery.extend({ |
---|
1207 | // Check to see if the W3C box model is being used |
---|
1208 | boxModel: !jQuery.browser.msie || document.compatMode == "CSS1Compat", |
---|
1209 | |
---|
1210 | props: { |
---|
1211 | "for": "htmlFor", |
---|
1212 | "class": "className", |
---|
1213 | "float": styleFloat, |
---|
1214 | cssFloat: styleFloat, |
---|
1215 | styleFloat: styleFloat, |
---|
1216 | innerHTML: "innerHTML", |
---|
1217 | className: "className", |
---|
1218 | value: "value", |
---|
1219 | disabled: "disabled", |
---|
1220 | checked: "checked", |
---|
1221 | readonly: "readOnly", |
---|
1222 | selected: "selected", |
---|
1223 | maxlength: "maxLength", |
---|
1224 | selectedIndex: "selectedIndex", |
---|
1225 | defaultValue: "defaultValue", |
---|
1226 | tagName: "tagName", |
---|
1227 | nodeName: "nodeName" |
---|
1228 | } |
---|
1229 | }); |
---|
1230 | |
---|
1231 | jQuery.each({ |
---|
1232 | parent: "elem.parentNode", |
---|
1233 | parents: "jQuery.dir(elem,'parentNode')", |
---|
1234 | next: "jQuery.nth(elem,2,'nextSibling')", |
---|
1235 | prev: "jQuery.nth(elem,2,'previousSibling')", |
---|
1236 | nextAll: "jQuery.dir(elem,'nextSibling')", |
---|
1237 | prevAll: "jQuery.dir(elem,'previousSibling')", |
---|
1238 | siblings: "jQuery.sibling(elem.parentNode.firstChild,elem)", |
---|
1239 | children: "jQuery.sibling(elem.firstChild)", |
---|
1240 | contents: "jQuery.nodeName(elem,'iframe')?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes)" |
---|
1241 | }, function(name, fn){ |
---|
1242 | fn = eval("false||function(elem){return " + fn + "}"); |
---|
1243 | |
---|
1244 | jQuery.fn[ name ] = function( selector ) { |
---|
1245 | var ret = jQuery.map( this, fn ); |
---|
1246 | |
---|
1247 | if ( selector && typeof selector == "string" ) |
---|
1248 | ret = jQuery.multiFilter( selector, ret ); |
---|
1249 | |
---|
1250 | return this.pushStack( jQuery.unique( ret ) ); |
---|
1251 | }; |
---|
1252 | }); |
---|
1253 | |
---|
1254 | jQuery.each({ |
---|
1255 | appendTo: "append", |
---|
1256 | prependTo: "prepend", |
---|
1257 | insertBefore: "before", |
---|
1258 | insertAfter: "after", |
---|
1259 | replaceAll: "replaceWith" |
---|
1260 | }, function(name, original){ |
---|
1261 | jQuery.fn[ name ] = function() { |
---|
1262 | var args = arguments; |
---|
1263 | |
---|
1264 | return this.each(function(){ |
---|
1265 | for ( var i = 0, length = args.length; i < length; i++ ) |
---|
1266 | jQuery( args[ i ] )[ original ]( this ); |
---|
1267 | }); |
---|
1268 | }; |
---|
1269 | }); |
---|
1270 | |
---|
1271 | jQuery.each({ |
---|
1272 | removeAttr: function( name ) { |
---|
1273 | jQuery.attr( this, name, "" ); |
---|
1274 | if (this.nodeType == 1) |
---|
1275 | this.removeAttribute( name ); |
---|
1276 | }, |
---|
1277 | |
---|
1278 | addClass: function( classNames ) { |
---|
1279 | jQuery.className.add( this, classNames ); |
---|
1280 | }, |
---|
1281 | |
---|
1282 | removeClass: function( classNames ) { |
---|
1283 | jQuery.className.remove( this, classNames ); |
---|
1284 | }, |
---|
1285 | |
---|
1286 | toggleClass: function( classNames ) { |
---|
1287 | jQuery.className[ jQuery.className.has( this, classNames ) ? "remove" : "add" ]( this, classNames ); |
---|
1288 | }, |
---|
1289 | |
---|
1290 | remove: function( selector ) { |
---|
1291 | if ( !selector || jQuery.filter( selector, [ this ] ).r.length ) { |
---|
1292 | // Prevent memory leaks |
---|
1293 | jQuery( "*", this ).add(this).each(function(){ |
---|
1294 | jQuery.event.remove(this); |
---|
1295 | jQuery.removeData(this); |
---|
1296 | }); |
---|
1297 | if (this.parentNode) |
---|
1298 | this.parentNode.removeChild( this ); |
---|
1299 | } |
---|
1300 | }, |
---|
1301 | |
---|
1302 | empty: function() { |
---|
1303 | // Remove element nodes and prevent memory leaks |
---|
1304 | jQuery( ">*", this ).remove(); |
---|
1305 | |
---|
1306 | // Remove any remaining nodes |
---|
1307 | while ( this.firstChild ) |
---|
1308 | this.removeChild( this.firstChild ); |
---|
1309 | } |
---|
1310 | }, function(name, fn){ |
---|
1311 | jQuery.fn[ name ] = function(){ |
---|
1312 | return this.each( fn, arguments ); |
---|
1313 | }; |
---|
1314 | }); |
---|
1315 | |
---|
1316 | jQuery.each([ "Height", "Width" ], function(i, name){ |
---|
1317 | var type = name.toLowerCase(); |
---|
1318 | |
---|
1319 | jQuery.fn[ type ] = function( size ) { |
---|
1320 | // Get window width or height |
---|
1321 | return this[0] == window ? |
---|
1322 | // Opera reports document.body.client[Width/Height] properly in both quirks and standards |
---|
1323 | jQuery.browser.opera && document.body[ "client" + name ] || |
---|
1324 | |
---|
1325 | // Safari reports inner[Width/Height] just fine (Mozilla and Opera include scroll bar widths) |
---|
1326 | jQuery.browser.safari && window[ "inner" + name ] || |
---|
1327 | |
---|
1328 | // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode |
---|
1329 | document.compatMode == "CSS1Compat" && document.documentElement[ "client" + name ] || document.body[ "client" + name ] : |
---|
1330 | |
---|
1331 | // Get document width or height |
---|
1332 | this[0] == document ? |
---|
1333 | // Either scroll[Width/Height] or offset[Width/Height], whichever is greater |
---|
1334 | Math.max( |
---|
1335 | Math.max(document.body["scroll" + name], document.documentElement["scroll" + name]), |
---|
1336 | Math.max(document.body["offset" + name], document.documentElement["offset" + name]) |
---|
1337 | ) : |
---|
1338 | |
---|
1339 | // Get or set width or height on the element |
---|
1340 | size == undefined ? |
---|
1341 | // Get width or height on the element |
---|
1342 | (this.length ? jQuery.css( this[0], type ) : null) : |
---|
1343 | |
---|
1344 | // Set the width or height on the element (default to pixels if value is unitless) |
---|
1345 | this.css( type, size.constructor == String ? size : size + "px" ); |
---|
1346 | }; |
---|
1347 | }); |
---|
1348 | |
---|
1349 | var chars = jQuery.browser.safari && parseInt(jQuery.browser.version) < 417 ? |
---|
1350 | "(?:[\\w*_-]|\\\\.)" : |
---|
1351 | "(?:[\\w\u0128-\uFFFF*_-]|\\\\.)", |
---|
1352 | quickChild = new RegExp("^>\\s*(" + chars + "+)"), |
---|
1353 | quickID = new RegExp("^(" + chars + "+)(#)(" + chars + "+)"), |
---|
1354 | quickClass = new RegExp("^([#.]?)(" + chars + "*)"); |
---|
1355 | |
---|
1356 | jQuery.extend({ |
---|
1357 | expr: { |
---|
1358 | "": "m[2]=='*'||jQuery.nodeName(a,m[2])", |
---|
1359 | "#": "a.getAttribute('id')==m[2]", |
---|
1360 | ":": { |
---|
1361 | // Position Checks |
---|
1362 | lt: "i<m[3]-0", |
---|
1363 | gt: "i>m[3]-0", |
---|
1364 | nth: "m[3]-0==i", |
---|
1365 | eq: "m[3]-0==i", |
---|
1366 | first: "i==0", |
---|
1367 | last: "i==r.length-1", |
---|
1368 | even: "i%2==0", |
---|
1369 | odd: "i%2", |
---|
1370 | |
---|
1371 | // Child Checks |
---|
1372 | "first-child": "a.parentNode.getElementsByTagName('*')[0]==a", |
---|
1373 | "last-child": "jQuery.nth(a.parentNode.lastChild,1,'previousSibling')==a", |
---|
1374 | "only-child": "!jQuery.nth(a.parentNode.lastChild,2,'previousSibling')", |
---|
1375 | |
---|
1376 | // Parent Checks |
---|
1377 | parent: "a.firstChild", |
---|
1378 | empty: "!a.firstChild", |
---|
1379 | |
---|
1380 | // Text Check |
---|
1381 | contains: "(a.textContent||a.innerText||jQuery(a).text()||'').indexOf(m[3])>=0", |
---|
1382 | |
---|
1383 | // Visibility |
---|
1384 | visible: '"hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden"', |
---|
1385 | hidden: '"hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden"', |
---|
1386 | |
---|
1387 | // Form attributes |
---|
1388 | enabled: "!a.disabled", |
---|
1389 | disabled: "a.disabled", |
---|
1390 | checked: "a.checked", |
---|
1391 | selected: "a.selected||jQuery.attr(a,'selected')", |
---|
1392 | |
---|
1393 | // Form elements |
---|
1394 | text: "'text'==a.type", |
---|
1395 | radio: "'radio'==a.type", |
---|
1396 | checkbox: "'checkbox'==a.type", |
---|
1397 | file: "'file'==a.type", |
---|
1398 | password: "'password'==a.type", |
---|
1399 | submit: "'submit'==a.type", |
---|
1400 | image: "'image'==a.type", |
---|
1401 | reset: "'reset'==a.type", |
---|
1402 | button: '"button"==a.type||jQuery.nodeName(a,"button")', |
---|
1403 | input: "/input|select|textarea|button/i.test(a.nodeName)", |
---|
1404 | |
---|
1405 | // :has() |
---|
1406 | has: "jQuery.find(m[3],a).length", |
---|
1407 | |
---|
1408 | // :header |
---|
1409 | header: "/h\\d/i.test(a.nodeName)", |
---|
1410 | |
---|
1411 | // :animated |
---|
1412 | animated: "jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;}).length" |
---|
1413 | } |
---|
1414 | }, |
---|
1415 | |
---|
1416 | // The regular expressions that power the parsing engine |
---|
1417 | parse: [ |
---|
1418 | // Match: [@value='test'], [@foo] |
---|
1419 | /^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/, |
---|
1420 | |
---|
1421 | // Match: :contains('foo') |
---|
1422 | /^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/, |
---|
1423 | |
---|
1424 | // Match: :even, :last-chlid, #id, .class |
---|
1425 | new RegExp("^([:.#]*)(" + chars + "+)") |
---|
1426 | ], |
---|
1427 | |
---|
1428 | multiFilter: function( expr, elems, not ) { |
---|
1429 | var old, cur = []; |
---|
1430 | |
---|
1431 | while ( expr && expr != old ) { |
---|
1432 | old = expr; |
---|
1433 | var f = jQuery.filter( expr, elems, not ); |
---|
1434 | expr = f.t.replace(/^\s*,\s*/, "" ); |
---|
1435 | cur = not ? elems = f.r : jQuery.merge( cur, f.r ); |
---|
1436 | } |
---|
1437 | |
---|
1438 | return cur; |
---|
1439 | }, |
---|
1440 | |
---|
1441 | find: function( t, context ) { |
---|
1442 | // Quickly handle non-string expressions |
---|
1443 | if ( typeof t != "string" ) |
---|
1444 | return [ t ]; |
---|
1445 | |
---|
1446 | // check to make sure context is a DOM element or a document |
---|
1447 | if ( context && context.nodeType != 1 && context.nodeType != 9) |
---|
1448 | return [ ]; |
---|
1449 | |
---|
1450 | // Set the correct context (if none is provided) |
---|
1451 | context = context || document; |
---|
1452 | |
---|
1453 | // Initialize the search |
---|
1454 | var ret = [context], done = [], last, nodeName; |
---|
1455 | |
---|
1456 | // Continue while a selector expression exists, and while |
---|
1457 | // we're no longer looping upon ourselves |
---|
1458 | while ( t && last != t ) { |
---|
1459 | var r = []; |
---|
1460 | last = t; |
---|
1461 | |
---|
1462 | t = jQuery.trim(t); |
---|
1463 | |
---|
1464 | var foundToken = false; |
---|
1465 | |
---|
1466 | // An attempt at speeding up child selectors that |
---|
1467 | // point to a specific element tag |
---|
1468 | var re = quickChild; |
---|
1469 | var m = re.exec(t); |
---|
1470 | |
---|
1471 | if ( m ) { |
---|
1472 | nodeName = m[1].toUpperCase(); |
---|
1473 | |
---|
1474 | // Perform our own iteration and filter |
---|
1475 | for ( var i = 0; ret[i]; i++ ) |
---|
1476 | for ( var c = ret[i].firstChild; c; c = c.nextSibling ) |
---|
1477 | if ( c.nodeType == 1 && (nodeName == "*" || c.nodeName.toUpperCase() == nodeName) ) |
---|
1478 | r.push( c ); |
---|
1479 | |
---|
1480 | ret = r; |
---|
1481 | t = t.replace( re, "" ); |
---|
1482 | if ( t.indexOf(" ") == 0 ) continue; |
---|
1483 | foundToken = true; |
---|
1484 | } else { |
---|
1485 | re = /^([>+~])\s*(\w*)/i; |
---|
1486 | |
---|
1487 | if ( (m = re.exec(t)) != null ) { |
---|
1488 | r = []; |
---|
1489 | |
---|
1490 | nodeName = m[2].toUpperCase(), merge = {}; |
---|
1491 | m = m[1]; |
---|
1492 | |
---|
1493 | for ( var j = 0, rl = ret.length; j < rl; j++ ) { |
---|
1494 | var n = m == "~" || m == "+" ? ret[j].nextSibling : ret[j].firstChild; |
---|
1495 | for ( ; n; n = n.nextSibling ) |
---|
1496 | if ( n.nodeType == 1 ) { |
---|
1497 | var id = jQuery.data(n); |
---|
1498 | |
---|
1499 | if ( m == "~" && merge[id] ) break; |
---|
1500 | |
---|
1501 | if (!nodeName || n.nodeName.toUpperCase() == nodeName ) { |
---|
1502 | if ( m == "~" ) merge[id] = true; |
---|
1503 | r.push( n ); |
---|
1504 | } |
---|
1505 | |
---|
1506 | if ( m == "+" ) break; |
---|
1507 | } |
---|
1508 | } |
---|
1509 | |
---|
1510 | ret = r; |
---|
1511 | |
---|
1512 | // And remove the token |
---|
1513 | t = jQuery.trim( t.replace( re, "" ) ); |
---|
1514 | foundToken = true; |
---|
1515 | } |
---|
1516 | } |
---|
1517 | |
---|
1518 | // See if there's still an expression, and that we haven't already |
---|
1519 | // matched a token |
---|
1520 | if ( t && !foundToken ) { |
---|
1521 | // Handle multiple expressions |
---|
1522 | if ( !t.indexOf(",") ) { |
---|
1523 | // Clean the result set |
---|
1524 | if ( context == ret[0] ) ret.shift(); |
---|
1525 | |
---|
1526 | // Merge the result sets |
---|
1527 | done = jQuery.merge( done, ret ); |
---|
1528 | |
---|
1529 | // Reset the context |
---|
1530 | r = ret = [context]; |
---|
1531 | |
---|
1532 | // Touch up the selector string |
---|
1533 | t = " " + t.substr(1,t.length); |
---|
1534 | |
---|
1535 | } else { |
---|
1536 | // Optimize for the case nodeName#idName |
---|
1537 | var re2 = quickID; |
---|
1538 | var m = re2.exec(t); |
---|
1539 | |
---|
1540 | // Re-organize the results, so that they're consistent |
---|
1541 | if ( m ) { |
---|
1542 | m = [ 0, m[2], m[3], m[1] ]; |
---|
1543 | |
---|
1544 | } else { |
---|
1545 | // Otherwise, do a traditional filter check for |
---|
1546 | // ID, class, and element selectors |
---|
1547 | re2 = quickClass; |
---|
1548 | m = re2.exec(t); |
---|
1549 | } |
---|
1550 | |
---|
1551 | m[2] = m[2].replace(/\\/g, ""); |
---|
1552 | |
---|
1553 | var elem = ret[ret.length-1]; |
---|
1554 | |
---|
1555 | // Try to do a global search by ID, where we can |
---|
1556 | if ( m[1] == "#" && elem && elem.getElementById && !jQuery.isXMLDoc(elem) ) { |
---|
1557 | // Optimization for HTML document case |
---|
1558 | var oid = elem.getElementById(m[2]); |
---|
1559 | |
---|
1560 | // Do a quick check for the existence of the actual ID attribute |
---|
1561 | // to avoid selecting by the name attribute in IE |
---|
1562 | // also check to insure id is a string to avoid selecting an element with the name of 'id' inside a form |
---|
1563 | if ( (jQuery.browser.msie||jQuery.browser.opera) && oid && typeof oid.id == "string" && oid.id != m[2] ) |
---|
1564 | oid = jQuery('[@id="'+m[2]+'"]', elem)[0]; |
---|
1565 | |
---|
1566 | // Do a quick check for node name (where applicable) so |
---|
1567 | // that div#foo searches will be really fast |
---|
1568 | ret = r = oid && (!m[3] || jQuery.nodeName(oid, m[3])) ? [oid] : []; |
---|
1569 | } else { |
---|
1570 | // We need to find all descendant elements |
---|
1571 | for ( var i = 0; ret[i]; i++ ) { |
---|
1572 | // Grab the tag name being searched for |
---|
1573 | var tag = m[1] == "#" && m[3] ? m[3] : m[1] != "" || m[0] == "" ? "*" : m[2]; |
---|
1574 | |
---|
1575 | // Handle IE7 being really dumb about <object>s |
---|
1576 | if ( tag == "*" && ret[i].nodeName.toLowerCase() == "object" ) |
---|
1577 | tag = "param"; |
---|
1578 | |
---|
1579 | r = jQuery.merge( r, ret[i].getElementsByTagName( tag )); |
---|
1580 | } |
---|
1581 | |
---|
1582 | // It's faster to filter by class and be done with it |
---|
1583 | if ( m[1] == "." ) |
---|
1584 | r = jQuery.classFilter( r, m[2] ); |
---|
1585 | |
---|
1586 | // Same with ID filtering |
---|
1587 | if ( m[1] == "#" ) { |
---|
1588 | var tmp = []; |
---|
1589 | |
---|
1590 | // Try to find the element with the ID |
---|
1591 | for ( var i = 0; r[i]; i++ ) |
---|
1592 | if ( r[i].getAttribute("id") == m[2] ) { |
---|
1593 | tmp = [ r[i] ]; |
---|
1594 | break; |
---|
1595 | } |
---|
1596 | |
---|
1597 | r = tmp; |
---|
1598 | } |
---|
1599 | |
---|
1600 | ret = r; |
---|
1601 | } |
---|
1602 | |
---|
1603 | t = t.replace( re2, "" ); |
---|
1604 | } |
---|
1605 | |
---|
1606 | } |
---|
1607 | |
---|
1608 | // If a selector string still exists |
---|
1609 | if ( t ) { |
---|
1610 | // Attempt to filter it |
---|
1611 | var val = jQuery.filter(t,r); |
---|
1612 | ret = r = val.r; |
---|
1613 | t = jQuery.trim(val.t); |
---|
1614 | } |
---|
1615 | } |
---|
1616 | |
---|
1617 | // An error occurred with the selector; |
---|
1618 | // just return an empty set instead |
---|
1619 | if ( t ) |
---|
1620 | ret = []; |
---|
1621 | |
---|
1622 | // Remove the root context |
---|
1623 | if ( ret && context == ret[0] ) |
---|
1624 | ret.shift(); |
---|
1625 | |
---|
1626 | // And combine the results |
---|
1627 | done = jQuery.merge( done, ret ); |
---|
1628 | |
---|
1629 | return done; |
---|
1630 | }, |
---|
1631 | |
---|
1632 | classFilter: function(r,m,not){ |
---|
1633 | m = " " + m + " "; |
---|
1634 | var tmp = []; |
---|
1635 | for ( var i = 0; r[i]; i++ ) { |
---|
1636 | var pass = (" " + r[i].className + " ").indexOf( m ) >= 0; |
---|
1637 | if ( !not && pass || not && !pass ) |
---|
1638 | tmp.push( r[i] ); |
---|
1639 | } |
---|
1640 | return tmp; |
---|
1641 | }, |
---|
1642 | |
---|
1643 | filter: function(t,r,not) { |
---|
1644 | var last; |
---|
1645 | |
---|
1646 | // Look for common filter expressions |
---|
1647 | while ( t && t != last ) { |
---|
1648 | last = t; |
---|
1649 | |
---|
1650 | var p = jQuery.parse, m; |
---|
1651 | |
---|
1652 | for ( var i = 0; p[i]; i++ ) { |
---|
1653 | m = p[i].exec( t ); |
---|
1654 | |
---|
1655 | if ( m ) { |
---|
1656 | // Remove what we just matched |
---|
1657 | t = t.substring( m[0].length ); |
---|
1658 | |
---|
1659 | m[2] = m[2].replace(/\\/g, ""); |
---|
1660 | break; |
---|
1661 | } |
---|
1662 | } |
---|
1663 | |
---|
1664 | if ( !m ) |
---|
1665 | break; |
---|
1666 | |
---|
1667 | // :not() is a special case that can be optimized by |
---|
1668 | // keeping it out of the expression list |
---|
1669 | if ( m[1] == ":" && m[2] == "not" ) |
---|
1670 | // optimize if only one selector found (most common case) |
---|
1671 | r = isSimple.test( m[3] ) ? |
---|
1672 | jQuery.filter(m[3], r, true).r : |
---|
1673 | jQuery( r ).not( m[3] ); |
---|
1674 | |
---|
1675 | // We can get a big speed boost by filtering by class here |
---|
1676 | else if ( m[1] == "." ) |
---|
1677 | r = jQuery.classFilter(r, m[2], not); |
---|
1678 | |
---|
1679 | else if ( m[1] == "[" ) { |
---|
1680 | var tmp = [], type = m[3]; |
---|
1681 | |
---|
1682 | for ( var i = 0, rl = r.length; i < rl; i++ ) { |
---|
1683 | var a = r[i], z = a[ jQuery.props[m[2]] || m[2] ]; |
---|
1684 | |
---|
1685 | if ( z == null || /href|src|selected/.test(m[2]) ) |
---|
1686 | z = jQuery.attr(a,m[2]) || ''; |
---|
1687 | |
---|
1688 | if ( (type == "" && !!z || |
---|
1689 | type == "=" && z == m[5] || |
---|
1690 | type == "!=" && z != m[5] || |
---|
1691 | type == "^=" && z && !z.indexOf(m[5]) || |
---|
1692 | type == "$=" && z.substr(z.length - m[5].length) == m[5] || |
---|
1693 | (type == "*=" || type == "~=") && z.indexOf(m[5]) >= 0) ^ not ) |
---|
1694 | tmp.push( a ); |
---|
1695 | } |
---|
1696 | |
---|
1697 | r = tmp; |
---|
1698 | |
---|
1699 | // We can get a speed boost by handling nth-child here |
---|
1700 | } else if ( m[1] == ":" && m[2] == "nth-child" ) { |
---|
1701 | var merge = {}, tmp = [], |
---|
1702 | // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6' |
---|
1703 | test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec( |
---|
1704 | m[3] == "even" && "2n" || m[3] == "odd" && "2n+1" || |
---|
1705 | !/\D/.test(m[3]) && "0n+" + m[3] || m[3]), |
---|
1706 | // calculate the numbers (first)n+(last) including if they are negative |
---|
1707 | first = (test[1] + (test[2] || 1)) - 0, last = test[3] - 0; |
---|
1708 | |
---|
1709 | // loop through all the elements left in the jQuery object |
---|
1710 | for ( var i = 0, rl = r.length; i < rl; i++ ) { |
---|
1711 | var node = r[i], parentNode = node.parentNode, id = jQuery.data(parentNode); |
---|
1712 | |
---|
1713 | if ( !merge[id] ) { |
---|
1714 | var c = 1; |
---|
1715 | |
---|
1716 | for ( var n = parentNode.firstChild; n; n = n.nextSibling ) |
---|
1717 | if ( n.nodeType == 1 ) |
---|
1718 | n.nodeIndex = c++; |
---|
1719 | |
---|
1720 | merge[id] = true; |
---|
1721 | } |
---|
1722 | |
---|
1723 | var add = false; |
---|
1724 | |
---|
1725 | if ( first == 0 ) { |
---|
1726 | if ( node.nodeIndex == last ) |
---|
1727 | add = true; |
---|
1728 | } else if ( (node.nodeIndex - last) % first == 0 && (node.nodeIndex - last) / first >= 0 ) |
---|
1729 | add = true; |
---|
1730 | |
---|
1731 | if ( add ^ not ) |
---|
1732 | tmp.push( node ); |
---|
1733 | } |
---|
1734 | |
---|
1735 | r = tmp; |
---|
1736 | |
---|
1737 | // Otherwise, find the expression to execute |
---|
1738 | } else { |
---|
1739 | var f = jQuery.expr[m[1]]; |
---|
1740 | if ( typeof f != "string" ) |
---|
1741 | f = jQuery.expr[m[1]][m[2]]; |
---|
1742 | |
---|
1743 | // Build a custom macro to enclose it |
---|
1744 | f = eval("false||function(a,i){return " + f + "}"); |
---|
1745 | |
---|
1746 | // Execute it against the current filter |
---|
1747 | r = jQuery.grep( r, f, not ); |
---|
1748 | } |
---|
1749 | } |
---|
1750 | |
---|
1751 | // Return an array of filtered elements (r) |
---|
1752 | // and the modified expression string (t) |
---|
1753 | return { r: r, t: t }; |
---|
1754 | }, |
---|
1755 | |
---|
1756 | dir: function( elem, dir ){ |
---|
1757 | var matched = []; |
---|
1758 | var cur = elem[dir]; |
---|
1759 | while ( cur && cur != document ) { |
---|
1760 | if ( cur.nodeType == 1 ) |
---|
1761 | matched.push( cur ); |
---|
1762 | cur = cur[dir]; |
---|
1763 | } |
---|
1764 | return matched; |
---|
1765 | }, |
---|
1766 | |
---|
1767 | nth: function(cur,result,dir,elem){ |
---|
1768 | result = result || 1; |
---|
1769 | var num = 0; |
---|
1770 | |
---|
1771 | for ( ; cur; cur = cur[dir] ) |
---|
1772 | if ( cur.nodeType == 1 && ++num == result ) |
---|
1773 | break; |
---|
1774 | |
---|
1775 | return cur; |
---|
1776 | }, |
---|
1777 | |
---|
1778 | sibling: function( n, elem ) { |
---|
1779 | var r = []; |
---|
1780 | |
---|
1781 | for ( ; n; n = n.nextSibling ) { |
---|
1782 | if ( n.nodeType == 1 && (!elem || n != elem) ) |
---|
1783 | r.push( n ); |
---|
1784 | } |
---|
1785 | |
---|
1786 | return r; |
---|
1787 | } |
---|
1788 | }); |
---|
1789 | |
---|
1790 | /* |
---|
1791 | |
---|
1792 | * A number of helper functions used for managing events. |
---|
1793 | |
---|
1794 | * Many of the ideas behind this code orignated from |
---|
1795 | |
---|
1796 | * Dean Edwards' addEvent library. |
---|
1797 | |
---|
1798 | */ |
---|
1799 | |
---|
1800 | jQuery.event = { |
---|
1801 | |
---|
1802 | |
---|
1803 | |
---|
1804 | // Bind an event to an element |
---|
1805 | |
---|
1806 | // Original by Dean Edwards |
---|
1807 | |
---|
1808 | add: function(elem, types, handler, data) { |
---|
1809 | |
---|
1810 | if ( elem.nodeType == 3 || elem.nodeType == 8 ) |
---|
1811 | |
---|
1812 | return; |
---|
1813 | |
---|
1814 | |
---|
1815 | |
---|
1816 | // For whatever reason, IE has trouble passing the window object |
---|
1817 | |
---|
1818 | // around, causing it to be cloned in the process |
---|
1819 | |
---|
1820 | if ( jQuery.browser.msie && elem.setInterval != undefined ) |
---|
1821 | |
---|
1822 | elem = window; |
---|
1823 | |
---|
1824 | |
---|
1825 | |
---|
1826 | // Make sure that the function being executed has a unique ID |
---|
1827 | |
---|
1828 | if ( !handler.guid ) |
---|
1829 | |
---|
1830 | handler.guid = this.guid++; |
---|
1831 | |
---|
1832 | |
---|
1833 | |
---|
1834 | // if data is passed, bind to handler |
---|
1835 | |
---|
1836 | if( data != undefined ) { |
---|
1837 | |
---|
1838 | // Create temporary function pointer to original handler |
---|
1839 | |
---|
1840 | var fn = handler; |
---|
1841 | |
---|
1842 | |
---|
1843 | |
---|
1844 | // Create unique handler function, wrapped around original handler |
---|
1845 | |
---|
1846 | handler = function() { |
---|
1847 | |
---|
1848 | // Pass arguments and context to original handler |
---|
1849 | |
---|
1850 | return fn.apply(this, arguments); |
---|
1851 | |
---|
1852 | }; |
---|
1853 | |
---|
1854 | |
---|
1855 | |
---|
1856 | // Store data in unique handler |
---|
1857 | |
---|
1858 | handler.data = data; |
---|
1859 | |
---|
1860 | |
---|
1861 | |
---|
1862 | // Set the guid of unique handler to the same of original handler, so it can be removed |
---|
1863 | |
---|
1864 | handler.guid = fn.guid; |
---|
1865 | |
---|
1866 | } |
---|
1867 | |
---|
1868 | |
---|
1869 | |
---|
1870 | // Init the element's event structure |
---|
1871 | |
---|
1872 | var events = jQuery.data(elem, "events") || jQuery.data(elem, "events", {}), |
---|
1873 | |
---|
1874 | handle = jQuery.data(elem, "handle") || jQuery.data(elem, "handle", function(){ |
---|
1875 | |
---|
1876 | // returned undefined or false |
---|
1877 | |
---|
1878 | var val; |
---|
1879 | |
---|
1880 | |
---|
1881 | |
---|
1882 | // Handle the second event of a trigger and when |
---|
1883 | |
---|
1884 | // an event is called after a page has unloaded |
---|
1885 | |
---|
1886 | if ( typeof jQuery == "undefined" || jQuery.event.triggered ) |
---|
1887 | |
---|
1888 | return val; |
---|
1889 | |
---|
1890 | |
---|
1891 | |
---|
1892 | val = jQuery.event.handle.apply(elem, arguments); |
---|
1893 | |
---|
1894 | |
---|
1895 | |
---|
1896 | return val; |
---|
1897 | |
---|
1898 | }); |
---|
1899 | |
---|
1900 | |
---|
1901 | |
---|
1902 | // Handle multiple events seperated by a space |
---|
1903 | |
---|
1904 | // jQuery(...).bind("mouseover mouseout", fn); |
---|
1905 | |
---|
1906 | jQuery.each(types.split(/\s+/), function(index, type) { |
---|
1907 | |
---|
1908 | // Namespaced event handlers |
---|
1909 | |
---|
1910 | var parts = type.split("."); |
---|
1911 | |
---|
1912 | type = parts[0]; |
---|
1913 | |
---|
1914 | handler.type = parts[1]; |
---|
1915 | |
---|
1916 | |
---|
1917 | |
---|
1918 | // Get the current list of functions bound to this event |
---|
1919 | |
---|
1920 | var handlers = events[type]; |
---|
1921 | |
---|
1922 | |
---|
1923 | |
---|
1924 | // Init the event handler queue |
---|
1925 | |
---|
1926 | if (!handlers) { |
---|
1927 | |
---|
1928 | handlers = events[type] = {}; |
---|
1929 | |
---|
1930 | |
---|
1931 | |
---|
1932 | // Check for a special event handler |
---|
1933 | |
---|
1934 | // Only use addEventListener/attachEvent if the special |
---|
1935 | |
---|
1936 | // events handler returns false |
---|
1937 | |
---|
1938 | if ( !jQuery.event.special[type] || jQuery.event.special[type].setup.call(elem) === false ) { |
---|
1939 | |
---|
1940 | // Bind the global event handler to the element |
---|
1941 | |
---|
1942 | if (elem.addEventListener) |
---|
1943 | |
---|
1944 | elem.addEventListener(type, handle, false); |
---|
1945 | |
---|
1946 | else if (elem.attachEvent) |
---|
1947 | |
---|
1948 | elem.attachEvent("on" + type, handle); |
---|
1949 | |
---|
1950 | } |
---|
1951 | |
---|
1952 | } |
---|
1953 | |
---|
1954 | |
---|
1955 | |
---|
1956 | // Add the function to the element's handler list |
---|
1957 | |
---|
1958 | handlers[handler.guid] = handler; |
---|
1959 | |
---|
1960 | |
---|
1961 | |
---|
1962 | // Keep track of which events have been used, for global triggering |
---|
1963 | |
---|
1964 | jQuery.event.global[type] = true; |
---|
1965 | |
---|
1966 | }); |
---|
1967 | |
---|
1968 | }, |
---|
1969 | |
---|
1970 | |
---|
1971 | |
---|
1972 | guid: 1, |
---|
1973 | |
---|
1974 | global: {}, |
---|
1975 | |
---|
1976 | |
---|
1977 | |
---|
1978 | // Detach an event or set of events from an element |
---|
1979 | |
---|
1980 | remove: function(elem, types, handler) { |
---|
1981 | |
---|
1982 | // don't do events on text and comment nodes |
---|
1983 | |
---|
1984 | if ( elem.nodeType == 3 || elem.nodeType == 8 ) |
---|
1985 | |
---|
1986 | return; |
---|
1987 | |
---|
1988 | |
---|
1989 | |
---|
1990 | var events = jQuery.data(elem, "events"), ret, index; |
---|
1991 | |
---|
1992 | |
---|
1993 | |
---|
1994 | if ( events ) { |
---|
1995 | |
---|
1996 | // Unbind all events for the element |
---|
1997 | |
---|
1998 | if ( !types ) |
---|
1999 | |
---|
2000 | for ( var type in events ) |
---|
2001 | |
---|
2002 | this.remove( elem, type ); |
---|
2003 | |
---|
2004 | else { |
---|
2005 | |
---|
2006 | // types is actually an event object here |
---|
2007 | |
---|
2008 | if ( types.type ) { |
---|
2009 | |
---|
2010 | handler = types.handler; |
---|
2011 | |
---|
2012 | types = types.type; |
---|
2013 | |
---|
2014 | } |
---|
2015 | |
---|
2016 | |
---|
2017 | |
---|
2018 | // Handle multiple events seperated by a space |
---|
2019 | |
---|
2020 | // jQuery(...).unbind("mouseover mouseout", fn); |
---|
2021 | |
---|
2022 | jQuery.each(types.split(/\s+/), function(index, type){ |
---|
2023 | |
---|
2024 | // Namespaced event handlers |
---|
2025 | |
---|
2026 | var parts = type.split("."); |
---|
2027 | |
---|
2028 | type = parts[0]; |
---|
2029 | |
---|
2030 | |
---|
2031 | |
---|
2032 | if ( events[type] ) { |
---|
2033 | |
---|
2034 | // remove the given handler for the given type |
---|
2035 | |
---|
2036 | if ( handler ) |
---|
2037 | |
---|
2038 | delete events[type][handler.guid]; |
---|
2039 | |
---|
2040 | |
---|
2041 | |
---|
2042 | // remove all handlers for the given type |
---|
2043 | |
---|
2044 | else |
---|
2045 | |
---|
2046 | for ( handler in events[type] ) |
---|
2047 | |
---|
2048 | // Handle the removal of namespaced events |
---|
2049 | |
---|
2050 | if ( !parts[1] || events[type][handler].type == parts[1] ) |
---|
2051 | |
---|
2052 | delete events[type][handler]; |
---|
2053 | |
---|
2054 | |
---|
2055 | |
---|
2056 | // remove generic event handler if no more handlers exist |
---|
2057 | |
---|
2058 | for ( ret in events[type] ) break; |
---|
2059 | |
---|
2060 | if ( !ret ) { |
---|
2061 | |
---|
2062 | if ( !jQuery.event.special[type] || jQuery.event.special[type].teardown.call(elem) === false ) { |
---|
2063 | |
---|
2064 | if (elem.removeEventListener) |
---|
2065 | |
---|
2066 | elem.removeEventListener(type, jQuery.data(elem, "handle"), false); |
---|
2067 | |
---|
2068 | else if (elem.detachEvent) |
---|
2069 | |
---|
2070 | elem.detachEvent("on" + type, jQuery.data(elem, "handle")); |
---|
2071 | |
---|
2072 | } |
---|
2073 | |
---|
2074 | ret = null; |
---|
2075 | |
---|
2076 | delete events[type]; |
---|
2077 | |
---|
2078 | } |
---|
2079 | |
---|
2080 | } |
---|
2081 | |
---|
2082 | }); |
---|
2083 | |
---|
2084 | } |
---|
2085 | |
---|
2086 | |
---|
2087 | |
---|
2088 | // Remove the expando if it's no longer used |
---|
2089 | |
---|
2090 | for ( ret in events ) break; |
---|
2091 | |
---|
2092 | if ( !ret ) { |
---|
2093 | |
---|
2094 | jQuery.removeData( elem, "events" ); |
---|
2095 | |
---|
2096 | jQuery.removeData( elem, "handle" ); |
---|
2097 | |
---|
2098 | } |
---|
2099 | |
---|
2100 | } |
---|
2101 | |
---|
2102 | }, |
---|
2103 | |
---|
2104 | |
---|
2105 | |
---|
2106 | trigger: function(type, data, elem, donative, extra) { |
---|
2107 | |
---|
2108 | // Clone the incoming data, if any |
---|
2109 | |
---|
2110 | data = jQuery.makeArray(data || []); |
---|
2111 | |
---|
2112 | |
---|
2113 | |
---|
2114 | // Handle a global trigger |
---|
2115 | |
---|
2116 | if ( !elem ) { |
---|
2117 | |
---|
2118 | // Only trigger if we've ever bound an event for it |
---|
2119 | |
---|
2120 | if ( this.global[type] ) |
---|
2121 | |
---|
2122 | jQuery("*").add([window, document]).trigger(type, data); |
---|
2123 | |
---|
2124 | |
---|
2125 | |
---|
2126 | // Handle triggering a single element |
---|
2127 | |
---|
2128 | } else { |
---|
2129 | |
---|
2130 | // don't do events on text and comment nodes |
---|
2131 | |
---|
2132 | if ( elem.nodeType == 3 || elem.nodeType == 8 ) |
---|
2133 | |
---|
2134 | return undefined; |
---|
2135 | |
---|
2136 | |
---|
2137 | |
---|
2138 | var val, ret, fn = jQuery.isFunction( elem[ type ] || null ), |
---|
2139 | |
---|
2140 | // Check to see if we need to provide a fake event, or not |
---|
2141 | |
---|
2142 | event = !data[0] || !data[0].preventDefault; |
---|
2143 | |
---|
2144 | |
---|
2145 | |
---|
2146 | // Pass along a fake event |
---|
2147 | |
---|
2148 | if ( event ) |
---|
2149 | |
---|
2150 | data.unshift( this.fix({ type: type, target: elem }) ); |
---|
2151 | |
---|
2152 | |
---|
2153 | |
---|
2154 | // Enforce the right trigger type |
---|
2155 | |
---|
2156 | data[0].type = type; |
---|
2157 | |
---|
2158 | |
---|
2159 | |
---|
2160 | // Trigger the event |
---|
2161 | |
---|
2162 | if ( jQuery.isFunction( jQuery.data(elem, "handle") ) ) |
---|
2163 | |
---|
2164 | val = jQuery.data(elem, "handle").apply( elem, data ); |
---|
2165 | |
---|
2166 | |
---|
2167 | |
---|
2168 | // Handle triggering native .onfoo handlers |
---|
2169 | |
---|
2170 | if ( !fn && elem["on"+type] && elem["on"+type].apply( elem, data ) === false ) |
---|
2171 | |
---|
2172 | val = false; |
---|
2173 | |
---|
2174 | |
---|
2175 | |
---|
2176 | // Extra functions don't get the custom event object |
---|
2177 | |
---|
2178 | if ( event ) |
---|
2179 | |
---|
2180 | data.shift(); |
---|
2181 | |
---|
2182 | |
---|
2183 | |
---|
2184 | // Handle triggering of extra function |
---|
2185 | |
---|
2186 | if ( extra && jQuery.isFunction( extra ) ) { |
---|
2187 | |
---|
2188 | // call the extra function and tack the current return value on the end for possible inspection |
---|
2189 | |
---|
2190 | var ret = extra.apply( elem, data.concat( val ) ); |
---|
2191 | |
---|
2192 | // if anything is returned, give it precedence and have it overwrite the previous value |
---|
2193 | |
---|
2194 | if (ret !== undefined) |
---|
2195 | |
---|
2196 | val = ret; |
---|
2197 | |
---|
2198 | } |
---|
2199 | |
---|
2200 | |
---|
2201 | |
---|
2202 | // Trigger the native events (except for clicks on links) |
---|
2203 | |
---|
2204 | if ( fn && donative !== false && val !== false && !(jQuery.nodeName(elem, 'a') && type == "click") ) { |
---|
2205 | |
---|
2206 | this.triggered = true; |
---|
2207 | |
---|
2208 | try { |
---|
2209 | |
---|
2210 | elem[ type ](); |
---|
2211 | |
---|
2212 | // prevent IE from throwing an error for some hidden elements |
---|
2213 | |
---|
2214 | } catch (e) {} |
---|
2215 | |
---|
2216 | } |
---|
2217 | |
---|
2218 | |
---|
2219 | |
---|
2220 | this.triggered = false; |
---|
2221 | |
---|
2222 | } |
---|
2223 | |
---|
2224 | |
---|
2225 | |
---|
2226 | return val; |
---|
2227 | |
---|
2228 | }, |
---|
2229 | |
---|
2230 | |
---|
2231 | |
---|
2232 | handle: function(event) { |
---|
2233 | |
---|
2234 | // returned undefined or false |
---|
2235 | |
---|
2236 | var val; |
---|
2237 | |
---|
2238 | |
---|
2239 | |
---|
2240 | // Empty object is for triggered events with no data |
---|
2241 | |
---|
2242 | event = jQuery.event.fix( event || window.event || {} ); |
---|
2243 | |
---|
2244 | |
---|
2245 | |
---|
2246 | // Namespaced event handlers |
---|
2247 | |
---|
2248 | var parts = event.type.split("."); |
---|
2249 | |
---|
2250 | event.type = parts[0]; |
---|
2251 | |
---|
2252 | |
---|
2253 | |
---|
2254 | var handlers = jQuery.data(this, "events") && jQuery.data(this, "events")[event.type], args = Array.prototype.slice.call( arguments, 1 ); |
---|
2255 | |
---|
2256 | args.unshift( event ); |
---|
2257 | |
---|
2258 | |
---|
2259 | |
---|
2260 | for ( var j in handlers ) { |
---|
2261 | |
---|
2262 | var handler = handlers[j]; |
---|
2263 | |
---|
2264 | // Pass in a reference to the handler function itself |
---|
2265 | |
---|
2266 | // So that we can later remove it |
---|
2267 | |
---|
2268 | args[0].handler = handler; |
---|
2269 | |
---|
2270 | args[0].data = handler.data; |
---|
2271 | |
---|
2272 | |
---|
2273 | |
---|
2274 | // Filter the functions by class |
---|
2275 | |
---|
2276 | if ( !parts[1] || handler.type == parts[1] ) { |
---|
2277 | |
---|
2278 | var ret = handler.apply( this, args ); |
---|
2279 | |
---|
2280 | |
---|
2281 | |
---|
2282 | if ( val !== false ) |
---|
2283 | |
---|
2284 | val = ret; |
---|
2285 | |
---|
2286 | |
---|
2287 | |
---|
2288 | if ( ret === false ) { |
---|
2289 | |
---|
2290 | event.preventDefault(); |
---|
2291 | |
---|
2292 | event.stopPropagation(); |
---|
2293 | |
---|
2294 | } |
---|
2295 | |
---|
2296 | } |
---|
2297 | |
---|
2298 | } |
---|
2299 | |
---|
2300 | |
---|
2301 | |
---|
2302 | // Clean up added properties in IE to prevent memory leak |
---|
2303 | |
---|
2304 | if (jQuery.browser.msie) |
---|
2305 | |
---|
2306 | event.target = event.preventDefault = event.stopPropagation = |
---|
2307 | |
---|
2308 | event.handler = event.data = null; |
---|
2309 | |
---|
2310 | |
---|
2311 | |
---|
2312 | return val; |
---|
2313 | |
---|
2314 | }, |
---|
2315 | |
---|
2316 | |
---|
2317 | |
---|
2318 | fix: function(event) { |
---|
2319 | |
---|
2320 | // store a copy of the original event object |
---|
2321 | |
---|
2322 | // and clone to set read-only properties |
---|
2323 | |
---|
2324 | var originalEvent = event; |
---|
2325 | |
---|
2326 | event = jQuery.extend({}, originalEvent); |
---|
2327 | |
---|
2328 | |
---|
2329 | |
---|
2330 | // add preventDefault and stopPropagation since |
---|
2331 | |
---|
2332 | // they will not work on the clone |
---|
2333 | |
---|
2334 | event.preventDefault = function() { |
---|
2335 | |
---|
2336 | // if preventDefault exists run it on the original event |
---|
2337 | |
---|
2338 | if (originalEvent.preventDefault) |
---|
2339 | |
---|
2340 | originalEvent.preventDefault(); |
---|
2341 | |
---|
2342 | // otherwise set the returnValue property of the original event to false (IE) |
---|
2343 | |
---|
2344 | originalEvent.returnValue = false; |
---|
2345 | |
---|
2346 | }; |
---|
2347 | |
---|
2348 | event.stopPropagation = function() { |
---|
2349 | |
---|
2350 | // if stopPropagation exists run it on the original event |
---|
2351 | |
---|
2352 | if (originalEvent.stopPropagation) |
---|
2353 | |
---|
2354 | originalEvent.stopPropagation(); |
---|
2355 | |
---|
2356 | // otherwise set the cancelBubble property of the original event to true (IE) |
---|
2357 | |
---|
2358 | originalEvent.cancelBubble = true; |
---|
2359 | |
---|
2360 | }; |
---|
2361 | |
---|
2362 | |
---|
2363 | |
---|
2364 | // Fix target property, if necessary |
---|
2365 | |
---|
2366 | if ( !event.target ) |
---|
2367 | |
---|
2368 | event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either |
---|
2369 | |
---|
2370 | |
---|
2371 | |
---|
2372 | // check if target is a textnode (safari) |
---|
2373 | |
---|
2374 | if ( event.target.nodeType == 3 ) |
---|
2375 | |
---|
2376 | event.target = originalEvent.target.parentNode; |
---|
2377 | |
---|
2378 | |
---|
2379 | |
---|
2380 | // Add relatedTarget, if necessary |
---|
2381 | |
---|
2382 | if ( !event.relatedTarget && event.fromElement ) |
---|
2383 | |
---|
2384 | event.relatedTarget = event.fromElement == event.target ? event.toElement : event.fromElement; |
---|
2385 | |
---|
2386 | |
---|
2387 | |
---|
2388 | // Calculate pageX/Y if missing and clientX/Y available |
---|
2389 | |
---|
2390 | if ( event.pageX == null && event.clientX != null ) { |
---|
2391 | |
---|
2392 | var doc = document.documentElement, body = document.body; |
---|
2393 | |
---|
2394 | event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc.clientLeft || 0); |
---|
2395 | |
---|
2396 | event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc.clientTop || 0); |
---|
2397 | |
---|
2398 | } |
---|
2399 | |
---|
2400 | |
---|
2401 | |
---|
2402 | // Add which for key events |
---|
2403 | |
---|
2404 | if ( !event.which && (event.charCode || event.keyCode) ) |
---|
2405 | |
---|
2406 | event.which = event.charCode || event.keyCode; |
---|
2407 | |
---|
2408 | |
---|
2409 | |
---|
2410 | // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs) |
---|
2411 | |
---|
2412 | if ( !event.metaKey && event.ctrlKey ) |
---|
2413 | |
---|
2414 | event.metaKey = event.ctrlKey; |
---|
2415 | |
---|
2416 | |
---|
2417 | |
---|
2418 | // Add which for click: 1 == left; 2 == middle; 3 == right |
---|
2419 | |
---|
2420 | // Note: button is not normalized, so don't use it |
---|
2421 | |
---|
2422 | if ( !event.which && event.button ) |
---|
2423 | |
---|
2424 | event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) )); |
---|
2425 | |
---|
2426 | |
---|
2427 | |
---|
2428 | return event; |
---|
2429 | |
---|
2430 | }, |
---|
2431 | |
---|
2432 | |
---|
2433 | |
---|
2434 | special: { |
---|
2435 | |
---|
2436 | ready: { |
---|
2437 | |
---|
2438 | setup: function() { |
---|
2439 | |
---|
2440 | // Make sure the ready event is setup |
---|
2441 | |
---|
2442 | bindReady(); |
---|
2443 | |
---|
2444 | return; |
---|
2445 | |
---|
2446 | }, |
---|
2447 | |
---|
2448 | |
---|
2449 | |
---|
2450 | teardown: function() { return; } |
---|
2451 | |
---|
2452 | }, |
---|
2453 | |
---|
2454 | |
---|
2455 | |
---|
2456 | mouseenter: { |
---|
2457 | |
---|
2458 | setup: function() { |
---|
2459 | |
---|
2460 | if ( jQuery.browser.msie ) return false; |
---|
2461 | |
---|
2462 | jQuery(this).bind("mouseover", jQuery.event.special.mouseenter.handler); |
---|
2463 | |
---|
2464 | return true; |
---|
2465 | |
---|
2466 | }, |
---|
2467 | |
---|
2468 | |
---|
2469 | |
---|
2470 | teardown: function() { |
---|
2471 | |
---|
2472 | if ( jQuery.browser.msie ) return false; |
---|
2473 | |
---|
2474 | jQuery(this).unbind("mouseover", jQuery.event.special.mouseenter.handler); |
---|
2475 | |
---|
2476 | return true; |
---|
2477 | |
---|
2478 | }, |
---|
2479 | |
---|
2480 | |
---|
2481 | |
---|
2482 | handler: function(event) { |
---|
2483 | |
---|
2484 | // If we actually just moused on to a sub-element, ignore it |
---|
2485 | |
---|
2486 | if ( withinElement(event, this) ) return true; |
---|
2487 | |
---|
2488 | // Execute the right handlers by setting the event type to mouseenter |
---|
2489 | |
---|
2490 | arguments[0].type = "mouseenter"; |
---|
2491 | |
---|
2492 | return jQuery.event.handle.apply(this, arguments); |
---|
2493 | |
---|
2494 | } |
---|
2495 | |
---|
2496 | }, |
---|
2497 | |
---|
2498 | |
---|
2499 | |
---|
2500 | mouseleave: { |
---|
2501 | |
---|
2502 | setup: function() { |
---|
2503 | |
---|
2504 | if ( jQuery.browser.msie ) return false; |
---|
2505 | |
---|
2506 | jQuery(this).bind("mouseout", jQuery.event.special.mouseleave.handler); |
---|
2507 | |
---|
2508 | return true; |
---|
2509 | |
---|
2510 | }, |
---|
2511 | |
---|
2512 | |
---|
2513 | |
---|
2514 | teardown: function() { |
---|
2515 | |
---|
2516 | if ( jQuery.browser.msie ) return false; |
---|
2517 | |
---|
2518 | jQuery(this).unbind("mouseout", jQuery.event.special.mouseleave.handler); |
---|
2519 | |
---|
2520 | return true; |
---|
2521 | |
---|
2522 | }, |
---|
2523 | |
---|
2524 | |
---|
2525 | |
---|
2526 | handler: function(event) { |
---|
2527 | |
---|
2528 | // If we actually just moused on to a sub-element, ignore it |
---|
2529 | |
---|
2530 | if ( withinElement(event, this) ) return true; |
---|
2531 | |
---|
2532 | // Execute the right handlers by setting the event type to mouseleave |
---|
2533 | |
---|
2534 | arguments[0].type = "mouseleave"; |
---|
2535 | |
---|
2536 | return jQuery.event.handle.apply(this, arguments); |
---|
2537 | |
---|
2538 | } |
---|
2539 | |
---|
2540 | } |
---|
2541 | |
---|
2542 | } |
---|
2543 | |
---|
2544 | }; |
---|
2545 | |
---|
2546 | |
---|
2547 | |
---|
2548 | jQuery.fn.extend({ |
---|
2549 | |
---|
2550 | bind: function( type, data, fn ) { |
---|
2551 | |
---|
2552 | return type == "unload" ? this.one(type, data, fn) : this.each(function(){ |
---|
2553 | |
---|
2554 | jQuery.event.add( this, type, fn || data, fn && data ); |
---|
2555 | |
---|
2556 | }); |
---|
2557 | |
---|
2558 | }, |
---|
2559 | |
---|
2560 | |
---|
2561 | |
---|
2562 | one: function( type, data, fn ) { |
---|
2563 | |
---|
2564 | return this.each(function(){ |
---|
2565 | |
---|
2566 | jQuery.event.add( this, type, function(event) { |
---|
2567 | |
---|
2568 | jQuery(this).unbind(event); |
---|
2569 | |
---|
2570 | return (fn || data).apply( this, arguments); |
---|
2571 | |
---|
2572 | }, fn && data); |
---|
2573 | |
---|
2574 | }); |
---|
2575 | |
---|
2576 | }, |
---|
2577 | |
---|
2578 | |
---|
2579 | |
---|
2580 | unbind: function( type, fn ) { |
---|
2581 | |
---|
2582 | return this.each(function(){ |
---|
2583 | |
---|
2584 | jQuery.event.remove( this, type, fn ); |
---|
2585 | |
---|
2586 | }); |
---|
2587 | |
---|
2588 | }, |
---|
2589 | |
---|
2590 | |
---|
2591 | |
---|
2592 | trigger: function( type, data, fn ) { |
---|
2593 | |
---|
2594 | return this.each(function(){ |
---|
2595 | |
---|
2596 | jQuery.event.trigger( type, data, this, true, fn ); |
---|
2597 | |
---|
2598 | }); |
---|
2599 | |
---|
2600 | }, |
---|
2601 | |
---|
2602 | |
---|
2603 | |
---|
2604 | triggerHandler: function( type, data, fn ) { |
---|
2605 | |
---|
2606 | if ( this[0] ) |
---|
2607 | |
---|
2608 | return jQuery.event.trigger( type, data, this[0], false, fn ); |
---|
2609 | |
---|
2610 | return undefined; |
---|
2611 | |
---|
2612 | }, |
---|
2613 | |
---|
2614 | |
---|
2615 | |
---|
2616 | toggle: function() { |
---|
2617 | |
---|
2618 | // Save reference to arguments for access in closure |
---|
2619 | |
---|
2620 | var args = arguments; |
---|
2621 | |
---|
2622 | |
---|
2623 | |
---|
2624 | return this.click(function(event) { |
---|
2625 | |
---|
2626 | // Figure out which function to execute |
---|
2627 | |
---|
2628 | this.lastToggle = 0 == this.lastToggle ? 1 : 0; |
---|
2629 | |
---|
2630 | |
---|
2631 | |
---|
2632 | // Make sure that clicks stop |
---|
2633 | |
---|
2634 | event.preventDefault(); |
---|
2635 | |
---|
2636 | |
---|
2637 | |
---|
2638 | // and execute the function |
---|
2639 | |
---|
2640 | return args[this.lastToggle].apply( this, arguments ) || false; |
---|
2641 | |
---|
2642 | }); |
---|
2643 | |
---|
2644 | }, |
---|
2645 | |
---|
2646 | |
---|
2647 | |
---|
2648 | hover: function(fnOver, fnOut) { |
---|
2649 | |
---|
2650 | return this.bind('mouseenter', fnOver).bind('mouseleave', fnOut); |
---|
2651 | |
---|
2652 | }, |
---|
2653 | |
---|
2654 | |
---|
2655 | |
---|
2656 | ready: function(fn) { |
---|
2657 | |
---|
2658 | // Attach the listeners |
---|
2659 | |
---|
2660 | bindReady(); |
---|
2661 | |
---|
2662 | |
---|
2663 | |
---|
2664 | // If the DOM is already ready |
---|
2665 | |
---|
2666 | if ( jQuery.isReady ) |
---|
2667 | |
---|
2668 | // Execute the function immediately |
---|
2669 | |
---|
2670 | fn.call( document, jQuery ); |
---|
2671 | |
---|
2672 | |
---|
2673 | |
---|
2674 | // Otherwise, remember the function for later |
---|
2675 | |
---|
2676 | else |
---|
2677 | |
---|
2678 | // Add the function to the wait list |
---|
2679 | |
---|
2680 | jQuery.readyList.push( function() { return fn.call(this, jQuery); } ); |
---|
2681 | |
---|
2682 | |
---|
2683 | |
---|
2684 | return this; |
---|
2685 | |
---|
2686 | } |
---|
2687 | |
---|
2688 | }); |
---|
2689 | |
---|
2690 | |
---|
2691 | |
---|
2692 | jQuery.extend({ |
---|
2693 | |
---|
2694 | isReady: false, |
---|
2695 | |
---|
2696 | readyList: [], |
---|
2697 | |
---|
2698 | // Handle when the DOM is ready |
---|
2699 | |
---|
2700 | ready: function() { |
---|
2701 | |
---|
2702 | // Make sure that the DOM is not already loaded |
---|
2703 | |
---|
2704 | if ( !jQuery.isReady ) { |
---|
2705 | |
---|
2706 | // Remember that the DOM is ready |
---|
2707 | |
---|
2708 | jQuery.isReady = true; |
---|
2709 | |
---|
2710 | |
---|
2711 | |
---|
2712 | // If there are functions bound, to execute |
---|
2713 | |
---|
2714 | if ( jQuery.readyList ) { |
---|
2715 | |
---|
2716 | // Execute all of them |
---|
2717 | |
---|
2718 | jQuery.each( jQuery.readyList, function(){ |
---|
2719 | |
---|
2720 | this.apply( document ); |
---|
2721 | |
---|
2722 | }); |
---|
2723 | |
---|
2724 | |
---|
2725 | |
---|
2726 | // Reset the list of functions |
---|
2727 | |
---|
2728 | jQuery.readyList = null; |
---|
2729 | |
---|
2730 | } |
---|
2731 | |
---|
2732 | |
---|
2733 | |
---|
2734 | // Trigger any bound ready events |
---|
2735 | |
---|
2736 | jQuery(document).triggerHandler("ready"); |
---|
2737 | |
---|
2738 | } |
---|
2739 | |
---|
2740 | } |
---|
2741 | |
---|
2742 | }); |
---|
2743 | |
---|
2744 | |
---|
2745 | |
---|
2746 | var readyBound = false; |
---|
2747 | |
---|
2748 | |
---|
2749 | |
---|
2750 | function bindReady(){ |
---|
2751 | |
---|
2752 | if ( readyBound ) return; |
---|
2753 | |
---|
2754 | readyBound = true; |
---|
2755 | |
---|
2756 | |
---|
2757 | |
---|
2758 | // Mozilla, Opera and webkit nightlies currently support this event |
---|
2759 | |
---|
2760 | if ( document.addEventListener ) |
---|
2761 | |
---|
2762 | // Use the handy event callback |
---|
2763 | |
---|
2764 | document.addEventListener( "DOMContentLoaded", jQuery.ready, false ); |
---|
2765 | |
---|
2766 | |
---|
2767 | |
---|
2768 | // If Safari or IE is used |
---|
2769 | |
---|
2770 | // Continually check to see if the document is ready |
---|
2771 | |
---|
2772 | if (jQuery.browser.msie || jQuery.browser.safari ) (function(){ |
---|
2773 | |
---|
2774 | try { |
---|
2775 | |
---|
2776 | // If IE is used, use the trick by Diego Perini |
---|
2777 | |
---|
2778 | // http://javascript.nwbox.com/IEContentLoaded/ |
---|
2779 | |
---|
2780 | if ( jQuery.browser.msie || document.readyState != "loaded" && document.readyState != "complete" ) |
---|
2781 | |
---|
2782 | document.documentElement.doScroll("left"); |
---|
2783 | |
---|
2784 | } catch( error ) { |
---|
2785 | |
---|
2786 | return setTimeout( arguments.callee, 0 ); |
---|
2787 | |
---|
2788 | } |
---|
2789 | |
---|
2790 | |
---|
2791 | |
---|
2792 | // and execute any waiting functions |
---|
2793 | |
---|
2794 | jQuery.ready(); |
---|
2795 | |
---|
2796 | })(); |
---|
2797 | |
---|
2798 | |
---|
2799 | |
---|
2800 | // A fallback to window.onload, that will always work |
---|
2801 | |
---|
2802 | jQuery.event.add( window, "load", jQuery.ready ); |
---|
2803 | |
---|
2804 | } |
---|
2805 | |
---|
2806 | |
---|
2807 | |
---|
2808 | jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," + |
---|
2809 | |
---|
2810 | "mousedown,mouseup,mousemove,mouseover,mouseout,change,select," + |
---|
2811 | |
---|
2812 | "submit,keydown,keypress,keyup,error").split(","), function(i, name){ |
---|
2813 | |
---|
2814 | |
---|
2815 | |
---|
2816 | // Handle event binding |
---|
2817 | |
---|
2818 | jQuery.fn[name] = function(fn){ |
---|
2819 | |
---|
2820 | return fn ? this.bind(name, fn) : this.trigger(name); |
---|
2821 | |
---|
2822 | }; |
---|
2823 | |
---|
2824 | }); |
---|
2825 | |
---|
2826 | |
---|
2827 | |
---|
2828 | // Checks if an event happened on an element within another element |
---|
2829 | |
---|
2830 | // Used in jQuery.event.special.mouseenter and mouseleave handlers |
---|
2831 | |
---|
2832 | var withinElement = function(event, elem) { |
---|
2833 | |
---|
2834 | // Check if mouse(over|out) are still within the same parent element |
---|
2835 | |
---|
2836 | var parent = event.relatedTarget; |
---|
2837 | |
---|
2838 | // Traverse up the tree |
---|
2839 | |
---|
2840 | while ( parent && parent != elem ) try { parent = parent.parentNode } catch(error) { parent = elem; }; |
---|
2841 | |
---|
2842 | // Return true if we actually just moused on to a sub-element |
---|
2843 | |
---|
2844 | return parent == elem; |
---|
2845 | |
---|
2846 | }; |
---|
2847 | |
---|
2848 | |
---|
2849 | |
---|
2850 | // Prevent memory leaks in IE |
---|
2851 | |
---|
2852 | // And prevent errors on refresh with events like mouseover in other browsers |
---|
2853 | |
---|
2854 | // Window isn't included so as not to unbind existing unload events |
---|
2855 | |
---|
2856 | jQuery(window).bind("unload", function() { |
---|
2857 | |
---|
2858 | jQuery("*").add(document).unbind(); |
---|
2859 | |
---|
2860 | }); |
---|
2861 | |
---|
2862 | jQuery.fn.extend({ |
---|
2863 | load: function( url, params, callback ) { |
---|
2864 | if ( jQuery.isFunction( url ) ) |
---|
2865 | return this.bind("load", url); |
---|
2866 | |
---|
2867 | var off = url.indexOf(" "); |
---|
2868 | if ( off >= 0 ) { |
---|
2869 | var selector = url.slice(off, url.length); |
---|
2870 | url = url.slice(0, off); |
---|
2871 | } |
---|
2872 | |
---|
2873 | callback = callback || function(){}; |
---|
2874 | |
---|
2875 | // Default to a GET request |
---|
2876 | var type = "GET"; |
---|
2877 | |
---|
2878 | // If the second parameter was provided |
---|
2879 | if ( params ) |
---|
2880 | // If it's a function |
---|
2881 | if ( jQuery.isFunction( params ) ) { |
---|
2882 | // We assume that it's the callback |
---|
2883 | callback = params; |
---|
2884 | params = null; |
---|
2885 | |
---|
2886 | // Otherwise, build a param string |
---|
2887 | } else { |
---|
2888 | params = jQuery.param( params ); |
---|
2889 | type = "POST"; |
---|
2890 | } |
---|
2891 | |
---|
2892 | var self = this; |
---|
2893 | |
---|
2894 | // Request the remote document |
---|
2895 | jQuery.ajax({ |
---|
2896 | url: url, |
---|
2897 | type: type, |
---|
2898 | dataType: "html", |
---|
2899 | data: params, |
---|
2900 | complete: function(res, status){ |
---|
2901 | // If successful, inject the HTML into all the matched elements |
---|
2902 | if ( status == "success" || status == "notmodified" ) |
---|
2903 | // See if a selector was specified |
---|
2904 | self.html( selector ? |
---|
2905 | // Create a dummy div to hold the results |
---|
2906 | jQuery("<div/>") |
---|
2907 | // inject the contents of the document in, removing the scripts |
---|
2908 | // to avoid any 'Permission Denied' errors in IE |
---|
2909 | .append(res.responseText.replace(/<script(.|\s)*?\/script>/g, "")) |
---|
2910 | |
---|
2911 | // Locate the specified elements |
---|
2912 | .find(selector) : |
---|
2913 | |
---|
2914 | // If not, just inject the full result |
---|
2915 | res.responseText ); |
---|
2916 | |
---|
2917 | self.each( callback, [res.responseText, status, res] ); |
---|
2918 | } |
---|
2919 | }); |
---|
2920 | return this; |
---|
2921 | }, |
---|
2922 | |
---|
2923 | serialize: function() { |
---|
2924 | return jQuery.param(this.serializeArray()); |
---|
2925 | }, |
---|
2926 | serializeArray: function() { |
---|
2927 | return this.map(function(){ |
---|
2928 | return jQuery.nodeName(this, "form") ? |
---|
2929 | jQuery.makeArray(this.elements) : this; |
---|
2930 | }) |
---|
2931 | .filter(function(){ |
---|
2932 | return this.name && !this.disabled && |
---|
2933 | (this.checked || /select|textarea/i.test(this.nodeName) || |
---|
2934 | /text|hidden|password/i.test(this.type)); |
---|
2935 | }) |
---|
2936 | .map(function(i, elem){ |
---|
2937 | var val = jQuery(this).val(); |
---|
2938 | return val == null ? null : |
---|
2939 | val.constructor == Array ? |
---|
2940 | jQuery.map( val, function(val, i){ |
---|
2941 | return {name: elem.name, value: val}; |
---|
2942 | }) : |
---|
2943 | {name: elem.name, value: val}; |
---|
2944 | }).get(); |
---|
2945 | } |
---|
2946 | }); |
---|
2947 | |
---|
2948 | // Attach a bunch of functions for handling common AJAX events |
---|
2949 | jQuery.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","), function(i,o){ |
---|
2950 | jQuery.fn[o] = function(f){ |
---|
2951 | return this.bind(o, f); |
---|
2952 | }; |
---|
2953 | }); |
---|
2954 | |
---|
2955 | var jsc = (new Date).getTime(); |
---|
2956 | |
---|
2957 | jQuery.extend({ |
---|
2958 | get: function( url, data, callback, type ) { |
---|
2959 | // shift arguments if data argument was ommited |
---|
2960 | if ( jQuery.isFunction( data ) ) { |
---|
2961 | callback = data; |
---|
2962 | data = null; |
---|
2963 | } |
---|
2964 | |
---|
2965 | return jQuery.ajax({ |
---|
2966 | type: "GET", |
---|
2967 | url: url, |
---|
2968 | data: data, |
---|
2969 | success: callback, |
---|
2970 | dataType: type |
---|
2971 | }); |
---|
2972 | }, |
---|
2973 | |
---|
2974 | getScript: function( url, callback ) { |
---|
2975 | return jQuery.get(url, null, callback, "script"); |
---|
2976 | }, |
---|
2977 | |
---|
2978 | getJSON: function( url, data, callback ) { |
---|
2979 | return jQuery.get(url, data, callback, "json"); |
---|
2980 | }, |
---|
2981 | |
---|
2982 | post: function( url, data, callback, type ) { |
---|
2983 | if ( jQuery.isFunction( data ) ) { |
---|
2984 | callback = data; |
---|
2985 | data = {}; |
---|
2986 | } |
---|
2987 | |
---|
2988 | return jQuery.ajax({ |
---|
2989 | type: "POST", |
---|
2990 | url: url, |
---|
2991 | data: data, |
---|
2992 | success: callback, |
---|
2993 | dataType: type |
---|
2994 | }); |
---|
2995 | }, |
---|
2996 | |
---|
2997 | ajaxSetup: function( settings ) { |
---|
2998 | jQuery.extend( jQuery.ajaxSettings, settings ); |
---|
2999 | }, |
---|
3000 | |
---|
3001 | ajaxSettings: { |
---|
3002 | global: true, |
---|
3003 | type: "GET", |
---|
3004 | timeout: 0, |
---|
3005 | contentType: "application/x-www-form-urlencoded", |
---|
3006 | processData: true, |
---|
3007 | async: true, |
---|
3008 | data: null |
---|
3009 | }, |
---|
3010 | |
---|
3011 | // Last-Modified header cache for next request |
---|
3012 | lastModified: {}, |
---|
3013 | |
---|
3014 | ajax: function( s ) { |
---|
3015 | var jsonp, jsre = /=\?(&|$)/g, status, data; |
---|
3016 | |
---|
3017 | // Extend the settings, but re-extend 's' so that it can be |
---|
3018 | // checked again later (in the test suite, specifically) |
---|
3019 | s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s)); |
---|
3020 | |
---|
3021 | // convert data if not already a string |
---|
3022 | if ( s.data && s.processData && typeof s.data != "string" ) |
---|
3023 | s.data = jQuery.param(s.data); |
---|
3024 | |
---|
3025 | // Handle JSONP Parameter Callbacks |
---|
3026 | if ( s.dataType == "jsonp" ) { |
---|
3027 | if ( s.type.toLowerCase() == "get" ) { |
---|
3028 | if ( !s.url.match(jsre) ) |
---|
3029 | s.url += (s.url.match(/\?/) ? "&" : "?") + (s.jsonp || "callback") + "=?"; |
---|
3030 | } else if ( !s.data || !s.data.match(jsre) ) |
---|
3031 | s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?"; |
---|
3032 | s.dataType = "json"; |
---|
3033 | } |
---|
3034 | |
---|
3035 | // Build temporary JSONP function |
---|
3036 | if ( s.dataType == "json" && (s.data && s.data.match(jsre) || s.url.match(jsre)) ) { |
---|
3037 | jsonp = "jsonp" + jsc++; |
---|
3038 | |
---|
3039 | // Replace the =? sequence both in the query string and the data |
---|
3040 | if ( s.data ) |
---|
3041 | s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1"); |
---|
3042 | s.url = s.url.replace(jsre, "=" + jsonp + "$1"); |
---|
3043 | |
---|
3044 | // We need to make sure |
---|
3045 | // that a JSONP style response is executed properly |
---|
3046 | s.dataType = "script"; |
---|
3047 | |
---|
3048 | // Handle JSONP-style loading |
---|
3049 | window[ jsonp ] = function(tmp){ |
---|
3050 | data = tmp; |
---|
3051 | success(); |
---|
3052 | complete(); |
---|
3053 | // Garbage collect |
---|
3054 | window[ jsonp ] = undefined; |
---|
3055 | try{ delete window[ jsonp ]; } catch(e){} |
---|
3056 | if ( head ) |
---|
3057 | head.removeChild( script ); |
---|
3058 | }; |
---|
3059 | } |
---|
3060 | |
---|
3061 | if ( s.dataType == "script" && s.cache == null ) |
---|
3062 | s.cache = false; |
---|
3063 | |
---|
3064 | if ( s.cache === false && s.type.toLowerCase() == "get" ) { |
---|
3065 | var ts = (new Date()).getTime(); |
---|
3066 | // try replacing _= if it is there |
---|
3067 | var ret = s.url.replace(/(\?|&)_=.*?(&|$)/, "$1_=" + ts + "$2"); |
---|
3068 | // if nothing was replaced, add timestamp to the end |
---|
3069 | s.url = ret + ((ret == s.url) ? (s.url.match(/\?/) ? "&" : "?") + "_=" + ts : ""); |
---|
3070 | } |
---|
3071 | |
---|
3072 | // If data is available, append data to url for get requests |
---|
3073 | if ( s.data && s.type.toLowerCase() == "get" ) { |
---|
3074 | s.url += (s.url.match(/\?/) ? "&" : "?") + s.data; |
---|
3075 | |
---|
3076 | // IE likes to send both get and post data, prevent this |
---|
3077 | s.data = null; |
---|
3078 | } |
---|
3079 | |
---|
3080 | // Watch for a new set of requests |
---|
3081 | if ( s.global && ! jQuery.active++ ) |
---|
3082 | jQuery.event.trigger( "ajaxStart" ); |
---|
3083 | |
---|
3084 | // If we're requesting a remote document |
---|
3085 | // and trying to load JSON or Script with a GET |
---|
3086 | if ( (!s.url.indexOf("http") || !s.url.indexOf("//")) && ( s.dataType == "script" || s.dataType =="json" ) && s.type.toLowerCase() == "get" ) { |
---|
3087 | var head = document.getElementsByTagName("head")[0]; |
---|
3088 | var script = document.createElement("script"); |
---|
3089 | script.src = s.url; |
---|
3090 | if (s.scriptCharset) |
---|
3091 | script.charset = s.scriptCharset; |
---|
3092 | |
---|
3093 | // Handle Script loading |
---|
3094 | if ( !jsonp ) { |
---|
3095 | var done = false; |
---|
3096 | |
---|
3097 | // Attach handlers for all browsers |
---|
3098 | script.onload = script.onreadystatechange = function(){ |
---|
3099 | if ( !done && (!this.readyState || |
---|
3100 | this.readyState == "loaded" || this.readyState == "complete") ) { |
---|
3101 | done = true; |
---|
3102 | success(); |
---|
3103 | complete(); |
---|
3104 | head.removeChild( script ); |
---|
3105 | } |
---|
3106 | }; |
---|
3107 | } |
---|
3108 | |
---|
3109 | head.appendChild(script); |
---|
3110 | |
---|
3111 | // We handle everything using the script element injection |
---|
3112 | return undefined; |
---|
3113 | } |
---|
3114 | |
---|
3115 | var requestDone = false; |
---|
3116 | |
---|
3117 | // Create the request object; Microsoft failed to properly |
---|
3118 | // implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available |
---|
3119 | var xml = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); |
---|
3120 | |
---|
3121 | // Open the socket |
---|
3122 | xml.open(s.type, s.url, s.async); |
---|
3123 | |
---|
3124 | // Need an extra try/catch for cross domain requests in Firefox 3 |
---|
3125 | try { |
---|
3126 | // Set the correct header, if data is being sent |
---|
3127 | if ( s.data ) |
---|
3128 | xml.setRequestHeader("Content-Type", s.contentType); |
---|
3129 | |
---|
3130 | // Set the If-Modified-Since header, if ifModified mode. |
---|
3131 | if ( s.ifModified ) |
---|
3132 | xml.setRequestHeader("If-Modified-Since", |
---|
3133 | jQuery.lastModified[s.url] || "Thu, 01 Jan 1970 00:00:00 GMT" ); |
---|
3134 | |
---|
3135 | // Set header so the called script knows that it's an XMLHttpRequest |
---|
3136 | xml.setRequestHeader("X-Requested-With", "XMLHttpRequest"); |
---|
3137 | } catch(e){} |
---|
3138 | |
---|
3139 | // Allow custom headers/mimetypes |
---|
3140 | if ( s.beforeSend ) |
---|
3141 | s.beforeSend(xml); |
---|
3142 | |
---|
3143 | if ( s.global ) |
---|
3144 | jQuery.event.trigger("ajaxSend", [xml, s]); |
---|
3145 | |
---|
3146 | // Wait for a response to come back |
---|
3147 | var onreadystatechange = function(isTimeout){ |
---|
3148 | // The transfer is complete and the data is available, or the request timed out |
---|
3149 | if ( !requestDone && xml && (xml.readyState == 4 || isTimeout == "timeout") ) { |
---|
3150 | requestDone = true; |
---|
3151 | |
---|
3152 | // clear poll interval |
---|
3153 | if (ival) { |
---|
3154 | clearInterval(ival); |
---|
3155 | ival = null; |
---|
3156 | } |
---|
3157 | |
---|
3158 | status = isTimeout == "timeout" && "timeout" || |
---|
3159 | !jQuery.httpSuccess( xml ) && "error" || |
---|
3160 | s.ifModified && jQuery.httpNotModified( xml, s.url ) && "notmodified" || |
---|
3161 | "success"; |
---|
3162 | |
---|
3163 | if ( status == "success" ) { |
---|
3164 | // Watch for, and catch, XML document parse errors |
---|
3165 | try { |
---|
3166 | // process the data (runs the xml through httpData regardless of callback) |
---|
3167 | data = jQuery.httpData( xml, s.dataType ); |
---|
3168 | } catch(e) { |
---|
3169 | status = "parsererror"; |
---|
3170 | } |
---|
3171 | } |
---|
3172 | |
---|
3173 | // Make sure that the request was successful or notmodified |
---|
3174 | if ( status == "success" ) { |
---|
3175 | // Cache Last-Modified header, if ifModified mode. |
---|
3176 | var modRes; |
---|
3177 | try { |
---|
3178 | modRes = xml.getResponseHeader("Last-Modified"); |
---|
3179 | } catch(e) {} // swallow exception thrown by FF if header is not available |
---|
3180 | |
---|
3181 | if ( s.ifModified && modRes ) |
---|
3182 | jQuery.lastModified[s.url] = modRes; |
---|
3183 | |
---|
3184 | // JSONP handles its own success callback |
---|
3185 | if ( !jsonp ) |
---|
3186 | success(); |
---|
3187 | } else |
---|
3188 | jQuery.handleError(s, xml, status); |
---|
3189 | |
---|
3190 | // Fire the complete handlers |
---|
3191 | complete(); |
---|
3192 | |
---|
3193 | // Stop memory leaks |
---|
3194 | if ( s.async ) |
---|
3195 | xml = null; |
---|
3196 | } |
---|
3197 | }; |
---|
3198 | |
---|
3199 | if ( s.async ) { |
---|
3200 | // don't attach the handler to the request, just poll it instead |
---|
3201 | var ival = setInterval(onreadystatechange, 13); |
---|
3202 | |
---|
3203 | // Timeout checker |
---|
3204 | if ( s.timeout > 0 ) |
---|
3205 | setTimeout(function(){ |
---|
3206 | // Check to see if the request is still happening |
---|
3207 | if ( xml ) { |
---|
3208 | // Cancel the request |
---|
3209 | xml.abort(); |
---|
3210 | |
---|
3211 | if( !requestDone ) |
---|
3212 | onreadystatechange( "timeout" ); |
---|
3213 | } |
---|
3214 | }, s.timeout); |
---|
3215 | } |
---|
3216 | |
---|
3217 | // Send the data |
---|
3218 | try { |
---|
3219 | xml.send(s.data); |
---|
3220 | } catch(e) { |
---|
3221 | jQuery.handleError(s, xml, null, e); |
---|
3222 | } |
---|
3223 | |
---|
3224 | // firefox 1.5 doesn't fire statechange for sync requests |
---|
3225 | if ( !s.async ) |
---|
3226 | onreadystatechange(); |
---|
3227 | |
---|
3228 | function success(){ |
---|
3229 | // If a local callback was specified, fire it and pass it the data |
---|
3230 | if ( s.success ) |
---|
3231 | s.success( data, status ); |
---|
3232 | |
---|
3233 | // Fire the global callback |
---|
3234 | if ( s.global ) |
---|
3235 | jQuery.event.trigger( "ajaxSuccess", [xml, s] ); |
---|
3236 | } |
---|
3237 | |
---|
3238 | function complete(){ |
---|
3239 | // Process result |
---|
3240 | if ( s.complete ) |
---|
3241 | s.complete(xml, status); |
---|
3242 | |
---|
3243 | // The request was completed |
---|
3244 | if ( s.global ) |
---|
3245 | jQuery.event.trigger( "ajaxComplete", [xml, s] ); |
---|
3246 | |
---|
3247 | // Handle the global AJAX counter |
---|
3248 | if ( s.global && ! --jQuery.active ) |
---|
3249 | jQuery.event.trigger( "ajaxStop" ); |
---|
3250 | } |
---|
3251 | |
---|
3252 | // return XMLHttpRequest to allow aborting the request etc. |
---|
3253 | return xml; |
---|
3254 | }, |
---|
3255 | |
---|
3256 | handleError: function( s, xml, status, e ) { |
---|
3257 | // If a local callback was specified, fire it |
---|
3258 | if ( s.error ) s.error( xml, status, e ); |
---|
3259 | |
---|
3260 | // Fire the global callback |
---|
3261 | if ( s.global ) |
---|
3262 | jQuery.event.trigger( "ajaxError", [xml, s, e] ); |
---|
3263 | }, |
---|
3264 | |
---|
3265 | // Counter for holding the number of active queries |
---|
3266 | active: 0, |
---|
3267 | |
---|
3268 | // Determines if an XMLHttpRequest was successful or not |
---|
3269 | httpSuccess: function( r ) { |
---|
3270 | try { |
---|
3271 | // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450 |
---|
3272 | return !r.status && location.protocol == "file:" || |
---|
3273 | ( r.status >= 200 && r.status < 300 ) || r.status == 304 || r.status == 1223 || |
---|
3274 | jQuery.browser.safari && r.status == undefined; |
---|
3275 | } catch(e){} |
---|
3276 | return false; |
---|
3277 | }, |
---|
3278 | |
---|
3279 | // Determines if an XMLHttpRequest returns NotModified |
---|
3280 | httpNotModified: function( xml, url ) { |
---|
3281 | try { |
---|
3282 | var xmlRes = xml.getResponseHeader("Last-Modified"); |
---|
3283 | |
---|
3284 | // Firefox always returns 200. check Last-Modified date |
---|
3285 | return xml.status == 304 || xmlRes == jQuery.lastModified[url] || |
---|
3286 | jQuery.browser.safari && xml.status == undefined; |
---|
3287 | } catch(e){} |
---|
3288 | return false; |
---|
3289 | }, |
---|
3290 | |
---|
3291 | httpData: function( r, type ) { |
---|
3292 | var ct = r.getResponseHeader("content-type"); |
---|
3293 | var xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0; |
---|
3294 | var data = xml ? r.responseXML : r.responseText; |
---|
3295 | |
---|
3296 | if ( xml && data.documentElement.tagName == "parsererror" ) |
---|
3297 | throw "parsererror"; |
---|
3298 | |
---|
3299 | // If the type is "script", eval it in global context |
---|
3300 | if ( type == "script" ) |
---|
3301 | jQuery.globalEval( data ); |
---|
3302 | |
---|
3303 | // Get the JavaScript object, if JSON is used. |
---|
3304 | if ( type == "json" ) |
---|
3305 | data = eval("(" + data + ")"); |
---|
3306 | |
---|
3307 | return data; |
---|
3308 | }, |
---|
3309 | |
---|
3310 | // Serialize an array of form elements or a set of |
---|
3311 | // key/values into a query string |
---|
3312 | param: function( a ) { |
---|
3313 | var s = []; |
---|
3314 | |
---|
3315 | // If an array was passed in, assume that it is an array |
---|
3316 | // of form elements |
---|
3317 | if ( a.constructor == Array || a.jquery ) |
---|
3318 | // Serialize the form elements |
---|
3319 | jQuery.each( a, function(){ |
---|
3320 | s.push( encodeURIComponent(this.name) + "=" + encodeURIComponent( this.value ) ); |
---|
3321 | }); |
---|
3322 | |
---|
3323 | // Otherwise, assume that it's an object of key/value pairs |
---|
3324 | else |
---|
3325 | // Serialize the key/values |
---|
3326 | for ( var j in a ) |
---|
3327 | // If the value is an array then the key names need to be repeated |
---|
3328 | if ( a[j] && a[j].constructor == Array ) |
---|
3329 | jQuery.each( a[j], function(){ |
---|
3330 | s.push( encodeURIComponent(j) + "=" + encodeURIComponent( this ) ); |
---|
3331 | }); |
---|
3332 | else |
---|
3333 | s.push( encodeURIComponent(j) + "=" + encodeURIComponent( a[j] ) ); |
---|
3334 | |
---|
3335 | // Return the resulting serialization |
---|
3336 | return s.join("&").replace(/%20/g, "+"); |
---|
3337 | } |
---|
3338 | |
---|
3339 | }); |
---|
3340 | jQuery.fn.extend({ |
---|
3341 | show: function(speed,callback){ |
---|
3342 | return speed ? |
---|
3343 | this.animate({ |
---|
3344 | height: "show", width: "show", opacity: "show" |
---|
3345 | }, speed, callback) : |
---|
3346 | |
---|
3347 | this.filter(":hidden").each(function(){ |
---|
3348 | this.style.display = this.oldblock || ""; |
---|
3349 | if ( jQuery.css(this,"display") == "none" ) { |
---|
3350 | var elem = jQuery("<" + this.tagName + " />").appendTo("body"); |
---|
3351 | this.style.display = elem.css("display"); |
---|
3352 | elem.remove(); |
---|
3353 | } |
---|
3354 | }).end(); |
---|
3355 | }, |
---|
3356 | |
---|
3357 | hide: function(speed,callback){ |
---|
3358 | return speed ? |
---|
3359 | this.animate({ |
---|
3360 | height: "hide", width: "hide", opacity: "hide" |
---|
3361 | }, speed, callback) : |
---|
3362 | |
---|
3363 | this.filter(":visible").each(function(){ |
---|
3364 | this.oldblock = this.oldblock || jQuery.css(this,"display"); |
---|
3365 | this.style.display = "none"; |
---|
3366 | }).end(); |
---|
3367 | }, |
---|
3368 | |
---|
3369 | // Save the old toggle function |
---|
3370 | _toggle: jQuery.fn.toggle, |
---|
3371 | |
---|
3372 | toggle: function( fn, fn2 ){ |
---|
3373 | return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ? |
---|
3374 | this._toggle( fn, fn2 ) : |
---|
3375 | fn ? |
---|
3376 | this.animate({ |
---|
3377 | height: "toggle", width: "toggle", opacity: "toggle" |
---|
3378 | }, fn, fn2) : |
---|
3379 | this.each(function(){ |
---|
3380 | jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ](); |
---|
3381 | }); |
---|
3382 | }, |
---|
3383 | |
---|
3384 | slideDown: function(speed,callback){ |
---|
3385 | return this.animate({height: "show"}, speed, callback); |
---|
3386 | }, |
---|
3387 | |
---|
3388 | slideUp: function(speed,callback){ |
---|
3389 | return this.animate({height: "hide"}, speed, callback); |
---|
3390 | }, |
---|
3391 | |
---|
3392 | slideToggle: function(speed, callback){ |
---|
3393 | return this.animate({height: "toggle"}, speed, callback); |
---|
3394 | }, |
---|
3395 | |
---|
3396 | fadeIn: function(speed, callback){ |
---|
3397 | return this.animate({opacity: "show"}, speed, callback); |
---|
3398 | }, |
---|
3399 | |
---|
3400 | fadeOut: function(speed, callback){ |
---|
3401 | return this.animate({opacity: "hide"}, speed, callback); |
---|
3402 | }, |
---|
3403 | |
---|
3404 | fadeTo: function(speed,to,callback){ |
---|
3405 | return this.animate({opacity: to}, speed, callback); |
---|
3406 | }, |
---|
3407 | |
---|
3408 | animate: function( prop, speed, easing, callback ) { |
---|
3409 | var optall = jQuery.speed(speed, easing, callback); |
---|
3410 | |
---|
3411 | return this[ optall.queue === false ? "each" : "queue" ](function(){ |
---|
3412 | if ( this.nodeType != 1) |
---|
3413 | return false; |
---|
3414 | |
---|
3415 | var opt = jQuery.extend({}, optall); |
---|
3416 | var hidden = jQuery(this).is(":hidden"), self = this; |
---|
3417 | |
---|
3418 | for ( var p in prop ) { |
---|
3419 | if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden ) |
---|
3420 | return jQuery.isFunction(opt.complete) && opt.complete.apply(this); |
---|
3421 | |
---|
3422 | if ( p == "height" || p == "width" ) { |
---|
3423 | // Store display property |
---|
3424 | opt.display = jQuery.css(this, "display"); |
---|
3425 | |
---|
3426 | // Make sure that nothing sneaks out |
---|
3427 | opt.overflow = this.style.overflow; |
---|
3428 | } |
---|
3429 | } |
---|
3430 | |
---|
3431 | if ( opt.overflow != null ) |
---|
3432 | this.style.overflow = "hidden"; |
---|
3433 | |
---|
3434 | opt.curAnim = jQuery.extend({}, prop); |
---|
3435 | |
---|
3436 | jQuery.each( prop, function(name, val){ |
---|
3437 | var e = new jQuery.fx( self, opt, name ); |
---|
3438 | |
---|
3439 | if ( /toggle|show|hide/.test(val) ) |
---|
3440 | e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop ); |
---|
3441 | else { |
---|
3442 | var parts = val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/), |
---|
3443 | start = e.cur(true) || 0; |
---|
3444 | |
---|
3445 | if ( parts ) { |
---|
3446 | var end = parseFloat(parts[2]), |
---|
3447 | unit = parts[3] || "px"; |
---|
3448 | |
---|
3449 | // We need to compute starting value |
---|
3450 | if ( unit != "px" ) { |
---|
3451 | self.style[ name ] = (end || 1) + unit; |
---|
3452 | start = ((end || 1) / e.cur(true)) * start; |
---|
3453 | self.style[ name ] = start + unit; |
---|
3454 | } |
---|
3455 | |
---|
3456 | // If a +=/-= token was provided, we're doing a relative animation |
---|
3457 | if ( parts[1] ) |
---|
3458 | end = ((parts[1] == "-=" ? -1 : 1) * end) + start; |
---|
3459 | |
---|
3460 | e.custom( start, end, unit ); |
---|
3461 | } else |
---|
3462 | e.custom( start, val, "" ); |
---|
3463 | } |
---|
3464 | }); |
---|
3465 | |
---|
3466 | // For JS strict compliance |
---|
3467 | return true; |
---|
3468 | }); |
---|
3469 | }, |
---|
3470 | |
---|
3471 | queue: function(type, fn){ |
---|
3472 | if ( jQuery.isFunction(type) || ( type && type.constructor == Array )) { |
---|
3473 | fn = type; |
---|
3474 | type = "fx"; |
---|
3475 | } |
---|
3476 | |
---|
3477 | if ( !type || (typeof type == "string" && !fn) ) |
---|
3478 | return queue( this[0], type ); |
---|
3479 | |
---|
3480 | return this.each(function(){ |
---|
3481 | if ( this.nodeType != 1) |
---|
3482 | return; |
---|
3483 | |
---|
3484 | if ( fn.constructor == Array ) |
---|
3485 | queue(this, type, fn); |
---|
3486 | else { |
---|
3487 | queue(this, type).push( fn ); |
---|
3488 | |
---|
3489 | if ( queue(this, type).length == 1 ) |
---|
3490 | fn.apply(this); |
---|
3491 | } |
---|
3492 | }); |
---|
3493 | }, |
---|
3494 | |
---|
3495 | stop: function(clearQueue, gotoEnd){ |
---|
3496 | var timers = jQuery.timers; |
---|
3497 | |
---|
3498 | if (clearQueue) |
---|
3499 | this.queue([]); |
---|
3500 | |
---|
3501 | this.each(function(){ |
---|
3502 | // go in reverse order so anything added to the queue during the loop is ignored |
---|
3503 | for ( var i = timers.length - 1; i >= 0; i-- ) |
---|
3504 | if ( timers[i].elem == this ) { |
---|
3505 | if (gotoEnd) |
---|
3506 | // force the next step to be the last |
---|
3507 | timers[i](true); |
---|
3508 | timers.splice(i, 1); |
---|
3509 | } |
---|
3510 | }); |
---|
3511 | |
---|
3512 | // start the next in the queue if the last step wasn't forced |
---|
3513 | if (!gotoEnd) |
---|
3514 | this.dequeue(); |
---|
3515 | |
---|
3516 | return this; |
---|
3517 | } |
---|
3518 | |
---|
3519 | }); |
---|
3520 | |
---|
3521 | var queue = function( elem, type, array ) { |
---|
3522 | if ( !elem ) |
---|
3523 | return undefined; |
---|
3524 | |
---|
3525 | type = type || "fx"; |
---|
3526 | |
---|
3527 | var q = jQuery.data( elem, type + "queue" ); |
---|
3528 | |
---|
3529 | if ( !q || array ) |
---|
3530 | q = jQuery.data( elem, type + "queue", |
---|
3531 | array ? jQuery.makeArray(array) : [] ); |
---|
3532 | |
---|
3533 | return q; |
---|
3534 | }; |
---|
3535 | |
---|
3536 | jQuery.fn.dequeue = function(type){ |
---|
3537 | type = type || "fx"; |
---|
3538 | |
---|
3539 | return this.each(function(){ |
---|
3540 | var q = queue(this, type); |
---|
3541 | |
---|
3542 | q.shift(); |
---|
3543 | |
---|
3544 | if ( q.length ) |
---|
3545 | q[0].apply( this ); |
---|
3546 | }); |
---|
3547 | }; |
---|
3548 | |
---|
3549 | jQuery.extend({ |
---|
3550 | |
---|
3551 | speed: function(speed, easing, fn) { |
---|
3552 | var opt = speed && speed.constructor == Object ? speed : { |
---|
3553 | complete: fn || !fn && easing || |
---|
3554 | jQuery.isFunction( speed ) && speed, |
---|
3555 | duration: speed, |
---|
3556 | easing: fn && easing || easing && easing.constructor != Function && easing |
---|
3557 | }; |
---|
3558 | |
---|
3559 | opt.duration = (opt.duration && opt.duration.constructor == Number ? |
---|
3560 | opt.duration : |
---|
3561 | { slow: 600, fast: 200 }[opt.duration]) || 400; |
---|
3562 | |
---|
3563 | // Queueing |
---|
3564 | opt.old = opt.complete; |
---|
3565 | opt.complete = function(){ |
---|
3566 | if ( opt.queue !== false ) |
---|
3567 | jQuery(this).dequeue(); |
---|
3568 | if ( jQuery.isFunction( opt.old ) ) |
---|
3569 | opt.old.apply( this ); |
---|
3570 | }; |
---|
3571 | |
---|
3572 | return opt; |
---|
3573 | }, |
---|
3574 | |
---|
3575 | easing: { |
---|
3576 | linear: function( p, n, firstNum, diff ) { |
---|
3577 | return firstNum + diff * p; |
---|
3578 | }, |
---|
3579 | swing: function( p, n, firstNum, diff ) { |
---|
3580 | return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum; |
---|
3581 | } |
---|
3582 | }, |
---|
3583 | |
---|
3584 | timers: [], |
---|
3585 | timerId: null, |
---|
3586 | |
---|
3587 | fx: function( elem, options, prop ){ |
---|
3588 | this.options = options; |
---|
3589 | this.elem = elem; |
---|
3590 | this.prop = prop; |
---|
3591 | |
---|
3592 | if ( !options.orig ) |
---|
3593 | options.orig = {}; |
---|
3594 | } |
---|
3595 | |
---|
3596 | }); |
---|
3597 | |
---|
3598 | jQuery.fx.prototype = { |
---|
3599 | |
---|
3600 | // Simple function for setting a style value |
---|
3601 | update: function(){ |
---|
3602 | if ( this.options.step ) |
---|
3603 | this.options.step.apply( this.elem, [ this.now, this ] ); |
---|
3604 | |
---|
3605 | (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this ); |
---|
3606 | |
---|
3607 | // Set display property to block for height/width animations |
---|
3608 | if ( this.prop == "height" || this.prop == "width" ) |
---|
3609 | this.elem.style.display = "block"; |
---|
3610 | }, |
---|
3611 | |
---|
3612 | // Get the current size |
---|
3613 | cur: function(force){ |
---|
3614 | if ( this.elem[this.prop] != null && this.elem.style[this.prop] == null ) |
---|
3615 | return this.elem[ this.prop ]; |
---|
3616 | |
---|
3617 | var r = parseFloat(jQuery.css(this.elem, this.prop, force)); |
---|
3618 | return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0; |
---|
3619 | }, |
---|
3620 | |
---|
3621 | // Start an animation from one number to another |
---|
3622 | custom: function(from, to, unit){ |
---|
3623 | this.startTime = (new Date()).getTime(); |
---|
3624 | this.start = from; |
---|
3625 | this.end = to; |
---|
3626 | this.unit = unit || this.unit || "px"; |
---|
3627 | this.now = this.start; |
---|
3628 | this.pos = this.state = 0; |
---|
3629 | this.update(); |
---|
3630 | |
---|
3631 | var self = this; |
---|
3632 | function t(gotoEnd){ |
---|
3633 | return self.step(gotoEnd); |
---|
3634 | } |
---|
3635 | |
---|
3636 | t.elem = this.elem; |
---|
3637 | |
---|
3638 | jQuery.timers.push(t); |
---|
3639 | |
---|
3640 | if ( jQuery.timerId == null ) { |
---|
3641 | jQuery.timerId = setInterval(function(){ |
---|
3642 | var timers = jQuery.timers; |
---|
3643 | |
---|
3644 | for ( var i = 0; i < timers.length; i++ ) |
---|
3645 | if ( !timers[i]() ) |
---|
3646 | timers.splice(i--, 1); |
---|
3647 | |
---|
3648 | if ( !timers.length ) { |
---|
3649 | clearInterval( jQuery.timerId ); |
---|
3650 | jQuery.timerId = null; |
---|
3651 | } |
---|
3652 | }, 13); |
---|
3653 | } |
---|
3654 | }, |
---|
3655 | |
---|
3656 | // Simple 'show' function |
---|
3657 | show: function(){ |
---|
3658 | // Remember where we started, so that we can go back to it later |
---|
3659 | this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop ); |
---|
3660 | this.options.show = true; |
---|
3661 | |
---|
3662 | // Begin the animation |
---|
3663 | this.custom(0, this.cur()); |
---|
3664 | |
---|
3665 | // Make sure that we start at a small width/height to avoid any |
---|
3666 | // flash of content |
---|
3667 | if ( this.prop == "width" || this.prop == "height" ) |
---|
3668 | this.elem.style[this.prop] = "1px"; |
---|
3669 | |
---|
3670 | // Start by showing the element |
---|
3671 | jQuery(this.elem).show(); |
---|
3672 | }, |
---|
3673 | |
---|
3674 | // Simple 'hide' function |
---|
3675 | hide: function(){ |
---|
3676 | // Remember where we started, so that we can go back to it later |
---|
3677 | this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop ); |
---|
3678 | this.options.hide = true; |
---|
3679 | |
---|
3680 | // Begin the animation |
---|
3681 | this.custom(this.cur(), 0); |
---|
3682 | }, |
---|
3683 | |
---|
3684 | // Each step of an animation |
---|
3685 | step: function(gotoEnd){ |
---|
3686 | var t = (new Date()).getTime(); |
---|
3687 | |
---|
3688 | if ( gotoEnd || t > this.options.duration + this.startTime ) { |
---|
3689 | this.now = this.end; |
---|
3690 | this.pos = this.state = 1; |
---|
3691 | this.update(); |
---|
3692 | |
---|
3693 | this.options.curAnim[ this.prop ] = true; |
---|
3694 | |
---|
3695 | var done = true; |
---|
3696 | for ( var i in this.options.curAnim ) |
---|
3697 | if ( this.options.curAnim[i] !== true ) |
---|
3698 | done = false; |
---|
3699 | |
---|
3700 | if ( done ) { |
---|
3701 | if ( this.options.display != null ) { |
---|
3702 | // Reset the overflow |
---|
3703 | this.elem.style.overflow = this.options.overflow; |
---|
3704 | |
---|
3705 | // Reset the display |
---|
3706 | this.elem.style.display = this.options.display; |
---|
3707 | if ( jQuery.css(this.elem, "display") == "none" ) |
---|
3708 | this.elem.style.display = "block"; |
---|
3709 | } |
---|
3710 | |
---|
3711 | // Hide the element if the "hide" operation was done |
---|
3712 | if ( this.options.hide ) |
---|
3713 | this.elem.style.display = "none"; |
---|
3714 | |
---|
3715 | // Reset the properties, if the item has been hidden or shown |
---|
3716 | if ( this.options.hide || this.options.show ) |
---|
3717 | for ( var p in this.options.curAnim ) |
---|
3718 | jQuery.attr(this.elem.style, p, this.options.orig[p]); |
---|
3719 | } |
---|
3720 | |
---|
3721 | // If a callback was provided, execute it |
---|
3722 | if ( done && jQuery.isFunction( this.options.complete ) ) |
---|
3723 | // Execute the complete function |
---|
3724 | this.options.complete.apply( this.elem ); |
---|
3725 | |
---|
3726 | return false; |
---|
3727 | } else { |
---|
3728 | var n = t - this.startTime; |
---|
3729 | this.state = n / this.options.duration; |
---|
3730 | |
---|
3731 | // Perform the easing function, defaults to swing |
---|
3732 | this.pos = jQuery.easing[this.options.easing || (jQuery.easing.swing ? "swing" : "linear")](this.state, n, 0, 1, this.options.duration); |
---|
3733 | this.now = this.start + ((this.end - this.start) * this.pos); |
---|
3734 | |
---|
3735 | // Perform the next step of the animation |
---|
3736 | this.update(); |
---|
3737 | } |
---|
3738 | |
---|
3739 | return true; |
---|
3740 | } |
---|
3741 | |
---|
3742 | }; |
---|
3743 | |
---|
3744 | jQuery.fx.step = { |
---|
3745 | scrollLeft: function(fx){ |
---|
3746 | fx.elem.scrollLeft = fx.now; |
---|
3747 | }, |
---|
3748 | |
---|
3749 | scrollTop: function(fx){ |
---|
3750 | fx.elem.scrollTop = fx.now; |
---|
3751 | }, |
---|
3752 | |
---|
3753 | opacity: function(fx){ |
---|
3754 | jQuery.attr(fx.elem.style, "opacity", fx.now); |
---|
3755 | }, |
---|
3756 | |
---|
3757 | _default: function(fx){ |
---|
3758 | fx.elem.style[ fx.prop ] = fx.now + fx.unit; |
---|
3759 | } |
---|
3760 | }; |
---|
3761 | // The Offset Method |
---|
3762 | // Originally By Brandon Aaron, part of the Dimension Plugin |
---|
3763 | // http://jquery.com/plugins/project/dimensions |
---|
3764 | jQuery.fn.offset = function() { |
---|
3765 | var left = 0, top = 0, elem = this[0], results; |
---|
3766 | |
---|
3767 | if ( elem ) with ( jQuery.browser ) { |
---|
3768 | var parent = elem.parentNode, |
---|
3769 | offsetChild = elem, |
---|
3770 | offsetParent = elem.offsetParent, |
---|
3771 | doc = elem.ownerDocument, |
---|
3772 | safari2 = safari && parseInt(version) < 522, |
---|
3773 | fixed = jQuery.css(elem, "position") == "fixed"; |
---|
3774 | |
---|
3775 | // Use getBoundingClientRect if available |
---|
3776 | if ( elem.getBoundingClientRect ) { |
---|
3777 | var box = elem.getBoundingClientRect(); |
---|
3778 | |
---|
3779 | // Add the document scroll offsets |
---|
3780 | add(box.left + Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft), |
---|
3781 | box.top + Math.max(doc.documentElement.scrollTop, doc.body.scrollTop)); |
---|
3782 | |
---|
3783 | // IE adds the HTML element's border, by default it is medium which is 2px |
---|
3784 | // IE 6 and 7 quirks mode the border width is overwritable by the following css html { border: 0; } |
---|
3785 | // IE 7 standards mode, the border is always 2px |
---|
3786 | // This border/offset is typically represented by the clientLeft and clientTop properties |
---|
3787 | // However, in IE6 and 7 quirks mode the clientLeft and clientTop properties are not updated when overwriting it via CSS |
---|
3788 | // Therefore this method will be off by 2px in IE while in quirksmode |
---|
3789 | add( -doc.documentElement.clientLeft, -doc.documentElement.clientTop ); |
---|
3790 | |
---|
3791 | // Otherwise loop through the offsetParents and parentNodes |
---|
3792 | } else { |
---|
3793 | |
---|
3794 | // Initial element offsets |
---|
3795 | add( elem.offsetLeft, elem.offsetTop ); |
---|
3796 | |
---|
3797 | // Get parent offsets |
---|
3798 | while ( offsetParent ) { |
---|
3799 | // Add offsetParent offsets |
---|
3800 | add( offsetParent.offsetLeft, offsetParent.offsetTop ); |
---|
3801 | |
---|
3802 | // Mozilla and Safari > 2 does not include the border on offset parents |
---|
3803 | // However Mozilla adds the border for table or table cells |
---|
3804 | if ( mozilla && !/^t(able|d|h)$/i.test(offsetParent.tagName) || safari && !safari2 ) |
---|
3805 | border( offsetParent ); |
---|
3806 | |
---|
3807 | // Add the document scroll offsets if position is fixed on any offsetParent |
---|
3808 | if ( !fixed && jQuery.css(offsetParent, "position") == "fixed" ) |
---|
3809 | fixed = true; |
---|
3810 | |
---|
3811 | // Set offsetChild to previous offsetParent unless it is the body element |
---|
3812 | offsetChild = /^body$/i.test(offsetParent.tagName) ? offsetChild : offsetParent; |
---|
3813 | // Get next offsetParent |
---|
3814 | offsetParent = offsetParent.offsetParent; |
---|
3815 | } |
---|
3816 | |
---|
3817 | // Get parent scroll offsets |
---|
3818 | while ( parent.tagName && !/^body|html$/i.test(parent.tagName) ) { |
---|
3819 | // Remove parent scroll UNLESS that parent is inline or a table to work around Opera inline/table scrollLeft/Top bug |
---|
3820 | if ( !/^inline|table.*$/i.test(jQuery.css(parent, "display")) ) |
---|
3821 | // Subtract parent scroll offsets |
---|
3822 | add( -parent.scrollLeft, -parent.scrollTop ); |
---|
3823 | |
---|
3824 | // Mozilla does not add the border for a parent that has overflow != visible |
---|
3825 | if ( mozilla && jQuery.css(parent, "overflow") != "visible" ) |
---|
3826 | border( parent ); |
---|
3827 | |
---|
3828 | // Get next parent |
---|
3829 | parent = parent.parentNode; |
---|
3830 | } |
---|
3831 | |
---|
3832 | // Safari <= 2 doubles body offsets with a fixed position element/offsetParent or absolutely positioned offsetChild |
---|
3833 | // Mozilla doubles body offsets with a non-absolutely positioned offsetChild |
---|
3834 | if ( (safari2 && (fixed || jQuery.css(offsetChild, "position") == "absolute")) || |
---|
3835 | (mozilla && jQuery.css(offsetChild, "position") != "absolute") ) |
---|
3836 | add( -doc.body.offsetLeft, -doc.body.offsetTop ); |
---|
3837 | |
---|
3838 | // Add the document scroll offsets if position is fixed |
---|
3839 | if ( fixed ) |
---|
3840 | add(Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft), |
---|
3841 | Math.max(doc.documentElement.scrollTop, doc.body.scrollTop)); |
---|
3842 | } |
---|
3843 | |
---|
3844 | // Return an object with top and left properties |
---|
3845 | results = { top: top, left: left }; |
---|
3846 | } |
---|
3847 | |
---|
3848 | function border(elem) { |
---|
3849 | add( jQuery.css(elem, "borderLeftWidth"), jQuery.css(elem, "borderTopWidth") ); |
---|
3850 | } |
---|
3851 | |
---|
3852 | function add(l, t) { |
---|
3853 | left += parseInt(l) || 0; |
---|
3854 | top += parseInt(t) || 0; |
---|
3855 | } |
---|
3856 | |
---|
3857 | return results; |
---|
3858 | }; |
---|
3859 | })(); |
---|