Merge branch 'master' into datepicker

This commit is contained in:
Felix Nagel 2016-11-09 10:13:10 +01:00
commit 6b8ac7ef1b
210 changed files with 153985 additions and 7631 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
dist
bower_components
node_modules
.sizecache.json

View File

@ -8,8 +8,5 @@
"es3": true,
// We want to output all errors
"maxErrors": 1000000,
// Ref https://github.com/jquery/contribute.jquery.org/issues/80#issuecomment-45253460
"maximumLineLength": null
"maxErrors": 1000000
}

View File

@ -17,7 +17,7 @@ Christoph Rönsch <christoph.roensch@arcor.de>
Corey Frang <gnarf37@gmail.com> <gnarf@gnarf.net>
Courtland Allen <courtlandallen@gmail.com>
Dan Streetman <ddstreet@ieee.org>
Dan Strohl <dstrohl@users.noreply.github.com>
Dan Strohl <dan@wjcg.net> <dstrohl@users.noreply.github.com>
Danny Trunk <dtrunk90@gmail.com> <dtrunk90@googlemail.com>
David De Sloovere <david.desloovere@outlook.com> <david.desloovere@hotmail.com>
David Murdoch <david@davidmurdoch.com> <musicisair@yahoo.com>

View File

@ -2,6 +2,4 @@ sudo: required
dist: trusty
language: node_js
node_js:
- "0.12"
before_script:
- npm install -g grunt-cli
- "6"

View File

@ -321,4 +321,13 @@ Piotr Baran <piotros@wp.pl>
Mukul Hase <mukulhase@gmail.com>
Konstantin Dinev <kdinev@mail.bw.edu>
Rand Scullard <rand@randscullard.com>
Dan Strohl
Dan Strohl <dan@wjcg.net>
Maksim Ryzhikov <rv.maksim@gmail.com>
Amine HADDAD <haddad@allegorie.tv>
Amanpreet Singh <apsdehal@gmail.com>
Alexey Balchunas <bleshik@gmail.com>
Peter Kehl <peter.kehl@gmail.com>
Peter Dave Hello <hsu@peterdavehello.org>
Johannes Schäfer <johnschaefer@gmx.de>
Ville Skyttä <ville.skytta@iki.fi>
Ryan Oriecuia <ryan.oriecuia@visioncritical.com>

View File

@ -27,7 +27,7 @@ git clone git://github.com/jquery/jquery-ui.git
cd jquery-ui
```
The tests can run in any local web server. Ideally you should test your patch in appropriate web browsers and if possible run `grunt` to lint the code and run automated tests (this will happen automatically when you create a pull request). See the [Recommended Setup](#environment-recommended-setup) for setting up Node.js so that the grunt command works.
The tests can run in any local web server. Ideally you should test your patch in appropriate web browsers and if possible run `npm test` to lint the code and run automated tests (this will happen automatically when you create a pull request). See the [Recommended Setup](#environment-recommended-setup) for setting up Node.js so that the `npm test` command works.
### Environment: Getting the Source
@ -61,15 +61,9 @@ git pull upstream master
### Environment: Recommended Setup
jQuery UI uses Node.js & Grunt to automate the building and validation of source code. Here is how to set that up:
jQuery UI uses Node.js to automate the building and validation of source code. Here is how to set that up:
* Get [Node.js](http://nodejs.org/) (includes NPM, necessary for the next step)
* Install Grunt cli:
```bash
npm install -g grunt-cli
```
* Install local Node.js modules
```bash
@ -87,10 +81,10 @@ The tests require a local web server and the samples contain some PHP, so a PHP
### Running the Tests
To lint the JavaScript, HTML, and CSS, as well as run a smoke test in PhantomJS, run grunt:
To lint the JavaScript, HTML, and CSS, as well as run a smoke test in PhantomJS, run the full test suite through npm:
```bash
grunt
npm test
```
To run the tests for a specific plugin in your browser, open the appropriate file from the `/tests/unit/` directory, for example: `http://localhost/tests/unit/accordion/accordion.html`. The domain will be dependent on your local server configuration; if there is a port, be sure to include it.

View File

