Merge branch 'master' of github.com:jquery/jquery-ui into selectmenu

This commit is contained in:
Felix Nagel 2011-09-24 19:49:22 +02:00
commit 55184e1e07
32 changed files with 883 additions and 463 deletions

View File

@ -0,0 +1,84 @@
<!DOCTYPE html>
<html>
<head>
<title>jQuery UI Popup - Animation demo</title>
<link rel="stylesheet" href="../demos.css" />
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css" title="ui-theme" />
<script src="../../jquery-1.6.2.js"></script>
<script src="../../ui/jquery.ui.core.js"></script>
<script src="../../ui/jquery.ui.widget.js"></script>
<script src="../../ui/jquery.ui.position.js"></script>
<script src="../../ui/jquery.ui.button.js"></script>
<script src="../../ui/jquery.effects.core.js"></script>
<script src="../../ui/jquery.effects.blind.js"></script>
<script src="../../ui/jquery.effects.scale.js"></script>
<script src="../../ui/jquery.ui.popup.js"></script>
<script>
$(function() {
var selected = {
select: function( event, ui ) {
$( "<div/>" ).text( "Selected: " + ui.item.text() ).appendTo( "#log" );
$(this).popup("close");
}
};
$("#login-form").popup({
show: {
effect: "blind",
direction: "up",
mode: "show",
duration: "fast"
},
hide: {
effect: "scale",
percent: 0,
duration: "fast"
}
})
.find(":submit").button().click(function(event) {
event.preventDefault();
});
});
</script>
<style type="text/css">
.ui-popup { position: absolute; z-index: 5000; }
#login-form {
width: 16em; border: 1px solid gray; border-radius: 5px;
padding: 1em;
box-shadow: 3px 3px 5px -1px rgba(0, 0, 0, 0.5);
background: lightgray; background-image: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#ddd));
font-size: 1.3em; outline: none;
}
#login-form label { display: inline-block; width: 5em; }
#login-form .submit { margin-left: 5em; }
</style>
</head>
<body>
<div class="demo">
<a href="#login-form">Log In</a>
<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. Open and close animations have been used.</p>
</div><!-- End demo-description -->
</body>
</html>

View File

@ -9,7 +9,6 @@
<script src="../../ui/jquery.ui.widget.js"></script> <script src="../../ui/jquery.ui.widget.js"></script>
<script src="../../ui/jquery.ui.position.js"></script> <script src="../../ui/jquery.ui.position.js"></script>
<script src="../../ui/jquery.ui.button.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.ui.popup.js"></script>
<script> <script>
$(function() { $(function() {
@ -28,17 +27,6 @@
</script> </script>
<style type="text/css"> <style type="text/css">
.ui-popup { position: absolute; z-index: 5000; } .ui-popup { position: absolute; z-index: 5000; }
.ui-menu { width: 200px; }
/*
table {
border-collapse: collapse;
}
th, td {
padding: 0.5em;
border: 1px solid black;
}
*/
#login-form { #login-form {
width: 16em; border: 1px solid gray; border-radius: 5px; width: 16em; border: 1px solid gray; border-radius: 5px;

View File

@ -10,6 +10,7 @@
<h4>Examples</h4> <h4>Examples</h4>
<ul> <ul>
<li class="demo-config-on"><a href="default.html">Default functionality</a></li> <li class="demo-config-on"><a href="default.html">Default functionality</a></li>
<li><a href="animation.html">Popup - show/hide effects</a></li>
<li><a href="popup-menu.html">Menu's as popup</a></li> <li><a href="popup-menu.html">Menu's as popup</a></li>
<li><a href="popup-menu-table.html">Menu's as popup in a table</a></li> <li><a href="popup-menu-table.html">Menu's as popup in a table</a></li>
</ul> </ul>

View File

@ -14,6 +14,7 @@
<style> <style>
#parent { #parent {
width: 60%; width: 60%;
height: 40px;
margin: 10px auto; margin: 10px auto;
padding: 5px; padding: 5px;
border: 1px solid #777; border: 1px solid #777;
@ -21,8 +22,6 @@
text-align: center; text-align: center;
} }
.positionable { .positionable {
width: 75px;
height: 75px;
position: absolute; position: absolute;
display: block; display: block;
right: 0; right: 0;
@ -30,6 +29,14 @@
background-color: #bcd5e6; background-color: #bcd5e6;
text-align: center; text-align: center;
} }
#positionable1 {
width: 75px;
height: 75px;
}
#positionable2 {
width: 120px;
height: 40px;
}
.ui-flipped-top { .ui-flipped-top {
border-top: 3px solid #000000; border-top: 3px solid #000000;
} }
@ -93,13 +100,13 @@
</p> </p>
</div> </div>
<div class="positionable"> <div class="positionable" id="positionable1">
<p> <p>
to position to position
</p> </p>
</div> </div>
<div class="positionable" style="width:120px; height: 40px;"> <div class="positionable" id="positionable2">
<p> <p>
to position 2 to position 2
</p> </p>

View File

