Merge branch 'master' into interactions

Conflicts:
	ui/jquery.ui.draggable.js
This commit is contained in:
Jörn Zaefferer 2012-07-24 17:20:18 +02:00
commit afc6835cd2
168 changed files with 5407 additions and 2892 deletions

View File

@ -42,7 +42,7 @@ Adam Sontag <ajpiano@ajpiano.com>
Carl Fürstenberg <carl@excito.com> Carl Fürstenberg <carl@excito.com>
Kevin Dalman <development@allpro.net> Kevin Dalman <development@allpro.net>
Alberto Fernández Capel <afcapel@gmail.com> Alberto Fernández Capel <afcapel@gmail.com>
Jacek Jędrzejewski <jacek.jedrzejewski@gmail.com> Jacek Jędrzejewski (http://jacek.jedrzejewski.name)
Ting Kuei <ting@kuei.com> Ting Kuei <ting@kuei.com>
Samuel Cormier-Iijima <sam@chide.it> Samuel Cormier-Iijima <sam@chide.it>
Jon Palmer <jonspalmer@gmail.com> Jon Palmer <jonspalmer@gmail.com>
@ -170,7 +170,7 @@ Ian Simpson <spoonlikesham@gmail.com>
Lev Kitsis <spam4lev@gmail.com> Lev Kitsis <spam4lev@gmail.com>
TJ VanToll <tj.vantoll@gmail.com> TJ VanToll <tj.vantoll@gmail.com>
Justin Domnitz <jdomnitz@gmail.com> Justin Domnitz <jdomnitz@gmail.com>
Douglas Cerna <replaceafill@system76.(none)> Douglas Cerna <douglascerna@yahoo.com>
Bert ter Heide <bertjh@hotmail.com> Bert ter Heide <bertjh@hotmail.com>
Jasvir Nagra <jasvir@gmail.com> Jasvir Nagra <jasvir@gmail.com>
Petr Hromadko <yuriy@tokyoscale.com> Petr Hromadko <yuriy@tokyoscale.com>
@ -187,3 +187,16 @@ Jason Moon <jmoon@socialcast.com>
Martin Frost <martinf55@hotmail.com> Martin Frost <martinf55@hotmail.com>
Eneko Illarramendi <eneko@illarra.com> Eneko Illarramendi <eneko@illarra.com>
EungJun Yi <semtlenori@gmail.com> EungJun Yi <semtlenori@gmail.com>
Courtland Allen <courtlandallen@gmail.com>
Viktar Varvanovich <non4eg@gmail.com>
Danny Trunk <dtrunk90@googlemail.com>
Pavel Stetina <pavel.stetina@nangu.tv>
Mike Stay <metaweta@gmail.com>
Steven Roussey <sroussey@gmail.com>
Mike Hollis <hollis21@gmail.com>
Lee Rowlands <lee.rowlands@previousnext.com.au>
Timmy Willison <timmywillisn@gmail.com>
Karl Swedberg <kswedberg@gmail.com>
Baoju Yuan <the_guy_1987@hotmail.com>
Maciej Mroziński <mrozik87@gmail.com>
Luis Dalmolin <luis.nh@gmail.com>

View File

@ -1,4 +1,5 @@
Copyright (c) 2012 Paul Bakaus, http://jqueryui.com/ Copyright 2012 jQuery Foundation and other contributors,
http://jqueryui.com/
This software consists of voluntary contributions made by many This software consists of voluntary contributions made by many
individuals (AUTHORS.txt, http://jqueryui.com/about) For exact individuals (AUTHORS.txt, http://jqueryui.com/about) For exact

67
build/core.json Normal file
View File

@ -0,0 +1,67 @@
{
"core": {
"description": "The core of jQuery UI, required for all interactions and widgets.",
"homepage": "http://jqueryui.com/",
"demo": "http://jqueryui.com/",
"docs": "http://api.jqueryui.com/category/ui-core/"
},
"datepicker": {
"description": "Displays a calendar from an input or inline for selecting dates.",
"dependencies": [ "core" ],
"keywords": [
"form",
"calendar",
"date",
"i18n"
],
"category": "widget"
},
"effect": {
"title": "jQuery UI Effects Core",
"description": "Extends the internal jQuery effects. Includes morphing and easing. Required by all other effects.",
"keywords": [
"animation",
"show",
"hide",
"color",
"class",
"transition",
"easing"
],
"category": "effect",
"homepage": "http://jqueryui.com/",
"demo": "http://jqueryui.com/effects/",
"docs": "http://api.jqueryui.com/category/effects-core/"
},
"position": {
"description": "Positions elements relative to other elements.",
"keywords": [
"offset",
"relative",
"absolute",
"fixed",
"collision"
]
},
"transfer": {
"name": "ui.effect-transfer",
"title": "jQuery UI Transfer Effect",
"description": "Displays a transfer effect from one element to another.",
"keywords": [
"effect"
],
"homepage": "http://jqueryui.com/transfer-effect/",
"demo": "http://jqueryui.com/transfer-effect/",
"docs": "http://api.jqueryui.com/transfer-effect/",
"dependencies": [ "effect" ],
"category": "effect"
},
"widget": {
"description": "Provides a factory for creating stateful widgets with a common API.",
"keywords": [
"abstraction",
"state",
"factory"
]
}
}

38
build/effect.json Normal file
View File

@ -0,0 +1,38 @@
{
"blind": {
"description": "Blinds the element."
},
"bounce": {
"description": "Bounces an element horizontally or vertically n times."
},
"clip": {
"description": "Clips the element on and off like an old TV."
},
"drop": {
"description": "Moves an element in one direction and hides it at the same time."
},
"explode": {
"description": "Explodes an element in all directions into n pieces. Implodes an element to its original wholeness."
},
"fade": {
"description": "Fades an element."
},
"fold": {
"description": "Folds an element first horizontally and then vertically."
},
"highlight": {
"description": "Highlights the background of an element in a defined color for a custom duration."
},
"pulsate": {
"description": "Pulsates an element n times by changing the opacity to zero and back."
},
"scale": {
"description": "Grows or shrinks an element and its content. Restores an elemnt to its original size."
},
"shake": {
"description": "Shakes an element horizontally or vertically n times."
},
"slide": {
"description": "Slides an element in and out of the viewport."
}
}

36
build/interaction.json Normal file
View File

@ -0,0 +1,36 @@
{
"draggable": {
"description": "Enables dragging functionality for any element.",
"keywords": [
"drag",
"drop"
]
},
"droppable": {
"dependencies": [ "draggable" ],
"description": "Enables drop targets for draggable elements.",
"keywords": [
"drag",
"drop"
]
},
"resizable": {
"description": "Enables resize functionality for any element.",
"keywords": [
"resize"
]
},
"selectable": {
"description": "Allows groups of elements to be selected with the mouse.",
"keywords": [
"selection"
]
},
"sortable": {
"description": "Enables items in a list to be sorted using the mouse.",
"keywords": [
"sort",
"list"
]
}
}

View File

@ -1,336 +0,0 @@
#!/bin/sh
base_dir="`pwd`/jquery-ui-release"
repo_dir="$base_dir/jquery-ui"
release_dir="$repo_dir/build/release"
github_repo="git@github.com:jquery/jquery-ui.git"
remote_cmd="ssh jqadmin@ui-dev.jquery.com /srv/dev.jqueryui.com/prepare-release"
#
# Setup environment
#
echo
echo "--------------------------"
echo "| SETTING UP ENVIRONMENT |"
echo "--------------------------"
echo
mkdir $base_dir
cd $base_dir
echo "Cloning repo from $github_repo..."
git clone $github_repo
cd $repo_dir
echo
echo "Environment setup complete."
echo
#
# Figure out which versions we're dealing with
#
echo
echo "------------------------"
echo "| CALCULATING VERSIONS |"
echo "------------------------"
echo
# NOTE: this will be different for minor and major releases
version=`$remote_cmd/get-latest-version`
major_minor=${version%.*}
point=${version##*.}
version_new="${major_minor}.$(($point + 1))"
version_next=`cat version.txt`
echo "We are going from $version to $version_new."
echo "version.txt will be set to $version_next when complete."
echo "Press enter to continue, or ctrl+c to cancel."
read
#
# Generate shell for changelog
#
echo
echo "------------------------"
echo "| GENERATING CHANGELOG |"
echo "------------------------"
echo
echo "Creating shell for changelog..."
changelog_url="http:\/\/docs.jquery.com\/action\/edit\/UI\/Changelog\/$version_new"
`sed "s/CHANGELOG_URL/$changelog_url/" <$release_dir/changelog-shell >$base_dir/changelog`
# find all commits
echo "Adding commits to changelog..."
format_ticket='[http://dev.jqueryui.com/ticket/XXXX #XXXX]'
format_commit='[http://github.com/jquery/jquery-ui/commit/%H %h]'
format_full="* %s ($format_ticket, $format_commit)"
git whatchanged $version... --pretty=format:"$format_full" \
-- ui themes demos build \
| sed '/^:/ d' \
| sed '/^$/ d' \
| sed 's/\(Fixe[sd] #\)\([0-9][0-9]*\)\(.*\)\(XXXX #XXXX\)/Fixed #\2\3\2 #\2/' \
| LC_ALL='C' sort -f \
>> $base_dir/changelog
# find all fixed tickets
echo "Adding Trac tickets to changelog..."
$remote_cmd/generate-changelog >> $base_dir/changelog
echo
echo "Changelog complete."
echo
#
# Generate list of contributors
#
echo
echo "--------------------------"
echo "| GATHERING CONTRIBUTORS |"
echo "--------------------------"
echo
# find all committers and authors
echo "Adding commiters and authors..."
format_contributors='%aN%n%cN'
git whatchanged $version... --pretty=format:"$format_contributors" \
| sed '/^:/ d' \
| sed '/^$/ d' \
> $base_dir/thankyou
# find all reporters and commenters from Trac
echo "Adding reporters and commenters from Trac..."
$remote_cmd/generate-contributors >> $base_dir/thankyou
# sort names
echo "Sorting contributors..."
LC_ALL='C' sort -f $base_dir/thankyou | uniq > $base_dir/_thankyou
mv $base_dir/_thankyou $base_dir/thankyou
# find all people that were thanked
echo "Adding people thanked in commits..."
git whatchanged $version... \
| grep -i thank \
>> $base_dir/thankyou
echo
echo "Find contributors from duplicates of fixed tickets and add them to:"
echo "$base_dir/thankyou"
echo "Press enter when done."
read
echo
echo "Contributors list complete."
echo
#
# Update version
#
echo
echo "--------------------"
echo "| UPDATING VERSION |"
echo "--------------------"
echo
echo "Updating version.txt to $version_new..."
echo $version_new > version.txt
git commit -a -m "Tagging the $version_new release."
version_new_time=`git log -1 --pretty=format:"%ad"`
echo "Committed version.txt at $version_new_time..."
echo "Tagging $version_new..."
git tag $version_new
echo "Updating version.txt to $version_next..."
echo $version_next > version.txt
git commit -a -m "Updating the master version to $version_next"
echo "Committed version.txt..."
echo
echo "Version update complete."
echo
#
# Push to GitHub
#
echo
echo "---------------------"
echo "| PUSHING TO GITHUB |"
echo "---------------------"
echo
echo "Please review the output and generated files as a sanity check."
echo "Press enter to continue or ctrl+c to abort."
read
git push
git push --tags
echo
echo "Push to GitHub complete."
echo
#
# Update Trac
#
echo
echo "-----------------"
echo "| UPDATING TRAC |"
echo "-----------------"
echo
# TODO: automate this
# NOTE: this will be different for minor and major releases
milestone=`$remote_cmd/get-latest-milestone`
# Create new milestrone and version
echo "$version_new was tagged at $version_new_time."
echo "Create and close the $version_new Milestone with the above date and time."
echo "Create the $version_new Version with the above date and time."
echo "Press enter when done."
read
# Update milestone for all fixed tickets
echo "Change all $milestone fixed tickets to $version_new."
echo "Press enter when done."
read
echo
echo "Trac updates complete."
echo
#
# Build jQuery UI
#
echo
echo "----------------------"
echo "| BUILDING JQUERY UI |"
echo "----------------------"
echo
# check out the tagged version
echo "Checking out $version_new..."
git checkout $version_new
cd build
# Update the link to the docs (never contains the patch version)
echo "Updating URL for API docs..."
sed "s/UI\/API\/\${release\.version}/UI\/API\/$major_minor/" build.xml >build.xml.tmp
mv build.xml.tmp build.xml
# Run the build
echo "Running build..."
ant
echo
echo "Build complete."
echo
#
# Upload zip to Google Code
#
echo
echo "----------------------"
echo "| UPDATE GOOGLE CODE |"
echo "----------------------"
echo
echo "Upload zip to Google Code."
echo " http://code.google.com/p/jquery-ui/downloads/entry"
echo " Summary: jQuery UI $version_new (Source, demos, docs, themes, tests) STABLE"
echo " Labels: Featured, Type-Source, OpSys-All"
echo "Modify the previous release to no longer say STABLE at the end."
echo "Remove the featured label from the previous release."
echo "Press enter when done."
read
echo
echo "Google Code update complete."
echo
#
# Update SVN
#
echo
echo "----------------"
echo "| UPDATING SVN |"
echo "----------------"
echo
cd $base_dir
mkdir svn
cd svn
echo "Checking out SVN tags..."
svn co --depth immediates https://jquery-ui.googlecode.com/svn/tags
cd tags
echo "Unzipping build into tags/$version_new..."
unzip $repo_dir/build/dist/jquery-ui-$version_new.zip
mv jquery-ui-$version_new $version_new
echo "Adding files to SVN..."
svn add $version_new
echo "Setting svn:mime-type..."
find $version_new -name \*.js -exec svn propset svn:mime-type text/javascript {} \;
find $version_new -name \*.css -exec svn propset svn:mime-type text/css {} \;
find $version_new -name \*.html -exec svn propset svn:mime-type text/html {} \;
find $version_new -name \*.png -exec svn propset svn:mime-type image/png {} \;
find $version_new -name \*.gif -exec svn propset svn:mime-type image/gif {} \;
# TODO: commit
echo
echo "svn commit with the following message:"
echo "Created $version_new tag from http://jquery-ui.googlecode.com/files/jquery-ui-$version_new.zip"
echo "Press enter when done."
read
echo
echo "SVN update complete."
echo
#
# Generate themes
#
# ruby -e 'puts File.read("thankyou").split("\n").join(", ")' > thankyou2

400
build/release/release.js Normal file
View File

@ -0,0 +1,400 @@
#!/usr/bin/env node
var baseDir, repoDir, prevVersion, newVersion, nextVersion, tagTime,
fs = require( "fs" ),
path = require( "path" ),
// support: node <0.8
existsSync = fs.existsSync || path.existsSync,
rnewline = /\r?\n/,
repo = "git@github.com:jquery/jquery-ui.git",
branch = "master";
walk([
bootstrap,
section( "setting up repo" ),
cloneRepo,
checkState,
section( "calculating versions" ),
getVersions,
confirm,
section( "building release" ),
buildRelease,
section( "pushing tag" ),
confirmReview,
pushRelease,
section( "updating branch version" ),
updateBranchVersion,
section( "pushing " + branch ),
confirmReview,
pushBranch,
section( "generating changelog" ),
generateChangelog,
section( "gathering contributors" ),
gatherContributors,
section( "updating trac" ),
updateTrac,
confirm
]);
function cloneRepo() {
echo( "Cloning " + repo.cyan + "..." );
git( "clone " + repo + " " + repoDir, "Error cloning repo." );
cd( repoDir );
echo( "Checking out " + branch.cyan + " branch..." );
git( "checkout " + branch, "Error checking out branch." );
echo();
echo( "Installing dependencies..." );
if ( exec( "npm install" ).code !== 0 ) {
abort( "Error installing dependencies." );
}
echo();
}
function checkState() {
echo( "Checking AUTHORS.txt..." );
var result, lastActualAuthor,
lastListedAuthor = cat( "AUTHORS.txt" ).trim().split( rnewline ).pop();
result = exec( "grunt authors", { silent: true });
if ( result.code !== 0 ) {
abort( "Error getting list of authors." );
}
lastActualAuthor = result.output.split( rnewline ).splice( -4, 1 )[ 0 ];
if ( lastListedAuthor !== lastActualAuthor ) {
echo( "Last listed author is " + lastListedAuthor.red + "." );
echo( "Last actual author is " + lastActualAuthor.green + "." );
abort( "Please update AUTHORS.txt." );
}
echo( "Last listed author (" + lastListedAuthor.cyan + ") is correct." );
}
function getVersions() {
// prevVersion, newVersion, nextVersion are defined in the parent scope
var parts, major, minor, patch,
currentVersion = readPackage().version;
echo( "Validating current version..." );
if ( currentVersion.substr( -3, 3 ) !== "pre" ) {
echo( "The current version is " + currentVersion.red + "." );
abort( "The version must be a pre version." );
}
newVersion = currentVersion.substr( 0, currentVersion.length - 3 );
parts = newVersion.split( "." );
major = parseInt( parts[ 0 ], 10 );
minor = parseInt( parts[ 1 ], 10 );
patch = parseInt( parts[ 2 ], 10 );
// TODO: handle 2.0.0
if ( minor === 0 ) {
abort( "This script is not smart enough to handle the 2.0.0 release." );
}
prevVersion = patch === 0 ?
[ major, minor - 1, 0 ].join( "." ) :
[ major, minor, patch - 1 ].join( "." );
// TODO: Remove version hack after 1.9.0 release
if ( prevVersion === "1.8.0" ) {
prevVersion = "1.8";
}
nextVersion = [ major, minor, patch + 1 ].join( "." ) + "pre";
echo( "We are going from " + prevVersion.cyan + " to " + newVersion.cyan + "." );
echo( "After the release, the version will be " + nextVersion.cyan + "." );
}
function buildRelease() {
var pkg;
echo( "Creating " + "release".cyan + " branch..." );
git( "checkout -b release", "Error creating release branch." );
echo();
echo( "Updating package.json..." );
pkg = readPackage();
pkg.version = newVersion;
pkg.licenses.forEach(function( license ) {
license.url = license.url.replace( "master", newVersion );
});
writePackage( pkg );
echo( "Generating manifest files..." );
if ( exec( "grunt manifest" ).code !== 0 ) {
abort( "Error generating manifest files." );
}
echo();
echo( "Building release..." );
if ( exec( "grunt release" ).code !== 0 ) {
abort( "Error building release." );
}
echo();
// TODO: Build themes
// TODO: Move build out of dist/
echo( "Committing release artifacts..." );
git( "add *.jquery.json", "Error adding manifest files to git." );
// TODO: Add built files
git( "commit -am 'Tagging the " + newVersion + " release.'",
"Error committing release changes." );
echo();
echo( "Tagging release..." );
git( "tag " + newVersion, "Error tagging " + newVersion + "." );
tagTime = git( "log -1 --format='%ad'", "Error getting tag timestamp." ).trim();
}
function pushRelease() {
echo( "Pushing release to GitHub..." );
git( "push --tags", "Error pushing tags to GitHub." );
}
function updateBranchVersion() {
var pkg;
echo( "Checking out " + branch.cyan + " branch..." );
git( "checkout " + branch, "Error checking out " + branch + " branch." );
echo( "Updating package.json..." );
pkg = readPackage();
pkg.version = nextVersion;
writePackage( pkg );
echo( "Committing version update..." );
git( "commit -am 'Updating the " + branch + " version to " + nextVersion + ".'",
"Error committing package.json." );
}
function pushBranch() {
echo( "Pushing " + branch.cyan + " to GitHub..." );
git( "push", "Error pushing to GitHub." );
}
function generateChangelog() {
var commits,
changelogPath = baseDir + "/changelog",
changelog = cat( "build/release/changelog-shell" ) + "\n",
fullFormat = "* %s (TICKETREF, [http://github.com/jquery/jquery-ui/commit/%H %h])";
echo ( "Adding commits..." );
commits = gitLog( fullFormat );
echo( "Adding links to tickets..." );
changelog += commits
// Add ticket references
.map(function( commit ) {
var tickets = [];
commit.replace( /Fixe[sd] #(\d+)/g, function( match, ticket ) {
tickets.push( ticket );
});
return tickets.length ?
commit.replace( "TICKETREF", tickets.map(function( ticket ) {
return "[http://bugs.jqueryui.com/ticket/" + ticket + " #" + ticket + "]";
}).join( ", " ) ) :
// Leave TICKETREF token in place so it's easy to find commits without tickets
commit;
})
// Sort commits so that they're grouped by component
.sort()
.join( "\n" ) + "\n";
echo( "Adding Trac tickets..." );
changelog += trac( "/query?milestone=" + newVersion + "&resolution=fixed" +
"&col=id&col=component&col=summary&order=component" ) + "\n";
fs.writeFileSync( changelogPath, changelog );
echo( "Stored changelog in " + changelogPath.cyan + "." );
}
function gatherContributors() {
var contributors,
contributorsPath = baseDir + "/contributors";
echo( "Adding committers and authors..." );
contributors = gitLog( "%aN%n%cN" );
echo( "Adding reporters and commenters from Trac..." );
contributors = contributors.concat(
trac( "/report/22?V=" + newVersion + "&max=-1" )
.split( rnewline )
// Remove header and trailing newline
.slice( 1, -1 ) );
echo( "Sorting contributors..." );
contributors = unique( contributors ).sort(function( a, b ) {
return a.toLowerCase() < b.toLowerCase() ? -1 : 1;
});
echo ( "Adding people thanked in commits..." );
contributors = contributors.concat(
gitLog( "%b%n%s" ).filter(function( line ) {
return /thank/i.test( line );
}));
fs.writeFileSync( contributorsPath, contributors.join( "\n" ) );
echo( "Stored contributors in " + contributorsPath.cyan + "." );
}
function updateTrac() {
echo( newVersion.cyan + " was tagged at " + tagTime.cyan + "." );
echo( "Close the " + newVersion.cyan + " Milestone with the above date and time." );
echo( "Create the " + newVersion.cyan + " Version with the above date and time." );
echo( "Create a Milestone for the next minor release." );
}
// ===== HELPER FUNCTIONS ======================================================
function git( command, errorMessage ) {
var result = exec( "git " + command );
if ( result.code !== 0 ) {
abort( errorMessage );
}
return result.output;
}
function gitLog( format ) {
var result = exec( "git log " + prevVersion + ".." + newVersion + " " +
"--format='" + format + "'",
{ silent: true });
if ( result.code !== 0 ) {
abort( "Error getting git log." );
}
result = result.output.split( rnewline );
if ( result[ result.length - 1 ] === "" ) {
result.pop();
}
return result;
}
function trac( path ) {
var result = exec( "curl -s 'http://bugs.jqueryui.com" + path + "&format=tab'",
{ silent: true });
if ( result.code !== 0 ) {
abort( "Error getting Trac data." );
}
return result.output;
}
function unique( arr ) {
var obj = {};
arr.forEach(function( item ) {
obj[ item ] = 1;
});
return Object.keys( obj );
}
function readPackage() {
return JSON.parse( fs.readFileSync( repoDir + "/package.json" ) );
}
function writePackage( pkg ) {
fs.writeFileSync( repoDir + "/package.json",
JSON.stringify( pkg, null, "\t" ) + "\n" );
}
function bootstrap( fn ) {
console.log( "Determining directories..." );
baseDir = process.cwd() + "/__release";
repoDir = baseDir + "/repo";
if ( existsSync( baseDir ) ) {
console.log( "The directory '" + baseDir + "' already exists." );
console.log( "Aborting." );
process.exit( 1 );
}
console.log( "Creating directory..." );
fs.mkdirSync( baseDir );
console.log( "Installing dependencies..." );
require( "child_process" ).exec( "npm install shelljs colors", {
cwd: baseDir
}, function( error ) {
if ( error ) {
console.log( error );
return process.exit( 1 );
}
require( baseDir + "/node_modules/shelljs/global" );
require( baseDir + "/node_modules/colors" );
fn();
});
}
function section( name ) {
return function() {
echo();
echo( "##" );
echo( "## " + name.toUpperCase().magenta );
echo( "##" );
echo();
};
}
function prompt( fn ) {
process.stdin.once( "data", function( chunk ) {
process.stdin.pause();
fn( chunk.toString().trim() );
});
process.stdin.resume();
}
function confirm( fn ) {
echo( "Press enter to continue, or ctrl+c to cancel.".yellow );
prompt( fn );
}
function confirmReview( fn ) {
echo( "Please review the output and generated files as a sanity check.".yellow );
confirm( fn );
}
function abort( msg ) {
echo( msg.red );
echo( "Aborting.".red );
exit( 1 );
}
function walk( methods ) {
var method = methods.shift();
function next( error ) {
if ( methods.length ) {
walk( methods );
}
}
if ( !method.length ) {
method();
next();
} else {
method( next );
}
}

267
build/tasks/build.js Normal file
View File

@ -0,0 +1,267 @@
module.exports = function( grunt ) {
var path = require( "path" );
grunt.registerTask( "manifest", "Generate jquery.json manifest files", function() {
var pkg = grunt.config( "pkg" ),
base = {
core: {
name: "ui.{plugin}",
title: "jQuery UI {Plugin}"
},
widget: {
name: "ui.{plugin}",
title: "jQuery UI {Plugin}",
dependencies: [ "core", "widget" ]
},
interaction: {
name: "ui.{plugin}",
title: "jQuery UI {Plugin}",
dependencies: [ "core", "widget", "mouse" ]
},
effect: {
name: "ui.effect-{plugin}",
title: "jQuery UI {Plugin} Effect",
keywords: [ "effect", "show", "hide" ],
homepage: "http://jqueryui.com/{plugin}-effect/",
demo: "http://jqueryui.com/{plugin}-effect/",
docs: "http://api.jqueryui.com/{plugin}-effect/",
dependencies: [ "effect" ]
}
};
Object.keys( base ).forEach(function( type ) {
var baseManifest = base[ type ],
plugins = grunt.file.readJSON( "build/" + type + ".json" );
Object.keys( plugins ).forEach(function( plugin ) {
var manifest,
data = plugins[ plugin ],
name = plugin.charAt( 0 ).toUpperCase() + plugin.substr( 1 );
function replace( str ) {
return str.replace( "{plugin}", plugin ).replace( "{Plugin}", name );
}
manifest = {
name: data.name || replace( baseManifest.name ),
title: data.title || replace( baseManifest.title ),
description: data.description,
keywords: [ "ui", plugin ]
.concat( baseManifest.keywords || [] )
.concat( data.keywords || [] ),
version: pkg.version,
author: pkg.author,
maintainers: pkg.maintainers,
licenses: pkg.licenses,
bugs: pkg.bugs,
homepage: data.homepage || replace( baseManifest.homepage ||
"http://jqueryui.com/{plugin}/" ),
demo: data.demo || replace( baseManifest.demo ||
"http://jqueryui.com/{plugin}/" ),
docs: data.docs || replace( baseManifest.docs ||
"http://api.jqueryui.com/{plugin}/" ),
download: "http://jqueryui.com/download/",
dependencies: {
jquery: ">=1.6"
},
// custom
category: data.category || type
};
(baseManifest.dependencies || [])
.concat(data.dependencies || [])
.forEach(function( dependency ) {
manifest.dependencies[ "ui." + dependency ] = pkg.version;
});
grunt.file.write( manifest.name + ".jquery.json",
JSON.stringify( manifest, null, "\t" ) + "\n" );
});
});
});
grunt.registerMultiTask( "copy", "Copy files to destination folder and replace @VERSION with pkg.version", function() {
function replaceVersion( source ) {
return source.replace( /@VERSION/g, grunt.config( "pkg.version" ) );
}
function copyFile( src, dest ) {
if ( /(js|css)$/.test( src ) ) {
grunt.file.copy( src, dest, {
process: replaceVersion
});
} else {
grunt.file.copy( src, dest );
}
}
var files = grunt.file.expandFiles( this.file.src ),
target = this.file.dest + "/",
strip = this.data.strip,
renameCount = 0,
fileName;
if ( typeof strip === "string" ) {
strip = new RegExp( "^" + grunt.template.process( strip, grunt.config() ).replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ) );
}
files.forEach(function( fileName ) {
var targetFile = strip ? fileName.replace( strip, "" ) : fileName;
copyFile( fileName, target + targetFile );
});
grunt.log.writeln( "Copied " + files.length + " files." );
for ( fileName in this.data.renames ) {
renameCount += 1;
copyFile( fileName, target + grunt.template.process( this.data.renames[ fileName ], grunt.config() ) );
}
if ( renameCount ) {
grunt.log.writeln( "Renamed " + renameCount + " files." );
}
});
grunt.registerMultiTask( "zip", "Create a zip file for release", function() {
// TODO switch back to adm-zip for better cross-platform compability once it actually works
// 0.1.3 works, but result can't be unzipped
// its also a lot slower then zip program, probably due to how its used...
// var files = grunt.file.expandFiles( "dist/" + this.file.src + "/**/*" );
// grunt.log.writeln( "Creating zip file " + this.file.dest );
//var AdmZip = require( "adm-zip" );
//var zip = new AdmZip();
//files.forEach(function( file ) {
// grunt.verbose.writeln( "Zipping " + file );
// // rewrite file names from dist folder (created by build), drop the /dist part
// zip.addFile(file.replace(/^dist/, "" ), fs.readFileSync( file ) );
//});
//zip.writeZip( "dist/" + this.file.dest );
//grunt.log.writeln( "Wrote " + files.length + " files to " + this.file.dest );
var done = this.async(),
dest = this.file.dest,
src = grunt.template.process( this.file.src, grunt.config() );
grunt.utils.spawn({
cmd: "zip",
args: [ "-r", dest, src ],
opts: {
cwd: 'dist'
}
}, function( err, result ) {
if ( err ) {
grunt.log.error( err );
done();
return;
}
grunt.log.writeln( "Zipped " + dest );
done();
});
});
grunt.registerMultiTask( "md5", "Create list of md5 hashes for CDN uploads", function() {
// remove dest file before creating it, to make sure itself is not included
if ( path.existsSync( this.file.dest ) ) {
fs.unlinkSync( this.file.dest );
}
var crypto = require( "crypto" ),
dir = this.file.src + "/",
hashes = [];
grunt.file.expandFiles( dir + "**/*" ).forEach(function( fileName ) {
var hash = crypto.createHash( "md5" );
hash.update( grunt.file.read( fileName, "ascii" ) );
hashes.push( fileName.replace( dir, "" ) + " " + hash.digest( "hex" ) );
});
grunt.file.write( this.file.dest, hashes.join( "\n" ) + "\n" );
grunt.log.writeln( "Wrote " + this.file.dest + " with " + hashes.length + " hashes" );
});
// only needed for 1.8
grunt.registerTask( "download_docs", function() {
function capitalize(value) {
return value[0].toUpperCase() + value.slice(1);
}
// should be grunt.config("pkg.version")?
var version = "1.8",
docsDir = "dist/docs",
files = "draggable droppable resizable selectable sortable accordion autocomplete button datepicker dialog progressbar slider tabs position"
.split(" ").map(function(widget) {
return {
url: "http://docs.jquery.com/action/render/UI/API/" + version + "/" + capitalize(widget),
dest: docsDir + '/' + widget + '.html'
};
});
files = files.concat("animate addClass effect hide removeClass show switchClass toggle toggleClass".split(" ").map(function(widget) {
return {
url: "http://docs.jquery.com/action/render/UI/Effects/" + widget,
dest: docsDir + '/' + widget + '.html'
};
}));
files = files.concat("Blind Clip Drop Explode Fade Fold Puff Slide Scale Bounce Highlight Pulsate Shake Size Transfer".split(" ").map(function(widget) {
return {
url: "http://docs.jquery.com/action/render/UI/Effects/" + widget,
dest: docsDir + '/effect-' + widget.toLowerCase() + '.html'
};
}));
grunt.file.mkdir( "dist/docs" );
grunt.utils.async.forEach( files, function( file, done ) {
var out = fs.createWriteStream( file.dest );
out.on( "close", done );
request( file.url ).pipe( out );
}, this.async() );
});
grunt.registerTask( "download_themes", function() {
// var AdmZip = require('adm-zip');
var done = this.async(),
themes = grunt.file.read( "build/themes" ).split(","),
requests = 0;
grunt.file.mkdir( "dist/tmp" );
themes.forEach(function( theme, index ) {
requests += 1;
grunt.file.mkdir( "dist/tmp/" + index );
var zipFileName = "dist/tmp/" + index + ".zip",
out = fs.createWriteStream( zipFileName );
out.on( "close", function() {
grunt.log.writeln( "done downloading " + zipFileName );
// TODO AdmZip produces "crc32 checksum failed", need to figure out why
// var zip = new AdmZip(zipFileName);
// zip.extractAllTo('dist/tmp/' + index + '/');
// until then, using cli unzip...
grunt.utils.spawn({
cmd: "unzip",
args: [ "-d", "dist/tmp/" + index, zipFileName ]
}, function( err, result ) {
grunt.log.writeln( "Unzipped " + zipFileName + ", deleting it now" );
fs.unlinkSync( zipFileName );
requests -= 1;
if (requests === 0) {
done();
}
});
});
request( "http://ui-dev.jquery.com/download/?" + theme ).pipe( out );
});
});
grunt.registerTask( "copy_themes", function() {
// each package includes the base theme, ignore that
var filter = /themes\/base/,
files = grunt.file.expandFiles( "dist/tmp/*/development-bundle/themes/**/*" ).filter(function( file ) {
return !filter.test( file );
}),
// TODO the grunt.template.process call shouldn't be necessary
target = "dist/" + grunt.template.process( grunt.config( "files.themes" ), grunt.config() ) + "/",
distFolder = "dist/" + grunt.template.process( grunt.config( "files.dist" ), grunt.config() );
files.forEach(function( fileName ) {
var targetFile = fileName.replace( /dist\/tmp\/\d+\/development-bundle\//, "" ).replace( "jquery-ui-.custom", "jquery-ui" );
grunt.file.copy( fileName, target + targetFile );
});
// copy minified base theme from regular release
files = grunt.file.expandFiles( distFolder + "/themes/base/**/*" );
files.forEach(function( fileName ) {
grunt.file.copy( fileName, target + fileName.replace( distFolder, "" ) );
});
});
grunt.registerTask( "clean", function() {
require( "rimraf" ).sync( "dist" );
});
};

79
build/tasks/testswarm.js Normal file
View File

@ -0,0 +1,79 @@
/*jshint node: true */
module.exports = function( grunt ) {
var versions = {
"git": "git",
"1.7": "1.7 1.7.1 1.7.2",
"1.6": "1.6 1.6.1 1.6.2 1.6.3 1.6.4"
},
tests = {
"Accordion": "accordion/accordion.html",
"Accordion_deprecated": "accordion/accordion_deprecated.html",
"Autocomplete": "autocomplete/autocomplete.html",
"Button": "button/button.html",
"Core": "core/core.html",
//"datepicker/datepicker.html",
//"dialog/dialog.html",
//"draggable/draggable.html",
//"droppable/droppable.html",
"Effects": "effects/effects.html",
"Menu": "menu/menu.html",
"Position": "position/position.html",
"Position_deprecated": "position/position_deprecated.html",
"Progressbar": "progressbar/progressbar.html",
//"resizable/resizable.html",
//"selectable/selectable.html",
//"slider/slider.html",
//"sortable/sortable.html",
"Spinner": "spinner/spinner.html",
"Tabs": "tabs/tabs.html",
"Tabs_deprecated": "tabs/tabs_deprecated.html",
"Tooltip": "tooltip/tooltip.html",
"Widget": "widget/widget.html"
};
function submit( commit, tests, configFile, version, done ) {
var test,
testswarm = require( "testswarm" ),
config = grunt.file.readJSON( configFile ).jqueryui,
testBase = config.testUrl + commit + "/tests/unit/",
testUrls = [];
for ( test in tests ) {
testUrls.push( testBase + tests[ test ] );
}
testswarm({
url: config.swarmUrl,
pollInterval: 10000,
timeout: 1000 * 60 * 30,
done: done
}, {
authUsername: config.authUsername,
authToken: config.authToken,
jobName: 'jQuery UI ' + version + '<a href="https://github.com/jquery/jquery-ui/commit/' + commit + '">' + commit.substr( 0, 7 ) + '</a>',
runMax: config.runMax,
"runNames[]": Object.keys(tests),
"runUrls[]": testUrls,
"browserSets[]": ["popular"]
});
}
grunt.registerTask( "testswarm", function( commit, configFile ) {
var test,
latestTests = {};
for ( test in tests ) {
latestTests[ test ] = tests[ test ] + "?nojshint=true";
}
submit( commit, latestTests, configFile, "", this.async() );
});
grunt.registerTask( "testswarm-multi-jquery", function( commit, configFile, minor ) {
var allTests = {};
versions[ minor ].split(" ").forEach(function( version ) {
for ( var test in tests ) {
allTests[ test + "-" + version ] = tests[ test ] + "?nojshint=true&jquery=" + version;
}
});
submit( commit, allTests, configFile, minor + " core ", this.async() );
});
};

98
build/widget.json Normal file
View File

@ -0,0 +1,98 @@
{
"accordion": {
"dependencies": [],
"description": "Displays collapsible content panels for presenting information in a limited amount of space.",
"keywords": [
"navigation",
"panel",
"collapse",
"expand"
]
},
"autocomplete": {
"dependencies": [ "menu", "position" ],
"description": "Lists suggested words as the user is typing.",
"keywords": [
"form",
"word",
"predict",
"suggest"
]
},
"button": {
"dependencies": [],
"description": "Enhances a form with themable buttons.",
"keywords": [
"form",
"radio",
"checkbox"
]
},
"dialog": {
"dependencies": [ "button", "draggable", "position", "resizable" ],
"description": "Displays customizable dialog windows.",
"keywords": [
"modal",
"alert",
"popup"
]
},
"menu": {
"dependencies": [ "position" ],
"description": "Creates nestable menus.",
"keywords": [
"dropdown",
"flyout"
]
},
"mouse": {
"dependencies": [],
"description": "Abstracts mouse-based interactions to assist in creating certain widgets.",
"keywords": [
"abstraction"
],
"category": "core"
},
"progressbar": {
"dependencies": [],
"description": "Displays a status indicator for loading state, standard percentage, and other progress indicators.",
"keywords": [
"determinate",
"status"
]
},
"slider": {
"dependencies": [ "mouse" ],
"description": "Displays a flexible slider with ranges and accessibility via keyboard.",
"keywords": [
"form",
"number",
"range"
]
},
"spinner": {
"dependencies": [ "button" ],
"description": "Displays buttons to easily input numbers via the keyboard or mouse.",
"keywords": [
"form",
"number",
"spinbutton",
"stepper"
]
},
"tabs": {
"dependencies": [],
"description": "Transforms a set of container elements into a tab structure.",
"keywords": [
"navigation",
"panel",
"collapse",
"expand"
]
},
"tooltip": {
"dependencies": [ "position" ],
"description": "Shows additional information for any element on hover or focus.",
"keywords": []
}
}

View File

@ -5,7 +5,7 @@
<title>jQuery UI Effects - addClass demo</title> <title>jQuery UI Effects - addClass demo</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.7.2.js"></script> <script src="../../jquery-1.7.2.js"></script>
<script src="../../ui/jquery.effects.core.js"></script> <script src="../../ui/jquery.ui.effect.js"></script>
<link rel="stylesheet" href="../demos.css"> <link rel="stylesheet" href="../demos.css">
<style> <style>
.toggler { width: 500px; height: 200px; position: relative; } .toggler { width: 500px; height: 200px; position: relative; }

View File

@ -5,7 +5,7 @@
<title>jQuery UI Effects - Animate demo</title> <title>jQuery UI Effects - Animate demo</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.7.2.js"></script> <script src="../../jquery-1.7.2.js"></script>
<script src="../../ui/jquery.effects.core.js"></script> <script src="../../ui/jquery.ui.effect.js"></script>
<link rel="stylesheet" href="../demos.css"> <link rel="stylesheet" href="../demos.css">
<style> <style>
.toggler { width: 500px; height: 200px; position: relative; } .toggler { width: 500px; height: 200px; position: relative; }

View File

@ -7,13 +7,13 @@
<script src="../../jquery-1.7.2.js"></script> <script src="../../jquery-1.7.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.effects.core.js"></script> <script src="../../ui/jquery.ui.effect.js"></script>
<script src="../../ui/jquery.effects.blind.js"></script> <script src="../../ui/jquery.ui.effect-blind.js"></script>
<script src="../../ui/jquery.effects.bounce.js"></script> <script src="../../ui/jquery.ui.effect-bounce.js"></script>
<script src="../../ui/jquery.effects.clip.js"></script> <script src="../../ui/jquery.ui.effect-clip.js"></script>
<script src="../../ui/jquery.effects.drop.js"></script> <script src="../../ui/jquery.ui.effect-drop.js"></script>
<script src="../../ui/jquery.effects.fold.js"></script> <script src="../../ui/jquery.ui.effect-fold.js"></script>
<script src="../../ui/jquery.effects.slide.js"></script> <script src="../../ui/jquery.ui.effect-slide.js"></script>
<script src="../../ui/jquery.ui.datepicker.js"></script> <script src="../../ui/jquery.ui.datepicker.js"></script>
<link rel="stylesheet" href="../demos.css"> <link rel="stylesheet" href="../demos.css">
<script> <script>

View File

@ -32,7 +32,6 @@
<script src="../../ui/i18n/jquery.ui.datepicker-fo.js"></script> <script src="../../ui/i18n/jquery.ui.datepicker-fo.js"></script>
<script src="../../ui/i18n/jquery.ui.datepicker-fr.js"></script> <script src="../../ui/i18n/jquery.ui.datepicker-fr.js"></script>
<script src="../../ui/i18n/jquery.ui.datepicker-fr-CH.js"></script> <script src="../../ui/i18n/jquery.ui.datepicker-fr-CH.js"></script>
<script src="../../ui/i18n/jquery.ui.datepicker-ge.js"></script>
<script src="../../ui/i18n/jquery.ui.datepicker-gl.js"></script> <script src="../../ui/i18n/jquery.ui.datepicker-gl.js"></script>
<script src="../../ui/i18n/jquery.ui.datepicker-he.js"></script> <script src="../../ui/i18n/jquery.ui.datepicker-he.js"></script>
<script src="../../ui/i18n/jquery.ui.datepicker-hi.js"></script> <script src="../../ui/i18n/jquery.ui.datepicker-hi.js"></script>
@ -43,6 +42,7 @@
<script src="../../ui/i18n/jquery.ui.datepicker-is.js"></script> <script src="../../ui/i18n/jquery.ui.datepicker-is.js"></script>
<script src="../../ui/i18n/jquery.ui.datepicker-it.js"></script> <script src="../../ui/i18n/jquery.ui.datepicker-it.js"></script>
<script src="../../ui/i18n/jquery.ui.datepicker-ja.js"></script> <script src="../../ui/i18n/jquery.ui.datepicker-ja.js"></script>
<script src="../../ui/i18n/jquery.ui.datepicker-ka.js"></script>
<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>

View File

@ -13,9 +13,9 @@
<script src="../../ui/jquery.ui.position.js"></script> <script src="../../ui/jquery.ui.position.js"></script>
<script src="../../ui/jquery.ui.resizable.js"></script> <script src="../../ui/jquery.ui.resizable.js"></script>
<script src="../../ui/jquery.ui.dialog.js"></script> <script src="../../ui/jquery.ui.dialog.js"></script>
<script src="../../ui/jquery.effects.core.js"></script> <script src="../../ui/jquery.ui.effect.js"></script>
<script src="../../ui/jquery.effects.blind.js"></script> <script src="../../ui/jquery.ui.effect-blind.js"></script>
<script src="../../ui/jquery.effects.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 // increase the default animation speed to exaggerate the effect

View File

@ -14,7 +14,7 @@
<script src="../../ui/jquery.ui.position.js"></script> <script src="../../ui/jquery.ui.position.js"></script>
<script src="../../ui/jquery.ui.resizable.js"></script> <script src="../../ui/jquery.ui.resizable.js"></script>
<script src="../../ui/jquery.ui.dialog.js"></script> <script src="../../ui/jquery.ui.dialog.js"></script>
<script src="../../ui/jquery.effects.core.js"></script> <script src="../../ui/jquery.ui.effect.js"></script>
<link rel="stylesheet" href="../demos.css"> <link rel="stylesheet" href="../demos.css">
<style> <style>
body { font-size: 62.5%; } body { font-size: 62.5%; }

View File

@ -16,7 +16,7 @@
<style> <style>
h1 { padding: .2em; margin: 0; } h1 { padding: .2em; margin: 0; }
#products { float:left; width: 500px; margin-right: 2em; } #products { float:left; width: 500px; margin-right: 2em; }
#cart { width: 200px; float: left; } #cart { width: 200px; float: left; margin-top: 1em; }
/* style the list to maximize the droppable hitarea */ /* style the list to maximize the droppable hitarea */
#cart ol { margin: 0; padding: 1em 0 1em 3em; } #cart ol { margin: 0; padding: 1em 0 1em 3em; }
</style> </style>
@ -49,11 +49,11 @@
<body> <body>
<div class="demo"> <div class="demo">
<div id="products"> <div id="products">
<h1 class="ui-widget-header">Products</h1> <h1 class="ui-widget-header">Products</h1>
<div id="catalog"> <div id="catalog">
<h3><a href="#">T-Shirts</a></h3> <h2><a href="#">T-Shirts</a></h2>
<div> <div>
<ul> <ul>
<li>Lolcat Shirt</li> <li>Lolcat Shirt</li>
@ -61,7 +61,7 @@
<li>Buckit Shirt</li> <li>Buckit Shirt</li>
</ul> </ul>
</div> </div>
<h3><a href="#">Bags</a></h3> <h2><a href="#">Bags</a></h2>
<div> <div>
<ul> <ul>
<li>Zebra Striped</li> <li>Zebra Striped</li>
@ -69,7 +69,7 @@
<li>Alligator Leather</li> <li>Alligator Leather</li>
</ul> </ul>
</div> </div>
<h3><a href="#">Gadgets</a></h3> <h2><a href="#">Gadgets</a></h2>
<div> <div>
<ul> <ul>
<li>iPhone</li> <li>iPhone</li>

View File

@ -5,20 +5,20 @@
<title>jQuery UI Effects - Effect demo</title> <title>jQuery UI Effects - Effect demo</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.7.2.js"></script> <script src="../../jquery-1.7.2.js"></script>
<script src="../../ui/jquery.effects.core.js"></script> <script src="../../ui/jquery.ui.effect.js"></script>
<script src="../../ui/jquery.effects.blind.js"></script> <script src="../../ui/jquery.ui.effect-blind.js"></script>
<script src="../../ui/jquery.effects.bounce.js"></script> <script src="../../ui/jquery.ui.effect-bounce.js"></script>
<script src="../../ui/jquery.effects.clip.js"></script> <script src="../../ui/jquery.ui.effect-clip.js"></script>
<script src="../../ui/jquery.effects.drop.js"></script> <script src="../../ui/jquery.ui.effect-drop.js"></script>
<script src="../../ui/jquery.effects.explode.js"></script> <script src="../../ui/jquery.ui.effect-explode.js"></script>
<script src="../../ui/jquery.effects.fade.js"></script> <script src="../../ui/jquery.ui.effect-fade.js"></script>
<script src="../../ui/jquery.effects.fold.js"></script> <script src="../../ui/jquery.ui.effect-fold.js"></script>
<script src="../../ui/jquery.effects.highlight.js"></script> <script src="../../ui/jquery.ui.effect-highlight.js"></script>
<script src="../../ui/jquery.effects.pulsate.js"></script> <script src="../../ui/jquery.ui.effect-pulsate.js"></script>
<script src="../../ui/jquery.effects.scale.js"></script> <script src="../../ui/jquery.ui.effect-scale.js"></script>
<script src="../../ui/jquery.effects.shake.js"></script> <script src="../../ui/jquery.ui.effect-shake.js"></script>
<script src="../../ui/jquery.effects.slide.js"></script> <script src="../../ui/jquery.ui.effect-slide.js"></script>
<script src="../../ui/jquery.effects.transfer.js"></script> <script src="../../ui/jquery.ui.effect-transfer.js"></script>
<link rel="stylesheet" href="../demos.css"> <link rel="stylesheet" href="../demos.css">
<style> <style>
.toggler { width: 500px; height: 200px; position: relative; } .toggler { width: 500px; height: 200px; position: relative; }

View File

@ -5,7 +5,7 @@
<title>jQuery UI Effects - Easing demo</title> <title>jQuery UI Effects - Easing demo</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.7.2.js"></script> <script src="../../jquery-1.7.2.js"></script>
<script src="../../ui/jquery.effects.core.js"></script> <script src="../../ui/jquery.ui.effect.js"></script>
<link rel="stylesheet" href="../demos.css"> <link rel="stylesheet" href="../demos.css">
<style> <style>
.graph { .graph {

View File

@ -5,18 +5,18 @@
<title>jQuery UI Effects - Hide Demo</title> <title>jQuery UI Effects - Hide Demo</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.7.2.js"></script> <script src="../../jquery-1.7.2.js"></script>
<script src="../../ui/jquery.effects.core.js"></script> <script src="../../ui/jquery.ui.effect.js"></script>
<script src="../../ui/jquery.effects.blind.js"></script> <script src="../../ui/jquery.ui.effect-blind.js"></script>
<script src="../../ui/jquery.effects.bounce.js"></script> <script src="../../ui/jquery.ui.effect-bounce.js"></script>
<script src="../../ui/jquery.effects.clip.js"></script> <script src="../../ui/jquery.ui.effect-clip.js"></script>
<script src="../../ui/jquery.effects.drop.js"></script> <script src="../../ui/jquery.ui.effect-drop.js"></script>
<script src="../../ui/jquery.effects.explode.js"></script> <script src="../../ui/jquery.ui.effect-explode.js"></script>
<script src="../../ui/jquery.effects.fold.js"></script> <script src="../../ui/jquery.ui.effect-fold.js"></script>
<script src="../../ui/jquery.effects.highlight.js"></script> <script src="../../ui/jquery.ui.effect-highlight.js"></script>
<script src="../../ui/jquery.effects.pulsate.js"></script> <script src="../../ui/jquery.ui.effect-pulsate.js"></script>
<script src="../../ui/jquery.effects.scale.js"></script> <script src="../../ui/jquery.ui.effect-scale.js"></script>
<script src="../../ui/jquery.effects.shake.js"></script> <script src="../../ui/jquery.ui.effect-shake.js"></script>
<script src="../../ui/jquery.effects.slide.js"></script> <script src="../../ui/jquery.ui.effect-slide.js"></script>
<link rel="stylesheet" href="../demos.css"> <link rel="stylesheet" href="../demos.css">
<style> <style>
.toggler { width: 500px; height: 200px; } .toggler { width: 500px; height: 200px; }

View File

@ -30,19 +30,19 @@
<script src="../ui/jquery.ui.spinner.js"></script> <script src="../ui/jquery.ui.spinner.js"></script>
<script src="../ui/jquery.ui.tabs.js"></script> <script src="../ui/jquery.ui.tabs.js"></script>
<script src="../ui/jquery.ui.tooltip.js"></script> <script src="../ui/jquery.ui.tooltip.js"></script>
<script src="../ui/jquery.effects.core.js"></script> <script src="../ui/jquery.ui.effect.js"></script>
<script src="../ui/jquery.effects.blind.js"></script> <script src="../ui/jquery.ui.effect-blind.js"></script>
<script src="../ui/jquery.effects.bounce.js"></script> <script src="../ui/jquery.ui.effect-bounce.js"></script>
<script src="../ui/jquery.effects.clip.js"></script> <script src="../ui/jquery.ui.effect-clip.js"></script>
<script src="../ui/jquery.effects.drop.js"></script> <script src="../ui/jquery.ui.effect-drop.js"></script>
<script src="../ui/jquery.effects.explode.js"></script> <script src="../ui/jquery.ui.effect-explode.js"></script>
<script src="../ui/jquery.effects.fold.js"></script> <script src="../ui/jquery.ui.effect-fold.js"></script>
<script src="../ui/jquery.effects.highlight.js"></script> <script src="../ui/jquery.ui.effect-highlight.js"></script>
<script src="../ui/jquery.effects.pulsate.js"></script> <script src="../ui/jquery.ui.effect-pulsate.js"></script>
<script src="../ui/jquery.effects.scale.js"></script> <script src="../ui/jquery.ui.effect-scale.js"></script>
<script src="../ui/jquery.effects.shake.js"></script> <script src="../ui/jquery.ui.effect-shake.js"></script>
<script src="../ui/jquery.effects.slide.js"></script> <script src="../ui/jquery.ui.effect-slide.js"></script>
<script src="../ui/jquery.effects.transfer.js"></script> <script src="../ui/jquery.ui.effect-transfer.js"></script>
<script src="../ui/i18n/jquery.ui.datepicker-af.js"></script> <script src="../ui/i18n/jquery.ui.datepicker-af.js"></script>
<script src="../ui/i18n/jquery.ui.datepicker-ar.js"></script> <script src="../ui/i18n/jquery.ui.datepicker-ar.js"></script>
<script src="../ui/i18n/jquery.ui.datepicker-ar-DZ.js"></script> <script src="../ui/i18n/jquery.ui.datepicker-ar-DZ.js"></script>
@ -67,7 +67,6 @@
<script src="../ui/i18n/jquery.ui.datepicker-fo.js"></script> <script src="../ui/i18n/jquery.ui.datepicker-fo.js"></script>
<script src="../ui/i18n/jquery.ui.datepicker-fr.js"></script> <script src="../ui/i18n/jquery.ui.datepicker-fr.js"></script>
<script src="../ui/i18n/jquery.ui.datepicker-fr-CH.js"></script> <script src="../ui/i18n/jquery.ui.datepicker-fr-CH.js"></script>
<script src="../ui/i18n/jquery.ui.datepicker-ge.js"></script>
<script src="../ui/i18n/jquery.ui.datepicker-gl.js"></script> <script src="../ui/i18n/jquery.ui.datepicker-gl.js"></script>
<script src="../ui/i18n/jquery.ui.datepicker-he.js"></script> <script src="../ui/i18n/jquery.ui.datepicker-he.js"></script>
<script src="../ui/i18n/jquery.ui.datepicker-hi.js"></script> <script src="../ui/i18n/jquery.ui.datepicker-hi.js"></script>
@ -78,6 +77,7 @@
<script src="../ui/i18n/jquery.ui.datepicker-is.js"></script> <script src="../ui/i18n/jquery.ui.datepicker-is.js"></script>
<script src="../ui/i18n/jquery.ui.datepicker-it.js"></script> <script src="../ui/i18n/jquery.ui.datepicker-it.js"></script>
<script src="../ui/i18n/jquery.ui.datepicker-ja.js"></script> <script src="../ui/i18n/jquery.ui.datepicker-ja.js"></script>
<script src="../ui/i18n/jquery.ui.datepicker-ka.js"></script>
<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>

View File

@ -1,28 +1,25 @@
<!DOCTYPE html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>jQuery UI Menu - Default demo</title> <title>jQuery UI Menu - Default functionality</title>
<link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" /> <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script src="../../jquery-1.7.2.js"></script> <script src="../../jquery-1.7.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.menu.js"></script> <script src="../../ui/jquery.ui.menu.js"></script>
<link href="../demos.css" rel="stylesheet" /> <link rel="stylesheet" href="../demos.css">
<script> <script>
$(function() { $(function() {
$(".demo ul").menu(); $( "#menu" ).menu();
}); });
</script> </script>
<style>
</style>
</head> </head>
<body> <body>
<div class="demo"> <div class="demo">
<ul> <ul id="menu">
<li><a href="#Aberdeen">Aberdeen</a></li> <li><a href="#Aberdeen">Aberdeen</a></li>
<li><a href="#Ada">Ada</a></li> <li><a href="#Ada">Ada</a></li>
<li><a href="#Adamsville">Adamsville</a></li> <li><a href="#Adamsville">Adamsville</a></li>
@ -44,11 +41,9 @@
<div class="demo-description"> <div class="demo-description">
<p>A menu with the default configuration. A list is transformed, adding themeing, mouse and keyboard navigation support. Try to tab to the menu and use the cursor keys to navigate.</p> <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>
</div><!-- End demo-description --> </div><!-- End demo-description -->
</body> </body>
</html> </html>

View File

@ -1,9 +1,9 @@
<!DOCTYPE html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="utf-8">
<title>jQuery UI Menu Demos</title> <title>jQuery UI Menu Demos</title>
<link href="../demos.css" rel="stylesheet" /> <link rel="stylesheet" href="../demos.css">
</head> </head>
<body> <body>
<div class="demos-nav"> <div class="demos-nav">

View File

@ -1,18 +1,18 @@
<!DOCTYPE html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>jQuery UI Menu - Navigation Menu demo</title> <title>jQuery UI Menu - Navigation Menu</title>
<link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" /> <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script src="../../jquery-1.7.2.js"></script> <script src="../../jquery-1.7.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.position.js"></script>
<script src="../../ui/jquery.ui.menu.js"></script> <script src="../../ui/jquery.ui.menu.js"></script>
<link href="../demos.css" rel="stylesheet" /> <link rel="stylesheet" href="../demos.css">
<script> <script>
$(function() { $(function() {
$("#navMenu").menu({ $( "#menu" ).menu({
select: function( event, ui ) { select: function( event, ui ) {
var link = ui.item.children( "a:first" ); var link = ui.item.children( "a:first" );
if ( link.attr( "target" ) || event.metaKey || event.shiftKey || event.ctrlKey ) { if ( link.attr( "target" ) || event.metaKey || event.shiftKey || event.ctrlKey ) {
@ -24,15 +24,14 @@
}); });
</script> </script>
<style> <style>
body { font-size:62.5%; } .ui-menu { width: 200px; margin-bottom: 2em; }
.ui-menu { width: 200px; margin-bottom: 2em; }
</style> </style>
</head> </head>
<body> <body>
<div class="demo"> <div class="demo">
<ul id="navMenu"> <ul id="menu">
<li><a href="?Aberdeen">Aberdeen</a></li> <li><a href="?Aberdeen">Aberdeen</a></li>
<li><a href="?Ada">Ada</a></li> <li><a href="?Ada">Ada</a></li>
<li><a href="?Adamsville">Adamsville</a></li> <li><a href="?Adamsville">Adamsville</a></li>
@ -74,11 +73,9 @@
<div class="demo-description"> <div class="demo-description">
<p>A navigation menu. A list is transformed, adding themeing, mouse and keyboard navigation support. Try to tab to the menu and use the cursor keys to navigate.</p> <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><!-- End demo-description --> </div><!-- End demo-description -->
</body> </body>
</html> </html>

View File

@ -3,8 +3,8 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Menu Demo: Top-aligned Menu</title> <title>Menu Demo: Top-aligned Menu</title>
<link type="text/css" href="../demos.css" rel="stylesheet" /> <link rel="stylesheet" href="../demos.css">
<link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" /> <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script src="../../jquery-1.7.2.js"></script> <script src="../../jquery-1.7.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>
@ -12,18 +12,21 @@
<script src="../../ui/jquery.ui.menu.js"></script> <script src="../../ui/jquery.ui.menu.js"></script>
<script> <script>
$(function() { $(function() {
$("#topMenu").menu({ $( "#menu" ).menu({
position: { of: "ul:has(a.ui-state-focus):last" } position: { of: "ul:has(a.ui-state-focus):last" },
icons: {
submenu: "ui-icon-carat-1-e"
}
}); });
}); });
</script> </script>
<style> <style>
.ui-menu { width: 200px; margin-bottom: 2em; } .ui-menu { width: 200px; margin-bottom: 2em; }
</style> </style>
</head> </head>
<body> <body>
<ul id="topMenu"> <ul id="menu">
<li><a href="#">Aberdeen</a></li> <li><a href="#">Aberdeen</a></li>
<li><a href="#">Ada</a></li> <li><a href="#">Ada</a></li>
<li><a href="#">Adamsville</a></li> <li><a href="#">Adamsville</a></li>

View File

@ -5,7 +5,7 @@
<title>jQuery UI Effects - removeClass Demo</title> <title>jQuery UI Effects - removeClass Demo</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.7.2.js"></script> <script src="../../jquery-1.7.2.js"></script>
<script src="../../ui/jquery.effects.core.js"></script> <script src="../../ui/jquery.ui.effect.js"></script>
<link rel="stylesheet" href="../demos.css"> <link rel="stylesheet" href="../demos.css">
<style> <style>
.toggler { width: 500px; height: 200px; position: relative; } .toggler { width: 500px; height: 200px; position: relative; }

View File

@ -5,18 +5,18 @@
<title>jQuery UI Effects - Show Demo</title> <title>jQuery UI Effects - Show Demo</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.7.2.js"></script> <script src="../../jquery-1.7.2.js"></script>
<script src="../../ui/jquery.effects.core.js"></script> <script src="../../ui/jquery.ui.effect.js"></script>
<script src="../../ui/jquery.effects.blind.js"></script> <script src="../../ui/jquery.ui.effect-blind.js"></script>
<script src="../../ui/jquery.effects.bounce.js"></script> <script src="../../ui/jquery.ui.effect-bounce.js"></script>
<script src="../../ui/jquery.effects.clip.js"></script> <script src="../../ui/jquery.ui.effect-clip.js"></script>
<script src="../../ui/jquery.effects.drop.js"></script> <script src="../../ui/jquery.ui.effect-drop.js"></script>
<script src="../../ui/jquery.effects.explode.js"></script> <script src="../../ui/jquery.ui.effect-explode.js"></script>
<script src="../../ui/jquery.effects.fold.js"></script> <script src="../../ui/jquery.ui.effect-fold.js"></script>
<script src="../../ui/jquery.effects.highlight.js"></script> <script src="../../ui/jquery.ui.effect-highlight.js"></script>
<script src="../../ui/jquery.effects.pulsate.js"></script> <script src="../../ui/jquery.ui.effect-pulsate.js"></script>
<script src="../../ui/jquery.effects.scale.js"></script> <script src="../../ui/jquery.ui.effect-scale.js"></script>
<script src="../../ui/jquery.effects.shake.js"></script> <script src="../../ui/jquery.ui.effect-shake.js"></script>
<script src="../../ui/jquery.effects.slide.js"></script> <script src="../../ui/jquery.ui.effect-slide.js"></script>
<link rel="stylesheet" href="../demos.css"> <link rel="stylesheet" href="../demos.css">
<style> <style>
.toggler { width: 500px; height: 200px; } .toggler { width: 500px; height: 200px; }

View File

@ -5,7 +5,7 @@
<title>jQuery UI Spinner - Default functionality</title> <title>jQuery UI Spinner - 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.7.2.js"></script> <script src="../../jquery-1.7.2.js"></script>
<script src="../../external/jquery.mousewheel-3.0.4.js"></script> <script src="../../external/jquery.mousewheel.js"></script>
<script src="../../external/globalize.js"></script> <script src="../../external/globalize.js"></script>
<script src="../../external/globalize.culture.de-DE.js"></script> <script src="../../external/globalize.culture.de-DE.js"></script>
<script src="../../external/globalize.culture.ja-JP.js"></script> <script src="../../external/globalize.culture.ja-JP.js"></script>
@ -52,7 +52,7 @@
<div class="demo-description"> <div class="demo-description">
<p>Example of a donation form, with currency selection and amout spinner.</p> <p>Example of a donation form, with currency selection and amount spinner.</p>
</div><!-- End demo-description --> </div><!-- End demo-description -->
</body> </body>

View File

@ -5,7 +5,7 @@
<title>jQuery UI Spinner - Decimal</title> <title>jQuery UI Spinner - Decimal</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.7.2.js"></script> <script src="../../jquery-1.7.2.js"></script>
<script src="../../external/jquery.mousewheel-3.0.4.js"></script> <script src="../../external/jquery.mousewheel.js"></script>
<script src="../../external/globalize.js"></script> <script src="../../external/globalize.js"></script>
<script src="../../external/globalize.culture.de-DE.js"></script> <script src="../../external/globalize.culture.de-DE.js"></script>
<script src="../../external/globalize.culture.ja-JP.js"></script> <script src="../../external/globalize.culture.ja-JP.js"></script>

View File

@ -5,7 +5,7 @@
<title>jQuery UI Spinner - Default functionality</title> <title>jQuery UI Spinner - 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.7.2.js"></script> <script src="../../jquery-1.7.2.js"></script>
<script src="../../external/jquery.mousewheel-3.0.4.js"></script> <script src="../../external/jquery.mousewheel.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.button.js"></script> <script src="../../ui/jquery.ui.button.js"></script>

View File

@ -6,7 +6,7 @@
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script src="http://maps.google.com/maps/api/js?sensor=false"></script> <script src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script src="../../jquery-1.7.2.js"></script> <script src="../../jquery-1.7.2.js"></script>
<script src="../../external/jquery.mousewheel-3.0.4.js"></script> <script src="../../external/jquery.mousewheel.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.button.js"></script> <script src="../../ui/jquery.ui.button.js"></script>

View File

@ -5,7 +5,7 @@
<title>jQuery UI Spinner - Overflow</title> <title>jQuery UI Spinner - Overflow</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.7.2.js"></script> <script src="../../jquery-1.7.2.js"></script>
<script src="../../external/jquery.mousewheel-3.0.4.js"></script> <script src="../../external/jquery.mousewheel.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.button.js"></script> <script src="../../ui/jquery.ui.button.js"></script>

View File

@ -5,7 +5,7 @@
<title>jQuery UI Spinner - Time</title> <title>jQuery UI Spinner - Time</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.7.2.js"></script> <script src="../../jquery-1.7.2.js"></script>
<script src="../../external/jquery.mousewheel-3.0.4.js"></script> <script src="../../external/jquery.mousewheel.js"></script>
<script src="../../external/globalize.js"></script> <script src="../../external/globalize.js"></script>
<script src="../../external/globalize.culture.de-DE.js"></script> <script src="../../external/globalize.culture.de-DE.js"></script>
<script src="../../ui/jquery.ui.core.js"></script> <script src="../../ui/jquery.ui.core.js"></script>

View File

@ -5,7 +5,7 @@
<title>jQuery UI Effects - switchClass Demo</title> <title>jQuery UI Effects - switchClass Demo</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.7.2.js"></script> <script src="../../jquery-1.7.2.js"></script>
<script src="../../ui/jquery.effects.core.js"></script> <script src="../../ui/jquery.ui.effect.js"></script>
<link rel="stylesheet" href="../demos.css"> <link rel="stylesheet" href="../demos.css">
<style> <style>
.toggler { width: 500px; height: 200px; position: relative; } .toggler { width: 500px; height: 200px; position: relative; }

View File

@ -1,57 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Tabs - Default functionality</title>
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script src="../../jquery-1.7.2.js"></script>
<script src="../../external/jquery.cookie.js"></script>
<script src="../../ui/jquery.ui.core.js"></script>
<script src="../../ui/jquery.ui.widget.js"></script>
<script src="../../ui/jquery.ui.tabs.js"></script>
<link rel="stylesheet" href="../demos.css">
<script>
$(function() {
$( "#tabs" ).tabs({
cookie: {
// store cookie for a day, without, it would be a session cookie
expires: 1
}
});
});
</script>
</head>
<body>
<div class="demo">
<div id="tabs">
<ul>
<li><a href="#tabs-1">Nunc tincidunt</a></li>
<li><a href="#tabs-2">Proin dolor</a></li>
<li><a href="#tabs-3">Aenean lacinia</a></li>
</ul>
<div id="tabs-1">
<p>Proin elit arcu, rutrum commodo, vehicula tempus, commodo a, risus. Curabitur nec arcu. Donec sollicitudin mi sit amet mauris. Nam elementum quam ullamcorper ante. Etiam aliquet massa et lorem. Mauris dapibus lacus auctor risus. Aenean tempor ullamcorper leo. Vivamus sed magna quis ligula eleifend adipiscing. Duis orci. Aliquam sodales tortor vitae ipsum. Aliquam nulla. Duis aliquam molestie erat. Ut et mauris vel pede varius sollicitudin. Sed ut dolor nec orci tincidunt interdum. Phasellus ipsum. Nunc tristique tempus lectus.</p>
</div>
<div id="tabs-2">
<p>Morbi tincidunt, dui sit amet facilisis feugiat, odio metus gravida ante, ut pharetra massa metus id nunc. Duis scelerisque molestie turpis. Sed fringilla, massa eget luctus malesuada, metus eros molestie lectus, ut tempus eros massa ut dolor. Aenean aliquet fringilla sem. Suspendisse sed ligula in ligula suscipit aliquam. Praesent in eros vestibulum mi adipiscing adipiscing. Morbi facilisis. Curabitur ornare consequat nunc. Aenean vel metus. Ut posuere viverra nulla. Aliquam erat volutpat. Pellentesque convallis. Maecenas feugiat, tellus pellentesque pretium posuere, felis lorem euismod felis, eu ornare leo nisi vel felis. Mauris consectetur tortor et purus.</p>
</div>
<div id="tabs-3">
<p>Mauris eleifend est et turpis. Duis id erat. Suspendisse potenti. Aliquam vulputate, pede vel vehicula accumsan, mi neque rutrum erat, eu congue orci lorem eget lorem. Vestibulum non ante. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Fusce sodales. Quisque eu urna vel enim commodo pellentesque. Praesent eu risus hendrerit ligula tempus pretium. Curabitur lorem enim, pretium nec, feugiat nec, luctus a, lacus.</p>
<p>Duis cursus. Maecenas ligula eros, blandit nec, pharetra at, semper at, magna. Nullam ac lacus. Nulla facilisi. Praesent viverra justo vitae neque. Praesent blandit adipiscing velit. Suspendisse potenti. Donec mattis, pede vel pharetra blandit, magna ligula faucibus eros, id euismod lacus dolor eget odio. Nam scelerisque. Donec non libero sed nulla mattis commodo. Ut sagittis. Donec nisi lectus, feugiat porttitor, tempor ac, tempor vitae, pede. Aenean vehicula velit eu tellus interdum rutrum. Maecenas commodo. Pellentesque nec elit. Fusce in lacus. Vivamus a libero vitae lectus hendrerit hendrerit.</p>
</div>
</div>
</div><!-- End demo -->
<div class="demo-description">
<p>Looks the same as the default demo, but uses cookie to store the selected tab, and restore it when the page (re)loads.
The cookie is stored for a day, so tabs will be restored even after closing the browser. Use cookie: {} for using cookies with default options.</p>
<p>The cookie option requires the cookie plugin, which can be found in the development-bundle > external folder from the download builder.</p>
</div><!-- End demo-description -->
</body>
</html>

View File

@ -17,7 +17,6 @@
<li><a href="sortable.html">Sortable</a></li> <li><a href="sortable.html">Sortable</a></li>
<li><a href="manipulation.html">Simple manipulation</a></li> <li><a href="manipulation.html">Simple manipulation</a></li>
<li><a href="bottom.html">Tabs below content</a></li> <li><a href="bottom.html">Tabs below content</a></li>
<li><a href="cookie.html">Cookie persistence</a></li>
</ul> </ul>
</div> </div>

View File

@ -5,18 +5,18 @@
<title>jQuery UI Effects - Toggle Demo</title> <title>jQuery UI Effects - Toggle Demo</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.7.2.js"></script> <script src="../../jquery-1.7.2.js"></script>
<script src="../../ui/jquery.effects.core.js"></script> <script src="../../ui/jquery.ui.effect.js"></script>
<script src="../../ui/jquery.effects.blind.js"></script> <script src="../../ui/jquery.ui.effect-blind.js"></script>
<script src="../../ui/jquery.effects.bounce.js"></script> <script src="../../ui/jquery.ui.effect-bounce.js"></script>
<script src="../../ui/jquery.effects.clip.js"></script> <script src="../../ui/jquery.ui.effect-clip.js"></script>
<script src="../../ui/jquery.effects.drop.js"></script> <script src="../../ui/jquery.ui.effect-drop.js"></script>
<script src="../../ui/jquery.effects.explode.js"></script> <script src="../../ui/jquery.ui.effect-explode.js"></script>
<script src="../../ui/jquery.effects.fold.js"></script> <script src="../../ui/jquery.ui.effect-fold.js"></script>
<script src="../../ui/jquery.effects.highlight.js"></script> <script src="../../ui/jquery.ui.effect-highlight.js"></script>
<script src="../../ui/jquery.effects.pulsate.js"></script> <script src="../../ui/jquery.ui.effect-pulsate.js"></script>
<script src="../../ui/jquery.effects.scale.js"></script> <script src="../../ui/jquery.ui.effect-scale.js"></script>
<script src="../../ui/jquery.effects.shake.js"></script> <script src="../../ui/jquery.ui.effect-shake.js"></script>
<script src="../../ui/jquery.effects.slide.js"></script> <script src="../../ui/jquery.ui.effect-slide.js"></script>
<link rel="stylesheet" href="../demos.css"> <link rel="stylesheet" href="../demos.css">
<style> <style>
.toggler { .toggler {

View File

@ -5,7 +5,7 @@
<title>jQuery UI Effects - toggleClass Demo</title> <title>jQuery UI Effects - toggleClass Demo</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.7.2.js"></script> <script src="../../jquery-1.7.2.js"></script>
<script src="../../ui/jquery.effects.core.js"></script> <script src="../../ui/jquery.ui.effect.js"></script>
<link rel="stylesheet" href="../demos.css"> <link rel="stylesheet" href="../demos.css">
<style> <style>
.toggler { width: 500px; height: 200px; position: relative; } .toggler { width: 500px; height: 200px; position: relative; }

View File

@ -9,8 +9,8 @@
<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.position.js"></script>
<script src="../../ui/jquery.ui.tooltip.js"></script> <script src="../../ui/jquery.ui.tooltip.js"></script>
<script src="../../ui/jquery.effects.core.js"></script> <script src="../../ui/jquery.ui.effect.js"></script>
<script src="../../ui/jquery.effects.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>
$(function() { $(function() {

View File

@ -19,24 +19,7 @@
<script> <script>
$(function() { $(function() {
$( ".demo" ).tooltip({ $( ".demo" ).tooltip({
position: { track: true
my: "left+25 center",
at: "center"
},
open: function( event ) {
var tooltip = $( ".ui-tooltip" ),
positionOption = $( this ).tooltip( "option", "position" );
function position( event ) {
positionOption.of = event;
tooltip.position( positionOption );
}
$( document ).bind( "mousemove.tooltip-position", position );
// trigger once to override element-relative positioning
position( event );
},
close: function() {
$( document ).unbind( "mousemove.tooltip-position" );
}
}); });
}); });
</script> </script>

View File

@ -11,8 +11,8 @@
<script src="../../ui/jquery.ui.tooltip.js"></script> <script src="../../ui/jquery.ui.tooltip.js"></script>
<script src="../../ui/jquery.ui.button.js"></script> <script src="../../ui/jquery.ui.button.js"></script>
<script src="../../ui/jquery.ui.menu.js"></script> <script src="../../ui/jquery.ui.menu.js"></script>
<script src="../../ui/jquery.effects.core.js"></script> <script src="../../ui/jquery.ui.effect.js"></script>
<script src="../../ui/jquery.effects.blind.js"></script> <script src="../../ui/jquery.ui.effect-blind.js"></script>
<link rel="stylesheet" href="../demos.css"> <link rel="stylesheet" href="../demos.css">
<style> <style>
.player { .player {

View File

@ -56,8 +56,8 @@
.button(); .button();
// bind click events on the changer button to the random method // bind click events on the changer button to the random method
this._bind( this.changer, { this._on( this.changer, {
// _bind won't call random when widget is disabled // _on won't call random when widget is disabled
click: "random" click: "random"
}); });
this._refresh(); this._refresh();
@ -90,7 +90,7 @@
} }
}, },
// events bound via _bind are removed automatically // events bound via _on are removed automatically
// revert other modifications here // revert other modifications here
_destroy: function() { _destroy: function() {
// remove generated elements // remove generated elements

View File

@ -1,12 +1,12 @@
/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net) /*! Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net)
* Licensed under the MIT License (LICENSE.txt). * Licensed under the MIT License (LICENSE.txt).
* *
* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers. * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix. * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
* Thanks to: Seamus Leahy for adding deltaX and deltaY * Thanks to: Seamus Leahy for adding deltaX and deltaY
* *
* Version: 3.0.4 * Version: 3.0.6
* *
* Requires: 1.2.2+ * Requires: 1.2.2+
*/ */
@ -14,6 +14,12 @@
var types = ['DOMMouseScroll', 'mousewheel']; var types = ['DOMMouseScroll', 'mousewheel'];
if ($.event.fixHooks) {
for ( var i=types.length; i; ) {
$.event.fixHooks[ types[--i] ] = $.event.mouseHooks;
}
}
$.event.special.mousewheel = { $.event.special.mousewheel = {
setup: function() { setup: function() {
if ( this.addEventListener ) { if ( this.addEventListener ) {
@ -24,7 +30,7 @@ $.event.special.mousewheel = {
this.onmousewheel = handler; this.onmousewheel = handler;
} }
}, },
teardown: function() { teardown: function() {
if ( this.removeEventListener ) { if ( this.removeEventListener ) {
for ( var i=types.length; i; ) { for ( var i=types.length; i; ) {
@ -40,7 +46,7 @@ $.fn.extend({
mousewheel: function(fn) { mousewheel: function(fn) {
return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel"); return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
}, },
unmousewheel: function(fn) { unmousewheel: function(fn) {
return this.unbind("mousewheel", fn); return this.unbind("mousewheel", fn);
} }
@ -51,28 +57,28 @@ function handler(event) {
var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0; var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0;
event = $.event.fix(orgEvent); event = $.event.fix(orgEvent);
event.type = "mousewheel"; event.type = "mousewheel";
// Old school scrollwheel delta // Old school scrollwheel delta
if ( event.wheelDelta ) { delta = event.wheelDelta/120; } if ( orgEvent.wheelDelta ) { delta = orgEvent.wheelDelta/120; }
if ( event.detail ) { delta = -event.detail/3; } if ( orgEvent.detail ) { delta = -orgEvent.detail/3; }
// New school multidimensional scroll (touchpads) deltas // New school multidimensional scroll (touchpads) deltas
deltaY = delta; deltaY = delta;
// Gecko // Gecko
if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) { if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
deltaY = 0; deltaY = 0;
deltaX = -1*delta; deltaX = -1*delta;
} }
// Webkit // Webkit
if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; } if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; }
if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; } if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; }
// Add event and delta to the front of the arguments // Add event and delta to the front of the arguments
args.unshift(event, delta, deltaX, deltaY); args.unshift(event, delta, deltaX, deltaY);
return $.event.handle.apply(this, args); return ($.event.dispatch || $.event.handle).apply(this, args);
} }
})(jQuery); })(jQuery);

41
external/qunit.css vendored
View File

@ -1,5 +1,5 @@
/** /**
* QUnit v1.6.0 - A JavaScript Unit Testing Framework * QUnit v1.9.0 - A JavaScript Unit Testing Framework
* *
* http://docs.jquery.com/QUnit * http://docs.jquery.com/QUnit
* *
@ -38,10 +38,10 @@
line-height: 1em; line-height: 1em;
font-weight: normal; font-weight: normal;
border-radius: 15px 15px 0 0; border-radius: 5px 5px 0 0;
-moz-border-radius: 15px 15px 0 0; -moz-border-radius: 5px 5px 0 0;
-webkit-border-top-right-radius: 15px; -webkit-border-top-right-radius: 5px;
-webkit-border-top-left-radius: 15px; -webkit-border-top-left-radius: 5px;
} }
#qunit-header a { #qunit-header a {
@ -54,9 +54,9 @@
color: #fff; color: #fff;
} }
#qunit-header label { #qunit-testrunner-toolbar label {
display: inline-block; display: inline-block;
padding-left: 0.5em; padding: 0 .5em 0 .1em;
} }
#qunit-banner { #qunit-banner {
@ -113,13 +113,9 @@
background-color: #fff; background-color: #fff;
border-radius: 15px; border-radius: 5px;
-moz-border-radius: 15px; -moz-border-radius: 5px;
-webkit-border-radius: 15px; -webkit-border-radius: 5px;
box-shadow: inset 0px 2px 13px #999;
-moz-box-shadow: inset 0px 2px 13px #999;
-webkit-box-shadow: inset 0px 2px 13px #999;
} }
#qunit-tests table { #qunit-tests table {
@ -162,8 +158,7 @@
#qunit-tests b.failed { color: #710909; } #qunit-tests b.failed { color: #710909; }
#qunit-tests li li { #qunit-tests li li {
margin: 0.5em; padding: 5px;
padding: 0.4em 0.5em 0.4em 0.5em;
background-color: #fff; background-color: #fff;
border-bottom: none; border-bottom: none;
list-style-position: inside; list-style-position: inside;
@ -172,9 +167,9 @@
/*** Passing Styles */ /*** Passing Styles */
#qunit-tests li li.pass { #qunit-tests li li.pass {
color: #5E740B; color: #3c510c;
background-color: #fff; background-color: #fff;
border-left: 26px solid #C6E746; border-left: 10px solid #C6E746;
} }
#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; } #qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
@ -190,15 +185,15 @@
#qunit-tests li li.fail { #qunit-tests li li.fail {
color: #710909; color: #710909;
background-color: #fff; background-color: #fff;
border-left: 26px solid #EE5757; border-left: 10px solid #EE5757;
white-space: pre; white-space: pre;
} }
#qunit-tests > li:last-child { #qunit-tests > li:last-child {
border-radius: 0 0 15px 15px; border-radius: 0 0 5px 5px;
-moz-border-radius: 0 0 15px 15px; -moz-border-radius: 0 0 5px 5px;
-webkit-border-bottom-right-radius: 15px; -webkit-border-bottom-right-radius: 5px;
-webkit-border-bottom-left-radius: 15px; -webkit-border-bottom-left-radius: 5px;
} }
#qunit-tests .fail { color: #000000; background-color: #EE5757; } #qunit-tests .fail { color: #000000; background-color: #EE5757; }

525
external/qunit.js vendored
View File

@ -1,5 +1,5 @@
/** /**
* QUnit v1.6.0 - A JavaScript Unit Testing Framework * QUnit v1.9.0 - A JavaScript Unit Testing Framework
* *
* http://docs.jquery.com/QUnit * http://docs.jquery.com/QUnit
* *
@ -12,7 +12,9 @@
var QUnit, var QUnit,
config, config,
onErrorFnPrev,
testId = 0, testId = 0,
fileName = (sourceFromStacktrace( 0 ) || "" ).replace(/(:\d+)+\)?/, "").replace(/.+\//, ""),
toString = Object.prototype.toString, toString = Object.prototype.toString,
hasOwn = Object.prototype.hasOwnProperty, hasOwn = Object.prototype.hasOwnProperty,
defined = { defined = {
@ -29,26 +31,31 @@ var QUnit,
}()) }())
}; };
function Test( name, testName, expected, async, callback ) { function Test( settings ) {
this.name = name; extend( this, settings );
this.testName = testName;
this.expected = expected;
this.async = async;
this.callback = callback;
this.assertions = []; this.assertions = [];
this.testNumber = ++Test.count;
} }
Test.count = 0;
Test.prototype = { Test.prototype = {
init: function() { init: function() {
var b, li, var a, b, li,
tests = id( "qunit-tests" ); tests = id( "qunit-tests" );
if ( tests ) { if ( tests ) {
b = document.createElement( "strong" ); b = document.createElement( "strong" );
b.innerHTML = "Running " + this.name; b.innerHTML = this.name;
// `a` initialized at top of scope
a = document.createElement( "a" );
a.innerHTML = "Rerun";
a.href = QUnit.url({ testNumber: this.testNumber });
li = document.createElement( "li" ); li = document.createElement( "li" );
li.appendChild( b ); li.appendChild( b );
li.appendChild( a );
li.className = "running"; li.className = "running";
li.id = this.id = "qunit-test-output" + testId++; li.id = this.id = "qunit-test-output" + testId++;
@ -119,14 +126,14 @@ Test.prototype = {
} }
if ( config.notrycatch ) { if ( config.notrycatch ) {
this.callback.call( this.testEnvironment ); this.callback.call( this.testEnvironment, QUnit.assert );
return; return;
} }
try { try {
this.callback.call( this.testEnvironment ); this.callback.call( this.testEnvironment, QUnit.assert );
} catch( e ) { } catch( e ) {
QUnit.pushFailure( "Died on test #" + (this.assertions.length + 1) + ": " + e.message, extractStacktrace( e, 1 ) ); QUnit.pushFailure( "Died on test #" + (this.assertions.length + 1) + " " + this.stack + ": " + e.message, extractStacktrace( e, 0 ) );
// else next test will carry the responsibility // else next test will carry the responsibility
saveGlobal(); saveGlobal();
@ -152,13 +159,16 @@ Test.prototype = {
}, },
finish: function() { finish: function() {
config.current = this; config.current = this;
if ( this.expected != null && this.expected != this.assertions.length ) { if ( config.requireExpects && this.expected == null ) {
QUnit.pushFailure( "Expected number of assertions to be defined, but expect() was not called.", this.stack );
} else if ( this.expected != null && this.expected != this.assertions.length ) {
QUnit.pushFailure( "Expected " + this.expected + " assertions, but " + this.assertions.length + " were run", this.stack ); QUnit.pushFailure( "Expected " + this.expected + " assertions, but " + this.assertions.length + " were run", this.stack );
} else if ( this.expected == null && !this.assertions.length ) { } else if ( this.expected == null && !this.assertions.length ) {
QUnit.pushFailure( "Expected at least one assertion, but none were run - call expect(0) to accept zero assertions.", this.stack ); QUnit.pushFailure( "Expected at least one assertion, but none were run - call expect(0) to accept zero assertions.", this.stack );
} }
var assertion, a, b, i, li, ol, var assertion, a, b, i, li, ol,
test = this,
good = 0, good = 0,
bad = 0, bad = 0,
tests = id( "qunit-tests" ); tests = id( "qunit-tests" );
@ -203,11 +213,6 @@ Test.prototype = {
b = document.createElement( "strong" ); b = document.createElement( "strong" );
b.innerHTML = this.name + " <b class='counts'>(<b class='failed'>" + bad + "</b>, <b class='passed'>" + good + "</b>, " + this.assertions.length + ")</b>"; b.innerHTML = this.name + " <b class='counts'>(<b class='failed'>" + bad + "</b>, <b class='passed'>" + good + "</b>, " + this.assertions.length + ")</b>";
// `a` initialized at top of scope
a = document.createElement( "a" );
a.innerHTML = "Rerun";
a.href = QUnit.url({ filter: getText([b]).replace( /\([^)]+\)$/, "" ).replace( /(^\s*|\s*$)/g, "" ) });
addEvent(b, "click", function() { addEvent(b, "click", function() {
var next = b.nextSibling.nextSibling, var next = b.nextSibling.nextSibling,
display = next.style.display; display = next.style.display;
@ -220,9 +225,7 @@ Test.prototype = {
target = target.parentNode; target = target.parentNode;
} }
if ( window.location && target.nodeName.toLowerCase() === "strong" ) { if ( window.location && target.nodeName.toLowerCase() === "strong" ) {
window.location = QUnit.url({ window.location = QUnit.url({ testNumber: test.testNumber });
filter: getText([target]).replace( /\([^)]+\)$/, "" ).replace( /(^\s*|\s*$)/g, "" )
});
} }
}); });
@ -230,8 +233,9 @@ Test.prototype = {
li = id( this.id ); li = id( this.id );
li.className = bad ? "fail" : "pass"; li.className = bad ? "fail" : "pass";
li.removeChild( li.firstChild ); li.removeChild( li.firstChild );
a = li.firstChild;
li.appendChild( b ); li.appendChild( b );
li.appendChild( a ); li.appendChild ( a );
li.appendChild( ol ); li.appendChild( ol );
} else { } else {
@ -253,6 +257,8 @@ Test.prototype = {
}); });
QUnit.reset(); QUnit.reset();
config.current = undefined;
}, },
queue: function() { queue: function() {
@ -291,6 +297,7 @@ Test.prototype = {
} }
}; };
// Root QUnit object.
// `QUnit` initialized at top of scope // `QUnit` initialized at top of scope
QUnit = { QUnit = {
@ -322,14 +329,21 @@ QUnit = {
name = "<span class='module-name'>" + config.currentModule + "</span>: " + name; name = "<span class='module-name'>" + config.currentModule + "</span>: " + name;
} }
if ( !validTest(config.currentModule + ": " + testName) ) { test = new Test({
name: name,
testName: testName,
expected: expected,
async: async,
callback: callback,
module: config.currentModule,
moduleTestEnvironment: config.currentModuleTestEnviroment,
stack: sourceFromStacktrace( 2 )
});
if ( !validTest( test ) ) {
return; return;
} }
test = new Test( name, testName, expected, async, callback );
test.module = config.currentModule;
test.moduleTestEnvironment = config.currentModuleTestEnviroment;
test.stack = sourceFromStacktrace( 2 );
test.queue(); test.queue();
}, },
@ -338,97 +352,6 @@ QUnit = {
config.current.expected = asserts; config.current.expected = asserts;
}, },
// Asserts true.
// @example ok( "asdfasdf".length > 5, "There must be at least 5 chars" );
ok: function( result, msg ) {
if ( !config.current ) {
throw new Error( "ok() assertion outside test context, was " + sourceFromStacktrace(2) );
}
result = !!result;
var source,
details = {
result: result,
message: msg
};
msg = escapeInnerText( msg || (result ? "okay" : "failed" ) );
msg = "<span class='test-message'>" + msg + "</span>";
if ( !result ) {
source = sourceFromStacktrace( 2 );
if ( source ) {
details.source = source;
msg += "<table><tr class='test-source'><th>Source: </th><td><pre>" + escapeInnerText( source ) + "</pre></td></tr></table>";
}
}
runLoggingCallbacks( "log", QUnit, details );
config.current.assertions.push({
result: result,
message: msg
});
},
// Checks that the first two arguments are equal, with an optional message. Prints out both actual and expected values.
// @example equal( format( "Received {0} bytes.", 2), "Received 2 bytes." );
equal: function( actual, expected, message ) {
QUnit.push( expected == actual, actual, expected, message );
},
notEqual: function( actual, expected, message ) {
QUnit.push( expected != actual, actual, expected, message );
},
deepEqual: function( actual, expected, message ) {
QUnit.push( QUnit.equiv(actual, expected), actual, expected, message );
},
notDeepEqual: function( actual, expected, message ) {
QUnit.push( !QUnit.equiv(actual, expected), actual, expected, message );
},
strictEqual: function( actual, expected, message ) {
QUnit.push( expected === actual, actual, expected, message );
},
notStrictEqual: function( actual, expected, message ) {
QUnit.push( expected !== actual, actual, expected, message );
},
raises: function( block, expected, message ) {
var actual,
ok = false;
if ( typeof expected === "string" ) {
message = expected;
expected = null;
}
try {
block.call( config.current.testEnvironment );
} catch (e) {
actual = e;
}
if ( actual ) {
// we don't want to validate thrown error
if ( !expected ) {
ok = true;
// expected is a regexp
} else if ( QUnit.objectType( expected ) === "regexp" ) {
ok = expected.test( actual );
// expected is a constructor
} else if ( actual instanceof expected ) {
ok = true;
// expected is a validation function which returns true is validation passed
} else if ( expected.call( {}, actual ) === true ) {
ok = true;
}
}
QUnit.ok( ok, message );
},
start: function( count ) { start: function( count ) {
config.semaphore -= count || 1; config.semaphore -= count || 1;
// don't start until equal number of stop-calls // don't start until equal number of stop-calls
@ -473,6 +396,160 @@ QUnit = {
} }
}; };
// Asssert helpers
// All of these must call either QUnit.push() or manually do:
// - runLoggingCallbacks( "log", .. );
// - config.current.assertions.push({ .. });
QUnit.assert = {
/**
* Asserts rough true-ish result.
* @name ok
* @function
* @example ok( "asdfasdf".length > 5, "There must be at least 5 chars" );
*/
ok: function( result, msg ) {
if ( !config.current ) {
throw new Error( "ok() assertion outside test context, was " + sourceFromStacktrace(2) );
}
result = !!result;
var source,
details = {
result: result,
message: msg
};
msg = escapeInnerText( msg || (result ? "okay" : "failed" ) );
msg = "<span class='test-message'>" + msg + "</span>";
if ( !result ) {
source = sourceFromStacktrace( 2 );
if ( source ) {
details.source = source;
msg += "<table><tr class='test-source'><th>Source: </th><td><pre>" + escapeInnerText( source ) + "</pre></td></tr></table>";
}
}
runLoggingCallbacks( "log", QUnit, details );
config.current.assertions.push({
result: result,
message: msg
});
},
/**
* Assert that the first two arguments are equal, with an optional message.
* Prints out both actual and expected values.
* @name equal
* @function
* @example equal( format( "Received {0} bytes.", 2), "Received 2 bytes.", "format() replaces {0} with next argument" );
*/
equal: function( actual, expected, message ) {
QUnit.push( expected == actual, actual, expected, message );
},
/**
* @name notEqual
* @function
*/
notEqual: function( actual, expected, message ) {
QUnit.push( expected != actual, actual, expected, message );
},
/**
* @name deepEqual
* @function
*/
deepEqual: function( actual, expected, message ) {
QUnit.push( QUnit.equiv(actual, expected), actual, expected, message );
},
/**
* @name notDeepEqual
* @function
*/
notDeepEqual: function( actual, expected, message ) {
QUnit.push( !QUnit.equiv(actual, expected), actual, expected, message );
},
/**
* @name strictEqual
* @function
*/
strictEqual: function( actual, expected, message ) {
QUnit.push( expected === actual, actual, expected, message );
},
/**
* @name notStrictEqual
* @function
*/
notStrictEqual: function( actual, expected, message ) {
QUnit.push( expected !== actual, actual, expected, message );
},
throws: function( block, expected, message ) {
var actual,
ok = false;
// 'expected' is optional
if ( typeof expected === "string" ) {
message = expected;
expected = null;
}
config.current.ignoreGlobalErrors = true;
try {
block.call( config.current.testEnvironment );
} catch (e) {
actual = e;
}
config.current.ignoreGlobalErrors = false;
if ( actual ) {
// we don't want to validate thrown error
if ( !expected ) {
ok = true;
// expected is a regexp
} else if ( QUnit.objectType( expected ) === "regexp" ) {
ok = expected.test( actual );
// expected is a constructor
} else if ( actual instanceof expected ) {
ok = true;
// expected is a validation function which returns true is validation passed
} else if ( expected.call( {}, actual ) === true ) {
ok = true;
}
QUnit.push( ok, actual, null, message );
} else {
QUnit.pushFailure( message, null, 'No exception was thrown.' );
}
}
};
/**
* @deprecate since 1.8.0
* Kept assertion helpers in root for backwards compatibility
*/
extend( QUnit, QUnit.assert );
/**
* @deprecated since 1.9.0
* Kept global "raises()" for backwards compatibility
*/
QUnit.raises = QUnit.assert.throws;
/**
* @deprecated since 1.0.0, replaced with error pushes since 1.3.0
* Kept to avoid TypeErrors for undefined methods.
*/
QUnit.equals = function() {
QUnit.push( false, false, false, "QUnit.equals has been deprecated since 2009 (e88049a0), use QUnit.equal instead" );
};
QUnit.same = function() {
QUnit.push( false, false, false, "QUnit.same has been deprecated since 2009 (e88049a0), use QUnit.deepEqual instead" );
};
// We want access to the constructor's prototype // We want access to the constructor's prototype
(function() { (function() {
function F() {} function F() {}
@ -482,17 +559,11 @@ QUnit = {
QUnit.constructor = F; QUnit.constructor = F;
}()); }());
// deprecated; still export them to window to provide clear error messages /**
// next step: remove entirely * Config object: Maintain internal state
QUnit.equals = function() { * Later exposed as QUnit.config
QUnit.push( false, false, false, "QUnit.equals has been deprecated since 2009 (e88049a0), use QUnit.equal instead" ); * `config` initialized at top of scope
}; */
QUnit.same = function() {
QUnit.push( false, false, false, "QUnit.same has been deprecated since 2009 (e88049a0), use QUnit.deepEqual instead" );
};
// Maintain internal state
// `config` initialized at top of scope
config = { config = {
// The queue of tests to run // The queue of tests to run
queue: [], queue: [],
@ -511,7 +582,23 @@ config = {
// by default, modify document.title when suite is done // by default, modify document.title when suite is done
altertitle: true, altertitle: true,
urlConfig: [ "noglobals", "notrycatch" ], // when enabled, all tests must call expect()
requireExpects: false,
// add checkboxes that are persisted in the query-string
// when enabled, the id is set to `true` as a `QUnit.config` property
urlConfig: [
{
id: "noglobals",
label: "Check for Globals",
tooltip: "Enabling this will test if any test introduces new properties on the `window` object. Stored as query-strings."
},
{
id: "notrycatch",
label: "No try-catch",
tooltip: "Enabling this will run tests outside of a try-catch block. Makes debugging exceptions in IE reasonable. Stored as query-strings."
}
],
// logging callback queues // logging callback queues
begin: [], begin: [],
@ -523,7 +610,7 @@ config = {
moduleDone: [] moduleDone: []
}; };
// Load paramaters // Initialize more QUnit.config and QUnit.urlParams
(function() { (function() {
var i, var i,
location = window.location || { search: "", protocol: "file:" }, location = window.location || { search: "", protocol: "file:" },
@ -543,20 +630,30 @@ config = {
} }
QUnit.urlParams = urlParams; QUnit.urlParams = urlParams;
// String search anywhere in moduleName+testName
config.filter = urlParams.filter; config.filter = urlParams.filter;
// Exact match of the module name
config.module = urlParams.module;
config.testNumber = parseInt( urlParams.testNumber, 10 ) || null;
// Figure out if we're running the tests from a server or not // Figure out if we're running the tests from a server or not
QUnit.isLocal = location.protocol === "file:"; QUnit.isLocal = location.protocol === "file:";
}()); }());
// Expose the API as global variables, unless an 'exports' object exists, // Export global variables, unless an 'exports' object exists,
// in that case we assume we're in CommonJS - export everything at the end // in that case we assume we're in CommonJS (dealt with on the bottom of the script)
if ( typeof exports === "undefined" ) { if ( typeof exports === "undefined" ) {
extend( window, QUnit ); extend( window, QUnit );
// Expose QUnit object
window.QUnit = QUnit; window.QUnit = QUnit;
} }
// define these after exposing globals to keep them in these QUnit namespace only // Extend QUnit object,
// these after set here because they should not be exposed as global functions
extend( QUnit, { extend( QUnit, {
config: config, config: config,
@ -722,22 +819,34 @@ extend( QUnit, {
}); });
}, },
pushFailure: function( message, source ) { pushFailure: function( message, source, actual ) {
if ( !config.current ) {
throw new Error( "pushFailure() assertion outside test context, was " + sourceFromStacktrace(2) );
}
var output, var output,
details = { details = {
result: false, result: false,
message: message message: message
}; };
message = escapeInnerText(message ) || "error"; message = escapeInnerText( message ) || "error";
message = "<span class='test-message'>" + message + "</span>"; message = "<span class='test-message'>" + message + "</span>";
output = message; output = message;
output += "<table>";
if ( actual ) {
output += "<tr class='test-actual'><th>Result: </th><td><pre>" + escapeInnerText( actual ) + "</pre></td></tr>";
}
if ( source ) { if ( source ) {
details.source = source; details.source = source;
output += "<table><tr class='test-source'><th>Source: </th><td><pre>" + escapeInnerText( source ) + "</pre></td></tr></table>"; output += "<tr class='test-source'><th>Source: </th><td><pre>" + escapeInnerText( source ) + "</pre></td></tr>";
} }
output += "</table>";
runLoggingCallbacks( "log", QUnit, details ); runLoggingCallbacks( "log", QUnit, details );
config.current.assertions.push({ config.current.assertions.push({
@ -764,25 +873,37 @@ extend( QUnit, {
extend: extend, extend: extend,
id: id, id: id,
addEvent: addEvent addEvent: addEvent
// load, equiv, jsDump, diff: Attached later
}); });
// QUnit.constructor is set to the empty F() above so that we can add to it's prototype later /**
// Doing this allows us to tell if the following methods have been overwritten on the actual * @deprecated: Created for backwards compatibility with test runner that set the hook function
// QUnit object, which is a deprecated way of using the callbacks. * into QUnit.{hook}, instead of invoking it and passing the hook function.
* QUnit.constructor is set to the empty F() above so that we can add to it's prototype here.
* Doing this allows us to tell if the following methods have been overwritten on the actual
* QUnit object.
*/
extend( QUnit.constructor.prototype, { extend( QUnit.constructor.prototype, {
// Logging callbacks; all receive a single argument with the listed properties // Logging callbacks; all receive a single argument with the listed properties
// run test/logs.html for any related changes // run test/logs.html for any related changes
begin: registerLoggingCallback( "begin" ), begin: registerLoggingCallback( "begin" ),
// done: { failed, passed, total, runtime } // done: { failed, passed, total, runtime }
done: registerLoggingCallback( "done" ), done: registerLoggingCallback( "done" ),
// log: { result, actual, expected, message } // log: { result, actual, expected, message }
log: registerLoggingCallback( "log" ), log: registerLoggingCallback( "log" ),
// testStart: { name } // testStart: { name }
testStart: registerLoggingCallback( "testStart" ), testStart: registerLoggingCallback( "testStart" ),
// testDone: { name, failed, passed, total } // testDone: { name, failed, passed, total }
testDone: registerLoggingCallback( "testDone" ), testDone: registerLoggingCallback( "testDone" ),
// moduleStart: { name } // moduleStart: { name }
moduleStart: registerLoggingCallback( "moduleStart" ), moduleStart: registerLoggingCallback( "moduleStart" ),
// moduleDone: { name, failed, passed, total } // moduleDone: { name, failed, passed, total }
moduleDone: registerLoggingCallback( "moduleDone" ) moduleDone: registerLoggingCallback( "moduleDone" )
}); });
@ -795,7 +916,7 @@ QUnit.load = function() {
runLoggingCallbacks( "begin", QUnit, {} ); runLoggingCallbacks( "begin", QUnit, {} );
// Initialize the config, saving the execution queue // Initialize the config, saving the execution queue
var banner, filter, i, label, len, main, ol, toolbar, userAgent, val, var banner, filter, i, label, len, main, ol, toolbar, userAgent, val, urlConfigCheckboxes,
urlConfigHtml = "", urlConfigHtml = "",
oldconfig = extend( {}, config ); oldconfig = extend( {}, config );
@ -808,8 +929,15 @@ QUnit.load = function() {
for ( i = 0; i < len; i++ ) { for ( i = 0; i < len; i++ ) {
val = config.urlConfig[i]; val = config.urlConfig[i];
config[val] = QUnit.urlParams[val]; if ( typeof val === "string" ) {
urlConfigHtml += "<label><input name='" + val + "' type='checkbox'" + ( config[val] ? " checked='checked'" : "" ) + ">" + val + "</label>"; val = {
id: val,
label: val,
tooltip: "[no tooltip available]"
};
}
config[ val.id ] = QUnit.urlParams[ val.id ];
urlConfigHtml += "<input id='qunit-urlconfig-" + val.id + "' name='" + val.id + "' type='checkbox'" + ( config[ val.id ] ? " checked='checked'" : "" ) + " title='" + val.tooltip + "'><label for='qunit-urlconfig-" + val.id + "' title='" + val.tooltip + "'>" + val.label + "</label>";
} }
// `userAgent` initialized at top of scope // `userAgent` initialized at top of scope
@ -821,12 +949,7 @@ QUnit.load = function() {
// `banner` initialized at top of scope // `banner` initialized at top of scope
banner = id( "qunit-header" ); banner = id( "qunit-header" );
if ( banner ) { if ( banner ) {
banner.innerHTML = "<a href='" + QUnit.url({ filter: undefined }) + "'>" + banner.innerHTML + "</a> " + urlConfigHtml; banner.innerHTML = "<a href='" + QUnit.url({ filter: undefined, module: undefined, testNumber: undefined }) + "'>" + banner.innerHTML + "</a> ";
addEvent( banner, "change", function( event ) {
var params = {};
params[ event.target.name ] = event.target.checked ? true : undefined;
window.location = QUnit.url( params );
});
} }
// `toolbar` initialized at top of scope // `toolbar` initialized at top of scope
@ -867,8 +990,18 @@ QUnit.load = function() {
// `label` initialized at top of scope // `label` initialized at top of scope
label = document.createElement( "label" ); label = document.createElement( "label" );
label.setAttribute( "for", "qunit-filter-pass" ); label.setAttribute( "for", "qunit-filter-pass" );
label.setAttribute( "title", "Only show tests and assertons that fail. Stored in sessionStorage." );
label.innerHTML = "Hide passed tests"; label.innerHTML = "Hide passed tests";
toolbar.appendChild( label ); toolbar.appendChild( label );
urlConfigCheckboxes = document.createElement( 'span' );
urlConfigCheckboxes.innerHTML = urlConfigHtml;
addEvent( urlConfigCheckboxes, "change", function( event ) {
var params = {};
params[ event.target.name ] = event.target.checked ? true : undefined;
window.location = QUnit.url( params );
});
toolbar.appendChild( urlConfigCheckboxes );
} }
// `main` initialized at top of scope // `main` initialized at top of scope
@ -884,15 +1017,36 @@ QUnit.load = function() {
addEvent( window, "load", QUnit.load ); addEvent( window, "load", QUnit.load );
// addEvent(window, "error" ) gives us a useless event object // `onErrorFnPrev` initialized at top of scope
window.onerror = function( message, file, line ) { // Preserve other handlers
if ( QUnit.config.current ) { onErrorFnPrev = window.onerror;
QUnit.pushFailure( message, file + ":" + line );
} else { // Cover uncaught exceptions
QUnit.test( "global failure", function() { // Returning true will surpress the default browser handler,
QUnit.pushFailure( message, file + ":" + line ); // returning false will let it run.
}); window.onerror = function ( error, filePath, linerNr ) {
var ret = false;
if ( onErrorFnPrev ) {
ret = onErrorFnPrev( error, filePath, linerNr );
} }
// Treat return value as window.onerror itself does,
// Only do our handling if not surpressed.
if ( ret !== true ) {
if ( QUnit.config.current ) {
if ( QUnit.config.current.ignoreGlobalErrors ) {
return true;
}
QUnit.pushFailure( error, filePath + ":" + linerNr );
} else {
QUnit.test( "global failure", function() {
QUnit.pushFailure( error, filePath + ":" + linerNr );
});
}
return false;
}
return ret;
}; };
function done() { function done() {
@ -962,39 +1116,46 @@ function done() {
}); });
} }
function validTest( name ) { /** @return Boolean: true if this test should be ran */
var not, function validTest( test ) {
filter = config.filter, var include,
run = false; filter = config.filter && config.filter.toLowerCase(),
module = config.module && config.module.toLowerCase(),
fullName = (test.module + ": " + test.testName).toLowerCase();
if ( config.testNumber ) {
return test.testNumber === config.testNumber;
}
if ( module && ( !test.module || test.module.toLowerCase() !== module ) ) {
return false;
}
if ( !filter ) { if ( !filter ) {
return true; return true;
} }
not = filter.charAt( 0 ) === "!"; include = filter.charAt( 0 ) !== "!";
if ( !include ) {
if ( not ) {
filter = filter.slice( 1 ); filter = filter.slice( 1 );
} }
if ( name.indexOf( filter ) !== -1 ) { // If the filter matches, we need to honour include
return !not; if ( fullName.indexOf( filter ) !== -1 ) {
return include;
} }
if ( not ) { // Otherwise, do the opposite
run = true; return !include;
}
return run;
} }
// so far supports only Firefox, Chrome and Opera (buggy), Safari (for real exceptions) // so far supports only Firefox, Chrome and Opera (buggy), Safari (for real exceptions)
// Later Safari and IE10 are supposed to support error.stack as well // Later Safari and IE10 are supposed to support error.stack as well
// See also https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error/Stack // See also https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error/Stack
function extractStacktrace( e, offset ) { function extractStacktrace( e, offset ) {
offset = offset || 3; offset = offset === undefined ? 3 : offset;
var stack; var stack, include, i, regex;
if ( e.stacktrace ) { if ( e.stacktrace ) {
// Opera // Opera
@ -1005,6 +1166,18 @@ function extractStacktrace( e, offset ) {
if (/^error$/i.test( stack[0] ) ) { if (/^error$/i.test( stack[0] ) ) {
stack.shift(); stack.shift();
} }
if ( fileName ) {
include = [];
for ( i = offset; i < stack.length; i++ ) {
if ( stack[ i ].indexOf( fileName ) != -1 ) {
break;
}
include.push( stack[ i ] );
}
if ( include.length ) {
return include.join( "\n" );
}
}
return stack[ offset ]; return stack[ offset ];
} else if ( e.sourceURL ) { } else if ( e.sourceURL ) {
// Safari, PhantomJS // Safari, PhantomJS
@ -1419,11 +1592,11 @@ QUnit.jsDump = (function() {
type = "null"; type = "null";
} else if ( typeof obj === "undefined" ) { } else if ( typeof obj === "undefined" ) {
type = "undefined"; type = "undefined";
} else if ( QUnit.is( "RegExp", obj) ) { } else if ( QUnit.is( "regexp", obj) ) {
type = "regexp"; type = "regexp";
} else if ( QUnit.is( "Date", obj) ) { } else if ( QUnit.is( "date", obj) ) {
type = "date"; type = "date";
} else if ( QUnit.is( "Function", obj) ) { } else if ( QUnit.is( "function", obj) ) {
type = "function"; type = "function";
} else if ( typeof obj.setInterval !== undefined && typeof obj.document !== "undefined" && typeof obj.nodeType === "undefined" ) { } else if ( typeof obj.setInterval !== undefined && typeof obj.document !== "undefined" && typeof obj.nodeType === "undefined" ) {
type = "window"; type = "window";

270
grunt.js
View File

@ -16,7 +16,7 @@ var // modules
"jquery.ui.resizable.js", "jquery.ui.resizable.js",
"jquery.ui.selectable.js", "jquery.ui.selectable.js",
"jquery.ui.sortable.js", "jquery.ui.sortable.js",
"jquery.effects.core.js" "jquery.ui.effect.js"
], ],
uiFiles = coreFiles.map(function( file ) { uiFiles = coreFiles.map(function( file ) {
@ -80,12 +80,14 @@ uiFiles.forEach(function( file ) {
compareFiles[ file ] = [ file, mapMinFile( file ) ]; compareFiles[ file ] = [ file, mapMinFile( file ) ];
}); });
// csslint and cssmin tasks // grunt plugins
grunt.loadNpmTasks( "grunt-css" ); grunt.loadNpmTasks( "grunt-css" );
// file size comparison tasks
grunt.loadNpmTasks( "grunt-compare-size" );
// html validation task
grunt.loadNpmTasks( "grunt-html" ); grunt.loadNpmTasks( "grunt-html" );
grunt.loadNpmTasks( "grunt-compare-size" );
grunt.loadNpmTasks( "grunt-junit" );
grunt.loadNpmTasks( "grunt-git-authors" );
// local testswarm and build tasks
grunt.loadTasks( "build/tasks" );
grunt.registerHelper( "strip_all_banners", function( filepath ) { grunt.registerHelper( "strip_all_banners", function( filepath ) {
return grunt.file.read( filepath ).replace( /^\s*\/\*[\s\S]*?\*\/\s*/g, "" ); return grunt.file.read( filepath ).replace( /^\s*\/\*[\s\S]*?\*\/\s*/g, "" );
@ -291,7 +293,7 @@ grunt.initConfig({
// TODO remove items from this list once rewritten // TODO remove items from this list once rewritten
return !( /(mouse|datepicker|draggable|droppable|resizable|selectable|sortable)\.js$/ ).test( file ); return !( /(mouse|datepicker|draggable|droppable|resizable|selectable|sortable)\.js$/ ).test( file );
}), }),
grunt: "grunt.js", grunt: [ "grunt.js", "build/tasks/*.js" ],
tests: "tests/unit/**/*.js" tests: "tests/unit/**/*.js"
}, },
csslint: { csslint: {
@ -340,262 +342,6 @@ grunt.initConfig({
})() })()
}); });
grunt.registerTask( "testswarm", function( commit, configFile ) {
var test,
testswarm = require( "testswarm" ),
testBase = "http://swarm.jquery.org/git/jquery-ui/" + commit + "/tests/unit/",
testUrls = [],
tests = {
"Accordion": "accordion/accordion.html",
"Accordion_deprecated": "accordion/accordion_deprecated.html",
"Autocomplete": "autocomplete/autocomplete.html",
"Button": "button/button.html",
"Core": "core/core.html",
//"datepicker/datepicker.html",
//"dialog/dialog.html",
//"draggable/draggable.html",
//"droppable/droppable.html",
"Effects": "effects/effects.html",
"Menu": "menu/menu.html",
"Position": "position/position.html",
"Position_deprecated": "position/position_deprecated.html",
"Progressbar": "progressbar/progressbar.html",
//"resizable/resizable.html",
//"selectable/selectable.html",
//"slider/slider.html",
//"sortable/sortable.html",
"Spinner": "spinner/spinner.html",
"Tabs": "tabs/tabs.html",
"Tabs_deprecated": "tabs/tabs_deprecated.html",
"Tooltip": "tooltip/tooltip.html",
"Widget": "widget/widget.html"
};
for ( test in tests ) {
testUrls.push( testBase + tests[ test ] + "?nojshint=true" );
}
testswarm({
url: "http://swarm.jquery.org/",
pollInterval: 10000,
timeout: 1000 * 60 * 30,
done: this.async()
}, {
authUsername: "jqueryui",
authToken: grunt.file.readJSON( configFile ).jqueryui.authToken,
jobName: 'jQuery UI commit #<a href="https://github.com/jquery/jquery-ui/commit/' + commit + '">' + commit.substr( 0, 10 ) + '</a>',
runMax: 3,
"runNames[]": Object.keys(tests),
"runUrls[]": testUrls,
"browserSets[]": ["popular"]
});
});
grunt.registerMultiTask( "copy", "Copy files to destination folder and replace @VERSION with pkg.version", function() {
function replaceVersion( source ) {
return source.replace( /@VERSION/g, grunt.config( "pkg.version" ) );
}
function copyFile( src, dest ) {
if ( /(js|css)$/.test( src ) ) {
grunt.file.copy( src, dest, {
process: replaceVersion
});
} else {
grunt.file.copy( src, dest );
}
}
var files = grunt.file.expandFiles( this.file.src ),
target = this.file.dest + "/",
strip = this.data.strip,
renameCount = 0,
fileName;
if ( typeof strip === "string" ) {
strip = new RegExp( "^" + grunt.template.process( strip, grunt.config() ).replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ) );
}
files.forEach(function( fileName ) {
var targetFile = strip ? fileName.replace( strip, "" ) : fileName;
copyFile( fileName, target + targetFile );
});
grunt.log.writeln( "Copied " + files.length + " files." );
for ( fileName in this.data.renames ) {
renameCount += 1;
copyFile( fileName, target + grunt.template.process( this.data.renames[ fileName ], grunt.config() ) );
}
if ( renameCount ) {
grunt.log.writeln( "Renamed " + renameCount + " files." );
}
});
grunt.registerMultiTask( "zip", "Create a zip file for release", function() {
// TODO switch back to adm-zip for better cross-platform compability once it actually works
// 0.1.3 works, but result can't be unzipped
// its also a lot slower then zip program, probably due to how its used...
// var files = grunt.file.expandFiles( "dist/" + this.file.src + "/**/*" );
// grunt.log.writeln( "Creating zip file " + this.file.dest );
//var AdmZip = require( "adm-zip" );
//var zip = new AdmZip();
//files.forEach(function( file ) {
// grunt.verbose.writeln( "Zipping " + file );
// // rewrite file names from dist folder (created by build), drop the /dist part
// zip.addFile(file.replace(/^dist/, "" ), fs.readFileSync( file ) );
//});
//zip.writeZip( "dist/" + this.file.dest );
//grunt.log.writeln( "Wrote " + files.length + " files to " + this.file.dest );
var done = this.async(),
dest = this.file.dest,
src = grunt.template.process( this.file.src, grunt.config() );
grunt.utils.spawn({
cmd: "zip",
args: [ "-r", dest, src ],
opts: {
cwd: 'dist'
}
}, function( err, result ) {
if ( err ) {
grunt.log.error( err );
done();
return;
}
grunt.log.writeln( "Zipped " + dest );
done();
});
});
grunt.registerMultiTask( "md5", "Create list of md5 hashes for CDN uploads", function() {
// remove dest file before creating it, to make sure itself is not included
if ( path.existsSync( this.file.dest ) ) {
fs.unlinkSync( this.file.dest );
}
var crypto = require( "crypto" ),
dir = this.file.src + "/",
hashes = [];
grunt.file.expandFiles( dir + "**/*" ).forEach(function( fileName ) {
var hash = crypto.createHash( "md5" );
hash.update( grunt.file.read( fileName, "ascii" ) );
hashes.push( fileName.replace( dir, "" ) + " " + hash.digest( "hex" ) );
});
grunt.file.write( this.file.dest, hashes.join( "\n" ) + "\n" );
grunt.log.writeln( "Wrote " + this.file.dest + " with " + hashes.length + " hashes" );
});
// only needed for 1.8
grunt.registerTask( "download_docs", function() {
function capitalize(value) {
return value[0].toUpperCase() + value.slice(1);
}
// should be grunt.config("pkg.version")?
var version = "1.8",
docsDir = "dist/docs",
files = "draggable droppable resizable selectable sortable accordion autocomplete button datepicker dialog progressbar slider tabs position"
.split(" ").map(function(widget) {
return {
url: "http://docs.jquery.com/action/render/UI/API/" + version + "/" + capitalize(widget),
dest: docsDir + '/' + widget + '.html'
};
});
files = files.concat("animate addClass effect hide removeClass show switchClass toggle toggleClass".split(" ").map(function(widget) {
return {
url: "http://docs.jquery.com/action/render/UI/Effects/" + widget,
dest: docsDir + '/' + widget + '.html'
};
}));
files = files.concat("Blind Clip Drop Explode Fade Fold Puff Slide Scale Bounce Highlight Pulsate Shake Size Transfer".split(" ").map(function(widget) {
return {
url: "http://docs.jquery.com/action/render/UI/Effects/" + widget,
dest: docsDir + '/effect-' + widget.toLowerCase() + '.html'
};
}));
grunt.file.mkdir( "dist/docs" );
grunt.utils.async.forEach( files, function( file, done ) {
var out = fs.createWriteStream( file.dest );
out.on( "close", done );
request( file.url ).pipe( out );
}, this.async() );
});
grunt.registerTask( "download_themes", function() {
// var AdmZip = require('adm-zip');
var done = this.async(),
themes = grunt.file.read( "build/themes" ).split(","),
requests = 0;
grunt.file.mkdir( "dist/tmp" );
themes.forEach(function( theme, index ) {
requests += 1;
grunt.file.mkdir( "dist/tmp/" + index );
var zipFileName = "dist/tmp/" + index + ".zip",
out = fs.createWriteStream( zipFileName );
out.on( "close", function() {
grunt.log.writeln( "done downloading " + zipFileName );
// TODO AdmZip produces "crc32 checksum failed", need to figure out why
// var zip = new AdmZip(zipFileName);
// zip.extractAllTo('dist/tmp/' + index + '/');
// until then, using cli unzip...
grunt.utils.spawn({
cmd: "unzip",
args: [ "-d", "dist/tmp/" + index, zipFileName ]
}, function( err, result ) {
grunt.log.writeln( "Unzipped " + zipFileName + ", deleting it now" );
fs.unlinkSync( zipFileName );
requests -= 1;
if (requests === 0) {
done();
}
});
});
request( "http://ui-dev.jquery.com/download/?" + theme ).pipe( out );
});
});
grunt.registerTask( "copy_themes", function() {
// each package includes the base theme, ignore that
var filter = /themes\/base/,
files = grunt.file.expandFiles( "dist/tmp/*/development-bundle/themes/**/*" ).filter(function( file ) {
return !filter.test( file );
}),
// TODO the grunt.template.process call shouldn't be necessary
target = "dist/" + grunt.template.process( grunt.config( "files.themes" ), grunt.config() ) + "/",
distFolder = "dist/" + grunt.template.process( grunt.config( "files.dist" ), grunt.config() );
files.forEach(function( fileName ) {
var targetFile = fileName.replace( /dist\/tmp\/\d+\/development-bundle\//, "" ).replace( "jquery-ui-.custom", "jquery-ui" );
grunt.file.copy( fileName, target + targetFile );
});
// copy minified base theme from regular release
files = grunt.file.expandFiles( distFolder + "/themes/base/**/*" );
files.forEach(function( fileName ) {
grunt.file.copy( fileName, target + fileName.replace( distFolder, "" ) );
});
});
grunt.registerTask( "clean", function() {
require( "rimraf" ).sync( "dist" );
});
grunt.registerTask( "authors", function() {
var done = this.async();
grunt.utils.spawn({
cmd: "git",
args: [ "log", "--pretty=%an <%ae>" ]
}, function( err, result ) {
if ( err ) {
grunt.log.error( err );
return done( false );
}
var authors,
tracked = {};
authors = result.split( "\n" ).reverse().filter(function( author ) {
var first = !tracked[ author ];
tracked[ author ] = true;
return first;
}).join( "\n" );
grunt.log.writeln( authors );
done();
});
});
grunt.registerTask( "default", "lint csslint htmllint qunit" ); grunt.registerTask( "default", "lint csslint htmllint qunit" );
grunt.registerTask( "sizer", "concat:ui min:dist/jquery-ui.min.js compare_size:all" ); grunt.registerTask( "sizer", "concat:ui min:dist/jquery-ui.min.js compare_size:all" );
grunt.registerTask( "sizer_all", "concat:ui min compare_size" ); grunt.registerTask( "sizer_all", "concat:ui min compare_size" );

View File

@ -1,38 +1,66 @@
{ {
"name": "jquery-ui", "name": "jquery-ui",
"title": "jQuery UI", "title": "jQuery UI",
"description": "Abstractions for low-level interaction and animation, advanced effects and high-level, themeable widgets, built on top of the jQuery JavaScript Library, that you can use to build highly interactive web applications.", "description": "A curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library.",
"version": "1.9.0pre", "version": "1.9.0pre",
"homepage": "https://github.com/jquery/jquery-ui", "homepage": "http://jqueryui.com",
"author": { "author": {
"name": "AUTHORS.txt" "name": "jQuery Foundation and other contributors",
}, "url": "http://jqueryui.com"
"repository": { },
"type": "git", "maintainers": [
"url": "git://github.com/jquery/jquery-ui.git" {
}, "name": "Scott González",
"bugs": { "email": "scott.gonzalez@gmail.com",
"url": "http://bugs.jqueryui.com/" "url": "http://scottgonzalez.com"
}, },
"licenses": [ {
{ "name": "Jörn Zaefferer",
"type": "MIT", "email": "joern.zaefferer@gmail.com",
"url": "http://www.opensource.org/licenses/MIT" "url": "http://bassistance.de"
}, },
{ {
"type": "GPL", "name": "Richard D. Worth",
"url": "http://www.opensource.org/licenses/GPL-2.0" "email": "rdworth@gmail.com",
} "url": "http://rdworth.org"
], },
"dependencies": {}, {
"devDependencies": { "name": "Kris Borchers",
"grunt": "0.3.9", "email": "kris.borchers@gmail.com",
"grunt-css": "0.2.0", "url": "http://krisborchers.com"
"grunt-compare-size": "0.1.4", },
"grunt-html": "0.1.1", {
"request": "2.9.153", "name": "Corey Frang",
"rimraf": "2.0.1", "email": "gnarf37@gmail.com",
"testswarm": "0.2.2" "url": "http://gnarf.net"
}, }
"keywords": [] ],
"repository": {
"type": "git",
"url": "git://github.com/jquery/jquery-ui.git"
},
"bugs": "http://bugs.jqueryui.com/",
"licenses": [
{
"type": "MIT",
"url": "http://www.opensource.org/licenses/MIT"
},
{
"type": "GPL",
"url": "http://www.opensource.org/licenses/GPL-2.0"
}
],
"dependencies": {},
"devDependencies": {
"grunt": "~0.3.9",
"grunt-css": "0.2.0",
"grunt-compare-size": "0.1.4",
"grunt-html": "0.1.1",
"grunt-junit": "0.1.4",
"grunt-git-authors": "1.0.0",
"request": "2.9.153",
"rimraf": "2.0.1",
"testswarm": "0.2.3"
},
"keywords": []
} }

View File

@ -1,7 +1,8 @@
/* /*
* jquery.simulate - simulate browser mouse and keyboard events * jquery.simulate - simulate browser mouse and keyboard events
* http://jqueryui.com
* *
* Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) * Copyright 2012 jQuery Foundation and other contributors
* Dual licensed under the MIT or GPL Version 2 licenses. * Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license * http://jquery.org/license
*/ */

View File

@ -48,31 +48,31 @@ test( "accessibility", function () {
equal( headers.eq( 1 ).attr( "aria-selected" ), "true", "active tab has aria-selected=true" ); equal( headers.eq( 1 ).attr( "aria-selected" ), "true", "active tab has aria-selected=true" );
equal( headers.eq( 1 ).next().attr( "aria-expanded" ), "true", "active tabpanel has aria-expanded=true" ); equal( headers.eq( 1 ).next().attr( "aria-expanded" ), "true", "active tabpanel has aria-expanded=true" );
equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "false", "active tabpanel has aria-hidden=false" ); equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "false", "active tabpanel has aria-hidden=false" );
equal( headers.eq( 0 ).attr( "tabindex" ), -1, "active header has tabindex=-1" ); equal( headers.eq( 0 ).attr( "tabindex" ), -1, "inactive header has tabindex=-1" );
equal( headers.eq( 0 ).attr( "aria-selected" ), "false", "active tab has aria-selected=false" ); equal( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
equal( headers.eq( 0 ).next().attr( "aria-expanded" ), "false", "active tabpanel has aria-expanded=false" ); equal( headers.eq( 0 ).next().attr( "aria-expanded" ), "false", "inactive tabpanel has aria-expanded=false" );
equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "true", "active tabpanel has aria-hidden=true" ); equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel has aria-hidden=true" );
equal( headers.eq( 2 ).attr( "tabindex" ), -1, "active header has tabindex=-1" ); equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header has tabindex=-1" );
equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "active tab has aria-selected=false" ); equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
equal( headers.eq( 2 ).next().attr( "aria-expanded" ), "false", "active tabpanel has aria-expanded=false" ); equal( headers.eq( 2 ).next().attr( "aria-expanded" ), "false", "inactive tabpanel has aria-expanded=false" );
equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "active tabpanel has aria-hidden=true" ); equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel has aria-hidden=true" );
element.accordion( "option", "active", 0 ); element.accordion( "option", "active", 0 );
equal( headers.eq( 0 ).attr( "tabindex" ), 0, "active header has tabindex=0" ); equal( headers.eq( 0 ).attr( "tabindex" ), 0, "active header has tabindex=0" );
equal( headers.eq( 0 ).attr( "aria-selected" ), "true", "active tab has aria-selected=true" ); equal( headers.eq( 0 ).attr( "aria-selected" ), "true", "active tab has aria-selected=true" );
equal( headers.eq( 0 ).next().attr( "aria-expanded" ), "true", "active tabpanel has aria-expanded=true" ); equal( headers.eq( 0 ).next().attr( "aria-expanded" ), "true", "active tabpanel has aria-expanded=true" );
equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "false", "active tabpanel has aria-hidden=false" ); equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "false", "active tabpanel has aria-hidden=false" );
equal( headers.eq( 1 ).attr( "tabindex" ), -1, "active header has tabindex=-1" ); equal( headers.eq( 1 ).attr( "tabindex" ), -1, "inactive header has tabindex=-1" );
equal( headers.eq( 1 ).attr( "aria-selected" ), "false", "active tab has aria-selected=false" ); equal( headers.eq( 1 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
equal( headers.eq( 1 ).next().attr( "aria-expanded" ), "false", "active tabpanel has aria-expanded=false" ); equal( headers.eq( 1 ).next().attr( "aria-expanded" ), "false", "inactive tabpanel has aria-expanded=false" );
equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "true", "active tabpanel has aria-hidden=true" ); equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel has aria-hidden=true" );
equal( headers.eq( 2 ).attr( "tabindex" ), -1, "active header has tabindex=-1" ); equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header has tabindex=-1" );
equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "active tab has aria-selected=false" ); equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
equal( headers.eq( 2 ).next().attr( "aria-expanded" ), "false", "active tabpanel has aria-expanded=false" ); equal( headers.eq( 2 ).next().attr( "aria-expanded" ), "false", "inactive tabpanel has aria-expanded=false" );
equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "active tabpanel has aria-hidden=true" ); equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel has aria-hidden=true" );
}); });
asyncTest( "keybaord support", function() { asyncTest( "keyboard support", function() {
expect( 13 ); expect( 13 );
var element = $( "#list1" ).accordion(), var element = $( "#list1" ).accordion(),
headers = element.find( ".ui-accordion-header" ), headers = element.find( ".ui-accordion-header" ),

View File

@ -1,6 +1,6 @@
(function( $ ) { (function( $ ) {
var equalHeights = TestHelpers.accordion.equalHeights, var equalHeight = TestHelpers.accordion.equalHeight,
setupTeardown = TestHelpers.accordion.setupTeardown, setupTeardown = TestHelpers.accordion.setupTeardown,
state = TestHelpers.accordion.state; state = TestHelpers.accordion.state;
@ -109,7 +109,7 @@ module( "accordion (deprecated) - height options", setupTeardown() );
test( "{ autoHeight: true }, default", function() { test( "{ autoHeight: true }, default", function() {
expect( 3 ); expect( 3 );
equalHeights( $( "#navigation" ).accordion({ autoHeight: true }), 95, 130 ); equalHeight( $( "#navigation" ).accordion({ autoHeight: true }), 105 );
}); });
test( "{ autoHeight: false }", function() { test( "{ autoHeight: false }", function() {
@ -128,7 +128,7 @@ test( "{ fillSpace: true }", function() {
expect( 3 ); expect( 3 );
$( "#navigationWrapper" ).height( 500 ); $( "#navigationWrapper" ).height( 500 );
var element = $( "#navigation" ).accordion({ fillSpace: true }); var element = $( "#navigation" ).accordion({ fillSpace: true });
equalHeights( element, 446, 458 ); equalHeight( element, 455 );
}); });
test( "{ fillSapce: true } with sibling", function() { test( "{ fillSapce: true } with sibling", function() {
@ -142,7 +142,7 @@ test( "{ fillSapce: true } with sibling", function() {
}) })
.prependTo( "#navigationWrapper" ); .prependTo( "#navigationWrapper" );
var element = $( "#navigation" ).accordion({ fillSpace: true }); var element = $( "#navigation" ).accordion({ fillSpace: true });
equalHeights( element , 346, 358); equalHeight( element , 355 );
}); });
test( "{ fillSpace: true } with multiple siblings", function() { test( "{ fillSpace: true } with multiple siblings", function() {
@ -171,7 +171,7 @@ test( "{ fillSpace: true } with multiple siblings", function() {
}) })
.prependTo( "#navigationWrapper" ); .prependTo( "#navigationWrapper" );
var element = $( "#navigation" ).accordion({ fillSpace: true }); var element = $( "#navigation" ).accordion({ fillSpace: true });
equalHeights( element, 296, 308 ); equalHeight( element, 305 );
}); });
@ -206,11 +206,11 @@ test( "resize", function() {
.accordion({ .accordion({
heightStyle: "fill" heightStyle: "fill"
}); });
equalHeights( element, 246, 258 ); equalHeight( element, 255 );
element.parent().height( 500 ); element.parent().height( 500 );
element.accordion( "resize" ); element.accordion( "resize" );
equalHeights( element, 446, 458 ); equalHeight( element, 455 );
}); });

View File

@ -56,11 +56,11 @@ test( "beforeActivate", function() {
element.one( "accordionbeforeactivate", function( event, ui ) { element.one( "accordionbeforeactivate", function( event, ui ) {
ok( !( "originalEvent" in event ) ); ok( !( "originalEvent" in event ) );
equal( ui.oldHeader.length, 0 ); equal( ui.oldHeader.length, 0 );
equal( ui.oldContent.length, 0 ); equal( ui.oldPanel.length, 0 );
equal( ui.newHeader.length, 1 ); equal( ui.newHeader.length, 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 0 ] ); strictEqual( ui.newHeader[ 0 ], headers[ 0 ] );
equal( ui.newContent.length, 1 ); equal( ui.newPanel.length, 1 );
strictEqual( ui.newContent[ 0 ], content[ 0 ] ); strictEqual( ui.newPanel[ 0 ], content[ 0 ] );
state( element, 0, 0, 0 ); state( element, 0, 0, 0 );
}); });
element.accordion( "option", "active", 0 ); element.accordion( "option", "active", 0 );
@ -70,12 +70,12 @@ test( "beforeActivate", function() {
equal( event.originalEvent.type, "click" ); equal( event.originalEvent.type, "click" );
equal( ui.oldHeader.length, 1 ); equal( ui.oldHeader.length, 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] ); strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] );
equal( ui.oldContent.length, 1 ); equal( ui.oldPanel.length, 1 );
strictEqual( ui.oldContent[ 0 ], content[ 0 ] ); strictEqual( ui.oldPanel[ 0 ], content[ 0 ] );
equal( ui.newHeader.length, 1 ); equal( ui.newHeader.length, 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 1 ] ); strictEqual( ui.newHeader[ 0 ], headers[ 1 ] );
equal( ui.newContent.length, 1 ); equal( ui.newPanel.length, 1 );
strictEqual( ui.newContent[ 0 ], content[ 1 ] ); strictEqual( ui.newPanel[ 0 ], content[ 1 ] );
state( element, 1, 0, 0 ); state( element, 1, 0, 0 );
}); });
headers.eq( 1 ).click(); headers.eq( 1 ).click();
@ -85,10 +85,10 @@ test( "beforeActivate", function() {
ok( !( "originalEvent" in event ) ); ok( !( "originalEvent" in event ) );
equal( ui.oldHeader.length, 1 ); equal( ui.oldHeader.length, 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] ); strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] );
equal( ui.oldContent.length, 1 ); equal( ui.oldPanel.length, 1 );
strictEqual( ui.oldContent[ 0 ], content[ 1 ] ); strictEqual( ui.oldPanel[ 0 ], content[ 1 ] );
equal( ui.newHeader.length, 0 ); equal( ui.newHeader.length, 0 );
equal( ui.newContent.length, 0 ); equal( ui.newPanel.length, 0 );
state( element, 0, 1, 0 ); state( element, 0, 1, 0 );
}); });
element.accordion( "option", "active", false ); element.accordion( "option", "active", false );
@ -97,11 +97,11 @@ test( "beforeActivate", function() {
element.one( "accordionbeforeactivate", function( event, ui ) { element.one( "accordionbeforeactivate", function( event, ui ) {
ok( !( "originalEvent" in event ) ); ok( !( "originalEvent" in event ) );
equal( ui.oldHeader.length, 0 ); equal( ui.oldHeader.length, 0 );
equal( ui.oldContent.length, 0 ); equal( ui.oldPanel.length, 0 );
equal( ui.newHeader.length, 1 ); equal( ui.newHeader.length, 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 2 ] ); strictEqual( ui.newHeader[ 0 ], headers[ 2 ] );
equal( ui.newContent.length, 1 ); equal( ui.newPanel.length, 1 );
strictEqual( ui.newContent[ 0 ], content[ 2 ] ); strictEqual( ui.newPanel[ 0 ], content[ 2 ] );
event.preventDefault(); event.preventDefault();
state( element, 0, 0, 0 ); state( element, 0, 0, 0 );
}); });
@ -120,33 +120,33 @@ test( "activate", function() {
element.one( "accordionactivate", function( event, ui ) { element.one( "accordionactivate", function( event, ui ) {
equal( ui.oldHeader.length, 0 ); equal( ui.oldHeader.length, 0 );
equal( ui.oldContent.length, 0 ); equal( ui.oldPanel.length, 0 );
equal( ui.newHeader.length, 1 ); equal( ui.newHeader.length, 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 0 ] ); strictEqual( ui.newHeader[ 0 ], headers[ 0 ] );
equal( ui.newContent.length, 1 ); equal( ui.newPanel.length, 1 );
strictEqual( ui.newContent[ 0 ], content[ 0 ] ); strictEqual( ui.newPanel[ 0 ], content[ 0 ] );
}); });
element.accordion( "option", "active", 0 ); element.accordion( "option", "active", 0 );
element.one( "accordionactivate", function( event, ui ) { element.one( "accordionactivate", function( event, ui ) {
equal( ui.oldHeader.length, 1 ); equal( ui.oldHeader.length, 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] ); strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] );
equal( ui.oldContent.length, 1 ); equal( ui.oldPanel.length, 1 );
strictEqual( ui.oldContent[ 0 ], content[ 0 ] ); strictEqual( ui.oldPanel[ 0 ], content[ 0 ] );
equal( ui.newHeader.length, 1 ); equal( ui.newHeader.length, 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 1 ] ); strictEqual( ui.newHeader[ 0 ], headers[ 1 ] );
equal( ui.newContent.length, 1 ); equal( ui.newPanel.length, 1 );
strictEqual( ui.newContent[ 0 ], content[ 1 ] ); strictEqual( ui.newPanel[ 0 ], content[ 1 ] );
}); });
headers.eq( 1 ).click(); headers.eq( 1 ).click();
element.one( "accordionactivate", function( event, ui ) { element.one( "accordionactivate", function( event, ui ) {
equal( ui.oldHeader.length, 1 ); equal( ui.oldHeader.length, 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] ); strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] );
equal( ui.oldContent.length, 1 ); equal( ui.oldPanel.length, 1 );
strictEqual( ui.oldContent[ 0 ], content[ 1 ] ); strictEqual( ui.oldPanel[ 0 ], content[ 1 ] );
equal( ui.newHeader.length, 0 ); equal( ui.newHeader.length, 0 );
equal( ui.newContent.length, 0 ); equal( ui.newPanel.length, 0 );
}); });
element.accordion( "option", "active", false ); element.accordion( "option", "active", false );

