shinmun 0.1

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