| 12 | | |
|---|
| 13 | | // Map over jQuery in case of overwrite |
|---|
| 14 | | var _jQuery = window.jQuery, |
|---|
| 15 | | // Map over the $ in case of overwrite |
|---|
| 16 | | _$ = window.$; |
|---|
| 17 | | |
|---|
| 18 | | var jQuery = window.jQuery = window.$ = function( selector, context ) { |
|---|
| 19 | | // The jQuery object is actually just the init constructor 'enhanced' |
|---|
| 20 | | return new jQuery.fn.init( selector, context ); |
|---|
| 21 | | }; |
|---|
| 22 | | |
|---|
| 23 | | // A simple way to check for HTML strings or ID strings |
|---|
| 24 | | // (both of which we optimize for) |
|---|
| 25 | | var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/, |
|---|
| 26 | | |
|---|
| 27 | | // Is it a simple selector |
|---|
| 28 | | isSimple = /^.[^:#\[\.]*$/, |
|---|
| 29 | | |
|---|
| 30 | | // Will speed up references to undefined, and allows munging its name. |
|---|
| 31 | | undefined; |
|---|
| 32 | | |
|---|
| 33 | | jQuery.fn = jQuery.prototype = { |
|---|
| 34 | | init: function( selector, context ) { |
|---|
| 35 | | // Make sure that a selection was provided |
|---|
| 36 | | selector = selector || document; |
|---|
| 37 | | |
|---|
| 38 | | // Handle $(DOMElement) |
|---|
| 39 | | if ( selector.nodeType ) { |
|---|
| 40 | | this[0] = selector; |
|---|
| 41 | | this.length = 1; |
|---|
| 42 | | return this; |
|---|
| 43 | | } |
|---|
| 44 | | // Handle HTML strings |
|---|
| 45 | | if ( typeof selector == "string" ) { |
|---|
| 46 | | // Are we dealing with HTML string or an ID? |
|---|
| 47 | | var match = quickExpr.exec( selector ); |
|---|
| 48 | | |
|---|
| 49 | | // Verify a match, and that no context was specified for #id |
|---|
| 50 | | if ( match && (match[1] || !context) ) { |
|---|
| 51 | | |
|---|
| 52 | | // HANDLE: $(html) -> $(array) |
|---|
| 53 | | if ( match[1] ) |
|---|
| 54 | | selector = jQuery.clean( [ match[1] ], context ); |
|---|
| 55 | | |
|---|
| 56 | | // HANDLE: $("#id") |
|---|
| 57 | | else { |
|---|
| 58 | | var elem = document.getElementById( match[3] ); |
|---|
| 59 | | |
|---|
| 60 | | // Make sure an element was located |
|---|
| 61 | | if ( elem ){ |
|---|
| 62 | | // Handle the case where IE and Opera return items |
|---|
| 63 | | // by name instead of ID |
|---|
| 64 | | if ( elem.id != match[3] ) |
|---|
| 65 | | return jQuery().find( selector ); |
|---|
| 66 | | |
|---|
| 67 | | // Otherwise, we inject the element directly into the jQuery object |
|---|
| 68 | | return jQuery( elem ); |
|---|
| 69 | | } |
|---|
| 70 | | selector = []; |
|---|
| 71 | | } |
|---|
| 72 | | |
|---|
| 73 | | // HANDLE: $(expr, [context]) |
|---|
| 74 | | // (which is just equivalent to: $(content).find(expr) |
|---|
| 75 | | } else |
|---|
| 76 | | return jQuery( context ).find( selector ); |
|---|
| 77 | | |
|---|
| 78 | | // HANDLE: $(function) |
|---|
| 79 | | // Shortcut for document ready |
|---|
| 80 | | } else if ( jQuery.isFunction( selector ) ) |
|---|
| 81 | | return jQuery( document )[ jQuery.fn.ready ? "ready" : "load" ]( selector ); |
|---|
| 82 | | |
|---|
| 83 | | return this.setArray(jQuery.makeArray(selector)); |
|---|
| 84 | | }, |
|---|
| 85 | | |
|---|
| 86 | | // The current version of jQuery being used |
|---|
| 87 | | jquery: "1.2.6", |
|---|
| 88 | | |
|---|
| 89 | | // The number of elements contained in the matched element set |
|---|
| 90 | | size: function() { |
|---|
| 91 | | return this.length; |
|---|
| 92 | | }, |
|---|
| 93 | | |
|---|
| 94 | | // The number of elements contained in the matched element set |
|---|
| 95 | | length: 0, |
|---|
| 96 | | |
|---|
| 97 | | // Get the Nth element in the matched element set OR |
|---|
| 98 | | // Get the whole matched element set as a clean array |
|---|
| 99 | | get: function( num ) { |
|---|
| 100 | | return num == undefined ? |
|---|
| 101 | | |
|---|
| 102 | | // Return a 'clean' array |
|---|
| 103 | | jQuery.makeArray( this ) : |
|---|
| 104 | | |
|---|
| 105 | | // Return just the object |
|---|
| 106 | | this[ num ]; |
|---|
| 107 | | }, |
|---|
| 108 | | |
|---|
| 109 | | // Take an array of elements and push it onto the stack |
|---|
| 110 | | // (returning the new matched element set) |
|---|
| 111 | | pushStack: function( elems ) { |
|---|
| 112 | | // Build a new jQuery matched element set |
|---|
| 113 | | var ret = jQuery( elems ); |
|---|
| 114 | | |
|---|
| 115 | | // Add the old object onto the stack (as a reference) |
|---|
| 116 | | ret.prevObject = this; |
|---|
| 117 | | |
|---|
| 118 | | // Return the newly-formed element set |
|---|
| 119 | | return ret; |
|---|
| 120 | | }, |
|---|
| 121 | | |
|---|
| 122 | | // Force the current matched set of elements to become |
|---|
| 123 | | // the specified array of elements (destroying the stack in the process) |
|---|
| 124 | | // You should use pushStack() in order to do this, but maintain the stack |
|---|
| 125 | | setArray: function( elems ) { |
|---|
| 126 | | // Resetting the length to 0, then using the native Array push |
|---|
| 127 | | // is a super-fast way to populate an object with array-like properties |
|---|
| 128 | | this.length = 0; |
|---|
| 129 | | Array.prototype.push.apply( this, elems ); |
|---|
| 130 | | |
|---|
| 131 | | return this; |
|---|
| 132 | | }, |
|---|
| 133 | | |
|---|
| 134 | | // Execute a callback for every element in the matched set. |
|---|
| 135 | | // (You can seed the arguments with an array of args, but this is |
|---|
| 136 | | // only used internally.) |
|---|
| 137 | | each: function( callback, args ) { |
|---|
| 138 | | return jQuery.each( this, callback, args ); |
|---|
| 139 | | }, |
|---|
| 140 | | |
|---|
| 141 | | // Determine the position of an element within |
|---|
| 142 | | // the matched set of elements |
|---|
| 143 | | index: function( elem ) { |
|---|
| 144 | | var ret = -1; |
|---|
| 145 | | |
|---|
| 146 | | // Locate the position of the desired element |
|---|
| 147 | | return jQuery.inArray( |
|---|
| 148 | | // If it receives a jQuery object, the first element is used |
|---|
| 149 | | elem && elem.jquery ? elem[0] : elem |
|---|
| 150 | | , this ); |
|---|
| 151 | | }, |
|---|
| 152 | | |
|---|
| 153 | | attr: function( name, value, type ) { |
|---|
| 154 | | var options = name; |
|---|
| 155 | | |
|---|
| 156 | | // Look for the case where we're accessing a style value |
|---|
| 157 | | if ( name.constructor == String ) |
|---|
| 158 | | if ( value === undefined ) |
|---|
| 159 | | return this[0] && jQuery[ type || "attr" ]( this[0], name ); |
|---|
| 160 | | |
|---|
| 161 | | else { |
|---|
| 162 | | options = {}; |
|---|
| 163 | | options[ name ] = value; |
|---|
| 164 | | } |
|---|
| 165 | | |
|---|
| 166 | | // Check to see if we're setting style values |
|---|
| 167 | | return this.each(function(i){ |
|---|
| 168 | | // Set all the styles |
|---|
| 169 | | for ( name in options ) |
|---|
| 170 | | jQuery.attr( |
|---|
| 171 | | type ? |
|---|
| 172 | | this.style : |
|---|
| 173 | | this, |
|---|
| 174 | | name, jQuery.prop( this, options[ name ], type, i, name ) |
|---|
| 175 | | ); |
|---|
| 176 | | }); |
|---|
| 177 | | }, |
|---|
| 178 | | |
|---|
| 179 | | css: function( key, value ) { |
|---|
| 180 | | // ignore negative width and height values |
|---|
| 181 | | if ( (key == 'width' || key == 'height') && parseFloat(value) < 0 ) |
|---|
| 182 | | value = undefined; |
|---|
| 183 | | return this.attr( key, value, "curCSS" ); |
|---|
| 184 | | }, |
|---|
| 185 | | |
|---|
| 186 | | text: function( text ) { |
|---|
| 187 | | if ( typeof text != "object" && text != null ) |
|---|
| 188 | | return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); |
|---|
| 189 | | |
|---|
| 190 | | var ret = ""; |
|---|
| 191 | | |
|---|
| 192 | | jQuery.each( text || this, function(){ |
|---|
| 193 | | jQuery.each( this.childNodes, function(){ |
|---|
| 194 | | if ( this.nodeType != 8 ) |
|---|
| 195 | | ret += this.nodeType != 1 ? |
|---|
| 196 | | this.nodeValue : |
|---|
| 197 | | jQuery.fn.text( [ this ] ); |
|---|
| 198 | | }); |
|---|
| 199 | | }); |
|---|
| 200 | | |
|---|
| 201 | | return ret; |
|---|
| 202 | | }, |
|---|
| 203 | | |
|---|
| 204 | | wrapAll: function( html ) { |
|---|
| 205 | | if ( this[0] ) |
|---|
| 206 | | // The elements to wrap the target around |
|---|
| 207 | | jQuery( html, this[0].ownerDocument ) |
|---|
| 208 | | .clone() |
|---|
| 209 | | .insertBefore( this[0] ) |
|---|
| 210 | | .map(function(){ |
|---|
| 211 | | var elem = this; |
|---|
| 212 | | |
|---|
| 213 | | while ( elem.firstChild ) |
|---|
| 214 | | elem = elem.firstChild; |
|---|
| 215 | | |
|---|
| 216 | | return elem; |
|---|
| 217 | | }) |
|---|
| 218 | | .append(this); |
|---|
| 219 | | |
|---|
| 220 | | return this; |
|---|
| 221 | | }, |
|---|
| 222 | | |
|---|
| 223 | | wrapInner: function( html ) { |
|---|
| 224 | | return this.each(function(){ |
|---|
| 225 | | jQuery( this ).contents().wrapAll( html ); |
|---|
| 226 | | }); |
|---|
| 227 | | }, |
|---|
| 228 | | |
|---|
| 229 | | wrap: function( html ) { |
|---|
| 230 | | return this.each(function(){ |
|---|
| 231 | | jQuery( this ).wrapAll( html ); |
|---|
| 232 | | }); |
|---|
| 233 | | }, |
|---|
| 234 | | |
|---|
| 235 | | append: function() { |
|---|
| 236 | | return this.domManip(arguments, true, false, function(elem){ |
|---|
| 237 | | if (this.nodeType == 1) |
|---|
| 238 | | this.appendChild( elem ); |
|---|
| 239 | | }); |
|---|
| 240 | | }, |
|---|
| 241 | | |
|---|
| 242 | | prepend: function() { |
|---|
| 243 | | return this.domManip(arguments, true, true, function(elem){ |
|---|
| 244 | | if (this.nodeType == 1) |
|---|
| 245 | | this.insertBefore( elem, this.firstChild ); |
|---|
| 246 | | }); |
|---|
| 247 | | }, |
|---|
| 248 | | |
|---|
| 249 | | before: function() { |
|---|
| 250 | | return this.domManip(arguments, false, false, function(elem){ |
|---|
| 251 | | this.parentNode.insertBefore( elem, this ); |
|---|
| 252 | | }); |
|---|
| 253 | | }, |
|---|
| 254 | | |
|---|
| 255 | | after: function() { |
|---|
| 256 | | return this.domManip(arguments, false, true, function(elem){ |
|---|
| 257 | | this.parentNode.insertBefore( elem, this.nextSibling ); |
|---|
| 258 | | }); |
|---|
| 259 | | }, |
|---|
| 260 | | |
|---|
| 261 | | end: function() { |
|---|
| 262 | | return this.prevObject || jQuery( [] ); |
|---|
| 263 | | }, |
|---|
| 264 | | |
|---|
| 265 | | find: function( selector ) { |
|---|
| 266 | | var elems = jQuery.map(this, function(elem){ |
|---|
| 267 | | return jQuery.find( selector, elem ); |
|---|
| 268 | | }); |
|---|
| 269 | | |
|---|
| 270 | | return this.pushStack( /[^+>] [^+>]/.test( selector ) || selector.indexOf("..") > -1 ? |
|---|
| 271 | | jQuery.unique( elems ) : |
|---|
| 272 | | elems ); |
|---|
| 273 | | }, |
|---|
| 274 | | |
|---|
| 275 | | clone: function( events ) { |
|---|
| 276 | | // Do the clone |
|---|
| 277 | | var ret = this.map(function(){ |
|---|
| 278 | | if ( jQuery.browser.msie && !jQuery.isXMLDoc(this) ) { |
|---|
| 279 | | // IE copies events bound via attachEvent when |
|---|
| 280 | | // using cloneNode. Calling detachEvent on the |
|---|
| 281 | | // clone will also remove the events from the orignal |
|---|
| 282 | | // In order to get around this, we use innerHTML. |
|---|
| 283 | | // Unfortunately, this means some modifications to |
|---|
| 284 | | // attributes in IE that are actually only stored |
|---|
| 285 | | // as properties will not be copied (such as the |
|---|
| 286 | | // the name attribute on an input). |
|---|
| 287 | | var clone = this.cloneNode(true), |
|---|
| 288 | | container = document.createElement("div"); |
|---|
| 289 | | container.appendChild(clone); |
|---|
| 290 | | return jQuery.clean([container.innerHTML])[0]; |
|---|
| 291 | | } else |
|---|
| 292 | | return this.cloneNode(true); |
|---|
| 293 | | }); |
|---|
| 294 | | |
|---|
| 295 | | // Need to set the expando to null on the cloned set if it exists |
|---|
| 296 | | // removeData doesn't work here, IE removes it from the original as well |
|---|
| 297 | | // this is primarily for IE but the data expando shouldn't be copied over in any browser |
|---|
| 298 | | var clone = ret.find("*").andSelf().each(function(){ |
|---|
| 299 | | if ( this[ expando ] != undefined ) |
|---|
| 300 | | this[ expando ] = null; |
|---|
| 301 | | }); |
|---|
| 302 | | |
|---|
| 303 | | // Copy the events from the original to the clone |
|---|
| 304 | | if ( events === true ) |
|---|
| 305 | | this.find("*").andSelf().each(function(i){ |
|---|
| 306 | | if (this.nodeType == 3) |
|---|
| 307 | | return; |
|---|
| 308 | | var events = jQuery.data( this, "events" ); |
|---|
| 309 | | |
|---|
| 310 | | for ( var type in events ) |
|---|
| 311 | | for ( var handler in events[ type ] ) |
|---|
| 312 | | jQuery.event.add( clone[ i ], type, events[ type ][ handler ], events[ type ][ handler ].data ); |
|---|
| 313 | | }); |
|---|
| 314 | | |
|---|
| 315 | | // Return the cloned set |
|---|
| 316 | | return ret; |
|---|
| 317 | | }, |
|---|
| 318 | | |
|---|
| 319 | | filter: function( selector ) { |
|---|
| 320 | | return this.pushStack( |
|---|
| 321 | | jQuery.isFunction( selector ) && |
|---|
| 322 | | jQuery.grep(this, function(elem, i){ |
|---|
| 323 | | return selector.call( elem, i ); |
|---|
| 324 | | }) || |
|---|
| 325 | | |
|---|
| 326 | | jQuery.multiFilter( selector, this ) ); |
|---|
| 327 | | }, |
|---|
| 328 | | |
|---|
| 329 | | not: function( selector ) { |
|---|
| 330 | | if ( selector.constructor == String ) |
|---|
| 331 | | // test special case where just one selector is passed in |
|---|
| 332 | | if ( isSimple.test( selector ) ) |
|---|
| 333 | | return this.pushStack( jQuery.multiFilter( selector, this, true ) ); |
|---|
| 334 | | else |
|---|
| 335 | | selector = jQuery.multiFilter( selector, this ); |
|---|
| 336 | | |
|---|
| 337 | | var isArrayLike = selector.length && selector[selector.length - 1] !== undefined && !selector.nodeType; |
|---|
| 338 | | return this.filter(function() { |
|---|
| 339 | | return isArrayLike ? jQuery.inArray( this, selector ) < 0 : this != selector; |
|---|
| 340 | | }); |
|---|
| 341 | | }, |
|---|
| 342 | | |
|---|
| 343 | | add: function( selector ) { |
|---|
| 344 | | return this.pushStack( jQuery.unique( jQuery.merge( |
|---|
| 345 | | this.get(), |
|---|
| 346 | | typeof selector == 'string' ? |
|---|
| 347 | | jQuery( selector ) : |
|---|
| 348 | | jQuery.makeArray( selector ) |
|---|
| 349 | | ))); |
|---|
| 350 | | }, |
|---|
| 351 | | |
|---|
| 352 | | is: function( selector ) { |
|---|
| 353 | | return !!selector && jQuery.multiFilter( selector, this ).length > 0; |
|---|
| 354 | | }, |
|---|
| 355 | | |
|---|
| 356 | | hasClass: function( selector ) { |
|---|
| 357 | | return this.is( "." + selector ); |
|---|
| 358 | | }, |
|---|
| 359 | | |
|---|
| 360 | | val: function( value ) { |
|---|
| 361 | | if ( value == undefined ) { |
|---|
| 362 | | |
|---|
| 363 | | if ( this.length ) { |
|---|
| 364 | | var elem = this[0]; |
|---|
| 365 | | |
|---|
| 366 | | // We need to handle select boxes special |
|---|
| 367 | | if ( jQuery.nodeName( elem, "select" ) ) { |
|---|
| 368 | | var index = elem.selectedIndex, |
|---|
| 369 | | values = [], |
|---|
| 370 | | options = elem.options, |
|---|
| 371 | | one = elem.type == "select-one"; |
|---|
| 372 | | |
|---|
| 373 | | // Nothing was selected |
|---|
| 374 | | if ( index < 0 ) |
|---|
| 375 | | return null; |
|---|
| 376 | | |
|---|
| 377 | | // Loop through all the selected options |
|---|
| 378 | | for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { |
|---|
| 379 | | var option = options[ i ]; |
|---|
| 380 | | |
|---|
| 381 | | if ( option.selected ) { |
|---|
| 382 | | // Get the specifc value for the option |
|---|
| 383 | | value = jQuery.browser.msie && !option.attributes.value.specified ? option.text : option.value; |
|---|
| 384 | | |
|---|
| 385 | | // We don't need an array for one selects |
|---|
| 386 | | if ( one ) |
|---|
| 387 | | return value; |
|---|
| 388 | | |
|---|
| 389 | | // Multi-Selects return an array |
|---|
| 390 | | values.push( value ); |
|---|
| 391 | | } |
|---|
| 392 | | } |
|---|
| 393 | | |
|---|
| 394 | | return values; |
|---|
| 395 | | |
|---|
| 396 | | // Everything else, we just grab the value |
|---|
| 397 | | } else |
|---|
| 398 | | return (this[0].value || "").replace(/\r/g, ""); |
|---|
| 399 | | |
|---|
| 400 | | } |
|---|
| 401 | | |
|---|
| 402 | | return undefined; |
|---|
| 403 | | } |
|---|
| 404 | | |
|---|
| 405 | | if( value.constructor == Number ) |
|---|
| 406 | | value += ''; |
|---|
| 407 | | |
|---|
| 408 | | return this.each(function(){ |
|---|
| 409 | | if ( this.nodeType != 1 ) |
|---|
| 410 | | return; |
|---|
| 411 | | |
|---|
| 412 | | if ( value.constructor == Array && /radio|checkbox/.test( this.type ) ) |
|---|
| 413 | | this.checked = (jQuery.inArray(this.value, value) >= 0 || |
|---|
| 414 | | jQuery.inArray(this.name, value) >= 0); |
|---|
| 415 | | |
|---|
| 416 | | else if ( jQuery.nodeName( this, "select" ) ) { |
|---|
| 417 | | var values = jQuery.makeArray(value); |
|---|
| 418 | | |
|---|
| 419 | | jQuery( "option", this ).each(function(){ |
|---|
| 420 | | this.selected = (jQuery.inArray( this.value, values ) >= 0 || |
|---|
| 421 | | jQuery.inArray( this.text, values ) >= 0); |
|---|
| 422 | | }); |
|---|
| 423 | | |
|---|
| 424 | | if ( !values.length ) |
|---|
| 425 | | this.selectedIndex = -1; |
|---|
| 426 | | |
|---|
| 427 | | } else |
|---|
| 428 | | this.value = value; |
|---|
| 429 | | }); |
|---|
| 430 | | }, |
|---|
| 431 | | |
|---|
| 432 | | html: function( value ) { |
|---|
| 433 | | return value == undefined ? |
|---|
| 434 | | (this[0] ? |
|---|
| 435 | | this[0].innerHTML : |
|---|
| 436 | | null) : |
|---|
| 437 | | this.empty().append( value ); |
|---|
| 438 | | }, |
|---|
| 439 | | |
|---|
| 440 | | replaceWith: function( value ) { |
|---|
| 441 | | return this.after( value ).remove(); |
|---|
| 442 | | }, |
|---|
| 443 | | |
|---|
| 444 | | eq: function( i ) { |
|---|
| 445 | | return this.slice( i, i + 1 ); |
|---|
| 446 | | }, |
|---|
| 447 | | |
|---|
| 448 | | slice: function() { |
|---|
| 449 | | return this.pushStack( Array.prototype.slice.apply( this, arguments ) ); |
|---|
| 450 | | }, |
|---|
| 451 | | |
|---|
| 452 | | map: function( callback ) { |
|---|
| 453 | | return this.pushStack( jQuery.map(this, function(elem, i){ |
|---|
| 454 | | return callback.call( elem, i, elem ); |
|---|
| 455 | | })); |
|---|
| 456 | | }, |
|---|
| 457 | | |
|---|
| 458 | | andSelf: function() { |
|---|
| 459 | | return this.add( this.prevObject ); |
|---|
| 460 | | }, |
|---|
| 461 | | |
|---|
| 462 | | data: function( key, value ){ |
|---|
| 463 | | var parts = key.split("."); |
|---|
| 464 | | parts[1] = parts[1] ? "." + parts[1] : ""; |
|---|
| 465 | | |
|---|
| 466 | | if ( value === undefined ) { |
|---|
| 467 | | var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); |
|---|
| 468 | | |
|---|
| 469 | | if ( data === undefined && this.length ) |
|---|
| 470 | | data = jQuery.data( this[0], key ); |
|---|
| 471 | | |
|---|
| 472 | | return data === undefined && parts[1] ? |
|---|
| 473 | | this.data( parts[0] ) : |
|---|
| 474 | | data; |
|---|
| 475 | | } else |
|---|
| 476 | | return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){ |
|---|
| 477 | | jQuery.data( this, key, value ); |
|---|
| 478 | | }); |
|---|
| 479 | | }, |
|---|
| 480 | | |
|---|
| 481 | | removeData: function( key ){ |
|---|
| 482 | | return this.each(function(){ |
|---|
| 483 | | jQuery.removeData( this, key ); |
|---|
| 484 | | }); |
|---|
| 485 | | }, |
|---|
| 486 | | |
|---|
| 487 | | domManip: function( args, table, reverse, callback ) { |
|---|
| 488 | | var clone = this.length > 1, elems; |
|---|
| 489 | | |
|---|
| 490 | | return this.each(function(){ |
|---|
| 491 | | if ( !elems ) { |
|---|
| 492 | | elems = jQuery.clean( args, this.ownerDocument ); |
|---|
| 493 | | |
|---|
| 494 | | if ( reverse ) |
|---|
| 495 | | elems.reverse(); |
|---|
| 496 | | } |
|---|
| 497 | | |
|---|
| 498 | | var obj = this; |
|---|
| 499 | | |
|---|
| 500 | | if ( table && jQuery.nodeName( this, "table" ) && jQuery.nodeName( elems[0], "tr" ) ) |
|---|
| 501 | | obj = this.getElementsByTagName("tbody")[0] || this.appendChild( this.ownerDocument.createElement("tbody") ); |
|---|
| 502 | | |
|---|
| 503 | | var scripts = jQuery( [] ); |
|---|
| 504 | | |
|---|
| 505 | | jQuery.each(elems, function(){ |
|---|
| 506 | | var elem = clone ? |
|---|
| 507 | | jQuery( this ).clone( true )[0] : |
|---|
| 508 | | this; |
|---|
| 509 | | |
|---|
| 510 | | // execute all scripts after the elements have been injected |
|---|
| 511 | | if ( jQuery.nodeName( elem, "script" ) ) |
|---|
| 512 | | scripts = scripts.add( elem ); |
|---|
| 513 | | else { |
|---|
| 514 | | // Remove any inner scripts for later evaluation |
|---|
| 515 | | if ( elem.nodeType == 1 ) |
|---|
| 516 | | scripts = scripts.add( jQuery( "script", elem ).remove() ); |
|---|
| 517 | | |
|---|
| 518 | | // Inject the elements into the document |
|---|
| 519 | | callback.call( obj, elem ); |
|---|
| 520 | | } |
|---|
| 521 | | }); |
|---|
| 522 | | |
|---|
| 523 | | scripts.each( evalScript ); |
|---|
| 524 | | }); |
|---|
| 525 | | } |
|---|
| 526 | | }; |
|---|
| 527 | | |
|---|
| 528 | | // Give the init function the jQuery prototype for later instantiation |
|---|
| 529 | | jQuery.fn.init.prototype = jQuery.fn; |
|---|
| 530 | | |
|---|
| 531 | | function evalScript( i, elem ) { |
|---|
| 532 | | if ( elem.src ) |
|---|
| 533 | | jQuery.ajax({ |
|---|
| 534 | | url: elem.src, |
|---|
| 535 | | async: false, |
|---|
| 536 | | dataType: "script" |
|---|
| 537 | | }); |
|---|
| 538 | | |
|---|
| 539 | | else |
|---|
| 540 | | jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" ); |
|---|
| 541 | | |
|---|
| 542 | | if ( elem.parentNode ) |
|---|
| 543 | | elem.parentNode.removeChild( elem ); |
|---|
| 544 | | } |
|---|
| 545 | | |
|---|
| 546 | | function now(){ |
|---|
| 547 | | return +new Date; |
|---|
| 548 | | } |
|---|
| 549 | | |
|---|
| 550 | | jQuery.extend = jQuery.fn.extend = function() { |
|---|
| 551 | | // copy reference to target object |
|---|
| 552 | | var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options; |
|---|
| 553 | | |
|---|
| 554 | | // Handle a deep copy situation |
|---|
| 555 | | if ( target.constructor == Boolean ) { |
|---|
| 556 | | deep = target; |
|---|
| 557 | | target = arguments[1] || {}; |
|---|
| 558 | | // skip the boolean and the target |
|---|
| 559 | | i = 2; |
|---|
| 560 | | } |
|---|
| 561 | | |
|---|
| 562 | | // Handle case when target is a string or something (possible in deep copy) |
|---|
| 563 | | if ( typeof target != "object" && typeof target != "function" ) |
|---|
| 564 | | target = {}; |
|---|
| 565 | | |
|---|
| 566 | | // extend jQuery itself if only one argument is passed |
|---|
| 567 | | if ( length == i ) { |
|---|
| 568 | | target = this; |
|---|
| 569 | | --i; |
|---|
| 570 | | } |
|---|
| 571 | | |
|---|
| 572 | | for ( ; i < length; i++ ) |
|---|
| 573 | | // Only deal with non-null/undefined values |
|---|
| 574 | | if ( (options = arguments[ i ]) != null ) |
|---|
| 575 | | // Extend the base object |
|---|
| 576 | | for ( var name in options ) { |
|---|
| 577 | | var src = target[ name ], copy = options[ name ]; |
|---|
| 578 | | |
|---|
| 579 | | // Prevent never-ending loop |
|---|
| 580 | | if ( target === copy ) |
|---|
| 581 | | continue; |
|---|
| 582 | | |
|---|
| 583 | | // Recurse if we're merging object values |
|---|
| 584 | | if ( deep && copy && typeof copy == "object" && !copy.nodeType ) |
|---|
| 585 | | target[ name ] = jQuery.extend( deep, |
|---|
| 586 | | // Never move original objects, clone them |
|---|
| 587 | | src || ( copy.length != null ? [ ] : { } ) |
|---|
| 588 | | , copy ); |
|---|
| 589 | | |
|---|
| 590 | | // Don't bring in undefined values |
|---|
| 591 | | else if ( copy !== undefined ) |
|---|
| 592 | | target[ name ] = copy; |
|---|
| 593 | | |
|---|
| 594 | | } |
|---|
| 595 | | |
|---|
| 596 | | // Return the modified object |
|---|
| 597 | | return target; |
|---|
| 598 | | }; |
|---|
| 599 | | |
|---|
| 600 | | var expando = "jQuery" + now(), uuid = 0, windowData = {}, |
|---|
| 601 | | // exclude the following css properties to add px |
|---|
| 602 | | exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i, |
|---|
| 603 | | // cache defaultView |
|---|
| 604 | | defaultView = document.defaultView || {}; |
|---|
| 605 | | |
|---|
| 606 | | jQuery.extend({ |
|---|
| 607 | | noConflict: function( deep ) { |
|---|
| 608 | | window.$ = _$; |
|---|
| 609 | | |
|---|
| 610 | | if ( deep ) |
|---|
| 611 | | window.jQuery = _jQuery; |
|---|
| 612 | | |
|---|
| 613 | | return jQuery; |
|---|
| 614 | | }, |
|---|
| 615 | | |
|---|
| 616 | | // See test/unit/core.js for details concerning this function. |
|---|
| 617 | | isFunction: function( fn ) { |
|---|
| 618 | | return !!fn && typeof fn != "string" && !fn.nodeName && |
|---|
| 619 | | fn.constructor != Array && /^[\s[]?function/.test( fn + "" ); |
|---|
| 620 | | }, |
|---|
| 621 | | |
|---|
| 622 | | // check if an element is in a (or is an) XML document |
|---|
| 623 | | isXMLDoc: function( elem ) { |
|---|
| 624 | | return elem.documentElement && !elem.body || |
|---|
| 625 | | elem.tagName && elem.ownerDocument && !elem.ownerDocument.body; |
|---|
| 626 | | }, |
|---|
| 627 | | |
|---|
| 628 | | // Evalulates a script in a global context |
|---|
| 629 | | globalEval: function( data ) { |
|---|
| 630 | | data = jQuery.trim( data ); |
|---|
| 631 | | |
|---|
| 632 | | if ( data ) { |
|---|
| 633 | | // Inspired by code by Andrea Giammarchi |
|---|
| 634 | | // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html |
|---|
| 635 | | var head = document.getElementsByTagName("head")[0] || document.documentElement, |
|---|
| 636 | | script = document.createElement("script"); |
|---|
| 637 | | |
|---|
| 638 | | script.type = "text/javascript"; |
|---|
| 639 | | if ( jQuery.browser.msie ) |
|---|
| 640 | | script.text = data; |
|---|
| 641 | | else |
|---|
| 642 | | script.appendChild( document.createTextNode( data ) ); |
|---|
| 643 | | |
|---|
| 644 | | // Use insertBefore instead of appendChild to circumvent an IE6 bug. |
|---|
| 645 | | // This arises when a base node is used (#2709). |
|---|
| 646 | | head.insertBefore( script, head.firstChild ); |
|---|
| 647 | | head.removeChild( script ); |
|---|
| 648 | | } |
|---|
| 649 | | }, |
|---|
| 650 | | |
|---|
| 651 | | nodeName: function( elem, name ) { |
|---|
| 652 | | return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase(); |
|---|
| 653 | | }, |
|---|
| 654 | | |
|---|
| 655 | | cache: {}, |
|---|
| 656 | | |
|---|
| 657 | | data: function( elem, name, data ) { |
|---|
| 658 | | elem = elem == window ? |
|---|
| 659 | | windowData : |
|---|
| 660 | | elem; |
|---|
| 661 | | |
|---|
| 662 | | var id = elem[ expando ]; |
|---|
| 663 | | |
|---|
| 664 | | // Compute a unique ID for the element |
|---|
| 665 | | if ( !id ) |
|---|
| 666 | | id = elem[ expando ] = ++uuid; |
|---|
| 667 | | |
|---|
| 668 | | // Only generate the data cache if we're |
|---|
| 669 | | // trying to access or manipulate it |
|---|
| 670 | | if ( name && !jQuery.cache[ id ] ) |
|---|
| 671 | | jQuery.cache[ id ] = {}; |
|---|
| 672 | | |
|---|
| 673 | | // Prevent overriding the named cache with undefined values |
|---|
| 674 | | if ( data !== undefined ) |
|---|
| 675 | | jQuery.cache[ id ][ name ] = data; |
|---|
| 676 | | |
|---|
| 677 | | // Return the named cache data, or the ID for the element |
|---|
| 678 | | return name ? |
|---|
| 679 | | jQuery.cache[ id ][ name ] : |
|---|
| 680 | | id; |
|---|
| 681 | | }, |
|---|
| 682 | | |
|---|
| 683 | | removeData: function( elem, name ) { |
|---|
| 684 | | elem = elem == window ? |
|---|
| 685 | | windowData : |
|---|
| 686 | | elem; |
|---|
| 687 | | |
|---|
| 688 | | var id = elem[ expando ]; |
|---|
| 689 | | |
|---|
| 690 | | // If we want to remove a specific section of the element's data |
|---|
| 691 | | if ( name ) { |
|---|
| 692 | | if ( jQuery.cache[ id ] ) { |
|---|
| 693 | | // Remove the section of cache data |
|---|
| 694 | | delete jQuery.cache[ id ][ name ]; |
|---|
| 695 | | |
|---|
| 696 | | // If we've removed all the data, remove the element's cache |
|---|
| 697 | | name = ""; |
|---|
| 698 | | |
|---|
| 699 | | for ( name in jQuery.cache[ id ] ) |
|---|
| 700 | | break; |
|---|
| 701 | | |
|---|
| 702 | | if ( !name ) |
|---|
| 703 | | jQuery.removeData( elem ); |
|---|
| 704 | | } |
|---|
| 705 | | |
|---|
| 706 | | // Otherwise, we want to remove all of the element's data |
|---|
| 707 | | } else { |
|---|
| 708 | | // Clean up the element expando |
|---|
| 709 | | try { |
|---|
| 710 | | delete elem[ expando ]; |
|---|
| 711 | | } catch(e){ |
|---|
| 712 | | // IE has trouble directly removing the expando |
|---|
| 713 | | // but it's ok with using removeAttribute |
|---|
| 714 | | if ( elem.removeAttribute ) |
|---|
| 715 | | elem.removeAttribute( expando ); |
|---|
| 716 | | } |
|---|
| 717 | | |
|---|
| 718 | | // Completely remove the data cache |
|---|
| 719 | | delete jQuery.cache[ id ]; |
|---|
| 720 | | } |
|---|
| 721 | | }, |
|---|
| 722 | | |
|---|
| 723 | | // args is for internal usage only |
|---|
| 724 | | each: function( object, callback, args ) { |
|---|
| 725 | | var name, i = 0, length = object.length; |
|---|
| 726 | | |
|---|
| 727 | | if ( args ) { |
|---|
| 728 | | if ( length == undefined ) { |
|---|
| 729 | | for ( name in object ) |
|---|
| 730 | | if ( callback.apply( object[ name ], args ) === false ) |
|---|
| 731 | | break; |
|---|
| 732 | | } else |
|---|
| 733 | | for ( ; i < length; ) |
|---|
| 734 | | if ( callback.apply( object[ i++ ], args ) === false ) |
|---|
| 735 | | break; |
|---|
| 736 | | |
|---|
| 737 | | // A special, fast, case for the most common use of each |
|---|
| 738 | | } else { |
|---|
| 739 | | if ( length == undefined ) { |
|---|
| 740 | | for ( name in object ) |
|---|
| 741 | | if ( callback.call( object[ name ], name, object[ name ] ) === false ) |
|---|
| 742 | | break; |
|---|
| 743 | | } else |
|---|
| 744 | | for ( var value = object[0]; |
|---|
| 745 | | i < length && callback.call( value, i, value ) !== false; value = object[++i] ){} |
|---|
| 746 | | } |
|---|
| 747 | | |
|---|
| 748 | | return object; |
|---|
| 749 | | }, |
|---|
| 750 | | |
|---|
| 751 | | prop: function( elem, value, type, i, name ) { |
|---|
| 752 | | // Handle executable functions |
|---|
| 753 | | if ( jQuery.isFunction( value ) ) |
|---|
| 754 | | value = value.call( elem, i ); |
|---|
| 755 | | |
|---|
| 756 | | // Handle passing in a number to a CSS property |
|---|
| 757 | | return value && value.constructor == Number && type == "curCSS" && !exclude.test( name ) ? |
|---|
| 758 | | value + "px" : |
|---|
| 759 | | value; |
|---|
| 760 | | }, |
|---|
| 761 | | |
|---|
| 762 | | className: { |
|---|
| 763 | | // internal only, use addClass("class") |
|---|
| 764 | | add: function( elem, classNames ) { |
|---|
| 765 | | jQuery.each((classNames || "").split(/\s+/), function(i, className){ |
|---|
| 766 | | if ( elem.nodeType == 1 && !jQuery.className.has( elem.className, className ) ) |
|---|
| 767 | | elem.className += (elem.className ? " " : "") + className; |
|---|
| 768 | | }); |
|---|
| 769 | | }, |
|---|
| 770 | | |
|---|
| 771 | | // internal only, use removeClass("class") |
|---|
| 772 | | remove: function( elem, classNames ) { |
|---|
| 773 | | if (elem.nodeType == 1) |
|---|
| 774 | | elem.className = classNames != undefined ? |
|---|
| 775 | | jQuery.grep(elem.className.split(/\s+/), function(className){ |
|---|
| 776 | | return !jQuery.className.has( classNames, className ); |
|---|
| 777 | | }).join(" ") : |
|---|
| 778 | | ""; |
|---|
| 779 | | }, |
|---|
| 780 | | |
|---|
| 781 | | // internal only, use hasClass("class") |
|---|
| 782 | | has: function( elem, className ) { |
|---|
| 783 | | return jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1; |
|---|
| 784 | | } |
|---|
| 785 | | }, |
|---|
| 786 | | |
|---|
| 787 | | // A method for quickly swapping in/out CSS properties to get correct calculations |
|---|
| 788 | | swap: function( elem, options, callback ) { |
|---|
| 789 | | var old = {}; |
|---|
| 790 | | // Remember the old values, and insert the new ones |
|---|
| 791 | | for ( var name in options ) { |
|---|
| 792 | | old[ name ] = elem.style[ name ]; |
|---|
| 793 | | elem.style[ name ] = options[ name ]; |
|---|
| 794 | | } |
|---|
| 795 | | |
|---|
| 796 | | callback.call( elem ); |
|---|
| 797 | | |
|---|
| 798 | | // Revert the old values |
|---|
| 799 | | for ( var name in options ) |
|---|
| 800 | | elem.style[ name ] = old[ name ]; |
|---|
| 801 | | }, |
|---|
| 802 | | |
|---|
| 803 | | css: function( elem, name, force ) { |
|---|
| 804 | | if ( name == "width" || name == "height" ) { |
|---|
| 805 | | var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ]; |
|---|
| 806 | | |
|---|
| 807 | | function getWH() { |
|---|
| 808 | | val = name == "width" ? elem.offsetWidth : elem.offsetHeight; |
|---|
| 809 | | var padding = 0, border = 0; |
|---|
| 810 | | jQuery.each( which, function() { |
|---|
| 811 | | padding += parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0; |
|---|
| 812 | | border += parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0; |
|---|
| 813 | | }); |
|---|
| 814 | | val -= Math.round(padding + border); |
|---|
| 815 | | } |
|---|
| 816 | | |
|---|
| 817 | | if ( jQuery(elem).is(":visible") ) |
|---|
| 818 | | getWH(); |
|---|
| 819 | | else |
|---|
| 820 | | & |
|---|