diff options
155 files changed, 5688 insertions, 5622 deletions
diff --git a/demos/menu/index.html b/demos/menu/index.html index 9983dbfd0..f55d16514 100644 --- a/demos/menu/index.html +++ b/demos/menu/index.html @@ -12,6 +12,7 @@ <li class="demo-config-on"><a href="default.html">Default functionality</a></li> <li><a href="contextmenu.html">Contextmenu</a></li> <li><a href="topalignmenu.html">Top-aligned sub menus</a></li> + <li><a href="navigationmenu.html">Navigation menu</a></li> </ul> </div> </body> diff --git a/demos/menu/navigationmenu.html b/demos/menu/navigationmenu.html new file mode 100644 index 000000000..315932981 --- /dev/null +++ b/demos/menu/navigationmenu.html @@ -0,0 +1,84 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8" /> + <title>jQuery UI Menu - Navigation Menu demo</title> + <link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" /> + <script src="../../jquery-1.6.2.js"></script> + <script src="../../ui/jquery.ui.core.js"></script> + <script src="../../ui/jquery.ui.widget.js"></script> + <script src="../../ui/jquery.ui.position.js"></script> + <script src="../../ui/jquery.ui.menu.js"></script> + <link href="../demos.css" rel="stylesheet" /> + <script> + $(function() { + $("#navMenu").menu({ + select: function( event, ui ) { + var link = ui.item.children( "a:first" ); + if ( link.attr( "target" ) || event.metaKey || event.shiftKey || event.ctrlKey ) { + return; + } + location.href = link.attr( "href" ); + } + }); + }); + </script> + <style> + body { font-size:62.5%; } + .ui-menu { width: 200px; margin-bottom: 2em; } + </style> +</head> +<body> + +<div class="demo"> + + <ul id="navMenu"> + <li><a href="?Aberdeen">Aberdeen</a></li> + <li><a href="?Ada">Ada</a></li> + <li><a href="?Adamsville">Adamsville</a></li> + <li><a href="?Addyston">Addyston</a></li> + <li> + <a href="?Delphi">Delphi</a> + <ul> + <li><a href="?Ada">Ada</a></li> + <li><a href="?Saarland">Saarland</a></li> + <li><a href="?Salzburg">Salzburg</a></li> + </ul> + </li> + <li><a href="?Saarland">Saarland</a></li> + <li> + <a href="?Salzburg">Salzburg</a> + <ul> + <li> + <a href="?Delphi">Delphi</a> + <ul> + <li><a href="?Ada">Ada</a></li> + <li><a href="?Saarland">Saarland</a></li> + <li><a href="?Salzburg">Salzburg</a></li> + </ul> + </li> + <li> + <a href="?Delphi">Delphi</a> + <ul> + <li><a href="?Ada">Ada</a></li> + <li><a href="?Saarland">Saarland</a></li> + <li><a href="?Salzburg">Salzburg</a></li> + </ul> + </li> + <li><a href="?Perch">Perch</a></li> + </ul> + </li> + </ul> + +</div><!-- End demo --> + +<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> + +</div><!-- End demo-description --> + + + +</body> +</html> diff --git a/demos/position/default.html b/demos/position/default.html index 6a753e2f1..f7cba888d 100644 --- a/demos/position/default.html +++ b/demos/position/default.html @@ -142,11 +142,13 @@ <select id="collision_horizontal"> <option value="flip">flip</option> <option value="fit">fit</option> + <option value="flipfit">flipfit</option> <option value="none">none</option> </select> <select id="collision_vertical"> <option value="flip">flip</option> <option value="fit">fit</option> + <option value="flipfit">flipfit</option> <option value="none">none</option> </select> </div> diff --git a/demos/spinner/currency.html b/demos/spinner/currency.html index cb5528dda..f73c19f80 100644 --- a/demos/spinner/currency.html +++ b/demos/spinner/currency.html @@ -1,61 +1,61 @@ -<!DOCTYPE html>
-<html lang="en">
-<head>
- <meta charset="utf-8">
- <title>jQuery UI Spinner - Default functionality</title>
- <link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" />
- <script type="text/javascript" src="../../jquery-1.6.2.js"></script>
- <script type="text/javascript" src="../../external/jquery.mousewheel-3.0.4.js"></script>
- <script type="text/javascript" src="../../external/jquery.global.js"></script>
- <script type="text/javascript" src="../../external/jquery.global.de-DE.js"></script>
- <script type="text/javascript" src="../../external/jquery.global.ja-JP.js"></script>
- <script type="text/javascript" src="../../ui/jquery.ui.core.js"></script>
- <script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script>
- <script type="text/javascript" src="../../ui/jquery.ui.button.js"></script>
- <script type="text/javascript" src="../../ui/jquery.ui.spinner.js"></script>
- <link type="text/css" href="../demos.css" rel="stylesheet" />
- <script type="text/javascript">
- $(function() {
- $("#currency").change(function() {
- var current = $("#spinner").spinner("value");
- $.global.preferCulture($(this).val());
- $("#spinner").spinner("value", current);
- })
-
- $("#spinner").spinner({
- min: 5,
- max: 2500,
- step: 25,
- start: 1000,
- numberFormat: "C"
- });
-
- });
- </script>
-</head>
-<body>
-
-<div class="demo">
-
-<p>
- <label for="currency">Currency to donate</label>
- <select id="currency" name="currency">
- <option value="en-US">US $</option>
- <option value="de-DE">EUR €</option>
- <option value="ja-JP">YEN ¥</option>
- </select>
-</p>
-<p>
- <label for="spinner">Amount to donate:</label>
- <input id="spinner" name="spinner" value="5" />
-</p>
-</div>
-
-<div class="demo-description">
-<p>
- Example of a donation form, with currency selection and amout spinner.
-</p>
-</div>
-
-</body>
-</html>
+<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Spinner - Default functionality</title> + <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> + <script src="../../jquery-1.6.2.js"></script> + <script src="../../external/jquery.mousewheel-3.0.4.js"></script> + <script src="../../external/globalize.js"></script> + <script src="../../external/globalize.culture.de-DE.js"></script> + <script src="../../external/globalize.culture.ja-JP.js"></script> + <script src="../../ui/jquery.ui.core.js"></script> + <script src="../../ui/jquery.ui.widget.js"></script> + <script src="../../ui/jquery.ui.button.js"></script> + <script src="../../ui/jquery.ui.spinner.js"></script> + <link rel="stylesheet" href="../demos.css"> + <script> + $(function() { + $( "#currency" ).change(function() { + var current = $( "#spinner" ).spinner( "value" ); + Globalize.culture( $(this).val() ); + $( "#spinner" ).spinner( "value", current ); + }); + + $( "#spinner" ).spinner({ + min: 5, + max: 2500, + step: 25, + start: 1000, + numberFormat: "C" + }); + }); + </script> +</head> +<body> + +<div class="demo"> + +<p> + <label for="currency">Currency to donate</label> + <select id="currency" name="currency"> + <option value="en-US">US $</option> + <option value="de-DE">EUR €</option> + <option value="ja-JP">YEN ¥</option> + </select> +</p> +<p> + <label for="spinner">Amount to donate:</label> + <input id="spinner" name="spinner" value="5"> +</p> + +</div><!-- End demo --> + + + +<div class="demo-description"> +<p>Example of a donation form, with currency selection and amout spinner.</p> +</div><!-- End demo-description --> + +</body> +</html> diff --git a/demos/spinner/decimal.html b/demos/spinner/decimal.html index bcbc24751..9d96613fe 100644 --- a/demos/spinner/decimal.html +++ b/demos/spinner/decimal.html @@ -1,59 +1,63 @@ -<!DOCTYPE html>
-<html lang="en">
-<head>
- <meta charset="utf-8">
- <title>jQuery UI Spinner - decimal</title>
- <link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" />
- <script type="text/javascript" src="../../jquery-1.6.2.js"></script>
- <script type="text/javascript" src="../../external/jquery.mousewheel-3.0.4.js"></script>
- <script type="text/javascript" src="../../external/jquery.global.js"></script>
- <script type="text/javascript" src="../../external/jquery.global.de-DE.js"></script>
- <script type="text/javascript" src="../../external/jquery.global.ja-JP.js"></script>
- <script type="text/javascript" src="../../ui/jquery.ui.core.js"></script>
- <script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script>
- <script type="text/javascript" src="../../ui/jquery.ui.button.js"></script>
- <script type="text/javascript" src="../../ui/jquery.ui.spinner.js"></script>
- <link type="text/css" href="../demos.css" rel="stylesheet" />
- <script type="text/javascript">
- $(function() {
- $("#spinner").spinner({
- step: 0.01,
- numberFormat: "n"
- });
-
- $("#culture").change(function() {
- var current = $("#spinner").spinner("value");
- $.global.preferCulture($(this).val());
- $("#spinner").spinner("value", current);
- })
- });
- </script>
-</head>
-<body>
-
-<div class="demo">
-<p>
- <label for="spinner">Decimal spinner:</label>
- <input id="spinner" name="spinner" value="5.06" />
-</p>
-<p>
- <label for="culture">Select a culture to use for formatting:</label>
- <select id="culture">
- <option value="en-EN" selected="selected">English</option>
- <option value="de-DE">German</option>
- <option value="ja-JP">Japanese</option>
- </select>
-</p>
-</div>
-
-<div class="demo-description">
-<p>
- Example of a decimal spinner. Step is set to 0.01.
- <br/>The code handling the culture change reads the current spinner value,
- then changes the culture, then sets the value again, resulting in an updated
- formatting, based on the new culture.
-</p>
-</div>
-
-</body>
-</html>
+<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Spinner - Decimal</title> + <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> + <script src="../../jquery-1.6.2.js"></script> + <script src="../../external/jquery.mousewheel-3.0.4.js"></script> + <script src="../../external/globalize.js"></script> + <script src="../../external/globalize.culture.de-DE.js"></script> + <script src="../../external/globalize.culture.ja-JP.js"></script> + <script src="../../ui/jquery.ui.core.js"></script> + <script src="../../ui/jquery.ui.widget.js"></script> + <script src="../../ui/jquery.ui.button.js"></script> + <script src="../../ui/jquery.ui.spinner.js"></script> + <link rel="stylesheet" href="../demos.css"> + <script> + $(function() { + $( "#spinner" ).spinner({ + step: 0.01, + numberFormat: "n" + }); + + $( "#culture" ).change(function() { + var current = $( "#spinner" ).spinner( "value" ); + Globalize.culture( $(this).val() ); + $( "#spinner" ).spinner( "value", current ); + }); + }); + </script> +</head> +<body> + +<div class="demo"> + +<p> + <label for="spinner">Decimal spinner:</label> + <input id="spinner" name="spinner" value="5.06"> +</p> +<p> + <label for="culture">Select a culture to use for formatting:</label> + <select id="culture"> + <option value="en-EN" selected="selected">English</option> + <option value="de-DE">German</option> + <option value="ja-JP">Japanese</option> + </select> +</p> + +</div><!-- End demo --> + + + +<div class="demo-description"> +<p> + Example of a decimal spinner. Step is set to 0.01. + <br>The code handling the culture change reads the current spinner value, + then changes the culture, then sets the value again, resulting in an updated + formatting, based on the new culture. +</p> +</div><!-- End demo-description --> + +</body> +</html> diff --git a/demos/spinner/default.html b/demos/spinner/default.html index 4035ee41c..c78c36d68 100644 --- a/demos/spinner/default.html +++ b/demos/spinner/default.html @@ -1,65 +1,67 @@ -<!DOCTYPE html>
-<html lang="en">
-<head>
- <meta charset="utf-8">
- <title>jQuery UI Spinner - Default functionality</title>
- <link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" />
- <script type="text/javascript" src="../../jquery-1.6.2.js"></script>
- <script type="text/javascript" src="../../external/jquery.mousewheel-3.0.4.js"></script>
- <script type="text/javascript" src="../../ui/jquery.ui.core.js"></script>
- <script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script>
- <script type="text/javascript" src="../../ui/jquery.ui.button.js"></script>
- <script type="text/javascript" src="../../ui/jquery.ui.spinner.js"></script>
- <link type="text/css" href="../demos.css" rel="stylesheet" />
- <script type="text/javascript">
- $(function() {
- $("#spinner").spinner();
-
- $("#disable").toggle(function() {
- $("#spinner").spinner("disable");
- }, function() {
- $("#spinner").spinner("enable");
- });
- $("#destroy").toggle(function() {
- $("#spinner").spinner("destroy");
- }, function() {
- $("#spinner").spinner();
- });
- $("#getvalue").click(function() {
- alert($("#spinner").spinner("value"));
- });
- $("#setvalue").click(function() {
- $("#spinner").spinner("value", 5);
- });
-
- $("button").button();
- });
- </script>
-</head>
-<body>
-
-<div class="demo">
-
-<p><label for="spinner">Select a value:</label>
-<input id="spinner" name="value" /></p>
-
-<p>
-<button id="disable">Toggle disable/enable</button>
-<button id="destroy">Toggle widget</button>
-</p>
-
-<p>
-<button id="getvalue">Get value</button>
-<button id="setvalue">Set value to 5</button>
-</p>
-
-</div><!-- End demo -->
-
-<div class="demo-description">
-<p>
-Default spinner.
-</p>
-</div><!-- End demo-description -->
-
-</body>
-</html>
+<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Spinner - Default functionality</title> + <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> + <script src="../../jquery-1.6.2.js"></script> + <script src="../../external/jquery.mousewheel-3.0.4.js"></script> + <script src="../../ui/jquery.ui.core.js"></script> + <script src="../../ui/jquery.ui.widget.js"></script> + <script src="../../ui/jquery.ui.button.js"></script> + <script src="../../ui/jquery.ui.spinner.js"></script> + <link rel="stylesheet" href="../demos.css"> + <script> + $(function() { + var spinner = $( "#spinner" ).spinner(); + + $( "#disable" ).toggle(function() { + spinner.spinner( "disable" ); + }, function() { + spinner.spinner( "enable" ); + }); + $( "#destroy" ).toggle(function() { + spinner.spinner( "destroy" ); + }, function() { + spinner.spinner(); + }); + $( "#getvalue" ).click(function() { + alert( spinner.spinner( "value" ) ); + }); + $( "#setvalue" ).click(function() { + spinner.spinner( "value", 5 ); + }); + + $( "button" ).button(); + }); + </script> +</head> +<body> + +<div class="demo"> + +<p> + <label for="spinner">Select a value:</label> + <input id="spinner" name="value"> +</p> + +<p> + <button id="disable">Toggle disable/enable</button> + <button id="destroy">Toggle widget</button> +</p> + +<p> + <button id="getvalue">Get value</button> + <button id="setvalue">Set value to 5</button> +</p> + +</div><!-- End demo --> + + + +<div class="demo-description"> +<p>Default spinner.</p> +</div><!-- End demo-description --> + +</body> +</html> diff --git a/demos/spinner/index.html b/demos/spinner/index.html index c1b9d9288..594fd9399 100644 --- a/demos/spinner/index.html +++ b/demos/spinner/index.html @@ -1,20 +1,23 @@ -<!DOCTYPE html>
-<html lang="en">
-<head>
- <title>jQuery UI Spinner Demos</title>
- <link type="text/css" href="../demos.css" rel="stylesheet" />
-</head>
-<body>
- <div class="demos-nav">
- <h4>Examples</h4>
- <ul>
- <li class="demo-config-on"><a href="default.html">Default functionality</a></li>
- <li><a href="decimal.html">Decimal</a></li>
- <li><a href="currency.html">Currency</a></li>
- <li><a href="latlong.html">Map</a></li>
- <li><a href="time.html">Time</a></li>
- <li><a href="overflow.html">Overflow</a></li>
- </ul>
- </div>
-</body>
-</html>
+<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Spinner Demos</title> + <link rel="stylesheet" href="../demos.css"> +</head> +<body> + +<div class="demos-nav"> + <h4>Examples</h4> + <ul> + <li class="demo-config-on"><a href="default.html">Default functionality</a></li> + <li><a href="decimal.html">Decimal</a></li> + <li><a href="currency.html">Currency</a></li> + <li><a href="latlong.html">Map</a></li> + <li><a href="time.html">Time</a></li> + <li><a href="overflow.html">Overflow</a></li> + </ul> +</div> + +</body> +</html> diff --git a/demos/spinner/latlong.html b/demos/spinner/latlong.html index 3c549f180..d1dc612b4 100644 --- a/demos/spinner/latlong.html +++ b/demos/spinner/latlong.html @@ -1,60 +1,63 @@ -<!DOCTYPE html>
-<html lang="en">
-<head>
- <meta charset="utf-8">
- <title>jQuery UI Spinner - Map</title>
- <link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" />
- <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
- <script type="text/javascript" src="../../jquery-1.6.2.js"></script>
- <script type="text/javascript" src="../../external/jquery.mousewheel-3.0.4.js"></script>
- <script type="text/javascript" src="../../ui/jquery.ui.core.js"></script>
- <script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script>
- <script type="text/javascript" src="../../ui/jquery.ui.button.js"></script>
- <script type="text/javascript" src="../../ui/jquery.ui.spinner.js"></script>
- <link type="text/css" href="../demos.css" rel="stylesheet" />
- <script type="text/javascript">
- $(function() {
- function latlong() {
- return new google.maps.LatLng($("#lat").val(),$("#lng").val());
- }
- function position() {
- map.setCenter(latlong());
- }
- $("#lat, #lng").spinner({
- precision: 6,
- change: position
- });
-
- var map = new google.maps.Map($("#map")[0], {
- zoom: 8,
- center: latlong(),
- mapTypeId: google.maps.MapTypeId.ROADMAP
- });
- });
- </script>
- <style>
- #map { width:500px; height:500px; }
- </style>
-</head>
-<body>
-
-<div class="demo">
-
-<label for="lat">Latitude</label>
-<input id="lat" name="lat" value="44.797916" />
-<br/>
-<label for="lng">Longitude</label>
-<input id="lng" name="lng" value="-93.278046" />
-
-<div id="map"></div>
-
-</div><!-- End demo -->
-
-<div class="demo-description">
-<p>
-Google Maps integration, using spinners to change latidude and longitude.
-</p>
-</div><!-- End demo-description -->
-
-</body>
-</html>
+<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Spinner - Map</title> + <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> + <script src="http://maps.google.com/maps/api/js?sensor=false"></script> + <script src="../../jquery-1.6.2.js"></script> + <script src="../../external/jquery.mousewheel-3.0.4.js"></script> + <script src="../../ui/jquery.ui.core.js"></script> + <script src="../../ui/jquery.ui.widget.js"></script> + <script src="../../ui/jquery.ui.button.js"></script> + <script src="../../ui/jquery.ui.spinner.js"></script> + <link rel="stylesheet" href="../demos.css"> + <script> + $(function() { + function latlong() { + return new google.maps.LatLng( $("#lat").val(), $("#lng").val() ); + } + function position() { + map.setCenter( latlong() ); + } + $( "#lat, #lng" ).spinner({ + precision: 6, + change: position + }); + + var map = new google.maps.Map( $("#map")[0], { + zoom: 8, + center: latlong(), + mapTypeId: google.maps.MapTypeId.ROADMAP + }); + }); + </script> + <style> + #map { + width:500px; + height:500px; + } + </style> +</head> +<body> + +<div class="demo"> + +<label for="lat">Latitude</label> +<input id="lat" name="lat" value="44.797916"> +<br> +<label for="lng">Longitude</label> +<input id="lng" name="lng" value="-93.278046"> + +<div id="map"></div> + +</div><!-- End demo --> + + + +<div class="demo-description"> +<p>Google Maps integration, using spinners to change latidude and longitude.</p> +</div><!-- End demo-description --> + +</body> +</html> diff --git a/demos/spinner/overflow.html b/demos/spinner/overflow.html index 23ae1a888..d55a48b01 100644 --- a/demos/spinner/overflow.html +++ b/demos/spinner/overflow.html @@ -1,47 +1,51 @@ -<!DOCTYPE html>
-<html lang="en">
-<head>
- <meta charset="utf-8">
- <title>jQuery UI Spinner - Default functionality</title>
- <link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" />
- <script type="text/javascript" src="../../jquery-1.6.2.js"></script>
- <script type="text/javascript" src="../../external/jquery.mousewheel-3.0.4.js"></script>
- <script type="text/javascript" src="../../ui/jquery.ui.core.js"></script>
- <script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script>
- <script type="text/javascript" src="../../ui/jquery.ui.button.js"></script>
- <script type="text/javascript" src="../../ui/jquery.ui.spinner.js"></script>
- <link type="text/css" href="../demos.css" rel="stylesheet" />
- <script type="text/javascript">
- $(function() {
- $("#spinner").spinner({
- spin: function(event, ui) {
- if (ui.value > 10) {
- $(this).spinner("value", -10);
- return false;
- } else if (ui.value < -10) {
- $(this).spinner("value", 10);
- return false;
- }
- }
- });
- });
- </script>
-</head>
-<body>
-
-<div class="demo">
- <p>
- <label for="spinner">Select a value:</label>
- <input id="spinner" name="value" />
- </p>
-</div>
-
-<div class="demo-description">
- <p>
- Overflowing spinner restricted to a range of -10 to 10.
- For anything above 10, it'll overflow to -10, and the other way round.
- </p>
-</div>
-
-</body>
-</html>
+<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Spinner - Overflow</title> + <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> + <script src="../../jquery-1.6.2.js"></script> + <script src="../../external/jquery.mousewheel-3.0.4.js"></script> + <script src="../../ui/jquery.ui.core.js"></script> + <script src="../../ui/jquery.ui.widget.js"></script> + <script src="../../ui/jquery.ui.button.js"></script> + <script src="../../ui/jquery.ui.spinner.js"></script> + <link rel="stylesheet" href="../demos.css"> + <script> + $(function() { + $( "#spinner" ).spinner({ + spin: function( event, ui ) { + if ( ui.value > 10 ) { + $( this ).spinner( "value", -10 ); + return false; + } else if ( ui.value < -10 ) { + $( this ).spinner( "value", 10 ); + return false; + } + } + }); + }); + </script> +</head> +<body> + +<div class="demo"> + +<p> + <label for="spinner">Select a value:</label> + <input id="spinner" name="value" /> +</p> + +</div><!-- End demo --> + + + +<div class="demo-description"> +<p> +Overflowing spinner restricted to a range of -10 to 10. +For anything above 10, it'll overflow to -10, and the other way round. +</p> +</div><!-- End demo-description --> + +</body> +</html> diff --git a/demos/spinner/time.html b/demos/spinner/time.html index 5858a5071..175407f4a 100644 --- a/demos/spinner/time.html +++ b/demos/spinner/time.html @@ -1,71 +1,79 @@ -<!DOCTYPE html>
-<html lang="en">
-<head>
- <meta charset="utf-8">
- <title>jQuery UI Spinner - decimal</title>
- <link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" />
- <script type="text/javascript" src="../../jquery-1.6.2.js"></script>
- <script type="text/javascript" src="../../external/jquery.mousewheel-3.0.4.js"></script>
- <script type="text/javascript" src="../../external/jquery.global.js"></script>
- <script type="text/javascript" src="../../external/jquery.global.de-DE.js"></script>
- <script type="text/javascript" src="../../ui/jquery.ui.core.js"></script>
- <script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script>
- <script type="text/javascript" src="../../ui/jquery.ui.button.js"></script>
- <script type="text/javascript" src="../../ui/jquery.ui.spinner.js"></script>
- <link type="text/css" href="../demos.css" rel="stylesheet" />
- <script type="text/javascript">
- $.widget("ui.timespinner", $.ui.spinner, {
- options: {
- // seconds
- step: 60 * 1000,
- // hours
- page: 60
- },
-
- _parse: function(value) {
- if (typeof value == 'string') {
- return +$.global.parseDate(value)
- }
- return value;
- },
- _format: function() {
- this.element.val( $.global.format(new Date(this.options.value), "t") );
- }
- })
- $(function() {
- $("#spinner").timespinner();
-
- $("#culture").change(function() {
- var current = $("#spinner").timespinner("value");
- $.global.preferCulture($(this).val());
- $("#spinner").timespinner("value", current);
- });
- });
- </script>
-</head>
-<body>
-
-<div class="demo">
-<p>
- <label for="spinner">Time spinner:</label>
- <input id="spinner" name="spinner" value="08:30 PM" />
-</p>
-<p>
- <label for="culture">Select a culture to use for formatting:</label>
- <select id="culture">
- <option value="en-EN" selected="selected">English</option>
- <option value="de-DE">German</option>
- </select>
-</p>
-</div>
-
-<div class="demo-description">
-<p>
- A custom widget extending spinner. Use the Globalization plugin to parse and output
- a timestamp, with custom step and page options. Cursor up/down spins minutes, page up/down
- spins hours.
-</p>
-</div>
-
-</body>
-</html>
+<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Spinner - Time</title> + <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> + <script src="../../jquery-1.6.2.js"></script> + <script src="../../external/jquery.mousewheel-3.0.4.js"></script> + <script src="../../external/globalize.js"></script> + <script src="../../external/globalize.culture.de-DE.js"></script> + <script src="../../ui/jquery.ui.core.js"></script> + <script src="../../ui/jquery.ui.widget.js"></script> + <script src="../../ui/jquery.ui.button.js"></script> + <script src="../../ui/jquery.ui.spinner.js"></script> + <link rel="stylesheet" href="../demos.css"> + <script> + $.widget( "ui.timespinner", $.ui.spinner, { + options: { + // seconds + step: 60 * 1000, + // hours + page: 60 + }, + + _parse: function( value ) { + if ( typeof value === "string" ) { + // already a timestamp + if ( Number( value ) == value ) { + return Number( value ); + } + return +Globalize.parseDate( value ); + } + return value; + }, + + _format: function( value ) { + return Globalize.format( new Date(value), "t" ); + } + }); + + $(function() { + $( "#spinner" ).timespinner(); + + $( "#culture" ).change(function() { + var current = $( "#spinner" ).timespinner( "value" ); + Globalize.culture( $(this).val() ); + $( "#spinner" ).timespinner( "value", current ); + }); + }); + </script> +</head> +<body> + +<div class="demo"> +<p> + <label for="spinner">Time spinner:</label> + <input id="spinner" name="spinner" value="08:30 PM"> +</p> +<p> + <label for="culture">Select a culture to use for formatting:</label> + <select id="culture"> + <option value="en-EN" selected="selected">English</option> + <option value="de-DE">German</option> + </select> +</p> +</div><!-- End demo --> + + + +<div class="demo-description"> +<p> + A custom widget extending spinner. Use the Globalization plugin to parse and output + a timestamp, with custom step and page options. Cursor up/down spins minutes, page up/down + spins hours. +</p> +</div><!-- End demo-description --> + +</body> +</html> diff --git a/demos/tabs/bottom.html b/demos/tabs/bottom.html index b677c629c..3417ed94b 100644 --- a/demos/tabs/bottom.html +++ b/demos/tabs/bottom.html @@ -12,17 +12,22 @@ <script> $(function() { $( "#tabs" ).tabs(); + + // fix the classes $( ".tabs-bottom .ui-tabs-nav, .tabs-bottom .ui-tabs-nav > *" ) .removeClass( "ui-corner-all ui-corner-top" ) .addClass( "ui-corner-bottom" ); + + // move the nav to the bottom + $( ".tabs-bottom .ui-tabs-nav" ).appendTo( ".tabs-bottom" ); }); </script> <style> - #tabs { height: 200px; } - .tabs-bottom { position: relative; } - .tabs-bottom .ui-tabs-panel { height: 140px; overflow: auto; } - .tabs-bottom .ui-tabs-nav { position: absolute !important; left: 0; bottom: 0; right:0; padding: 0 0.2em 0.2em 0; } - .tabs-bottom .ui-tabs-nav li { margin-top: -2px !important; margin-bottom: 1px !important; border-top: none; border-bottom-width: 1px; } + /* force a height so the tabs don't jump as content height changes */ + #tabs .tabs-spacer { float: left; height: 200px; } + .tabs-bottom .ui-tabs-nav { clear: left; padding: 0 .2em .2em .2em; } + .tabs-bottom .ui-tabs-nav li { top: auto; bottom: 0; margin: 0 .2em 1px 0; border-bottom: auto; border-top: 0; } + .tabs-bottom .ui-tabs-nav li.ui-tabs-active { margin-top: -1px; padding-top: 1px; } </style> </head> <body> @@ -35,6 +40,7 @@ <li><a href="#tabs-2">Proin dolor</a></li> <li><a href="#tabs-3">Aenean lacinia</a></li> </ul> + <div class="tabs-spacer"></div> <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> diff --git a/demos/widget/default.html b/demos/widget/default.html index 4dad912c2..a645ef283 100644 --- a/demos/widget/default.html +++ b/demos/widget/default.html @@ -50,7 +50,7 @@ this.changer = $( "<button>", { text: "change", - className: "custom-colorize-changer" + "class": "custom-colorize-changer" }) .appendTo( this.element ) .button(); @@ -165,7 +165,7 @@ <div id="my-widget1">color me</div> <div id="my-widget2">color me</div> <div id="my-widget3">color me</div> - <button id="disable">Toglge disabled option</button> + <button id="disable">Toggle disabled option</button> <button id="black">Go black</button> </div> diff --git a/external/globalize.culture.de-DE.js b/external/globalize.culture.de-DE.js new file mode 100644 index 000000000..5466bd75e --- /dev/null +++ b/external/globalize.culture.de-DE.js @@ -0,0 +1,81 @@ +/* + * Globalize Culture de-DE + * + * http://github.com/jquery/globalize + * + * Copyright Software Freedom Conservancy, Inc. + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * This file was generated by the Globalize Culture Generator + * Translation: bugs found in this file need to be fixed in the generator + */ + +(function( window, undefined ) { + +var Globalize; + +if ( typeof require !== "undefined" + && typeof exports !== "undefined" + && typeof module !== "undefined" ) { + // Assume CommonJS + Globalize = require( "globalize" ); +} else { + // Global variable + Globalize = window.Globalize; +} + +Globalize.addCultureInfo( "de-DE", "default", { + name: "de-DE", + englishName: "German (Germany)", + nativeName: "Deutsch (Deutschland)", + language: "de", + numberFormat: { + ",": ".", + ".": ",", + NaN: "n. def.", + negativeInfinity: "-unendlich", + positiveInfinity: "+unendlich", + percent: { + pattern: ["-n%","n%"], + ",": ".", + ".": "," + }, + currency: { + pattern: ["-n $","n $"], + ",": ".", + ".": ",", + symbol: "€" + } + }, + calendars: { + standard: { + "/": ".", + firstDay: 1, + days: { + names: ["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"], + namesAbbr: ["So","Mo","Di","Mi","Do","Fr","Sa"], + namesShort: ["So","Mo","Di","Mi","Do","Fr","Sa"] + }, + months: { + names: ["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember",""], + namesAbbr: ["Jan","Feb","Mrz","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez",""] + }, + AM: null, + PM: null, + eras: [{"name":"n. Chr.","start":null,"offset":0}], + patterns: { + d: "dd.MM.yyyy", + D: "dddd, d. MMMM yyyy", + t: "HH:mm", + T: "HH:mm:ss", + f: "dddd, d. MMMM yyyy HH:mm", + F: "dddd, d. MMMM yyyy HH:mm:ss", + M: "dd MMMM", + Y: "MMMM yyyy" + } + } + } +}); + +}( this )); diff --git a/external/globalize.culture.ja-JP.js b/external/globalize.culture.ja-JP.js new file mode 100644 index 000000000..a9469d709 --- /dev/null +++ b/external/globalize.culture.ja-JP.js @@ -0,0 +1,100 @@ +/* + * Globalize Culture ja-JP + * + * http://github.com/jquery/globalize + * + * Copyright Software Freedom Conservancy, Inc. + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * This file was generated by the Globalize Culture Generator + * Translation: bugs found in this file need to be fixed in the generator + */ + +(function( window, undefined ) { + +var Globalize; + +if ( typeof require !== "undefined" + && typeof exports !== "undefined" + && typeof module !== "undefined" ) { + // Assume CommonJS + Globalize = require( "globalize" ); +} else { + // Global variable + Globalize = window.Globalize; +} + +Globalize.addCultureInfo( "ja-JP", "default", { + name: "ja-JP", + englishName: "Japanese (Japan)", + nativeName: "日本語 (日本)", + language: "ja", + numberFormat: { + NaN: "NaN (非数値)", + negativeInfinity: "-∞", + positiveInfinity: "+∞", + percent: { + pattern: ["-n%","n%"] + }, + currency: { + pattern: ["-$n","$n"], + decimals: 0, + symbol: "¥" + } + }, + calendars: { + standard: { + days: { + names: ["日曜日","月曜日","火曜日","水曜日","木曜日","金曜日","土曜日"], + namesAbbr: ["日","月","火","水","木","金","土"], + namesShort: ["日","月","火","水","木","金","土"] + }, + months: { + names: ["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月",""], + namesAbbr: ["1","2","3","4","5","6","7","8","9","10","11","12",""] + }, + AM: ["午前","午前","午前"], + PM: ["午後","午後","午後"], + eras: [{"name":"西暦","start":null,"offset":0}], + patterns: { + d: "yyyy/MM/dd", + D: "yyyy'年'M'月'd'日'", + t: "H:mm", + T: "H:mm:ss", + f: "yyyy'年'M'月'd'日' H:mm", + F: "yyyy'年'M'月'd'日' H:mm:ss", + M: "M'月'd'日'", + Y: "yyyy'年'M'月'" + } + }, + Japanese: { + name: "Japanese", + days: { + names: ["日曜日","月曜日","火曜日","水曜日","木曜日","金曜日","土曜日"], + namesAbbr: ["日","月","火","水","木","金","土"], + namesShort: ["日","月","火","水","木","金","土"] + }, + months: { + names: ["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月",""], + namesAbbr: ["1","2","3","4","5","6","7","8","9","10","11","12",""] + }, + AM: ["午前","午前","午前"], + PM: ["午後","午後","午後"], + eras: [{"name":"平成","start":null,"offset":1867},{"name":"昭和","start":-1812153600000,"offset":1911},{"name":"大正","start":-1357603200000,"offset":1925},{"name":"明治","start":60022080000,"offset":1988}], + twoDigitYearMax: 99, + patterns: { + d: "gg y/M/d", + D: "gg y'年'M'月'd'日'", + t: "H:mm", + T: "H:mm:ss", + f: "gg y'年'M'月'd'日' H:mm", + F: "gg y'年'M'月'd'日' H:mm:ss", + M: "M'月'd'日'", + Y: "gg y'年'M'月'" + } + } + } +}); + +}( this )); diff --git a/external/globalize.js b/external/globalize.js new file mode 100644 index 000000000..ebaca1748 --- /dev/null +++ b/external/globalize.js @@ -0,0 +1,1573 @@ +/*! + * Globalize + * + * http://github.com/jquery/globalize + * + * Copyright Software Freedom Conservancy, Inc. + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + */ + +(function( window, undefined ) { + +var Globalize, + // private variables + regexHex, + regexInfinity, + regexParseFloat, + regexTrim, + // private JavaScript utility functions + arrayIndexOf, + endsWith, + extend, + isArray, + isFunction, + isObject, + startsWith, + trim, + truncate, + zeroPad, + // private Globalization utility functions + appendPreOrPostMatch, + expandFormat, + formatDate, + formatNumber, + getTokenRegExp, + getEra, + getEraYear, + parseExact, + parseNegativePattern; + +// Global variable (Globalize) or CommonJS module (globalize) +Globalize = function( cultureSelector ) { + return new Globalize.prototype.init( cultureSelector ); +}; + +if ( typeof require !== "undefined" + && typeof exports !== "undefined" + && typeof module !== "undefined" ) { + // Assume CommonJS + module.exports = Globalize; +} else { + // Export as global variable + window.Globalize = Globalize; +} + +Globalize.cultures = {}; + +Globalize.prototype = { + constructor: Globalize, + init: function( cultureSelector ) { + this.cultures = Globalize.cultures; + this.cultureSelector = cultureSelector; + + return this; + } +}; +Globalize.prototype.init.prototype = Globalize.prototype; + +// 1. When defining a culture, all fields are required except the ones stated as optional. +// 2. Each culture should have a ".calendars" object with at least one calendar named "standard" +// which serves as the default calendar in use by that culture. +// 3. Each culture should have a ".calendar" object which is the current calendar being used, +// it may be dynamically changed at any time to one of the calendars in ".calendars". +Globalize.cultures[ "default" ] = { + // A unique name for the culture in the form <language code>-<country/region code> + name: "en", + // the name of the culture in the english language + englishName: "English", + // the name of the culture in its own language + nativeName: "English", + // whether the culture uses right-to-left text + isRTL: false, + // "language" is used for so-called "specific" cultures. + // For example, the culture "es-CL" means "Spanish, in Chili". + // It represents the Spanish-speaking culture as it is in Chili, + // which might have different formatting rules or even translations + // than Spanish in Spain. A "neutral" culture is one that is not + // specific to a region. For example, the culture "es" is the generic + // Spanish culture, which may be a more generalized version of the language + // that may or may not be what a specific culture expects. + // For a specific culture like "es-CL", the "language" field refers to the + // neutral, generic culture information for the language it is using. + // This is not always a simple matter of the string before the dash. + // For example, the "zh-Hans" culture is netural (Simplified Chinese). + // And the "zh-SG" culture is Simplified Chinese in Singapore, whose lanugage + // field is "zh-CHS", not "zh". + // This field should be used to navigate from a specific culture to it's + // more general, neutral culture. If a culture is already as general as it + // can get, the language may refer to itself. + language: "en", + // numberFormat defines general number formatting rules, like the digits in + // each grouping, the group separator, and how negative numbers are displayed. + numberFormat: { + // [negativePattern] + // Note, numberFormat.pattern has no "positivePattern" unlike percent and currency, + // but is still defined as an array for consistency with them. + // negativePattern: one of "(n)|-n|- n|n-|n -" + pattern: [ "-n" ], + // number of decimal places normally shown + decimals: 2, + // string that separates number groups, as in 1,000,000 + ",": ",", + // string that separates a number from the fractional portion, as in 1.99 + ".": ".", + // array of numbers indicating the size of each number group. + // TODO: more detailed description and example + groupSizes: [ 3 ], + // symbol used for positive numbers + "+": "+", + // symbol used for negative numbers + "-": "-", + // symbol used for NaN (Not-A-Number) + NaN: "NaN", + // symbol used for Negative Infinity + negativeInfinity: "-Infinity", + // symbol used for Positive Infinity + positiveInfinity: "Infinity", + percent: { + // [negativePattern, positivePattern] + // negativePattern: one of "-n %|-n%|-%n|%-n|%n-|n-%|n%-|-% n|n %-|% n-|% -n|n- %" + // positivePattern: one of "n %|n%|%n|% n" + pattern: [ "-n %", "n %" ], + // number of decimal places normally shown + decimals: 2, + // array of numbers indicating the size of each number group. + // TODO: more detailed description and example + groupSizes: [ 3 ], + // string that separates number groups, as in 1,000,000 + ",": ",", + // string that separates a number from the fractional portion, as in 1.99 + ".": ".", + // symbol used to represent a percentage + symbol: "%" + }, + currency: { + // [negativePattern, positivePattern] + // negativePattern: one of "($n)|-$n|$-n|$n-|(n$)|-n$|n-$|n$-|-n $|-$ n|n $-|$ n-|$ -n|n- $|($ n)|(n $)" + // positivePattern: one of "$n|n$|$ n|n $" + pattern: [ "($n)", "$n" ], + // number of decimal places normally shown + decimals: 2, + // array of numbers indicating the size of each number group. + // TODO: more detailed description and example + groupSizes: [ 3 ], + // string that separates number groups, as in 1,000,000 + ",": ",", + // string that separates a number from the fractional portion, as in 1.99 + ".": ".", + // symbol used to represent currency + symbol: "$" + } + }, + // calendars defines all the possible calendars used by this culture. + // There should be at least one defined with name "standard", and is the default + // calendar used by the culture. + // A calendar contains information about how dates are formatted, information about + // the calendar's eras, a standard set of the date formats, + // translations for day and month names, and if the calendar is not based on the Gregorian + // calendar, conversion functions to and from the Gregorian calendar. + calendars: { + standard: { + // name that identifies the type of calendar this is + name: "Gregorian_USEnglish", + // separator of parts of a date (e.g. "/" in 11/05/1955) + "/": "/", + // separator of parts of a time (e.g. ":" in 05:44 PM) + ":": ":", + // the first day of the week (0 = Sunday, 1 = Monday, etc) + firstDay: 0, + days: { + // full day names + names: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], + // abbreviated day names + namesAbbr: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ], + // shortest day names + namesShort: [ "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" ] + }, + months: { + // full month names (13 months for lunar calendards -- 13th month should be "" if not lunar) + names: [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", "" ], + // abbreviated month names + namesAbbr: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "" ] + }, + // AM and PM designators in one of these forms: + // The usual view, and the upper and lower case versions + // [ standard, lowercase, uppercase ] + // The culture does not use AM or PM (likely all standard date formats use 24 hour time) + // null + AM: [ "AM", "am", "AM" ], + PM: [ "PM", "pm", "PM" ], + eras: [ + // eras in reverse chronological order. + // name: the name of the era in this culture (e.g. A.D., C.E.) + // start: when the era starts in ticks (gregorian, gmt), null if it is the earliest supported era. + // offset: offset in years from gregorian calendar + { + "name": "A.D.", + "start": null, + "offset": 0 + } + ], + // when a two digit year is given, it will never be parsed as a four digit + // year greater than this year (in the appropriate era for the culture) + // Set it as a full year (e.g. 2029) or use an offset format starting from + // the current year: "+19" would correspond to 2029 if the current year 2010. + twoDigitYearMax: 2029, + // set of predefined date and time patterns used by the culture + // these represent the format someone in this culture would expect + // to see given the portions of the date that are shown. + patterns: { + // short date pattern + d: "M/d/yyyy", + // long date pattern + D: "dddd, MMMM dd, yyyy", + // short time pattern + t: "h:mm tt", + // long time pattern + T: "h:mm:ss tt", + // long date, short time pattern + f: "dddd, MMMM dd, yyyy h:mm tt", + // long date, long time pattern + F: "dddd, MMMM dd, yyyy h:mm:ss tt", + // month/day pattern + M: "MMMM dd", + // month/year pattern + Y: "yyyy MMMM", + // S is a sortable format that does not vary by culture + S: "yyyy\u0027-\u0027MM\u0027-\u0027dd\u0027T\u0027HH\u0027:\u0027mm\u0027:\u0027ss" + } + // optional fields for each calendar: + /* + monthsGenitive: + Same as months but used when the day preceeds the month. + Omit if the culture has no genitive distinction in month names. + For an explaination of genitive months, see http://blogs.msdn.com/michkap/archive/2004/12/25/332259.aspx + convert: + Allows for the support of non-gregorian based calendars. This convert object is used to + to convert a date to and from a gregorian calendar date to handle parsing and formatting. + The two functions: + fromGregorian( date ) + Given the date as a parameter, return an array with parts [ year, month, day ] + corresponding to the non-gregorian based year, month, and day for the calendar. + toGregorian( year, month, day ) + Given the non-gregorian year, month, and day, return a new Date() object + set to the corresponding date in the gregorian calendar. + */ + } + }, + // For localized strings + messages: {} +}; + +Globalize.cultures[ "default" ].calendar = Globalize.cultures[ "default" ].calendars.standard; + +Globalize.cultures[ "en" ] = Globalize.cultures[ "default" ]; + +Globalize.cultureSelector = "en"; + +// +// private variables +// + +regexHex = /^0x[a-f0-9]+$/i; +regexInfinity = /^[+-]?infinity$/i; +regexParseFloat = /^[+-]?\d*\.?\d*(e[+-]?\d+)?$/; +regexTrim = /^\s+|\s+$/g; + +// +// private JavaScript utility functions +// + +arrayIndexOf = function( array, item ) { + if ( array.indexOf ) { + return array.indexOf( item ); + } + for ( var i = 0, length = array.length; i < length; i++ ) { + if ( array[i] === item ) { + return i; + } + } + return -1; +}; + +endsWith = function( value, pattern ) { + return value.substr( value.length - pattern.length ) === pattern; +}; + +extend = function( deep ) { + var options, name, src, copy, copyIsArray, clone, + target = arguments[0] || {}, + i = 1, + length = arguments.length, + deep = false; + + // Handle a deep copy situation + if ( typeof target === "boolean" ) { + deep = target; + target = arguments[1] || {}; + // skip the boolean and the target + i = 2; + } + + // Handle case when target is a string or something (possible in deep copy) + if ( typeof target !== "object" && !isFunction(target) ) { + target = {}; + } + + for ( ; i < length; i++ ) { + // Only deal with non-null/undefined values + if ( (options = arguments[ i ]) != null ) { + // Extend the base object + for ( name in options ) { + src = target[ name ]; + copy = options[ name ]; + + // Prevent never-ending loop + if ( target === copy ) { + continue; + } + + // Recurse if we're merging plain objects or arrays + if ( deep && copy && ( isObject(copy) || (copyIsArray = isArray(copy)) ) ) { + if ( copyIsArray ) { + copyIsArray = false; + clone = src && isArray(src) ? src : []; + + } else { + clone = src && isObject(src) ? src : {}; + } + + // Never move original objects, clone them + target[ name ] = extend( deep, clone, copy ); + + // Don't bring in undefined values + } else if ( copy !== undefined ) { + target[ name ] = copy; + } + } + } + } + + // Return the modified object + return target; +}; + +isArray = Array.isArray || function( obj ) { + return Object.prototype.toString.call( obj ) === "[object Array]"; +}; + +isFunction = function( obj ) { + return Object.prototype.toString.call( obj ) === "[object Function]" +} + +isObject = function( obj ) { + return Object.prototype.toString.call( obj ) === "[object Object]"; +}; + +startsWith = function( value, pattern ) { + return value.indexOf( pattern ) === 0; +}; + +trim = function( value ) { + return ( value + "" ).replace( regexTrim, "" ); +}; + +truncate = function( value ) { + return value | 0; +}; + +zeroPad = function( str, count, left ) { + var l; + for ( l = str.length; l < count; l += 1 ) { + str = ( left ? ("0" + str) : (str + "0") ); + } + return str; +}; + +// +// private Globalization utility functions +// + +appendPreOrPostMatch = function( preMatch, strings ) { + // appends pre- and post- token match strings while removing escaped characters. + // Returns a single quote count which is used to determine if the token occurs + // in a string literal. + var quoteCount = 0, + escaped = false; + for ( var i = 0, il = preMatch.length; i < il; i++ ) { + var c = preMatch.charAt( i ); + switch ( c ) { + case "\'": + if ( escaped ) { + strings.push( "\'" ); + } + else { + quoteCount++; + } + escaped = false; + break; + case "\\": + if ( escaped ) { + strings.push( "\\" ); + } + escaped = !escaped; + break; + default: + strings.push( c ); + escaped = false; + break; + } + } + return quoteCount; +}; + +expandFormat = function( cal, format ) { + // expands unspecified or single character date formats into the full pattern. + format = format || "F"; + var pattern, + patterns = cal.patterns, + len = format.length; + if ( len === 1 ) { + pattern = patterns[ format ]; + if ( !pattern ) { + throw "Invalid date format string \'" + format + "\'."; + } + format = pattern; + } + else if ( len === 2 && format.charAt(0) === "%" ) { + // %X escape format -- intended as a custom format string that is only one character, not a built-in format. + format = format.charAt( 1 ); + } + return format; +}; + +formatDate = function( value, format, culture ) { + var cal = culture.calendar, + convert = cal.convert; + + if ( !format || !format.length || format === "i" ) { + var ret; + if ( culture && culture.name.length ) { + if ( convert ) { + // non-gregorian calendar, so we cannot use built-in toLocaleString() + ret = formatDate( value, cal.patterns.F, culture ); + } + else { + var eraDate = new Date( value.getTime() ), + era = getEra( value, cal.eras ); + eraDate.setFullYear( getEraYear(value, cal, era) ); + ret = eraDate.toLocaleString(); + } + } + else { + ret = value.toString(); + } + return ret; + } + + var eras = cal.eras, + sortable = format === "s"; + format = expandFormat( cal, format ); + + // Start with an empty string + ret = []; + var hour, + zeros = [ "0", "00", "000" ], + foundDay, + checkedDay, + dayPartRegExp = /([^d]|^)(d|dd)([^d]|$)/g, + quoteCount = 0, + tokenRegExp = getTokenRegExp(), + converted; + + function padZeros( num, c ) { + var r, s = num + ""; + if ( c > 1 && s.length < c ) { + r = ( zeros[c - 2] + s); + return r.substr( r.length - c, c ); + } + else { + r = s; + } + return r; + } + + function hasDay() { + if ( foundDay || checkedDay ) { + return foundDay; + } + foundDay = dayPartRegExp.test( format ); + checkedDay = true; + return foundDay; + } + + function getPart( date, part ) { + if ( converted ) { + return converted[ part ]; + } + switch ( part ) { + case 0: return date.getFullYear(); + case 1: return date.getMonth(); + case 2: return date.getDate(); + } + } + + if ( !sortable && convert ) { + converted = convert.fromGregorian( value ); + } + + for ( ; ; ) { + // Save the current index + var index = tokenRegExp.lastIndex, + // Look for the next pattern + ar = tokenRegExp.exec( format ); + + // Append the text before the pattern (or the end of the string if not found) + var preMatch = format.slice( index, ar ? ar.index : format.length ); + quoteCount += appendPreOrPostMatch( preMatch, ret ); + + if ( !ar ) { + break; + } + + // do not replace any matches that occur inside a string literal. + if ( quoteCount % 2 ) { + ret.push( ar[0] ); + continue; + } + + var current = ar[ 0 ], + clength = current.length; + + switch ( current ) { + case "ddd": + //Day of the week, as a three-letter abbreviation + case "dddd": + // Day of the week, using the full name + var names = ( clength === 3 ) ? cal.days.namesAbbr : cal.days.names; + ret.push( names[value.getDay()] ); + break; + case "d": + // Day of month, without leading zero for single-digit days + case "dd": + // Day of month, with leading zero for single-digit days + foundDay = true; + ret.push( + padZeros( getPart(value, 2), clength ) + ); + break; + case "MMM": + // Month, as a three-letter abbreviation + case "MMMM": + // Month, using the full name + var part = getPart( value, 1 ); + ret.push( + ( cal.monthsGenitive && hasDay() ) + ? + cal.monthsGenitive[ clength === 3 ? "namesAbbr" : "names" ][ part ] + : + cal.months[ clength === 3 ? "namesAbbr" : "names" ][ part ] + ); + break; + case "M": + // Month, as digits, with no leading zero for single-digit months + case "MM": + // Month, as digits, with leading zero for single-digit months + ret.push( + padZeros( getPart(value, 1) + 1, clength ) + ); + break; + case "y": + // Year, as two digits, but with no leading zero for years less than 10 + case "yy": + // Year, as two digits, with leading zero for years less than 10 + case "yyyy": + // Year represented by four full digits + part = converted ? converted[ 0 ] : getEraYear( value, cal, getEra(value, eras), sortable ); + if ( clength < 4 ) { + part = part % 100; + } + ret.push( + padZeros( part, clength ) + ); + break; + case "h": + // Hours with no leading zero for single-digit hours, using 12-hour clock + case "hh": + // Hours with leading zero for single-digit hours, using 12-hour clock + hour = value.getHours() % 12; + if ( hour === 0 ) hour = 12; + ret.push( + padZeros( hour, clength ) + ); + break; + case "H": + // Hours with no leading zero for single-digit hours, using 24-hour clock + case "HH": + // Hours with leading zero for single-digit hours, using 24-hour clock + ret.push( + padZeros( value.getHours(), clength ) + ); + break; + case "m": + // Minutes with no leading zero for single-digit minutes + case "mm": + // Minutes with leading zero for single-digit minutes + ret.push( + padZeros( value.getMinutes(), clength ) + ); + break; + case "s": + // Seconds with no leading zero for single-digit seconds + case "ss": + // Seconds with leading zero for single-digit seconds + ret.push( + padZeros( value.getSeconds(), clength ) + ); + break; + case "t": + // One character am/pm indicator ("a" or "p") + case "tt": + // Multicharacter am/pm indicator + part = value.getHours() < 12 ? ( cal.AM ? cal.AM[0] : " " ) : ( cal.PM ? cal.PM[0] : " " ); + ret.push( clength === 1 ? part.charAt(0) : part ); + break; + case "f": + // Deciseconds + case "ff": + // Centiseconds + case "fff": + // Milliseconds + ret.push( + padZeros( value.getMilliseconds(), 3 ).substr( 0, clength ) + ); + break; + case "z": + // Time zone offset, no leading zero + case "zz": + // Time zone offset with leading zero + hour = value.getTimezoneOffset() / 60; + ret.push( + ( hour <= 0 ? "+" : "-" ) + padZeros( Math.floor(Math.abs(hour)), clength ) + ); + break; + case "zzz": + // Time zone offset with leading zero + hour = value.getTimezoneOffset() / 60; + ret.push( + ( hour <= 0 ? "+" : "-" ) + padZeros( Math.floor(Math.abs(hour)), 2 ) + // Hard coded ":" separator, rather than using cal.TimeSeparator + // Repeated here for consistency, plus ":" was already assumed in date parsing. + + ":" + padZeros( Math.abs(value.getTimezoneOffset() % 60), 2 ) + ); + break; + case "g": + case "gg": + if ( cal.eras ) { + ret.push( + cal.eras[ getEra(value, eras) ].name + ); + } + break; + case "/": + ret.push( cal["/"] ); + break; + default: + throw "Invalid date format pattern \'" + current + "\'."; + break; + } + } + return ret.join( "" ); +}; + +// formatNumber +(function() { + var expandNumber; + + expandNumber = function( number, precision, formatInfo ) { + var groupSizes = formatInfo.groupSizes, + curSize = groupSizes[ 0 ], + curGroupIndex = 1, + factor = Math.pow( 10, precision ), + rounded = Math.round( number * factor ) / factor; + + if ( !isFinite(rounded) ) { + rounded = number; + } + number = rounded; + + var numberString = number+"", + right = "", + split = numberString.split( /e/i ), + exponent = split.length > 1 ? parseInt( split[1], 10 ) : 0; + numberString = split[ 0 ]; + split = numberString.split( "." ); + numberString = split[ 0 ]; + right = split.length > 1 ? split[ 1 ] : ""; + + var l; + if ( exponent > 0 ) { + right = zeroPad( right, exponent, false ); + numberString += right.slice( 0, exponent ); + right = right.substr( exponent ); + } + else if ( exponent < 0 ) { + exponent = -exponent; + numberString = zeroPad( numberString, exponent + 1 ); + right = numberString.slice( -exponent, numberString.length ) + right; + numberString = numberString.slice( 0, -exponent ); + } + + if ( precision > 0 ) { + right = formatInfo[ "." ] + + ( (right.length > precision) ? right.slice(0, precision) : zeroPad(right, precision) ); + } + else { + right = ""; + } + + var stringIndex = numberString.length - 1, + sep = formatInfo[ "," ], + ret = ""; + + while ( stringIndex >= 0 ) { + if ( curSize === 0 || curSize > stringIndex ) { + return numberString.slice( 0, stringIndex + 1 ) + ( ret.length ? (sep + ret + right) : right ); + } + ret = numberString.slice( stringIndex - curSize + 1, stringIndex + 1 ) + ( ret.length ? (sep + ret) : "" ); + + stringIndex -= curSize; + + if ( curGroupIndex < groupSizes.length ) { + curSize = groupSizes[ curGroupIndex ]; + curGroupIndex++; + } + } + + return numberString.slice( 0, stringIndex + 1 ) + sep + ret + right; + }; + + formatNumber = function( value, format, culture ) { + if ( !isFinite(value) ) { + if ( value === Infinity ) { + return culture.numberFormat.positiveInfinity; + } + if ( value === -Infinity ) { + return culture.numberFormat.negativeInfinity; + } + return culture.numberFormat.NaN; + } + if ( !format || format === "i" ) { + return culture.name.length ? value.toLocaleString() : value.toString(); + } + format = format || "D"; + + var nf = culture.numberFormat, + number = Math.abs( value ), + precision = -1, + pattern; + if ( format.length > 1 ) precision = parseInt( format.slice(1), 10 ); + + var current = format.charAt( 0 ).toUpperCase(), + formatInfo; + + switch ( current ) { + case "D": + pattern = "n"; + number = truncate( number ); + if ( precision !== -1 ) { + number = zeroPad( "" + number, precision, true ); + } + if ( value < 0 ) number = "-" + number; + break; + case "N": + formatInfo = nf; + // fall through + case "C": + formatInfo = formatInfo || nf.currency; + // fall through + case "P": + formatInfo = formatInfo || nf.percent; + pattern = value < 0 ? formatInfo.pattern[ 0 ] : ( formatInfo.pattern[1] || "n" ); + if ( precision === -1 ) precision = formatInfo.decimals; + number = expandNumber( number * (current === "P" ? 100 : 1), precision, formatInfo ); + break; + default: + throw "Bad number format specifier: " + current; + } + + var patternParts = /n|\$|-|%/g, + ret = ""; + for ( ; ; ) { + var index = patternParts.lastIndex, + ar = patternParts.exec( pattern ); + + ret += pattern.slice( index, ar ? ar.index : pattern.length ); + + if ( !ar ) { + break; + } + + switch ( ar[0] ) { + case "n": + ret += number; + break; + case "$": + ret += nf.currency.symbol; + break; + case "-": + // don't make 0 negative + if ( /[1-9]/.test(number) ) { + ret += nf[ "-" ]; + } + break; + case "%": + ret += nf.percent.symbol; + break; + } + } + + return ret; + }; + +}()); + +getTokenRegExp = function() { + // regular expression for matching date and time tokens in format strings. + return /\/|dddd|ddd|dd|d|MMMM|MMM|MM|M|yyyy|yy|y|hh|h|HH|H|mm|m|ss|s|tt|t|fff|ff|f|zzz|zz|z|gg|g/g; +}; + +getEra = function( date, eras ) { + if ( !eras ) return 0; + var start, ticks = date.getTime(); + for ( var i = 0, l = eras.length; i < l; i++ ) { + start = eras[ i ].start; + if ( start === null || ticks >= start ) { + return i; + } + } + return 0; +}; + +getEraYear = function( date, cal, era, sortable ) { + var year = date.getFullYear(); + if ( !sortable && cal.eras ) { + // convert normal gregorian year to era-shifted gregorian + // year by subtracting the era offset + year -= cal.eras[ era ].offset; + } + return year; +}; + +// parseExact +(function() { + var expandYear, + getDayIndex, + getMonthIndex, + getParseRegExp, + outOfRange, + toUpper, + toUpperArray; + + expandYear = function( cal, year ) { + // expands 2-digit year into 4 digits. + var now = new Date(), + era = getEra( now ); + if ( year < 100 ) { + var twoDigitYearMax = cal.twoDigitYearMax; + twoDigitYearMax = typeof twoDigitYearMax === "string" ? new Date().getFullYear() % 100 + parseInt( twoDigitYearMax, 10 ) : twoDigitYearMax; + var curr = getEraYear( now, cal, era ); + year += curr - ( curr % 100 ); + if ( year > twoDigitYearMax ) { + year -= 100; + } + } + return year; + }; + + getDayIndex = function ( cal, value, abbr ) { + var ret, + days = cal.days, + upperDays = cal._upperDays; + if ( !upperDays ) { + cal._upperDays = upperDays = [ + toUpperArray( days.names ), + toUpperArray( days.namesAbbr ), + toUpperArray( days.namesShort ) + ]; + } + value = toUpper( value ); + if ( abbr ) { + ret = arrayIndexOf( upperDays[1], value ); + if ( ret === -1 ) { + ret = arrayIndexOf( upperDays[2], value ); + } + } + else { + ret = arrayIndexOf( upperDays[0], value ); + } + return ret; + }; + + getMonthIndex = function( cal, value, abbr ) { + var months = cal.months, + monthsGen = cal.monthsGenitive || cal.months, + upperMonths = cal._upperMonths, + upperMonthsGen = cal._upperMonthsGen; + if ( !upperMonths ) { + cal._upperMonths = upperMonths = [ + toUpperArray( months.names ), + toUpperArray( months.namesAbbr ) + ]; + cal._upperMonthsGen = upperMonthsGen = [ + toUpperArray( monthsGen.names ), + toUpperArray( monthsGen.namesAbbr ) + ]; + } + value = toUpper( value ); + var i = arrayIndexOf( abbr ? upperMonths[1] : upperMonths[0], value ); + if ( i < 0 ) { + i = arrayIndexOf( abbr ? upperMonthsGen[1] : upperMonthsGen[0], value ); + } + return i; + }; + + getParseRegExp = function( cal, format ) { + // converts a format string into a regular expression with groups that + // can be used to extract date fields from a date string. + // check for a cached parse regex. + var re = cal._parseRegExp; + if ( !re ) { + cal._parseRegExp = re = {}; + } + else { + var reFormat = re[ format ]; + if ( reFormat ) { + return reFormat; + } + } + + // expand single digit formats, then escape regular expression characters. + var expFormat = expandFormat( cal, format ).replace( /([\^\$\.\*\+\?\|\[\]\(\)\{\}])/g, "\\\\$1" ), + regexp = [ "^" ], + groups = [], + index = 0, + quoteCount = 0, + tokenRegExp = getTokenRegExp(), + match; + + // iterate through each date token found. + while ( (match = tokenRegExp.exec(expFormat)) !== null ) { + var preMatch = expFormat.slice( index, match.index ); + index = tokenRegExp.lastIndex; + + // don't replace any matches that occur inside a string literal. + quoteCount += appendPreOrPostMatch( preMatch, regexp ); + if ( quoteCount % 2 ) { + regexp.push( match[0] ); + continue; + } + + // add a regex group for the token. + var m = match[ 0 ], + len = m.length, + add; + switch ( m ) { + case "dddd": case "ddd": + case "MMMM": case "MMM": + case "gg": case "g": + add = "(\\D+)"; + break; + case "tt": case "t": + add = "(\\D*)"; + break; + case "yyyy": + case "fff": + case "ff": + case "f": + add = "(\\d{" + len + "})"; + break; + case "dd": case "d": + case "MM": case "M": + case "yy": case "y": + case "HH": case "H": + case "hh": case "h": + case "mm": case "m": + case "ss": case "s": + add = "(\\d\\d?)"; + break; + case "zzz": + add = "([+-]?\\d\\d?:\\d{2})"; + break; + case "zz": case "z": + add = "([+-]?\\d\\d?)"; + break; + case "/": + add = "(\\" + cal[ "/" ] + ")"; + break; + default: + throw "Invalid date format pattern \'" + m + "\'."; + break; + } + if ( add ) { + regexp.push( add ); + } + groups.push( match[0] ); + } + appendPreOrPostMatch( expFormat.slice(index), regexp ); + regexp.push( "$" ); + + // allow whitespace to differ when matching formats. + var regexpStr = regexp.join( "" ).replace( /\s+/g, "\\s+" ), + parseRegExp = { "regExp": regexpStr, "groups": groups }; + + // cache the regex for this format. + return re[ format ] = parseRegExp; + }; + + outOfRange = function( value, low, high ) { + return value < low || value > high; + }; + + toUpper = function( value ) { + // "he-IL" has non-breaking space in weekday names. + return value.split( "\u00A0" ).join( " " ).toUpperCase(); + }; + + toUpperArray = function( arr ) { + var results = []; + for ( var i = 0, l = arr.length; i < l; i++ ) { + results[ i ] = toUpper( arr[i] ); + } + return results; + }; + + parseExact = function( value, format, culture ) { + // try to parse the date string by matching against the format string + // while using the specified culture for date field names. + value = trim( value ); + var cal = culture.calendar, + // convert date formats into regular expressions with groupings. + // use the regexp to determine the input format and extract the date fields. + parseInfo = getParseRegExp( cal, format ), + match = new RegExp( parseInfo.regExp ).exec( value ); + if ( match === null ) { + return null; + } + // found a date format that matches the input. + var groups = parseInfo.groups, + era = null, year = null, month = null, date = null, weekDay = null, + hour = 0, hourOffset, min = 0, sec = 0, msec = 0, tzMinOffset = null, + pmHour = false; + // iterate the format groups to extract and set the date fields. + for ( var j = 0, jl = groups.length; j < jl; j++ ) { + var matchGroup = match[ j + 1 ]; + if ( matchGroup ) { + var current = groups[ j ], + clength = current.length, + matchInt = parseInt( matchGroup, 10 ); + switch ( current ) { + case "dd": case "d": + // Day of month. + date = matchInt; + // check that date is generally in valid range, also checking overflow below. + if ( outOfRange(date, 1, 31) ) return null; + break; + case "MMM": case "MMMM": + month = getMonthIndex( cal, matchGroup, clength === 3 ); + if ( outOfRange(month, 0, 11) ) return null; + break; + case "M": case "MM": + // Month. + month = matchInt - 1; + if ( outOfRange(month, 0, 11) ) return null; + break; + case "y": case "yy": + case "yyyy": + year = clength < 4 ? expandYear( cal, matchInt ) : matchInt; + if ( outOfRange(year, 0, 9999) ) return null; + break; + case "h": case "hh": + // Hours (12-hour clock). + hour = matchInt; + if ( hour === 12 ) hour = 0; + if ( outOfRange(hour, 0, 11) ) return null; + break; + case "H": case "HH": + // Hours (24-hour clock). + hour = matchInt; + if ( outOfRange(hour, 0, 23) ) return null; + break; + case "m": case "mm": + // Minutes. + min = matchInt; + if ( outOfRange(min, 0, 59) ) return null; + break; + case "s": case "ss": + // Seconds. + sec = matchInt; + if ( outOfRange(sec, 0, 59) ) return null; + break; + case "tt": case "t": + // AM/PM designator. + // see if it is standard, upper, or lower case PM. If not, ensure it is at least one of + // the AM tokens. If not, fail the parse for this format. + pmHour = cal.PM && ( matchGroup === cal.PM[0] || matchGroup === cal.PM[1] || matchGroup === cal.PM[2] ); + if ( + !pmHour && ( + !cal.AM || ( matchGroup !== cal.AM[0] && matchGroup !== cal.AM[1] && matchGroup !== cal.AM[2] ) + ) + ) return null; + break; + case "f": + // Deciseconds. + case "ff": + // Centiseconds. + case "fff": + // Milliseconds. + msec = matchInt * Math.pow( 10, 3 - clength ); + if ( outOfRange(msec, 0, 999) ) return null; + break; + case "ddd": + // Day of week. + case "dddd": + // Day of week. + weekDay = getDayIndex( cal, matchGroup, clength === 3 ); + if ( outOfRange(weekDay, 0, 6) ) return null; + break; + case "zzz": + // Time zone offset in +/- hours:min. + var offsets = matchGroup.split( /:/ ); + if ( offsets.length !== 2 ) return null; + hourOffset = parseInt( offsets[0], 10 ); + if ( outOfRange(hourOffset, -12, 13) ) return null; + var minOffset = parseInt( offsets[1], 10 ); + if ( outOfRange(minOffset, 0, 59) ) return null; + tzMinOffset = ( hourOffset * 60 ) + ( startsWith(matchGroup, "-") ? -minOffset : minOffset ); + break; + case "z": case "zz": + // Time zone offset in +/- hours. + hourOffset = matchInt; + if ( outOfRange(hourOffset, -12, 13) ) return null; + tzMinOffset = hourOffset * 60; + break; + case "g": case "gg": + var eraName = matchGroup; + if ( !eraName || !cal.eras ) return null; + eraName = trim( eraName.toLowerCase() ); + for ( var i = 0, l = cal.eras.length; i < l; i++ ) { + if ( eraName === cal.eras[i].name.toLowerCase() ) { + era = i; + break; + } + } + // could not find an era with that name + if ( era === null ) return null; + break; + } + } + } + var result = new Date(), defaultYear, convert = cal.convert; + defaultYear = convert ? convert.fromGregorian( result )[ 0 ] : result.getFullYear(); + if ( year === null ) { + year = defaultYear; + } + else if ( cal.eras ) { + // year must be shifted to normal gregorian year + // but not if year was not specified, its already normal gregorian + // per the main if clause above. + year += cal.eras[( era || 0 )].offset; + } + // set default day and month to 1 and January, so if unspecified, these are the defaults + // instead of the current day/month. + if ( month === null ) { + month = 0; + } + if ( date === null ) { + date = 1; + } + // now have year, month, and date, but in the culture's calendar. + // convert to gregorian if necessary + if ( convert ) { + result = convert.toGregorian( year, month, date ); + // conversion failed, must be an invalid match + if ( result === null ) return null; + } + else { + // have to set year, month and date together to avoid overflow based on current date. + result.setFullYear( year, month, date ); + // check to see if date overflowed for specified month (only checked 1-31 above). + if ( result.getDate() !== date ) return null; + // invalid day of week. + if ( weekDay !== null && result.getDay() !== weekDay ) { + return null; + } + } + // if pm designator token was found make sure the hours fit the 24-hour clock. + if ( pmHour && hour < 12 ) { + hour += 12; + } + result.setHours( hour, min, sec, msec ); + if ( tzMinOffset !== null ) { + // adjust timezone to utc before applying local offset. + var adjustedMin = result.getMinutes() - ( tzMinOffset + result.getTimezoneOffset() ); + // Safari limits hours and minutes to the range of -127 to 127. We need to use setHours + // to ensure both these fields will not exceed this range. adjustedMin will range + // somewhere between -1440 and 1500, so we only need to split this into hours. + result.setHours( result.getHours() + parseInt(adjustedMin / 60, 10), adjustedMin % 60 ); + } + return result; + }; +}()); + +parseNegativePattern = function( value, nf, negativePattern ) { + var neg = nf[ "-" ], + pos = nf[ "+" ], + ret; + switch ( negativePattern ) { + case "n -": + neg = " " + neg; + pos = " " + pos; + // fall through + case "n-": + if ( endsWith(value, neg) ) { + ret = [ "-", value.substr(0, value.length - neg.length) ]; + } + else if ( endsWith(value, pos) ) { + ret = [ "+", value.substr(0, value.length - pos.length) ]; + } + break; + case "- n": + neg += " "; + pos += " "; + // fall through + case "-n": + if ( startsWith(value, neg) ) { + ret = [ "-", value.substr(neg.length) ]; + } + else if ( startsWith(value, pos) ) { + ret = [ "+", value.substr(pos.length) ]; + } + break; + case "(n)": + if ( startsWith(value, "(") && endsWith(value, ")") ) { + ret = [ "-", value.substr(1, value.length - 2) ]; + } + break; + } + return ret || [ "", value ]; +}; + +// +// public instance functions +// + +Globalize.prototype.findClosestCulture = function( cultureSelector ) { + return Globalize.findClosestCulture.call( this, cultureSelector ); +}; + +Globalize.prototype.format = function( value, format, cultureSelector ) { + return Globalize.format.call( this, value, format, cultureSelector ); +}; + +Globalize.prototype.localize = function( key, cultureSelector ) { + return Globalize.localize.call( this, key, cultureSelector ); +}; + +Globalize.prototype.parseInt = function( value, radix, cultureSelector ) { + return Globalize.parseInt.call( this, value, radix, cultureSelector ); +}; + +Globalize.prototype.parseFloat = function( value, radix, cultureSelector ) { + return Globalize.parseFloat.call( this, value, radix, cultureSelector ); +}; + +Globalize.prototype.culture = function( cultureSelector ) { + return Globalize.culture.call( this, cultureSelector ); +}; + +// +// public singleton functions +// + +Globalize.addCultureInfo = function( cultureName, baseCultureName, info ) { + + var base = {}, + isNew = false; + + if ( typeof cultureName !== "string" ) { + // cultureName argument is optional string. If not specified, assume info is first + // and only argument. Specified info deep-extends current culture. + info = cultureName; + cultureName = this.culture().name; + base = this.cultures[ cultureName ]; + } else if ( typeof baseCultureName !== "string" ) { + // baseCultureName argument is optional string. If not specified, assume info is second + // argument. Specified info deep-extends specified culture. + // If specified culture does not exist, create by deep-extending default + info = baseCultureName; + isNew = ( this.cultures[ cultureName ] == null ); + base = this.cultures[ cultureName ] || this.cultures[ "default" ]; + } else { + // cultureName and baseCultureName specified. Assume a new culture is being created + // by deep-extending an specified base culture + isNew = true; + base = this.cultures[ baseCultureName ]; + } + + this.cultures[ cultureName ] = extend(true, {}, + base, + info + ); + // Make the standard calendar the current culture if it's a new culture + if ( isNew ) { + this.cultures[ cultureName ].calendar = this.cultures[ cultureName ].calendars.standard; + } +}; + +Globalize.findClosestCulture = function( name ) { + var match; + if ( !name ) { + return this.cultures[ this.cultureSelector ] || this.cultures[ "default" ]; + } + if ( typeof name === "string" ) { + name = name.split( "," ); + } + if ( isArray(name) ) { + var lang, + cultures = this.cultures, + list = name, + i, l = list.length, + prioritized = []; + for ( i = 0; i < l; i++ ) { + name = trim( list[i] ); + var pri, parts = name.split( ";" ); + lang = trim( parts[0] ); + if ( parts.length === 1 ) { + pri = 1; + } + else { + name = trim( parts[1] ); + if ( name.indexOf("q=") === 0 ) { + name = name.substr( 2 ); + pri = parseFloat( name ); + pri = isNaN( pri ) ? 0 : pri; + } + else { + pri = 1; + } + } + prioritized.push({ lang: lang, pri: pri }); + } + prioritized.sort(function( a, b ) { + return a.pri < b.pri ? 1 : -1; + }); + + // exact match + for ( i = 0; i < l; i++ ) { + lang = prioritized[ i ].lang; + match = cultures[ lang ]; + if ( match ) { + return match; + } + } + + // neutral language match + for ( i = 0; i < l; i++ ) { + lang = prioritized[ i ].lang; + do { + var index = lang.lastIndexOf( "-" ); + if ( index === -1 ) { + break; + } + // strip off the last part. e.g. en-US => en + lang = lang.substr( 0, index ); + match = cultures[ lang ]; + if ( match ) { + return match; + } + } + while ( 1 ); + } + + // last resort: match first culture using that language + for ( i = 0; i < l; i++ ) { + lang = prioritized[ i ].lang; + for ( var cultureKey in cultures ) { + var culture = cultures[ cultureKey ]; + if ( culture.language == lang ) { + return culture; + } + } + } + } + else if ( typeof name === "object" ) { + return name; + } + return match || null; +}; + +Globalize.format = function( value, format, cultureSelector ) { + culture = this.findClosestCulture( cultureSelector ); + if ( value instanceof Date ) { + value = formatDate( value, format, culture ); + } + else if ( typeof value === "number" ) { + value = formatNumber( value, format, culture ); + } + return value; +}; + +Globalize.localize = function( key, cultureSelector ) { + return this.findClosestCulture( cultureSelector ).messages[ key ] || + this.cultures[ "default" ].messages[ key ]; +}; + +Globalize.parseDate = function( value, formats, culture ) { + culture = this.findClosestCulture( culture ); + + var date, prop, patterns; + if ( formats ) { + if ( typeof formats === "string" ) { + formats = [ formats ]; + } + if ( formats.length ) { + for ( var i = 0, l = formats.length; i < l; i++ ) { + var format = formats[ i ]; + if ( format ) { + date = parseExact( value, format, culture ); + if ( date ) { + break; + } + } + } + } + } else { + patterns = culture.calendar.patterns; + for ( prop in patterns ) { + date = parseExact( value, patterns[prop], culture ); + if ( date ) { + break; + } + } + } + + return date || null; +}; + +Globalize.parseInt = function( value, radix, cultureSelector ) { + return truncate( Globalize.parseFloat(value, radix, cultureSelector) ); +}; + +Globalize.parseFloat = function( value, radix, cultureSelector ) { + // radix argument is optional + if ( typeof radix !== "number" ) { + cultureSelector = radix; + radix = 10; + } + + var culture = this.findClosestCulture( cultureSelector ); + var ret = NaN, + nf = culture.numberFormat; + + if ( value.indexOf(culture.numberFormat.currency.symbol) > -1 ) { + // remove currency symbol + value = value.replace( culture.numberFormat.currency.symbol, "" ); + // replace decimal seperator + value = value.replace( culture.numberFormat.currency["."], culture.numberFormat["."] ); + } + + // trim leading and trailing whitespace + value = trim( value ); + + // allow infinity or hexidecimal + if ( regexInfinity.test(value) ) { + ret = parseFloat( value ); + } + else if ( !radix && regexHex.test(value) ) { + ret = parseInt( value, 16 ); + } + else { + + // determine sign and number + var signInfo = parseNegativePattern( value, nf, nf.pattern[0] ), + sign = signInfo[ 0 ], + num = signInfo[ 1 ]; + + // #44 - try parsing as "(n)" + if ( sign === "" && nf.pattern[0] !== "(n)" ) { + signInfo = parseNegativePattern( value, nf, "(n)" ); + sign = signInfo[ 0 ]; + num = signInfo[ 1 ]; + } + + // try parsing as "-n" + if ( sign === "" && nf.pattern[0] !== "-n" ) { + signInfo = parseNegativePattern( value, nf, "-n" ); + sign = signInfo[ 0 ]; + num = signInfo[ 1 ]; + } + + sign = sign || "+"; + + // determine exponent and number + var exponent, + intAndFraction, + exponentPos = num.indexOf( "e" ); + if ( exponentPos < 0 ) exponentPos = num.indexOf( "E" ); + if ( exponentPos < 0 ) { + intAndFraction = num; + exponent = null; + } + else { + intAndFraction = num.substr( 0, exponentPos ); + exponent = num.substr( exponentPos + 1 ); + } + // determine decimal position + var integer, + fraction, + decSep = nf[ "." ], + decimalPos = intAndFraction.indexOf( decSep ); + if ( decimalPos < 0 ) { + integer = intAndFraction; + fraction = null; + } + else { + integer = intAndFraction.substr( 0, decimalPos ); + fraction = intAndFraction.substr( decimalPos + decSep.length ); + } + // handle groups (e.g. 1,000,000) + var groupSep = nf[ "," ]; + integer = integer.split( groupSep ).join( "" ); + var altGroupSep = groupSep.replace( /\u00A0/g, " " ); + if ( groupSep !== altGroupSep ) { + integer = integer.split( altGroupSep ).join( "" ); + } + // build a natively parsable number string + var p = sign + integer; + if ( fraction !== null ) { + p += "." + fraction; + } + if ( exponent !== null ) { + // exponent itself may have a number patternd + var expSignInfo = parseNegativePattern( exponent, nf, "-n" ); + p += "e" + ( expSignInfo[0] || "+" ) + expSignInfo[ 1 ]; + } + if ( regexParseFloat.test(p) ) { + ret = parseFloat( p ); + } + } + return ret; +}; + +Globalize.culture = function( cultureSelector ) { + // setter + if ( typeof cultureSelector !== "undefined" ) { + this.cultureSelector = cultureSelector; + } + // getter + return this.findClosestCulture( cultureSelector ) || this.culture[ "default" ]; +}; + +}( this )); diff --git a/external/jquery.global.de-DE.js b/external/jquery.global.de-DE.js deleted file mode 100644 index e526e7831..000000000 --- a/external/jquery.global.de-DE.js +++ /dev/null @@ -1,55 +0,0 @@ -(function($) { - var cultures = $.global.cultures, - en = cultures.en, - standard = en.calendars.standard, - culture = cultures["de-DE"] = $.extend(true, {}, en, { - name: "de-DE", - englishName: "German (Germany)", - nativeName: "Deutsch (Deutschland)", - language: "de", - numberFormat: { - ',': ".", - '.': ",", - percent: { - pattern: ["-n%","n%"], - ',': ".", - '.': "," - }, - currency: { - pattern: ["-n $","n $"], - ',': ".", - '.': ",", - symbol: "€" - } - }, - calendars: { - standard: $.extend(true, {}, standard, { - '/': ".", - firstDay: 1, - days: { - names: ["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"], - namesAbbr: ["So","Mo","Di","Mi","Do","Fr","Sa"], - namesShort: ["So","Mo","Di","Mi","Do","Fr","Sa"] - }, - months: { - names: ["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember",""], - namesAbbr: ["Jan","Feb","Mrz","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez",""] - }, - AM: null, - PM: null, - eras: [{"name":"n. Chr.","start":null,"offset":0}], - patterns: { - d: "dd.MM.yyyy", - D: "dddd, d. MMMM yyyy", - t: "HH:mm", - T: "HH:mm:ss", - f: "dddd, d. MMMM yyyy HH:mm", - F: "dddd, d. MMMM yyyy HH:mm:ss", - M: "dd MMMM", - Y: "MMMM yyyy" - } - }) - } - }, cultures["de-DE"]); - culture.calendar = culture.calendars.standard; -})(jQuery);
\ No newline at end of file diff --git a/external/jquery.global.ja-JP.js b/external/jquery.global.ja-JP.js deleted file mode 100644 index 3673cefd1..000000000 --- a/external/jquery.global.ja-JP.js +++ /dev/null @@ -1,74 +0,0 @@ -(function($) { - var cultures = $.global.cultures, - en = cultures.en, - standard = en.calendars.standard, - culture = cultures["ja-JP"] = $.extend(true, {}, en, { - name: "ja-JP", - englishName: "Japanese (Japan)", - nativeName: "日本語 (日本)", - language: "ja", - numberFormat: { - percent: { - pattern: ["-n%","n%"] - }, - currency: { - pattern: ["-$n","$n"], - decimals: 0, - symbol: "¥" - } - }, - calendars: { - standard: $.extend(true, {}, standard, { - days: { - names: ["日曜日","月曜日","火曜日","水曜日","木曜日","金曜日","土曜日"], - namesAbbr: ["日","月","火","水","木","金","土"], - namesShort: ["日","月","火","水","木","金","土"] - }, - months: { - names: ["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月",""], - namesAbbr: ["1","2","3","4","5","6","7","8","9","10","11","12",""] - }, - AM: ["午前","午前","午前"], - PM: ["午後","午後","午後"], - eras: [{"name":"西暦","start":null,"offset":0}], - patterns: { - d: "yyyy/MM/dd", - D: "yyyy'年'M'月'd'日'", - t: "H:mm", - T: "H:mm:ss", - f: "yyyy'年'M'月'd'日' H:mm", - F: "yyyy'年'M'月'd'日' H:mm:ss", - M: "M'月'd'日'", - Y: "yyyy'年'M'月'" - } - }), - Japanese: $.extend(true, {}, standard, { - name: "Japanese", - days: { - names: ["日曜日","月曜日","火曜日","水曜日","木曜日","金曜日","土曜日"], - namesAbbr: ["日","月","火","水","木","金","土"], - namesShort: ["日","月","火","水","木","金","土"] - }, - months: { - names: ["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月",""], - namesAbbr: ["1","2","3","4","5","6","7","8","9","10","11","12",""] - }, - AM: ["午前","午前","午前"], - PM: ["午後","午後","午後"], - eras: [{"name":"平成","start":null,"offset":1867},{"name":"昭和","start":-1812153600000,"offset":1911},{"name":"大正","start":-1357603200000,"offset":1925},{"name":"明治","start":60022080000,"offset":1988}], - twoDigitYearMax: 99, - patterns: { - d: "gg y/M/d", - D: "gg y'年'M'月'd'日'", - t: "H:mm", - T: "H:mm:ss", - f: "gg y'年'M'月'd'日' H:mm", - F: "gg y'年'M'月'd'日' H:mm:ss", - M: "M'月'd'日'", - Y: "gg y'年'M'月'" - } - }) - } - }, cultures["ja-JP"]); - culture.calendar = culture.calendars.standard; -})(jQuery);
\ No newline at end of file diff --git a/external/jquery.global.js b/external/jquery.global.js deleted file mode 100644 index 29ae5c637..000000000 --- a/external/jquery.global.js +++ /dev/null @@ -1,1341 +0,0 @@ -/*! - * jQuery Globalization Plugin - * http://github.com/jquery/jquery-global - * - * Copyright Software Freedom Conservancy, Inc. - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - */ -(function() { - -var Globalization = {}, localized = { en: {} }; -localized["default"] = localized.en; - -Globalization.extend = function( deep ) { - var target = arguments[ 1 ] || {}; - for ( var i = 2, l = arguments.length; i < l; i++ ) { - var source = arguments[ i ]; - if ( source ) { - for ( var field in source ) { - var sourceVal = source[ field ]; - if ( typeof sourceVal !== "undefined" ) { - if ( deep && (isObject( sourceVal ) || isArray( sourceVal )) ) { - var targetVal = target[ field ]; - // extend onto the existing value, or create a new one - targetVal = targetVal && (isObject( targetVal ) || isArray( targetVal )) - ? targetVal - : (isArray( sourceVal ) ? [] : {}); - target[ field ] = this.extend( true, targetVal, sourceVal ); - } - else { - target[ field ] = sourceVal; - } - } - } - } - } - return target; -} - -Globalization.findClosestCulture = function(name) { - var match; - if ( !name ) { - return this.culture || this.cultures["default"]; - } - if ( isString( name ) ) { - name = name.split( ',' ); - } - if ( isArray( name ) ) { - var lang, - cultures = this.cultures, - list = name, - i, l = list.length, - prioritized = []; - for ( i = 0; i < l; i++ ) { - name = trim( list[ i ] ); - var pri, parts = name.split( ';' ); - lang = trim( parts[ 0 ] ); - if ( parts.length === 1 ) { - pri = 1; - } - else { - name = trim( parts[ 1 ] ); - if ( name.indexOf("q=") === 0 ) { - name = name.substr( 2 ); - pri = parseFloat( name, 10 ); - pri = isNaN( pri ) ? 0 : pri; - } - else { - pri = 1; - } - } - prioritized.push( { lang: lang, pri: pri } ); - } - prioritized.sort(function(a, b) { - return a.pri < b.pri ? 1 : -1; - }); - for ( i = 0; i < l; i++ ) { - lang = prioritized[ i ].lang; - match = cultures[ lang ]; - // exact match? - if ( match ) { - return match; - } - } - for ( i = 0; i < l; i++ ) { - lang = prioritized[ i ].lang; - // for each entry try its neutral language - do { - var index = lang.lastIndexOf( "-" ); - if ( index === -1 ) { - break; - } - // strip off the last part. e.g. en-US => en - lang = lang.substr( 0, index ); - match = cultures[ lang ]; - if ( match ) { - return match; - } - } - while ( 1 ); - } - } - else if ( typeof name === 'object' ) { - return name; - } - return match || null; -} -Globalization.preferCulture = function(name) { - this.culture = this.findClosestCulture( name ) || this.cultures["default"]; -} -Globalization.localize = function(key, culture, value) { - // usign default culture in case culture is not provided - if (typeof culture !== 'string') { - culture = this.culture.name || this.culture || "default"; - } - culture = this.cultures[ culture ] || { name: culture }; - - var local = localized[ culture.name ]; - if ( arguments.length === 3 ) { - if ( !local) { - local = localized[ culture.name ] = {}; - } - local[ key ] = value; - } - else { - if ( local ) { - value = local[ key ]; - } - if ( typeof value === 'undefined' ) { - var language = localized[ culture.language ]; - if ( language ) { - value = language[ key ]; - } - if ( typeof value === 'undefined' ) { - value = localized["default"][ key ]; - } - } - } - return typeof value === "undefined" ? null : value; -} -Globalization.format = function(value, format, culture) { - culture = this.findClosestCulture( culture ); - if ( typeof value === "number" ) { - value = formatNumber( value, format, culture ); - } - else if ( value instanceof Date ) { - value = formatDate( value, format, culture ); - } - return value; -} -Globalization.parseInt = function(value, radix, culture) { - return Math.floor( this.parseFloat( value, radix, culture ) ); -} -Globalization.parseFloat = function(value, radix, culture) { - // make radix optional - if (typeof radix === "string") { - culture = radix; - radix = 10; - } - - culture = this.findClosestCulture( culture ); - var ret = NaN, - nf = culture.numberFormat; - - if (value.indexOf(culture.numberFormat.currency.symbol) > -1) { - // remove currency symbol - value = value.replace(culture.numberFormat.currency.symbol, ""); - // replace decimal seperator - value = value.replace(culture.numberFormat.currency["."], culture.numberFormat["."]); - } - - // trim leading and trailing whitespace - value = trim( value ); - - // allow infinity or hexidecimal - if (regexInfinity.test(value)) { - ret = parseFloat(value, radix); - } - else if (!radix && regexHex.test(value)) { - ret = parseInt(value, 16); - } - else { - var signInfo = parseNegativePattern( value, nf, nf.pattern[0] ), - sign = signInfo[0], - num = signInfo[1]; - // determine sign and number - if ( sign === "" && nf.pattern[0] !== "-n" ) { - signInfo = parseNegativePattern( value, nf, "-n" ); - sign = signInfo[0]; - num = signInfo[1]; - } - sign = sign || "+"; - // determine exponent and number - var exponent, - intAndFraction, - exponentPos = num.indexOf( 'e' ); - if ( exponentPos < 0 ) exponentPos = num.indexOf( 'E' ); - if ( exponentPos < 0 ) { - intAndFraction = num; - exponent = null; - } - else { - intAndFraction = num.substr( 0, exponentPos ); - exponent = num.substr( exponentPos + 1 ); - } - // determine decimal position - var integer, - fraction, - decSep = nf['.'], - decimalPos = intAndFraction.indexOf( decSep ); - if ( decimalPos < 0 ) { - integer = intAndFraction; - fraction = null; - } - else { - integer = intAndFraction.substr( 0, decimalPos ); - fraction = intAndFraction.substr( decimalPos + decSep.length ); - } - // handle groups (e.g. 1,000,000) - var groupSep = nf[","]; - integer = integer.split(groupSep).join(''); - var altGroupSep = groupSep.replace(/\u00A0/g, " "); - if ( groupSep !== altGroupSep ) { - integer = integer.split(altGroupSep).join(''); - } - // build a natively parsable number string - var p = sign + integer; - if ( fraction !== null ) { - p += '.' + fraction; - } - if ( exponent !== null ) { - // exponent itself may have a number patternd - var expSignInfo = parseNegativePattern( exponent, nf, "-n" ); - p += 'e' + (expSignInfo[0] || "+") + expSignInfo[1]; - } - if ( regexParseFloat.test( p ) ) { - ret = parseFloat( p ); - } - } - return ret; -} -Globalization.parseDate = function(value, formats, culture) { - culture = this.findClosestCulture( culture ); - - var date, prop, patterns; - if ( formats ) { - if ( typeof formats === "string" ) { - formats = [ formats ]; - } - if ( formats.length ) { - for ( var i = 0, l = formats.length; i < l; i++ ) { - var format = formats[ i ]; - if ( format ) { - date = parseExact( value, format, culture ); - if ( date ) { - break; - } - } - } - } - } - else { - patterns = culture.calendar.patterns; - for ( prop in patterns ) { - date = parseExact( value, patterns[prop], culture ); - if ( date ) { - break; - } - } - } - return date || null; -} - -// 1. When defining a culture, all fields are required except the ones stated as optional. -// 2. You can use Globalization.extend to copy an existing culture and provide only the differing values, -// a good practice since most cultures do not differ too much from the 'default' culture. -// DO use the 'default' culture if you do this, as it is the only one that definitely -// exists. -// 3. Other plugins may add to the culture information provided by extending it. However, -// that plugin may extend it prior to the culture being defined, or after. Therefore, -// do not overwrite values that already exist when defining the baseline for a culture, -// by extending your culture object with the existing one. -// 4. Each culture should have a ".calendars" object with at least one calendar named "standard" -// which serves as the default calendar in use by that culture. -// 5. Each culture should have a ".calendar" object which is the current calendar being used, -// it may be dynamically changed at any time to one of the calendars in ".calendars". - -// To define a culture, use the following pattern, which handles defining the culture based -// on the 'default culture, extending it with the existing culture if it exists, and defining -// it if it does not exist. -// Globalization.cultures.foo = Globalization.extend(true, Globalization.extend(true, {}, Globalization.cultures['default'], fooCulture), Globalization.cultures.foo) - -var cultures = Globalization.cultures = Globalization.cultures || {}; -var en = cultures["default"] = cultures.en = Globalization.extend(true, { - // A unique name for the culture in the form <language code>-<country/region code> - name: "en", - // the name of the culture in the english language - englishName: "English", - // the name of the culture in its own language - nativeName: "English", - // whether the culture uses right-to-left text - isRTL: false, - // 'language' is used for so-called "specific" cultures. - // For example, the culture "es-CL" means "Spanish, in Chili". - // It represents the Spanish-speaking culture as it is in Chili, - // which might have different formatting rules or even translations - // than Spanish in Spain. A "neutral" culture is one that is not - // specific to a region. For example, the culture "es" is the generic - // Spanish culture, which may be a more generalized version of the language - // that may or may not be what a specific culture expects. - // For a specific culture like "es-CL", the 'language' field refers to the - // neutral, generic culture information for the language it is using. - // This is not always a simple matter of the string before the dash. - // For example, the "zh-Hans" culture is netural (Simplified Chinese). - // And the 'zh-SG' culture is Simplified Chinese in Singapore, whose lanugage - // field is "zh-CHS", not "zh". - // This field should be used to navigate from a specific culture to it's - // more general, neutral culture. If a culture is already as general as it - // can get, the language may refer to itself. - language: "en", - // numberFormat defines general number formatting rules, like the digits in - // each grouping, the group separator, and how negative numbers are displayed. - numberFormat: { - // [negativePattern] - // Note, numberFormat.pattern has no 'positivePattern' unlike percent and currency, - // but is still defined as an array for consistency with them. - // negativePattern: one of "(n)|-n|- n|n-|n -" - pattern: ["-n"], - // number of decimal places normally shown - decimals: 2, - // string that separates number groups, as in 1,000,000 - ',': ",", - // string that separates a number from the fractional portion, as in 1.99 - '.': ".", - // array of numbers indicating the size of each number group. - // TODO: more detailed description and example - groupSizes: [3], - // symbol used for positive numbers - '+': "+", - // symbol used for negative numbers - '-': "-", - percent: { - // [negativePattern, positivePattern] - // negativePattern: one of "-n %|-n%|-%n|%-n|%n-|n-%|n%-|-% n|n %-|% n-|% -n|n- %" - // positivePattern: one of "n %|n%|%n|% n" - pattern: ["-n %","n %"], - // number of decimal places normally shown - decimals: 2, - // array of numbers indicating the size of each number group. - // TODO: more detailed description and example - groupSizes: [3], - // string that separates number groups, as in 1,000,000 - ',': ",", - // string that separates a number from the fractional portion, as in 1.99 - '.': ".", - // symbol used to represent a percentage - symbol: "%" - }, - currency: { - // [negativePattern, positivePattern] - // negativePattern: one of "($n)|-$n|$-n|$n-|(n$)|-n$|n-$|n$-|-n $|-$ n|n $-|$ n-|$ -n|n- $|($ n)|(n $)" - // positivePattern: one of "$n|n$|$ n|n $" - pattern: ["($n)","$n"], - // number of decimal places normally shown - decimals: 2, - // array of numbers indicating the size of each number group. - // TODO: more detailed description and example - groupSizes: [3], - // string that separates number groups, as in 1,000,000 - ',': ",", - // string that separates a number from the fractional portion, as in 1.99 - '.': ".", - // symbol used to represent currency - symbol: "$" - } - }, - // calendars defines all the possible calendars used by this culture. - // There should be at least one defined with name 'standard', and is the default - // calendar used by the culture. - // A calendar contains information about how dates are formatted, information about - // the calendar's eras, a standard set of the date formats, - // translations for day and month names, and if the calendar is not based on the Gregorian - // calendar, conversion functions to and from the Gregorian calendar. - calendars: { - standard: { - // name that identifies the type of calendar this is - name: "Gregorian_USEnglish", - // separator of parts of a date (e.g. '/' in 11/05/1955) - '/': "/", - // separator of parts of a time (e.g. ':' in 05:44 PM) - ':': ":", - // the first day of the week (0 = Sunday, 1 = Monday, etc) - firstDay: 0, - days: { - // full day names - names: ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"], - // abbreviated day names - namesAbbr: ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"], - // shortest day names - namesShort: ["Su","Mo","Tu","We","Th","Fr","Sa"] - }, - months: { - // full month names (13 months for lunar calendards -- 13th month should be "" if not lunar) - names: ["January","February","March","April","May","June","July","August","September","October","November","December",""], - // abbreviated month names - namesAbbr: ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",""] - }, - // AM and PM designators in one of these forms: - // The usual view, and the upper and lower case versions - // [standard,lowercase,uppercase] - // The culture does not use AM or PM (likely all standard date formats use 24 hour time) - // null - AM: ["AM", "am", "AM"], - PM: ["PM", "pm", "PM"], - eras: [ - // eras in reverse chronological order. - // name: the name of the era in this culture (e.g. A.D., C.E.) - // start: when the era starts in ticks (gregorian, gmt), null if it is the earliest supported era. - // offset: offset in years from gregorian calendar - { "name": "A.D.", "start": null, "offset": 0 } - ], - // when a two digit year is given, it will never be parsed as a four digit - // year greater than this year (in the appropriate era for the culture) - // Set it as a full year (e.g. 2029) or use an offset format starting from - // the current year: "+19" would correspond to 2029 if the current year 2010. - twoDigitYearMax: 2029, - // set of predefined date and time patterns used by the culture - // these represent the format someone in this culture would expect - // to see given the portions of the date that are shown. - patterns: { - // short date pattern - d: "M/d/yyyy", - // long date pattern - D: "dddd, MMMM dd, yyyy", - // short time pattern - t: "h:mm tt", - // long time pattern - T: "h:mm:ss tt", - // long date, short time pattern - f: "dddd, MMMM dd, yyyy h:mm tt", - // long date, long time pattern - F: "dddd, MMMM dd, yyyy h:mm:ss tt", - // month/day pattern - M: "MMMM dd", - // month/year pattern - Y: "yyyy MMMM", - // S is a sortable format that does not vary by culture - S: "yyyy\u0027-\u0027MM\u0027-\u0027dd\u0027T\u0027HH\u0027:\u0027mm\u0027:\u0027ss" - } - // optional fields for each calendar: - /* - monthsGenitive: - Same as months but used when the day preceeds the month. - Omit if the culture has no genitive distinction in month names. - For an explaination of genitive months, see http://blogs.msdn.com/michkap/archive/2004/12/25/332259.aspx - convert: - Allows for the support of non-gregorian based calendars. This convert object is used to - to convert a date to and from a gregorian calendar date to handle parsing and formatting. - The two functions: - fromGregorian(date) - Given the date as a parameter, return an array with parts [year, month, day] - corresponding to the non-gregorian based year, month, and day for the calendar. - toGregorian(year, month, day) - Given the non-gregorian year, month, and day, return a new Date() object - set to the corresponding date in the gregorian calendar. - */ - } - } -}, cultures.en); -en.calendar = en.calendar || en.calendars.standard; - -var regexTrim = /^\s+|\s+$/g, - regexInfinity = /^[+-]?infinity$/i, - regexHex = /^0x[a-f0-9]+$/i, - regexParseFloat = /^[+-]?\d*\.?\d*(e[+-]?\d+)?$/, - toString = Object.prototype.toString; - -function startsWith(value, pattern) { - return value.indexOf( pattern ) === 0; -} - -function endsWith(value, pattern) { - return value.substr( value.length - pattern.length ) === pattern; -} - -function trim(value) { - return (value+"").replace( regexTrim, "" ); -} - -function zeroPad(str, count, left) { - for (var l=str.length; l < count; l++) { - str = (left ? ('0' + str) : (str + '0')); - } - return str; -} - -function isArray(obj) { - return toString.call(obj) === "[object Array]"; -} - -function isString(obj) { - return toString.call(obj) === "[object String]"; -} - -function isObject(obj) { - return toString.call(obj) === "[object Object]"; -} - -function arrayIndexOf( array, item ) { - if ( array.indexOf ) { - return array.indexOf( item ); - } - for ( var i = 0, length = array.length; i < length; i++ ) { - if ( array[ i ] === item ) { - return i; - } - } - return -1; -} - -// *************************************** Numbers *************************************** - -function expandNumber(number, precision, formatInfo) { - var groupSizes = formatInfo.groupSizes, - curSize = groupSizes[ 0 ], - curGroupIndex = 1, - factor = Math.pow( 10, precision ), - rounded = Math.round( number * factor ) / factor; - if ( !isFinite(rounded) ) { - rounded = number; - } - number = rounded; - - var numberString = number+"", - right = "", - split = numberString.split(/e/i), - exponent = split.length > 1 ? parseInt( split[ 1 ], 10 ) : 0; - numberString = split[ 0 ]; - split = numberString.split( "." ); - numberString = split[ 0 ]; - right = split.length > 1 ? split[ 1 ] : ""; - - var l; - if ( exponent > 0 ) { - right = zeroPad( right, exponent, false ); - numberString += right.slice( 0, exponent ); - right = right.substr( exponent ); - } - else if ( exponent < 0 ) { - exponent = -exponent; - numberString = zeroPad( numberString, exponent + 1 ); - right = numberString.slice( -exponent, numberString.length ) + right; - numberString = numberString.slice( 0, -exponent ); - } - - if ( precision > 0 ) { - right = formatInfo['.'] + - ((right.length > precision) ? right.slice( 0, precision ) : zeroPad( right, precision )); - } - else { - right = ""; - } - - var stringIndex = numberString.length - 1, - sep = formatInfo[","], - ret = ""; - - while ( stringIndex >= 0 ) { - if ( curSize === 0 || curSize > stringIndex ) { - return numberString.slice( 0, stringIndex + 1 ) + ( ret.length ? ( sep + ret + right ) : right ); - } - ret = numberString.slice( stringIndex - curSize + 1, stringIndex + 1 ) + ( ret.length ? ( sep + ret ) : "" ); - - stringIndex -= curSize; - - if ( curGroupIndex < groupSizes.length ) { - curSize = groupSizes[ curGroupIndex ]; - curGroupIndex++; - } - } - return numberString.slice( 0, stringIndex + 1 ) + sep + ret + right; -} - - -function parseNegativePattern(value, nf, negativePattern) { - var neg = nf["-"], - pos = nf["+"], - ret; - switch (negativePattern) { - case "n -": - neg = ' ' + neg; - pos = ' ' + pos; - // fall through - case "n-": - if ( endsWith( value, neg ) ) { - ret = [ '-', value.substr( 0, value.length - neg.length ) ]; - } - else if ( endsWith( value, pos ) ) { - ret = [ '+', value.substr( 0, value.length - pos.length ) ]; - } - break; - case "- n": - neg += ' '; - pos += ' '; - // fall through - case "-n": - if ( startsWith( value, neg ) ) { - ret = [ '-', value.substr( neg.length ) ]; - } - else if ( startsWith(value, pos) ) { - ret = [ '+', value.substr( pos.length ) ]; - } - break; - case "(n)": - if ( startsWith( value, '(' ) && endsWith( value, ')' ) ) { - ret = [ '-', value.substr( 1, value.length - 2 ) ]; - } - break; - } - return ret || [ '', value ]; -} - -function formatNumber(value, format, culture) { - if ( !format || format === 'i' ) { - return culture.name.length ? value.toLocaleString() : value.toString(); - } - format = format || "D"; - - var nf = culture.numberFormat, - number = Math.abs(value), - precision = -1, - pattern; - if (format.length > 1) precision = parseInt( format.slice( 1 ), 10 ); - - var current = format.charAt( 0 ).toUpperCase(), - formatInfo; - - switch (current) { - case "D": - pattern = 'n'; - if (precision !== -1) { - number = zeroPad( ""+number, precision, true ); - } - if (value < 0) number = -number; - break; - case "N": - formatInfo = nf; - // fall through - case "C": - formatInfo = formatInfo || nf.currency; - // fall through - case "P": - formatInfo = formatInfo || nf.percent; - pattern = value < 0 ? formatInfo.pattern[0] : (formatInfo.pattern[1] || "n"); - if (precision === -1) precision = formatInfo.decimals; - number = expandNumber( number * (current === "P" ? 100 : 1), precision, formatInfo ); - break; - default: - throw "Bad number format specifier: " + current; - } - - var patternParts = /n|\$|-|%/g, - ret = ""; - for (;;) { - var index = patternParts.lastIndex, - ar = patternParts.exec(pattern); - - ret += pattern.slice( index, ar ? ar.index : pattern.length ); - - if (!ar) { - break; - } - - switch (ar[0]) { - case "n": - ret += number; - break; - case "$": - ret += nf.currency.symbol; - break; - case "-": - // don't make 0 negative - if ( /[1-9]/.test( number ) ) { - ret += nf["-"]; - } - break; - case "%": - ret += nf.percent.symbol; - break; - } - } - - return ret; -} - -// *************************************** Dates *************************************** - -function outOfRange(value, low, high) { - return value < low || value > high; -} - -function expandYear(cal, year) { - // expands 2-digit year into 4 digits. - var now = new Date(), - era = getEra(now); - if ( year < 100 ) { - var twoDigitYearMax = cal.twoDigitYearMax; - twoDigitYearMax = typeof twoDigitYearMax === 'string' ? new Date().getFullYear() % 100 + parseInt( twoDigitYearMax, 10 ) : twoDigitYearMax; - var curr = getEraYear( now, cal, era ); - year += curr - ( curr % 100 ); - if ( year > twoDigitYearMax ) { - year -= 100; - } - } - return year; -} - -function getEra(date, eras) { - if ( !eras ) return 0; - var start, ticks = date.getTime(); - for ( var i = 0, l = eras.length; i < l; i++ ) { - start = eras[ i ].start; - if ( start === null || ticks >= start ) { - return i; - } - } - return 0; -} - -function toUpper(value) { - // 'he-IL' has non-breaking space in weekday names. - return value.split( "\u00A0" ).join(' ').toUpperCase(); -} - -function toUpperArray(arr) { - var results = []; - for ( var i = 0, l = arr.length; i < l; i++ ) { - results[i] = toUpper(arr[i]); - } - return results; -} - -function getEraYear(date, cal, era, sortable) { - var year = date.getFullYear(); - if ( !sortable && cal.eras ) { - // convert normal gregorian year to era-shifted gregorian - // year by subtracting the era offset - year -= cal.eras[ era ].offset; - } - return year; -} - -function getDayIndex(cal, value, abbr) { - var ret, - days = cal.days, - upperDays = cal._upperDays; - if ( !upperDays ) { - cal._upperDays = upperDays = [ - toUpperArray( days.names ), - toUpperArray( days.namesAbbr ), - toUpperArray( days.namesShort ) - ]; - } - value = toUpper( value ); - if ( abbr ) { - ret = arrayIndexOf( upperDays[ 1 ], value ); - if ( ret === -1 ) { - ret = arrayIndexOf( upperDays[ 2 ], value ); - } - } - else { - ret = arrayIndexOf( upperDays[ 0 ], value ); - } - return ret; -} - -function getMonthIndex(cal, value, abbr) { - var months = cal.months, - monthsGen = cal.monthsGenitive || cal.months, - upperMonths = cal._upperMonths, - upperMonthsGen = cal._upperMonthsGen; - if ( !upperMonths ) { - cal._upperMonths = upperMonths = [ - toUpperArray( months.names ), - toUpperArray( months.namesAbbr ) - ]; - cal._upperMonthsGen = upperMonthsGen = [ - toUpperArray( monthsGen.names ), - toUpperArray( monthsGen.namesAbbr ) - ]; - } - value = toUpper( value ); - var i = arrayIndexOf( abbr ? upperMonths[ 1 ] : upperMonths[ 0 ], value ); - if ( i < 0 ) { - i = arrayIndexOf( abbr ? upperMonthsGen[ 1 ] : upperMonthsGen[ 0 ], value ); - } - return i; -} - -function appendPreOrPostMatch(preMatch, strings) { - // appends pre- and post- token match strings while removing escaped characters. - // Returns a single quote count which is used to determine if the token occurs - // in a string literal. - var quoteCount = 0, - escaped = false; - for ( var i = 0, il = preMatch.length; i < il; i++ ) { - var c = preMatch.charAt( i ); - switch ( c ) { - case '\'': - if ( escaped ) { - strings.push( "'" ); - } - else { - quoteCount++; - } - escaped = false; - break; - case '\\': - if ( escaped ) { - strings.push( "\\" ); - } - escaped = !escaped; - break; - default: - strings.push( c ); - escaped = false; - break; - } - } - return quoteCount; -} - -function expandFormat(cal, format) { - // expands unspecified or single character date formats into the full pattern. - format = format || "F"; - var pattern, - patterns = cal.patterns, - len = format.length; - if ( len === 1 ) { - pattern = patterns[ format ]; - if ( !pattern ) { - throw "Invalid date format string '" + format + "'."; - } - format = pattern; - } - else if ( len === 2 && format.charAt(0) === "%" ) { - // %X escape format -- intended as a custom format string that is only one character, not a built-in format. - format = format.charAt( 1 ); - } - return format; -} - -function getParseRegExp(cal, format) { - // converts a format string into a regular expression with groups that - // can be used to extract date fields from a date string. - // check for a cached parse regex. - var re = cal._parseRegExp; - if ( !re ) { - cal._parseRegExp = re = {}; - } - else { - var reFormat = re[ format ]; - if ( reFormat ) { - return reFormat; - } - } - - // expand single digit formats, then escape regular expression characters. - var expFormat = expandFormat( cal, format ).replace( /([\^\$\.\*\+\?\|\[\]\(\)\{\}])/g, "\\\\$1" ), - regexp = ["^"], - groups = [], - index = 0, - quoteCount = 0, - tokenRegExp = getTokenRegExp(), - match; - - // iterate through each date token found. - while ( (match = tokenRegExp.exec( expFormat )) !== null ) { - var preMatch = expFormat.slice( index, match.index ); - index = tokenRegExp.lastIndex; - - // don't replace any matches that occur inside a string literal. - quoteCount += appendPreOrPostMatch( preMatch, regexp ); - if ( quoteCount % 2 ) { - regexp.push( match[ 0 ] ); - continue; - } - - // add a regex group for the token. - var m = match[ 0 ], - len = m.length, - add; - switch ( m ) { - case 'dddd': case 'ddd': - case 'MMMM': case 'MMM': - case 'gg': case 'g': - add = "(\\D+)"; - break; - case 'tt': case 't': - add = "(\\D*)"; - break; - case 'yyyy': - case 'fff': - case 'ff': - case 'f': - add = "(\\d{" + len + "})"; - break; - case 'dd': case 'd': - case 'MM': case 'M': - case 'yy': case 'y': - case 'HH': case 'H': - case 'hh': case 'h': - case 'mm': case 'm': - case 'ss': case 's': - add = "(\\d\\d?)"; - break; - case 'zzz': - add = "([+-]?\\d\\d?:\\d{2})"; - break; - case 'zz': case 'z': - add = "([+-]?\\d\\d?)"; - break; - case '/': - add = "(\\" + cal["/"] + ")"; - break; - default: - throw "Invalid date format pattern '" + m + "'."; - break; - } - if ( add ) { - regexp.push( add ); - } - groups.push( match[ 0 ] ); - } - appendPreOrPostMatch( expFormat.slice( index ), regexp ); - regexp.push( "$" ); - - // allow whitespace to differ when matching formats. - var regexpStr = regexp.join( '' ).replace( /\s+/g, "\\s+" ), - parseRegExp = {'regExp': regexpStr, 'groups': groups}; - - // cache the regex for this format. - return re[ format ] = parseRegExp; -} - -function getTokenRegExp() { - // regular expression for matching date and time tokens in format strings. - return /\/|dddd|ddd|dd|d|MMMM|MMM|MM|M|yyyy|yy|y|hh|h|HH|H|mm|m|ss|s|tt|t|fff|ff|f|zzz|zz|z|gg|g/g; -} - -function parseExact(value, format, culture) { - // try to parse the date string by matching against the format string - // while using the specified culture for date field names. - value = trim( value ); - var cal = culture.calendar, - // convert date formats into regular expressions with groupings. - // use the regexp to determine the input format and extract the date fields. - parseInfo = getParseRegExp(cal, format), - match = new RegExp(parseInfo.regExp).exec(value); - if (match === null) { - return null; - } - // found a date format that matches the input. - var groups = parseInfo.groups, - era = null, year = null, month = null, date = null, weekDay = null, - hour = 0, hourOffset, min = 0, sec = 0, msec = 0, tzMinOffset = null, - pmHour = false; - // iterate the format groups to extract and set the date fields. - for ( var j = 0, jl = groups.length; j < jl; j++ ) { - var matchGroup = match[ j + 1 ]; - if ( matchGroup ) { - var current = groups[ j ], - clength = current.length, - matchInt = parseInt( matchGroup, 10 ); - switch ( current ) { - case 'dd': case 'd': - // Day of month. - date = matchInt; - // check that date is generally in valid range, also checking overflow below. - if ( outOfRange( date, 1, 31 ) ) return null; - break; - case 'MMM': - case 'MMMM': - month = getMonthIndex( cal, matchGroup, clength === 3 ); - if ( outOfRange( month, 0, 11 ) ) return null; - break; - case 'M': case 'MM': - // Month. - month = matchInt - 1; - if ( outOfRange( month, 0, 11 ) ) return null; - break; - case 'y': case 'yy': - case 'yyyy': - year = clength < 4 ? expandYear( cal, matchInt ) : matchInt; - if ( outOfRange( year, 0, 9999 ) ) return null; - break; - case 'h': case 'hh': - // Hours (12-hour clock). - hour = matchInt; - if ( hour === 12 ) hour = 0; - if ( outOfRange( hour, 0, 11 ) ) return null; - break; - case 'H': case 'HH': - // Hours (24-hour clock). - hour = matchInt; - if ( outOfRange( hour, 0, 23 ) ) return null; - break; - case 'm': case 'mm': - // Minutes. - min = matchInt; - if ( outOfRange( min, 0, 59 ) ) return null; - break; - case 's': case 'ss': - // Seconds. - sec = matchInt; - if ( outOfRange( sec, 0, 59 ) ) return null; - break; - case 'tt': case 't': - // AM/PM designator. - // see if it is standard, upper, or lower case PM. If not, ensure it is at least one of - // the AM tokens. If not, fail the parse for this format. - pmHour = cal.PM && ( matchGroup === cal.PM[0] || matchGroup === cal.PM[1] || matchGroup === cal.PM[2] ); - if ( !pmHour && ( !cal.AM || (matchGroup !== cal.AM[0] && matchGroup !== cal.AM[1] && matchGroup !== cal.AM[2]) ) ) return null; - break; - case 'f': - // Deciseconds. - case 'ff': - // Centiseconds. - case 'fff': - // Milliseconds. - msec = matchInt * Math.pow( 10, 3-clength ); - if ( outOfRange( msec, 0, 999 ) ) return null; - break; - case 'ddd': - // Day of week. - case 'dddd': - // Day of week. - weekDay = getDayIndex( cal, matchGroup, clength === 3 ); - if ( outOfRange( weekDay, 0, 6 ) ) return null; - break; - case 'zzz': - // Time zone offset in +/- hours:min. - var offsets = matchGroup.split( /:/ ); - if ( offsets.length !== 2 ) return null; - hourOffset = parseInt( offsets[ 0 ], 10 ); - if ( outOfRange( hourOffset, -12, 13 ) ) return null; - var minOffset = parseInt( offsets[ 1 ], 10 ); - if ( outOfRange( minOffset, 0, 59 ) ) return null; - tzMinOffset = (hourOffset * 60) + (startsWith( matchGroup, '-' ) ? -minOffset : minOffset); - break; - case 'z': case 'zz': - // Time zone offset in +/- hours. - hourOffset = matchInt; - if ( outOfRange( hourOffset, -12, 13 ) ) return null; - tzMinOffset = hourOffset * 60; - break; - case 'g': case 'gg': - var eraName = matchGroup; - if ( !eraName || !cal.eras ) return null; - eraName = trim( eraName.toLowerCase() ); - for ( var i = 0, l = cal.eras.length; i < l; i++ ) { - if ( eraName === cal.eras[ i ].name.toLowerCase() ) { - era = i; - break; - } - } - // could not find an era with that name - if ( era === null ) return null; - break; - } - } - } - var result = new Date(), defaultYear, convert = cal.convert; - defaultYear = convert ? convert.fromGregorian( result )[ 0 ] : result.getFullYear(); - if ( year === null ) { - year = defaultYear; - } - else if ( cal.eras ) { - // year must be shifted to normal gregorian year - // but not if year was not specified, its already normal gregorian - // per the main if clause above. - year += cal.eras[ (era || 0) ].offset; - } - // set default day and month to 1 and January, so if unspecified, these are the defaults - // instead of the current day/month. - if ( month === null ) { - month = 0; - } - if ( date === null ) { - date = 1; - } - // now have year, month, and date, but in the culture's calendar. - // convert to gregorian if necessary - if ( convert ) { - result = convert.toGregorian( year, month, date ); - // conversion failed, must be an invalid match - if ( result === null ) return null; - } - else { - // have to set year, month and date together to avoid overflow based on current date. - result.setFullYear( year, month, date ); - // check to see if date overflowed for specified month (only checked 1-31 above). - if ( result.getDate() !== date ) return null; - // invalid day of week. - if ( weekDay !== null && result.getDay() !== weekDay ) { - return null; - } - } - // if pm designator token was found make sure the hours fit the 24-hour clock. - if ( pmHour && hour < 12 ) { - hour += 12; - } - result.setHours( hour, min, sec, msec ); - if ( tzMinOffset !== null ) { - // adjust timezone to utc before applying local offset. - var adjustedMin = result.getMinutes() - ( tzMinOffset + result.getTimezoneOffset() ); - // Safari limits hours and minutes to the range of -127 to 127. We need to use setHours - // to ensure both these fields will not exceed this range. adjustedMin will range - // somewhere between -1440 and 1500, so we only need to split this into hours. - result.setHours( result.getHours() + parseInt( adjustedMin / 60, 10 ), adjustedMin % 60 ); - } - return result; -} - -function formatDate(value, format, culture) { - var cal = culture.calendar, - convert = cal.convert; - if ( !format || !format.length || format === 'i' ) { - var ret; - if ( culture && culture.name.length ) { - if ( convert ) { - // non-gregorian calendar, so we cannot use built-in toLocaleString() - ret = formatDate( value, cal.patterns.F, culture ); - } - else { - var eraDate = new Date( value.getTime() ), - era = getEra( value, cal.eras ); - eraDate.setFullYear( getEraYear( value, cal, era ) ); - ret = eraDate.toLocaleString(); - } - } - else { - ret = value.toString(); - } - return ret; - } - - var eras = cal.eras, - sortable = format === "s"; - format = expandFormat( cal, format ); - - // Start with an empty string - ret = []; - var hour, - zeros = ['0','00','000'], - foundDay, - checkedDay, - dayPartRegExp = /([^d]|^)(d|dd)([^d]|$)/g, - quoteCount = 0, - tokenRegExp = getTokenRegExp(), - converted; - - function padZeros(num, c) { - var r, s = num+''; - if ( c > 1 && s.length < c ) { - r = ( zeros[ c - 2 ] + s); - return r.substr( r.length - c, c ); - } - else { - r = s; - } - return r; - } - - function hasDay() { - if ( foundDay || checkedDay ) { - return foundDay; - } - foundDay = dayPartRegExp.test( format ); - checkedDay = true; - return foundDay; - } - - function getPart( date, part ) { - if ( converted ) { - return converted[ part ]; - } - switch ( part ) { - case 0: return date.getFullYear(); - case 1: return date.getMonth(); - case 2: return date.getDate(); - } - } - - if ( !sortable && convert ) { - converted = convert.fromGregorian( value ); - } - - for (;;) { - // Save the current index - var index = tokenRegExp.lastIndex, - // Look for the next pattern - ar = tokenRegExp.exec( format ); - - // Append the text before the pattern (or the end of the string if not found) - var preMatch = format.slice( index, ar ? ar.index : format.length ); - quoteCount += appendPreOrPostMatch( preMatch, ret ); - - if ( !ar ) { - break; - } - - // do not replace any matches that occur inside a string literal. - if ( quoteCount % 2 ) { - ret.push( ar[ 0 ] ); - continue; - } - - var current = ar[ 0 ], - clength = current.length; - - switch ( current ) { - case "ddd": - //Day of the week, as a three-letter abbreviation - case "dddd": - // Day of the week, using the full name - names = (clength === 3) ? cal.days.namesAbbr : cal.days.names; - ret.push( names[ value.getDay() ] ); - break; - case "d": - // Day of month, without leading zero for single-digit days - case "dd": - // Day of month, with leading zero for single-digit days - foundDay = true; - ret.push( padZeros( getPart( value, 2 ), clength ) ); - break; - case "MMM": - // Month, as a three-letter abbreviation - case "MMMM": - // Month, using the full name - var part = getPart( value, 1 ); - ret.push( (cal.monthsGenitive && hasDay()) - ? cal.monthsGenitive[ clength === 3 ? "namesAbbr" : "names" ][ part ] - : cal.months[ clength === 3 ? "namesAbbr" : "names" ][ part ] ); - break; - case "M": - // Month, as digits, with no leading zero for single-digit months - case "MM": - // Month, as digits, with leading zero for single-digit months - ret.push( padZeros( getPart( value, 1 ) + 1, clength ) ); - break; - case "y": - // Year, as two digits, but with no leading zero for years less than 10 - case "yy": - // Year, as two digits, with leading zero for years less than 10 - case "yyyy": - // Year represented by four full digits - part = converted ? converted[ 0 ] : getEraYear( value, cal, getEra( value, eras ), sortable ); - if ( clength < 4 ) { - part = part % 100; - } - ret.push( padZeros( part, clength ) ); - break; - case "h": - // Hours with no leading zero for single-digit hours, using 12-hour clock - case "hh": - // Hours with leading zero for single-digit hours, using 12-hour clock - hour = value.getHours() % 12; - if ( hour === 0 ) hour = 12; - ret.push( padZeros( hour, clength ) ); - break; - case "H": - // Hours with no leading zero for single-digit hours, using 24-hour clock - case "HH": - // Hours with leading zero for single-digit hours, using 24-hour clock - ret.push( padZeros( value.getHours(), clength ) ); - break; - case "m": - // Minutes with no leading zero for single-digit minutes - case "mm": - // Minutes with leading zero for single-digit minutes - ret.push( padZeros( value.getMinutes(), clength ) ); - break; - case "s": - // Seconds with no leading zero for single-digit seconds - case "ss": - // Seconds with leading zero for single-digit seconds - ret.push( padZeros(value .getSeconds(), clength ) ); - break; - case "t": - // One character am/pm indicator ("a" or "p") - case "tt": - // Multicharacter am/pm indicator - part = value.getHours() < 12 ? (cal.AM ? cal.AM[0] : " ") : (cal.PM ? cal.PM[0] : " "); - ret.push( clength === 1 ? part.charAt( 0 ) : part ); - break; - case "f": - // Deciseconds - case "ff": - // Centiseconds - case "fff": - // Milliseconds - ret.push( padZeros( value.getMilliseconds(), 3 ).substr( 0, clength ) ); - break; - case "z": - // Time zone offset, no leading zero - case "zz": - // Time zone offset with leading zero - hour = value.getTimezoneOffset() / 60; - ret.push( (hour <= 0 ? '+' : '-') + padZeros( Math.floor( Math.abs( hour ) ), clength ) ); - break; - case "zzz": - // Time zone offset with leading zero - hour = value.getTimezoneOffset() / 60; - ret.push( (hour <= 0 ? '+' : '-') + padZeros( Math.floor( Math.abs( hour ) ), 2 ) + - // Hard coded ":" separator, rather than using cal.TimeSeparator - // Repeated here for consistency, plus ":" was already assumed in date parsing. - ":" + padZeros( Math.abs( value.getTimezoneOffset() % 60 ), 2 ) ); - break; - case "g": - case "gg": - if ( cal.eras ) { - ret.push( cal.eras[ getEra(value, eras) ].name ); - } - break; - case "/": - ret.push( cal["/"] ); - break; - default: - throw "Invalid date format pattern '" + current + "'."; - break; - } - } - return ret.join( '' ); -} - -// EXPORTS -jQuery.global = Globalization; - -})(); - diff --git a/external/qunit.js b/external/qunit.js index d56936ee2..a1b3fa5e9 100644 --- a/external/qunit.js +++ b/external/qunit.js @@ -625,7 +625,7 @@ extend(QUnit, { var source = sourceFromStacktrace(); if (source) { details.source = source; - output += '<tr class="test-source"><th>Source: </th><td><pre>' + source +'</pre></td></tr>'; + output += '<tr class="test-source"><th>Source: </th><td><pre>' + escapeHtml(source) + '</pre></td></tr>'; } } output += "</table>"; @@ -649,6 +649,10 @@ extend(QUnit, { return window.location.pathname + querystring.slice( 0, -1 ); }, + extend: extend, + id: id, + addEvent: addEvent, + // Logging callbacks; all receive a single argument with the listed properties // run test/logs.html for any related changes begin: function() {}, @@ -779,7 +783,7 @@ function done() { } if ( typeof document !== "undefined" && document.title ) { - // show ✖ for good, ✔ for bad suite result in title + // show ✖ for bad, ✔ for good suite result in title // use escape sequences in case file gets loaded with non-utf-8-charset document.title = (config.stats.bad ? "\u2716" : "\u2714") + " " + document.title; } diff --git a/tests/unit/accordion/accordion.html b/tests/unit/accordion/accordion.html index 9e23a1243..b3c3b59ac 100644 --- a/tests/unit/accordion/accordion.html +++ b/tests/unit/accordion/accordion.html @@ -4,6 +4,7 @@ <meta charset="utf-8"> <title>jQuery UI Accordion Test Suite</title> + <link rel="stylesheet" href="../../../themes/base/jquery.ui.core.css"> <link rel="stylesheet" href="../../../themes/base/jquery.ui.accordion.css"> <script src="../../jquery.js"></script> @@ -19,36 +20,7 @@ <script src="../../jquery.simulate.js"></script> <script src="../testsuite.js"></script> - <script> - function accordion_state( accordion ) { - var expected = $.makeArray( arguments ).slice( 1 ); - var actual = accordion.find( ".ui-accordion-content" ).map(function() { - return $( this ).css( "display" ) === "none" ? 0 : 1; - }).get(); - deepEqual( actual, expected ); - } - function accordion_equalHeights( accordion, min, max ) { - var sizes = []; - accordion.find( ".ui-accordion-content" ).each(function() { - sizes.push( $( this ).outerHeight() ); - }); - 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 ] ); - } - function accordionSetupTeardown() { - var animated = $.ui.accordion.prototype.options.animated; - return { - setup: function() { - $.ui.accordion.prototype.options.animated = false; - }, - teardown: function() { - $.ui.accordion.prototype.options.animated = animated; - } - }; - } - </script> + <script src="accordion_test_helpers.js"></script> <script src="accordion_defaults.js"></script> <script src="accordion_core.js"></script> <script src="accordion_events.js"></script> @@ -57,8 +29,12 @@ <script src="../swarminject.js"></script> <style> - #qunit-fixture { font-size: 10pt; font-family: "trebuchet ms", verdana, arial; } - #list, #list1 *, #navigation, #navigation * { margin: 0; padding: 0; font-size: 12px; line-height: 15px; } + #list, #list1 *, #navigation, #navigation * { + margin: 0; + padding: 0; + font-size: 12px; + line-height: 15px; + } </style> </head> <body> @@ -74,9 +50,9 @@ <div class="foo"> <p> You've seen it coming! - <br/> + <br> Buy now and get nothing for free! - <br/> + <br> Well, at least no free beer. Perhaps a bear, if you can afford it. </p> </div> @@ -84,7 +60,7 @@ <div class="foo"> <p> your bear, you have to admit it! - <br/> + <br> No, we aren't selling bears. </p> <p> diff --git a/tests/unit/accordion/accordion_core.js b/tests/unit/accordion/accordion_core.js index 18d2d6bfb..3442cad62 100644 --- a/tests/unit/accordion/accordion_core.js +++ b/tests/unit/accordion/accordion_core.js @@ -1,6 +1,6 @@ (function( $ ) { -module( "accordion: core", accordionSetupTeardown() ); +module( "accordion: core", accordion_setupTeardown() ); $.each( { div: "#list1", ul: "#navigation", dl: "#accordion-dl" }, function( type, selector ) { test( "markup structure: " + type, function() { diff --git a/tests/unit/accordion/accordion_deprecated.html b/tests/unit/accordion/accordion_deprecated.html index 7ba6d47e4..3a7ad86f2 100644 --- a/tests/unit/accordion/accordion_deprecated.html +++ b/tests/unit/accordion/accordion_deprecated.html @@ -4,6 +4,7 @@ <meta charset="utf-8"> <title>jQuery UI Accordion Test Suite</title> + <link rel="stylesheet" href="../../../themes/base/jquery.ui.core.css"> <link rel="stylesheet" href="../../../themes/base/jquery.ui.accordion.css"> <script src="../../jquery.js"></script> @@ -16,36 +17,7 @@ <script src="../../jquery.simulate.js"></script> <script src="../testsuite.js"></script> - <script> - function accordion_state( accordion ) { - var expected = $.makeArray( arguments ).slice( 1 ); - var actual = accordion.find( ".ui-accordion-content" ).map(function() { - return $( this ).css( "display" ) === "none" ? 0 : 1; - }).get(); - deepEqual( actual, expected ); - } - function accordion_equalHeights( accordion, min, max ) { - var sizes = []; - accordion.find( ".ui-accordion-content" ).each(function() { - sizes.push( $( this ).outerHeight() ); - }); - 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 ] ); - } - function accordionSetupTeardown() { - var animated = $.ui.accordion.prototype.options.animated; - return { - setup: function() { - $.ui.accordion.prototype.options.animated = false; - }, - teardown: function() { - $.ui.accordion.prototype.options.animated = animated; - } - }; - } - </script> + <script src="accordion_test_helpers.js"></script> <script src="accordion_defaults_deprecated.js"></script> <script src="accordion_core.js"></script> <script src="accordion_events.js"></script> @@ -55,8 +27,12 @@ <script src="../swarminject.js"></script> <style> - #qunit-fixture { font-size: 10pt; font-family: "trebuchet ms", verdana, arial; } - #list, #list1 *, #navigation, #navigation * { margin: 0; padding: 0; font-size: 12px; line-height: 15px; } + #list, #list1 *, #navigation, #navigation * { + margin: 0; + padding: 0; + font-size: 12px; + line-height: 15px; + } </style> </head> <body> @@ -72,9 +48,9 @@ <div class="foo"> <p> You've seen it coming! - <br/> + <br> Buy now and get nothing for free! - <br/> + <br> Well, at least no free beer. Perhaps a bear, if you can afford it. </p> </div> @@ -82,7 +58,7 @@ <div class="foo"> <p> your bear, you have to admit it! - <br/> + <br> No, we aren't selling bears. </p> <p> diff --git a/tests/unit/accordion/accordion_deprecated.js b/tests/unit/accordion/accordion_deprecated.js index 3a2075b2b..eec034e18 100644 --- a/tests/unit/accordion/accordion_deprecated.js +++ b/tests/unit/accordion/accordion_deprecated.js @@ -1,6 +1,6 @@ (function( $ ) { -module( "accordion (deprecated): expanded active option, activate method", accordionSetupTeardown() ); +module( "accordion (deprecated): expanded active option, activate method", accordion_setupTeardown() ); test( "activate, numeric", function() { expect( 5 ); @@ -101,7 +101,7 @@ test( "{ active: jQuery Object }", function() { -module( "accordion (deprecated) - height options", accordionSetupTeardown() ); +module( "accordion (deprecated) - height options", accordion_setupTeardown() ); test( "{ autoHeight: true }, default", function() { expect( 3 ); @@ -174,7 +174,7 @@ test( "{ fillSpace: true } with multiple siblings", function() { -module( "accordion (deprecated) - icons", accordionSetupTeardown() ); +module( "accordion (deprecated) - icons", accordion_setupTeardown() ); test( "icons, headerSelected", function() { expect( 3 ); @@ -191,7 +191,7 @@ test( "icons, headerSelected", function() { -module( "accordion (deprecated) - resize", accordionSetupTeardown() ); +module( "accordion (deprecated) - resize", accordion_setupTeardown() ); test( "resize", function() { expect( 6 ); @@ -213,7 +213,7 @@ test( "resize", function() { -module( "accordion (deprecated) - navigation", accordionSetupTeardown() ); +module( "accordion (deprecated) - navigation", accordion_setupTeardown() ); test( "{ navigation: true, navigationFilter: header }", function() { expect( 2 ); @@ -243,7 +243,7 @@ test( "{ navigation: true, navigationFilter: content }", function() { -module( "accordion (deprecated) - changestart/change events", accordionSetupTeardown() ); +module( "accordion (deprecated) - changestart/change events", accordion_setupTeardown() ); test( "changestart", function() { expect( 26 ); diff --git a/tests/unit/accordion/accordion_events.js b/tests/unit/accordion/accordion_events.js index d704e54c8..12acf2a44 100644 --- a/tests/unit/accordion/accordion_events.js +++ b/tests/unit/accordion/accordion_events.js @@ -1,6 +1,6 @@ (function( $ ) { -module( "accordion: events", accordionSetupTeardown() ); +module( "accordion: events", accordion_setupTeardown() ); test( "beforeActivate", function() { expect( 38 ); diff --git a/tests/unit/accordion/accordion_methods.js b/tests/unit/accordion/accordion_methods.js index c6ba3230a..9f61647c4 100644 --- a/tests/unit/accordion/accordion_methods.js +++ b/tests/unit/accordion/accordion_methods.js @@ -1,6 +1,6 @@ (function( $ ) { -module( "accordion: methods", accordionSetupTeardown() ); +module( "accordion: methods", accordion_setupTeardown() ); test( "destroy", function() { expect( 1 ); diff --git a/tests/unit/accordion/accordion_options.js b/tests/unit/accordion/accordion_options.js index 80b7f0b39..a60bb27e1 100644 --- a/tests/unit/accordion/accordion_options.js +++ b/tests/unit/accordion/accordion_options.js @@ -1,6 +1,6 @@ (function( $ ) { -module( "accordion: options", accordionSetupTeardown() ); +module( "accordion: options", accordion_setupTeardown() ); test( "{ active: default }", function() { expect( 2 ); diff --git a/tests/unit/accordion/accordion_test_helpers.js b/tests/unit/accordion/accordion_test_helpers.js new file mode 100644 index 000000000..66d60a469 --- /dev/null +++ b/tests/unit/accordion/accordion_test_helpers.js @@ -0,0 +1,30 @@ +function accordion_state( accordion ) { + var expected = $.makeArray( arguments ).slice( 1 ); + var actual = accordion.find( ".ui-accordion-content" ).map(function() { + return $( this ).css( "display" ) === "none" ? 0 : 1; + }).get(); + deepEqual( actual, expected ); +} + +function accordion_equalHeights( accordion, min, max ) { + var sizes = []; + accordion.find( ".ui-accordion-content" ).each(function() { + sizes.push( $( this ).outerHeight() ); + }); + 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 ] ); +} + +function accordion_setupTeardown() { + var animated = $.ui.accordion.prototype.options.animated; + return { + setup: function() { + $.ui.accordion.prototype.options.animated = false; + }, + teardown: function() { + $.ui.accordion.prototype.options.animated = animated; + } + }; +} diff --git a/tests/unit/accordion/all.html b/tests/unit/accordion/all.html new file mode 100644 index 000000000..ad4e44300 --- /dev/null +++ b/tests/unit/accordion/all.html @@ -0,0 +1,30 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Accordion Test Suite</title> + + <script src="../../../jquery-1.6.2.js"></script> + + <link rel="stylesheet" href="../../../external/qunit.css"> + <link rel="stylesheet" href="../subsuiteRunner.css"> + <script src="../../../external/qunit.js"></script> + <script src="../subsuiteRunner.js"></script> + <script src="../subsuite.js"></script> + + <script> + testAllVersions( "accordion" ); + </script> +</head> +<body> + +<h1 id="qunit-header">jQuery UI Accordion Test Suite</h1> +<h2 id="qunit-banner"></h2> +<div id="qunit-testrunner-toolbar"></div> +<h2 id="qunit-userAgent"></h2> +<ol id="qunit-tests"></ol> +<div id="qunit-fixture"> + +</div> +</body> +</html> diff --git a/tests/unit/all.html b/tests/unit/all.html index 284885dbc..41d379534 100644 --- a/tests/unit/all.html +++ b/tests/unit/all.html @@ -7,8 +7,9 @@ <script src="../../jquery-1.6.2.js"></script> <link rel="stylesheet" href="../../external/qunit.css"> + <link rel="stylesheet" href="subsuiteRunner.css"> <script src="../../external/qunit.js"></script> - <script src="testsuites.js"></script> + <script src="subsuiteRunner.js"></script> <script> (function() { diff --git a/tests/unit/autocomplete/all.html b/tests/unit/autocomplete/all.html new file mode 100644 index 000000000..6e410dbb3 --- /dev/null +++ b/tests/unit/autocomplete/all.html @@ -0,0 +1,30 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Autocomplete Test Suite</title> + + <script src="../../../jquery-1.6.2.js"></script> + + <link rel="stylesheet" href="../../../external/qunit.css"> + <link rel="stylesheet" href="../subsuiteRunner.css"> + <script src="../../../external/qunit.js"></script> + <script src="../subsuiteRunner.js"></script> + <script src="../subsuite.js"></script> + + <script> + testAllVersions( "autocomplete" ); + </script> +</head> +<body> + +<h1 id="qunit-header">jQuery UI Autocomplete Test Suite</h1> +<h2 id="qunit-banner"></h2> +<div id="qunit-testrunner-toolbar"></div> +<h2 id="qunit-userAgent"></h2> +<ol id="qunit-tests"></ol> +<div id="qunit-fixture"> + +</div> +</body> +</html> diff --git a/tests/unit/autocomplete/autocomplete.html b/tests/unit/autocomplete/autocomplete.html index 82d04291b..e5987350b 100644 --- a/tests/unit/autocomplete/autocomplete.html +++ b/tests/unit/autocomplete/autocomplete.html @@ -4,6 +4,7 @@ <meta charset="utf-8"> <title>jQuery UI Autocomplete Test Suite</title> + <link rel="stylesheet" href="../../../themes/base/jquery.ui.core.css"> <link rel="stylesheet" href="../../../themes/base/jquery.ui.autocomplete.css"> <script src="../../jquery.js"></script> @@ -36,8 +37,9 @@ <div id="qunit-fixture"> <div id="ac-wrap1" class="ac-wrap"></div> -<div id="ac-wrap2" class="ac-wrap"><input id="autocomplete" class="foo" /></div> +<div id="ac-wrap2" class="ac-wrap"><input id="autocomplete" class="foo"></div> <div id="autocomplete-contenteditable" contenteditable="" tabindex=0></div> +<textarea id="autocomplete-textarea"></textarea> </div> </body> diff --git a/tests/unit/autocomplete/autocomplete_events.js b/tests/unit/autocomplete/autocomplete_events.js index c6d42ddcc..6813cfa71 100644 --- a/tests/unit/autocomplete/autocomplete_events.js +++ b/tests/unit/autocomplete/autocomplete_events.js @@ -4,110 +4,75 @@ module( "autocomplete: events" ); var data = [ "Clojure", "COBOL", "ColdFusion", "Java", "JavaScript", "Scala", "Scheme" ]; -asyncTest( "all events", function() { - expect( 13 ); - var element = $( "#autocomplete" ) - .autocomplete({ - autoFocus: false, - delay: 0, - source: data, - search: function( event ) { - equal( event.originalEvent.type, "keydown", "search originalEvent" ); - }, - response: function( event, ui ) { - deepEqual( ui.content, [ - { label: "Clojure", value: "Clojure" }, - { label: "Java", value: "Java" }, - { label: "JavaScript", value: "JavaScript" } - ], "response ui.content" ); - ui.content.splice( 0, 1 ); - }, - open: function( event ) { - ok( menu.is( ":visible" ), "menu open on open" ); - }, - focus: function( event, ui ) { - equal( event.originalEvent.type, "menufocus", "focus originalEvent" ); - deepEqual( ui.item, { label: "Java", value: "Java" }, "focus ui.item" ); - }, - close: function( event ) { - equal( event.originalEvent.type, "menuselect", "close originalEvent" ); - ok( menu.is( ":hidden" ), "menu closed on close" ); - }, - select: function( event, ui ) { - equal( event.originalEvent.type, "menuselect", "select originalEvent" ); - deepEqual( ui.item, { label: "Java", value: "Java" }, "select ui.item" ); - }, - change: function( event, ui ) { - equal( event.originalEvent.type, "blur", "change originalEvent" ); - deepEqual( ui.item, { label: "Java", value: "Java" }, "chnage ui.item" ); - ok( menu.is( ":hidden" ), "menu closed on change" ); - start(); - } - }), - menu = element.autocomplete( "widget" ); - - element.focus().val( "j" ).keydown(); - setTimeout(function() { - ok( menu.is( ":visible" ), "menu is visible after delay" ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); - // blurring through jQuery causes a bug in IE 6 which causes the - // autocompletechange event to occur twice - element[0].blur(); - }, 50 ); -}); - -asyncTest( "all events - contenteditable", function() { - expect( 13 ); - var element = $( "#autocomplete-contenteditable" ) - .autocomplete({ - autoFocus: false, - delay: 0, - source: data, - search: function( event ) { - equal( event.originalEvent.type, "keydown", "search originalEvent" ); - }, - response: function( event, ui ) { - deepEqual( ui.content, [ - { label: "Clojure", value: "Clojure" }, - { label: "Java", value: "Java" }, - { label: "JavaScript", value: "JavaScript" } - ], "response ui.content" ); - ui.content.splice( 0, 1 ); - }, - open: function( event ) { - ok( menu.is( ":visible" ), "menu open on open" ); - }, - focus: function( event, ui ) { - equal( event.originalEvent.type, "menufocus", "focus originalEvent" ); - deepEqual( ui.item, { label: "Java", value: "Java" }, "focus ui.item" ); - }, - close: function( event ) { - equal( event.originalEvent.type, "menuselect", "close originalEvent" ); - ok( menu.is( ":hidden" ), "menu closed on close" ); - }, - select: function( event, ui ) { - equal( event.originalEvent.type, "menuselect", "select originalEvent" ); - deepEqual( ui.item, { label: "Java", value: "Java" }, "select ui.item" ); - }, - change: function( event, ui ) { - equal( event.originalEvent.type, "blur", "change originalEvent" ); - deepEqual( ui.item, { label: "Java", value: "Java" }, "chnage ui.item" ); - ok( menu.is( ":hidden" ), "menu closed on change" ); - start(); - } - }), - menu = element.autocomplete( "widget" ); - - element.focus().text( "j" ).keydown(); - setTimeout(function() { - ok( menu.is( ":visible" ), "menu is visible after delay" ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); - // TODO: blurring through jQuery causes a bug in IE 6 which causes the - // autocompletechange event to occur twice - element[0].blur(); - }, 50 ); +$.each([ + { + type: "input", + selector: "#autocomplete", + valueMethod: "val" + }, + { + type: "textarea", + selector: "#autocomplete-textarea", + valueMethod: "val" + }, + { + type: "contenteditable", + selector: "#autocomplete-contenteditable", + valueMethod: "text" + } +], function( i, settings ) { + asyncTest( "all events - " + settings.type, function() { + expect( 13 ); + var element = $( settings.selector ) + .autocomplete({ + autoFocus: false, + delay: 0, + source: data, + search: function( event ) { + equal( event.originalEvent.type, "keydown", "search originalEvent" ); + }, + response: function( event, ui ) { + deepEqual( ui.content, [ + { label: "Clojure", value: "Clojure" }, + { label: "Java", value: "Java" }, + { label: "JavaScript", value: "JavaScript" } + ], "response ui.content" ); + ui.content.splice( 0, 1 ); + }, + open: function( event ) { + ok( menu.is( ":visible" ), "menu open on open" ); + }, + focus: function( event, ui ) { + equal( event.originalEvent.type, "menufocus", "focus originalEvent" ); + deepEqual( ui.item, { label: "Java", value: "Java" }, "focus ui.item" ); + }, + close: function( event ) { + equal( event.originalEvent.type, "menuselect", "close originalEvent" ); + ok( menu.is( ":hidden" ), "menu closed on close" ); + }, + select: function( event, ui ) { + equal( event.originalEvent.type, "menuselect", "select originalEvent" ); + deepEqual( ui.item, { label: "Java", value: "Java" }, "select ui.item" ); + }, + change: function( event, ui ) { + equal( event.originalEvent.type, "blur", "change originalEvent" ); + deepEqual( ui.item, { label: "Java", value: "Java" }, "chnage ui.item" ); + ok( menu.is( ":hidden" ), "menu closed on change" ); + start(); + } + }), + menu = element.autocomplete( "widget" ); + + element.focus()[ settings.valueMethod ]( "j" ).keydown(); + setTimeout(function() { + ok( menu.is( ":visible" ), "menu is visible after delay" ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); + // blurring through jQuery causes a bug in IE 6 which causes the + // autocompletechange event to occur twice + element[0].blur(); + }, 50 ); + }); }); asyncTest( "change without selection", function() { diff --git a/tests/unit/autocomplete/autocomplete_options.js b/tests/unit/autocomplete/autocomplete_options.js index 01c4e9fef..8d11aa399 100644 --- a/tests/unit/autocomplete/autocomplete_options.js +++ b/tests/unit/autocomplete/autocomplete_options.js @@ -117,7 +117,6 @@ function sourceTest( source, async ) { source: source }), menu = element.autocomplete( "widget" ); - element.val( "ja" ).autocomplete( "search" ); function result() { equal( menu.find( ".ui-menu-item" ).text(), "javajavascript" ); element.autocomplete( "destroy" ); @@ -128,7 +127,9 @@ function sourceTest( source, async ) { if ( async ) { stop(); $( document ).one( "ajaxStop", result ); - } else { + } + element.val( "ja" ).autocomplete( "search" ); + if ( !async ) { result(); } } diff --git a/tests/unit/button/all.html b/tests/unit/button/all.html new file mode 100644 index 000000000..4ff579703 --- /dev/null +++ b/tests/unit/button/all.html @@ -0,0 +1,30 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Button Test Suite</title> + + <script src="../../../jquery-1.6.2.js"></script> + + <link rel="stylesheet" href="../../../external/qunit.css"> + <link rel="stylesheet" href="../subsuiteRunner.css"> + <script src="../../../external/qunit.js"></script> + <script src="../subsuiteRunner.js"></script> + <script src="../subsuite.js"></script> + + <script> + testAllVersions( "button" ); + </script> +</head> +<body> + +<h1 id="qunit-header">jQuery UI Button Test Suite</h1> +<h2 id="qunit-banner"></h2> +<div id="qunit-testrunner-toolbar"></div> +<h2 id="qunit-userAgent"></h2> +<ol id="qunit-tests"></ol> +<div id="qunit-fixture"> + +</div> +</body> +</html> diff --git a/tests/unit/button/button.html b/tests/unit/button/button.html index 3474df20c..7fcf07eec 100644 --- a/tests/unit/button/button.html +++ b/tests/unit/button/button.html @@ -1,29 +1,30 @@ -<!DOCTYPE html> +<!doctype html> <html lang="en"> <head> - <meta charset="UTF-8" /> + <meta charset="utf-8"> <title>jQuery UI Button Test Suite</title> - <link type="text/css" href="../../../themes/base/jquery.ui.button.css" rel="stylesheet" /> + <link rel="stylesheet" href="../../../themes/base/jquery.ui.core.css"> + <link rel="stylesheet" href="../../../themes/base/jquery.ui.button.css"> <script src="../../jquery.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.button.js"></script> + <script src="../../../ui/jquery.ui.core.js"></script> + <script src="../../../ui/jquery.ui.widget.js"></script> + <script src="../../../ui/jquery.ui.button.js"></script> - <link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/> - <script type="text/javascript" src="../../../external/qunit.js"></script> - <script type="text/javascript" src="../../jquery.simulate.js"></script> - <script type="text/javascript" src="../testsuite.js"></script> - - <script type="text/javascript" src="button_core.js"></script> - <script type="text/javascript" src="button_defaults.js"></script> - <script type="text/javascript" src="button_events.js"></script> - <script type="text/javascript" src="button_methods.js"></script> - <script type="text/javascript" src="button_options.js"></script> - <script type="text/javascript" src="button_tickets.js"></script> - - <script type="text/javascript" src="../swarminject.js"></script> + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> + + <script src="button_core.js"></script> + <script src="button_defaults.js"></script> + <script src="button_events.js"></script> + <script src="button_methods.js"></script> + <script src="button_options.js"></script> + <script src="button_tickets.js"></script> + + <script src="../swarminject.js"></script> </head> <body> @@ -31,38 +32,35 @@ <h2 id="qunit-banner"></h2> <div id="qunit-testrunner-toolbar"></div> <h2 id="qunit-userAgent"></h2> -<ol id="qunit-tests"> -</ol> - +<ol id="qunit-tests"></ol> <div id="qunit-fixture"> +<div><button id="button" class="foo">Label</button></div> - <div><button id="button" class="foo">Label</button></div> - - <div id="radio0" style="margin-top: 2em;"> - <input type="radio" id="radio01" name="radio" checked="checked" /><label for="radio01">Choice 1</label> - <input type="radio" id="radio02" name="radio" /><label for="radio02">Choice 2</label> - <input type="radio" id="radio03" name="radio" /><label for="radio03">Choice 3</label> +<div id="radio0" style="margin-top: 2em;"> + <input type="radio" id="radio01" name="radio" checked="checked"><label for="radio01">Choice 1</label> + <input type="radio" id="radio02" name="radio"><label for="radio02">Choice 2</label> + <input type="radio" id="radio03" name="radio"><label for="radio03">Choice 3</label> +</div> +<form> + <div id="radio1" style="margin-top: 2em;"> + <input type="radio" id="radio11" name="radio"><label for="radio11">Choice 1</label> + <input type="radio" id="radio12" name="radio" checked="checked"><label for="radio12">Choice 2</label> + <input type="radio" id="radio13" name="radio"><label for="radio13">Choice 3</label> </div> - <form> - <div id="radio1" style="margin-top: 2em;"> - <input type="radio" id="radio11" name="radio" /><label for="radio11">Choice 1</label> - <input type="radio" id="radio12" name="radio" checked="checked" /><label for="radio12">Choice 2</label> - <input type="radio" id="radio13" name="radio" /><label for="radio13">Choice 3</label> - </div> - </form> - <form> - <div id="radio2" style="margin-top: 2em;"> - <input type="radio" id="radio21" name="radio" /><label for="radio21">Choice 1</label> - <input type="radio" id="radio22" name="radio" /><label for="radio22">Choice 2</label> - <input type="radio" id="radio23" name="radio" checked="checked" /><label for="radio23">Choice 3</label> - </div> - </form> - - <input type="checkbox" id="check" /><label for="check">Toggle</label> +</form> +<form> + <div id="radio2" style="margin-top: 2em;"> + <input type="radio" id="radio21" name="radio"><label for="radio21">Choice 1</label> + <input type="radio" id="radio22" name="radio"><label for="radio22">Choice 2</label> + <input type="radio" id="radio23" name="radio" checked="checked"><label for="radio23">Choice 3</label> + </div> +</form> - <div><input id="submit" type="submit" value="Label" /></div> -</div> +<input type="checkbox" id="check"><label for="check">Toggle</label> +<div><input id="submit" type="submit" value="Label"></div> + +</div> </body> </html> diff --git a/tests/unit/button/button_tickets.js b/tests/unit/button/button_tickets.js index 9a7ccae43..624d16716 100644 --- a/tests/unit/button/button_tickets.js +++ b/tests/unit/button/button_tickets.js @@ -29,25 +29,31 @@ 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() { - var group = $( "<span><label for='t7092a'/><input type='checkbox' id='t7092a'/></span>" ); + var group = $( "<span><label for='t7092a'></label><input type='checkbox' id='t7092a'></span>" ); group.find( "input:checkbox" ).button(); ok( group.find( "label" ).is( ".ui-button" ) ); - group = $( "<input type='checkbox' id='t7092b'/><label for='t7092b'/>" ); + group = $( "<input type='checkbox' id='t7092b'><label for='t7092b'></label>" ); group.filter( "input:checkbox" ).button(); ok( group.filter( "label" ).is( ".ui-button" ) ); - group = $( "<span><input type='checkbox' id='t7092c'/></span><label for='t7092c'/>" ); + group = $( "<span><input type='checkbox' id='t7092c'></span><label for='t7092c'></label>" ); group.find( "input:checkbox" ).button(); ok( group.filter( "label" ).is( ".ui-button" ) ); - group = $( "<span><input type='checkbox' id='t7092d'/></span><span><label for='t7092d'/></span>" ); + group = $( "<span><input type='checkbox' id='t7092d'></span><span><label for='t7092d'></label></span>" ); group.find( "input:checkbox" ).button(); ok( group.find( "label" ).is( ".ui-button" ) ); - group = $( "<input type='checkbox' id='t7092e'/><span><label for='t7092e'/></span>" ); + group = $( "<input type='checkbox' id='t7092e'><span><label for='t7092e'></label></span>" ); group.filter( "input:checkbox" ).button(); ok( group.find( "label" ).is( ".ui-button" ) ); }); +test( "#7534 - Button label selector works for ids with \":\"", function() { + var group = $( "<span><input type='checkbox' id='check:7534'><label for='check:7534'>Label</label></span>" ); + group.find( "input" ).button(); + ok( group.find( "label" ).is( ".ui-button" ), "Found an id with a :" ); +}); + })( jQuery ); diff --git a/tests/unit/core/all.html b/tests/unit/core/all.html new file mode 100644 index 000000000..0bc9fdb2a --- /dev/null +++ b/tests/unit/core/all.html @@ -0,0 +1,30 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Core Test Suite</title> + + <script src="../../../jquery-1.6.2.js"></script> + + <link rel="stylesheet" href="../../../external/qunit.css"> + <link rel="stylesheet" href="../subsuiteRunner.css"> + <script src="../../../external/qunit.js"></script> + <script src="../subsuiteRunner.js"></script> + <script src="../subsuite.js"></script> + + <script> + testAllVersions( "core" ); + </script> +</head> +<body> + +<h1 id="qunit-header">jQuery UI Core Test Suite</h1> +<h2 id="qunit-banner"></h2> +<div id="qunit-testrunner-toolbar"></div> +<h2 id="qunit-userAgent"></h2> +<ol id="qunit-tests"></ol> +<div id="qunit-fixture"> + +</div> +</body> +</html> diff --git a/tests/unit/core/core.html b/tests/unit/core/core.html index 4c1186271..e2d988806 100644 --- a/tests/unit/core/core.html +++ b/tests/unit/core/core.html @@ -1,26 +1,29 @@ -<!DOCTYPE html> +<!doctype html> <html lang="en"> <head> - <meta charset="UTF-8" /> + <meta charset="utf-8"> <title>jQuery UI Core Test Suite</title> <script src="../../jquery.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - - <link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/> - <script type="text/javascript" src="../../../external/qunit.js"></script> - <script type="text/javascript" src="../../jquery.simulate.js"></script> - <script type="text/javascript" src="../testsuite.js"></script> - - <script type="text/javascript" src="core.js"></script> - <script type="text/javascript" src="selector.js"></script> - - <script type="text/javascript" src="../swarminject.js"></script> - - <style type="text/css"> - .zindex {z-index: 100} - .absolute {position: absolute} + <script src="../../../ui/jquery.ui.core.js"></script> + <script src="../../../ui/jquery.ui.widget.js"></script> + + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> + + <script src="core.js"></script> + <script src="selector.js"></script> + + <script src="../swarminject.js"></script> + <style> + .zindex { + z-index: 100; + } + .absolute { + position: absolute; + } </style> </head> <body> @@ -29,98 +32,99 @@ <h2 id="qunit-banner"></h2> <div id="qunit-testrunner-toolbar"></div> <h2 id="qunit-userAgent"></h2> -<ol id="qunit-tests"> -</ol> - +<ol id="qunit-tests"></ol> <div id="qunit-fixture"> - <img src="../images/jqueryui_32x32.png" usemap="#mymap" width="10", height="10"> - <map name="mymap"> - <area shape="rect" coords="0,0,1,1" id="areaCoordsNoHref"> - <area shape="rect" coords="1,1,2,2" href="foo.html" id="areaCoordsHref"> - <area shape="rect" coords="0,0,0,0" href="foo.html" id="areaCoordsNoSizeHref"> - <area href="foo.html" id="areaNoCoordsHref"> - </map> - <map name="mymap2"> - <area shape="rect" coords="1,1,2,2" href="foo.html" id="areaNoImg"> - </map> - - <div> - <input id="visibleAncestor-inputTypeNone" /> - <input type="text" id="visibleAncestor-inputTypeText" /> - <input type="checkbox" id="visibleAncestor-inputTypeCheckbox" /> - <input type="radio" id="visibleAncestor-inputTypeRadio" /> - <input type="button" id="visibleAncestor-inputTypeButton" /> - <input type="hidden" id="visibleAncestor-inputTypeHidden" /> - <button id="visibleAncestor-button">x</button> - <select id="visibleAncestor-select"> - <option>option</option> - </select> - <textarea id="visibleAncestor-textarea">x</textarea> - <object id="visibleAncestor-object" codebase="about:blank">xxx</object> - <a href="#" id="visibleAncestor-anchorWithHref">anchor</a> - <a id="visibleAncestor-anchorWithoutHref">anchor</a> - <span id="visibleAncestor-span">x</span> - <div id="visibleAncestor-div">x</div> - <span id="visibleAncestor-spanWithTabindex" tabindex="1">x</span> - <div id="visibleAncestor-divWithNegativeTabindex" tabindex="-1">x</div> - </div> - - <div> - <input id="disabledElement-inputTypeNone" disabled="disabled" /> - <input type="text" id="disabledElement-inputTypeText" disabled="disabled" /> - <input type="checkbox" id="disabledElement-inputTypeCheckbox" disabled="disabled" /> - <input type="radio" id="disabledElement-inputTypeRadio" disabled="disabled" /> - <input type="button" id="disabledElement-inputTypeButton" disabled="disabled" /> - <input type="hidden" id="disabledElement-inputTypeHidden" disabled="disabled" /> - <button id="disabledElement-button" disabled="disabled"></button> - <select id="disabledElement-select" disabled="disabled"></select> - <textarea id="disabledElement-textarea" disabled="disabled"></textarea> - </div> - - <div> - <div id="displayNoneAncestor" style="display: none;"> - <input id="displayNoneAncestor-input" /> - <span tabindex="1" id="displayNoneAncestor-span">.</span> - </div> - - <div id="visibilityHiddenAncestor" style="visibility: hidden;"> - <input id="visibilityHiddenAncestor-input" /> - <span tabindex="1" id="visibilityHiddenAncestor-span">.</span> - </div> - - <span tabindex="1" id="displayNone-span" style="display: none;">.</span> - <span tabindex="1" id="visibilityHidden-span" style="visibility: hidden;">.</span> - - <input id="displayNone-input" style="display: none;" /> - <input id="visibilityHidden-input" style="visibility: hidden;" /> - </div> - - <div> - <input id="inputTabindex0" tabindex="0" /> - <input id="inputTabindex10" tabindex="10" /> - <input id="inputTabindex-1" tabindex="-1" /> - <input id="inputTabindex-50" tabindex="-50" /> - - <span id="spanTabindex0" tabindex="0">.</span> - <span id="spanTabindex10" tabindex="10">.</span> - <span id="spanTabindex-1" tabindex="-1">.</span> - <span id="spanTabindex-50" tabindex="-50">.</span> - </div> - - <div id="zIndex100" style="z-index: 100; position: absolute"> - <div id="zIndexAutoWithParent">.</div> - </div> - <div id="zIndex100ViaCSS" class="zindex"> - <div id="zIndexAutoWithParentViaCSS">.</div> +<img src="../images/jqueryui_32x32.png" usemap="#mymap" width="10", height="10"> +<map name="mymap"> + <area shape="rect" coords="0,0,1,1" id="areaCoordsNoHref"> + <area shape="rect" coords="1,1,2,2" href="foo.html" id="areaCoordsHref"> + <area shape="rect" coords="0,0,0,0" href="foo.html" id="areaCoordsNoSizeHref"> + <area href="foo.html" id="areaNoCoordsHref"> +</map> +<map name="mymap2"> + <area shape="rect" coords="1,1,2,2" href="foo.html" id="areaNoImg"> +</map> + +<form id="formNoTabindex"></form> +<form id="formTabindex" tabindex="1"></form> + +<div> + <input id="visibleAncestor-inputTypeNone"> + <input type="text" id="visibleAncestor-inputTypeText"> + <input type="checkbox" id="visibleAncestor-inputTypeCheckbox"> + <input type="radio" id="visibleAncestor-inputTypeRadio"> + <input type="button" id="visibleAncestor-inputTypeButton"> + <input type="hidden" id="visibleAncestor-inputTypeHidden"> + <button id="visibleAncestor-button">x</button> + <select id="visibleAncestor-select"> + <option>option</option> + </select> + <textarea id="visibleAncestor-textarea">x</textarea> + <object id="visibleAncestor-object" codebase="about:blank">xxx</object> + <a href="#" id="visibleAncestor-anchorWithHref">anchor</a> + <a id="visibleAncestor-anchorWithoutHref">anchor</a> + <span id="visibleAncestor-span">x</span> + <div id="visibleAncestor-div">x</div> + <span id="visibleAncestor-spanWithTabindex" tabindex="1">x</span> + <div id="visibleAncestor-divWithNegativeTabindex" tabindex="-1">x</div> +</div> + +<div> + <input id="disabledElement-inputTypeNone" disabled="disabled"> + <input type="text" id="disabledElement-inputTypeText" disabled="disabled"> + <input type="checkbox" id="disabledElement-inputTypeCheckbox" disabled="disabled"> + <input type="radio" id="disabledElement-inputTypeRadio" disabled="disabled"> + <input type="button" id="disabledElement-inputTypeButton" disabled="disabled"> + <input type="hidden" id="disabledElement-inputTypeHidden" disabled="disabled"> + <button id="disabledElement-button" disabled="disabled"></button> + <select id="disabledElement-select" disabled="disabled"></select> + <textarea id="disabledElement-textarea" disabled="disabled"></textarea> +</div> + +<div> + <div id="displayNoneAncestor" style="display: none;"> + <input id="displayNoneAncestor-input"> + <span tabindex="1" id="displayNoneAncestor-span">.</span> </div> - <div id="zIndex100ViaCSSPositioned" class="zindex absolute"> - <div id="zIndexAutoWithParentViaCSSPositioned">.</div> + + <div id="visibilityHiddenAncestor" style="visibility: hidden;"> + <input id="visibilityHiddenAncestor-input"> + <span tabindex="1" id="visibilityHiddenAncestor-span">.</span> </div> - <div id="zIndexAutoNoParent"></div> - - <div id="dimensions" style="float: left; height: 50px; width: 100px; margin: 1px 12px 11px 2px; border-style: solid; border-width: 3px 14px 13px 4px; padding: 5px 16px 15px 6px;"></div> + + <span tabindex="1" id="displayNone-span" style="display: none;">.</span> + <span tabindex="1" id="visibilityHidden-span" style="visibility: hidden;">.</span> + + <input id="displayNone-input" style="display: none;"> + <input id="visibilityHidden-input" style="visibility: hidden;"> +</div> + +<div> + <input id="inputTabindex0" tabindex="0"> + <input id="inputTabindex10" tabindex="10"> + <input id="inputTabindex-1" tabindex="-1"> + <input id="inputTabindex-50" tabindex="-50"> + + <span id="spanTabindex0" tabindex="0">.</span> + <span id="spanTabindex10" tabindex="10">.</span> + <span id="spanTabindex-1" tabindex="-1">.</span> + <span id="spanTabindex-50" tabindex="-50">.</span> </div> +<div id="zIndex100" style="z-index: 100; position: absolute"> + <div id="zIndexAutoWithParent">.</div> +</div> +<div id="zIndex100ViaCSS" class="zindex"> + <div id="zIndexAutoWithParentViaCSS">.</div> +</div> +<div id="zIndex100ViaCSSPositioned" class="zindex absolute"> + <div id="zIndexAutoWithParentViaCSSPositioned">.</div> +</div> +<div id="zIndexAutoNoParent"></div> + +<div id="dimensions" style="float: left; height: 50px; width: 100px; margin: 1px 12px 11px 2px; border-style: solid; border-width: 3px 14px 13px 4px; padding: 5px 16px 15px 6px;"></div> + +</div> </body> </html> diff --git a/tests/unit/core/selector.js b/tests/unit/core/selector.js index 44888ad88..2fb78025c 100644 --- a/tests/unit/core/selector.js +++ b/tests/unit/core/selector.js @@ -32,55 +32,57 @@ test("data", function() { ok(!el.is(':data(test)'), msg); } - el = $('<div/>'); + el = $('<div>'); shouldNotHaveData('data never set'); - el = $('<div/>').data('test', null); + el = $('<div>').data('test', null); shouldNotHaveData('data is null'); - el = $('<div/>').data('test', true); + el = $('<div>').data('test', true); shouldHaveData('data set to true'); - el = $('<div/>').data('test', false); + el = $('<div>').data('test', false); shouldNotHaveData('data set to false'); - el = $('<div/>').data('test', 0); + el = $('<div>').data('test', 0); shouldNotHaveData('data set to 0'); - el = $('<div/>').data('test', 1); + el = $('<div>').data('test', 1); shouldHaveData('data set to 1'); - el = $('<div/>').data('test', ''); + el = $('<div>').data('test', ''); shouldNotHaveData('data set to empty string'); - el = $('<div/>').data('test', 'foo'); + el = $('<div>').data('test', 'foo'); shouldHaveData('data set to string'); - el = $('<div/>').data('test', []); + el = $('<div>').data('test', []); shouldHaveData('data set to empty array'); - el = $('<div/>').data('test', [1]); + el = $('<div>').data('test', [1]); shouldHaveData('data set to array'); - el = $('<div/>').data('test', {}); + el = $('<div>').data('test', {}); shouldHaveData('data set to empty object'); - el = $('<div/>').data('test', {foo: 'bar'}); + el = $('<div>').data('test', {foo: 'bar'}); shouldHaveData('data set to object'); - el = $('<div/>').data('test', new Date()); + el = $('<div>').data('test', new Date()); shouldHaveData('data set to date'); - el = $('<div/>').data('test', /test/); + el = $('<div>').data('test', /test/); shouldHaveData('data set to regexp'); - el = $('<div/>').data('test', function() {}); + el = $('<div>').data('test', function() {}); shouldHaveData('data set to function'); }); test("focusable - visible, enabled elements", function() { - expect(16); + expect(18); + isNotFocusable('#formNoTabindex', 'form'); + isFocusable('#formTabindex', 'form with tabindex'); isFocusable('#visibleAncestor-inputTypeNone', 'input, no type'); isFocusable('#visibleAncestor-inputTypeText', 'input, type text'); isFocusable('#visibleAncestor-inputTypeCheckbox', 'input, type checkbox'); @@ -156,8 +158,10 @@ test("focusable - area elements", function() { }); test("tabbable - visible, enabled elements", function() { - expect(16); + expect(18); + isNotTabbable('#formNoTabindex', 'form'); + isTabbable('#formTabindex', 'form with tabindex'); isTabbable('#visibleAncestor-inputTypeNone', 'input, no type'); isTabbable('#visibleAncestor-inputTypeText', 'input, type text'); isTabbable('#visibleAncestor-inputTypeCheckbox', 'input, type checkbox'); diff --git a/tests/unit/datepicker/all.html b/tests/unit/datepicker/all.html new file mode 100644 index 000000000..0891de88c --- /dev/null +++ b/tests/unit/datepicker/all.html @@ -0,0 +1,30 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Datepicker Test Suite</title> + + <script src="../../../jquery-1.6.2.js"></script> + + <link rel="stylesheet" href="../../../external/qunit.css"> + <link rel="stylesheet" href="../subsuiteRunner.css"> + <script src="../../../external/qunit.js"></script> + <script src="../subsuiteRunner.js"></script> + <script src="../subsuite.js"></script> + + <script> + testAllVersions( "datepicker" ); + </script> +</head> +<body> + +<h1 id="qunit-header">jQuery UI Datepicker Test Suite</h1> +<h2 id="qunit-banner"></h2> +<div id="qunit-testrunner-toolbar"></div> +<h2 id="qunit-userAgent"></h2> +<ol id="qunit-tests"></ol> +<div id="qunit-fixture"> + +</div> +</body> +</html> diff --git a/tests/unit/datepicker/datepicker.html b/tests/unit/datepicker/datepicker.html index 51b61f603..108023372 100644 --- a/tests/unit/datepicker/datepicker.html +++ b/tests/unit/datepicker/datepicker.html @@ -1,32 +1,33 @@ -<!DOCTYPE html> +<!doctype html> <html lang="en"> <head> - <meta charset="UTF-8" /> + <meta charset="utf-8"> <title>jQuery UI Datepicker Test Suite</title> - <link type="text/css" href="../../../themes/base/jquery.ui.datepicker.css" rel="stylesheet" /> + <link rel="stylesheet" href="../../../themes/base/jquery.ui.core.css"> + <link rel="stylesheet" href="../../../themes/base/jquery.ui.datepicker.css"> <script src="../../jquery.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.datepicker.js"></script> - <script type="text/javascript" src="../../../ui/i18n/jquery.ui.datepicker-fr.js"></script> - <script type="text/javascript" src="../../../ui/i18n/jquery.ui.datepicker-he.js"></script> - <script type="text/javascript" src="../../../ui/i18n/jquery.ui.datepicker-zh-CN.js"></script> - - <link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/> - <script type="text/javascript" src="../../../external/qunit.js"></script> - <script type="text/javascript" src="../../jquery.simulate.js"></script> - <script type="text/javascript" src="../testsuite.js"></script> - - <script type="text/javascript" src="datepicker_core.js"></script> - <script type="text/javascript" src="datepicker_defaults.js"></script> - <script type="text/javascript" src="datepicker_events.js"></script> - <script type="text/javascript" src="datepicker_methods.js"></script> - <script type="text/javascript" src="datepicker_options.js"></script> - <script type="text/javascript" src="datepicker_tickets.js"></script> - - <script type="text/javascript"> + <script src="../../../ui/jquery.ui.core.js"></script> + <script src="../../../ui/jquery.ui.widget.js"></script> + <script src="../../../ui/jquery.ui.datepicker.js"></script> + <script src="../../../ui/i18n/jquery.ui.datepicker-fr.js"></script> + <script src="../../../ui/i18n/jquery.ui.datepicker-he.js"></script> + <script src="../../../ui/i18n/jquery.ui.datepicker-zh-CN.js"></script> + + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> + + <script src="datepicker_core.js"></script> + <script src="datepicker_defaults.js"></script> + <script src="datepicker_events.js"></script> + <script src="datepicker_methods.js"></script> + <script src="datepicker_options.js"></script> + <script src="datepicker_tickets.js"></script> + + <script> // disable this stale testsuite for testswarm only var url = window.location.search; url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + 9 ) ); @@ -36,7 +37,7 @@ test("datepicker", function() { ok(true, "disabled datepicker testsuite"); }); } </script> - <script type="text/javascript" src="../swarminject.js"></script> + <script src="../swarminject.js"></script> </head> <body> @@ -44,13 +45,12 @@ <h2 id="qunit-banner"></h2> <div id="qunit-testrunner-toolbar"></div> <h2 id="qunit-userAgent"></h2> -<ol id="qunit-tests"> -</ol> - +<ol id="qunit-tests"></ol> <div id="qunit-fixture"> - <p><input type="text" id="inp"/><input type="text" id="alt"/><div id="inl"></div></p> - <p><input type="text" id="inp2"/></p> -</div> +<div><input type="text" id="inp"><input type="text" id="alt"><div id="inl"></div></div> +<p><input type="text" id="inp2"></p> + +</div> </body> </html> diff --git a/tests/unit/datepicker/datepicker_options.js b/tests/unit/datepicker/datepicker_options.js index 0a3d5cdac..272af9dac 100644 --- a/tests/unit/datepicker/datepicker_options.js +++ b/tests/unit/datepicker/datepicker_options.js @@ -469,16 +469,6 @@ test('setDate', function() { var dateAndTimeClone = new Date(2008, 3 - 1, 28, 1, 11, 0); inp.datepicker('setDate', dateAndTimeToSet); equals(dateAndTimeToSet.getTime(), dateAndTimeClone.getTime(), 'Date object passed should not be changed by setDate'); - // Test onSelect callback is executed when using setDate - inp.datepicker('destroy'); - var testDate = null; - inp.datepicker({ - onSelect: function(dateText, inst) { - testDate = new Date(dateText); - } - }); - inp.datepicker('setDate', date2); - equals(date2.getTime(), testDate.getTime(), 'onSelect is called after setDate'); }); test('altField', function() { diff --git a/tests/unit/datepicker/datepicker_tickets.js b/tests/unit/datepicker/datepicker_tickets.js index 10647eb13..353426625 100644 --- a/tests/unit/datepicker/datepicker_tickets.js +++ b/tests/unit/datepicker/datepicker_tickets.js @@ -24,6 +24,39 @@ test('beforeShowDay-getDate', function() { inp.datepicker('hide'); }); +test('Ticket 7602: Stop datepicker from appearing with beforeShow event handler', function(){ + var inp = init('#inp',{ + beforeShow: function(){ + return false; + } + }); + var dp = $('#ui-datepicker-div'); + inp.datepicker('show'); + equals(dp.css('display'), 'none',"beforeShow returns false"); + inp.datepicker('destroy'); + + inp = init('#inp',{ + beforeShow: function(){ + } + }); + dp = $('#ui-datepicker-div'); + inp.datepicker('show'); + equal(dp.css('display'), 'block',"beforeShow returns nothing"); + inp.datepicker('hide'); + inp.datepicker('destroy'); + + inp = init('#inp',{ + beforeShow: function(){ + return true; + } + }); + dp = $('#ui-datepicker-div'); + inp.datepicker('show'); + equal(dp.css('display'), 'block',"beforeShow returns true"); + inp.datepicker('hide'); + inp.datepicker('destroy'); +}); + test('Ticket 6827: formatDate day of year calculation is wrong during day lights savings time', function(){ var time = $.datepicker.formatDate("oo", new Date("2010/03/30 12:00:00 CDT")); equals(time, "089"); diff --git a/tests/unit/dialog/all.html b/tests/unit/dialog/all.html new file mode 100644 index 000000000..8aed4c05e --- /dev/null +++ b/tests/unit/dialog/all.html @@ -0,0 +1,30 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Dialog Test Suite</title> + + <script src="../../../jquery-1.6.2.js"></script> + + <link rel="stylesheet" href="../../../external/qunit.css"> + <link rel="stylesheet" href="../subsuiteRunner.css"> + <script src="../../../external/qunit.js"></script> + <script src="../subsuiteRunner.js"></script> + <script src="../subsuite.js"></script> + + <script> + testAllVersions( "dialog" ); + </script> +</head> +<body> + +<h1 id="qunit-header">jQuery UI Dialog Test Suite</h1> +<h2 id="qunit-banner"></h2> +<div id="qunit-testrunner-toolbar"></div> +<h2 id="qunit-userAgent"></h2> +<ol id="qunit-tests"></ol> +<div id="qunit-fixture"> + +</div> +</body> +</html> diff --git a/tests/unit/dialog/dialog.html b/tests/unit/dialog/dialog.html index 1840e2c4a..b35ae5823 100644 --- a/tests/unit/dialog/dialog.html +++ b/tests/unit/dialog/dialog.html @@ -1,34 +1,35 @@ -<!DOCTYPE html> +<!doctype html> <html lang="en"> <head> - <meta charset="UTF-8" /> + <meta charset="utf-8"> <title>jQuery UI Dialog Test Suite</title> - <link type="text/css" href="../../../themes/base/jquery.ui.dialog.css" rel="stylesheet" /> + <link rel="stylesheet" href="../../../themes/base/jquery.ui.core.css"> + <link rel="stylesheet" href="../../../themes/base/jquery.ui.dialog.css"> <script src="../../jquery.js"></script> - <script type="text/javascript" src="../../../external/jquery.bgiframe-2.1.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.draggable.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.position.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.resizable.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.dialog.js"></script> + <script src="../../../external/jquery.bgiframe-2.1.2.js"></script> + <script src="../../../ui/jquery.ui.core.js"></script> + <script src="../../../ui/jquery.ui.widget.js"></script> + <script src="../../../ui/jquery.ui.mouse.js"></script> + <script src="../../../ui/jquery.ui.draggable.js"></script> + <script src="../../../ui/jquery.ui.position.js"></script> + <script src="../../../ui/jquery.ui.resizable.js"></script> + <script src="../../../ui/jquery.ui.dialog.js"></script> - <link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/> - <script type="text/javascript" src="../../../external/qunit.js"></script> - <script type="text/javascript" src="../../jquery.simulate.js"></script> - <script type="text/javascript" src="../testsuite.js"></script> - - <script type="text/javascript" src="dialog_core.js"></script> - <script type="text/javascript" src="dialog_defaults.js"></script> - <script type="text/javascript" src="dialog_events.js"></script> - <script type="text/javascript" src="dialog_methods.js"></script> - <script type="text/javascript" src="dialog_options.js"></script> - <script type="text/javascript" src="dialog_tickets.js"></script> - - <script type="text/javascript"> + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> + + <script src="dialog_core.js"></script> + <script src="dialog_defaults.js"></script> + <script src="dialog_events.js"></script> + <script src="dialog_methods.js"></script> + <script src="dialog_options.js"></script> + <script src="dialog_tickets.js"></script> + + <script> // disable this testsuite for testswarm only - until we fix it from freezing IE6 var url = window.location.search; url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + 9 ) ); @@ -38,8 +39,7 @@ test("dialog", function() { ok(true, "disabled dialog testsuite"); }); } </script> - - <script type="text/javascript" src="../swarminject.js"></script> + <script src="../swarminject.js"></script> </head> <body> @@ -47,11 +47,9 @@ <h2 id="qunit-banner"></h2> <div id="qunit-testrunner-toolbar"></div> <h2 id="qunit-userAgent"></h2> -<ol id="qunit-tests"> -</ol> - +<ol id="qunit-tests"></ol> <div id="qunit-fixture"> -</div> +</div> </body> </html> diff --git a/tests/unit/dialog/dialog_core.js b/tests/unit/dialog/dialog_core.js index aec3e22be..2003689e9 100644 --- a/tests/unit/dialog/dialog_core.js +++ b/tests/unit/dialog/dialog_core.js @@ -106,7 +106,7 @@ test("title id", function() { equals(titleId, 'ui-dialog-title-2', 'auto-numbered title id'); el.remove(); - el = $('<div id="foo"/>').dialog(); + el = $('<div id="foo">').dialog(); titleId = dlg().find('.ui-dialog-title').attr('id'); equals(titleId, 'ui-dialog-title-foo', 'carried over title id'); el.remove(); @@ -131,7 +131,7 @@ test("ARIA", function() { }); test("widget method", function() { - var dialog = $("<div/>").appendTo("#main").dialog(); + var dialog = $("<div>").appendTo("#main").dialog(); same(dialog.parent()[0], dialog.dialog("widget")[0]); }); diff --git a/tests/unit/dialog/dialog_options.js b/tests/unit/dialog/dialog_options.js index 5705da079..eab577c69 100644 --- a/tests/unit/dialog/dialog_options.js +++ b/tests/unit/dialog/dialog_options.js @@ -407,7 +407,7 @@ test("title", function() { equals(el.dialog("option", "title"), "", "option not changed"); el.remove(); - el = $('<div title="foo"/>').dialog(); + el = $('<div title="foo">').dialog(); equals(titleText(), "foo", "title in element attribute"); equals(el.dialog("option", "title"), "foo", "option updated from attribute"); el.remove(); @@ -417,7 +417,7 @@ test("title", function() { equals(el.dialog("option", "title"), "foo", "opiton set from options hash"); el.remove(); - el = $('<div title="foo"/>').dialog({ title: 'bar' }); + el = $('<div title="foo">').dialog({ title: 'bar' }); equals(titleText(), "bar", "title in init options should override title in element attribute"); equals(el.dialog("option", "title"), "bar", "opiton set from options hash"); el.remove(); diff --git a/tests/unit/dialog/dialog_tickets.js b/tests/unit/dialog/dialog_tickets.js index 1cfdcefea..b203ca7d5 100644 --- a/tests/unit/dialog/dialog_tickets.js +++ b/tests/unit/dialog/dialog_tickets.js @@ -3,7 +3,36 @@ */ (function($) { -module("dialog: tickets"); +module( "dialog: tickets" ); + +asyncTest( "#3123: Prevent tabbing out of modal dialogs", function() { + expect( 3 ); + + var el = $( "<div><input id='t3123-first'><input id='t3123-last'></div>" ).dialog({ modal: true }), + inputs = el.find( "input" ), + widget = el.dialog( "widget" ); + + inputs.eq( 1 ).focus(); + equal( document.activeElement, inputs[1], "Focus set on second input" ); + inputs.eq( 1 ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB }); + + setTimeout( checkTab, 2 ); + + function checkTab() { + ok( $.contains( widget, document.activeElement ), "Tab key event moved focus within the modal" ); + + // check shift tab + $( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB, shiftKey: true }); + setTimeout( checkShiftTab, 2 ); + } + + function checkShiftTab() { + ok( $.contains( widget, document.activeElement ), "Shift-Tab key event moved focus within the modal" ); + + el.remove(); + start(); + } +}); test("#4826: setting resizable false toggles resizable on dialog", function() { expect(6); diff --git a/tests/unit/draggable/all.html b/tests/unit/draggable/all.html new file mode 100644 index 000000000..8f6279eb9 --- /dev/null +++ b/tests/unit/draggable/all.html @@ -0,0 +1,30 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Draggable Test Suite</title> + + <script src="../../../jquery-1.6.2.js"></script> + + <link rel="stylesheet" href="../../../external/qunit.css"> + <link rel="stylesheet" href="../subsuiteRunner.css"> + <script src="../../../external/qunit.js"></script> + <script src="../subsuiteRunner.js"></script> + <script src="../subsuite.js"></script> + + <script> + testAllVersions( "draggable" ); + </script> +</head> +<body> + +<h1 id="qunit-header">jQuery UI Draggable Test Suite</h1> +<h2 id="qunit-banner"></h2> +<div id="qunit-testrunner-toolbar"></div> +<h2 id="qunit-userAgent"></h2> +<ol id="qunit-tests"></ol> +<div id="qunit-fixture"> + +</div> +</body> +</html> diff --git a/tests/unit/draggable/draggable.html b/tests/unit/draggable/draggable.html index f9d3ee7a9..e5006bf17 100644 --- a/tests/unit/draggable/draggable.html +++ b/tests/unit/draggable/draggable.html @@ -1,27 +1,27 @@ -<!DOCTYPE html> +<!doctype html> <html lang="en"> <head> - <meta charset="UTF-8" /> + <meta charset="utf-8"> <title>jQuery UI Draggable Test Suite</title> <script src="../../jquery.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.draggable.js"></script> + <script src="../../../ui/jquery.ui.core.js"></script> + <script src="../../../ui/jquery.ui.widget.js"></script> + <script src="../../../ui/jquery.ui.mouse.js"></script> + <script src="../../../ui/jquery.ui.draggable.js"></script> - <link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/> - <script type="text/javascript" src="../../../external/qunit.js"></script> - <script type="text/javascript" src="../../jquery.simulate.js"></script> - <script type="text/javascript" src="../testsuite.js"></script> + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> - <script type="text/javascript" src="draggable_core.js"></script> - <script type="text/javascript" src="draggable_defaults.js"></script> - <script type="text/javascript" src="draggable_events.js"></script> - <script type="text/javascript" src="draggable_methods.js"></script> - <script type="text/javascript" src="draggable_options.js"></script> - - <script type="text/javascript"> + <script src="draggable_core.js"></script> + <script src="draggable_defaults.js"></script> + <script src="draggable_events.js"></script> + <script src="draggable_methods.js"></script> + <script src="draggable_options.js"></script> + + <script> // disable this stale testsuite for testswarm only var url = window.location.search; url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + 9 ) ); @@ -31,7 +31,7 @@ test("draggable", function() { ok(true, "disabled draggable testsuite"); }); } </script> - <script type="text/javascript" src="../swarminject.js"></script> + <script src="../swarminject.js"></script> </head> <body> @@ -39,15 +39,14 @@ <h2 id="qunit-banner"></h2> <div id="qunit-testrunner-toolbar"></div> <h2 id="qunit-userAgent"></h2> -<ol id="qunit-tests"> -</ol> - +<ol id="qunit-tests"></ol> <div id="qunit-fixture"> - <div id="draggable1" style="background: green; width: 200px; height: 100px;">Relative</div> - <div id="draggable2" style="background: green; width: 200px; height: 100px; position: absolute; top: 10px; left: 10px;"><span>Absolute</span></div> - <div style='width: 1px; height: 1000px;'></div> - <div style="position: absolute; width: 1px; height: 2000px;"></div> -</div> +<div id="draggable1" style="background: green; width: 200px; height: 100px;">Relative</div> +<div id="draggable2" style="background: green; width: 200px; height: 100px; position: absolute; top: 10px; left: 10px;"><span>Absolute</span></div> +<div style='width: 1px; height: 1000px;'></div> +<div style="position: absolute; width: 1px; height: 2000px;"></div> + +</div> </body> </html> diff --git a/tests/unit/droppable/all.html b/tests/unit/droppable/all.html new file mode 100644 index 000000000..5296b3cfe --- /dev/null +++ b/tests/unit/droppable/all.html @@ -0,0 +1,30 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Droppable Test Suite</title> + + <script src="../../../jquery-1.6.2.js"></script> + + <link rel="stylesheet" href="../../../external/qunit.css"> + <link rel="stylesheet" href="../subsuiteRunner.css"> + <script src="../../../external/qunit.js"></script> + <script src="../subsuiteRunner.js"></script> + <script src="../subsuite.js"></script> + + <script> + testAllVersions( "droppable" ); + </script> +</head> +<body> + +<h1 id="qunit-header">jQuery UI Droppable Test Suite</h1> +<h2 id="qunit-banner"></h2> +<div id="qunit-testrunner-toolbar"></div> +<h2 id="qunit-userAgent"></h2> +<ol id="qunit-tests"></ol> +<div id="qunit-fixture"> + +</div> +</body> +</html> diff --git a/tests/unit/droppable/droppable.html b/tests/unit/droppable/droppable.html index 80edfa4b0..149430bcf 100644 --- a/tests/unit/droppable/droppable.html +++ b/tests/unit/droppable/droppable.html @@ -1,28 +1,28 @@ -<!DOCTYPE html> +<!doctype html> <html lang="en"> <head> - <meta charset="UTF-8" /> + <meta charset="utf-8"> <title>jQuery UI Droppable Test Suite</title> <script src="../../jquery.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.draggable.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.droppable.js"></script> + <script src="../../../ui/jquery.ui.core.js"></script> + <script src="../../../ui/jquery.ui.widget.js"></script> + <script src="../../../ui/jquery.ui.mouse.js"></script> + <script src="../../../ui/jquery.ui.draggable.js"></script> + <script src="../../../ui/jquery.ui.droppable.js"></script> - <link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/> - <script type="text/javascript" src="../../../external/qunit.js"></script> - <script type="text/javascript" src="../../jquery.simulate.js"></script> - <script type="text/javascript" src="../testsuite.js"></script> - - <script type="text/javascript" src="droppable_core.js"></script> - <script type="text/javascript" src="droppable_defaults.js"></script> - <script type="text/javascript" src="droppable_events.js"></script> - <script type="text/javascript" src="droppable_methods.js"></script> - <script type="text/javascript" src="droppable_options.js"></script> - - <script type="text/javascript"> + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> + + <script src="droppable_core.js"></script> + <script src="droppable_defaults.js"></script> + <script src="droppable_events.js"></script> + <script src="droppable_methods.js"></script> + <script src="droppable_options.js"></script> + + <script> // disable this stale testsuite for testswarm only var url = window.location.search; url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + 9 ) ); @@ -32,7 +32,7 @@ test("droppable", function() { ok(true, "disabled droppable testsuite"); }); } </script> - <script type="text/javascript" src="../swarminject.js"></script> + <script src="../swarminject.js"></script> </head> <body> @@ -40,14 +40,13 @@ <h2 id="qunit-banner"></h2> <div id="qunit-testrunner-toolbar"></div> <h2 id="qunit-userAgent"></h2> -<ol id="qunit-tests"> -</ol> - +<ol id="qunit-tests"></ol> <div id="qunit-fixture"> - <div id="draggable1" style="width: 25px; height: 25px;">Draggable</div> - <div id="droppable1" style="width: 100px; height: 100px;">Droppable</div> - <div style='width:1000px;height:1000px;'> </div> -</div> +<div id="draggable1" style="width: 25px; height: 25px;">Draggable</div> +<div id="droppable1" style="width: 100px; height: 100px;">Droppable</div> +<div style='width:1000px;height:1000px;'> </div> + +</div> </body> </html> diff --git a/tests/unit/effects/all.html b/tests/unit/effects/all.html new file mode 100644 index 000000000..6a9617ba4 --- /dev/null +++ b/tests/unit/effects/all.html @@ -0,0 +1,30 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Effects Test Suite</title> + + <script src="../../../jquery-1.6.2.js"></script> + + <link rel="stylesheet" href="../../../external/qunit.css"> + <link rel="stylesheet" href="../subsuiteRunner.css"> + <script src="../../../external/qunit.js"></script> + <script src="../subsuiteRunner.js"></script> + <script src="../subsuite.js"></script> + + <script> + testAllVersions( "effects" ); + </script> +</head> +<body> + +<h1 id="qunit-header">jQuery UI Effects Test Suite</h1> +<h2 id="qunit-banner"></h2> +<div id="qunit-testrunner-toolbar"></div> +<h2 id="qunit-userAgent"></h2> +<ol id="qunit-tests"></ol> +<div id="qunit-fixture"> + +</div> +</body> +</html> diff --git a/tests/unit/effects/effects.html b/tests/unit/effects/effects.html index 3068aedc3..f2c447ef7 100644 --- a/tests/unit/effects/effects.html +++ b/tests/unit/effects/effects.html @@ -2,7 +2,7 @@ <html lang="en"> <head> <meta charset="utf-8"> - <title>jQuery UI Core Test Suite</title> + <title>jQuery UI Effects Test Suite</title> <script src="../../jquery.js"></script> <script> @@ -31,8 +31,7 @@ <script src="effects_scale.js"></script> <script src="../swarminject.js"></script> - - <style type="text/css"> + <style> #qunit-fixture { width: 1000px; height: 1000px; @@ -84,20 +83,18 @@ <h2 id="qunit-banner"></h2> <div id="qunit-testrunner-toolbar"></div> <h2 id="qunit-userAgent"></h2> -<ol id="qunit-tests"> -</ol> - +<ol id="qunit-tests"></ol> <div id="qunit-fixture"> - <div class="hidden test"></div> - <div class="animateClass test"> - <h2>Child Element Test</h2> - </div> - <div class="relWidth relHeight testAddBorder"> - <h2>Slide with relative width</d2> - </div> - <div class="testScale"> - </div> +<div class="hidden test"></div> +<div class="animateClass test"> + <h2>Child Element Test</h2> +</div> +<div class="relWidth relHeight testAddBorder"> + <h2>Slide with relative width</h2> +</div> +<div class="testScale"> </div> +</div> </body> </html> diff --git a/tests/unit/effects/effects_core.js b/tests/unit/effects/effects_core.js index 7c20e22fe..2b4d684eb 100644 --- a/tests/unit/effects/effects_core.js +++ b/tests/unit/effects/effects_core.js @@ -150,4 +150,15 @@ asyncTest( "animateClass clears style properties when stopped", function() { start(); }); +test( "createWrapper and removeWrapper retain focused elements (#7595)", function() { + expect( 2 ); + var test = $( "div.hidden" ).show(), + input = $( "<input>" ).appendTo( test ).focus(); + + $.effects.createWrapper( test ); + equal( document.activeElement, input[ 0 ], "Active element is still input after createWrapper" ); + $.effects.removeWrapper( test ); + equal( document.activeElement, input[ 0 ], "Active element is still input after removeWrapper" ); +}) + })(jQuery); diff --git a/tests/unit/index.html b/tests/unit/index.html index 5282d3f27..b73ede29c 100644 --- a/tests/unit/index.html +++ b/tests/unit/index.html @@ -1,69 +1,96 @@ -<!DOCTYPE html> +<!doctype html> <html lang="en"> <head> - <meta charset="UTF-8" /> + <meta charset="utf-8"> <title>jQuery UI Unit Tests</title> - <link type="text/css" href="../../themes/base/jquery.ui.base.css" rel="stylesheet" /> - <link rel="stylesheet" href="../../external/qunit.css" type="text/css"/> - <style type="text/css"> - ul { font-family: 'trebuchet ms', verdana, arial; } - h2, ul {font-size: 10pt; } - h2 { - background-color:#EEEEEE; - color:black; - font-size:small; - font-weight:normal; - margin:0; - padding:10px; + <link rel="stylesheet" href="../../themes/base/jquery.ui.core.css"> + <link rel="stylesheet" href="../../themes/base/jquery.ui.theme.css"> + <style> + body { + font-size: 62.5%; + } + .ui-widget-header { + padding: 0.2em 0.5em; + margin: 0; + } + .ui-widget-content { + padding: 1em; + margin-bottom: 1em; + } + ul { + margin: 0; + list-style: none; + } + li { + line-height: 2em; } </style> + <script src="../jquery.js"></script> + <script> + $(function() { + $( "#main" ) + .addClass( "ui-widget" ) + .find( "h1, h2" ) + .addClass( "ui-widget-header ui-corner-top" ) + .next() + .addClass( "ui-widget-content ui-corner-bottom" ); + + }); + </script> </head> <body> -<h1 id="qunit-header">jQuery UI Unit Tests</h1> +<div id="main"> + <h1>jQuery UI Unit Tests</h1> + <div> + <h2>Full Test Suite</h2> + <ul> + <li><a href="all.html">All</a></li> + </ul> -<h2>Core</h2> -<ul> - <li><a href="core/core.html">Core</a></li> - <li><a href="widget/widget.html">Widget</a></li> -</ul> + <h2>Core</h2> + <ul> + <li><a href="core/core.html">Core</a></li> + <li><a href="widget/widget.html">Widget</a></li> + </ul> -<h2>Interactions</h2> -<ul> - <li><a href="draggable/draggable.html">Draggable</a></li> - <li><a href="droppable/droppable.html">Droppable</a></li> - <li><a href="resizable/resizable.html">Resizable</a></li> - <li><a href="selectable/selectable.html">Selectable</a></li> - <li><a href="sortable/sortable.html">Sortable</a></li> -</ul> + <h2>Interactions</h2> + <ul> + <li><a href="draggable/draggable.html">Draggable</a></li> + <li><a href="droppable/droppable.html">Droppable</a></li> + <li><a href="resizable/resizable.html">Resizable</a></li> + <li><a href="selectable/selectable.html">Selectable</a></li> + <li><a href="sortable/sortable.html">Sortable</a></li> + </ul> -<h2>Widgets</h2> -<ul> - <li><a href="accordion/accordion.html">Accordion</a></li> - <li><a href="autocomplete/autocomplete.html">Autocomplete</a></li> - <li><a href="button/button.html">Button</a></li> - <li><a href="datepicker/datepicker.html">Datepicker</a></li> - <li><a href="dialog/dialog.html">Dialog</a></li> - <li><a href="menu/menu.html">Menu</a></li> - <li><a href="progressbar/progressbar.html">Progressbar</a></li> - <li><a href="slider/slider.html">Slider</a></li> - <li><a href="spinner/spinner.html">Spinner</a></li> - <li><a href="tabs/tabs.html">Tabs</a></li> - <li><a href="tooltip/tooltip.html">Tooltip</a></li> -</ul> + <h2>Widgets</h2> + <ul> + <li><a href="accordion/accordion.html">Accordion</a></li> + <li><a href="autocomplete/autocomplete.html">Autocomplete</a></li> + <li><a href="button/button.html">Button</a></li> + <li><a href="datepicker/datepicker.html">Datepicker</a></li> + <li><a href="dialog/dialog.html">Dialog</a></li> + <li><a href="menu/menu.html">Menu</a></li> + <li><a href="progressbar/progressbar.html">Progressbar</a></li> + <li><a href="slider/slider.html">Slider</a></li> + <li><a href="spinner/spinner.html">Spinner</a></li> + <li><a href="tabs/tabs.html">Tabs</a></li> + <li><a href="tooltip/tooltip.html">Tooltip</a></li> + </ul> -<h2>Utilities</h2> -<ul> - <li><a href="position/position.html">Position</a></li> -</ul> + <h2>Utilities</h2> + <ul> + <li><a href="position/position.html">Position</a></li> + </ul> -<h2>Effects</h2> -<ul> - <li><a href="effects/effects.html">Effects</a></li> -</ul> + <h2>Effects</h2> + <ul> + <li><a href="effects/effects.html">Effects</a></li> + </ul> + </div> +</div> </body> - </html> diff --git a/tests/unit/menu/all.html b/tests/unit/menu/all.html new file mode 100644 index 000000000..399614254 --- /dev/null +++ b/tests/unit/menu/all.html @@ -0,0 +1,30 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Menu Test Suite</title> + + <script src="../../../jquery-1.6.2.js"></script> + + <link rel="stylesheet" href="../../../external/qunit.css"> + <link rel="stylesheet" href="../subsuiteRunner.css"> + <script src="../../../external/qunit.js"></script> + <script src="../subsuiteRunner.js"></script> + <script src="../subsuite.js"></script> + + <script> + testAllVersions( "menu" ); + </script> +</head> +<body> + +<h1 id="qunit-header">jQuery UI Menu Test Suite</h1> +<h2 id="qunit-banner"></h2> +<div id="qunit-testrunner-toolbar"></div> +<h2 id="qunit-userAgent"></h2> +<ol id="qunit-tests"></ol> +<div id="qunit-fixture"> + +</div> +</body> +</html> diff --git a/tests/unit/menu/menu.html b/tests/unit/menu/menu.html index e1f79b0f9..dc5b71a00 100644 --- a/tests/unit/menu/menu.html +++ b/tests/unit/menu/menu.html @@ -1,52 +1,41 @@ -<!DOCTYPE html> +<!doctype html> <html lang="en"> <head> - <meta charset="UTF-8" /> + <meta charset="utf-8"> <title>jQuery UI Menu Test Suite</title> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css" title="ui-theme" /> + <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css"> <script src="../../jquery.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.menu.js"></script> - - <link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/> - <script type="text/javascript" src="../../../external/qunit.js"></script> - <script type="text/javascript" src="../../jquery.simulate.js"></script> - <script type="text/javascript" src="../testsuite.js"></script> - - <script type="text/javascript"> - - function log(message,clear) { - if (clear && clear === true) { - $("#log").html(""); - } - if ( message === undefined ) { - message = $("#log").data("lastItem"); - } - $("#log").prepend( message + "," ); - } - function clickMenu(menu,item) { - $("#log").data("lastItem",item); - $('li:eq(' + item + ') a',menu).trigger("click"); - } - - - </script> - <script type="text/javascript" src="menu_core.js"></script> - <script type="text/javascript" src="menu_defaults.js"></script> - <script type="text/javascript" src="menu_events.js"></script> - <script type="text/javascript" src="menu_methods.js"></script> - <script type="text/javascript" src="menu_options.js"></script> - - <script type="text/javascript" src="../swarminject.js"></script> - + <script src="../../../ui/jquery.ui.core.js"></script> + <script src="../../../ui/jquery.ui.widget.js"></script> + <script src="../../../ui/jquery.ui.menu.js"></script> + + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> + + <script src="menu_test_helpers.js"></script> + <script src="menu_core.js"></script> + <script src="menu_defaults.js"></script> + <script src="menu_events.js"></script> + <script src="menu_methods.js"></script> + <script src="menu_options.js"></script> + + <script src="../swarminject.js"></script> <style> - #qunit-fixture { font-size: 10pt; font-family: 'trebuchet ms', verdana, arial; } - #list, #list1 *, #navigation, #navigation * { margin: 0; padding: 0; font-size: 12px; } - #menu3 { height: 250px; overflow: auto; } - #menu4, #menu4 ul { height: 250px; overflow: auto; } + .ui-menu { + font-size: 15px; + } + #menu3 { + height: 250px; + overflow: auto; + } + #menu4, #menu4 ul { + height: 250px; + overflow: auto; + } </style> </head> <body> @@ -55,10 +44,7 @@ <h2 id="qunit-banner"></h2> <div id="qunit-testrunner-toolbar"></div> <h2 id="qunit-userAgent"></h2> -<ol id="qunit-tests"> -</ol> - - +<ol id="qunit-tests"></ol> <div id="qunit-fixture"> <ul class="foo" id="menu1"> @@ -224,6 +210,5 @@ <div id="log"></div> </div> - </body> </html> diff --git a/tests/unit/menu/menu_events.js b/tests/unit/menu/menu_events.js index ab691b782..563ed7c2d 100644 --- a/tests/unit/menu/menu_events.js +++ b/tests/unit/menu/menu_events.js @@ -9,15 +9,15 @@ test("handle click on menu", function() { expect(1); var ac = $('#menu1').menu({ select: function(event, ui) { - log(); + menu_log(); } }); - log("click",true); - clickMenu($('#menu1'),"1"); - log("afterclick"); - clickMenu( ac,"2"); - clickMenu($('#menu1'),"3"); - clickMenu( ac,"1"); + menu_log("click",true); + menu_click($('#menu1'),"1"); + menu_log("afterclick"); + menu_click( ac,"2"); + menu_click($('#menu1'),"3"); + menu_click( ac,"1"); equals( $("#log").html(), "1,3,2,afterclick,1,click,", "Click order not valid."); }); @@ -36,7 +36,7 @@ test( "handle blur: click", function() { }); $menu.find( "li a:first" ).trigger( "click" ); - $( "<a/>", { id: "remove"} ).appendTo("body").trigger( "click" ); + $( "<a>", { id: "remove"} ).appendTo("body").trigger( "click" ); $("#remove").remove(); }); @@ -64,59 +64,59 @@ test("handle keyboard navigation on menu without scroll and without submenus", f expect(12); var element = $('#menu1').menu({ select: function(event, ui) { - log($(ui.item[0]).text()); + menu_log($(ui.item[0]).text()); }, focus: function( event, ui ) { - log($(event.target).find(".ui-state-focus").parent().index()); + menu_log($(event.target).find(".ui-state-focus").parent().index()); } }); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); equals( $("#log").html(), "1,0,keydown,", "Keydown DOWN"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); equals( $("#log").html(), "0,keydown,", "Keydown UP"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); equals( $("#log").html(), "keydown,", "Keydown LEFT (no effect)"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); equals( $("#log").html(), "keydown,", "Keydown RIGHT (no effect)"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); equals( $("#log").html(), "4,keydown,", "Keydown PAGE_DOWN"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); equals( $("#log").html(), "keydown,", "Keydown PAGE_DOWN (no effect)"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); equals( $("#log").html(), "0,keydown,", "Keydown PAGE_UP"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); equals( $("#log").html(), "keydown,", "Keydown PAGE_UP (no effect)"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.END } ); equals( $("#log").html(), "4,keydown,", "Keydown END"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } ); equals( $("#log").html(), "0,keydown,", "Keydown HOME"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } ); equals( $("#log").html(), "keydown,", "Keydown ESCAPE (no effect)"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); equals( $("#log").html(), "Aberdeen,keydown,", "Keydown ENTER"); }); @@ -125,27 +125,27 @@ asyncTest("handle keyboard navigation on menu without scroll and with submenus", expect(14); var element = $('#menu2').menu({ select: function(event, ui) { - log($(ui.item[0]).text()); + menu_log($(ui.item[0]).text()); }, focus: function( event, ui ) { - log($(event.target).find(".ui-state-focus").parent().index()); + menu_log($(event.target).find(".ui-state-focus").parent().index()); } }); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); equals( $("#log").html(), "1,0,keydown,", "Keydown DOWN"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); equals( $("#log").html(), "0,keydown,", "Keydown UP"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); equals( $("#log").html(), "keydown,", "Keydown LEFT (no effect)"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); @@ -157,7 +157,7 @@ asyncTest("handle keyboard navigation on menu without scroll and with submenus", }, 50); setTimeout( function() { - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); equals( $("#log").html(), "4,keydown,", "Keydown LEFT (close submenu)"); @@ -165,41 +165,41 @@ asyncTest("handle keyboard navigation on menu without scroll and with submenus", element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); setTimeout( function() { - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); equals( $("#log").html(), "2,keydown,", "Keydown PAGE_DOWN"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); equals( $("#log").html(), "keydown,", "Keydown PAGE_DOWN (no effect)"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); equals( $("#log").html(), "0,keydown,", "Keydown PAGE_UP"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); equals( $("#log").html(), "keydown,", "Keydown PAGE_UP (no effect)"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.END } ); equals( $("#log").html(), "2,keydown,", "Keydown END"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } ); equals( $("#log").html(), "0,keydown,", "Keydown HOME"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } ); equals( $("#log").html(), "4,keydown,", "Keydown ESCAPE (close submenu)"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); setTimeout( function() { equals( $("#log").html(), "0,keydown,", "Keydown ENTER (open submenu)"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); equals( $("#log").html(), "Ada,keydown,", "Keydown ENTER (select item)"); @@ -214,67 +214,67 @@ test("handle keyboard navigation on menu with scroll and without submenus", func expect(14); var element = $('#menu3').menu({ select: function(event, ui) { - log($(ui.item[0]).text()); + menu_log($(ui.item[0]).text()); }, focus: function( event, ui ) { - log($(event.target).find(".ui-state-focus").parent().index()); + menu_log($(event.target).find(".ui-state-focus").parent().index()); } }); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); equals( $("#log").html(), "1,0,keydown,", "Keydown DOWN"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); equals( $("#log").html(), "0,keydown,", "Keydown UP"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); equals( $("#log").html(), "keydown,", "Keydown LEFT (no effect)"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); equals( $("#log").html(), "keydown,", "Keydown RIGHT (no effect)"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); equals( $("#log").html(), "10,keydown,", "Keydown PAGE_DOWN"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); equals( $("#log").html(), "20,keydown,", "Keydown PAGE_DOWN"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); equals( $("#log").html(), "10,keydown,", "Keydown PAGE_UP"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); equals( $("#log").html(), "0,keydown,", "Keydown PAGE_UP"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); equals( $("#log").html(), "keydown,", "Keydown PAGE_UP (no effect)"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.END } ); equals( $("#log").html(), "37,keydown,", "Keydown END"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); equals( $("#log").html(), "keydown,", "Keydown PAGE_DOWN (no effect)"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } ); equals( $("#log").html(), "0,keydown,", "Keydown HOME"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } ); equals( $("#log").html(), "keydown,", "Keydown ESCAPE (no effect)"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); equals( $("#log").html(), "Aberdeen,keydown,", "Keydown ENTER"); }); @@ -283,27 +283,27 @@ asyncTest("handle keyboard navigation on menu with scroll and with submenus", fu expect(14); var element = $('#menu4').menu({ select: function(event, ui) { - log($(ui.item[0]).text()); + menu_log($(ui.item[0]).text()); }, focus: function( event, ui ) { - log($(event.target).find(".ui-state-focus").parent().index()); + menu_log($(event.target).find(".ui-state-focus").parent().index()); } }); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); equals( $("#log").html(), "1,0,keydown,", "Keydown DOWN"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); equals( $("#log").html(), "0,keydown,", "Keydown UP"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); equals( $("#log").html(), "keydown,", "Keydown LEFT (no effect)"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); @@ -312,7 +312,7 @@ asyncTest("handle keyboard navigation on menu with scroll and with submenus", fu }, 50); setTimeout( function() { - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); equals( $("#log").html(), "1,keydown,", "Keydown LEFT (close submenu)"); @@ -320,41 +320,41 @@ asyncTest("handle keyboard navigation on menu with scroll and with submenus", fu element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); setTimeout( function() { - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); equals( $("#log").html(), "10,keydown,", "Keydown PAGE_DOWN"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); equals( $("#log").html(), "20,keydown,", "Keydown PAGE_DOWN"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); equals( $("#log").html(), "10,keydown,", "Keydown PAGE_UP"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); equals( $("#log").html(), "0,keydown,", "Keydown PAGE_UP"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.END } ); equals( $("#log").html(), "27,keydown,", "Keydown END"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } ); equals( $("#log").html(), "0,keydown,", "Keydown HOME"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } ); equals( $("#log").html(), "1,keydown,", "Keydown ESCAPE (close submenu)"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); setTimeout( function() { equals( $("#log").html(), "0,keydown,", "Keydown ENTER (open submenu)"); - log("keydown",true); + menu_log("keydown",true); element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); equals( $("#log").html(), "Aberdeen,keydown,", "Keydown ENTER (select item)"); diff --git a/tests/unit/menu/menu_test_helpers.js b/tests/unit/menu/menu_test_helpers.js new file mode 100644 index 000000000..717cfc45d --- /dev/null +++ b/tests/unit/menu/menu_test_helpers.js @@ -0,0 +1,14 @@ +function menu_log( message, clear ) { + if ( clear ) { + $( "#log" ).empty(); + } + if ( message === undefined ) { + message = $( "#log" ).data( "lastItem" ); + } + $( "#log" ).prepend( message + "," ); +} + +function menu_click( menu, item ) { + $( "#log" ).data( "lastItem", item ); + menu.find( "li:eq(" + item + ") a" ).trigger( "click" ); +} diff --git a/tests/unit/position/all.html b/tests/unit/position/all.html new file mode 100644 index 000000000..00f7e3bba --- /dev/null +++ b/tests/unit/position/all.html @@ -0,0 +1,30 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Position Test Suite</title> + + <script src="../../../jquery-1.6.2.js"></script> + + <link rel="stylesheet" href="../../../external/qunit.css"> + <link rel="stylesheet" href="../subsuiteRunner.css"> + <script src="../../../external/qunit.js"></script> + <script src="../subsuiteRunner.js"></script> + <script src="../subsuite.js"></script> + + <script> + testAllVersions( "position" ); + </script> +</head> +<body> + +<h1 id="qunit-header">jQuery UI Position Test Suite</h1> +<h2 id="qunit-banner"></h2> +<div id="qunit-testrunner-toolbar"></div> +<h2 id="qunit-userAgent"></h2> +<ol id="qunit-tests"></ol> +<div id="qunit-fixture"> + +</div> +</body> +</html> diff --git a/tests/unit/position/position.html b/tests/unit/position/position.html index 3df9d465c..a3a97911c 100644 --- a/tests/unit/position/position.html +++ b/tests/unit/position/position.html @@ -1,4 +1,4 @@ -<!DOCTYPE html> +<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> @@ -16,7 +16,7 @@ <script src="../testsuite.js"></script> <script src="position_core.js"></script> - <script src="position_core_within.js"></script> + <script src="position_core_within.js"></script> <script src="../swarminject.js"></script> </head> @@ -36,34 +36,35 @@ elements smaller than 10px have a line-height set on them to avoid a bug in IE6 --> <div id="qunit-fixture" style="top: 0; left: 0; z-index:1"> - <div id="within-container"> - <div id="el1" style="position: absolute; width: 6px; height: 6px; line-height: 6px;"></div> - <div id="el2" style="position: absolute; width: 6px; height: 6px; line-height: 6px;"></div> - <div id="parent" style="position: absolute; width: 6px; height: 6px; top: 4px; left: 4px; line-height: 6px;"></div> - - <div style="position: absolute; top: 0px; left: 0px"> - <div id="elx" style="position: absolute; width: 10px; height: 10px; line-height: 10px;"></div> - <div id="parentx" style="position: absolute; width: 20px; height: 20px; top: 40px; left: 40px;"></div> - </div> - - <div style="position: absolute; top: 200px; left: 100px;"> - <div id="el-offset-100-200" style="position: absolute; width: 10px; height: 10px; line-height: 10px;"></div> - <div style="position: absolute; top: 100px; left: 50px;"> - <div id="el-two-offset-150-300" style="position: absolute; width: 10px; height: 10px; line-height: 10px;"></div> - <div id="el-fixed" style="position: fixed; top: 200px; left: 200px;"></div> - </div> - </div> - - <div style="position: absolute; height: 5000px; width: 5000px;"></div> - - <div id="bug-5280" style="height: 30px; width: 201px;"> - <div style="width: 50px; height: 10px;"></div> - </div> - </div> -</div> + <div id="within-container"> + <div id="el1" style="position: absolute; width: 6px; height: 6px; line-height: 6px;"></div> + <div id="el2" style="position: absolute; width: 6px; height: 6px; line-height: 6px;"></div> + <div id="parent" style="position: absolute; width: 6px; height: 6px; top: 4px; left: 4px; line-height: 6px;"></div> + + <div style="position: absolute; top: 0px; left: 0px"> + <div id="elx" style="position: absolute; width: 10px; height: 10px; line-height: 10px;"></div> + <div id="parentx" style="position: absolute; width: 20px; height: 20px; top: 40px; left: 40px;"></div> + </div> + <div style="position: absolute; top: 200px; left: 100px;"> + <div id="el-offset-100-200" style="position: absolute; width: 10px; height: 10px; line-height: 10px;"></div> + <div style="position: absolute; top: 100px; left: 50px;"> + <div id="el-two-offset-150-300" style="position: absolute; width: 10px; height: 10px; line-height: 10px;"></div> + <div id="el-fixed" style="position: fixed; top: 200px; left: 200px;"></div> + </div> + </div> + <div style="position: absolute; height: 5000px; width: 5000px;"></div> + <div id="bug-5280" style="height: 30px; width: 201px;"> + <div style="width: 50px; height: 10px;"></div> + </div> + + <div id="fractions-parent" style="position: absolute; left: 10.7432222px; top: 10.532325px; height: 30px; width: 201px;"> + <div id="fractions-element"></div> + </div> + </div> +</div> </body> </html> diff --git a/tests/unit/position/position_core.js b/tests/unit/position/position_core.js index fd6e643e9..ea1baee72 100644 --- a/tests/unit/position/position_core.js +++ b/tests/unit/position/position_core.js @@ -332,28 +332,28 @@ test( "collision: fit, window scrolled", function() { test( "collision: flip, no offset", function() { collisionTest({ collision: "flip" - }, { top: -10, left: -10 }, "left top" ); + }, { top: $( window ).height(), left: $( window ).width() }, "left top" ); collisionTest2({ collision: "flip" - }, { top: $( window ).height(), left: $( window ).width() }, "right bottom" ); + }, { top: -10, left: -10 }, "right bottom" ); }); test( "collision: flip, with offset", function() { collisionTest({ collision: "flip", at: "right+2 bottom+3" - }, { top: -13, left: -12 }, "left top, with offset added" ); + }, { top: $( window ).height() + 3, left: $( window ).width() + 2 }, "left top, with offset added" ); collisionTest2({ collision: "flip", at: "left+2 top+3" - }, { top: $( window ).height() - 3, left: $( window ).width() - 2 }, "bottom, positive offset" ); + }, { top: -7, left: -8 }, "bottom, positive offset" ); collisionTest2({ collision: "flip", at: "left-2 top-3" - }, { top: $( window ).height() + 3, left: $( window ).width() + 2 }, "right bottom, negative offset" ); + }, { top: -13, left: -12 }, "right bottom, negative offset" ); }); test( "collision: none, no offset", function() { @@ -427,12 +427,12 @@ test( "collision: flip, with margin", function() { collisionTest({ collision: "flip", at: "left top" - }, { top: $( window ).height() - 10, left: $( window ).width() - 10 }, "left top" ); + }, { top: 0, left: 0 }, "left top" ); collisionTest2({ collision: "flip", at: "right bottom" - }, { top: 0, left: 0 }, "right bottom" ); + }, { top: $( window ).height() - 10, left: $( window ).width() - 10 }, "right bottom" ); }); test( "addClass: flipped left", function() { @@ -443,7 +443,7 @@ test( "addClass: flipped left", function() { at: "right center" }); - same( elem.hasClass( 'ui-flipped-left' ), true, 'Has ui-flipped-left class' ); + same( elem.hasClass( 'ui-flipped-left' ), false, 'Has ui-flipped-left class' ); elem.position( { my: "right center", @@ -451,7 +451,7 @@ test( "addClass: flipped left", function() { collision: "flip", at: "left center" }) - + same( elem.hasClass( 'ui-flipped-left' ), false, 'Removed ui-flipped-left class' ); }); @@ -463,8 +463,8 @@ test( "addClass: flipped top", function() { at: "right bottom" }); - same( elem.hasClass( 'ui-flipped-top' ), true, 'Has ui-flipped-top class' ); - + same( elem.hasClass( 'ui-flipped-top' ), false, 'Has ui-flipped-top class' ); + elem.position( { my: "left bottom", of: window, @@ -483,7 +483,7 @@ test( "addClass: flipped right", function() { at: "left center" }); - same( elem.hasClass( 'ui-flipped-right' ), true, 'Has ui-flipped-right class' ); + same( elem.hasClass( 'ui-flipped-right' ), false, 'Has ui-flipped-right class' ); elem.position( { my: "left center", @@ -504,8 +504,8 @@ test( "addClass: flipped bottom", function() { at: "right top" }); - same( elem.hasClass( 'ui-flipped-bottom' ), true, 'Has ui-flipped-bottom class' ); - + same( elem.hasClass( 'ui-flipped-bottom' ), false, 'Has ui-flipped-bottom class' ); + elem.position( { my: "left top", of: window, @@ -516,22 +516,32 @@ test( "addClass: flipped bottom", function() { same( elem.hasClass( 'ui-flipped-bottom' ), false, 'Removed ui-flipped-bottom class' ); }); -//test( "bug #5280: consistent results (avoid fractional values)", function() { -// var wrapper = $( "#bug-5280" ), -// elem = wrapper.children(), -// offset1 = elem.position({ -// my: "center", -// at: "center", -// of: wrapper, -// collision: "none" -// }).offset(), -// offset2 = elem.position({ -// my: "center", -// at: "center", -// of: wrapper, -// collision: "none" -// }).offset(); -// same( offset1, offset2 ); -//}); +test( "fractions", function() { + $( "#fractions-element" ).position({ + my: "left top", + at: "left top", + of: "#fractions-parent", + collision: "none" + }); + same( $( "#fractions-element" ).offset(), $( "#fractions-parent" ).offset(), "left top, left top" ); +}); + +test( "bug #5280: consistent results (avoid fractional values)", function() { + var wrapper = $( "#bug-5280" ), + elem = wrapper.children(), + offset1 = elem.position({ + my: "center", + at: "center", + of: wrapper, + collision: "none" + }).offset(), + offset2 = elem.position({ + my: "center", + at: "center", + of: wrapper, + collision: "none" + }).offset(); + same( offset1, offset2 ); +}); }( jQuery ) ); diff --git a/tests/unit/position/position_core_within.js b/tests/unit/position/position_core_within.js index bfb913335..392e409c5 100644 --- a/tests/unit/position/position_core_within.js +++ b/tests/unit/position/position_core_within.js @@ -7,7 +7,7 @@ function scrollTopSupport() { module( "position - within", { setup: function(){ - $("#within-container").css({"width": "500px", "height": "500px", "top": "20px", "left": "20px", "position": "relative"}).show(); + $("#within-container").css({"width": "70px", "height": "70px", "top": "20px", "left": "20px", "position": "relative"}).show(); } }); @@ -20,13 +20,13 @@ $.fn.addOffsets = function() { elOffset.top -= offset.top; elOffset.left -= offset.left; - + return {top: elOffset.top - offset.top, left: elOffset.left - offset.left }; }; test( "my, at, of", function() { var within = $("#within-container"); - + $( "#elx" ).position({ my: "left top", at: "left top", @@ -121,7 +121,7 @@ test( "positions", function() { test( "of", function() { var within = $("#within-container"); - + $( "#elx" ).position({ my: "left top", at: "left top", @@ -178,7 +178,7 @@ test( "of", function() { test( "within:offsets", function() { var within = $("#within-container"); - + $( "#elx" ).position({ my: "left top", at: "left+10 bottom+10", @@ -218,7 +218,7 @@ test( "within:offsets", function() { test( "using", function() { expect( 6 ); - + var within = $("#within-container"); var count = 0, @@ -226,7 +226,7 @@ test( "using", function() { expectedPosition = { top: addTop + 40, left: addLeft + 40 }, originalPosition = elems.position({ my: "right bottom", - at: "rigt bottom", + at: "right bottom", of: "#parentx", collision: "none", within: within @@ -253,14 +253,14 @@ test( "using", function() { function collisionTest( config, result, msg ) { var within = $("#within-container"); - + var elem = $( "#elx" ).position( $.extend({ my: "left top", at: "right bottom", - of: within[0], + of: "#parentx", within: within }, config ) ); - + same( elem.addOffsets(), result, msg ); } @@ -272,128 +272,136 @@ function collisionTest2( config, result, msg ) { } test( "collision: fit, no offset", function() { - var within = $("#within-container"); - + var within = $("#within-container"), + of = $("#parentx"); + collisionTest({ collision: "fit" - }, { top: addTop + within.height() - 10 - $.position.getScrollInfo( within ).height, left: addLeft + within.width() - 10 - $.position.getScrollInfo( within ).width }, "right bottom" ); + }, { top: addTop + of.position().top + of.height() - $.position.getScrollInfo( within ).height, left: addLeft + of.position().left + of.width() - $.position.getScrollInfo( within ).width }, "right bottom" ); collisionTest2({ collision: "fit" - }, { top: addTop + 0, left: addLeft + 0 }, "left top" ); + }, { top: addTop + of.position().top - 10, left: addLeft + of.position().left - 10 }, "left top" ); }); test( "collision: fit, with offset", function() { - var within = $("#within-container"); - + var within = $("#within-container"), + of = $("#parentx"); + collisionTest({ collision: "fit", at: "right+2 bottom+3" - }, { top: addTop + within.height() - 10 - $.position.getScrollInfo( within ).height, left: addLeft + within.width() - 10 - $.position.getScrollInfo( within ).width }, "right bottom"); + }, { top: addTop + of.position().top + of.height() - $.position.getScrollInfo( within ).height, left: addLeft + of.position().left + of.width() - $.position.getScrollInfo( within ).width }, "right bottom"); collisionTest2({ collision: "fit", at: "left+2 top+3" - }, { top: addTop + 0, left: addLeft + 0 }, "left top, positive offset" ); + }, { top: addTop + of.position().top - 7, left: addLeft + of.position().left - 8 }, "left top, positive offset" ); collisionTest2({ collision: "fit", at: "left-2 top-3" - }, { top: addTop + 0, left: addLeft + 0 }, "left top, negative offset" ); + }, { top: addTop + of.position().top - 13, left: addLeft + of.position().left - 12 }, "left top, negative offset" ); }); -test( "collision: fit, within scrolled", function() { +test( "collision: none, within scrolled", function() { if ( scrollTopSupport() ) { - var within = $("#within-container").css({"width": "1000px", "height": "800px", "overflow": "auto"}); + var within = $("#within-container").css({"width": "1000px", "height": "800px", "overflow": "auto"}), + of = $("#parentx"); within.scrollTop( 300 ).scrollLeft( 150 ); - + collisionTest({ - collision: "fit", + collision: "none", at: "left-100 top-100" - }, { top: addTop, left: addLeft }, "top left" ); + }, { top: of.offset().top + addTop - 100 - of.height(), left: of.offset().left + addLeft - 100 - of.width() }, "top left" ); collisionTest2({ - collision: "fit", + collision: "none", at: "right+100 bottom+100" - }, { top: addTop + within.height() - 10 - $.position.getScrollInfo( within ).height, left: addLeft + within.width() - 10 - $.position.getScrollInfo( within ).width }, "right bottom" ); + }, { top: of.offset().top + addTop + 100 - 10, left: of.offset().left + addLeft + 100 - 10 }, "right bottom" ); within.scrollTop( 0 ).scrollLeft( 0 ); } }); - + test( "collision: flip, no offset", function() { - var within = $("#within-container"); - + var within = $("#within-container"), + of = $("#parentx"); + collisionTest({ collision: "flip" - }, { top: addTop + -10, left: addLeft + -10 }, "left top" ); + }, { top: addTop + of.position().top + of.height(), left: addLeft + of.position().left + of.width() }, "left top" ); collisionTest2({ collision: "flip" - }, { top: addTop + within.height(), left: addLeft + within.width() }, "right bottom" ); + }, { top: addTop + of.position().top - 10, left: addTop + of.position().top - 10 }, "right bottom" ); }); test( "collision: flip, with offset", function() { - var within = $("#within-container"); - + var within = $("#within-container"), + of = $("#parentx"); + collisionTest({ collision: "flip", at: "right+2 bottom+3" - }, { top: addTop + -13, left: addLeft + -12 }, "left top, with offset added" ); + }, { top: addTop + of.position().top - 13, left: addLeft + of.position().left - 12 }, "left top, with offset added" ); collisionTest2({ collision: "flip", at: "left+2 top+3" - }, { top: addTop + within.height() - 3, left: addLeft + within.width() - 2 }, "bottom, positive offset" ); + }, { top: addTop + of.position().top - 10 + 3, left: addLeft + of.position().left - 10 + 2 }, "right bottom, positive offset" ); collisionTest2({ collision: "flip", at: "left-2 top-3" - }, { top: addTop + within.height() + 3, left: addLeft + within.width() + 2 }, "right bottom, negative offset" ); + }, { top: addTop + of.position().top - 13, left: addLeft + of.position().left - 12 }, "right bottom, negative offset" ); }); test( "collision: none, no offset", function() { - var within = $("#within-container"); - + var within = $("#within-container"), + of = $("#parentx"); + collisionTest({ collision: "none" - }, { top: addTop + within.height(), left: addLeft + within.width() }, "left top" ); + }, { top: addTop + of.position().top + of.height(), left: addLeft + of.position().left + of.width() }, "left top" ); collisionTest2({ collision: "none" - }, { top: addTop + -10, left: addLeft + -10 }, "moved to the right bottom" ); + }, { top: addTop + of.position().top - 10, left: addLeft + of.position().left - 10 }, "right bottom" ); }); test( "collision: none, with offset", function() { - var within = $("#within-container"); - + var within = $("#within-container"), + of = $("#parentx"); + collisionTest({ collision: "none", at: "right+2 bottom+3" - }, { top: addTop + within.height() + 3, left: addLeft + within.width() + 2 }, "right bottom, with offset added" ); + }, { top: addTop + of.position().top + of.height() + 3, left: addLeft + of.position().left + of.width() + 2 }, "right bottom, with offset added" ); collisionTest2({ collision: "none", at: "left+2 top+3" - }, { top: addTop + -7, left: addLeft + -8 }, "left top, positive offset" ); + }, { top: addTop + of.position().top - 7, left: addTop + of.position().top - 8 }, "left top, positive offset" ); collisionTest2({ collision: "none", at: "left-2 top-3" - }, { top: addTop + -13, left: addLeft + -12 }, "left top, negative offset" ); + }, { top: addTop + of.position().top - 13, left: addTop + of.position().top - 12 }, "left top, negative offset" ); }); test( "collision: fit, with margin", function() { - var within = $("#within-container"); - + var within = $("#within-container"), + of = $("#parentx"); + $( "#elx" ).css( "margin", 10 ); collisionTest({ collision: "fit" - }, { top: addTop + within.height() - 20 - $.position.getScrollInfo( within ).height, left: addLeft + within.width() - 20 - $.position.getScrollInfo( within ).width }, "right bottom" ); + }, { top: addTop + of.position().top + of.height() - 10 - $.position.getScrollInfo( within ).height, left: addLeft + of.position().left + of.width() - 10 - $.position.getScrollInfo( within ).width }, "right bottom" ); collisionTest2({ collision: "fit" - }, { top: addTop + 10, left: addLeft + 10 }, "left top" ); + }, { top: addTop + of.position().top - 10, left: addLeft + of.position().left - 10 }, "left top" ); $( "#elx" ).css({ "margin-left": 5, @@ -402,11 +410,11 @@ test( "collision: fit, with margin", function() { collisionTest({ collision: "fit" - }, { top: addTop + within.height() - 20 - $.position.getScrollInfo( within ).height, left: addLeft + within.width() - 20 - $.position.getScrollInfo( within ).width }, "right bottom" ); + }, { top: addTop + of.position().top + of.height() - 10 - $.position.getScrollInfo( within ).height, left: addLeft + of.position().left + of.width() - 10 - $.position.getScrollInfo( within ).width }, "right bottom" ); collisionTest2({ collision: "fit" - }, { top: addTop + 5, left: addLeft + 5 }, "left top" ); + }, { top: addTop + of.position().top - 10, left: addLeft + of.position().left - 10 }, "left top" ); $( "#elx" ).css({ "margin-right": 15, @@ -415,32 +423,33 @@ test( "collision: fit, with margin", function() { collisionTest({ collision: "fit" - }, { top: addTop + within.height() - 25 - $.position.getScrollInfo( within ).height, left: addLeft + within.width() - 25 - $.position.getScrollInfo( within ).width }, "right bottom" ); + }, { top: addTop + of.position().top + of.height() - 15 - $.position.getScrollInfo( within ).height, left: addLeft + of.position().left + of.width() - 15 - $.position.getScrollInfo( within ).width }, "right bottom" ); collisionTest2({ collision: "fit" - }, { top: addTop + 5, left: addLeft + 5 }, "left top" ); + }, { top: addTop + of.position().top - 10, left: addLeft + of.position().left - 10 }, "left top" ); }); test( "collision: flip, with margin", function() { - var within = $("#within-container"); - + var within = $("#within-container"), + of = $("#parentx"); + $( "#elx" ).css( "margin", 10 ); collisionTest({ - collision: "flip", - at: "left top" - }, { top: addTop + within.height() - 10, left: addLeft + within.width() - 10 }, "left top" ); + collision: "flip" + }, { top: addTop + of.position().top - 10, left: addLeft + of.position().left - 10 }, "left top" ); collisionTest2({ - collision: "flip", - at: "right bottom" - }, { top: addTop + 0, left: addLeft + 0 }, "right bottom" ); + collision: "flip" + }, { top: addTop + of.position().top - 10, left: addLeft + of.position().left - 10 }, "right bottom" ); + + $( "#elx" ).css( "margin", 0 ); }); test( "addClass: flipped left", function() { var within = $("#within-container"); - + var elem = $( "#elx" ).position( { my: "left center", of: within[0], @@ -449,7 +458,7 @@ test( "addClass: flipped left", function() { at: "right center" }); - same( elem.hasClass( 'ui-flipped-left' ), true, 'Has ui-flipped-left class' ); + same( elem.hasClass( 'ui-flipped-left' ), false, 'Has ui-flipped-left class' ); elem.position( { my: "right center", @@ -458,13 +467,13 @@ test( "addClass: flipped left", function() { collision: "flip", at: "left center" }) - + same( elem.hasClass( 'ui-flipped-left' ), false, 'Removed ui-flipped-left class' ); }); test( "addClass: flipped top", function() { var within = $("#within-container"); - + var elem = $( "#elx" ).position( { my: "left top", of: within[0], @@ -473,8 +482,8 @@ test( "addClass: flipped top", function() { at: "right bottom" }); - same( elem.hasClass( 'ui-flipped-top' ), true, 'Has ui-flipped-top class' ); - + same( elem.hasClass( 'ui-flipped-top' ), false, 'Has ui-flipped-top class' ); + elem.position( { my: "left bottom", of: within[0], @@ -488,7 +497,7 @@ test( "addClass: flipped top", function() { test( "addClass: flipped right", function() { var within = $("#within-container"); - + var elem = $( "#elx" ).position( { my: "right center", of: within[0], @@ -497,7 +506,7 @@ test( "addClass: flipped right", function() { at: "left center" }); - same( elem.hasClass( 'ui-flipped-right' ), true, 'Has ui-flipped-right class' ); + same( elem.hasClass( 'ui-flipped-right' ), false, 'Has ui-flipped-right class' ); elem.position( { my: "left center", @@ -513,7 +522,7 @@ test( "addClass: flipped right", function() { test( "addClass: flipped bottom", function() { var within = $("#within-container"); - + var elem = $( "#elx" ).position( { my: "left bottom", of: window, @@ -521,8 +530,8 @@ test( "addClass: flipped bottom", function() { at: "right top" }); - same( elem.hasClass( 'ui-flipped-bottom' ), true, 'Has ui-flipped-bottom class' ); - + same( elem.hasClass( 'ui-flipped-bottom' ), false, 'Has ui-flipped-bottom class' ); + elem.position( { my: "left top", of: window, diff --git a/tests/unit/position/position_deprecated.html b/tests/unit/position/position_deprecated.html index 9d595e48e..c80490f74 100644 --- a/tests/unit/position/position_deprecated.html +++ b/tests/unit/position/position_deprecated.html @@ -1,4 +1,4 @@ -<!DOCTYPE html> +<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> @@ -23,8 +23,7 @@ <h2 id="qunit-banner"></h2> <div id="qunit-testrunner-toolbar"></div> <h2 id="qunit-userAgent"></h2> -<ol id="qunit-tests"> -</ol> +<ol id="qunit-tests"></ol> <!-- elements smaller than 10px have a line-height set on them to avoid a bug in IE6 @@ -56,5 +55,9 @@ elements smaller than 10px have a line-height set on them to avoid a bug in IE6 <div style="width: 50px; height: 10px;"></div> </div> +<div id="fractions-parent" style="position: absolute; left: 10.7432222px; top: 10.532325px; height: 30px; width: 201px;"> + <div id="fractions-element"></div> +</div> + </body> </html> diff --git a/tests/unit/progressbar/all.html b/tests/unit/progressbar/all.html new file mode 100644 index 000000000..8f5f0ed26 --- /dev/null +++ b/tests/unit/progressbar/all.html @@ -0,0 +1,30 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Progressbar Test Suite</title> + + <script src="../../../jquery-1.6.2.js"></script> + + <link rel="stylesheet" href="../../../external/qunit.css"> + <link rel="stylesheet" href="../subsuiteRunner.css"> + <script src="../../../external/qunit.js"></script> + <script src="../subsuiteRunner.js"></script> + <script src="../subsuite.js"></script> + + <script> + testAllVersions( "progressbar" ); + </script> +</head> +<body> + +<h1 id="qunit-header">jQuery UI Progressbar Test Suite</h1> +<h2 id="qunit-banner"></h2> +<div id="qunit-testrunner-toolbar"></div> +<h2 id="qunit-userAgent"></h2> +<ol id="qunit-tests"></ol> +<div id="qunit-fixture"> + +</div> +</body> +</html> diff --git a/tests/unit/progressbar/progressbar.html b/tests/unit/progressbar/progressbar.html index d3f9b033d..b708af265 100644 --- a/tests/unit/progressbar/progressbar.html +++ b/tests/unit/progressbar/progressbar.html @@ -1,28 +1,29 @@ -<!DOCTYPE html> +<!doctype html> <html lang="en"> <head> - <meta charset="UTF-8" /> + <meta charset="utf-8"> <title>jQuery UI Progressbar Test Suite</title> - <link type="text/css" href="../../../themes/base/jquery.ui.progressbar.css" rel="stylesheet" /> + <link rel="stylesheet" href="../../../themes/base/jquery.ui.core.css"> + <link rel="stylesheet" href="../../../themes/base/jquery.ui.progressbar.css"> <script src="../../jquery.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.progressbar.js"></script> - - <link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/> - <script type="text/javascript" src="../../../external/qunit.js"></script> - <script type="text/javascript" src="../../jquery.simulate.js"></script> - <script type="text/javascript" src="../testsuite.js"></script> - - <script type="text/javascript" src="progressbar_core.js"></script> - <script type="text/javascript" src="progressbar_defaults.js"></script> - <script type="text/javascript" src="progressbar_events.js"></script> - <script type="text/javascript" src="progressbar_methods.js"></script> - <script type="text/javascript" src="progressbar_options.js"></script> - - <script type="text/javascript" src="../swarminject.js"></script> + <script src="../../../ui/jquery.ui.core.js"></script> + <script src="../../../ui/jquery.ui.widget.js"></script> + <script src="../../../ui/jquery.ui.progressbar.js"></script> + + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> + + <script src="progressbar_core.js"></script> + <script src="progressbar_defaults.js"></script> + <script src="progressbar_events.js"></script> + <script src="progressbar_methods.js"></script> + <script src="progressbar_options.js"></script> + + <script src="../swarminject.js"></script> </head> <body> @@ -30,12 +31,11 @@ <h2 id="qunit-banner"></h2> <div id="qunit-testrunner-toolbar"></div> <h2 id="qunit-userAgent"></h2> -<ol id="qunit-tests"> -</ol> - +<ol id="qunit-tests"></ol> <div id="qunit-fixture"> - <div id="progressbar"></div> -</div> +<div id="progressbar"></div> + +</div> </body> </html> diff --git a/tests/unit/resizable/all.html b/tests/unit/resizable/all.html new file mode 100644 index 000000000..f496ed5a7 --- /dev/null +++ b/tests/unit/resizable/all.html @@ -0,0 +1,30 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Resizable Test Suite</title> + + <script src="../../../jquery-1.6.2.js"></script> + + <link rel="stylesheet" href="../../../external/qunit.css"> + <link rel="stylesheet" href="../subsuiteRunner.css"> + <script src="../../../external/qunit.js"></script> + <script src="../subsuiteRunner.js"></script> + <script src="../subsuite.js"></script> + + <script> + testAllVersions( "resizable" ); + </script> +</head> +<body> + +<h1 id="qunit-header">jQuery UI Resizable Test Suite</h1> +<h2 id="qunit-banner"></h2> +<div id="qunit-testrunner-toolbar"></div> +<h2 id="qunit-userAgent"></h2> +<ol id="qunit-tests"></ol> +<div id="qunit-fixture"> + +</div> +</body> +</html> diff --git a/tests/unit/resizable/resizable.html b/tests/unit/resizable/resizable.html index e29e94b16..f1b2f1bc3 100644 --- a/tests/unit/resizable/resizable.html +++ b/tests/unit/resizable/resizable.html @@ -1,29 +1,30 @@ -<!DOCTYPE html> +<!doctype html> <html lang="en"> <head> - <meta charset="UTF-8" /> + <meta charset="utf-8"> <title>jQuery UI Resizable Test Suite</title> - <link type="text/css" href="../../../themes/base/jquery.ui.resizable.css" rel="stylesheet" /> + <link rel="stylesheet" href="../../../themes/base/jquery.ui.core.css"> + <link rel="stylesheet" href="../../../themes/base/jquery.ui.resizable.css"> <script src="../../jquery.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.resizable.js"></script> - - <link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/> - <script type="text/javascript" src="../../../external/qunit.js"></script> - <script type="text/javascript" src="../../jquery.simulate.js"></script> - <script type="text/javascript" src="../testsuite.js"></script> - - <script type="text/javascript" src="resizable_core.js"></script> - <script type="text/javascript" src="resizable_defaults.js"></script> - <script type="text/javascript" src="resizable_events.js"></script> - <script type="text/javascript" src="resizable_methods.js"></script> - <script type="text/javascript" src="resizable_options.js"></script> - - <script type="text/javascript"> + <script src="../../../ui/jquery.ui.core.js"></script> + <script src="../../../ui/jquery.ui.widget.js"></script> + <script src="../../../ui/jquery.ui.mouse.js"></script> + <script src="../../../ui/jquery.ui.resizable.js"></script> + + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> + + <script src="resizable_core.js"></script> + <script src="resizable_defaults.js"></script> + <script src="resizable_events.js"></script> + <script src="resizable_methods.js"></script> + <script src="resizable_options.js"></script> + + <script> // disable this stale testsuite for testswarm only var url = window.location.search; url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + 9 ) ); @@ -33,7 +34,7 @@ test("resizable", function() { ok(true, "disabled resizable testsuite"); }); } </script> - <script type="text/javascript" src="../swarminject.js"></script> + <script src="../swarminject.js"></script> </head> <body> @@ -41,13 +42,12 @@ <h2 id="qunit-banner"></h2> <div id="qunit-testrunner-toolbar"></div> <h2 id="qunit-userAgent"></h2> -<ol id="qunit-tests"> -</ol> - +<ol id="qunit-tests"></ol> <div id="qunit-fixture"> - <div id="resizable1" style="background: green; width: 100px; height: 100px;">I'm a resizable.</div> - <img src="images/test.jpg" id="resizable2" style="width: 100px; height: 100px;"/> -</div> +<div id="resizable1" style="background: green; width: 100px; height: 100px;">I'm a resizable.</div> +<img src="images/test.jpg" id="resizable2" style="width: 100px; height: 100px;"> + +</div> </body> </html> diff --git a/tests/unit/selectable/all.html b/tests/unit/selectable/all.html new file mode 100644 index 000000000..e8098a53e --- /dev/null +++ b/tests/unit/selectable/all.html @@ -0,0 +1,30 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Selectable Test Suite</title> + + <script src="../../../jquery-1.6.2.js"></script> + + <link rel="stylesheet" href="../../../external/qunit.css"> + <link rel="stylesheet" href="../subsuiteRunner.css"> + <script src="../../../external/qunit.js"></script> + <script src="../subsuiteRunner.js"></script> + <script src="../subsuite.js"></script> + + <script> + testAllVersions( "selectable" ); + </script> +</head> +<body> + +<h1 id="qunit-header">jQuery UI Selectable Test Suite</h1> +<h2 id="qunit-banner"></h2> +<div id="qunit-testrunner-toolbar"></div> +<h2 id="qunit-userAgent"></h2> +<ol id="qunit-tests"></ol> +<div id="qunit-fixture"> + +</div> +</body> +</html> diff --git a/tests/unit/selectable/selectable.html b/tests/unit/selectable/selectable.html index 95501eaa9..4d6150691 100644 --- a/tests/unit/selectable/selectable.html +++ b/tests/unit/selectable/selectable.html @@ -1,27 +1,27 @@ -<!DOCTYPE html> +<!doctype html> <html lang="en"> <head> - <meta charset="UTF-8" /> + <meta charset="utf-8"> <title>jQuery UI Selectable Test Suite</title> <script src="../../jquery.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.selectable.js"></script> + <script src="../../../ui/jquery.ui.core.js"></script> + <script src="../../../ui/jquery.ui.widget.js"></script> + <script src="../../../ui/jquery.ui.mouse.js"></script> + <script src="../../../ui/jquery.ui.selectable.js"></script> - <link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/> - <script type="text/javascript" src="../../../external/qunit.js"></script> - <script type="text/javascript" src="../../jquery.simulate.js"></script> - <script type="text/javascript" src="../testsuite.js"></script> + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> - <script type="text/javascript" src="selectable_core.js"></script> - <script type="text/javascript" src="selectable_defaults.js"></script> - <script type="text/javascript" src="selectable_events.js"></script> - <script type="text/javascript" src="selectable_methods.js"></script> - <script type="text/javascript" src="selectable_options.js"></script> - - <script type="text/javascript"> + <script src="selectable_core.js"></script> + <script src="selectable_defaults.js"></script> + <script src="selectable_events.js"></script> + <script src="selectable_methods.js"></script> + <script src="selectable_options.js"></script> + + <script> // disable this stale testsuite for testswarm only var url = window.location.search; url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + 9 ) ); @@ -31,7 +31,7 @@ test("selectable", function() { ok(true, "disabled selectable testsuite"); }); } </script> - <script type="text/javascript" src="../swarminject.js"></script> + <script src="../swarminject.js"></script> </head> <body> @@ -39,18 +39,17 @@ <h2 id="qunit-banner"></h2> <div id="qunit-testrunner-toolbar"></div> <h2 id="qunit-userAgent"></h2> -<ol id="qunit-tests"> -</ol> - +<ol id="qunit-tests"></ol> <div id="qunit-fixture"> - <ul id="selectable1"> - <li>Item 1</li> - <li>Item 2</li> - <li class="special">Item 3</li> - <li>Item 4</li> - <li>Item 5</li> - </ul> -</div> +<ul id="selectable1"> + <li>Item 1</li> + <li>Item 2</li> + <li class="special">Item 3</li> + <li>Item 4</li> + <li>Item 5</li> +</ul> + +</div> </body> </html> diff --git a/tests/unit/slider/all.html b/tests/unit/slider/all.html new file mode 100644 index 000000000..99d96c118 --- /dev/null +++ b/tests/unit/slider/all.html @@ -0,0 +1,30 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Slider Test Suite</title> + + <script src="../../../jquery-1.6.2.js"></script> + + <link rel="stylesheet" href="../../../external/qunit.css"> + <link rel="stylesheet" href="../subsuiteRunner.css"> + <script src="../../../external/qunit.js"></script> + <script src="../subsuiteRunner.js"></script> + <script src="../subsuite.js"></script> + + <script> + testAllVersions( "slider" ); + </script> +</head> +<body> + +<h1 id="qunit-header">jQuery UI Slider Test Suite</h1> +<h2 id="qunit-banner"></h2> +<div id="qunit-testrunner-toolbar"></div> +<h2 id="qunit-userAgent"></h2> +<ol id="qunit-tests"></ol> +<div id="qunit-fixture"> + +</div> +</body> +</html> diff --git a/tests/unit/slider/slider.html b/tests/unit/slider/slider.html index 962dadc40..3fe3b3588 100644 --- a/tests/unit/slider/slider.html +++ b/tests/unit/slider/slider.html @@ -1,29 +1,29 @@ -<!DOCTYPE html> +<!doctype html> <html lang="en"> <head> - <meta charset="UTF-8" /> + <meta charset="utf-8"> <title>jQuery UI Slider Test Suite</title> - <link type="text/css" href="../../../themes/base/jquery.ui.slider.css" rel="stylesheet" /> + <link rel="stylesheet" href="../../../themes/base/jquery.ui.slider.css"> <script src="../../jquery.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - - <link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/> - <script type="text/javascript" src="../../../external/qunit.js"></script> - <script type="text/javascript" src="../../jquery.simulate.js"></script> - <script type="text/javascript" src="../testsuite.js"></script> - - <script type="text/javascript" src="slider_core.js"></script> - <script type="text/javascript" src="slider_defaults.js"></script> - <script type="text/javascript" src="slider_events.js"></script> - <script type="text/javascript" src="slider_methods.js"></script> - <script type="text/javascript" src="slider_options.js"></script> - - <script type="text/javascript"> + <script src="../../../ui/jquery.ui.core.js"></script> + <script src="../../../ui/jquery.ui.widget.js"></script> + <script src="../../../ui/jquery.ui.mouse.js"></script> + <script src="../../../ui/jquery.ui.slider.js"></script> + + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> + + <script src="slider_core.js"></script> + <script src="slider_defaults.js"></script> + <script src="slider_events.js"></script> + <script src="slider_methods.js"></script> + <script src="slider_options.js"></script> + + <script> // disable this stale testsuite for testswarm only var url = window.location.search; url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + 9 ) ); @@ -33,7 +33,7 @@ test("slider", function() { ok(true, "disabled slider testsuite"); }); } </script> - <script type="text/javascript" src="../swarminject.js"></script> + <script src="../swarminject.js"></script> </head> <body> @@ -41,15 +41,14 @@ <h2 id="qunit-banner"></h2> <div id="qunit-testrunner-toolbar"></div> <h2 id="qunit-userAgent"></h2> -<ol id="qunit-tests"> -</ol> - +<ol id="qunit-tests"></ol> <div id="qunit-fixture"> - <div id="slider1"></div> - <div id="slider3" style="position: relative; margin: 40px; width: 217px; height: 28px;"> - <div class="ui-slider-handle" style="position: absolute; height: 21px; left: 0px; bottom: 0px; width: 17px;"></div> - </div> + +<div id="slider1"></div> +<div id="slider3" style="position: relative; margin: 40px; width: 217px; height: 28px;"> + <div class="ui-slider-handle" style="position: absolute; height: 21px; left: 0px; bottom: 0px; width: 17px;"></div> </div> +</div> </body> </html> diff --git a/tests/unit/sortable/all.html b/tests/unit/sortable/all.html new file mode 100644 index 000000000..ec5d9391d --- /dev/null +++ b/tests/unit/sortable/all.html @@ -0,0 +1,30 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Sortable Test Suite</title> + + <script src="../../../jquery-1.6.2.js"></script> + + <link rel="stylesheet" href="../../../external/qunit.css"> + <link rel="stylesheet" href="../subsuiteRunner.css"> + <script src="../../../external/qunit.js"></script> + <script src="../subsuiteRunner.js"></script> + <script src="../subsuite.js"></script> + + <script> + testAllVersions( "sortable" ); + </script> +</head> +<body> + +<h1 id="qunit-header">jQuery UI Sortable Test Suite</h1> +<h2 id="qunit-banner"></h2> +<div id="qunit-testrunner-toolbar"></div> +<h2 id="qunit-userAgent"></h2> +<ol id="qunit-tests"></ol> +<div id="qunit-fixture"> + +</div> +</body> +</html> diff --git a/tests/unit/sortable/sortable.html b/tests/unit/sortable/sortable.html index ee03e1344..40eed6652 100644 --- a/tests/unit/sortable/sortable.html +++ b/tests/unit/sortable/sortable.html @@ -1,28 +1,28 @@ -<!DOCTYPE html> +<!doctype html> <html lang="en"> <head> - <meta charset="UTF-8" /> + <meta charset="utf-8"> <title>jQuery UI Sortable Test Suite</title> <script src="../../jquery.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.sortable.js"></script> + <script src="../../../ui/jquery.ui.core.js"></script> + <script src="../../../ui/jquery.ui.widget.js"></script> + <script src="../../../ui/jquery.ui.mouse.js"></script> + <script src="../../../ui/jquery.ui.sortable.js"></script> - <link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/> - <script type="text/javascript" src="../../../external/qunit.js"></script> - <script type="text/javascript" src="../../jquery.simulate.js"></script> - <script type="text/javascript" src="../testsuite.js"></script> + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> - <script type="text/javascript" src="sortable_core.js"></script> - <script type="text/javascript" src="sortable_defaults.js"></script> - <script type="text/javascript" src="sortable_events.js"></script> - <script type="text/javascript" src="sortable_methods.js"></script> - <script type="text/javascript" src="sortable_options.js"></script> - <script type="text/javascript" src="sortable_tickets.js"></script> - - <script type="text/javascript"> + <script src="sortable_core.js"></script> + <script src="sortable_defaults.js"></script> + <script src="sortable_events.js"></script> + <script src="sortable_methods.js"></script> + <script src="sortable_options.js"></script> + <script src="sortable_tickets.js"></script> + + <script> // disable this stale testsuite for testswarm only var url = window.location.search; url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + 9 ) ); @@ -32,7 +32,7 @@ test("sortable", function() { ok(true, "disabled sortable testsuite"); }); } </script> - <script type="text/javascript" src="../swarminject.js"></script> + <script src="../swarminject.js"></script> </head> <body> @@ -40,18 +40,17 @@ <h2 id="qunit-banner"></h2> <div id="qunit-testrunner-toolbar"></div> <h2 id="qunit-userAgent"></h2> -<ol id="qunit-tests"> -</ol> - +<ol id="qunit-tests"></ol> <div id="qunit-fixture"> - <ul id="sortable"> - <li>Item 1</li> - <li>Item 2</li> - <li>Item 3</li> - <li>Item 4</li> - <li>Item 5</li> - </ul> -</div> +<ul id="sortable"> + <li>Item 1</li> + <li>Item 2</li> + <li>Item 3</li> + <li>Item 4</li> + <li>Item 5</li> +</ul> + +</div> </body> </html> diff --git a/tests/unit/spinner/all.html b/tests/unit/spinner/all.html new file mode 100644 index 000000000..17ae4d164 --- /dev/null +++ b/tests/unit/spinner/all.html @@ -0,0 +1,30 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Spinner Test Suite</title> + + <script src="../../../jquery-1.6.2.js"></script> + + <link rel="stylesheet" href="../../../external/qunit.css"> + <link rel="stylesheet" href="../subsuiteRunner.css"> + <script src="../../../external/qunit.js"></script> + <script src="../subsuiteRunner.js"></script> + <script src="../subsuite.js"></script> + + <script> + testAllVersions( "spinner" ); + </script> +</head> +<body> + +<h1 id="qunit-header">jQuery UI Spinner Test Suite</h1> +<h2 id="qunit-banner"></h2> +<div id="qunit-testrunner-toolbar"></div> +<h2 id="qunit-userAgent"></h2> +<ol id="qunit-tests"></ol> +<div id="qunit-fixture"> + +</div> +</body> +</html> diff --git a/tests/unit/spinner/spinner.html b/tests/unit/spinner/spinner.html index b3807a439..ddfb03d91 100644 --- a/tests/unit/spinner/spinner.html +++ b/tests/unit/spinner/spinner.html @@ -1,46 +1,45 @@ -<!doctype html>
-<html lang="en">
-<head>
- <title>jQuery UI Spinner Test Suite</title>
-
- <link type="text/css" href="../../../themes/base/jquery.ui.spinner.css" rel="stylesheet" />
-
- <script src="../../jquery.js"></script>
- <script type="text/javascript" src="../../../external/jquery.mousewheel-3.0.4.js"></script>
- <script type="text/javascript" src="../../../external/jquery.global.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.button.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.spinner.js"></script>
-
- <link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/>
- <script type="text/javascript" src="../../../external/qunit.js"></script>
- <script type="text/javascript" src="../../jquery.simulate.js"></script>
- <script type="text/javascript" src="../testsuite.js"></script>
-
- <script type="text/javascript" src="spinner_core.js"></script>
- <script type="text/javascript" src="spinner_defaults.js"></script>
- <script type="text/javascript" src="spinner_events.js"></script>
- <script type="text/javascript" src="spinner_methods.js"></script>
- <script type="text/javascript" src="spinner_options.js"></script>
-
- <script type="text/javascript" src="../swarminject.js"></script>
-
-</head>
-<body>
-
-
-<h1 id="qunit-header">jQuery UI Spinner Test Suite</h1>
-<h2 id="qunit-banner"></h2>
-<div id="qunit-testrunner-toolbar"></div>
-<h2 id="qunit-userAgent"></h2>
-<ol id="qunit-tests">
-</ol>
-
-<div id="qunit-fixture">
- <input id="spin" class="foo">
- <input id="spin2" value="2">
-</div>
-
-</body>
-</html>
+<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Spinner Test Suite</title> + + <link rel="stylesheet" href="../../../themes/base/jquery.ui.spinner.css"> + + <script src="../../jquery.js"></script> + <script src="../../../external/jquery.mousewheel-3.0.4.js"></script> + <script src="../../../external/globalize.js"></script> + <script src="../../../ui/jquery.ui.core.js"></script> + <script src="../../../ui/jquery.ui.widget.js"></script> + <script src="../../../ui/jquery.ui.button.js"></script> + <script src="../../../ui/jquery.ui.spinner.js"></script> + + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> + + <script src="spinner_test_helpers.js"></script> + <script src="spinner_core.js"></script> + <script src="spinner_defaults.js"></script> + <script src="spinner_events.js"></script> + <script src="spinner_methods.js"></script> + <script src="spinner_options.js"></script> + + <script src="../swarminject.js"></script> +</head> +<body> + +<h1 id="qunit-header">jQuery UI Spinner Test Suite</h1> +<h2 id="qunit-banner"></h2> +<div id="qunit-testrunner-toolbar"></div> +<h2 id="qunit-userAgent"></h2> +<ol id="qunit-tests"></ol> +<div id="qunit-fixture"> + +<input id="spin" class="foo"> +<input id="spin2" value="2"> + +</div> +</body> +</html> diff --git a/tests/unit/spinner/spinner_core.js b/tests/unit/spinner/spinner_core.js index 19bdb3495..34a79bb16 100644 --- a/tests/unit/spinner/spinner_core.js +++ b/tests/unit/spinner/spinner_core.js @@ -1,171 +1,207 @@ -/*
- * spinner_core.js
- */
-
-var simulateKeyDownUp = function(el, kCode, shift) {
- el.simulate("keydown",{keyCode:kCode, shiftKey: shift || false })
- .simulate("keyup",{keyCode:kCode, shiftKey: shift || false });
-};
-
-(function($) {
-
-// Spinner Tests
-module("spinner: core");
-
-test("destroy", function() {
- // cheat a bit to get IE6 to pass
- $("#spin").val(0);
- var beforeHtml = $("#spin").parent().html();
- var afterHtml = $("#spin").spinner().spinner("destroy").parent().html();
- equal( afterHtml, beforeHtml, "before/after html should be the same" );
-});
-
-test("keydown UP on input, increases value not greater than max", function() {
- var el = $("#spin").spinner({
- max:100,
- value:50,
- step:10
- });
-
- simulateKeyDownUp(el, $.ui.keyCode.UP);
- equals(el.val(), 60);
-
- for (i = 0; i<11; i++) {
- simulateKeyDownUp(el, $.ui.keyCode.UP);
- }
- equals(el.val(), 100);
-
- el.spinner("value", 50);
- simulateKeyDownUp(el, $.ui.keyCode.UP);
- equals(el.val(), 60);
-});
-
-test("keydown DOWN on input, decreases value not less than min", function() {
- var el = $("#spin").spinner({
- min:-100,
- value:50,
- step:10
- });
-
- simulateKeyDownUp(el, $.ui.keyCode.DOWN);
- equals(el.val(), 40);
-
- for (i = 0; i<21; i++) {
- simulateKeyDownUp(el, $.ui.keyCode.DOWN);
- }
- equals(el.val(), -100);
-
- el.spinner("value", 50);
- simulateKeyDownUp(el, $.ui.keyCode.DOWN);
- equals(el.val(), 40);
-});
-
-test("keydown PGUP on input, increases value not greater than max", function() {
- var el = $("#spin").spinner({
- max: 500,
- value: 0,
- step: 10
- });
-
- simulateKeyDownUp(el, $.ui.keyCode.PAGE_UP);
- equal(el.val(), 100);
-
- for (i = 0; i<5; i++) {
- simulateKeyDownUp(el, $.ui.keyCode.PAGE_UP);
- }
- equal(el.val(), 500);
-
- el.spinner("value", 0);
- simulateKeyDownUp(el, $.ui.keyCode.PAGE_UP);
- equals(el.val(), 100);
-});
-
-test("keydown PGDN on input, decreases value not less than min", function() {
- var el = $("#spin").spinner({
- min:-500,
- value:0,
- step:10
- });
-
- simulateKeyDownUp(el, $.ui.keyCode.PAGE_DOWN);
- equals(el.val(), -100);
-
- for (i = 0; i<5; i++) {
- simulateKeyDownUp(el, $.ui.keyCode.PAGE_DOWN);
- }
- equals(el.val(), -500);
-
- el.spinner("value", 0);
- simulateKeyDownUp(el, $.ui.keyCode.PAGE_DOWN);
- equals(el.val(), -100);
-});
-
-test("mouse click on buttons", function() {
- var el = $("#spin").spinner(),
- val = 0;
-
- $(".ui-spinner-up").trigger("mousedown").trigger("mouseup");
- equals(el.val(), ++val, "mouse click to up");
-
- $(".ui-spinner-down").trigger("mousedown").trigger("mouseup");
- equals(el.val(), --val, "mouse click to down");
-
- el.spinner("value", 50);
- $(".ui-spinner-up").trigger("mousedown").trigger("mouseup");
- equals(el.val(), 51);
-
- el.spinner("value", 50);
- $(".ui-spinner-down").trigger("mousedown").trigger("mouseup");
- equals(el.val(), 49);
-});
-
-test("mouse wheel on input", function() {
- expect(4);
- stop();
-
- var el = $("#spin").spinner();
- equal(el.val(), 0);
- el.trigger("mousewheel", 1);
- equal(el.val(), 1);
-
- // mousewheel handler uses a timeout, need to accomodate that
- setTimeout(function() {
- el.trigger("mousewheel", -1);
- equal(el.val(), 0);
-
- setTimeout(function() {
- el.trigger("mousewheel", -1);
- equal(el.val(), -1);
- start();
- }, 100);
- }, 100);
-
-});
-
-test("reading HTML5 attributes", function() {
- var el = $('<input id="spinner" type="number" min="-100" max="100" value="5" step="2">').spinner();
- equals(el.spinner('option', 'value'), 5, 'value');
- equals(el.spinner('option', 'max'), 100, 'max');
- equals(el.spinner('option', 'min'), -100, 'min');
- equals(el.spinner('option', 'step'), 2, 'step');
-});
-
-test("ARIA attributes", function() {
- var el = $('#spin').spinner({ min: -5, max: 5, value: 2 });;
-
- equals(el.attr('role'), 'spinbutton', 'role');
- equals(el.attr('aria-valuemin'), -5, 'aria-valuemin');
- equals(el.attr('aria-valuemax'), 5, 'aria-valuemax');
- equals(el.attr('aria-valuenow'), 2, 'aria-valuenow');
-
- el.spinner('stepUp');
-
- equals(el.attr('aria-valuenow'), 3, 'stepUp 1 step changes aria-valuenow');
-
- el.spinner('option', { min: -10, max: 10 });
-
- equals(el.attr('aria-valuemin'), -10, 'min option changed aria-valuemin changes');
- equals(el.attr('aria-valuemax'), 10, 'max option changed aria-valuemax changes');
-});
-
-})(jQuery);
+(function( $ ) { + +module( "spinner: core" ); + +test( "keydown UP on input, increases value not greater than max", function() { + expect( 5 ); + var element = $( "#spin" ).val( 70 ).spinner({ + max: 100, + step: 10 + }); + + spinner_simulateKeyDownUp( element, $.ui.keyCode.UP ); + equal( element.val(), 80 ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.UP ); + equal( element.val(), 90 ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.UP ); + equal( element.val(), 100 ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.UP ); + equal( element.val(), 100 ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.UP ); + equal( element.val(), 100 ); +}); + +test( "keydown DOWN on input, decreases value not less than min", function() { + expect( 5 ); + var element = $( "#spin" ).val( 50 ).spinner({ + min: 20, + step: 10 + }); + + spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN ); + equal( element.val(), 40 ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN ); + equal( element.val(), 30 ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN ); + equal( element.val(), 20 ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN ); + equal( element.val(), 20 ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN ); + equal( element.val(), 20 ); +}); + +test( "keydown PAGE_UP on input, increases value not greater than max", function() { + expect( 5 ); + var element = $( "#spin" ).val( 70 ).spinner({ + max: 100, + page: 10 + }); + + spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP ); + equal( element.val(), 80 ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP ); + equal( element.val(), 90 ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP ); + equal( element.val(), 100 ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP ); + equal( element.val(), 100 ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP ); + equal( element.val(), 100 ); +}); + +test( "keydown PAGE_DOWN on input, decreases value not less than min", function() { + expect( 5 ); + var element = $( "#spin" ).val( 50 ).spinner({ + min: 20, + page: 10 + }); + + spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN ); + equal( element.val(), 40 ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN ); + equal( element.val(), 30 ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN ); + equal( element.val(), 20 ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN ); + equal( element.val(), 20 ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN ); + equal( element.val(), 20 ); +}); + +test( "mouse click on up button, increases value not greater than max", function() { + expect( 3 ); + var element = $( "#spin" ).val( 18 ).spinner({ + max: 20 + }), + button = element.spinner( "widget" ).find( ".ui-spinner-up" ); + + button.trigger( "mousedown" ).trigger( "mouseup" ); + equal( element.val(), 19 ); + button.trigger( "mousedown" ).trigger( "mouseup" ); + equal( element.val(), 20 ); + button.trigger( "mousedown" ).trigger( "mouseup" ); + equal( element.val(), 20 ); +}); + +test( "mouse click on up button, increases value not greater than max", function() { + expect( 3 ); + var element = $( "#spin" ).val( 2 ).spinner({ + min: 0 + }), + button = element.spinner( "widget" ).find( ".ui-spinner-down" ); + + button.trigger( "mousedown" ).trigger( "mouseup" ); + equal( element.val(), 1 ); + button.trigger( "mousedown" ).trigger( "mouseup" ); + equal( element.val(), 0 ); + button.trigger( "mousedown" ).trigger( "mouseup" ); + equal( element.val(), 0 ); +}); + +test( "mousewheel on input", function() { + expect( 5 ); + + var element = $( "#spin" ).spinner({ + step: 2 + }); + + equal( element.val(), 0 ); + + element.trigger( "mousewheel" ); + equal( element.val(), 0, "mousewheel event without delta does not change value" ); + + element.trigger( "mousewheel", 1 ); + equal( element.val(), 2 ); + + element.trigger( "mousewheel", -0.2 ); + equal( element.val(), 0 ); + + element.trigger( "mousewheel", -15 ); + equal(element.val(), -2 ); +}); + +test( "reading HTML5 attributes", function() { + expect( 6 ); + var markup = "<input type='number' min='-100' max='100' value='5' step='2'>", + element = $( markup ).spinner(); + equal( element.spinner( "option", "min" ), -100, "min from markup" ); + equal( element.spinner( "option", "max" ), 100, "max from markup" ); + equal( element.spinner( "option", "step" ), 2, "step from markup" ); + + element = $( markup ).spinner({ + min: -200, + max: 200, + step: 5 + }); + equal( element.spinner( "option", "min" ), -200, "min from options" ); + equal( element.spinner( "option", "max" ), 200, "max from options" ); + equal( element.spinner( "option", "step" ), 5, "stop from options" ); +}); + +test( "ARIA attributes", function() { + expect( 9 ); + var element = $( "#spin" ).val( 2 ).spinner({ min: -5, max: 5 }); + + equal( element.attr( "role" ), "spinbutton", "role" ); + equal( element.attr( "aria-valuemin" ), "-5", "aria-valuemin" ); + equal( element.attr( "aria-valuemax" ), "5", "aria-valuemax" ); + equal( element.attr( "aria-valuenow" ), "2", "aria-valuenow" ); + + element.spinner( "stepUp" ); + + equal( element.attr( "aria-valuenow" ), "3", "stepUp 1 step changes aria-valuenow" ); + + element.spinner( "option", { min: -10, max: 10 } ); + + equal( element.attr( "aria-valuemin" ), "-10", "min option changed aria-valuemin changes" ); + equal( element.attr( "aria-valuemax" ), "10", "max option changed aria-valuemax changes" ); + + element.spinner( "option", "min", null ); + equal( element.attr( "aria-valuemin" ), undefined, "aria-valuemin not set when no min" ); + + element.spinner( "option", "max", null ); + equal( element.attr( "aria-valuemax" ), undefined, "aria-valuemax not set when no max" ); +}); + +test( "focus text field when pressing button", function() { + expect( 2 ); + var element = $( "#spin" ).spinner(); + $( "body" ).focus(); + ok( element[ 0 ] !== document.activeElement, "not focused before" ); + element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown(); + ok( element[ 0 ] === document.activeElement, "focused after" ); +}); + +test( "don't clear invalid value on blur", function() { + expect( 1 ); + var element = $( "#spin" ).spinner(); + element.focus().val( "a" ).blur(); + equal( element.val(), "a" ); +}); + +test( "precision", function() { + expect( 2 ); + var element = $( "#spin" ).val( .05 ).spinner({ + step: .0001 + }); + element.spinner( "stepUp" ); + equal( element.val(), "0.0501", "precision from step" ); + + element.val( 1.05 ).spinner( "option", { + step: 1 + }); + element.spinner( "stepDown" ); + equal( element.val(), "0.05", "precision from value" ); +}); + +})( jQuery ); diff --git a/tests/unit/spinner/spinner_defaults.js b/tests/unit/spinner/spinner_defaults.js index c9a7d5f62..3321f8733 100644 --- a/tests/unit/spinner/spinner_defaults.js +++ b/tests/unit/spinner/spinner_defaults.js @@ -1,15 +1,18 @@ -commonWidgetTests( "spinner", {
- defaults: {
- disabled: false,
- incremental: true,
- max: null,
- min: null,
- numberFormat: null,
- page: 10,
- step: null,
- value: null,
-
- // callbacks
- create: null
- }
-});
+commonWidgetTests( "spinner", { + defaults: { + disabled: false, + incremental: true, + max: null, + min: null, + numberFormat: null, + page: 10, + step: 1, + + // callbacks + change: null, + create: null, + spin: null, + start: null, + stop: null + } +}); diff --git a/tests/unit/spinner/spinner_events.js b/tests/unit/spinner/spinner_events.js index c0771ca2f..e43ba3365 100644 --- a/tests/unit/spinner/spinner_events.js +++ b/tests/unit/spinner/spinner_events.js @@ -1,64 +1,221 @@ -/*
- * spinner_events.js
- */
-(function($) {
-
-module("spinner: events");
-
-test("start", function() {
- var start = 0;
-
- var el = $("#spin").spinner({
- start: function(){
- start++;
- }
- });
-
- simulateKeyDownUp(el, $.ui.keyCode.UP);
-
- equals(start, 1, "Start triggered");
-});
-
-test("spin", function() {
- var spin = 0;
-
- var el = $("#spin").spinner({
- spin: function(){
- spin++;
- }
- });
-
- simulateKeyDownUp(el, $.ui.keyCode.UP);
-
- equals(spin, 1, "Spin triggered");
-});
-
-test("stop", function() {
- var stop = 0;
-
- var el = $("#spin").spinner({
- stop: function(){
- stop++;
- }
- });
-
- simulateKeyDownUp(el, $.ui.keyCode.DOWN);
-
- equals(stop, 1, "Stop triggered");
-});
-
-test("change", function() {
- var change = 0;
-
- var el = $("#spin").spinner({
- change: function(){
- change++;
- }
- });
-
- simulateKeyDownUp(el, $.ui.keyCode.UP);
-
- equals(change, 1, "Change triggered");
-});
-
-})(jQuery);
+(function( $ ) { + +module( "spinner: events" ); + +test( "start", function() { + expect( 6 ); + var element = $( "#spin" ).spinner(); + + function shouldStart( expectation, msg ) { + element.spinner( "option", "start", function() { + ok( expectation, msg ); + }); + } + + shouldStart( true, "key UP" ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.UP ); + shouldStart( true, "key DOWN" ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN ); + + shouldStart( true, "key PAGE_UP" ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP ); + shouldStart( true, "key PAGE_DOWN" ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN ); + + shouldStart( true, "button up" ); + element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup(); + shouldStart( true, "button down" ); + element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup(); + + shouldStart( false, "stepUp" ); + element.spinner( "stepUp" ); + shouldStart( false, "stepDown" ); + element.spinner( "stepDown" ); + + shouldStart( false, "pageUp" ); + element.spinner( "pageUp" ); + shouldStart( false, "pageDown" ); + element.spinner( "pageDown" ); + + shouldStart( false, "value" ); + element.spinner( "value", 999 ); +}); + +test( "spin", function() { + expect( 6 ); + var element = $( "#spin" ).spinner(); + + function shouldSpin( expectation, msg ) { + element.spinner( "option", "spin", function() { + ok( expectation, msg ); + }); + } + + shouldSpin( true, "key UP" ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.UP ); + shouldSpin( true, "key DOWN" ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN ); + + shouldSpin( true, "key PAGE_UP" ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP ); + shouldSpin( true, "key PAGE_DOWN" ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN ); + + shouldSpin( true, "button up" ); + element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup(); + shouldSpin( true, "button down" ); + element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup(); + + shouldSpin( false, "stepUp" ); + element.spinner( "stepUp" ); + shouldSpin( false, "stepDown" ); + element.spinner( "stepDown" ); + + shouldSpin( false, "pageUp" ); + element.spinner( "pageUp" ); + shouldSpin( false, "pageDown" ); + element.spinner( "pageDown" ); + + shouldSpin( false, "value" ); + element.spinner( "value", 999 ); +}); + +test( "stop", function() { + expect( 6 ); + var element = $( "#spin" ).spinner(); + + function shouldStop( expectation, msg ) { + element.spinner( "option", "stop", function() { + ok( expectation, msg ); + }); + } + + shouldStop( true, "key UP" ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.UP ); + shouldStop( true, "key DOWN" ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN ); + + shouldStop( true, "key PAGE_UP" ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP ); + shouldStop( true, "key PAGE_DOWN" ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN ); + + shouldStop( true, "button up" ); + element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup(); + shouldStop( true, "button down" ); + element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup(); + + shouldStop( false, "stepUp" ); + element.spinner( "stepUp" ); + shouldStop( false, "stepDown" ); + element.spinner( "stepDown" ); + + shouldStop( false, "pageUp" ); + element.spinner( "pageUp" ); + shouldStop( false, "pageDown" ); + element.spinner( "pageDown" ); + + shouldStop( false, "value" ); + element.spinner( "value", 999 ); +}); + +test( "change", function() { + expect( 14 ); + var element = $( "#spin" ).spinner(); + + function shouldChange( expectation, msg ) { + element.spinner( "option", "change", function() { + ok( expectation, msg ); + }); + } + + element.focus(); + shouldChange( false, "key UP, before blur" ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.UP ); + shouldChange( true, "blur after key UP" ); + element.blur(); + + element.focus(); + shouldChange( false, "key DOWN, before blur" ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN ); + shouldChange( true, "blur after key DOWN" ); + element.blur(); + + element.focus(); + shouldChange( false, "key PAGE_UP, before blur" ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP ); + shouldChange( true, "blur after key PAGE_UP" ); + element.blur(); + + element.focus(); + shouldChange( false, "key PAGE_DOWN, before blur" ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN ); + shouldChange( true, "blur after key PAGE_DOWN" ); + element.blur(); + + shouldChange( false, "many keys, before blur" ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.UP ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.UP ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.UP ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN ); + shouldChange( true, "blur after many keys" ); + element.blur(); + + shouldChange( false, "many keys, same final value, before blur" ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.UP ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.UP ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN ); + spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN ); + shouldChange( false, "blur after many keys, same final value" ); + + shouldChange( false, "button up, before blur" ); + element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup(); + shouldChange( true, "blur after button up" ); + element.blur(); + + shouldChange( false, "button down, before blur" ); + element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup(); + shouldChange( true, "blur after button down" ); + element.blur(); + + shouldChange( false, "many buttons, same final value, before blur" ); + element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup(); + element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup(); + element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup(); + element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup(); + shouldChange( false, "blur after many buttons, same final value" ); + element.blur(); + + shouldChange( true, "stepUp" ); + element.spinner( "stepUp" ); + + shouldChange( true, "stepDown" ); + element.spinner( "stepDown" ); + + shouldChange( true, "pageUp" ); + element.spinner( "pageUp" ); + + shouldChange( true, "pageDown" ); + element.spinner( "pageDown" ); + + shouldChange( true, "value" ); + element.spinner( "value", 999 ); + + shouldChange( false, "value, same value" ); + element.spinner( "value", 999 ); + + shouldChange( true, "max, value changed" ); + element.spinner( "option", "max", 900 ); + + shouldChange( false, "max, value not changed" ); + element.spinner( "option", "max", 1000 ); + + shouldChange( true, "min, value changed" ); + element.spinner( "option", "min", 950 ); + + shouldChange( false, "min, value not changed" ); + element.spinner( "option", "min", 200 ); +}); + +})( jQuery ); diff --git a/tests/unit/spinner/spinner_methods.js b/tests/unit/spinner/spinner_methods.js index fb58edbdf..fbfcf1bb3 100644 --- a/tests/unit/spinner/spinner_methods.js +++ b/tests/unit/spinner/spinner_methods.js @@ -1,155 +1,162 @@ -/*
- * spinner_methods.js
- */
-(function($) {
-
-module("spinner: methods");
-
-test("disable", function() {
- var el = $("#spin").spinner({ disabled: false }),
- val = el.val(),
- wrapper = $("#spin").spinner("widget");
-
- ok(!wrapper.hasClass("ui-spinner-disabled"), "before: wrapper does not have ui-spinner-disabled class");
- ok(!el.is(':disabled'), "before: input does not have disabled attribute");
-
- el.spinner("disable");
- ok(wrapper.hasClass("ui-spinner-disabled"), "after: wrapper has ui-spinner-disabled class");
- ok(el.is(':disabled'), "after: input has disabled attribute");
-
- simulateKeyDownUp(el, $.ui.keyCode.UP);
- equals(val, el.val(), "keyboard - value does not change on key UP");
-
- simulateKeyDownUp(el, $.ui.keyCode.DOWN);
- equals(val, el.val(), "keyboard - value does not change on key DOWN");
-
- simulateKeyDownUp(el, $.ui.keyCode.PAGE_UP);
- equals(val, el.val(), "keyboard - value does not change on key PGUP");
-
- simulateKeyDownUp(el, $.ui.keyCode.PAGE_DOWN);
- equals(val, el.val(), "keyboard - value does not change on key PGDN");
-
- wrapper.find(":ui-button").first().trigger('mousedown').trigger('mouseup');
- equals(val, el.val(), "mouse - value does not change on clicking up button");
-
- wrapper.find(":ui-button").last().trigger('mousedown').trigger('mouseup');
- equals(val, el.val(), "mouse - value does not change on clicking down button");
-
- el.spinner('stepUp', 6);
- equals(6, el.val(), "script - stepUp 6 steps changes value");
-
- el.spinner('stepDown');
- equals(5, el.val(), "script - stepDown 1 step changes value");
-
- el.spinner('pageUp');
- equals(15, el.val(), "script - pageUp 1 page changes value");
-
- el.spinner('pageDown');
- equals(5, el.val(), "script - pageDown 1 page changes value");
-
-});
-
-test("enable", function() {
- var el = $("#spin").spinner({ disabled: true })
- val = el.val(),
- wrapper = el.spinner("widget");
-
- ok(wrapper.hasClass("ui-spinner-disabled"), "before: wrapper has ui-spinner-disabled class");
- ok(el.is(':disabled'), "before: input has disabled attribute");
-
- el.spinner("enable");
-
- ok(!wrapper.hasClass(".ui-spinner-disabled"), "after: wrapper does not have ui-spinner-disabled class");
- ok(!el.is(':disabled'), "after: input does not have disabled attribute");
-});
-
-test("pageDown", function() {
- var el = $('#spin').spinner({
- step: 2,
- value: 0,
- min: -100
- });
-
- el.spinner('pageDown');
- equals(el.val(), -20, "pageDown 1 page");
-
- el.spinner('pageDown', 3);
- equals(el.val(), -80, "pageDown 3 pages");
-
- el.val(-91).spinner('pageDown');
- equals(el.val(), -100, "value close to min and pageDown 1 page");
-
- el.spinner('pageDown', 10);
- equals(el.val(), -100, "value at min and pageDown 10 pages");
-});
-
-test("pageUp", function() {
- var el = $('#spin').spinner({
- step: 2,
- value: 0,
- max: 100
- });
-
- el.spinner('pageUp');
- equals(el.val(), 20, "pageUp 1 page");
-
- el.spinner('pageUp', 3);
- equals(el.val(), 80, "pageUp 3 pages");
-
- el.val(91).spinner('pageUp');
- equals(el.val(), 100, "value close to max and pageUp 1 page");
-
- el.spinner('pageUp', 10);
- equals(el.val(), 100, "value at max and pageUp 10 pages");
-
-});
-
-test("stepDown", function() {
- expect(4);
-
- el = $('#spin').spinner({ step: 2, page: 5, value: 0, min: -15 });
-
- el.spinner('stepDown')
- equals(el.val(), -2, "stepDown 1 step");
-
- el.spinner('stepDown', 5)
- equals(el.val(), -12, "stepDown 5 steps");
-
- el.spinner('stepDown', 3);
- equals(el.val(), -15, "close to min and stepDown 3 steps");
-
- el.spinner('stepDown');
- equals(el.val(), -15, "at min and stepDown 1 step");
-});
-
-test("stepUp", function() {
- expect(4);
-
- el = $('#spin').spinner({ step: 2, page: 5, value: 0, max: 15 });
-
- el.spinner('stepUp')
- equals(el.val(), 2, "stepUp 1 steps");
-
- el.spinner('stepUp', 5)
- equals(el.val(), 12, "stepUp 5 steps");
-
- el.spinner('stepUp', 3);
- equals(el.val(), 15, "close to min and stepUp 3 steps");
-
- el.spinner('stepUp');
- equals(el.val(), 15, "at min and stepUp 1 step");
-
-});
-
-test("value", function() {
- expect(2);
-
- el = $('#spin').spinner({ value: 0 });
-
- el.spinner('value', 10);
- equals(el.val(), 10, "change value via value method");
-
- equals(10, el.spinner('value'), "get value via value method");
-});
-
-})(jQuery);
+(function( $ ) { + +module( "spinner: methods" ); + +test( "destroy", function() { + expect( 1 ); + domEqual( "#spin", function() { + $( "#spin" ).spinner().spinner( "destroy" ); + }); +}); + +test( "disable", function() { + expect( 14 ); + var element = $( "#spin" ).val( 2 ).spinner(), + wrapper = $( "#spin" ).spinner( "widget" ); + + ok( !wrapper.hasClass( "ui-spinner-disabled" ), "before: wrapper does not have ui-spinner-disabled class" ); + ok( !element.is( ":disabled" ), "before: input does not have disabled attribute" ); + + element.spinner( "disable" ); + ok( wrapper.hasClass( "ui-spinner-disabled" ), "after: wrapper has ui-spinner-disabled class" ); + ok( element.is( ":disabled"), "after: input has disabled attribute" ); + + spinner_simulateKeyDownUp( element, $.ui.keyCode.UP ); + equals( 2, element.val(), "keyboard - value does not change on key UP" ); + + spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN ); + equals( 2, element.val(), "keyboard - value does not change on key DOWN" ); + + spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP ); + equals( 2, element.val(), "keyboard - value does not change on key PGUP" ); + + spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN ); + equals( 2, element.val(), "keyboard - value does not change on key PGDN" ); + + wrapper.find( ".ui-spinner-up" ).trigger( "mousedown" ).trigger( "mouseup" ); + equals( 2, element.val(), "mouse - value does not change on clicking up button" ); + + wrapper.find( ".ui-spinner-down" ).trigger( "mousedown" ).trigger( "mouseup" ); + equals( 2, element.val(), "mouse - value does not change on clicking down button" ); + + element.spinner( "stepUp", 6 ); + equals( 8, element.val(), "script - stepUp 6 steps changes value"); + + element.spinner( "stepDown" ); + equals( 7, element.val(), "script - stepDown 1 step changes value" ); + + element.spinner( "pageUp" ); + equals( 17, element.val(), "script - pageUp 1 page changes value" ); + + element.spinner( "pageDown" ); + equals( 7, element.val(), "script - pageDown 1 page changes value" ); +}); + +test( "enable", function() { + expect( 5 ); + var element = $( "#spin" ).spinner({ disabled: true }) + wrapper = element.spinner( "widget" ); + + ok( wrapper.hasClass( "ui-spinner-disabled" ), "before: wrapper has ui-spinner-disabled class" ); + ok( element.is( ":disabled" ), "before: input has disabled attribute" ); + + element.spinner( "enable" ); + + ok( !wrapper.hasClass( ".ui-spinner-disabled" ), "after: wrapper does not have ui-spinner-disabled class" ); + ok( !element.is( ":disabled" ), "after: input does not have disabled attribute" ); + + spinner_simulateKeyDownUp( element, $.ui.keyCode.UP ); + equals( 1, element.val(), "keyboard - value does not change on key UP" ); +}); + +test( "pageDown", function() { + expect( 4 ); + var element = $( "#spin" ).val( -12 ).spinner({ + page: 20, + min: -100 + }); + + element.spinner( "pageDown" ); + equals( element.val(), -32, "pageDown 1 page" ); + + element.spinner( "pageDown", 3 ); + equals( element.val(), -92, "pageDown 3 pages" ); + + element.spinner( "pageDown" ); + equals( element.val(), -100, "value close to min and pageDown 1 page" ); + + element.spinner( "pageDown", 10 ); + equals( element.val(), -100, "value at min and pageDown 10 pages" ); +}); + +test( "pageUp", function() { + expect( 4 ); + var element = $( "#spin" ).val( 12 ).spinner({ + page: 20, + max: 100 + }); + + element.spinner( "pageUp" ); + equals( element.val(), 32, "pageUp 1 page" ); + + element.spinner( "pageUp", 3 ); + equals( element.val(), 92, "pageUp 3 pages" ); + + element.spinner( "pageUp" ); + equals( element.val(), 100, "value close to max and pageUp 1 page" ); + + element.spinner( "pageUp", 10 ); + equals( element.val(), 100, "value at max and pageUp 10 pages" ); +}); + +test( "stepDown", function() { + expect( 4 ); + var element = $( "#spin" ).val( 0 ).spinner({ + step: 2, + min: -15 + }); + + element.spinner( "stepDown" ); + equals( element.val(), -2, "stepDown 1 step" ); + + element.spinner( "stepDown", 5 ); + equals( element.val(), -12, "stepDown 5 steps" ); + + element.spinner( "stepDown", 4 ); + equals( element.val(), -15, "close to min and stepDown 4 steps" ); + + element.spinner( "stepDown" ); + equals( element.val(), -15, "at min and stepDown 1 step" ); +}); + +test( "stepUp", function() { + expect( 4 ); + var element = $( "#spin" ).val( 0 ).spinner({ + step: 2, + max: 15 + }); + + element.spinner( "stepUp" ); + equals( element.val(), 2, "stepUp 1 step" ); + + element.spinner( "stepUp", 5 ); + equals( element.val(), 12, "stepUp 5 steps" ); + + element.spinner( "stepUp", 4 ); + equals( element.val(), 15, "close to min and stepUp 4 steps" ); + + element.spinner( "stepUp" ); + equals( element.val(), 15, "at max and stepUp 1 step" ); +}); + +test( "value", function() { + expect( 2 ); + var element = $( "#spin" ).val( 0 ).spinner(); + + element.spinner( "value", 10 ); + equals( element.val(), 10, "change value via value method" ); + + equals( element.spinner( "value" ), 10, "get value via value method" ); +}); + +})( jQuery ); diff --git a/tests/unit/spinner/spinner_options.js b/tests/unit/spinner/spinner_options.js index 398780ad2..48bdf96a9 100644 --- a/tests/unit/spinner/spinner_options.js +++ b/tests/unit/spinner/spinner_options.js @@ -1,154 +1,142 @@ -/*
- * spinner_options.js
- */
-(function($) {
-
-module("spinner: options");
-
-test("numberFormat, number", function() {
- var el = $("#spin").spinner({
- value: "1",
- numberFormat: "n"
- });
- equal(el.val(), "1.00");
-});
-
-test("numberFormat, number, simple", function() {
- var el = $("#spin").spinner({
- value: "1",
- numberFormat: "n0"
- });
- equal(el.val(), "1");
-});
-
-test("numberFormat, currency", function() {
- var el = $("#spin").spinner({
- value: "1",
- numberFormat: "C"
- });
- equal(el.val(), "$1.00");
-});
-
-/* TODO figure out how to test this properly
-test("incremental - false (default)", function() {
- var el = $("#spin").spinner({ incremental:false });
-
- for ( var i = 1 ; i<=120 ; i++ ) {
- el.simulate("keydown",{keyCode:$.ui.keyCode.UP});
- }
- el.simulate("keyup",{keyCode:$.ui.keyCode.UP});
-
- equals(el.val(), 120, "incremental false - keydown 120 times");
-
- for ( var i = 1 ; i<=210 ; i++ ) {
- el.simulate("keydown",{keyCode:$.ui.keyCode.DOWN});
- }
- el.simulate("keyup",{keyCode:$.ui.keyCode.DOWN});
-
- equals(el.val(), -90, "incremental false - keydown 210 times");
-});
-
-test("incremental - true (default)", function() {
- var el = $("#spin").spinner();
-
- for ( var i = 1 ; i<=120 ; i++ ) {
- el.simulate("keydown",{keyCode:$.ui.keyCode.UP});
- }
- el.simulate("keyup",{keyCode:$.ui.keyCode.UP});
-
- equals(el.val(), 300, "incremental true - keydown 120 times (100+20*10)");
-
- for ( var i = 1 ; i<=210 ; i++ ) {
- el.simulate("keydown",{keyCode:$.ui.keyCode.DOWN});
- }
- el.simulate("keyup",{keyCode:$.ui.keyCode.DOWN});
-
- equals(el.val(), -1800, "incremental true - keydown 210 times (300-100-100*10-10*100)");
-});
-*/
-
-test("max", function() {
- var el = $("#spin").spinner({ max: 100, value: 1000 });
- equals(el.val(), 100, "max constrained if value option is greater");
-
- el.spinner('value', 1000);
- equals(el.val(), 100, "max constrained if value method is greater");
-
- el.val(1000).blur();
- equals(el.val(), 100, "max constrained if manual entry");
-});
-
-test("min", function() {
- var el = $("#spin").spinner({ min: -100, value: -1000 });
- equals(el.val(), -100, "min constrained if value option is greater");
-
- el.spinner('value', -1000);
- equals(el.val(), -100, "min constrained if value method is greater");
-
- el.val(-1000).blur();
- equals(el.val(), -100, "min constrained if manual entry");
-});
-
-test("step, 2", function() {
- var el = $("#spin").spinner({ step: 2 });
- equals(el.val(), "0", "value initialized to");
-
- for ( var i = 0 ; i < 5 ; i++ ) {
- simulateKeyDownUp(el, $.ui.keyCode.UP);
- }
- equals(el.val(), "10", "UP 5 times with step: 2");
-
- el.spinner('value', '10.5');
- equals(el.val(), "10.5", "value reset to");
-
- el.spinner('option', 'step', 2);
- for ( var i = 0 ; i < 5 ; i++ ) {
- simulateKeyDownUp(el, $.ui.keyCode.UP);
- }
- equals(el.val(), "20.5", "UP 5 times with step: 2");
-});
-
-test("step, 0.7", function() {
- var el = $("#spin").spinner({
- step: 0.7,
- numberFormat: "n1"
- });
- equals(el.val(), "0.0", "value initialized to");
-
- simulateKeyDownUp(el, $.ui.keyCode.DOWN);
- equals(el.val(), "-0.7", "DOWN 1 time with step: 0.7");
-
- for ( var i = 0 ; i < 11 ; i++ ) {
- simulateKeyDownUp(el, $.ui.keyCode.UP);
- }
- equals(el.val(), "7.0", "UP 11 times with step: 0.7");
-});
-
-test("value, default, specified in markup", function() {
- var el = $('#spin2').spinner();
- equals(el.val(), 2, "starting value");
-});
-
-test("value, default, nothing specified", function() {
- var el = $('#spin').spinner();
- equals(el.val(), 0, "starting value");
-});
-
-test("value, override", function() {
- var el = $('#spin').spinner({ value: 100 });
- equals(el.val(), 100, "starting value");
-});
-
-test("value, override markup", function() {
- var el = $('#spin2').spinner({ value: 100 });
- equals(el.val(), 100, "starting value");
-});
-
-test("value, override later", function() {
- var el = $('#spin').spinner();
- equals(el.val(), 0, "starting value");
- el.spinner('option', 'value', 1000);
- equals(el.val(), 1000, "value option changed and set as current value");
-});
-
-})(jQuery);
+(function( $ ) { + +module( "spinner: options" ); + +test( "incremental, false", function() { + expect( 100 ); + + var i, diff, + prev = 0, + element = $( "#spin" ).val( prev ).spinner({ + incremental: false, + spin: function( event, ui ) { + equal( ui.value - prev, 1 ); + prev = ui.value; + } + }); + + for ( i = 0; i < 100; i++ ) { + element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); + } +}); + +test( "incremental, true", function() { + expect( 100 ); + + function fill( num, val ) { + return $.map( new Array( num ), function() { + return val; + }); + } + + var i, diff, + prev = 0, + expected = [].concat( fill( 18, 1 ), fill( 37, 2 ), fill( 14, 3 ), + fill( 9, 4 ), fill( 6, 5 ), fill( 5, 6 ), fill ( 5, 7 ), + fill( 4, 8 ), fill( 2, 9 ) ), + element = $( "#spin" ).val( prev ).spinner({ + incremental: true, + spin: function( event, ui ) { + equal( ui.value - prev, expected[ i ] ); + prev = ui.value; + } + }); + + for ( i = 0; i < 100; i++ ) { + element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); + } +}); + +test( "incremental, function", function() { + expect( 100 ); + + var i, + prev = 0, + element = $( "#spin" ).val( prev ).spinner({ + incremental: function( i ) { + return i; + }, + spin: function( event, ui ) { + equal( ui.value - prev, i + 1 ); + prev = ui.value; + } + }); + + for ( i = 0; i < 100; i++ ) { + element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); + } +}); + +test( "numberFormat, number", function() { + expect( 2 ); + var element = $( "#spin" ).val( 0 ).spinner({ numberFormat: "n" }); + equal( element.val(), "0.00", "formatted on init" ); + element.spinner( "stepUp" ); + equal( element.val(), "1.00", "formatted after step" ); +}); + +test( "numberFormat, number, simple", function() { + expect( 2 ); + var element = $( "#spin" ).val( 0 ).spinner({ numberFormat: "n0" }); + equal( element.val(), "0", "formatted on init" ); + element.spinner( "stepUp" ); + equal( element.val(), "1", "formatted after step" ); +}); + +test( "numberFormat, currency", function() { + expect( 2 ); + var element = $( "#spin" ).val( 0 ).spinner({ numberFormat: "C" }); + equal( element.val(), "$0.00", "formatted on init" ); + element.spinner( "stepUp" ); + equal( element.val(), "$1.00", "formatted after step" ); +}); + +test( "max", function() { + expect( 3 ); + var element = $( "#spin" ).val( 1000 ).spinner({ max: 100 }); + equals( element.val(), 1000, "value not constrained on init" ); + + element.spinner( "value", 1000 ); + equals( element.val(), 100, "max constrained if value method is greater" ); + + element.val( 1000 ).blur(); + equals( element.val(), 1000, "max not constrained if manual entry" ); +}); + +test( "min", function() { + expect( 3 ); + var element = $( "#spin" ).val( -1000 ).spinner({ min: -100 }); + equals( element.val(), -1000, "value not constrained on init" ); + + element.spinner( "value", -1000 ); + equals( element.val(), -100, "min constrained if value method is greater" ); + + element.val( -1000 ).blur(); + equals( element.val(), -1000, "min not constrained if manual entry" ); +}); + +test( "step, 2", function() { + expect( 3 ); + var element = $( "#spin" ).val( 0 ).spinner({ step: 2 }); + + element.spinner( "stepUp" ); + equals( element.val(), "2", "stepUp" ); + + element.spinner( "value", "10.5" ); + equals( element.val(), "10.5", "value reset to 10.5" ); + + element.spinner( "stepUp" ); + equals( element.val(), "12.5", "stepUp" ); +}); + +test( "step, 0.7", function() { + expect( 1 ); + var element = $("#spin").val( 0 ).spinner({ + step: 0.7 + }); + + element.spinner( "stepUp" ); + equals( element.val(), "0.7", "stepUp" ); +}); + +})( jQuery ); diff --git a/tests/unit/spinner/spinner_test_helpers.js b/tests/unit/spinner/spinner_test_helpers.js new file mode 100644 index 000000000..af555dbf2 --- /dev/null +++ b/tests/unit/spinner/spinner_test_helpers.js @@ -0,0 +1,5 @@ +var spinner_simulateKeyDownUp = function( element, keyCode, shift ) { + element + .simulate( "keydown", { keyCode: keyCode, shiftKey: shift || false } ) + .simulate( "keyup", { keyCode: keyCode, shiftKey: shift || false } ); +}; diff --git a/tests/unit/subsuite.js b/tests/unit/subsuite.js new file mode 100644 index 000000000..90dc550f1 --- /dev/null +++ b/tests/unit/subsuite.js @@ -0,0 +1,21 @@ +(function() { + +var versions = [ "1.6", "1.6.1", "1.6.2", "git" ]; + +var additionalTests = { + accordion: [ "accordion_deprecated.html" ], + position: [ "position_deprecated.html" ], + tabs: [ "tabs_deprecated.html" ] +}; + +window.testAllVersions = function( widget ) { + QUnit.testSuites( $.map( + [ widget + ".html" ].concat( additionalTests[ widget ] || [] ), + function( test ) { + return $.map( versions, function( version ) { + return test + "?jquery=" + version; + }); + })); +}; + +}()); diff --git a/tests/unit/subsuiteRunner.css b/tests/unit/subsuiteRunner.css new file mode 100644 index 000000000..bca30a75e --- /dev/null +++ b/tests/unit/subsuiteRunner.css @@ -0,0 +1,8 @@ +iframe.qunit-subsuite { + margin: 0; + padding: 0; + border-width: 1px 0 0; + height: 600px; + width: 100%; + background: #fff; +}
\ No newline at end of file diff --git a/tests/unit/subsuiteRunner.js b/tests/unit/subsuiteRunner.js new file mode 100644 index 000000000..ddfccc7c1 --- /dev/null +++ b/tests/unit/subsuiteRunner.js @@ -0,0 +1,82 @@ +(function( QUnit ) { + +var subsuiteFrame; + +QUnit.extend( QUnit, { + testSuites: function( suites ) { + for ( var i = 0; i < suites.length; i++ ) { + (function( suite ) { + asyncTest( suite, function() { + QUnit.runSuite( suite ); + }); + }( suites[i] ) ); + } + QUnit.done = function() { + subsuiteFrame.style.display = "none"; + }; + }, + + testStart: function( data ) { + // update the test status to show which test suite is running + QUnit.id( "qunit-testresult" ).innerHTML = "Running " + data.name + "...<br> "; + }, + + testDone: function() { + var current = QUnit.id( this.config.current.id ), + children = current.children; + + // undo the auto-expansion of failed tests + for ( var i = 0; i < children.length; i++ ) { + if ( children[i].nodeName === "OL" ) { + children[i].style.display = "none"; + } + } + }, + + runSuite: function( suite ) { + var body = document.getElementsByTagName( "body" )[0], + iframe = subsuiteFrame = document.createElement( "iframe" ), + iframeWin; + + iframe.className = "qunit-subsuite"; + body.appendChild( iframe ); + + function onIframeLoad() { + var module, test, + count = 0; + + QUnit.extend( iframeWin.QUnit, { + moduleStart: function( data ) { + // capture module name for messages + module = data.name; + }, + + testStart: function( data ) { + // capture test name for messages + test = data.name; + }, + + log: function( data ) { + // pass all test details through to the main page + var message = module + ": " + test + ": " + data.message; + expect( ++count ); + QUnit.push( data.result, data.actual, data.expected, message ); + }, + + done: function() { + // start the wrapper test from the main page + start(); + } + }); + } + QUnit.addEvent( iframe, "load", onIframeLoad ); + + iframeWin = iframe.contentWindow; + iframe.setAttribute( "src", suite ); + + this.runSuite = function( suite ) { + iframe.setAttribute( "src", suite ); + }; + } +}); +}( QUnit ) ); diff --git a/tests/unit/tabs/all.html b/tests/unit/tabs/all.html new file mode 100644 index 000000000..e5c41ba9b --- /dev/null +++ b/tests/unit/tabs/all.html @@ -0,0 +1,30 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Tabs Test Suite</title> + + <script src="../../../jquery-1.6.2.js"></script> + + <link rel="stylesheet" href="../../../external/qunit.css"> + <link rel="stylesheet" href="../subsuiteRunner.css"> + <script src="../../../external/qunit.js"></script> + <script src="../subsuiteRunner.js"></script> + <script src="../subsuite.js"></script> + + <script> + testAllVersions( "tabs" ); + </script> +</head> +<body> + +<h1 id="qunit-header">jQuery UI Tabs Test Suite</h1> +<h2 id="qunit-banner"></h2> +<div id="qunit-testrunner-toolbar"></div> +<h2 id="qunit-userAgent"></h2> +<ol id="qunit-tests"></ol> +<div id="qunit-fixture"> + +</div> +</body> +</html> diff --git a/tests/unit/tabs/tabs_core.js b/tests/unit/tabs/tabs_core.js index 98cb617ec..e7c1ee576 100644 --- a/tests/unit/tabs/tabs_core.js +++ b/tests/unit/tabs/tabs_core.js @@ -48,7 +48,7 @@ test( "aria-controls", function() { tabs = element.find( ".ui-tabs-nav a" ); tabs.each(function() { var tab = $( this ); - equal( tab.attr( "href" ).substring( 1 ), tab.attr( "aria-controls" ) ); + equal( tab.prop( "hash" ).substring( 1 ), tab.attr( "aria-controls" ) ); }); element = $( "#tabs2" ).tabs(); diff --git a/tests/unit/testsuites.js b/tests/unit/testsuites.js deleted file mode 100644 index ffe2d3cc0..000000000 --- a/tests/unit/testsuites.js +++ /dev/null @@ -1,76 +0,0 @@ -(function( $, QUnit ) { - -$.extend( QUnit, { - testSuites: function( suites ) { - $.each( suites, function( i, suite ) { - asyncTest( suite, function() { - runSuite( suite ); - }); - }); - }, - - testStart: function( data ) { - // update the test status to show which test suite is running - $( "#qunit-testresult" ).html( "Running " + data.name + "...<br> " ); - }, - - testDone: function() { - // undo the auto-expansion of failed tests - $( "#qunit-tests > li.fail" ).each(function() { - var test = $( this ); - // avoid collapsing test results that the user manually opened - if ( test.data( "auto-collapsed" ) ) { - return; - } - test.data( "auto-collapsed", true ) - .children( "ol" ).hide(); - }); - } -}); - -// generate an iframe to run the test suite and proxy the iframe's QUnit -// to pass all test info to the main page -function runSuite( suite ) { - var body = $( "body" ), - iframe = $( "<iframe>", { src: suite } ) - .css({ - width: 1000, - height: 1000 - }) - .appendTo( body ) - [0], - iframeWin = iframe.contentWindow; - - $( iframeWin ).bind( "load", function() { - var module, test, - count = 0; - - $.extend( iframeWin.QUnit, { - moduleStart: function( data ) { - // capture module name for messages - module = data.name; - }, - - testStart: function( data ) { - // capture test name for messages - test = data.name; - }, - - log: function( data ) { - // pass all test details through to the main page - var message = module + ": " + test + ": " + data.message; - expect( ++count ); - QUnit.push( data.result, data.actual, data.expected, message ); - }, - - done: function() { - // hide the iframe from the main page once the tests are done - // and start the wrapper test from the main page - $( iframe ).hide(); - start(); - } - }); - }); -} - -}( jQuery, QUnit ) ); diff --git a/tests/unit/tooltip/all.html b/tests/unit/tooltip/all.html new file mode 100644 index 000000000..de147a71c --- /dev/null +++ b/tests/unit/tooltip/all.html @@ -0,0 +1,30 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Tooltip Test Suite</title> + + <script src="../../../jquery-1.6.2.js"></script> + + <link rel="stylesheet" href="../../../external/qunit.css"> + <link rel="stylesheet" href="../subsuiteRunner.css"> + <script src="../../../external/qunit.js"></script> + <script src="../subsuiteRunner.js"></script> + <script src="../subsuite.js"></script> + + <script> + testAllVersions( "tooltip" ); + </script> +</head> +<body> + +<h1 id="qunit-header">jQuery UI Tooltip Test Suite</h1> +<h2 id="qunit-banner"></h2> +<div id="qunit-testrunner-toolbar"></div> +<h2 id="qunit-userAgent"></h2> +<ol id="qunit-tests"></ol> +<div id="qunit-fixture"> + +</div> +</body> +</html> diff --git a/tests/unit/widget/all.html b/tests/unit/widget/all.html new file mode 100644 index 000000000..2b14d474d --- /dev/null +++ b/tests/unit/widget/all.html @@ -0,0 +1,30 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Widget Test Suite</title> + + <script src="../../../jquery-1.6.2.js"></script> + + <link rel="stylesheet" href="../../../external/qunit.css"> + <link rel="stylesheet" href="../subsuiteRunner.css"> + <script src="../../../external/qunit.js"></script> + <script src="../subsuiteRunner.js"></script> + <script src="../subsuite.js"></script> + + <script> + testAllVersions( "widget" ); + </script> +</head> +<body> + +<h1 id="qunit-header">jQuery UI Widget Test Suite</h1> +<h2 id="qunit-banner"></h2> +<div id="qunit-testrunner-toolbar"></div> +<h2 id="qunit-userAgent"></h2> +<ol id="qunit-tests"></ol> +<div id="qunit-fixture"> + +</div> +</body> +</html> diff --git a/tests/unit/widget/widget.html b/tests/unit/widget/widget.html index eae47f4a1..7ae41f264 100644 --- a/tests/unit/widget/widget.html +++ b/tests/unit/widget/widget.html @@ -25,9 +25,7 @@ <h2 id="qunit-banner"></h2> <div id="qunit-testrunner-toolbar"></div> <h2 id="qunit-userAgent"></h2> -<ol id="qunit-tests"> -</ol> - +<ol id="qunit-tests"></ol> <div id="qunit-fixture"> <div id="widget-wrapper"> @@ -37,6 +35,5 @@ </div> </div> - </body> </html> diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js index 8cacdd47d..0510da4b4 100644 --- a/tests/unit/widget/widget_core.js +++ b/tests/unit/widget/widget_core.js @@ -571,23 +571,23 @@ test( ".widget() - overriden", function() { test( "._bind() to element (default)", function() { expect( 12 ); - var self; + var that; $.widget( "ui.testWidget", { _create: function() { - self = this; + that = this; this._bind({ keyup: this.keyup, keydown: "keydown" }); }, keyup: function( event ) { - equals( self, this ); - equals( self.element[0], event.currentTarget ); + equals( that, this ); + equals( that.element[0], event.currentTarget ); equals( "keyup", event.type ); }, keydown: function( event ) { - equals( self, this ); - equals( self.element[0], event.currentTarget ); + equals( that, this ); + equals( that.element[0], event.currentTarget ); equals( "keydown", event.type ); } }); @@ -611,23 +611,23 @@ test( "._bind() to element (default)", function() { test( "._bind() to descendent", function() { expect( 12 ); - var self; + var that; $.widget( "ui.testWidget", { _create: function() { - self = this; + that = this; this._bind( this.element.find( "strong" ), { keyup: this.keyup, keydown: "keydown" }); }, keyup: function( event ) { - equals( self, this ); - equals( self.element.find( "strong" )[0], event.currentTarget ); + equals( that, this ); + equals( that.element.find( "strong" )[0], event.currentTarget ); equals( "keyup", event.type ); }, keydown: function(event) { - equals( self, this ); - equals( self.element.find( "strong" )[0], event.currentTarget ); + equals( that, this ); + equals( that.element.find( "strong" )[0], event.currentTarget ); equals( "keydown", event.type ); } }); @@ -673,23 +673,31 @@ test( "_bind() with delegate", function() { this.element = { bind: function( event, handler ) { equal( event, "click.testWidget" ); - ok( $.isFunction(handler) ); - }, - delegate: function( selector, event, handler ) { - equal( selector, "a" ); - equal( event, "click.testWidget" ); - ok( $.isFunction(handler) ); + ok( $.isFunction(handler) ); }, trigger: $.noop }; + this.widget = function() { + return { + delegate: function( selector, event, handler ) { + equal( selector, "a" ); + equal( event, "click.testWidget" ); + ok( $.isFunction(handler) ); + } + }; + }; this._bind({ "click": "handler", - "click a": "handler", + "click a": "handler" }); - this.element.delegate = function( selector, event, handler ) { - equal( selector, "form fieldset > input" ); - equal( event, "change.testWidget" ); - ok( $.isFunction(handler) ); + this.widget = function() { + return { + delegate: function( selector, event, handler ) { + equal( selector, "form fieldset > input" ); + equal( event, "change.testWidget" ); + ok( $.isFunction(handler) ); + } + }; }; this._bind({ "change form fieldset > input": "handler" @@ -979,31 +987,31 @@ test( "._trigger() - instance as element", function() { $( "#widget" ).testWidget().remove(); }); }); - + test( "auto-destroy - .remove() on parent", function() { shouldDestroy( true, function() { $( "#widget" ).testWidget().parent().remove(); }); }); - + test( "auto-destroy - .remove() on child", function() { shouldDestroy( false, function() { $( "#widget" ).testWidget().children().remove(); }); }); - + test( "auto-destroy - .empty()", function() { shouldDestroy( false, function() { $( "#widget" ).testWidget().empty(); }); }); - + test( "auto-destroy - .empty() on parent", function() { shouldDestroy( true, function() { $( "#widget" ).testWidget().parent().empty(); }); }); - + test( "auto-destroy - .detach()", function() { shouldDestroy( false, function() { $( "#widget" ).testWidget().detach(); @@ -1032,4 +1040,30 @@ test( "redefine", function() { equal( $.ui.testWidget.foo, "bar", "static properties remain" ); }); +asyncTest( "_delay", function() { + expect( 6 ); + var order = 0, + that; + $.widget( "ui.testWidget", { + defaultElement: null, + _create: function() { + that = this; + var timer = this._delay(function() { + strictEqual( this, that ); + equal( order, 1 ); + start(); + }, 500); + ok( timer !== undefined ); + timer = this._delay("callback"); + ok( timer !== undefined ); + }, + callback: function() { + strictEqual( this, that ); + equal( order, 0 ); + order += 1; + } + }); + $( "#widget" ).testWidget(); +}); + }( jQuery ) ); diff --git a/tests/unit/widget/widget_extend.js b/tests/unit/widget/widget_extend.js index fb78ecfb7..90e686e18 100644 --- a/tests/unit/widget/widget_extend.js +++ b/tests/unit/widget/widget_extend.js @@ -6,7 +6,6 @@ test( "$.widget.extend()", function() { optionsCopy = { xnumber2: 1, xstring2: "x", xxx: "newstring" }, merged = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "x", xxx: "newstring" }, deep1 = { foo: { bar: true } }, - deep1copy = { foo: { bar: true } }, deep2 = { foo: { baz: true }, foo2: document }, deep2copy = { foo: { baz: true }, foo2: document }, deepmerged = { foo: { bar: true, baz: true }, foo2: document }, @@ -93,10 +92,10 @@ test( "$.widget.extend()", function() { deepEqual( defaults, defaultsCopy, "Check if not modified: options1 must not be modified" ); deepEqual( options1, options1Copy, "Check if not modified: options1 must not be modified" ); deepEqual( options2, options2Copy, "Check if not modified: options2 must not be modified" ); - + var input = { key: [ 1, 2, 3 ] - } + }; var output = $.widget.extend( {}, input ); deepEqual( input, output, "don't clone arrays" ); input.key[0] = 10; diff --git a/tests/visual/all.css b/tests/visual/all.css deleted file mode 100644 index d4b4805a1..000000000 --- a/tests/visual/all.css +++ /dev/null @@ -1,84 +0,0 @@ - -body { font-size: 62.5%; margin: 0; padding: 20px; background: #191919; } -ul.plugins { - margin: 0; - padding: 0; -} -ul.plugins li.plugin { - margin: 0 12px 12px 0; - list-style-type: none; - width: 220px; - height: 220px; - float: left; - color: white; - border: 1px solid gray; - text-align: center; - font-weight: bold; -} -li.plugin { - -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; -} - -#draggable, #resizable, #selectable, #sortable { - margin: 10px; - width: 190px; height: 180px; - text-align: center; - background: #FF9C08; color: white; font-weight: bold; - -moz-border-radius: 2px; -webkit-border-radius: 2px; border-radius: 2px; -} -#accordion { - background: none; - text-align: left; -} -#accordion, #datepicker, #dialog, #progressbar, #slider { - margin: 10px; -} -#datepicker { - margin-left: -40px; -} -#tabs { - margin: 0 10px; -} -#selectable div { - width: 45px; height: 45px; float: left; margin: 6px 8px; - border: 1px solid white; - -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; -} -#selectable .ui-selecting { - background: gray; -} -#selectable .ui-selected { - background: black; -} -#sortable div { - width: 45px; height: 45px; float: left; margin: 6px 8px; - border: 1px solid white; - -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; -} -#sortable .ui-sortable-helper { - background: black; -} -#tabs { - text-align: left; -} - -.draggable { - margin: 10px; - width: 32px; - height: 30px; - float: left; - background: #FF9C08; - -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; -} -#droppable { - margin: 10px; - width: 190px; - height: 130px; - float: left; - border: 1px solid #FF9C08; - overflow: hidden; - -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; -} -#droppable .draggable { - margin: 7px; -} diff --git a/tests/visual/all.html b/tests/visual/all.html deleted file mode 100644 index 4f922e46a..000000000 --- a/tests/visual/all.html +++ /dev/null @@ -1,190 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Simple All</title> - <link rel="stylesheet" href="all.css" type="text/css"> - <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.position.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.accordion.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.menu.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.autocomplete.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.button.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.datepicker.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.dialog.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.draggable.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.droppable.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.progressbar.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.resizable.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.selectable.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.sortable.js"></script> - <script type="text/javascript" src="../../ui/jquery.ui.tabs.js"></script> - <script type="text/javascript"> - $(function() { - $("#accordion").accordion({ header: "h3" }); - $("#autocomplete").autocomplete({ - source: ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", "python", "c", "scala", "groovy", "haskell", "perl"] - }); - $("#button").button(); - $("#buttonset").buttonset(); - $("#datepicker").datepicker(); - $("#dialog button").click(function() { - $("#dlg").clone().dialog(); - }); - $("#draggable").draggable(); - $(".draggable").draggable(); - $("#droppable").droppable({ - accept: '.draggable', - drop: function(ev, ui) { - ui.draggable.css({ position: 'relative', top: 0, left: 0 }).clone().appendTo(this); - } - }); - $("#progressbar").progressbar({ value: 37 }); - $("#resizable").resizable(); - $("#selectable").selectable(); - $("#slider").slider(); - $("#sortable").sortable(); - $("#tabs").tabs(); - }); - </script> -</head> -<body> - -<ul class="plugins"> -<li class="plugin"> - Accordion - <div id="accordion"> - <div> - <h3><a href="#">First</a></h3> - <div> - Lorem ipsum dolor sit amet. - </div> - </div> - <div> - <h3><a href="#">Second</a></h3> - <div> - Phasellus mattis tincidunt nibh. - </div> - </div> - <div> - <h3><a href="#">Third</a></h3> - <div> - Nam dui erat, auctor a, dignissim quis. - </div> - </div> - </div> -</li> -<li class="plugin"> - Autocomplete - <div> - <input id="autocomplete" /> - <select> - <option>iframe test</option> - </select> - </div> -</li> -<li class="plugin"> - Button - <div> - <button id="button">A button element</button> - <form style="margin-top: 1em;"> - <div id="buttonset"> - <input type="radio" id="radio1" name="radio" /><label for="radio1">Choice 1</label> - <input type="radio" id="radio2" name="radio" checked="checked" /><label for="radio2">Choice 2</label> - <input type="radio" id="radio3" name="radio" /><label for="radio3">Choice 3</label> - </div> - </form> - </div> -</li> -<li class="plugin"> - Datepicker - <div> - <input type="text" id="datepicker"> - </div> -</li> -<li class="plugin"> - Dialog - <div id="dialog"> - <button>Open</button> - <div id="dlg" title="Dialog Title"> - <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p> - </div> - </div> -</li> -<li class="plugin"> - Draggable - <div id="draggable"></div> -</li> -<li class="plugin"> - Droppable - <div class="draggable">D</div> - <div class="draggable">R</div> - <div class="draggable">A</div> - <div class="draggable">G</div> - <div id="droppable"> - DROP - <hr> - </div> -</li> -<li class="plugin"> - Progressbar - <div id="progressbar"></div> -</li> -<li class="plugin"> - Resizable - <div id="resizable"></div> -</li> -<li class="plugin"> - Selectable - <div id="selectable"> - <div>1</div> - <div>2</div> - <div>3</div> - <div>4</div> - <div>5</div> - <div>6</div> - <div>7</div> - <div>8</div> - <div>9</div> - </div> -</li> -<li class="plugin"> - Slider - <div id="slider"></div> -</li> -<li class="plugin"> - Sortable - <div id="sortable"> - <div>C</div> - <div>I</div> - <div>G</div> - <div>F</div> - <div>D</div> - <div>H</div> - <div>A</div> - <div>E</div> - <div>B</div> - </div> -</li> -<li class="plugin"> - Tabs - <div id="tabs"> - <ul> - <li><a href="#tabs-1">First</a></li> - <li><a href="#tabs-2">Second</a></li> - <li><a href="#tabs-3">Third</a></li> - </ul> - <div id="tabs-1">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div> - <div id="tabs-2">Phasellus mattis tincidunt nibh. Cras orci urna, blandit id, pretium vel, aliquet ornare, felis. Maecenas scelerisque sem non nisl. Fusce sed lorem in enim dictum bibendum.</div> - <div id="tabs-3">Nam dui erat, auctor a, dignissim quis, sollicitudin eu, felis. Pellentesque nisi urna, interdum eget, sagittis et, consequat vestibulum, lacus. Mauris porttitor ullamcorper augue.</div> - </div> -</li> -</ul> - -</body> -</html> diff --git a/tests/visual/animate/animate_backgroundColor_hex.html b/tests/visual/animate/animate_backgroundColor_hex.html deleted file mode 100644 index e3431abae..000000000 --- a/tests/visual/animate/animate_backgroundColor_hex.html +++ /dev/null @@ -1,44 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Animate Visual Test : Animate backgroundColor hex</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.effects.core.js"></script> - <script type="text/javascript"> - function hexFromRGB (r, g, b) { - var hex = [ - r.toString(16), - g.toString(16), - b.toString(16) - ]; - $.each(hex, function (nr, val) { - if (val.length == 1) { - hex[nr] = '0' + val; - } - }); - return hex.join('').toUpperCase(); - } - function randomColorHex() { - return '#' + hexFromRGB(Math.floor(Math.random()*256), Math.floor(Math.random()*256), Math.floor(Math.random()*256)); - } - $(function() { - $("#go").click(function() { - $("#animate-backgroundColor").stop().animate({ backgroundColor: randomColorHex() }, "fast"); - }); - }) - </script> - <style type="text/css"> - #animate-backgroundColor { width: 100px; height: 100px; background-color: gray; } - </style> -</head> -<body> - -<div id="animate-backgroundColor"></div> - -<button id="go">Go</button> - -</body> -</html> diff --git a/tests/visual/animate/animate_backgroundColor_rgb.html b/tests/visual/animate/animate_backgroundColor_rgb.html deleted file mode 100644 index 762621bb5..000000000 --- a/tests/visual/animate/animate_backgroundColor_rgb.html +++ /dev/null @@ -1,35 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Animate Visual Test : Animate backgroundColor rgb</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.effects.core.js"></script> - <script type="text/javascript"> - function randomColorRGB() { - return 'rgb(' - + Math.floor(Math.random()*256) - + ', ' + Math.floor(Math.random()*256) - + ', ' + Math.floor(Math.random()*256) - + ')'; - } - $(function() { - $("#go").click(function() { - $("#animate-backgroundColor").stop().animate({ backgroundColor: randomColorRGB() }, "fast"); - }); - }) - </script> - <style type="text/css"> - #animate-backgroundColor { width: 100px; height: 100px; background-color: gray; } - </style> -</head> -<body> - -<div id="animate-backgroundColor"></div> - -<button id="go">Go</button> - -</body> -</html> diff --git a/tests/visual/animate/animate_color_hex.html b/tests/visual/animate/animate_color_hex.html deleted file mode 100644 index fb9349111..000000000 --- a/tests/visual/animate/animate_color_hex.html +++ /dev/null @@ -1,44 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Animate Visual Test : Animate color hex</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.effects.core.js"></script> - <script type="text/javascript"> - function hexFromRGB (r, g, b) { - var hex = [ - r.toString(16), - g.toString(16), - b.toString(16) - ]; - $.each(hex, function (nr, val) { - if (val.length == 1) { - hex[nr] = '0' + val; - } - }); - return hex.join('').toUpperCase(); - } - function randomColorHex() { - return '#' + hexFromRGB(Math.floor(Math.random()*256), Math.floor(Math.random()*256), Math.floor(Math.random()*256)); - } - $(function() { - $("#go").click(function() { - $("#animate-color").stop().animate({ color: randomColorHex() }, "fast"); - }); - }) - </script> - <style type="text/css"> - #animate-color { width: 250px; height: 100px; color: gray; } - </style> -</head> -<body> - -<div id="animate-color">Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.</div> - -<button id="go">Go</button> - -</body> -</html> diff --git a/tests/visual/animate/animate_color_rgb.html b/tests/visual/animate/animate_color_rgb.html deleted file mode 100644 index 702b2282f..000000000 --- a/tests/visual/animate/animate_color_rgb.html +++ /dev/null @@ -1,35 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Animate Visual Test : Animate color rgb</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.effects.core.js"></script> - <script type="text/javascript"> - function randomColorRGB() { - return 'rgb(' - + Math.floor(Math.random()*256) - + ', ' + Math.floor(Math.random()*256) - + ', ' + Math.floor(Math.random()*256) - + ')'; - } - $(function() { - $("#go").click(function() { - $("#animate-color").stop().animate({ color: randomColorRGB() }, "fast"); - }); - }) - </script> - <style type="text/css"> - #animate-color { width: 250px; height: 100px; color: gray; } - </style> -</head> -<body> - -<div id="animate-color">Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.</div> - -<button id="go">Go</button> - -</body> -</html> diff --git a/tests/visual/mouse/mouse_ticket_6946.html b/tests/visual/mouse/mouse_ticket_6946.html deleted file mode 100644 index d8d99ef99..000000000 --- a/tests/visual/mouse/mouse_ticket_6946.html +++ /dev/null @@ -1,67 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset=utf-8 /> - <title>Test for Issue #6946</title> - <link rel="stylesheet" href="../all.css" type="text/css"> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css" /> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.sortable.js"></script> - <style type="text/css" media="screen"> - - body { - background: white; - font-size: 90%; - } - .error { - color: #f55; - font-style: italic; - } - #sortable div:hover { - cursor: move; - } - - </style> -</head> -<body> - <h1>Test for Issue #6946</h1> - <p>Use the following list to test the steps listed below:</p> - <div id="sortable"> - <div>One</div> - <div>Two</div> - <div>Three</div> - </div> - <div id="events"></div> - <h2>Expected</h2> - <ol> - <li>Drag an item to a new position in the list and release.</li> - <li>The click event should be received (appropriately suppressed by jQuery UI).</li> - <li>Click the same item.</li> - <li>The click event should be received.</li> - <li>Click the same item again.</li> - <li>The click event should be received.</li> - </ol> - <h2>Experienced (Gecko/Opera)</h2> - <ol> - <li>Drag an item to a new position in the list and release.</li> - <li>The click event is not received <em>(never sent by browser)</em>.</li> - <li>Click the same item.</li> - <li class="error">The click event is not received (erroneously suppressed by jQuery UI).</li> - <li>Click the same item again.</li> - <li>The click event is finally received.</li> - </ol> - <script type="text/javascript"> - - $(function () { - $('#sortable').sortable(); - $('#sortable').bind('click', function () { - $('#events').append('Click event received!<br />'); - }); - }); - - </script> -</body> -</html>
\ No newline at end of file diff --git a/tests/visual/position/position_fit.html b/tests/visual/position/position_fit.html new file mode 100644 index 000000000..a95fa9e01 --- /dev/null +++ b/tests/visual/position/position_fit.html @@ -0,0 +1,148 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8" /> + <title>Position Visual Test: Fit</title> + <link rel="stylesheet" href="../visual.css" type="text/css" /> + <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css" title="ui-theme" /> + <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> + <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> + <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> + <script type="text/javascript" src="../../../ui/jquery.ui.position.js"></script> + <script type="text/javascript" src="../../../ui/jquery.ui.menu.js"></script> + <script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script> + <script type="text/javascript"> + $(function() { + var inputs = $("input"); + $("ul").insertAfter(inputs); + inputs.each(function(index) { + $(this).position({ + my: this.id.replace(/-/, " "), + at: this.id.replace(/-/, " "), + of: "#container"+index, + collision: "none" + }); + if(index < 3) { + $(this).next().menu().position({ + my: "left top", + at: "left bottom", + of: this, + within: "#container"+index, + collision: "fit" + }); + } + if(index >= 3 && index < 6) { + $(this).next().menu().position({ + my: "right top", + at: "right bottom", + of: this, + within: "#container"+index, + collision: "fit" + }); + } + if(index >= 6 && index < 9) { + $(this).next().menu().position({ + my: "center top", + at: "center bottom", + of: this, + within: "#container"+index, + collision: "fit" + }); + } + if(index >= 9 && index < 12) { + $(this).next().menu().position({ + my: "left top", + at: "left bottom", + of: this, + within: "#container"+index, + collision: "fit" + }); + } + if(index >= 12 && index < 15) { + $(this).next().menu().position({ + my: "center center", + at: "center center", + of: this, + within: "#container"+index, + collision: "fit" + }); + } + if(index >= 15) { + $(this).next().menu().position({ + my: "left bottom", + at: "left top", + of: this, + within: "#container"+index, + collision: "fit" + }); + } + }); + }); + </script> + <style> + input, .ui-menu { position: absolute; } + .ui-menu { width: 300px; } + #ui-menu-9, #ui-menu-10, #ui-menu-11, #ui-menu-12, #ui-menu-13, #ui-menu-14, #ui-menu-15, #ui-menu-16, #ui-menu-17 { width: auto; } + html, body { width: 99%; height: 99%; min-height:700px; min-width:700px; } + .container { width: 200px; height: 200px; border: 1px solid black; display:inline-block; margin-left: 230px; margin-top: 15px; margin-bottom: 135px; } + .container2 { width: 200px; height: 100px; border: 1px solid black; display:inline-block; margin-left: 230px; margin-top: 15px; margin-bottom: 135px; } + </style> +</head> +<body> + +<div id="container0" class="container"></div> +<div id="container1" class="container"></div> +<div id="container2" class="container"></div> +<div style="clear:both;"></div> +<div id="container3" class="container"></div> +<div id="container4" class="container"></div> +<div id="container5" class="container"></div> +<div style="clear:both;"></div> +<div id="container6" class="container"></div> +<div id="container7" class="container"></div> +<div id="container8" class="container"></div> +<div style="clear:both;"></div> +<div id="container9" class="container2"></div> +<div id="container10" class="container2"></div> +<div id="container11" class="container2"></div> +<div style="clear:both;"></div> +<div id="container12" class="container2"></div> +<div id="container13" class="container2"></div> +<div id="container14" class="container2"></div> +<div style="clear:both;"></div> +<div id="container15" class="container2"></div> +<div id="container16" class="container2"></div> +<div id="container17" class="container2"></div> + +<input id="left-top" /> +<input id="center-top" /> +<input id="right-top" /> +<input id="left-top" /> +<input id="center-top" /> +<input id="right-top" /> +<input id="left-top" /> +<input id="center-top" /> +<input id="right-top" /> + +<input id="left-top" /> +<input id="center-center" /> +<input id="right-bottom" /> +<input id="left-top" /> +<input id="center-center" /> +<input id="right-bottom" /> +<input id="left-top" /> +<input id="center-center" /> +<input id="right-bottom" /> + +<ul> + <li><a href="#">Java</a></li> + <li><a href="#">JavaScript</a></li> + <li><a href="#">Perl</a></li> + <li><a href="#">Ruby</a></li> + <li><a href="#">C++</a></li> + <li><a href="#">Python</a></li> + <li><a href="#">C#</a></li> +</ul> + +</body> +</html> diff --git a/tests/visual/position/position_flip.html b/tests/visual/position/position_flip.html new file mode 100644 index 000000000..f4a3849ef --- /dev/null +++ b/tests/visual/position/position_flip.html @@ -0,0 +1,77 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8" /> + <title>Position Visual Test: Flip</title> + <link rel="stylesheet" href="../visual.css" type="text/css" /> + <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css" title="ui-theme" /> + <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> + <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> + <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> + <script type="text/javascript" src="../../../ui/jquery.ui.position.js"></script> + <script type="text/javascript" src="../../../ui/jquery.ui.menu.js"></script> + <script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script> + <script type="text/javascript"> + $(function() { + var inputs = $("input"); + $("ul").insertAfter(inputs); + inputs.each(function(index) { + $(this).position({ + my: this.id.replace(/-/, " "), + at: this.id.replace(/-/, " "), + of: "#container"+index, + collision: "none" + }); + $(this).next().menu().position({ + my: "left top", + at: "left bottom", + of: this, + within: "#container"+index + }); + }); + }); + </script> + <style> + input, .ui-menu { position: absolute; } + .ui-menu { width: 300px; } + #ui-menu-6, #ui-menu-7, #ui-menu-8 { width: auto; } + html, body { width: 99%; height: 99%; min-height:700px; min-width:700px; } + .container { width: 200px; height: 200px; border: 1px solid black; display:inline-block; margin-left: 230px; margin-top: 150px; } + </style> +</head> +<body> + +<div id="container0" class="container"></div> +<div id="container1" class="container"></div> +<div id="container2" class="container"></div><br> +<div style="clear:both;"></div> +<div id="container3" class="container" style="width:300px;"></div> +<div id="container4" class="container" style="width:300px;"></div> +<div id="container5" class="container" style="width:300px;"></div> +<div style="clear:both;"></div> +<div id="container6" class="container" style="height:100px; margin-bottom: 500px;"></div> +<div id="container7" class="container" style="height:100px; margin-bottom: 500px;"></div> +<div id="container8" class="container" style="height:100px; margin-bottom: 500px;"></div> + +<input id="left-top" /> +<input id="center-top" /> +<input id="right-top" /> +<input id="left-center" /> +<input id="center-center" /> +<input id="right-center" /> +<input id="left-bottom" /> +<input id="center-center" /> +<input id="right-bottom" /> + +<ul> + <li><a href="#">Java</a></li> + <li><a href="#">JavaScript</a></li> + <li><a href="#">Perl</a></li> + <li><a href="#">Ruby</a></li> + <li><a href="#">C++</a></li> + <li><a href="#">Python</a></li> + <li><a href="#">C#</a></li> +</ul> + +</body> +</html> diff --git a/tests/visual/position/position_flipfit.html b/tests/visual/position/position_flipfit.html new file mode 100644 index 000000000..89ead1098 --- /dev/null +++ b/tests/visual/position/position_flipfit.html @@ -0,0 +1,86 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8" /> + <title>Position Visual Test: FlipFit</title> + <link rel="stylesheet" href="../visual.css" type="text/css" /> + <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css" title="ui-theme" /> + <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> + <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> + <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> + <script type="text/javascript" src="../../../ui/jquery.ui.position.js"></script> + <script type="text/javascript" src="../../../ui/jquery.ui.menu.js"></script> + <script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script> + <script type="text/javascript"> + $(function() { + var inputs = $("input"); + $("ul").insertAfter(inputs); + inputs.each(function(index) { + $(this).position({ + my: this.id.replace(/-/, " "), + at: this.id.replace(/-/, " "), + of: "#container"+index, + collision: "none" + }); + $(this).next().menu().position({ + my: index > 2 && index < 6 ? "right top" : "left top", + at: index > 2 && index < 6 ? "right bottom" : "left bottom", + of: this, + within: "#container"+index, + collision: "flipfit" + }); + }); + }); + </script> + <style> + input, .ui-menu { position: absolute; } + .ui-menu { width: 300px; } + #ui-menu-3, #ui-menu-4, #ui-menu-5 { width: 185px; } + #ui-menu-9, #ui-menu-10, #ui-menu-11 { width: auto; } + html, body { width: 99%; height: 99%; min-height:700px; min-width:700px; } + .container { width: 200px; height: 200px; border: 1px solid black; display:inline-block; margin-left: 230px; margin-top: 150px; } + </style> +</head> +<body> + +<div id="container0" class="container"></div> +<div id="container1" class="container"></div> +<div id="container2" class="container"></div><br> +<div style="clear:both;"></div> +<div id="container3" class="container"></div> +<div id="container4" class="container"></div> +<div id="container5" class="container"></div><br> +<div style="clear:both;"></div> +<div id="container6" class="container" style="width:300px;"></div> +<div id="container7" class="container" style="width:300px;"></div> +<div id="container8" class="container" style="width:300px;"></div> +<div style="clear:both;"></div> +<div id="container9" class="container" style="height:100px; margin-bottom: 500px;"></div> +<div id="container10" class="container" style="height:100px; margin-bottom: 500px;"></div> +<div id="container11" class="container" style="height:100px; margin-bottom: 500px;"></div> + +<input id="left-top" /> +<input id="center-top" /> +<input id="right-top" /> +<input id="left-top" /> +<input id="center-top" /> +<input id="right-top" /> +<input id="left-center" /> +<input id="center-center" /> +<input id="right-center" /> +<input id="left-bottom" /> +<input id="center-center" /> +<input id="right-bottom" /> + +<ul> + <li><a href="#">Java</a></li> + <li><a href="#">JavaScript</a></li> + <li><a href="#">Perl</a></li> + <li><a href="#">Ruby</a></li> + <li><a href="#">C++</a></li> + <li><a href="#">Python</a></li> + <li><a href="#">C#</a></li> +</ul> + +</body> +</html> diff --git a/tests/visual/slider/slider.html b/tests/visual/slider/slider.html deleted file mode 100644 index 816a5e620..000000000 --- a/tests/visual/slider/slider.html +++ /dev/null @@ -1,24 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Default</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("#slider1").slider(); - }); - </script> -</head> -<body> - -<div id="slider1"></div> - -</body> -</html> diff --git a/tests/visual/slider/slider_horizontal.html b/tests/visual/slider/slider_horizontal.html deleted file mode 100644 index 1bc971e08..000000000 --- a/tests/visual/slider/slider_horizontal.html +++ /dev/null @@ -1,27 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider horizontal</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("body").children(":first").slider({ - orientation: 'horizontal', - value: 50 - }); - }); - </script> -</head> -<body> - -<div></div> - -</body> -</html> diff --git a/tests/visual/slider/slider_horizontal_range.html b/tests/visual/slider/slider_horizontal_range.html deleted file mode 100644 index 3b3d60f03..000000000 --- a/tests/visual/slider/slider_horizontal_range.html +++ /dev/null @@ -1,28 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider horizontal range</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("body").children(":first").slider({ - orientation: 'horizontal', - range: true, - values: [25, 75] - }); - }); - </script> -</head> -<body> - -<div></div> - -</body> -</html> diff --git a/tests/visual/slider/slider_horizontal_range_max.html b/tests/visual/slider/slider_horizontal_range_max.html deleted file mode 100644 index 2e52ff0aa..000000000 --- a/tests/visual/slider/slider_horizontal_range_max.html +++ /dev/null @@ -1,28 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider horizontal range max</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("body").children(":first").slider({ - orientation: 'horizontal', - range: 'max', - value: 75 - }); - }); - </script> -</head> -<body> - -<div></div> - -</body> -</html> diff --git a/tests/visual/slider/slider_horizontal_range_min.html b/tests/visual/slider/slider_horizontal_range_min.html deleted file mode 100644 index 7e98fb0c7..000000000 --- a/tests/visual/slider/slider_horizontal_range_min.html +++ /dev/null @@ -1,28 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider horizontal range min</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("body").children(":first").slider({ - orientation: 'horizontal', - range: 'min', - value: 25 - }); - }); - </script> -</head> -<body> - -<div></div> - -</body> -</html> diff --git a/tests/visual/slider/slider_in_container_with_scrollbars.html b/tests/visual/slider/slider_in_container_with_scrollbars.html deleted file mode 100644 index bf5723373..000000000 --- a/tests/visual/slider/slider_in_container_with_scrollbars.html +++ /dev/null @@ -1,43 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider in container with scrollbars</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("#slider").slider({ value: 50 }); - }); - </script> -</head> -<body> - -<h1> -TEST: press UP, DOWN, LEFT, RIGHT, HOME, END on a slider which is inside a container with scrollbars. -</h1> - -<div style="width: 200px; height: 150px; overflow:scroll;"> - -<div style="width: 220px; height: 180px;"> - -<div style="width: 100px; margin-left: 40px; margin-top: 60px;" id="slider"></div> - -</div> - -</div> - -<h2> -ASSERT: the scrollbars do not move when the focus is on the slider handle and an arrow key or HOME or END are pressed. -</h2> -<h2> -ASSERT: the scrollbars move when the focus is not on the slider handle and an arrow key or HOME or END are pressed. -</h2> - -</body> -</html> diff --git a/tests/visual/slider/slider_method_destroy.html b/tests/visual/slider/slider_method_destroy.html deleted file mode 100644 index 5f71871b9..000000000 --- a/tests/visual/slider/slider_method_destroy.html +++ /dev/null @@ -1,28 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider method destroy</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("#slider").slider({ - range: true, - values: [25, 75] - }); - $("#slider").slider("destroy"); - }); - </script> -</head> -<body> - -<div id="slider"></div> - -</body> -</html> diff --git a/tests/visual/slider/slider_method_disable.html b/tests/visual/slider/slider_method_disable.html deleted file mode 100644 index e060ebd70..000000000 --- a/tests/visual/slider/slider_method_disable.html +++ /dev/null @@ -1,47 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider method disable</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("#slider").slider({ - range: true, - values: [25, 75] - }); - $("#slider").slider("disable"); - $(".hover").disableSelection().addClass("ui-corner-all"); - $("#hover-enable").mouseover(function() { - $("#slider").slider("enable"); - }); - $("#hover-disable").mouseover(function() { - $("#slider").slider("disable"); - }); - }); - </script> - <style type="text/css"> - .hover { width: 250px; height: 75px; color: white; font-size: 3em; text-align: center; line-height: 2.5em; cursor: default; margin: 1em 1em 0 0; float: left; } - #hover-enable { background: #4e9a06; } - #hover-disable { background: #cc0000; } - </style> -</head> -<body> - -<a href="#">tab before</a> -<div id="slider"></div> -<a href="#">tab after</a> - -<hr style="margin-top:100px;"/> - -<div id="hover-enable" class="hover">hover to enable</div> -<div id="hover-disable" class="hover">hover to disable</div> - -</body> -</html> diff --git a/tests/visual/slider/slider_option_animate_false.html b/tests/visual/slider/slider_option_animate_false.html deleted file mode 100644 index 2724278db..000000000 --- a/tests/visual/slider/slider_option_animate_false.html +++ /dev/null @@ -1,26 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider option animate false</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("#slider").slider({ - animate: false - }); - }); - </script> -</head> -<body> - -<div id="slider"></div> - -</body> -</html> diff --git a/tests/visual/slider/slider_option_animate_true.html b/tests/visual/slider/slider_option_animate_true.html deleted file mode 100644 index b9c0a50ee..000000000 --- a/tests/visual/slider/slider_option_animate_true.html +++ /dev/null @@ -1,65 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider option animate true</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - - <style type="text/css"> - fieldset { padding: 1em; margin: 1em; } - legend { font-size: 1.3em; font-family: monospace; font-weight: bold; } - #slider1 { margin: 1em; } - #slider2 { margin: 1em; height: 400px; } - </style> - - <script type="text/javascript"> - $(function() { - $("#slider1").slider({ - animate: true, - step: 10 - }); - $("#slider2").slider({ - animate: true, - orientation: 'vertical', - step: 5, - values: [5, 15, 35, 75] - }); - }); - </script> -</head> -<body> - -<fieldset> - <legend>$("#slider1").slider({ - animate: true, - step: 10 - });</legend> -<div id="slider1"></div> -<button onclick="$('#slider1').slider('value', 15);">method value: 15</button> -<button onclick="$('#slider1').slider('value', 75);">method value: 75</button> -<button onclick="$('#slider1').slider('option', 'value', 25);">option value: 25</button> -<button onclick="$('#slider1').slider('option', 'value', 85);">option value: 85</button> -</fieldset> - -<fieldset> - <legend>$("#slider2").slider({ - animate: true, - orientation: 'vertical', - step: 5, - values: [5, 15, 35, 75] - });</legend> -<div id="slider2"></div> -<button onclick="$('#slider2').slider('values', [10, 20, 30, 40]);">method values: [10, 20, 30, 40]</button> -<button onclick="$('#slider2').slider('values', [80, 70, 60, 50]);">method values: [80, 70, 60, 50]</button> -<button onclick="$('#slider2').slider('option', 'values', [20, 30, 40, 50]);">option values: [20, 30, 40, 50]</button> -<button onclick="$('#slider2').slider('option', 'values', [90, 80, 70, 60]);">option values: [90, 80, 70, 60]</button> -</fieldset> - -</body> -</html> diff --git a/tests/visual/slider/slider_option_max_3.html b/tests/visual/slider/slider_option_max_3.html deleted file mode 100644 index 7ef05e009..000000000 --- a/tests/visual/slider/slider_option_max_3.html +++ /dev/null @@ -1,26 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider option max 3</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("#slider").slider({ - max: 3 - }); - }); - </script> -</head> -<body> - -<div id="slider"></div> - -</body> -</html> diff --git a/tests/visual/slider/slider_option_max_30.html b/tests/visual/slider/slider_option_max_30.html deleted file mode 100644 index 7c0203764..000000000 --- a/tests/visual/slider/slider_option_max_30.html +++ /dev/null @@ -1,26 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider option max 30</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("#slider").slider({ - max: 30 - }); - }); - </script> -</head> -<body> - -<div id="slider"></div> - -</body> -</html> diff --git a/tests/visual/slider/slider_option_max_300.html b/tests/visual/slider/slider_option_max_300.html deleted file mode 100644 index df5d13ea4..000000000 --- a/tests/visual/slider/slider_option_max_300.html +++ /dev/null @@ -1,26 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider option max 300</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("#slider").slider({ - max: 300 - }); - }); - </script> -</head> -<body> - -<div id="slider"></div> - -</body> -</html> diff --git a/tests/visual/slider/slider_option_min_-3.html b/tests/visual/slider/slider_option_min_-3.html deleted file mode 100644 index 512d8312c..000000000 --- a/tests/visual/slider/slider_option_min_-3.html +++ /dev/null @@ -1,27 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider option min -3</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("#slider").slider({ - min: -3, - max: 0 - }); - }); - </script> -</head> -<body> - -<div id="slider"></div> - -</body> -</html> diff --git a/tests/visual/slider/slider_option_min_-30.html b/tests/visual/slider/slider_option_min_-30.html deleted file mode 100644 index 7f68b5b42..000000000 --- a/tests/visual/slider/slider_option_min_-30.html +++ /dev/null @@ -1,27 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider option min -30</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("#slider").slider({ - min: -30, - max: 0 - }); - }); - </script> -</head> -<body> - -<div id="slider"></div> - -</body> -</html> diff --git a/tests/visual/slider/slider_option_min_-300.html b/tests/visual/slider/slider_option_min_-300.html deleted file mode 100644 index 0aa6db165..000000000 --- a/tests/visual/slider/slider_option_min_-300.html +++ /dev/null @@ -1,27 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider option min -300</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("#slider").slider({ - min: -300, - max: 0 - }); - }); - </script> -</head> -<body> - -<div id="slider"></div> - -</body> -</html> diff --git a/tests/visual/slider/slider_option_orientation_horizontal.html b/tests/visual/slider/slider_option_orientation_horizontal.html deleted file mode 100644 index a2d61bea9..000000000 --- a/tests/visual/slider/slider_option_orientation_horizontal.html +++ /dev/null @@ -1,26 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider option orientation 'horizontal'</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("#slider").slider({ - orientation: 'horizontal' - }); - }); - </script> -</head> -<body> - -<div id="slider"></div> - -</body> -</html> diff --git a/tests/visual/slider/slider_option_orientation_vertical.html b/tests/visual/slider/slider_option_orientation_vertical.html deleted file mode 100644 index 8b521d70e..000000000 --- a/tests/visual/slider/slider_option_orientation_vertical.html +++ /dev/null @@ -1,26 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider option orientation 'vertical'</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("#slider").slider({ - orientation: 'vertical' - }); - }); - </script> -</head> -<body> - -<div id="slider"></div> - -</body> -</html> diff --git a/tests/visual/slider/slider_option_range_false.html b/tests/visual/slider/slider_option_range_false.html deleted file mode 100644 index 3c8566de7..000000000 --- a/tests/visual/slider/slider_option_range_false.html +++ /dev/null @@ -1,27 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider option range false</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("#slider").slider({ - range: false, - value: 50 - }); - }); - </script> -</head> -<body> - -<div id="slider"></div> - -</body> -</html> diff --git a/tests/visual/slider/slider_option_range_max.html b/tests/visual/slider/slider_option_range_max.html deleted file mode 100644 index be863f08f..000000000 --- a/tests/visual/slider/slider_option_range_max.html +++ /dev/null @@ -1,27 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider option range 'max'</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("#slider").slider({ - range: 'max', - value: 40 - }); - }); - </script> -</head> -<body> - -<div id="slider"></div> - -</body> -</html> diff --git a/tests/visual/slider/slider_option_range_min.html b/tests/visual/slider/slider_option_range_min.html deleted file mode 100644 index 288a7b088..000000000 --- a/tests/visual/slider/slider_option_range_min.html +++ /dev/null @@ -1,27 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider option range 'min'</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("#slider").slider({ - range: 'min', - value: 60 - }); - }); - </script> -</head> -<body> - -<div id="slider"></div> - -</body> -</html> diff --git a/tests/visual/slider/slider_option_range_true.html b/tests/visual/slider/slider_option_range_true.html deleted file mode 100644 index d1d4ffe74..000000000 --- a/tests/visual/slider/slider_option_range_true.html +++ /dev/null @@ -1,27 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider option range true</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("#slider").slider({ - range: true, - values: [25, 75] - }); - }); - </script> -</head> -<body> - -<div id="slider"></div> - -</body> -</html> diff --git a/tests/visual/slider/slider_option_step_25.html b/tests/visual/slider/slider_option_step_25.html deleted file mode 100644 index a55fe1cba..000000000 --- a/tests/visual/slider/slider_option_step_25.html +++ /dev/null @@ -1,26 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider option step 25</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("#slider").slider({ - step: 25 - }); - }); - </script> -</head> -<body> - -<div id="slider"></div> - -</body> -</html> diff --git a/tests/visual/slider/slider_option_step_5.html b/tests/visual/slider/slider_option_step_5.html deleted file mode 100644 index 3099d0082..000000000 --- a/tests/visual/slider/slider_option_step_5.html +++ /dev/null @@ -1,26 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider option step 5</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("#slider").slider({ - step: 5 - }); - }); - </script> -</head> -<body> - -<div id="slider"></div> - -</body> -</html> diff --git a/tests/visual/slider/slider_option_value_3.html b/tests/visual/slider/slider_option_value_3.html deleted file mode 100644 index e1531a27b..000000000 --- a/tests/visual/slider/slider_option_value_3.html +++ /dev/null @@ -1,26 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider option value 3</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("#slider").slider({ - value: 3 - }); - }); - </script> -</head> -<body> - -<div id="slider"></div> - -</body> -</html> diff --git a/tests/visual/slider/slider_option_value_30.html b/tests/visual/slider/slider_option_value_30.html deleted file mode 100644 index 42d76332d..000000000 --- a/tests/visual/slider/slider_option_value_30.html +++ /dev/null @@ -1,26 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider option value 30</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("#slider").slider({ - value: 30 - }); - }); - </script> -</head> -<body> - -<div id="slider"></div> - -</body> -</html> diff --git a/tests/visual/slider/slider_option_values_25_50_75.html b/tests/visual/slider/slider_option_values_25_50_75.html deleted file mode 100644 index 30ca81d6e..000000000 --- a/tests/visual/slider/slider_option_values_25_50_75.html +++ /dev/null @@ -1,26 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider option values 25 50 75</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("#slider").slider({ - values: [25, 50, 75] - }); - }); - </script> -</head> -<body> - -<div id="slider"></div> - -</body> -</html> diff --git a/tests/visual/slider/slider_option_values_25_75.html b/tests/visual/slider/slider_option_values_25_75.html deleted file mode 100644 index 8181e4b6e..000000000 --- a/tests/visual/slider/slider_option_values_25_75.html +++ /dev/null @@ -1,26 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider option values 25 75</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("#slider").slider({ - values: [25, 75] - }); - }); - </script> -</head> -<body> - -<div id="slider"></div> - -</body> -</html> diff --git a/tests/visual/slider/slider_option_values_50.html b/tests/visual/slider/slider_option_values_50.html deleted file mode 100644 index 898ff097f..000000000 --- a/tests/visual/slider/slider_option_values_50.html +++ /dev/null @@ -1,26 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider option values 50</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("#slider").slider({ - values: [50] - }); - }); - </script> -</head> -<body> - -<div id="slider"></div> - -</body> -</html> diff --git a/tests/visual/slider/slider_ticket_3736.html b/tests/visual/slider/slider_ticket_3736.html deleted file mode 100644 index 29e784cdb..000000000 --- a/tests/visual/slider/slider_ticket_3736.html +++ /dev/null @@ -1,36 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider ticket #3736</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("#slider").slider({ - values: [25, 50, 75] - }); - }); - </script> -</head> -<body> - -<h1 class="ui-widget-header"><a href="http://dev.jqueryui.com/ticket/3736">#3736 - Some handles get stuck when using two or more handles</a></h1> - -<h2> -TEST: Move all three handles with the mouse and the keyboard. -</h2> - -<div id="slider"></div> - -<h3> -ASSERT: Each handle can be moved along the full slider, not restricted by value of other handle(s). -</h3> - -</body> -</html> diff --git a/tests/visual/slider/slider_ticket_3762.html b/tests/visual/slider/slider_ticket_3762.html deleted file mode 100644 index 9130d7870..000000000 --- a/tests/visual/slider/slider_ticket_3762.html +++ /dev/null @@ -1,44 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider ticket #3762</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("#slider").slider({ values: [5,0], range: true}); - $("#slider1").slider({ values: [-1,5], range: true}); - $("#slider2").slider({ values: [5,200], range: true}); - $("#slider3").slider({ values: [5,0], range: true}); - $("#slider4").slider({range: true}); - }); - </script> -</head> -<body> - -<h1 class="ui-widget-header"><a href="http://dev.jqueryui.com/ticket/3762">#3762 - slider handles not restricted properly when set programmatically</a></h1> - -<div id="slider"></div> - -<div>- if less than min, set to min</div> -<div id="slider1"></div> - -<div>- if greater than max, set to max</div> -<div id="slider2"></div> - -<div>- if less than previous handle value, set to previous handle value</div> -<div id="slider3"></div> - -<div>no values set</div> -<div id="slider4"></div> - - - -</body> -</html> diff --git a/tests/visual/slider/slider_ticket_4385.html b/tests/visual/slider/slider_ticket_4385.html deleted file mode 100644 index 736e0164e..000000000 --- a/tests/visual/slider/slider_ticket_4385.html +++ /dev/null @@ -1,42 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider ticket #4385</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("#slider").slider({ - range: true, - min: 0, - max: 500, - values: [75, 300], - slide: function(event, ui) { - var minMet = ((ui.values[1] - ui.values[0]) > 50); - minMet && $("#rangevalue").text(ui.values[0] + ' - ' + ui.values[1]); - return minMet; - } - }); - $("#rangevalue").text($("#slider").slider("values", 0) + ' - ' + $("#slider").slider("values", 1)); - }); - </script> -</head> -<body> - -<h1 class="ui-widget-header"><a href="http://dev.jqueryui.com/ticket/4385">#4385 - event slide callback returning false can lead to stuck range handles</a></h1> - -<p> -<label for="rangevalue">Price range:</label> -<span id="rangevalue"></span> -</p> - -<div id="slider"></div> - -</body> -</html> diff --git a/tests/visual/slider/slider_ticket_4467.html b/tests/visual/slider/slider_ticket_4467.html deleted file mode 100644 index 16fe470e2..000000000 --- a/tests/visual/slider/slider_ticket_4467.html +++ /dev/null @@ -1,34 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider ticket #4467</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("#slider").slider({ - range: true, - values: [25, 75] - }); - }); - </script> - <style type="text/css"> - .ui-slider-handle { - width: 100px !important; - } - </style> -</head> -<body> - -<h1 class="ui-widget-header"><a href="http://dev.jqueryui.com/ticket/4467">#4467 - slider handle jumps few pixels right or left if it's clicked on it</a></h1> - -<div id="slider"></div> - -</body> -</html> diff --git a/tests/visual/slider/slider_vertical.html b/tests/visual/slider/slider_vertical.html deleted file mode 100644 index e920a5ff0..000000000 --- a/tests/visual/slider/slider_vertical.html +++ /dev/null @@ -1,27 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider vertical</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("body").children(":first").slider({ - orientation: 'vertical', - value: 50 - }); - }); - </script> -</head> -<body> - -<div></div> - -</body> -</html> diff --git a/tests/visual/slider/slider_vertical_range.html b/tests/visual/slider/slider_vertical_range.html deleted file mode 100644 index 0b5c832ad..000000000 --- a/tests/visual/slider/slider_vertical_range.html +++ /dev/null @@ -1,28 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider vertical range</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("body").children(":first").slider({ - orientation: 'vertical', - range: true, - values: [25, 75] - }); - }); - </script> -</head> -<body> - -<div></div> - -</body> -</html> diff --git a/tests/visual/slider/slider_vertical_range_max.html b/tests/visual/slider/slider_vertical_range_max.html deleted file mode 100644 index bdf943a38..000000000 --- a/tests/visual/slider/slider_vertical_range_max.html +++ /dev/null @@ -1,28 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider vertical range max</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("body").children(":first").slider({ - orientation: 'vertical', - range: 'max', - value: 75 - }); - }); - </script> -</head> -<body> - -<div></div> - -</body> -</html> diff --git a/tests/visual/slider/slider_vertical_range_min.html b/tests/visual/slider/slider_vertical_range_min.html deleted file mode 100644 index d05d9b0c6..000000000 --- a/tests/visual/slider/slider_vertical_range_min.html +++ /dev/null @@ -1,28 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8" /> - <title>Slider Visual Test : Slider vertical range min</title> - <link rel="stylesheet" href="../visual.css" type="text/css" /> - <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css"> - <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> - <script type="text/javascript" src="../../../ui/jquery.ui.slider.js"></script> - <script type="text/javascript"> - $(function() { - $("body").children(":first").slider({ - orientation: 'vertical', - range: 'min', - value: 25 - }); - }); - </script> -</head> -<body> - -<div></div> - -</body> -</html> diff --git a/tests/visual/spinner/spinner.html b/tests/visual/spinner/spinner.html deleted file mode 100644 index 0711b4e2b..000000000 --- a/tests/visual/spinner/spinner.html +++ /dev/null @@ -1,43 +0,0 @@ -<!doctype html>
-<html lang="en">
-<head>
- <title>Spinner Visual Test Page</title>
- <link rel="stylesheet" href="../visual.css" type="text/css" />
- <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css" title="ui-theme" />
- <script type="text/javascript" src="../../../jquery-1.6.2.js"></script>
- <script type="text/javascript" src="../../../external/jquery.mousewheel-3.0.4.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.button.js"></script>
- <script type="text/javascript" src="../../../ui/jquery.ui.spinner.js"></script>
- <script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script>
- <script type="text/javascript">
- $(function() {
- $.fn.themeswitcher && $('<div/>').css({
- position: "absolute",
- right: 10,
- top: 10
- }).appendTo(document.body).themeswitcher();
-
- $('#spinner').spinner({
- start: function(event, ui) {
- console.log(event.type, ui.value, $(this).spinner("value"));
- },
- spin: function(event, ui) {
- console.log(event.type, ui.value, $(this).spinner("value"));
- },
- stop: function(event) {
- console.log(event.type, $(this).spinner("value"));
- },
- change: function(event) {
- console.log(event.type, $(this).spinner("value"));
- }
- });
- });
- </script>
-</head>
-<body>
-
-<p><label for="spinner">Basic with event callbacks:</label> <input id="spinner"></p>
-</body>
-</html>
\ No newline at end of file diff --git a/ui/jquery.effects.core.js b/ui/jquery.effects.core.js index b08cd6cf4..15d81b4b0 100644 --- a/ui/jquery.effects.core.js +++ b/ui/jquery.effects.core.js @@ -415,9 +415,16 @@ $.extend( $.effects, { size = { width: element.width(), height: element.height() - }; + }, + active = document.activeElement; element.wrap( wrapper ); + + // Fixes #7595 - Elements lose focus when wrapped. + if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) { + $( active ).focus(); + } + wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually loose the reference to the wrapped element // transfer positioning properties to the wrapper @@ -449,8 +456,18 @@ $.extend( $.effects, { }, removeWrapper: function( element ) { - if ( element.parent().is( ".ui-effects-wrapper" ) ) - return element.parent().replaceWith( element ); + var active = document.activeElement; + + if ( element.parent().is( ".ui-effects-wrapper" ) ) { + element.parent().replaceWith( element ); + + // Fixes #7595 - Elements lose focus when wrapped. + if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) { + $( active ).focus(); + } + } + + return element; }, diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index 09c3707f0..b871715ba 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -51,7 +51,7 @@ $.widget( "ui.autocomplete", { suppressKeyPress, suppressInput; - this.valueMethod = this.element[ this.element.is( "input" ) ? "val" : "text" ]; + this.valueMethod = this.element[ this.element.is( "input,textarea" ) ? "val" : "text" ]; this.element .addClass( "ui-autocomplete-input" ) @@ -263,6 +263,7 @@ $.widget( "ui.autocomplete", { }, _destroy: function() { + clearTimeout( this.searching ); this.element .removeClass( "ui-autocomplete-input" ) .removeAttr( "autocomplete" ) diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js index ad17ab0c1..1d9393d37 100644 --- a/ui/jquery.ui.button.js +++ b/ui/jquery.ui.button.js @@ -229,7 +229,7 @@ $.widget( "ui.button", { // we don't search against the document in case the element // is disconnected from the DOM var ancestor = this.element.parents().last(), - labelSelector = "label[for=" + this.element.attr("id") + "]"; + labelSelector = "label[for='" + this.element.attr("id") + "']"; this.buttonElement = ancestor.find( labelSelector ); if ( !this.buttonElement.length ) { ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings(); @@ -379,7 +379,7 @@ $.widget( "ui.buttonset", { }, refresh: function() { - var ltr = this.element.css( "direction" ) === "ltr"; + var rtl = this.element.css( "direction" ) === "rtl"; this.buttons = this.element.find( this.options.items ) .filter( ":ui-button" ) @@ -393,10 +393,10 @@ $.widget( "ui.buttonset", { }) .removeClass( "ui-corner-all ui-corner-left ui-corner-right" ) .filter( ":first" ) - .addClass( ltr ? "ui-corner-left" : "ui-corner-right" ) + .addClass( rtl ? "ui-corner-right" : "ui-corner-left" ) .end() .filter( ":last" ) - .addClass( ltr ? "ui-corner-right" : "ui-corner-left" ) + .addClass( rtl ? "ui-corner-left" : "ui-corner-right" ) .end() .end(); }, diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js index 9f7f0b6e1..0b6fb2218 100644 --- a/ui/jquery.ui.datepicker.js +++ b/ui/jquery.ui.datepicker.js @@ -625,6 +625,7 @@ $.extend(Datepicker.prototype, { }, /* Pop-up the date picker for a given input field. + If false returned from beforeShow event handler do not show. @param input element - the input field attached to the date picker or event - if triggered by focus */ _showDatepicker: function(input) { @@ -641,7 +642,12 @@ $.extend(Datepicker.prototype, { $.datepicker._curInst.dpDiv.stop(true, true); } var beforeShow = $.datepicker._get(inst, 'beforeShow'); - extendRemove(inst.settings, (beforeShow ? beforeShow.apply(input, [input, inst]) : {})); + var beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {}; + if(beforeShowSettings === false){ + //false + return; + } + extendRemove(inst.settings, beforeShowSettings); inst.lastVal = null; $.datepicker._lastInput = input; $.datepicker._setDateFromField(inst); @@ -882,7 +888,6 @@ $.extend(Datepicker.prototype, { _selectMonthYear: function(id, select, period) { var target = $(id); var inst = this._getInst(target[0]); - inst._selectingMonthYear = false; inst['selected' + (period == 'M' ? 'Month' : 'Year')] = inst['draw' + (period == 'M' ? 'Month' : 'Year')] = parseInt(select.options[select.selectedIndex].value,10); @@ -890,18 +895,6 @@ $.extend(Datepicker.prototype, { this._adjustDate(target); }, - /* Restore input focus after not changing month/year. */ - _clickMonthYear: function(id) { - var target = $(id); - var inst = this._getInst(target[0]); - if (inst.input && inst._selectingMonthYear) { - setTimeout(function() { - inst.input.focus(); - }, 0); - } - inst._selectingMonthYear = !inst._selectingMonthYear; - }, - /* Action for selecting a day. */ _selectDay: function(id, month, year, td) { var target = $(id); @@ -941,7 +934,8 @@ $.extend(Datepicker.prototype, { else { this._hideDatepicker(); this._lastInput = inst.input[0]; - inst.input.focus(); // restore focus + if (typeof(inst.input[0]) != 'object') + inst.input.focus(); // restore focus this._lastInput = null; } }, @@ -1404,14 +1398,6 @@ $.extend(Datepicker.prototype, { if (inst.input) { inst.input.val(clear ? '' : this._formatDate(inst)); } - - var onSelect = this._get(inst, 'onSelect'); - if (onSelect) { - var dateStr = this._formatDate(inst); - - // trigger custom callback - onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); - } }, /* Retrieve the date(s) directly. */ @@ -1610,7 +1596,6 @@ $.extend(Datepicker.prototype, { var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear); monthHtml += '<select class="ui-datepicker-month" ' + 'onchange="DP_jQuery_' + dpuuid + '.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'M\');" ' + - 'onclick="DP_jQuery_' + dpuuid + '.datepicker._clickMonthYear(\'#' + inst.id + '\');"' + '>'; for (var month = 0; month < 12; month++) { if ((!inMinYear || month >= minDate.getMonth()) && @@ -1644,7 +1629,6 @@ $.extend(Datepicker.prototype, { endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear); inst.yearshtml += '<select class="ui-datepicker-year" ' + 'onchange="DP_jQuery_' + dpuuid + '.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'Y\');" ' + - 'onclick="DP_jQuery_' + dpuuid + '.datepicker._clickMonthYear(\'#' + inst.id + '\');"' + '>'; for (; year <= endYear; year++) { inst.yearshtml += '<option value="' + year + '"' + diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 493ed07e6..065d640fb 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -293,7 +293,7 @@ $.widget("ui.dialog", { // prevent tabbing out of modal dialogs if ( options.modal ) { - uiDialog.bind( "keypress.ui-dialog", function( event ) { + uiDialog.bind( "keydown.ui-dialog", function( event ) { if ( event.keyCode !== $.ui.keyCode.TAB ) { return; } diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js index 549eb5fae..bfe35efb5 100644 --- a/ui/jquery.ui.menu.js +++ b/ui/jquery.ui.menu.js @@ -26,7 +26,6 @@ $.widget( "ui.menu", { } }, _create: function() { - var self = this; this.activeMenu = this.element; this.menuId = this.element.attr( "id" ) || "ui-menu-" + idIncrement++; if ( this.element.find( ".ui-icon" ).length ) { @@ -40,11 +39,11 @@ $.widget( "ui.menu", { }) // need to catch all clicks on disabled menu // not possible through _bind - .bind( "click.menu", function( event ) { - if ( self.options.disabled ) { + .bind( "click.menu", $.proxy( function( event ) { + if ( this.options.disabled ) { event.preventDefault(); } - }); + }, this)); this._bind({ "click .ui-menu-item:has(a)": function( event ) { event.stopImmediatePropagation(); @@ -73,111 +72,111 @@ $.widget( "ui.menu", { this.refresh(); - this.element.attr( "tabIndex", 0 ).bind( "keydown.menu", function( event ) { - if ( self.options.disabled ) { - return; - } - switch ( event.keyCode ) { - case $.ui.keyCode.PAGE_UP: - self.previousPage( event ); - event.preventDefault(); - event.stopImmediatePropagation(); - break; - case $.ui.keyCode.PAGE_DOWN: - self.nextPage( event ); - event.preventDefault(); - event.stopImmediatePropagation(); - break; - case $.ui.keyCode.HOME: - self._move( "first", "first", event ); - event.preventDefault(); - event.stopImmediatePropagation(); - break; - case $.ui.keyCode.END: - self._move( "last", "last", event ); - event.preventDefault(); - event.stopImmediatePropagation(); - break; - case $.ui.keyCode.UP: - self.previous( event ); - event.preventDefault(); - event.stopImmediatePropagation(); - break; - case $.ui.keyCode.DOWN: - self.next( event ); - event.preventDefault(); - event.stopImmediatePropagation(); - break; - case $.ui.keyCode.LEFT: - if (self.collapse( event )) { + this.element.attr( "tabIndex", 0 ); + this._bind({ + "keydown": function( event ) { + switch ( event.keyCode ) { + case $.ui.keyCode.PAGE_UP: + this.previousPage( event ); + event.preventDefault(); event.stopImmediatePropagation(); - } - event.preventDefault(); - break; - case $.ui.keyCode.RIGHT: - if (self.expand( event )) { + break; + case $.ui.keyCode.PAGE_DOWN: + this.nextPage( event ); + event.preventDefault(); event.stopImmediatePropagation(); - } - event.preventDefault(); - break; - case $.ui.keyCode.ENTER: - if ( self.active.children( "a[aria-haspopup='true']" ).length ) { - if ( self.expand( event ) ) { - event.stopImmediatePropagation(); - } - } - else { - self.select( event ); + break; + case $.ui.keyCode.HOME: + this._move( "first", "first", event ); + event.preventDefault(); event.stopImmediatePropagation(); - } - event.preventDefault(); - break; - case $.ui.keyCode.ESCAPE: - if ( self.collapse( event ) ) { + break; + case $.ui.keyCode.END: + this._move( "last", "last", event ); + event.preventDefault(); event.stopImmediatePropagation(); - } - event.preventDefault(); - break; - default: - event.stopPropagation(); - clearTimeout( self.filterTimer ); - var match, - prev = self.previousFilter || "", - character = String.fromCharCode( event.keyCode ), - skip = false; - - if (character == prev) { - skip = true; - } else { - character = prev + character; - } - function escape( value ) { - return value.replace( /[-[\]{}()*+?.,\\^$|#\s]/g , "\\$&" ); - } - match = self.activeMenu.children( ".ui-menu-item" ).filter( function() { - return new RegExp("^" + escape(character), "i") - .test( $( this ).children( "a" ).text() ); - }); - match = skip && match.index(self.active.next()) != -1 ? self.active.nextAll(".ui-menu-item") : match; - if ( !match.length ) { - character = String.fromCharCode(event.keyCode); - match = self.activeMenu.children(".ui-menu-item").filter( function() { + break; + case $.ui.keyCode.UP: + this.previous( event ); + event.preventDefault(); + event.stopImmediatePropagation(); + break; + case $.ui.keyCode.DOWN: + this.next( event ); + event.preventDefault(); + event.stopImmediatePropagation(); + break; + case $.ui.keyCode.LEFT: + if (this.collapse( event )) { + event.stopImmediatePropagation(); + } + event.preventDefault(); + break; + case $.ui.keyCode.RIGHT: + if (this.expand( event )) { + event.stopImmediatePropagation(); + } + event.preventDefault(); + break; + case $.ui.keyCode.ENTER: + if ( this.active.children( "a[aria-haspopup='true']" ).length ) { + if ( this.expand( event ) ) { + event.stopImmediatePropagation(); + } + } + else { + this.select( event ); + event.stopImmediatePropagation(); + } + event.preventDefault(); + break; + case $.ui.keyCode.ESCAPE: + if ( this.collapse( event ) ) { + event.stopImmediatePropagation(); + } + event.preventDefault(); + break; + default: + event.stopPropagation(); + clearTimeout( this.filterTimer ); + var match, + prev = this.previousFilter || "", + character = String.fromCharCode( event.keyCode ), + skip = false; + + if (character == prev) { + skip = true; + } else { + character = prev + character; + } + function escape( value ) { + return value.replace( /[-[\]{}()*+?.,\\^$|#\s]/g , "\\$&" ); + } + match = this.activeMenu.children( ".ui-menu-item" ).filter( function() { return new RegExp("^" + escape(character), "i") .test( $( this ).children( "a" ).text() ); }); - } - if ( match.length ) { - self.focus( event, match ); - if (match.length > 1) { - self.previousFilter = character; - self.filterTimer = setTimeout( function() { - delete self.previousFilter; - }, 1000 ); + match = skip && match.index(this.active.next()) != -1 ? this.active.nextAll(".ui-menu-item") : match; + if ( !match.length ) { + character = String.fromCharCode(event.keyCode); + match = this.activeMenu.children(".ui-menu-item").filter( function() { + return new RegExp("^" + escape(character), "i") + .test( $( this ).children( "a" ).text() ); + }); + } + if ( match.length ) { + this.focus( event, match ); + if (match.length > 1) { + this.previousFilter = character; + this.filterTimer = this._delay( function() { + delete this.previousFilter; + }, 1000 ); + } else { + delete this.previousFilter; + } } else { - delete self.previousFilter; + delete this.previousFilter; } - } else { - delete self.previousFilter; } } }); @@ -221,7 +220,7 @@ $.widget( "ui.menu", { }, refresh: function() { - var self = this, + var that = this, // initialize nested menus submenus = this.element.find( "ul:not(.ui-menu)" ) @@ -241,7 +240,7 @@ $.widget( "ui.menu", { .attr( "tabIndex", -1 ) .attr( "role", "menuitem" ) .attr( "id", function( i ) { - return self.element.attr( "id" ) + "-" + i; + return that.element.attr( "id" ) + "-" + i; }); submenus.each( function() { @@ -255,9 +254,6 @@ $.widget( "ui.menu", { }, focus: function( event, item ) { - var nested, - self = this; - this.blur( event ); if ( this._hasScroll() ) { @@ -279,18 +275,18 @@ $.widget( "ui.menu", { .children( "a" ) .addClass( "ui-state-focus" ) .end(); - self.element.attr( "aria-activedescendant", self.active.children("a").attr("id") ); + this.element.attr( "aria-activedescendant", this.active.children("a").attr("id") ); // highlight active parent menu item, if any this.active.parent().closest(".ui-menu-item").children("a:first").addClass("ui-state-active"); - self.timer = setTimeout( function() { - self._close(); - }, self.delay ); + this.timer = this._delay( function() { + this._close(); + }, this.delay ); - nested = $( ">ul", item ); + var nested = $( ">ul", item ); if ( nested.length && ( /^mouse/.test( event.type ) ) ) { - self._startOpening(nested); + this._startOpening(nested); } this.activeMenu = item.parent(); @@ -319,11 +315,10 @@ $.widget( "ui.menu", { return; } - var self = this; - self.timer = setTimeout( function() { - self._close(); - self._open( submenu ); - }, self.delay ); + this.timer = this._delay( function() { + this._close(); + this._open( submenu ); + }, this.delay ); }, _open: function( submenu ) { @@ -391,15 +386,14 @@ $.widget( "ui.menu", { }, expand: function( event ) { - var self = this, - newItem = this.active && this.active.children("ul").children("li").first(); + var newItem = this.active && this.active.children("ul").children("li").first(); if ( newItem && newItem.length ) { this._open( newItem.parent() ); //timeout so Firefox will not hide activedescendant change in expanding submenu from AT - setTimeout( function() { - self.focus( event, newItem ); + this._delay( function() { + this.focus( event, newItem ); }, 20 ); return true; } diff --git a/ui/jquery.ui.mouse.js b/ui/jquery.ui.mouse.js index 582eaf9c0..888fbedfe 100644 --- a/ui/jquery.ui.mouse.js +++ b/ui/jquery.ui.mouse.js @@ -13,7 +13,7 @@ (function( $, undefined ) { var mouseHandled = false; -$(document).mousedown(function(e) { +$( document ).mouseup( function( e ) { mouseHandled = false; }); @@ -50,7 +50,7 @@ $.widget("ui.mouse", { _mouseDown: function(event) { // don't let more than one widget handle mouseStart - if(mouseHandled) {return}; + if( mouseHandled ) { return }; // we may have missed mouseup (out of window) (this._mouseStarted && this._mouseUp(event)); @@ -59,7 +59,9 @@ $.widget("ui.mouse", { var self = this, btnIsLeft = (event.which == 1), - elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).closest(this.options.cancel).length : false); + // event.target.nodeName works around a bug in IE 8 with + // disabled inputs (#7620) + elIsCancel = (typeof this.options.cancel == "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false); if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) { return true; } diff --git a/ui/jquery.ui.popup.js b/ui/jquery.ui.popup.js index 508209a55..8e5cf198c 100644 --- a/ui/jquery.ui.popup.js +++ b/ui/jquery.ui.popup.js @@ -45,13 +45,13 @@ $.widget( "ui.popup", { .attr( "aria-owns", this.element.attr( "id" ) ); this.element - .addClass( "ui-popup" ) + .addClass( "ui-popup" ); this.close(); this._bind(this.options.trigger, { keydown: function( event ) { // prevent space-to-open to scroll the page, only happens for anchor ui.button - if ( this.options.trigger.is( "a:ui-button" ) && event.keyCode == $.ui.keyCode.SPACE ) { + if ( $.ui.button && this.options.trigger.is( "a:ui-button" ) && event.keyCode == $.ui.keyCode.SPACE ) { event.preventDefault(); } // TODO handle SPACE to open popup? only when not handled by ui.button diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js index 23a98b491..24a033fc2 100644 --- a/ui/jquery.ui.position.js +++ b/ui/jquery.ui.position.js @@ -39,15 +39,16 @@ $.position = { return w1 - w2; }, - getScrollInfo: function( within ) { - var that = within[0], - scrollHeight = within.height() < that.scrollHeight, - scrollWidth = within.width() < that.scrollWidth, - scrollbarWidth = $.position.scrollbarWidth(); + getScrollInfo: function(within) { + var notWindow = within[0] !== window, + overflowX = notWindow ? within.css( "overflow-x" ) : "", + overflowY = notWindow ? within.css( "overflow-y" ) : "", + scrollbarWidth = overflowX === "auto" || overflowX === "scroll" ? $.position.scrollbarWidth() : 0, + scrollbarHeight = overflowY === "auto" || overflowY === "scroll" ? $.position.scrollbarWidth() : 0; return { - height: scrollHeight ? scrollbarWidth : 0, - width : scrollWidth ? scrollbarWidth : 0 + height: within.height() < within[0].scrollHeight ? scrollbarHeight : 0, + width: within.width() < within[0].scrollWidth ? scrollbarWidth : 0 }; } }; @@ -182,13 +183,9 @@ $.fn.position = function( options ) { position.left += myOffset[ 0 ]; position.top += myOffset[ 1 ]; - // prevent fractions (see #5280) - position.left = Math.round( position.left ); - position.top = Math.round( position.top ); - collisionPosition = { - left: position.left - marginLeft, - top: position.top - marginTop + marginLeft: marginLeft, + marginTop: marginTop }; $.each( [ "left", "top" ], function( i, dir ) { @@ -225,18 +222,38 @@ $.ui.position = { isWindow = $.isWindow( data.within[0] ), withinOffset = isWindow ? win.scrollLeft() : within.offset().left, outerWidth = isWindow ? win.width() : within.outerWidth(), - overLeft = withinOffset - data.collisionPosition.left, - overRight = data.collisionPosition.left + data.collisionWidth - outerWidth - withinOffset; - - // element is wider than window or too far left -> align with left edge - if ( data.collisionWidth > outerWidth || overLeft > 0 ) { + collisionPosLeft = position.left - data.collisionPosition.marginLeft, + overLeft = withinOffset - collisionPosLeft, + overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset, + newOverRight, + newOverLeft; + + // element is wider than within + if ( data.collisionWidth > outerWidth ) { + // element is initially over the left side of within + if ( overLeft > 0 && overRight <= 0 ) { + newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset; + position.left += overLeft - newOverRight; + // element is initially over right side of within + } else if ( overRight > 0 && overLeft <= 0 ) { + position.left = withinOffset; + // element is initially over both left and right sides of within + } else { + if ( overLeft > overRight ) { + position.left = withinOffset + outerWidth - data.collisionWidth; + } else { + position.left = withinOffset; + } + } + // too far left -> align with left edge + } else if ( overLeft > 0 ) { position.left += overLeft; // too far right -> align with right edge } else if ( overRight > 0 ) { position.left -= overRight; // adjust based on position and margin } else { - position.left = Math.max( position.left - data.collisionPosition.left, position.left ); + position.left = Math.max( position.left - collisionPosLeft, position.left ); } }, top: function( position, data ) { @@ -245,18 +262,38 @@ $.ui.position = { isWindow = $.isWindow( data.within[0] ), withinOffset = isWindow ? win.scrollTop() : within.offset().top, outerHeight = isWindow ? win.height() : within.outerHeight(), - overTop = withinOffset - data.collisionPosition.top, - overBottom = data.collisionPosition.top + data.collisionHeight - outerHeight - withinOffset; - - // element is taller than window or too far up -> align with top edge - if ( data.collisionHeight > outerHeight || overTop > 0 ) { + collisionPosTop = position.top - data.collisionPosition.marginTop, + overTop = withinOffset - collisionPosTop, + overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset, + newOverTop, + newOverBottom; + + // element is taller than within + if ( data.collisionHeight > outerHeight ) { + // element is initially over the top of within + if ( overTop > 0 && overBottom <= 0 ) { + newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset; + position.top += overTop - newOverBottom; + // element is initially over bottom of within + } else if ( overBottom > 0 && overTop <= 0 ) { + position.top = withinOffset; + // element is initially over both top and bottom of within + } else { + if ( overTop > overBottom ) { + position.top = withinOffset + outerHeight - data.collisionHeight; + } else { + position.top = withinOffset; + } + } + // too far up -> align with top + } else if ( overTop > 0 ) { position.top += overTop; // too far down -> align with bottom edge } else if ( overBottom > 0 ) { position.top -= overBottom; // adjust based on position and margin } else { - position.top = Math.max( position.top - data.collisionPosition.top, position.top ); + position.top = Math.max( position.top - collisionPosTop, position.top ); } } }, @@ -268,14 +305,15 @@ $.ui.position = { data.elem .removeClass( "ui-flipped-left ui-flipped-right" ); - + var within = data.within, win = $( window ), isWindow = $.isWindow( data.within[0] ), - withinOffset = isWindow ? 0 : within.offset().left, + withinOffset = ( isWindow ? 0 : within.offset().left ) + within.scrollLeft(), outerWidth = isWindow ? within.width() : within.outerWidth(), - overLeft = data.collisionPosition.left - withinOffset, - overRight = data.collisionPosition.left + data.collisionWidth - outerWidth - withinOffset, + collisionPosLeft = position.left - data.collisionPosition.marginLeft, + overLeft = collisionPosLeft - withinOffset, + overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset, left = data.my[ 0 ] === "left", myOffset = data.my[ 0 ] === "left" ? -data.elemWidth : @@ -285,30 +323,45 @@ $.ui.position = { atOffset = data.at[ 0 ] === "left" ? data.targetWidth : -data.targetWidth, - offset = -2 * data.offset[ 0 ]; - if ( overLeft < 0 || overRight > 0 ) { - - data.elem - .addClass( "ui-flipped-" + ( overLeft < 0 ? "right" : "left" ) ); - - position.left += myOffset + atOffset + offset; + offset = -2 * data.offset[ 0 ], + newOverRight, + newOverLeft; + + if ( overLeft < 0 ) { + newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset; + if ( newOverRight < 0 || newOverRight < Math.abs( overLeft ) ) { + data.elem + .addClass( "ui-flipped-right" ); + + position.left += myOffset + atOffset + offset; + } + } + else if ( overRight > 0 ) { + newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - withinOffset; + if ( newOverLeft > 0 || Math.abs( newOverLeft ) < overRight ) { + data.elem + .addClass( "ui-flipped-left" ); + + position.left += myOffset + atOffset + offset; + } } }, top: function( position, data ) { if ( data.at[ 1 ] === center ) { return; } - + data.elem .removeClass( "ui-flipped-top ui-flipped-bottom" ); - + var within = data.within, win = $( window ), isWindow = $.isWindow( data.within[0] ), - withinOffset = isWindow ? 0 : within.offset().top, + withinOffset = ( isWindow ? 0 : within.offset().top ) + within.scrollTop(), outerHeight = isWindow ? within.height() : within.outerHeight(), - overTop = data.collisionPosition.top - withinOffset, - overBottom = data.collisionPosition.top + data.collisionHeight - outerHeight - withinOffset, + collisionPosTop = position.top - data.collisionPosition.marginTop, + overTop = collisionPosTop - withinOffset, + overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset, top = data.my[ 1 ] === "top", myOffset = top ? -data.elemHeight : @@ -318,14 +371,37 @@ $.ui.position = { atOffset = data.at[ 1 ] === "top" ? data.targetHeight : -data.targetHeight, - offset = -2 * data.offset[ 1 ]; - if ( overTop < 0 || overBottom > 0 ) { - - data.elem - .addClass( "ui-flipped-" + ( overTop < 0 ? "bottom" : "top" ) ); - - position.top += myOffset + atOffset + offset; + offset = -2 * data.offset[ 1 ], + newOverTop, + newOverBottom; + if ( overTop < 0 ) { + newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset; + if ( newOverBottom < 0 || newOverBottom < Math.abs( overTop ) ) { + data.elem + .addClass( "ui-flipped-bottom" ); + + position.top += myOffset + atOffset + offset; + } } + else if ( overBottom > 0 ) { + newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - withinOffset; + if ( newOverTop > 0 || Math.abs( newOverTop ) < overBottom ) { + data.elem + .addClass( "ui-flipped-top" ); + + position.top += myOffset + atOffset + offset; + } + } + } + }, + flipfit: { + left: function() { + $.ui.position.flip.left.apply( this, arguments ); + $.ui.position.fit.left.apply( this, arguments ); + }, + top: function() { + $.ui.position.flip.top.apply( this, arguments ); + $.ui.position.fit.top.apply( this, arguments ); } } }; diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js index b03c59709..a7fb30cc3 100644 --- a/ui/jquery.ui.spinner.js +++ b/ui/jquery.ui.spinner.js @@ -13,6 +13,17 @@ */ (function( $ ) { +function modifier( fn ) { + return function() { + var previous = this.element.val(); + fn.apply( this, arguments ); + this._refresh(); + if ( previous !== this.element.val() ) { + this._trigger( "change" ); + } + }; +} + $.widget( "ui.spinner", { version: "@VERSION", defaultElement: "<input>", @@ -23,135 +34,121 @@ $.widget( "ui.spinner", { min: null, numberFormat: null, page: 10, - step: null, - value: null + step: 1, + + change: null, + spin: null, + start: null, + stop: null }, _create: function() { + this._value( this.element.val(), true ); this._draw(); - this._markupOptions(); - this._mousewheel(); - this._aria(); + this._bind( this._events ); + this._refresh(); }, - _markupOptions: function() { - var that = this; - $.each({ - min: -Number.MAX_VALUE, - max: Number.MAX_VALUE, - step: 1 - }, function( attr, defaultValue ) { - if ( that.options[ attr ] === null ) { - var value = that.element.attr( attr ); - that.options[ attr ] = typeof value === "string" && value.length > 0 ? - that._parse( value ) : - defaultValue; + _getCreateOptions: function() { + var options = {}, + element = this.element; + + $.each( [ "min", "max", "step" ], function( i, option ) { + var value = element.attr( option ); + if ( value !== undefined && value.length ) { + options[ option ] = value; } }); - this.value( this.options.value !== null ? this.options.value : this.element.val() || 0 ); + + return options; }, - _draw: function() { - var self = this, - options = self.options; + _events: { + keydown: function( event ) { + if ( this._start( event ) && this._keydown( event ) ) { + event.preventDefault(); + } + }, + keyup: "_stop", + focus: function() { + this.uiSpinner.addClass( "ui-state-active" ); + this.previous = this.element.val(); + }, + blur: function( event ) { + this._refresh(); + this.uiSpinner.removeClass( "ui-state-active" ); + if ( this.previous !== this.element.val() ) { + this._trigger( "change", event ); + } + }, + mousewheel: function( event, delta ) { + if ( !delta ) { + return; + } + if ( !this.spinning && !this._start( event ) ) { + return false; + } + + this._spin( (delta > 0 ? 1 : -1) * this.options.step, event ); + clearTimeout( this.mousewheelTimer ); + this.mousewheelTimer = setTimeout(function() { + if ( this.spinning ) { + this._stop( event ); + } + }, 100 ); + event.preventDefault(); + }, + "mousedown .ui-spinner-button": function( event ) { + // ensure focus is on (or stays on) the text field + event.preventDefault(); + if ( document.activeElement !== this.element[ 0 ] ) { + this.element.focus(); + } + + if ( this._start( event ) === false ) { + return; + } + + this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event ); + }, + "mouseup .ui-spinner-button": "_stop", + "mouseenter .ui-spinner-button": function( event ) { + // button will add ui-state-active if mouse was down while mouseleave and kept down + if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) { + return; + } - var uiSpinner = this.uiSpinner = self.element + if ( this._start( event ) === false ) { + return false; + } + this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event ); + }, + // TODO: do we really want to consider this a stop? + // shouldn't we just stop the repeater and wait until mouseup before + // we trigger the stop event? + "mouseleave .ui-spinner-button": "_stop" + }, + + _draw: function() { + var uiSpinner = this.uiSpinner = this.element .addClass( "ui-spinner-input" ) .attr( "autocomplete", "off" ) - .wrap( self._uiSpinnerHtml() ) + .wrap( this._uiSpinnerHtml() ) .parent() // add buttons - .append( self._buttonHtml() ) - // add behaviours - .disableSelection() - // TODO: user ._hoverable - .hover(function() { - if ( !options.disabled ) { - $( this ).addClass( "ui-state-hover" ); - } - self.hovered = true; - }, function() { - $( this ).removeClass( "ui-state-hover" ); - self.hovered = false; - }); - - // TODO: use ._bind() - this.element - .attr( "role", "spinbutton" ) - .bind( "keydown.spinner", function( event ) { - if ( options.disabled ) { - return; - } - if ( self._start( event ) ) { - return self._keydown( event ); - } - return true; - }) - .bind( "keyup.spinner", function( event ) { - if ( options.disabled ) { - return; - } - if ( self.spinning ) { - self._stop( event ); - self._change( event ); - } - }) - .bind( "focus.spinner", function() { - uiSpinner.addClass( "ui-state-active" ); - self.focused = true; - }) - .bind( "blur.spinner", function( event ) { - self.value( self.element.val() ); - if ( !self.hovered ) { - uiSpinner.removeClass( "ui-state-active" ); - } - self.focused = false; - }); + .append( this._buttonHtml() ); + this._hoverable( uiSpinner ); + + this.element.attr( "role", "spinbutton" ); // button bindings this.buttons = uiSpinner.find( ".ui-spinner-button" ) .attr( "tabIndex", -1 ) .button() - .removeClass( "ui-corner-all" ) - .bind( "mousedown", function( event ) { - if ( options.disabled ) { - return; - } - if ( self._start( event ) === false ) { - return false; - } - self._repeat( null, $( this ).hasClass( "ui-spinner-up" ) ? 1 : -1, event ); - }) - .bind( "mouseup", function( event ) { - if ( options.disabled ) { - return; - } - if ( self.spinning ) { - self._stop( event ); - self._change( event ); - } - }) - .bind( "mouseenter", function() { - if ( self.options.disabled ) { - return; - } - // button will add ui-state-active if mouse was down while mouseleave and kept down - if ( $( this ).hasClass( "ui-state-active" ) ) { - if ( self._start( event ) === false ) { - return false; - } - self._repeat( null, $( this ).hasClass( "ui-spinner-up" ) ? 1 : -1, event ); - } - }) - .bind( "mouseleave", function() { - if ( self.spinning ) { - self._stop( event ); - self._change( event ); - } - }); + .removeClass( "ui-corner-all" ); // disable spinner if element was already disabled - if ( options.disabled ) { + if ( this.options.disabled ) { this.disable(); } }, @@ -163,46 +160,19 @@ $.widget( "ui.spinner", { switch ( event.keyCode ) { case keyCode.UP: this._repeat( null, 1, event ); - return false; + return true; case keyCode.DOWN: this._repeat( null, -1, event ); - return false; + return true; case keyCode.PAGE_UP: this._repeat( null, options.page, event ); - return false; + return true; case keyCode.PAGE_DOWN: this._repeat( null, -options.page, event ); - return false; - case keyCode.ENTER: - this.value( this.element.val() ); + return true; } - return true; - }, - - _mousewheel: function() { - // need the delta normalization that mousewheel plugin provides - if ( !$.fn.mousewheel ) { - return; - } - var self = this; - this.element.bind( "mousewheel.spinner", function( event, delta ) { - if ( self.options.disabled || !delta ) { - return; - } - if ( !self.spinning && !self._start( event ) ) { - return false; - } - self._spin( (delta > 0 ? 1 : -1) * self.options.step, event ); - clearTimeout( self.timeout ); - self.timeout = setTimeout(function() { - if ( self.spinning ) { - self._stop( event ); - self._change( event ); - } - }, 100); - event.preventDefault(); - }); + return false; }, _uiSpinnerHtml: function() { @@ -232,15 +202,15 @@ $.widget( "ui.spinner", { }, _repeat: function( i, steps, event ) { - var self = this; + var that = this; i = i || 500; clearTimeout( this.timer ); this.timer = setTimeout(function() { - self._repeat( 40, steps, event ); + that._repeat( 40, steps, event ); }, i ); - self._spin( steps * self.options.step, event ); + this._spin( steps * this.options.step, event ); }, _spin: function( step, event ) { @@ -248,33 +218,46 @@ $.widget( "ui.spinner", { this.counter = 1; } - // TODO refactor, maybe figure out some non-linear math - var newVal = this.value() + step * (this.options.incremental && - this.counter > 20 - ? this.counter > 100 - ? this.counter > 200 - ? 100 - : 10 - : 2 - : 1); - - // clamp the new value - newVal = this._trimValue( newVal ); - - if ( this._trigger( "spin", event, { value: newVal } ) !== false) { - this.value( newVal ); + var value = this.value(), + newVal = value + step * this._increment( this.counter ), + // fix precision from bad JS floating point math + precision = Math.max( this._precision( value ), + this._precision( this.options.step ) ); + // clamp the new value + newVal = this._trimValue( newVal.toFixed( precision ) ); + + if ( !this.spinning || this._trigger( "spin", event, { value: newVal } ) !== false) { + this._value( newVal ); this.counter++; } }, + _increment: function( i ) { + var incremental = this.options.incremental; + + if ( incremental ) { + return $.isFunction( incremental ) ? + incremental( i ) : + Math.floor( i*i*i/50000 - i*i/500 + 17*i/200 + 1 ); + } + + return 1; + }, + + _precision: function( num ) { + var str = num.toString(), + decimal = str.indexOf( "." ); + return decimal === -1 ? 0 : str.length - decimal - 1; + }, + _trimValue: function( value ) { var options = this.options; - if ( value > options.max) { + if ( options.max != null && value > options.max) { return options.max; } - if ( value < options.min ) { + if ( options.min != null && value < options.min ) { return options.min; } @@ -282,23 +265,19 @@ $.widget( "ui.spinner", { }, _stop: function( event ) { - this.counter = 0; - if ( this.timer ) { - clearTimeout( this.timer ); + if ( !this.spinning ) { + return; } - this.element.focus(); + + clearTimeout( this.timer ); + clearTimeout( this.mousewheelTimer ); + this.counter = 0; this.spinning = false; this._trigger( "stop", event ); }, - _change: function( event ) { - this._trigger( "change", event ); - }, - _setOption: function( key, value ) { - if ( key === "value") { - value = this._trimValue( this._parse(value) ); - } + this._super( "_setOption", key, value ); if ( key === "disabled" ) { if ( value ) { @@ -309,35 +288,52 @@ $.widget( "ui.spinner", { this.buttons.button( "enable" ); } } - - this._super( "_setOption", key, value ); }, - _setOptions: function( options ) { + _setOptions: modifier(function( options ) { this._super( "_setOptions", options ); - if ( "value" in options ) { - this._format( this.options.value ); + this._value( this.element.val() ); + }), + + _parse: function( val ) { + if ( typeof val === "string" ) { + val = window.Globalize && this.options.numberFormat ? Globalize.parseFloat( val ) : +val; } - this._aria(); + return isNaN( val ) ? null : val; }, - _aria: function() { + _format: function( value ) { + if ( value === "" ) { + return ""; + } + return window.Globalize && this.options.numberFormat ? + Globalize.format( value, this.options.numberFormat ) : + value; + }, + + _refresh: function() { this.element.attr({ "aria-valuemin": this.options.min, "aria-valuemax": this.options.max, - "aria-valuenow": this.options.value + // TODO: what should we do with values that can't be parsed? + "aria-valuenow": this._parse( this.element.val() ) }); }, - _parse: function( val ) { - if ( typeof val === "string" ) { - val = $.global && this.options.numberFormat ? $.global.parseFloat( val ) : +val; + // update the value without triggering change + _value: function( value, ignoreRange ) { + var parsed; + if ( value !== "" ) { + parsed = this._parse( value ); + if ( parsed !== null ) { + if ( !ignoreRange ) { + parsed = this._trimValue( parsed ); + } + value = this._format( parsed ); + } } - return isNaN( val ) ? null : val; - }, - - _format: function( num ) { - this.element.val( $.global && this.options.numberFormat ? $.global.format( num, this.options.numberFormat ) : num ); + this.element.val( value ); + this._refresh(); }, destroy: function() { @@ -353,27 +349,33 @@ $.widget( "ui.spinner", { this.uiSpinner.replaceWith( this.element ); }, - stepUp: function( steps ) { + stepUp: modifier(function( steps ) { + this._stepUp( steps ); + }), + _stepUp: function( steps ) { this._spin( (steps || 1) * this.options.step ); }, - stepDown: function( steps ) { + stepDown: modifier(function( steps ) { + this._stepDown( steps ); + }), + _stepDown: function( steps ) { this._spin( (steps || 1) * -this.options.step ); }, - pageUp: function( pages ) { - this.stepUp( (pages || 1) * this.options.page ); - }, + pageUp: modifier(function( pages ) { + this._stepUp( (pages || 1) * this.options.page ); + }), - pageDown: function( pages ) { - this.stepDown( (pages || 1) * this.options.page ); - }, + pageDown: modifier(function( pages ) { + this._stepDown( (pages || 1) * this.options.page ); + }), value: function( newVal ) { if ( !arguments.length ) { return this._parse( this.element.val() ); } - this.option( "value", newVal ); + modifier( this._value ).call( this, newVal ); }, widget: function() { diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index 515a93ae0..a1bf72cb1 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -18,6 +18,19 @@ function getNextTabId() { return ++tabId; } +var isLocal = (function() { + var rhash = /#.*$/, + currentPage = location.href.replace( rhash, "" ); + + return function( anchor ) { + // clone the node to work around IE 6 not normalizing the href property + // if it's manually set, i.e., a.href = "#foo" kills the normalization + anchor = anchor.cloneNode( false ); + return anchor.hash.length > 1 && + anchor.href.replace( rhash, "" ) === currentPage; + }; +})(); + $.widget( "ui.tabs", { version: "@VERSION", options: { @@ -197,8 +210,7 @@ $.widget( "ui.tabs", { }, _processTabs: function() { - var self = this, - fragmentId = /^#.+/; // Safari 2 reports '#' for an empty hash + var self = this; this.list = this.element.find( "ol,ul" ).eq( 0 ); this.lis = $( " > li:has(a[href])", this.list ); @@ -208,30 +220,14 @@ $.widget( "ui.tabs", { this.panels = $( [] ); this.anchors.each(function( i, a ) { - var href = $( a ).attr( "href" ), - hrefBase = href.split( "#" )[ 0 ], - selector, - panel, - baseEl; - - // For dynamically created HTML that contains a hash as href IE < 8 expands - // such href to the full page url with hash and then misinterprets tab as ajax. - // Same consideration applies for an added tab with a fragment identifier - // since a[href=#fragment-identifier] does unexpectedly not match. - // Thus normalize href attribute... - if ( hrefBase && ( hrefBase === location.toString().split( "#" )[ 0 ] || - ( baseEl = $( "base" )[ 0 ]) && hrefBase === baseEl.href ) ) { - href = a.hash; - a.href = href; - } + var selector, panel; // inline tab - if ( fragmentId.test( href ) ) { - selector = href; + if ( isLocal( a ) ) { + selector = a.hash; panel = self.element.find( self._sanitizeSelector( selector ) ); // remote tab - // prevent loading the page itself if href is just "#" - } else if ( href && href !== "#" ) { + } else { var id = self._tabId( a ); selector = "#" + id; panel = self.element.find( selector ); @@ -239,9 +235,6 @@ $.widget( "ui.tabs", { panel = self._createPanel( id ); panel.insertAfter( self.panels[ i - 1 ] || self.list ); } - // invalid tab href - } else { - self.options.disabled.push( i ); } if ( panel.length) { @@ -354,7 +347,7 @@ $.widget( "ui.tabs", { if ( toShow.length ) { - // TODO make passing in node possible, see also http://dev.jqueryui.com/ticket/3171 + // TODO make passing in node possible that.load( that.anchors.index( clicked ), event ); clicked[ 0 ].blur(); @@ -449,12 +442,10 @@ $.widget( "ui.tabs", { this.list.removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" ); - this.anchors.each(function() { - var $this = $( this ).unbind( ".tabs" ); - $.each( [ "href", "load" ], function( i, prefix ) { - $this.removeData( prefix + ".tabs" ); - }); - }); + this.anchors + .unbind( ".tabs" ) + .removeData( "href.tabs" ) + .removeData( "load.tabs" ); this.lis.unbind( ".tabs" ).add( this.panels ).each(function() { if ( $.data( this, "destroy.tabs" ) ) { @@ -527,21 +518,18 @@ $.widget( "ui.tabs", { options = this.options, anchor = this.anchors.eq( index ), panel = self._getPanelForTab( anchor ), - // TODO until #3808 is fixed strip fragment identifier from url - // (IE fails to load from such url) - url = anchor.attr( "href" ).replace( /#.*$/, "" ), eventData = { tab: anchor, panel: panel }; // not remote - if ( !url ) { + if ( isLocal( anchor[ 0 ] ) ) { return; } this.xhr = $.ajax({ - url: url, + url: anchor.attr( "href" ), beforeSend: function( jqXHR, settings ) { return self._trigger( "beforeLoad", event, $.extend( { jqXHR : jqXHR, ajaxSettings: settings }, eventData ) ); @@ -804,11 +792,14 @@ if ( $.uiBackCompat !== false ) { index = this._getIndex( index ); var options = this.options, tab = this.lis.eq( index ).remove(), - panel = this.panels.eq( index ).remove(); + panel = this._getPanelForTab( tab.find( "a[aria-controls]" ) ).remove(); // If selected tab was removed focus tab to the right or // in case the last tab was removed the tab to the left. - if ( tab.hasClass( "ui-tabs-active" ) && this.anchors.length > 1) { + // We check for more than 2 tabs, because if there are only 2, + // then when we remove this tab, there will only be one tab left + // so we don't need to detect which tab to activate. + if ( tab.hasClass( "ui-tabs-active" ) && this.anchors.length > 2 ) { this._activate( index + ( index + 1 < this.anchors.length ? 1 : -1 ) ); } diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index 5e32459fc..2f8d92969 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -27,7 +27,7 @@ $.widget( "ui.tooltip", { position: { my: "left+15 center", at: "right center", - collision: "flip fit" + collision: "flipfit flipfit" }, show: true, tooltipClass: null, diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index a66b8a54a..31328a455 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -14,7 +14,10 @@ var slice = Array.prototype.slice; var _cleanData = $.cleanData; $.cleanData = function( elems ) { for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { - $( elem ).triggerHandler( "remove" ); + try { + $( elem ).triggerHandler( "remove" ); + // http://bugs.jquery.com/ticket/8235 + } catch( e ) {} } _cleanData( elems ); }; @@ -267,9 +270,9 @@ $.Widget.prototype = { return this; }, _setOptions: function( options ) { - var self = this; + var that = this; $.each( options, function( key, value ) { - self._setOption( key, value ); + that._setOption( key, value ); }); return this; @@ -323,13 +326,22 @@ $.Widget.prototype = { eventName = match[1] + "." + instance.widgetName, selector = match[2]; if ( selector ) { - element.delegate( selector, eventName, handlerProxy ); + instance.widget().delegate( selector, eventName, handlerProxy ); } else { element.bind( eventName, handlerProxy ); } }); }, + _delay: function( handler, delay ) { + function handlerProxy() { + return ( typeof handler === "string" ? instance[ handler ] : handler ) + .apply( instance, arguments ); + } + var instance = this; + return setTimeout( handlerProxy, delay || 0 ); + }, + _hoverable: function( element ) { this.hoverable = this.hoverable.add( element ); this._bind( element, { |