Хранилища Subversion ant

Сравнить редакции

Не учитывать пробелы Редакция 290 → Редакция 289

/trunk/js/jquery.js
6,8 → 6,8
* Dual licensed under the MIT and GPL licenses.
* http://docs.jquery.com/License
*
* Date: 2009-07-28 03:48:42 +0700 (Втр, 28 Июл 2009)
* Revision: 6514
* Date: 2009-06-17 09:31:45 +0700 (Срд, 17 Июн 2009)
* Revision: 6399
*/
(function(window, undefined){
 
25,32 → 25,21
// Map over the $ in case of overwrite
_$ = window.$,
 
// Use the correct document accordingly with window argument (sandbox)
document = window.document,
 
// A central reference to the root jQuery(document)
rootjQuery,
 
// A simple way to check for HTML strings or ID strings
// (both of which we optimize for)
quickExpr = /^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,
quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,
 
// Is it a simple selector
isSimple = /^.[^:#\[\.,]*$/,
 
// Check if a string has a non-whitespace character in it
rnotwhite = /\S/,
 
// Used for trimming whitespace
rtrim = /^\s+|\s+$/g,
 
// Keep a UserAgent string for use with jQuery.browser
userAgent = navigator.userAgent.toLowerCase(),
 
// Save a reference to some core methods
toString = Object.prototype.toString,
push = Array.prototype.push,
slice = Array.prototype.slice;
// Save a reference to the core toString method
toString = Object.prototype.toString;
 
// Expose jQuery to the global object
window.jQuery = window.$ = jQuery;
61,13 → 50,15
 
// Handle $(""), $(null), or $(undefined)
if ( !selector ) {
this.length = 0;
return this;
}
 
// Handle $(DOMElement)
if ( selector.nodeType ) {
this.context = this[0] = selector;
this.length++;
this[0] = selector;
this.length = 1;
this.context = selector;
return this;
}
 
85,23 → 76,19
 
// HANDLE: $("#id")
} else {
elem = document.getElementById( match[2] );
elem = document.getElementById( match[3] );
 
if ( elem ) {
// Handle the case where IE and Opera return items
// by name instead of ID
if ( elem.id !== match[2] ) {
return rootjQuery.find( selector );
}
 
// Otherwise, we inject the element directly into the jQuery object
this.length++;
this[0] = elem;
// Handle the case where IE and Opera return items
// by name instead of ID
if ( elem && elem.id !== match[3] ) {
return rootjQuery.find( selector );
}
 
this.context = document;
this.selector = selector;
return this;
// Otherwise, we inject the element directly into the jQuery object
ret = jQuery( elem || null );
ret.context = document;
ret.selector = selector;
return ret;
}
 
// HANDLE: $(expr, $(...))
137,18 → 124,11
// The current version of jQuery being used
jquery: "1.3.3pre",
 
// The default length of a jQuery object is 0
length: 0,
 
// The number of elements contained in the matched element set
size: function() {
return this.length;
},
 
toArray: function(){
return slice.call( this, 0 );
},
 
// Get the Nth element in the matched element set OR
// Get the whole matched element set as a clean array
get: function( num ) {
155,10 → 135,10
return num == null ?
 
// Return a 'clean' array
this.toArray() :
Array.prototype.slice.call( this ) :
 
// Return just the object
( num < 0 ? this.slice(num)[ 0 ] : this[ num ] );
this[ num ];
},
 
// Take an array of elements and push it onto the stack
189,7 → 169,7
// Resetting the length to 0, then using the native Array push
// is a super-fast way to populate an object with array-like properties
this.length = 0;
push.apply( this, elems );
Array.prototype.push.apply( this, elems );
 
return this;
},
222,7 → 202,7
 
// For internal use only.
// Behaves like an Array's method, not like a jQuery method.
push: push,
push: [].push,
sort: [].sort,
splice: [].splice
};
268,21 → 248,10
 
// Recurse if we're merging object values
if ( deep && copy && typeof copy === "object" && !copy.nodeType ) {
var clone;
target[ name ] = jQuery.extend( deep,
// Never move original objects, clone them
src || ( copy.length != null ? [ ] : { } ), copy );
 
if ( src ) {
clone = src;
} else if ( jQuery.isArray(copy) ) {
clone = [];
} else if ( jQuery.isObject(copy) ) {
clone = {};
} else {
clone = copy;
}
 
// Never move original objects, clone them
target[ name ] = jQuery.extend( deep, clone, copy );
 
// Don't bring in undefined values
} else if ( copy !== undefined ) {
target[ name ] = copy;
317,27 → 286,15
return toString.call(obj) === "[object Array]";
},
 
isObject: function( obj ) {
return this.constructor.call(obj) === Object;
},
 
isEmptyObject: function( obj ) {
for ( var name in obj ) {
return false;
}
return true;
},
 
// check if an element is in a (or is an) XML document
isXMLDoc: function( elem ) {
// documentElement is verified for cases where it doesn't yet exist
// (such as loading iframes in IE - #4833)
return ((elem.ownerDocument || elem).documentElement || 0).nodeName !== "HTML";
return elem.nodeType === 9 && elem.documentElement.nodeName !== "HTML" ||
!!elem.ownerDocument && elem.ownerDocument.documentElement.nodeName !== "HTML";
},
 
// Evalulates a script in a global context
globalEval: function( data ) {
if ( data && rnotwhite.test(data) ) {
if ( data && /\S/.test(data) ) {
// Inspired by code by Andrea Giammarchi
// http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
var head = document.getElementsByTagName("head")[0] || document.documentElement,
344,7 → 301,6
script = document.createElement("script");
 
script.type = "text/javascript";
 
if ( jQuery.support.scriptEval ) {
script.appendChild( document.createTextNode( data ) );
} else {
364,12 → 320,10
 
// args is for internal usage only
each: function( object, callback, args ) {
var name, i = 0,
length = object.length,
isObj = length === undefined || jQuery.isFunction(object);
var name, i = 0, length = object.length;
 
if ( args ) {
if ( isObj ) {
if ( length === undefined ) {
for ( name in object ) {
if ( callback.apply( object[ name ], args ) === false ) {
break;
385,7 → 339,7
 
// A special, fast, case for the most common use of each
} else {
if ( isObj ) {
if ( length === undefined ) {
for ( name in object ) {
if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
break;
401,7 → 355,7
},
 
trim: function( text ) {
return (text || "").replace( rtrim, "" );
return (text || "").replace( /^\s+|\s+$/g, "" );
},
 
makeArray: function( array ) {
509,7 → 463,7
// It's included for backwards compatibility and plugins,
// although they should work to migrate away.
browser: {
version: (/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/.exec(userAgent) || [0,'0'])[1],
version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1],
safari: /webkit/.test( userAgent ),
opera: /opera/.test( userAgent ),
msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
549,24 → 503,25
windowData :
elem;
 
var id = elem[ expando ], cache = jQuery.cache;
var id = elem[ expando ];
 
// Compute a unique ID for the element
if(!id) id = elem[ expando ] = ++uuid;
if ( !id )
id = elem[ expando ] = ++uuid;
 
// Only generate the data cache if we're
// trying to access or manipulate it
if ( name && !cache[ id ] )
cache[ id ] = {};
if ( name && !jQuery.cache[ id ] )
jQuery.cache[ id ] = {};
 
var thisCache = cache[ id ];
 
// Prevent overriding the named cache with undefined values
if ( data !== undefined ) thisCache[ name ] = data;
if ( data !== undefined )
jQuery.cache[ id ][ name ] = data;
 
if(name === true) return thisCache
else if(name) return thisCache[name]
else return id
// Return the named cache data, or the ID for the element
return name ?
jQuery.cache[ id ][ name ] :
id;
},
 
removeData: function( elem, name ) {
574,16 → 529,21
windowData :
elem;
 
var id = elem[ expando ], cache = jQuery.cache, thisCache = cache[ id ];
var id = elem[ expando ];
 
// If we want to remove a specific section of the element's data
if ( name ) {
if ( thisCache ) {
if ( jQuery.cache[ id ] ) {
// Remove the section of cache data
delete thisCache[ name ];
delete jQuery.cache[ id ][ name ];
 
// If we've removed all the data, remove the element's cache
if( jQuery.isEmptyObject(thisCache) )
name = "";
 
for ( name in jQuery.cache[ id ] )
break;
 
if ( !name )
jQuery.removeData( elem );
}
 
600,48 → 560,39
}
 
// Completely remove the data cache
delete cache[ id ];
delete jQuery.cache[ id ];
}
},
queue: function( elem, type, data ) {
if( !elem ) return;
if ( elem ){
 
type = (type || "fx") + "queue";
var q = jQuery.data( elem, type );
type = (type || "fx") + "queue";
 
// Speed up dequeue by getting out quickly if this is just a lookup
if( !data ) return q || [];
var q = jQuery.data( elem, type );
 
if ( !q || jQuery.isArray(data) )
q = jQuery.data( elem, type, jQuery.makeArray(data) );
else
q.push( data );
if ( !q || jQuery.isArray(data) )
q = jQuery.data( elem, type, jQuery.makeArray(data) );
else if( data )
q.push( data );
 
}
return q;
},
 
dequeue: function( elem, type ){
type = type || "fx";
var queue = jQuery.queue( elem, type ),
fn = queue.shift();
 
var queue = jQuery.queue( elem, type ), fn = queue.shift();
if( !type || type === "fx" )
fn = queue[0];
 
// If the fx queue is dequeued, always remove the progress sentinel
if( fn === "inprogress" ) fn = queue.shift();
 
if( fn ) {
// Add a progress sentinel to prevent the fx queue from being
// automatically dequeued
if( type == "fx" ) queue.unshift("inprogress");
 
fn.call(elem, function() { jQuery.dequeue(elem, type); });
}
if( fn !== undefined )
fn.call(elem);
}
});
 
jQuery.fn.extend({
data: function( key, value ){
if(typeof key === "undefined" && this.length) return jQuery.data(this[0], true);
 
var parts = key.split(".");
parts[1] = parts[1] ? "." + parts[1] : "";
 
674,11 → 625,11
if ( data === undefined )
return jQuery.queue( this[0], type );
 
return this.each(function(i, elem){
return this.each(function(){
var queue = jQuery.queue( this, type, data );
 
if( type == "fx" && queue[0] !== "inprogress" )
jQuery.dequeue( this, type )
if( type == "fx" && queue.length == 1 )
queue[0].call(this);
});
},
dequeue: function(type){
685,9 → 636,6
return this.each(function(){
jQuery.dequeue( this, type );
});
},
clearQueue: function(type){
return this.queue( type || "fx", [] );
}
});/*!
* Sizzle CSS Selector Engine - v1.0
1023,7 → 971,7
"": function(checkSet, part, isXML){
var doneName = done++, checkFn = dirCheck;
 
if ( !/\W/.test(part) ) {
if ( !part.match(/\W/) ) {
var nodeCheck = part = isXML ? part : part.toUpperCase();
checkFn = dirNodeCheck;
}
1033,7 → 981,7
"~": function(checkSet, part, isXML){
var doneName = done++, checkFn = dirCheck;
 
if ( typeof part === "string" && !/\W/.test(part) ) {
if ( typeof part === "string" && !part.match(/\W/) ) {
var nodeCheck = part = isXML ? part : part.toUpperCase();
checkFn = dirNodeCheck;
}
1126,7 → 1074,7
PSEUDO: function(match, curLoop, inplace, result, not){
if ( match[1] === "not" ) {
// If we're dealing with a complex expression, or a simple one
if ( chunker.exec(match[3]).length > 1 || /^\w/.test(match[3]) ) {
if ( match[3].match(chunker).length > 1 || /^\w/.test(match[3]) ) {
match[3] = Sizzle(match[3], null, null, curLoop);
} else {
var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
1352,7 → 1300,7
}
 
var makeArray = function(array, results) {
array = Array.prototype.slice.call( array, 0 );
array = Array.prototype.slice.call( array );
 
if ( results ) {
results.push.apply( results, array );
1365,7 → 1313,7
// Perform a simple check to determine if the browser is capable of
// converting a NodeList to an array using builtin methods.
try {
Array.prototype.slice.call( document.documentElement.childNodes, 0 );
Array.prototype.slice.call( document.documentElement.childNodes );
 
// Provide a fallback method if it does not work
} catch(e){
1668,17 → 1616,21
jQuery.expr[":"] = jQuery.expr.filters;
 
Sizzle.selectors.filters.hidden = function(elem){
var width = elem.offsetWidth, height = elem.offsetHeight,
force = /^tr$/i.test( elem.nodeName ); // ticket #4512
return ( width === 0 && height === 0 && !force ) ?
var width = elem.offsetWidth, height = elem.offsetHeight;
return ( width === 0 && height === 0 ) ?
true :
( width !== 0 && height !== 0 && !force ) ?
false :
!!( jQuery.curCSS(elem, "display") === "none" );
( width !== 0 && height !== 0 ) ?
false :
!!( jQuery.curCSS(elem, "display") === "none" );
};
 
Sizzle.selectors.filters.visible = function(elem){
return !Sizzle.selectors.filters.hidden(elem);
var width = elem.offsetWidth, height = elem.offsetHeight;
return ( width === 0 && height === 0 ) ?
false :
( width > 0 && height > 0 ) ?
true :
!!( jQuery.curCSS(elem, "display") !== "none" );
};
 
Sizzle.selectors.filters.animated = function(elem){
1732,27 → 1684,6
window.Sizzle = Sizzle;
 
})();
jQuery.winnow = function( elements, qualifier, keep ) {
if(jQuery.isFunction( qualifier )) {
return jQuery.grep(elements, function(elem, i) {
return !!qualifier.call( elem, i ) === keep;
});
} else if( qualifier.nodeType ) {
return jQuery.grep(elements, function(elem, i) {
return (elem === qualifier) === keep;
})
} else if( typeof qualifier === "string" ) {
var filtered = jQuery.grep(elements, function(elem) { return elem.nodeType === 1 });
 
if(isSimple.test( qualifier )) return jQuery.multiFilter(qualifier, filtered, !keep);
else qualifier = jQuery.multiFilter( qualifier, elements );
}
 
return jQuery.grep(elements, function(elem, i) {
return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
});
}
 
jQuery.fn.extend({
find: function( selector ) {
var ret = this.pushStack( "", "find", selector ), length = 0;
1777,22 → 1708,25
return ret;
},
 
not: function( selector ) {
return this.pushStack( jQuery.winnow(this, selector, false), "not", selector);
},
filter: function( selector ) {
return this.pushStack(
jQuery.isFunction( selector ) &&
jQuery.grep(this, function(elem, i){
return selector.call( elem, i );
}) ||
 
filter: function( selector ) {
return this.pushStack( jQuery.winnow(this, selector, true), "filter", selector );
jQuery.multiFilter( selector, jQuery.grep(this, function(elem){
return elem.nodeType === 1;
}) ), "filter", selector );
},
 
closest: function( selector ) {
var pos = jQuery.expr.match.POS.test( selector ) ? jQuery(selector) : null,
closer = 0,
context = this.context;
closer = 0;
 
return this.map(function(){
var cur = this;
while ( cur && cur.ownerDocument && cur !== context ) {
while ( cur && cur.ownerDocument ) {
if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selector) ) {
jQuery.data(cur, "closest", closer);
return cur;
1803,6 → 1737,20
});
},
 
not: function( selector ) {
if ( typeof selector === "string" )
// test special case where just one selector is passed in
if ( isSimple.test( selector ) )
return this.pushStack( jQuery.multiFilter( selector, this, true ), "not", selector );
else
selector = jQuery.multiFilter( selector, this );
 
var isArrayLike = selector.length && selector[selector.length - 1] !== undefined && !selector.nodeType;
return this.filter(function() {
return isArrayLike ? jQuery.inArray( this, selector ) < 0 : this != selector;
});
},
 
add: function( selector ) {
return this.pushStack( jQuery.unique( jQuery.merge(
this.get(),
1855,34 → 1803,37
 
return this.pushStack( jQuery.unique( ret ), name, selector );
};
});
jQuery.fn.extend({
});jQuery.fn.extend({
attr: function( name, value ) {
var elem, options, isFunction = jQuery.isFunction(value);
var options = name, isFunction = jQuery.isFunction( value );
 
if ( typeof name === "string" ) { // A single attribute
if ( value === undefined ) { // Query it on first element
if ( typeof name === "string" ) {
// Are we setting the attribute?
if ( value === undefined ) {
return this.length ?
jQuery.attr( this[0], name ) :
null;
} else { // Set it on all elements
for ( var i = 0, l = this.length; i < l; i++ ) {
elem = this[i];
if ( isFunction )
value = value.call(elem,i);
jQuery.attr( elem, name, value );
}
 
// Convert name, value params to options hash format
} else {
options = {};
options[ name ] = value;
}
} else { // Multiple attributes to set on all
options = name;
for ( var i = 0, l = this.length; i < l; i++ ) {
elem = this[i];
for ( name in options ) {
value = options[name];
if ( jQuery.isFunction(value) )
value = value.call(elem,i);
jQuery.attr( elem, name, value );
}
 
// For each element...
for ( var i = 0, l = this.length; i < l; i++ ) {
var elem = this[i];
 
// Set all the attributes
for ( var prop in options ) {
value = options[prop];
 
if ( isFunction ) {
value = value.call( elem, i );
}
 
jQuery.attr( elem, prop, value );
}
}
 
1940,31 → 1891,23
return undefined;
}
 
// Typecast once if the value is a number
if ( typeof value === "number" )
value += '';
var val = value;
 
return this.each(function(){
if(jQuery.isFunction(value)) {
val = value.call(this);
// Typecast each time if the value is a Function and the appended
// value is therefore different each time.
if( typeof val === "number" ) val += '';
}
if ( this.nodeType != 1 )
return;
 
if ( jQuery.isArray(val) && /radio|checkbox/.test( this.type ) )
this.checked = jQuery.inArray(this.value || this.name, val) >= 0;
if ( jQuery.isArray(value) && /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 = jQuery.makeArray(val);
var values = jQuery.makeArray(value);
 
jQuery( "option", this ).each(function(){
this.selected = jQuery.inArray( this.value || this.text, values ) >= 0;
this.selected = (jQuery.inArray( this.value, values ) >= 0 ||
jQuery.inArray( this.text, values ) >= 0);
});
 
if ( !values.length )
1971,7 → 1914,7
this.selectedIndex = -1;
 
} else
this.value = val;
this.value = value;
});
}
});
2048,7 → 1991,7
if (!elem || elem.nodeType == 3 || elem.nodeType == 8)
return undefined;
 
var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ),
var notxml = !elem.tagName || !jQuery.isXMLDoc( elem ),
// Whether we are setting (or getting)
set = value !== undefined;
 
2056,7 → 1999,7
name = notxml && jQuery.props[ name ] || name;
 
// Only do all the following if this is a node (faster for style)
if ( elem.nodeType === 1 ) {
if ( elem.tagName ) {
 
// These attributes require special treatment
var special = /href|src|style/.test( name );
2070,7 → 2013,7
if ( name in elem && notxml && !special ) {
if ( set ){
// We can't allow the type property to be changed (since it causes problems in IE)
if ( name == "type" && /(button|input)/i.test(elem.nodeName) && elem.parentNode )
if ( name == "type" && elem.nodeName.match(/(button|input)/i) && elem.parentNode )
throw "type property can't be changed";
 
elem[ name ] = value;
2086,9 → 2029,9
var attributeNode = elem.getAttributeNode( "tabIndex" );
return attributeNode && attributeNode.specified
? attributeNode.value
: /(button|input|object|select|textarea)/i.test(elem.nodeName)
: elem.nodeName.match(/(button|input|object|select|textarea)/i)
? 0
: /^(a|area)$/i.test(elem.nodeName) && elem.href
: elem.nodeName.match(/^(a|area)$/i) && elem.href
? 0
: undefined;
}
2120,23 → 2063,9
// Using attr for specific style information is now deprecated. Use style insead.
return jQuery.style(elem, name, value);
}
});
var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
rleadingWhitespace = /^\s+/,
rsingleTag = /^<(\w+)\s*\/?>$/,
rxhtmlTag = /(<(\w+)[^>]*?)\/>/g,
rselfClosing = /^(?:abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i,
rinsideTable = /^<(thead|tbody|tfoot|colg|cap)/,
rtbody = /<tbody/i,
fcloseTag = function(all, front, tag){
return rselfClosing.test(tag) ?
all :
front + "></" + tag + ">";
};
 
jQuery.fn.extend({
});jQuery.fn.extend({
text: function( text ) {
if ( typeof text !== "object" && text !== undefined )
if ( typeof text !== "object" && text != null )
return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
 
var ret = "";
2143,11 → 2072,10
 
jQuery.each( text || this, function(){
jQuery.each( this.childNodes, function(){
if ( this.nodeType !== 8 ) {
ret += this.nodeType !== 1 ?
if ( this.nodeType != 8 )
ret += this.nodeType != 1 ?
this.nodeValue :
jQuery.fn.text( [ this ] );
}
});
});
 
2155,26 → 2083,18
},
 
wrapAll: function( html ) {
if ( jQuery.isFunction( html ) ) {
return this.each(function() {
jQuery(this).wrapAll( html.apply(this, arguments) );
});
}
 
if ( this[0] ) {
// The elements to wrap the target around
var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone();
var wrap = jQuery( html, this[0].ownerDocument ).clone();
 
if ( this[0].parentNode ) {
if ( this[0].parentNode )
wrap.insertBefore( this[0] );
}
 
wrap.map(function(){
var elem = this;
 
while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
while ( elem.firstChild )
elem = elem.firstChild;
}
 
return elem;
}).append(this);
2197,17 → 2117,15
 
append: function() {
return this.domManip(arguments, true, function(elem){
if ( this.nodeType === 1 ) {
if (this.nodeType == 1)
this.appendChild( elem );
}
});
},
 
prepend: function() {
return this.domManip(arguments, true, function(elem){
if ( this.nodeType === 1 ) {
if (this.nodeType == 1)
this.insertBefore( elem, this.firstChild );
}
});
},
 
2242,11 → 2160,9
html = div.innerHTML;
}
 
return jQuery.clean([html.replace(rinlinejQuery, "")
.replace(rleadingWhitespace, "")], ownerDocument)[0];
} else {
return jQuery.clean([html.replace(/ jQuery\d+="(?:\d+|null)"/g, "").replace(/^\s*/, "")], ownerDocument)[0];
} else
return this.cloneNode(true);
}
});
 
// Copy the events from the original to the clone
2254,7 → 2170,8
var orig = this.find("*").andSelf(), i = 0;
 
ret.find("*").andSelf().each(function(){
if ( this.nodeName !== orig[i].nodeName ) { return; }
if ( this.nodeName !== orig[i].nodeName )
return;
 
var events = jQuery.data( orig[i], "events" );
 
2275,7 → 2192,7
html: function( value ) {
return value === undefined ?
(this[0] ?
this[0].innerHTML.replace(rinlinejQuery, "") :
this[0].innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g, "") :
null) :
this.empty().append( value );
},
2284,68 → 2201,25
return this.after( value ).remove();
},
 
detach: function( selector ) {
return this.remove( selector, true );
},
 
domManip: function( args, table, callback ) {
var fragment, scripts, cacheable, cached, cacheresults, first,
value = args[0];
 
if ( jQuery.isFunction(value) ) {
return this.each(function() {
args[0] = value.call(this);
return jQuery(this).domManip( args, table, callback );
});
}
 
if ( this[0] ) {
if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && args[0].indexOf("<option") < 0 ) {
cacheable = true;
cacheresults = jQuery.fragments[ args[0] ];
if ( cacheresults ) {
if ( cacheresults !== 1 ) {
fragment = cacheresults;
}
cached = true;
}
}
var fragment = (this[0].ownerDocument || this[0]).createDocumentFragment(),
scripts = jQuery.clean( args, (this[0].ownerDocument || this[0]), fragment ),
first = fragment.firstChild;
 
if ( !fragment ) {
fragment = (this[0].ownerDocument || this[0]).createDocumentFragment();
scripts = jQuery.clean( args, (this[0].ownerDocument || this[0]), fragment );
}
if ( first )
for ( var i = 0, l = this.length; i < l; i++ )
callback.call( root(this[i], first), this.length > 1 || i > 0 ?
fragment.cloneNode(true) : fragment );
 
first = fragment.firstChild;
 
if ( first ) {
table = table && jQuery.nodeName( first, "tr" );
 
for ( var i = 0, l = this.length; i < l; i++ ) {
callback.call(
table ?
root(this[i], first) :
this[i],
cacheable || this.length > 1 || i > 0 ?
fragment.cloneNode(true) :
fragment
);
}
}
 
if ( scripts ) {
if ( scripts )
jQuery.each( scripts, evalScript );
}
 
if ( cacheable ) {
jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1;
}
}
 
return this;
 
function root( elem, cur ) {
return jQuery.nodeName(elem, "table") ?
return table && jQuery.nodeName(elem, "table") && jQuery.nodeName(cur, "tr") ?
(elem.getElementsByTagName("tbody")[0] ||
elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
elem;
2353,8 → 2227,6
}
});
 
jQuery.fragments = {};
 
jQuery.each({
appendTo: "append",
prependTo: "prepend",
2376,15 → 2248,14
});
 
jQuery.each({
// keepData is for internal use only--do not document
remove: function( selector, keepData ) {
remove: function( selector ) {
if ( !selector || jQuery.multiFilter( selector, [ this ] ).length ) {
if ( !keepData && this.nodeType === 1 ) {
if ( this.nodeType === 1 ) {
cleanData( jQuery("*", this).add(this) );
}
 
if ( this.parentNode ) {
this.parentNode.removeChild( this );
this.parentNode.removeChild( this );
}
}
},
2411,36 → 2282,37
context = context || document;
 
// !context.createElement fails in IE with an error but returns typeof 'object'
if ( typeof context.createElement === "undefined" ) {
if ( typeof context.createElement === "undefined" )
context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
}
 
// If a single string is passed in and it's a single tag
// just do a createElement and skip the rest
if ( !fragment && elems.length === 1 && typeof elems[0] === "string" ) {
var match = rsingleTag.exec(elems[0]);
if ( match ) {
var match = /^<(\w+)\s*\/?>$/.exec(elems[0]);
if ( match )
return [ context.createElement( match[1] ) ];
}
}
 
var ret = [], scripts = [], div = context.createElement("div");
 
jQuery.each(elems, function(i, elem){
if ( typeof elem === "number" ) {
if ( typeof elem === "number" )
elem += '';
}
 
if ( !elem ) { return; }
if ( !elem )
return;
 
// Convert html string into DOM nodes
if ( typeof elem === "string" ) {
// Fix "XHTML"-style tags in all browsers
elem = elem.replace(rxhtmlTag, fcloseTag);
elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){
return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i) ?
all :
front + "></" + tag + ">";
});
 
// Trim whitespace, otherwise indexOf won't work as expected
var tags = elem.replace(rleadingWhitespace, "")
.substring(0, 10).toLowerCase();
var tags = elem.replace(/^\s+/, "").substring(0, 10).toLowerCase();
 
var wrap =
// option or optgroup
2450,7 → 2322,7
!tags.indexOf("<leg") &&
[ 1, "<fieldset>", "</fieldset>" ] ||
 
rinsideTable.test(tags) &&
tags.match(/^<(thead|tbody|tfoot|colg|cap)/) &&
[ 1, "<table>", "</table>" ] ||
 
!tags.indexOf("<tr") &&
2473,44 → 2345,39
div.innerHTML = wrap[1] + elem + wrap[2];
 
// Move to the right depth
while ( wrap[0]-- ) {
while ( wrap[0]-- )
div = div.lastChild;
}
 
// Remove IE's autoinserted <tbody> from table fragments
if ( !jQuery.support.tbody ) {
 
// String was a <table>, *may* have spurious <tbody>
var hasBody = rtbody.test(elem),
var hasBody = /<tbody/i.test(elem),
tbody = !tags.indexOf("<table") && !hasBody ?
div.firstChild && div.firstChild.childNodes :
 
// String was a bare <thead> or <tfoot>
wrap[1] == "<table>" && !hasBody ?
div.childNodes :
[];
// String was a bare <thead> or <tfoot>
wrap[1] == "<table>" && !hasBody ?
div.childNodes :
[];
 
for ( var j = tbody.length - 1; j >= 0 ; --j ) {
if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
for ( var j = tbody.length - 1; j >= 0 ; --j )
if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length )
tbody[ j ].parentNode.removeChild( tbody[ j ] );
}
 
}
 
}
 
// IE completely kills leading whitespace when innerHTML is used
if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
}
if ( !jQuery.support.leadingWhitespace && /^\s/.test( elem ) )
div.insertBefore( context.createTextNode( elem.match(/^\s*/)[0] ), div.firstChild );
 
elem = jQuery.makeArray( div.childNodes );
}
 
if ( elem.nodeType ) {
if ( elem.nodeType )
ret.push( elem );
} else {
else
ret = jQuery.merge( ret, elem );
}
 
});
 
2519,9 → 2386,8
if ( jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
} else {
if ( ret[i].nodeType === 1 ) {
if ( ret[i].nodeType === 1 )
ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );
}
fragment.appendChild( ret[i] );
}
}
2600,7 → 2466,7
// Namespaced event handlers
var namespaces = type.split(".");
type = namespaces.shift();
handler.type = namespaces.slice(0).sort().join(".");
handler.type = namespaces.slice().sort().join(".");
 
// Get the current list of functions bound to this event
var handlers = events[ type ],
2676,7 → 2542,7
var namespaces = type.split(".");
type = namespaces.shift();
var all = !namespaces.length,
namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join(".*\\.") + "(\\.|$)"),
namespace = new RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)"),
special = this.special[ type ] || {};
 
