6,21 → 6,29 |
* Dual licensed under the MIT and GPL licenses. |
* http://docs.jquery.com/License |
* |
* Date: 2009-03-28 00:20:57 +0600 (Сбт, 28 Мар 2009) |
* Revision: 6301 |
* Date: 2009-04-01 00:35:20 +0700 (Срд, 01 Апр 2009) |
* Revision: 6303 |
*/ |
(function(){ |
|
var |
// Will speed up references to window, and allows munging its name. |
window = this, |
var window = this, |
|
// Will speed up references to undefined, and allows munging its name. |
undefined, |
|
// Map over jQuery in case of overwrite |
_jQuery = window.jQuery, |
|
// Map over the $ in case of overwrite |
_$ = window.$, |
|
// Define a local copy of jQuery |
jQuery, |
|
// A central reference to the root jQuery(document) |
rootjQuery, |
|
jQuery = window.jQuery = window.$ = function( selector, context ) { |
// The jQuery object is actually just the init constructor 'enhanced' |
return selector === undefined ? |
31,12 → 39,27 |
// A simple way to check for HTML strings or ID strings |
// (both of which we optimize for) |
quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/, |
|
// Is it a simple selector |
isSimple = /^.[^:#\[\.,]*$/; |
isSimple = /^.[^:#\[\.,]*$/, |
|
// Keep a UserAgent string for use with jQuery.browser |
userAgent = navigator.userAgent.toLowerCase(), |
|
// Save a reference to the core toString method |
toString = Object.prototype.toString; |
|
// Define the main jQuery method |
jQuery = window.jQuery = window.$ = function( selector, context ) { |
// The jQuery object is actually just the init constructor 'enhanced' |
return new jQuery.fn.init( selector, context ); |
}; |
|
jQuery.fn = jQuery.prototype = { |
init: function( selector, context ) { |
// Handle $("") or $(null) |
var match, elem, ret; |
|
// Handle $(""), $(null), or $(undefined) |
if ( !selector ) { |
this.length = 0; |
return this; |
53,7 → 76,7 |
// Handle HTML strings |
if ( typeof selector === "string" ) { |
// Are we dealing with HTML string or an ID? |
var match = quickExpr.exec( selector ); |
match = quickExpr.exec( selector ); |
|
// Verify a match, and that no context was specified for #id |
if ( match && (match[1] || !context) ) { |
64,16 → 87,16 |
|
// HANDLE: $("#id") |
} else { |
var elem = document.getElementById( match[3] ); |
elem = document.getElementById( match[3] ); |
|
// Handle the case where IE and Opera return items |
// by name instead of ID |
if ( elem && elem.id != match[3] ) { |
if ( elem && elem.id !== match[3] ) { |
return rootjQuery.find( selector ); |
} |
|
// Otherwise, we inject the element directly into the jQuery object |
var ret = jQuery( elem || null ); |
ret = jQuery( elem || null ); |
ret.context = document; |
ret.selector = selector; |
return ret; |
120,7 → 143,7 |
// Get the Nth element in the matched element set OR |
// Get the whole matched element set as a clean array |
get: function( num ) { |
return num === undefined ? |
return num == null ? |
|
// Return a 'clean' array |
Array.prototype.slice.call( this ) : |
140,10 → 163,11 |
|
ret.context = this.context; |
|
if ( name === "find" ) |
if ( name === "find" ) { |
ret.selector = this.selector + (this.selector ? " " : "") + selector; |
else if ( name ) |
} else if ( name ) { |
ret.selector = this.selector + "." + name + "(" + selector + ")"; |
} |
|
// Return the newly-formed element set |
return ret; |
174,8 → 198,7 |
// Locate the position of the desired element |
return jQuery.inArray( |
// If it receives a jQuery object, the first element is used |
elem && elem.jquery ? elem[0] : elem |
, this ); |
elem && elem.jquery ? elem[0] : elem, this ); |
}, |
|
is: function( selector ) { |
192,28 → 215,9 |
// Give the init function the jQuery prototype for later instantiation |
jQuery.fn.init.prototype = jQuery.fn; |
|
function evalScript( i, elem ) { |
if ( elem.src ) |
jQuery.ajax({ |
url: elem.src, |
async: false, |
dataType: "script" |
}); |
|
else |
jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" ); |
|
if ( elem.parentNode ) |
elem.parentNode.removeChild( elem ); |
} |
|
function now(){ |
return +new Date; |
} |
|
jQuery.extend = jQuery.fn.extend = function() { |
// copy reference to target object |
var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options; |
var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy; |
|
// Handle a deep copy situation |
if ( typeof target === "boolean" ) { |
224,51 → 228,54 |
} |
|
// Handle case when target is a string or something (possible in deep copy) |
if ( typeof target !== "object" && !jQuery.isFunction(target) ) |
if ( typeof target !== "object" && !jQuery.isFunction(target) ) { |
target = {}; |
} |
|
// extend jQuery itself if only one argument is passed |
if ( length == i ) { |
if ( length === i ) { |
target = this; |
--i; |
} |
|
for ( ; i < length; i++ ) |
for ( ; i < length; i++ ) { |
// Only deal with non-null/undefined values |
if ( (options = arguments[ i ]) != null ) |
if ( (options = arguments[ i ]) != null ) { |
// Extend the base object |
for ( var name in options ) { |
var src = target[ name ], copy = options[ name ]; |
for ( name in options ) { |
src = target[ name ]; |
copy = options[ name ]; |
|
// Prevent never-ending loop |
if ( target === copy ) |
if ( target === copy ) { |
continue; |
} |
|
// Recurse if we're merging object values |
if ( deep && copy && typeof copy === "object" && !copy.nodeType ) |
if ( deep && copy && typeof copy === "object" && !copy.nodeType ) { |
target[ name ] = jQuery.extend( deep, |
// Never move original objects, clone them |
src || ( copy.length != null ? [ ] : { } ) |
, copy ); |
src || ( copy.length != null ? [ ] : { } ), copy ); |
|
// Don't bring in undefined values |
else if ( copy !== undefined ) |
} else if ( copy !== undefined ) { |
target[ name ] = copy; |
|
} |
} |
} |
} |
|
// Return the modified object |
return target; |
}; |
|
var toString = Object.prototype.toString; |
|
jQuery.extend({ |
noConflict: function( deep ) { |
window.$ = _$; |
|
if ( deep ) |
if ( deep ) { |
window.jQuery = _jQuery; |
} |
|
return jQuery; |
}, |
299,10 → 306,11 |
script = document.createElement("script"); |
|
script.type = "text/javascript"; |
if ( jQuery.support.scriptEval ) |
if ( jQuery.support.scriptEval ) { |
script.appendChild( document.createTextNode( data ) ); |
else |
} else { |
script.text = data; |
} |
|
// Use insertBefore instead of appendChild to circumvent an IE6 bug. |
// This arises when a base node is used (#2709). |
312,7 → 320,7 |
}, |
|
nodeName: function( elem, name ) { |
return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase(); |
return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase(); |
}, |
|
// args is for internal usage only |
321,24 → 329,32 |
|
if ( args ) { |
if ( length === undefined ) { |
for ( name in object ) |
if ( callback.apply( object[ name ], args ) === false ) |
for ( name in object ) { |
if ( callback.apply( object[ name ], args ) === false ) { |
break; |
} else |
for ( ; i < length; ) |
if ( callback.apply( object[ i++ ], args ) === false ) |
} |
} |
} else { |
for ( ; i < length; ) { |
if ( callback.apply( object[ i++ ], args ) === false ) { |
break; |
} |
} |
} |
|
// A special, fast, case for the most common use of each |
} else { |
if ( length === undefined ) { |
for ( name in object ) |
if ( callback.call( object[ name ], name, object[ name ] ) === false ) |
for ( name in object ) { |
if ( callback.call( object[ name ], name, object[ name ] ) === false ) { |
break; |
} else |
} |
} |
} else { |
for ( var value = object[0]; |
i < length && callback.call( value, i, value ) !== false; value = object[++i] ){} |
} |
} |
|
return object; |
}, |
348,26 → 364,30 |
}, |
|
makeArray: function( array ) { |
var ret = []; |
var ret = [], i; |
|
if( array != null ){ |
var i = array.length; |
i = array.length; |
|
// The window, strings (and functions) also have 'length' |
if( i == null || typeof array === "string" || jQuery.isFunction(array) || array.setInterval ) |
if ( i == null || typeof array === "string" || jQuery.isFunction(array) || array.setInterval ) { |
ret[0] = array; |
else |
while( i ) |
} else { |
while ( i ) { |
ret[--i] = array[i]; |
} |
} |
} |
|
return ret; |
}, |
|
inArray: function( elem, array ) { |
for ( var i = 0, length = array.length; i < length; i++ ) |
// Use === because on IE, window == document |
if ( array[ i ] === elem ) |
for ( var i = 0, length = array.length; i < length; i++ ) { |
if ( array[ i ] === elem ) { |
return i; |
} |
} |
|
return -1; |
}, |
376,27 → 396,31 |
// We have to loop this way because IE & Opera overwrite the length |
// expando of getElementsByTagName |
var i = 0, elem, pos = first.length; |
|
// Also, we need to make sure that the correct elements are being returned |
// (IE returns comment nodes in a '*' query) |
if ( !jQuery.support.getAll ) { |
while ( (elem = second[ i++ ]) != null ) |
if ( elem.nodeType != 8 ) |
while ( (elem = second[ i++ ]) != null ) { |
if ( elem.nodeType !== 8 ) { |
first[ pos++ ] = elem; |
} |
} |
|
} else |
while ( (elem = second[ i++ ]) != null ) |
} else { |
while ( (elem = second[ i++ ]) != null ) { |
first[ pos++ ] = elem; |
} |
} |
|
return first; |
}, |
|
unique: function( array ) { |
var ret = [], done = {}; |
var ret = [], done = {}, id; |
|
try { |
|
for ( var i = 0, length = array.length; i < length; i++ ) { |
var id = jQuery.data( array[ i ] ); |
id = jQuery.data( array[ i ] ); |
|
if ( !done[ id ] ) { |
done[ id ] = true; |
403,7 → 427,6 |
ret.push( array[ i ] ); |
} |
} |
|
} catch( e ) { |
ret = array; |
} |
416,47 → 439,67 |
|
// Go through the array, only saving the items |
// that pass the validator function |
for ( var i = 0, length = elems.length; i < length; i++ ) |
if ( !inv != !callback( elems[ i ], i ) ) |
for ( var i = 0, length = elems.length; i < length; i++ ) { |
if ( !inv !== !callback( elems[ i ], i ) ) { |
ret.push( elems[ i ] ); |
} |
} |
|
return ret; |
}, |
|
map: function( elems, callback ) { |
var ret = []; |
var ret = [], value; |
|
// Go through the array, translating each of the items to their |
// new value (or values). |
for ( var i = 0, length = elems.length; i < length; i++ ) { |
var value = callback( elems[ i ], i ); |
value = callback( elems[ i ], i ); |
|
if ( value != null ) |
if ( value != null ) { |
ret[ ret.length ] = value; |
} |
} |
|
return ret.concat.apply( [], ret ); |
} |
}); |
}, |
|
// All jQuery objects should point back to these |
var rootjQuery = jQuery(document); |
|
// Use of jQuery.browser is deprecated. |
// It's included for backwards compatibility and plugins, |
// although they should work to migrate away. |
|
var userAgent = navigator.userAgent.toLowerCase(); |
|
// Figure out what browser is being used |
jQuery.browser = { |
browser: { |
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 ), |
mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent ) |
};var expando = "jQuery" + now(), uuid = 0, windowData = {}; |
} |
}); |
|
// All jQuery objects should point back to these |
rootjQuery = jQuery(document); |
|
function evalScript( i, elem ) { |
if ( elem.src ) { |
jQuery.ajax({ |
url: elem.src, |
async: false, |
dataType: "script" |
}); |
} else { |
jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" ); |
} |
|
if ( elem.parentNode ) { |
elem.parentNode.removeChild( elem ); |
} |
} |
|
function now() { |
return (new Date).getTime(); |
} |
var expando = "jQuery" + now(), uuid = 0, windowData = {}; |
|
jQuery.extend({ |
cache: {}, |
|
4336,7 → 4379,7 |
|
jQuery.offset = { |
initialize: function() { |
var body = document.body, container = document.createElement('div'), innerDiv, checkDiv, table, td, prop, bodyMarginTop = body.style.marginTop, |
var body = document.body, container = document.createElement('div'), innerDiv, checkDiv, table, td, prop, bodyMarginTop = parseFloat(jQuery.curCSS(body, 'marginTop', true), 10) || 0, |
html = '<div style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;"><div></div></div><table style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;" cellpadding="0" cellspacing="0"><tr><td></td></tr></table>'; |
|
jQuery.extend( container.style, { position: 'absolute', top: 0, left: 0, margin: 0, border: 0, width: '1px', height: '1px', visibility: 'hidden' } ); |
4355,9 → 4398,7 |
innerDiv.style.overflow = 'hidden', innerDiv.style.position = 'relative'; |
this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5); |
|
body.style.marginTop = '1px'; |
this.doesNotIncludeMarginInBodyOffset = (body.offsetTop === 0); |
body.style.marginTop = bodyMarginTop; |
this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop); |
|
body.removeChild(container); |
jQuery.offset.initialize = function(){}; |