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