equipment 0.1.0 → 1.4.84
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +9 -0
- data/LICENSE +340 -0
- data/README +29 -12
- data/Rakefile +157 -0
- data/TODO +14 -0
- data/doc/structure.dia +0 -0
- data/doc/structure.png +0 -0
- data/lib/camping_ext.rb +72 -0
- data/lib/equipment.rb +39 -116
- data/lib/ext.rb +33 -0
- data/lib/ext/active_record.rb +146 -0
- data/lib/ext/basic_auth.rb +15 -15
- data/lib/ext/controls.rb +16 -14
- data/lib/ext/flash.rb +35 -17
- data/lib/ext/form_helpers.rb +46 -0
- data/lib/ext/forward.rb +44 -15
- data/lib/ext/js_helpers.rb +66 -19
- data/lib/ext/logging.rb +61 -0
- data/lib/ext/mount.rb +33 -27
- data/lib/ext/negociate_content.rb +90 -0
- data/lib/ext/og.rb +18 -10
- data/lib/ext/og_scaffold.rb +5 -8
- data/lib/ext/resource.rb +127 -0
- data/lib/ext/security.rb +66 -31
- data/lib/ext/sendfile.rb +3 -4
- data/lib/ext/settings.rb +243 -0
- data/lib/ext/template_view.rb +9 -37
- data/lib/ext/use_helper.rb +6 -10
- data/lib/ext/view.rb +98 -0
- data/lib/ext/view_slot.rb +60 -0
- data/lib/mimetype_ext.rb +12 -0
- data/lib/more/typecast.rb +288 -0
- data/lib/ruby_ext.rb +126 -0
- data/share/js/date_ext.js +234 -0
- data/share/js/es-confirm.js +23 -0
- data/share/js/event-selector.js +145 -0
- data/share/js/jquery.js +1793 -0
- data/share/js/prototype.js +2012 -0
- metadata +50 -35
- data/ProjectInfo +0 -55
- data/examples/basicauthtest.rb +0 -59
- data/examples/erubytest.rb +0 -36
- data/examples/flashtest.rb +0 -46
- data/examples/index.erb +0 -9
- data/examples/mounttest.rb +0 -34
- data/examples/ogtest.rb +0 -41
- data/examples/patchestest.rb +0 -40
- data/examples/sendfiletest.rb +0 -29
- data/lib/ext/forms.rb +0 -22
- data/lib/ext/patches.rb +0 -130
- data/lib/ext/ressource.rb +0 -88
data/share/js/jquery.js
ADDED
@@ -0,0 +1,1793 @@
|
|
1
|
+
/*
|
2
|
+
* jQuery - New Wave Javascript
|
3
|
+
*
|
4
|
+
* Copyright (c) 2006 John Resig (jquery.com)
|
5
|
+
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
6
|
+
* and GPL (GPL-LICENSE.txt) licenses.
|
7
|
+
*
|
8
|
+
* $Date: 2006-08-22 01:00:07 -0400 (Tue, 22 Aug 2006) $
|
9
|
+
* $Rev: 221 $
|
10
|
+
*/
|
11
|
+
|
12
|
+
// Global undefined variable
|
13
|
+
window.undefined = window.undefined;
|
14
|
+
function jQuery(a,c) {
|
15
|
+
|
16
|
+
// Initalize the extra macro functions
|
17
|
+
if ( !jQuery.initDone ) jQuery.init();
|
18
|
+
|
19
|
+
// Shortcut for document ready (because $(document).each() is silly)
|
20
|
+
if ( a && a.constructor == Function && jQuery.fn.ready )
|
21
|
+
return jQuery(document).ready(a);
|
22
|
+
|
23
|
+
// Make sure that a selection was provided
|
24
|
+
a = a || jQuery.context || document;
|
25
|
+
|
26
|
+
/*
|
27
|
+
* Handle support for overriding other $() functions. Way too many libraries
|
28
|
+
* provide this function to simply ignore it and overwrite it.
|
29
|
+
*/
|
30
|
+
/*
|
31
|
+
// Check to see if this is a possible collision case
|
32
|
+
if ( jQuery._$ && !c && a.constructor == String &&
|
33
|
+
|
34
|
+
// Make sure that the expression is a colliding one
|
35
|
+
!/[^a-zA-Z0-9_-]/.test(a) &&
|
36
|
+
|
37
|
+
// and that there are no elements that match it
|
38
|
+
// (this is the one truly ambiguous case)
|
39
|
+
!document.getElementsByTagName(a).length )
|
40
|
+
|
41
|
+
// Use the default method, in case it works some voodoo
|
42
|
+
return jQuery._$( a );
|
43
|
+
*/
|
44
|
+
|
45
|
+
// Watch for when a jQuery object is passed as the selector
|
46
|
+
if ( a.jquery )
|
47
|
+
return $( jQuery.merge( a, [] ) );
|
48
|
+
|
49
|
+
// Watch for when a jQuery object is passed at the context
|
50
|
+
if ( c && c.jquery )
|
51
|
+
return $( c ).find(a);
|
52
|
+
|
53
|
+
// If the context is global, return a new object
|
54
|
+
if ( window == this )
|
55
|
+
return new jQuery(a,c);
|
56
|
+
|
57
|
+
// Handle HTML strings
|
58
|
+
var m = /^[^<]*(<.+>)[^>]*$/.exec(a);
|
59
|
+
if ( m ) a = jQuery.clean( [ m[1] ] );
|
60
|
+
|
61
|
+
// Watch for when an array is passed in
|
62
|
+
this.get( a.constructor == Array || a.length && !a.nodeType && a[0] != undefined && a[0].nodeType ?
|
63
|
+
// Assume that it is an array of DOM Elements
|
64
|
+
jQuery.merge( a, [] ) :
|
65
|
+
|
66
|
+
// Find the matching elements and save them for later
|
67
|
+
jQuery.find( a, c ) );
|
68
|
+
|
69
|
+
var fn = arguments[ arguments.length - 1 ];
|
70
|
+
if ( fn && fn.constructor == Function )
|
71
|
+
this.each(fn);
|
72
|
+
}
|
73
|
+
|
74
|
+
// Map over the $ in case of overwrite
|
75
|
+
if ( $ )
|
76
|
+
jQuery._$ = $;
|
77
|
+
|
78
|
+
// Map the jQuery namespace to the '$' one
|
79
|
+
var $ = jQuery;
|
80
|
+
|
81
|
+
jQuery.fn = jQuery.prototype = {
|
82
|
+
jquery: "$Rev: 221 $",
|
83
|
+
|
84
|
+
size: function() {
|
85
|
+
return this.length;
|
86
|
+
},
|
87
|
+
|
88
|
+
get: function( num ) {
|
89
|
+
// Watch for when an array (of elements) is passed in
|
90
|
+
if ( num && num.constructor == Array ) {
|
91
|
+
|
92
|
+
// Use a tricky hack to make the jQuery object
|
93
|
+
// look and feel like an array
|
94
|
+
this.length = 0;
|
95
|
+
[].push.apply( this, num );
|
96
|
+
|
97
|
+
return this;
|
98
|
+
} else
|
99
|
+
return num == undefined ?
|
100
|
+
|
101
|
+
// Return a 'clean' array
|
102
|
+
jQuery.map( this, function(a){ return a } ) :
|
103
|
+
|
104
|
+
// Return just the object
|
105
|
+
this[num];
|
106
|
+
},
|
107
|
+
each: function( fn, args ) {
|
108
|
+
return jQuery.each( this, fn, args );
|
109
|
+
},
|
110
|
+
|
111
|
+
index: function( obj ) {
|
112
|
+
var pos = -1;
|
113
|
+
this.each(function(i){
|
114
|
+
if ( this == obj ) pos = i;
|
115
|
+
});
|
116
|
+
return pos;
|
117
|
+
},
|
118
|
+
|
119
|
+
attr: function( key, value, type ) {
|
120
|
+
// Check to see if we're setting style values
|
121
|
+
return key.constructor != String || value != undefined ?
|
122
|
+
this.each(function(){
|
123
|
+
// See if we're setting a hash of styles
|
124
|
+
if ( value == undefined )
|
125
|
+
// Set all the styles
|
126
|
+
for ( var prop in key )
|
127
|
+
jQuery.attr(
|
128
|
+
type ? this.style : this,
|
129
|
+
prop, key[prop]
|
130
|
+
);
|
131
|
+
|
132
|
+
// See if we're setting a single key/value style
|
133
|
+
else
|
134
|
+
jQuery.attr(
|
135
|
+
type ? this.style : this,
|
136
|
+
key, value
|
137
|
+
);
|
138
|
+
}) :
|
139
|
+
|
140
|
+
// Look for the case where we're accessing a style value
|
141
|
+
jQuery[ type || "attr" ]( this[0], key );
|
142
|
+
},
|
143
|
+
|
144
|
+
css: function( key, value ) {
|
145
|
+
return this.attr( key, value, "curCSS" );
|
146
|
+
},
|
147
|
+
text: function(e) {
|
148
|
+
e = e || this;
|
149
|
+
var t = "";
|
150
|
+
for ( var j = 0; j < e.length; j++ ) {
|
151
|
+
var r = e[j].childNodes;
|
152
|
+
for ( var i = 0; i < r.length; i++ )
|
153
|
+
t += r[i].nodeType != 1 ?
|
154
|
+
r[i].nodeValue : jQuery.fn.text([ r[i] ]);
|
155
|
+
}
|
156
|
+
return t;
|
157
|
+
},
|
158
|
+
wrap: function() {
|
159
|
+
// The elements to wrap the target around
|
160
|
+
var a = jQuery.clean(arguments);
|
161
|
+
|
162
|
+
// Wrap each of the matched elements individually
|
163
|
+
return this.each(function(){
|
164
|
+
// Clone the structure that we're using to wrap
|
165
|
+
var b = a[0].cloneNode(true);
|
166
|
+
|
167
|
+
// Insert it before the element to be wrapped
|
168
|
+
this.parentNode.insertBefore( b, this );
|
169
|
+
|
170
|
+
// Find he deepest point in the wrap structure
|
171
|
+
while ( b.firstChild )
|
172
|
+
b = b.firstChild;
|
173
|
+
|
174
|
+
// Move the matched element to within the wrap structure
|
175
|
+
b.appendChild( this );
|
176
|
+
});
|
177
|
+
},
|
178
|
+
append: function() {
|
179
|
+
return this.domManip(arguments, true, 1, function(a){
|
180
|
+
this.appendChild( a );
|
181
|
+
});
|
182
|
+
},
|
183
|
+
prepend: function() {
|
184
|
+
return this.domManip(arguments, true, -1, function(a){
|
185
|
+
this.insertBefore( a, this.firstChild );
|
186
|
+
});
|
187
|
+
},
|
188
|
+
before: function() {
|
189
|
+
return this.domManip(arguments, false, 1, function(a){
|
190
|
+
this.parentNode.insertBefore( a, this );
|
191
|
+
});
|
192
|
+
},
|
193
|
+
after: function() {
|
194
|
+
return this.domManip(arguments, false, -1, function(a){
|
195
|
+
this.parentNode.insertBefore( a, this.nextSibling );
|
196
|
+
});
|
197
|
+
},
|
198
|
+
end: function() {
|
199
|
+
return this.get( this.stack.pop() );
|
200
|
+
},
|
201
|
+
find: function(t) {
|
202
|
+
return this.pushStack( jQuery.map( this, function(a){
|
203
|
+
return jQuery.find(t,a);
|
204
|
+
}), arguments );
|
205
|
+
},
|
206
|
+
|
207
|
+
clone: function(deep) {
|
208
|
+
return this.pushStack( jQuery.map( this, function(a){
|
209
|
+
return a.cloneNode( deep != undefined ? deep : true );
|
210
|
+
}), arguments );
|
211
|
+
},
|
212
|
+
|
213
|
+
filter: function(t) {
|
214
|
+
return this.pushStack(
|
215
|
+
t.constructor == Array &&
|
216
|
+
jQuery.map(this,function(a){
|
217
|
+
for ( var i = 0; i < t.length; i++ )
|
218
|
+
if ( jQuery.filter(t[i],[a]).r.length )
|
219
|
+
return a;
|
220
|
+
}) ||
|
221
|
+
|
222
|
+
t.constructor == Boolean &&
|
223
|
+
( t ? this.get() : [] ) ||
|
224
|
+
|
225
|
+
t.constructor == Function &&
|
226
|
+
jQuery.grep( this, t ) ||
|
227
|
+
|
228
|
+
jQuery.filter(t,this).r, arguments );
|
229
|
+
},
|
230
|
+
|
231
|
+
not: function(t) {
|
232
|
+
return this.pushStack( t.constructor == String ?
|
233
|
+
jQuery.filter(t,this,false).r :
|
234
|
+
jQuery.grep(this,function(a){ return a != t; }), arguments );
|
235
|
+
},
|
236
|
+
|
237
|
+
add: function(t) {
|
238
|
+
return this.pushStack( jQuery.merge( this, t.constructor == String ?
|
239
|
+
jQuery.find(t) : t.constructor == Array ? t : [t] ), arguments );
|
240
|
+
},
|
241
|
+
is: function(expr) {
|
242
|
+
return expr ? jQuery.filter(expr,this).r.length > 0 : this.length > 0;
|
243
|
+
},
|
244
|
+
domManip: function(args, table, dir, fn){
|
245
|
+
var clone = this.size() > 1;
|
246
|
+
var a = jQuery.clean(args);
|
247
|
+
|
248
|
+
return this.each(function(){
|
249
|
+
var obj = this;
|
250
|
+
|
251
|
+
if ( table && this.nodeName == "TABLE" && a[0].nodeName != "THEAD" ) {
|
252
|
+
var tbody = this.getElementsByTagName("tbody");
|
253
|
+
|
254
|
+
if ( !tbody.length ) {
|
255
|
+
obj = document.createElement("tbody");
|
256
|
+
this.appendChild( obj );
|
257
|
+
} else
|
258
|
+
obj = tbody[0];
|
259
|
+
}
|
260
|
+
|
261
|
+
for ( var i = ( dir < 0 ? a.length - 1 : 0 );
|
262
|
+
i != ( dir < 0 ? dir : a.length ); i += dir ) {
|
263
|
+
fn.apply( obj, [ clone ? a[i].cloneNode(true) : a[i] ] );
|
264
|
+
}
|
265
|
+
});
|
266
|
+
},
|
267
|
+
pushStack: function(a,args) {
|
268
|
+
var fn = args && args[args.length-1];
|
269
|
+
|
270
|
+
if ( !fn || fn.constructor != Function ) {
|
271
|
+
if ( !this.stack ) this.stack = [];
|
272
|
+
this.stack.push( this.get() );
|
273
|
+
this.get( a );
|
274
|
+
} else {
|
275
|
+
var old = this.get();
|
276
|
+
this.get( a );
|
277
|
+
if ( fn.constructor == Function )
|
278
|
+
return this.each( fn );
|
279
|
+
this.get( old );
|
280
|
+
}
|
281
|
+
|
282
|
+
return this;
|
283
|
+
}
|
284
|
+
};
|
285
|
+
|
286
|
+
jQuery.extend = jQuery.fn.extend = function(obj,prop) {
|
287
|
+
if ( !prop ) { prop = obj; obj = this; }
|
288
|
+
for ( var i in prop ) obj[i] = prop[i];
|
289
|
+
return obj;
|
290
|
+
};
|
291
|
+
|
292
|
+
jQuery.extend({
|
293
|
+
init: function(){
|
294
|
+
jQuery.initDone = true;
|
295
|
+
|
296
|
+
jQuery.each( jQuery.macros.axis, function(i,n){
|
297
|
+
jQuery.fn[ i ] = function(a) {
|
298
|
+
var ret = jQuery.map(this,n);
|
299
|
+
if ( a && a.constructor == String )
|
300
|
+
ret = jQuery.filter(a,ret).r;
|
301
|
+
return this.pushStack( ret, arguments );
|
302
|
+
};
|
303
|
+
});
|
304
|
+
|
305
|
+
jQuery.each( jQuery.macros.to, function(i,n){
|
306
|
+
jQuery.fn[ i ] = function(){
|
307
|
+
var a = arguments;
|
308
|
+
return this.each(function(){
|
309
|
+
for ( var j = 0; j < a.length; j++ )
|
310
|
+
$(a[j])[n]( this );
|
311
|
+
});
|
312
|
+
};
|
313
|
+
});
|
314
|
+
|
315
|
+
jQuery.each( jQuery.macros.each, function(i,n){
|
316
|
+
jQuery.fn[ i ] = function() {
|
317
|
+
return this.each( n, arguments );
|
318
|
+
};
|
319
|
+
});
|
320
|
+
|
321
|
+
jQuery.each( jQuery.macros.filter, function(i,n){
|
322
|
+
jQuery.fn[ n ] = function(num,fn) {
|
323
|
+
return this.filter( ":" + n + "(" + num + ")", fn );
|
324
|
+
};
|
325
|
+
});
|
326
|
+
|
327
|
+
jQuery.each( jQuery.macros.attr, function(i,n){
|
328
|
+
n = n || i;
|
329
|
+
jQuery.fn[ i ] = function(h) {
|
330
|
+
return h == undefined ?
|
331
|
+
this.length ? this[0][n] : null :
|
332
|
+
this.attr( n, h );
|
333
|
+
};
|
334
|
+
});
|
335
|
+
|
336
|
+
jQuery.each( jQuery.macros.css, function(i,n){
|
337
|
+
jQuery.fn[ n ] = function(h) {
|
338
|
+
return h == undefined ?
|
339
|
+
( this.length ? jQuery.css( this[0], n ) : null ) :
|
340
|
+
this.css( n, h );
|
341
|
+
};
|
342
|
+
});
|
343
|
+
|
344
|
+
},
|
345
|
+
each: function( obj, fn, args ) {
|
346
|
+
if ( obj.length == undefined )
|
347
|
+
for ( var i in obj )
|
348
|
+
fn.apply( obj[i], args || [i, obj[i]] );
|
349
|
+
else
|
350
|
+
for ( var i = 0; i < obj.length; i++ )
|
351
|
+
fn.apply( obj[i], args || [i, obj[i]] );
|
352
|
+
return obj;
|
353
|
+
},
|
354
|
+
|
355
|
+
className: {
|
356
|
+
add: function(o,c){
|
357
|
+
if (jQuery.className.has(o,c)) return;
|
358
|
+
o.className += ( o.className ? " " : "" ) + c;
|
359
|
+
},
|
360
|
+
remove: function(o,c){
|
361
|
+
o.className = !c ? "" :
|
362
|
+
o.className.replace(
|
363
|
+
new RegExp("(^|\\s*\\b[^-])"+c+"($|\\b(?=[^-]))", "g"), "");
|
364
|
+
},
|
365
|
+
has: function(e,a) {
|
366
|
+
if ( e.className )
|
367
|
+
e = e.className;
|
368
|
+
return new RegExp("(^|\\s)" + a + "(\\s|$)").test(e);
|
369
|
+
}
|
370
|
+
},
|
371
|
+
swap: function(e,o,f) {
|
372
|
+
for ( var i in o ) {
|
373
|
+
e.style["old"+i] = e.style[i];
|
374
|
+
e.style[i] = o[i];
|
375
|
+
}
|
376
|
+
f.apply( e, [] );
|
377
|
+
for ( var i in o )
|
378
|
+
e.style[i] = e.style["old"+i];
|
379
|
+
},
|
380
|
+
|
381
|
+
css: function(e,p) {
|
382
|
+
if ( p == "height" || p == "width" ) {
|
383
|
+
var old = {}, oHeight, oWidth, d = ["Top","Bottom","Right","Left"];
|
384
|
+
|
385
|
+
for ( var i in d ) {
|
386
|
+
old["padding" + d[i]] = 0;
|
387
|
+
old["border" + d[i] + "Width"] = 0;
|
388
|
+
}
|
389
|
+
|
390
|
+
jQuery.swap( e, old, function() {
|
391
|
+
if (jQuery.css(e,"display") != "none") {
|
392
|
+
oHeight = e.offsetHeight;
|
393
|
+
oWidth = e.offsetWidth;
|
394
|
+
} else
|
395
|
+
jQuery.swap( e, { visibility: "hidden", position: "absolute", display: "" },
|
396
|
+
function(){
|
397
|
+
oHeight = e.clientHeight;
|
398
|
+
oWidth = e.clientWidth;
|
399
|
+
});
|
400
|
+
});
|
401
|
+
|
402
|
+
return p == "height" ? oHeight : oWidth;
|
403
|
+
} else if ( p == "opacity" && jQuery.browser.msie )
|
404
|
+
return parseFloat( jQuery.curCSS(e,"filter").replace(/[^0-9.]/,"") ) || 1;
|
405
|
+
|
406
|
+
return jQuery.curCSS( e, p );
|
407
|
+
},
|
408
|
+
|
409
|
+
curCSS: function(e,p,force) {
|
410
|
+
var r;
|
411
|
+
|
412
|
+
if (!force && e.style[p])
|
413
|
+
r = e.style[p];
|
414
|
+
else if (e.currentStyle) {
|
415
|
+
p = p.replace(/\-(\w)/g,function(m,c){return c.toUpperCase()});
|
416
|
+
r = e.currentStyle[p];
|
417
|
+
} else if (document.defaultView && document.defaultView.getComputedStyle) {
|
418
|
+
p = p.replace(/([A-Z])/g,"-$1").toLowerCase();
|
419
|
+
var s = document.defaultView.getComputedStyle(e,"");
|
420
|
+
r = s ? s.getPropertyValue(p) : null;
|
421
|
+
}
|
422
|
+
|
423
|
+
return r;
|
424
|
+
},
|
425
|
+
|
426
|
+
clean: function(a) {
|
427
|
+
var r = [];
|
428
|
+
for ( var i = 0; i < a.length; i++ ) {
|
429
|
+
if ( a[i].constructor == String ) {
|
430
|
+
|
431
|
+
var table = "";
|
432
|
+
|
433
|
+
if ( !a[i].indexOf("<thead") || !a[i].indexOf("<tbody") ) {
|
434
|
+
table = "thead";
|
435
|
+
a[i] = "<table>" + a[i] + "</table>";
|
436
|
+
} else if ( !a[i].indexOf("<tr") ) {
|
437
|
+
table = "tr";
|
438
|
+
a[i] = "<table>" + a[i] + "</table>";
|
439
|
+
} else if ( !a[i].indexOf("<td") || !a[i].indexOf("<th") ) {
|
440
|
+
table = "td";
|
441
|
+
a[i] = "<table><tbody><tr>" + a[i] + "</tr></tbody></table>";
|
442
|
+
}
|
443
|
+
|
444
|
+
var div = document.createElement("div");
|
445
|
+
div.innerHTML = a[i];
|
446
|
+
|
447
|
+
if ( table ) {
|
448
|
+
div = div.firstChild;
|
449
|
+
if ( table != "thead" ) div = div.firstChild;
|
450
|
+
if ( table == "td" ) div = div.firstChild;
|
451
|
+
}
|
452
|
+
|
453
|
+
for ( var j = 0; j < div.childNodes.length; j++ )
|
454
|
+
r.push( div.childNodes[j] );
|
455
|
+
} else if ( a[i].jquery || a[i].length && !a[i].nodeType )
|
456
|
+
for ( var k = 0; k < a[i].length; k++ )
|
457
|
+
r.push( a[i][k] );
|
458
|
+
else if ( a[i] !== null )
|
459
|
+
r.push( a[i].nodeType ? a[i] : document.createTextNode(a[i].toString()) );
|
460
|
+
}
|
461
|
+
return r;
|
462
|
+
},
|
463
|
+
|
464
|
+
expr: {
|
465
|
+
"": "m[2]== '*'||a.nodeName.toUpperCase()==m[2].toUpperCase()",
|
466
|
+
"#": "a.getAttribute('id')&&a.getAttribute('id')==m[2]",
|
467
|
+
":": {
|
468
|
+
// Position Checks
|
469
|
+
lt: "i<m[3]-0",
|
470
|
+
gt: "i>m[3]-0",
|
471
|
+
nth: "m[3]-0==i",
|
472
|
+
eq: "m[3]-0==i",
|
473
|
+
first: "i==0",
|
474
|
+
last: "i==r.length-1",
|
475
|
+
even: "i%2==0",
|
476
|
+
odd: "i%2",
|
477
|
+
|
478
|
+
// Child Checks
|
479
|
+
"first-child": "jQuery.sibling(a,0).cur",
|
480
|
+
"last-child": "jQuery.sibling(a,0).last",
|
481
|
+
"only-child": "jQuery.sibling(a).length==1",
|
482
|
+
|
483
|
+
// Parent Checks
|
484
|
+
parent: "a.childNodes.length",
|
485
|
+
empty: "!a.childNodes.length",
|
486
|
+
|
487
|
+
// Text Check
|
488
|
+
contains: "(a.innerText||a.innerHTML).indexOf(m[3])>=0",
|
489
|
+
|
490
|
+
// Visibility
|
491
|
+
visible: "a.type!='hidden'&&jQuery.css(a,'display')!='none'&&jQuery.css(a,'visibility')!='hidden'",
|
492
|
+
hidden: "a.type=='hidden'||jQuery.css(a,'display')=='none'||jQuery.css(a,'visibility')=='hidden'",
|
493
|
+
|
494
|
+
// Form elements
|
495
|
+
enabled: "!a.disabled",
|
496
|
+
disabled: "a.disabled",
|
497
|
+
checked: "a.checked",
|
498
|
+
selected: "a.selected"
|
499
|
+
},
|
500
|
+
".": "jQuery.className.has(a,m[2])",
|
501
|
+
"@": {
|
502
|
+
"=": "z==m[4]",
|
503
|
+
"!=": "z!=m[4]",
|
504
|
+
"^=": "!z.indexOf(m[4])",
|
505
|
+
"$=": "z.substr(z.length - m[4].length,m[4].length)==m[4]",
|
506
|
+
"*=": "z.indexOf(m[4])>=0",
|
507
|
+
"": "z"
|
508
|
+
},
|
509
|
+
"[": "jQuery.find(m[2],a).length"
|
510
|
+
},
|
511
|
+
|
512
|
+
token: [
|
513
|
+
"\\.\\.|/\\.\\.", "a.parentNode",
|
514
|
+
">|/", "jQuery.sibling(a.firstChild)",
|
515
|
+
"\\+", "jQuery.sibling(a).next",
|
516
|
+
"~", function(a){
|
517
|
+
var r = [];
|
518
|
+
var s = jQuery.sibling(a);
|
519
|
+
if ( s.n > 0 )
|
520
|
+
for ( var i = s.n; i < s.length; i++ )
|
521
|
+
r.push( s[i] );
|
522
|
+
return r;
|
523
|
+
}
|
524
|
+
],
|
525
|
+
find: function( t, context ) {
|
526
|
+
// Make sure that the context is a DOM Element
|
527
|
+
if ( context && context.nodeType == undefined )
|
528
|
+
context = null;
|
529
|
+
|
530
|
+
// Set the correct context (if none is provided)
|
531
|
+
context = context || jQuery.context || document;
|
532
|
+
|
533
|
+
if ( t.constructor != String ) return [t];
|
534
|
+
|
535
|
+
if ( !t.indexOf("//") ) {
|
536
|
+
context = context.documentElement;
|
537
|
+
t = t.substr(2,t.length);
|
538
|
+
} else if ( !t.indexOf("/") ) {
|
539
|
+
context = context.documentElement;
|
540
|
+
t = t.substr(1,t.length);
|
541
|
+
// FIX Assume the root element is right :(
|
542
|
+
if ( t.indexOf("/") >= 1 )
|
543
|
+
t = t.substr(t.indexOf("/"),t.length);
|
544
|
+
}
|
545
|
+
|
546
|
+
var ret = [context];
|
547
|
+
var done = [];
|
548
|
+
var last = null;
|
549
|
+
|
550
|
+
while ( t.length > 0 && last != t ) {
|
551
|
+
var r = [];
|
552
|
+
last = t;
|
553
|
+
|
554
|
+
t = jQuery.trim(t).replace( /^\/\//i, "" );
|
555
|
+
|
556
|
+
var foundToken = false;
|
557
|
+
|
558
|
+
for ( var i = 0; i < jQuery.token.length; i += 2 ) {
|
559
|
+
var re = new RegExp("^(" + jQuery.token[i] + ")");
|
560
|
+
var m = re.exec(t);
|
561
|
+
|
562
|
+
if ( m ) {
|
563
|
+
r = ret = jQuery.map( ret, jQuery.token[i+1] );
|
564
|
+
t = jQuery.trim( t.replace( re, "" ) );
|
565
|
+
foundToken = true;
|
566
|
+
}
|
567
|
+
}
|
568
|
+
|
569
|
+
if ( !foundToken ) {
|
570
|
+
if ( !t.indexOf(",") || !t.indexOf("|") ) {
|
571
|
+
if ( ret[0] == context ) ret.shift();
|
572
|
+
done = jQuery.merge( done, ret );
|
573
|
+
r = ret = [context];
|
574
|
+
t = " " + t.substr(1,t.length);
|
575
|
+
} else {
|
576
|
+
var re2 = /^([#.]?)([a-z0-9\\*_-]*)/i;
|
577
|
+
var m = re2.exec(t);
|
578
|
+
|
579
|
+
if ( m[1] == "#" ) {
|
580
|
+
// Ummm, should make this work in all XML docs
|
581
|
+
var oid = document.getElementById(m[2]);
|
582
|
+
r = ret = oid ? [oid] : [];
|
583
|
+
t = t.replace( re2, "" );
|
584
|
+
} else {
|
585
|
+
if ( !m[2] || m[1] == "." ) m[2] = "*";
|
586
|
+
|
587
|
+
for ( var i = 0; i < ret.length; i++ )
|
588
|
+
r = jQuery.merge( r,
|
589
|
+
m[2] == "*" ?
|
590
|
+
jQuery.getAll(ret[i]) :
|
591
|
+
ret[i].getElementsByTagName(m[2])
|
592
|
+
);
|
593
|
+
}
|
594
|
+
}
|
595
|
+
}
|
596
|
+
|
597
|
+
if ( t ) {
|
598
|
+
var val = jQuery.filter(t,r);
|
599
|
+
ret = r = val.r;
|
600
|
+
t = jQuery.trim(val.t);
|
601
|
+
}
|
602
|
+
}
|
603
|
+
|
604
|
+
if ( ret && ret[0] == context ) ret.shift();
|
605
|
+
done = jQuery.merge( done, ret );
|
606
|
+
|
607
|
+
return done;
|
608
|
+
},
|
609
|
+
|
610
|
+
getAll: function(o,r) {
|
611
|
+
r = r || [];
|
612
|
+
var s = o.childNodes;
|
613
|
+
for ( var i = 0; i < s.length; i++ )
|
614
|
+
if ( s[i].nodeType == 1 ) {
|
615
|
+
r.push( s[i] );
|
616
|
+
jQuery.getAll( s[i], r );
|
617
|
+
}
|
618
|
+
return r;
|
619
|
+
},
|
620
|
+
|
621
|
+
attr: function(o,a,v){
|
622
|
+
if ( a && a.constructor == String ) {
|
623
|
+
var fix = {
|
624
|
+
"for": "htmlFor",
|
625
|
+
"class": "className",
|
626
|
+
"float": "cssFloat"
|
627
|
+
};
|
628
|
+
|
629
|
+
a = (fix[a] && fix[a].replace && fix[a] || a)
|
630
|
+
.replace(/-([a-z])/ig,function(z,b){
|
631
|
+
return b.toUpperCase();
|
632
|
+
});
|
633
|
+
|
634
|
+
if ( v != undefined ) {
|
635
|
+
o[a] = v;
|
636
|
+
if ( o.setAttribute && a != "disabled" )
|
637
|
+
o.setAttribute(a,v);
|
638
|
+
}
|
639
|
+
|
640
|
+
return o[a] || o.getAttribute && o.getAttribute(a) || "";
|
641
|
+
} else
|
642
|
+
return "";
|
643
|
+
},
|
644
|
+
|
645
|
+
// The regular expressions that power the parsing engine
|
646
|
+
parse: [
|
647
|
+
// Match: [@value='test'], [@foo]
|
648
|
+
[ "\\[ *(@)S *([!*$^=]*) *Q\\]", 1 ],
|
649
|
+
|
650
|
+
// Match: [div], [div p]
|
651
|
+
[ "(\\[)Q\\]", 0 ],
|
652
|
+
|
653
|
+
// Match: :contains('foo')
|
654
|
+
[ "(:)S\\(Q\\)", 0 ],
|
655
|
+
|
656
|
+
// Match: :even, :last-chlid
|
657
|
+
[ "([:.#]*)S", 0 ]
|
658
|
+
],
|
659
|
+
|
660
|
+
filter: function(t,r,not) {
|
661
|
+
// Figure out if we're doing regular, or inverse, filtering
|
662
|
+
var g = not !== false ? jQuery.grep :
|
663
|
+
function(a,f) {return jQuery.grep(a,f,true);};
|
664
|
+
|
665
|
+
while ( t && /^[a-z[({<*:.#]/i.test(t) ) {
|
666
|
+
|
667
|
+
var p = jQuery.parse;
|
668
|
+
|
669
|
+
for ( var i = 0; i < p.length; i++ ) {
|
670
|
+
var re = new RegExp( "^" + p[i][0]
|
671
|
+
|
672
|
+
// Look for a string-like sequence
|
673
|
+
.replace( 'S', "([a-z*_-][a-z0-9_-]*)" )
|
674
|
+
|
675
|
+
// Look for something (optionally) enclosed with quotes
|
676
|
+
.replace( 'Q', " *'?\"?([^'\"]*?)'?\"? *" ), "i" );
|
677
|
+
|
678
|
+
var m = re.exec( t );
|
679
|
+
|
680
|
+
if ( m ) {
|
681
|
+
// Re-organize the match
|
682
|
+
if ( p[i][1] )
|
683
|
+
m = ["", m[1], m[3], m[2], m[4]];
|
684
|
+
|
685
|
+
// Remove what we just matched
|
686
|
+
t = t.replace( re, "" );
|
687
|
+
|
688
|
+
break;
|
689
|
+
}
|
690
|
+
}
|
691
|
+
|
692
|
+
// :not() is a special case that can be optomized by
|
693
|
+
// keeping it out of the expression list
|
694
|
+
if ( m[1] == ":" && m[2] == "not" )
|
695
|
+
r = jQuery.filter(m[3],r,false).r;
|
696
|
+
|
697
|
+
// Otherwise, find the expression to execute
|
698
|
+
else {
|
699
|
+
var f = jQuery.expr[m[1]];
|
700
|
+
if ( f.constructor != String )
|
701
|
+
f = jQuery.expr[m[1]][m[2]];
|
702
|
+
|
703
|
+
// Build a custom macro to enclose it
|
704
|
+
eval("f = function(a,i){" +
|
705
|
+
( m[1] == "@" ? "z=jQuery.attr(a,m[3]);" : "" ) +
|
706
|
+
"return " + f + "}");
|
707
|
+
|
708
|
+
// Execute it against the current filter
|
709
|
+
r = g( r, f );
|
710
|
+
}
|
711
|
+
}
|
712
|
+
|
713
|
+
// Return an array of filtered elements (r)
|
714
|
+
// and the modified expression string (t)
|
715
|
+
return { r: r, t: t };
|
716
|
+
},
|
717
|
+
trim: function(t){
|
718
|
+
return t.replace(/^\s+|\s+$/g, "");
|
719
|
+
},
|
720
|
+
parents: function(a){
|
721
|
+
var b = [];
|
722
|
+
var c = a.parentNode;
|
723
|
+
while ( c && c != document ) {
|
724
|
+
b.push( c );
|
725
|
+
c = c.parentNode;
|
726
|
+
}
|
727
|
+
return b;
|
728
|
+
},
|
729
|
+
sibling: function(a,n) {
|
730
|
+
var type = [];
|
731
|
+
var tmp = a.parentNode.childNodes;
|
732
|
+
for ( var i = 0; i < tmp.length; i++ ) {
|
733
|
+
if ( tmp[i].nodeType == 1 )
|
734
|
+
type.push( tmp[i] );
|
735
|
+
if ( tmp[i] == a )
|
736
|
+
type.n = type.length - 1;
|
737
|
+
}
|
738
|
+
type.last = type.n == type.length - 1;
|
739
|
+
type.cur =
|
740
|
+
n == "even" && type.n % 2 == 0 ||
|
741
|
+
n == "odd" && type.n % 2 ||
|
742
|
+
type[n] == a;
|
743
|
+
type.prev = type[type.n - 1];
|
744
|
+
type.next = type[type.n + 1];
|
745
|
+
return type;
|
746
|
+
},
|
747
|
+
merge: function(a,b) {
|
748
|
+
var d = [];
|
749
|
+
|
750
|
+
// Move b over to the new array (this helps to avoid
|
751
|
+
// StaticNodeList instances)
|
752
|
+
for ( var k = 0; k < a.length; k++ )
|
753
|
+
d[k] = a[k];
|
754
|
+
|
755
|
+
// Now check for duplicates between a and b and only
|
756
|
+
// add the unique items
|
757
|
+
for ( var i = 0; i < b.length; i++ ) {
|
758
|
+
var c = true;
|
759
|
+
|
760
|
+
// The collision-checking process
|
761
|
+
for ( var j = 0; j < a.length; j++ )
|
762
|
+
if ( b[i] == a[j] )
|
763
|
+
c = false;
|
764
|
+
|
765
|
+
// If the item is unique, add it
|
766
|
+
if ( c )
|
767
|
+
d.push( b[i] );
|
768
|
+
}
|
769
|
+
|
770
|
+
return d;
|
771
|
+
},
|
772
|
+
grep: function(a,f,s) {
|
773
|
+
// If a string is passed in for the function, make a function
|
774
|
+
// for it (a handy shortcut)
|
775
|
+
if ( f.constructor == String )
|
776
|
+
f = new Function("a","i","return " + f);
|
777
|
+
|
778
|
+
var r = [];
|
779
|
+
|
780
|
+
// Go through the array, only saving the items
|
781
|
+
// that pass the validator function
|
782
|
+
for ( var i = 0; i < a.length; i++ )
|
783
|
+
if ( !s && f(a[i],i) || s && !f(a[i],i) )
|
784
|
+
r.push( a[i] );
|
785
|
+
|
786
|
+
return r;
|
787
|
+
},
|
788
|
+
map: function(a,f) {
|
789
|
+
// If a string is passed in for the function, make a function
|
790
|
+
// for it (a handy shortcut)
|
791
|
+
if ( f.constructor == String )
|
792
|
+
f = new Function("a","return " + f);
|
793
|
+
|
794
|
+
var r = [];
|
795
|
+
|
796
|
+
// Go through the array, translating each of the items to their
|
797
|
+
// new value (or values).
|
798
|
+
for ( var i = 0; i < a.length; i++ ) {
|
799
|
+
var t = f(a[i],i);
|
800
|
+
if ( t !== null && t != undefined ) {
|
801
|
+
if ( t.constructor != Array ) t = [t];
|
802
|
+
r = jQuery.merge( r, t );
|
803
|
+
}
|
804
|
+
}
|
805
|
+
return r;
|
806
|
+
},
|
807
|
+
|
808
|
+
/*
|
809
|
+
* A number of helper functions used for managing events.
|
810
|
+
* Many of the ideas behind this code orignated from Dean Edwards' addEvent library.
|
811
|
+
*/
|
812
|
+
event: {
|
813
|
+
|
814
|
+
// Bind an event to an element
|
815
|
+
// Original by Dean Edwards
|
816
|
+
add: function(element, type, handler) {
|
817
|
+
// For whatever reason, IE has trouble passing the window object
|
818
|
+
// around, causing it to be cloned in the process
|
819
|
+
if ( jQuery.browser.msie && element.setInterval != undefined )
|
820
|
+
element = window;
|
821
|
+
|
822
|
+
// Make sure that the function being executed has a unique ID
|
823
|
+
if ( !handler.guid )
|
824
|
+
handler.guid = this.guid++;
|
825
|
+
|
826
|
+
// Init the element's event structure
|
827
|
+
if (!element.events)
|
828
|
+
element.events = {};
|
829
|
+
|
830
|
+
// Get the current list of functions bound to this event
|
831
|
+
var handlers = element.events[type];
|
832
|
+
|
833
|
+
// If it hasn't been initialized yet
|
834
|
+
if (!handlers) {
|
835
|
+
// Init the event handler queue
|
836
|
+
handlers = element.events[type] = {};
|
837
|
+
|
838
|
+
// Remember an existing handler, if it's already there
|
839
|
+
if (element["on" + type])
|
840
|
+
handlers[0] = element["on" + type];
|
841
|
+
}
|
842
|
+
|
843
|
+
// Add the function to the element's handler list
|
844
|
+
handlers[handler.guid] = handler;
|
845
|
+
|
846
|
+
// And bind the global event handler to the element
|
847
|
+
element["on" + type] = this.handle;
|
848
|
+
|
849
|
+
// Remember the function in a global list (for triggering)
|
850
|
+
if (!this.global[type])
|
851
|
+
this.global[type] = [];
|
852
|
+
this.global[type].push( element );
|
853
|
+
},
|
854
|
+
|
855
|
+
guid: 1,
|
856
|
+
global: {},
|
857
|
+
|
858
|
+
// Detach an event or set of events from an element
|
859
|
+
remove: function(element, type, handler) {
|
860
|
+
if (element.events)
|
861
|
+
if (type && element.events[type])
|
862
|
+
if ( handler )
|
863
|
+
delete element.events[type][handler.guid];
|
864
|
+
else
|
865
|
+
for ( var i in element.events[type] )
|
866
|
+
delete element.events[type][i];
|
867
|
+
else
|
868
|
+
for ( var j in element.events )
|
869
|
+
this.remove( element, j );
|
870
|
+
},
|
871
|
+
|
872
|
+
trigger: function(type,data,element) {
|
873
|
+
// Touch up the incoming data
|
874
|
+
data = data || [];
|
875
|
+
|
876
|
+
// Handle a global trigger
|
877
|
+
if ( !element ) {
|
878
|
+
var g = this.global[type];
|
879
|
+
if ( g )
|
880
|
+
for ( var i = 0; i < g.length; i++ )
|
881
|
+
this.trigger( type, data, g[i] );
|
882
|
+
|
883
|
+
// Handle triggering a single element
|
884
|
+
} else if ( element["on" + type] ) {
|
885
|
+
// Pass along a fake event
|
886
|
+
data.unshift( this.fix({ type: type, target: element }) );
|
887
|
+
|
888
|
+
// Trigger the event
|
889
|
+
element["on" + type].apply( element, data );
|
890
|
+
}
|
891
|
+
},
|
892
|
+
|
893
|
+
handle: function(event) {
|
894
|
+
if ( typeof jQuery == "undefined" ) return;
|
895
|
+
|
896
|
+
event = event || jQuery.event.fix( window.event );
|
897
|
+
|
898
|
+
// If no correct event was found, fail
|
899
|
+
if ( !event ) return;
|
900
|
+
|
901
|
+
var returnValue = true;
|
902
|
+
|
903
|
+
var c = this.events[event.type];
|
904
|
+
|
905
|
+
for ( var j in c ) {
|
906
|
+
if ( c[j].apply( this, [event] ) === false ) {
|
907
|
+
event.preventDefault();
|
908
|
+
event.stopPropagation();
|
909
|
+
returnValue = false;
|
910
|
+
}
|
911
|
+
}
|
912
|
+
|
913
|
+
return returnValue;
|
914
|
+
},
|
915
|
+
|
916
|
+
fix: function(event) {
|
917
|
+
if ( event ) {
|
918
|
+
event.preventDefault = function() {
|
919
|
+
this.returnValue = false;
|
920
|
+
};
|
921
|
+
|
922
|
+
event.stopPropagation = function() {
|
923
|
+
this.cancelBubble = true;
|
924
|
+
};
|
925
|
+
}
|
926
|
+
|
927
|
+
return event;
|
928
|
+
}
|
929
|
+
|
930
|
+
}
|
931
|
+
});
|
932
|
+
|
933
|
+
new function() {
|
934
|
+
var b = navigator.userAgent.toLowerCase();
|
935
|
+
|
936
|
+
// Figure out what browser is being used
|
937
|
+
jQuery.browser = {
|
938
|
+
safari: /webkit/.test(b),
|
939
|
+
opera: /opera/.test(b),
|
940
|
+
msie: /msie/.test(b) && !/opera/.test(b),
|
941
|
+
mozilla: /mozilla/.test(b) && !/compatible/.test(b)
|
942
|
+
};
|
943
|
+
|
944
|
+
// Check to see if the W3C box model is being used
|
945
|
+
jQuery.boxModel = !jQuery.browser.msie || document.compatMode == "CSS1Compat";
|
946
|
+
};
|
947
|
+
|
948
|
+
jQuery.macros = {
|
949
|
+
to: {
|
950
|
+
appendTo: "append",
|
951
|
+
prependTo: "prepend",
|
952
|
+
insertBefore: "before",
|
953
|
+
insertAfter: "after"
|
954
|
+
},
|
955
|
+
|
956
|
+
|
957
|
+
css: "width,height,top,left,position,float,overflow,color,background".split(","),
|
958
|
+
|
959
|
+
filter: [ "eq", "lt", "gt", "contains" ],
|
960
|
+
|
961
|
+
attr: {
|
962
|
+
|
963
|
+
val: "value",
|
964
|
+
|
965
|
+
html: "innerHTML",
|
966
|
+
|
967
|
+
id: null,
|
968
|
+
|
969
|
+
title: null,
|
970
|
+
|
971
|
+
name: null,
|
972
|
+
|
973
|
+
href: null,
|
974
|
+
|
975
|
+
src: null,
|
976
|
+
|
977
|
+
rel: null
|
978
|
+
},
|
979
|
+
|
980
|
+
axis: {
|
981
|
+
|
982
|
+
parent: "a.parentNode",
|
983
|
+
|
984
|
+
ancestors: jQuery.parents,
|
985
|
+
|
986
|
+
parents: jQuery.parents,
|
987
|
+
|
988
|
+
next: "jQuery.sibling(a).next",
|
989
|
+
|
990
|
+
prev: "jQuery.sibling(a).prev",
|
991
|
+
|
992
|
+
siblings: jQuery.sibling,
|
993
|
+
|
994
|
+
children: "a.childNodes"
|
995
|
+
},
|
996
|
+
|
997
|
+
each: {
|
998
|
+
|
999
|
+
removeAttr: function( key ) {
|
1000
|
+
this.removeAttribute( key );
|
1001
|
+
},
|
1002
|
+
_show: function(){
|
1003
|
+
this.style.display = this.oldblock ? this.oldblock : "";
|
1004
|
+
if ( jQuery.css(this,"display") == "none" )
|
1005
|
+
this.style.display = "block";
|
1006
|
+
},
|
1007
|
+
_hide: function(){
|
1008
|
+
this.oldblock = this.oldblock || jQuery.css(this,"display");
|
1009
|
+
if ( this.oldblock == "none" )
|
1010
|
+
this.oldblock = "block";
|
1011
|
+
this.style.display = "none";
|
1012
|
+
},
|
1013
|
+
_toggle: function(){
|
1014
|
+
var d = jQuery.css(this,"display");
|
1015
|
+
$(this)[ !d || d == "none" ? "show" : "hide" ]();
|
1016
|
+
},
|
1017
|
+
addClass: function(c){
|
1018
|
+
jQuery.className.add(this,c);
|
1019
|
+
},
|
1020
|
+
removeClass: function(c){
|
1021
|
+
jQuery.className.remove(this,c);
|
1022
|
+
},
|
1023
|
+
toggleClass: function( c ){
|
1024
|
+
jQuery.className[ jQuery.className.has(this,c) ? "remove" : "add" ](this,c);
|
1025
|
+
},
|
1026
|
+
|
1027
|
+
remove: function(a){
|
1028
|
+
if ( !a || jQuery.filter( [this], a ).r )
|
1029
|
+
this.parentNode.removeChild( this );
|
1030
|
+
},
|
1031
|
+
empty: function(){
|
1032
|
+
while ( this.firstChild )
|
1033
|
+
this.removeChild( this.firstChild );
|
1034
|
+
},
|
1035
|
+
bind: function( type, fn ) {
|
1036
|
+
if ( fn.constructor == String )
|
1037
|
+
fn = new Function("e", ( !fn.indexOf(".") ? "$(this)" : "return " ) + fn);
|
1038
|
+
jQuery.event.add( this, type, fn );
|
1039
|
+
},
|
1040
|
+
|
1041
|
+
unbind: function( type, fn ) {
|
1042
|
+
jQuery.event.remove( this, type, fn );
|
1043
|
+
},
|
1044
|
+
trigger: function( type, data ) {
|
1045
|
+
jQuery.event.trigger( type, data, this );
|
1046
|
+
}
|
1047
|
+
}
|
1048
|
+
};
|
1049
|
+
jQuery.fn.extend({
|
1050
|
+
|
1051
|
+
// We're overriding the old toggle function, so
|
1052
|
+
// remember it for later
|
1053
|
+
//_toggle: jQuery.fn.toggle,
|
1054
|
+
toggle: function(a,b) {
|
1055
|
+
// If two functions are passed in, we're
|
1056
|
+
// toggling on a click
|
1057
|
+
return a && b ? this.click(function(e){
|
1058
|
+
// Figure out which function to execute
|
1059
|
+
this.last = this.last == a ? b : a;
|
1060
|
+
|
1061
|
+
// Make sure that clicks stop
|
1062
|
+
e.preventDefault();
|
1063
|
+
|
1064
|
+
// and execute the function
|
1065
|
+
return this.last.apply( this, [e] ) || false;
|
1066
|
+
}) :
|
1067
|
+
|
1068
|
+
// Otherwise, execute the old toggle function
|
1069
|
+
this._toggle();
|
1070
|
+
},
|
1071
|
+
|
1072
|
+
hover: function(f,g) {
|
1073
|
+
|
1074
|
+
// A private function for haandling mouse 'hovering'
|
1075
|
+
function handleHover(e) {
|
1076
|
+
// Check if mouse(over|out) are still within the same parent element
|
1077
|
+
var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
|
1078
|
+
|
1079
|
+
// Traverse up the tree
|
1080
|
+
while ( p && p != this ) p = p.parentNode;
|
1081
|
+
|
1082
|
+
// If we actually just moused on to a sub-element, ignore it
|
1083
|
+
if ( p == this ) return false;
|
1084
|
+
|
1085
|
+
// Execute the right function
|
1086
|
+
return (e.type == "mouseover" ? f : g).apply(this, [e]);
|
1087
|
+
}
|
1088
|
+
|
1089
|
+
// Bind the function to the two event listeners
|
1090
|
+
return this.mouseover(handleHover).mouseout(handleHover);
|
1091
|
+
},
|
1092
|
+
ready: function(f) {
|
1093
|
+
// If the DOM is already ready
|
1094
|
+
if ( jQuery.isReady )
|
1095
|
+
// Execute the function immediately
|
1096
|
+
f.apply( document );
|
1097
|
+
|
1098
|
+
// Otherwise, remember the function for later
|
1099
|
+
else {
|
1100
|
+
// Add the function to the wait list
|
1101
|
+
jQuery.readyList.push( f );
|
1102
|
+
}
|
1103
|
+
|
1104
|
+
return this;
|
1105
|
+
}
|
1106
|
+
});
|
1107
|
+
|
1108
|
+
jQuery.extend({
|
1109
|
+
/*
|
1110
|
+
* All the code that makes DOM Ready work nicely.
|
1111
|
+
*/
|
1112
|
+
isReady: false,
|
1113
|
+
readyList: [],
|
1114
|
+
|
1115
|
+
// Handle when the DOM is ready
|
1116
|
+
ready: function() {
|
1117
|
+
// Make sure that the DOM is not already loaded
|
1118
|
+
if ( !jQuery.isReady ) {
|
1119
|
+
// Remember that the DOM is ready
|
1120
|
+
jQuery.isReady = true;
|
1121
|
+
|
1122
|
+
// If there are functions bound, to execute
|
1123
|
+
if ( jQuery.readyList ) {
|
1124
|
+
// Execute all of them
|
1125
|
+
for ( var i = 0; i < jQuery.readyList.length; i++ )
|
1126
|
+
jQuery.readyList[i].apply( document );
|
1127
|
+
|
1128
|
+
// Reset the list of functions
|
1129
|
+
jQuery.readyList = null;
|
1130
|
+
}
|
1131
|
+
}
|
1132
|
+
}
|
1133
|
+
});
|
1134
|
+
|
1135
|
+
new function(){
|
1136
|
+
|
1137
|
+
var e = ("blur,focus,load,resize,scroll,unload,click,dblclick," +
|
1138
|
+
"mousedown,mouseup,mousemove,mouseover,mouseout,change,reset,select," +
|
1139
|
+
"submit,keydown,keypress,keyup,error").split(",");
|
1140
|
+
|
1141
|
+
// Go through all the event names, but make sure that
|
1142
|
+
// it is enclosed properly
|
1143
|
+
for ( var i = 0; i < e.length; i++ ) new function(){
|
1144
|
+
|
1145
|
+
var o = e[i];
|
1146
|
+
|
1147
|
+
// Handle event binding
|
1148
|
+
jQuery.fn[o] = function(f){
|
1149
|
+
return f ? this.bind(o, f) : this.trigger(o);
|
1150
|
+
};
|
1151
|
+
|
1152
|
+
// Handle event unbinding
|
1153
|
+
jQuery.fn["un"+o] = function(f){ return this.unbind(o, f); };
|
1154
|
+
|
1155
|
+
// Finally, handle events that only fire once
|
1156
|
+
jQuery.fn["one"+o] = function(f){
|
1157
|
+
// Attach the event listener
|
1158
|
+
return this.each(function(){
|
1159
|
+
|
1160
|
+
var count = 0;
|
1161
|
+
|
1162
|
+
// Add the event
|
1163
|
+
jQuery.event.add( this, o, function(e){
|
1164
|
+
// If this function has already been executed, stop
|
1165
|
+
if ( count++ ) return;
|
1166
|
+
|
1167
|
+
// And execute the bound function
|
1168
|
+
return f.apply(this, [e]);
|
1169
|
+
});
|
1170
|
+
});
|
1171
|
+
};
|
1172
|
+
|
1173
|
+
};
|
1174
|
+
|
1175
|
+
// If Mozilla is used
|
1176
|
+
if ( jQuery.browser.mozilla || jQuery.browser.opera ) {
|
1177
|
+
// Use the handy event callback
|
1178
|
+
document.addEventListener( "DOMContentLoaded", jQuery.ready, false );
|
1179
|
+
|
1180
|
+
// If IE is used, use the excellent hack by Matthias Miller
|
1181
|
+
// http://www.outofhanwell.com/blog/index.php?title=the_window_onload_problem_revisited
|
1182
|
+
} else if ( jQuery.browser.msie ) {
|
1183
|
+
|
1184
|
+
// Only works if you document.write() it
|
1185
|
+
document.write("<scr" + "ipt id=__ie_init defer=true " +
|
1186
|
+
"src=//:><\/script>");
|
1187
|
+
|
1188
|
+
// Use the defer script hack
|
1189
|
+
var script = document.getElementById("__ie_init");
|
1190
|
+
script.onreadystatechange = function() {
|
1191
|
+
if ( this.readyState == "complete" )
|
1192
|
+
jQuery.ready();
|
1193
|
+
};
|
1194
|
+
|
1195
|
+
// Clear from memory
|
1196
|
+
script = null;
|
1197
|
+
|
1198
|
+
// If Safari is used
|
1199
|
+
} else if ( jQuery.browser.safari ) {
|
1200
|
+
// Continually check to see if the document.readyState is valid
|
1201
|
+
jQuery.safariTimer = setInterval(function(){
|
1202
|
+
// loaded and complete are both valid states
|
1203
|
+
if ( document.readyState == "loaded" ||
|
1204
|
+
document.readyState == "complete" ) {
|
1205
|
+
|
1206
|
+
// If either one are found, remove the timer
|
1207
|
+
clearInterval( jQuery.safariTimer );
|
1208
|
+
jQuery.safariTimer = null;
|
1209
|
+
|
1210
|
+
// and execute any waiting functions
|
1211
|
+
jQuery.ready();
|
1212
|
+
}
|
1213
|
+
}, 10);
|
1214
|
+
}
|
1215
|
+
|
1216
|
+
// A fallback to window.onload, that will always work
|
1217
|
+
jQuery.event.add( window, "load", jQuery.ready );
|
1218
|
+
|
1219
|
+
};
|
1220
|
+
jQuery.fn.extend({
|
1221
|
+
|
1222
|
+
// overwrite the old show method
|
1223
|
+
//_show: jQuery.fn.show,
|
1224
|
+
|
1225
|
+
show: function(speed,callback){
|
1226
|
+
return speed ? this.animate({
|
1227
|
+
height: "show", width: "show", opacity: "show"
|
1228
|
+
}, speed, callback) : this._show();
|
1229
|
+
},
|
1230
|
+
|
1231
|
+
// Overwrite the old hide method
|
1232
|
+
//_hide: jQuery.fn.hide,
|
1233
|
+
|
1234
|
+
hide: function(speed,callback){
|
1235
|
+
return speed ? this.animate({
|
1236
|
+
height: "hide", width: "hide", opacity: "hide"
|
1237
|
+
}, speed, callback) : this._hide();
|
1238
|
+
},
|
1239
|
+
|
1240
|
+
slideDown: function(speed,callback){
|
1241
|
+
return this.animate({height: "show"}, speed, callback);
|
1242
|
+
},
|
1243
|
+
|
1244
|
+
slideUp: function(speed,callback){
|
1245
|
+
return this.animate({height: "hide"}, speed, callback);
|
1246
|
+
},
|
1247
|
+
|
1248
|
+
fadeIn: function(speed,callback){
|
1249
|
+
return this.animate({opacity: "show"}, speed, callback);
|
1250
|
+
},
|
1251
|
+
|
1252
|
+
fadeOut: function(speed,callback){
|
1253
|
+
return this.animate({opacity: "hide"}, speed, callback);
|
1254
|
+
},
|
1255
|
+
|
1256
|
+
fadeTo: function(speed,to,callback){
|
1257
|
+
return this.animate({opacity: to}, speed, callback);
|
1258
|
+
},
|
1259
|
+
animate: function(prop,speed,callback) {
|
1260
|
+
return this.queue(function(){
|
1261
|
+
var i = 0;
|
1262
|
+
for ( var p in prop ) {
|
1263
|
+
var e = new jQuery.fx( this, jQuery.speed(speed,callback,i++), p );
|
1264
|
+
if ( prop[p].constructor == Number )
|
1265
|
+
e.custom( e.cur(), prop[p] );
|
1266
|
+
else
|
1267
|
+
e[ prop[p] ]( prop );
|
1268
|
+
}
|
1269
|
+
});
|
1270
|
+
},
|
1271
|
+
queue: function(type,fn){
|
1272
|
+
if ( !fn ) {
|
1273
|
+
fn = type;
|
1274
|
+
type = "fx";
|
1275
|
+
}
|
1276
|
+
|
1277
|
+
return this.each(function(){
|
1278
|
+
if ( !this.queue )
|
1279
|
+
this.queue = {};
|
1280
|
+
|
1281
|
+
if ( !this.queue[type] )
|
1282
|
+
this.queue[type] = [];
|
1283
|
+
|
1284
|
+
this.queue[type].push( fn );
|
1285
|
+
|
1286
|
+
if ( this.queue[type].length == 1 )
|
1287
|
+
fn.apply(this);
|
1288
|
+
});
|
1289
|
+
}
|
1290
|
+
|
1291
|
+
});
|
1292
|
+
|
1293
|
+
jQuery.extend({
|
1294
|
+
|
1295
|
+
setAuto: function(e,p) {
|
1296
|
+
if ( e.notAuto ) return;
|
1297
|
+
|
1298
|
+
if ( p == "height" && e.scrollHeight != parseInt(jQuery.curCSS(e,p)) ) return;
|
1299
|
+
if ( p == "width" && e.scrollWidth != parseInt(jQuery.curCSS(e,p)) ) return;
|
1300
|
+
|
1301
|
+
// Remember the original height
|
1302
|
+
var a = e.style[p];
|
1303
|
+
|
1304
|
+
// Figure out the size of the height right now
|
1305
|
+
var o = jQuery.curCSS(e,p,1);
|
1306
|
+
|
1307
|
+
if ( p == "height" && e.scrollHeight != o ||
|
1308
|
+
p == "width" && e.scrollWidth != o ) return;
|
1309
|
+
|
1310
|
+
// Set the height to auto
|
1311
|
+
e.style[p] = e.currentStyle ? "" : "auto";
|
1312
|
+
|
1313
|
+
// See what the size of "auto" is
|
1314
|
+
var n = jQuery.curCSS(e,p,1);
|
1315
|
+
|
1316
|
+
// Revert back to the original size
|
1317
|
+
if ( o != n && n != "auto" ) {
|
1318
|
+
e.style[p] = a;
|
1319
|
+
e.notAuto = true;
|
1320
|
+
}
|
1321
|
+
},
|
1322
|
+
|
1323
|
+
speed: function(s,o,i) {
|
1324
|
+
o = o || {};
|
1325
|
+
|
1326
|
+
if ( o.constructor == Function )
|
1327
|
+
o = { complete: o };
|
1328
|
+
|
1329
|
+
var ss = { slow: 600, fast: 200 };
|
1330
|
+
o.duration = (s && s.constructor == Number ? s : ss[s]) || 400;
|
1331
|
+
|
1332
|
+
// Queueing
|
1333
|
+
o.oldComplete = o.complete;
|
1334
|
+
o.complete = function(){
|
1335
|
+
jQuery.dequeue(this, "fx");
|
1336
|
+
if ( o.oldComplete && o.oldComplete.constructor == Function )
|
1337
|
+
o.oldComplete.apply( this );
|
1338
|
+
};
|
1339
|
+
|
1340
|
+
if ( i > 0 )
|
1341
|
+
o.complete = null;
|
1342
|
+
|
1343
|
+
return o;
|
1344
|
+
},
|
1345
|
+
|
1346
|
+
queue: {},
|
1347
|
+
|
1348
|
+
dequeue: function(elem,type){
|
1349
|
+
type = type || "fx";
|
1350
|
+
|
1351
|
+
if ( elem.queue && elem.queue[type] ) {
|
1352
|
+
// Remove self
|
1353
|
+
elem.queue[type].shift();
|
1354
|
+
|
1355
|
+
// Get next function
|
1356
|
+
var f = elem.queue[type][0];
|
1357
|
+
|
1358
|
+
if ( f ) f.apply( elem );
|
1359
|
+
}
|
1360
|
+
},
|
1361
|
+
|
1362
|
+
/*
|
1363
|
+
* I originally wrote fx() as a clone of moo.fx and in the process
|
1364
|
+
* of making it small in size the code became illegible to sane
|
1365
|
+
* people. You've been warned.
|
1366
|
+
*/
|
1367
|
+
|
1368
|
+
fx: function( elem, options, prop ){
|
1369
|
+
|
1370
|
+
var z = this;
|
1371
|
+
|
1372
|
+
// The users options
|
1373
|
+
z.o = {
|
1374
|
+
duration: options.duration || 400,
|
1375
|
+
complete: options.complete,
|
1376
|
+
step: options.step
|
1377
|
+
};
|
1378
|
+
|
1379
|
+
// The element
|
1380
|
+
z.el = elem;
|
1381
|
+
|
1382
|
+
// The styles
|
1383
|
+
var y = z.el.style;
|
1384
|
+
|
1385
|
+
// Simple function for setting a style value
|
1386
|
+
z.a = function(){
|
1387
|
+
if ( options.step )
|
1388
|
+
options.step.apply( elem, [ z.now ] );
|
1389
|
+
|
1390
|
+
if ( prop == "opacity" ) {
|
1391
|
+
if (z.now == 1) z.now = 0.9999;
|
1392
|
+
if (window.ActiveXObject)
|
1393
|
+
y.filter = "alpha(opacity=" + z.now*100 + ")";
|
1394
|
+
else
|
1395
|
+
y.opacity = z.now;
|
1396
|
+
|
1397
|
+
// My hate for IE will never die
|
1398
|
+
} else if ( parseInt(z.now) )
|
1399
|
+
y[prop] = parseInt(z.now) + "px";
|
1400
|
+
y.display = "block";
|
1401
|
+
};
|
1402
|
+
|
1403
|
+
// Figure out the maximum number to run to
|
1404
|
+
z.max = function(){
|
1405
|
+
return parseFloat( jQuery.css(z.el,prop) );
|
1406
|
+
};
|
1407
|
+
|
1408
|
+
// Get the current size
|
1409
|
+
z.cur = function(){
|
1410
|
+
return parseFloat( jQuery.curCSS(z.el, prop) ) || z.max();
|
1411
|
+
};
|
1412
|
+
|
1413
|
+
// Start an animation from one number to another
|
1414
|
+
z.custom = function(from,to){
|
1415
|
+
z.startTime = (new Date()).getTime();
|
1416
|
+
z.now = from;
|
1417
|
+
z.a();
|
1418
|
+
|
1419
|
+
z.timer = setInterval(function(){
|
1420
|
+
z.step(from, to);
|
1421
|
+
}, 13);
|
1422
|
+
};
|
1423
|
+
|
1424
|
+
// Simple 'show' function
|
1425
|
+
z.show = function( p ){
|
1426
|
+
if ( !z.el.orig ) z.el.orig = {};
|
1427
|
+
|
1428
|
+
// Remember where we started, so that we can go back to it later
|
1429
|
+
z.el.orig[prop] = this.cur();
|
1430
|
+
|
1431
|
+
z.custom( 0, z.el.orig[prop] );
|
1432
|
+
|
1433
|
+
// Stupid IE, look what you made me do
|
1434
|
+
if ( prop != "opacity" )
|
1435
|
+
y[prop] = "1px";
|
1436
|
+
};
|
1437
|
+
|
1438
|
+
// Simple 'hide' function
|
1439
|
+
z.hide = function(){
|
1440
|
+
if ( !z.el.orig ) z.el.orig = {};
|
1441
|
+
|
1442
|
+
// Remember where we started, so that we can go back to it later
|
1443
|
+
z.el.orig[prop] = this.cur();
|
1444
|
+
|
1445
|
+
z.o.hide = true;
|
1446
|
+
|
1447
|
+
// Begin the animation
|
1448
|
+
z.custom(z.cur(),0);
|
1449
|
+
};
|
1450
|
+
|
1451
|
+
// IE has trouble with opacity if it does not have layout
|
1452
|
+
if ( jQuery.browser.msie && !z.el.currentStyle.hasLayout )
|
1453
|
+
y.zoom = "1";
|
1454
|
+
|
1455
|
+
// Remember the overflow of the element
|
1456
|
+
if ( !z.el.oldOverlay )
|
1457
|
+
z.el.oldOverflow = jQuery.css( z.el, "overflow" );
|
1458
|
+
|
1459
|
+
// Make sure that nothing sneaks out
|
1460
|
+
//if ( z.el.oldOverlay == "visible" )
|
1461
|
+
y.overflow = "hidden";
|
1462
|
+
|
1463
|
+
// Each step of an animation
|
1464
|
+
z.step = function(firstNum, lastNum){
|
1465
|
+
var t = (new Date()).getTime();
|
1466
|
+
|
1467
|
+
if (t > z.o.duration + z.startTime) {
|
1468
|
+
// Stop the timer
|
1469
|
+
clearInterval(z.timer);
|
1470
|
+
z.timer = null;
|
1471
|
+
|
1472
|
+
z.now = lastNum;
|
1473
|
+
z.a();
|
1474
|
+
|
1475
|
+
// Hide the element if the "hide" operation was done
|
1476
|
+
if ( z.o.hide ) y.display = 'none';
|
1477
|
+
|
1478
|
+
// Reset the overflow
|
1479
|
+
y.overflow = z.el.oldOverflow;
|
1480
|
+
|
1481
|
+
// Reset the property, if the item has been hidden
|
1482
|
+
if ( z.o.hide )
|
1483
|
+
y[ prop ] = z.el.orig[ prop ].constructor == Number && prop != "opacity" ?
|
1484
|
+
z.el.orig[prop] + "px" : z.el.orig[prop];
|
1485
|
+
|
1486
|
+
// set its height and/or width to auto
|
1487
|
+
if ( prop == 'height' || prop == 'width' )
|
1488
|
+
jQuery.setAuto( z.el, prop );
|
1489
|
+
|
1490
|
+
// If a callback was provided, execute it
|
1491
|
+
if( z.o.complete && z.o.complete.constructor == Function )
|
1492
|
+
// Execute the complete function
|
1493
|
+
z.o.complete.apply( z.el );
|
1494
|
+
} else {
|
1495
|
+
// Figure out where in the animation we are and set the number
|
1496
|
+
var p = (t - this.startTime) / z.o.duration;
|
1497
|
+
z.now = ((-Math.cos(p*Math.PI)/2) + 0.5) * (lastNum-firstNum) + firstNum;
|
1498
|
+
|
1499
|
+
// Perform the next step of the animation
|
1500
|
+
z.a();
|
1501
|
+
}
|
1502
|
+
};
|
1503
|
+
|
1504
|
+
}
|
1505
|
+
|
1506
|
+
});
|
1507
|
+
// AJAX Plugin
|
1508
|
+
// Docs Here:
|
1509
|
+
// http://jquery.com/docs/ajax/
|
1510
|
+
jQuery.fn.loadIfModified = function( url, params, callback ) {
|
1511
|
+
this.load( url, params, callback, 1 );
|
1512
|
+
};
|
1513
|
+
|
1514
|
+
jQuery.fn.load = function( url, params, callback, ifModified ) {
|
1515
|
+
if ( url.constructor == Function )
|
1516
|
+
return this.bind("load", url);
|
1517
|
+
|
1518
|
+
callback = callback || function(){};
|
1519
|
+
|
1520
|
+
// Default to a GET request
|
1521
|
+
var type = "GET";
|
1522
|
+
|
1523
|
+
// If the second parameter was provided
|
1524
|
+
if ( params ) {
|
1525
|
+
// If it's a function
|
1526
|
+
if ( params.constructor == Function ) {
|
1527
|
+
// We assume that it's the callback
|
1528
|
+
callback = params;
|
1529
|
+
params = null;
|
1530
|
+
|
1531
|
+
// Otherwise, build a param string
|
1532
|
+
} else {
|
1533
|
+
params = jQuery.param( params );
|
1534
|
+
type = "POST";
|
1535
|
+
}
|
1536
|
+
}
|
1537
|
+
|
1538
|
+
var self = this;
|
1539
|
+
|
1540
|
+
// Request the remote document
|
1541
|
+
jQuery.ajax( type, url, params,function(res, status){
|
1542
|
+
|
1543
|
+
if ( status == "success" || !ifModified && status == "notmodified" ) {
|
1544
|
+
// Inject the HTML into all the matched elements
|
1545
|
+
self.html(res.responseText).each( callback, [res.responseText, status] );
|
1546
|
+
|
1547
|
+
// Execute all the scripts inside of the newly-injected HTML
|
1548
|
+
$("script", self).each(function(){
|
1549
|
+
if ( this.src )
|
1550
|
+
$.getScript( this.src );
|
1551
|
+
else
|
1552
|
+
eval.call( window, this.text || this.textContent || this.innerHTML || "" );
|
1553
|
+
});
|
1554
|
+
} else
|
1555
|
+
callback.apply( self, [res.responseText, status] );
|
1556
|
+
|
1557
|
+
}, ifModified);
|
1558
|
+
|
1559
|
+
return this;
|
1560
|
+
};
|
1561
|
+
|
1562
|
+
// If IE is used, create a wrapper for the XMLHttpRequest object
|
1563
|
+
if ( jQuery.browser.msie )
|
1564
|
+
XMLHttpRequest = function(){
|
1565
|
+
return new ActiveXObject(
|
1566
|
+
navigator.userAgent.indexOf("MSIE 5") >= 0 ?
|
1567
|
+
"Microsoft.XMLHTTP" : "Msxml2.XMLHTTP"
|
1568
|
+
);
|
1569
|
+
};
|
1570
|
+
|
1571
|
+
// Attach a bunch of functions for handling common AJAX events
|
1572
|
+
new function(){
|
1573
|
+
var e = "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess".split(',');
|
1574
|
+
|
1575
|
+
for ( var i = 0; i < e.length; i++ ) new function(){
|
1576
|
+
var o = e[i];
|
1577
|
+
jQuery.fn[o] = function(f){
|
1578
|
+
return this.bind(o, f);
|
1579
|
+
};
|
1580
|
+
};
|
1581
|
+
};
|
1582
|
+
|
1583
|
+
jQuery.extend({
|
1584
|
+
get: function( url, data, callback, type, ifModified ) {
|
1585
|
+
if ( data.constructor == Function ) {
|
1586
|
+
type = callback;
|
1587
|
+
callback = data;
|
1588
|
+
data = null;
|
1589
|
+
}
|
1590
|
+
|
1591
|
+
if ( data ) url += "?" + jQuery.param(data);
|
1592
|
+
|
1593
|
+
// Build and start the HTTP Request
|
1594
|
+
jQuery.ajax( "GET", url, null, function(r, status) {
|
1595
|
+
if ( callback ) callback( jQuery.httpData(r,type), status );
|
1596
|
+
}, ifModified);
|
1597
|
+
},
|
1598
|
+
|
1599
|
+
getIfModified: function( url, data, callback, type ) {
|
1600
|
+
jQuery.get(url, data, callback, type, 1);
|
1601
|
+
},
|
1602
|
+
|
1603
|
+
getScript: function( url, data, callback ) {
|
1604
|
+
jQuery.get(url, data, callback, "script");
|
1605
|
+
},
|
1606
|
+
post: function( url, data, callback, type ) {
|
1607
|
+
// Build and start the HTTP Request
|
1608
|
+
jQuery.ajax( "POST", url, jQuery.param(data), function(r, status) {
|
1609
|
+
if ( callback ) callback( jQuery.httpData(r,type), status );
|
1610
|
+
});
|
1611
|
+
},
|
1612
|
+
|
1613
|
+
// timeout (ms)
|
1614
|
+
timeout: 0,
|
1615
|
+
|
1616
|
+
ajaxTimeout: function(timeout) {
|
1617
|
+
jQuery.timeout = timeout;
|
1618
|
+
},
|
1619
|
+
|
1620
|
+
// Last-Modified header cache for next request
|
1621
|
+
lastModified: {},
|
1622
|
+
ajax: function( type, url, data, ret, ifModified ) {
|
1623
|
+
// If only a single argument was passed in,
|
1624
|
+
// assume that it is a object of key/value pairs
|
1625
|
+
if ( !url ) {
|
1626
|
+
ret = type.complete;
|
1627
|
+
var success = type.success;
|
1628
|
+
var error = type.error;
|
1629
|
+
data = type.data;
|
1630
|
+
url = type.url;
|
1631
|
+
type = type.type;
|
1632
|
+
}
|
1633
|
+
|
1634
|
+
// Watch for a new set of requests
|
1635
|
+
if ( ! jQuery.active++ )
|
1636
|
+
jQuery.event.trigger( "ajaxStart" );
|
1637
|
+
|
1638
|
+
var requestDone = false;
|
1639
|
+
|
1640
|
+
// Create the request object
|
1641
|
+
var xml = new XMLHttpRequest();
|
1642
|
+
|
1643
|
+
// Open the socket
|
1644
|
+
xml.open(type || "GET", url, true);
|
1645
|
+
|
1646
|
+
// Set the correct header, if data is being sent
|
1647
|
+
if ( data )
|
1648
|
+
xml.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
1649
|
+
|
1650
|
+
// Set the If-Modified-Since header, if ifModified mode.
|
1651
|
+
if ( ifModified )
|
1652
|
+
xml.setRequestHeader("If-Modified-Since",
|
1653
|
+
jQuery.lastModified[url] || "Thu, 01 Jan 1970 00:00:00 GMT" );
|
1654
|
+
|
1655
|
+
// Set header so calling script knows that it's an XMLHttpRequest
|
1656
|
+
xml.setRequestHeader("X-Requested-With", "XMLHttpRequest");
|
1657
|
+
|
1658
|
+
// Make sure the browser sends the right content length
|
1659
|
+
if ( xml.overrideMimeType )
|
1660
|
+
xml.setRequestHeader("Connection", "close");
|
1661
|
+
|
1662
|
+
// Wait for a response to come back
|
1663
|
+
var onreadystatechange = function(istimeout){
|
1664
|
+
// The transfer is complete and the data is available, or the request timed out
|
1665
|
+
if ( xml && (xml.readyState == 4 || istimeout == "timeout") ) {
|
1666
|
+
requestDone = true;
|
1667
|
+
|
1668
|
+
var status = jQuery.httpSuccess( xml ) && istimeout != "timeout" ?
|
1669
|
+
ifModified && jQuery.httpNotModified( xml, url ) ? "notmodified" : "success" : "error";
|
1670
|
+
|
1671
|
+
// Make sure that the request was successful or notmodified
|
1672
|
+
if ( status != "error" ) {
|
1673
|
+
// Cache Last-Modified header, if ifModified mode.
|
1674
|
+
var modRes = xml.getResponseHeader("Last-Modified");
|
1675
|
+
if ( ifModified && modRes ) jQuery.lastModified[url] = modRes;
|
1676
|
+
|
1677
|
+
// If a local callback was specified, fire it
|
1678
|
+
if ( success ) success( xml, status );
|
1679
|
+
|
1680
|
+
// Fire the global callback
|
1681
|
+
jQuery.event.trigger( "ajaxSuccess" );
|
1682
|
+
|
1683
|
+
// Otherwise, the request was not successful
|
1684
|
+
} else {
|
1685
|
+
// If a local callback was specified, fire it
|
1686
|
+
if ( error ) error( xml, status );
|
1687
|
+
|
1688
|
+
// Fire the global callback
|
1689
|
+
jQuery.event.trigger( "ajaxError" );
|
1690
|
+
}
|
1691
|
+
|
1692
|
+
// The request was completed
|
1693
|
+
jQuery.event.trigger( "ajaxComplete" );
|
1694
|
+
|
1695
|
+
// Handle the global AJAX counter
|
1696
|
+
if ( ! --jQuery.active )
|
1697
|
+
jQuery.event.trigger( "ajaxStop" );
|
1698
|
+
|
1699
|
+
// Process result
|
1700
|
+
if ( ret ) ret(xml, status);
|
1701
|
+
|
1702
|
+
// Stop memory leaks
|
1703
|
+
xml.onreadystatechange = function(){};
|
1704
|
+
xml = null;
|
1705
|
+
|
1706
|
+
}
|
1707
|
+
};
|
1708
|
+
xml.onreadystatechange = onreadystatechange;
|
1709
|
+
|
1710
|
+
// Timeout checker
|
1711
|
+
if(jQuery.timeout > 0)
|
1712
|
+
setTimeout(function(){
|
1713
|
+
// Check to see if the request is still happening
|
1714
|
+
if (xml) {
|
1715
|
+
// Cancel the request
|
1716
|
+
xml.abort();
|
1717
|
+
|
1718
|
+
if ( !requestDone ) onreadystatechange( "timeout" );
|
1719
|
+
|
1720
|
+
// Clear from memory
|
1721
|
+
xml = null;
|
1722
|
+
}
|
1723
|
+
}, jQuery.timeout);
|
1724
|
+
|
1725
|
+
// Send the data
|
1726
|
+
xml.send(data);
|
1727
|
+
},
|
1728
|
+
|
1729
|
+
// Counter for holding the number of active queries
|
1730
|
+
active: 0,
|
1731
|
+
|
1732
|
+
// Determines if an XMLHttpRequest was successful or not
|
1733
|
+
httpSuccess: function(r) {
|
1734
|
+
try {
|
1735
|
+
return !r.status && location.protocol == "file:" ||
|
1736
|
+
( r.status >= 200 && r.status < 300 ) || r.status == 304 ||
|
1737
|
+
jQuery.browser.safari && r.status == undefined;
|
1738
|
+
} catch(e){}
|
1739
|
+
|
1740
|
+
return false;
|
1741
|
+
},
|
1742
|
+
|
1743
|
+
// Determines if an XMLHttpRequest returns NotModified
|
1744
|
+
httpNotModified: function(xml, url) {
|
1745
|
+
try {
|
1746
|
+
var xmlRes = xml.getResponseHeader("Last-Modified");
|
1747
|
+
|
1748
|
+
// Firefox always returns 200. check Last-Modified date
|
1749
|
+
return xml.status == 304 || xmlRes == jQuery.lastModified[url] ||
|
1750
|
+
jQuery.browser.safari && xml.status == undefined;
|
1751
|
+
} catch(e){}
|
1752
|
+
|
1753
|
+
return false;
|
1754
|
+
},
|
1755
|
+
|
1756
|
+
// Get the data out of an XMLHttpRequest.
|
1757
|
+
// Return parsed XML if content-type header is "xml" and type is "xml" or omitted,
|
1758
|
+
// otherwise return plain text.
|
1759
|
+
httpData: function(r,type) {
|
1760
|
+
var ct = r.getResponseHeader("content-type");
|
1761
|
+
var data = !type && ct && ct.indexOf("xml") >= 0;
|
1762
|
+
data = type == "xml" || data ? r.responseXML : r.responseText;
|
1763
|
+
|
1764
|
+
// If the type is "script", eval it
|
1765
|
+
if ( type == "script" ) eval.call( window, data );
|
1766
|
+
|
1767
|
+
return data;
|
1768
|
+
},
|
1769
|
+
|
1770
|
+
// Serialize an array of form elements or a set of
|
1771
|
+
// key/values into a query string
|
1772
|
+
param: function(a) {
|
1773
|
+
var s = [];
|
1774
|
+
|
1775
|
+
// If an array was passed in, assume that it is an array
|
1776
|
+
// of form elements
|
1777
|
+
if ( a.constructor == Array ) {
|
1778
|
+
// Serialize the form elements
|
1779
|
+
for ( var i = 0; i < a.length; i++ )
|
1780
|
+
s.push( a[i].name + "=" + encodeURIComponent( a[i].value ) );
|
1781
|
+
|
1782
|
+
// Otherwise, assume that it's an object of key/value pairs
|
1783
|
+
} else {
|
1784
|
+
// Serialize the key/values
|
1785
|
+
for ( var j in a )
|
1786
|
+
s.push( j + "=" + encodeURIComponent( a[j] ) );
|
1787
|
+
}
|
1788
|
+
|
1789
|
+
// Return the resulting serialization
|
1790
|
+
return s.join("&");
|
1791
|
+
}
|
1792
|
+
|
1793
|
+
});
|