Merge branch 'master' into widget-factory-demo

This commit is contained in:
Jörn Zaefferer 2011-06-02 14:06:54 +02:00
commit afe0f72945
56 changed files with 900 additions and 639 deletions

View File

@ -59,7 +59,7 @@
<div class="demo"> <div class="demo">
<label for="search">Search: </label> <label for="search">Search: </label>
<input id="search" /> <input id="search">
</div><!-- End demo --> </div><!-- End demo -->

View File

@ -14,9 +14,16 @@
<script src="../../ui/jquery.ui.tooltip.js"></script> <script src="../../ui/jquery.ui.tooltip.js"></script>
<link rel="stylesheet" href="../demos.css"> <link rel="stylesheet" href="../demos.css">
<style> <style>
.ui-button { margin-left: -1px; } .ui-button {
.ui-button-icon-only .ui-button-text { padding: 0.35em; } margin-left: -1px;
.ui-autocomplete-input { margin: 0; padding: 0.4em 0 0.4em 0.45em; } }
.ui-button-icon-only .ui-button-text {
padding: 0.35em;
}
.ui-autocomplete-input {
margin: 0;
padding: 0.4em 0 0.4em 0.45em;
}
</style> </style>
<script> <script>
(function( $ ) { (function( $ ) {
@ -90,7 +97,7 @@
.addClass( "ui-widget ui-widget-content ui-corner-left" ); .addClass( "ui-widget ui-widget-content ui-corner-left" );
input.data( "autocomplete" )._renderItem = function( ul, item ) { input.data( "autocomplete" )._renderItem = function( ul, item ) {
return $( "<li></li>" ) return $( "<li>" )
.data( "item.autocomplete", item ) .data( "item.autocomplete", item )
.append( "<a>" + item.label + "</a>" ) .append( "<a>" + item.label + "</a>" )
.appendTo( ul ); .appendTo( ul );

View File

@ -67,7 +67,7 @@
} }
}) })
.data( "autocomplete" )._renderItem = function( ul, item ) { .data( "autocomplete" )._renderItem = function( ul, item ) {
return $( "<li></li>" ) return $( "<li>" )
.data( "item.autocomplete", item ) .data( "item.autocomplete", item )
.append( "<a>" + item.label + "<br>" + item.desc + "</a>" ) .append( "<a>" + item.label + "<br>" + item.desc + "</a>" )
.appendTo( ul ); .appendTo( ul );
@ -79,9 +79,9 @@
<div class="demo"> <div class="demo">
<div id="project-label">Select a project (type "j" for a start):</div> <div id="project-label">Select a project (type "j" for a start):</div>
<img id="project-icon" src="images/transparent_1x1.png" class="ui-state-default"/> <img id="project-icon" src="images/transparent_1x1.png" class="ui-state-default">
<input id="project"/> <input id="project">
<input type="hidden" id="project-id"/> <input type="hidden" id="project-id">
<p id="project-description"></p> <p id="project-description"></p>
</div><!-- End demo --> </div><!-- End demo -->

View File

@ -49,7 +49,7 @@
<div class="ui-widget"> <div class="ui-widget">
<label for="tags">Tags: </label> <label for="tags">Tags: </label>
<input id="tags" /> <input id="tags">
</div> </div>
</div><!-- End demo --> </div><!-- End demo -->

View File

@ -46,7 +46,7 @@
<div class="ui-widget"> <div class="ui-widget">
<form> <form>
<label for="developer">Developer: </label> <label for="developer">Developer: </label>
<input id="developer" /> <input id="developer">
</form> </form>
</div> </div>

View File

@ -65,7 +65,7 @@
<div class="ui-widget"> <div class="ui-widget">
<label for="tags">Tags: </label> <label for="tags">Tags: </label>
<input id="tags" /> <input id="tags">
</div> </div>
</div><!-- End demo --> </div><!-- End demo -->

View File

@ -12,7 +12,9 @@
<script src="../../ui/jquery.ui.autocomplete.js"></script> <script src="../../ui/jquery.ui.autocomplete.js"></script>
<link rel="stylesheet" href="../demos.css"> <link rel="stylesheet" href="../demos.css">
<style> <style>
.ui-autocomplete-loading { background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat; } .ui-autocomplete-loading {
background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat;
}
</style> </style>
<script> <script>
$(function() { $(function() {
@ -69,7 +71,7 @@
<div class="ui-widget"> <div class="ui-widget">
<label for="birds">Birds: </label> <label for="birds">Birds: </label>
<input id="birds" size="50" /> <input id="birds" size="50">
</div> </div>
</div><!-- End demo --> </div><!-- End demo -->

View File

@ -84,7 +84,7 @@
<div class="ui-widget"> <div class="ui-widget">
<label for="tags">Tag programming languages: </label> <label for="tags">Tag programming languages: </label>
<input id="tags" size="50" /> <input id="tags" size="50">
</div> </div>
</div><!-- End demo --> </div><!-- End demo -->

View File

@ -12,14 +12,16 @@
<script src="../../ui/jquery.ui.autocomplete.js"></script> <script src="../../ui/jquery.ui.autocomplete.js"></script>
<link rel="stylesheet" href="../demos.css"> <link rel="stylesheet" href="../demos.css">
<style> <style>
.ui-autocomplete-loading { background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat; } .ui-autocomplete-loading {
background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat;
}
#city { width: 25em; } #city { width: 25em; }
</style> </style>
<script> <script>
$(function() { $(function() {
function log( message ) { function log( message ) {
$( "<div/>" ).text( message ).prependTo( "#log" ); $( "<div>" ).text( message ).prependTo( "#log" );
$( "#log" ).attr( "scrollTop", 0 ); $( "#log" ).scrollTop( 0 );
} }
$( "#city" ).autocomplete({ $( "#city" ).autocomplete({
@ -65,7 +67,7 @@
<div class="ui-widget"> <div class="ui-widget">
<label for="city">Your city: </label> <label for="city">Your city: </label>
<input id="city" /> <input id="city">
Powered by <a href="http://geonames.org">geonames.org</a> Powered by <a href="http://geonames.org">geonames.org</a>
</div> </div>

View File

@ -12,7 +12,9 @@
<script src="../../ui/jquery.ui.autocomplete.js"></script> <script src="../../ui/jquery.ui.autocomplete.js"></script>
<link rel="stylesheet" href="../demos.css"> <link rel="stylesheet" href="../demos.css">
<style> <style>
.ui-autocomplete-loading { background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat; } .ui-autocomplete-loading {
background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat;
}
</style> </style>
<script> <script>
$(function() { $(function() {
@ -44,7 +46,7 @@
<div class="ui-widget"> <div class="ui-widget">
<label for="birds">Birds: </label> <label for="birds">Birds: </label>
<input id="birds" /> <input id="birds">
</div> </div>
</div><!-- End demo --> </div><!-- End demo -->

View File

@ -12,13 +12,15 @@
<script src="../../ui/jquery.ui.autocomplete.js"></script> <script src="../../ui/jquery.ui.autocomplete.js"></script>
<link rel="stylesheet" href="../demos.css"> <link rel="stylesheet" href="../demos.css">
<style> <style>
.ui-autocomplete-loading { background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat; } .ui-autocomplete-loading {
background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat;
}
</style> </style>
<script> <script>
$(function() { $(function() {
function log( message ) { function log( message ) {
$( "<div/>" ).text( message ).prependTo( "#log" ); $( "<div>" ).text( message ).prependTo( "#log" );
$( "#log" ).attr( "scrollTop", 0 ); $( "#log" ).scrollTop( 0 );
} }
$( "#birds" ).autocomplete({ $( "#birds" ).autocomplete({
@ -39,7 +41,7 @@
<div class="ui-widget"> <div class="ui-widget">
<label for="birds">Birds: </label> <label for="birds">Birds: </label>
<input id="birds" /> <input id="birds">
</div> </div>
<div class="ui-widget" style="margin-top:2em; font-family:Arial"> <div class="ui-widget" style="margin-top:2em; font-family:Arial">

View File

@ -1,4 +1,6 @@
<?php <?php
sleep( 3 );
// no term passed - just exit early with no response // no term passed - just exit early with no response
if (empty($_GET['term'])) exit ; if (empty($_GET['term'])) exit ;
$q = strtolower($_GET["term"]); $q = strtolower($_GET["term"]);

View File

@ -27,7 +27,7 @@
max: 2500, max: 2500,
step: 25, step: 25,
start: 1000, start: 1000,
numberformat: "C" numberFormat: "C"
}); });
}); });

View File

@ -18,7 +18,7 @@
$(function() { $(function() {
$("#spinner").spinner({ $("#spinner").spinner({
step: 0.01, step: 0.01,
numberformat: "n" numberFormat: "n"
}); });
$("#culture").change(function() { $("#culture").change(function() {

View File

@ -1,59 +1,64 @@
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8">
<title>jQuery UI Tooltip - Custom animation demo</title> <title>jQuery UI Tooltip - Custom animation demo</title>
<link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" /> <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script type="text/javascript" src="../../jquery-1.5.1.js"></script> <script src="../../jquery-1.5.1.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.core.js"></script> <script src="../../ui/jquery.ui.core.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script> <script src="../../ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.position.js"></script> <script src="../../ui/jquery.ui.position.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.tooltip.js"></script> <script src="../../ui/jquery.ui.tooltip.js"></script>
<link type="text/css" href="../demos.css" rel="stylesheet" /> <script src="../../ui/jquery.effects.core.js"></script>
<script type="text/javascript"> <script src="../../ui/jquery.effects.explode.js"></script>
<link rel="stylesheet" href="../demos.css">
<script>
$(function() { $(function() {
$(".demo").tooltip({ $( "#show-option" ).tooltip({
show: { show: {
effect: "slideDown", effect: "slideDown",
delay: 250 delay: 250
}, }
});
$( "#hide-option" ).tooltip({
hide: { hide: {
effect: "hide", effect: "explode",
delay: 250 delay: 250
} }
}); });
$( "#position-option" ).tooltip({
position: {
my: "left top",
at: "left bottom+10",
using: function( pos ) {
$( this ).css({
left: pos.left,
top: pos.top - 10
}).animate({ top: pos.top }, "fast" );
}
}
});
}); });
</script> </script>
<style>
label { display: inline-block; width: 5em; }
</style>
</head> </head>
<body> <body>
<div class="demo"> <div class="demo">
<p><a href="#" title="That's what this widget is">Tooltips</a> can be attached to any element. When you hover <p>There are various ways to customize the animation of a tooltip.</p>
the element with your mouse, the title attribute is displayed in a little box next to the element, just like a native tooltip. <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
</p> <a id="hide-option" href="http://jqueryui.com/demos/tooltip/#option-hide" title="explode on hide">hide</a> options.</p>
<p>But as it's not a native tooltip, it can be styled. Any themes built with <p>You can also use the <a id="position-option" href="http://jqueryui.com/demos/tooltip/#option-position" title="move down on show">position option</a>.</p>
<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>
</div><!-- End demo --> </div><!-- End demo -->
<div class="demo-description"> <div class="demo-description">
<p>This demo shows how to customize animations. The tooltip is shown, after a <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, delay of 250ms, using a slide down animation, and hidden, after another delay,
without an animation.</p> without an animation.</p>
</div><!-- End demo-description --> </div><!-- End demo-description -->
</body> </body>
</html> </html>

View File

@ -1,48 +1,47 @@
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<title>jQuery UI Tooltip - Default demo</title> <meta charset="utf-8">
<link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" /> <title>jQuery UI Tooltip - Default functionality</title>
<script type="text/javascript" src="../../jquery-1.5.1.js"></script> <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script type="text/javascript" src="../../ui/jquery.ui.core.js"></script> <script src="../../jquery-1.5.1.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script> <script src="../../ui/jquery.ui.core.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.position.js"></script> <script src="../../ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.tooltip.js"></script> <script src="../../ui/jquery.ui.position.js"></script>
<link type="text/css" href="../demos.css" rel="stylesheet" /> <script src="../../ui/jquery.ui.tooltip.js"></script>
<script type="text/javascript"> <link rel="stylesheet" href="../demos.css">
<script>
$(function() { $(function() {
$(".demo").tooltip(); $( ".demo" ).tooltip();
}); });
</script> </script>
<style> <style>
label { display: inline-block; width: 5em; } label {
display: inline-block;
width: 5em;
}
</style> </style>
</head> </head>
<body> <body>
<div class="demo"> <div class="demo">
<p><a href="#" title="That's what this widget is">Tooltips</a> can be attached to any element. When you hover <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. 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> <p>But as it's not a native tooltip, it can be styled. Any themes built with
<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>
<a href="http://themeroller.com" title="ThemeRoller, jQuery UI's theme builder application">ThemeRoller</a> will also style tooltips accordingly.</p>
will also style tooltip's accordingly.</p> <p>Tooltips are also useful for form elements, to show some additional information in the context of each field.</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><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>
<p>Click the field to see the tooltip; when you tab out of the field, it gets hidden.</p>
</div><!-- End demo --> </div><!-- End demo -->
<div class="demo-description"> <div class="demo-description">
<p>Hover the links above or use the tab key to cycle the focus on each element.</p> <p>Hover the links above or use the tab key to cycle the focus on each element.</p>
</div><!-- End demo-description --> </div><!-- End demo-description -->
</body> </body>
</html> </html>

View File

@ -1,73 +1,88 @@
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8">
<title>jQuery UI Tooltip - Default demo</title> <title>jQuery UI Tooltip - Default demo</title>
<link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" /> <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script type="text/javascript" src="../../jquery-1.5.1.js"></script> <script src="../../jquery-1.5.1.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.core.js"></script> <script src="../../ui/jquery.ui.core.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script> <script src="../../ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.position.js"></script> <script src="../../ui/jquery.ui.position.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.tooltip.js"></script> <script src="../../ui/jquery.ui.tooltip.js"></script>
<link type="text/css" href="../demos.css" rel="stylesheet" /> <link rel="stylesheet" href="../demos.css">
<script type="text/javascript"> <style>
$(function() { .photo {
$(".demo").tooltip({ width: 300px;
items: "[href], [title]", text-align: center;
content: function(response) { }
var href = $(this).attr("href"); .photo .ui-widget-header {
if (/^#/.test(href)) { margin: 1em 0;
return $(href).html(); }
} else if (href) { </style>
$.get(href, response); <script>
return "loading..."; $(function() {
$( ".demo" ).tooltip({
items: "img, [data-geo], [title]",
content: function() {
var element = $( this );
if ( element.is( "[data-geo]" ) ) {
return $( "<iframe>", {
width: 425,
height: 350,
frameborder: 0,
scrolling: "no",
marginheight: 0,
marginwidth: 0,
src: "http://maps.google.com/maps?ll=" + element.attr( "data-geo" ) +
"&z=11&t=p&output=embed"
});
}
if ( element.is( "[title]" ) ) {
return element.attr( "title" );
}
if ( element.is( "img" ) ) {
return element.attr( "alt" );
} }
return this.title;
} }
}); });
$("#footnotes").hide();
}); });
</script> </script>
<style>
label { display: inline-block; width: 5em; }
</style>
</head> </head>
<body> <body>
<div class="demo"> <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> <div class="ui-widget photo">
<li> <div class="ui-widget-header ui-corner-all">
<a href="ajax/content1.html">Link to ajax content, with tooltip preview!</a> <h2>St. Stephen's Cathedral</h2>
</li> <h3><a href="http://maps.google.com/maps?q=vienna,+austria&z=11" data-geo="48.208174,16.373819">Vienna, Austria</a></h3>
<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>
<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="51.500152,-0.126236">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><!-- End demo -->
<div class="demo-description"> <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>Show 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 --> </div><!-- End demo-description -->
</body> </body>
</html> </html>

View File

@ -1,71 +1,87 @@
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8">
<title>jQuery UI Tooltip - Default demo</title> <title>jQuery UI Tooltip - Default demo</title>
<link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" /> <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script type="text/javascript" src="../../jquery-1.5.1.js"></script> <script src="../../jquery-1.5.1.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.core.js"></script> <script src="../../ui/jquery.ui.core.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script> <script src="../../ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.position.js"></script> <script src="../../ui/jquery.ui.position.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.tooltip.js"></script> <script src="../../ui/jquery.ui.tooltip.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.button.js"></script> <script src="../../ui/jquery.ui.button.js"></script>
<link type="text/css" href="../demos.css" rel="stylesheet" /> <link rel="stylesheet" href="../demos.css">
<script type="text/javascript">
$(function() {
$("[title]").tooltip().unbind(".tooltip");
$("<button/>").text("Show help").button().toggle(function() {
$(":ui-tooltip").tooltip("open");
}, function() {
$(":ui-tooltip").tooltip("close");
}).appendTo("form");
});
</script>
<style> <style>
label { display: inline-block; width: 5em; } label {
.ui-icon { display: inline-block; } display: inline-block; width: 5em;
}
fieldset div { fieldset div {
margin-bottom: 2em; margin-bottom: 2em;
} }
.ui-tooltip { width: 210px; } fieldset .help {
display: inline-block;
}
.ui-tooltip {
width: 210px;
}
</style> </style>
<script>
$(function() {
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>
</head> </head>
<body> <body>
<div class="demo"> <div class="demo">
<form> <form>
<fieldset> <fieldset>
<div> <div>
<label for="firstname">Firstname</label> <label for="firstname">Firstname</label>
<input id="firstname" name="firstname" /> <input id="firstname" name="firstname">
<span title="Please provide your firstname." class="ui-state-default ui-corner-all ui-icon ui-icon-help">?</span> <span title="Please provide your firstname." class="help ui-state-default ui-corner-all ui-icon ui-icon-help">?</span>
</div> </div>
<div> <div>
<label for="lastname">Lastname</label> <label for="lastname">Lastname</label>
<input id="lastname" name="lastname" /> <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> <span title="Please provide also your lastname." class="help ui-state-default ui-corner-all ui-icon ui-icon-help">?</span>
</div> </div>
<div> <div>
<label for="address">Address</label> <label for="address">Address</label>
<input id="address" name="address" /> <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> <span title="Your home or work address." class="help ui-state-default ui-corner-all ui-icon ui-icon-help">?</span>
</div> </div>
</fieldset> </fieldset>
</form> </form>
</div><!-- End demo --> </div><!-- End demo -->
<div class="demo-description"> <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>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> <p>A fixed width is defined in CSS to make the tooltips look consistent when displayed all at once.</p>
</div><!-- End demo-description --> </div><!-- End demo-description -->
</body> </body>
</html> </html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -1,8 +1,9 @@
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8">
<title>jQuery UI Tooltip Demos</title> <title>jQuery UI Tooltip Demos</title>
<link type="text/css" href="../demos.css" rel="stylesheet" /> <link rel="stylesheet" href="../demos.css">
</head> </head>
<body> <body>

View File

@ -1,64 +1,64 @@
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<title>jQuery UI Tooltip - Default demo</title> <meta charset="utf-8">
<link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" /> <title>jQuery UI Tooltip - Track the mouse</title>
<script type="text/javascript" src="../../jquery-1.5.1.js"></script> <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script type="text/javascript" src="../../ui/jquery.ui.core.js"></script> <script src="../../jquery-1.5.1.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script> <script src="../../ui/jquery.ui.core.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.position.js"></script> <script src="../../ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.tooltip.js"></script> <script src="../../ui/jquery.ui.position.js"></script>
<link type="text/css" href="../demos.css" rel="stylesheet" /> <script src="../../ui/jquery.ui.tooltip.js"></script>
<script type="text/javascript"> <link rel="stylesheet" href="../demos.css">
<style>
label {
display: inline-block;
width: 5em;
}
</style>
<script>
$(function() { $(function() {
$(".demo").tooltip({ $( ".demo" ).tooltip({
open: function() { open: function( event ) {
var tooltip = $( ".ui-tooltip" ); var tooltip = $( ".ui-tooltip" );
$(document).mousemove(function( event ) { function position( event ) {
tooltip.position( { tooltip.position({
my: "left+25 center", my: "left+25 center",
at: "right+25 center", at: "right+25 center",
of: event of: event
}); });
}) }
$( document ).bind( "mousemove.tooltip-position", position );
// trigger once to override element-relative positioning // trigger once to override element-relative positioning
.mousemove(); position( event );
}, },
close: function() { close: function() {
$(document).unbind( "mousemove" ); $( document ).unbind( "mousemove.tooltip-position" );
} }
}); });
}); });
</script> </script>
<style>
label { display: inline-block; width: 5em; }
</style>
</head> </head>
<body> <body>
<div class="demo"> <div class="demo">
<p><a href="#" title="That's what this widget is">Tooltips</a> can be attached to any element. When you hover <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. 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> <p>But as it's not a native tooltip, it can be styled. Any themes built with
<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>
<a href="http://themeroller.com" title="ThemeRoller, jQuery UI's theme builder application">ThemeRoller</a> will also style tooltips accordingly.</p>
will also style tooltip's accordingly.</p> <p>Tooltips are also useful for form elements, to show some additional information in the context of each field.</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><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>
<p>Click the field to see the tooltip; when you tab out of the field, it gets hidden.</p>
</div><!-- End demo --> </div><!-- End demo -->
<div class="demo-description"> <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> <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 --> </div><!-- End demo-description -->
</body> </body>
</html> </html>

View File

@ -1,64 +1,105 @@
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8">
<title>jQuery UI Tooltip - Video Player demo</title> <title>jQuery UI Tooltip - Video Player demo</title>
<link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" /> <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script type="text/javascript" src="../../jquery-1.5.1.js"></script> <script src="../../jquery-1.5.1.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.core.js"></script> <script src="../../ui/jquery.ui.core.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script> <script src="../../ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.position.js"></script> <script src="../../ui/jquery.ui.position.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.tooltip.js"></script> <script src="../../ui/jquery.ui.tooltip.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.button.js"></script> <script src="../../ui/jquery.ui.button.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.menu.js"></script> <script src="../../ui/jquery.ui.menu.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.popup.js"></script> <script src="../../ui/jquery.ui.popup.js"></script>
<script type="text/javascript" src="../../ui/jquery.effects.core.js"></script> <script src="../../ui/jquery.effects.core.js"></script>
<script type="text/javascript" src="../../ui/jquery.effects.blind.js"></script> <script src="../../ui/jquery.effects.blind.js"></script>
<link type="text/css" href="../demos.css" rel="stylesheet" /> <link rel="stylesheet" href="../demos.css">
<script type="text/javascript"> <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() {
function notify( input ) { function notify( input ) {
var msg = "Selected " + $.trim($(input).text()); 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({ $( "<div>" )
.appendTo( document.body )
.text( msg )
.addClass( "notification ui-state-default ui-corner-bottom" )
.position({
my: "center top", my: "center top",
at: "center top", at: "center top",
of: window of: window
}).show({ })
.show({
effect: "blind" effect: "blind"
}).delay(1000).hide({ })
.delay( 1000 )
.hide({
effect: "blind", effect: "blind",
duration: "slow" duration: "slow"
}, function() { }, function() {
$(this).remove(); $( this ).remove();
}); });
} }
$("ul").menu({ $( "ul" ).menu({
select: function(event, ui) { select: function( event, ui ) {
// TODO stop button from handling the click // TODO should probably be handled by popup, see ESCAPE key handler
$(this).popup("close");
// TODO should probably be handled by poup, see ESCAPE key handler
// affects key handling // affects key handling
$(this).prev().focus(); $( this ).prev().focus();
notify(ui.item); notify( ui.item );
} }
}).popup(); }).popup();
$("button").each(function() { $( "button" ).each(function() {
$(this).button({ var button = $( this ).button({
icons: { icons: {
primary: $(this).data("icon") primary: $( this ).data( "icon" )
}, },
text: !!$(this).attr("title") text: !!$( this ).attr( "title" )
}).click(function() {
// TODO don't notify if the button is opening a popup
notify(this);
}); });
if ( button.next().is( ":ui-popup" ) ) {
button.click(function( event ) {
$( ".demo" ).tooltip( "close", event );
}); });
$(".set").buttonset({ } else {
button.click(function() {
notify( button );
});
}
});
$( ".set" ).buttonset({
items: "button" items: "button"
}); });
$( ".demo" ).tooltip({
$(".demo").tooltip({
position: { position: {
my: "center top", my: "center top",
at: "center bottom+5", at: "center bottom+5",
@ -72,28 +113,13 @@
}); });
}); });
</script> </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> </head>
<body> <body>
<div class="demo"> <div class="demo">
<div class="player">Here Be Video (HTML5?)</div> <div class="player">Here Be Video (HTML5?)</div>
<div class="tools"> <div class="tools">
<span class="set"> <span class="set">
<button data-icon="ui-icon-circle-arrow-n" title="I like this">Like</button> <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> <button data-icon="ui-icon-circle-arrow-s">I dislike this</button>
@ -115,20 +141,15 @@
</div> </div>
<button title="Share this video">Share</button> <button title="Share this video">Share</button>
<button data-icon="ui-icon-alert">Flag as inappropiate</button> <button data-icon="ui-icon-alert">Flag as inappropiate</button>
</div> </div>
</div>
</div><!-- End demo --> </div><!-- End demo -->
<div class="demo-description"> <div class="demo-description">
<p>A fake video player with like/share/stats button, each with a custom-styled tooltip.</p> <p>A fake video player with like/share/stats button, each with a custom-styled tooltip.</p>
</div><!-- End demo-description --> </div><!-- End demo-description -->
</body> </body>
</html> </html>

View File

@ -123,10 +123,10 @@ $.extend($.simulate.prototype, {
this.simulateEvent(target, "click", coord); this.simulateEvent(target, "click", coord);
}, },
findCenter: function(el) { findCenter: function(el) {
var el = $(this.target), o = el.offset(); var el = $(this.target), o = el.offset(), d = $(document);
return { return {
x: o.left + el.outerWidth() / 2, x: o.left + el.outerWidth() / 2 - d.scrollLeft(),
y: o.top + el.outerHeight() / 2 y: o.top + el.outerHeight() / 2 - d.scrollTop()
}; };
} }
}); });

View File

@ -20,6 +20,14 @@ test( "#6262 - buttonset not applying ui-corner to invisible elements", function
ok( set.find( "label:eq(2)" ).is( ".ui-button.ui-corner-right" ) ); ok( set.find( "label:eq(2)" ).is( ".ui-button.ui-corner-right" ) );
}); });
test( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard Navigation", function() {
var check = $( "#check" ).button(),
label = $( "label[for='check']" );
ok( !label.is( ".ui-state-focus" ) );
check.focus();
ok( label.is( ".ui-state-focus" ) );
});
test( "#7092 - button creation that requires a matching label does not find label in all cases", function() { test( "#7092 - button creation that requires a matching label does not find label in all cases", function() {
var group = $( "<span><label for='t7092a'/><input type='checkbox' id='t7092a'/></span>" ); var group = $( "<span><label for='t7092a'/><input type='checkbox' id='t7092a'/></span>" );
group.find( "input:checkbox" ).button(); group.find( "input:checkbox" ).button();

View File

@ -4,7 +4,7 @@ commonWidgetTests( "spinner", {
incremental: true, incremental: true,
max: null, max: null,
min: null, min: null,
numberformat: null, numberFormat: null,
page: 10, page: 10,
step: null, step: null,
value: null, value: null,

View File

@ -5,26 +5,26 @@
module("spinner: options"); module("spinner: options");
test("numberformat, number", function() { test("numberFormat, number", function() {
var el = $("#spin").spinner({ var el = $("#spin").spinner({
value: "1", value: "1",
numberformat: "n" numberFormat: "n"
}); });
equal(el.val(), "1.00"); equal(el.val(), "1.00");
}); });
test("numberformat, number, simple", function() { test("numberFormat, number, simple", function() {
var el = $("#spin").spinner({ var el = $("#spin").spinner({
value: "1", value: "1",
numberformat: "n0" numberFormat: "n0"
}); });
equal(el.val(), "1"); equal(el.val(), "1");
}); });
test("numberformat, currency", function() { test("numberFormat, currency", function() {
var el = $("#spin").spinner({ var el = $("#spin").spinner({
value: "1", value: "1",
numberformat: "C" numberFormat: "C"
}); });
equal(el.val(), "$1.00"); equal(el.val(), "$1.00");
}); });
@ -111,7 +111,7 @@ test("step, 2", function() {
test("step, 0.7", function() { test("step, 0.7", function() {
var el = $("#spin").spinner({ var el = $("#spin").spinner({
step: 0.7, step: 0.7,
numberformat: "n1" numberFormat: "n1"
}); });
equals(el.val(), "0.0", "value initialized to"); equals(el.val(), "0.0", "value initialized to");

View File

@ -61,7 +61,7 @@ window.commonWidgetTests = function( widget, settings ) {
testWidgetOverrides( widget ); testWidgetOverrides( widget );
testBasicUsage( widget ); testBasicUsage( widget );
test( "version", function() { test( "version", function() {
ok( "version" in $.ui[ widget ], "version property exists" ); ok( "version" in $.ui[ widget ].prototype, "version property exists" );
}); });
} }

View File

@ -1,30 +1,29 @@
<!DOCTYPE html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="utf-8">
<title>jQuery UI Tooltip Test Suite</title> <title>jQuery UI Tooltip Test Suite</title>
<link type="text/css" href="../../../themes/base/jquery.ui.tooltip.css" rel="stylesheet" /> <link rel="stylesheet" href="../../../themes/base/jquery.ui.tooltip.css">
<script type="text/javascript" src="../../../jquery-1.5.1.js"></script> <script src="../../../jquery-1.5.1.js"></script>
<script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> <script src="../../../ui/jquery.ui.core.js"></script>
<script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> <script src="../../../ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="../../../ui/jquery.ui.position.js"></script> <script src="../../../ui/jquery.ui.position.js"></script>
<script type="text/javascript" src="../../../ui/jquery.ui.tooltip.js"></script> <script src="../../../ui/jquery.ui.tooltip.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/> <link rel="stylesheet" href="../../../external/qunit.css">
<script type="text/javascript" src="../../../external/qunit.js"></script> <script src="../../../external/qunit.js"></script>
<script type="text/javascript" src="../../jquery.simulate.js"></script> <script src="../../jquery.simulate.js"></script>
<script type="text/javascript" src="../testsuite.js"></script> <script src="../testsuite.js"></script>
<script type="text/javascript" src="tooltip_core.js"></script> <script src="tooltip_defaults.js"></script>
<script type="text/javascript" src="tooltip_defaults.js"></script> <script src="tooltip_core.js"></script>
<script type="text/javascript" src="tooltip_events.js"></script> <script src="tooltip_events.js"></script>
<script type="text/javascript" src="tooltip_methods.js"></script> <script src="tooltip_methods.js"></script>
<script type="text/javascript" src="tooltip_options.js"></script> <script src="tooltip_options.js"></script>
<script type="text/javascript" src="../swarminject.js"></script>
<script src="../swarminject.js"></script>
</head> </head>
<body> <body>
@ -32,16 +31,15 @@
<h2 id="qunit-banner"></h2> <h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div> <div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2> <h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"> <ol id="qunit-tests"></ol>
</ol>
<div id="qunit-fixture"> <div id="qunit-fixture">
<div>
<div>
<a id="tooltipped1" href="#" title="anchortitle">anchor</a> <a id="tooltipped1" href="#" title="anchortitle">anchor</a>
<input title="inputtitle" /> <input title="inputtitle">
<span id="fixture-span" data-tooltip="text">span</span> <span id="fixture-span" title="title-text">span</span>
</div>
</div> </div>
</div>
</body> </body>
</html> </html>

View File

@ -1,11 +1,26 @@
/* (function( $ ) {
* tooltip_core.js
*/
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 ) );

View File

@ -1,11 +1,12 @@
commonWidgetTests( "tooltip", { commonWidgetTests( "tooltip", {
defaults: { defaults: {
content: function() {},
disabled: false, disabled: false,
items: "[title]", items: "[title]",
content: $.ui.tooltip.prototype.options.content,
position: { position: {
my: "left+15 center", my: "left+15 center",
at: "right center" at: "right center",
collision: "flip fit"
}, },
tooltipClass: null, tooltipClass: null,

View File

@ -1,54 +1,76 @@
/* (function( $ ) {
* tooltip_events.js
*/
(function($) {
module("tooltip: events"); module( "tooltip: events" );
test("programmatic triggers", function() { test( "programmatic triggers", function() {
expect(2); expect( 2 );
var e = $("#tooltipped1").tooltip({ var element = $( "#tooltipped1" ).tooltip();
open: function(event, ui) {
same( event.type, "tooltipopen" ); element.one( "tooltipopen", function( event ) {
}, ok( !( "originalEvent" in event ), "open" );
close: function(event, ui) {
same( event.type, "tooltipclose" );
}
}); });
e.tooltip("open").tooltip("close"); element.tooltip( "open" );
e.tooltip("destroy");
element.one( "tooltipclose", function( event ) {
ok( !( "originalEvent" in event ), "close" );
});
element.tooltip( "close" );
}); });
test("mouse events", function() { test( "mouse events", function() {
expect(4); expect( 2 );
var e = $("#tooltipped1").tooltip({ var element = $( "#tooltipped1" ).tooltip();
open: function(event, ui) {
same( event.type, "tooltipopen" ); element.one( "tooltipopen", function( event ) {
same( event.originalEvent.type, "mouseover" ); same( event.originalEvent.type, "mouseover" );
}, });
close: function(event, ui) { element.trigger( "mouseover" );
same( event.type, "tooltipclose" );
element.one( "tooltipclose", function( event ) {
same( event.originalEvent.type, "mouseleave" ); same( event.originalEvent.type, "mouseleave" );
}
}); });
e.trigger("mouseover").trigger("mouseleave"); element.trigger( "mouseleave" );
e.tooltip("destroy");
}); });
test("focus events", function() { test( "focus events", function() {
expect(4); expect( 2 );
var e = $("#tooltipped1").tooltip({ var element = $( "#tooltipped1" ).tooltip();
open: function(event, ui) {
same( event.type, "tooltipopen" ); element.one( "tooltipopen", function( event ) {
same( event.originalEvent.type, "focusin" ); same( event.originalEvent.type, "focusin" );
},
close: function(event, ui) {
same( event.type, "tooltipclose" );
same( event.originalEvent.type, "blur" );
}
}); });
e.trigger("focus").trigger("blur"); element.trigger( "focusin" );
e.tooltip("destroy");
element.one( "tooltipclose", function( event ) {
same( event.originalEvent.type, "blur" );
});
element.trigger( "blur" );
}); });
})(jQuery); 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 ) );

View File

@ -1,22 +1,57 @@
/* (function( $ ) {
* tooltip_methods.js
*/
(function($) {
module( "tooltip: methods" );
module("tooltip: methods"); test( "destroy", function() {
expect( 2 );
domEqual( "#tooltipped1", function() {
$( "#tooltipped1" ).tooltip().tooltip( "destroy" );
});
test("destroy", function() { // make sure that open tooltips are removed on destroy
var beforeHtml = $("#tooltipped1").parent().html(); $( "#tooltipped1" ).tooltip().tooltip( "open" ).tooltip( "destroy" );
var afterHtml = $("#tooltipped1").tooltip().tooltip("destroy").parent().html(); equal( $( ".ui-tooltip" ).length, 0 );
equal( afterHtml, beforeHtml );
}); });
test("open", function() { test( "open/close", function() {
var e = $("#tooltipped1").tooltip(); expect( 3 );
e.tooltip("open"); $.fx.off = true;
ok( $(".ui-tooltip").is(":visible") ); var element = $( "#tooltipped1" ).tooltip();
$(":ui-tooltip").tooltip("destroy"); 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);

View File

@ -1,66 +1,73 @@
/* (function( $ ) {
* tooltip_options.js
*/
(function($) {
module("tooltip: options", { module( "tooltip: options" );
teardown: function() {
$(":ui-tooltip").tooltip("destroy"); test( "content: default", function() {
} var element = $( "#tooltipped1" ).tooltip().tooltip( "open" );
same( $( "#" + element.attr( "aria-describedby" ) ).text(), "anchortitle" );
}); });
test( "content: return string", function() {
test("option: items", function() { var element = $( "#tooltipped1" ).tooltip({
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() {
$("#tooltipped1").tooltip().tooltip("open");
same( $( "#" + $("#tooltipped1").attr("aria-describedby") ).text(), "anchortitle" );
});
test("content: return string", function() {
$("#tooltipped1").tooltip({
content: function() { content: function() {
return "customstring"; return "customstring";
} }
}).tooltip("open"); }).tooltip( "open" );
same( $( "#" + $("#tooltipped1").attr("aria-describedby") ).text(), "customstring" ); same( $( "#" + element.attr( "aria-describedby" ) ).text(), "customstring" );
}); });
test("content: return jQuery", function() { test( "content: return jQuery", function() {
$("#tooltipped1").tooltip({ var element = $( "#tooltipped1" ).tooltip({
content: function() { content: function() {
return $("<div></div>").html("cu<b>s</b>tomstring"); return $( "<div>" ).html( "cu<b>s</b>tomstring" );
} }
}).tooltip("open"); }).tooltip( "open" );
same( $( "#" + $("#tooltipped1").attr("aria-describedby") ).text(), "customstring" ); same( $( "#" + element.attr( "aria-describedby" ) ).text(), "customstring" );
}); });
/* asyncTest( "content: sync + async callback", function() {
TODO broken, probably related to async content expect( 2 );
test("content: callback string", function() { var element = $( "#tooltipped1" ).tooltip({
stop(); content: function( response ) {
$("#tooltipped1").tooltip({
content: function(response) {
response("customstring2");
setTimeout(function() { setTimeout(function() {
//console.log($("#tooltipped1").attr("aria-describedby")) same( $( "#" + element.attr("aria-describedby") ).text(), "loading..." );
same( $( "#" + $("#tooltipped1").attr("aria-describedby") ).text(), "customstring2" );
response( "customstring2" );
setTimeout(function() {
same( $( "#" + element.attr("aria-describedby") ).text(), "customstring2" );
start(); start();
}, 100) }, 13 );
}, 13 );
return "loading...";
} }
}).tooltip("open"); }).tooltip( "open" );
}); });
*/
})(jQuery); 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 ) );

View File

@ -31,7 +31,12 @@ $.effects.effect.blind = function( o ) {
animation = {}, animation = {},
wrapper, distance; wrapper, distance;
// if already wrapped, the wrapper's properties are my property. #6245
if ( el.parent().is( ".ui-effects-wrapper" ) ) {
$.effects.save( el.parent(), props );
} else {
$.effects.save( el, props ); $.effects.save( el, props );
}
el.show(); el.show();
wrapper = $.effects.createWrapper( el ).css({ wrapper = $.effects.createWrapper( el ).css({
overflow: "hidden" overflow: "hidden"

View File

@ -54,7 +54,9 @@ $.effects.effect.scale = function( o ) {
origin = o.origin, origin = o.origin,
original = { original = {
height: el.height(), height: el.height(),
width: el.width() width: el.width(),
outerHeight: el.outerHeight(),
outerWidth: el.outerWidth()
}, },
factor = { factor = {
y: direction != 'horizontal' ? (percent / 100) : 1, y: direction != 'horizontal' ? (percent / 100) : 1,
@ -74,7 +76,9 @@ $.effects.effect.scale = function( o ) {
options.from = o.from || ( mode == 'show' ? { height: 0, width: 0 } : original ); options.from = o.from || ( mode == 'show' ? { height: 0, width: 0 } : original );
options.to = { options.to = {
height: original.height * factor.y, height: original.height * factor.y,
width: original.width * factor.x width: original.width * factor.x,
outerHeight: original.outerHeight * factor.y,
outerWidth: original.outerWidth * factor.x
}; };
if ( options.fade ) { // Fade option to support puff if ( options.fade ) { // Fade option to support puff
@ -122,21 +126,14 @@ $.effects.effect.size = function( o ) {
} }
original = { original = {
height: el.height(), height: el.height(),
width: el.width() width: el.width(),
outerHeight: el.outerHeight(),
outerWidth: el.outerWidth()
}; };
el.from = o.from || original; el.from = o.from || original;
el.to = o.to || original; el.to = o.to || original;
// Adjust
if (origin) { // Calculate baseline shifts
baseline = $.effects.getBaseline( origin, original );
el.from.top = ( original.height - el.from.height ) * baseline.y;
el.from.left = ( original.width - el.from.width ) * baseline.x;
el.to.top = ( original.height - el.to.height ) * baseline.y;
el.to.left = ( original.width - el.to.width ) * baseline.x;
}
// Set scaling factor // Set scaling factor
factor = { factor = {
from: { from: {
@ -183,6 +180,16 @@ $.effects.effect.size = function( o ) {
$.effects.createWrapper( el ); $.effects.createWrapper( el );
el.css( 'overflow', 'hidden' ).css( el.from ); el.css( 'overflow', 'hidden' ).css( el.from );
// Adjust
if (origin) { // Calculate baseline shifts
baseline = $.effects.getBaseline( origin, original );
el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y;
el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x;
el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y;
el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x;
}
el.css( el.from ); // set top & left
// Animate // Animate
if ( scale == 'content' || scale == 'both' ) { // Scale the children if ( scale == 'content' || scale == 'both' ) { // Scale the children

View File

@ -15,6 +15,7 @@
// TODO: use ui-accordion-header-active class and fix styling // TODO: use ui-accordion-header-active class and fix styling
$.widget( "ui.accordion", { $.widget( "ui.accordion", {
version: "@VERSION",
options: { options: {
active: 0, active: 0,
animated: "slide", animated: "slide",
@ -432,7 +433,6 @@ $.widget( "ui.accordion", {
}); });
$.extend( $.ui.accordion, { $.extend( $.ui.accordion, {
version: "@VERSION",
animations: { animations: {
slide: function( options, additions ) { slide: function( options, additions ) {
var showOverflow = options.toShow.css( "overflow" ), var showOverflow = options.toShow.css( "overflow" ),

View File

@ -19,6 +19,7 @@
var requestIndex = 0; var requestIndex = 0;
$.widget( "ui.autocomplete", { $.widget( "ui.autocomplete", {
version: "@VERSION",
defaultElement: "<input>", defaultElement: "<input>",
options: { options: {
appendTo: "body", appendTo: "body",
@ -475,7 +476,6 @@ $.widget( "ui.autocomplete", {
}); });
$.extend( $.ui.autocomplete, { $.extend( $.ui.autocomplete, {
version: "@VERSION",
escapeRegex: function( value ) { escapeRegex: function( value ) {
return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
}, },

View File

@ -41,6 +41,7 @@ var lastActive, startXPos, startYPos, clickDragged,
}; };
$.widget( "ui.button", { $.widget( "ui.button", {
version: "@VERSION",
defaultElement: "<button>", defaultElement: "<button>",
options: { options: {
disabled: null, disabled: null,
@ -95,19 +96,22 @@ $.widget( "ui.button", {
} }
$( this ).removeClass( hoverClass ); $( this ).removeClass( hoverClass );
}) })
.bind( "focus.button", function() {
// no need to check disabled, focus won't be triggered anyway
$( this ).addClass( focusClass );
})
.bind( "blur.button", function() {
$( this ).removeClass( focusClass );
})
.bind( "click.button", function( event ) { .bind( "click.button", function( event ) {
if ( options.disabled ) { if ( options.disabled ) {
event.preventDefault();
event.stopImmediatePropagation(); event.stopImmediatePropagation();
} }
}); });
this.element
.bind( "focus.button", function() {
// no need to check disabled, focus won't be triggered anyway
self.buttonElement.addClass( focusClass );
})
.bind( "blur.button", function() {
self.buttonElement.removeClass( focusClass );
});
if ( toggleButton ) { if ( toggleButton ) {
this.element.bind( "change.button", function() { this.element.bind( "change.button", function() {
if ( clickDragged ) { if ( clickDragged ) {
@ -409,6 +413,4 @@ $.widget( "ui.buttonset", {
} }
}); });
$.ui.buttonset.version = "@VERSION";
}( jQuery ) ); }( jQuery ) );

View File

@ -36,6 +36,7 @@ var uiDialogClasses = "ui-dialog ui-widget ui-widget-content ui-corner-all ",
}; };
$.widget("ui.dialog", { $.widget("ui.dialog", {
version: "@VERSION",
options: { options: {
autoOpen: true, autoOpen: true,
buttons: {}, buttons: {},
@ -190,6 +191,10 @@ $.widget("ui.dialog", {
}, },
close: function( event ) { close: function( event ) {
if ( !this._isOpen ) {
return self;
}
var self = this, var self = this,
maxZ, thisZ; maxZ, thisZ;
@ -197,13 +202,13 @@ $.widget("ui.dialog", {
return; return;
} }
self._isOpen = false;
if ( self.overlay ) { if ( self.overlay ) {
self.overlay.destroy(); self.overlay.destroy();
} }
self.uiDialog.unbind( "keypress.ui-dialog" ); self.uiDialog.unbind( "keypress.ui-dialog" );
self._isOpen = false;
if ( self.options.hide ) { if ( self.options.hide ) {
self.uiDialog.hide( self.options.hide, function() { self.uiDialog.hide( self.options.hide, function() {
self._trigger( "close", event ); self._trigger( "close", event );
@ -369,8 +374,7 @@ $.widget("ui.dialog", {
_makeDraggable: function() { _makeDraggable: function() {
var self = this, var self = this,
options = self.options, options = self.options,
doc = $( document ), doc = $( document );
heightBeforeDrag;
function filteredUi( ui ) { function filteredUi( ui ) {
return { return {
@ -384,9 +388,7 @@ $.widget("ui.dialog", {
handle: ".ui-dialog-titlebar", handle: ".ui-dialog-titlebar",
containment: "document", containment: "document",
start: function( event, ui ) { start: function( event, ui ) {
heightBeforeDrag = options.height === "auto" ? "auto" : $( this ).height();
$( this ) $( this )
.height( $( this ).height() )
.addClass( "ui-dialog-dragging" ); .addClass( "ui-dialog-dragging" );
self._trigger( "dragStart", event, filteredUi( ui ) ); self._trigger( "dragStart", event, filteredUi( ui ) );
}, },
@ -399,8 +401,7 @@ $.widget("ui.dialog", {
ui.position.top - doc.scrollTop() ui.position.top - doc.scrollTop()
]; ];
$( this ) $( this )
.removeClass( "ui-dialog-dragging" ) .removeClass( "ui-dialog-dragging" );
.height( heightBeforeDrag );
self._trigger( "dragStop", event, filteredUi( ui ) ); self._trigger( "dragStop", event, filteredUi( ui ) );
$.ui.dialog.overlay.resize(); $.ui.dialog.overlay.resize();
} }
@ -655,8 +656,6 @@ $.widget("ui.dialog", {
}); });
$.extend($.ui.dialog, { $.extend($.ui.dialog, {
version: "@VERSION",
uuid: 0, uuid: 0,
maxZ: 0, maxZ: 0,

View File

@ -15,6 +15,7 @@
(function( $, undefined ) { (function( $, undefined ) {
$.widget("ui.draggable", $.ui.mouse, { $.widget("ui.draggable", $.ui.mouse, {
version: "@VERSION",
widgetEventPrefix: "drag", widgetEventPrefix: "drag",
options: { options: {
addClasses: true, addClasses: true,
@ -163,6 +164,10 @@ $.widget("ui.draggable", $.ui.mouse, {
this.helper.addClass("ui-draggable-dragging"); this.helper.addClass("ui-draggable-dragging");
this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
//If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
if ( $.ui.ddmanager ) $.ui.ddmanager.dragStart(this, event);
return true; return true;
}, },
@ -229,6 +234,9 @@ $.widget("ui.draggable", $.ui.mouse, {
}); //Remove frame helpers }); //Remove frame helpers
} }
//If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
if( $.ui.ddmanager ) $.ui.ddmanager.dragStop(this, event);
return $.ui.mouse.prototype._mouseUp.call(this, event); return $.ui.mouse.prototype._mouseUp.call(this, event);
}, },
@ -495,10 +503,6 @@ $.widget("ui.draggable", $.ui.mouse, {
}); });
$.extend($.ui.draggable, {
version: "@VERSION"
});
$.ui.plugin.add("draggable", "connectToSortable", { $.ui.plugin.add("draggable", "connectToSortable", {
start: function(event, ui) { start: function(event, ui) {

View File

@ -16,6 +16,7 @@
(function( $, undefined ) { (function( $, undefined ) {
$.widget("ui.droppable", { $.widget("ui.droppable", {
version: "@VERSION",
widgetEventPrefix: "drop", widgetEventPrefix: "drop",
options: { options: {
accept: '*', accept: '*',
@ -146,10 +147,6 @@ $.widget("ui.droppable", {
}); });
$.extend($.ui.droppable, {
version: "@VERSION"
});
$.ui.intersect = function(draggable, droppable, toleranceMode) { $.ui.intersect = function(draggable, droppable, toleranceMode) {
if (!droppable.offset) return false; if (!droppable.offset) return false;
@ -238,6 +235,12 @@ $.ui.ddmanager = {
return dropped; return dropped;
}, },
dragStart: function( draggable, event ) {
//Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
if( !draggable.options.refreshPositions ) $.ui.ddmanager.prepareOffsets( draggable, event );
});
},
drag: function(draggable, event) { drag: function(draggable, event) {
//If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse. //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
@ -279,6 +282,11 @@ $.ui.ddmanager = {
} }
}); });
},
dragStop: function( draggable, event ) {
draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
//Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
if( !draggable.options.refreshPositions ) $.ui.ddmanager.prepareOffsets( draggable, event );
} }
}; };

View File

@ -16,6 +16,7 @@
var idIncrement = 0; var idIncrement = 0;
$.widget("ui.menu", { $.widget("ui.menu", {
version: "@VERSION",
defaultElement: "<ul>", defaultElement: "<ul>",
delay: 150, delay: 150,
options: { options: {
@ -420,6 +421,4 @@ $.widget("ui.menu", {
} }
}); });
$.ui.menu.version = "@VERSION";
}( jQuery )); }( jQuery ));

View File

@ -18,6 +18,7 @@
// TODO when mixing clicking menus and keyboard navigation, focus handling is broken // TODO when mixing clicking menus and keyboard navigation, focus handling is broken
// there has to be just one item that has tabindex // there has to be just one item that has tabindex
$.widget( "ui.menubar", { $.widget( "ui.menubar", {
version: "@VERSION",
options: { options: {
buttons: false, buttons: false,
menuIcon: false menuIcon: false

View File

@ -18,6 +18,7 @@ $(document).mousedown(function(e) {
}); });
$.widget("ui.mouse", { $.widget("ui.mouse", {
version: "@VERSION",
options: { options: {
cancel: ':input,option', cancel: ':input,option',
distance: 1, distance: 1,
@ -58,7 +59,7 @@ $.widget("ui.mouse", {
var self = this, var self = this,
btnIsLeft = (event.which == 1), btnIsLeft = (event.which == 1),
elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false); elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).closest(this.options.cancel).length : false);
if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) { if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
return true; return true;
} }

View File

@ -17,6 +17,7 @@
var idIncrement = 0; var idIncrement = 0;
$.widget( "ui.popup", { $.widget( "ui.popup", {
version: "@VERSION",
options: { options: {
position: { position: {
my: "left top", my: "left top",

View File

@ -14,6 +14,7 @@
(function( $, undefined ) { (function( $, undefined ) {
$.widget( "ui.progressbar", { $.widget( "ui.progressbar", {
version: "@VERSION",
options: { options: {
value: 0, value: 0,
max: 100 max: 100
@ -100,8 +101,4 @@ $.widget( "ui.progressbar", {
} }
}); });
$.extend( $.ui.progressbar, {
version: "@VERSION"
});
})( jQuery ); })( jQuery );

View File

@ -15,6 +15,7 @@
(function( $, undefined ) { (function( $, undefined ) {
$.widget("ui.resizable", $.ui.mouse, { $.widget("ui.resizable", $.ui.mouse, {
version: "@VERSION",
widgetEventPrefix: "resize", widgetEventPrefix: "resize",
options: { options: {
alsoResize: false, alsoResize: false,
@ -293,6 +294,8 @@ $.widget("ui.resizable", $.ui.mouse, {
// Calculate the attrs that will be change // Calculate the attrs that will be change
var data = trigger.apply(this, [event, dx, dy]), ie6 = $.browser.msie && $.browser.version < 7, csdif = this.sizeDiff; var data = trigger.apply(this, [event, dx, dy]), ie6 = $.browser.msie && $.browser.version < 7, csdif = this.sizeDiff;
// Put this in the mouseDrag handler since the user can start pressing shift while resizing
this._updateVirtualBoundaries(event.shiftKey);
if (this._aspectRatio || event.shiftKey) if (this._aspectRatio || event.shiftKey)
data = this._updateRatio(data, event); data = this._updateRatio(data, event);
@ -351,6 +354,32 @@ $.widget("ui.resizable", $.ui.mouse, {
}, },
_updateVirtualBoundaries: function(forceAspectRatio) {
var o = this.options, pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b;
b = {
minWidth: isNumber(o.minWidth) ? o.minWidth : 0,
maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity,
minHeight: isNumber(o.minHeight) ? o.minHeight : 0,
maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity
};
if(this._aspectRatio || forceAspectRatio) {
// We want to create an enclosing box whose aspect ration is the requested one
// First, compute the "projected" size for each dimension based on the aspect ratio and other dimension
pMinWidth = b.minHeight * this.aspectRatio;
pMinHeight = b.minWidth / this.aspectRatio;
pMaxWidth = b.maxHeight * this.aspectRatio;
pMaxHeight = b.maxWidth / this.aspectRatio;
if(pMinWidth > b.minWidth) b.minWidth = pMinWidth;
if(pMinHeight > b.minHeight) b.minHeight = pMinHeight;
if(pMaxWidth < b.maxWidth) b.maxWidth = pMaxWidth;
if(pMaxHeight < b.maxHeight) b.maxHeight = pMaxHeight;
}
this._vBoundaries = b;
},
_updateCache: function(data) { _updateCache: function(data) {
var o = this.options; var o = this.options;
this.offset = this.helper.offset(); this.offset = this.helper.offset();
@ -364,8 +393,8 @@ $.widget("ui.resizable", $.ui.mouse, {
var o = this.options, cpos = this.position, csize = this.size, a = this.axis; var o = this.options, cpos = this.position, csize = this.size, a = this.axis;
if (data.height) data.width = (csize.height * this.aspectRatio); if (isNumber(data.height)) data.width = (data.height * this.aspectRatio);
else if (data.width) data.height = (csize.width / this.aspectRatio); else if (isNumber(data.width)) data.height = (data.width / this.aspectRatio);
if (a == 'sw') { if (a == 'sw') {
data.left = cpos.left + (csize.width - data.width); data.left = cpos.left + (csize.width - data.width);
@ -381,7 +410,7 @@ $.widget("ui.resizable", $.ui.mouse, {
_respectSize: function(data, event) { _respectSize: function(data, event) {
var el = this.helper, o = this.options, pRatio = this._aspectRatio || event.shiftKey, a = this.axis, var el = this.helper, o = this._vBoundaries, pRatio = this._aspectRatio || event.shiftKey, a = this.axis,
ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height), ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height); isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height);
@ -520,10 +549,6 @@ $.widget("ui.resizable", $.ui.mouse, {
}); });
$.extend($.ui.resizable, {
version: "@VERSION"
});
/* /*
* Resizable Extensions * Resizable Extensions
*/ */

View File

@ -15,6 +15,7 @@
(function( $, undefined ) { (function( $, undefined ) {
$.widget("ui.selectable", $.ui.mouse, { $.widget("ui.selectable", $.ui.mouse, {
version: "@VERSION",
options: { options: {
appendTo: 'body', appendTo: 'body',
autoRefresh: true, autoRefresh: true,
@ -259,8 +260,4 @@ $.widget("ui.selectable", $.ui.mouse, {
}); });
$.extend($.ui.selectable, {
version: "@VERSION"
});
})(jQuery); })(jQuery);

View File

@ -19,7 +19,7 @@
var numPages = 5; var numPages = 5;
$.widget( "ui.slider", $.ui.mouse, { $.widget( "ui.slider", $.ui.mouse, {
version: "@VERSION",
widgetEventPrefix: "slide", widgetEventPrefix: "slide",
options: { options: {
@ -659,8 +659,4 @@ $.widget( "ui.slider", $.ui.mouse, {
}); });
$.extend( $.ui.slider, {
version: "@VERSION"
});
}(jQuery)); }(jQuery));

View File

@ -15,6 +15,7 @@
(function( $, undefined ) { (function( $, undefined ) {
$.widget("ui.sortable", $.ui.mouse, { $.widget("ui.sortable", $.ui.mouse, {
version: "@VERSION",
widgetEventPrefix: "sort", widgetEventPrefix: "sort",
options: { options: {
appendTo: "parent", appendTo: "parent",
@ -983,7 +984,7 @@ $.widget("ui.sortable", $.ui.mouse, {
// We first have to update the dom position of the actual currentItem // We first have to update the dom position of the actual currentItem
// Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088) // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
if(!this._noFinalSort && this.currentItem[0].parentNode) this.placeholder.before(this.currentItem); if(!this._noFinalSort && this.currentItem.parent().length) this.placeholder.before(this.currentItem);
this._noFinalSort = null; this._noFinalSort = null;
if(this.helper[0] == this.currentItem[0]) { if(this.helper[0] == this.currentItem[0]) {
@ -1069,8 +1070,4 @@ $.widget("ui.sortable", $.ui.mouse, {
}); });
$.extend($.ui.sortable, {
version: "@VERSION"
});
})(jQuery); })(jQuery);

View File

@ -14,13 +14,14 @@
(function( $ ) { (function( $ ) {
$.widget( "ui.spinner", { $.widget( "ui.spinner", {
version: "@VERSION",
defaultElement: "<input>", defaultElement: "<input>",
widgetEventPrefix: "spin", widgetEventPrefix: "spin",
options: { options: {
incremental: true, incremental: true,
max: null, max: null,
min: null, min: null,
numberformat: null, numberFormat: null,
page: 10, page: 10,
step: null, step: null,
value: null value: null
@ -62,6 +63,7 @@ $.widget( "ui.spinner", {
// add buttons // add buttons
.append( self._buttonHtml() ) .append( self._buttonHtml() )
// add behaviours // add behaviours
.disableSelection()
// TODO: user ._hoverable // TODO: user ._hoverable
.hover(function() { .hover(function() {
if ( !options.disabled ) { if ( !options.disabled ) {
@ -318,13 +320,13 @@ $.widget( "ui.spinner", {
_parse: function( val ) { _parse: function( val ) {
if ( typeof val === "string" ) { if ( typeof val === "string" ) {
val = $.global && this.options.numberformat ? $.global.parseFloat( val ) : +val; val = $.global && this.options.numberFormat ? $.global.parseFloat( val ) : +val;
} }
return isNaN( val ) ? null : val; return isNaN( val ) ? null : val;
}, },
_format: function( num ) { _format: function( num ) {
this.element.val( $.global && this.options.numberformat ? $.global.format( num, this.options.numberformat ) : num ); this.element.val( $.global && this.options.numberFormat ? $.global.format( num, this.options.numberFormat ) : num );
}, },
destroy: function() { destroy: function() {
@ -368,6 +370,4 @@ $.widget( "ui.spinner", {
} }
}); });
$.ui.spinner.version = "@VERSION";
}( jQuery ) ); }( jQuery ) );

View File

@ -19,6 +19,7 @@ function getNextTabId() {
} }
$.widget( "ui.tabs", { $.widget( "ui.tabs", {
version: "@VERSION",
options: { options: {
active: null, active: null,
collapsible: false, collapsible: false,
@ -577,10 +578,6 @@ $.widget( "ui.tabs", {
} }
}); });
$.extend( $.ui.tabs, {
version: "@VERSION"
});
// DEPRECATED // DEPRECATED
if ( $.uiBackCompat !== false ) { if ( $.uiBackCompat !== false ) {

View File

@ -12,108 +12,165 @@
* jquery.ui.widget.js * jquery.ui.widget.js
* jquery.ui.position.js * jquery.ui.position.js
*/ */
(function($) { (function( $ ) {
var increments = 0; var increments = 0;
$.widget("ui.tooltip", { $.widget( "ui.tooltip", {
version: "@VERSION",
options: { options: {
tooltipClass: null,
items: "[title]",
content: function() { content: function() {
return $( this ).attr( "title" ); return $( this ).attr( "title" );
}, },
items: "[title]",
position: { position: {
my: "left+15 center", my: "left+15 center",
at: "right center" at: "right center",
} collision: "flip fit"
}, },
tooltipClass: null
},
_create: function() { _create: function() {
this._bind( { this._bind({
mouseover: "open", mouseover: "open",
focusin: "open" focusin: "open"
}); });
// IDs of generated tooltips, needed for destroy
this.tooltips = {};
}, },
enable: function() { _setOption: function( key, value ) {
this.options.disabled = false; if ( key === "disabled" ) {
}, this[ value ? "_disable" : "_enable" ]();
this.options[ key ] = value;
disable: function() { // disable element style changes
// only set option, disable element style changes
this.options.disabled = true;
},
open: function(event) {
var target = $(event && event.target || this.element).closest(this.options.items);
if ( !target.length ) {
return; return;
} }
var self = this; this._super( "_setOption", key, value );
if ( !target.data("tooltip-title") ) { },
target.data("tooltip-title", target.attr("title"));
} _disable: function() {
var content = this.options.content.call(target[0], function(response) { var that = this;
// IE may instantly serve a cached response, need to give it a chance to finish with _open before that
setTimeout(function() { // close open tooltips
// when undefined, it got removeAttr, then ignore (ajax response) $.each( this.tooltips, function( id, element ) {
// intially its an empty string, so not undefined var event = $.Event( "blur" );
// TODO is there a better approach to enable ajax tooltips to have two updates? event.target = event.currentTarget = element[0];
if (target.attr( "aria-describedby" ) !== undefined) { that.close( event, true );
self._open(event, target, response);
}
}, 13);
}); });
if (content) {
self._open(event, target, content); // 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", "" );
}
});
},
_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;
}
if ( !target.data( "tooltip-title" ) ) {
target.data( "tooltip-title", target.attr( "title" ) );
}
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() {
that._open( event, target, response );
}, 1 );
});
if ( content ) {
that._open( event, target, content );
} }
}, },
_open: function( event, target, content ) { _open: function( event, target, content ) {
if ( !content ) if ( !content ) {
return; return;
}
target.attr("title", ""); // 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
if ( this.options.disabled ) // (we don't want to cause an element to start matching [title])
return; // TODO: document why we don't use .removeAttr()
if ( target.is( "[title]" ) ) {
target.attr( "title", "" );
}
// ajaxy tooltip can update an existing one // ajaxy tooltip can update an existing one
var tooltip = this._find( target ); var tooltip = this._find( target );
if (!tooltip.length) { if ( !tooltip.length ) {
tooltip = this._tooltip(); tooltip = this._tooltip( target );
target.attr( "aria-describedby", tooltip.attr( "id" ) ); target.attr( "aria-describedby", tooltip.attr( "id" ) );
} }
tooltip.find(".ui-tooltip-content").html( content ); tooltip.find( ".ui-tooltip-content" ).html( content );
tooltip.position( $.extend({ tooltip
of: target .stop( true )
}, this.options.position ) ).hide(); .position( $.extend({
of: target,
using: function( pos ) {
// we only want to hide if there's no custom using defined
$( this ).css( pos ).hide();
}
}, this.options.position ) );
tooltip.stop( true );
this._show( tooltip, this.options.show ); this._show( tooltip, this.options.show );
this._trigger( "open", event ); this._trigger( "open", event );
this._bind( target, { this._bind( target, {
mouseleave: "close", mouseleave: "close",
blur: "close", blur: "close"
click: "close"
}); });
}, },
close: function( event ) { close: function( event, force ) {
var target = $( event && event.currentTarget || this.element ); var that = this,
target.attr( "title", target.data( "tooltip-title" ) ); target = $( event ? event.currentTarget : this.element ),
tooltip = this._find( target );
if ( this.options.disabled ) // 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; 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" ); target.removeAttr( "aria-describedby" );
tooltip.stop( true ); tooltip.stop( true );
this._hide( tooltip, this.options.hide, function() { this._hide( tooltip, this.options.hide, function() {
$( this ).remove(); $( this ).remove();
delete that.tooltips[ this.id ];
}); });
target.unbind( "mouseleave.tooltip blur.tooltip" ); target.unbind( "mouseleave.tooltip blur.tooltip" );
@ -121,27 +178,36 @@ $.widget("ui.tooltip", {
this._trigger( "close", event ); this._trigger( "close", event );
}, },
_tooltip: function() { _tooltip: function( element ) {
var tooltip = $( "<div></div>" ) var id = "ui-tooltip-" + increments++,
.attr( "id", "ui-tooltip-" + increments++ ) tooltip = $( "<div>" )
.attr( "role", "tooltip" ) .attr({
.addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content" ); id: id,
if (this.options.tooltipClass) { role: "tooltip"
tooltip.addClass(this.options.tooltipClass); })
} .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " +
$( "<div></div>" ) ( this.options.tooltipClass || "" ) );
$( "<div>" )
.addClass( "ui-tooltip-content" ) .addClass( "ui-tooltip-content" )
.appendTo( tooltip ); .appendTo( tooltip );
tooltip.appendTo( document.body ); tooltip.appendTo( document.body );
if ( $.fn.bgiframe ) {
tooltip.bgiframe();
}
this.tooltips[ id ] = element;
return tooltip; return tooltip;
}, },
_find: function( target ) { _find: function( target ) {
var id = target.attr( "aria-describedby" ); 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 ) );
})(jQuery);

View File

@ -49,7 +49,7 @@ $.widget = function( name, base, prototype ) {
if ( arguments.length ) { if ( arguments.length ) {
this._createWidget( options, element ); this._createWidget( options, element );
} }
}, $[ namespace ][ name ] ); }, $[ namespace ][ name ], { version: prototype.version } );
var basePrototype = new base(); var basePrototype = new base();
// we need to make the options hash a property directly on the new instance // we need to make the options hash a property directly on the new instance
@ -379,7 +379,7 @@ $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
var hasOptions = !$.isEmptyObject( options ), var hasOptions = !$.isEmptyObject( options ),
effectName = options.effect || defaultEffect; effectName = options.effect || defaultEffect;
options.complete = callback; options.complete = callback;
if (options.delay) { if ( options.delay ) {
element.delay( options.delay ); element.delay( options.delay );
} }
if ( hasOptions && $.effects && ( $.effects.effect[ effectName ] || $.uiBackCompat !== false && $.effects[ effectName ] ) ) { if ( hasOptions && $.effects && ( $.effects.effect[ effectName ] || $.uiBackCompat !== false && $.effects[ effectName ] ) ) {