2006-12-23 07:07:21 +01:00
|
|
|
/*
|
|
|
|
* jQuery @VERSION - New Wave Javascript
|
|
|
|
*
|
2007-01-14 23:25:27 +01:00
|
|
|
* Copyright (c) 2007 John Resig (jquery.com)
|
2006-12-23 07:07:21 +01:00
|
|
|
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
|
|
|
* and GPL (GPL-LICENSE.txt) licenses.
|
|
|
|
*
|
|
|
|
* $Date$
|
|
|
|
* $Rev$
|
|
|
|
*/
|
|
|
|
|
2007-08-22 07:44:47 +02:00
|
|
|
// Map over jQuery in case of overwrite
|
|
|
|
if ( typeof jQuery != "undefined" )
|
|
|
|
var _jQuery = jQuery;
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
var jQuery = window.jQuery = function( selector, context ) {
|
2007-09-15 04:24:44 +02:00
|
|
|
// If the context is a namespace object, return a new object
|
|
|
|
return this instanceof jQuery ?
|
2007-09-23 18:55:19 +02:00
|
|
|
this.init( selector, context ) :
|
|
|
|
new jQuery( selector, context );
|
2006-12-23 07:07:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// Map over the $ in case of overwrite
|
|
|
|
if ( typeof $ != "undefined" )
|
2007-08-22 07:44:47 +02:00
|
|
|
var _$ = $;
|
2006-12-23 07:07:21 +01:00
|
|
|
|
|
|
|
// Map the jQuery namespace to the '$' one
|
2007-08-21 07:43:44 +02:00
|
|
|
window.$ = jQuery;
|
2006-12-23 07:07:21 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
// A simple way to check for HTML strings or ID strings
|
|
|
|
// (both of which we optimize for)
|
2007-08-21 10:25:11 +02:00
|
|
|
var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/;
|
|
|
|
|
2006-12-23 07:07:21 +01:00
|
|
|
jQuery.fn = jQuery.prototype = {
|
2007-09-23 18:55:19 +02:00
|
|
|
init: function( selector, context ) {
|
2007-05-01 23:03:44 +02:00
|
|
|
// Make sure that a selection was provided
|
2007-09-15 04:24:44 +02:00
|
|
|
selector = selector || document;
|
2007-05-01 23:03:44 +02:00
|
|
|
|
|
|
|
// Handle HTML strings
|
2007-09-15 04:24:44 +02:00
|
|
|
if ( typeof selector == "string" ) {
|
2007-09-23 18:55:19 +02:00
|
|
|
// Are we dealing with HTML string or an ID?
|
|
|
|
var match = quickExpr.exec( selector );
|
|
|
|
|
|
|
|
// Verify a match, and that no context was specified for #id
|
|
|
|
if ( match && (match[1] || !context) ) {
|
|
|
|
|
2007-08-21 10:25:11 +02:00
|
|
|
// HANDLE: $(html) -> $(array)
|
2007-09-23 18:55:19 +02:00
|
|
|
if ( match[1] )
|
|
|
|
selector = jQuery.clean( [ match[1] ], context );
|
2007-08-21 10:25:11 +02:00
|
|
|
|
|
|
|
// HANDLE: $("#id")
|
|
|
|
else {
|
2007-09-23 18:55:19 +02:00
|
|
|
var elem = document.getElementById( match[3] );
|
|
|
|
|
|
|
|
// Make sure an element was located
|
|
|
|
if ( elem )
|
2007-08-21 10:25:11 +02:00
|
|
|
// Handle the case where IE and Opera return items
|
|
|
|
// by name instead of ID
|
2007-09-23 18:55:19 +02:00
|
|
|
if ( elem.id != match[3] )
|
2007-09-15 04:24:44 +02:00
|
|
|
return jQuery().find( selector );
|
2007-09-23 18:55:19 +02:00
|
|
|
|
|
|
|
// Otherwise, we inject the element directly into the jQuery object
|
2007-08-21 10:25:11 +02:00
|
|
|
else {
|
2007-09-23 18:55:19 +02:00
|
|
|
this[0] = elem;
|
2007-08-21 10:25:11 +02:00
|
|
|
this.length = 1;
|
|
|
|
return this;
|
|
|
|
}
|
2007-09-23 18:55:19 +02:00
|
|
|
|
2007-08-21 10:25:11 +02:00
|
|
|
else
|
2007-09-15 04:24:44 +02:00
|
|
|
selector = [];
|
2007-08-21 10:25:11 +02:00
|
|
|
}
|
2007-05-01 23:03:44 +02:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
// HANDLE: $(expr, [context])
|
|
|
|
// (which is just equivalent to: $(content).find(expr)
|
2007-08-21 10:25:11 +02:00
|
|
|
} else
|
2007-09-15 04:24:44 +02:00
|
|
|
return new jQuery( context ).find( selector );
|
2007-08-21 10:25:11 +02:00
|
|
|
|
|
|
|
// HANDLE: $(function)
|
|
|
|
// Shortcut for document ready
|
2007-09-23 18:55:19 +02:00
|
|
|
} else if ( jQuery.isFunction( selector ) )
|
|
|
|
return new jQuery( document )[ jQuery.fn.ready ? "ready" : "load" ]( selector );
|
2007-05-01 23:03:44 +02:00
|
|
|
|
|
|
|
return this.setArray(
|
|
|
|
// HANDLE: $(array)
|
2007-09-15 04:24:44 +02:00
|
|
|
selector.constructor == Array && selector ||
|
2007-05-01 23:03:44 +02:00
|
|
|
|
|
|
|
// HANDLE: $(arraylike)
|
2007-09-23 18:55:19 +02:00
|
|
|
// Watch for when an array-like object, contains DOM nodes, is passed in as the selector
|
2007-09-15 04:24:44 +02:00
|
|
|
(selector.jquery || selector.length && selector != window && !selector.nodeType && selector[0] != undefined && selector[0].nodeType) && jQuery.makeArray( selector ) ||
|
2007-05-01 23:03:44 +02:00
|
|
|
|
|
|
|
// HANDLE: $(*)
|
2007-09-15 04:24:44 +02:00
|
|
|
[ selector ] );
|
2007-05-01 23:03:44 +02:00
|
|
|
},
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
// The current version of jQuery being used
|
2006-12-23 07:07:21 +01:00
|
|
|
jquery: "@VERSION",
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
// The number of elements contained in the matched element set
|
2006-12-23 07:07:21 +01:00
|
|
|
size: function() {
|
|
|
|
return this.length;
|
|
|
|
},
|
2007-01-02 17:42:31 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
// The number of elements contained in the matched element set
|
2007-01-02 17:42:31 +01:00
|
|
|
length: 0,
|
2006-12-23 07:07:21 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
// Get the Nth element in the matched element set OR
|
|
|
|
// Get the whole matched element set as a clean array
|
2006-12-23 07:07:21 +01:00
|
|
|
get: function( num ) {
|
|
|
|
return num == undefined ?
|
|
|
|
|
|
|
|
// Return a 'clean' array
|
|
|
|
jQuery.makeArray( this ) :
|
|
|
|
|
|
|
|
// Return just the object
|
2007-09-23 18:55:19 +02:00
|
|
|
this[ num ];
|
2006-12-23 07:07:21 +01:00
|
|
|
},
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
// Take an array of elements and push it onto the stack
|
|
|
|
// (returning the new matched element set)
|
|
|
|
pushStack: function( elems ) {
|
|
|
|
// Build a new jQuery matched element set
|
|
|
|
var ret = jQuery( elems );
|
|
|
|
|
|
|
|
// Add the old object onto the stack (as a reference)
|
2007-01-02 17:42:31 +01:00
|
|
|
ret.prevObject = this;
|
2007-09-23 18:55:19 +02:00
|
|
|
|
|
|
|
// Return the newly-formed element set
|
2007-01-23 17:58:03 +01:00
|
|
|
return ret;
|
2007-01-02 17:42:31 +01:00
|
|
|
},
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
// Force the current matched set of elements to become
|
|
|
|
// the specified array of elements (destroying the stack in the process)
|
|
|
|
// You should use pushStack() in order to do this, but maintain the stack
|
|
|
|
setArray: function( elems ) {
|
|
|
|
// Resetting the length to 0, then using the native Array push
|
|
|
|
// is a super-fast way to populate an object with array-like properties
|
2006-12-23 07:07:21 +01:00
|
|
|
this.length = 0;
|
2007-09-23 18:55:19 +02:00
|
|
|
Array.prototype.push.apply( this, elems );
|
|
|
|
|
2006-12-23 07:07:21 +01:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
// Execute a callback for every element in the matched set.
|
|
|
|
// (You can seed the arguments with an array of args, but this is
|
|
|
|
// only used internally.)
|
|
|
|
each: function( callback, args ) {
|
|
|
|
return jQuery.each( this, callback, args );
|
2006-12-23 07:07:21 +01:00
|
|
|
},
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
// Determine the position of an element within
|
|
|
|
// the matched set of elements
|
|
|
|
index: function( elem ) {
|
|
|
|
var ret = -1;
|
|
|
|
|
|
|
|
// Locate the position of the desired element
|
2006-12-23 07:07:21 +01:00
|
|
|
this.each(function(i){
|
2007-09-23 18:55:19 +02:00
|
|
|
if ( this == elem )
|
|
|
|
ret = i;
|
2006-12-23 07:07:21 +01:00
|
|
|
});
|
2007-09-23 18:55:19 +02:00
|
|
|
|
|
|
|
return ret;
|
2006-12-23 07:07:21 +01:00
|
|
|
},
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
attr: function( name, value, type ) {
|
|
|
|
var options = name;
|
2007-01-08 03:39:10 +01:00
|
|
|
|
|
|
|
// Look for the case where we're accessing a style value
|
2007-09-23 18:55:19 +02:00
|
|
|
if ( name.constructor == String )
|
2007-01-08 03:39:10 +01:00
|
|
|
if ( value == undefined )
|
2007-09-23 18:55:19 +02:00
|
|
|
return this.length && jQuery[ type || "attr" ]( this[0], name ) || undefined;
|
|
|
|
|
2007-01-08 03:39:10 +01:00
|
|
|
else {
|
2007-09-23 18:55:19 +02:00
|
|
|
options = {};
|
|
|
|
options[ name ] = value;
|
2007-01-08 03:39:10 +01:00
|
|
|
}
|
|
|
|
|
2006-12-23 07:07:21 +01:00
|
|
|
// Check to see if we're setting style values
|
2007-09-23 18:55:19 +02:00
|
|
|
return this.each(function(i){
|
2007-01-08 03:39:10 +01:00
|
|
|
// Set all the styles
|
2007-09-23 18:55:19 +02:00
|
|
|
for ( name in options )
|
2007-01-08 03:39:10 +01:00
|
|
|
jQuery.attr(
|
2007-09-23 18:55:19 +02:00
|
|
|
type ?
|
|
|
|
this.style :
|
|
|
|
this,
|
|
|
|
name, jQuery.prop( this, options[ name ], type, i, name )
|
2007-01-08 03:39:10 +01:00
|
|
|
);
|
|
|
|
});
|
2006-12-23 07:07:21 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
css: function( key, value ) {
|
|
|
|
return this.attr( key, value, "curCSS" );
|
|
|
|
},
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
text: function( text ) {
|
|
|
|
if ( typeof text != "object" && text != null )
|
|
|
|
return this.empty().append( document.createTextNode( text ) );
|
|
|
|
|
|
|
|
var ret = "";
|
2007-01-14 22:49:59 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
jQuery.each( text || this, function(){
|
2007-01-14 22:49:59 +01:00
|
|
|
jQuery.each( this.childNodes, function(){
|
|
|
|
if ( this.nodeType != 8 )
|
2007-09-23 18:55:19 +02:00
|
|
|
ret += this.nodeType != 1 ?
|
|
|
|
this.nodeValue :
|
|
|
|
jQuery.fn.text( [ this ] );
|
2007-01-14 22:49:59 +01:00
|
|
|
});
|
|
|
|
});
|
2007-09-23 18:55:19 +02:00
|
|
|
|
|
|
|
return ret;
|
2006-12-23 07:07:21 +01:00
|
|
|
},
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
wrapAll: function( html ) {
|
2007-08-31 07:33:43 +02:00
|
|
|
if ( this[0] )
|
|
|
|
// The elements to wrap the target around
|
2007-09-23 18:55:19 +02:00
|
|
|
jQuery( html, this[0].ownerDocument )
|
2007-08-31 07:33:43 +02:00
|
|
|
.clone()
|
2007-09-23 18:55:19 +02:00
|
|
|
.insertBefore( this[0] )
|
2007-08-31 07:33:43 +02:00
|
|
|
.map(function(){
|
|
|
|
var elem = this;
|
2007-09-23 18:55:19 +02:00
|
|
|
|
2007-08-31 07:33:43 +02:00
|
|
|
while ( elem.firstChild )
|
|
|
|
elem = elem.firstChild;
|
2007-09-23 18:55:19 +02:00
|
|
|
|
2007-08-31 07:33:43 +02:00
|
|
|
return elem;
|
|
|
|
})
|
|
|
|
.append(this);
|
2006-12-23 07:07:21 +01:00
|
|
|
|
2007-08-31 07:33:43 +02:00
|
|
|
return this;
|
|
|
|
},
|
2006-12-23 07:07:21 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
wrapInner: function( html ) {
|
2007-08-31 07:33:43 +02:00
|
|
|
return this.each(function(){
|
2007-09-23 18:55:19 +02:00
|
|
|
jQuery( this ).contents().wrapAll( html );
|
2007-08-31 07:33:43 +02:00
|
|
|
});
|
|
|
|
},
|
2006-12-23 07:07:21 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
wrap: function( html ) {
|
2007-08-31 07:33:43 +02:00
|
|
|
return this.each(function(){
|
2007-09-23 18:55:19 +02:00
|
|
|
jQuery( this ).wrapAll( html );
|
2006-12-23 07:07:21 +01:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
append: function() {
|
2007-09-23 18:55:19 +02:00
|
|
|
return this.domManip(arguments, true, false, function(elem){
|
|
|
|
this.appendChild( elem );
|
2006-12-23 07:07:21 +01:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
prepend: function() {
|
2007-09-23 18:55:19 +02:00
|
|
|
return this.domManip(arguments, true, true, function(elem){
|
|
|
|
this.insertBefore( elem, this.firstChild );
|
2006-12-23 07:07:21 +01:00
|
|
|
});
|
|
|
|
},
|
2007-01-02 20:03:12 +01:00
|
|
|
|
2006-12-23 07:07:21 +01:00
|
|
|
before: function() {
|
2007-09-23 18:55:19 +02:00
|
|
|
return this.domManip(arguments, false, false, function(elem){
|
|
|
|
this.parentNode.insertBefore( elem, this );
|
2006-12-23 07:07:21 +01:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
after: function() {
|
2007-09-23 18:55:19 +02:00
|
|
|
return this.domManip(arguments, false, true, function(elem){
|
|
|
|
this.parentNode.insertBefore( elem, this.nextSibling );
|
2006-12-23 07:07:21 +01:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
end: function() {
|
2007-09-23 18:55:19 +02:00
|
|
|
return this.prevObject || jQuery( [] );
|
2006-12-23 07:07:21 +01:00
|
|
|
},
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
find: function( selector ) {
|
|
|
|
var elems = jQuery.map(this, function(elem){
|
|
|
|
return jQuery.find( selector, elem );
|
|
|
|
});
|
|
|
|
|
|
|
|
return this.pushStack( /[^+>] [^+>]/.test( selector ) || selector.indexOf("..") > -1 ?
|
|
|
|
jQuery.unique( elems ) :
|
|
|
|
elems );
|
2006-12-23 07:07:21 +01:00
|
|
|
},
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
clone: function( events ) {
|
2007-05-14 19:46:00 +02:00
|
|
|
// Do the clone
|
2007-09-08 18:19:34 +02:00
|
|
|
var ret = this.map(function(){
|
2007-09-23 18:55:19 +02:00
|
|
|
return this.outerHTML ?
|
|
|
|
jQuery( this.outerHTML )[0] :
|
|
|
|
this.cloneNode( true );
|
2007-09-08 18:19:34 +02:00
|
|
|
});
|
|
|
|
|
2007-09-13 18:45:53 +02:00
|
|
|
// Need to set the expando to null on the cloned set if it exists
|
|
|
|
// removeData doesn't work here, IE removes it from the original as well
|
|
|
|
// this is primarily for IE but the data expando shouldn't be copied over in any browser
|
|
|
|
var clone = ret.find("*").andSelf().each(function(){
|
|
|
|
if ( this[ expando ] != undefined )
|
|
|
|
this[ expando ] = null;
|
|
|
|
});
|
|
|
|
|
|
|
|
// Copy the events from the original to the clone
|
2007-09-23 18:55:19 +02:00
|
|
|
if ( events === true )
|
|
|
|
this.find("*").andSelf().each(function(i){
|
|
|
|
var events = jQuery.data( this, "events" );
|
|
|
|
|
2007-09-08 18:19:34 +02:00
|
|
|
for ( var type in events )
|
2007-09-23 18:55:19 +02:00
|
|
|
for ( var handler in events[ type ] )
|
|
|
|
jQuery.event.add( clone[ i ], type, events[ type ][ handler ], events[ type ][ handler ].data );
|
2007-07-21 05:16:22 +02:00
|
|
|
});
|
2007-07-21 06:26:13 +02:00
|
|
|
|
2007-05-14 19:46:00 +02:00
|
|
|
// Return the cloned set
|
2007-09-08 18:19:34 +02:00
|
|
|
return ret;
|
2006-12-23 07:07:21 +01:00
|
|
|
},
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
filter: function( selector ) {
|
2007-01-10 17:00:22 +01:00
|
|
|
return this.pushStack(
|
2007-09-23 18:55:19 +02:00
|
|
|
jQuery.isFunction( selector ) &&
|
|
|
|
jQuery.grep(this, function(elem, i){
|
|
|
|
return selector.call( elem, i );
|
2006-12-23 07:07:21 +01:00
|
|
|
}) ||
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
jQuery.multiFilter( selector, this ) );
|
2006-12-23 07:07:21 +01:00
|
|
|
},
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
not: function( selector ) {
|
2007-01-10 18:54:42 +01:00
|
|
|
return this.pushStack(
|
2007-09-23 18:55:19 +02:00
|
|
|
selector.constructor == String &&
|
|
|
|
jQuery.multiFilter( selector, this, true ) ||
|
|
|
|
|
|
|
|
jQuery.grep(this, function(elem) {
|
|
|
|
return selector.constructor == Array || selector.jquery ?
|
|
|
|
jQuery.inArray( elem, selector ) < 0 :
|
|
|
|
elem != selector;
|
|
|
|
}) );
|
2006-12-23 07:07:21 +01:00
|
|
|
},
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
add: function( selector ) {
|
|
|
|
return this.pushStack( jQuery.merge( this.get(), jQuery( selector ) ) );
|
2006-12-23 07:07:21 +01:00
|
|
|
},
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
is: function( selector ) {
|
|
|
|
return selector ?
|
|
|
|
jQuery.multiFilter( selector, this ).length > 0 :
|
|
|
|
false;
|
2006-12-23 07:07:21 +01:00
|
|
|
},
|
2007-09-08 15:49:42 +02:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
hasClass: function( selector ) {
|
|
|
|
return this.is( "." + selector );
|
2007-09-08 15:49:42 +02:00
|
|
|
},
|
2006-12-23 07:07:21 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
val: function( value ) {
|
|
|
|
if ( value == undefined ) {
|
|
|
|
|
2007-09-09 21:00:56 +02:00
|
|
|
if ( this.length ) {
|
|
|
|
var elem = this[0];
|
2007-09-05 19:06:05 +02:00
|
|
|
|
2007-09-09 21:00:56 +02:00
|
|
|
// We need to handle select boxes special
|
2007-09-23 18:55:19 +02:00
|
|
|
if ( jQuery.nodeName( elem, "select" ) ) {
|
2007-09-09 21:00:56 +02:00
|
|
|
var index = elem.selectedIndex,
|
2007-09-23 18:55:19 +02:00
|
|
|
values = [],
|
2007-09-05 19:06:05 +02:00
|
|
|
options = elem.options,
|
|
|
|
one = elem.type == "select-one";
|
|
|
|
|
2007-09-09 21:00:56 +02:00
|
|
|
// Nothing was selected
|
|
|
|
if ( index < 0 )
|
|
|
|
return null;
|
|
|
|
|
|
|
|
// Loop through all the selected options
|
|
|
|
for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
|
2007-09-23 18:55:19 +02:00
|
|
|
var option = options[ i ];
|
|
|
|
|
2007-09-09 21:00:56 +02:00
|
|
|
if ( option.selected ) {
|
|
|
|
// Get the specifc value for the option
|
2007-09-23 18:55:19 +02:00
|
|
|
value = jQuery.browser.msie && !option.attributes.value.specified ? option.text : option.value;
|
2007-09-05 19:06:05 +02:00
|
|
|
|
2007-09-09 21:00:56 +02:00
|
|
|
// We don't need an array for one selects
|
|
|
|
if ( one )
|
2007-09-23 18:55:19 +02:00
|
|
|
return value;
|
2007-09-05 19:06:05 +02:00
|
|
|
|
2007-09-09 21:00:56 +02:00
|
|
|
// Multi-Selects return an array
|
2007-09-23 18:55:19 +02:00
|
|
|
values.push( value );
|
2007-09-09 21:00:56 +02:00
|
|
|
}
|
|
|
|
}
|
2007-09-05 19:06:05 +02:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
return values;
|
2007-09-09 21:00:56 +02:00
|
|
|
|
|
|
|
// Everything else, we just grab the value
|
|
|
|
} else
|
2007-09-05 19:06:05 +02:00
|
|
|
return this[0].value.replace(/\r/g, "");
|
2007-09-23 18:55:19 +02:00
|
|
|
|
2007-09-05 19:06:05 +02:00
|
|
|
}
|
2007-09-23 18:55:19 +02:00
|
|
|
|
2007-09-05 19:06:05 +02:00
|
|
|
} else
|
2007-09-09 21:00:56 +02:00
|
|
|
return this.each(function(){
|
2007-09-23 18:55:19 +02:00
|
|
|
if ( value.constructor == Array && /radio|checkbox/.test( this.type ) )
|
|
|
|
this.checked = (jQuery.inArray(this.value, value) >= 0 ||
|
|
|
|
jQuery.inArray(this.name, value) >= 0);
|
|
|
|
|
|
|
|
else if ( jQuery.nodeName( this, "select" ) ) {
|
|
|
|
var values = value.constructor == Array ?
|
|
|
|
value :
|
|
|
|
[ value ];
|
|
|
|
|
|
|
|
jQuery( "option", this ).each(function(){
|
|
|
|
this.selected = (jQuery.inArray( this.value, values ) >= 0 ||
|
|
|
|
jQuery.inArray( this.text, values ) >= 0);
|
2007-09-09 21:00:56 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
if ( !tmp.length )
|
|
|
|
this.selectedIndex = -1;
|
2007-09-23 18:55:19 +02:00
|
|
|
|
2007-09-09 21:00:56 +02:00
|
|
|
} else
|
2007-09-23 18:55:19 +02:00
|
|
|
this.value = value;
|
2007-09-09 21:00:56 +02:00
|
|
|
});
|
2007-01-06 06:09:11 +01:00
|
|
|
},
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
html: function( value ) {
|
|
|
|
return value == undefined ?
|
|
|
|
(this.length ?
|
|
|
|
this[0].innerHTML :
|
|
|
|
null) :
|
|
|
|
this.empty().append( value );
|
2007-01-06 06:09:11 +01:00
|
|
|
},
|
2007-08-20 04:51:57 +02:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
replaceWith: function( value ) {
|
|
|
|
return this.after( value ).remove();
|
2007-08-25 07:12:20 +02:00
|
|
|
},
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
eq: function( i ) {
|
|
|
|
return this.slice( i, i + 1 );
|
2007-09-15 05:08:46 +02:00
|
|
|
},
|
|
|
|
|
2007-08-20 04:51:57 +02:00
|
|
|
slice: function() {
|
|
|
|
return this.pushStack( Array.prototype.slice.apply( this, arguments ) );
|
|
|
|
},
|
2007-08-31 05:26:03 +02:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
map: function( callback ) {
|
|
|
|
return this.pushStack( jQuery.map(this, function(elem, i){
|
|
|
|
return callback.call( elem, i, elem );
|
2007-08-31 05:26:03 +02:00
|
|
|
}));
|
|
|
|
},
|
2007-09-04 06:44:54 +02:00
|
|
|
|
|
|
|
andSelf: function() {
|
|
|
|
return this.add( this.prevObject );
|
|
|
|
},
|
2007-01-06 06:09:11 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
domManip: function( args, table, reverse, callback ) {
|
|
|
|
var clone = this.length > 1, elems;
|
2006-12-23 07:07:21 +01:00
|
|
|
|
|
|
|
return this.each(function(){
|
2007-09-23 18:55:19 +02:00
|
|
|
if ( !elems ) {
|
|
|
|
elems = jQuery.clean( args, this.ownerDocument );
|
|
|
|
|
|
|
|
if ( reverse )
|
|
|
|
elems.reverse();
|
2007-03-24 03:03:47 +01:00
|
|
|
}
|
|
|
|
|
2006-12-23 07:07:21 +01:00
|
|
|
var obj = this;
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
if ( table && jQuery.nodeName( this, "table" ) && jQuery.nodeName( elems[0], "tr" ) )
|
|
|
|
obj = this.getElementsByTagName("tbody")[0] || this.appendChild( document.createElement("tbody") );
|
|
|
|
|
|
|
|
jQuery.each(elems, function(){
|
|
|
|
var elem = clone ?
|
|
|
|
this.cloneNode( true ) :
|
|
|
|
this;
|
2006-12-23 07:07:21 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
if ( !evalScript( 0, elem ) )
|
|
|
|
callback.call( obj, elem );
|
2007-01-14 22:49:59 +01:00
|
|
|
});
|
2006-12-23 07:07:21 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
function evalScript( i, elem ) {
|
|
|
|
var script = jQuery.nodeName( elem, "script" );
|
2007-09-15 04:16:29 +02:00
|
|
|
|
|
|
|
if ( script ) {
|
|
|
|
if ( elem.src )
|
2007-09-23 18:55:19 +02:00
|
|
|
jQuery.ajax({
|
|
|
|
url: elem.src,
|
|
|
|
async: false,
|
|
|
|
dataType: "script"
|
|
|
|
});
|
|
|
|
|
2007-09-15 04:16:29 +02:00
|
|
|
else
|
|
|
|
jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
|
|
|
|
|
|
|
|
if ( elem.parentNode )
|
2007-09-23 18:55:19 +02:00
|
|
|
elem.parentNode.removeChild( elem );
|
2007-09-15 04:16:29 +02:00
|
|
|
|
|
|
|
} else if ( elem.nodeType == 1 )
|
2007-09-23 18:55:19 +02:00
|
|
|
jQuery( "script", elem ).each( evalScript );
|
2007-09-15 04:16:29 +02:00
|
|
|
|
|
|
|
return script;
|
|
|
|
}
|
|
|
|
|
2006-12-23 07:07:21 +01:00
|
|
|
jQuery.extend = jQuery.fn.extend = function() {
|
|
|
|
// copy reference to target object
|
2007-09-23 18:55:19 +02:00
|
|
|
var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options;
|
2007-08-21 06:42:31 +02:00
|
|
|
|
|
|
|
// Handle a deep copy situation
|
|
|
|
if ( target.constructor == Boolean ) {
|
2007-08-21 06:46:07 +02:00
|
|
|
deep = target;
|
2007-08-21 06:42:31 +02:00
|
|
|
target = arguments[1] || {};
|
|
|
|
}
|
2007-04-29 20:39:07 +02:00
|
|
|
|
2006-12-23 07:07:21 +01:00
|
|
|
// extend jQuery itself if only one argument is passed
|
2007-09-23 18:55:19 +02:00
|
|
|
if ( length == 1 ) {
|
2006-12-23 07:07:21 +01:00
|
|
|
target = this;
|
2007-09-23 18:55:19 +02:00
|
|
|
i = 0;
|
2006-12-23 07:07:21 +01:00
|
|
|
}
|
2007-08-20 01:37:26 +02:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
for ( ; i < length; i++ )
|
2007-08-20 01:37:26 +02:00
|
|
|
// Only deal with non-null/undefined values
|
2007-09-23 18:55:19 +02:00
|
|
|
if ( (options = arguments[ i ]) != null )
|
2007-08-20 01:37:26 +02:00
|
|
|
// Extend the base object
|
2007-09-23 18:55:19 +02:00
|
|
|
for ( var name in options ) {
|
2007-08-20 01:37:26 +02:00
|
|
|
// Prevent never-ending loop
|
2007-09-23 18:55:19 +02:00
|
|
|
if ( target == options[ name ] )
|
2007-08-20 01:37:26 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// Recurse if we're merging object values
|
2007-09-23 18:55:19 +02:00
|
|
|
if ( deep && typeof options[ name ] == "object" && target[ name ] )
|
|
|
|
jQuery.extend( target[ name ], options[ name ] );
|
2007-08-20 01:37:26 +02:00
|
|
|
|
|
|
|
// Don't bring in undefined values
|
2007-09-23 18:55:19 +02:00
|
|
|
else if ( options[ name ] != undefined )
|
|
|
|
target[ name ] = options[ name ];
|
|
|
|
|
2007-08-20 01:37:26 +02:00
|
|
|
}
|
2006-12-23 07:07:21 +01:00
|
|
|
|
|
|
|
// Return the modified object
|
|
|
|
return target;
|
|
|
|
};
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
var expando = "jQuery" + (new Date()).getTime(), uuid = 0, windowData = {};
|
|
|
|
|
|
|
|
// exclude the following css properties to add px
|
|
|
|
var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i;
|
2007-09-09 01:31:23 +02:00
|
|
|
|
2006-12-23 07:07:21 +01:00
|
|
|
jQuery.extend({
|
2007-09-23 18:55:19 +02:00
|
|
|
noConflict: function( deep ) {
|
2007-08-22 07:44:47 +02:00
|
|
|
window.$ = _$;
|
2007-09-23 18:55:19 +02:00
|
|
|
|
2007-08-22 07:44:47 +02:00
|
|
|
if ( deep )
|
|
|
|
window.jQuery = _jQuery;
|
2007-09-23 18:55:19 +02:00
|
|
|
|
2007-01-22 04:25:00 +01:00
|
|
|
return jQuery;
|
2007-01-04 19:48:48 +01:00
|
|
|
},
|
2006-12-23 07:07:21 +01:00
|
|
|
|
2007-01-22 03:17:47 +01:00
|
|
|
// This may seem like some crazy code, but trust me when I say that this
|
|
|
|
// is the only cross-browser way to do this. --John
|
2007-01-14 07:22:20 +01:00
|
|
|
isFunction: function( fn ) {
|
2007-02-25 18:40:27 +01:00
|
|
|
return !!fn && typeof fn != "string" && !fn.nodeName &&
|
2007-03-16 01:00:46 +01:00
|
|
|
fn.constructor != Array && /function/i.test( fn + "" );
|
2007-01-14 07:22:20 +01:00
|
|
|
},
|
2007-02-05 21:16:46 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
// check if an element is in a (or is an) XML document
|
|
|
|
isXMLDoc: function( elem ) {
|
2007-07-25 02:56:50 +02:00
|
|
|
return elem.documentElement && !elem.body ||
|
|
|
|
elem.tagName && elem.ownerDocument && !elem.ownerDocument.body;
|
2007-02-05 21:16:46 +01:00
|
|
|
},
|
2007-01-14 07:22:20 +01:00
|
|
|
|
2007-07-31 04:59:53 +02:00
|
|
|
// Evalulates a script in a global context
|
|
|
|
// Evaluates Async. in Safari 2 :-(
|
|
|
|
globalEval: function( data ) {
|
|
|
|
data = jQuery.trim( data );
|
2007-09-23 18:55:19 +02:00
|
|
|
|
2007-07-31 04:59:53 +02:00
|
|
|
if ( data ) {
|
|
|
|
if ( window.execScript )
|
|
|
|
window.execScript( data );
|
2007-09-23 18:55:19 +02:00
|
|
|
|
2007-07-31 04:59:53 +02:00
|
|
|
else if ( jQuery.browser.safari )
|
|
|
|
// safari doesn't provide a synchronous global eval
|
|
|
|
window.setTimeout( data, 0 );
|
2007-09-23 18:55:19 +02:00
|
|
|
|
2007-07-31 04:59:53 +02:00
|
|
|
else
|
|
|
|
eval.call( window, data );
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2007-01-22 06:27:54 +01:00
|
|
|
nodeName: function( elem, name ) {
|
|
|
|
return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();
|
|
|
|
},
|
2007-09-09 01:31:23 +02:00
|
|
|
|
|
|
|
cache: {},
|
|
|
|
|
|
|
|
data: function( elem, name, data ) {
|
2007-09-23 18:55:19 +02:00
|
|
|
elem = elem == window ?
|
|
|
|
windowData :
|
|
|
|
elem;
|
2007-09-10 20:39:16 +02:00
|
|
|
|
2007-09-09 01:31:23 +02:00
|
|
|
var id = elem[ expando ];
|
|
|
|
|
|
|
|
// Compute a unique ID for the element
|
|
|
|
if ( !id )
|
|
|
|
id = elem[ expando ] = ++uuid;
|
|
|
|
|
|
|
|
// Only generate the data cache if we're
|
|
|
|
// trying to access or manipulate it
|
|
|
|
if ( name && !jQuery.cache[ id ] )
|
|
|
|
jQuery.cache[ id ] = {};
|
|
|
|
|
|
|
|
// Prevent overriding the named cache with undefined values
|
|
|
|
if ( data != undefined )
|
|
|
|
jQuery.cache[ id ][ name ] = data;
|
|
|
|
|
|
|
|
// Return the named cache data, or the ID for the element
|
2007-09-23 18:55:19 +02:00
|
|
|
return name ?
|
|
|
|
jQuery.cache[ id ][ name ] :
|
|
|
|
id;
|
2007-09-09 01:31:23 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
removeData: function( elem, name ) {
|
2007-09-23 18:55:19 +02:00
|
|
|
elem = elem == window ?
|
|
|
|
windowData :
|
|
|
|
elem;
|
2007-09-10 20:39:16 +02:00
|
|
|
|
2007-09-09 01:31:23 +02:00
|
|
|
var id = elem[ expando ];
|
|
|
|
|
|
|
|
// If we want to remove a specific section of the element's data
|
|
|
|
if ( name ) {
|
2007-09-10 01:08:21 +02:00
|
|
|
if ( jQuery.cache[ id ] ) {
|
|
|
|
// Remove the section of cache data
|
|
|
|
delete jQuery.cache[ id ][ name ];
|
|
|
|
|
|
|
|
// If we've removed all the data, remove the element's cache
|
|
|
|
name = "";
|
2007-09-23 18:55:19 +02:00
|
|
|
|
|
|
|
for ( name in jQuery.cache[ id ] )
|
|
|
|
break;
|
|
|
|
|
2007-09-10 01:08:21 +02:00
|
|
|
if ( !name )
|
|
|
|
jQuery.removeData( elem );
|
|
|
|
}
|
2007-09-09 01:31:23 +02:00
|
|
|
|
|
|
|
// Otherwise, we want to remove all of the element's data
|
|
|
|
} else {
|
|
|
|
// Clean up the element expando
|
|
|
|
try {
|
|
|
|
delete elem[ expando ];
|
|
|
|
} catch(e){
|
|
|
|
// IE has trouble directly removing the expando
|
|
|
|
// but it's ok with using removeAttribute
|
2007-09-10 20:39:16 +02:00
|
|
|
if ( elem.removeAttribute )
|
|
|
|
elem.removeAttribute( expando );
|
2007-09-09 01:31:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Completely remove the data cache
|
|
|
|
delete jQuery.cache[ id ];
|
|
|
|
}
|
|
|
|
},
|
2007-01-22 06:27:54 +01:00
|
|
|
|
2006-12-23 07:07:21 +01:00
|
|
|
// args is for internal usage only
|
2007-09-23 18:55:19 +02:00
|
|
|
each: function( object, callback, args ) {
|
2007-08-20 09:04:00 +02:00
|
|
|
if ( args ) {
|
2007-09-23 18:55:19 +02:00
|
|
|
if ( object.length == undefined )
|
|
|
|
for ( var name in object )
|
|
|
|
callback.apply( object[ name ], args );
|
2007-08-20 09:04:00 +02:00
|
|
|
else
|
2007-09-23 18:55:19 +02:00
|
|
|
for ( var i = 0, length = object.length; i < length; i++ )
|
|
|
|
if ( callback.apply( object[ i ], args ) === false )
|
|
|
|
break;
|
2007-08-20 08:29:41 +02:00
|
|
|
|
|
|
|
// A special, fast, case for the most common use of each
|
2007-08-20 09:04:00 +02:00
|
|
|
} else {
|
2007-09-23 18:55:19 +02:00
|
|
|
if ( object.length == undefined )
|
|
|
|
for ( var name in object )
|
|
|
|
callback.call( object[ name ], name, object[ name ] );
|
2007-08-20 09:04:00 +02:00
|
|
|
else
|
2007-09-23 18:55:19 +02:00
|
|
|
for ( var i = 0, length = object.length, value = object[0];
|
|
|
|
i < length && callback.call( value, i, value ) !== false; value = object[++i] ){}
|
2007-08-20 09:04:00 +02:00
|
|
|
}
|
2007-08-20 08:29:41 +02:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
return object;
|
2006-12-23 07:07:21 +01:00
|
|
|
},
|
2007-01-08 02:12:21 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
prop: function( elem, value, type, i, name ) {
|
2007-01-10 19:06:19 +01:00
|
|
|
// Handle executable functions
|
2007-01-14 08:17:41 +01:00
|
|
|
if ( jQuery.isFunction( value ) )
|
2007-09-23 18:55:19 +02:00
|
|
|
value = value.call( elem, i );
|
2007-01-16 15:19:01 +01:00
|
|
|
|
2007-01-10 19:06:19 +01:00
|
|
|
// Handle passing in a number to a CSS property
|
2007-09-23 18:55:19 +02:00
|
|
|
return value && value.constructor == Number && type == "curCSS" && !exclude.test( name ) ?
|
2007-02-03 20:32:16 +01:00
|
|
|
value + "px" :
|
|
|
|
value;
|
2007-01-08 02:12:21 +01:00
|
|
|
},
|
2006-12-23 07:07:21 +01:00
|
|
|
|
|
|
|
className: {
|
2007-01-08 17:12:20 +01:00
|
|
|
// internal only, use addClass("class")
|
2007-09-23 18:55:19 +02:00
|
|
|
add: function( elem, classNames ) {
|
|
|
|
jQuery.each((classNames || "").split(/\s+/), function(i, className){
|
|
|
|
if ( !jQuery.className.has( elem.className, className ) )
|
|
|
|
elem.className += (elem.className ? " " : "") + className;
|
2006-12-29 19:04:26 +01:00
|
|
|
});
|
2006-12-23 07:07:21 +01:00
|
|
|
},
|
2007-01-10 17:13:48 +01:00
|
|
|
|
2007-01-08 17:12:20 +01:00
|
|
|
// internal only, use removeClass("class")
|
2007-09-23 18:55:19 +02:00
|
|
|
remove: function( elem, classNames ) {
|
|
|
|
elem.className = classNames != undefined ?
|
|
|
|
jQuery.grep(elem.className.split(/\s+/), function(className){
|
|
|
|
return !jQuery.className.has( classNames, className );
|
|
|
|
}).join(" ") :
|
|
|
|
"";
|
2006-12-23 07:07:21 +01:00
|
|
|
},
|
2007-01-10 17:13:48 +01:00
|
|
|
|
2007-01-08 17:12:20 +01:00
|
|
|
// internal only, use is(".class")
|
2007-09-23 18:55:19 +02:00
|
|
|
has: function( elem, className ) {
|
|
|
|
return jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1;
|
2006-12-23 07:07:21 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
// A method for quickly swapping in/out CSS properties to get correct calculations
|
|
|
|
swap: function( elem, options, callback ) {
|
|
|
|
// Remember the old values, and insert the new ones
|
|
|
|
for ( var name in options ) {
|
|
|
|
elem.style[ "old" + name ] = elem.style[ name ];
|
|
|
|
elem.style[ name ] = options[ name ];
|
2006-12-23 07:07:21 +01:00
|
|
|
}
|
2007-09-23 18:55:19 +02:00
|
|
|
|
|
|
|
callback.call( elem );
|
|
|
|
|
|
|
|
// Revert the old values
|
|
|
|
for ( var name in options )
|
|
|
|
elem.style[ name ] = elem.style[ "old" + name ];
|
2006-12-23 07:07:21 +01:00
|
|
|
},
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
css: function( elem, name ) {
|
|
|
|
if ( name == "height" || name == "width" ) {
|
|
|
|
var old = {}, height, width;
|
2006-12-23 07:07:21 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
// Revert the padding and border widths to get the
|
|
|
|
// correct height/width values
|
|
|
|
jQuery.each([ "Top", "Bottom", "Right", "Left" ], function(){
|
|
|
|
old[ "padding" + this ] = 0;
|
|
|
|
old[ "border" + this + "Width" ] = 0;
|
2007-01-14 22:49:59 +01:00
|
|
|
});
|
2006-12-23 07:07:21 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
// Swap out the padding/border values temporarily
|
|
|
|
jQuery.swap( elem, old, function() {
|
|
|
|
|
|
|
|
// If the element is visible, then the calculation is easy
|
|
|
|
if ( jQuery( elem ).is(":visible") ) {
|
|
|
|
height = elem.offsetHeight;
|
|
|
|
width = elem.offsetWidth;
|
|
|
|
|
|
|
|
// Otherwise, we need to flip out more values
|
2006-12-23 07:07:21 +01:00
|
|
|
} else {
|
2007-09-23 18:55:19 +02:00
|
|
|
elem = jQuery( elem.cloneNode(true) )
|
2006-12-23 07:07:21 +01:00
|
|
|
.find(":radio").removeAttr("checked").end()
|
|
|
|
.css({
|
2007-09-23 18:55:19 +02:00
|
|
|
visibility: "hidden",
|
|
|
|
position: "absolute",
|
|
|
|
display: "block",
|
|
|
|
right: "0",
|
|
|
|
left: "0"
|
|
|
|
}).appendTo( elem.parentNode )[0];
|
2006-12-23 07:07:21 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
var position = jQuery.css( elem.parentNode, "position" ) || "static";
|
|
|
|
if ( position == "static" )
|
|
|
|
elem.parentNode.style.position = "relative";
|
2006-12-23 07:07:21 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
height = elem.clientHeight;
|
|
|
|
width = elem.clientWidth;
|
2006-12-23 07:07:21 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
if ( position == "static" )
|
|
|
|
elem.parentNode.style.position = "static";
|
2006-12-23 07:07:21 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
elem.parentNode.removeChild( elem );
|
2006-12-23 07:07:21 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
return name == "height" ?
|
|
|
|
height :
|
|
|
|
width;
|
2006-12-23 07:07:21 +01:00
|
|
|
}
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
return jQuery.curCSS( elem, name );
|
2006-12-23 07:07:21 +01:00
|
|
|
},
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
curCSS: function( elem, name, force ) {
|
|
|
|
var ret;
|
2007-07-30 01:01:42 +02:00
|
|
|
|
|
|
|
// A helper method for determining if an element's values are broken
|
2007-09-23 18:55:19 +02:00
|
|
|
function color( elem ) {
|
2007-07-30 01:01:42 +02:00
|
|
|
if ( !jQuery.browser.safari )
|
|
|
|
return false;
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
var ret = document.defaultView.getComputedStyle( elem, null );
|
2007-07-30 01:01:42 +02:00
|
|
|
return !ret || ret.getPropertyValue("color") == "";
|
|
|
|
}
|
2007-03-16 21:37:10 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
// We need to handle opacity special in IE
|
|
|
|
if ( name == "opacity" && jQuery.browser.msie ) {
|
|
|
|
ret = jQuery.attr( elem.style, "opacity" );
|
|
|
|
|
|
|
|
return ret == "" ?
|
|
|
|
"1" :
|
|
|
|
ret;
|
2007-03-22 02:37:28 +01:00
|
|
|
}
|
2007-03-16 21:37:10 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
// Make sure we're using the right name for getting the float value
|
|
|
|
if ( name.match( /float/i ) )
|
|
|
|
name = styleFloat;
|
|
|
|
|
|
|
|
if ( !force && elem.style[ name ] )
|
|
|
|
ret = elem.style[ name ];
|
2006-12-23 07:07:21 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
else if ( document.defaultView && document.defaultView.getComputedStyle ) {
|
2006-12-23 07:07:21 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
// Only "float" is needed here
|
|
|
|
if ( name.match( /float/i ) )
|
|
|
|
name = "float";
|
2006-12-23 07:07:21 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase();
|
2006-12-23 07:07:21 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
var getComputedStyle = document.defaultView.getComputedStyle( elem, null );
|
2006-12-23 07:07:21 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
if ( getComputedStyle && !color( elem ) )
|
|
|
|
ret = getComputedStyle.getPropertyValue( name );
|
2007-07-30 00:32:06 +02:00
|
|
|
|
|
|
|
// If the element isn't reporting its values properly in Safari
|
|
|
|
// then some display: none elements are involved
|
|
|
|
else {
|
2007-09-23 18:55:19 +02:00
|
|
|
var swap = [], stack = [];
|
|
|
|
|
2007-07-30 00:32:06 +02:00
|
|
|
// Locate all of the parent display: none elements
|
2007-08-19 09:06:15 +02:00
|
|
|
for ( var a = elem; a && color(a); a = a.parentNode )
|
2007-07-30 00:32:06 +02:00
|
|
|
stack.unshift(a);
|
|
|
|
|
|
|
|
// Go through and make them visible, but in reverse
|
|
|
|
// (It would be better if we knew the exact display type that they had)
|
2007-09-23 18:55:19 +02:00
|
|
|
for ( var i = 0; i < stack.length; i++ )
|
|
|
|
if ( color( stack[ i ] ) ) {
|
|
|
|
swap[ i ] = stack[ i ].style.display;
|
|
|
|
stack[ i ].style.display = "block";
|
2007-07-30 00:32:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Since we flip the display style, we have to handle that
|
|
|
|
// one special, otherwise get the value
|
2007-09-23 18:55:19 +02:00
|
|
|
ret = name == "display" && swap[ stack.length - 1 ] != null ?
|
2007-07-30 00:32:06 +02:00
|
|
|
"none" :
|
2007-09-23 18:55:19 +02:00
|
|
|
document.defaultView.getComputedStyle( elem, null ).getPropertyValue( name ) || "";
|
2007-07-30 00:32:06 +02:00
|
|
|
|
|
|
|
// Finally, revert the display styles back
|
2007-09-23 18:55:19 +02:00
|
|
|
for ( var i = 0; i < swap.length; i++ )
|
|
|
|
if ( swap[ i ] != null )
|
|
|
|
stack[ i ].style.display = swap[ i ];
|
2007-07-30 00:32:06 +02:00
|
|
|
}
|
2006-12-23 07:07:21 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
// We should always get a number back from opacity
|
|
|
|
if ( name == "opacity" && ret == "" )
|
2007-07-21 00:47:21 +02:00
|
|
|
ret = "1";
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
} else if ( elem.currentStyle ) {
|
|
|
|
var camelCase = name.replace(/\-(\w)/g, function(all, letter){
|
|
|
|
return letter.toUpperCase();
|
|
|
|
});
|
|
|
|
|
|
|
|
ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ];
|
2007-09-07 23:39:44 +02:00
|
|
|
|
|
|
|
// From the awesome hack by Dean Edwards
|
|
|
|
// http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
|
|
|
|
|
|
|
|
// If we're not dealing with a regular pixel number
|
|
|
|
// but a number that has a weird ending, we need to convert it to pixels
|
2007-09-23 18:55:19 +02:00
|
|
|
if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) {
|
|
|
|
// Remember the original values
|
|
|
|
var style = elem.style.left, runtimeStyle = elem.runtimeStyle.left;
|
|
|
|
|
|
|
|
// Put in the new values to get a computed value out
|
2007-09-07 23:39:44 +02:00
|
|
|
elem.runtimeStyle.left = elem.currentStyle.left;
|
|
|
|
elem.style.left = ret || 0;
|
|
|
|
ret = elem.style.pixelLeft + "px";
|
2007-09-23 18:55:19 +02:00
|
|
|
|
|
|
|
// Revert the changed values
|
2007-09-07 23:39:44 +02:00
|
|
|
elem.style.left = style;
|
|
|
|
elem.runtimeStyle.left = runtimeStyle;
|
|
|
|
}
|
2006-12-23 07:07:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
},
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
clean: function( elems, context ) {
|
|
|
|
var ret = [];
|
|
|
|
context = context || document;
|
2007-01-11 04:57:19 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
jQuery.each(elems, function(i, elem){
|
|
|
|
if ( !elem )
|
|
|
|
return;
|
2007-01-11 19:44:53 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
if ( elem.constructor == Number )
|
|
|
|
elem = elem.toString();
|
2007-01-08 03:39:10 +01:00
|
|
|
|
2007-05-22 09:11:50 +02:00
|
|
|
// Convert html string into DOM nodes
|
2007-09-23 18:55:19 +02:00
|
|
|
if ( typeof elem == "string" ) {
|
2007-09-04 06:34:48 +02:00
|
|
|
// Fix "XHTML"-style tags in all browsers
|
2007-09-23 18:55:19 +02:00
|
|
|
elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){
|
|
|
|
return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area)$/i) ?
|
|
|
|
all :
|
|
|
|
front + "></" + tag + ">";
|
2007-09-04 06:34:48 +02:00
|
|
|
});
|
|
|
|
|
2006-12-23 07:07:21 +01:00
|
|
|
// Trim whitespace, otherwise indexOf won't work as expected
|
2007-09-23 18:55:19 +02:00
|
|
|
var tags = jQuery.trim( elem ).toLowerCase(), div = context.createElement("div");
|
2007-01-08 03:39:10 +01:00
|
|
|
|
|
|
|
var wrap =
|
2007-05-22 09:11:50 +02:00
|
|
|
// option or optgroup
|
2007-09-23 18:55:19 +02:00
|
|
|
!tags.indexOf("<opt") &&
|
|
|
|
[ 1, "<select>", "</select>" ] ||
|
2007-04-25 20:41:49 +02:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
!tags.indexOf("<leg") &&
|
|
|
|
[ 1, "<fieldset>", "</fieldset>" ] ||
|
2007-01-08 03:39:10 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
tags.match(/^<(thead|tbody|tfoot|colg|cap)/) &&
|
|
|
|
[ 1, "<table>", "</table>" ] ||
|
2007-01-08 03:39:10 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
!tags.indexOf("<tr") &&
|
|
|
|
[ 2, "<table><tbody>", "</tbody></table>" ] ||
|
2007-01-08 03:39:10 +01:00
|
|
|
|
|
|
|
// <thead> matched above
|
2007-09-23 18:55:19 +02:00
|
|
|
(!tags.indexOf("<td") || !tags.indexOf("<th")) &&
|
|
|
|
[ 3, "<table><tbody><tr>", "</tr></tbody></table>" ] ||
|
2007-01-08 03:39:10 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
!tags.indexOf("<col") &&
|
|
|
|
[ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ] ||
|
2007-08-20 01:37:26 +02:00
|
|
|
|
|
|
|
// IE can't serialize <link> and <script> tags normally
|
|
|
|
jQuery.browser.msie &&
|
2007-09-23 18:55:19 +02:00
|
|
|
[ 1, "div<div>", "</div>" ] ||
|
2007-04-30 03:43:52 +02:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
[ 0, "", "" ];
|
2006-12-23 07:07:21 +01:00
|
|
|
|
|
|
|
// Go to html and back, then peel off extra wrappers
|
2007-09-23 18:55:19 +02:00
|
|
|
div.innerHTML = wrap[1] + elem + wrap[2];
|
2007-01-08 03:39:10 +01:00
|
|
|
|
|
|
|
// Move to the right depth
|
|
|
|
while ( wrap[0]-- )
|
2007-08-20 01:37:26 +02:00
|
|
|
div = div.lastChild;
|
2006-12-23 07:07:21 +01:00
|
|
|
|
|
|
|
// Remove IE's autoinserted <tbody> from table fragments
|
|
|
|
if ( jQuery.browser.msie ) {
|
2007-01-08 03:39:10 +01:00
|
|
|
|
2006-12-23 07:07:21 +01:00
|
|
|
// String was a <table>, *may* have spurious <tbody>
|
2007-09-23 18:55:19 +02:00
|
|
|
var tbody = !tags.indexOf("<table") && tags.indexOf("<tbody") < 0 ?
|
|
|
|
div.firstChild && div.firstChild.childNodes :
|
2007-01-08 03:39:10 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
// String was a bare <thead> or <tfoot>
|
|
|
|
wrap[1] == "<table>" && s.indexOf("<tbody") < 0 ?
|
|
|
|
div.childNodes :
|
|
|
|
[];
|
|
|
|
|
|
|
|
for ( var i = tbody.length - 1; i >= 0 ; --i )
|
|
|
|
if ( jQuery.nodeName( tbody[ i ], "tbody" ) && !tbody[ i ].childNodes.length )
|
|
|
|
tbody[ i ].parentNode.removeChild( tbody[ i ] );
|
2007-07-30 04:14:06 +02:00
|
|
|
|
|
|
|
// IE completely kills leading whitespace when innerHTML is used
|
2007-09-23 18:55:19 +02:00
|
|
|
if ( /^\s/.test( elem ) )
|
|
|
|
div.insertBefore( context.createTextNode( elem.match(/^\s*/)[0] ), div.firstChild );
|
2007-07-30 04:14:06 +02:00
|
|
|
|
2006-12-23 07:07:21 +01:00
|
|
|
}
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
elem = jQuery.makeArray( div.childNodes );
|
2007-01-08 03:39:10 +01:00
|
|
|
}
|
2007-01-14 20:30:40 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
if ( elem.length === 0 && (!jQuery.nodeName( elem, "form" ) && !jQuery.nodeName( elem, "select" )) )
|
2007-01-14 22:49:59 +01:00
|
|
|
return;
|
2007-04-25 20:19:39 +02:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
if ( elem[0] == undefined || jQuery.nodeName( elem, "form" ) || elem.options )
|
|
|
|
ret.push( elem );
|
|
|
|
|
2006-12-23 07:07:21 +01:00
|
|
|
else
|
2007-09-23 18:55:19 +02:00
|
|
|
ret = jQuery.merge( ret, elem );
|
2007-01-10 08:00:02 +01:00
|
|
|
|
2007-01-14 22:49:59 +01:00
|
|
|
});
|
2006-12-23 07:07:21 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
return ret;
|
2006-12-23 07:07:21 +01:00
|
|
|
},
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
attr: function( elem, name, value ) {
|
|
|
|
var fix = jQuery.isXMLDoc( elem ) ?
|
|
|
|
{} :
|
|
|
|
jQuery.props;
|
2007-07-30 00:32:06 +02:00
|
|
|
|
|
|
|
// Safari mis-reports the default selected property of a hidden option
|
|
|
|
// Accessing the parent's selectedIndex property fixes it
|
|
|
|
if ( name == "selected" && jQuery.browser.safari )
|
|
|
|
elem.parentNode.selectedIndex;
|
2006-12-23 07:07:21 +01:00
|
|
|
|
|
|
|
// Certain attributes only work when accessed via the old DOM 0 way
|
2007-09-23 18:55:19 +02:00
|
|
|
if ( fix[ name ] ) {
|
|
|
|
if ( value != undefined )
|
|
|
|
elem[ fix[ name ] ] = value;
|
|
|
|
|
|
|
|
return elem[ fix[ name ] ];
|
|
|
|
|
2007-07-21 02:12:18 +02:00
|
|
|
} else if ( jQuery.browser.msie && name == "style" )
|
|
|
|
return jQuery.attr( elem.style, "cssText", value );
|
2006-12-23 07:07:21 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
else if ( value == undefined && jQuery.browser.msie && jQuery.nodeName( elem, "form" ) && (name == "action" || name == "method") )
|
|
|
|
return elem.getAttributeNode( name ).nodeValue;
|
2006-12-23 07:07:21 +01:00
|
|
|
|
|
|
|
// IE elem.getAttribute passes even for style
|
2007-01-08 03:39:10 +01:00
|
|
|
else if ( elem.tagName ) {
|
2007-07-02 17:27:58 +02:00
|
|
|
|
2007-09-04 06:17:14 +02:00
|
|
|
if ( value != undefined ) {
|
2007-09-23 18:55:19 +02:00
|
|
|
// We can't allow the type property to be changed (since it causes problems in IE)
|
|
|
|
if ( name == "type" && jQuery.nodeName( elem, "input" ) && elem.parentNode )
|
2007-09-04 06:17:14 +02:00
|
|
|
throw "type property can't be changed";
|
2007-09-23 18:55:19 +02:00
|
|
|
|
2007-09-04 06:17:14 +02:00
|
|
|
elem.setAttribute( name, value );
|
|
|
|
}
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
if ( jQuery.browser.msie && /href|src/.test( name ) && !jQuery.isXMLDoc( elem ) )
|
2007-07-02 17:27:58 +02:00
|
|
|
return elem.getAttribute( name, 2 );
|
2007-09-04 06:17:14 +02:00
|
|
|
|
2007-07-02 17:27:58 +02:00
|
|
|
return elem.getAttribute( name );
|
|
|
|
|
|
|
|
// elem is actually elem.style ... set the style
|
|
|
|
} else {
|
|
|
|
// IE actually uses filters for opacity
|
2007-06-29 21:52:38 +02:00
|
|
|
if ( name == "opacity" && jQuery.browser.msie ) {
|
|
|
|
if ( value != undefined ) {
|
|
|
|
// IE has trouble with opacity if it does not have layout
|
|
|
|
// Force it by setting the zoom level
|
|
|
|
elem.zoom = 1;
|
|
|
|
|
|
|
|
// Set the alpha filter to set the opacity
|
2007-09-23 18:55:19 +02:00
|
|
|
elem.filter = (elem.filter || "").replace( /alpha\([^)]*\)/, "" ) +
|
|
|
|
(parseFloat( value ).toString() == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");
|
2007-06-29 21:52:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return elem.filter ?
|
2007-09-23 18:55:19 +02:00
|
|
|
(parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100).toString() :
|
|
|
|
"";
|
2007-06-29 21:52:38 +02:00
|
|
|
}
|
2007-09-23 18:55:19 +02:00
|
|
|
|
|
|
|
name = name.replace(/-([a-z])/ig, function(all, letter){
|
|
|
|
return letter.toUpperCase();
|
|
|
|
});
|
|
|
|
|
|
|
|
if ( value != undefined )
|
|
|
|
elem[ name ] = value;
|
|
|
|
|
|
|
|
return elem[ name ];
|
2006-12-23 07:07:21 +01:00
|
|
|
}
|
|
|
|
},
|
2006-12-31 06:22:06 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
trim: function( text ) {
|
|
|
|
return (text || "").replace( /^\s+|\s+$/g, "" );
|
2006-12-23 07:07:21 +01:00
|
|
|
},
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
makeArray: function( array ) {
|
|
|
|
var ret = [];
|
2006-12-23 07:07:21 +01:00
|
|
|
|
2007-03-16 05:32:37 +01:00
|
|
|
// Need to use typeof to fight Safari childNodes crashes
|
2007-09-23 18:55:19 +02:00
|
|
|
if ( typeof array != "array" )
|
|
|
|
for ( var i = 0, length = array.length; i < length; i++ )
|
|
|
|
ret.push( array[ i ] );
|
2007-01-08 03:39:10 +01:00
|
|
|
else
|
2007-09-23 18:55:19 +02:00
|
|
|
ret = array.slice( 0 );
|
2006-12-23 07:07:21 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
return ret;
|
2006-12-23 07:07:21 +01:00
|
|
|
},
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
inArray: function( elem, array ) {
|
|
|
|
for ( var i = 0, length = array.length; i < length; i++ )
|
|
|
|
if ( array[ i ] == elem )
|
2006-12-23 07:07:21 +01:00
|
|
|
return i;
|
2007-09-23 18:55:19 +02:00
|
|
|
|
2006-12-23 07:07:21 +01:00
|
|
|
return -1;
|
|
|
|
},
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
merge: function( first, second ) {
|
2007-03-25 22:28:34 +02:00
|
|
|
// We have to loop this way because IE & Opera overwrite the length
|
|
|
|
// expando of getElementsByTagName
|
2007-08-19 09:28:41 +02:00
|
|
|
|
|
|
|
// Also, we need to make sure that the correct elements are being returned
|
|
|
|
// (IE returns comment nodes in a '*' query)
|
|
|
|
if ( jQuery.browser.msie ) {
|
2007-09-23 18:55:19 +02:00
|
|
|
for ( var i = 0; second[ i ]; i++ )
|
|
|
|
if ( second[ i ].nodeType != 8 )
|
|
|
|
first.push( second[ i ] );
|
|
|
|
|
2007-08-19 09:28:41 +02:00
|
|
|
} else
|
2007-09-23 18:55:19 +02:00
|
|
|
for ( var i = 0; second[ i ]; i++ )
|
|
|
|
first.push( second[ i ] );
|
2007-08-19 09:28:41 +02:00
|
|
|
|
2006-12-23 07:07:21 +01:00
|
|
|
return first;
|
|
|
|
},
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
unique: function( array ) {
|
|
|
|
var ret = [], done = {};
|
2007-03-24 22:55:03 +01:00
|
|
|
|
2007-07-20 20:08:29 +02:00
|
|
|
try {
|
2007-09-23 18:55:19 +02:00
|
|
|
|
|
|
|
for ( var i = 0, length = array.length; i < length; i++ ) {
|
|
|
|
var id = jQuery.data( array[ i ] );
|
|
|
|
|
|
|
|
if ( !done[ id ] ) {
|
|
|
|
done[ id ] = true;
|
|
|
|
ret.push( array[ i ] );
|
2007-07-20 20:08:29 +02:00
|
|
|
}
|
2007-09-09 01:31:23 +02:00
|
|
|
}
|
2007-09-23 18:55:19 +02:00
|
|
|
|
|
|
|
} catch( e ) {
|
|
|
|
ret = array;
|
2007-07-20 20:08:29 +02:00
|
|
|
}
|
2007-03-24 22:55:03 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
return ret;
|
2007-03-24 22:55:03 +01:00
|
|
|
},
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
grep: function( elems, callback, inv ) {
|
2006-12-23 07:07:21 +01:00
|
|
|
// If a string is passed in for the function, make a function
|
|
|
|
// for it (a handy shortcut)
|
2007-09-23 18:55:19 +02:00
|
|
|
if ( typeof callback == "string" )
|
|
|
|
callback = eval("false||function(a,i){return " + callback + "}");
|
2006-12-23 07:07:21 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
var ret = [];
|
2006-12-23 07:07:21 +01:00
|
|
|
|
|
|
|
// Go through the array, only saving the items
|
|
|
|
// that pass the validator function
|
2007-09-23 18:55:19 +02:00
|
|
|
for ( var i = 0, length = elems.length; i < length; i++ )
|
|
|
|
if ( !inv && callback( elems[ i ], i ) || inv && !callback( elems[ i ], i ) )
|
|
|
|
ret.push( elems[ i ] );
|
2006-12-23 07:07:21 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
return ret;
|
2006-12-23 07:07:21 +01:00
|
|
|
},
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
map: function( elems, callback ) {
|
|
|
|
var ret = [];
|
2006-12-23 07:07:21 +01:00
|
|
|
|
|
|
|
// Go through the array, translating each of the items to their
|
|
|
|
// new value (or values).
|
2007-09-23 18:55:19 +02:00
|
|
|
for ( var i = 0, length = elems.length; i < length; i++ ) {
|
|
|
|
var value = callback( elems[ i ], i );
|
2006-12-23 07:07:21 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
if ( value !== null && value != undefined ) {
|
|
|
|
if ( value.constructor != Array )
|
|
|
|
value = [ value ];
|
|
|
|
|
|
|
|
ret = ret.concat( value );
|
2006-12-23 07:07:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
return ret;
|
2006-12-23 07:07:21 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2007-08-21 07:43:44 +02:00
|
|
|
var userAgent = navigator.userAgent.toLowerCase();
|
|
|
|
|
|
|
|
// Figure out what browser is being used
|
|
|
|
jQuery.browser = {
|
2007-09-23 18:55:19 +02:00
|
|
|
version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1],
|
|
|
|
safari: /webkit/.test( userAgent ),
|
|
|
|
opera: /opera/.test( userAgent ),
|
|
|
|
msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
|
|
|
|
mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )
|
2007-08-21 07:43:44 +02:00
|
|
|
};
|
2006-12-23 07:07:21 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
var styleFloat = jQuery.browser.msie ?
|
|
|
|
"styleFloat" :
|
|
|
|
"cssFloat";
|
2007-08-21 07:43:44 +02:00
|
|
|
|
|
|
|
jQuery.extend({
|
2006-12-23 07:07:21 +01:00
|
|
|
// Check to see if the W3C box model is being used
|
2007-08-21 07:43:44 +02:00
|
|
|
boxModel: !jQuery.browser.msie || document.compatMode == "CSS1Compat",
|
|
|
|
|
|
|
|
props: {
|
2007-06-29 21:52:38 +02:00
|
|
|
"for": "htmlFor",
|
|
|
|
"class": "className",
|
2007-08-21 07:43:44 +02:00
|
|
|
"float": styleFloat,
|
|
|
|
cssFloat: styleFloat,
|
|
|
|
styleFloat: styleFloat,
|
2007-06-29 21:52:38 +02:00
|
|
|
innerHTML: "innerHTML",
|
|
|
|
className: "className",
|
|
|
|
value: "value",
|
|
|
|
disabled: "disabled",
|
|
|
|
checked: "checked",
|
|
|
|
readonly: "readOnly",
|
|
|
|
selected: "selected",
|
2007-09-18 16:35:41 +02:00
|
|
|
maxlength: "maxLength",
|
|
|
|
selectedIndex: "selectedIndex"
|
2007-08-21 07:43:44 +02:00
|
|
|
}
|
|
|
|
});
|
2006-12-23 07:07:21 +01:00
|
|
|
|
2007-01-06 06:09:11 +01:00
|
|
|
jQuery.each({
|
2007-09-23 18:55:19 +02:00
|
|
|
parent: "elem.parentNode",
|
|
|
|
parents: "jQuery.dir(elem,'parentNode')",
|
|
|
|
next: "jQuery.nth(elem,2,'nextSibling')",
|
|
|
|
prev: "jQuery.nth(elem,2,'previousSibling')",
|
|
|
|
nextAll: "jQuery.dir(elem,'nextSibling')",
|
|
|
|
prevAll: "jQuery.dir(elem,'previousSibling')",
|
|
|
|
siblings: "jQuery.sibling(elem.parentNode.firstChild,elem)",
|
|
|
|
children: "jQuery.sibling(elem.firstChild)",
|
|
|
|
contents: "jQuery.nodeName(elem,'iframe')?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes)"
|
|
|
|
}, function(name, fn){
|
|
|
|
fn = eval("false||function(elem){return " + fn + "}");
|
|
|
|
|
|
|
|
jQuery.fn[ name ] = function( selector ) {
|
|
|
|
var ret = jQuery.map( this, fn );
|
|
|
|
|
|
|
|
if ( selector && typeof selector == "string" )
|
|
|
|
ret = jQuery.multiFilter( selector, ret );
|
|
|
|
|
|
|
|
return this.pushStack( jQuery.unique( ret ) );
|
2007-01-06 06:09:11 +01:00
|
|
|
};
|
|
|
|
});
|
2006-12-23 07:07:21 +01:00
|
|
|
|
2007-01-06 06:09:11 +01:00
|
|
|
jQuery.each({
|
|
|
|
appendTo: "append",
|
|
|
|
prependTo: "prepend",
|
|
|
|
insertBefore: "before",
|
2007-08-25 07:12:20 +02:00
|
|
|
insertAfter: "after",
|
|
|
|
replaceAll: "replaceWith"
|
2007-09-23 18:55:19 +02:00
|
|
|
}, function(name, original){
|
|
|
|
jQuery.fn[ name ] = function() {
|
|
|
|
var args = arguments;
|
|
|
|
|
2007-01-06 06:09:11 +01:00
|
|
|
return this.each(function(){
|
2007-09-23 18:55:19 +02:00
|
|
|
for ( var i = 0, length = args.length; i < length; i++ )
|
|
|
|
jQuery( args[ i ] )[ original ]( this );
|
2007-01-06 06:09:11 +01:00
|
|
|
});
|
|
|
|
};
|
|
|
|
});
|
2006-12-23 07:07:21 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
jQuery.each({
|
|
|
|
removeAttr: function( name ) {
|
|
|
|
jQuery.attr( this, name, "" );
|
|
|
|
this.removeAttribute( name );
|
2006-12-23 07:07:21 +01:00
|
|
|
},
|
2007-09-23 18:55:19 +02:00
|
|
|
|
|
|
|
addClass: function( classNames ) {
|
|
|
|
jQuery.className.add( this, classNames );
|
2007-01-06 06:09:11 +01:00
|
|
|
},
|
2007-09-23 18:55:19 +02:00
|
|
|
|
|
|
|
removeClass: function( classNames ) {
|
|
|
|
jQuery.className.remove( this, classNames );
|
2007-01-06 06:09:11 +01:00
|
|
|
},
|
2007-09-23 18:55:19 +02:00
|
|
|
|
|
|
|
toggleClass: function( classNames ) {
|
|
|
|
jQuery.className[ jQuery.className.has( this, classNames ) ? "remove" : "add" ]( this, classNames );
|
2007-01-06 06:09:11 +01:00
|
|
|
},
|
2007-09-23 18:55:19 +02:00
|
|
|
|
|
|
|
remove: function( selector ) {
|
|
|
|
if ( !selector || jQuery.filter( selector, [ this ] ).r.length ) {
|
2007-09-09 01:31:23 +02:00
|
|
|
jQuery.removeData( this );
|
2007-01-06 06:09:11 +01:00
|
|
|
this.parentNode.removeChild( this );
|
2007-09-09 01:31:23 +02:00
|
|
|
}
|
2007-01-06 06:09:11 +01:00
|
|
|
},
|
2007-09-23 18:55:19 +02:00
|
|
|
|
2007-01-06 06:09:11 +01:00
|
|
|
empty: function() {
|
2007-09-09 01:31:23 +02:00
|
|
|
// Clean up the cache
|
2007-09-23 18:55:19 +02:00
|
|
|
jQuery( "*", this ).each(function(){
|
|
|
|
jQuery.removeData(this);
|
|
|
|
});
|
2007-09-09 01:31:23 +02:00
|
|
|
|
2007-01-06 06:09:11 +01:00
|
|
|
while ( this.firstChild )
|
|
|
|
this.removeChild( this.firstChild );
|
|
|
|
}
|
2007-09-23 18:55:19 +02:00
|
|
|
}, function(name, fn){
|
|
|
|
jQuery.fn[ name ] = function(){
|
|
|
|
return this.each( fn, arguments );
|
2007-01-06 06:09:11 +01:00
|
|
|
};
|
|
|
|
});
|
2006-12-23 07:07:21 +01:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
jQuery.each([ "Height", "Width" ], function(i, name){
|
|
|
|
var type = name.toLowerCase();
|
2007-09-10 00:59:41 +02:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
jQuery.fn[ type ] = function( size ) {
|
2007-09-17 21:14:05 +02:00
|
|
|
// Get window width or height
|
2007-09-10 00:59:41 +02:00
|
|
|
return this[0] == window ?
|
2007-09-17 21:14:05 +02:00
|
|
|
// Opera reports document.body.client[Width/Height] properly in both quirks and standards
|
2007-09-23 18:55:19 +02:00
|
|
|
jQuery.browser.opera && document.body[ "client" + name ] ||
|
2007-09-17 21:14:05 +02:00
|
|
|
|
|
|
|
// Safari reports inner[Width/Height] just fine (Mozilla and Opera include scroll bar widths)
|
2007-09-23 18:55:19 +02:00
|
|
|
jQuery.browser.safari && self[ "inner" + name ] ||
|
2007-09-17 21:14:05 +02:00
|
|
|
|
|
|
|
// Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
|
2007-09-23 18:55:19 +02:00
|
|
|
document.compatMode == "CSS1Compat" && document.documentElement[ "client" + name ] || document.body[ "client" + name ] :
|
2007-09-10 00:59:41 +02:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
// Get document width or height
|
2007-09-10 00:59:41 +02:00
|
|
|
this[0] == document ?
|
2007-09-17 21:14:05 +02:00
|
|
|
// Either scroll[Width/Height] or offset[Width/Height], whichever is greater (Mozilla reports scrollWidth the same as offsetWidth)
|
2007-09-23 18:55:19 +02:00
|
|
|
Math.max( document.body[ "scroll" + name ], document.body[ "offset" + name ] ) :
|
2007-09-10 00:59:41 +02:00
|
|
|
|
2007-09-23 18:55:19 +02:00
|
|
|
// Get or set width or height on the element
|
|
|
|
size == undefined ?
|
2007-09-17 21:14:05 +02:00
|
|
|
// Get width or height on the element
|
2007-09-23 18:55:19 +02:00
|
|
|
(this.length ? jQuery.css( this[0], type ) : null) :
|
|
|
|
|
2007-09-17 21:14:05 +02:00
|
|
|
// Set the width or height on the element (default to pixels if value is unitless)
|
2007-09-23 18:55:19 +02:00
|
|
|
this.css( type, size.constructor == String ? size : size + "px" );
|
2007-01-10 17:40:32 +01:00
|
|
|
};
|
|
|
|
});
|