@ -7,18 +7,18 @@ var
coreFiles = [
"core.js",
"widget.js",
"mouse.js",
"draggable.js",
"droppable.js",
"resizable.js",
"selectable.js",
"sortable.js",
"widgets/mouse.js",
"widgets/draggable.js",
"widgets/droppable.js",
"widgets/resizable.js",
"widgets/selectable.js",
"widgets/sortable.js",
"effect.js"
],
uiFiles = coreFiles.map(function( file ) {
return "ui/" + file;
}).concat( expandFiles( "ui/*.js" ).filter(function( file ) {
}).concat( expandFiles( "ui/**/*.js" ).filter(function( file ) {
return coreFiles.indexOf( file.substring( 3 ) ) === -1;
}) ),
@ -178,12 +178,21 @@ grunt.initConfig({
},
jscs: {
all: {
ui: {
options: {
config: true
},
files: {
src: [ "demos/**/*.js", "build/**/*.js", "tests/**/*.js", "ui/**/*.js" ]
src: [ "demos/**/*.js", "build/**/*.js", "ui/**/*.js" ]
}
},
tests: {
options: {
config: true,
maximumLineLength: null
},
files: {
src: [ "tests/**/*.js" ]
}
}
},
@ -287,7 +296,7 @@ grunt.initConfig({
"jshint/LICENSE": "jshint/LICENSE",
"jquery/jquery.js": "jquery-1.x/dist/jquery.js",
"jquery/MIT-LICENSE.txt": "jquery-1.x/MIT-LICENSE.txt",
"jquery/LICENSE.txt": "jquery-1.x/LICENSE.txt",
"jquery-1.7.0/jquery.js": "jquery-1.7.0/jquery.js",
"jquery-1.7.0/MIT-LICENSE.txt": "jquery-1.7.0/MIT-LICENSE.txt",
@ -337,6 +346,21 @@ grunt.initConfig({
"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-1.12.0/jquery.js": "jquery-1.12.0/dist/jquery.js",
"jquery-1.12.0/LICENSE.txt": "jquery-1.12.0/LICENSE.txt",
"jquery-1.12.1/jquery.js": "jquery-1.12.1/dist/jquery.js",
"jquery-1.12.1/LICENSE.txt": "jquery-1.12.1/LICENSE.txt",
"jquery-1.12.2/jquery.js": "jquery-1.12.2/dist/jquery.js",
"jquery-1.12.2/LICENSE.txt": "jquery-1.12.2/LICENSE.txt",
"jquery-1.12.3/jquery.js": "jquery-1.12.3/dist/jquery.js",
"jquery-1.12.3/LICENSE.txt": "jquery-1.12.3/LICENSE.txt",
"jquery-1.12.4/jquery.js": "jquery-1.12.4/dist/jquery.js",
"jquery-1.12.4/LICENSE.txt": "jquery-1.12.4/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",
@ -359,7 +383,34 @@ grunt.initConfig({
"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"
"jquery-2.1.3/MIT-LICENSE.txt": "jquery-2.1.3/MIT-LICENSE.txt",
"jquery-2.1.4/jquery.js": "jquery-2.1.4/dist/jquery.js",
"jquery-2.1.4/MIT-LICENSE.txt": "jquery-2.1.4/MIT-LICENSE.txt",
"jquery-2.2.0/jquery.js": "jquery-2.2.0/dist/jquery.js",
"jquery-2.2.0/LICENSE.txt": "jquery-2.2.0/LICENSE.txt",
"jquery-2.2.1/jquery.js": "jquery-2.2.1/dist/jquery.js",
"jquery-2.2.1/LICENSE.txt": "jquery-2.2.1/LICENSE.txt",
"jquery-2.2.2/jquery.js": "jquery-2.2.2/dist/jquery.js",
"jquery-2.2.2/LICENSE.txt": "jquery-2.2.2/LICENSE.txt",
"jquery-2.2.3/jquery.js": "jquery-2.2.3/dist/jquery.js",
"jquery-2.2.3/LICENSE.txt": "jquery-2.2.3/LICENSE.txt",
"jquery-2.2.4/jquery.js": "jquery-2.2.4/dist/jquery.js",
"jquery-2.2.4/LICENSE.txt": "jquery-2.2.4/LICENSE.txt",
"jquery-3.0.0/jquery.js": "jquery-3.0.0/dist/jquery.js",
"jquery-3.0.0/LICENSE.txt": "jquery-3.0.0/LICENSE.txt",
"jquery-3.1.0/jquery.js": "jquery-3.1.0/dist/jquery.js",
"jquery-3.1.0/LICENSE.txt": "jquery-3.1.0/LICENSE.txt",
"jquery-3.1.1/jquery.js": "jquery-3.1.1/dist/jquery.js",
"jquery-3.1.1/LICENSE.txt": "jquery-3.1.1/LICENSE.txt"
}
}
},
@ -405,9 +456,7 @@ grunt.registerTask( "update-authors", function() {
}
authors = authors.map(function( author ) {
if ( author.match( /^Dan Strohl </ ) ) {
return "Dan Strohl";
} else if ( author.match( /^Jacek Jędrzejewski </ ) ) {
if ( author.match( /^Jacek Jędrzejewski </ ) ) {
return "Jacek Jędrzejewski (http://jacek.jedrzejewski.name)";
} else if ( author.match( /^Pawel Maruszczyk </ ) ) {
return "Pawel Maruszczyk (http://hrabstwo.net)";

View File

@ -7,6 +7,7 @@
"external",
"tests"
],
"license": "MIT",
"dependencies": {
"jquery": ">=1.6"
},
@ -37,7 +38,12 @@
"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-1.12.0": "jquery#1.12.0",
"jquery-1.12.1": "jquery#1.12.1",
"jquery-1.12.2": "jquery#1.12.2",
"jquery-1.12.3": "jquery#1.12.3",
"jquery-1.12.4": "jquery#1.12.4",
"jquery-1.x": "jquery#1.12.4",
"jquery-2.0.0": "jquery#2.0.0",
"jquery-2.0.1": "jquery#2.0.1",
"jquery-2.0.2": "jquery#2.0.2",
@ -45,6 +51,15 @@
"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"
"jquery-2.1.3": "jquery#2.1.3",
"jquery-2.1.4": "jquery#2.1.4",
"jquery-2.2.0": "jquery#2.2.0",
"jquery-2.2.1": "jquery#2.2.1",
"jquery-2.2.2": "jquery#2.2.2",
"jquery-2.2.3": "jquery#2.2.3",
"jquery-2.2.4": "jquery#2.2.4",
"jquery-3.0.0": "jquery#3.0.0",
"jquery-3.1.0": "jquery#3.1.0",
"jquery-3.1.1": "jquery#3.1.1"
}
}

View File

@ -35,6 +35,14 @@ function replaceAtVersion() {
return matches;
}
function removeExternals ( packager ) {
Object.keys( packager.builtFiles ).forEach( function( filepath ) {
if ( /^external\//.test( filepath ) ) {
delete packager.builtFiles[ filepath ];
}
} );
}
function addManifest( packager ) {
var output = packager.builtFiles;
output.MANIFEST = Object.keys( output ).sort( function( a, b ) {
@ -52,7 +60,8 @@ function buildCDNPackage( callback ) {
var Package = require( "download.jqueryui.com/lib/package-1-12-themes" );
var Packager = require( "node-packager" );
var jqueryUi = new JqueryUi( path.resolve( "." ) );
var target = fs.createWriteStream( "../" + jqueryUi.pkg.name + "-" + jqueryUi.pkg.version + "-cdn.zip" );
var target = fs.createWriteStream( "../" + jqueryUi.pkg.name + "-" + jqueryUi.pkg.version +
"-cdn.zip" );
var packager = new Packager( jqueryUi.files().cache, Package, {
components: jqueryUi.components().map( function( component ) {
return component.name;
@ -61,6 +70,7 @@ function buildCDNPackage( callback ) {
themeVars: null
} );
packager.ready.then( function() {
removeExternals( packager );
addManifest( packager );
packager.toZip( target, {
basedir: ""
@ -82,7 +92,8 @@ Release.define( {
"August", "September", "October", "November", "December" ],
now = new Date();
return "<script>{\n\t\"title\": \"jQuery UI " + Release.newVersion + " Changelog\"\n" +
"}</script>\n\nReleased on " + monthNames[ now.getMonth() ] + " " + now.getDate() + ", " + now.getFullYear() + "\n\n";
"}</script>\n\nReleased on " + monthNames[ now.getMonth() ] + " " + now.getDate() +
", " + now.getFullYear() + "\n\n";
},
generateArtifacts: function( fn ) {
var files = replaceAtVersion();

View File

@ -4,23 +4,32 @@ module.exports = function( grunt ) {
var versions = {
"git": "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"
"3.1": "3.1.1",
"3.0": "3.0.0",
"2.2": "2.2.4",
"2.1": "2.1.4",
"2.0": "2.0.3",
"1.12": "1.12.4",
"1.11": "1.11.3",
"1.10": "1.10.2",
"1.9": "1.9.1",
"1.8": "1.8.3",
"1.7": "1.7.2"
},
tests = {
"Accordion": "accordion/accordion.html",
"Autocomplete": "autocomplete/autocomplete.html",
"Button": "button/button.html",
"Calendar": "calendar/calendar.html",
"Checkboxradio": "checkboxradio/checkboxradio.html",
"Controlgroup": "controlgroup/controlgroup.html",
"Core": "core/core.html",
"Datepicker": "datepicker/datepicker.html",
"Dialog": "dialog/dialog.html",
"Draggable": "draggable/draggable.html",
"Droppable": "droppable/droppable.html",
"Effects": "effects/effects.html",
"Form Reset Mixin": "form-reset-mixin/form-reset-mixin.html",
"Menu": "menu/menu.html",
"Position": "position/position.html",
"Progressbar": "progressbar/progressbar.html",
@ -43,12 +52,6 @@ function submit( commit, runs, configFile, extra, done ) {
commitUrl = "https://github.com/jquery/jquery-ui/commit/" + commit;
if ( extra ) {
// jquery-git doesn't support IE 8.
if ( extra === "core git" ) {
browserSets = "jquery-ui-future";
}
extra = " (" + extra + ")";
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 997 B

After

Width:  |  Height:  |  Size: 965 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 B

After

Width:  |  Height:  |  Size: 68 B

View File

@ -17,7 +17,7 @@
return val.split( /,\s*/ );
}
function extractLast( term ) {
return split( term ).pop();
return split( term ).pop();
}
$( "#birds" )

View File

@ -10,7 +10,6 @@
.ui-autocomplete-loading {
background: white url("images/ui-anim_basic_16x16.gif") right center no-repeat;
}
#city { width: 25em; }
</style>
<script src="../../external/requirejs/require.js"></script>
<script src="../bootstrap.js">
@ -19,24 +18,22 @@
$( "#log" ).scrollTop( 0 );
}
$( "#city" ).autocomplete({
$( "#birds" ).autocomplete({
source: function( request, response ) {
$.ajax( {
url: "http://gd.geobytes.com/AutoCompleteCity",
url: "search.php",
dataType: "jsonp",
data: {
q: request.term
term: request.term
},
success: function( data ) {
// Handle 'no match' indicated by [ "" ] response
response( data.length === 1 && data[ 0 ].length === 0 ? [] : data );
response( data );
}
} );
},
minLength: 3,
minLength: 2,
select: function( event, ui ) {
log( "Selected: " + ui.item.label );
log( "Selected: " + ui.item.value + " aka " + ui.item.id );
}
} );
</script>
@ -44,9 +41,8 @@
<body>
<div class="ui-widget">
<label for="city">Your city: </label>
<input id="city" type="text">
Powered by <a href="http://geobytes.com">geobytes.com</a>
<label for="birds">Birds: </label>
<input id="birds">
</div>
<div class="ui-widget" style="margin-top:2em; font-family:Arial">
@ -55,7 +51,8 @@
</div>
<div class="demo-description">
<p>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 <a href="http://geobytes.com">geobytes.com webservice</a>. That data is also available in callbacks, as illustrated by the Result area below the input.</p>
<p>The Autocomplete widgets provides suggestions while you type into the field. Here the suggestions are bird names, displayed when at least two characters are entered into the field.</p>
<p>The datasource is a server-side script which returns JSONP data, specified via a function which uses <code>jQuery.ajax()</code> for the <code>source</code> option.</p>
</div>
</body>
</html>

View File

@ -22,9 +22,7 @@
source: "search.php",
minLength: 2,
select: function( event, ui ) {
log( ui.item ?
"Selected: " + ui.item.value + " aka " + ui.item.id :
"Nothing selected, input was " + this.value );
log( "Selected: " + ui.item.value + " aka " + ui.item.id );
}
});
</script>

View File

@ -1,6 +1,6 @@
<?php
sleep( 3 );
sleep( 2 );
// no term passed - just exit early with no response
if (empty($_GET['term'])) exit ;
$q = strtolower($_GET["term"]);
@ -573,7 +573,6 @@ $items = array(
"Heuglin's Gull"=>"Larus heuglini"
);
$result = array();
foreach ($items as $key=>$value) {
if (strpos(strtolower($key), $q) !== false) {
@ -584,6 +583,15 @@ foreach ($items as $key=>$value) {
}
// json_encode is available in PHP 5.2 and above, or you can install a PECL module in earlier versions
echo json_encode($result);
$output = json_encode($result);
if ($_GET["callback"]) {
// Escape special characters to avoid XSS attacks via direct loads of this
// page with a callback that contains HTML. This is a lot easier than validating
// the callback name.
$output = htmlspecialchars($_GET["callback"]) . "($output);";
}
echo $output;
?>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

@ -75,7 +75,7 @@
<input type="checkbox" name="insurance" id="insurance-v">
<label for="vertical-spinner" class="ui-controlgroup-label"># of cars</label>
<input id="vertical-spinner" class="ui-spinner-input">
<button>Book Now!</button>
<button id="book">Book Now!</button>
</div>
</fieldset>
</div>

View File

@ -12,7 +12,7 @@
modal: true,
buttons: {
Ok: function() {
$( this ).dialog( "close" );
$( this ).dialog( "close" );
}
}
});

Binary file not shown.

Before

Width:  |  Height:  |  Size: 681 B

After

Width:  |  Height:  |  Size: 395 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 594 B

After

Width:  |  Height:  |  Size: 387 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 649 B

After

Width:  |  Height:  |  Size: 487 B

View File

@ -0,0 +1,42 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Slider - Custom handle</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
<style>
#custom-handle {
width: 3em;
height: 1.6em;
top: 50%;
margin-top: -.8em;
text-align: center;
line-height: 1.6em;
}
</style>
<script src="../../external/requirejs/require.js"></script>
<script src="../bootstrap.js">
var handle = $( "#custom-handle" );
$( "#slider" ).slider({
create: function() {
handle.text( $( this ).slider( "value" ) );
},
slide: function( event, ui ) {
handle.text( ui.value );
}
});
</script>
</head>
<body>
<div id="slider">
<div id="custom-handle" class="ui-slider-handle"></div>
</div>
<div class="demo-description">
<p>The basic slider is horizontal and has a single handle that can be moved with the mouse or by using the arrow keys.</p>
</div>
</body>
</html>

View File

@ -18,6 +18,7 @@
<li><a href="range-vertical.html">Vertical range slider</a></li>
<li><a href="multiple-vertical.html">Multiple sliders</a></li>
<li><a href="colorpicker.html">Simple colorpicker</a></li>
<li><a href="custom-handle.html">Custom handle</a></li>
</ul>
</body>

View File

@ -9,10 +9,21 @@
<script src="../../external/requirejs/require.js"></script>
<script src="../bootstrap.js" data-modules="sortable">
var tabs = $( "#tabs" ).tabs();
var previouslyFocused = false;
tabs.find( ".ui-tabs-nav" ).sortable({
axis: "x",
stop: function() {
// Sortable removes focus, so we need to restore it if the tab was focused
// prior to sorting
start: function(event, ui) {
previouslyFocused = document.activeElement === ui.item[ 0 ];
},
stop: function(event, ui) {
tabs.tabs( "refresh" );
if (previouslyFocused) {
ui.item.focus();
}
}
});
</script>

36
external/jquery-1.12.0/LICENSE.txt vendored Normal file
View File

@ -0,0 +1,36 @@
Copyright jQuery Foundation and other contributors, https://jquery.org/
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/jquery/jquery
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
All files located in the node_modules and external directories are
externally maintained libraries used by this software which have their
own licenses; we recommend you read them, as their terms may differ from
the terms above.

11027
external/jquery-1.12.0/jquery.js vendored Normal file

File diff suppressed because it is too large Load Diff

36
external/jquery-1.12.1/LICENSE.txt vendored Normal file
View File

@ -0,0 +1,36 @@
Copyright jQuery Foundation and other contributors, https://jquery.org/
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/jquery/jquery
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
All files located in the node_modules and external directories are
externally maintained libraries used by this software which have their
own licenses; we recommend you read them, as their terms may differ from
the terms above.

11026
external/jquery-1.12.1/jquery.js vendored Normal file

File diff suppressed because it is too large Load Diff

36
external/jquery-1.12.2/LICENSE.txt vendored Normal file
View File

@ -0,0 +1,36 @@
Copyright jQuery Foundation and other contributors, https://jquery.org/
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/jquery/jquery
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
All files located in the node_modules and external directories are
externally maintained libraries used by this software which have their
own licenses; we recommend you read them, as their terms may differ from
the terms above.

11022
external/jquery-1.12.2/jquery.js vendored Normal file

File diff suppressed because it is too large Load Diff

36
external/jquery-1.12.3/LICENSE.txt vendored Normal file
View File

@ -0,0 +1,36 @@
Copyright jQuery Foundation and other contributors, https://jquery.org/
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/jquery/jquery
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
All files located in the node_modules and external directories are
externally maintained libraries used by this software which have their
own licenses; we recommend you read them, as their terms may differ from
the terms above.

11015
external/jquery-1.12.3/jquery.js vendored Normal file

File diff suppressed because it is too large Load Diff

36
external/jquery-1.12.4/LICENSE.txt vendored Normal file
View File

@ -0,0 +1,36 @@
Copyright jQuery Foundation and other contributors, https://jquery.org/
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/jquery/jquery
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
All files located in the node_modules and external directories are
externally maintained libraries used by this software which have their
own licenses; we recommend you read them, as their terms may differ from
the terms above.

11008
external/jquery-1.12.4/jquery.js vendored Normal file

File diff suppressed because it is too large Load Diff

21
external/jquery-2.1.4/MIT-LICENSE.txt vendored Normal file
View File

@ -0,0 +1,21 @@
Copyright 2014 jQuery Foundation and other contributors
http://jquery.com/
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

9210
external/jquery-2.1.4/jquery.js vendored Normal file

File diff suppressed because it is too large Load Diff

36
external/jquery-2.2.0/LICENSE.txt vendored Normal file
View File

@ -0,0 +1,36 @@
Copyright jQuery Foundation and other contributors, https://jquery.org/
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/jquery/jquery
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
All files located in the node_modules and external directories are
externally maintained libraries used by this software which have their
own licenses; we recommend you read them, as their terms may differ from
the terms above.

9831
external/jquery-2.2.0/jquery.js vendored Normal file

File diff suppressed because it is too large Load Diff

36
external/jquery-2.2.1/LICENSE.txt vendored Normal file
View File

@ -0,0 +1,36 @@
Copyright jQuery Foundation and other contributors, https://jquery.org/
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/jquery/jquery
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
All files located in the node_modules and external directories are
externally maintained libraries used by this software which have their
own licenses; we recommend you read them, as their terms may differ from
the terms above.

9831
external/jquery-2.2.1/jquery.js vendored Normal file

File diff suppressed because it is too large Load Diff

36
external/jquery-2.2.2/LICENSE.txt vendored Normal file
View File

@ -0,0 +1,36 @@
Copyright jQuery Foundation and other contributors, https://jquery.org/
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/jquery/jquery
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
All files located in the node_modules and external directories are
externally maintained libraries used by this software which have their
own licenses; we recommend you read them, as their terms may differ from
the terms above.

9842
external/jquery-2.2.2/jquery.js vendored Normal file

File diff suppressed because it is too large Load Diff

36
external/jquery-2.2.3/LICENSE.txt vendored Normal file
View File

@ -0,0 +1,36 @@
Copyright jQuery Foundation and other contributors, https://jquery.org/
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/jquery/jquery
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
All files located in the node_modules and external directories are
externally maintained libraries used by this software which have their
own licenses; we recommend you read them, as their terms may differ from
the terms above.

9842
external/jquery-2.2.3/jquery.js vendored Normal file

File diff suppressed because it is too large Load Diff

36
external/jquery-2.2.4/LICENSE.txt vendored Normal file
View File

@ -0,0 +1,36 @@
Copyright jQuery Foundation and other contributors, https://jquery.org/
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/jquery/jquery
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
All files located in the node_modules and external directories are
externally maintained libraries used by this software which have their
own licenses; we recommend you read them, as their terms may differ from
the terms above.

9814
external/jquery-2.2.4/jquery.js vendored Normal file

File diff suppressed because it is too large Load Diff

36
external/jquery-3.0.0/LICENSE.txt vendored Normal file
View File

@ -0,0 +1,36 @@
Copyright jQuery Foundation and other contributors, https://jquery.org/
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/jquery/jquery
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
All files located in the node_modules and external directories are
externally maintained libraries used by this software which have their
own licenses; we recommend you read them, as their terms may differ from
the terms above.

10037
external/jquery-3.0.0/jquery.js vendored Normal file

File diff suppressed because it is too large Load Diff

36
external/jquery-3.1.0/LICENSE.txt vendored Normal file
View File

@ -0,0 +1,36 @@
Copyright jQuery Foundation and other contributors, https://jquery.org/
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/jquery/jquery
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
All files located in the node_modules and external directories are
externally maintained libraries used by this software which have their
own licenses; we recommend you read them, as their terms may differ from
the terms above.

10074
external/jquery-3.1.0/jquery.js vendored Normal file

File diff suppressed because it is too large Load Diff

36
external/jquery-3.1.1/LICENSE.txt vendored Normal file
View File

@ -0,0 +1,36 @@
Copyright jQuery Foundation and other contributors, https://jquery.org/
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/jquery/jquery
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
All files located in the node_modules and external directories are
externally maintained libraries used by this software which have their
own licenses; we recommend you read them, as their terms may differ from
the terms above.

10220
external/jquery-3.1.1/jquery.js vendored Normal file

File diff suppressed because it is too large Load Diff

36
external/jquery/LICENSE.txt vendored Normal file
View File

@ -0,0 +1,36 @@
Copyright jQuery Foundation and other contributors, https://jquery.org/
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/jquery/jquery
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
All files located in the node_modules and external directories are
externally maintained libraries used by this software which have their
own licenses; we recommend you read them, as their terms may differ from
the terms above.

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
"name": "jquery-ui",
"title": "jQuery UI",
"description": "A curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library.",
"version": "1.12.0-pre",
"version": "1.12.2-pre",
"homepage": "http://jqueryui.com",
"author": {
"name": "jQuery Foundation and other contributors",
@ -57,6 +57,7 @@
"globalize-compiler": "0.2.0",
"grunt": "0.4.5",
"grunt-bowercopy": "1.2.4",
"grunt-cli": "0.1.13",
"grunt-compare-size": "0.4.0",
"grunt-contrib-concat": "0.5.1",
"grunt-contrib-csslint": "0.5.0",

View File

@ -18,24 +18,11 @@
"jquery": true,
"globals": {
"asyncTest": false,
"deepEqual": false,
"define": false,
"equal": false,
"expect": false,
"Globalize": false,
"module": false,
"notEqual": false,
"notDeepEqual": false,
"notStrictEqual": false,
"ok": false,
"QUnit": true,
"QUnit": false,
"require": true,
"requirejs": true,
"start": false,
"strictEqual": false,
"stop": false,
"test": false,
"JSHINT": false
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -105,7 +105,7 @@ function jqueryUrl() {
if ( version === "git" ) {
url = "http://code.jquery.com/jquery-" + version;
} else {
url = "../../../external/jquery-" + ( version || "1.11.3" ) + "/jquery";
url = "../../../external/jquery-" + ( version || "1.12.4" ) + "/jquery";
}
return url;

View File

@ -1,6 +1,7 @@
define( [
"jquery"
], function( $ ) {
"qunit",
"jquery" ],
function( QUnit, $ ) {
var exports = {};
@ -8,39 +9,39 @@ function testWidgetDefaults( widget, defaults ) {
var pluginDefaults = $.ui[ widget ].prototype.options;
// Ensure that all defaults have the correct value
test( "defined defaults", function() {
QUnit.test( "defined defaults", function( assert ) {
var count = 0;
$.each( defaults, function( key, val ) {
expect( ++count );
assert.expect( ++count );
if ( $.isFunction( val ) ) {
ok( $.isFunction( pluginDefaults[ key ] ), key );
assert.ok( $.isFunction( pluginDefaults[ key ] ), key );
return;
}
deepEqual( pluginDefaults[ key ], val, key );
assert.deepEqual( pluginDefaults[ key ], val, key );
} );
} );
// Ensure that all defaults were tested
test( "tested defaults", function() {
QUnit.test( "tested defaults", function( assert ) {
var count = 0;
$.each( pluginDefaults, function( key ) {
expect( ++count );
ok( key in defaults, key );
assert.expect( ++count );
assert.ok( key in defaults, key );
} );
} );
}
function testWidgetOverrides( widget ) {
if ( $.uiBackCompat === false ) {
test( "$.widget overrides", function() {
expect( 4 );
QUnit.test( "$.widget overrides", function( assert ) {
assert.expect( 4 );
$.each( [
"_createWidget",
"destroy",
"option",
"_trigger"
], function( i, method ) {
strictEqual( $.ui[ widget ].prototype[ method ],
assert.strictEqual( $.ui[ widget ].prototype[ method ],
$.Widget.prototype[ method ], "should not override " + method );
} );
} );
@ -48,24 +49,24 @@ function testWidgetOverrides( widget ) {
}
function testBasicUsage( widget ) {
test( "basic usage", function() {
expect( 3 );
QUnit.test( "basic usage", function( assert ) {
assert.expect( 3 );
var defaultElement = $.ui[ widget ].prototype.defaultElement;
$( defaultElement ).appendTo( "body" )[ widget ]().remove();
ok( true, "initialized on element" );
assert.ok( true, "initialized on element" );
$( defaultElement )[ widget ]().remove();
ok( true, "initialized on disconnected DOMElement - never connected" );
assert.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" );
assert.ok( true, "initialized on disconnected DOMElement - removed" );
} );
}
exports.testWidget = function( widget, settings ) {
module( widget + ": common widget" );
QUnit.module( widget + ": common widget" );
exports.testJshint( "/widgets/" + widget );
testWidgetDefaults( widget, settings.defaults );
@ -73,9 +74,9 @@ exports.testWidget = function( widget, settings ) {
if ( !settings.noDefaultElement ) {
testBasicUsage( widget );
}
test( "version", function() {
expect( 1 );
ok( "version" in $.ui[ widget ].prototype, "version property exists" );
QUnit.test( "version", function( assert ) {
assert.expect( 1 );
assert.ok( "version" in $.ui[ widget ].prototype, "version property exists" );
} );
};
@ -87,9 +88,10 @@ exports.testJshint = function( module ) {
return;
}
asyncTest( "JSHint", function() {
QUnit.test( "JSHint", function( assert ) {
var ready = assert.async();
require( [ "jshint" ], function() {
expect( 1 );
assert.expect( 1 );
$.when(
$.ajax( {
@ -119,12 +121,12 @@ exports.testJshint = function( module ) {
return "[L" + error.line + ":C" + error.character + "] " +
error.reason + "\n" + error.evidence + "\n";
} ).join( "\n" );
ok( passed, errors );
start();
assert.ok( passed, errors );
ready();
} )
.fail( function( hintError, srcError ) {
ok( false, "error loading source: " + ( hintError || srcError ).statusText );
start();
assert.ok( false, "error loading source: " + ( hintError || srcError ).statusText );
ready();
} );
} );
} );

View File

@ -99,11 +99,11 @@ function extract( selector, message ) {
var children;
$.each( domEqual.properties, function( index, attr ) {
var value = elem.prop( attr );
result[ attr ] = value != null ? value : "";
result[ attr ] = value != null ? value : "";
} );
$.each( domEqual.attributes, function( index, attr ) {
var value = elem.attr( attr );
result[ attr ] = value != null ? value : "";
result[ attr ] = value != null ? value : "";
} );
result.style = getElementStyles( elem[ 0 ] );
result.events = $._data( elem[ 0 ], "events" );

View File

@ -26,8 +26,12 @@ QUnit.config.urlConfig.push( {
"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",
"1.12.0", "1.12.1", "1.12.2", "1.12.3", "1.12.4",
"2.0.0", "2.0.1", "2.0.2", "2.0.3",
"2.1.0", "2.1.1", "2.1.2", "2.1.3",
"2.1.0", "2.1.1", "2.1.2", "2.1.3", "2.1.4",
"2.2.0", "2.2.1", "2.2.2", "2.2.3", "2.2.4",
"3.0.0",
"3.1.0", "3.1.1",
"git", "custom"
],
tooltip: "Which jQuery Core version to test against"

View File

@ -1,129 +1,131 @@
define( [
"qunit",
"jquery",
"./helper",
"ui/widgets/accordion"
], function( $, testHelper ) {
], function( QUnit, $, testHelper ) {
var setupTeardown = testHelper.setupTeardown,
state = testHelper.state;
module( "accordion: core", setupTeardown() );
QUnit.module( "accordion: core", setupTeardown() );
$.each( { div: "#list1", ul: "#navigation", dl: "#accordion-dl" }, function( type, selector ) {
test( "markup structure: " + type, function( assert ) {
expect( 10 );
QUnit.test( "markup structure: " + type, function( assert ) {
assert.expect( 10 );
var element = $( selector ).accordion(),
headers = element.find( ".ui-accordion-header" ),
content = headers.next();
assert.hasClasses( element, "ui-accordion ui-widget" );
equal( headers.length, 3, ".ui-accordion-header elements exist, correct number" );
assert.equal( headers.length, 3, ".ui-accordion-header elements exist, correct number" );
assert.hasClasses( headers[ 0 ],
"ui-accordion-header ui-accordion-header-active ui-accordion-icons" );
assert.hasClasses( headers[ 1 ],
"ui-accordion-header ui-accordion-header-collapsed ui-accordion-icons" );
assert.hasClasses( headers[ 2 ],
"ui-accordion-header ui-accordion-header-collapsed ui-accordion-icons" );
equal( content.length, 3, ".ui-accordion-content elements exist, correct number" );
assert.equal( content.length, 3, ".ui-accordion-content elements exist, correct number" );
assert.hasClasses( content[ 0 ],
"ui-accordion-content ui-widget-content ui-accordion-content-active" );
assert.hasClasses( content[ 1 ], "ui-accordion-content ui-widget-content" );
assert.hasClasses( content[ 2 ], "ui-accordion-content ui-widget-content" );
deepEqual( element.find( ".ui-accordion-header" ).next().get(),
assert.deepEqual( element.find( ".ui-accordion-header" ).next().get(),
element.find( ".ui-accordion-content" ).get(),
"content panels come immediately after headers" );
} );
} );
test( "handle click on header-descendant", function() {
expect( 1 );
QUnit.test( "handle click on header-descendant", function( assert ) {
assert.expect( 1 );
var element = $( "#navigation" ).accordion();
$( "#navigation h2:eq(1) a" ).trigger( "click" );
state( element, 0, 1, 0 );
state( assert, element, 0, 1, 0 );
} );
test( "accessibility", function() {
expect( 61 );
QUnit.test( "accessibility", function( assert ) {
assert.expect( 61 );
var element = $( "#list1" ).accordion( {
active: 1,
collapsible: true
} ),
headers = element.find( ".ui-accordion-header" );
equal( element.attr( "role" ), "tablist", "element role" );
assert.equal( element.attr( "role" ), "tablist", "element role" );
headers.each( function( i ) {
var header = headers.eq( i ),
panel = header.next();
equal( header.attr( "role" ), "tab", "header " + i + " role" );
equal( header.attr( "aria-controls" ), panel.attr( "id" ), "header " + i + " aria-controls" );
equal( panel.attr( "role" ), "tabpanel", "panel " + i + " role" );
equal( panel.attr( "aria-labelledby" ), header.attr( "id" ), "panel " + i + " aria-labelledby" );
assert.equal( header.attr( "role" ), "tab", "header " + i + " role" );
assert.equal( header.attr( "aria-controls" ), panel.attr( "id" ), "header " + i + " aria-controls" );
assert.equal( panel.attr( "role" ), "tabpanel", "panel " + i + " role" );
assert.equal( panel.attr( "aria-labelledby" ), header.attr( "id" ), "panel " + i + " aria-labelledby" );
} );
equal( headers.eq( 1 ).attr( "tabindex" ), 0, "active header has tabindex=0" );
equal( headers.eq( 1 ).attr( "aria-selected" ), "true", "active tab (1) has aria-selected=true" );
equal( headers.eq( 1 ).attr( "aria-expanded" ), "true", "active tab (1) has aria-expanded=true" );
equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "false", "active tabpanel (1) has aria-hidden=false" );
equal( headers.eq( 0 ).attr( "tabindex" ), -1, "inactive header (0) has tabindex=-1" );
equal( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab (0) has aria-selected=false" );
equal( headers.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab (0) has aria-expanded=false" );
equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (0) has aria-hidden=true" );
equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header (2) has tabindex=-1" );
equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab (2) has aria-selected=false" );
equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab (2) has aria-expanded=false" );
equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (2) has aria-hidden=true" );
assert.equal( headers.eq( 1 ).attr( "tabindex" ), 0, "active header has tabindex=0" );
assert.equal( headers.eq( 1 ).attr( "aria-selected" ), "true", "active tab (1) has aria-selected=true" );
assert.equal( headers.eq( 1 ).attr( "aria-expanded" ), "true", "active tab (1) has aria-expanded=true" );
assert.equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "false", "active tabpanel (1) has aria-hidden=false" );
assert.equal( headers.eq( 0 ).attr( "tabindex" ), -1, "inactive header (0) has tabindex=-1" );
assert.equal( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab (0) has aria-selected=false" );
assert.equal( headers.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab (0) has aria-expanded=false" );
assert.equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (0) has aria-hidden=true" );
assert.equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header (2) has tabindex=-1" );
assert.equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab (2) has aria-selected=false" );
assert.equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab (2) has aria-expanded=false" );
assert.equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (2) has aria-hidden=true" );
element.accordion( "option", "active", 0 );
equal( headers.eq( 0 ).attr( "tabindex" ), 0, "active header (0) has tabindex=0" );
equal( headers.eq( 0 ).attr( "aria-selected" ), "true", "active tab (0) has aria-selected=true" );
equal( headers.eq( 0 ).attr( "aria-expanded" ), "true", "active tab (0) has aria-expanded=true" );
equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "false", "active tabpanel (0) has aria-hidden=false" );
equal( headers.eq( 1 ).attr( "tabindex" ), -1, "inactive header (1) has tabindex=-1" );
equal( headers.eq( 1 ).attr( "aria-selected" ), "false", "inactive tab (1) has aria-selected=false" );
equal( headers.eq( 1 ).attr( "aria-expanded" ), "false", "inactive tab (1) has aria-expanded=false" );
equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (1) has aria-hidden=true" );
equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header (2) has tabindex=-1" );
equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab (2) has aria-selected=false" );
equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab (2) has aria-expanded=false" );
equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (2) has aria-hidden=true" );
assert.equal( headers.eq( 0 ).attr( "tabindex" ), 0, "active header (0) has tabindex=0" );
assert.equal( headers.eq( 0 ).attr( "aria-selected" ), "true", "active tab (0) has aria-selected=true" );
assert.equal( headers.eq( 0 ).attr( "aria-expanded" ), "true", "active tab (0) has aria-expanded=true" );
assert.equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "false", "active tabpanel (0) has aria-hidden=false" );
assert.equal( headers.eq( 1 ).attr( "tabindex" ), -1, "inactive header (1) has tabindex=-1" );
assert.equal( headers.eq( 1 ).attr( "aria-selected" ), "false", "inactive tab (1) has aria-selected=false" );
assert.equal( headers.eq( 1 ).attr( "aria-expanded" ), "false", "inactive tab (1) has aria-expanded=false" );
assert.equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (1) has aria-hidden=true" );
assert.equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header (2) has tabindex=-1" );
assert.equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab (2) has aria-selected=false" );
assert.equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab (2) has aria-expanded=false" );
assert.equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (2) has aria-hidden=true" );
element.accordion( "option", "active", false );
equal( headers.eq( 0 ).attr( "tabindex" ), 0, "previously active header (0) has tabindex=0" );
equal( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab (0) has aria-selected=false" );
equal( headers.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab (0) has aria-expanded=false" );
equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (0) has aria-hidden=true" );
equal( headers.eq( 1 ).attr( "tabindex" ), -1, "inactive header (1) has tabindex=-1" );
equal( headers.eq( 1 ).attr( "aria-selected" ), "false", "inactive tab (1) has aria-selected=false" );
equal( headers.eq( 1 ).attr( "aria-expanded" ), "false", "inactive tab (1) has aria-expanded=false" );
equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (1) has aria-hidden=true" );
equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header (2) has tabindex=-1" );
equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab (2) has aria-selected=false" );
equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab (2) has aria-expanded=false" );
equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (2) has aria-hidden=true" );
assert.equal( headers.eq( 0 ).attr( "tabindex" ), 0, "previously active header (0) has tabindex=0" );
assert.equal( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab (0) has aria-selected=false" );
assert.equal( headers.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab (0) has aria-expanded=false" );
assert.equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (0) has aria-hidden=true" );
assert.equal( headers.eq( 1 ).attr( "tabindex" ), -1, "inactive header (1) has tabindex=-1" );
assert.equal( headers.eq( 1 ).attr( "aria-selected" ), "false", "inactive tab (1) has aria-selected=false" );
assert.equal( headers.eq( 1 ).attr( "aria-expanded" ), "false", "inactive tab (1) has aria-expanded=false" );
assert.equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (1) has aria-hidden=true" );
assert.equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header (2) has tabindex=-1" );
assert.equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab (2) has aria-selected=false" );
assert.equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab (2) has aria-expanded=false" );
assert.equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (2) has aria-hidden=true" );
element.accordion( "option", "active", 1 );
equal( headers.eq( 1 ).attr( "tabindex" ), 0, "active header has tabindex=0" );
equal( headers.eq( 1 ).attr( "aria-selected" ), "true", "active tab (1) has aria-selected=true" );
equal( headers.eq( 1 ).attr( "aria-expanded" ), "true", "active tab (1) has aria-expanded=true" );
equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "false", "active tabpanel (1) has aria-hidden=false" );
equal( headers.eq( 0 ).attr( "tabindex" ), -1, "inactive header (0) has tabindex=-1" );
equal( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab (0) has aria-selected=false" );
equal( headers.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab (0) has aria-expanded=false" );
equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (0) has aria-hidden=true" );
equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header (2) has tabindex=-1" );
equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab (2) has aria-selected=false" );
equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab (2) has aria-expanded=false" );
equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (2) has aria-hidden=true" );
assert.equal( headers.eq( 1 ).attr( "tabindex" ), 0, "active header has tabindex=0" );
assert.equal( headers.eq( 1 ).attr( "aria-selected" ), "true", "active tab (1) has aria-selected=true" );
assert.equal( headers.eq( 1 ).attr( "aria-expanded" ), "true", "active tab (1) has aria-expanded=true" );
assert.equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "false", "active tabpanel (1) has aria-hidden=false" );
assert.equal( headers.eq( 0 ).attr( "tabindex" ), -1, "inactive header (0) has tabindex=-1" );
assert.equal( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab (0) has aria-selected=false" );
assert.equal( headers.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab (0) has aria-expanded=false" );
assert.equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (0) has aria-hidden=true" );
assert.equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header (2) has tabindex=-1" );
assert.equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab (2) has aria-selected=false" );
assert.equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab (2) has aria-expanded=false" );
assert.equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel (2) has aria-hidden=true" );
} );
asyncTest( "keyboard support", function( assert ) {
expect( 13 );
QUnit.test( "keyboard support", function( assert ) {
var ready = assert.async();
assert.expect( 13 );
var element = $( "#list1" ).accordion(),
headers = element.find( ".ui-accordion-header" ),
anchor = headers.eq( 1 ).next().find( "a" ).eq( 0 ),
keyCode = $.ui.keyCode;
equal( headers.filter( ".ui-state-focus" ).length, 0, "no headers focused on init" );
assert.equal( headers.filter( ".ui-state-focus" ).length, 0, "no headers focused on init" );
headers.eq( 0 ).simulate( "focus" );
setTimeout( step1 );
@ -180,13 +182,13 @@ asyncTest( "keyboard support", function( assert ) {
}
function step9() {
equal( element.accordion( "option", "active" ), 2, "ENTER activates panel" );
assert.equal( element.accordion( "option", "active" ), 2, "ENTER activates panel" );
headers.eq( 1 ).simulate( "keydown", { keyCode: keyCode.SPACE } );
setTimeout( step10 );
}
function step10() {
equal( element.accordion( "option", "active" ), 1, "SPACE activates panel" );
assert.equal( element.accordion( "option", "active" ), 1, "SPACE activates panel" );
anchor.simulate( "focus" );
setTimeout( step11 );
}
@ -200,7 +202,7 @@ asyncTest( "keyboard support", function( assert ) {
function step12() {
assert.hasClasses( headers.eq( 1 ), "ui-state-focus", "CTRL+UP moves focus to header" );
start();
ready();
}
} );

View File

@ -1,16 +1,17 @@
define( [
"qunit",
"jquery",
"./helper",
"ui/widgets/accordion"
], function( $, testHelper ) {
], function( QUnit, $, testHelper ) {
var setupTeardown = testHelper.setupTeardown,
state = testHelper.state;
module( "accordion: events", setupTeardown() );
QUnit.module( "accordion: events", setupTeardown() );
test( "create", function() {
expect( 10 );
QUnit.test( "create", function( assert ) {
assert.expect( 10 );
var element = $( "#list1" ),
headers = element.children( "h3" ),
@ -18,10 +19,10 @@ test( "create", function() {
element.accordion( {
create: function( event, ui ) {
equal( ui.header.length, 1, "header length" );
strictEqual( ui.header[ 0 ], headers[ 0 ], "header" );
equal( ui.panel.length, 1, "panel length" );
strictEqual( ui.panel[ 0 ], contents[ 0 ], "panel" );
assert.equal( ui.header.length, 1, "header length" );
assert.strictEqual( ui.header[ 0 ], headers[ 0 ], "header" );
assert.equal( ui.panel.length, 1, "panel length" );
assert.strictEqual( ui.panel[ 0 ], contents[ 0 ], "panel" );
}
} );
element.accordion( "destroy" );
@ -29,10 +30,10 @@ test( "create", function() {
element.accordion( {
active: 2,
create: function( event, ui ) {
equal( ui.header.length, 1, "header length" );
strictEqual( ui.header[ 0 ], headers[ 2 ], "header" );
equal( ui.panel.length, 1, "panel length" );
strictEqual( ui.panel[ 0 ], contents[ 2 ], "panel" );
assert.equal( ui.header.length, 1, "header length" );
assert.strictEqual( ui.header[ 0 ], headers[ 2 ], "header" );
assert.equal( ui.panel.length, 1, "panel length" );
assert.strictEqual( ui.panel[ 0 ], contents[ 2 ], "panel" );
}
} );
element.accordion( "destroy" );
@ -41,15 +42,15 @@ test( "create", function() {
active: false,
collapsible: true,
create: function( event, ui ) {
equal( ui.header.length, 0, "header length" );
equal( ui.panel.length, 0, "panel length" );
assert.equal( ui.header.length, 0, "header length" );
assert.equal( ui.panel.length, 0, "panel length" );
}
} );
element.accordion( "destroy" );
} );
test( "beforeActivate", function() {
expect( 38 );
QUnit.test( "beforeActivate", function( assert ) {
assert.expect( 38 );
var element = $( "#list1" ).accordion( {
active: false,
collapsible: true
@ -58,63 +59,63 @@ test( "beforeActivate", function() {
content = element.find( ".ui-accordion-content" );
element.one( "accordionbeforeactivate", function( event, ui ) {
ok( !( "originalEvent" in event ) );
equal( ui.oldHeader.length, 0 );
equal( ui.oldPanel.length, 0 );
equal( ui.newHeader.length, 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 0 ] );
equal( ui.newPanel.length, 1 );
strictEqual( ui.newPanel[ 0 ], content[ 0 ] );
state( element, 0, 0, 0 );
assert.ok( !( "originalEvent" in event ) );
assert.equal( ui.oldHeader.length, 0 );
assert.equal( ui.oldPanel.length, 0 );
assert.equal( ui.newHeader.length, 1 );
assert.strictEqual( ui.newHeader[ 0 ], headers[ 0 ] );
assert.equal( ui.newPanel.length, 1 );
assert.strictEqual( ui.newPanel[ 0 ], content[ 0 ] );
state( assert, element, 0, 0, 0 );
} );
element.accordion( "option", "active", 0 );
state( element, 1, 0, 0 );
state( assert, element, 1, 0, 0 );
element.one( "accordionbeforeactivate", function( event, ui ) {
equal( event.originalEvent.type, "click" );
equal( ui.oldHeader.length, 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] );
equal( ui.oldPanel.length, 1 );
strictEqual( ui.oldPanel[ 0 ], content[ 0 ] );
equal( ui.newHeader.length, 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 1 ] );
equal( ui.newPanel.length, 1 );
strictEqual( ui.newPanel[ 0 ], content[ 1 ] );
state( element, 1, 0, 0 );
assert.equal( event.originalEvent.type, "click" );
assert.equal( ui.oldHeader.length, 1 );
assert.strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] );
assert.equal( ui.oldPanel.length, 1 );
assert.strictEqual( ui.oldPanel[ 0 ], content[ 0 ] );
assert.equal( ui.newHeader.length, 1 );
assert.strictEqual( ui.newHeader[ 0 ], headers[ 1 ] );
assert.equal( ui.newPanel.length, 1 );
assert.strictEqual( ui.newPanel[ 0 ], content[ 1 ] );
state( assert, element, 1, 0, 0 );
} );
headers.eq( 1 ).trigger( "click" );
state( element, 0, 1, 0 );
state( assert, element, 0, 1, 0 );
element.one( "accordionbeforeactivate", function( event, ui ) {
ok( !( "originalEvent" in event ) );
equal( ui.oldHeader.length, 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] );
equal( ui.oldPanel.length, 1 );
strictEqual( ui.oldPanel[ 0 ], content[ 1 ] );
equal( ui.newHeader.length, 0 );
equal( ui.newPanel.length, 0 );
state( element, 0, 1, 0 );
assert.ok( !( "originalEvent" in event ) );
assert.equal( ui.oldHeader.length, 1 );
assert.strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] );
assert.equal( ui.oldPanel.length, 1 );
assert.strictEqual( ui.oldPanel[ 0 ], content[ 1 ] );
assert.equal( ui.newHeader.length, 0 );
assert.equal( ui.newPanel.length, 0 );
state( assert, element, 0, 1, 0 );
} );
element.accordion( "option", "active", false );
state( element, 0, 0, 0 );
state( assert, element, 0, 0, 0 );
element.one( "accordionbeforeactivate", function( event, ui ) {
ok( !( "originalEvent" in event ) );
equal( ui.oldHeader.length, 0 );
equal( ui.oldPanel.length, 0 );
equal( ui.newHeader.length, 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 2 ] );
equal( ui.newPanel.length, 1 );
strictEqual( ui.newPanel[ 0 ], content[ 2 ] );
assert.ok( !( "originalEvent" in event ) );
assert.equal( ui.oldHeader.length, 0 );
assert.equal( ui.oldPanel.length, 0 );
assert.equal( ui.newHeader.length, 1 );
assert.strictEqual( ui.newHeader[ 0 ], headers[ 2 ] );
assert.equal( ui.newPanel.length, 1 );
assert.strictEqual( ui.newPanel[ 0 ], content[ 2 ] );
event.preventDefault();
state( element, 0, 0, 0 );
state( assert, element, 0, 0, 0 );
} );
element.accordion( "option", "active", 2 );
state( element, 0, 0, 0 );
state( assert, element, 0, 0, 0 );
} );
test( "activate", function() {
expect( 21 );
QUnit.test( "activate", function( assert ) {
assert.expect( 21 );
var element = $( "#list1" ).accordion( {
active: false,
collapsible: true
@ -123,44 +124,44 @@ test( "activate", function() {
content = element.find( ".ui-accordion-content" );
element.one( "accordionactivate", function( event, ui ) {
equal( ui.oldHeader.length, 0 );
equal( ui.oldPanel.length, 0 );
equal( ui.newHeader.length, 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 0 ] );
equal( ui.newPanel.length, 1 );
strictEqual( ui.newPanel[ 0 ], content[ 0 ] );
assert.equal( ui.oldHeader.length, 0 );
assert.equal( ui.oldPanel.length, 0 );
assert.equal( ui.newHeader.length, 1 );
assert.strictEqual( ui.newHeader[ 0 ], headers[ 0 ] );
assert.equal( ui.newPanel.length, 1 );
assert.strictEqual( ui.newPanel[ 0 ], content[ 0 ] );
} );
element.accordion( "option", "active", 0 );
element.one( "accordionactivate", function( event, ui ) {
equal( ui.oldHeader.length, 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] );
equal( ui.oldPanel.length, 1 );
strictEqual( ui.oldPanel[ 0 ], content[ 0 ] );
equal( ui.newHeader.length, 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 1 ] );
equal( ui.newPanel.length, 1 );
strictEqual( ui.newPanel[ 0 ], content[ 1 ] );
assert.equal( ui.oldHeader.length, 1 );
assert.strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] );
assert.equal( ui.oldPanel.length, 1 );
assert.strictEqual( ui.oldPanel[ 0 ], content[ 0 ] );
assert.equal( ui.newHeader.length, 1 );
assert.strictEqual( ui.newHeader[ 0 ], headers[ 1 ] );
assert.equal( ui.newPanel.length, 1 );
assert.strictEqual( ui.newPanel[ 0 ], content[ 1 ] );
} );
headers.eq( 1 ).trigger( "click" );
element.one( "accordionactivate", function( event, ui ) {
equal( ui.oldHeader.length, 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] );
equal( ui.oldPanel.length, 1 );
strictEqual( ui.oldPanel[ 0 ], content[ 1 ] );
equal( ui.newHeader.length, 0 );
equal( ui.newPanel.length, 0 );
assert.equal( ui.oldHeader.length, 1 );
assert.strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] );
assert.equal( ui.oldPanel.length, 1 );
assert.strictEqual( ui.oldPanel[ 0 ], content[ 1 ] );
assert.equal( ui.newHeader.length, 0 );
assert.equal( ui.newPanel.length, 0 );
} );
element.accordion( "option", "active", false );
// Prevent activation
element.one( "accordionbeforeactivate", function( event ) {
ok( true );
assert.ok( true );
event.preventDefault();
} );
element.one( "accordionactivate", function() {
ok( false );
assert.ok( false );
} );
element.accordion( "option", "active", 1 );
} );

View File

@ -1,13 +1,14 @@
define( [
"qunit",
"jquery",
"lib/helper",
"ui/widgets/accordion"
], function( $, helper ) {
], function( QUnit, $, helper ) {
return $.extend( helper, {
equalHeight: function( accordion, height ) {
equalHeight: function( assert, accordion, height ) {
accordion.find( ".ui-accordion-content" ).each( function() {
equal( $( this ).outerHeight(), height );
assert.equal( $( this ).outerHeight(), height );
} );
},
@ -23,12 +24,12 @@ return $.extend( helper, {
};
},
state: function( accordion ) {
var expected = $.makeArray( arguments ).slice( 1 ),
state: function( assert, accordion ) {
var expected = $.makeArray( arguments ).slice( 2 ),
actual = accordion.find( ".ui-accordion-content" ).map( function() {
return $( this ).css( "display" ) === "none" ? 0 : 1;
} ).get();
QUnit.push( QUnit.equiv( actual, expected ), actual, expected );
assert.deepEqual( actual, expected );
}
} );

View File

@ -1,47 +1,48 @@
define( [
"qunit",
"jquery",
"./helper",
"ui/widgets/accordion"
], function( $, testHelper ) {
], function( QUnit, $, testHelper ) {
var equalHeight = testHelper.equalHeight,
setupTeardown = testHelper.setupTeardown,
state = testHelper.state;
module( "accordion: methods", setupTeardown() );
QUnit.module( "accordion: methods", setupTeardown() );
test( "destroy", function( assert ) {
expect( 1 );
QUnit.test( "destroy", function( assert ) {
assert.expect( 1 );
assert.domEqual( "#list1", function() {
$( "#list1" ).accordion().accordion( "destroy" );
} );
} );
test( "enable/disable", function( assert ) {
expect( 7 );
QUnit.test( "enable/disable", function( assert ) {
assert.expect( 7 );
var element = $( "#list1" ).accordion();
state( element, 1, 0, 0 );
state( assert, element, 1, 0, 0 );
element.accordion( "disable" );
assert.hasClasses( element, "ui-state-disabled" );
equal( element.attr( "aria-disabled" ), "true", "element gets aria-disabled" );
assert.equal( element.attr( "aria-disabled" ), "true", "element gets aria-disabled" );
assert.hasClasses( element, "ui-accordion-disabled" );
// Event does nothing
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" );
state( element, 1, 0, 0 );
state( assert, element, 1, 0, 0 );
// Option still works
element.accordion( "option", "active", 1 );
state( element, 0, 1, 0 );
state( assert, element, 0, 1, 0 );
element.accordion( "enable" );
element.accordion( "option", "active", 2 );
state( element, 0, 0, 1 );
state( assert, element, 0, 0, 1 );
} );
test( "refresh", function() {
expect( 19 );
QUnit.test( "refresh", function( assert ) {
assert.expect( 19 );
var element = $( "#navigation" )
.parent()
.height( 300 )
@ -49,37 +50,37 @@ test( "refresh", function() {
.accordion( {
heightStyle: "fill"
} );
equalHeight( element, 255 );
equalHeight( assert, element, 255 );
element.parent().height( 500 );
element.accordion( "refresh" );
equalHeight( element, 455 );
equalHeight( assert, element, 455 );
element = $( "#list1" );
element.accordion();
state( element, 1, 0, 0 );
state( assert, element, 1, 0, 0 );
// Disable panel via markup
element.find( "h3.bar" ).eq( 1 ).addClass( "ui-state-disabled" );
element.accordion( "refresh" );
state( element, 1, 0, 0 );
state( assert, element, 1, 0, 0 );
// Don't add multiple icons
element.accordion( "refresh" );
equal( element.find( ".ui-accordion-header-icon" ).length, 3 );
assert.equal( element.find( ".ui-accordion-header-icon" ).length, 3 );
// Add a panel
element
.append( "<h3 class='bar' id='new_1'>new 1</h3>" )
.append( "<div class='foo' id='new_1_panel'>new 1</div>" );
element.accordion( "refresh" );
state( element, 1, 0, 0, 0 );
state( assert, element, 1, 0, 0, 0 );
// Remove all tabs
element.find( "h3.bar, div.foo" ).remove();
element.accordion( "refresh" );
state( element );
equal( element.accordion( "option", "active" ), false, "no active accordion panel" );
state( assert, element );
assert.equal( element.accordion( "option", "active" ), false, "no active accordion panel" );
// Add panels
element
@ -92,46 +93,46 @@ test( "refresh", function() {
.append( "<h3 class='bar' id='new_5'>new 5</h3>" )
.append( "<div class='foo' id='new_5_panel'>new 5</div>" );
element.accordion( "refresh" );
state( element, 1, 0, 0, 0 );
state( assert, element, 1, 0, 0, 0 );
// Activate third tab
element.accordion( "option", "active", 2 );
state( element, 0, 0, 1, 0 );
state( assert, element, 0, 0, 1, 0 );
// Remove fourth panel, third panel should stay active
element.find( "h3.bar" ).eq( 3 ).remove();
element.find( "div.foo" ).eq( 3 ).remove();
element.accordion( "refresh" );
state( element, 0, 0, 1 );
state( assert, element, 0, 0, 1 );
// Remove third (active) panel, second panel should become active
element.find( "h3.bar" ).eq( 2 ).remove();
element.find( "div.foo" ).eq( 2 ).remove();
element.accordion( "refresh" );
state( element, 0, 1 );
state( assert, element, 0, 1 );
// Remove first panel, previously active panel (now first) should stay active
element.find( "h3.bar" ).eq( 0 ).remove();
element.find( "div.foo" ).eq( 0 ).remove();
element.accordion( "refresh" );
state( element, 1 );
state( assert, element, 1 );
// Collapse all panels
element.accordion( "option", {
collapsible: true,
active: false
} );
state( element, 0 );
state( assert, element, 0 );
element.accordion( "refresh" );
state( element, 0 );
state( assert, element, 0 );
} );
test( "widget", function() {
expect( 2 );
QUnit.test( "widget", function( assert ) {
assert.expect( 2 );
var element = $( "#list1" ).accordion(),
widgetElement = element.accordion( "widget" );
equal( widgetElement.length, 1, "one element" );
strictEqual( widgetElement[ 0 ], element[ 0 ], "same element" );
assert.equal( widgetElement.length, 1, "one element" );
assert.strictEqual( widgetElement[ 0 ], element[ 0 ], "same element" );
} );
} );

View File

@ -1,56 +1,57 @@
define( [
"qunit",
"jquery",
"./helper",
"ui/widgets/accordion"
], function( $, testHelper ) {
], function( QUnit, $, testHelper ) {
var equalHeight = testHelper.equalHeight,
setupTeardown = testHelper.setupTeardown,
state = testHelper.state;
module( "accordion: options", setupTeardown() );
QUnit.module( "accordion: options", setupTeardown() );
test( "{ active: default }", function() {
expect( 2 );
QUnit.test( "{ active: default }", function( assert ) {
assert.expect( 2 );
var element = $( "#list1" ).accordion();
equal( element.accordion( "option", "active" ), 0 );
state( element, 1, 0, 0 );
assert.equal( element.accordion( "option", "active" ), 0 );
state( assert, element, 1, 0, 0 );
} );
test( "{ active: null }", function() {
expect( 2 );
QUnit.test( "{ active: null }", function( assert ) {
assert.expect( 2 );
var element = $( "#list1" ).accordion( {
active: null
} );
equal( element.accordion( "option", "active" ), 0 );
state( element, 1, 0, 0 );
assert.equal( element.accordion( "option", "active" ), 0 );
state( assert, element, 1, 0, 0 );
} );
test( "{ active: false }", function() {
expect( 7 );
QUnit.test( "{ active: false }", function( assert ) {
assert.expect( 7 );
var element = $( "#list1" ).accordion( {
active: false,
collapsible: true
} );
state( element, 0, 0, 0 );
equal( element.find( ".ui-accordion-header.ui-state-active" ).length, 0, "no headers selected" );
equal( element.accordion( "option", "active" ), false );
state( assert, element, 0, 0, 0 );
assert.equal( element.find( ".ui-accordion-header.ui-state-active" ).length, 0, "no headers selected" );
assert.equal( element.accordion( "option", "active" ), false );
element.accordion( "option", "collapsible", false );
state( element, 1, 0, 0 );
equal( element.accordion( "option", "active" ), 0 );
state( assert, element, 1, 0, 0 );
assert.equal( element.accordion( "option", "active" ), 0 );
element.accordion( "destroy" );
element.accordion( {
active: false
} );
state( element, 1, 0, 0 );
strictEqual( element.accordion( "option", "active" ), 0 );
state( assert, element, 1, 0, 0 );
assert.strictEqual( element.accordion( "option", "active" ), 0 );
} );
// http://bugs.jqueryui.com/ticket/11938
test( "{ active: false, collapsible: true }", function() {
expect( 1 );
QUnit.test( "{ active: false, collapsible: true }", function( assert ) {
assert.expect( 1 );
var element = $( "#collapsible" ).accordion(),
height = element.outerHeight();
@ -61,71 +62,72 @@ test( "{ active: false, collapsible: true }", function() {
collapsible: true
} )
.accordion( "option", "active", 0 );
equal( element.outerHeight(), height );
assert.equal( element.outerHeight(), height );
} );
test( "{ active: Number }", function() {
expect( 8 );
QUnit.test( "{ active: Number }", function( assert ) {
assert.expect( 8 );
var element = $( "#list1" ).accordion( {
active: 2
} );
equal( element.accordion( "option", "active" ), 2 );
state( element, 0, 0, 1 );
assert.equal( element.accordion( "option", "active" ), 2 );
state( assert, element, 0, 0, 1 );
element.accordion( "option", "active", 0 );
equal( element.accordion( "option", "active" ), 0 );
state( element, 1, 0, 0 );
assert.equal( element.accordion( "option", "active" ), 0 );
state( assert, element, 1, 0, 0 );
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" );
equal( element.accordion( "option", "active" ), 1 );
state( element, 0, 1, 0 );
assert.equal( element.accordion( "option", "active" ), 1 );
state( assert, element, 0, 1, 0 );
element.accordion( "option", "active", 10 );
equal( element.accordion( "option", "active" ), 1 );
state( element, 0, 1, 0 );
assert.equal( element.accordion( "option", "active" ), 1 );
state( assert, element, 0, 1, 0 );
} );
test( "{ active: -Number }", function() {
expect( 8 );
QUnit.test( "{ active: -Number }", function( assert ) {
assert.expect( 8 );
var element = $( "#list1" ).accordion( {
active: -1
} );
equal( element.accordion( "option", "active" ), 2 );
state( element, 0, 0, 1 );
assert.equal( element.accordion( "option", "active" ), 2 );
state( assert, element, 0, 0, 1 );
element.accordion( "option", "active", -2 );
equal( element.accordion( "option", "active" ), 1 );
state( element, 0, 1, 0 );
assert.equal( element.accordion( "option", "active" ), 1 );
state( assert, element, 0, 1, 0 );
element.accordion( "option", "active", -10 );
equal( element.accordion( "option", "active" ), 1 );
state( element, 0, 1, 0 );
assert.equal( element.accordion( "option", "active" ), 1 );
state( assert, element, 0, 1, 0 );
element.accordion( "option", "active", -3 );
equal( element.accordion( "option", "active" ), 0 );
state( element, 1, 0, 0 );
assert.equal( element.accordion( "option", "active" ), 0 );
state( assert, element, 1, 0, 0 );
} );
test( "{ animate: false }", function() {
expect( 3 );
QUnit.test( "{ animate: false }", function( assert ) {
assert.expect( 3 );
var element = $( "#list1" ).accordion( {
animate: false
} ),
panels = element.find( ".ui-accordion-content" ),
animate = $.fn.animate;
$.fn.animate = function() {
ok( false, ".animate() called" );
assert.ok( false, ".animate() called" );
};
ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
element.accordion( "option", "active", 1 );
ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
assert.ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
assert.ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
$.fn.animate = animate;
} );
asyncTest( "{ animate: Number }", function() {
expect( 7 );
QUnit.test( "{ animate: Number }", function( assert ) {
var ready = assert.async();
assert.expect( 7 );
var element = $( "#list1" ).accordion( {
animate: 100
} ),
@ -134,23 +136,24 @@ asyncTest( "{ animate: Number }", function() {
// Called twice (both panels)
$.fn.animate = function( props, options ) {
equal( options.duration, 100, "correct duration" );
equal( options.easing, undefined, "default easing" );
assert.equal( options.duration, 100, "correct duration" );
assert.equal( options.easing, undefined, "default easing" );
animate.apply( this, arguments );
};
ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
element.accordion( "option", "active", 1 );
panels.promise().done( function() {
ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
assert.ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
assert.ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
$.fn.animate = animate;
start();
ready();
} );
} );
asyncTest( "{ animate: String }", function() {
expect( 7 );
QUnit.test( "{ animate: String }", function( assert ) {
var ready = assert.async();
assert.expect( 7 );
var element = $( "#list1" ).accordion( {
animate: "linear"
} ),
@ -159,23 +162,24 @@ asyncTest( "{ animate: String }", function() {
// Called twice (both panels)
$.fn.animate = function( props, options ) {
equal( options.duration, undefined, "default duration" );
equal( options.easing, "linear", "correct easing" );
assert.equal( options.duration, undefined, "default duration" );
assert.equal( options.easing, "linear", "correct easing" );
animate.apply( this, arguments );
};
ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
element.accordion( "option", "active", 1 );
panels.promise().done( function() {
ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
assert.ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
assert.ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
$.fn.animate = animate;
start();
ready();
} );
} );
asyncTest( "{ animate: {} }", function() {
expect( 7 );
QUnit.test( "{ animate: {} }", function( assert ) {
var ready = assert.async();
assert.expect( 7 );
var element = $( "#list1" ).accordion( {
animate: {}
} ),
@ -184,23 +188,24 @@ asyncTest( "{ animate: {} }", function() {
// Called twice (both panels)
$.fn.animate = function( props, options ) {
equal( options.duration, undefined, "default duration" );
equal( options.easing, undefined, "default easing" );
assert.equal( options.duration, undefined, "default duration" );
assert.equal( options.easing, undefined, "default easing" );
animate.apply( this, arguments );
};
ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
element.accordion( "option", "active", 1 );
panels.promise().done( function() {
ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
assert.ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
assert.ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
$.fn.animate = animate;
start();
ready();
} );
} );
asyncTest( "{ animate: { duration, easing } }", function() {
expect( 7 );
QUnit.test( "{ animate: { duration, easing } }", function( assert ) {
var ready = assert.async();
assert.expect( 7 );
var element = $( "#list1" ).accordion( {
animate: { duration: 100, easing: "linear" }
} ),
@ -209,23 +214,24 @@ asyncTest( "{ animate: { duration, easing } }", function() {
// Called twice (both panels)
$.fn.animate = function( props, options ) {
equal( options.duration, 100, "correct duration" );
equal( options.easing, "linear", "correct easing" );
assert.equal( options.duration, 100, "correct duration" );
assert.equal( options.easing, "linear", "correct easing" );
animate.apply( this, arguments );
};
ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
assert.ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
element.accordion( "option", "active", 1 );
panels.promise().done( function() {
ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
assert.ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
assert.ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
$.fn.animate = animate;
start();
ready();
} );
} );
asyncTest( "{ animate: { duration, easing } }, animate down", function() {
expect( 7 );
QUnit.test( "{ animate: { duration, easing } }, animate down", function( assert ) {
var ready = assert.async();
assert.expect( 7 );
var element = $( "#list1" ).accordion( {
active: 1,
animate: { duration: 100, easing: "linear" }
@ -235,23 +241,24 @@ asyncTest( "{ animate: { duration, easing } }, animate down", function() {
// Called twice (both panels)
$.fn.animate = function( props, options ) {
equal( options.duration, 100, "correct duration" );
equal( options.easing, "linear", "correct easing" );
assert.equal( options.duration, 100, "correct duration" );
assert.equal( options.easing, "linear", "correct easing" );
animate.apply( this, arguments );
};
ok( panels.eq( 1 ).is( ":visible" ), "first panel visible" );
assert.ok( panels.eq( 1 ).is( ":visible" ), "first panel visible" );
element.accordion( "option", "active", 0 );
panels.promise().done( function() {
ok( panels.eq( 1 ).is( ":hidden" ), "first panel hidden" );
ok( panels.eq( 0 ).is( ":visible" ), "second panel visible" );
assert.ok( panels.eq( 1 ).is( ":hidden" ), "first panel hidden" );
assert.ok( panels.eq( 0 ).is( ":visible" ), "second panel visible" );
$.fn.animate = animate;
start();
ready();
} );
} );
asyncTest( "{ animate: { duration, easing, down } }, animate down", function() {
expect( 7 );
QUnit.test( "{ animate: { duration, easing, down } }, animate down", function( assert ) {
var ready = assert.async();
assert.expect( 7 );
var element = $( "#list1" ).accordion( {
active: 1,
animate: {
@ -267,156 +274,156 @@ asyncTest( "{ animate: { duration, easing, down } }, animate down", function() {
// Called twice (both panels)
$.fn.animate = function( props, options ) {
equal( options.duration, 100, "correct duration" );
equal( options.easing, "swing", "correct easing" );
assert.equal( options.duration, 100, "correct duration" );
assert.equal( options.easing, "swing", "correct easing" );
animate.apply( this, arguments );
};
ok( panels.eq( 1 ).is( ":visible" ), "first panel visible" );
assert.ok( panels.eq( 1 ).is( ":visible" ), "first panel visible" );
element.accordion( "option", "active", 0 );
panels.promise().done( function() {
ok( panels.eq( 1 ).is( ":hidden" ), "first panel hidden" );
ok( panels.eq( 0 ).is( ":visible" ), "second panel visible" );
assert.ok( panels.eq( 1 ).is( ":hidden" ), "first panel hidden" );
assert.ok( panels.eq( 0 ).is( ":visible" ), "second panel visible" );
$.fn.animate = animate;
start();
ready();
} );
} );
test( "{ collapsible: false }", function() {
expect( 4 );
QUnit.test( "{ collapsible: false }", function( assert ) {
assert.expect( 4 );
var element = $( "#list1" ).accordion( {
active: 1
} );
element.accordion( "option", "active", false );
equal( element.accordion( "option", "active" ), 1 );
state( element, 0, 1, 0 );
assert.equal( element.accordion( "option", "active" ), 1 );
state( assert, element, 0, 1, 0 );
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" );
equal( element.accordion( "option", "active" ), 1 );
state( element, 0, 1, 0 );
assert.equal( element.accordion( "option", "active" ), 1 );
state( assert, element, 0, 1, 0 );
} );
test( "{ collapsible: true }", function() {
expect( 6 );
QUnit.test( "{ collapsible: true }", function( assert ) {
assert.expect( 6 );
var element = $( "#list1" ).accordion( {
active: 1,
collapsible: true
} );
element.accordion( "option", "active", false );
equal( element.accordion( "option", "active" ), false );
state( element, 0, 0, 0 );
assert.equal( element.accordion( "option", "active" ), false );
state( assert, element, 0, 0, 0 );
element.accordion( "option", "active", 1 );
equal( element.accordion( "option", "active" ), 1 );
state( element, 0, 1, 0 );
assert.equal( element.accordion( "option", "active" ), 1 );
state( assert, element, 0, 1, 0 );
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" );
equal( element.accordion( "option", "active" ), false );
state( element, 0, 0, 0 );
assert.equal( element.accordion( "option", "active" ), false );
state( assert, element, 0, 0, 0 );
} );
test( "{ event: null }", function() {
expect( 5 );
QUnit.test( "{ event: null }", function( assert ) {
assert.expect( 5 );
var element = $( "#list1" ).accordion( {
event: null
} );
state( element, 1, 0, 0 );
state( assert, element, 1, 0, 0 );
element.accordion( "option", "active", 1 );
equal( element.accordion( "option", "active" ), 1 );
state( element, 0, 1, 0 );
assert.equal( element.accordion( "option", "active" ), 1 );
state( assert, element, 0, 1, 0 );
// Ensure default click handler isn't bound
element.find( ".ui-accordion-header" ).eq( 2 ).trigger( "click" );
equal( element.accordion( "option", "active" ), 1 );
state( element, 0, 1, 0 );
assert.equal( element.accordion( "option", "active" ), 1 );
state( assert, element, 0, 1, 0 );
} );
test( "{ event: custom }", function() {
expect( 11 );
QUnit.test( "{ event: custom }", function( assert ) {
assert.expect( 11 );
var element = $( "#list1" ).accordion( {
event: "custom1 custom2"
} );
state( element, 1, 0, 0 );
state( assert, element, 1, 0, 0 );
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom1" );
equal( element.accordion( "option", "active" ), 1 );
state( element, 0, 1, 0 );
assert.equal( element.accordion( "option", "active" ), 1 );
state( assert, element, 0, 1, 0 );
// Ensure default click handler isn't bound
element.find( ".ui-accordion-header" ).eq( 2 ).trigger( "click" );
equal( element.accordion( "option", "active" ), 1 );
state( element, 0, 1, 0 );
assert.equal( element.accordion( "option", "active" ), 1 );
state( assert, element, 0, 1, 0 );
element.find( ".ui-accordion-header" ).eq( 2 ).trigger( "custom2" );
equal( element.accordion( "option", "active" ), 2 );
state( element, 0, 0, 1 );
assert.equal( element.accordion( "option", "active" ), 2 );
state( assert, element, 0, 0, 1 );
element.accordion( "option", "event", "custom3" );
// Ensure old event handlers are unbound
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom1" );
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom2" );
equal( element.accordion( "option", "active" ), 2 );
state( element, 0, 0, 1 );
assert.equal( element.accordion( "option", "active" ), 2 );
state( assert, element, 0, 0, 1 );
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom3" );
equal( element.accordion( "option", "active" ), 1 );
state( element, 0, 1, 0 );
assert.equal( element.accordion( "option", "active" ), 1 );
state( assert, element, 0, 1, 0 );
} );
test( "{ header: default }", function() {
expect( 2 );
QUnit.test( "{ header: default }", function( assert ) {
assert.expect( 2 );
// Default: > li > :first-child,> :not(li):even
// > :not(li):even
state( $( "#list1" ).accordion(), 1, 0, 0 );
state( assert, $( "#list1" ).accordion(), 1, 0, 0 );
// > li > :first-child
state( $( "#navigation" ).accordion(), 1, 0, 0 );
state( assert, $( "#navigation" ).accordion(), 1, 0, 0 );
} );
test( "{ header: custom }", function( assert ) {
expect( 6 );
QUnit.test( "{ header: custom }", function( assert ) {
assert.expect( 6 );
var element = $( "#navigationWrapper" ).accordion( {
header: "h2"
} );
element.find( "h2" ).each( function() {
assert.hasClasses( this, "ui-accordion-header" );
} );
equal( element.find( ".ui-accordion-header" ).length, 3 );
state( element, 1, 0, 0 );
assert.equal( element.find( ".ui-accordion-header" ).length, 3 );
state( assert, element, 1, 0, 0 );
element.accordion( "option", "active", 2 );
state( element, 0, 0, 1 );
state( assert, element, 0, 0, 1 );
} );
test( "{ heightStyle: 'auto' }", function() {
expect( 3 );
QUnit.test( "{ heightStyle: 'auto' }", function( assert ) {
assert.expect( 3 );
var element = $( "#navigation" ).accordion( { heightStyle: "auto" } );
equalHeight( element, 105 );
equalHeight( assert, element, 105 );
} );
test( "{ heightStyle: 'content' }", function() {
expect( 3 );
QUnit.test( "{ heightStyle: 'content' }", function( assert ) {
assert.expect( 3 );
var element = $( "#navigation" ).accordion( { heightStyle: "content" } ),
sizes = element.find( ".ui-accordion-content" ).map( function() {
return $( this ).height();
} ).get();
equal( sizes[ 0 ], 75 );
equal( sizes[ 1 ], 105 );
equal( sizes[ 2 ], 45 );
assert.equal( sizes[ 0 ], 75 );
assert.equal( sizes[ 1 ], 105 );
assert.equal( sizes[ 2 ], 45 );
} );
test( "{ heightStyle: 'fill' }", function() {
expect( 3 );
QUnit.test( "{ heightStyle: 'fill' }", function( assert ) {
assert.expect( 3 );
$( "#navigationWrapper" ).height( 500 );
var element = $( "#navigation" ).accordion( { heightStyle: "fill" } );
equalHeight( element, 455 );
equalHeight( assert, element, 455 );
} );
test( "{ heightStyle: 'fill' } with sibling", function() {
expect( 3 );
QUnit.test( "{ heightStyle: 'fill' } with sibling", function( assert ) {
assert.expect( 3 );
$( "#navigationWrapper" ).height( 500 );
$( "<p>Lorem Ipsum</p>" )
.css( {
@ -426,11 +433,11 @@ test( "{ heightStyle: 'fill' } with sibling", function() {
} )
.prependTo( "#navigationWrapper" );
var element = $( "#navigation" ).accordion( { heightStyle: "fill" } );
equalHeight( element, 355 );
equalHeight( assert, element, 355 );
} );
test( "{ heightStyle: 'fill' } with multiple siblings", function() {
expect( 3 );
QUnit.test( "{ heightStyle: 'fill' } with multiple siblings", function( assert ) {
assert.expect( 3 );
$( "#navigationWrapper" ).height( 500 );
$( "<p>Lorem Ipsum</p>" )
.css( {
@ -455,15 +462,15 @@ test( "{ heightStyle: 'fill' } with multiple siblings", function() {
} )
.prependTo( "#navigationWrapper" );
var element = $( "#navigation" ).accordion( { heightStyle: "fill" } );
equalHeight( element, 305 );
equalHeight( assert, element, 305 );
} );
test( "{ icons: false }", function() {
expect( 8 );
QUnit.test( "{ icons: false }", function( assert ) {
assert.expect( 8 );
var element = $( "#list1" );
function icons( on ) {
deepEqual( element.find( "span.ui-icon" ).length, on ? 3 : 0 );
deepEqual( element.find( ".ui-accordion-header.ui-accordion-icons" ).length, on ? 3 : 0 );
assert.deepEqual( element.find( "span.ui-icon" ).length, on ? 3 : 0 );
assert.deepEqual( element.find( ".ui-accordion-header.ui-accordion-icons" ).length, on ? 3 : 0 );
}
element.accordion();
icons( true );
@ -477,8 +484,8 @@ test( "{ icons: false }", function() {
icons( false );
} );
test( "{ icons: hash }", function( assert ) {
expect( 3 );
QUnit.test( "{ icons: hash }", function( assert ) {
assert.expect( 3 );
var element = $( "#list1" ).accordion( {
icons: { activeHeader: "a1", header: "h1" }
} );

View File

@ -19,6 +19,8 @@
"accordion/accordion.html",
"autocomplete/autocomplete.html",
"button/button.html",
"checkboxradio/checkboxradio.html",
"controlgroup/controlgroup.html",
"core/core.html",
"calendar/calendar.html",
"datepicker/datepicker.html",
@ -32,6 +34,7 @@
"progressbar/progressbar.html",
"resizable/resizable.html",
"selectable/selectable.html",
"selectmenu/selectmenu.html",
"slider/slider.html",
"sortable/sortable.html",
"spinner/spinner.html",

View File

@ -1,12 +1,13 @@
define( [
"qunit",
"jquery",
"ui/widgets/autocomplete"
], function( $ ) {
], function( QUnit, $ ) {
module( "autocomplete: core" );
QUnit.module( "autocomplete: core" );
test( "markup structure", function( assert ) {
expect( 2 );
QUnit.test( "markup structure", function( assert ) {
assert.expect( 2 );
var element = $( "#autocomplete" ).autocomplete(),
menu = element.autocomplete( "widget" );
@ -14,8 +15,8 @@ test( "markup structure", function( assert ) {
assert.hasClasses( menu, "ui-autocomplete ui-widget ui-widget-content" );
} );
test( "prevent form submit on enter when menu is active", function() {
expect( 2 );
QUnit.test( "prevent form submit on enter when menu is active", function( assert ) {
assert.expect( 2 );
var event,
element = $( "#autocomplete" )
.autocomplete( {
@ -28,17 +29,17 @@ test( "prevent form submit on enter when menu is active", function() {
event = $.Event( "keydown" );
event.keyCode = $.ui.keyCode.DOWN;
element.trigger( event );
equal( menu.find( ".ui-menu-item-wrapper.ui-state-active" ).length, 1,
assert.equal( menu.find( ".ui-menu-item-wrapper.ui-state-active" ).length, 1,
"menu item is active" );
event = $.Event( "keydown" );
event.keyCode = $.ui.keyCode.ENTER;
element.trigger( event );
ok( event.isDefaultPrevented(), "default action is prevented" );
assert.ok( event.isDefaultPrevented(), "default action is prevented" );
} );
test( "allow form submit on enter when menu is not active", function() {
expect( 1 );
QUnit.test( "allow form submit on enter when menu is not active", function( assert ) {
assert.expect( 1 );
var event,
element = $( "#autocomplete" )
.autocomplete( {
@ -51,84 +52,84 @@ test( "allow form submit on enter when menu is not active", function() {
event = $.Event( "keydown" );
event.keyCode = $.ui.keyCode.ENTER;
element.trigger( event );
ok( !event.isDefaultPrevented(), "default action is prevented" );
assert.ok( !event.isDefaultPrevented(), "default action is prevented" );
} );
( function() {
test( "up arrow invokes search - input", function() {
arrowsInvokeSearch( "#autocomplete", true, true );
QUnit.test( "up arrow invokes search - input", function( assert ) {
arrowsInvokeSearch( assert, "#autocomplete", true, true );
} );
test( "down arrow invokes search - input", function() {
arrowsInvokeSearch( "#autocomplete", false, true );
QUnit.test( "down arrow invokes search - input", function( assert ) {
arrowsInvokeSearch( assert, "#autocomplete", false, true );
} );
test( "up arrow invokes search - textarea", function() {
arrowsInvokeSearch( "#autocomplete-textarea", true, false );
QUnit.test( "up arrow invokes search - textarea", function( assert ) {
arrowsInvokeSearch( assert, "#autocomplete-textarea", true, false );
} );
test( "down arrow invokes search - textarea", function() {
arrowsInvokeSearch( "#autocomplete-textarea", false, false );
QUnit.test( "down arrow invokes search - textarea", function( assert ) {
arrowsInvokeSearch( assert, "#autocomplete-textarea", false, false );
} );
test( "up arrow invokes search - contenteditable", function() {
arrowsInvokeSearch( "#autocomplete-contenteditable", true, false );
QUnit.test( "up arrow invokes search - contenteditable", function( assert ) {
arrowsInvokeSearch( assert, "#autocomplete-contenteditable", true, false );
} );
test( "down arrow invokes search - contenteditable", function() {
arrowsInvokeSearch( "#autocomplete-contenteditable", false, false );
QUnit.test( "down arrow invokes search - contenteditable", function( assert ) {
arrowsInvokeSearch( assert, "#autocomplete-contenteditable", false, false );
} );
test( "up arrow moves focus - input", function() {
arrowsMoveFocus( "#autocomplete", true );
QUnit.test( "up arrow moves focus - input", function( assert ) {
arrowsMoveFocus( assert, "#autocomplete", true );
} );
test( "down arrow moves focus - input", function() {
arrowsMoveFocus( "#autocomplete", false );
QUnit.test( "down arrow moves focus - input", function( assert ) {
arrowsMoveFocus( assert, "#autocomplete", false );
} );
test( "up arrow moves focus - textarea", function() {
arrowsMoveFocus( "#autocomplete-textarea", true );
QUnit.test( "up arrow moves focus - textarea", function( assert ) {
arrowsMoveFocus( assert, "#autocomplete-textarea", true );
} );
test( "down arrow moves focus - textarea", function() {
arrowsMoveFocus( "#autocomplete-textarea", false );
QUnit.test( "down arrow moves focus - textarea", function( assert ) {
arrowsMoveFocus( assert, "#autocomplete-textarea", false );
} );
test( "up arrow moves focus - contenteditable", function() {
arrowsMoveFocus( "#autocomplete-contenteditable", true );
QUnit.test( "up arrow moves focus - contenteditable", function( assert ) {
arrowsMoveFocus( assert, "#autocomplete-contenteditable", true );
} );
test( "down arrow moves focus - contenteditable", function() {
arrowsMoveFocus( "#autocomplete-contenteditable", false );
QUnit.test( "down arrow moves focus - contenteditable", function( assert ) {
arrowsMoveFocus( assert, "#autocomplete-contenteditable", false );
} );
test( "up arrow moves cursor - input", function() {
arrowsNavigateElement( "#autocomplete", true, false );
QUnit.test( "up arrow moves cursor - input", function( assert ) {
arrowsNavigateElement( assert, "#autocomplete", true, false );
} );
test( "down arrow moves cursor - input", function() {
arrowsNavigateElement( "#autocomplete", false, false );
QUnit.test( "down arrow moves cursor - input", function( assert ) {
arrowsNavigateElement( assert, "#autocomplete", false, false );
} );
test( "up arrow moves cursor - textarea", function() {
arrowsNavigateElement( "#autocomplete-textarea", true, true );
QUnit.test( "up arrow moves cursor - textarea", function( assert ) {
arrowsNavigateElement( assert, "#autocomplete-textarea", true, true );
} );
test( "down arrow moves cursor - textarea", function() {
arrowsNavigateElement( "#autocomplete-textarea", false, true );
QUnit.test( "down arrow moves cursor - textarea", function( assert ) {
arrowsNavigateElement( assert, "#autocomplete-textarea", false, true );
} );
test( "up arrow moves cursor - contenteditable", function() {
arrowsNavigateElement( "#autocomplete-contenteditable", true, true );
QUnit.test( "up arrow moves cursor - contenteditable", function( assert ) {
arrowsNavigateElement( assert, "#autocomplete-contenteditable", true, true );
} );
test( "down arrow moves cursor - contenteditable", function() {
arrowsNavigateElement( "#autocomplete-contenteditable", false, true );
QUnit.test( "down arrow moves cursor - contenteditable", function( assert ) {
arrowsNavigateElement( assert, "#autocomplete-contenteditable", false, true );
} );
function arrowsInvokeSearch( id, isKeyUp, shouldMove ) {
expect( 1 );
function arrowsInvokeSearch( assert, id, isKeyUp, shouldMove ) {
assert.expect( 1 );
var didMove = false,
element = $( id ).autocomplete( {
@ -140,11 +141,11 @@ test( "allow form submit on enter when menu is not active", function() {
didMove = true;
};
element.simulate( "keydown", { keyCode: ( isKeyUp ? $.ui.keyCode.UP : $.ui.keyCode.DOWN ) } );
equal( didMove, shouldMove, "respond to arrow" );
assert.equal( didMove, shouldMove, "respond to arrow" );
}
function arrowsMoveFocus( id, isKeyUp ) {
expect( 1 );
function arrowsMoveFocus( assert, id, isKeyUp ) {
assert.expect( 1 );
var element = $( id ).autocomplete( {
source: [ "a" ],
@ -152,14 +153,14 @@ test( "allow form submit on enter when menu is not active", function() {
minLength: 0
} );
element.autocomplete( "instance" )._move = function() {
ok( true, "repsond to arrow" );
assert.ok( true, "repsond to arrow" );
};
element.autocomplete( "search" );
element.simulate( "keydown", { keyCode: ( isKeyUp ? $.ui.keyCode.UP : $.ui.keyCode.DOWN ) } );
}
function arrowsNavigateElement( id, isKeyUp, shouldMove ) {
expect( 1 );
function arrowsNavigateElement( assert, id, isKeyUp, shouldMove ) {
assert.expect( 1 );
var didMove = false,
element = $( id ).autocomplete( {
@ -172,19 +173,20 @@ test( "allow form submit on enter when menu is not active", function() {
} );
element.simulate( "keydown", { keyCode: ( isKeyUp ? $.ui.keyCode.UP : $.ui.keyCode.DOWN ) } );
element.simulate( "keypress" );
equal( didMove, shouldMove, "respond to arrow" );
assert.equal( didMove, shouldMove, "respond to arrow" );
}
} )();
asyncTest( "past end of menu in multiline autocomplete", function() {
expect( 2 );
QUnit.test( "past end of menu in multiline autocomplete", function( assert ) {
var ready = assert.async();
assert.expect( 2 );
var customVal = "custom value",
element = $( "#autocomplete-contenteditable" ).autocomplete( {
delay: 0,
source: [ "javascript" ],
focus: function( event, ui ) {
equal( ui.item.value, "javascript", "Item gained focus" );
assert.equal( ui.item.value, "javascript", "Item gained focus" );
$( this ).text( customVal );
event.preventDefault();
}
@ -197,20 +199,21 @@ asyncTest( "past end of menu in multiline autocomplete", function() {
setTimeout( function() {
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
equal( element.text(), customVal );
start();
assert.equal( element.text(), customVal );
ready();
} );
} );
asyncTest( "ESCAPE in multiline autocomplete", function() {
expect( 2 );
QUnit.test( "ESCAPE in multiline autocomplete", function( assert ) {
var ready = assert.async();
assert.expect( 2 );
var customVal = "custom value",
element = $( "#autocomplete-contenteditable" ).autocomplete( {
delay: 0,
source: [ "javascript" ],
focus: function( event, ui ) {
equal( ui.item.value, "javascript", "Item gained focus" );
assert.equal( ui.item.value, "javascript", "Item gained focus" );
$( this ).text( customVal );
event.preventDefault();
}
@ -223,26 +226,27 @@ asyncTest( "ESCAPE in multiline autocomplete", function() {
setTimeout( function() {
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
equal( element.text(), customVal );
start();
assert.equal( element.text(), customVal );
ready();
} );
} );
asyncTest( "handle race condition", function() {
expect( 3 );
QUnit.test( "handle race condition", function( assert ) {
var ready = assert.async();
assert.expect( 3 );
var count = 0,
element = $( "#autocomplete" ).autocomplete( {
source: function( request, response ) {
count++;
if ( request.term.length === 1 ) {
equal( count, 1, "request with 1 character is first" );
assert.equal( count, 1, "request with 1 character is first" );
setTimeout( function() {
response( [ "one" ] );
setTimeout( checkResults );
} );
return;
}
equal( count, 2, "request with 2 characters is second" );
assert.equal( count, 2, "request with 2 characters is second" );
response( [ "two" ] );
}
} );
@ -251,14 +255,15 @@ asyncTest( "handle race condition", function() {
element.autocomplete( "search", "ab" );
function checkResults() {
equal( element.autocomplete( "widget" ).find( ".ui-menu-item" ).text(), "two",
assert.equal( element.autocomplete( "widget" ).find( ".ui-menu-item" ).text(), "two",
"correct results displayed" );
start();
ready();
}
} );
asyncTest( "simultaneous searches (#9334)", function() {
expect( 2 );
QUnit.test( "simultaneous searches (#9334)", function( assert ) {
var ready = assert.async();
assert.expect( 2 );
var element = $( "#autocomplete" ).autocomplete( {
source: function( request, response ) {
setTimeout( function() {
@ -266,7 +271,7 @@ asyncTest( "simultaneous searches (#9334)", function() {
} );
},
response: function() {
ok( true, "response from first instance" );
assert.ok( true, "response from first instance" );
}
} ),
element2 = $( "#autocomplete-textarea" ).autocomplete( {
@ -276,8 +281,8 @@ asyncTest( "simultaneous searches (#9334)", function() {
} );
},
response: function() {
ok( true, "response from second instance" );
start();
assert.ok( true, "response from second instance" );
ready();
}
} );
@ -285,60 +290,60 @@ asyncTest( "simultaneous searches (#9334)", function() {
element2.autocomplete( "search", "test" );
} );
test( "ARIA", function() {
expect( 13 );
QUnit.test( "ARIA", function( assert ) {
assert.expect( 13 );
var element = $( "#autocomplete" ).autocomplete( {
source: [ "java", "javascript" ]
} ),
liveRegion = element.autocomplete( "instance" ).liveRegion;
equal( liveRegion.children().length, 0, "Empty live region on create" );
equal( liveRegion.attr( "aria-live" ), "assertive",
assert.equal( liveRegion.children().length, 0, "Empty live region on create" );
assert.equal( liveRegion.attr( "aria-live" ), "assertive",
"Live region's aria-live attribute must be assertive" );
equal( liveRegion.attr( "aria-relevant" ), "additions",
assert.equal( liveRegion.attr( "aria-relevant" ), "additions",
"Live region's aria-relevant attribute must be additions" );
equal( liveRegion.attr( "role" ), "status",
assert.equal( liveRegion.attr( "role" ), "status",
"Live region's role attribute must be status" );
element.autocomplete( "search", "j" );
equal( liveRegion.children().first().text(),
assert.equal( liveRegion.children().first().text(),
"2 results are available, use up and down arrow keys to navigate.",
"Live region for multiple values" );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
equal( liveRegion.children().filter( ":visible" ).text(), "java",
assert.equal( liveRegion.children().filter( ":visible" ).text(), "java",
"Live region changed on keydown to announce the highlighted value" );
element.one( "autocompletefocus", function( event ) {
event.preventDefault();
} );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
equal( liveRegion.children().filter( ":visible" ).text(), "javascript",
assert.equal( liveRegion.children().filter( ":visible" ).text(), "javascript",
"Live region updated when default focus is prevented" );
element.autocomplete( "search", "javas" );
equal( liveRegion.children().filter( ":visible" ).text(),
assert.equal( liveRegion.children().filter( ":visible" ).text(),
"1 result is available, use up and down arrow keys to navigate.",
"Live region for one value" );
element.autocomplete( "search", "z" );
equal( liveRegion.children().filter( ":visible" ).text(), "No search results.",
assert.equal( liveRegion.children().filter( ":visible" ).text(), "No search results.",
"Live region for no values" );
equal( liveRegion.children().length, 5,
assert.equal( liveRegion.children().length, 5,
"Should be five children in the live region after the above" );
equal( liveRegion.children().filter( ":visible" ).length, 1,
assert.equal( liveRegion.children().filter( ":visible" ).length, 1,
"Only one should be still visible" );
ok( liveRegion.children().filter( ":visible" )[ 0 ] === liveRegion.children().last()[ 0 ],
assert.ok( liveRegion.children().filter( ":visible" )[ 0 ] === liveRegion.children().last()[ 0 ],
"The last one should be the visible one" );
element.autocomplete( "destroy" );
equal( liveRegion.parent().length, 0,
assert.equal( liveRegion.parent().length, 0,
"The liveRegion should be detached after destroy" );
} );
test( "ARIA, aria-label announcement", function() {
expect( 1 );
QUnit.test( "ARIA, aria-label announcement", function( assert ) {
assert.expect( 1 );
$.widget( "custom.catcomplete", $.ui.autocomplete, {
_renderMenu: function( ul, items ) {
var that = this;
@ -354,31 +359,32 @@ test( "ARIA, aria-label announcement", function() {
liveRegion = element.catcomplete( "instance" ).liveRegion;
element.catcomplete( "search", "a" );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
equal( liveRegion.children().filter( ":visible" ).text(), "People : anders andersson",
assert.equal( liveRegion.children().filter( ":visible" ).text(), "People : anders andersson",
"Live region changed on keydown to announce the highlighted value's aria-label attribute" );
} );
test( "ARIA, init on detached input", function() {
expect( 1 );
QUnit.test( "ARIA, init on detached input", function( assert ) {
assert.expect( 1 );
var element = $( "<input>" ).autocomplete( {
source: [ "java", "javascript" ]
} ),
liveRegion = element.autocomplete( "instance" ).liveRegion;
equal( liveRegion.parent().length, 1, "liveRegion must have a parent" );
assert.equal( liveRegion.parent().length, 1, "liveRegion must have a parent" );
} );
test( ".replaceWith() (#9172)", function() {
expect( 1 );
QUnit.test( ".replaceWith() (#9172)", function( assert ) {
assert.expect( 1 );
var element = $( "#autocomplete" ).autocomplete(),
replacement = "<div>test</div>",
parent = element.parent();
element.replaceWith( replacement );
equal( parent.html().toLowerCase(), replacement );
assert.equal( parent.html().toLowerCase(), replacement );
} );
asyncTest( "Search if the user retypes the same value (#7434)", function() {
expect( 3 );
QUnit.test( "Search if the user retypes the same value (#7434)", function( assert ) {
var ready = assert.async();
assert.expect( 3 );
var element = $( "#autocomplete" ).autocomplete( {
source: [ "java", "javascript" ],
delay: 0
@ -387,19 +393,20 @@ asyncTest( "Search if the user retypes the same value (#7434)", function() {
element.val( "j" ).simulate( "keydown" );
setTimeout( function() {
ok( menu.is( ":visible" ), "menu displays initially" );
assert.ok( menu.is( ":visible" ), "menu displays initially" );
element.trigger( "blur" );
ok( !menu.is( ":visible" ), "menu hidden after blur" );
assert.ok( !menu.is( ":visible" ), "menu hidden after blur" );
element.val( "j" ).simulate( "keydown" );
setTimeout( function() {
ok( menu.is( ":visible" ), "menu displays after typing the same value" );
start();
assert.ok( menu.is( ":visible" ), "menu displays after typing the same value" );
ready();
} );
} );
} );
asyncTest( "Close on click outside when focus remains", function() {
expect( 2 );
QUnit.test( "Close on click outside when focus remains", function( assert ) {
var ready = assert.async();
assert.expect( 2 );
var element = $( "#autocomplete" ).autocomplete( {
source: [ "java", "javascript" ],
@ -413,11 +420,11 @@ asyncTest( "Close on click outside when focus remains", function() {
element.val( "j" ).autocomplete( "search", "j" );
setTimeout( function() {
ok( menu.is( ":visible" ), "menu displays initially" );
assert.ok( menu.is( ":visible" ), "menu displays initially" );
$( "body" ).simulate( "mousedown" );
setTimeout( function() {
ok( menu.is( ":hidden" ), "menu closes after clicking elsewhere" );
start();
assert.ok( menu.is( ":hidden" ), "menu closes after clicking elsewhere" );
ready();
} );
} );
} );

View File

@ -1,9 +1,10 @@
define( [
"qunit",
"jquery",
"ui/widgets/autocomplete"
], function( $ ) {
], function( QUnit, $ ) {
module( "autocomplete: events" );
QUnit.module( "autocomplete: events" );
var data = [ "Clojure", "COBOL", "ColdFusion", "Java", "JavaScript", "Scala", "Scheme" ];
@ -24,18 +25,19 @@ $.each( [
valueMethod: "text"
}
], function( i, settings ) {
asyncTest( "all events - " + settings.type, function() {
expect( 13 );
QUnit.test( "all events - " + settings.type, function( assert ) {
var ready = assert.async();
assert.expect( 13 );
var element = $( settings.selector )
.autocomplete( {
autoFocus: false,
delay: 0,
source: data,
search: function( event ) {
equal( event.originalEvent.type, "keydown", "search originalEvent" );
assert.equal( event.originalEvent.type, "keydown", "search originalEvent" );
},
response: function( event, ui ) {
deepEqual( ui.content, [
assert.deepEqual( ui.content, [
{ label: "Clojure", value: "Clojure" },
{ label: "Java", value: "Java" },
{ label: "JavaScript", value: "JavaScript" }
@ -43,32 +45,32 @@ $.each( [
ui.content.splice( 0, 1 );
},
open: function() {
ok( menu.is( ":visible" ), "menu open on open" );
assert.ok( menu.is( ":visible" ), "menu open on open" );
},
focus: function( event, ui ) {
equal( event.originalEvent.type, "menufocus", "focus originalEvent" );
deepEqual( ui.item, { label: "Java", value: "Java" }, "focus ui.item" );
assert.equal( event.originalEvent.type, "menufocus", "focus originalEvent" );
assert.deepEqual( ui.item, { label: "Java", value: "Java" }, "focus ui.item" );
},
close: function( event ) {
equal( event.originalEvent.type, "menuselect", "close originalEvent" );
ok( menu.is( ":hidden" ), "menu closed on close" );
assert.equal( event.originalEvent.type, "menuselect", "close originalEvent" );
assert.ok( menu.is( ":hidden" ), "menu closed on close" );
},
select: function( event, ui ) {
equal( event.originalEvent.type, "menuselect", "select originalEvent" );
deepEqual( ui.item, { label: "Java", value: "Java" }, "select ui.item" );
assert.equal( event.originalEvent.type, "menuselect", "select originalEvent" );
assert.deepEqual( ui.item, { label: "Java", value: "Java" }, "select ui.item" );
},
change: function( event, ui ) {
equal( event.originalEvent.type, "blur", "change originalEvent" );
deepEqual( ui.item, { label: "Java", value: "Java" }, "change ui.item" );
ok( menu.is( ":hidden" ), "menu closed on change" );
start();
assert.equal( event.originalEvent.type, "blur", "change originalEvent" );
assert.deepEqual( ui.item, { label: "Java", value: "Java" }, "change ui.item" );
assert.ok( menu.is( ":hidden" ), "menu closed on change" );
ready();
}
} ),
menu = element.autocomplete( "widget" );
element.simulate( "focus" )[ settings.valueMethod ]( "j" ).trigger( "keydown" );
setTimeout( function() {
ok( menu.is( ":visible" ), "menu is visible after delay" );
assert.ok( menu.is( ":visible" ), "menu is visible after delay" );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
@ -80,53 +82,56 @@ $.each( [
} );
} );
asyncTest( "change without selection", function() {
expect( 1 );
QUnit.test( "change without selection", function( assert ) {
var ready = assert.async();
assert.expect( 1 );
var element = $( "#autocomplete" ).autocomplete( {
delay: 0,
source: data,
change: function( event, ui ) {
strictEqual( ui.item, null );
start();
assert.strictEqual( ui.item, null );
ready();
}
} );
element.triggerHandler( "focus" );
element.val( "ja" ).triggerHandler( "blur" );
} );
asyncTest( "cancel search", function() {
expect( 6 );
QUnit.test( "cancel search", function( assert ) {
var ready = assert.async();
assert.expect( 6 );
var first = true,
element = $( "#autocomplete" ).autocomplete( {
delay: 0,
source: data,
search: function() {
if ( first ) {
equal( element.val(), "ja", "val on first search" );
assert.equal( element.val(), "ja", "val on first search" );
first = false;
return false;
}
equal( element.val(), "java", "val on second search" );
assert.equal( element.val(), "java", "val on second search" );
},
open: function() {
ok( true, "menu opened" );
assert.ok( true, "menu opened" );
}
} ),
menu = element.autocomplete( "widget" );
element.val( "ja" ).trigger( "keydown" );
setTimeout( function() {
ok( menu.is( ":hidden" ), "menu is hidden after first search" );
assert.ok( menu.is( ":hidden" ), "menu is hidden after first search" );
element.val( "java" ).trigger( "keydown" );
setTimeout( function() {
ok( menu.is( ":visible" ), "menu is visible after second search" );
equal( menu.find( ".ui-menu-item" ).length, 2, "# of menu items" );
start();
assert.ok( menu.is( ":visible" ), "menu is visible after second search" );
assert.equal( menu.find( ".ui-menu-item" ).length, 2, "# of menu items" );
ready();
} );
} );
} );
asyncTest( "cancel focus", function() {
expect( 1 );
QUnit.test( "cancel focus", function( assert ) {
var ready = assert.async();
assert.expect( 1 );
var customVal = "custom value",
element = $( "#autocomplete" ).autocomplete( {
delay: 0,
@ -139,13 +144,14 @@ asyncTest( "cancel focus", function() {
element.val( "ja" ).trigger( "keydown" );
setTimeout( function() {
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
equal( element.val(), customVal );
start();
assert.equal( element.val(), customVal );
ready();
} );
} );
asyncTest( "cancel select", function() {
expect( 1 );
QUnit.test( "cancel select", function( assert ) {
var ready = assert.async();
assert.expect( 1 );
var customVal = "custom value",
element = $( "#autocomplete" ).autocomplete( {
delay: 0,
@ -159,25 +165,26 @@ asyncTest( "cancel select", function() {
setTimeout( function() {
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
equal( element.val(), customVal );
start();
assert.equal( element.val(), customVal );
ready();
} );
} );
asyncTest( "blur during remote search", function() {
expect( 1 );
QUnit.test( "blur during remote search", function( assert ) {
var ready = assert.async();
assert.expect( 1 );
var ac = $( "#autocomplete" ).autocomplete( {
delay: 0,
source: function( request, response ) {
ok( true, "trigger request" );
assert.ok( true, "trigger request" );
ac.simulate( "blur" );
setTimeout( function() {
response( [ "result" ] );
start();
ready();
}, 25 );
},
open: function() {
ok( false, "opened after a blur" );
assert.ok( false, "opened after a blur" );
}
} );
ac.val( "ro" ).trigger( "keydown" );

View File

@ -1,19 +1,20 @@
define( [
"qunit",
"jquery",
"ui/widgets/autocomplete"
], function( $ ) {
], function( QUnit, $ ) {
module( "autocomplete: methods" );
QUnit.module( "autocomplete: methods" );
test( "destroy", function( assert ) {
expect( 1 );
QUnit.test( "destroy", function( assert ) {
assert.expect( 1 );
assert.domEqual( "#autocomplete", function() {
$( "#autocomplete" ).autocomplete().autocomplete( "destroy" );
} );
} );
test( "search, close", function() {
expect( 6 );
QUnit.test( "search, close", function( assert ) {
assert.expect( 6 );
var data = [ "c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", "python", "c", "scala", "groovy", "haskell", "perl" ],
element = $( "#autocomplete" ).autocomplete( {
source: data,
@ -21,27 +22,27 @@ test( "search, close", function() {
} ),
menu = element.autocomplete( "widget" );
ok( menu.is( ":hidden" ), "menu is hidden on init" );
assert.ok( menu.is( ":hidden" ), "menu is hidden on init" );
element.autocomplete( "search" );
ok( menu.is( ":visible" ), "menu is visible after search" );
equal( menu.find( ".ui-menu-item" ).length, data.length, "all items for a blank search" );
assert.ok( menu.is( ":visible" ), "menu is visible after search" );
assert.equal( menu.find( ".ui-menu-item" ).length, data.length, "all items for a blank search" );
element.val( "has" ).autocomplete( "search" );
equal( menu.find( ".ui-menu-item" ).text(), "haskell", "only one item for set input value" );
assert.equal( menu.find( ".ui-menu-item" ).text(), "haskell", "only one item for set input value" );
element.autocomplete( "search", "ja" );
equal( menu.find( ".ui-menu-item" ).length, 2, "only java and javascript for 'ja'" );
assert.equal( menu.find( ".ui-menu-item" ).length, 2, "only java and javascript for 'ja'" );
element.autocomplete( "close" );
ok( menu.is( ":hidden" ), "menu is hidden after close" );
assert.ok( menu.is( ":hidden" ), "menu is hidden after close" );
} );
test( "widget", function( assert ) {
expect( 2 );
QUnit.test( "widget", function( assert ) {
assert.expect( 2 );
var element = $( "#autocomplete" ).autocomplete(),
widgetElement = element.autocomplete( "widget" );
equal( widgetElement.length, 1, "one element" );
assert.equal( widgetElement.length, 1, "one element" );
assert.hasClasses( widgetElement, "ui-menu" );
} );

View File

@ -1,108 +1,110 @@
define( [
"qunit",
"jquery",
"ui/widgets/autocomplete"
], function( $ ) {
], function( QUnit, $ ) {
module( "autocomplete: options" );
QUnit.module( "autocomplete: options" );
var data = [ "c++", "java", "php", "coldfusion", "javascript", "asp", "ruby",
"python", "c", "scala", "groovy", "haskell", "perl" ];
test( "appendTo: null", function() {
expect( 1 );
QUnit.test( "appendTo: null", function( assert ) {
assert.expect( 1 );
var element = $( "#autocomplete" ).autocomplete();
equal( element.autocomplete( "widget" ).parent()[ 0 ], document.body,
assert.equal( element.autocomplete( "widget" ).parent()[ 0 ], document.body,
"defaults to body" );
element.autocomplete( "destroy" );
} );
test( "appendTo: explicit", function() {
expect( 6 );
QUnit.test( "appendTo: explicit", function( assert ) {
assert.expect( 6 );
var detached = $( "<div>" ),
element = $( "#autocomplete" );
element.autocomplete( {
appendTo: ".autocomplete-wrap"
} );
equal( element.autocomplete( "widget" ).parent()[ 0 ],
assert.equal( element.autocomplete( "widget" ).parent()[ 0 ],
$( "#autocomplete-wrap1" )[ 0 ], "first found element" );
equal( $( "#autocomplete-wrap2 .ui-autocomplete" ).length, 0,
assert.equal( $( "#autocomplete-wrap2 .ui-autocomplete" ).length, 0,
"only appends to one element" );
element.autocomplete( "destroy" );
element.autocomplete().autocomplete( "option", "appendTo", "#autocomplete-wrap1" );
equal( element.autocomplete( "widget" ).parent()[ 0 ],
assert.equal( element.autocomplete( "widget" ).parent()[ 0 ],
$( "#autocomplete-wrap1" )[ 0 ], "modified after init" );
element.autocomplete( "destroy" );
element.autocomplete( {
appendTo: detached
} );
equal( element.autocomplete( "widget" ).parent()[ 0 ], detached[ 0 ],
assert.equal( element.autocomplete( "widget" ).parent()[ 0 ], detached[ 0 ],
"detached jQuery object" );
element.autocomplete( "destroy" );
element.autocomplete( {
appendTo: detached[ 0 ]
} );
equal( element.autocomplete( "widget" ).parent()[ 0 ], detached[ 0 ],
assert.equal( element.autocomplete( "widget" ).parent()[ 0 ], detached[ 0 ],
"detached DOM element" );
element.autocomplete( "destroy" );
element.autocomplete().autocomplete( "option", "appendTo", detached );
equal( element.autocomplete( "widget" ).parent()[ 0 ], detached[ 0 ],
assert.equal( element.autocomplete( "widget" ).parent()[ 0 ], detached[ 0 ],
"detached DOM element via option()" );
element.autocomplete( "destroy" );
} );
test( "appendTo: ui-front", function() {
expect( 2 );
QUnit.test( "appendTo: ui-front", function( assert ) {
assert.expect( 2 );
var element = $( "#autocomplete" );
$( "#autocomplete-wrap2" ).addClass( "ui-front" );
element.autocomplete();
equal( element.autocomplete( "widget" ).parent()[ 0 ],
assert.equal( element.autocomplete( "widget" ).parent()[ 0 ],
$( "#autocomplete-wrap2" )[ 0 ], "null, inside .ui-front" );
element.autocomplete( "destroy" );
element.autocomplete( {
appendTo: $()
} );
equal( element.autocomplete( "widget" ).parent()[ 0 ],
assert.equal( element.autocomplete( "widget" ).parent()[ 0 ],
$( "#autocomplete-wrap2" )[ 0 ], "empty jQuery object, inside .ui-front" );
} );
function autoFocusTest( afValue, focusedLength ) {
function autoFocusTest( assert, afValue, focusedLength ) {
var ready = assert.async();
var element = $( "#autocomplete" ).autocomplete( {
autoFocus: afValue,
delay: 0,
source: data,
open: function() {
equal(
assert.equal(
element.autocomplete( "widget" )
.find( ".ui-menu-item-wrapper.ui-state-active" )
.length,
focusedLength,
"first item is " + ( afValue ? "" : "not" ) + " auto focused" );
start();
ready();
}
} );
element.val( "ja" ).trigger( "keydown" );
stop();
}
test( "autoFocus: false", function() {
expect( 1 );
autoFocusTest( false, 0 );
QUnit.test( "autoFocus: false", function( assert ) {
assert.expect( 1 );
autoFocusTest( assert, false, 0 );
} );
test( "autoFocus: true", function() {
expect( 1 );
autoFocusTest( true, 1 );
QUnit.test( "autoFocus: true", function( assert ) {
assert.expect( 1 );
autoFocusTest( assert, true, 1 );
} );
asyncTest( "delay", function() {
expect( 2 );
QUnit.test( "delay", function( assert ) {
var ready = assert.async();
assert.expect( 2 );
var element = $( "#autocomplete" ).autocomplete( {
source: data,
delay: 25
@ -110,16 +112,17 @@ asyncTest( "delay", function() {
menu = element.autocomplete( "widget" );
element.val( "ja" ).trigger( "keydown" );
ok( menu.is( ":hidden" ), "menu is closed immediately after search" );
assert.ok( menu.is( ":hidden" ), "menu is closed immediately after search" );
setTimeout( function() {
ok( menu.is( ":visible" ), "menu is open after delay" );
start();
assert.ok( menu.is( ":visible" ), "menu is open after delay" );
ready();
}, 50 );
} );
asyncTest( "disabled", function( assert ) {
expect( 5 );
QUnit.test( "disabled", function( assert ) {
var ready = assert.async();
assert.expect( 5 );
var element = $( "#autocomplete" ).autocomplete( {
source: data,
delay: 0
@ -127,38 +130,39 @@ asyncTest( "disabled", function( assert ) {
menu = element.autocomplete( "disable" ).autocomplete( "widget" );
element.val( "ja" ).trigger( "keydown" );
ok( menu.is( ":hidden" ) );
assert.ok( menu.is( ":hidden" ) );
assert.lacksClasses( element, "ui-state-disabled" );
assert.hasClasses( menu, "ui-autocomplete-disabled" );
ok( !element.attr( "aria-disabled" ), "element doesn't get aria-disabled" );
assert.ok( !element.attr( "aria-disabled" ), "element doesn't get aria-disabled" );
setTimeout( function() {
ok( menu.is( ":hidden" ) );
start();
assert.ok( menu.is( ":hidden" ) );
ready();
} );
} );
test( "minLength", function() {
expect( 2 );
QUnit.test( "minLength", function( assert ) {
assert.expect( 2 );
var element = $( "#autocomplete" ).autocomplete( {
source: data
} ),
menu = element.autocomplete( "widget" );
element.autocomplete( "search", "" );
ok( menu.is( ":hidden" ), "blank not enough for minLength: 1" );
assert.ok( menu.is( ":hidden" ), "blank not enough for minLength: 1" );
element.autocomplete( "option", "minLength", 0 );
element.autocomplete( "search", "" );
ok( menu.is( ":visible" ), "blank enough for minLength: 0" );
assert.ok( menu.is( ":visible" ), "blank enough for minLength: 0" );
} );
asyncTest( "minLength, exceed then drop below", function() {
expect( 4 );
QUnit.test( "minLength, exceed then drop below", function( assert ) {
var ready = assert.async();
assert.expect( 4 );
var element = $( "#autocomplete" ).autocomplete( {
minLength: 2,
source: function( req, res ) {
equal( req.term, "12", "correct search term" );
assert.equal( req.term, "12", "correct search term" );
setTimeout( function() {
res( [ "item" ] );
} );
@ -166,20 +170,20 @@ asyncTest( "minLength, exceed then drop below", function() {
} ),
menu = element.autocomplete( "widget" );
ok( menu.is( ":hidden" ), "menu is hidden before first search" );
assert.ok( menu.is( ":hidden" ), "menu is hidden before first search" );
element.autocomplete( "search", "12" );
ok( menu.is( ":hidden" ), "menu is hidden before second search" );
assert.ok( menu.is( ":hidden" ), "menu is hidden before second search" );
element.autocomplete( "search", "1" );
setTimeout( function() {
ok( menu.is( ":hidden" ), "menu is hidden after searches" );
start();
assert.ok( menu.is( ":hidden" ), "menu is hidden after searches" );
ready();
} );
} );
test( "minLength, exceed then drop below then exceed", function() {
expect( 3 );
QUnit.test( "minLength, exceed then drop below then exceed", function( assert ) {
assert.expect( 3 );
var _res = [],
element = $( "#autocomplete" ).autocomplete( {
minLength: 2,
@ -190,11 +194,11 @@ test( "minLength, exceed then drop below then exceed", function() {
menu = element.autocomplete( "widget" );
// Trigger a valid search
ok( menu.is( ":hidden" ), "menu is hidden before first search" );
assert.ok( menu.is( ":hidden" ), "menu is hidden before first search" );
element.autocomplete( "search", "12" );
// Trigger a search below the minLength, to turn on cancelSearch flag
ok( menu.is( ":hidden" ), "menu is hidden before second search" );
assert.ok( menu.is( ":hidden" ), "menu is hidden before second search" );
element.autocomplete( "search", "1" );
// Trigger a valid search
@ -206,46 +210,47 @@ test( "minLength, exceed then drop below then exceed", function() {
// React to second search
_res[ 1 ]( [ "13" ] );
ok( menu.is( ":visible" ), "menu is visible after searches" );
assert.ok( menu.is( ":visible" ), "menu is visible after searches" );
} );
test( "source, local string array", function() {
expect( 1 );
QUnit.test( "source, local string array", function( assert ) {
assert.expect( 1 );
var element = $( "#autocomplete" ).autocomplete( {
source: data
} ),
menu = element.autocomplete( "widget" );
element.val( "ja" ).autocomplete( "search" );
equal( menu.find( ".ui-menu-item" ).text(), "javajavascript" );
assert.equal( menu.find( ".ui-menu-item" ).text(), "javajavascript" );
} );
function sourceTest( source, async ) {
function sourceTest( assert, source, async ) {
var ready;
var element = $( "#autocomplete" ).autocomplete( {
source: source
} ),
menu = element.autocomplete( "widget" );
function result() {
var items = menu.find( ".ui-menu-item" );
equal( items.length, 3, "Should find three results." );
deepEqual( items.eq( 0 ).data( "ui-autocomplete-item" ), {
assert.equal( items.length, 3, "Should find three results." );
assert.deepEqual( items.eq( 0 ).data( "ui-autocomplete-item" ), {
label: "java",
value: "java"
} );
deepEqual( items.eq( 1 ).data( "ui-autocomplete-item" ), {
assert.deepEqual( items.eq( 1 ).data( "ui-autocomplete-item" ), {
label: "javascript",
value: "javascript"
} );
deepEqual( items.eq( 2 ).data( "ui-autocomplete-item" ), {
assert.deepEqual( items.eq( 2 ).data( "ui-autocomplete-item" ), {
label: "clojure",
value: "clojure"
} );
element.autocomplete( "destroy" );
if ( async ) {
start();
ready();
}
}
if ( async ) {
stop();
ready = assert.async();
$( document ).one( "ajaxStop", result );
}
element.val( "j" ).autocomplete( "search" );
@ -254,9 +259,9 @@ function sourceTest( source, async ) {
}
}
test( "source, local object array, only labels", function() {
expect( 4 );
sourceTest( [
QUnit.test( "source, local object array, only labels", function( assert ) {
assert.expect( 4 );
sourceTest( assert, [
{ label: "java", value: null },
{ label: "php", value: null },
{ label: "coldfusion", value: "" },
@ -265,9 +270,9 @@ test( "source, local object array, only labels", function() {
] );
} );
test( "source, local object array, only values", function() {
expect( 4 );
sourceTest( [
QUnit.test( "source, local object array, only values", function( assert ) {
assert.expect( 4 );
sourceTest( assert, [
{ value: "java", label: null },
{ value: "php", label: null },
{ value: "coldfusion", label: "" },
@ -276,25 +281,25 @@ test( "source, local object array, only values", function() {
] );
} );
test( "source, url string with remote json string array", function() {
expect( 4 );
sourceTest( "remote_string_array.txt", true );
QUnit.test( "source, url string with remote json string array", function( assert ) {
assert.expect( 4 );
sourceTest( assert, "remote_string_array.txt", true );
} );
test( "source, url string with remote json object array, only value properties", function() {
expect( 4 );
sourceTest( "remote_object_array_values.txt", true );
QUnit.test( "source, url string with remote json object array, only value properties", function( assert ) {
assert.expect( 4 );
sourceTest( assert, "remote_object_array_values.txt", true );
} );
test( "source, url string with remote json object array, only label properties", function() {
expect( 4 );
sourceTest( "remote_object_array_labels.txt", true );
QUnit.test( "source, url string with remote json object array, only label properties", function( assert ) {
assert.expect( 4 );
sourceTest( assert, "remote_object_array_labels.txt", true );
} );
test( "source, custom", function() {
expect( 5 );
sourceTest( function( request, response ) {
equal( request.term, "j" );
QUnit.test( "source, custom", function( assert ) {
assert.expect( 5 );
sourceTest( assert, function( request, response ) {
assert.equal( request.term, "j" );
response( [
"java",
{ label: "javascript", value: null },
@ -303,17 +308,17 @@ test( "source, custom", function() {
} );
} );
test( "source, update after init", function() {
expect( 2 );
QUnit.test( "source, update after init", function( assert ) {
assert.expect( 2 );
var element = $( "#autocomplete" ).autocomplete( {
source: [ "java", "javascript", "haskell" ]
} ),
menu = element.autocomplete( "widget" );
element.val( "ja" ).autocomplete( "search" );
equal( menu.find( ".ui-menu-item" ).text(), "javajavascript" );
assert.equal( menu.find( ".ui-menu-item" ).text(), "javajavascript" );
element.autocomplete( "option", "source", [ "php", "asp" ] );
element.val( "ph" ).autocomplete( "search" );
equal( menu.find( ".ui-menu-item" ).text(), "php" );
assert.equal( menu.find( ".ui-menu-item" ).text(), "php" );
} );
} );

View File

@ -1,23 +1,25 @@
define( [
"qunit",
"jquery",
"ui/safe-active-element",
"ui/widgets/button"
], function( $ ) {
], function( QUnit, $ ) {
module( "Button: core" );
QUnit.module( "Button: core" );
asyncTest( "Disabled button loses focus", function() {
expect( 2 );
QUnit.test( "Disabled button loses focus", function( assert ) {
var ready = assert.async();
assert.expect( 2 );
var element = $( "#button" ).button();
element.focus();
setTimeout( function() {
equal( element[ 0 ], $.ui.safeActiveElement( document ), "Button is focused" );
assert.equal( element[ 0 ], $.ui.safeActiveElement( document ), "Button is focused" );
element.button( "disable" );
notEqual( element[ 0 ], $.ui.safeActiveElement( document ), "Button has had focus removed" );
start();
assert.notEqual( element[ 0 ], $.ui.safeActiveElement( document ), "Button has had focus removed" );
ready();
} );
} );

View File

@ -1,134 +1,135 @@
define( [
"qunit",
"jquery",
"ui/widgets/button"
], function( $ ) {
], function( QUnit, $ ) {
module( "Button (deprecated): core" );
QUnit.module( "Button (deprecated): core" );
test( "Calling button on a checkbox input calls checkboxradio widget", function() {
QUnit.test( "Calling button on a checkbox input calls checkboxradio widget", function( assert ) {
var checkbox = $( "#checkbox01" );
expect( 2 );
assert.expect( 2 );
checkbox.button();
ok( !!checkbox.checkboxradio( "instance" ),
assert.ok( !!checkbox.checkboxradio( "instance" ),
"Calling button on a checkbox creates checkboxradio instance" );
ok( !checkbox.checkboxradio( "option", "icon" ),
assert.ok( !checkbox.checkboxradio( "option", "icon" ),
"Calling button on a checkbox sets the checkboxradio icon option to false" );
} );
test( "Calling buttonset calls controlgroup", function() {
QUnit.test( "Calling buttonset calls controlgroup", function( assert ) {
var controlgroup = $( ".buttonset" );
expect( 1 );
assert.expect( 1 );
controlgroup.buttonset();
ok( controlgroup.is( ":ui-controlgroup" ), "Calling buttonset creates controlgroup instance" );
assert.ok( controlgroup.is( ":ui-controlgroup" ), "Calling buttonset creates controlgroup instance" );
} );
module( "Button (deprecated): methods" );
QUnit.module( "Button (deprecated): methods" );
test( "destroy", function( assert ) {
expect( 1 );
QUnit.test( "destroy", function( assert ) {
assert.expect( 1 );
assert.domEqual( "#checkbox02", function() {
$( "#checkbox02" ).button().button( "destroy" );
} );
} );
test( "refresh: Ensure disabled state is preserved correctly.", function() {
expect( 5 );
QUnit.test( "refresh: Ensure disabled state is preserved correctly.", function( assert ) {
assert.expect( 5 );
var element = null;
element = $( "#checkbox02" );
element.button( { disabled: true } ).button( "refresh" );
ok( element.button( "option", "disabled" ), "Checkboxes should remain disabled after refresh" );
ok( element.prop( "disabled" ), "Input remains disabled after refresh" );
assert.ok( element.button( "option", "disabled" ), "Checkboxes should remain disabled after refresh" );
assert.ok( element.prop( "disabled" ), "Input remains disabled after refresh" );
element = $( "#radio02" );
element.button( { disabled: true } ).button( "refresh" );
ok( element.button( "option", "disabled" ), "Radio buttons should remain disabled after refresh" );
assert.ok( element.button( "option", "disabled" ), "Radio buttons should remain disabled after refresh" );
element = $( "#checkbox02" );
element.button( { disabled: true } ).prop( "disabled", false ).button( "refresh" );
ok( !element.button( "option", "disabled" ), "Changing a checkbox's disabled property should update the state after refresh." );
assert.ok( !element.button( "option", "disabled" ), "Changing a checkbox's disabled property should update the state after refresh." );
element = $( "#radio02" );
element.button( { disabled: true } ).prop( "disabled", false ).button( "refresh" );
ok( !element.button( "option", "disabled" ), "Changing a radio button's disabled property should update the state after refresh." );
assert.ok( !element.button( "option", "disabled" ), "Changing a radio button's disabled property should update the state after refresh." );
} );
module( "button (deprecated): options" );
QUnit.module( "button (deprecated): options" );
test( "Setting items option on buttonset sets the button properties on the items option", function() {
expect( 2 );
QUnit.test( "Setting items option on buttonset sets the button properties on the items option", function( assert ) {
assert.expect( 2 );
var controlgroup = $( ".buttonset" );
controlgroup.buttonset( { items: "bar" } );
equal( controlgroup.controlgroup( "option", "items.button" ), "bar",
assert.equal( controlgroup.controlgroup( "option", "items.button" ), "bar",
"items.button set when setting items option on init on buttonset" );
controlgroup.buttonset( "option", "items", "foo" );
equal( controlgroup.controlgroup( "option", "items.button" ), "foo",
assert.equal( controlgroup.controlgroup( "option", "items.button" ), "foo",
"items.button set when setting items option on buttonset" );
} );
test( "disabled, null", function() {
expect( 2 );
QUnit.test( "disabled, null", function( assert ) {
assert.expect( 2 );
$( "#radio02" ).prop( "disabled", true ).button( { disabled: null } );
deepEqual( $( "#radio02" ).button( "option", "disabled" ), true,
assert.deepEqual( $( "#radio02" ).button( "option", "disabled" ), true,
"disabled option set to true" );
deepEqual( true, $( "#radio02" ).prop( "disabled" ), "element is not disabled" );
assert.deepEqual( true, $( "#radio02" ).prop( "disabled" ), "element is not disabled" );
} );
test( "text / showLabel options proxied", function() {
expect( 8 );
QUnit.test( "text / showLabel options proxied", function( assert ) {
assert.expect( 8 );
var button = $( "#button" );
button.button( {
text: false,
icon: "ui-icon-gear"
} );
equal( button.button( "option", "showLabel" ), false,
assert.equal( button.button( "option", "showLabel" ), false,
"Setting the text option to false sets the showLabel option to false on init" );
button.button( "option", "showLabel", true );
equal( button.button( "option", "text" ), true,
assert.equal( button.button( "option", "text" ), true,
"Setting showLabel true with option method sets text option to true" );
button.button( "option", "text", false );
equal( button.button( "option", "showLabel" ), false,
assert.equal( button.button( "option", "showLabel" ), false,
"Setting text false with option method sets showLabel option to false" );
button.button( "option", "text", true );
equal( button.button( "option", "showLabel" ), true,
assert.equal( button.button( "option", "showLabel" ), true,
"Setting text true with option method sets showLabel option to true" );
button.button( "option", "showLabel", false );
equal( button.button( "option", "text" ), false,
assert.equal( button.button( "option", "text" ), false,
"Setting showLabel false with option method sets text option to false" );
button.button( "destroy" );
button.button( {
text: true,
icon: "ui-icon-gear"
} );
equal( button.button( "option", "showLabel" ), true,
assert.equal( button.button( "option", "showLabel" ), true,
"Setting the text option to true sets the showLabel option to true on init" );
button.button( "destroy" );
button.button( {
showLabel: true,
icon: "ui-icon-gear"
} );
equal( button.button( "option", "text" ), true,
assert.equal( button.button( "option", "text" ), true,
"Setting the showLabel option to true sets the text option to true on init" );
button.button( "destroy" );
button.button( {
showLabel: false,
icon: "ui-icon-gear"
} );
equal( button.button( "option", "text" ), false,
assert.equal( button.button( "option", "text" ), false,
"Setting the showLabel option to false sets the text option to false on init" );
} );
test( "icon / icons options properly proxied", function() {
expect( 10 );
QUnit.test( "icon / icons options properly proxied", function( assert ) {
assert.expect( 10 );
var button = $( "#button" );
@ -136,14 +137,14 @@ test( "icon / icons options properly proxied", function() {
icon: "foo"
} );
equal( button.button( "option", "icons.primary" ), "foo",
assert.equal( button.button( "option", "icons.primary" ), "foo",
"Icon option properly proxied on init" );
button.button( {
icon: "bar"
} );
equal( button.button( "option", "icons.primary" ), "bar",
assert.equal( button.button( "option", "icons.primary" ), "bar",
"Icon option properly proxied with option method" );
button.button( {
@ -152,9 +153,9 @@ test( "icon / icons options properly proxied", function() {
}
} );
equal( button.button( "option", "icon" ), "foo",
assert.equal( button.button( "option", "icon" ), "foo",
"Icons primary option properly proxied with option method" );
equal( button.button( "option", "iconPosition" ), "beginning",
assert.equal( button.button( "option", "iconPosition" ), "beginning",
"Icons primary option sets iconPosition option to beginning" );
button.button( {
@ -163,9 +164,9 @@ test( "icon / icons options properly proxied", function() {
}
} );
equal( button.button( "option", "icon" ), "bar",
assert.equal( button.button( "option", "icon" ), "bar",
"Icons secondary option properly proxied with option method" );
equal( button.button( "option", "iconPosition" ), "end",
assert.equal( button.button( "option", "iconPosition" ), "end",
"Icons secondary option sets iconPosition option to end" );
button.button( "destroy" );
@ -176,9 +177,9 @@ test( "icon / icons options properly proxied", function() {
}
} );
equal( button.button( "option", "icon" ), "foo",
assert.equal( button.button( "option", "icon" ), "foo",
"Icons primary option properly proxied on init" );
equal( button.button( "option", "iconPosition" ), "beginning",
assert.equal( button.button( "option", "iconPosition" ), "beginning",
"Icons primary option sets iconPosition option to beginning on init" );
button.button( {
@ -187,9 +188,9 @@ test( "icon / icons options properly proxied", function() {
}
} );
equal( button.button( "option", "icon" ), "bar",
assert.equal( button.button( "option", "icon" ), "bar",
"Icons secondary option properly proxied on init" );
equal( button.button( "option", "iconPosition" ), "end",
assert.equal( button.button( "option", "iconPosition" ), "end",
"Icons secondary option sets iconPosition option to end on init" );
} );

View File

@ -1,18 +1,20 @@
define( [
"qunit",
"jquery",
"ui/widgets/button"
], function( $ ) {
], function( QUnit, $ ) {
module( "Button: events" );
QUnit.module( "Button: events" );
asyncTest( "Anchor recieves click event when spacebar is pressed", function() {
expect( 1 );
QUnit.test( "Anchor recieves click event when spacebar is pressed", function( assert ) {
var ready = assert.async();
assert.expect( 1 );
var element = $( "#anchor-button" ).button();
element.on( "click", function( event ) {
event.preventDefault();
ok( true, "click occcured as a result of spacebar" );
start();
assert.ok( true, "click occcured as a result of spacebar" );
ready();
} );
element.trigger( $.Event( "keyup", { keyCode: $.ui.keyCode.SPACE } ) );

View File

@ -1,32 +1,33 @@
define( [
"qunit",
"jquery",
"ui/widgets/button"
], function( $ ) {
], function( QUnit, $ ) {
module( "Button: methods" );
QUnit.module( "Button: methods" );
test( "destroy", function( assert ) {
expect( 1 );
QUnit.test( "destroy", function( assert ) {
assert.expect( 1 );
assert.domEqual( "#button", function() {
$( "#button" ).button().button( "destroy" );
} );
} );
test( "refresh: Ensure disabled state is preserved correctly.", function() {
expect( 3 );
QUnit.test( "refresh: Ensure disabled state is preserved correctly.", function( assert ) {
assert.expect( 3 );
var element = $( "<a href='#'></a>" );
element.button( { disabled: true } ).button( "refresh" );
ok( element.button( "option", "disabled" ),
assert.ok( element.button( "option", "disabled" ),
"Anchor button should remain disabled after refresh" );
element = $( "<button></button>" );
element.button( { disabled: true } ).button( "refresh" );
ok( element.button( "option", "disabled" ), "<button> should remain disabled after refresh" );
assert.ok( element.button( "option", "disabled" ), "<button> should remain disabled after refresh" );
element = $( "<button></button>" );
element.button( { disabled: true } ).prop( "disabled", false ).button( "refresh" );
ok( !element.button( "option", "disabled" ),
assert.ok( !element.button( "option", "disabled" ),
"Changing a <button>'s disabled property should update the state after refresh." );
} );

View File

@ -1,66 +1,67 @@
define( [
"qunit",
"jquery",
"ui/widgets/button"
], function( $ ) {
], function( QUnit, $ ) {
module( "button: options" );
QUnit.module( "button: options" );
test( "disabled, explicit value", function( assert ) {
expect( 8 );
QUnit.test( "disabled, explicit value", function( assert ) {
assert.expect( 8 );
var element = $( "#button" ).button( { disabled: false } );
strictEqual( element.button( "option", "disabled" ), false, "disabled option set to false" );
strictEqual( element.prop( "disabled" ), false, "Disabled property is false" );
assert.strictEqual( element.button( "option", "disabled" ), false, "disabled option set to false" );
assert.strictEqual( element.prop( "disabled" ), false, "Disabled property is false" );
assert.lacksClasses( element.button( "widget" ), "ui-state-disabled ui-button-disabled" );
element = $( "#button" ).button( { disabled: true } );
assert.hasClasses( element.button( "widget" ), "ui-state-disabled" );
strictEqual( element.button( "widget" ).attr( "aria-disabled" ), undefined,
assert.strictEqual( element.button( "widget" ).attr( "aria-disabled" ), undefined,
"element does not get aria-disabled" );
assert.hasClasses( element.button( "widget" ), "ui-button-disabled" );
strictEqual( element.button( "option", "disabled" ), true, "disabled option set to true" );
strictEqual( element.prop( "disabled" ), true, "Disabled property is set" );
assert.strictEqual( element.button( "option", "disabled" ), true, "disabled option set to true" );
assert.strictEqual( element.prop( "disabled" ), true, "Disabled property is set" );
} );
// We are testing the default here because the default null is a special value which means to check
// the DOM. We need to make sure this happens correctly. Checking the options should never return
// null, it should always be true or false.
test( "disabled, null", function() {
expect( 4 );
QUnit.test( "disabled, null", function( assert ) {
assert.expect( 4 );
var element = $( "#button" ),
elementDisabled = $( "#button-disabled" );
element.add( elementDisabled ).button( { disabled: null } );
strictEqual( element.button( "option", "disabled" ), false, "disabled option set to false" );
strictEqual( element.prop( "disabled" ), false, "element is disabled" );
strictEqual( elementDisabled.button( "option", "disabled" ), true,
assert.strictEqual( element.button( "option", "disabled" ), false, "disabled option set to false" );
assert.strictEqual( element.prop( "disabled" ), false, "element is disabled" );
assert.strictEqual( elementDisabled.button( "option", "disabled" ), true,
"disabled option set to true" );
strictEqual( elementDisabled.prop( "disabled" ), true, "element is disabled" );
assert.strictEqual( elementDisabled.prop( "disabled" ), true, "element is disabled" );
} );
test( "showLabel, false, without icon", function( assert ) {
expect( 4 );
QUnit.test( "showLabel, false, without icon", function( assert ) {
assert.expect( 4 );
var button = $( "#button" ).button( {
showLabel: false
} );
assert.lacksClasses( button, "ui-button-icon-only" );
strictEqual( button.button( "option", "showLabel" ), true,
assert.strictEqual( button.button( "option", "showLabel" ), true,
"showLabel false only allowed if icon true" );
button.button( "option", "showLabel", false );
assert.lacksClasses( button, "ui-button-icon-only" );
strictEqual( button.button( "option", "showLabel" ), true,
assert.strictEqual( button.button( "option", "showLabel" ), true,
"showLabel false only allowed if icon true" );
} );
test( "showLabel, false, with icon", function( assert ) {
expect( 1 );
QUnit.test( "showLabel, false, with icon", function( assert ) {
assert.expect( 1 );
var button = $( "#button" ).button( {
showLabel: false,
icon: "iconclass"
@ -68,53 +69,53 @@ test( "showLabel, false, with icon", function( assert ) {
assert.hasClasses( button, "ui-button ui-corner-all ui-widget ui-button-icon-only" );
} );
test( "label, default", function() {
expect( 2 );
QUnit.test( "label, default", function( assert ) {
assert.expect( 2 );
var button = $( "#button" ).button();
deepEqual( button.text(), "Label" );
deepEqual( button.button( "option", "label" ), "Label" );
assert.deepEqual( button.text(), "Label" );
assert.deepEqual( button.button( "option", "label" ), "Label" );
} );
test( "label, with html markup", function() {
expect( 3 );
QUnit.test( "label, with html markup", function( assert ) {
assert.expect( 3 );
var button = $( "#button2" ).button();
deepEqual( button.text(), "label with span" );
deepEqual( button.html().toLowerCase(), "label <span>with span</span>" );
deepEqual( button.button( "option", "label" ).toLowerCase(), "label <span>with span</span>" );
assert.deepEqual( button.text(), "label with span" );
assert.deepEqual( button.html().toLowerCase(), "label <span>with span</span>" );
assert.deepEqual( button.button( "option", "label" ).toLowerCase(), "label <span>with span</span>" );
} );
test( "label, explicit value", function() {
expect( 2 );
QUnit.test( "label, explicit value", function( assert ) {
assert.expect( 2 );
var button = $( "#button" ).button( {
label: "xxx"
} );
deepEqual( button.text(), "xxx" );
deepEqual( button.button( "option", "label" ), "xxx" );
assert.deepEqual( button.text(), "xxx" );
assert.deepEqual( button.button( "option", "label" ), "xxx" );
} );
test( "label, default, with input type submit", function() {
expect( 2 );
QUnit.test( "label, default, with input type submit", function( assert ) {
assert.expect( 2 );
var button = $( "#submit" ).button();
deepEqual( button.val(), "Label" );
deepEqual( button.button( "option", "label" ), "Label" );
assert.deepEqual( button.val(), "Label" );
assert.deepEqual( button.button( "option", "label" ), "Label" );
} );
test( "label, explicit value, with input type submit", function() {
expect( 2 );
QUnit.test( "label, explicit value, with input type submit", function( assert ) {
assert.expect( 2 );
var button = $( "#submit" ).button( {
label: "xxx"
} );
deepEqual( button.val(), "xxx" );
deepEqual( button.button( "option", "label" ), "xxx" );
assert.deepEqual( button.val(), "xxx" );
assert.deepEqual( button.button( "option", "label" ), "xxx" );
} );
test( "icon", function( assert ) {
expect( 4 );
QUnit.test( "icon", function( assert ) {
assert.expect( 4 );
var button = $( "#button" ).button( {
showLabel: false,
icon: "iconclass"
@ -122,18 +123,18 @@ test( "icon", function( assert ) {
icon = button.find( ".ui-icon" );
assert.hasClasses( icon, "iconclass" );
equal( icon.length, 1, "button with icon option set has icon" );
assert.equal( icon.length, 1, "button with icon option set has icon" );
button.button( "option", "icon", false );
equal( button.find( ".ui-icon" ).length, 0, "setting icon to false removes the icon" );
assert.equal( button.find( ".ui-icon" ).length, 0, "setting icon to false removes the icon" );
button.button( "option", "icon", "iconclass" );
ok( button.find( ".ui-icon" ).length, "setting icon to a value adds the icon" );
assert.ok( button.find( ".ui-icon" ).length, "setting icon to a value adds the icon" );
} );
test( "icon position", function( assert ) {
expect( 22 );
QUnit.test( "icon position", function( assert ) {
assert.expect( 22 );
var button = $( "#button" ).button( {
icon: "ui-icon-gear"
@ -141,41 +142,41 @@ test( "icon position", function( assert ) {
icon = button.find( ".ui-icon" ),
space = button.find( ".ui-button-icon-space" );
equal( icon.length, 1, "button with icon option set has icon" );
equal( button.button( "option", "iconPosition" ), "beginning",
assert.equal( icon.length, 1, "button with icon option set has icon" );
assert.equal( button.button( "option", "iconPosition" ), "beginning",
"Button has iconPosition beginning by default" );
equal( button.contents()[ 0 ], icon[ 0 ], "icon is prepended when position is begining" );
equal( icon.next()[ 0 ], space[ 0 ], "icon is followed by a space when position is begining" );
equal( space.length, 1,
assert.equal( button.contents()[ 0 ], icon[ 0 ], "icon is prepended when position is begining" );
assert.equal( icon.next()[ 0 ], space[ 0 ], "icon is followed by a space when position is begining" );
assert.equal( space.length, 1,
"ui-button-icon-space contains a breaking space iconPosition:beginning" );
assert.lacksClasses( icon, "ui-widget-icon-block" );
button.button( "option", "iconPosition", "end" );
icon = button.find( ".ui-icon" );
space = button.find( ".ui-button-icon-space" );
equal( icon.length, 1, "Changing position to end does not re-create or duplicate icon" );
equal( button.button( "option", "iconPosition" ), "end", "Button has iconPosition end" );
equal( button.contents().last()[ 0 ], icon[ 0 ], "icon is appended when position is end" );
equal( icon.prev()[ 0 ], space[ 0 ], "icon is preceeded by a space when position is end" );
equal( space.length, 1,
assert.equal( icon.length, 1, "Changing position to end does not re-create or duplicate icon" );
assert.equal( button.button( "option", "iconPosition" ), "end", "Button has iconPosition end" );
assert.equal( button.contents().last()[ 0 ], icon[ 0 ], "icon is appended when position is end" );
assert.equal( icon.prev()[ 0 ], space[ 0 ], "icon is preceeded by a space when position is end" );
assert.equal( space.length, 1,
"ui-button-icon-space contains a breaking space iconPosition:beginning" );
assert.lacksClasses( icon, "ui-widget-icon-block" );
button.button( "option", "iconPosition", "top" );
icon = button.find( ".ui-icon" );
equal( icon.length, 1, "Changing position to top does not re-create or duplicate icon" );
equal( button.button( "option", "iconPosition" ), "top", "Button has iconPosition top" );
equal( button.contents()[ 0 ], icon[ 0 ], "icon is prepended when position is top" );
ok( !button.find( "ui-button-icon-space" ).length,
assert.equal( icon.length, 1, "Changing position to top does not re-create or duplicate icon" );
assert.equal( button.button( "option", "iconPosition" ), "top", "Button has iconPosition top" );
assert.equal( button.contents()[ 0 ], icon[ 0 ], "icon is prepended when position is top" );
assert.ok( !button.find( "ui-button-icon-space" ).length,
"Button should not have an iconSpace with position: top" );
assert.hasClasses( icon, "ui-widget-icon-block" );
button.button( "option", "iconPosition", "bottom" );
icon = button.find( ".ui-icon" );
equal( icon.length, 1, "Changing position to bottom does not re-create or duplicate icon" );
equal( button.button( "option", "iconPosition" ), "bottom", "Button has iconPosition top" );
equal( button.contents().last()[ 0 ], icon[ 0 ], "icon is prepended when position is bottom" );
ok( !button.find( "ui-button-icon-space" ).length,
assert.equal( icon.length, 1, "Changing position to bottom does not re-create or duplicate icon" );
assert.equal( button.button( "option", "iconPosition" ), "bottom", "Button has iconPosition top" );
assert.equal( button.contents().last()[ 0 ], icon[ 0 ], "icon is prepended when position is bottom" );
assert.ok( !button.find( "ui-button-icon-space" ).length,
"Button should not have an iconSpace with position: bottom" );
assert.hasClasses( icon, "ui-widget-icon-block" );

View File

@ -1,12 +1,13 @@
define( [
"qunit",
"jquery",
"ui/widgets/checkboxradio"
], function( $ ) {
], function( QUnit, $ ) {
module( "Checkboxradio: core" );
QUnit.module( "Checkboxradio: core" );
test( "Checkbox - Initial class structure", function( assert ) {
expect( 2 );
QUnit.test( "Checkbox - Initial class structure", function( assert ) {
assert.expect( 2 );
var input = $( "#check" ),
label = $( "label[for=check]" );
@ -15,8 +16,8 @@ test( "Checkbox - Initial class structure", function( assert ) {
assert.hasClasses( label, "ui-button ui-widget ui-checkboxradio-label ui-corner-all" );
} );
test( "Radios - Initial class structure", function( assert ) {
expect( 6 );
QUnit.test( "Radios - Initial class structure", function( assert ) {
assert.expect( 6 );
var inputs = $( "#radio0 input" ),
labels = $( "#radio0 label" );
@ -29,12 +30,13 @@ test( "Radios - Initial class structure", function( assert ) {
} );
} );
asyncTest( "Ensure checked after single click on checkbox label button", function( assert ) {
expect( 2 );
QUnit.test( "Ensure checked after single click on checkbox label button", function( assert ) {
var ready = assert.async();
assert.expect( 2 );
$( "#check2" ).checkboxradio().change( function() {
var label = $( this ).checkboxradio( "widget" );
ok( this.checked, "checked ok" );
assert.ok( this.checked, "checked ok" );
assert.hasClasses( label, "ui-state-active" );
} );
@ -45,12 +47,12 @@ asyncTest( "Ensure checked after single click on checkbox label button", functio
// tracked down, this delay will have to do.
setTimeout( function() {
$( "#check2" ).checkboxradio( "widget" ).simulate( "click" );
start();
ready();
} );
} );
test( "Handle form association via form attribute", function( assert ) {
expect( 4 );
QUnit.test( "Handle form association via form attribute", function( assert ) {
assert.expect( 4 );
var radio1 = $( "#crazy-form-1" ).checkboxradio();
var radio1Label = radio1.checkboxradio( "widget" );
@ -58,8 +60,8 @@ test( "Handle form association via form attribute", function( assert ) {
var radio2Label = radio2.checkboxradio( "widget" );
radio2.change( function() {
ok( this.checked, "#2 checked" );
ok( !radio1[ 0 ].checked, "#1 not checked" );
assert.ok( this.checked, "#2 checked" );
assert.ok( !radio1[ 0 ].checked, "#1 not checked" );
assert.hasClasses( radio2Label, "ui-state-active" );
assert.lacksClasses( radio1Label, "ui-state-active" );
@ -68,8 +70,8 @@ test( "Handle form association via form attribute", function( assert ) {
radio2Label.simulate( "click" );
} );
test( "Checkbox creation requires a label, and finds it in all cases", function( assert ) {
expect( 7 );
QUnit.test( "Checkbox creation requires a label, and finds it in all cases", function( assert ) {
assert.expect( 7 );
var groups = [
"<span><label for='t7092a'></label><input type='checkbox' id='t7092a'></span>",
"<span><input type='checkbox' id='t7092b'><label for='t7092b'></label></span>",
@ -88,8 +90,8 @@ test( "Checkbox creation requires a label, and finds it in all cases", function(
} );
} );
test( "Calling checkboxradio on an unsupported element throws an error", function( assert ) {
expect( 2 );
QUnit.test( "Calling checkboxradio on an unsupported element throws an error", function( assert ) {
assert.expect( 2 );
var errorMessage =
"Can't create checkboxradio on element.nodeName=div and element.type=undefined";
@ -117,8 +119,8 @@ test( "Calling checkboxradio on an unsupported element throws an error", functio
);
} );
test( "Calling checkboxradio on an input with no label throws an error", function( assert ) {
expect( 1 );
QUnit.test( "Calling checkboxradio on an input with no label throws an error", function( assert ) {
assert.expect( 1 );
var errorMessage = "No label found for checkboxradio widget";
var error = new Error( errorMessage );

View File

@ -1,14 +1,16 @@
define( [
"qunit",
"jquery",
"ui/widgets/checkboxradio"
], function( $ ) {
], function( QUnit, $ ) {
module( "Checkboxradio: events" );
QUnit.module( "Checkboxradio: events" );
asyncTest(
QUnit.test(
"Resetting a checkbox's form should refresh the visual state of the checkbox",
function( assert ) {
expect( 2 );
var ready = assert.async();
assert.expect( 2 );
var form = $( "<form>" +
"<label for='c1'></label><input id='c1' type='checkbox' checked>" +
"</form>" ),
@ -22,20 +24,21 @@ asyncTest(
setTimeout( function() {
assert.hasClasses( widget, "ui-state-active" );
start();
ready();
}, 1 );
}
);
asyncTest( "Checkbox shows focus when using keyboard navigation", function( assert ) {
expect( 2 );
QUnit.test( "Checkbox shows focus when using keyboard navigation", function( assert ) {
var ready = assert.async();
assert.expect( 2 );
var check = $( "#check" ).checkboxradio(),
label = $( "label[for='check']" );
assert.lacksClasses( label, "ui-state-focus" );
check.focus();
setTimeout( function() {
assert.hasClasses( label, "ui-state-focus" );
start();
ready();
} );
} );

View File

@ -1,29 +1,30 @@
define( [
"qunit",
"jquery",
"ui/widgets/checkboxradio"
], function( $ ) {
], function( QUnit, $ ) {
module( "Checkboxradio: methods" );
QUnit.module( "Checkboxradio: methods" );
$.each( [ "checkbox", "radio" ], function( index, value ) {
test( value + ": refresh", function( assert ) {
QUnit.test( value + ": refresh", function( assert ) {
var widget, icon,
checkbox = value === "checkbox",
input = $( "#" + value + "-method-refresh" );
expect( checkbox ? 11 : 8 );
assert.expect( checkbox ? 11 : 8 );
input.checkboxradio();
widget = input.checkboxradio( "widget" );
icon = widget.find( ".ui-icon" );
strictEqual( icon.length, 1,
assert.strictEqual( icon.length, 1,
"There is initally one icon" );
icon.remove();
input.checkboxradio( "refresh" );
icon = widget.find( ".ui-icon" );
strictEqual( icon.length, 1,
assert.strictEqual( icon.length, 1,
"Icon is recreated on refresh if absent" );
assert.hasClasses( icon, "ui-icon-blank" );
if ( checkbox ) {
@ -48,49 +49,49 @@ $.each( [ "checkbox", "radio" ], function( index, value ) {
assert.lacksClasses( widget, "ui-checkboxradio-checked" );
} );
test( value + ": destroy", function( assert ) {
expect( 1 );
QUnit.test( value + ": destroy", function( assert ) {
assert.expect( 1 );
assert.domEqual( "#" + value + "-method-destroy", function() {
$( "#" + value + "-method-destroy" ).checkboxradio().checkboxradio( "destroy" );
} );
} );
test( value + ": disable / enable", function( assert ) {
expect( 4 );
QUnit.test( value + ": disable / enable", function( assert ) {
assert.expect( 4 );
var input = $( "#" + value + "-method-disable" ),
widget = input.checkboxradio().checkboxradio( "widget" );
input.checkboxradio( "disable" );
assert.hasClasses( widget, "ui-state-disabled" );
strictEqual( input.is( ":disabled" ), true,
assert.strictEqual( input.is( ":disabled" ), true,
value + " is disabled when disable is called" );
input.checkboxradio( "enable" );
assert.lacksClasses( widget, "ui-state-disabled" );
strictEqual( input.is( ":disabled" ), false,
assert.strictEqual( input.is( ":disabled" ), false,
value + " has disabled prop removed when enable is called" );
} );
test( value + ": widget returns the label", function() {
expect( 1 );
QUnit.test( value + ": widget returns the label", function( assert ) {
assert.expect( 1 );
var input = $( "#" + value + "-method-refresh" ),
label = $( "#" + value + "-method-refresh-label" );
input.checkboxradio();
strictEqual( input.checkboxradio( "widget" )[ 0 ], label[ 0 ],
assert.strictEqual( input.checkboxradio( "widget" )[ 0 ], label[ 0 ],
"widget method returns label" );
} );
} );
test( "Input wrapped in a label preserved on refresh", function() {
QUnit.test( "Input wrapped in a label preserved on refresh", function( assert ) {
var input = $( "#label-with-no-for" ).checkboxradio(),
element = input.checkboxradio( "widget" );
expect( 1 );
assert.expect( 1 );
input.checkboxradio( "refresh" );
strictEqual( input.parent()[ 0 ], element[ 0 ], "Input preserved" );
assert.strictEqual( input.parent()[ 0 ], element[ 0 ], "Input preserved" );
} );
} );

View File

@ -1,25 +1,26 @@
define( [
"qunit",
"jquery",
"ui/widgets/checkboxradio"
], function( $ ) {
], function( QUnit, $ ) {
module( "Checkboxradio: options" );
QUnit.module( "Checkboxradio: options" );
function assertDisabled( checkbox, assert ) {
assert.hasClasses( checkbox.checkboxradio( "widget" ), "ui-state-disabled",
"label gets ui-state-disabled" );
strictEqual( checkbox.is( ":disabled" ), true, "checkbox is disabled" );
assert.strictEqual( checkbox.is( ":disabled" ), true, "checkbox is disabled" );
}
function assertEnabled( checkbox, assert ) {
assert.lacksClasses( checkbox.checkboxradio( "widget" ), "ui-state-disabled",
"label has ui-state-disabled removed when disabled set to false" );
strictEqual( checkbox.is( ":disabled" ), false,
assert.strictEqual( checkbox.is( ":disabled" ), false,
"checkbox has disabled prop removed when disabled set to false" );
}
test( "disabled", function( assert ) {
expect( 6 );
QUnit.test( "disabled", function( assert ) {
assert.expect( 6 );
var checkbox = $( "#checkbox-option-disabled" );
checkbox.checkboxradio( {
@ -35,8 +36,8 @@ test( "disabled", function( assert ) {
assertDisabled( checkbox, assert );
} );
test( "disabled - prop true on init", function( assert ) {
expect( 2 );
QUnit.test( "disabled - prop true on init", function( assert ) {
assert.expect( 2 );
var checkbox = $( "#checkbox-option-disabled" );
checkbox.prop( "disabled", true );
@ -45,8 +46,8 @@ test( "disabled - prop true on init", function( assert ) {
assertDisabled( checkbox, assert );
} );
test( "disabled - explicit null value, checks the DOM", function( assert ) {
expect( 2 );
QUnit.test( "disabled - explicit null value, checks the DOM", function( assert ) {
assert.expect( 2 );
var checkbox = $( "#checkbox-option-disabled" );
checkbox.prop( "disabled", true );
@ -56,8 +57,8 @@ test( "disabled - explicit null value, checks the DOM", function( assert ) {
assertDisabled( checkbox, assert );
} );
function assertNoIcon( checkbox ) {
strictEqual( checkbox.checkboxradio( "widget" ).find( "span.ui-icon" ).length, 0,
function assertNoIcon( assert, checkbox ) {
assert.strictEqual( checkbox.checkboxradio( "widget" ).find( "span.ui-icon" ).length, 0,
"Label does not contain an icon" );
}
@ -65,83 +66,83 @@ function assertIcon( checkbox, icon, assert ) {
var iconElement = checkbox.checkboxradio( "widget" ).find( ".ui-icon" );
icon = icon || "blank";
strictEqual( iconElement.length, 1,
assert.strictEqual( iconElement.length, 1,
"Label contains icon" );
assert.hasClasses( iconElement, "ui-checkboxradio-icon ui-corner-all ui-icon " +
"ui-icon-background ui-icon-" + icon,
"Icon has proper classes" );
if ( icon === "blank" ) {
assert.lacksClasses( iconElement, "ui-icon-check ui-state-highlight" );
assert.lacksClasses( iconElement, "ui-icon-check ui-state-checked" );
}
}
test( "icon - false on init", function() {
QUnit.test( "icon - false on init", function( assert ) {
var checkbox = $( "#checkbox-option-icon" );
expect( 1 );
assert.expect( 1 );
checkbox.checkboxradio( { icon: false } );
assertNoIcon( checkbox );
assertNoIcon( assert, checkbox );
} );
test( "icon - default unchecked", function( assert ) {
QUnit.test( "icon - default unchecked", function( assert ) {
var checkbox = $( "#checkbox-option-icon" );
expect( 3 );
assert.expect( 3 );
checkbox.checkboxradio();
assertIcon( checkbox, false, assert );
} );
test( "icon - default checked", function( assert ) {
QUnit.test( "icon - default checked", function( assert ) {
var checkbox = $( "#checkbox-option-icon" ).attr( "checked", true );
expect( 2 );
assert.expect( 2 );
checkbox.checkboxradio();
assertIcon( checkbox, "check ui-state-highlight", assert );
assertIcon( checkbox, "check ui-state-checked", assert );
} );
test( "icon", function( assert ) {
QUnit.test( "icon", function( assert ) {
var checkbox = $( "#checkbox-option-icon" );
expect( 9 );
assert.expect( 9 );
checkbox.prop( "checked", true );
checkbox.checkboxradio();
assertIcon( checkbox, "check ui-state-highlight", assert );
assertIcon( checkbox, "check ui-state-checked", assert );
checkbox.checkboxradio( "option", "icon", false );
assertNoIcon( checkbox );
assertNoIcon( assert, checkbox );
checkbox.checkboxradio( "option", "icon", true );
assertIcon( checkbox, "check ui-state-highlight", assert );
assertIcon( checkbox, "check ui-state-checked", assert );
checkbox.checkboxradio( "option", "icon", false );
assertNoIcon( checkbox );
assertNoIcon( assert, checkbox );
checkbox.checkboxradio( "option", "icon", true );
checkbox.prop( "checked", false ).checkboxradio( "refresh" );
assertIcon( checkbox, false, assert );
} );
test( "label - default", function() {
QUnit.test( "label - default", function( assert ) {
var checkbox = $( "#checkbox-option-label" ),
widget;
expect( 2 );
assert.expect( 2 );
checkbox.checkboxradio();
widget = checkbox.checkboxradio( "widget" );
strictEqual( checkbox.checkboxradio( "option", "label" ),
assert.strictEqual( checkbox.checkboxradio( "option", "label" ),
"checkbox label", "When no value passed on create text from dom is used for option" );
strictEqual( $.trim( widget.text() ),
assert.strictEqual( $.trim( widget.text() ),
"checkbox label", "When no value passed on create text from dom is used in dom" );
} );
test( "label - explicit value", function() {
expect( 5 );
QUnit.test( "label - explicit value", function( assert ) {
assert.expect( 5 );
var checkbox = $( "#checkbox-option-label" ).checkboxradio( {
label: "foo"
} ),
@ -149,23 +150,23 @@ test( "label - explicit value", function() {
icon = widget.find( ".ui-icon" ),
iconSpace = widget.find( ".ui-checkboxradio-icon-space" );
strictEqual( checkbox.checkboxradio( "option", "label" ),
assert.strictEqual( checkbox.checkboxradio( "option", "label" ),
"foo", "When value is passed on create value is used for option" );
strictEqual( $.trim( widget.text() ),
assert.strictEqual( $.trim( widget.text() ),
"foo", "When value is passed on create value is used in dom" );
strictEqual( icon.length, 1,
assert.strictEqual( icon.length, 1,
"Icon is preserved when label is set on init when wrapped in label" );
strictEqual( iconSpace.length, 1,
assert.strictEqual( iconSpace.length, 1,
"Icon space is preserved when label is set on init when wrapped in label" );
strictEqual( $( "#checkbox-option-label" ).length, 1,
assert.strictEqual( $( "#checkbox-option-label" ).length, 1,
"Element is preserved when label is set on init when wrapped in label" );
} );
test( "label - explicit null value", function() {
QUnit.test( "label - explicit null value", function( assert ) {
var checkbox = $( "#checkbox-option-label" ),
widget;
expect( 2 );
assert.expect( 2 );
// The default null is a special value which means to check the DOM.
// We need to make sure that the option never return null.
@ -174,15 +175,15 @@ test( "label - explicit null value", function() {
label: null
} );
widget = checkbox.checkboxradio( "widget" );
strictEqual( checkbox.checkboxradio( "option", "label" ),
assert.strictEqual( checkbox.checkboxradio( "option", "label" ),
"checkbox label", "When null is passed on create text from dom is used for option" );
strictEqual( $.trim( widget.text() ),
assert.strictEqual( $.trim( widget.text() ),
"checkbox label", "When null is passed on create text from dom is used in dom" );
} );
test( "label", function() {
expect( 4 );
QUnit.test( "label", function( assert ) {
assert.expect( 4 );
var checkbox = $( "#checkbox-option-label" ),
widget;
@ -190,15 +191,15 @@ test( "label", function() {
checkbox.checkboxradio();
widget = checkbox.checkboxradio( "widget" );
checkbox.checkboxradio( "option", "label", "bar" );
strictEqual( checkbox.checkboxradio( "option", "label" ),
assert.strictEqual( checkbox.checkboxradio( "option", "label" ),
"bar", "When value is passed value is used for option" );
strictEqual( $.trim( widget.text() ),
assert.strictEqual( $.trim( widget.text() ),
"bar", "When value is passed value is used in dom" );
checkbox.checkboxradio( "option", "label", null );
strictEqual( checkbox.checkboxradio( "option", "label" ),
assert.strictEqual( checkbox.checkboxradio( "option", "label" ),
"bar", "When null is passed text from dom is used for option" );
strictEqual( $.trim( widget.text() ),
assert.strictEqual( $.trim( widget.text() ),
"bar", "When null is passed text from dom is used in dom" );
} );

View File

@ -3,7 +3,8 @@ define( [
"ui/widgets/controlgroup",
"ui/widgets/checkboxradio",
"ui/widgets/selectmenu",
"ui/widgets/button"
"ui/widgets/button",
"ui/widgets/spinner"
], function( common ) {
common.testWidget( "controlgroup", {

View File

@ -36,6 +36,54 @@
<option>Slow</option>
</select>
</div>
<select id="select-sanatize">
<option>Fast</option>
<option>Medium</option>
<option>Slow</option>
</select>
<div class="controlgroup-pre">
<select id="select-pre">
<option>Fast</option>
<option>Medium</option>
<option>Slow</option>
</select>
<button>Button with icon on the bottom</button>
</div>
<div class="controlgroup-refresh">
<select id="select-refresh">
<option>Fast</option>
<option>Medium</option>
<option>Slow</option>
</select>
<label class="ui-controlgroup-label">Label</label>
<button>Button with icon on the bottom</button>
</div>
<div class="controlgroup-single-select">
<select id="select-single">
<option>Fast</option>
<option>Medium</option>
<option>Slow</option>
</select>
</div>
<div class="controlgroup-single-button">
<button class="single-button">button</button>
</div>
<div class="controlgroup-class-key-init">
<select id="class-key-init-child">
<option>Option 1</option>
<option>Option 2</option>
</select>
</div>
<div class="controlgroup-class-key-dupe">
<select id="class-key-dupe-first">
<option>Option 1</option>
<option>Option 2</option>
</select>
<select id="class-key-dupe-second">
<option>Option 1</option>
<option>Option 2</option>
</select>
</div>
</div>
</body>
</html>

View File

@ -1,15 +1,17 @@
define( [
"qunit",
"jquery",
"ui/widgets/controlgroup",
"ui/widgets/checkboxradio",
"ui/widgets/selectmenu",
"ui/widgets/button"
], function( $ ) {
"ui/widgets/button",
"ui/widgets/spinner"
], function( QUnit, $ ) {
module( "Controlgroup: Core" );
QUnit.module( "Controlgroup: Core" );
test( "selectmenu: open/close corners", function( assert ) {
expect( 12 );
QUnit.test( "selectmenu: open/close corners", function( assert ) {
assert.expect( 12 );
var element = $( ".controlgroup" ).controlgroup(),
selects = element.find( "select" ),
selectButton = selects.eq( 0 ).selectmenu( "widget" );
@ -64,8 +66,8 @@ test( "selectmenu: open/close corners", function( assert ) {
"vertical: Last selectmenu gets ui-corner-bottom when closed" );
} );
test( "selectmenu: controlgroupLabel", function( assert ) {
expect( 2 );
QUnit.test( "selectmenu: controlgroupLabel", function( assert ) {
assert.expect( 2 );
var element = $( ".controlgroup" ).controlgroup();
var label = element.find( ".ui-controlgroup-label" );
@ -73,4 +75,126 @@ test( "selectmenu: controlgroupLabel", function( assert ) {
assert.hasClasses( label.find( "span" ), "ui-controlgroup-label-contents" );
} );
var assertSanatized = function( assert, initClasses, expectedClasses, message ) {
var selectmenu = $( "#select-sanatize" ).selectmenu( {
classes: {
"ui-selectmenu-button-open": initClasses
}
} ).selectmenu( "instance" );
var classes = {
"ui-selectmenu-button-open": "ui-corner-top"
};
var result = $.ui.controlgroup.prototype._resolveClassesValues( classes, selectmenu );
assert.deepEqual( result, {
"ui-selectmenu-button-open": expectedClasses + " ui-corner-top"
}, message );
};
QUnit.test( "_resolveClassesValues", function( assert ) {
assert.expect( 6 );
assertSanatized( assert, "bar ui-corner-bottom", "bar", "Single corner class removed end" );
assertSanatized( assert, "ui-corner-bottom bar", "bar", "Single corner class removed beginning" );
assertSanatized( assert, "bar ui-corner-bottom ui-corner-left", "bar", "Multiple corner classes removed end" );
assertSanatized( assert, "ui-corner-bottom ui-corner-left bar", "bar", "Multiple corner classes removed beginning" );
assertSanatized( assert, "bar ui-corner-bottom ui-corner-left foo", "bar foo", "Multiple corner class removed middle" );
assertSanatized( assert, "bar", "bar", "No corner classes" );
} );
QUnit.test( "Single controlgroup select - horizontal", function( assert ) {
assert.expect( 4 );
var group = $( ".controlgroup-single-select" ).controlgroup();
var select = group.find( ".ui-selectmenu-button" );
assert.hasClasses( select, "ui-corner-all" );
assert.lacksClasses( select,
"ui-corner-left ui-corner-right ui-corner-top ui-corner-left" +
" ui-corner-tr ui-corner-tl ui-corner-bl ui corner-br" );
group.find( "select" ).selectmenu( "open" );
assert.hasClasses( select, "ui-corner-top" );
assert.lacksClasses( select,
"ui-corner-left ui-corner-right ui-corner-all ui-corner-left" +
" ui-corner-tr ui-corner-tl ui-corner-bl ui corner-br" );
} );
QUnit.test( "Single controlgroup select - vertical", function( assert ) {
assert.expect( 4 );
var group = $( ".controlgroup-single-select" ).controlgroup( {
direction: "verticle"
} );
var select = group.find( ".ui-selectmenu-button" );
assert.hasClasses( select, "ui-corner-all" );
assert.lacksClasses( select,
"ui-corner-left ui-corner-right ui-corner-top ui-corner-left" +
" ui-corner-tr ui-corner-tl ui-corner-bl ui corner-br" );
group.find( "select" ).selectmenu( "open" );
assert.hasClasses( select, "ui-corner-top" );
assert.lacksClasses( select,
"ui-corner-left ui-corner-right ui-corner-all ui-corner-left" +
" ui-corner-tr ui-corner-tl ui-corner-bl ui corner-br" );
} );
QUnit.test( "Single controlgroup button - horizontal", function( assert ) {
assert.expect( 2 );
var group = $( ".controlgroup-single-button" ).controlgroup();
var button = group.find( "button" );
assert.hasClasses( button, "ui-corner-all" );
assert.lacksClasses( button,
"ui-corner-left ui-corner-right ui-corner-top ui-corner-left" +
" ui-corner-tr ui-corner-tl ui-corner-bl ui corner-br" );
} );
QUnit.test( "Single controlgroup button - vertical", function( assert ) {
assert.expect( 2 );
var group = $( ".controlgroup-single-button" ).controlgroup( {
direction: "verticle"
} );
var button = group.find( "button" );
assert.hasClasses( button, "ui-corner-all" );
assert.lacksClasses( button,
"ui-corner-left ui-corner-right ui-corner-top ui-corner-left" +
" ui-corner-tr ui-corner-tl ui-corner-bl ui corner-br" );
} );
QUnit.module( "Controlgroup: Non-empty class key", {
setup: function() {
this.classKey = $.ui.selectmenu.prototype.options.classes[ "ui-selectmenu-button-closed" ];
$.ui.selectmenu.prototype.options.classes[ "ui-selectmenu-button-closed" ] =
"something-custom";
},
teardown: function() {
$.ui.selectmenu.prototype.options.classes[ "ui-selectmenu-button-closed" ] = this.classKey;
}
} );
QUnit.test( "Controlgroup instantiates child widgets with correct options", function( assert ) {
assert.expect( 1 );
$( ".controlgroup-class-key-init" ).controlgroup();
assert.hasClasses( $( "#class-key-init-child" ).next(), "something-custom" );
} );
QUnit.test( "Controlgroup correctly assigns child widget classes options key", function( assert ) {
assert.expect( 2 );
$( ".controlgroup-class-key-dupe" ).controlgroup();
assert.strictEqual(
( $( "#class-key-dupe-first" )
.selectmenu( "option", "classes.ui-selectmenu-button-closed" )
.match( /something-custom/g ) || [] ).length, 1,
"Class 'something-custom' appears exactly once in the first widget's class key value" );
assert.strictEqual(
( $( "#class-key-dupe-second" )
.selectmenu( "option", "classes.ui-selectmenu-button-closed" )
.match( /something-custom/g ) || [] ).length, 1,
"Class 'something-custom' appears exactly once in the second widget's class key value" );
} );
} );

View File

@ -1,42 +1,46 @@
define( [
"qunit",
"jquery",
"ui/widgets/controlgroup",
"ui/widgets/checkboxradio",
"ui/widgets/selectmenu",
"ui/widgets/button"
], function( $ ) {
"ui/widgets/button",
"ui/widgets/spinner"
], function( QUnit, $ ) {
module( "Controlgroup: methods" );
QUnit.module( "Controlgroup: methods" );
test( "destroy", function( assert ) {
expect( 1 );
QUnit.test( "destroy", function( assert ) {
assert.expect( 1 );
assert.domEqual( ".controlgroup", function() {
$( ".controlgroup" ).controlgroup().controlgroup( "destroy" );
$( "#spinner" ).addClass( "ui-spinner-input" );
} );
} );
test( "disable", function( assert ) {
expect( 2 );
QUnit.test( "disable", function( assert ) {
assert.expect( 2 );
var element = $( ".controlgroup" ).controlgroup().controlgroup( "disable" );
assert.lacksClasses( element, "ui-state-disabled",
"The widget does not get the disabled class, because we disable each child widget" );
strictEqual( element.find( ".ui-state-disabled" ).length, 6,
assert.strictEqual( element.find( ".ui-state-disabled" ).length, 9,
"Child widgets are disabled" );
} );
test( "enable", function( assert ) {
expect( 2 );
QUnit.test( "enable", function( assert ) {
assert.expect( 2 );
var element = $( ".controlgroup" ).controlgroup().controlgroup( "enable" );
assert.lacksClasses( element, "ui-state-disabled",
"ui-state-disabled is not present on widget after enabling" );
strictEqual( element.find( "ui-state-disabled" ).length, 0,
assert.strictEqual( element.find( "ui-state-disabled" ).length, 0,
"Child widgets are disabled" );
} );
var tests = {
"checkboxradio": "<input type='checkbox'>",
"selectmenu": "<select><option>foo</option></select>",
"button": "<button>button text</button>"
"button": "<button>button text</button>",
"spinner": "<input class='ui-spinner-input'>"
},
orientations = {
"horizontal": [
@ -59,16 +63,16 @@ $.each( tests, function( widget, html ) {
// Check in both horizontal and vertical orientations
$.each( orientations, function( name, classes ) {
test( "refresh: " + widget + ": " + name, function( assert ) {
expect( 41 );
QUnit.test( "refresh: " + widget + ": " + name, function( assert ) {
assert.expect( 41 );
var i, control, currentClasses,
var i, control, label, currentClasses,
controls = [],
element = $( "<div>" ).controlgroup( {
direction: name
} ).appendTo( "body" );
// checks the elements with in the controlgroup against the expected class list
// Checks the elements with in the controlgroup against the expected class list
function checkCornerClasses( classList ) {
for ( var j = 0; j < 4; j++ ) {
if ( classList[ j ] ) {
@ -108,24 +112,24 @@ $.each( tests, function( widget, html ) {
// Add a label for each element and then append the element to the control group
for ( i = 0; i < 4; i++ ) {
control = $( html ).attr( "id", "id" + i )
.add( $( "<label>label text</label>" ).clone().attr( "for", "id" + i ) );
control = $( html ).attr( "id", "id" + i );
label = $( "<label>label text</label>" ).attr( "for", "id" + i );
controls.push( control );
element.append( control );
element.append( control, label );
}
// Refresh the controlgroup now that its populated
element.controlgroup( "refresh" );
for ( i = 0; i < 4; i++ ) {
strictEqual( controls[ i ].is( ":ui-" + widget ), true,
assert.strictEqual( controls[ i ].is( ":ui-" + widget ), true,
name + ": " + widget + " " + i + ": is a " + widget + " widget" );
}
// Check that we have the right classes
checkCornerClasses( classes );
// hide each element and then check its classes
// Hide each element and then check its classes
iterateHidden( true );
// Set the exclude option to false so we no longer care about hidden
@ -135,16 +139,50 @@ $.each( tests, function( widget, html ) {
iterateHidden();
// Disable the first control
if ( widget === "spinner" ) {
controls[ 0 ].spinner( "disable" );
}
controls[ 0 ].prop( "disabled", true );
element.controlgroup( "refresh" );
assert.hasClasses( controls[ 0 ][ widget ]( "widget" ), "ui-state-disabled" );
// remove the controlgroup before we start the next set
// Remove the controlgroup before we start the next set
element.remove();
} );
} );
} );
QUnit.test( "Child Classes Option: init", function( assert ) {
assert.expect( 1 );
var selectmenu = $( "#select-pre" ).selectmenu( {
classes: {
"ui-selectmenu-button-closed": "test-class"
}
} );
$( ".controlgroup-pre" ).controlgroup();
assert.hasClasses( selectmenu.selectmenu( "widget" ), "test-class" );
} );
QUnit.test( "Child Classes Option: refresh", function( assert ) {
assert.expect( 1 );
var controlgroup = $( ".controlgroup-refresh" ).controlgroup();
var selectmenu = $( "#select-refresh" ).selectmenu( {
classes: {
"ui-selectmenu-button-closed": "test-class"
}
} );
controlgroup.controlgroup( "refresh" );
assert.hasClasses( selectmenu.selectmenu( "widget" ), "test-class" );
} );
QUnit.test( "Controlgroup Label: refresh", function( assert ) {
assert.expect( 1 );
var controlgroup = $( ".controlgroup-refresh" ).controlgroup();
controlgroup.controlgroup( "refresh" );
assert.strictEqual( controlgroup.find( ".ui-controlgroup-label-contents" ).length, 1,
"Controlgroup label does not re-wrap on refresh" );
} );
} );

View File

@ -1,27 +1,29 @@
define( [
"qunit",
"jquery",
"ui/widgets/controlgroup",
"ui/widgets/checkboxradio",
"ui/widgets/selectmenu",
"ui/widgets/button"
], function( $ ) {
"ui/widgets/button",
"ui/widgets/spinner"
], function( QUnit, $ ) {
module( "Controlgroup: options" );
QUnit.module( "Controlgroup: options" );
test( "disabled", function( assert ) {
expect( 4 );
QUnit.test( "disabled", function( assert ) {
assert.expect( 4 );
var element = $( ".controlgroup" ).controlgroup().controlgroup( "option", "disabled", true );
assert.lacksClasses( element, "ui-state-disabled" );
equal( element.find( ".ui-state-disabled" ).length, 6, "Child widgets are disabled" );
assert.equal( element.find( ".ui-state-disabled" ).length, 9, "Child widgets are disabled" );
element.controlgroup( "option", "disabled", false );
assert.lacksClasses( element, "ui-state-disabled" );
strictEqual( element.find( ".ui-state-disabled" ).length, 0, "Child widgets are not disabled" );
assert.strictEqual( element.find( ".ui-state-disabled" ).length, 0, "Child widgets are not disabled" );
} );
test( "items - null", function() {
expect( 2 );
QUnit.test( "items - null", function( assert ) {
assert.expect( 2 );
var element = $( ".controlgroup" ).controlgroup( {
items: {
"button": null,
@ -30,24 +32,24 @@ test( "items - null", function() {
}
} );
strictEqual( element.children( ".ui-button" ).length, 0,
assert.strictEqual( element.children( ".ui-button" ).length, 0,
"Child widgets are not called when selector is null" );
element.controlgroup( "option", "items", {
"button": "button"
} );
strictEqual( element.children( ".ui-button" ).length, 2,
assert.strictEqual( element.children( ".ui-button" ).length, 2,
"Correct child widgets are called when selector is updated" );
} );
test( "items: custom selector", function() {
expect( 1 );
QUnit.test( "items: custom selector", function( assert ) {
assert.expect( 1 );
var element = $( ".controlgroup" ).controlgroup( {
items: {
"button": ".button"
}
} );
strictEqual( element.children( ".ui-button" ).length, 4,
assert.strictEqual( element.children( ".ui-button" ).length, 4,
"Correct child widgets are called when custom selector used" );
} );
@ -60,22 +62,22 @@ $.widget( "ui.test", {
refresh: $.noop
} );
test( "items: custom widget", function() {
expect( 2 );
QUnit.test( "items: custom widget", function( assert ) {
assert.expect( 2 );
var element = $( ".controlgroup" ).controlgroup( {
items: {
"test": ".test"
}
} );
strictEqual( element.children( ".ui-button" ).length, 7,
assert.strictEqual( element.children( ".ui-button" ).length, 7,
"Correct child widgets are called when custom selector used" );
strictEqual( element.children( ".ui-test" ).length, 1,
assert.strictEqual( element.children( ".ui-test" ).length, 1,
"Custom widget called" );
} );
test( "onlyVisible", function( assert ) {
expect( 4 );
QUnit.test( "onlyVisible", function( assert ) {
assert.expect( 4 );
var element = $( ".controlgroup" ).controlgroup( {
onlyVisible: false
} ),
@ -91,8 +93,8 @@ test( "onlyVisible", function( assert ) {
"onlyVisible: true: First button is hidden second button get corner class" );
} );
test( "direction", function( assert ) {
expect( 6 );
QUnit.test( "direction", function( assert ) {
assert.expect( 6 );
var element = $( ".controlgroup" ).controlgroup(),
buttons = element.children( ".ui-button" ).filter( ":visible" );

View File

@ -38,6 +38,15 @@
<input>
</form>
<form>
<fieldset id="enabledFieldset">
<input>
</fieldset>
<fieldset id="disabledFieldset" disabled="disabled">
<input>
</fieldset>
</form>
<div>
<input id="visibleAncestor-inputTypeNone">
<input type="text" id="visibleAncestor-inputTypeText">

View File

@ -1,147 +1,148 @@
define( [
"qunit",
"jquery",
"lib/common",
"ui/form",
"ui/labels",
"ui/unique-id"
], function( $, common ) {
], function( QUnit, $, common ) {
module( "core - jQuery extensions" );
QUnit.module( "core - jQuery extensions" );
common.testJshint( "core" );
test( "innerWidth - getter", function() {
expect( 2 );
QUnit.test( "innerWidth - getter", function( assert ) {
assert.expect( 2 );
var el = $( "#dimensions" );
equal( el.innerWidth(), 122, "getter passthru" );
assert.equal( el.innerWidth(), 122, "getter passthru" );
el.hide();
equal( el.innerWidth(), 122, "getter passthru when hidden" );
assert.equal( el.innerWidth(), 122, "getter passthru when hidden" );
} );
test( "innerWidth - setter", function() {
expect( 2 );
QUnit.test( "innerWidth - setter", function( assert ) {
assert.expect( 2 );
var el = $( "#dimensions" );
el.innerWidth( 120 );
equal( el.width(), 98, "width set properly" );
assert.equal( el.width(), 98, "width set properly" );
el.hide();
el.innerWidth( 100 );
equal( el.width(), 78, "width set properly when hidden" );
assert.equal( el.width(), 78, "width set properly when hidden" );
} );
test( "innerHeight - getter", function() {
expect( 2 );
QUnit.test( "innerHeight - getter", function( assert ) {
assert.expect( 2 );
var el = $( "#dimensions" );
equal( el.innerHeight(), 70, "getter passthru" );
assert.equal( el.innerHeight(), 70, "getter passthru" );
el.hide();
equal( el.innerHeight(), 70, "getter passthru when hidden" );
assert.equal( el.innerHeight(), 70, "getter passthru when hidden" );
} );
test( "innerHeight - setter", function() {
expect( 2 );
QUnit.test( "innerHeight - setter", function( assert ) {
assert.expect( 2 );
var el = $( "#dimensions" );
el.innerHeight( 60 );
equal( el.height(), 40, "height set properly" );
assert.equal( el.height(), 40, "height set properly" );
el.hide();
el.innerHeight( 50 );
equal( el.height(), 30, "height set properly when hidden" );
assert.equal( el.height(), 30, "height set properly when hidden" );
} );
test( "outerWidth - getter", function() {
expect( 2 );
QUnit.test( "outerWidth - getter", function( assert ) {
assert.expect( 2 );
var el = $( "#dimensions" );
equal( el.outerWidth(), 140, "getter passthru" );
assert.equal( el.outerWidth(), 140, "getter passthru" );
el.hide();
equal( el.outerWidth(), 140, "getter passthru when hidden" );
assert.equal( el.outerWidth(), 140, "getter passthru when hidden" );
} );
test( "outerWidth - setter", function() {
expect( 2 );
QUnit.test( "outerWidth - setter", function( assert ) {
assert.expect( 2 );
var el = $( "#dimensions" );
el.outerWidth( 130 );
equal( el.width(), 90, "width set properly" );
assert.equal( el.width(), 90, "width set properly" );
el.hide();
el.outerWidth( 120 );
equal( el.width(), 80, "width set properly when hidden" );
assert.equal( el.width(), 80, "width set properly when hidden" );
} );
test( "outerWidth(true) - getter", function() {
expect( 2 );
QUnit.test( "outerWidth(true) - getter", function( assert ) {
assert.expect( 2 );
var el = $( "#dimensions" );
equal( el.outerWidth( true ), 154, "getter passthru w/ margin" );
assert.equal( el.outerWidth( true ), 154, "getter passthru w/ margin" );
el.hide();
equal( el.outerWidth( true ), 154, "getter passthru w/ margin when hidden" );
assert.equal( el.outerWidth( true ), 154, "getter passthru w/ margin when hidden" );
} );
test( "outerWidth(true) - setter", function() {
expect( 2 );
QUnit.test( "outerWidth(true) - setter", function( assert ) {
assert.expect( 2 );
var el = $( "#dimensions" );
el.outerWidth( 130, true );
equal( el.width(), 76, "width set properly" );
assert.equal( el.width(), 76, "width set properly" );
el.hide();
el.outerWidth( 120, true );
equal( el.width(), 66, "width set properly when hidden" );
assert.equal( el.width(), 66, "width set properly when hidden" );
} );
test( "outerHeight - getter", function() {
expect( 2 );
QUnit.test( "outerHeight - getter", function( assert ) {
assert.expect( 2 );
var el = $( "#dimensions" );
equal( el.outerHeight(), 86, "getter passthru" );
assert.equal( el.outerHeight(), 86, "getter passthru" );
el.hide();
equal( el.outerHeight(), 86, "getter passthru when hidden" );
assert.equal( el.outerHeight(), 86, "getter passthru when hidden" );
} );
test( "outerHeight - setter", function() {
expect( 2 );
QUnit.test( "outerHeight - setter", function( assert ) {
assert.expect( 2 );
var el = $( "#dimensions" );
el.outerHeight( 80 );
equal( el.height(), 44, "height set properly" );
assert.equal( el.height(), 44, "height set properly" );
el.hide();
el.outerHeight( 70 );
equal( el.height(), 34, "height set properly when hidden" );
assert.equal( el.height(), 34, "height set properly when hidden" );
} );
test( "outerHeight(true) - getter", function() {
expect( 2 );
QUnit.test( "outerHeight(true) - getter", function( assert ) {
assert.expect( 2 );
var el = $( "#dimensions" );
equal( el.outerHeight( true ), 98, "getter passthru w/ margin" );
assert.equal( el.outerHeight( true ), 98, "getter passthru w/ margin" );
el.hide();
equal( el.outerHeight( true ), 98, "getter passthru w/ margin when hidden" );
assert.equal( el.outerHeight( true ), 98, "getter passthru w/ margin when hidden" );
} );
test( "outerHeight(true) - setter", function() {
expect( 2 );
QUnit.test( "outerHeight(true) - setter", function( assert ) {
assert.expect( 2 );
var el = $( "#dimensions" );
el.outerHeight( 90, true );
equal( el.height(), 42, "height set properly" );
assert.equal( el.height(), 42, "height set properly" );
el.hide();
el.outerHeight( 80, true );
equal( el.height(), 32, "height set properly when hidden" );
assert.equal( el.height(), 32, "height set properly when hidden" );
} );
test( "uniqueId / removeUniqueId", function() {
expect( 3 );
QUnit.test( "uniqueId / removeUniqueId", function( assert ) {
assert.expect( 3 );
var el = $( "img" ).eq( 0 );
equal( el.attr( "id" ), null, "element has no initial id" );
assert.equal( el.attr( "id" ), null, "element has no initial id" );
el.uniqueId();
ok( /ui-id-\d+$/.test( el.attr( "id" ) ), "element has generated id" );
assert.ok( /ui-id-\d+$/.test( el.attr( "id" ) ), "element has generated id" );
el.removeUniqueId();
equal( el.attr( "id" ), null, "unique id has been removed from element" );
assert.equal( el.attr( "id" ), null, "unique id has been removed from element" );
} );
test( "Labels", function() {
expect( 2 );
QUnit.test( "Labels", function( assert ) {
assert.expect( 2 );
var expected = [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" ];
var dom = $( "#labels-fragment" );
@ -155,7 +156,7 @@ test( "Labels", function() {
return $.trim( $( this ).text() );
} ).get();
deepEqual( found, expected,
assert.deepEqual( found, expected,
".labels() finds all labels in " + testType + ", and sorts them in DOM order" );
}
@ -176,9 +177,10 @@ test( "Labels", function() {
inputs.each( function() {
var input = $( this );
asyncTest( name + this.id.replace( /_/g, " " ), function() {
expect( 1 );
var form = input.form();
QUnit.test( name + this.id.replace( /_/g, " " ), function( assert ) {
var ready = assert.async();
assert.expect( 1 );
var form = input._form();
// If input has a form the value should reset to "" if not it should be "changed"
var value = form.length ? "" : "changed";
@ -193,8 +195,8 @@ test( "Labels", function() {
} );
setTimeout( function() {
equal( input.val(), value, "Proper form found for #" + input.attr( "id" ) );
start();
assert.equal( input.val(), value, "Proper form found for #" + input.attr( "id" ) );
ready();
} );
} );
} );

View File

@ -1,44 +1,45 @@
define( [
"qunit",
"jquery",
"ui/data",
"ui/escape-selector",
"ui/focusable",
"ui/tabbable"
], function( $ ) {
], function( QUnit, $ ) {
module( "core - selectors" );
QUnit.module( "core - selectors" );
function isFocusable( selector, msg ) {
QUnit.push( $( selector ).is( ":focusable" ), null, null,
QUnit.assert.isFocusable = function( selector, msg ) {
this.push( $( selector ).is( ":focusable" ), null, null,
msg + " - selector " + selector + " is focusable" );
}
};
function isNotFocusable( selector, msg ) {
QUnit.push( $( selector ).length && !$( selector ).is( ":focusable" ), null, null,
QUnit.assert.isNotFocusable = function( selector, msg ) {
this.push( $( selector ).length && !$( selector ).is( ":focusable" ), null, null,
msg + " - selector " + selector + " is not focusable" );
}
};
function isTabbable( selector, msg ) {
QUnit.push( $( selector ).is( ":tabbable" ), null, null,
QUnit.assert.isTabbable = function( selector, msg ) {
this.push( $( selector ).is( ":tabbable" ), null, null,
msg + " - selector " + selector + " is tabbable" );
}
};
function isNotTabbable( selector, msg ) {
QUnit.push( $( selector ).length && !$( selector ).is( ":tabbable" ), null, null,
QUnit.assert.isNotTabbable = function( selector, msg ) {
this.push( $( selector ).length && !$( selector ).is( ":tabbable" ), null, null,
msg + " - selector " + selector + " is not tabbable" );
}
};
test( "data", function() {
expect( 15 );
QUnit.test( "data", function( assert ) {
assert.expect( 15 );
var element;
function shouldHaveData( msg ) {
ok( element.is( ":data(test)" ), msg );
assert.ok( element.is( ":data(test)" ), msg );
}
function shouldNotHaveData( msg ) {
ok( !element.is( ":data(test)" ), msg );
assert.ok( !element.is( ":data(test)" ), msg );
}
element = $( "<div>" );
@ -87,193 +88,197 @@ test( "data", function() {
shouldHaveData( "data set to function" );
} );
test( "focusable - visible, enabled elements", function() {
expect( 20 );
QUnit.test( "focusable - visible, enabled elements", function( assert ) {
assert.expect( 22 );
isNotFocusable( "#formNoTabindex", "form" );
isFocusable( "#formTabindex", "form with tabindex" );
isFocusable( "#visibleAncestor-inputTypeNone", "input, no type" );
isFocusable( "#visibleAncestor-inputTypeText", "input, type text" );
isFocusable( "#visibleAncestor-inputTypeCheckbox", "input, type checkbox" );
isFocusable( "#visibleAncestor-inputTypeRadio", "input, type radio" );
isFocusable( "#visibleAncestor-inputTypeButton", "input, type button" );
isNotFocusable( "#visibleAncestor-inputTypeHidden", "input, type hidden" );
isFocusable( "#visibleAncestor-button", "button" );
isFocusable( "#visibleAncestor-select", "select" );
isFocusable( "#visibleAncestor-textarea", "textarea" );
isFocusable( "#visibleAncestor-object", "object" );
isFocusable( "#visibleAncestor-anchorWithHref", "anchor with href" );
isNotFocusable( "#visibleAncestor-anchorWithoutHref", "anchor without href" );
isNotFocusable( "#visibleAncestor-span", "span" );
isNotFocusable( "#visibleAncestor-div", "div" );
isFocusable( "#visibleAncestor-spanWithTabindex", "span with tabindex" );
isFocusable( "#visibleAncestor-divWithNegativeTabindex", "div with tabindex" );
isFocusable( "#nestedVisibilityInheritWithVisibleAncestor",
assert.isNotFocusable( "#formNoTabindex", "form" );
assert.isFocusable( "#formTabindex", "form with tabindex" );
assert.isFocusable( "#enabledFieldset input", "input in enabled fieldset" );
assert.isNotFocusable( "#disabledFieldset input", "input in disabled fieldset" );
assert.isFocusable( "#visibleAncestor-inputTypeNone", "input, no type" );
assert.isFocusable( "#visibleAncestor-inputTypeText", "input, type text" );
assert.isFocusable( "#visibleAncestor-inputTypeCheckbox", "input, type checkbox" );
assert.isFocusable( "#visibleAncestor-inputTypeRadio", "input, type radio" );
assert.isFocusable( "#visibleAncestor-inputTypeButton", "input, type button" );
assert.isNotFocusable( "#visibleAncestor-inputTypeHidden", "input, type hidden" );
assert.isFocusable( "#visibleAncestor-button", "button" );
assert.isFocusable( "#visibleAncestor-select", "select" );
assert.isFocusable( "#visibleAncestor-textarea", "textarea" );
assert.isFocusable( "#visibleAncestor-object", "object" );
assert.isFocusable( "#visibleAncestor-anchorWithHref", "anchor with href" );
assert.isNotFocusable( "#visibleAncestor-anchorWithoutHref", "anchor without href" );
assert.isNotFocusable( "#visibleAncestor-span", "span" );
assert.isNotFocusable( "#visibleAncestor-div", "div" );
assert.isFocusable( "#visibleAncestor-spanWithTabindex", "span with tabindex" );
assert.isFocusable( "#visibleAncestor-divWithNegativeTabindex", "div with tabindex" );
assert.isFocusable( "#nestedVisibilityInheritWithVisibleAncestor",
"span, visibility: inherit inside visibility: visible parent" );
isFocusable( "#nestedVisibilityInheritWithVisibleAncestor-input",
assert.isFocusable( "#nestedVisibilityInheritWithVisibleAncestor-input",
"input, visibility: inherit inside visibility: visible parent" );
} );
test( "focusable - disabled elements", function() {
expect( 9 );
QUnit.test( "focusable - disabled elements", function( assert ) {
assert.expect( 9 );
isNotFocusable( "#disabledElement-inputTypeNone", "input, no type" );
isNotFocusable( "#disabledElement-inputTypeText", "input, type text" );
isNotFocusable( "#disabledElement-inputTypeCheckbox", "input, type checkbox" );
isNotFocusable( "#disabledElement-inputTypeRadio", "input, type radio" );
isNotFocusable( "#disabledElement-inputTypeButton", "input, type button" );
isNotFocusable( "#disabledElement-inputTypeHidden", "input, type hidden" );
isNotFocusable( "#disabledElement-button", "button" );
isNotFocusable( "#disabledElement-select", "select" );
isNotFocusable( "#disabledElement-textarea", "textarea" );
assert.isNotFocusable( "#disabledElement-inputTypeNone", "input, no type" );
assert.isNotFocusable( "#disabledElement-inputTypeText", "input, type text" );
assert.isNotFocusable( "#disabledElement-inputTypeCheckbox", "input, type checkbox" );
assert.isNotFocusable( "#disabledElement-inputTypeRadio", "input, type radio" );
assert.isNotFocusable( "#disabledElement-inputTypeButton", "input, type button" );
assert.isNotFocusable( "#disabledElement-inputTypeHidden", "input, type hidden" );
assert.isNotFocusable( "#disabledElement-button", "button" );
assert.isNotFocusable( "#disabledElement-select", "select" );
assert.isNotFocusable( "#disabledElement-textarea", "textarea" );
} );
test( "focusable - hidden styles", function() {
expect( 12 );
QUnit.test( "focusable - hidden styles", function( assert ) {
assert.expect( 12 );
isNotFocusable( "#displayNoneAncestor-input", "input, display: none parent" );
isNotFocusable( "#displayNoneAncestor-span", "span with tabindex, display: none parent" );
assert.isNotFocusable( "#displayNoneAncestor-input", "input, display: none parent" );
assert.isNotFocusable( "#displayNoneAncestor-span", "span with tabindex, display: none parent" );
isNotFocusable( "#visibilityHiddenAncestor-input", "input, visibility: hidden parent" );
isNotFocusable( "#visibilityHiddenAncestor-span", "span with tabindex, visibility: hidden parent" );
assert.isNotFocusable( "#visibilityHiddenAncestor-input", "input, visibility: hidden parent" );
assert.isNotFocusable( "#visibilityHiddenAncestor-span", "span with tabindex, visibility: hidden parent" );
isFocusable( "#nestedVisibilityOverrideAncestor-input", "input, visibility: visible parent but visibility: hidden grandparent" );
isFocusable( "#nestedVisibilityOverrideAncestor-span", "span with tabindex, visibility: visible parent but visibility: hidden grandparent " );
assert.isFocusable( "#nestedVisibilityOverrideAncestor-input", "input, visibility: visible parent but visibility: hidden grandparent" );
assert.isFocusable( "#nestedVisibilityOverrideAncestor-span", "span with tabindex, visibility: visible parent but visibility: hidden grandparent " );
isNotFocusable( "#nestedVisibilityInheritWithHiddenAncestor", "span, visibility: inherit inside visibility: hidden parent" );
isNotFocusable( "#nestedVisibilityInheritWithHiddenAncestor-input", "input, visibility: inherit inside visibility: hidden parent" );
assert.isNotFocusable( "#nestedVisibilityInheritWithHiddenAncestor", "span, visibility: inherit inside visibility: hidden parent" );
assert.isNotFocusable( "#nestedVisibilityInheritWithHiddenAncestor-input", "input, visibility: inherit inside visibility: hidden parent" );
isNotFocusable( "#displayNone-input", "input, display: none" );
isNotFocusable( "#visibilityHidden-input", "input, visibility: hidden" );
assert.isNotFocusable( "#displayNone-input", "input, display: none" );
assert.isNotFocusable( "#visibilityHidden-input", "input, visibility: hidden" );
isNotFocusable( "#displayNone-span", "span with tabindex, display: none" );
isNotFocusable( "#visibilityHidden-span", "span with tabindex, visibility: hidden" );
assert.isNotFocusable( "#displayNone-span", "span with tabindex, display: none" );
assert.isNotFocusable( "#visibilityHidden-span", "span with tabindex, visibility: hidden" );
} );
test( "focusable - natively focusable with various tabindex", function() {
expect( 4 );
QUnit.test( "focusable - natively focusable with various tabindex", function( assert ) {
assert.expect( 4 );
isFocusable( "#inputTabindex0", "input, tabindex 0" );
isFocusable( "#inputTabindex10", "input, tabindex 10" );
isFocusable( "#inputTabindex-1", "input, tabindex -1" );
isFocusable( "#inputTabindex-50", "input, tabindex -50" );
assert.isFocusable( "#inputTabindex0", "input, tabindex 0" );
assert.isFocusable( "#inputTabindex10", "input, tabindex 10" );
assert.isFocusable( "#inputTabindex-1", "input, tabindex -1" );
assert.isFocusable( "#inputTabindex-50", "input, tabindex -50" );
} );
test( "focusable - not natively focusable with various tabindex", function() {
expect( 4 );
QUnit.test( "focusable - not natively focusable with various tabindex", function( assert ) {
assert.expect( 4 );
isFocusable( "#spanTabindex0", "span, tabindex 0" );
isFocusable( "#spanTabindex10", "span, tabindex 10" );
isFocusable( "#spanTabindex-1", "span, tabindex -1" );
isFocusable( "#spanTabindex-50", "span, tabindex -50" );
assert.isFocusable( "#spanTabindex0", "span, tabindex 0" );
assert.isFocusable( "#spanTabindex10", "span, tabindex 10" );
assert.isFocusable( "#spanTabindex-1", "span, tabindex -1" );
assert.isFocusable( "#spanTabindex-50", "span, tabindex -50" );
} );
test( "focusable - area elements", function() {
expect( 3 );
QUnit.test( "focusable - area elements", function( assert ) {
assert.expect( 3 );
isFocusable( "#areaCoordsHref", "coords and href" );
isFocusable( "#areaNoCoordsHref", "href but no coords" );
isNotFocusable( "#areaNoImg", "not associated with an image" );
assert.isFocusable( "#areaCoordsHref", "coords and href" );
assert.isFocusable( "#areaNoCoordsHref", "href but no coords" );
assert.isNotFocusable( "#areaNoImg", "not associated with an image" );
} );
test( "focusable - dimensionless parent with overflow", function() {
expect( 1 );
QUnit.test( "focusable - dimensionless parent with overflow", function( assert ) {
assert.expect( 1 );
isFocusable( "#dimensionlessParent", "input" );
assert.isFocusable( "#dimensionlessParent", "input" );
} );
test( "tabbable - visible, enabled elements", function() {
expect( 18 );
QUnit.test( "tabbable - visible, enabled elements", function( assert ) {
assert.expect( 20 );
isNotTabbable( "#formNoTabindex", "form" );
isTabbable( "#formTabindex", "form with tabindex" );
isTabbable( "#visibleAncestor-inputTypeNone", "input, no type" );
isTabbable( "#visibleAncestor-inputTypeText", "input, type text" );
isTabbable( "#visibleAncestor-inputTypeCheckbox", "input, type checkbox" );
isTabbable( "#visibleAncestor-inputTypeRadio", "input, type radio" );
isTabbable( "#visibleAncestor-inputTypeButton", "input, type button" );
isNotTabbable( "#visibleAncestor-inputTypeHidden", "input, type hidden" );
isTabbable( "#visibleAncestor-button", "button" );
isTabbable( "#visibleAncestor-select", "select" );
isTabbable( "#visibleAncestor-textarea", "textarea" );
isTabbable( "#visibleAncestor-object", "object" );
isTabbable( "#visibleAncestor-anchorWithHref", "anchor with href" );
isNotTabbable( "#visibleAncestor-anchorWithoutHref", "anchor without href" );
isNotTabbable( "#visibleAncestor-span", "span" );
isNotTabbable( "#visibleAncestor-div", "div" );
isTabbable( "#visibleAncestor-spanWithTabindex", "span with tabindex" );
isNotTabbable( "#visibleAncestor-divWithNegativeTabindex", "div with tabindex" );
assert.isNotTabbable( "#formNoTabindex", "form" );
assert.isTabbable( "#formTabindex", "form with tabindex" );
assert.isTabbable( "#enabledFieldset input", "input in enabled fieldset" );
assert.isNotTabbable( "#disabledFieldset input", "input in disabled fieldset" );
assert.isTabbable( "#visibleAncestor-inputTypeNone", "input, no type" );
assert.isTabbable( "#visibleAncestor-inputTypeText", "input, type text" );
assert.isTabbable( "#visibleAncestor-inputTypeCheckbox", "input, type checkbox" );
assert.isTabbable( "#visibleAncestor-inputTypeRadio", "input, type radio" );
assert.isTabbable( "#visibleAncestor-inputTypeButton", "input, type button" );
assert.isNotTabbable( "#visibleAncestor-inputTypeHidden", "input, type hidden" );
assert.isTabbable( "#visibleAncestor-button", "button" );
assert.isTabbable( "#visibleAncestor-select", "select" );
assert.isTabbable( "#visibleAncestor-textarea", "textarea" );
assert.isTabbable( "#visibleAncestor-object", "object" );
assert.isTabbable( "#visibleAncestor-anchorWithHref", "anchor with href" );
assert.isNotTabbable( "#visibleAncestor-anchorWithoutHref", "anchor without href" );
assert.isNotTabbable( "#visibleAncestor-span", "span" );
assert.isNotTabbable( "#visibleAncestor-div", "div" );
assert.isTabbable( "#visibleAncestor-spanWithTabindex", "span with tabindex" );
assert.isNotTabbable( "#visibleAncestor-divWithNegativeTabindex", "div with tabindex" );
} );
test( "tabbable - disabled elements", function() {
expect( 9 );
QUnit.test( "tabbable - disabled elements", function( assert ) {
assert.expect( 9 );
isNotTabbable( "#disabledElement-inputTypeNone", "input, no type" );
isNotTabbable( "#disabledElement-inputTypeText", "input, type text" );
isNotTabbable( "#disabledElement-inputTypeCheckbox", "input, type checkbox" );
isNotTabbable( "#disabledElement-inputTypeRadio", "input, type radio" );
isNotTabbable( "#disabledElement-inputTypeButton", "input, type button" );
isNotTabbable( "#disabledElement-inputTypeHidden", "input, type hidden" );
isNotTabbable( "#disabledElement-button", "button" );
isNotTabbable( "#disabledElement-select", "select" );
isNotTabbable( "#disabledElement-textarea", "textarea" );
assert.isNotTabbable( "#disabledElement-inputTypeNone", "input, no type" );
assert.isNotTabbable( "#disabledElement-inputTypeText", "input, type text" );
assert.isNotTabbable( "#disabledElement-inputTypeCheckbox", "input, type checkbox" );
assert.isNotTabbable( "#disabledElement-inputTypeRadio", "input, type radio" );
assert.isNotTabbable( "#disabledElement-inputTypeButton", "input, type button" );
assert.isNotTabbable( "#disabledElement-inputTypeHidden", "input, type hidden" );
assert.isNotTabbable( "#disabledElement-button", "button" );
assert.isNotTabbable( "#disabledElement-select", "select" );
assert.isNotTabbable( "#disabledElement-textarea", "textarea" );
} );
test( "tabbable - hidden styles", function() {
expect( 10 );
QUnit.test( "tabbable - hidden styles", function( assert ) {
assert.expect( 10 );
isNotTabbable( "#displayNoneAncestor-input", "input, display: none parent" );
isNotTabbable( "#displayNoneAncestor-span", "span with tabindex, display: none parent" );
assert.isNotTabbable( "#displayNoneAncestor-input", "input, display: none parent" );
assert.isNotTabbable( "#displayNoneAncestor-span", "span with tabindex, display: none parent" );
isNotTabbable( "#visibilityHiddenAncestor-input", "input, visibility: hidden parent" );
isNotTabbable( "#visibilityHiddenAncestor-span", "span with tabindex, visibility: hidden parent" );
assert.isNotTabbable( "#visibilityHiddenAncestor-input", "input, visibility: hidden parent" );
assert.isNotTabbable( "#visibilityHiddenAncestor-span", "span with tabindex, visibility: hidden parent" );
isTabbable( "#nestedVisibilityOverrideAncestor-input", "input, visibility: visible parent but visibility: hidden grandparent" );
isTabbable( "#nestedVisibilityOverrideAncestor-span", "span with tabindex, visibility: visible parent but visibility: hidden grandparent " );
assert.isTabbable( "#nestedVisibilityOverrideAncestor-input", "input, visibility: visible parent but visibility: hidden grandparent" );
assert.isTabbable( "#nestedVisibilityOverrideAncestor-span", "span with tabindex, visibility: visible parent but visibility: hidden grandparent " );
isNotTabbable( "#displayNone-input", "input, display: none" );
isNotTabbable( "#visibilityHidden-input", "input, visibility: hidden" );
assert.isNotTabbable( "#displayNone-input", "input, display: none" );
assert.isNotTabbable( "#visibilityHidden-input", "input, visibility: hidden" );
isNotTabbable( "#displayNone-span", "span with tabindex, display: none" );
isNotTabbable( "#visibilityHidden-span", "span with tabindex, visibility: hidden" );
assert.isNotTabbable( "#displayNone-span", "span with tabindex, display: none" );
assert.isNotTabbable( "#visibilityHidden-span", "span with tabindex, visibility: hidden" );
} );
test( "tabbable - natively tabbable with various tabindex", function() {
expect( 4 );
QUnit.test( "tabbable - natively tabbable with various tabindex", function( assert ) {
assert.expect( 4 );
isTabbable( "#inputTabindex0", "input, tabindex 0" );
isTabbable( "#inputTabindex10", "input, tabindex 10" );
isNotTabbable( "#inputTabindex-1", "input, tabindex -1" );
isNotTabbable( "#inputTabindex-50", "input, tabindex -50" );
assert.isTabbable( "#inputTabindex0", "input, tabindex 0" );
assert.isTabbable( "#inputTabindex10", "input, tabindex 10" );
assert.isNotTabbable( "#inputTabindex-1", "input, tabindex -1" );
assert.isNotTabbable( "#inputTabindex-50", "input, tabindex -50" );
} );
test( "tabbable - not natively tabbable with various tabindex", function() {
expect( 4 );
QUnit.test( "tabbable - not natively tabbable with various tabindex", function( assert ) {
assert.expect( 4 );
isTabbable( "#spanTabindex0", "span, tabindex 0" );
isTabbable( "#spanTabindex10", "span, tabindex 10" );
isNotTabbable( "#spanTabindex-1", "span, tabindex -1" );
isNotTabbable( "#spanTabindex-50", "span, tabindex -50" );
assert.isTabbable( "#spanTabindex0", "span, tabindex 0" );
assert.isTabbable( "#spanTabindex10", "span, tabindex 10" );
assert.isNotTabbable( "#spanTabindex-1", "span, tabindex -1" );
assert.isNotTabbable( "#spanTabindex-50", "span, tabindex -50" );
} );
test( "tabbable - area elements", function() {
expect( 3 );
QUnit.test( "tabbable - area elements", function( assert ) {
assert.expect( 3 );
isTabbable( "#areaCoordsHref", "coords and href" );
isTabbable( "#areaNoCoordsHref", "href but no coords" );
isNotTabbable( "#areaNoImg", "not associated with an image" );
assert.isTabbable( "#areaCoordsHref", "coords and href" );
assert.isTabbable( "#areaNoCoordsHref", "href but no coords" );
assert.isNotTabbable( "#areaNoImg", "not associated with an image" );
} );
test( "tabbable - dimensionless parent with overflow", function() {
expect( 1 );
QUnit.test( "tabbable - dimensionless parent with overflow", function( assert ) {
assert.expect( 1 );
isTabbable( "#dimensionlessParent", "input" );
assert.isTabbable( "#dimensionlessParent", "input" );
} );
test( "escapeSelector", function() {
expect( 1 );
QUnit.test( "escapeSelector", function( assert ) {
assert.expect( 1 );
equal( $( "#" + $.ui.escapeSelector( "weird-['x']-id" ) ).length, 1,
assert.equal( $( "#" + $.ui.escapeSelector( "weird-['x']-id" ) ).length, 1,
"properly escapes selectors to use as an id" );
} );

View File

@ -1,13 +1,14 @@
define( [
"qunit",
"jquery",
"ui/widgets/dialog"
], function( $ ) {
], function( QUnit, $ ) {
// TODO add teardown callback to remove dialogs
module( "dialog: core" );
QUnit.module( "dialog: core" );
test( "markup structure", function( assert ) {
expect( 11 );
QUnit.test( "markup structure", function( assert ) {
assert.expect( 11 );
var element = $( "<div>" ).dialog( {
buttons: [ {
@ -25,20 +26,20 @@ test( "markup structure", function( assert ) {
assert.hasClasses( widget, "ui-dialog ui-dialog-buttons ui-widget ui-widget-content" );
assert.hasClasses( titlebar, "ui-dialog-titlebar ui-widget-header" );
equal( titlebar.length, 1, "Dialog has exactly one titlebar" );
assert.equal( titlebar.length, 1, "Dialog has exactly one titlebar" );
assert.hasClasses( close, "ui-dialog-titlebar-close ui-widget" );
equal( close.length, 1, "Titlebar has exactly one close button" );
equal( title.length, 1, "Titlebar has exactly one title" );
assert.equal( close.length, 1, "Titlebar has exactly one close button" );
assert.equal( title.length, 1, "Titlebar has exactly one title" );
assert.hasClasses( element, "ui-dialog-content ui-widget-content" );
assert.hasClasses( buttonpane, "ui-dialog-buttonpane ui-widget-content" );
equal( buttonpane.length, 1, "Dialog has exactly one buttonpane" );
equal( buttonset.length, 1, "Buttonpane has exactly one buttonset" );
equal( buttons.length, 1, "Buttonset contains exactly 1 button when created with 1" );
assert.equal( buttonpane.length, 1, "Dialog has exactly one buttonpane" );
assert.equal( buttonset.length, 1, "Buttonpane has exactly one buttonset" );
assert.equal( buttons.length, 1, "Buttonset contains exactly 1 button when created with 1" );
} );
test( "markup structure - no buttons", function( assert ) {
expect( 7 );
QUnit.test( "markup structure - no buttons", function( assert ) {
assert.expect( 7 );
var element = $( "<div>" ).dialog(),
widget = element.dialog( "widget" ),
@ -48,48 +49,49 @@ test( "markup structure - no buttons", function( assert ) {
assert.hasClasses( widget, "ui-dialog ui-widget ui-widget-content" );
assert.hasClasses( titlebar, "ui-dialog-titlebar ui-widget-header" );
equal( titlebar.length, 1, "Dialog has exactly one titlebar" );
assert.equal( titlebar.length, 1, "Dialog has exactly one titlebar" );
assert.hasClasses( close, "ui-dialog-titlebar-close ui-widget" );
equal( close.length, 1, "Titlebar has exactly one close button" );
equal( title.length, 1, "Titlebar has exactly one title" );
assert.equal( close.length, 1, "Titlebar has exactly one close button" );
assert.equal( title.length, 1, "Titlebar has exactly one title" );
assert.hasClasses( element, "ui-dialog-content ui-widget-content" );
} );
test( "title id", function() {
expect( 1 );
QUnit.test( "title id", function( assert ) {
assert.expect( 1 );
var titleId,
element = $( "<div>" ).dialog();
titleId = element.dialog( "widget" ).find( ".ui-dialog-title" ).attr( "id" );
ok( /ui-id-\d+$/.test( titleId ), "auto-numbered title id" );
assert.ok( /ui-id-\d+$/.test( titleId ), "auto-numbered title id" );
element.remove();
} );
test( "ARIA", function() {
expect( 4 );
QUnit.test( "ARIA", function( assert ) {
assert.expect( 4 );
var element = $( "<div>" ).dialog(),
wrapper = element.dialog( "widget" );
equal( wrapper.attr( "role" ), "dialog", "dialog role" );
equal( wrapper.attr( "aria-labelledby" ), wrapper.find( ".ui-dialog-title" ).attr( "id" ) );
equal( wrapper.attr( "aria-describedby" ), element.attr( "id" ), "aria-describedby added" );
assert.equal( wrapper.attr( "role" ), "dialog", "dialog role" );
assert.equal( wrapper.attr( "aria-labelledby" ), wrapper.find( ".ui-dialog-title" ).attr( "id" ) );
assert.equal( wrapper.attr( "aria-describedby" ), element.attr( "id" ), "aria-describedby added" );
element.remove();
element = $( "<div><div aria-describedby='section2'><p id='section2'>descriotion</p></div></div>" ).dialog();
equal( element.dialog( "widget" ).attr( "aria-describedby" ), null, "no aria-describedby added, as already present in markup" );
assert.equal( element.dialog( "widget" ).attr( "aria-describedby" ), null, "no aria-describedby added, as already present in markup" );
element.remove();
} );
test( "widget method", function() {
expect( 1 );
QUnit.test( "widget method", function( assert ) {
assert.expect( 1 );
var dialog = $( "<div>" ).appendTo( "#qunit-fixture" ).dialog();
deepEqual( dialog.parent()[ 0 ], dialog.dialog( "widget" )[ 0 ] );
assert.deepEqual( dialog.parent()[ 0 ], dialog.dialog( "widget" )[ 0 ] );
dialog.remove();
} );
asyncTest( "focus tabbable", function() {
expect( 8 );
QUnit.test( "focus tabbable", function( assert ) {
var ready = assert.async();
assert.expect( 8 );
var element,
options = {
buttons: [ {
@ -119,7 +121,7 @@ asyncTest( "focus tabbable", function() {
var input = element.find( "input:last" ).trigger( "focus" ).trigger( "blur" );
element.dialog( "instance" )._focusTabbable();
setTimeout( function() {
equal( document.activeElement, input[ 0 ],
assert.equal( document.activeElement, input[ 0 ],
"1. an element that was focused previously." );
done();
} );
@ -128,7 +130,7 @@ asyncTest( "focus tabbable", function() {
function step2() {
checkFocus( "<div><input><input autofocus></div>", options, function( done ) {
equal( document.activeElement, element.find( "input" )[ 1 ],
assert.equal( document.activeElement, element.find( "input" )[ 1 ],
"2. first element inside the dialog matching [autofocus]" );
done();
}, step3 );
@ -136,7 +138,7 @@ asyncTest( "focus tabbable", function() {
function step3() {
checkFocus( "<div><input><input></div>", options, function( done ) {
equal( document.activeElement, element.find( "input" )[ 0 ],
assert.equal( document.activeElement, element.find( "input" )[ 0 ],
"3. tabbable element inside the content element" );
done();
}, step4 );
@ -144,7 +146,7 @@ asyncTest( "focus tabbable", function() {
function step4() {
checkFocus( "<div>text</div>", options, function( done ) {
equal( document.activeElement,
assert.equal( document.activeElement,
element.dialog( "widget" ).find( ".ui-dialog-buttonpane button" )[ 0 ],
"4. tabbable element inside the buttonpane" );
done();
@ -153,7 +155,7 @@ asyncTest( "focus tabbable", function() {
function step5() {
checkFocus( "<div>text</div>", {}, function( done ) {
equal( document.activeElement,
assert.equal( document.activeElement,
element.dialog( "widget" ).find( ".ui-dialog-titlebar .ui-dialog-titlebar-close" )[ 0 ],
"5. the close button" );
done();
@ -165,7 +167,7 @@ asyncTest( "focus tabbable", function() {
element.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).hide();
element.dialog( "open" );
setTimeout( function() {
equal( document.activeElement, element.parent()[ 0 ], "6. the dialog itself" );
assert.equal( document.activeElement, element.parent()[ 0 ], "6. the dialog itself" );
done();
} );
}, step7 );
@ -184,36 +186,39 @@ asyncTest( "focus tabbable", function() {
}
},
function( done ) {
var inputs = element.find( "input" );
equal( document.activeElement, inputs[ 1 ], "Focus starts on second input" );
var inputs = element.find( "input"
);
assert.equal
( document.activeElement, inputs[ 1 ], "Focus starts on second input" );
inputs.last().simulate( "keydown", { keyCode: $.ui.keyCode.TAB } );
setTimeout( function() {
equal( document.activeElement, inputs[ 0 ],
assert.equal( document.activeElement, inputs[ 0 ],
"Honor preventDefault, allowing custom focus management" );
done();
}, 50 );
},
start
ready
);
}
step1();
} );
test( "#7960: resizable handles below modal overlays", function() {
expect( 1 );
QUnit.test( "#7960: resizable handles below modal overlays", function( assert ) {
assert.expect( 1 );
var resizable = $( "<div>" ).resizable(),
dialog = $( "<div>" ).dialog( { modal: true } ),
resizableZindex = parseInt( resizable.find( ".ui-resizable-handle" ).css( "zIndex" ), 10 ),
overlayZindex = parseInt( $( ".ui-widget-overlay" ).css( "zIndex" ), 10 );
ok( resizableZindex < overlayZindex, "Resizable handles have lower z-index than modal overlay" );
assert.ok( resizableZindex < overlayZindex, "Resizable handles have lower z-index than modal overlay" );
dialog.dialog( "destroy" );
} );
asyncTest( "Prevent tabbing out of dialogs", function() {
expect( 3 );
QUnit.test( "Prevent tabbing out of dialogs", function( assert ) {
var ready = assert.async();
assert.expect( 3 );
var element = $( "<div><input name='0'><input name='1'></div>" ).dialog(),
inputs = element.find( "input" );
@ -222,7 +227,7 @@ asyncTest( "Prevent tabbing out of dialogs", function() {
element.dialog( "widget" ).find( ".ui-button" ).remove();
function checkTab() {
equal( document.activeElement, inputs[ 0 ], "Tab key event moved focus within the modal" );
assert.equal( document.activeElement, inputs[ 0 ], "Tab key event move d focus within the modal" );
// Check shift tab
$( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB, shiftKey: true } );
@ -230,23 +235,25 @@ asyncTest( "Prevent tabbing out of dialogs", function() {
}
function checkShiftTab() {
equal( document.activeElement, inputs[ 1 ], "Shift-Tab key event moved focus back to second input" );
assert.equal( document.activeElement, inputs[ 1 ], "Shift-Tab key event moved focus back to second input" );
element.remove();
setTimeout( start );
setTimeout( ready );
}
inputs[ 1 ].focus();
setTimeout( function() {
equal( document.activeElement, inputs[ 1 ], "Focus set on second input" );
assert.equal( document.activeElement, inputs[ 1 ], "Focus set on second input" );
inputs.eq( 1 ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB } );
setTimeout( checkTab );
} );
} );
asyncTest( "#9048: multiple modal dialogs opened and closed in different order", function() {
expect( 1 );
QUnit.test( "#9048: multiple modal dialogs opened and closed in different order",
function( assert ) {
var ready = assert.async();
assert.expect( 1 );
$( "#dialog1, #dialog2" ).dialog( { autoOpen: false, modal:true } );
$( "#dialog1" ).dialog( "open" );
$( "#dialog2" ).dialog( "open" );
@ -254,19 +261,20 @@ asyncTest( "#9048: multiple modal dialogs opened and closed in different order",
setTimeout( function() {
$( "#dialog2" ).dialog( "close" );
$( "#favorite-animal" ).trigger( "focus" );
ok( true, "event handlers cleaned up (no errors thrown)" );
start();
assert.ok( true, "event handlers cleaned up (no errors thrown)" );
ready();
} );
} );
asyncTest( "interaction between overlay and other dialogs", function() {
QUnit.test( "interaction between overlay and other dialogs", function( assert ) {
var ready = assert.async();
$.widget( "ui.testWidget", $.ui.dialog, {
options: {
modal: true,
autoOpen: false
}
} );
expect( 2 );
assert.expect( 2 );
var first = $( "<div><input id='input-1'></div>" ).dialog( {
modal: true
} ),
@ -281,25 +289,28 @@ asyncTest( "interaction between overlay and other dialogs", function() {
// Wait for the modal to init
setTimeout( function() {
second.testWidget( "open" );
// Simulate user tabbing from address bar to an element outside the dialog
second.
testWidget
( "open" );
// Simulate user tabbing from address bar to an element outside the dialog
$( "#favorite-animal" ).trigger( "focus" );
setTimeout( function() {
equal( document.activeElement, secondInput[ 0 ] );
assert.equal( document.activeElement, secondInput[ 0 ] );
// Last active dialog must receive focus
firstInput.trigger( "focus" );
$( "#favorite-animal" ).trigger( "focus" );
setTimeout( function() {
equal( document.activeElement, firstInput[ 0 ] );
assert.equal( document.activeElement, firstInput[ 0 ] );
// Cleanup
first.remove();
second.remove();
delete $.ui.testWidget;
delete $.fn.testWidget;
start();
ready();
} );
} );
} );

View File

@ -1,12 +1,13 @@
define( [
"qunit",
"jquery",
"ui/widgets/dialog"
], function( $ ) {
], function( QUnit, $ ) {
module( "dialog (deprecated): options" );
QUnit.module( "dialog (deprecated): options" );
test( "dialogClass", function( assert ) {
expect( 5 );
QUnit.test( "dialogClass", function( assert ) {
assert.expect( 5 );
var element = $( "<div>" ).dialog(),
widget = element.dialog( "widget" );
@ -27,4 +28,34 @@ test( "dialogClass", function( assert ) {
element.remove();
} );
QUnit.test( "buttons - deprecated options", function( assert ) {
assert.expect( 7 );
var buttons,
element = $( "<div></div>" ).dialog( {
buttons: [
{
html: "a button",
"class": "additional-class",
id: "my-button-id",
click: function() {
assert.equal( this, element[ 0 ], "correct context" );
},
icons: { primary: "ui-icon-cancel" },
text: false
}
]
} );
buttons = element.dialog( "widget" ).find( ".ui-dialog-buttonpane button" );
assert.equal( buttons.length, 1, "correct number of buttons" );
assert.equal( buttons.attr( "id" ), "my-button-id", "correct id" );
assert.equal( $.trim( buttons.text() ), "a button", "correct label" );
assert.hasClasses( buttons, "additional-class" );
assert.deepEqual( buttons.button( "option", "icon" ), "ui-icon-cancel" );
assert.equal( buttons.button( "option", "showLabel" ), false );
buttons.trigger( "click" );
element.remove();
} );
} );

View File

@ -1,22 +1,23 @@
define( [
"qunit",
"jquery",
"./helper",
"ui/widgets/dialog"
], function( $, testHelper ) {
], function( QUnit, $, testHelper ) {
module( "dialog: events" );
QUnit.module( "dialog: events" );
test( "open", function() {
expect( 13 );
QUnit.test( "open", function( assert ) {
assert.expect( 13 );
var element = $( "<div></div>" );
element.dialog( {
open: function( ev, ui ) {
ok( element.dialog( "instance" )._isOpen, "interal _isOpen flag is set" );
ok( true, "autoOpen: true fires open callback" );
equal( this, element[ 0 ], "context of callback" );
equal( ev.type, "dialogopen", "event type in callback" );
deepEqual( ui, {}, "ui hash in callback" );
assert.ok( element.dialog( "instance" )._isOpen, "interal _isOpen flag is set" );
assert.ok( true, "autoOpen: true fires open callback" );
assert.equal( this, element[ 0 ], "context of callback" );
assert.equal( ev.type, "dialogopen", "event type in callback" );
assert.deepEqual( ui, {}, "ui hash in callback" );
}
} );
element.remove();
@ -25,23 +26,23 @@ test( "open", function() {
element.dialog( {
autoOpen: false,
open: function( ev, ui ) {
ok( true, ".dialog('open') fires open callback" );
equal( this, element[ 0 ], "context of callback" );
equal( ev.type, "dialogopen", "event type in callback" );
deepEqual( ui, {}, "ui hash in callback" );
assert.ok( true, ".dialog('open') fires open callback" );
assert.equal( this, element[ 0 ], "context of callback" );
assert.equal( ev.type, "dialogopen", "event type in callback" );
assert.deepEqual( ui, {}, "ui hash in callback" );
}
} ).on( "dialogopen", function( ev, ui ) {
ok( element.dialog( "instance" )._isOpen, "interal _isOpen flag is set" );
ok( true, "dialog('open') fires open event" );
equal( this, element[ 0 ], "context of event" );
deepEqual( ui, {}, "ui hash in event" );
assert.ok( element.dialog( "instance" )._isOpen, "interal _isOpen flag is set" );
assert.ok( true, "dialog('open') fires open event" );
assert.equal( this, element[ 0 ], "context of event" );
assert.deepEqual( ui, {}, "ui hash in event" );
} );
element.dialog( "open" );
element.remove();
} );
test( "focus", function() {
expect( 5 );
QUnit.test( "focus", function( assert ) {
assert.expect( 5 );
var element, other;
element = $( "#dialog1" ).dialog( {
autoOpen: false
@ -51,27 +52,27 @@ test( "focus", function() {
} );
element.one( "dialogopen", function() {
ok( true, "open, just once" );
assert.ok( true, "open, just once" );
} );
element.one( "dialogfocus", function() {
ok( true, "focus on open" );
assert.ok( true, "focus on open" );
} );
other.dialog( "open" );
element.one( "dialogfocus", function() {
ok( true, "when opening and already open and wasn't on top" );
assert.ok( true, "when opening and already open and wasn't on top" );
} );
other.dialog( "open" );
element.dialog( "open" );
element.one( "dialogfocus", function() {
ok( true, "when calling moveToTop and wasn't on top" );
assert.ok( true, "when calling moveToTop and wasn't on top" );
} );
other.dialog( "moveToTop" );
element.dialog( "moveToTop" );
element.on( "dialogfocus", function() {
ok( true, "when mousedown anywhere on the dialog and it wasn't on top" );
assert.ok( true, "when mousedown anywhere on the dialog and it wasn't on top" );
} );
other.dialog( "moveToTop" );
element.trigger( "mousedown" );
@ -84,23 +85,23 @@ test( "focus", function() {
element.add( other ).remove();
} );
test( "dragStart", function() {
expect( 9 );
QUnit.test( "dragStart", function( assert ) {
assert.expect( 9 );
var handle,
element = $( "<div></div>" ).dialog( {
dragStart: function( ev, ui ) {
ok( true, "dragging fires dragStart callback" );
equal( this, element[ 0 ], "context of callback" );
equal( ev.type, "dialogdragstart", "event type in callback" );
ok( ui.position !== undefined, "ui.position in callback" );
ok( ui.offset !== undefined, "ui.offset in callback" );
assert.ok( true, "dragging fires dragStart callback" );
assert.equal( this, element[ 0 ], "context of callback" );
assert.equal( ev.type, "dialogdragstart", "event type in callback" );
assert.ok( ui.position !== undefined, "ui.position in callback" );
assert.ok( ui.offset !== undefined, "ui.offset in callback" );
}
} ).on( "dialogdragstart", function( ev, ui ) {
ok( true, "dragging fires dialogdragstart event" );
equal( this, element[ 0 ], "context of event" );
ok( ui.position !== undefined, "ui.position in callback" );
ok( ui.offset !== undefined, "ui.offset in callback" );
assert.ok( true, "dragging fires dialogdragstart event" );
assert.equal( this, element[ 0 ], "context of event" );
assert.ok( ui.position !== undefined, "ui.position in callback" );
assert.ok( ui.offset !== undefined, "ui.offset in callback" );
} );
handle = $( ".ui-dialog-titlebar", element.dialog( "widget" ) );
@ -108,27 +109,27 @@ test( "dragStart", function() {
element.remove();
} );
test( "drag", function() {
expect( 9 );
QUnit.test( "drag", function( assert ) {
assert.expect( 9 );
var handle,
hasDragged = false,
element = $( "<div></div>" ).dialog( {
drag: function( ev, ui ) {
if ( !hasDragged ) {
ok( true, "dragging fires drag callback" );
equal( this, element[ 0 ], "context of callback" );
equal( ev.type, "dialogdrag", "event type in callback" );
ok( ui.position !== undefined, "ui.position in callback" );
ok( ui.offset !== undefined, "ui.offset in callback" );
assert.ok( true, "dragging fires drag callback" );
assert.equal( this, element[ 0 ], "context of callback" );
assert.equal( ev.type, "dialogdrag", "event type in callback" );
assert.ok( ui.position !== undefined, "ui.position in callback" );
assert.ok( ui.offset !== undefined, "ui.offset in callback" );
hasDragged = true;
}
}
} ).one( "dialogdrag", function( ev, ui ) {
ok( true, "dragging fires dialogdrag event" );
equal( this, element[ 0 ], "context of event" );
ok( ui.position !== undefined, "ui.position in callback" );
ok( ui.offset !== undefined, "ui.offset in callback" );
assert.ok( true, "dragging fires dialogdrag event" );
assert.equal( this, element[ 0 ], "context of event" );
assert.ok( ui.position !== undefined, "ui.position in callback" );
assert.ok( ui.offset !== undefined, "ui.offset in callback" );
} );
handle = $( ".ui-dialog-titlebar", element.dialog( "widget" ) );
@ -136,23 +137,23 @@ test( "drag", function() {
element.remove();
} );
test( "dragStop", function() {
expect( 9 );
QUnit.test( "dragStop", function( assert ) {
assert.expect( 9 );
var handle,
element = $( "<div></div>" ).dialog( {
dragStop: function( ev, ui ) {
ok( true, "dragging fires dragStop callback" );
equal( this, element[ 0 ], "context of callback" );
equal( ev.type, "dialogdragstop", "event type in callback" );
ok( ui.position !== undefined, "ui.position in callback" );
ok( ui.offset !== undefined, "ui.offset in callback" );
assert.ok( true, "dragging fires dragStop callback" );
assert.equal( this, element[ 0 ], "context of callback" );
assert.equal( ev.type, "dialogdragstop", "event type in callback" );
assert.ok( ui.position !== undefined, "ui.position in callback" );
assert.ok( ui.offset !== undefined, "ui.offset in callback" );
}
} ).on( "dialogdragstop", function( ev, ui ) {
ok( true, "dragging fires dialogdragstop event" );
equal( this, element[ 0 ], "context of event" );
ok( ui.position !== undefined, "ui.position in callback" );
ok( ui.offset !== undefined, "ui.offset in callback" );
assert.ok( true, "dragging fires dialogdragstop event" );
assert.equal( this, element[ 0 ], "context of event" );
assert.ok( ui.position !== undefined, "ui.position in callback" );
assert.ok( ui.offset !== undefined, "ui.offset in callback" );
} );
handle = $( ".ui-dialog-titlebar", element.dialog( "widget" ) );
@ -160,27 +161,27 @@ test( "dragStop", function() {
element.remove();
} );
test( "resizeStart", function() {
expect( 13 );
QUnit.test( "resizeStart", function( assert ) {
assert.expect( 13 );
var handle,
element = $( "<div></div>" ).dialog( {
resizeStart: function( ev, ui ) {
ok( true, "resizing fires resizeStart callback" );
equal( this, element[ 0 ], "context of callback" );
equal( ev.type, "dialogresizestart", "event type in callback" );
ok( ui.originalPosition !== undefined, "ui.originalPosition in callback" );
ok( ui.originalSize !== undefined, "ui.originalSize in callback" );
ok( ui.position !== undefined, "ui.position in callback" );
ok( ui.size !== undefined, "ui.size in callback" );
assert.ok( true, "resizing fires resizeStart callback" );
assert.equal( this, element[ 0 ], "context of callback" );
assert.equal( ev.type, "dialogresizestart", "event type in callback" );
assert.ok( ui.originalPosition !== undefined, "ui.originalPosition in callback" );
assert.ok( ui.originalSize !== undefined, "ui.originalSize in callback" );
assert.ok( ui.position !== undefined, "ui.position in callback" );
assert.ok( ui.size !== undefined, "ui.size in callback" );
}
} ).on( "dialogresizestart", function( ev, ui ) {
ok( true, "resizing fires dialogresizestart event" );
equal( this, element[ 0 ], "context of event" );
ok( ui.originalPosition !== undefined, "ui.originalPosition in callback" );
ok( ui.originalSize !== undefined, "ui.originalSize in callback" );
ok( ui.position !== undefined, "ui.position in callback" );
ok( ui.size !== undefined, "ui.size in callback" );
assert.ok( true, "resizing fires dialogresizestart event" );
assert.equal( this, element[ 0 ], "context of event" );
assert.ok( ui.originalPosition !== undefined, "ui.originalPosition in callback" );
assert.ok( ui.originalSize !== undefined, "ui.originalSize in callback" );
assert.ok( ui.position !== undefined, "ui.position in callback" );
assert.ok( ui.size !== undefined, "ui.size in callback" );
} );
handle = $( ".ui-resizable-se", element.dialog( "widget" ) );
@ -188,31 +189,31 @@ test( "resizeStart", function() {
element.remove();
} );
test( "resize", function() {
expect( 13 );
QUnit.test( "resize", function( assert ) {
assert.expect( 13 );
var handle,
hasResized = false,
element = $( "<div></div>" ).dialog( {
resize: function( ev, ui ) {
if ( !hasResized ) {
ok( true, "resizing fires resize callback" );
equal( this, element[ 0 ], "context of callback" );
equal( ev.type, "dialogresize", "event type in callback" );
ok( ui.originalPosition !== undefined, "ui.originalPosition in callback" );
ok( ui.originalSize !== undefined, "ui.originalSize in callback" );
ok( ui.position !== undefined, "ui.position in callback" );
ok( ui.size !== undefined, "ui.size in callback" );
assert.ok( true, "resizing fires resize callback" );
assert.equal( this, element[ 0 ], "context of callback" );
assert.equal( ev.type, "dialogresize", "event type in callback" );
assert.ok( ui.originalPosition !== undefined, "ui.originalPosition in callback" );
assert.ok( ui.originalSize !== undefined, "ui.originalSize in callback" );
assert.ok( ui.position !== undefined, "ui.position in callback" );
assert.ok( ui.size !== undefined, "ui.size in callback" );
hasResized = true;
}
}
} ).one( "dialogresize", function( ev, ui ) {
ok( true, "resizing fires dialogresize event" );
equal( this, element[ 0 ], "context of event" );
ok( ui.originalPosition !== undefined, "ui.originalPosition in callback" );
ok( ui.originalSize !== undefined, "ui.originalSize in callback" );
ok( ui.position !== undefined, "ui.position in callback" );
ok( ui.size !== undefined, "ui.size in callback" );
assert.ok( true, "resizing fires dialogresize event" );
assert.equal( this, element[ 0 ], "context of event" );
assert.ok( ui.originalPosition !== undefined, "ui.originalPosition in callback" );
assert.ok( ui.originalSize !== undefined, "ui.originalSize in callback" );
assert.ok( ui.position !== undefined, "ui.position in callback" );
assert.ok( ui.size !== undefined, "ui.size in callback" );
} );
handle = $( ".ui-resizable-se", element.dialog( "widget" ) );
@ -220,27 +221,27 @@ test( "resize", function() {
element.remove();
} );
test( "resizeStop", function() {
expect( 13 );
QUnit.test( "resizeStop", function( assert ) {
assert.expect( 13 );
var handle,
element = $( "<div></div>" ).dialog( {
resizeStop: function( ev, ui ) {
ok( true, "resizing fires resizeStop callback" );
equal( this, element[ 0 ], "context of callback" );
equal( ev.type, "dialogresizestop", "event type in callback" );
ok( ui.originalPosition !== undefined, "ui.originalPosition in callback" );
ok( ui.originalSize !== undefined, "ui.originalSize in callback" );
ok( ui.position !== undefined, "ui.position in callback" );
ok( ui.size !== undefined, "ui.size in callback" );
assert.ok( true, "resizing fires resizeStop callback" );
assert.equal( this, element[ 0 ], "context of callback" );
assert.equal( ev.type, "dialogresizestop", "event type in callback" );
assert.ok( ui.originalPosition !== undefined, "ui.originalPosition in callback" );
assert.ok( ui.originalSize !== undefined, "ui.originalSize in callback" );
assert.ok( ui.position !== undefined, "ui.position in callback" );
assert.ok( ui.size !== undefined, "ui.size in callback" );
}
} ).on( "dialogresizestop", function( ev, ui ) {
ok( true, "resizing fires dialogresizestop event" );
equal( this, element[ 0 ], "context of event" );
ok( ui.originalPosition !== undefined, "ui.originalPosition in callback" );
ok( ui.originalSize !== undefined, "ui.originalSize in callback" );
ok( ui.position !== undefined, "ui.position in callback" );
ok( ui.size !== undefined, "ui.size in callback" );
assert.ok( true, "resizing fires dialogresizestop event" );
assert.equal( this, element[ 0 ], "context of event" );
assert.ok( ui.originalPosition !== undefined, "ui.originalPosition in callback" );
assert.ok( ui.originalSize !== undefined, "ui.originalSize in callback" );
assert.ok( ui.position !== undefined, "ui.position in callback" );
assert.ok( ui.size !== undefined, "ui.size in callback" );
} );
handle = $( ".ui-resizable-se", element.dialog( "widget" ) );
@ -248,20 +249,21 @@ test( "resizeStop", function() {
element.remove();
} );
asyncTest( "close", function() {
expect( 14 );
QUnit.test( "close", function( assert ) {
var ready = assert.async();
assert.expect( 14 );
var element = $( "<div></div>" ).dialog( {
close: function( ev, ui ) {
ok( true, ".dialog('close') fires close callback" );
equal( this, element[ 0 ], "context of callback" );
equal( ev.type, "dialogclose", "event type in callback" );
deepEqual( ui, {}, "ui hash in callback" );
assert.ok( true, ".dialog('close') fires close callback" );
assert.equal( this, element[ 0 ], "context of callback" );
assert.equal( ev.type, "dialogclose", "event type in callback" );
assert.deepEqual( ui, {}, "ui hash in callback" );
}
} ).on( "dialogclose", function( ev, ui ) {
ok( true, ".dialog('close') fires dialogclose event" );
equal( this, element[ 0 ], "context of event" );
deepEqual( ui, {}, "ui hash in event" );
assert.ok( true, ".dialog('close') fires dialogclose event" );
assert.equal( this, element[ 0 ], "context of event" );
assert.deepEqual( ui, {}, "ui hash in event" );
} );
element.dialog( "close" );
element.remove();
@ -270,100 +272,101 @@ asyncTest( "close", function() {
element = $( "<div></div>" ).dialog( {
hide: 10,
close: function( ev, ui ) {
ok( true, ".dialog('close') fires close callback" );
equal( this, element[ 0 ], "context of callback" );
equal( ev.type, "dialogclose", "event type in callback" );
deepEqual( ui, {}, "ui hash in callback" );
start();
assert.ok( true, ".dialog('close') fires close callback" );
assert.equal( this, element[ 0 ], "context of callback" );
assert.equal( ev.type, "dialogclose", "event type in callback" );
assert.deepEqual( ui, {}, "ui hash in callback" );
ready();
}
} ).on( "dialogclose", function( ev, ui ) {
ok( true, ".dialog('close') fires dialogclose event" );
equal( this, element[ 0 ], "context of event" );
deepEqual( ui, {}, "ui hash in event" );
assert.ok( true, ".dialog('close') fires dialogclose event" );
assert.equal( this, element[ 0 ], "context of event" );
assert.deepEqual( ui, {}, "ui hash in event" );
} );
element.dialog( "close" );
} );
test( "beforeClose", function() {
expect( 14 );
QUnit.test( "beforeClose", function( assert ) {
assert.expect( 14 );
var element = $( "<div></div>" ).dialog( {
beforeClose: function( ev, ui ) {
ok( true, ".dialog('close') fires beforeClose callback" );
equal( this, element[ 0 ], "context of callback" );
equal( ev.type, "dialogbeforeclose", "event type in callback" );
deepEqual( ui, {}, "ui hash in callback" );
assert.ok( true, ".dialog('close') fires beforeClose callback" );
assert.equal( this, element[ 0 ], "context of callback" );
assert.equal( ev.type, "dialogbeforeclose", "event type in callback" );
assert.deepEqual( ui, {}, "ui hash in callback" );
return false;
}
} );
element.dialog( "close" );
ok( element.dialog( "widget" ).is( ":visible" ), "beforeClose callback should prevent dialog from closing" );
assert.ok( element.dialog( "widget" ).is( ":visible" ), "beforeClose callback should prevent dialog from closing" );
element.remove();
element = $( "<div></div>" ).dialog();
element.dialog( "option", "beforeClose", function( ev, ui ) {
ok( true, ".dialog('close') fires beforeClose callback" );
equal( this, element[ 0 ], "context of callback" );
equal( ev.type, "dialogbeforeclose", "event type in callback" );
deepEqual( ui, {}, "ui hash in callback" );
assert.ok( true, ".dialog('close') fires beforeClose callback" );
assert.equal( this, element[ 0 ], "context of callback" );
assert.equal( ev.type, "dialogbeforeclose", "event type in callback" );
assert.deepEqual( ui, {}, "ui hash in callback" );
return false;
} );
element.dialog( "close" );
ok( element.dialog( "widget" ).is( ":visible" ), "beforeClose callback should prevent dialog from closing" );
assert.ok( element.dialog( "widget" ).is( ":visible" ), "beforeClose callback should prevent dialog from closing" );
element.remove();
element = $( "<div></div>" ).dialog().on( "dialogbeforeclose", function( ev, ui ) {
ok( true, ".dialog('close') triggers dialogbeforeclose event" );
equal( this, element[ 0 ], "context of event" );
deepEqual( ui, {}, "ui hash in event" );
assert.ok( true, ".dialog('close') triggers dialogbeforeclose event" );
assert.equal( this, element[ 0 ], "context of event" );
assert.deepEqual( ui, {}, "ui hash in event" );
return false;
} );
element.dialog( "close" );
ok( element.dialog( "widget" ).is( ":visible" ), "dialogbeforeclose event should prevent dialog from closing" );
assert.ok( element.dialog( "widget" ).is( ":visible" ), "dialogbeforeclose event should prevent dialog from closing" );
element.remove();
} );
// #8789 and #8838
asyncTest( "ensure dialog's container doesn't scroll on resize and focus", function() {
expect( 2 );
QUnit.test( "ensure dialog's container doesn't scroll on resize and focus", function( assert ) {
var ready = assert.async();
assert.expect( 2 );
var element = $( "#dialog1" ).dialog(),
initialScroll = $( window ).scrollTop();
element.dialog( "option", "height", 600 );
equal( $( window ).scrollTop(), initialScroll, "scroll hasn't moved after height change" );
assert.equal( $( window ).scrollTop(), initialScroll, "scroll hasn't moved after height change" );
setTimeout( function() {
$( ".ui-dialog-titlebar-close" ).simulate( "mousedown" );
equal( $( window ).scrollTop(), initialScroll, "scroll hasn't moved after focus moved to dialog" );
assert.equal( $( window ).scrollTop(), initialScroll, "scroll hasn't moved after focus moved to dialog" );
element.dialog( "destroy" );
start();
ready();
} );
} );
test( "#5184: isOpen in dialogclose event is true", function() {
expect( 3 );
QUnit.test( "#5184: isOpen in dialogclose event is true", function( assert ) {
assert.expect( 3 );
var element = $( "<div></div>" ).dialog( {
close: function() {
ok( !element.dialog( "isOpen" ), "dialog is not open during close" );
assert.ok( !element.dialog( "isOpen" ), "dialog is not open during close" );
}
} );
ok( element.dialog( "isOpen" ), "dialog is open after init" );
assert.ok( element.dialog( "isOpen" ), "dialog is open after init" );
element.dialog( "close" );
ok( !element.dialog( "isOpen" ), "dialog is not open after close" );
assert.ok( !element.dialog( "isOpen" ), "dialog is not open after close" );
element.remove();
} );
test( "ensure dialog keeps focus when clicking modal overlay", function() {
expect( 2 );
QUnit.test( "ensure dialog keeps focus when clicking modal overlay", function( assert ) {
assert.expect( 2 );
var element = $( "<div></div>" ).dialog( {
modal: true
} );
equal( $( document.activeElement ).closest( ".ui-dialog" ).length, 1, "focus is in dialog" );
assert.equal( $( document.activeElement ).closest( ".ui-dialog" ).length, 1, "focus is in dialog" );
$( ".ui-widget-overlay" ).simulate( "mousedown" );
equal( $( document.activeElement ).closest( ".ui-dialog" ).length, 1, "focus is still in dialog" );
assert.equal( $( document.activeElement ).closest( ".ui-dialog" ).length, 1, "focus is still in dialog" );
element.remove();
} );

View File

@ -1,21 +1,22 @@
define( [
"qunit",
"jquery",
"lib/helper",
"ui/widgets/dialog"
], function( $, helper ) {
], function( QUnit, $, helper ) {
return $.extend( helper, {
drag: function( element, handle, dx, dy ) {
var d = element.dialog( "widget" );
//this mouseover is to work around a limitation in resizable
//This mouseover is to work around a limitation in resizable
//TODO: fix resizable so handle doesn't require mouseover in order to be used
$( handle, d ).simulate( "mouseover" ).simulate( "drag", {
dx: dx,
dy: dy
} );
},
testDrag: function( element, dx, dy, expectedDX, expectedDY, msg ) {
testDrag: function( assert, element, dx, dy, expectedDX, expectedDY, msg ) {
var actualDX, actualDY, offsetAfter,
d = element.dialog( "widget" ),
handle = $( ".ui-dialog-titlebar", d ),
@ -29,14 +30,11 @@ return $.extend( helper, {
actualDX = offsetAfter.left - offsetBefore.left;
actualDY = offsetAfter.top - offsetBefore.top;
ok( expectedDX - actualDX <= 1 && expectedDY - actualDY <= 1, "dragged[" + expectedDX + ", " + expectedDY + "] " + msg );
assert.ok( expectedDX - actualDX <= 1 && expectedDY - actualDY <= 1, "dragged[" + expectedDX + ", " + expectedDY + "] " + msg );
},
// TODO switch back to checking the size of the .ui-dialog element (var d)
// once we switch to using box-sizing: border-box (#9845) that should work fine
// using the element's dimensions to avoid subpixel errors
shouldResize: function( element, dw, dh, msg ) {
var heightAfter, widthAfter, actual, expected,
shouldResize: function( assert, element, dw, dh, msg ) {
var actualDH, actualDW, heightAfter, widthAfter,
d = element.dialog( "widget" ),
handle = $( ".ui-resizable-se", d ),
heightBefore = element.height(),
@ -48,9 +46,13 @@ return $.extend( helper, {
widthAfter = element.width();
msg = msg ? msg + "." : "";
actual = { width: widthAfter, height: heightAfter },
expected = { width: widthBefore + dw, height: heightBefore + dh };
deepEqual( actual, expected, "resized[" + 50 + ", " + 50 + "] " + msg );
actualDH = heightAfter - heightBefore;
actualDW = widthAfter - widthBefore;
// TODO: Switch to assert.close().
// Also change the testDrag() helper.
assert.ok( Math.abs( actualDH - dh ) <= 1 && Math.abs( actualDW - dw ) <= 1, "resized[50, 50] " + msg );
}
} );

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