Хранилища Subversion ant

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

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

/trunk/js/jquery.js
6,29 → 6,21
* Dual licensed under the MIT and GPL licenses.
* http://docs.jquery.com/License
*
* Date: 2009-04-01 00:35:20 +0700 (Срд, 01 Апр 2009)
* Revision: 6303
* Date: 2009-03-28 00:20:57 +0600 (Сбт, 28 Мар 2009)
* Revision: 6301
*/
(function(){
 
// Will speed up references to window, and allows munging its name.
var window = this,
 
var
// Will speed up references to window, and allows munging its name.
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 ?
39,27 → 31,12
// 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 ) {
var match, elem, ret;
 
// Handle $(""), $(null), or $(undefined)
// Handle $("") or $(null)
if ( !selector ) {
this.length = 0;
return this;
76,7 → 53,7
// Handle HTML strings
if ( typeof selector === "string" ) {
// Are we dealing with HTML string or an ID?
match = quickExpr.exec( selector );
var match = quickExpr.exec( selector );
 
// Verify a match, and that no context was specified for #id
if ( match && (match[1] || !context) ) {
87,16 → 64,16
 
// HANDLE: $("#id")
} else {
elem = document.getElementById( match[3] );
var 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
ret = jQuery( elem || null );
var ret = jQuery( elem || null );
ret.context = document;
ret.selector = selector;
return ret;
143,7 → 120,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 == null ?
return num === undefined ?
 
// Return a 'clean' array
Array.prototype.slice.call( this ) :
163,11 → 140,10
 
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;
198,7 → 174,8
// 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 ) {
215,9 → 192,28
// 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, name, src, copy;
var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options;
 
// Handle a deep copy situation
if ( typeof target === "boolean" ) {
228,54 → 224,51
}
 
// 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 ( name in options ) {
src = target[ name ];
copy = options[ name ];
for ( var name in options ) {
var 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;
},
306,11 → 299,10
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).
320,7 → 312,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
329,31 → 321,23
 
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] ) {}
}
i < length && callback.call( value, i, value ) !== false; value = object[++i] ){}
}
 
return object;
364,19 → 348,16
},
 
makeArray: function( array ) {
var ret = [], i;
var ret = [];
 
if ( array != null ) {
i = array.length;
if( array != null ){
var 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;
383,11 → 364,10
},
 
inArray: function( elem, array ) {
for ( var i = 0, length = array.length; i < length; i++ ) {
if ( array[ i ] === elem ) {
for ( var i = 0, length = array.length; i < length; i++ )
// Use === because on IE, window == document
if ( array[ i ] === elem )
return i;
}
}
 
return -1;
},
396,31 → 376,27
// 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 = {}, id;
var ret = [], done = {};
 
try {
 
for ( var i = 0, length = array.length; i < length; i++ ) {
id = jQuery.data( array[ i ] );
var id = jQuery.data( array[ i ] );
 
if ( !done[ id ] ) {
done[ id ] = true;
427,6 → 403,7
ret.push( array[ i ] );
}
}
 
} catch( e ) {
ret = array;
}
439,66 → 416,46
 
// 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 = [], value;
var ret = [];
 
// 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++ ) {
value = callback( elems[ i ], i );
var value = callback( elems[ i ], i );
 
if ( value != null ) {
if ( value != null )
ret[ ret.length ] = value;
}
}
 
return ret.concat.apply( [], ret );
},
 
// Use of jQuery.browser is deprecated.
// It's included for backwards compatibility and plugins,
// although they should work to migrate away.
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 )
}
});
 
// All jQuery objects should point back to these
rootjQuery = jQuery(document);
var 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 || "" );
}
// Use of jQuery.browser is deprecated.
// It's included for backwards compatibility and plugins,
// although they should work to migrate away.
 
if ( elem.parentNode ) {
elem.parentNode.removeChild( elem );
}
}
var userAgent = navigator.userAgent.toLowerCase();
 
function now() {
return (new Date).getTime();
}
var expando = "jQuery" + now(), uuid = 0, windowData = {};
// Figure out what browser is being used
jQuery.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 = {};
 
jQuery.extend({
cache: {},
4379,7 → 4336,7
 
jQuery.offset = {
initialize: function() {
var body = document.body, container = document.createElement('div'), innerDiv, checkDiv, table, td, prop, bodyMarginTop = parseFloat(jQuery.curCSS(body, 'marginTop', true), 10) || 0,
var body = document.body, container = document.createElement('div'), innerDiv, checkDiv, table, td, prop, bodyMarginTop = body.style.marginTop,
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' } );
4398,7 → 4355,9
innerDiv.style.overflow = 'hidden', innerDiv.style.position = 'relative';
this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5);
 
this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop);
body.style.marginTop = '1px';
this.doesNotIncludeMarginInBodyOffset = (body.offsetTop === 0);
body.style.marginTop = bodyMarginTop;
 
body.removeChild(container);
jQuery.offset.initialize = function(){};