Merge branch 'master' into selectmenu

This commit is contained in:
Felix Nagel 2012-11-10 01:40:05 +01:00
commit 7ce8e0515e
214 changed files with 11709 additions and 13420 deletions

View File

@ -9,3 +9,8 @@ end_of_line = lf
charset = utf-8 charset = utf-8
trim_trailing_whitespace = true trim_trailing_whitespace = true
insert_final_newline = true insert_final_newline = true
[external/**]
trim_trailing_whitespace = false
insert_final_newline = varies
end_of_line = varies

View File

@ -3,10 +3,10 @@
"eqnull": true, "eqnull": true,
"eqeqeq": true, "eqeqeq": true,
"expr": true, "expr": true,
"latedef": true,
"noarg": true, "noarg": true,
"node": true,
"onevar": true, "onevar": true,
"smarttabs": true,
"trailing": true, "trailing": true,
"undef": true "undef": true,
"unused": true
} }

View File

@ -1,13 +0,0 @@
{
"curly": true,
"eqnull": true,
"eqeqeq": true,
"expr": true,
"noarg": true,
"node": true,
"onevar": true,
"smarttabs": true,
"strict": false,
"trailing": true,
"undef": true
}

View File

@ -24,54 +24,86 @@ DELETE EVERYTHING ABOVE THE FOLLOWING LINE
## Build ## Build
## Core & Utilities ## Core & Utilities
### UI Core ### UI Core
### Mouse ### Mouse
### Widget Factory ### Widget Factory
### Position ### Position
## Interactions ## Interactions
### Draggable ### Draggable
### Droppable ### Droppable
### Resizable ### Resizable
### Selectable ### Selectable
### Sortable ### Sortable
## Widgets ## Widgets
### Accordion ### Accordion
### Autocomplete ### Autocomplete
### Button ### Button
### Datepicker ### Datepicker
### Dialog ### Dialog
### Menu
### Progressbar ### Progressbar
### Slider ### Slider
### Spinner
### Tabs ### Tabs
### Tooltip
## Effects ## Effects
### Individual effects ### Individual effects
## CSS Framework ## CSS Framework
## Demos ## Demos
## Website ## Website
### Download Builder ### Download Builder

View File

@ -1,5 +1,7 @@
#!/usr/bin/env node #!/usr/bin/env node
/*global cat:true cd:true cp:true echo:true exec:true exit:true ls:true*/ /*global cat:true cd:true echo:true exec:true exit:true*/
"use strict";
var baseDir, repoDir, prevVersion, newVersion, nextVersion, tagTime, var baseDir, repoDir, prevVersion, newVersion, nextVersion, tagTime,
fs = require( "fs" ), fs = require( "fs" ),
@ -41,9 +43,6 @@ walk([
section( "gathering contributors" ), section( "gathering contributors" ),
gatherContributors, gatherContributors,
section( "generating quick download" ),
generateQuickDownload,
section( "updating trac" ), section( "updating trac" ),
updateTrac, updateTrac,
confirm confirm
@ -261,34 +260,6 @@ function gatherContributors() {
echo( "Stored contributors in " + contributorsPath.cyan + "." ); echo( "Stored contributors in " + contributorsPath.cyan + "." );
} }
function generateQuickDownload() {
var config,
downloadDir = repoDir + "/node_modules/download.jqueryui.com",
filename = "jquery-ui-" + newVersion + ".custom.zip",
destination = baseDir + "/" + filename;
cd( downloadDir );
// Update jQuery UI version for download builder
config = JSON.parse( cat( "config.json" ) );
config.jqueryUi = newVersion;
JSON.stringify( config ).to( "config.json" );
// Generate quick download
// TODO: Find a way to avoid having to clone jquery-ui inside download builder
if ( exec( "grunt prepare build" ).code !== 0 ) {
abort( "Error generating quick download." );
}
cp( downloadDir + "/release/" + filename, destination );
// cp() doesn't have error handling, so check for the file
if ( ls( destination ).length !== 1 ) {
abort( "Error copying quick download." );
}
// Go back to repo directory for consistency
cd( repoDir );
}
function updateTrac() { function updateTrac() {
echo( newVersion.cyan + " was tagged at " + tagTime.cyan + "." ); echo( newVersion.cyan + " was tagged at " + tagTime.cyan + "." );
echo( "Close the " + newVersion.cyan + " Milestone with the above date and time." ); echo( "Close the " + newVersion.cyan + " Milestone with the above date and time." );
@ -423,7 +394,7 @@ function abort( msg ) {
function walk( methods ) { function walk( methods ) {
var method = methods.shift(); var method = methods.shift();
function next( error ) { function next() {
if ( methods.length ) { if ( methods.length ) {
walk( methods ); walk( methods );
} }

View File

@ -1,6 +1,9 @@
module.exports = function( grunt ) { module.exports = function( grunt ) {
var path = require( "path" ); "use strict";
var path = require( "path" ),
fs = require( "fs" );
grunt.registerTask( "manifest", "Generate jquery.json manifest files", function() { grunt.registerTask( "manifest", "Generate jquery.json manifest files", function() {
var pkg = grunt.config( "pkg" ), var pkg = grunt.config( "pkg" ),
@ -143,7 +146,7 @@ grunt.registerMultiTask( "zip", "Create a zip file for release", function() {
opts: { opts: {
cwd: 'dist' cwd: 'dist'
} }
}, function( err, result ) { }, function( err ) {
if ( err ) { if ( err ) {
grunt.log.error( err ); grunt.log.error( err );
done(); done();

View File

@ -1,6 +1,7 @@
/*jshint node: true */
module.exports = function( grunt ) { module.exports = function( grunt ) {
"use strict";
var versions = { var versions = {
"git": "git", "git": "git",
"1.8": "1.8.0 1.8.1 1.8.2", "1.8": "1.8.0 1.8.1 1.8.2",
@ -9,26 +10,23 @@ var versions = {
}, },
tests = { tests = {
"Accordion": "accordion/accordion.html", "Accordion": "accordion/accordion.html",
"Accordion_deprecated": "accordion/accordion_deprecated.html",
"Autocomplete": "autocomplete/autocomplete.html", "Autocomplete": "autocomplete/autocomplete.html",
"Button": "button/button.html", "Button": "button/button.html",
"Core": "core/core.html", "Core": "core/core.html",
//"datepicker/datepicker.html", "Datepicker": "datepicker/datepicker.html",
//"dialog/dialog.html", "Dialog": "dialog/dialog.html",
//"draggable/draggable.html", "Draggable": "draggable/draggable.html",
//"droppable/droppable.html", "Droppable": "droppable/droppable.html",
"Effects": "effects/effects.html", "Effects": "effects/effects.html",
"Menu": "menu/menu.html", "Menu": "menu/menu.html",
"Position": "position/position.html", "Position": "position/position.html",
"Position_deprecated": "position/position_deprecated.html",
"Progressbar": "progressbar/progressbar.html", "Progressbar": "progressbar/progressbar.html",
//"resizable/resizable.html", "Resizable": "resizable/resizable.html",
//"selectable/selectable.html", "Selectable": "selectable/selectable.html",
//"slider/slider.html", "Slider": "slider/slider.html",
//"sortable/sortable.html", "Sortable": "sortable/sortable.html",
"Spinner": "spinner/spinner.html", "Spinner": "spinner/spinner.html",
"Tabs": "tabs/tabs.html", "Tabs": "tabs/tabs.html",
"Tabs_deprecated": "tabs/tabs_deprecated.html",
"Tooltip": "tooltip/tooltip.html", "Tooltip": "tooltip/tooltip.html",
"Widget": "widget/widget.html" "Widget": "widget/widget.html"
}; };
@ -53,9 +51,9 @@ function submit( commit, tests, configFile, version, done ) {
authToken: config.authToken, authToken: config.authToken,
jobName: 'jQuery UI ' + version + '#<a href="https://github.com/jquery/jquery-ui/commit/' + commit + '">' + commit.substr( 0, 10 ) + '</a>', jobName: 'jQuery UI ' + version + '#<a href="https://github.com/jquery/jquery-ui/commit/' + commit + '">' + commit.substr( 0, 10 ) + '</a>',
runMax: config.runMax, runMax: config.runMax,
"runNames[]": Object.keys(tests), "runNames[]": Object.keys( tests ),
"runUrls[]": testUrls, "runUrls[]": testUrls,
"browserSets[]": ["popular"] "browserSets[]": [ "popular-no-ie6" ]
}); });
} }

View File

@ -111,7 +111,6 @@
input.data( "autocomplete" )._renderItem = function( ul, item ) { input.data( "autocomplete" )._renderItem = function( ul, item ) {
return $( "<li>" ) return $( "<li>" )
.data( "item.autocomplete", item )
.append( "<a>" + item.label + "</a>" ) .append( "<a>" + item.label + "</a>" )
.appendTo( ul ); .appendTo( ul );
}; };

View File

@ -68,7 +68,6 @@
}) })
.data( "autocomplete" )._renderItem = function( ul, item ) { .data( "autocomplete" )._renderItem = function( ul, item ) {
return $( "<li>" ) return $( "<li>" )
.data( "item.autocomplete", item )
.append( "<a>" + item.label + "<br>" + item.desc + "</a>" ) .append( "<a>" + item.label + "<br>" + item.desc + "</a>" )
.appendTo( ul ); .appendTo( ul );
}; };

View File

@ -43,7 +43,7 @@
<button>Button with two icons and no text</button> <button>Button with two icons and no text</button>
<div class="demo-description"> <div class="demo-description">
<p>Some buttons with various combinations of text and icons, here specified via metadata.</p> <p>Some buttons with various combinations of text and icons.</p>
</div> </div>
</body> </body>
</html> </html>

View File

@ -46,6 +46,7 @@
<script src="../../ui/i18n/jquery.ui.datepicker-kk.js"></script> <script src="../../ui/i18n/jquery.ui.datepicker-kk.js"></script>
<script src="../../ui/i18n/jquery.ui.datepicker-km.js"></script> <script src="../../ui/i18n/jquery.ui.datepicker-km.js"></script>
<script src="../../ui/i18n/jquery.ui.datepicker-ko.js"></script> <script src="../../ui/i18n/jquery.ui.datepicker-ko.js"></script>
<script src="../../ui/i18n/jquery.ui.datepicker-ky.js"></script>
<script src="../../ui/i18n/jquery.ui.datepicker-lb.js"></script> <script src="../../ui/i18n/jquery.ui.datepicker-lb.js"></script>
<script src="../../ui/i18n/jquery.ui.datepicker-lt.js"></script> <script src="../../ui/i18n/jquery.ui.datepicker-lt.js"></script>
<script src="../../ui/i18n/jquery.ui.datepicker-lv.js"></script> <script src="../../ui/i18n/jquery.ui.datepicker-lv.js"></script>
@ -134,6 +135,7 @@
<option value="kk">Kazakhstan (Kazakh)</option> <option value="kk">Kazakhstan (Kazakh)</option>
<option value="km">Khmer</option> <option value="km">Khmer</option>
<option value="ko">Korean (&#54620;&#44397;&#50612;)</option> <option value="ko">Korean (&#54620;&#44397;&#50612;)</option>
<option value="ky">Kyrgyzstan (Kyrgyz)</option>
<option value="lv">Latvian (Latvie&ouml;u Valoda)</option> <option value="lv">Latvian (Latvie&ouml;u Valoda)</option>
<option value="lt">Lithuanian (lietuviu kalba)</option> <option value="lt">Lithuanian (lietuviu kalba)</option>
<option value="lb">Luxembourgish</option> <option value="lb">Luxembourgish</option>

View File

@ -5,7 +5,6 @@
<title>jQuery UI Dialog - Animation</title> <title>jQuery UI Dialog - Animation</title>
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script src="../../jquery-1.8.2.js"></script> <script src="../../jquery-1.8.2.js"></script>
<script src="../../external/jquery.bgiframe-2.1.2.js"></script>
<script src="../../ui/jquery.ui.core.js"></script> <script src="../../ui/jquery.ui.core.js"></script>
<script src="../../ui/jquery.ui.widget.js"></script> <script src="../../ui/jquery.ui.widget.js"></script>
<script src="../../ui/jquery.ui.mouse.js"></script> <script src="../../ui/jquery.ui.mouse.js"></script>
@ -18,18 +17,21 @@
<script src="../../ui/jquery.ui.effect-explode.js"></script> <script src="../../ui/jquery.ui.effect-explode.js"></script>
<link rel="stylesheet" href="../demos.css"> <link rel="stylesheet" href="../demos.css">
<script> <script>
// increase the default animation speed to exaggerate the effect
$.fx.speeds._default = 1000;
$(function() { $(function() {
$( "#dialog" ).dialog({ $( "#dialog" ).dialog({
autoOpen: false, autoOpen: false,
show: "blind", show: {
hide: "explode" effect: "blind",
duration: 1000
},
hide: {
effect: "explode",
duration: 1000
}
}); });
$( "#opener" ).click(function() { $( "#opener" ).click(function() {
$( "#dialog" ).dialog( "open" ); $( "#dialog" ).dialog( "open" );
return false;
}); });
}); });
</script> </script>

View File

@ -5,7 +5,6 @@
<title>jQuery UI Dialog - Default functionality</title> <title>jQuery UI Dialog - Default functionality</title>
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script src="../../jquery-1.8.2.js"></script> <script src="../../jquery-1.8.2.js"></script>
<script src="../../external/jquery.bgiframe-2.1.2.js"></script>
<script src="../../ui/jquery.ui.core.js"></script> <script src="../../ui/jquery.ui.core.js"></script>
<script src="../../ui/jquery.ui.widget.js"></script> <script src="../../ui/jquery.ui.widget.js"></script>
<script src="../../ui/jquery.ui.mouse.js"></script> <script src="../../ui/jquery.ui.mouse.js"></script>

View File

@ -5,7 +5,6 @@
<title>jQuery UI Dialog - Modal confirmation</title> <title>jQuery UI Dialog - Modal confirmation</title>
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script src="../../jquery-1.8.2.js"></script> <script src="../../jquery-1.8.2.js"></script>
<script src="../../external/jquery.bgiframe-2.1.2.js"></script>
<script src="../../ui/jquery.ui.core.js"></script> <script src="../../ui/jquery.ui.core.js"></script>
<script src="../../ui/jquery.ui.widget.js"></script> <script src="../../ui/jquery.ui.widget.js"></script>
<script src="../../ui/jquery.ui.mouse.js"></script> <script src="../../ui/jquery.ui.mouse.js"></script>

View File

@ -5,7 +5,6 @@
<title>jQuery UI Dialog - Modal form</title> <title>jQuery UI Dialog - Modal form</title>
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script src="../../jquery-1.8.2.js"></script> <script src="../../jquery-1.8.2.js"></script>
<script src="../../external/jquery.bgiframe-2.1.2.js"></script>
<script src="../../ui/jquery.ui.core.js"></script> <script src="../../ui/jquery.ui.core.js"></script>
<script src="../../ui/jquery.ui.widget.js"></script> <script src="../../ui/jquery.ui.widget.js"></script>
<script src="../../ui/jquery.ui.mouse.js"></script> <script src="../../ui/jquery.ui.mouse.js"></script>

View File

@ -5,7 +5,6 @@
<title>jQuery UI Dialog - Modal message</title> <title>jQuery UI Dialog - Modal message</title>
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script src="../../jquery-1.8.2.js"></script> <script src="../../jquery-1.8.2.js"></script>
<script src="../../external/jquery.bgiframe-2.1.2.js"></script>
<script src="../../ui/jquery.ui.core.js"></script> <script src="../../ui/jquery.ui.core.js"></script>
<script src="../../ui/jquery.ui.widget.js"></script> <script src="../../ui/jquery.ui.widget.js"></script>
<script src="../../ui/jquery.ui.mouse.js"></script> <script src="../../ui/jquery.ui.mouse.js"></script>

View File

@ -5,7 +5,6 @@
<title>jQuery UI Dialog - Basic modal</title> <title>jQuery UI Dialog - Basic modal</title>
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script src="../../jquery-1.8.2.js"></script> <script src="../../jquery-1.8.2.js"></script>
<script src="../../external/jquery.bgiframe-2.1.2.js"></script>
<script src="../../ui/jquery.ui.core.js"></script> <script src="../../ui/jquery.ui.core.js"></script>
<script src="../../ui/jquery.ui.widget.js"></script> <script src="../../ui/jquery.ui.widget.js"></script>
<script src="../../ui/jquery.ui.mouse.js"></script> <script src="../../ui/jquery.ui.mouse.js"></script>

View File

@ -15,7 +15,7 @@
<script src="../../ui/jquery.ui.dialog.js"></script> <script src="../../ui/jquery.ui.dialog.js"></script>
<link rel="stylesheet" href="../demos.css"> <link rel="stylesheet" href="../demos.css">
<style> <style>
#gallery { float: left; width: 65%; min-height: 12em; } * html #gallery { height: 12em; } /* IE6 */ #gallery { float: left; width: 65%; min-height: 12em; }
.gallery.custom-state-active { background: #eee; } .gallery.custom-state-active { background: #eee; }
.gallery li { float: left; width: 96px; padding: 0.4em; margin: 0 0.4em 0.4em 0; text-align: center; } .gallery li { float: left; width: 96px; padding: 0.4em; margin: 0 0.4em 0.4em 0; text-align: center; }
.gallery li h5 { margin: 0 0 0.4em; cursor: move; } .gallery li h5 { margin: 0 0 0.4em; cursor: move; }
@ -23,7 +23,7 @@
.gallery li a.ui-icon-zoomin { float: left; } .gallery li a.ui-icon-zoomin { float: left; }
.gallery li img { width: 100%; cursor: move; } .gallery li img { width: 100%; cursor: move; }
#trash { float: right; width: 32%; min-height: 18em; padding: 1%;} * html #trash { height: 18em; } /* IE6 */ #trash { float: right; width: 32%; min-height: 18em; padding: 1%; }
#trash h4 { line-height: 16px; margin: 0 0 0.4em; } #trash h4 { line-height: 16px; margin: 0 0 0.4em; }
#trash h4 .ui-icon { float: left; } #trash h4 .ui-icon { float: left; }
#trash .gallery h5 { display: none; } #trash .gallery h5 { display: none; }

View File

@ -88,7 +88,7 @@
</div> </div>
<div class="demo-description"> <div class="demo-description">
<p>Demonstrate how to use an accordion to structure products into a catalog and make use drag and drop for adding them to a shopping cart, where they are sortable.</p> <p>Demonstrate how to use an accordion to structure products into a catalog and make use of drag and drop for adding them to a shopping cart, where they are sortable.</p>
</div> </div>
</body> </body>
</html> </html>

View File

@ -7,6 +7,7 @@
<script src="../../jquery-1.8.2.js"></script> <script src="../../jquery-1.8.2.js"></script>
<script src="../../ui/jquery.ui.core.js"></script> <script src="../../ui/jquery.ui.core.js"></script>
<script src="../../ui/jquery.ui.widget.js"></script> <script src="../../ui/jquery.ui.widget.js"></script>
<script src="../../ui/jquery.ui.position.js"></script>
<script src="../../ui/jquery.ui.menu.js"></script> <script src="../../ui/jquery.ui.menu.js"></script>
<link rel="stylesheet" href="../demos.css"> <link rel="stylesheet" href="../demos.css">
<script> <script>
@ -14,29 +15,53 @@
$( "#menu" ).menu(); $( "#menu" ).menu();
}); });
</script> </script>
<style>
.ui-menu { width: 150px; }
</style>
</head> </head>
<body> <body>
<ul id="menu"> <ul id="menu">
<li><a href="#Aberdeen">Aberdeen</a></li> <li class="ui-state-disabled"><a href="#">Aberdeen</a></li>
<li><a href="#Ada">Ada</a></li> <li><a href="#">Ada</a></li>
<li><a href="#Adamsville">Adamsville</a></li> <li><a href="#">Adamsville</a></li>
<li><a href="#Addyston">Addyston</a></li> <li><a href="#">Addyston</a></li>
<li><a href="#Adelphi">Adelphi</a></li> <li>
<li><a href="#Adena">Adena</a></li> <a href="#">Delphi</a>
<li><a href="#Adrian">Adrian</a></li> <ul>
<li><a href="#Akron">Akron</a></li> <li class="ui-state-disabled"><a href="#">Ada</a></li>
<li><a href="#Albany">Albany</a></li> <li><a href="#">Saarland</a></li>
<li><a href="#Alexandria">Alexandria</a></li> <li><a href="#">Salzburg</a></li>
<li><a href="#Alger">Alger</a></li> </ul>
<li><a href="#Alledonia">Alledonia</a></li> </li>
<li><a href="#Alliance">Alliance</a></li> <li><a href="#">Saarland</a></li>
<li><a href="#Alpha">Alpha</a></li> <li>
<li><a href="#Alvada">Alvada</a></li> <a href="#">Salzburg</a>
<ul>
<li>
<a href="#">Delphi</a>
<ul>
<li><a href="#">Ada</a></li>
<li><a href="#">Saarland</a></li>
<li><a href="#">Salzburg</a></li>
</ul>
</li>
<li>
<a href="#">Delphi</a>
<ul>
<li><a href="#">Ada</a></li>
<li><a href="#">Saarland</a></li>
<li><a href="#">Salzburg</a></li>
</ul>
</li>
<li><a href="#">Perch</a></li>
</ul>
</li>
<li class="ui-state-disabled"><a href="#">Amesville</a></li>
</ul> </ul>
<div class="demo-description"> <div class="demo-description">
<p>A menu with the default configuration. A list is transformed, adding theming, mouse and keyboard navigation support. Try to tab to the menu then use the cursor keys to navigate.</p> <p>A menu with the default configuration, disabled items and nested menus. A list is transformed, adding theming, mouse and keyboard navigation support. Try to tab to the menu then use the cursor keys to navigate.</p>
</div> </div>
</body> </body>
</html> </html>

44
demos/menu/icons.html Normal file
View File

@ -0,0 +1,44 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Menu - Icons</title>
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script src="../../jquery-1.8.2.js"></script>
<script src="../../ui/jquery.ui.core.js"></script>
<script src="../../ui/jquery.ui.widget.js"></script>
<script src="../../ui/jquery.ui.position.js"></script>
<script src="../../ui/jquery.ui.menu.js"></script>
<link rel="stylesheet" href="../demos.css">
<script>
$(function() {
$( "#menu" ).menu();
});
</script>
<style>
.ui-menu { width: 150px; }
</style>
</head>
<body>
<ul id="menu">
<li><a href="#"><span class="ui-icon ui-icon-disk"></span>Save</a></li>
<li><a href="#"><span class="ui-icon ui-icon-zoomin"></span>Zoom In</a></li>
<li><a href="#"><span class="ui-icon ui-icon-zoomout"></span>Zoom Out</a></li>
<li class="ui-state-disabled"><a href="#"><span class="ui-icon ui-icon-print"></span>Print...</a></li>
<li>
<a href="#">Playback</a>
<ul>
<li><a href="#"><span class="ui-icon ui-icon-seek-start"></span>Prev</a></li>
<li><a href="#"><span class="ui-icon ui-icon-stop"></span>Stop</a></li>
<li><a href="#"><span class="ui-icon ui-icon-play"></span>Play</a></li>
<li><a href="#"><span class="ui-icon ui-icon-seek-end"></span>Next</a></li>
</ul>
</li>
</ul>
<div class="demo-description">
<p>A menu with the default configuration, showing how to use a menu with icons.</p>
</div>
</body>
</html>

View File

@ -8,8 +8,7 @@
<ul> <ul>
<li><a href="default.html">Default functionality</a></li> <li><a href="default.html">Default functionality</a></li>
<li><a href="topalignmenu.html">Top-aligned sub menus</a></li> <li><a href="icons.html">Icons</a></li>
<li><a href="navigationmenu.html">Navigation menu</a></li>
</ul> </ul>
</body> </body>

View File

@ -1,74 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Menu - Navigation Menu</title>
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script src="../../jquery-1.8.2.js"></script>
<script src="../../ui/jquery.ui.core.js"></script>
<script src="../../ui/jquery.ui.widget.js"></script>
<script src="../../ui/jquery.ui.position.js"></script>
<script src="../../ui/jquery.ui.menu.js"></script>
<link rel="stylesheet" href="../demos.css">
<script>
$(function() {
$( "#menu" ).menu({
select: function( event, ui ) {
var link = ui.item.children( "a:first" );
if ( link.attr( "target" ) || event.metaKey || event.shiftKey || event.ctrlKey ) {
return;
}
location.href = link.attr( "href" );
}
});
});
</script>
<style>
.ui-menu { width: 200px; margin-bottom: 2em; }
</style>
</head>
<body>
<ul id="menu">
<li><a href="?Aberdeen">Aberdeen</a></li>
<li><a href="?Ada">Ada</a></li>
<li><a href="?Adamsville">Adamsville</a></li>
<li><a href="?Addyston">Addyston</a></li>
<li>
<a href="?Delphi">Delphi</a>
<ul>
<li><a href="?Ada">Ada</a></li>
<li><a href="?Saarland">Saarland</a></li>
<li><a href="?Salzburg">Salzburg</a></li>
</ul>
</li>
<li><a href="?Saarland">Saarland</a></li>
<li>
<a href="?Salzburg">Salzburg</a>
<ul>
<li>
<a href="?Delphi">Delphi</a>
<ul>
<li><a href="?Ada">Ada</a></li>
<li><a href="?Saarland">Saarland</a></li>
<li><a href="?Salzburg">Salzburg</a></li>
</ul>
</li>
<li>
<a href="?Delphi">Delphi</a>
<ul>
<li><a href="?Ada">Ada</a></li>
<li><a href="?Saarland">Saarland</a></li>
<li><a href="?Salzburg">Salzburg</a></li>
</ul>
</li>
<li><a href="?Perch">Perch</a></li>
</ul>
</li>
</ul>
<div class="demo-description">
<p>A navigation menu. A list is transformed, adding theming, mouse and keyboard navigation support. Try to tab to the menu then use the cursor keys to navigate.</p>
</div>
</body>
</html>

View File

@ -1,87 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Menu Demo: Top-aligned Menu</title>
<link rel="stylesheet" href="../demos.css">
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script src="../../jquery-1.8.2.js"></script>
<script src="../../ui/jquery.ui.core.js"></script>
<script src="../../ui/jquery.ui.widget.js"></script>
<script src="../../ui/jquery.ui.position.js"></script>
<script src="../../ui/jquery.ui.menu.js"></script>
<script>
$(function() {
$( "#menu" ).menu({
position: { of: "ul:has(a.ui-state-focus):last" },
icons: {
submenu: "ui-icon-carat-1-e"
}
});
});
</script>
<style>
.ui-menu { width: 200px; margin-bottom: 2em; }
</style>
</head>
<body>
<ul id="menu">
<li><a href="#">Aberdeen</a></li>
<li><a href="#">Ada</a></li>
<li><a href="#">Adamsville</a></li>
<li><a href="#">Addyston</a></li>
<li>
<a href="#">Delphi</a>
<ul>
<li><a href="#">Ada</a></li>
<li><a href="#">Saarland</a></li>
<li><a href="#">Salzburg</a></li>
</ul>
</li>
<li><a href="#">Saarland</a></li>
<li>
<a href="#">Salzburg</a>
<ul>
<li>
<a href="#">Delphi</a>
<ul>
<li><a href="#">Ada</a></li>
<li><a href="#">Saarland</a></li>
<li><a href="#">Salzburg</a></li>
</ul>
</li>
<li>
<a href="#">Adamsville</a>
<ul>
<li><a href="#">Aberdeen</a></li>
<li><a href="#">Ada</a></li>
<li><a href="#">Adamsville</a></li>
<li><a href="#">Addyston</a></li>
<li>
<a href="#">Delphi</a>
<ul>
<li><a href="#">Ada</a></li>
<li><a href="#">Saarland</a></li>
<li><a href="#">Salzburg</a></li>
</ul>
</li>
<li><a href="#">Saarland</a></li>
</ul>
</li>
<li><a href="#">Perch</a>
<ul>
<li><a href="#">Addyston</a></li>
<li><a href="#">Delphi</a></li>
<li><a href="#">Perch</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<div class="demo-description">
<p>Menus can use custom positioning. There is a delay before activing an item on hover and a delay before closing a menu on mouse out to allow for moving to a submenu that is not touching its parent item.</p>
</div>
</body>
</html>

View File

@ -10,6 +10,9 @@
<script src="../../ui/jquery.ui.position.js"></script> <script src="../../ui/jquery.ui.position.js"></script>
<link rel="stylesheet" href="../demos.css"> <link rel="stylesheet" href="../demos.css">
<style> <style>
body {
margin: 0;
}
#container { #container {
overflow: hidden; overflow: hidden;
position: relative; position: relative;
@ -96,10 +99,9 @@
</div> </div>
<div class="demo-description"> <div class="demo-description">
<p>A prototype for the <a href="http://wiki.jqueryui.com/Photoviewer">Photoviewer</a> using Position to place images at the center, left and right and cycle them. <p>A photoviewer prototype using Position to place images at the center, left and right and cycle them.
<br>Use the links at the top to cycle, or click on the images on the left and right. <br>Use the links at the top to cycle, or click on the images on the left and right.
<br>Note how the images are repositioned when resizing the window. <br>Note how the images are repositioned when resizing the window.
<br>Warning: Doesn't currently work inside the demo viewer; open in a new window instead!</p>
</div> </div>
</body> </body>
</html> </html>

View File

@ -48,7 +48,6 @@
of: $( "#parent" ), of: $( "#parent" ),
my: $( "#my_horizontal" ).val() + " " + $( "#my_vertical" ).val(), my: $( "#my_horizontal" ).val() + " " + $( "#my_vertical" ).val(),
at: $( "#at_horizontal" ).val() + " " + $( "#at_vertical" ).val(), at: $( "#at_horizontal" ).val() + " " + $( "#at_vertical" ).val(),
offset: $( "#offset" ).val(),
collision: $( "#collision_horizontal" ).val() + " " + $( "#collision_vertical" ).val() collision: $( "#collision_horizontal" ).val() + " " + $( "#collision_vertical" ).val()
}); });
} }
@ -113,10 +112,6 @@
<option value="bottom">bottom</option> <option value="bottom">bottom</option>
</select> </select>
</div> </div>
<div style="padding-bottom: 20px;">
<b>offset:</b>
<input id="offset">
</div>
<div style="padding-bottom: 20px;"> <div style="padding-bottom: 20px;">
<b>collision:</b> <b>collision:</b>
<select id="collision_horizontal"> <select id="collision_horizontal">

View File

@ -2,7 +2,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>jQuery UI Slider - Range with fixed minimum</title> <title>jQuery UI Slider - Slider bound to select</title>
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script src="../../jquery-1.8.2.js"></script> <script src="../../jquery-1.8.2.js"></script>
<script src="../../ui/jquery.ui.core.js"></script> <script src="../../ui/jquery.ui.core.js"></script>

View File

@ -14,7 +14,6 @@
.scroll-pane { overflow: auto; width: 99%; float:left; } .scroll-pane { overflow: auto; width: 99%; float:left; }
.scroll-content { width: 2440px; float: left; } .scroll-content { width: 2440px; float: left; }
.scroll-content-item { width: 100px; height: 100px; float: left; margin: 10px; font-size: 3em; line-height: 96px; text-align: center; } .scroll-content-item { width: 100px; height: 100px; float: left; margin: 10px; font-size: 3em; line-height: 96px; text-align: center; }
* html .scroll-content-item { display: inline; } /* IE6 float double margin bug */
.scroll-bar-wrap { clear: left; padding: 0 4px 0 2px; margin: 0 -1px -1px -1px; } .scroll-bar-wrap { clear: left; padding: 0 4px 0 2px; margin: 0 -1px -1px -1px; }
.scroll-bar-wrap .ui-slider { background: none; border:0; height: 2em; margin: 0 auto; } .scroll-bar-wrap .ui-slider { background: none; border:0; height: 2em; margin: 0 auto; }
.scroll-bar-wrap .ui-handle-helper-parent { position: relative; width: 100%; height: 100%; margin: 0 auto; } .scroll-bar-wrap .ui-handle-helper-parent { position: relative; width: 100%; height: 100%; margin: 0 auto; }

View File

@ -22,6 +22,9 @@
width: 350px; width: 350px;
height: 350px; height: 350px;
} }
.ui-tooltip {
max-width: 350px;
}
</style> </style>
<script> <script>
$(function() { $(function() {

View File

@ -2,7 +2,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>jQuery UI Tooltip - Default demo</title> <title>jQuery UI Tooltip - Forms</title>
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script src="../../jquery-1.8.2.js"></script> <script src="../../jquery-1.8.2.js"></script>
<script src="../../ui/jquery.ui.core.js"></script> <script src="../../ui/jquery.ui.core.js"></script>

View File

@ -1,39 +0,0 @@
/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
* Licensed under the MIT License (LICENSE.txt).
*
* Version 2.1.2
*/
(function($){
$.fn.bgiframe = ($.browser.msie && /msie 6\.0/i.test(navigator.userAgent) ? function(s) {
s = $.extend({
top : 'auto', // auto == .currentStyle.borderTopWidth
left : 'auto', // auto == .currentStyle.borderLeftWidth
width : 'auto', // auto == offsetWidth
height : 'auto', // auto == offsetHeight
opacity : true,
src : 'javascript:false;'
}, s);
var html = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+
'style="display:block;position:absolute;z-index:-1;'+
(s.opacity !== false?'filter:Alpha(Opacity=\'0\');':'')+
'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+
'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+
'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+
'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+
'"/>';
return this.each(function() {
if ( $(this).children('iframe.bgiframe').length === 0 )
this.insertBefore( document.createElement(html), this.firstChild );
});
} : function() { return this; });
// old alias
$.fn.bgIframe = $.fn.bgiframe;
function prop(n) {
return n && n.constructor === Number ? n + 'px' : n;
}
})(jQuery);

View File

@ -1,89 +0,0 @@
/*jslint browser: true */ /*global jQuery: true */
/**
* jQuery Cookie plugin
*
* Copyright (c) 2010 Klaus Hartl (stilbuero.de)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
// TODO JsDoc
/**
* Create a cookie with the given key and value and other optional parameters.
*
* @example $.cookie('the_cookie', 'the_value');
* @desc Set the value of a cookie.
* @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
* @desc Create a cookie with all available options.
* @example $.cookie('the_cookie', 'the_value');
* @desc Create a session cookie.
* @example $.cookie('the_cookie', null);
* @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
* used when the cookie was set.
*
* @param String key The key of the cookie.
* @param String value The value of the cookie.
* @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
* @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
* If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
* If set to null or omitted, the cookie will be a session cookie and will not be retained
* when the the browser exits.
* @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
* @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
* @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
* require a secure protocol (like HTTPS).
* @type undefined
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/
/**
* Get the value of a cookie with the given key.
*
* @example $.cookie('the_cookie');
* @desc Get the value of a cookie.
*
* @param String key The key of the cookie.
* @return The value of the cookie.
* @type String
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/
jQuery.cookie = function (key, value, options) {
// key and value given, set cookie...
if (arguments.length > 1 && (value === null || typeof value !== "object")) {
options = jQuery.extend({}, options);
if (value === null) {
options.expires = -1;
}
if (typeof options.expires === 'number') {
var days = options.expires, t = options.expires = new Date();
t.setDate(t.getDate() + days);
}
return (document.cookie = [
encodeURIComponent(key), '=',
options.raw ? String(value) : encodeURIComponent(String(value)),
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
options.path ? '; path=' + options.path : '',
options.domain ? '; domain=' + options.domain : '',
options.secure ? '; secure' : ''
].join(''));
}
// key and possibly options given, get cookie...
options = value || {};
var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};

View File

@ -1,122 +0,0 @@
/*
* Metadata - jQuery plugin for parsing metadata from elements
*
* Copyright (c) 2006 John Resig, Yehuda Katz, J<EFBFBD>örn Zaefferer, Paul McLanahan
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* Revision: $Id: jquery.metadata.js 4187 2007-12-16 17:15:27Z joern.zaefferer $
*
*/
/**
* Sets the type of metadata to use. Metadata is encoded in JSON, and each property
* in the JSON will become a property of the element itself.
*
* There are three supported types of metadata storage:
*
* attr: Inside an attribute. The name parameter indicates *which* attribute.
*
* class: Inside the class attribute, wrapped in curly braces: { }
*
* elem: Inside a child element (e.g. a script tag). The
* name parameter indicates *which* element.
*
* The metadata for an element is loaded the first time the element is accessed via jQuery.
*
* As a result, you can define the metadata type, use $(expr) to load the metadata into the elements
* matched by expr, then redefine the metadata type and run another $(expr) for other elements.
*
* @name $.metadata.setType
*
* @example <p id="one" class="some_class {item_id: 1, item_label: 'Label'}">This is a p</p>
* @before $.metadata.setType("class")
* @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
* @desc Reads metadata from the class attribute
*
* @example <p id="one" class="some_class" data="{item_id: 1, item_label: 'Label'}">This is a p</p>
* @before $.metadata.setType("attr", "data")
* @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
* @desc Reads metadata from a "data" attribute
*
* @example <p id="one" class="some_class"><script>{item_id: 1, item_label: 'Label'}</script>This is a p</p>
* @before $.metadata.setType("elem", "script")
* @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
* @desc Reads metadata from a nested script element
*
* @param String type The encoding type
* @param String name The name of the attribute to be used to get metadata (optional)
* @cat Plugins/Metadata
* @descr Sets the type of encoding to be used when loading metadata for the first time
* @type undefined
* @see metadata()
*/
(function($) {
$.extend({
metadata : {
defaults : {
type: 'class',
name: 'metadata',
cre: /({.*})/,
single: 'metadata'
},
setType: function( type, name ){
this.defaults.type = type;
this.defaults.name = name;
},
get: function( elem, opts ){
var settings = $.extend({},this.defaults,opts);
// check for empty string in single property
if ( !settings.single.length ) settings.single = 'metadata';
var data = $.data(elem, settings.single);
// returned cached data if it already exists
if ( data ) return data;
data = "{}";
if ( settings.type == "class" ) {
var m = settings.cre.exec( elem.className );
if ( m )
data = m[1];
} else if ( settings.type == "elem" ) {
if( !elem.getElementsByTagName )
return undefined;
var e = elem.getElementsByTagName(settings.name);
if ( e.length )
data = $.trim(e[0].innerHTML);
} else if ( elem.getAttribute != undefined ) {
var attr = elem.getAttribute( settings.name );
if ( attr )
data = attr;
}
if ( data.indexOf( '{' ) <0 )
data = "{" + data + "}";
data = eval("(" + data + ")");
$.data( elem, settings.single, data );
return data;
}
}
});
/**
* Returns the metadata object for the first member of the jQuery object.
*
* @name metadata
* @descr Returns element's metadata object
* @param Object opts An object contianing settings to override the defaults
* @type jQuery
* @cat Plugins/Metadata
*/
$.fn.metadata = function( opts ){
return $.metadata.get( this[0], opts );
};
})(jQuery);

2791
external/jshint.js vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,7 @@
/*jshint node: true */
module.exports = function( grunt ) { module.exports = function( grunt ) {
"use strict";
var var
// files // files
coreFiles = [ coreFiles = [
@ -161,6 +162,7 @@ grunt.initConfig({
"package.json", "package.json",
"*.jquery.json", "*.jquery.json",
"ui/**/*", "ui/**/*",
"ui/.jshintrc",
"demos/**/*", "demos/**/*",
"themes/**/*", "themes/**/*",
"external/**/*", "external/**/*",
@ -279,14 +281,11 @@ grunt.initConfig({
files: grunt.file.expandFiles( "tests/unit/**/*.html" ).filter(function( file ) { files: grunt.file.expandFiles( "tests/unit/**/*.html" ).filter(function( file ) {
// disabling everything that doesn't (quite) work with PhantomJS for now // disabling everything that doesn't (quite) work with PhantomJS for now
// TODO except for all|index|test, try to include more as we go // TODO except for all|index|test, try to include more as we go
return !( /(all|all-active|index|test|draggable|droppable|selectable|resizable|sortable|dialog|slider|datepicker|tabs|tabs_deprecated)\.html$/ ).test( file ); return !( /(all|index|test|dialog|tabs|tooltip)\.html$/ ).test( file );
}) })
}, },
lint: { lint: {
ui: grunt.file.expandFiles( "ui/*.js" ).filter(function( file ) { ui: "ui/*.js",
// TODO remove items from this list once rewritten
return !( /(mouse|datepicker|draggable|droppable|resizable|selectable|sortable)\.js$/ ).test( file );
}),
grunt: [ "grunt.js", "build/**/*.js" ], grunt: [ "grunt.js", "build/**/*.js" ],
tests: "tests/unit/**/*.js" tests: "tests/unit/**/*.js"
}, },
@ -304,7 +303,8 @@ grunt.initConfig({
"important": false, "important": false,
"outline-none": false, "outline-none": false,
// especially this one // especially this one
"overqualified-elements": false "overqualified-elements": false,
"compatible-vendor-prefixes": false
} }
} }
}, },
@ -325,9 +325,7 @@ grunt.initConfig({
} }
return { return {
// TODO: use "faux strict mode" https://github.com/jshint/jshint/issues/504 grunt: parserc(),
// TODO: limit `smarttabs` to multi-line comments https://github.com/jshint/jshint/issues/503
options: parserc(),
ui: parserc( "ui/" ), ui: parserc( "ui/" ),
// TODO: `evil: true` is only for document.write() https://github.com/jshint/jshint/issues/519 // TODO: `evil: true` is only for document.write() https://github.com/jshint/jshint/issues/519
// TODO: don't create so many globals in tests // TODO: don't create so many globals in tests

3328
jquery-1.8.2.js vendored

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
"name": "jquery-ui", "name": "jquery-ui",
"title": "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.", "description": "A curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library.",
"version": "1.9.1pre", "version": "1.10.0pre",
"homepage": "http://jqueryui.com", "homepage": "http://jqueryui.com",
"author": { "author": {
"name": "jQuery Foundation and other contributors", "name": "jQuery Foundation and other contributors",
@ -19,11 +19,6 @@
"email": "joern.zaefferer@gmail.com", "email": "joern.zaefferer@gmail.com",
"url": "http://bassistance.de" "url": "http://bassistance.de"
}, },
{
"name": "Richard D. Worth",
"email": "rdworth@gmail.com",
"url": "http://rdworth.org"
},
{ {
"name": "Kris Borchers", "name": "Kris Borchers",
"email": "kris.borchers@gmail.com", "email": "kris.borchers@gmail.com",
@ -48,7 +43,7 @@
], ],
"dependencies": {}, "dependencies": {},
"devDependencies": { "devDependencies": {
"grunt": "~0.3.9", "grunt": "~0.3.17",
"grunt-css": "0.2.0", "grunt-css": "0.2.0",
"grunt-compare-size": "0.1.4", "grunt-compare-size": "0.1.4",
"grunt-html": "0.1.1", "grunt-html": "0.1.1",

View File

@ -9,51 +9,26 @@
"latedef": true, "latedef": true,
"noarg": true, "noarg": true,
"onevar": true, "onevar": true,
"smarttabs": true,
"trailing": true, "trailing": true,
"undef": true, "undef": true,
"unused": true,
"predef": [ "predef": [
"addMonths",
"asyncTest", "asyncTest",
"container", "closeEnough",
"deepEqual", "deepEqual",
"d1",
"d2",
"dlg",
"domEqual", "domEqual",
"drag",
"dragged",
"el",
"equal", "equal",
"equalsDate",
"expect", "expect",
"Globalize", "Globalize",
"heightAfter",
"init",
"isNotOpen",
"isOpen",
"modal",
"module", "module",
"moved",
"notEqual", "notEqual",
"offsetAfter",
"offsetBefore",
"ok", "ok",
"PROP_NAME",
"QUnit", "QUnit",
"restoreScroll",
"shouldBeDroppable",
"shouldmove",
"shouldNotBeDroppable",
"shouldnotmove",
"shouldnotresize",
"shouldresize",
"start", "start",
"strictEqual", "strictEqual",
"stop", "stop",
"test", "test",
"TestHelpers", "TestHelpers",
"widthAfter",
"JSHINT" "JSHINT"
] ]
} }

106
tests/jquery-1.6.1.js vendored
View File

@ -1895,11 +1895,11 @@ jQuery.fn.extend({
jQuery.removeAttr( this, name ); jQuery.removeAttr( this, name );
}); });
}, },
prop: function( name, value ) { prop: function( name, value ) {
return jQuery.access( this, name, value, true, jQuery.prop ); return jQuery.access( this, name, value, true, jQuery.prop );
}, },
removeProp: function( name ) { removeProp: function( name ) {
name = jQuery.propFix[ name ] || name; name = jQuery.propFix[ name ] || name;
return this.each(function() { return this.each(function() {
@ -2031,7 +2031,7 @@ jQuery.fn.extend({
val: function( value ) { val: function( value ) {
var hooks, ret, var hooks, ret,
elem = this[0]; elem = this[0];
if ( !arguments.length ) { if ( !arguments.length ) {
if ( elem ) { if ( elem ) {
hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ]; hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ];
@ -2159,15 +2159,15 @@ jQuery.extend({
height: true, height: true,
offset: true offset: true
}, },
attrFix: { attrFix: {
// Always normalize to ensure hook usage // Always normalize to ensure hook usage
tabindex: "tabIndex" tabindex: "tabIndex"
}, },
attr: function( elem, name, value, pass ) { attr: function( elem, name, value, pass ) {
var nType = elem.nodeType; var nType = elem.nodeType;
// don't get/set attributes on text, comment and attribute nodes // don't get/set attributes on text, comment and attribute nodes
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
return undefined; return undefined;
@ -2235,7 +2235,7 @@ jQuery.extend({
var propName; var propName;
if ( elem.nodeType === 1 ) { if ( elem.nodeType === 1 ) {
name = jQuery.attrFix[ name ] || name; name = jQuery.attrFix[ name ] || name;
if ( jQuery.support.getSetAttribute ) { if ( jQuery.support.getSetAttribute ) {
// Use removeAttribute in browsers that support it // Use removeAttribute in browsers that support it
elem.removeAttribute( name ); elem.removeAttribute( name );
@ -2299,7 +2299,7 @@ jQuery.extend({
frameborder: "frameBorder", frameborder: "frameBorder",
contenteditable: "contentEditable" contenteditable: "contentEditable"
}, },
prop: function( elem, name, value ) { prop: function( elem, name, value ) {
var nType = elem.nodeType; var nType = elem.nodeType;
@ -2313,7 +2313,7 @@ jQuery.extend({
// Try to normalize/fix the name // Try to normalize/fix the name
name = notxml && jQuery.propFix[ name ] || name; name = notxml && jQuery.propFix[ name ] || name;
hooks = jQuery.propHooks[ name ]; hooks = jQuery.propHooks[ name ];
if ( value !== undefined ) { if ( value !== undefined ) {
@ -2333,7 +2333,7 @@ jQuery.extend({
} }
} }
}, },
propHooks: {} propHooks: {}
}); });
@ -2388,7 +2388,7 @@ if ( !jQuery.support.getSetAttribute ) {
// propFix is more comprehensive and contains all fixes // propFix is more comprehensive and contains all fixes
jQuery.attrFix = jQuery.propFix; jQuery.attrFix = jQuery.propFix;
// Use this for any attribute on a form in IE6/7 // Use this for any attribute on a form in IE6/7
formHook = jQuery.attrHooks.name = jQuery.valHooks.button = { formHook = jQuery.attrHooks.name = jQuery.valHooks.button = {
get: function( elem, name ) { get: function( elem, name ) {
@ -2759,7 +2759,7 @@ jQuery.event = {
} }
} }
}, },
// Events that are safe to short-circuit if no handlers are attached. // Events that are safe to short-circuit if no handlers are attached.
// Native DOM events should not be added, they may have inline handlers. // Native DOM events should not be added, they may have inline handlers.
customEvent: { customEvent: {
@ -2805,7 +2805,7 @@ jQuery.event = {
event.exclusive = exclusive; event.exclusive = exclusive;
event.namespace = namespaces.join("."); event.namespace = namespaces.join(".");
event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)"); event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)");
// triggerHandler() and global events don't bubble or run the default action // triggerHandler() and global events don't bubble or run the default action
if ( onlyHandlers || !elem ) { if ( onlyHandlers || !elem ) {
event.preventDefault(); event.preventDefault();
@ -2896,7 +2896,7 @@ jQuery.event = {
jQuery.event.triggered = undefined; jQuery.event.triggered = undefined;
} }
} }
return event.result; return event.result;
}, },
@ -3731,7 +3731,7 @@ var Sizzle = function( selector, context, results, seed ) {
if ( context.nodeType !== 1 && context.nodeType !== 9 ) { if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
return []; return [];
} }
if ( !selector || typeof selector !== "string" ) { if ( !selector || typeof selector !== "string" ) {
return results; return results;
} }
@ -3741,7 +3741,7 @@ var Sizzle = function( selector, context, results, seed ) {
contextXML = Sizzle.isXML( context ), contextXML = Sizzle.isXML( context ),
parts = [], parts = [],
soFar = selector; soFar = selector;
// Reset the position of the chunker regexp (start from head) // Reset the position of the chunker regexp (start from head)
do { do {
chunker.exec( "" ); chunker.exec( "" );
@ -3749,9 +3749,9 @@ var Sizzle = function( selector, context, results, seed ) {
if ( m ) { if ( m ) {
soFar = m[3]; soFar = m[3];
parts.push( m[1] ); parts.push( m[1] );
if ( m[2] ) { if ( m[2] ) {
extra = m[3]; extra = m[3];
break; break;
@ -3775,7 +3775,7 @@ var Sizzle = function( selector, context, results, seed ) {
if ( Expr.relative[ selector ] ) { if ( Expr.relative[ selector ] ) {
selector += parts.shift(); selector += parts.shift();
} }
set = posProcess( selector, set ); set = posProcess( selector, set );
} }
} }
@ -3904,7 +3904,7 @@ Sizzle.find = function( expr, context, isXML ) {
for ( var i = 0, l = Expr.order.length; i < l; i++ ) { for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
var match, var match,
type = Expr.order[i]; type = Expr.order[i];
if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
var left = match[1]; var left = match[1];
match.splice( 1, 1 ); match.splice( 1, 1 );
@ -4236,7 +4236,7 @@ var Expr = Sizzle.selectors = {
ATTR: function( match, curLoop, inplace, result, not, isXML ) { ATTR: function( match, curLoop, inplace, result, not, isXML ) {
var name = match[1] = match[1].replace( rBackslash, "" ); var name = match[1] = match[1].replace( rBackslash, "" );
if ( !isXML && Expr.attrMap[name] ) { if ( !isXML && Expr.attrMap[name] ) {
match[1] = Expr.attrMap[name]; match[1] = Expr.attrMap[name];
} }
@ -4270,7 +4270,7 @@ var Expr = Sizzle.selectors = {
} else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
return true; return true;
} }
return match; return match;
}, },
@ -4280,7 +4280,7 @@ var Expr = Sizzle.selectors = {
return match; return match;
} }
}, },
filters: { filters: {
enabled: function( elem ) { enabled: function( elem ) {
return elem.disabled === false && elem.type !== "hidden"; return elem.disabled === false && elem.type !== "hidden";
@ -4293,14 +4293,14 @@ var Expr = Sizzle.selectors = {
checked: function( elem ) { checked: function( elem ) {
return elem.checked === true; return elem.checked === true;
}, },
selected: function( elem ) { selected: function( elem ) {
// Accessing this property makes selected-by-default // Accessing this property makes selected-by-default
// options in Safari work properly // options in Safari work properly
if ( elem.parentNode ) { if ( elem.parentNode ) {
elem.parentNode.selectedIndex; elem.parentNode.selectedIndex;
} }
return elem.selected === true; return elem.selected === true;
}, },
@ -4322,7 +4322,7 @@ var Expr = Sizzle.selectors = {
text: function( elem ) { text: function( elem ) {
var attr = elem.getAttribute( "type" ), type = elem.type; var attr = elem.getAttribute( "type" ), type = elem.type;
// IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
// use getAttribute instead to test this case // use getAttribute instead to test this case
return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null ); return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null );
}, },
@ -4438,21 +4438,21 @@ var Expr = Sizzle.selectors = {
case "only": case "only":
case "first": case "first":
while ( (node = node.previousSibling) ) { while ( (node = node.previousSibling) ) {
if ( node.nodeType === 1 ) { if ( node.nodeType === 1 ) {
return false; return false;
} }
} }
if ( type === "first" ) { if ( type === "first" ) {
return true; return true;
} }
node = elem; node = elem;
case "last": case "last":
while ( (node = node.nextSibling) ) { while ( (node = node.nextSibling) ) {
if ( node.nodeType === 1 ) { if ( node.nodeType === 1 ) {
return false; return false;
} }
} }
@ -4465,22 +4465,22 @@ var Expr = Sizzle.selectors = {
if ( first === 1 && last === 0 ) { if ( first === 1 && last === 0 ) {
return true; return true;
} }
var doneName = match[0], var doneName = match[0],
parent = elem.parentNode; parent = elem.parentNode;
if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) { if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
var count = 0; var count = 0;
for ( node = parent.firstChild; node; node = node.nextSibling ) { for ( node = parent.firstChild; node; node = node.nextSibling ) {
if ( node.nodeType === 1 ) { if ( node.nodeType === 1 ) {
node.nodeIndex = ++count; node.nodeIndex = ++count;
} }
} }
parent.sizcache = doneName; parent.sizcache = doneName;
} }
var diff = elem.nodeIndex - last; var diff = elem.nodeIndex - last;
if ( first === 0 ) { if ( first === 0 ) {
@ -4499,7 +4499,7 @@ var Expr = Sizzle.selectors = {
TAG: function( elem, match ) { TAG: function( elem, match ) {
return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match; return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
}, },
CLASS: function( elem, match ) { CLASS: function( elem, match ) {
return (" " + (elem.className || elem.getAttribute("class")) + " ") return (" " + (elem.className || elem.getAttribute("class")) + " ")
.indexOf( match ) > -1; .indexOf( match ) > -1;
@ -4565,7 +4565,7 @@ var makeArray = function( array, results ) {
results.push.apply( results, array ); results.push.apply( results, array );
return results; return results;
} }
return array; return array;
}; };
@ -4817,7 +4817,7 @@ if ( document.querySelectorAll ) {
if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
return; return;
} }
Sizzle = function( query, context, extra, seed ) { Sizzle = function( query, context, extra, seed ) {
context = context || document; context = context || document;
@ -4826,24 +4826,24 @@ if ( document.querySelectorAll ) {
if ( !seed && !Sizzle.isXML(context) ) { if ( !seed && !Sizzle.isXML(context) ) {
// See if we find a selector to speed up // See if we find a selector to speed up
var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query ); var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
if ( match && (context.nodeType === 1 || context.nodeType === 9) ) { if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
// Speed-up: Sizzle("TAG") // Speed-up: Sizzle("TAG")
if ( match[1] ) { if ( match[1] ) {
return makeArray( context.getElementsByTagName( query ), extra ); return makeArray( context.getElementsByTagName( query ), extra );
// Speed-up: Sizzle(".CLASS") // Speed-up: Sizzle(".CLASS")
} else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) { } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
return makeArray( context.getElementsByClassName( match[2] ), extra ); return makeArray( context.getElementsByClassName( match[2] ), extra );
} }
} }
if ( context.nodeType === 9 ) { if ( context.nodeType === 9 ) {
// Speed-up: Sizzle("body") // Speed-up: Sizzle("body")
// The body element only exists once, optimize finding it // The body element only exists once, optimize finding it
if ( query === "body" && context.body ) { if ( query === "body" && context.body ) {
return makeArray( [ context.body ], extra ); return makeArray( [ context.body ], extra );
// Speed-up: Sizzle("#ID") // Speed-up: Sizzle("#ID")
} else if ( match && match[3] ) { } else if ( match && match[3] ) {
var elem = context.getElementById( match[3] ); var elem = context.getElementById( match[3] );
@ -4856,12 +4856,12 @@ if ( document.querySelectorAll ) {
if ( elem.id === match[3] ) { if ( elem.id === match[3] ) {
return makeArray( [ elem ], extra ); return makeArray( [ elem ], extra );
} }
} else { } else {
return makeArray( [], extra ); return makeArray( [], extra );
} }
} }
try { try {
return makeArray( context.querySelectorAll(query), extra ); return makeArray( context.querySelectorAll(query), extra );
} catch(qsaError) {} } catch(qsaError) {}
@ -4899,7 +4899,7 @@ if ( document.querySelectorAll ) {
} }
} }
} }
return oldSizzle(query, context, extra, seed); return oldSizzle(query, context, extra, seed);
}; };
@ -4926,7 +4926,7 @@ if ( document.querySelectorAll ) {
// This should fail with an exception // This should fail with an exception
// Gecko does not error, returns false instead // Gecko does not error, returns false instead
matches.call( document.documentElement, "[test!='']:sizzle" ); matches.call( document.documentElement, "[test!='']:sizzle" );
} catch( pseudoError ) { } catch( pseudoError ) {
pseudoWorks = true; pseudoWorks = true;
} }
@ -4936,7 +4936,7 @@ if ( document.querySelectorAll ) {
expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
if ( !Sizzle.isXML( node ) ) { if ( !Sizzle.isXML( node ) ) {
try { try {
if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) { if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
var ret = matches.call( node, expr ); var ret = matches.call( node, expr );
@ -4973,7 +4973,7 @@ if ( document.querySelectorAll ) {
if ( div.getElementsByClassName("e").length === 1 ) { if ( div.getElementsByClassName("e").length === 1 ) {
return; return;
} }
Expr.order.splice(1, 0, "CLASS"); Expr.order.splice(1, 0, "CLASS");
Expr.find.CLASS = function( match, context, isXML ) { Expr.find.CLASS = function( match, context, isXML ) {
if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
@ -5024,7 +5024,7 @@ function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
if ( elem ) { if ( elem ) {
var match = false; var match = false;
elem = elem[dir]; elem = elem[dir];
while ( elem ) { while ( elem ) {
@ -5077,7 +5077,7 @@ if ( document.documentElement.contains ) {
Sizzle.isXML = function( elem ) { Sizzle.isXML = function( elem ) {
// documentElement is verified for cases where it doesn't yet exist // documentElement is verified for cases where it doesn't yet exist
// (such as loading iframes in IE - #4833) // (such as loading iframes in IE - #4833)
var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
return documentElement ? documentElement.nodeName !== "HTML" : false; return documentElement ? documentElement.nodeName !== "HTML" : false;
@ -5198,7 +5198,7 @@ jQuery.fn.extend({
closest: function( selectors, context ) { closest: function( selectors, context ) {
var ret = [], i, l, cur = this[0]; var ret = [], i, l, cur = this[0];
// Array // Array
if ( jQuery.isArray( selectors ) ) { if ( jQuery.isArray( selectors ) ) {
var match, selector, var match, selector,

110
tests/jquery-1.6.2.js vendored
View File

@ -1511,7 +1511,7 @@ jQuery.extend({
return thisCache[ internalKey ] && thisCache[ internalKey ].events; return thisCache[ internalKey ] && thisCache[ internalKey ].events;
} }
return getByName ? return getByName ?
// Check for both converted-to-camel and non-converted data property names // Check for both converted-to-camel and non-converted data property names
thisCache[ jQuery.camelCase( name ) ] || thisCache[ name ] : thisCache[ jQuery.camelCase( name ) ] || thisCache[ name ] :
thisCache; thisCache;
@ -1923,11 +1923,11 @@ jQuery.fn.extend({
jQuery.removeAttr( this, name ); jQuery.removeAttr( this, name );
}); });
}, },
prop: function( name, value ) { prop: function( name, value ) {
return jQuery.access( this, name, value, true, jQuery.prop ); return jQuery.access( this, name, value, true, jQuery.prop );
}, },
removeProp: function( name ) { removeProp: function( name ) {
name = jQuery.propFix[ name ] || name; name = jQuery.propFix[ name ] || name;
return this.each(function() { return this.each(function() {
@ -2060,7 +2060,7 @@ jQuery.fn.extend({
val: function( value ) { val: function( value ) {
var hooks, ret, var hooks, ret,
elem = this[0]; elem = this[0];
if ( !arguments.length ) { if ( !arguments.length ) {
if ( elem ) { if ( elem ) {
hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ]; hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ];
@ -2071,9 +2071,9 @@ jQuery.fn.extend({
ret = elem.value; ret = elem.value;
return typeof ret === "string" ? return typeof ret === "string" ?
// handle most common string cases // handle most common string cases
ret.replace(rreturn, "") : ret.replace(rreturn, "") :
// handle cases where value is null/undef or number // handle cases where value is null/undef or number
ret == null ? "" : ret; ret == null ? "" : ret;
} }
@ -2194,15 +2194,15 @@ jQuery.extend({
height: true, height: true,
offset: true offset: true
}, },
attrFix: { attrFix: {
// Always normalize to ensure hook usage // Always normalize to ensure hook usage
tabindex: "tabIndex" tabindex: "tabIndex"
}, },
attr: function( elem, name, value, pass ) { attr: function( elem, name, value, pass ) {
var nType = elem.nodeType; var nType = elem.nodeType;
// don't get/set attributes on text, comment and attribute nodes // don't get/set attributes on text, comment and attribute nodes
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
return undefined; return undefined;
@ -2273,7 +2273,7 @@ jQuery.extend({
var propName; var propName;
if ( elem.nodeType === 1 ) { if ( elem.nodeType === 1 ) {
name = jQuery.attrFix[ name ] || name; name = jQuery.attrFix[ name ] || name;
if ( jQuery.support.getSetAttribute ) { if ( jQuery.support.getSetAttribute ) {
// Use removeAttribute in browsers that support it // Use removeAttribute in browsers that support it
elem.removeAttribute( name ); elem.removeAttribute( name );
@ -2356,7 +2356,7 @@ jQuery.extend({
frameborder: "frameBorder", frameborder: "frameBorder",
contenteditable: "contentEditable" contenteditable: "contentEditable"
}, },
prop: function( elem, name, value ) { prop: function( elem, name, value ) {
var nType = elem.nodeType; var nType = elem.nodeType;
@ -2391,7 +2391,7 @@ jQuery.extend({
} }
} }
}, },
propHooks: {} propHooks: {}
}); });
@ -2428,7 +2428,7 @@ if ( !jQuery.support.getSetAttribute ) {
// propFix is more comprehensive and contains all fixes // propFix is more comprehensive and contains all fixes
jQuery.attrFix = jQuery.propFix; jQuery.attrFix = jQuery.propFix;
// Use this for any attribute on a form in IE6/7 // Use this for any attribute on a form in IE6/7
formHook = jQuery.attrHooks.name = jQuery.attrHooks.title = jQuery.valHooks.button = { formHook = jQuery.attrHooks.name = jQuery.attrHooks.title = jQuery.valHooks.button = {
get: function( elem, name ) { get: function( elem, name ) {
@ -2798,7 +2798,7 @@ jQuery.event = {
} }
} }
}, },
// Events that are safe to short-circuit if no handlers are attached. // Events that are safe to short-circuit if no handlers are attached.
// Native DOM events should not be added, they may have inline handlers. // Native DOM events should not be added, they may have inline handlers.
customEvent: { customEvent: {
@ -2844,7 +2844,7 @@ jQuery.event = {
event.exclusive = exclusive; event.exclusive = exclusive;
event.namespace = namespaces.join("."); event.namespace = namespaces.join(".");
event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)"); event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)");
// triggerHandler() and global events don't bubble or run the default action // triggerHandler() and global events don't bubble or run the default action
if ( onlyHandlers || !elem ) { if ( onlyHandlers || !elem ) {
event.preventDefault(); event.preventDefault();
@ -2935,7 +2935,7 @@ jQuery.event = {
jQuery.event.triggered = undefined; jQuery.event.triggered = undefined;
} }
} }
return event.result; return event.result;
}, },
@ -3763,7 +3763,7 @@ var Sizzle = function( selector, context, results, seed ) {
if ( context.nodeType !== 1 && context.nodeType !== 9 ) { if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
return []; return [];
} }
if ( !selector || typeof selector !== "string" ) { if ( !selector || typeof selector !== "string" ) {
return results; return results;
} }
@ -3773,7 +3773,7 @@ var Sizzle = function( selector, context, results, seed ) {
contextXML = Sizzle.isXML( context ), contextXML = Sizzle.isXML( context ),
parts = [], parts = [],
soFar = selector; soFar = selector;
// Reset the position of the chunker regexp (start from head) // Reset the position of the chunker regexp (start from head)
do { do {
chunker.exec( "" ); chunker.exec( "" );
@ -3781,9 +3781,9 @@ var Sizzle = function( selector, context, results, seed ) {
if ( m ) { if ( m ) {
soFar = m[3]; soFar = m[3];
parts.push( m[1] ); parts.push( m[1] );
if ( m[2] ) { if ( m[2] ) {
extra = m[3]; extra = m[3];
break; break;
@ -3807,7 +3807,7 @@ var Sizzle = function( selector, context, results, seed ) {
if ( Expr.relative[ selector ] ) { if ( Expr.relative[ selector ] ) {
selector += parts.shift(); selector += parts.shift();
} }
set = posProcess( selector, set ); set = posProcess( selector, set );
} }
} }
@ -3936,7 +3936,7 @@ Sizzle.find = function( expr, context, isXML ) {
for ( var i = 0, l = Expr.order.length; i < l; i++ ) { for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
var match, var match,
type = Expr.order[i]; type = Expr.order[i];
if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
var left = match[1]; var left = match[1];
match.splice( 1, 1 ); match.splice( 1, 1 );
@ -4268,7 +4268,7 @@ var Expr = Sizzle.selectors = {
ATTR: function( match, curLoop, inplace, result, not, isXML ) { ATTR: function( match, curLoop, inplace, result, not, isXML ) {
var name = match[1] = match[1].replace( rBackslash, "" ); var name = match[1] = match[1].replace( rBackslash, "" );
if ( !isXML && Expr.attrMap[name] ) { if ( !isXML && Expr.attrMap[name] ) {
match[1] = Expr.attrMap[name]; match[1] = Expr.attrMap[name];
} }
@ -4302,7 +4302,7 @@ var Expr = Sizzle.selectors = {
} else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
return true; return true;
} }
return match; return match;
}, },
@ -4312,7 +4312,7 @@ var Expr = Sizzle.selectors = {
return match; return match;
} }
}, },
filters: { filters: {
enabled: function( elem ) { enabled: function( elem ) {
return elem.disabled === false && elem.type !== "hidden"; return elem.disabled === false && elem.type !== "hidden";
@ -4325,14 +4325,14 @@ var Expr = Sizzle.selectors = {
checked: function( elem ) { checked: function( elem ) {
return elem.checked === true; return elem.checked === true;
}, },
selected: function( elem ) { selected: function( elem ) {
// Accessing this property makes selected-by-default // Accessing this property makes selected-by-default
// options in Safari work properly // options in Safari work properly
if ( elem.parentNode ) { if ( elem.parentNode ) {
elem.parentNode.selectedIndex; elem.parentNode.selectedIndex;
} }
return elem.selected === true; return elem.selected === true;
}, },
@ -4354,7 +4354,7 @@ var Expr = Sizzle.selectors = {
text: function( elem ) { text: function( elem ) {
var attr = elem.getAttribute( "type" ), type = elem.type; var attr = elem.getAttribute( "type" ), type = elem.type;
// IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
// use getAttribute instead to test this case // use getAttribute instead to test this case
return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null ); return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null );
}, },
@ -4470,21 +4470,21 @@ var Expr = Sizzle.selectors = {
case "only": case "only":
case "first": case "first":
while ( (node = node.previousSibling) ) { while ( (node = node.previousSibling) ) {
if ( node.nodeType === 1 ) { if ( node.nodeType === 1 ) {
return false; return false;
} }
} }
if ( type === "first" ) { if ( type === "first" ) {
return true; return true;
} }
node = elem; node = elem;
case "last": case "last":
while ( (node = node.nextSibling) ) { while ( (node = node.nextSibling) ) {
if ( node.nodeType === 1 ) { if ( node.nodeType === 1 ) {
return false; return false;
} }
} }
@ -4497,22 +4497,22 @@ var Expr = Sizzle.selectors = {
if ( first === 1 && last === 0 ) { if ( first === 1 && last === 0 ) {
return true; return true;
} }
var doneName = match[0], var doneName = match[0],
parent = elem.parentNode; parent = elem.parentNode;
if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) { if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
var count = 0; var count = 0;
for ( node = parent.firstChild; node; node = node.nextSibling ) { for ( node = parent.firstChild; node; node = node.nextSibling ) {
if ( node.nodeType === 1 ) { if ( node.nodeType === 1 ) {
node.nodeIndex = ++count; node.nodeIndex = ++count;
} }
} }
parent.sizcache = doneName; parent.sizcache = doneName;
} }
var diff = elem.nodeIndex - last; var diff = elem.nodeIndex - last;
if ( first === 0 ) { if ( first === 0 ) {
@ -4531,7 +4531,7 @@ var Expr = Sizzle.selectors = {
TAG: function( elem, match ) { TAG: function( elem, match ) {
return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match; return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
}, },
CLASS: function( elem, match ) { CLASS: function( elem, match ) {
return (" " + (elem.className || elem.getAttribute("class")) + " ") return (" " + (elem.className || elem.getAttribute("class")) + " ")
.indexOf( match ) > -1; .indexOf( match ) > -1;
@ -4597,7 +4597,7 @@ var makeArray = function( array, results ) {
results.push.apply( results, array ); results.push.apply( results, array );
return results; return results;
} }
return array; return array;
}; };
@ -4849,7 +4849,7 @@ if ( document.querySelectorAll ) {
if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
return; return;
} }
Sizzle = function( query, context, extra, seed ) { Sizzle = function( query, context, extra, seed ) {
context = context || document; context = context || document;
@ -4858,24 +4858,24 @@ if ( document.querySelectorAll ) {
if ( !seed && !Sizzle.isXML(context) ) { if ( !seed && !Sizzle.isXML(context) ) {
// See if we find a selector to speed up // See if we find a selector to speed up
var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query ); var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
if ( match && (context.nodeType === 1 || context.nodeType === 9) ) { if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
// Speed-up: Sizzle("TAG") // Speed-up: Sizzle("TAG")
if ( match[1] ) { if ( match[1] ) {
return makeArray( context.getElementsByTagName( query ), extra ); return makeArray( context.getElementsByTagName( query ), extra );
// Speed-up: Sizzle(".CLASS") // Speed-up: Sizzle(".CLASS")
} else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) { } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
return makeArray( context.getElementsByClassName( match[2] ), extra ); return makeArray( context.getElementsByClassName( match[2] ), extra );
} }
} }
if ( context.nodeType === 9 ) { if ( context.nodeType === 9 ) {
// Speed-up: Sizzle("body") // Speed-up: Sizzle("body")
// The body element only exists once, optimize finding it // The body element only exists once, optimize finding it
if ( query === "body" && context.body ) { if ( query === "body" && context.body ) {
return makeArray( [ context.body ], extra ); return makeArray( [ context.body ], extra );
// Speed-up: Sizzle("#ID") // Speed-up: Sizzle("#ID")
} else if ( match && match[3] ) { } else if ( match && match[3] ) {
var elem = context.getElementById( match[3] ); var elem = context.getElementById( match[3] );
@ -4888,12 +4888,12 @@ if ( document.querySelectorAll ) {
if ( elem.id === match[3] ) { if ( elem.id === match[3] ) {
return makeArray( [ elem ], extra ); return makeArray( [ elem ], extra );
} }
} else { } else {
return makeArray( [], extra ); return makeArray( [], extra );
} }
} }
try { try {
return makeArray( context.querySelectorAll(query), extra ); return makeArray( context.querySelectorAll(query), extra );
} catch(qsaError) {} } catch(qsaError) {}
@ -4931,7 +4931,7 @@ if ( document.querySelectorAll ) {
} }
} }
} }
return oldSizzle(query, context, extra, seed); return oldSizzle(query, context, extra, seed);
}; };
@ -4958,7 +4958,7 @@ if ( document.querySelectorAll ) {
// This should fail with an exception // This should fail with an exception
// Gecko does not error, returns false instead // Gecko does not error, returns false instead
matches.call( document.documentElement, "[test!='']:sizzle" ); matches.call( document.documentElement, "[test!='']:sizzle" );
} catch( pseudoError ) { } catch( pseudoError ) {
pseudoWorks = true; pseudoWorks = true;
} }
@ -4968,7 +4968,7 @@ if ( document.querySelectorAll ) {
expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
if ( !Sizzle.isXML( node ) ) { if ( !Sizzle.isXML( node ) ) {
try { try {
if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) { if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
var ret = matches.call( node, expr ); var ret = matches.call( node, expr );
@ -5005,7 +5005,7 @@ if ( document.querySelectorAll ) {
if ( div.getElementsByClassName("e").length === 1 ) { if ( div.getElementsByClassName("e").length === 1 ) {
return; return;
} }
Expr.order.splice(1, 0, "CLASS"); Expr.order.splice(1, 0, "CLASS");
Expr.find.CLASS = function( match, context, isXML ) { Expr.find.CLASS = function( match, context, isXML ) {
if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
@ -5056,7 +5056,7 @@ function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
if ( elem ) { if ( elem ) {
var match = false; var match = false;
elem = elem[dir]; elem = elem[dir];
while ( elem ) { while ( elem ) {
@ -5109,7 +5109,7 @@ if ( document.documentElement.contains ) {
Sizzle.isXML = function( elem ) { Sizzle.isXML = function( elem ) {
// documentElement is verified for cases where it doesn't yet exist // documentElement is verified for cases where it doesn't yet exist
// (such as loading iframes in IE - #4833) // (such as loading iframes in IE - #4833)
var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
return documentElement ? documentElement.nodeName !== "HTML" : false; return documentElement ? documentElement.nodeName !== "HTML" : false;
@ -5230,7 +5230,7 @@ jQuery.fn.extend({
closest: function( selectors, context ) { closest: function( selectors, context ) {
var ret = [], i, l, cur = this[0]; var ret = [], i, l, cur = this[0];
// Array // Array
if ( jQuery.isArray( selectors ) ) { if ( jQuery.isArray( selectors ) ) {
var match, selector, var match, selector,

108
tests/jquery-1.6.3.js vendored
View File

@ -1961,11 +1961,11 @@ jQuery.fn.extend({
jQuery.removeAttr( this, name ); jQuery.removeAttr( this, name );
}); });
}, },
prop: function( name, value ) { prop: function( name, value ) {
return jQuery.access( this, name, value, true, jQuery.prop ); return jQuery.access( this, name, value, true, jQuery.prop );
}, },
removeProp: function( name ) { removeProp: function( name ) {
name = jQuery.propFix[ name ] || name; name = jQuery.propFix[ name ] || name;
return this.each(function() { return this.each(function() {
@ -2098,7 +2098,7 @@ jQuery.fn.extend({
val: function( value ) { val: function( value ) {
var hooks, ret, var hooks, ret,
elem = this[0]; elem = this[0];
if ( !arguments.length ) { if ( !arguments.length ) {
if ( elem ) { if ( elem ) {
hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ]; hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ];
@ -2109,9 +2109,9 @@ jQuery.fn.extend({
ret = elem.value; ret = elem.value;
return typeof ret === "string" ? return typeof ret === "string" ?
// handle most common string cases // handle most common string cases
ret.replace(rreturn, "") : ret.replace(rreturn, "") :
// handle cases where value is null/undef or number // handle cases where value is null/undef or number
ret == null ? "" : ret; ret == null ? "" : ret;
} }
@ -2232,15 +2232,15 @@ jQuery.extend({
height: true, height: true,
offset: true offset: true
}, },
attrFix: { attrFix: {
// Always normalize to ensure hook usage // Always normalize to ensure hook usage
tabindex: "tabIndex" tabindex: "tabIndex"
}, },
attr: function( elem, name, value, pass ) { attr: function( elem, name, value, pass ) {
var nType = elem.nodeType; var nType = elem.nodeType;
// don't get/set attributes on text, comment and attribute nodes // don't get/set attributes on text, comment and attribute nodes
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
return undefined; return undefined;
@ -2373,7 +2373,7 @@ jQuery.extend({
frameborder: "frameBorder", frameborder: "frameBorder",
contenteditable: "contentEditable" contenteditable: "contentEditable"
}, },
prop: function( elem, name, value ) { prop: function( elem, name, value ) {
var nType = elem.nodeType; var nType = elem.nodeType;
@ -2408,7 +2408,7 @@ jQuery.extend({
} }
} }
}, },
propHooks: { propHooks: {
tabIndex: { tabIndex: {
get: function( elem ) { get: function( elem ) {
@ -2461,7 +2461,7 @@ boolHook = {
// IE6/7 do not support getting/setting some attributes with get/setAttribute // IE6/7 do not support getting/setting some attributes with get/setAttribute
if ( !jQuery.support.getSetAttribute ) { if ( !jQuery.support.getSetAttribute ) {
// Use this for any attribute in IE6/7 // Use this for any attribute in IE6/7
// This fixes almost every IE6/7 issue // This fixes almost every IE6/7 issue
nodeHook = jQuery.valHooks.button = { nodeHook = jQuery.valHooks.button = {
@ -2833,7 +2833,7 @@ jQuery.event = {
} }
} }
}, },
// Events that are safe to short-circuit if no handlers are attached. // Events that are safe to short-circuit if no handlers are attached.
// Native DOM events should not be added, they may have inline handlers. // Native DOM events should not be added, they may have inline handlers.
customEvent: { customEvent: {
@ -2879,7 +2879,7 @@ jQuery.event = {
event.exclusive = exclusive; event.exclusive = exclusive;
event.namespace = namespaces.join("."); event.namespace = namespaces.join(".");
event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)"); event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)");
// triggerHandler() and global events don't bubble or run the default action // triggerHandler() and global events don't bubble or run the default action
if ( onlyHandlers || !elem ) { if ( onlyHandlers || !elem ) {
event.preventDefault(); event.preventDefault();
@ -2970,7 +2970,7 @@ jQuery.event = {
jQuery.event.triggered = undefined; jQuery.event.triggered = undefined;
} }
} }
return event.result; return event.result;
}, },
@ -3799,7 +3799,7 @@ var Sizzle = function( selector, context, results, seed ) {
if ( context.nodeType !== 1 && context.nodeType !== 9 ) { if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
return []; return [];
} }
if ( !selector || typeof selector !== "string" ) { if ( !selector || typeof selector !== "string" ) {
return results; return results;
} }
@ -3809,7 +3809,7 @@ var Sizzle = function( selector, context, results, seed ) {
contextXML = Sizzle.isXML( context ), contextXML = Sizzle.isXML( context ),
parts = [], parts = [],
soFar = selector; soFar = selector;
// Reset the position of the chunker regexp (start from head) // Reset the position of the chunker regexp (start from head)
do { do {
chunker.exec( "" ); chunker.exec( "" );
@ -3817,9 +3817,9 @@ var Sizzle = function( selector, context, results, seed ) {
if ( m ) { if ( m ) {
soFar = m[3]; soFar = m[3];
parts.push( m[1] ); parts.push( m[1] );
if ( m[2] ) { if ( m[2] ) {
extra = m[3]; extra = m[3];
break; break;
@ -3843,7 +3843,7 @@ var Sizzle = function( selector, context, results, seed ) {
if ( Expr.relative[ selector ] ) { if ( Expr.relative[ selector ] ) {
selector += parts.shift(); selector += parts.shift();
} }
set = posProcess( selector, set ); set = posProcess( selector, set );
} }
} }
@ -3972,7 +3972,7 @@ Sizzle.find = function( expr, context, isXML ) {
for ( var i = 0, l = Expr.order.length; i < l; i++ ) { for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
var match, var match,
type = Expr.order[i]; type = Expr.order[i];
if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
var left = match[1]; var left = match[1];
match.splice( 1, 1 ); match.splice( 1, 1 );
@ -4304,7 +4304,7 @@ var Expr = Sizzle.selectors = {
ATTR: function( match, curLoop, inplace, result, not, isXML ) { ATTR: function( match, curLoop, inplace, result, not, isXML ) {
var name = match[1] = match[1].replace( rBackslash, "" ); var name = match[1] = match[1].replace( rBackslash, "" );
if ( !isXML && Expr.attrMap[name] ) { if ( !isXML && Expr.attrMap[name] ) {
match[1] = Expr.attrMap[name]; match[1] = Expr.attrMap[name];
} }
@ -4338,7 +4338,7 @@ var Expr = Sizzle.selectors = {
} else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
return true; return true;
} }
return match; return match;
}, },
@ -4348,7 +4348,7 @@ var Expr = Sizzle.selectors = {
return match; return match;
} }
}, },
filters: { filters: {
enabled: function( elem ) { enabled: function( elem ) {
return elem.disabled === false && elem.type !== "hidden"; return elem.disabled === false && elem.type !== "hidden";
@ -4361,14 +4361,14 @@ var Expr = Sizzle.selectors = {
checked: function( elem ) { checked: function( elem ) {
return elem.checked === true; return elem.checked === true;
}, },
selected: function( elem ) { selected: function( elem ) {
// Accessing this property makes selected-by-default // Accessing this property makes selected-by-default
// options in Safari work properly // options in Safari work properly
if ( elem.parentNode ) { if ( elem.parentNode ) {
elem.parentNode.selectedIndex; elem.parentNode.selectedIndex;
} }
return elem.selected === true; return elem.selected === true;
}, },
@ -4390,7 +4390,7 @@ var Expr = Sizzle.selectors = {
text: function( elem ) { text: function( elem ) {
var attr = elem.getAttribute( "type" ), type = elem.type; var attr = elem.getAttribute( "type" ), type = elem.type;
// IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
// use getAttribute instead to test this case // use getAttribute instead to test this case
return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null ); return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null );
}, },
@ -4506,21 +4506,21 @@ var Expr = Sizzle.selectors = {
case "only": case "only":
case "first": case "first":
while ( (node = node.previousSibling) ) { while ( (node = node.previousSibling) ) {
if ( node.nodeType === 1 ) { if ( node.nodeType === 1 ) {
return false; return false;
} }
} }
if ( type === "first" ) { if ( type === "first" ) {
return true; return true;
} }
node = elem; node = elem;
case "last": case "last":
while ( (node = node.nextSibling) ) { while ( (node = node.nextSibling) ) {
if ( node.nodeType === 1 ) { if ( node.nodeType === 1 ) {
return false; return false;
} }
} }
@ -4533,22 +4533,22 @@ var Expr = Sizzle.selectors = {
if ( first === 1 && last === 0 ) { if ( first === 1 && last === 0 ) {
return true; return true;
} }
var doneName = match[0], var doneName = match[0],
parent = elem.parentNode; parent = elem.parentNode;
if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) { if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
var count = 0; var count = 0;
for ( node = parent.firstChild; node; node = node.nextSibling ) { for ( node = parent.firstChild; node; node = node.nextSibling ) {
if ( node.nodeType === 1 ) { if ( node.nodeType === 1 ) {
node.nodeIndex = ++count; node.nodeIndex = ++count;
} }
} }
parent.sizcache = doneName; parent.sizcache = doneName;
} }
var diff = elem.nodeIndex - last; var diff = elem.nodeIndex - last;
if ( first === 0 ) { if ( first === 0 ) {
@ -4567,7 +4567,7 @@ var Expr = Sizzle.selectors = {
TAG: function( elem, match ) { TAG: function( elem, match ) {
return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match; return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
}, },
CLASS: function( elem, match ) { CLASS: function( elem, match ) {
return (" " + (elem.className || elem.getAttribute("class")) + " ") return (" " + (elem.className || elem.getAttribute("class")) + " ")
.indexOf( match ) > -1; .indexOf( match ) > -1;
@ -4633,7 +4633,7 @@ var makeArray = function( array, results ) {
results.push.apply( results, array ); results.push.apply( results, array );
return results; return results;
} }
return array; return array;
}; };
@ -4885,7 +4885,7 @@ if ( document.querySelectorAll ) {
if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
return; return;
} }
Sizzle = function( query, context, extra, seed ) { Sizzle = function( query, context, extra, seed ) {
context = context || document; context = context || document;
@ -4894,24 +4894,24 @@ if ( document.querySelectorAll ) {
if ( !seed && !Sizzle.isXML(context) ) { if ( !seed && !Sizzle.isXML(context) ) {
// See if we find a selector to speed up // See if we find a selector to speed up
var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query ); var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
if ( match && (context.nodeType === 1 || context.nodeType === 9) ) { if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
// Speed-up: Sizzle("TAG") // Speed-up: Sizzle("TAG")
if ( match[1] ) { if ( match[1] ) {
return makeArray( context.getElementsByTagName( query ), extra ); return makeArray( context.getElementsByTagName( query ), extra );
// Speed-up: Sizzle(".CLASS") // Speed-up: Sizzle(".CLASS")
} else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) { } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
return makeArray( context.getElementsByClassName( match[2] ), extra ); return makeArray( context.getElementsByClassName( match[2] ), extra );
} }
} }
if ( context.nodeType === 9 ) { if ( context.nodeType === 9 ) {
// Speed-up: Sizzle("body") // Speed-up: Sizzle("body")
// The body element only exists once, optimize finding it // The body element only exists once, optimize finding it
if ( query === "body" && context.body ) { if ( query === "body" && context.body ) {
return makeArray( [ context.body ], extra ); return makeArray( [ context.body ], extra );
// Speed-up: Sizzle("#ID") // Speed-up: Sizzle("#ID")
} else if ( match && match[3] ) { } else if ( match && match[3] ) {
var elem = context.getElementById( match[3] ); var elem = context.getElementById( match[3] );
@ -4924,12 +4924,12 @@ if ( document.querySelectorAll ) {
if ( elem.id === match[3] ) { if ( elem.id === match[3] ) {
return makeArray( [ elem ], extra ); return makeArray( [ elem ], extra );
} }
} else { } else {
return makeArray( [], extra ); return makeArray( [], extra );
} }
} }
try { try {
return makeArray( context.querySelectorAll(query), extra ); return makeArray( context.querySelectorAll(query), extra );
} catch(qsaError) {} } catch(qsaError) {}
@ -4967,7 +4967,7 @@ if ( document.querySelectorAll ) {
} }
} }
} }
return oldSizzle(query, context, extra, seed); return oldSizzle(query, context, extra, seed);
}; };
@ -4994,7 +4994,7 @@ if ( document.querySelectorAll ) {
// This should fail with an exception // This should fail with an exception
// Gecko does not error, returns false instead // Gecko does not error, returns false instead
matches.call( document.documentElement, "[test!='']:sizzle" ); matches.call( document.documentElement, "[test!='']:sizzle" );
} catch( pseudoError ) { } catch( pseudoError ) {
pseudoWorks = true; pseudoWorks = true;
} }
@ -5004,7 +5004,7 @@ if ( document.querySelectorAll ) {
expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
if ( !Sizzle.isXML( node ) ) { if ( !Sizzle.isXML( node ) ) {
try { try {
if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) { if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
var ret = matches.call( node, expr ); var ret = matches.call( node, expr );
@ -5041,7 +5041,7 @@ if ( document.querySelectorAll ) {
if ( div.getElementsByClassName("e").length === 1 ) { if ( div.getElementsByClassName("e").length === 1 ) {
return; return;
} }
Expr.order.splice(1, 0, "CLASS"); Expr.order.splice(1, 0, "CLASS");
Expr.find.CLASS = function( match, context, isXML ) { Expr.find.CLASS = function( match, context, isXML ) {
if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
@ -5092,7 +5092,7 @@ function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
if ( elem ) { if ( elem ) {
var match = false; var match = false;
elem = elem[dir]; elem = elem[dir];
while ( elem ) { while ( elem ) {
@ -5145,7 +5145,7 @@ if ( document.documentElement.contains ) {
Sizzle.isXML = function( elem ) { Sizzle.isXML = function( elem ) {
// documentElement is verified for cases where it doesn't yet exist // documentElement is verified for cases where it doesn't yet exist
// (such as loading iframes in IE - #4833) // (such as loading iframes in IE - #4833)
var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
return documentElement ? documentElement.nodeName !== "HTML" : false; return documentElement ? documentElement.nodeName !== "HTML" : false;
@ -5266,7 +5266,7 @@ jQuery.fn.extend({
closest: function( selectors, context ) { closest: function( selectors, context ) {
var ret = [], i, l, cur = this[0]; var ret = [], i, l, cur = this[0];
// Array // Array
if ( jQuery.isArray( selectors ) ) { if ( jQuery.isArray( selectors ) ) {
var match, selector, var match, selector,
@ -6718,7 +6718,7 @@ var r20 = /%20/g,
// Document location segments // Document location segments
ajaxLocParts, ajaxLocParts,
// Avoid comment-prolog char sequence (#10098); must appease lint and evade compression // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
allTypes = ["*/"] + ["*"]; allTypes = ["*/"] + ["*"];

108
tests/jquery-1.6.4.js vendored
View File

@ -1962,11 +1962,11 @@ jQuery.fn.extend({
jQuery.removeAttr( this, name ); jQuery.removeAttr( this, name );
}); });
}, },
prop: function( name, value ) { prop: function( name, value ) {
return jQuery.access( this, name, value, true, jQuery.prop ); return jQuery.access( this, name, value, true, jQuery.prop );
}, },
removeProp: function( name ) { removeProp: function( name ) {
name = jQuery.propFix[ name ] || name; name = jQuery.propFix[ name ] || name;
return this.each(function() { return this.each(function() {
@ -2099,7 +2099,7 @@ jQuery.fn.extend({
val: function( value ) { val: function( value ) {
var hooks, ret, var hooks, ret,
elem = this[0]; elem = this[0];
if ( !arguments.length ) { if ( !arguments.length ) {
if ( elem ) { if ( elem ) {
hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ]; hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ];
@ -2110,9 +2110,9 @@ jQuery.fn.extend({
ret = elem.value; ret = elem.value;
return typeof ret === "string" ? return typeof ret === "string" ?
// handle most common string cases // handle most common string cases
ret.replace(rreturn, "") : ret.replace(rreturn, "") :
// handle cases where value is null/undef or number // handle cases where value is null/undef or number
ret == null ? "" : ret; ret == null ? "" : ret;
} }
@ -2233,15 +2233,15 @@ jQuery.extend({
height: true, height: true,
offset: true offset: true
}, },
attrFix: { attrFix: {
// Always normalize to ensure hook usage // Always normalize to ensure hook usage
tabindex: "tabIndex" tabindex: "tabIndex"
}, },
attr: function( elem, name, value, pass ) { attr: function( elem, name, value, pass ) {
var nType = elem.nodeType; var nType = elem.nodeType;
// don't get/set attributes on text, comment and attribute nodes // don't get/set attributes on text, comment and attribute nodes
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
return undefined; return undefined;
@ -2374,7 +2374,7 @@ jQuery.extend({
frameborder: "frameBorder", frameborder: "frameBorder",
contenteditable: "contentEditable" contenteditable: "contentEditable"
}, },
prop: function( elem, name, value ) { prop: function( elem, name, value ) {
var nType = elem.nodeType; var nType = elem.nodeType;
@ -2409,7 +2409,7 @@ jQuery.extend({
} }
} }
}, },
propHooks: { propHooks: {
tabIndex: { tabIndex: {
get: function( elem ) { get: function( elem ) {
@ -2462,7 +2462,7 @@ boolHook = {
// IE6/7 do not support getting/setting some attributes with get/setAttribute // IE6/7 do not support getting/setting some attributes with get/setAttribute
if ( !jQuery.support.getSetAttribute ) { if ( !jQuery.support.getSetAttribute ) {
// Use this for any attribute in IE6/7 // Use this for any attribute in IE6/7
// This fixes almost every IE6/7 issue // This fixes almost every IE6/7 issue
nodeHook = jQuery.valHooks.button = { nodeHook = jQuery.valHooks.button = {
@ -2834,7 +2834,7 @@ jQuery.event = {
} }
} }
}, },
// Events that are safe to short-circuit if no handlers are attached. // Events that are safe to short-circuit if no handlers are attached.
// Native DOM events should not be added, they may have inline handlers. // Native DOM events should not be added, they may have inline handlers.
customEvent: { customEvent: {
@ -2880,7 +2880,7 @@ jQuery.event = {
event.exclusive = exclusive; event.exclusive = exclusive;
event.namespace = namespaces.join("."); event.namespace = namespaces.join(".");
event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)"); event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)");
// triggerHandler() and global events don't bubble or run the default action // triggerHandler() and global events don't bubble or run the default action
if ( onlyHandlers || !elem ) { if ( onlyHandlers || !elem ) {
event.preventDefault(); event.preventDefault();
@ -2971,7 +2971,7 @@ jQuery.event = {
jQuery.event.triggered = undefined; jQuery.event.triggered = undefined;
} }
} }
return event.result; return event.result;
}, },
@ -3801,7 +3801,7 @@ var Sizzle = function( selector, context, results, seed ) {
if ( context.nodeType !== 1 && context.nodeType !== 9 ) { if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
return []; return [];
} }
if ( !selector || typeof selector !== "string" ) { if ( !selector || typeof selector !== "string" ) {
return results; return results;
} }
@ -3811,7 +3811,7 @@ var Sizzle = function( selector, context, results, seed ) {
contextXML = Sizzle.isXML( context ), contextXML = Sizzle.isXML( context ),
parts = [], parts = [],
soFar = selector; soFar = selector;
// Reset the position of the chunker regexp (start from head) // Reset the position of the chunker regexp (start from head)
do { do {
chunker.exec( "" ); chunker.exec( "" );
@ -3819,9 +3819,9 @@ var Sizzle = function( selector, context, results, seed ) {
if ( m ) { if ( m ) {
soFar = m[3]; soFar = m[3];
parts.push( m[1] ); parts.push( m[1] );
if ( m[2] ) { if ( m[2] ) {
extra = m[3]; extra = m[3];
break; break;
@ -3845,7 +3845,7 @@ var Sizzle = function( selector, context, results, seed ) {
if ( Expr.relative[ selector ] ) { if ( Expr.relative[ selector ] ) {
selector += parts.shift(); selector += parts.shift();
} }
set = posProcess( selector, set ); set = posProcess( selector, set );
} }
} }
@ -3974,7 +3974,7 @@ Sizzle.find = function( expr, context, isXML ) {
for ( var i = 0, l = Expr.order.length; i < l; i++ ) { for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
var match, var match,
type = Expr.order[i]; type = Expr.order[i];
if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
var left = match[1]; var left = match[1];
match.splice( 1, 1 ); match.splice( 1, 1 );
@ -4306,7 +4306,7 @@ var Expr = Sizzle.selectors = {
ATTR: function( match, curLoop, inplace, result, not, isXML ) { ATTR: function( match, curLoop, inplace, result, not, isXML ) {
var name = match[1] = match[1].replace( rBackslash, "" ); var name = match[1] = match[1].replace( rBackslash, "" );
if ( !isXML && Expr.attrMap[name] ) { if ( !isXML && Expr.attrMap[name] ) {
match[1] = Expr.attrMap[name]; match[1] = Expr.attrMap[name];
} }
@ -4340,7 +4340,7 @@ var Expr = Sizzle.selectors = {
} else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
return true; return true;
} }
return match; return match;
}, },
@ -4350,7 +4350,7 @@ var Expr = Sizzle.selectors = {
return match; return match;
} }
}, },
filters: { filters: {
enabled: function( elem ) { enabled: function( elem ) {
return elem.disabled === false && elem.type !== "hidden"; return elem.disabled === false && elem.type !== "hidden";
@ -4363,14 +4363,14 @@ var Expr = Sizzle.selectors = {
checked: function( elem ) { checked: function( elem ) {
return elem.checked === true; return elem.checked === true;
}, },
selected: function( elem ) { selected: function( elem ) {
// Accessing this property makes selected-by-default // Accessing this property makes selected-by-default
// options in Safari work properly // options in Safari work properly
if ( elem.parentNode ) { if ( elem.parentNode ) {
elem.parentNode.selectedIndex; elem.parentNode.selectedIndex;
} }
return elem.selected === true; return elem.selected === true;
}, },
@ -4392,7 +4392,7 @@ var Expr = Sizzle.selectors = {
text: function( elem ) { text: function( elem ) {
var attr = elem.getAttribute( "type" ), type = elem.type; var attr = elem.getAttribute( "type" ), type = elem.type;
// IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
// use getAttribute instead to test this case // use getAttribute instead to test this case
return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null ); return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null );
}, },
@ -4508,21 +4508,21 @@ var Expr = Sizzle.selectors = {
case "only": case "only":
case "first": case "first":
while ( (node = node.previousSibling) ) { while ( (node = node.previousSibling) ) {
if ( node.nodeType === 1 ) { if ( node.nodeType === 1 ) {
return false; return false;
} }
} }
if ( type === "first" ) { if ( type === "first" ) {
return true; return true;
} }
node = elem; node = elem;
case "last": case "last":
while ( (node = node.nextSibling) ) { while ( (node = node.nextSibling) ) {
if ( node.nodeType === 1 ) { if ( node.nodeType === 1 ) {
return false; return false;
} }
} }
@ -4535,22 +4535,22 @@ var Expr = Sizzle.selectors = {
if ( first === 1 && last === 0 ) { if ( first === 1 && last === 0 ) {
return true; return true;
} }
var doneName = match[0], var doneName = match[0],
parent = elem.parentNode; parent = elem.parentNode;
if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) { if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
var count = 0; var count = 0;
for ( node = parent.firstChild; node; node = node.nextSibling ) { for ( node = parent.firstChild; node; node = node.nextSibling ) {
if ( node.nodeType === 1 ) { if ( node.nodeType === 1 ) {
node.nodeIndex = ++count; node.nodeIndex = ++count;
} }
} }
parent.sizcache = doneName; parent.sizcache = doneName;
} }
var diff = elem.nodeIndex - last; var diff = elem.nodeIndex - last;
if ( first === 0 ) { if ( first === 0 ) {
@ -4569,7 +4569,7 @@ var Expr = Sizzle.selectors = {
TAG: function( elem, match ) { TAG: function( elem, match ) {
return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match; return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
}, },
CLASS: function( elem, match ) { CLASS: function( elem, match ) {
return (" " + (elem.className || elem.getAttribute("class")) + " ") return (" " + (elem.className || elem.getAttribute("class")) + " ")
.indexOf( match ) > -1; .indexOf( match ) > -1;
@ -4635,7 +4635,7 @@ var makeArray = function( array, results ) {
results.push.apply( results, array ); results.push.apply( results, array );
return results; return results;
} }
return array; return array;
}; };
@ -4887,7 +4887,7 @@ if ( document.querySelectorAll ) {
if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
return; return;
} }
Sizzle = function( query, context, extra, seed ) { Sizzle = function( query, context, extra, seed ) {
context = context || document; context = context || document;
@ -4896,24 +4896,24 @@ if ( document.querySelectorAll ) {
if ( !seed && !Sizzle.isXML(context) ) { if ( !seed && !Sizzle.isXML(context) ) {
// See if we find a selector to speed up // See if we find a selector to speed up
var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query ); var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
if ( match && (context.nodeType === 1 || context.nodeType === 9) ) { if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
// Speed-up: Sizzle("TAG") // Speed-up: Sizzle("TAG")
if ( match[1] ) { if ( match[1] ) {
return makeArray( context.getElementsByTagName( query ), extra ); return makeArray( context.getElementsByTagName( query ), extra );
// Speed-up: Sizzle(".CLASS") // Speed-up: Sizzle(".CLASS")
} else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) { } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
return makeArray( context.getElementsByClassName( match[2] ), extra ); return makeArray( context.getElementsByClassName( match[2] ), extra );
} }
} }
if ( context.nodeType === 9 ) { if ( context.nodeType === 9 ) {
// Speed-up: Sizzle("body") // Speed-up: Sizzle("body")
// The body element only exists once, optimize finding it // The body element only exists once, optimize finding it
if ( query === "body" && context.body ) { if ( query === "body" && context.body ) {
return makeArray( [ context.body ], extra ); return makeArray( [ context.body ], extra );
// Speed-up: Sizzle("#ID") // Speed-up: Sizzle("#ID")
} else if ( match && match[3] ) { } else if ( match && match[3] ) {
var elem = context.getElementById( match[3] ); var elem = context.getElementById( match[3] );
@ -4926,12 +4926,12 @@ if ( document.querySelectorAll ) {
if ( elem.id === match[3] ) { if ( elem.id === match[3] ) {
return makeArray( [ elem ], extra ); return makeArray( [ elem ], extra );
} }
} else { } else {
return makeArray( [], extra ); return makeArray( [], extra );
} }
} }
try { try {
return makeArray( context.querySelectorAll(query), extra ); return makeArray( context.querySelectorAll(query), extra );
} catch(qsaError) {} } catch(qsaError) {}
@ -4969,7 +4969,7 @@ if ( document.querySelectorAll ) {
} }
} }
} }
return oldSizzle(query, context, extra, seed); return oldSizzle(query, context, extra, seed);
}; };
@ -4996,7 +4996,7 @@ if ( document.querySelectorAll ) {
// This should fail with an exception // This should fail with an exception
// Gecko does not error, returns false instead // Gecko does not error, returns false instead
matches.call( document.documentElement, "[test!='']:sizzle" ); matches.call( document.documentElement, "[test!='']:sizzle" );
} catch( pseudoError ) { } catch( pseudoError ) {
pseudoWorks = true; pseudoWorks = true;
} }
@ -5006,7 +5006,7 @@ if ( document.querySelectorAll ) {
expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
if ( !Sizzle.isXML( node ) ) { if ( !Sizzle.isXML( node ) ) {
try { try {
if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) { if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
var ret = matches.call( node, expr ); var ret = matches.call( node, expr );
@ -5043,7 +5043,7 @@ if ( document.querySelectorAll ) {
if ( div.getElementsByClassName("e").length === 1 ) { if ( div.getElementsByClassName("e").length === 1 ) {
return; return;
} }
Expr.order.splice(1, 0, "CLASS"); Expr.order.splice(1, 0, "CLASS");
Expr.find.CLASS = function( match, context, isXML ) { Expr.find.CLASS = function( match, context, isXML ) {
if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
@ -5094,7 +5094,7 @@ function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
if ( elem ) { if ( elem ) {
var match = false; var match = false;
elem = elem[dir]; elem = elem[dir];
while ( elem ) { while ( elem ) {
@ -5147,7 +5147,7 @@ if ( document.documentElement.contains ) {
Sizzle.isXML = function( elem ) { Sizzle.isXML = function( elem ) {
// documentElement is verified for cases where it doesn't yet exist // documentElement is verified for cases where it doesn't yet exist
// (such as loading iframes in IE - #4833) // (such as loading iframes in IE - #4833)
var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
return documentElement ? documentElement.nodeName !== "HTML" : false; return documentElement ? documentElement.nodeName !== "HTML" : false;
@ -5268,7 +5268,7 @@ jQuery.fn.extend({
closest: function( selectors, context ) { closest: function( selectors, context ) {
var ret = [], i, l, cur = this[0]; var ret = [], i, l, cur = this[0];
// Array // Array
if ( jQuery.isArray( selectors ) ) { if ( jQuery.isArray( selectors ) ) {
var match, selector, var match, selector,
@ -6720,7 +6720,7 @@ var r20 = /%20/g,
// Document location segments // Document location segments
ajaxLocParts, ajaxLocParts,
// Avoid comment-prolog char sequence (#10098); must appease lint and evade compression // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
allTypes = ["*/"] + ["*"]; allTypes = ["*/"] + ["*"];

130
tests/jquery-1.6.js vendored
View File

@ -1893,11 +1893,11 @@ jQuery.fn.extend({
jQuery.removeAttr( this, name ); jQuery.removeAttr( this, name );
}); });
}, },
prop: function( name, value ) { prop: function( name, value ) {
return jQuery.access( this, name, value, true, jQuery.prop ); return jQuery.access( this, name, value, true, jQuery.prop );
}, },
removeProp: function( name ) { removeProp: function( name ) {
return this.each(function() { return this.each(function() {
// try/catch handles cases where IE balks (such as removing a property on window) // try/catch handles cases where IE balks (such as removing a property on window)
@ -2028,7 +2028,7 @@ jQuery.fn.extend({
val: function( value ) { val: function( value ) {
var hooks, ret, var hooks, ret,
elem = this[0]; elem = this[0];
if ( !arguments.length ) { if ( !arguments.length ) {
if ( elem ) { if ( elem ) {
hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ]; hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ];
@ -2155,16 +2155,16 @@ jQuery.extend({
height: true, height: true,
offset: true offset: true
}, },
attrFix: { attrFix: {
// Always normalize to ensure hook usage // Always normalize to ensure hook usage
tabindex: "tabIndex", tabindex: "tabIndex",
readonly: "readOnly" readonly: "readOnly"
}, },
attr: function( elem, name, value, pass ) { attr: function( elem, name, value, pass ) {
var nType = elem.nodeType; var nType = elem.nodeType;
// don't get/set attributes on text, comment and attribute nodes // don't get/set attributes on text, comment and attribute nodes
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
return undefined; return undefined;
@ -2173,10 +2173,10 @@ jQuery.extend({
if ( pass && name in jQuery.attrFn ) { if ( pass && name in jQuery.attrFn ) {
return jQuery( elem )[ name ]( value ); return jQuery( elem )[ name ]( value );
} }
var ret, hooks, var ret, hooks,
notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
// Normalize the name if needed // Normalize the name if needed
name = notxml && jQuery.attrFix[ name ] || name; name = notxml && jQuery.attrFix[ name ] || name;
@ -2223,11 +2223,11 @@ jQuery.extend({
} }
} }
}, },
removeAttr: function( elem, name ) { removeAttr: function( elem, name ) {
if ( elem.nodeType === 1 ) { if ( elem.nodeType === 1 ) {
name = jQuery.attrFix[ name ] || name; name = jQuery.attrFix[ name ] || name;
if ( jQuery.support.getSetAttribute ) { if ( jQuery.support.getSetAttribute ) {
// Use removeAttribute in browsers that support it // Use removeAttribute in browsers that support it
elem.removeAttribute( name ); elem.removeAttribute( name );
@ -2271,43 +2271,43 @@ jQuery.extend({
} }
} }
}, },
propFix: {}, propFix: {},
prop: function( elem, name, value ) { prop: function( elem, name, value ) {
var nType = elem.nodeType; var nType = elem.nodeType;
// don't get/set properties on text, comment and attribute nodes // don't get/set properties on text, comment and attribute nodes
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
return undefined; return undefined;
} }
var ret, hooks, var ret, hooks,
notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
// Try to normalize/fix the name // Try to normalize/fix the name
name = notxml && jQuery.propFix[ name ] || name; name = notxml && jQuery.propFix[ name ] || name;
hooks = jQuery.propHooks[ name ]; hooks = jQuery.propHooks[ name ];
if ( value !== undefined ) { if ( value !== undefined ) {
if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
return ret; return ret;
} else { } else {
return (elem[ name ] = value); return (elem[ name ] = value);
} }
} else { } else {
if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== undefined ) { if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== undefined ) {
return ret; return ret;
} else { } else {
return elem[ name ]; return elem[ name ];
} }
} }
}, },
propHooks: {} propHooks: {}
}); });
@ -2324,7 +2324,7 @@ if ( !jQuery.support.getSetAttribute ) {
usemap: "useMap", usemap: "useMap",
frameborder: "frameBorder" frameborder: "frameBorder"
}); });
// Use this for any attribute on a form in IE6/7 // Use this for any attribute on a form in IE6/7
formHook = jQuery.attrHooks.name = jQuery.attrHooks.value = jQuery.valHooks.button = { formHook = jQuery.attrHooks.name = jQuery.attrHooks.value = jQuery.valHooks.button = {
get: function( elem, name ) { get: function( elem, name ) {
@ -2698,7 +2698,7 @@ jQuery.event = {
} }
} }
}, },
// Events that are safe to short-circuit if no handlers are attached. // Events that are safe to short-circuit if no handlers are attached.
// Native DOM events should not be added, they may have inline handlers. // Native DOM events should not be added, they may have inline handlers.
customEvent: { customEvent: {
@ -2744,7 +2744,7 @@ jQuery.event = {
event.exclusive = exclusive; event.exclusive = exclusive;
event.namespace = namespaces.join("."); event.namespace = namespaces.join(".");
event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)"); event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)");
// triggerHandler() and global events don't bubble or run the default action // triggerHandler() and global events don't bubble or run the default action
if ( onlyHandlers || !elem ) { if ( onlyHandlers || !elem ) {
event.preventDefault(); event.preventDefault();
@ -2835,7 +2835,7 @@ jQuery.event = {
jQuery.event.triggered = undefined; jQuery.event.triggered = undefined;
} }
} }
return event.result; return event.result;
}, },
@ -3669,7 +3669,7 @@ var Sizzle = function( selector, context, results, seed ) {
if ( context.nodeType !== 1 && context.nodeType !== 9 ) { if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
return []; return [];
} }
if ( !selector || typeof selector !== "string" ) { if ( !selector || typeof selector !== "string" ) {
return results; return results;
} }
@ -3679,7 +3679,7 @@ var Sizzle = function( selector, context, results, seed ) {
contextXML = Sizzle.isXML( context ), contextXML = Sizzle.isXML( context ),
parts = [], parts = [],
soFar = selector; soFar = selector;
// Reset the position of the chunker regexp (start from head) // Reset the position of the chunker regexp (start from head)
do { do {
chunker.exec( "" ); chunker.exec( "" );
@ -3687,9 +3687,9 @@ var Sizzle = function( selector, context, results, seed ) {
if ( m ) { if ( m ) {
soFar = m[3]; soFar = m[3];
parts.push( m[1] ); parts.push( m[1] );
if ( m[2] ) { if ( m[2] ) {
extra = m[3]; extra = m[3];
break; break;
@ -3713,7 +3713,7 @@ var Sizzle = function( selector, context, results, seed ) {
if ( Expr.relative[ selector ] ) { if ( Expr.relative[ selector ] ) {
selector += parts.shift(); selector += parts.shift();
} }
set = posProcess( selector, set ); set = posProcess( selector, set );
} }
} }
@ -3842,7 +3842,7 @@ Sizzle.find = function( expr, context, isXML ) {
for ( var i = 0, l = Expr.order.length; i < l; i++ ) { for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
var match, var match,
type = Expr.order[i]; type = Expr.order[i];
if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
var left = match[1]; var left = match[1];
match.splice( 1, 1 ); match.splice( 1, 1 );
@ -4174,7 +4174,7 @@ var Expr = Sizzle.selectors = {
ATTR: function( match, curLoop, inplace, result, not, isXML ) { ATTR: function( match, curLoop, inplace, result, not, isXML ) {
var name = match[1] = match[1].replace( rBackslash, "" ); var name = match[1] = match[1].replace( rBackslash, "" );
if ( !isXML && Expr.attrMap[name] ) { if ( !isXML && Expr.attrMap[name] ) {
match[1] = Expr.attrMap[name]; match[1] = Expr.attrMap[name];
} }
@ -4208,7 +4208,7 @@ var Expr = Sizzle.selectors = {
} else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
return true; return true;
} }
return match; return match;
}, },
@ -4218,7 +4218,7 @@ var Expr = Sizzle.selectors = {
return match; return match;
} }
}, },
filters: { filters: {
enabled: function( elem ) { enabled: function( elem ) {
return elem.disabled === false && elem.type !== "hidden"; return elem.disabled === false && elem.type !== "hidden";
@ -4231,14 +4231,14 @@ var Expr = Sizzle.selectors = {
checked: function( elem ) { checked: function( elem ) {
return elem.checked === true; return elem.checked === true;
}, },
selected: function( elem ) { selected: function( elem ) {
// Accessing this property makes selected-by-default // Accessing this property makes selected-by-default
// options in Safari work properly // options in Safari work properly
if ( elem.parentNode ) { if ( elem.parentNode ) {
elem.parentNode.selectedIndex; elem.parentNode.selectedIndex;
} }
return elem.selected === true; return elem.selected === true;
}, },
@ -4260,7 +4260,7 @@ var Expr = Sizzle.selectors = {
text: function( elem ) { text: function( elem ) {
var attr = elem.getAttribute( "type" ), type = elem.type; var attr = elem.getAttribute( "type" ), type = elem.type;
// IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
// use getAttribute instead to test this case // use getAttribute instead to test this case
return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null ); return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null );
}, },
@ -4375,21 +4375,21 @@ var Expr = Sizzle.selectors = {
case "only": case "only":
case "first": case "first":
while ( (node = node.previousSibling) ) { while ( (node = node.previousSibling) ) {
if ( node.nodeType === 1 ) { if ( node.nodeType === 1 ) {
return false; return false;
} }
} }
if ( type === "first" ) { if ( type === "first" ) {
return true; return true;
} }
node = elem; node = elem;
case "last": case "last":
while ( (node = node.nextSibling) ) { while ( (node = node.nextSibling) ) {
if ( node.nodeType === 1 ) { if ( node.nodeType === 1 ) {
return false; return false;
} }
} }
@ -4402,22 +4402,22 @@ var Expr = Sizzle.selectors = {
if ( first === 1 && last === 0 ) { if ( first === 1 && last === 0 ) {
return true; return true;
} }
var doneName = match[0], var doneName = match[0],
parent = elem.parentNode; parent = elem.parentNode;
if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) { if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
var count = 0; var count = 0;
for ( node = parent.firstChild; node; node = node.nextSibling ) { for ( node = parent.firstChild; node; node = node.nextSibling ) {
if ( node.nodeType === 1 ) { if ( node.nodeType === 1 ) {
node.nodeIndex = ++count; node.nodeIndex = ++count;
} }
} }
parent.sizcache = doneName; parent.sizcache = doneName;
} }
var diff = elem.nodeIndex - last; var diff = elem.nodeIndex - last;
if ( first === 0 ) { if ( first === 0 ) {
@ -4436,7 +4436,7 @@ var Expr = Sizzle.selectors = {
TAG: function( elem, match ) { TAG: function( elem, match ) {
return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match; return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
}, },
CLASS: function( elem, match ) { CLASS: function( elem, match ) {
return (" " + (elem.className || elem.getAttribute("class")) + " ") return (" " + (elem.className || elem.getAttribute("class")) + " ")
.indexOf( match ) > -1; .indexOf( match ) > -1;
@ -4502,7 +4502,7 @@ var makeArray = function( array, results ) {
results.push.apply( results, array ); results.push.apply( results, array );
return results; return results;
} }
return array; return array;
}; };
@ -4749,7 +4749,7 @@ if ( document.querySelectorAll ) {
if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
return; return;
} }
Sizzle = function( query, context, extra, seed ) { Sizzle = function( query, context, extra, seed ) {
context = context || document; context = context || document;
@ -4758,24 +4758,24 @@ if ( document.querySelectorAll ) {
if ( !seed && !Sizzle.isXML(context) ) { if ( !seed && !Sizzle.isXML(context) ) {
// See if we find a selector to speed up // See if we find a selector to speed up
var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query ); var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
if ( match && (context.nodeType === 1 || context.nodeType === 9) ) { if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
// Speed-up: Sizzle("TAG") // Speed-up: Sizzle("TAG")
if ( match[1] ) { if ( match[1] ) {
return makeArray( context.getElementsByTagName( query ), extra ); return makeArray( context.getElementsByTagName( query ), extra );
// Speed-up: Sizzle(".CLASS") // Speed-up: Sizzle(".CLASS")
} else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) { } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
return makeArray( context.getElementsByClassName( match[2] ), extra ); return makeArray( context.getElementsByClassName( match[2] ), extra );
} }
} }
if ( context.nodeType === 9 ) { if ( context.nodeType === 9 ) {
// Speed-up: Sizzle("body") // Speed-up: Sizzle("body")
// The body element only exists once, optimize finding it // The body element only exists once, optimize finding it
if ( query === "body" && context.body ) { if ( query === "body" && context.body ) {
return makeArray( [ context.body ], extra ); return makeArray( [ context.body ], extra );
// Speed-up: Sizzle("#ID") // Speed-up: Sizzle("#ID")
} else if ( match && match[3] ) { } else if ( match && match[3] ) {
var elem = context.getElementById( match[3] ); var elem = context.getElementById( match[3] );
@ -4788,12 +4788,12 @@ if ( document.querySelectorAll ) {
if ( elem.id === match[3] ) { if ( elem.id === match[3] ) {
return makeArray( [ elem ], extra ); return makeArray( [ elem ], extra );
} }
} else { } else {
return makeArray( [], extra ); return makeArray( [], extra );
} }
} }
try { try {
return makeArray( context.querySelectorAll(query), extra ); return makeArray( context.querySelectorAll(query), extra );
} catch(qsaError) {} } catch(qsaError) {}
@ -4831,7 +4831,7 @@ if ( document.querySelectorAll ) {
} }
} }
} }
return oldSizzle(query, context, extra, seed); return oldSizzle(query, context, extra, seed);
}; };
@ -4858,7 +4858,7 @@ if ( document.querySelectorAll ) {
// This should fail with an exception // This should fail with an exception
// Gecko does not error, returns false instead // Gecko does not error, returns false instead
matches.call( document.documentElement, "[test!='']:sizzle" ); matches.call( document.documentElement, "[test!='']:sizzle" );
} catch( pseudoError ) { } catch( pseudoError ) {
pseudoWorks = true; pseudoWorks = true;
} }
@ -4868,7 +4868,7 @@ if ( document.querySelectorAll ) {
expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
if ( !Sizzle.isXML( node ) ) { if ( !Sizzle.isXML( node ) ) {
try { try {
if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) { if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
var ret = matches.call( node, expr ); var ret = matches.call( node, expr );
@ -4905,7 +4905,7 @@ if ( document.querySelectorAll ) {
if ( div.getElementsByClassName("e").length === 1 ) { if ( div.getElementsByClassName("e").length === 1 ) {
return; return;
} }
Expr.order.splice(1, 0, "CLASS"); Expr.order.splice(1, 0, "CLASS");
Expr.find.CLASS = function( match, context, isXML ) { Expr.find.CLASS = function( match, context, isXML ) {
if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
@ -4956,7 +4956,7 @@ function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
if ( elem ) { if ( elem ) {
var match = false; var match = false;
elem = elem[dir]; elem = elem[dir];
while ( elem ) { while ( elem ) {
@ -5009,7 +5009,7 @@ if ( document.documentElement.contains ) {
Sizzle.isXML = function( elem ) { Sizzle.isXML = function( elem ) {
// documentElement is verified for cases where it doesn't yet exist // documentElement is verified for cases where it doesn't yet exist
// (such as loading iframes in IE - #4833) // (such as loading iframes in IE - #4833)
var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
return documentElement ? documentElement.nodeName !== "HTML" : false; return documentElement ? documentElement.nodeName !== "HTML" : false;
@ -5130,7 +5130,7 @@ jQuery.fn.extend({
closest: function( selectors, context ) { closest: function( selectors, context ) {
var ret = [], i, l, cur = this[0]; var ret = [], i, l, cur = this[0];
// Array // Array
if ( jQuery.isArray( selectors ) ) { if ( jQuery.isArray( selectors ) ) {
var match, selector, var match, selector,
@ -5884,7 +5884,7 @@ jQuery.each({
function getAll( elem ) { function getAll( elem ) {
if ( "getElementsByTagName" in elem ) { if ( "getElementsByTagName" in elem ) {
return elem.getElementsByTagName( "*" ); return elem.getElementsByTagName( "*" );
} else if ( "querySelectorAll" in elem ) { } else if ( "querySelectorAll" in elem ) {
return elem.querySelectorAll( "*" ); return elem.querySelectorAll( "*" );

82
tests/jquery-1.7.1.js vendored
View File

@ -3885,7 +3885,7 @@ var Sizzle = function( selector, context, results, seed ) {
if ( context.nodeType !== 1 && context.nodeType !== 9 ) { if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
return []; return [];
} }
if ( !selector || typeof selector !== "string" ) { if ( !selector || typeof selector !== "string" ) {
return results; return results;
} }
@ -3895,7 +3895,7 @@ var Sizzle = function( selector, context, results, seed ) {
contextXML = Sizzle.isXML( context ), contextXML = Sizzle.isXML( context ),
parts = [], parts = [],
soFar = selector; soFar = selector;
// Reset the position of the chunker regexp (start from head) // Reset the position of the chunker regexp (start from head)
do { do {
chunker.exec( "" ); chunker.exec( "" );
@ -3903,9 +3903,9 @@ var Sizzle = function( selector, context, results, seed ) {
if ( m ) { if ( m ) {
soFar = m[3]; soFar = m[3];
parts.push( m[1] ); parts.push( m[1] );
if ( m[2] ) { if ( m[2] ) {
extra = m[3]; extra = m[3];
break; break;
@ -3929,7 +3929,7 @@ var Sizzle = function( selector, context, results, seed ) {
if ( Expr.relative[ selector ] ) { if ( Expr.relative[ selector ] ) {
selector += parts.shift(); selector += parts.shift();
} }
set = posProcess( selector, set, seed ); set = posProcess( selector, set, seed );
} }
} }
@ -4057,7 +4057,7 @@ Sizzle.find = function( expr, context, isXML ) {
for ( i = 0, len = Expr.order.length; i < len; i++ ) { for ( i = 0, len = Expr.order.length; i < len; i++ ) {
type = Expr.order[i]; type = Expr.order[i];
if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
left = match[1]; left = match[1];
match.splice( 1, 1 ); match.splice( 1, 1 );
@ -4429,7 +4429,7 @@ var Expr = Sizzle.selectors = {
ATTR: function( match, curLoop, inplace, result, not, isXML ) { ATTR: function( match, curLoop, inplace, result, not, isXML ) {
var name = match[1] = match[1].replace( rBackslash, "" ); var name = match[1] = match[1].replace( rBackslash, "" );
if ( !isXML && Expr.attrMap[name] ) { if ( !isXML && Expr.attrMap[name] ) {
match[1] = Expr.attrMap[name]; match[1] = Expr.attrMap[name];
} }
@ -4463,7 +4463,7 @@ var Expr = Sizzle.selectors = {
} else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
return true; return true;
} }
return match; return match;
}, },
@ -4473,7 +4473,7 @@ var Expr = Sizzle.selectors = {
return match; return match;
} }
}, },
filters: { filters: {
enabled: function( elem ) { enabled: function( elem ) {
return elem.disabled === false && elem.type !== "hidden"; return elem.disabled === false && elem.type !== "hidden";
@ -4486,14 +4486,14 @@ var Expr = Sizzle.selectors = {
checked: function( elem ) { checked: function( elem ) {
return elem.checked === true; return elem.checked === true;
}, },
selected: function( elem ) { selected: function( elem ) {
// Accessing this property makes selected-by-default // Accessing this property makes selected-by-default
// options in Safari work properly // options in Safari work properly
if ( elem.parentNode ) { if ( elem.parentNode ) {
elem.parentNode.selectedIndex; elem.parentNode.selectedIndex;
} }
return elem.selected === true; return elem.selected === true;
}, },
@ -4515,7 +4515,7 @@ var Expr = Sizzle.selectors = {
text: function( elem ) { text: function( elem ) {
var attr = elem.getAttribute( "type" ), type = elem.type; var attr = elem.getAttribute( "type" ), type = elem.type;
// IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
// use getAttribute instead to test this case // use getAttribute instead to test this case
return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null ); return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null );
}, },
@ -4634,21 +4634,21 @@ var Expr = Sizzle.selectors = {
case "only": case "only":
case "first": case "first":
while ( (node = node.previousSibling) ) { while ( (node = node.previousSibling) ) {
if ( node.nodeType === 1 ) { if ( node.nodeType === 1 ) {
return false; return false;
} }
} }
if ( type === "first" ) { if ( type === "first" ) {
return true; return true;
} }
node = elem; node = elem;
case "last": case "last":
while ( (node = node.nextSibling) ) { while ( (node = node.nextSibling) ) {
if ( node.nodeType === 1 ) { if ( node.nodeType === 1 ) {
return false; return false;
} }
} }
@ -4661,22 +4661,22 @@ var Expr = Sizzle.selectors = {
if ( first === 1 && last === 0 ) { if ( first === 1 && last === 0 ) {
return true; return true;
} }
doneName = match[0]; doneName = match[0];
parent = elem.parentNode; parent = elem.parentNode;
if ( parent && (parent[ expando ] !== doneName || !elem.nodeIndex) ) { if ( parent && (parent[ expando ] !== doneName || !elem.nodeIndex) ) {
count = 0; count = 0;
for ( node = parent.firstChild; node; node = node.nextSibling ) { for ( node = parent.firstChild; node; node = node.nextSibling ) {
if ( node.nodeType === 1 ) { if ( node.nodeType === 1 ) {
node.nodeIndex = ++count; node.nodeIndex = ++count;
} }
} }
parent[ expando ] = doneName; parent[ expando ] = doneName;
} }
diff = elem.nodeIndex - last; diff = elem.nodeIndex - last;
if ( first === 0 ) { if ( first === 0 ) {
@ -4695,7 +4695,7 @@ var Expr = Sizzle.selectors = {
TAG: function( elem, match ) { TAG: function( elem, match ) {
return (match === "*" && elem.nodeType === 1) || !!elem.nodeName && elem.nodeName.toLowerCase() === match; return (match === "*" && elem.nodeType === 1) || !!elem.nodeName && elem.nodeName.toLowerCase() === match;
}, },
CLASS: function( elem, match ) { CLASS: function( elem, match ) {
return (" " + (elem.className || elem.getAttribute("class")) + " ") return (" " + (elem.className || elem.getAttribute("class")) + " ")
.indexOf( match ) > -1; .indexOf( match ) > -1;
@ -4765,7 +4765,7 @@ var makeArray = function( array, results ) {
results.push.apply( results, array ); results.push.apply( results, array );
return results; return results;
} }
return array; return array;
}; };
@ -4997,7 +4997,7 @@ if ( document.querySelectorAll ) {
if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
return; return;
} }
Sizzle = function( query, context, extra, seed ) { Sizzle = function( query, context, extra, seed ) {
context = context || document; context = context || document;
@ -5006,24 +5006,24 @@ if ( document.querySelectorAll ) {
if ( !seed && !Sizzle.isXML(context) ) { if ( !seed && !Sizzle.isXML(context) ) {
// See if we find a selector to speed up // See if we find a selector to speed up
var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query ); var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
if ( match && (context.nodeType === 1 || context.nodeType === 9) ) { if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
// Speed-up: Sizzle("TAG") // Speed-up: Sizzle("TAG")
if ( match[1] ) { if ( match[1] ) {
return makeArray( context.getElementsByTagName( query ), extra ); return makeArray( context.getElementsByTagName( query ), extra );
// Speed-up: Sizzle(".CLASS") // Speed-up: Sizzle(".CLASS")
} else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) { } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
return makeArray( context.getElementsByClassName( match[2] ), extra ); return makeArray( context.getElementsByClassName( match[2] ), extra );
} }
} }
if ( context.nodeType === 9 ) { if ( context.nodeType === 9 ) {
// Speed-up: Sizzle("body") // Speed-up: Sizzle("body")
// The body element only exists once, optimize finding it // The body element only exists once, optimize finding it
if ( query === "body" && context.body ) { if ( query === "body" && context.body ) {
return makeArray( [ context.body ], extra ); return makeArray( [ context.body ], extra );
// Speed-up: Sizzle("#ID") // Speed-up: Sizzle("#ID")
} else if ( match && match[3] ) { } else if ( match && match[3] ) {
var elem = context.getElementById( match[3] ); var elem = context.getElementById( match[3] );
@ -5036,12 +5036,12 @@ if ( document.querySelectorAll ) {
if ( elem.id === match[3] ) { if ( elem.id === match[3] ) {
return makeArray( [ elem ], extra ); return makeArray( [ elem ], extra );
} }
} else { } else {
return makeArray( [], extra ); return makeArray( [], extra );
} }
} }
try { try {
return makeArray( context.querySelectorAll(query), extra ); return makeArray( context.querySelectorAll(query), extra );
} catch(qsaError) {} } catch(qsaError) {}
@ -5079,7 +5079,7 @@ if ( document.querySelectorAll ) {
} }
} }
} }
return oldSizzle(query, context, extra, seed); return oldSizzle(query, context, extra, seed);
}; };
@ -5106,7 +5106,7 @@ if ( document.querySelectorAll ) {
// This should fail with an exception // This should fail with an exception
// Gecko does not error, returns false instead // Gecko does not error, returns false instead
matches.call( document.documentElement, "[test!='']:sizzle" ); matches.call( document.documentElement, "[test!='']:sizzle" );
} catch( pseudoError ) { } catch( pseudoError ) {
pseudoWorks = true; pseudoWorks = true;
} }
@ -5116,7 +5116,7 @@ if ( document.querySelectorAll ) {
expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
if ( !Sizzle.isXML( node ) ) { if ( !Sizzle.isXML( node ) ) {
try { try {
if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) { if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
var ret = matches.call( node, expr ); var ret = matches.call( node, expr );
@ -5153,7 +5153,7 @@ if ( document.querySelectorAll ) {
if ( div.getElementsByClassName("e").length === 1 ) { if ( div.getElementsByClassName("e").length === 1 ) {
return; return;
} }
Expr.order.splice(1, 0, "CLASS"); Expr.order.splice(1, 0, "CLASS");
Expr.find.CLASS = function( match, context, isXML ) { Expr.find.CLASS = function( match, context, isXML ) {
if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
@ -5204,7 +5204,7 @@ function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
if ( elem ) { if ( elem ) {
var match = false; var match = false;
elem = elem[dir]; elem = elem[dir];
while ( elem ) { while ( elem ) {
@ -5257,7 +5257,7 @@ if ( document.documentElement.contains ) {
Sizzle.isXML = function( elem ) { Sizzle.isXML = function( elem ) {
// documentElement is verified for cases where it doesn't yet exist // documentElement is verified for cases where it doesn't yet exist
// (such as loading iframes in IE - #4833) // (such as loading iframes in IE - #4833)
var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
return documentElement ? documentElement.nodeName !== "HTML" : false; return documentElement ? documentElement.nodeName !== "HTML" : false;
@ -5374,11 +5374,11 @@ jQuery.fn.extend({
}, },
is: function( selector ) { is: function( selector ) {
return !!selector && ( return !!selector && (
typeof selector === "string" ? typeof selector === "string" ?
// If this is a positional selector, check membership in the returned set // If this is a positional selector, check membership in the returned set
// so $("p:first").is("p:last") won't return true for a doc with two "p". // so $("p:first").is("p:last") won't return true for a doc with two "p".
POS.test( selector ) ? POS.test( selector ) ?
jQuery( selector, this.context ).index( this[0] ) >= 0 : jQuery( selector, this.context ).index( this[0] ) >= 0 :
jQuery.filter( selector, this ).length > 0 : jQuery.filter( selector, this ).length > 0 :
this.filter( selector ).length > 0 ); this.filter( selector ).length > 0 );
@ -5386,7 +5386,7 @@ jQuery.fn.extend({
closest: function( selectors, context ) { closest: function( selectors, context ) {
var ret = [], i, l, cur = this[0]; var ret = [], i, l, cur = this[0];
// Array (deprecated as of jQuery 1.7) // Array (deprecated as of jQuery 1.7)
if ( jQuery.isArray( selectors ) ) { if ( jQuery.isArray( selectors ) ) {
var level = 1; var level = 1;

View File

@ -3645,7 +3645,7 @@ if ( !jQuery.support.submitBubbles ) {
}); });
// return undefined since we don't need an event listener // return undefined since we don't need an event listener
}, },
postDispatch: function( event ) { postDispatch: function( event ) {
// If form was submitted by the user, bubble the event up the tree // If form was submitted by the user, bubble the event up the tree
if ( event._submit_bubble ) { if ( event._submit_bubble ) {

82
tests/jquery-1.7.js vendored
View File

@ -3947,7 +3947,7 @@ var Sizzle = function( selector, context, results, seed ) {
if ( context.nodeType !== 1 && context.nodeType !== 9 ) { if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
return []; return [];
} }
if ( !selector || typeof selector !== "string" ) { if ( !selector || typeof selector !== "string" ) {
return results; return results;
} }
@ -3957,7 +3957,7 @@ var Sizzle = function( selector, context, results, seed ) {
contextXML = Sizzle.isXML( context ), contextXML = Sizzle.isXML( context ),
parts = [], parts = [],
soFar = selector; soFar = selector;
// Reset the position of the chunker regexp (start from head) // Reset the position of the chunker regexp (start from head)
do { do {
chunker.exec( "" ); chunker.exec( "" );
@ -3965,9 +3965,9 @@ var Sizzle = function( selector, context, results, seed ) {
if ( m ) { if ( m ) {
soFar = m[3]; soFar = m[3];
parts.push( m[1] ); parts.push( m[1] );
if ( m[2] ) { if ( m[2] ) {
extra = m[3]; extra = m[3];
break; break;
@ -3991,7 +3991,7 @@ var Sizzle = function( selector, context, results, seed ) {
if ( Expr.relative[ selector ] ) { if ( Expr.relative[ selector ] ) {
selector += parts.shift(); selector += parts.shift();
} }
set = posProcess( selector, set, seed ); set = posProcess( selector, set, seed );
} }
} }
@ -4119,7 +4119,7 @@ Sizzle.find = function( expr, context, isXML ) {
for ( i = 0, len = Expr.order.length; i < len; i++ ) { for ( i = 0, len = Expr.order.length; i < len; i++ ) {
type = Expr.order[i]; type = Expr.order[i];
if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
left = match[1]; left = match[1];
match.splice( 1, 1 ); match.splice( 1, 1 );
@ -4491,7 +4491,7 @@ var Expr = Sizzle.selectors = {
ATTR: function( match, curLoop, inplace, result, not, isXML ) { ATTR: function( match, curLoop, inplace, result, not, isXML ) {
var name = match[1] = match[1].replace( rBackslash, "" ); var name = match[1] = match[1].replace( rBackslash, "" );
if ( !isXML && Expr.attrMap[name] ) { if ( !isXML && Expr.attrMap[name] ) {
match[1] = Expr.attrMap[name]; match[1] = Expr.attrMap[name];
} }
@ -4525,7 +4525,7 @@ var Expr = Sizzle.selectors = {
} else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
return true; return true;
} }
return match; return match;
}, },
@ -4535,7 +4535,7 @@ var Expr = Sizzle.selectors = {
return match; return match;
} }
}, },
filters: { filters: {
enabled: function( elem ) { enabled: function( elem ) {
return elem.disabled === false && elem.type !== "hidden"; return elem.disabled === false && elem.type !== "hidden";
@ -4548,14 +4548,14 @@ var Expr = Sizzle.selectors = {
checked: function( elem ) { checked: function( elem ) {
return elem.checked === true; return elem.checked === true;
}, },
selected: function( elem ) { selected: function( elem ) {
// Accessing this property makes selected-by-default // Accessing this property makes selected-by-default
// options in Safari work properly // options in Safari work properly
if ( elem.parentNode ) { if ( elem.parentNode ) {
elem.parentNode.selectedIndex; elem.parentNode.selectedIndex;
} }
return elem.selected === true; return elem.selected === true;
}, },
@ -4577,7 +4577,7 @@ var Expr = Sizzle.selectors = {
text: function( elem ) { text: function( elem ) {
var attr = elem.getAttribute( "type" ), type = elem.type; var attr = elem.getAttribute( "type" ), type = elem.type;
// IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
// use getAttribute instead to test this case // use getAttribute instead to test this case
return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null ); return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null );
}, },
@ -4696,21 +4696,21 @@ var Expr = Sizzle.selectors = {
case "only": case "only":
case "first": case "first":
while ( (node = node.previousSibling) ) { while ( (node = node.previousSibling) ) {
if ( node.nodeType === 1 ) { if ( node.nodeType === 1 ) {
return false; return false;
} }
} }
if ( type === "first" ) { if ( type === "first" ) {
return true; return true;
} }
node = elem; node = elem;
case "last": case "last":
while ( (node = node.nextSibling) ) { while ( (node = node.nextSibling) ) {
if ( node.nodeType === 1 ) { if ( node.nodeType === 1 ) {
return false; return false;
} }
} }
@ -4723,22 +4723,22 @@ var Expr = Sizzle.selectors = {
if ( first === 1 && last === 0 ) { if ( first === 1 && last === 0 ) {
return true; return true;
} }
doneName = match[0]; doneName = match[0];
parent = elem.parentNode; parent = elem.parentNode;
if ( parent && (parent[ expando ] !== doneName || !elem.nodeIndex) ) { if ( parent && (parent[ expando ] !== doneName || !elem.nodeIndex) ) {
count = 0; count = 0;
for ( node = parent.firstChild; node; node = node.nextSibling ) { for ( node = parent.firstChild; node; node = node.nextSibling ) {
if ( node.nodeType === 1 ) { if ( node.nodeType === 1 ) {
node.nodeIndex = ++count; node.nodeIndex = ++count;
} }
} }
parent[ expando ] = doneName; parent[ expando ] = doneName;
} }
diff = elem.nodeIndex - last; diff = elem.nodeIndex - last;
if ( first === 0 ) { if ( first === 0 ) {
@ -4757,7 +4757,7 @@ var Expr = Sizzle.selectors = {
TAG: function( elem, match ) { TAG: function( elem, match ) {
return (match === "*" && elem.nodeType === 1) || !!elem.nodeName && elem.nodeName.toLowerCase() === match; return (match === "*" && elem.nodeType === 1) || !!elem.nodeName && elem.nodeName.toLowerCase() === match;
}, },
CLASS: function( elem, match ) { CLASS: function( elem, match ) {
return (" " + (elem.className || elem.getAttribute("class")) + " ") return (" " + (elem.className || elem.getAttribute("class")) + " ")
.indexOf( match ) > -1; .indexOf( match ) > -1;
@ -4827,7 +4827,7 @@ var makeArray = function( array, results ) {
results.push.apply( results, array ); results.push.apply( results, array );
return results; return results;
} }
return array; return array;
}; };
@ -5059,7 +5059,7 @@ if ( document.querySelectorAll ) {
if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
return; return;
} }
Sizzle = function( query, context, extra, seed ) { Sizzle = function( query, context, extra, seed ) {
context = context || document; context = context || document;
@ -5068,24 +5068,24 @@ if ( document.querySelectorAll ) {
if ( !seed && !Sizzle.isXML(context) ) { if ( !seed && !Sizzle.isXML(context) ) {
// See if we find a selector to speed up // See if we find a selector to speed up
var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query ); var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
if ( match && (context.nodeType === 1 || context.nodeType === 9) ) { if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
// Speed-up: Sizzle("TAG") // Speed-up: Sizzle("TAG")
if ( match[1] ) { if ( match[1] ) {
return makeArray( context.getElementsByTagName( query ), extra ); return makeArray( context.getElementsByTagName( query ), extra );
// Speed-up: Sizzle(".CLASS") // Speed-up: Sizzle(".CLASS")
} else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) { } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
return makeArray( context.getElementsByClassName( match[2] ), extra ); return makeArray( context.getElementsByClassName( match[2] ), extra );
} }
} }
if ( context.nodeType === 9 ) { if ( context.nodeType === 9 ) {
// Speed-up: Sizzle("body") // Speed-up: Sizzle("body")
// The body element only exists once, optimize finding it // The body element only exists once, optimize finding it
if ( query === "body" && context.body ) { if ( query === "body" && context.body ) {
return makeArray( [ context.body ], extra ); return makeArray( [ context.body ], extra );
// Speed-up: Sizzle("#ID") // Speed-up: Sizzle("#ID")
} else if ( match && match[3] ) { } else if ( match && match[3] ) {
var elem = context.getElementById( match[3] ); var elem = context.getElementById( match[3] );
@ -5098,12 +5098,12 @@ if ( document.querySelectorAll ) {
if ( elem.id === match[3] ) { if ( elem.id === match[3] ) {
return makeArray( [ elem ], extra ); return makeArray( [ elem ], extra );
} }
} else { } else {
return makeArray( [], extra ); return makeArray( [], extra );
} }
} }
try { try {
return makeArray( context.querySelectorAll(query), extra ); return makeArray( context.querySelectorAll(query), extra );
} catch(qsaError) {} } catch(qsaError) {}
@ -5141,7 +5141,7 @@ if ( document.querySelectorAll ) {
} }
} }
} }
return oldSizzle(query, context, extra, seed); return oldSizzle(query, context, extra, seed);
}; };
@ -5168,7 +5168,7 @@ if ( document.querySelectorAll ) {
// This should fail with an exception // This should fail with an exception
// Gecko does not error, returns false instead // Gecko does not error, returns false instead
matches.call( document.documentElement, "[test!='']:sizzle" ); matches.call( document.documentElement, "[test!='']:sizzle" );
} catch( pseudoError ) { } catch( pseudoError ) {
pseudoWorks = true; pseudoWorks = true;
} }
@ -5178,7 +5178,7 @@ if ( document.querySelectorAll ) {
expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
if ( !Sizzle.isXML( node ) ) { if ( !Sizzle.isXML( node ) ) {
try { try {
if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) { if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
var ret = matches.call( node, expr ); var ret = matches.call( node, expr );
@ -5215,7 +5215,7 @@ if ( document.querySelectorAll ) {
if ( div.getElementsByClassName("e").length === 1 ) { if ( div.getElementsByClassName("e").length === 1 ) {
return; return;
} }
Expr.order.splice(1, 0, "CLASS"); Expr.order.splice(1, 0, "CLASS");
Expr.find.CLASS = function( match, context, isXML ) { Expr.find.CLASS = function( match, context, isXML ) {
if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
@ -5266,7 +5266,7 @@ function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
if ( elem ) { if ( elem ) {
var match = false; var match = false;
elem = elem[dir]; elem = elem[dir];
while ( elem ) { while ( elem ) {
@ -5319,7 +5319,7 @@ if ( document.documentElement.contains ) {
Sizzle.isXML = function( elem ) { Sizzle.isXML = function( elem ) {
// documentElement is verified for cases where it doesn't yet exist // documentElement is verified for cases where it doesn't yet exist
// (such as loading iframes in IE - #4833) // (such as loading iframes in IE - #4833)
var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
return documentElement ? documentElement.nodeName !== "HTML" : false; return documentElement ? documentElement.nodeName !== "HTML" : false;
@ -5436,11 +5436,11 @@ jQuery.fn.extend({
}, },
is: function( selector ) { is: function( selector ) {
return !!selector && ( return !!selector && (
typeof selector === "string" ? typeof selector === "string" ?
// If this is a positional selector, check membership in the returned set // If this is a positional selector, check membership in the returned set
// so $("p:first").is("p:last") won't return true for a doc with two "p". // so $("p:first").is("p:last") won't return true for a doc with two "p".
POS.test( selector ) ? POS.test( selector ) ?
jQuery( selector, this.context ).index( this[0] ) >= 0 : jQuery( selector, this.context ).index( this[0] ) >= 0 :
jQuery.filter( selector, this ).length > 0 : jQuery.filter( selector, this ).length > 0 :
this.filter( selector ).length > 0 ); this.filter( selector ).length > 0 );
@ -5448,7 +5448,7 @@ jQuery.fn.extend({
closest: function( selectors, context ) { closest: function( selectors, context ) {
var ret = [], i, l, cur = this[0]; var ret = [], i, l, cur = this[0];
// Array (deprecated as of jQuery 1.7) // Array (deprecated as of jQuery 1.7)
if ( jQuery.isArray( selectors ) ) { if ( jQuery.isArray( selectors ) ) {
var level = 1; var level = 1;

2922
tests/jquery-1.8.0.js vendored

File diff suppressed because it is too large Load Diff

3058
tests/jquery-1.8.1.js vendored

File diff suppressed because it is too large Load Diff

3328
tests/jquery-1.8.2.js vendored

File diff suppressed because it is too large Load Diff

View File

@ -228,7 +228,7 @@ function findCenter( elem ) {
document = $( elem.ownerDocument ); document = $( elem.ownerDocument );
elem = $( elem ); elem = $( elem );
offset = elem.offset(); offset = elem.offset();
return { return {
x: offset.left + elem.outerWidth() / 2 - document.scrollLeft(), x: offset.left + elem.outerWidth() / 2 - document.scrollLeft(),
y: offset.top + elem.outerHeight() / 2 - document.scrollTop() y: offset.top + elem.outerHeight() / 2 - document.scrollTop()
@ -241,7 +241,7 @@ $.extend( $.simulate.prototype, {
options = this.options, options = this.options,
center = findCenter( target ), center = findCenter( target ),
x = Math.floor( center.x ), x = Math.floor( center.x ),
y = Math.floor( center.y ), y = Math.floor( center.y ),
dx = options.dx || 0, dx = options.dx || 0,
dy = options.dy || 0, dy = options.dy || 0,
coord = { clientX: x, clientY: y }; coord = { clientX: x, clientY: y };

View File

@ -5,9 +5,6 @@
<title>jQuery UI Accordion Test Suite</title> <title>jQuery UI Accordion Test Suite</title>
<script src="../../jquery.js"></script> <script src="../../jquery.js"></script>
<script>
$.uiBackCompat = false;
</script>
<link rel="stylesheet" href="../../../external/qunit.css"> <link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script> <script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script> <script src="../../jquery.simulate.js"></script>

View File

@ -1,29 +0,0 @@
TestHelpers.commonWidgetTests( "accordion", {
defaults: {
active: 0,
animate: null,
animated: "slide",
autoHeight: true,
clearStyle: false,
collapsible: false,
disabled: false,
event: "click",
fillSpace: false,
header: "> li > :first-child,> :not(li):even",
heightStyle: null,
icons: {
"activeHeader": null,
"header": "ui-icon-triangle-1-e",
"headerSelected": "ui-icon-triangle-1-s"
},
navigation: false,
navigationFilter: function() {},
// callbacks
activate: null,
beforeActivate: null,
change: null,
changestart: null,
create: null
}
});

View File

@ -1,140 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Accordion Test Suite</title>
<script src="../../jquery.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script>
TestHelpers.loadResources({
css: [ "ui.core", "ui.accordion" ],
js: [
"ui/jquery.ui.core.js",
"ui/jquery.ui.widget.js",
"ui/jquery.ui.accordion.js"
]
});
</script>
<script src="accordion_test_helpers.js"></script>
<script src="accordion_common_deprecated.js"></script>
<script src="accordion_core.js"></script>
<script src="accordion_events.js"></script>
<script src="accordion_methods.js"></script>
<script src="accordion_options.js"></script>
<script src="accordion_deprecated.js"></script>
<script src="../swarminject.js"></script>
<style>
#list, #list1 *, #navigation, #navigation * {
margin: 0;
padding: 0;
font-size: 12px;
line-height: 15px;
}
</style>
</head>
<body>
<h1 id="qunit-header">jQuery UI Accordion Test Suite</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">
<div id="list1" class="foo">
<h3 class="bar">There is one obvious advantage:</h3>
<div class="foo">
<p>
You've seen it coming!
<br>
Buy now and get nothing for free!
<br>
Well, at least no free beer. Perhaps a bear, if you can afford it.
</p>
</div>
<h3 class="bar">Now that you've got...</h3>
<div class="foo">
<p>
your bear, you have to admit it!
<br>
No, we aren't <a href="#">selling bears</a>.
</p>
<p>
We could talk about renting one.
</p>
</div>
<h3 class="bar">Rent one bear, ...</h3>
<div class="foo">
<p>
get two for three beer.
</p>
<p>
And now, for something completely different.
</p>
</div>
</div>
<div id="navigationWrapper">
<ul id="navigation">
<li>
<h2><a href="?p=1.1.1">Guitar</a></h2>
<ul>
<li><a href="?p=1.1.1.1">Electric</a></li>
<li><a href="?p=1.1.1.2">Acoustic</a></li>
<li><a href="?p=1.1.1.3">Amps</a></li>
<li><a href="?p=1.1.1.4">Effects</a></li>
<li><a href="?p=1.1.1.5">Accessories</a></li>
</ul>
</li>
<li>
<h2><a href="?p=1.1.2"><span>Bass</span></a></h2>
<ul>
<li><a href="?p=1.1.2.1">Electric</a></li>
<li><a href="?p=1.1.2.2">Acoustic</a></li>
<li><a href="?p=1.1.2.3">Amps</a></li>
<li><a href="?p=1.1.2.4">Effects</a></li>
<li><a href="?p=1.1.2.5">Accessories</a></li>
<li><a href="?p=1.1.2.5">Accessories</a></li>
<li><a href="?p=1.1.2.5">Accessories</a></li>
</ul>
</li>
<li>
<h2><a href="?p=1.1.3">Drums</a></h2>
<ul>
<li><a href="?p=1.1.3.2">Acoustic</a></li>
<li><a href="?p=1.1.3.3">Electronic</a></li>
<li><a href="?p=1.1.3.6">Accessories</a></li>
</ul>
</li>
</ul>
</div>
<dl id="accordion-dl">
<dt>
Accordion Header 1
</dt>
<dd>
Accordion Content 1
</dd>
<dt>
Accordion Header 2
</dt>
<dd>
Accordion Content 2
</dd>
<dt>
Accordion Header 3
</dt>
<dd>
Accordion Content 3
</dd>
</dl>
</div>
</body>
</html>

View File

@ -1,342 +0,0 @@
(function( $ ) {
var equalHeight = TestHelpers.accordion.equalHeight,
setupTeardown = TestHelpers.accordion.setupTeardown,
state = TestHelpers.accordion.state;
module( "accordion (deprecated): expanded active option, activate method", setupTeardown() );
test( "activate, numeric", function() {
expect( 5 );
var element = $( "#list1" ).accordion({ active: 1 });
state( element, 0, 1, 0 );
element.accordion( "activate", 2 );
state( element, 0, 0, 1 );
element.accordion( "activate", 0 );
state( element, 1, 0, 0 );
element.accordion( "activate", 1 );
state( element, 0, 1, 0 );
element.accordion( "activate", 2 );
state( element, 0, 0, 1 );
});
test( "activate, numeric, collapsible:true", function() {
expect( 3 );
var element = $( "#list1" ).accordion({ collapsible: true });
element.accordion( "activate", 2 );
state( element, 0, 0, 1 );
element.accordion( "activate", 0 );
state( element, 1, 0, 0 );
element.accordion( "activate", -1 );
state( element, 0, 0, 0 );
});
test( "activate, boolean, collapsible: true", function() {
expect( 2 );
var element = $( "#list1" ).accordion({ collapsible: true });
element.accordion( "activate", 2 );
state( element, 0, 0, 1 );
element.accordion( "activate", false );
state( element, 0, 0, 0 );
});
test( "activate, boolean, collapsible: false", function() {
expect( 2 );
var element = $( "#list1" ).accordion();
element.accordion( "activate", 2 );
state( element, 0, 0, 1 );
element.accordion( "activate", false );
state( element, 0, 0, 1 );
});
test( "activate, string expression", function() {
expect( 4 );
var element = $( "#list1" ).accordion({ active: "h3:last" });
state( element, 0, 0, 1 );
element.accordion( "activate", ":first" );
state( element, 1, 0, 0 );
element.accordion( "activate", ":eq(1)" );
state( element, 0, 1, 0 );
element.accordion( "activate", ":last" );
state( element, 0, 0, 1 );
});
test( "activate, jQuery or DOM element", function() {
expect( 3 );
var element = $( "#list1" ).accordion({ active: $( "#list1 h3:last" ) });
state( element, 0, 0, 1 );
element.accordion( "activate", $( "#list1 h3:first" ) );
state( element, 1, 0, 0 );
element.accordion( "activate", $( "#list1 h3" )[ 1 ] );
state( element, 0, 1, 0 );
});
test( "{ active: Selector }", function() {
expect( 2 );
var element = $("#list1").accordion({
active: "h3:last"
});
state( element, 0, 0, 1 );
element.accordion( "option", "active", "h3:eq(1)" );
state( element, 0, 1, 0 );
});
test( "{ active: Element }", function() {
expect( 2 );
var element = $( "#list1" ).accordion({
active: $( "#list1 h3:last" )[ 0 ]
});
state( element, 0, 0, 1 );
element.accordion( "option", "active", $( "#list1 h3:eq(1)" )[ 0 ] );
state( element, 0, 1, 0 );
});
test( "{ active: jQuery Object }", function() {
expect( 2 );
var element = $( "#list1" ).accordion({
active: $( "#list1 h3:last" )
});
state( element, 0, 0, 1 );
element.accordion( "option", "active", $( "#list1 h3:eq(1)" ) );
state( element, 0, 1, 0 );
});
module( "accordion (deprecated) - height options", setupTeardown() );
test( "{ autoHeight: true }, default", function() {
expect( 3 );
equalHeight( $( "#navigation" ).accordion({ autoHeight: true }), 105 );
});
test( "{ autoHeight: false }", function() {
expect( 3 );
var element = $( "#navigation" ).accordion({ autoHeight: false }),
sizes = [];
element.find( ".ui-accordion-content" ).each(function() {
sizes.push( $(this).height() );
});
ok( sizes[0] >= 70 && sizes[0] <= 105, "was " + sizes[0] );
ok( sizes[1] >= 98 && sizes[1] <= 126, "was " + sizes[1] );
ok( sizes[2] >= 42 && sizes[2] <= 54, "was " + sizes[2] );
});
test( "{ fillSpace: true }", function() {
expect( 3 );
$( "#navigationWrapper" ).height( 500 );
var element = $( "#navigation" ).accordion({ fillSpace: true });
equalHeight( element, 455 );
});
test( "{ fillSapce: true } with sibling", function() {
expect( 3 );
$( "#navigationWrapper" ).height( 500 );
$( "<p>Lorem Ipsum</p>" )
.css({
height: 50,
marginTop: 20,
marginBottom: 30
})
.prependTo( "#navigationWrapper" );
var element = $( "#navigation" ).accordion({ fillSpace: true });
equalHeight( element , 355 );
});
test( "{ fillSpace: true } with multiple siblings", function() {
expect( 3 );
$( "#navigationWrapper" ).height( 500 );
$( "<p>Lorem Ipsum</p>" )
.css({
height: 50,
marginTop: 20,
marginBottom: 30
})
.prependTo( "#navigationWrapper" );
$( "<p>Lorem Ipsum</p>" )
.css({
height: 50,
marginTop: 20,
marginBottom: 30,
position: "absolute"
})
.prependTo( "#navigationWrapper" );
$( "<p>Lorem Ipsum</p>" )
.css({
height: 25,
marginTop: 10,
marginBottom: 15
})
.prependTo( "#navigationWrapper" );
var element = $( "#navigation" ).accordion({ fillSpace: true });
equalHeight( element, 305 );
});
module( "accordion (deprecated) - icons", setupTeardown() );
test( "icons, headerSelected", function() {
expect( 3 );
var element = $( "#list1" ).accordion({
icons: { headerSelected: "a1", header: "h1" }
});
ok( element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ).hasClass( "a1" ) );
element.accordion( "option", "icons", { headerSelected: "a2", header: "h2" } );
ok( !element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ).hasClass( "a1" ) );
ok( element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ).hasClass( "a2" ) );
});
module( "accordion (deprecated) - resize", setupTeardown() );
test( "resize", function() {
expect( 6 );
var element = $( "#navigation" )
.parent()
.height( 300 )
.end()
.accordion({
heightStyle: "fill"
});
equalHeight( element, 255 );
element.parent().height( 500 );
element.accordion( "resize" );
equalHeight( element, 455 );
});
module( "accordion (deprecated) - navigation", setupTeardown() );
test( "{ navigation: true, navigationFilter: header }", function() {
expect( 2 );
var element = $( "#navigation" ).accordion({
navigation: true,
navigationFilter: function() {
return (/\?p=1\.1\.3$/).test( this.href );
}
});
equal( element.accordion( "option", "active" ), 2 );
state( element, 0, 0, 1 );
});
test( "{ navigation: true, navigationFilter: content }", function() {
expect( 2 );
var element = $( "#navigation" ).accordion({
navigation: true,
navigationFilter: function() {
return (/\?p=1\.1\.3\.2$/).test( this.href );
}
});
equal( element.accordion( "option", "active" ), 2 );
state( element, 0, 0, 1 );
});
module( "accordion (deprecated) - changestart/change events", setupTeardown() );
test( "changestart", function() {
expect( 26 );
var element = $( "#list1" ).accordion({
active: false,
collapsible: true
}),
headers = element.find( ".ui-accordion-header" ),
content = element.find( ".ui-accordion-content" );
element.one( "accordionchangestart", function( event, ui ) {
equal( ui.oldHeader.length, 0 );
equal( ui.oldContent.length, 0 );
equal( ui.newHeader.length, 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 0 ] );
equal( ui.newContent.length, 1 );
strictEqual( ui.newContent[ 0 ], content[ 0 ] );
state( element, 0, 0, 0 );
});
element.accordion( "option", "active", 0 );
state( element, 1, 0, 0 );
element.one( "accordionchangestart", function( event, ui ) {
equal( ui.oldHeader.length, 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] );
equal( ui.oldContent.length, 1 );
strictEqual( ui.oldContent[ 0 ], content[ 0 ] );
equal( ui.newHeader.length, 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 1 ] );
equal( ui.newContent.length, 1 );
strictEqual( ui.newContent[ 0 ], content[ 1 ] );
state( element, 1, 0, 0 );
});
headers.eq( 1 ).click();
state( element, 0, 1, 0 );
element.one( "accordionchangestart", function( event, ui ) {
equal( ui.oldHeader.length, 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] );
equal( ui.oldContent.length, 1 );
strictEqual( ui.oldContent[ 0 ], content[ 1 ] );
equal( ui.newHeader.length, 0 );
equal( ui.newContent.length, 0 );
state( element, 0, 1, 0 );
});
element.accordion( "option", "active", false );
state( element, 0, 0, 0 );
});
test( "change", function() {
expect( 20 );
var element = $( "#list1" ).accordion({
active: false,
collapsible: true
}),
headers = element.find( ".ui-accordion-header" ),
content = element.find( ".ui-accordion-content" );
element.one( "accordionchange", function( event, ui ) {
equal( ui.oldHeader.length, 0 );
equal( ui.oldContent.length, 0 );
equal( ui.newHeader.length, 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 0 ] );
equal( ui.newContent.length, 1 );
strictEqual( ui.newContent[ 0 ], content[ 0 ] );
});
element.accordion( "option", "active", 0 );
element.one( "accordionchange", function( event, ui ) {
equal( ui.oldHeader.length, 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] );
equal( ui.oldContent.length, 1 );
strictEqual( ui.oldContent[ 0 ], content[ 0 ] );
equal( ui.newHeader.length, 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 1 ] );
equal( ui.newContent.length, 1 );
strictEqual( ui.newContent[ 0 ], content[ 1 ] );
});
headers.eq( 1 ).click();
element.one( "accordionchange", function( event, ui ) {
equal( ui.oldHeader.length, 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] );
equal( ui.oldContent.length, 1 );
strictEqual( ui.oldContent[ 0 ], content[ 1 ] );
equal( ui.newHeader.length, 0 );
equal( ui.newContent.length, 0 );
});
element.accordion( "option", "active", false );
});
})(jQuery);

View File

@ -13,6 +13,15 @@ test( "{ active: default }", function() {
state( element, 1, 0, 0 ); state( element, 1, 0, 0 );
}); });
test( "{ active: null }", function() {
expect( 2 );
var element = $( "#list1" ).accordion({
active: null
});
equal( element.accordion( "option", "active" ), 0 );
state( element, 1, 0, 0 );
});
test( "{ active: false }", function() { test( "{ active: false }", function() {
expect( 7 ); expect( 7 );
var element = $( "#list1" ).accordion({ var element = $( "#list1" ).accordion({
@ -56,28 +65,26 @@ test( "{ active: Number }", function() {
state( element, 0, 1, 0 ); state( element, 0, 1, 0 );
}); });
if ( $.uiBackCompat === false ) { test( "{ active: -Number }", function() {
test( "{ active: -Number }", function() { expect( 8 );
expect( 8 ); var element = $( "#list1" ).accordion({
var element = $( "#list1" ).accordion({ active: -1
active: -1
});
equal( element.accordion( "option", "active" ), 2 );
state( element, 0, 0, 1 );
element.accordion( "option", "active", -2 );
equal( element.accordion( "option", "active" ), 1 );
state( element, 0, 1, 0 );
element.accordion( "option", "active", -10 );
equal( element.accordion( "option", "active" ), 1 );
state( element, 0, 1, 0 );
element.accordion( "option", "active", -3 );
equal( element.accordion( "option", "active" ), 0 );
state( element, 1, 0, 0 );
}); });
} equal( element.accordion( "option", "active" ), 2 );
state( element, 0, 0, 1 );
element.accordion( "option", "active", -2 );
equal( element.accordion( "option", "active" ), 1 );
state( element, 0, 1, 0 );
element.accordion( "option", "active", -10 );
equal( element.accordion( "option", "active" ), 1 );
state( element, 0, 1, 0 );
element.accordion( "option", "active", -3 );
equal( element.accordion( "option", "active" ), 0 );
state( element, 1, 0, 0 );
});
test( "{ animate: false }", function() { test( "{ animate: false }", function() {
expect( 3 ); expect( 3 );

View File

@ -1,72 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Test Suite</title>
<script src="../../jquery-1.8.2.js"></script>
<link rel="stylesheet" href="../../external/qunit.css">
<link rel="stylesheet" href="qunit-composite.css">
<script src="../../external/qunit.js"></script>
<script src="qunit-composite.js"></script>
<script>
(function() {
var params = [],
suites = [
"accordion/accordion.html",
"accordion/accordion_deprecated.html",
"autocomplete/autocomplete.html",
"button/button.html",
"core/core.html",
//"datepicker/datepicker.html",
//"dialog/dialog.html",
//"draggable/draggable.html",
//"droppable/droppable.html",
"effects/effects.html",
"menu/menu.html",
"position/position.html",
"position/position_deprecated.html",
"progressbar/progressbar.html",
//"resizable/resizable.html",
//"selectable/selectable.html",
//"slider/slider.html",
//"sortable/sortable.html",
"spinner/spinner.html",
"tabs/tabs.html",
"tabs/tabs_deprecated.html",
"tooltip/tooltip.html",
"widget/widget.html"
];
$.each( QUnit.urlParams, function( key, value ) {
if ( key === "filter" ) {
return;
}
params.push( encodeURIComponent( key ) + "=" + encodeURIComponent( value ) );
});
if ( params.length ) {
params = "?" + params.join( "&" );
suites = $.map( suites, function( suite ) {
return suite + params;
});
}
QUnit.testSuites( suites );
}());
</script>
</head>
<body>
<h1 id="qunit-header">jQuery UI Test Suite</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">
</div>
</body>
</html>

View File

@ -17,26 +17,23 @@
var params = [], var params = [],
suites = [ suites = [
"accordion/accordion.html", "accordion/accordion.html",
"accordion/accordion_deprecated.html",
"autocomplete/autocomplete.html", "autocomplete/autocomplete.html",
"button/button.html", "button/button.html",
"core/core.html", "core/core.html",
"datepicker/datepicker.html", "datepicker/datepicker.html",
"dialog/dialog.html", "dialog/dialog.html",
//"draggable/draggable.html", "draggable/draggable.html",
//"droppable/droppable.html", "droppable/droppable.html",
"effects/effects.html", "effects/effects.html",
"menu/menu.html", "menu/menu.html",
"position/position.html", "position/position.html",
"position/position_deprecated.html",
"progressbar/progressbar.html", "progressbar/progressbar.html",
//"resizable/resizable.html", "resizable/resizable.html",
//"selectable/selectable.html", "selectable/selectable.html",
"slider/slider.html", "slider/slider.html",
//"sortable/sortable.html", "sortable/sortable.html",
"spinner/spinner.html", "spinner/spinner.html",
"tabs/tabs.html", "tabs/tabs.html",
"tabs/tabs_deprecated.html",
"tooltip/tooltip.html", "tooltip/tooltip.html",
"widget/widget.html" "widget/widget.html"
]; ];

View File

@ -99,7 +99,7 @@ test( "allow form submit on enter when menu is not active", function() {
delay: 0, delay: 0,
minLength: 0 minLength: 0
}); });
element.data( "autocomplete" )._move = function() { element.data( "ui-autocomplete" )._move = function() {
didMove = true; didMove = true;
}; };
element.simulate( "keydown", { keyCode: ( isKeyUp ? $.ui.keyCode.UP : $.ui.keyCode.DOWN ) } ); element.simulate( "keydown", { keyCode: ( isKeyUp ? $.ui.keyCode.UP : $.ui.keyCode.DOWN ) } );
@ -109,13 +109,12 @@ test( "allow form submit on enter when menu is not active", function() {
function arrowsMoveFocus( id, isKeyUp ) { function arrowsMoveFocus( id, isKeyUp ) {
expect( 1 ); expect( 1 );
var didMove = false, var element = $( id ).autocomplete({
element = $( id ).autocomplete({
source: [ "a" ], source: [ "a" ],
delay: 0, delay: 0,
minLength: 0 minLength: 0
}); });
element.data( "autocomplete" )._move = function() { element.data( "ui-autocomplete" )._move = function() {
ok( true, "repsond to arrow" ); ok( true, "repsond to arrow" );
}; };
element.autocomplete( "search" ); element.autocomplete( "search" );

View File

@ -39,7 +39,7 @@ $.each([
], "response ui.content" ); ], "response ui.content" );
ui.content.splice( 0, 1 ); ui.content.splice( 0, 1 );
}, },
open: function( event ) { open: function() {
ok( menu.is( ":visible" ), "menu open on open" ); ok( menu.is( ":visible" ), "menu open on open" );
}, },
focus: function( event, ui ) { focus: function( event, ui ) {
@ -127,7 +127,7 @@ asyncTest( "cancel focus", function() {
element = $( "#autocomplete" ).autocomplete({ element = $( "#autocomplete" ).autocomplete({
delay: 0, delay: 0,
source: data, source: data,
focus: function( event, ui ) { focus: function() {
$( this ).val( customVal ); $( this ).val( customVal );
return false; return false;
} }
@ -146,7 +146,7 @@ asyncTest( "cancel select", function() {
element = $( "#autocomplete" ).autocomplete({ element = $( "#autocomplete" ).autocomplete({
delay: 0, delay: 0,
source: data, source: data,
select: function( event, ui ) { select: function() {
$( this ).val( customVal ); $( this ).val( customVal );
return false; return false;
} }

View File

@ -33,7 +33,7 @@ function autoFocusTest( afValue, focusedLength ) {
autoFocus: afValue, autoFocus: afValue,
delay: 0, delay: 0,
source: data, source: data,
open: function( event, ui ) { open: function() {
equal( element.autocomplete( "widget" ).children( ".ui-menu-item:first" ).find( ".ui-state-focus" ).length, equal( element.autocomplete( "widget" ).children( ".ui-menu-item:first" ).find( ".ui-state-focus" ).length,
focusedLength, "first item is " + (afValue ? "" : "not") + " auto focused" ); focusedLength, "first item is " + (afValue ? "" : "not") + " auto focused" );
start(); start();

View File

@ -1,7 +1,7 @@
/* /*
* button_events.js * button_events.js
*/ */
(function($) { (function() {
module("button: events"); module("button: events");

View File

@ -61,4 +61,12 @@ test( "#7534 - Button label selector works for ids with \":\"", function() {
ok( group.find( "label" ).is( ".ui-button" ), "Found an id with a :" ); ok( group.find( "label" ).is( ".ui-button" ), "Found an id with a :" );
}); });
test( "#8237 - Anchor tags lose disabled state when refreshed", function() {
expect( 1 );
var element = $( "<a id='a8237'></a>" ).appendTo( "#qunit-fixture" );
element.button({ disabled: true }).button( "refresh" );
ok( element.button( "option", "disabled" ), "Anchor button should remain disabled after refresh" );
});
})( jQuery ); })( jQuery );

View File

@ -112,6 +112,11 @@
<span id="spanTabindex-50" tabindex="-50">.</span> <span id="spanTabindex-50" tabindex="-50">.</span>
</div> </div>
<div style="width: 0; height: 0;">
<input id="dimensionlessParent">
<input id="dimensionlessParent-dimensionless" style="height: 0; width: 0;">
</div>
<div id="zIndex100" style="z-index: 100; position: absolute"> <div id="zIndex100" style="z-index: 100; position: absolute">
<div id="zIndexAutoWithParent">.</div> <div id="zIndexAutoWithParent">.</div>
</div> </div>

View File

@ -157,6 +157,12 @@ test("focusable - area elements", function() {
isNotFocusable('#areaNoImg', 'not associated with an image'); isNotFocusable('#areaNoImg', 'not associated with an image');
}); });
test( "focusable - dimensionless parent with overflow", function() {
expect( 1 );
isFocusable( "#dimensionlessParent", "input" );
});
test("tabbable - visible, enabled elements", function() { test("tabbable - visible, enabled elements", function() {
expect(18); expect(18);
@ -236,4 +242,10 @@ test("tabbable - area elements", function() {
isNotTabbable('#areaNoImg', 'not associated with an image'); isNotTabbable('#areaNoImg', 'not associated with an image');
}); });
test( "tabbable - dimensionless parent with overflow", function() {
expect( 1 );
isTabbable( "#dimensionlessParent", "input" );
});
})(jQuery); })(jQuery);

View File

@ -27,18 +27,8 @@
<script src="datepicker_events.js"></script> <script src="datepicker_events.js"></script>
<script src="datepicker_methods.js"></script> <script src="datepicker_methods.js"></script>
<script src="datepicker_options.js"></script> <script src="datepicker_options.js"></script>
<script src="datepicker_tickets.js"></script> <script src="datepicker_test_helpers.js"></script>
<script>
// disable this stale testsuite for testswarm only
var url = window.location.search;
url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + 9 ) );
if ( url && url.indexOf("http") == 0 ) {
// reset config to kill previous tests; make sure testsuite.js is loaded afterwards to init the testswarm script
QUnit.init();
test("datepicker", function() { ok(true, "disabled datepicker testsuite"); });
}
</script>
<script src="../swarminject.js"></script> <script src="../swarminject.js"></script>
</head> </head>
<body> <body>

View File

@ -2,42 +2,6 @@
* datepicker_core.js * datepicker_core.js
*/ */
function equalsDate(d1, d2, message) {
if (!d1 || !d2) {
ok(false, message + ' - missing date');
return;
}
d1 = new Date(d1.getFullYear(), d1.getMonth(), d1.getDate());
d2 = new Date(d2.getFullYear(), d2.getMonth(), d2.getDate());
equal(d1.toString(), d2.toString(), message);
}
function equalsDateArray(a1, a2, message) {
if (!a1 || !a2) {
ok(false, message + ' - missing dates');
return;
}
a1[0] = (a1[0] ? new Date(a1[0].getFullYear(), a1[0].getMonth(), a1[0].getDate()) : '');
a1[1] = (a1[1] ? new Date(a1[1].getFullYear(), a1[1].getMonth(), a1[1].getDate()) : '');
a2[0] = (a2[0] ? new Date(a2[0].getFullYear(), a2[0].getMonth(), a2[0].getDate()) : '');
a2[1] = (a2[1] ? new Date(a2[1].getFullYear(), a2[1].getMonth(), a2[1].getDate()) : '');
deepEqual(a1, a2, message);
}
function addMonths(date, offset) {
var maxDay = 32 - new Date(date.getFullYear(), date.getMonth() + offset, 32).getDate();
date.setDate(Math.min(date.getDate(), maxDay));
date.setMonth(date.getMonth() + offset);
return date;
}
function init(id, options) {
$.datepicker.setDefaults($.datepicker.regional['']);
return $(id).datepicker($.extend({showAnim: ''}, options || {}));
}
var PROP_NAME = 'datepicker';
(function($) { (function($) {
module("datepicker: core"); module("datepicker: core");
@ -55,15 +19,14 @@ test("widget method", function() {
}); });
test('baseStructure', function() { test('baseStructure', function() {
expect( 59 ); expect( 58 );
var header, title, table, thead, week, panel, inl, child, var header, title, table, thead, week, panel, inl, child,
inp = init('#inp').focus(), inp = TestHelpers.datepicker.init('#inp').focus(),
dp = $('#ui-datepicker-div'), dp = $('#ui-datepicker-div');
iframe = ($.ui.ie6);
ok(dp.is(':visible'), 'Structure - datepicker visible'); ok(dp.is(':visible'), 'Structure - datepicker visible');
ok(!dp.is('.ui-datepicker-rtl'), 'Structure - not right-to-left'); ok(!dp.is('.ui-datepicker-rtl'), 'Structure - not right-to-left');
ok(!dp.is('.ui-datepicker-multi'), 'Structure - not multi-month'); ok(!dp.is('.ui-datepicker-multi'), 'Structure - not multi-month');
equal(dp.children().length, 2 + (iframe ? 1 : 0), 'Structure - child count'); equal(dp.children().length, 2, 'Structure - child count');
header = dp.children(':first'); header = dp.children(':first');
ok(header.is('div.ui-datepicker-header'), 'Structure - header division'); ok(header.is('div.ui-datepicker-header'), 'Structure - header division');
@ -90,11 +53,10 @@ test('baseStructure', function() {
equal(week.children().length, 7, 'Structure - week child count'); equal(week.children().length, 7, 'Structure - week child count');
ok(week.children(':first').is('td.ui-datepicker-week-end'), 'Structure - month table first day cell'); ok(week.children(':first').is('td.ui-datepicker-week-end'), 'Structure - month table first day cell');
ok(week.children(':last').is('td.ui-datepicker-week-end'), 'Structure - month table second day cell'); ok(week.children(':last').is('td.ui-datepicker-week-end'), 'Structure - month table second day cell');
ok(dp.children('iframe').length === (iframe ? 1 : 0), 'Structure - iframe');
inp.datepicker('hide').datepicker('destroy'); inp.datepicker('hide').datepicker('destroy');
// Editable month/year and button panel // Editable month/year and button panel
inp = init('#inp', {changeMonth: true, changeYear: true, showButtonPanel: true}); inp = TestHelpers.datepicker.init('#inp', {changeMonth: true, changeYear: true, showButtonPanel: true});
inp.focus(); inp.focus();
title = dp.find('div.ui-datepicker-title'); title = dp.find('div.ui-datepicker-title');
@ -109,10 +71,10 @@ test('baseStructure', function() {
inp.datepicker('hide').datepicker('destroy'); inp.datepicker('hide').datepicker('destroy');
// Multi-month 2 // Multi-month 2
inp = init('#inp', {numberOfMonths: 2}); inp = TestHelpers.datepicker.init('#inp', {numberOfMonths: 2});
inp.focus(); inp.focus();
ok(dp.is('.ui-datepicker-multi'), 'Structure multi [2] - multi-month'); ok(dp.is('.ui-datepicker-multi'), 'Structure multi [2] - multi-month');
equal(dp.children().length, 3 + (iframe ? 1 : 0), 'Structure multi [2] - child count'); equal(dp.children().length, 3, 'Structure multi [2] - child count');
child = dp.children(':first'); child = dp.children(':first');
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure multi [2] - first month division'); ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure multi [2] - first month division');
child = dp.children(':eq(1)'); child = dp.children(':eq(1)');
@ -123,17 +85,17 @@ test('baseStructure', function() {
inp.datepicker('hide').datepicker('destroy'); inp.datepicker('hide').datepicker('destroy');
// Multi-month 3 // Multi-month 3
inp = init('#inp', {numberOfMonths: 3}); inp = TestHelpers.datepicker.init('#inp', {numberOfMonths: 3});
inp.focus(); inp.focus();
ok(dp.is('.ui-datepicker-multi-3'), 'Structure multi [3] - multi-3'); ok(dp.is('.ui-datepicker-multi-3'), 'Structure multi [3] - multi-3');
ok(! dp.is('.ui-datepicker-multi-2'), 'Structure multi [3] - Trac #6704'); ok(! dp.is('.ui-datepicker-multi-2'), 'Structure multi [3] - Trac #6704');
inp.datepicker('hide').datepicker('destroy'); inp.datepicker('hide').datepicker('destroy');
// Multi-month [2, 2] // Multi-month [2, 2]
inp = init('#inp', {numberOfMonths: [2, 2]}); inp = TestHelpers.datepicker.init('#inp', {numberOfMonths: [2, 2]});
inp.focus(); inp.focus();
ok(dp.is('.ui-datepicker-multi'), 'Structure multi - multi-month'); ok(dp.is('.ui-datepicker-multi'), 'Structure multi - multi-month');
equal(dp.children().length, 6 + (iframe ? 1 : 0), 'Structure multi [2,2] - child count'); equal(dp.children().length, 6, 'Structure multi [2,2] - child count');
child = dp.children(':first'); child = dp.children(':first');
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure multi [2,2] - first month division'); ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure multi [2,2] - first month division');
child = dp.children(':eq(1)'); child = dp.children(':eq(1)');
@ -149,7 +111,7 @@ test('baseStructure', function() {
inp.datepicker('hide').datepicker('destroy'); inp.datepicker('hide').datepicker('destroy');
// Inline // Inline
inl = init('#inl'); inl = TestHelpers.datepicker.init('#inl');
dp = inl.children(); dp = inl.children();
ok(dp.is('.ui-datepicker-inline'), 'Structure inline - main div'); ok(dp.is('.ui-datepicker-inline'), 'Structure inline - main div');
ok(!dp.is('.ui-datepicker-rtl'), 'Structure inline - not right-to-left'); ok(!dp.is('.ui-datepicker-rtl'), 'Structure inline - not right-to-left');
@ -165,10 +127,10 @@ test('baseStructure', function() {
inl.datepicker('destroy'); inl.datepicker('destroy');
// Inline multi-month // Inline multi-month
inl = init('#inl', {numberOfMonths: 2}); inl = TestHelpers.datepicker.init('#inl', {numberOfMonths: 2});
dp = inl.children(); dp = inl.children();
ok(dp.is('.ui-datepicker-inline') && dp.is('.ui-datepicker-multi'), 'Structure inline multi - main div'); ok(dp.is('.ui-datepicker-inline') && dp.is('.ui-datepicker-multi'), 'Structure inline multi - main div');
equal(dp.children().length, 3 + (iframe ? 1 : 0), 'Structure inline multi - child count'); equal(dp.children().length, 3, 'Structure inline multi - child count');
child = dp.children(':first'); child = dp.children(':first');
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure inline multi - first month division'); ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure inline multi - first month division');
child = dp.children(':eq(1)'); child = dp.children(':eq(1)');
@ -180,13 +142,12 @@ test('baseStructure', function() {
test('customStructure', function() { test('customStructure', function() {
expect( 20 ); expect( 20 );
var iframe, header, panel, title, thead, var header, panel, title, thead,
dp = $('#ui-datepicker-div'), dp = $('#ui-datepicker-div'),
// Check right-to-left localisation // Check right-to-left localisation
inp = init('#inp', $.datepicker.regional.he); inp = TestHelpers.datepicker.init('#inp', $.datepicker.regional.he);
inp.data('showButtonPanel.datepicker',true); inp.data('showButtonPanel.datepicker',true);
inp.focus(); inp.focus();
iframe = ($.ui.ie6);
ok(dp.is('.ui-datepicker-rtl'), 'Structure RTL - right-to-left'); ok(dp.is('.ui-datepicker-rtl'), 'Structure RTL - right-to-left');
header = dp.children(':first'); header = dp.children(':first');
ok(header.is('div.ui-datepicker-header'), 'Structure RTL - header division'); ok(header.is('div.ui-datepicker-header'), 'Structure RTL - header division');
@ -201,7 +162,7 @@ test('customStructure', function() {
inp.datepicker('hide').datepicker('destroy'); inp.datepicker('hide').datepicker('destroy');
// Hide prev/next // Hide prev/next
inp = init('#inp', {hideIfNoPrevNext: true, minDate: new Date(2008, 2 - 1, 4), maxDate: new Date(2008, 2 - 1, 14)}); inp = TestHelpers.datepicker.init('#inp', {hideIfNoPrevNext: true, minDate: new Date(2008, 2 - 1, 4), maxDate: new Date(2008, 2 - 1, 14)});
inp.val('02/10/2008').focus(); inp.val('02/10/2008').focus();
header = dp.children(':first'); header = dp.children(':first');
ok(header.is('div.ui-datepicker-header'), 'Structure hide prev/next - header division'); ok(header.is('div.ui-datepicker-header'), 'Structure hide prev/next - header division');
@ -210,7 +171,7 @@ test('customStructure', function() {
inp.datepicker('hide').datepicker('destroy'); inp.datepicker('hide').datepicker('destroy');
// Changeable Month with read-only year // Changeable Month with read-only year
inp = init('#inp', {changeMonth: true}); inp = TestHelpers.datepicker.init('#inp', {changeMonth: true});
inp.focus(); inp.focus();
title = dp.children(':first').children(':last'); title = dp.children(':first').children(':last');
equal(title.children().length, 2, 'Structure changeable month - title child count'); equal(title.children().length, 2, 'Structure changeable month - title child count');
@ -219,7 +180,7 @@ test('customStructure', function() {
inp.datepicker('hide').datepicker('destroy'); inp.datepicker('hide').datepicker('destroy');
// Changeable year with read-only month // Changeable year with read-only month
inp = init('#inp', {changeYear: true}); inp = TestHelpers.datepicker.init('#inp', {changeYear: true});
inp.focus(); inp.focus();
title = dp.children(':first').children(':last'); title = dp.children(':first').children(':last');
equal(title.children().length, 2, 'Structure changeable year - title child count'); equal(title.children().length, 2, 'Structure changeable year - title child count');
@ -228,7 +189,7 @@ test('customStructure', function() {
inp.datepicker('hide').datepicker('destroy'); inp.datepicker('hide').datepicker('destroy');
// Read-only first day of week // Read-only first day of week
inp = init('#inp', {changeFirstDay: false}); inp = TestHelpers.datepicker.init('#inp', {changeFirstDay: false});
inp.focus(); inp.focus();
thead = dp.find('.ui-datepicker-calendar thead tr'); thead = dp.find('.ui-datepicker-calendar thead tr');
equal(thead.children().length, 7, 'Structure read-only first day - thead child count'); equal(thead.children().length, 7, 'Structure read-only first day - thead child count');
@ -238,19 +199,19 @@ test('customStructure', function() {
test('keystrokes', function() { test('keystrokes', function() {
expect( 26 ); expect( 26 );
var inp = init('#inp'), var inp = TestHelpers.datepicker.init('#inp'),
date = new Date(); date = new Date();
inp.val('').datepicker('show'). inp.val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equalsDate(inp.datepicker('getDate'), date, 'Keystroke enter'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Keystroke enter');
inp.val('02/04/2008').datepicker('show'). inp.val('02/04/2008').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4), TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4),
'Keystroke enter - preset'); 'Keystroke enter - preset');
inp.val('02/04/2008').datepicker('show'). inp.val('02/04/2008').datepicker('show').
simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.HOME}). simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.HOME}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equalsDate(inp.datepicker('getDate'), date, 'Keystroke ctrl+home'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Keystroke ctrl+home');
inp.val('02/04/2008').datepicker('show'). inp.val('02/04/2008').datepicker('show').
simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.END}); simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.END});
ok(inp.datepicker('getDate') == null, 'Keystroke ctrl+end'); ok(inp.datepicker('getDate') == null, 'Keystroke ctrl+end');
@ -259,95 +220,95 @@ test('keystrokes', function() {
ok(inp.datepicker('getDate') == null, 'Keystroke esc'); ok(inp.datepicker('getDate') == null, 'Keystroke esc');
inp.val('02/04/2008').datepicker('show'). inp.val('02/04/2008').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE}); simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE});
equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4), TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4),
'Keystroke esc - preset'); 'Keystroke esc - preset');
inp.val('02/04/2008').datepicker('show'). inp.val('02/04/2008').datepicker('show').
simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}).
simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE}); simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE});
equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4), TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4),
'Keystroke esc - abandoned'); 'Keystroke esc - abandoned');
// Moving by day or week // Moving by day or week
inp.val('').datepicker('show'). inp.val('').datepicker('show').
simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.LEFT}). simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.LEFT}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
date.setDate(date.getDate() - 1); date.setDate(date.getDate() - 1);
equalsDate(inp.datepicker('getDate'), date, 'Keystroke ctrl+left'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Keystroke ctrl+left');
inp.val('').datepicker('show'). inp.val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.LEFT}). simulate('keydown', {keyCode: $.ui.keyCode.LEFT}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
date.setDate(date.getDate() + 1); date.setDate(date.getDate() + 1);
equalsDate(inp.datepicker('getDate'), date, 'Keystroke left'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Keystroke left');
inp.val('').datepicker('show'). inp.val('').datepicker('show').
simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.RIGHT}). simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.RIGHT}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
date.setDate(date.getDate() + 1); date.setDate(date.getDate() + 1);
equalsDate(inp.datepicker('getDate'), date, 'Keystroke ctrl+right'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Keystroke ctrl+right');
inp.val('').datepicker('show'). inp.val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.RIGHT}). simulate('keydown', {keyCode: $.ui.keyCode.RIGHT}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
date.setDate(date.getDate() - 1); date.setDate(date.getDate() - 1);
equalsDate(inp.datepicker('getDate'), date, 'Keystroke right'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Keystroke right');
inp.val('').datepicker('show'). inp.val('').datepicker('show').
simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.UP}). simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.UP}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
date.setDate(date.getDate() - 7); date.setDate(date.getDate() - 7);
equalsDate(inp.datepicker('getDate'), date, 'Keystroke ctrl+up'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Keystroke ctrl+up');
inp.val('').datepicker('show'). inp.val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.UP}). simulate('keydown', {keyCode: $.ui.keyCode.UP}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
date.setDate(date.getDate() + 7); date.setDate(date.getDate() + 7);
equalsDate(inp.datepicker('getDate'), date, 'Keystroke up'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Keystroke up');
inp.val('').datepicker('show'). inp.val('').datepicker('show').
simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.DOWN}). simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.DOWN}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
date.setDate(date.getDate() + 7); date.setDate(date.getDate() + 7);
equalsDate(inp.datepicker('getDate'), date, 'Keystroke ctrl+down'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Keystroke ctrl+down');
inp.val('').datepicker('show'). inp.val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.DOWN}). simulate('keydown', {keyCode: $.ui.keyCode.DOWN}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
date.setDate(date.getDate() - 7); date.setDate(date.getDate() - 7);
equalsDate(inp.datepicker('getDate'), date, 'Keystroke down'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Keystroke down');
// Moving by month or year // Moving by month or year
inp.val('02/04/2008').datepicker('show'). inp.val('02/04/2008').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.PAGE_UP}). simulate('keydown', {keyCode: $.ui.keyCode.PAGE_UP}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equalsDate(inp.datepicker('getDate'), new Date(2008, 1 - 1, 4), TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 1 - 1, 4),
'Keystroke pgup'); 'Keystroke pgup');
inp.val('02/04/2008').datepicker('show'). inp.val('02/04/2008').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.PAGE_DOWN}). simulate('keydown', {keyCode: $.ui.keyCode.PAGE_DOWN}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equalsDate(inp.datepicker('getDate'), new Date(2008, 3 - 1, 4), TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 3 - 1, 4),
'Keystroke pgdn'); 'Keystroke pgdn');
inp.val('02/04/2008').datepicker('show'). inp.val('02/04/2008').datepicker('show').
simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equalsDate(inp.datepicker('getDate'), new Date(2007, 2 - 1, 4), TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2007, 2 - 1, 4),
'Keystroke ctrl+pgup'); 'Keystroke ctrl+pgup');
inp.val('02/04/2008').datepicker('show'). inp.val('02/04/2008').datepicker('show').
simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}). simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equalsDate(inp.datepicker('getDate'), new Date(2009, 2 - 1, 4), TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2009, 2 - 1, 4),
'Keystroke ctrl+pgdn'); 'Keystroke ctrl+pgdn');
// Check for moving to short months // Check for moving to short months
inp.val('03/31/2008').datepicker('show'). inp.val('03/31/2008').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.PAGE_UP}). simulate('keydown', {keyCode: $.ui.keyCode.PAGE_UP}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 29), TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 29),
'Keystroke pgup - Feb'); 'Keystroke pgup - Feb');
inp.val('01/30/2008').datepicker('show'). inp.val('01/30/2008').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.PAGE_DOWN}). simulate('keydown', {keyCode: $.ui.keyCode.PAGE_DOWN}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 29), TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 29),
'Keystroke pgdn - Feb'); 'Keystroke pgdn - Feb');
inp.val('02/29/2008').datepicker('show'). inp.val('02/29/2008').datepicker('show').
simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equalsDate(inp.datepicker('getDate'), new Date(2007, 2 - 1, 28), TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2007, 2 - 1, 28),
'Keystroke ctrl+pgup - Feb'); 'Keystroke ctrl+pgup - Feb');
inp.val('02/29/2008').datepicker('show'). inp.val('02/29/2008').datepicker('show').
simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}). simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equalsDate(inp.datepicker('getDate'), new Date(2009, 2 - 1, 28), TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2009, 2 - 1, 28),
'Keystroke ctrl+pgdn - Feb'); 'Keystroke ctrl+pgdn - Feb');
// Goto current // Goto current
inp.datepicker('option', {gotoCurrent: true}). inp.datepicker('option', {gotoCurrent: true}).
@ -355,35 +316,35 @@ test('keystrokes', function() {
simulate('keydown', {keyCode: $.ui.keyCode.PAGE_DOWN}). simulate('keydown', {keyCode: $.ui.keyCode.PAGE_DOWN}).
simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.HOME}). simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.HOME}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4), TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4),
'Keystroke ctrl+home'); 'Keystroke ctrl+home');
// Change steps // Change steps
inp.datepicker('option', {stepMonths: 2, gotoCurrent: false}). inp.datepicker('option', {stepMonths: 2, gotoCurrent: false}).
datepicker('hide').val('02/04/2008').datepicker('show'). datepicker('hide').val('02/04/2008').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.PAGE_UP}). simulate('keydown', {keyCode: $.ui.keyCode.PAGE_UP}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equalsDate(inp.datepicker('getDate'), new Date(2007, 12 - 1, 4), TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2007, 12 - 1, 4),
'Keystroke pgup step 2'); 'Keystroke pgup step 2');
inp.val('02/04/2008').datepicker('show'). inp.val('02/04/2008').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.PAGE_DOWN}). simulate('keydown', {keyCode: $.ui.keyCode.PAGE_DOWN}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equalsDate(inp.datepicker('getDate'), new Date(2008, 4 - 1, 4), TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 4 - 1, 4),
'Keystroke pgdn step 2'); 'Keystroke pgdn step 2');
}); });
test('mouse', function() { test('mouse', function() {
expect( 15 ); expect( 15 );
var inl, var inl,
inp = init('#inp'), inp = TestHelpers.datepicker.init('#inp'),
dp = $('#ui-datepicker-div'), dp = $('#ui-datepicker-div'),
date = new Date(); date = new Date();
inp.val('').datepicker('show'); inp.val('').datepicker('show');
$('.ui-datepicker-calendar tbody a:contains(10)', dp).simulate('click', {}); $('.ui-datepicker-calendar tbody a:contains(10)', dp).simulate('click', {});
date.setDate(10); date.setDate(10);
equalsDate(inp.datepicker('getDate'), date, 'Mouse click'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Mouse click');
inp.val('02/04/2008').datepicker('show'); inp.val('02/04/2008').datepicker('show');
$('.ui-datepicker-calendar tbody a:contains(12)', dp).simulate('click', {}); $('.ui-datepicker-calendar tbody a:contains(12)', dp).simulate('click', {});
equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 12), TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 12),
'Mouse click - preset'); 'Mouse click - preset');
inp.val('02/04/2008').datepicker('show'); inp.val('02/04/2008').datepicker('show');
inp.val('').datepicker('show'); inp.val('').datepicker('show');
@ -391,66 +352,66 @@ test('mouse', function() {
ok(inp.datepicker('getDate') == null, 'Mouse click - close'); ok(inp.datepicker('getDate') == null, 'Mouse click - close');
inp.val('02/04/2008').datepicker('show'); inp.val('02/04/2008').datepicker('show');
$('button.ui-datepicker-close', dp).simulate('click', {}); $('button.ui-datepicker-close', dp).simulate('click', {});
equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4), TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4),
'Mouse click - close + preset'); 'Mouse click - close + preset');
inp.val('02/04/2008').datepicker('show'); inp.val('02/04/2008').datepicker('show');
$('a.ui-datepicker-prev', dp).simulate('click', {}); $('a.ui-datepicker-prev', dp).simulate('click', {});
$('button.ui-datepicker-close', dp).simulate('click', {}); $('button.ui-datepicker-close', dp).simulate('click', {});
equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4), TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4),
'Mouse click - abandoned'); 'Mouse click - abandoned');
// Current/previous/next // Current/previous/next
inp.val('02/04/2008').datepicker('option', {showButtonPanel: true}).datepicker('show'); inp.val('02/04/2008').datepicker('option', {showButtonPanel: true}).datepicker('show');
$('.ui-datepicker-current', dp).simulate('click', {}); $('.ui-datepicker-current', dp).simulate('click', {});
$('.ui-datepicker-calendar tbody a:contains(14)', dp).simulate('click', {}); $('.ui-datepicker-calendar tbody a:contains(14)', dp).simulate('click', {});
date.setDate(14); date.setDate(14);
equalsDate(inp.datepicker('getDate'), date, 'Mouse click - current'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Mouse click - current');
inp.val('02/04/2008').datepicker('show'); inp.val('02/04/2008').datepicker('show');
$('.ui-datepicker-prev', dp).simulate('click'); $('.ui-datepicker-prev', dp).simulate('click');
$('.ui-datepicker-calendar tbody a:contains(16)', dp).simulate('click'); $('.ui-datepicker-calendar tbody a:contains(16)', dp).simulate('click');
equalsDate(inp.datepicker('getDate'), new Date(2008, 1 - 1, 16), TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 1 - 1, 16),
'Mouse click - previous'); 'Mouse click - previous');
inp.val('02/04/2008').datepicker('show'); inp.val('02/04/2008').datepicker('show');
$('.ui-datepicker-next', dp).simulate('click'); $('.ui-datepicker-next', dp).simulate('click');
$('.ui-datepicker-calendar tbody a:contains(18)', dp).simulate('click'); $('.ui-datepicker-calendar tbody a:contains(18)', dp).simulate('click');
equalsDate(inp.datepicker('getDate'), new Date(2008, 3 - 1, 18), TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 3 - 1, 18),
'Mouse click - next'); 'Mouse click - next');
// Previous/next with minimum/maximum // Previous/next with minimum/maximum
inp.datepicker('option', {minDate: new Date(2008, 2 - 1, 2), inp.datepicker('option', {minDate: new Date(2008, 2 - 1, 2),
maxDate: new Date(2008, 2 - 1, 26)}).val('02/04/2008').datepicker('show'); maxDate: new Date(2008, 2 - 1, 26)}).val('02/04/2008').datepicker('show');
$('.ui-datepicker-prev', dp).simulate('click'); $('.ui-datepicker-prev', dp).simulate('click');
$('.ui-datepicker-calendar tbody a:contains(16)', dp).simulate('click'); $('.ui-datepicker-calendar tbody a:contains(16)', dp).simulate('click');
equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 16), TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 16),
'Mouse click - previous + min/max'); 'Mouse click - previous + min/max');
inp.val('02/04/2008').datepicker('show'); inp.val('02/04/2008').datepicker('show');
$('.ui-datepicker-next', dp).simulate('click'); $('.ui-datepicker-next', dp).simulate('click');
$('.ui-datepicker-calendar tbody a:contains(18)', dp).simulate('click'); $('.ui-datepicker-calendar tbody a:contains(18)', dp).simulate('click');
equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 18), TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 18),
'Mouse click - next + min/max'); 'Mouse click - next + min/max');
// Inline // Inline
inl = init('#inl'); inl = TestHelpers.datepicker.init('#inl');
dp = $('.ui-datepicker-inline', inl); dp = $('.ui-datepicker-inline', inl);
date = new Date(); date = new Date();
inl.datepicker('setDate', date); inl.datepicker('setDate', date);
$('.ui-datepicker-calendar tbody a:contains(10)', dp).simulate('click', {}); $('.ui-datepicker-calendar tbody a:contains(10)', dp).simulate('click', {});
date.setDate(10); date.setDate(10);
equalsDate(inl.datepicker('getDate'), date, 'Mouse click inline'); TestHelpers.datepicker.equalsDate(inl.datepicker('getDate'), date, 'Mouse click inline');
inl.datepicker('option', {showButtonPanel: true}).datepicker('setDate', new Date(2008, 2 - 1, 4)); inl.datepicker('option', {showButtonPanel: true}).datepicker('setDate', new Date(2008, 2 - 1, 4));
$('.ui-datepicker-calendar tbody a:contains(12)', dp).simulate('click', {}); $('.ui-datepicker-calendar tbody a:contains(12)', dp).simulate('click', {});
equalsDate(inl.datepicker('getDate'), new Date(2008, 2 - 1, 12), 'Mouse click inline - preset'); TestHelpers.datepicker.equalsDate(inl.datepicker('getDate'), new Date(2008, 2 - 1, 12), 'Mouse click inline - preset');
inl.datepicker('option', {showButtonPanel: true}); inl.datepicker('option', {showButtonPanel: true});
$('.ui-datepicker-current', dp).simulate('click', {}); $('.ui-datepicker-current', dp).simulate('click', {});
$('.ui-datepicker-calendar tbody a:contains(14)', dp).simulate('click', {}); $('.ui-datepicker-calendar tbody a:contains(14)', dp).simulate('click', {});
date.setDate(14); date.setDate(14);
equalsDate(inl.datepicker('getDate'), date, 'Mouse click inline - current'); TestHelpers.datepicker.equalsDate(inl.datepicker('getDate'), date, 'Mouse click inline - current');
inl.datepicker('setDate', new Date(2008, 2 - 1, 4)); inl.datepicker('setDate', new Date(2008, 2 - 1, 4));
$('.ui-datepicker-prev', dp).simulate('click'); $('.ui-datepicker-prev', dp).simulate('click');
$('.ui-datepicker-calendar tbody a:contains(16)', dp).simulate('click'); $('.ui-datepicker-calendar tbody a:contains(16)', dp).simulate('click');
equalsDate(inl.datepicker('getDate'), new Date(2008, 1 - 1, 16), TestHelpers.datepicker.equalsDate(inl.datepicker('getDate'), new Date(2008, 1 - 1, 16),
'Mouse click inline - previous'); 'Mouse click inline - previous');
inl.datepicker('setDate', new Date(2008, 2 - 1, 4)); inl.datepicker('setDate', new Date(2008, 2 - 1, 4));
$('.ui-datepicker-next', dp).simulate('click'); $('.ui-datepicker-next', dp).simulate('click');
$('.ui-datepicker-calendar tbody a:contains(18)', dp).simulate('click'); $('.ui-datepicker-calendar tbody a:contains(18)', dp).simulate('click');
equalsDate(inl.datepicker('getDate'), new Date(2008, 3 - 1, 18), TestHelpers.datepicker.equalsDate(inl.datepicker('getDate'), new Date(2008, 3 - 1, 18),
'Mouse click inline - next'); 'Mouse click inline - next');
}); });

View File

@ -2,8 +2,10 @@
* datepicker_defaults.js * datepicker_defaults.js
*/ */
/*
var datepicker_defaults = { var datepicker_defaults = {
disabled: false disabled: false
}; };
//TestHelpers.commonWidgetTests('datepicker', { defaults: datepicker_defaults }); TestHelpers.commonWidgetTests('datepicker', { defaults: datepicker_defaults });
*/

View File

@ -24,13 +24,13 @@ function callback2(year, month, inst) {
test('events', function() { test('events', function() {
expect( 26 ); expect( 26 );
var dateStr, newMonthYear, inp2, var dateStr, newMonthYear, inp2,
inp = init('#inp', {onSelect: callback}), inp = TestHelpers.datepicker.init('#inp', {onSelect: callback}),
date = new Date(); date = new Date();
// onSelect // onSelect
inp.val('').datepicker('show'). inp.val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equal(selectedThis, inp[0], 'Callback selected this'); equal(selectedThis, inp[0], 'Callback selected this');
equal(selectedInst, $.data(inp[0], PROP_NAME), 'Callback selected inst'); equal(selectedInst, $.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Callback selected inst');
equal(selectedDate, $.datepicker.formatDate('mm/dd/yy', date), equal(selectedDate, $.datepicker.formatDate('mm/dd/yy', date),
'Callback selected date'); 'Callback selected date');
inp.val('').datepicker('show'). inp.val('').datepicker('show').
@ -59,7 +59,7 @@ test('events', function() {
inp.simulate('keydown', {keyCode: $.ui.keyCode.PAGE_UP}); inp.simulate('keydown', {keyCode: $.ui.keyCode.PAGE_UP});
date.setMonth(date.getMonth() - 1); date.setMonth(date.getMonth() - 1);
equal(selectedThis, inp[0], 'Callback change month/year this'); equal(selectedThis, inp[0], 'Callback change month/year this');
equal(selectedInst, $.data(inp[0], PROP_NAME), 'Callback change month/year inst'); equal(selectedInst, $.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Callback change month/year inst');
equal(selectedDate, newMonthYear(date), equal(selectedDate, newMonthYear(date),
'Callback change month/year date - pgup'); 'Callback change month/year date - pgup');
inp.simulate('keydown', {keyCode: $.ui.keyCode.PAGE_DOWN}); inp.simulate('keydown', {keyCode: $.ui.keyCode.PAGE_DOWN});
@ -107,7 +107,7 @@ test('events', function() {
val('').datepicker('show'). val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE}); simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE});
equal(selectedThis, inp[0], 'Callback close this'); equal(selectedThis, inp[0], 'Callback close this');
equal(selectedInst, $.data(inp[0], PROP_NAME), 'Callback close inst'); equal(selectedInst, $.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Callback close inst');
equal(selectedDate, '', 'Callback close date - esc'); equal(selectedDate, '', 'Callback close date - esc');
inp.val('').datepicker('show'). inp.val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
@ -120,10 +120,29 @@ test('events', function() {
simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.END}); simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.END});
equal(selectedDate, '', 'Callback close date - ctrl+end'); equal(selectedDate, '', 'Callback close date - ctrl+end');
inp2 = init('#inp2'); inp2 = TestHelpers.datepicker.init('#inp2');
inp2.datepicker().datepicker('option', {onClose: callback}).datepicker('show'); inp2.datepicker().datepicker('option', {onClose: callback}).datepicker('show');
inp.datepicker('show'); inp.datepicker('show');
equal(selectedThis, inp2[0], 'Callback close this'); equal(selectedThis, inp2[0], 'Callback close this');
}); });
test('beforeShowDay-getDate', function() {
expect( 3 );
var inp = TestHelpers.datepicker.init('#inp', {beforeShowDay: function() { inp.datepicker('getDate'); return [true, '']; }}),
dp = $('#ui-datepicker-div');
inp.val('01/01/2010').datepicker('show');
// contains non-breaking space
equal($('div.ui-datepicker-title').text(), 'January 2010', 'Initial month');
$('a.ui-datepicker-next', dp).click();
$('a.ui-datepicker-next', dp).click();
// contains non-breaking space
equal($('div.ui-datepicker-title').text(), 'March 2010', 'After next clicks');
inp.datepicker('hide').datepicker('show');
$('a.ui-datepicker-prev', dp).click();
$('a.ui-datepicker-prev', dp).click();
// contains non-breaking space
equal($('div.ui-datepicker-title').text(), 'November 2009', 'After prev clicks');
inp.datepicker('hide');
});
})(jQuery); })(jQuery);

View File

@ -8,65 +8,65 @@ module("datepicker: methods");
test('destroy', function() { test('destroy', function() {
expect( 33 ); expect( 33 );
var inl, var inl,
inp = init('#inp'); inp = TestHelpers.datepicker.init('#inp');
ok(inp.is('.hasDatepicker'), 'Default - marker class set'); ok(inp.is('.hasDatepicker'), 'Default - marker class set');
ok($.data(inp[0], PROP_NAME), 'Default - instance present'); ok($.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Default - instance present');
ok(inp.next().is('#alt'), 'Default - button absent'); ok(inp.next().is('#alt'), 'Default - button absent');
inp.datepicker('destroy'); inp.datepicker('destroy');
inp = $('#inp'); inp = $('#inp');
ok(!inp.is('.hasDatepicker'), 'Default - marker class cleared'); ok(!inp.is('.hasDatepicker'), 'Default - marker class cleared');
ok(!$.data(inp[0], PROP_NAME), 'Default - instance absent'); ok(!$.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Default - instance absent');
ok(inp.next().is('#alt'), 'Default - button absent'); ok(inp.next().is('#alt'), 'Default - button absent');
// With button // With button
inp= init('#inp', {showOn: 'both'}); inp= TestHelpers.datepicker.init('#inp', {showOn: 'both'});
ok(inp.is('.hasDatepicker'), 'Button - marker class set'); ok(inp.is('.hasDatepicker'), 'Button - marker class set');
ok($.data(inp[0], PROP_NAME), 'Button - instance present'); ok($.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Button - instance present');
ok(inp.next().text() === '...', 'Button - button added'); ok(inp.next().text() === '...', 'Button - button added');
inp.datepicker('destroy'); inp.datepicker('destroy');
inp = $('#inp'); inp = $('#inp');
ok(!inp.is('.hasDatepicker'), 'Button - marker class cleared'); ok(!inp.is('.hasDatepicker'), 'Button - marker class cleared');
ok(!$.data(inp[0], PROP_NAME), 'Button - instance absent'); ok(!$.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Button - instance absent');
ok(inp.next().is('#alt'), 'Button - button removed'); ok(inp.next().is('#alt'), 'Button - button removed');
// With append text // With append text
inp = init('#inp', {appendText: 'Testing'}); inp = TestHelpers.datepicker.init('#inp', {appendText: 'Testing'});
ok(inp.is('.hasDatepicker'), 'Append - marker class set'); ok(inp.is('.hasDatepicker'), 'Append - marker class set');
ok($.data(inp[0], PROP_NAME), 'Append - instance present'); ok($.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Append - instance present');
ok(inp.next().text() === 'Testing', 'Append - append text added'); ok(inp.next().text() === 'Testing', 'Append - append text added');
inp.datepicker('destroy'); inp.datepicker('destroy');
inp = $('#inp'); inp = $('#inp');
ok(!inp.is('.hasDatepicker'), 'Append - marker class cleared'); ok(!inp.is('.hasDatepicker'), 'Append - marker class cleared');
ok(!$.data(inp[0], PROP_NAME), 'Append - instance absent'); ok(!$.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Append - instance absent');
ok(inp.next().is('#alt'), 'Append - append text removed'); ok(inp.next().is('#alt'), 'Append - append text removed');
// With both // With both
inp= init('#inp', {showOn: 'both', buttonImageOnly: true, inp= TestHelpers.datepicker.init('#inp', {showOn: 'both', buttonImageOnly: true,
buttonImage: 'img/calendar.gif', appendText: 'Testing'}); buttonImage: 'img/calendar.gif', appendText: 'Testing'});
ok(inp.is('.hasDatepicker'), 'Both - marker class set'); ok(inp.is('.hasDatepicker'), 'Both - marker class set');
ok($.data(inp[0], PROP_NAME), 'Both - instance present'); ok($.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Both - instance present');
ok(inp.next()[0].nodeName.toLowerCase() === 'img', 'Both - button added'); ok(inp.next()[0].nodeName.toLowerCase() === 'img', 'Both - button added');
ok(inp.next().next().text() === 'Testing', 'Both - append text added'); ok(inp.next().next().text() === 'Testing', 'Both - append text added');
inp.datepicker('destroy'); inp.datepicker('destroy');
inp = $('#inp'); inp = $('#inp');
ok(!inp.is('.hasDatepicker'), 'Both - marker class cleared'); ok(!inp.is('.hasDatepicker'), 'Both - marker class cleared');
ok(!$.data(inp[0], PROP_NAME), 'Both - instance absent'); ok(!$.data(inp[0], TestHelpers.datepicker.PROP_NAME), 'Both - instance absent');
ok(inp.next().is('#alt'), 'Both - button and append text absent'); ok(inp.next().is('#alt'), 'Both - button and append text absent');
// Inline // Inline
inl = init('#inl'); inl = TestHelpers.datepicker.init('#inl');
ok(inl.is('.hasDatepicker'), 'Inline - marker class set'); ok(inl.is('.hasDatepicker'), 'Inline - marker class set');
ok(inl.html() !== '', 'Inline - datepicker present'); ok(inl.html() !== '', 'Inline - datepicker present');
ok($.data(inl[0], PROP_NAME), 'Inline - instance present'); ok($.data(inl[0], TestHelpers.datepicker.PROP_NAME), 'Inline - instance present');
ok(inl.next().length === 0 || inl.next().is('p'), 'Inline - button absent'); ok(inl.next().length === 0 || inl.next().is('p'), 'Inline - button absent');
inl.datepicker('destroy'); inl.datepicker('destroy');
inl = $('#inl'); inl = $('#inl');
ok(!inl.is('.hasDatepicker'), 'Inline - marker class cleared'); ok(!inl.is('.hasDatepicker'), 'Inline - marker class cleared');
ok(inl.html() === '', 'Inline - datepicker absent'); ok(inl.html() === '', 'Inline - datepicker absent');
ok(!$.data(inl[0], PROP_NAME), 'Inline - instance absent'); ok(!$.data(inl[0], TestHelpers.datepicker.PROP_NAME), 'Inline - instance absent');
ok(inl.next().length === 0 || inl.next().is('p'), 'Inline - button absent'); ok(inl.next().length === 0 || inl.next().is('p'), 'Inline - button absent');
}); });
test('enableDisable', function() { test('enableDisable', function() {
expect( 33 ); expect( 33 );
var inl, dp, var inl, dp,
inp = init('#inp'); inp = TestHelpers.datepicker.init('#inp');
ok(!inp.datepicker('isDisabled'), 'Enable/disable - initially marked as enabled'); ok(!inp.datepicker('isDisabled'), 'Enable/disable - initially marked as enabled');
ok(!inp[0].disabled, 'Enable/disable - field initially enabled'); ok(!inp[0].disabled, 'Enable/disable - field initially enabled');
inp.datepicker('disable'); inp.datepicker('disable');
@ -77,7 +77,7 @@ test('enableDisable', function() {
ok(!inp[0].disabled, 'Enable/disable - field now enabled'); ok(!inp[0].disabled, 'Enable/disable - field now enabled');
inp.datepicker('destroy'); inp.datepicker('destroy');
// With a button // With a button
inp = init('#inp', {showOn: 'button'}); inp = TestHelpers.datepicker.init('#inp', {showOn: 'button'});
ok(!inp.datepicker('isDisabled'), 'Enable/disable button - initially marked as enabled'); ok(!inp.datepicker('isDisabled'), 'Enable/disable button - initially marked as enabled');
ok(!inp[0].disabled, 'Enable/disable button - field initially enabled'); ok(!inp[0].disabled, 'Enable/disable button - field initially enabled');
ok(!inp.next('button')[0].disabled, 'Enable/disable button - button initially enabled'); ok(!inp.next('button')[0].disabled, 'Enable/disable button - button initially enabled');
@ -91,7 +91,7 @@ test('enableDisable', function() {
ok(!inp.next('button')[0].disabled, 'Enable/disable button - button now enabled'); ok(!inp.next('button')[0].disabled, 'Enable/disable button - button now enabled');
inp.datepicker('destroy'); inp.datepicker('destroy');
// With an image button // With an image button
inp = init('#inp', {showOn: 'button', buttonImageOnly: true, inp = TestHelpers.datepicker.init('#inp', {showOn: 'button', buttonImageOnly: true,
buttonImage: 'img/calendar.gif'}); buttonImage: 'img/calendar.gif'});
ok(!inp.datepicker('isDisabled'), 'Enable/disable image - initially marked as enabled'); ok(!inp.datepicker('isDisabled'), 'Enable/disable image - initially marked as enabled');
ok(!inp[0].disabled, 'Enable/disable image - field initially enabled'); ok(!inp[0].disabled, 'Enable/disable image - field initially enabled');
@ -106,7 +106,7 @@ test('enableDisable', function() {
ok(parseFloat(inp.next('img').css('opacity')) === 1, 'Enable/disable image - image now enabled'); ok(parseFloat(inp.next('img').css('opacity')) === 1, 'Enable/disable image - image now enabled');
inp.datepicker('destroy'); inp.datepicker('destroy');
// Inline // Inline
inl = init('#inl', {changeYear: true}); inl = TestHelpers.datepicker.init('#inl', {changeYear: true});
dp = $('.ui-datepicker-inline', inl); dp = $('.ui-datepicker-inline', inl);
ok(!inl.datepicker('isDisabled'), 'Enable/disable inline - initially marked as enabled'); ok(!inl.datepicker('isDisabled'), 'Enable/disable inline - initially marked as enabled');
ok(!dp.children().is('.ui-state-disabled'), 'Enable/disable inline - not visually disabled initially'); ok(!dp.children().is('.ui-state-disabled'), 'Enable/disable inline - not visually disabled initially');

View File

@ -8,7 +8,7 @@ module("datepicker: options");
test('setDefaults', function() { test('setDefaults', function() {
expect( 3 ); expect( 3 );
var inp = init('#inp'); TestHelpers.datepicker.init('#inp');
equal($.datepicker._defaults.showOn, 'focus', 'Initial showOn'); equal($.datepicker._defaults.showOn, 'focus', 'Initial showOn');
$.datepicker.setDefaults({showOn: 'button'}); $.datepicker.setDefaults({showOn: 'button'});
equal($.datepicker._defaults.showOn, 'button', 'Change default showOn'); equal($.datepicker._defaults.showOn, 'button', 'Change default showOn');
@ -18,8 +18,8 @@ test('setDefaults', function() {
test('option', function() { test('option', function() {
expect( 17 ); expect( 17 );
var inp = init('#inp'), var inp = TestHelpers.datepicker.init('#inp'),
inst = $.data(inp[0], PROP_NAME); inst = $.data(inp[0], TestHelpers.datepicker.PROP_NAME);
// Set option // Set option
equal(inst.settings.showOn, null, 'Initial setting showOn'); equal(inst.settings.showOn, null, 'Initial setting showOn');
equal($.datepicker._get(inst, 'showOn'), 'focus', 'Initial instance showOn'); equal($.datepicker._get(inst, 'showOn'), 'focus', 'Initial instance showOn');
@ -37,7 +37,7 @@ test('option', function() {
equal($.datepicker._get(inst, 'showOn'), 'focus', 'Restore instance showOn'); equal($.datepicker._get(inst, 'showOn'), 'focus', 'Restore instance showOn');
equal($.datepicker._defaults.showOn, 'focus', 'Retain default showOn'); equal($.datepicker._defaults.showOn, 'focus', 'Retain default showOn');
// Get option // Get option
inp = init('#inp'); inp = TestHelpers.datepicker.init('#inp');
equal(inp.datepicker('option', 'showOn'), 'focus', 'Initial setting showOn'); equal(inp.datepicker('option', 'showOn'), 'focus', 'Initial setting showOn');
inp.datepicker('option', 'showOn', 'button'); inp.datepicker('option', 'showOn', 'button');
equal(inp.datepicker('option', 'showOn'), 'button', 'Change instance showOn'); equal(inp.datepicker('option', 'showOn'), 'button', 'Change instance showOn');
@ -50,8 +50,8 @@ test('option', function() {
test('change', function() { test('change', function() {
expect( 12 ); expect( 12 );
var inp = init('#inp'), var inp = TestHelpers.datepicker.init('#inp'),
inst = $.data(inp[0], PROP_NAME); inst = $.data(inp[0], TestHelpers.datepicker.PROP_NAME);
equal(inst.settings.showOn, null, 'Initial setting showOn'); equal(inst.settings.showOn, null, 'Initial setting showOn');
equal($.datepicker._get(inst, 'showOn'), 'focus', 'Initial instance showOn'); equal($.datepicker._get(inst, 'showOn'), 'focus', 'Initial instance showOn');
equal($.datepicker._defaults.showOn, 'focus', 'Initial default showOn'); equal($.datepicker._defaults.showOn, 'focus', 'Initial default showOn');
@ -72,7 +72,7 @@ test('change', function() {
test('invocation', function() { test('invocation', function() {
expect( 29 ); expect( 29 );
var button, image, var button, image,
inp = init('#inp'), inp = TestHelpers.datepicker.init('#inp'),
dp = $('#ui-datepicker-div'), dp = $('#ui-datepicker-div'),
body = $('body'); body = $('body');
// On focus // On focus
@ -90,7 +90,7 @@ test('invocation', function() {
ok(!dp.is(':visible'), 'Focus - hidden on external click'); ok(!dp.is(':visible'), 'Focus - hidden on external click');
inp.datepicker('hide').datepicker('destroy'); inp.datepicker('hide').datepicker('destroy');
// On button // On button
inp = init('#inp', {showOn: 'button', buttonText: 'Popup'}); inp = TestHelpers.datepicker.init('#inp', {showOn: 'button', buttonText: 'Popup'});
ok(!dp.is(':visible'), 'Button - initially hidden'); ok(!dp.is(':visible'), 'Button - initially hidden');
button = inp.siblings('button'); button = inp.siblings('button');
image = inp.siblings('img'); image = inp.siblings('img');
@ -105,7 +105,7 @@ test('invocation', function() {
ok(!dp.is(':visible'), 'Button - hidden on second button click'); ok(!dp.is(':visible'), 'Button - hidden on second button click');
inp.datepicker('hide').datepicker('destroy'); inp.datepicker('hide').datepicker('destroy');
// On image button // On image button
inp = init('#inp', {showOn: 'button', buttonImageOnly: true, inp = TestHelpers.datepicker.init('#inp', {showOn: 'button', buttonImageOnly: true,
buttonImage: 'img/calendar.gif', buttonText: 'Cal'}); buttonImage: 'img/calendar.gif', buttonText: 'Cal'});
ok(!dp.is(':visible'), 'Image button - initially hidden'); ok(!dp.is(':visible'), 'Image button - initially hidden');
button = inp.siblings('button'); button = inp.siblings('button');
@ -122,7 +122,7 @@ test('invocation', function() {
ok(!dp.is(':visible'), 'Image button - hidden on second image click'); ok(!dp.is(':visible'), 'Image button - hidden on second image click');
inp.datepicker('hide').datepicker('destroy'); inp.datepicker('hide').datepicker('destroy');
// On both // On both
inp = init('#inp', {showOn: 'both', buttonImage: 'img/calendar.gif'}); inp = TestHelpers.datepicker.init('#inp', {showOn: 'both', buttonImage: 'img/calendar.gif'});
ok(!dp.is(':visible'), 'Both - initially hidden'); ok(!dp.is(':visible'), 'Both - initially hidden');
button = inp.siblings('button'); button = inp.siblings('button');
ok(button.length === 1, 'Both - button present'); ok(button.length === 1, 'Both - button present');
@ -143,7 +143,7 @@ test('invocation', function() {
test('otherMonths', function() { test('otherMonths', function() {
expect( 8 ); expect( 8 );
var inp = init('#inp'), var inp = TestHelpers.datepicker.init('#inp'),
pop = $('#ui-datepicker-div'); pop = $('#ui-datepicker-div');
inp.val('06/01/2009').datepicker('show'); inp.val('06/01/2009').datepicker('show');
equal(pop.find('tbody').text(), '\u00a0123456789101112131415161718192021222324252627282930\u00a0\u00a0\u00a0\u00a0', equal(pop.find('tbody').text(), '\u00a0123456789101112131415161718192021222324252627282930\u00a0\u00a0\u00a0\u00a0',
@ -164,105 +164,106 @@ test('otherMonths', function() {
}); });
test('defaultDate', function() { test('defaultDate', function() {
expect( 17 ); expect( 16 );
var inp = init('#inp'), var inp = TestHelpers.datepicker.init('#inp'),
date = new Date(); date = new Date();
inp.val('').datepicker('show'). inp.val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equalsDate(inp.datepicker('getDate'), date, 'Default date null'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Default date null');
// Numeric values // Numeric values
inp.datepicker('option', {defaultDate: -2}). inp.datepicker('option', {defaultDate: -2}).
datepicker('hide').val('').datepicker('show'). datepicker('hide').val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
date.setDate(date.getDate() - 2); date.setDate(date.getDate() - 2);
equalsDate(inp.datepicker('getDate'), date, 'Default date -2'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Default date -2');
date = new Date();
inp.datepicker('option', {defaultDate: 3}). inp.datepicker('option', {defaultDate: 3}).
datepicker('hide').val('').datepicker('show'). datepicker('hide').val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
date.setDate(date.getDate() + 5); date.setDate(date.getDate() + 3);
equalsDate(inp.datepicker('getDate'), date, 'Default date 3'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Default date 3');
inp.datepicker('option', {defaultDate: 1 / 0}).
datepicker('hide').val('').datepicker('show'). date = new Date();
simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
date.setDate(date.getDate() - 3);
equalsDate(inp.datepicker('getDate'), date, 'Default date Infinity');
inp.datepicker('option', {defaultDate: 1 / 'a'}). inp.datepicker('option', {defaultDate: 1 / 'a'}).
datepicker('hide').val('').datepicker('show'). datepicker('hide').val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equalsDate(inp.datepicker('getDate'), date, 'Default date NaN'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Default date NaN');
// String offset values // String offset values
inp.datepicker('option', {defaultDate: '-1d'}). inp.datepicker('option', {defaultDate: '-1d'}).
datepicker('hide').val('').datepicker('show'). datepicker('hide').val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
date.setDate(date.getDate() - 1); date.setDate(date.getDate() - 1);
equalsDate(inp.datepicker('getDate'), date, 'Default date -1d'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Default date -1d');
inp.datepicker('option', {defaultDate: '+3D'}). inp.datepicker('option', {defaultDate: '+3D'}).
datepicker('hide').val('').datepicker('show'). datepicker('hide').val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
date.setDate(date.getDate() + 4); date.setDate(date.getDate() + 4);
equalsDate(inp.datepicker('getDate'), date, 'Default date +3D'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Default date +3D');
inp.datepicker('option', {defaultDate: ' -2 w '}). inp.datepicker('option', {defaultDate: ' -2 w '}).
datepicker('hide').val('').datepicker('show'). datepicker('hide').val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
date = new Date(); date = new Date();
date.setDate(date.getDate() - 14); date.setDate(date.getDate() - 14);
equalsDate(inp.datepicker('getDate'), date, 'Default date -2 w'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Default date -2 w');
inp.datepicker('option', {defaultDate: '+1 W'}). inp.datepicker('option', {defaultDate: '+1 W'}).
datepicker('hide').val('').datepicker('show'). datepicker('hide').val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
date.setDate(date.getDate() + 21); date.setDate(date.getDate() + 21);
equalsDate(inp.datepicker('getDate'), date, 'Default date +1 W'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Default date +1 W');
inp.datepicker('option', {defaultDate: ' -1 m '}). inp.datepicker('option', {defaultDate: ' -1 m '}).
datepicker('hide').val('').datepicker('show'). datepicker('hide').val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
date = addMonths(new Date(), -1); date = TestHelpers.datepicker.addMonths(new Date(), -1);
equalsDate(inp.datepicker('getDate'), date, 'Default date -1 m'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Default date -1 m');
inp.datepicker('option', {defaultDate: '+2M'}). inp.datepicker('option', {defaultDate: '+2M'}).
datepicker('hide').val('').datepicker('show'). datepicker('hide').val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
date = addMonths(new Date(), 2); date = TestHelpers.datepicker.addMonths(new Date(), 2);
equalsDate(inp.datepicker('getDate'), date, 'Default date +2M'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Default date +2M');
inp.datepicker('option', {defaultDate: '-2y'}). inp.datepicker('option', {defaultDate: '-2y'}).
datepicker('hide').val('').datepicker('show'). datepicker('hide').val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
date = new Date(); date = new Date();
date.setFullYear(date.getFullYear() - 2); date.setFullYear(date.getFullYear() - 2);
equalsDate(inp.datepicker('getDate'), date, 'Default date -2y'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Default date -2y');
inp.datepicker('option', {defaultDate: '+1 Y '}). inp.datepicker('option', {defaultDate: '+1 Y '}).
datepicker('hide').val('').datepicker('show'). datepicker('hide').val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
date.setFullYear(date.getFullYear() + 3); date.setFullYear(date.getFullYear() + 3);
equalsDate(inp.datepicker('getDate'), date, 'Default date +1 Y'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Default date +1 Y');
inp.datepicker('option', {defaultDate: '+1M +10d'}). inp.datepicker('option', {defaultDate: '+1M +10d'}).
datepicker('hide').val('').datepicker('show'). datepicker('hide').val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
date = addMonths(new Date(), 1); date = TestHelpers.datepicker.addMonths(new Date(), 1);
date.setDate(date.getDate() + 10); date.setDate(date.getDate() + 10);
equalsDate(inp.datepicker('getDate'), date, 'Default date +1M +10d'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Default date +1M +10d');
// String date values // String date values
inp.datepicker('option', {defaultDate: '07/04/2007'}). inp.datepicker('option', {defaultDate: '07/04/2007'}).
datepicker('hide').val('').datepicker('show'). datepicker('hide').val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
date = new Date(2007, 7 - 1, 4); date = new Date(2007, 7 - 1, 4);
equalsDate(inp.datepicker('getDate'), date, 'Default date 07/04/2007'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Default date 07/04/2007');
inp.datepicker('option', {dateFormat: 'yy-mm-dd', defaultDate: '2007-04-02'}). inp.datepicker('option', {dateFormat: 'yy-mm-dd', defaultDate: '2007-04-02'}).
datepicker('hide').val('').datepicker('show'). datepicker('hide').val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
date = new Date(2007, 4 - 1, 2); date = new Date(2007, 4 - 1, 2);
equalsDate(inp.datepicker('getDate'), date, 'Default date 2007-04-02'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Default date 2007-04-02');
// Date value // Date value
date = new Date(2007, 1 - 1, 26); date = new Date(2007, 1 - 1, 26);
inp.datepicker('option', {dateFormat: 'mm/dd/yy', defaultDate: date}). inp.datepicker('option', {dateFormat: 'mm/dd/yy', defaultDate: date}).
datepicker('hide').val('').datepicker('show'). datepicker('hide').val('').datepicker('show').
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equalsDate(inp.datepicker('getDate'), date, 'Default date 01/26/2007'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date, 'Default date 01/26/2007');
}); });
test('miscellaneous', function() { test('miscellaneous', function() {
expect( 19 ); expect( 19 );
var curYear, longNames, shortNames, date, var curYear, longNames, shortNames, date,
dp = $('#ui-datepicker-div'), dp = $('#ui-datepicker-div'),
inp = init('#inp'); inp = TestHelpers.datepicker.init('#inp');
// Year range // Year range
function genRange(start, offset) { function genRange(start, offset) {
var i = start, var i = start,
@ -323,7 +324,7 @@ test('miscellaneous', function() {
test('minMax', function() { test('minMax', function() {
expect( 17 ); expect( 17 );
var date, var date,
inp = init('#inp'), inp = TestHelpers.datepicker.init('#inp'),
lastYear = new Date(2007, 6 - 1, 4), lastYear = new Date(2007, 6 - 1, 4),
nextYear = new Date(2009, 6 - 1, 4), nextYear = new Date(2009, 6 - 1, 4),
minDate = new Date(2008, 2 - 1, 29), minDate = new Date(2008, 2 - 1, 29),
@ -331,45 +332,45 @@ test('minMax', function() {
inp.val('06/04/2008').datepicker('show'); inp.val('06/04/2008').datepicker('show');
inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equalsDate(inp.datepicker('getDate'), lastYear, TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), lastYear,
'Min/max - null, null - ctrl+pgup'); 'Min/max - null, null - ctrl+pgup');
inp.val('06/04/2008').datepicker('show'); inp.val('06/04/2008').datepicker('show');
inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}). inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equalsDate(inp.datepicker('getDate'), nextYear, TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), nextYear,
'Min/max - null, null - ctrl+pgdn'); 'Min/max - null, null - ctrl+pgdn');
inp.datepicker('option', {minDate: minDate}). inp.datepicker('option', {minDate: minDate}).
datepicker('hide').val('06/04/2008').datepicker('show'); datepicker('hide').val('06/04/2008').datepicker('show');
inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equalsDate(inp.datepicker('getDate'), minDate, TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), minDate,
'Min/max - 02/29/2008, null - ctrl+pgup'); 'Min/max - 02/29/2008, null - ctrl+pgup');
inp.val('06/04/2008').datepicker('show'); inp.val('06/04/2008').datepicker('show');
inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}). inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equalsDate(inp.datepicker('getDate'), nextYear, TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), nextYear,
'Min/max - 02/29/2008, null - ctrl+pgdn'); 'Min/max - 02/29/2008, null - ctrl+pgdn');
inp.datepicker('option', {maxDate: maxDate}). inp.datepicker('option', {maxDate: maxDate}).
datepicker('hide').val('06/04/2008').datepicker('show'); datepicker('hide').val('06/04/2008').datepicker('show');
inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equalsDate(inp.datepicker('getDate'), minDate, TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), minDate,
'Min/max - 02/29/2008, 12/07/2008 - ctrl+pgup'); 'Min/max - 02/29/2008, 12/07/2008 - ctrl+pgup');
inp.val('06/04/2008').datepicker('show'); inp.val('06/04/2008').datepicker('show');
inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}). inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equalsDate(inp.datepicker('getDate'), maxDate, TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), maxDate,
'Min/max - 02/29/2008, 12/07/2008 - ctrl+pgdn'); 'Min/max - 02/29/2008, 12/07/2008 - ctrl+pgdn');
inp.datepicker('option', {minDate: null}). inp.datepicker('option', {minDate: null}).
datepicker('hide').val('06/04/2008').datepicker('show'); datepicker('hide').val('06/04/2008').datepicker('show');
inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equalsDate(inp.datepicker('getDate'), lastYear, TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), lastYear,
'Min/max - null, 12/07/2008 - ctrl+pgup'); 'Min/max - null, 12/07/2008 - ctrl+pgup');
inp.val('06/04/2008').datepicker('show'); inp.val('06/04/2008').datepicker('show');
inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}). inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equalsDate(inp.datepicker('getDate'), maxDate, TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), maxDate,
'Min/max - null, 12/07/2008 - ctrl+pgdn'); 'Min/max - null, 12/07/2008 - ctrl+pgdn');
// Relative dates // Relative dates
date = new Date(); date = new Date();
@ -378,80 +379,80 @@ test('minMax', function() {
datepicker('hide').val('').datepicker('show'); datepicker('hide').val('').datepicker('show');
inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equalsDate(inp.datepicker('getDate'), date, TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date,
'Min/max - -1w, +1 M +10 D - ctrl+pgup'); 'Min/max - -1w, +1 M +10 D - ctrl+pgup');
date = addMonths(new Date(), 1); date = TestHelpers.datepicker.addMonths(new Date(), 1);
date.setDate(date.getDate() + 10); date.setDate(date.getDate() + 10);
inp.val('').datepicker('show'); inp.val('').datepicker('show');
inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}). inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}).
simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); simulate('keydown', {keyCode: $.ui.keyCode.ENTER});
equalsDate(inp.datepicker('getDate'), date, TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date,
'Min/max - -1w, +1 M +10 D - ctrl+pgdn'); 'Min/max - -1w, +1 M +10 D - ctrl+pgdn');
// With existing date // With existing date
inp = init('#inp'); inp = TestHelpers.datepicker.init('#inp');
inp.val('06/04/2008').datepicker('option', {minDate: minDate}); inp.val('06/04/2008').datepicker('option', {minDate: minDate});
equalsDate(inp.datepicker('getDate'), new Date(2008, 6 - 1, 4), 'Min/max - setDate > min'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 6 - 1, 4), 'Min/max - setDate > min');
inp.datepicker('option', {minDate: null}).val('01/04/2008').datepicker('option', {minDate: minDate}); inp.datepicker('option', {minDate: null}).val('01/04/2008').datepicker('option', {minDate: minDate});
equalsDate(inp.datepicker('getDate'), minDate, 'Min/max - setDate < min'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), minDate, 'Min/max - setDate < min');
inp.datepicker('option', {minDate: null}).val('06/04/2008').datepicker('option', {maxDate: maxDate}); inp.datepicker('option', {minDate: null}).val('06/04/2008').datepicker('option', {maxDate: maxDate});
equalsDate(inp.datepicker('getDate'), new Date(2008, 6 - 1, 4), 'Min/max - setDate < max'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 6 - 1, 4), 'Min/max - setDate < max');
inp.datepicker('option', {maxDate: null}).val('01/04/2009').datepicker('option', {maxDate: maxDate}); inp.datepicker('option', {maxDate: null}).val('01/04/2009').datepicker('option', {maxDate: maxDate});
equalsDate(inp.datepicker('getDate'), maxDate, 'Min/max - setDate > max'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), maxDate, 'Min/max - setDate > max');
inp.datepicker('option', {maxDate: null}).val('01/04/2008').datepicker('option', {minDate: minDate, maxDate: maxDate}); inp.datepicker('option', {maxDate: null}).val('01/04/2008').datepicker('option', {minDate: minDate, maxDate: maxDate});
equalsDate(inp.datepicker('getDate'), minDate, 'Min/max - setDate < min'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), minDate, 'Min/max - setDate < min');
inp.datepicker('option', {maxDate: null}).val('06/04/2008').datepicker('option', {minDate: minDate, maxDate: maxDate}); inp.datepicker('option', {maxDate: null}).val('06/04/2008').datepicker('option', {minDate: minDate, maxDate: maxDate});
equalsDate(inp.datepicker('getDate'), new Date(2008, 6 - 1, 4), 'Min/max - setDate > min, < max'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), new Date(2008, 6 - 1, 4), 'Min/max - setDate > min, < max');
inp.datepicker('option', {maxDate: null}).val('01/04/2009').datepicker('option', {minDate: minDate, maxDate: maxDate}); inp.datepicker('option', {maxDate: null}).val('01/04/2009').datepicker('option', {minDate: minDate, maxDate: maxDate});
equalsDate(inp.datepicker('getDate'), maxDate, 'Min/max - setDate > max'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), maxDate, 'Min/max - setDate > max');
}); });
test('setDate', function() { test('setDate', function() {
expect( 24 ); expect( 24 );
var inl, alt, minDate, maxDate, dateAndTimeToSet, dateAndTimeClone, var inl, alt, minDate, maxDate, dateAndTimeToSet, dateAndTimeClone,
inp = init('#inp'), inp = TestHelpers.datepicker.init('#inp'),
date1 = new Date(2008, 6 - 1, 4), date1 = new Date(2008, 6 - 1, 4),
date2 = new Date(); date2 = new Date();
ok(inp.datepicker('getDate') == null, 'Set date - default'); ok(inp.datepicker('getDate') == null, 'Set date - default');
inp.datepicker('setDate', date1); inp.datepicker('setDate', date1);
equalsDate(inp.datepicker('getDate'), date1, 'Set date - 2008-06-04'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date1, 'Set date - 2008-06-04');
date1 = new Date(); date1 = new Date();
date1.setDate(date1.getDate() + 7); date1.setDate(date1.getDate() + 7);
inp.datepicker('setDate', +7); inp.datepicker('setDate', +7);
equalsDate(inp.datepicker('getDate'), date1, 'Set date - +7'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date1, 'Set date - +7');
date2.setFullYear(date2.getFullYear() + 2); date2.setFullYear(date2.getFullYear() + 2);
inp.datepicker('setDate', '+2y'); inp.datepicker('setDate', '+2y');
equalsDate(inp.datepicker('getDate'), date2, 'Set date - +2y'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date2, 'Set date - +2y');
inp.datepicker('setDate', date1, date2); inp.datepicker('setDate', date1, date2);
equalsDate(inp.datepicker('getDate'), date1, 'Set date - two dates'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date1, 'Set date - two dates');
inp.datepicker('setDate'); inp.datepicker('setDate');
ok(inp.datepicker('getDate') == null, 'Set date - null'); ok(inp.datepicker('getDate') == null, 'Set date - null');
// Relative to current date // Relative to current date
date1 = new Date(); date1 = new Date();
date1.setDate(date1.getDate() + 7); date1.setDate(date1.getDate() + 7);
inp.datepicker('setDate', 'c +7'); inp.datepicker('setDate', 'c +7');
equalsDate(inp.datepicker('getDate'), date1, 'Set date - c +7'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date1, 'Set date - c +7');
date1.setDate(date1.getDate() + 7); date1.setDate(date1.getDate() + 7);
inp.datepicker('setDate', 'c+7'); inp.datepicker('setDate', 'c+7');
equalsDate(inp.datepicker('getDate'), date1, 'Set date - c+7'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date1, 'Set date - c+7');
date1.setDate(date1.getDate() - 21); date1.setDate(date1.getDate() - 21);
inp.datepicker('setDate', 'c -3 w'); inp.datepicker('setDate', 'c -3 w');
equalsDate(inp.datepicker('getDate'), date1, 'Set date - c -3 w'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date1, 'Set date - c -3 w');
// Inline // Inline
inl = init('#inl'); inl = TestHelpers.datepicker.init('#inl');
date1 = new Date(2008, 6 - 1, 4); date1 = new Date(2008, 6 - 1, 4);
date2 = new Date(); date2 = new Date();
equalsDate(inl.datepicker('getDate'), date2, 'Set date inline - default'); TestHelpers.datepicker.equalsDate(inl.datepicker('getDate'), date2, 'Set date inline - default');
inl.datepicker('setDate', date1); inl.datepicker('setDate', date1);
equalsDate(inl.datepicker('getDate'), date1, 'Set date inline - 2008-06-04'); TestHelpers.datepicker.equalsDate(inl.datepicker('getDate'), date1, 'Set date inline - 2008-06-04');
date1 = new Date(); date1 = new Date();
date1.setDate(date1.getDate() + 7); date1.setDate(date1.getDate() + 7);
inl.datepicker('setDate', +7); inl.datepicker('setDate', +7);
equalsDate(inl.datepicker('getDate'), date1, 'Set date inline - +7'); TestHelpers.datepicker.equalsDate(inl.datepicker('getDate'), date1, 'Set date inline - +7');
date2.setFullYear(date2.getFullYear() + 2); date2.setFullYear(date2.getFullYear() + 2);
inl.datepicker('setDate', '+2y'); inl.datepicker('setDate', '+2y');
equalsDate(inl.datepicker('getDate'), date2, 'Set date inline - +2y'); TestHelpers.datepicker.equalsDate(inl.datepicker('getDate'), date2, 'Set date inline - +2y');
inl.datepicker('setDate', date1, date2); inl.datepicker('setDate', date1, date2);
equalsDate(inl.datepicker('getDate'), date1, 'Set date inline - two dates'); TestHelpers.datepicker.equalsDate(inl.datepicker('getDate'), date1, 'Set date inline - two dates');
inl.datepicker('setDate'); inl.datepicker('setDate');
ok(inl.datepicker('getDate') == null, 'Set date inline - null'); ok(inl.datepicker('getDate') == null, 'Set date inline - null');
// Alternate field // Alternate field
@ -462,23 +463,23 @@ test('setDate', function() {
equal(inp.val(), '06/04/2008', 'Set date alternate - 06/04/2008'); equal(inp.val(), '06/04/2008', 'Set date alternate - 06/04/2008');
equal(alt.val(), '2008-06-04', 'Set date alternate - 2008-06-04'); equal(alt.val(), '2008-06-04', 'Set date alternate - 2008-06-04');
// With minimum/maximum // With minimum/maximum
inp = init('#inp'); inp = TestHelpers.datepicker.init('#inp');
date1 = new Date(2008, 1 - 1, 4); date1 = new Date(2008, 1 - 1, 4);
date2 = new Date(2008, 6 - 1, 4); date2 = new Date(2008, 6 - 1, 4);
minDate = new Date(2008, 2 - 1, 29); minDate = new Date(2008, 2 - 1, 29);
maxDate = new Date(2008, 3 - 1, 28); maxDate = new Date(2008, 3 - 1, 28);
inp.val('').datepicker('option', {minDate: minDate}).datepicker('setDate', date2); inp.val('').datepicker('option', {minDate: minDate}).datepicker('setDate', date2);
equalsDate(inp.datepicker('getDate'), date2, 'Set date min/max - setDate > min'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date2, 'Set date min/max - setDate > min');
inp.datepicker('setDate', date1); inp.datepicker('setDate', date1);
equalsDate(inp.datepicker('getDate'), minDate, 'Set date min/max - setDate < min'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), minDate, 'Set date min/max - setDate < min');
inp.val('').datepicker('option', {maxDate: maxDate, minDate: null}).datepicker('setDate', date1); inp.val('').datepicker('option', {maxDate: maxDate, minDate: null}).datepicker('setDate', date1);
equalsDate(inp.datepicker('getDate'), date1, 'Set date min/max - setDate < max'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), date1, 'Set date min/max - setDate < max');
inp.datepicker('setDate', date2); inp.datepicker('setDate', date2);
equalsDate(inp.datepicker('getDate'), maxDate, 'Set date min/max - setDate > max'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), maxDate, 'Set date min/max - setDate > max');
inp.val('').datepicker('option', {minDate: minDate}).datepicker('setDate', date1); inp.val('').datepicker('option', {minDate: minDate}).datepicker('setDate', date1);
equalsDate(inp.datepicker('getDate'), minDate, 'Set date min/max - setDate < min'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), minDate, 'Set date min/max - setDate < min');
inp.datepicker('setDate', date2); inp.datepicker('setDate', date2);
equalsDate(inp.datepicker('getDate'), maxDate, 'Set date min/max - setDate > max'); TestHelpers.datepicker.equalsDate(inp.datepicker('getDate'), maxDate, 'Set date min/max - setDate > max');
dateAndTimeToSet = new Date(2008, 3 - 1, 28, 1, 11, 0); dateAndTimeToSet = new Date(2008, 3 - 1, 28, 1, 11, 0);
dateAndTimeClone = new Date(2008, 3 - 1, 28, 1, 11, 0); dateAndTimeClone = new Date(2008, 3 - 1, 28, 1, 11, 0);
inp.datepicker('setDate', dateAndTimeToSet); inp.datepicker('setDate', dateAndTimeToSet);
@ -487,7 +488,7 @@ test('setDate', function() {
test('altField', function() { test('altField', function() {
expect( 10 ); expect( 10 );
var inp = init('#inp'), var inp = TestHelpers.datepicker.init('#inp'),
alt = $('#alt'); alt = $('#alt');
// No alternate field set // No alternate field set
alt.val(''); alt.val('');
@ -525,9 +526,10 @@ test('altField', function() {
}); });
test('autoSize', function() { test('autoSize', function() {
expect( 15 ); expect( 14 );
var inp = init('#inp'); var inp = TestHelpers.datepicker.init('#inp');
equal(inp.prop('size'), 20, 'Auto size - default'); // todo: figure out why this test fails in Opera 11.6
//equal(inp.prop('size'), 20, 'Auto size - default');
inp.datepicker('option', 'autoSize', true); inp.datepicker('option', 'autoSize', true);
equal(inp.prop('size'), 10, 'Auto size - mm/dd/yy'); equal(inp.prop('size'), 10, 'Auto size - mm/dd/yy');
inp.datepicker('option', 'dateFormat', 'm/d/yy'); inp.datepicker('option', 'dateFormat', 'm/d/yy');
@ -536,6 +538,7 @@ test('autoSize', function() {
equal(inp.prop('size'), 15, 'Auto size - D M d yy'); equal(inp.prop('size'), 15, 'Auto size - D M d yy');
inp.datepicker('option', 'dateFormat', 'DD, MM dd, yy'); inp.datepicker('option', 'dateFormat', 'DD, MM dd, yy');
equal(inp.prop('size'), 29, 'Auto size - DD, MM dd, yy'); equal(inp.prop('size'), 29, 'Auto size - DD, MM dd, yy');
// French // French
inp.datepicker('option', $.extend({autoSize: false}, $.datepicker.regional.fr)); inp.datepicker('option', $.extend({autoSize: false}, $.datepicker.regional.fr));
equal(inp.prop('size'), 29, 'Auto size - fr - default'); equal(inp.prop('size'), 29, 'Auto size - fr - default');
@ -547,6 +550,7 @@ test('autoSize', function() {
equal(inp.prop('size'), 18, 'Auto size - fr - D M d yy'); equal(inp.prop('size'), 18, 'Auto size - fr - D M d yy');
inp.datepicker('option', 'dateFormat', 'DD, MM dd, yy'); inp.datepicker('option', 'dateFormat', 'DD, MM dd, yy');
equal(inp.prop('size'), 28, 'Auto size - fr - DD, MM dd, yy'); equal(inp.prop('size'), 28, 'Auto size - fr - DD, MM dd, yy');
// Hebrew // Hebrew
inp.datepicker('option', $.extend({autoSize: false}, $.datepicker.regional.he)); inp.datepicker('option', $.extend({autoSize: false}, $.datepicker.regional.he));
equal(inp.prop('size'), 28, 'Auto size - he - default'); equal(inp.prop('size'), 28, 'Auto size - he - default');
@ -562,7 +566,7 @@ test('autoSize', function() {
test('daylightSaving', function() { test('daylightSaving', function() {
expect( 25 ); expect( 25 );
var inp = init('#inp'), var inp = TestHelpers.datepicker.init('#inp'),
dp = $('#ui-datepicker-div'); dp = $('#ui-datepicker-div');
ok(true, 'Daylight saving - ' + new Date()); ok(true, 'Daylight saving - ' + new Date());
// Australia, Sydney - AM change, southern hemisphere // Australia, Sydney - AM change, southern hemisphere
@ -665,21 +669,11 @@ function beforeDay(date) {
(date.getDate() % 3 === 0 ? 'Divisble by 3' : '')]; (date.getDate() % 3 === 0 ? 'Divisble by 3' : '')];
} }
function calcWeek(date) {
var doy = date.getDate() + 6,
m = date.getMonth() - 1;
for (; m >= 0; m--) {
doy += $.datepicker._getDaysInMonth(date.getFullYear(), m);
}
// Simple count from 01/01 starting at week 1
return Math.floor(doy / 7);
}
test('callbacks', function() { test('callbacks', function() {
expect( 13 ); expect( 13 );
// Before show // Before show
var dp, day20, day21, var dp, day20, day21,
inp = init('#inp', {beforeShow: beforeAll}), inp = TestHelpers.datepicker.init('#inp', {beforeShow: beforeAll}),
inst = $.data(inp[0], 'datepicker'); inst = $.data(inp[0], 'datepicker');
equal($.datepicker._get(inst, 'currentText'), 'Today', 'Before show - initial'); equal($.datepicker._get(inst, 'currentText'), 'Today', 'Before show - initial');
inp.val('02/04/2008').datepicker('show'); inp.val('02/04/2008').datepicker('show');
@ -689,7 +683,7 @@ test('callbacks', function() {
deepEqual(beforeShowInst, inst, 'Before show - inst OK'); deepEqual(beforeShowInst, inst, 'Before show - inst OK');
inp.datepicker('hide').datepicker('destroy'); inp.datepicker('hide').datepicker('destroy');
// Before show day // Before show day
inp = init('#inp', {beforeShowDay: beforeDay}); inp = TestHelpers.datepicker.init('#inp', {beforeShowDay: beforeDay});
dp = $('#ui-datepicker-div'); dp = $('#ui-datepicker-div');
inp.val('02/04/2008').datepicker('show'); inp.val('02/04/2008').datepicker('show');
ok(beforeShowDayThis.id === inp[0].id, 'Before show day - this OK'); ok(beforeShowDayThis.id === inp[0].id, 'Before show day - this OK');
@ -708,7 +702,7 @@ test('callbacks', function() {
test('localisation', function() { test('localisation', function() {
expect( 24 ); expect( 24 );
var dp, month, day, date, var dp, month, day, date,
inp = init('#inp', $.datepicker.regional.fr); inp = TestHelpers.datepicker.init('#inp', $.datepicker.regional.fr);
inp.datepicker('option', {dateFormat: 'DD, d MM yy', showButtonPanel:true, changeMonth:true, changeYear:true}).val('').datepicker('show'); inp.datepicker('option', {dateFormat: 'DD, d MM yy', showButtonPanel:true, changeMonth:true, changeYear:true}).val('').datepicker('show');
dp = $('#ui-datepicker-div'); dp = $('#ui-datepicker-div');
equal($('.ui-datepicker-close', dp).text(), 'Fermer', 'Localisation - close'); equal($('.ui-datepicker-close', dp).text(), 'Fermer', 'Localisation - close');
@ -775,72 +769,72 @@ test('iso8601Week', function() {
test('parseDate', function() { test('parseDate', function() {
expect( 26 ); expect( 26 );
init('#inp'); TestHelpers.datepicker.init('#inp');
var currentYear, gmtDate, fr, settings, zh; var currentYear, gmtDate, fr, settings, zh;
ok($.datepicker.parseDate('d m y', '') == null, 'Parse date empty'); ok($.datepicker.parseDate('d m y', '') == null, 'Parse date empty');
equalsDate($.datepicker.parseDate('d m y', '3 2 01'), TestHelpers.datepicker.equalsDate($.datepicker.parseDate('d m y', '3 2 01'),
new Date(2001, 2 - 1, 3), 'Parse date d m y'); new Date(2001, 2 - 1, 3), 'Parse date d m y');
equalsDate($.datepicker.parseDate('dd mm yy', '03 02 2001'), TestHelpers.datepicker.equalsDate($.datepicker.parseDate('dd mm yy', '03 02 2001'),
new Date(2001, 2 - 1, 3), 'Parse date dd mm yy'); new Date(2001, 2 - 1, 3), 'Parse date dd mm yy');
equalsDate($.datepicker.parseDate('d m y', '13 12 01'), TestHelpers.datepicker.equalsDate($.datepicker.parseDate('d m y', '13 12 01'),
new Date(2001, 12 - 1, 13), 'Parse date d m y'); new Date(2001, 12 - 1, 13), 'Parse date d m y');
equalsDate($.datepicker.parseDate('dd mm yy', '13 12 2001'), TestHelpers.datepicker.equalsDate($.datepicker.parseDate('dd mm yy', '13 12 2001'),
new Date(2001, 12 - 1, 13), 'Parse date dd mm yy'); new Date(2001, 12 - 1, 13), 'Parse date dd mm yy');
equalsDate($.datepicker.parseDate('y-o', '01-34'), TestHelpers.datepicker.equalsDate($.datepicker.parseDate('y-o', '01-34'),
new Date(2001, 2 - 1, 3), 'Parse date y-o'); new Date(2001, 2 - 1, 3), 'Parse date y-o');
equalsDate($.datepicker.parseDate('yy-oo', '2001-347'), TestHelpers.datepicker.equalsDate($.datepicker.parseDate('yy-oo', '2001-347'),
new Date(2001, 12 - 1, 13), 'Parse date yy-oo'); new Date(2001, 12 - 1, 13), 'Parse date yy-oo');
equalsDate($.datepicker.parseDate('oo yy', '348 2004'), TestHelpers.datepicker.equalsDate($.datepicker.parseDate('oo yy', '348 2004'),
new Date(2004, 12 - 1, 13), 'Parse date oo yy'); new Date(2004, 12 - 1, 13), 'Parse date oo yy');
equalsDate($.datepicker.parseDate('D d M y', 'Sat 3 Feb 01'), TestHelpers.datepicker.equalsDate($.datepicker.parseDate('D d M y', 'Sat 3 Feb 01'),
new Date(2001, 2 - 1, 3), 'Parse date D d M y'); new Date(2001, 2 - 1, 3), 'Parse date D d M y');
equalsDate($.datepicker.parseDate('d MM DD yy', '3 February Saturday 2001'), TestHelpers.datepicker.equalsDate($.datepicker.parseDate('d MM DD yy', '3 February Saturday 2001'),
new Date(2001, 2 - 1, 3), 'Parse date dd MM DD yy'); new Date(2001, 2 - 1, 3), 'Parse date dd MM DD yy');
equalsDate($.datepicker.parseDate('DD, MM d, yy', 'Saturday, February 3, 2001'), TestHelpers.datepicker.equalsDate($.datepicker.parseDate('DD, MM d, yy', 'Saturday, February 3, 2001'),
new Date(2001, 2 - 1, 3), 'Parse date DD, MM d, yy'); new Date(2001, 2 - 1, 3), 'Parse date DD, MM d, yy');
equalsDate($.datepicker.parseDate('\'day\' d \'of\' MM (\'\'DD\'\'), yy', TestHelpers.datepicker.equalsDate($.datepicker.parseDate('\'day\' d \'of\' MM (\'\'DD\'\'), yy',
'day 3 of February (\'Saturday\'), 2001'), new Date(2001, 2 - 1, 3), 'day 3 of February (\'Saturday\'), 2001'), new Date(2001, 2 - 1, 3),
'Parse date \'day\' d \'of\' MM (\'\'DD\'\'), yy'); 'Parse date \'day\' d \'of\' MM (\'\'DD\'\'), yy');
currentYear = new Date().getFullYear(); currentYear = new Date().getFullYear();
equalsDate($.datepicker.parseDate('y-m-d', (currentYear - 2000) + '-02-03'), TestHelpers.datepicker.equalsDate($.datepicker.parseDate('y-m-d', (currentYear - 2000) + '-02-03'),
new Date(currentYear, 2 - 1, 3), 'Parse date y-m-d - default cutuff'); new Date(currentYear, 2 - 1, 3), 'Parse date y-m-d - default cutuff');
equalsDate($.datepicker.parseDate('y-m-d', (currentYear - 2000 + 10) + '-02-03'), TestHelpers.datepicker.equalsDate($.datepicker.parseDate('y-m-d', (currentYear - 2000 + 10) + '-02-03'),
new Date(currentYear+10, 2 - 1, 3), 'Parse date y-m-d - default cutuff'); new Date(currentYear+10, 2 - 1, 3), 'Parse date y-m-d - default cutuff');
equalsDate($.datepicker.parseDate('y-m-d', (currentYear - 2000 + 11) + '-02-03'), TestHelpers.datepicker.equalsDate($.datepicker.parseDate('y-m-d', (currentYear - 2000 + 11) + '-02-03'),
new Date(currentYear-89, 2 - 1, 3), 'Parse date y-m-d - default cutuff'); new Date(currentYear-89, 2 - 1, 3), 'Parse date y-m-d - default cutuff');
equalsDate($.datepicker.parseDate('y-m-d', '80-02-03', {shortYearCutoff: 80}), TestHelpers.datepicker.equalsDate($.datepicker.parseDate('y-m-d', '80-02-03', {shortYearCutoff: 80}),
new Date(2080, 2 - 1, 3), 'Parse date y-m-d - cutoff 80'); new Date(2080, 2 - 1, 3), 'Parse date y-m-d - cutoff 80');
equalsDate($.datepicker.parseDate('y-m-d', '81-02-03', {shortYearCutoff: 80}), TestHelpers.datepicker.equalsDate($.datepicker.parseDate('y-m-d', '81-02-03', {shortYearCutoff: 80}),
new Date(1981, 2 - 1, 3), 'Parse date y-m-d - cutoff 80'); new Date(1981, 2 - 1, 3), 'Parse date y-m-d - cutoff 80');
equalsDate($.datepicker.parseDate('y-m-d', (currentYear - 2000 + 60) + '-02-03', {shortYearCutoff: '+60'}), TestHelpers.datepicker.equalsDate($.datepicker.parseDate('y-m-d', (currentYear - 2000 + 60) + '-02-03', {shortYearCutoff: '+60'}),
new Date(currentYear + 60, 2 - 1, 3), 'Parse date y-m-d - cutoff +60'); new Date(currentYear + 60, 2 - 1, 3), 'Parse date y-m-d - cutoff +60');
equalsDate($.datepicker.parseDate('y-m-d', (currentYear - 2000 + 61) + '-02-03', {shortYearCutoff: '+60'}), TestHelpers.datepicker.equalsDate($.datepicker.parseDate('y-m-d', (currentYear - 2000 + 61) + '-02-03', {shortYearCutoff: '+60'}),
new Date(currentYear - 39, 2 - 1, 3), 'Parse date y-m-d - cutoff +60'); new Date(currentYear - 39, 2 - 1, 3), 'Parse date y-m-d - cutoff +60');
gmtDate = new Date(2001, 2 - 1, 3); gmtDate = new Date(2001, 2 - 1, 3);
gmtDate.setMinutes(gmtDate.getMinutes() - gmtDate.getTimezoneOffset()); gmtDate.setMinutes(gmtDate.getMinutes() - gmtDate.getTimezoneOffset());
equalsDate($.datepicker.parseDate('@', '981158400000'), gmtDate, 'Parse date @'); TestHelpers.datepicker.equalsDate($.datepicker.parseDate('@', '981158400000'), gmtDate, 'Parse date @');
equalsDate($.datepicker.parseDate('!', '631167552000000000'), gmtDate, 'Parse date !'); TestHelpers.datepicker.equalsDate($.datepicker.parseDate('!', '631167552000000000'), gmtDate, 'Parse date !');
fr = $.datepicker.regional.fr; fr = $.datepicker.regional.fr;
settings = {dayNamesShort: fr.dayNamesShort, dayNames: fr.dayNames, settings = {dayNamesShort: fr.dayNamesShort, dayNames: fr.dayNames,
monthNamesShort: fr.monthNamesShort, monthNames: fr.monthNames}; monthNamesShort: fr.monthNamesShort, monthNames: fr.monthNames};
equalsDate($.datepicker.parseDate('D d M y', 'Lun. 9 Avril 01', settings), TestHelpers.datepicker.equalsDate($.datepicker.parseDate('D d M y', 'Lun. 9 Avril 01', settings),
new Date(2001, 4 - 1, 9), 'Parse date D M y with settings'); new Date(2001, 4 - 1, 9), 'Parse date D M y with settings');
equalsDate($.datepicker.parseDate('d MM DD yy', '9 Avril Lundi 2001', settings), TestHelpers.datepicker.equalsDate($.datepicker.parseDate('d MM DD yy', '9 Avril Lundi 2001', settings),
new Date(2001, 4 - 1, 9), 'Parse date d MM DD yy with settings'); new Date(2001, 4 - 1, 9), 'Parse date d MM DD yy with settings');
equalsDate($.datepicker.parseDate('DD, MM d, yy', 'Lundi, Avril 9, 2001', settings), TestHelpers.datepicker.equalsDate($.datepicker.parseDate('DD, MM d, yy', 'Lundi, Avril 9, 2001', settings),
new Date(2001, 4 - 1, 9), 'Parse date DD, MM d, yy with settings'); new Date(2001, 4 - 1, 9), 'Parse date DD, MM d, yy with settings');
equalsDate($.datepicker.parseDate('\'jour\' d \'de\' MM (\'\'DD\'\'), yy', TestHelpers.datepicker.equalsDate($.datepicker.parseDate("'jour' d 'de' MM (''DD''), yy", "jour 9 de Avril ('Lundi'), 2001", settings),
'jour 9 de Avril (\'Lundi\'), 2001', settings), new Date(2001, 4 - 1, 9), new Date(2001, 4 - 1, 9), "Parse date 'jour' d 'de' MM (''DD''), yy with settings");
'Parse date \'jour\' d \'de\' MM (\'\'DD\'\'), yy with settings');
zh = $.datepicker.regional['zh-CN']; zh = $.datepicker.regional['zh-CN'];
equalsDate($.datepicker.parseDate('yy M d', '2011 十一 22', zh), TestHelpers.datepicker.equalsDate($.datepicker.parseDate('yy M d', '2011 十一 22', zh),
new Date(2011, 11 - 1, 22), 'Parse date yy M d with zh-CN'); new Date(2011, 11 - 1, 22), 'Parse date yy M d with zh-CN');
}); });
test('parseDateErrors', function() { test('parseDateErrors', function() {
expect( 17 ); expect( 17 );
init('#inp'); TestHelpers.datepicker.init('#inp');
var fr, settings; var fr, settings;
function expectError(expr, value, error) { function expectError(expr, value, error) {
try { try {
@ -891,9 +885,29 @@ test('parseDateErrors', function() {
'Lun. 9 Apr 01 - D d M y', 'Unknown name at position 7'); 'Lun. 9 Apr 01 - D d M y', 'Unknown name at position 7');
}); });
test('Ticket #7244: date parser does not fail when too many numbers are passed into the date function', function() {
expect( 4 );
var date;
try{
date = $.datepicker.parseDate('dd/mm/yy', '18/04/19881');
ok(false, "Did not properly detect an invalid date");
}catch(e){
ok("invalid date detected");
}
try {
date = $.datepicker.parseDate('dd/mm/yy', '18/04/1988 @ 2:43 pm');
equal(date.getDate(), 18);
equal(date.getMonth(), 3);
equal(date.getFullYear(), 1988);
} catch(e) {
ok(false, "Did not properly parse date with extra text separated by whitespace");
}
});
test('formatDate', function() { test('formatDate', function() {
expect( 16 ); expect( 16 );
init('#inp'); TestHelpers.datepicker.init('#inp');
var gmtDate, fr, settings; var gmtDate, fr, settings;
equal($.datepicker.formatDate('d m y', new Date(2001, 2 - 1, 3)), equal($.datepicker.formatDate('d m y', new Date(2001, 2 - 1, 3)),
'3 2 01', 'Format date d m y'); '3 2 01', 'Format date d m y');
@ -934,4 +948,44 @@ test('formatDate', function() {
'Format date \'jour\' d \'de\' MM (\'\'DD\'\'), yy with settings'); 'Format date \'jour\' d \'de\' MM (\'\'DD\'\'), yy with settings');
}); });
test('Ticket 6827: formatDate day of year calculation is wrong during day lights savings time', function(){
expect( 1 );
var time = $.datepicker.formatDate("oo", new Date("2010/03/30 12:00:00 CDT"));
equal(time, "089");
});
test('Ticket 7602: Stop datepicker from appearing with beforeShow event handler', function(){
expect( 3 );
var inp = TestHelpers.datepicker.init('#inp',{
beforeShow: function(){
return false;
}
}),
dp = $('#ui-datepicker-div');
inp.datepicker('show');
equal(dp.css('display'), 'none',"beforeShow returns false");
inp.datepicker('destroy');
inp = TestHelpers.datepicker.init('#inp',{
beforeShow: function(){
}
});
dp = $('#ui-datepicker-div');
inp.datepicker('show');
equal(dp.css('display'), 'block',"beforeShow returns nothing");
inp.datepicker('hide');
inp.datepicker('destroy');
inp = TestHelpers.datepicker.init('#inp',{
beforeShow: function(){
return true;
}
});
dp = $('#ui-datepicker-div');
inp.datepicker('show');
equal(dp.css('display'), 'block',"beforeShow returns true");
inp.datepicker('hide');
inp.datepicker('destroy');
});
})(jQuery); })(jQuery);

View File

@ -0,0 +1,22 @@
TestHelpers.datepicker = {
addMonths: function(date, offset) {
var maxDay = 32 - new Date(date.getFullYear(), date.getMonth() + offset, 32).getDate();
date.setDate(Math.min(date.getDate(), maxDay));
date.setMonth(date.getMonth() + offset);
return date;
},
equalsDate: function(d1, d2, message) {
if (!d1 || !d2) {
ok(false, message + ' - missing date');
return;
}
d1 = new Date(d1.getFullYear(), d1.getMonth(), d1.getDate());
d2 = new Date(d2.getFullYear(), d2.getMonth(), d2.getDate());
equal(d1.toString(), d2.toString(), message);
},
init: function(id, options) {
$.datepicker.setDefaults($.datepicker.regional['']);
return $(id).datepicker($.extend({showAnim: ''}, options || {}));
},
PROP_NAME: 'datepicker'
};

View File

@ -1,88 +0,0 @@
/*
* datepicker_tickets.js
*/
(function($) {
module("datepicker: tickets");
// http://forum.jquery.com/topic/several-breaking-changes-in-jquery-ui-1-8rc1
test('beforeShowDay-getDate', function() {
expect( 3 );
var inp = init('#inp', {beforeShowDay: function(date) { inp.datepicker('getDate'); return [true, '']; }}),
dp = $('#ui-datepicker-div');
inp.val('01/01/2010').datepicker('show');
// contains non-breaking space
equal($('div.ui-datepicker-title').text(), 'January 2010', 'Initial month');
$('a.ui-datepicker-next', dp).click();
$('a.ui-datepicker-next', dp).click();
// contains non-breaking space
equal($('div.ui-datepicker-title').text(), 'March 2010', 'After next clicks');
inp.datepicker('hide').datepicker('show');
$('a.ui-datepicker-prev', dp).click();
$('a.ui-datepicker-prev', dp).click();
// contains non-breaking space
equal($('div.ui-datepicker-title').text(), 'November 2009', 'After prev clicks');
inp.datepicker('hide');
});
test('Ticket 7602: Stop datepicker from appearing with beforeShow event handler', function(){
expect( 3 );
var inp = init('#inp',{
beforeShow: function(){
return false;
}
}),
dp = $('#ui-datepicker-div');
inp.datepicker('show');
equal(dp.css('display'), 'none',"beforeShow returns false");
inp.datepicker('destroy');
inp = init('#inp',{
beforeShow: function(){
}
});
dp = $('#ui-datepicker-div');
inp.datepicker('show');
equal(dp.css('display'), 'block',"beforeShow returns nothing");
inp.datepicker('hide');
inp.datepicker('destroy');
inp = init('#inp',{
beforeShow: function(){
return true;
}
});
dp = $('#ui-datepicker-div');
inp.datepicker('show');
equal(dp.css('display'), 'block',"beforeShow returns true");
inp.datepicker('hide');
inp.datepicker('destroy');
});
test('Ticket 6827: formatDate day of year calculation is wrong during day lights savings time', function(){
expect( 1 );
var time = $.datepicker.formatDate("oo", new Date("2010/03/30 12:00:00 CDT"));
equal(time, "089");
});
test('Ticket #7244: date parser does not fail when too many numbers are passed into the date function', function() {
expect( 4 );
var date;
try{
date = $.datepicker.parseDate('dd/mm/yy', '18/04/19881');
ok(false, "Did not properly detect an invalid date");
}catch(e){
ok("invalid date detected");
}
try {
date = $.datepicker.parseDate('dd/mm/yy', '18/04/1988 @ 2:43 pm');
equal(date.getDate(), 18);
equal(date.getMonth(), 3);
equal(date.getFullYear(), 1988);
} catch(e) {
ok(false, "Did not properly parse date with extra text separated by whitespace");
}
});
})(jQuery);

View File

@ -5,7 +5,6 @@
<title>jQuery UI Dialog Test Suite</title> <title>jQuery UI Dialog Test Suite</title>
<script src="../../jquery.js"></script> <script src="../../jquery.js"></script>
<script src="../../../external/jquery.bgiframe-2.1.2.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css"> <link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script> <script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script> <script src="../../jquery.simulate.js"></script>
@ -30,18 +29,9 @@
<script src="dialog_events.js"></script> <script src="dialog_events.js"></script>
<script src="dialog_methods.js"></script> <script src="dialog_methods.js"></script>
<script src="dialog_options.js"></script> <script src="dialog_options.js"></script>
<script src="dialog_test_helpers.js"></script>
<script src="dialog_tickets.js"></script> <script src="dialog_tickets.js"></script>
<script>
// disable this testsuite for testswarm only - until we fix it from freezing IE6
var url = window.location.search;
url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + 9 ) );
if ( url && url.indexOf("http") == 0 ) {
// reset config to kill previous tests; make sure testsuite.js is loaded afterwards to init the testswarm script
QUnit.init();
test("dialog", function() { ok(true, "disabled dialog testsuite"); });
}
</script>
<script src="../swarminject.js"></script> <script src="../swarminject.js"></script>
</head> </head>
<body> <body>
@ -52,7 +42,8 @@
<h2 id="qunit-userAgent"></h2> <h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol> <ol id="qunit-tests"></ol>
<div id="qunit-fixture"> <div id="qunit-fixture">
<div id="dialog1"></div>
<div id="dialog2"></div>
</div> </div>
</body> </body>
</html> </html>

View File

@ -23,10 +23,8 @@ TestHelpers.commonWidgetTests( "dialog", {
}, },
resizable: true, resizable: true,
show: null, show: null,
stack: true,
title: '', title: '',
width: 300, width: 300,
zIndex: 1000,
// callbacks // callbacks
create: null create: null

View File

@ -2,88 +2,6 @@
* dialog_core.js * dialog_core.js
*/ */
var el,
offsetBefore, offsetAfter,
heightBefore, heightAfter,
widthBefore, widthAfter,
dragged;
function dlg() {
return el.dialog('widget');
}
function isOpen(why) {
ok(dlg().is(":visible"), why);
}
function isNotOpen(why) {
ok(!dlg().is(":visible"), why);
}
function drag(handle, dx, dy) {
var d = dlg();
offsetBefore = d.offset();
heightBefore = d.height();
widthBefore = d.width();
//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");
$(handle, d).simulate("drag", {
dx: dx || 0,
dy: dy || 0
});
dragged = { dx: dx, dy: dy };
offsetAfter = d.offset();
heightAfter = d.height();
widthAfter = d.width();
}
function moved(dx, dy, msg) {
msg = msg ? msg + "." : "";
var actual = { left: Math.round(offsetAfter.left), top: Math.round(offsetAfter.top) },
expected = { left: Math.round(offsetBefore.left + dx), top: Math.round(offsetBefore.top + dy) };
deepEqual(actual, expected, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ' + msg);
}
function shouldmove(why) {
var handle = $(".ui-dialog-titlebar", dlg());
drag(handle, 50, -50);
moved(50, -50, why);
}
function shouldnotmove(why) {
var handle = $(".ui-dialog-titlebar", dlg());
drag(handle, 50, -50);
moved(0, 0, why);
}
function resized(dw, dh, msg) {
msg = msg ? msg + "." : "";
var actual = { width: widthAfter, height: heightAfter },
expected = { width: widthBefore + dw, height: heightBefore + dh };
deepEqual(actual, expected, 'resized[' + dragged.dx + ', ' + dragged.dy + '] ' + msg);
}
function shouldresize(why) {
var handle = $(".ui-resizable-se", dlg());
drag(handle, 50, 50);
resized(50, 50, why);
}
function shouldnotresize(why) {
var handle = $(".ui-resizable-se", dlg());
drag(handle, 50, 50);
resized(0, 0, why);
}
function broder(el, side){
return parseInt(el.css('border-' + side + '-width'), 10);
}
function margin(el, side) {
return parseInt(el.css('margin-' + side), 10);
}
(function($) { (function($) {
module("dialog: core"); module("dialog: core");
@ -91,8 +9,10 @@ module("dialog: core");
test("title id", function() { test("title id", function() {
expect(1); expect(1);
el = $('<div></div>').dialog(); var titleId,
var titleId = dlg().find('.ui-dialog-title').attr('id'); el = $('<div></div>').dialog();
titleId = el.dialog('widget').find('.ui-dialog-title').attr('id');
ok( /ui-id-\d+$/.test( titleId ), 'auto-numbered title id'); ok( /ui-id-\d+$/.test( titleId ), 'auto-numbered title id');
el.remove(); el.remove();
}); });
@ -100,16 +20,17 @@ test("title id", function() {
test("ARIA", function() { test("ARIA", function() {
expect(4); expect(4);
el = $('<div></div>').dialog(); var labelledBy,
el = $('<div></div>').dialog();
equal(dlg().attr('role'), 'dialog', 'dialog role'); equal(el.dialog('widget').attr('role'), 'dialog', 'dialog role');
var labelledBy = dlg().attr('aria-labelledby'); labelledBy = el.dialog('widget').attr('aria-labelledby');
ok(labelledBy.length > 0, 'has aria-labelledby attribute'); ok(labelledBy.length > 0, 'has aria-labelledby attribute');
equal(dlg().find('.ui-dialog-title').attr('id'), labelledBy, equal(el.dialog('widget').find('.ui-dialog-title').attr('id'), labelledBy,
'proper aria-labelledby attribute'); 'proper aria-labelledby attribute');
equal(dlg().find('.ui-dialog-titlebar-close').attr('role'), 'button', equal(el.dialog('widget').find('.ui-dialog-titlebar-close').attr('role'), 'button',
'close link role'); 'close link role');
el.remove(); el.remove();

View File

@ -8,10 +8,10 @@ module("dialog: events");
test("open", function() { test("open", function() {
expect(13); expect(13);
el = $("<div></div>"); var el = $("<div></div>");
el.dialog({ el.dialog({
open: function(ev, ui) { open: function(ev, ui) {
ok(el.data("dialog")._isOpen, "interal _isOpen flag is set"); ok(el.data("ui-dialog")._isOpen, "interal _isOpen flag is set");
ok(true, 'autoOpen: true fires open callback'); ok(true, 'autoOpen: true fires open callback');
equal(this, el[0], "context of callback"); equal(this, el[0], "context of callback");
equal(ev.type, 'dialogopen', 'event type in callback'); equal(ev.type, 'dialogopen', 'event type in callback');
@ -30,7 +30,7 @@ test("open", function() {
deepEqual(ui, {}, 'ui hash in callback'); deepEqual(ui, {}, 'ui hash in callback');
} }
}).bind('dialogopen', function(ev, ui) { }).bind('dialogopen', function(ev, ui) {
ok(el.data("dialog")._isOpen, "interal _isOpen flag is set"); ok(el.data("ui-dialog")._isOpen, "interal _isOpen flag is set");
ok(true, 'dialog("open") fires open event'); ok(true, 'dialog("open") fires open event');
equal(this, el[0], 'context of event'); equal(this, el[0], 'context of event');
deepEqual(ui, {}, 'ui hash in event'); deepEqual(ui, {}, 'ui hash in event');
@ -42,163 +42,171 @@ test("open", function() {
test("dragStart", function() { test("dragStart", function() {
expect(9); expect(9);
el = $('<div></div>').dialog({ var handle,
dragStart: function(ev, ui) { el = $('<div></div>').dialog({
ok(true, 'dragging fires dragStart callback'); dragStart: function(ev, ui) {
equal(this, el[0], "context of callback"); ok(true, 'dragging fires dragStart callback');
equal(ev.type, 'dialogdragstart', 'event type in callback'); equal(this, el[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");
}
}).bind('dialogdragstart', function(ev, ui) {
ok(true, 'dragging fires dialogdragstart event');
equal(this, el[0], 'context of event');
ok(ui.position !== undefined, "ui.position in callback"); ok(ui.position !== undefined, "ui.position in callback");
ok(ui.offset !== undefined, "ui.offset in callback"); ok(ui.offset !== undefined, "ui.offset in callback");
} });
}).bind('dialogdragstart', function(ev, ui) {
ok(true, 'dragging fires dialogdragstart event'); handle = $(".ui-dialog-titlebar", el.dialog('widget'));
equal(this, el[0], 'context of event'); TestHelpers.dialog.drag(el, handle, 50, 50);
ok(ui.position !== undefined, "ui.position in callback");
ok(ui.offset !== undefined, "ui.offset in callback");
});
var handle = $(".ui-dialog-titlebar", dlg());
drag(handle, 50, 50);
el.remove(); el.remove();
}); });
test("drag", function() { test("drag", function() {
expect(9); expect(9);
var handle, var handle,
hasDragged = false; hasDragged = false,
el = $('<div></div>').dialog({
drag: function(ev, ui) {
if (!hasDragged) {
ok(true, 'dragging fires drag callback');
equal(this, el[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");
el = $('<div></div>').dialog({ hasDragged = true;
drag: function(ev, ui) { }
if (!hasDragged) {
ok(true, 'dragging fires drag callback');
equal(this, el[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");
hasDragged = true;
} }
} }).one('dialogdrag', function(ev, ui) {
}).one('dialogdrag', function(ev, ui) { ok(true, 'dragging fires dialogdrag event');
ok(true, 'dragging fires dialogdrag event'); equal(this, el[0], 'context of event');
equal(this, el[0], 'context of event'); ok(ui.position !== undefined, "ui.position in callback");
ok(ui.position !== undefined, "ui.position in callback"); ok(ui.offset !== undefined, "ui.offset in callback");
ok(ui.offset !== undefined, "ui.offset in callback"); });
});
handle = $(".ui-dialog-titlebar", dlg()); handle = $(".ui-dialog-titlebar", el.dialog('widget'));
drag(handle, 50, 50); TestHelpers.dialog.drag(el, handle, 50, 50);
el.remove(); el.remove();
}); });
test("dragStop", function() { test("dragStop", function() {
expect(9); expect(9);
el = $('<div></div>').dialog({ var handle,
dragStop: function(ev, ui) { el = $('<div></div>').dialog({
ok(true, 'dragging fires dragStop callback'); dragStop: function(ev, ui) {
equal(this, el[0], "context of callback"); ok(true, 'dragging fires dragStop callback');
equal(ev.type, 'dialogdragstop', 'event type in callback'); equal(this, el[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");
}
}).bind('dialogdragstop', function(ev, ui) {
ok(true, 'dragging fires dialogdragstop event');
equal(this, el[0], 'context of event');
ok(ui.position !== undefined, "ui.position in callback"); ok(ui.position !== undefined, "ui.position in callback");
ok(ui.offset !== undefined, "ui.offset in callback"); ok(ui.offset !== undefined, "ui.offset in callback");
} });
}).bind('dialogdragstop', function(ev, ui) {
ok(true, 'dragging fires dialogdragstop event'); handle = $(".ui-dialog-titlebar", el.dialog('widget'));
equal(this, el[0], 'context of event'); TestHelpers.dialog.drag(el, handle, 50, 50);
ok(ui.position !== undefined, "ui.position in callback");
ok(ui.offset !== undefined, "ui.offset in callback");
});
var handle = $(".ui-dialog-titlebar", dlg());
drag(handle, 50, 50);
el.remove(); el.remove();
}); });
test("resizeStart", function() { test("resizeStart", function() {
expect(13); expect(13);
el = $('<div></div>').dialog({ var handle,
resizeStart: function(ev, ui) { el = $('<div></div>').dialog({
ok(true, 'resizing fires resizeStart callback'); resizeStart: function(ev, ui) {
equal(this, el[0], "context of callback"); ok(true, 'resizing fires resizeStart callback');
equal(ev.type, 'dialogresizestart', 'event type in callback'); equal(this, el[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");
}
}).bind('dialogresizestart', function(ev, ui) {
ok(true, 'resizing fires dialogresizestart event');
equal(this, el[0], 'context of event');
ok(ui.originalPosition !== undefined, "ui.originalPosition in callback"); ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
ok(ui.originalSize !== undefined, "ui.originalSize in callback"); ok(ui.originalSize !== undefined, "ui.originalSize in callback");
ok(ui.position !== undefined, "ui.position in callback"); ok(ui.position !== undefined, "ui.position in callback");
ok(ui.size !== undefined, "ui.size in callback"); ok(ui.size !== undefined, "ui.size in callback");
} });
}).bind('dialogresizestart', function(ev, ui) {
ok(true, 'resizing fires dialogresizestart event'); handle = $(".ui-resizable-se", el.dialog('widget'));
equal(this, el[0], 'context of event'); TestHelpers.dialog.drag(el, handle, 50, 50);
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");
});
var handle = $(".ui-resizable-se", dlg());
drag(handle, 50, 50);
el.remove(); el.remove();
}); });
test("resize", function() { test("resize", function() {
expect(13); expect(13);
var handle, var handle,
hasResized = false; hasResized = false,
el = $('<div></div>').dialog({
resize: function(ev, ui) {
if (!hasResized) {
ok(true, 'resizing fires resize callback');
equal(this, el[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");
el = $('<div></div>').dialog({ hasResized = true;
resize: function(ev, ui) { }
if (!hasResized) {
ok(true, 'resizing fires resize callback');
equal(this, el[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");
hasResized = true;
} }
} }).one('dialogresize', function(ev, ui) {
}).one('dialogresize', function(ev, ui) { ok(true, 'resizing fires dialogresize event');
ok(true, 'resizing fires dialogresize event'); equal(this, el[0], 'context of event');
equal(this, el[0], 'context of event'); ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
ok(ui.originalPosition !== undefined, "ui.originalPosition in callback"); ok(ui.originalSize !== undefined, "ui.originalSize in callback");
ok(ui.originalSize !== undefined, "ui.originalSize in callback"); ok(ui.position !== undefined, "ui.position in callback");
ok(ui.position !== undefined, "ui.position in callback"); ok(ui.size !== undefined, "ui.size in callback");
ok(ui.size !== undefined, "ui.size in callback"); });
});
handle = $(".ui-resizable-se", dlg()); handle = $(".ui-resizable-se", el.dialog('widget'));
drag(handle, 50, 50); TestHelpers.dialog.drag(el, handle, 50, 50);
el.remove(); el.remove();
}); });
test("resizeStop", function() { test("resizeStop", function() {
expect(13); expect(13);
el = $('<div></div>').dialog({ var handle,
resizeStop: function(ev, ui) { el = $('<div></div>').dialog({
ok(true, 'resizing fires resizeStop callback'); resizeStop: function(ev, ui) {
equal(this, el[0], "context of callback"); ok(true, 'resizing fires resizeStop callback');
equal(ev.type, 'dialogresizestop', 'event type in callback'); equal(this, el[0], "context of callback");
ok(ui.originalPosition !== undefined, "ui.originalPosition in callback"); equal(ev.type, 'dialogresizestop', 'event type in callback');
ok(ui.originalSize !== undefined, "ui.originalSize in callback"); ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
ok(ui.position !== undefined, "ui.position in callback"); ok(ui.originalSize !== undefined, "ui.originalSize in callback");
ok(ui.size !== undefined, "ui.size in callback"); ok(ui.position !== undefined, "ui.position in callback");
} ok(ui.size !== undefined, "ui.size in callback");
}).bind('dialogresizestop', function(ev, ui) { }
ok(true, 'resizing fires dialogresizestop event'); }).bind('dialogresizestop', function(ev, ui) {
equal(this, el[0], 'context of event'); ok(true, 'resizing fires dialogresizestop event');
ok(ui.originalPosition !== undefined, "ui.originalPosition in callback"); equal(this, el[0], 'context of event');
ok(ui.originalSize !== undefined, "ui.originalSize in callback"); ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
ok(ui.position !== undefined, "ui.position in callback"); ok(ui.originalSize !== undefined, "ui.originalSize in callback");
ok(ui.size !== undefined, "ui.size in callback"); ok(ui.position !== undefined, "ui.position in callback");
}); ok(ui.size !== undefined, "ui.size in callback");
var handle = $(".ui-resizable-se", dlg()); });
drag(handle, 50, 50);
handle = $(".ui-resizable-se", el.dialog('widget'));
TestHelpers.dialog.drag(el, handle, 50, 50);
el.remove(); el.remove();
}); });
test("close", function() { asyncTest("close", function() {
expect(7); expect(14);
el = $('<div></div>').dialog({ var el = $('<div></div>').dialog({
close: function(ev, ui) { close: function(ev, ui) {
ok(true, '.dialog("close") fires close callback'); ok(true, '.dialog("close") fires close callback');
equal(this, el[0], "context of callback"); equal(this, el[0], "context of callback");
@ -212,12 +220,29 @@ test("close", function() {
}); });
el.dialog('close'); el.dialog('close');
el.remove(); el.remove();
// Close event with an effect
el = $('<div></div>').dialog({
hide: 10,
close: function(ev, ui) {
ok(true, '.dialog("close") fires close callback');
equal(this, el[0], "context of callback");
equal(ev.type, 'dialogclose', 'event type in callback');
deepEqual(ui, {}, 'ui hash in callback');
start();
}
}).bind('dialogclose', function(ev, ui) {
ok(true, '.dialog("close") fires dialogclose event');
equal(this, el[0], 'context of event');
deepEqual(ui, {}, 'ui hash in event');
});
el.dialog('close');
}); });
test("beforeClose", function() { test("beforeClose", function() {
expect(14); expect(14);
el = $('<div></div>').dialog({ var el = $('<div></div>').dialog({
beforeClose: function(ev, ui) { beforeClose: function(ev, ui) {
ok(true, '.dialog("close") fires beforeClose callback'); ok(true, '.dialog("close") fires beforeClose callback');
equal(this, el[0], "context of callback"); equal(this, el[0], "context of callback");
@ -226,8 +251,9 @@ test("beforeClose", function() {
return false; return false;
} }
}); });
el.dialog('close'); el.dialog('close');
isOpen('beforeClose callback should prevent dialog from closing'); ok( el.dialog("widget").is(":visible"), 'beforeClose callback should prevent dialog from closing');
el.remove(); el.remove();
el = $('<div></div>').dialog(); el = $('<div></div>').dialog();
@ -239,7 +265,8 @@ test("beforeClose", function() {
return false; return false;
}); });
el.dialog('close'); el.dialog('close');
isOpen('beforeClose callback should prevent dialog from closing');
ok( el.dialog("widget").is(":visible"), 'beforeClose callback should prevent dialog from closing');
el.remove(); el.remove();
el = $('<div></div>').dialog().bind('dialogbeforeclose', function(ev, ui) { el = $('<div></div>').dialog().bind('dialogbeforeclose', function(ev, ui) {
@ -249,7 +276,7 @@ test("beforeClose", function() {
return false; return false;
}); });
el.dialog('close'); el.dialog('close');
isOpen('dialogbeforeclose event should prevent dialog from closing'); ok( el.dialog("widget").is(":visible"), 'dialogbeforeclose event should prevent dialog from closing');
el.remove(); el.remove();
}); });

View File

@ -24,8 +24,8 @@ test("init", function() {
$('<div></div>').appendTo('body').remove().dialog().remove(); $('<div></div>').appendTo('body').remove().dialog().remove();
ok(true, '.dialog() called on disconnected DOMElement - removed'); ok(true, '.dialog() called on disconnected DOMElement - removed');
el = $('<div></div>').dialog(); var el = $('<div></div>').dialog();
var foo = el.dialog("option", "foo"); el.dialog("option", "foo");
el.remove(); el.remove();
ok(true, 'arbitrary option getter after init'); ok(true, 'arbitrary option getter after init');
@ -53,46 +53,49 @@ test("destroy", function() {
test("enable", function() { test("enable", function() {
expect( 3 ); expect( 3 );
var expected = $('<div></div>').dialog(), var el,
expected = $('<div></div>').dialog(),
actual = expected.dialog('enable'); actual = expected.dialog('enable');
equal(actual, expected, 'enable is chainable'); equal(actual, expected, 'enable is chainable');
el = $('<div></div>').dialog({ disabled: true }); el = $('<div></div>').dialog({ disabled: true });
el.dialog('enable'); el.dialog('enable');
equal(el.dialog('option', 'disabled'), false, 'enable method sets disabled option to false'); equal(el.dialog('option', 'disabled'), false, 'enable method sets disabled option to false');
ok(!dlg().hasClass('ui-dialog-disabled'), 'enable method removes ui-dialog-disabled class from ui-dialog element'); ok(!el.dialog('widget').hasClass('ui-dialog-disabled'), 'enable method removes ui-dialog-disabled class from ui-dialog element');
}); });
test("disable", function() { test("disable", function() {
expect( 3 ); expect( 3 );
var expected = $('<div></div>').dialog(), var el,
expected = $('<div></div>').dialog(),
actual = expected.dialog('disable'); actual = expected.dialog('disable');
equal(actual, expected, 'disable is chainable'); equal(actual, expected, 'disable is chainable');
el = $('<div></div>').dialog({ disabled: false }); el = $('<div></div>').dialog({ disabled: false });
el.dialog('disable'); el.dialog('disable');
equal(el.dialog('option', 'disabled'), true, 'disable method sets disabled option to true'); equal(el.dialog('option', 'disabled'), true, 'disable method sets disabled option to true');
ok(dlg().hasClass('ui-dialog-disabled'), 'disable method adds ui-dialog-disabled class to ui-dialog element'); ok(el.dialog('widget').hasClass('ui-dialog-disabled'), 'disable method adds ui-dialog-disabled class to ui-dialog element');
}); });
test("close", function() { test("close", function() {
expect( 3 ); expect( 3 );
var expected = $('<div></div>').dialog(), var el,
expected = $('<div></div>').dialog(),
actual = expected.dialog('close'); actual = expected.dialog('close');
equal(actual, expected, 'close is chainable'); equal(actual, expected, 'close is chainable');
el = $('<div></div>').dialog(); el = $('<div></div>').dialog();
ok(dlg().is(':visible') && !dlg().is(':hidden'), 'dialog visible before close method called'); ok(el.dialog('widget').is(':visible') && !el.dialog('widget').is(':hidden'), 'dialog visible before close method called');
el.dialog('close'); el.dialog('close');
ok(dlg().is(':hidden') && !dlg().is(':visible'), 'dialog hidden after close method called'); ok(el.dialog('widget').is(':hidden') && !el.dialog('widget').is(':visible'), 'dialog hidden after close method called');
}); });
test("isOpen", function() { test("isOpen", function() {
expect(4); expect(4);
el = $('<div></div>').dialog(); var el = $('<div></div>').dialog();
equal(el.dialog('isOpen'), true, "dialog is open after init"); equal(el.dialog('isOpen'), true, "dialog is open after init");
el.dialog('close'); el.dialog('close');
equal(el.dialog('isOpen'), false, "dialog is closed"); equal(el.dialog('isOpen'), false, "dialog is closed");
@ -106,36 +109,43 @@ test("isOpen", function() {
}); });
test("moveToTop", function() { test("moveToTop", function() {
expect( 3 ); expect( 5 );
function order() {
var d1, d2, dlg1, dlg2, var actual = $( ".ui-dialog" ).map(function() {
expected = $('<div></div>').dialog(), return +$( this ).find( ".ui-dialog-content" ).attr( "id" ).replace( /\D+/, "" );
actual = expected.dialog('moveToTop'); }).get().reverse();
equal(actual, expected, 'moveToTop is chainable'); deepEqual( actual, $.makeArray( arguments ) );
}
d1 = $('<div></div>').dialog(); var dialog1, dialog2,
dlg1 = d1.parents('.ui-dialog'); focusOn = "dialog1";
d1.dialog('close'); dialog1 = $( "#dialog1" ).dialog({
d1.dialog('open'); focus: function() {
d2 = $('<div></div>').dialog(); equal( focusOn, "dialog1" );
dlg2 = d2.parents('.ui-dialog'); }
d2.dialog('close'); });
d2.dialog('open'); focusOn = "dialog2";
ok(dlg1.css('zIndex') < dlg2.css('zIndex'), 'dialog 1 under dialog 2 before moveToTop method called'); dialog2 = $( "#dialog2" ).dialog({
d1.dialog('moveToTop'); focus: function() {
ok(dlg1.css('zIndex') > dlg2.css('zIndex'), 'dialog 1 above dialog 2 after moveToTop method called'); equal( focusOn, "dialog2" );
}
});
order( 2, 1 );
focusOn = "dialog1";
dialog1.dialog( "moveToTop" );
order( 1, 2 );
}); });
test("open", function() { test("open", function() {
expect( 3 ); expect( 3 );
var expected = $('<div></div>').dialog(), var el,
expected = $('<div></div>').dialog(),
actual = expected.dialog('open'); actual = expected.dialog('open');
equal(actual, expected, 'open is chainable'); equal(actual, expected, 'open is chainable');
el = $('<div></div>').dialog({ autoOpen: false }); el = $('<div></div>').dialog({ autoOpen: false });
ok(dlg().is(':hidden') && !dlg().is(':visible'), 'dialog hidden before open method called'); ok(el.dialog('widget').is(':hidden') && !el.dialog('widget').is(':visible'), 'dialog hidden before open method called');
el.dialog('open'); el.dialog('open');
ok(dlg().is(':visible') && !dlg().is(':hidden'), 'dialog visible after open method called'); ok(el.dialog('widget').is(':visible') && !el.dialog('widget').is(':hidden'), 'dialog visible after open method called');
}); });
})(jQuery); })(jQuery);

View File

@ -8,12 +8,12 @@ module("dialog: options");
test("autoOpen", function() { test("autoOpen", function() {
expect(2); expect(2);
el = $('<div></div>').dialog({ autoOpen: false }); var el = $('<div></div>').dialog({ autoOpen: false });
isNotOpen('.dialog({ autoOpen: false })'); ok( !el.dialog("widget").is(":visible"), '.dialog({ autoOpen: false })');
el.remove(); el.remove();
el = $('<div></div>').dialog({ autoOpen: true }); el = $('<div></div>').dialog({ autoOpen: true });
isOpen('.dialog({ autoOpen: true })'); ok( el.dialog("widget").is(":visible"), '.dialog({ autoOpen: true })');
el.remove(); el.remove();
}); });
@ -22,24 +22,24 @@ test("buttons", function() {
var btn, i, newButtons, var btn, i, newButtons,
buttons = { buttons = {
"Ok": function(ev, ui) { "Ok": function( ev ) {
ok(true, "button click fires callback"); ok(true, "button click fires callback");
equal(this, el[0], "context of callback"); equal(this, el[0], "context of callback");
equal(ev.target, btn[0], "event target"); equal(ev.target, btn[0], "event target");
},
"Cancel": function( ev ) {
ok(true, "button click fires callback");
equal(this, el[0], "context of callback");
equal(ev.target, btn[1], "event target");
}
}, },
"Cancel": function(ev, ui) { el = $('<div></div>').dialog({ buttons: buttons });
ok(true, "button click fires callback");
equal(this, el[0], "context of callback");
equal(ev.target, btn[1], "event target");
}
};
el = $('<div></div>').dialog({ buttons: buttons }); btn = $("button", el.dialog('widget'));
btn = $("button", dlg());
equal(btn.length, 2, "number of buttons"); equal(btn.length, 2, "number of buttons");
i = 0; i = 0;
$.each(buttons, function(key, val) { $.each(buttons, function( key ) {
equal(btn.eq(i).text(), key, "text of button " + (i+1)); equal(btn.eq(i).text(), key, "text of button " + (i+1));
i++; i++;
}); });
@ -50,7 +50,7 @@ test("buttons", function() {
btn.trigger("click"); btn.trigger("click");
newButtons = { newButtons = {
"Close": function(ev, ui) { "Close": function( ev ) {
ok(true, "button click fires callback"); ok(true, "button click fires callback");
equal(this, el[0], "context of callback"); equal(this, el[0], "context of callback");
equal(ev.target, btn[0], "event target"); equal(ev.target, btn[0], "event target");
@ -61,18 +61,18 @@ test("buttons", function() {
el.dialog("option", "buttons", newButtons); el.dialog("option", "buttons", newButtons);
deepEqual(el.dialog("option", "buttons"), newButtons, '.dialog("option", "buttons", ...) setter'); deepEqual(el.dialog("option", "buttons"), newButtons, '.dialog("option", "buttons", ...) setter');
btn = $("button", dlg()); btn = $("button", el.dialog('widget'));
equal(btn.length, 1, "number of buttons after setter"); equal(btn.length, 1, "number of buttons after setter");
btn.trigger('click'); btn.trigger('click');
i = 0; i = 0;
$.each(newButtons, function(key, val) { $.each(newButtons, function( key ) {
equal(btn.eq(i).text(), key, "text of button " + (i+1)); equal(btn.eq(i).text(), key, "text of button " + (i+1));
i += 1; i += 1;
}); });
el.dialog("option", "buttons", null); el.dialog("option", "buttons", null);
btn = $("button", dlg()); btn = $("button", el.dialog('widget'));
equal(btn.length, 0, "all buttons have been removed"); equal(btn.length, 0, "all buttons have been removed");
equal(el.find(".ui-dialog-buttonset").length, 0, "buttonset has been removed"); equal(el.find(".ui-dialog-buttonset").length, 0, "buttonset has been removed");
equal(el.parent().hasClass('ui-dialog-buttons'), false, "dialog wrapper removes class about having buttons"); equal(el.parent().hasClass('ui-dialog-buttons'), false, "dialog wrapper removes class about having buttons");
@ -83,19 +83,21 @@ test("buttons", function() {
test("buttons - advanced", function() { test("buttons - advanced", function() {
expect(5); expect(5);
el = $("<div></div>").dialog({ var buttons,
buttons: [ el = $("<div></div>").dialog({
{ buttons: [
text: "a button", {
"class": "additional-class", text: "a button",
id: "my-button-id", "class": "additional-class",
click: function() { id: "my-button-id",
equal(this, el[0], "correct context"); click: function() {
equal(this, el[0], "correct context");
}
} }
} ]
] });
});
var buttons = dlg().find("button"); buttons = el.dialog('widget').find("button");
equal(buttons.length, 1, "correct number of buttons"); equal(buttons.length, 1, "correct number of buttons");
equal(buttons.attr("id"), "my-button-id", "correct id"); equal(buttons.attr("id"), "my-button-id", "correct id");
equal(buttons.text(), "a button", "correct label"); equal(buttons.text(), "a button", "correct label");
@ -107,40 +109,40 @@ test("buttons - advanced", function() {
test("closeOnEscape", function() { test("closeOnEscape", function() {
expect( 6 ); expect( 6 );
el = $('<div></div>').dialog({ closeOnEscape: false }); var el = $('<div></div>').dialog({ closeOnEscape: false });
ok(true, 'closeOnEscape: false'); ok(true, 'closeOnEscape: false');
ok(dlg().is(':visible') && !dlg().is(':hidden'), 'dialog is open before ESC'); ok(el.dialog('widget').is(':visible') && !el.dialog('widget').is(':hidden'), 'dialog is open before ESC');
el.simulate('keydown', { keyCode: $.ui.keyCode.ESCAPE }) el.simulate('keydown', { keyCode: $.ui.keyCode.ESCAPE })
.simulate('keypress', { keyCode: $.ui.keyCode.ESCAPE }) .simulate('keypress', { keyCode: $.ui.keyCode.ESCAPE })
.simulate('keyup', { keyCode: $.ui.keyCode.ESCAPE }); .simulate('keyup', { keyCode: $.ui.keyCode.ESCAPE });
ok(dlg().is(':visible') && !dlg().is(':hidden'), 'dialog is open after ESC'); ok(el.dialog('widget').is(':visible') && !el.dialog('widget').is(':hidden'), 'dialog is open after ESC');
el.remove(); el.remove();
el = $('<div></div>').dialog({ closeOnEscape: true }); el = $('<div></div>').dialog({ closeOnEscape: true });
ok(true, 'closeOnEscape: true'); ok(true, 'closeOnEscape: true');
ok(dlg().is(':visible') && !dlg().is(':hidden'), 'dialog is open before ESC'); ok(el.dialog('widget').is(':visible') && !el.dialog('widget').is(':hidden'), 'dialog is open before ESC');
el.simulate('keydown', { keyCode: $.ui.keyCode.ESCAPE }) el.simulate('keydown', { keyCode: $.ui.keyCode.ESCAPE })
.simulate('keypress', { keyCode: $.ui.keyCode.ESCAPE }) .simulate('keypress', { keyCode: $.ui.keyCode.ESCAPE })
.simulate('keyup', { keyCode: $.ui.keyCode.ESCAPE }); .simulate('keyup', { keyCode: $.ui.keyCode.ESCAPE });
ok(dlg().is(':hidden') && !dlg().is(':visible'), 'dialog is closed after ESC'); ok(el.dialog('widget').is(':hidden') && !el.dialog('widget').is(':visible'), 'dialog is closed after ESC');
}); });
test("closeText", function() { test("closeText", function() {
expect(3); expect(3);
el = $('<div></div>').dialog(); var el = $('<div></div>').dialog();
equal(dlg().find('.ui-dialog-titlebar-close span').text(), 'close', equal(el.dialog('widget').find('.ui-dialog-titlebar-close span').text(), 'close',
'default close text'); 'default close text');
el.remove(); el.remove();
el = $('<div></div>').dialog({ closeText: "foo" }); el = $('<div></div>').dialog({ closeText: "foo" });
equal(dlg().find('.ui-dialog-titlebar-close span').text(), 'foo', equal(el.dialog('widget').find('.ui-dialog-titlebar-close span').text(), 'foo',
'closeText on init'); 'closeText on init');
el.remove(); el.remove();
el = $('<div></div>').dialog().dialog('option', 'closeText', 'bar'); el = $('<div></div>').dialog().dialog('option', 'closeText', 'bar');
equal(dlg().find('.ui-dialog-titlebar-close span').text(), 'bar', equal(el.dialog('widget').find('.ui-dialog-titlebar-close span').text(), 'bar',
'closeText via option method'); 'closeText via option method');
el.remove(); el.remove();
}); });
@ -148,131 +150,132 @@ test("closeText", function() {
test("dialogClass", function() { test("dialogClass", function() {
expect(4); expect(4);
el = $('<div></div>').dialog(); var el = $('<div></div>').dialog();
equal(dlg().is(".foo"), false, 'dialogClass not specified. foo class added'); equal(el.dialog('widget').is(".foo"), false, 'dialogClass not specified. foo class added');
el.remove(); el.remove();
el = $('<div></div>').dialog({ dialogClass: "foo" }); el = $('<div></div>').dialog({ dialogClass: "foo" });
equal(dlg().is(".foo"), true, 'dialogClass in init. foo class added'); equal(el.dialog('widget').is(".foo"), true, 'dialogClass in init. foo class added');
el.remove(); el.remove();
el = $('<div></div>').dialog({ dialogClass: "foo bar" }); el = $('<div></div>').dialog({ dialogClass: "foo bar" });
equal(dlg().is(".foo"), true, 'dialogClass in init, two classes. foo class added'); equal(el.dialog('widget').is(".foo"), true, 'dialogClass in init, two classes. foo class added');
equal(dlg().is(".bar"), true, 'dialogClass in init, two classes. bar class added'); equal(el.dialog('widget').is(".bar"), true, 'dialogClass in init, two classes. bar class added');
el.remove(); el.remove();
}); });
test("draggable", function() { test("draggable", function() {
expect(4); expect(4);
el = $('<div></div>').dialog({ draggable: false }); var el = $('<div></div>').dialog({ draggable: false });
shouldnotmove();
TestHelpers.dialog.testDrag(el, 50, -50, 0, 0);
el.dialog('option', 'draggable', true); el.dialog('option', 'draggable', true);
shouldmove(); TestHelpers.dialog.testDrag(el, 50, -50, 50, -50);
el.remove(); el.remove();
el = $('<div></div>').dialog({ draggable: true }); el = $('<div></div>').dialog({ draggable: true });
shouldmove(); TestHelpers.dialog.testDrag(el, 50, -50, 50, -50);
el.dialog('option', 'draggable', false); el.dialog('option', 'draggable', false);
shouldnotmove(); TestHelpers.dialog.testDrag(el, 50, -50, 0, 0);
el.remove(); el.remove();
}); });
test("height", function() { test("height", function() {
expect(4); expect(4);
el = $('<div></div>').dialog(); var el = $('<div></div>').dialog();
equal(dlg().outerHeight(), 150, "default height"); equal(el.dialog('widget').outerHeight(), 150, "default height");
el.remove(); el.remove();
el = $('<div></div>').dialog({ height: 237 }); el = $('<div></div>').dialog({ height: 237 });
equal(dlg().outerHeight(), 237, "explicit height"); equal(el.dialog('widget').outerHeight(), 237, "explicit height");
el.remove(); el.remove();
el = $('<div></div>').dialog(); el = $('<div></div>').dialog();
el.dialog('option', 'height', 238); el.dialog('option', 'height', 238);
equal(dlg().outerHeight(), 238, "explicit height set after init"); equal(el.dialog('widget').outerHeight(), 238, "explicit height set after init");
el.remove(); el.remove();
el = $('<div></div>').css("padding", "20px") el = $('<div></div>').css("padding", "20px")
.dialog({ height: 240 }); .dialog({ height: 240 });
equal(dlg().outerHeight(), 240, "explicit height with padding"); equal(el.dialog('widget').outerHeight(), 240, "explicit height with padding");
el.remove(); el.remove();
}); });
test("maxHeight", function() { test("maxHeight", function() {
expect(3); expect(3);
el = $('<div></div>').dialog({ maxHeight: 200 }); var el = $('<div></div>').dialog({ maxHeight: 200 });
drag('.ui-resizable-s', 1000, 1000); TestHelpers.dialog.drag(el, '.ui-resizable-s', 1000, 1000);
equal(heightAfter, 200, "maxHeight"); closeEnough(el.dialog('widget').height(), 200, 1, "maxHeight");
el.remove(); el.remove();
el = $('<div></div>').dialog({ maxHeight: 200 }); el = $('<div></div>').dialog({ maxHeight: 200 });
drag('.ui-resizable-n', -1000, -1000); TestHelpers.dialog.drag(el, '.ui-resizable-n', -1000, -1000);
equal(heightAfter, 200, "maxHeight"); closeEnough(el.dialog('widget').height(), 200, 1, "maxHeight");
el.remove(); el.remove();
el = $('<div></div>').dialog({ maxHeight: 200 }).dialog('option', 'maxHeight', 300); el = $('<div></div>').dialog({ maxHeight: 200 }).dialog('option', 'maxHeight', 300);
drag('.ui-resizable-s', 1000, 1000); TestHelpers.dialog.drag(el, '.ui-resizable-s', 1000, 1000);
equal(heightAfter, 300, "maxHeight"); closeEnough(el.dialog('widget').height(), 300, 1, "maxHeight");
el.remove(); el.remove();
}); });
test("maxWidth", function() { test("maxWidth", function() {
expect(3); expect(3);
el = $('<div></div>').dialog({ maxWidth: 200 }); var el = $('<div></div>').dialog({ maxWidth: 200 });
drag('.ui-resizable-e', 1000, 1000); TestHelpers.dialog.drag(el, '.ui-resizable-e', 1000, 1000);
equal(widthAfter, 200, "maxWidth"); closeEnough(el.dialog('widget').width(), 200, 1, "maxWidth");
el.remove(); el.remove();
el = $('<div></div>').dialog({ maxWidth: 200 }); el = $('<div></div>').dialog({ maxWidth: 200 });
drag('.ui-resizable-w', -1000, -1000); TestHelpers.dialog.drag(el, '.ui-resizable-w', -1000, -1000);
equal(widthAfter, 200, "maxWidth"); closeEnough(el.dialog('widget').width(), 200, 1, "maxWidth");
el.remove(); el.remove();
el = $('<div></div>').dialog({ maxWidth: 200 }).dialog('option', 'maxWidth', 300); el = $('<div></div>').dialog({ maxWidth: 200 }).dialog('option', 'maxWidth', 300);
drag('.ui-resizable-w', -1000, -1000); TestHelpers.dialog.drag(el, '.ui-resizable-w', -1000, -1000);
equal(widthAfter, 300, "maxWidth"); closeEnough(el.dialog('widget').width(), 300, 1, "maxWidth");
el.remove(); el.remove();
}); });
test("minHeight", function() { test("minHeight", function() {
expect(3); expect(3);
el = $('<div></div>').dialog({ minHeight: 10 }); var el = $('<div></div>').dialog({ minHeight: 10 });
drag('.ui-resizable-s', -1000, -1000); TestHelpers.dialog.drag(el, '.ui-resizable-s', -1000, -1000);
equal(heightAfter, 10, "minHeight"); closeEnough(el.dialog('widget').height(), 10, 1, "minHeight");
el.remove(); el.remove();
el = $('<div></div>').dialog({ minHeight: 10 }); el = $('<div></div>').dialog({ minHeight: 10 });
drag('.ui-resizable-n', 1000, 1000); TestHelpers.dialog.drag(el, '.ui-resizable-n', 1000, 1000);
equal(heightAfter, 10, "minHeight"); closeEnough(el.dialog('widget').height(), 10, 1, "minHeight");
el.remove(); el.remove();
el = $('<div></div>').dialog({ minHeight: 10 }).dialog('option', 'minHeight', 30); el = $('<div></div>').dialog({ minHeight: 10 }).dialog('option', 'minHeight', 30);
drag('.ui-resizable-n', 1000, 1000); TestHelpers.dialog.drag(el, '.ui-resizable-n', 1000, 1000);
equal(heightAfter, 30, "minHeight"); closeEnough(el.dialog('widget').height(), 30, 1, "minHeight");
el.remove(); el.remove();
}); });
test("minWidth", function() { test("minWidth", function() {
expect(3); expect(3);
el = $('<div></div>').dialog({ minWidth: 10 }); var el = $('<div></div>').dialog({ minWidth: 10 });
drag('.ui-resizable-e', -1000, -1000); TestHelpers.dialog.drag(el, '.ui-resizable-e', -1000, -1000);
equal(widthAfter, 10, "minWidth"); closeEnough(el.dialog('widget').width(), 10, 1, "minWidth");
el.remove(); el.remove();
el = $('<div></div>').dialog({ minWidth: 10 }); el = $('<div></div>').dialog({ minWidth: 10 });
drag('.ui-resizable-w', 1000, 1000); TestHelpers.dialog.drag(el, '.ui-resizable-w', 1000, 1000);
equal(widthAfter, 10, "minWidth"); closeEnough(el.dialog('widget').width(), 10, 1, "minWidth");
el.remove(); el.remove();
el = $('<div></div>').dialog({ minWidth: 30 }).dialog('option', 'minWidth', 30); el = $('<div></div>').dialog({ minWidth: 30 }).dialog('option', 'minWidth', 30);
drag('.ui-resizable-w', 1000, 1000); TestHelpers.dialog.drag(el, '.ui-resizable-w', 1000, 1000);
equal(widthAfter, 30, "minWidth"); closeEnough(el.dialog('widget').width(), 30, 1, "minWidth");
el.remove(); el.remove();
}); });
@ -281,8 +284,8 @@ test("position, default center on window", function() {
var el = $('<div></div>').dialog(), var el = $('<div></div>').dialog(),
dialog = el.dialog('widget'), dialog = el.dialog('widget'),
offset = dialog.offset(); offset = dialog.offset();
deepEqual(offset.left, Math.round($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft()); closeEnough(offset.left, Math.round($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft(), 1);
deepEqual(offset.top, Math.round($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop()); closeEnough(offset.top, Math.round($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop(), 1);
el.remove(); el.remove();
}); });
@ -291,8 +294,8 @@ test("position, top on window", function() {
var el = $('<div></div>').dialog({ position: "top" }), var el = $('<div></div>').dialog({ position: "top" }),
dialog = el.dialog('widget'), dialog = el.dialog('widget'),
offset = dialog.offset(); offset = dialog.offset();
deepEqual(offset.left, Math.round($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft()); closeEnough(offset.left, Math.round($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft(), 1);
deepEqual(offset.top, $(window).scrollTop()); closeEnough(offset.top, $(window).scrollTop(), 1);
el.remove(); el.remove();
}); });
@ -301,54 +304,59 @@ test("position, left on window", function() {
var el = $('<div></div>').dialog({ position: "left" }), var el = $('<div></div>').dialog({ position: "left" }),
dialog = el.dialog('widget'), dialog = el.dialog('widget'),
offset = dialog.offset(); offset = dialog.offset();
deepEqual(offset.left, 0); closeEnough(offset.left, 0, 1);
deepEqual(offset.top, Math.round($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop()); closeEnough(offset.top, Math.round($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop(), 1);
el.remove(); el.remove();
}); });
test("position, right bottom on window", function() { // todo: figure out these fails in IE7
expect( 2 ); if ( !$.ui.ie ) {
var el = $('<div></div>').dialog({ position: "right bottom" }),
dialog = el.dialog('widget'),
offset = dialog.offset();
deepEqual(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft());
deepEqual(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop());
el.remove();
});
test("position, right bottom on window w/array", function() { test("position, right bottom on window", function() {
expect( 2 ); expect( 2 );
var el = $('<div></div>').dialog({ position: ["right", "bottom"] }), var el = $('<div></div>').dialog({ position: "right bottom" }),
dialog = el.dialog('widget'), dialog = el.dialog('widget'),
offset = dialog.offset(); offset = dialog.offset();
deepEqual(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft()); closeEnough(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft(), 1);
deepEqual(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop()); closeEnough(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop(), 1);
el.remove(); el.remove();
}); });
test("position, right bottom on window w/array", function() {
expect( 2 );
var el = $('<div></div>').dialog({ position: ["right", "bottom"] }),
dialog = el.dialog('widget'),
offset = dialog.offset();
closeEnough(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft(), 1);
closeEnough(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop(), 1);
el.remove();
});
test("position, right bottom at right bottom via ui.position args", function() {
expect( 2 );
var el = $('<div></div>').dialog({
position: {
my: "right bottom",
at: "right bottom"
}
}),
dialog = el.dialog('widget'),
offset = dialog.offset();
closeEnough(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft(), 1);
closeEnough(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop(), 1);
el.remove();
});
}
test("position, offset from top left w/array", function() { test("position, offset from top left w/array", function() {
expect( 2 ); expect( 2 );
var el = $('<div></div>').dialog({ position: [10, 10] }), var el = $('<div></div>').dialog({ position: [10, 10] }),
dialog = el.dialog('widget'), dialog = el.dialog('widget'),
offset = dialog.offset(); offset = dialog.offset();
deepEqual(offset.left, 10 + $(window).scrollLeft()); closeEnough(offset.left, 10 + $(window).scrollLeft(), 1);
deepEqual(offset.top, 10 + $(window).scrollTop()); closeEnough(offset.top, 10 + $(window).scrollTop(), 1);
el.remove();
});
test("position, right bottom at right bottom via ui.position args", function() {
expect( 2 );
var el = $('<div></div>').dialog({
position: {
my: "right bottom",
at: "right bottom"
}
}),
dialog = el.dialog('widget'),
offset = dialog.offset();
deepEqual(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft());
deepEqual(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop());
el.remove(); el.remove();
}); });
@ -394,16 +402,16 @@ test("position, at another element", function() {
test("resizable", function() { test("resizable", function() {
expect(4); expect(4);
el = $('<div></div>').dialog(); var el = $('<div></div>').dialog();
shouldresize("[default]"); TestHelpers.dialog.shouldResize(el, 50, 50, "[default]");
el.dialog('option', 'resizable', false); el.dialog('option', 'resizable', false);
shouldnotresize('disabled after init'); TestHelpers.dialog.shouldResize(el, 0, 0, 'disabled after init');
el.remove(); el.remove();
el = $('<div></div>').dialog({ resizable: false }); el = $('<div></div>').dialog({ resizable: false });
shouldnotresize("disabled in init options"); TestHelpers.dialog.shouldResize(el, 0, 0, "disabled in init options");
el.dialog('option', 'resizable', true); el.dialog('option', 'resizable', true);
shouldresize('enabled after init'); TestHelpers.dialog.shouldResize(el, 50, 50, 'enabled after init');
el.remove(); el.remove();
}); });
@ -411,13 +419,13 @@ test("title", function() {
expect(9); expect(9);
function titleText() { function titleText() {
return dlg().find(".ui-dialog-title").html(); return el.dialog('widget').find(".ui-dialog-title").html();
} }
el = $('<div></div>').dialog(); var el = $('<div></div>').dialog();
// some browsers return a non-breaking space and some return "&nbsp;" // some browsers return a non-breaking space and some return "&nbsp;"
// so we get the text to normalize to the actual non-breaking space // so we get the text to normalize to the actual non-breaking space
equal(dlg().find(".ui-dialog-title").text(), " ", "[default]"); equal(el.dialog('widget').find(".ui-dialog-title").text(), " ", "[default]");
equal(el.dialog("option", "title"), "", "option not changed"); equal(el.dialog("option", "title"), "", "option not changed");
el.remove(); el.remove();
@ -444,14 +452,14 @@ test("title", function() {
test("width", function() { test("width", function() {
expect(3); expect(3);
el = $('<div></div>').dialog(); var el = $('<div></div>').dialog();
equal(dlg().width(), 300, "default width"); closeEnough(el.dialog('widget').width(), 300, 1, "default width");
el.remove(); el.remove();
el = $('<div></div>').dialog({width: 437 }); el = $('<div></div>').dialog({width: 437 });
equal(dlg().width(), 437, "explicit width"); closeEnough(el.dialog('widget').width(), 437, 1, "explicit width");
el.dialog('option', 'width', 438); el.dialog('option', 'width', 438);
equal(dlg().width(), 438, 'explicit width after init'); closeEnough(el.dialog('widget').width(), 438, 1, 'explicit width after init');
el.remove(); el.remove();
}); });

View File

@ -0,0 +1,45 @@
TestHelpers.dialog = {
drag: function(el, handle, dx, dy) {
var d = el.dialog('widget');
//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");
$(handle, d).simulate("drag", {
dx: dx || 0,
dy: dy || 0
});
},
testDrag: function(el, dx, dy, expectedDX, expectedDY, msg) {
var actual, expected, offsetAfter,
d = el.dialog('widget'),
handle = $(".ui-dialog-titlebar", d),
offsetBefore = d.offset();
TestHelpers.dialog.drag(el, handle, dx, dy);
offsetAfter = d.offset();
msg = msg ? msg + "." : "";
actual = { left: Math.round(offsetAfter.left), top: Math.round(offsetAfter.top) },
expected = { left: Math.round(offsetBefore.left + expectedDX), top: Math.round(offsetBefore.top + expectedDY) };
deepEqual(actual, expected, 'dragged[' + expectedDX + ', ' + expectedDY + '] ' + msg);
},
shouldResize: function(el, dw, dh, msg) {
var heightAfter, widthAfter, actual, expected,
d = el.dialog('widget'),
handle = $(".ui-resizable-se", d),
heightBefore = d.height(),
widthBefore = d.width();
TestHelpers.dialog.drag(el, handle, 50, 50);
heightAfter = d.height();
widthAfter = d.width();
msg = msg ? msg + "." : "";
actual = { width: widthAfter, height: heightAfter },
expected = { width: widthBefore + dw, height: heightBefore + dh };
deepEqual(actual, expected, 'resized[' + 50 + ', ' + 50 + '] ' + msg);
}
};

View File

@ -36,21 +36,21 @@ asyncTest( "#3123: Prevent tabbing out of modal dialogs", function() {
test("#4826: setting resizable false toggles resizable on dialog", function() { test("#4826: setting resizable false toggles resizable on dialog", function() {
expect(6); expect(6);
var i; var i,
el = $('<div></div>').dialog({ resizable: false });
el = $('<div></div>').dialog({ resizable: false }); TestHelpers.dialog.shouldResize(el, 0, 0, "[default]");
shouldnotresize("[default]");
for (i=0; i<2; i++) { for (i=0; i<2; i++) {
el.dialog('close').dialog('open'); el.dialog('close').dialog('open');
shouldnotresize('initialized with resizable false toggle ('+ (i+1) +')'); TestHelpers.dialog.shouldResize(el, 0, 0, 'initialized with resizable false toggle ('+ (i+1) +')');
} }
el.remove(); el.remove();
el = $('<div></div>').dialog({ resizable: true }); el = $('<div></div>').dialog({ resizable: true });
shouldresize("[default]"); TestHelpers.dialog.shouldResize(el, 50, 50, "[default]");
for (i=0; i<2; i++) { for (i=0; i<2; i++) {
el.dialog('close').dialog('option', 'resizable', false).dialog('open'); el.dialog('close').dialog('option', 'resizable', false).dialog('open');
shouldnotresize('set option resizable false toggle ('+ (i+1) +')'); TestHelpers.dialog.shouldResize(el, 0, 0, 'set option resizable false toggle ('+ (i+1) +')');
} }
el.remove(); el.remove();
@ -59,11 +59,11 @@ test("#4826: setting resizable false toggles resizable on dialog", function() {
test("#5184: isOpen in dialogclose event is true", function() { test("#5184: isOpen in dialogclose event is true", function() {
expect( 3 ); expect( 3 );
el = $( "<div></div>" ).dialog({ var el = $( "<div></div>" ).dialog({
close: function() { close: function() {
ok( !el.dialog("isOpen"), "dialog is not open during close" ); ok( !el.dialog("isOpen"), "dialog is not open during close" );
} }
}); });
ok( el.dialog("isOpen"), "dialog is open after init" ); ok( el.dialog("isOpen"), "dialog is open after init" );
el.dialog( "close" ); el.dialog( "close" );
ok( !el.dialog("isOpen"), "dialog is not open after close" ); ok( !el.dialog("isOpen"), "dialog is not open after close" );
@ -72,7 +72,7 @@ test("#5184: isOpen in dialogclose event is true", function() {
test("#5531: dialog width should be at least minWidth on creation", function () { test("#5531: dialog width should be at least minWidth on creation", function () {
expect( 4 ); expect( 4 );
el = $('<div></div>').dialog({ var el = $('<div></div>').dialog({
width: 200, width: 200,
minWidth: 300 minWidth: 300
}); });
@ -95,107 +95,33 @@ test("#5531: dialog width should be at least minWidth on creation", function ()
test("#6137: dialog('open') causes form elements to reset on IE7", function() { test("#6137: dialog('open') causes form elements to reset on IE7", function() {
expect(2); expect(2);
d1 = $('<form><input type="radio" name="radio" id="a" value="a" checked="checked"></input>' + var d1 = $('<form><input type="radio" name="radio" id="a" value="a" checked="checked"></input>' +
'<input type="radio" name="radio" id="b" value="b">b</input></form>').appendTo( "body" ).dialog({autoOpen: false}); '<input type="radio" name="radio" id="b" value="b">b</input></form>').appendTo( "body" ).dialog({autoOpen: false});
d1.find('#b').prop( "checked", true ); d1.find('#b').prop( "checked", true );
equal($('input:checked').val(), 'b', "checkbox b is checked"); equal(d1.find('input:checked').val(), 'b', "checkbox b is checked");
d1.dialog('open'); d1.dialog('open');
equal($('input:checked').val(), 'b', "checkbox b is checked"); equal(d1.find('input:checked').val(), 'b', "checkbox b is checked");
d1.remove(); d1.remove();
}); });
test("#6645: Missing element not found check in overlay", function(){ test("#6645: Missing element not found check in overlay", function(){
expect(2); expect(2);
d1 = $('<div title="dialog 1">Dialog 1</div>').dialog({modal: true}); var d1 = $('<div title="dialog 1">Dialog 1</div>').dialog({modal: true}),
d2 = $('<div title="dialog 2">Dialog 2</div>').dialog({modal: true, close: function(){ d2.remove(); }}); d2 = $('<div title="dialog 2">Dialog 2</div>').dialog({modal: true, close: function(){ d2.remove(); }});
equal($.ui.dialog.overlay.instances.length, 2, 'two overlays created'); equal($.ui.dialog.overlay.instances.length, 2, 'two overlays created');
d2.dialog('close'); d2.dialog('close');
equal($.ui.dialog.overlay.instances.length, 1, 'one overlay remains after closing the 2nd overlay'); equal($.ui.dialog.overlay.instances.length, 1, 'one overlay remains after closing the 2nd overlay');
d1.add(d2).remove(); d1.add(d2).remove();
}); });
test("#6966: Escape key closes all dialogs, not the top one", function(){
expect(24);
// test with close function removing dialog triggered through the overlay
d1 = $('<div title="dialog 1">Dialog 1</div>').dialog({modal: true, close: function(){ d1.remove(); }});
d2 = $('<div title="dialog 2">Dialog 2</div>').dialog({modal: true, close: function(){ d2.remove(); }});
ok(d1.data('dialog') && d1.dialog('isOpen'), 'first dialog is open');
ok(d2.data('dialog') && d2.dialog('isOpen'), 'second dialog is open');
$( document ).simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE});
ok(d1.data('dialog') && d1.dialog('isOpen'), 'first dialog still open');
ok(!d2.data('dialog'), 'second dialog is closed');
$( document ).simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE});
ok(!d1.data('dialog'), 'first dialog is closed');
ok(!d2.data('dialog'), 'second dialog is closed');
d2.remove();
d1.remove();
// test with close function removing dialog triggered through the dialog
d1 = $('<div title="dialog 1">Dialog 1</div>').dialog({modal: true, close: function(){ d1.remove(); }});
d2 = $('<div title="dialog 2">Dialog 2</div>').dialog({modal: true, close: function(){ d2.remove(); }});
ok(d1.data('dialog') && d1.dialog('isOpen'), 'first dialog is open');
ok(d2.data('dialog') && d2.dialog('isOpen'), 'second dialog is open');
d2.simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE});
ok(d1.data('dialog') && d1.dialog('isOpen'), 'first dialog still open');
ok(!d2.data('dialog'), 'second dialog is closed');
d1.simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE});
ok(!d1.data('dialog'), 'first dialog is closed');
ok(!d2.data('dialog'), 'second dialog is closed');
d2.remove();
d1.remove();
// test without close function removing dialog
d1 = $('<div title="dialog 1">Dialog 1</div>').dialog({modal: true});
d2 = $('<div title="dialog 2">Dialog 2</div>').dialog({modal: true});
ok(d1.dialog("isOpen"), 'first dialog is open');
ok(d2.dialog("isOpen"), 'second dialog is open');
d2.simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
ok(d1.dialog("isOpen"), 'first dialog still open');
ok(!d2.dialog("isOpen"), 'second dialog is closed');
d1.simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
ok(!d1.dialog("isOpen"), 'first dialog is closed');
ok(!d2.dialog("isOpen"), 'second dialog is closed');
d2.remove();
d1.remove();
// test without close function removing dialog triggered through the overlay
d1 = $('<div title="dialog 1">Dialog 1</div>').dialog({modal: true});
d2 = $('<div title="dialog 2">Dialog 2</div>').dialog({modal: true});
ok(d1.dialog("isOpen"), 'first dialog is open');
ok(d2.dialog("isOpen"), 'second dialog is open');
$( document ).simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
ok(d1.dialog("isOpen"), 'first dialog still open');
ok(!d2.dialog("isOpen"), 'second dialog is closed');
$( document ).simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
ok(!d1.dialog("isOpen"), 'first dialog is closed');
ok(!d2.dialog("isOpen"), 'second dialog is closed');
d2.remove();
d1.remove();
});
test("#4980: Destroy should place element back in original DOM position", function(){ test("#4980: Destroy should place element back in original DOM position", function(){
expect( 2 ); expect( 2 );
container = $('<div id="container"><div id="modal">Content</div></div>'); var container = $('<div id="container"><div id="modal">Content</div></div>'),
modal = container.find('#modal'); modal = container.find('#modal');
modal.dialog(); modal.dialog();
ok(!$.contains(container[0], modal[0]), 'dialog should move modal element to outside container element'); ok(!$.contains(container[0], modal[0]), 'dialog should move modal element to outside container element');
modal.dialog('destroy'); modal.dialog('destroy');

View File

@ -26,17 +26,8 @@
<script src="draggable_events.js"></script> <script src="draggable_events.js"></script>
<script src="draggable_methods.js"></script> <script src="draggable_methods.js"></script>
<script src="draggable_options.js"></script> <script src="draggable_options.js"></script>
<script src="draggable_test_helpers.js"></script>
<script>
// disable this stale testsuite for testswarm only
var url = window.location.search;
url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + 9 ) );
if ( url && url.indexOf("http") == 0 ) {
// reset config to kill previous tests; make sure testsuite.js is loaded afterwards to init the testswarm script
QUnit.init();
test("draggable", function() { ok(true, "disabled draggable testsuite"); });
}
</script>
<script src="../swarminject.js"></script> <script src="../swarminject.js"></script>
</head> </head>
<body> <body>
@ -48,11 +39,14 @@
<ol id="qunit-tests"></ol> <ol id="qunit-tests"></ol>
<div id="qunit-fixture"> <div id="qunit-fixture">
<div id="main"></div>
<div id="draggable1" style="background: green; width: 200px; height: 100px;">Relative</div> <div id="draggable1" style="background: green; width: 200px; height: 100px;">Relative</div>
<div id="draggable2" style="background: green; width: 200px; height: 100px; position: absolute; top: 10px; left: 10px;"><span>Absolute</span></div> <div id="draggable2" style="background: green; width: 200px; height: 100px; position: absolute; top: 10px; left: 10px;"><span>Absolute</span></div>
<div style='width: 1px; height: 1000px;'></div> <div style='width: 1px; height: 1000px;'></div>
<div style="position: absolute; width: 1px; height: 2000px;"></div> <div style="position: absolute; width: 1px; height: 2000px;"></div>
</div> </div>
</body> </body>
</html> </html>

View File

@ -6,6 +6,7 @@ TestHelpers.commonWidgetTests( "draggable", {
cancel: "input,textarea,button,select,option", cancel: "input,textarea,button,select,option",
connectToSortable: false, connectToSortable: false,
containment: false, containment: false,
create: null,
cursor: "auto", cursor: "auto",
cursorAt: false, cursorAt: false,
delay: 0, delay: 0,

View File

@ -2,34 +2,6 @@
* draggable_core.js * draggable_core.js
*/ */
var el, offsetBefore, offsetAfter, dragged;
function drag(handle, dx, dy) {
var element = el.data("draggable").element;
offsetBefore = el.offset();
$(handle).simulate("drag", {
dx: dx || 0,
dy: dy || 0
});
dragged = { dx: dx, dy: dy };
offsetAfter = el.offset();
}
function moved(dx, dy, msg) {
msg = msg ? msg + "." : "";
var actual = { left: offsetAfter.left, top: offsetAfter.top },
expected = { left: offsetBefore.left + dx, top: offsetBefore.top + dy };
deepEqual(actual, expected, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ' + msg);
}
function restoreScroll(what) {
if(what) {
$(document).scrollTop(0); $(document).scrollLeft(0);
} else {
$("#main")[0].scrollTop = 0; $("#main")[0].scrollLeft = 0;
}
}
(function($) { (function($) {
module("draggable"); module("draggable");
@ -37,31 +9,39 @@ module("draggable");
test("element types", function() { test("element types", function() {
var typeNames = ('p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form' + var typeNames = ('p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form' +
',table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr' + ',table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr' +
',acronym,code,samp,kbd,var,img,object,hr' + ',acronym,code,samp,kbd,var,img,hr' +
',input,button,label,select,iframe').split(','); ',input,button,label,select,iframe').split(',');
expect( typeNames.length * 2 );
$.each(typeNames, function(i) { $.each(typeNames, function(i) {
var typeName = typeNames[i]; var offsetBefore, offsetAfter,
el = $(document.createElement(typeName)).appendTo('body'); typeName = typeNames[i],
el = $(document.createElement(typeName)).appendTo('#main');
(typeName === 'table' && el.append("<tr><td>content</td></tr>")); (typeName === 'table' && el.append("<tr><td>content</td></tr>"));
el.draggable({ cancel: '' }); el.draggable({ cancel: '' });
drag(el, 50, 50); offsetBefore = el.offset();
moved(50, 50, "&lt;" + typeName + "&gt;"); TestHelpers.draggable.drag(el, 50, 50);
offsetAfter = el.offset();
// there are some rounding errors in FF, Chrome, and IE9, so we can't say equal, we have to settle for close enough
closeEnough(offsetBefore.left, offsetAfter.left - 50, 1, "dragged[50, 50] " + "<" + typeName + ">");
closeEnough(offsetBefore.top, offsetAfter.top - 50, 1, "dragged[50, 50] " + "<" + typeName + ">");
el.draggable("destroy"); el.draggable("destroy");
el.remove(); el.remove();
}); });
}); });
test("No options, relative", function() { test("No options, relative", function() {
el = $("#draggable1").draggable(); expect( 1 );
drag(el, 50, 50); var el = $("#draggable1").draggable();
moved(50, 50); TestHelpers.draggable.shouldMove(el);
}); });
test("No options, absolute", function() { test("No options, absolute", function() {
el = $("#draggable2").draggable(); expect( 1 );
drag(el, 50, 50); var el = $("#draggable2").draggable();
moved(50, 50); TestHelpers.draggable.shouldMove(el);
}); });
})(jQuery); })(jQuery);

View File

@ -9,14 +9,16 @@ test("callbacks occurrence count", function() {
expect(3); expect(3);
var start = 0, stop = 0, dragc = 0; var start = 0,
el = $("#draggable2").draggable({ stop = 0,
start: function() { start++; }, dragc = 0,
drag: function() { dragc++; }, el = $("#draggable2").draggable({
stop: function() { stop++; } start: function() { start++; },
}); drag: function() { dragc++; },
stop: function() { stop++; }
});
drag(el, 10, 10); TestHelpers.draggable.drag(el, 10, 10);
equal(start, 1, "start callback should happen exactly once"); equal(start, 1, "start callback should happen exactly once");
equal(dragc, 3, "drag callback should happen exactly once per mousemove"); equal(dragc, 3, "drag callback should happen exactly once per mousemove");
@ -28,14 +30,16 @@ test("stopping the start callback", function() {
expect(3); expect(3);
var start = 0, stop = 0, dragc = 0; var start = 0,
el = $("#draggable2").draggable({ stop = 0,
start: function() { start++; return false; }, dragc = 0,
drag: function() { dragc++; }, el = $("#draggable2").draggable({
stop: function() { stop++; } start: function() { start++; return false; },
}); drag: function() { dragc++; },
stop: function() { stop++; }
});
drag(el, 10, 10); TestHelpers.draggable.drag(el, 10, 10);
equal(start, 1, "start callback should happen exactly once"); equal(start, 1, "start callback should happen exactly once");
equal(dragc, 0, "drag callback should not happen at all"); equal(dragc, 0, "drag callback should not happen at all");
@ -47,14 +51,16 @@ test("stopping the drag callback", function() {
expect(3); expect(3);
var start = 0, stop = 0, dragc = 0; var start = 0,
el = $("#draggable2").draggable({ stop = 0,
start: function() { start++;}, dragc = 0,
drag: function() { dragc++; return false; }, el = $("#draggable2").draggable({
stop: function() { stop++; } start: function() { start++;},
}); drag: function() { dragc++; return false; },
stop: function() { stop++; }
});
drag(el, 10, 10); TestHelpers.draggable.drag(el, 10, 10);
equal(start, 1, "start callback should happen exactly once"); equal(start, 1, "start callback should happen exactly once");
equal(dragc, 1, "drag callback should happen exactly once"); equal(dragc, 1, "drag callback should happen exactly once");
@ -66,14 +72,14 @@ test("stopping the stop callback", function() {
expect(1); expect(1);
el = $("#draggable2").draggable({ var el = $("#draggable2").draggable({
helper: 'clone', helper: 'clone',
stop: function() { return false; } stop: function() { return false; }
}); });
drag(el, 10, 10); TestHelpers.draggable.drag(el, 10, 10);
ok($("#draggable2").data('draggable').helper, "the clone should not be deleted if the stop callback is stopped"); ok($("#draggable2").data('ui-draggable').helper, "the clone should not be deleted if the stop callback is stopped");
}); });

View File

@ -3,20 +3,10 @@
*/ */
(function($) { (function($) {
function shouldmove(why) {
drag(el, 50, 50);
moved(50, 50, why);
}
function shouldnotmove(why) {
drag(el, 50, 50);
moved(0, 0, why);
}
module("draggable: methods"); module("draggable: methods");
test("init", function() { test("init", function() {
expect(6); expect(5);
$("<div></div>").appendTo('body').draggable().remove(); $("<div></div>").appendTo('body').draggable().remove();
ok(true, '.draggable() called on element'); ok(true, '.draggable() called on element');
@ -27,9 +17,6 @@ test("init", function() {
$("<div></div>").draggable(); $("<div></div>").draggable();
ok(true, '.draggable() called on disconnected DOMElement'); ok(true, '.draggable() called on disconnected DOMElement');
$("<div></div>").draggable().draggable("foo");
ok(true, 'arbitrary method called after init');
$("<div></div>").draggable().draggable("option", "foo"); $("<div></div>").draggable().draggable("option", "foo");
ok(true, 'arbitrary option getter after init'); ok(true, 'arbitrary option getter after init');
@ -38,6 +25,7 @@ test("init", function() {
}); });
test("destroy", function() { test("destroy", function() {
expect(4);
$("<div></div>").appendTo('body').draggable().draggable("destroy").remove(); $("<div></div>").appendTo('body').draggable().draggable("destroy").remove();
ok(true, '.draggable("destroy") called on element'); ok(true, '.draggable("destroy") called on element');
@ -47,9 +35,6 @@ test("destroy", function() {
$("<div></div>").draggable().draggable("destroy"); $("<div></div>").draggable().draggable("destroy");
ok(true, '.draggable("destroy") called on disconnected DOMElement'); ok(true, '.draggable("destroy") called on disconnected DOMElement');
$("<div></div>").draggable().draggable("destroy").draggable("foo");
ok(true, 'arbitrary method called after destroy');
var expected = $('<div></div>').draggable(), var expected = $('<div></div>').draggable(),
actual = expected.draggable('destroy'); actual = expected.draggable('destroy');
equal(actual, expected, 'destroy is chainable'); equal(actual, expected, 'destroy is chainable');
@ -57,42 +42,52 @@ test("destroy", function() {
test("enable", function() { test("enable", function() {
expect(7); expect(7);
var expected, actual, el;
el = $("#draggable2").draggable({ disabled: true }); el = $("#draggable2").draggable({ disabled: true });
shouldnotmove('.draggable({ disabled: true })'); TestHelpers.draggable.shouldNotMove(el, '.draggable({ disabled: true })');
el.draggable("enable"); el.draggable("enable");
shouldmove('.draggable("enable")'); TestHelpers.draggable.shouldMove(el, '.draggable("enable")');
equal(el.draggable("option", "disabled"), false, "disabled option getter"); equal(el.draggable("option", "disabled"), false, "disabled option getter");
el.draggable("destroy"); el.draggable("destroy");
el.draggable({ disabled: true }); el.draggable({ disabled: true });
shouldnotmove('.draggable({ disabled: true })'); TestHelpers.draggable.shouldNotMove(el, '.draggable({ disabled: true })');
el.draggable("option", "disabled", false); el.draggable("option", "disabled", false);
equal(el.draggable("option", "disabled"), false, "disabled option setter"); equal(el.draggable("option", "disabled"), false, "disabled option setter");
shouldmove('.draggable("option", "disabled", false)'); TestHelpers.draggable.shouldMove(el, '.draggable("option", "disabled", false)');
var expected = $('<div></div>').draggable(), expected = $('<div></div>').draggable(),
actual = expected.draggable('enable'); actual = expected.draggable('enable');
equal(actual, expected, 'enable is chainable'); equal(actual, expected, 'enable is chainable');
}); });
test("disable", function() { test("disable", function() {
expect(7); expect(7);
var expected, actual, el;
el = $("#draggable2").draggable({ disabled: false }); el = $("#draggable2").draggable({ disabled: false });
shouldmove('.draggable({ disabled: false })'); TestHelpers.draggable.shouldMove(el, '.draggable({ disabled: false })');
el.draggable("disable"); el.draggable("disable");
shouldnotmove('.draggable("disable")'); TestHelpers.draggable.shouldNotMove(el, '.draggable("disable")');
equal(el.draggable("option", "disabled"), true, "disabled option getter"); equal(el.draggable("option", "disabled"), true, "disabled option getter");
el.draggable("destroy"); el.draggable("destroy");
el.draggable({ disabled: false }); el.draggable({ disabled: false });
shouldmove('.draggable({ disabled: false })'); TestHelpers.draggable.shouldMove(el, '.draggable({ disabled: false })');
el.draggable("option", "disabled", true); el.draggable("option", "disabled", true);
equal(el.draggable("option", "disabled"), true, "disabled option setter"); equal(el.draggable("option", "disabled"), true, "disabled option setter");
shouldnotmove('.draggable("option", "disabled", true)'); TestHelpers.draggable.shouldNotMove(el, '.draggable("option", "disabled", true)');
var expected = $('<div></div>').draggable(), expected = $('<div></div>').draggable(),
actual = expected.draggable('disable'); actual = expected.draggable('disable');
equal(actual, expected, 'disable is chainable'); equal(actual, expected, 'disable is chainable');
}); });

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,57 @@
TestHelpers.draggable = {
// todo: remove the unreliable offset hacks
unreliableOffset: $.ui.ie && ( !document.documentMode || document.documentMode < 8 ) ? 2 : 0,
drag: function(handle, dx, dy) {
$(handle).simulate("drag", {
dx: dx || 0,
dy: dy || 0
});
},
testDrag: function(el, handle, dx, dy, expectedDX, expectedDY, msg) {
var offsetAfter, actual, expected,
offsetBefore = el.offset();
TestHelpers.draggable.drag(handle, dx, dy);
offsetAfter = el.offset();
actual = { left: offsetAfter.left, top: offsetAfter.top },
expected = { left: offsetBefore.left + expectedDX, top: offsetBefore.top + expectedDY };
msg = msg ? msg + "." : "";
deepEqual(actual, expected, 'dragged[' + dx + ', ' + dy + '] ' + msg);
},
shouldMove: function(el, why) {
TestHelpers.draggable.testDrag(el, el, 50, 50, 50, 50, why);
},
shouldNotMove: function(el, why) {
TestHelpers.draggable.testDrag(el, el, 50, 50, 0, 0, why);
},
testScroll: function(el, position ) {
var oldPosition = $("#main").css('position');
$("#main").css('position', position);
TestHelpers.draggable.shouldMove(el, position+' parent');
$("#main").css('position', oldPosition);
},
restoreScroll: function( what ) {
if( what ) {
$(document).scrollTop(0); $(document).scrollLeft(0);
} else {
$("#main").scrollTop(0); $("#main").scrollLeft(0);
}
},
setScroll: function( what ) {
if(what) {
// todo: currently, the draggable interaction doesn't properly account for scrolled pages,
// uncomment the line below to make the tests fail that should when the page is scrolled
// $(document).scrollTop(100); $(document).scrollLeft(100);
} else {
$("#main").scrollTop(100); $("#main").scrollLeft(100);
}
},
border: function(el, side) {
return parseInt(el.css('border-' + side + '-width'), 10) || 0;
},
margin: function(el, side) {
return parseInt(el.css('margin-' + side), 10) || 0;
}
};

View File

@ -27,17 +27,8 @@
<script src="droppable_events.js"></script> <script src="droppable_events.js"></script>
<script src="droppable_methods.js"></script> <script src="droppable_methods.js"></script>
<script src="droppable_options.js"></script> <script src="droppable_options.js"></script>
<script src="droppable_test_helpers.js"></script>
<script>
// disable this stale testsuite for testswarm only
var url = window.location.search;
url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + 9 ) );
if ( url && url.indexOf("http") == 0 ) {
// reset config to kill previous tests; make sure testsuite.js is loaded afterwards to init the testswarm script
QUnit.init();
test("droppable", function() { ok(true, "disabled droppable testsuite"); });
}
</script>
<script src="../swarminject.js"></script> <script src="../swarminject.js"></script>
</head> </head>
<body> <body>

View File

@ -3,6 +3,7 @@ TestHelpers.commonWidgetTests( "droppable", {
accept: "*", accept: "*",
activeClass: false, activeClass: false,
addClasses: true, addClasses: true,
create: null,
disabled: false, disabled: false,
greedy: false, greedy: false,
hoverClass: false, hoverClass: false,

View File

@ -2,16 +2,6 @@
* droppable_core.js * droppable_core.js
*/ */
var el, drg;
function shouldBeDroppable() {
ok(false, 'missing test - untested code is broken code');
}
function shouldNotBeDroppable() {
ok(false, 'missing test - untested code is broken code');
}
(function($) { (function($) {
module("droppable: core"); module("droppable: core");
@ -19,15 +9,18 @@ module("droppable: core");
test("element types", function() { test("element types", function() {
var typeNames = ('p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form' + var typeNames = ('p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form' +
',table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr' + ',table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr' +
',acronym,code,samp,kbd,var,img,object,hr' + ',acronym,code,samp,kbd,var,img,hr' +
',input,button,label,select,iframe').split(','); ',input,button,label,select,iframe').split(',');
expect( typeNames.length );
$.each(typeNames, function(i) { $.each(typeNames, function(i) {
var typeName = typeNames[i]; var typeName = typeNames[i],
el = $(document.createElement(typeName)).appendTo('body'); el = $(document.createElement(typeName)).appendTo('body');
(typeName === 'table' && el.append("<tr><td>content</td></tr>")); (typeName === 'table' && el.append("<tr><td>content</td></tr>"));
el.droppable(); el.droppable();
shouldBeDroppable(); TestHelpers.droppable.shouldDrop();
el.droppable("destroy"); el.droppable("destroy");
el.remove(); el.remove();
}); });

View File

@ -5,6 +5,12 @@
module("droppable: events"); module("droppable: events");
// this is here to make JSHint pass "unused", and we don't want to
// remove the parameter for when we finally implement
$.noop();
// todo: comment the following in when ready to actually test
/*
test("activate", function() { test("activate", function() {
ok(false, 'missing test - untested code is broken code'); ok(false, 'missing test - untested code is broken code');
}); });
@ -24,5 +30,6 @@ test("out", function() {
test("drop", function() { test("drop", function() {
ok(false, 'missing test - untested code is broken code'); ok(false, 'missing test - untested code is broken code');
}); });
*/
})(jQuery); })(jQuery);

View File

@ -6,7 +6,7 @@
module("droppable: methods"); module("droppable: methods");
test("init", function() { test("init", function() {
expect(6); expect( 5 );
$("<div></div>").appendTo('body').droppable().remove(); $("<div></div>").appendTo('body').droppable().remove();
ok(true, '.droppable() called on element'); ok(true, '.droppable() called on element');
@ -17,9 +17,6 @@ test("init", function() {
$("<div></div>").droppable(); $("<div></div>").droppable();
ok(true, '.droppable() called on disconnected DOMElement'); ok(true, '.droppable() called on disconnected DOMElement');
$("<div></div>").droppable().droppable("foo");
ok(true, 'arbitrary method called after init');
$("<div></div>").droppable().droppable("option", "foo"); $("<div></div>").droppable().droppable("option", "foo");
ok(true, 'arbitrary option getter after init'); ok(true, 'arbitrary option getter after init');
@ -28,6 +25,8 @@ test("init", function() {
}); });
test("destroy", function() { test("destroy", function() {
expect( 4 );
$("<div></div>").appendTo('body').droppable().droppable("destroy").remove(); $("<div></div>").appendTo('body').droppable().droppable("destroy").remove();
ok(true, '.droppable("destroy") called on element'); ok(true, '.droppable("destroy") called on element');
@ -37,9 +36,6 @@ test("destroy", function() {
$("<div></div>").droppable().droppable("destroy"); $("<div></div>").droppable().droppable("destroy");
ok(true, '.droppable("destroy") called on disconnected DOMElement'); ok(true, '.droppable("destroy") called on disconnected DOMElement');
$("<div></div>").droppable().droppable("destroy").droppable("foo");
ok(true, 'arbitrary method called after destroy');
var expected = $('<div></div>').droppable(), var expected = $('<div></div>').droppable(),
actual = expected.droppable('destroy'); actual = expected.droppable('destroy');
equal(actual, expected, 'destroy is chainable'); equal(actual, expected, 'destroy is chainable');
@ -47,39 +43,45 @@ test("destroy", function() {
test("enable", function() { test("enable", function() {
expect(7); expect(7);
var el, expected, actual;
el = $("#droppable1").droppable({ disabled: true }); el = $("#droppable1").droppable({ disabled: true });
shouldNotBeDroppable(); TestHelpers.droppable.shouldNotDrop();
el.droppable("enable"); el.droppable("enable");
shouldBeDroppable(); TestHelpers.droppable.shouldDrop();
equal(el.droppable("option", "disabled"), false, "disabled option getter"); equal(el.droppable("option", "disabled"), false, "disabled option getter");
el.droppable("destroy"); el.droppable("destroy");
el.droppable({ disabled: true }); el.droppable({ disabled: true });
shouldNotBeDroppable(); TestHelpers.droppable.shouldNotDrop();
el.droppable("option", "disabled", false); el.droppable("option", "disabled", false);
equal(el.droppable("option", "disabled"), false, "disabled option setter"); equal(el.droppable("option", "disabled"), false, "disabled option setter");
shouldBeDroppable(); TestHelpers.droppable.shouldDrop();
var expected = $('<div></div>').droppable(), expected = $('<div></div>').droppable(),
actual = expected.droppable('enable'); actual = expected.droppable('enable');
equal(actual, expected, 'enable is chainable'); equal(actual, expected, 'enable is chainable');
}); });
test("disable", function() { test("disable", function() {
expect(7); expect(7);
var el, actual, expected;
el = $("#droppable1").droppable({ disabled: false }); el = $("#droppable1").droppable({ disabled: false });
shouldBeDroppable(); TestHelpers.droppable.shouldDrop();
el.droppable("disable"); el.droppable("disable");
shouldNotBeDroppable(); TestHelpers.droppable.shouldNotDrop();
equal(el.droppable("option", "disabled"), true, "disabled option getter"); equal(el.droppable("option", "disabled"), true, "disabled option getter");
el.droppable("destroy"); el.droppable("destroy");
el.droppable({ disabled: false }); el.droppable({ disabled: false });
shouldBeDroppable(); TestHelpers.droppable.shouldDrop();
el.droppable("option", "disabled", true); el.droppable("option", "disabled", true);
equal(el.droppable("option", "disabled"), true, "disabled option setter"); equal(el.droppable("option", "disabled"), true, "disabled option setter");
shouldNotBeDroppable(); TestHelpers.droppable.shouldNotDrop();
var expected = $('<div></div>').droppable(), expected = $('<div></div>').droppable(),
actual = expected.droppable('disable'); actual = expected.droppable('disable');
equal(actual, expected, 'disable is chainable'); equal(actual, expected, 'disable is chainable');
}); });

View File

@ -5,6 +5,7 @@
module("droppable: options"); module("droppable: options");
/*
test("{ accept '*' }, default ", function() { test("{ accept '*' }, default ", function() {
ok(false, 'missing test - untested code is broken code'); ok(false, 'missing test - untested code is broken code');
}); });
@ -20,19 +21,21 @@ test("{ accept: function(draggable) }", function() {
test("activeClass", function() { test("activeClass", function() {
ok(false, 'missing test - untested code is broken code'); ok(false, 'missing test - untested code is broken code');
}); });
*/
test("{ addClasses: true }, default", function() { test("{ addClasses: true }, default", function() {
el = $("<div></div>").droppable({ addClasses: true }); expect( 1 );
var el = $("<div></div>").droppable({ addClasses: true });
ok(el.is(".ui-droppable"), "'ui-droppable' class added"); ok(el.is(".ui-droppable"), "'ui-droppable' class added");
el.droppable("destroy"); el.droppable("destroy");
}); });
test("{ addClasses: false }", function() { test("{ addClasses: false }", function() {
el = $("<div></div>").droppable({ addClasses: false }); expect( 1 );
var el = $("<div></div>").droppable({ addClasses: false });
ok(!el.is(".ui-droppable"), "'ui-droppable' class not added"); ok(!el.is(".ui-droppable"), "'ui-droppable' class not added");
el.droppable("destroy"); el.droppable("destroy");
}); });
/*
test("greedy", function() { test("greedy", function() {
ok(false, 'missing test - untested code is broken code'); ok(false, 'missing test - untested code is broken code');
}); });
@ -60,5 +63,5 @@ test("tolerance, pointer", function() {
test("tolerance, touch", function() { test("tolerance, touch", function() {
ok(false, 'missing test - untested code is broken code'); ok(false, 'missing test - untested code is broken code');
}); });
*/
})(jQuery); })(jQuery);

View File

@ -0,0 +1,10 @@
TestHelpers.droppable = {
shouldDrop: function() {
// todo: actually implement this
ok(true, 'missing test - untested code is broken code');
},
shouldNotDrop: function() {
// todo: actually implement this
ok(true, 'missing test - untested code is broken code');
}
};

View File

@ -5,9 +5,6 @@
<title>jQuery UI Effects Test Suite</title> <title>jQuery UI Effects Test Suite</title>
<script src="../../jquery.js"></script> <script src="../../jquery.js"></script>
<script>
$.uiBackCompat = false;
</script>
<link rel="stylesheet" href="../../../external/qunit.css"> <link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script> <script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script> <script src="../../jquery.simulate.js"></script>

View File

@ -12,10 +12,7 @@ function notPresent( value, array, message ) {
var minDuration = 15, var minDuration = 15,
// duration is used for "long" animates where we plan on testing properties during animation // duration is used for "long" animates where we plan on testing properties during animation
duration = 200, duration = 200;
// mid is used for testing in the "middle" of the "duration" animations
mid = duration / 2;
module( "effects.core" ); module( "effects.core" );
@ -31,6 +28,17 @@ test( "Immediate Return Conditions", function() {
equal( ++count, 3, "Both Functions worked properly" ); equal( ++count, 3, "Both Functions worked properly" );
}); });
asyncTest( "Parse of null for options", function() {
var hidden = $( "div.hidden" ),
count = 0;
expect( 1 );
hidden.show( "blind", null, 1, function() {
equal( ++count, 1, "null for options still works" );
start();
});
});
/* TODO: Disabled - Can't figure out why this is failing in IE 6/7 /* TODO: Disabled - Can't figure out why this is failing in IE 6/7
test( "createWrapper and removeWrapper retain focused elements (#7595)", function() { test( "createWrapper and removeWrapper retain focused elements (#7595)", function() {
expect( 2 ); expect( 2 );
@ -47,8 +55,7 @@ test( "createWrapper and removeWrapper retain focused elements (#7595)", functio
module( "effects.core: animateClass" ); module( "effects.core: animateClass" );
asyncTest( "animateClass works with borderStyle", function() { asyncTest( "animateClass works with borderStyle", function() {
var test = $("div.animateClass"), var test = $("div.animateClass");
count = 0;
expect(3); expect(3);
test.toggleClass("testAddBorder", minDuration, function() { test.toggleClass("testAddBorder", minDuration, function() {
test.toggleClass("testAddBorder", minDuration, function() { test.toggleClass("testAddBorder", minDuration, function() {
@ -62,8 +69,8 @@ asyncTest( "animateClass works with borderStyle", function() {
asyncTest( "animateClass works with colors", function() { asyncTest( "animateClass works with colors", function() {
var test = $("div.animateClass"), var test = $("div.animateClass"),
count = 0,
oldStep = jQuery.fx.step.backgroundColor; oldStep = jQuery.fx.step.backgroundColor;
expect(2); expect(2);
// we want to catch the first frame of animation // we want to catch the first frame of animation
@ -91,7 +98,7 @@ asyncTest( "animateClass works with colors", function() {
asyncTest( "animateClass calls step option", 1, function() { asyncTest( "animateClass calls step option", 1, function() {
var test = jQuery( "div.animateClass" ), var test = jQuery( "div.animateClass" ),
step = function( fx ) { step = function() {
ok( true, "Step Function Called" ); ok( true, "Step Function Called" );
test.stop(); test.stop();
start(); start();
@ -205,7 +212,7 @@ $.each( $.effects.effect, function( effect ) {
equal( hidden.css("display"), "block", "Hidden is shown after .show(\"" +effect+ "\", time)" ); equal( hidden.css("display"), "block", "Hidden is shown after .show(\"" +effect+ "\", time)" );
})).queue( queueTest() ).hide( effect, minDuration, queueTest(function() { })).queue( queueTest() ).hide( effect, minDuration, queueTest(function() {
equal( hidden.css("display"), "none", "Back to hidden after .hide(\"" +effect+ "\", time)" ); equal( hidden.css("display"), "none", "Back to hidden after .hide(\"" +effect+ "\", time)" );
})).queue( queueTest(function(next) { })).queue( queueTest(function() {
deepEqual( hidden.queue(), ["inprogress"], "Only the inprogress sentinel remains"); deepEqual( hidden.queue(), ["inprogress"], "Only the inprogress sentinel remains");
start(); start();
})); }));

View File

@ -13,7 +13,7 @@ module( "menu: events", {
test( "handle click on menu", function() { test( "handle click on menu", function() {
expect( 1 ); expect( 1 );
var element = $( "#menu1" ).menu({ var element = $( "#menu1" ).menu({
select: function( event, ui ) { select: function() {
log(); log();
} }
}); });
@ -29,7 +29,7 @@ test( "handle click on menu", function() {
test( "handle click on custom item menu", function() { test( "handle click on custom item menu", function() {
expect( 1 ); expect( 1 );
var element = $( "#menu5" ).menu({ var element = $( "#menu5" ).menu({
select: function( event, ui ) { select: function() {
log(); log();
}, },
menus: "div" menus: "div"
@ -47,7 +47,7 @@ asyncTest( "handle blur", function() {
expect( 1 ); expect( 1 );
var blurHandled = false, var blurHandled = false,
element = $( "#menu1" ).menu({ element = $( "#menu1" ).menu({
blur: function( event, ui ) { blur: function( event ) {
// Ignore duplicate blur event fired by IE // Ignore duplicate blur event fired by IE
if ( !blurHandled ) { if ( !blurHandled ) {
blurHandled = true; blurHandled = true;
@ -69,7 +69,7 @@ asyncTest( "handle blur via click outside", function() {
expect( 1 ); expect( 1 );
var blurHandled = false, var blurHandled = false,
element = $( "#menu1" ).menu({ element = $( "#menu1" ).menu({
blur: function( event, ui ) { blur: function( event ) {
// Ignore duplicate blur event fired by IE // Ignore duplicate blur event fired by IE
if ( !blurHandled ) { if ( !blurHandled ) {
blurHandled = true; blurHandled = true;
@ -90,7 +90,7 @@ asyncTest( "handle blur via click outside", function() {
test( "handle focus of menu with active item", function() { test( "handle focus of menu with active item", function() {
expect( 1 ); expect( 1 );
var element = $( "#menu1" ).menu({ var element = $( "#menu1" ).menu({
focus: function( event, ui ) { focus: function( event ) {
log( $( event.target ).find( ".ui-state-focus" ).parent().index() ); log( $( event.target ).find( ".ui-state-focus" ).parent().index() );
} }
}); });
@ -168,7 +168,7 @@ test( "handle keyboard navigation on menu without scroll and without submenus",
select: function( event, ui ) { select: function( event, ui ) {
log( $( ui.item[0] ).text() ); log( $( ui.item[0] ).text() );
}, },
focus: function( event, ui ) { focus: function( event ) {
log( $( event.target ).find( ".ui-state-focus" ).parent().index() ); log( $( event.target ).find( ".ui-state-focus" ).parent().index() );
} }
}); });
@ -230,13 +230,13 @@ asyncTest( "handle keyboard navigation on menu without scroll and with submenus"
select: function( event, ui ) { select: function( event, ui ) {
log( $( ui.item[0] ).text() ); log( $( ui.item[0] ).text() );
}, },
focus: function( event, ui ) { focus: function( event ) {
log( $( event.target ).find( ".ui-state-focus" ).parent().index() ); log( $( event.target ).find( ".ui-state-focus" ).parent().index() );
} }
}); });
log( "keydown", true ); log( "keydown", true );
element.one( "menufocus", function( event, ui ) { element.one( "menufocus", function() {
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
equal( logOutput(), "keydown,1,2", "Keydown DOWN" ); equal( logOutput(), "keydown,1,2", "Keydown DOWN" );
@ -350,7 +350,7 @@ test( "handle keyboard navigation on menu with scroll and without submenus", fun
select: function( event, ui ) { select: function( event, ui ) {
log( $( ui.item[0] ).text() ); log( $( ui.item[0] ).text() );
}, },
focus: function( event, ui ) { focus: function( event ) {
log( $( event.target ).find( ".ui-state-focus" ).parent().index()); log( $( event.target ).find( ".ui-state-focus" ).parent().index());
} }
}); });
@ -421,13 +421,13 @@ asyncTest( "handle keyboard navigation on menu with scroll and with submenus", f
select: function( event, ui ) { select: function( event, ui ) {
log( $( ui.item[0] ).text() ); log( $( ui.item[0] ).text() );
}, },
focus: function( event, ui ) { focus: function( event ) {
log( $( event.target ).find( ".ui-state-focus" ).parent().index()); log( $( event.target ).find( ".ui-state-focus" ).parent().index());
} }
}); });
log( "keydown", true ); log( "keydown", true );
element.one( "menufocus", function( event, ui ) { element.one( "menufocus", function() {
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
equal( logOutput(), "keydown,1,2", "Keydown DOWN" ); equal( logOutput(), "keydown,1,2", "Keydown DOWN" );
@ -516,13 +516,13 @@ asyncTest( "handle keyboard navigation and mouse click on menu with disabled ite
select: function( event, ui ) { select: function( event, ui ) {
log( $( ui.item[0] ).text() ); log( $( ui.item[0] ).text() );
}, },
focus: function( event, ui ) { focus: function( event ) {
log( $( event.target ).find( ".ui-state-focus" ).parent().index()); log( $( event.target ).find( ".ui-state-focus" ).parent().index());
} }
}); });
log( "keydown", true ); log( "keydown", true );
element.one( "menufocus", function( event, ui ) { element.one( "menufocus", function() {
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
equal( logOutput(), "keydown,1", "Keydown focus but not select disabled item" ); equal( logOutput(), "keydown,1", "Keydown focus but not select disabled item" );
@ -564,13 +564,13 @@ asyncTest( "handle keyboard navigation and mouse click on menu with disabled ite
test( "handle keyboard navigation with spelling of menu items", function() { test( "handle keyboard navigation with spelling of menu items", function() {
expect( 2 ); expect( 2 );
var element = $( "#menu2" ).menu({ var element = $( "#menu2" ).menu({
focus: function( event, ui ) { focus: function( event ) {
log( $( event.target ).find( ".ui-state-focus" ).parent().index() ); log( $( event.target ).find( ".ui-state-focus" ).parent().index() );
} }
}); });
log( "keydown", true ); log( "keydown", true );
element.one( "menufocus", function( event, ui ) { element.one( "menufocus", function() {
element.simulate( "keydown", { keyCode: 65 } ); element.simulate( "keydown", { keyCode: 65 } );
element.simulate( "keydown", { keyCode: 68 } ); element.simulate( "keydown", { keyCode: 68 } );
element.simulate( "keydown", { keyCode: 68 } ); element.simulate( "keydown", { keyCode: 68 } );

View File

@ -29,7 +29,7 @@ test( "destroy", function() {
test( "enable/disable", function() { test( "enable/disable", function() {
expect( 3 ); expect( 3 );
var element = $( "#menu1" ).menu({ var element = $( "#menu1" ).menu({
select: function( event, ui ) { select: function() {
log(); log();
} }
}); });
@ -60,6 +60,15 @@ test( "refresh", function() {
equal( element.find( ".ui-menu-item" ).length, 5, "Incorrect number of menu items" ); equal( element.find( ".ui-menu-item" ).length, 5, "Incorrect number of menu items" );
}); });
test( "refresh submenu", function() {
expect( 2 );
var element = $( "#menu2" ).menu();
equal( element.find( "ul:first .ui-menu-item" ).length, 3 );
element.find( "ul" ).andSelf().append( "<li><a href=\"#\">New Item</a></li>" );
element.menu("refresh");
equal( element.find( "ul:first .ui-menu-item" ).length, 4 );
});
test( "widget", function() { test( "widget", function() {
expect( 2 ); expect( 2 );
var element = $( "#menu1" ).menu(), var element = $( "#menu1" ).menu(),

View File

@ -14,7 +14,7 @@ test( "{ disabled: true }", function() {
expect( 2 ); expect( 2 );
var element = $( "#menu1" ).menu({ var element = $( "#menu1" ).menu({
disabled: true, disabled: true,
select: function(event, ui) { select: function() {
log(); log();
} }
}); });
@ -29,7 +29,7 @@ test( "{ disabled: false }", function() {
expect( 2 ); expect( 2 );
var element = $( "#menu1" ).menu({ var element = $( "#menu1" ).menu({
disabled: false, disabled: false,
select: function( event, ui ) { select: function() {
log(); log();
} }
}); });

View File

@ -5,9 +5,6 @@
<title>jQuery UI Position Test Suite</title> <title>jQuery UI Position Test Suite</title>
<script src="../../jquery.js"></script> <script src="../../jquery.js"></script>
<script>
$.uiBackCompat = false;
</script>
<link rel="stylesheet" href="../../../external/qunit.css"> <link rel="stylesheet" href="../../../external/qunit.css">
<script src="../../../external/qunit.js"></script> <script src="../../../external/qunit.js"></script>
<script src="../../jquery.simulate.js"></script> <script src="../../jquery.simulate.js"></script>

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