diff --git a/Gruntfile.js b/Gruntfile.js index 81c3a2618..5d77e7393 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -77,10 +77,30 @@ var "dist/jquery-ui.min.js" ] }, - component = grunt.option( "component" ) || "**"; + component = grunt.option( "component" ) || "**", + + jscsBad = [ + "ui/button.js", + "ui/datepicker.js", + "ui/draggable.js", + "ui/droppable.js", + "ui/effect.js", + "ui/mouse.js", + "ui/resizable.js", + "ui/selectable.js", + "ui/slider.js", + "ui/sortable.js" + ], + + htmllintBad = [ + "demos/tabs/ajax/content*.html", + "demos/tooltip/ajax/content*.html", + "tests/unit/core/core.html", + "tests/unit/tabs/data/test.html" + ]; function mapMinFile( file ) { - return "dist/" + file.replace( /\.js$/, ".min.js" ).replace( /ui\//, "minified/" ); + return "dist/" + file.replace( /ui\//, "minified/" ); } function expandFiles( files ) { @@ -159,25 +179,54 @@ grunt.initConfig({ dest: "dist/jquery-ui.css" } }, + + // Remove the requireSpacesInsideParentheses override once everything is fixed jscs: { - // datepicker and sortable are getting rewritten, ignore until that's done - ui: [ "ui/*.js", "!ui/datepicker.js", "!ui/sortable.js" ], - // TODO enable this once we have a tool that can auto format files - // tests: "tests/unit/**/*.js", - grunt: [ "Gruntfile.js", "build/tasks/*.js" ] + "ui-good": [ "ui/*.js" ].concat( jscsBad.map( function( file ) { + return "!" + file; + } ) ), + "ui-bad": { + options: { + requireSpacesInsideParentheses: null + }, + src: jscsBad + }, + tests: { + options: { + requireSpacesInsideParentheses: null + }, + src: "tests/unit/**/*.js" + }, + grunt: { + options: { + requireSpacesInsideParentheses: null + }, + src: [ "Gruntfile.js", "build/tasks/*.js" ] + } }, uglify: minify, 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 ); - }) + good: [ "demos/**/*.html", "tests/**/*.html" ].concat( htmllintBad.map( function( file ) { + return "!" + file; + } ) ), + bad: { + options: { + ignore: [ + /Start tag seen without seeing a doctype first/, + /Element “head” is missing a required instance of child element “title”/, + /Element “object” is missing one or more of the following/, + /The “codebase” attribute on the “object” element is obsolete/ + ] + }, + src: htmllintBad + } }, qunit: { files: expandFiles( "tests/unit/" + component + "/*.html" ).filter(function( file ) { return !( /(all|index|test)\.html$/ ).test( file ); }), options: { + inject: false, page: { viewportSize: { width: 700, height: 500 } } @@ -191,7 +240,8 @@ grunt.initConfig({ "ui/*.js", "Gruntfile.js", "build/**/*.js", - "tests/unit/**/*.js" + "tests/unit/**/*.js", + "tests/lib/**/*.js" ] }, csslint: { @@ -228,7 +278,19 @@ grunt.initConfig({ files: { "qunit/qunit.js": "qunit/qunit/qunit.js", "qunit/qunit.css": "qunit/qunit/qunit.css", - "qunit/MIT-LICENSE.txt": "qunit/MIT-LICENSE.txt", + "qunit/LICENSE.txt": "qunit/LICENSE.txt", + + "qunit-assert-classes/qunit-assert-classes.js": "qunit-assert-classes/qunit-assert-classes.js", + "qunit-assert-classes/LICENSE.txt": "qunit-assert-classes/LICENSE", + + "qunit-assert-close/qunit-assert-close.js": "qunit-assert-close/qunit-assert-close.js", + "qunit-assert-close/MIT-LICENSE.txt": "qunit-assert-close/MIT-LICENSE.txt", + + "qunit-composite/qunit-composite.js": "qunit-composite/qunit-composite.js", + "qunit-composite/qunit-composite.css": "qunit-composite/qunit-composite.css", + "qunit-composite/LICENSE.txt": "qunit-composite/LICENSE.txt", + + "requirejs/require.js": "requirejs/require.js", "jquery-mousewheel/jquery.mousewheel.js": "jquery-mousewheel/jquery.mousewheel.js", "jquery-mousewheel/LICENSE.txt": "jquery-mousewheel/LICENSE.txt", @@ -239,7 +301,7 @@ grunt.initConfig({ "jshint/jshint.js": "jshint/dist/jshint.js", "jshint/LICENSE": "jshint/LICENSE", - "jquery/jquery.js": "jquery-1.x/jquery.js", + "jquery/jquery.js": "jquery-1.x/dist/jquery.js", "jquery/MIT-LICENSE.txt": "jquery-1.x/MIT-LICENSE.txt", "jquery-1.7.0/jquery.js": "jquery-1.7.0/jquery.js", @@ -278,6 +340,18 @@ grunt.initConfig({ "jquery-1.10.2/jquery.js": "jquery-1.10.2/jquery.js", "jquery-1.10.2/MIT-LICENSE.txt": "jquery-1.10.2/MIT-LICENSE.txt", + "jquery-1.11.0/jquery.js": "jquery-1.11.0/dist/jquery.js", + "jquery-1.11.0/MIT-LICENSE.txt": "jquery-1.11.0/MIT-LICENSE.txt", + + "jquery-1.11.1/jquery.js": "jquery-1.11.1/dist/jquery.js", + "jquery-1.11.1/MIT-LICENSE.txt": "jquery-1.11.1/MIT-LICENSE.txt", + + "jquery-1.11.2/jquery.js": "jquery-1.11.2/dist/jquery.js", + "jquery-1.11.2/MIT-LICENSE.txt": "jquery-1.11.2/MIT-LICENSE.txt", + + "jquery-1.11.3/jquery.js": "jquery-1.11.3/dist/jquery.js", + "jquery-1.11.3/MIT-LICENSE.txt": "jquery-1.11.3/MIT-LICENSE.txt", + "jquery-2.0.0/jquery.js": "jquery-2.0.0/jquery.js", "jquery-2.0.0/MIT-LICENSE.txt": "jquery-2.0.0/MIT-LICENSE.txt", @@ -288,7 +362,19 @@ grunt.initConfig({ "jquery-2.0.2/MIT-LICENSE.txt": "jquery-2.0.2/MIT-LICENSE.txt", "jquery-2.0.3/jquery.js": "jquery-2.0.3/jquery.js", - "jquery-2.0.3/MIT-LICENSE.txt": "jquery-2.0.3/MIT-LICENSE.txt" + "jquery-2.0.3/MIT-LICENSE.txt": "jquery-2.0.3/MIT-LICENSE.txt", + + "jquery-2.1.0/jquery.js": "jquery-2.1.0/dist/jquery.js", + "jquery-2.1.0/MIT-LICENSE.txt": "jquery-2.1.0/MIT-LICENSE.txt", + + "jquery-2.1.1/jquery.js": "jquery-2.1.1/dist/jquery.js", + "jquery-2.1.1/MIT-LICENSE.txt": "jquery-2.1.1/MIT-LICENSE.txt", + + "jquery-2.1.2/jquery.js": "jquery-2.1.2/dist/jquery.js", + "jquery-2.1.2/MIT-LICENSE.txt": "jquery-2.1.2/MIT-LICENSE.txt", + + "jquery-2.1.3/jquery.js": "jquery-2.1.3/dist/jquery.js", + "jquery-2.1.3/MIT-LICENSE.txt": "jquery-2.1.3/MIT-LICENSE.txt" } } }, diff --git a/README.md b/README.md index 998a3f24b..a1727c0c0 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ You can also run the unit tests inside phantomjs by [setting up your environment jQuery UI uses the [Grunt](http://gruntjs.com/) build system. -To build jQuery UI, [setup your environment]([setting up your environment](CONTRIBUTING.md#environment-minimum-required)) and then run the following commands: +To build jQuery UI, [setup your environment](CONTRIBUTING.md#environment-minimum-required) and then run the following commands: ```sh # Run the concat task to concatenate files diff --git a/bower.json b/bower.json index cab4b258e..2c8b5a6ba 100644 --- a/bower.json +++ b/bower.json @@ -14,7 +14,11 @@ "jquery-mousewheel": "3.1.12", "jquery-simulate": "1.0.0", "jshint": "2.4.4", - "qunit": "1.17.1", + "qunit": "1.18.0", + "qunit-assert-classes": "1.0.2", + "qunit-assert-close": "JamesMGreene/qunit-assert-close#v1.1.1", + "qunit-composite": "JamesMGreene/qunit-composite#v1.1.0", + "requirejs": "2.1.14", "jquery-1.7.0": "jquery#1.7.0", "jquery-1.7.1": "jquery#1.7.1", @@ -28,10 +32,18 @@ "jquery-1.10.0": "jquery#1.10.0", "jquery-1.10.1": "jquery#1.10.1", "jquery-1.10.2": "jquery#1.10.2", - "jquery-1.x": "jquery#1.10.2", + "jquery-1.11.0": "jquery#1.11.0", + "jquery-1.11.1": "jquery#1.11.1", + "jquery-1.11.2": "jquery#1.11.2", + "jquery-1.11.3": "jquery#1.11.3", + "jquery-1.x": "jquery#1.11.3", "jquery-2.0.0": "jquery#2.0.0", "jquery-2.0.1": "jquery#2.0.1", "jquery-2.0.2": "jquery#2.0.2", - "jquery-2.0.3": "jquery#2.0.3" + "jquery-2.0.3": "jquery#2.0.3", + "jquery-2.1.0": "jquery#2.1.0", + "jquery-2.1.1": "jquery#2.1.1", + "jquery-2.1.2": "jquery#2.1.2", + "jquery-2.1.3": "jquery#2.1.3" } } diff --git a/build/release.js b/build/release.js index a55f8002c..ce1425bb0 100644 --- a/build/release.js +++ b/build/release.js @@ -9,7 +9,7 @@ function replaceAtVersion() { var matches = []; function recurse( folder ) { - fs.readdirSync( folder ).forEach(function( fileName ) { + fs.readdirSync( folder ).forEach( function( fileName ) { var content, fullPath = folder + "/" + fileName; if ( fs.statSync( fullPath ).isDirectory() ) { @@ -18,13 +18,13 @@ function replaceAtVersion() { } content = fs.readFileSync( fullPath, { encoding: "utf-8" - }); + } ); if ( !/@VERSION/.test( content ) ) { return; } matches.push( fullPath ); fs.writeFileSync( fullPath, content.replace( /@VERSION/g, Release.newVersion ) ); - }); + } ); } [ "ui", "themes" ].forEach( recurse ); @@ -41,7 +41,7 @@ function buildCDNPackage( callback ) { builder = new downloadBuilder.Builder( jqueryUi, ":all:" ), packer = new downloadBuilder.ThemesPacker( builder, { includeJs: true - }), + } ), target = "../" + jqueryUi.pkg.name + "-" + jqueryUi.pkg.version + "-cdn.zip"; // Zip dir structure must be flat, override default base folder @@ -51,15 +51,15 @@ function buildCDNPackage( callback ) { Release.abort( "Failed to zip CDN package", error ); } callback(); - }); + } ); } -Release.define({ +Release.define( { issueTracker: "trac", contributorReportId: 22, changelogShell: function() { var monthNames = [ "January", "February", "March", "April", "May", "June", "July", - "August", "September", "October", "November", "December" ], + "August", "September", "October", "November", "December" ], now = new Date(); return "\n\nReleased on " + monthNames[ now.getMonth() ] + " " + now.getDate() + ", " + now.getFullYear() + "\n\n"; @@ -67,14 +67,14 @@ Release.define({ generateArtifacts: function( fn ) { var files = replaceAtVersion(); - buildCDNPackage(function copyCdnFiles() { + buildCDNPackage( function copyCdnFiles() { var zipFile = shell.ls( "../jquery*-cdn.zip" )[ 0 ], tmpFolder = "../tmp-zip-output", unzipCommand = "unzip -o " + zipFile + " -d " + tmpFolder; console.log( "Unzipping for dist/cdn copies" ); shell.mkdir( "-p", tmpFolder ); - Release.exec({ + Release.exec( { command: unzipCommand, silent: true }, "Failed to unzip cdn files" ); @@ -83,9 +83,9 @@ Release.define({ shell.cp( tmpFolder + "/jquery-ui*.js", "dist/cdn" ); shell.cp( "-r", tmpFolder + "/themes", "dist/cdn" ); fn( files ); - }); + } ); } -}); +} ); }; diff --git a/build/tasks/build.js b/build/tasks/build.js index 13e6fad14..77ae2545d 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -4,12 +4,12 @@ module.exports = function( grunt ) { grunt.registerTask( "clean", function() { require( "rimraf" ).sync( "dist" ); -}); +} ); grunt.registerTask( "asciilint", function() { var valid = true, - files = grunt.file.expand({ filter: "isFile" }, "ui/*.js" ); - files.forEach(function( filename ) { + files = grunt.file.expand( { filter: "isFile" }, "ui/*.js" ); + files.forEach( function( filename ) { var i, c, text = grunt.file.read( filename ); @@ -32,11 +32,11 @@ grunt.registerTask( "asciilint", function() { } valid = false; } - }); + } ); if ( valid ) { grunt.log.ok( files.length + " files lint free." ); } return valid; -}); +} ); }; diff --git a/build/tasks/testswarm.js b/build/tasks/testswarm.js index 957153777..b889c6c36 100644 --- a/build/tasks/testswarm.js +++ b/build/tasks/testswarm.js @@ -3,8 +3,9 @@ module.exports = function( grunt ) { "use strict"; var versions = { - "git": "git", - "1.10": "1.10.0 1.10.1 1.10.2", + "compat-git": "compat-git", + "1.11": "1.11.0 1.11.1 1.11.2 1.11.3", + "1.10": "1.10.0 1.10.2", "1.9": "1.9.0 1.9.1", "1.8": "1.8.0 1.8.1 1.8.2 1.8.3", "1.7": "1.7.0 1.7.1 1.7.2" @@ -48,26 +49,26 @@ function submit( commit, runs, configFile, extra, done ) { runs[ testName ] = config.testUrl + commit + "/tests/unit/" + runs[ testName ]; } - testswarm.createClient({ + testswarm.createClient( { url: config.swarmUrl - }) - .addReporter( testswarm.reporters.cli ) - .auth({ - id: config.authUsername, - token: config.authToken - }) - .addjob({ - name: "Commit " + commit.substr( 0, 10 ) + "" + extra, - runs: runs, - runMax: config.runMax, - browserSets: [ "popular-ui" ], - timeout: 1000 * 60 * 30 - }, function( error, passed ) { - if ( error ) { - grunt.log.error( error ); - } - done( passed ); - }); + } ) + .addReporter( testswarm.reporters.cli ) + .auth( { + id: config.authUsername, + token: config.authToken + } ) + .addjob( { + name: "Commit " + commit.substr( 0, 10 ) + "" + extra, + runs: runs, + runMax: config.runMax, + browserSets: config.browserSets, + timeout: 1000 * 60 * 30 + }, function( error, passed ) { + if ( error ) { + grunt.log.error( error ); + } + done( passed ); + } ); } grunt.registerTask( "testswarm", function( commit, configFile ) { @@ -77,16 +78,16 @@ grunt.registerTask( "testswarm", function( commit, configFile ) { latestTests[ test ] = tests[ test ] + "?nojshint=true"; } submit( commit, latestTests, configFile, "", this.async() ); -}); +} ); grunt.registerTask( "testswarm-multi-jquery", function( commit, configFile, minor ) { var allTests = {}; - versions[ minor ].split(" ").forEach(function( version ) { + versions[ minor ].split( " " ).forEach( function( version ) { for ( var test in tests ) { allTests[ test + "-" + version ] = tests[ test ] + "?nojshint=true&jquery=" + version; } - }); + } ); submit( commit, allTests, configFile, "core " + minor, this.async() ); -}); +} ); }; diff --git a/demos/accordion/custom-icons.html b/demos/accordion/custom-icons.html index 91ca4543a..9d43c3c8b 100644 --- a/demos/accordion/custom-icons.html +++ b/demos/accordion/custom-icons.html @@ -19,7 +19,7 @@ $( "#accordion" ).accordion({ icons: icons }); - $( "#toggle" ).button().click(function() { + $( "#toggle" ).button().on( "click", function() { if ( $( "#accordion" ).accordion( "option", "icons" ) ) { $( "#accordion" ).accordion( "option", "icons", null ); } else { diff --git a/demos/accordion/hoverintent.html b/demos/accordion/hoverintent.html index dce8a8f0c..ad15721f3 100644 --- a/demos/accordion/hoverintent.html +++ b/demos/accordion/hoverintent.html @@ -23,10 +23,10 @@ */ $.event.special.hoverintent = { setup: function() { - $( this ).bind( "mouseover", jQuery.event.special.hoverintent.handler ); + $( this ).on( "mouseover", jQuery.event.special.hoverintent.handler ); }, teardown: function() { - $( this ).unbind( "mouseover", jQuery.event.special.hoverintent.handler ); + $( this ).off( "mouseover", jQuery.event.special.hoverintent.handler ); }, handler: function( event ) { var currentX, currentY, timeout, @@ -42,8 +42,8 @@ function clear() { target - .unbind( "mousemove", track ) - .unbind( "mouseout", clear ); + .off( "mousemove", track ) + .off( "mouseout", clear ); clearTimeout( timeout ); } @@ -75,7 +75,7 @@ } timeout = setTimeout( handler, 100 ); - target.bind({ + target.on({ mousemove: track, mouseout: clear }); diff --git a/demos/autocomplete/combobox.html b/demos/autocomplete/combobox.html index 437e52ab1..76d792470 100644 --- a/demos/autocomplete/combobox.html +++ b/demos/autocomplete/combobox.html @@ -58,7 +58,9 @@ source: $.proxy( this, "_source" ) }) .tooltip({ - tooltipClass: "ui-state-highlight" + classes: { + "ui-tooltip": "ui-state-highlight" + } }); this._on( this.input, { @@ -90,11 +92,11 @@ }) .removeClass( "ui-corner-all" ) .addClass( "custom-combobox-toggle ui-corner-right" ) - .mousedown(function() { + .on( "mousedown", function() { wasOpen = input.autocomplete( "widget" ).is( ":visible" ); }) - .click(function() { - input.focus(); + .on( "click", function() { + input.trigger( "focus" ); // Close if already visible if ( wasOpen ) { @@ -163,7 +165,7 @@ $(function() { $( "#combobox" ).combobox(); - $( "#toggle" ).click(function() { + $( "#toggle" ).on( "click", function() { $( "#combobox" ).toggle(); }); }); diff --git a/demos/autocomplete/multiple-remote.html b/demos/autocomplete/multiple-remote.html index 72c001754..45f319865 100644 --- a/demos/autocomplete/multiple-remote.html +++ b/demos/autocomplete/multiple-remote.html @@ -27,7 +27,7 @@ $( "#birds" ) // don't navigate away from the field on tab when selecting an item - .bind( "keydown", function( event ) { + .on( "keydown", function( event ) { if ( event.keyCode === $.ui.keyCode.TAB && $( this ).autocomplete( "instance" ).menu.active ) { event.preventDefault(); diff --git a/demos/autocomplete/multiple.html b/demos/autocomplete/multiple.html index 63d379067..1bd70f228 100644 --- a/demos/autocomplete/multiple.html +++ b/demos/autocomplete/multiple.html @@ -46,7 +46,7 @@ $( "#tags" ) // don't navigate away from the field on tab when selecting an item - .bind( "keydown", function( event ) { + .on( "keydown", function( event ) { if ( event.keyCode === $.ui.keyCode.TAB && $( this ).autocomplete( "instance" ).menu.active ) { event.preventDefault(); diff --git a/demos/autocomplete/remote-jsonp.html b/demos/autocomplete/remote-jsonp.html index 84c6957e0..0d71dae9a 100644 --- a/demos/autocomplete/remote-jsonp.html +++ b/demos/autocomplete/remote-jsonp.html @@ -26,39 +26,33 @@ $( "#city" ).autocomplete({ source: function( request, response ) { - $.ajax({ + $.ajax( { url: "http://gd.geobytes.com/AutoCompleteCity", dataType: "jsonp", data: { q: request.term }, success: function( data ) { - response( data ); + + // Handle 'no match' indicated by [ "" ] response + response( data.length === 1 && data[ 0 ].length === 0 ? [] : data ); } - }); + } ); }, minLength: 3, select: function( event, ui ) { - log( ui.item ? - "Selected: " + ui.item.label : - "Nothing selected, input was " + this.value); - }, - open: function() { - $( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" ); - }, - close: function() { - $( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" ); + log( "Selected: " + ui.item.label ); } - }); - }); + } ); + } );
- - Powered by geonames.org + + Powered by geobytes.com
@@ -67,8 +61,7 @@
-

The Autocomplete widgets provides suggestions while you type into the field. Here the suggestions are cities, displayed when at least two characters are entered into the field.

-

In this case, the datasource is the geonames.org webservice. While only the city name itself ends up in the input after selecting an element, more info is displayed in the suggestions to help find the right entry. That data is also available in callbacks, as illustrated by the Result area below the input.

+

The Autocomplete widgets provides suggestions while you type into the field. Here the suggestions are cities, displayed when at least three characters are entered into the field. The datasource is the geobytes.com webservice. That data is also available in callbacks, as illustrated by the Result area below the input.

diff --git a/demos/button/default.html b/demos/button/default.html index 8c1690969..1bd4f9191 100644 --- a/demos/button/default.html +++ b/demos/button/default.html @@ -13,7 +13,7 @@ $(function() { $( "input[type=submit], a, button" ) .button() - .click(function( event ) { + .on( "click", function( event ) { event.preventDefault(); }); }); diff --git a/demos/button/splitbutton.html b/demos/button/splitbutton.html index 441e0a912..333d54bd7 100644 --- a/demos/button/splitbutton.html +++ b/demos/button/splitbutton.html @@ -18,7 +18,7 @@ $(function() { $( "#rerun" ) .button() - .click(function() { + .on( "click", function() { alert( "Running the last action" ); }) .next() @@ -28,7 +28,7 @@ primary: "ui-icon-triangle-1-s" } }) - .click(function() { + .on( "click", function() { var menu = $( this ).parent().next().show().position({ my: "left top", at: "left bottom", diff --git a/demos/button/toolbar.html b/demos/button/toolbar.html index e2eac055c..e13b4a1d1 100644 --- a/demos/button/toolbar.html +++ b/demos/button/toolbar.html @@ -35,7 +35,7 @@ primary: "ui-icon-play" } }) - .click(function() { + .on( "click", function() { var options; if ( $( this ).text() === "play" ) { options = { @@ -60,7 +60,7 @@ primary: "ui-icon-stop" } }) - .click(function() { + .on( "click", function() { $( "#play" ).button( "option", { label: "play", icons: { diff --git a/demos/datepicker/animation.html b/demos/datepicker/animation.html index 6fbc31ff9..04b196627 100644 --- a/demos/datepicker/animation.html +++ b/demos/datepicker/animation.html @@ -25,7 +25,7 @@ - - - - - - - - - - - - - -
-

Products

-
-

T-Shirts

-
-
    -
  • Lolcat Shirt
  • -
  • Cheezeburger Shirt
  • -
  • Buckit Shirt
  • -
-
-

Bags

-
-
    -
  • Zebra Striped
  • -
  • Black Leather
  • -
  • Alligator Leather
  • -
-
-

Gadgets

-
-
    -
  • iPhone
  • -
  • iPod
  • -
  • iPad
  • -
-
-
-
- -
-

Shopping Cart

-
-
    -
  1. Add your items here
  2. -
-
-
- -
-

Demonstrate how to use an accordion to structure products into a catalog and make use of drag and drop for adding them to a shopping cart, where they are sortable.

-
- - diff --git a/demos/droppable/visual-feedback.html b/demos/droppable/visual-feedback.html index 9b197c56e..9852f371b 100644 --- a/demos/droppable/visual-feedback.html +++ b/demos/droppable/visual-feedback.html @@ -20,7 +20,9 @@ $(function() { $( "#draggable" ).draggable(); $( "#droppable" ).droppable({ - hoverClass: "ui-state-hover", + classes: { + "ui-droppable-hover": "ui-state-hover" + }, drop: function( event, ui ) { $( this ) .addClass( "ui-state-highlight" ) @@ -32,7 +34,9 @@ $( "#draggable2" ).draggable(); $( "#droppable2" ).droppable({ accept: "#draggable2", - activeClass: "ui-state-default", + classes: { + "ui-droppable-active": "ui-state-default" + }, drop: function( event, ui ) { $( this ) .addClass( "ui-state-highlight" ) @@ -66,7 +70,7 @@
-

Change the droppable's appearance on hover, or when the droppable is active (an acceptable draggable is dropped on it). Use the hoverClass or activeClass options to specify respective classes.

+

Change the droppable's appearance on hover, or when the droppable is active (an acceptable draggable is dropped on it). Set the values of the ui-droppable-hover or ui-droppable-active properties on the classes option to specify the respective classes.

diff --git a/demos/effect/addClass.html b/demos/effect/addClass.html index 0aab17304..915a72f2d 100644 --- a/demos/effect/addClass.html +++ b/demos/effect/addClass.html @@ -15,7 +15,7 @@ diff --git a/demos/selectmenu/custom_render.html b/demos/selectmenu/custom_render.html index 9329b81b1..ec0b4b6d5 100644 --- a/demos/selectmenu/custom_render.html +++ b/demos/selectmenu/custom_render.html @@ -59,9 +59,6 @@ label { display: block; } - select { - width: 200px; - } /* select with custom icons */ .ui-selectmenu-menu .ui-menu.customicons .ui-menu-item-wrapper { diff --git a/demos/selectmenu/default.html b/demos/selectmenu/default.html index d9b198683..5fa1af28b 100644 --- a/demos/selectmenu/default.html +++ b/demos/selectmenu/default.html @@ -22,6 +22,8 @@ .selectmenu() .selectmenu( "menuWidget" ) .addClass( "overflow" ); + + $( "#salutation" ).selectmenu(); }); - - - - -
-
-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
-
-
-
-
- -
-

Use a slider to manipulate the positioning of content on the page. In this case, it acts as a scrollbar with the potential to capture values if needed.

-
- - diff --git a/demos/sortable/portlets.html b/demos/sortable/portlets.html index 4d7f9cd53..42ddb4444 100644 --- a/demos/sortable/portlets.html +++ b/demos/sortable/portlets.html @@ -58,7 +58,7 @@ .addClass( "ui-widget-header ui-corner-all" ) .prepend( ""); - $( ".portlet-toggle" ).click(function() { + $( ".portlet-toggle" ).on( "click", function() { var icon = $( this ); icon.toggleClass( "ui-icon-minusthick ui-icon-plusthick" ); icon.closest( ".portlet" ).find( ".portlet-content" ).toggle(); diff --git a/demos/spinner/currency.html b/demos/spinner/currency.html index b39a431c5..0509e80a0 100644 --- a/demos/spinner/currency.html +++ b/demos/spinner/currency.html @@ -16,7 +16,7 @@ " ); - -}() ); diff --git a/tests/lib/bootstrap.js b/tests/lib/bootstrap.js new file mode 100644 index 000000000..2829c6639 --- /dev/null +++ b/tests/lib/bootstrap.js @@ -0,0 +1,150 @@ +( function() { + +requirejs.config({ + paths: { + "date": "../../../external/date", + "globalize": "../../../external/globalize/globalize", + "globalize-locales": "../../../external/localization", + "globalize-old": "../../../external/globalize-old/globalize", + "globalize-old/ja-JP": "../../../external/globalize-old/globalize.culture.ja-JP", + "jquery": jqueryUrl(), + "jquery-simulate": "../../../external/jquery-simulate/jquery.simulate", + "jshint": "../../../external/jshint/jshint", + "lib": "../../lib", + "phantom-bridge": "../../../node_modules/grunt-contrib-qunit/phantomjs/bridge", + "qunit-assert-classes": "../../../external/qunit-assert-classes/qunit-assert-classes", + "qunit-assert-close": "../../../external/qunit-assert-close/qunit-assert-close", + "qunit": "../../../external/qunit/qunit", + "testswarm": "http://swarm.jquery.org/js/inject.js?" + (new Date()).getTime(), + "ui": "../../../ui" + }, + shim: { + "date": [ "globalize-locales" ], + "globalize-old/ja-JP": [ "globalize-old" ], + "jquery-simulate": [ "jquery" ], + "qunit-assert-close": [ "qunit" ], + "testswarm": [ "qunit" ] + } +}); + +// Create a module that disables back compat for UI modules +define( "jquery-no-back-compat", [ "jquery" ], function( $ ) { + $.uiBackCompat = false; + + return $; +} ); + +// Create a dummy bridge if we're not actually testing in PhantomJS +if ( !/PhantomJS/.test( navigator.userAgent ) ) { + define( "phantom-bridge", function() {} ); +} + +// Load all modules in series +function requireModules( dependencies, callback, modules ) { + if ( !dependencies.length ) { + if ( callback ) { + callback.apply( null, modules ); + } + return; + } + + if ( !modules ) { + modules = []; + } + + var dependency = dependencies.shift(); + require( [ dependency ], function( module ) { + modules.push( module ); + requireModules( dependencies, callback, modules ); + } ); +} + +// Load a set of test file along with the required test infrastructure +function requireTests( dependencies, noBackCompat ) { + dependencies = [ + "lib/qunit", + noBackCompat ? "jquery-no-back-compat" : "jquery", + "jquery-simulate" + ].concat( dependencies ); + + // Load the TestSwarm injector, if necessary + if ( parseUrl().swarmURL ) { + dependencies.push( "testswarm" ); + } + + requireModules( dependencies, function( QUnit ) { + QUnit.start(); + } ); +} + +// Parse the URL into key/value pairs +function parseUrl() { + var data = {}; + var parts = document.location.search.slice( 1 ).split( "&" ); + var length = parts.length; + var i = 0; + var current; + + for ( ; i < length; i++ ) { + current = parts[ i ].split( "=" ); + data[ current[ 0 ] ] = current[ 1 ]; + } + + return data; +} + +function jqueryUrl() { + var version = parseUrl().jquery; + var url; + + if ( version === "git" || version === "compat-git" ) { + url = "http://code.jquery.com/jquery-" + version; + } else { + url = "../../../external/jquery-" + ( version || "1.11.3" ) + "/jquery"; + } + + return url; +} + +// Load test modules based on data attributes +// - data-modules: list of test modules to load +// - data-widget: A widget to load test modules for +// - Automatically loads common, core, events, methods, and options +// - data-deprecated: Loads the deprecated test modules for a widget +// - data-no-back-compat: Set $.uiBackCompat to false +(function() { + + // Find the script element + var scripts = document.getElementsByTagName( "script" ); + var script = scripts[ scripts.length - 1 ]; + + // Read the modules + var modules = script.getAttribute( "data-modules" ); + if ( modules ) { + modules = modules + .replace( /^\s+|\s+$/g, "" ) + .split( /\s+/ ); + } else { + modules = []; + } + var widget = script.getAttribute( "data-widget" ); + var deprecated = !!script.getAttribute( "data-deprecated" ); + var noBackCompat = !!script.getAttribute( "data-no-back-compat" ); + + if ( widget ) { + modules = modules.concat([ + ( deprecated ? "common-deprecated" : "common" ), + "core", + "events", + "methods", + "options" + ]); + if ( deprecated ) { + modules = modules.concat( "deprecated" ); + } + } + + requireTests( modules, noBackCompat ); +} )(); + +} )(); diff --git a/tests/lib/common.js b/tests/lib/common.js new file mode 100644 index 000000000..9faa4e246 --- /dev/null +++ b/tests/lib/common.js @@ -0,0 +1,133 @@ +define([ + "jquery" +], function( $ ) { + +var exports = {}; + +function testWidgetDefaults( widget, defaults ) { + var pluginDefaults = $.ui[ widget ].prototype.options; + + // Ensure that all defaults have the correct value + test( "defined defaults", function() { + var count = 0; + $.each( defaults, function( key, val ) { + expect( ++count ); + if ( $.isFunction( val ) ) { + ok( $.isFunction( pluginDefaults[ key ] ), key ); + return; + } + deepEqual( pluginDefaults[ key ], val, key ); + }); + }); + + // Ensure that all defaults were tested + test( "tested defaults", function() { + var count = 0; + $.each( pluginDefaults, function( key ) { + expect( ++count ); + ok( key in defaults, key ); + }); + }); +} + +function testWidgetOverrides( widget ) { + if ( $.uiBackCompat === false ) { + test( "$.widget overrides", function() { + expect( 4 ); + $.each([ + "_createWidget", + "destroy", + "option", + "_trigger" + ], function( i, method ) { + strictEqual( $.ui[ widget ].prototype[ method ], + $.Widget.prototype[ method ], "should not override " + method ); + }); + }); + } +} + +function testBasicUsage( widget ) { + test( "basic usage", function() { + expect( 3 ); + + var defaultElement = $.ui[ widget ].prototype.defaultElement; + $( defaultElement ).appendTo( "body" )[ widget ]().remove(); + ok( true, "initialized on element" ); + + $( defaultElement )[ widget ]().remove(); + ok( true, "initialized on disconnected DOMElement - never connected" ); + + // Ensure manipulating removed elements works (#3664) + $( defaultElement ).appendTo( "body" ).remove()[ widget ]().remove(); + ok( true, "initialized on disconnected DOMElement - removed" ); + }); +} + +exports.testWidget = function( widget, settings ) { + module( widget + ": common widget" ); + + exports.testJshint( widget ); + testWidgetDefaults( widget, settings.defaults ); + testWidgetOverrides( widget ); + testBasicUsage( widget ); + test( "version", function() { + expect( 1 ); + ok( "version" in $.ui[ widget ].prototype, "version property exists" ); + }); +}; + +exports.testJshint = function( module ) { + + // Function.prototype.bind check is needed because JSHint doesn't work in ES3 browsers anymore + // https://github.com/jshint/jshint/issues/1384 + if ( QUnit.urlParams.nojshint || !Function.prototype.bind ) { + return; + } + + asyncTest( "JSHint", function() { + require( [ "jshint" ], function() { + expect( 1 ); + + $.when( + $.ajax( { + url: "../../../ui/.jshintrc", + dataType: "json" + } ), + $.ajax( { + url: "../../../ui/" + module + ".js", + dataType: "text" + } ) + ) + .done( function( hintArgs, srcArgs ) { + var globals, passed, errors, + jshintrc = hintArgs[ 0 ], + source = srcArgs[ 0 ]; + + globals = jshintrc.globals || {}; + delete jshintrc.globals; + passed = JSHINT( source, jshintrc, globals ); + errors = $.map( JSHINT.errors, function( error ) { + + // JSHINT may report null if there are too many errors + if ( !error ) { + return; + } + + return "[L" + error.line + ":C" + error.character + "] " + + error.reason + "\n" + error.evidence + "\n"; + } ).join( "\n" ); + ok( passed, errors ); + start(); + } ) + .fail(function( hintError, srcError ) { + ok( false, "error loading source: " + ( hintError || srcError ).statusText ); + start(); + } ); + }); + }); +}; + +return exports; + +}); diff --git a/tests/lib/css.js b/tests/lib/css.js new file mode 100644 index 000000000..37353e912 --- /dev/null +++ b/tests/lib/css.js @@ -0,0 +1,23 @@ +(function() { + +function includeStyle( url ) { + document.write( "" ); +} + +// Find the script element +var scripts = document.getElementsByTagName( "script" ); +var script = scripts[ scripts.length - 1 ]; + +// Load the modules +var modules = script.getAttribute( "data-modules" ); +if ( modules ) { + modules = modules.split( /\s+/ ); + for ( var i = 0; i < modules.length; i++ ) { + includeStyle( "themes/base/" + modules[ i ] + ".css" ); + } +} + +// Load the QUnit stylesheet +includeStyle( "external/qunit/qunit.css" ); + +} )(); diff --git a/tests/lib/helper.js b/tests/lib/helper.js new file mode 100644 index 000000000..cc7d8c000 --- /dev/null +++ b/tests/lib/helper.js @@ -0,0 +1,33 @@ +define([ + "jquery" +], function( $ ) { + +var exports = {}; + +exports.forceScrollableWindow = function( appendTo ) { + + // The main testable area is 10000x10000 so to enforce scrolling, + // this DIV must be greater than 10000 to work + return $( "
" ) + .css({ + height: "11000px", + width: "11000px" + }) + .appendTo( appendTo || "#qunit-fixture" ); +}; + +exports.onFocus = function( element, onFocus ) { + var fn = function( event ) { + if ( !event.originalEvent ) { + return; + } + element.off( "focus", fn ); + onFocus(); + }; + + element.on( "focus", fn )[ 0 ].focus(); +}; + +return exports; + +}); diff --git a/tests/lib/qunit-assert-domequal.js b/tests/lib/qunit-assert-domequal.js new file mode 100644 index 000000000..ba516453d --- /dev/null +++ b/tests/lib/qunit-assert-domequal.js @@ -0,0 +1,123 @@ +/* + * Experimental assertion for comparing DOM objects. + * + * Serializes an element and some properties and attributes and its children if any, + * otherwise the text. Then compares the result using deepEqual(). + */ +define( [ + "qunit", + "jquery" +], function( QUnit, $ ) { + +var domEqual = QUnit.assert.domEqual = function( selector, modifier, message ) { + + var assert = this; + + // Get current state prior to modifier + var expected = extract( selector, message ); + + function done() { + var actual = extract( selector, message ); + assert.push( QUnit.equiv( actual, expected ), actual, expected, message ); + } + + // Run modifier (async or sync), then compare state via done() + if ( modifier.length ) { + modifier( done ); + } else { + modifier(); + done(); + } +}; + +domEqual.properties = [ + "disabled", + "readOnly" +]; + +domEqual.attributes = [ + "autocomplete", + "aria-activedescendant", + "aria-controls", + "aria-describedby", + "aria-disabled", + "aria-expanded", + "aria-haspopup", + "aria-hidden", + "aria-labelledby", + "aria-pressed", + "aria-selected", + "aria-valuemax", + "aria-valuemin", + "aria-valuenow", + "class", + "href", + "id", + "nodeName", + "role", + "tabIndex", + "title" +]; + +function getElementStyles( elem ) { + var styles = {}; + var style = elem.ownerDocument.defaultView ? + elem.ownerDocument.defaultView.getComputedStyle( elem, null ) : + elem.currentStyle; + var key, len; + + if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) { + len = style.length; + while ( len-- ) { + key = style[ len ]; + if ( typeof style[ key ] === "string" ) { + styles[ $.camelCase( key ) ] = style[ key ]; + } + } + + // Support: Opera, IE <9 + } else { + for ( key in style ) { + if ( typeof style[ key ] === "string" ) { + styles[ key ] = style[ key ]; + } + } + } + + return styles; +} + +function extract( selector, message ) { + var elem = $( selector ); + if ( !elem.length ) { + QUnit.push( false, null, null, + "domEqual failed, can't extract " + selector + ", message was: " + message ); + return; + } + + var result = {}; + var children; + $.each( domEqual.properties, function( index, attr ) { + var value = elem.prop( attr ); + result[ attr ] = value != null ? value : ""; + }); + $.each( domEqual.attributes, function( index, attr ) { + var value = elem.attr( attr ); + result[ attr ] = value != null ? value : ""; + }); + result.style = getElementStyles( elem[ 0 ] ); + result.events = $._data( elem[ 0 ], "events" ); + result.data = $.extend( {}, elem.data() ); + delete result.data[ $.expando ]; + children = elem.children(); + if ( children.length ) { + result.children = elem.children().map(function() { + return extract( $( this ) ); + }).get(); + } else { + result.text = elem.text(); + } + return result; +} + +} ); diff --git a/tests/lib/qunit.js b/tests/lib/qunit.js new file mode 100644 index 000000000..87ef8b662 --- /dev/null +++ b/tests/lib/qunit.js @@ -0,0 +1,48 @@ +define( [ + "qunit", + "jquery", + "qunit-assert-classes", + "qunit-assert-close", + "lib/qunit-assert-domequal", + "phantom-bridge" +], function( QUnit, $ ) { + +QUnit.config.autostart = false; +QUnit.config.requireExpects = true; + +QUnit.config.urlConfig.push({ + id: "nojshint", + label: "Skip JSHint", + tooltip: "Skip running JSHint, e.g., within TestSwarm, where Jenkins runs it already" +}); + +QUnit.config.urlConfig.push({ + id: "jquery", + label: "jQuery version", + value: [ + "1.7.0", "1.7.1", "1.7.2", + "1.8.0", "1.8.1", "1.8.2", "1.8.3", + "1.9.0", "1.9.1", + "1.10.0", "1.10.1", "1.10.2", + "1.11.0", "1.11.1", "1.11.2", "1.11.3", + "2.0.0", "2.0.1", "2.0.2", "2.0.3", + "2.1.0", "2.1.1", "2.1.2", "2.1.3", + "compat-git", "git", "custom" + ], + tooltip: "Which jQuery Core version to test against" +}); + +QUnit.reset = ( function( reset ) { + return function() { + + // Ensure jQuery events and data on the fixture are properly removed + $( "#qunit-fixture" ).empty(); + + // Let QUnit reset the fixture + reset.apply( this, arguments ); + }; +} )( QUnit.reset ); + +return QUnit; + +} ); diff --git a/tests/unit/accordion/accordion.html b/tests/unit/accordion/accordion.html index 0a8755fd3..683b87456 100644 --- a/tests/unit/accordion/accordion.html +++ b/tests/unit/accordion/accordion.html @@ -4,30 +4,9 @@ jQuery UI Accordion Test Suite - - - - - - - - - - - - - - - + + + - - - - - - - - - - - - - - @@ -100,7 +73,6 @@
Relative
Absolute
-
Absolute right-bottom
Absolute
diff --git a/tests/unit/draggable/draggable_events.js b/tests/unit/draggable/events.js similarity index 98% rename from tests/unit/draggable/draggable_events.js rename to tests/unit/draggable/events.js index dd5c315b0..ebbf606ef 100644 --- a/tests/unit/draggable/draggable_events.js +++ b/tests/unit/draggable/events.js @@ -1,7 +1,7 @@ -/* - * draggable_events.js - */ -(function( $ ) { +define( [ + "jquery", + "ui/draggable" +], function( $ ) { var element; @@ -161,4 +161,4 @@ test( "position and offset in hash is consistent between start, drag, and stop", deepEqual( dragOffset, stopOffset, "drag offset equals stop offset" ); }); -})( jQuery ); +} ); diff --git a/tests/unit/draggable/draggable_test_helpers.js b/tests/unit/draggable/helper.js similarity index 84% rename from tests/unit/draggable/draggable_test_helpers.js rename to tests/unit/draggable/helper.js index 1b004e7cf..4af87d37f 100644 --- a/tests/unit/draggable/draggable_test_helpers.js +++ b/tests/unit/draggable/helper.js @@ -1,11 +1,20 @@ -TestHelpers.draggable = { +define( [ + "jquery", + "lib/helper", + "ui/draggable" +], function( $, helper ) { + +return $.extend( helper, { + // TODO: remove the unreliable offset hacks unreliableOffset: $.ui.ie && ( !document.documentMode || document.documentMode < 8 ) ? 2 : 0, // Support: Opera 12.10, Safari 5.1, jQuery <1.8 + unreliableContains: (function() { var element = $( "
" ); return $.contains( element[ 0 ].ownerDocument, element[ 0 ] ); })(), + testDragPosition: function( el, dx, dy, expectedDX, expectedDY, msg ) { msg = msg ? msg + "." : ""; @@ -14,6 +23,7 @@ TestHelpers.draggable = { deepEqual( ui.position, positionExpected, "position dragged[" + dx + ", " + dy + "] " + msg ); }); }, + testDragOffset: function( el, dx, dy, expectedDX, expectedDY, msg ) { msg = msg ? msg + "." : ""; @@ -24,6 +34,7 @@ TestHelpers.draggable = { deepEqual( ui.offset, offsetExpected, "offset dragged[" + dx + ", " + dy + "] " + msg ); }); }, + testDragHelperOffset: function( el, dx, dy, expectedDX, expectedDY, msg ) { msg = msg ? msg + "." : ""; @@ -34,33 +45,38 @@ TestHelpers.draggable = { deepEqual( ui.helper.offset(), offsetExpected, "offset dragged[" + dx + ", " + dy + "] " + msg ); }); }, + testDrag: function( el, handle, dx, dy, expectedDX, expectedDY, msg ) { - TestHelpers.draggable.testDragPosition( el, dx, dy, expectedDX, expectedDY, msg ); - TestHelpers.draggable.testDragOffset( el, dx, dy, expectedDX, expectedDY, msg ); + this.testDragPosition( el, dx, dy, expectedDX, expectedDY, msg ); + this.testDragOffset( el, dx, dy, expectedDX, expectedDY, msg ); $( handle ).simulate( "drag", { dx: dx, dy: dy }); }, + shouldMovePositionButNotOffset: function( el, msg, handle ) { handle = handle || el; - TestHelpers.draggable.testDragPosition( el, 100, 100, 100, 100, msg ); - TestHelpers.draggable.testDragHelperOffset( el, 100, 100, 0, 0, msg ); + this.testDragPosition( el, 100, 100, 100, 100, msg ); + this.testDragHelperOffset( el, 100, 100, 0, 0, msg ); $( handle ).simulate( "drag", { dx: 100, dy: 100 }); }, + shouldMove: function( el, msg, handle ) { handle = handle || el; - TestHelpers.draggable.testDrag( el, handle, 100, 100, 100, 100, msg ); + this.testDrag( el, handle, 100, 100, 100, 100, msg ); }, + shouldNotMove: function( el, msg, handle ) { handle = handle || el; - TestHelpers.draggable.testDrag( el, handle, 100, 100, 0, 0, msg ); + this.testDrag( el, handle, 100, 100, 0, 0, msg ); }, + shouldNotDrag: function( el, msg, handle ) { handle = handle || el; @@ -68,7 +84,7 @@ TestHelpers.draggable = { element = $( el ), beginOffset = element.offset(); - element.bind( "dragstop", function() { + element.on( "dragstop", function() { ok( false, "should not drag " + msg ); }); @@ -84,48 +100,59 @@ TestHelpers.draggable = { equal( newOffset.left, beginOffset.left, "Offset left should not be different" ); equal( newOffset.top, beginOffset.top, "Offset top should not be different" ); - element.unbind( "dragstop" ); + element.off( "dragstop" ); }, + setScrollable: function( what, isScrollable ) { var overflow = isScrollable ? "scroll" : "hidden"; $( what ).css({ overflow: overflow, overflowX: overflow, overflowY: overflow }); }, + testScroll: function( el, position ) { var oldPosition = $( "#main" ).css( "position" ); $( "#main" ).css({ position: position, top: "0px", left: "0px" }); - TestHelpers.draggable.shouldMove( el, position + " parent" ); + this.shouldMove( el, position + " parent" ); $( "#main" ).css( "position", oldPosition ); }, + restoreScroll: function( what ) { $( what ).scrollTop( 0 ).scrollLeft( 0 ); }, + setScroll: function( what ) { $( what ).scrollTop( 100 ).scrollLeft( 100 ); }, + border: function( el, side ) { return parseInt( el.css( "border-" + side + "-width" ), 10 ) || 0; }, + margin: function( el, side ) { return parseInt( el.css( "margin-" + side ), 10 ) || 0; }, + move: function( el, x, y ) { $( el ).simulate( "drag", { dx: x, dy: y }); }, + trackMouseCss: function( el ) { - el.bind( "drag", function() { + el.on( "drag", function() { el.data( "last_dragged_cursor", $( "body" ).css( "cursor" ) ); }); }, + trackAppendedParent: function( el ) { // TODO: appendTo is currently ignored if helper is original (see #7044) el.draggable( "option", "helper", "clone" ); // Get what parent is at time of drag - el.bind( "drag", function(e, ui) { + el.on( "drag", function(e, ui) { el.data( "last_dragged_parent", ui.helper.parent()[ 0 ] ); }); } -}; +} ); + +} ); diff --git a/tests/unit/draggable/draggable_methods.js b/tests/unit/draggable/methods.js similarity index 72% rename from tests/unit/draggable/draggable_methods.js rename to tests/unit/draggable/methods.js index 351d57764..195e9e2fb 100644 --- a/tests/unit/draggable/draggable_methods.js +++ b/tests/unit/draggable/methods.js @@ -1,7 +1,8 @@ -/* - * draggable_methods.js - */ -(function( $ ) { +define( [ + "jquery", + "./helper", + "ui/draggable" +], function( $, testHelper ) { var element; @@ -54,50 +55,50 @@ test( "enable", function() { expect( 11 ); element.draggable({ disabled: true }); - TestHelpers.draggable.shouldNotDrag( element, ".draggable({ disabled: true })" ); + testHelper.shouldNotDrag( element, ".draggable({ disabled: true })" ); element.draggable("enable"); - TestHelpers.draggable.shouldMove( element, ".draggable('enable')" ); + testHelper.shouldMove( element, ".draggable('enable')" ); equal( element.draggable( "option", "disabled" ), false, "disabled option getter" ); element.draggable("destroy"); element.draggable({ disabled: true }); - TestHelpers.draggable.shouldNotDrag( element, ".draggable({ disabled: true })" ); + testHelper.shouldNotDrag( element, ".draggable({ disabled: true })" ); element.draggable( "option", "disabled", false ); equal(element.draggable( "option", "disabled" ), false, "disabled option setter" ); - TestHelpers.draggable.shouldMove( element, ".draggable('option', 'disabled', false)" ); + testHelper.shouldMove( element, ".draggable('option', 'disabled', false)" ); var expected = element.draggable(), actual = expected.draggable("enable"); equal( actual, expected, "enable is chainable" ); }); -test( "disable", function() { +test( "disable", function( assert ) { expect( 14 ); element = $( "#draggable2" ).draggable({ disabled: false }); - TestHelpers.draggable.shouldMove( element, ".draggable({ disabled: false })" ); + testHelper.shouldMove( element, ".draggable({ disabled: false })" ); element.draggable( "disable" ); - TestHelpers.draggable.shouldNotDrag( element, ".draggable('disable')" ); + testHelper.shouldNotDrag( element, ".draggable('disable')" ); equal( element.draggable( "option", "disabled" ), true, "disabled option getter" ); element.draggable( "destroy" ); element.draggable({ disabled: false }); - TestHelpers.draggable.shouldMove( element, ".draggable({ disabled: false })" ); + testHelper.shouldMove( element, ".draggable({ disabled: false })" ); element.draggable( "option", "disabled", true ); equal( element.draggable( "option", "disabled" ), true, "disabled option setter" ); - TestHelpers.draggable.shouldNotDrag( element, ".draggable('option', 'disabled', true)" ); + testHelper.shouldNotDrag( element, ".draggable('option', 'disabled', true)" ); - ok( !element.draggable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" ); + assert.lacksClasses( element.draggable( "widget" ), "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" ); + assert.hasClasses( element.draggable( "widget" ), "ui-draggable-disabled" ); var expected = element.draggable(), actual = expected.draggable( "disable" ); equal( actual, expected, "disable is chainable" ); }); -})( jQuery ); +} ); diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/options.js similarity index 76% rename from tests/unit/draggable/draggable_options.js rename to tests/unit/draggable/options.js index d8bbedc91..877b4275c 100644 --- a/tests/unit/draggable/draggable_options.js +++ b/tests/unit/draggable/options.js @@ -1,15 +1,19 @@ -(function( $ ) { - -module( "draggable: options" ); +define( [ + "jquery", + "./helper", + "ui/draggable", + "ui/droppable", + "ui/sortable" +], function( $, testHelper ) { // TODO: This doesn't actually test whether append happened, possibly remove test( "{ appendTo: 'parent' }, default, no clone", function() { expect( 4 ); var element = $( "#draggable2" ).draggable({ appendTo: "parent" }); - TestHelpers.draggable.shouldMove( element, "absolute appendTo: parent" ); + testHelper.shouldMove( element, "absolute appendTo: parent" ); element = $( "#draggable1" ).draggable({ appendTo: "parent" }); - TestHelpers.draggable.shouldMove( element, "relative appendTo: parent" ); + testHelper.shouldMove( element, "relative appendTo: parent" ); }); // TODO: This doesn't actually test whether append happened, possibly remove @@ -17,20 +21,20 @@ test( "{ appendTo: Element }, no clone", function() { expect( 4 ); var element = $( "#draggable2" ).draggable({ appendTo: $( "#draggable2" ).parent()[ 0 ] }); - TestHelpers.draggable.shouldMove( element, "absolute appendTo: Element" ); + testHelper.shouldMove( element, "absolute appendTo: Element" ); element = $( "#draggable1" ).draggable({ appendTo: $( "#draggable2" ).parent()[ 0 ] }); - TestHelpers.draggable.shouldMove( element, "relative appendTo: Element" ); + testHelper.shouldMove( element, "relative appendTo: Element" ); }); // TODO: This doesn't actually test whether append happened, possibly remove test( "{ appendTo: Selector }, no clone", function() { expect( 4 ); var element = $( "#draggable2" ).draggable({ appendTo: "#main" }); - TestHelpers.draggable.shouldMove( element, "absolute appendTo: Selector" ); + testHelper.shouldMove( element, "absolute appendTo: Selector" ); element = $( "#draggable1" ).draggable({ appendTo: "#main" }); - TestHelpers.draggable.shouldMove( element, "relative appendTo: Selector" ); + testHelper.shouldMove( element, "relative appendTo: Selector" ); }); test( "{ appendTo: 'parent' }, default", function() { @@ -38,11 +42,11 @@ test( "{ appendTo: 'parent' }, default", function() { var element = $( "#draggable1" ).draggable(); - TestHelpers.draggable.trackAppendedParent( element ); + testHelper.trackAppendedParent( element ); equal( element.draggable( "option", "appendTo" ), "parent" ); - TestHelpers.draggable.move( element, 1, 1 ); + testHelper.move( element, 1, 1 ); equal( element.data( "last_dragged_parent" ), $( "#main" )[ 0 ] ); }); @@ -52,9 +56,9 @@ test( "{ appendTo: Element }", function() { var appendTo = $( "#draggable2" ).parent()[ 0 ], element = $( "#draggable1" ).draggable({ appendTo: appendTo }); - TestHelpers.draggable.trackAppendedParent( element ); + testHelper.trackAppendedParent( element ); - TestHelpers.draggable.move( element, 1, 1 ); + testHelper.move( element, 1, 1 ); equal( element.data( "last_dragged_parent" ), appendTo ); }); @@ -64,9 +68,9 @@ test( "{ appendTo: jQuery }", function() { var appendTo = $( "#draggable2" ).parent(), element = $( "#draggable1" ).draggable({ appendTo: appendTo }); - TestHelpers.draggable.trackAppendedParent( element ); + testHelper.trackAppendedParent( element ); - TestHelpers.draggable.move( element, 1, 1 ); + testHelper.move( element, 1, 1 ); equal( element.data( "last_dragged_parent" ), appendTo[ 0 ] ); }); @@ -76,9 +80,9 @@ test( "{ appendTo: Selector }", function() { var appendTo = "#main", element = $( "#draggable1" ).draggable({ appendTo: appendTo }); - TestHelpers.draggable.trackAppendedParent( element ); + testHelper.trackAppendedParent( element ); - TestHelpers.draggable.move( element, 1, 1 ); + testHelper.move( element, 1, 1 ); equal( element.data( "last_dragged_parent" ), $(appendTo)[ 0 ] ); }); @@ -87,34 +91,34 @@ test( "appendTo, default, switching after initialization", function() { var element = $( "#draggable1" ).draggable({ helper: "clone" }); - TestHelpers.draggable.trackAppendedParent( element ); + testHelper.trackAppendedParent( element ); // Move and make sure element was appended to fixture - TestHelpers.draggable.move( element, 1, 1 ); + testHelper.move( element, 1, 1 ); equal( element.data( "last_dragged_parent" ), $( "#main" )[ 0 ] ); // Move and make sure element was appended to main element.draggable( "option", "appendTo", $( "#qunit-fixture" ) ); - TestHelpers.draggable.move( element, 2, 2 ); + testHelper.move( element, 2, 2 ); equal( element.data( "last_dragged_parent" ), $( "#qunit-fixture" )[ 0 ] ); }); test( "{ axis: false }, default", function() { expect( 2 ); var element = $( "#draggable2" ).draggable({ axis: false }); - TestHelpers.draggable.shouldMove( element, "axis: false" ); + testHelper.shouldMove( element, "axis: false" ); }); test( "{ axis: 'x' }", function() { expect( 2 ); var element = $( "#draggable2" ).draggable({ axis: "x" }); - TestHelpers.draggable.testDrag( element, element, 50, 50, 50, 0, "axis: x" ); + testHelper.testDrag( element, element, 50, 50, 50, 0, "axis: x" ); }); test( "{ axis: 'y' }", function() { expect( 2 ); var element = $( "#draggable2" ).draggable({ axis: "y" }); - TestHelpers.draggable.testDrag( element, element, 50, 50, 0, 50, "axis: y" ); + testHelper.testDrag( element, element, 50, 50, 0, 50, "axis: y" ); }); test( "{ axis: ? }, unexpected", function() { @@ -132,7 +136,7 @@ test( "{ axis: ? }, unexpected", function() { $.each(unexpected, function(key, val) { element = $( "#draggable2" ).draggable({ axis: val }); - TestHelpers.draggable.shouldMove( element, "axis: " + key ); + testHelper.shouldMove( element, "axis: " + key ); element.draggable( "destroy" ); }); }); @@ -143,15 +147,15 @@ test( "axis, default, switching after initialization", function() { var element = $( "#draggable1" ).draggable({ axis: false }); // Any Direction - TestHelpers.draggable.shouldMove( element, "axis: default" ); + testHelper.shouldMove( element, "axis: default" ); // Only horizontal element.draggable( "option", "axis", "x" ); - TestHelpers.draggable.testDrag( element, element, 50, 50, 50, 0, "axis: x as option" ); + testHelper.testDrag( element, element, 50, 50, 50, 0, "axis: x as option" ); // Vertical only element.draggable( "option", "axis", "y" ); - TestHelpers.draggable.testDrag( element, element, 50, 50, 0, 50, "axis: y as option" ); + testHelper.testDrag( element, element, 50, 50, 0, 50, "axis: y as option" ); }); @@ -161,12 +165,12 @@ test( "{ cancel: 'input,textarea,button,select,option' }, default", function() { $( "
" ).appendTo( "#qunit-fixture" ); var element = $( "#draggable-option-cancel-default" ).draggable({ cancel: "input,textarea,button,select,option" }); - TestHelpers.draggable.shouldMove( element, "cancel: default, element dragged" ); + testHelper.shouldMove( element, "cancel: default, element dragged" ); element.draggable( "destroy" ); element = $( "#draggable-option-cancel-default" ).draggable({ cancel: "input,textarea,button,select,option" }); - TestHelpers.draggable.shouldNotDrag( element, "cancel: default, input dragged", "#draggable-option-cancel-default input" ); + testHelper.shouldNotDrag( element, "cancel: default, input dragged", "#draggable-option-cancel-default input" ); element.draggable( "destroy" ); }); @@ -174,12 +178,12 @@ test( "{ cancel: 'span' }", function() { expect( 4 ); var element = $( "#draggable2" ).draggable(); - TestHelpers.draggable.shouldMove( element, "cancel: default, span dragged", "#draggable2 span" ); + testHelper.shouldMove( element, "cancel: default, span dragged", "#draggable2 span" ); element.draggable( "destroy" ); element = $( "#draggable2" ).draggable({ cancel: "span" }); - TestHelpers.draggable.shouldNotDrag( element, "cancel: span, span dragged", "#draggable2 span" ); + testHelper.shouldNotDrag( element, "cancel: span, span dragged", "#draggable2 span" ); }); test( "{ cancel: ? }, unexpected", function() { @@ -197,7 +201,7 @@ test( "{ cancel: ? }, unexpected", function() { $.each( unexpected, function( key, val ) { element = $( "#draggable2" ).draggable({ cancel: val }); - TestHelpers.draggable.shouldMove( element, "cancel: " + key ); + testHelper.shouldMove( element, "cancel: " + key ); element.draggable( "destroy" ); }); }); @@ -215,15 +219,15 @@ test( "{ cancel: Selectors }, matching parent selector", function() { $( "#wrapping a" ).append( element ); - TestHelpers.draggable.shouldMove( element, "drag span child", "#draggable2 span" ); - TestHelpers.draggable.shouldNotDrag( $( "#draggable2 span a" ), "drag span a" ); - TestHelpers.draggable.shouldNotDrag( $( "#wrapping a" ), "drag wrapping a" ); + testHelper.shouldMove( element, "drag span child", "#draggable2 span" ); + testHelper.shouldNotDrag( $( "#draggable2 span a" ), "drag span a" ); + testHelper.shouldNotDrag( $( "#wrapping a" ), "drag wrapping a" ); $( "#draggable2" ).draggable( "option", "cancel", "span > a" ); $( "#draggable2" ).find( "a" ).append( "" ); - TestHelpers.draggable.shouldMove( element, "drag span child", $( "#draggable2 span a" ).last() ); - TestHelpers.draggable.shouldNotDrag( $( "#draggable2 span a" ).first(), "drag span a first child" ); + testHelper.shouldMove( element, "drag span child", $( "#draggable2 span a" ).last() ); + testHelper.shouldNotDrag( $( "#draggable2 span a" ).first(), "drag span a first child" ); }); */ @@ -235,13 +239,13 @@ test( "cancelement, default, switching after initialization", function() { var input = $( "#draggable-option-cancel-default input" ), element = $( "#draggable-option-cancel-default" ).draggable(); - TestHelpers.draggable.shouldNotDrag( element, "cancel: default, input dragged", input ); + testHelper.shouldNotDrag( element, "cancel: default, input dragged", input ); element.draggable( "option", "cancel", "textarea" ); - TestHelpers.draggable.shouldMove( element, "cancel: textarea, input dragged", input ); + testHelper.shouldMove( element, "cancel: textarea, input dragged", input ); element.draggable( "option", "cancel", "input" ); - TestHelpers.draggable.shouldNotDrag( element, "cancel: input, input dragged", input ); + testHelper.shouldNotDrag( element, "cancel: input, input dragged", input ); }); test( "connectToSortable, dragging out of a sortable", function() { @@ -436,8 +440,8 @@ test( "{ containment: Element }", function() { p = element.parent(), po = p.offset(), expected = { - left: po.left + TestHelpers.draggable.border( p, "left" ) + TestHelpers.draggable.margin( element, "left" ), - top: po.top + TestHelpers.draggable.border( p, "top" ) + TestHelpers.draggable.margin( element, "top" ) + left: po.left + testHelper.border( p, "left" ) + testHelper.margin( element, "left" ), + top: po.top + testHelper.border( p, "top" ) + testHelper.margin( element, "top" ) }; element.simulate( "drag", { @@ -456,8 +460,8 @@ test( "{ containment: Selector }", function() { p = element.parent(), po = p.offset(), expected = { - left: po.left + TestHelpers.draggable.border( p, "left" ) + TestHelpers.draggable.margin( element, "left" ), - top: po.top + TestHelpers.draggable.border( p, "top" ) + TestHelpers.draggable.margin( element, "top" ) + left: po.left + testHelper.border( p, "left" ) + testHelper.margin( element, "left" ), + top: po.top + testHelper.border( p, "top" ) + testHelper.margin( element, "top" ) }; element.simulate( "drag", { @@ -476,7 +480,7 @@ test( "{ containment: [x1, y1, x2, y2] }", function() { element.draggable( "option", "containment", [ eo.left, eo.top, eo.left + element.width() + 5, eo.top + element.height() + 5 ] ); - TestHelpers.draggable.testDrag( element, element, -100, -100, 0, 0, "containment: [x1, y1, x2, y2]" ); + testHelper.testDrag( element, element, -100, -100, 0, 0, "containment: [x1, y1, x2, y2]" ); }); test( "{ containment: 'parent' }, relative", function() { @@ -487,8 +491,8 @@ test( "{ containment: 'parent' }, relative", function() { p = element.parent(), po = p.offset(), expected = { - left: po.left + TestHelpers.draggable.border( p, "left" ) + TestHelpers.draggable.margin( element, "left" ), - top: po.top + TestHelpers.draggable.border( p, "top" ) + TestHelpers.draggable.margin( element, "top" ) + left: po.left + testHelper.border( p, "left" ) + testHelper.margin( element, "left" ), + top: po.top + testHelper.border( p, "top" ) + testHelper.margin( element, "top" ) }; element.simulate( "drag", { @@ -507,8 +511,8 @@ test( "{ containment: 'parent' }, absolute", function() { p = element.parent(), po = p.offset(), expected = { - left: po.left + TestHelpers.draggable.border( p, "left" ) + TestHelpers.draggable.margin( element, "left" ), - top: po.top + TestHelpers.draggable.border( p, "top" ) + TestHelpers.draggable.margin( element, "top" ) + left: po.left + testHelper.border( p, "left" ) + testHelper.margin( element, "left" ), + top: po.top + testHelper.border( p, "top" ) + testHelper.margin( element, "top" ) }; element.simulate( "drag", { @@ -519,7 +523,7 @@ test( "{ containment: 'parent' }, absolute", function() { deepEqual( offsetAfter, expected, "compare offset to parent" ); }); -test( "containment, account for border", function() { +test( "containment, account for border", function( assert ) { expect( 2 ); var el = $( "#draggable1" ).appendTo( "#scrollParent" ), @@ -531,8 +535,8 @@ test( "containment, account for border", function() { }), parentBottom = parent.offset().top + parent.outerHeight(), parentRight = parent.offset().left + parent.outerWidth(), - parentBorderBottom = TestHelpers.draggable.border( parent, "bottom" ), - parentBorderRight = TestHelpers.draggable.border( parent, "right" ); + parentBorderBottom = testHelper.border( parent, "bottom" ), + parentBorderRight = testHelper.border( parent, "right" ); el.css({ height: "5px", @@ -544,9 +548,9 @@ test( "containment, account for border", function() { dy: 100 }); - closeEnough( el.offset().top, parentBottom - parentBorderBottom - el.height(), 1, + assert.close( el.offset().top, parentBottom - parentBorderBottom - el.height(), 1, "The draggable should be on top of its parent's bottom border" ); - closeEnough( el.offset().left, parentRight - parentBorderRight - el.width(), 1, + assert.close( el.offset().left, parentRight - parentBorderRight - el.width(), 1, "The draggable should be to the right of its parent's right border" ); }); @@ -587,16 +591,16 @@ test( "containment, default, switching after initialization", function() { po = element.parent().offset(), containment = [ po.left - 100, po.top - 100, po.left + 500, po.top + 500 ]; - TestHelpers.draggable.testDrag( element, element, -100, -100, -100, -100, "containment: default" ); + testHelper.testDrag( element, element, -100, -100, -100, -100, "containment: default" ); element.draggable( "option", "containment", "parent" ).css({ top: 0, left: 0 }); - TestHelpers.draggable.testDrag( element, element, -100, -100, 0, 0, "containment: parent as option" ); + testHelper.testDrag( element, element, -100, -100, 0, 0, "containment: parent as option" ); element.draggable( "option", "containment", containment ).css({ top: 0, left: 0 }); - TestHelpers.draggable.testDrag( element, element, -100, -100, -100, -100, "containment: array as option" ); + testHelper.testDrag( element, element, -100, -100, -100, -100, "containment: array as option" ); element.draggable( "option", "containment", false ); - TestHelpers.draggable.testDrag( element, element, -100, -100, -100, -100, "containment: false as option" ); + testHelper.testDrag( element, element, -100, -100, -100, -100, "containment: false as option" ); }); test( "{ cursor: 'auto' }, default", function() { @@ -674,7 +678,7 @@ test( "#6889: Cursor doesn't revert to pre-dragging state after revert action wh }), expected = getCursor(); - if ( TestHelpers.draggable.unreliableContains ) { + if ( testHelper.unreliableContains ) { ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" ); ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" ); } else { @@ -690,17 +694,17 @@ test( "cursor, default, switching after initialization", function() { var element = $( "#draggable1" ).draggable(); - TestHelpers.draggable.trackMouseCss( element ); + testHelper.trackMouseCss( element ); - TestHelpers.draggable.move( element, 1, 1 ); + testHelper.move( element, 1, 1 ); equal( element.data( "last_dragged_cursor" ), "auto" ); element.draggable( "option", "cursor", "move" ); - TestHelpers.draggable.move( element, 1, 1 ); + testHelper.move( element, 1, 1 ); equal( element.data( "last_dragged_cursor" ), "move" ); element.draggable( "option", "cursor", "ns-resize" ); - TestHelpers.draggable.move( element, 1, 1 ); + testHelper.move( element, 1, 1 ); equal( element.data( "last_dragged_cursor" ), "ns-resize" ); }); @@ -727,11 +731,11 @@ test( "cursorAt", function() { equal( ui.position.left - ui.originalPosition.left, deltaX, testName + " " + position + " left" ); equal( ui.position.top - ui.originalPosition.top, deltaY, testName + " " + position + " top" ); } else if ( testData.cursorAt.right ) { - equal( ui.helper.width() - ( event.clientX - ui.offset.left ), testData.x - TestHelpers.draggable.unreliableOffset, testName + " " + position + " left" ); - equal( ui.helper.height() - ( event.clientY - ui.offset.top ), testData.y - TestHelpers.draggable.unreliableOffset, testName + " " + position + " top" ); + equal( ui.helper.width() - ( event.clientX - ui.offset.left ), testData.x - testHelper.unreliableOffset, testName + " " + position + " left" ); + equal( ui.helper.height() - ( event.clientY - ui.offset.top ), testData.y - testHelper.unreliableOffset, testName + " " + position + " top" ); } else { - equal( event.clientX - ui.offset.left, testData.x + TestHelpers.draggable.unreliableOffset, testName + " " + position + " left" ); - equal( event.clientY - ui.offset.top, testData.y + TestHelpers.draggable.unreliableOffset, testName + " " + position + " top" ); + equal( event.clientX - ui.offset.left, testData.x + testHelper.unreliableOffset, testName + " " + position + " left" ); + equal( event.clientY - ui.offset.top, testData.y + testHelper.unreliableOffset, testName + " " + position + " top" ); } } }); @@ -769,11 +773,11 @@ test( "cursorAt, switching after initialization", function() { equal( ui.position.left - ui.originalPosition.left, deltaX, testName + " " + position + " left" ); equal( ui.position.top - ui.originalPosition.top, deltaY, testName + " " + position + " top" ); } else if ( testData.cursorAt.right ) { - equal( ui.helper.width() - ( event.clientX - ui.offset.left ), testData.x - TestHelpers.draggable.unreliableOffset, testName + " " + position + " left" ); - equal( ui.helper.height() - ( event.clientY - ui.offset.top ), testData.y - TestHelpers.draggable.unreliableOffset, testName + " " + position + " top" ); + equal( ui.helper.width() - ( event.clientX - ui.offset.left ), testData.x - testHelper.unreliableOffset, testName + " " + position + " left" ); + equal( ui.helper.height() - ( event.clientY - ui.offset.top ), testData.y - testHelper.unreliableOffset, testName + " " + position + " top" ); } else { - equal( event.clientX - ui.offset.left, testData.x + TestHelpers.draggable.unreliableOffset, testName + " " + position + " left" ); - equal( event.clientY - ui.offset.top, testData.y + TestHelpers.draggable.unreliableOffset, testName + " " + position + " top" ); + equal( event.clientX - ui.offset.left, testData.x + testHelper.unreliableOffset, testName + " " + position + " left" ); + equal( event.clientY - ui.offset.top, testData.y + testHelper.unreliableOffset, testName + " " + position + " top" ); } } }); @@ -795,29 +799,29 @@ test( "disabled", function() { var element = $( "#draggable1" ).draggable(); - TestHelpers.draggable.shouldMove( element, "disabled: default" ); + testHelper.shouldMove( element, "disabled: default" ); element.draggable( "option", "disabled", true ); - TestHelpers.draggable.shouldNotDrag( element, "option: disabled true" ); + testHelper.shouldNotDrag( element, "option: disabled true" ); element.draggable( "option", "disabled", false ); - TestHelpers.draggable.shouldMove( element, "option: disabled false" ); + testHelper.shouldMove( element, "option: disabled false" ); }); test( "{ grid: [50, 50] }, relative", function() { expect( 4 ); var element = $( "#draggable1" ).draggable({ grid: [ 50, 50 ] }); - TestHelpers.draggable.testDrag( element, element, 24, 24, 0, 0, "grid: [50, 50] relative" ); - TestHelpers.draggable.testDrag( element, element, 26, 25, 50, 50, "grid: [50, 50] relative" ); + testHelper.testDrag( element, element, 24, 24, 0, 0, "grid: [50, 50] relative" ); + testHelper.testDrag( element, element, 26, 25, 50, 50, "grid: [50, 50] relative" ); }); test( "{ grid: [50, 50] }, absolute", function() { expect( 4 ); var element = $( "#draggable2" ).draggable({ grid: [ 50, 50 ] }); - TestHelpers.draggable.testDrag( element, element, 24, 24, 0, 0, "grid: [50, 50] absolute" ); - TestHelpers.draggable.testDrag( element, element, 26, 25, 50, 50, "grid: [50, 50] absolute" ); + testHelper.testDrag( element, element, 24, 24, 0, 0, "grid: [50, 50] absolute" ); + testHelper.testDrag( element, element, 26, 25, 50, 50, "grid: [50, 50] absolute" ); }); test( "grid, switching after initialization", function() { @@ -826,13 +830,13 @@ test( "grid, switching after initialization", function() { var element = $( "#draggable1" ).draggable(); // Forward - TestHelpers.draggable.testDrag( element, element, 24, 24, 24, 24, "grid: default" ); - TestHelpers.draggable.testDrag( element, element, 0, 0, 0, 0, "grid: default" ); + testHelper.testDrag( element, element, 24, 24, 24, 24, "grid: default" ); + testHelper.testDrag( element, element, 0, 0, 0, 0, "grid: default" ); element.draggable( "option", "grid", [ 50, 50 ] ); - TestHelpers.draggable.testDrag( element, element, 24, 24, 0, 0, "grid: [50, 50] as option" ); - TestHelpers.draggable.testDrag( element, element, 26, 25, 50, 50, "grid: [50, 50] as option" ); + testHelper.testDrag( element, element, 24, 24, 0, 0, "grid: [50, 50] as option" ); + testHelper.testDrag( element, element, 26, 25, 50, 50, "grid: [50, 50] as option" ); }); test( "{ handle: 'span' }", function() { @@ -840,9 +844,9 @@ test( "{ handle: 'span' }", function() { var element = $( "#draggable2" ).draggable({ handle: "span" }); - TestHelpers.draggable.shouldMove( element, "handle: span", "#draggable2 span"); - TestHelpers.draggable.shouldMove( element, "handle: span child", "#draggable2 span em" ); - TestHelpers.draggable.shouldNotDrag( element, "handle: span element" ); + testHelper.shouldMove( element, "handle: span", "#draggable2 span"); + testHelper.shouldMove( element, "handle: span child", "#draggable2 span em" ); + testHelper.shouldNotDrag( element, "handle: span element" ); }); test( "handle, default, switching after initialization", function() { @@ -850,31 +854,31 @@ test( "handle, default, switching after initialization", function() { var element = $( "#draggable2" ).draggable(); - TestHelpers.draggable.shouldMove( element, "handle: default, element dragged" ); - TestHelpers.draggable.shouldMove( element, "handle: default, span dragged", "#draggable2 span" ); + testHelper.shouldMove( element, "handle: default, element dragged" ); + testHelper.shouldMove( element, "handle: default, span dragged", "#draggable2 span" ); // Switch element.draggable( "option", "handle", "span" ); - TestHelpers.draggable.shouldNotDrag( element, "handle: span as option, element dragged" ); - TestHelpers.draggable.shouldMove( element, "handle: span as option, span dragged", "#draggable2 span" ); + testHelper.shouldNotDrag( element, "handle: span as option, element dragged" ); + testHelper.shouldMove( element, "handle: span as option, span dragged", "#draggable2 span" ); // And back element.draggable( "option", "handle", false ); - TestHelpers.draggable.shouldMove( element, "handle: false as option, element dragged" ); - TestHelpers.draggable.shouldMove( element, "handle: false as option, span dragged", "#draggable2 span" ); + testHelper.shouldMove( element, "handle: false as option, element dragged" ); + testHelper.shouldMove( element, "handle: false as option, span dragged", "#draggable2 span" ); }); test( "helper, default, switching after initialization", function() { expect( 6 ); var element = $( "#draggable1" ).draggable(); - TestHelpers.draggable.shouldMove( element, "helper: default" ); + testHelper.shouldMove( element, "helper: default" ); element.draggable( "option", "helper", "clone" ); - TestHelpers.draggable.shouldMove( element, "helper: clone" ); + testHelper.shouldMove( element, "helper: clone" ); element.draggable( "option", "helper", "original" ); - TestHelpers.draggable.shouldMove( element, "helper: original" ); + testHelper.shouldMove( element, "helper: original" ); }); // http://bugs.jqueryui.com/ticket/9446 @@ -888,7 +892,7 @@ test( "helper, function returning original element", function() { } }); - TestHelpers.draggable.testDragHelperOffset( element, 100, 100, 100, 100, "original element is draggable" ); + testHelper.testDragHelperOffset( element, 100, 100, 100, 100, "original element is draggable" ); element.simulate( "drag", { dx: 100, @@ -907,25 +911,25 @@ function testHelperPosition( scrollPositions, position, helper, scrollElements, }); if ( scrollElements.length === 1 && scrollElements[ 0 ] === "#scrollParent" ) { - TestHelpers.draggable.setScrollable( "#main", false ); - TestHelpers.draggable.setScrollable( "#scrollParent", true ); + testHelper.setScrollable( "#main", false ); + testHelper.setScrollable( "#scrollParent", true ); } for ( j = 0; j < scrollPositions.length; j++ ) { for ( i = 0; i < scrollElements.length; i++ ) { - TestHelpers.draggable.setScroll( scrollElements[ i ] ); + testHelper.setScroll( scrollElements[ i ] ); } - TestHelpers.draggable.testScroll( element, scrollPositions[ j ] ); + testHelper.testScroll( element, scrollPositions[ j ] ); for ( i = 0; i < scrollElements.length; i++ ) { - TestHelpers.draggable.restoreScroll( scrollElements[ i ] ); + testHelper.restoreScroll( scrollElements[ i ] ); } } if ( scrollElements.length === 1 && scrollElements[ 1 ] === "#scrollParent" ) { - TestHelpers.draggable.setScrollable( "#main", true ); - TestHelpers.draggable.setScrollable( "#scrollParent", false ); + testHelper.setScrollable( "#main", true ); + testHelper.setScrollable( "#scrollParent", false ); } }); } @@ -983,15 +987,15 @@ test( "opacity, default, switching after initialization", function() { } }); - TestHelpers.draggable.move( element, 1, 1 ); + testHelper.move( element, 1, 1 ); equal( opacity, 1 ); element.draggable( "option", "opacity", 0.5 ); - TestHelpers.draggable.move( element, 2, 1 ); + testHelper.move( element, 2, 1 ); equal( opacity, 0.5 ); element.draggable( "option", "opacity", false ); - TestHelpers.draggable.move( element, 3, 1 ); + testHelper.move( element, 3, 1 ); equal( opacity, 1 ); }); @@ -1002,13 +1006,13 @@ asyncTest( "revert and revertDuration", function() { revert: true, revertDuration: 0 }); - TestHelpers.draggable.shouldMovePositionButNotOffset( element, "revert: true, revertDuration: 0 should revert immediately" ); + testHelper.shouldMovePositionButNotOffset( element, "revert: true, revertDuration: 0 should revert immediately" ); $( "#draggable2" ).draggable( "option", "revert", "invalid" ); - TestHelpers.draggable.shouldMovePositionButNotOffset( element, "revert: invalid, revertDuration: 0 should revert immediately" ); + testHelper.shouldMovePositionButNotOffset( element, "revert: invalid, revertDuration: 0 should revert immediately" ); $( "#draggable2" ).draggable( "option", "revert", false ); - TestHelpers.draggable.shouldMove( element, "revert: false should allow movement" ); + testHelper.shouldMove( element, "revert: false should allow movement" ); $( "#draggable2" ).draggable( "option", { revert: true, @@ -1019,7 +1023,7 @@ asyncTest( "revert and revertDuration", function() { }); // animation are async, so test for it asynchronously - TestHelpers.draggable.move( element, 50, 50 ); + testHelper.move( element, 50, 50 ); setTimeout( function() { ok( $( "#draggable2" ).is( ":animated" ), "revert: true with revertDuration should animate" ); }); @@ -1035,7 +1039,7 @@ test( "revert: valid", function() { $( "#droppable" ).droppable(); - TestHelpers.draggable.shouldMovePositionButNotOffset( element, "revert: valid reverts when dropped on a droppable" ); + testHelper.shouldMovePositionButNotOffset( element, "revert: valid reverts when dropped on a droppable" ); }); test( "scope", function() { @@ -1049,17 +1053,17 @@ test( "scope", function() { $( "#droppable" ).droppable({ scope: "tasks" }); - TestHelpers.draggable.shouldMovePositionButNotOffset( element, "revert: valid reverts when dropped on a droppable in scope" ); + testHelper.shouldMovePositionButNotOffset( element, "revert: valid reverts when dropped on a droppable in scope" ); $( "#droppable" ).droppable( "destroy" ).droppable({ scope: "nottasks" }); - TestHelpers.draggable.shouldMove( element, "revert: valid reverts when dropped on a droppable out of scope" ); + testHelper.shouldMove( element, "revert: valid reverts when dropped on a droppable out of scope" ); }); test( "scroll, scrollSensitivity, and scrollSpeed", function() { expect( 2 ); - TestHelpers.draggable.setScrollable( "#main", false ); + testHelper.setScrollable( "#main", false ); var currentScrollTop, viewportHeight = $( window ).height(), @@ -1101,7 +1105,7 @@ test( "scroll, scrollSensitivity, and scrollSpeed", function() { moves: 1 }); - TestHelpers.draggable.restoreScroll( document ); + testHelper.restoreScroll( document ); }); test( "scroll ignores containers that are overflow: hidden", function() { @@ -1137,10 +1141,10 @@ test( "scroll ignores containers that are overflow: hidden", function() { equal( scrollParent.scrollLeft(), 0, "container doesn't scroll horizontally" ); }); -test( "#6817: auto scroll goes double distance when dragging", function() { +test( "#6817: auto scroll goes double distance when dragging", function( assert ) { expect( 2 ); - TestHelpers.draggable.restoreScroll( document ); + testHelper.restoreScroll( document ); var offsetBefore, distance = 10, @@ -1149,8 +1153,8 @@ test( "#6817: auto scroll goes double distance when dragging", function() { scroll: true, stop: function( e, ui ) { equal( ui.offset.top, newY, "offset of item matches pointer position after scroll" ); - // TODO: fix IE8 testswarm IFRAME positioning bug so closeEnough can be turned back to equal - closeEnough( ui.offset.top - offsetBefore.top, distance, 1, "offset of item only moves expected distance after scroll" ); + // TODO: fix IE8 testswarm IFRAME positioning bug so assert.close can be turned back to equal + assert.close( ui.offset.top - offsetBefore.top, distance, 1, "offset of item only moves expected distance after scroll" ); } }), scrollSensitivity = element.draggable( "option", "scrollSensitivity" ), @@ -1171,10 +1175,10 @@ test( "#6817: auto scroll goes double distance when dragging", function() { moves: 1 }); - TestHelpers.draggable.restoreScroll( document ); + testHelper.restoreScroll( document ); }); -test( "snap, snapMode, and snapTolerance", function() { +test( "snap, snapMode, and snapTolerance", function( assert ) { expect( 10 ); var newX, newY, @@ -1206,9 +1210,9 @@ test( "snap, snapMode, and snapTolerance", function() { moves: 1 }); - // TODO: fix IE8 testswarm IFRAME positioning bug so closeEnough can be turned back to equal - closeEnough( element.offset().left, newX, 1, "doesn't snap outside the snapTolerance" ); - closeEnough( element.offset().top, newY, 1, "doesn't snap outside the snapTolerance" ); + // TODO: fix IE8 testswarm IFRAME positioning bug so assert.close can be turned back to equal + assert.close( element.offset().left, newX, 1, "doesn't snap outside the snapTolerance" ); + assert.close( element.offset().top, newY, 1, "doesn't snap outside the snapTolerance" ); newX += 3; @@ -1301,7 +1305,7 @@ 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() { +test( "#8459: element can snap to an element that was removed during drag", function( assert ) { expect( 2 ); var newX, newY, @@ -1333,13 +1337,13 @@ test( "#8459: element can snap to an element that was removed during drag", func }); // Support: Opera 12.10, Safari 5.1, jQuery <1.8 - if ( TestHelpers.draggable.unreliableContains ) { + if ( testHelper.unreliableContains ) { ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" ); ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" ); } else { - // TODO: fix IE8 testswarm IFRAME positioning bug so closeEnough can be turned back to equal - closeEnough( element.offset().left, newX, 1, "doesn't snap to a removed element" ); - closeEnough( element.offset().top, newY, 1, "doesn't snap to a removed element" ); + // TODO: fix IE8 testswarm IFRAME positioning bug so assert.close can be turned back to equal + assert.close( element.offset().left, newX, 1, "doesn't snap to a removed element" ); + assert.close( element.offset().top, newY, 1, "doesn't snap to a removed element" ); } }); @@ -1390,10 +1394,10 @@ test( "stack", function() { stack: "#draggable1, #draggable2" }); - TestHelpers.draggable.move( element, 1, 1 ); + testHelper.move( element, 1, 1 ); equal( element.css( "zIndex" ), "2", "stack increments zIndex correctly" ); - TestHelpers.draggable.move( element2, 1, 1 ); + testHelper.move( element2, 1, 1 ); equal( element2.css( "zIndex" ), "3", "stack increments zIndex correctly" ); }); @@ -1431,15 +1435,15 @@ test( "zIndex, default, switching after initialization", function() { element.css( "z-index", 1 ); - TestHelpers.draggable.move( element, 1, 1 ); + testHelper.move( element, 1, 1 ); equal( zindex, 1 ); element.draggable( "option", "zIndex", 5 ); - TestHelpers.draggable.move( element, 2, 1 ); + testHelper.move( element, 2, 1 ); equal( zindex, 5 ); element.draggable( "option", "zIndex", false ); - TestHelpers.draggable.move( element, 3, 1 ); + testHelper.move( element, 3, 1 ); equal( zindex, 1 ); }); @@ -1486,4 +1490,4 @@ test( "iframeFix", function() { }); }); -})( jQuery ); +} ); diff --git a/tests/unit/droppable/all.html b/tests/unit/droppable/all.html index b8be47d0d..4934e13d1 100644 --- a/tests/unit/droppable/all.html +++ b/tests/unit/droppable/all.html @@ -7,9 +7,9 @@ - + - + + + + + + +
+
+ +
Draggable
+
Droppable
+
Droppable
+
 
+ +
+ + diff --git a/tests/unit/droppable/deprecated.js b/tests/unit/droppable/deprecated.js new file mode 100644 index 000000000..3931f5f06 --- /dev/null +++ b/tests/unit/droppable/deprecated.js @@ -0,0 +1 @@ +define( function() {} ); diff --git a/tests/unit/droppable/droppable.html b/tests/unit/droppable/droppable.html index 03ff888e8..5c3ec3dd9 100644 --- a/tests/unit/droppable/droppable.html +++ b/tests/unit/droppable/droppable.html @@ -4,32 +4,10 @@ jQuery UI Droppable Test Suite - - - - - - - - - - - - - - - + + + diff --git a/tests/unit/droppable/droppable_events.js b/tests/unit/droppable/events.js similarity index 89% rename from tests/unit/droppable/droppable_events.js rename to tests/unit/droppable/events.js index 0e1424245..a60d9292e 100644 --- a/tests/unit/droppable/droppable_events.js +++ b/tests/unit/droppable/events.js @@ -1,8 +1,11 @@ -(function( $ ) { +define( [ + "jquery", + "ui/droppable" +], function( $ ) { module( "droppable: events" ); -test( "droppable destruction/recreation on drop event", function() { +test( "droppable destruction/recreation on drop event", function( assert ) { expect( 1 ); var config = { @@ -32,7 +35,7 @@ test( "droppable destruction/recreation on drop event", function() { dy: dy }); - ok( !droppable2.hasClass( "active" ), "subsequent droppable no longer active" ); + assert.lacksClasses( droppable2, "active", "subsequent droppable no longer active" ); }); // todo: comment the following in when ready to actually test @@ -58,4 +61,4 @@ test("drop", function() { }); */ -})( jQuery ); +} ); diff --git a/tests/unit/droppable/droppable_test_helpers.js b/tests/unit/droppable/helper.js similarity index 71% rename from tests/unit/droppable/droppable_test_helpers.js rename to tests/unit/droppable/helper.js index ce972be63..460fa1aa6 100644 --- a/tests/unit/droppable/droppable_test_helpers.js +++ b/tests/unit/droppable/helper.js @@ -1,10 +1,18 @@ -TestHelpers.droppable = { +define( [ + "jquery", + "lib/helper" +], function( $, helper ) { + +return $.extend( helper, { shouldDrop: function() { // todo: actually implement this ok(true, "missing test - untested code is broken code"); }, + shouldNotDrop: function() { // todo: actually implement this ok(true, "missing test - untested code is broken code"); } -}; +} ); + +} ); diff --git a/tests/unit/droppable/droppable_methods.js b/tests/unit/droppable/methods.js similarity index 78% rename from tests/unit/droppable/droppable_methods.js rename to tests/unit/droppable/methods.js index a8a2a078c..1c9bba023 100644 --- a/tests/unit/droppable/droppable_methods.js +++ b/tests/unit/droppable/methods.js @@ -1,7 +1,8 @@ -/* - * droppable_methods.js - */ -(function($) { +define( [ + "jquery", + "./helper", + "ui/droppable" +], function( $, testHelper ) { module("droppable: methods"); @@ -47,45 +48,45 @@ test("enable", function() { var el, expected, actual; el = $("#droppable1").droppable({ disabled: true }); - TestHelpers.droppable.shouldNotDrop(); + testHelper.shouldNotDrop(); el.droppable("enable"); - TestHelpers.droppable.shouldDrop(); + testHelper.shouldDrop(); equal(el.droppable("option", "disabled"), false, "disabled option getter"); el.droppable("destroy"); el.droppable({ disabled: true }); - TestHelpers.droppable.shouldNotDrop(); + testHelper.shouldNotDrop(); el.droppable("option", "disabled", false); equal(el.droppable("option", "disabled"), false, "disabled option setter"); - TestHelpers.droppable.shouldDrop(); + testHelper.shouldDrop(); expected = $("
").droppable(), actual = expected.droppable("enable"); equal(actual, expected, "enable is chainable"); }); -test( "disable", function() { +test( "disable", function( assert ) { expect( 10 ); var actual, expected, element = $( "#droppable1" ).droppable({ disabled: false }); - TestHelpers.droppable.shouldDrop(); + testHelper.shouldDrop(); element.droppable( "disable" ); - TestHelpers.droppable.shouldNotDrop(); + testHelper.shouldNotDrop(); equal( element.droppable( "option", "disabled" ), true, "disabled option getter" ); element.droppable( "destroy" ); element.droppable({ disabled: false }); - TestHelpers.droppable.shouldDrop(); + testHelper.shouldDrop(); element.droppable( "option", "disabled", true ); - ok( !element.droppable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" ); + assert.lacksClasses( element.droppable( "widget" ), "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" ); + assert.hasClasses( element.droppable( "widget" ), "ui-droppable-disabled" ); equal( element.droppable( "option", "disabled" ), true, "disabled option setter" ); - TestHelpers.droppable.shouldNotDrop(); + testHelper.shouldNotDrop(); expected = $( "
" ).droppable(); actual = expected.droppable( "disable" ); equal( actual, expected, "disable is chainable" ); }); -})( jQuery ); +} ); diff --git a/tests/unit/droppable/droppable_options.js b/tests/unit/droppable/options.js similarity index 91% rename from tests/unit/droppable/droppable_options.js rename to tests/unit/droppable/options.js index 047858abf..c7c0dbdd6 100644 --- a/tests/unit/droppable/droppable_options.js +++ b/tests/unit/droppable/options.js @@ -1,7 +1,7 @@ -/* - * droppable_options.js - */ -(function($) { +define( [ + "jquery", + "ui/droppable" +], function( $ ) { module( "droppable: options" ); @@ -22,17 +22,18 @@ test( "activeClass", function() { ok(false, 'missing test - untested code is broken code'); }); */ -test( "{ addClasses: true }, default", function() { +test( "{ addClasses: true }, default", function( assert ) { expect( 1 ); var el = $( "
" ).droppable({ addClasses: true }); - ok( el.is( ".ui-droppable" ), "'ui-droppable' class added" ); + assert.hasClasses( el, "ui-droppable" ); el.droppable( "destroy" ); }); -test( "{ addClasses: false }", function() { +test( "{ addClasses: false }", function( assert ) { expect( 1 ); var el = $( "
" ).droppable({ addClasses: false }); - ok( !el.is( ".ui-droppable" ), "'ui-droppable' class not added" ); + + assert.lacksClasses( el, "ui-droppable" ); el.droppable( "destroy" ); }); @@ -133,7 +134,7 @@ test( "tolerance, intersect", function() { left: 0 }); - droppable.unbind( "drop" ).bind( "drop", function() { + droppable.off( "drop" ).on( "drop", function() { equal( true, data[ 2 ], data[ 3 ] ); }); @@ -172,7 +173,7 @@ test( "tolerance, pointer", function() { $.each( dataset, function() { var data = this; - droppable.unbind( "drop" ).bind( "drop", function() { + droppable.off( "drop" ).on( "drop", function() { equal( true, data[ 2 ], data[ 3 ] ); }); @@ -186,7 +187,7 @@ test( "tolerance, pointer", function() { draggable.css({ top: 0, left: 0 }).draggable( "option", "axis", "x" ); droppable.css({ top: 15, left: 15 }); - droppable.unbind( "drop" ).bind( "drop", function() { + droppable.off( "drop" ).on( "drop", function() { ok( true, "drop fires as long as pointer is within droppable" ); }); @@ -201,4 +202,4 @@ test( "tolerance, touch", function() { ok(false, 'missing test - untested code is broken code'); }); */ -})(jQuery); +} ); diff --git a/tests/unit/effects/all.html b/tests/unit/effects/all.html index 54752f594..b043b6223 100644 --- a/tests/unit/effects/all.html +++ b/tests/unit/effects/all.html @@ -7,9 +7,9 @@ - + - + - - - - - + + - - - - - @@ -35,6 +24,7 @@
+
diff --git a/tests/unit/slider/slider_common.js b/tests/unit/slider/slider_common.js deleted file mode 100644 index 6d7278de6..000000000 --- a/tests/unit/slider/slider_common.js +++ /dev/null @@ -1,23 +0,0 @@ -TestHelpers.commonWidgetTests( "slider", { - defaults: { - animate: false, - cancel: "input,textarea,button,select,option", - delay: 0, - disabled: false, - distance: 0, - max: 100, - min: 0, - orientation: "horizontal", - range: false, - step: 1, - value: 0, - values: null, - - // callbacks - create: null, - change: null, - slide: null, - start: null, - stop: null - } -}); diff --git a/tests/unit/sortable/all.html b/tests/unit/sortable/all.html index cabaea469..cb08860bc 100644 --- a/tests/unit/sortable/all.html +++ b/tests/unit/sortable/all.html @@ -7,9 +7,9 @@ - + - + - - - - - - - - - - - - - - + + + + + + + + + + +
+

Range Slider

+

When set both values of range slider to the maximum, slider should not lock

+
+
+ + +
+ + + + diff --git a/tests/visual/tooltip/tooltip.html b/tests/visual/tooltip/tooltip.html index 8d5364d78..c0ba7a11c 100644 --- a/tests/visual/tooltip/tooltip.html +++ b/tests/visual/tooltip/tooltip.html @@ -22,10 +22,14 @@ // custom class, replaces ui-widget-content $( "#context2" ).tooltip({ - tooltipClass: "ui-widget-header" + classes: { + "ui-tooltip": "ui-corner-all ui-widget-header" + } }); $( "#right1" ).tooltip({ - tooltipClass: "ui-state-error" + classes: { + "ui-tooltip": "ui-corner-all ui-state-error" + } }); // synchronous content @@ -63,7 +67,9 @@ // custom position $( "#right2" ).tooltip({ - tooltipClass: "ui-state-highlight", + classes: { + "ui-tooltip": "ui-corner-all ui-state-highlight" + }, position: { my: "center top", at: "center bottom+10" @@ -94,8 +100,8 @@ show: { delay: 500 } - }).click(function() { - $( "#focus-on-me" ).focus(); + }).on( "click", function() { + $( "#focus-on-me" ).trigger( "focus" ); }); }); diff --git a/themes/base/selectmenu.css b/themes/base/selectmenu.css index be4819a1a..178d7037f 100644 --- a/themes/base/selectmenu.css +++ b/themes/base/selectmenu.css @@ -39,6 +39,7 @@ position: relative; text-decoration: none; cursor: pointer; + width: 14em; } .ui-selectmenu-button span.ui-icon { right: 0.5em; diff --git a/themes/base/theme.css b/themes/base/theme.css index 1b7a7bf1b..12b94c653 100644 --- a/themes/base/theme.css +++ b/themes/base/theme.css @@ -396,7 +396,7 @@ /* Overlays */ .ui-widget-overlay { - background: #aaaaaa/*{bgColorOverlay}*/; + background: #aaaaaa/*{bgColorOverlay}*/ /*{bgImgUrlOverlay}*/ /*{bgOverlayXPos}*/ /*{bgOverlayYPos}*/ /*{bgOverlayRepeat}*/; opacity: .3/*{opacityOverlay}*/; filter: Alpha(Opacity=30)/*{opacityFilterOverlay}*/; /* support: IE8 */ } diff --git a/ui/accordion.js b/ui/accordion.js index e904df2be..a9b843cd5 100644 --- a/ui/accordion.js +++ b/ui/accordion.js @@ -12,12 +12,15 @@ //>>description: Displays collapsible content panels for presenting information in a limited amount of space. //>>docs: http://api.jqueryui.com/accordion/ //>>demos: http://jqueryui.com/accordion/ +//>>css.structure: ../themes/base/core.css +//>>css.structure: ../themes/base/accordion.css +//>>css.theme: ../themes/base/theme.css -(function( factory ) { +( function( factory ) { if ( typeof define === "function" && define.amd ) { // AMD. Register as an anonymous module. - define([ + define( [ "jquery", "./core", "./widget" @@ -27,16 +30,21 @@ // Browser globals factory( jQuery ); } -}(function( $ ) { +}( function( $ ) { return $.widget( "ui.accordion", { version: "@VERSION", options: { active: 0, animate: {}, + classes: { + "ui-accordion-header": "ui-corner-top", + "ui-accordion-header-collapsed": "ui-corner-all", + "ui-accordion-content": "ui-corner-bottom" + }, collapsible: false, event: "click", - header: "> li > :first-child,> :not(li):even", + header: "> li > :first-child, > :not(li):even", heightStyle: "auto", icons: { activeHeader: "ui-icon-triangle-1-s", @@ -66,13 +74,13 @@ return $.widget( "ui.accordion", { _create: function() { var options = this.options; + this.prevShow = this.prevHide = $(); - this.element.addClass( "ui-accordion ui-widget ui-helper-reset" ) - // ARIA - .attr( "role", "tablist" ); + this._addClass( "ui-accordion", "ui-widget ui-helper-reset" ); + this.element.attr( "role", "tablist" ); // don't allow collapsible: false and active: false / null - if ( !options.collapsible && (options.active === false || options.active == null) ) { + if ( !options.collapsible && ( options.active === false || options.active == null ) ) { options.active = 0; } @@ -92,54 +100,42 @@ return $.widget( "ui.accordion", { }, _createIcons: function() { - var icons = this.options.icons; + var icon, children, + icons = this.options.icons; + if ( icons ) { - $( "" ) - .addClass( "ui-accordion-header-icon ui-icon " + icons.header ) - .prependTo( this.headers ); - this.active.children( ".ui-accordion-header-icon" ) - .removeClass( icons.header ) - .addClass( icons.activeHeader ); - this.headers.addClass( "ui-accordion-icons" ); + icon = $( "" ); + this._addClass( icon, "ui-accordion-header-icon", "ui-icon " + icons.header ); + icon.prependTo( this.headers ); + children = this.active.children( ".ui-accordion-header-icon" ); + this._removeClass( children, icons.header ) + ._addClass( children, null, icons.activeHeader ) + ._addClass( this.headers, "ui-accordion-icons" ); } }, _destroyIcons: function() { - this.headers - .removeClass( "ui-accordion-icons" ) - .children( ".ui-accordion-header-icon" ) - .remove(); + this._removeClass( this.headers, "ui-accordion-icons" ); + this.headers.children( ".ui-accordion-header-icon" ).remove(); }, _destroy: function() { var contents; // clean up main element - this.element - .removeClass( "ui-accordion ui-widget ui-helper-reset" ) - .removeAttr( "role" ); + this.element.removeAttr( "role" ); // clean up headers this.headers - .removeClass( "ui-accordion-header ui-accordion-header-active ui-state-default " + - "ui-corner-all ui-state-active ui-state-disabled ui-corner-top" ) - .removeAttr( "role" ) - .removeAttr( "aria-expanded" ) - .removeAttr( "aria-selected" ) - .removeAttr( "aria-controls" ) - .removeAttr( "tabIndex" ) + .removeAttr( "role aria-expanded aria-selected aria-controls tabIndex" ) .removeUniqueId(); this._destroyIcons(); // clean up content panels contents = this.headers.next() - .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom " + - "ui-accordion-content ui-accordion-content-active ui-state-disabled" ) .css( "display", "" ) - .removeAttr( "role" ) - .removeAttr( "aria-hidden" ) - .removeAttr( "aria-labelledby" ) + .removeAttr( "role aria-hidden aria-labelledby" ) .removeUniqueId(); if ( this.options.heightStyle !== "content" ) { @@ -175,14 +171,15 @@ return $.widget( "ui.accordion", { } } - // #5332 - opacity doesn't cascade to positioned elements in IE + // Support: IE8 Only + // #5332 / #6059 - 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 ); + this.element.attr( "aria-disabled", value ); + + this._toggleClass( null, "ui-state-disabled", !!value ); + this._toggleClass( this.headers.add( this.headers.next() ), null, "ui-state-disabled", + !!value ); } }, @@ -197,37 +194,37 @@ return $.widget( "ui.accordion", { toFocus = false; switch ( event.keyCode ) { - case keyCode.RIGHT: - case keyCode.DOWN: - toFocus = this.headers[ ( currentIndex + 1 ) % length ]; - break; - case keyCode.LEFT: - case keyCode.UP: - toFocus = this.headers[ ( currentIndex - 1 + length ) % length ]; - break; - case keyCode.SPACE: - case keyCode.ENTER: - this._eventHandler( event ); - break; - case keyCode.HOME: - toFocus = this.headers[ 0 ]; - break; - case keyCode.END: - toFocus = this.headers[ length - 1 ]; - break; + case keyCode.RIGHT: + case keyCode.DOWN: + toFocus = this.headers[ ( currentIndex + 1 ) % length ]; + break; + case keyCode.LEFT: + case keyCode.UP: + toFocus = this.headers[ ( currentIndex - 1 + length ) % length ]; + break; + case keyCode.SPACE: + case keyCode.ENTER: + this._eventHandler( event ); + break; + case keyCode.HOME: + toFocus = this.headers[ 0 ]; + break; + case keyCode.END: + toFocus = this.headers[ length - 1 ]; + break; } if ( toFocus ) { $( event.target ).attr( "tabIndex", -1 ); $( toFocus ).attr( "tabIndex", 0 ); - toFocus.focus(); + $( toFocus ).trigger( "focus" ); event.preventDefault(); } }, _panelKeyDown: function( event ) { if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) { - $( event.currentTarget ).prev().focus(); + $( event.currentTarget ).prev().trigger( "focus" ); } }, @@ -245,7 +242,7 @@ return $.widget( "ui.accordion", { // was active, but active panel is gone } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) { // all remaining panel are disabled - if ( this.headers.length === this.headers.find(".ui-state-disabled").length ) { + if ( this.headers.length === this.headers.find( ".ui-state-disabled" ).length ) { options.active = false; this.active = $(); // activate previous panel @@ -267,13 +264,12 @@ return $.widget( "ui.accordion", { var prevHeaders = this.headers, prevPanels = this.panels; - this.headers = this.element.find( this.options.header ) - .addClass( "ui-accordion-header ui-state-default ui-corner-all" ); + this.headers = this.element.find( this.options.header ); + this._addClass( this.headers, "ui-accordion-header ui-accordion-header-collapsed", + "ui-state-default" ); - this.panels = this.headers.next() - .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" ) - .filter( ":not(.ui-accordion-content-active)" ) - .hide(); + this.panels = this.headers.next().filter( ":not(.ui-accordion-content-active)" ).hide(); + this._addClass( this.panels, "ui-accordion-content", "ui-helper-reset ui-widget-content" ); // Avoid memory leaks (#10056) if ( prevPanels ) { @@ -288,52 +284,51 @@ return $.widget( "ui.accordion", { heightStyle = options.heightStyle, parent = this.element.parent(); - this.active = this._findActive( options.active ) - .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" ) - .removeClass( "ui-corner-all" ); - this.active.next() - .addClass( "ui-accordion-content-active" ) - .show(); + this.active = this._findActive( options.active ); + this._addClass( this.active, "ui-accordion-header-active", "ui-state-active" ) + ._removeClass( this.active, "ui-accordion-header-collapsed" ); + this._addClass( this.active.next(), "ui-accordion-content-active" ); + this.active.next().show(); this.headers .attr( "role", "tab" ) - .each(function() { + .each( function() { var header = $( this ), headerId = header.uniqueId().attr( "id" ), panel = header.next(), panelId = panel.uniqueId().attr( "id" ); header.attr( "aria-controls", panelId ); panel.attr( "aria-labelledby", headerId ); - }) + } ) .next() .attr( "role", "tabpanel" ); this.headers .not( this.active ) - .attr({ - "aria-selected": "false", - "aria-expanded": "false", - tabIndex: -1 - }) - .next() - .attr({ - "aria-hidden": "true" - }) - .hide(); + .attr( { + "aria-selected": "false", + "aria-expanded": "false", + tabIndex: -1 + } ) + .next() + .attr( { + "aria-hidden": "true" + } ) + .hide(); // make sure at least one header is in the tab order if ( !this.active.length ) { this.headers.eq( 0 ).attr( "tabIndex", 0 ); } else { - this.active.attr({ + this.active.attr( { "aria-selected": "true", "aria-expanded": "true", tabIndex: 0 - }) - .next() - .attr({ - "aria-hidden": "false" - }); + } ) + .next() + .attr( { + "aria-hidden": "false" + } ); } this._createIcons(); @@ -342,7 +337,7 @@ return $.widget( "ui.accordion", { if ( heightStyle === "fill" ) { maxHeight = parent.height(); - this.element.siblings( ":visible" ).each(function() { + this.element.siblings( ":visible" ).each( function() { var elem = $( this ), position = elem.css( "position" ); @@ -350,24 +345,24 @@ return $.widget( "ui.accordion", { return; } maxHeight -= elem.outerHeight( true ); - }); + } ); - this.headers.each(function() { + this.headers.each( function() { maxHeight -= $( this ).outerHeight( true ); - }); + } ); this.headers.next() - .each(function() { + .each( function() { $( this ).height( Math.max( 0, maxHeight - $( this ).innerHeight() + $( this ).height() ) ); - }) + } ) .css( "overflow", "auto" ); } else if ( heightStyle === "auto" ) { maxHeight = 0; this.headers.next() - .each(function() { + .each( function() { maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() ); - }) + } ) .height( maxHeight ); } }, @@ -383,11 +378,11 @@ return $.widget( "ui.accordion", { // trying to collapse, simulate a click on the currently active header active = active || this.active[ 0 ]; - this._eventHandler({ + this._eventHandler( { target: active, currentTarget: active, preventDefault: $.noop - }); + } ); }, _findActive: function( selector ) { @@ -401,18 +396,19 @@ return $.widget( "ui.accordion", { if ( event ) { $.each( event.split( " " ), function( index, eventName ) { events[ eventName ] = "_eventHandler"; - }); + } ); } this._off( this.headers.add( this.headers.next() ) ); this._on( this.headers, events ); - this._on( this.headers.next(), { keydown: "_panelKeyDown" }); + this._on( this.headers.next(), { keydown: "_panelKeyDown" } ); this._hoverable( this.headers ); this._focusable( this.headers ); }, _eventHandler: function( event ) { - var options = this.options, + var activeChildren, clickedChildren, + options = this.options, active = this.active, clicked = $( event.currentTarget ), clickedIsActive = clicked[ 0 ] === active[ 0 ], @@ -445,26 +441,23 @@ return $.widget( "ui.accordion", { // switch classes // corner classes on the previously active header stay after the animation - active.removeClass( "ui-accordion-header-active ui-state-active" ); + this._removeClass( active, "ui-accordion-header-active", "ui-state-active" ); if ( options.icons ) { - active.children( ".ui-accordion-header-icon" ) - .removeClass( options.icons.activeHeader ) - .addClass( options.icons.header ); + activeChildren = active.children( ".ui-accordion-header-icon" ); + this._removeClass( activeChildren, null, options.icons.activeHeader ) + ._addClass( activeChildren, null, options.icons.header ); } if ( !clickedIsActive ) { - clicked - .removeClass( "ui-corner-all" ) - .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" ); + this._removeClass( clicked, "ui-accordion-header-collapsed" ) + ._addClass( clicked, "ui-accordion-header-active", "ui-state-active" ); if ( options.icons ) { - clicked.children( ".ui-accordion-header-icon" ) - .removeClass( options.icons.header ) - .addClass( options.icons.activeHeader ); + clickedChildren = clicked.children( ".ui-accordion-header-icon" ); + this._removeClass( clickedChildren, null, options.icons.header ) + ._addClass( clickedChildren, null, options.icons.activeHeader ); } - clicked - .next() - .addClass( "ui-accordion-content-active" ); + this._addClass( clicked.next(), "ui-accordion-content-active" ); } }, @@ -485,42 +478,43 @@ return $.widget( "ui.accordion", { this._toggleComplete( data ); } - toHide.attr({ + toHide.attr( { "aria-hidden": "true" - }); - toHide.prev().attr({ + } ); + toHide.prev().attr( { "aria-selected": "false", "aria-expanded": "false" - }); + } ); // if we're switching panels, remove the old header from the tab order // if we're opening from collapsed state, remove the previous header from the tab order // if we're collapsing, then keep the collapsing header in the tab order if ( toShow.length && toHide.length ) { - toHide.prev().attr({ + toHide.prev().attr( { "tabIndex": -1, "aria-expanded": "false" - }); + } ); } else if ( toShow.length ) { - this.headers.filter(function() { + this.headers.filter( function() { return parseInt( $( this ).attr( "tabIndex" ), 10 ) === 0; - }) - .attr( "tabIndex", -1 ); + } ) + .attr( "tabIndex", -1 ); } toShow .attr( "aria-hidden", "false" ) .prev() - .attr({ + .attr( { "aria-selected": "true", "aria-expanded": "true", tabIndex: 0 - }); + } ); }, _animate: function( toShow, toHide, data ) { var total, easing, duration, that = this, adjust = 0, + boxSizing = toShow.css( "box-sizing" ), down = toShow.length && ( !toHide.length || ( toShow.index() < toHide.index() ) ), animate = this.options.animate || {}, @@ -553,7 +547,7 @@ return $.widget( "ui.accordion", { step: function( now, fx ) { fx.now = Math.round( now ); } - }); + } ); toShow .hide() .animate( this.showProps, { @@ -563,23 +557,24 @@ return $.widget( "ui.accordion", { step: function( now, fx ) { fx.now = Math.round( now ); if ( fx.prop !== "height" ) { - adjust += fx.now; + if ( boxSizing === "content-box" ) { + adjust += fx.now; + } } else if ( that.options.heightStyle !== "content" ) { fx.now = Math.round( total - toHide.outerHeight() - adjust ); adjust = 0; } } - }); + } ); }, _toggleComplete: function( data ) { - var toHide = data.oldPanel; + var toHide = data.oldPanel, + prev = toHide.prev(); - toHide - .removeClass( "ui-accordion-content-active" ) - .prev() - .removeClass( "ui-corner-top" ) - .addClass( "ui-corner-all" ); + this._removeClass( toHide, "ui-accordion-content-active" ); + this._removeClass( prev, "ui-accordion-header-active" ) + ._addClass( prev, "ui-accordion-header-collapsed" ); // Work around for rendering bug in IE (#5421) if ( toHide.length ) { @@ -587,6 +582,6 @@ return $.widget( "ui.accordion", { } this._trigger( "activate", null, data ); } -}); +} ); -})); +} ) ); diff --git a/ui/autocomplete.js b/ui/autocomplete.js index d8db9a442..de173cc4f 100644 --- a/ui/autocomplete.js +++ b/ui/autocomplete.js @@ -12,12 +12,15 @@ //>>description: Lists suggested words as the user is typing. //>>docs: http://api.jqueryui.com/autocomplete/ //>>demos: http://jqueryui.com/autocomplete/ +//>>css.structure: ../themes/base/core.css +//>>css.structure: ../themes/base/autocomplete.css +//>>css.theme: ../themes/base/theme.css -(function( factory ) { +( function( factory ) { if ( typeof define === "function" && define.amd ) { // AMD. Register as an anonymous module. - define([ + define( [ "jquery", "./core", "./widget", @@ -29,7 +32,7 @@ // Browser globals factory( jQuery ); } -}(function( $ ) { +}( function( $ ) { $.widget( "ui.autocomplete", { version: "@VERSION", @@ -72,21 +75,17 @@ $.widget( "ui.autocomplete", { isTextarea = nodeName === "textarea", isInput = nodeName === "input"; - this.isMultiLine = - // Textareas are always multi-line - isTextarea ? true : - // Inputs are always single-line, even if inside a contentEditable element - // IE also treats inputs as contentEditable - isInput ? false : - // All other element types are determined by whether or not they're contentEditable - this.element.prop( "isContentEditable" ); + // Textareas are always multi-line + // Inputs are always single-line, even if inside a contentEditable element + // IE also treats inputs as contentEditable + // All other element types are determined by whether or not they're contentEditable + this.isMultiLine = isTextarea || !isInput && this.element.prop( "isContentEditable" ); this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ]; this.isNewMenu = true; - this.element - .addClass( "ui-autocomplete-input" ) - .attr( "autocomplete", "off" ); + this._addClass( "ui-autocomplete-input" ); + this.element.attr( "autocomplete", "off" ); this._on( this.element, { keydown: function( event ) { @@ -203,19 +202,19 @@ $.widget( "ui.autocomplete", { this.close( event ); this._change( event ); } - }); + } ); this._initSource(); this.menu = $( "
    " ) - .addClass( "ui-autocomplete ui-front" ) .appendTo( this._appendTo() ) - .menu({ + .menu( { // disable ARIA support, the live region takes care of that role: null - }) + } ) .hide() .menu( "instance" ); + this._addClass( this.menu.element, "ui-autocomplete", "ui-front" ); this._on( this.menu.element, { mousedown: function( event ) { // prevent moving focus out of the text field @@ -224,9 +223,19 @@ $.widget( "ui.autocomplete", { // IE doesn't prevent moving focus even with event.preventDefault() // so we set a flag to know when we should ignore the blur event this.cancelBlur = true; - this._delay(function() { + this._delay( function() { delete this.cancelBlur; - }); + + // Support: IE 8 only + // Right clicking a menu item or selecting text from the menu items will + // result in focus moving out of the input. However, we've already received + // and ignored the blur event because of the cancelBlur flag set above. So + // we restore focus to ensure that the menu closes properly based on the user's + // next actions. + if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) { + this.element.trigger( "focus" ); + } + } ); // clicking on the scrollbar causes focus to shift to the body // but we can't detect a mouseup or a click immediately afterward @@ -234,7 +243,7 @@ $.widget( "ui.autocomplete", { // the user clicks somewhere outside of the autocomplete var menuElement = this.menu.element[ 0 ]; if ( !$( event.target ).closest( ".ui-menu-item" ).length ) { - this._delay(function() { + this._delay( function() { var that = this; this.document.one( "mousedown", function( event ) { if ( event.target !== that.element[ 0 ] && @@ -242,8 +251,8 @@ $.widget( "ui.autocomplete", { !$.contains( menuElement, event.target ) ) { that.close(); } - }); - }); + } ); + } ); } }, menufocus: function( event, ui ) { @@ -257,7 +266,7 @@ $.widget( "ui.autocomplete", { this.document.one( "mousemove", function() { $( event.target ).trigger( event.originalEvent ); - }); + } ); return; } @@ -283,16 +292,16 @@ $.widget( "ui.autocomplete", { previous = this.previous; // only trigger when focus was lost (click on menu) - if ( this.element[ 0 ] !== this.document[ 0 ].activeElement ) { - this.element.focus(); + if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) { + this.element.trigger( "focus" ); this.previous = previous; // #6109 - IE triggers two focus events and the second // is asynchronous, so we need to reset the previous // term synchronously and asynchronously :-( - this._delay(function() { + this._delay( function() { this.previous = previous; this.selectedItem = item; - }); + } ); } if ( false !== this._trigger( "select", event, { item: item } ) ) { @@ -305,16 +314,17 @@ $.widget( "ui.autocomplete", { this.close( event ); this.selectedItem = item; } - }); + } ); this.liveRegion = $( "", { - role: "status", - "aria-live": "assertive", - "aria-relevant": "additions" - }) - .addClass( "ui-helper-hidden-accessible" ) + role: "status", + "aria-live": "assertive", + "aria-relevant": "additions" + } ) .appendTo( this.document[ 0 ].body ); + this._addClass( this.liveRegion, null, "ui-helper-hidden-accessible" ); + // turning off autocomplete prevents the browser from remembering the // value when navigating through history, so we re-enable autocomplete // if the page is unloaded before the widget is destroyed. #7790 @@ -322,14 +332,12 @@ $.widget( "ui.autocomplete", { beforeunload: function() { this.element.removeAttr( "autocomplete" ); } - }); + } ); }, _destroy: function() { clearTimeout( this.searching ); - this.element - .removeClass( "ui-autocomplete-input" ) - .removeAttr( "autocomplete" ); + this.element.removeAttr( "autocomplete" ); this.menu.element.remove(); this.liveRegion.remove(); }, @@ -357,7 +365,7 @@ $.widget( "ui.autocomplete", { } if ( !element || !element[ 0 ] ) { - element = this.element.closest( ".ui-front" ); + element = this.element.closest( ".ui-front, dialog" ); } if ( !element.length ) { @@ -381,7 +389,7 @@ $.widget( "ui.autocomplete", { if ( that.xhr ) { that.xhr.abort(); } - that.xhr = $.ajax({ + that.xhr = $.ajax( { url: url, data: request, dataType: "json", @@ -389,9 +397,9 @@ $.widget( "ui.autocomplete", { response( data ); }, error: function() { - response([]); + response( [] ); } - }); + } ); }; } else { this.source = this.options.source; @@ -400,7 +408,7 @@ $.widget( "ui.autocomplete", { _searchTimeout: function( event ) { clearTimeout( this.searching ); - this.searching = this._delay(function() { + this.searching = this._delay( function() { // Search if the value has changed, or if the user retypes the same value (see #7434) var equalValues = this.term === this._value(), @@ -433,7 +441,7 @@ $.widget( "ui.autocomplete", { _search: function( value ) { this.pending++; - this.element.addClass( "ui-autocomplete-loading" ); + this._addClass( "ui-autocomplete-loading" ); this.cancelSearch = false; this.source( { term: value }, this._response() ); @@ -442,14 +450,14 @@ $.widget( "ui.autocomplete", { _response: function() { var index = ++this.requestIndex; - return $.proxy(function( content ) { + return $.proxy( function( content ) { if ( index === this.requestIndex ) { this.__response( content ); } this.pending--; if ( !this.pending ) { - this.element.removeClass( "ui-autocomplete-loading" ); + this._removeClass( "ui-autocomplete-loading" ); } }, this ); }, @@ -503,8 +511,8 @@ $.widget( "ui.autocomplete", { return $.extend( {}, item, { label: item.label || item.value, value: item.value || item.label - }); - }); + } ); + } ); }, _suggest: function( items ) { @@ -516,7 +524,7 @@ $.widget( "ui.autocomplete", { // size and position menu ul.show(); this._resizeMenu(); - ul.position( $.extend({ + ul.position( $.extend( { of: this.element }, this.options.position ) ); @@ -539,7 +547,7 @@ $.widget( "ui.autocomplete", { var that = this; $.each( items, function( index, item ) { that._renderItemData( ul, item ); - }); + } ); }, _renderItemData: function( ul, item ) { @@ -586,7 +594,7 @@ $.widget( "ui.autocomplete", { event.preventDefault(); } } -}); +} ); $.extend( $.ui.autocomplete, { escapeRegex: function( value ) { @@ -596,9 +604,9 @@ $.extend( $.ui.autocomplete, { var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), "i" ); return $.grep( array, function( value ) { return matcher.test( value.label || value.value || value ); - }); + } ); } -}); +} ); // live region extension, adding a `messages` option // NOTE: This is an experimental API. We are still investigating @@ -628,8 +636,8 @@ $.widget( "ui.autocomplete", $.ui.autocomplete, { this.liveRegion.children().hide(); $( "
    " ).text( message ).appendTo( this.liveRegion ); } -}); +} ); return $.ui.autocomplete; -})); +} ) ); diff --git a/ui/button.js b/ui/button.js index a3a40b46d..70cc31680 100644 --- a/ui/button.js +++ b/ui/button.js @@ -12,6 +12,9 @@ //>>description: Enhances a form with themeable buttons. //>>docs: http://api.jqueryui.com/button/ //>>demos: http://jqueryui.com/button/ +//>>css.structure: ../themes/base/core.css +//>>css.structure: ../themes/base/button.css +//>>css.theme: ../themes/base/theme.css (function( factory ) { if ( typeof define === "function" && define.amd ) { @@ -70,8 +73,8 @@ $.widget( "ui.button", { }, _create: function() { this.element.closest( "form" ) - .unbind( "reset" + this.eventNamespace ) - .bind( "reset" + this.eventNamespace, formResetHandler ); + .off( "reset" + this.eventNamespace ) + .on( "reset" + this.eventNamespace, formResetHandler ); if ( typeof this.options.disabled !== "boolean" ) { this.options.disabled = !!this.element.prop( "disabled" ); @@ -96,7 +99,7 @@ $.widget( "ui.button", { this.buttonElement .addClass( baseClasses ) .attr( "role", "button" ) - .bind( "mouseenter" + this.eventNamespace, function() { + .on( "mouseenter" + this.eventNamespace, function() { if ( options.disabled ) { return; } @@ -104,13 +107,13 @@ $.widget( "ui.button", { $( this ).addClass( "ui-state-active" ); } }) - .bind( "mouseleave" + this.eventNamespace, function() { + .on( "mouseleave" + this.eventNamespace, function() { if ( options.disabled ) { return; } $( this ).removeClass( activeClass ); }) - .bind( "click" + this.eventNamespace, function( event ) { + .on( "click" + this.eventNamespace, function( event ) { if ( options.disabled ) { event.preventDefault(); event.stopImmediatePropagation(); @@ -129,19 +132,19 @@ $.widget( "ui.button", { }); if ( toggleButton ) { - this.element.bind( "change" + this.eventNamespace, function() { + this.element.on( "change" + this.eventNamespace, function() { that.refresh(); }); } if ( this.type === "checkbox" ) { - this.buttonElement.bind( "click" + this.eventNamespace, function() { + this.buttonElement.on( "click" + this.eventNamespace, function() { if ( options.disabled ) { return false; } }); } else if ( this.type === "radio" ) { - this.buttonElement.bind( "click" + this.eventNamespace, function() { + this.buttonElement.on( "click" + this.eventNamespace, function() { if ( options.disabled ) { return false; } @@ -159,7 +162,7 @@ $.widget( "ui.button", { }); } else { this.buttonElement - .bind( "mousedown" + this.eventNamespace, function() { + .on( "mousedown" + this.eventNamespace, function() { if ( options.disabled ) { return false; } @@ -169,13 +172,13 @@ $.widget( "ui.button", { lastActive = null; }); }) - .bind( "mouseup" + this.eventNamespace, function() { + .on( "mouseup" + this.eventNamespace, function() { if ( options.disabled ) { return false; } $( this ).removeClass( "ui-state-active" ); }) - .bind( "keydown" + this.eventNamespace, function(event) { + .on( "keydown" + this.eventNamespace, function(event) { if ( options.disabled ) { return false; } @@ -185,15 +188,15 @@ $.widget( "ui.button", { }) // see #8559, we bind to blur here in case the button element loses // focus between keydown and keyup, it would be left in an "active" state - .bind( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() { + .on( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() { $( this ).removeClass( "ui-state-active" ); }); if ( this.buttonElement.is("a") ) { - this.buttonElement.keyup(function(event) { + this.buttonElement.on( "keyup", function(event) { if ( event.keyCode === $.ui.keyCode.SPACE ) { // TODO pass through original event correctly (just as 2nd argument doesn't work) - $( this ).click(); + $( this ).trigger( "click" ); } }); } @@ -250,8 +253,7 @@ $.widget( "ui.button", { .removeClass( "ui-helper-hidden-accessible" ); this.buttonElement .removeClass( baseClasses + " ui-state-active " + typeClasses ) - .removeAttr( "role" ) - .removeAttr( "aria-pressed" ) + .removeAttr( "role aria-pressed" ) .html( this.buttonElement.find(".ui-button-text").html() ); if ( !this.hasTitle ) { diff --git a/ui/calendar.js b/ui/calendar.js index 40884c283..a358f69a0 100644 --- a/ui/calendar.js +++ b/ui/calendar.js @@ -13,24 +13,25 @@ //>>docs: http://api.jqueryui.com/calendar/ //>>demos: http://jqueryui.com/calendar/ -(function( factory ) { +( function( factory ) { if ( typeof define === "function" && define.amd ) { // AMD. Register as an anonymous module. - // TODO Add globalize and $.date // TODO: Keep button even if its optional? - define([ + define( [ "jquery", + "globalize", "./core", "./widget", - "./button" + "./button", + "date" ], factory ); } else { // Browser globals - factory( jQuery ); + factory( jQuery, Globalize ); } -}(function( $ ) { +}( function( $, Globalize ) { return $.widget( "ui.calendar", { version: "@VERSION", @@ -89,7 +90,7 @@ return $.widget( "ui.calendar", { "mouseenter .ui-calendar-calendar button": "_hover", "mouseleave .ui-calendar-calendar button": "_hover", "keydown .ui-calendar-calendar": "_handleKeydown" - }); + } ); this._createCalendar(); }, @@ -179,10 +180,10 @@ return $.widget( "ui.calendar", { this.element .addClass( classes ) - .attr({ + .attr( { role: "region", "aria-labelledby": this.id + "-title" - }) + } ) .html( pickerHtml ); this._createButtonPane(); @@ -446,7 +447,7 @@ return $.widget( "ui.calendar", { $( "", props ) .button( buttonOptions ) .appendTo( that.buttonSet ); - }); + } ); this.element.addClass( "ui-calendar-buttons" ); this.buttonPane.appendTo( this.element ); }, @@ -504,10 +505,10 @@ return $.widget( "ui.calendar", { }, _setHiddenPicker: function() { - this.element.attr({ + this.element.attr( { "aria-hidden": "true", "aria-expanded": "false" - }); + } ); }, value: function( value ) { @@ -565,7 +566,7 @@ return $.widget( "ui.calendar", { if ( key in that.refreshRelatedOptions ) { refresh = true; } - }); + } ); if ( refresh ) { this._refresh(); @@ -608,6 +609,6 @@ return $.widget( "ui.calendar", { this.date.setFormat( value ); } } -}); +} ); -})); +} ) ); diff --git a/ui/core.js b/ui/core.js index afaab689b..9ac196d38 100644 --- a/ui/core.js +++ b/ui/core.js @@ -14,7 +14,7 @@ //>>docs: http://api.jqueryui.com/category/ui-core/ //>>demos: http://jqueryui.com/ -(function( factory ) { +( function( factory ) { if ( typeof define === "function" && define.amd ) { // AMD. Register as an anonymous module. @@ -24,7 +24,7 @@ // Browser globals factory( jQuery ); } -}(function( $ ) { +}( function( $ ) { // $.ui might exist from components with no dependencies, e.g., $.ui.position $.ui = $.ui || {}; @@ -49,11 +49,58 @@ $.extend( $.ui, { SPACE: 32, TAB: 9, UP: 38 - } -}); + }, + + // Internal use only + safeActiveElement: function( document ) { + var activeElement; + + // Support: IE 9 only + // IE9 throws an "Unspecified error" accessing document.activeElement from an