virgo-gadgeteer 0.2.2

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