// Bind a function to a context, optionally partially applying any
// arguments.
// 代理方法:为fn指定上下文(即this)
// jQuery.proxy( function, context )
// jQuery.proxy( context, name )
proxy: function( fn, context ) {
// 如果context是字符串,设置上下文为fn,fn为fn[ context ]
// 即设置fn的context方法的上下文为fn(默认不是这样吗???TODO)
if ( typeof context === “string” ) {
var tmp = fn[ context ];
context = fn;
fn = tmp;
}
// Quick check to determine if target is callable, in the spec
// this throws a TypeError, but we will just return undefined.
// 快速测试fn是否是可调用的(即函数),在文档说明中,会抛出一个TypeError,
// 但是这里仅返回undefined
if ( !jQuery.isFunction( fn ) ) {
return undefined;
}
// Simulated bind
var args = slice.call( arguments, 2 ), // 从参数列表中去掉fn,context
proxy = function() {
// 设置上下文为context和参数
return fn.apply( context, args.concat( slice.call( arguments ) ) );
};
// Set the guid of unique handler to the same of original handler, so it can be removed
// 统一guid,使得proxy能够被移除
proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
return proxy;
},
// Mutifunctional method to get and set values to a collection
// The value/s can be optionally by executed if its a function
// 多功能函数,读取或设置集合的属性值;值为函数时会被执行
// fn:jQuery.fn.css, jQuery.fn.attr, jQuery.fn.prop
access: function( elems, key, value, exec, fn, pass ) {
var length = elems.length;
// Setting many attributes
// 如果有多个属性,则迭代
if ( typeof key === “object” ) {
for ( var k in key ) {
jQuery.access( elems, k, key[k], exec, fn, value );
}
return elems;
}
// Setting one attribute
// 只设置一个属性
if ( value !== undefined ) {
// Optionally, function values get executed if exec is true
exec = !pass && exec && jQuery.isFunction(value);
for ( var i = 0; i < length; i++ ) {
fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
}
return elems;
}
// Getting an attribute
// 读取属性
return length ? fn( elems[0], key ) : undefined;
},
// 获取当前时间的便捷函数
now: function() {
return (new Date()).getTime();
},
// Use of jQuery.browser is frowned upon.
// More details: http://docs.jquery.com/Utilities/jQuery.browser
// 不赞成使用jQuery.browser,推荐使用jQuery.support
// Navigator 正在使用的浏览器的信息
// Navigator.userAgent 一个只读的字符串,声明了浏览器用于HTPP请求的用户代理头的值
uaMatch: function( ua ) {
ua = ua.toLowerCase();
// 依次匹配各浏览器
var match = rwebkit.exec( ua ) ||
ropera.exec( ua ) ||










