Build: Update jscs and lint files

Ref 10fdad742a
Fixes gh-2056
This commit is contained in:
Oleg Gaidarenko 2015-09-03 02:52:01 +03:00
parent fa8a5a90e1
commit 20ddbe4f59
135 changed files with 8800 additions and 8027 deletions

11
.jscsrc
View File

@ -1,6 +1,13 @@
{
"preset": "jquery",
"excludeFiles": [ "external", "src/intro.js", "src/outro.js",
"test/node_smoke_tests/lib/ensure_iterability.js" ]
// remove after https://github.com/jscs-dev/node-jscs/issues/1685
// and https://github.com/jscs-dev/node-jscs/issues/1686
"requireCapitalizedComments": null,
"excludeFiles": [
"external", "src/intro.js", "src/outro.js",
"node_modules",
"test/node_smoke_tests/lib/ensure_iterability.js"
]
}

View File

@ -20,7 +20,7 @@ module.exports = function( grunt ) {
// But our modules can
delete srcHintOptions.onevar;
grunt.initConfig({
grunt.initConfig( {
pkg: grunt.file.readJSON( "package.json" ),
dst: readOptionalJSON( "dist/.destination.json" ),
"compare_size": {
@ -107,7 +107,12 @@ module.exports = function( grunt ) {
gruntfile: "Gruntfile.js",
// Check parts of tests that pass
test: [ "test/data/testrunner.js", "test/unit/animation.js", "test/unit/tween.js" ],
test: [
"test/data/testrunner.js",
"test/unit/animation.js",
"test/unit/tween.js",
"test/unit/wrap.js"
],
build: "build"
},
testswarm: {
@ -160,7 +165,7 @@ module.exports = function( grunt ) {
}
}
}
});
} );
// Load grunt tasks from NPM packages
require( "load-grunt-tasks" )( grunt );

View File

@ -10,7 +10,7 @@ module.exports = function( Release ) {
npmTags = Release.npmTags,
createTag = Release._createTag;
Release.define({
Release.define( {
npmPublish: true,
issueTracker: "github",
/**
@ -48,6 +48,7 @@ module.exports = function( Release ) {
* for publishing the distribution repo instead
*/
npmTags: function() {
// origRepo is not defined if dist was skipped
Release.dir.repo = Release.dir.origRepo || Release.dir.repo;
return npmTags();
@ -59,9 +60,9 @@ module.exports = function( Release ) {
dist: function( callback ) {
cdn.makeArchives( Release, function() {
dist( Release, callback );
});
} );
}
});
} );
};
module.exports.dependencies = [

View File

@ -33,13 +33,14 @@ function makeReleaseCopies( Release ) {
var version = Release.newVersion.replace( "-compat", "" );
shell.mkdir( "-p", cdnFolder );
Object.keys( releaseFiles ).forEach(function( key ) {
Object.keys( releaseFiles ).forEach( function( key ) {
var text,
builtFile = releaseFiles[ key ],
unpathedFile = key.replace( /VER/g, version ),
releaseFile = cdnFolder + "/" + unpathedFile;
if ( /\.map$/.test( releaseFile ) ) {
// Map files need to reference the new uncompressed name;
// assume that all files reside in the same directory.
// "file":"jquery.min.js","sources":["jquery.js"]
@ -51,7 +52,7 @@ function makeReleaseCopies( Release ) {
} else if ( builtFile !== releaseFile ) {
shell.cp( "-f", builtFile, releaseFile );
}
});
} );
}
function makeArchives( Release, callback ) {
@ -80,16 +81,17 @@ function makeArchives( Release, callback ) {
output.on( "error", function( err ) {
throw err;
});
} );
archiver.pipe( output );
files = files.map(function( item ) {
files = files.map( function( item ) {
return "dist" + ( rver.test( item ) ? "/cdn" : "" ) + "/" +
item.replace( rver, version );
});
} );
sum = Release.exec(
// Read jQuery files
"md5sum " + files.join( " " ).replace( rcompat, "." ),
"Error retrieving md5sum"
@ -97,11 +99,12 @@ function makeArchives( Release, callback ) {
fs.writeFileSync( "./" + md5file, sum );
files.push( md5file );
files.forEach(function( file ) {
files.forEach( function( file ) {
// For Google, read jquery.js, write jquery-compat.js
archiver.append( fs.createReadStream( file.replace( rcompat, "." ) ),
{ name: path.basename( file ) } );
});
} );
archiver.finalize();
}
@ -114,9 +117,9 @@ function makeArchives( Release, callback ) {
makeArchive( "mscdn", msFilesCDN, callback );
}
buildGoogleCDN(function() {
buildGoogleCDN( function() {
buildMicrosoftCDN( callback );
});
} );
}
module.exports = {

View File

@ -5,6 +5,7 @@ module.exports = function( Release, complete ) {
shell = require( "shelljs" ),
pkg = require( Release.dir.repo + "/package.json" ),
distRemote = Release.remote.replace( "jquery.git", "jquery-compat-dist.git" ),
// These files are included with the distribution
files = [
"src",
@ -34,7 +35,7 @@ module.exports = function( Release, complete ) {
* Generate bower file for jquery-compat-dist
*/
function generateBower() {
return JSON.stringify({
return JSON.stringify( {
name: pkg.name,
main: pkg.main,
license: "MIT",
@ -42,7 +43,7 @@ module.exports = function( Release, complete ) {
"package.json"
],
keywords: pkg.keywords
}, null, 2);
}, null, 2 );
}
/**
@ -57,14 +58,14 @@ module.exports = function( Release, complete ) {
"dist/jquery.js",
"dist/jquery.min.js",
"dist/jquery.min.map"
].forEach(function( file ) {
].forEach( function( file ) {
shell.cp( Release.dir.repo + "/" + file, distFolder );
});
} );
// Copy other files
files.forEach(function( file ) {
files.forEach( function( file ) {
shell.cp( "-r", Release.dir.repo + "/" + file, Release.dir.dist );
});
} );
// Write generated bower file
fs.writeFileSync( Release.dir.dist + "/bower.json", generateBower() );

View File

@ -8,7 +8,7 @@ var fs = require( "fs" ),
* @param {Function(string)} callback
*/
function getLatestSizzle( callback ) {
npm.load(function( err, npm ) {
npm.load( function( err, npm ) {
if ( err ) {
throw err;
}
@ -17,8 +17,8 @@ function getLatestSizzle( callback ) {
throw err;
}
callback( Object.keys( info )[ 0 ] );
});
});
} );
} );
}
/**
@ -29,11 +29,12 @@ function getLatestSizzle( callback ) {
function ensureSizzle( Release, callback ) {
console.log();
console.log( "Checking Sizzle version..." );
getLatestSizzle(function( latest ) {
getLatestSizzle( function( latest ) {
var match = rversion.exec( fs.readFileSync( sizzleLoc, "utf8" ) ),
version = match ? match[ 1 ] : "Not Found";
if ( version !== latest ) {
// colors is inherited from jquery-release
console.log(
"The Sizzle version in the src folder (" + version.red +
@ -44,7 +45,7 @@ function ensureSizzle( Release, callback ) {
console.log( "Sizzle is latest (" + latest.green + ")" );
callback();
}
});
} );
}
module.exports = ensureSizzle;

View File

@ -3,16 +3,16 @@
* jQuery Release Note Generator
*/
var http = require("http"),
var http = require( "http" ),
extract = /<a href="\/ticket\/(\d+)" title="View ticket">(.*?)<[^"]+"component">\s*(\S+)/g,
version = process.argv[2];
version = process.argv[ 2 ];
if ( !/^\d+\.\d+/.test( version ) ) {
console.error( "Invalid version number: " + version );
process.exit( 1 );
}
http.request({
http.request( {
host: "bugs.jquery.com",
port: 80,
method: "GET",
@ -23,34 +23,36 @@ http.request({
res.on( "data", function( chunk ) {
data.push( chunk );
});
} );
res.on( "end", function() {
var match, cur, cat,
file = data.join("");
file = data.join( "" );
while ( (match = extract.exec( file )) ) {
if ( "#" + match[1] !== match[2] ) {
cat = match[3];
while ( ( match = extract.exec( file ) ) ) {
if ( "#" + match[ 1 ] !== match[ 2 ] ) {
cat = match[ 3 ];
if ( !cur || cur !== cat ) {
if ( cur ) {
console.log("</ul>");
console.log( "</ul>" );
}
cur = cat;
console.log( "<h3>" + cat.charAt(0).toUpperCase() + cat.slice(1) + "</h3>" );
console.log("<ul>");
console.log(
"<h3>" + cat.charAt( 0 ).toUpperCase() + cat.slice( 1 ) + "</h3>"
);
console.log( "<ul>" );
}
console.log(
" <li><a href=\"http://bugs.jquery.com/ticket/" + match[1] + "\">#" +
match[1] + ": " + match[2] + "</a></li>"
" <li><a href=\"http://bugs.jquery.com/ticket/" + match[ 1 ] + "\">#" +
match[ 1 ] + ": " + match[ 2 ] + "</a></li>"
);
}
}
if ( cur ) {
console.log("</ul>");
console.log( "</ul>" );
}
});
}).end();
} );
} ).end();

View File

@ -16,12 +16,16 @@ module.exports = function( grunt ) {
baseUrl: "src",
name: "jquery",
out: "dist/jquery.js",
// We have multiple minify steps
optimize: "none",
// Include dependencies loaded with require
findNestedDependencies: true,
// Avoid inserting define() placeholder
skipModuleInsertion: true,
// Avoid breaking semicolons inserted by r.js
skipSemiColonInsertion: true,
wrap: {
@ -47,15 +51,17 @@ module.exports = function( grunt ) {
*/
function convert( name, path, contents ) {
var amdName;
// Convert var modules
if ( /.\/var\//.test( path ) ) {
contents = contents
.replace( /define\([\w\W]*?return/, "var " + (/var\/([\w-]+)/.exec(name)[1]) + " =" )
.replace( /define\([\w\W]*?return/, "var " + ( /var\/([\w-]+)/.exec( name )[ 1 ] ) + " =" )
.replace( rdefineEnd, "" );
// Sizzle treatment
} else if ( /^sizzle$/.test( name ) ) {
contents = "var Sizzle =\n" + contents
// Remove EXPOSE lines from Sizzle
.replace( /\/\/\s*EXPOSE[\w\W]*\/\/\s*EXPOSE/, "return Sizzle;" );
@ -63,6 +69,7 @@ module.exports = function( grunt ) {
contents = contents
.replace( /\s*return\s+[^\}]+(\}\);[^\w\}]*)$/, "$1" )
// Multiple exports
.replace( /\s*exports\.\w+\s*=\s*\w+;/g, "" );
@ -82,13 +89,15 @@ module.exports = function( grunt ) {
contents = contents
.replace( /define\(\[[^\]]*\]\)[\W\n]+$/, "" );
}
// AMD Name
if ( (amdName = grunt.option( "amd" )) != null && /^exports\/amd$/.test( name ) ) {
if (amdName) {
if ( ( amdName = grunt.option( "amd" ) ) != null && /^exports\/amd$/.test( name ) ) {
if ( amdName ) {
grunt.log.writeln( "Naming jQuery with AMD name: " + amdName );
} else {
grunt.log.writeln( "AMD name now anonymous" );
}
// Remove the comma for anonymous defines
contents = contents
.replace( /(\s*)"jquery"(\,\s*)/, amdName ? "$1\"" + amdName + "\"$2" : "" );
@ -121,7 +130,8 @@ module.exports = function( grunt ) {
excludeList = function( list, prepend ) {
if ( list ) {
prepend = prepend ? prepend + "/" : "";
list.forEach(function( module ) {
list.forEach( function( module ) {
// Exclude var modules as well
if ( module === "var" ) {
excludeList(
@ -130,20 +140,22 @@ module.exports = function( grunt ) {
return;
}
if ( prepend ) {
// Skip if this is not a js file and we're walking files in a dir
if ( !(module = /([\w-\/]+)\.js$/.exec( module )) ) {
if ( !( module = /([\w-\/]+)\.js$/.exec( module ) ) ) {
return;
}
// Prepend folder name if passed
// Remove .js extension
module = prepend + module[1];
module = prepend + module[ 1 ];
}
// Avoid infinite recursion
if ( excluded.indexOf( module ) === -1 ) {
excluder( "-" + module );
}
});
} );
}
},
/**
@ -158,16 +170,19 @@ module.exports = function( grunt ) {
module = m[ 2 ];
if ( exclude ) {
// Can't exclude sizzle on this branch
if ( module === "sizzle" ) {
grunt.log.error( "Sizzle cannot be excluded on the compat branch." );
// Can't exclude certain modules
} else if ( minimum.indexOf( module ) === -1 ) {
// Add to excluded
if ( excluded.indexOf( module ) === -1 ) {
grunt.log.writeln( flag );
excluded.push( module );
// Exclude all files in the folder of the same name
// These are the removable dependencies
// It's fine if the directory is not there
@ -177,10 +192,11 @@ module.exports = function( grunt ) {
grunt.verbose.writeln( e );
}
}
// Check removeWith list
excludeList( removeWith[ module ] );
} else {
grunt.log.error( "Module \"" + module + "\" is a minimum requirement.");
grunt.log.error( "Module \"" + module + "\" is a minimum requirement." );
}
} else {
grunt.log.writeln( flag );
@ -213,7 +229,7 @@ module.exports = function( grunt ) {
}
// Replace exports/global with a noop noConflict
if ( (index = excluded.indexOf( "exports/global" )) > -1 ) {
if ( ( index = excluded.indexOf( "exports/global" ) ) > -1 ) {
config.rawText[ "exports/global" ] = "define(['../core']," +
"function( jQuery ) {\njQuery.noConflict = function() {};\n});";
excluded.splice( index, 1 );
@ -225,9 +241,11 @@ module.exports = function( grunt ) {
// append excluded modules to version
if ( excluded.length ) {
version += " -" + excluded.join( ",-" );
// set pkg.version to version with excludes, so minified file picks it up
grunt.config.set( "pkg.version", version );
grunt.verbose.writeln( "Version changed to " + version );
// Have to use shallow or core will get excluded since it is a dependency
config.excludeShallow = excluded;
}
@ -239,8 +257,10 @@ module.exports = function( grunt ) {
*/
config.out = function( compiled ) {
compiled = compiled
// Embed Version
.replace( /@VERSION/g, version )
// Embed Date
// yyyy-mm-ddThh:mmZ
.replace( /@DATE/g, ( new Date() ).toISOString().replace( /:\d+\.\d+Z$/, "Z" ) );
@ -251,9 +271,10 @@ module.exports = function( grunt ) {
// Turn off opt-in if necessary
if ( !optIn ) {
// Overwrite the default inclusions with the explicit ones provided
config.rawText.jquery = "define([" +
(included.length ? included.join(",") : "") +
( included.length ? included.join( "," ) : "" ) +
"]);";
}
@ -264,8 +285,8 @@ module.exports = function( grunt ) {
done();
}, function( err ) {
done( err );
});
});
} );
} );
// Special "alias" task to make custom build creation less grawlix-y
// Translation example
@ -281,6 +302,6 @@ module.exports = function( grunt ) {
grunt.log.writeln( "Creating custom build...\n" );
grunt.task.run([ "build:*:*" + (modules ? ":" + modules : ""), "uglify", "dist" ]);
});
grunt.task.run( [ "build:*:*" + ( modules ? ":" + modules : "" ), "uglify", "dist" ] );
} );
};

View File

@ -21,14 +21,14 @@ module.exports = function( grunt ) {
flags = Object.keys( this.flags );
// Combine all output target paths
paths = [].concat( stored, flags ).filter(function( path ) {
paths = [].concat( stored, flags ).filter( function( path ) {
return path !== "*";
});
} );
// Ensure the dist files are pure ASCII
nonascii = false;
distpaths.forEach(function( filename ) {
distpaths.forEach( function( filename ) {
var i, c,
text = fs.readFileSync( filename, "utf8" );
@ -53,7 +53,7 @@ module.exports = function( grunt ) {
}
// Optionally copy dist files to other locations
paths.forEach(function( path ) {
paths.forEach( function( path ) {
var created;
if ( !/\/$/.test( path ) ) {
@ -63,9 +63,9 @@ module.exports = function( grunt ) {
created = path + filename.replace( "dist/", "" );
grunt.file.write( created, text );
grunt.log.writeln( "File '" + created + "' created." );
});
});
} );
} );
return !nonascii;
});
} );
};

View File

@ -23,5 +23,5 @@ module.exports = function( grunt ) {
args: [ "install", "jsdom@" + version ],
opts: { stdio: "inherit" }
}, this.async() );
});
} );
};

View File

@ -15,6 +15,6 @@ module.exports = function( grunt ) {
{ stdio: "inherit" }
).on( "close", function( code ) {
done( code === 0 );
});
});
} );
} );
};

View File

@ -3,11 +3,12 @@ var fs = require( "fs" );
module.exports = function( grunt ) {
var minLoc = Object.keys( grunt.config( "uglify.all.files" ) )[ 0 ];
grunt.registerTask( "remove_map_comment", function() {
// Remove the source map comment; it causes way too many problems.
// The map file is still generated for manual associations
// https://github.com/jquery/jquery/issues/1707
var text = fs.readFileSync( minLoc, "utf8" )
.replace( /\/\/# sourceMappingURL=\S+/, "" );
fs.writeFileSync( minLoc, text );
});
} );
};

View File