if ( events[ type ] ) {
2834,7 → 2700,7
// Cache this now, all = true means, any handler
all = !namespaces.length && !event.exclusive;
 
var namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join(".*\\.") + "(\\.|$)");
var namespace = new RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)");
 
handlers = ( jQuery.data(this, "events") || {} )[ event.type ];
 
3258,12 → 3124,6
if ( readyBound ) return;
readyBound = true;
 
// Catch cases where $(document).ready() is called after the
// browser event has already occurred.
if ( document.readyState === "complete" ) {
return jQuery.ready();
}
 
// Mozilla, Opera and webkit nightlies currently support this event
if ( document.addEventListener ) {
// Use the handy event callback
3440,22 → 3300,11
tabindex: "tabIndex"
};
// exclude the following css properties to add px
var rexclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
ralpha = /alpha\([^)]*\)/,
ropacity = /opacity=([^)]*)/,
rfloat = /float/i,
rdashAlpha = /-([a-z])/ig,
rupper = /([A-Z])/g,
rnumpx = /^\d+(?:px)?$/i,
rnum = /^\d/,
 
var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
// cache check for defaultView.getComputedStyle
getComputedStyle = document.defaultView && document.defaultView.getComputedStyle,
// normalize float css property
styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat",
fcamelCase = function(all, letter){
return letter.toUpperCase();
};
styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat";
 