View File

@ -1,6 +1,6 @@
(function( $ ) { (function( $ ) {
var equalHeights = TestHelpers.accordion.equalHeights, var equalHeight = TestHelpers.accordion.equalHeight,
setupTeardown = TestHelpers.accordion.setupTeardown, setupTeardown = TestHelpers.accordion.setupTeardown,
state = TestHelpers.accordion.state; state = TestHelpers.accordion.state;
@ -38,11 +38,11 @@ test( "refresh", function() {
.accordion({ .accordion({
heightStyle: "fill" heightStyle: "fill"
}); });
equalHeights( element, 246, 258 ); equalHeight( element, 255 );
element.parent().height( 500 ); element.parent().height( 500 );
element.accordion( "refresh" ); element.accordion( "refresh" );
equalHeights( element, 446, 458 ); equalHeight( element, 455 );
}); });
}( jQuery ) ); }( jQuery ) );

View File

@ -1,6 +1,6 @@
(function( $ ) { (function( $ ) {
var equalHeights = TestHelpers.accordion.equalHeights, var equalHeight = TestHelpers.accordion.equalHeight,
setupTeardown = TestHelpers.accordion.setupTeardown, setupTeardown = TestHelpers.accordion.setupTeardown,
state = TestHelpers.accordion.state; state = TestHelpers.accordion.state;
@ -359,7 +359,7 @@ test( "{ header: custom }", function() {
test( "{ heightStyle: 'auto' }", function() { test( "{ heightStyle: 'auto' }", function() {
expect( 3 ); expect( 3 );
var element = $( "#navigation" ).accordion({ heightStyle: "auto" }); var element = $( "#navigation" ).accordion({ heightStyle: "auto" });
equalHeights( element, 95, 130 ); equalHeight( element, 105 );
}); });
test( "{ heightStyle: 'content' }", function() { test( "{ heightStyle: 'content' }", function() {
@ -368,16 +368,16 @@ test( "{ heightStyle: 'content' }", function() {
sizes = element.find( ".ui-accordion-content" ).map(function() { sizes = element.find( ".ui-accordion-content" ).map(function() {
return $( this ).height(); return $( this ).height();
}).get(); }).get();
ok( sizes[ 0 ] >= 70 && sizes[ 0 ] <= 105, "was " + sizes[ 0 ] ); equal( sizes[ 0 ], 75 );
ok( sizes[ 1 ] >= 98 && sizes[ 1 ] <= 126, "was " + sizes[ 1 ] ); equal( sizes[ 1 ], 105 );
ok( sizes[ 2 ] >= 42 && sizes[ 2 ] <= 54, "was " + sizes[ 2 ] ); equal( sizes[ 2 ], 45 );
}); });
test( "{ heightStyle: 'fill' }", function() { test( "{ heightStyle: 'fill' }", function() {
expect( 3 ); expect( 3 );
$( "#navigationWrapper" ).height( 500 ); $( "#navigationWrapper" ).height( 500 );
var element = $( "#navigation" ).accordion({ heightStyle: "fill" }); var element = $( "#navigation" ).accordion({ heightStyle: "fill" });
equalHeights( element, 446, 458 ); equalHeight( element, 455 );
}); });
test( "{ heightStyle: 'fill' } with sibling", function() { test( "{ heightStyle: 'fill' } with sibling", function() {
@ -391,7 +391,7 @@ test( "{ heightStyle: 'fill' } with sibling", function() {
}) })
.prependTo( "#navigationWrapper" ); .prependTo( "#navigationWrapper" );
var element = $( "#navigation" ).accordion({ heightStyle: "fill" }); var element = $( "#navigation" ).accordion({ heightStyle: "fill" });
equalHeights( element , 346, 358); equalHeight( element , 355 );
}); });
test( "{ heightStyle: 'fill' } with multiple siblings", function() { test( "{ heightStyle: 'fill' } with multiple siblings", function() {
@ -420,7 +420,7 @@ test( "{ heightStyle: 'fill' } with multiple siblings", function() {
}) })
.prependTo( "#navigationWrapper" ); .prependTo( "#navigationWrapper" );
var element = $( "#navigation" ).accordion({ heightStyle: "fill" }); var element = $( "#navigation" ).accordion({ heightStyle: "fill" });
equalHeights( element, 296, 308 ); equalHeight( element, 305 );
}); });
test( "{ icons: false }", function() { test( "{ icons: false }", function() {

View File

@ -1,13 +1,8 @@
TestHelpers.accordion = { TestHelpers.accordion = {
equalHeights: function( accordion, min, max ) { equalHeight: function( accordion, height ) {
var sizes = [];
accordion.find( ".ui-accordion-content" ).each(function() { accordion.find( ".ui-accordion-content" ).each(function() {
sizes.push( $( this ).outerHeight() ); equal( $( this ).outerHeight(), height );
}); });
ok( sizes[ 0 ] >= min && sizes[ 0 ] <= max,
"must be within " + min + " and " + max + ", was " + sizes[ 0 ] );
deepEqual( sizes[ 0 ], sizes[ 1 ] );
deepEqual( sizes[ 0 ], sizes[ 2 ] );
}, },
setupTeardown: function() { setupTeardown: function() {

View File

@ -8,6 +8,7 @@
module("button: core"); module("button: core");
test("checkbox", function() { test("checkbox", function() {
expect( 4 );
var input = $("#check"), var input = $("#check"),
label = $("label[for=check]"); label = $("label[for=check]");
ok( input.is(":visible") ); ok( input.is(":visible") );
@ -18,6 +19,7 @@ test("checkbox", function() {
}); });
test("radios", function() { test("radios", function() {
expect( 4 );
var inputs = $("#radio0 input"), var inputs = $("#radio0 input"),
labels = $("#radio0 label"); labels = $("#radio0 label");
ok( inputs.is(":visible") ); ok( inputs.is(":visible") );
@ -34,6 +36,7 @@ function assert(noForm, form1, form2) {
} }
test("radio groups", function() { test("radio groups", function() {
expect( 12 );
$("input[type=radio]").button(); $("input[type=radio]").button();
assert(":eq(0)", ":eq(1)", ":eq(2)"); assert(":eq(0)", ":eq(1)", ":eq(2)");
@ -51,6 +54,7 @@ test("radio groups", function() {
}); });
test("input type submit, don't create child elements", function() { test("input type submit, don't create child elements", function() {
expect( 2 );
var input = $("#submit"); var input = $("#submit");
deepEqual( input.children().length, 0 ); deepEqual( input.children().length, 0 );
input.button(); input.button();
@ -58,6 +62,7 @@ test("input type submit, don't create child elements", function() {
}); });
test("buttonset", function() { test("buttonset", function() {
expect( 6 );
var set = $("#radio1").buttonset(); var set = $("#radio1").buttonset();
ok( set.is(".ui-buttonset") ); ok( set.is(".ui-buttonset") );
deepEqual( set.children(".ui-button").length, 3 ); deepEqual( set.children(".ui-button").length, 3 );
@ -68,6 +73,7 @@ test("buttonset", function() {
}); });
test("buttonset (rtl)", function() { test("buttonset (rtl)", function() {
expect( 6 );
var set, var set,
parent = $("#radio1").parent(); parent = $("#radio1").parent();
// Set to rtl // Set to rtl

View File

@ -7,13 +7,10 @@
module("button: methods"); module("button: methods");
test("destroy", function() { test("destroy", function() {
var beforeHtml = $("#button").parent().html(), expect( 1 );
afterHtml = $("#button").button().button("destroy").parent().html(); domEqual( "#button", function() {
// Opera 9 outputs role="" instead of removing the attribute like everyone else $( "#button" ).button().button( "destroy" );
if ($.browser.opera) { });
afterHtml = afterHtml.replace(/ role=""/g, "");
}
equal( afterHtml, beforeHtml );
}); });
})(jQuery); })(jQuery);

View File

@ -6,6 +6,7 @@
module("button: options"); module("button: options");
test("disabled, explicit value", function() { test("disabled, explicit value", function() {
expect( 4 );
$("#radio01").button({ disabled: false }); $("#radio01").button({ disabled: false });
deepEqual(false, $("#radio01").button("option", "disabled"), deepEqual(false, $("#radio01").button("option", "disabled"),
"disabled option set to false"); "disabled option set to false");
@ -18,6 +19,7 @@ test("disabled, explicit value", function() {
}); });
test("disabled, null", function() { test("disabled, null", function() {
expect( 4 );
$("#radio01").button({ disabled: null }); $("#radio01").button({ disabled: null });
deepEqual(false, $("#radio01").button("option", "disabled"), deepEqual(false, $("#radio01").button("option", "disabled"),
"disabled option set to false"); "disabled option set to false");
@ -30,6 +32,7 @@ test("disabled, null", function() {
}); });
test("text false without icon", function() { test("text false without icon", function() {
expect( 1 );
$("#button").button({ $("#button").button({
text: false text: false
}); });
@ -39,6 +42,7 @@ test("text false without icon", function() {
}); });
test("text false with icon", function() { test("text false with icon", function() {
expect( 1 );
$("#button").button({ $("#button").button({
text: false, text: false,
icons: { icons: {
@ -51,6 +55,7 @@ test("text false with icon", function() {
}); });
test("label, default", function() { test("label, default", function() {
expect( 2 );
$("#button").button(); $("#button").button();
deepEqual( $("#button").text(), "Label" ); deepEqual( $("#button").text(), "Label" );
deepEqual( $( "#button").button( "option", "label" ), "Label" ); deepEqual( $( "#button").button( "option", "label" ), "Label" );
@ -59,6 +64,7 @@ test("label, default", function() {
}); });
test("label", function() { test("label", function() {
expect( 2 );
$("#button").button({ $("#button").button({
label: "xxx" label: "xxx"
}); });
@ -69,11 +75,13 @@ test("label", function() {
}); });
test("label default with input type submit", function() { test("label default with input type submit", function() {
expect( 2 );
deepEqual( $("#submit").button().val(), "Label" ); deepEqual( $("#submit").button().val(), "Label" );
deepEqual( $("#submit").button( "option", "label" ), "Label" ); deepEqual( $("#submit").button( "option", "label" ), "Label" );
}); });
test("label with input type submit", function() { test("label with input type submit", function() {
expect( 2 );
var label = $("#submit").button({ var label = $("#submit").button({
label: "xxx" label: "xxx"
}).val(); }).val();
@ -82,6 +90,7 @@ test("label with input type submit", function() {
}); });
test("icons", function() { test("icons", function() {
expect( 1 );
$("#button").button({ $("#button").button({
text: false, text: false,
icons: { icons: {

View File

@ -6,6 +6,7 @@
module( "button: tickets" ); module( "button: tickets" );
test( "#5946 - buttonset should ignore buttons that are not :visible", function() { test( "#5946 - buttonset should ignore buttons that are not :visible", function() {
expect( 2 );
$( "#radio01" ).next().andSelf().hide(); $( "#radio01" ).next().andSelf().hide();
var set = $( "#radio0" ).buttonset({ items: "input[type=radio]:visible" }); var set = $( "#radio0" ).buttonset({ items: "input[type=radio]:visible" });
ok( set.find( "label:eq(0)" ).is( ":not(.ui-button):not(.ui-corner-left)" ) ); ok( set.find( "label:eq(0)" ).is( ":not(.ui-button):not(.ui-corner-left)" ) );
@ -13,6 +14,7 @@ test( "#5946 - buttonset should ignore buttons that are not :visible", function(
}); });
test( "#6262 - buttonset not applying ui-corner to invisible elements", function() { test( "#6262 - buttonset not applying ui-corner to invisible elements", function() {
expect( 3 );
$( "#radio0" ).hide(); $( "#radio0" ).hide();
var set = $( "#radio0" ).buttonset(); var set = $( "#radio0" ).buttonset();
ok( set.find( "label:eq(0)" ).is( ".ui-button.ui-corner-left" ) ); ok( set.find( "label:eq(0)" ).is( ".ui-button.ui-corner-left" ) );
@ -21,6 +23,7 @@ test( "#6262 - buttonset not applying ui-corner to invisible elements", function
}); });
test( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard Navigation", function() { test( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard Navigation", function() {
expect( 2 );
var check = $( "#check" ).button(), var check = $( "#check" ).button(),
label = $( "label[for='check']" ); label = $( "label[for='check']" );
ok( !label.is( ".ui-state-focus" ) ); ok( !label.is( ".ui-state-focus" ) );
@ -29,6 +32,7 @@ test( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard
}); });
test( "#7092 - button creation that requires a matching label does not find label in all cases", function() { test( "#7092 - button creation that requires a matching label does not find label in all cases", function() {
expect( 5 );
var group = $( "<span><label for='t7092a'></label><input type='checkbox' id='t7092a'></span>" ); var group = $( "<span><label for='t7092a'></label><input type='checkbox' id='t7092a'></span>" );
group.find( "input[type=checkbox]" ).button(); group.find( "input[type=checkbox]" ).button();
ok( group.find( "label" ).is( ".ui-button" ) ); ok( group.find( "label" ).is( ".ui-button" ) );
@ -51,6 +55,7 @@ test( "#7092 - button creation that requires a matching label does not find labe
}); });
test( "#7534 - Button label selector works for ids with \":\"", function() { test( "#7534 - Button label selector works for ids with \":\"", function() {
expect( 1 );
var group = $( "<span><input type='checkbox' id='check:7534'><label for='check:7534'>Label</label></span>" ); var group = $( "<span><input type='checkbox' id='check:7534'><label for='check:7534'>Label</label></span>" );
group.find( "input" ).button(); group.find( "input" ).button();
ok( group.find( "label" ).is( ".ui-button" ), "Found an id with a :" ); ok( group.find( "label" ).is( ".ui-button" ), "Found an id with a :" );

View File

@ -2,7 +2,7 @@
module( "core - jQuery extensions" ); module( "core - jQuery extensions" );
TestHelpers.testJshint( "ui.core" ); TestHelpers.testJshint( "core" );
test( "focus - original functionality", function() { test( "focus - original functionality", function() {
expect( 1 ); expect( 1 );
@ -28,6 +28,7 @@ asyncTest( "focus", function() {
}); });
test( "zIndex", function() { test( "zIndex", function() {
expect( 7 );
var el = $( "#zIndexAutoWithParent" ), var el = $( "#zIndexAutoWithParent" ),
parent = el.parent(); parent = el.parent();
equal( el.zIndex(), 100, "zIndex traverses up to find value" ); equal( el.zIndex(), 100, "zIndex traverses up to find value" );
@ -46,6 +47,7 @@ test( "zIndex", function() {
}); });
test( "innerWidth - getter", function() { test( "innerWidth - getter", function() {
expect( 2 );
var el = $( "#dimensions" ); var el = $( "#dimensions" );
equal( el.innerWidth(), 122, "getter passthru" ); equal( el.innerWidth(), 122, "getter passthru" );
@ -54,6 +56,7 @@ test( "innerWidth - getter", function() {
}); });
test( "innerWidth - setter", function() { test( "innerWidth - setter", function() {
expect( 2 );
var el = $( "#dimensions" ); var el = $( "#dimensions" );
el.innerWidth( 120 ); el.innerWidth( 120 );
@ -64,6 +67,7 @@ test( "innerWidth - setter", function() {
}); });
test( "innerHeight - getter", function() { test( "innerHeight - getter", function() {
expect( 2 );
var el = $( "#dimensions" ); var el = $( "#dimensions" );
equal( el.innerHeight(), 70, "getter passthru" ); equal( el.innerHeight(), 70, "getter passthru" );
@ -72,6 +76,7 @@ test( "innerHeight - getter", function() {
}); });
test( "innerHeight - setter", function() { test( "innerHeight - setter", function() {
expect( 2 );
var el = $( "#dimensions" ); var el = $( "#dimensions" );
el.innerHeight( 60 ); el.innerHeight( 60 );
@ -82,6 +87,7 @@ test( "innerHeight - setter", function() {
}); });
test( "outerWidth - getter", function() { test( "outerWidth - getter", function() {
expect( 2 );
var el = $( "#dimensions" ); var el = $( "#dimensions" );
equal( el.outerWidth(), 140, "getter passthru" ); equal( el.outerWidth(), 140, "getter passthru" );
@ -90,6 +96,7 @@ test( "outerWidth - getter", function() {
}); });
test( "outerWidth - setter", function() { test( "outerWidth - setter", function() {
expect( 2 );
var el = $( "#dimensions" ); var el = $( "#dimensions" );
el.outerWidth( 130 ); el.outerWidth( 130 );
@ -100,6 +107,7 @@ test( "outerWidth - setter", function() {
}); });
test( "outerWidth(true) - getter", function() { test( "outerWidth(true) - getter", function() {
expect( 2 );
var el = $( "#dimensions" ); var el = $( "#dimensions" );
equal( el.outerWidth(true), 154, "getter passthru w/ margin" ); equal( el.outerWidth(true), 154, "getter passthru w/ margin" );
@ -108,6 +116,7 @@ test( "outerWidth(true) - getter", function() {
}); });
test( "outerWidth(true) - setter", function() { test( "outerWidth(true) - setter", function() {
expect( 2 );
var el = $( "#dimensions" ); var el = $( "#dimensions" );
el.outerWidth( 130, true ); el.outerWidth( 130, true );
@ -118,6 +127,7 @@ test( "outerWidth(true) - setter", function() {
}); });
test( "outerHeight - getter", function() { test( "outerHeight - getter", function() {
expect( 2 );
var el = $( "#dimensions" ); var el = $( "#dimensions" );
equal( el.outerHeight(), 86, "getter passthru" ); equal( el.outerHeight(), 86, "getter passthru" );
@ -126,6 +136,7 @@ test( "outerHeight - getter", function() {
}); });
test( "outerHeight - setter", function() { test( "outerHeight - setter", function() {
expect( 2 );
var el = $( "#dimensions" ); var el = $( "#dimensions" );
el.outerHeight( 80 ); el.outerHeight( 80 );
@ -136,6 +147,7 @@ test( "outerHeight - setter", function() {
}); });
test( "outerHeight(true) - getter", function() { test( "outerHeight(true) - getter", function() {
expect( 2 );
var el = $( "#dimensions" ); var el = $( "#dimensions" );
equal( el.outerHeight(true), 98, "getter passthru w/ margin" ); equal( el.outerHeight(true), 98, "getter passthru w/ margin" );
@ -144,6 +156,7 @@ test( "outerHeight(true) - getter", function() {
}); });
test( "outerHeight(true) - setter", function() { test( "outerHeight(true) - setter", function() {
expect( 2 );
var el = $( "#dimensions" ); var el = $( "#dimensions" );
el.outerHeight( 90, true ); el.outerHeight( 90, true );
@ -153,4 +166,21 @@ test( "outerHeight(true) - setter", function() {
equal( el.height(), 32, "height set properly when hidden" ); equal( el.height(), 32, "height set properly when hidden" );
}); });
test( "uniqueId / removeUniqueId", function() {
expect( 3 );
var el = $( "img" ).eq( 0 );
// support: jQuery <1.6.2
// support: IE <8
// We should use strictEqual( id, undefined ) when dropping jQuery 1.6.1 support (or IE6/7)
ok( !el.attr( "id" ), "element has no initial id" );
el.uniqueId();
ok( /ui-id-\d+$/.test( el.attr( "id" ) ), "element has generated id" );
el.removeUniqueId();
// support: jQuery <1.6.2
// support: IE <8
// see above
ok( !el.attr( "id" ), "unique id has been removed from element" );
});
})( jQuery ); })( jQuery );

View File

@ -150,6 +150,8 @@ test("focusable - not natively focusable with various tabindex", function() {
}); });
test("focusable - area elements", function() { test("focusable - area elements", function() {
expect( 3 );
isFocusable('#areaCoordsHref', 'coords and href'); isFocusable('#areaCoordsHref', 'coords and href');
isFocusable('#areaNoCoordsHref', 'href but no coords'); isFocusable('#areaNoCoordsHref', 'href but no coords');
isNotFocusable('#areaNoImg', 'not associated with an image'); isNotFocusable('#areaNoImg', 'not associated with an image');
@ -227,6 +229,8 @@ test("tabbable - not natively tabbable with various tabindex", function() {
}); });
test("tabbable - area elements", function() { test("tabbable - area elements", function() {
expect( 3 );
isTabbable('#areaCoordsHref', 'coords and href'); isTabbable('#areaCoordsHref', 'coords and href');
isTabbable('#areaNoCoordsHref', 'href but no coords'); isTabbable('#areaNoCoordsHref', 'href but no coords');
isNotTabbable('#areaNoImg', 'not associated with an image'); isNotTabbable('#areaNoImg', 'not associated with an image');

View File

@ -43,16 +43,19 @@ var PROP_NAME = 'datepicker';
module("datepicker: core"); module("datepicker: core");
test( "widget method - empty collection", function() { test( "widget method - empty collection", function() {
expect( 1 );
$( "#nonExist" ).datepicker(); // should create nothing $( "#nonExist" ).datepicker(); // should create nothing
ok( !$( "#ui-datepicker-div" ).length, "Non init on empty collection" ); ok( !$( "#ui-datepicker-div" ).length, "Non init on empty collection" );
}); });
test("widget method", function() { test("widget method", function() {
expect( 1 );
var actual = $("#inp").datepicker().datepicker("widget")[0]; var actual = $("#inp").datepicker().datepicker("widget")[0];
deepEqual($("body > #ui-datepicker-div:last-child")[0], actual); deepEqual($("body > #ui-datepicker-div:last-child")[0], actual);
}); });
test('baseStructure', function() { test('baseStructure', function() {
expect( 59 );
var header, title, table, thead, week, panel, inl, child, var header, title, table, thead, week, panel, inl, child,
inp = init('#inp').focus(), inp = init('#inp').focus(),
dp = $('#ui-datepicker-div'), dp = $('#ui-datepicker-div'),
@ -176,6 +179,7 @@ test('baseStructure', function() {
}); });
test('customStructure', function() { test('customStructure', function() {
expect( 20 );
var iframe, header, panel, title, thead, var iframe, header, panel, title, thead,
dp = $('#ui-datepicker-div'), dp = $('#ui-datepicker-div'),
// Check right-to-left localisation // Check right-to-left localisation
@ -233,6 +237,7 @@ test('customStructure', function() {
}); });
test('keystrokes', function() { test('keystrokes', function() {
expect( 26 );
var inp = init('#inp'), var inp = init('#inp'),
date = new Date(); date = new Date();
inp.val('').datepicker('show'). inp.val('').datepicker('show').
@ -367,6 +372,7 @@ test('keystrokes', function() {
}); });
test('mouse', function() { test('mouse', function() {
expect( 15 );
var inl, var inl,
inp = init('#inp'), inp = init('#inp'),
dp = $('#ui-datepicker-div'), dp = $('#ui-datepicker-div'),

View File

@ -22,6 +22,7 @@ function callback2(year, month, inst) {
} }
test('events', function() { test('events', function() {
expect( 26 );
var dateStr, newMonthYear, inp2, var dateStr, newMonthYear, inp2,
inp = init('#inp', {onSelect: callback}), inp = init('#inp', {onSelect: callback}),
date = new Date(); date = new Date();

View File

@ -6,6 +6,7 @@
module("datepicker: methods"); module("datepicker: methods");
test('destroy', function() { test('destroy', function() {
expect( 33 );
var inl, var inl,
inp = init('#inp'); inp = init('#inp');
ok(inp.is('.hasDatepicker'), 'Default - marker class set'); ok(inp.is('.hasDatepicker'), 'Default - marker class set');
@ -63,6 +64,7 @@ test('destroy', function() {
}); });
test('enableDisable', function() { test('enableDisable', function() {
expect( 33 );
var inl, dp, var inl, dp,
inp = init('#inp'); inp = init('#inp');
ok(!inp.datepicker('isDisabled'), 'Enable/disable - initially marked as enabled'); ok(!inp.datepicker('isDisabled'), 'Enable/disable - initially marked as enabled');

View File

@ -7,6 +7,7 @@
module("datepicker: options"); module("datepicker: options");
test('setDefaults', function() { test('setDefaults', function() {
expect( 3 );
var inp = init('#inp'); var inp = init('#inp');
equal($.datepicker._defaults.showOn, 'focus', 'Initial showOn'); equal($.datepicker._defaults.showOn, 'focus', 'Initial showOn');
$.datepicker.setDefaults({showOn: 'button'}); $.datepicker.setDefaults({showOn: 'button'});
@ -16,6 +17,7 @@ test('setDefaults', function() {
}); });
test('option', function() { test('option', function() {
expect( 17 );
var inp = init('#inp'), var inp = init('#inp'),
inst = $.data(inp[0], PROP_NAME); inst = $.data(inp[0], PROP_NAME);
// Set option // Set option
@ -47,6 +49,7 @@ test('option', function() {
}); });
test('change', function() { test('change', function() {
expect( 12 );
var inp = init('#inp'), var inp = init('#inp'),
inst = $.data(inp[0], PROP_NAME); inst = $.data(inp[0], PROP_NAME);
equal(inst.settings.showOn, null, 'Initial setting showOn'); equal(inst.settings.showOn, null, 'Initial setting showOn');
@ -67,6 +70,7 @@ test('change', function() {
}); });
test('invocation', function() { test('invocation', function() {
expect( 29 );
var button, image, var button, image,
inp = init('#inp'), inp = init('#inp'),
dp = $('#ui-datepicker-div'), dp = $('#ui-datepicker-div'),
@ -138,6 +142,7 @@ test('invocation', function() {
}); });
test('otherMonths', function() { test('otherMonths', function() {
expect( 8 );
var inp = init('#inp'), var inp = init('#inp'),
pop = $('#ui-datepicker-div'); pop = $('#ui-datepicker-div');
inp.val('06/01/2009').datepicker('show'); inp.val('06/01/2009').datepicker('show');
@ -159,6 +164,7 @@ test('otherMonths', function() {
}); });
test('defaultDate', function() { test('defaultDate', function() {
expect( 17 );
var inp = init('#inp'), var inp = init('#inp'),
date = new Date(); date = new Date();
inp.val('').datepicker('show'). inp.val('').datepicker('show').
@ -253,6 +259,7 @@ test('defaultDate', function() {
}); });
test('miscellaneous', function() { test('miscellaneous', function() {
expect( 19 );
var curYear, longNames, shortNames, date, var curYear, longNames, shortNames, date,
dp = $('#ui-datepicker-div'), dp = $('#ui-datepicker-div'),
inp = init('#inp'); inp = init('#inp');
@ -314,6 +321,7 @@ test('miscellaneous', function() {
}); });
test('minMax', function() { test('minMax', function() {
expect( 17 );
var date, var date,
inp = init('#inp'), inp = init('#inp'),
lastYear = new Date(2007, 6 - 1, 4), lastYear = new Date(2007, 6 - 1, 4),
@ -398,6 +406,7 @@ test('minMax', function() {
}); });
test('setDate', function() { test('setDate', function() {
expect( 24 );
var inl, alt, minDate, maxDate, dateAndTimeToSet, dateAndTimeClone, var inl, alt, minDate, maxDate, dateAndTimeToSet, dateAndTimeClone,
inp = init('#inp'), inp = init('#inp'),
date1 = new Date(2008, 6 - 1, 4), date1 = new Date(2008, 6 - 1, 4),
@ -477,6 +486,7 @@ test('setDate', function() {
}); });
test('altField', function() { test('altField', function() {
expect( 10 );
var inp = init('#inp'), var inp = init('#inp'),
alt = $('#alt'); alt = $('#alt');
// No alternate field set // No alternate field set
@ -515,6 +525,7 @@ test('altField', function() {
}); });
test('autoSize', function() { test('autoSize', function() {
expect( 15 );
var inp = init('#inp'); var inp = init('#inp');
equal(inp.prop('size'), 20, 'Auto size - default'); equal(inp.prop('size'), 20, 'Auto size - default');
inp.datepicker('option', 'autoSize', true); inp.datepicker('option', 'autoSize', true);
@ -550,6 +561,7 @@ test('autoSize', function() {
}); });
test('daylightSaving', function() { test('daylightSaving', function() {
expect( 25 );
var inp = init('#inp'), var inp = init('#inp'),
dp = $('#ui-datepicker-div'); dp = $('#ui-datepicker-div');
ok(true, 'Daylight saving - ' + new Date()); ok(true, 'Daylight saving - ' + new Date());
@ -664,6 +676,7 @@ function calcWeek(date) {
} }
test('callbacks', function() { test('callbacks', function() {
expect( 13 );
// Before show // Before show
var dp, day20, day21, var dp, day20, day21,
inp = init('#inp', {beforeShow: beforeAll}), inp = init('#inp', {beforeShow: beforeAll}),
@ -693,6 +706,7 @@ test('callbacks', function() {
}); });
test('localisation', function() { test('localisation', function() {
expect( 24 );
var dp, month, day, date, var dp, month, day, date,
inp = init('#inp', $.datepicker.regional.fr); inp = 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');
@ -722,6 +736,7 @@ test('localisation', function() {
}); });
test('noWeekends', function() { test('noWeekends', function() {
expect( 31 );
var i, date; var i, date;
for (i = 1; i <= 31; i++) { for (i = 1; i <= 31; i++) {
date = new Date(2001, 1 - 1, i); date = new Date(2001, 1 - 1, i);
@ -731,6 +746,7 @@ test('noWeekends', function() {
}); });
test('iso8601Week', function() { test('iso8601Week', function() {
expect( 12 );
var date = new Date(2000, 12 - 1, 31); var date = new Date(2000, 12 - 1, 31);
equal($.datepicker.iso8601Week(date), 52, 'ISO 8601 week ' + date); equal($.datepicker.iso8601Week(date), 52, 'ISO 8601 week ' + date);
date = new Date(2001, 1 - 1, 1); date = new Date(2001, 1 - 1, 1);
@ -758,6 +774,7 @@ test('iso8601Week', function() {
}); });
test('parseDate', function() { test('parseDate', function() {
expect( 26 );
init('#inp'); 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');
@ -822,6 +839,7 @@ test('parseDate', function() {
}); });
test('parseDateErrors', function() { test('parseDateErrors', function() {
expect( 17 );
init('#inp'); init('#inp');
var fr, settings; var fr, settings;
function expectError(expr, value, error) { function expectError(expr, value, error) {
@ -874,6 +892,7 @@ test('parseDateErrors', function() {
}); });
test('formatDate', function() { test('formatDate', function() {
expect( 16 );
init('#inp'); 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)),

View File

@ -7,6 +7,7 @@ module("datepicker: tickets");
// http://forum.jquery.com/topic/several-breaking-changes-in-jquery-ui-1-8rc1 // http://forum.jquery.com/topic/several-breaking-changes-in-jquery-ui-1-8rc1
test('beforeShowDay-getDate', function() { test('beforeShowDay-getDate', function() {
expect( 3 );
var inp = init('#inp', {beforeShowDay: function(date) { inp.datepicker('getDate'); return [true, '']; }}), var inp = init('#inp', {beforeShowDay: function(date) { inp.datepicker('getDate'); return [true, '']; }}),
dp = $('#ui-datepicker-div'); dp = $('#ui-datepicker-div');
inp.val('01/01/2010').datepicker('show'); inp.val('01/01/2010').datepicker('show');
@ -25,6 +26,7 @@ test('beforeShowDay-getDate', function() {
}); });
test('Ticket 7602: Stop datepicker from appearing with beforeShow event handler', function(){ test('Ticket 7602: Stop datepicker from appearing with beforeShow event handler', function(){
expect( 3 );
var inp = init('#inp',{ var inp = init('#inp',{
beforeShow: function(){ beforeShow: function(){
return false; return false;
@ -58,11 +60,13 @@ test('Ticket 7602: Stop datepicker from appearing with beforeShow event handler'
}); });
test('Ticket 6827: formatDate day of year calculation is wrong during day lights savings time', function(){ 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")); var time = $.datepicker.formatDate("oo", new Date("2010/03/30 12:00:00 CDT"));
equal(time, "089"); equal(time, "089");
}); });
test('Ticket #7244: date parser does not fail when too many numbers are passed into the date function', function() { test('Ticket #7244: date parser does not fail when too many numbers are passed into the date function', function() {
expect( 4 );
var date; var date;
try{ try{
date = $.datepicker.parseDate('dd/mm/yy', '18/04/19881'); date = $.datepicker.parseDate('dd/mm/yy', '18/04/19881');

View File

@ -89,26 +89,11 @@ function margin(el, side) {
module("dialog: core"); module("dialog: core");
test("title id", function() { test("title id", function() {
expect(3); expect(1);
var titleId;
// reset the uuid so we know what values to expect
$.ui.dialog.uuid = 0;
el = $('<div></div>').dialog(); el = $('<div></div>').dialog();
titleId = dlg().find('.ui-dialog-title').attr('id'); var titleId = dlg().find('.ui-dialog-title').attr('id');
equal(titleId, 'ui-dialog-title-1', 'auto-numbered title id'); ok( /ui-id-\d+$/.test( titleId ), 'auto-numbered title id');
el.remove();
el = $('<div></div>').dialog();
titleId = dlg().find('.ui-dialog-title').attr('id');
equal(titleId, 'ui-dialog-title-2', 'auto-numbered title id');
el.remove();
el = $('<div id="foo">').dialog();
titleId = dlg().find('.ui-dialog-title').attr('id');
equal(titleId, 'ui-dialog-title-foo', 'carried over title id');
el.remove(); el.remove();
}); });
@ -131,6 +116,7 @@ test("ARIA", function() {
}); });
test("widget method", function() { test("widget method", function() {
expect( 1 );
var dialog = $("<div>").appendTo("#main").dialog(); var dialog = $("<div>").appendTo("#main").dialog();
deepEqual(dialog.parent()[0], dialog.dialog("widget")[0]); deepEqual(dialog.parent()[0], dialog.dialog("widget")[0]);
}); });

View File

@ -34,6 +34,8 @@ test("init", function() {
}); });
test("destroy", function() { test("destroy", function() {
expect( 4 );
$("<div></div>").appendTo('body').dialog().dialog("destroy").remove(); $("<div></div>").appendTo('body').dialog().dialog("destroy").remove();
ok(true, '.dialog("destroy") called on element'); ok(true, '.dialog("destroy") called on element');
@ -49,6 +51,8 @@ test("destroy", function() {
}); });
test("enable", function() { test("enable", function() {
expect( 3 );
var expected = $('<div></div>').dialog(), var expected = $('<div></div>').dialog(),
actual = expected.dialog('enable'); actual = expected.dialog('enable');
equal(actual, expected, 'enable is chainable'); equal(actual, expected, 'enable is chainable');
@ -60,6 +64,8 @@ test("enable", function() {
}); });
test("disable", function() { test("disable", function() {
expect( 3 );
var expected = $('<div></div>').dialog(), var expected = $('<div></div>').dialog(),
actual = expected.dialog('disable'); actual = expected.dialog('disable');
equal(actual, expected, 'disable is chainable'); equal(actual, expected, 'disable is chainable');
@ -71,6 +77,8 @@ test("disable", function() {
}); });
test("close", function() { test("close", function() {
expect( 3 );
var expected = $('<div></div>').dialog(), var expected = $('<div></div>').dialog(),
actual = expected.dialog('close'); actual = expected.dialog('close');
equal(actual, expected, 'close is chainable'); equal(actual, expected, 'close is chainable');
@ -98,6 +106,8 @@ test("isOpen", function() {
}); });
test("moveToTop", function() { test("moveToTop", function() {
expect( 3 );
var d1, d2, dlg1, dlg2, var d1, d2, dlg1, dlg2,
expected = $('<div></div>').dialog(), expected = $('<div></div>').dialog(),
actual = expected.dialog('moveToTop'); actual = expected.dialog('moveToTop');
@ -117,6 +127,7 @@ test("moveToTop", function() {
}); });
test("open", function() { test("open", function() {
expect( 3 );
var expected = $('<div></div>').dialog(), var expected = $('<div></div>').dialog(),
actual = expected.dialog('open'); actual = expected.dialog('open');
equal(actual, expected, 'open is chainable'); equal(actual, expected, 'open is chainable');

View File

@ -106,6 +106,7 @@ test("buttons - advanced", function() {
}); });
test("closeOnEscape", function() { test("closeOnEscape", function() {
expect( 6 );
el = $('<div></div>').dialog({ closeOnEscape: false }); 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(dlg().is(':visible') && !dlg().is(':hidden'), 'dialog is open before ESC');
@ -276,6 +277,7 @@ test("minWidth", function() {
}); });
test("position, default center on window", function() { test("position, default center on window", function() {
expect( 2 );
var el = $('<div></div>').dialog(), var el = $('<div></div>').dialog(),
dialog = el.dialog('widget'), dialog = el.dialog('widget'),
offset = dialog.offset(); offset = dialog.offset();
@ -285,6 +287,7 @@ test("position, default center on window", function() {
}); });
test("position, top on window", function() { test("position, top on window", function() {
expect( 2 );
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();
@ -294,6 +297,7 @@ test("position, top on window", function() {
}); });
test("position, left on window", function() { test("position, left on window", function() {
expect( 2 );
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();
@ -303,6 +307,7 @@ test("position, left on window", function() {
}); });
test("position, right bottom on window", function() { test("position, right bottom on window", function() {
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();
@ -312,6 +317,7 @@ test("position, right bottom on window", function() {
}); });
test("position, right bottom on window w/array", function() { test("position, right bottom on window w/array", function() {
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();
@ -321,6 +327,7 @@ test("position, right bottom on window w/array", function() {
}); });
test("position, offset from top left w/array", function() { test("position, offset from top left w/array", function() {
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();
@ -330,6 +337,7 @@ test("position, offset from top left w/array", function() {
}); });
test("position, right bottom at right bottom via ui.position args", function() { test("position, right bottom at right bottom via ui.position args", function() {
expect( 2 );
var el = $('<div></div>').dialog({ var el = $('<div></div>').dialog({
position: { position: {
my: "right bottom", my: "right bottom",
@ -345,6 +353,7 @@ test("position, right bottom at right bottom via ui.position args", function() {
}); });
test("position, at another element", function() { test("position, at another element", function() {
expect( 4 );
var parent = $('<div></div>').css({ var parent = $('<div></div>').css({
position: 'absolute', position: 'absolute',
top: 400, top: 400,

View File

@ -10,7 +10,7 @@ asyncTest( "#3123: Prevent tabbing out of modal dialogs", function() {
var el = $( "<div><input id='t3123-first'><input id='t3123-last'></div>" ).dialog({ modal: true }), var el = $( "<div><input id='t3123-first'><input id='t3123-last'></div>" ).dialog({ modal: true }),
inputs = el.find( "input" ), inputs = el.find( "input" ),
widget = el.dialog( "widget" ); widget = el.dialog( "widget" )[ 0 ];
function checkTab() { function checkTab() {
ok( $.contains( widget, document.activeElement ), "Tab key event moved focus within the modal" ); ok( $.contains( widget, document.activeElement ), "Tab key event moved focus within the modal" );
@ -71,6 +71,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 );
el = $('<div></div>').dialog({ el = $('<div></div>').dialog({
width: 200, width: 200,
minWidth: 300 minWidth: 300
@ -192,6 +193,7 @@ test("#6966: Escape key closes all dialogs, not the top one", function(){
}); });
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 );
container = $('<div id="container"><div id="modal">Content</div></div>'); container = $('<div id="container"><div id="modal">Content</div></div>');
modal = container.find('#modal'); modal = container.find('#modal');
modal.dialog(); modal.dialog();

View File

@ -15,20 +15,20 @@
<script> <script>
TestHelpers.loadResources({ TestHelpers.loadResources({
js: [ js: [
"ui/jquery.effects.core.js", "ui/jquery.ui.effect.js",
"ui/jquery.effects.blind.js", "ui/jquery.ui.effect-blind.js",
"ui/jquery.effects.bounce.js", "ui/jquery.ui.effect-bounce.js",
"ui/jquery.effects.clip.js", "ui/jquery.ui.effect-clip.js",
"ui/jquery.effects.drop.js", "ui/jquery.ui.effect-drop.js",
"ui/jquery.effects.explode.js", "ui/jquery.ui.effect-explode.js",
"ui/jquery.effects.fade.js", "ui/jquery.ui.effect-fade.js",
"ui/jquery.effects.fold.js", "ui/jquery.ui.effect-fold.js",
"ui/jquery.effects.highlight.js", "ui/jquery.ui.effect-highlight.js",
"ui/jquery.effects.pulsate.js", "ui/jquery.ui.effect-pulsate.js",
"ui/jquery.effects.scale.js", "ui/jquery.ui.effect-scale.js",
"ui/jquery.effects.shake.js", "ui/jquery.ui.effect-shake.js",
"ui/jquery.effects.slide.js", "ui/jquery.ui.effect-slide.js",
"ui/jquery.effects.transfer.js" "ui/jquery.ui.effect-transfer.js"
] ]
}); });
</script> </script>

View File

@ -90,16 +90,16 @@ 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" ),
done = function() { step = function( fx ) {
done = jQuery.noop; ok( true, "Step Function Called" );
test.stop(); test.stop();
start(); start();
step = $.noop;
}; };
test.toggleClass( "testChangeBackground", { test.toggleClass( "testChangeBackground", {
step: function( fx ) { step: function() {
ok( true, "Step Function Called" ); step();
setTimeout( done, 0 );
} }
}); });
}); });
@ -153,6 +153,7 @@ asyncTest( "animateClass clears style properties when stopped", function() {
}); });
asyncTest( "animateClass: css and class changes during animation are not lost (#7106)", function() { asyncTest( "animateClass: css and class changes during animation are not lost (#7106)", function() {
expect( 2 );
var test = $( "div.ticket7106" ); var test = $( "div.ticket7106" );
// ensure the class stays and that the css property stays // ensure the class stays and that the css property stays
@ -174,7 +175,7 @@ $.each( $.effects.effect, function( effect ) {
// puff and size are defined inside scale // puff and size are defined inside scale
if ( effect !== "puff" && effect !== "size" ) { if ( effect !== "puff" && effect !== "size" ) {
TestHelpers.testJshint( "effects." + effect ); TestHelpers.testJshint( "effect-" + effect );
} }
if ( effect === "transfer" ) { if ( effect === "transfer" ) {

View File

@ -4,6 +4,7 @@ module( "effect.scale: Scale" );
function run( position, v, h, vo, ho ) { function run( position, v, h, vo, ho ) {
var desc = "End Position Correct: " + position + " (" + v + "," + h + ") - origin: (" + vo + "," + ho + ")"; var desc = "End Position Correct: " + position + " (" + v + "," + h + ") - origin: (" + vo + "," + ho + ")";
asyncTest( desc, function() { asyncTest( desc, function() {
expect( 2 );
function complete() { function complete() {
equal( parseInt( test.css( h ), 10 ), target[ h ], "Horizontal Position Correct " + desc ); equal( parseInt( test.css( h ), 10 ), target[ h ], "Horizontal Position Correct " + desc );
equal( parseInt( test.css( v ), 10 ), target[ v ], "Vertical Position Correct " + desc ); equal( parseInt( test.css( v ), 10 ), target[ v ], "Vertical Position Correct " + desc );
@ -53,13 +54,13 @@ function suite( position ) {
$(function() { $(function() {
suite( "absolute" ); suite( "absolute" );
suite( "relative" ); suite( "relative" );
var fixed = $.support.fixedPosition; var fixedElem = $( "<div>" )
// jQuery < 1.7 uses $.offset.supportsFixedPosition .css({
if ( fixed === undefined ) { position: "fixed",
$.offset.initialize(); top: 10
fixed = $.offset.supportsFixedPosition; })
} .appendTo( "body" );
if ( fixed ) { if ( fixedElem.offset().top === 10 ) {
suite( "fixed" ); suite( "fixed" );
} }
}); });

View File

@ -44,18 +44,14 @@
</head> </head>
<body> <body>
<h1 id="qunit-header">jQuery UI Menu Test Suite</h1> <div id="qunit">jQuery UI Menu Test Suite</div>
<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="qunit-fixture">
<ul class="foo" id="menu1"> <ul class="foo" id="menu1">
<li class="foo"><a class="foo" href="#">Aberdeen</a></li> <li class="foo"><a class="foo" href="#">Aberdeen</a></li>
<li class="foo"><a class="foo" href="#">Ada</a></li> <li class="foo"><a class="foo" href="#">Ada</a></li>
<li class="foo"><a class="foo" href="#">Adamsville</a></li> <li class="foo"><a class="foo" href="#">Adamsville</a></li>
<li class="foo"><a class="foo" href="#">Addyston</a></li> <li class="foo"><a id="testID1" class="foo" href="#">Addyston</a></li>
<li class="foo"><a class="foo" href="#">Adelphi</a></li> <li class="foo"><a class="foo" href="#">Adelphi</a></li>
</ul> </ul>
@ -235,7 +231,7 @@
<a href="#">Delphi</a> <a href="#">Delphi</a>
<div> <div>
<blockquote><a href="#">Ada</a></blockquote> <blockquote><a href="#">Ada</a></blockquote>
<blockquote><a href="#">Saarland</a></blockquote> <blockquote><a id="testID2" href="#">Saarland</a></blockquote>
<blockquote><a href="#">Salzburg</a></blockquote> <blockquote><a href="#">Salzburg</a></blockquote>
</div> </div>
</blockquote> </blockquote>
@ -258,7 +254,7 @@
<li class="foo"><a class="foo" href="#">Adamsville</a></li> <li class="foo"><a class="foo" href="#">Adamsville</a></li>
<li class="foo"><a class="foo" href="#">Addyston</a></li> <li class="foo"><a class="foo" href="#">Addyston</a></li>
<li class="ui-state-disabled"> <li class="ui-state-disabled">
<a href="#">Delphi</a> <a id="testID3" href="#">Delphi</a>
<ul> <ul>
<li class="foo"><a class="foo" href="#">Ada</a></li> <li class="foo"><a class="foo" href="#">Ada</a></li>
<li class="foo"><a class="foo" href="#">Saarland</a></li> <li class="foo"><a class="foo" href="#">Saarland</a></li>
@ -268,8 +264,6 @@
<li class="foo"><a class="foo" href="#">Saarland</a></li> <li class="foo"><a class="foo" href="#">Saarland</a></li>
</ul> </ul>
<div id="log"></div>
</div> </div>
</body> </body>
</html> </html>

View File

@ -1,6 +1,9 @@
TestHelpers.commonWidgetTests( "menu", { TestHelpers.commonWidgetTests( "menu", {
defaults: { defaults: {
disabled: false, disabled: false,
icons: {
submenu: "ui-icon-carat-1-e"
},
menus: "ul", menus: "ul",
position: { position: {
my: "left top", my: "left top",

View File

@ -1,29 +1,30 @@
/* (function( $ ) {
* menu_core.js
*/
module( "menu: core" );
(function($) { test( "markup structure", function() {
expect( 6 );
module("menu: core"); var element = $( "#menu1" ).menu();
ok( element.hasClass( "ui-menu" ), "main element is .ui-menu" );
test("accessibility", function () { element.children().each(function( index ) {
expect(5); ok( $( this ).hasClass( "ui-menu-item" ), "child " + index + " is .ui-menu-item" );
var item, });
menu = $('#menu1').menu(),
item0 = $("li:eq(0) a");
ok( menu.hasClass("ui-menu ui-widget ui-widget-content ui-corner-all"), "menu class");
equal( menu.attr("role"), "menu", "main role");
ok( !menu.attr("aria-activedescendant"), "aria attribute not yet active");
item = menu.find( "li:first" ).find( "a" ).attr( "id", "xid" ).end();
menu.menu( "focus", $.Event(), item );
equal( menu.attr("aria-activedescendant"), "xid", "aria attribute, id from dom");
item = menu.find( "li:last" );
menu.menu( "focus", $.Event(), item );
equal( menu.attr("aria-activedescendant"), "menu1-4", "aria attribute, generated id");
}); });
})(jQuery); test( "accessibility", function () {
expect( 4 );
var element = $( "#menu1" ).menu();
equal( element.attr( "role" ), "menu", "main role" );
ok( !element.attr( "aria-activedescendant" ), "aria-activedescendant not set" );
element.menu( "focus", $.Event(), element.children().eq( -2 ) );
equal( element.attr( "aria-activedescendant" ), "testID1", "aria-activedescendant from existing id" );
element.menu( "focus", $.Event(), element.children().eq( 0 ) );
ok( /^ui-id-\d+$/.test( element.attr( "aria-activedescendant" ) ), "aria-activedescendant from generated id" );
// Item roles are tested in the role option tests
});
})( jQuery );

View File

@ -1,50 +1,52 @@
/* (function( $ ) {
* menu_events.js
*/
(function($) {
var log = TestHelpers.menu.log, var log = TestHelpers.menu.log,
logOutput = TestHelpers.menu.logOutput,
click = TestHelpers.menu.click; click = TestHelpers.menu.click;
module("menu: events"); module( "menu: events", {
setup: function() {
TestHelpers.menu.clearLog();
}
});
test("handle click on menu", function() { test( "handle click on menu", function() {
expect(1); expect( 1 );
var menu = $('#menu1').menu({ var element = $( "#menu1" ).menu({
select: function(event, ui) { select: function( event, ui ) {
log(); log();
} }
}); });
log("click",true); log( "click", true );
click($('#menu1'),"1"); click( $( "#menu1" ), "1" );
log("afterclick"); log( "afterclick" );
click( menu,"2"); click( element, "2" );
click($('#menu1'),"3"); click( $( "#menu1" ), "3" );
click( menu,"1"); click( element, "1" );
equal( $("#log").html(), "1,3,2,afterclick,1,click,", "Click order not valid."); equal( logOutput(), "click,1,afterclick,2,3,1", "Click order not valid." );
}); });
test("handle click on custom item menu", function() { test( "handle click on custom item menu", function() {
expect(1); expect( 1 );
var menu = $('#menu5').menu({ var element = $( "#menu5" ).menu({
select: function(event, ui) { select: function( event, ui ) {
log(); log();
}, },
menus: "div" menus: "div"
}); });
log("click",true); log( "click", true );
click($('#menu5'),"1"); click( $( "#menu5" ), "1" );
log("afterclick"); log( "afterclick" );
click( menu,"2"); click( element, "2" );
click($('#menu5'),"3"); click( $( "#menu5" ), "3" );
click( menu,"1"); click( element, "1" );
equal( $("#log").html(), "1,3,2,afterclick,1,click,", "Click order not valid."); equal( logOutput(), "click,1,afterclick,2,3,1", "Click order not valid." );
}); });
asyncTest( "handle blur", function() { asyncTest( "handle blur", function() {
expect( 1 ); expect( 1 );
var blurHandled = false, var blurHandled = false,
$menu = $( "#menu1" ).menu({ element = $( "#menu1" ).menu({
blur: function( event, ui ) { blur: function( event, ui ) {
// Ignore duplicate blur event fired by IE // Ignore duplicate blur event fired by IE
if ( !blurHandled ) { if ( !blurHandled ) {
@ -54,17 +56,17 @@ asyncTest( "handle blur", function() {
} }
}); });
click( $menu, "1" ); click( element, "1" );
setTimeout( function() { setTimeout( function() {
$menu.blur(); element.blur();
start(); start();
}, 350); }, 350 );
}); });
asyncTest( "handle blur on click", function() { asyncTest( "handle blur on click", function() {
expect( 1 ); expect( 1 );
var blurHandled = false, var blurHandled = false,
$menu = $( "#menu1" ).menu({ element = $( "#menu1" ).menu({
blur: function( event, ui ) { blur: function( event, ui ) {
// Ignore duplicate blur event fired by IE // Ignore duplicate blur event fired by IE
if ( !blurHandled ) { if ( !blurHandled ) {
@ -74,12 +76,11 @@ asyncTest( "handle blur on click", function() {
} }
}); });
click( $menu, "1" ); click( element, "1" );
setTimeout( function() { setTimeout( function() {
$( "<a>", { id: "remove"} ).appendTo("body").trigger( "click" ); $( "<a>", { id: "remove"} ).appendTo( "body" ).trigger( "click" );
$("#remove").remove();
start(); start();
}, 350); }, 350 );
}); });
test( "handle focus of menu with active item", function() { test( "handle focus of menu with active item", function() {
@ -95,226 +96,225 @@ test( "handle focus of menu with active item", 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 } );
element.focus(); element.focus();
equal( $("#log").html(), "2,2,1,0,focus,", "current active item remains active"); equal( logOutput(), "focus,0,1,2,2", "current active item remains active" );
}); });
asyncTest( "handle submenu auto collapse: mouseleave", function() { asyncTest( "handle submenu auto collapse: mouseleave", function() {
expect( 4 ); expect( 4 );
var $menu = $( "#menu2" ).menu(), var element = $( "#menu2" ).menu(),
event = $.Event( "mouseenter" ); event = $.Event( "mouseenter" );
function menumouseleave1() { function menumouseleave1() {
equal( $menu.find( "ul[aria-expanded='true']" ).length, 1, "first submenu expanded" ); equal( element.find( "ul[aria-expanded='true']" ).length, 1, "first submenu expanded" );
$menu.menu( "focus", event, $menu.find( "li:nth-child(7) li:first" ) ); element.menu( "focus", event, element.find( "li:nth-child(7) li:first" ) );
setTimeout( menumouseleave2, 350 ); setTimeout( menumouseleave2, 350 );
} }
function menumouseleave2() { function menumouseleave2() {
equal( $menu.find( "ul[aria-expanded='true']" ).length, 2, "second submenu expanded" ); equal( element.find( "ul[aria-expanded='true']" ).length, 2, "second submenu expanded" );
$menu.find( "ul[aria-expanded='true']:first" ).trigger( "mouseleave" ); element.find( "ul[aria-expanded='true']:first" ).trigger( "mouseleave" );
setTimeout( menumouseleave3, 350 ); setTimeout( menumouseleave3, 350 );
} }
function menumouseleave3() { function menumouseleave3() {
equal( $menu.find( "ul[aria-expanded='true']" ).length, 1, "second submenu collapsed" ); equal( element.find( "ul[aria-expanded='true']" ).length, 1, "second submenu collapsed" );
$menu.trigger( "mouseleave" ); element.trigger( "mouseleave" );
setTimeout( menumouseleave4, 350 ); setTimeout( menumouseleave4, 350 );
} }
function menumouseleave4() { function menumouseleave4() {
equal( $menu.find( "ul[aria-expanded='true']" ).length, 0, "first submenu collapsed" ); equal( element.find( "ul[aria-expanded='true']" ).length, 0, "first submenu collapsed" );
start(); start();
} }
$menu.find( "li:nth-child(7)" ).trigger( "mouseenter" ); element.find( "li:nth-child(7)" ).trigger( "mouseenter" );
setTimeout( menumouseleave1, 350 ); setTimeout( menumouseleave1, 350 );
}); });
asyncTest( "handle submenu auto collapse: mouseleave", function() { asyncTest( "handle submenu auto collapse: mouseleave", function() {
expect( 4 ); expect( 4 );
var $menu = $( "#menu5" ).menu( { menus: "div" } ), var element = $( "#menu5" ).menu({ menus: "div" }),
event = $.Event( "mouseenter" ); event = $.Event( "mouseenter" );
function menumouseleave1() { function menumouseleave1() {
equal( $menu.find( "div[aria-expanded='true']" ).length, 1, "first submenu expanded" ); equal( element.find( "div[aria-expanded='true']" ).length, 1, "first submenu expanded" );
$menu.menu( "focus", event, $menu.find( ":nth-child(7)" ).find( "div" ).eq( 0 ).children().eq( 0 ) ); element.menu( "focus", event, element.find( ":nth-child(7)" ).find( "div" ).eq( 0 ).children().eq( 0 ) );
setTimeout( menumouseleave2, 350 ); setTimeout( menumouseleave2, 350 );
} }
function menumouseleave2() { function menumouseleave2() {
equal( $menu.find( "div[aria-expanded='true']" ).length, 2, "second submenu expanded" ); equal( element.find( "div[aria-expanded='true']" ).length, 2, "second submenu expanded" );
$menu.find( "div[aria-expanded='true']:first" ).trigger( "mouseleave" ); element.find( "div[aria-expanded='true']:first" ).trigger( "mouseleave" );
setTimeout( menumouseleave3, 350 ); setTimeout( menumouseleave3, 350 );
} }
function menumouseleave3() { function menumouseleave3() {
equal( $menu.find( "div[aria-expanded='true']" ).length, 1, "second submenu collapsed" ); equal( element.find( "div[aria-expanded='true']" ).length, 1, "second submenu collapsed" );
$menu.trigger( "mouseleave" ); element.trigger( "mouseleave" );
setTimeout( menumouseleave4, 350 ); setTimeout( menumouseleave4, 350 );
} }
function menumouseleave4() { function menumouseleave4() {
equal( $menu.find( "div[aria-expanded='true']" ).length, 0, "first submenu collapsed" ); equal( element.find( "div[aria-expanded='true']" ).length, 0, "first submenu collapsed" );
start(); start();
} }
$menu.find( ":nth-child(7)" ).trigger( "mouseenter" ); element.find( ":nth-child(7)" ).trigger( "mouseenter" );
setTimeout( menumouseleave1, 350 ); setTimeout( menumouseleave1, 350 );
}); });
test("handle keyboard navigation on menu without scroll and without submenus", function() { test( "handle keyboard navigation on menu without scroll and without submenus", function() {
expect(12); expect( 12 );
var element = $('#menu1').menu({ var element = $( "#menu1" ).menu({
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, ui ) {
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.focus(); element.focus();
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( $("#log").html(), "2,1,0,keydown,", "Keydown DOWN"); equal( logOutput(), "keydown,0,1,2", "Keydown DOWN" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
equal( $("#log").html(), "1,keydown,", "Keydown UP"); equal( logOutput(), "keydown,1", "Keydown UP" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
equal( $("#log").html(), "keydown,", "Keydown LEFT (no effect)"); equal( logOutput(), "keydown", "Keydown LEFT (no effect)" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
equal( $("#log").html(), "keydown,", "Keydown RIGHT (no effect)"); equal( logOutput(), "keydown", "Keydown RIGHT (no effect)" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
equal( $("#log").html(), "4,keydown,", "Keydown PAGE_DOWN"); equal( logOutput(), "keydown,4", "Keydown PAGE_DOWN" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
equal( $("#log").html(), "keydown,", "Keydown PAGE_DOWN (no effect)"); equal( logOutput(), "keydown", "Keydown PAGE_DOWN (no effect)" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
equal( $("#log").html(), "0,keydown,", "Keydown PAGE_UP"); equal( logOutput(), "keydown,0", "Keydown PAGE_UP" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
equal( $("#log").html(), "keydown,", "Keydown PAGE_UP (no effect)"); equal( logOutput(), "keydown", "Keydown PAGE_UP (no effect)" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.END } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.END } );
equal( $("#log").html(), "4,keydown,", "Keydown END"); equal( logOutput(), "keydown,4", "Keydown END" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } );
equal( $("#log").html(), "0,keydown,", "Keydown HOME"); equal( logOutput(), "keydown,0", "Keydown HOME" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
equal( $("#log").html(), "keydown,", "Keydown ESCAPE (no effect)"); equal( logOutput(), "keydown", "Keydown ESCAPE (no effect)" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
equal( $("#log").html(), "Aberdeen,keydown,", "Keydown ENTER"); equal( logOutput(), "keydown,Aberdeen", "Keydown ENTER" );
}); });
asyncTest("handle keyboard navigation on menu without scroll and with submenus", function() { asyncTest( "handle keyboard navigation on menu without scroll and with submenus", function() {
expect(16); expect( 16 );
var element = $('#menu2').menu({ var element = $( "#menu2" ).menu({
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, ui ) {
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( event, ui ) {
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( $("#log").html(), "2,1,keydown,", "Keydown DOWN"); equal( logOutput(), "keydown,1,2", "Keydown DOWN" );
setTimeout( menukeyboard1, 50 ); setTimeout( menukeyboard1, 50 );
}); });
element.focus(); element.focus();
function menukeyboard1() { function menukeyboard1() {
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
equal( $("#log").html(), "0,1,keydown,", "Keydown UP"); equal( logOutput(), "keydown,1,0", "Keydown UP" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
equal( $("#log").html(), "keydown,", "Keydown LEFT (no effect)"); equal( logOutput(), "keydown", "Keydown LEFT (no effect)" );
log("keydown",true); log( "keydown", true );
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 } );
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 } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
setTimeout( function() { setTimeout(function() {
equal( $("#log").html(), "0,4,3,2,1,keydown,", "Keydown RIGHT (open submenu)"); equal( logOutput(), "keydown,1,2,3,4,0", "Keydown RIGHT (open submenu)" );
}, 50); setTimeout( menukeyboard2, 50 );
setTimeout( menukeyboard2, 50 ); }, 50 );
} }
function menukeyboard2() { function menukeyboard2() {
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
equal( $("#log").html(), "4,keydown,", "Keydown LEFT (close submenu)"); equal( logOutput(), "keydown,4", "Keydown LEFT (close submenu)" );
//re-open submenu // re-open submenu
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
setTimeout( menukeyboard3, 50 ); setTimeout( menukeyboard3, 50 );
} }
function menukeyboard3() { function menukeyboard3() {
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
equal( $("#log").html(), "2,keydown,", "Keydown PAGE_DOWN"); equal( logOutput(), "keydown,2", "Keydown PAGE_DOWN" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
equal( $("#log").html(), "keydown,", "Keydown PAGE_DOWN (no effect)"); equal( logOutput(), "keydown", "Keydown PAGE_DOWN (no effect)" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
equal( $("#log").html(), "0,keydown,", "Keydown PAGE_UP"); equal( logOutput(), "keydown,0", "Keydown PAGE_UP" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
equal( $("#log").html(), "keydown,", "Keydown PAGE_UP (no effect)"); equal( logOutput(), "keydown", "Keydown PAGE_UP (no effect)" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.END } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.END } );
equal( $("#log").html(), "2,keydown,", "Keydown END"); equal( logOutput(), "keydown,2", "Keydown END" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } );
equal( $("#log").html(), "0,keydown,", "Keydown HOME"); equal( logOutput(), "keydown,0", "Keydown HOME" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
equal( $("#log").html(), "4,keydown,", "Keydown ESCAPE (close submenu)"); equal( logOutput(), "keydown,4", "Keydown ESCAPE (close submenu)" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.SPACE } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.SPACE } );
setTimeout( menukeyboard4, 50 ); setTimeout( menukeyboard4, 50 );
} }
function menukeyboard4() { function menukeyboard4() {
equal( $("#log").html(), "0,keydown,", "Keydown SPACE (open submenu)"); equal( logOutput(), "keydown,0", "Keydown SPACE (open submenu)" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
equal( $("#log").html(), "4,keydown,", "Keydown ESCAPE (close submenu)"); equal( logOutput(), "keydown,4", "Keydown ESCAPE (close submenu)" );
log("keydown",true); log( "keydown", true );
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 } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
@ -325,9 +325,9 @@ asyncTest("handle keyboard navigation on menu without scroll and with submenus",
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 } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
equal( $("#log").html(), "0,4,2,0,1,0,6,5,keydown,", "Keydown skip dividers and items without anchors"); equal( logOutput(), "keydown,5,6,0,1,0,2,4,0", "Keydown skip dividers and items without anchors" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
setTimeout( menukeyboard6, 50 ); setTimeout( menukeyboard6, 50 );
}, 50 ); }, 50 );
@ -335,232 +335,229 @@ asyncTest("handle keyboard navigation on menu without scroll and with submenus",
} }
function menukeyboard6() { function menukeyboard6() {
equal( $("#log").html(), "Ada,keydown,", "Keydown ENTER (open submenu)"); equal( logOutput(), "keydown,Ada", "Keydown ENTER (open submenu)" );
start(); start();
} }
}); });
test("handle keyboard navigation on menu with scroll and without submenus", function() { test( "handle keyboard navigation on menu with scroll and without submenus", function() {
expect(14); expect( 14 );
var element = $('#menu3').menu({ var element = $( "#menu3" ).menu({
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, ui ) {
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.focus(); element.focus();
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( $("#log").html(), "2,1,0,keydown,", "Keydown DOWN"); equal( logOutput(), "keydown,0,1,2", "Keydown DOWN" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
equal( $("#log").html(), "0,1,keydown,", "Keydown UP"); equal( logOutput(), "keydown,1,0", "Keydown UP" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
equal( $("#log").html(), "keydown,", "Keydown LEFT (no effect)"); equal( logOutput(), "keydown", "Keydown LEFT (no effect)" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
equal( $("#log").html(), "keydown,", "Keydown RIGHT (no effect)"); equal( logOutput(), "keydown", "Keydown RIGHT (no effect)" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
equal( $("#log").html(), "10,keydown,", "Keydown PAGE_DOWN"); equal( logOutput(), "keydown,10", "Keydown PAGE_DOWN" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
equal( $("#log").html(), "20,keydown,", "Keydown PAGE_DOWN"); equal( logOutput(), "keydown,20", "Keydown PAGE_DOWN" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
equal( $("#log").html(), "10,keydown,", "Keydown PAGE_UP"); equal( logOutput(), "keydown,10", "Keydown PAGE_UP" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
equal( $("#log").html(), "0,keydown,", "Keydown PAGE_UP"); equal( logOutput(), "keydown,0", "Keydown PAGE_UP" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
equal( $("#log").html(), "keydown,", "Keydown PAGE_UP (no effect)"); equal( logOutput(), "keydown", "Keydown PAGE_UP (no effect)" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.END } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.END } );
equal( $("#log").html(), "37,keydown,", "Keydown END"); equal( logOutput(), "keydown,37", "Keydown END" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
equal( $("#log").html(), "keydown,", "Keydown PAGE_DOWN (no effect)"); equal( logOutput(), "keydown", "Keydown PAGE_DOWN (no effect)" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } );
equal( $("#log").html(), "0,keydown,", "Keydown HOME"); equal( logOutput(), "keydown,0", "Keydown HOME" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
equal( $("#log").html(), "keydown,", "Keydown ESCAPE (no effect)"); equal( logOutput(), "keydown", "Keydown ESCAPE (no effect)" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
equal( $("#log").html(), "Aberdeen,keydown,", "Keydown ENTER"); equal( logOutput(), "keydown,Aberdeen", "Keydown ENTER" );
}); });
asyncTest("handle keyboard navigation on menu with scroll and with submenus", function() { asyncTest( "handle keyboard navigation on menu with scroll and with submenus", function() {
expect(14); expect( 14 );
var element = $('#menu4').menu({ var element = $( "#menu4" ).menu({
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, ui ) {
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( event, ui ) {
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( $("#log").html(), "2,1,keydown,", "Keydown DOWN"); equal( logOutput(), "keydown,1,2", "Keydown DOWN" );
setTimeout( menukeyboard1, 50 ); setTimeout( menukeyboard1, 50 );
}); });
element.focus(); element.focus();
function menukeyboard1() { function menukeyboard1() {
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
equal( $("#log").html(), "0,1,keydown,", "Keydown UP"); equal( logOutput(), "keydown,1,0", "Keydown UP" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
equal( $("#log").html(), "keydown,", "Keydown LEFT (no effect)"); equal( logOutput(), "keydown", "Keydown LEFT (no effect)" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
setTimeout( function() { setTimeout( function() {
equal( $("#log").html(), "0,1,keydown,", "Keydown RIGHT (open submenu)"); equal( logOutput(), "keydown,1,0", "Keydown RIGHT (open submenu)" );
}, 50); }, 50 );
setTimeout( menukeyboard2, 50 ); setTimeout( menukeyboard2, 50 );
} }
function menukeyboard2() { function menukeyboard2() {
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
equal( $("#log").html(), "1,keydown,", "Keydown LEFT (close submenu)"); equal( logOutput(), "keydown,1", "Keydown LEFT (close submenu)" );
//re-open submenu // re-open submenu
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
setTimeout( menukeyboard3, 50 ); setTimeout( menukeyboard3, 50 );
} }
function menukeyboard3() { function menukeyboard3() {
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
equal( $("#log").html(), "10,keydown,", "Keydown PAGE_DOWN"); equal( logOutput(), "keydown,10", "Keydown PAGE_DOWN" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
equal( $("#log").html(), "20,keydown,", "Keydown PAGE_DOWN"); equal( logOutput(), "keydown,20", "Keydown PAGE_DOWN" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
equal( $("#log").html(), "10,keydown,", "Keydown PAGE_UP"); equal( logOutput(), "keydown,10", "Keydown PAGE_UP" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
equal( $("#log").html(), "0,keydown,", "Keydown PAGE_UP"); equal( logOutput(), "keydown,0", "Keydown PAGE_UP" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.END } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.END } );
equal( $("#log").html(), "27,keydown,", "Keydown END"); equal( logOutput(), "keydown,27", "Keydown END" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } );
equal( $("#log").html(), "0,keydown,", "Keydown HOME"); equal( logOutput(), "keydown,0", "Keydown HOME" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
equal( $("#log").html(), "1,keydown,", "Keydown ESCAPE (close submenu)"); equal( logOutput(), "keydown,1", "Keydown ESCAPE (close submenu)" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
setTimeout( menukeyboard4, 50 ); setTimeout( menukeyboard4, 50 );
} }
function menukeyboard4() { function menukeyboard4() {
equal( $("#log").html(), "0,keydown,", "Keydown ENTER (open submenu)"); equal( logOutput(), "keydown,0", "Keydown ENTER (open submenu)" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
equal( $("#log").html(), "Aberdeen,keydown,", "Keydown ENTER (select item)"); equal( logOutput(), "keydown,Aberdeen", "Keydown ENTER (select item)" );
start(); start();
} }
}); });
asyncTest("handle keyboard navigation and mouse click on menu with disabled items", function() { asyncTest( "handle keyboard navigation and mouse click on menu with disabled items", function() {
expect(6); expect( 6 );
var element = $('#menu6').menu({ var element = $( "#menu6" ).menu({
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, ui ) {
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( event, ui ) {
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( $("#log").html(), "1,keydown,", "Keydown focus but not select disabled item"); equal( logOutput(), "keydown,1", "Keydown focus but not select disabled item" );
setTimeout( menukeyboard1, 50 ); setTimeout( menukeyboard1, 50 );
}); });
element.focus(); element.focus();
function menukeyboard1() { function menukeyboard1() {
log("keydown",true); log( "keydown", true );
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 } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
equal( $("#log").html(), "4,3,2,keydown,", "Keydown focus disabled item with submenu"); equal( logOutput(), "keydown,2,3,4", "Keydown focus disabled item with submenu" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
equal( $("#log").html(), "keydown,", "Keydown LEFT (no effect)"); equal( logOutput(), "keydown", "Keydown LEFT (no effect)" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
setTimeout( function() { setTimeout( function() {
equal( $("#log").html(), "keydown,", "Keydown RIGHT (no effect on disabled sub-menu)"); equal( logOutput(), "keydown", "Keydown RIGHT (no effect on disabled sub-menu)" );
log("keydown",true); log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
setTimeout( function() { setTimeout( function() {
equal( $("#log").html(), "keydown,", "Keydown ENTER (no effect on disabled sub-menu)"); equal( logOutput(), "keydown", "Keydown ENTER (no effect on disabled sub-menu)" );
log("click",true); log( "click", true );
click( element, "1" ); click( element, "1" );
equal( $("#log").html(), "click,", "Click disabled item (no effect)"); equal( logOutput(), "click", "Click disabled item (no effect)" );
start(); start();
}, 50); }, 50 );
}, 50); }, 50 );
} }
}); });
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, ui ) {
@ -573,29 +570,11 @@ test("handle keyboard navigation with spelling of menu items", 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 } );
equal( $("#log").html(), "3,1,0,keydown,", "Keydown focus Addyston by spelling the first 3 letters"); equal( logOutput(), "keydown,0,1,3", "Keydown focus Addyston by spelling the first 3 letters" );
element.simulate( "keydown", { keyCode: 68 } ); element.simulate( "keydown", { keyCode: 68 } );
equal( $("#log").html(), "4,3,1,0,keydown,", "Keydown focus Delphi by repeating the 'd' again"); equal( logOutput(), "keydown,0,1,3,4", "Keydown focus Delphi by repeating the 'd' again" );
}); });
element.focus(); element.focus();
}); });
asyncTest("handle page up and page down before the menu has focus", function() { })( jQuery );
expect( 1 );
var element = $( "#menu1" ).menu({
focus: function( event, ui ) {
log( $( event.target ).find( ".ui-state-focus" ).parent().index() );
}
});
log( "keydown", true );
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
element.blur();
setTimeout( function() {
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
equal( $("#log").html(), "0,0,keydown,", "Page Up and Page Down bring initial focus to first item");
start();
}, 500);
});
})(jQuery);

View File

@ -1,58 +1,87 @@
/* (function( $ ) {
* menu_methods.js
*/
(function($) {
var log = TestHelpers.menu.log, var log = TestHelpers.menu.log,
logOutput = TestHelpers.menu.logOutput,
click = TestHelpers.menu.click; click = TestHelpers.menu.click;
module("menu: methods"); module( "menu: methods", {
setup: function() {
TestHelpers.menu.clearLog();
}
});
test( "enable/disable", function() { test( "enable/disable", function() {
expect( 3 ); expect( 3 );
var menu = $( "#menu1" ).menu({ var element = $( "#menu1" ).menu({
select: function(event, ui) { select: function( event, ui ) {
log(); log();
} }
}); });
menu.menu("disable"); element.menu( "disable" );
ok(menu.is(".ui-state-disabled"),"Missing ui-state-disabled class"); ok( element.is( ".ui-state-disabled" ), "Missing ui-state-disabled class" );
log("click",true); log( "click", true );
click(menu,"1"); click( element, "1" );
log("afterclick"); log( "afterclick" );
menu.menu("enable"); element.menu( "enable" );
ok(menu.not(".ui-state-disabled"),"Has ui-state-disabled class"); ok( element.not( ".ui-state-disabled" ), "Has ui-state-disabled class" );
log("click"); log( "click" );
click(menu,"1"); click( element, "1" );
log("afterclick"); log( "afterclick" );
equal( $("#log").html(), "afterclick,1,click,afterclick,click,", "Click order not valid."); equal( logOutput(), "click,afterclick,click,1,afterclick", "Click order not valid." );
}); });
test( "refresh", function() { test( "refresh", function() {
expect( 5 ); expect( 5 );
var menu = $( "#menu1" ).menu(); var element = $( "#menu1" ).menu();
equal(menu.find(".ui-menu-item").length,5,"Incorrect number of menu items"); equal( element.find( ".ui-menu-item" ).length, 5, "Incorrect number of menu items" );
menu.append("<li><a href='#'>test item</a></li>").menu("refresh"); element.append( "<li><a href='#'>test item</a></li>" ).menu( "refresh" );
equal(menu.find(".ui-menu-item").length,6,"Incorrect number of menu items"); equal( element.find( ".ui-menu-item" ).length, 6, "Incorrect number of menu items" );
menu.find(".ui-menu-item:last").remove().end().menu("refresh"); element.find( ".ui-menu-item:last" ).remove().end().menu( "refresh" );
equal(menu.find(".ui-menu-item").length,5,"Incorrect number of menu items"); equal( element.find( ".ui-menu-item" ).length, 5, "Incorrect number of menu items" );
menu.append("<li>---</li>").menu("refresh"); element.append( "<li>---</li>" ).menu( "refresh" );
equal(menu.find(".ui-menu-item").length,5,"Incorrect number of menu items"); equal( element.find( ".ui-menu-item" ).length, 5, "Incorrect number of menu items" );
menu.children(":last").remove().end().menu("refresh"); element.children( ":last" ).remove().end().menu( "refresh" );
equal(menu.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("destroy", function() { // TODO: test focus method
domEqual("#menu1", function() {
$("#menu1").menu().menu("destroy"); // TODO: test blur method
// TODO: test collapseAll method
// TODO: test collapse method
// TODO: test expand method
// TODO: test next method
// TODO: test prev method
// TODO: test isFirstItem method
// TODO: test isLastItem method
// TODO: test nextPage method
// TODO: test prevPage method
// TODO: test select method
test( "destroy", function() {
expect( 4 );
domEqual( "#menu1", function() {
$( "#menu1" ).menu().menu( "destroy" );
}); });
domEqual("#menu5", function() { domEqual( "#menu2", function() {
$("#menu5").menu().menu("destroy"); $( "#menu2" ).menu().menu( "destroy" );
}); });
domEqual("#menu6", function() { domEqual( "#menu5", function() {
$("#menu6").menu().menu("destroy"); $( "#menu5").menu().menu( "destroy" );
});
domEqual( "#menu6", function() {
$( "#menu6" ).menu().menu( "destroy" );
}); });
}); });
})( jQuery );
})(jQuery);

View File

@ -1,67 +1,112 @@
/* (function( $ ) {
* menu_options.js
*/
(function($) {
var log = TestHelpers.menu.log, var log = TestHelpers.menu.log,
logOutput = TestHelpers.menu.logOutput,
click = TestHelpers.menu.click; click = TestHelpers.menu.click;
module("menu: options"); module( "menu: options", {
setup: function() {
TestHelpers.menu.clearLog();
}
});
test( "{ disabled: true }", function() { test( "{ disabled: true }", function() {
expect( 2 ); expect( 2 );
var menu = $( "#menu1" ).menu({ var element = $( "#menu1" ).menu({
disabled: true, disabled: true,
select: function(event, ui) { select: function(event, ui) {
log(); log();
} }
}); });
ok(menu.is(".ui-state-disabled"),"Missing ui-state-disabled class"); ok( element.hasClass( "ui-state-disabled" ), "Missing ui-state-disabled class" );
log("click",true); log( "click", true );
click(menu,"1"); click( element, "1" );
log("afterclick"); log( "afterclick" );
equal( $("#log").html(), "afterclick,click,", "Click order not valid."); equal( logOutput(), "click,afterclick", "Click order not valid." );
}); });
test( "{ disabled: false }", function() { test( "{ disabled: false }", function() {
expect( 2 ); expect( 2 );
var menu = $( "#menu1" ).menu({ var element = $( "#menu1" ).menu({
disabled: false, disabled: false,
select: function(event, ui) { select: function( event, ui ) {
log(); log();
} }
}); });
ok(menu.not(".ui-state-disabled"),"Has ui-state-disabled class"); ok( !element.hasClass( "ui-state-disabled" ), "Has ui-state-disabled class" );
log("click",true); log( "click", true );
click(menu,"1"); click( element, "1" );
log("afterclick"); log( "afterclick" );
equal( $("#log").html(), "afterclick,1,click,", "Click order not valid."); equal( logOutput(), "click,1,afterclick", "Click order not valid." );
}); });
test("{ role: 'menu' } ", function () { test( "{ icons: default }", function() {
var menu = $('#menu1').menu(); expect( 1 );
expect(2 + 5 * $("li", menu).length); var element = $( "#menu2" ).menu();
equal( menu.attr( "role" ), "menu" ); equal( element.find( ".ui-menu-icon" ).attr( "class" ), "ui-menu-icon ui-icon ui-icon-carat-1-e" );
ok( $("li", menu).length > 0, "number of menu items"); });
$("li", menu).each(function(item) {
ok( $(this).hasClass("ui-menu-item"), "menu item ("+ item + ") class for item"); test( "{ icons: { submenu: 'custom' } }", function() {
equal( $(this).attr("role"), "presentation", "menu item ("+ item + ") role"); expect( 1 );
equal( $("a", this).attr("role"), "menuitem", "menu item ("+ item + ") role"); var element = $( "#menu2" ).menu({
ok( $("a",this).hasClass("ui-corner-all"), "a element class for menu item ("+ item + ") "); icons: {
equal( $("a",this).attr("tabindex"), "-1", "a element tabindex for menu item ("+ item + ") "); submenu: "custom-class"
}
});
equal( element.find( ".ui-menu-icon" ).attr( "class" ), "ui-menu-icon ui-icon custom-class" );
});
// TODO: test menus option
// TODO: test position option
test( "{ role: 'menu' } ", function() {
var element = $( "#menu1" ).menu(),
items = element.find( "li" );
expect( 2 + 5 * items.length );
equal( element.attr( "role" ), "menu" );
ok( items.length > 0, "number of menu items" );
items.each(function( item ) {
ok( $( this ).hasClass( "ui-menu-item" ), "menu item ("+ item + ") class for item" );
equal( $( this ).attr( "role" ), "presentation", "menu item ("+ item + ") role" );
equal( $( "a", this ).attr( "role" ), "menuitem", "menu item ("+ item + ") role" );
ok( $( "a", this ).hasClass( "ui-corner-all" ), "a element class for menu item ("+ item + ")" );
equal( $( "a", this ).attr( "tabindex" ), "-1", "a element tabindex for menu item ("+ item + ")" );
}); });
}); });
test("{ role: 'listbox' } ", function () { test( "{ role: 'listbox' } ", function() {
var menu = $('#menu1').menu({ var element = $( "#menu1" ).menu({
role: "listbox" role: "listbox"
}); }),
expect(2 + $("li", menu).length); items = element.find( "li" );
equal( menu.attr( "role" ), "listbox" ); expect( 2 + 5 * items.length );
ok( ($("li", menu).length > 0 ), "number of menu items"); equal( element.attr( "role" ), "listbox" );
$("li", menu).each(function(item) { ok( items.length > 0, "number of menu items" );
equal( $("a", this).attr("role"), "option", "menu item ("+ item + ") role"); items.each(function( item ) {
ok( $( this ).hasClass( "ui-menu-item" ), "menu item ("+ item + ") class for item" );
equal( $( this ).attr( "role" ), "presentation", "menu item ("+ item + ") role" );
equal( $( "a", this ).attr( "role" ), "option", "menu item ("+ item + ") role" );
ok( $( "a", this ).hasClass( "ui-corner-all" ), "a element class for menu item ("+ item + ")" );
equal( $( "a", this ).attr( "tabindex" ), "-1", "a element tabindex for menu item ("+ item + ")" );
}); });
}); });
})(jQuery); test( "{ role: null }", function() {
var element = $( "#menu1" ).menu({
role: null
}),
items = element.find( "li" );
expect( 2 + 5 * items.length );
strictEqual( element.attr( "role" ), undefined );
ok( items.length > 0, "number of menu items" );
items.each(function( item ) {
ok( $( this ).hasClass( "ui-menu-item" ), "menu item ("+ item + ") class for item" );
equal( $( this ).attr( "role" ), "presentation", "menu item ("+ item + ") role" );
equal( $( "a", this ).attr( "role" ), undefined, "menu item ("+ item + ") role" );
ok( $( "a", this ).hasClass( "ui-corner-all" ), "a element class for menu item ("+ item + ")" );
equal( $( "a", this ).attr( "tabindex" ), "-1", "a element tabindex for menu item ("+ item + ")" );
});
});
})( jQuery );

View File

@ -1,16 +1,31 @@
(function() {
var lastItem,
log = [];
TestHelpers.menu = { TestHelpers.menu = {
log: function( message, clear ) { log: function( message, clear ) {
if ( clear ) { if ( clear ) {
$( "#log" ).empty(); log.length = 0;
} }
if ( message === undefined ) { if ( message === undefined ) {
message = $( "#log" ).data( "lastItem" ); message = lastItem;
} }
$( "#log" ).prepend( $.trim( message ) + "," ); log.push( $.trim( message ) );
},
logOutput: function() {
return log.join( "," );
},
clearLog: function() {
log.length = 0;
}, },
click: function( menu, item ) { click: function( menu, item ) {
$( "#log" ).data( "lastItem", item ); lastItem = item;
menu.children( ":eq(" + item + ")" ).find( "a:first" ).trigger( "click" ); menu.children( ":eq(" + item + ")" ).find( "a:first" ).trigger( "click" );
} }
}; };
})();

View File

@ -16,7 +16,7 @@ module( "position", {
} }
}); });
TestHelpers.testJshint( "ui.position" ); TestHelpers.testJshint( "position" );
test( "my, at, of", function() { test( "my, at, of", function() {
expect( 4 ); expect( 4 );

View File

@ -1,6 +1,7 @@
(function( $ ) { (function( $ ) {
test( "offset", function() { test( "offset", function() {
expect( 3 );
$( "#elx" ).position({ $( "#elx" ).position({
my: "left top", my: "left top",
at: "left bottom", at: "left bottom",

View File

@ -1,28 +1,20 @@
/* module( "progressbar: core" );
* progressbar_core.js
*/
var el; test( "accessibility", function() {
expect( 7 );
var element = $( "#progressbar" ).progressbar();
(function($) { equal( element.attr( "role" ), "progressbar", "aria role" );
equal( element.attr( "aria-valuemin" ), 0, "aria-valuemin" );
equal( element.attr( "aria-valuemax" ), 100, "aria-valuemax" );
equal( element.attr( "aria-valuenow" ), 0, "aria-valuenow initially" );
module("progressbar: core"); element.progressbar( "value", 77 );
equal( element.attr( "aria-valuenow" ), 77, "aria-valuenow" );
test("accessibility", function() { element.progressbar( "disable" );
expect(7); equal( element.attr( "aria-disabled" ), "true", "aria-disabled on" );
el = $("#progressbar").progressbar();
equal(el.attr("role"), "progressbar", "aria role"); element.progressbar( "enable" );
equal(el.attr("aria-valuemin"), 0, "aria-valuemin"); equal( element.attr( "aria-disabled" ), "false", "aria-disabled off" );
equal(el.attr("aria-valuemax"), 100, "aria-valuemax");
equal(el.attr("aria-valuenow"), 0, "aria-valuenow initially");
el.progressbar("value", 77);
equal(el.attr("aria-valuenow"), 77, "aria-valuenow");
el.progressbar("disable");
equal(el.attr("aria-disabled"), "true", "aria-disabled on");
el.progressbar("enable");
// FAIL: for some reason IE6 and 7 return a boolean false instead of the string
equal(el.attr("aria-disabled"), "false", "aria-disabled off");
}); });
})(jQuery);

View File

@ -1,51 +1,43 @@
/* module( "progressbar: events" );
* progressbar_events.js
*/
(function($) {
module("progressbar: events"); test( "create", function() {
expect( 1 );
test("create", function() { $( "#progressbar" ).progressbar({
expect(1);
$("#progressbar").progressbar({
value: 5, value: 5,
create: function() { create: function() {
deepEqual(5, $(this).progressbar("value") ); deepEqual( 5, $( this ).progressbar( "value" ) );
}, },
change: function() { change: function() {
ok(false, 'create() has triggered change()'); ok( false, "create() has triggered change()" );
} }
}); });
}); });
test("change", function() { test( "change", function() {
expect(1); expect( 1 );
$("#progressbar").progressbar({ $( "#progressbar" ).progressbar({
change: function() { change: function() {
deepEqual( 5, $(this).progressbar("value") ); deepEqual( 5, $( this ).progressbar( "value" ) );
} }
}).progressbar("value", 5); }).progressbar( "value", 5 );
}); });
test( "complete", function() { test( "complete", function() {
expect( 3 ); expect( 3 );
var changes = 0, var value,
value; changes = 0,
element = $( "#progressbar" ).progressbar({
$( "#progressbar" ).progressbar({ change: function() {
change: function() { changes++;
changes++; deepEqual( element.progressbar( "value" ), value, "change at " + value );
deepEqual( $( this ).progressbar( "value" ), value, "change at " + value ); },
}, complete: function() {
complete: function() { equal( changes, 2, "complete triggered after change" );
equal( changes, 2, "complete triggered after change" ); }
} });
});
value = 5; value = 5;
$( "#progressbar" ).progressbar( "value", value ); element.progressbar( "value", value );
value = 100; value = 100;
$( "#progressbar" ).progressbar( "value", value ); element.progressbar( "value", value );
}); });
})(jQuery);

View File

@ -1,36 +1,17 @@
/* module( "progressbar: methods" );
* progressbar_methods.js
*/
(function($) {
module("progressbar: methods");
test("init", function() {
expect(1);
$("<div></div>").appendTo('body').progressbar().remove();
ok(true, '.progressbar() called on element');
test( "destroy", function() {
expect( 1 );
domEqual( "#progressbar", function() {
$( "#progressbar" ).progressbar().progressbar( "destroy" );
});
}); });
test("destroy", function() { test( "value", function() {
expect(2); expect( 3 );
$("<div></div>").appendTo('body').progressbar().progressbar("destroy").remove(); var element = $( "<div>" ).progressbar({ value: 20 });
ok(true, '.progressbar("destroy") called on element'); equal( element.progressbar( "value" ), 20, "correct value as getter" );
equal( element.progressbar( "value", 30), element, "chainable as setter" );
var expected = $('<div></div>').progressbar(), equal( element.progressbar( "option", "value" ), 30, "correct value after setter" );
actual = expected.progressbar('destroy');
equal(actual, expected, 'destroy is chainable');
}); });
test('value', function() {
expect(3);
var el = $('<div></div>').progressbar({ value: 20 });
equal(el.progressbar('value'), 20, 'correct value as getter');
equal(el.progressbar('value', 30), el, 'chainable as setter');
equal(el.progressbar('option', 'value'), 30, 'correct value after setter');
});
})(jQuery);

View File

@ -1,13 +1,9 @@
/* module( "progressbar: options" );
* progressbar_options.js
*/
(function($) {
module("progressbar: options"); test( "{ value : 0 }, default", function() {
expect( 1 );
test("{ value : 0 }, default", function() { $( "#progressbar" ).progressbar();
$("#progressbar").progressbar(); equal( 0, $( "#progressbar" ).progressbar( "value" ) );
deepEqual( 0, $("#progressbar").progressbar("value") );
}); });
// Ticket #7231 - valueDiv should be hidden when value is at 0% // Ticket #7231 - valueDiv should be hidden when value is at 0%
@ -16,44 +12,51 @@ test( "value: visibility of valueDiv", function() {
var element = $( "#progressbar" ).progressbar({ var element = $( "#progressbar" ).progressbar({
value: 0 value: 0
}); });
ok( element.children( ".ui-progressbar-value" ).is( ":hidden" ), "valueDiv hidden when value is initialized at 0" ); ok( element.children( ".ui-progressbar-value" ).is( ":hidden" ),
"valueDiv hidden when value is initialized at 0" );
element.progressbar( "value", 1 ); element.progressbar( "value", 1 );
ok( element.children( ".ui-progressbar-value" ).is( ":visible" ), "valueDiv visible when value is set to 1" ); ok( element.children( ".ui-progressbar-value" ).is( ":visible" ),
"valueDiv visible when value is set to 1" );
element.progressbar( "value", 100 ); element.progressbar( "value", 100 );
ok( element.children( ".ui-progressbar-value" ).is( ":visible" ), "valueDiv visible when value is set to 100" ); ok( element.children( ".ui-progressbar-value" ).is( ":visible" ),
"valueDiv visible when value is set to 100" );
element.progressbar( "value", 0 ); element.progressbar( "value", 0 );
ok( element.children( ".ui-progressbar-value" ).is( ":hidden" ), "valueDiv hidden when value is set to 0" ); ok( element.children( ".ui-progressbar-value" ).is( ":hidden" ),
"valueDiv hidden when value is set to 0" );
element.progressbar( "value", -1 ); element.progressbar( "value", -1 );
ok( element.children( ".ui-progressbar-value" ).is( ":hidden" ), "valueDiv hidden when value set to -1 (normalizes to 0)" ); ok( element.children( ".ui-progressbar-value" ).is( ":hidden" ),
"valueDiv hidden when value set to -1 (normalizes to 0)" );
}); });
test("{ value : 5 }", function() { test( "{ value : 5 }", function() {
$("#progressbar").progressbar({ expect( 1 );
$( "#progressbar" ).progressbar({
value: 5 value: 5
}); });
deepEqual( 5, $("#progressbar").progressbar("value") ); equal( 5, $( "#progressbar" ).progressbar( "value" ) );
}); });
test("{ value : -5 }", function() { test( "{ value : -5 }", function() {
$("#progressbar").progressbar({ expect( 1 );
$( "#progressbar" ).progressbar({
value: -5 value: -5
}); });
deepEqual( 0, $("#progressbar").progressbar("value") ); deepEqual( 0, $( "#progressbar" ).progressbar( "value" ) );
}); });
test("{ value : 105 }", function() { test( "{ value : 105 }", function() {
$("#progressbar").progressbar({ expect( 1 );
$( "#progressbar" ).progressbar({
value: 105 value: 105
}); });
deepEqual( 100, $("#progressbar").progressbar("value") ); deepEqual( 100, $( "#progressbar" ).progressbar( "value" ) );
}); });
test("{ max : 5, value : 10 }", function() { test( "{ max : 5, value : 10 }", function() {
expect( 1 );
$("#progressbar").progressbar({ $("#progressbar").progressbar({
max: 5, max: 5,
value: 10 value: 10
}); });
deepEqual( 5, $("#progressbar").progressbar("value") ); deepEqual( 5, $( "#progressbar" ).progressbar( "value" ) );
}); });
})(jQuery);

View File

@ -16,6 +16,7 @@ function handle() {
module("slider: core"); module("slider: core");
test("keydown HOME on handle sets value to min", function() { test("keydown HOME on handle sets value to min", function() {
expect( 2 );
el = $('<div></div>'); el = $('<div></div>');
options = { options = {
max: 5, max: 5,
@ -50,6 +51,7 @@ test("keydown HOME on handle sets value to min", function() {
}); });
test("keydown END on handle sets value to max", function() { test("keydown END on handle sets value to max", function() {
expect( 2 );
el = $('<div></div>'); el = $('<div></div>');
options = { options = {
max: 5, max: 5,
@ -84,6 +86,7 @@ test("keydown END on handle sets value to max", function() {
}); });
test("keydown PAGE_UP on handle increases value by 1/5 range, not greater than max", function() { test("keydown PAGE_UP on handle increases value by 1/5 range, not greater than max", function() {
expect( 4 );
$.each(['horizontal', 'vertical'], function(i, orientation) { $.each(['horizontal', 'vertical'], function(i, orientation) {
el = $('<div></div>'); el = $('<div></div>');
options = { options = {
@ -107,6 +110,7 @@ test("keydown PAGE_UP on handle increases value by 1/5 range, not greater than m
}); });
test("keydown PAGE_DOWN on handle decreases value by 1/5 range, not less than min", function() { test("keydown PAGE_DOWN on handle decreases value by 1/5 range, not less than min", function() {
expect( 4 );
$.each(['horizontal', 'vertical'], function(i, orientation) { $.each(['horizontal', 'vertical'], function(i, orientation) {
el = $('<div></div>'); el = $('<div></div>');
options = { options = {
@ -130,6 +134,7 @@ test("keydown PAGE_DOWN on handle decreases value by 1/5 range, not less than mi
}); });
test("keydown UP on handle increases value by step, not greater than max", function() { test("keydown UP on handle increases value by step, not greater than max", function() {
expect( 4 );
el = $('<div></div>'); el = $('<div></div>');
options = { options = {
max: 5, max: 5,
@ -170,6 +175,7 @@ test("keydown UP on handle increases value by step, not greater than max", funct
}); });
test("keydown RIGHT on handle increases value by step, not greater than max", function() { test("keydown RIGHT on handle increases value by step, not greater than max", function() {
expect( 4 );
el = $('<div></div>'); el = $('<div></div>');
options = { options = {
max: 5, max: 5,
@ -210,6 +216,7 @@ test("keydown RIGHT on handle increases value by step, not greater than max", fu
}); });
test("keydown DOWN on handle decreases value by step, not less than min", function() { test("keydown DOWN on handle decreases value by step, not less than min", function() {
expect( 4 );
el = $('<div></div>'); el = $('<div></div>');
options = { options = {
max: 5, max: 5,
@ -250,6 +257,7 @@ test("keydown DOWN on handle decreases value by step, not less than min", functi
}); });
test("keydown LEFT on handle decreases value by step, not less than min", function() { test("keydown LEFT on handle decreases value by step, not less than min", function() {
expect( 4 );
el = $('<div></div>'); el = $('<div></div>');
options = { options = {
max: 5, max: 5,

View File

@ -12,8 +12,7 @@ module( "slider: events" );
test( "mouse based interaction", function() { test( "mouse based interaction", function() {
expect(4); expect(4);
var el = $( "<div></div>" ) var el = $( "#slider1" )
.appendTo( "body" )
.slider({ .slider({
start: function(event, ui) { start: function(event, ui) {
equal( event.originalEvent.type, "mousedown", "start triggered by mousedown" ); equal( event.originalEvent.type, "mousedown", "start triggered by mousedown" );
@ -37,8 +36,7 @@ test( "keyboard based interaction", function() {
expect(3); expect(3);
// Test keyup at end of handle slide (keyboard) // Test keyup at end of handle slide (keyboard)
var el = $( "<div></div>" ) var el = $( "#slider1" )
.appendTo( "body" )
.slider({ .slider({
start: function(event, ui) { start: function(event, ui) {
equal( event.originalEvent.type, "keydown", "start triggered by keydown" ); equal( event.originalEvent.type, "keydown", "start triggered by keydown" );

View File

@ -27,21 +27,14 @@ test("init", function() {
}); });
test("destroy", function() { test("destroy", function() {
$("<div></div>").appendTo('body').slider().slider("destroy").remove(); expect( 1 );
ok(true, '.slider("destroy") called on element'); domEqual( "#slider1", function() {
$( "#slider1" ).slider().slider( "destroy" );
$([]).slider().slider("destroy").remove(); });
ok(true, '.slider("destroy") called on empty collection');
$('<div></div>').appendTo('body').remove().slider().slider("destroy").remove();
ok(true, '.slider("destroy") called on disconnected DOMElement');
var expected = $('<div></div>').slider(),
actual = expected.slider('destroy');
equal(actual, expected, 'destroy is chainable');
}); });
test("enable", function() { test("enable", function() {
expect( 5 );
var el, var el,
expected = $('<div></div>').slider(), expected = $('<div></div>').slider(),
actual = expected.slider('enable'); actual = expected.slider('enable');
@ -56,6 +49,7 @@ test("enable", function() {
}); });
test("disable", function() { test("disable", function() {
expect( 5 );
var el, var el,
expected = $('<div></div>').slider(), expected = $('<div></div>').slider(),
actual = expected.slider('disable'); actual = expected.slider('disable');
@ -70,6 +64,7 @@ test("disable", function() {
}); });
test("value", function() { test("value", function() {
expect( 17 );
$([false, 'min', 'max']).each(function() { $([false, 'min', 'max']).each(function() {
var el = $('<div></div>').slider({ var el = $('<div></div>').slider({
range: this, range: this,

View File

@ -12,6 +12,7 @@ function handle() {
module("slider: options"); module("slider: options");
test("max", function() { test("max", function() {
expect( 2 );
el = $('<div></div>'); el = $('<div></div>');
options = { options = {
@ -30,6 +31,7 @@ test("max", function() {
}); });
test("min", function() { test("min", function() {
expect( 2 );
el = $('<div></div>'); el = $('<div></div>');
options = { options = {
@ -48,7 +50,8 @@ test("min", function() {
}); });
test("orientation", function() { test("orientation", function() {
el = $('<div></div>'); expect( 6 );
el = $('#slider1');
options = { options = {
max: 2, max: 2,
@ -62,7 +65,7 @@ test("orientation", function() {
el.slider(options).slider("option", "orientation", "horizontal"); el.slider(options).slider("option", "orientation", "horizontal");
ok(el.is('.ui-slider-horizontal'), "horizontal slider has class .ui-slider-horizontal"); ok(el.is('.ui-slider-horizontal'), "horizontal slider has class .ui-slider-horizontal");
ok(!el.is('.ui-slider-vertical'), "horizontal slider does not have class .ui-slider-vertical"); ok(!el.is('.ui-slider-vertical'), "horizontal slider does not have class .ui-slider-vertical");
equal(handle().css('left'), percentVal + '%', "horizontal slider handle is positioned with left: %"); equal(handle()[0].style.left, percentVal + '%', "horizontal slider handle is positioned with left: %");
el.slider('destroy'); el.slider('destroy');
@ -78,7 +81,7 @@ test("orientation", function() {
el.slider(options).slider("option", "orientation", "vertical"); el.slider(options).slider("option", "orientation", "vertical");
ok(el.is('.ui-slider-vertical'), "vertical slider has class .ui-slider-vertical"); ok(el.is('.ui-slider-vertical'), "vertical slider has class .ui-slider-vertical");
ok(!el.is('.ui-slider-horizontal'), "vertical slider does not have class .ui-slider-horizontal"); ok(!el.is('.ui-slider-horizontal'), "vertical slider does not have class .ui-slider-horizontal");
equal(handle().css('bottom'), percentVal + '%', "vertical slider handle is positioned with bottom: %"); equal(handle()[0].style.bottom, percentVal + '%', "vertical slider handle is positioned with bottom: %");
el.slider('destroy'); el.slider('destroy');
@ -92,6 +95,7 @@ test("orientation", function() {
// value option/method: the value option is not restricted by min/max/step. // value option/method: the value option is not restricted by min/max/step.
// What is returned by the value method is restricted by min (>=), max (<=), and step (even multiple) // What is returned by the value method is restricted by min (>=), max (<=), and step (even multiple)
test("step", function() { test("step", function() {
expect( 9 );
var el = $('<div></div>').slider({ var el = $('<div></div>').slider({
min: 0, min: 0,
value: 0, value: 0,
@ -112,7 +116,7 @@ test("step", function() {
el.slider("value", 19); el.slider("value", 19);
equal( el.slider("value"), 20 ); equal( el.slider("value"), 20 );
el = $('<div></div>').slider({ el = $('<div></div>').slider({
min: 0, min: 0,
value: 0, value: 0,
step: 20, step: 20,

View File

@ -5,7 +5,7 @@
<title>jQuery UI Spinner Test Suite</title> <title>jQuery UI Spinner Test Suite</title>
<script src="../../jquery.js"></script> <script src="../../jquery.js"></script>
<script src="../../../external/jquery.mousewheel-3.0.4.js"></script> <script src="../../../external/jquery.mousewheel.js"></script>
<script src="../../../external/globalize.js"></script> <script src="../../../external/globalize.js"></script>
<script src="../../../external/globalize.culture.ja-JP.js"></script> <script src="../../../external/globalize.culture.ja-JP.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css"> <link rel="stylesheet" href="../../../external/qunit.css">

View File

@ -2,6 +2,10 @@ TestHelpers.commonWidgetTests( "spinner", {
defaults: { defaults: {
culture: null, culture: null,
disabled: false, disabled: false,
icons: {
down: "ui-icon-triangle-1-s",
up: "ui-icon-triangle-1-n"
},
incremental: true, incremental: true,
max: null, max: null,
min: null, min: null,

View File

@ -220,6 +220,7 @@ asyncTest( "change", function() {
shouldChange( false, "min, value not changed" ); shouldChange( false, "min, value not changed" );
element.spinner( "option", "min", 200 ); element.spinner( "option", "min", 200 );
shouldChange( true, "cleanup" );
start(); start();
}); });
}); });

View File

@ -6,6 +6,25 @@ module( "spinner: options" );
// culture is tested after numberFormat, since it depends on numberFormat // culture is tested after numberFormat, since it depends on numberFormat
test( "icons: default ", function() {
expect( 2 );
var element = $( "#spin" ).val( 0 ).spinner().spinner( "widget" );
equal( element.find( ".ui-icon:first" ).attr( "class" ), "ui-icon ui-icon-triangle-1-n" );
equal( element.find( ".ui-icon:last" ).attr( "class" ), "ui-icon ui-icon-triangle-1-s" );
});
test( "icons: custom ", function() {
expect( 2 );
var element = $( "#spin" ).val( 0 ).spinner({
icons: {
down: "custom-down",
up: "custom-up"
}
}).spinner( "widget" );
equal( element.find( ".ui-icon:first" ).attr( "class" ), "ui-icon custom-up" );
equal( element.find( ".ui-icon:last" ).attr( "class" ), "ui-icon custom-down" );
});
test( "incremental, false", function() { test( "incremental, false", function() {
expect( 100 ); expect( 100 );

View File

@ -31,6 +31,14 @@
<script src="tabs_options.js"></script> <script src="tabs_options.js"></script>
<script src="../swarminject.js"></script> <script src="../swarminject.js"></script>
<style>
#tabs8, #tabs8 * {
margin: 0;
padding: 0;
font-size: 12px;
line-height: 15px;
}
</style>
</head> </head>
<body> <body>
@ -120,6 +128,23 @@
<div id="tabs7-1"></div> <div id="tabs7-1"></div>
</div> </div>
<div id="tabs8Wrapper">
<div id="tabs8">
<ul id="tabs8-list">
<li><a href="#tabs8-1">1</a></li>
<li><a href="#tabs8-2">2</a></li>
</ul>
<div id="tabs8-1">
<p>Lorem ipsum</p>
<p>Lorem ipsum</p>
<p>Lorem ipsum</p>
</div>
<div id="tabs8-2">
<p>Lorem ipsum</p>
</div>
</div>
</div>
</div> </div>
</body> </body>
</html> </html>

View File

@ -4,6 +4,7 @@ TestHelpers.commonWidgetTests( "tabs", {
collapsible: false, collapsible: false,
disabled: false, disabled: false,
event: "click", event: "click",
heightStyle: "content",
hide: null, hide: null,
show: null, show: null,

View File

@ -7,6 +7,7 @@ TestHelpers.commonWidgetTests( "tabs", {
cookie: null, cookie: null,
disabled: false, disabled: false,
event: "click", event: "click",
heightStyle: "content",
hide: null, hide: null,
fx: null, fx: null,
idPrefix: "ui-tabs-", idPrefix: "ui-tabs-",

View File

@ -63,8 +63,529 @@ test( "aria-controls", function() {
}); });
test( "accessibility", function() { test( "accessibility", function() {
// TODO: add tests expect( 49 );
expect( 0 ); var element = $( "#tabs1" ).tabs({
active: 1,
disabled: [ 2 ]
}),
tabs = element.find( ".ui-tabs-nav li" ),
anchors = tabs.find( ".ui-tabs-anchor" ),
panels = element.find( ".ui-tabs-panel" );
equal( element.find( ".ui-tabs-nav" ).attr( "role" ), "tablist", "tablist role" );
tabs.each(function( index ) {
var tab = tabs.eq( index ),
anchor = anchors.eq( index ),
anchorId = anchor.attr( "id" ),
panel = panels.eq( index );
equal( tab.attr( "role" ), "tab", "tab " + index + " role" );
equal( tab.attr( "aria-labelledby" ), anchorId, "tab " + index + " aria-labelledby" );
equal( anchor.attr( "role" ), "presentation", "anchor " + index + " role" );
equal( anchor.attr( "tabindex" ), -1, "anchor " + index + " tabindex" );
equal( panel.attr( "role" ), "tabpanel", "panel " + index + " role" );
equal( panel.attr( "aria-labelledby" ), anchorId, "panel " + index + " aria-labelledby" );
});
equal( tabs.eq( 1 ).attr( "aria-selected" ), "true", "active tab has aria-selected=true" );
equal( tabs.eq( 1 ).attr( "tabindex" ), 0, "active tab has tabindex=0" );
equal( tabs.eq( 1 ).attr( "aria-disabled" ), null, "enabled tab does not have aria-disabled" );
equal( panels.eq( 1 ).attr( "aria-expanded" ), "true", "active panel has aria-expanded=true" );
equal( panels.eq( 1 ).attr( "aria-hidden" ), "false", "active panel has aria-hidden=false" );
equal( tabs.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
equal( tabs.eq( 0 ).attr( "tabindex" ), -1, "inactive tab has tabindex=-1" );
equal( tabs.eq( 0 ).attr( "aria-disabled" ), null, "enabled tab does not have aria-disabled" );
equal( panels.eq( 0 ).attr( "aria-expanded" ), "false", "inactive panel has aria-expanded=false" );
equal( panels.eq( 0 ).attr( "aria-hidden" ), "true", "inactive panel has aria-hidden=true" );
equal( tabs.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
equal( tabs.eq( 2 ).attr( "tabindex" ), -1, "inactive tab has tabindex=-1" );
equal( tabs.eq( 2 ).attr( "aria-disabled" ), "true", "disabled tab has aria-disabled=true" );
equal( panels.eq( 2 ).attr( "aria-expanded" ), "false", "inactive panel has aria-expanded=false" );
equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "inactive panel has aria-hidden=true" );
element.tabs( "option", "active", 0 );
equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "active tab has aria-selected=true" );
equal( tabs.eq( 0 ).attr( "tabindex" ), 0, "active tab has tabindex=0" );
equal( tabs.eq( 0 ).attr( "aria-disabled" ), null, "enabled tab does not have aria-disabled" );
equal( panels.eq( 0 ).attr( "aria-expanded" ), "true", "active panel has aria-expanded=true" );
equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "active panel has aria-hidden=false" );
equal( tabs.eq( 1 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
equal( tabs.eq( 1 ).attr( "tabindex" ), -1, "inactive tab has tabindex=-1" );
equal( tabs.eq( 1 ).attr( "aria-disabled" ), null, "enabled tab does not have aria-disabled" );
equal( panels.eq( 1 ).attr( "aria-expanded" ), "false", "inactive panel has aria-expanded=false" );
equal( panels.eq( 1 ).attr( "aria-hidden" ), "true", "inactive panel has aria-hidden=true" );
equal( tabs.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
equal( tabs.eq( 2 ).attr( "tabindex" ), -1, "inactive tab has tabindex=-1" );
equal( tabs.eq( 2 ).attr( "aria-disabled" ), "true", "disabled tab has aria-disabled=true" );
equal( panels.eq( 2 ).attr( "aria-expanded" ), "false", "inactive panel has aria-expanded=false" );
equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "inactive panel has aria-hidden=true" );
});
asyncTest( "accessibility - ajax", function() {
expect( 4 );
var element = $( "#tabs2" ).tabs(),
tab = element.find( ".ui-tabs-nav li" ).eq( 3 ),
panel = $( "#custom-id" );
equal( panel.attr( "aria-live" ), "polite", "remote panel has aria-live" );
equal( panel.attr( "aria-busy" ), null, "does not have aria-busy on init" );
element.tabs( "option", "active", 3 );
equal( panel.attr( "aria-busy" ), "true", "panel has aria-busy during load" );
element.one( "tabsload", function() {
setTimeout(function() {
equal( panel.attr( "aria-busy" ), null, "panel does not have aria-busy after load" );
start();
}, 1 );
});
});
asyncTest( "keyboard support - LEFT, RIGHT, UP, DOWN, HOME, END, SPACE, ENTER", function() {
expect( 92 );
var element = $( "#tabs1" ).tabs({
collapsible: true
}),
tabs = element.find( ".ui-tabs-nav li" ),
panels = element.find( ".ui-tabs-panel" ),
keyCode = $.ui.keyCode;
element.data( "tabs" ).delay = 50;
equal( tabs.filter( ".ui-state-focus" ).length, 0, "no tabs focused on init" );
tabs.eq( 0 ).simulate( "focus" );
// down, right, down (wrap), up (wrap)
function step1() {
ok( tabs.eq( 0 ).is( ".ui-state-focus" ), "first tab has focus" );
equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
tabs.eq( 0 ).simulate( "keydown", { keyCode: keyCode.DOWN } );
ok( tabs.eq( 1 ).is( ".ui-state-focus" ), "DOWN moves focus to next tab" );
ok( !tabs.eq( 0 ).is( ".ui-state-focus" ), "first tab is no longer focused" );
equal( tabs.eq( 1 ).attr( "aria-selected" ), "true", "second tab has aria-selected=true" );
equal( tabs.eq( 0 ).attr( "aria-selected" ), "false", "first tab has aria-selected=false" );
ok( panels.eq( 1 ).is( ":hidden" ), "second panel is still hidden" );
equal( panels.eq( 1 ).attr( "aria-expanded" ), "false", "second panel has aria-expanded=false" );
equal( panels.eq( 1 ).attr( "aria-hidden" ), "true", "second panel has aria-hidden=true" );
ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
equal( panels.eq( 0 ).attr( "aria-expanded" ), "true", "first panel has aria-expanded=true" );
equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
tabs.eq( 1 ).simulate( "keydown", { keyCode: keyCode.RIGHT } );
ok( tabs.eq( 2 ).is( ".ui-state-focus" ), "RIGHT moves focus to next tab" );
equal( tabs.eq( 2 ).attr( "aria-selected" ), "true", "third tab has aria-selected=true" );
equal( tabs.eq( 1 ).attr( "aria-selected" ), "false", "second tab has aria-selected=false" );
ok( panels.eq( 2 ).is( ":hidden" ), "third panel is still hidden" );
equal( panels.eq( 2 ).attr( "aria-expanded" ), "false", "third panel has aria-expanded=false" );
equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
equal( panels.eq( 0 ).attr( "aria-expanded" ), "true", "first panel has aria-expanded=true" );
equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
tabs.eq( 2 ).simulate( "keydown", { keyCode: keyCode.DOWN } );
ok( tabs.eq( 0 ).is( ".ui-state-focus" ), "DOWN wraps focus to first tab" );
equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
equal( tabs.eq( 2 ).attr( "aria-selected" ), "false", "third tab has aria-selected=false" );
ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
equal( panels.eq( 0 ).attr( "aria-expanded" ), "true", "first panel has aria-expanded=true" );
equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
tabs.eq( 0 ).simulate( "keydown", { keyCode: keyCode.UP } );
ok( tabs.eq( 2 ).is( ".ui-state-focus" ), "UP wraps focus to last tab" );
equal( tabs.eq( 2 ).attr( "aria-selected" ), "true", "third tab has aria-selected=true" );
equal( tabs.eq( 0 ).attr( "aria-selected" ), "false", "first tab has aria-selected=false" );
ok( panels.eq( 2 ).is( ":hidden" ), "third panel is still hidden" );
equal( panels.eq( 2 ).attr( "aria-expanded" ), "false", "third panel has aria-expanded=false" );
equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
equal( panels.eq( 0 ).attr( "aria-expanded" ), "true", "first panel has aria-expanded=true" );
equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
setTimeout( step2, 100 );
}
// left, home, space
function step2() {
equal( tabs.eq( 2 ).attr( "aria-selected" ), "true", "third tab has aria-selected=true" );
equal( tabs.eq( 0 ).attr( "aria-selected" ), "false", "first tab has aria-selected=false" );
ok( panels.eq( 2 ).is( ":visible" ), "third panel is visible" );
equal( panels.eq( 2 ).attr( "aria-expanded" ), "true", "third panel has aria-expanded=true" );
equal( panels.eq( 2 ).attr( "aria-hidden" ), "false", "third panel has aria-hidden=false" );
ok( panels.eq( 0 ).is( ":hidden" ), "first panel is hidden" );
equal( panels.eq( 0 ).attr( "aria-expanded" ), "false", "first panel has aria-expanded=false" );
equal( panels.eq( 0 ).attr( "aria-hidden" ), "true", "first panel has aria-hidden=true" );
tabs.eq( 2 ).simulate( "keydown", { keyCode: keyCode.LEFT } );
ok( tabs.eq( 1 ).is( ".ui-state-focus" ), "LEFT moves focus to previous tab" );
equal( tabs.eq( 1 ).attr( "aria-selected" ), "true", "second tab has aria-selected=true" );
equal( tabs.eq( 2 ).attr( "aria-selected" ), "false", "third tab has aria-selected=false" );
ok( panels.eq( 1 ).is( ":hidden" ), "second panel is still hidden" );
equal( panels.eq( 1 ).attr( "aria-expanded" ), "false", "second panel has aria-expanded=false" );
equal( panels.eq( 1 ).attr( "aria-hidden" ), "true", "second panel has aria-hidden=true" );
ok( panels.eq( 2 ).is( ":visible" ), "third panel is still visible" );
equal( panels.eq( 2 ).attr( "aria-expanded" ), "true", "third panel has aria-expanded=true" );
equal( panels.eq( 2 ).attr( "aria-hidden" ), "false", "third panel has aria-hidden=false" );
tabs.eq( 1 ).simulate( "keydown", { keyCode: keyCode.HOME } );
ok( tabs.eq( 0 ).is( ".ui-state-focus" ), "HOME moves focus to first tab" );
equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
equal( tabs.eq( 1 ).attr( "aria-selected" ), "false", "second tab has aria-selected=false" );
ok( panels.eq( 0 ).is( ":hidden" ), "first panel is still hidden" );
equal( panels.eq( 0 ).attr( "aria-expanded" ), "false", "first panel has aria-expanded=false" );
equal( panels.eq( 0 ).attr( "aria-hidden" ), "true", "first panel has aria-hidden=true" );
ok( panels.eq( 2 ).is( ":visible" ), "third panel is still visible" );
equal( panels.eq( 2 ).attr( "aria-expanded" ), "true", "third panel has aria-expanded=true" );
equal( panels.eq( 2 ).attr( "aria-hidden" ), "false", "third panel has aria-hidden=false" );
// SPACE activates, cancels delay
tabs.eq( 0 ).simulate( "keydown", { keyCode: keyCode.SPACE } );
setTimeout( step3, 1 );
}
// end, enter
function step3() {
equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
equal( tabs.eq( 2 ).attr( "aria-selected" ), "false", "third tab has aria-selected=false" );
ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
equal( panels.eq( 0 ).attr( "aria-expanded" ), "true", "first panel has aria-expanded=true" );
equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
ok( panels.eq( 2 ).is( ":hidden" ), "third panel is hidden" );
equal( panels.eq( 2 ).attr( "aria-expanded" ), "false", "third panel has aria-expanded=false" );
equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
tabs.eq( 0 ).simulate( "keydown", { keyCode: keyCode.END } );
ok( tabs.eq( 2 ).is( ".ui-state-focus" ), "END moves focus to last tab" );
equal( tabs.eq( 2 ).attr( "aria-selected" ), "true", "third tab has aria-selected=true" );
equal( tabs.eq( 0 ).attr( "aria-selected" ), "false", "first tab has aria-selected=false" );
ok( panels.eq( 2 ).is( ":hidden" ), "third panel is still hidden" );
equal( panels.eq( 2 ).attr( "aria-expanded" ), "false", "third panel has aria-expanded=false" );
equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
equal( panels.eq( 0 ).attr( "aria-expanded" ), "true", "first panel has aria-expanded=true" );
equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
// ENTER activates, cancels delay
tabs.eq( 0 ).simulate( "keydown", { keyCode: keyCode.ENTER } );
setTimeout( step4, 1 );
}
// enter (collapse)
function step4() {
equal( tabs.eq( 2 ).attr( "aria-selected" ), "true", "third tab has aria-selected=true" );
ok( panels.eq( 2 ).is( ":visible" ), "third panel is visible" );
equal( panels.eq( 2 ).attr( "aria-expanded" ), "true", "third panel has aria-expanded=true" );
equal( panels.eq( 2 ).attr( "aria-hidden" ), "false", "third panel has aria-hidden=false" );
ok( panels.eq( 0 ).is( ":hidden" ), "first panel is hidden" );
equal( panels.eq( 0 ).attr( "aria-expanded" ), "false", "first panel has aria-expanded=false" );
equal( panels.eq( 0 ).attr( "aria-hidden" ), "true", "first panel has aria-hidden=true" );
// ENTER collapses if active
tabs.eq( 2 ).simulate( "keydown", { keyCode: keyCode.ENTER } );
equal( tabs.eq( 2 ).attr( "aria-selected" ), "false", "third tab has aria-selected=false" );
ok( panels.eq( 2 ).is( ":hidden" ), "third panel is hidden" );
equal( panels.eq( 2 ).attr( "aria-expanded" ), "false", "third panel has aria-expanded=false" );
equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
// support: Firefox 12
// Firefox <13 passes arguments so we can't use setTimeout( start, 1 )
setTimeout(function() {
start();
}, 1 );
}
setTimeout( step1, 1 );
});
asyncTest( "keyboard support - CTRL navigation", function() {
expect( 115 );
var element = $( "#tabs1" ).tabs(),
tabs = element.find( ".ui-tabs-nav li" ),
panels = element.find( ".ui-tabs-panel" ),
keyCode = $.ui.keyCode;
element.data( "tabs" ).delay = 50;
equal( tabs.filter( ".ui-state-focus" ).length, 0, "no tabs focused on init" );
tabs.eq( 0 ).simulate( "focus" );
// down
function step1() {
ok( tabs.eq( 0 ).is( ".ui-state-focus" ), "first tab has focus" );
equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
tabs.eq( 0 ).simulate( "keydown", { keyCode: keyCode.DOWN, ctrlKey: true } );
ok( tabs.eq( 1 ).is( ".ui-state-focus" ), "DOWN moves focus to next tab" );
ok( !tabs.eq( 0 ).is( ".ui-state-focus" ), "first tab is no longer focused" );
equal( tabs.eq( 1 ).attr( "aria-selected" ), "false", "second tab has aria-selected=false" );
equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
ok( panels.eq( 1 ).is( ":hidden" ), "second panel is still hidden" );
equal( panels.eq( 1 ).attr( "aria-expanded" ), "false", "second panel has aria-expanded=false" );
equal( panels.eq( 1 ).attr( "aria-hidden" ), "true", "second panel has aria-hidden=true" );
ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
equal( panels.eq( 0 ).attr( "aria-expanded" ), "true", "first panel has aria-expanded=true" );
equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
setTimeout( step2, 100 );
}
// right
function step2() {
equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
equal( panels.eq( 0 ).attr( "aria-expanded" ), "true", "first panel has aria-expanded=true" );
equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
ok( panels.eq( 1 ).is( ":hidden" ), "second panel is hidden" );
equal( panels.eq( 1 ).attr( "aria-expanded" ), "false", "second panel has aria-expanded=false" );
equal( panels.eq( 1 ).attr( "aria-hidden" ), "true", "second panel has aria-hidden=true" );
tabs.eq( 1 ).simulate( "keydown", { keyCode: keyCode.RIGHT, ctrlKey: true } );
ok( tabs.eq( 2 ).is( ".ui-state-focus" ), "RIGHT moves focus to next tab" );
equal( tabs.eq( 2 ).attr( "aria-selected" ), "false", "third tab has aria-selected=false" );
equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
ok( panels.eq( 2 ).is( ":hidden" ), "third panel is still hidden" );
equal( panels.eq( 2 ).attr( "aria-expanded" ), "false", "third panel has aria-expanded=false" );
equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
equal( panels.eq( 0 ).attr( "aria-expanded" ), "true", "first panel has aria-expanded=true" );
equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
setTimeout( step3, 100 );
}
// down (wrap)
function step3() {
equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
equal( panels.eq( 0 ).attr( "aria-expanded" ), "true", "first panel has aria-expanded=true" );
equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
ok( panels.eq( 2 ).is( ":hidden" ), "third panel is hidden" );
equal( panels.eq( 2 ).attr( "aria-expanded" ), "false", "third panel has aria-expanded=false" );
equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
tabs.eq( 2 ).simulate( "keydown", { keyCode: keyCode.DOWN, ctrlKey: true } );
ok( tabs.eq( 0 ).is( ".ui-state-focus" ), "DOWN wraps focus to first tab" );
equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
equal( panels.eq( 0 ).attr( "aria-expanded" ), "true", "first panel has aria-expanded=true" );
equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
setTimeout( step4, 100 );
}
// up (wrap)
function step4() {
equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
equal( panels.eq( 0 ).attr( "aria-expanded" ), "true", "first panel has aria-expanded=true" );
equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
tabs.eq( 0 ).simulate( "keydown", { keyCode: keyCode.UP, ctrlKey: true } );
ok( tabs.eq( 2 ).is( ".ui-state-focus" ), "UP wraps focus to last tab" );
equal( tabs.eq( 2 ).attr( "aria-selected" ), "false", "third tab has aria-selected=false" );
equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
ok( panels.eq( 2 ).is( ":hidden" ), "third panel is still hidden" );
equal( panels.eq( 2 ).attr( "aria-expanded" ), "false", "third panel has aria-expanded=false" );
equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
equal( panels.eq( 0 ).attr( "aria-expanded" ), "true", "first panel has aria-expanded=true" );
equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
setTimeout( step5, 100 );
}
// left
function step5() {
equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
equal( panels.eq( 0 ).attr( "aria-expanded" ), "true", "first panel has aria-expanded=true" );
equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
ok( panels.eq( 2 ).is( ":hidden" ), "third panel is hidden" );
equal( panels.eq( 2 ).attr( "aria-expanded" ), "false", "third panel has aria-expanded=false" );
equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
tabs.eq( 2 ).simulate( "keydown", { keyCode: keyCode.LEFT, ctrlKey: true } );
ok( tabs.eq( 1 ).is( ".ui-state-focus" ), "LEFT moves focus to previous tab" );
equal( tabs.eq( 1 ).attr( "aria-selected" ), "false", "second tab has aria-selected=false" );
equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
ok( panels.eq( 1 ).is( ":hidden" ), "second panel is still hidden" );
equal( panels.eq( 1 ).attr( "aria-expanded" ), "false", "second panel has aria-expanded=false" );
equal( panels.eq( 1 ).attr( "aria-hidden" ), "true", "second panel has aria-hidden=true" );
ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
equal( panels.eq( 0 ).attr( "aria-expanded" ), "true", "first panel has aria-expanded=true" );
equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
setTimeout( step6, 100 );
}
// home
function step6() {
equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
equal( panels.eq( 0 ).attr( "aria-expanded" ), "true", "first panel has aria-expanded=true" );
equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
ok( panels.eq( 1 ).is( ":hidden" ), "second panel is hidden" );
equal( panels.eq( 1 ).attr( "aria-expanded" ), "false", "second panel has aria-expanded=false" );
equal( panels.eq( 1 ).attr( "aria-hidden" ), "true", "second panel has aria-hidden=true" );
tabs.eq( 1 ).simulate( "keydown", { keyCode: keyCode.HOME, ctrlKey: true } );
ok( tabs.eq( 0 ).is( ".ui-state-focus" ), "HOME moves focus to first tab" );
equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
equal( tabs.eq( 1 ).attr( "aria-selected" ), "false", "second tab has aria-selected=false" );
ok( panels.eq( 1 ).is( ":hidden" ), "second panel is still hidden" );
equal( panels.eq( 1 ).attr( "aria-expanded" ), "false", "second panel has aria-expanded=false" );
equal( panels.eq( 1 ).attr( "aria-hidden" ), "true", "second panel has aria-hidden=true" );
ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
equal( panels.eq( 0 ).attr( "aria-expanded" ), "true", "first panel has aria-expanded=true" );
equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
setTimeout( step7, 100 );
}
// end
function step7() {
equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
equal( panels.eq( 0 ).attr( "aria-expanded" ), "true", "first panel has aria-expanded=true" );
equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
tabs.eq( 0 ).simulate( "keydown", { keyCode: keyCode.END, ctrlKey: true } );
ok( tabs.eq( 2 ).is( ".ui-state-focus" ), "END moves focus to last tab" );
equal( tabs.eq( 2 ).attr( "aria-selected" ), "false", "third tab has aria-selected=false" );
equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
ok( panels.eq( 2 ).is( ":hidden" ), "third panel is still hidden" );
equal( panels.eq( 2 ).attr( "aria-expanded" ), "false", "third panel has aria-expanded=false" );
equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
ok( panels.eq( 0 ).is( ":visible" ), "first panel is still visible" );
equal( panels.eq( 0 ).attr( "aria-expanded" ), "true", "first panel has aria-expanded=true" );
equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
setTimeout( step8, 100 );
}
// space
function step8() {
equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
equal( panels.eq( 0 ).attr( "aria-expanded" ), "true", "first panel has aria-expanded=true" );
equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
ok( panels.eq( 2 ).is( ":hidden" ), "third panel is hidden" );
equal( panels.eq( 2 ).attr( "aria-expanded" ), "false", "third panel has aria-expanded=false" );
equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
tabs.eq( 2 ).simulate( "keydown", { keyCode: keyCode.SPACE } );
equal( tabs.eq( 2 ).attr( "aria-selected" ), "true", "third tab has aria-selected=true" );
equal( tabs.eq( 0 ).attr( "aria-selected" ), "false", "first tab has aria-selected=false" );
ok( panels.eq( 2 ).is( ":visible" ), "third panel is visible" );
equal( panels.eq( 2 ).attr( "aria-expanded" ), "true", "third panel has aria-expanded=true" );
equal( panels.eq( 2 ).attr( "aria-hidden" ), "false", "third panel has aria-hidden=false" );
ok( panels.eq( 0 ).is( ":hidden" ), "first panel is hidden" );
equal( panels.eq( 0 ).attr( "aria-expanded" ), "false", "first panel has aria-expanded=false" );
equal( panels.eq( 0 ).attr( "aria-hidden" ), "true", "first panel has aria-hidden=true" );
// support: Firefox 12
// Firefox <13 passes arguments so we can't use setTimeout( start, 1 )
setTimeout(function() {
start();
}, 1 );
}
setTimeout( step1, 1 );
});
asyncTest( "keyboard support - CTRL+UP, ALT+PAGE_DOWN, ALT+PAGE_UP", function() {
expect( 50 );
var element = $( "#tabs1" ).tabs(),
tabs = element.find( ".ui-tabs-nav li" ),
panels = element.find( ".ui-tabs-panel" ),
keyCode = $.ui.keyCode;
equal( tabs.filter( ".ui-state-focus" ).length, 0, "no tabs focused on init" );
panels.attr( "tabindex", -1 );
panels.eq( 0 ).simulate( "focus" );
function step1() {
strictEqual( document.activeElement, panels[ 0 ], "first panel is activeElement" );
panels.eq( 0 ).simulate( "keydown", { keyCode: keyCode.PAGE_DOWN, altKey: true } );
strictEqual( document.activeElement, tabs[ 1 ], "second tab is activeElement" );
ok( tabs.eq( 1 ).is( ".ui-state-focus" ), "ALT+PAGE_DOWN moves focus to next tab" );
equal( tabs.eq( 1 ).attr( "aria-selected" ), "true", "second tab has aria-selected=true" );
ok( panels.eq( 1 ).is( ":visible" ), "second panel is visible" );
equal( panels.eq( 1 ).attr( "aria-expanded" ), "true", "second panel has aria-expanded=true" );
equal( panels.eq( 1 ).attr( "aria-hidden" ), "false", "second panel has aria-hidden=false" );
ok( panels.eq( 0 ).is( ":hidden" ), "first panel is hidden" );
equal( panels.eq( 0 ).attr( "aria-expanded" ), "false", "first panel has aria-expanded=false" );
equal( panels.eq( 0 ).attr( "aria-hidden" ), "true", "first panel has aria-hidden=true" );
tabs.eq( 1 ).simulate( "keydown", { keyCode: keyCode.PAGE_DOWN, altKey: true } );
strictEqual( document.activeElement, tabs[ 2 ], "third tab is activeElement" );
ok( tabs.eq( 2 ).is( ".ui-state-focus" ), "ALT+PAGE_DOWN moves focus to next tab" );
equal( tabs.eq( 2 ).attr( "aria-selected" ), "true", "third tab has aria-selected=true" );
ok( panels.eq( 2 ).is( ":visible" ), "third panel is visible" );
equal( panels.eq( 2 ).attr( "aria-expanded" ), "true", "third panel has aria-expanded=true" );
equal( panels.eq( 2 ).attr( "aria-hidden" ), "false", "third panel has aria-hidden=false" );
ok( panels.eq( 1 ).is( ":hidden" ), "second panel is hidden" );
equal( panels.eq( 1 ).attr( "aria-expanded" ), "false", "second panel has aria-expanded=false" );
equal( panels.eq( 1 ).attr( "aria-hidden" ), "true", "second panel has aria-hidden=true" );
tabs.eq( 2 ).simulate( "keydown", { keyCode: keyCode.PAGE_DOWN, altKey: true } );
strictEqual( document.activeElement, tabs[ 0 ], "first tab is activeElement" );
ok( tabs.eq( 0 ).is( ".ui-state-focus" ), "ALT+PAGE_DOWN wraps focus to first tab" );
equal( tabs.eq( 0 ).attr( "aria-selected" ), "true", "first tab has aria-selected=true" );
ok( panels.eq( 0 ).is( ":visible" ), "first panel is visible" );
equal( panels.eq( 0 ).attr( "aria-expanded" ), "true", "first panel has aria-expanded=true" );
equal( panels.eq( 0 ).attr( "aria-hidden" ), "false", "first panel has aria-hidden=false" );
ok( panels.eq( 2 ).is( ":hidden" ), "third panel is hidden" );
equal( panels.eq( 2 ).attr( "aria-expanded" ), "false", "third panel has aria-expanded=false" );
equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
panels.eq( 0 ).simulate( "focus" );
setTimeout( step2, 1 );
}
function step2() {
strictEqual( document.activeElement, panels[ 0 ], "first panel is activeElement" );
panels.eq( 0 ).simulate( "keydown", { keyCode: keyCode.PAGE_UP, altKey: true } );
strictEqual( document.activeElement, tabs[ 2 ], "third tab is activeElement" );
ok( tabs.eq( 2 ).is( ".ui-state-focus" ), "ALT+PAGE_UP wraps focus to last tab" );
equal( tabs.eq( 2 ).attr( "aria-selected" ), "true", "third tab has aria-selected=true" );
ok( panels.eq( 2 ).is( ":visible" ), "third panel is visible" );
equal( panels.eq( 2 ).attr( "aria-expanded" ), "true", "third panel has aria-expanded=true" );
equal( panels.eq( 2 ).attr( "aria-hidden" ), "false", "third panel has aria-hidden=false" );
ok( panels.eq( 0 ).is( ":hidden" ), "first panel is hidden" );
equal( panels.eq( 0 ).attr( "aria-expanded" ), "false", "first panel has aria-expanded=false" );
equal( panels.eq( 0 ).attr( "aria-hidden" ), "true", "first panel has aria-hidden=true" );
tabs.eq( 2 ).simulate( "keydown", { keyCode: keyCode.PAGE_UP, altKey: true } );
strictEqual( document.activeElement, tabs[ 1 ], "second tab is activeElement" );
ok( tabs.eq( 1 ).is( ".ui-state-focus" ), "ALT+PAGE_UP moves focus to previous tab" );
equal( tabs.eq( 1 ).attr( "aria-selected" ), "true", "second tab has aria-selected=true" );
ok( panels.eq( 1 ).is( ":visible" ), "second panel is visible" );
equal( panels.eq( 1 ).attr( "aria-expanded" ), "true", "second panel has aria-expanded=true" );
equal( panels.eq( 1 ).attr( "aria-hidden" ), "false", "second panel has aria-hidden=false" );
ok( panels.eq( 2 ).is( ":hidden" ), "third panel is hidden" );
equal( panels.eq( 2 ).attr( "aria-expanded" ), "false", "third panel has aria-expanded=false" );
equal( panels.eq( 2 ).attr( "aria-hidden" ), "true", "third panel has aria-hidden=true" );
panels.eq( 1 ).simulate( "focus" );
setTimeout( step3, 1 );
}
function step3() {
strictEqual( document.activeElement, panels[ 1 ], "second panel is activeElement" );
panels.eq( 1 ).simulate( "keydown", { keyCode: keyCode.UP, ctrlKey: true } );
strictEqual( document.activeElement, tabs[ 1 ], "second tab is activeElement" );
// support: Firefox 12
// Firefox <13 passes arguments so we can't use setTimeout( start, 1 )
setTimeout(function() {
start();
}, 1 );
}
setTimeout( step1, 1 );
}); });
test( "#3627 - Ajax tab with url containing a fragment identifier fails to load", function() { test( "#3627 - Ajax tab with url containing a fragment identifier fails to load", function() {

View File

@ -30,6 +30,14 @@
<script src="tabs_deprecated.js"></script> <script src="tabs_deprecated.js"></script>
<script src="../swarminject.js"></script> <script src="../swarminject.js"></script>
<style>
#tabs8, #tabs8 * {
margin: 0;
padding: 0;
font-size: 12px;
line-height: 15px;
}
</style>
</head> </head>
<body> <body>
@ -119,6 +127,23 @@
<div id="tabs7-1"></div> <div id="tabs7-1"></div>
</div> </div>
<div id="tabs8Wrapper">
<div id="tabs8">
<ul id="tabs8-list">
<li><a href="#tabs8-1">1</a></li>
<li><a href="#tabs8-2">2</a></li>
</ul>
<div id="tabs8-1">
<p>Lorem ipsum</p>
<p>Lorem ipsum</p>
<p>Lorem ipsum</p>
</div>
<div id="tabs8-2">
<p>Lorem ipsum</p>
</div>
</div>
</div>
</div> </div>
</body> </body>
</html> </html>

View File

@ -6,6 +6,7 @@ var disabled = TestHelpers.tabs.disabled,
module( "tabs: methods" ); module( "tabs: methods" );
test( "destroy", function() { test( "destroy", function() {
expect( 1 );
domEqual( "#tabs1", function() { domEqual( "#tabs1", function() {
$( "#tabs1" ).tabs().tabs( "destroy" ); $( "#tabs1" ).tabs().tabs( "destroy" );
}); });
@ -148,6 +149,26 @@ test( "refresh", function() {
disabled( element, false ); disabled( element, false );
}); });
test( "refresh - looping", function() {
expect( 6 );
var element = $( "#tabs1" ).tabs({
disabled: [ 0 ],
active: 1
});
state( element, 0, 1, 0 );
disabled( element, [ 0 ] );
// remove active, jump to previous
// previous is disabled, just back one more
// reached first tab, move to end
// activate last tab
element.find( ".ui-tabs-nav li" ).eq( 2 ).remove();
element.tabs( "refresh" );
state( element, 0, 1 );
disabled( element, [ 0 ] );
});
asyncTest( "load", function() { asyncTest( "load", function() {
expect( 30 ); expect( 30 );

View File

@ -1,6 +1,7 @@
(function( $ ) { (function( $ ) {
var disabled = TestHelpers.tabs.disabled, var disabled = TestHelpers.tabs.disabled,
equalHeight = TestHelpers.tabs.equalHeight,
state = TestHelpers.tabs.state; state = TestHelpers.tabs.state;
module( "tabs: options" ); module( "tabs: options" );
@ -68,6 +69,8 @@ test( "{ active: Number }", function() {
if ( $.uiBackCompat === false ) { if ( $.uiBackCompat === false ) {
test( "{ active: -Number }", function() { test( "{ active: -Number }", function() {
expect( 8 );
var element = $( "#tabs1" ).tabs({ var element = $( "#tabs1" ).tabs({
active: -1 active: -1
}); });
@ -211,6 +214,120 @@ test( "{ event: custom }", function() {
state( element, 0, 1, 0 ); state( element, 0, 1, 0 );
}); });
// TODO: add animation tests test( "{ heightStyle: 'auto' }", function() {
expect( 2 );
var element = $( "#tabs8" ).tabs({ heightStyle: "auto" });
equalHeight( element, 45 );
});
test( "{ heightStyle: 'content' }", function() {
expect( 2 );
var element = $( "#tabs8" ).tabs({ heightStyle: "content" }),
sizes = element.find( ".ui-tabs-panel" ).map(function() {
return $( this ).height();
}).get();
equal( sizes[ 0 ], 45 );
equal( sizes[ 1 ], 15 );
});
test( "{ heightStyle: 'fill' }", function() {
expect( 2 );
$( "#tabs8Wrapper" ).height( 500 );
var element = $( "#tabs8" ).tabs({ heightStyle: "fill" });
equalHeight( element, 485 );
});
test( "{ heightStyle: 'fill' } with sibling", function() {
expect( 2 );
$( "#tabs8Wrapper" ).height( 500 );
$( "<p>Lorem Ipsum</p>" )
.css({
height: 50,
marginTop: 20,
marginBottom: 30
})
.prependTo( "#tabs8Wrapper" );
var element = $( "#tabs8" ).tabs({ heightStyle: "fill" });
equalHeight( element, 385 );
});
test( "{ heightStyle: 'fill' } with multiple siblings", function() {
expect( 2 );
$( "#tabs8Wrapper" ).height( 500 );
$( "<p>Lorem Ipsum</p>" )
.css({
height: 50,
marginTop: 20,
marginBottom: 30
})
.prependTo( "#tabs8Wrapper" );
$( "<p>Lorem Ipsum</p>" )
.css({
height: 50,
marginTop: 20,
marginBottom: 30,
position: "absolute"
})
.prependTo( "#tabs8Wrapper" );
$( "<p>Lorem Ipsum</p>" )
.css({
height: 25,
marginTop: 10,
marginBottom: 15
})
.prependTo( "#tabs8Wrapper" );
var element = $( "#tabs8" ).tabs({ heightStyle: "fill" });
equalHeight( element, 335 );
});
test( "hide and show: false", function() {
expect( 3 );
var element = $( "#tabs1" ).tabs({
show: false,
hide: false
}),
widget = element.data( "tabs" ),
panels = element.find( ".ui-tabs-panel" );
widget._show = function() {
ok( false, "_show() called" );
};
widget._hide = function() {
ok( false, "_hide() called" );
};
ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
element.tabs( "option", "active", 1 );
ok( panels.eq( 0 ).is( ":hidden" ), "first panel hidden" );
ok( panels.eq( 1 ).is( ":visible" ), "second panel visible" );
});
asyncTest( "hide and show - animation", function() {
expect( 5 );
var element = $( "#tabs1" ).tabs({
show: "drop",
hide: 2000
}),
widget = element.data( "tabs" ),
panels = element.find( ".ui-tabs-panel" );
widget._show = function( element, options, callback ) {
strictEqual( element[ 0 ], panels[ 1 ], "correct element in _show()" );
equal( options, "drop", "correct options in _show()" );
setTimeout(function() {
callback();
}, 1 );
};
widget._hide = function( element, options, callback ) {
strictEqual( element[ 0 ], panels[ 0 ], "correct element in _hide()" );
equal( options, 2000, "correct options in _hide()" );
setTimeout(function() {
callback();
start();
}, 1 );
};
ok( panels.eq( 0 ).is( ":visible" ), "first panel visible" );
element.tabs( "option", "active", 1 );
});
}( jQuery ) ); }( jQuery ) );

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