@ -14,11 +14,12 @@ module.exports = function( grunt ) {
config = grunt.file.readJSON( configFile )[ projectName ];
browserSets = browserSets || config.browserSets;
if ( browserSets[ 0 ] === "[" ) {
// We got an array, parse it
browserSets = JSON.parse( browserSets );
}
timeout = timeout || 1000 * 60 * 15;
tests = grunt.config([ this.name, "tests" ]);
tests = grunt.config( [ this.name, "tests" ] );
if ( pull ) {
jobName = "Pull <a href='https://github.com/jquery/jquery/pull/" +
@ -28,18 +29,18 @@ module.exports = function( grunt ) {
commit + "'>" + commit.substr( 0, 10 ) + "</a>";
}
tests.forEach(function( test ) {
tests.forEach( function( test ) {
runs[ test ] = config.testUrl + commit + "/test/index.html?module=" + test;
});
} );
testswarm.createClient({
testswarm.createClient( {
url: config.swarmUrl
} )
.addReporter( testswarm.reporters.cli )
.auth( {
id: config.authUsername,
token: config.authToken
})
} )
.addjob(
{
name: jobName,
@ -54,5 +55,5 @@ module.exports = function( grunt ) {
done( passed );
}
);
});
} );
};

View File

@ -35,7 +35,7 @@
"grunt-contrib-uglify": "0.7.0",
"grunt-contrib-watch": "0.6.1",
"grunt-git-authors": "2.0.1",
"grunt-jscs-checker": "0.8.1",
"grunt-jscs": "2.1.0",
"grunt-jsonlint": "1.0.4",
"grunt-npmcopy": "0.1.0",
"gzip-js": "0.3.2",

View File