@ -21,8 +21,9 @@
map.setCenter( latlong() ); map.setCenter( latlong() );
} }
$( "#lat, #lng" ).spinner({ $( "#lat, #lng" ).spinner({
precision: 6, step: .001,
change: position change: position,
stop: position
}); });
var map = new google.maps.Map( $("#map")[0], { var map = new google.maps.Map( $("#map")[0], {
@ -44,10 +45,10 @@
<div class="demo"> <div class="demo">
<label for="lat">Latitude</label> <label for="lat">Latitude</label>
<input id="lat" name="lat" value="44.797916"> <input id="lat" name="lat" value="44.797">
<br> <br>
<label for="lng">Longitude</label> <label for="lng">Longitude</label>
<input id="lng" name="lng" value="-93.278046"> <input id="lng" name="lng" value="-93.278">
<div id="map"></div> <div id="map"></div>

View File

@ -39,6 +39,7 @@
<div id="ac-wrap1" class="ac-wrap"></div> <div id="ac-wrap1" class="ac-wrap"></div>
<div id="ac-wrap2" class="ac-wrap"><input id="autocomplete" class="foo"></div> <div id="ac-wrap2" class="ac-wrap"><input id="autocomplete" class="foo"></div>
<div id="autocomplete-contenteditable" contenteditable="" tabindex=0></div> <div id="autocomplete-contenteditable" contenteditable="" tabindex=0></div>
<textarea id="autocomplete-textarea"></textarea>
</div> </div>
</body> </body>

View File

@ -4,9 +4,26 @@ module( "autocomplete: events" );
var data = [ "Clojure", "COBOL", "ColdFusion", "Java", "JavaScript", "Scala", "Scheme" ]; var data = [ "Clojure", "COBOL", "ColdFusion", "Java", "JavaScript", "Scala", "Scheme" ];
asyncTest( "all events", function() { $.each([
{
type: "input",
selector: "#autocomplete",
valueMethod: "val"
},
{
type: "textarea",
selector: "#autocomplete-textarea",
valueMethod: "val"
},
{
type: "contenteditable",
selector: "#autocomplete-contenteditable",
valueMethod: "text"
}
], function( i, settings ) {
asyncTest( "all events - " + settings.type, function() {
expect( 13 ); expect( 13 );
var element = $( "#autocomplete" ) var element = $( settings.selector )
.autocomplete({ .autocomplete({
autoFocus: false, autoFocus: false,
delay: 0, delay: 0,
@ -46,7 +63,7 @@ asyncTest( "all events", function() {
}), }),
menu = element.autocomplete( "widget" ); menu = element.autocomplete( "widget" );
element.focus().val( "j" ).keydown(); element.focus()[ settings.valueMethod ]( "j" ).keydown();
setTimeout(function() { setTimeout(function() {
ok( menu.is( ":visible" ), "menu is visible after delay" ); ok( menu.is( ":visible" ), "menu is visible after delay" );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
@ -56,58 +73,6 @@ asyncTest( "all events", function() {
element[0].blur(); element[0].blur();
}, 50 ); }, 50 );
}); });
asyncTest( "all events - contenteditable", function() {
expect( 13 );
var element = $( "#autocomplete-contenteditable" )
.autocomplete({
autoFocus: false,
delay: 0,
source: data,
search: function( event ) {
equal( event.originalEvent.type, "keydown", "search originalEvent" );
},
response: function( event, ui ) {
deepEqual( ui.content, [
{ label: "Clojure", value: "Clojure" },
{ label: "Java", value: "Java" },
{ label: "JavaScript", value: "JavaScript" }
], "response ui.content" );
ui.content.splice( 0, 1 );
},
open: function( event ) {
ok( menu.is( ":visible" ), "menu open on open" );
},
focus: function( event, ui ) {
equal( event.originalEvent.type, "menufocus", "focus originalEvent" );
deepEqual( ui.item, { label: "Java", value: "Java" }, "focus ui.item" );
},
close: function( event ) {
equal( event.originalEvent.type, "menuselect", "close originalEvent" );
ok( menu.is( ":hidden" ), "menu closed on close" );
},
select: function( event, ui ) {
equal( event.originalEvent.type, "menuselect", "select originalEvent" );
deepEqual( ui.item, { label: "Java", value: "Java" }, "select ui.item" );
},
change: function( event, ui ) {
equal( event.originalEvent.type, "blur", "change originalEvent" );
deepEqual( ui.item, { label: "Java", value: "Java" }, "chnage ui.item" );
ok( menu.is( ":hidden" ), "menu closed on change" );
start();
}
}),
menu = element.autocomplete( "widget" );
element.focus().text( "j" ).keydown();
setTimeout(function() {
ok( menu.is( ":visible" ), "menu is visible after delay" );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
// TODO: blurring through jQuery causes a bug in IE 6 which causes the
// autocompletechange event to occur twice
element[0].blur();
}, 50 );
}); });
asyncTest( "change without selection", function() { asyncTest( "change without selection", function() {

View File

@ -5,6 +5,35 @@
module( "dialog: tickets" ); module( "dialog: tickets" );
asyncTest( "#3123: Prevent tabbing out of modal dialogs", function() {
expect( 3 );
var el = $( "<div><input id='t3123-first'><input id='t3123-last'></div>" ).dialog({ modal: true }),
inputs = el.find( "input" ),
widget = el.dialog( "widget" );
inputs.eq( 1 ).focus();
equal( document.activeElement, inputs[1], "Focus set on second input" );
inputs.eq( 1 ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB });
setTimeout( checkTab, 2 );
function checkTab() {
ok( $.contains( widget, document.activeElement ), "Tab key event moved focus within the modal" );
// check shift tab
$( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB, shiftKey: true });
setTimeout( checkShiftTab, 2 );
}
function checkShiftTab() {
ok( $.contains( widget, document.activeElement ), "Shift-Tab key event moved focus within the modal" );
el.remove();
start();
}
});
test("#4826: setting resizable false toggles resizable on dialog", function() { test("#4826: setting resizable false toggles resizable on dialog", function() {
expect(6); expect(6);

View File

@ -207,6 +207,44 @@
<li class="foo"><a class="foo" href="#">Amesville</a></li> <li class="foo"><a class="foo" href="#">Amesville</a></li>
</ul> </ul>
<div id="menu5">
<blockquote><a href="#">Aberdeen</a></blockquote>
<blockquote><a href="#">Ada</a></blockquote>
<blockquote><a href="#">Adamsville</a></blockquote>
<blockquote><a href="#">Addyston</a></blockquote>
<blockquote>
<a href="#">Delphi</a>
<div>
<blockquote><a href="#">Ada</a></blockquote>
<blockquote><a href="#">Saarland</a></blockquote>
<blockquote><a href="#">Salzburg</a></blockquote>
</div>
</blockquote>
<blockquote><a href="#">Saarland</a></blockquote>
<blockquote>
<a href="#">Salzburg</a>
<div>
<blockquote>
<a href="#">Delphi</a>
<div>
<blockquote><a href="#">Ada</a></blockquote>
<blockquote><a href="#">Saarland</a></blockquote>
<blockquote><a href="#">Salzburg</a></blockquote>
</div>
</blockquote>
<blockquote>
<a href="#">Delphi</a>
<div>
<blockquote><a href="#">Ada</a></blockquote>
<blockquote><a href="#">Saarland</a></blockquote>
<blockquote><a href="#">Salzburg</a></blockquote>
</div>
</blockquote>
<blockquote><a href="#">Perch</a></blockquote>
</div>
</blockquote>
</div>
<div id="log"></div> <div id="log"></div>
</div> </div>

View File

@ -5,6 +5,7 @@ commonWidgetTests( "menu", {
my: "left top", my: "left top",
at: "right top" at: "right top"
}, },
items: "ul",
// callbacks // callbacks
create: null create: null

View File

@ -21,6 +21,23 @@ test("handle click on menu", function() {
equals( $("#log").html(), "1,3,2,afterclick,1,click,", "Click order not valid."); equals( $("#log").html(), "1,3,2,afterclick,1,click,", "Click order not valid.");
}); });
test("handle click on custom item menu", function() {
expect(1);
var ac = $('#menu5').menu({
select: function(event, ui) {
menu_log();
},
items: "div"
});
menu_log("click",true);
menu_click($('#menu5'),"1");
menu_log("afterclick");
menu_click( ac,"2");
menu_click($('#menu5'),"3");
menu_click( ac,"1");
equals( $("#log").html(), "1,3,2,afterclick,1,click,", "Click order not valid.");
});
test( "handle blur: click", function() { test( "handle blur: click", function() {
expect( 4 ); expect( 4 );
var $menu = $( "#menu1" ).menu({ var $menu = $( "#menu1" ).menu({
@ -41,6 +58,71 @@ test( "handle blur: click", function() {
$("#remove").remove(); $("#remove").remove();
}); });
test( "handle blur on custom item menu: click", function() {
expect( 4 );
var $menu = $( "#menu5" ).menu({
focus: function( event, ui ) {
equal( event.originalEvent.type, "click", "focus triggered 'click'" );
equal( event.type, "menufocus", "focus event.type is 'menufocus'" );
},
blur: function( event, ui ) {
equal( event.originalEvent.type, "click", "blur triggered 'click'" );
equal( event.type, "menublur", "blur event.type is 'menublur'" );
},
items: "div"
});
menu_click($('#menu5'),"1");
$( "<a>", { id: "remove"} ).appendTo("body").trigger( "click" );
$("#remove").remove();
});
asyncTest( "handle submenu auto collapse: mouseleave", function() {
expect( 4 );
var $menu = $( "#menu2" ).menu();
$menu.find( "li:nth-child(7)" ).trigger( "mouseover" );
setTimeout(function() {
equal( $menu.find( "ul[aria-expanded='true']" ).length, 1, "first submenu expanded" );
$menu.find( "li:nth-child(7) li:first" ).trigger( "mouseover" );
setTimeout(function() {
equal( $menu.find( "ul[aria-expanded='true']" ).length, 2, "second submenu expanded" );
$menu.find( "ul[aria-expanded='true']:first" ).trigger( "mouseleave" );
equal( $menu.find( "ul[aria-expanded='true']" ).length, 1, "second submenu collapsed" );
$menu.trigger( "mouseleave" );
equal( $menu.find( "ul[aria-expanded='true']" ).length, 0, "first submenu collapsed" );
start();
}, 400);
}, 200);
});
asyncTest( "handle custom menu item submenu auto collapse: mouseleave", function() {
expect( 5 );
var $menu = $( "#menu5" ).menu( { items: "div" } );
$menu.children( ":nth-child(7)" ).trigger( "mouseover" );
setTimeout(function() {
equal( $menu.find( "div[aria-expanded='true']" ).length, 1, "first submenu expanded" );
$menu.children( ":nth-child(7)" ).find( "div:first" ).children( ":first" ).trigger( "mouseover" );
setTimeout(function() {
equal( $menu.find( "div[aria-expanded='true']" ).length, 2, "second submenu expanded" );
$menu.find( "div[aria-expanded='true']:first" ).trigger( "mouseleave" );
equal( $menu.find( "div[aria-expanded='true']" ).length, 1, "second submenu collapsed" );
$menu.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN });
ok( $menu.find( ".ui-state-active" ).is( "#menu5 :nth-child(7) a" ),
"down keypress selected an item from the first submenu" );
$menu.trigger( "mouseleave" );
equal( $menu.find( "div[aria-expanded='true']" ).length, 0, "first submenu collapsed" );
start();
}, 400);
}, 200);
});
test("handle keyboard navigation on menu without scroll and without submenus", function() { test("handle keyboard navigation on menu without scroll and without submenus", function() {
expect(12); expect(12);
var element = $('#menu1').menu({ var element = $('#menu1').menu({

View File

@ -5,10 +5,10 @@ function menu_log( message, clear ) {
if ( message === undefined ) { if ( message === undefined ) {
message = $( "#log" ).data( "lastItem" ); message = $( "#log" ).data( "lastItem" );
} }
$( "#log" ).prepend( message + "," ); $( "#log" ).prepend( $.trim( message ) + "," );
} }
function menu_click( menu, item ) { function menu_click( menu, item ) {
$( "#log" ).data( "lastItem", item ); $( "#log" ).data( "lastItem", item );
menu.find( "li:eq(" + item + ") a" ).trigger( "click" ); menu.children( ":eq(" + item + ")" ).find( "a:first" ).trigger( "click" );
} }

View File

@ -55,5 +55,9 @@ elements smaller than 10px have a line-height set on them to avoid a bug in IE6
<div style="width: 50px; height: 10px;"></div> <div style="width: 50px; height: 10px;"></div>
</div> </div>
<div id="fractions-parent" style="position: absolute; left: 10.7432222px; top: 10.532325px; height: 30px; width: 201px;">
<div id="fractions-element"></div>
</div>
</body> </body>
</html> </html>

View File

@ -109,14 +109,12 @@ test( "mouse click on up button, increases value not greater than max", function
}); });
test( "mousewheel on input", function() { test( "mousewheel on input", function() {
expect( 5 ); expect( 4 );
var element = $( "#spin" ).spinner({ var element = $( "#spin" ).val( 0 ).spinner({
step: 2 step: 2
}); });
equal( element.val(), 0 );
element.trigger( "mousewheel" ); element.trigger( "mousewheel" );
equal( element.val(), 0, "mousewheel event without delta does not change value" ); equal( element.val(), 0, "mousewheel event without delta does not change value" );
@ -149,22 +147,28 @@ test( "reading HTML5 attributes", function() {
}); });
test( "ARIA attributes", function() { test( "ARIA attributes", function() {
expect( 7 ); expect( 9 );
var element = $( "#spin" ).val( 2 ).spinner({ min: -5, max: 5 }); var element = $( "#spin" ).val( 2 ).spinner({ min: -5, max: 5 });
equal( element.attr( "role" ), "spinbutton", "role" ); equal( element.attr( "role" ), "spinbutton", "role" );
equal( element.attr( "aria-valuemin" ), -5, "aria-valuemin" ); equal( element.attr( "aria-valuemin" ), "-5", "aria-valuemin" );
equal( element.attr( "aria-valuemax" ), 5, "aria-valuemax" ); equal( element.attr( "aria-valuemax" ), "5", "aria-valuemax" );
equal( element.attr( "aria-valuenow" ), 2, "aria-valuenow" ); equal( element.attr( "aria-valuenow" ), "2", "aria-valuenow" );
element.spinner( "stepUp" ); element.spinner( "stepUp" );
equal( element.attr( "aria-valuenow" ), 3, "stepUp 1 step changes aria-valuenow" ); equal( element.attr( "aria-valuenow" ), "3", "stepUp 1 step changes aria-valuenow" );
element.spinner( "option", { min: -10, max: 10 } ); element.spinner( "option", { min: -10, max: 10 } );
equal( element.attr( "aria-valuemin" ), -10, "min option changed aria-valuemin changes" ); equal( element.attr( "aria-valuemin" ), "-10", "min option changed aria-valuemin changes" );
equal( element.attr( "aria-valuemax" ), 10, "max option changed aria-valuemax changes" ); equal( element.attr( "aria-valuemax" ), "10", "max option changed aria-valuemax changes" );
element.spinner( "option", "min", null );
equal( element.attr( "aria-valuemin" ), undefined, "aria-valuemin not set when no min" );
element.spinner( "option", "max", null );
equal( element.attr( "aria-valuemax" ), undefined, "aria-valuemax not set when no max" );
}); });
test( "focus text field when pressing button", function() { test( "focus text field when pressing button", function() {
@ -192,10 +196,11 @@ test( "precision", function() {
equal( element.val(), "0.0501", "precision from step" ); equal( element.val(), "0.0501", "precision from step" );
element.val( 1.05 ).spinner( "option", { element.val( 1.05 ).spinner( "option", {
step: 1 step: 1,
min: -9.95
}); });
element.spinner( "stepDown" ); element.spinner( "stepDown" );
equal( element.val(), "0.05", "precision from value" ); equal( element.val(), "0.05", "precision from min" );
}); });
})( jQuery ); })( jQuery );

View File

@ -2,8 +2,8 @@ commonWidgetTests( "spinner", {
defaults: { defaults: {
disabled: false, disabled: false,
incremental: true, incremental: true,
max: Number.MAX_VALUE, max: null,
min: -Number.MAX_VALUE, min: null,
numberFormat: null, numberFormat: null,
page: 10, page: 10,
step: 1, step: 1,

View File

@ -54,7 +54,7 @@ test( "disable", function() {
test( "enable", function() { test( "enable", function() {
expect( 5 ); expect( 5 );
var element = $( "#spin" ).spinner({ disabled: true }) var element = $( "#spin" ).val( 1 ).spinner({ disabled: true })
wrapper = element.spinner( "widget" ); wrapper = element.spinner( "widget" );
ok( wrapper.hasClass( "ui-spinner-disabled" ), "before: wrapper has ui-spinner-disabled class" ); ok( wrapper.hasClass( "ui-spinner-disabled" ), "before: wrapper has ui-spinner-disabled class" );
@ -66,7 +66,7 @@ test( "enable", function() {
ok( !element.is( ":disabled" ), "after: input does not have disabled attribute" ); ok( !element.is( ":disabled" ), "after: input does not have disabled attribute" );
spinner_simulateKeyDownUp( element, $.ui.keyCode.UP ); spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
equals( 1, element.val(), "keyboard - value does not change on key UP" ); equals( 2, element.val(), "keyboard - value changes on key UP" );
}); });
test( "pageDown", function() { test( "pageDown", function() {
@ -117,23 +117,23 @@ test( "stepDown", function() {
}); });
element.spinner( "stepDown" ); element.spinner( "stepDown" );
equals( element.val(), -2, "stepDown 1 step" ); equals( element.val(), "-1", "stepDown 1 step" );
element.spinner( "stepDown", 5 ); element.spinner( "stepDown", 5 );
equals( element.val(), -12, "stepDown 5 steps" ); equals( element.val(), "-11", "stepDown 5 steps" );
element.spinner( "stepDown", 4 ); element.spinner( "stepDown", 4 );
equals( element.val(), -15, "close to min and stepDown 4 steps" ); equals( element.val(), "-15", "close to min and stepDown 4 steps" );
element.spinner( "stepDown" ); element.spinner( "stepDown" );
equals( element.val(), -15, "at min and stepDown 1 step" ); equals( element.val(), "-15", "at min and stepDown 1 step" );
}); });
test( "stepUp", function() { test( "stepUp", function() {
expect( 4 ); expect( 4 );
var element = $( "#spin" ).val( 0 ).spinner({ var element = $( "#spin" ).val( 0 ).spinner({
step: 2, step: 2,
max: 15 max: 16
}); });
element.spinner( "stepUp" ); element.spinner( "stepUp" );
@ -143,20 +143,22 @@ test( "stepUp", function() {
equals( element.val(), 12, "stepUp 5 steps" ); equals( element.val(), 12, "stepUp 5 steps" );
element.spinner( "stepUp", 4 ); element.spinner( "stepUp", 4 );
equals( element.val(), 15, "close to min and stepUp 4 steps" ); equals( element.val(), 16, "close to min and stepUp 4 steps" );
element.spinner( "stepUp" ); element.spinner( "stepUp" );
equals( element.val(), 15, "at max and stepUp 1 step" ); equals( element.val(), 16, "at max and stepUp 1 step" );
}); });
test( "value", function() { test( "value", function() {
expect( 2 ); expect( 2 );
var element = $( "#spin" ).val( 0 ).spinner(); var element = $( "#spin" ).val( 0 ).spinner({
step: 3
});
element.spinner( "value", 10 ); element.spinner( "value", 10 );
equals( element.val(), 10, "change value via value method" ); equals( element.val(), 9, "change value via value method" );
equals( element.spinner( "value" ), 10, "get value via value method" ); equals( element.spinner( "value" ), 9, "get value via value method" );
}); });
})( jQuery ); })( jQuery );

View File

@ -2,6 +2,71 @@
module( "spinner: options" ); module( "spinner: options" );
test( "incremental, false", function() {
expect( 100 );
var i, diff,
prev = 0,
element = $( "#spin" ).val( prev ).spinner({
incremental: false,
spin: function( event, ui ) {
equal( ui.value - prev, 1 );
prev = ui.value;
}
});
for ( i = 0; i < 100; i++ ) {
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
}
});
test( "incremental, true", function() {
expect( 100 );
function fill( num, val ) {
return $.map( new Array( num ), function() {
return val;
});
}
var i, diff,
prev = 0,
expected = [].concat( fill( 18, 1 ), fill( 37, 2 ), fill( 14, 3 ),
fill( 9, 4 ), fill( 6, 5 ), fill( 5, 6 ), fill ( 5, 7 ),
fill( 4, 8 ), fill( 2, 9 ) ),
element = $( "#spin" ).val( prev ).spinner({
incremental: true,
spin: function( event, ui ) {
equal( ui.value - prev, expected[ i ] );
prev = ui.value;
}
});
for ( i = 0; i < 100; i++ ) {
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
}
});
test( "incremental, function", function() {
expect( 100 );
var i,
prev = 0,
element = $( "#spin" ).val( prev ).spinner({
incremental: function( i ) {
return i;
},
spin: function( event, ui ) {
equal( ui.value - prev, i + 1 );
prev = ui.value;
}
});
for ( i = 0; i < 100; i++ ) {
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
}
});
test( "numberFormat, number", function() { test( "numberFormat, number", function() {
expect( 2 ); expect( 2 );
var element = $( "#spin" ).val( 0 ).spinner({ numberFormat: "n" }); var element = $( "#spin" ).val( 0 ).spinner({ numberFormat: "n" });
@ -26,44 +91,6 @@ test( "numberFormat, currency", function() {
equal( element.val(), "$1.00", "formatted after step" ); equal( element.val(), "$1.00", "formatted after step" );
}); });
/* TODO figure out how to test this properly
test("incremental - false (default)", function() {
var el = $("#spin").spinner({ incremental:false });
for ( var i = 1 ; i<=120 ; i++ ) {
el.simulate("keydown",{keyCode:$.ui.keyCode.UP});
}
el.simulate("keyup",{keyCode:$.ui.keyCode.UP});
equals(el.val(), 120, "incremental false - keydown 120 times");
for ( var i = 1 ; i<=210 ; i++ ) {
el.simulate("keydown",{keyCode:$.ui.keyCode.DOWN});
}
el.simulate("keyup",{keyCode:$.ui.keyCode.DOWN});
equals(el.val(), -90, "incremental false - keydown 210 times");
});
test("incremental - true (default)", function() {
var el = $("#spin").spinner();
for ( var i = 1 ; i<=120 ; i++ ) {
el.simulate("keydown",{keyCode:$.ui.keyCode.UP});
}
el.simulate("keyup",{keyCode:$.ui.keyCode.UP});
equals(el.val(), 300, "incremental true - keydown 120 times (100+20*10)");
for ( var i = 1 ; i<=210 ; i++ ) {
el.simulate("keydown",{keyCode:$.ui.keyCode.DOWN});
}
el.simulate("keyup",{keyCode:$.ui.keyCode.DOWN});
equals(el.val(), -1800, "incremental true - keydown 210 times (300-100-100*10-10*100)");
});
*/
test( "max", function() { test( "max", function() {
expect( 3 ); expect( 3 );
var element = $( "#spin" ).val( 1000 ).spinner({ max: 100 }); var element = $( "#spin" ).val( 1000 ).spinner({ max: 100 });
@ -96,10 +123,11 @@ test( "step, 2", function() {
equals( element.val(), "2", "stepUp" ); equals( element.val(), "2", "stepUp" );
element.spinner( "value", "10.5" ); element.spinner( "value", "10.5" );
equals( element.val(), "10.5", "value reset to 10.5" ); equals( element.val(), "10", "value reset to 10" );
element.val( "4.5" );
element.spinner( "stepUp" ); element.spinner( "stepUp" );
equals( element.val(), "12.5", "stepUp" ); equals( element.val(), "6", "stepUp" );
}); });
test( "step, 0.7", function() { test( "step, 0.7", function() {

View File

@ -571,23 +571,23 @@ test( ".widget() - overriden", function() {
test( "._bind() to element (default)", function() { test( "._bind() to element (default)", function() {
expect( 12 ); expect( 12 );
var self; var that;
$.widget( "ui.testWidget", { $.widget( "ui.testWidget", {
_create: function() { _create: function() {
self = this; that = this;
this._bind({ this._bind({
keyup: this.keyup, keyup: this.keyup,
keydown: "keydown" keydown: "keydown"
}); });
}, },
keyup: function( event ) { keyup: function( event ) {
equals( self, this ); equals( that, this );
equals( self.element[0], event.currentTarget ); equals( that.element[0], event.currentTarget );
equals( "keyup", event.type ); equals( "keyup", event.type );
}, },
keydown: function( event ) { keydown: function( event ) {
equals( self, this ); equals( that, this );
equals( self.element[0], event.currentTarget ); equals( that.element[0], event.currentTarget );
equals( "keydown", event.type ); equals( "keydown", event.type );
} }
}); });
@ -611,23 +611,23 @@ test( "._bind() to element (default)", function() {
test( "._bind() to descendent", function() { test( "._bind() to descendent", function() {
expect( 12 ); expect( 12 );
var self; var that;
$.widget( "ui.testWidget", { $.widget( "ui.testWidget", {
_create: function() { _create: function() {
self = this; that = this;
this._bind( this.element.find( "strong" ), { this._bind( this.element.find( "strong" ), {
keyup: this.keyup, keyup: this.keyup,
keydown: "keydown" keydown: "keydown"
}); });
}, },
keyup: function( event ) { keyup: function( event ) {
equals( self, this ); equals( that, this );
equals( self.element.find( "strong" )[0], event.currentTarget ); equals( that.element.find( "strong" )[0], event.currentTarget );
equals( "keyup", event.type ); equals( "keyup", event.type );
}, },
keydown: function(event) { keydown: function(event) {
equals( self, this ); equals( that, this );
equals( self.element.find( "strong" )[0], event.currentTarget ); equals( that.element.find( "strong" )[0], event.currentTarget );
equals( "keydown", event.type ); equals( "keydown", event.type );
} }
}); });
@ -1040,4 +1040,30 @@ test( "redefine", function() {
equal( $.ui.testWidget.foo, "bar", "static properties remain" ); equal( $.ui.testWidget.foo, "bar", "static properties remain" );
}); });
asyncTest( "_delay", function() {
expect( 6 );
var order = 0,
that;
$.widget( "ui.testWidget", {
defaultElement: null,
_create: function() {
that = this;
var timer = this._delay(function() {
strictEqual( this, that );
equal( order, 1 );
start();
}, 500);
ok( timer !== undefined );
timer = this._delay("callback");
ok( timer !== undefined );
},
callback: function() {
strictEqual( this, that );
equal( order, 0 );
order += 1;
}
});
$( "#widget" ).testWidget();
});
}( jQuery ) ); }( jQuery ) );

View File

@ -6,7 +6,6 @@ test( "$.widget.extend()", function() {
optionsCopy = { xnumber2: 1, xstring2: "x", xxx: "newstring" }, optionsCopy = { xnumber2: 1, xstring2: "x", xxx: "newstring" },
merged = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "x", xxx: "newstring" }, merged = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "x", xxx: "newstring" },
deep1 = { foo: { bar: true } }, deep1 = { foo: { bar: true } },
deep1copy = { foo: { bar: true } },
deep2 = { foo: { baz: true }, foo2: document }, deep2 = { foo: { baz: true }, foo2: document },
deep2copy = { foo: { baz: true }, foo2: document }, deep2copy = { foo: { baz: true }, foo2: document },
deepmerged = { foo: { bar: true, baz: true }, foo2: document }, deepmerged = { foo: { bar: true, baz: true }, foo2: document },
@ -96,7 +95,7 @@ test( "$.widget.extend()", function() {
var input = { var input = {
key: [ 1, 2, 3 ] key: [ 1, 2, 3 ]
} };
var output = $.widget.extend( {}, input ); var output = $.widget.extend( {}, input );
deepEqual( input, output, "don't clone arrays" ); deepEqual( input, output, "don't clone arrays" );
input.key[0] = 10; input.key[0] = 10;

View File

@ -23,9 +23,23 @@
$("<div/>").text("Selected: " + ui.item.text()).appendTo("#log"); $("<div/>").text("Selected: " + ui.item.text()).appendTo("#log");
} }
}); });
$("#menu5").menu({
select: function(event, ui) {
$("<div/>").text("Selected: " + ui.item.text()).appendTo("#log");
},
items: "div"
});
$("#menu6").menu({
select: function(event, ui) {
$("<div/>").text("Selected: " + ui.item.text()).appendTo("#log");
},
items: ".menuElement"
});
} }
var menus = $("#menu1, #menu2, #menu3, #menu4"); var menus = $("#menu1, #menu2, #menu3, .menu4");
create(); create();
$("#toggle-destroy").toggle(function() { $("#toggle-destroy").toggle(function() {
@ -41,7 +55,10 @@
<style> <style>
body { font-size:62.5%; } body { font-size:62.5%; }
.ui-menu { width: 200px; margin-bottom: 2em; } .ui-menu { width: 200px; margin-bottom: 2em; }
#menu4 { height: 200px; overflow: auto; } .menu4 { height: 200px; overflow: auto; }
.address-item { border-bottom: 1px solid #999; }
.address-header { display: block; margin-bottom: .2em; font-weight: bold; }
.address-content { display: block; margin-bottom: .2em; padding-left: 10px; }
</style> </style>
</head> </head>
<body> <body>
@ -132,7 +149,7 @@
</li> </li>
</ul> </ul>
<ul id="menu4"> <ul class="menu4">
<li><a href="#">Aberdeen</a></li> <li><a href="#">Aberdeen</a></li>
<li><a href="#">Ada</a></li> <li><a href="#">Ada</a></li>
<li><a href="#">Adamsville</a></li> <li><a href="#">Adamsville</a></li>
@ -173,6 +190,87 @@
<li><a href="#">Amesville</a></li> <li><a href="#">Amesville</a></li>
</ul> </ul>
<div id="menu5">
<blockquote><a href="#">Aberdeen</a></blockquote>
<blockquote><a href="#">Ada</a></blockquote>
<blockquote><a href="#">Adamsville</a></blockquote>
<blockquote><a href="#">Addyston</a></blockquote>
<blockquote>
<a href="#">Delphi</a>
<div>
<blockquote><a href="#">Ada</a></blockquote>
<blockquote><a href="#">Saarland</a></blockquote>
<blockquote><a href="#">Salzburg</a></blockquote>
</div>
</blockquote>
<blockquote><a href="#">Saarland</a></blockquote>
<blockquote>
<a href="#">Salzburg</a>
<div>
<blockquote>
<a href="#">Delphi</a>
<div>
<blockquote><a href="#">Ada</a></blockquote>
<blockquote><a href="#">Saarland</a></blockquote>
<blockquote><a href="#">Salzburg</a></blockquote>
</div>
</blockquote>
<blockquote>
<a href="#">Delphi</a>
<div>
<blockquote><a href="#">Ada</a></blockquote>
<blockquote><a href="#">Saarland</a></blockquote>
<blockquote><a href="#">Salzburg</a></blockquote>
</div>
</blockquote>
<blockquote><a href="#">Perch</a></blockquote>
</div>
</blockquote>
</div>
<div class="menuElement" id="menu6">
<div class="address-item">
<a href="#">
<span class="address-header">John Doe</span>
<span class="address-content">78 West Main St Apt 3A</span>
<span class="address-content">Bloomsburg, PA 12345</span>
</a>
</div>
<div class="address-item">
<a href="#">
<span class="address-header">Jane Doe</span>
<span class="address-content">78 West Main St Apt 3A</span>
<span class="address-content">Bloomsburg, PA 12345</span>
</a>
</div>
<div class="address-item">
<a href="#">
<span class="address-header">James Doe</span>
<span class="address-content">78 West Main St Apt 3A</span>
<span class="address-content">Bloomsburg, PA 12345</span>
</a>
</div>
<div class="address-item">
<a href="#">
<span class="address-header">Jenny Doe</span>
<span class="address-content">78 West Main St Apt 3A</span>
<span class="address-content">Bloomsburg, PA 12345</span>
</a>
</div>
<div class="address-item">
<a href="#">
<span class="address-header">John Doe</span>
<span class="address-content">78 West Main St Apt 3A</span>
<span class="address-content">Bloomsburg, PA 12345</span>
</a>
<div class="menuElement">
<div><a href="#">Ada</a></div>
<div><a href="#">Saarland</a></div>
<div><a href="#">Salzburg</a></div>
</div>
</div>
</div>
<div class="ui-widget" style="clear: left; margin-top:2em; font-family:Arial"> <div class="ui-widget" style="clear: left; margin-top:2em; font-family:Arial">
Log: Log:
<div id="log" style="height: 400px; width: 300px; overflow: auto;" class="ui-widget-content"></div> <div id="log" style="height: 400px; width: 300px; overflow: auto;" class="ui-widget-content"></div>

View File

@ -2,19 +2,19 @@
/* Written by Istvan Karaszi (jquery@spam.raszi.hu). */ /* Written by Istvan Karaszi (jquery@spam.raszi.hu). */
jQuery(function($){ jQuery(function($){
$.datepicker.regional['hu'] = { $.datepicker.regional['hu'] = {
closeText: 'bezárás', closeText: 'bezár',
prevText: '&#xAB;&#xA0;vissza', prevText: 'vissza',
nextText: 'előre&#xA0;&#xBB;', nextText: 'előre',
currentText: 'ma', currentText: 'ma',
monthNames: ['Január', 'Február', 'Március', 'Április', 'Május', 'Június', monthNames: ['Január', 'Február', 'Március', 'Április', 'Május', 'Június',
'Július', 'Augusztus', 'Szeptember', 'Október', 'November', 'December'], 'Július', 'Augusztus', 'Szeptember', 'Október', 'November', 'December'],
monthNamesShort: ['Jan', 'Feb', 'Már', 'Ápr', 'Máj', 'Jún', monthNamesShort: ['Jan', 'Feb', 'Már', 'Ápr', 'Máj', 'Jún',
'Júl', 'Aug', 'Szep', 'Okt', 'Nov', 'Dec'], 'Júl', 'Aug', 'Szep', 'Okt', 'Nov', 'Dec'],
dayNames: ['Vasárnap', 'Hétfö', 'Kedd', 'Szerda', 'Csütörtök', 'Péntek', 'Szombat'], dayNames: ['Vasárnap', 'Hétfő', 'Kedd', 'Szerda', 'Csütörtök', 'Péntek', 'Szombat'],
dayNamesShort: ['Vas', 'Hét', 'Ked', 'Sze', 'Csü', 'Pén', 'Szo'], dayNamesShort: ['Vas', 'Hét', 'Ked', 'Sze', 'Csü', 'Pén', 'Szo'],
dayNamesMin: ['V', 'H', 'K', 'Sze', 'Cs', 'P', 'Szo'], dayNamesMin: ['V', 'H', 'K', 'Sze', 'Cs', 'P', 'Szo'],
weekHeader: 'Hé', weekHeader: 'Hét',
dateFormat: 'yy-mm-dd', dateFormat: 'yy.mm.dd.',
firstDay: 1, firstDay: 1,
isRTL: false, isRTL: false,
showMonthAfterYear: true, showMonthAfterYear: true,

View File

@ -51,7 +51,7 @@ $.widget( "ui.autocomplete", {
suppressKeyPress, suppressKeyPress,
suppressInput; suppressInput;
this.valueMethod = this.element[ this.element.is( "input" ) ? "val" : "text" ]; this.valueMethod = this.element[ this.element.is( "input,textarea" ) ? "val" : "text" ];
this.element this.element
.addClass( "ui-autocomplete-input" ) .addClass( "ui-autocomplete-input" )
@ -325,6 +325,7 @@ $.widget( "ui.autocomplete", {
_searchTimeout: function( event ) { _searchTimeout: function( event ) {
var self = this; var self = this;
clearTimeout( self.searching );
self.searching = setTimeout(function() { self.searching = setTimeout(function() {
// only search if the value has changed // only search if the value has changed
if ( self.term != self.element.val() ) { if ( self.term != self.element.val() ) {

View File

@ -379,7 +379,7 @@ $.widget( "ui.buttonset", {
}, },
refresh: function() { refresh: function() {
var ltr = this.element.css( "direction" ) === "ltr"; var rtl = this.element.css( "direction" ) === "rtl";
this.buttons = this.element.find( this.options.items ) this.buttons = this.element.find( this.options.items )
.filter( ":ui-button" ) .filter( ":ui-button" )
@ -393,10 +393,10 @@ $.widget( "ui.buttonset", {
}) })
.removeClass( "ui-corner-all ui-corner-left ui-corner-right" ) .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
.filter( ":first" ) .filter( ":first" )
.addClass( ltr ? "ui-corner-left" : "ui-corner-right" ) .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
.end() .end()
.filter( ":last" ) .filter( ":last" )
.addClass( ltr ? "ui-corner-right" : "ui-corner-left" ) .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
.end() .end()
.end(); .end();
}, },

View File

@ -636,10 +636,10 @@ $.extend(Datepicker.prototype, {
return; return;
var inst = $.datepicker._getInst(input); var inst = $.datepicker._getInst(input);
if ($.datepicker._curInst && $.datepicker._curInst != inst) { if ($.datepicker._curInst && $.datepicker._curInst != inst) {
if ( $.datepicker._datepickerShowing ) {
$.datepicker._triggerOnClose($.datepicker._curInst);
}
$.datepicker._curInst.dpDiv.stop(true, true); $.datepicker._curInst.dpDiv.stop(true, true);
if ( inst && $.datepicker._datepickerShowing ) {
$.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
}
} }
var beforeShow = $.datepicker._get(inst, 'beforeShow'); var beforeShow = $.datepicker._get(inst, 'beforeShow');
var beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {}; var beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
@ -790,14 +790,6 @@ $.extend(Datepicker.prototype, {
return [position.left, position.top]; return [position.left, position.top];
}, },
/* Trigger custom callback of onClose. */
_triggerOnClose: function(inst) {
var onClose = this._get(inst, 'onClose');
if (onClose)
onClose.apply((inst.input ? inst.input[0] : null),
[(inst.input ? inst.input.val() : ''), inst]);
},
/* Hide the date picker from view. /* Hide the date picker from view.
@param input element - the input field attached to the date picker */ @param input element - the input field attached to the date picker */
_hideDatepicker: function(input) { _hideDatepicker: function(input) {
@ -820,8 +812,11 @@ $.extend(Datepicker.prototype, {
(showAnim == 'fadeIn' ? 'fadeOut' : 'hide'))]((showAnim ? duration : null), postProcess); (showAnim == 'fadeIn' ? 'fadeOut' : 'hide'))]((showAnim ? duration : null), postProcess);
if (!showAnim) if (!showAnim)
postProcess(); postProcess();
$.datepicker._triggerOnClose(inst);
this._datepickerShowing = false; this._datepickerShowing = false;
var onClose = this._get(inst, 'onClose');
if (onClose)
onClose.apply((inst.input ? inst.input[0] : null),
[(inst.input ? inst.input.val() : ''), inst]);
this._lastInput = null; this._lastInput = null;
if (this._inDialog) { if (this._inDialog) {
this._dialogInput.css({ position: 'absolute', left: '0', top: '-100px' }); this._dialogInput.css({ position: 'absolute', left: '0', top: '-100px' });
@ -843,12 +838,16 @@ $.extend(Datepicker.prototype, {
_checkExternalClick: function(event) { _checkExternalClick: function(event) {
if (!$.datepicker._curInst) if (!$.datepicker._curInst)
return; return;
var $target = $(event.target);
if ($target[0].id != $.datepicker._mainDivId && var $target = $(event.target),
inst = $.datepicker._getInst($target[0]);
if ( ( ( $target[0].id != $.datepicker._mainDivId &&
$target.parents('#' + $.datepicker._mainDivId).length == 0 && $target.parents('#' + $.datepicker._mainDivId).length == 0 &&
!$target.hasClass($.datepicker.markerClassName) && !$target.hasClass($.datepicker.markerClassName) &&
!$target.hasClass($.datepicker._triggerClass) && !$target.hasClass($.datepicker._triggerClass) &&
$.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI)) $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst != inst ) )
$.datepicker._hideDatepicker(); $.datepicker._hideDatepicker();
}, },

View File

@ -293,7 +293,7 @@ $.widget("ui.dialog", {
// prevent tabbing out of modal dialogs // prevent tabbing out of modal dialogs
if ( options.modal ) { if ( options.modal ) {
uiDialog.bind( "keypress.ui-dialog", function( event ) { uiDialog.bind( "keydown.ui-dialog", function( event ) {
if ( event.keyCode !== $.ui.keyCode.TAB ) { if ( event.keyCode !== $.ui.keyCode.TAB ) {
return; return;
} }

166
ui/jquery.ui.menu.js vendored
View File

@ -20,13 +20,13 @@ $.widget( "ui.menu", {
defaultElement: "<ul>", defaultElement: "<ul>",
delay: 150, delay: 150,
options: { options: {
items: "ul",
position: { position: {
my: "left top", my: "left top",
at: "right top" at: "right top"
} }
}, },
_create: function() { _create: function() {
var self = this;
this.activeMenu = this.element; this.activeMenu = this.element;
this.menuId = this.element.attr( "id" ) || "ui-menu-" + idIncrement++; this.menuId = this.element.attr( "id" ) || "ui-menu-" + idIncrement++;
if ( this.element.find( ".ui-icon" ).length ) { if ( this.element.find( ".ui-icon" ).length ) {
@ -40,11 +40,11 @@ $.widget( "ui.menu", {
}) })
// need to catch all clicks on disabled menu // need to catch all clicks on disabled menu
// not possible through _bind // not possible through _bind
.bind( "click.menu", function( event ) { .bind( "click.menu", $.proxy( function( event ) {
if ( self.options.disabled ) { if ( this.options.disabled ) {
event.preventDefault(); event.preventDefault();
} }
}); }, this));
this._bind({ this._bind({
"click .ui-menu-item:has(a)": function( event ) { "click .ui-menu-item:has(a)": function( event ) {
event.stopImmediatePropagation(); event.stopImmediatePropagation();
@ -62,85 +62,92 @@ $.widget( "ui.menu", {
target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" ); target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
this.focus( event, target ); this.focus( event, target );
}, },
"mouseleave": "collapseAll",
"mouseleave .ui-menu": "collapseAll",
"mouseout .ui-menu-item": "blur", "mouseout .ui-menu-item": "blur",
"focus": function( event ) { "focus": function( event ) {
this.focus( event, $( event.target ).children( ".ui-menu-item:first" ) ); this.focus( event, $( event.target ).children( ".ui-menu-item:first" ) );
}, },
"blur": "collapseAll" blur: function( event ) {
this._delay( function() {
if ( ! $.contains( this.element[0], document.activeElement ) ) {
this.collapseAll( event );
}
}, 0);
}
}); });
this.refresh(); this.refresh();
this.element.attr( "tabIndex", 0 ).bind( "keydown.menu", function( event ) { this.element.attr( "tabIndex", 0 );
if ( self.options.disabled ) { this._bind({
return; "keydown": function( event ) {
}
switch ( event.keyCode ) { switch ( event.keyCode ) {
case $.ui.keyCode.PAGE_UP: case $.ui.keyCode.PAGE_UP:
self.previousPage( event ); this.previousPage( event );
event.preventDefault(); event.preventDefault();
event.stopImmediatePropagation(); event.stopImmediatePropagation();
break; break;
case $.ui.keyCode.PAGE_DOWN: case $.ui.keyCode.PAGE_DOWN:
self.nextPage( event ); this.nextPage( event );
event.preventDefault(); event.preventDefault();
event.stopImmediatePropagation(); event.stopImmediatePropagation();
break; break;
case $.ui.keyCode.HOME: case $.ui.keyCode.HOME:
self._move( "first", "first", event ); this._move( "first", "first", event );
event.preventDefault(); event.preventDefault();
event.stopImmediatePropagation(); event.stopImmediatePropagation();
break; break;
case $.ui.keyCode.END: case $.ui.keyCode.END:
self._move( "last", "last", event ); this._move( "last", "last", event );
event.preventDefault(); event.preventDefault();
event.stopImmediatePropagation(); event.stopImmediatePropagation();
break; break;
case $.ui.keyCode.UP: case $.ui.keyCode.UP:
self.previous( event ); this.previous( event );
event.preventDefault(); event.preventDefault();
event.stopImmediatePropagation(); event.stopImmediatePropagation();
break; break;
case $.ui.keyCode.DOWN: case $.ui.keyCode.DOWN:
self.next( event ); this.next( event );
event.preventDefault(); event.preventDefault();
event.stopImmediatePropagation(); event.stopImmediatePropagation();
break; break;
case $.ui.keyCode.LEFT: case $.ui.keyCode.LEFT:
if (self.collapse( event )) { if (this.collapse( event )) {
event.stopImmediatePropagation(); event.stopImmediatePropagation();
} }
event.preventDefault(); event.preventDefault();
break; break;
case $.ui.keyCode.RIGHT: case $.ui.keyCode.RIGHT:
if (self.expand( event )) { if (this.expand( event )) {
event.stopImmediatePropagation(); event.stopImmediatePropagation();
} }
event.preventDefault(); event.preventDefault();
break; break;
case $.ui.keyCode.ENTER: case $.ui.keyCode.ENTER:
if ( self.active.children( "a[aria-haspopup='true']" ).length ) { if ( this.active.children( "a[aria-haspopup='true']" ).length ) {
if ( self.expand( event ) ) { if ( this.expand( event ) ) {
event.stopImmediatePropagation(); event.stopImmediatePropagation();
} }
} }
else { else {
self.select( event ); this.select( event );
event.stopImmediatePropagation(); event.stopImmediatePropagation();
} }
event.preventDefault(); event.preventDefault();
break; break;
case $.ui.keyCode.ESCAPE: case $.ui.keyCode.ESCAPE:
if ( self.collapse( event ) ) { if ( this.collapse( event ) ) {
event.stopImmediatePropagation(); event.stopImmediatePropagation();
} }
event.preventDefault(); event.preventDefault();
break; break;
default: default:
event.stopPropagation(); event.stopPropagation();
clearTimeout( self.filterTimer ); clearTimeout( this.filterTimer );
var match, var match,
prev = self.previousFilter || "", prev = this.previousFilter || "",
character = String.fromCharCode( event.keyCode ), character = String.fromCharCode( event.keyCode ),
skip = false; skip = false;
@ -152,30 +159,31 @@ $.widget( "ui.menu", {
function escape( value ) { function escape( value ) {
return value.replace( /[-[\]{}()*+?.,\\^$|#\s]/g , "\\$&" ); return value.replace( /[-[\]{}()*+?.,\\^$|#\s]/g , "\\$&" );
} }
match = self.activeMenu.children( ".ui-menu-item" ).filter( function() { match = this.activeMenu.children( ".ui-menu-item" ).filter( function() {
return new RegExp("^" + escape(character), "i") return new RegExp("^" + escape(character), "i")
.test( $( this ).children( "a" ).text() ); .test( $( this ).children( "a" ).text() );
}); });
match = skip && match.index(self.active.next()) != -1 ? self.active.nextAll(".ui-menu-item") : match; match = skip && match.index(this.active.next()) != -1 ? this.active.nextAll(".ui-menu-item") : match;
if ( !match.length ) { if ( !match.length ) {
character = String.fromCharCode(event.keyCode); character = String.fromCharCode(event.keyCode);
match = self.activeMenu.children(".ui-menu-item").filter( function() { match = this.activeMenu.children(".ui-menu-item").filter( function() {
return new RegExp("^" + escape(character), "i") return new RegExp("^" + escape(character), "i")
.test( $( this ).children( "a" ).text() ); .test( $( this ).children( "a" ).text() );
}); });
} }
if ( match.length ) { if ( match.length ) {
self.focus( event, match ); this.focus( event, match );
if (match.length > 1) { if (match.length > 1) {
self.previousFilter = character; this.previousFilter = character;
self.filterTimer = setTimeout( function() { this.filterTimer = this._delay( function() {
delete self.previousFilter; delete this.previousFilter;
}, 1000 ); }, 1000 );
} else { } else {
delete self.previousFilter; delete this.previousFilter;
} }
} else { } else {
delete self.previousFilter; delete this.previousFilter;
}
} }
} }
}); });
@ -193,7 +201,7 @@ $.widget( "ui.menu", {
//destroy (sub)menus //destroy (sub)menus
this.element this.element
.removeAttr( "aria-activedescendant" ) .removeAttr( "aria-activedescendant" )
.find( "ul" ) .find( ".ui-menu" )
.andSelf() .andSelf()
.removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all" ) .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
.removeAttr( "role" ) .removeAttr( "role" )
@ -219,27 +227,25 @@ $.widget( "ui.menu", {
}, },
refresh: function() { refresh: function() {
var self = this,
// initialize nested menus // initialize nested menus
submenus = this.element.find( "ul:not(.ui-menu)" ) var submenus = this.element.find( this.options.items + ":not( .ui-menu )" )
.addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" ) .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
.attr( "role", "menu" ) .attr( "role", "menu" )
.hide() .hide()
.attr( "aria-hidden", "true" ) .attr( "aria-hidden", "true" )
.attr( "aria-expanded", "false" ), .attr( "aria-expanded", "false" );
// don't refresh list items that are already adapted // don't refresh list items that are already adapted
items = submenus.add( this.element ).children( "li:not(.ui-menu-item):has(a)" ) var menuId = this.menuId;
submenus.add( this.element ).children( ":not( .ui-menu-item ):has( a )" )
.addClass( "ui-menu-item" ) .addClass( "ui-menu-item" )
.attr( "role", "presentation" ); .attr( "role", "presentation" )
.children( "a" )
items.children( "a" )
.addClass( "ui-corner-all" ) .addClass( "ui-corner-all" )
.attr( "tabIndex", -1 ) .attr( "tabIndex", -1 )
.attr( "role", "menuitem" ) .attr( "role", "menuitem" )
.attr( "id", function( i ) { .attr( "id", function( i ) {
return self.element.attr( "id" ) + "-" + i; return menuId + "-" + i;
}); });
submenus.each( function() { submenus.each( function() {
@ -253,9 +259,6 @@ $.widget( "ui.menu", {
}, },
focus: function( event, item ) { focus: function( event, item ) {
var nested,
self = this;
this.blur( event ); this.blur( event );
if ( this._hasScroll() ) { if ( this._hasScroll() ) {
@ -277,18 +280,18 @@ $.widget( "ui.menu", {
.children( "a" ) .children( "a" )
.addClass( "ui-state-focus" ) .addClass( "ui-state-focus" )
.end(); .end();
self.element.attr( "aria-activedescendant", self.active.children("a").attr("id") ); this.element.attr( "aria-activedescendant", this.active.children( "a" ).attr( "id" ) );
// highlight active parent menu item, if any // highlight active parent menu item, if any
this.active.parent().closest( ".ui-menu-item" ).children( "a:first" ).addClass( "ui-state-active" ); this.active.parent().closest( ".ui-menu-item" ).children( "a:first" ).addClass( "ui-state-active" );
self.timer = setTimeout( function() { this.timer = this._delay( function() {
self._close(); this._close();
}, self.delay ); }, this.delay );
nested = $( ">ul", item ); var nested = $( "> .ui-menu", item );
if ( nested.length && ( /^mouse/.test( event.type ) ) ) { if ( nested.length && ( /^mouse/.test( event.type ) ) ) {
self._startOpening(nested); this._startOpening(nested);
} }
this.activeMenu = item.parent(); this.activeMenu = item.parent();
@ -317,11 +320,10 @@ $.widget( "ui.menu", {
return; return;
} }
var self = this; this.timer = this._delay( function() {
self.timer = setTimeout( function() { this._close();
self._close(); this._open( submenu );
self._open( submenu ); }, this.delay );
}, self.delay );
}, },
_open: function( submenu ) { _open: function( submenu ) {
@ -345,23 +347,32 @@ $.widget( "ui.menu", {
.position( position ); .position( position );
}, },
collapseAll: function( event ) { collapseAll: function( event, all ) {
this.element
.find( "ul" ) // if we were passed an event, look for the submenu that contains the event
.hide() var currentMenu = all ? this.element :
.attr( "aria-hidden", "true" ) $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
.attr( "aria-expanded", "false" )
.end() // if we found no valid submenu ancestor, use the main menu to close all sub menus anyway
.find( "a.ui-state-active" ) if ( !currentMenu.length ) {
.removeClass( "ui-state-active" ); currentMenu = this.element;
}
this._close( currentMenu );
this.blur( event ); this.blur( event );
this.activeMenu = this.element; this.activeMenu = currentMenu;
}, },
_close: function() { // With no arguments, closes the currently active menu - if nothing is active
this.active.parent() // it closes all menus. If passed an argument, it will search for menus BELOW
.find( "ul" ) _close: function( startMenu ) {
if ( !startMenu ) {
startMenu = this.active ? this.active.parent() : this.element;
}
startMenu
.find( ".ui-menu" )
.hide() .hide()
.attr( "aria-hidden", "true" ) .attr( "aria-hidden", "true" )
.attr( "aria-expanded", "false" ) .attr( "aria-expanded", "false" )
@ -371,27 +382,23 @@ $.widget( "ui.menu", {
}, },
collapse: function( event ) { collapse: function( event ) {
var newItem = this.active && this.active.parents("li:not(.ui-menubar-item)").first(); var newItem = this.active && this.active.parent().closest( ".ui-menu-item", this.element );
if ( newItem && newItem.length ) { if ( newItem && newItem.length ) {
this.active.parent() this._close();
.attr("aria-hidden", "true")
.attr("aria-expanded", "false")
.hide();
this.focus( event, newItem ); this.focus( event, newItem );
return true; return true;
} }
}, },
expand: function( event ) { expand: function( event ) {
var self = this, var newItem = this.active && this.active.children( ".ui-menu " ).children( ".ui-menu-item" ).first();
newItem = this.active && this.active.children("ul").children("li").first();
if ( newItem && newItem.length ) { if ( newItem && newItem.length ) {
this._open( newItem.parent() ); this._open( newItem.parent() );
//timeout so Firefox will not hide activedescendant change in expanding submenu from AT //timeout so Firefox will not hide activedescendant change in expanding submenu from AT
setTimeout( function() { this._delay( function() {
self.focus( event, newItem ); this.focus( event, newItem );
}, 20 ); }, 20 );
return true; return true;
} }
@ -487,11 +494,12 @@ $.widget( "ui.menu", {
}, },
select: function( event ) { select: function( event ) {
// save active reference before collapseAll triggers blur // save active reference before collapseAll triggers blur
var ui = { var ui = {
item: this.active item: this.active
}; };
this.collapseAll( event ); this.collapseAll( event, true );
this._trigger( "select", event, ui ); this._trigger( "select", event, ui );
} }
}); });

46
ui/jquery.ui.popup.js vendored
View File

@ -22,6 +22,14 @@ $.widget( "ui.popup", {
position: { position: {
my: "left top", my: "left top",
at: "left bottom" at: "left bottom"
},
show: {
effect: "slideDown",
duration: "fast"
},
hide: {
effect: "fadeOut",
duration: "fast"
} }
}, },
_create: function() { _create: function() {
@ -45,13 +53,14 @@ $.widget( "ui.popup", {
.attr( "aria-owns", this.element.attr( "id" ) ); .attr( "aria-owns", this.element.attr( "id" ) );
this.element this.element
.addClass( "ui-popup" ) .addClass( "ui-popup" );
this.close(); this._beforeClose();
this.element.hide();
this._bind(this.options.trigger, { this._bind(this.options.trigger, {
keydown: function( event ) { keydown: function( event ) {
// prevent space-to-open to scroll the page, only happens for anchor ui.button // prevent space-to-open to scroll the page, only happens for anchor ui.button
if ( this.options.trigger.is( "a:ui-button" ) && event.keyCode == $.ui.keyCode.SPACE ) { if ( $.ui.button && this.options.trigger.is( "a:ui-button" ) && event.keyCode == $.ui.keyCode.SPACE ) {
event.preventDefault(); event.preventDefault();
} }
// TODO handle SPACE to open popup? only when not handled by ui.button // TODO handle SPACE to open popup? only when not handled by ui.button
@ -72,15 +81,14 @@ $.widget( "ui.popup", {
// let it propagate to close // let it propagate to close
return; return;
} }
var that = this;
clearTimeout( this.closeTimer ); clearTimeout( this.closeTimer );
setTimeout(function() { this._delay(function() {
that.open( event ); this.open( event );
}, 1); }, 1);
} }
}); });
if ( !this.element.is( ":ui-menu" ) ) { if ( !$.ui.menu || !this.element.is( ":ui-menu" ) ) {
// default use case, wrap tab order in popup // default use case, wrap tab order in popup
this._bind({ keydown : function( event ) { this._bind({ keydown : function( event ) {
if ( event.keyCode !== $.ui.keyCode.TAB ) { if ( event.keyCode !== $.ui.keyCode.TAB ) {
@ -102,11 +110,10 @@ $.widget( "ui.popup", {
this._bind({ this._bind({
focusout: function( event ) { focusout: function( event ) {
var that = this;
// use a timer to allow click to clear it and letting that // use a timer to allow click to clear it and letting that
// handle the closing instead of opening again // handle the closing instead of opening again
that.closeTimer = setTimeout( function() { this.closeTimer = this._delay( function() {
that.close( event ); this.close( event );
}, 100); }, 100);
}, },
focusin: function( event ) { focusin: function( event ) {
@ -133,7 +140,7 @@ $.widget( "ui.popup", {
this.close( event ); this.close( event );
} }
} }
}) });
}, },
_destroy: function() { _destroy: function() {
@ -161,13 +168,14 @@ $.widget( "ui.popup", {
of: this.options.trigger of: this.options.trigger
}, this.options.position ); }, this.options.position );
this._show( this.element, this.options.show );
this.element this.element
.show()
.attr( "aria-hidden", "false" ) .attr( "aria-hidden", "false" )
.attr( "aria-expanded", "true" ) .attr( "aria-expanded", "true" )
.position( position ); .position( position );
if (this.element.is( ":ui-menu" )) { //popup is a menu // can't use custom selector when menu isn't loaded
if ( $.ui.menu && this.element.is( ":ui-menu" ) ) {
this.element.menu( "focus", event, this.element.children( "li" ).first() ); this.element.menu( "focus", event, this.element.children( "li" ).first() );
this.element.focus(); this.element.focus();
} else { } else {
@ -192,10 +200,8 @@ $.widget( "ui.popup", {
}, },
close: function( event ) { close: function( event ) {
this.element this._beforeClose();
.hide() this._hide( this.element, this.options.hide );
.attr( "aria-hidden", "true" )
.attr( "aria-expanded", "false" );
this.options.trigger.attr( "tabindex" , 0 ); this.options.trigger.attr( "tabindex" , 0 );
if ( this.removeTabIndex ) { if ( this.removeTabIndex ) {
@ -203,6 +209,12 @@ $.widget( "ui.popup", {
} }
this.isOpen = false; this.isOpen = false;
this._trigger( "close", event ); this._trigger( "close", event );
},
_beforeClose: function() {
this.element
.attr( "aria-hidden", "true" )
.attr( "aria-expanded", "false" );
} }
}); });

View File

@ -376,7 +376,7 @@ $.ui.position = {
newOverBottom; newOverBottom;
if ( overTop < 0 ) { if ( overTop < 0 ) {
newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset; newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
if ( newOverBottom < 0 || newOverBottom < Math.abs( overTop ) ) { if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < Math.abs( overTop ) ) ) {
data.elem data.elem
.addClass( "ui-flipped-bottom" ); .addClass( "ui-flipped-bottom" );
@ -385,7 +385,7 @@ $.ui.position = {
} }
else if ( overBottom > 0 ) { else if ( overBottom > 0 ) {
newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - withinOffset; newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - withinOffset;
if ( newOverTop > 0 || Math.abs( newOverTop ) < overBottom ) { if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || Math.abs( newOverTop ) < overBottom ) ) {
data.elem data.elem
.addClass( "ui-flipped-top" ); .addClass( "ui-flipped-top" );

View File

@ -10,6 +10,7 @@
* Depends: * Depends:
* jquery.ui.core.js * jquery.ui.core.js
* jquery.ui.widget.js * jquery.ui.widget.js
* jquery.ui.button.js
*/ */
(function( $ ) { (function( $ ) {
@ -30,8 +31,8 @@ $.widget( "ui.spinner", {
widgetEventPrefix: "spin", widgetEventPrefix: "spin",
options: { options: {
incremental: true, incremental: true,
max: Number.MAX_VALUE, max: null,
min: -Number.MAX_VALUE, min: null,
numberFormat: null, numberFormat: null,
page: 10, page: 10,
step: 1, step: 1,
@ -147,6 +148,12 @@ $.widget( "ui.spinner", {
.button() .button()
.removeClass( "ui-corner-all" ); .removeClass( "ui-corner-all" );
// IE 6 doesn't understand height: 50% for the buttons
// unless the wrapper has an explicit height
if ( this.buttons.height() === uiSpinner.height() && uiSpinner.height() > 0 ) {
uiSpinner.height( uiSpinner.height() );
}
// disable spinner if element was already disabled // disable spinner if element was already disabled
if ( this.options.disabled ) { if ( this.options.disabled ) {
this.disable(); this.disable();
@ -202,56 +209,78 @@ $.widget( "ui.spinner", {
}, },
_repeat: function( i, steps, event ) { _repeat: function( i, steps, event ) {
var that = this;
i = i || 500; i = i || 500;
clearTimeout( this.timer ); clearTimeout( this.timer );
this.timer = setTimeout(function() { this.timer = this._delay(function() {
that._repeat( 40, steps, event ); this._repeat( 40, steps, event );
}, i ); }, i );
this._spin( steps * this.options.step, event ); this._spin( steps * this.options.step, event );
}, },
_spin: function( step, event ) { _spin: function( step, event ) {
var value = this.value() || 0;
if ( !this.counter ) { if ( !this.counter ) {
this.counter = 1; this.counter = 1;
} }
var value = this.value(), value = this._adjustValue( value + step * this._increment( this.counter ) );
newVal = value + step * this._increment( this.counter ),
// fix precision from bad JS floating point math
precision = Math.max( this._precision( value ),
this._precision( this.options.step ) );
// clamp the new value
newVal = this._trimValue( newVal.toFixed( precision ) );
if ( !this.spinning || this._trigger( "spin", event, { value: newVal } ) !== false) { if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false) {
this._value( newVal ); this._value( value );
this.counter++; this.counter++;
} }
}, },
_increment: function( i ) { _increment: function( i ) {
return this.options.incremental ? var incremental = this.options.incremental;
Math.floor( i*i*i/50000 - i*i/500 + 17*i/200 + 1 ) :
1; if ( incremental ) {
return $.isFunction( incremental ) ?
incremental( i ) :
Math.floor( i*i*i/50000 - i*i/500 + 17*i/200 + 1 );
}
return 1;
}, },
_precision: function( num ) { _precision: function() {
var precision = this._precisionOf( this.options.step );
if ( this.options.min !== null ) {
precision = Math.max( precision, this._precisionOf( this.options.min ) );
}
return precision;
},
_precisionOf: function( num ) {
var str = num.toString(), var str = num.toString(),
decimal = str.indexOf( "." ); decimal = str.indexOf( "." );
return decimal === -1 ? 0 : str.length - decimal - 1; return decimal === -1 ? 0 : str.length - decimal - 1;
}, },
_trimValue: function( value ) { _adjustValue: function( value ) {
var options = this.options; var base, aboveMin,
options = this.options;
if ( value > options.max) { // make sure we're at a valid step
// - find out where we are relative to the base (min or 0)
base = options.min !== null ? options.min : 0;
aboveMin = value - base;
// - round to the nearest step
aboveMin = Math.round(aboveMin / options.step) * options.step;
// - rounding is based on 0, so adjust back to our base
value = base + aboveMin;
// fix precision from bad JS floating point math
value = parseFloat( value.toFixed( this._precision() ) );
// clamp the value
if ( options.max !== null && value > options.max) {
return options.max; return options.max;
} }
if ( options.min !== null && value < options.min ) {
if ( value < options.min ) {
return options.min; return options.min;
} }
@ -290,10 +319,10 @@ $.widget( "ui.spinner", {
}), }),
_parse: function( val ) { _parse: function( val ) {
if ( typeof val === "string" ) { if ( typeof val === "string" && val !== "" ) {
val = window.Globalize && this.options.numberFormat ? Globalize.parseFloat( val ) : +val; val = window.Globalize && this.options.numberFormat ? Globalize.parseFloat( val ) : +val;
} }
return isNaN( val ) ? null : val; return val === "" || isNaN( val ) ? null : val;
}, },
_format: function( value ) { _format: function( value ) {
@ -315,13 +344,13 @@ $.widget( "ui.spinner", {
}, },
// update the value without triggering change // update the value without triggering change
_value: function( value, ignoreRange ) { _value: function( value, allowAny ) {
var parsed; var parsed;
if ( value !== "" ) { if ( value !== "" ) {
parsed = this._parse( value ); parsed = this._parse( value );
if ( parsed !== null ) { if ( parsed !== null ) {
if ( !ignoreRange ) { if ( !allowAny ) {
parsed = this._trimValue( parsed ); parsed = this._adjustValue( parsed );
} }
value = this._format( parsed ); value = this._format( parsed );
} }

View File

@ -25,7 +25,7 @@ var isLocal = (function() {
return function( anchor ) { return function( anchor ) {
// clone the node to work around IE 6 not normalizing the href property // clone the node to work around IE 6 not normalizing the href property
// if it's manually set, i.e., a.href = "#foo" kills the normalization // if it's manually set, i.e., a.href = "#foo" kills the normalization
anchor = anchor.cloneNode(); anchor = anchor.cloneNode( false );
return anchor.hash.length > 1 && return anchor.hash.length > 1 &&
anchor.href.replace( rhash, "" ) === currentPage; anchor.href.replace( rhash, "" ) === currentPage;
}; };
@ -792,11 +792,14 @@ if ( $.uiBackCompat !== false ) {
index = this._getIndex( index ); index = this._getIndex( index );
var options = this.options, var options = this.options,
tab = this.lis.eq( index ).remove(), tab = this.lis.eq( index ).remove(),
panel = this.panels.eq( index ).remove(); panel = this._getPanelForTab( tab.find( "a[aria-controls]" ) ).remove();
// If selected tab was removed focus tab to the right or // If selected tab was removed focus tab to the right or
// in case the last tab was removed the tab to the left. // in case the last tab was removed the tab to the left.
if ( tab.hasClass( "ui-tabs-active" ) && this.anchors.length > 1) { // We check for more than 2 tabs, because if there are only 2,
// then when we remove this tab, there will only be one tab left
// so we don't need to detect which tab to activate.
if ( tab.hasClass( "ui-tabs-active" ) && this.anchors.length > 2 ) {
this._activate( index + ( index + 1 < this.anchors.length ? 1 : -1 ) ); this._activate( index + ( index + 1 < this.anchors.length ? 1 : -1 ) );
} }

View File

@ -27,7 +27,7 @@ $.widget( "ui.tooltip", {
position: { position: {
my: "left+15 center", my: "left+15 center",
at: "right center", at: "right center",
collision: "flip fit" collision: "flipfit flipfit"
}, },
show: true, show: true,
tooltipClass: null, tooltipClass: null,

View File

@ -270,9 +270,9 @@ $.Widget.prototype = {
return this; return this;
}, },
_setOptions: function( options ) { _setOptions: function( options ) {
var self = this; var that = this;
$.each( options, function( key, value ) { $.each( options, function( key, value ) {
self._setOption( key, value ); that._setOption( key, value );
}); });
return this; return this;
@ -333,6 +333,15 @@ $.Widget.prototype = {
}); });
}, },
_delay: function( handler, delay ) {
function handlerProxy() {
return ( typeof handler === "string" ? instance[ handler ] : handler )
.apply( instance, arguments );
}
var instance = this;
return setTimeout( handlerProxy, delay || 0 );
},
_hoverable: function( element ) { _hoverable: function( element ) {
this.hoverable = this.hoverable.add( element ); this.hoverable = this.hoverable.add( element );
this._bind( element, { this._bind( element, {