diff options
64 files changed, 1148 insertions, 705 deletions
diff --git a/.csslintrc b/.csslintrc new file mode 100644 index 000000000..5d9db072c --- /dev/null +++ b/.csslintrc @@ -0,0 +1,11 @@ +{ + "adjoining-classes": false, + "box-model": false, + "compatible-vendor-prefixes": false, + "duplicate-background-images": false, + "import": false, + "important": false, + "outline-none": false, + "overqualified-elements": false, + "text-indent": false +} @@ -1,6 +1,90 @@ +Aaron Peterson <aaronp123@yahoo.com> +Adam Baratz <adam@adambaratz.com> <adam.baratz@gmail.com> +Adam Sontag <ajpiano@ajpiano.com> +Alexander Polomoshnov <alex.polomoshnov@gmail.com> +Aliaksandr Rahalevich <saksmlz@gmail.com> +Andrew Couch <andy@couchand.com> <acouch@bluewolf.com> +Andrew Newcomb <ext.github@preceptsoftware.co.uk> +Andrew Powell <powella@gmail.com> <andrew@shellscape.org> +Andrey Kapitcyn <ru.m157y@gmail.com> +Ben Hollis <bhollis@amazon.com> <ben@benhollis.net> +Benjamin Scott Boyle <benjamins.boyle@gmail.com> +Bert ter Heide <bertjh@hotmail.com> +Chairat Sunthornwiphat <pipo@sixhead.com> +Corey Frang <gnarf@gnarf.net> +Courtland Allen <courtlandallen@gmail.com> +Dan Streetman <ddstreet@ieee.org> +Diego Tres <diegotres@gmail.com> +Dominique Vincent <dominique.vincent@toitl.com> +Doug Blood <dougblood@gmail.com> +Douglas Cerna <douglascerna@yahoo.com> <replaceafill@system76.(none)> +Douglas Neiner <doug@pixelgraphics.us> +Douglas Neiner <doug@pixelgraphics.us> <doug@Doug-Neiners-MacBook-Pro.local> +Dylan Just <dev@ephox.com> +Eddie Monge <eddie@eddiemonge.com> +Edward A Faulkner <ef@alum.mit.edu> +Eric Hynds <eric@hynds.net> +Ethan Romba <ethanromba@gmail.com> <ethan.romba@parivedasolutions.com> +EungJun Yi <semtlenori@gmail.com> +Eyal Kobrigo <kobrigo@hotmail.com> +Filippo Cavallarin <filippo.cavallarin@codseq.it> <poplix@papuasia.org> +Florian Gutmann <f.gutmann@chronimo.com> <blackfeet@gmx.at> +Genie <386@mail.com> +Guntupalli Karunakar <karunakarg@yahoo.com> +Hiroshi Tomita <tomykaira@gmail.com> +Ian Simpson <spoonlikesham@gmail.com> +Igor Milla <igor.fsp.milla@gmail.com> +Israel Tsadok <itsadok@gmail.com> +Jacek Jędrzejewski <jacek.jedrzejewski@gmail.com> +Jamie Gegerson <git@jamiegegerson.com> +Jay Merrifield <fracmak@gmail.com> <merrifieldj@pixia.com> +John Enters <github@darkdark.net> +Jonathan Vingiano <jvingiano@gmail.com> +Josh Varner <josh.varner@gmail.com> +Justin Domnitz <jdomnitz@gmail.com> +Justin MacCarthy <Justin@Rubystars.biz> +Jörn Zaefferer <joern.zaefferer@gmail.com> +Karl Kirch <karlkrch@gmail.com> <karl.ctr.kirch@faa.gov> +Kevin Dalman <development@allpro.net> +Klaus Hartl <klaus.hartl@googlemail.com> carhartl <klaus.hartl@stilbuero.de> Kris Borchers <kris.borchers@gmail.com> Kris Borchers <kris.borchers@gmail.com> <k_borchers@yahoo.com> -Corey Frang <gnarf@gnarf.net> +Krzysztof Rosiński <rozwell69@gmail.com> +Lev Kitsis <spam4lev@gmail.com> Maggie Costello Wachs <fg.maggie@gmail.com> maggiewachs <maggie@filamentgroup.com> +Marc Neuwirth <marc.neuwirth@gmail.com> +Marcos Sousa <falecomigo@marcossousa.com> <marcos.sousa@corp.globo.com> +Martin Frost <martinf55@hotmail.com> +Mathias Stenbom <mathias@stenbom.com> +Matthew Edward Hutton <meh@corefiling.co.uk> +Max Schnur <max.schnur@gmail.com> +Michael Hollis <hollis21@gmail.com> +Michael Stay <metaweta@gmail.com> +Michael Wu <michaelmwu@gmail.com> +Mike Alsup <malsup@gmail.com> +Milan Broum <midlis@googlemail.com> +Mohamed Cherif Bouchelaghem <cherifbouchelaghem@yahoo.fr> <cherif@cherif.(none)> +Paul Irish <paul.irish@gmail.com> +Pavol Hluchý <lopo@losys.sk> +Peter Heiberg <peter@heiberg.se> +Petr Hromadko <yuriy@tokyoscale.com> +Phillip Barnes <philbar@gmail.com> <phillipbarnes@Phillip-Barnes-Computer.local> +Pierre-Henri Ausseil <ph.ausseil@gmail.com> +Raymond Schwartz <skeetergraphics@gmail.com> Richard Worth <rdworth@gmail.com> -Jörn Zaefferer <joern.zaefferer@gmail.com> +Rick Waldron <waldron.rick@gmail.com> +Ryan Neufeld <ryan@neufeldmail.com> +Ryan Olton <oltonr@gmail.com> +Saji Nediyanchath <saji89@gmail.com> Saji <saji@saji-laptop.(none)> +Sebastian Sauer <info@dynpages.de> +Sergey Kartashov <ebishkek@yandex.ru> +Shahyar Ghobadpour <shahyar@gmail.com> +Shane Whittet <whittet@gmail.com> +Shannon Pekary <spekary@gmail.com> +Simon Sattes <simon.sattes@gmail.com> +Stojce Slavkovski <stojce@gmail.com> +Tarafder Ashek-E-Elahi <mail.ashek@gmail.com> +Thibault Duplessis <thibault.duplessis@gmail.com> +Ting Kuei <ting@kuei.com> +Wesley Walser <waw325@gmail.com> <wwalser@atlassian.com> +Xavi Ramirez <xavi.rmz@gmail.com> diff --git a/AUTHORS.txt b/AUTHORS.txt index 2a7a396c8..756e9daa5 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -168,7 +168,7 @@ Genie <386@mail.com> Rick Waldron <waldron.rick@gmail.com> Ian Simpson <spoonlikesham@gmail.com> Lev Kitsis <spam4lev@gmail.com> -Ted VanToll <tj.vantoll@gmail.com> +TJ VanToll <tj.vantoll@gmail.com> Justin Domnitz <jdomnitz@gmail.com> Douglas Cerna <douglascerna@yahoo.com> Bert ter Heide <bertjh@hotmail.com> @@ -216,8 +216,8 @@ Marc-Andre Lafortune <github@marc-andre.ca> Nate Eagle <nate.eagle@teamaol.com> David Souther <davidsouther@gmail.com> Mathias Stenbom <mathias@stenbom.com> -Avinash R <nashpapa@gmail.com> Sergey Kartashov <ebishkek@yandex.ru> +Avinash R <nashpapa@gmail.com> Ethan Romba <ethanromba@gmail.com> Cory Gackenheimer <cory.gack@gmail.com> Juan Pablo Kaniefsky <jpkaniefsky@gmail.com> @@ -236,3 +236,7 @@ Thomas Jaggi <thomas.jaggi@gmail.com> Vahid Sohrabloo <vahid4134@gmail.com> Travis Carden <travis.carden@gmail.com> Bruno M. Custódio <bruno@brunomcustodio.com> +Nathanael Silverman <nathanael.silverman@gmail.com> +Christian Wenz <christian@wenz.org> +Steve Urmston <steve@urm.st> +Zaven Muradyan <megalivoithos@gmail.com> diff --git a/grunt.js b/Gruntfile.js index 1281bdbd2..f00343d58 100644 --- a/grunt.js +++ b/Gruntfile.js @@ -18,11 +18,11 @@ var uiFiles = coreFiles.map(function( file ) { return "ui/" + file; - }).concat( grunt.file.expandFiles( "ui/*.js" ).filter(function( file ) { + }).concat( expandFiles( "ui/*.js" ).filter(function( file ) { return coreFiles.indexOf( file.substring(3) ) === -1; })), - allI18nFiles = grunt.file.expandFiles( "ui/i18n/*.js" ), + allI18nFiles = expandFiles( "ui/i18n/*.js" ), cssFiles = [ "core", @@ -47,12 +47,38 @@ var // minified files minify = { - "dist/jquery-ui.min.js": [ "<banner:meta.bannerAll>", "dist/jquery-ui.js" ], - "dist/i18n/jquery-ui-i18n.min.js": [ "<banner:meta.bannerI18n>", "dist/i18n/jquery-ui-i18n.js" ] + options: { + preserveComments: false + }, + main: { + options: { + banner: createBanner( uiFiles ) + }, + files: { + "dist/jquery-ui.min.js": "dist/jquery-ui.js" + } + }, + i18n: { + options: { + banner: createBanner( allI18nFiles ) + }, + files: { + "dist/i18n/jquery-ui-i18n.min.js": "dist/i18n/jquery-ui-i18n.js" + } + } }, minifyCSS = { - "dist/jquery-ui.min.css": "dist/jquery-ui.css" + options: { + keepSpecialComments: 0 + }, + main: { + options: { + keepSpecialComments: '*' + }, + src: "dist/jquery-ui.css", + dest: "dist/jquery-ui.min.css" + } }, compareFiles = { @@ -66,90 +92,108 @@ function mapMinFile( file ) { return "dist/" + file.replace( /\.js$/, ".min.js" ).replace( /ui\//, "minified/" ); } +function expandFiles( files ) { + return grunt.util._.pluck( grunt.file.expandMapping( files ), "src" ).map(function( values ) { + return values[ 0 ]; + }); +} + uiFiles.concat( allI18nFiles ).forEach(function( file ) { - minify[ mapMinFile( file ) ] = [ "<banner>", file ]; + minify[ file ] = { + options: { + banner: createBanner() + }, + files: {} + }; + minify[ file ].files[ mapMinFile( file ) ] = file; }); cssFiles.forEach(function( file ) { - minifyCSS[ "dist/" + file.replace( /\.css$/, ".min.css" ).replace( /themes\/base\//, "themes/base/minified/" ) ] = [ "<banner>", "<strip_all_banners:" + file + ">" ]; + minifyCSS[ file ] = { + options: { + banner: createBanner() + }, + src: file, + dest: "dist/" + file.replace( /\.css$/, ".min.css" ).replace( /themes\/base\//, "themes/base/minified/" ) + }; }); uiFiles.forEach(function( file ) { + // TODO this doesn't do anything until https://github.com/rwldrn/grunt-compare-size/issues/13 compareFiles[ file ] = [ file, mapMinFile( file ) ]; }); // grunt plugins -grunt.loadNpmTasks( "grunt-css" ); +grunt.loadNpmTasks( "grunt-contrib-jshint" ); +grunt.loadNpmTasks( "grunt-contrib-uglify" ); +grunt.loadNpmTasks( "grunt-contrib-concat" ); +grunt.loadNpmTasks( "grunt-contrib-qunit" ); +grunt.loadNpmTasks( "grunt-contrib-csslint" ); +grunt.loadNpmTasks( "grunt-contrib-cssmin" ); grunt.loadNpmTasks( "grunt-html" ); grunt.loadNpmTasks( "grunt-compare-size" ); -grunt.loadNpmTasks( "grunt-junit" ); grunt.loadNpmTasks( "grunt-git-authors" ); // local testswarm and build tasks grunt.loadTasks( "build/tasks" ); -grunt.registerHelper( "strip_all_banners", function( filepath ) { - return grunt.file.read( filepath ).replace( /^\s*\/\*[\s\S]*?\*\/\s*/g, "" ); -}); - -function stripBanner( files ) { - return files.map(function( file ) { - return "<strip_all_banners:" + file + ">"; - }); -} - function stripDirectory( file ) { - // TODO: we're receiving the directive, so we need to strip the trailing > - // we should be receving a clean path without the directive return file.replace( /.+\/(.+?)>?$/, "$1" ); } -// allow access from banner template -global.stripDirectory = stripDirectory; function createBanner( files ) { // strip folders var fileNames = files && files.map( stripDirectory ); return "/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - " + "<%= grunt.template.today('isoDate') %>\n" + - "<%= pkg.homepage ? '* ' + pkg.homepage + '\n' : '' %>" + - "* Includes: " + (files ? fileNames.join(", ") : "<%= stripDirectory(grunt.task.current.file.src[1]) %>") + "\n" + + "<%= pkg.homepage ? '* ' + pkg.homepage + '\\n' : '' %>" + + (files ? "* Includes: " + fileNames.join(", ") + "\n" : "")+ "* Copyright <%= grunt.template.today('yyyy') %> <%= pkg.author.name %>;" + - " Licensed <%= _.pluck(pkg.licenses, 'type').join(', ') %> */"; + " Licensed <%= _.pluck(pkg.licenses, 'type').join(', ') %> */\n"; } grunt.initConfig({ - pkg: "<json:package.json>", + pkg: grunt.file.readJSON("package.json"), files: { dist: "<%= pkg.name %>-<%= pkg.version %>", cdn: "<%= pkg.name %>-<%= pkg.version %>-cdn", themes: "<%= pkg.name %>-themes-<%= pkg.version %>" }, - meta: { - banner: createBanner(), - bannerAll: createBanner( uiFiles ), - bannerI18n: createBanner( allI18nFiles ), - bannerCSS: createBanner( cssFiles ) - }, compare_size: compareFiles, concat: { ui: { - src: [ "<banner:meta.bannerAll>", stripBanner( uiFiles ) ], + options: { + banner: createBanner( uiFiles ), + stripBanners: { + block: true + } + }, + src: uiFiles, dest: "dist/jquery-ui.js" }, i18n: { - src: [ "<banner:meta.bannerI18n>", allI18nFiles ], + options: { + banner: createBanner( allI18nFiles ) + }, + src: allI18nFiles, dest: "dist/i18n/jquery-ui-i18n.js" }, css: { - src: [ "<banner:meta.bannerCSS>", stripBanner( cssFiles ) ], + options: { + banner: createBanner( cssFiles ), + stripBanners: { + block: true + } + }, + src: cssFiles, dest: "dist/jquery-ui.css" } }, - min: minify, + uglify: minify, cssmin: minifyCSS, htmllint: { // ignore files that contain invalid html, used only for ajax content testing all: grunt.file.expand( [ "demos/**/*.html", "tests/**/*.html" ] ).filter(function( file ) { - return !/(?:ajax\/content\d\.html|tabs\/data\/test\.html|tests\/unit\/core\/core\.html)/.test( file ); + return !/(?:ajax\/content\d\.html|tabs\/data\/test\.html|tests\/unit\/core\/core.*\.html)/.test( file ); }) }, copy: { @@ -159,7 +203,7 @@ grunt.initConfig({ "jquery-*.js", "MIT-LICENSE.txt", "README.md", - "grunt.js", + "Gruntfile.js", "package.json", "*.jquery.json", "ui/**/*", @@ -210,9 +254,7 @@ grunt.initConfig({ "dist/jquery-ui.js": "jquery-ui.js", "dist/jquery-ui.min.js": "jquery-ui.min.js", "dist/i18n/jquery-ui-i18n.js": "i18n/jquery-ui-i18n.js", - "dist/i18n/jquery-ui-i18n.min.js": "i18n/jquery-ui-i18n.min.js", - "dist/jquery-ui.css": "themes/base/jquery-ui.css", - "dist/jquery-ui.min.css": "themes/base/minified/jquery-ui.min.css" + "dist/i18n/jquery-ui-i18n.min.js": "i18n/jquery-ui-i18n.min.js" }, dest: "dist/<%= files.cdn %>" }, @@ -231,11 +273,6 @@ grunt.initConfig({ strip: /^dist\/minified/, dest: "dist/<%= files.cdn %>/ui" }, - cdn_min_images: { - src: "themes/base/images/*", - strip: /^themes\/base\//, - dest: "dist/<%= files.cdn %>/themes/base/minified" - }, cdn_themes: { src: "dist/<%= files.themes %>/themes/**/*", strip: "dist/<%= files.themes %>", @@ -279,68 +316,56 @@ grunt.initConfig({ } }, qunit: { - files: grunt.file.expandFiles( "tests/unit/**/*.html" ).filter(function( file ) { + files: expandFiles( "tests/unit/**/*.html" ).filter(function( file ) { // disabling everything that doesn't (quite) work with PhantomJS for now // TODO except for all|index|test, try to include more as we go - return !( /(all|index|test|dialog|dialog_deprecated|tabs|tooltip)\.html$/ ).test( file ); + return !( /(all|index|test|dialog|tabs|tooltip)\.html$/ ).test( file ); }) }, - lint: { - ui: "ui/*.js", - grunt: [ "grunt.js", "build/**/*.js" ], - tests: "tests/unit/**/*.js" + jshint: { + ui: { + options: { + jshintrc: "ui/.jshintrc" + }, + files: { + src: "ui/*.js" + } + }, + grunt: { + options: { + jshintrc: ".jshintrc" + }, + files: { + src: [ "Gruntfile.js", "build/**/*.js" ] + } + }, + tests: { + options: { + jshintrc: "tests/.jshintrc" + }, + files: { + src: "tests/unit/**/*.js" + } + } }, csslint: { - // nothing: [] - // TODO figure out what to check for, then fix and enable base_theme: { - src: grunt.file.expandFiles( "themes/base/*.css" ).filter(function( file ) { - // TODO remove items from this list once rewritten - return !( /(button|datepicker|core|dialog|theme)\.css$/ ).test( file ); - }), - // TODO consider reenabling some of these rules - rules: { - "adjoining-classes": false, - "import": false, - "outline-none": false, - // especially this one - "overqualified-elements": false, - "compatible-vendor-prefixes": false + src: "themes/base/*.css", + options: { + csslintrc: ".csslintrc" } } - }, - jshint: (function() { - function parserc( path ) { - var rc = grunt.file.readJSON( (path || "") + ".jshintrc" ), - settings = { - options: rc, - globals: {} - }; - - (rc.predef || []).forEach(function( prop ) { - settings.globals[ prop ] = true; - }); - delete rc.predef; - - return settings; - } - - return { - grunt: parserc(), - ui: parserc( "ui/" ), - // TODO: `evil: true` is only for document.write() https://github.com/jshint/jshint/issues/519 - // TODO: don't create so many globals in tests - tests: parserc( "tests/" ) - }; - })() + } }); -grunt.registerTask( "default", "lint csslint htmllint qunit" ); -grunt.registerTask( "sizer", "concat:ui min:dist/jquery-ui.min.js compare_size:all" ); -grunt.registerTask( "sizer_all", "concat:ui min compare_size" ); -grunt.registerTask( "build", "concat min cssmin copy:dist_units_images" ); -grunt.registerTask( "release", "clean build copy:dist copy:dist_min copy:dist_min_images copy:dist_css_min md5:dist zip:dist" ); -grunt.registerTask( "release_themes", "release generate_themes copy:themes md5:themes zip:themes" ); -grunt.registerTask( "release_cdn", "release_themes copy:cdn copy:cdn_min copy:cdn_i18n copy:cdn_i18n_min copy:cdn_min_images copy:cdn_themes md5:cdn zip:cdn" ); +grunt.registerTask( "default", [ "lint", "test" ] ); +grunt.registerTask( "lint", [ "jshint", "csslint", "htmllint" ] ); +grunt.registerTask( "test", [ "qunit" ] ); +grunt.registerTask( "sizer", [ "concat:ui", "uglify:main", "compare_size:all" ] ); +grunt.registerTask( "sizer_all", [ "concat:ui", "uglify", "compare_size" ] ); +grunt.registerTask( "build", [ "concat", "uglify", "cssmin", "copy:dist_units_images" ] ); +grunt.registerTask( "release", "clean build copy:dist copy:dist_min copy:dist_min_images copy:dist_css_min md5:dist zip:dist".split( " " ) ); +grunt.registerTask( "release_themes", "release generate_themes copy:themes md5:themes zip:themes".split( " " ) ); +grunt.registerTask( "release_cdn", "release_themes copy:cdn copy:cdn_min copy:cdn_i18n copy:cdn_i18n_min copy:cdn_themes md5:cdn zip:cdn".split( " " ) ); }; @@ -75,7 +75,7 @@ These should be squashed before landing in master. Fetch the remote first: - git fetch [their-fork.git] [their-branch] + git fetch [their-fork.git] [their-branch] Then cherry-pick the commit(s): @@ -83,7 +83,7 @@ Then cherry-pick the commit(s): If you need to edit the commit message: - git cherry-pick -e [sha-of-commit] + git cherry-pick -e [sha-of-commit] If you need to edit the changes: @@ -93,7 +93,7 @@ If you need to edit the changes: If it should go to the stable brach, cherry-pick it to stable: - git checkout 1-8-stable - git cherry-pick -x [sha-of-commit-from-master] + git checkout 1-10-stable + git cherry-pick -x [sha-of-commit-from-master] -*NOTE: Do not cherry-pick into 1-8-stable until you have pushed the commit from master upstream.* +*NOTE: Do not cherry-pick into 1-10-stable until you have pushed the commit from master upstream.* diff --git a/build/tasks/build.js b/build/tasks/build.js index a8f25f98f..978bee004 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -5,6 +5,19 @@ module.exports = function( grunt ) { var path = require( "path" ), fs = require( "fs" ); +function expandFiles( files ) { + return grunt.util._.pluck( grunt.file.expandMapping( files ), "src" ).filter(function(filepath) { + // restrict to files, exclude folders + try { + return fs.statSync( filepath[ 0 ] ).isFile(); + } catch(e) { + throw grunt.task.taskError(e.message, e); + } + }).map(function( values ) { + return values[ 0 ]; + }); +} + grunt.registerTask( "manifest", "Generate jquery.json manifest files", function() { var pkg = grunt.config( "pkg" ), base = { @@ -97,8 +110,8 @@ grunt.registerMultiTask( "copy", "Copy files to destination folder and replace @ grunt.file.copy( src, dest ); } } - var files = grunt.file.expandFiles( this.file.src ), - target = this.file.dest + "/", + var files = expandFiles( this.filesSrc ), + target = this.data.dest + "/", strip = this.data.strip, renameCount = 0, fileName; @@ -121,28 +134,11 @@ grunt.registerMultiTask( "copy", "Copy files to destination folder and replace @ grunt.registerMultiTask( "zip", "Create a zip file for release", function() { - // TODO switch back to adm-zip for better cross-platform compability once it actually works - // 0.1.3 works, but result can't be unzipped - // its also a lot slower then zip program, probably due to how its used... - // var files = grunt.file.expandFiles( "dist/" + this.file.src + "/**/*" ); - // grunt.log.writeln( "Creating zip file " + this.file.dest ); - - //var AdmZip = require( "adm-zip" ); - //var zip = new AdmZip(); - //files.forEach(function( file ) { - // grunt.verbose.writeln( "Zipping " + file ); - // // rewrite file names from dist folder (created by build), drop the /dist part - // zip.addFile(file.replace(/^dist/, "" ), fs.readFileSync( file ) ); - //}); - //zip.writeZip( "dist/" + this.file.dest ); - //grunt.log.writeln( "Wrote " + files.length + " files to " + this.file.dest ); - var done = this.async(), - dest = this.file.dest, - src = grunt.template.process( this.file.src, grunt.config() ); - grunt.utils.spawn({ + dest = this.data.dest; + grunt.util.spawn({ cmd: "zip", - args: [ "-r", dest, src ], + args: [ "-r", dest, this.data.src ], opts: { cwd: 'dist' } @@ -159,19 +155,19 @@ grunt.registerMultiTask( "zip", "Create a zip file for release", function() { grunt.registerMultiTask( "md5", "Create list of md5 hashes for CDN uploads", function() { // remove dest file before creating it, to make sure itself is not included - if ( fs.existsSync( this.file.dest ) ) { - fs.unlinkSync( this.file.dest ); + if ( fs.existsSync( this.data.dest ) ) { + fs.unlinkSync( this.data.dest ); } var crypto = require( "crypto" ), - dir = this.file.src + "/", + dir = this.filesSrc + "/", hashes = []; - grunt.file.expandFiles( dir + "**/*" ).forEach(function( fileName ) { + expandFiles( dir + "**/*" ).forEach(function( fileName ) { var hash = crypto.createHash( "md5" ); hash.update( grunt.file.read( fileName, "ascii" ) ); hashes.push( fileName.replace( dir, "" ) + " " + hash.digest( "hex" ) ); }); - grunt.file.write( this.file.dest, hashes.join( "\n" ) + "\n" ); - grunt.log.writeln( "Wrote " + this.file.dest + " with " + hashes.length + " hashes" ); + grunt.file.write( this.data.dest, hashes.join( "\n" ) + "\n" ); + grunt.log.writeln( "Wrote " + this.data.dest + " with " + hashes.length + " hashes" ); }); grunt.registerTask( "generate_themes", function() { diff --git a/build/tasks/testswarm.js b/build/tasks/testswarm.js index 55653649e..3166e9277 100644 --- a/build/tasks/testswarm.js +++ b/build/tasks/testswarm.js @@ -14,9 +14,9 @@ var versions = { "Autocomplete": "autocomplete/autocomplete.html", "Button": "button/button.html", "Core": "core/core.html", + "Core_deprecated": "core/core_deprecated.html", "Datepicker": "datepicker/datepicker.html", "Dialog": "dialog/dialog.html", - "Dialog_deprecated": "dialog/dialog_deprecated.html", "Draggable": "draggable/draggable.html", "Droppable": "droppable/droppable.html", "Effects": "effects/effects.html", diff --git a/demos/autocomplete/combobox.html b/demos/autocomplete/combobox.html index f89f260eb..22f34aa17 100644 --- a/demos/autocomplete/combobox.html +++ b/demos/autocomplete/combobox.html @@ -41,6 +41,7 @@ .addClass( "ui-combobox" ) .insertAfter( this.element ); + this.element.hide(); this._createAutocomplete(); this._createShowAllButton(); }, @@ -76,7 +77,8 @@ }, _createShowAllButton: function() { - var wasOpen = false; + var input = this.input, + wasOpen = false; $( "<a>" ) .attr( "tabIndex", -1 ) @@ -152,7 +154,7 @@ this._delay(function() { this.input.tooltip( "close" ).attr( "title", "" ); }, 2500 ); - this.input.data( "ui-autocomplete" ).term = ""; + this.input.autocomplete( "instance" ).term = ""; }, _destroy: function() { diff --git a/demos/autocomplete/custom-data.html b/demos/autocomplete/custom-data.html index 4e518db4d..32e6a9ad3 100644 --- a/demos/autocomplete/custom-data.html +++ b/demos/autocomplete/custom-data.html @@ -66,7 +66,7 @@ return false; } }) - .data( "ui-autocomplete" )._renderItem = function( ul, item ) { + .autocomplete( "instance" )._renderItem = function( ul, item ) { return $( "<li>" ) .append( "<a>" + item.label + "<br>" + item.desc + "</a>" ) .appendTo( ul ); diff --git a/demos/autocomplete/multiple-remote.html b/demos/autocomplete/multiple-remote.html index ed275628a..c97b3a904 100644 --- a/demos/autocomplete/multiple-remote.html +++ b/demos/autocomplete/multiple-remote.html @@ -29,7 +29,7 @@ // don't navigate away from the field on tab when selecting an item .bind( "keydown", function( event ) { if ( event.keyCode === $.ui.keyCode.TAB && - $( this ).data( "ui-autocomplete" ).menu.active ) { + $( this ).autocomplete( "instance" ).menu.active ) { event.preventDefault(); } }) diff --git a/demos/autocomplete/multiple.html b/demos/autocomplete/multiple.html index 68ae3d6a0..909432277 100644 --- a/demos/autocomplete/multiple.html +++ b/demos/autocomplete/multiple.html @@ -48,7 +48,7 @@ // don't navigate away from the field on tab when selecting an item .bind( "keydown", function( event ) { if ( event.keyCode === $.ui.keyCode.TAB && - $( this ).data( "ui-autocomplete" ).menu.active ) { + $( this ).autocomplete( "instance" ).menu.active ) { event.preventDefault(); } }) diff --git a/demos/progressbar/label.html b/demos/progressbar/label.html index 3e669ba4a..a1e16cb71 100644 --- a/demos/progressbar/label.html +++ b/demos/progressbar/label.html @@ -10,10 +10,13 @@ <script src="../../ui/jquery.ui.progressbar.js"></script> <link rel="stylesheet" href="../demos.css"> <style> + .ui-progressbar { + position: relative; + } .progress-label { - float: left; - margin-left: 50%; - margin-top: 5px; + position: absolute; + left: 50%; + top: 4px; font-weight: bold; text-shadow: 1px 1px 0 #fff; } diff --git a/demos/spinner/default.html b/demos/spinner/default.html index 5093e8666..3d3288807 100644 --- a/demos/spinner/default.html +++ b/demos/spinner/default.html @@ -23,7 +23,7 @@ } }); $( "#destroy" ).click(function() { - if ( spinner.data( "ui-spinner" ) ) { + if ( spinner.spinner( "instance" ) ) { spinner.spinner( "destroy" ); } else { spinner.spinner(); diff --git a/package.json b/package.json index ae8b13dc8..93c45a9fc 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "jquery-ui", "title": "jQuery UI", "description": "A curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library.", - "version": "1.10.2pre", + "version": "1.10.3pre", "homepage": "http://jqueryui.com", "author": { "name": "jQuery Foundation and other contributors", @@ -53,13 +53,17 @@ ], "dependencies": {}, "devDependencies": { - "grunt": "~0.3.17", - "grunt-css": "0.2.0", - "grunt-compare-size": "0.1.4", - "grunt-html": "0.1.1", - "grunt-junit": "0.1.5", - "grunt-git-authors": "1.0.0", - "rimraf": "2.0.1", + "grunt": "0.4.0", + "grunt-contrib-jshint": "0.1.1", + "grunt-contrib-uglify": "0.1.1", + "grunt-contrib-concat": "0.1.3", + "grunt-contrib-qunit": "0.2.0", + "grunt-contrib-csslint": "0.1.1", + "grunt-contrib-cssmin": "0.4.2", + "grunt-compare-size": "0.3.1", + "grunt-html": "0.3.3", + "grunt-git-authors": "1.2.0", + "rimraf": "2.1.4", "testswarm": "1.0.0-alpha" }, "keywords": [] diff --git a/tests/unit/accordion/accordion_events.js b/tests/unit/accordion/accordion_events.js index 79283d11c..5f6cfa8bc 100644 --- a/tests/unit/accordion/accordion_events.js +++ b/tests/unit/accordion/accordion_events.js @@ -6,7 +6,7 @@ var setupTeardown = TestHelpers.accordion.setupTeardown, module( "accordion: events", setupTeardown() ); test( "create", function() { - expect( 15 ); + expect( 10 ); var element = $( "#list1" ), headers = element.children( "h3" ), @@ -18,8 +18,6 @@ test( "create", function() { strictEqual( ui.header[ 0 ], headers[ 0 ], "header" ); equal( ui.panel.length, 1, "panel length" ); strictEqual( ui.panel[ 0 ], contents[ 0 ], "panel" ); - equal( ui.content.length, 1, "content length" ); - strictEqual( ui.content[ 0 ], contents[ 0 ], "content" ); } }); element.accordion( "destroy" ); @@ -31,8 +29,6 @@ test( "create", function() { strictEqual( ui.header[ 0 ], headers[ 2 ], "header" ); equal( ui.panel.length, 1, "panel length" ); strictEqual( ui.panel[ 0 ], contents[ 2 ], "panel" ); - equal( ui.content.length, 1, "content length" ); - strictEqual( ui.content[ 0 ], contents[ 2 ], "content" ); } }); element.accordion( "destroy" ); @@ -43,7 +39,6 @@ test( "create", function() { create: function( event, ui ) { equal( ui.header.length, 0, "header length" ); equal( ui.panel.length, 0, "panel length" ); - equal( ui.content.length, 0, "content length" ); } }); element.accordion( "destroy" ); diff --git a/tests/unit/accordion/accordion_methods.js b/tests/unit/accordion/accordion_methods.js index b1123b828..7612479f7 100644 --- a/tests/unit/accordion/accordion_methods.js +++ b/tests/unit/accordion/accordion_methods.js @@ -14,10 +14,15 @@ test( "destroy", function() { }); test( "enable/disable", function() { - expect( 4 ); + expect( 7 ); var element = $( "#list1" ).accordion(); state( element, 1, 0, 0 ); element.accordion( "disable" ); + + ok( element.hasClass( "ui-state-disabled" ), "element gets ui-state-disabled" ); + equal( element.attr( "aria-disabled" ), "true", "element gets aria-disabled" ); + ok( element.hasClass( "ui-accordion-disabled" ), "element gets ui-accordion-disabled" ); + // event does nothing element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" ); state( element, 1, 0, 0 ); diff --git a/tests/unit/all.html b/tests/unit/all.html index ba96feef2..8dfff2a4e 100644 --- a/tests/unit/all.html +++ b/tests/unit/all.html @@ -20,9 +20,9 @@ "autocomplete/autocomplete.html", "button/button.html", "core/core.html", + "core/core_deprecated.html", "datepicker/datepicker.html", "dialog/dialog.html", - "dialog/dialog_deprecated.html", "draggable/draggable.html", "droppable/droppable.html", "effects/effects.html", diff --git a/tests/unit/autocomplete/autocomplete_core.js b/tests/unit/autocomplete/autocomplete_core.js index 845a3b19d..a9fc1143c 100644 --- a/tests/unit/autocomplete/autocomplete_core.js +++ b/tests/unit/autocomplete/autocomplete_core.js @@ -99,7 +99,7 @@ test( "allow form submit on enter when menu is not active", function() { delay: 0, minLength: 0 }); - element.data( "ui-autocomplete" )._move = function() { + element.autocomplete( "instance" )._move = function() { didMove = true; }; element.simulate( "keydown", { keyCode: ( isKeyUp ? $.ui.keyCode.UP : $.ui.keyCode.DOWN ) } ); @@ -114,7 +114,7 @@ test( "allow form submit on enter when menu is not active", function() { delay: 0, minLength: 0 }); - element.data( "ui-autocomplete" )._move = function() { + element.autocomplete( "instance" )._move = function() { ok( true, "repsond to arrow" ); }; element.autocomplete( "search" ); @@ -156,7 +156,7 @@ test( "ARIA", function() { var element = $( "#autocomplete" ).autocomplete({ source: [ "java", "javascript" ] }), - liveRegion = element.data( "ui-autocomplete" ).liveRegion; + liveRegion = element.autocomplete( "instance" ).liveRegion; equal( liveRegion.text(), "", "Empty live region on create" ); diff --git a/tests/unit/autocomplete/autocomplete_options.js b/tests/unit/autocomplete/autocomplete_options.js index 9f0bd2d43..c98f2c28e 100644 --- a/tests/unit/autocomplete/autocomplete_options.js +++ b/tests/unit/autocomplete/autocomplete_options.js @@ -88,17 +88,20 @@ asyncTest( "delay", function() { }); asyncTest( "disabled", function() { - expect( 2 ); + expect( 5 ); var element = $( "#autocomplete" ).autocomplete({ source: data, - delay: 0, - disabled: true + delay: 0 }), - menu = element.autocomplete( "widget" ); + menu = element.autocomplete( "disable" ).autocomplete( "widget" ); element.val( "ja" ).keydown(); ok( menu.is( ":hidden" ) ); + ok( !element.is( ".ui-state-disabled" ), "element doesn't get ui-state-disabled" ); + ok( !element.attr( "aria-disabled" ), "element doesn't get aria-disabled" ); + ok( menu.is( ".ui-autocomplete-disabled" ), "element gets ui-autocomplete-disabled" ); + setTimeout(function() { ok( menu.is( ":hidden" ) ); start(); diff --git a/tests/unit/button/button_options.js b/tests/unit/button/button_options.js index e1931a54e..124a8699f 100644 --- a/tests/unit/button/button_options.js +++ b/tests/unit/button/button_options.js @@ -3,19 +3,26 @@ */ (function($) { -module("button: options"); +module( "button: options" ); -test("disabled, explicit value", function() { - expect( 4 ); - $("#radio01").button({ disabled: false }); - deepEqual(false, $("#radio01").button("option", "disabled"), - "disabled option set to false"); - deepEqual(false, $("#radio01").prop("disabled"), "element is disabled"); +test( "disabled, explicit value", function() { + expect( 9 ); - $("#radio02").button({ disabled: true }); - deepEqual(true, $("#radio02").button("option", "disabled"), - "disabled option set to true"); - deepEqual(true, $("#radio02").prop("disabled"), "element is not disabled"); + var element = $( "#radio01" ).button({ disabled: false }); + deepEqual( element.button( "option", "disabled" ), false, "disabled option set to false" ); + deepEqual( element.prop( "disabled" ), false, "element is disabled" ); + + ok( !element.button( "widget" ).hasClass( "ui-state-disabled" ), "element gets ui-state-disabled" ); + ok( !element.button( "widget" ).hasClass( "ui-button-disabled" ), "element gets ui-button-disabled" ); + + element = $( "#radio02" ).button({ disabled: true }); + + ok( element.button( "widget" ).hasClass( "ui-state-disabled" ), "element gets ui-state-disabled" ); + ok( !element.button( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" ); + ok( element.button( "widget" ).hasClass( "ui-button-disabled" ), "element gets ui-button-disabled" ); + + deepEqual( element.button( "option", "disabled" ), true, "disabled option set to true" ); + deepEqual( element.prop( "disabled" ), true, "element is not disabled" ); }); test("disabled, null", function() { diff --git a/tests/unit/core/core.html b/tests/unit/core/core.html index 41c8db827..fd472d64a 100644 --- a/tests/unit/core/core.html +++ b/tests/unit/core/core.html @@ -117,17 +117,6 @@ <input id="dimensionlessParent-dimensionless" style="height: 0; width: 0;"> </div> -<div id="zIndex100" style="z-index: 100; position: absolute"> - <div id="zIndexAutoWithParent">.</div> -</div> -<div id="zIndex100ViaCSS" class="zindex"> - <div id="zIndexAutoWithParentViaCSS">.</div> -</div> -<div id="zIndex100ViaCSSPositioned" class="zindex absolute"> - <div id="zIndexAutoWithParentViaCSSPositioned">.</div> -</div> -<div id="zIndexAutoNoParent"></div> - <div id="dimensions" style="float: left; height: 50px; width: 100px; margin: 1px 12px 11px 2px; border-style: solid; border-width: 3px 14px 13px 4px; padding: 5px 16px 15px 6px;"></div> </div> diff --git a/tests/unit/core/core.js b/tests/unit/core/core.js index 78a225338..54d50d84e 100644 --- a/tests/unit/core/core.js +++ b/tests/unit/core/core.js @@ -26,25 +26,6 @@ asyncTest( "focus", function() { }); }); -test( "zIndex", function() { - expect( 7 ); - var el = $( "#zIndexAutoWithParent" ), - parent = el.parent(); - equal( el.zIndex(), 100, "zIndex traverses up to find value" ); - equal( parent.zIndex(200 ), parent, "zIndex setter is chainable" ); - equal( el.zIndex(), 200, "zIndex setter changed zIndex" ); - - el = $( "#zIndexAutoWithParentViaCSS" ); - equal( el.zIndex(), 0, "zIndex traverses up to find CSS value, not found because not positioned" ); - - el = $( "#zIndexAutoWithParentViaCSSPositioned" ); - equal( el.zIndex(), 100, "zIndex traverses up to find CSS value" ); - el.parent().zIndex( 200 ); - equal( el.zIndex(), 200, "zIndex setter changed zIndex, overriding CSS" ); - - equal( $( "#zIndexAutoNoParent" ).zIndex(), 0, "zIndex never explicitly set in hierarchy" ); -}); - test( "innerWidth - getter", function() { expect( 2 ); var el = $( "#dimensions" ); diff --git a/tests/unit/core/core_deprecated.html b/tests/unit/core/core_deprecated.html new file mode 100644 index 000000000..d9c41ca39 --- /dev/null +++ b/tests/unit/core/core_deprecated.html @@ -0,0 +1,136 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Core Test Suite</title> + + <script src="../../jquery.js"></script> + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> + <script> + TestHelpers.loadResources({ + js: [ "ui/jquery.ui.core.js" ] + }); + </script> + + <script src="core.js"></script> + <script src="selector.js"></script> + <script src="core_deprecated.js"></script> + + <script src="../swarminject.js"></script> + <style> + .zindex { + z-index: 100; + } + .absolute { + position: absolute; + } + </style> +</head> +<body> + +<h1 id="qunit-header">jQuery UI Core Test Suite</h1> +<h2 id="qunit-banner"></h2> +<div id="qunit-testrunner-toolbar"></div> +<h2 id="qunit-userAgent"></h2> +<ol id="qunit-tests"></ol> +<div id="qunit-fixture"> + +<img src="../images/jqueryui_32x32.png" usemap="#mymap" width="10" height="10" alt=""> +<map name="mymap"> + <area shape="rect" coords="1,1,2,2" href="foo.html" id="areaCoordsHref" alt=""> + <area href="foo.html" id="areaNoCoordsHref" alt=""> +</map> +<map name="mymap2"> + <area shape="rect" coords="1,1,2,2" href="foo.html" id="areaNoImg" alt=""> +</map> + +<form id="formNoTabindex"></form> +<form id="formTabindex" tabindex="1"></form> + +<div> + <input id="visibleAncestor-inputTypeNone"> + <input type="text" id="visibleAncestor-inputTypeText"> + <input type="checkbox" id="visibleAncestor-inputTypeCheckbox"> + <input type="radio" id="visibleAncestor-inputTypeRadio"> + <input type="button" id="visibleAncestor-inputTypeButton" value="visibleAncestor-inputTypeButton"> + <input type="hidden" id="visibleAncestor-inputTypeHidden"> + <button id="visibleAncestor-button">x</button> + <select id="visibleAncestor-select"> + <option>option</option> + </select> + <textarea id="visibleAncestor-textarea">x</textarea> + <object id="visibleAncestor-object" codebase="about:blank">xxx</object> + <a href="#" id="visibleAncestor-anchorWithHref">anchor</a> + <a id="visibleAncestor-anchorWithoutHref">anchor</a> + <span id="visibleAncestor-span">x</span> + <div id="visibleAncestor-div">x</div> + <span id="visibleAncestor-spanWithTabindex" tabindex="1">x</span> + <div id="visibleAncestor-divWithNegativeTabindex" tabindex="-1">x</div> +</div> + +<div> + <input id="disabledElement-inputTypeNone" disabled="disabled"> + <input type="text" id="disabledElement-inputTypeText" disabled="disabled"> + <input type="checkbox" id="disabledElement-inputTypeCheckbox" disabled="disabled"> + <input type="radio" id="disabledElement-inputTypeRadio" disabled="disabled"> + <input type="button" id="disabledElement-inputTypeButton" disabled="disabled" value="disabledElement-inputTypeButton"> + <input type="hidden" id="disabledElement-inputTypeHidden" disabled="disabled"> + <button id="disabledElement-button" disabled="disabled"></button> + <select id="disabledElement-select" disabled="disabled"></select> + <textarea id="disabledElement-textarea" disabled="disabled"></textarea> +</div> + +<div> + <div id="displayNoneAncestor" style="display: none;"> + <input id="displayNoneAncestor-input"> + <span tabindex="1" id="displayNoneAncestor-span">.</span> + </div> + + <div id="visibilityHiddenAncestor" style="visibility: hidden;"> + <input id="visibilityHiddenAncestor-input"> + <span tabindex="1" id="visibilityHiddenAncestor-span">.</span> + </div> + + <span tabindex="1" id="displayNone-span" style="display: none;">.</span> + <span tabindex="1" id="visibilityHidden-span" style="visibility: hidden;">.</span> + + <input id="displayNone-input" style="display: none;"> + <input id="visibilityHidden-input" style="visibility: hidden;"> +</div> + +<div> + <input id="inputTabindex0" tabindex="0"> + <input id="inputTabindex10" tabindex="10"> + <input id="inputTabindex-1" tabindex="-1"> + <input id="inputTabindex-50" tabindex="-50"> + + <span id="spanTabindex0" tabindex="0">.</span> + <span id="spanTabindex10" tabindex="10">.</span> + <span id="spanTabindex-1" tabindex="-1">.</span> + <span id="spanTabindex-50" tabindex="-50">.</span> +</div> + +<div style="width: 0; height: 0;"> + <input id="dimensionlessParent"> + <input id="dimensionlessParent-dimensionless" style="height: 0; width: 0;"> +</div> + +<div id="zIndex100" style="z-index: 100; position: absolute"> + <div id="zIndexAutoWithParent">.</div> +</div> +<div id="zIndex100ViaCSS" class="zindex"> + <div id="zIndexAutoWithParentViaCSS">.</div> +</div> +<div id="zIndex100ViaCSSPositioned" class="zindex absolute"> + <div id="zIndexAutoWithParentViaCSSPositioned">.</div> +</div> +<div id="zIndexAutoNoParent"></div> + +<div id="dimensions" style="float: left; height: 50px; width: 100px; margin: 1px 12px 11px 2px; border-style: solid; border-width: 3px 14px 13px 4px; padding: 5px 16px 15px 6px;"></div> + +</div> +</body> +</html> diff --git a/tests/unit/core/core_deprecated.js b/tests/unit/core/core_deprecated.js new file mode 100644 index 000000000..bb06f77b2 --- /dev/null +++ b/tests/unit/core/core_deprecated.js @@ -0,0 +1,24 @@ +(function( $ ) { + +module( "core - deprecated" ); + +test( "zIndex", function() { + expect( 7 ); + var el = $( "#zIndexAutoWithParent" ), + parent = el.parent(); + equal( el.zIndex(), 100, "zIndex traverses up to find value" ); + equal( parent.zIndex(200 ), parent, "zIndex setter is chainable" ); + equal( el.zIndex(), 200, "zIndex setter changed zIndex" ); + + el = $( "#zIndexAutoWithParentViaCSS" ); + equal( el.zIndex(), 0, "zIndex traverses up to find CSS value, not found because not positioned" ); + + el = $( "#zIndexAutoWithParentViaCSSPositioned" ); + equal( el.zIndex(), 100, "zIndex traverses up to find CSS value" ); + el.parent().zIndex( 200 ); + equal( el.zIndex(), 200, "zIndex setter changed zIndex, overriding CSS" ); + + equal( $( "#zIndexAutoNoParent" ).zIndex(), 0, "zIndex never explicitly set in hierarchy" ); +}); + +})( jQuery ); diff --git a/tests/unit/dialog/dialog_deprecated.html b/tests/unit/dialog/dialog_deprecated.html deleted file mode 100644 index 1f8bac689..000000000 --- a/tests/unit/dialog/dialog_deprecated.html +++ /dev/null @@ -1,67 +0,0 @@ -<!doctype html> -<html lang="en"> -<head> - <meta charset="utf-8"> - <title>jQuery UI Dialog Test Suite</title> - - <script src="../../jquery.js"></script> - <link rel="stylesheet" href="../../../external/qunit.css"> - <script src="../../../external/qunit.js"></script> - <script src="../../jquery.simulate.js"></script> - <script src="../testsuite.js"></script> - <script> - TestHelpers.loadResources({ - css: [ "ui.core", "ui.dialog" ], - js: [ - "ui/jquery.ui.core.js", - "ui/jquery.ui.widget.js", - "ui/jquery.ui.position.js", - "ui/jquery.ui.mouse.js", - "ui/jquery.ui.draggable.js", - "ui/jquery.ui.resizable.js", - "ui/jquery.ui.button.js", - "ui/jquery.ui.effect.js", - "ui/jquery.ui.effect-blind.js", - "ui/jquery.ui.effect-clip.js", - "ui/jquery.ui.effect-explode.js", - "ui/jquery.ui.dialog.js" - ] - }); - </script> - - <script src="dialog_common.js"></script> - <script src="dialog_core.js"></script> - <script src="dialog_events.js"></script> - <script src="dialog_methods.js"></script> - <script src="dialog_options.js"></script> - <script src="dialog_test_helpers.js"></script> - <script src="dialog_deprecated.js"></script> - - <script src="../swarminject.js"></script> -</head> -<body> - -<h1 id="qunit-header">jQuery UI Dialog Test Suite</h1> -<h2 id="qunit-banner"></h2> -<div id="qunit-testrunner-toolbar"></div> -<h2 id="qunit-userAgent"></h2> -<ol id="qunit-tests"></ol> -<div id="qunit-fixture"> - <div id="dialog1"></div> - <div id="dialog2"></div> - <div id="form-dialog" title="Profile Information"> - <fieldset> - <legend>Please share some personal information</legend> - <label for="favorite-animal">Your favorite animal</label><input id="favorite-animal"> - <label for="favorite-color">Your favorite color</label><input id="favorite-color"> - </fieldset> - <div role="group" aria-describedby="section2"> - <p id="section2">Some more (optional) information</p> - <label for="favorite-food">Favorite food</label><input id="favorite-food"> - </div> - </div> - <div class="wrap" id="wrap1"></div> - <div class="wrap" id="wrap2"></div> -</div> -</body> -</html> diff --git a/tests/unit/dialog/dialog_deprecated.js b/tests/unit/dialog/dialog_deprecated.js deleted file mode 100644 index ff6284ea5..000000000 --- a/tests/unit/dialog/dialog_deprecated.js +++ /dev/null @@ -1,63 +0,0 @@ -module("dialog (deprecated): position option with string and array"); - -test( "position, right bottom on window w/array", function() { - expect( 2 ); - - // dialogs alter the window width and height in FF and IE7 - // so we collect that information before creating the dialog - // Support: FF, IE7 - var winWidth = $( window ).width(), - winHeight = $( window ).height(), - element = $("<div></div>").dialog({ position: [ "right", "bottom" ] }), - dialog = element.dialog("widget"), - offset = dialog.offset(); - closeEnough( offset.left, winWidth - dialog.outerWidth() + $( window ).scrollLeft(), 1, "offset left of right bottom on window w/array" ); - closeEnough( offset.top, winHeight - dialog.outerHeight() + $( window ).scrollTop(), 1, "offset top of right bottom on window w/array" ); - element.remove(); -}); - -test( "position, right bottom on window", function() { - expect( 2 ); - - // dialogs alter the window width and height in FF and IE7 - // so we collect that information before creating the dialog - // Support: FF, IE7 - var winWidth = $( window ).width(), - winHeight = $( window ).height(), - element = $("<div></div>").dialog({ position: "right bottom" }), - dialog = element.dialog("widget"), - offset = dialog.offset(); - closeEnough( offset.left, winWidth - dialog.outerWidth() + $( window ).scrollLeft(), 1, "offset left of right bottom on window" ); - closeEnough( offset.top, winHeight - dialog.outerHeight() + $( window ).scrollTop(), 1, "offset top of right bottom on window" ); - element.remove(); -}); - -test("position, offset from top left w/array", function() { - expect( 2 ); - var element = $("<div></div>").dialog({ position: [10, 10] }), - dialog = element.dialog("widget"), - offset = dialog.offset(); - closeEnough(offset.left, 10 + $(window).scrollLeft(), 1); - closeEnough(offset.top, 10 + $(window).scrollTop(), 1); - element.remove(); -}); - -test("position, top on window", function() { - expect( 2 ); - var element = $("<div></div>").dialog({ position: "top" }), - dialog = element.dialog("widget"), - offset = dialog.offset(); - closeEnough(offset.left, Math.round($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft(), 1); - closeEnough(offset.top, $(window).scrollTop(), 1); - element.remove(); -}); - -test("position, left on window", function() { - expect( 2 ); - var element = $("<div></div>").dialog({ position: "left" }), - dialog = element.dialog("widget"), - offset = dialog.offset(); - closeEnough(offset.left, 0, 1); - closeEnough(offset.top, Math.round($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop(), 1); - element.remove(); -}); diff --git a/tests/unit/dialog/dialog_events.js b/tests/unit/dialog/dialog_events.js index 7bcd5673e..1384500f6 100644 --- a/tests/unit/dialog/dialog_events.js +++ b/tests/unit/dialog/dialog_events.js @@ -11,7 +11,7 @@ test("open", function() { var element = $("<div></div>"); element.dialog({ open: function(ev, ui) { - ok(element.data("ui-dialog")._isOpen, "interal _isOpen flag is set"); + ok(element.dialog( "instance" )._isOpen, "interal _isOpen flag is set"); ok(true, "autoOpen: true fires open callback"); equal(this, element[0], "context of callback"); equal(ev.type, "dialogopen", "event type in callback"); @@ -30,7 +30,7 @@ test("open", function() { deepEqual(ui, {}, "ui hash in callback"); } }).bind("dialogopen", function(ev, ui) { - ok(element.data("ui-dialog")._isOpen, "interal _isOpen flag is set"); + ok(element.dialog( "instance" )._isOpen, "interal _isOpen flag is set"); ok(true, "dialog('open') fires open event"); equal(this, element[0], "context of event"); deepEqual(ui, {}, "ui hash in event"); diff --git a/tests/unit/dialog/dialog_methods.js b/tests/unit/dialog/dialog_methods.js index 6de185513..2bb06ab46 100644 --- a/tests/unit/dialog/dialog_methods.js +++ b/tests/unit/dialog/dialog_methods.js @@ -101,11 +101,13 @@ test("#4980: Destroy should place element back in original DOM position", functi }); test( "enable/disable disabled", function() { - expect( 2 ); + expect( 4 ); var element = $( "<div></div>" ).dialog(); element.dialog( "disable" ); equal(element.dialog( "option", "disabled" ), false, "disable method doesn't do anything" ); ok( !element.dialog( "widget" ).hasClass( "ui-dialog-disabled" ), "disable method doesn't add ui-dialog-disabled class" ); + ok( !element.dialog( "widget" ).hasClass( "ui-state-disabled" ), "disable method doesn't add ui-state-disabled class" ); + ok( !element.dialog( "widget" ).attr( "aria-disabled" ), "disable method doesn't add aria-disabled" ); }); test("close", function() { diff --git a/tests/unit/draggable/draggable.html b/tests/unit/draggable/draggable.html index 6380f3e85..3d1d3326e 100644 --- a/tests/unit/draggable/draggable.html +++ b/tests/unit/draggable/draggable.html @@ -48,7 +48,7 @@ <div id="qunit-fixture"> <div id="main"></div> <div id="draggable1" style="background: green; width: 200px; height: 100px;">Relative</div> - <div id="draggable2" style="background: green; width: 200px; height: 100px; position: absolute; top: 10px; left: 10px;"><span>Absolute</span></div> + <div id="draggable2" style="background: green; width: 200px; height: 100px; position: absolute; top: 10px; left: 10px;"><span><em>Absolute</em></span></div> <div id="droppable" style="background: green; width: 200px; height: 100px; position: absolute; top: 110px; left: 110px;"><span>Absolute</span></div> <div style="width: 1px; height: 1000px;"></div> <div style="position: absolute; width: 1px; height: 2000px;"></div> diff --git a/tests/unit/draggable/draggable_events.js b/tests/unit/draggable/draggable_events.js index 199561be3..bbaaaeb15 100644 --- a/tests/unit/draggable/draggable_events.js +++ b/tests/unit/draggable/draggable_events.js @@ -117,7 +117,7 @@ test( "stopping the stop callback", function() { dy: 10 }); - ok( element.data("ui-draggable").helper, "the clone should not be deleted if the stop callback is stopped" ); + ok( element.draggable( "instance" ).helper, "the clone should not be deleted if the stop callback is stopped" ); }); diff --git a/tests/unit/draggable/draggable_methods.js b/tests/unit/draggable/draggable_methods.js index 901c261d6..63a19e26d 100644 --- a/tests/unit/draggable/draggable_methods.js +++ b/tests/unit/draggable/draggable_methods.js @@ -74,16 +74,16 @@ test( "enable", function() { }); test( "disable", function() { - expect( 7 ); + expect( 10 ); - element = $("#draggable2").draggable({ disabled: false }); + element = $( "#draggable2" ).draggable({ disabled: false }); TestHelpers.draggable.shouldMove( element, ".draggable({ disabled: false })" ); - element.draggable("disable"); + element.draggable( "disable" ); TestHelpers.draggable.shouldNotMove( element, ".draggable('disable')" ); equal( element.draggable( "option", "disabled" ), true, "disabled option getter" ); - element.draggable("destroy"); + element.draggable( "destroy" ); element.draggable({ disabled: false }); TestHelpers.draggable.shouldMove( element, ".draggable({ disabled: false })" ); @@ -91,8 +91,12 @@ test( "disable", function() { equal( element.draggable( "option", "disabled" ), true, "disabled option setter" ); TestHelpers.draggable.shouldNotMove( element, ".draggable('option', 'disabled', true)" ); + ok( !element.draggable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" ); + ok( !element.draggable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" ); + ok( element.draggable( "widget" ).hasClass( "ui-draggable-disabled" ), "element gets ui-draggable-disabled" ); + var expected = element.draggable(), - actual = expected.draggable("disable"); + actual = expected.draggable( "disable" ); equal( actual, expected, "disable is chainable" ); }); diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js index ccbe7224a..f4fca0b2e 100644 --- a/tests/unit/draggable/draggable_options.js +++ b/tests/unit/draggable/draggable_options.js @@ -346,6 +346,37 @@ test( "{ containment: 'parent' }, absolute", function() { deepEqual( offsetAfter, expected, "compare offset to parent" ); }); +test( "containment, account for border", function() { + expect( 2 ); + + var el = $("#draggable1").appendTo("#main"), + parent = el.parent().css({ + height: "100px", + width: "100px", + borderStyle: "solid", + borderWidth: "5px 10px 15px 20px" + }), + parentBottom = parent.offset().top + parent.outerHeight(), + parentRight = parent.offset().left + parent.outerWidth(), + parentBorderBottom = TestHelpers.draggable.border( parent, "bottom" ), + parentBorderRight = TestHelpers.draggable.border( parent, "right" ); + + el.css({ + height: "5px", + width: "5px" + }).draggable({ containment: "parent" }); + + el.simulate( "drag", { + dx: 100, + dy: 100 + }); + + equal( el.offset().top, parentBottom - parentBorderBottom - el.height(), + "The draggable should be on top of its parent's bottom border" ); + equal( el.offset().left, parentRight - parentBorderRight - el.width(), + "The draggable should be to the right of its parent's right border" ); +}); + test( "containment, default, switching after initialization", function() { expect( 2 ); @@ -572,39 +603,15 @@ test( "grid, switching after initialization", function() { }); test( "{ handle: 'span' }", function() { - expect( 2 ); + expect( 3 ); var element = $( "#draggable2" ).draggable({ handle: "span" }); TestHelpers.draggable.testDrag( element, "#draggable2 span", 50, 50, 50, 50, "drag span" ); + TestHelpers.draggable.testDrag( element, "#draggable2 span em", 50, 50, 50, 50, "drag span child" ); TestHelpers.draggable.shouldNotMove( element, "drag element" ); }); -/* -test( "{ handle: Selectors }, matching parent selector", function() { - - expect( 4 ); - - var element = $( "#draggable2" ).draggable({ handle: "span a" }); - - $( "#qunit-fixture" ).append( "<span id='wrapping'><a></a></span>" ); - - element.find( "span" ).append( "<a>" ); - - $( "#wrapping a" ).append( element ); - - TestHelpers.draggable.testDrag( element, "#draggable2 span a", 50, 50, 50, 50, "drag span child" ); - TestHelpers.draggable.shouldNotMove( $( "#wrapping a" ) ); - - $( "#draggable2" ).draggable( "option", "handle", "span > a" ); - $( "#draggable2" ).find( "a" ).append( "<a>" ); - - TestHelpers.draggable.testDrag( element, $( "#draggable2 span a" ).first(), 50, 50, 50, 50, "drag span child" ); - TestHelpers.draggable.shouldNotMove( $( "#draggable2 span a" ).last() ); - -}); -*/ - test( "handle, default, switching after initialization", function() { expect( 6 ); @@ -1096,6 +1103,40 @@ test( "scroll, scrollSensitivity, and scrollSpeed", function() { TestHelpers.draggable.restoreScroll( document ); }); +test( "#6817: auto scroll goes double distance when dragging", function() { + expect( 2 ); + + var offsetBefore, + distance = 10, + viewportHeight = $( window ).height(), + element = $( "#draggable1" ).draggable({ + scroll: true, + stop: function( e, ui ) { + equal( ui.offset.top, newY, "offset of item matches pointer position after scroll" ); + equal( ui.offset.top - offsetBefore.top, distance, "offset of item only moves expected distance after scroll" ); + } + }), + scrollSensitivity = element.draggable( "option", "scrollSensitivity" ), + oldY = viewportHeight - scrollSensitivity, + newY = oldY + distance; + + element.offset({ + top: oldY, + left: 1 + }); + + offsetBefore = element.offset(); + + element.simulate( "drag", { + handle: "corner", + dx: 1, + y: newY, + moves: 1 + }); + + TestHelpers.draggable.restoreScroll( document ); +}); + test( "snap, snapMode, and snapTolerance", function() { expect( 9 ); @@ -1216,6 +1257,76 @@ test( "snap, snapMode, and snapTolerance", function() { deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap on the inner snapTolerance area when snapMode is outer" ); }); +test( "#8459: element can snap to an element that was removed during drag", function() { + expect( 1 ); + + var newX, newY, + snapTolerance = 15, + element = $( "#draggable1" ).draggable({ + snap: true, + snapMode: "both", + snapTolerance: snapTolerance, + start: function() { + element2.remove(); + } + }), + element2 = $( "#draggable2" ).draggable(); + + element.offset({ + top: 1, + left: 1 + }); + + newX = element2.offset().left - element.outerWidth() - snapTolerance + 1; + newY = element2.offset().top; + + element.simulate( "drag", { + handle: "corner", + x: newX, + y: newY, + moves: 1 + }); + + deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap to a removed element" ); +}); + +test( "#8165: Snapping large rectangles to small rectangles doesn't snap properly", function() { + expect( 1 ); + + var snapTolerance = 20, + y = 1, + element = $( "#draggable1" ) + .css({ + width: "50px", + height: "200px" + }).offset({ + top: y, + left: 1 + }), + element2 = $( "#draggable2" ) + .css({ + width: "50px", + height: "50px" + }).offset({ + top: y + snapTolerance + 1, + left: 200 + }), + newX = element2.offset().left - element.outerWidth() - snapTolerance + 1; + + $( "#draggable1, #draggable2" ).draggable({ + snap: true, + snapTolerance: snapTolerance + }); + + element.simulate( "drag", { + handle: "corner", + x: newX, + moves: 1 + }); + + notDeepEqual( element.offset(), { top: y, left: newX }, "snaps even if only a side (not a corner) is inside the snapTolerance" ); +}); + test( "stack", function() { expect( 2 ); diff --git a/tests/unit/draggable/draggable_test_helpers.js b/tests/unit/draggable/draggable_test_helpers.js index e1c79c6cc..44e37c559 100644 --- a/tests/unit/draggable/draggable_test_helpers.js +++ b/tests/unit/draggable/draggable_test_helpers.js @@ -60,7 +60,7 @@ TestHelpers.draggable = { }, trackMouseCss : function( el ) { - el.on( "drag", function() { + el.bind( "drag", function() { el.data( "last_dragged_cursor", $("body").css("cursor") ); }); }, @@ -69,7 +69,7 @@ TestHelpers.draggable = { // appendTo ignored without being clone el.draggable( "option", "helper", "clone" ); - el.on( "drag", function(e,ui) { + el.bind( "drag", function(e,ui) { // Get what parent is at time of drag el.data( "last_dragged_parent", ui.helper.parent()[0] ); }); diff --git a/tests/unit/droppable/droppable_methods.js b/tests/unit/droppable/droppable_methods.js index 2b452a63d..f7682d262 100644 --- a/tests/unit/droppable/droppable_methods.js +++ b/tests/unit/droppable/droppable_methods.js @@ -63,26 +63,29 @@ test("enable", function() { equal(actual, expected, "enable is chainable"); }); -test("disable", function() { - expect(7); +test( "disable", function() { + expect( 10 ); - var el, actual, expected; + var actual, expected, + element = $( "#droppable1" ).droppable({ disabled: false }); - el = $("#droppable1").droppable({ disabled: false }); TestHelpers.droppable.shouldDrop(); - el.droppable("disable"); + element.droppable( "disable" ); TestHelpers.droppable.shouldNotDrop(); - equal(el.droppable("option", "disabled"), true, "disabled option getter"); - el.droppable("destroy"); - el.droppable({ disabled: false }); + equal( element.droppable( "option", "disabled" ), true, "disabled option getter" ); + element.droppable( "destroy" ); + element.droppable({ disabled: false }); TestHelpers.droppable.shouldDrop(); - el.droppable("option", "disabled", true); - equal(el.droppable("option", "disabled"), true, "disabled option setter"); + element.droppable( "option", "disabled", true ); + ok( !element.droppable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" ); + ok( !element.droppable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" ); + ok( element.droppable( "widget" ).hasClass( "ui-droppable-disabled" ), "element gets ui-droppable-disabled" ); + equal( element.droppable( "option", "disabled" ), true, "disabled option setter" ); TestHelpers.droppable.shouldNotDrop(); - expected = $("<div></div>").droppable(), - actual = expected.droppable("disable"); - equal(actual, expected, "disable is chainable"); + expected = $( "<div></div>" ).droppable(); + actual = expected.droppable( "disable" ); + equal( actual, expected, "disable is chainable" ); }); })(jQuery); diff --git a/tests/unit/progressbar/progressbar_methods.js b/tests/unit/progressbar/progressbar_methods.js index cf7faf6af..004eacf90 100644 --- a/tests/unit/progressbar/progressbar_methods.js +++ b/tests/unit/progressbar/progressbar_methods.js @@ -7,6 +7,16 @@ test( "destroy", function() { }); }); +test( "disable", function() { + expect( 3 ); + + var element = $( "#progressbar" ).progressbar().progressbar( "disable" ); + + ok( element.progressbar( "widget" ).hasClass( "ui-state-disabled" ), "element gets ui-state-disabled" ); + ok( element.progressbar( "widget" ).attr( "aria-disabled" ), "element gets aria-disabled" ); + ok( element.progressbar( "widget" ).hasClass( "ui-progressbar-disabled" ), "element gets ui-progressbar-disabled" ); +}); + test( "value", function() { expect( 3 ); diff --git a/tests/unit/resizable/resizable_methods.js b/tests/unit/resizable/resizable_methods.js index b12f3035a..abb8951f9 100644 --- a/tests/unit/resizable/resizable_methods.js +++ b/tests/unit/resizable/resizable_methods.js @@ -3,10 +3,19 @@ */ (function($) { -module("resizable: methods"); +module( "resizable: methods" ); -// this is here to make JSHint pass "unused", and we don't want to -// remove the parameter for when we finally implement -$.noop(); +test( "disable", function() { + expect( 5 ); + + var element = $( "#resizable1" ).resizable({ disabled: false }), + chainable = element.resizable( "disable" ); + + ok( !element.resizable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" ); + ok( !element.resizable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" ); + ok( element.resizable( "widget" ).hasClass( "ui-resizable-disabled" ), "element gets ui-resizable-disabled" ); + equal( element.resizable( "option", "disabled" ), true, "disabled option setter" ); + equal( chainable, element, "disable is chainable" ); +}); })(jQuery); diff --git a/tests/unit/selectable/selectable_methods.js b/tests/unit/selectable/selectable_methods.js index 72f9bb28d..179d4ecd6 100644 --- a/tests/unit/selectable/selectable_methods.js +++ b/tests/unit/selectable/selectable_methods.js @@ -71,34 +71,40 @@ test("enable", function() { equal(actual, expected, "enable is chainable"); }); -test("disable", function() { - expect(3); - var expected, actual, +test( "disable", function() { + expect( 6 ); + var chainable, fired = false, - el = $("#selectable1"); + element = $( "#selectable1" ); - el.selectable({ + element.selectable({ disabled: false, - start: function() { fired = true; } + start: function() { + fired = true; + } }); - el.simulate( "drag", { + element.simulate( "drag", { dx: 20, dy: 20 }); - equal(fired, true, "start fired"); - el.selectable("disable"); + equal( fired, true, "start fired" ); + + chainable = element.selectable( "disable" ); fired = false; - el.simulate( "drag", { + element.simulate( "drag", { dx: 20, dy: 20 }); - equal(fired, false, "start fired"); - el.selectable("destroy"); + equal( fired, false, "start fired" ); - expected = $("<div></div>").selectable(); - actual = expected.selectable("disable"); - equal(actual, expected, "disable is chainable"); + ok( !element.selectable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" ); + ok( !element.selectable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" ); + ok( element.selectable( "widget" ).hasClass( "ui-selectable-disabled" ), "element gets ui-selectable-disabled" ); + + element.selectable( "destroy" ); + + equal( chainable, element, "disable is chainable" ); }); })(jQuery); diff --git a/tests/unit/slider/slider_methods.js b/tests/unit/slider/slider_methods.js index 75df230a6..bd9023133 100644 --- a/tests/unit/slider/slider_methods.js +++ b/tests/unit/slider/slider_methods.js @@ -49,7 +49,7 @@ test( "enable", function() { }); test( "disable", function() { - expect( 5 ); + expect( 6 ); var element, expected = $( "<div></div>" ).slider(), actual = expected.slider( "disable" ); @@ -61,6 +61,7 @@ test( "disable", function() { element.slider( "disable" ); ok( element.hasClass( "ui-state-disabled" ), "slider has ui-state-disabled class after disable method call" ); ok( element.hasClass( "ui-slider-disabled" ), "slider has ui-slider-disabled class after disable method call" ); + ok( !element.attr( "aria-disabled" ), "slider does not have aria-disabled attr after disable method call" ); }); test( "value", function() { diff --git a/tests/unit/slider/slider_options.js b/tests/unit/slider/slider_options.js index f46dbde99..3a6f55390 100644 --- a/tests/unit/slider/slider_options.js +++ b/tests/unit/slider/slider_options.js @@ -185,8 +185,8 @@ test( "values", function() { }); notStrictEqual( - ranges.eq( 0 ).data( "ui-slider" ).options.values, - ranges.eq( 1 ).data( "ui-slider" ).options.values, + ranges.eq( 0 ).slider( "instance" ).options.values, + ranges.eq( 1 ).slider( "instance" ).options.values, "multiple range sliders should not have a reference to the same options.values array" ); diff --git a/tests/unit/sortable/sortable_events.js b/tests/unit/sortable/sortable_events.js index 1b8165acb..46a493b3e 100644 --- a/tests/unit/sortable/sortable_events.js +++ b/tests/unit/sortable/sortable_events.js @@ -231,11 +231,34 @@ test("receive", function() { test("remove", function() { ok(false, "missing test - untested code is broken code."); }); +*/ -test("over", function() { - ok(false, "missing test - untested code is broken code."); +test( "over", function() { + expect( 8 ); + + var hash, + overCount = 0; + + $( "#sortable" ).sortable({ + over: function( e, ui ) { + hash = ui; + overCount++; + } + }).find( "li:eq(0)" ).simulate( "drag", { + dy: 20 + }); + + ok( hash, "stop event triggered" ); + ok( hash.helper, "UI should not include: helper" ); + ok( hash.placeholder, "UI hash includes: placeholder" ); + ok( hash.position && ( "top" in hash.position && "left" in hash.position ), "UI hash includes: position" ); + ok( hash.offset && ( hash.offset.top && hash.offset.left ), "UI hash includes: offset" ); + ok( hash.item, "UI hash includes: item" ); + ok( hash.sender, "UI hash does not include: sender" ); + equal( overCount, 1, "over fires only once" ); }); +/* test("out", function() { ok(false, "missing test - untested code is broken code."); }); diff --git a/tests/unit/sortable/sortable_methods.js b/tests/unit/sortable/sortable_methods.js index 07a7bc77d..f3fe240e7 100644 --- a/tests/unit/sortable/sortable_methods.js +++ b/tests/unit/sortable/sortable_methods.js @@ -64,29 +64,30 @@ test("enable", function() { equal(actual, expected, "enable is chainable"); }); -test("disable", function() { - expect(7); +test( "disable", function() { + expect( 9 ); - var el, actual, expected; + var chainable, + element = $( "#sortable" ).sortable({ disabled: false }); - el = $("#sortable").sortable({ disabled: false }); - TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, ".sortable({ disabled: false })"); + TestHelpers.sortable.sort( $( "li", element )[ 0 ], 0, 44, 2, ".sortable({ disabled: false })" ); - el.sortable("disable"); - TestHelpers.sortable.sort($("li", el)[0], 0, 44, 0, "disabled.sortable getter"); + chainable = element.sortable( "disable" ); + TestHelpers.sortable.sort( $( "li", element )[ 0 ], 0, 44, 0, "disabled.sortable getter" ); - el.sortable("destroy"); + element.sortable( "destroy" ); - el.sortable({ disabled: false }); - TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, ".sortable({ disabled: false })"); - el.sortable("option", "disabled", true); - equal(el.sortable("option", "disabled"), true, "disabled option setter"); - ok(el.sortable("widget").is(":not(.ui-state-disabled)"), "sortable element does not get ui-state-disabled since it's an interaction"); - TestHelpers.sortable.sort($("li", el)[0], 0, 44, 0, ".sortable('option', 'disabled', true)"); + element.sortable({ disabled: false }); + TestHelpers.sortable.sort( $( "li", element )[ 0 ], 0, 44, 2, ".sortable({ disabled: false })" ); + element.sortable( "option", "disabled", true); + equal( element.sortable( "option", "disabled" ), true, "disabled option setter" ); - expected = $("<div></div>").sortable(), - actual = expected.sortable("disable"); - equal(actual, expected, "disable is chainable"); + ok( !element.sortable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" ); + ok( !element.sortable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" ); + ok( element.sortable( "widget" ).hasClass( "ui-sortable-disabled" ), "element gets ui-sortable-disabled" ); + + TestHelpers.sortable.sort($( "li", element )[ 0 ], 0, 44, 0, ".sortable('option', 'disabled', true)" ); + equal( chainable, element, "disable is chainable" ); }); })(jQuery); diff --git a/tests/unit/sortable/sortable_options.js b/tests/unit/sortable/sortable_options.js index caba0a777..8dcf0e82f 100644 --- a/tests/unit/sortable/sortable_options.js +++ b/tests/unit/sortable/sortable_options.js @@ -13,23 +13,100 @@ test("{ appendTo: 'parent' }, default", function() { test("{ appendTo: Selector }", function() { ok(false, "missing test - untested code is broken code."); }); +*/ -test("{ axis: false }, default", function() { - ok(false, "missing test - untested code is broken code."); +test( "{ axis: false }, default", function() { + expect( 2 ); + + var offsetAfter, + element = $( "#sortable" ).sortable({ + axis: false, + change: function() { + offsetAfter = item.offset(); + notEqual( offsetAfter.left, offsetBefore.left, "x axis not constrained when axis: false" ); + notEqual( offsetAfter.top, offsetBefore.top, "y axis not constrained when axis: false" ); + } + }), + item = element.find( "li" ).eq( 0 ), + offsetBefore = item.offset(); + + item.simulate( "drag", { + dx: 50, + dy: 25, + moves: 1 + }); }); -test("{ axis: 'x' }", function() { - ok(false, "missing test - untested code is broken code."); +test( "{ axis: 'x' }", function() { + expect( 2 ); + + var offsetAfter, + element = $( "#sortable" ).sortable({ + axis: "x", + change: function() { + offsetAfter = item.offset(); + notEqual( offsetAfter.left, offsetBefore.left, "x axis not constrained when axis: x" ); + equal( offsetAfter.top, offsetBefore.top, "y axis constrained when axis: x" ); + } + }), + item = element.find( "li" ).eq( 0 ), + offsetBefore = item.offset(); + + item.simulate( "drag", { + dx: 50, + dy: 25, + moves: 1 + }); }); -test("{ axis: 'y' }", function() { - ok(false, "missing test - untested code is broken code."); +test( "{ axis: 'y' }", function() { + expect( 2 ); + + var offsetAfter, + element = $( "#sortable" ).sortable({ + axis: "y", + change: function() { + offsetAfter = item.offset(); + equal( offsetAfter.left, offsetBefore.left, "x axis constrained when axis: y" ); + notEqual( offsetAfter.top, offsetBefore.top, "y axis not constrained when axis: y" ); + } + }), + item = element.find( "li" ).eq( 0 ), + offsetBefore = item.offset(); + + item.simulate( "drag", { + dx: 50, + dy: 25, + moves: 1 + }); }); -test("{ axis: ? }, unexpected", function() { - ok(false, "missing test - untested code is broken code."); +asyncTest( "#7415: Incorrect revert animation with axis: 'y'", function() { + expect( 2 ); + var expectedLeft, + element = $( "#sortable" ).sortable({ + axis: "y", + revert: true, + stop: start, + sort: function() { + expectedLeft = item.css( "left" ); + } + }), + item = element.find( "li" ).eq( 0 ); + + item.simulate( "drag", { + dy: 300, + dx: 50 + }); + + setTimeout(function() { + var top = parseFloat( item.css( "top" ) ); + equal( item.css( "left" ), expectedLeft, "left not animated" ); + ok( top > 0 && top < 300, "top is animated" ); + }, 100 ); }); +/* test("{ cancel: 'input,textarea,button,select,option' }, default", function() { ok(false, "missing test - untested code is broken code."); }); @@ -37,7 +114,44 @@ test("{ cancel: 'input,textarea,button,select,option' }, default", function() { test("{ cancel: Selector }", function() { ok(false, "missing test - untested code is broken code."); }); +*/ + +test( "#8792: issues with floated items in connected lists", function() { + expect( 2 ); + + var element, + changeCount = 0; + $( "#qunit-fixture" ) + .html( "<ul class='c'><li>a</li><li>a</li></ul><ul class='c'><li>a</li><li>a</li></ul>" ) + .find( "ul" ).css({ "float": "left", width: "100px" }).end() + .find( "li" ).css({ "float": "left", width: "50px", height: "50px" }); + + $( "#qunit-fixture .c" ).sortable({ + connectWith: "#qunit-fixture .c", + change: function() { + changeCount++; + } + }); + + element = $( "#qunit-fixture li:eq(0)" ); + + element.simulate( "drag", { + dx: 51, + moves: 15 + }); + + equal( changeCount, 1, "change fired only once (no jitters) when dragging a floated sortable in it's own container" ); + + element.simulate( "drag", { + dx: 50, + moves: 15 + }); + + equal( changeCount, 3, "change fired once for each expected change when dragging a floated sortable to a connected container" ); +}); + +/* test("{ connectWith: false }, default", function() { ok(false, "missing test - untested code is broken code."); }); diff --git a/tests/unit/spinner/spinner_methods.js b/tests/unit/spinner/spinner_methods.js index af872f257..4f44a73ae 100644 --- a/tests/unit/spinner/spinner_methods.js +++ b/tests/unit/spinner/spinner_methods.js @@ -12,7 +12,7 @@ test( "destroy", function() { }); test( "disable", function() { - expect( 14 ); + expect( 16 ); var element = $( "#spin" ).val( 2 ).spinner(), wrapper = $( "#spin" ).spinner( "widget" ); @@ -21,6 +21,8 @@ test( "disable", function() { element.spinner( "disable" ); ok( wrapper.hasClass( "ui-spinner-disabled" ), "after: wrapper has ui-spinner-disabled class" ); + ok( wrapper.hasClass( "ui-state-disabled" ), "after: wrapper has ui-state-disabled class" ); + ok( !wrapper.attr( "aria-disabled" ), "after: wrapper does not have aria-disabled attr" ); ok( element.is( ":disabled"), "after: input has disabled attribute" ); simulateKeyDownUp( element, $.ui.keyCode.UP ); diff --git a/tests/unit/tabs/tabs_core.js b/tests/unit/tabs/tabs_core.js index 5f70206dc..cc4f0460c 100644 --- a/tests/unit/tabs/tabs_core.js +++ b/tests/unit/tabs/tabs_core.js @@ -33,7 +33,7 @@ test( "nested list", function() { expect( 1 ); var element = $( "#tabs6" ).tabs(); - equal( element.data( "ui-tabs" ).anchors.length, 2, "should contain 2 tab" ); + equal( element.tabs( "instance" ).anchors.length, 2, "should contain 2 tab" ); }); test( "disconnected from DOM", function() { @@ -155,7 +155,7 @@ asyncTest( "keyboard support - LEFT, RIGHT, UP, DOWN, HOME, END, SPACE, ENTER", panels = element.find( ".ui-tabs-panel" ), keyCode = $.ui.keyCode; - element.data( "ui-tabs" ).delay = 50; + element.tabs( "instance" ).delay = 50; equal( tabs.filter( ".ui-state-focus" ).length, 0, "no tabs focused on init" ); tabs.eq( 0 ).simulate( "focus" ); @@ -306,7 +306,7 @@ asyncTest( "keyboard support - CTRL navigation", function() { panels = element.find( ".ui-tabs-panel" ), keyCode = $.ui.keyCode; - element.data( "ui-tabs" ).delay = 50; + element.tabs( "instance" ).delay = 50; equal( tabs.filter( ".ui-state-focus" ).length, 0, "no tabs focused on init" ); tabs.eq( 0 ).simulate( "focus" ); diff --git a/tests/unit/tabs/tabs_options.js b/tests/unit/tabs/tabs_options.js index c78c42b58..51212b8f0 100644 --- a/tests/unit/tabs/tabs_options.js +++ b/tests/unit/tabs/tabs_options.js @@ -144,24 +144,40 @@ test( "{ collapsible: true }", function() { }); test( "disabled", function() { - expect( 10 ); + expect( 22 ); // fully enabled by default var element = $( "#tabs1" ).tabs(); disabled( element, false ); + ok( !element.tabs( "widget" ).hasClass( "ui-state-disabled" ), "after: wrapper doesn't have ui-state-disabled class" ); + ok( !element.tabs( "widget" ).hasClass( "ui-tabs-disabled" ), "after: wrapper doesn't have ui-tabs-disabled class" ); + ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" ); + // disable single tab element.tabs( "option", "disabled", [ 1 ] ); disabled( element, [ 1 ] ); + ok( !element.tabs( "widget" ).hasClass( "ui-state-disabled" ), "after: wrapper doesn't have ui-state-disabled class" ); + ok( !element.tabs( "widget" ).hasClass( "ui-tabs-disabled" ), "after: wrapper doesn't have ui-tabs-disabled class" ); + ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" ); + // disabled active tab element.tabs( "option", "disabled", [ 0, 1 ] ); disabled( element, [ 0, 1 ] ); + ok( !element.tabs( "widget" ).hasClass( "ui-state-disabled" ), "after: wrapper doesn't have ui-state-disabled class" ); + ok( !element.tabs( "widget" ).hasClass( "ui-tabs-disabled" ), "after: wrapper doesn't have ui-tabs-disabled class" ); + ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" ); + // disable all tabs element.tabs( "option", "disabled", [ 0, 1, 2 ] ); disabled( element, true ); + ok( !element.tabs( "widget" ).hasClass( "ui-state-disabled" ), "after: wrapper doesn't have ui-state-disabled class" ); + ok( !element.tabs( "widget" ).hasClass( "ui-tabs-disabled" ), "after: wrapper doesn't have ui-tabs-disabled class" ); + ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" ); + // enable all tabs element.tabs( "option", "disabled", [] ); disabled( element, false ); @@ -298,7 +314,7 @@ test( "hide and show: false", function() { show: false, hide: false }), - widget = element.data( "ui-tabs" ), + widget = element.tabs( "instance" ), panels = element.find( ".ui-tabs-panel" ); widget._show = function() { ok( false, "_show() called" ); @@ -319,7 +335,7 @@ asyncTest( "hide and show - animation", function() { show: "drop", hide: 2000 }), - widget = element.data( "ui-tabs" ), + widget = element.tabs( "instance" ), panels = element.find( ".ui-tabs-panel" ); widget._show = function( element, options, callback ) { strictEqual( element[ 0 ], panels[ 1 ], "correct element in _show()" ); diff --git a/tests/unit/tooltip/tooltip_methods.js b/tests/unit/tooltip/tooltip_methods.js index c846d216c..a557ff943 100644 --- a/tests/unit/tooltip/tooltip_methods.js +++ b/tests/unit/tooltip/tooltip_methods.js @@ -54,7 +54,7 @@ test( "open/close with tracking", function() { }); test( "enable/disable", function() { - expect( 7 ); + expect( 10 ); $.fx.off = true; var tooltip, element = $( "#tooltipped1" ).tooltip(); @@ -66,6 +66,11 @@ test( "enable/disable", function() { element.tooltip( "disable" ); equal( $( ".ui-tooltip" ).length, 0, "no tooltip when disabled" ); + + ok( !element.tooltip( "widget" ).hasClass( "ui-state-disabled" ), "element doesn't get ui-state-disabled" ); + ok( !element.tooltip( "widget" ).attr( "aria-disabled" ), "element doesn't get aria-disabled" ); + ok( !element.tooltip( "widget" ).hasClass( "ui-tooltip-disabled" ), "element doesn't get ui-tooltip-disabled" ); + // support: jQuery <1.6.2 // support: IE <8 // We should use strictEqual( ..., undefined ) when dropping jQuery 1.6.1 support (or IE6/7) diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js index 8102b1f4f..0d97742ff 100644 --- a/tests/unit/widget/widget_core.js +++ b/tests/unit/widget/widget_core.js @@ -43,28 +43,28 @@ test( "element normalization", function() { // workaround for core ticket #8381 this.element.appendTo( "#qunit-fixture" ); ok( this.element.is( "div" ), "generated div" ); - deepEqual( this.element.data( "ui-testWidget" ), this, "instance stored in .data()" ); + deepEqual( this.element.testWidget( "instance" ), this, "instance stored in .data()" ); }; $.ui.testWidget(); $.ui.testWidget.prototype.defaultElement = "<span data-test='pass'></span>"; $.ui.testWidget.prototype._create = function() { ok( this.element.is( "span[data-test=pass]" ), "generated span with properties" ); - deepEqual( this.element.data( "ui-testWidget" ), this, "instace stored in .data()" ); + deepEqual( this.element.testWidget( "instance" ), this, "instace stored in .data()" ); }; $.ui.testWidget(); elem = $( "<input>" ); $.ui.testWidget.prototype._create = function() { deepEqual( this.element[ 0 ], elem[ 0 ], "from element" ); - deepEqual( elem.data( "ui-testWidget" ), this, "instace stored in .data()" ); + deepEqual( elem.testWidget( "instance" ), this, "instace stored in .data()" ); }; $.ui.testWidget( {}, elem[ 0 ] ); elem = $( "<div>" ); $.ui.testWidget.prototype._create = function() { deepEqual( this.element[ 0 ], elem[ 0 ], "from jQuery object" ); - deepEqual( elem.data( "ui-testWidget" ), this, "instace stored in .data()" ); + deepEqual( elem.testWidget( "instance" ), this, "instace stored in .data()" ); }; $.ui.testWidget( {}, elem ); @@ -72,7 +72,7 @@ test( "element normalization", function() { .appendTo( "#qunit-fixture" ); $.ui.testWidget.prototype._create = function() { deepEqual( this.element[ 0 ], elem[ 0 ], "from selector" ); - deepEqual( elem.data( "ui-testWidget" ), this, "instace stored in .data()" ); + deepEqual( elem.testWidget( "instance" ), this, "instace stored in .data()" ); }; $.ui.testWidget( {}, "#element-normalization-selector" ); @@ -133,7 +133,7 @@ test( "jQuery usage", function() { .testWidget(); shouldCreate = false; - instance = elem.data( "ui-testWidget" ); + instance = elem.testWidget( "instance" ); equal( typeof instance, "object", "instance stored in .data(pluginName)" ); equal( instance.element[0], elem[0], "element stored on widget" ); ret = elem.testWidget( "methodWithParams", "value1", "value2" ); @@ -149,7 +149,7 @@ test( "jQuery usage", function() { equal( ret.end(), elem, "stack preserved" ); elem.testWidget( "destroy" ); - equal( elem.data( "ui-testWidget" ), null ); + equal( elem.testWidget( "instance" ), null ); }); test( "direct usage", function() { @@ -185,7 +185,7 @@ test( "direct usage", function() { instance = new $.ui.testWidget( {}, elem ); shouldCreate = false; - equal( $( elem ).data( "ui-testWidget" ), instance, + equal( $( elem ).testWidget( "instance" ), instance, "instance stored in .data(pluginName)" ); equal( instance.element[ 0 ], elem, "element stored on widget" ); @@ -405,7 +405,7 @@ test( "._super()", function() { } }); - instance = $( "<div>" ).testWidget3().data( "ui-testWidget3" ); + instance = $( "<div>" ).testWidget3().testWidget3( "instance" ); instance.method( 5 ); delete $.ui.testWidget3; delete $.ui.testWidget2; @@ -442,7 +442,7 @@ test( "._superApply()", function() { } }); - instance = $( "<div>" ).testWidget3().data( "ui-testWidget3" ); + instance = $( "<div>" ).testWidget3().testWidget3( "instance" ); instance.method( 5, 10 ); delete $.ui.testWidget3; delete $.ui.testWidget2; @@ -560,7 +560,7 @@ test( ".option() - deep option setter", function() { $.widget( "ui.testWidget", {} ); var div = $( "<div>" ).testWidget(); function deepOption( from, to, msg ) { - div.data( "ui-testWidget" ).options.foo = from; + div.testWidget( "instance" ).options.foo = from; $.ui.testWidget.prototype._setOption = function( key, value ) { deepEqual( key, "foo", msg + ": key" ); deepEqual( value, to, msg + ": value" ); @@ -625,6 +625,20 @@ test( ".widget() - overriden", function() { deepEqual( wrapper[0], $( "<div>" ).testWidget().testWidget( "widget" )[0] ); }); +test( ".instance()", function() { + expect( 2 ); + var div; + + $.widget( "ui.testWidget", { + _create: function() {} + }); + + div = $( "<div>" ); + equal( div.testWidget( "instance" ), undefined ); + div.testWidget(); + equal( div.testWidget( "instance" ), div.testWidget( "instance" ) ); +}); + test( "._on() to element (default)", function() { expect( 12 ); var that, widget; @@ -840,7 +854,7 @@ test( "_on() to common element", function() { ok( true, "handler triggered" ); } }); - var widget = $( "#widget" ).testWidget().data( "ui-testWidget" ); + var widget = $( "#widget" ).testWidget().testWidget( "instance" ); $( "#widget-wrapper" ).testWidget(); widget.destroy(); $( document ).trigger( "customevent" ); @@ -852,7 +866,7 @@ test( "_off() - single event", function() { $.widget( "ui.testWidget", {} ); var shouldTriggerWidget, shouldTriggerOther, element = $( "#widget" ), - widget = element.testWidget().data( "ui-testWidget" ); + widget = element.testWidget().testWidget( "instance" ); widget._on( element, { foo: function() { ok( shouldTriggerWidget, "foo called from _on" ); }}); @@ -873,7 +887,7 @@ test( "_off() - multiple events", function() { $.widget( "ui.testWidget", {} ); var shouldTriggerWidget, shouldTriggerOther, element = $( "#widget" ), - widget = element.testWidget().data( "ui-testWidget" ); + widget = element.testWidget().testWidget( "instance" ); widget._on( element, { foo: function() { ok( shouldTriggerWidget, "foo called from _on" ); @@ -901,7 +915,7 @@ test( "_off() - all events", function() { $.widget( "ui.testWidget", {} ); var shouldTriggerWidget, shouldTriggerOther, element = $( "#widget" ), - widget = element.testWidget().data( "ui-testWidget" ); + widget = element.testWidget().testWidget( "instance" ); widget._on( element, { foo: function() { ok( shouldTriggerWidget, "foo called from _on" ); @@ -1007,7 +1021,7 @@ test( "._trigger() - no event, no ui", function() { deepEqual( ui, {}, "empty ui hash passed" ); handlers.push( this ); }); - deepEqual( $( "#widget" ).data( "ui-testWidget" )._trigger( "foo" ), true, + deepEqual( $( "#widget" ).testWidget( "instance" )._trigger( "foo" ), true, "_trigger returns true when event is not cancelled" ); deepEqual( handlers, [ $( "#widget" )[ 0 ], @@ -1035,7 +1049,7 @@ test( "._trigger() - cancelled event", function() { ok( true, "event was triggered" ); return false; }); - deepEqual( $( "#widget" ).data( "ui-testWidget" )._trigger( "foo" ), false, + deepEqual( $( "#widget" ).testWidget( "instance" )._trigger( "foo" ), false, "_trigger returns false when event is cancelled" ); }); @@ -1050,7 +1064,7 @@ test( "._trigger() - cancelled callback", function() { return false; } }); - deepEqual( $( "#widget" ).data( "ui-testWidget" )._trigger( "foo" ), false, + deepEqual( $( "#widget" ).testWidget( "instance" )._trigger( "foo" ), false, "_trigger returns false when callback returns false" ); }); @@ -1384,7 +1398,7 @@ asyncTest( "_delay", function() { }); test( "$.widget.bridge()", function() { - expect( 9 ); + expect( 10 ); var instance, ret, elem = $( "<div>" ); @@ -1412,6 +1426,7 @@ test( "$.widget.bridge()", function() { strictEqual( elem.testWidget({ foo: "bar" }), elem, "plugin returns original jQuery object" ); instance = elem.data( "testWidget" ); equal( typeof instance, "object", "instance stored in .data(pluginName)" ); + equal( typeof elem.testWidget( "instance" ), "object", "also retrievable via instance method" ); ret = elem.testWidget( "method", "value1" ); equal( ret, elem, "jQuery object returned from method call" ); diff --git a/themes/base/jquery.ui.theme.css b/themes/base/jquery.ui.theme.css index c606011f0..fd586d90b 100644 --- a/themes/base/jquery.ui.theme.css +++ b/themes/base/jquery.ui.theme.css @@ -156,7 +156,6 @@ .ui-icon { width: 16px; height: 16px; - background-position: 16px 16px; } .ui-icon, .ui-widget-content .ui-icon { @@ -184,6 +183,7 @@ } /* positioning */ +.ui-icon-blank { background-position: 16px 16px; } .ui-icon-carat-1-n { background-position: 0 0; } .ui-icon-carat-1-ne { background-position: -16px 0; } .ui-icon-carat-1-e { background-position: -32px 0; } diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index 1afa95cb4..c210a29a9 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -65,8 +65,7 @@ $.widget( "ui.accordion", { _getCreateEventData: function() { return { header: this.active, - panel: !this.active.length ? $() : this.active.next(), - content: !this.active.length ? $() : this.active.next() + panel: !this.active.length ? $() : this.active.next() }; }, @@ -161,6 +160,9 @@ $.widget( "ui.accordion", { // #5332 - opacity doesn't cascade to positioned elements in IE // so we need to add the disabled class to the headers and panels if ( key === "disabled" ) { + this.element + .toggleClass( "ui-state-disabled", !!value ) + .attr( "aria-disabled", value ); this.headers.add( this.headers.next() ) .toggleClass( "ui-state-disabled", !!value ); } diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index b3a05da0b..92ddc3a12 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -201,7 +201,7 @@ $.widget( "ui.autocomplete", { role: null }) .hide() - .data( "ui-menu" ); + .menu( "instance" ); this._on( this.menu.element, { mousedown: function( event ) { diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js index fcb7b14d1..5e64f5164 100644 --- a/ui/jquery.ui.button.js +++ b/ui/jquery.ui.button.js @@ -207,9 +207,6 @@ $.widget( "ui.button", { } } - // TODO: pull out $.Widget's handling for the disabled option into - // $.Widget.prototype._setOptionDisabled so it's easy to proxy and can - // be overridden by individual plugins this._setOption( "disabled", options.disabled ); this._resetButton(); }, @@ -273,11 +270,8 @@ $.widget( "ui.button", { _setOption: function( key, value ) { this._super( key, value ); if ( key === "disabled" ) { - if ( value ) { - this.element.prop( "disabled", true ); - } else { - this.element.prop( "disabled", false ); - } + this.widget().toggleClass( "ui-state-disabled", !!value ); + this.element.prop( "disabled", !!value ); return; } this._resetButton(); diff --git a/ui/jquery.ui.core.js b/ui/jquery.ui.core.js index d224f181a..0d263fa5f 100644 --- a/ui/jquery.ui.core.js +++ b/ui/jquery.ui.core.js @@ -13,13 +13,8 @@ var uuid = 0, runiqueId = /^ui-id-\d+$/; -// prevent duplicate loading -// this is only a problem because we proxy existing functions -// and we don't want to double proxy them +// $.ui might exist from components with no dependencies, e.g., $.ui.position $.ui = $.ui || {}; -if ( $.ui.version ) { - return; -} $.extend( $.ui, { version: "@VERSION", @@ -52,20 +47,21 @@ $.extend( $.ui, { // plugins $.fn.extend({ - _focus: $.fn.focus, - focus: function( delay, fn ) { - return typeof delay === "number" ? - this.each(function() { - var elem = this; - setTimeout(function() { - $( elem ).focus(); - if ( fn ) { - fn.call( elem ); - } - }, delay ); - }) : - this._focus.apply( this, arguments ); - }, + focus: (function( orig ) { + return function( delay, fn ) { + return typeof delay === "number" ? + this.each(function() { + var elem = this; + setTimeout(function() { + $( elem ).focus(); + if ( fn ) { + fn.call( elem ); + } + }, delay ); + }) : + orig.apply( this, arguments ); + }; + })( $.fn.focus ), scrollParent: function() { var scrollParent; @@ -82,35 +78,6 @@ $.fn.extend({ return (/fixed/).test(this.css("position")) || !scrollParent.length ? $(document) : scrollParent; }, - zIndex: function( zIndex ) { - if ( zIndex !== undefined ) { - return this.css( "zIndex", zIndex ); - } - - if ( this.length ) { - var elem = $( this[ 0 ] ), position, value; - while ( elem.length && elem[ 0 ] !== document ) { - // Ignore z-index if position is set to a value where z-index is ignored by the browser - // This makes behavior of this function consistent across browsers - // WebKit always returns auto if the element is positioned - position = elem.css( "position" ); - if ( position === "absolute" || position === "relative" || position === "fixed" ) { - // IE returns 0 when zIndex is not specified - // other browsers return a string - // we ignore the case of nested elements with an explicit value of 0 - // <div style="z-index: -10;"><div style="z-index: 0;"></div></div> - value = parseInt( elem.css( "zIndex" ), 10 ); - if ( !isNaN( value ) && value !== 0 ) { - return value; - } - } - elem = elem.parent(); - } - } - - return 0; - }, - uniqueId: function() { return this.each(function() { if ( !this.id ) { @@ -267,6 +234,35 @@ $.fn.extend({ enableSelection: function() { return this.unbind( ".ui-disableSelection" ); + }, + + zIndex: function( zIndex ) { + if ( zIndex !== undefined ) { + return this.css( "zIndex", zIndex ); + } + + if ( this.length ) { + var elem = $( this[ 0 ] ), position, value; + while ( elem.length && elem[ 0 ] !== document ) { + // Ignore z-index if position is set to a value where z-index is ignored by the browser + // This makes behavior of this function consistent across browsers + // WebKit always returns auto if the element is positioned + position = elem.css( "position" ); + if ( position === "absolute" || position === "relative" || position === "fixed" ) { + // IE returns 0 when zIndex is not specified + // other browsers return a string + // we ignore the case of nested elements with an explicit value of 0 + // <div style="z-index: -10;"><div style="z-index: 0;"></div></div> + value = parseInt( elem.css( "zIndex" ), 10 ); + if ( !isNaN( value ) && value !== 0 ) { + return value; + } + } + elem = elem.parent(); + } + } + + return 0; } }); diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js index efee7a819..5892e2ddc 100644 --- a/ui/jquery.ui.datepicker.js +++ b/ui/jquery.ui.datepicker.js @@ -19,6 +19,28 @@ var PROP_NAME = "datepicker", dpuuid = new Date().getTime(), instActive; +function getZindex( elem ) { + var position, value; + while ( elem.length && elem[ 0 ] !== document ) { + // Ignore z-index if position is set to a value where z-index is ignored by the browser + // This makes behavior of this function consistent across browsers + // WebKit always returns auto if the element is positioned + position = elem.css( "position" ); + if ( position === "absolute" || position === "relative" || position === "fixed" ) { + // IE returns 0 when zIndex is not specified + // other browsers return a string + // we ignore the case of nested elements with an explicit value of 0 + // <div style="z-index: -10;"><div style="z-index: 0;"></div></div> + value = parseInt( elem.css( "zIndex" ), 10 ); + if ( !isNaN( value ) && value !== 0 ) { + return value; + } + } + elem = elem.parent(); + } + + return 0; +} /* Date picker manager. Use the singleton instance of this class, $.datepicker, to interact with the date picker. Settings for (groups of) date pickers are maintained in an instance object, @@ -744,7 +766,7 @@ $.extend(Datepicker.prototype, { if (!inst.inline) { showAnim = $.datepicker._get(inst, "showAnim"); duration = $.datepicker._get(inst, "duration"); - inst.dpDiv.zIndex($(input).zIndex()+1); + inst.dpDiv.css( "z-index", getZindex( $( input ) ) + 1 ); $.datepicker._datepickerShowing = true; if ( $.effects && $.effects.effect[ showAnim ] ) { diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index b35c0ffcf..59a7961ed 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -755,54 +755,4 @@ $.widget( "ui.dialog", { $.ui.dialog.overlayInstances = 0; -// DEPRECATED -if ( $.uiBackCompat !== false ) { - // position option with array notation - // just override with old implementation - $.widget( "ui.dialog", $.ui.dialog, { - _position: function() { - var position = this.options.position, - myAt = [], - offset = [ 0, 0 ], - isVisible; - - if ( position ) { - if ( typeof position === "string" || (typeof position === "object" && "0" in position ) ) { - myAt = position.split ? position.split(" ") : [ position[0], position[1] ]; - if ( myAt.length === 1 ) { - myAt[1] = myAt[0]; - } - - $.each( [ "left", "top" ], function( i, offsetPosition ) { - if ( +myAt[ i ] === myAt[ i ] ) { - offset[ i ] = myAt[ i ]; - myAt[ i ] = offsetPosition; - } - }); - - position = { - my: myAt[0] + (offset[0] < 0 ? offset[0] : "+" + offset[0]) + " " + - myAt[1] + (offset[1] < 0 ? offset[1] : "+" + offset[1]), - at: myAt.join(" ") - }; - } - - position = $.extend( {}, $.ui.dialog.prototype.options.position, position ); - } else { - position = $.ui.dialog.prototype.options.position; - } - - // need to show the dialog to get the actual offset in the position plugin - isVisible = this.uiDialog.is(":visible"); - if ( !isVisible ) { - this.uiDialog.show(); - } - this.uiDialog.position( position ); - if ( !isVisible ) { - this.uiDialog.hide(); - } - } - }); -} - }( jQuery ) ); diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index 7c1fb3361..e5fc069b9 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -135,6 +135,9 @@ $.widget("ui.draggable", $.ui.mouse, { left: this.offset.left - this.margins.left }; + //Reset scroll cache + this.offset.scroll = false; + $.extend(this.offset, { click: { //Where the click happened, relative to the element left: event.pageX - this.offset.left, @@ -214,9 +217,7 @@ $.widget("ui.draggable", $.ui.mouse, { _mouseStop: function(event) { //If we are using droppables, inform the manager about the drop - var element, - that = this, - elementInDom = false, + var that = this, dropped = false; if ($.ui.ddmanager && !this.options.dropBehaviour) { dropped = $.ui.ddmanager.drop(this, event); @@ -229,13 +230,7 @@ $.widget("ui.draggable", $.ui.mouse, { } //if the original element is no longer in the DOM don't bother to continue (see #8269) - element = this.element[0]; - while ( element && (element = element.parentNode) ) { - if (element === document ) { - elementInDom = true; - } - } - if ( !elementInDom && this.options.helper === "original" ) { + if ( this.options.helper === "original" && !$.contains( this.element[ 0 ].ownerDocument, this.element[ 0 ] ) ) { return false; } @@ -281,17 +276,9 @@ $.widget("ui.draggable", $.ui.mouse, { }, _getHandle: function(event) { - - var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false; - - this.element.find( this.options.handle ).each(function() { - if(this === event.target) { - handle = true; - } - }); - - return handle; - + return this.options.handle ? + !!$( event.target ).closest( this.element.find( this.options.handle ) ).length : + true; }, _createHelper: function(event) { @@ -421,8 +408,8 @@ $.widget("ui.draggable", $.ui.mouse, { this.containment = [ (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0), (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0), - (over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left - this.margins.right, - (over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top - this.margins.bottom + (over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderRightWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left - this.margins.right, + (over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderBottomWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top - this.margins.bottom ]; this.relative_container = c; @@ -441,18 +428,23 @@ $.widget("ui.draggable", $.ui.mouse, { var mod = d === "absolute" ? 1 : -1, scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); + //Cache the scroll + if (!this.offset.scroll) { + this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()}; + } + return { top: ( pos.top + // The absolute mouse position this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border) - ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod) + ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod) ), left: ( pos.left + // The absolute mouse position this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border) - ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod) + ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : this.offset.scroll.left ) * mod) ) }; @@ -467,6 +459,11 @@ $.widget("ui.draggable", $.ui.mouse, { pageX = event.pageX, pageY = event.pageY; + //Cache the scroll + if (!this.offset.scroll) { + this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()}; + } + /* * - Position constraining - * Constrain the position to a mix of grid, containment. @@ -516,14 +513,14 @@ $.widget("ui.draggable", $.ui.mouse, { this.offset.click.top - // Click offset (relative to the element) this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent this.offset.parent.top + // The offsetParent's offset without borders (offset + border) - ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) )) + ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) )) ), left: ( pageX - // The absolute mouse position this.offset.click.left - // Click offset (relative to the element) this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent this.offset.parent.left + // The offsetParent's offset without borders (offset + border) - ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() )) + ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : this.offset.scroll.left )) ) }; @@ -566,11 +563,11 @@ $.widget("ui.draggable", $.ui.mouse, { $.ui.plugin.add("draggable", "connectToSortable", { start: function(event, ui) { - var inst = $(this).data("ui-draggable"), o = inst.options, + var inst = $(this).draggable( "instance" ), o = inst.options, uiSortable = $.extend({}, ui, { item: inst.element }); inst.sortables = []; $(o.connectToSortable).each(function() { - var sortable = $.data(this, "ui-sortable"); + var sortable = $( this ).sortable( "instance" ); if (sortable && !sortable.options.disabled) { inst.sortables.push({ instance: sortable, @@ -585,7 +582,7 @@ $.ui.plugin.add("draggable", "connectToSortable", { stop: function(event, ui) { //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper - var inst = $(this).data("ui-draggable"), + var inst = $(this).draggable( "instance" ), uiSortable = $.extend({}, ui, { item: inst.element }); $.each(inst.sortables, function() { @@ -621,7 +618,7 @@ $.ui.plugin.add("draggable", "connectToSortable", { }, drag: function(event, ui) { - var inst = $(this).data("ui-draggable"), that = this; + var inst = $(this).draggable( "instance" ), that = this; $.each(inst.sortables, function() { @@ -722,14 +719,14 @@ $.ui.plugin.add("draggable", "connectToSortable", { $.ui.plugin.add("draggable", "cursor", { start: function() { - var t = $("body"), o = $(this).data("ui-draggable").options; + var t = $("body"), o = $(this).draggable( "instance" ).options; if (t.css("cursor")) { o._cursor = t.css("cursor"); } t.css("cursor", o.cursor); }, stop: function() { - var o = $(this).data("ui-draggable").options; + var o = $(this).draggable( "instance" ).options; if (o._cursor) { $("body").css("cursor", o._cursor); } @@ -738,14 +735,14 @@ $.ui.plugin.add("draggable", "cursor", { $.ui.plugin.add("draggable", "opacity", { start: function(event, ui) { - var t = $(ui.helper), o = $(this).data("ui-draggable").options; + var t = $(ui.helper), o = $(this).draggable( "instance" ).options; if(t.css("opacity")) { o._opacity = t.css("opacity"); } t.css("opacity", o.opacity); }, stop: function(event, ui) { - var o = $(this).data("ui-draggable").options; + var o = $(this).draggable( "instance" ).options; if(o._opacity) { $(ui.helper).css("opacity", o._opacity); } @@ -754,14 +751,14 @@ $.ui.plugin.add("draggable", "opacity", { $.ui.plugin.add("draggable", "scroll", { start: function() { - var i = $(this).data("ui-draggable"); + var i = $(this).draggable( "instance" ); if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") { i.overflowOffset = i.scrollParent.offset(); } }, drag: function( event ) { - var i = $(this).data("ui-draggable"), o = i.options, scrolled = false; + var i = $(this).draggable( "instance" ), o = i.options, scrolled = false; if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") { @@ -811,7 +808,7 @@ $.ui.plugin.add("draggable", "scroll", { $.ui.plugin.add("draggable", "snap", { start: function() { - var i = $(this).data("ui-draggable"), + var i = $(this).draggable( "instance" ), o = i.options; i.snapElements = []; @@ -832,7 +829,7 @@ $.ui.plugin.add("draggable", "snap", { drag: function(event, ui) { var ts, bs, ls, rs, l, r, t, b, i, first, - inst = $(this).data("ui-draggable"), + inst = $(this).draggable( "instance" ), o = inst.options, d = o.snapTolerance, x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width, @@ -845,8 +842,7 @@ $.ui.plugin.add("draggable", "snap", { t = inst.snapElements[i].top; b = t + inst.snapElements[i].height; - //Yes, I know, this is insane ;) - if(!((l-d < x1 && x1 < r+d && t-d < y1 && y1 < b+d) || (l-d < x1 && x1 < r+d && t-d < y2 && y2 < b+d) || (l-d < x2 && x2 < r+d && t-d < y1 && y1 < b+d) || (l-d < x2 && x2 < r+d && t-d < y2 && y2 < b+d))) { + if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) { if(inst.snapElements[i].snapping) { (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item }))); } @@ -907,7 +903,7 @@ $.ui.plugin.add("draggable", "snap", { $.ui.plugin.add("draggable", "stack", { start: function() { var min, - o = this.data("ui-draggable").options, + o = $(this).draggable( "instance" ).options, group = $.makeArray($(o.stack)).sort(function(a,b) { return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0); }); @@ -924,14 +920,14 @@ $.ui.plugin.add("draggable", "stack", { $.ui.plugin.add("draggable", "zIndex", { start: function(event, ui) { - var t = $(ui.helper), o = $(this).data("ui-draggable").options; + var t = $(ui.helper), o = $(this).draggable( "instance" ).options; if(t.css("zIndex")) { o._zIndex = t.css("zIndex"); } t.css("zIndex", o.zIndex); }, stop: function(event, ui) { - var o = $(this).data("ui-draggable").options; + var o = $(this).draggable( "instance" ).options; if(o._zIndex) { $(ui.helper).css("zIndex", o._zIndex); } diff --git a/ui/jquery.ui.droppable.js b/ui/jquery.ui.droppable.js index 552b24a58..6bc4b594d 100644 --- a/ui/jquery.ui.droppable.js +++ b/ui/jquery.ui.droppable.js @@ -82,7 +82,7 @@ $.widget("ui.droppable", { return d.is(value); }; } - $.Widget.prototype._setOption.apply(this, arguments); + this._super( key, value ); }, _activate: function(event) { @@ -152,7 +152,7 @@ $.widget("ui.droppable", { } this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function() { - var inst = $.data(this, "ui-droppable"); + var inst = $( this ).droppable( "instance" ); if( inst.options.greedy && !inst.options.disabled && @@ -331,11 +331,11 @@ $.ui.ddmanager = { // find droppable parents with same scope scope = this.options.scope; parent = this.element.parents(":data(ui-droppable)").filter(function () { - return $.data(this, "ui-droppable").options.scope === scope; + return $(this).droppable( "instance" ).options.scope === scope; }); if (parent.length) { - parentInstance = $.data(parent[0], "ui-droppable"); + parentInstance = $( parent[ 0 ] ).droppable( "instance" ); parentInstance.greedyChild = (c === "isover"); } } diff --git a/ui/jquery.ui.effect.js b/ui/jquery.ui.effect.js index f3d9929b0..3d65b40c7 100644 --- a/ui/jquery.ui.effect.js +++ b/ui/jquery.ui.effect.js @@ -8,7 +8,7 @@ * * http://api.jqueryui.com/category/effects-core/ */ -;(jQuery.effects || (function($, undefined) { +(function($, undefined) { var dataSpace = "ui-effects-"; @@ -839,39 +839,42 @@ $.effects.animateClass = function( value, duration, easing, callback ) { }; $.fn.extend({ - _addClass: $.fn.addClass, - addClass: function( classNames, speed, easing, callback ) { - return speed ? - $.effects.animateClass.call( this, - { add: classNames }, speed, easing, callback ) : - this._addClass( classNames ); - }, - - _removeClass: $.fn.removeClass, - removeClass: function( classNames, speed, easing, callback ) { - return arguments.length > 1 ? - $.effects.animateClass.call( this, - { remove: classNames }, speed, easing, callback ) : - this._removeClass.apply( this, arguments ); - }, - - _toggleClass: $.fn.toggleClass, - toggleClass: function( classNames, force, speed, easing, callback ) { - if ( typeof force === "boolean" || force === undefined ) { - if ( !speed ) { - // without speed parameter - return this._toggleClass( classNames, force ); + addClass: (function( orig ) { + return function( classNames, speed, easing, callback ) { + return speed ? + $.effects.animateClass.call( this, + { add: classNames }, speed, easing, callback ) : + orig.apply( this, arguments ); + }; + })( $.fn.addClass ), + + removeClass: (function( orig ) { + return function( classNames, speed, easing, callback ) { + return arguments.length > 1 ? + $.effects.animateClass.call( this, + { remove: classNames }, speed, easing, callback ) : + orig.apply( this, arguments ); + }; + })( $.fn.removeClass ), + + toggleClass: (function( orig ) { + return function( classNames, force, speed, easing, callback ) { + if ( typeof force === "boolean" || force === undefined ) { + if ( !speed ) { + // without speed parameter + return orig.apply( this, arguments ); + } else { + return $.effects.animateClass.call( this, + (force ? { add: classNames } : { remove: classNames }), + speed, easing, callback ); + } } else { + // without force parameter return $.effects.animateClass.call( this, - (force ? { add: classNames } : { remove: classNames }), - speed, easing, callback ); + { toggle: classNames }, force, speed, easing ); } - } else { - // without force parameter - return $.effects.animateClass.call( this, - { toggle: classNames }, force, speed, easing ); - } - }, + }; + })( $.fn.toggleClass ), switchClass: function( remove, add, speed, easing, callback) { return $.effects.animateClass.call( this, { @@ -1283,4 +1286,4 @@ $.each( baseEasings, function( name, easeIn ) { })(); -})(jQuery)); +})(jQuery); diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js index 1c633786d..bdef93248 100644 --- a/ui/jquery.ui.menu.js +++ b/ui/jquery.ui.menu.js @@ -350,6 +350,11 @@ $.widget( "ui.menu", { .removeClass( this.options.icons.submenu ) .addClass( value.submenu ); } + if ( key === "disabled" ) { + this.element + .toggleClass( "ui-state-disabled", !!value ) + .attr( "aria-disabled", value ); + } this._super( key, value ); }, diff --git a/ui/jquery.ui.progressbar.js b/ui/jquery.ui.progressbar.js index 9e959ebc4..0eaa8b41e 100644 --- a/ui/jquery.ui.progressbar.js +++ b/ui/jquery.ui.progressbar.js @@ -97,7 +97,11 @@ $.widget( "ui.progressbar", { // Don't allow a max less than min value = Math.max( this.min, value ); } - + if ( key === "disabled" ) { + this.element + .toggleClass( "ui-state-disabled", !!value ) + .attr( "aria-disabled", value ); + } this._super( key, value ); }, diff --git a/ui/jquery.ui.resizable.js b/ui/jquery.ui.resizable.js index 2468dcaa6..761ea058b 100644 --- a/ui/jquery.ui.resizable.js +++ b/ui/jquery.ui.resizable.js @@ -81,7 +81,7 @@ $.widget("ui.resizable", $.ui.mouse, { //Overwrite the original this.element this.element = this.element.parent().data( - "ui-resizable", this.element.data("ui-resizable") + "ui-resizable", this.element.resizable( "instance" ) ); this.elementIsWrapper = true; @@ -651,7 +651,7 @@ $.widget("ui.resizable", $.ui.mouse, { $.ui.plugin.add("resizable", "animate", { stop: function( event ) { - var that = $(this).data("ui-resizable"), + var that = $(this).resizable( "instance" ), o = that.options, pr = that._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName), @@ -693,7 +693,7 @@ $.ui.plugin.add("resizable", "containment", { start: function() { var element, p, co, ch, cw, width, height, - that = $(this).data("ui-resizable"), + that = $(this).resizable( "instance" ), o = that.options, el = that.element, oc = o.containment, @@ -739,7 +739,7 @@ $.ui.plugin.add("resizable", "containment", { resize: function( event ) { var woset, hoset, isParent, isOffsetRelative, - that = $(this).data("ui-resizable"), + that = $(this).resizable( "instance" ), o = that.options, co = that.containerOffset, cp = that.position, pRatio = that._aspectRatio || event.shiftKey, @@ -794,7 +794,7 @@ $.ui.plugin.add("resizable", "containment", { }, stop: function(){ - var that = $(this).data("ui-resizable"), + var that = $(this).resizable( "instance" ), o = that.options, co = that.containerOffset, cop = that.containerPosition, @@ -818,7 +818,7 @@ $.ui.plugin.add("resizable", "containment", { $.ui.plugin.add("resizable", "alsoResize", { start: function () { - var that = $(this).data("ui-resizable"), + var that = $(this).resizable( "instance" ), o = that.options, _store = function (exp) { $(exp).each(function() { @@ -839,7 +839,7 @@ $.ui.plugin.add("resizable", "alsoResize", { }, resize: function (event, ui) { - var that = $(this).data("ui-resizable"), + var that = $(this).resizable( "instance" ), o = that.options, os = that.originalSize, op = that.originalPosition, @@ -880,7 +880,7 @@ $.ui.plugin.add("resizable", "ghost", { start: function() { - var that = $(this).data("ui-resizable"), o = that.options, cs = that.size; + var that = $(this).resizable( "instance" ), o = that.options, cs = that.size; that.ghost = that.originalElement.clone(); that.ghost @@ -893,14 +893,14 @@ $.ui.plugin.add("resizable", "ghost", { }, resize: function(){ - var that = $(this).data("ui-resizable"); + var that = $(this).resizable( "instance" ); if (that.ghost) { that.ghost.css({ position: "relative", height: that.size.height, width: that.size.width }); } }, stop: function() { - var that = $(this).data("ui-resizable"); + var that = $(this).resizable( "instance" ); if (that.ghost && that.helper) { that.helper.get(0).removeChild(that.ghost.get(0)); } @@ -911,7 +911,7 @@ $.ui.plugin.add("resizable", "ghost", { $.ui.plugin.add("resizable", "grid", { resize: function() { - var that = $(this).data("ui-resizable"), + var that = $(this).resizable( "instance" ), o = that.options, cs = that.size, os = that.originalSize, diff --git a/ui/jquery.ui.slider.js b/ui/jquery.ui.slider.js index b3e609aa2..88281240d 100644 --- a/ui/jquery.ui.slider.js +++ b/ui/jquery.ui.slider.js @@ -427,7 +427,11 @@ $.widget( "ui.slider", $.ui.mouse, { valsLength = this.options.values.length; } - $.Widget.prototype._setOption.apply( this, arguments ); + if ( key === "disabled" ) { + this.element.toggleClass( "ui-state-disabled", !!value ); + } + + this._super( key, value ); switch ( key ) { case "orientation": diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index 93c6cccc5..642d5d947 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -21,6 +21,10 @@ function isOverAxis( x, reference, size ) { return ( x > reference ) && ( x < ( reference + size ) ); } +function isFloating(item) { + return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display")); +} + $.widget("ui.sortable", $.ui.mouse, { version: "@VERSION", widgetEventPrefix: "sort", @@ -73,7 +77,7 @@ $.widget("ui.sortable", $.ui.mouse, { this.refresh(); //Let's determine if the items are being displayed horizontally - this.floating = this.items.length ? o.axis === "x" || (/left|right/).test(this.items[0].item.css("float")) || (/inline|table-cell/).test(this.items[0].item.css("display")) : false; + this.floating = this.items.length ? o.axis === "x" || isFloating(this.items[0].item) : false; //Let's determine the parent's offset this.offset = this.element.offset(); @@ -98,17 +102,6 @@ $.widget("ui.sortable", $.ui.mouse, { return this; }, - _setOption: function(key, value){ - if ( key === "disabled" ) { - this.options[ key ] = value; - - this.widget().toggleClass( "ui-sortable-disabled", !!value ); - } else { - // Don't call widget base _setOption for disable as it adds ui-state-disabled class - $.Widget.prototype._setOption.apply(this, arguments); - } - }, - _mouseCapture: function(event, overrideHandle) { var currentItem = null, validHandle = false, @@ -424,14 +417,18 @@ $.widget("ui.sortable", $.ui.mouse, { if(this.options.revert) { var that = this, - cur = this.placeholder.offset(); + cur = this.placeholder.offset(), + axis = this.options.axis, + animation = {}; + if ( !axis || axis === "x" ) { + animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft); + } + if ( !axis || axis === "y" ) { + animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop); + } this.reverting = true; - - $(this.helper).animate({ - left: cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft), - top: cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop) - }, parseInt(this.options.revert, 10) || 500, function() { + $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() { that._clear(event); }); } else { @@ -799,7 +796,7 @@ $.widget("ui.sortable", $.ui.mouse, { }, _contactContainers: function(event) { - var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, base, cur, nearBottom, + var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, base, cur, nearBottom, floating, innermostContainer = null, innermostIndex = null; @@ -838,15 +835,18 @@ $.widget("ui.sortable", $.ui.mouse, { // move the item into the container if it's not there already if(this.containers.length === 1) { - this.containers[innermostIndex]._trigger("over", event, this._uiHash(this)); - this.containers[innermostIndex].containerCache.over = 1; + if (!this.containers[innermostIndex].containerCache.over) { + this.containers[innermostIndex]._trigger("over", event, this._uiHash(this)); + this.containers[innermostIndex].containerCache.over = 1; + } } else { //When entering a new container, we will find the item with the least distance and append our item near it dist = 10000; itemWithLeastDistance = null; - posProperty = this.containers[innermostIndex].floating ? "left" : "top"; - sizeProperty = this.containers[innermostIndex].floating ? "width" : "height"; + floating = innermostContainer.floating || isFloating(this.currentItem); + posProperty = floating ? "left" : "top"; + sizeProperty = floating ? "width" : "height"; base = this.positionAbs[posProperty] + this.offset.click[posProperty]; for (j = this.items.length - 1; j >= 0; j--) { if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) { @@ -855,6 +855,9 @@ $.widget("ui.sortable", $.ui.mouse, { if(this.items[j].item[0] === this.currentItem[0]) { continue; } + if (floating && !isOverAxis(this.positionAbs.top + this.offset.click.top, this.items[j].top, this.items[j].height)) { + continue; + } cur = this.items[j].item.offset()[posProperty]; nearBottom = false; if(Math.abs(cur - base) > Math.abs(cur + this.items[j][sizeProperty] - base)){ @@ -873,10 +876,14 @@ $.widget("ui.sortable", $.ui.mouse, { return; } - this.currentContainer = this.containers[innermostIndex]; + if(this.currentContainer === this.containers[innermostIndex]) { + return; + } + itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true); this._trigger("change", event, this._uiHash()); this.containers[innermostIndex]._trigger("change", event, this._uiHash(this)); + this.currentContainer = this.containers[innermostIndex]; //Update the placeholder this.options.placeholder.update(this.currentContainer, this.placeholder); diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js index 644b65239..c022413dc 100644 --- a/ui/jquery.ui.spinner.js +++ b/ui/jquery.ui.spinner.js @@ -381,13 +381,9 @@ $.widget( "ui.spinner", { this._super( key, value ); if ( key === "disabled" ) { - if ( value ) { - this.element.prop( "disabled", true ); - this.buttons.button( "disable" ); - } else { - this.element.prop( "disabled", false ); - this.buttons.button( "enable" ); - } + this.widget().toggleClass( "ui-state-disabled", !!value ); + this.element.prop( "disabled", !!value ); + this.buttons.button( value ? "disable" : "enable" ); } }, diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index c581e4b81..741ac74d7 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -178,6 +178,10 @@ $.widget.bridge = function( name, object ) { this.each(function() { var methodValue, instance = $.data( this, fullName ); + if ( options === "instance" ) { + returnValue = instance; + return false; + } if ( !instance ) { return $.error( "cannot call methods on " + name + " prior to initialization; " + "attempted to call method '" + options + "'" ); @@ -345,8 +349,7 @@ $.Widget.prototype = { if ( key === "disabled" ) { this.widget() - .toggleClass( this.widgetFullName + "-disabled ui-state-disabled", !!value ) - .attr( "aria-disabled", value ); + .toggleClass( this.widgetFullName + "-disabled", !!value ); this.hoverable.removeClass( "ui-state-hover" ); this.focusable.removeClass( "ui-state-focus" ); } |