@ -1,4 +1,4 @@
define([
define( [
"./core",
"./var/document",
"./var/rnotwhite",
@ -15,6 +15,7 @@ var
rhash = /#.*$/,
rts = /([?&])_=[^&]*/,
rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
// #7653, #8125, #8152: local protocol detection
rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
rnoContent = /^(?:GET|HEAD)$/,
@ -62,16 +63,18 @@ function addToPrefiltersOrTransports( structure ) {
dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
if ( jQuery.isFunction( func ) ) {
// For each dataType in the dataTypeExpression
while ( (dataType = dataTypes[i++]) ) {
while ( ( dataType = dataTypes[ i++ ] ) ) {
// Prepend if requested
if ( dataType[ 0 ] === "+" ) {
dataType = dataType.slice( 1 ) || "*";
(structure[ dataType ] = structure[ dataType ] || []).unshift( func );
( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
// Otherwise append
} else {
(structure[ dataType ] = structure[ dataType ] || []).push( func );
( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
}
}
}
@ -98,7 +101,7 @@ function inspectPrefiltersOrTransports( structure, options, originalOptions, jqX
} else if ( seekingTransport ) {
return !( selected = dataTypeOrTransport );
}
});
} );
return selected;
}
@ -114,7 +117,7 @@ function ajaxExtend( target, src ) {
for ( key in src ) {
if ( src[ key ] !== undefined ) {
( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
}
}
if ( deep ) {
@ -137,7 +140,7 @@ function ajaxHandleResponses( s, jqXHR, responses ) {
while ( dataTypes[ 0 ] === "*" ) {
dataTypes.shift();
if ( ct === undefined ) {
ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
}
}
@ -155,9 +158,10 @@ function ajaxHandleResponses( s, jqXHR, responses ) {
if ( dataTypes[ 0 ] in responses ) {
finalDataType = dataTypes[ 0 ];
} else {
// Try convertible dataTypes
for ( type in responses ) {
if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
finalDataType = type;
break;
}
@ -165,6 +169,7 @@ function ajaxHandleResponses( s, jqXHR, responses ) {
firstDataType = type;
}
}
// Or just use first one
finalDataType = finalDataType || firstDataType;
}
@ -186,6 +191,7 @@ function ajaxHandleResponses( s, jqXHR, responses ) {
function ajaxConvert( s, response, jqXHR, isSuccess ) {
var conv2, current, conv, tmp, prev,
converters = {},
// Work with a copy of dataTypes in case we need to modify it for conversion
dataTypes = s.dataTypes.slice();
@ -238,6 +244,7 @@ function ajaxConvert( s, response, jqXHR, isSuccess ) {
conv = converters[ prev + " " + tmp[ 0 ] ] ||
converters[ "* " + tmp[ 0 ] ];
if ( conv ) {
// Condense equivalence converters
if ( conv === true ) {
conv = converters[ conv2 ];
@ -257,7 +264,7 @@ function ajaxConvert( s, response, jqXHR, isSuccess ) {
if ( conv !== true ) {
// Unless errors are allowed to bubble, catch and return them
if ( conv && s[ "throws" ] ) {
if ( conv && s[ "throws" ] ) { // jscs:ignore requireDotNotation
response = conv( response );
} else {
try {
@ -277,7 +284,7 @@ function ajaxConvert( s, response, jqXHR, isSuccess ) {
return { state: "success", data: response };
}
jQuery.extend({
jQuery.extend( {
// Counter for holding the number of active queries
active: 0,
@ -382,43 +389,59 @@ jQuery.extend({
options = options || {};
var
// Loop variable
i,
// URL without anti-cache param
cacheURL,
// Response headers as string
responseHeadersString,
// timeout handle
timeoutTimer,
// Url cleanup var
urlAnchor,
// To know if global events are to be dispatched
fireGlobals,
transport,
// Response headers
responseHeaders,
// Create the final options object
s = jQuery.ajaxSetup( {}, options ),
// Callbacks context
callbackContext = s.context || s,
// Context for global events is callbackContext if it is a DOM node or jQuery collection
globalEventContext = s.context &&
( callbackContext.nodeType || callbackContext.jquery ) ?
jQuery( callbackContext ) :
jQuery.event,
// Deferreds
deferred = jQuery.Deferred(),
completeDeferred = jQuery.Callbacks("once memory"),
completeDeferred = jQuery.Callbacks( "once memory" ),
// Status-dependent callbacks
statusCode = s.statusCode || {},
// Headers (they are sent all at once)
requestHeaders = {},
requestHeadersNames = {},
// The jqXHR state
state = 0,
// Default abort message
strAbort = "canceled",
// Fake xhr
jqXHR = {
readyState: 0,
@ -429,8 +452,8 @@ jQuery.extend({
if ( state === 2 ) {
if ( !responseHeaders ) {
responseHeaders = {};
while ( (match = rheaders.exec( responseHeadersString )) ) {
responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
responseHeaders[ match[ 1 ].toLowerCase() ] = match[ 2 ];
}
}
match = responseHeaders[ key.toLowerCase() ];
@ -467,10 +490,12 @@ jQuery.extend({
if ( map ) {
if ( state < 2 ) {
for ( code in map ) {
// Lazy-add the new callback in a way that preserves old ones
statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
}
} else {
// Execute the appropriate callbacks
jqXHR.always( map[ jqXHR.status ] );
}
@ -513,12 +538,14 @@ jQuery.extend({
// IE throws exception if url is malformed, e.g. http://example.com:80x/
try {
urlAnchor.href = s.url;
// Support: IE8-11+
// Anchor's host property isn't correctly set when s.url is relative
urlAnchor.href = urlAnchor.href;
s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
urlAnchor.protocol + "//" + urlAnchor.host;
} catch ( e ) {
// If there is an error parsing the URL, assume it is crossDomain,
// it can be rejected by the transport if it is invalid
s.crossDomain = true;
@ -544,7 +571,7 @@ jQuery.extend({
// Watch for a new set of requests
if ( fireGlobals && jQuery.active++ === 0 ) {
jQuery.event.trigger("ajaxStart");
jQuery.event.trigger( "ajaxStart" );
}
// Uppercase the type
@ -563,6 +590,7 @@ jQuery.extend({
// If data is available, append data to url
if ( s.data ) {
cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
// #9682: remove data so that it's not used in an eventual retry
delete s.data;
}
@ -597,8 +625,8 @@ jQuery.extend({
// Set the Accepts header for the server, depending on the dataType
jqXHR.setRequestHeader(
"Accept",
s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
s.accepts[ s.dataTypes[0] ] +
s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
s.accepts[ s.dataTypes[ 0 ] ] +
( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
s.accepts[ "*" ]
);
@ -645,8 +673,8 @@ jQuery.extend({
// Timeout
if ( s.async && s.timeout > 0 ) {
timeoutTimer = window.setTimeout(function() {
jqXHR.abort("timeout");
timeoutTimer = window.setTimeout( function() {
jqXHR.abort( "timeout" );
}, s.timeout );
}
@ -654,9 +682,11 @@ jQuery.extend({
state = 1;
transport.send( requestHeaders, done );
} catch ( e ) {
// Propagate exception as error if not done
if ( state < 2 ) {
done( -1, e );
// Simply rethrow otherwise
} else {
throw e;
@ -708,11 +738,11 @@ jQuery.extend({
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
if ( s.ifModified ) {
modified = jqXHR.getResponseHeader("Last-Modified");
modified = jqXHR.getResponseHeader( "Last-Modified" );
if ( modified ) {
jQuery.lastModified[ cacheURL ] = modified;
}
modified = jqXHR.getResponseHeader("etag");
modified = jqXHR.getResponseHeader( "etag" );
if ( modified ) {
jQuery.etag[ cacheURL ] = modified;
}
@ -734,6 +764,7 @@ jQuery.extend({
isSuccess = !error;
}
} else {
// We extract error from statusText
// then normalize statusText and status for non-aborts
error = statusText;
@ -770,9 +801,10 @@ jQuery.extend({
if ( fireGlobals ) {
globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
// Handle the global AJAX counter
if ( !( --jQuery.active ) ) {
jQuery.event.trigger("ajaxStop");
jQuery.event.trigger( "ajaxStop" );
}
}
}
@ -787,10 +819,11 @@ jQuery.extend({
getScript: function( url, callback ) {
return jQuery.get( url, undefined, callback, "script" );
}
});
} );
jQuery.each( [ "get", "post" ], function( i, method ) {
jQuery[ method ] = function( url, data, callback, type ) {
// shift arguments if data argument was omitted
if ( jQuery.isFunction( data ) ) {
type = type || callback;
@ -799,7 +832,7 @@ jQuery.each( [ "get", "post" ], function( i, method ) {
}
// The url can be an options object (which then must have .url)
return jQuery.ajax( jQuery.extend({
return jQuery.ajax( jQuery.extend( {
url: url,
type: method,
dataType: type,
@ -807,7 +840,7 @@ jQuery.each( [ "get", "post" ], function( i, method ) {
success: callback
}, jQuery.isPlainObject( url ) && url ) );
};
});
} );
return jQuery;
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"../core",
"./var/nonce",
"./var/rquery",
@ -9,14 +9,14 @@ var oldCallbacks = [],
rjsonp = /(=)\?(?=&|$)|\?\?/;
// Default jsonp settings
jQuery.ajaxSetup({
jQuery.ajaxSetup( {
jsonp: "callback",
jsonpCallback: function() {
var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
this[ callback ] = true;
return callback;
}
});
} );
// Detect, normalize options and install callbacks for jsonp requests
jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
@ -26,7 +26,7 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
"url" :
typeof s.data === "string" &&
( s.contentType || "" )
.indexOf("application/x-www-form-urlencoded") === 0 &&
.indexOf( "application/x-www-form-urlencoded" ) === 0 &&
rjsonp.test( s.data ) && "data"
);
@ -46,7 +46,7 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
}
// Use data converter to retrieve json after script execution
s.converters["script json"] = function() {
s.converters[ "script json" ] = function() {
if ( !responseContainer ) {
jQuery.error( callbackName + " was not called" );
}
@ -63,7 +63,8 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
};
// Clean-up function (fires after converters)
jqXHR.always(function() {
jqXHR.always( function() {
// If previous value didn't exist - remove it
if ( overwritten === undefined ) {
jQuery( window ).removeProp( callbackName );
@ -75,6 +76,7 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
// Save back as free
if ( s[ callbackName ] ) {
// make sure that re-using the options doesn't screw things around
s.jsonpCallback = originalSettings.jsonpCallback;
@ -88,11 +90,11 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
}
responseContainer = overwritten = undefined;
});
} );
// Delegate to script
return "script";
}
});
} );
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"../core",
"../core/parseHTML",
"../ajax",
@ -13,7 +13,7 @@ define([
jQuery.fn.load = function( url, params, callback ) {
var selector, response, type,
self = this,
off = url.indexOf(" ");
off = url.indexOf( " " );
if ( off > -1 ) {
selector = jQuery.trim( url.slice( off, url.length ) );
@ -34,7 +34,7 @@ jQuery.fn.load = function( url, params, callback ) {
// If we have elements to modify, make the request
if ( self.length > 0 ) {
jQuery.ajax({
jQuery.ajax( {
url: url,
// If "type" variable is undefined, then "GET" method will be used.
@ -43,7 +43,7 @@ jQuery.fn.load = function( url, params, callback ) {
type: type || "GET",
dataType: "html",
data: params
}).done(function( responseText ) {
} ).done( function( responseText ) {
// Save response for use in complete callback
response = arguments;
@ -52,7 +52,7 @@ jQuery.fn.load = function( url, params, callback ) {
// If a selector was specified, locate the right elements in a dummy div
// Exclude scripts to avoid IE 'Permission Denied' errors
jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
// Otherwise use the full result
responseText );
@ -60,14 +60,14 @@ jQuery.fn.load = function( url, params, callback ) {
// If the request succeeds, this function gets "data", "status", "jqXHR"
// but they are ignored because response was set above.
// If it fails, this function gets "jqXHR", "status", "error"
}).always( callback && function( jqXHR, status ) {
} ).always( callback && function( jqXHR, status ) {
self.each( function() {
callback.apply( self, response || [ jqXHR.responseText, status, jqXHR ] );
});
});
} );
} );
}
return this;
};
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"../core"
], function( jQuery ) {
@ -10,4 +10,4 @@ jQuery.parseJSON = function( data ) {
return jQuery.parseJSON;
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"../core"
], function( jQuery ) {
@ -28,4 +28,4 @@ jQuery.parseXML = function( data ) {
return jQuery.parseXML;
});
} );

View File

@ -1,11 +1,11 @@
define([
define( [
"../core",
"../var/document",
"../ajax"
], function( jQuery, document ) {
// Install script dataType
jQuery.ajaxSetup({
jQuery.ajaxSetup( {
accepts: {
script: "text/javascript, application/javascript, " +
"application/ecmascript, application/x-ecmascript"
@ -19,7 +19,7 @@ jQuery.ajaxSetup({
return text;
}
}
});
} );
// Handle cache's special case and global
jQuery.ajaxPrefilter( "script", function( s ) {
@ -30,22 +30,22 @@ jQuery.ajaxPrefilter( "script", function( s ) {
s.type = "GET";
s.global = false;
}
});
} );
// Bind script tag hack transport
jQuery.ajaxTransport( "script", function(s) {
jQuery.ajaxTransport( "script", function( s ) {
// This transport only deals with cross domain requests
if ( s.crossDomain ) {
var script,
head = document.head || jQuery("head")[0] || document.documentElement;
head = document.head || jQuery( "head" )[ 0 ] || document.documentElement;
return {
send: function( _, callback ) {
script = document.createElement("script");
script = document.createElement( "script" );
if ( s.scriptCharset ) {
script.charset = s.scriptCharset;
@ -87,6 +87,6 @@ jQuery.ajaxTransport( "script", function(s) {
}
};
}
});
} );
});
} );

View File

@ -1,3 +1,3 @@
define(function() {
define( function() {
return window.location;
});
} );

View File

@ -1,5 +1,5 @@
define([
define( [
"../../core"
], function( jQuery ) {
return jQuery.now();
});
} );

View File

@ -1,3 +1,3 @@
define(function() {
return (/\?/);
});
define( function() {
return ( /\?/ );
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"../core",
"../var/document",
"../var/support",
@ -8,6 +8,7 @@ define([
// Create the request object
// (This is still attached to ajaxSettings for backward compatibility)
jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ?
// Support: IE8
function() {
@ -35,6 +36,7 @@ jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ?
return /^(get|post|head|put|delete|options)$/i.test( this.type ) &&
createStandardXHR() || createActiveXHR();
} :
// For all other browsers, use the standard XMLHttpRequest object
createStandardXHR;
@ -47,7 +49,8 @@ xhrSupported = support.ajax = !!xhrSupported;
// Create transport if the browser can provide an xhr
if ( xhrSupported ) {
jQuery.ajaxTransport(function( options ) {
jQuery.ajaxTransport( function( options ) {
// Cross domain only allowed if supported through XMLHttpRequest
if ( !options.crossDomain || support.cors ) {
@ -84,12 +87,13 @@ if ( xhrSupported ) {
// akin to a jigsaw puzzle, we simply never set it to be sure.
// (it can always be set on a per-request basis or even using ajaxSetup)
// For same-domain requests, won't change header if already provided.
if ( !options.crossDomain && !headers["X-Requested-With"] ) {
headers["X-Requested-With"] = "XMLHttpRequest";
if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
headers[ "X-Requested-With" ] = "XMLHttpRequest";
}
// Set headers
for ( i in headers ) {
// Support: IE<9
// IE's ActiveXObject throws a 'Type Mismatch' exception when setting
// request header to a null-value.
@ -112,6 +116,7 @@ if ( xhrSupported ) {
// Was never called and is aborted or complete
if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
// Clean up
callback = undefined;
xhr.onreadystatechange = jQuery.noop;
@ -137,6 +142,7 @@ if ( xhrSupported ) {
try {
statusText = xhr.statusText;
} catch ( e ) {
// We normalize with Webkit giving an empty statusText
statusText = "";
}
@ -148,6 +154,7 @@ if ( xhrSupported ) {
// can do given current implementations)
if ( !status && options.isLocal && !options.crossDomain ) {
status = responses.text ? 200 : 404;
// IE - #1450: sometimes returns 1223 when it should be 204
} else if ( status === 1223 ) {
status = 204;
@ -162,9 +169,11 @@ if ( xhrSupported ) {
};
if ( !options.async ) {
// if we're in sync mode we fire the callback
callback();
} else {
// Add to the list of active xhr callbacks
xhr.onreadystatechange = callback;
}
@ -177,7 +186,7 @@ if ( xhrSupported ) {
}
};
}
});
} );
}
// Functions to create xhrs
@ -193,4 +202,4 @@ function createActiveXHR() {
} catch ( e ) {}
}
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"./core",
"./attributes/val",
"./attributes/attr",
@ -8,4 +8,4 @@ define([
// Return jQuery for attributes-only inclusion
return jQuery;
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"../core",
"../core/access",
"./support",
@ -12,7 +12,7 @@ var boolHook,
ruseDefault = /^(?:checked|selected)$/i,
getSetInput = support.input;
jQuery.fn.extend({
jQuery.fn.extend( {
attr: function( name, value ) {
return access( this, jQuery.attr, name, value, arguments.length > 1 );
},
@ -20,11 +20,11 @@ jQuery.fn.extend({
removeAttr: function( name ) {
return this.each( function() {
jQuery.removeAttr( this, name );
});
} );
}
});
} );
jQuery.extend({
jQuery.extend( {
attr: function( elem, name, value ) {
var ret, hooks,
nType = elem.nodeType;
@ -97,7 +97,7 @@ jQuery.extend({
attrNames = value && value.match( rnotwhite );
if ( attrNames && elem.nodeType === 1 ) {
while ( ( name = attrNames[i++] ) ) {
while ( ( name = attrNames[ i++ ] ) ) {
propName = jQuery.propFix[ name ] || name;
// Boolean attributes get special treatment (#10870)
@ -119,7 +119,7 @@ jQuery.extend({
}
}
}
});
} );
// Hooks for boolean attributes
boolHook = {
@ -168,7 +168,7 @@ jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name )
}
};
}
});
} );
// fix oldIE attroperties
if ( !getSetInput ) {
@ -198,4 +198,4 @@ if ( !support.style ) {
};
}
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"../core",
"../var/rnotwhite",
"../core/init"
@ -10,7 +10,7 @@ function getClass( elem ) {
return elem.getAttribute && elem.getAttribute( "class" ) || "";
}
jQuery.fn.extend({
jQuery.fn.extend( {
addClass: function( value ) {
var classes, elem, cur, curValue, clazz, j, finalValue,
i = 0,
@ -18,12 +18,13 @@ jQuery.fn.extend({
proceed = typeof value === "string" && value;
if ( jQuery.isFunction( value ) ) {
return this.each(function( j ) {
return this.each( function( j ) {
jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
});
} );
}
if ( proceed ) {
// The disjunction here is for better compressibility (see removeClass)
classes = ( value || "" ).match( rnotwhite ) || [];
@ -35,7 +36,7 @@ jQuery.fn.extend({
if ( cur ) {
j = 0;
while ( (clazz = classes[j++]) ) {
while ( ( clazz = classes[ j++ ] ) ) {
if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
cur += clazz + " ";
}
@ -60,9 +61,9 @@ jQuery.fn.extend({
proceed = arguments.length === 0 || typeof value === "string" && value;
if ( jQuery.isFunction( value ) ) {
return this.each(function( j ) {
return this.each( function( j ) {
jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
});
} );
}
if ( proceed ) {
classes = ( value || "" ).match( rnotwhite ) || [];
@ -77,7 +78,8 @@ jQuery.fn.extend({
if ( cur ) {
j = 0;
while ( (clazz = classes[j++]) ) {
while ( ( clazz = classes[ j++ ] ) ) {
// Remove *all* instances
while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
cur = cur.replace( " " + clazz + " ", " " );
@ -104,15 +106,15 @@ jQuery.fn.extend({
}
if ( jQuery.isFunction( value ) ) {
return this.each(function( i ) {
return this.each( function( i ) {
jQuery( this ).toggleClass(
value.call( this, i, getClass( this ), stateVal ),
stateVal
);
});
} );
}
return this.each(function() {
return this.each( function() {
var className, i, self, classNames;
if ( type === "string" ) {
@ -153,7 +155,7 @@ jQuery.fn.extend({
);
}
}
});
} );
},
hasClass: function( selector ) {
@ -161,8 +163,8 @@ jQuery.fn.extend({
i = 0,
l = this.length;
for ( ; i < l; i++ ) {
if ( this[i].nodeType === 1 &&
( " " + getClass( this[i] ) + " " ).replace( rclass, " " )
if ( this[ i ].nodeType === 1 &&
( " " + getClass( this[ i ] ) + " " ).replace( rclass, " " )
.indexOf( className ) > -1
) {
return true;
@ -171,6 +173,6 @@ jQuery.fn.extend({
return false;
}
});
} );
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"../core",
"../core/access",
"./support",
@ -8,24 +8,25 @@ define([
var rfocusable = /^(?:input|select|textarea|button|object)$/i,
rclickable = /^(?:a|area)$/i;
jQuery.fn.extend({
jQuery.fn.extend( {
prop: function( name, value ) {
return access( this, jQuery.prop, name, value, arguments.length > 1 );
},
removeProp: function( name ) {
name = jQuery.propFix[ name ] || name;
return this.each(function() {
return this.each( function() {
// try/catch handles cases where IE balks (such as removing a property on window)
try {
this[ name ] = undefined;
delete this[ name ];
} catch ( e ) {}
});
} );
}
});
} );
jQuery.extend({
jQuery.extend( {
prop: function( elem, name, value ) {
var ret, hooks,
nType = elem.nodeType;
@ -61,6 +62,7 @@ jQuery.extend({
propHooks: {
tabIndex: {
get: function( elem ) {
// elem.tabIndex doesn't always return the
// correct value when it hasn't been explicitly set
// http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
@ -81,7 +83,7 @@ jQuery.extend({
"for": "htmlFor",
"class": "className"
}
});
} );
if ( !support.optSelected ) {
jQuery.propHooks.selected = {
@ -101,7 +103,7 @@ if ( !support.optSelected ) {
};
}
jQuery.each([
jQuery.each( [
"tabIndex",
"readOnly",
"maxLength",
@ -114,6 +116,6 @@ jQuery.each([
"contentEditable"
], function() {
jQuery.propFix[ this.toLowerCase() ] = this;
});
} );
});
} );

View File

@ -1,9 +1,9 @@
define([
define( [
"../var/document",
"../var/support"
], function( document, support ) {
(function() {
( function() {
var a,
input = document.createElement( "input" ),
div = document.createElement( "div" ),
@ -12,6 +12,7 @@ define([
// Setup
div.innerHTML = " <link/><a href='/a'>a</a>";
// Support: Windows Web Apps (WWA)
// `type` must use .setAttribute for WWA (#14901)
input.setAttribute( "type", "checkbox" );
@ -24,7 +25,7 @@ define([
// Get the style information from getAttribute
// (IE uses .cssText instead)
support.style = /top/.test( a.getAttribute("style") );
support.style = /top/.test( a.getAttribute( "style" ) );
// Check the default checkbox/radio value ("" on WebKit; "on" elsewhere)
support.checkOn = !!input.value;
@ -49,8 +50,8 @@ define([
input.value = "t";
input.setAttribute( "type", "radio" );
support.radioValue = input.value === "t";
})();
} )();
return support;
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"../core",
"./support",
"../core/init"
@ -6,25 +6,31 @@ define([
var rreturn = /\r/g;
jQuery.fn.extend({
jQuery.fn.extend( {
val: function( value ) {
var hooks, ret, isFunction,
elem = this[0];
elem = this[ 0 ];
if ( !arguments.length ) {
if ( elem ) {
hooks = jQuery.valHooks[ elem.type ] ||
jQuery.valHooks[ elem.nodeName.toLowerCase() ];
if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
if (
hooks &&
"get" in hooks &&
( ret = hooks.get( elem, "value" ) ) !== undefined
) {
return ret;
}
ret = elem.value;
return typeof ret === "string" ?
// handle most common string cases
ret.replace(rreturn, "") :
ret.replace( rreturn, "" ) :
// handle cases where value is null/undef or number
ret == null ? "" : ret;
}
@ -34,7 +40,7 @@ jQuery.fn.extend({
isFunction = jQuery.isFunction( value );
return this.each(function( i ) {
return this.each( function( i ) {
var val;
if ( this.nodeType !== 1 ) {
@ -55,23 +61,24 @@ jQuery.fn.extend({
} else if ( jQuery.isArray( val ) ) {
val = jQuery.map( val, function( value ) {
return value == null ? "" : value + "";
});
} );
}
hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
// If set returns undefined, fall back to normal setting
if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
this.value = val;
}
});
} );
}
});
} );
jQuery.extend({
jQuery.extend( {
valHooks: {
option: {
get: function( elem ) {
// Support: IE<11
// option.value not trimmed (#14858)
return jQuery.trim( elem.value );
@ -96,10 +103,11 @@ jQuery.extend({
// Support: IE<10
// IE8-9 doesn't update selected after form reset (#2551)
if ( ( option.selected || i === index ) &&
// Don't return options that are disabled or in a disabled optgroup
( support.optDisabled ?
!option.disabled :
option.getAttribute("disabled") === null ) &&
option.getAttribute( "disabled" ) === null ) &&
( !option.parentNode.disabled ||
!jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
@ -127,8 +135,10 @@ jQuery.extend({
while ( i-- ) {
option = options[ i ];
if ( (option.selected =
jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1) ) {
if (
option.selected =
jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
) {
optionSet = true;
}
}
@ -142,22 +152,22 @@ jQuery.extend({
}
}
}
});
} );
// Radios and checkboxes getter/setter
jQuery.each([ "radio", "checkbox" ], function() {
jQuery.each( [ "radio", "checkbox" ], function() {
jQuery.valHooks[ this ] = {
set: function( elem, value ) {
if ( jQuery.isArray( value ) ) {
return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) > -1 );
return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
}
}
};
if ( !support.checkOn ) {
jQuery.valHooks[ this ].get = function( elem ) {
return elem.getAttribute("value") === null ? "on" : elem.value;
return elem.getAttribute( "value" ) === null ? "on" : elem.value;
};
}
});
} );
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"./core",
"./var/rnotwhite"
], function( jQuery, rnotwhite ) {
@ -8,7 +8,7 @@ function createOptions( options ) {
var object = {};
jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
object[ flag ] = true;
});
} );
return object;
}
@ -44,18 +44,25 @@ jQuery.Callbacks = function( options ) {
var // Flag to know if list is currently firing
firing,
// Last fire value for non-forgettable lists
memory,
// Flag to know if list was already fired
fired,
// Flag to prevent firing
locked,
// Actual callback list
list = [],
// Queue of execution data for repeatable lists
queue = [],
// Index of currently firing callback (modified by add/remove as needed)
firingIndex = -1,
// Fire callbacks
fire = function() {
@ -114,18 +121,19 @@ jQuery.Callbacks = function( options ) {
queue.push( memory );
}
(function add( args ) {
( function add( args ) {
jQuery.each( args, function( _, arg ) {
if ( jQuery.isFunction( arg ) ) {
if ( !options.unique || !self.has( arg ) ) {
list.push( arg );
}
} else if ( arg && arg.length && jQuery.type( arg ) !== "string" ) {
// Inspect recursively
add( arg );
}
});
})( arguments );
} );
} )( arguments );
if ( memory && !firing ) {
fire();
@ -146,7 +154,7 @@ jQuery.Callbacks = function( options ) {
firingIndex--;
}
}
});
} );
return this;
},
@ -221,4 +229,4 @@ jQuery.Callbacks = function( options ) {
};
return jQuery;
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"./var/deletedIds",
"./var/document",
"./var/slice",
@ -17,6 +17,7 @@ var
// Define a local copy of jQuery
jQuery = function( selector, context ) {
// The jQuery object is actually just the init constructor 'enhanced'
// Need init if jQuery is called (just allow error to be thrown if not included)
return new jQuery.fn.init( selector, context );
@ -36,6 +37,7 @@ var
};
jQuery.fn = jQuery.prototype = {
// The current version of jQuery being used
jquery: version,
@ -80,9 +82,9 @@ jQuery.fn = jQuery.prototype = {
},
map: function( callback ) {
return this.pushStack( jQuery.map(this, function( elem, i ) {
return this.pushStack( jQuery.map( this, function( elem, i ) {
return callback.call( elem, i, elem );
}));
} ) );
},
slice: function() {
@ -100,11 +102,11 @@ jQuery.fn = jQuery.prototype = {
eq: function( i ) {
var len = this.length,
j = +i + ( i < 0 ? len : 0 );
return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
},
end: function() {
return this.prevObject || this.constructor(null);
return this.prevObject || this.constructor( null );
},
// For internal use only.
@ -116,7 +118,7 @@ jQuery.fn = jQuery.prototype = {
jQuery.extend = jQuery.fn.extend = function() {
var src, copyIsArray, copy, name, options, clone,
target = arguments[0] || {},
target = arguments[ 0 ] || {},
i = 1,
length = arguments.length,
deep = false;
@ -131,7 +133,7 @@ jQuery.extend = jQuery.fn.extend = function() {
}
// 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 = {};
}
@ -142,8 +144,10 @@ jQuery.extend = jQuery.fn.extend = function() {
}
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 ];
@ -155,15 +159,15 @@ jQuery.extend = jQuery.fn.extend = function() {
}
// Recurse if we're merging plain objects or arrays
if ( deep && copy && ( jQuery.isPlainObject(copy) ||
(copyIsArray = jQuery.isArray(copy)) ) ) {
if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
( copyIsArray = jQuery.isArray( copy ) ) ) ) {
if ( copyIsArray ) {
copyIsArray = false;
clone = src && jQuery.isArray(src) ? src : [];
clone = src && jQuery.isArray( src ) ? src : [];
} else {
clone = src && jQuery.isPlainObject(src) ? src : {};
clone = src && jQuery.isPlainObject( src ) ? src : {};
}
// Never move original objects, clone them
@ -181,7 +185,8 @@ jQuery.extend = jQuery.fn.extend = function() {
return target;
};
jQuery.extend({
jQuery.extend( {
// Unique for each copy of jQuery on the page
expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
@ -198,11 +203,11 @@ jQuery.extend({
// Since version 1.3, DOM methods and functions like alert
// aren't supported. They return false on IE (#2968).
isFunction: function( obj ) {
return jQuery.type(obj) === "function";
return jQuery.type( obj ) === "function";
},
isArray: Array.isArray || function( obj ) {
return jQuery.type(obj) === "array";
return jQuery.type( obj ) === "array";
},
isWindow: function( obj ) {
@ -211,11 +216,12 @@ jQuery.extend({
},
isNumeric: function( obj ) {
// parseFloat NaNs numeric-cast false positives (null|true|false|"")
// ...but misinterprets leading-number strings, particularly hex literals ("0x...")
// subtraction forces infinities to NaN
// adding 1 corrects loss of precision from parseFloat (#15100)
return !jQuery.isArray( obj ) && (obj - parseFloat( obj ) + 1) >= 0;
return !jQuery.isArray( obj ) && ( obj - parseFloat( obj ) + 1 ) >= 0;
},
isEmptyObject: function( obj ) {
@ -232,18 +238,20 @@ jQuery.extend({
// Must be an Object.
// Because of IE, we also have to check the presence of the constructor property.
// Make sure that DOM nodes and window objects don't pass through, as well
if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
if ( !obj || jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
return false;
}
try {
// Not own constructor property must be Object
if ( obj.constructor &&
!hasOwn.call(obj, "constructor") &&
!hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
!hasOwn.call( obj, "constructor" ) &&
!hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
return false;
}
} catch ( e ) {
// IE8,9 Will throw exceptions on certain host objects #9897
return false;
}
@ -268,12 +276,13 @@ jQuery.extend({
return obj + "";
}
return typeof obj === "object" || typeof obj === "function" ?
class2type[ toString.call(obj) ] || "object" :
class2type[ toString.call( obj ) ] || "object" :
typeof obj;
},
// Evaluates a script in a global context
globalEval: function( data ) {
// Inspired by code by Andrea Giammarchi
// http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
var head = document.head || jQuery( "head" )[ 0 ] || document.documentElement,
@ -353,6 +362,7 @@ jQuery.extend({
i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
for ( ; i < len; i++ ) {
// Skip accessing in sparse arrays
if ( i in arr && arr[ i ] === elem ) {
return i;
@ -375,7 +385,7 @@ jQuery.extend({
// Support: IE<9
// Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists)
if ( len !== len ) {
while ( second[j] !== undefined ) {
while ( second[ j ] !== undefined ) {
first[ i++ ] = second[ j++ ];
}
}
@ -475,7 +485,7 @@ jQuery.extend({
// jQuery.support is not used in Core but other projects attach their
// properties to it so it needs to exist.
support: support
});
} );
// JSHint would error on this code due to the Symbol not being defined in ES5.
// Defining this global in .jshintrc would create a danger of using the global
@ -488,10 +498,10 @@ if ( typeof Symbol === "function" ) {
/* jshint ignore: end */
// Populate the class2type map
jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),
function(i, name) {
jQuery.each( "Boolean Number String Function Array Date RegExp Object Error".split( " " ),
function( i, name ) {
class2type[ "[object " + name + "]" ] = name.toLowerCase();
});
} );
function isArrayLike( obj ) {
@ -511,4 +521,4 @@ function isArrayLike( obj ) {
}
return jQuery;
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"../core"
], function( jQuery ) {
@ -13,7 +13,7 @@ var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
if ( jQuery.type( key ) === "object" ) {
chainable = true;
for ( i in key ) {
access( elems, fn, i, key[i], true, emptyGet, raw );
access( elems, fn, i, key[ i ], true, emptyGet, raw );
}
// Sets one value
@ -25,6 +25,7 @@ var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
}
if ( bulk ) {
// Bulk operations run against the entire set
if ( raw ) {
fn.call( elems, value );
@ -41,7 +42,11 @@ var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
if ( fn ) {
for ( ; i < length; i++ ) {
fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
fn(
elems[ i ],
key,
raw ? value : value.call( elems[ i ], i, fn( elems[ i ], key ) )
);
}
}
}
@ -52,9 +57,9 @@ var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
// Gets
bulk ?
fn.call( elems ) :
length ? fn( elems[0], key ) : emptyGet;
length ? fn( elems[ 0 ], key ) : emptyGet;
};
return access;
});
} );

View File

@ -1,5 +1,5 @@
// Initialize a jQuery object
define([
define( [
"../core",
"../var/document",
"./var/rsingleTag",
@ -41,23 +41,24 @@ var rootjQuery,
}
// Match html or make sure no context is specified for #id
if ( match && (match[1] || !context) ) {
if ( match && ( match[ 1 ] || !context ) ) {
// HANDLE: $(html) -> $(array)
if ( match[1] ) {
context = context instanceof jQuery ? context[0] : context;
if ( match[ 1 ] ) {
context = context instanceof jQuery ? context[ 0 ] : context;
// scripts is true for back-compat
// Intentionally let the error be thrown if parseHTML is not present
jQuery.merge( this, jQuery.parseHTML(
match[1],
match[ 1 ],
context && context.nodeType ? context.ownerDocument || context : document,
true
) );
// HANDLE: $(html, props)
if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
for ( match in context ) {
// Properties of context are called as methods if possible
if ( jQuery.isFunction( this[ match ] ) ) {
this[ match ]( context[ match ] );
@ -73,11 +74,12 @@ var rootjQuery,
// HANDLE: $(#id)
} else {
elem = document.getElementById( match[2] );
elem = document.getElementById( match[ 2 ] );
if ( elem ) {
// Inject the element directly into the jQuery object
this[0] = elem;
this[ 0 ] = elem;
this.length = 1;
}
return this;
@ -95,7 +97,7 @@ var rootjQuery,
// HANDLE: $(DOMElement)
} else if ( selector.nodeType ) {
this[0] = selector;
this[ 0 ] = selector;
this.length = 1;
return this;
@ -104,6 +106,7 @@ var rootjQuery,
} else if ( jQuery.isFunction( selector ) ) {
return typeof root.ready !== "undefined" ?
root.ready( selector ) :
// Execute immediately if ready is not present
selector( jQuery );
}
@ -119,4 +122,4 @@ rootjQuery = jQuery( document );
return init;
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"../core",
"../var/document",
"./var/rsingleTag",
@ -20,6 +20,7 @@ jQuery.parseHTML = function( data, context, keepScripts ) {
keepScripts = context;
context = false;
}
// document.implementation stops scripts or inline event handlers from
// being executed immediately
context = context || ( support.createHTMLDocument ?
@ -31,7 +32,7 @@ jQuery.parseHTML = function( data, context, keepScripts ) {
// Single tag
if ( parsed ) {
return [ context.createElement( parsed[1] ) ];
return [ context.createElement( parsed[ 1 ] ) ];
}
parsed = buildFragment( [ data ], context, scripts );
@ -45,4 +46,4 @@ jQuery.parseHTML = function( data, context, keepScripts ) {
return jQuery.parseHTML;
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"../core",
"../var/document",
"../deferred"
@ -8,13 +8,15 @@ define([
var readyList;
jQuery.fn.ready = function( fn ) {
// Add the callback
jQuery.ready.promise().done( fn );
return this;
};
jQuery.extend({
jQuery.extend( {
// Is the DOM ready to be used? Set to true once it occurs.
isReady: false,
@ -50,7 +52,7 @@ jQuery.extend({
// If there are functions bound, to execute
readyList.resolveWith( document, [ jQuery ] );
}
});
} );
/**
* Clean-up method for dom ready events
@ -71,6 +73,7 @@ function detach() {
* The ready event handler and self cleanup method
*/
function completed() {
// readyState === "complete" is good enough for us to call the dom ready in oldIE
if ( document.addEventListener ||
window.event.type === "load" ||
@ -93,11 +96,13 @@ jQuery.ready.promise = function( obj ) {
// discovered by ChrisS here:
// http://bugs.jquery.com/ticket/12282#comment:15
if ( document.readyState === "complete" ) {
// Handle it asynchronously to allow scripts the opportunity to delay ready
window.setTimeout( jQuery.ready );
// Standards-based browsers support DOMContentLoaded
} else if ( document.addEventListener ) {
// Use the handy event callback
document.addEventListener( "DOMContentLoaded", completed );
@ -107,6 +112,7 @@ jQuery.ready.promise = function( obj ) {
// Support: IE<9
// If IE event model is used
} else {
// Ensure firing before onload, maybe late but safe also for iframes
document.attachEvent( "onreadystatechange", completed );
@ -120,4 +126,4 @@ jQuery.ready.promise = function( obj ) {
// Kick off the DOM ready check even if the user does not
jQuery.ready.promise();
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"../var/document",
"../var/support"
], function( document, support ) {
@ -8,14 +8,14 @@ define([
// collapse sibling forms: the second one becomes a child of the first one.
// Because of that, this security measure has to be disabled in Safari 8.
// https://bugs.webkit.org/show_bug.cgi?id=137337
support.createHTMLDocument = (function() {
support.createHTMLDocument = ( function() {
if ( !document.implementation.createHTMLDocument ) {
return false;
}
var doc = document.implementation.createHTMLDocument( "" );
doc.body.innerHTML = "<form></form><form></form>";
return doc.body.childNodes.length === 2;
})();
} )();
return support;
});
} );

View File

@ -1,4 +1,5 @@
define(function() {
define( function() {
// Match a standalone tag
return (/^<([\w-]+)\s*\/?>(?:<\/\1>|)$/);
});
return ( /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/ );
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"./core",
"./var/pnum",
"./core/access",
@ -22,6 +22,7 @@ define([
isHidden, swap, curCSS, adjustCSS, addGetHookIf, support, showHide ) {
var
// BuildExclude
getStyles = curCSS.getStyles,
ralpha = /alpha\([^)]*\)/i,
@ -69,6 +70,7 @@ function vendorPropName( name ) {
function setPositiveNumber( elem, value, subtract ) {
var matches = rnumsplit.exec( value );
return matches ?
// Guard against undefined "subtract", e.g., when used as in cssHooks
Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
value;
@ -76,20 +78,24 @@ function setPositiveNumber( elem, value, subtract ) {
function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
var i = extra === ( isBorderBox ? "border" : "content" ) ?
// If we already have the right measurement, avoid augmentation
4 :
// Otherwise initialize for horizontal or vertical properties
name === "width" ? 1 : 0,
val = 0;
for ( ; i < 4; i += 2 ) {
// both box models exclude margin, so add it if we want it
if ( extra === "margin" ) {
val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
}
if ( isBorderBox ) {
// border-box includes padding, so remove it if we want content
if ( extra === "content" ) {
val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
@ -100,6 +106,7 @@ function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
}
} else {
// at this point, extra isn't content, so add padding
val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
@ -122,6 +129,7 @@ function getWidthOrHeight( elem, name, extra ) {
isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
if ( support.gBCRDimensions() ) {
// Support: IE <= 11 only
// Running getBoundingClientRect on a disconnected node
// in IE throws an error.
@ -129,6 +137,7 @@ function getWidthOrHeight( elem, name, extra ) {
val = elem.getBoundingClientRect()[ name ];
}
} else {
// In IE8 gBCR doesn't report width & height; we need to fall back to offset*.
val = name === "width" ? elem.offsetWidth : elem.offsetHeight;
}
@ -144,6 +153,7 @@ function getWidthOrHeight( elem, name, extra ) {
// svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
// MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
if ( val <= 0 || val == null ) {
// Fall back to computed then uncomputed css if necessary
val = curCSS( elem, name, styles );
if ( val < 0 || val == null ) {
@ -151,7 +161,7 @@ function getWidthOrHeight( elem, name, extra ) {
}
// Computed unit is not pixels. Stop here and return.
if ( rnumnonpx.test(val) ) {
if ( rnumnonpx.test( val ) ) {
return val;
}
@ -176,13 +186,15 @@ function getWidthOrHeight( elem, name, extra ) {
) + "px";
}
jQuery.extend({
jQuery.extend( {
// Add in style property hooks for overriding the default
// behavior of getting and setting a style property
cssHooks: {
opacity: {
get: function( elem, computed ) {
if ( computed ) {
// We should always get a number back from opacity
var ret = curCSS( elem, "opacity" );
return ret === "" ? "1" : ret;
@ -210,12 +222,14 @@ jQuery.extend({
// Add in properties whose names you wish to fix before
// setting or getting the value
cssProps: {
// normalize float css property
"float": support.cssFloat ? "cssFloat" : "styleFloat"
},
// Get and set the style property on a DOM Node
style: function( elem, name, value, extra ) {
// Don't set styles on text and comment nodes
if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
return;
@ -238,8 +252,9 @@ jQuery.extend({
type = typeof value;
// Convert "+=" or "-=" to relative numbers (#7345)
if ( type === "string" && (ret = rcssNum.exec( value )) && ret[ 1 ] ) {
if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
value = adjustCSS( elem, name, ret );
// Fixes bug #9237
type = "number";
}
@ -257,25 +272,26 @@ jQuery.extend({
// Fixes #8908, it can be done more correctly by specifing setters in cssHooks,
// but it would mean to define eight
// (for every problematic property) identical functions
if ( !support.clearCloneStyle && value === "" && name.indexOf("background") === 0 ) {
if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
style[ name ] = "inherit";
}
// If a hook was provided, use that value, otherwise just set the specified value
if ( !hooks || !("set" in hooks) ||
(value = hooks.set( elem, value, extra )) !== undefined ) {
if ( !hooks || !( "set" in hooks ) ||
( value = hooks.set( elem, value, extra ) ) !== undefined ) {
// Support: IE<9
// Swallow errors from 'invalid' CSS values (#5509)
try {
style[ name ] = value;
} catch (e) {}
} catch ( e ) {}
}
} else {
// If a hook was provided get the non-computed value from there
if ( hooks && "get" in hooks &&
(ret = hooks.get( elem, false, extra )) !== undefined ) {
( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
return ret;
}
@ -319,15 +335,17 @@ jQuery.extend({
}
return val;
}
});
} );
jQuery.each([ "height", "width" ], function( i, name ) {
jQuery.each( [ "height", "width" ], function( i, name ) {
jQuery.cssHooks[ name ] = {
get: function( elem, computed, extra ) {
if ( computed ) {
// certain elements can have dimension info if we invisibly show them
// however, it must have a current display style that would benefit from this
return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
// Support: Safari 8+
// Table columns in Safari have non-zero offsetWidth & zero
// getBoundingClientRect().width unless display is changed.
@ -337,7 +355,7 @@ jQuery.each([ "height", "width" ], function( i, name ) {
( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
swap( elem, cssShow, function() {
return getWidthOrHeight( elem, name, extra );
}) :
} ) :
getWidthOrHeight( elem, name, extra );
}
},
@ -355,15 +373,16 @@ jQuery.each([ "height", "width" ], function( i, name ) {
);
}
};
});
} );
if ( !support.opacity ) {
jQuery.cssHooks.opacity = {
get: function( elem, computed ) {
// IE uses filters for opacity
return ropacity.test( (computed && elem.currentStyle ?
return ropacity.test( ( computed && elem.currentStyle ?
elem.currentStyle.filter :
elem.style.filter) || "" ) ?
elem.style.filter ) || "" ) ?
( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
computed ? "1" : "";
},
@ -416,7 +435,7 @@ jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
);
// These hooks are used by animate to expand properties
jQuery.each({
jQuery.each( {
margin: "",
padding: "",
border: "Width"
@ -427,7 +446,7 @@ jQuery.each({
expanded = {},
// assumes a single number if not a string
parts = typeof value === "string" ? value.split(" ") : [ value ];
parts = typeof value === "string" ? value.split( " " ) : [ value ];
for ( ; i < 4; i++ ) {
expanded[ prefix + cssExpand[ i ] + suffix ] =
@ -441,9 +460,9 @@ jQuery.each({
if ( !rmargin.test( prefix ) ) {
jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
}
});
} );
jQuery.fn.extend({
jQuery.fn.extend( {
css: function( name, value ) {
return access( this, function( elem, name, value ) {
var styles, len,
@ -477,15 +496,15 @@ jQuery.fn.extend({
return state ? this.show() : this.hide();
}
return this.each(function() {
return this.each( function() {
if ( isHidden( this ) ) {
jQuery( this ).show();
} else {
jQuery( this ).hide();
}
});
} );
}
});
} );
return jQuery;
});
} );

View File

@ -1,10 +1,12 @@
define(function() {
define( function() {
function addGetHookIf( conditionFn, hookFn ) {
// Define the hook, we'll check on the first run if it's really needed.
return {
get: function() {
if ( conditionFn() ) {
// Hook not needed (or it's not possible to use it due
// to missing dependency), remove it.
delete this.get;
@ -12,11 +14,11 @@ function addGetHookIf( conditionFn, hookFn ) {
}
// Hook needed; redefine it so that the support test is not executed again.
return (this.get = hookFn).apply( this, arguments );
return ( this.get = hookFn ).apply( this, arguments );
}
};
}
return addGetHookIf;
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"../core",
"../var/rcssNum"
], function( jQuery, rcssNum ) {
@ -12,11 +12,13 @@ function adjustCSS( elem, prop, valueParts, tween ) {
function() { return jQuery.css( elem, prop, "" ); },
initial = currentValue(),
unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
// Starting value computation is required for potential unit mismatches
initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
rcssNum.exec( jQuery.css( elem, prop ) );
if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
// Trust units reported by jQuery.css
unit = unit || initialInUnit[ 3 ];
@ -27,6 +29,7 @@ function adjustCSS( elem, prop, valueParts, tween ) {
initialInUnit = +initial || 1;
do {
// If previous iteration zeroed out, double until we get *something*.
// Use string for doubling so we don't accidentally see scale as unchanged below
scale = scale || ".5";
@ -38,12 +41,13 @@ function adjustCSS( elem, prop, valueParts, tween ) {
// Update scale, tolerating zero or NaN from tween.cur()
// Break the loop if scale is unchanged or perfect, or if we've just had enough.
} while (
scale !== (scale = currentValue() / initial) && scale !== 1 && --maxIterations
scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations
);
}
if ( valueParts ) {
initialInUnit = +initialInUnit || +initial || 0;
// Apply relative offset (+=/-=) if specified
adjusted = valueParts[ 1 ] ?
initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
@ -58,4 +62,4 @@ function adjustCSS( elem, prop, valueParts, tween ) {
}
return adjustCSS;
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"exports",
"../core",
"../var/documentElement",
@ -13,6 +13,7 @@ var getStyles, curCSS,
if ( window.getComputedStyle ) {
getStyles = function( elem ) {
// Support: IE<=11+, Firefox<=30+ (#15098, #14150)
// IE throws on elements created in popups
// FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
@ -120,4 +121,4 @@ if ( window.getComputedStyle ) {
exports.getStyles = getStyles;
exports.curCSS = curCSS;
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"../core",
"./support",
"../selector",
@ -15,4 +15,4 @@ jQuery.expr.filters.visible = function( elem ) {
( ( elem.style && elem.style.display ) || jQuery.css( elem, "display" ) ) !== "none" );
};
});
} );

View File

@ -1,4 +1,4 @@
define([], function() {
define( [], function() {
function showHide( elements, show ) {
var display, elem,
@ -16,6 +16,7 @@ function showHide( elements, show ) {
display = elem.style.display;
if ( show ) {
if ( display === "none" ) {
// Restore a pre-hide() value if we have one
values[ index ] = jQuery._data( elem, "display" ) || "";
}
@ -42,4 +43,4 @@ function showHide( elements, show ) {
return showHide;
});
} );

View File

@ -1,11 +1,11 @@
define([
define( [
"../core",
"../var/document",
"../var/documentElement",
"../var/support"
], function( jQuery, document, documentElement, support ) {
(function() {
( function() {
var pixelPositionVal, boxSizingReliableVal, gBCRDimensionsVal,
pixelMarginRightVal, reliableHiddenOffsetsVal, reliableMarginRightVal,
container = document.createElement( "div" ),
@ -36,7 +36,7 @@ define([
div.innerHTML = "";
container.appendChild( div );
jQuery.extend(support, {
jQuery.extend( support, {
reliableHiddenOffsets: function() {
if ( pixelPositionVal == null ) {
computeStyleTests();
@ -45,6 +45,7 @@ define([
},
boxSizingReliable: function() {
// We're checking for pixelPositionVal here instead of boxSizingReliableVal
// since that compresses better and they're computed together anyway.
if ( pixelPositionVal == null ) {
@ -61,6 +62,7 @@ define([
},
pixelMarginRight: function() {
// Support: Android 4.0-4.3
if ( pixelPositionVal == null ) {
computeStyleTests();
@ -76,13 +78,14 @@ define([
},
reliableMarginRight: function() {
// Support: Android 2.3
if ( pixelPositionVal == null ) {
computeStyleTests();
}
return reliableMarginRightVal;
}
});
} );
function computeStyleTests() {
var contents, divStyle,
@ -92,6 +95,7 @@ define([
documentElement.appendChild( container );
div.style.cssText =
// Support: Android 2.3
// Vendor-prefix box-sizing
"-webkit-box-sizing:border-box;box-sizing:border-box;" +
@ -124,6 +128,7 @@ define([
// Reset CSS: box-sizing; display; margin; border; padding
contents.style.cssText = div.style.cssText =
// Support: Android 2.3
// Vendor-prefix box-sizing
"-webkit-box-sizing:content-box;box-sizing:content-box;" +
@ -158,8 +163,8 @@ define([
documentElement.removeChild( container );
}
})();
} )();
return support;
});
} );

View File

@ -1,3 +1,3 @@
define(function() {
define( function() {
return [ "Top", "Right", "Bottom", "Left" ];
});
} );

View File

@ -1,14 +1,16 @@
define([
define( [
"../../core",
"../../selector"
// css is assumed
], function( jQuery ) {
return function( elem, el ) {
// isHidden might be called from jQuery#filter function;
// in that case, element will be second argument
elem = el || elem;
return jQuery.css( elem, "display" ) === "none" ||
!jQuery.contains( elem.ownerDocument, elem );
};
});
} );

View File

@ -1,3 +1,3 @@
define(function() {
return (/^margin/);
});
define( function() {
return ( /^margin/ );
} );

View File

@ -1,5 +1,5 @@
define([
define( [
"../../var/pnum"
], function( pnum ) {
return new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
});
} );

View File

@ -1,4 +1,4 @@
define(function() {
define( function() {
// A method for quickly swapping in/out CSS properties to get correct calculations.
return function( elem, options, callback, args ) {
@ -21,4 +21,4 @@ return function( elem, options, callback, args ) {
return ret;
};
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"./core",
"./var/deletedIds",
"./data/support",
@ -9,6 +9,7 @@ var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
rmultiDash = /([A-Z])/g;
function dataAttr( elem, key, data ) {
// If nothing was found internally, try to fetch any
// data from the HTML5 data-* attribute
if ( data === undefined && elem.nodeType === 1 ) {
@ -22,6 +23,7 @@ function dataAttr( elem, key, data ) {
data = data === "true" ? true :
data === "false" ? false :
data === "null" ? null :
// Only convert to a number if it doesn't change the string
+data + "" === data ? +data :
rbrace.test( data ) ? jQuery.parseJSON( data ) :
@ -78,12 +80,13 @@ function internalData( elem, key, data, pvt /* Internal Use Only */ ) {
// Avoid doing any more work than we need to when trying to get data on an
// object that has no data at all
if ( (!id || !cache[id] || (!pvt && !cache[id].data)) &&
if ( ( !id || !cache[ id ] || ( !pvt && !cache[ id ].data ) ) &&
data === undefined && typeof key === "string" ) {
return;
}
if ( !id ) {
// Only DOM nodes need a new unique ID for each element since their data
// ends up in the global cache
if ( isNode ) {
@ -94,6 +97,7 @@ function internalData( elem, key, data, pvt /* Internal Use Only */ ) {
}
if ( !cache[ id ] ) {
// Avoid exposing jQuery metadata on plain JS objects when the object
// is serialized using JSON.stringify
cache[ id ] = isNode ? {} : { toJSON: jQuery.noop };
@ -118,6 +122,7 @@ function internalData( elem, key, data, pvt /* Internal Use Only */ ) {
for ( prop in key ) {
thisCache[ jQuery.camelCase( prop ) ] = key[ prop ];
}
// Stop here, ignore other arguments
return thisCache;
}
@ -129,6 +134,7 @@ function internalData( elem, key, data, pvt /* Internal Use Only */ ) {
// We always set camelCased properties (gh-2257)
return typeof key === "string" ?
thisCache[ jQuery.camelCase( key ) ] :
// Return the whole cache if no key was specified
thisCache;
}
@ -178,7 +184,7 @@ function internalRemoveData( elem, key, pvt ) {
// If there is no data left in the cache, we want to continue
// and let the cache object itself get destroyed
if ( pvt ? !isEmptyDataObject(thisCache) : !jQuery.isEmptyObject(thisCache) ) {
if ( pvt ? !isEmptyDataObject( thisCache ) : !jQuery.isEmptyObject( thisCache ) ) {
return;
}
}
@ -211,7 +217,7 @@ function internalRemoveData( elem, key, pvt ) {
}
}
jQuery.extend({
jQuery.extend( {
cache: {},
// The following elements (space-suffixed to avoid Object.prototype collisions)
@ -219,12 +225,13 @@ jQuery.extend({
noData: {
"applet ": true,
"embed ": true,
// ...but Flash objects (which have this classid) *can* handle expandos
"object ": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
},
hasData: function( elem ) {
elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
elem = elem.nodeType ? jQuery.cache[ elem[ jQuery.expando ] ] : elem[ jQuery.expando ];
return !!elem && !isEmptyDataObject( elem );
},
@ -244,12 +251,12 @@ jQuery.extend({
_removeData: function( elem, name ) {
return internalRemoveData( elem, name, true );
}
});
} );
jQuery.fn.extend({
jQuery.fn.extend( {
data: function( key, value ) {
var i, name, data,
elem = this[0],
elem = this[ 0 ],
attrs = elem && elem.attributes;
// Special expections of .data basically thwart jQuery.access,
@ -269,7 +276,7 @@ jQuery.fn.extend({
if ( attrs[ i ] ) {
name = attrs[ i ].name;
if ( name.indexOf( "data-" ) === 0 ) {
name = jQuery.camelCase( name.slice(5) );
name = jQuery.camelCase( name.slice( 5 ) );
dataAttr( elem, name, data[ name ] );
}
}
@ -283,16 +290,17 @@ jQuery.fn.extend({
// Sets multiple values
if ( typeof key === "object" ) {
return this.each(function() {
return this.each( function() {
jQuery.data( this, key );
});
} );
}
return arguments.length > 1 ?
// Sets one value
this.each(function() {
this.each( function() {
jQuery.data( this, key, value );
}) :
} ) :
// Gets one value
// Try to fetch any internally stored data first
@ -300,11 +308,11 @@ jQuery.fn.extend({
},
removeData: function( key ) {
return this.each(function() {
return this.each( function() {
jQuery.removeData( this, key );
});
} );
}
});
} );
return jQuery;
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"../core"
], function( jQuery ) {
@ -6,7 +6,7 @@ define([
* Determines whether an object can have data
*/
jQuery.acceptData = function( elem ) {
var noData = jQuery.noData[ (elem.nodeName + " ").toLowerCase() ],
var noData = jQuery.noData[ ( elem.nodeName + " " ).toLowerCase() ],
nodeType = +elem.nodeType || 1;
// Do not set data on non-element DOM nodes because it will not be cleared (#8335).
@ -14,8 +14,8 @@ jQuery.acceptData = function( elem ) {
false :
// Nodes accept data unless otherwise specified; rejection can be conditional
!noData || noData !== true && elem.getAttribute("classid") === noData;
!noData || noData !== true && elem.getAttribute( "classid" ) === noData;
};
return jQuery.acceptData;
});
} );

View File

@ -1,9 +1,9 @@
define([
define( [
"../var/document",
"../var/support"
], function( document, support ) {
(function() {
( function() {
var div = document.createElement( "div" );
// Support: IE<9
@ -16,8 +16,8 @@ define([
// Null elements to avoid leaks in IE.
div = null;
})();
} )();
return support;
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"./core",
"./var/slice",
"./callbacks"
@ -11,18 +11,19 @@ function Thrower( ex ) {
throw ex;
}
jQuery.extend({
jQuery.extend( {
Deferred: function( func ) {
var tuples = [
// action, add listener, callbacks,
// ... .then handlers, argument index, [final state]
[ "notify", "progress", jQuery.Callbacks("memory"),
jQuery.Callbacks("memory"), 2 ],
[ "resolve", "done", jQuery.Callbacks("once memory"),
jQuery.Callbacks("once memory"), 0, "resolved" ],
[ "reject", "fail", jQuery.Callbacks("once memory"),
jQuery.Callbacks("once memory"), 1, "rejected" ]
[ "notify", "progress", jQuery.Callbacks( "memory" ),
jQuery.Callbacks( "memory" ), 2 ],
[ "resolve", "done", jQuery.Callbacks( "once memory" ),
jQuery.Callbacks( "once memory" ), 0, "resolved" ],
[ "reject", "fail", jQuery.Callbacks( "once memory" ),
jQuery.Callbacks( "once memory" ), 1, "rejected" ]
],
state = "pending",
promise = {
@ -36,19 +37,21 @@ jQuery.extend({
"catch": function( fn ) {
return promise.then( null, fn );
},
// Keep pipe for back-compat
pipe: function( /* fnDone, fnFail, fnProgress */ ) {
var fns = arguments;
return jQuery.Deferred(function( newDefer ) {
return jQuery.Deferred( function( newDefer ) {
jQuery.each( tuples, function( i, tuple ) {
// Map tuples (progress, done, fail) to arguments (done, fail, progress)
var fn = jQuery.isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
// deferred.progress(function() { bind to newDefer or newDefer.notify })
// deferred.done(function() { bind to newDefer or newDefer.resolve })
// deferred.fail(function() { bind to newDefer or newDefer.reject })
deferred[ tuple[1] ](function() {
deferred[ tuple[ 1 ] ]( function() {
var returned = fn && fn.apply( this, arguments );
if ( returned && jQuery.isFunction( returned.promise ) ) {
returned.promise()
@ -61,10 +64,10 @@ jQuery.extend({
fn ? [ returned ] : arguments
);
}
});
});
} );
} );
fns = null;
}).promise();
} ).promise();
},
then: function( onFulfilled, onRejected, onProgress ) {
var maxDepth = 0;
@ -105,6 +108,7 @@ jQuery.extend({
// Handle a returned thenable
if ( jQuery.isFunction( then ) ) {
// Special processors (notify) just wait for resolution
if ( special ) {
then.call(
@ -130,6 +134,7 @@ jQuery.extend({
// Handle all other returned values
} else {
// Only substitue handlers pass on context
// and multiple values (non-spec behavior)
if ( handler !== Identity ) {
@ -156,6 +161,7 @@ jQuery.extend({
// https://promisesaplus.com/#point-61
// Ignore post-resolution exceptions
if ( depth + 1 >= maxDepth ) {
// Only substitue handlers pass on context
// and multiple values (non-spec behavior)
if ( handler !== Thrower ) {
@ -181,7 +187,8 @@ jQuery.extend({
};
}
return jQuery.Deferred(function( newDefer ) {
return jQuery.Deferred( function( newDefer ) {
// progress_handlers.add( ... )
tuples[ 0 ][ 3 ].add(
resolve(
@ -215,8 +222,9 @@ jQuery.extend({
Thrower
)
);
}).promise();
} ).promise();
},
// Get a promise for this deferred
// If obj is provided, the promise aspect is added to the object
promise: function( obj ) {
@ -233,12 +241,13 @@ jQuery.extend({
// promise.progress = list.add
// promise.done = list.add
// promise.fail = list.add
promise[ tuple[1] ] = list.add;
promise[ tuple[ 1 ] ] = list.add;
// Handle state
if ( stateString ) {
list.add(
function() {
// state = "resolved" (i.e., fulfilled)
// state = "rejected"
state = stateString;
@ -261,16 +270,16 @@ jQuery.extend({
// deferred.notify = function() { deferred.notifyWith(...) }
// deferred.resolve = function() { deferred.resolveWith(...) }
// deferred.reject = function() { deferred.rejectWith(...) }
deferred[ tuple[0] ] = function() {
deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments );
deferred[ tuple[ 0 ] ] = function() {
deferred[ tuple[ 0 ] + "With" ]( this === deferred ? promise : this, arguments );
return this;
};
// deferred.notifyWith = list.fireWith
// deferred.resolveWith = list.fireWith
// deferred.rejectWith = list.fireWith
deferred[ tuple[0] + "With" ] = list.fireWith;
});
deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
} );
// Make the deferred a promise
promise.promise( deferred );
@ -320,14 +329,14 @@ jQuery.extend({
resolveContexts = new Array( length );
for ( ; i < length; i++ ) {
if ( resolveValues[ i ] &&
jQuery.isFunction( (method = resolveValues[ i ].promise) ) ) {
jQuery.isFunction( ( method = resolveValues[ i ].promise ) ) ) {
method.call( resolveValues[ i ] )
.progress( updateFunc( i, progressContexts, progressValues ) )
.done( updateFunc( i, resolveContexts, resolveValues ) )
.fail( master.reject );
} else if ( resolveValues[ i ] &&
jQuery.isFunction( (method = resolveValues[ i ].then) ) ) {
jQuery.isFunction( ( method = resolveValues[ i ].then ) ) ) {
method.call(
resolveValues[ i ],
@ -348,7 +357,7 @@ jQuery.extend({
return master.promise();
}
});
} );
return jQuery;
});
} );

View File

@ -1,2 +1,2 @@
define(function() {
});
define( function() {
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"./core",
"./core/access",
"./css"
@ -8,6 +8,7 @@ define([
jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
function( defaultExtra, funcName ) {
// margin is only for outerHeight, outerWidth
jQuery.fn[ funcName ] = function( margin, value ) {
var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
@ -17,6 +18,7 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
var doc;
if ( jQuery.isWindow( elem ) ) {
// As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
// isn't a whole lot we can do. See pull request at this URL for discussion:
// https://github.com/jquery/jquery/pull/764
@ -39,6 +41,7 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
}
return value === undefined ?
// Get width or height on the element, requesting but not forcing parseFloat
jQuery.css( elem, type, extra ) :
@ -46,8 +49,8 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
jQuery.style( elem, type, value, extra );
}, type, chainable ? margin : undefined, chainable, null );
};
});
});
} );
} );
return jQuery;
});
} );

82
src/effects.js vendored
View File

@ -1,4 +1,4 @@
define([
define( [
"./core",
"./var/document",
"./var/rcssNum",
@ -33,9 +33,9 @@ function raf() {
// Animations created synchronously will run synchronously
function createFxNow() {
window.setTimeout(function() {
window.setTimeout( function() {
fxNow = undefined;
});
} );
return ( fxNow = jQuery.now() );
}
@ -66,7 +66,7 @@ function createTween( value, prop, animation ) {
index = 0,
length = collection.length;
for ( ; index < length; index++ ) {
if ( (tween = collection[ index ].call( animation, prop, value )) ) {
if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
// we're done with this property
return tween;
@ -98,16 +98,17 @@ function defaultPrefilter( elem, props, opts ) {
}
hooks.unqueued++;
anim.always(function() {
anim.always( function() {
// doing this makes sure that the complete handler will be called
// before this completes
anim.always(function() {
anim.always( function() {
hooks.unqueued--;
if ( !jQuery.queue( elem, "fx" ).length ) {
hooks.empty.fire();
}
});
});
} );
} );
}
// Detect show/hide animations
@ -140,6 +141,7 @@ function defaultPrefilter( elem, props, opts ) {
// Restrict "overflow" and "display" styles during box animations
if ( isBox && elem.nodeType === 1 ) {
// Support: IE 9 - 11
// Record all 3 overflow attributes because IE does not infer the shorthand
// from identically-valued overflowX and overflowY
@ -163,9 +165,9 @@ function defaultPrefilter( elem, props, opts ) {
// Restore the original display value at the end of pure show/hide animations
if ( !propTween ) {
anim.done(function() {
anim.done( function() {
style.display = restoreDisplay;
});
} );
if ( restoreDisplay == null ) {
display = style.display;
restoreDisplay = display === "none" ? "" : display;
@ -178,11 +180,11 @@ function defaultPrefilter( elem, props, opts ) {
if ( opts.overflow ) {
style.overflow = "hidden";
anim.always(function() {
anim.always( function() {
style.overflow = opts.overflow[ 0 ];
style.overflowX = opts.overflow[ 1 ];
style.overflowY = opts.overflow[ 2 ];
});
} );
}
// Implement show/hide animations
@ -210,7 +212,8 @@ function defaultPrefilter( elem, props, opts ) {
}
/* jshint -W083 */
anim.done(function() {
anim.done( function() {
// The final step of a "hide" animation is actually hiding the element
if ( !hidden ) {
showHide( [ elem ] );
@ -219,7 +222,7 @@ function defaultPrefilter( elem, props, opts ) {
for ( prop in orig ) {
jQuery.style( elem, prop, orig[ prop ] );
}
});
} );
}
// Per-property setup
@ -277,15 +280,17 @@ function Animation( elem, properties, options ) {
index = 0,
length = Animation.prefilters.length,
deferred = jQuery.Deferred().always( function() {
// don't match elem in the :animated selector
delete tick.elem;
}),
} ),
tick = function() {
if ( stopped ) {
return false;
}
var currentTime = fxNow || createFxNow(),
remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
// Support: Android 2.3
// Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
temp = remaining / animation.duration || 0,
@ -297,7 +302,7 @@ function Animation( elem, properties, options ) {
animation.tweens[ index ].run( percent );
}
deferred.notifyWith( elem, [ animation, percent, remaining ]);
deferred.notifyWith( elem, [ animation, percent, remaining ] );
if ( percent < 1 && length ) {
return remaining;
@ -306,7 +311,7 @@ function Animation( elem, properties, options ) {
return false;
}
},
animation = deferred.promise({
animation = deferred.promise( {
elem: elem,
props: jQuery.extend( {}, properties ),
opts: jQuery.extend( true, {
@ -326,6 +331,7 @@ function Animation( elem, properties, options ) {
},
stop: function( gotoEnd ) {
var index = 0,
// if we are going to the end, we want to run all the tweens
// otherwise we skip this part
length = gotoEnd ? animation.tweens.length : 0;
@ -346,7 +352,7 @@ function Animation( elem, properties, options ) {
}
return this;
}
}),
} ),
props = animation.props;
propFilter( props, animation.opts.specialEasing );
@ -373,7 +379,7 @@ function Animation( elem, properties, options ) {
elem: elem,
anim: animation,
queue: animation.opts.queue
})
} )
);
// attach callbacks from options
@ -421,7 +427,7 @@ jQuery.Animation = jQuery.extend( Animation, {
Animation.prefilters.push( callback );
}
}
});
} );
jQuery.speed = function( speed, easing, fn ) {
var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
@ -462,18 +468,20 @@ jQuery.speed = function( speed, easing, fn ) {
return opt;
};
jQuery.fn.extend({
jQuery.fn.extend( {
fadeTo: function( speed, to, easing, callback ) {
// show any hidden elements after setting opacity to 0
return this.filter( isHidden ).css( "opacity", 0 ).show()
// animate to the value specified
.end().animate({ opacity: to }, speed, easing, callback );
.end().animate( { opacity: to }, speed, easing, callback );
},
animate: function( prop, speed, easing, callback ) {
var empty = jQuery.isEmptyObject( prop ),
optall = jQuery.speed( speed, easing, callback ),
doAnimation = function() {
// Operate on a copy of prop so per-property easing won't be lost
var anim = Animation( this, jQuery.extend( {}, prop ), optall );
@ -504,7 +512,7 @@ jQuery.fn.extend({
this.queue( type || "fx", [] );
}
return this.each(function() {
return this.each( function() {
var dequeue = true,
index = type != null && type + "queueHooks",
timers = jQuery.timers,
@ -524,7 +532,7 @@ jQuery.fn.extend({
for ( index = timers.length; index--; ) {
if ( timers[ index ].elem === this &&
(type == null || timers[ index ].queue === type) ) {
( type == null || timers[ index ].queue === type ) ) {
timers[ index ].anim.stop( gotoEnd );
dequeue = false;
@ -538,13 +546,13 @@ jQuery.fn.extend({
if ( dequeue || !gotoEnd ) {
jQuery.dequeue( this, type );
}
});
} );
},
finish: function( type ) {
if ( type !== false ) {
type = type || "fx";
}
return this.each(function() {
return this.each( function() {
var index,
data = jQuery._data( this ),
queue = data[ type + "queue" ],
@ -579,24 +587,24 @@ jQuery.fn.extend({
// turn off finishing flag
delete data.finish;
});
} );
}
});
} );
jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
var cssFn = jQuery.fn[ name ];
jQuery.fn[ name ] = function( speed, easing, callback ) {
return speed == null || typeof speed === "boolean" ?
cssFn.apply( this, arguments ) :
this.animate( genFx( name, true ), speed, easing, callback );
};
});
} );
// Generate shortcuts for custom animations
jQuery.each({
slideDown: genFx("show"),
slideUp: genFx("hide"),
slideToggle: genFx("toggle"),
jQuery.each( {
slideDown: genFx( "show" ),
slideUp: genFx( "hide" ),
slideToggle: genFx( "toggle" ),
fadeIn: { opacity: "show" },
fadeOut: { opacity: "hide" },
fadeToggle: { opacity: "toggle" }
@ -604,7 +612,7 @@ jQuery.each({
jQuery.fn[ name ] = function( speed, easing, callback ) {
return this.animate( props, speed, easing, callback );
};
});
} );
jQuery.timers = [];
jQuery.fx.tick = function() {
@ -616,6 +624,7 @@ jQuery.fx.tick = function() {
for ( ; i < timers.length; i++ ) {
timer = timers[ i ];
// Checks the timer has not already been removed
if ( !timer() && timers[ i ] === timer ) {
timers.splice( i--, 1 );
@ -658,9 +667,10 @@ jQuery.fx.stop = function() {
jQuery.fx.speeds = {
slow: 600,
fast: 200,
// Default speed
_default: 400
};
return jQuery;
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"../core",
"../css"
], function( jQuery ) {
@ -71,10 +71,12 @@ Tween.propHooks = {
// so, simple values such as "10px" are parsed to Float.
// complex values such as "rotate(1rad)" are returned as is.
result = jQuery.css( tween.elem, tween.prop, "" );
// Empty strings, null, undefined and "auto" are converted to 0.
return !result || result === "auto" ? 0 : result;
},
set: function( tween ) {
// use step hook for back compat - use cssHook if its there - use .style if its
// available and use plain properties where available
if ( jQuery.fx.step[ tween.prop ] ) {
@ -116,4 +118,4 @@ jQuery.fx = Tween.prototype.init;
// Back Compat <1.8 extension point
jQuery.fx.step = {};
});
} );

View File

@ -1,13 +1,13 @@
define([
define( [
"../core",
"../selector",
"../effects"
], function( jQuery ) {
jQuery.expr.filters.animated = function( elem ) {
return jQuery.grep(jQuery.timers, function( fn ) {
return jQuery.grep( jQuery.timers, function( fn ) {
return elem === fn.elem;
}).length;
} ).length;
};
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"./core",
"./var/document",
"./var/rnotwhite",
@ -38,8 +38,10 @@ function on( elem, types, selector, data, fn, one ) {
// Types can be a map of types/handlers
if ( typeof types === "object" ) {
// ( types-Object, selector, data )
if ( typeof selector !== "string" ) {
// ( types-Object, data )
data = data || selector;
selector = undefined;
@ -51,15 +53,18 @@ function on( elem, types, selector, data, fn, one ) {
}
if ( data == null && fn == null ) {
// ( types, fn )
fn = selector;
data = selector = undefined;
} else if ( fn == null ) {
if ( typeof selector === "string" ) {
// ( types, selector, fn )
fn = data;
data = undefined;
} else {
// ( types, data, fn )
fn = data;
data = selector;
@ -73,16 +78,18 @@ function on( elem, types, selector, data, fn, one ) {
if ( one === 1 ) {
origFn = fn;
fn = function( event ) {
// Can use an empty set, since event contains the info
jQuery().off( event );
return origFn.apply( this, arguments );
};
// Use same guid so caller can remove using origFn
fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
}
return elem.each( function() {
jQuery.event.add( this, types, fn, data, selector );
});
} );
}
/*
@ -117,17 +124,20 @@ jQuery.event = {
}
// Init the element's event structure and main handler, if this is the first
if ( !(events = elemData.events) ) {
if ( !( events = elemData.events ) ) {
events = elemData.events = {};
}
if ( !(eventHandle = elemData.handle) ) {
if ( !( eventHandle = elemData.handle ) ) {
eventHandle = elemData.handle = function( e ) {
// Discard the second event of a jQuery.event.trigger() and
// when an event is called after a page has unloaded
return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
return typeof jQuery !== "undefined" &&
( !e || jQuery.event.triggered !== e.type ) ?
jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
undefined;
};
// Add elem as a property of the handle fn to prevent a memory leak
// with IE non-native events
eventHandle.elem = elem;
@ -137,9 +147,9 @@ jQuery.event = {
types = ( types || "" ).match( rnotwhite ) || [ "" ];
t = types.length;
while ( t-- ) {
tmp = rtypenamespace.exec( types[t] ) || [];
type = origType = tmp[1];
namespaces = ( tmp[2] || "" ).split( "." ).sort();
tmp = rtypenamespace.exec( types[ t ] ) || [];
type = origType = tmp[ 1 ];
namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
// There *must* be a type, no attaching namespace-only handlers
if ( !type ) {
@ -156,7 +166,7 @@ jQuery.event = {
special = jQuery.event.special[ type ] || {};
// handleObj is passed to all event handlers
handleObj = jQuery.extend({
handleObj = jQuery.extend( {
type: type,
origType: origType,
data: data,
@ -164,11 +174,11 @@ jQuery.event = {
guid: handler.guid,
selector: selector,
needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
namespace: namespaces.join(".")
namespace: namespaces.join( "." )
}, handleObjIn );
// Init the event handler queue if we're the first
if ( !(handlers = events[ type ]) ) {
if ( !( handlers = events[ type ] ) ) {
handlers = events[ type ] = [];
handlers.delegateCount = 0;
@ -217,7 +227,7 @@ jQuery.event = {
namespaces, origType,
elemData = jQuery.hasData( elem ) && jQuery._data( elem );
if ( !elemData || !(events = elemData.events) ) {
if ( !elemData || !( events = elemData.events ) ) {
return;
}
@ -225,9 +235,9 @@ jQuery.event = {
types = ( types || "" ).match( rnotwhite ) || [ "" ];
t = types.length;
while ( t-- ) {
tmp = rtypenamespace.exec( types[t] ) || [];
type = origType = tmp[1];
namespaces = ( tmp[2] || "" ).split( "." ).sort();
tmp = rtypenamespace.exec( types[ t ] ) || [];
type = origType = tmp[ 1 ];
namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
// Unbind all events (on this namespace, if provided) for the element
if ( !type ) {
@ -240,7 +250,8 @@ jQuery.event = {
special = jQuery.event.special[ type ] || {};
type = ( selector ? special.delegateType : special.bindType ) || type;
handlers = events[ type ] || [];
tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
tmp = tmp[ 2 ] &&
new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
// Remove matching events
origCount = j = handlers.length;
@ -291,7 +302,7 @@ jQuery.event = {
bubbleType, special, tmp, i,
eventPath = [ elem || document ],
type = hasOwn.call( event, "type" ) ? event.type : event,
namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
cur = tmp = elem = elem || document;
@ -305,13 +316,14 @@ jQuery.event = {
return;
}
if ( type.indexOf(".") > -1 ) {
if ( type.indexOf( "." ) > -1 ) {
// Namespaced trigger; create a regexp to match event type in handle()
namespaces = type.split(".");
namespaces = type.split( "." );
type = namespaces.shift();
namespaces.sort();
}
ontype = type.indexOf(":") < 0 && "on" + type;
ontype = type.indexOf( ":" ) < 0 && "on" + type;
// Caller can pass in a jQuery.Event object, Object, or just an event type string
event = event[ jQuery.expando ] ?
@ -320,9 +332,9 @@ jQuery.event = {
// Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
event.isTrigger = onlyHandlers ? 2 : 3;
event.namespace = namespaces.join(".");
event.namespace = namespaces.join( "." );
event.rnamespace = event.namespace ?
new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
null;
// Clean up the event in case it is being reused
@ -356,14 +368,14 @@ jQuery.event = {
}
// Only add window if we got to document (e.g., not plain obj or detached DOM)
if ( tmp === (elem.ownerDocument || document) ) {
if ( tmp === ( elem.ownerDocument || document ) ) {
eventPath.push( tmp.defaultView || tmp.parentWindow || window );
}
}
// Fire handlers on the event path
i = 0;
while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
event.type = i > 1 ?
bubbleType :
@ -391,8 +403,11 @@ jQuery.event = {
// If nobody prevented the default action, do it now
if ( !onlyHandlers && !event.isDefaultPrevented() ) {
if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) &&
jQuery.acceptData( elem ) ) {
if (
( !special._default ||
special._default.apply( eventPath.pop(), data ) === false
) && jQuery.acceptData( elem )
) {
// Call a native DOM method on the target with the same name name as the event.
// Don't do default actions on window, that's where global variables be (#6170)
@ -412,6 +427,7 @@ jQuery.event = {
try {
elem[ type ]();
} catch ( e ) {
// IE<9 dies on focus/blur to hidden element (#1486,#12518)
// only reproducible on winXP IE8 native, not IE9 in IE8 mode
}
@ -439,7 +455,7 @@ jQuery.event = {
special = jQuery.event.special[ event.type ] || {};
// Use the fix-ed jQuery.Event rather than the (read-only) native event
args[0] = event;
args[ 0 ] = event;
event.delegateTarget = this;
// Call the preDispatch hook for the mapped type, and let it bail if desired
@ -452,11 +468,11 @@ jQuery.event = {
// Run delegates first; they may want to stop propagation beneath us
i = 0;
while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
event.currentTarget = matched.elem;
j = 0;
while ( (handleObj = matched.handlers[ j++ ]) &&
while ( ( handleObj = matched.handlers[ j++ ] ) &&
!event.isImmediatePropagationStopped() ) {
// Triggered event must either 1) have no namespace, or 2) have namespace(s)
@ -466,11 +482,11 @@ jQuery.event = {
event.handleObj = handleObj;
event.data = handleObj.data;
ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle ||
ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
handleObj.handler ).apply( matched.elem, args );
if ( ret !== undefined ) {
if ( (event.result = ret) === false ) {
if ( ( event.result = ret ) === false ) {
event.preventDefault();
event.stopPropagation();
}
@ -499,7 +515,7 @@ jQuery.event = {
//
// Support: Firefox
// Avoid non-left-click bubbling in Firefox (#3861)
if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
if ( delegateCount && cur.nodeType && ( !event.button || event.type !== "click" ) ) {
/* jshint eqeqeq: false */
for ( ; cur != this; cur = cur.parentNode || this ) {
@ -507,7 +523,7 @@ jQuery.event = {
// Don't check non-elements (#13208)
// Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
if ( cur.nodeType === 1 && (cur.disabled !== true || event.type !== "click") ) {
if ( cur.nodeType === 1 && ( cur.disabled !== true || event.type !== "click" ) ) {
matches = [];
for ( i = 0; i < delegateCount; i++ ) {
handleObj = handlers[ i ];
@ -525,7 +541,7 @@ jQuery.event = {
}
}
if ( matches.length ) {
handlerQueue.push({ elem: cur, handlers: matches });
handlerQueue.push( { elem: cur, handlers: matches } );
}
}
}
@ -533,7 +549,7 @@ jQuery.event = {
// Add the remaining (directly-bound) handlers
if ( delegateCount < handlers.length ) {
handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
handlerQueue.push( { elem: this, handlers: handlers.slice( delegateCount ) } );
}
return handlerQueue;
@ -587,12 +603,12 @@ jQuery.event = {
// Includes some event props shared by KeyEvent and MouseEvent
props: ( "altKey bubbles cancelable ctrlKey currentTarget detail eventPhase " +
"metaKey relatedTarget shiftKey target timeStamp view which" ).split(" "),
"metaKey relatedTarget shiftKey target timeStamp view which" ).split( " " ),
fixHooks: {},
keyHooks: {
props: "char charCode key keyCode".split(" "),
props: "char charCode key keyCode".split( " " ),
filter: function( event, original ) {
// Add which for key events
@ -606,7 +622,7 @@ jQuery.event = {
mouseHooks: {
props: ( "button buttons clientX clientY fromElement offsetX offsetY " +
"pageX pageY screenX screenY toElement" ).split(" "),
"pageX pageY screenX screenY toElement" ).split( " " ),
filter: function( event, original ) {
var body, eventDoc, doc,
button = original.button,
@ -645,10 +661,12 @@ jQuery.event = {
special: {
load: {
// Prevent triggered image.load events from bubbling to window.load
noBubble: true
},
focus: {
// Fire native event if possible so blur/focus sequence is correct
trigger: function() {
if ( this !== safeActiveElement() && this.focus ) {
@ -656,6 +674,7 @@ jQuery.event = {
this.focus();
return false;
} catch ( e ) {
// Support: IE<9
// If we error on focus to hidden element (#1486, #12518),
// let .trigger() run the handlers
@ -674,6 +693,7 @@ jQuery.event = {
delegateType: "focusout"
},
click: {
// For checkbox, fire native event so checked state will be right
trigger: function() {
if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) {
@ -708,6 +728,7 @@ jQuery.event = {
{
type: type,
isSimulated: true
// Previously, `originalEvent: {}` was set here, so stopPropagation call
// would not be triggered on donor event, since in our own
// jQuery.event.stopPropagation function we had a check for existence of
@ -752,8 +773,9 @@ jQuery.removeEvent = document.removeEventListener ?
};
jQuery.Event = function( src, props ) {
// Allow instantiation without the 'new' keyword
if ( !(this instanceof jQuery.Event) ) {
if ( !( this instanceof jQuery.Event ) ) {
return new jQuery.Event( src, props );
}
@ -766,6 +788,7 @@ jQuery.Event = function( src, props ) {
// by a handler lower down the tree; reflect the correct value.
this.isDefaultPrevented = src.defaultPrevented ||
src.defaultPrevented === undefined &&
// Support: IE < 9, Android < 4.0
src.returnValue === false ?
returnTrue :
@ -822,6 +845,7 @@ jQuery.Event.prototype = {
if ( !e || this.isSimulated ) {
return;
}
// If stopPropagation exists, run it on the original event
if ( e.stopPropagation ) {
e.stopPropagation();
@ -852,7 +876,7 @@ jQuery.Event.prototype = {
// Safari sends mouseenter too often; see:
// https://code.google.com/p/chromium/issues/detail?id=470258
// for the description of the bug (it existed in older Chrome versions as well).
jQuery.each({
jQuery.each( {
mouseenter: "mouseover",
mouseleave: "mouseout",
pointerenter: "pointerover",
@ -870,7 +894,7 @@ jQuery.each({
// For mousenter/leave call the handler if related is outside the target.
// NB: No relatedTarget if the mouse left/entered the browser window
if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
event.type = handleObj.origType;
ret = handleObj.handler.apply( this, arguments );
event.type = fix;
@ -878,13 +902,14 @@ jQuery.each({
return ret;
}
};
});
} );
// IE submit delegation
if ( !support.submit ) {
jQuery.event.special.submit = {
setup: function() {
// Only need this for delegated form submit events
if ( jQuery.nodeName( this, "form" ) ) {
return false;
@ -892,6 +917,7 @@ if ( !support.submit ) {
// Lazy-add a submit handler when a descendant form may potentially be submitted
jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
// Node name check avoids a VML-related crash in IE (#9807)
var elem = e.target,
form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ?
@ -901,14 +927,16 @@ if ( !support.submit ) {
if ( form && !jQuery._data( form, "submit" ) ) {
jQuery.event.add( form, "submit._submit", function( event ) {
event._submitBubble = true;
});
} );
jQuery._data( form, "submit", true );
}
});
} );
// return undefined since we don't need an event listener
},
postDispatch: function( event ) {
// If form was submitted by the user, bubble the event up the tree
if ( event._submitBubble ) {
delete event._submitBubble;
@ -919,6 +947,7 @@ if ( !support.submit ) {
},
teardown: function() {
// Only need this for delegated form submit events
if ( jQuery.nodeName( this, "form" ) ) {
return false;
@ -938,6 +967,7 @@ if ( !support.change ) {
setup: function() {
if ( rformElems.test( this.nodeName ) ) {
// IE doesn't fire change on a check/radio until blur; trigger it on click
// after a propertychange. Eat the blur-change in special.change.handle.
// This still fires onchange a second time for check/radio after blur.
@ -946,17 +976,19 @@ if ( !support.change ) {
if ( event.originalEvent.propertyName === "checked" ) {
this._justChanged = true;
}
});
} );
jQuery.event.add( this, "click._change", function( event ) {
if ( this._justChanged && !event.isTrigger ) {
this._justChanged = false;
}
// Allow triggered, simulated change events (#11500)
jQuery.event.simulate( "change", this, event );
});
} );
}
return false;
}
// Delegated event; lazy-add a change handler on descendant inputs
jQuery.event.add( this, "beforeactivate._change", function( e ) {
var elem = e.target;
@ -966,10 +998,10 @@ if ( !support.change ) {
if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
jQuery.event.simulate( "change", this.parentNode, event );
}
});
} );
jQuery._data( elem, "change", true );
}
});
} );
},
handle: function( event ) {
@ -977,7 +1009,7 @@ if ( !support.change ) {
// Swallow native change events from checkbox/radio, we already triggered them above
if ( this !== elem || event.isSimulated || event.isTrigger ||
(elem.type !== "radio" && elem.type !== "checkbox") ) {
( elem.type !== "radio" && elem.type !== "checkbox" ) ) {
return event.handleObj.handler.apply( this, arguments );
}
@ -1000,7 +1032,7 @@ if ( !support.change ) {
// which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
// Related ticket - https://code.google.com/p/chromium/issues/detail?id=449857
if ( !support.focusin ) {
jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
// Attach a single capturing handler on the document while someone wants focusin/focusout
var handler = function( event ) {
@ -1029,10 +1061,10 @@ if ( !support.focusin ) {
}
}
};
});
} );
}
jQuery.fn.extend({
jQuery.fn.extend( {
on: function( types, selector, data, fn ) {
return on( this, types, selector, data, fn );
@ -1043,6 +1075,7 @@ jQuery.fn.extend({
off: function( types, selector, fn ) {
var handleObj, type;
if ( types && types.preventDefault && types.handleObj ) {
// ( event ) dispatched jQuery.Event
handleObj = types.handleObj;
jQuery( types.delegateTarget ).off(
@ -1055,6 +1088,7 @@ jQuery.fn.extend({
return this;
}
if ( typeof types === "object" ) {
// ( types-object [, selector] )
for ( type in types ) {
this.off( type, selector, types[ type ] );
@ -1062,6 +1096,7 @@ jQuery.fn.extend({
return this;
}
if ( selector === false || typeof selector === "function" ) {
// ( types [, fn] )
fn = selector;
selector = undefined;
@ -1069,23 +1104,23 @@ jQuery.fn.extend({
if ( fn === false ) {
fn = returnFalse;
}
return this.each(function() {
return this.each( function() {
jQuery.event.remove( this, types, fn, selector );
});
} );
},
trigger: function( type, data ) {
return this.each(function() {
return this.each( function() {
jQuery.event.trigger( type, data, this );
});
} );
},
triggerHandler: function( type, data ) {
var elem = this[0];
var elem = this[ 0 ];
if ( elem ) {
return jQuery.event.trigger( type, data, elem, true );
}
}
});
} );
return jQuery;
});
} );

View File

@ -1,10 +1,10 @@
define([
define( [
"../core",
"../event"
], function( jQuery ) {
// Attach a bunch of functions for handling common AJAX events
jQuery.each([
jQuery.each( [
"ajaxStart",
"ajaxStop",
"ajaxComplete",
@ -15,6 +15,6 @@ jQuery.each([
jQuery.fn[ type ] = function( fn ) {
return this.on( type, fn );
};
});
} );
});
} );

View File

@ -1,11 +1,11 @@
define([
define( [
"../core",
"../event"
], function( jQuery ) {
jQuery.each( ("blur focus focusin focusout resize scroll click dblclick " +
jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
"change select submit keydown keypress keyup contextmenu").split(" "),
"change select submit keydown keypress keyup contextmenu" ).split( " " ),
function( i, name ) {
// Handle event binding
@ -14,9 +14,9 @@ jQuery.each( ("blur focus focusin focusout resize scroll click dblclick " +
this.on( name, null, data, fn ) :
this.trigger( name );
};
});
} );
jQuery.fn.extend({
jQuery.fn.extend( {
hover: function( fnOver, fnOut ) {
return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
},
@ -32,11 +32,12 @@ jQuery.fn.extend({
return this.on( types, selector, data, fn );
},
undelegate: function( selector, types, fn ) {
// ( namespace ) or ( selector, types [, fn] )
return arguments.length === 1 ?
this.off( selector, "**" ) :
this.off( types, selector || "**", fn );
}
});
} );
});
} );

View File

@ -1,17 +1,18 @@
define([
define( [
"../var/document",
"../var/support"
], function( document, support ) {
(function() {
( function() {
var i, eventName,
div = document.createElement( "div" );
// Support: IE<9 (lack submit/change bubble), Firefox (lack focus(in | out) events)
for ( i in { submit: true, change: true, focusin: true }) {
for ( i in { submit: true, change: true, focusin: true } ) {
eventName = "on" + i;
if ( !(support[ i ] = eventName in window) ) {
if ( !( support[ i ] = eventName in window ) ) {
// Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
div.setAttribute( eventName, "t" );
support[ i ] = div.attributes[ eventName ].expando === false;
@ -20,8 +21,8 @@ define([
// Null elements to avoid leaks in IE.
div = null;
})();
} )();
return support;
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"../core"
], function( jQuery ) {
@ -18,7 +18,7 @@ define([
if ( typeof define === "function" && define.amd ) {
define( "jquery", [], function() {
return jQuery;
});
} );
}
});
} );

View File

@ -1,4 +1,5 @@
var
// Map over jQuery in case of overwrite
_jQuery = window.jQuery,

6
src/jquery.js vendored
View File

@ -1,4 +1,4 @@
define([
define( [
"./core",
"./selector",
"./traversing",
@ -32,6 +32,6 @@ define([
"./exports/amd"
], function( jQuery ) {
return (window.jQuery = window.$ = jQuery);
return ( window.jQuery = window.$ = jQuery );
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"./core",
"./var/document",
"./var/concat",
@ -32,12 +32,13 @@ var rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
rnoshimcache = new RegExp( "<(?:" + nodeNames + ")[\\s/>]", "i" ),
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi,
rnoInnerhtml = /<(?:script|style|link)/i,
// checked="checked" or checked
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
rscriptTypeMasked = /^true\/(.*)/,
rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
safeFragment = createSafeFragment( document ),
fragmentDiv = safeFragment.appendChild( document.createElement("div") );
fragmentDiv = safeFragment.appendChild( document.createElement( "div" ) );
// Manipulating tables requires a tbody
function manipulationTarget( elem, content ) {
@ -52,15 +53,15 @@ function manipulationTarget( elem, content ) {
// Replace/restore the type attribute of script elements for safe DOM manipulation
function disableScript( elem ) {
elem.type = (jQuery.find.attr( elem, "type" ) !== null) + "/" + elem.type;
elem.type = ( jQuery.find.attr( elem, "type" ) !== null ) + "/" + elem.type;
return elem;
}
function restoreScript( elem ) {
var match = rscriptTypeMasked.exec( elem.type );
if ( match ) {
elem.type = match[1];
elem.type = match[ 1 ];
} else {
elem.removeAttribute("type");
elem.removeAttribute( "type" );
}
return elem;
}
@ -149,20 +150,20 @@ function domManip( collection, args, callback, ignored ) {
i = 0,
l = collection.length,
iNoClone = l - 1,
value = args[0],
value = args[ 0 ],
isFunction = jQuery.isFunction( value );
// We can't cloneNode fragments that contain checked, in WebKit
if ( isFunction ||
( l > 1 && typeof value === "string" &&
!support.checkClone && rchecked.test( value ) ) ) {
return collection.each(function( index ) {
return collection.each( function( index ) {
var self = collection.eq( index );
if ( isFunction ) {
args[0] = value.call( this, index, self.html() );
args[ 0 ] = value.call( this, index, self.html() );
}
domManip( self, args, callback, ignored );
});
} );
}
if ( l ) {
@ -189,13 +190,14 @@ function domManip( collection, args, callback, ignored ) {
// Keep references to cloned scripts for later restoration
if ( hasScripts ) {
// Support: Android<4.1, PhantomJS<2
// push.apply(_, arraylike) throws on ancient WebKit
jQuery.merge( scripts, getAll( node, "script" ) );
}
}
callback.call( collection[i], node, i );
callback.call( collection[ i ], node, i );
}
if ( hasScripts ) {
@ -212,6 +214,7 @@ function domManip( collection, args, callback, ignored ) {
jQuery.contains( doc, node ) ) {
if ( node.src ) {
// Optional AJAX dependency, but won't run scripts if not present
if ( jQuery._evalUrl ) {
jQuery._evalUrl( node.src );
@ -239,7 +242,7 @@ function remove( elem, selector, keepData ) {
elems = selector ? jQuery.filter( selector, elem ) : elem,
i = 0;
for ( ; (node = elems[i]) != null; i++ ) {
for ( ; ( node = elems[ i ] ) != null; i++ ) {
if ( !keepData && node.nodeType === 1 ) {
jQuery.cleanData( getAll( node ) );
@ -256,7 +259,7 @@ function remove( elem, selector, keepData ) {
return elem;
}
jQuery.extend({
jQuery.extend( {
htmlPrefilter: function( html ) {
return html.replace( rxhtmlTag, "<$1></$2>" );
},
@ -265,7 +268,7 @@ jQuery.extend({
var destElements, node, clone, i, srcElements,
inPage = jQuery.contains( elem.ownerDocument, elem );
if ( support.html5Clone || jQuery.isXMLDoc(elem) ||
if ( support.html5Clone || jQuery.isXMLDoc( elem ) ||
!rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
clone = elem.cloneNode( true );
@ -276,18 +279,19 @@ jQuery.extend({
fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
}
if ( (!support.noCloneEvent || !support.noCloneChecked) &&
(elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
if ( ( !support.noCloneEvent || !support.noCloneChecked ) &&
( elem.nodeType === 1 || elem.nodeType === 11 ) && !jQuery.isXMLDoc( elem ) ) {
// We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
destElements = getAll( clone );
srcElements = getAll( elem );
// Fix all IE cloning issues
for ( i = 0; (node = srcElements[i]) != null; ++i ) {
for ( i = 0; ( node = srcElements[ i ] ) != null; ++i ) {
// Ensure that the destination node is not null; Fixes #9587
if ( destElements[i] ) {
fixCloneNodeIssues( node, destElements[i] );
if ( destElements[ i ] ) {
fixCloneNodeIssues( node, destElements[ i ] );
}
}
}
@ -298,8 +302,8 @@ jQuery.extend({
srcElements = srcElements || getAll( elem );
destElements = destElements || getAll( clone );
for ( i = 0; (node = srcElements[i]) != null; i++ ) {
cloneCopyEvent( node, destElements[i] );
for ( i = 0; ( node = srcElements[ i ] ) != null; i++ ) {
cloneCopyEvent( node, destElements[ i ] );
}
} else {
cloneCopyEvent( elem, clone );
@ -326,7 +330,7 @@ jQuery.extend({
attributes = support.attributes,
special = jQuery.event.special;
for ( ; (elem = elems[i]) != null; i++ ) {
for ( ; ( elem = elems[ i ] ) != null; i++ ) {
if ( acceptData || jQuery.acceptData( elem ) ) {
id = elem[ internalKey ];
@ -370,9 +374,9 @@ jQuery.extend({
}
}
}
});
} );
jQuery.fn.extend({
jQuery.fn.extend( {
detach: function( selector ) {
return remove( this, selector, true );
},
@ -386,7 +390,7 @@ jQuery.fn.extend({
return value === undefined ?
jQuery.text( this ) :
this.empty().append(
( this[0] && this[0].ownerDocument || document ).createTextNode( value )
( this[ 0 ] && this[ 0 ].ownerDocument || document ).createTextNode( value )
);
}, null, value, arguments.length );
},
@ -397,7 +401,7 @@ jQuery.fn.extend({
var target = manipulationTarget( this, elem );
target.appendChild( elem );
}
});
} );
},
prepend: function() {
@ -406,7 +410,7 @@ jQuery.fn.extend({
var target = manipulationTarget( this, elem );
target.insertBefore( elem, target.firstChild );
}
});
} );
},
before: function() {
@ -414,7 +418,7 @@ jQuery.fn.extend({
if ( this.parentNode ) {
this.parentNode.insertBefore( elem, this );
}
});
} );
},
after: function() {
@ -422,14 +426,15 @@ jQuery.fn.extend({
if ( this.parentNode ) {
this.parentNode.insertBefore( elem, this.nextSibling );
}
});
} );
},
empty: function() {
var elem,
i = 0;
for ( ; (elem = this[i]) != null; i++ ) {
for ( ; ( elem = this[ i ] ) != null; i++ ) {
// Remove element nodes and prevent memory leaks
if ( elem.nodeType === 1 ) {
jQuery.cleanData( getAll( elem, false ) );
@ -454,9 +459,9 @@ jQuery.fn.extend({
dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
return this.map(function() {
return this.map( function() {
return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
});
} );
},
html: function( value ) {
@ -475,14 +480,15 @@ jQuery.fn.extend({
if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
( support.htmlSerialize || !rnoshimcache.test( value ) ) &&
( support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
!wrapMap[ (rtagName.exec( value ) || [ "", "" ])[ 1 ].toLowerCase() ] ) {
!wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
value = jQuery.htmlPrefilter( value );
try {
for (; i < l; i++ ) {
for ( ; i < l; i++ ) {
// Remove element nodes and prevent memory leaks
elem = this[i] || {};
elem = this[ i ] || {};
if ( elem.nodeType === 1 ) {
jQuery.cleanData( getAll( elem, false ) );
elem.innerHTML = value;
@ -518,9 +524,9 @@ jQuery.fn.extend({
// Force callback invocation
}, ignored );
}
});
} );
jQuery.each({
jQuery.each( {
appendTo: "append",
prependTo: "prepend",
insertBefore: "before",
@ -535,8 +541,8 @@ jQuery.each({
last = insert.length - 1;
for ( ; i <= last; i++ ) {
elems = i === last ? this : this.clone(true);
jQuery( insert[i] )[ original ]( elems );
elems = i === last ? this : this.clone( true );
jQuery( insert[ i ] )[ original ]( elems );
// Support: IE<9, Android<4.1, PhantomJS<2
// .get() because push.apply(_, arraylike) throws on ancient WebKit
@ -545,7 +551,7 @@ jQuery.each({
return this.pushStack( ret );
};
});
} );
return jQuery;
});
} );

View File

@ -1,9 +1,9 @@
define([
define( [
"../ajax"
], function( jQuery ) {
jQuery._evalUrl = function( url ) {
return jQuery.ajax({
return jQuery.ajax( {
url: url,
// Make this explicit, since user can override this through ajaxSetup (#11264)
@ -13,9 +13,9 @@ jQuery._evalUrl = function( url ) {
async: false,
global: false,
"throws": true
});
} );
};
return jQuery._evalUrl;
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"../core",
"./var/rtagName",
"./var/rscriptType",
@ -38,22 +38,22 @@ function buildFragment( elems, context, scripts, selection, ignored ) {
// Convert html into DOM nodes
} else {
tmp = tmp || safe.appendChild( context.createElement("div") );
tmp = tmp || safe.appendChild( context.createElement( "div" ) );
// Deserialize a standard representation
tag = (rtagName.exec( elem ) || [ "", "" ])[ 1 ].toLowerCase();
tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
wrap = wrapMap[ tag ] || wrapMap._default;
tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
// Descend through wrappers to the right content
j = wrap[0];
j = wrap[ 0 ];
while ( j-- ) {
tmp = tmp.lastChild;
}
// Manually add leading whitespace removed by IE
if ( !support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[0] ) );
nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[ 0 ] ) );
}
jQuery.merge( nodes, tmp.childNodes );
@ -78,7 +78,7 @@ function buildFragment( elems, context, scripts, selection, ignored ) {
}
i = 0;
while ( (elem = nodes[ i++ ]) ) {
while ( ( elem = nodes[ i++ ] ) ) {
// Skip elements already in the context collection (trac-4087)
if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
@ -101,7 +101,7 @@ function buildFragment( elems, context, scripts, selection, ignored ) {
// Capture executables
if ( scripts ) {
j = 0;
while ( (elem = tmp[ j++ ]) ) {
while ( ( elem = tmp[ j++ ] ) ) {
if ( rscriptType.test( elem.type || "" ) ) {
scripts.push( elem );
}
@ -115,4 +115,4 @@ function buildFragment( elems, context, scripts, selection, ignored ) {
}
return buildFragment;
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"./var/nodeNames"
], function( nodeNames ) {
@ -17,4 +17,4 @@ function createSafeFragment( document ) {
}
return createSafeFragment;
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"../core"
], function( jQuery ) {
@ -13,7 +13,7 @@ function getAll( context, tag ) {
if ( !found ) {
for ( found = [], elems = context.childNodes || context;
( elem = elems[i] ) != null;
( elem = elems[ i ] ) != null;
i++
) {
if ( !tag || jQuery.nodeName( elem, tag ) ) {
@ -30,4 +30,4 @@ function getAll( context, tag ) {
}
return getAll;
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"../core"
], function( jQuery ) {
@ -6,14 +6,14 @@ define([
function setGlobalEval( elems, refElements ) {
var elem,
i = 0;
for ( ; ( elem = elems[i] ) != null; i++ ) {
for ( ; ( elem = elems[ i ] ) != null; i++ ) {
jQuery._data(
elem,
"globalEval",
!refElements || jQuery._data( refElements[i], "globalEval" )
!refElements || jQuery._data( refElements[ i ], "globalEval" )
);
}
}
return setGlobalEval;
});
} );

View File

@ -1,10 +1,10 @@
define([
define( [
"../core",
"../var/document",
"../var/support"
], function( jQuery, document, support ) {
(function() {
( function() {
var div = document.createElement( "div" ),
fragment = document.createDocumentFragment(),
input = document.createElement( "input" );
@ -31,6 +31,7 @@ define([
// #11217 - WebKit loses check when the name is after the checked attribute
fragment.appendChild( div );
// Support: Windows Web Apps (WWA)
// `name` and `type` must use .setAttribute for WWA (#14901)
input.setAttribute( "type", "radio" );
@ -52,8 +53,8 @@ define([
// cleanData must set properties to undefined rather than use removeAttribute
div[ jQuery.expando ] = 1;
support.attributes = !div.getAttribute( jQuery.expando );
})();
} )();
return support;
});
} );

View File

@ -1,5 +1,5 @@
define(function() {
define( function() {
return "abbr|article|aside|audio|bdi|canvas|data|datalist|" +
"details|dialog|figcaption|figure|footer|header|hgroup|main|" +
"mark|meter|nav|output|picture|progress|section|summary|template|time|video";
});
} );

View File

@ -1,3 +1,3 @@
define(function() {
return (/^(?:checkbox|radio)$/i);
});
define( function() {
return ( /^(?:checkbox|radio)$/i );
} );

View File

@ -1,3 +1,3 @@
define(function() {
define( function() {
return ( /^\s+/ );
});
} );

View File

@ -1,3 +1,3 @@
define(function() {
define( function() {
return ( /^$|\/(?:java|ecma)script/i );
});
} );

View File

@ -1,3 +1,3 @@
define(function() {
define( function() {
return ( /<([\w:-]+)/ );
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"./support"
], function( support ) {
@ -37,4 +37,4 @@ wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.the
wrapMap.th = wrapMap.td;
return wrapMap;
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"./core",
"./core/access",
"./var/document",
@ -45,7 +45,7 @@ jQuery.offset = {
curCSSTop = jQuery.css( elem, "top" );
curCSSLeft = jQuery.css( elem, "left" );
calculatePosition = ( position === "absolute" || position === "fixed" ) &&
jQuery.inArray("auto", [ curCSSTop, curCSSLeft ] ) > -1;
jQuery.inArray( "auto", [ curCSSTop, curCSSLeft ] ) > -1;
// need to be able to calculate position if either top or left
// is auto and position is either absolute or fixed
@ -79,15 +79,16 @@ jQuery.offset = {
}
};
jQuery.fn.extend({
jQuery.fn.extend( {
offset: function( options ) {
// Preserve chaining for setter
if ( arguments.length ) {
return options === undefined ?
this :
this.each(function( i ) {
this.each( function( i ) {
jQuery.offset.setOffset( this, options, i );
});
} );
}
var docElem, win, rect, doc,
@ -138,9 +139,11 @@ jQuery.fn.extend({
// Fixed elements are offset from window (parentOffset = {top:0, left: 0},
// because it is its only offset parent
if ( jQuery.css( elem, "position" ) === "fixed" ) {
// we assume that getBoundingClientRect is available when computed position is fixed
offset = elem.getBoundingClientRect();
} else {
// Get *real* offsetParent
offsetParent = this.offsetParent();
@ -163,7 +166,7 @@ jQuery.fn.extend({
// are the same in Safari causing offset.left to incorrectly be 0
return {
top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true)
left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
};
},
@ -178,7 +181,7 @@ jQuery.fn.extend({
//
// This logic, however, is not guaranteed and can change at any point in the future
offsetParent: function() {
return this.map(function() {
return this.map( function() {
var offsetParent = this.offsetParent;
while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
@ -186,9 +189,9 @@ jQuery.fn.extend({
}
return offsetParent || docElem;
});
} );
}
});
} );
// Create scrollLeft and scrollTop methods
jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
@ -199,7 +202,7 @@ jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function(
var win = getWindow( elem );
if ( val === undefined ) {
return win ? (prop in win) ? win[ prop ] :
return win ? ( prop in win ) ? win[ prop ] :
win.document.documentElement[ method ] :
elem[ method ];
}
@ -215,7 +218,7 @@ jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function(
}
}, method, val, arguments.length, null );
};
});
} );
// Support: Safari<7-8+, Chrome<37-44+
// Add the top/left cssHooks using jQuery.fn.position
@ -227,6 +230,7 @@ jQuery.each( [ "top", "left" ], function( i, prop ) {
function( elem, computed ) {
if ( computed ) {
computed = curCSS( elem, prop );
// if curCSS returns percentage, fallback to offset
return rnumnonpx.test( computed ) ?
jQuery( elem ).position()[ prop ] + "px" :
@ -234,7 +238,7 @@ jQuery.each( [ "top", "left" ], function( i, prop ) {
}
}
);
});
} );
return jQuery;
});
} );

View File

@ -1,10 +1,10 @@
define([
define( [
"./core",
"./deferred",
"./callbacks"
], function( jQuery ) {
jQuery.extend({
jQuery.extend( {
queue: function( elem, type, data ) {
var queue;
@ -14,8 +14,8 @@ jQuery.extend({
// Speed up dequeue by getting out quickly if this is just a lookup
if ( data ) {
if ( !queue || jQuery.isArray(data) ) {
queue = jQuery._data( elem, type, jQuery.makeArray(data) );
if ( !queue || jQuery.isArray( data ) ) {
queue = jQuery._data( elem, type, jQuery.makeArray( data ) );
} else {
queue.push( data );
}
@ -64,15 +64,15 @@ jQuery.extend({
_queueHooks: function( elem, type ) {
var key = type + "queueHooks";
return jQuery._data( elem, key ) || jQuery._data( elem, key, {
empty: jQuery.Callbacks("once memory").add(function() {
empty: jQuery.Callbacks( "once memory" ).add( function() {
jQuery._removeData( elem, type + "queue" );
jQuery._removeData( elem, key );
})
});
} )
} );
}
});
} );
jQuery.fn.extend({
jQuery.fn.extend( {
queue: function( type, data ) {
var setter = 2;
@ -83,30 +83,31 @@ jQuery.fn.extend({
}
if ( arguments.length < setter ) {
return jQuery.queue( this[0], type );
return jQuery.queue( this[ 0 ], type );
}
return data === undefined ?
this :
this.each(function() {
this.each( function() {
var queue = jQuery.queue( this, type, data );
// ensure a hooks for this queue
jQuery._queueHooks( this, type );
if ( type === "fx" && queue[0] !== "inprogress" ) {
if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
jQuery.dequeue( this, type );
}
});
} );
},
dequeue: function( type ) {
return this.each(function() {
return this.each( function() {
jQuery.dequeue( this, type );
});
} );
},
clearQueue: function( type ) {
return this.queue( type || "fx", [] );
},
// Get a promise resolved when queues of a certain type
// are emptied (fx is the type by default)
promise: function( type, obj ) {
@ -137,7 +138,7 @@ jQuery.fn.extend({
resolve();
return defer.promise( obj );
}
});
} );
return jQuery;
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"../core",
"../queue",
"../effects" // Delay is optional because of this dependency
@ -15,8 +15,8 @@ jQuery.fn.delay = function( time, type ) {
hooks.stop = function() {
window.clearTimeout( timeout );
};
});
} );
};
return jQuery.fn.delay;
});
} );

View File

@ -1,14 +1,14 @@
define([
define( [
"./core",
"sizzle"
], function( jQuery, Sizzle ) {
jQuery.find = Sizzle;
jQuery.expr = Sizzle.selectors;
jQuery.expr[":"] = jQuery.expr.pseudos;
jQuery.expr[ ":" ] = jQuery.expr.pseudos;
jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
jQuery.text = Sizzle.getText;
jQuery.isXMLDoc = Sizzle.isXML;
jQuery.contains = Sizzle.contains;
});
} );

View File

@ -1 +1 @@
define([ "./selector-sizzle" ], function() {});
define( [ "./selector-sizzle" ], function() {} );

View File

@ -1,4 +1,4 @@
define([
define( [
"./core",
"./manipulation/var/rcheckableType",
"./core/init",
@ -16,13 +16,16 @@ function buildParams( prefix, obj, traditional, add ) {
var name;
if ( jQuery.isArray( obj ) ) {
// Serialize array item.
jQuery.each( obj, function( i, v ) {
if ( traditional || rbracket.test( prefix ) ) {
// Treat each array item as a scalar.
add( prefix, v );
} else {
// Item is non-scalar (array or object), encode its numeric index.
buildParams(
prefix + "[" + ( typeof v === "object" ? i : "" ) + "]",
@ -31,15 +34,17 @@ function buildParams( prefix, obj, traditional, add ) {
add
);
}
});
} );
} else if ( !traditional && jQuery.type( obj ) === "object" ) {
// Serialize object item.
for ( name in obj ) {
buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
}
} else {
// Serialize scalar item.
add( prefix, obj );
}
@ -51,6 +56,7 @@ jQuery.param = function( a, traditional ) {
var prefix,
s = [],
add = function( key, value ) {
// If value is a function, invoke it and return its value
value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
@ -63,12 +69,14 @@ jQuery.param = function( a, traditional ) {
// If an array was passed in, assume that it is an array of form elements.
if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
// Serialize the form elements
jQuery.each( a, function() {
add( this.name, this.value );
});
} );
} else {
// If traditional, encode the "old" way (the way 1.3.2 or older
// did it), otherwise encode params recursively.
for ( prefix in a ) {
@ -80,24 +88,26 @@ jQuery.param = function( a, traditional ) {
return s.join( "&" ).replace( r20, "+" );
};
jQuery.fn.extend({
jQuery.fn.extend( {
serialize: function() {
return jQuery.param( this.serializeArray() );
},
serializeArray: function() {
return this.map(function() {
return this.map( function() {
// Can add propHook for "elements" to filter or add form elements
var elements = jQuery.prop( this, "elements" );
return elements ? jQuery.makeArray( elements ) : this;
})
.filter(function() {
} )
.filter( function() {
var type = this.type;
// Use .is(":disabled") so that fieldset[disabled] works
return this.name && !jQuery( this ).is( ":disabled" ) &&
rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
( this.checked || !rcheckableType.test( type ) );
})
.map(function( i, elem ) {
} )
.map( function( i, elem ) {
var val = jQuery( this ).val();
return val == null ?
@ -105,11 +115,11 @@ jQuery.fn.extend({
jQuery.isArray( val ) ?
jQuery.map( val, function( val ) {
return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
}) :
} ) :
{ name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
}).get();
} ).get();
}
});
} );
return jQuery;
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"./core",
"./var/support",
"./core/init", // Needed for hasOwn support test
@ -16,4 +16,4 @@ support.ownFirst = i === "0";
// Note: most support tests are defined in their respective modules.
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"./core",
"./traversing/var/rneedsContext",
"./core/init",
@ -7,6 +7,7 @@ define([
], function( jQuery, rneedsContext ) {
var rparentsprev = /^(?:parents|prev(?:Until|All))/,
// methods guaranteed to produce a unique set when starting from a unique set
guaranteedUnique = {
children: true,
@ -15,18 +16,18 @@ var rparentsprev = /^(?:parents|prev(?:Until|All))/,
prev: true
};
jQuery.extend({
jQuery.extend( {
dir: function( elem, dir, until ) {
var matched = [],
cur = elem[ dir ];
while ( cur && cur.nodeType !== 9 &&
(until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
( until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until ) ) ) {
if ( cur.nodeType === 1 ) {
matched.push( cur );
}
cur = cur[dir];
cur = cur[ dir ];
}
return matched;
},
@ -42,21 +43,21 @@ jQuery.extend({
return r;
}
});
} );
jQuery.fn.extend({
jQuery.fn.extend( {
has: function( target ) {
var i,
targets = jQuery( target, this ),
len = targets.length;
return this.filter(function() {
return this.filter( function() {
for ( i = 0; i < len; i++ ) {
if ( jQuery.contains( this, targets[i] ) ) {
if ( jQuery.contains( this, targets[ i ] ) ) {
return true;
}
}
});
} );
},
closest: function( selectors, context ) {
@ -69,14 +70,15 @@ jQuery.fn.extend({
0;
for ( ; i < l; i++ ) {
for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) {
for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
// Always skip document fragments
if ( cur.nodeType < 11 && (pos ?
pos.index(cur) > -1 :
if ( cur.nodeType < 11 && ( pos ?
pos.index( cur ) > -1 :
// Don't pass non-elements to Sizzle
cur.nodeType === 1 &&
jQuery.find.matchesSelector(cur, selectors)) ) {
jQuery.find.matchesSelector( cur, selectors ) ) ) {
matched.push( cur );
break;
@ -93,18 +95,19 @@ jQuery.fn.extend({
// No argument, return index in parent
if ( !elem ) {
return ( this[0] && this[0].parentNode ) ? this.first().prevAll().length : -1;
return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
}
// index in selector
if ( typeof elem === "string" ) {
return jQuery.inArray( this[0], jQuery( elem ) );
return jQuery.inArray( this[ 0 ], jQuery( elem ) );
}
// Locate the position of the desired element
return jQuery.inArray(
// If it receives a jQuery object, the first element is used
elem.jquery ? elem[0] : elem, this );
elem.jquery ? elem[ 0 ] : elem, this );
},
add: function( selector, context ) {
@ -117,10 +120,10 @@ jQuery.fn.extend({
addBack: function( selector ) {
return this.add( selector == null ?
this.prevObject : this.prevObject.filter(selector)
this.prevObject : this.prevObject.filter( selector )
);
}
});
} );
function sibling( cur, dir ) {
do {
@ -130,7 +133,7 @@ function sibling( cur, dir ) {
return cur;
}
jQuery.each({
jQuery.each( {
parent: function( elem ) {
var parent = elem.parentNode;
return parent && parent.nodeType !== 11 ? parent : null;
@ -181,6 +184,7 @@ jQuery.each({
}
if ( this.length > 1 ) {
// Remove duplicates
if ( !guaranteedUnique[ name ] ) {
ret = jQuery.uniqueSort( ret );
@ -194,7 +198,7 @@ jQuery.each({
return this.pushStack( ret );
};
});
} );
return jQuery;
});
} );

View File

@ -1,4 +1,4 @@
define([
define( [
"../core",
"../var/indexOf",
"./var/rneedsContext",
@ -13,14 +13,14 @@ function winnow( elements, qualifier, not ) {
return jQuery.grep( elements, function( elem, i ) {
/* jshint -W018 */
return !!qualifier.call( elem, i, elem ) !== not;
});
} );
}
if ( qualifier.nodeType ) {
return jQuery.grep( elements, function( elem ) {
return ( elem === qualifier ) !== not;
});
} );
}
@ -34,7 +34,7 @@ function winnow( elements, qualifier, not ) {
return jQuery.grep( elements, function( elem ) {
return ( jQuery.inArray( elem, qualifier ) > -1 ) !== not;
});
} );
}
jQuery.filter = function( expr, elems, not ) {
@ -48,10 +48,10 @@ jQuery.filter = function( expr, elems, not ) {
jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
return elem.nodeType === 1;
}));
} ) );
};
jQuery.fn.extend({
jQuery.fn.extend( {
find: function( selector ) {
var i,
ret = [],
@ -59,13 +59,13 @@ jQuery.fn.extend({
len = self.length;
if ( typeof selector !== "string" ) {
return this.pushStack( jQuery( selector ).filter(function() {
return this.pushStack( jQuery( selector ).filter( function() {
for ( i = 0; i < len; i++ ) {
if ( jQuery.contains( self[ i ], this ) ) {
return true;
}
}
}) );
} ) );
}
for ( i = 0; i < len; i++ ) {
@ -75,10 +75,10 @@ jQuery.fn.extend({
return this.pushStack( len > 1 ? jQuery.uniqueSort( ret ) : ret );
},
filter: function( selector ) {
return this.pushStack( winnow(this, selector || [], false) );
return this.pushStack( winnow( this, selector || [], false ) );
},
not: function( selector ) {
return this.pushStack( winnow(this, selector || [], true) );
return this.pushStack( winnow( this, selector || [], true ) );
},
is: function( selector ) {
return !!winnow(
@ -92,6 +92,6 @@ jQuery.fn.extend({
false
).length;
}
});
} );
});
} );

View File

@ -1,6 +1,6 @@
define([
define( [
"../../core",
"../../selector"
], function( jQuery ) {
return jQuery.expr.match.needsContext;
});
} );

View File

@ -1,4 +1,5 @@
define(function() {
define( function() {
// [[Class]] -> type pairs
return {};
});
} );

View File

@ -1,5 +1,5 @@
define([
define( [
"./deletedIds"
], function( deletedIds ) {
return deletedIds.concat;
});
} );

View File

@ -1,3 +1,3 @@
define(function() {
define( function() {
return [];
});
} );

View File

@ -1,3 +1,3 @@
define(function() {
define( function() {
return window.document;
});
} );

View File

@ -1,5 +1,5 @@
define([
define( [
"./document"
], function( document ) {
return document.documentElement;
});
} );

View File

@ -1,5 +1,5 @@
define([
define( [
"./class2type"
], function( class2type ) {
return class2type.hasOwnProperty;
});
} );

View File

@ -1,5 +1,5 @@
define([
define( [
"./deletedIds"
], function( deletedIds ) {
return deletedIds.indexOf;
});
} );

View File

@ -1,3 +1,3 @@
define(function() {
return (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source;
});
define( function() {
return ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
} );

View File

@ -1,5 +1,5 @@
define([
define( [
"./deletedIds"
], function( deletedIds ) {
return deletedIds.push;
});
} );

View File

@ -1,7 +1,7 @@
define([
define( [
"../var/pnum"
], function( pnum ) {
return new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
});
} );

View File

@ -1,3 +1,3 @@
define(function() {
return (/\S+/g);
});
define( function() {
return ( /\S+/g );
} );

Some files were not shown because too many files have changed in this diff Show More