jQuery.fn.css = function( name, value ) {
var options = name, isFunction = jQuery.isFunction( value );
3473,14 → 3322,6
options[ name ] = value;
}
}
var isFunction = {};
// For each value, determine whether it's a Function so we don't
// need to determine it again for each element
for ( var prop in options ) {
isFunction[prop] = jQuery.isFunction( options[prop] );
}
 
// For each element...
for ( var i = 0, l = this.length; i < l; i++ ) {
3490,11 → 3331,11
for ( var prop in options ) {
value = options[prop];
 
if ( isFunction[prop] ) {
if ( isFunction ) {
value = value.call( elem, i );
}
 
if ( typeof value === "number" && !rexclude.test(prop) ) {
if ( typeof value === "number" && !exclude.test(prop) ) {
value = value + "px";
}
 
3508,19 → 3349,17
jQuery.extend({
style: function( elem, name, value ) {
// don't set styles on text and comment nodes
if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
if (!elem || elem.nodeType == 3 || elem.nodeType == 8)
return undefined;
}
 
// ignore negative width and height values #1599
if ( (name === "width" || name === "height") && parseFloat(value) < 0 ) {
if ( (name == 'width' || name == 'height') && parseFloat(value) < 0 )
value = undefined;
}
 
var style = elem.style || elem, set = value !== undefined;
 
// IE uses filters for opacity
if ( !jQuery.support.opacity && name === "opacity" ) {
if ( !jQuery.support.opacity && name == "opacity" ) {
if ( set ) {
// IE has trouble with opacity if it does not have layout
// Force it by setting the zoom level
3527,56 → 3366,53
style.zoom = 1;
 
// Set the alpha filter to set the opacity
style.filter = (style.filter || "").replace( ralpha, "" ) +
(parseInt( value ) + '' === "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");
style.filter = (style.filter || "").replace( /alpha\([^)]*\)/, "" ) +
(parseInt( value ) + '' == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");
}
 
return style.filter && style.filter.indexOf("opacity=") >= 0 ?
(parseFloat( ropacity.exec(style.filter)[1] ) / 100) + '':
(parseFloat( style.filter.match(/opacity=([^)]*)/)[1] ) / 100) + '':
"";
}
 
// Make sure we're using the right name for getting the float value
if ( rfloat.test( name ) ) {
if ( /float/i.test( name ) )
name = styleFloat;
}
 
name = name.replace(rdashAlpha, fcamelCase);
name = name.replace(/-([a-z])/ig, function(all, letter){
return letter.toUpperCase();
});
 
if ( set ) {
if ( set )
style[ name ] = value;
}
 
return style[ name ];
},
 
css: function( elem, name, force, extra ) {
if ( name === "width" || name === "height" ) {
var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name === "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ];
if ( name == "width" || name == "height" ) {
var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ];
 
function getWH() {
val = name === "width" ? elem.offsetWidth : elem.offsetHeight;
val = name == "width" ? elem.offsetWidth : elem.offsetHeight;
 
if ( extra === "border" ) { return; }
if ( extra === "border" )
return;
 
jQuery.each( which, function() {
if ( !extra ) {
if ( !extra )
val -= parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0;
}
 
if ( extra === "margin" ) {
if ( extra === "margin" )
val += parseFloat(jQuery.curCSS( elem, "margin" + this, true)) || 0;
} else {
else
val -= parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0;
}
});
}
 
if ( elem.offsetWidth !== 0 ) {
if ( elem.offsetWidth !== 0 )
getWH();
} else {
else
jQuery.swap( elem, props, getWH );
}
 
return Math.max(0, Math.round(val));
}
3589,7 → 3425,7
 
// IE uses filters for opacity
if ( !jQuery.support.opacity && name === "opacity" && elem.currentStyle ) {
ret = ropacity.test(elem.currentStyle.filter || "") ?
ret = (elem.currentStyle.filter || "").match(/opacity=([^)]*)/) ?
(parseFloat(RegExp.$1) / 100) + "" :
"";
 
3599,9 → 3435,8
}
 
// Make sure we're using the right name for getting the float value
if ( rfloat.test( name ) ) {
if ( /float/i.test( name ) )
name = styleFloat;
}
 
if ( !force && style && style[ name ] ) {
ret = style[ name ];
3609,25 → 3444,24
} else if ( getComputedStyle ) {
 
// Only "float" is needed here
if ( rfloat.test( name ) ) {
if ( /float/i.test( name ) )
name = "float";
}
 
name = name.replace( rupper, "-$1" ).toLowerCase();
name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase();
 
var computedStyle = elem.ownerDocument.defaultView.getComputedStyle( elem, null );
 
if ( computedStyle ) {
if ( computedStyle )
ret = computedStyle.getPropertyValue( name );
}
 
// We should always get a number back from opacity
if ( name === "opacity" && ret === "" ) {
if ( name == "opacity" && ret == "" )
ret = "1";
}
 
} else if ( elem.currentStyle ) {
var camelCase = name.replace(rdashAlpha, fcamelCase);
var camelCase = name.replace(/\-(\w)/g, function(all, letter){
return letter.toUpperCase();
});
 
ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ];
 
3636,7 → 3470,7
 
// 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
if ( !rnumpx.test( ret ) && rnum.test( ret ) ) {
if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) {
// Remember the original values
var left = style.left, rsLeft = elem.runtimeStyle.left;
 
3657,7 → 3491,6
// A method for quickly swapping in/out CSS properties to get correct calculations
swap: function( elem, options, callback ) {
var old = {};
 
// Remember the old values, and insert the new ones
for ( var name in options ) {
old[ name ] = elem.style[ name ];
3667,29 → 3500,16
callback.call( elem );
 
// Revert the old values
for ( var name in options ) {
for ( var name in options )
elem.style[ name ] = old[ name ];
}
}
});
var jsc = now(),
rscript = /<script(.|\s)*?\/script>/g,
rselectTextarea = /select|textarea/i,
rinput = /text|hidden|password|search/i,
jsre = /=\?(&|$)/,
rquery = /\?/,
rts = /(\?|&)_=.*?(&|$)/,
rurl = /^(\w+:)?\/\/([^\/?#]+)/,
r20 = /%20/g;
 
jQuery.fn.extend({
});jQuery.fn.extend({
// Keep a copy of the old load
_load: jQuery.fn.load,
 
load: function( url, params, callback ) {
if ( typeof url !== "string" ) {
if ( typeof url !== "string" )
return this._load( url );
}
 
var off = url.indexOf(" ");
if ( off >= 0 ) {
3701,7 → 3521,7
var type = "GET";
 
// If the second parameter was provided
if ( params ) {
if ( params )
// If it's a function
if ( jQuery.isFunction( params ) ) {
// We assume that it's the callback
3709,11 → 3529,10
params = null;
 
// Otherwise, build a param string
} else if ( typeof params === "object" ) {
} else if( typeof params === "object" ) {
params = jQuery.param( params );
type = "POST";
}
}
 
var self = this;
 
3725,7 → 3544,7
data: params,
complete: function(res, status){
// If successful, inject the HTML into all the matched elements
if ( status === "success" || status === "notmodified" ) {
if ( status == "success" || status == "notmodified" )
// See if a selector was specified
self.html( selector ?
// Create a dummy div to hold the results
3732,7 → 3551,7
jQuery("<div/>")
// inject the contents of the document in, removing the scripts
// to avoid any 'Permission Denied' errors in IE
.append(res.responseText.replace(rscript, ""))
.append(res.responseText.replace(/<script(.|\s)*?\/script>/g, ""))
 
// Locate the specified elements
.find(selector) :
3739,14 → 3558,11
 
// If not, just inject the full result
res.responseText );
}
 
if ( callback ) {
if( callback )
self.each( callback, [res.responseText, status, res] );
}
}
});
 
return this;
},
 
3759,14 → 3575,12
})
.filter(function(){
return this.name && !this.disabled &&
(this.checked || rselectTextarea.test(this.nodeName) ||
rinput.test(this.type));
(this.checked || /select|textarea/i.test(this.nodeName) ||
/text|hidden|password|search/i.test(this.type));
})
.map(function(i, elem){
var val = jQuery(this).val();
 
return val == null ?
null :
return val == null ? null :
jQuery.isArray(val) ?
jQuery.map( val, function(val, i){
return {name: elem.name, value: val};
3783,6 → 3597,8
};
});
 
var jsc = now();
 
jQuery.extend({
 
get: function( url, data, callback, type ) {
3844,10 → 3660,8
// Create the request object; Microsoft failed to properly
// implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
// This function can be overriden by calling jQuery.ajaxSetup
xhr: function(){
return window.ActiveXObject ?
new ActiveXObject("Microsoft.XMLHTTP") :
new XMLHttpRequest();
xhr:function(){
return window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
},
accepts: {
xml: "application/xml, text/xml",
3868,35 → 3682,30
// checked again later (in the test suite, specifically)
s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s));
 
var jsonp, status, data,
var jsonp, jsre = /=\?(&|$)/g, status, data,
type = s.type.toUpperCase();
 
// convert data if not already a string
if ( s.data && s.processData && typeof s.data !== "string" ) {
if ( s.data && s.processData && typeof s.data !== "string" )
s.data = jQuery.param(s.data);
}
 
// Handle JSONP Parameter Callbacks
if ( s.dataType === "jsonp" ) {
if ( type === "GET" ) {
if ( !jsre.test( s.url ) ) {
s.url += (rquery.test( s.url ) ? "&" : "?") + (s.jsonp || "callback") + "=?";
}
} else if ( !s.data || !jsre.test(s.data) ) {
if ( s.dataType == "jsonp" ) {
if ( type == "GET" ) {
if ( !s.url.match(jsre) )
s.url += (s.url.match(/\?/) ? "&" : "?") + (s.jsonp || "callback") + "=?";
} else if ( !s.data || !s.data.match(jsre) )
s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?";
}
s.dataType = "json";
}
 
// Build temporary JSONP function
if ( s.dataType === "json" && (s.data && jsre.test(s.data) || jsre.test(s.url)) ) {
if ( s.dataType == "json" && (s.data && s.data.match(jsre) || s.url.match(jsre)) ) {
jsonp = "jsonp" + jsc++;
 
// Replace the =? sequence both in the query string and the data
if ( s.data ) {
if ( s.data )
s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1");
}
 
s.url = s.url.replace(jsre, "=" + jsonp + "$1");
 
// We need to make sure
3911,50 → 3720,44
// Garbage collect
window[ jsonp ] = undefined;
try{ delete window[ jsonp ]; } catch(e){}
if ( head ) {
if ( head )
head.removeChild( script );
}
};
}
 
if ( s.dataType === "script" && s.cache === null ) {
if ( s.dataType == "script" && s.cache == null )
s.cache = false;
}
 
if ( s.cache === false && type === "GET" ) {
if ( s.cache === false && type == "GET" ) {
var ts = now();
 
// try replacing _= if it is there
var ret = s.url.replace(rts, "$1_=" + ts + "$2");
 
var ret = s.url.replace(/(\?|&)_=.*?(&|$)/, "$1_=" + ts + "$2");
// if nothing was replaced, add timestamp to the end
s.url = ret + ((ret === s.url) ? (rquery.test(s.url) ? "&" : "?") + "_=" + ts : "");
s.url = ret + ((ret == s.url) ? (s.url.match(/\?/) ? "&" : "?") + "_=" + ts : "");
}
 
// If data is available, append data to url for get requests
if ( s.data && type === "GET" ) {
s.url += (rquery.test(s.url) ? "&" : "?") + s.data;
if ( s.data && type == "GET" ) {
s.url += (s.url.match(/\?/) ? "&" : "?") + s.data;
}
 
// Watch for a new set of requests
if ( s.global && ! jQuery.active++ ) {
if ( s.global && ! jQuery.active++ )
jQuery.event.trigger( "ajaxStart" );
}
 
// Matches an absolute URL, and saves the domain
var parts = rurl.exec( s.url );
var parts = /^(\w+:)?\/\/([^\/?#]+)/.exec( s.url );
 
// If we're requesting a remote document
// and trying to load JSON or Script with a GET
if ( s.dataType === "script" && type === "GET" && parts
&& ( parts[1] && parts[1] !== location.protocol || parts[2] !== location.host )) {
if ( s.dataType == "script" && type == "GET" && parts
&& ( parts[1] && parts[1] != location.protocol || parts[2] != location.host )){
 
var head = document.getElementsByTagName("head")[0];
var script = document.createElement("script");
script.src = s.url;
if ( s.scriptCharset ) {
if (s.scriptCharset)
script.charset = s.scriptCharset;
}
 
// Handle Script loading
if ( !jsonp ) {
3963,7 → 3766,7
// Attach handlers for all browsers
script.onload = script.onreadystatechange = function(){
if ( !done && (!this.readyState ||
this.readyState === "loaded" || this.readyState === "complete") ) {
this.readyState == "loaded" || this.readyState == "complete") ) {
done = true;
success();
complete();
3970,9 → 3773,7
 
// Handle memory leak in IE
script.onload = script.onreadystatechange = null;
if ( head && script.parentNode ) {
head.removeChild( script );
}
head.removeChild( script );
}
};
}
3992,28 → 3793,23
 
// Open the socket
// Passing null username, generates a login popup on Opera (#2865)
if ( s.username ) {
if( s.username )
xhr.open(type, s.url, s.async, s.username, s.password);
} else {
else
xhr.open(type, s.url, s.async);
}
 
// Need an extra try/catch for cross domain requests in Firefox 3
try {
// Set the correct header, if data is being sent
if ( s.data ) {
if ( s.data )
xhr.setRequestHeader("Content-Type", s.contentType);
}
 
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
if ( s.ifModified ) {
if ( jQuery.lastModified[s.url] ) {
if (jQuery.lastModified[s.url])
xhr.setRequestHeader("If-Modified-Since", jQuery.lastModified[s.url]);
}
 
if ( jQuery.etag[s.url] ) {
if (jQuery.etag[s.url])
xhr.setRequestHeader("If-None-Match", jQuery.etag[s.url]);
}
}
 
// Set header so the called script knows that it's an XMLHttpRequest
4028,36 → 3824,30
// Allow custom headers/mimetypes and early abort
if ( s.beforeSend && s.beforeSend(xhr, s) === false ) {
// Handle the global AJAX counter
if ( s.global && ! --jQuery.active ) {
if ( s.global && ! --jQuery.active )
jQuery.event.trigger( "ajaxStop" );
}
 
// close opended socket
xhr.abort();
return false;
}
 
if ( s.global ) {
if ( s.global )
jQuery.event.trigger("ajaxSend", [xhr, s]);
}
 
// Wait for a response to come back
var onreadystatechange = function(isTimeout){
// The request was aborted, clear the interval and decrement jQuery.active
if ( xhr.readyState === 0 ) {
if ( ival ) {
if (xhr.readyState == 0) {
if (ival) {
// clear poll interval
clearInterval( ival );
clearInterval(ival);
ival = null;
 
// Handle the global AJAX counter
if ( s.global && ! --jQuery.active ) {
if ( s.global && ! --jQuery.active )
jQuery.event.trigger( "ajaxStop" );
}
}
 
// The transfer is complete and the data is available, or the request timed out
} else if ( !requestDone && xhr && (xhr.readyState === 4 || isTimeout === "timeout") ) {
} else if ( !requestDone && xhr && (xhr.readyState == 4 || isTimeout == "timeout") ) {
requestDone = true;
 
// clear poll interval
4066,15 → 3856,12
ival = null;
}
 
status = isTimeout === "timeout" ?
"timeout" :
!jQuery.httpSuccess( xhr ) ?
"error" :
s.ifModified && jQuery.httpNotModified( xhr, s.url ) ?
"notmodified" :
"success";
status = isTimeout == "timeout" ? "timeout" :
!jQuery.httpSuccess( xhr ) ? "error" :
s.ifModified && jQuery.httpNotModified( xhr, s.url ) ? "notmodified" :
"success";
 
if ( status === "success" ) {
if ( status == "success" ) {
// Watch for, and catch, XML document parse errors
try {
// process the data (runs the xml through httpData regardless of callback)
4085,26 → 3872,22
}
 
// Make sure that the request was successful or notmodified
if ( status === "success" || status === "notmodified" ) {
if ( status == "success" || status == "notmodified" ) {
// JSONP handles its own success callback
if ( !jsonp ) {
if ( !jsonp )
success();
}
} else {
} else
jQuery.handleError(s, xhr, status);
}
 
// Fire the complete handlers
complete();
 
if ( isTimeout ) {
if ( isTimeout )
xhr.abort();
}
 
// Stop memory leaks
if ( s.async ) {
if ( s.async )
xhr = null;
}
}
};
 
4113,55 → 3896,47
var ival = setInterval(onreadystatechange, 13);
 
// Timeout checker
if ( s.timeout > 0 ) {
if ( s.timeout > 0 )
setTimeout(function(){
// Check to see if the request is still happening
if ( xhr && !requestDone ) {
if ( xhr && !requestDone )
onreadystatechange( "timeout" );
}
}, s.timeout);
}
}
 
// Send the data
try {
xhr.send( type === "POST" || type === "PUT" ? s.data : null );
xhr.send( type === "POST" ? s.data : null );
} catch(e) {
jQuery.handleError(s, xhr, null, e);
}
 
// firefox 1.5 doesn't fire statechange for sync requests
if ( !s.async ) {
if ( !s.async )
onreadystatechange();
}
 
function success(){
// If a local callback was specified, fire it and pass it the data
if ( s.success ) {
if ( s.success )
s.success( data, status );
}
 
// Fire the global callback
if ( s.global ) {
if ( s.global )
jQuery.event.trigger( "ajaxSuccess", [xhr, s] );
}
}
 
function complete(){
// Process result
if ( s.complete ) {
if ( s.complete )
s.complete(xhr, status);
}
 
// The request was completed
if ( s.global ) {
if ( s.global )
jQuery.event.trigger( "ajaxComplete", [xhr, s] );
}
 
// Handle the global AJAX counter
if ( s.global && ! --jQuery.active ) {
if ( s.global && ! --jQuery.active )
jQuery.event.trigger( "ajaxStop" );
}
}
 
// return XMLHttpRequest to allow aborting the request etc.
4170,14 → 3945,11
 
handleError: function( s, xhr, status, e ) {
// If a local callback was specified, fire it
if ( s.error ) {
s.error( xhr, status, e );
}
if ( s.error ) s.error( xhr, status, e );
 
// Fire the global callback
if ( s.global ) {
if ( s.global )
jQuery.event.trigger( "ajaxError", [xhr, s, e] );
}
},
 
// Counter for holding the number of active queries
4187,43 → 3959,37
httpSuccess: function( xhr ) {
try {
// IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
return !xhr.status && location.protocol === "file:" ||
// Opera returns 0 when status is 304
( xhr.status >= 200 && xhr.status < 300 ) ||
xhr.status === 304 || xhr.status === 1223 || xhr.status === 0;
return !xhr.status && location.protocol == "file:" ||
( xhr.status >= 200 && xhr.status < 300 ) || xhr.status == 304 || xhr.status == 1223;
} catch(e){}
 
return false;
},
 
// Determines if an XMLHttpRequest returns NotModified
httpNotModified: function( xhr, url ) {
var last_modified = xhr.getResponseHeader("Last-Modified"),
etag = xhr.getResponseHeader("Etag");
var last_modified = xhr.getResponseHeader("Last-Modified");
var etag = xhr.getResponseHeader("Etag");
 
if ( last_modified ) {
if (last_modified)
jQuery.lastModified[url] = last_modified;
}
 
if ( etag ) {
if (etag)
jQuery.etag[url] = etag;
}
 
// Opera returns 0 when status is 304
return xhr.status === 304 || xhr.status === 0;
return xhr.status == 304;
},
 
httpData: function( xhr, type, s ) {
var ct = xhr.getResponseHeader("content-type"),
xml = type === "xml" || !type && ct && ct.indexOf("xml") >= 0,
xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0,
data = xml ? xhr.responseXML : xhr.responseText;
 
if ( xml && data.documentElement.nodeName === "parsererror" ) {
if ( xml && data.documentElement.tagName == "parsererror" ) {
throw "parsererror";
}
 
// Allow a pre-filtering function to sanitize the response
// s is checked to keep backwards compatibility
// s != null is checked to keep backwards compatibility
if ( s && s.dataFilter ) {
data = s.dataFilter( data, type );
}
4237,7 → 4003,7
}
 
// Get the JavaScript object, if JSON is used.
if ( type === "json" ) {
if ( type == "json" ) {
if ( typeof JSON === "object" && JSON.parse ) {
data = JSON.parse( data );
} else {
4252,15 → 4018,15
// Serialize an array of form elements or a set of
// key/values into a query string
param: function( a ) {
var s = [];
var s = [ ];
 
function add( key, value ){
s[ s.length ] = encodeURIComponent(key) + '=' + encodeURIComponent(value);
}
};
 
// If an array was passed in, assume that it is an array
// of form elements
if ( jQuery.isArray(a) || a.jquery ) {
if ( jQuery.isArray(a) || a.jquery )
// Serialize the form elements
jQuery.each( a, function(){
add( this.name, this.value );
4267,22 → 4033,19
});
 
// Otherwise, assume that it's an object of key/value pairs
} else {
else
// Serialize the key/values
for ( var j in a ) {
for ( var j in a )
// If the value is an array then the key names need to be repeated
if ( jQuery.isArray(a[j]) ) {
if ( jQuery.isArray(a[j]) )
jQuery.each( a[j], function(){
add( j, this );
});
} else {
else
add( j, jQuery.isFunction(a[j]) ? a[j]() : a[j] );
}
}
}
 
// Return the resulting serialization
return s.join("&").replace(r20, "+");
return s.join("&").replace(/%20/g, "+");
}
 
});
4316,12 → 4079,12
this[i].style.display = old || "";
 
if ( jQuery.css(this[i], "display") === "none" ) {
var nodeName = this[i].nodeName, display;
var tagName = this[i].tagName, display;
 
if ( elemdisplay[ nodeName ] ) {
display = elemdisplay[ nodeName ];
if ( elemdisplay[ tagName ] ) {
display = elemdisplay[ tagName ];
} else {
var elem = jQuery("<" + nodeName + " />").appendTo("body");
var elem = jQuery("<" + tagName + " />").appendTo("body");
 
display = elem.css("display");
if ( display === "none" )
4329,7 → 4092,7
 
elem.remove();
 
elemdisplay[ nodeName ] = display;
elemdisplay[ tagName ] = display;
}
 
jQuery.data(this[i], "olddisplay", display);
4397,14 → 4160,6
self = this;
 
for ( p in prop ) {
var name = p.replace(rdashAlpha, fcamelCase);
 
if ( p !== name ) {
prop[ name ] = prop[ p ];
delete prop[ p ];
p = name;
}
 
if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden )
return opt.complete.call(this);
 
4428,7 → 4183,7
if ( /toggle|show|hide/.test(val) )
e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop );
else {
var parts = /^([+-]=)?([\d+-.]+)(.*)$/.exec(val),
var parts = val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),
start = e.cur(true) || 0;
 
if ( parts ) {
4708,14 → 4463,11
}
}
});
if ( "getBoundingClientRect" in document.documentElement ) {
if ( "getBoundingClientRect" in document.documentElement )
jQuery.fn.offset = function() {
var elem = this[0];
if ( !elem || !elem.ownerDocument ) { return null; }
if ( elem === elem.ownerDocument.body ) {
return jQuery.offset.bodyOffset( elem );
}
 
if ( !elem || !elem.ownerDocument ) return null;
if ( elem === elem.ownerDocument.body ) return jQuery.offset.bodyOffset( elem );
var box = elem.getBoundingClientRect(), doc = elem.ownerDocument, body = doc.body, docElem = doc.documentElement,
clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0,
top = box.top + (self.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop,
4722,14 → 4474,11
left = box.left + (self.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft;
return { top: top, left: left };
};
} else {
else
jQuery.fn.offset = function() {
var elem = this[0];
if ( !elem || !elem.ownerDocument ) { return null; }
if ( elem === elem.ownerDocument.body ) {
return jQuery.offset.bodyOffset( elem );
}
 
if ( !elem || !elem.ownerDocument ) return null;
if ( elem === elem.ownerDocument.body ) return jQuery.offset.bodyOffset( elem );
jQuery.offset.initialize();
 
var offsetParent = elem.offsetParent, prevOffsetParent = elem,
4739,45 → 4488,32
top = elem.offsetTop, left = elem.offsetLeft;
 
while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) { break; }
 
if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) break;
computedStyle = defaultView.getComputedStyle(elem, null);
top -= elem.scrollTop;
left -= elem.scrollLeft;
 
top -= elem.scrollTop, left -= elem.scrollLeft;
if ( elem === offsetParent ) {
top += elem.offsetTop;
left += elem.offsetLeft;
 
if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.nodeName)) ) {
top += parseFloat( computedStyle.borderTopWidth ) || 0;
top += elem.offsetTop, left += elem.offsetLeft;
if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.tagName)) )
top += parseFloat( computedStyle.borderTopWidth ) || 0,
left += parseFloat( computedStyle.borderLeftWidth ) || 0;
}
 
prevOffsetParent = offsetParent, offsetParent = elem.offsetParent;
}
 
if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
top += parseFloat( computedStyle.borderTopWidth ) || 0;
if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" )
top += parseFloat( computedStyle.borderTopWidth ) || 0,
left += parseFloat( computedStyle.borderLeftWidth ) || 0;
}
 
prevComputedStyle = computedStyle;
}
 
if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {
top += body.offsetTop;
if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" )
top += body.offsetTop,
left += body.offsetLeft;
}
 
if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
top += Math.max( docElem.scrollTop, body.scrollTop );
if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" )
top += Math.max( docElem.scrollTop, body.scrollTop ),
left += Math.max( docElem.scrollLeft, body.scrollLeft );
}
 
return { top: top, left: left };
};
}
 
jQuery.offset = {
initialize: function() {
4788,17 → 4524,14
 
container.innerHTML = html;
body.insertBefore( container, body.firstChild );
innerDiv = container.firstChild;
checkDiv = innerDiv.firstChild;
td = innerDiv.nextSibling.firstChild.firstChild;
innerDiv = container.firstChild, checkDiv = innerDiv.firstChild, td = innerDiv.nextSibling.firstChild.firstChild;
 
this.doesNotAddBorder = (checkDiv.offsetTop !== 5);
this.doesAddBorderForTableAndCells = (td.offsetTop === 5);
 
checkDiv.style.position = 'fixed', checkDiv.style.top = '20px';
// safari subtracts parent border width here which is 5px
this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15);
checkDiv.style.position = checkDiv.style.top = '';
this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15); // safari subtracts parent border width here which is 5px
checkDiv.style.position = '', checkDiv.style.top = '';
 
innerDiv.style.overflow = 'hidden', innerDiv.style.position = 'relative';
this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5);
4806,20 → 4539,17
this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop);
 
body.removeChild( container );
jQuery.offset.initialize = function(){};
body = container = innerDiv = checkDiv = table = td = null;
jQuery.offset.initialize = function(){};
},
 
bodyOffset: function(body) {
jQuery.offset.initialize();
var top = body.offsetTop, left = body.offsetLeft;
 
jQuery.offset.initialize();
 
if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) {
top += parseFloat( jQuery.curCSS(body, 'marginTop', true) ) || 0;
if ( jQuery.offset.doesNotIncludeMarginInBodyOffset )
top += parseFloat( jQuery.curCSS(body, 'marginTop', true) ) || 0,
left += parseFloat( jQuery.curCSS(body, 'marginLeft', true) ) || 0;
}
 
return { top: top, left: left };
}
};
4827,7 → 4557,7
 
jQuery.fn.extend({
position: function() {
if ( !this[0] ) { return null; }
if ( !this[0] ) return null;
 
var elem = this[0],
 
4836,7 → 4566,7
 
// Get correct offsets
offset = this.offset(),
parentOffset = /^body|html$/i.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
parentOffset = /^body|html$/i.test(offsetParent[0].tagName) ? { top: 0, left: 0 } : offsetParent.offset();
 
// Subtract element margins
// note: when an element has margin: auto the offsetLeft and marginLeft
4856,13 → 4586,10
},
 
offsetParent: function() {
return this.map(function(){
var offsetParent = this.offsetParent || document.body;
while ( offsetParent && (!/^body|html$/i.test(offsetParent.nodeName) && jQuery.css(offsetParent, 'position') === 'static') ) {
offsetParent = offsetParent.offsetParent;
}
return offsetParent;
});
var offsetParent = this[0].offsetParent || document.body;
while ( offsetParent && (!/^body|html$/i.test(offsetParent.tagName) && jQuery.css(offsetParent, 'position') === 'static') )
offsetParent = offsetParent.offsetParent;
return jQuery( offsetParent );
}
});
 
4872,15 → 4599,20
var method = 'scroll' + name;
 
jQuery.fn[ method ] = function(val) {
var elem = this[0], win;
if ( !this[0] ) return null;
if ( !elem ) { return null; }
var elem = this[0], win = ("scrollTo" in elem && elem.document) ? elem :
(elem.nodeName === "#document") ? elem.defaultView || elem.parentWindow :
false;
 
if ( val !== undefined ) {
return val !== undefined ?
 
// Set the scroll offset
return this.each(function() {
win = getWindow( this );
 
this.each(function() {
win = ("scrollTo" in this && this.document) ? this :
(this.nodeName === "#document") ? this.defaultView || this.parentWindow :
false;
win ?
win.scrollTo(
!i ? val : jQuery(win).scrollLeft(),
4887,26 → 4619,16
i ? val : jQuery(win).scrollTop()
) :
this[ method ] = val;
});
} else {
win = getWindow( elem );
}) :
 
// Return the scroll offset
return win ? ('pageXOffset' in win) ? win[ i ? 'pageYOffset' : 'pageXOffset' ] :
jQuery.support.boxModel && win.document.documentElement[ method ] ||
win ?
win[ i ? 'pageYOffset' : 'pageXOffset' ] ||
jQuery.support.boxModel && win.document.documentElement[ method ] ||
win.document.body[ method ] :
elem[ method ];
}
};
});
 
function getWindow( elem ) {
return ("scrollTo" in elem && elem.document) ?
elem :
elem.nodeType === 9 ?
elem.defaultView || elem.parentWindow :
false;
}
// Create innerHeight, innerWidth, outerHeight and outerWidth methods
jQuery.each([ "Height", "Width" ], function(i, name){
 
4936,7 → 4658,7
elem.document.body[ "client" + name ] :
 
// Get document width or height
(elem.nodeType === 9) ? // is it a document
(elem.nodeName === "#document") ? // is it a document
// Either scroll[Width/Height] or offset[Width/Height], whichever is greater
Math.max(
elem.documentElement["client" + name],