bgneal@45: (function(){ bgneal@45: /* bgneal@45: * jQuery 1.2.6 - New Wave Javascript bgneal@45: * bgneal@45: * Copyright (c) 2008 John Resig (jquery.com) bgneal@45: * Dual licensed under the MIT (MIT-LICENSE.txt) bgneal@45: * and GPL (GPL-LICENSE.txt) licenses. bgneal@45: * bgneal@45: * $Date: 2008-05-27 21:17:26 +0200 (Di, 27 Mai 2008) $ bgneal@45: * $Rev: 5700 $ bgneal@45: */ bgneal@45: bgneal@45: // Map over jQuery in case of overwrite bgneal@45: var _jQuery = window.jQuery, bgneal@45: // Map over the $ in case of overwrite bgneal@45: _$ = window.$; bgneal@45: bgneal@45: var jQuery = window.jQuery = window.$ = function( selector, context ) { bgneal@45: // The jQuery object is actually just the init constructor 'enhanced' bgneal@45: return new jQuery.fn.init( selector, context ); bgneal@45: }; bgneal@45: bgneal@45: // A simple way to check for HTML strings or ID strings bgneal@45: // (both of which we optimize for) bgneal@45: var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/, bgneal@45: bgneal@45: // Is it a simple selector bgneal@45: isSimple = /^.[^:#\[\.]*$/, bgneal@45: bgneal@45: // Will speed up references to undefined, and allows munging its name. bgneal@45: undefined; bgneal@45: bgneal@45: jQuery.fn = jQuery.prototype = { bgneal@45: init: function( selector, context ) { bgneal@45: // Make sure that a selection was provided bgneal@45: selector = selector || document; bgneal@45: bgneal@45: // Handle $(DOMElement) bgneal@45: if ( selector.nodeType ) { bgneal@45: this[0] = selector; bgneal@45: this.length = 1; bgneal@45: return this; bgneal@45: } bgneal@45: // Handle HTML strings bgneal@45: if ( typeof selector == "string" ) { bgneal@45: // Are we dealing with HTML string or an ID? bgneal@45: var match = quickExpr.exec( selector ); bgneal@45: bgneal@45: // Verify a match, and that no context was specified for #id bgneal@45: if ( match && (match[1] || !context) ) { bgneal@45: bgneal@45: // HANDLE: $(html) -> $(array) bgneal@45: if ( match[1] ) bgneal@45: selector = jQuery.clean( [ match[1] ], context ); bgneal@45: bgneal@45: // HANDLE: $("#id") bgneal@45: else { bgneal@45: var elem = document.getElementById( match[3] ); bgneal@45: bgneal@45: // Make sure an element was located bgneal@45: if ( elem ){ bgneal@45: // Handle the case where IE and Opera return items bgneal@45: // by name instead of ID bgneal@45: if ( elem.id != match[3] ) bgneal@45: return jQuery().find( selector ); bgneal@45: bgneal@45: // Otherwise, we inject the element directly into the jQuery object bgneal@45: return jQuery( elem ); bgneal@45: } bgneal@45: selector = []; bgneal@45: } bgneal@45: bgneal@45: // HANDLE: $(expr, [context]) bgneal@45: // (which is just equivalent to: $(content).find(expr) bgneal@45: } else bgneal@45: return jQuery( context ).find( selector ); bgneal@45: bgneal@45: // HANDLE: $(function) bgneal@45: // Shortcut for document ready bgneal@45: } else if ( jQuery.isFunction( selector ) ) bgneal@45: return jQuery( document )[ jQuery.fn.ready ? "ready" : "load" ]( selector ); bgneal@45: bgneal@45: return this.setArray(jQuery.makeArray(selector)); bgneal@45: }, bgneal@45: bgneal@45: // The current version of jQuery being used bgneal@45: jquery: "1.2.6", bgneal@45: bgneal@45: // The number of elements contained in the matched element set bgneal@45: size: function() { bgneal@45: return this.length; bgneal@45: }, bgneal@45: bgneal@45: // The number of elements contained in the matched element set bgneal@45: length: 0, bgneal@45: bgneal@45: // Get the Nth element in the matched element set OR bgneal@45: // Get the whole matched element set as a clean array bgneal@45: get: function( num ) { bgneal@45: return num == undefined ? bgneal@45: bgneal@45: // Return a 'clean' array bgneal@45: jQuery.makeArray( this ) : bgneal@45: bgneal@45: // Return just the object bgneal@45: this[ num ]; bgneal@45: }, bgneal@45: bgneal@45: // Take an array of elements and push it onto the stack bgneal@45: // (returning the new matched element set) bgneal@45: pushStack: function( elems ) { bgneal@45: // Build a new jQuery matched element set bgneal@45: var ret = jQuery( elems ); bgneal@45: bgneal@45: // Add the old object onto the stack (as a reference) bgneal@45: ret.prevObject = this; bgneal@45: bgneal@45: // Return the newly-formed element set bgneal@45: return ret; bgneal@45: }, bgneal@45: bgneal@45: // Force the current matched set of elements to become bgneal@45: // the specified array of elements (destroying the stack in the process) bgneal@45: // You should use pushStack() in order to do this, but maintain the stack bgneal@45: setArray: function( elems ) { bgneal@45: // Resetting the length to 0, then using the native Array push bgneal@45: // is a super-fast way to populate an object with array-like properties bgneal@45: this.length = 0; bgneal@45: Array.prototype.push.apply( this, elems ); bgneal@45: bgneal@45: return this; bgneal@45: }, bgneal@45: bgneal@45: // Execute a callback for every element in the matched set. bgneal@45: // (You can seed the arguments with an array of args, but this is bgneal@45: // only used internally.) bgneal@45: each: function( callback, args ) { bgneal@45: return jQuery.each( this, callback, args ); bgneal@45: }, bgneal@45: bgneal@45: // Determine the position of an element within bgneal@45: // the matched set of elements bgneal@45: index: function( elem ) { bgneal@45: var ret = -1; bgneal@45: bgneal@45: // Locate the position of the desired element bgneal@45: return jQuery.inArray( bgneal@45: // If it receives a jQuery object, the first element is used bgneal@45: elem && elem.jquery ? elem[0] : elem bgneal@45: , this ); bgneal@45: }, bgneal@45: bgneal@45: attr: function( name, value, type ) { bgneal@45: var options = name; bgneal@45: bgneal@45: // Look for the case where we're accessing a style value bgneal@45: if ( name.constructor == String ) bgneal@45: if ( value === undefined ) bgneal@45: return this[0] && jQuery[ type || "attr" ]( this[0], name ); bgneal@45: bgneal@45: else { bgneal@45: options = {}; bgneal@45: options[ name ] = value; bgneal@45: } bgneal@45: bgneal@45: // Check to see if we're setting style values bgneal@45: return this.each(function(i){ bgneal@45: // Set all the styles bgneal@45: for ( name in options ) bgneal@45: jQuery.attr( bgneal@45: type ? bgneal@45: this.style : bgneal@45: this, bgneal@45: name, jQuery.prop( this, options[ name ], type, i, name ) bgneal@45: ); bgneal@45: }); bgneal@45: }, bgneal@45: bgneal@45: css: function( key, value ) { bgneal@45: // ignore negative width and height values bgneal@45: if ( (key == 'width' || key == 'height') && parseFloat(value) < 0 ) bgneal@45: value = undefined; bgneal@45: return this.attr( key, value, "curCSS" ); bgneal@45: }, bgneal@45: bgneal@45: text: function( text ) { bgneal@45: if ( typeof text != "object" && text != null ) bgneal@45: return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); bgneal@45: bgneal@45: var ret = ""; bgneal@45: bgneal@45: jQuery.each( text || this, function(){ bgneal@45: jQuery.each( this.childNodes, function(){ bgneal@45: if ( this.nodeType != 8 ) bgneal@45: ret += this.nodeType != 1 ? bgneal@45: this.nodeValue : bgneal@45: jQuery.fn.text( [ this ] ); bgneal@45: }); bgneal@45: }); bgneal@45: bgneal@45: return ret; bgneal@45: }, bgneal@45: bgneal@45: wrapAll: function( html ) { bgneal@45: if ( this[0] ) bgneal@45: // The elements to wrap the target around bgneal@45: jQuery( html, this[0].ownerDocument ) bgneal@45: .clone() bgneal@45: .insertBefore( this[0] ) bgneal@45: .map(function(){ bgneal@45: var elem = this; bgneal@45: bgneal@45: while ( elem.firstChild ) bgneal@45: elem = elem.firstChild; bgneal@45: bgneal@45: return elem; bgneal@45: }) bgneal@45: .append(this); bgneal@45: bgneal@45: return this; bgneal@45: }, bgneal@45: bgneal@45: wrapInner: function( html ) { bgneal@45: return this.each(function(){ bgneal@45: jQuery( this ).contents().wrapAll( html ); bgneal@45: }); bgneal@45: }, bgneal@45: bgneal@45: wrap: function( html ) { bgneal@45: return this.each(function(){ bgneal@45: jQuery( this ).wrapAll( html ); bgneal@45: }); bgneal@45: }, bgneal@45: bgneal@45: append: function() { bgneal@45: return this.domManip(arguments, true, false, function(elem){ bgneal@45: if (this.nodeType == 1) bgneal@45: this.appendChild( elem ); bgneal@45: }); bgneal@45: }, bgneal@45: bgneal@45: prepend: function() { bgneal@45: return this.domManip(arguments, true, true, function(elem){ bgneal@45: if (this.nodeType == 1) bgneal@45: this.insertBefore( elem, this.firstChild ); bgneal@45: }); bgneal@45: }, bgneal@45: bgneal@45: before: function() { bgneal@45: return this.domManip(arguments, false, false, function(elem){ bgneal@45: this.parentNode.insertBefore( elem, this ); bgneal@45: }); bgneal@45: }, bgneal@45: bgneal@45: after: function() { bgneal@45: return this.domManip(arguments, false, true, function(elem){ bgneal@45: this.parentNode.insertBefore( elem, this.nextSibling ); bgneal@45: }); bgneal@45: }, bgneal@45: bgneal@45: end: function() { bgneal@45: return this.prevObject || jQuery( [] ); bgneal@45: }, bgneal@45: bgneal@45: find: function( selector ) { bgneal@45: var elems = jQuery.map(this, function(elem){ bgneal@45: return jQuery.find( selector, elem ); bgneal@45: }); bgneal@45: bgneal@45: return this.pushStack( /[^+>] [^+>]/.test( selector ) || selector.indexOf("..") > -1 ? bgneal@45: jQuery.unique( elems ) : bgneal@45: elems ); bgneal@45: }, bgneal@45: bgneal@45: clone: function( events ) { bgneal@45: // Do the clone bgneal@45: var ret = this.map(function(){ bgneal@45: if ( jQuery.browser.msie && !jQuery.isXMLDoc(this) ) { bgneal@45: // IE copies events bound via attachEvent when bgneal@45: // using cloneNode. Calling detachEvent on the bgneal@45: // clone will also remove the events from the orignal bgneal@45: // In order to get around this, we use innerHTML. bgneal@45: // Unfortunately, this means some modifications to bgneal@45: // attributes in IE that are actually only stored bgneal@45: // as properties will not be copied (such as the bgneal@45: // the name attribute on an input). bgneal@45: var clone = this.cloneNode(true), bgneal@45: container = document.createElement("div"); bgneal@45: container.appendChild(clone); bgneal@45: return jQuery.clean([container.innerHTML])[0]; bgneal@45: } else bgneal@45: return this.cloneNode(true); bgneal@45: }); bgneal@45: bgneal@45: // Need to set the expando to null on the cloned set if it exists bgneal@45: // removeData doesn't work here, IE removes it from the original as well bgneal@45: // this is primarily for IE but the data expando shouldn't be copied over in any browser bgneal@45: var clone = ret.find("*").andSelf().each(function(){ bgneal@45: if ( this[ expando ] != undefined ) bgneal@45: this[ expando ] = null; bgneal@45: }); bgneal@45: bgneal@45: // Copy the events from the original to the clone bgneal@45: if ( events === true ) bgneal@45: this.find("*").andSelf().each(function(i){ bgneal@45: if (this.nodeType == 3) bgneal@45: return; bgneal@45: var events = jQuery.data( this, "events" ); bgneal@45: bgneal@45: for ( var type in events ) bgneal@45: for ( var handler in events[ type ] ) bgneal@45: jQuery.event.add( clone[ i ], type, events[ type ][ handler ], events[ type ][ handler ].data ); bgneal@45: }); bgneal@45: bgneal@45: // Return the cloned set bgneal@45: return ret; bgneal@45: }, bgneal@45: bgneal@45: filter: function( selector ) { bgneal@45: return this.pushStack( bgneal@45: jQuery.isFunction( selector ) && bgneal@45: jQuery.grep(this, function(elem, i){ bgneal@45: return selector.call( elem, i ); bgneal@45: }) || bgneal@45: bgneal@45: jQuery.multiFilter( selector, this ) ); bgneal@45: }, bgneal@45: bgneal@45: not: function( selector ) { bgneal@45: if ( selector.constructor == String ) bgneal@45: // test special case where just one selector is passed in bgneal@45: if ( isSimple.test( selector ) ) bgneal@45: return this.pushStack( jQuery.multiFilter( selector, this, true ) ); bgneal@45: else bgneal@45: selector = jQuery.multiFilter( selector, this ); bgneal@45: bgneal@45: var isArrayLike = selector.length && selector[selector.length - 1] !== undefined && !selector.nodeType; bgneal@45: return this.filter(function() { bgneal@45: return isArrayLike ? jQuery.inArray( this, selector ) < 0 : this != selector; bgneal@45: }); bgneal@45: }, bgneal@45: bgneal@45: add: function( selector ) { bgneal@45: return this.pushStack( jQuery.unique( jQuery.merge( bgneal@45: this.get(), bgneal@45: typeof selector == 'string' ? bgneal@45: jQuery( selector ) : bgneal@45: jQuery.makeArray( selector ) bgneal@45: ))); bgneal@45: }, bgneal@45: bgneal@45: is: function( selector ) { bgneal@45: return !!selector && jQuery.multiFilter( selector, this ).length > 0; bgneal@45: }, bgneal@45: bgneal@45: hasClass: function( selector ) { bgneal@45: return this.is( "." + selector ); bgneal@45: }, bgneal@45: bgneal@45: val: function( value ) { bgneal@45: if ( value == undefined ) { bgneal@45: bgneal@45: if ( this.length ) { bgneal@45: var elem = this[0]; bgneal@45: bgneal@45: // We need to handle select boxes special bgneal@45: if ( jQuery.nodeName( elem, "select" ) ) { bgneal@45: var index = elem.selectedIndex, bgneal@45: values = [], bgneal@45: options = elem.options, bgneal@45: one = elem.type == "select-one"; bgneal@45: bgneal@45: // Nothing was selected bgneal@45: if ( index < 0 ) bgneal@45: return null; bgneal@45: bgneal@45: // Loop through all the selected options bgneal@45: for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { bgneal@45: var option = options[ i ]; bgneal@45: bgneal@45: if ( option.selected ) { bgneal@45: // Get the specifc value for the option bgneal@45: value = jQuery.browser.msie && !option.attributes.value.specified ? option.text : option.value; bgneal@45: bgneal@45: // We don't need an array for one selects bgneal@45: if ( one ) bgneal@45: return value; bgneal@45: bgneal@45: // Multi-Selects return an array bgneal@45: values.push( value ); bgneal@45: } bgneal@45: } bgneal@45: bgneal@45: return values; bgneal@45: bgneal@45: // Everything else, we just grab the value bgneal@45: } else bgneal@45: return (this[0].value || "").replace(/\r/g, ""); bgneal@45: bgneal@45: } bgneal@45: bgneal@45: return undefined; bgneal@45: } bgneal@45: bgneal@45: if( value.constructor == Number ) bgneal@45: value += ''; bgneal@45: bgneal@45: return this.each(function(){ bgneal@45: if ( this.nodeType != 1 ) bgneal@45: return; bgneal@45: bgneal@45: if ( value.constructor == Array && /radio|checkbox/.test( this.type ) ) bgneal@45: this.checked = (jQuery.inArray(this.value, value) >= 0 || bgneal@45: jQuery.inArray(this.name, value) >= 0); bgneal@45: bgneal@45: else if ( jQuery.nodeName( this, "select" ) ) { bgneal@45: var values = jQuery.makeArray(value); bgneal@45: bgneal@45: jQuery( "option", this ).each(function(){ bgneal@45: this.selected = (jQuery.inArray( this.value, values ) >= 0 || bgneal@45: jQuery.inArray( this.text, values ) >= 0); bgneal@45: }); bgneal@45: bgneal@45: if ( !values.length ) bgneal@45: this.selectedIndex = -1; bgneal@45: bgneal@45: } else bgneal@45: this.value = value; bgneal@45: }); bgneal@45: }, bgneal@45: bgneal@45: html: function( value ) { bgneal@45: return value == undefined ? bgneal@45: (this[0] ? bgneal@45: this[0].innerHTML : bgneal@45: null) : bgneal@45: this.empty().append( value ); bgneal@45: }, bgneal@45: bgneal@45: replaceWith: function( value ) { bgneal@45: return this.after( value ).remove(); bgneal@45: }, bgneal@45: bgneal@45: eq: function( i ) { bgneal@45: return this.slice( i, i + 1 ); bgneal@45: }, bgneal@45: bgneal@45: slice: function() { bgneal@45: return this.pushStack( Array.prototype.slice.apply( this, arguments ) ); bgneal@45: }, bgneal@45: bgneal@45: map: function( callback ) { bgneal@45: return this.pushStack( jQuery.map(this, function(elem, i){ bgneal@45: return callback.call( elem, i, elem ); bgneal@45: })); bgneal@45: }, bgneal@45: bgneal@45: andSelf: function() { bgneal@45: return this.add( this.prevObject ); bgneal@45: }, bgneal@45: bgneal@45: data: function( key, value ){ bgneal@45: var parts = key.split("."); bgneal@45: parts[1] = parts[1] ? "." + parts[1] : ""; bgneal@45: bgneal@45: if ( value === undefined ) { bgneal@45: var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); bgneal@45: bgneal@45: if ( data === undefined && this.length ) bgneal@45: data = jQuery.data( this[0], key ); bgneal@45: bgneal@45: return data === undefined && parts[1] ? bgneal@45: this.data( parts[0] ) : bgneal@45: data; bgneal@45: } else bgneal@45: return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){ bgneal@45: jQuery.data( this, key, value ); bgneal@45: }); bgneal@45: }, bgneal@45: bgneal@45: removeData: function( key ){ bgneal@45: return this.each(function(){ bgneal@45: jQuery.removeData( this, key ); bgneal@45: }); bgneal@45: }, bgneal@45: bgneal@45: domManip: function( args, table, reverse, callback ) { bgneal@45: var clone = this.length > 1, elems; bgneal@45: bgneal@45: return this.each(function(){ bgneal@45: if ( !elems ) { bgneal@45: elems = jQuery.clean( args, this.ownerDocument ); bgneal@45: bgneal@45: if ( reverse ) bgneal@45: elems.reverse(); bgneal@45: } bgneal@45: bgneal@45: var obj = this; bgneal@45: bgneal@45: if ( table && jQuery.nodeName( this, "table" ) && jQuery.nodeName( elems[0], "tr" ) ) bgneal@45: obj = this.getElementsByTagName("tbody")[0] || this.appendChild( this.ownerDocument.createElement("tbody") ); bgneal@45: bgneal@45: var scripts = jQuery( [] ); bgneal@45: bgneal@45: jQuery.each(elems, function(){ bgneal@45: var elem = clone ? bgneal@45: jQuery( this ).clone( true )[0] : bgneal@45: this; bgneal@45: bgneal@45: // execute all scripts after the elements have been injected bgneal@45: if ( jQuery.nodeName( elem, "script" ) ) bgneal@45: scripts = scripts.add( elem ); bgneal@45: else { bgneal@45: // Remove any inner scripts for later evaluation bgneal@45: if ( elem.nodeType == 1 ) bgneal@45: scripts = scripts.add( jQuery( "script", elem ).remove() ); bgneal@45: bgneal@45: // Inject the elements into the document bgneal@45: callback.call( obj, elem ); bgneal@45: } bgneal@45: }); bgneal@45: bgneal@45: scripts.each( evalScript ); bgneal@45: }); bgneal@45: } bgneal@45: }; bgneal@45: bgneal@45: // Give the init function the jQuery prototype for later instantiation bgneal@45: jQuery.fn.init.prototype = jQuery.fn; bgneal@45: bgneal@45: function evalScript( i, elem ) { bgneal@45: if ( elem.src ) bgneal@45: jQuery.ajax({ bgneal@45: url: elem.src, bgneal@45: async: false, bgneal@45: dataType: "script" bgneal@45: }); bgneal@45: bgneal@45: else bgneal@45: jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" ); bgneal@45: bgneal@45: if ( elem.parentNode ) bgneal@45: elem.parentNode.removeChild( elem ); bgneal@45: } bgneal@45: bgneal@45: function now(){ bgneal@45: return +new Date; bgneal@45: } bgneal@45: bgneal@45: jQuery.extend = jQuery.fn.extend = function() { bgneal@45: // copy reference to target object bgneal@45: var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options; bgneal@45: bgneal@45: // Handle a deep copy situation bgneal@45: if ( target.constructor == Boolean ) { bgneal@45: deep = target; bgneal@45: target = arguments[1] || {}; bgneal@45: // skip the boolean and the target bgneal@45: i = 2; bgneal@45: } bgneal@45: bgneal@45: // Handle case when target is a string or something (possible in deep copy) bgneal@45: if ( typeof target != "object" && typeof target != "function" ) bgneal@45: target = {}; bgneal@45: bgneal@45: // extend jQuery itself if only one argument is passed bgneal@45: if ( length == i ) { bgneal@45: target = this; bgneal@45: --i; bgneal@45: } bgneal@45: bgneal@45: for ( ; i < length; i++ ) bgneal@45: // Only deal with non-null/undefined values bgneal@45: if ( (options = arguments[ i ]) != null ) bgneal@45: // Extend the base object bgneal@45: for ( var name in options ) { bgneal@45: var src = target[ name ], copy = options[ name ]; bgneal@45: bgneal@45: // Prevent never-ending loop bgneal@45: if ( target === copy ) bgneal@45: continue; bgneal@45: bgneal@45: // Recurse if we're merging object values bgneal@45: if ( deep && copy && typeof copy == "object" && !copy.nodeType ) bgneal@45: target[ name ] = jQuery.extend( deep, bgneal@45: // Never move original objects, clone them bgneal@45: src || ( copy.length != null ? [ ] : { } ) bgneal@45: , copy ); bgneal@45: bgneal@45: // Don't bring in undefined values bgneal@45: else if ( copy !== undefined ) bgneal@45: target[ name ] = copy; bgneal@45: bgneal@45: } bgneal@45: bgneal@45: // Return the modified object bgneal@45: return target; bgneal@45: }; bgneal@45: bgneal@45: var expando = "jQuery" + now(), uuid = 0, windowData = {}, bgneal@45: // exclude the following css properties to add px bgneal@45: exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i, bgneal@45: // cache defaultView bgneal@45: defaultView = document.defaultView || {}; bgneal@45: bgneal@45: jQuery.extend({ bgneal@45: noConflict: function( deep ) { bgneal@45: window.$ = _$; bgneal@45: bgneal@45: if ( deep ) bgneal@45: window.jQuery = _jQuery; bgneal@45: bgneal@45: return jQuery; bgneal@45: }, bgneal@45: bgneal@45: // See test/unit/core.js for details concerning this function. bgneal@45: isFunction: function( fn ) { bgneal@45: return !!fn && typeof fn != "string" && !fn.nodeName && bgneal@45: fn.constructor != Array && /^[\s[]?function/.test( fn + "" ); bgneal@45: }, bgneal@45: bgneal@45: // check if an element is in a (or is an) XML document bgneal@45: isXMLDoc: function( elem ) { bgneal@45: return elem.documentElement && !elem.body || bgneal@45: elem.tagName && elem.ownerDocument && !elem.ownerDocument.body; bgneal@45: }, bgneal@45: bgneal@45: // Evalulates a script in a global context bgneal@45: globalEval: function( data ) { bgneal@45: data = jQuery.trim( data ); bgneal@45: bgneal@45: if ( data ) { bgneal@45: // Inspired by code by Andrea Giammarchi bgneal@45: // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html bgneal@45: var head = document.getElementsByTagName("head")[0] || document.documentElement, bgneal@45: script = document.createElement("script"); bgneal@45: bgneal@45: script.type = "text/javascript"; bgneal@45: if ( jQuery.browser.msie ) bgneal@45: script.text = data; bgneal@45: else bgneal@45: script.appendChild( document.createTextNode( data ) ); bgneal@45: bgneal@45: // Use insertBefore instead of appendChild to circumvent an IE6 bug. bgneal@45: // This arises when a base node is used (#2709). bgneal@45: head.insertBefore( script, head.firstChild ); bgneal@45: head.removeChild( script ); bgneal@45: } bgneal@45: }, bgneal@45: bgneal@45: nodeName: function( elem, name ) { bgneal@45: return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase(); bgneal@45: }, bgneal@45: bgneal@45: cache: {}, bgneal@45: bgneal@45: data: function( elem, name, data ) { bgneal@45: elem = elem == window ? bgneal@45: windowData : bgneal@45: elem; bgneal@45: bgneal@45: var id = elem[ expando ]; bgneal@45: bgneal@45: // Compute a unique ID for the element bgneal@45: if ( !id ) bgneal@45: id = elem[ expando ] = ++uuid; bgneal@45: bgneal@45: // Only generate the data cache if we're bgneal@45: // trying to access or manipulate it bgneal@45: if ( name && !jQuery.cache[ id ] ) bgneal@45: jQuery.cache[ id ] = {}; bgneal@45: bgneal@45: // Prevent overriding the named cache with undefined values bgneal@45: if ( data !== undefined ) bgneal@45: jQuery.cache[ id ][ name ] = data; bgneal@45: bgneal@45: // Return the named cache data, or the ID for the element bgneal@45: return name ? bgneal@45: jQuery.cache[ id ][ name ] : bgneal@45: id; bgneal@45: }, bgneal@45: bgneal@45: removeData: function( elem, name ) { bgneal@45: elem = elem == window ? bgneal@45: windowData : bgneal@45: elem; bgneal@45: bgneal@45: var id = elem[ expando ]; bgneal@45: bgneal@45: // If we want to remove a specific section of the element's data bgneal@45: if ( name ) { bgneal@45: if ( jQuery.cache[ id ] ) { bgneal@45: // Remove the section of cache data bgneal@45: delete jQuery.cache[ id ][ name ]; bgneal@45: bgneal@45: // If we've removed all the data, remove the element's cache bgneal@45: name = ""; bgneal@45: bgneal@45: for ( name in jQuery.cache[ id ] ) bgneal@45: break; bgneal@45: bgneal@45: if ( !name ) bgneal@45: jQuery.removeData( elem ); bgneal@45: } bgneal@45: bgneal@45: // Otherwise, we want to remove all of the element's data bgneal@45: } else { bgneal@45: // Clean up the element expando bgneal@45: try { bgneal@45: delete elem[ expando ]; bgneal@45: } catch(e){ bgneal@45: // IE has trouble directly removing the expando bgneal@45: // but it's ok with using removeAttribute bgneal@45: if ( elem.removeAttribute ) bgneal@45: elem.removeAttribute( expando ); bgneal@45: } bgneal@45: bgneal@45: // Completely remove the data cache bgneal@45: delete jQuery.cache[ id ]; bgneal@45: } bgneal@45: }, bgneal@45: bgneal@45: // args is for internal usage only bgneal@45: each: function( object, callback, args ) { bgneal@45: var name, i = 0, length = object.length; bgneal@45: bgneal@45: if ( args ) { bgneal@45: if ( length == undefined ) { bgneal@45: for ( name in object ) bgneal@45: if ( callback.apply( object[ name ], args ) === false ) bgneal@45: break; bgneal@45: } else bgneal@45: for ( ; i < length; ) bgneal@45: if ( callback.apply( object[ i++ ], args ) === false ) bgneal@45: break; bgneal@45: bgneal@45: // A special, fast, case for the most common use of each bgneal@45: } else { bgneal@45: if ( length == undefined ) { bgneal@45: for ( name in object ) bgneal@45: if ( callback.call( object[ name ], name, object[ name ] ) === false ) bgneal@45: break; bgneal@45: } else bgneal@45: for ( var value = object[0]; bgneal@45: i < length && callback.call( value, i, value ) !== false; value = object[++i] ){} bgneal@45: } bgneal@45: bgneal@45: return object; bgneal@45: }, bgneal@45: bgneal@45: prop: function( elem, value, type, i, name ) { bgneal@45: // Handle executable functions bgneal@45: if ( jQuery.isFunction( value ) ) bgneal@45: value = value.call( elem, i ); bgneal@45: bgneal@45: // Handle passing in a number to a CSS property bgneal@45: return value && value.constructor == Number && type == "curCSS" && !exclude.test( name ) ? bgneal@45: value + "px" : bgneal@45: value; bgneal@45: }, bgneal@45: bgneal@45: className: { bgneal@45: // internal only, use addClass("class") bgneal@45: add: function( elem, classNames ) { bgneal@45: jQuery.each((classNames || "").split(/\s+/), function(i, className){ bgneal@45: if ( elem.nodeType == 1 && !jQuery.className.has( elem.className, className ) ) bgneal@45: elem.className += (elem.className ? " " : "") + className; bgneal@45: }); bgneal@45: }, bgneal@45: bgneal@45: // internal only, use removeClass("class") bgneal@45: remove: function( elem, classNames ) { bgneal@45: if (elem.nodeType == 1) bgneal@45: elem.className = classNames != undefined ? bgneal@45: jQuery.grep(elem.className.split(/\s+/), function(className){ bgneal@45: return !jQuery.className.has( classNames, className ); bgneal@45: }).join(" ") : bgneal@45: ""; bgneal@45: }, bgneal@45: bgneal@45: // internal only, use hasClass("class") bgneal@45: has: function( elem, className ) { bgneal@45: return jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1; bgneal@45: } bgneal@45: }, bgneal@45: bgneal@45: // A method for quickly swapping in/out CSS properties to get correct calculations bgneal@45: swap: function( elem, options, callback ) { bgneal@45: var old = {}; bgneal@45: // Remember the old values, and insert the new ones bgneal@45: for ( var name in options ) { bgneal@45: old[ name ] = elem.style[ name ]; bgneal@45: elem.style[ name ] = options[ name ]; bgneal@45: } bgneal@45: bgneal@45: callback.call( elem ); bgneal@45: bgneal@45: // Revert the old values bgneal@45: for ( var name in options ) bgneal@45: elem.style[ name ] = old[ name ]; bgneal@45: }, bgneal@45: bgneal@45: css: function( elem, name, force ) { bgneal@45: if ( name == "width" || name == "height" ) { bgneal@45: var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ]; bgneal@45: bgneal@45: function getWH() { bgneal@45: val = name == "width" ? elem.offsetWidth : elem.offsetHeight; bgneal@45: var padding = 0, border = 0; bgneal@45: jQuery.each( which, function() { bgneal@45: padding += parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0; bgneal@45: border += parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0; bgneal@45: }); bgneal@45: val -= Math.round(padding + border); bgneal@45: } bgneal@45: bgneal@45: if ( jQuery(elem).is(":visible") ) bgneal@45: getWH(); bgneal@45: else bgneal@45: jQuery.swap( elem, props, getWH ); bgneal@45: bgneal@45: return Math.max(0, val); bgneal@45: } bgneal@45: bgneal@45: return jQuery.curCSS( elem, name, force ); bgneal@45: }, bgneal@45: bgneal@45: curCSS: function( elem, name, force ) { bgneal@45: var ret, style = elem.style; bgneal@45: bgneal@45: // A helper method for determining if an element's values are broken bgneal@45: function color( elem ) { bgneal@45: if ( !jQuery.browser.safari ) bgneal@45: return false; bgneal@45: bgneal@45: // defaultView is cached bgneal@45: var ret = defaultView.getComputedStyle( elem, null ); bgneal@45: return !ret || ret.getPropertyValue("color") == ""; bgneal@45: } bgneal@45: bgneal@45: // We need to handle opacity special in IE bgneal@45: if ( name == "opacity" && jQuery.browser.msie ) { bgneal@45: ret = jQuery.attr( style, "opacity" ); bgneal@45: bgneal@45: return ret == "" ? bgneal@45: "1" : bgneal@45: ret; bgneal@45: } bgneal@45: // Opera sometimes will give the wrong display answer, this fixes it, see #2037 bgneal@45: if ( jQuery.browser.opera && name == "display" ) { bgneal@45: var save = style.outline; bgneal@45: style.outline = "0 solid black"; bgneal@45: style.outline = save; bgneal@45: } bgneal@45: bgneal@45: // Make sure we're using the right name for getting the float value bgneal@45: if ( name.match( /float/i ) ) bgneal@45: name = styleFloat; bgneal@45: bgneal@45: if ( !force && style && style[ name ] ) bgneal@45: ret = style[ name ]; bgneal@45: bgneal@45: else if ( defaultView.getComputedStyle ) { bgneal@45: bgneal@45: // Only "float" is needed here bgneal@45: if ( name.match( /float/i ) ) bgneal@45: name = "float"; bgneal@45: bgneal@45: name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase(); bgneal@45: bgneal@45: var computedStyle = defaultView.getComputedStyle( elem, null ); bgneal@45: bgneal@45: if ( computedStyle && !color( elem ) ) bgneal@45: ret = computedStyle.getPropertyValue( name ); bgneal@45: bgneal@45: // If the element isn't reporting its values properly in Safari bgneal@45: // then some display: none elements are involved bgneal@45: else { bgneal@45: var swap = [], stack = [], a = elem, i = 0; bgneal@45: bgneal@45: // Locate all of the parent display: none elements bgneal@45: for ( ; a && color(a); a = a.parentNode ) bgneal@45: stack.unshift(a); bgneal@45: bgneal@45: // Go through and make them visible, but in reverse bgneal@45: // (It would be better if we knew the exact display type that they had) bgneal@45: for ( ; i < stack.length; i++ ) bgneal@45: if ( color( stack[ i ] ) ) { bgneal@45: swap[ i ] = stack[ i ].style.display; bgneal@45: stack[ i ].style.display = "block"; bgneal@45: } bgneal@45: bgneal@45: // Since we flip the display style, we have to handle that bgneal@45: // one special, otherwise get the value bgneal@45: ret = name == "display" && swap[ stack.length - 1 ] != null ? bgneal@45: "none" : bgneal@45: ( computedStyle && computedStyle.getPropertyValue( name ) ) || ""; bgneal@45: bgneal@45: // Finally, revert the display styles back bgneal@45: for ( i = 0; i < swap.length; i++ ) bgneal@45: if ( swap[ i ] != null ) bgneal@45: stack[ i ].style.display = swap[ i ]; bgneal@45: } bgneal@45: bgneal@45: // We should always get a number back from opacity bgneal@45: if ( name == "opacity" && ret == "" ) bgneal@45: ret = "1"; bgneal@45: bgneal@45: } else if ( elem.currentStyle ) { bgneal@45: var camelCase = name.replace(/\-(\w)/g, function(all, letter){ bgneal@45: return letter.toUpperCase(); bgneal@45: }); bgneal@45: bgneal@45: ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ]; bgneal@45: bgneal@45: // From the awesome hack by Dean Edwards bgneal@45: // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 bgneal@45: bgneal@45: // If we're not dealing with a regular pixel number bgneal@45: // but a number that has a weird ending, we need to convert it to pixels bgneal@45: if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) { bgneal@45: // Remember the original values bgneal@45: var left = style.left, rsLeft = elem.runtimeStyle.left; bgneal@45: bgneal@45: // Put in the new values to get a computed value out bgneal@45: elem.runtimeStyle.left = elem.currentStyle.left; bgneal@45: style.left = ret || 0; bgneal@45: ret = style.pixelLeft + "px"; bgneal@45: bgneal@45: // Revert the changed values bgneal@45: style.left = left; bgneal@45: elem.runtimeStyle.left = rsLeft; bgneal@45: } bgneal@45: } bgneal@45: bgneal@45: return ret; bgneal@45: }, bgneal@45: bgneal@45: clean: function( elems, context ) { bgneal@45: var ret = []; bgneal@45: context = context || document; bgneal@45: // !context.createElement fails in IE with an error but returns typeof 'object' bgneal@45: if (typeof context.createElement == 'undefined') bgneal@45: context = context.ownerDocument || context[0] && context[0].ownerDocument || document; bgneal@45: bgneal@45: jQuery.each(elems, function(i, elem){ bgneal@45: if ( !elem ) bgneal@45: return; bgneal@45: bgneal@45: if ( elem.constructor == Number ) bgneal@45: elem += ''; bgneal@45: bgneal@45: // Convert html string into DOM nodes bgneal@45: if ( typeof elem == "string" ) { bgneal@45: // Fix "XHTML"-style tags in all browsers bgneal@45: elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){ bgneal@45: return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i) ? bgneal@45: all : bgneal@45: front + ">"; bgneal@45: }); bgneal@45: bgneal@45: // Trim whitespace, otherwise indexOf won't work as expected bgneal@45: var tags = jQuery.trim( elem ).toLowerCase(), div = context.createElement("div"); bgneal@45: bgneal@45: var wrap = bgneal@45: // option or optgroup bgneal@45: !tags.indexOf("", "" ] || bgneal@45: bgneal@45: !tags.indexOf("", "" ] || bgneal@45: bgneal@45: tags.match(/^<(thead|tbody|tfoot|colg|cap)/) && bgneal@45: [ 1, "", "
" ] || bgneal@45: bgneal@45: !tags.indexOf("", "" ] || bgneal@45: bgneal@45: // matched above bgneal@45: (!tags.indexOf("", "" ] || bgneal@45: bgneal@45: !tags.indexOf("", "" ] || bgneal@45: bgneal@45: // IE can't serialize and