aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demos/index.html1
-rw-r--r--demos/menubar/default.html106
-rw-r--r--demos/popup/default.html30
-rw-r--r--demos/tooltip/custom-animation.html62
-rw-r--r--demos/tooltip/custom-content.html85
-rw-r--r--demos/tooltip/default.html47
-rw-r--r--demos/tooltip/delegation-mixbag.html73
-rw-r--r--demos/tooltip/forms.html110
-rw-r--r--demos/tooltip/images/st-stephens.jpgbin0 -> 17724 bytes
-rw-r--r--demos/tooltip/images/tower-bridge.jpgbin0 -> 15764 bytes
-rw-r--r--demos/tooltip/index.html5
-rw-r--r--demos/tooltip/tracking.html64
-rw-r--r--demos/tooltip/video-player.html193
-rw-r--r--demos/widget/default.html165
-rw-r--r--demos/widget/index.html18
-rw-r--r--tests/unit/accordion/accordion.html8
-rw-r--r--tests/unit/accordion/accordion_core.js32
-rw-r--r--tests/unit/accordion/accordion_deprecated.html8
-rw-r--r--tests/unit/accordion/accordion_deprecated.js90
-rw-r--r--tests/unit/accordion/accordion_events.js58
-rw-r--r--tests/unit/accordion/accordion_methods.js13
-rw-r--r--tests/unit/accordion/accordion_options.js55
-rw-r--r--tests/unit/autocomplete/autocomplete.html60
-rw-r--r--tests/unit/autocomplete/autocomplete_core.js106
-rw-r--r--tests/unit/autocomplete/autocomplete_events.js337
-rw-r--r--tests/unit/autocomplete/autocomplete_methods.js55
-rw-r--r--tests/unit/autocomplete/autocomplete_options.js317
-rw-r--r--tests/unit/effects/effects.html73
-rw-r--r--tests/unit/effects/effects_core.js15
-rw-r--r--tests/unit/effects/effects_scale.js61
-rw-r--r--tests/unit/position/position.html61
-rw-r--r--tests/unit/position/position_core.js5
-rw-r--r--tests/unit/position/position_core_within.js441
-rw-r--r--tests/unit/testsuite.js2
-rw-r--r--tests/unit/tooltip/tooltip.html60
-rw-r--r--tests/unit/tooltip/tooltip_core.js27
-rw-r--r--tests/unit/tooltip/tooltip_defaults.js11
-rw-r--r--tests/unit/tooltip/tooltip_events.js123
-rw-r--r--tests/unit/tooltip/tooltip_methods.js66
-rw-r--r--tests/unit/tooltip/tooltip_options.js105
-rw-r--r--tests/unit/widget/widget.html1
-rw-r--r--tests/unit/widget/widget_animation.js257
-rw-r--r--tests/unit/widget/widget_core.js19
-rw-r--r--tests/visual/effects/effects.all.css (renamed from tests/visual/effects.all.css)1
-rw-r--r--tests/visual/effects/effects.all.html (renamed from tests/visual/effects.all.html)38
-rw-r--r--tests/visual/effects/effects.all.js (renamed from tests/visual/effects.all.js)0
-rw-r--r--tests/visual/effects/effects.scale.html159
-rw-r--r--tests/visual/position/position.html2
-rw-r--r--tests/visual/position/position_within.html189
-rw-r--r--themes/base/jquery.ui.base.css1
-rw-r--r--themes/base/jquery.ui.menu.css38
-rw-r--r--themes/base/jquery.ui.menubar.css15
-rw-r--r--themes/base/jquery.ui.theme.css4
-rw-r--r--ui/jquery.effects.blind.js2
-rw-r--r--ui/jquery.effects.bounce.js2
-rw-r--r--ui/jquery.effects.clip.js57
-rw-r--r--ui/jquery.effects.core.js8
-rw-r--r--ui/jquery.effects.drop.js2
-rw-r--r--ui/jquery.effects.fold.js2
-rw-r--r--ui/jquery.effects.scale.js51
-rw-r--r--ui/jquery.effects.shake.js2
-rw-r--r--ui/jquery.effects.slide.js16
-rw-r--r--ui/jquery.effects.transfer.js14
-rw-r--r--ui/jquery.ui.accordion.js2
-rw-r--r--ui/jquery.ui.autocomplete.js2
-rw-r--r--ui/jquery.ui.button.js3
-rw-r--r--ui/jquery.ui.datepicker.js11
-rw-r--r--ui/jquery.ui.dialog.js3
-rw-r--r--ui/jquery.ui.draggable.js5
-rw-r--r--ui/jquery.ui.droppable.js5
-rw-r--r--ui/jquery.ui.menu.js254
-rw-r--r--ui/jquery.ui.menubar.js50
-rw-r--r--ui/jquery.ui.mouse.js1
-rw-r--r--ui/jquery.ui.popup.js103
-rw-r--r--ui/jquery.ui.position.js119
-rw-r--r--ui/jquery.ui.progressbar.js5
-rw-r--r--ui/jquery.ui.resizable.js5
-rw-r--r--ui/jquery.ui.selectable.js5
-rw-r--r--ui/jquery.ui.slider.js6
-rw-r--r--ui/jquery.ui.sortable.js5
-rw-r--r--ui/jquery.ui.spinner.js31
-rw-r--r--ui/jquery.ui.tabs.js5
-rw-r--r--ui/jquery.ui.tooltip.js213
-rw-r--r--ui/jquery.ui.widget.js36
84 files changed, 3273 insertions, 1624 deletions
diff --git a/demos/index.html b/demos/index.html
index b1cfcdd44..53a2557a2 100644
--- a/demos/index.html
+++ b/demos/index.html
@@ -300,6 +300,7 @@
<dd><a href="show/index.html">Show</a></dd>
<dt>Utilities</dt>
<dd><a href="position/index.html">Position</a></dd>
+ <dd><a href="widget/index.html">Widget</a></dd>
<dt>About jQuery UI</dt>
<dd><a href="http://jqueryui.com/docs/Getting_Started">Getting Started</a></dd>
<dd><a href="http://jqueryui.com/docs/Upgrade_Guide">Upgrade Guide</a></dd>
diff --git a/demos/menubar/default.html b/demos/menubar/default.html
index 79662bd9f..57a3209ce 100644
--- a/demos/menubar/default.html
+++ b/demos/menubar/default.html
@@ -3,7 +3,7 @@
<head>
<title>jQuery UI Menubar - Default demo</title>
<link rel="stylesheet" href="../demos.css" type="text/css" />
- <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-1.5.1.js"></script>
<script src="../../ui/jquery.ui.core.js"></script>
<script src="../../ui/jquery.ui.widget.js"></script>
@@ -13,56 +13,29 @@
<script src="../../ui/jquery.ui.menubar.js"></script>
<script>
$(function() {
- $("td:has(.menubar)").clone().appendTo("tbody tr:not(:first)");
-
- $("#bar1, .menubar").menubar({
+ $("#bar1").menubar({
+ position: {
+ within: $("#demo-frame").add(window).first()
+ },
select: function(event, ui) {
$("<div/>").text("Selected: " + ui.item.text()).appendTo("#log");
}
});
-
+
$(".menubar-icons").menubar({
menuIcon: true,
buttons: true,
+ position: {
+ within: $("#demo-frame").add(window).first()
+ },
select: function(event, ui) {
$("<div/>").text("Selected: " + ui.item.text()).appendTo("#log");
}
});
});
</script>
- <style type="text/css">
- #bar1, #bar2 { margin: 0 0 4em; } /* style for this page only */
- .ui-menu { width: 200px; position: absolute; outline: none; z-index: 9999; }
- .ui-menu .ui-icon { float: right; }
- .ui-menu li.ui-state-disabled {
- font-weight: bold;
- padding: .0em .4em;
- margin: .4em 0 .2em;
- line-height: 1.5;
- }
-
- /* menubar styles */
- .ui-menubar .ui-button { float: left; font-weight: normal; border-top-width: 0 !important; border-bottom-width: 0 !important; margin: 0; outline: none; }
- .ui-menubar .ui-menubar-link { border-right: 1px dashed transparent; border-left: 1px dashed transparent; }
-
- .ui-menubar {
- list-style: none;
- margin: 0;
- padding-left: 0;
- }
-
- .ui-menubar-item {
- float: left;
- }
- /*
- table {
- border-collapse: collapse;
- }
- th, td {
- padding: 0.5em;
- border: 1px solid black;
- }
- */
+ <style>
+ #bar1, #bar2 { margin: 0 0 4em; }
</style>
</head>
<body>
@@ -160,63 +133,6 @@
</li>
</ul>
-<!--
-<table id="movies" class="ui-widget">
- <thead>
- <tr>
- <th data-field="Name" class="ui-widget-header">Name</th>
- <th data-field="ReleaseYear" class="ui-widget-header">Release Year</th>
- <th data-field="AverageRating" class="ui-widget-header">Average Rating</th>
- <th class="ui-widget-header"></th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td class="ui-widget-content">Red Hot Chili Peppers: Funky Monks</td>
- <td class="ui-widget-content">1993</td>
- <td class="ui-widget-content">3.6</td>
- <td class="ui-widget-content">
- <ul class="menubar">
- <li>
- <a href="#Options">Options</a>
- <ul>
- <li><a href="#Order...">Order...</a></li>
- <li class="ui-state-disabled">Write a Review...</li>
- <li><a href="#Find Similar Movies...">Find Similar Movies...</a></li>
- <li>
- <a href="#Rate">Rate</a>
- <ul>
- <li><a href="#5 stars">5 stars</a></li>
- <li><a href="#4 stars">4 stars</a></li>
- <li><a href="#3 stars">3 stars</a></li>
- <li><a href="#2 stars">2 stars</a></li>
- <li><a href="#1 stars">1 stars</a></li>
- </ul>
- </li>
- </ul>
- </li>
- </ul>
- </td>
- </tr>
- <tr>
- <td class="ui-widget-content">Rod Stewart: Storyteller 1984-1991</td>
- <td class="ui-widget-content">1991</td>
- <td class="ui-widget-content">3.1</td>
- </tr>
- <tr>
- <td class="ui-widget-content">Stevie Ray Vaughan and Double Trouble: Live at the El Mocambo 1983</td>
- <td class="ui-widget-content">1991</td>
- <td class="ui-widget-content">3.9</td>
- </tr>
- <tr>
- <td class="ui-widget-content">Spike and Mike's Sick &amp; Twisted Festival of Animation</td>
- <td class="ui-widget-content">1997</td>
- <td class="ui-widget-content">2.6</td>
- </tr>
- </tbody>
-</table>
--->
-
<div class="ui-widget" style="margin-top:2em; font-family:Arial">
Log:
<div id="log" style="height: 100px; width: 300px; overflow: auto;" class="ui-widget-content"></div>
diff --git a/demos/popup/default.html b/demos/popup/default.html
index 71b3c8dd2..7b63d9e1d 100644
--- a/demos/popup/default.html
+++ b/demos/popup/default.html
@@ -29,7 +29,7 @@
<style type="text/css">
.ui-popup { position: absolute; z-index: 5000; }
.ui-menu { width: 200px; }
-
+
/*
table {
border-collapse: collapse;
@@ -55,26 +55,24 @@
<div class="demo">
<a href="#login-form">Log In</a>
- <div id="login-form" class="ui-widget-content" tabIndex="0">
- <form>
- <div>
- <label>Username</label>
- <input type="username" />
- </div>
- <div>
- <label>Password</label>
- <input type="password" />
- </div>
- <div>
- <input type="submit" class="submit" value="Login" />
- </div>
- </form>
+ <div class="ui-widget-content" id="login-form" aria-label="Login options">
+ <div>
+ <label for="un">Username</label>
+ <input type="text" id="un" />
+ </div>
+ <div>
+ <label for="pw">Password</label>
+ <input type="password" id="pw" />
+ </div>
+ <div>
+ <input type="submit" value="Login" class="submit" />
+ </div>
</div>
</div>
<div class="demo-description">
-<p>A link to a login form that opens as a popup. [Not quite functional, focus handling needs to get better]</p>
+<p>A link to a login form that opens as a popup.</p>
</div><!-- End demo-description -->
diff --git a/demos/tooltip/custom-animation.html b/demos/tooltip/custom-animation.html
index ef8857979..c7d1aa5b8 100644
--- a/demos/tooltip/custom-animation.html
+++ b/demos/tooltip/custom-animation.html
@@ -1,59 +1,61 @@
<!doctype html>
<html lang="en">
<head>
+ <meta charset="utf-8">
<title>jQuery UI Tooltip - Custom animation demo</title>
- <link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" />
- <script type="text/javascript" src="../../jquery-1.5.1.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.tooltip.js"></script>
- <link type="text/css" href="../demos.css" rel="stylesheet" />
- <script type="text/javascript">
+ <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
+ <script src="../../jquery-1.5.1.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.tooltip.js"></script>
+ <script src="../../ui/jquery.effects.core.js"></script>
+ <script src="../../ui/jquery.effects.explode.js"></script>
+ <link rel="stylesheet" href="../demos.css">
+ <script>
$(function() {
- $(".demo").tooltip({
+ $( "#show-option" ).tooltip({
show: {
effect: "slideDown",
delay: 250
- },
+ }
+ });
+ $( "#hide-option" ).tooltip({
hide: {
- effect: "hide",
+ effect: "explode",
delay: 250
}
});
+ $( "#open-event" ).tooltip({
+ show: null,
+ position: {
+ my: "left top",
+ at: "left bottom"
+ },
+ open: function( event, ui ) {
+ ui.tooltip.animate({ top: ui.tooltip.position().top + 10 }, "fast" );
+ }
+ });
});
</script>
- <style>
- label { display: inline-block; width: 5em; }
- </style>
</head>
<body>
<div class="demo">
- <p><a href="#" title="That's what this widget is">Tooltips</a> can be attached to any element. When you hover
- the element with your mouse, the title attribute is displayed in a little box next to the element, just like a native tooltip.
- </p>
- <p>But as it's not a native tooltip, it can be styled. Any themes built with
- <a href="http://themeroller.com" title="ThemeRoller, jQuery UI's theme builder application">ThemeRoller</a>
- will also style tooltip's accordingly.</p>
- <p>Tooltip's are also useful for form elements, to show some additional information in the context of each field.</p>
- <p><label for="age">Your age:</label><input id="age" title="We ask for your age only for statistical purposes." /></p>
- <p>Click the field to see the tooltip; when you tab out of the field, it gets hidden.</p>
+<p>There are various ways to customize the animation of a tooltip.</p>
+<p>You can use the <a id="show-option" href="http://jqueryui.com/demos/tooltip/#option-show" title="slide down on show">show</a> and
+<a id="hide-option" href="http://jqueryui.com/demos/tooltip/#option-hide" title="explode on hide">hide</a> options.</p>
+<p>You can also use the <a id="open-event" href="http://jqueryui.com/demos/tooltip/#event-open" title="move down on show">open event</a>.</p>
</div><!-- End demo -->
<div class="demo-description">
-
-<p>This demo shows how to customize animations. The tooltip is shown, after a
-delay of 250ms, using a slide down animation, and hidden, after another delay,
-without an animation.</p>
-
+<p>This demo shows how to customize animations using the show and hide options,
+as well as the open event.</p>
</div><!-- End demo-description -->
-
-
</body>
</html>
diff --git a/demos/tooltip/custom-content.html b/demos/tooltip/custom-content.html
new file mode 100644
index 000000000..e84a7104b
--- /dev/null
+++ b/demos/tooltip/custom-content.html
@@ -0,0 +1,85 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>jQuery UI Tooltip - Custom content</title>
+ <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
+ <script src="../../jquery-1.5.1.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.tooltip.js"></script>
+ <link rel="stylesheet" href="../demos.css">
+ <style>
+ .photo {
+ width: 300px;
+ text-align: center;
+ }
+ .photo .ui-widget-header {
+ margin: 1em 0;
+ }
+ .map {
+ width: 350px;
+ height: 350px;
+ }
+ </style>
+ <script>
+ $(function() {
+ $( ".demo" ).tooltip({
+ items: "img, [data-geo], [title]",
+ content: function() {
+ var element = $( this );
+ if ( element.is( "[data-geo]" ) ) {
+ return "<img class='map' src='http://maps.google.com/maps/api/staticmap?" +
+ "zoom=11&size=350x350&maptype=terrain&sensor=false&center=" +
+ element.text() + "'>";
+ }
+ if ( element.is( "[title]" ) ) {
+ return element.attr( "title" );
+ }
+ if ( element.is( "img" ) ) {
+ return element.attr( "alt" );
+ }
+ }
+ });
+ });
+ </script>
+</head>
+<body>
+
+<div class="demo">
+
+<div class="ui-widget photo">
+ <div class="ui-widget-header ui-corner-all">
+ <h2>St. Stephen's Cathedral</h2>
+ <h3><a href="http://maps.google.com/maps?q=vienna,+austria&z=11" data-geo>Vienna, Austria</a></h3>
+ </div>
+ <a href="http://en.wikipedia.org/wiki/File:Wien_Stefansdom_DSC02656.JPG">
+ <img src="images/st-stephens.jpg" alt="St. Stephen's Cathedral" class="ui-corner-all">
+ </a>
+</div>
+
+<div class="ui-widget photo">
+ <div class="ui-widget-header ui-corner-all">
+ <h2>Tower Bridge</h2>
+ <h3><a href="http://maps.google.com/maps?q=london,+england&z=11" data-geo>London, England</a></h3>
+ </div>
+ <a href="http://en.wikipedia.org/wiki/File:Tower_bridge_London_Twilight_-_November_2006.jpg">
+ <img src="images/tower-bridge.jpg" alt="Tower Bridge" class="ui-corner-all">
+ </a>
+</div>
+
+<p>All images are part of <a href="http://commons.wikimedia.org/wiki/Main_Page">Wikimedia Commons</a>
+and are licensed under <a href="http://creativecommons.org/licenses/by-sa/3.0/deed.en" title="Creative Commons Attribution-ShareAlike 3.0">CC BY-SA 3.0</a> by the copyright holder.</p>
+
+</div><!-- End demo -->
+
+
+
+<div class="demo-description">
+<p>Shows how to combine different event delegated tooltips into a single instance, by customizing the items and content options.</p>
+<p>We realize you may want to interact with the map tooltips. This is a planned feature for a future version.</p>
+</div><!-- End demo-description -->
+
+</body>
+</html>
diff --git a/demos/tooltip/default.html b/demos/tooltip/default.html
index 9d5502f2b..cfb61f2eb 100644
--- a/demos/tooltip/default.html
+++ b/demos/tooltip/default.html
@@ -1,48 +1,47 @@
<!doctype html>
<html lang="en">
<head>
- <title>jQuery UI Tooltip - Default demo</title>
- <link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" />
- <script type="text/javascript" src="../../jquery-1.5.1.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.tooltip.js"></script>
- <link type="text/css" href="../demos.css" rel="stylesheet" />
- <script type="text/javascript">
+ <meta charset="utf-8">
+ <title>jQuery UI Tooltip - Default functionality</title>
+ <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
+ <script src="../../jquery-1.5.1.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.tooltip.js"></script>
+ <link rel="stylesheet" href="../demos.css">
+ <script>
$(function() {
- $(".demo").tooltip();
+ $( ".demo" ).tooltip();
});
</script>
<style>
- label { display: inline-block; width: 5em; }
+ label {
+ display: inline-block;
+ width: 5em;
+ }
</style>
</head>
<body>
<div class="demo">
- <p><a href="#" title="That's what this widget is">Tooltips</a> can be attached to any element. When you hover
- the element with your mouse, the title attribute is displayed in a little box next to the element, just like a native tooltip.
- </p>
- <p>But as it's not a native tooltip, it can be styled. Any themes built with
- <a href="http://themeroller.com" title="ThemeRoller, jQuery UI's theme builder application">ThemeRoller</a>
- will also style tooltip's accordingly.</p>
- <p>Tooltip's are also useful for form elements, to show some additional information in the context of each field.</p>
- <p><label for="age">Your age:</label><input id="age" title="We ask for your age only for statistical purposes." /></p>
- <p>Click the field to see the tooltip; when you tab out of the field, it gets hidden.</p>
+<p><a href="#" title="That's what this widget is">Tooltips</a> can be attached to any element. When you hover
+the element with your mouse, the title attribute is displayed in a little box next to the element, just like a native tooltip.</p>
+<p>But as it's not a native tooltip, it can be styled. Any themes built with
+<a href="http://themeroller.com" title="ThemeRoller: jQuery UI's theme builder application">ThemeRoller</a>
+will also style tooltips accordingly.</p>
+<p>Tooltips are also useful for form elements, to show some additional information in the context of each field.</p>
+<p><label for="age">Your age:</label><input id="age" title="We ask for your age only for statistical purposes."></p>
+<p>Hover the field to see the tooltip.</p>
</div><!-- End demo -->
<div class="demo-description">
-
<p>Hover the links above or use the tab key to cycle the focus on each element.</p>
-
</div><!-- End demo-description -->
-
-
</body>
</html>
diff --git a/demos/tooltip/delegation-mixbag.html b/demos/tooltip/delegation-mixbag.html
deleted file mode 100644
index 9c524dabe..000000000
--- a/demos/tooltip/delegation-mixbag.html
+++ /dev/null
@@ -1,73 +0,0 @@
-<!doctype html>
-<html lang="en">
-<head>
- <title>jQuery UI Tooltip - Default demo</title>
- <link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" />
- <script type="text/javascript" src="../../jquery-1.5.1.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.tooltip.js"></script>
- <link type="text/css" href="../demos.css" rel="stylesheet" />
- <script type="text/javascript">
- $(function() {
- $(".demo").tooltip({
- items: "[href], [title]",
- content: function(response) {
- var href = $(this).attr("href");
- if (/^#/.test(href)) {
- return $(href).html();
- } else if (href) {
- $.get(href, response);
- return "loading...";
- }
- return this.title;
- }
- });
- $("#footnotes").hide();
- });
- </script>
- <style>
- label { display: inline-block; width: 5em; }
- </style>
-</head>
-<body>
-
-<div class="demo">
- <ul>
- <li>
- <a href="#footnote1">I'm a link to a footnote.</a>
- </li>
- <li>
- <a href="#footnote2">I'm another link to a footnote.</a>
- </li>
- </ul>
- <input title="This is just an input, nothing special" />
-
- <ul>
- <li>
- <a href="ajax/content1.html">Link to ajax content, with tooltip preview!</a>
- </li>
- <li>
- <a href="ajax/content2.html">Another link to ajax content, with tooltip preview!</a>
- </li>
- </ul>
-
- <div id="footnotes">
- <div id="footnote1">This is <strong>the</strong> footnote, including other elements</div>
- <div id="footnote2">This is <strong>the other</strong> footnote, including other elements</div>
- </div>
-</div><!-- End demo -->
-
-
-
-<div class="demo-description">
-
-<p>Show how to combine different event delegated tooltips into a single instance, by customizing the items and content options.</p>
-
-</div><!-- End demo-description -->
-
-
-
-</body>
-</html>
diff --git a/demos/tooltip/forms.html b/demos/tooltip/forms.html
index 983b56bdf..0f91736b2 100644
--- a/demos/tooltip/forms.html
+++ b/demos/tooltip/forms.html
@@ -1,71 +1,87 @@
<!doctype html>
<html lang="en">
<head>
+ <meta charset="utf-8">
<title>jQuery UI Tooltip - Default demo</title>
- <link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" />
- <script type="text/javascript" src="../../jquery-1.5.1.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.tooltip.js"></script>
- <script type="text/javascript" src="../../ui/jquery.ui.button.js"></script>
- <link type="text/css" href="../demos.css" rel="stylesheet" />
- <script type="text/javascript">
+ <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
+ <script src="../../jquery-1.5.1.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.tooltip.js"></script>
+ <script src="../../ui/jquery.ui.button.js"></script>
+ <link rel="stylesheet" href="../demos.css">
+ <style>
+ label {
+ display: inline-block; width: 5em;
+ }
+ fieldset div {
+ margin-bottom: 2em;
+ }
+ fieldset .help {
+ display: inline-block;
+ }
+ .ui-tooltip {
+ width: 210px;
+ }
+ </style>
+ <script>
$(function() {
- $("[title]").tooltip().unbind(".tooltip");
- $("<button/>").text("Show help").button().toggle(function() {
- $(":ui-tooltip").tooltip("open");
- }, function() {
- $(":ui-tooltip").tooltip("close");
- }).appendTo("form");
+ var tooltips = $( "[title]" )
+ .click(function() {
+ $( this ).tooltip( $( this ).attr( "title" ) ? "open" : "close" );
+ })
+ .bind( "mouseover focusin mouseleave blur click", function( event ) {
+ event.stopImmediatePropagation();
+ })
+ .tooltip();
+ $( "<button>" )
+ .text( "Show help" )
+ .button()
+ .toggle(
+ function() {
+ tooltips.tooltip( "open" );
+ },
+ function() {
+ tooltips.tooltip( "close" );
+ }
+ )
+ .appendTo( "form" );
});
</script>
- <style>
- label { display: inline-block; width: 5em; }
- .ui-icon { display: inline-block; }
- fieldset div {
- margin-bottom: 2em;
- }
- .ui-tooltip { width: 210px; }
- </style>
</head>
<body>
<div class="demo">
- <form>
- <fieldset>
- <div>
- <label for="firstname">Firstname</label>
- <input id="firstname" name="firstname" />
- <span title="Please provide your firstname." class="ui-state-default ui-corner-all ui-icon ui-icon-help">?</span>
- </div>
- <div>
- <label for="lastname">Lastname</label>
- <input id="lastname" name="lastname" />
- <span title="Please provide also your lastname." class="ui-state-default ui-corner-all ui-icon ui-icon-help">?</span>
- </div>
- <div>
- <label for="address">Address</label>
- <input id="address" name="address" />
- <span title="Your home or work address." class="ui-state-default ui-corner-all ui-icon ui-icon-help">?</span>
- </div>
- </fieldset>
- </form>
+<form>
+ <fieldset>
+ <div>
+ <label for="firstname">Firstname</label>
+ <input id="firstname" name="firstname">
+ <span title="Please provide your firstname." class="help ui-state-default ui-corner-all ui-icon ui-icon-help">?</span>
+ </div>
+ <div>
+ <label for="lastname">Lastname</label>
+ <input id="lastname" name="lastname">
+ <span title="Please provide also your lastname." class="help ui-state-default ui-corner-all ui-icon ui-icon-help">?</span>
+ </div>
+ <div>
+ <label for="address">Address</label>
+ <input id="address" name="address">
+ <span title="Your home or work address." class="help ui-state-default ui-corner-all ui-icon ui-icon-help">?</span>
+ </div>
+ </fieldset>
+</form>
</div><!-- End demo -->
<div class="demo-description">
-
<p>Use the button below to display the help texts. Click again to hide them. Default hover and focus events are removed to show tooltip only programmatically.</p>
-
<p>A fixed width is defined in CSS to make the tooltips look consistent when displayed all at once.</p>
-
</div><!-- End demo-description -->
-
-
</body>
</html>
diff --git a/demos/tooltip/images/st-stephens.jpg b/demos/tooltip/images/st-stephens.jpg
new file mode 100644
index 000000000..30fc36d67
--- /dev/null
+++ b/demos/tooltip/images/st-stephens.jpg
Binary files differ
diff --git a/demos/tooltip/images/tower-bridge.jpg b/demos/tooltip/images/tower-bridge.jpg
new file mode 100644
index 000000000..d1e14d6d2
--- /dev/null
+++ b/demos/tooltip/images/tower-bridge.jpg
Binary files differ
diff --git a/demos/tooltip/index.html b/demos/tooltip/index.html
index 4ad189ed2..6e7c6836e 100644
--- a/demos/tooltip/index.html
+++ b/demos/tooltip/index.html
@@ -1,8 +1,9 @@
<!doctype html>
<html lang="en">
<head>
+ <meta charset="utf-8">
<title>jQuery UI Tooltip Demos</title>
- <link type="text/css" href="../demos.css" rel="stylesheet" />
+ <link rel="stylesheet" href="../demos.css">
</head>
<body>
@@ -13,7 +14,7 @@
<li><a href="forms.html">Forms with tooltips</a></li>
<li><a href="tracking.html">Track the mouse</a></li>
<li><a href="custom-animation.html">Custom animation</a></li>
- <li><a href="delegation-mixbag.html">Delegation Mixbag</a></li>
+ <li><a href="custom-content.html">Custom content</a></li>
<li><a href="video-player.html">Video Player</a></li>
</ul>
</div>
diff --git a/demos/tooltip/tracking.html b/demos/tooltip/tracking.html
index dd5dc9d92..4cddb4437 100644
--- a/demos/tooltip/tracking.html
+++ b/demos/tooltip/tracking.html
@@ -1,64 +1,64 @@
<!doctype html>
<html lang="en">
<head>
- <title>jQuery UI Tooltip - Default demo</title>
- <link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" />
- <script type="text/javascript" src="../../jquery-1.5.1.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.tooltip.js"></script>
- <link type="text/css" href="../demos.css" rel="stylesheet" />
- <script type="text/javascript">
+ <meta charset="utf-8">
+ <title>jQuery UI Tooltip - Track the mouse</title>
+ <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
+ <script src="../../jquery-1.5.1.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.tooltip.js"></script>
+ <link rel="stylesheet" href="../demos.css">
+ <style>
+ label {
+ display: inline-block;
+ width: 5em;
+ }
+ </style>
+ <script>
$(function() {
- $(".demo").tooltip({
- open: function() {
+ $( ".demo" ).tooltip({
+ open: function( event ) {
var tooltip = $( ".ui-tooltip" );
- $(document).mousemove(function( event ) {
- tooltip.position( {
+ function position( event ) {
+ tooltip.position({
my: "left+25 center",
at: "right+25 center",
of: event
});
- })
+ }
+ $( document ).bind( "mousemove.tooltip-position", position );
// trigger once to override element-relative positioning
- .mousemove();
+ position( event );
},
close: function() {
- $(document).unbind( "mousemove" );
+ $( document ).unbind( "mousemove.tooltip-position" );
}
});
});
</script>
- <style>
- label { display: inline-block; width: 5em; }
- </style>
</head>
<body>
<div class="demo">
- <p><a href="#" title="That's what this widget is">Tooltips</a> can be attached to any element. When you hover
- the element with your mouse, the title attribute is displayed in a little box next to the element, just like a native tooltip.
- </p>
- <p>But as it's not a native tooltip, it can be styled. Any themes built with
- <a href="http://themeroller.com" title="ThemeRoller, jQuery UI's theme builder application">ThemeRoller</a>
- will also style tooltip's accordingly.</p>
- <p>Tooltip's are also useful for form elements, to show some additional information in the context of each field.</p>
- <p><label for="age">Your age:</label><input id="age" title="We ask for your age only for statistical purposes." /></p>
- <p>Click the field to see the tooltip; when you tab out of the field, it gets hidden.</p>
+<p><a href="#" title="That's what this widget is">Tooltips</a> can be attached to any element. When you hover
+the element with your mouse, the title attribute is displayed in a little box next to the element, just like a native tooltip.</p>
+<p>But as it's not a native tooltip, it can be styled. Any themes built with
+<a href="http://themeroller.com" title="ThemeRoller: jQuery UI's theme builder application">ThemeRoller</a>
+will also style tooltips accordingly.</p>
+<p>Tooltips are also useful for form elements, to show some additional information in the context of each field.</p>
+<p><label for="age">Your age:</label><input id="age" title="We ask for your age only for statistical purposes."></p>
+<p>Hover the field to see the tooltip.</p>
</div><!-- End demo -->
<div class="demo-description">
-
<p>Here the tooltips are positioned relative to the mouse, and follow the mouse while it moves above the element.</p>
-
</div><!-- End demo-description -->
-
-
</body>
</html>
diff --git a/demos/tooltip/video-player.html b/demos/tooltip/video-player.html
index 56003ab5a..1d8458abb 100644
--- a/demos/tooltip/video-player.html
+++ b/demos/tooltip/video-player.html
@@ -1,64 +1,105 @@
<!doctype html>
<html lang="en">
<head>
+ <meta charset="utf-8">
<title>jQuery UI Tooltip - Video Player demo</title>
- <link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" />
- <script type="text/javascript" src="../../jquery-1.5.1.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.tooltip.js"></script>
- <script type="text/javascript" src="../../ui/jquery.ui.button.js"></script>
- <script type="text/javascript" src="../../ui/jquery.ui.menu.js"></script>
- <script type="text/javascript" src="../../ui/jquery.ui.popup.js"></script>
- <script type="text/javascript" src="../../ui/jquery.effects.core.js"></script>
- <script type="text/javascript" src="../../ui/jquery.effects.blind.js"></script>
- <link type="text/css" href="../demos.css" rel="stylesheet" />
- <script type="text/javascript">
+ <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
+ <script src="../../jquery-1.5.1.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.tooltip.js"></script>
+ <script src="../../ui/jquery.ui.button.js"></script>
+ <script src="../../ui/jquery.ui.menu.js"></script>
+ <script src="../../ui/jquery.ui.popup.js"></script>
+ <script src="../../ui/jquery.effects.core.js"></script>
+ <script src="../../ui/jquery.effects.blind.js"></script>
+ <link rel="stylesheet" href="../demos.css">
+ <style>
+ .player {
+ width: 500px;
+ height: 300px;
+ border: 2px groove gray;
+ background: rgb(200, 200, 200);
+ text-align: center;
+ line-height: 300px;
+ }
+ /* TODO load from jquery.ui.popup.css */
+ .ui-popup {
+ position: absolute;
+ z-index: 5000;
+ }
+ .ui-tooltip {
+ border: 1px solid white;
+ background: rgba(20, 20, 20, 1);
+ color: white;
+ }
+ .set {
+ display: inline-block;
+ }
+ .notification {
+ position: absolute;
+ display: inline-block;
+ font-size: 2em;
+ padding: .5em;
+ box-shadow: 2px 2px 5px -2px rgba(0,0,0,0.5);
+ }
+ </style>
+ <script>
$(function() {
function notify( input ) {
- var msg = "Selected " + $.trim($(input).text());
- $("<div/>").appendTo(document.body).text(msg).addClass("notification ui-state-default ui-corner-bottom").position({
- my: "center top",
- at: "center top",
- of: window
- }).show({
- effect: "blind"
- }).delay(1000).hide({
- effect: "blind",
- duration: "slow"
- }, function() {
- $(this).remove();
- });
+ var msg = "Selected " + $.trim( input.data( "tooltip-title" ) || input.text() );
+ $( "<div>" )
+ .appendTo( document.body )
+ .text( msg )
+ .addClass( "notification ui-state-default ui-corner-bottom" )
+ .position({
+ my: "center top",
+ at: "center top",
+ of: window
+ })
+ .show({
+ effect: "blind"
+ })
+ .delay( 1000 )
+ .hide({
+ effect: "blind",
+ duration: "slow"
+ }, function() {
+ $( this ).remove();
+ });
}
- $("ul").menu({
- select: function(event, ui) {
- // TODO stop button from handling the click
- $(this).popup("close");
- // TODO should probably be handled by poup, see ESCAPE key handler
+ $( "ul" ).menu({
+ select: function( event, ui ) {
+ // TODO should probably be handled by popup, see ESCAPE key handler
// affects key handling
- $(this).prev().focus();
- notify(ui.item);
+ $( this ).prev().focus();
+ notify( ui.item );
}
}).popup();
- $("button").each(function() {
- $(this).button({
+ $( "button" ).each(function() {
+ var button = $( this ).button({
icons: {
- primary: $(this).data("icon")
+ primary: $( this ).data( "icon" )
},
- text: !!$(this).attr("title")
- }).click(function() {
- // TODO don't notify if the button is opening a popup
- notify(this);
+ text: !!$( this ).attr( "title" )
});
+ if ( button.next().is( ":ui-popup" ) ) {
+ button.click(function( event ) {
+ $( ".demo" ).tooltip( "close", event );
+ });
+ } else {
+ button.click(function() {
+ notify( button );
+ });
+ }
});
- $(".set").buttonset({
+ $( ".set" ).buttonset({
items: "button"
});
-
- $(".demo").tooltip({
+ $( ".demo" ).tooltip({
position: {
my: "center top",
at: "center bottom+5",
@@ -72,63 +113,43 @@
});
});
</script>
- <style>
- .player { width: 500px; height: 300px; border: 2px groove gray; background: rgb(200, 200, 200); text-align: center; line-height: 300px; }
- /* TODO load from jquery.ui.popup.css */
- .ui-popup { position: absolute; z-index: 5000; }
-
- .ui-tooltip {
- border: 1px solid white;
- background: rgba(20, 20, 20, 1);
- color: white;
- }
-
- .set { display: inline-block; }
-
- .notification { position: absolute; display: inline-block; font-size: 2em; padding: .5em; box-shadow: 2px 2px 5px -2px rgba(0,0,0,0.5); }
- </style>
</head>
<body>
<div class="demo">
- <div class="player">Here Be Video (HTML5?)</div>
- <div class="tools">
- <span class="set">
- <button data-icon="ui-icon-circle-arrow-n" title="I like this">Like</button>
- <button data-icon="ui-icon-circle-arrow-s">I dislike this</button>
- </span>
- <div class="set">
- <button data-icon="ui-icon-circle-plus" title="Add to Watch Later">Add to</button>
- <button class="menu" data-icon="ui-icon-triangle-1-s">Add to favorites or playlist</button>
- <ul>
- <li>
- <a href="#">Favorites</a>
- </li>
- <li>
- <a href="#">Watch Later</a>
- </li>
- <li>
- <a href="#">New Playlist...</a>
- </li>
- </ul>
- </div>
- <button title="Share this video">Share</button>
- <button data-icon="ui-icon-alert">Flag as inappropiate</button>
+<div class="player">Here Be Video (HTML5?)</div>
+<div class="tools">
+ <span class="set">
+ <button data-icon="ui-icon-circle-arrow-n" title="I like this">Like</button>
+ <button data-icon="ui-icon-circle-arrow-s">I dislike this</button>
+ </span>
+ <div class="set">
+ <button data-icon="ui-icon-circle-plus" title="Add to Watch Later">Add to</button>
+ <button class="menu" data-icon="ui-icon-triangle-1-s">Add to favorites or playlist</button>
+ <ul>
+ <li>
+ <a href="#">Favorites</a>
+ </li>
+ <li>
+ <a href="#">Watch Later</a>
+ </li>
+ <li>
+ <a href="#">New Playlist...</a>
+ </li>
+ </ul>
</div>
- </div>
+ <button title="Share this video">Share</button>
+ <button data-icon="ui-icon-alert">Flag as inappropiate</button>
+</div>
</div><!-- End demo -->
<div class="demo-description">
-
<p>A fake video player with like/share/stats button, each with a custom-styled tooltip.</p>
-
</div><!-- End demo-description -->
-
-
</body>
</html>
diff --git a/demos/widget/default.html b/demos/widget/default.html
new file mode 100644
index 000000000..c2b520983
--- /dev/null
+++ b/demos/widget/default.html
@@ -0,0 +1,165 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>jQuery UI Widget - Default functionality</title>
+ <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
+ <script src="../../jquery-1.5.1.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>
+ <link rel="stylesheet" href="../demos.css">
+ <style>
+ .custom-colorize {
+ font-size: 25px;
+ width: 75px;
+ height: 75px;
+ }
+ </style>
+ <script>
+ $(function() {
+ // the widget definition, where "custom" is the namespace,
+ // "colorize" the widget name
+ $.widget( "custom.colorize", {
+ // default options
+ options: {
+ red: 255,
+ green: 0,
+ blue: 0,
+
+ // callbacks
+ change: null,
+ random: null
+ },
+
+ // the constructor
+ _create: function() {
+ this.element
+ // add a class for theming
+ .addClass( "custom-colorize" )
+ // prevent double click to select text
+ .disableSelection();
+
+ // bind click events to random method
+ this._bind({
+ // _bind won't call random when widget is disabled
+ click: "random"
+ });
+ this._refresh();
+ },
+
+ // called when created, and later when changing options
+ _refresh: function() {
+ this.element.css( "background-color", "rgb(" +
+ this.options.red +"," +
+ this.options.green + "," +
+ this.options.blue + ")"
+ );
+
+ // trigger a callback/event
+ this._trigger( "change" );
+ },
+
+ // a public method to change the color to a random value
+ // can be called directly via .colorize( "random" )
+ random: function( event ) {
+ var colors = {
+ red: Math.floor( Math.random() * 256 ),
+ green: Math.floor( Math.random() * 256 ),
+ blue: Math.floor( Math.random() * 256 )
+ };
+
+ // trigger an event, check if it's canceled
+ if ( this._trigger( "random", event, colors ) !== false ) {
+ this.option( colors );
+ }
+ },
+
+ // events bound via _bind are removed automatically
+ // revert other modifications here
+ _destroy: function() {
+ this.element
+ .removeClass( "custom-colorize" )
+ .enableSelection()
+ .css( "background-color", "transparent" );
+ },
+
+ // _setOptions is called with a hash of all options that are changing
+ // always refresh when changing options
+ _setOptions: function() {
+ // _super and _superApply handle keeping the right this-context
+ this._superApply( "_setOptions", arguments );
+ this._refresh();
+ },
+
+ // _setOption is called for each individual option that is changing
+ _setOption: function( key, value ) {
+ // prevent invalid color values
+ if ( /red|green|blue/.test(key) && (value < 0 || value > 255) ) {
+ return;
+ }
+ this._super( "_setOption", key, value );
+ }
+ });
+
+ // initialize with default options
+ $( "#my-widget1" ).colorize();
+
+ // initialize with two customized options
+ $( "#my-widget2" ).colorize({
+ red: 60,
+ blue: 60
+ });
+
+ // initialize with custom green value
+ // and a random callback to allow only colors with enough green
+ $( "#my-widget3" ).colorize( {
+ green: 128,
+ random: function( event, ui ) {
+ return ui.green > 128;
+ }
+ });
+
+ // click to toggle enabled/disabled
+ $( "#disable" ).toggle(function() {
+ // use the custom selector created for each widget to find all instances
+ $( ":custom-colorize" ).colorize( "disable" );
+ }, function() {
+ $( ":custom-colorize" ).colorize( "enable" );
+ });
+
+ // click to set options after initalization
+ $( "#black" ).click( function() {
+ $( ":custom-colorize" ).colorize( "option", {
+ red: 0,
+ green: 0,
+ blue: 0
+ });
+ });
+ });
+ </script>
+</head>
+<body>
+
+<div class="demo">
+
+<div>
+ <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="black">Go black</button>
+</div>
+
+</div><!-- End demo -->
+
+
+
+<div class="demo-description">
+<p>This demo shows a simple custom widget built using the widget factory (jquery.ui.widget.js).</p>
+<p>The three boxes are initialized in different ways. Clicking them changes their background color. View source to see how it works, its heavily commented</p>
+<p><a href="http://wiki.jqueryui.com/w/page/12138135/Widget-factory">For more details on the widget factory, visit the jQuery UI planning wiki.</a></p>
+</div><!-- End demo-description -->
+
+</body>
+</html>
diff --git a/demos/widget/index.html b/demos/widget/index.html
new file mode 100644
index 000000000..1ecb4feea
--- /dev/null
+++ b/demos/widget/index.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>jQuery UI Widget Demo</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>
+ </ul>
+</div>
+
+</body>
+</html>
diff --git a/tests/unit/accordion/accordion.html b/tests/unit/accordion/accordion.html
index c260ef22f..c4eee6b4c 100644
--- a/tests/unit/accordion/accordion.html
+++ b/tests/unit/accordion/accordion.html
@@ -25,17 +25,17 @@
var actual = accordion.find( ".ui-accordion-content" ).map(function() {
return $( this ).css( "display" ) === "none" ? 0 : 1;
}).get();
- same( actual, expected );
+ deepEqual( actual, expected );
}
- function equalHeights( accordion, min, max ) {
+ 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 ] );
- same( sizes[ 0 ], sizes[ 1 ] );
- same( sizes[ 0 ], sizes[ 2 ] );
+ deepEqual( sizes[ 0 ], sizes[ 1 ] );
+ deepEqual( sizes[ 0 ], sizes[ 2 ] );
}
function accordionSetupTeardown() {
var animated = $.ui.accordion.prototype.options.animated;
diff --git a/tests/unit/accordion/accordion_core.js b/tests/unit/accordion/accordion_core.js
index 280339c26..ec4ca29d5 100644
--- a/tests/unit/accordion/accordion_core.js
+++ b/tests/unit/accordion/accordion_core.js
@@ -3,6 +3,7 @@
module( "accordion: core", accordionSetupTeardown() );
$.each( { div: "#list1", ul: "#navigation", dl: "#accordion-dl" }, function( type, selector ) {
+ expect( 4 );
test( "markup structure: " + type, function() {
var element = $( selector ).accordion();
ok( element.hasClass( "ui-accordion" ), "main element is .ui-accordion" );
@@ -10,13 +11,14 @@ $.each( { div: "#list1", ul: "#navigation", dl: "#accordion-dl" }, function( typ
".ui-accordion-header elements exist, correct number" );
equal( element.find( ".ui-accordion-content" ).length, 3,
".ui-accordion-content elements exist, correct number" );
- same( element.find( ".ui-accordion-header" ).next().get(),
+ deepEqual( element.find( ".ui-accordion-header" ).next().get(),
element.find( ".ui-accordion-content" ).get(),
"content panels come immediately after headers" );
});
});
test( "handle click on header-descendant", function() {
+ expect( 1 );
var element = $( "#navigation" ).accordion();
$( "#navigation h2:eq(1) a" ).click();
accordion_state( element, 0, 1, 0 );
@@ -26,7 +28,7 @@ test( "ui-accordion-heading class added to headers anchor", function() {
expect( 1 );
var element = $( "#list1" ).accordion();
var anchors = element.find( ".ui-accordion-heading" );
- equals( anchors.length, 3 );
+ equal( anchors.length, 3 );
});
test( "accessibility", function () {
@@ -34,20 +36,20 @@ test( "accessibility", function () {
var element = $( "#list1" ).accordion().accordion( "option", "active", 1 );
var headers = element.find( ".ui-accordion-header" );
- equals( headers.eq( 1 ).attr( "tabindex" ), 0, "active header should have tabindex=0" );
- equals( headers.eq( 0 ).attr( "tabindex" ), -1, "inactive header should have tabindex=-1" );
- equals( element.attr( "role" ), "tablist", "main role" );
- equals( headers.attr( "role" ), "tab", "tab roles" );
- equals( headers.next().attr( "role" ), "tabpanel", "tabpanel roles" );
- equals( headers.eq( 1 ).attr( "aria-expanded" ), "true", "active tab has aria-expanded" );
- equals( headers.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded" );
- equals( headers.eq( 1 ).attr( "aria-selected" ), "true", "active tab has aria-selected" );
- equals( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected" );
+ equal( headers.eq( 1 ).attr( "tabindex" ), 0, "active header should have tabindex=0" );
+ equal( headers.eq( 0 ).attr( "tabindex" ), -1, "inactive header should have tabindex=-1" );
+ equal( element.attr( "role" ), "tablist", "main role" );
+ equal( headers.attr( "role" ), "tab", "tab roles" );
+ equal( headers.next().attr( "role" ), "tabpanel", "tabpanel roles" );
+ equal( headers.eq( 1 ).attr( "aria-expanded" ), "true", "active tab has aria-expanded" );
+ equal( headers.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded" );
+ equal( headers.eq( 1 ).attr( "aria-selected" ), "true", "active tab has aria-selected" );
+ equal( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected" );
element.accordion( "option", "active", 0 );
- equals( headers.eq( 0 ).attr( "aria-expanded" ), "true", "newly active tab has aria-expanded" );
- equals( headers.eq( 1 ).attr( "aria-expanded" ), "false", "newly inactive tab has aria-expanded" );
- equals( headers.eq( 0 ).attr( "aria-selected" ), "true", "active tab has aria-selected" );
- equals( headers.eq( 1 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected" );
+ equal( headers.eq( 0 ).attr( "aria-expanded" ), "true", "newly active tab has aria-expanded" );
+ equal( headers.eq( 1 ).attr( "aria-expanded" ), "false", "newly inactive tab has aria-expanded" );
+ equal( headers.eq( 0 ).attr( "aria-selected" ), "true", "active tab has aria-selected" );
+ equal( headers.eq( 1 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected" );
});
}( jQuery ) );
diff --git a/tests/unit/accordion/accordion_deprecated.html b/tests/unit/accordion/accordion_deprecated.html
index e8254f4f3..5bfe7562b 100644
--- a/tests/unit/accordion/accordion_deprecated.html
+++ b/tests/unit/accordion/accordion_deprecated.html
@@ -22,17 +22,17 @@
var actual = accordion.find( ".ui-accordion-content" ).map(function() {
return $( this ).css( "display" ) === "none" ? 0 : 1;
}).get();
- same( actual, expected );
+ deepEqual( actual, expected );
}
- function equalHeights( accordion, min, max ) {
+ 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 ] );
- same( sizes[ 0 ], sizes[ 1 ] );
- same( sizes[ 0 ], sizes[ 2 ] );
+ deepEqual( sizes[ 0 ], sizes[ 1 ] );
+ deepEqual( sizes[ 0 ], sizes[ 2 ] );
}
function accordionSetupTeardown() {
var animated = $.ui.accordion.prototype.options.animated;
diff --git a/tests/unit/accordion/accordion_deprecated.js b/tests/unit/accordion/accordion_deprecated.js
index 0435f48a7..3a2075b2b 100644
--- a/tests/unit/accordion/accordion_deprecated.js
+++ b/tests/unit/accordion/accordion_deprecated.js
@@ -3,6 +3,7 @@
module( "accordion (deprecated): expanded active option, activate method", accordionSetupTeardown() );
test( "activate, numeric", function() {
+ expect( 5 );
var element = $( "#list1" ).accordion({ active: 1 });
accordion_state( element, 0, 1, 0 );
element.accordion( "activate", 2 );
@@ -16,6 +17,7 @@ test( "activate, numeric", function() {
});
test( "activate, numeric, collapsible:true", function() {
+ expect( 3 );
var element = $( "#list1" ).accordion({ collapsible: true });
element.accordion( "activate", 2 );
accordion_state( element, 0, 0, 1 );
@@ -26,6 +28,7 @@ test( "activate, numeric, collapsible:true", function() {
});
test( "activate, boolean, collapsible: true", function() {
+ expect( 2 );
var element = $( "#list1" ).accordion({ collapsible: true });
element.accordion( "activate", 2 );
accordion_state( element, 0, 0, 1 );
@@ -34,6 +37,7 @@ test( "activate, boolean, collapsible: true", function() {
});
test( "activate, boolean, collapsible: false", function() {
+ expect( 2 );
var element = $( "#list1" ).accordion();
element.accordion( "activate", 2 );
accordion_state( element, 0, 0, 1 );
@@ -42,6 +46,7 @@ test( "activate, boolean, collapsible: false", function() {
});
test( "activate, string expression", function() {
+ expect( 4 );
var element = $( "#list1" ).accordion({ active: "h3:last" });
accordion_state( element, 0, 0, 1 );
element.accordion( "activate", ":first" );
@@ -53,6 +58,7 @@ test( "activate, string expression", function() {
});
test( "activate, jQuery or DOM element", function() {
+ expect( 3 );
var element = $( "#list1" ).accordion({ active: $( "#list1 h3:last" ) });
accordion_state( element, 0, 0, 1 );
element.accordion( "activate", $( "#list1 h3:first" ) );
@@ -62,6 +68,7 @@ test( "activate, jQuery or DOM element", function() {
});
test( "{ active: Selector }", function() {
+ expect( 2 );
var element = $("#list1").accordion({
active: "h3:last"
});
@@ -71,6 +78,7 @@ test( "{ active: Selector }", function() {
});
test( "{ active: Element }", function() {
+ expect( 2 );
var element = $( "#list1" ).accordion({
active: $( "#list1 h3:last" )[ 0 ]
});
@@ -80,6 +88,7 @@ test( "{ active: Element }", function() {
});
test( "{ active: jQuery Object }", function() {
+ expect( 2 );
var element = $( "#list1" ).accordion({
active: $( "#list1 h3:last" )
});
@@ -95,14 +104,16 @@ test( "{ active: jQuery Object }", function() {
module( "accordion (deprecated) - height options", accordionSetupTeardown() );
test( "{ autoHeight: true }, default", function() {
- equalHeights($('#navigation').accordion({ autoHeight: true }), 95, 130);
+ expect( 3 );
+ accordion_equalHeights( $( "#navigation" ).accordion({ autoHeight: true }), 95, 130 );
});
-test("{ autoHeight: false }", function() {
- var element = $('#navigation').accordion({ autoHeight: false });
+test( "{ autoHeight: false }", function() {
+ expect( 3 );
+ var element = $( "#navigation" ).accordion({ autoHeight: false });
var sizes = [];
- element.find(".ui-accordion-content").each(function() {
- sizes.push($(this).height());
+ element.find( ".ui-accordion-content" ).each(function() {
+ sizes.push( $(this).height() );
});
ok( sizes[0] >= 70 && sizes[0] <= 105, "was " + sizes[0] );
ok( sizes[1] >= 98 && sizes[1] <= 126, "was " + sizes[1] );
@@ -110,12 +121,14 @@ test("{ autoHeight: false }", function() {
});
test( "{ fillSpace: true }", function() {
+ expect( 3 );
$( "#navigationWrapper" ).height( 500 );
var element = $( "#navigation" ).accordion({ fillSpace: true });
- equalHeights( element, 446, 458 );
+ accordion_equalHeights( element, 446, 458 );
});
test( "{ fillSapce: true } with sibling", function() {
+ expect( 3 );
$( "#navigationWrapper" ).height( 500 );
$( "<p>Lorem Ipsum</p>" )
.css({
@@ -125,10 +138,11 @@ test( "{ fillSapce: true } with sibling", function() {
})
.prependTo( "#navigationWrapper" );
var element = $( "#navigation" ).accordion({ fillSpace: true });
- equalHeights( element , 346, 358);
+ accordion_equalHeights( element , 346, 358);
});
test( "{ fillSpace: true } with multiple siblings", function() {
+ expect( 3 );
$( "#navigationWrapper" ).height( 500 );
$( "<p>Lorem Ipsum</p>" )
.css({
@@ -153,7 +167,7 @@ test( "{ fillSpace: true } with multiple siblings", function() {
})
.prependTo( "#navigationWrapper" );
var element = $( "#navigation" ).accordion({ fillSpace: true });
- equalHeights( element, 296, 308 );
+ accordion_equalHeights( element, 296, 308 );
});
@@ -163,6 +177,7 @@ test( "{ fillSpace: true } with multiple siblings", function() {
module( "accordion (deprecated) - icons", accordionSetupTeardown() );
test( "icons, headerSelected", function() {
+ expect( 3 );
var element = $( "#list1" ).accordion({
icons: { headerSelected: "a1", header: "h1" }
});
@@ -179,6 +194,7 @@ test( "icons, headerSelected", function() {
module( "accordion (deprecated) - resize", accordionSetupTeardown() );
test( "resize", function() {
+ expect( 6 );
var element = $( "#navigation" )
.parent()
.height( 300 )
@@ -186,11 +202,11 @@ test( "resize", function() {
.accordion({
heightStyle: "fill"
});
- equalHeights( element, 246, 258 );
+ accordion_equalHeights( element, 246, 258 );
element.parent().height( 500 );
element.accordion( "resize" );
- equalHeights( element, 446, 458 );
+ accordion_equalHeights( element, 446, 458 );
});
@@ -200,6 +216,7 @@ test( "resize", function() {
module( "accordion (deprecated) - navigation", accordionSetupTeardown() );
test( "{ navigation: true, navigationFilter: header }", function() {
+ expect( 2 );
var element = $( "#navigation" ).accordion({
navigation: true,
navigationFilter: function() {
@@ -211,10 +228,11 @@ test( "{ navigation: true, navigationFilter: header }", function() {
});
test( "{ navigation: true, navigationFilter: content }", function() {
- var element = $("#navigation").accordion({
+ expect( 2 );
+ var element = $( "#navigation" ).accordion({
navigation: true,
navigationFilter: function() {
- return /\?p=1\.1\.3\.2$/.test(this.href);
+ return /\?p=1\.1\.3\.2$/.test( this.href );
}
});
equal( element.accordion( "option", "active" ), 2 );
@@ -237,11 +255,11 @@ test( "changestart", function() {
var content = element.find( ".ui-accordion-content" );
element.one( "accordionchangestart", function( event, ui ) {
- equals( ui.oldHeader.size(), 0 );
- equals( ui.oldContent.size(), 0 );
- equals( ui.newHeader.size(), 1 );
+ equal( ui.oldHeader.size(), 0 );
+ equal( ui.oldContent.size(), 0 );
+ equal( ui.newHeader.size(), 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 0 ] );
- equals( ui.newContent.size(), 1 );
+ equal( ui.newContent.size(), 1 );
strictEqual( ui.newContent[ 0 ], content[ 0 ] );
accordion_state( element, 0, 0, 0 );
});
@@ -249,13 +267,13 @@ test( "changestart", function() {
accordion_state( element, 1, 0, 0 );
element.one( "accordionchangestart", function( event, ui ) {
- equals( ui.oldHeader.size(), 1 );
+ equal( ui.oldHeader.size(), 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] );
- equals( ui.oldContent.size(), 1 );
+ equal( ui.oldContent.size(), 1 );
strictEqual( ui.oldContent[ 0 ], content[ 0 ] );
- equals( ui.newHeader.size(), 1 );
+ equal( ui.newHeader.size(), 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 1 ] );
- equals( ui.newContent.size(), 1 );
+ equal( ui.newContent.size(), 1 );
strictEqual( ui.newContent[ 0 ], content[ 1 ] );
accordion_state( element, 1, 0, 0 );
});
@@ -263,12 +281,12 @@ test( "changestart", function() {
accordion_state( element, 0, 1, 0 );
element.one( "accordionchangestart", function( event, ui ) {
- equals( ui.oldHeader.size(), 1 );
+ equal( ui.oldHeader.size(), 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] );
- equals( ui.oldContent.size(), 1 );
+ equal( ui.oldContent.size(), 1 );
strictEqual( ui.oldContent[ 0 ], content[ 1 ] );
- equals( ui.newHeader.size(), 0 );
- equals( ui.newContent.size(), 0 );
+ equal( ui.newHeader.size(), 0 );
+ equal( ui.newContent.size(), 0 );
accordion_state( element, 0, 1, 0 );
});
element.accordion( "option", "active", false );
@@ -285,34 +303,34 @@ test( "change", function() {
var content = element.find( ".ui-accordion-content" );
element.one( "accordionchange", function( event, ui ) {
- equals( ui.oldHeader.size(), 0 );
- equals( ui.oldContent.size(), 0 );
- equals( ui.newHeader.size(), 1 );
+ equal( ui.oldHeader.size(), 0 );
+ equal( ui.oldContent.size(), 0 );
+ equal( ui.newHeader.size(), 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 0 ] );
- equals( ui.newContent.size(), 1 );
+ equal( ui.newContent.size(), 1 );
strictEqual( ui.newContent[ 0 ], content[ 0 ] );
});
element.accordion( "option", "active", 0 );
element.one( "accordionchange", function( event, ui ) {
- equals( ui.oldHeader.size(), 1 );
+ equal( ui.oldHeader.size(), 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] );
- equals( ui.oldContent.size(), 1 );
+ equal( ui.oldContent.size(), 1 );
strictEqual( ui.oldContent[ 0 ], content[ 0 ] );
- equals( ui.newHeader.size(), 1 );
+ equal( ui.newHeader.size(), 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 1 ] );
- equals( ui.newContent.size(), 1 );
+ equal( ui.newContent.size(), 1 );
strictEqual( ui.newContent[ 0 ], content[ 1 ] );
});
headers.eq( 1 ).click();
element.one( "accordionchange", function( event, ui ) {
- equals( ui.oldHeader.size(), 1 );
+ equal( ui.oldHeader.size(), 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] );
- equals( ui.oldContent.size(), 1 );
+ equal( ui.oldContent.size(), 1 );
strictEqual( ui.oldContent[ 0 ], content[ 1 ] );
- equals( ui.newHeader.size(), 0 );
- equals( ui.newContent.size(), 0 );
+ equal( ui.newHeader.size(), 0 );
+ equal( ui.newContent.size(), 0 );
});
element.accordion( "option", "active", false );
});
diff --git a/tests/unit/accordion/accordion_events.js b/tests/unit/accordion/accordion_events.js
index 2438f28ea..d704e54c8 100644
--- a/tests/unit/accordion/accordion_events.js
+++ b/tests/unit/accordion/accordion_events.js
@@ -13,11 +13,11 @@ test( "beforeActivate", function() {
element.one( "accordionbeforeactivate", function( event, ui ) {
ok( !( "originalEvent" in event ) );
- equals( ui.oldHeader.size(), 0 );
- equals( ui.oldContent.size(), 0 );
- equals( ui.newHeader.size(), 1 );
+ equal( ui.oldHeader.size(), 0 );
+ equal( ui.oldContent.size(), 0 );
+ equal( ui.newHeader.size(), 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 0 ] );
- equals( ui.newContent.size(), 1 );
+ equal( ui.newContent.size(), 1 );
strictEqual( ui.newContent[ 0 ], content[ 0 ] );
accordion_state( element, 0, 0, 0 );
});
@@ -25,14 +25,14 @@ test( "beforeActivate", function() {
accordion_state( element, 1, 0, 0 );
element.one( "accordionbeforeactivate", function( event, ui ) {
- equals( event.originalEvent.type, "click" );
- equals( ui.oldHeader.size(), 1 );
+ equal( event.originalEvent.type, "click" );
+ equal( ui.oldHeader.size(), 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] );
- equals( ui.oldContent.size(), 1 );
+ equal( ui.oldContent.size(), 1 );
strictEqual( ui.oldContent[ 0 ], content[ 0 ] );
- equals( ui.newHeader.size(), 1 );
+ equal( ui.newHeader.size(), 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 1 ] );
- equals( ui.newContent.size(), 1 );
+ equal( ui.newContent.size(), 1 );
strictEqual( ui.newContent[ 0 ], content[ 1 ] );
accordion_state( element, 1, 0, 0 );
});
@@ -41,12 +41,12 @@ test( "beforeActivate", function() {
element.one( "accordionbeforeactivate", function( event, ui ) {
ok( !( "originalEvent" in event ) );
- equals( ui.oldHeader.size(), 1 );
+ equal( ui.oldHeader.size(), 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] );
- equals( ui.oldContent.size(), 1 );
+ equal( ui.oldContent.size(), 1 );
strictEqual( ui.oldContent[ 0 ], content[ 1 ] );
- equals( ui.newHeader.size(), 0 );
- equals( ui.newContent.size(), 0 );
+ equal( ui.newHeader.size(), 0 );
+ equal( ui.newContent.size(), 0 );
accordion_state( element, 0, 1, 0 );
});
element.accordion( "option", "active", false );
@@ -54,11 +54,11 @@ test( "beforeActivate", function() {
element.one( "accordionbeforeactivate", function( event, ui ) {
ok( !( "originalEvent" in event ) );
- equals( ui.oldHeader.size(), 0 );
- equals( ui.oldContent.size(), 0 );
- equals( ui.newHeader.size(), 1 );
+ equal( ui.oldHeader.size(), 0 );
+ equal( ui.oldContent.size(), 0 );
+ equal( ui.newHeader.size(), 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 2 ] );
- equals( ui.newContent.size(), 1 );
+ equal( ui.newContent.size(), 1 );
strictEqual( ui.newContent[ 0 ], content[ 2 ] );
event.preventDefault();
accordion_state( element, 0, 0, 0 );
@@ -77,34 +77,34 @@ test( "activate", function() {
var content = element.find( ".ui-accordion-content" );
element.one( "accordionactivate", function( event, ui ) {
- equals( ui.oldHeader.size(), 0 );
- equals( ui.oldContent.size(), 0 );
- equals( ui.newHeader.size(), 1 );
+ equal( ui.oldHeader.size(), 0 );
+ equal( ui.oldContent.size(), 0 );
+ equal( ui.newHeader.size(), 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 0 ] );
- equals( ui.newContent.size(), 1 );
+ equal( ui.newContent.size(), 1 );
strictEqual( ui.newContent[ 0 ], content[ 0 ] );
});
element.accordion( "option", "active", 0 );
element.one( "accordionactivate", function( event, ui ) {
- equals( ui.oldHeader.size(), 1 );
+ equal( ui.oldHeader.size(), 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] );
- equals( ui.oldContent.size(), 1 );
+ equal( ui.oldContent.size(), 1 );
strictEqual( ui.oldContent[ 0 ], content[ 0 ] );
- equals( ui.newHeader.size(), 1 );
+ equal( ui.newHeader.size(), 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 1 ] );
- equals( ui.newContent.size(), 1 );
+ equal( ui.newContent.size(), 1 );
strictEqual( ui.newContent[ 0 ], content[ 1 ] );
});
headers.eq( 1 ).click();
element.one( "accordionactivate", function( event, ui ) {
- equals( ui.oldHeader.size(), 1 );
+ equal( ui.oldHeader.size(), 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] );
- equals( ui.oldContent.size(), 1 );
+ equal( ui.oldContent.size(), 1 );
strictEqual( ui.oldContent[ 0 ], content[ 1 ] );
- equals( ui.newHeader.size(), 0 );
- equals( ui.newContent.size(), 0 );
+ equal( ui.newHeader.size(), 0 );
+ equal( ui.newContent.size(), 0 );
});
element.accordion( "option", "active", false );
diff --git a/tests/unit/accordion/accordion_methods.js b/tests/unit/accordion/accordion_methods.js
index d45bde134..c6ba3230a 100644
--- a/tests/unit/accordion/accordion_methods.js
+++ b/tests/unit/accordion/accordion_methods.js
@@ -3,13 +3,15 @@
module( "accordion: methods", accordionSetupTeardown() );
test( "destroy", function() {
- domEqual("#list1", function() {
- $("#list1").accordion().accordion("destroy");
+ expect( 1 );
+ domEqual( "#list1", function() {
+ $( "#list1" ).accordion().accordion( "destroy" );
});
});
test( "enable/disable", function() {
- var element = $('#list1').accordion();
+ expect( 3 );
+ var element = $( "#list1" ).accordion();
accordion_state( element, 1, 0, 0 );
element.accordion( "disable" );
element.accordion( "option", "active", 1 );
@@ -20,6 +22,7 @@ test( "enable/disable", function() {
});
test( "refresh", function() {
+ expect( 6 );
var element = $( "#navigation" )
.parent()
.height( 300 )
@@ -27,11 +30,11 @@ test( "refresh", function() {
.accordion({
heightStyle: "fill"
});
- equalHeights( element, 246, 258 );
+ accordion_equalHeights( element, 246, 258 );
element.parent().height( 500 );
element.accordion( "refresh" );
- equalHeights( element, 446, 458 );
+ accordion_equalHeights( element, 446, 458 );
});
}( jQuery ) );
diff --git a/tests/unit/accordion/accordion_options.js b/tests/unit/accordion/accordion_options.js
index 7bd6f2e74..80b7f0b39 100644
--- a/tests/unit/accordion/accordion_options.js
+++ b/tests/unit/accordion/accordion_options.js
@@ -3,23 +3,25 @@
module( "accordion: options", accordionSetupTeardown() );
test( "{ active: default }", function() {
+ expect( 2 );
var element = $( "#list1" ).accordion();
- equals( element.accordion( "option", "active" ), 0 );
+ equal( element.accordion( "option", "active" ), 0 );
accordion_state( element, 1, 0, 0 );
});
test( "{ active: false }", function() {
+ expect( 7 );
var element = $( "#list1" ).accordion({
active: false,
collapsible: true
});
accordion_state( element, 0, 0, 0 );
- equals( element.find( ".ui-accordion-header.ui-state-active" ).size(), 0, "no headers selected" );
- equals( element.accordion( "option", "active" ), false );
+ equal( element.find( ".ui-accordion-header.ui-state-active" ).size(), 0, "no headers selected" );
+ equal( element.accordion( "option", "active" ), false );
element.accordion( "option", "collapsible", false );
accordion_state( element, 1, 0, 0 );
- equals( element.accordion( "option", "active" ), 0 );
+ equal( element.accordion( "option", "active" ), 0 );
element.accordion( "destroy" );
element.accordion({
@@ -30,43 +32,45 @@ test( "{ active: false }", function() {
});
test( "{ active: Number }", function() {
+ expect( 8 );
var element = $( "#list1" ).accordion({
active: 2
});
- equals( element.accordion( "option", "active" ), 2 );
+ equal( element.accordion( "option", "active" ), 2 );
accordion_state( element, 0, 0, 1 );
element.accordion( "option", "active", 0 );
- equals( element.accordion( "option", "active" ), 0 );
+ equal( element.accordion( "option", "active" ), 0 );
accordion_state( element, 1, 0, 0 );
element.find( ".ui-accordion-header" ).eq( 1 ).click();
- equals( element.accordion( "option", "active" ), 1 );
+ equal( element.accordion( "option", "active" ), 1 );
accordion_state( element, 0, 1, 0 );
element.accordion( "option", "active", 10 );
- equals( element.accordion( "option", "active" ), 1 );
+ equal( element.accordion( "option", "active" ), 1 );
accordion_state( element, 0, 1, 0 );
});
if ( $.uiBackCompat === false ) {
test( "{ active: -Number }", function() {
+ expect( 8 );
var element = $( "#list1" ).accordion({
active: -1
});
- equals( element.accordion( "option", "active" ), 2 );
+ equal( element.accordion( "option", "active" ), 2 );
accordion_state( element, 0, 0, 1 );
element.accordion( "option", "active", -2 );
- equals( element.accordion( "option", "active" ), 1 );
+ equal( element.accordion( "option", "active" ), 1 );
accordion_state( element, 0, 1, 0 );
element.accordion( "option", "active", -10 );
- equals( element.accordion( "option", "active" ), 1 );
+ equal( element.accordion( "option", "active" ), 1 );
accordion_state( element, 0, 1, 0 );
element.accordion( "option", "active", -3 );
- equals( element.accordion( "option", "active" ), 0 );
+ equal( element.accordion( "option", "active" ), 0 );
accordion_state( element, 1, 0, 0 );
});
}
@@ -74,6 +78,7 @@ if ( $.uiBackCompat === false ) {
// TODO: add animation tests
test( "{ collapsible: false }", function() {
+ expect( 4 );
var element = $( "#list1" ).accordion({
active: 1
});
@@ -87,6 +92,7 @@ test( "{ collapsible: false }", function() {
});
test( "{ collapsible: true }", function() {
+ expect( 6 );
var element = $( "#list1" ).accordion({
active: 1,
collapsible: true
@@ -101,11 +107,12 @@ test( "{ collapsible: true }", function() {
accordion_state( element, 0, 1, 0 );
element.find( ".ui-accordion-header" ).eq( 1 ).click();
- equals( element.accordion( "option", "active" ), false );
+ equal( element.accordion( "option", "active" ), false );
accordion_state( element, 0, 0, 0 );
});
test( "{ event: null }", function() {
+ expect( 5 );
var element = $( "#list1" ).accordion({
event: null
});
@@ -122,6 +129,7 @@ test( "{ event: null }", function() {
});
test( "{ event: custom }", function() {
+ expect( 11 );
var element = $( "#list1" ).accordion({
event: "custom1 custom2"
});
@@ -153,6 +161,7 @@ test( "{ event: custom }", function() {
});
test( "{ header: default }", function() {
+ expect( 2 );
// default: > li > :first-child,> :not(li):even
// > :not(li):even
accordion_state( $( "#list1" ).accordion(), 1, 0, 0);
@@ -161,6 +170,7 @@ test( "{ header: default }", function() {
});
test( "{ header: custom }", function() {
+ expect( 6 );
var element = $( "#navigationWrapper" ).accordion({
header: "h2"
});
@@ -174,11 +184,13 @@ test( "{ header: custom }", function() {
});
test( "{ heightStyle: 'auto' }", function() {
+ expect( 3 );
var element = $( "#navigation" ).accordion({ heightStyle: "auto" });
- equalHeights( element, 95, 130 );
+ accordion_equalHeights( element, 95, 130 );
});
test( "{ heightStyle: 'content' }", function() {
+ expect( 3 );
var element = $( "#navigation" ).accordion({ heightStyle: "content" });
var sizes = element.find( ".ui-accordion-content" ).map(function() {
return $( this ).height();
@@ -189,12 +201,14 @@ test( "{ heightStyle: 'content' }", function() {
});
test( "{ heightStyle: 'fill' }", function() {
+ expect( 3 );
$( "#navigationWrapper" ).height( 500 );
var element = $( "#navigation" ).accordion({ heightStyle: "fill" });
- equalHeights( element, 446, 458 );
+ accordion_equalHeights( element, 446, 458 );
});
test( "{ heightStyle: 'fill' } with sibling", function() {
+ expect( 3 );
$( "#navigationWrapper" ).height( 500 );
$( "<p>Lorem Ipsum</p>" )
.css({
@@ -204,10 +218,11 @@ test( "{ heightStyle: 'fill' } with sibling", function() {
})
.prependTo( "#navigationWrapper" );
var element = $( "#navigation" ).accordion({ heightStyle: "fill" });
- equalHeights( element , 346, 358);
+ accordion_equalHeights( element , 346, 358);
});
test( "{ heightStyle: 'fill' } with multiple siblings", function() {
+ expect( 3 );
$( "#navigationWrapper" ).height( 500 );
$( "<p>Lorem Ipsum</p>" )
.css({
@@ -232,14 +247,15 @@ test( "{ heightStyle: 'fill' } with multiple siblings", function() {
})
.prependTo( "#navigationWrapper" );
var element = $( "#navigation" ).accordion({ heightStyle: "fill" });
- equalHeights( element, 296, 308 );
+ accordion_equalHeights( element, 296, 308 );
});
test( "{ icons: false }", function() {
+ expect( 8 );
var element = $( "#list1" );
function icons( on ) {
- same( element.find( "span.ui-icon").length, on ? 3 : 0 );
- same( element.hasClass( "ui-accordion-icons" ), on );
+ deepEqual( element.find( "span.ui-icon").length, on ? 3 : 0 );
+ deepEqual( element.hasClass( "ui-accordion-icons" ), on );
}
element.accordion();
icons( true );
@@ -254,6 +270,7 @@ test( "{ icons: false }", function() {
});
test( "{ icons: hash }", function() {
+ expect( 3 );
var element = $( "#list1" ).accordion({
icons: { activeHeader: "a1", header: "h1" }
});
diff --git a/tests/unit/autocomplete/autocomplete.html b/tests/unit/autocomplete/autocomplete.html
index 8f1d9db9a..a69562d3f 100644
--- a/tests/unit/autocomplete/autocomplete.html
+++ b/tests/unit/autocomplete/autocomplete.html
@@ -1,46 +1,44 @@
-<!DOCTYPE html>
+<!doctype html>
<html lang="en">
<head>
- <meta charset="UTF-8" />
+ <meta charset="utf-8">
<title>jQuery UI Autocomplete Test Suite</title>
- <link type="text/css" href="../../../themes/base/jquery.ui.autocomplete.css" rel="stylesheet" />
-
- <script type="text/javascript" src="../../../jquery-1.5.1.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="../../../ui/jquery.ui.autocomplete.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="autocomplete_core.js"></script>
- <script type="text/javascript" src="autocomplete_defaults.js"></script>
- <script type="text/javascript" src="autocomplete_events.js"></script>
- <script type="text/javascript" src="autocomplete_methods.js"></script>
- <script type="text/javascript" src="autocomplete_options.js"></script>
-
- <script type="text/javascript" src="../swarminject.js"></script>
+ <link rel="stylesheet" href="../../../themes/base/jquery.ui.autocomplete.css">
+
+ <script src="../../../jquery-1.5.1.js"></script>
+ <script src="../../../ui/jquery.ui.core.js"></script>
+ <script src="../../../ui/jquery.ui.widget.js"></script>
+ <script src="../../../ui/jquery.ui.position.js"></script>
+ <script src="../../../ui/jquery.ui.menu.js"></script>
+ <script src="../../../ui/jquery.ui.autocomplete.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="autocomplete_defaults.js"></script>
+ <script src="autocomplete_core.js"></script>
+ <script src="autocomplete_events.js"></script>
+ <script src="autocomplete_methods.js"></script>
+ <script src="autocomplete_options.js"></script>
+
+ <script src="../swarminject.js"></script>
</head>
-<body id="body">
+<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>
-
+<ol id="qunit-tests"></ol>
<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="autocomplete-contenteditable" contenteditable="" tabindex=0></div>
-</div>
+<div id="ac-wrap1" class="ac-wrap"></div>
+<div id="ac-wrap2" class="ac-wrap"><input id="autocomplete" class="foo" /></div>
+<div id="autocomplete-contenteditable" contenteditable="" tabindex=0></div>
+</div>
</body>
</html>
diff --git a/tests/unit/autocomplete/autocomplete_core.js b/tests/unit/autocomplete/autocomplete_core.js
index 19f52dc15..3f92aa01f 100644
--- a/tests/unit/autocomplete/autocomplete_core.js
+++ b/tests/unit/autocomplete/autocomplete_core.js
@@ -1,73 +1,83 @@
-/*
- * autocomplete_core.js
- */
+(function( $ ) {
+module( "autocomplete: core" );
-(function($) {
+asyncTest( "close-on-blur is properly delayed", function() {
+ expect( 3 );
+ var element = $( "#autocomplete" )
+ .autocomplete({
+ source: [ "java", "javascript" ]
+ })
+ .val( "ja" )
+ .autocomplete( "search" ),
+ menu = element.autocomplete( "widget" );
-module("autocomplete: core", {
- teardown: function() {
- $( ":ui-autocomplete" ).autocomplete( "destroy" );
- }
-});
-
-test("close-on-blur is properly delayed", function() {
- var ac = $("#autocomplete").autocomplete({
- source: ["java", "javascript"]
- }).val("ja").autocomplete("search");
- same( $(".ui-menu:visible").length, 1 );
- ac.blur();
- same( $(".ui-menu:visible").length, 1 );
- stop();
+ ok( menu.is( ":visible" ) );
+ element.blur();
+ ok( menu.is( ":visible" ) );
setTimeout(function() {
- same( $(".ui-menu:visible").length, 0 );
+ ok( menu.is( ":hidden") );
start();
- }, 200);
+ }, 200 );
});
-test("close-on-blur is cancelled when starting a search", function() {
- var ac = $("#autocomplete").autocomplete({
- source: ["java", "javascript"]
- }).val("ja").autocomplete("search");
- same( $(".ui-menu:visible").length, 1 );
- ac.blur();
- same( $(".ui-menu:visible").length, 1 );
- ac.autocomplete("search");
- stop();
+asyncTest( "close-on-blur is cancelled when starting a search", function() {
+ expect( 3 );
+ var element = $( "#autocomplete" )
+ .autocomplete({
+ source: [ "java", "javascript" ]
+ })
+ .val( "ja" )
+ .autocomplete( "search" ),
+ menu = element.autocomplete( "widget" );
+
+ ok( menu.is( ":visible" ) );
+ element.blur();
+ ok( menu.is( ":visible" ) );
+ element.autocomplete( "search" );
setTimeout(function() {
- same( $(".ui-menu:visible").length, 1 );
+ ok( menu.is( ":visible" ) );
start();
- }, 200);
+ }, 200 );
});
test( "prevent form submit on enter when menu is active", function() {
- var event;
- var ac = $( "#autocomplete" ).autocomplete({
- source: [ "java", "javascript" ]
- }).val( "ja" ).autocomplete( "search" );
-
+ expect( 2 );
+ var event,
+ element = $( "#autocomplete" )
+ .autocomplete({
+ source: [ "java", "javascript" ]
+ })
+ .val( "ja" )
+ .autocomplete( "search" ),
+ menu = element.autocomplete( "widget" );
+
event = $.Event( "keydown" );
event.keyCode = $.ui.keyCode.DOWN;
- ac.trigger( event );
- same( $( ".ui-menu-item:has(.ui-state-focus)" ).length, 1, "menu item is active" );
-
+ element.trigger( event );
+ deepEqual( menu.find( ".ui-menu-item:has(.ui-state-focus)" ).length, 1, "menu item is active" );
+
event = $.Event( "keydown" );
event.keyCode = $.ui.keyCode.ENTER;
- ac.trigger( event );
+ element.trigger( event );
ok( event.isDefaultPrevented(), "default action is prevented" );
});
test( "allow form submit on enter when menu is not active", function() {
- var event;
- var ac = $( "#autocomplete" ).autocomplete({
- autoFocus: false,
- source: [ "java", "javascript" ]
- }).val( "ja" ).autocomplete( "search" );
-
+ expect( 1 );
+ var event,
+ element = $( "#autocomplete" )
+ .autocomplete({
+ autoFocus: false,
+ source: [ "java", "javascript" ]
+ })
+ .val( "ja" )
+ .autocomplete( "search" );
+
event = $.Event( "keydown" );
event.keyCode = $.ui.keyCode.ENTER;
- ac.trigger( event );
+ element.trigger( event );
ok( !event.isDefaultPrevented(), "default action is prevented" );
});
-})(jQuery);
+}( jQuery ) );
diff --git a/tests/unit/autocomplete/autocomplete_events.js b/tests/unit/autocomplete/autocomplete_events.js
index c884733d6..c6d42ddcc 100644
--- a/tests/unit/autocomplete/autocomplete_events.js
+++ b/tests/unit/autocomplete/autocomplete_events.js
@@ -1,206 +1,197 @@
-/*
- * autocomplete_events.js
- */
-(function($) {
+(function( $ ) {
-module("autocomplete: events", {
- teardown: function() {
- $( ":ui-autocomplete" ).autocomplete( "destroy" );
- }
-});
+module( "autocomplete: events" );
var data = [ "Clojure", "COBOL", "ColdFusion", "Java", "JavaScript", "Scala", "Scheme" ];
-test("all events", function() {
- expect(14);
- var ac = $("#autocomplete").autocomplete({
- autoFocus: false,
- delay: 0,
- source: data,
- search: function(event) {
- same(event.type, "autocompletesearch");
- },
- response: function(event, ui) {
- same(event.type, "autocompleteresponse");
- same(ui.content, [
- { label: "Clojure", value: "Clojure" },
- { label: "Java", value: "Java" },
- { label: "JavaScript", value: "JavaScript" }
- ]);
- ui.content.splice( 0, 1 );
- },
- open: function(event) {
- same(event.type, "autocompleteopen");
- },
- focus: function(event, ui) {
- same(event.type, "autocompletefocus");
- same(ui.item, {label:"Java", value:"Java"});
- },
- close: function(event) {
- same(event.type, "autocompleteclose");
- same( $(".ui-menu:visible").length, 0 );
- },
- select: function(event, ui) {
- same(event.type, "autocompleteselect");
- same(ui.item, {label:"Java", value:"Java"});
- },
- change: function(event, ui) {
- same(event.type, "autocompletechange");
- same(ui.item, {label:"Java", value:"Java"});
- same( $(".ui-menu:visible").length, 0 );
- start();
- }
- });
- stop();
- ac.focus().val("j").keydown();
+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() {
- same( $(".ui-menu:visible").length, 1 );
- ac.simulate("keydown", { keyCode: $.ui.keyCode.DOWN });
- ac.simulate("keydown", { keyCode: $.ui.keyCode.ENTER });
+ 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
- ac[0].blur();
- }, 50);
+ element[0].blur();
+ }, 50 );
});
-test("all events - contenteditable", function() {
- expect(14);
- var ac = $("#autocomplete-contenteditable").autocomplete({
- autoFocus: false,
- delay: 0,
- source: data,
- search: function(event) {
- same(event.type, "autocompletesearch");
- },
- response: function(event, ui) {
- same(event.type, "autocompleteresponse");
- same(ui.content, [
- { label: "Clojure", value: "Clojure" },
- { label: "Java", value: "Java" },
- { label: "JavaScript", value: "JavaScript" }
- ]);
- ui.content.splice( 0, 1 );
- },
- open: function(event) {
- same(event.type, "autocompleteopen");
- },
- focus: function(event, ui) {
- same(event.type, "autocompletefocus");
- same(ui.item, {label:"Java", value:"Java"});
- },
- close: function(event) {
- same(event.type, "autocompleteclose");
- same( $(".ui-menu:visible").length, 0 );
- },
- select: function(event, ui) {
- same(event.type, "autocompleteselect");
- same(ui.item, {label:"Java", value:"Java"});
- },
- change: function(event, ui) {
- same(event.type, "autocompletechange");
- same(ui.item, {label:"Java", value:"Java"});
- same( $(".ui-menu:visible").length, 0 );
- start();
- }
- });
- stop();
- ac.focus().text("j").keydown();
+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() {
- same( $(".ui-menu:visible").length, 1 );
- ac.simulate("keydown", { keyCode: $.ui.keyCode.DOWN });
- ac.simulate("keydown", { keyCode: $.ui.keyCode.ENTER });
- // blurring through jQuery causes a bug in IE 6 which causes the
+ 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
- ac[0].blur();
- }, 50);
+ element[0].blur();
+ }, 50 );
});
-test("change without selection", function() {
- expect(2);
- stop();
- var ac = $("#autocomplete").autocomplete({
+asyncTest( "change without selection", function() {
+ expect( 1 );
+ var element = $( "#autocomplete" ).autocomplete({
delay: 0,
source: data,
- change: function(event, ui) {
- same(event.type, "autocompletechange");
- same(ui.item, null);
+ change: function( event, ui ) {
+ strictEqual( ui.item, null );
start();
}
});
- ac.triggerHandler("focus");
- ac.val("ja").triggerHandler("blur");
+ element.triggerHandler( "focus" );
+ element.val( "ja" ).triggerHandler( "blur" );
});
-test("cancel search", function() {
- expect(6);
- var first = true;
- var ac = $("#autocomplete").autocomplete({
- delay: 0,
- source: data,
- search: function() {
- if (first) {
- same( ac.val(), "ja" );
- first = false;
- return false;
+asyncTest( "cancel search", function() {
+ expect( 6 );
+ var first = true,
+ element = $( "#autocomplete" ).autocomplete({
+ delay: 0,
+ source: data,
+ search: function() {
+ if ( first ) {
+ equal( element.val(), "ja", "val on first search" );
+ first = false;
+ return false;
+ }
+ equal( element.val(), "java", "val on second search" );
+ },
+ open: function() {
+ ok( true, "menu opened" );
}
- same( ac.val(), "java" );
- },
- open: function() {
- ok(true);
- }
- });
- stop();
- ac.val("ja").keydown();
+ }),
+ menu = element.autocomplete( "widget" );
+ element.val( "ja" ).keydown();
setTimeout(function() {
- same( $(".ui-menu:visible").length, 0 );
- ac.val("java").keydown();
+ ok( menu.is( ":hidden" ), "menu is hidden after first search" );
+ element.val( "java" ).keydown();
setTimeout(function() {
- same( $(".ui-menu:visible").length, 1 );
- same( $(".ui-menu .ui-menu-item").length, 2 );
+ ok( menu.is( ":visible" ), "menu is visible after second search" );
+ equal( menu.find( ".ui-menu-item" ).length, 2, "# of menu items" );
start();
- }, 50);
- }, 50);
+ }, 50 );
+ }, 50 );
});
-test("cancel focus", function() {
- expect(1);
- var customVal = 'custom value';
- var ac = $("#autocomplete").autocomplete({
- delay: 0,
- source: data,
- focus: function(event, ui) {
- $(this).val(customVal);
- return false;
- }
- });
- stop();
- ac.val("ja").keydown();
+asyncTest( "cancel focus", function() {
+ expect( 1 );
+ var customVal = "custom value";
+ element = $( "#autocomplete" ).autocomplete({
+ delay: 0,
+ source: data,
+ focus: function( event, ui ) {
+ $( this ).val( customVal );
+ return false;
+ }
+ });
+ element.val( "ja" ).keydown();
setTimeout(function() {
- ac.simulate("keydown", { keyCode: $.ui.keyCode.DOWN });
- same( ac.val(), customVal );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ equal( element.val(), customVal );
start();
- }, 50);
+ }, 50 );
});
-test("cancel select", function() {
- expect(1);
- var customVal = 'custom value';
- var ac = $("#autocomplete").autocomplete({
- delay: 0,
- source: data,
- select: function(event, ui) {
- $(this).val(customVal);
- return false;
- }
- });
- stop();
- ac.val("ja").keydown();
+asyncTest( "cancel select", function() {
+ expect( 1 );
+ var customVal = "custom value",
+ element = $( "#autocomplete" ).autocomplete({
+ delay: 0,
+ source: data,
+ select: function( event, ui ) {
+ $( this ).val( customVal );
+ return false;
+ }
+ });
+ element.val( "ja" ).keydown();
setTimeout(function() {
- ac.simulate("keydown", { keyCode: $.ui.keyCode.DOWN });
- ac.simulate("keydown", { keyCode: $.ui.keyCode.ENTER });
- same( ac.val(), customVal );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
+ equal( element.val(), customVal );
start();
- }, 50);
+ }, 50 );
});
/* TODO previous fix broke more than it fixed, disabling this for now - messed up regular menu select event
@@ -215,10 +206,10 @@ test("blur without selection", function() {
setTimeout(function() {
$( ".ui-menu-item" ).first().simulate("mouseover");
ac.simulate("keydown", { keyCode: $.ui.keyCode.TAB });
- same( ac.val(), "j" );
+ deepEqual( ac.val(), "j" );
start();
}, 50);
});
*/
-})(jQuery);
+}( jQuery ) );
diff --git a/tests/unit/autocomplete/autocomplete_methods.js b/tests/unit/autocomplete/autocomplete_methods.js
index 1043e47ba..3fe035d28 100644
--- a/tests/unit/autocomplete/autocomplete_methods.js
+++ b/tests/unit/autocomplete/autocomplete_methods.js
@@ -1,39 +1,30 @@
-/*
- * autocomplete_methods.js
- */
-(function($) {
+(function( $ ) {
+module( "autocomplete: methods" );
-module("autocomplete: methods", {
- teardown: function() {
- $( ":ui-autocomplete" ).autocomplete( "destroy" );
- }
+test( "destroy", function() {
+ expect( 1 );
+ domEqual( "#autocomplete", function() {
+ $( "#autocomplete" ).autocomplete().autocomplete( "destroy" );
+ });
});
-test("destroy", function() {
- domEqual("#autocomplete", function() {
- $("#autocomplete").autocomplete().autocomplete("destroy");
- });
-})
+test( "search", function() {
+ expect( 3 );
+ var data = [ "c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", "python", "c", "scala", "groovy", "haskell", "perl" ],
+ element = $( "#autocomplete" ).autocomplete({
+ source: data,
+ minLength: 0
+ }),
+ menu = element.autocomplete( "widget" );
+ element.autocomplete( "search" );
+ equal( menu.find( ".ui-menu-item" ).length, data.length, "all items for a blank search" );
-var data = ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", "python", "c", "scala", "groovy", "haskell", "perl"];
+ element.val( "has" ).autocomplete( "search" );
+ equal( menu.find( ".ui-menu-item" ).text(), "haskell", "only one item for set input value" );
-test("search", function() {
- var ac = $("#autocomplete").autocomplete({
- source: data,
- minLength: 0
- });
- ac.autocomplete("search");
- same( $(".ui-menu .ui-menu-item").length, data.length, "all items for a blank search" );
-
- ac.val("has");
- ac.autocomplete("search")
- same( $(".ui-menu .ui-menu-item").text(), "haskell", "only one item for set input value" );
-
- ac.autocomplete("search", "ja");
- same( $(".ui-menu .ui-menu-item").length, 2, "only java and javascript for 'ja'" );
-
- $("#autocomplete").autocomplete("destroy");
-})
+ element.autocomplete( "search", "ja" );
+ equal( menu.find( ".ui-menu-item" ).length, 2, "only java and javascript for 'ja'" );
+});
-})(jQuery);
+}( jQuery ) );
diff --git a/tests/unit/autocomplete/autocomplete_options.js b/tests/unit/autocomplete/autocomplete_options.js
index f2da2f4aa..01c4e9fef 100644
--- a/tests/unit/autocomplete/autocomplete_options.js
+++ b/tests/unit/autocomplete/autocomplete_options.js
@@ -1,247 +1,192 @@
-/*
- * autocomplete_options.js
- */
-(function($) {
-
-module("autocomplete: options", {
- teardown: function() {
- $( ":ui-autocomplete" ).autocomplete( "destroy" );
- }
-});
-
+(function( $ ) {
-/* disabled until autocomplete actually has built-in support for caching
-// returns at most 4 items
-function source(request) {
- ok(true, "handling a request");
- switch(request.term) {
- case "cha":
- return ["Common Pochard", "Common Chiffchaff", "Common Chaffinch", "Iberian Chiffchaff"]
- case "chaf":
- case "chaff":
- return ["Common Chiffchaff", "Common Chaffinch", "Iberian Chiffchaff"]
- case "chaffi":
- return ["Common Chaffinch"]
- case "schi":
- return ["schifpre"]
- }
-}
+module( "autocomplete: options" );
-function search(input) {
- var autocomplete = input.data("autocomplete");
- autocomplete.search("cha");
- autocomplete.close();
- autocomplete.search("chaf");
- autocomplete.close();
- autocomplete.search("chaff");
- autocomplete.close();
- autocomplete.search("chaffi");
- autocomplete.close();
- autocomplete.search("schi");
-}
-
-test("cache: default", function() {
- expect(2);
- search($("#autocomplete").autocomplete({
- source: source
- }));
-});
-
-test("cache: {limit:4}", function() {
- expect(3);
- search($("#autocomplete").autocomplete({
- cache: {
- limit: 4
- },
- source: source
- }));
-});
-
-test("cache: false", function() {
- expect(5);
- search($("#autocomplete").autocomplete({
- cache: false,
- source: source
- }));
-});
-*/
-
-var data = ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", "python", "c", "scala", "groovy", "haskell", "perl"];
+var data = [ "c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", "python", "c", "scala", "groovy", "haskell", "perl" ];
test( "appendTo", function() {
- var ac = $( "#autocomplete" ).autocomplete();
- same( ac.autocomplete( "widget" ).parent()[0], document.body, "defaults to body" );
- ac.autocomplete( "destroy" );
-
- ac.autocomplete({
- appendTo: "#ac-wrap2"
- });
- same( ac.autocomplete( "widget" ).parent()[0], $( "#ac-wrap2" )[0], "id" );
- ac.autocomplete( "destroy" );
+ expect( 5 );
+ var element = $( "#autocomplete" ).autocomplete();
+ equal( element.autocomplete( "widget" ).parent()[0], document.body, "defaults to body" );
+ element.autocomplete( "destroy" );
- ac.autocomplete({
+ element.autocomplete({
appendTo: ".ac-wrap"
});
- same( ac.autocomplete( "widget" ).parent()[0], $( "#ac-wrap1" )[0], "class" );
- same( $( "#ac-wrap2 .ui-autocomplete").length, 0, "class - only appends to one element")
- ac.autocomplete( "destroy" );
+ equal( element.autocomplete( "widget" ).parent()[0], $( "#ac-wrap1" )[0], "first found element" );
+ equal( $( "#ac-wrap2 .ui-autocomplete" ).length, 0, "only appends to one element" );
+ element.autocomplete( "destroy" );
- ac.autocomplete({
+ element.autocomplete({
appendTo: null
});
- same( ac.autocomplete( "widget" ).parent()[0], document.body, "null" );
- ac.autocomplete( "destroy" );
-
- ac.autocomplete().autocomplete( "option", "appendTo", "#ac-wrap1" );
- same( ac.autocomplete( "widget" ).parent()[0], $( "#ac-wrap1" )[0], "modified after init" );
- ac.autocomplete( "destroy" );
+ equal( element.autocomplete( "widget" ).parent()[0], document.body, "null" );
+ element.autocomplete( "destroy" );
+
+ element.autocomplete().autocomplete( "option", "appendTo", "#ac-wrap1" );
+ equal( element.autocomplete( "widget" ).parent()[0], $( "#ac-wrap1" )[0], "modified after init" );
+ element.autocomplete( "destroy" );
});
function autoFocusTest( afValue, focusedLength ) {
- var ac = $( "#autocomplete" ).autocomplete({
+ var element = $( "#autocomplete" ).autocomplete({
autoFocus: afValue,
delay: 0,
source: data,
open: function( event, ui ) {
- equal( ac.autocomplete( "widget" ).children( ".ui-menu-item:first .ui-state-focus" ).length, focusedLength, "first item is " + afValue ? "" : "not" + " auto focused" );
- start();
+ equal( element.autocomplete( "widget" ).children( ".ui-menu-item:first .ui-state-focus" ).length,
+ focusedLength, "first item is " + (afValue ? "" : "not") + " auto focused" );
+ start();
}
});
- ac.val( "ja" ).keydown();
+ element.val( "ja" ).keydown();
stop();
}
test( "autoFocus: false", function() {
+ expect( 1 );
autoFocusTest( false, 0 );
});
test( "autoFocus: true", function() {
+ expect( 1 );
autoFocusTest( true, 1 );
});
-test("delay", function() {
- var ac = $("#autocomplete").autocomplete({
- source: data,
- delay: 50
- });
- ac.val("ja").keydown();
-
- same( $(".ui-menu:visible").length, 0 );
-
- // wait half a second for the default delay to open the menu
- stop();
- setTimeout(function() {
- same( $(".ui-menu:visible").length, 1 );
- ac.autocomplete("destroy");
- start();
- }, 100);
-});
+asyncTest( "delay", function() {
+ expect( 2 );
+ var element = $( "#autocomplete" ).autocomplete({
+ source: data,
+ delay: 50
+ }),
+ menu = element.autocomplete( "widget" );
+ element.val( "ja" ).keydown();
+
+ ok( menu.is( ":hidden" ), "menu is closed immediately after search" );
-test("disabled", function() {
- var ac = $("#autocomplete").autocomplete({
- source: data,
- delay: 0,
- disabled: true
- });
- ac.val("ja").keydown();
-
- same( $(".ui-menu:visible").length, 0 );
-
- stop();
setTimeout(function() {
- same( $(".ui-menu:visible").length, 0 );
- ac.autocomplete("destroy");
+ ok( menu.is( ":visible" ), "menu is open after delay" );
start();
- }, 50);
+ }, 100 );
});
-test("minLength", function() {
- var ac = $("#autocomplete").autocomplete({
- source: data
- });
- ac.autocomplete("search", "");
- same( $(".ui-menu:visible").length, 0, "blank not enough for minLength: 1" );
-
- ac.autocomplete("option", "minLength", 0);
- ac.autocomplete("search", "");
- same( $(".ui-menu:visible").length, 1, "blank enough for minLength: 0" );
- ac.autocomplete("destroy");
-});
+asyncTest( "disabled", function() {
+ expect( 2 );
+ var element = $( "#autocomplete" ).autocomplete({
+ source: data,
+ delay: 0,
+ disabled: true
+ }),
+ menu = element.autocomplete( "widget" );
+ element.val( "ja" ).keydown();
-test("source, local string array", function() {
- var ac = $("#autocomplete").autocomplete({
- source: data
- });
- ac.val("ja").autocomplete("search");
- same( $(".ui-menu .ui-menu-item").text(), "javajavascript" );
- ac.autocomplete("destroy");
-});
+ ok( menu.is( ":hidden" ) );
-function source_test(source, async) {
- var ac = $("#autocomplete").autocomplete({
- source: source
- });
- ac.val("ja").autocomplete("search");
- function result(){
- same( $(".ui-menu .ui-menu-item").text(), "javajavascript" );
- ac.autocomplete("destroy");
- async && start();
+ setTimeout(function() {
+ ok( menu.is( ":hidden" ) );
+ start();
+ }, 50 );
+});
+
+test( "minLength", function() {
+ expect( 2 );
+ var element = $( "#autocomplete" ).autocomplete({
+ source: data
+ }),
+ menu = element.autocomplete( "widget" );
+ element.autocomplete( "search", "" );
+ ok( menu.is( ":hidden" ), "blank not enough for minLength: 1" );
+
+ element.autocomplete( "option", "minLength", 0 );
+ element.autocomplete( "search", "" );
+ ok( menu.is( ":visible" ), "blank enough for minLength: 0" );
+});
+
+test( "source, local string array", function() {
+ expect( 1 );
+ var element = $( "#autocomplete" ).autocomplete({
+ source: data
+ }),
+ menu = element.autocomplete( "widget" );
+ element.val( "ja" ).autocomplete( "search" );
+ equal( menu.find( ".ui-menu-item" ).text(), "javajavascript" );
+});
+
+function sourceTest( source, async ) {
+ var element = $( "#autocomplete" ).autocomplete({
+ source: source
+ }),
+ menu = element.autocomplete( "widget" );
+ element.val( "ja" ).autocomplete( "search" );
+ function result() {
+ equal( menu.find( ".ui-menu-item" ).text(), "javajavascript" );
+ element.autocomplete( "destroy" );
+ if ( async ) {
+ start();
+ }
}
- if (async) {
+ if ( async ) {
stop();
- $(document).one("ajaxStop", result);
+ $( document ).one( "ajaxStop", result );
} else {
result();
}
}
-test("source, local object array, only label property", function() {
- source_test([
- {label:"java"},
- {label:"php"},
- {label:"coldfusion"},
- {label:"javascript"}
+test( "source, local object array, only label property", function() {
+ expect( 1 );
+ sourceTest([
+ { label: "java" },
+ { label: "php" },
+ { label: "coldfusion" },
+ { label: "javascript" }
]);
});
-test("source, local object array, only value property", function() {
- source_test([
- {value:"java"},
- {value:"php"},
- {value:"coldfusion"},
- {value:"javascript"}
+test( "source, local object array, only value property", function() {
+ expect( 1 );
+ sourceTest([
+ { value: "java" },
+ { value: "php" },
+ { value: "coldfusion" },
+ { value: "javascript" }
]);
});
-test("source, url string with remote json string array", function() {
- source_test("remote_string_array.txt", true);
+test( "source, url string with remote json string array", function() {
+ expect( 1 );
+ sourceTest( "remote_string_array.txt", true );
});
-test("source, url string with remote json object array, only value properties", function() {
- source_test("remote_object_array_values.txt", true);
+test( "source, url string with remote json object array, only value properties", function() {
+ expect( 1 );
+ sourceTest( "remote_object_array_values.txt", true );
});
-test("source, url string with remote json object array, only label properties", function() {
- source_test("remote_object_array_labels.txt", true);
+test( "source, url string with remote json object array, only label properties", function() {
+ expect( 1 );
+ sourceTest( "remote_object_array_labels.txt", true );
});
-test("source, custom", function() {
- source_test(function(request, response) {
- same( request.term, "ja" );
- response(["java", "javascript"]);
+test( "source, custom", function() {
+ expect( 2 );
+ sourceTest(function( request, response ) {
+ equal( request.term, "ja" );
+ response( ["java", "javascript"] );
});
});
-test("source, update after init", function() {
- var ac = $("#autocomplete").autocomplete({
- source: ["java", "javascript", "haskell"]
- });
- ac.val("ja").autocomplete("search");
- same( $(".ui-menu .ui-menu-item").text(), "javajavascript" );
- ac.autocomplete("option", "source", ["php", "asp"]);
- ac.val("ph").autocomplete("search");
- same( $(".ui-menu .ui-menu-item").text(), "php" );
- ac.autocomplete("destroy");
+test( "source, update after init", function() {
+ expect( 2 );
+ var element = $( "#autocomplete" ).autocomplete({
+ source: [ "java", "javascript", "haskell" ]
+ }),
+ menu = element.autocomplete( "widget" );
+ element.val( "ja" ).autocomplete( "search" );
+ equal( menu.find( ".ui-menu-item" ).text(), "javajavascript" );
+ element.autocomplete( "option", "source", [ "php", "asp" ] );
+ element.val( "ph" ).autocomplete( "search" );
+ equal( menu.find( ".ui-menu-item" ).text(), "php" );
});
-})(jQuery);
+}( jQuery ) );
diff --git a/tests/unit/effects/effects.html b/tests/unit/effects/effects.html
index 84fecd9cc..e3c6d2f4e 100644
--- a/tests/unit/effects/effects.html
+++ b/tests/unit/effects/effects.html
@@ -28,32 +28,54 @@
<script src="../../jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script src="effects_core.js"></script>
-
+ <script src="effects_scale.js"></script>
+
<script src="../swarminject.js"></script>
<style type="text/css">
- .hidden {
- display: none;
- }
- .test {
- background: #000;
- border: 0;
- width: 100px;
- height: 100px;
- }
- .testAddBorder {
- border: 10px solid #000;
- }
- .testChildren,
- .testChangeBackground {
- background: #fff;
- }
- .test h2 {
- font-size: 10px;
- }
- .testChildren h2 {
- font-size: 20px;
- }
+ #qunit-fixture {
+ width: 1000px;
+ height: 1000px;
+ }
+ .hidden {
+ display: none;
+ }
+ .test {
+ background: #000;
+ border: 0;
+ width: 100px;
+ height: 100px;
+ }
+ .testAddBorder {
+ border: 10px solid #000;
+ }
+ .testChildren,
+ .testChangeBackground {
+ background: #fff;
+ }
+ .test h2 {
+ font-size: 10px;
+ }
+ .testChildren h2 {
+ font-size: 20px;
+ }
+
+ .relWidth {
+ width: 50%;
+ }
+
+ .relHeight {
+ height: 50%;
+ }
+
+ .testScale {
+ border: 5px solid #000;
+ padding: 5px;
+ margin: 5px;
+ width: 50px;
+ height: 50px;
+ }
+
</style>
</head>
<body>
@@ -70,6 +92,11 @@
<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>
</body>
diff --git a/tests/unit/effects/effects_core.js b/tests/unit/effects/effects_core.js
index ed9fbf9ba..4c685ebb6 100644
--- a/tests/unit/effects/effects_core.js
+++ b/tests/unit/effects/effects_core.js
@@ -54,6 +54,21 @@ $.each( $.effects.effect, function( effect ) {
start();
}));
});
+
+ asyncTest( "relative width & height - properties are preserved", function() {
+ var test = $("div.relWidth.relHeight"),
+ width = test.width(), height = test.height(),
+ cssWidth = test[0].style.width, cssHeight = test[0].style.height;
+
+ expect( 4 );
+ test.toggle( effect, minDuration, function() {
+ equal( test[0].style.width, cssWidth, "Inline CSS Width has been reset after animation ended" );
+ equal( test[0].style.height, cssHeight, "Inline CSS Height has been rest after animation ended" );
+ start();
+ });
+ equal( test.width(), width, "Width is the same px after animation started" );
+ equal( test.height(), height, "Height is the same px after animation started" );
+ });
});
module("animateClass");
diff --git a/tests/unit/effects/effects_scale.js b/tests/unit/effects/effects_scale.js
new file mode 100644
index 000000000..1436cd030
--- /dev/null
+++ b/tests/unit/effects/effects_scale.js
@@ -0,0 +1,61 @@
+(function( $ ) {
+module( "effect.scale: Scale" );
+
+function run( position, v, h, vo, ho ) {
+ var desc = "End Position Correct: " + position + " (" + v + "," + h + ") - origin: (" + vo + "," + ho + ")";
+ asyncTest( desc, function() {
+ var test = $( ".testScale" ),
+ css = {
+ position: position
+ },
+ effect = {
+ effect: "scale",
+ mode: "effect",
+ percent: 200,
+ origin: [ vo, ho ],
+ complete: complete,
+ duration: 1
+ },
+ target = {},
+ relative = position === "relative";
+
+ css[ h ] = 33;
+ css[ v ] = 33;
+ target[ h ] = h === ho ? css[ h ] : ho == "center" ? css[ h ] - 35 : css[ h ] - 70;
+ target[ v ] = v === vo ? css[ v ] : vo == "middle" ? css[ v ] - 35 : css[ v ] - 70;
+ if ( relative && h == "right" ) {
+ target[ h ] += 70;
+ }
+ if ( relative && v == "bottom" ) {
+ target[ v ] += 70;
+ }
+ test.css( css );
+ test.effect( effect );
+
+ function complete() {
+ equal( parseInt( test.css( h ), 10 ), target[ h ], "Horizontal Position Correct " + desc );
+ equal( parseInt( test.css( v ), 10 ), target[ v ], "Vertical Position Correct " + desc );
+ start();
+ }
+ });
+}
+
+function suite( position ) {
+ run( position, "top", "left", "top", "left" );
+ run( position, "top", "left", "middle", "center" );
+ run( position, "top", "left", "bottom", "right" );
+ run( position, "bottom", "right", "top", "left" );
+ run( position, "bottom", "right", "middle", "center" );
+ run( position, "bottom", "right", "bottom", "right" );
+}
+
+$(function() {
+ suite( "absolute" );
+ suite( "relative" );
+ $.offset.initialize();
+ if ( $.offset.supportsFixedPosition ) {
+ suite( "fixed" );
+ }
+});
+
+})( jQuery );
diff --git a/tests/unit/position/position.html b/tests/unit/position/position.html
index 4f2e87e08..d71bae497 100644
--- a/tests/unit/position/position.html
+++ b/tests/unit/position/position.html
@@ -16,47 +16,54 @@
<script src="../testsuite.js"></script>
<script src="position_core.js"></script>
+ <script src="position_core_within.js"></script>
<script src="../swarminject.js"></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 style="position:relative; z-index:2;">
+ <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>
<!--
elements smaller than 10px have a line-height set on them to avoid a bug in IE6
.height() returns the greater of the height and line-height
-->
-<div id="qunit-fixture" style="top: 0; left: 0;">
- <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>
-
-<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 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 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>
</body>
</html>
diff --git a/tests/unit/position/position_core.js b/tests/unit/position/position_core.js
index dbbda8a3b..bd8e58612 100644
--- a/tests/unit/position/position_core.js
+++ b/tests/unit/position/position_core.js
@@ -64,7 +64,6 @@ test( "positions", function() {
center: 3,
right: 6,
top: 0,
- center: 3,
bottom: 6
};
var start = { left: 4, top: 4 };
@@ -316,6 +315,7 @@ test( "collision: fit, window scrolled", function() {
if ( scrollTopSupport() ) {
var win = $( window );
win.scrollTop( 300 ).scrollLeft( 200 );
+
collisionTest({
collision: "fit",
at: "left-100 top-100"
@@ -324,6 +324,7 @@ test( "collision: fit, window scrolled", function() {
collision: "fit",
at: "right+100 bottom+100"
}, { top: 300 + win.height() - 10, left: 200 + win.width() - 10 }, "right bottom" );
+
win.scrollTop( 0 ).scrollLeft( 0 );
}
});
@@ -351,7 +352,7 @@ test( "collision: flip, with offset", function() {
collisionTest2({
collision: "flip",
- at: "left-2 top-3",
+ at: "left-2 top-3"
}, { top: $( window ).height() + 3, left: $( window ).width() + 2 }, "right bottom, negative offset" );
});
diff --git a/tests/unit/position/position_core_within.js b/tests/unit/position/position_core_within.js
new file mode 100644
index 000000000..567c17192
--- /dev/null
+++ b/tests/unit/position/position_core_within.js
@@ -0,0 +1,441 @@
+(function( $ ) {
+
+function scrollTopSupport() {
+ $( window ).scrollTop( 1 );
+ return $( window ).scrollTop() === 1;
+}
+
+module( "position - within", {
+ setup: function(){
+ $("#within-container").css({"width": "500px", "height": "500px", "top": "20px", "left": "20px", "position": "relative"}).show();
+ }
+});
+
+var addTop = -20,
+ addLeft = -20;
+
+$.fn.addOffsets = function() {
+ var elOffset = this.offset(),
+ offset = $("#within-container").offset();
+
+ 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",
+ of: "#parentx",
+ collision: "none",
+ within: within
+ });
+ same( $( "#elx" ).addOffsets(), { top: addTop + 40, left: addLeft + 40 }, "left top, left top" );
+
+ $( "#elx" ).position({
+ my: "left top",
+ at: "left bottom",
+ of: "#parentx",
+ collision: "none",
+ within: within
+ });
+ same( $( "#elx" ).addOffsets(), { top: addTop + 60, left: addLeft + 40 }, "left top, left bottom" );
+
+ $( "#elx" ).position({
+ my: "left",
+ at: "bottom",
+ of: "#parentx",
+ collision: "none",
+ within: within
+ });
+ same( $( "#elx" ).addOffsets(), { top: addTop + 55, left: addLeft + 50 }, "left, bottom" );
+
+ $( "#elx" ).position({
+ my: "left foo",
+ at: "bar baz",
+ of: "#parentx",
+ collision: "none",
+ within: within
+ });
+ same( $( "#elx" ).addOffsets(), { top: addTop + 45, left: addLeft +50 }, "left foo, bar baz" );
+});
+
+test( "multiple elements", function() {
+ var elements = $( "#el1, #el2" );
+ var result = elements.position({
+ my: "left top",
+ at: "left bottom",
+ of: "#parent",
+ collision: "none",
+ within: $("#within-container")
+ });
+
+ same( result, elements );
+ var expected = { top: addTop + 10, left: addLeft + 4 };
+ elements.each(function() {
+ same( $( this ).addOffsets(), expected );
+ });
+});
+
+test( "positions", function() {
+ var definitions = [];
+ var offsets = {
+ left: 0,
+ center: 3,
+ right: 6,
+ top: 0,
+ bottom: 6
+ };
+ var start = { left: 4, top: 4 };
+ $.each( [ 0, 1 ], function( my ) {
+ $.each( [ "top", "center", "bottom" ], function( vindex, vertical ) {
+ $.each( [ "left", "center", "right" ], function( hindex, horizontal ) {
+ definitions.push({
+ my: my ? horizontal + " " + vertical : "left top",
+ at: !my ? horizontal + " " + vertical : "left top",
+ result: {
+ top: addTop + (my ? start.top - offsets[ vertical ] : start.top + offsets[ vertical ]),
+ left: addLeft + (my ? start.left - offsets[ horizontal ] : start.left + offsets[ horizontal ])
+ }
+ });
+ });
+ });
+ });
+ var el = $( "#el1" );
+ $.each( definitions, function( index, definition ) {
+ el.position({
+ my: definition.my,
+ at: definition.at,
+ of: "#parent",
+ collision: "none",
+ within: $("#within-container")
+ });
+ same( el.addOffsets(), definition.result,
+ "Position via " + QUnit.jsDump.parse({ my:definition.my, at:definition.at }) );
+ });
+});
+
+test( "of", function() {
+ var within = $("#within-container");
+
+ $( "#elx" ).position({
+ my: "left top",
+ at: "left top",
+ of: "#parentx",
+ collision: "none",
+ within: within
+ });
+ same( $( "#elx" ).addOffsets(), { top: addTop + 40, left: addLeft + 40 }, "selector" );
+
+ $( "#elx" ).position({
+ my: "left top",
+ at: "left bottom",
+ of: $( "#parentx"),
+ collision: "none",
+ within: within
+ });
+ same( $( "#elx" ).addOffsets(), { top: addTop + 60, left: addLeft + 40 }, "jQuery object" );
+
+ $( "#elx" ).position({
+ my: "left top",
+ at: "left top",
+ of: $( "#parentx" )[ 0 ],
+ collision: "none",
+ within: within
+ });
+ same( $( "#elx" ).addOffsets(), { top: addTop + 40, left: addLeft + 40 }, "DOM element" );
+
+ var event = $.extend( $.Event( "someEvent" ), { pageX: 200, pageY: 300 } );
+ $( "#elx" ).position({
+ my: "left top",
+ at: "left top",
+ of: event,
+ collision: "none",
+ within: within
+ });
+ same( $( "#elx" ).offset(), {
+ top: 300,
+ left: 200
+ }, "event - left top, left top" );
+
+ event = $.extend( $.Event( "someEvent" ), { pageX: 400, pageY: 600 } );
+ $( "#elx" ).position({
+ my: "left top",
+ at: "right bottom",
+ of: event,
+ collision: "none",
+ within: within
+ });
+ same( $( "#elx" ).offset(), {
+ top: 600,
+ left: 400
+ }, "event - left top, right bottom" );
+});
+
+test( "within:offsets", function() {
+ var within = $("#within-container");
+
+ $( "#elx" ).position({
+ my: "left top",
+ at: "left+10 bottom+10",
+ of: "#parentx",
+ collision: "none",
+ within: within
+ });
+ same( $( "#elx" ).addOffsets(), { top: addTop + 70, left: addLeft + 50 }, "offsets in at" );
+
+ $( "#elx" ).position({
+ my: "left+10 top-10",
+ at: "left bottom",
+ of: "#parentx",
+ collision: "none",
+ within: within
+ });
+ same( $( "#elx" ).addOffsets(), { top: addTop + 50, left: addLeft + 50 }, "offsets in my" );
+
+ $( "#elx" ).position({
+ my: "left top",
+ at: "left+50% bottom-10%",
+ of: "#parentx",
+ collision: "none",
+ within: within
+ });
+ same( $( "#elx" ).addOffsets(), { top: addTop + 58, left: addLeft + 50 }, "percentage offsets in at" );
+
+ $( "#elx" ).position({
+ my: "left-30% top+50%",
+ at: "left bottom",
+ of: "#parentx",
+ collision: "none",
+ within: within
+ });
+ same( $( "#elx" ).addOffsets(), { top: addTop + 65, left: addLeft + 37 }, "percentage offsets in my" );
+});
+
+test( "using", function() {
+ expect( 6 );
+
+ var within = $("#within-container");
+
+ var count = 0,
+ elems = $( "#el1, #el2" ),
+ expectedPosition = { top: addTop + 40, left: addLeft + 40 },
+ originalPosition = elems.position({
+ my: "right bottom",
+ at: "rigt bottom",
+ of: "#parentx",
+ collision: "none",
+ within: within
+ }).addOffsets();
+
+ elems.position({
+ my: "left top",
+ at: "left top",
+ of: "#parentx",
+ using: function( position ) {
+ position.top -= within.offset().top;
+ position.left -= within.offset().left;
+ same( this, elems[ count ], "correct context for call #" + count );
+ same( position, expectedPosition, "correct position for call #" + count );
+ count++;
+ },
+ within: within
+ });
+
+ elems.each(function() {
+ same( $( this ).addOffsets(), originalPosition, "elements not moved" );
+ });
+});
+
+function collisionTest( config, result, msg ) {
+ var within = $("#within-container");
+
+ var elem = $( "#elx" ).position( $.extend({
+ my: "left top",
+ at: "right bottom",
+ of: within[0],
+ within: within
+ }, config ) );
+
+ same( elem.addOffsets(), result, msg );
+}
+
+function collisionTest2( config, result, msg ) {
+ collisionTest( $.extend({
+ my: "right bottom",
+ at: "left top"
+ }, config ), result, msg );
+}
+
+test( "collision: fit, no offset", function() {
+ var within = $("#within-container");
+
+ collisionTest({
+ collision: "fit"
+ }, { top: addTop + within.height() - 10 - $.position.getScrollInfo( within ).height, left: addLeft + within.width() - 10 - $.position.getScrollInfo( within ).width }, "right bottom" );
+
+ collisionTest2({
+ collision: "fit"
+ }, { top: addTop + 0, left: addLeft + 0 }, "left top" );
+});
+
+
+test( "collision: fit, with offset", function() {
+ var within = $("#within-container");
+
+ 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");
+
+ collisionTest2({
+ collision: "fit",
+ at: "left+2 top+3"
+ }, { top: addTop + 0, left: addLeft + 0 }, "left top, positive offset" );
+
+ collisionTest2({
+ collision: "fit",
+ at: "left-2 top-3"
+ }, { top: addTop + 0, left: addLeft + 0 }, "left top, negative offset" );
+});
+
+test( "collision: fit, within scrolled", function() {
+ if ( scrollTopSupport() ) {
+ var within = $("#within-container").css({"width": "1000px", "height": "800px", "overflow": "auto"});
+ within.scrollTop( 300 ).scrollLeft( 150 );
+
+ collisionTest({
+ collision: "fit",
+ at: "left-100 top-100"
+ }, { top: addTop, left: addLeft }, "top left" );
+ collisionTest2({
+ collision: "fit",
+ 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" );
+ within.scrollTop( 0 ).scrollLeft( 0 );
+ }
+});
+
+test( "collision: flip, no offset", function() {
+ var within = $("#within-container");
+
+ collisionTest({
+ collision: "flip"
+ }, { top: addTop + -10, left: addLeft + -10 }, "left top" );
+
+ collisionTest2({
+ collision: "flip"
+ }, { top: addTop + within.height(), left: addLeft + within.width() }, "right bottom" );
+});
+
+test( "collision: flip, with offset", function() {
+ var within = $("#within-container");
+
+ collisionTest({
+ collision: "flip",
+ at: "right+2 bottom+3"
+ }, { top: addTop + -13, left: addLeft + -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" );
+
+ collisionTest2({
+ collision: "flip",
+ at: "left-2 top-3"
+ }, { top: addTop + within.height() + 3, left: addLeft + within.width() + 2 }, "right bottom, negative offset" );
+});
+
+test( "collision: none, no offset", function() {
+ var within = $("#within-container");
+
+ collisionTest({
+ collision: "none"
+ }, { top: addTop + within.height(), left: addLeft + within.width() }, "left top" );
+
+ collisionTest2({
+ collision: "none"
+ }, { top: addTop + -10, left: addLeft + -10 }, "moved to the right bottom" );
+});
+
+test( "collision: none, with offset", function() {
+ var within = $("#within-container");
+
+ collisionTest({
+ collision: "none",
+ at: "right+2 bottom+3"
+ }, { top: addTop + within.height() + 3, left: addLeft + within.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" );
+
+ collisionTest2({
+ collision: "none",
+ at: "left-2 top-3"
+ }, { top: addTop + -13, left: addLeft + -12 }, "left top, negative offset" );
+});
+
+test( "collision: fit, with margin", function() {
+ var within = $("#within-container");
+
+ $( "#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" );
+
+ collisionTest2({
+ collision: "fit"
+ }, { top: addTop + 10, left: addLeft + 10 }, "left top" );
+
+ $( "#elx" ).css({
+ "margin-left": 5,
+ "margin-top": 5
+ });
+
+ collisionTest({
+ collision: "fit"
+ }, { top: addTop + within.height() - 20 - $.position.getScrollInfo( within ).height, left: addLeft + within.width() - 20 - $.position.getScrollInfo( within ).width }, "right bottom" );
+
+ collisionTest2({
+ collision: "fit"
+ }, { top: addTop + 5, left: addLeft + 5 }, "left top" );
+
+ $( "#elx" ).css({
+ "margin-right": 15,
+ "margin-bottom": 15
+ });
+
+ collisionTest({
+ collision: "fit"
+ }, { top: addTop + within.height() - 25 - $.position.getScrollInfo( within ).height, left: addLeft + within.width() - 25 - $.position.getScrollInfo( within ).width }, "right bottom" );
+
+ collisionTest2({
+ collision: "fit"
+ }, { top: addTop + 5, left: addLeft + 5 }, "left top" );
+});
+
+test( "collision: flip, with margin", function() {
+ var within = $("#within-container");
+
+ $( "#elx" ).css( "margin", 10 );
+
+ collisionTest({
+ collision: "flip",
+ at: "left top"
+ }, { top: addTop + within.height() - 10, left: addLeft + within.width() - 10 }, "left top" );
+
+ collisionTest2({
+ collision: "flip",
+ at: "right bottom"
+ }, { top: addTop + 0, left: addLeft + 0 }, "right bottom" );
+});
+
+}( jQuery ) );
diff --git a/tests/unit/testsuite.js b/tests/unit/testsuite.js
index c1f394ed9..3d9e64d60 100644
--- a/tests/unit/testsuite.js
+++ b/tests/unit/testsuite.js
@@ -61,7 +61,7 @@ window.commonWidgetTests = function( widget, settings ) {
testWidgetOverrides( widget );
testBasicUsage( widget );
test( "version", function() {
- ok( "version" in $.ui[ widget ], "version property exists" );
+ ok( "version" in $.ui[ widget ].prototype, "version property exists" );
});
}
diff --git a/tests/unit/tooltip/tooltip.html b/tests/unit/tooltip/tooltip.html
index 189c75261..21eff51fd 100644
--- a/tests/unit/tooltip/tooltip.html
+++ b/tests/unit/tooltip/tooltip.html
@@ -1,30 +1,29 @@
-<!DOCTYPE html>
+<!doctype html>
<html lang="en">
<head>
- <meta charset="UTF-8" />
+ <meta charset="utf-8">
<title>jQuery UI Tooltip Test Suite</title>
- <link type="text/css" href="../../../themes/base/jquery.ui.tooltip.css" rel="stylesheet" />
-
- <script type="text/javascript" src="../../../jquery-1.5.1.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.tooltip.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="tooltip_core.js"></script>
- <script type="text/javascript" src="tooltip_defaults.js"></script>
- <script type="text/javascript" src="tooltip_events.js"></script>
- <script type="text/javascript" src="tooltip_methods.js"></script>
- <script type="text/javascript" src="tooltip_options.js"></script>
-
- <script type="text/javascript" src="../swarminject.js"></script>
-
+ <link rel="stylesheet" href="../../../themes/base/jquery.ui.tooltip.css">
+
+ <script src="../../../jquery-1.5.1.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.tooltip.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="tooltip_defaults.js"></script>
+ <script src="tooltip_core.js"></script>
+ <script src="tooltip_events.js"></script>
+ <script src="tooltip_methods.js"></script>
+ <script src="tooltip_options.js"></script>
+
+ <script src="../swarminject.js"></script>
</head>
<body>
@@ -32,16 +31,15 @@
<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>
- <a id="tooltipped1" href="#" title="anchortitle">anchor</a>
- <input title="inputtitle" />
- <span id="fixture-span" data-tooltip="text">span</span>
- </div>
+
+<div>
+ <a id="tooltipped1" href="#" title="anchortitle">anchor</a>
+ <input title="inputtitle">
+ <span id="fixture-span" title="title-text">span</span>
</div>
+</div>
</body>
</html>
diff --git a/tests/unit/tooltip/tooltip_core.js b/tests/unit/tooltip/tooltip_core.js
index 247927df4..d18b85398 100644
--- a/tests/unit/tooltip/tooltip_core.js
+++ b/tests/unit/tooltip/tooltip_core.js
@@ -1,11 +1,26 @@
-/*
- * tooltip_core.js
- */
+(function( $ ) {
+module( "tooltip: core" );
-(function($) {
+test( "markup structure", function() {
+ expect( 6 );
+ var element = $( "#tooltipped1" ).tooltip(),
+ tooltip = $( ".ui-tooltip" );
-module("tooltip: core");
+ equal( element.attr( "aria-describedby" ), undefined, "no aria-describedby on init" );
+ equal( tooltip.length, 0, "no tooltip on init" );
+ element.tooltip( "open" );
+ tooltip = $( "#" + element.attr( "aria-describedby" ) );
+ equal( tooltip.length, 1, "tooltip exists" );
+ ok( tooltip.hasClass( "ui-tooltip" ), "tooltip is .ui-tooltip" );
+ equal( tooltip.length, 1, ".ui-tooltip exists" );
+ equal( tooltip.find( ".ui-tooltip-content" ).length, 1,
+ ".ui-tooltip-content exists" );
+});
-})(jQuery);
+test( "accessibility", function() {
+ // TODO: add tests
+});
+
+}( jQuery ) );
diff --git a/tests/unit/tooltip/tooltip_defaults.js b/tests/unit/tooltip/tooltip_defaults.js
index 5f304f497..4b687bdcb 100644
--- a/tests/unit/tooltip/tooltip_defaults.js
+++ b/tests/unit/tooltip/tooltip_defaults.js
@@ -1,15 +1,20 @@
commonWidgetTests( "tooltip", {
defaults: {
+ content: function() {},
disabled: false,
+ hide: true,
items: "[title]",
- content: $.ui.tooltip.prototype.options.content,
position: {
my: "left+15 center",
- at: "right center"
+ at: "right center",
+ collision: "flip fit"
},
+ show: true,
tooltipClass: null,
// callbacks
- create: null
+ close: null,
+ create: null,
+ open: null
}
});
diff --git a/tests/unit/tooltip/tooltip_events.js b/tests/unit/tooltip/tooltip_events.js
index 5c915ae30..29220705f 100644
--- a/tests/unit/tooltip/tooltip_events.js
+++ b/tests/unit/tooltip/tooltip_events.js
@@ -1,54 +1,81 @@
-/*
- * tooltip_events.js
- */
-(function($) {
-
-module("tooltip: events");
-
-test("programmatic triggers", function() {
- expect(2);
- var e = $("#tooltipped1").tooltip({
- open: function(event, ui) {
- same( event.type, "tooltipopen" );
- },
- close: function(event, ui) {
- same( event.type, "tooltipclose" );
- }
- });
- e.tooltip("open").tooltip("close");
- e.tooltip("destroy");
+(function( $ ) {
+
+module( "tooltip: events" );
+
+test( "programmatic triggers", function() {
+ expect( 4 );
+ var tooltip,
+ element = $( "#tooltipped1" ).tooltip();
+
+ element.one( "tooltipopen", function( event, ui ) {
+ tooltip = ui.tooltip;
+ ok( !( "originalEvent" in event ), "open" );
+ strictEqual( ui.tooltip[0],
+ $( "#" + element.attr( "aria-describedby" ) )[0], "ui.tooltip" );
+ });
+ element.tooltip( "open" );
+
+ element.one( "tooltipclose", function( event, ui ) {
+ ok( !( "originalEvent" in event ), "close" );
+ strictEqual( ui.tooltip[0], tooltip[0], "ui.tooltip" );
+ });
+ element.tooltip( "close" );
+});
+
+test( "mouse events", function() {
+ expect( 2 );
+ var element = $( "#tooltipped1" ).tooltip();
+
+ element.one( "tooltipopen", function( event ) {
+ same( event.originalEvent.type, "mouseover" );
+ });
+ element.trigger( "mouseover" );
+
+ element.one( "tooltipclose", function( event ) {
+ same( event.originalEvent.type, "mouseleave" );
+ });
+ element.trigger( "mouseleave" );
});
-test("mouse events", function() {
- expect(4);
- var e = $("#tooltipped1").tooltip({
- open: function(event, ui) {
- same( event.type, "tooltipopen" );
- same( event.originalEvent.type, "mouseover" );
- },
- close: function(event, ui) {
- same( event.type, "tooltipclose" );
- same( event.originalEvent.type, "mouseleave" );
- }
- });
- e.trigger("mouseover").trigger("mouseleave");
- e.tooltip("destroy");
+test( "focus events", function() {
+ expect( 2 );
+ var element = $( "#tooltipped1" ).tooltip();
+
+ element.one( "tooltipopen", function( event ) {
+ same( event.originalEvent.type, "focusin" );
+ });
+ element.trigger( "focusin" );
+
+ element.one( "tooltipclose", function( event ) {
+ same( event.originalEvent.type, "blur" );
+ });
+ element.trigger( "blur" );
});
-test("focus events", function() {
- expect(4);
- var e = $("#tooltipped1").tooltip({
- open: function(event, ui) {
- same( event.type, "tooltipopen" );
- same( event.originalEvent.type, "focusin" );
- },
- close: function(event, ui) {
- same( event.type, "tooltipclose" );
- same( event.originalEvent.type, "blur" );
- }
- });
- e.trigger("focus").trigger("blur");
- e.tooltip("destroy");
+test( "mixed events", function() {
+ expect( 2 );
+ var element = $( "#tooltipped1" ).tooltip();
+
+ element.one( "tooltipopen", function( event ) {
+ same( event.originalEvent.type, "focusin" );
+ });
+ element[0].focus();
+
+ element.one( "tooltipopen", function() {
+ ok( false, "open triggered while already open" );
+ });
+ element.trigger( "mouseover" );
+
+ element.bind( "tooltipclose", function( event ) {
+ ok( false, "close triggered while still focused" );
+ });
+ element.trigger( "mouseleave" );
+ element.unbind( "tooltipclose" );
+
+ element.one( "tooltipclose", function( event ) {
+ same( event.originalEvent.type, "blur" );
+ });
+ element[0].blur();
});
-})(jQuery);
+}( jQuery ) );
diff --git a/tests/unit/tooltip/tooltip_methods.js b/tests/unit/tooltip/tooltip_methods.js
index 496a5fdb7..798d55896 100644
--- a/tests/unit/tooltip/tooltip_methods.js
+++ b/tests/unit/tooltip/tooltip_methods.js
@@ -1,22 +1,57 @@
-/*
- * tooltip_methods.js
- */
-(function($) {
+(function( $ ) {
+module( "tooltip: methods" );
-module("tooltip: methods");
+test( "destroy", function() {
+ expect( 2 );
+ domEqual( "#tooltipped1", function() {
+ $( "#tooltipped1" ).tooltip().tooltip( "destroy" );
+ });
-test("destroy", function() {
- var beforeHtml = $("#tooltipped1").parent().html();
- var afterHtml = $("#tooltipped1").tooltip().tooltip("destroy").parent().html();
- equal( afterHtml, beforeHtml );
+ // make sure that open tooltips are removed on destroy
+ $( "#tooltipped1" ).tooltip().tooltip( "open" ).tooltip( "destroy" );
+ equal( $( ".ui-tooltip" ).length, 0 );
});
-test("open", function() {
- var e = $("#tooltipped1").tooltip();
- e.tooltip("open");
- ok( $(".ui-tooltip").is(":visible") );
- $(":ui-tooltip").tooltip("destroy");
+test( "open/close", function() {
+ expect( 3 );
+ $.fx.off = true;
+ var element = $( "#tooltipped1" ).tooltip();
+ equal( $( ".ui-tooltip" ).length, 0, "no tooltip on init" );
+
+ element.tooltip( "open" );
+ var tooltip = $( "#" + element.attr( "aria-describedby" ) );
+ ok( tooltip.is( ":visible" ) );
+
+ element.tooltip( "close" );
+ ok( tooltip.is( ":hidden" ) );
+ $.fx.off = false;
+});
+
+test( "enable/disable", function() {
+ expect( 7 );
+ $.fx.off = true;
+ var element = $( "#tooltipped1" ).tooltip();
+ equal( $( ".ui-tooltip" ).length, 0, "no tooltip on init" );
+
+ element.tooltip( "open" );
+ var tooltip = $( "#" + element.attr( "aria-describedby" ) );
+ ok( tooltip.is( ":visible" ) );
+
+ element.tooltip( "disable" );
+ equal( $( ".ui-tooltip" ).length, 0, "no tooltip when disabled" );
+ equal( tooltip.attr( "title" ), "", "title removed on disable" );
+
+ element.tooltip( "open" );
+ equal( $( ".ui-tooltip" ).length, 0, "open does nothing when disabled" );
+
+ element.tooltip( "enable" );
+ equal( element.attr( "title" ), "anchortitle", "title restored on enable" );
+
+ element.tooltip( "open" );
+ tooltip = $( "#" + element.attr( "aria-describedby" ) );
+ ok( tooltip.is( ":visible" ) );
+ $.fx.off = false;
});
/*
@@ -29,5 +64,4 @@ test("widget", function() {
});
*/
-
-})(jQuery);
+}( jQuery ) );
diff --git a/tests/unit/tooltip/tooltip_options.js b/tests/unit/tooltip/tooltip_options.js
index 37a468489..04bb4c6a4 100644
--- a/tests/unit/tooltip/tooltip_options.js
+++ b/tests/unit/tooltip/tooltip_options.js
@@ -1,66 +1,73 @@
-/*
- * tooltip_options.js
- */
-(function($) {
-
-module("tooltip: options", {
- teardown: function() {
- $(":ui-tooltip").tooltip("destroy");
- }
-});
+(function( $ ) {
+module( "tooltip: options" );
-test("option: items", function() {
- var event = $.Event("mouseenter");
- event.target = $("[data-tooltip]");
- $("#qunit-fixture").tooltip({
- items: "[data-tooltip]",
- content: function() {
- return $(this).attr("data-tooltip");
- }
- }).tooltip("open", event);
- same( $( "#" + $("#fixture-span").attr("aria-describedby") ).text(), "text" );
+test( "content: default", function() {
+ var element = $( "#tooltipped1" ).tooltip().tooltip( "open" );
+ same( $( "#" + element.attr( "aria-describedby" ) ).text(), "anchortitle" );
});
-test("content: default", function() {
- $("#tooltipped1").tooltip().tooltip("open");
- same( $( "#" + $("#tooltipped1").attr("aria-describedby") ).text(), "anchortitle" );
-});
-
-test("content: return string", function() {
- $("#tooltipped1").tooltip({
+test( "content: return string", function() {
+ var element = $( "#tooltipped1" ).tooltip({
content: function() {
return "customstring";
}
- }).tooltip("open");
- same( $( "#" + $("#tooltipped1").attr("aria-describedby") ).text(), "customstring" );
+ }).tooltip( "open" );
+ same( $( "#" + element.attr( "aria-describedby" ) ).text(), "customstring" );
});
-test("content: return jQuery", function() {
- $("#tooltipped1").tooltip({
+test( "content: return jQuery", function() {
+ var element = $( "#tooltipped1" ).tooltip({
content: function() {
- return $("<div></div>").html("cu<b>s</b>tomstring");
+ return $( "<div>" ).html( "cu<b>s</b>tomstring" );
}
- }).tooltip("open");
- same( $( "#" + $("#tooltipped1").attr("aria-describedby") ).text(), "customstring" );
+ }).tooltip( "open" );
+ same( $( "#" + element.attr( "aria-describedby" ) ).text(), "customstring" );
});
-/*
-TODO broken, probably related to async content
-test("content: callback string", function() {
- stop();
- $("#tooltipped1").tooltip({
- content: function(response) {
- response("customstring2");
+asyncTest( "content: sync + async callback", function() {
+ expect( 2 );
+ var element = $( "#tooltipped1" ).tooltip({
+ content: function( response ) {
setTimeout(function() {
- //console.log($("#tooltipped1").attr("aria-describedby"))
- same( $( "#" + $("#tooltipped1").attr("aria-describedby") ).text(), "customstring2" );
- start();
- }, 100)
+ same( $( "#" + element.attr("aria-describedby") ).text(), "loading..." );
+
+ response( "customstring2" );
+ setTimeout(function() {
+ same( $( "#" + element.attr("aria-describedby") ).text(), "customstring2" );
+ start();
+ }, 13 );
+ }, 13 );
+ return "loading...";
}
- }).tooltip("open");
-
+ }).tooltip( "open" );
+});
+
+test( "items", function() {
+ expect( 2 );
+ var element = $( "#qunit-fixture" ).tooltip({
+ items: "#fixture-span"
+ });
+
+ var event = $.Event( "mouseenter" );
+ event.target = $( "#fixture-span" )[ 0 ];
+ element.tooltip( "open", event );
+ same( $( "#" + $( "#fixture-span" ).attr( "aria-describedby" ) ).text(), "title-text" );
+
+ // make sure default [title] doesn't get used
+ event.target = $( "#tooltipped1" )[ 0 ];
+ element.tooltip( "open", event );
+ same( $( "#tooltipped1" ).attr( "aria-describedby" ), undefined );
+
+ element.tooltip( "destroy" );
+});
+
+test( "tooltipClass", function() {
+ expect( 1 )
+ var element = $( "#tooltipped1" ).tooltip({
+ tooltipClass: "custom"
+ }).tooltip( "open" );
+ ok( $( "#" + element.attr( "aria-describedby" ) ).hasClass( "custom" ) );
});
-*/
-})(jQuery);
+}( jQuery ) );
diff --git a/tests/unit/widget/widget.html b/tests/unit/widget/widget.html
index 183537612..b06aa19f8 100644
--- a/tests/unit/widget/widget.html
+++ b/tests/unit/widget/widget.html
@@ -15,6 +15,7 @@
<script src="widget_core.js"></script>
<script src="widget_extend.js"></script>
+ <script src="widget_animation.js"></script>
<script src="../swarminject.js"></script>
</head>
diff --git a/tests/unit/widget/widget_animation.js b/tests/unit/widget/widget_animation.js
new file mode 100644
index 000000000..8ef55aa11
--- /dev/null
+++ b/tests/unit/widget/widget_animation.js
@@ -0,0 +1,257 @@
+
+module( "widget animation", (function() {
+ var show = $.fn.show,
+ fadeIn = $.fn.fadeIn,
+ slideDown = $.fn.slideDown;
+ return {
+ setup: function() {
+ $.widget( "ui.testWidget", {
+ _create: function() {
+ this.element.hide();
+ },
+ show: function( fn ) {
+ this._show( this.element, this.options.show, fn );
+ }
+ });
+ $.effects = { effect: { testEffect: $.noop } };
+ },
+ teardown: function() {
+ delete $.ui.testWidget;
+ delete $.effects.effect.testEffect;
+ $.fn.show = show;
+ $.fn.fadeIn = fadeIn;
+ $.fn.slideDown = slideDown;
+ }
+ };
+}()));
+
+asyncTest( "show: null", function() {
+ expect( 4 );
+
+ var element = $( "#widget" ).testWidget(),
+ hasRun = false;
+ $.fn.show = function() {
+ ok( true, "show called" );
+ equal( arguments.length, 0, "no args passed to show" );
+ };
+
+ element
+ .delay( 50 )
+ .queue(function( next ) {
+ ok( !hasRun, "queue before show" );
+ next();
+ })
+ .testWidget( "show", function() {
+ hasRun = true;
+ })
+ .queue(function( next ) {
+ ok( hasRun, "queue after show" );
+ start();
+ next();
+ });
+});
+
+asyncTest( "show: true", function() {
+ expect( 4 );
+
+ var element = $( "#widget" ).testWidget({
+ show: true
+ }),
+ hasRun = false;
+ $.fn.fadeIn = function( duration, easing, complete ) {
+ return this.queue(function( next ) {
+ strictEqual( duration, undefined, "duration" );
+ strictEqual( easing, undefined, "easing" );
+ complete();
+ next();
+ });
+ };
+
+ element
+ .delay( 50 )
+ .queue(function( next ) {
+ ok( !hasRun, "queue before show" );
+ next();
+ })
+ .testWidget( "show", function() {
+ hasRun = true;
+ })
+ .queue(function( next ) {
+ ok( hasRun, "queue after show" );
+ start();
+ next();
+ });
+});
+
+asyncTest( "show: number", function() {
+ expect( 4 );
+
+ var element = $( "#widget" ).testWidget({
+ show: 123
+ }),
+ hasRun = false;
+ $.fn.fadeIn = function( duration, easing, complete ) {
+ return this.queue(function( next ) {
+ strictEqual( duration, 123, "duration" );
+ strictEqual( easing, undefined, "easing" );
+ complete();
+ next();
+ });
+ };
+
+ element
+ .delay( 50 )
+ .queue(function( next ) {
+ ok( !hasRun, "queue before show" );
+ next();
+ })
+ .testWidget( "show", function() {
+ hasRun = true;
+ })
+ .queue(function( next ) {
+ ok( hasRun, "queue after show" );
+ start();
+ next();
+ });
+});
+
+asyncTest( "show: core animation", function() {
+ expect( 4 );
+
+ var element = $( "#widget" ).testWidget({
+ show: "slideDown"
+ }),
+ hasRun = false;
+ $.fn.slideDown = function( duration, easing, complete ) {
+ return this.queue(function( next ) {
+ strictEqual( duration, undefined, "duration" );
+ strictEqual( easing, undefined, "easing" );
+ complete();
+ next();
+ });
+ };
+
+ element
+ .delay( 50 )
+ .queue(function( next ) {
+ ok( !hasRun, "queue before show" );
+ next();
+ })
+ .testWidget( "show", function() {
+ hasRun = true;
+ })
+ .queue(function( next ) {
+ ok( hasRun, "queue after show" );
+ start();
+ next();
+ });
+});
+
+asyncTest( "show: effect", function() {
+ expect( 5 );
+
+ var element = $( "#widget" ).testWidget({
+ show: "testEffect"
+ }),
+ hasRun = false;
+ $.fn.show = function( options ) {
+ return this.queue(function( next ) {
+ equal( options.effect, "testEffect", "effect" );
+ ok( !("duration" in options), "duration" );
+ ok( !("easing" in options), "easing" );
+ options.complete();
+ next();
+ });
+ };
+
+ element
+ .delay( 50 )
+ .queue(function( next ) {
+ ok( !hasRun, "queue before show" );
+ next();
+ })
+ .testWidget( "show", function() {
+ hasRun = true;
+ })
+ .queue(function( next ) {
+ ok( hasRun, "queue after show" );
+ start();
+ next();
+ });
+});
+
+asyncTest( "show: object(core animation)", function() {
+ expect( 4 );
+
+ var element = $( "#widget" ).testWidget({
+ show: {
+ effect: "slideDown",
+ duration: 123,
+ easing: "testEasing"
+ }
+ }),
+ hasRun = false;
+ $.fn.slideDown = function( duration, easing, complete ) {
+ return this.queue(function( next ) {
+ equal( duration, 123, "duration" );
+ equal( easing, "testEasing", "easing" );
+ complete();
+ next();
+ });
+ };
+
+ element
+ .delay( 50 )
+ .queue(function( next ) {
+ ok( !hasRun, "queue before show" );
+ next();
+ })
+ .testWidget( "show", function() {
+ hasRun = true;
+ })
+ .queue(function( next ) {
+ ok( hasRun, "queue after show" );
+ start();
+ next();
+ });
+});
+
+asyncTest( "show: object(effect)", function() {
+ expect( 3 );
+
+ var element = $( "#widget" ).testWidget({
+ show: {
+ effect: "testEffect",
+ duration: 123,
+ easing: "testEasing"
+ }
+ }),
+ hasRun = false;
+ $.fn.show = function( options ) {
+ return this.queue(function( next ) {
+ deepEqual( options, {
+ effect: "testEffect",
+ duration: 123,
+ easing: "testEasing",
+ complete: options.complete
+ });
+ options.complete();
+ next();
+ });
+ };
+
+ element
+ .delay( 50 )
+ .queue(function( next ) {
+ ok( !hasRun, "queue before show" );
+ next();
+ })
+ .testWidget( "show", function() {
+ hasRun = true;
+ })
+ .queue(function( next ) {
+ ok( hasRun, "queue after show" );
+ start();
+ next();
+ });
+});
diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js
index b1c27b104..40fd97ba5 100644
--- a/tests/unit/widget/widget_core.js
+++ b/tests/unit/widget/widget_core.js
@@ -413,6 +413,7 @@ test( ".option() - getter", function() {
qux: [ "quux", "quuux" ]
});
+ same( div.testWidget( "option", "x" ), null, "non-existent option" );
same( div.testWidget( "option", "foo"), "bar", "single option - string" );
same( div.testWidget( "option", "baz"), 5, "single option - number" );
same( div.testWidget( "option", "qux"), [ "quux", "quuux" ],
@@ -431,6 +432,24 @@ test( ".option() - getter", function() {
"modifying returned options hash does not modify plugin instance" );
});
+test( ".option() - deep option getter", function() {
+ $.widget( "ui.testWidget", {} );
+ var div = $( "<div>" ).testWidget({
+ foo: {
+ bar: "baz",
+ qux: {
+ quux: "xyzzy"
+ }
+ }
+ });
+ equal( div.testWidget( "option", "foo.bar" ), "baz", "one level deep - string" );
+ deepEqual( div.testWidget( "option", "foo.qux" ), { quux: "xyzzy" },
+ "one level deep - object" );
+ equal( div.testWidget( "option", "foo.qux.quux" ), "xyzzy", "two levels deep - string" );
+ equal( div.testWidget( "option", "x.y" ), null, "top level non-existent" );
+ equal( div.testWidget( "option", "foo.x.y" ), null, "one level deep - non-existent" );
+});
+
test( ".option() - delegate to ._setOptions()", function() {
var calls = [];
$.widget( "ui.testWidget", {
diff --git a/tests/visual/effects.all.css b/tests/visual/effects/effects.all.css
index d2ed94026..1d531b026 100644
--- a/tests/visual/effects.all.css
+++ b/tests/visual/effects/effects.all.css
@@ -5,6 +5,7 @@ body,html {
font-size: 12px;
font-family: Arial;
background: #191919;
+ color: #fff;
}
body { margin: 1em; }
diff --git a/tests/visual/effects.all.html b/tests/visual/effects/effects.all.html
index fed35de8a..a2f8f62ef 100644
--- a/tests/visual/effects.all.html
+++ b/tests/visual/effects/effects.all.html
@@ -1,25 +1,25 @@
-<!DOCTYPE html>
+<!doctype html>
<html lang="en">
<head>
- <meta charset="UTF-8" />
+ <meta charset="utf-8">
<title>jQuery UI Effects Test Suite</title>
- <link rel="stylesheet" href="effects.all.css" type="text/css" />
- <script type="text/javascript" src="../../jquery-1.5.1.js"></script>
- <script type="text/javascript" src="../../ui/jquery.effects.core.js"></script>
- <script type="text/javascript" src="../../ui/jquery.effects.blind.js"></script>
- <script type="text/javascript" src="../../ui/jquery.effects.bounce.js"></script>
- <script type="text/javascript" src="../../ui/jquery.effects.clip.js"></script>
- <script type="text/javascript" src="../../ui/jquery.effects.drop.js"></script>
- <script type="text/javascript" src="../../ui/jquery.effects.explode.js"></script>
- <script type="text/javascript" src="../../ui/jquery.effects.fade.js"></script>
- <script type="text/javascript" src="../../ui/jquery.effects.fold.js"></script>
- <script type="text/javascript" src="../../ui/jquery.effects.highlight.js"></script>
- <script type="text/javascript" src="../../ui/jquery.effects.pulsate.js"></script>
- <script type="text/javascript" src="../../ui/jquery.effects.scale.js"></script>
- <script type="text/javascript" src="../../ui/jquery.effects.shake.js"></script>
- <script type="text/javascript" src="../../ui/jquery.effects.slide.js"></script>
- <script type="text/javascript" src="../../ui/jquery.effects.transfer.js"></script>
- <script type="text/javascript" src="effects.all.js"></script>
+ <link rel="stylesheet" href="effects.all.css" type="text/css">
+ <script src="../../../jquery-1.5.1.js"></script>
+ <script src="../../../ui/jquery.effects.core.js"></script>
+ <script src="../../../ui/jquery.effects.blind.js"></script>
+ <script src="../../../ui/jquery.effects.bounce.js"></script>
+ <script src="../../../ui/jquery.effects.clip.js"></script>
+ <script src="../../../ui/jquery.effects.drop.js"></script>
+ <script src="../../../ui/jquery.effects.explode.js"></script>
+ <script src="../../../ui/jquery.effects.fade.js"></script>
+ <script src="../../../ui/jquery.effects.fold.js"></script>
+ <script src="../../../ui/jquery.effects.highlight.js"></script>
+ <script src="../../../ui/jquery.effects.pulsate.js"></script>
+ <script src="../../../ui/jquery.effects.scale.js"></script>
+ <script src="../../../ui/jquery.effects.shake.js"></script>
+ <script src="../../../ui/jquery.effects.slide.js"></script>
+ <script src="../../../ui/jquery.effects.transfer.js"></script>
+ <script src="effects.all.js"></script>
</head>
<body>
diff --git a/tests/visual/effects.all.js b/tests/visual/effects/effects.all.js
index a28c41a89..a28c41a89 100644
--- a/tests/visual/effects.all.js
+++ b/tests/visual/effects/effects.all.js
diff --git a/tests/visual/effects/effects.scale.html b/tests/visual/effects/effects.scale.html
new file mode 100644
index 000000000..9521a1872
--- /dev/null
+++ b/tests/visual/effects/effects.scale.html
@@ -0,0 +1,159 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>jQuery UI Effects Test Suite</title>
+ <link rel="stylesheet" href="effects.all.css" type="text/css">
+ <script src="../../../jquery-1.5.1.js"></script>
+ <script src="../../../ui/jquery.effects.core.js"></script>
+ <script src="../../../ui/jquery.effects.scale.js"></script>
+ <script src="effects.all.js"></script>
+ <script type="text/javascript" charset="utf-8">
+ jQuery(function( $ ) {
+ var test = $( "#testBox" ),
+ opts = $( ".arg" ),
+ optsRev = $( opts.get().reverse() ),
+ doer = $( "#doAnim" ),
+ current = $( "#current" ),
+ cleanStyle = test[0].style,
+ total = 1;
+
+ opts.each(function() {
+ total *= this.options.length;
+ });
+
+ opts.change( doAnim );
+ doer.click( doAnim );
+ $( "#cyclePrev" ).click(function() {
+ cycle( -1 );
+ });
+ $( "#cycleNext" ).click(function() {
+ cycle( 1 );
+ });
+
+ function cycle( direction ) {
+ optsRev.each(function() {
+ var cur = this.selectedIndex,
+ next = cur + direction,
+ len = this.options.length;
+
+ this.selectedIndex = ( next + len ) % len;
+
+ if ( ( next+len ) % len === next ) return false;
+ });
+ doAnim();
+ }
+
+
+ function doAnim() {
+ var cur = 0;
+ opts.each(function() {
+ cur *= this.options.length
+ cur += this.selectedIndex;
+ });
+ cur++;
+ current.text( "Configuration: " + cur + " of " + total );
+ run.apply(test, opts.map(function() {
+ return $(this).val();
+ }).get());
+ }
+
+ function run( position, v, h, vo, ho ) {
+ var el = this,
+ style = el[0].style,
+ effect = {
+ effect: "scale",
+ mode: "effect",
+ percent: 200,
+ origin: [ vo, ho ],
+ duration: 500
+ };
+ el.stop(true, true);
+ if ( typeof style === "object" ) {
+ style.cssText = "";
+ } else {
+ el[0].style = "";
+ }
+ el.css( "position", position )
+ .css( h, 5 )
+ .css( v, 5 )
+ .delay( 100 )
+ .effect( effect );
+ }
+ });
+ </script>
+ <style type="text/css">
+ #testArea {
+/* border: 5px dashed #777;*/
+ width: 200px;
+ height: 200px;
+ position: relative;
+ }
+ #testBox {
+ width: 50px;
+ height: 50px;
+ background-color: #bada55;
+ color: black;
+ border: 10px solid #fff;
+ margin: 10px;
+ padding: 10px;
+ }
+ label {
+ display: block;
+ }
+ #controls {
+ position: absolute;
+ z-index: 300;
+ left: 50%;
+ top: 50%;
+ margin-left: -200px;
+ width: 400px;
+ opacity: 0.8;
+ }
+ </style>
+</head>
+<body>
+ <div id="testArea">
+ <div id="testBox">
+ </div>
+ </div>
+ <div id="controls">
+ <label for="pos">Positioning
+ <select id="pos" class="arg">
+ <option value="absolute">absolute</option>
+ <option value="relative">relative</option>
+ <option value="fixed">fixed</option>
+ </select>
+ </label>
+ <label for="vertPos">Vertical Positioning
+ <select id="vertPos" class="arg">
+ <option value="top">top</option>
+ <option value="bottom">bottom</option>
+ </select>
+ </label>
+ <label for="horizPos">Horizontal Positioning
+ <select id="horizPos" class="arg">
+ <option value="left">left</option>
+ <option value="right">right</option>
+ </select>
+ </label>
+ <label for="vertOrigin">Vertical Origin
+ <select id="vertOrigin" class="arg">
+ <option value="top">top</option>
+ <option value="middle">middle</option>
+ <option value="bottom">bottom</option>
+ </select>
+ </label>
+ <label for="horizOrigin">Horizontal Origin
+ <select id="horizOrigin" class="arg">
+ <option value="left">left</option>
+ <option value="center">center</option>
+ <option value="right">right</option>
+ </select>
+ </label><br />
+ <label id="current">jQuery UI Scale Animation Test</label>
+ <button id="cyclePrev">Back</button>
+ <button id="doAnim">Run Animation</button>
+ <button id="cycleNext">Forward</button>
+ </div>
+</body> \ No newline at end of file
diff --git a/tests/visual/position/position.html b/tests/visual/position/position.html
index da0ff5170..11932da0e 100644
--- a/tests/visual/position/position.html
+++ b/tests/visual/position/position.html
@@ -35,7 +35,7 @@
<style>
input, .ui-menu { position: absolute; }
.ui-menu { width: 200px; }
- html, body { width: 99%; height: 99% }
+ html, body { width: 99%; height: 99%; min-height:700px; min-width:700px; }
#container { width: 95%; height: 95%; border: 1px solid black; margin: auto; }
</style>
</head>
diff --git a/tests/visual/position/position_within.html b/tests/visual/position/position_within.html
new file mode 100644
index 000000000..f120a4b47
--- /dev/null
+++ b/tests/visual/position/position_within.html
@@ -0,0 +1,189 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>Position Visual Test: Containing Element</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.5.1.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>
+
+ <style>
+ html, body {
+ height:100%;
+ width:100%;
+ margin:0;
+ /* force scroll bar*/
+ min-height:800px;
+ min-width:800px;
+
+ /* IE6 needs this */
+ text-align:center;
+ }
+ .demo-description {
+ text-align:center;
+ padding:1.5em;
+ }
+ .demo-container {
+ background:#aaa;
+ width:80%;
+ height:80%;
+
+ text-align:left;
+ margin:0 auto;
+ position:relative;
+ padding:10px;
+ }
+ .demo {
+ background:#eee;
+ overflow:hidden;
+ position:relative;
+ height:100%;
+ /* IE6 needs this */
+ width:100%;
+ }
+ #parent {
+ width: 60%;
+ margin: 10px auto;
+ padding: 5px;
+ border: 1px solid #777;
+ background-color: #fbca93;
+ text-align: center;
+ cursor:move;
+ }
+ .positionable {
+ width: 75px;
+ height: 75px;
+ position: absolute;
+ display: block;
+ right: 0;
+ bottom: 0;
+ background-color: #bcd5e6;
+ text-align: center;
+ border:solid 2px #555;
+ cursor:move;
+ }
+ select, input {
+ margin-left: 15px;
+ }
+ </style>
+ <script>
+ $(function() {
+ function position( using ) {
+ $( ".positionable" ).position({
+ of: $( "#parent" ),
+ my: $( "#my_horizontal" ).val() + " " + $( "#my_vertical" ).val(),
+ at: $( "#at_horizontal" ).val() + " " + $( "#at_vertical" ).val(),
+ offset: $( "#offset" ).val(),
+ using: using,
+ within: $( ".demo" ),
+ collision: $( "#collision_horizontal" ).val() + " " + $( "#collision_vertical" ).val()
+ });
+ }
+ $( ".demo" ).append("<div style='width:5000px;height:5000px;' />").css("overflow","auto");
+
+ $( ".positionable" ).css( "opacity", 0.5 );
+
+ $( ":input" ).bind( "click keyup change", function() { position(); } );
+
+ $( "#parent" ).draggable({
+ drag: function() { position(); }
+ });
+
+ $( ".positionable" ).draggable({
+ drag: function( event, ui ) {
+ // reset offset before calculating it
+ $( "#offset" ).val( "0" );
+ position(function( result ) {
+ var demo = $( ".demo" );
+ $( "#offset" ).val( "" + ( ui.offset.left - result.left - demo.offset().left + demo.scrollLeft() ) +
+ " " + ( ui.offset.top - result.top - demo.offset().top + demo.scrollTop() ) );
+ position();
+ });
+ }
+ });
+
+ position();
+ });
+ </script>
+</head>
+<body>
+
+<div class="demo-description">
+ Use the form controls to configure the positioning, or drag the positioned element to modify its offset.
+ <br/>Drag around the parent element to see collision detection in action.
+</div><!-- End demo-description -->
+
+<div class="demo-container">
+<div class="demo">
+
+ <div id="parent">
+ <p>This is the position parent element.</p>
+ </div>
+
+ <div class="positionable">
+ <p>to position</p>
+ </div>
+
+ <div class="positionable" style="width:120px; height: 40px;">
+ <p>to position 2</p>
+ </div>
+
+ <div style="padding: 20px; margin-top: 75px;">
+ position...
+ <div style="padding-bottom: 20px;">
+ <b>my:</b>
+ <select id="my_horizontal">
+ <option value="left">left</option>
+ <option value="center">center</option>
+ <option value="right" selected="selected">right</option>
+ </select>
+ <select id="my_vertical">
+ <option value="top">top</option>
+ <option value="middle">center</option>
+ <option value="bottom">bottom</option>
+ </select>
+ </div>
+ <div style="padding-bottom: 20px;">
+ <b>at:</b>
+ <select id="at_horizontal">
+ <option value="left">left</option>
+ <option value="center">center</option>
+ <option value="right" selected="selected">right</option>
+ </select>
+ <select id="at_vertical">
+ <option value="top">top</option>
+ <option value="middle">center</option>
+ <option value="bottom">bottom</option>
+ </select>
+ </div>
+ <div style="padding-bottom: 20px;">
+ <b>offset:</b>
+ <input id="offset" type="text" size="15"/>
+ </div>
+ <div style="padding-bottom: 20px;">
+ <b>collision:</b>
+ <select id="collision_horizontal">
+ <option value="flip">flip</option>
+ <option value="fit">fit</option>
+ <option value="none">none</option>
+ </select>
+ <select id="collision_vertical">
+ <option value="flip">flip</option>
+ <option value="fit">fit</option>
+ <option value="none">none</option>
+ </select>
+ </div>
+ </div>
+
+</div><!-- End demo -->
+</div>
+
+</body>
+</html>
diff --git a/themes/base/jquery.ui.base.css b/themes/base/jquery.ui.base.css
index 9a18856c1..a359c2ba4 100644
--- a/themes/base/jquery.ui.base.css
+++ b/themes/base/jquery.ui.base.css
@@ -15,6 +15,7 @@
@import url("jquery.ui.datepicker.css");
@import url("jquery.ui.dialog.css");
@import url("jquery.ui.menu.css");
+@import url("jquery.ui.menubar.css");
@import url("jquery.ui.progressbar.css");
@import url("jquery.ui.resizable.css");
@import url("jquery.ui.selectable.css");
diff --git a/themes/base/jquery.ui.menu.css b/themes/base/jquery.ui.menu.css
index ed4b4a13a..c616cf2c5 100644
--- a/themes/base/jquery.ui.menu.css
+++ b/themes/base/jquery.ui.menu.css
@@ -7,38 +7,14 @@
*
* http://docs.jquery.com/UI/Menu#theming
*/
-.ui-menu {
- list-style:none;
- padding: 2px;
- margin: 0;
- display:block;
- outline: none;
-}
-.ui-menu .ui-menu {
- margin-top: -3px;
-}
-.ui-menu .ui-menu-item {
- margin:0;
- padding: 0;
- zoom: 1;
- width: 100%;
-}
-.ui-menu .ui-menu-item a {
- text-decoration:none;
- display:block;
- padding: 2px .4em;
- line-height:1.5;
- zoom:1;
- font-weight: normal;
-}
+.ui-menu { list-style:none; padding: 2px; margin: 0; display:block; outline: none; }
+.ui-menu .ui-menu { margin-top: -3px; position: absolute; }
+.ui-menu .ui-menu-item { margin: 0; padding: 0; zoom: 1; width: 100%; }
+.ui-menu .ui-menu-item a { text-decoration: none; display: block; padding: 2px .4em; line-height: 1.5; zoom: 1; font-weight: normal; }
.ui-menu .ui-menu-item a.ui-state-focus,
-.ui-menu .ui-menu-item a.ui-state-active {
- font-weight: normal;
- margin: -1px;
-}
+.ui-menu .ui-menu-item a.ui-state-active { font-weight: normal; margin: -1px; }
-/* nested menus */
-.ui-menu .ui-menu { position: absolute; }
+.ui-menu li.ui-state-disabled { font-weight: normal; padding: .0em .4em; margin: .4em 0 .2em; line-height: 1.5; }
/* icon support */
.ui-menu-icons { position: relative; }
@@ -48,4 +24,4 @@
.ui-menu .ui-icon { position: absolute; top: .2em; left: .2em; }
/* right-aligned */
-.ui-menu .ui-menu-icon { position: static; float: right; } \ No newline at end of file
+.ui-menu .ui-menu-icon { position: static; float: right; }
diff --git a/themes/base/jquery.ui.menubar.css b/themes/base/jquery.ui.menubar.css
new file mode 100644
index 000000000..95c42ae9e
--- /dev/null
+++ b/themes/base/jquery.ui.menubar.css
@@ -0,0 +1,15 @@
+/*
+ * jQuery UI Menubar @VERSION
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ */
+.ui-menubar { list-style: none; margin: 0; padding-left: 0; }
+
+.ui-menubar-item { float: left; }
+
+.ui-menubar .ui-button { float: left; font-weight: normal; border-top-width: 0 !important; border-bottom-width: 0 !important; margin: 0; outline: none; }
+.ui-menubar .ui-menubar-link { border-right: 1px dashed transparent; border-left: 1px dashed transparent; }
+
+.ui-menubar .ui-menu { width: 200px; position: absolute; z-index: 9999; }
diff --git a/themes/base/jquery.ui.theme.css b/themes/base/jquery.ui.theme.css
index be2676909..368ebfbb5 100644
--- a/themes/base/jquery.ui.theme.css
+++ b/themes/base/jquery.ui.theme.css
@@ -182,8 +182,8 @@
.ui-icon-help { background-position: -48px -144px; }
.ui-icon-check { background-position: -64px -144px; }
.ui-icon-bullet { background-position: -80px -144px; }
-.ui-icon-radio-off { background-position: -96px -144px; }
-.ui-icon-radio-on { background-position: -112px -144px; }
+.ui-icon-radio-on { background-position: -96px -144px; }
+.ui-icon-radio-off { background-position: -112px -144px; }
.ui-icon-pin-w { background-position: -128px -144px; }
.ui-icon-pin-s { background-position: -144px -144px; }
.ui-icon-play { background-position: 0 -160px; }
diff --git a/ui/jquery.effects.blind.js b/ui/jquery.effects.blind.js
index 8ef544faa..b6485b641 100644
--- a/ui/jquery.effects.blind.js
+++ b/ui/jquery.effects.blind.js
@@ -21,7 +21,7 @@ $.effects.effect.blind = function( o ) {
// Create element
var el = $( this ),
- props = [ "position", "top", "bottom", "left", "right" ],
+ props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
mode = $.effects.setMode( el, o.mode || "hide" ),
direction = o.direction || "up",
vertical = rvertical.test( direction ),
diff --git a/ui/jquery.effects.bounce.js b/ui/jquery.effects.bounce.js
index 9e1117ce9..78fedb0ce 100644
--- a/ui/jquery.effects.bounce.js
+++ b/ui/jquery.effects.bounce.js
@@ -16,7 +16,7 @@ $.effects.effect.bounce = function(o) {
return this.queue( function( next ) {
var el = $( this ),
- props = [ "position", "top", "bottom", "left", "right" ],
+ props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
// defaults:
mode = $.effects.setMode( el, o.mode || "effect" ),
diff --git a/ui/jquery.effects.clip.js b/ui/jquery.effects.clip.js
index 14b358dfa..dbf0d36c9 100644
--- a/ui/jquery.effects.clip.js
+++ b/ui/jquery.effects.clip.js
@@ -17,47 +17,52 @@ $.effects.effect.clip = function( o ) {
return this.queue( function() {
// Create element
- var el = $( this ),
- props = ['position','top','bottom','left','right','height','width'],
- mode = $.effects.setMode( el, o.mode || 'hide' ),
- direction = o.direction || 'vertical',
- ref = {
- size: (direction == 'vertical') ? 'height' : 'width',
- position: (direction == 'vertical') ? 'top' : 'left'
- },
+ var el = $( this ),
+ props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
+ mode = $.effects.setMode( el, o.mode || "hide" ),
+ show = mode === "show",
+ direction = o.direction || "vertical",
+ vert = direction === "vertical",
+ size = vert ? "height" : "width",
+ position = vert ? "top" : "left",
animation = {},
wrapper, animate, distance;
// Save & Show
- $.effects.save( el, props ); el.show();
+ $.effects.save( el, props );
+ el.show();
// Create Wrapper
- wrapper = $.effects.createWrapper( el ).css({
- overflow: 'hidden'
+ wrapper = $.effects.createWrapper( el ).css({
+ overflow: "hidden"
});
- animate = ( el[0].tagName == 'IMG' ) ? wrapper : el;
- distance = animate[ ref.size ]();
+ animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
+ distance = animate[ size ]();
// Shift
- if ( mode == 'show' ) {
- animate.css( ref.size, 0 );
- animate.css( ref.position, distance / 2 );
+ if ( show ) {
+ animate.css( size, 0 );
+ animate.css( position, distance / 2 );
}
// Create Animation Object:
- animation[ ref.size ] = mode == 'show' ? distance : 0;
- animation[ ref.position ] = mode == 'show' ? 0 : distance / 2;
+ animation[ size ] = show ? distance : 0;
+ animation[ position ] = show ? 0 : distance / 2;
// Animate
- animate.animate( animation, {
- queue: false,
- duration: o.duration,
- easing: o.easing,
+ animate.animate( animation, {
+ queue: false,
+ duration: o.duration,
+ easing: o.easing,
complete: function() {
- mode == 'hide' && el.hide();
- $.effects.restore( el, props );
- $.effects.removeWrapper( el );
- $.isFunction( o.complete ) && o.complete.apply( el[ 0 ], arguments );
+ if ( !show ) {
+ el.hide();
+ }
+ $.effects.restore( el, props );
+ $.effects.removeWrapper( el );
+ if ( $.isFunction( o.complete ) ) {
+ o.complete.apply( el[ 0 ], arguments );
+ }
el.dequeue();
}
});
diff --git a/ui/jquery.effects.core.js b/ui/jquery.effects.core.js
index 7650aa8f4..00a803360 100644
--- a/ui/jquery.effects.core.js
+++ b/ui/jquery.effects.core.js
@@ -410,7 +410,12 @@ $.extend( $.effects, {
border: "none",
margin: 0,
padding: 0
- });
+ }),
+ // Store the size in case width/height are defined in % - Fixes #5245
+ size = {
+ width: element.width(),
+ height: element.height()
+ };
element.wrap( wrapper );
wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually loose the reference to the wrapped element
@@ -438,6 +443,7 @@ $.extend( $.effects, {
bottom: "auto"
});
}
+ element.css(size);
return wrapper.css( props ).show();
},
diff --git a/ui/jquery.effects.drop.js b/ui/jquery.effects.drop.js
index 24fb89db0..4265b737b 100644
--- a/ui/jquery.effects.drop.js
+++ b/ui/jquery.effects.drop.js
@@ -17,7 +17,7 @@ $.effects.effect.drop = function( o ) {
return this.queue( function() {
var el = $( this ),
- props = [ 'position', 'top', 'bottom', 'left', 'right', 'opacity' ],
+ props = [ 'position', 'top', 'bottom', 'left', 'right', 'opacity', "height", "width" ],
mode = $.effects.setMode( el, o.mode || 'hide' ),
direction = o.direction || 'left',
ref = ( direction == 'up' || direction == 'down' ) ? 'top' : 'left',
diff --git a/ui/jquery.effects.fold.js b/ui/jquery.effects.fold.js
index 29da090cb..6100c33a1 100644
--- a/ui/jquery.effects.fold.js
+++ b/ui/jquery.effects.fold.js
@@ -18,7 +18,7 @@ $.effects.effect.fold = function( o ) {
// Create element
var el = $( this ),
- props = ['position','top','bottom','left','right'],
+ props = ['position','top','bottom','left','right','height','width'],
mode = $.effects.setMode(el, o.mode || 'hide'),
size = o.size || 15,
percent = /([0-9]+)%/.exec(size),
diff --git a/ui/jquery.effects.scale.js b/ui/jquery.effects.scale.js
index 00f0151af..e00d82497 100644
--- a/ui/jquery.effects.scale.js
+++ b/ui/jquery.effects.scale.js
@@ -116,10 +116,13 @@ $.effects.effect.size = function( o ) {
// Set options
mode = $.effects.setMode( el, o.mode || 'effect' ),
- restore = o.restore || false,
+ restore = o.restore || mode !== "effect",
scale = o.scale || 'both',
- origin = o.origin,
- original, baseline, factor;
+ origin = o.origin || [ "middle", "center" ],
+ original, baseline, factor,
+ position = el.css( "position" ),
+ originalVerticalPositioning = el.css( "bottom" ) !== "auto" ? "bottom" : "top";
+ originalHorizontalPositioning = el.css( "right" ) !== "auto" ? "right" : "left";
if ( mode === "show" ) {
el.show();
@@ -249,7 +252,47 @@ $.effects.effect.size = function( o ) {
if( mode == 'hide' ) {
el.hide();
}
- $.effects.restore( el, restore ? props : props1 );
+ $.effects.restore( el, restore ? props : props1 );
+
+ // we need to recalculate our positioning based on the new scaling
+ if ( position === "static" ) {
+ el.css({
+ position: "relative",
+ top: el.to.top,
+ left: el.to.left
+ });
+ } else {
+ $.each([ originalVerticalPositioning, originalHorizontalPositioning ], function( idx, pos ) {
+ el.css( pos, function( _, str ) {
+ var val = parseInt( str, 10 ),
+ toRef = idx ? el.to.left : el.to.top,
+ delta = idx ? el.to.outerWidth - el.from.outerWidth: el.to.outerHeight - el.from.outerHeight,
+ same = origin[ idx ] === pos,
+ mid = origin[ idx ] === "middle" || origin[ idx ] === "center",
+ direction = pos == "left" || pos == "top";
+
+ // if original was "auto", recalculate the new value from wrapper
+ if ( str === "auto" ) {
+ return toRef + "px";
+ }
+
+ // if not setting left or top
+ if ( !direction ) {
+
+ // if the position is relative, bottom/right are reversed meaning
+ if ( position === "relative" ) {
+ toRef *= -1;
+
+ // otherwise, if its NOT a midpoint origin, compensate for the outerWidth difference
+ } else if ( !mid ) {
+ toRef -= delta * ( same ? -1 : 1 );
+ }
+ }
+ return val + toRef + "px";
+ });
+ });
+ }
+
$.effects.removeWrapper( el );
$.isFunction( o.complete ) && o.complete.apply( this, arguments ); // Callback
el.dequeue();
diff --git a/ui/jquery.effects.shake.js b/ui/jquery.effects.shake.js
index 550329ca4..52ab331e8 100644
--- a/ui/jquery.effects.shake.js
+++ b/ui/jquery.effects.shake.js
@@ -17,7 +17,7 @@ $.effects.effect.shake = function( o ) {
return this.queue( function() {
var el = $( this ),
- props = [ "position", "top", "bottom", "left", "right" ],
+ props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
mode = $.effects.setMode( el, o.mode || "effect" ),
direction = o.direction || "left",
distance = o.distance || 20,
diff --git a/ui/jquery.effects.slide.js b/ui/jquery.effects.slide.js
index 6b0296754..ccb13fa1b 100644
--- a/ui/jquery.effects.slide.js
+++ b/ui/jquery.effects.slide.js
@@ -18,24 +18,26 @@ $.effects.effect.slide = function( o ) {
// Create element
var el = $( this ),
- props = ['position','top','bottom','left','right'],
+ props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
mode = $.effects.setMode( el, o.mode || 'show' ),
direction = o.direction || 'left',
ref = (direction == 'up' || direction == 'down') ? 'top' : 'left',
motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg',
distance,
- animation = {};
+ animation = {},
+ size;
// Adjust
- $.effects.save( el, props );
+ $.effects.save( el, props );
el.show();
+ distance = o.distance || el[ ref == 'top' ? "outerHeight" : "outerWidth" ]({
+ margin: true
+ });
+
$.effects.createWrapper( el ).css({
overflow: 'hidden'
- });
-
- distance = o.distance || el[ ref == 'top' ? "outerHeight" : "outerWidth" ]({
- margin: true
});
+
if (mode == 'show') {
el.css( ref, motion == 'pos' ? (isNaN(distance) ? "-" + distance : -distance) : distance );
}
diff --git a/ui/jquery.effects.transfer.js b/ui/jquery.effects.transfer.js
index 17d23c5fa..f0f9d9fd4 100644
--- a/ui/jquery.effects.transfer.js
+++ b/ui/jquery.effects.transfer.js
@@ -17,10 +17,14 @@ $.effects.effect.transfer = function( o ) {
return this.queue( function() {
var elem = $( this ),
target = $( o.to ),
+ targetFixed = target.css( "position" ) === "fixed",
+ body = $("body"),
+ fixTop = targetFixed ? body.scrollTop() : 0,
+ fixLeft = targetFixed ? body.scrollLeft() : 0,
endPosition = target.offset(),
animation = {
- top: endPosition.top,
- left: endPosition.left,
+ top: endPosition.top - fixTop ,
+ left: endPosition.left - fixLeft ,
height: target.innerHeight(),
width: target.innerWidth()
},
@@ -29,11 +33,11 @@ $.effects.effect.transfer = function( o ) {
.appendTo( document.body )
.addClass( o.className )
.css({
- top: startPosition.top,
- left: startPosition.left,
+ top: startPosition.top - fixTop ,
+ left: startPosition.left - fixLeft ,
height: elem.innerHeight(),
width: elem.innerWidth(),
- position: 'absolute'
+ position: targetFixed ? "fixed" : "absolute"
})
.animate( animation, o.duration, o.easing, function() {
transfer.remove();
diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js
index c6b33befb..7602ae9bc 100644
--- a/ui/jquery.ui.accordion.js
+++ b/ui/jquery.ui.accordion.js
@@ -15,6 +15,7 @@
// TODO: use ui-accordion-header-active class and fix styling
$.widget( "ui.accordion", {
+ version: "@VERSION",
options: {
active: 0,
animated: "slide",
@@ -432,7 +433,6 @@ $.widget( "ui.accordion", {
});
$.extend( $.ui.accordion, {
- version: "@VERSION",
animations: {
slide: function( options, additions ) {
var showOverflow = options.toShow.css( "overflow" ),
diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js
index 4619949fb..e39b4649e 100644
--- a/ui/jquery.ui.autocomplete.js
+++ b/ui/jquery.ui.autocomplete.js
@@ -19,6 +19,7 @@
var requestIndex = 0;
$.widget( "ui.autocomplete", {
+ version: "@VERSION",
defaultElement: "<input>",
options: {
appendTo: "body",
@@ -475,7 +476,6 @@ $.widget( "ui.autocomplete", {
});
$.extend( $.ui.autocomplete, {
- version: "@VERSION",
escapeRegex: function( value ) {
return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
},
diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js
index 32e00e9e0..482cdc24c 100644
--- a/ui/jquery.ui.button.js
+++ b/ui/jquery.ui.button.js
@@ -41,6 +41,7 @@ var lastActive, startXPos, startYPos, clickDragged,
};
$.widget( "ui.button", {
+ version: "@VERSION",
defaultElement: "<button>",
options: {
disabled: null,
@@ -412,6 +413,4 @@ $.widget( "ui.buttonset", {
}
});
-$.ui.buttonset.version = "@VERSION";
-
}( jQuery ) );
diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js
index ebc5b119d..ee0a86338 100644
--- a/ui/jquery.ui.datepicker.js
+++ b/ui/jquery.ui.datepicker.js
@@ -105,7 +105,8 @@ function Datepicker() {
altFormat: '', // The date format to use for the alternate field
constrainInput: true, // The input is constrained by the current date format
showButtonPanel: false, // True to show button panel, false to not show it
- autoSize: false // True to size the input for the date format, false to leave as is
+ autoSize: false, // True to size the input for the date format, false to leave as is
+ disabled: false // The initial disabled state
};
$.extend(this._defaults, this.regional['']);
this.dpDiv = bindHover($('<div id="' + this._mainDivId + '" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'));
@@ -197,6 +198,10 @@ $.extend(Datepicker.prototype, {
});
this._autoSize(inst);
$.data(target, PROP_NAME, inst);
+ //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
+ if( inst.settings.disabled ) {
+ this._disableDatepicker( target );
+ }
},
/* Make attachments based on settings. */
@@ -276,6 +281,10 @@ $.extend(Datepicker.prototype, {
this._setDate(inst, this._getDefaultDate(inst), true);
this._updateDatepicker(inst);
this._updateAlternate(inst);
+ //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
+ if( inst.settings.disabled ) {
+ this._disableDatepicker( target );
+ }
inst.dpDiv.show();
},
diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js
index 84b2dd3b3..0eba39842 100644
--- a/ui/jquery.ui.dialog.js
+++ b/ui/jquery.ui.dialog.js
@@ -36,6 +36,7 @@ var uiDialogClasses = "ui-dialog ui-widget ui-widget-content ui-corner-all ",
};
$.widget("ui.dialog", {
+ version: "@VERSION",
options: {
autoOpen: true,
buttons: {},
@@ -655,8 +656,6 @@ $.widget("ui.dialog", {
});
$.extend($.ui.dialog, {
- version: "@VERSION",
-
uuid: 0,
maxZ: 0,
diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js
index f8c187a7a..6475ebd61 100644
--- a/ui/jquery.ui.draggable.js
+++ b/ui/jquery.ui.draggable.js
@@ -15,6 +15,7 @@
(function( $, undefined ) {
$.widget("ui.draggable", $.ui.mouse, {
+ version: "@VERSION",
widgetEventPrefix: "drag",
options: {
addClasses: true,
@@ -502,10 +503,6 @@ $.widget("ui.draggable", $.ui.mouse, {
});
-$.extend($.ui.draggable, {
- version: "@VERSION"
-});
-
$.ui.plugin.add("draggable", "connectToSortable", {
start: function(event, ui) {
diff --git a/ui/jquery.ui.droppable.js b/ui/jquery.ui.droppable.js
index 58a1c4bc1..3942c6b8f 100644
--- a/ui/jquery.ui.droppable.js
+++ b/ui/jquery.ui.droppable.js
@@ -16,6 +16,7 @@
(function( $, undefined ) {
$.widget("ui.droppable", {
+ version: "@VERSION",
widgetEventPrefix: "drop",
options: {
accept: '*',
@@ -146,10 +147,6 @@ $.widget("ui.droppable", {
});
-$.extend($.ui.droppable, {
- version: "@VERSION"
-});
-
$.ui.intersect = function(draggable, droppable, toleranceMode) {
if (!droppable.offset) return false;
diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js
index 41b2e7a1a..7dd1a9ce0 100644
--- a/ui/jquery.ui.menu.js
+++ b/ui/jquery.ui.menu.js
@@ -1,6 +1,6 @@
/*
* jQuery UI Menu @VERSION
- *
+ *
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
@@ -12,10 +12,11 @@
* jquery.ui.widget.js
*/
(function($) {
-
+
var idIncrement = 0;
-$.widget("ui.menu", {
+$.widget( "ui.menu", {
+ version: "@VERSION",
defaultElement: "<ul>",
delay: 150,
options: {
@@ -28,8 +29,8 @@ $.widget("ui.menu", {
var self = this;
this.activeMenu = this.element;
this.menuId = this.element.attr( "id" ) || "ui-menu-" + idIncrement++;
- if (this.element.find(".ui-icon").length) {
- this.element.addClass("ui-menu-icons");
+ if ( this.element.find( ".ui-icon" ).length ) {
+ this.element.addClass( "ui-menu-icons" );
}
this.element
.addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
@@ -60,7 +61,7 @@ $.widget("ui.menu", {
self.focus( event, target );
}
})
- .bind("mouseout.menu", function( event ) {
+ .bind( "mouseout.menu", function( event ) {
if ( self.options.disabled ) {
return;
}
@@ -70,7 +71,7 @@ $.widget("ui.menu", {
}
});
this.refresh();
-
+
this.element.attr( "tabIndex", 0 ).bind( "keydown.menu", function( event ) {
if ( self.options.disabled ) {
return;
@@ -109,8 +110,8 @@ $.widget("ui.menu", {
event.preventDefault();
break;
case $.ui.keyCode.ENTER:
- if (self.active.children("a[aria-haspopup='true']").length) {
- if (self.right( event )) {
+ if ( self.active.children( "a[aria-haspopup='true']" ).length ) {
+ if ( self.right( event ) ) {
event.stopImmediatePropagation();
}
}
@@ -128,35 +129,39 @@ $.widget("ui.menu", {
break;
default:
event.stopPropagation();
- clearTimeout(self.filterTimer);
- var prev = self.previousFilter || "";
- var character = String.fromCharCode(event.keyCode);
- var skip = false;
+ 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, "\\$&");
+ function escape( value ) {
+ return value.replace( /[-[\]{}()*+?.,\\^$|#\s]/g , "\\$&" );
}
- var match = self.activeMenu.children(".ui-menu-item").filter(function() {
- return new RegExp("^" + escape(character), "i").test($(this).children("a").text());
+ match = self.activeMenu.children( ".ui-menu-item" ).filter( function() {
+ return new RegExp("^" + escape(character), "i")
+ .test( $( this ).children( "a" ).text() );
});
- var match = skip && match.index(self.active.next()) != -1 ? self.active.nextAll(".ui-menu-item") : match;
- if (!match.length) {
+ 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() {
- return new RegExp("^" + escape(character), "i").test($(this).children("a").text());
+ match = self.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 ) {
+ self.focus( event, match );
if (match.length > 1) {
self.previousFilter = character;
- self.filterTimer = setTimeout(function() {
+ self.filterTimer = setTimeout( function() {
delete self.previousFilter;
- }, 1000);
+ }, 1000 );
} else {
delete self.previousFilter;
}
@@ -166,21 +171,21 @@ $.widget("ui.menu", {
}
});
},
-
+
_destroy: function() {
//destroy (sub)menus
this.element
.removeAttr( "aria-activedescendant" )
- .find("ul")
+ .find( "ul" )
.andSelf()
.removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
.removeAttr( "role" )
- .removeAttr("tabIndex")
+ .removeAttr( "tabIndex" )
.removeAttr( "aria-labelledby" )
.removeAttr( "aria-expanded" )
.removeAttr( "aria-hidden" )
.show();
-
+
//destroy menu items
this.element.find( ".ui-menu-item" )
.unbind( ".menu" )
@@ -192,143 +197,176 @@ $.widget("ui.menu", {
.removeAttr( "role" )
.removeAttr( "aria-haspopup" )
.removeAttr( "id" )
- .children(".ui-icon").remove();
+ .children( ".ui-icon" )
+ .remove();
},
-
+
refresh: function() {
- var self = this;
- // initialize nested menus
- var submenus = this.element.find("ul:not(.ui-menu)")
- .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
- .attr("role", "menu")
- .hide()
- .attr("aria-hidden", "true")
- .attr("aria-expanded", "false")
- ;
-
+ var self = this,
+
+ // initialize nested menus
+ submenus = this.element.find( "ul:not(.ui-menu)" )
+ .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
+ .attr( "role", "menu" )
+ .hide()
+ .attr( "aria-hidden", "true" )
+ .attr( "aria-expanded", "false" ),
+
// don't refresh list items that are already adapted
- var items = submenus.add(this.element).children( "li:not(.ui-menu-item):has(a)" )
- .addClass( "ui-menu-item" )
- .attr( "role", "presentation" );
-
+ items = submenus.add( this.element ).children( "li:not(.ui-menu-item):has(a)" )
+ .addClass( "ui-menu-item" )
+ .attr( "role", "presentation" );
+
items.children( "a" )
.addClass( "ui-corner-all" )
.attr( "tabIndex", -1 )
.attr( "role", "menuitem" )
- .attr("id", function(i) {return self.element.attr("id") + "-" + i});
-
- submenus.each(function() {
- var menu = $(this);
- var item = menu.prev("a")
- item.attr("aria-haspopup", "true")
- .prepend('<span class="ui-menu-icon ui-icon ui-icon-carat-1-e"></span>');
- menu.attr("aria-labelledby", item.attr("id"));
+ .attr( "id", function( i ) {
+ return self.element.attr( "id" ) + "-" + i;
+ });
+
+ submenus.each( function() {
+ var menu = $( this ),
+ item = menu.prev( "a" );
+
+ item.attr( "aria-haspopup", "true" )
+ .prepend( '<span class="ui-menu-icon ui-icon ui-icon-carat-1-e"></span>' );
+ menu.attr( "aria-labelledby", item.attr( "id" ) );
});
},
focus: function( event, item ) {
- var self = this;
-
+ var nested,
+ self = this;
+
this.blur();
-
+
if ( this._hasScroll() ) {
- var borderTop = parseFloat( $.curCSS( this.element[0], "borderTopWidth", true) ) || 0,
- paddingTop = parseFloat( $.curCSS( this.element[0], "paddingTop", true) ) || 0,
+ var borderTop = parseFloat( $.curCSS( this.element[0], "borderTopWidth", true ) ) || 0,
+ paddingTop = parseFloat( $.curCSS( this.element[0], "paddingTop", true ) ) || 0,
offset = item.offset().top - this.element.offset().top - borderTop - paddingTop,
scroll = this.element.scrollTop(),
elementHeight = this.element.height(),
itemHeight = item.height();
+
if ( offset < 0 ) {
this.element.scrollTop( scroll + offset );
} else if ( offset + itemHeight > elementHeight ) {
this.element.scrollTop( scroll + offset - elementHeight + itemHeight );
}
}
-
+
this.active = item.first()
.children( "a" )
.addClass( "ui-state-focus" )
.end();
- self.element.attr("aria-activedescendant", self.active.children("a").attr("id"))
+ self.element.attr( "aria-activedescendant", self.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.timer = setTimeout( function() {
self._close();
- }, self.delay)
- var nested = $(">ul", item);
- if (nested.length && /^mouse/.test(event.type)) {
+ }, self.delay );
+
+ nested = $( ">ul", item );
+ if ( nested.length && ( /^mouse/.test( event.type ) ) ) {
self._startOpening(nested);
}
this.activeMenu = item.parent();
-
+
this._trigger( "focus", event, { item: item } );
},
- blur: function(event) {
- if (!this.active) {
+ blur: function( event ) {
+ if ( !this.active ) {
return;
}
-
- clearTimeout(this.timer);
-
+
+ clearTimeout( this.timer );
+
this.active.children( "a" ).removeClass( "ui-state-focus" );
this.active = null;
},
- _startOpening: function(submenu) {
- clearTimeout(this.timer);
+ _startOpening: function( submenu ) {
+ clearTimeout( this.timer );
var self = this;
- self.timer = setTimeout(function() {
+ self.timer = setTimeout( function() {
self._close();
- self._open(submenu);
- }, self.delay);
+ self._open( submenu );
+ }, self.delay );
},
-
- _open: function(submenu) {
- clearTimeout(this.timer);
- this.element.find(".ui-menu").not(submenu.parents()).hide().attr("aria-hidden", "true");
+
+ _open: function( submenu ) {
+ clearTimeout( this.timer );
+ this.element
+ .find( ".ui-menu" )
+ .not( submenu.parents() )
+ .hide()
+ .attr( "aria-hidden", "true" );
+
var position = $.extend({}, {
- of: this.active
- }, $.type(this.options.position) == "function"
- ? this.options.position(this.active)
- : this.options.position
- );
- submenu.show().removeAttr("aria-hidden").attr("aria-expanded", "true").position(position);
+ of: this.active
+ }, $.type(this.options.position) == "function"
+ ? this.options.position(this.active)
+ : this.options.position
+ );
+
+ submenu.show()
+ .removeAttr( "aria-hidden" )
+ .attr( "aria-expanded", "true" )
+ .position( position );
},
-
+
closeAll: function() {
this.element
- .find("ul").hide().attr("aria-hidden", "true").attr("aria-expanded", "false").end()
- .find("a.ui-state-active").removeClass("ui-state-active");
+ .find( "ul" )
+ .hide()
+ .attr( "aria-hidden", "true" )
+ .attr( "aria-expanded", "false" )
+ .end()
+ .find( "a.ui-state-active" )
+ .removeClass( "ui-state-active" );
+
this.blur();
this.activeMenu = this.element;
},
-
+
_close: function() {
this.active.parent()
- .find("ul").hide().attr("aria-hidden", "true").attr("aria-expanded", "false").end()
- .find("a.ui-state-active").removeClass("ui-state-active");
+ .find( "ul" )
+ .hide()
+ .attr( "aria-hidden", "true" )
+ .attr( "aria-expanded", "false" )
+ .end()
+ .find( "a.ui-state-active" )
+ .removeClass( "ui-state-active" );
},
- left: function(event) {
+ left: function( event ) {
var newItem = this.active && this.active.parents("li:not(.ui-menubar-item)").first();
- if (newItem && newItem.length) {
- this.active.parent().attr("aria-hidden", "true").attr("aria-expanded", "false").hide();
- this.focus(event, newItem);
+ if ( newItem && newItem.length ) {
+ this.active.parent()
+ .attr("aria-hidden", "true")
+ .attr("aria-expanded", "false")
+ .hide();
+ this.focus( event, newItem );
return true;
}
},
- right: function(event) {
- var self= this;
- var newItem = this.active && this.active.children("ul").children("li").first();
- if (newItem && newItem.length) {
- this._open(newItem.parent());
- var current = this.active;
+ right: function( event ) {
+ var self = this,
+ 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)}, 20);
+ setTimeout( function() {
+ self.focus( event, newItem );
+ }, 20 );
return true;
}
},
@@ -349,19 +387,19 @@ $.widget("ui.menu", {
return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
},
- _move: function(direction, edge, filter, event) {
+ _move: function( direction, edge, filter, event ) {
if ( !this.active ) {
- this.focus( event, this.activeMenu.children(edge)[filter]() );
+ this.focus( event, this.activeMenu.children( edge )[ filter ]() );
return;
}
var next = this.active[ direction + "All" ]( ".ui-menu-item" ).eq( 0 );
if ( next.length ) {
this.focus( event, next );
} else {
- this.focus( event, this.activeMenu.children(edge)[filter]() );
+ this.focus( event, this.activeMenu.children( edge )[ filter ]() );
}
},
-
+
nextPage: function( event ) {
if ( this._hasScroll() ) {
if ( !this.active || this.last() ) {
@@ -420,6 +458,4 @@ $.widget("ui.menu", {
}
});
-$.ui.menu.version = "@VERSION";
-
}( jQuery ));
diff --git a/ui/jquery.ui.menubar.js b/ui/jquery.ui.menubar.js
index 2879d079c..39e75924e 100644
--- a/ui/jquery.ui.menubar.js
+++ b/ui/jquery.ui.menubar.js
@@ -18,10 +18,15 @@
// TODO when mixing clicking menus and keyboard navigation, focus handling is broken
// there has to be just one item that has tabindex
$.widget( "ui.menubar", {
- options: {
- buttons: false,
- menuIcon: false
- },
+ version: "@VERSION",
+ options: {
+ buttons: false,
+ menuIcon: false,
+ position: {
+ my: "left top",
+ at: "left bottom"
+ }
+ },
_create: function() {
var that = this;
var items = this.items = this.element.children( "li" )
@@ -38,6 +43,9 @@ $.widget( "ui.menubar", {
this._hoverable( items );
items.next( "ul" )
.menu({
+ position: {
+ within: this.options.position.within
+ },
select: function( event, ui ) {
ui.item.parents( "ul.ui-menu:last" ).hide();
that._trigger( "select", event, ui );
@@ -68,13 +76,13 @@ $.widget( "ui.menubar", {
var input = $(this),
// TODO menu var is only used on two places, doesn't quite justify the .each
menu = input.next( "ul" );
-
+
input.bind( "click.menubar focus.menubar mouseenter.menubar", function( event ) {
// ignore triggered focus event
if ( event.type == "focus" && !event.originalEvent ) {
return;
}
- event.preventDefault();
+ event.preventDefault();
// TODO can we simplify or extractthis check? especially the last two expressions
// there's a similar active[0] == menu[0] check in _open
if ( event.type == "click" && menu.is( ":visible" ) && that.active && that.active[0] == menu[0] ) {
@@ -84,7 +92,7 @@ $.widget( "ui.menubar", {
if ( ( that.open && event.type == "mouseenter" ) || event.type == "click" ) {
that._open( event, menu );
}
- })
+ })
.bind( "keydown", function( event ) {
switch ( event.keyCode ) {
case $.ui.keyCode.SPACE:
@@ -113,12 +121,12 @@ $.widget( "ui.menubar", {
input.addClass( "ui-state-default" ).append( "<span class='ui-button-icon-secondary ui-icon ui-icon-triangle-1-s'></span>" );
input.removeClass( "ui-button-text-only" ).addClass( "ui-button-text-icon-secondary" );
}
-
+
if ( !that.options.buttons ) {
// TODO ui-menubar-link is added above, not needed here?
input.addClass( "ui-menubar-link" ).removeClass( "ui-state-default" );
- };
-
+ };
+
});
that._bind( {
keydown: function( event ) {
@@ -139,18 +147,18 @@ $.widget( "ui.menubar", {
}
});
},
-
+
_destroy : function() {
var items = this.element.children( "li" )
.removeClass( "ui-menubar-item" )
.removeAttr( "role", "presentation" )
.children( "button, a" );
-
+
this.element
.removeClass( "ui-menubar ui-widget-header ui-helper-clearfix" )
.removeAttr( "role", "menubar" )
.unbind( ".menubar" );
-
+
items
.unbind( ".menubar" )
.removeClass( "ui-button ui-widget ui-button-text-only ui-menubar-link ui-state-default" )
@@ -172,7 +180,7 @@ $.widget( "ui.menubar", {
.removeAttr( "tabindex" )
.unbind( ".menubar" );
},
-
+
_close: function() {
if ( !this.active || !this.active.length )
return;
@@ -188,7 +196,7 @@ $.widget( "ui.menubar", {
this.active = null;
this.open = false;
},
-
+
_open: function( event, menu ) {
// on a single-button menubar, ignore reopening the same menu
if ( this.active && this.active[0] == menu[0] ) {
@@ -209,11 +217,9 @@ $.widget( "ui.menubar", {
var button = menu.prev().addClass( "ui-state-active" ).attr( "tabIndex", -1 );
this.active = menu
.show()
- .position( {
- my: "left top",
- at: "left bottom",
+ .position( $.extend({
of: button
- })
+ }, this.options.position ) )
.removeAttr( "aria-hidden" )
.attr( "aria-expanded", "true" )
.menu("focus", event, menu.children( "li" ).first() )
@@ -222,7 +228,7 @@ $.widget( "ui.menubar", {
.focusin();
this.open = true;
},
-
+
// TODO refactor this and the next three methods
_prev: function( event, button ) {
button.attr( "tabIndex", -1 );
@@ -234,7 +240,7 @@ $.widget( "ui.menubar", {
lastItem.removeAttr( "tabIndex" )[0].focus();
}
},
-
+
_next: function( event, button ) {
button.attr( "tabIndex", -1 );
var next = button.parent().nextAll( "li" ).children( ".ui-button" ).eq( 0 );
@@ -256,7 +262,7 @@ $.widget( "ui.menubar", {
this._open( event, lastItem );
}
},
-
+
// TODO rename to child (or something like that)
_right: function( event ) {
var next = this.active.parent().nextAll( "li:eq(0)" ).children( ".ui-menu" ).eq( 0 );
diff --git a/ui/jquery.ui.mouse.js b/ui/jquery.ui.mouse.js
index 2fb1389f2..582eaf9c0 100644
--- a/ui/jquery.ui.mouse.js
+++ b/ui/jquery.ui.mouse.js
@@ -18,6 +18,7 @@ $(document).mousedown(function(e) {
});
$.widget("ui.mouse", {
+ version: "@VERSION",
options: {
cancel: ':input,option',
distance: 1,
diff --git a/ui/jquery.ui.popup.js b/ui/jquery.ui.popup.js
index 10361a35c..d455346dc 100644
--- a/ui/jquery.ui.popup.js
+++ b/ui/jquery.ui.popup.js
@@ -13,10 +13,11 @@
* jquery.ui.position.js
*/
(function($) {
-
+
var idIncrement = 0;
$.widget( "ui.popup", {
+ version: "@VERSION",
options: {
position: {
my: "left top",
@@ -27,34 +28,34 @@ $.widget( "ui.popup", {
if ( !this.options.trigger ) {
this.options.trigger = this.element.prev();
}
-
+
if ( !this.element.attr( "id" ) ) {
this.element.attr( "id", "ui-popup-" + idIncrement++ );
this.generatedId = true;
}
-
+
if ( !this.element.attr( "role" ) ) {
// TODO alternatives to tooltip are dialog and menu, all three aren't generic popups
- this.element.attr( "role", "tooltip" );
+ this.element.attr( "role", "dialog" );
this.generatedRole = true;
}
-
+
this.options.trigger
.attr( "aria-haspopup", true )
.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 hapens for anchor ui.button
- if ( this.options.trigger.is( "a:ui-button" ) && event.keyCode == $.ui.keyCode.SPACE) {
- event.preventDefault()
+ // 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 ) {
+ event.preventDefault();
}
// TODO handle SPACE to open popup? only when not handled by ui.button
- if ( event.keyCode == $.ui.keyCode.SPACE && this.options.trigger.is("a:not(:ui-button)") ) {
+ if ( event.keyCode == $.ui.keyCode.SPACE && this.options.trigger.is( "a:not(:ui-button)" ) ) {
this.options.trigger.trigger( "click", event );
}
// translate keydown to click
@@ -78,52 +79,75 @@ $.widget( "ui.popup", {
}, 1);
}
});
-
- this._bind(this.element, {
- // TODO use focusout so that element itself doesn't need to be focussable
- blur: function( event ) {
+
+ if ( !this.element.is( ":ui-menu" ) ) {
+ //default use case, wrap tab order in popup
+ this._bind({ keydown : function( event ) {
+ if ( event.keyCode !== $.ui.keyCode.TAB ) {
+ return;
+ }
+ var tabbables = $( ":tabbable", this.element ),
+ first = tabbables.first(),
+ last = tabbables.last();
+ if ( event.target === last[ 0 ] && !event.shiftKey ) {
+ first.focus( 1 );
+ event.preventDefault();
+ } else if ( event.target === first[ 0 ] && event.shiftKey ) {
+ last.focus( 1 );
+ event.preventDefault();
+ }
+ }
+ });
+ }
+
+ this._bind({
+ focusout: function( event ) {
var that = this;
// use a timer to allow click to clear it and letting that
// handle the closing instead of opening again
that.closeTimer = setTimeout( function() {
that.close( event );
}, 100);
+ },
+ focusin: function( event ) {
+ clearTimeout( this.closeTimer );
}
});
this._bind({
- // TODO only triggerd on element if it can receive focus
+ // TODO only triggered on element if it can receive focus
// bind to document instead?
// either element itself or a child should be focusable
keyup: function( event ) {
- if (event.keyCode == $.ui.keyCode.ESCAPE && this.element.is( ":visible" )) {
+ if ( event.keyCode == $.ui.keyCode.ESCAPE && this.element.is( ":visible" ) ) {
this.close( event );
// TODO move this to close()? would allow menu.select to call popup.close, and get focus back to trigger
this.options.trigger.focus();
}
}
});
-
+
this._bind(document, {
click: function( event ) {
- if (this.isOpen && !$(event.target).closest(".ui-popup").length) {
+ if ( this.isOpen && !$(event.target).closest(".ui-popup").length ) {
this.close( event );
}
}
})
},
-
+
_destroy: function() {
this.element
.show()
.removeClass( "ui-popup" )
.removeAttr( "aria-hidden" )
- .removeAttr( "aria-expanded" );
+ .removeAttr( "aria-expanded" )
+ .unbind( "keypress.ui-popup");
this.options.trigger
.removeAttr( "aria-haspopup" )
.removeAttr( "aria-owns" );
-
+
if ( this.generatedId ) {
this.element.removeAttr( "id" );
}
@@ -131,7 +155,7 @@ $.widget( "ui.popup", {
this.element.removeAttr( "role" );
}
},
-
+
open: function( event ) {
var position = $.extend( {}, {
of: this.options.trigger
@@ -141,17 +165,28 @@ $.widget( "ui.popup", {
.show()
.attr( "aria-hidden", false )
.attr( "aria-expanded", true )
- .position( position )
- // TODO find a focussable child, otherwise put focus on element, add tabIndex=0 if not focussable
- .focus();
+ .position( position );
- if (this.element.is(":ui-menu")) {
- this.element.menu("focus", event, this.element.children( "li" ).first() );
+ if (this.element.is( ":ui-menu" )) { //popup is a menu
+ this.element.menu( "focus", event, this.element.children( "li" ).first() );
+ this.element.focus();
+ } else {
+ // set focus to the first tabbable element in the popup container
+ // if there are no tabbable elements, set focus on the popup itself
+ var tabbables = this.element.find( ":tabbable" );
+ this.removeTabIndex = false;
+ if ( !tabbables.length ) {
+ if ( !this.element.is(":tabbable") ) {
+ this.element.attr("tabindex", "0");
+ this.removeTabIndex = true;
+ }
+ tabbables = tabbables.add( this.element[ 0 ] );
+ }
+ tabbables.first().focus( 1 );
}
// take trigger out of tab order to allow shift-tab to skip trigger
- this.options.trigger.attr("tabindex", -1);
-
+ this.options.trigger.attr( "tabindex", -1 );
this.isOpen = true;
this._trigger( "open", event );
},
@@ -162,13 +197,13 @@ $.widget( "ui.popup", {
.attr( "aria-hidden", true )
.attr( "aria-expanded", false );
- this.options.trigger.attr("tabindex", 0);
-
+ this.options.trigger.attr( "tabindex" , 0 );
+ if ( this.removeTabIndex ) {
+ this.element.removeAttr( "tabindex" );
+ }
this.isOpen = false;
this._trigger( "close", event );
}
-
-
});
}(jQuery));
diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js
index 98b8198e2..3bae0d010 100644
--- a/ui/jquery.ui.position.js
+++ b/ui/jquery.ui.position.js
@@ -19,6 +19,39 @@ var rhorizontal = /left|center|right/,
center = "center",
_position = $.fn.position;
+$.position = {
+ scrollbarWidth: function() {
+ var w1, w2,
+ div = $( "<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
+ innerDiv = div.children()[0];
+
+ $( "body" ).append( div );
+ w1 = innerDiv.offsetWidth;
+ div.css( "overflow", "scroll" );
+
+ w2 = innerDiv.offsetWidth;
+
+ if ( w1 === w2 ) {
+ w2 = div[0].clientWidth;
+ }
+
+ div.remove();
+
+ return w1 - w2;
+ },
+ getScrollInfo: function( within ) {
+ var that = within[0],
+ scrollHeight = within.height() < that.scrollHeight,
+ scrollWidth = within.width() < that.scrollWidth,
+ scrollbarWidth = $.position.scrollbarWidth();
+
+ return {
+ height: scrollHeight ? scrollbarWidth : 0,
+ width : scrollWidth ? scrollbarWidth : 0
+ };
+ }
+};
+
$.fn.position = function( options ) {
if ( !options || !options.of ) {
return _position.apply( this, arguments );
@@ -28,6 +61,7 @@ $.fn.position = function( options ) {
options = $.extend( {}, options );
var target = $( options.of ),
+ within = $( options.within || window ),
targetElem = target[0],
collision = ( options.collision || "flip" ).split( " " ),
offsets = {},
@@ -56,7 +90,7 @@ $.fn.position = function( options ) {
}
// force my and at to have valid horizontal and vertical positions
- // if a value is missing or invalid, it will be converted to center
+ // if a value is missing or invalid, it will be converted to center
$.each( [ "my", "at" ], function() {
var pos = ( options[ this ] || "" ).split( " " ),
horizontalOffset,
@@ -110,7 +144,7 @@ $.fn.position = function( options ) {
parseInt( offsets.at[ 1 ], 10 ) *
( rpercent.test( offsets.at[ 1 ] ) ? targetHeight / 100 : 1 )
];
- basePosition.left += atOffset[ 0 ],
+ basePosition.left += atOffset[ 0 ];
basePosition.top += atOffset[ 1 ];
return this.each(function() {
@@ -119,10 +153,11 @@ $.fn.position = function( options ) {
elemHeight = elem.outerHeight(),
marginLeft = parseInt( $.curCSS( this, "marginLeft", true ) ) || 0,
marginTop = parseInt( $.curCSS( this, "marginTop", true ) ) || 0,
+ scrollInfo = $.position.getScrollInfo( within ),
collisionWidth = elemWidth + marginLeft +
- ( parseInt( $.curCSS( this, "marginRight", true ) ) || 0 ),
+ ( parseInt( $.curCSS( this, "marginRight", true ) ) || 0 ) + scrollInfo.width,
collisionHeight = elemHeight + marginTop +
- ( parseInt( $.curCSS( this, "marginBottom", true ) ) || 0 ),
+ ( parseInt( $.curCSS( this, "marginBottom", true ) ) || 0 ) + scrollInfo.height,
position = $.extend( {}, basePosition ),
myOffset = [
parseInt( offsets.my[ 0 ], 10 ) *
@@ -168,7 +203,8 @@ $.fn.position = function( options ) {
collisionHeight: collisionHeight,
offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
my: options.my,
- at: options.at
+ at: options.at,
+ within: within
});
}
});
@@ -183,32 +219,40 @@ $.fn.position = function( options ) {
$.ui.position = {
fit: {
left: function( position, data ) {
- var win = $( window ),
- overLeft = win.scrollLeft() - data.collisionPosition.left,
- overRight = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft();
+ var within = data.within,
+ win = $( window ),
+ 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 > win.width() || overLeft > 0 ) {
- position.left = position.left + overLeft;
+ if ( data.collisionWidth > outerWidth || overLeft > 0 ) {
+ position.left += overLeft;
// too far right -> align with right edge
} else if ( overRight > 0 ) {
- position.left = position.left - overRight;
+ position.left -= overRight;
// adjust based on position and margin
} else {
position.left = Math.max( position.left - data.collisionPosition.left, position.left );
}
},
top: function( position, data ) {
- var win = $( window ),
- overTop = win.scrollTop() - data.collisionPosition.top,
- overBottom = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop();
+ var within = data.within,
+ win = $( window ),
+ 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 > win.height() || overTop > 0 ) {
- position.top = position.top + overTop;
+ if ( data.collisionHeight > outerHeight || overTop > 0 ) {
+ position.top += overTop;
// too far down -> align with bottom edge
} else if ( overBottom > 0 ) {
- position.top = position.top - overBottom;
+ position.top -= overBottom;
// adjust based on position and margin
} else {
position.top = Math.max( position.top - data.collisionPosition.top, position.top );
@@ -220,8 +264,15 @@ $.ui.position = {
if ( data.at[ 0 ] === center ) {
return;
}
- var win = $( window ),
- over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft(),
+
+ var within = data.within,
+ win = $( window ),
+ isWindow = $.isWindow( data.within[0] ),
+ withinOffset = isWindow ? 0 : within.offset().left,
+ outerWidth = isWindow ? within.width() : within.outerWidth(),
+ overLeft = data.collisionPosition.left - withinOffset,
+ overRight = data.collisionPosition.left + data.collisionWidth - outerWidth - withinOffset,
+ left = data.my[ 0 ] === "left",
myOffset = data.my[ 0 ] === "left" ?
-data.elemWidth :
data.my[ 0 ] === "right" ?
@@ -231,19 +282,23 @@ $.ui.position = {
data.targetWidth :
-data.targetWidth,
offset = -2 * data.offset[ 0 ];
- position.left += data.collisionPosition.left < 0 ?
- myOffset + atOffset + offset :
- over > 0 ?
- myOffset + atOffset + offset :
- 0;
+ if ( overLeft < 0 || overRight > 0 ) {
+ position.left += myOffset + atOffset + offset;
+ }
},
top: function( position, data ) {
if ( data.at[ 1 ] === center ) {
return;
}
- var win = $( window ),
- over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop(),
- myOffset = data.my[ 1 ] === "top" ?
+ var within = data.within,
+ win = $( window ),
+ isWindow = $.isWindow( data.within[0] ),
+ withinOffset = isWindow ? 0 : within.offset().top,
+ outerHeight = isWindow ? within.height() : within.outerHeight(),
+ overTop = data.collisionPosition.top - withinOffset,
+ overBottom = data.collisionPosition.top + data.collisionHeight - outerHeight - withinOffset,
+ top = data.my[ 1 ] === "top",
+ myOffset = top ?
-data.elemHeight :
data.my[ 1 ] === "bottom" ?
data.elemHeight :
@@ -252,11 +307,9 @@ $.ui.position = {
data.targetHeight :
-data.targetHeight,
offset = -2 * data.offset[ 1 ];
- position.top += data.collisionPosition.top < 0 ?
- myOffset + atOffset + offset :
- over > 0 ?
- myOffset + atOffset + offset :
- 0;
+ if ( overTop < 0 || overBottom > 0 ) {
+ position.top += myOffset + atOffset + offset;
+ }
}
}
};
@@ -267,7 +320,7 @@ if ( $.uiBackCompat !== false ) {
(function( $ ) {
var _position = $.fn.position;
$.fn.position = function( options ) {
- if ( !options || !( "offset" in options ) ) {
+ if ( !options || !options.offset ) {
return _position.call( this, options );
}
var offset = options.offset.split( " " ),
diff --git a/ui/jquery.ui.progressbar.js b/ui/jquery.ui.progressbar.js
index e3b25cfd7..187470681 100644
--- a/ui/jquery.ui.progressbar.js
+++ b/ui/jquery.ui.progressbar.js
@@ -14,6 +14,7 @@
(function( $, undefined ) {
$.widget( "ui.progressbar", {
+ version: "@VERSION",
options: {
value: 0,
max: 100
@@ -100,8 +101,4 @@ $.widget( "ui.progressbar", {
}
});
-$.extend( $.ui.progressbar, {
- version: "@VERSION"
-});
-
})( jQuery );
diff --git a/ui/jquery.ui.resizable.js b/ui/jquery.ui.resizable.js
index de24e94dd..673a8fd75 100644
--- a/ui/jquery.ui.resizable.js
+++ b/ui/jquery.ui.resizable.js
@@ -15,6 +15,7 @@
(function( $, undefined ) {
$.widget("ui.resizable", $.ui.mouse, {
+ version: "@VERSION",
widgetEventPrefix: "resize",
options: {
alsoResize: false,
@@ -548,10 +549,6 @@ $.widget("ui.resizable", $.ui.mouse, {
});
-$.extend($.ui.resizable, {
- version: "@VERSION"
-});
-
/*
* Resizable Extensions
*/
diff --git a/ui/jquery.ui.selectable.js b/ui/jquery.ui.selectable.js
index fa7d01122..75f1cee66 100644
--- a/ui/jquery.ui.selectable.js
+++ b/ui/jquery.ui.selectable.js
@@ -15,6 +15,7 @@
(function( $, undefined ) {
$.widget("ui.selectable", $.ui.mouse, {
+ version: "@VERSION",
options: {
appendTo: 'body',
autoRefresh: true,
@@ -259,8 +260,4 @@ $.widget("ui.selectable", $.ui.mouse, {
});
-$.extend($.ui.selectable, {
- version: "@VERSION"
-});
-
})(jQuery);
diff --git a/ui/jquery.ui.slider.js b/ui/jquery.ui.slider.js
index f0b01d7c0..978155370 100644
--- a/ui/jquery.ui.slider.js
+++ b/ui/jquery.ui.slider.js
@@ -19,7 +19,7 @@
var numPages = 5;
$.widget( "ui.slider", $.ui.mouse, {
-
+ version: "@VERSION",
widgetEventPrefix: "slide",
options: {
@@ -659,8 +659,4 @@ $.widget( "ui.slider", $.ui.mouse, {
});
-$.extend( $.ui.slider, {
- version: "@VERSION"
-});
-
}(jQuery));
diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js
index a8084412f..99798a915 100644
--- a/ui/jquery.ui.sortable.js
+++ b/ui/jquery.ui.sortable.js
@@ -15,6 +15,7 @@
(function( $, undefined ) {
$.widget("ui.sortable", $.ui.mouse, {
+ version: "@VERSION",
widgetEventPrefix: "sort",
options: {
appendTo: "parent",
@@ -1069,8 +1070,4 @@ $.widget("ui.sortable", $.ui.mouse, {
});
-$.extend($.ui.sortable, {
- version: "@VERSION"
-});
-
})(jQuery);
diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js
index 0a0ebb37e..951b336ed 100644
--- a/ui/jquery.ui.spinner.js
+++ b/ui/jquery.ui.spinner.js
@@ -14,6 +14,7 @@
(function( $ ) {
$.widget( "ui.spinner", {
+ version: "@VERSION",
defaultElement: "<input>",
widgetEventPrefix: "spin",
options: {
@@ -62,6 +63,7 @@ $.widget( "ui.spinner", {
// add buttons
.append( self._buttonHtml() )
// add behaviours
+ .disableSelection()
// TODO: user ._hoverable
.hover(function() {
if ( !options.disabled ) {
@@ -251,17 +253,34 @@ $.widget( "ui.spinner", {
this.counter > 20
? this.counter > 100
? this.counter > 200
- ? 100
+ ? 100
: 10
: 2
: 1);
+ // clamp the new value
+ newVal = this._trimValue( newVal );
+
if ( this._trigger( "spin", event, { value: newVal } ) !== false) {
this.value( newVal );
this.counter++;
}
},
+ _trimValue: function( value ) {
+ var options = this.options;
+
+ if ( value > options.max) {
+ return options.max;
+ }
+
+ if ( value < options.min ) {
+ return options.min;
+ }
+
+ return value;
+ },
+
_stop: function( event ) {
this.counter = 0;
if ( this.timer ) {
@@ -278,13 +297,7 @@ $.widget( "ui.spinner", {
_setOption: function( key, value ) {
if ( key === "value") {
- value = this._parse( value );
- if ( value < this.options.min ) {
- value = this.options.min;
- }
- if ( value > this.options.max ) {
- value = this.options.max;
- }
+ value = this._trimValue( this._parse(value) );
}
if ( key === "disabled" ) {
@@ -368,6 +381,4 @@ $.widget( "ui.spinner", {
}
});
-$.ui.spinner.version = "@VERSION";
-
}( jQuery ) );
diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js
index 239805b14..515a93ae0 100644
--- a/ui/jquery.ui.tabs.js
+++ b/ui/jquery.ui.tabs.js
@@ -19,6 +19,7 @@ function getNextTabId() {
}
$.widget( "ui.tabs", {
+ version: "@VERSION",
options: {
active: null,
collapsible: false,
@@ -577,10 +578,6 @@ $.widget( "ui.tabs", {
}
});
-$.extend( $.ui.tabs, {
- version: "@VERSION"
-});
-
// DEPRECATED
if ( $.uiBackCompat !== false ) {
diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js
index a8a44f1c0..f19061bc3 100644
--- a/ui/jquery.ui.tooltip.js
+++ b/ui/jquery.ui.tooltip.js
@@ -12,136 +12,205 @@
* jquery.ui.widget.js
* jquery.ui.position.js
*/
-(function($) {
+(function( $ ) {
var increments = 0;
-$.widget("ui.tooltip", {
+$.widget( "ui.tooltip", {
+ version: "@VERSION",
options: {
- tooltipClass: null,
- items: "[title]",
content: function() {
return $( this ).attr( "title" );
},
+ hide: true,
+ items: "[title]",
position: {
my: "left+15 center",
- at: "right center"
- }
+ at: "right center",
+ collision: "flip fit"
+ },
+ show: true,
+ tooltipClass: null,
+
+ // callbacks
+ close: null,
+ open: null
},
+
_create: function() {
- this._bind( {
+ this._bind({
mouseover: "open",
focusin: "open"
});
+
+ // IDs of generated tooltips, needed for destroy
+ this.tooltips = {};
},
-
- enable: function() {
- this.options.disabled = false;
+
+ _setOption: function( key, value ) {
+ if ( key === "disabled" ) {
+ this[ value ? "_disable" : "_enable" ]();
+ this.options[ key ] = value;
+ // disable element style changes
+ return;
+ }
+ this._super( "_setOption", key, value );
},
-
- disable: function() {
- // only set option, disable element style changes
- this.options.disabled = true;
+
+ _disable: function() {
+ var that = this;
+
+ // close open tooltips
+ $.each( this.tooltips, function( id, element ) {
+ var event = $.Event( "blur" );
+ event.target = event.currentTarget = element[0];
+ that.close( event, true );
+ });
+
+ // remove title attributes to prevent native tooltips
+ this.element.find( this.options.items ).andSelf().each(function() {
+ var element = $( this );
+ if ( element.is( "[title]" ) ) {
+ element
+ .data( "tooltip-title", element.attr( "title" ) )
+ .attr( "title", "" );
+ }
+ });
},
-
- open: function(event) {
- var target = $(event && event.target || this.element).closest(this.options.items);
- if ( !target.length ) {
+
+ _enable: function() {
+ // restore title attributes
+ this.element.find( this.options.items ).andSelf().each(function() {
+ var element = $( this );
+ if ( element.data( "tooltip-title" ) ) {
+ element.attr( "title", element.data( "tooltip-title" ) );
+ }
+ });
+ },
+
+ open: function( event ) {
+ var content,
+ that = this,
+ target = $( event ? event.target : this.element )
+ .closest( this.options.items );
+
+ // if aria-describedby exists, then the tooltip is already open
+ if ( !target.length || target.attr( "aria-describedby" ) ) {
return;
}
- var self = this;
- if ( !target.data("tooltip-title") ) {
- target.data("tooltip-title", target.attr("title"));
+
+ if ( !target.data( "tooltip-title" ) ) {
+ target.data( "tooltip-title", target.attr( "title" ) );
}
- var content = this.options.content.call(target[0], function(response) {
- // IE may instantly serve a cached response, need to give it a chance to finish with _open before that
+
+ content = this.options.content.call( target[0], function( response ) {
+ // IE may instantly serve a cached response for ajax requests
+ // delay this call to _open so the other call to _open runs first
setTimeout(function() {
- // when undefined, it got removeAttr, then ignore (ajax response)
- // intially its an empty string, so not undefined
- // TODO is there a better approach to enable ajax tooltips to have two updates?
- if (target.attr( "aria-describedby" ) !== undefined) {
- self._open(event, target, response);
- }
- }, 13);
+ that._open( event, target, response );
+ }, 1 );
});
- if (content) {
- self._open(event, target, content);
+ if ( content ) {
+ that._open( event, target, content );
}
},
-
+
_open: function( event, target, content ) {
- if ( !content )
+ if ( !content ) {
return;
+ }
- target.attr("title", "");
-
- if ( this.options.disabled )
- return;
+ // if we have a title, clear it to prevent the native tooltip
+ // we have to check first to avoid defining a title if none exists
+ // (we don't want to cause an element to start matching [title])
+ // TODO: document why we don't use .removeAttr()
+ if ( target.is( "[title]" ) ) {
+ target.attr( "title", "" );
+ }
// ajaxy tooltip can update an existing one
var tooltip = this._find( target );
- if (!tooltip.length) {
- tooltip = this._tooltip();
+ if ( !tooltip.length ) {
+ tooltip = this._tooltip( target );
target.attr( "aria-describedby", tooltip.attr( "id" ) );
}
- tooltip.find(".ui-tooltip-content").html( content );
- tooltip.position( $.extend({
- of: target
- }, this.options.position ) ).hide();
+ tooltip.find( ".ui-tooltip-content" ).html( content );
+ tooltip
+ .stop( true )
+ .position( $.extend({
+ of: target
+ }, this.options.position ) )
+ .hide();
- tooltip.stop( true );
this._show( tooltip, this.options.show );
- this._trigger( "open", event );
+ this._trigger( "open", event, { tooltip: tooltip } );
this._bind( target, {
mouseleave: "close",
- blur: "close",
- click: "close"
+ blur: "close"
});
},
-
- close: function( event ) {
- var target = $( event && event.currentTarget || this.element );
- target.attr( "title", target.data( "tooltip-title" ) );
-
- if ( this.options.disabled )
+
+ close: function( event, force ) {
+ var that = this,
+ target = $( event ? event.currentTarget : this.element ),
+ tooltip = this._find( target );
+
+ // don't close if the element has focus
+ // this prevents the tooltip from closing if you hover while focused
+ if ( !force && document.activeElement === target[0] ) {
return;
+ }
+
+ // only set title if we had one before (see comment in _open())
+ if ( target.data( "tooltip-title" ) ) {
+ target.attr( "title", target.data( "tooltip-title" ) );
+ }
- var tooltip = this._find( target );
target.removeAttr( "aria-describedby" );
-
+
tooltip.stop( true );
this._hide( tooltip, this.options.hide, function() {
$( this ).remove();
+ delete that.tooltips[ this.id ];
});
-
+
target.unbind( "mouseleave.tooltip blur.tooltip" );
-
- this._trigger( "close", event );
+
+ this._trigger( "close", event, { tooltip: tooltip } );
},
- _tooltip: function() {
- var tooltip = $( "<div></div>" )
- .attr( "id", "ui-tooltip-" + increments++ )
- .attr( "role", "tooltip" )
- .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content" );
- if (this.options.tooltipClass) {
- tooltip.addClass(this.options.tooltipClass);
- }
- $( "<div></div>" )
+ _tooltip: function( element ) {
+ var id = "ui-tooltip-" + increments++,
+ tooltip = $( "<div>" )
+ .attr({
+ id: id,
+ role: "tooltip"
+ })
+ .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " +
+ ( this.options.tooltipClass || "" ) );
+ $( "<div>" )
.addClass( "ui-tooltip-content" )
.appendTo( tooltip );
tooltip.appendTo( document.body );
+ if ( $.fn.bgiframe ) {
+ tooltip.bgiframe();
+ }
+ this.tooltips[ id ] = element;
return tooltip;
},
_find: function( target ) {
var id = target.attr( "aria-describedby" );
- return id ? $( document.getElementById( id ) ) : $();
+ return id ? $( "#" + id ) : $();
+ },
+
+ _destroy: function() {
+ $.each( this.tooltips, function( id ) {
+ $( "#" + id ).remove();
+ });
}
});
-$.ui.tooltip.version = "@VERSION";
-
-})(jQuery); \ No newline at end of file
+}( jQuery ) );
diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js
index 4167fd4e5..59d110b6a 100644
--- a/ui/jquery.ui.widget.js
+++ b/ui/jquery.ui.widget.js
@@ -49,7 +49,7 @@ $.widget = function( name, base, prototype ) {
if ( arguments.length ) {
this._createWidget( options, element );
}
- }, $[ namespace ][ name ] );
+ }, $[ namespace ][ name ], { version: prototype.version } );
var basePrototype = new base();
// we need to make the options hash a property directly on the new instance
@@ -133,7 +133,7 @@ $.widget.bridge = function( name, object ) {
}
var methodValue = instance[ options ].apply( instance, args );
if ( methodValue !== instance && methodValue !== undefined ) {
- returnValue = methodValue.jquery ?
+ returnValue = methodValue && methodValue.jquery ?
returnValue.pushStack( methodValue.get() ) :
methodValue;
return false;
@@ -239,9 +239,6 @@ $.Widget.prototype = {
}
if ( typeof key === "string" ) {
- if ( value === undefined ) {
- return this.options[ key ];
- }
// handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
options = {};
parts = key.split( "." );
@@ -252,8 +249,15 @@ $.Widget.prototype = {
curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
curOption = curOption[ parts[ i ] ];
}
- curOption[ parts.pop() ] = value;
+ key = parts.pop();
+ if ( value === undefined ) {
+ return curOption[ key ] === undefined ? null : curOption[ key ];
+ }
+ curOption[ key ] = value;
} else {
+ if ( value === undefined ) {
+ return this.options[ key ] === undefined ? null : this.options[ key ];
+ }
options[ key ] = value;
}
}
@@ -375,11 +379,22 @@ $.Widget.prototype = {
$.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
$.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
+ if ( typeof options === "string" ) {
+ options = { effect: options };
+ }
+ var hasOptions,
+ effectName = !options ?
+ method :
+ options === true || typeof options === "number" ?
+ defaultEffect :
+ options.effect || defaultEffect;
options = options || {};
- var hasOptions = !$.isEmptyObject( options ),
- effectName = options.effect || defaultEffect;
+ if ( typeof options === "number" ) {
+ options = { duration: options };
+ }
+ hasOptions = !$.isEmptyObject( options );
options.complete = callback;
- if (options.delay) {
+ if ( options.delay ) {
element.delay( options.delay );
}
if ( hasOptions && $.effects && ( $.effects.effect[ effectName ] || $.uiBackCompat !== false && $.effects[ effectName ] ) ) {
@@ -387,11 +402,12 @@ $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
} else if ( effectName !== method && element[ effectName ] ) {
element[ effectName ]( options.duration, options.easing, callback );
} else {
- element.queue( function() {
+ element.queue(function( next ) {
$( this )[ method ]();
if ( callback ) {
callback.call( element[ 0 ] );
}
+ next();
});
}
};