diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 00000000..a3f79a92
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,8 @@
+; Unix-style newlines
+[*]
+end_of_line = LF
+
+; Tab indentation (no size specified)
+[*.js]
+indent_style = tab
+indent_size = 4
diff --git a/.gitignore b/.gitignore
index b55e4c35..75eb2460 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,9 @@ dist
*node_modules*
build/github/jquerypp
docs/*
+npm-debug.log
+build/ci/can
+build/ci/jquery
+build/ci/funcunit
+build/ci/steal
+dist/
\ No newline at end of file
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 00000000..96725b65
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,54 @@
+{
+ "globals": {
+
+ "steal": true,
+ "can": true,
+
+
+ "Zepto": true,
+
+
+ "QUnit": true,
+ "test": true,
+ "asyncTest": true,
+ "expect": true,
+ "module": true,
+ "ok": true,
+ "equal": true,
+ "notEqual": true,
+ "deepEqual": true,
+ "notDeepEqual": true,
+ "strictEqual": true,
+ "notStrictEqual": true,
+ "raises": true,
+ "start": true,
+ "stop": true
+ },
+
+
+ "curly": true,
+ "eqeqeq": true,
+ "freeze": true,
+ "indent": 2,
+ "latedef": true,
+ "noarg": true,
+ "undef": true,
+ "unused": "vars",
+ "trailing": true,
+ "maxdepth": 4,
+ "boss" : true,
+
+ "eqnull": true,
+ "evil": true,
+ "loopfunc": true,
+ "smarttabs": true,
+ "maxerr" : 200,
+
+ "jquery": true,
+ "dojo": true,
+ "mootools": true,
+ "yui": true,
+ "browser": true,
+ "phantom": true,
+ "rhino": true
+}
diff --git a/.npmignore b/.npmignore
new file mode 100644
index 00000000..05a9d0cf
--- /dev/null
+++ b/.npmignore
@@ -0,0 +1 @@
+!dist/
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 00000000..7fbd8557
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,5 @@
+language: node_js
+before_install:
+ - "export DISPLAY=:99.0"
+ - "sh -e /etc/init.d/xvfb start"
+node_js: 0.10
diff --git a/1x1.jpg b/1x1.jpg
new file mode 100644
index 00000000..b0d69110
Binary files /dev/null and b/1x1.jpg differ
diff --git a/Gruntfile.js b/Gruntfile.js
new file mode 100644
index 00000000..394c62a9
--- /dev/null
+++ b/Gruntfile.js
@@ -0,0 +1,104 @@
+var path = require('path');
+var normalize = function(depName, depLoad, curName, curLoad) {
+ depName = depName.substring(depName.indexOf('#') + 1, depName.length);
+
+ if(depName === 'dist/jquery') {
+ return 'jquery';
+ }
+
+ if(curLoad) {
+ depName = path.relative(path.dirname(curLoad.address), depLoad.address);
+ if(depName[0] !== '.') {
+ depName = './' + depName;
+ }
+ }
+
+ return depName;
+};
+
+module.exports = function (grunt) {
+ var _ = grunt.util._;
+ var builderJSON = grunt.file.readJSON('builder.json');
+ var pkg = grunt.file.readJSON('package.json');
+
+ grunt.initConfig({
+ jshint: {
+ options: {
+ jshintrc: true
+ },
+ lib: [
+ 'dom/**/*.js', 'event/**/*.js', 'lang/**/*.js', 'test/**/*.js'
+ ]
+ },
+
+ 'steal-export': {
+ dist: {
+ system: {
+ config: "package.json!npm",
+ main: "jquerypp"
+ },
+ outputs: {
+ "cjs": {
+ graphs: ['jquerypp'],
+ format: 'cjs',
+ useNormalizedDependencies: true,
+ ignore: ['jquery'],
+ normalize: normalize,
+ dest: function(moduleName){
+ return path.join(__dirname, 'dist/cjs/' + normalize(moduleName) + '.js');
+ }
+ },
+ "amd": {
+ graphs: ['jquerypp'],
+ format: 'amd',
+ useNormalizedDependencies: true,
+ ignore: ['jquery'],
+ normalize: normalize,
+ dest: function(moduleName){
+ return path.join(__dirname, 'dist/amd/' + normalize(moduleName) + '.js');
+ }
+ },
+ "+global-js": {
+ ignore: ['jquery'],
+ exports: { 'jquery/jquery': 'jQuery' }
+ },
+ 'min +global-js': {
+ minify: true,
+ dest: path.join(__dirname, 'dist/global/jquerypp.min.js')
+ }
+ }
+ }
+ },
+
+ usebanner: {
+ taskName: {
+ options: {
+ position: 'top',
+ banner: _.template(builderJSON.banner, {
+ pkg: pkg,
+ ids: [ 'jQuery++ dist build' ]
+ }),
+ linebreak: true
+ },
+ files: {
+ src: [ 'dist/**/*.js' ]
+ }
+ }
+ },
+
+ testee: {
+ options: {
+ browsers: [ 'firefox' ]
+ },
+ all: ['test.html']
+ }
+ });
+
+ grunt.loadNpmTasks('grunt-contrib-jshint');
+ grunt.loadNpmTasks('testee');
+ grunt.loadNpmTasks('steal-tools');
+ grunt.loadNpmTasks('grunt-banner');
+
+ grunt.registerTask('test', ['testee']);
+ grunt.registerTask('build', ['steal-export', 'usebanner']);
+};
diff --git a/bower.json b/bower.json
new file mode 100644
index 00000000..914e3ce5
--- /dev/null
+++ b/bower.json
@@ -0,0 +1,17 @@
+{
+ "name": "jquerypp",
+ "title": "jQuery++",
+ "version": "2.0.0",
+ "repo": "bitovi/canjs",
+ "description": "jQuery's missing utils and special events",
+ "main": "can.jquery.js",
+ "keywords": [
+ "mvc",
+ "canjs",
+ "can",
+ "requirejs",
+ "component",
+ "amd"
+ ],
+ "license": "MIT"
+}
\ No newline at end of file
diff --git a/build/amdify.js b/build/amdify.js
deleted file mode 100644
index 017d50cf..00000000
--- a/build/amdify.js
+++ /dev/null
@@ -1,140 +0,0 @@
-steal('steal/build', 'steal/build/pluginify', function(steal) {
- var contents = {},
- modules = {},
- inexcludes = function(excludes, src) {
- for(var i = 0; i < excludes.length; i++) {
- if(src.indexOf(excludes[i]) !== -1) {
- return true;
- }
- }
- return false;
- },
- /**
- * Creates a variable name from a filename or AMD module name.
- *
- * @param {String} name The name of the AMD module or file
- * @return {String} The variable name
- */
- variableName = function(name) {
- var start = name.lastIndexOf('/') + 1,
- end = name.lastIndexOf('.') !== -1 ? name.lastIndexOf('.') : name.length;
- return '__' + name.substring(start, end).replace(/\./g, '_');
- },
- /**
- * Returns a steal.File instance from a filename or AMD module name.
- *
- * @param name
- * @param suffix
- * @return {*}
- */
- getFile = function(name, suffix) {
- var suffix = suffix || '.js', file = name;
- if(name.indexOf(suffix, name.length - suffix.length) === -1) {
- file = file + suffix;
- }
- return steal.File(file);
- },
- /**
- * Returns a list of steal dependencies for a given file and caches
- * the plain content.
- *
- * @param {String} file The JavaScript file to load
- * @param {Array} excludes A list of dependencies to exclude
- * @param {Object} options Options
- * @param {Function} callback A callback getting passed an array
- * of steals
- */
- getDependencies = function(file, excludes, options, callback) {
- steal.build.open("steal/rhino/empty.html", {
- startFile : file,
- skipCallbacks: true
- }, function(opener){
- var ret = [];
- opener.each(function(stl, text){
- if(!inexcludes(excludes || [], stl.rootSrc.toString())) {
- // Add the parsed content to cache
- if(!contents[stl.rootSrc.toString().toString()]) {
- contents[stl.rootSrc.toString()] = steal.build.pluginify.content(stl, options, text);
- }
- ret.push(stl);
- }
- });
- callback(ret);
- }, null);
- },
- /**
- * Creates the actual module recursively
- *
- * @param {String} name The name of the main module file
- * @param {Array} excludes A list of files to exclude
- * @param {Object} options The options to use
- */
- createModule = function(name, excludes, options) {
- getDependencies(name, excludes, options, function(steals) {
- var content,
- dependencies = [],
- names = [],
- nameMap = options.names || {},
- map = options.map || {},
- where = getFile(options.out + (map[name] || name));
-
- print(' > ' + name + ' -> ' + (map[name] || name));
-
- steals.forEach(function(stl) {
- var current = (map[stl.rootSrc.toString()] || stl.rootSrc.toString());
- if(stl.rootSrc.toString() !== name) { // Don't include the current file
- if(!modules[stl.rootSrc.toString()]) {
- createModule(stl.rootSrc.toString(), excludes, options);
- }
- dependencies.push("'" + current + "'");
- names.push(nameMap[current] || variableName(current));
- }
- });
-
- content = "define([" +
- dependencies.join(',') +
- '], function(' +
- names.join(', ') +
- ') { \n' +
- (contents[name] || (' return ' + (options.global || '{}'))) +
- ';\n})';
-
- modules[name] = content;
-
- steal.File(where.dir()).mkdirs();
- where.save(content);
- });
- };
-
- /**
- * Creates a set of AMD modules recursively. The `map` options contain a mapping from Steal
- * rootSrc filenames to AMD module names. For examples:
- *
- * { "jquery/dom/compare/compare.js" : "jquerypp/compare" }
- *
- * Will map "jquery/dom/compare/compare.js" to "jquerypp/compare.js" in the output folder
- * and all dependencies as well (e.g. dependent files would `define(['jquery/compare'], ...)`.
- * By default it will use the Steal rootSrc name.
- * The `names` mapping can be used to map AMD module names to variable names passed to the
- * pluginified function. By default this will be the filename without extension, `__` prefixed and
- * `.` converted to `_` (looking like `define(['jquery/compare`], function(__compare) { ... })`).
- *
- * @param {String} source The root JavaScript source file name to generate the modules from.
- * @param {Object} options The options for generating AMD modules.
- * The following options will be used:
- *
- * - `out` - The output folder
- * - `excludes` - An array of files to exclude (must be the full Steal rootSrc)
- * - `map` - A mapping from full Steal rootSrc filenames to the AMD module name.
- * Any missing folders will be created automatically.
- * - `names` - A mapping from AMD module names (as set in `map` or the default)
- * to parameter variable names.
- * - `global` - The global option passed to pluginify
- */
- steal.build.amdify = function(source, options) {
- var out = options.out;
- print('Creating AMD modules for ' + source + " in " + options.out);
- steal.File(out).mkdirs();
- createModule(source, options.exclude || {}, options);
- }
-});
diff --git a/build/docco/.gitignore b/build/docco/.gitignore
deleted file mode 100644
index 0820d537..00000000
--- a/build/docco/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-temp
-docs
diff --git a/build/docco/generate.js b/build/docco/generate.js
deleted file mode 100644
index 8f14d00f..00000000
--- a/build/docco/generate.js
+++ /dev/null
@@ -1,146 +0,0 @@
-var path = require('path'),
- fs = require('fs'),
- child_process = require('child_process'),
- os = require('os'),
-
- // Resolve directories
- rhinoDir = path.join( path.dirname( fs.realpathSync( __filename )), '../../..' ),
- jqueryDir = path.join( rhinoDir, 'jquery' ),
- docsDir = path.join( jqueryDir, "docs" ),
- doccoDir = path.join( jqueryDir, "build/docco" ),
- doccoOutDir = path.join( doccoDir, "docs" ),
- sourceDir = path.join( doccoDir, 'standalone' ),
- makePath = path.join( doccoDir, "makestandalone.js" ),
- genCommand;
-
-function execCommandWithOutput( command, cwd, callback ) {
-
- var spawn, parts;
-
- parts = command.split(" ");
- spawn = child_process.spawn( parts.shift(), parts, {
- cwd : cwd,
- env : process.env
- });
-
- ["stdout", "stderr"].forEach( function( stream ) {
- spawn[stream].setEncoding("utf-8");
- spawn[stream].pipe( process[stream] );
- });
-
- spawn.on("exit", callback );
-
-}
-
-function runDocco() {
-
- fs.mkdir(docsDir, function() {
-
- fs.readdir( path.join( doccoDir, "temp" ), function( err, files ) {
-
- files = files.map(function( file ) {
- return path.join( "temp", file );
- });
-
- var command = os.platform() != "win32" ?
- "node_modules/docco/bin/docco " :
- "sh node_modules/docco/bin/docco ";
-
- console.log( "Generating docco annotated source..." );
-
-
- execCommandWithOutput( command + files.join(" "), doccoDir, function( exitCode ) {
- if ( exitCode == 0 ) {
- fs.readdir( doccoOutDir, function( err, files ) {
- console.log("Moving files into place...");
- files.forEach(function( file ) {
- console.log( "\t" + file );
- fs.renameSync( path.join( doccoDir, "docs", file ), path.join( jqueryDir, "docs", file ));
- });
- console.log("Cleaning up...");
- ["temp", "standalone", "docs"].forEach(function( dir ) {
- fs.readdir( path.join( doccoDir, dir ), function( e, files ) {
- files.forEach(function( file ) {
- fs.unlinkSync( path.join( doccoDir, dir, file ));
- });
- fs.rmdir( path.join( doccoDir, dir ));
- });
- });
- console.log("Done!");
- });
- } else {
- console.log("Error generating annotated source.");
- }
- });
-
- });
-
-
- });
-
-}
-
-function format( exitCode ) {
-
- if ( exitCode != 0 ) {
- console.log("Error generating unminified sources.");
- return
- }
-
- fs.readdir( sourceDir, function( err, files ) {
-
- var count = 0;
-
- if ( ! files.length ) {
- console.log("Error - Source directory is empty");
- }
-
- // Only annotate full srcs
- files = files.filter(function( file ) {
- return file.indexOf(".min.") < 0;
- });
-
- // Create the temp directory for stripped code
- fs.mkdir( path.join( doccoDir, "temp"), function() {
-
- // Generate source for all standalones
- console.log( "Stripping multiline comments and steal removes..." );
- console.log( "Converting tabs to 4 spaces." );
-
- files.forEach(function( file ) {
- fs.readFile( path.join( sourceDir, file ), "utf-8", function( err, code ) {
- console.log( "\t" + file );
-
- // Remove multiline comments
- code = code.replace( /\/\*(?:.*)(?:\n\s+\*.*)*\n/gim, "");
-
- // Remove double semicolons from steal pluginify
- code = code.replace( /;[\s]*;/gim, ";");
- code = code.replace( /(\/\/.*)\n[\s]*;/gi, "$1");
-
- // Tabs -> four spaces
- code = code.replace( /\t/gim, " ");
-
- // Only single new lines
- code = code.replace( /(\n){3,}/gim, "\n\n");
-
- fs.writeFile( path.join( doccoDir, "temp", file ), code, "utf-8", function() {
- if ( ++count == files.length ) {
- runDocco();
- }
- });
- });
- });
- });
- });
-}
-
-console.log("Generating unminified sources...");
-
-if ( os.platform() != "win32" ) {
- genCommand = "./js " + makePath;
-} else {
- genCommand = "js.bat " + makePath;
-}
-
-execCommandWithOutput( genCommand, rhinoDir, format );
diff --git a/build/docco/makestandalone.js b/build/docco/makestandalone.js
deleted file mode 100644
index cf70d2ca..00000000
--- a/build/docco/makestandalone.js
+++ /dev/null
@@ -1,47 +0,0 @@
-load("steal/rhino/rhino.js");
-steal('jquery/build/extract.js', 'steal/clean', function() {
-
- var out = "jquery/build/docco/standalone/",
- excludes = [ 'steal/dev',
- "can/util/jquery/jquery.1.7.1.js",
- "jquery/build/lib.js" ],
- plugins = {
- "jquery/dom/animate/animate.js" : "jquery.animate.js",
- "jquery/dom/compare/compare.js" : "jquery.compare.js",
- "jquery/dom/cookie/cookie.js" : "jquery.cookie.js",
- "jquery/dom/dimensions/dimensions.js" : "jquery.dimensions.js",
- "jquery/dom/form_params/form_params.js" : "jquery.form_params.js",
- "jquery/dom/range/range.js" : "jquery.range.js",
- "jquery/dom/selection/selection.js" : "jquery.selection.js",
- "jquery/dom/styles/styles.js" : "jquery.styles.js",
- "jquery/dom/within/within.js" : "jquery.within.js",
- "jquery/event/default/default.js" : "jquery.event.default.js",
- "jquery/event/destroyed/destroyed.js" : "jquery.event.destroyed.js",
- "jquery/event/drag/drag.js" : "jquery.event.drag.js",
- "jquery/event/drop/drop.js" : "jquery.event.drop.js",
- "jquery/event/fastfix/fastfix.js" : "jquery.event.fastfix.js",
- "jquery/event/hover/hover.js" : "jquery.event.hover.js",
- "jquery/event/key/key.js" : "jquery.event.key.js",
- "jquery/event/pause/pause.js" : "jquery.event.pause.js",
- "jquery/event/resize/resize.js" : "jquery.event.resize.js",
- "jquery/event/swipe/swipe.js" : "jquery.event.swipe.js",
- "jquery/event/livehack/livehack.js" : "jquery.event.livehack.js",
- "jquery/lang/json/json.js" : "jquery.lang.json.js",
- "jquery/lang/vector/vector.js" : "jquery.lang.vector.js"
- };
-
- steal.File(out).mkdirs();
-
- steal.build.extract(plugins, {
- skipCallbacks: true,
- exclude : excludes.concat([
- 'jquery/dom/dom.js', 'jquery/event/event.js', 'jquery/jquery.js'
- ]),
- out : out
- });
-
- for(var name in plugins) {
- console.log("Cleaning " + out + plugins[name]);
- steal.clean(out + plugins[name]);
- }
-});
diff --git a/build/docco/package.json b/build/docco/package.json
deleted file mode 100644
index 8811690c..00000000
--- a/build/docco/package.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "name": "docco-generator",
- "version" : "0.0.1",
- "dependencies": {
- "docco": ">= 0.1.x"
- },
- "engine": "node >= 0.6.x"
-}
diff --git a/build/extract.js b/build/extract.js
deleted file mode 100644
index 7d541324..00000000
--- a/build/extract.js
+++ /dev/null
@@ -1,50 +0,0 @@
-steal('steal/build/pluginify', function(steal) {
- var inexcludes = function(excludes, src) {
- for(var i = 0; i < excludes.length; i++) {
- if(src.indexOf(excludes[i]) !== -1) {
- return true;
- }
- }
- return false;
- },
- getDependencies = function(file, options, callback) {
- steal.build.open("steal/rhino/empty.html", {
- startFile : file,
- skipCallbacks: true
- }, function(opener){
- var ret = [];
- opener.each(function(stl, text){
- if(!inexcludes(options.exclude || [], stl.rootSrc.toString())) {
- ret.push(stl);
- }
- });
- callback(ret);
- }, null);
- };
-
- steal.build.extract = function(plugins, options) {
- var ops = steal.extend({ global : 'jQuery' }, options);
- steal.File(ops.out).mkdirs();
- print('Extracting plugin files');
- for(var file in plugins) {
- var content = "";
-
- getDependencies(file, ops, function(steals) {
- if(steals.length > 1) {
- content += "// Dependencies:\n//\n";
- }
- steals.forEach(function(stl) {
- if(stl.rootSrc !== file) {
- content += "// - " + (plugins[stl.rootSrc] || stl.rootSrc) + "\n";
- }
- });
- if(steals.length > 1) {
- content += "\n";
- }
- content += steal.build.pluginify.content({ rootSrc : file }, ops);
- new steal.File(options.out + plugins[file]).save(content);
- print(' > ' + file + ' -> ' + plugins[file]);
- });
- }
- }
-});
diff --git a/build/github/package.json b/build/github/package.json
deleted file mode 100644
index 0312e102..00000000
--- a/build/github/package.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "name": "github-download-updater",
- "version" : "0.0.1",
- "dependencies": {
- "commander": ">= 0.1.x",
- "github": ">= 0.1.x",
- "underscore" : ">= 0.1.x",
- "underscore.deferred" : ">= 0.1.x",
- "tafa-misc-util" : ">= 0.1.x",
- "mime" : ">= 1.2.5"
- },
- "engine": "node >= 0.6.x"
-}
diff --git a/build/github/s3-post.js b/build/github/s3-post.js
deleted file mode 100644
index 0f078d52..00000000
--- a/build/github/s3-post.js
+++ /dev/null
@@ -1,106 +0,0 @@
-// Generated by CoffeeScript 1.3.1
-(function() {
- var crypto, https, joinBuffers, postToS3, readText, signPolicy, url, _ref;
-
- url = require('url');
-
- https = require('https');
-
- crypto = require('crypto');
-
- _ref = require('tafa-misc-util'), joinBuffers = _ref.joinBuffers, readText = _ref.readText;
-
- signPolicy = function(secretKey, policy) {
- var data, hmac, json, key, policy64, signature64;
- json = JSON.stringify(policy);
- policy64 = new Buffer(json).toString('base64');
- data = new Buffer(policy64, 'utf-8');
- key = new Buffer(secretKey, 'utf-8');
- hmac = crypto.createHmac('sha1', key);
- hmac.update(data);
- signature64 = hmac.digest('base64');
- return {
- signature64: signature64,
- policy64: policy64
- };
- };
-
- postToS3 = function(_arg, callback) {
- var AWSAccessKeyId, Filename, acl, addParam, arr, boundary, bucket, buf, ca, contentType, customUrl, data, host, hostname, key, options, policy64, port, protocol, req, req_body, signature64, success_action_status, _ref1;
- AWSAccessKeyId = _arg.AWSAccessKeyId, policy64 = _arg.policy64, signature64 = _arg.signature64, bucket = _arg.bucket, key = _arg.key, data = _arg.data, boundary = _arg.boundary, customUrl = _arg.customUrl, ca = _arg.ca, acl = _arg.acl, success_action_status = _arg.success_action_status, Filename = _arg.Filename, contentType = _arg.contentType;
- if (callback == null) {
- callback = (function() {});
- }
- if (customUrl) {
- _ref1 = url.parse(customUrl), protocol = _ref1.protocol, hostname = _ref1.hostname, port = _ref1.port;
- if (protocol !== "https:") {
- return callback(new Error("customUrl must be https://"));
- }
- host = hostname;
- port || (port = 443);
- } else {
- host = "" + bucket + ".s3.amazonaws.com";
- port = 443;
- }
- boundary || (boundary = '----------R46EARkAg4SAXSjufGsb6m');
- buf = function(x) {
- return new Buffer(x);
- };
- arr = [];
- addParam = function(k, v) {
- arr.push(buf('--' + boundary + '\r\n'));
- arr.push(buf('Content-Disposition: form-data; name="' + k + '"\r\n\r\n'));
- return arr.push(buf(v), buf('\r\n'));
- };
- addParam('key', key);
- addParam('acl', acl);
- addParam('success_action_status', success_action_status);
- addParam('Filename', Filename);
- addParam('AWSAccessKeyId', AWSAccessKeyId);
- addParam('Policy', policy64);
- addParam('Signature', signature64);
- addParam('Content-Type', contentType);
- console.log(arr.join(""));
- arr.push(buf('--' + boundary + '\r\n'));
- arr.push(buf('Content-Disposition: form-data; name="file"; filename="data"\r\n'));
- arr.push(buf("Content-Length: " + data.length + "\r\n"));
- arr.push(buf('Content-Transfer-Encoding: binary\r\n\r\n'));
- arr.push(data, buf('\r\n'));
- arr.push(buf('--' + boundary + '--'));
- req_body = joinBuffers(arr);
- options = {
- host: host,
- port: port,
- path: '/',
- method: 'POST',
- headers: {
- 'Host': "" + bucket + ".s3.amazonaws.com",
- 'Content-Type': 'multipart/form-data; boundary=' + boundary,
- 'Content-Length': req_body.length
- }
- };
- if (ca) {
- options.ca = ca;
- }
- req = https.request(options, function(res) {
- var _ref2;
- if ((200 <= (_ref2 = res.statusCode) && _ref2 < 300)) {
- return callback(null);
- } else {
- return readText(res, function(text) {
- return callback({
- responseCode: res.statusCode,
- responseText: text
- });
- });
- }
- });
- return req.end(req_body);
- };
-
- module.exports = {
- postToS3: postToS3,
- signPolicy: signPolicy
- };
-
-}).call(this);
\ No newline at end of file
diff --git a/build/github/update-download.js b/build/github/update-download.js
deleted file mode 100644
index 197c2b44..00000000
--- a/build/github/update-download.js
+++ /dev/null
@@ -1,273 +0,0 @@
-var path = require("path"),
- fs = require("fs"),
- spawn = require("child_process").spawn,
-
-// Third party modules
- program = require("commander"),
- GitHubApi = require("github"),
- _ = require("underscore"),
- s3p = require("./s3-post.js"),
- mime = require('mime'),
-
-// Get the current version
- version = fs.readFileSync(path.join(__dirname, "../version")).toString("utf8").trim(),
-
-// Describe all the files we'll be uploading to Github
- descriptions = {
- "jquerypp.js" : "jQuery++ #{VERSION} - All plugins",
- },
-
-// Figure out some paths
- rhinoPath = path.join(__dirname, "../../.."),
- distPathShort = "jquery/dist/",
- distPath = path.join(__dirname, "../../dist"),
-
-// Github client
- github = new GitHubApi({
- version : "3.0.0"
- }),
- remote = "git@github.com:jupiterjs/jquerypp.git",
-
-// Timeouts
- stealTimeout,
-
-// For Github credentials
- username,
- password,
-
-// For steal build process
- pluginify;
-
-// Get deferreds
-_.mixin(require("underscore.deferred"));
-
-function updateDist() {
- console.log("Copying built files to gh-pages.");
-
- var clone = spawn("git", [ "clone", remote ], {
- cwd : __dirname
- }), dfd = new _.Deferred();
-
- clone.on("exit", function () {
-
- var clonePath = path.join(__dirname, "jquerypp"),
- checkout = spawn("git", [ "checkout", "gh-pages"], {
- cwd : clonePath
- });
-
- checkout.on("exit", function () {
- var cloneReleasePath = path.join(clonePath, "release"),
- latestPath = path.join(cloneReleasePath, "latest"),
- versionPath = path.join(cloneReleasePath, version);
- // Make sure directories exist
- [ cloneReleasePath, versionPath, latestPath ].forEach(function (dir) {
- if (!path.existsSync(dir)) {
- fs.mkdirSync(dir);
- }
- });
-
- fs.readdir(distPath, function (err, files) {
- var dfds = files.map(function (file) {
- var dfd = new _.Deferred(),
- inPath, outPath, latestOutPath,
- inStream;
-
- if(file.match(/.*\.js/)) {
- inPath = path.join(distPath, file),
- outPath = path.join(versionPath, file),
- latestOutPath = path.join(latestPath, file),
- inStream = fs.createReadStream(inPath);
- inStream.pipe(fs.createWriteStream(outPath));
- inStream.pipe(fs.createWriteStream(latestOutPath));
-
- inStream.on("end", function () {
- dfd.resolve();
- });
- } else {
- dfd.resolve();
- }
-
- return dfd.promise();
-
- });
-
- _.when.apply(_, dfds).done(function () {
- console.log("Finished copying files. Cleaning up...")
- var add = spawn("git", ["add", "release/*"], {
- cwd : clonePath
- });
-
- add.on("exit", function () {
- var commit = spawn("git", ["commit", "-m", "Generated release files for " + version ], {
- cwd : clonePath
- });
-
- commit.on("exit", function () {
- var push = spawn("git", ["push", "origin", "gh-pages"], {
- cwd : clonePath
- });
-
- push.on("exit", function () {
-
- var remove = spawn("rm", ["-rf", "jquerypp"], {
- cwd : __dirname
- });
- console.log("Done!")
-
- });
- });
- });
- });
- });
- });
-
- });
-
- return dfd.promise();
-}
-
-// Upload files to the Github downloads page
-function uploadFiles() {
- console.log('Uploading files');
-
- var dfd = new _.Deferred(),
- dfds = _.map(descriptions, function (desc, filename) {
-
- var dfd = new _.Deferred();
-
- desc = desc.replace("#{VERSION}", version);
-
- fs.readFile(path.join(distPath, filename), function (err, buf) {
- console.log('Uploading ' + filename + ' MIME type ' + mime.lookup(filename));
-
- github.httpSend({
- "user" : "jupiterjs",
- "repo" : "jquerypp",
- "name" : filename,
- "size" : buf.length,
- "description" : desc,
- "content_type" : mime.lookup(filename)
- }, {
- "url" : "/repos/:user/:repo/downloads",
- "method" : "POST",
- "params" : {
- "$user" : null,
- "$repo" : null,
- "$name" : null,
- "$size" : null,
- "description" : null,
- "$content_type" : null
- }
- }, function (err, socket) {
- console.log(err);
- var data = JSON.parse(socket.data);
-
-
- s3p.postToS3({
- key : data.path,
- acl : data.acl,
- success_action_status : "201",
- Filename : data.name,
- AWSAccessKeyId : data.accesskeyid,
- policy64 : data.policy,
- signature64 : data.signature,
- contentType : data.mime_type,
- data : buf,
- bucket : "github"
- }, function (e) {
- if (e) {
- console.log(e);
- }
- dfd.resolve();
- })
-
- });
-
- });
-
- return dfd.promise();
- });
-
- _.when.apply(_, dfds).done(dfd.resolve.bind(dfd));
-
- return dfd.promise();
-}
-
-function stealBuild() {
-
- var dfd = new _.Deferred(),
- zipFile;
-
- // Run Steal build script
- pluginify = spawn(rhinoPath + "/js", ["jquery/build/make.js"], {
- cwd : rhinoPath
- });
-
- pluginify.on("exit", function (code) {
- // Create a zip file
- // tar -cvzf jquery/dist/jquerypp.tar.gz jquery/dist
- zipFile = 'jquerypp-' + version + '.zip';
- descriptions[zipFile] = "jQuery++ #{VERSION} - Full download";
- spawn("zip", ["-r", zipFile, '.'], {
- cwd : distPath
- }).on("exit", function () {
- console.log("Done creating ZIP file " + zipFile);
- dfd.resolve(code);
- });
- });
-
- return dfd.promise();
-}
-
-// Clean up on process exit
-process.on("exit", function () {
- process.stdout.write("\n")
-})
-
-// Get Github credentials
-function getCredentials() {
-
- var dfd = new _.Deferred();
-
- program.prompt("Github Username: ", function (name) {
- username = name;
-
- program.password("Github Password: ", "*", function (pass) {
- var timeout;
- password = pass;
- process.stdin.pause();
-
- github.authenticate({
- type : "basic",
- username : username,
- password : password
- });
-
- process.stdout.write("Building jQuery++...")
- stealTimeout = setInterval(function () {
- process.stdout.write(".")
- }, 1000)
- dfd.resolve();
- })
-
- });
-
- return dfd.promise();
-}
-
-_.when(stealBuild(), getCredentials()).done(function (code) {
- console.log('Built and got credentials');
-
- if (stealTimeout) {
- clearTimeout(stealTimeout);
- process.stdout.write(" Done!\n")
- }
-
- console.log(code);
- if (code != 0) {
- console.log("Steal build process failed.")
- } else {
- _.when(uploadFiles(), updateDist()).done(function () {
- });
- }
-});
diff --git a/build/lib.js b/build/lib.js
deleted file mode 100644
index fc3c0eef..00000000
--- a/build/lib.js
+++ /dev/null
@@ -1,25 +0,0 @@
-steal(
- "jquery/dom/animate",
- "jquery/dom/compare",
- "jquery/dom/cookie",
- "jquery/dom/dimensions",
- "jquery/dom/fills",
- "jquery/dom/form_params",
- "jquery/dom/range",
- "jquery/dom/selection",
- "jquery/dom/styles",
- "jquery/dom/within",
- "jquery/event/default",
- "jquery/event/destroyed",
- "jquery/event/drag",
- 'jquery/event/drag/limit',
- 'jquery/event/drag/scroll',
- 'jquery/event/drag/step',
- "jquery/event/drop",
- "jquery/event/fastfix",
- "jquery/event/hover",
- "jquery/event/key",
- "jquery/event/pause",
- "jquery/event/resize",
- "jquery/event/swipe"
-)
\ No newline at end of file
diff --git a/build/make.js b/build/make.js
deleted file mode 100644
index 8f550077..00000000
--- a/build/make.js
+++ /dev/null
@@ -1,102 +0,0 @@
-
-load("steal/rhino/rhino.js");
-steal('steal/build/pluginify', 'jquery/build/stealify.js', 'jquery/build/amdify.js', 'jquery/build/extract.js',
-function() {
-
- var out = "jquery/dist/",
- excludes = [ 'steal/dev',
- "can/util/jquery/jquery.1.7.1.js",
- "jquery/build/lib.js" ];
-
- steal.File(out).mkdirs();
-
- // Create full library
- steal.build.pluginify('jquery/build/lib.js', {
- out: out + "jquerypp.js",
- skipCallbacks: true,
- exclude : excludes.concat([
- 'jquery/dom/dom.js', 'jquery/event/event.js', 'jquery/jquery.js'
- ])
- });
-
- // Create separate files
- steal.build.extract({
- "jquery/dom/animate/animate.js" : "jquery.animate.js",
- "jquery/dom/compare/compare.js" : "jquery.compare.js",
- "jquery/dom/cookie/cookie.js" : "jquery.cookie.js",
- "jquery/dom/dimensions/dimensions.js" : "jquery.dimensions.js",
- "jquery/dom/fills/fills.js" : "jquery.fills.js",
- "jquery/dom/form_params/form_params.js" : "jquery.form_params.js",
- "jquery/dom/range/range.js" : "jquery.range.js",
- "jquery/dom/selection/selection.js" : "jquery.selection.js",
- "jquery/dom/styles/styles.js" : "jquery.styles.js",
- "jquery/dom/within/within.js" : "jquery.within.js",
- "jquery/event/default/default.js" : "jquery.event.default.js",
- "jquery/event/destroyed/destroyed.js" : "jquery.event.destroyed.js",
- "jquery/event/drag/drag.js" : "jquery.event.drag.js",
- "jquery/event/drop/drop.js" : "jquery.event.drop.js",
- "jquery/event/fastfix/fastfix.js" : "jquery.event.fastfix.js",
- "jquery/event/hover/hover.js" : "jquery.event.hover.js",
- "jquery/event/key/key.js" : "jquery.event.key.js",
- "jquery/event/pause/pause.js" : "jquery.event.pause.js",
- "jquery/event/resize/resize.js" : "jquery.event.resize.js",
- "jquery/event/swipe/swipe.js" : "jquery.event.swipe.js",
- "jquery/event/livehack/livehack.js" : "jquery.event.livehack.js",
- "jquery/lang/json/json.js" : "jquery.lang.json.js",
- "jquery/lang/vector/vector.js" : "jquery.lang.vector.js"
- }, {
- skipCallbacks: true,
- exclude : excludes.concat([
- 'jquery/dom/dom.js', 'jquery/event/event.js', 'jquery/jquery.js'
- ]),
- out : out + 'lib/'
- });
-
- // Make Steal distributable
- steal.build.stealify('jquery/build/lib.js', {
- out : out + 'steal/',
- exclude : excludes
- });
-
- // Make AMD modules
- steal.build.amdify('jquery/build/lib.js', {
- out : out + 'amd/',
- exclude : excludes.concat([
- 'jquery/dom/dom.js', 'jquery/event/event.js'
- ]),
- map : { // steal file to CommonJS module name mappings
- "jquery/jquery.js" : "jquery",
- "jquery/build/lib.js" : "jquerypp/index",
- "jquery/lang/json/json.js" : "jquerypp/util/json",
- "jquery/lang/vector/vector.js" : "jquerypp/util/vector",
- "jquery/dom/animate/animate.js" : "jquerypp/animate",
- "jquery/dom/compare/compare.js" : "jquerypp/compare",
- "jquery/dom/cookie/cookie.js" : "jquerypp/cookie",
- "jquery/dom/dimensions/dimensions.js" : "jquerypp/dimensions",
- "jquery/dom/fills/fills.js" : "jquerypp/fills",
- "jquery/dom/form_params/form_params.js" : "jquerypp/form_params",
- "jquery/dom/range/range.js" : "jquerypp/range",
- "jquery/dom/selection/selection.js" : "jquerypp/selection",
- "jquery/dom/styles/styles.js" : "jquerypp/styles",
- "jquery/dom/within/within.js" : "jquerypp/within",
- "jquery/event/default/default.js" : "jquerypp/event/default",
- "jquery/event/destroyed/destroyed.js" : "jquerypp/event/destroyed",
- "jquery/event/drag/drag.js" : "jquerypp/event/drag",
- "jquery/event/drag/limit/limit.js" : "jquerypp/event/drag.limit",
- "jquery/event/drag/scroll/scroll.js" : "jquerypp/event/drag.scroll",
- "jquery/event/drag/step/step.js" : "jquerypp/event/drag.step",
- "jquery/event/drop/drop.js" : "jquerypp/event/drop",
- "jquery/event/fastfix/fastfix.js" : "jquerypp/event/fastfix",
- "jquery/event/hover/hover.js" : "jquerypp/event/hover",
- "jquery/event/key/key.js" : "jquerypp/event/key",
- "jquery/event/livehack/livehack.js" : "jquerypp/event/livehack",
- "jquery/event/pause/pause.js" : "jquerypp/event/pause",
- "jquery/event/resize/resize.js" : "jquerypp/event/resize",
- "jquery/event/swipe/swipe.js" : "jquerypp/event/swipe"
- },
- names : { // Module name to variable name mappings
- 'jquery' : 'jQuery'
- },
- global : 'jQuery'
- });
-});
diff --git a/build/stealify.js b/build/stealify.js
deleted file mode 100644
index 1a936f21..00000000
--- a/build/stealify.js
+++ /dev/null
@@ -1,43 +0,0 @@
-steal('steal/build', function(steal) {
- var inexcludes = function(excludes, src) {
- for(var i = 0; i < excludes.length; i++) {
- if(src.indexOf(excludes[i]) !== -1) {
- return true;
- }
- }
- return false;
- };
-
- /**
- * A build plugin that copies only actual dependencies for a given file into
- * a destination folder. The destination folder content is the minimal fileset
- * you can deliver to be used with Steal.
- *
- * @param {String} source The source file to copy the dependencies for
- * @param {Object} options The following options are available:
- * - `out` - The output folder (will be created if it doesn't exist)
- * - `excludes` - An array of files to exclude from copying
- */
- steal.build.stealify = function(source, options) {
- var out = options.out || steal.File(source).dir();
- print('Copying Steal dependencies for ' + source + ' to ' + out);
- steal.File(out).mkdirs();
- steal.build.open("steal/rhino/empty.html", {
- startFile : source,
- skipCallbacks: true
- }, function(opener){
- opener.each(function(stl){
- if(!inexcludes(options.exclude || [], stl.rootSrc.toString())) {
- var file = steal.File(stl.rootSrc.toString()),
- outPath = steal.File(out + file.dir()),
- copyTo = outPath.path + '/' + file.filename();
- outPath.mkdirs();
- print(' > ' + copyTo);
- file.copyTo(copyTo);
- } else {
- print(' Ignoring ' + stl.rootSrc.toString());
- }
- })
- });
- }
-})
\ No newline at end of file
diff --git a/build/version b/build/version
deleted file mode 100644
index ad0ed1a2..00000000
--- a/build/version
+++ /dev/null
@@ -1 +0,0 @@
-1.0b
\ No newline at end of file
diff --git a/builder.json b/builder.json
new file mode 100644
index 00000000..ca989169
--- /dev/null
+++ b/builder.json
@@ -0,0 +1,121 @@
+{
+ "filename": "jquerypp.custom.js",
+ "banner": "/*!\n * <%= pkg.title || pkg.name %> - <%= pkg.version %>\n * <%= pkg.homepage %>\n * Copyright (c) <%= new Date().getFullYear() %> <%= pkg.author.name %>\n * <%= new Date().toUTCString() %>\n * Licensed <%= pkg.licenses[0].type %>\n<% if(typeof url !== \"undefined\") { %>\n * Includes: <%= ids %>\n * Download from: <%= url %>\n<% } %> */\n",
+ "modules": {
+ "jquerypp/dom/animate/animate": {
+ "name": "jQuery.animate",
+ "description": "Animate using CSS animations",
+ "type": "dom",
+ "isDefault": true
+ },
+ "jquerypp/dom/compare/compare": {
+ "name": "jQuery.compare",
+ "description": "Compare element document position",
+ "type": "dom",
+ "isDefault": true
+ },
+ "jquerypp/dom/cookie/cookie": {
+ "name": "jQuery.cookie",
+ "description": "Read and write cookies",
+ "type": "dom",
+ "isDefault": true
+ },
+ "jquerypp/dom/form_params/form_params": {
+ "name": "jQuery.formParams",
+ "description": "Serializes a form into an object",
+ "type": "dom",
+ "isDefault": true
+ },
+ "jquerypp/dom/range/range": {
+ "name": "jQuery.range",
+ "description": "Create and manipulate text ranges",
+ "type": "dom",
+ "isDefault": true
+ },
+ "jquerypp/dom/selection/selection": {
+ "name": "jQuery.selection",
+ "description": "Get and set the current text selection",
+ "type": "dom",
+ "isDefault": true
+ },
+ "jquerypp/dom/within/within": {
+ "name": "jQuery.within",
+ "description": "Get elements within an area or at a point",
+ "type": "dom",
+ "isDefault": true
+ },
+ "jquerypp/event/removed/removed": {
+ "name": "jQuery.event.removed",
+ "description": "An element is removed from the DOM",
+ "type": "event",
+ "isDefault": true
+ },
+ "jquerypp/event/drag/drag": {
+ "name": "jQuery.event.drag",
+ "description": "Delegatable drag events",
+ "type": "event",
+ "isDefault": true
+ },
+ "jquerypp/event/drop/drop": {
+ "name": "jQuery.event.drop",
+ "description": "Delegatable drop events",
+ "type": "event",
+ "isDefault": true
+ },
+ "jquerypp/event/hover/hover": {
+ "name": "jQuery.event.hover",
+ "description": "Delegatable hover events",
+ "type": "event",
+ "isDefault": true
+ },
+ "jquerypp/event/key/key": {
+ "name": "jQuery.event.key",
+ "description": "Returns a string representation of the key pressed",
+ "type": "event",
+ "isDefault": true
+ },
+ "jquerypp/event/pause/pause": {
+ "name": "jQuery.event.pause",
+ "description": "Pause and resume event propagation",
+ "type": "event",
+ "isDefault": true
+ },
+ "jquerypp/event/resize/resize": {
+ "name": "jQuery.event.resize",
+ "description": "Listen to a resize event on every object",
+ "type": "event",
+ "isDefault": true
+ },
+ "jquerypp/event/swipe/swipe": {
+ "name": "jQuery.event.swipe",
+ "description": "Delegatable swipe events",
+ "type": "event",
+ "isDefault": true
+ }
+ },
+ "types": {
+ "dom": "DOM helpers",
+ "event": "Special events"
+ },
+ "pluginify": {
+ "shim": {
+ "jquery/jquery.js": "$"
+ },
+ "wrapper": "(function($) {\n<%= content %>\n})(jQuery);\n"
+ },
+ "configurations": {
+ "default": {
+ "description": "jQuery",
+ "isDefault": true
+ }
+ },
+ "ignore": ["dojo","dojo/dojo","dojo/main",
+ "jquery","jquery/jquery",
+ "mootools/mootools","mootools",
+ "zepto","zepto/zepto",
+ "yui","yui/yui"],
+ "exports": {
+ "jquery": "jQuery",
+ "zepto": "Zepto"
+ }
+}
\ No newline at end of file
diff --git a/changelog.md b/changelog.md
new file mode 100644
index 00000000..2dd60838
--- /dev/null
+++ b/changelog.md
@@ -0,0 +1,45 @@
+### Change Log
+
+__1.0.1__
+
+- fix: [Force hover leave on new mouseenter](https://github.com/bitovi/jquerypp/pull/65)
+- fix: [Removing the element being hovered prevents all future hoverenter](https://github.com/bitovi/jquerypp/issues/64)
+- fix: [hover.leave != 0 prevents hover of next element with same selecto](https://github.com/bitovi/jquerypp/issues/63)
+- fix: [Changing jQuery references to local $](https://github.com/bitovi/jquerypp/pull/71)
+- fix: [Breaks in jQuery.noConflict(true) Scenario](https://github.com/bitovi/jquerypp/issues/67)
+- fix: [Can't download drag.limit, drag.step, and drag.scroll from downloader on website](https://github.com/bitovi/jquerypp/pull/66)
+- feature: [jQuery 1.9.x support](https://github.com/bitovi/jquerypp/commit/692ed50a7b43fb2c6bfb9d89c5e0505ddcbd6595)
+- feature: Added to the new [jQuery plugin repository](http://plugins.jquery.com/jquerypp)
+
+__1.0.0__
+
+- feature: jQuery 1.8.0+ compatibility
+- feature: [dragcleanup event](https://github.com/jupiterjs/jquerypp/pull/43)
+- feature: [Reverse and move event](https://github.com/jupiterjs/jquerypp/issues/25)
+- fix: [pass through scrollTop in animate](https://github.com/jupiterjs/jquerypp/pull/40)
+- fix: [Fastfix: Original can be undefined](https://github.com/jupiterjs/jquerypp/pull/45)
+- fix: [Animate Scroll not working](https://github.com/jupiterjs/jquerypp/issues/35)
+- fix: [.stop() does not stop callbacks from being executed](https://github.com/jupiterjs/jquerypp/issues/28)
+- fix: [jQuery.event.swipe.max isn't actually being used](https://github.com/jupiterjs/jquerypp/issues/33)
+- fix: [Range triggers error on IE8](https://github.com/jupiterjs/jquerypp/issues/39)
+- fix: [[FormParams] convertValue function: Null value to undefined (Internet Explorer Fix)](https://github.com/jupiterjs/jquerypp/pull/51)
+- fix: [HoverInit delay 0 does not trigger hoverenter if immediately moused out](https://github.com/bitovi/jquerypp/issues/57)
+
+__1.0 Beta 2__
+
+- feature: [Key mapping tool for jQuery.event.key for international characters](https://github.com/jupiterjs/jquerypp/issues/16)
+- fix: [jQuery.formParams converts disabled fields](https://github.com/jupiterjs/jquerypp/issues/24)
+- fix: [jQuery.animate supports all parameters](https://github.com/jupiterjs/jquerypp/issues/22)
+- fix: [jQuery.animate .stop() doesn't work](https://github.com/jupiterjs/jquerypp/issues/19)
+- fix: [Bug with duplicate sub keys](https://github.com/jupiterjs/jquerypp/issues/17)
+- fix: [Security error in jQuery.animate](https://github.com/jupiterjs/jquerypp/issues/5)
+- change: [jQuery.event.drag supports touch events](https://github.com/jupiterjs/jquerypp/issues/23)
+- change: [Added width property to jQuery.selection](https://github.com/jupiterjs/jquerypp/pull/11)
+- *jquerypp.com*
+ - jsFiddle examples for [cookie](#cookie), [compare](#compare), [range](#range), [styles](#styles) and [key](#key)
+ - Links to annotated sources ([e.g. jQuery.animate](http://donejs.com/jquery/docs/jquery.animate.html))
+ - Changelog and list of heroes section
+
+__1.0 Beta__
+
+- Released!
\ No newline at end of file
diff --git a/class/class.js b/class/class.js
deleted file mode 100644
index c404cab2..00000000
--- a/class/class.js
+++ /dev/null
@@ -1,8 +0,0 @@
-//jQuery.Class
-// This is a modified version of John Resig's class
-// http://ejohn.org/blog/simple-javascript-inheritance/
-// It provides class level inheritance and callbacks.
-//!steal-clean
-steal("can/construct/proxy","can/construct/super",function( $ ) {
- $.Class = can.Construct;
-})();
diff --git a/class/class_test.js b/class/class_test.js
deleted file mode 100644
index 61caa64d..00000000
--- a/class/class_test.js
+++ /dev/null
@@ -1,205 +0,0 @@
-steal("jquery/class") //load your app
- .then('funcunit/qunit').then(function(){
-
-module("jquery/class");
-
-test("Creating", function(){
-
- jQuery.Class.extend("Animal",
- {
- count: 0,
- test: function() {
- return this.match ? true : false
- }
- },
- {
- init: function() {
- this.constructor.count++;
- this.eyes = false;
- }
- }
- );
- Animal.extend("Dog",
- {
- match : /abc/
- },
- {
- init: function() {
- this._super();
- },
- talk: function() {
- return "Woof";
- }
- });
- Dog.extend("Ajax",
- {
- count : 0
- },
- {
- init: function( hairs ) {
- this._super();
- this.hairs = hairs;
- this.setEyes();
-
- },
- setEyes: function() {
- this.eyes = true;
- }
- });
- new Dog();
- new Animal();
- new Animal();
- var ajax = new Ajax(1000);
-
- equals(2, Animal.count, "right number of animals");
- equals(1, Dog.count, "right number of animals")
- ok(Dog.match, "right number of animals")
- ok(!Animal.match, "right number of animals")
- ok(Dog.test(), "right number of animals")
- ok(!Animal.test(), "right number of animals")
- equals(1, Ajax.count, "right number of animals")
- equals(2, Animal.count, "right number of animals");
- equals(true, ajax.eyes, "right number of animals");
- equals(1000, ajax.hairs, "right number of animals");
-})
-
-
-test("new instance",function(){
- var d = Ajax.newInstance(6);
- equals(6, d.hairs);
-})
-
-
-test("namespaces",function(){
- var fb = $.Class.extend("Foo.Bar")
- ok(Foo.Bar === fb, "returns class")
- equals(fb.shortName, "Bar", "short name is right");
- equals(fb.fullName, "Foo.Bar","fullName is right")
-
-})
-
-test("setups", function(){
- var order = 0,
- staticSetup,
- staticSetupArgs,
- staticInit,
- staticInitArgs,
- protoSetup,
- protoInitArgs,
- protoInit,
- staticProps = {
- setup: function() {
- staticSetup = ++order;
- staticSetupArgs = arguments;
- return ["something"]
- },
- init: function() {
- staticInit = ++order;
- staticInitArgs = arguments;
- }
- },
- protoProps = {
- setup: function( name ) {
- protoSetup = ++order;
- return ["Ford: "+name];
- },
- init: function() {
- protoInit = ++order;
- protoInitArgs = arguments;
- }
- }
- $.Class.extend("Car",staticProps,protoProps);
-
- var geo = new Car("geo");
- equals(staticSetup, 1);
- equals(staticInit, 2);
- equals(protoSetup, 3);
- equals(protoInit, 4);
-
- same($.makeArray(staticInitArgs), ["something"] )
- same($.makeArray(protoInitArgs),["Ford: geo"] )
-
- same($.makeArray(staticSetupArgs),[$.Class, "Car",staticProps, protoProps] ,"static construct");
-
-
- //now see if staticSetup gets called again ...
- Car.extend("Truck");
- equals(staticSetup, 5, "Static setup is called if overwriting");
-
-});
-
-test("callback", function(){
- var curVal = 0;
- $.Class.extend("Car",{
- show: function( value ) {
- equals(curVal, value)
- }
- },{
- show: function( value ) {
-
- }
- })
- var cb = Car.proxy('show');
- curVal = 1;
- cb(1)
-
- curVal = 2;
- var cb2 = Car.proxy('show',2)
- cb2();
-});
-
-test("callback error", 1,function(){
- $.Class.extend("Car",{
- show: function( value ) {
- equals(curVal, value)
- }
- },{
- show: function( value ) {
-
- }
- })
- try{
- Car.proxy('huh');
- ok(false, "I should have errored")
- }catch(e){
- ok(true, "Error was thrown")
- }
-})
-
-test("Creating without extend", function(){
- $.Class("Bar",{
- ok : function(){
- ok(true, "ok called")
- }
- });
- new Bar().ok();
-
- Bar("Foo",{
- dude : function(){
- ok(true, "dude called")
- }
- });
- new Foo().dude(true);
-})
-
-
-/* Not sure I want to fix this yet.
-test("Super in derived when parent doesn't have init", function(){
- $.Class("Parent",{
- });
-
- Parent("Derived",{
- init : function(){
- this._super();
- }
- });
-
- try {
- new Derived();
- ok(true, "Can call super in init safely")
- } catch (e) {
- ok(false, "Failed to call super in init with error: " + e)
- }
-})*/
-
-});
\ No newline at end of file
diff --git a/class/qunit.html b/class/qunit.html
deleted file mode 100644
index 503f699f..00000000
--- a/class/qunit.html
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/controller/controller.html b/controller/controller.html
deleted file mode 100644
index a76e2ace..00000000
--- a/controller/controller.html
+++ /dev/null
@@ -1,88 +0,0 @@
-
-
-
- Controller Example
-
-
-
-
-
-
Tab 1 Content
-
Tab 2 Content
-
Tab 3 Content
-
-
-
-
-
\ No newline at end of file
diff --git a/controller/controller.js b/controller/controller.js
deleted file mode 100644
index 93b2c403..00000000
--- a/controller/controller.js
+++ /dev/null
@@ -1,5 +0,0 @@
-steal('jquery/class','can/control/plugin',function( $ ) {
- $.Controller = can.Control;
- $.fn.controller = $.fn.control;
- $.fn.controllers = $.fn.controllers;
-});
diff --git a/controller/controller_test.js b/controller/controller_test.js
deleted file mode 100644
index d2322b85..00000000
--- a/controller/controller_test.js
+++ /dev/null
@@ -1,269 +0,0 @@
-steal("jquery/controller",'jquery/controller/subscribe') //load your app
- .then('funcunit/qunit') //load qunit
- .then(function(){
-
-module("jquery/controller")
-test("subscribe testing works", function(){
-
- var ta = $("
").appendTo( $("#qunit-test-area") )
-
- ta.html("click here")
-
- var clicks = 0, destroys = 0;
- var subscribes = 0;
- $.Controller.extend("MyTest",{
- click: function() {
- clicks++
- },
- "a.b subscribe" : function() {
- subscribes++
- },
- destroy: function() {
-
- this._super()
- destroys++;
- }
- })
- ta.my_test();
- ta.trigger("click")
- equals(clicks,1, "can listen to clicks")
-
- OpenAjax.hub.publish("a.b",{})
- equals(subscribes,1, "can subscribe")
- var controllerInstance = ta.controller('my_test')
- ok( controllerInstance.constructor == MyTest, "can get controller" )
- controllerInstance.destroy()
-
- equals(destroys,1, "destroy called once")
- ok(!ta.controller(), "controller is removed")
-
- OpenAjax.hub.publish("a.b",{})
- equals(subscribes,1, "subscription is torn down")
- ta.trigger("click")
- equals(clicks,1, "No longer listening")
-
-
-
- ta.my_test();
- ta.trigger("click")
- OpenAjax.hub.publish("a.b",{})
- equals(clicks,2, "can listen again to clicks")
- equals(subscribes,2, "can listen again to subscription")
-
- ta.remove();
-
- ta.trigger("click")
- OpenAjax.hub.publish("a.b",{})
- equals(clicks,2, "Clicks stopped")
- equals(subscribes,2, "Subscribes stopped")
-})
-
-
-
-test("bind to any special", function(){
- jQuery.event.special.crazyEvent = {
-
- }
- var called = false;
- jQuery.Controller.extend("WeirdBind",{
- crazyEvent: function() {
- called = true;
- }
- })
- var a = $("
").appendTo($("#qunit-test-area"))
- a.weird_bind();
- a.trigger("crazyEvent")
- ok(called, "heard the trigger");
-
- $("#qunit-test-area").html("")
-
-})
-
-test("parameterized actions", function(){
- var called = false;
- jQuery.Controller.extend("WeirderBind",{
- "{parameterized}" : function() {
- called = true;
- }
- })
- var a = $("
").appendTo($("#qunit-test-area"))
- a.weirder_bind({parameterized: "sillyEvent"});
- a.trigger("sillyEvent")
- ok(called, "heard the trigger")
-
- $("#qunit-test-area").html("")
-})
-
-test("windowresize", function(){
- var called = false;
- jQuery.Controller.extend("WindowBind",{
- "{window} resize" : function() {
- called = true;
- }
- })
- $("#qunit-test-area").html("")
- $("#weird").window_bind();
- $(window).trigger('resize')
- ok(called,"got window resize event");
-
- $("#qunit-test-area").html("")
-})
-
-// this.delegate(this.cached.header.find('tr'), "th", "mousemove", "th_mousemove");
-test("delegate", function(){
- var called = false;
- jQuery.Controller.extend("DelegateTest",{
- click: function() {}
- })
- var els = $("
").appendTo($("#qunit-test-area"))
- var c = els.delegate_test();
- c.controller().on(els.find("span"), "a", "click", function(){
- called = true;
- })
- els.find("a").trigger('click')
- ok(called, "delegate works")
- $("#qunit-test-area").html("")
-})
-
-test("inherit", function(){
- var called = false;
- $.Controller.extend( "Parent", {
- click: function(){
- called = true;
- }
- })
- Parent.extend( "Child", {
-
- })
- var els = $("
").appendTo($("#qunit-test-area"))
- els.child();
- els.find("a").trigger('click')
- ok(called, "inherited the click method")
- $("#qunit-test-area").html("")
-});
-
-test("objects in action", function(){
- $.Controller('Thing',{
- "{item} someEvent" : function(thing, ev){
- ok(true, "called");
- equals(ev.type, "someEvent","correct event")
- equals(this.constructor.fullName, "Thing", "This is a controller isntance")
- equals(thing.name,"Justin","Raw, not jQuery wrapped thing")
- }
- });
-
- var thing1 = {name: "Justin"};
-
- var ta = $("
").appendTo( $("#qunit-test-area") )
- ta.thing({item : thing1});
-
- $(thing1).trigger("someEvent");
-
- $("#qunit-test-area").html("");
-
-});
-
-test("dot",function(){
- $.Controller("Dot",{
- "foo.bar" : function(){
- ok(true,'called')
- }
- });
-
- var ta = $("
").appendTo( $("#qunit-test-area") );
- ta.dot().trigger("foo.bar");
- $("#qunit-test-area").html("");
-})
-
-// HTMLFormElement[0] breaks
-test("the right element", 1, function(){
- $.Controller('FormTester',{
- init : function(){
- equals(this.element[0].nodeName.toLowerCase(), "form" )
- }
- })
- $("
").appendTo( $("#qunit-test-area") )
- .form_tester();
- $("#qunit-test-area").html("")
-})
-
-test("pluginName", function() {
- // Testing for controller pluginName fixes as reported in
- // http://forum.javascriptmvc.com/#topic/32525000000253001
- // http://forum.javascriptmvc.com/#topic/32525000000488001
- expect(6);
-
- $.Controller("PluginName", {
- pluginName : "my_plugin"
- }, {
- method : function(arg) {
- ok(true, "Method called");
- },
-
- update : function(options) {
- this._super(options);
- ok(true, "Update called");
- },
-
- destroy : function() {
- ok(true, "Destroyed");
- this._super();
- }
- });
-
- var ta = $("
").addClass('existing_class').appendTo( $("#qunit-test-area") );
- ta.my_plugin(); // Init
- ok(ta.hasClass("my_plugin"), "Should have class my_plugin");
- ta.my_plugin(); // Update
- ta.my_plugin("method"); // method()
- ta.controller().destroy(); // destroy
- ok(!ta.hasClass("my_plugin"), "Shouldn't have class my_plugin after being destroyed");
- ok(ta.hasClass("existing_class"), "Existing class should still be there");
-})
-
-test("inherit defaults", function() {
- $.Controller.extend("BaseController", {
- defaults : {
- foo: 'bar'
- }
- }, {});
-
- BaseController.extend("InheritingController", {
- defaults : {
- newProp : 'newVal'
- }
- }, {});
-
- ok(InheritingController.defaults.foo === 'bar', 'Class must inherit defaults from the parent class');
- ok(InheritingController.defaults.newProp == 'newVal', 'Class must have own defaults');
- var inst = new InheritingController($('
'), {});
- ok(inst.options.foo === 'bar', 'Instance must inherit defaults from the parent class');
- ok(inst.options.newProp == 'newVal', 'Instance must have defaults of it`s class');
-});
-
-test("update rebinding", 2, function(){
- var first = true;
- $.Controller("Rebinder", {
- "{item} foo" : function(item, ev){
- if(first){
- equals(item.id, 1, "first item");
- first = false;
- } else {
- equals(item.id, 2, "first item");
- }
- }
- });
-
- var item1 = {id: 1},
- item2 = {id: 2},
- el = $('
').rebinder({item: item1})
-
- $(item1).trigger("foo")
-
- el.rebinder({item: item2});
-
- $(item2).trigger("foo")
-})
-
-
-});
diff --git a/controller/demo-update.html b/controller/demo-update.html
deleted file mode 100644
index cb5e936b..00000000
--- a/controller/demo-update.html
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
-
-
Controller Example
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/controller/pages/listening.md b/controller/pages/listening.md
deleted file mode 100644
index c27ab175..00000000
--- a/controller/pages/listening.md
+++ /dev/null
@@ -1,189 +0,0 @@
-@page jquery.controller.listening Listening To Events
-@parent jQuery.Controller
-
-Controllers make creating and tearing down event handlers extremely
-easy. The tearingdown of event handlers is especially important
-in preventing memory leaks in long lived applications.
-
-## Automatic Binding
-
-When a [jQuery.Controller.prototype.setup new controller is created],
-contoller checks its prototype methods for functions that are named like
-event handlers. It binds these functions to the
-controller's [jQuery.Controller.prototype.element element] with
-event delegation. When
-the controller is destroyed (or it's element is removed from the page), controller
-will unbind its event handlers automatically.
-
-For example, each of the following controller's functions will automatically
-bound:
-
- $.Controller("Crazy",{
-
- // listens to all clicks on this element
- "click" : function(el, ev){},
-
- // listens to all mouseovers on
- // li elements withing this controller
- "li mouseover" : function(el, ev){}
-
- // listens to the window being resized
- "{window} resize" : function(window, ev){}
- })
-
-Controller will bind function names with spaces, standard DOM events, and
-event names in $.event.special.
-
-In general, Controller will know automatically when to bind event handler functions except for
-one case - event names without selectors that are not in $.event.special.
-
-But to correct for this, you just need to add the
-function to the [jQuery.Controller.static.listensTo listensTo]
-property. Here's how:
-
- $.Controller("MyShow",{
- listensTo: ["show"]
- },{
- show: function( el, ev ) {
- el.show();
- }
- })
- $('.show').my_show().trigger("show");
-
-## Callback parameters
-
-Event handlers bound with controller are called back with the element and the event
-as parameters.
this refers to the controller instance. For example:
-
- $.Controller("Tabs",{
-
- // li - the list element that was clicked
- // ev - the click event
- "li click" : function(li, ev){
- this.tab(li).hide()
- },
- tab : function(li){
- return $(li.find("a").attr("href"))
- }
- })
-
-## Templated Event Bindings
-
-One of Controller's most powerful features is templated event
-handlers. You can parameterize the event name,
-the selector, or event the root element.
-
-### Templating event names and selectors:
-
-Often, you want to make a widget's behavior
-configurable. A common example is configuring which event
-a menu should show a sub-menu (ex: on click or mouseenter). The
-following controller lets you configure when a menu should show
-sub-menus:
-
-The following makes two buttons. One says hello on click,
-the other on a 'tap' event.
-
- $.Controller("Menu",{
- "li {showEvent}" : function(el){
- el.children('ul').show()
- }
- })
-
- $("#clickMe").menu({showEvent : "click"});
- $("#touchMe").menu({showEvent : "mouseenter"});
-
-$.Controller replaces value in
{} with
-values in a
-controller's [jQuery.Controller.prototype.options options]. This means
-we can easily provide a default
showEvent value and create
-a menu without providing a value like:
-
- $.Controller("Menu",
- {
- defaults : {
- showEvent : "click"
- }
- },
- {
- "li {showEvent}" : function(el){
- el.children('ul').show()
- }
- });
-
- $("#clickMe").menu(); //defaults to using click
-
-Sometimes, we might might want to configure our widget to
-use different elements. The following makes the menu widget's
-
button elements configurable:
-
- $.Controller("Menu",{
- "{button} {showEvent}" : function(el){
- el.children('ul').show()
- }
- })
-
- $('#buttonMenu').menu({button: "button"});
-
-### Templating the root element.
-
-Finally, controller lets you bind to objects outside
-of the [jQuery.Controller.prototype.element controller's element].
-
-The following listens to clicks on the window:
-
- $.Controller("HideOnClick",{
- "{window} click" : function(){
- this.element.hide()
- }
- })
-
-The following listens to Todos being created:
-
- $.Controller("NewTodos",{
- "{App.Models.Todo} created" : function(Todo, ev, newTodo){
- this.element.append("newTodos.ejs", newTodo)
- }
- });
-
-But instead of making NewTodos only work with the Todo model,
-we can make it configurable:
-
- $.Controller("Newbie",{
- "{model} created" : function(Model, ev, newItem){
- this.element.append(this.options.view, newItem)
- }
- });
-
- $('#newItems').newbie({
- model: App.Models.Todo,
- view: "newTodos.ejs"
- })
-
-### How Templated events work
-
-When looking up a value to replace
{},
-controller first looks up the item in the options, then it looks
-up the value in the window object. It does not use eval to look up the
-object. Instead it uses [jQuery.String.getObject].
-
-
-## Subscribing to OpenAjax messages and custom bindings
-
-The jquery/controller/subscribe plugin allows controllers to listen
-to OpenAjax.hub messages like:
-
- $.Controller("Listener",{
- "something.updated subscribe" : function(called, data){
-
- }
- })
-
-You can create your own binders by adding to [jQuery.Controller.static.processors].
-
-## Manually binding to events.
-
-The [jQuery.Controller.prototype.bind] and [jQuery.Controller.prototype.delegate]
-methods let you listen to events on other elements. These event handlers will
-be unbound when the controller instance is destroyed.
-
diff --git a/controller/pages/plugin.md b/controller/pages/plugin.md
deleted file mode 100644
index d3ee520f..00000000
--- a/controller/pages/plugin.md
+++ /dev/null
@@ -1,101 +0,0 @@
-@page jquery.controller.plugin The generated jQuery plugin
-@parent jQuery.Controller
-
-When you create a controller, it creates a jQuery plugin that can be
-used to:
-
- - Create controllers on an element or elements
- - Call controller methods
- - Update a controller
-
-For example, the following controller:
-
- $.Controller("My.Widget",{
- say : function(){
- alert(this.options.message);
- }
- })
-
-creates a
jQuery.fn.my_widget method that you can use like:
-
- // create my_widget on each .thing
- $(".thing").my_widget({message : "Hello"})
-
- // alerts "Hello"
- $(".thing").my_widget("say");
-
- // updates the message option
- $(".thing").my_widget({message : "World"});
-
- // alerts "World"
- $(".thing").my_widget("say");
-
-Note that in every case, the my_widget plugin
-returns the original jQuery collection for chaining (
$('.thing')). If you want to
-get a value from a controller, use the [jQuery.fn.controllers] or [jQuery.fn.controller].
-
-## Creating controllers
-
-When a controller's jQuery plugin helper is used on a jQuery collection, it goes to each
-element and tests if it has a controller instance on the element. If it does not, it creates one.
-
-It calls
new YourController with the element and any additional arguments you passed
-to the jQuery plugin helper. So for example, say there are 2 elements in
$('.thing').
-
-This:
-
- $(".thing").my_widget({message : "Hello"})
-
-Does the exact same thing as:
-
- var things = $('.thing'),
- options = {message : "Hello"};
- new My.Widget(things[0],options);
- new My.Widget(things[1],options);
-
-Note, when a
new Class is created, it calls your
-class's prototype setup and init methods. Read [jQuery.Controller.prototype.setup controller's setup]
-for the details on what happens when a new controller is created.
-
-
-## Calling methods on controllers
-
-Once a Controller is already on an element, you can call methods on it with the same jQuery
-helper. The first param to the helper is the name of the method, the following params are
-passed to the jQuery function. For example:
-
- $.Controller("Adder",{
- sum : function(first, second, third){
- this.element.text(first+second+third);
- }
- })
-
- // add an adder to the page
- $("#myadder").adder()
-
- // show the sum of 1+2+3
- $("#myadder").adder("sum",1,2,3);
-
-## Naming
-
-By default, a controller's jQuery helper is the controller name:
-
- - [jQuery.String.underscore underscored]
- - "." replaced with "_"
- - with Controllers removed.
-
-Here are some examples:
-
- $.Controller("Foo") // -> .foo()
- $.Controller("Foo.Bar") // -> .foo_bar()
- $.Controller("Foo.Controllers.Bar") // -> .foo_bar()
-
-You can overwrite the Controller's default name by setting a static pluginName property:
-
- $.Controller("My.Tabs",
- {
- pluginName: "tabs"
- },
- { ... })
-
- $("#tabs").tabs()
diff --git a/controller/qunit.html b/controller/qunit.html
deleted file mode 100644
index ae8fad54..00000000
--- a/controller/qunit.html
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/controller/route/qunit.html b/controller/route/qunit.html
deleted file mode 100644
index 25edc491..00000000
--- a/controller/route/qunit.html
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
route QUnit Test
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/controller/route/route.html b/controller/route/route.html
deleted file mode 100644
index 178af929..00000000
--- a/controller/route/route.html
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
route
-
-
-
-
route Demo
-
foo/bar
-
foo/car
-
empty
-
-
-
-
\ No newline at end of file
diff --git a/controller/route/route.js b/controller/route/route.js
deleted file mode 100644
index cbf9bb92..00000000
--- a/controller/route/route.js
+++ /dev/null
@@ -1 +0,0 @@
-steal('jquery/controller', 'can/control/route')
diff --git a/controller/route/route_test.js b/controller/route/route_test.js
deleted file mode 100644
index 6a140d6b..00000000
--- a/controller/route/route_test.js
+++ /dev/null
@@ -1,10 +0,0 @@
-steal('funcunit/qunit','./route',function(){
-
-module("route");
-
-test("route testing works", function(){
- ok(true,"an assert is run");
-});
-
-
-});
\ No newline at end of file
diff --git a/controller/subscribe/funcunit.html b/controller/subscribe/funcunit.html
deleted file mode 100644
index 48dda424..00000000
--- a/controller/subscribe/funcunit.html
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/controller/subscribe/subscribe.html b/controller/subscribe/subscribe.html
deleted file mode 100644
index a26d72d5..00000000
--- a/controller/subscribe/subscribe.html
+++ /dev/null
@@ -1,56 +0,0 @@
-
-
-
-
hover
-
-
-
-
-
-
-
-
-
diff --git a/controller/subscribe/subscribe.js b/controller/subscribe/subscribe.js
deleted file mode 100644
index 26280343..00000000
--- a/controller/subscribe/subscribe.js
+++ /dev/null
@@ -1,54 +0,0 @@
-/*global OpenAjax: true */
-steal('jquery/controller', 'jquery/lang/openajax').then(function() {
-
- /**
- * @function jQuery.Controller.static.processors.subscribe
- * @parent jQuery.Controller.static.processors
- * @plugin jquery/controller/subscribe
- * Adds OpenAjax.Hub subscribing to controllers.
- *
- * $.Controller("Subscriber",{
- * "recipe.updated subscribe" : function(called, recipe){
- *
- * },
- * "todo.* subscribe" : function(called, todo){
- *
- * }
- * })
- *
- * You should typically be listening to jQuery triggered events when communicating between
- * controllers. Subscribe should be used for listening to model changes.
- *
- * ### API
- *
- * This is the call signiture for the processor, not the controller subscription callbacks.
- *
- * @param {HTMLElement} el the element being bound. This isn't used.
- * @param {String} event the event type (subscribe).
- * @param {String} selector the subscription name
- * @param {String} cb the callback function's name
- */
- jQuery.Controller.processors.subscribe = function( el, event, selector, cb, controller ) {
- var subscription = OpenAjax.hub.subscribe(selector, function(){
- return controller[cb].apply(controller, arguments)
- });
- return function() {
- OpenAjax.hub.unsubscribe(subscription);
- };
- };
-
- /**
- * @add jQuery.Controller.prototype
- */
- //breaker
- /**
- * @function publish
- * @hide
- * Publishes a message to OpenAjax.hub.
- * @param {String} message Message name, ex: "Something.Happened".
- * @param {Object} data The data sent.
- */
- jQuery.Controller.prototype.publish = function() {
- OpenAjax.hub.publish.apply(OpenAjax.hub, arguments);
- };
-});
\ No newline at end of file
diff --git a/controller/view/qunit.html b/controller/view/qunit.html
deleted file mode 100644
index cc57a785..00000000
--- a/controller/view/qunit.html
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/controller/view/test/qunit/controller_view_test.js b/controller/view/test/qunit/controller_view_test.js
deleted file mode 100644
index 506da897..00000000
--- a/controller/view/test/qunit/controller_view_test.js
+++ /dev/null
@@ -1,50 +0,0 @@
-steal('jquery/controller/view','jquery/view/micro','funcunit/qunit') //load qunit
- .then(function(){
-
- module("jquery/controller/view");
-
- test("this.view", function(){
-
- $.Controller.extend("jquery.Controller.View.Test.Qunit",{
- init: function() {
- this.element.html(this.view())
- }
- })
- jQuery.View.ext = ".micro";
- $("#qunit-test-area").append("
");
-
- new jquery.Controller.View.Test.Qunit( $('#cont_view') );
-
- ok(/Hello World/i.test($('#cont_view').text()),"view rendered")
- });
-
- test("test.suffix.doubling", function(){
-
- $.Controller.extend("jquery.Controller.View.Test.Qunit",{
- init: function() {
- this.element.html(this.view('init.micro'))
- }
- })
-
- jQuery.View.ext = ".ejs"; // Reset view extension to default
- equal(".ejs", jQuery.View.ext);
-
- $("#qunit-test-area").append("
");
-
- new jquery.Controller.View.Test.Qunit( $('#suffix_test_cont_view') );
-
- ok(/Hello World/i.test($('#suffix_test_cont_view').text()),"view rendered")
- });
-
- test("complex paths nested inside a controller directory", function(){
- $.Controller.extend("Myproject.Controllers.Foo.Bar");
-
- var path = jQuery.Controller._calculatePosition(Myproject.Controllers.Foo.Bar, "init.ejs", "init")
- equals(path, "//myproject/views/foo/bar/init.ejs", "view path is correct")
-
- $.Controller.extend("Myproject.Controllers.FooBar");
- path = jQuery.Controller._calculatePosition(Myproject.Controllers.FooBar, "init.ejs", "init")
- equals(path, "//myproject/views/foo_bar/init.ejs", "view path is correct")
- })
-});
-
diff --git a/controller/view/test/qunit/qunit.js b/controller/view/test/qunit/qunit.js
deleted file mode 100644
index 7873c312..00000000
--- a/controller/view/test/qunit/qunit.js
+++ /dev/null
@@ -1,5 +0,0 @@
-//we probably have to have this only describing where the tests are
-steal('jquery/controller/view','jquery/view/micro') //load your app
- .then('funcunit/qunit') //load qunit
- .then("./controller_view_test.js")
-
diff --git a/controller/view/test/qunit/views/init.micro b/controller/view/test/qunit/views/init.micro
deleted file mode 100644
index 9a1eb8d2..00000000
--- a/controller/view/test/qunit/views/init.micro
+++ /dev/null
@@ -1 +0,0 @@
-
Hello World
\ No newline at end of file
diff --git a/controller/view/view.js b/controller/view/view.js
deleted file mode 100644
index c7743076..00000000
--- a/controller/view/view.js
+++ /dev/null
@@ -1 +0,0 @@
-steal('jquery/controller', 'can/control/view');
\ No newline at end of file
diff --git a/dom/animate/1x1.jpg b/dom/animate/1x1.jpg
new file mode 100644
index 00000000..b0d69110
Binary files /dev/null and b/dom/animate/1x1.jpg differ
diff --git a/dom/animate/animate.html b/dom/animate/animate.html
index e3af0314..11dbfa81 100644
--- a/dom/animate/animate.html
+++ b/dom/animate/animate.html
@@ -1,42 +1,30 @@
-
-
Animate Demo
-
-
-
+
+
Animate Demo
+
+
+
-
\ No newline at end of file
diff --git a/dom/animate/animate.js b/dom/animate/animate.js
index e00b9fd0..a91ee4b8 100644
--- a/dom/animate/animate.js
+++ b/dom/animate/animate.js
@@ -1,4 +1,4 @@
-steal('jquery', 'jquery/dom/styles').then(function ($) {
+steal('jquery', function ($) {
// Overwrites `jQuery.fn.animate` to use CSS 3 animations if possible
@@ -45,27 +45,32 @@ steal('jquery', 'jquery/dom/styles').then(function ($) {
},
// Returns whether the animation should be passed to the original $.fn.animate.
- passThrough = function (props, ops) {
+ passThrough = function (props, ops, easing, callback) {
var nonElement = !(this[0] && this[0].nodeType),
- isInline = !nonElement && $(this).css("display") === "inline" && $(this).css("float") === "none";
+ isInline = !nonElement && $(this).css("display") === "inline" && $(this).css("float") === "none",
+ browser = getBrowser();
for (var name in props) {
- if (props[name] == 'show' || props[name] == 'hide' // jQuery does something with these two values
- || $.isArray(props[name]) // Arrays for individual easing
- || props[name] < 0 // Negative values not handled the same
- || name == 'zIndex' || name == 'z-index'
- ) { // unit-less value
+ // jQuery does something with these values
+ if (props[name] == 'show' || props[name] == 'hide' || props[name] == 'toggle'
+ // Arrays for individual easing
+ || $.isArray(props[name])
+ // Negative values not handled the same
+ || props[name] < 0
+ // unit-less value
+ || name == 'zIndex' || name == 'z-index' || name == 'scrollTop' || name == 'scrollLeft'
+ ) {
return true;
}
}
- return props.jquery === true || getBrowser() === null ||
+ return props.jquery === true || browser === null || browser.prefix === '-o-' ||
// Animating empty properties
$.isEmptyObject(props) ||
+ // We can't do custom easing
+ (easing || easing && typeof easing == 'string') ||
// Second parameter is an object - we can only handle primitives
$.isPlainObject(ops) ||
- // Second parameter is a string like 'slow' TODO: remove
- typeof ops == 'string' ||
// Inline and non elements
isInline || nonElement;
},
@@ -85,33 +90,30 @@ steal('jquery', 'jquery/dom/styles').then(function ($) {
el = document.createElement('fakeelement'),
transitions = {
'transition': {
- transitionEnd : 'transitionEnd',
+ transitionEnd : 'transitionend',
prefix : ''
},
-// 'OTransition': {
-// transitionEnd : 'oTransitionEnd',
-// prefix : '-o-'
-// },
-// 'MSTransition': {
-// transitionEnd : 'msTransitionEnd',
-// prefix : '-ms-'
-// },
'MozTransition': {
transitionEnd : 'animationend',
prefix : '-moz-'
},
'WebkitTransition': {
- transitionEnd : 'webkitAnimationEnd',
+ transitionEnd : 'webkitTransitionEnd',
prefix : '-webkit-'
+ },
+ 'OTransition': {
+ transitionEnd : 'oTransitionEnd',
+ prefix : '-o-'
}
}
for(t in transitions){
- if( el.style[t] !== undefined ){
+ if( t in el.style ){
browser = transitions[t];
}
}
}
+
return browser;
},
@@ -190,8 +192,10 @@ steal('jquery', 'jquery/dom/styles').then(function ($) {
};
/**
- * @function $.fn.animate
- * @parent $.animate
+ * @parent jQuery.animate
+ * @function jQuery.fn.animate
+ * @signature $(element).animate(options)
+ * @hide
*
* Animate CSS properties using native CSS animations, if possible.
* Uses the original [$.fn.animate()](http://api.$.com/animate/) otherwise.
@@ -202,17 +206,24 @@ steal('jquery', 'jquery/dom/styles').then(function ($) {
* @param {Function} [callback] A callback to execute once the animation is complete
* @return {jQuery} The jQuery element
*/
- $.fn.animate = function (props, speed, callback) {
+ $.fn.animate = function (props, speed, easing, callback) {
//default to normal animations if browser doesn't support them
if (passThrough.apply(this, arguments)) {
return oldanimate.apply(this, arguments);
}
- if ($.isFunction(speed)) {
- callback = speed;
+
+ var optall = $.speed(speed, easing, callback),
+ overflow = [];
+
+ // if we are animating height and width properties, set overflow to hidden, and save
+ // the previous overflow information to replace with when done.
+ if("height" in props || "width" in props) {
+ overflow = [this[0].style.overflow, this[0].style.overflowX, this[0].style.overflowY];
+ this.css('overflow', 'hidden');
}
// Add everything to the animation queue
- this.queue('fx', function(done) {
+ this.queue(optall.queue, function(done) {
var
//current CSS values
current,
@@ -221,7 +232,7 @@ steal('jquery', 'jquery/dom/styles').then(function ($) {
to = "",
prop,
self = $(this),
- duration = $.fx.speeds[speed] || speed || $.fx.speeds._default,
+ duration = optall.duration,
//the animation keyframe name
animationName,
// The key used to store the animation hook
@@ -231,8 +242,19 @@ steal('jquery', 'jquery/dom/styles').then(function ($) {
// The animation end event handler.
// Will be called both on animation end and after calling .stop()
animationEnd = function (currentCSS, exec) {
+ // As long as we don't stop mid animation, then we will replace
+ // the overflow values of the element being animated.
+ if(!exec) {
+ self[0].style.overflow = overflow[0];
+ self[0].style.overflowX = overflow[1];
+ self[0].style.overflowY = overflow[2];
+ }
+ else {
+ self.css('overflow', '');
+ }
+
self.css(currentCSS);
-
+
self.css(addPrefix({
"animation-duration" : "",
"animation-name" : "",
@@ -240,20 +262,27 @@ steal('jquery', 'jquery/dom/styles').then(function ($) {
"animation-play-state" : ""
}));
- if (callback && exec) {
+ // Call the original callback
+ if ($.isFunction(optall.old) && exec) {
// Call success, pass the DOM element as the this reference
- callback.call(self[0], true)
+ optall.old.call(self[0], true)
}
$.removeData(self, dataKey, true);
- }
+ },
+ finishAnimation = function() {
+ // Call animationEnd using the passed properties
+ animationEnd(props, true);
+ done();
+ };
for(prop in props) {
properties.push(prop);
}
- if(getBrowser().prefix === '-moz-') {
+ if(getBrowser().prefix === '-moz-' || /Edge\/\d+/.test(navigator.userAgent)) {
// Normalize 'auto' properties in FF
+ // This is also needed in Edge (tested in 13)
$.each(properties, function(i, prop) {
var converter = ffProps[$.camelCase(prop)];
if(converter && self.css(prop) == 'auto') {
@@ -263,7 +292,7 @@ steal('jquery', 'jquery/dom/styles').then(function ($) {
}
// Use $.styles
- current = self.styles.apply(self, properties);
+ current = self.css.apply(self, properties);
$.each(properties, function(i, cur) {
// Convert a camelcased property name
var name = cur.replace(/([A-Z]|^ms)/g, "-$1" ).toLowerCase();
@@ -284,7 +313,7 @@ steal('jquery', 'jquery/dom/styles').then(function ($) {
'animation-play-state' : 'paused'
}));
// Unbind the animation end handler
- self.off(getBrowser().transitionEnd, animationEnd);
+ self.off(getBrowser().transitionEnd, finishAnimation);
if(!gotoEnd) {
// We were told not to finish the animation
// Call animationEnd but set the CSS to the current computed style
@@ -304,14 +333,12 @@ steal('jquery', 'jquery/dom/styles').then(function ($) {
}));
// Attach the transition end event handler to run only once
- self.one(getBrowser().transitionEnd, function() {
- // Call animationEnd using the passed properties
- animationEnd(props, true);
- done();
- });
+ self.one(getBrowser().transitionEnd, finishAnimation);
});
return this;
};
+
+ return $;
});
diff --git a/dom/animate/animate.md b/dom/animate/animate.md
index b12a572d..af80c732 100644
--- a/dom/animate/animate.md
+++ b/dom/animate/animate.md
@@ -1,6 +1,19 @@
-@page jQuery.animate
+@function jQuery.animate jQuery.animate
@parent jquerypp
+@signature `jQuery(element).animate(options)`
+
+Animate CSS properties using native CSS animations, if possible.
+Uses the original [$.fn.animate()](http://api.jquery.com/animate/) otherwise.
+
+@param {Object} props The CSS properties to animate
+@param {Integer|String|Object} [speed=400] The animation duration in ms.
+Will use $.fn.animate if a string or object is passed
+@param {Function} [callback] A callback to execute once the animation is complete
+@return {jQuery} The jQuery element
+
+@body
+
`jQuery.animate` overwrites `[jQuery.fn.animate jQuery.fn.animate(properties, duration, callback)]`
and enables it to animate properties using CSS 3 animations, if supported.
If the browser doesn't support CSS animations, the original [jQuery.fn.animate()](http://api.jquery.com/animate/) will be used.
@@ -26,7 +39,7 @@ The following example creates a fade-in effect using CSS animations:
$('#element').css({
opacity : 0
- }).anifast({
+ }).animate({
opacity : 1
}, 1000, function() {
console.log('Animation done');
@@ -38,7 +51,7 @@ the animation has been done using CSS animations:
$('#element').css({
opacity : 0,
jquery : true
- }).anifast({
+ }).animate({
opacity : 1
}, 1000, function(usedCss) {
console.log('Animation done');
@@ -46,9 +59,3 @@ the animation has been done using CSS animations:
console.log('Used jQuery animation');
}
});
-
-## Demo
-
-The following demo is based on the [jQuery .animate reference](http://api.jquery.com/animate/) but uses CSS animations:
-
-@demo jquery/dom/animate/animate.html 400
diff --git a/dom/animate/animate_test.js b/dom/animate/animate_test.js
index 9bbe6077..3c512823 100644
--- a/dom/animate/animate_test.js
+++ b/dom/animate/animate_test.js
@@ -1,1247 +1,1813 @@
-steal('jquery/dom/animate',
- 'funcunit/qunit').then('./qunit.css', function () {
-
- module("jquery/dom/animate");
-
- test("sanity check", function () {
- expect(1);
- ok(jQuery("#dl:visible, #qunit-fixture:visible, #foo:visible").length === 3, "QUnit state is correct for testing effects");
+steal('jquery',
+ "jquerypp/dom/animate/test/fixture.html!system-text",
+ 'jquerypp/dom/animate', 'steal-qunit', function ($, fixtureHTML) {
+
+ module("jquerypp/dom/animate", {
+ setup: function(){
+ // make qunit-fixture something else
+ $("#qunit-fixture").prop("id","outer-qunit-fixture")
+ .html(fixtureHTML);
+ },
+ teardown: function(){
+ $("#outer-qunit-fixture").empty().prop("id","qunit-fixture");
+ }
});
+ var reset = function(){
+ $("#outer-qunit-fixture").html(fixtureHTML);
+ };
- test("show()", function () {
- expect(28);
+ if ( $.fx ) {
+ test("sanity check", function() {
+ expect(1);
+ ok( jQuery("#dl:visible, #qunit-fixture:visible, #foo:visible").length === 3, "QUnit state is correct for testing effects" );
+ });
- var hiddendiv = jQuery("div.hidden");
+ test("show()", function() {
+ expect(26);
- hiddendiv.hide().show();
+ var hiddendiv = jQuery("div.hidden");
- equal(hiddendiv.css("display"), "block", "Make sure a pre-hidden div is visible.");
+ hiddendiv.hide().show();
- var div = jQuery("
").hide().appendTo("#qunit-fixture").show();
+ equal( hiddendiv.css("display"), "block", "Make sure a pre-hidden div is visible." );
- equal(div.css("display"), "block", "Make sure pre-hidden divs show");
+ var div = jQuery("
").hide().appendTo("#qunit-fixture").show();
- QUnit.reset();
+ equal( div.css("display"), "block", "Make sure pre-hidden divs show" );
- hiddendiv = jQuery("div.hidden");
+ reset();
- equal(jQuery.css(hiddendiv[0], "display"), "none", "hiddendiv is display: none");
+ hiddendiv = jQuery("div.hidden");
+
+ equal($.css( hiddendiv[0], "display"), "none", "hiddendiv is display: none");
- hiddendiv.css("display", "block");
- equal(jQuery.css(hiddendiv[0], "display"), "block", "hiddendiv is display: block");
+ hiddendiv.css("display", "block");
+ equal($.css( hiddendiv[0], "display"), "block", "hiddendiv is display: block");
- hiddendiv.show();
- equal(jQuery.css(hiddendiv[0], "display"), "block", "hiddendiv is display: block");
+ hiddendiv.show();
+ equal($.css( hiddendiv[0], "display"), "block", "hiddendiv is display: block");
- hiddendiv.css("display", "");
+ hiddendiv.css("display","");
- var pass = true;
- div = jQuery("#qunit-fixture div");
- div.show().each(function () {
- if (this.style.display == "none") pass = false;
- });
- ok(pass, "Show");
+ var pass = true;
+ div = jQuery("#qunit-fixture div");
+ div.show().each(function(){
+ if ( this.style.display == "none" ) {
+ pass = false;
+ }
+ });
+ ok( pass, "Show" );
- var speeds = {
- "null speed" : null,
- "undefined speed" : undefined,
- "empty string speed" : "",
- "false speed" : false
- };
+ var speeds = {
+ "null speed": null,
+ "undefined speed": undefined,
+ "false speed": false
+ };
- jQuery.each(speeds, function (name, speed) {
- pass = true;
- div.hide().show(speed).each(function () {
- if (this.style.display == "none") pass = false;
+ $.each(speeds, function(name, speed) {
+ pass = true;
+ div.hide().show(speed).each(function() {
+ if ( this.style.display == "none" ) {
+ pass = false;
+ }
+ });
+ ok( pass, "Show with " + name);
});
- ok(pass, "Show with " + name);
- });
- jQuery.each(speeds, function (name, speed) {
- pass = true;
- div.hide().show(speed, function () {
- pass = false;
+ $.each(speeds, function(name, speed) {
+ pass = true;
+ div.hide().show(speed, function() {
+ pass = false;
+ });
+ ok( pass, "Show with " + name + " does not call animate callback" );
});
- ok(pass, "Show with " + name + " does not call animate callback");
- });
-
- // #show-tests * is set display: none in CSS
- jQuery("#qunit-fixture").append("
");
-
- var old = jQuery("#test-table").show().css("display") !== "table";
- jQuery("#test-table").remove();
-
- var test = {
- "div" : "block",
- "p" : "block",
- "a" : "inline",
- "code" : "inline",
- "pre" : "block",
- "span" : "inline",
- "table" : old ? "block" : "table",
- "thead" : old ? "block" : "table-header-group",
- "tbody" : old ? "block" : "table-row-group",
- "tr" : old ? "block" : "table-row",
- "th" : old ? "block" : "table-cell",
- "td" : old ? "block" : "table-cell",
- "ul" : "block",
- "li" : old ? "block" : "list-item"
- };
- jQuery.each(test, function (selector, expected) {
- var elem = jQuery(selector, "#show-tests").show();
- equal(elem.css("display"), expected, "Show using correct display type for " + selector);
+ // #show-tests * is set display: none in CSS
+ jQuery("#qunit-fixture").append("
");
+
+ var old = jQuery("#test-table").show().css("display") !== "table";
+ jQuery("#test-table").remove();
+
+ var test = {
+ "div" : "block",
+ "p" : "block",
+ "a" : "inline",
+ "code" : "inline",
+ "pre" : "block",
+ "span" : "inline",
+ "table" : old ? "block" : "table",
+ "thead" : old ? "block" : "table-header-group",
+ "tbody" : old ? "block" : "table-row-group",
+ "tr" : old ? "block" : "table-row",
+ "th" : old ? "block" : "table-cell",
+ "td" : old ? "block" : "table-cell",
+ "ul" : "block",
+ "li" : old ? "block" : "list-item"
+ };
+
+ $.each(test, function(selector, expected) {
+ var elem = jQuery(selector, "#show-tests").show();
+ equal( elem.css("display"), expected, "Show using correct display type for " + selector );
+ });
+
+ jQuery("#show-tests").remove();
+
+ // Make sure that showing or hiding a text node doesn't cause an error
+ jQuery("
test
text
test ").show().remove();
+ jQuery("
test
text
test ").hide().remove();
});
- // Make sure that showing or hiding a text node doesn't cause an error
- jQuery("
test
text
test ").show().remove();
- jQuery("
test
text
test ").hide().remove();
- });
+ /* COMMENTED OUT
+ test("show(Number) - other displays", function() {
+ expect(15);
+ reset();
+ stop();
- test("show(Number) - other displays", function () {
- expect(15);
- QUnit.reset();
- stop();
-
- // #show-tests * is set display: none in CSS
- jQuery("#qunit-fixture").append("
");
-
- var old = jQuery("#test-table").show().css("display") !== "table",
- num = 0;
- jQuery("#test-table").remove();
-
- var test = {
- "div" : "block",
- "p" : "block",
- "a" : "inline",
- "code" : "inline",
- "pre" : "block",
- "span" : "inline",
- "table" : old ? "block" : "table",
- "thead" : old ? "block" : "table-header-group",
- "tbody" : old ? "block" : "table-row-group",
- "tr" : old ? "block" : "table-row",
- "th" : old ? "block" : "table-cell",
- "td" : old ? "block" : "table-cell",
- "ul" : "block",
- "li" : old ? "block" : "list-item"
- };
+ // #show-tests * is set display: none in CSS
+ jQuery("#qunit-fixture").append("
");
+
+ var old = jQuery("#test-table").show().css("display") !== "table",
+ num = 0;
+ jQuery("#test-table").remove();
+
+ var test = {
+ "div" : "block",
+ "p" : "block",
+ "a" : "inline",
+ "code" : "inline",
+ "pre" : "block",
+ "span" : "inline",
+ "table" : old ? "block" : "table",
+ "thead" : old ? "block" : "table-header-group",
+ "tbody" : old ? "block" : "table-row-group",
+ "tr" : old ? "block" : "table-row",
+ "th" : old ? "block" : "table-cell",
+ "td" : old ? "block" : "table-cell",
+ "ul" : "block",
+ "li" : old ? "block" : "list-item"
+ };
- jQuery.each(test, function (selector, expected) {
- var elem = jQuery(selector, "#show-tests").show(1, function () {
- equal(elem.css("display"), expected, "Show using correct display type for " + selector);
- if (++num === 15) {
- start();
- }
+ $.each(test, function(selector, expected) {
+ var elem = jQuery(selector, "#show-tests").show(1, function() {
+ equal( elem.css("display"), expected, "Show using correct display type for " + selector );
+ if ( ++num === 15 ) {
+ start();
+ }
+ });
});
+
+ jQuery("#show-tests").remove();
});
- });
+ */
// Supports #7397
- test("Persist correct display value", function () {
- expect(3);
- QUnit.reset();
- stop();
+ test("Persist correct display value", function() {
+ expect(3);
+ reset();
+ stop();
- // #show-tests * is set display: none in CSS
- jQuery("#qunit-fixture").append("
foo
");
+ // #show-tests * is set display: none in CSS
+ jQuery("#qunit-fixture").append("
foo
");
- var $span = jQuery("#show-tests span"),
- displayNone = $span.css("display"),
- display = "", num = 0;
+ var $span = jQuery("#show-tests span"),
+ displayNone = $span.css("display"),
+ display = "", num = 0;
- $span.show();
+ $span.show();
- display = $span.css("display");
+ display = $span.css("display");
- $span.hide();
+ $span.hide();
- $span.fadeIn(100, function () {
- equal($span.css("display"), display, "Expecting display: " + display);
- $span.fadeOut(100, function () {
- equal($span.css("display"), displayNone, "Expecting display: " + displayNone);
- $span.fadeIn(100, function () {
- equal($span.css("display"), display, "Expecting display: " + display);
- start();
+ $span.fadeIn(100, function() {
+ equal($span.css("display"), display, "Expecting display: " + display);
+ $span.fadeOut(100, function () {
+ equal($span.css("display"), displayNone, "Expecting display: " + displayNone);
+ $span.fadeIn(100, function() {
+ equal($span.css("display"), display, "Expecting display: " + display);
+ start();
+ });
});
});
});
- });
- test("show() resolves correct default display #8099", function () {
- expect(7);
- var tt8099 = jQuery("
").appendTo("body"),
- dfn8099 = jQuery("
", { html : "foo"}).appendTo("body");
+ test("animate(Hash, Object, Function)", function() {
+ expect(1);
+ stop();
+ var hash = {opacity: "show"};
+ var hashCopy = $.extend({}, hash);
+ jQuery("#foo").animate(hash, 0, function() {
+ equal( hash.opacity, hashCopy.opacity, "Check if animate changed the hash parameter" );
+ start();
+ });
+ });
- equal(tt8099.css("display"), "none", "default display override for all tt");
- equal(tt8099.show().css("display"), "inline", "Correctly resolves display:inline");
+ test("animate negative height", function() {
+ expect(1);
+ stop();
+ jQuery("#foo").animate({ height: -100 }, 100, function() {
+ equal( parseFloat(this.style.height) , 0, "Verify height." );
+ start();
+ });
+ });
- equal(jQuery("#foo").hide().show().css("display"), "block", "Correctly resolves display:block after hide/show");
+ test("animate negative margin", function() {
+ expect(1);
+ stop();
+ jQuery("#foo").animate({ "marginTop": -100 }, 100, function() {
+ equal( jQuery(this).css("marginTop"), "-100px", "Verify margin." );
+ start();
+ });
+ });
- equal(tt8099.hide().css("display"), "none", "default display override for all tt");
- equal(tt8099.show().css("display"), "inline", "Correctly resolves display:inline");
+ test("animate negative margin with px", function() {
+ expect(1);
+ stop();
+ jQuery("#foo").animate({ marginTop: "-100px" }, 100, function() {
+ equal( jQuery(this).css("marginTop"), "-100px", "Verify margin." );
+ start();
+ });
+ });
- equal(dfn8099.css("display"), "none", "default display override for all dfn");
- equal(dfn8099.show().css("display"), "inline", "Correctly resolves display:inline");
+ test("animate negative padding", function() {
+ expect(1);
+ stop();
+ jQuery("#foo").animate({ "paddingBottom": -100 }, 100, function() {
+ equal( jQuery(this).css("paddingBottom"), "0px", "Verify paddingBottom." );
+ start();
+ });
+ });
- tt8099.remove();
- dfn8099.remove();
+ test("animate block as inline width/height", function() {
+ expect(3);
- });
+ var span = jQuery("
").css("display", "inline-block").appendTo("body"),
+ expected = span.css("display");
+ span.remove();
- test("animate(Hash, Object, Function)", function () {
- expect(1);
- stop();
- var hash = {opacity : "show"};
- var hashCopy = jQuery.extend({}, hash);
- jQuery("#foo").animate(hash, 0, function () {
- equal(hash.opacity, hashCopy.opacity, "Check if animate changed the hash parameter");
- start();
- });
- });
+ if ( $.support.inlineBlockNeedsLayout || expected === "inline-block" ) {
+ stop();
- test("animate negative height", function () {
- expect(1);
- stop();
- jQuery("#foo").animate({ height : -100 }, 100, function () {
- equal(this.offsetHeight, 0, "Verify height.");
- start();
+ jQuery("#foo").css({ display: "inline", width: "", height: "" }).animate({ width: 42, height: 42 }, 100, function() {
+ equal( jQuery(this).css("display"), $.support.inlineBlockNeedsLayout ? "inline" : "inline-block", "inline-block was set on non-floated inline element when animating width/height" );
+ equal( this.offsetWidth, 42, "width was animated" );
+ equal( this.offsetHeight, 42, "height was animated" );
+ start();
+ });
+
+ // Browser doesn't support inline-block
+ } else {
+ ok( true, "Browser doesn't support inline-block" );
+ ok( true, "Browser doesn't support inline-block" );
+ ok( true, "Browser doesn't support inline-block" );
+ }
});
- });
- test("animate block as inline width/height", function () {
- expect(3);
+ test("animate native inline width/height", function() {
+ expect(3);
+
+ var span = jQuery("").css("display", "inline-block").appendTo("body"),
+ expected = span.css("display");
+
+ span.remove();
+
+ if ( $.support.inlineBlockNeedsLayout || expected === "inline-block" ) {
+ stop();
+ jQuery("#foo").css({ display: "", width: "", height: "" })
+ .append("text ")
+ .children("span")
+ .animate({ width: 42, height: 42 }, 100, function() {
+ equal( jQuery(this).css("display"), "inline-block", "inline-block was set on non-floated inline element when animating width/height" );
+ equal( this.offsetWidth, 42, "width was animated" );
+ equal( this.offsetHeight, 42, "height was animated" );
+ start();
+ });
- var span = jQuery("").css("display", "inline-block").appendTo("body"),
- expected = span.css("display");
+ // Browser doesn't support inline-block
+ } else {
+ ok( true, "Browser doesn't support inline-block" );
+ ok( true, "Browser doesn't support inline-block" );
+ ok( true, "Browser doesn't support inline-block" );
+ }
+ });
- span.remove();
+ test("animate block width/height", function() {
+ expect(3);
+ stop();
+ jQuery("#foo").css({ display: "block", width: 20, height: 20 }).animate({ width: 42, height: 42 }, 100, function() {
+ equal( jQuery(this).css("display"), "block", "inline-block was not set on block element when animating width/height" );
+ equal( this.offsetWidth, 42, "width was animated" );
+ equal( this.offsetHeight, 42, "height was animated" );
+ start();
+ });
+ });
- if (jQuery.support.inlineBlockNeedsLayout || expected === "inline-block") {
+ test("animate table width/height", function() {
+ expect(1);
stop();
- jQuery("#foo").css({ display : "inline", width : "", height : "" }).animate({ width : 42, height : 42 }, 100, function () {
- equal(jQuery(this).css("display"), jQuery.support.inlineBlockNeedsLayout ? "inline" : "inline-block", "inline-block was set on non-floated inline element when animating width/height");
- equal(this.offsetWidth, 42, "width was animated");
- equal(this.offsetHeight, 42, "height was animated");
+ var displayMode = jQuery("#table").css("display") !== "table" ? "block" : "table";
+
+ jQuery("#table").animate({ width: 42, height: 42 }, 100, function() {
+ equal( jQuery(this).css("display"), displayMode, "display mode is correct" );
start();
});
+ });
- // Browser doesn't support inline-block
- } else {
- ok(true, "Browser doesn't support inline-block");
- ok(true, "Browser doesn't support inline-block");
- ok(true, "Browser doesn't support inline-block");
- }
- });
+ test("animate table-row width/height", function() {
+ expect(3);
+ stop();
+ var tr = jQuery("#table")
+ .attr({ "cellspacing": 0, "cellpadding": 0, "border": 0 })
+ .html("
")
+ .find("tr");
+
+ // IE<8 uses "block" instead of the correct display type
+ var displayMode = tr.css("display") !== "table-row" ? "block" : "table-row";
+
+ tr.animate({ width: 10, height: 10 }, 100, function() {
+ equal( jQuery(this).css("display"), displayMode, "display mode is correct" );
+ equal( this.offsetWidth, 20, "width animated to shrink wrap point" );
+ equal( this.offsetHeight, 20, "height animated to shrink wrap point" );
+ start();
+ });
+ });
- test("animate native inline width/height", function () {
- expect(3);
+ test("animate table-cell width/height", function() {
+ expect(3);
+ stop();
+ var td = jQuery("#table")
+ .attr({ "cellspacing": 0, "cellpadding": 0, "border": 0 })
+ .html("
")
+ .find("td");
+
+ // IE<8 uses "block" instead of the correct display type
+ var displayMode = td.css("display") !== "table-cell" ? "block" : "table-cell";
+
+ td.animate({ width: 10, height: 10 }, 100, function() {
+ equal( jQuery(this).css("display"), displayMode, "display mode is correct" );
+ equal( this.offsetWidth, 20, "width animated to shrink wrap point" );
+ equal( this.offsetHeight, 20, "height animated to shrink wrap point" );
+ start();
+ });
+ });
- var span = jQuery("").css("display", "inline-block").appendTo("body"),
- expected = span.css("display");
+ test("animate percentage(%) on width/height", function() {
+ expect( 2 );
- span.remove();
+ var $div = jQuery("")
+ .appendTo("#qunit-fixture").children("div");
- if (jQuery.support.inlineBlockNeedsLayout || expected === "inline-block") {
stop();
- jQuery("#foo").css({ display : "", width : "", height : "" })
- .append("text ")
- .children("span")
- .animate({ width : 42, height : 42 }, 100, function () {
- equal(jQuery(this).css("display"), "inline-block", "inline-block was set on non-floated inline element when animating width/height");
- equal(this.offsetWidth, 42, "width was animated");
- equal(this.offsetHeight, 42, "height was animated");
+ $div.animate({ width: "25%", height: "25%" }, 13, function() {
+ var $this = jQuery(this);
+ equal( $this.css("width"), "15px", "Width was animated to 15px rather than 25px");
+ equal( $this.css("height"), "15px", "Height was animated to 15px rather than 25px");
+ start();
+ });
+ });
+
+ test("animate resets overflow-x and overflow-y when finished", function() {
+ expect(2);
+ stop();
+ jQuery("#foo")
+ .css({ display: "block", width: 20, height: 20, overflowX: "visible", overflowY: "auto" })
+ .animate({ width: 42, height: 42 }, 100, function() {
+ equal( this.style.overflowX, "visible", "overflow-x is visible" );
+ equal( this.style.overflowY, "auto", "overflow-y is auto" );
start();
});
+ });
- // Browser doesn't support inline-block
- } else {
- ok(true, "Browser doesn't support inline-block");
- ok(true, "Browser doesn't support inline-block");
- ok(true, "Browser doesn't support inline-block");
- }
- });
+ /* // This test ends up being flaky depending upon the CPU load
+ test("animate option (queue === false)", function () {
+ expect(1);
+ stop();
+
+ var order = [];
+
+ var $foo = jQuery("#foo");
+ $foo.animate({width:"100px"}, 3000, function () {
+ // should finish after unqueued animation so second
+ order.push(2);
+ deepEqual( order, [ 1, 2 ], "Animations finished in the correct order" );
+ start();
+ });
+ $foo.animate({fontSize:"2em"}, {queue:false, duration:10, complete:function () {
+ // short duration and out of queue so should finish first
+ order.push(1);
+ }});
+ });
+ */
+
+ asyncTest( "animate option { queue: false }", function() {
+ expect( 2 );
+ var foo = jQuery( "#foo" );
+
+ foo.animate({
+ fontSize: "2em"
+ }, {
+ queue: false,
+ duration: 10,
+ complete: function() {
+ ok( true, "Animation Completed" );
+ start();
+ }
+ });
- test("animate block width/height", function () {
- expect(3);
- stop();
- jQuery("#foo").css({ display : "block", width : 20, height : 20 }).animate({ width : 42, height : 42 }, 100, function () {
- equal(jQuery(this).css("display"), "block", "inline-block was not set on block element when animating width/height");
- equal(this.offsetWidth, 42, "width was animated");
- equal(this.offsetHeight, 42, "height was animated");
- start();
+ equal( foo.queue().length, 0, "Queue is empty" );
});
- });
- test("animate table width/height", function () {
- expect(1);
- stop();
-
- var displayMode = jQuery("#table").css("display") !== "table" ? "block" : "table";
+ asyncTest( "animate option { queue: true }", function() {
+ expect( 2 );
+ var foo = jQuery( "#foo" );
+
+ foo.animate({
+ fontSize: "2em"
+ }, {
+ queue: true,
+ duration: 10,
+ complete: function() {
+ ok( true, "Animation Completed" );
+ start();
+ }
+ });
- jQuery("#table").animate({ width : 42, height : 42 }, 100, function () {
- equal(jQuery(this).css("display"), displayMode, "display mode is correct");
- start();
+ notEqual( foo.queue().length, 0, "Default queue is not empty" );
});
- });
- test("animate table-row width/height", function () {
- expect(3);
- stop();
- var tr = jQuery("#table")
- .attr({ "cellspacing" : 0, "cellpadding" : 0, "border" : 0 })
- .html("
")
- .find("tr");
-
- // IE<8 uses "block" instead of the correct display type
- var displayMode = tr.css("display") !== "table-row" ? "block" : "table-row";
-
- tr.animate({ width : 10, height : 10 }, 100, function () {
- equal(jQuery(this).css("display"), displayMode, "display mode is correct");
- equal(this.offsetWidth, 20, "width animated to shrink wrap point");
- equal(this.offsetHeight, 20, "height animated to shrink wrap point");
- start();
- });
- });
+ asyncTest( "animate option { queue: 'name' }", function() {
+ expect( 5 );
+ var foo = jQuery( "#foo" ),
+ origWidth = parseFloat( foo.css("width") ),
+ order = [];
+
+ foo.animate( { width: origWidth + 100 }, {
+ queue: 'name',
+ duration: 1,
+ complete: function() {
+
+ // second callback function
+ order.push( 2 );
+ equal( parseFloat( foo.css("width") ), origWidth + 100, "Animation ended" );
+ equal( foo.queue("name").length, 1, "Queue length of 'name' queue" );
+ }
+ }).queue( "name", function( next ) {
- test("animate table-cell width/height", function () {
- expect(3);
- stop();
- var td = jQuery("#table")
- .attr({ "cellspacing" : 0, "cellpadding" : 0, "border" : 0 })
- .html("
")
- .find("td");
-
- // IE<8 uses "block" instead of the correct display type
- var displayMode = td.css("display") !== "table-cell" ? "block" : "table-cell";
-
- td.animate({ width : 10, height : 10 }, 100, function () {
- equal(jQuery(this).css("display"), displayMode, "display mode is correct");
- equal(this.offsetWidth, 20, "width animated to shrink wrap point");
- equal(this.offsetHeight, 20, "height animated to shrink wrap point");
- start();
- });
- });
+ // last callback function
+ deepEqual( order, [ 1, 2 ], "Callbacks in expected order" );
+ start();
+ });
- test("animate percentage(%) on width/height", function () {
- expect(2);
+ setTimeout( function() {
- var $div = jQuery("")
- .appendTo("#qunit-fixture").children("div");
+ // this is the first callback function that should be called
+ order.push( 1 );
+ equal( parseFloat( foo.css("width") ), origWidth, "Animation does not start on its own." );
+ equal( foo.queue("name").length, 2, "Queue length of 'name' queue" );
+ foo.dequeue( "name" );
+ }, 100 );
- stop();
- $div.animate({ width : "25%", height : "25%" }, 13, function () {
- var $this = jQuery(this);
- equal($this.width(), 15, "Width was animated to 15px rather than 25px");
- equal($this.height(), 15, "Height was animated to 15px rather than 25px");
- start();
});
- });
- test("animate resets overflow-x and overflow-y when finished", function () {
- expect(2);
- stop();
- jQuery("#foo")
- .css({ display : "block", width : 20, height : 20, overflowX : "visible", overflowY : "auto" })
- .animate({ width : 42, height : 42 }, 100, function () {
- equal(this.style.overflowX, "visible", "overflow-x is visible");
- equal(this.style.overflowY, "auto", "overflow-y is auto");
- start();
+ test("animate with no properties", function() {
+ expect(2);
+
+ var divs = jQuery("div"), count = 0;
+
+ divs.animate({}, function(){
+ count++;
});
- });
- asyncTest("animate option { queue: false }", function () {
- expect(2);
- var foo = jQuery("#foo");
-
- foo.animate({
- fontSize : "2em"
- }, {
- queue : false,
- duration : 10,
- complete : function () {
- ok(true, "Animation Completed");
- start();
- }
- });
+ equal( divs.length, count, "Make sure that callback is called for each element in the set." );
- equal(foo.queue().length, 0, "Queue is empty");
- });
+ stop();
- asyncTest("animate option { queue: true }", function () {
- expect(2);
- var foo = jQuery("#foo");
-
- foo.animate({
- fontSize : "2em"
- }, {
- queue : true,
- duration : 10,
- complete : function () {
- ok(true, "Animation Completed");
+ var foo = jQuery("#foo");
+
+ foo.animate({});
+ foo.animate({top: 10}, 100, function(){
+ ok( true, "Animation was properly dequeued." );
start();
- }
+ });
});
- notEqual(foo.queue().length, 0, "Default queue is not empty");
- });
+ test("animate duration 0", function() {
+ expect(11);
+ stop();
- asyncTest("animate option { queue: 'name' }", function () {
- expect(5);
- var foo = jQuery("#foo"),
- origWidth = foo.width(),
- order = [];
+ var $elems = jQuery([{ a:0 },{ a:0 }]), counter = 0;
- foo.animate({ width : origWidth + 100 }, {
- queue : 'name',
- duration : 1,
- complete : function () {
+ equal( $.timers.length, 0, "Make sure no animation was running from another test" );
- // second callback function
- order.push(2);
- equal(foo.width(), origWidth + 100, "Animation ended");
- equal(foo.queue("name").length, 1, "Queue length of 'name' queue");
- }
- }).queue("name", function (next) {
+ $elems.eq(0).animate( {a:1}, 0, function(){
+ ok( true, "Animate a simple property." );
+ counter++;
+ });
- // last callback function
- deepEqual(order, [ 1, 2 ], "Callbacks in expected order");
- start();
+ // Failed until [6115]
+ equal( $.timers.length, 0, "Make sure synchronic animations are not left on $.timers" );
+
+ equal( counter, 1, "One synchronic animations" );
+
+ $elems.animate( { a:2 }, 0, function(){
+ ok( true, "Animate a second simple property." );
+ counter++;
});
- setTimeout(function () {
+ equal( counter, 3, "Multiple synchronic animations" );
- // this is the first callback function that should be called
- order.push(1);
- equal(foo.width(), origWidth, "Animation does not start on its own.");
- equal(foo.queue("name").length, 2, "Queue length of 'name' queue");
- foo.dequeue("name");
- }, 100);
+ $elems.eq(0).animate( {a:3}, 0, function(){
+ ok( true, "Animate a third simple property." );
+ counter++;
+ });
+ $elems.eq(1).animate( {a:3}, 200, function(){
+ counter++;
+ // Failed until [6115]
+ equal( counter, 5, "One synchronic and one asynchronic" );
+ start();
+ });
- });
+ var $elem = jQuery("
");
+ $elem.show(0, function(){
+ ok(true, "Show callback with no duration");
+ });
+ $elem.hide(0, function(){
+ ok(true, "Hide callback with no duration");
+ });
- test("animate with no properties", function () {
- expect(2);
+ // manually clean up detached elements
+ $elem.remove();
+ });
- var divs = jQuery("div"), count = 0;
+ test("animate hyphenated properties", function() {
+ expect(1);
+ stop();
- divs.animate({}, function () {
- count++;
+ jQuery("#foo")
+ .css("font-size", 10)
+ .animate({"font-size": 20}, 200, function() {
+ equal( this.style.fontSize, "20px", "The font-size property was animated." );
+ start();
+ });
});
- equal(divs.length, count, "Make sure that callback is called for each element in the set.");
+ test("animate non-element", function() {
+ expect(1);
+ stop();
- stop();
+ var obj = { test: 0 };
- var foo = jQuery("#foo");
+ jQuery(obj).animate({test: 200}, 200, function(){
+ equal( obj.test, 200, "The custom property should be modified." );
+ start();
+ });
+ });
- foo.animate({});
- foo.animate({ top : 10 }, 100, function () {
- ok(true, "Animation was properly dequeued.");
- start();
+ test("stop()", function() {
+ expect( 4 );
+ stop();
+
+ var $foo = jQuery("#foo"),
+ tests = 2,
+ w = 0;
+
+ $foo.hide().css( "width", 200 )
+ .animate( { "width": "show" }, 1500 );
+
+ setTimeout(function() {
+ var nw = $foo.css("width");
+ notEqual( parseFloat( nw ), w, "An animation occurred " + nw + " " + w + "px" );
+ $foo.stop();
+
+ nw = $foo.css("width");
+ notEqual( parseFloat( nw ), w, "Stop didn't reset the animation " + nw + " " + w + "px" );
+ setTimeout(function() {
+ $foo.removeData();
+ $foo.removeData(undefined, true);
+ equal( nw, $foo.css("width"), "The animation didn't continue" );
+ if ( --tests === 0 ) {
+ start();
+ }
+ }, 100);
+ }, 100);
+
+ var $one = jQuery("#fadein");
+ var $two = jQuery("#show");
+ $one.fadeTo(100, 0, function() {
+ $one.stop();
+ });
+ setTimeout(function() {
+ $two.fadeTo(100, 0, function() {
+ equal( $two.css("opacity"), "0", "Stop does not interfere with animations on other elements (#6641)" );
+ // Reset styles
+ $one.add( $two ).css("opacity", "");
+ if ( --tests === 0 ) {
+ start();
+ }
+ });
+ }, 50);
});
- });
- test("animate duration 0", function () {
- expect(11);
+ test("stop() - several in queue", function() {
+ expect(3);
+ stop();
- stop();
+ var $foo = jQuery("#foo");
+ var w = 0;
+ $foo.hide().css( "width", 200 ).css("width");
- var $elems = jQuery([
- { a : 0 },
- { a : 0 }
- ]), counter = 0;
+ $foo.animate({ "width": "show" }, 1500);
+ $foo.animate({ "width": "hide" }, 1000);
+ $foo.animate({ "width": "show" }, 1000);
+ setTimeout(function(){
+ equal( $foo.queue().length, 3, "All 3 still in the queue" );
+ var nw = $foo.css("width");
+ notEqual( parseFloat( nw ), w, "An animation occurred " + nw + " " + w + "px");
+ $foo.stop();
- equal(jQuery.timers.length, 0, "Make sure no animation was running from another test");
+ nw = $foo.css("width");
+ notEqual( parseFloat( nw ), w, "Stop didn't reset the animation " + nw + " " + w + "px");
- $elems.eq(0).animate({a : 1}, 0, function () {
- ok(true, "Animate a simple property.");
- counter++;
+ $foo.stop(true);
+ start();
+ }, 200);
});
- // Failed until [6115]
- equal(jQuery.timers.length, 0, "Make sure synchronic animations are not left on jQuery.timers");
+ test("stop(clearQueue)", function() {
+ expect(4);
+ stop();
+
+ var $foo = jQuery("#foo");
+ var w = 0;
+ $foo.hide().css( "width", 200 ).css("width");
+
+ $foo.animate({ "width": "show" }, 1000);
+ $foo.animate({ "width": "hide" }, 1000);
+ $foo.animate({ "width": "show" }, 1000);
+ setTimeout(function(){
+ var nw = $foo.css("width");
+ ok( parseFloat( nw ) != w, "An animation occurred " + nw + " " + w + "px");
+ $foo.stop(true);
- equal(counter, 1, "One synchronic animations");
+ nw = $foo.css("width");
+ ok( parseFloat( nw ) != w, "Stop didn't reset the animation " + nw + " " + w + "px");
- $elems.animate({ a : 2 }, 0, function () {
- ok(true, "Animate a second simple property.");
- counter++;
+ equal( $foo.queue().length, 0, "The animation queue was cleared" );
+ setTimeout(function(){
+ equal( nw, $foo.css("width"), "The animation didn't continue" );
+ start();
+ }, 100);
+ }, 100);
});
- equal(counter, 3, "Multiple synchronic animations");
+ test("stop(clearQueue, gotoEnd)", function() {
+ expect(1);
+ stop();
+
+ var $foo = jQuery("#foo");
+ var w = 0;
+ $foo.hide().css( "width", 200 ).css("width");
- $elems.eq(0).animate({a : 3}, 0, function () {
- ok(true, "Animate a third simple property.");
- counter++;
+ $foo.animate({ width: "show" }, 1000);
+ $foo.animate({ width: "hide" }, 1000);
+ $foo.animate({ width: "show" }, 1000);
+ $foo.animate({ width: "hide" }, 1000);
+ setTimeout(function(){
+ var nw = $foo.css("width");
+ ok( parseFloat( nw ) != w, "An animation occurred " + nw + " " + w + "px");
+ $foo.stop(false, true);
+
+ nw = $foo.css("width");
+ // Disabled, being flaky
+ //equal( nw, 1, "Stop() reset the animation" );
+
+ setTimeout(function(){
+ // Disabled, being flaky
+ //equal( $foo.queue().length, 2, "The next animation continued" );
+ $foo.stop(true);
+ start();
+ }, 100);
+ }, 100);
});
- $elems.eq(1).animate({a : 3}, 200, function () {
- counter++;
- // Failed until [6115]
- equal(counter, 5, "One synchronic and one asynchronic");
- start();
+
+ asyncTest( "stop( queue, ..., ... ) - Stop single queues", function() {
+ expect( 3 );
+ var foo = jQuery( "#foo" ),
+ saved;
+
+ foo.css( "width", 200 ).css( "height", 200 );
+ foo.animate({
+ width: 400
+ },{
+ duration: 1000,
+ complete: function() {
+ equal( parseFloat( foo.css("width") ), 400, "Animation completed for standard queue" );
+ equal( parseFloat( foo.css("height") ), saved, "Height was not changed after the second stop");
+ start();
+ }
+ });
+
+ foo.animate({
+ height: 400
+ },{
+ duration: 1000,
+ queue: "height"
+ }).dequeue( "height" ).stop( "height", false, true );
+
+ equal( parseFloat( foo.css("height") ), 400, "Height was stopped with gotoEnd" );
+
+ foo.animate({
+ height: 200
+ },{
+ duration: 1000,
+ queue: "height"
+ }).dequeue( "height" ).stop( "height", false, false );
+ saved = parseFloat( foo.css("height") );
});
- var $elem = jQuery("
");
- $elem.show(0, function () {
- ok(true, "Show callback with no duration");
+ test("toggle()", function() {
+ expect(6);
+ var x = jQuery("#foo");
+ ok( x.is(":visible"), "is visible" );
+ x.toggle();
+ ok( x.is(":hidden"), "is hidden" );
+ x.toggle();
+ ok( x.is(":visible"), "is visible again" );
+
+ x.toggle(true);
+ ok( x.is(":visible"), "is visible" );
+ x.toggle(false);
+ ok( x.is(":hidden"), "is hidden" );
+ x.toggle(true);
+ ok( x.is(":visible"), "is visible again" );
});
- $elem.hide(0, function () {
- ok(true, "Hide callback with no duration");
+
+ $.checkOverflowDisplay = function(){
+ var o = $.css( this, "overflow" );
+
+ equal(o, "visible", "Overflow should be visible: " + o);
+ equal($.css( this, "display" ), "inline", "Display shouldn't be tampered with.");
+
+ jQuery(this).remove();
+ start();
+ };
+
+ test("JS Overflow and Display", function() {
+ expect(2);
+ stop();
+ $.makeTest( "JS Overflow and Display" )
+ .addClass("widewidth")
+ .css({ overflow: "visible", display: "inline" })
+ .addClass("widewidth")
+ .text("Some sample text.")
+ .before("text before")
+ .after("text after")
+ .animate({ opacity: 0.5 }, "slow", $.checkOverflowDisplay);
});
- // manually clean up detached elements
- $elem.remove();
- });
+ test("CSS Overflow and Display", function() {
+ expect(2);
+ stop();
+ $.makeTest( "CSS Overflow and Display" )
+ .addClass("overflow inline")
+ .addClass("widewidth")
+ .text("Some sample text.")
+ .before("text before")
+ .after("text after")
+ .animate({ opacity: 0.5 }, "slow", $.checkOverflowDisplay);
+ });
- test("animate hyphenated properties", function () {
- expect(1);
- stop();
+ $.each({
+ "CSS Auto": function( elem, prop ) {
+ jQuery( elem ).addClass( "auto" + prop )
+ .text( "This is a long string of text." );
+ return "";
+ },
+ "JS Auto": function( elem, prop ) {
+ jQuery( elem ).css( prop, "" )
+ .text( "This is a long string of text." );
+ return "";
+ },
+ "CSS 100": function( elem, prop ) {
+ jQuery( elem ).addClass( "large" + prop );
+ return "";
+ },
+ "JS 100": function( elem, prop ) {
+ jQuery( elem ).css( prop, prop === "opacity" ? 1 : "100px" );
+ return prop === "opacity" ? 1 : 100;
+ },
+ "CSS 50": function( elem, prop ) {
+ jQuery( elem ).addClass( "med" + prop );
+ return "";
+ },
+ "JS 50": function( elem, prop ) {
+ jQuery( elem ).css( prop, prop === "opacity" ? 0.50 : "50px" );
+ return prop === "opacity" ? 0.5 : 50;
+ },
+ "CSS 0": function( elem, prop ) {
+ jQuery( elem ).addClass( "no" + prop );
+ return "";
+ },
+ "JS 0": function( elem, prop ) {
+ jQuery( elem ).css( prop, prop === "opacity" ? 0 : "0px" );
+ return 0;
+ }
+ }, function( fn, f ) {
+ $.each({
+ "show": function( elem, prop ) {
+ jQuery( elem ).hide( ).addClass( "wide" + prop );
+ return "show";
+ },
+ "hide": function( elem, prop ) {
+ jQuery( elem ).addClass( "wide" + prop );
+ return "hide";
+ },
+ "100": function( elem, prop ) {
+ jQuery( elem ).addClass( "wide" + prop );
+ return prop == "opacity" ? 1 : 100;
+ },
+ "50": function( elem, prop ) {
+ return prop == "opacity" ? 0.50 : 50;
+ },
+ "0": function( elem, prop ) {
+ jQuery( elem ).addClass( "noback" );
+ return 0;
+ }
+ }, function( tn, t ) {
+ test(fn + " to " + tn, function() {
+ var elem = $.makeTest( fn + " to " + tn );
+
+ var t_w = t( elem, "width" );
+ var f_w = f( elem, "width" );
+ var t_h = t( elem, "height" );
+ var f_h = f( elem, "height" );
+ var t_o = t( elem, "opacity" );
+ var f_o = f( elem, "opacity" );
+
+ if ( f_o === "" ) {
+ f_o = 1;
+ }
- jQuery("#foo")
- .css("font-size", 10)
- .animate({"font-size" : 20}, 200, function () {
- equal(this.style.fontSize, "20px", "The font-size property was animated.");
- start();
- });
- });
+ var num = 0;
+ // TODO: uncrowd this
+ if ( t_h == "show" ) {num++;}
+ if ( t_w == "show" ) {num++;}
+ if ( t_w == "hide" || t_w == "show" ) {num++;}
+ if ( t_h == "hide" || t_h == "show" ) {num++;}
+ if ( t_o == "hide" || t_o == "show" ) {num++;}
+ if ( t_w == "hide" ) {num++;}
+ if ( t_o.constructor == Number ) {num += 2;}
+ if ( t_w.constructor == Number ) {num += 2;}
+ if ( t_h.constructor == Number ) {num +=2;}
+
+ expect( num );
+ stop();
- test("animate non-element", function () {
- expect(1);
- stop();
+ var anim = { width: t_w, height: t_h, opacity: t_o };
- var obj = { test : 0 };
+ elem.animate(anim, 50);
- jQuery(obj).animate({test : 200}, 200, function () {
- equal(obj.test, 200, "The custom property should be modified.");
- start();
- });
- });
+ $.when( elem ).done(function( elem ) {
- test("stop()", function () {
- expect(4);
- stop();
+ elem = elem[ 0 ];
- var $foo = jQuery("#foo");
- var w = 0;
+ if ( t_w == "show" ) {
+ equal( elem.style.display, "block", "Showing, display should block: " + elem.style.display );
+ }
- $foo.hide().width(200)
- .animate({ width : "show" }, 1000);
+ if ( t_w == "hide" || t_w == "show" ) {
+ ok( f_w === "" ? elem.style.width === f_w : elem.style.width.indexOf( f_w ) === 0, "Width must be reset to " + f_w + ": " + elem.style.width );
+ }
- setTimeout(function () {
- var nw = $foo.width();
- notEqual(nw, w, "An animation occurred " + nw + "px " + w + "px");
- $foo.stop();
+ if ( t_h == "hide" || t_h == "show" ) {
+ ok( f_h === "" ? elem.style.height === f_h : elem.style.height.indexOf( f_h ) === 0, "Height must be reset to " + f_h + ": " + elem.style.height );
+ }
- nw = $foo.width();
- notEqual(nw, w, "Stop didn't reset the animation " + nw + "px " + w + "px");
- setTimeout(function () {
- $foo.removeData();
- $foo.removeData(undefined, true);
- equal(nw, $foo.width(), "The animation didn't continue");
- start();
- }, 100);
- }, 100);
-
- var $one = jQuery("#fadein");
- var $two = jQuery("#show");
- $one.fadeTo(100, 0, function () {
- $one.stop();
- });
- setTimeout(function () {
- $two.fadeTo(100, 0, function () {
- equal($two.css("opacity"), "0", "Stop does not interfere with animations on other elements (#6641)");
- // Reset styles
- $one.add($two).css("opacity", "");
- });
- }, 50);
- });
+ var cur_o = $.style(elem, "opacity");
- test("stop() - several in queue", function () {
- expect(3);
- stop();
+ if ( f_o !== $.css(elem, "opacity") ) {
+ f_o = f( elem, "opacity" );
+ }
- var $foo = jQuery("#foo");
- var w = 0;
- $foo.hide().width(200).width();
+ // The only time an _empty_string_ will be matched is in IE
+ // otherwise, the correct values will be tested as usual
+ if ( f_o === "" ) {
+ f_o = 1;
+ }
+ // See above
+ if ( cur_o === "" ) {
+ cur_o = 1;
+ }
- $foo.animate({ width : "show" }, 1000);
- $foo.animate({ width : "hide" }, 1000);
- $foo.animate({ width : "show" }, 1000);
- setTimeout(function () {
- equal($foo.queue().length, 3, "All 3 still in the queue");
- var nw = $foo.width();
- notEqual(nw, w, "An animation occurred " + nw + "px " + w + "px");
- $foo.stop();
+ if ( t_o == "hide" || t_o == "show" ) {
+ equal( cur_o, f_o, "Opacity must be reset to " + f_o + ": " + cur_o );
+ }
- nw = $foo.width();
- notEqual(nw, w, "Stop didn't reset the animation " + nw + "px " + w + "px");
+ if ( t_w == "hide" ) {
+ equal( elem.style.display, "none", "Hiding, display should be none: " + elem.style.display );
+ }
- $foo.stop(true);
- start();
- }, 100);
- });
+ if ( t_o.constructor == Number ) {
+ equal( cur_o, t_o, "Final opacity should be " + t_o + ": " + cur_o );
- test("stop(clearQueue)", function () {
- expect(4);
- stop();
+ ok( $.css(elem, "opacity") !== "" || cur_o == t_o, "Opacity should be explicitly set to " + t_o + ", is instead: " + cur_o );
+ }
- var $foo = jQuery("#foo");
- var w = 0;
- $foo.hide().width(200).width();
+ if ( t_w.constructor == Number ) {
+ equal( elem.style.width, t_w + "px", "Final width should be " + t_w + ": " + elem.style.width );
- $foo.animate({ width : "show" }, 1000);
- $foo.animate({ width : "hide" }, 1000);
- $foo.animate({ width : "show" }, 1000);
- setTimeout(function () {
- var nw = $foo.width();
- ok(nw != w, "An animation occurred " + nw + "px " + w + "px");
- $foo.stop(true);
+ var cur_w = $.css( elem,"width" );
- nw = $foo.width();
- ok(nw != w, "Stop didn't reset the animation " + nw + "px " + w + "px");
+ ok( elem.style.width !== "" || cur_w == t_w, "Width should be explicitly set to " + t_w + ", is instead: " + cur_w );
+ }
- equal($foo.queue().length, 0, "The animation queue was cleared");
- setTimeout(function () {
- equal(nw, $foo.width(), "The animation didn't continue");
- start();
- }, 100);
- }, 100);
- });
+ if ( t_h.constructor == Number ) {
+ equal( elem.style.height, t_h + "px", "Final height should be " + t_h + ": " + elem.style.height );
- test("stop(clearQueue, gotoEnd)", function () {
- expect(1);
- stop();
+ var cur_h = $.css( elem,"height" );
- var $foo = jQuery("#foo");
- var w = 0;
- $foo.hide().width(200).width();
+ ok( elem.style.height !== "" || cur_h == t_h, "Height should be explicitly set to " + t_h + ", is instead: " + cur_h );
+ }
- $foo.animate({ width : "show" }, 1000);
- $foo.animate({ width : "hide" }, 1000);
- $foo.animate({ width : "show" }, 1000);
- $foo.animate({ width : "hide" }, 1000);
- setTimeout(function () {
- var nw = $foo.width();
- ok(nw != w, "An animation occurred " + nw + "px " + w + "px");
- $foo.stop(false, true);
+ if ( t_h == "show" ) {
+ var old_h = $.css( elem, "height" );
+ jQuery( elem ).append(" Some more text and some more...");
- nw = $foo.width();
- // Disabled, being flaky
- //equal( nw, 1, "Stop() reset the animation" );
+ if ( /Auto/.test( fn ) ) {
+ notEqual( $.css( elem, "height" ), old_h, "Make sure height is auto." );
+ } else {
+ equal( $.css( elem, "height" ), old_h, "Make sure height is not auto." );
+ }
+ }
- setTimeout(function () {
- // Disabled, being flaky
- //equal( $foo.queue().length, 2, "The next animation continued" );
- $foo.stop(true);
- start();
- }, 100);
- }, 100);
- });
+ // manually remove generated element
+ jQuery( elem ).remove();
- asyncTest("stop( queue, ..., ... ) - Stop single queues", function () {
- expect(3);
- var foo = jQuery("#foo"),
- saved;
-
- foo.width(200).height(200);
- foo.animate({
- width : 400
- }, {
- duration : 1000,
- complete : function () {
- equal(foo.width(), 400, "Animation completed for standard queue");
- equal(foo.height(), saved, "Height was not changed after the second stop");
- start();
- }
+ start();
+ });
+ });
+ });
});
- foo.animate({
- height : 400
- }, {
- duration : 1000,
- queue : "height"
- }).dequeue("height").stop("height", false, true);
+ $.fn.saveState = function( hiddenOverflow ) {
+ var check = ["opacity", "height", "width", "display", "overflow"];
+ expect(check.length);
- equal(foo.height(), 400, "Height was stopped with gotoEnd");
+ stop();
+ return this.each(function(){
+ var self = this;
+ self.save = {};
+ $.each(check, function( i, c ) {
+ self.save[ c ] = c === "overflow" && hiddenOverflow ? "hidden" : self.style[ c ] || $.css( self, c );
+ });
+ });
+ };
- foo.animate({
- height : 200
- }, {
- duration : 1000,
- queue : "height"
- }).dequeue("height").stop("height", false, false);
- saved = foo.height();
- });
+ /** @expose */
+ $.checkState = function() {
+ var self = this;
+ $.each(this.save, function( c, v ) {
+ var cur = self.style[ c ] || $.css( self, c );
+ equal( cur, v, "Make sure that " + c + " is reset (Old: " + v + " Cur: " + cur + ")");
+ });
- test("toggle()", function () {
- expect(6);
- var x = jQuery("#foo");
- ok(x.is(":visible"), "is visible");
- x.toggle();
- ok(x.is(":hidden"), "is hidden");
- x.toggle();
- ok(x.is(":visible"), "is visible again");
-
- x.toggle(true);
- ok(x.is(":visible"), "is visible");
- x.toggle(false);
- ok(x.is(":hidden"), "is hidden");
- x.toggle(true);
- ok(x.is(":visible"), "is visible again");
- });
+ // manually clean data on modified element
+ $.removeData( this, "olddisplay", true );
- jQuery.checkOverflowDisplay = function () {
- var o = jQuery.css(this, "overflow");
+ start();
+ };
- equal(o, "visible", "Overflow should be visible: " + o);
- equal(jQuery.css(this, "display"), "inline", "Display shouldn't be tampered with.");
+// Chaining Tests
+ test("Chain fadeOut fadeIn", function() {
+ jQuery("#fadein div").saveState().fadeOut("fast").fadeIn("fast", $.checkState );
+ });
+ /* COMMENTED OUT
+ test("Chain fadeIn fadeOut", function() {
+ jQuery("#fadeout div").saveState().fadeIn("fast").fadeOut("fast", $.checkState );
+ });
+ */
+
+ test("Chain hide show", function() {
+ jQuery("#show div").saveState( $.support.shrinkWrapBlocks ).hide("fast").show("fast", $.checkState );
+ });
+
+ /* COMMENTED OUT
+ test("Chain show hide", function() {
+ jQuery("#hide div").saveState( $.support.shrinkWrapBlocks ).show("fast").hide("fast", $.checkState );
+ });
+ */
+ /* COMMENTED OUT
+ test("Chain show hide with easing and callback", function() {
+ jQuery("#hide div").saveState().show("fast").hide("fast","linear", $.checkState );
+ });
+ */
- start();
- };
+ test("Chain toggle in", function() {
+ jQuery("#togglein div").saveState( $.support.shrinkWrapBlocks ).toggle("fast").toggle("fast", $.checkState );
+ });
+ test("Chain toggle out", function() {
+ jQuery("#toggleout div").saveState( $.support.shrinkWrapBlocks ).toggle("fast").toggle("fast", $.checkState );
+ });
+ test("Chain toggle out with easing and callback", function() {
+ jQuery("#toggleout div").saveState( $.support.shrinkWrapBlocks ).toggle("fast").toggle("fast","linear", $.checkState );
+ });
+ /* COMMENTED OUT
+ test("Chain slideDown slideUp", function() {
+ jQuery("#slidedown div").saveState( $.support.shrinkWrapBlocks ).slideDown("fast").slideUp("fast", $.checkState );
+ });
+ */
+ test("Chain slideUp slideDown", function() {
+ jQuery("#slideup div").saveState( $.support.shrinkWrapBlocks ).slideUp("fast").slideDown("fast", $.checkState );
+ });
+ test("Chain slideUp slideDown with easing and callback", function() {
+ jQuery("#slideup div").saveState( $.support.shrinkWrapBlocks ).slideUp("fast").slideDown("fast","linear", $.checkState );
+ });
- test("jQuery.fx.prototype.cur()", 6, function () {
- var div = jQuery("
").appendTo("#qunit-fixture").css({
- color : "#ABC",
- border : "5px solid black",
- left : "auto",
- marginBottom : "-11000px"
- })[0];
-
- equal(
- ( new jQuery.fx(div, {}, "color") ).cur(),
- jQuery.css(div, "color"),
- "Return the same value as jQuery.css for complex properties (bug #7912)"
- );
-
- strictEqual(
- ( new jQuery.fx(div, {}, "borderLeftWidth") ).cur(),
- 5,
- "Return simple values parsed as Float"
- );
-
- // backgroundPosition actually returns 0% 0% in most browser
- // this fakes a "" return
- jQuery.cssHooks.backgroundPosition = {
- get : function () {
- ok(true, "hook used");
- return "";
- }
- };
+ test("Chain slideToggle in", function() {
+ jQuery("#slidetogglein div").saveState( $.support.shrinkWrapBlocks ).slideToggle("fast").slideToggle("fast", $.checkState );
+ });
+ test("Chain slideToggle out", function() {
+ jQuery("#slidetoggleout div").saveState( $.support.shrinkWrapBlocks ).slideToggle("fast").slideToggle("fast", $.checkState );
+ });
- strictEqual(
- ( new jQuery.fx(div, {}, "backgroundPosition") ).cur(),
- 0,
- "Return 0 when jQuery.css returns an empty string"
- );
-
- delete jQuery.cssHooks.backgroundPosition;
-
- strictEqual(
- ( new jQuery.fx(div, {}, "left") ).cur(),
- 0,
- "Return 0 when jQuery.css returns 'auto'"
- );
-
- equal(
- ( new jQuery.fx(div, {}, "marginBottom") ).cur(),
- -11000,
- "support negative values < -10000 (bug #7193)"
- );
- });
+ test("Chain fadeToggle in", function() {
+ jQuery("#fadetogglein div").saveState().fadeToggle("fast").fadeToggle("fast", $.checkState );
+ });
+ test("Chain fadeToggle out", function() {
+ jQuery("#fadetoggleout div").saveState().fadeToggle("fast").fadeToggle("fast", $.checkState );
+ });
- test("JS Overflow and Display", function () {
- expect(2);
- stop();
- jQuery.makeTest("JS Overflow and Display")
- .addClass("widewidth")
- .css({ overflow : "visible", display : "inline" })
- .addClass("widewidth")
- .text("Some sample text.")
- .before("text before")
- .after("text after")
- .animate({ opacity : 0.5 }, "slow", jQuery.checkOverflowDisplay);
- });
+ test("Chain fadeTo 0.5 1.0 with easing and callback)", function() {
+ jQuery("#fadeto div").saveState().fadeTo("fast",0.5).fadeTo("fast",1.0,"linear", $.checkState );
+ });
- test("CSS Overflow and Display", function () {
- expect(2);
- stop();
- jQuery.makeTest("CSS Overflow and Display")
- .addClass("overflow inline")
- .addClass("widewidth")
- .text("Some sample text.")
- .before("text before")
- .after("text after")
- .animate({ opacity : 0.5 }, "slow", jQuery.checkOverflowDisplay);
- });
+ $.makeTest = function( text ){
+ var elem = jQuery("
")
+ .attr( "id", "test" + $.makeTest.id++ )
+ .addClass("box");
- jQuery.each({
- "CSS Auto" : function (elem, prop) {
- jQuery(elem).addClass("auto" + prop)
- .text("This is a long string of text.");
- return "";
- },
- "JS Auto" : function (elem, prop) {
- jQuery(elem).css(prop, "")
- .text("This is a long string of text.");
- return "";
- },
- "CSS 100" : function (elem, prop) {
- jQuery(elem).addClass("large" + prop);
- return "";
- },
- "JS 100" : function (elem, prop) {
- jQuery(elem).css(prop, prop === "opacity" ? 1 : "100px");
- return prop === "opacity" ? 1 : 100;
- },
- "CSS 50" : function (elem, prop) {
- jQuery(elem).addClass("med" + prop);
- return "";
- },
- "JS 50" : function (elem, prop) {
- jQuery(elem).css(prop, prop === "opacity" ? 0.50 : "50px");
- return prop === "opacity" ? 0.5 : 50;
- },
- "CSS 0" : function (elem, prop) {
- jQuery(elem).addClass("no" + prop);
- return "";
- },
- "JS 0" : function (elem, prop) {
- jQuery(elem).css(prop, prop === "opacity" ? 0 : "0px");
- return 0;
- }
- }, function (fn, f) {
- jQuery.each({
- "show" : function (elem, prop) {
- jQuery(elem).hide().addClass("wide" + prop);
- return "show";
- },
- "hide" : function (elem, prop) {
- jQuery(elem).addClass("wide" + prop);
- return "hide";
- },
- "100" : function (elem, prop) {
- jQuery(elem).addClass("wide" + prop);
- return prop == "opacity" ? 1 : 100;
- },
- "50" : function (elem, prop) {
- return prop == "opacity" ? 0.50 : 50;
- },
- "0" : function (elem, prop) {
- jQuery(elem).addClass("noback");
- return 0;
- }
- }, function (tn, t) {
- test(fn + " to " + tn, function () {
- var elem = jQuery.makeTest(fn + " to " + tn);
-
- var t_w = t(elem, "width");
- var f_w = f(elem, "width");
- var t_h = t(elem, "height");
- var f_h = f(elem, "height");
- var t_o = t(elem, "opacity");
- var f_o = f(elem, "opacity");
-
- if (f_o === "") {
- f_o = 1;
- }
+ jQuery(" ")
+ .text( text )
+ .appendTo("#fx-tests")
+ .after( elem );
- var num = 0;
+ return elem;
+ };
- if (t_h == "show") num++;
- if (t_w == "show") num++;
- if (t_w == "hide" || t_w == "show") num++;
- if (t_h == "hide" || t_h == "show") num++;
- if (t_o == "hide" || t_o == "show") num++;
- if (t_w == "hide") num++;
- if (t_o.constructor == Number) num += 2;
- if (t_w.constructor == Number) num += 2;
- if (t_h.constructor == Number) num += 2;
+ $.makeTest.id = 1;
- expect(num);
- stop();
+ test("$.show('fast') doesn't clear radio buttons (bug #1095)", function () {
+ expect(4);
+ stop();
- var anim = { width : t_w, height : t_h, opacity : t_o };
+ var $checkedtest = jQuery("#checkedtest");
+ // IE6 was clearing "checked" in jQuery(elem).show("fast");
+ $checkedtest.hide().show("fast", function() {
+ ok( !! jQuery(":radio:first", $checkedtest).attr("checked"), "Check first radio still checked." );
+ ok( ! jQuery(":radio:last", $checkedtest).attr("checked"), "Check last radio still NOT checked." );
+ ok( !! jQuery(":checkbox:first", $checkedtest).attr("checked"), "Check first checkbox still checked." );
+ ok( ! jQuery(":checkbox:last", $checkedtest).attr("checked"), "Check last checkbox still NOT checked." );
+ start();
+ });
+ });
- elem.animate(anim, 50);
+ $.expandedEach = $.each;
+ $.expandedEach({
+ "slideToggle": function( $elem ) {
+ return parseFloat( $elem.css("height") );
+ },
+ "fadeToggle": function( $elem ) {
+ return $elem.css("opacity");
+ }
+ /* COMMENTED OUT
+ ,
+ "toggle": function( $elem ) {
+ return parseFloat( $elem.css("width") );
+ }
+ */
+ },
+ function( method, defProp ) {
+ test( method + "().stop()." + method + "()", function() {
+ expect( 8 );
- jQuery.when(elem).done(function (elem) {
+ var animTime = 2000;
- elem = elem[ 0 ];
+ $.each([ "in", "out" ], function( i, type ) {
+ var $elem = jQuery( "#" + method.toLowerCase() + type ),
+ startVal = defProp( $elem );
- if (t_w == "show") {
- equal(elem.style.display, "block", "Showing, display should block: " + elem.style.display);
- }
+ $elem[ method ]( animTime );
+ stop();
- if (t_w == "hide" || t_w == "show") {
- ok(f_w === "" ? elem.style.width === f_w : elem.style.width.indexOf(f_w) === 0, "Width must be reset to " + f_w + ": " + elem.style.width);
- }
+ setTimeout( function() {
+ $elem.stop();
- if (t_h == "hide" || t_h == "show") {
- ok(f_h === "" ? elem.style.height === f_h : elem.style.height.indexOf(f_h) === 0, "Height must be reset to " + f_h + ": " + elem.style.height);
- }
+ notEqual( defProp( $elem ), startVal, ".stop() is called about halfway through animation." );
- var cur_o = jQuery.style(elem, "opacity");
+ $elem[ method ](animTime, function() {
+ equal( defProp( $elem ), startVal, "After doing .stop() halfway through hide, check that state has been saved for returning to original property value." );
- if (f_o !== jQuery.css(elem, "opacity")) {
- f_o = f(elem, "opacity");
- }
+ // Start from hidden position to show this time
+ $elem.hide()[ method ]( animTime );
+ setTimeout( function() {
+ $elem.stop();
+
+ notEqual( defProp( $elem ), startVal, ".stop() is called about halfway through animation." );
- // The only time an _empty_string_ will be matched is in IE
- // otherwise, the correct values will be tested as usual
- if (f_o === "") {
- f_o = 1;
- }
- // See above
- if (cur_o === "") {
- cur_o = 1;
- }
+ $elem[ method ](animTime, function() {
+ equal( defProp( $elem ), startVal, "After doing .stop() halfway through show, check that state has been saved for returning to original property value." );
- if (t_o == "hide" || t_o == "show") {
- equal(cur_o, f_o, "Opacity must be reset to " + f_o + ": " + cur_o);
- }
+ // Remove olddisplay data from .hide() call
+ $.removeData( this, "olddisplay", true );
+ start();
+ });
+ }, animTime / 2);
+ });
+ }, animTime / 2);
+ });
+ });
+ });
- if (t_w == "hide") {
- equal(elem.style.display, "none", "Hiding, display should be none: " + elem.style.display);
- }
+ test("animate with per-property easing", function(){
- if (t_o.constructor == Number) {
- equal(cur_o, t_o, "Final opacity should be " + t_o + ": " + cur_o);
+ expect(5);
+ stop();
- ok(jQuery.css(elem, "opacity") != "" || cur_o == t_o, "Opacity should be explicitly set to " + t_o + ", is instead: " + cur_o);
- }
+ var data = { a:0, b:0, c:0 },
+ _test1_called = false,
+ _test2_called = false,
+ _default_test_called = false,
+ props = {
+ a: [ 100, "_test1" ],
+ b: [ 100, "_test2" ],
+ c: 100
+ };
+
+ $.easing["_test1"] = function(p) {
+ _test1_called = true;
+ return p;
+ };
- if (t_w.constructor == Number) {
- equal(elem.style.width, t_w + "px", "Final width should be " + t_w + ": " + elem.style.width);
+ $.easing["_test2"] = function(p) {
+ _test2_called = true;
+ return p;
+ };
- var cur_w = jQuery.css(elem, "width");
+ $.easing["_default_test"] = function(p) {
+ _default_test_called = true;
+ return p;
+ };
- ok(elem.style.width != "" || cur_w == t_w, "Width should be explicitly set to " + t_w + ", is instead: " + cur_w);
- }
+ jQuery(data).animate( props, 400, "_default_test", function(){
+ start();
- if (t_h.constructor == Number) {
- equal(elem.style.height, t_h + "px", "Final height should be " + t_h + ": " + elem.style.height);
+ ok( _test1_called, "Easing function (_test1) called" );
+ ok( _test2_called, "Easing function (_test2) called" );
+ ok( _default_test_called, "Easing function (_default) called" );
+ equal( props.a[ 1 ], "_test1", "animate does not change original props (per-property easing would be lost)");
+ equal( props.b[ 1 ], "_test2", "animate does not change original props (per-property easing would be lost)");
+ });
- var cur_h = jQuery.css(elem, "height");
+ });
- ok(elem.style.height != "" || cur_h == t_h, "Height should be explicitly set to " + t_h + ", is instead: " + cur_w);
- }
+ test("animate with CSS shorthand properties", function(){
+ expect(11);
+ stop();
- if (t_h == "show") {
- var old_h = jQuery.css(elem, "height");
- jQuery(elem).append(" Some more text and some more...");
+ var _def_count = 0,
+ _special_count = 0,
+ propsBasic = { "padding": "10 20 30" },
+ propsSpecial = { "padding": [ "1 2 3", "_special" ] };
- if (/Auto/.test(fn)) {
- notEqual(jQuery.css(elem, "height"), old_h, "Make sure height is auto.");
- } else {
- equal(jQuery.css(elem, "height"), old_h, "Make sure height is not auto.");
- }
- }
+ $.easing._def = function(p) {
+ if ( p >= 1 ) {
+ _def_count++;
+ }
+ return p;
+ };
- // manually remove generated element
- jQuery(elem).remove();
+ $.easing._special = function(p) {
+ if ( p >= 1 ) {
+ _special_count++;
+ }
+ return p;
+ };
+ jQuery("#foo")
+ .animate( propsBasic, 200, "_def", function() {
+ equal( this.style.paddingTop, "10px", "padding-top was animated" );
+ equal( this.style.paddingLeft, "20px", "padding-left was animated" );
+ equal( this.style.paddingRight, "20px", "padding-right was animated" );
+ equal( this.style.paddingBottom, "30px", "padding-bottom was animated" );
+ equal( _def_count, 4, "per-animation default easing called for each property" );
+ _def_count = 0;
+ })
+ .animate( propsSpecial, 200, "_def", function() {
+ equal( this.style.paddingTop, "1px", "padding-top was animated again" );
+ equal( this.style.paddingLeft, "2px", "padding-left was animated again" );
+ equal( this.style.paddingRight, "2px", "padding-right was animated again" );
+ equal( this.style.paddingBottom, "3px", "padding-bottom was animated again" );
+ equal( _def_count, 0, "per-animation default easing not called" );
+ equal( _special_count, 4, "special easing called for each property" );
+
+ jQuery(this).css("padding", "0");
+ delete $.easing._def;
+ delete $.easing._special;
start();
});
- });
});
- });
- jQuery.fn.saveState = function (hiddenOverflow) {
- var check = ["opacity", "height", "width", "display", "overflow"];
- expect(check.length);
+ test("hide hidden elements, with animation (bug #7141)", function() {
+ expect(3);
+ reset();
+ stop();
- stop();
- return this.each(function () {
- var self = this;
- self.save = {};
- jQuery.each(check, function (i, c) {
- self.save[ c ] = c === "overflow" && hiddenOverflow ? "hidden" : self.style[ c ] || jQuery.css(self, c);
+ var div = jQuery("
").appendTo("#qunit-fixture");
+ equal( div.css("display"), "none", "Element is hidden by default" );
+ div.hide(1, function () {
+ ok( !$._data(div, "olddisplay"), "olddisplay is undefined after hiding an already-hidden element" );
+ div.show(1, function () {
+ equal( div.css("display"), "block", "Show a double-hidden element" );
+ start();
+ });
});
});
- };
- jQuery.checkState = function () {
- var self = this;
- jQuery.each(this.save, function (c, v) {
- var cur = self.style[ c ] || jQuery.css(self, c);
- equal(cur, v, "Make sure that " + c + " is reset (Old: " + v + " Cur: " + cur + ")");
+ test("animate unit-less properties (#4966)", 2, function() {
+ stop();
+ var div = jQuery( "
" ).appendTo( "#qunit-fixture" );
+ equal( div.css( "z-index" ), "0", "z-index is 0" );
+ div.animate({ zIndex: 2 }, function() {
+ equal( div.css( "z-index" ), "2", "z-index is 2" );
+ start();
+ });
});
- // manually clean data on modified element
- jQuery.removeData(this, "olddisplay", true);
+ test( "animate properties missing px w/ opacity as last (#9074)", 2, function() {
+ expect( 6 );
+ stop();
+ var div = jQuery( "
" )
+ .appendTo( "#qunit-fixture" );
+ function cssInt( prop ) {
+ return parseInt( div.css( prop ), 10 );
+ }
+ equal( cssInt( "marginLeft" ), 0, "Margin left is 0" );
+ equal( cssInt( "left" ), 0, "Left is 0" );
+ div.animate({
+ left: 200,
+ marginLeft: 200,
+ opacity: 0
+ }, 2000);
+ setTimeout(function() {
+ var ml = cssInt( "marginLeft" ),
+ l = cssInt( "left" );
+ notEqual( ml, 0, "Margin left is not 0 after partial animate" );
+ notEqual( ml, 200, "Margin left is not 200 after partial animate" );
+ notEqual( l, 0, "Left is not 0 after partial animate" );
+ notEqual( l, 200, "Left is not 200 after partial animate" );
+ div.stop().remove();
+ start();
+ }, 1000);
+ });
- start();
- };
+ test("callbacks should fire in correct order (#9100)", function() {
+ stop();
+ var a = 1,
+ cb = 0,
+ $lis = jQuery("
").appendTo("#qunit-fixture")
+ // The test will always pass if no properties are animated or if the duration is 0
+ .animate({fontSize: 12}, 13, function() {
+ a *= jQuery(this).data("operation") === "*2" ? 2 : a;
+ cb++;
+ if ( cb === 2 ) {
+ equal( a, 4, "test value has been *2 and _then_ ^2");
+ start();
+ }
+ });
+ });
+ /* COMMENTED OUT
+ asyncTest( "callbacks that throw exceptions will be removed (#5684)", function() {
+ expect( 2 );
-// Chaining Tests
- test("Chain fadeOut fadeIn", function () {
- jQuery("#fadein div").saveState().fadeOut("fast").fadeIn("fast", jQuery.checkState);
- });
- test("Chain fadeIn fadeOut", function () {
- jQuery("#fadeout div").saveState().fadeIn("fast").fadeOut("fast", jQuery.checkState);
- });
+ var foo = jQuery( "#foo" );
- test("Chain hide show", function () {
- jQuery("#show div").saveState(jQuery.support.shrinkWrapBlocks).hide("fast").show("fast", jQuery.checkState);
- });
- test("Chain show hide", function () {
- jQuery("#hide div").saveState(jQuery.support.shrinkWrapBlocks).show("fast").hide("fast", jQuery.checkState);
- });
- test("Chain show hide with easing and callback", function () {
- jQuery("#hide div").saveState().show("fast").hide("fast", "linear", jQuery.checkState);
- });
+ function testException() {
+ }
- test("Chain toggle in", function () {
- jQuery("#togglein div").saveState(jQuery.support.shrinkWrapBlocks).toggle("fast").toggle("fast", jQuery.checkState);
- });
- test("Chain toggle out", function () {
- jQuery("#toggleout div").saveState(jQuery.support.shrinkWrapBlocks).toggle("fast").toggle("fast", jQuery.checkState);
- });
- test("Chain toggle out with easing and callback", function () {
- jQuery("#toggleout div").saveState(jQuery.support.shrinkWrapBlocks).toggle("fast").toggle("fast", "linear", jQuery.checkState);
- });
- test("Chain slideDown slideUp", function () {
- jQuery("#slidedown div").saveState(jQuery.support.shrinkWrapBlocks).slideDown("fast").slideUp("fast", jQuery.checkState);
- });
- test("Chain slideUp slideDown", function () {
- jQuery("#slideup div").saveState(jQuery.support.shrinkWrapBlocks).slideUp("fast").slideDown("fast", jQuery.checkState);
- });
- test("Chain slideUp slideDown with easing and callback", function () {
- jQuery("#slideup div").saveState(jQuery.support.shrinkWrapBlocks).slideUp("fast").slideDown("fast", "linear", jQuery.checkState);
- });
+ foo.animate({ height: 1 }, 1, function() {
+ throw new testException();
+ });
- test("Chain slideToggle in", function () {
- jQuery("#slidetogglein div").saveState(jQuery.support.shrinkWrapBlocks).slideToggle("fast").slideToggle("fast", jQuery.checkState);
- });
- test("Chain slideToggle out", function () {
- jQuery("#slidetoggleout div").saveState(jQuery.support.shrinkWrapBlocks).slideToggle("fast").slideToggle("fast", jQuery.checkState);
- });
+ // this test thoroughly abuses undocumented methods - please feel free to update
+ // with any changes internally to these functions.
- test("Chain fadeToggle in", function () {
- jQuery("#fadetogglein div").saveState().fadeToggle("fast").fadeToggle("fast", jQuery.checkState);
- });
- test("Chain fadeToggle out", function () {
- jQuery("#fadetoggleout div").saveState().fadeToggle("fast").fadeToggle("fast", jQuery.checkState);
- });
+ // make sure that the standard timer loop will NOT run.
+ $.fx.stop();
- test("Chain fadeTo 0.5 1.0 with easing and callback)", function () {
- jQuery("#fadeto div").saveState().fadeTo("fast", 0.5).fadeTo("fast", 1.0, "linear", jQuery.checkState);
- });
+ setTimeout(function() {
- jQuery.makeTest = function (text) {
- var elem = jQuery("
")
- .attr("id", "test" + jQuery.makeTest.id++)
- .addClass("box");
+ // the first call to fx.tick should raise the callback exception
+ raises( $.fx.tick, testException, "Exception was thrown" );
- jQuery(" ")
- .text(text)
- .appendTo("#fx-tests")
- .after(elem);
+ // the second call shouldn't
+ $.fx.tick();
- return elem;
- };
+ ok( true, "Test completed without throwing a second exception" );
+
+ start();
+ }, 1);
+ });
+ */
+ test("animate will scale margin properties individually", function() {
+ expect( 2 );
+ stop();
- jQuery.makeTest.id = 1;
+ var foo = jQuery( "#foo" ).css({
+ "margin": 0,
+ "marginLeft": 100
+ });
- test("jQuery.show('fast') doesn't clear radio buttons (bug #1095)", function () {
- expect(4);
- stop();
+ ok( foo.css( "marginLeft" ) !== foo.css( "marginRight" ), "Sanity Check" );
- var $checkedtest = jQuery("#checkedtest");
- // IE6 was clearing "checked" in jQuery(elem).show("fast");
- $checkedtest.hide().show("fast", function () {
- ok(!!jQuery(":radio:first", $checkedtest).attr("checked"), "Check first radio still checked.");
- ok(!jQuery(":radio:last", $checkedtest).attr("checked"), "Check last radio still NOT checked.");
- ok(!!jQuery(":checkbox:first", $checkedtest).attr("checked"), "Check first checkbox still checked.");
- ok(!jQuery(":checkbox:last", $checkedtest).attr("checked"), "Check last checkbox still NOT checked.");
+ foo.animate({
+ "margin": 200
+ }).stop();
+
+ ok( foo.css( "marginLeft") !== foo.css( "marginRight" ), "The margin properties are different");
+
+ // clean up for next test
+ foo.css({
+ "marginLeft": '',
+ "marginRight": '',
+ "marginTop": '',
+ "marginBottom": ''
+ });
start();
});
- });
- jQuery.each({
- "slideToggle" : function ($elem) {
- return $elem.height();
- },
- "fadeToggle" : function ($elem) {
- return $elem.css("opacity");
- },
- "toggle" : function ($elem) {
- return $elem.width();
- }
- },
- function (method, defProp) {
- test(method + "().stop()." + method + "()", function () {
- expect(4);
+ test("Do not append px to 'fill-opacity' #9548", 1, function() {
+ var $div = jQuery("").appendTo("#qunit-fixture");
- jQuery.each([ "in", "out" ], function (i, type) {
- var $elem = jQuery("#" + method.toLowerCase() + type),
- startVal = defProp($elem);
+ $div.css("fill-opacity", 0).animate({ "fill-opacity": 1.0 }, 0, function () {
+ equal( jQuery(this).css("fill-opacity"), 1, "Do not append px to 'fill-opacity'");
+ $div.remove();
+ });
+ });
- $elem[ method ]("fast");
- stop();
+// Start 1.8 Animation tests
+ asyncTest( "$.Animation( object, props, opts )", 4, function() {
+ var testObject = {
+ "foo": 0,
+ "bar": 1,
+ "width": 100
+ },
+ testDest = {
+ "foo": 1,
+ "bar": 0,
+ "width": 200
+ };
+
+ var animation = $.Animation( testObject, testDest, { "duration": 1 });
+ animation.done(function() {
+ for ( var prop in testDest ) {
+ equal( testObject[ prop ], testDest[ prop ], "Animated: " + prop );
+ }
+ animation.done(function() {
+ deepEqual( testObject, testDest, "No unexpected properties" );
+ start();
+ });
+ });
+ });
- setTimeout(function () {
- $elem.stop();
+ asyncTest( "Animate Option: step: function( percent, tween )", 1, function() {
+ var counter = {};
+ jQuery( "#foo" ).animate({
+ prop1: 1,
+ prop2: 2,
+ prop3: 3
+ }, {
+ duration: 1,
+ step: function( value, tween ) {
+ var calls = counter[ tween.prop ] = counter[ tween.prop ] || [];
+ // in case this is called multiple times for either, lets store it in
+ // 0 or 1 in the array
+ calls[ value === 0 ? 0 : 1 ] = value;
+ }
+ }).queue( function( next ) {
+ deepEqual( counter, {
+ prop1: [0, 1],
+ prop2: [0, 2],
+ prop3: [0, 3]
+ }, "Step function was called once at 0% and once at 100% for each property");
+ next();
+ start();
+ });
+ });
- notEqual(defProp($elem), startVal, ".stop() is called about halfway through animation.");
+ asyncTest( "Animate callbacks have correct context", 2, function() {
+ var foo = jQuery( "#foo" );
+ foo.animate({
+ height: 10
+ }, 10, function() {
+ equal( foo[ 0 ], this, "Complete callback after stop(true) `this` is element" );
+ }).stop( true, true );
+ foo.animate({
+ height: 100
+ }, 10, function() {
+ equal( foo[ 0 ], this, "Complete callback `this` is element" );
+ start();
+ });
+ });
- $elem[ method ]("fast", function () {
- equal(defProp(jQuery(this)), startVal, "After doing .stop() halfway, check that state has been saved for returning to original property value.");
- start();
- });
- }, 100);
+ asyncTest( "User supplied callback called after show when fx off (#8892)", 2, function() {
+ var foo = jQuery( "#foo" );
+ $.fx.off = true;
+ foo.hide();
+ foo.fadeIn( 500, function() {
+ ok( jQuery( this ).is( ":visible" ), "Element is visible in callback" );
+ foo.fadeOut( 500, function() {
+ ok( jQuery( this ).is( ":hidden" ), "Element is hidden in callback" );
+ $.fx.off = false;
+ start();
});
});
});
- test("animate with per-property easing", function () {
+ test( "animate should set display for disconnected nodes", function() {
+ expect( 18 );
- expect(5);
- stop();
+ var i = 0,
+ methods = {
+ toggle: [ 1 ],
+ slideToggle: [],
+ fadeIn: [],
+ fadeTo: [ "fast", 0.5 ],
+ slideDown: [ "fast" ],
+ show: [ 1 ],
+ animate: [{ width: "show" }]
+ },
+ elems = [
- var data = { a : 0, b : 0, c : 0 },
- _test1_called = false,
- _test2_called = false,
- _default_test_called = false,
- props = {
- a : [ 100, "_test1" ],
- b : [ 100, "_test2" ],
- c : 100
- };
+ // parentNode = document fragment
+ jQuery("
test
"),
- jQuery.easing["_test1"] = function (p) {
- _test1_called = true;
- return p;
- };
+ // parentNode = null
+ jQuery("
"),
- jQuery.easing["_test2"] = function (p) {
- _test2_called = true;
- return p;
- };
+ jQuery('
'),
- jQuery.easing["_default_test"] = function (p) {
- _default_test_called = true;
- return p;
- };
+ jQuery('
')
+ ];
- jQuery(data).animate(props, 400, "_default_test", function () {
- start();
+ strictEqual( elems[ 0 ].show()[ 0 ].style.display, "block", "set display with show() for element with parentNode = document fragment" );
+ strictEqual( elems[ 1 ].show()[ 0 ].style.display, "block", "set display with show() for element with parentNode = null" );
+ strictEqual( elems[ 2 ].show()[ 0 ].style.display, "inline", "show() should not change display if it already set" );
+ strictEqual( elems[ 3 ].show()[ 0 ].style.display, "block", "show() should change display if it already set to none" );
- ok(_test1_called, "Easing function (_test1) called");
- ok(_test2_called, "Easing function (_test2) called");
- ok(_default_test_called, "Easing function (_default) called");
- equal(props.a[ 1 ], "_test1", "animate does not change original props (per-property easing would be lost)");
- equal(props.b[ 1 ], "_test2", "animate does not change original props (per-property easing would be lost)");
- });
+ // cleanup
+ $.each( elems, function() {
+ $.removeData( this[ 0 ], "olddisplay", true );
+ });
- });
+ stop();
+ $.each( methods, function( name, opt ) {
+ $.each([
- test("hide hidden elements (bug #7141)", function () {
- expect(3);
- QUnit.reset();
+ // parentNode = document fragment
+ jQuery("
test
"),
- var div = jQuery("
").appendTo("#qunit-fixture");
- equal(div.css("display"), "none", "Element is hidden by default");
- div.hide();
- ok(!jQuery._data(div, "olddisplay"), "olddisplay is undefined after hiding an already-hidden element");
- div.show();
- equal(div.css("display"), "block", "Show a double-hidden element");
+ // parentNode = null
+ jQuery("
")
- div.remove();
- });
+ ], function() {
+ var callback = [function () {
+ strictEqual( this.style.display, "block", "set display to block with " + name );
+
+ $.removeData( this, "olddisplay", true );
- test("hide hidden elements, with animation (bug #7141)", function () {
- expect(3);
- QUnit.reset();
- stop();
-
- var div = jQuery("
").appendTo("#qunit-fixture");
- equal(div.css("display"), "none", "Element is hidden by default");
- div.hide(1, function () {
- ok(!jQuery._data(div, "olddisplay"), "olddisplay is undefined after hiding an already-hidden element");
- div.show(1, function () {
- equal(div.css("display"), "block", "Show a double-hidden element");
+ if ( ++i === 14 ) {
+ start();
+ }
+ }];
+ $.fn[ name ].apply( this, opt.concat( callback ) );
+ });
+ });
+ });
+
+ asyncTest("Animation callback should not show animated element as animated (#7157)", 1, function() {
+ var foo = jQuery( "#foo" );
+
+ foo.animate({
+ opacity: 0
+ }, 100, function() {
+ ok( !foo.is(':animated'), "The element is not animated" );
start();
});
});
- });
- test("animate unit-less properties (#4966)", 2, function () {
- stop();
- var div = jQuery("
").appendTo("#qunit-fixture");
- equal(div.css("z-index"), "0", "z-index is 0");
- div.animate({ zIndex : 2 }, function () {
- equal(div.css("z-index"), "2", "z-index is 2");
- start();
+ asyncTest( "hide called on element within hidden parent should set display to none (#10045)", 3, function() {
+ var hidden = jQuery(".hidden"),
+ elems = jQuery("
hide
hide0
hide1
");
+
+ hidden.append( elems );
+
+ $.when(
+ elems.eq( 0 ).hide(),
+ elems.eq( 1 ).hide( 0 ),
+ elems.eq( 2 ).hide( 1 )
+ ).done(function() {
+ strictEqual( elems.get( 0 ).style.display, "none", "hide() called on element within hidden parent should set display to none" );
+ strictEqual( elems.get( 1 ).style.display, "none", "hide( 0 ) called on element within hidden parent should set display to none" );
+ strictEqual( elems.get( 2 ).style.display, "none", "hide( 1 ) called on element within hidden parent should set display to none" );
+
+ elems.remove();
+ start();
+ });
});
- });
- test("callbacks should fire in correct order (#9100)", function () {
- stop();
- var a = 1,
- cb = 0,
- $lis = jQuery("
").appendTo("#qunit-fixture")
- // The test will always pass if no properties are animated or if the duration is 0
- .animate({fontSize : 12}, 13, function () {
- a *= jQuery(this).data("operation") === "*2" ? 2 : a;
- cb++;
- if (cb === 2) {
- equal(a, 4, "test value has been *2 and _then_ ^2");
- start();
+ asyncTest( "hide, fadeOut and slideUp called on element width height and width = 0 should set display to none", 5, function() {
+ var foo = jQuery("#foo"),
+ i = 0,
+ elems = jQuery();
+
+ for ( ; i < 5; i++ ) {
+ elems = elems.add('
');
+ }
+
+ foo.append( elems );
+
+ $.when(
+ elems.eq( 0 ).hide(),
+ elems.eq( 1 ).hide( $.noop ),
+ elems.eq( 2 ).hide( 1 ),
+ elems.eq( 3 ).fadeOut(),
+ elems.eq( 4 ).slideUp()
+ ).done(function() {
+ strictEqual( elems.get( 0 ).style.display, "none", "hide() called on element width height and width = 0 should set display to none" );
+ strictEqual( elems.get( 1 ).style.display, "none",
+ "hide( $.noop ) called on element width height and width = 0 should set display to none" );
+ strictEqual( elems.get( 2 ).style.display, "none", "hide( 1 ) called on element width height and width = 0 should set display to none" );
+ strictEqual( elems.get( 3 ).style.display, "none", "fadeOut() called on element width height and width = 0 should set display to none" );
+ strictEqual( elems.get( 4 ).style.display, "none", "slideUp() called on element width height and width = 0 should set display to none" );
+
+ start();
+ });
+ });
+
+ asyncTest( "Handle queue:false promises", 10, function() {
+ var foo = jQuery( "#foo" ).clone().andSelf(),
+ step = 1;
+
+ foo.animate({
+ top: 1
+ }, {
+ duration: 10,
+ queue: false,
+ complete: function() {
+ ok( step++ <= 2, "Step one or two" );
+ }
+ }).animate({
+ bottom: 1
+ }, {
+ duration: 10,
+ complete: function() {
+ ok( step > 2 && step < 5, "Step three or four" );
+ step++;
}
});
- });
- test("jQuery.stop() on CSS animation", 2, function () {
- stop();
- var div = jQuery("
").appendTo("#qunit-fixture");
- div.animate({ height : 100, width: 150 }, 200);
- setTimeout(function() {
- // Clear the queue and stop
- div.stop();
- ok(div.height() < 100 * 0.95, 'Animation stopped at ' + div.height() + ' before it reached full height of 100');
- ok(div.width() < 150 * 0.95, 'Animation stopped at ' + div.width() + ' before it reached full width of 150');
- start();
- }, 50);
- });
+ foo.promise().done( function() {
+ equal( step++, 5, "steps 1-5: queue:false then queue:fx done" );
+ foo.animate({
+ top: 10
+ }, {
+ duration: 10,
+ complete: function() {
+ ok( step > 5 && step < 8, "Step six or seven" );
+ step++;
+ }
+ }).animate({
+ bottom: 10
+ }, {
+ duration: 10,
+ queue: false,
+ complete: function() {
+ ok( step > 7 && step < 10, "Step eight or nine" );
+ step++;
+ }
+ }).promise().done( function() {
+ equal( step++, 10, "steps 6-10: queue:fx then queue:false" );
+ start();
+ });
- /* As mentioned, thoroughly abuses undocumented methods. Since the overwritten animate doesn't
- * use timers this doesn't need to be tested
- asyncTest("callbacks that throw exceptions will be removed (#5684)", function () {
- expect(2);
+ });
+ });
- var foo = jQuery("#foo").fadeIn()
+ asyncTest( "multiple unqueued and promise", 4, function() {
+ var foo = jQuery( "#foo" ),
+ step = 1;
+ foo.animate({
+ marginLeft: 300
+ }, {
+ duration: 500,
+ queue: false,
+ complete: function() {
+ strictEqual( step++, 2, "Step 2" );
+ }
+ }).animate({
+ top: 100
+ }, {
+ duration: 1500,
+ queue: false,
+ complete: function() {
+ strictEqual( step++, 3, "Step 3" );
+ }
+ }).animate({}, {
+ duration: 2000,
+ queue: false,
+ complete: function() {
+ // no properties is a non-op and finishes immediately
+ strictEqual( step++, 1, "Step 1" );
+ }
+ }).promise().done( function() {
+ strictEqual( step++, 4, "Step 4" );
+ start();
+ });
+ });
- function testException() {
- }
+ asyncTest( "animate does not change start value for non-px animation (#7109)", 1, function() {
+ var parent = jQuery( "
" ).css({ width: 284, height: 1 }).appendTo( "#qunit-fixture" ),
+ child = parent.children().css({ fontSize: "98.6in", width: "0.01em", height: 1 }),
+ actual = parseFloat( child.css( "width" ) ),
+ computed = [];
- foo.animate({ height : 1 }, 1, function () {
- throw new testException;
+ child.animate({ width: "0%" }, {
+ duration: 1,
+ step: function() {
+ computed.push( parseFloat( child.css( "width" ) ) );
+ }
+ }).queue( function( next ) {
+ var ratio = computed[ 0 ] / actual;
+ ok( ratio > 0.9 && ratio < 1.1 , "Starting width was close enough" );
+ next();
+ parent.remove();
+ start();
+ });
});
- // this test thoroughly abuses undocumented methods - please feel free to update
- // with any changes internally to these functions.
+ // This test and functionality has issues stemming deep into jQuery itself, and
+ // should be brought up to them. It doesn't preserve the numeric start, but it does
+ // animate normall.
+ /*asyncTest( "non-px animation handles non-numeric start (#11971)", 2, function() {
+ var foo = jQuery("#foo"),
+ initial = foo.css("backgroundPositionX");
+
+ if ( initial == null ) {
+ expect(1);
+ ok( true, "Style property not understood" );
+ start();
+ return;
+ }
+
+ foo.animate({ backgroundPositionX: "42%" }, {
+ duration: 1,
+ progress: function( anim, percent ) {
+ if ( percent ) {
+ return;
+ }
+
+ if ( parseFloat( initial ) ) {
+ equal( $.style( this, "backgroundPositionX" ), initial, "Numeric start preserved" );
+ } else {
+ equal( $.style( this, "backgroundPositionX" ), "0%", "Non-numeric start zeroed" );
+ }
+ },
+ done: function() {
+ equal( $.style( this, "backgroundPositionX" ), "42%", "End reached" );
+ start();
+ }
+ });
+ });*/
+
+ asyncTest("Animation callbacks (#11797)", 16, function() {
+ var targets = jQuery("#foo").children(),
+ done = false,
+ expectedProgress = 0;
+
+ targets.eq( 0 ).animate( {}, {
+ duration: 1,
+ start: function() {
+ ok( true, "empty: start" );
+ },
+ progress: function( anim, percent ) {
+ equal( percent, expectedProgress, "empty: progress " + expectedProgress );
+ expectedProgress++;
+ },
+ done: function() {
+ ok( true, "empty: done" );
+ },
+ fail: function() {
+ ok( false, "empty: fail" );
+ },
+ always: function() {
+ ok( true, "empty: always" );
+ done = true;
+ }
+ });
- // make sure that the standard timer loop will NOT run.
- jQuery.fx.stop();
+ ok( done, "empty: done immediately" );
+
+ done = false;
+ targets.eq( 1 ).animate({
+ opacity: 0
+ }, {
+ duration: 1,
+ start: function() {
+ ok( true, "stopped: start" );
+ },
+ progress: function( anim, percent ) {
+ equal( percent, 0, "stopped: progress 0" );
+ },
+ done: function() {
+ ok( false, "stopped: done" );
+ },
+ fail: function() {
+ ok( true, "stopped: fail" );
+ },
+ always: function() {
+ ok( true, "stopped: always" );
+ done = true;
+ }
+ }).stop();
+
+ ok( done, "stopped: stopped immediately" );
+
+ expectedProgress = 0;
+ targets.eq( 2 ).animate({
+ opacity: 0
+ }, {
+ duration: 1,
+ start: function() {
+ ok( true, "async: start" );
+ },
+ progress: function( anim, percent ) {
+ // occasionally the progress handler is called twice in first frame.... *shrug*
+ if ( percent === 0 && expectedProgress === 1 ) {
+ return;
+ }
+ equal( percent, expectedProgress, "async: progress " + expectedProgress );
+ // once at 0, once at 1
+ expectedProgress++;
+ },
+ done: function() {
+ ok( true, "async: done" );
+ },
+ fail: function() {
+ ok( false, "async: fail" );
+ },
+ always: function() {
+ ok( true, "async: always" );
+ start();
+ }
+ });
+ });
- setTimeout(function () {
+ test( "Animate properly sets overflow hidden when animating width/height (#12117)", 4, function() {
+ $.each( [ "height", "width" ], function( _, prop ) {
+ $.each( [ 100, 0 ], function( _, value ) {
+ var div = jQuery("
"),
+ props = {};
+ props[ prop ] = value;
+
+ div.animate( props, 1 );
+ equal( div.css( "overflow" ), "hidden",
+ "overflow: hidden set when animating " + prop + " to " + value );
+ div.stop();
+ });
+ });
+ });
- // the first call to fx.tick should raise the callback exception
- raises(jQuery.fx.tick, testException, "Exception was thrown");
+ test( "Animations with 0 duration don't ease (#12273)", 1, function() {
+ $.easing.test = function() {
+ ok( false, "Called easing" );
+ };
- // the second call shouldn't
- jQuery.fx.tick();
+ jQuery( "#foo" ).animate({
+ height: 100
+ }, {
+ duration: 0,
+ easing: "test",
+ complete: function() {
+ equal( jQuery( this ).height(), 100, "Height is 100" );
+ }
+ });
- ok(true, "Test completed without throwing a second exception");
+ delete $.easing.test;
+ });
- start();
- }, 1);
- });
- */
+ } // if ( $.fx )
});
\ No newline at end of file
diff --git a/dom/animate/iframe.html b/dom/animate/iframe.html
new file mode 100644
index 00000000..46edda98
--- /dev/null
+++ b/dom/animate/iframe.html
@@ -0,0 +1,8 @@
+
+
+
iframe
+
+
+
span text
+
+
\ No newline at end of file
diff --git a/dom/animate/qunit.html b/dom/animate/qunit.html
index d81d3ee0..94656b21 100644
--- a/dom/animate/qunit.html
+++ b/dom/animate/qunit.html
@@ -1,11 +1,11 @@
Animate Test Suite
-
-
+
+
-
+
@@ -15,227 +15,15 @@
+
+
-