mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Merge branch 'master' of github.com:jquery/jquery-ui into selectmenu
This commit is contained in:
commit
55184e1e07
84
demos/popup/animation.html
Normal file
84
demos/popup/animation.html
Normal 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>
|
@ -9,7 +9,6 @@
|
||||
<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.ui.menu.js"></script>
|
||||
<script src="../../ui/jquery.ui.popup.js"></script>
|
||||
<script>
|
||||
$(function() {
|
||||
@ -28,17 +27,6 @@
|
||||
</script>
|
||||
<style type="text/css">
|
||||
.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 {
|
||||
width: 16em; border: 1px solid gray; border-radius: 5px;
|
||||
|
@ -10,6 +10,7 @@
|
||||
<h4>Examples</h4>
|
||||
<ul>
|
||||
<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-table.html">Menu's as popup in a table</a></li>
|
||||
</ul>
|
||||
|
@ -14,6 +14,7 @@
|
||||
<style>
|
||||
#parent {
|
||||
width: 60%;
|
||||
height: 40px;
|
||||
margin: 10px auto;
|
||||
padding: 5px;
|
||||
border: 1px solid #777;
|
||||
@ -21,8 +22,6 @@
|
||||
text-align: center;
|
||||
}
|
||||
.positionable {
|
||||
width: 75px;
|
||||
height: 75px;
|
||||
position: absolute;
|
||||
display: block;
|
||||
right: 0;
|
||||
@ -30,6 +29,14 @@
|
||||
background-color: #bcd5e6;
|
||||
text-align: center;
|
||||
}
|
||||
#positionable1 {
|
||||
width: 75px;
|
||||
height: 75px;
|
||||
}
|
||||
#positionable2 {
|
||||
width: 120px;
|
||||
height: 40px;
|
||||
}
|
||||
.ui-flipped-top {
|
||||
border-top: 3px solid #000000;
|
||||
}
|
||||
@ -93,13 +100,13 @@
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="positionable">
|
||||
<div class="positionable" id="positionable1">
|
||||
<p>
|
||||
to position
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="positionable" style="width:120px; height: 40px;">
|
||||
<div class="positionable" id="positionable2">
|
||||
<p>
|
||||
to position 2
|
||||
</p>
|
||||
|
@ -21,8 +21,9 @@
|
||||
map.setCenter( latlong() );
|
||||
}
|
||||
$( "#lat, #lng" ).spinner({
|
||||
precision: 6,
|
||||
change: position
|
||||
step: .001,
|
||||
change: position,
|
||||
stop: position
|
||||
});
|
||||
|
||||
var map = new google.maps.Map( $("#map")[0], {
|
||||
@ -44,10 +45,10 @@
|
||||
<div class="demo">
|
||||
|
||||
<label for="lat">Latitude</label>
|
||||
<input id="lat" name="lat" value="44.797916">
|
||||
<input id="lat" name="lat" value="44.797">
|
||||
<br>
|
||||
<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>
|
||||
|
||||
|
@ -39,6 +39,7 @@
|
||||
<div id="ac-wrap1" class="ac-wrap"></div>
|
||||
<div id="ac-wrap2" class="ac-wrap"><input id="autocomplete" class="foo"></div>
|
||||
<div id="autocomplete-contenteditable" contenteditable="" tabindex=0></div>
|
||||
<textarea id="autocomplete-textarea"></textarea>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
|
@ -4,9 +4,26 @@ module( "autocomplete: events" );
|
||||
|
||||
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 );
|
||||
var element = $( "#autocomplete" )
|
||||
var element = $( settings.selector )
|
||||
.autocomplete({
|
||||
autoFocus: false,
|
||||
delay: 0,
|
||||
@ -46,7 +63,7 @@ asyncTest( "all events", function() {
|
||||
}),
|
||||
menu = element.autocomplete( "widget" );
|
||||
|
||||
element.focus().val( "j" ).keydown();
|
||||
element.focus()[ settings.valueMethod ]( "j" ).keydown();
|
||||
setTimeout(function() {
|
||||
ok( menu.is( ":visible" ), "menu is visible after delay" );
|
||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
||||
@ -56,58 +73,6 @@ asyncTest( "all events", function() {
|
||||
element[0].blur();
|
||||
}, 50 );
|
||||
});
|
||||
|
||||
asyncTest( "all events - contenteditable", function() {
|
||||
expect( 13 );
|
||||
var element = $( "#autocomplete-contenteditable" )
|
||||
.autocomplete({
|
||||
autoFocus: false,
|
||||
delay: 0,
|
||||
source: data,
|
||||
search: function( event ) {
|
||||
equal( event.originalEvent.type, "keydown", "search originalEvent" );
|
||||
},
|
||||
response: function( event, ui ) {
|
||||
deepEqual( ui.content, [
|
||||
{ label: "Clojure", value: "Clojure" },
|
||||
{ label: "Java", value: "Java" },
|
||||
{ label: "JavaScript", value: "JavaScript" }
|
||||
], "response ui.content" );
|
||||
ui.content.splice( 0, 1 );
|
||||
},
|
||||
open: function( event ) {
|
||||
ok( menu.is( ":visible" ), "menu open on open" );
|
||||
},
|
||||
focus: function( event, ui ) {
|
||||
equal( event.originalEvent.type, "menufocus", "focus originalEvent" );
|
||||
deepEqual( ui.item, { label: "Java", value: "Java" }, "focus ui.item" );
|
||||
},
|
||||
close: function( event ) {
|
||||
equal( event.originalEvent.type, "menuselect", "close originalEvent" );
|
||||
ok( menu.is( ":hidden" ), "menu closed on close" );
|
||||
},
|
||||
select: function( event, ui ) {
|
||||
equal( event.originalEvent.type, "menuselect", "select originalEvent" );
|
||||
deepEqual( ui.item, { label: "Java", value: "Java" }, "select ui.item" );
|
||||
},
|
||||
change: function( event, ui ) {
|
||||
equal( event.originalEvent.type, "blur", "change originalEvent" );
|
||||
deepEqual( ui.item, { label: "Java", value: "Java" }, "chnage ui.item" );
|
||||
ok( menu.is( ":hidden" ), "menu closed on change" );
|
||||
start();
|
||||
}
|
||||
}),
|
||||
menu = element.autocomplete( "widget" );
|
||||
|
||||
element.focus().text( "j" ).keydown();
|
||||
setTimeout(function() {
|
||||
ok( menu.is( ":visible" ), "menu is visible after delay" );
|
||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
|
||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
||||
// TODO: blurring through jQuery causes a bug in IE 6 which causes the
|
||||
// autocompletechange event to occur twice
|
||||
element[0].blur();
|
||||
}, 50 );
|
||||
});
|
||||
|
||||
asyncTest( "change without selection", function() {
|
||||
|
@ -5,6 +5,35 @@
|
||||
|
||||
module( "dialog: tickets" );
|
||||
|
||||
asyncTest( "#3123: Prevent tabbing out of modal dialogs", function() {
|
||||
expect( 3 );
|
||||
|
||||
var el = $( "<div><input id='t3123-first'><input id='t3123-last'></div>" ).dialog({ modal: true }),
|
||||
inputs = el.find( "input" ),
|
||||
widget = el.dialog( "widget" );
|
||||
|
||||
inputs.eq( 1 ).focus();
|
||||
equal( document.activeElement, inputs[1], "Focus set on second input" );
|
||||
inputs.eq( 1 ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB });
|
||||
|
||||
setTimeout( checkTab, 2 );
|
||||
|
||||
function checkTab() {
|
||||
ok( $.contains( widget, document.activeElement ), "Tab key event moved focus within the modal" );
|
||||
|
||||
// check shift tab
|
||||
$( document.activeElement ).simulate( "keydown", { keyCode: $.ui.keyCode.TAB, shiftKey: true });
|
||||
setTimeout( checkShiftTab, 2 );
|
||||
}
|
||||
|
||||
function checkShiftTab() {
|
||||
ok( $.contains( widget, document.activeElement ), "Shift-Tab key event moved focus within the modal" );
|
||||
|
||||
el.remove();
|
||||
start();
|
||||
}
|
||||
});
|
||||
|
||||
test("#4826: setting resizable false toggles resizable on dialog", function() {
|
||||
expect(6);
|
||||
|
||||
|
@ -207,6 +207,44 @@
|
||||
<li class="foo"><a class="foo" href="#">Amesville</a></li>
|
||||
</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>
|
||||
|
@ -5,6 +5,7 @@ commonWidgetTests( "menu", {
|
||||
my: "left top",
|
||||
at: "right top"
|
||||
},
|
||||
items: "ul",
|
||||
|
||||
// callbacks
|
||||
create: null
|
||||
|
@ -21,6 +21,23 @@ test("handle click on menu", function() {
|
||||
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() {
|
||||
expect( 4 );
|
||||
var $menu = $( "#menu1" ).menu({
|
||||
@ -41,6 +58,71 @@ test( "handle blur: click", function() {
|
||||
$("#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() {
|
||||
expect(12);
|
||||
var element = $('#menu1').menu({
|
||||
|
@ -5,10 +5,10 @@ function menu_log( message, clear ) {
|
||||
if ( message === undefined ) {
|
||||
message = $( "#log" ).data( "lastItem" );
|
||||
}
|
||||
$( "#log" ).prepend( message + "," );
|
||||
$( "#log" ).prepend( $.trim( message ) + "," );
|
||||
}
|
||||
|
||||
function menu_click( menu, item ) {
|
||||
$( "#log" ).data( "lastItem", item );
|
||||
menu.find( "li:eq(" + item + ") a" ).trigger( "click" );
|
||||
menu.children( ":eq(" + item + ")" ).find( "a:first" ).trigger( "click" );
|
||||
}
|
@ -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>
|
||||
|
||||
<div id="fractions-parent" style="position: absolute; left: 10.7432222px; top: 10.532325px; height: 30px; width: 201px;">
|
||||
<div id="fractions-element"></div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@ -109,14 +109,12 @@ test( "mouse click on up button, increases value not greater than max", function
|
||||
});
|
||||
|
||||
test( "mousewheel on input", function() {
|
||||
expect( 5 );
|
||||
expect( 4 );
|
||||
|
||||
var element = $( "#spin" ).spinner({
|
||||
var element = $( "#spin" ).val( 0 ).spinner({
|
||||
step: 2
|
||||
});
|
||||
|
||||
equal( element.val(), 0 );
|
||||
|
||||
element.trigger( "mousewheel" );
|
||||
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() {
|
||||
expect( 7 );
|
||||
expect( 9 );
|
||||
var element = $( "#spin" ).val( 2 ).spinner({ min: -5, max: 5 });
|
||||
|
||||
equal( element.attr( "role" ), "spinbutton", "role" );
|
||||
equal( element.attr( "aria-valuemin" ), -5, "aria-valuemin" );
|
||||
equal( element.attr( "aria-valuemax" ), 5, "aria-valuemax" );
|
||||
equal( element.attr( "aria-valuenow" ), 2, "aria-valuenow" );
|
||||
equal( element.attr( "aria-valuemin" ), "-5", "aria-valuemin" );
|
||||
equal( element.attr( "aria-valuemax" ), "5", "aria-valuemax" );
|
||||
equal( element.attr( "aria-valuenow" ), "2", "aria-valuenow" );
|
||||
|
||||
element.spinner( "stepUp" );
|
||||
|
||||
equal( element.attr( "aria-valuenow" ), 3, "stepUp 1 step changes aria-valuenow" );
|
||||
equal( element.attr( "aria-valuenow" ), "3", "stepUp 1 step changes aria-valuenow" );
|
||||
|
||||
element.spinner( "option", { min: -10, max: 10 } );
|
||||
|
||||
equal( element.attr( "aria-valuemin" ), -10, "min option changed aria-valuemin changes" );
|
||||
equal( element.attr( "aria-valuemax" ), 10, "max option changed aria-valuemax changes" );
|
||||
equal( element.attr( "aria-valuemin" ), "-10", "min option changed aria-valuemin changes" );
|
||||
equal( element.attr( "aria-valuemax" ), "10", "max option changed aria-valuemax changes" );
|
||||
|
||||
element.spinner( "option", "min", null );
|
||||
equal( element.attr( "aria-valuemin" ), undefined, "aria-valuemin not set when no min" );
|
||||
|
||||
element.spinner( "option", "max", null );
|
||||
equal( element.attr( "aria-valuemax" ), undefined, "aria-valuemax not set when no max" );
|
||||
});
|
||||
|
||||
test( "focus text field when pressing button", function() {
|
||||
@ -192,10 +196,11 @@ test( "precision", function() {
|
||||
equal( element.val(), "0.0501", "precision from step" );
|
||||
|
||||
element.val( 1.05 ).spinner( "option", {
|
||||
step: 1
|
||||
step: 1,
|
||||
min: -9.95
|
||||
});
|
||||
element.spinner( "stepDown" );
|
||||
equal( element.val(), "0.05", "precision from value" );
|
||||
equal( element.val(), "0.05", "precision from min" );
|
||||
});
|
||||
|
||||
})( jQuery );
|
||||
|
@ -2,8 +2,8 @@ commonWidgetTests( "spinner", {
|
||||
defaults: {
|
||||
disabled: false,
|
||||
incremental: true,
|
||||
max: Number.MAX_VALUE,
|
||||
min: -Number.MAX_VALUE,
|
||||
max: null,
|
||||
min: null,
|
||||
numberFormat: null,
|
||||
page: 10,
|
||||
step: 1,
|
||||
|
@ -54,7 +54,7 @@ test( "disable", function() {
|
||||
|
||||
test( "enable", function() {
|
||||
expect( 5 );
|
||||
var element = $( "#spin" ).spinner({ disabled: true })
|
||||
var element = $( "#spin" ).val( 1 ).spinner({ disabled: true })
|
||||
wrapper = element.spinner( "widget" );
|
||||
|
||||
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" );
|
||||
|
||||
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() {
|
||||
@ -117,23 +117,23 @@ test( "stepDown", function() {
|
||||
});
|
||||
|
||||
element.spinner( "stepDown" );
|
||||
equals( element.val(), -2, "stepDown 1 step" );
|
||||
equals( element.val(), "-1", "stepDown 1 step" );
|
||||
|
||||
element.spinner( "stepDown", 5 );
|
||||
equals( element.val(), -12, "stepDown 5 steps" );
|
||||
equals( element.val(), "-11", "stepDown 5 steps" );
|
||||
|
||||
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" );
|
||||
equals( element.val(), -15, "at min and stepDown 1 step" );
|
||||
equals( element.val(), "-15", "at min and stepDown 1 step" );
|
||||
});
|
||||
|
||||
test( "stepUp", function() {
|
||||
expect( 4 );
|
||||
var element = $( "#spin" ).val( 0 ).spinner({
|
||||
step: 2,
|
||||
max: 15
|
||||
max: 16
|
||||
});
|
||||
|
||||
element.spinner( "stepUp" );
|
||||
@ -143,20 +143,22 @@ test( "stepUp", function() {
|
||||
equals( element.val(), 12, "stepUp 5 steps" );
|
||||
|
||||
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" );
|
||||
equals( element.val(), 15, "at max and stepUp 1 step" );
|
||||
equals( element.val(), 16, "at max and stepUp 1 step" );
|
||||
});
|
||||
|
||||
test( "value", function() {
|
||||
expect( 2 );
|
||||
var element = $( "#spin" ).val( 0 ).spinner();
|
||||
var element = $( "#spin" ).val( 0 ).spinner({
|
||||
step: 3
|
||||
});
|
||||
|
||||
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 );
|
||||
|
@ -2,6 +2,71 @@
|
||||
|
||||
module( "spinner: options" );
|
||||
|
||||
test( "incremental, false", function() {
|
||||
expect( 100 );
|
||||
|
||||
var i, diff,
|
||||
prev = 0,
|
||||
element = $( "#spin" ).val( prev ).spinner({
|
||||
incremental: false,
|
||||
spin: function( event, ui ) {
|
||||
equal( ui.value - prev, 1 );
|
||||
prev = ui.value;
|
||||
}
|
||||
});
|
||||
|
||||
for ( i = 0; i < 100; i++ ) {
|
||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
|
||||
}
|
||||
});
|
||||
|
||||
test( "incremental, true", function() {
|
||||
expect( 100 );
|
||||
|
||||
function fill( num, val ) {
|
||||
return $.map( new Array( num ), function() {
|
||||
return val;
|
||||
});
|
||||
}
|
||||
|
||||
var i, diff,
|
||||
prev = 0,
|
||||
expected = [].concat( fill( 18, 1 ), fill( 37, 2 ), fill( 14, 3 ),
|
||||
fill( 9, 4 ), fill( 6, 5 ), fill( 5, 6 ), fill ( 5, 7 ),
|
||||
fill( 4, 8 ), fill( 2, 9 ) ),
|
||||
element = $( "#spin" ).val( prev ).spinner({
|
||||
incremental: true,
|
||||
spin: function( event, ui ) {
|
||||
equal( ui.value - prev, expected[ i ] );
|
||||
prev = ui.value;
|
||||
}
|
||||
});
|
||||
|
||||
for ( i = 0; i < 100; i++ ) {
|
||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
|
||||
}
|
||||
});
|
||||
|
||||
test( "incremental, function", function() {
|
||||
expect( 100 );
|
||||
|
||||
var i,
|
||||
prev = 0,
|
||||
element = $( "#spin" ).val( prev ).spinner({
|
||||
incremental: function( i ) {
|
||||
return i;
|
||||
},
|
||||
spin: function( event, ui ) {
|
||||
equal( ui.value - prev, i + 1 );
|
||||
prev = ui.value;
|
||||
}
|
||||
});
|
||||
|
||||
for ( i = 0; i < 100; i++ ) {
|
||||
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
|
||||
}
|
||||
});
|
||||
|
||||
test( "numberFormat, number", function() {
|
||||
expect( 2 );
|
||||
var element = $( "#spin" ).val( 0 ).spinner({ numberFormat: "n" });
|
||||
@ -26,44 +91,6 @@ test( "numberFormat, currency", function() {
|
||||
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() {
|
||||
expect( 3 );
|
||||
var element = $( "#spin" ).val( 1000 ).spinner({ max: 100 });
|
||||
@ -96,10 +123,11 @@ test( "step, 2", function() {
|
||||
equals( element.val(), "2", "stepUp" );
|
||||
|
||||
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" );
|
||||
equals( element.val(), "12.5", "stepUp" );
|
||||
equals( element.val(), "6", "stepUp" );
|
||||
});
|
||||
|
||||
test( "step, 0.7", function() {
|
||||
|
@ -571,23 +571,23 @@ test( ".widget() - overriden", function() {
|
||||
|
||||
test( "._bind() to element (default)", function() {
|
||||
expect( 12 );
|
||||
var self;
|
||||
var that;
|
||||
$.widget( "ui.testWidget", {
|
||||
_create: function() {
|
||||
self = this;
|
||||
that = this;
|
||||
this._bind({
|
||||
keyup: this.keyup,
|
||||
keydown: "keydown"
|
||||
});
|
||||
},
|
||||
keyup: function( event ) {
|
||||
equals( self, this );
|
||||
equals( self.element[0], event.currentTarget );
|
||||
equals( that, this );
|
||||
equals( that.element[0], event.currentTarget );
|
||||
equals( "keyup", event.type );
|
||||
},
|
||||
keydown: function( event ) {
|
||||
equals( self, this );
|
||||
equals( self.element[0], event.currentTarget );
|
||||
equals( that, this );
|
||||
equals( that.element[0], event.currentTarget );
|
||||
equals( "keydown", event.type );
|
||||
}
|
||||
});
|
||||
@ -611,23 +611,23 @@ test( "._bind() to element (default)", function() {
|
||||
|
||||
test( "._bind() to descendent", function() {
|
||||
expect( 12 );
|
||||
var self;
|
||||
var that;
|
||||
$.widget( "ui.testWidget", {
|
||||
_create: function() {
|
||||
self = this;
|
||||
that = this;
|
||||
this._bind( this.element.find( "strong" ), {
|
||||
keyup: this.keyup,
|
||||
keydown: "keydown"
|
||||
});
|
||||
},
|
||||
keyup: function( event ) {
|
||||
equals( self, this );
|
||||
equals( self.element.find( "strong" )[0], event.currentTarget );
|
||||
equals( that, this );
|
||||
equals( that.element.find( "strong" )[0], event.currentTarget );
|
||||
equals( "keyup", event.type );
|
||||
},
|
||||
keydown: function(event) {
|
||||
equals( self, this );
|
||||
equals( self.element.find( "strong" )[0], event.currentTarget );
|
||||
equals( that, this );
|
||||
equals( that.element.find( "strong" )[0], event.currentTarget );
|
||||
equals( "keydown", event.type );
|
||||
}
|
||||
});
|
||||
@ -1040,4 +1040,30 @@ test( "redefine", function() {
|
||||
equal( $.ui.testWidget.foo, "bar", "static properties remain" );
|
||||
});
|
||||
|
||||
asyncTest( "_delay", function() {
|
||||
expect( 6 );
|
||||
var order = 0,
|
||||
that;
|
||||
$.widget( "ui.testWidget", {
|
||||
defaultElement: null,
|
||||
_create: function() {
|
||||
that = this;
|
||||
var timer = this._delay(function() {
|
||||
strictEqual( this, that );
|
||||
equal( order, 1 );
|
||||
start();
|
||||
}, 500);
|
||||
ok( timer !== undefined );
|
||||
timer = this._delay("callback");
|
||||
ok( timer !== undefined );
|
||||
},
|
||||
callback: function() {
|
||||
strictEqual( this, that );
|
||||
equal( order, 0 );
|
||||
order += 1;
|
||||
}
|
||||
});
|
||||
$( "#widget" ).testWidget();
|
||||
});
|
||||
|
||||
}( jQuery ) );
|
||||
|
@ -6,7 +6,6 @@ test( "$.widget.extend()", function() {
|
||||
optionsCopy = { xnumber2: 1, xstring2: "x", xxx: "newstring" },
|
||||
merged = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "x", xxx: "newstring" },
|
||||
deep1 = { foo: { bar: true } },
|
||||
deep1copy = { foo: { bar: true } },
|
||||
deep2 = { foo: { baz: true }, foo2: document },
|
||||
deep2copy = { foo: { baz: true }, foo2: document },
|
||||
deepmerged = { foo: { bar: true, baz: true }, foo2: document },
|
||||
@ -96,7 +95,7 @@ test( "$.widget.extend()", function() {
|
||||
|
||||
var input = {
|
||||
key: [ 1, 2, 3 ]
|
||||
}
|
||||
};
|
||||
var output = $.widget.extend( {}, input );
|
||||
deepEqual( input, output, "don't clone arrays" );
|
||||
input.key[0] = 10;
|
||||
|
@ -23,9 +23,23 @@
|
||||
$("<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();
|
||||
|
||||
$("#toggle-destroy").toggle(function() {
|
||||
@ -41,7 +55,10 @@
|
||||
<style>
|
||||
body { font-size:62.5%; }
|
||||
.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>
|
||||
</head>
|
||||
<body>
|
||||
@ -132,7 +149,7 @@
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul id="menu4">
|
||||
<ul class="menu4">
|
||||
<li><a href="#">Aberdeen</a></li>
|
||||
<li><a href="#">Ada</a></li>
|
||||
<li><a href="#">Adamsville</a></li>
|
||||
@ -173,6 +190,87 @@
|
||||
<li><a href="#">Amesville</a></li>
|
||||
</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">
|
||||
Log:
|
||||
<div id="log" style="height: 400px; width: 300px; overflow: auto;" class="ui-widget-content"></div>
|
||||
|
12
ui/i18n/jquery.ui.datepicker-hu.js
vendored
12
ui/i18n/jquery.ui.datepicker-hu.js
vendored
@ -2,19 +2,19 @@
|
||||
/* Written by Istvan Karaszi (jquery@spam.raszi.hu). */
|
||||
jQuery(function($){
|
||||
$.datepicker.regional['hu'] = {
|
||||
closeText: 'bezárás',
|
||||
prevText: '« vissza',
|
||||
nextText: 'előre »',
|
||||
closeText: 'bezár',
|
||||
prevText: 'vissza',
|
||||
nextText: 'előre',
|
||||
currentText: 'ma',
|
||||
monthNames: ['Január', 'Február', 'Március', 'Április', 'Május', 'Június',
|
||||
'Július', 'Augusztus', 'Szeptember', 'Október', 'November', 'December'],
|
||||
monthNamesShort: ['Jan', 'Feb', 'Már', 'Ápr', 'Máj', 'Jún',
|
||||
'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'],
|
||||
dayNamesMin: ['V', 'H', 'K', 'Sze', 'Cs', 'P', 'Szo'],
|
||||
weekHeader: 'Hé',
|
||||
dateFormat: 'yy-mm-dd',
|
||||
weekHeader: 'Hét',
|
||||
dateFormat: 'yy.mm.dd.',
|
||||
firstDay: 1,
|
||||
isRTL: false,
|
||||
showMonthAfterYear: true,
|
||||
|
3
ui/jquery.ui.autocomplete.js
vendored
3
ui/jquery.ui.autocomplete.js
vendored
@ -51,7 +51,7 @@ $.widget( "ui.autocomplete", {
|
||||
suppressKeyPress,
|
||||
suppressInput;
|
||||
|
||||
this.valueMethod = this.element[ this.element.is( "input" ) ? "val" : "text" ];
|
||||
this.valueMethod = this.element[ this.element.is( "input,textarea" ) ? "val" : "text" ];
|
||||
|
||||
this.element
|
||||
.addClass( "ui-autocomplete-input" )
|
||||
@ -325,6 +325,7 @@ $.widget( "ui.autocomplete", {
|
||||
|
||||
_searchTimeout: function( event ) {
|
||||
var self = this;
|
||||
clearTimeout( self.searching );
|
||||
self.searching = setTimeout(function() {
|
||||
// only search if the value has changed
|
||||
if ( self.term != self.element.val() ) {
|
||||
|
6
ui/jquery.ui.button.js
vendored
6
ui/jquery.ui.button.js
vendored
@ -379,7 +379,7 @@ $.widget( "ui.buttonset", {
|
||||
},
|
||||
|
||||
refresh: function() {
|
||||
var ltr = this.element.css( "direction" ) === "ltr";
|
||||
var rtl = this.element.css( "direction" ) === "rtl";
|
||||
|
||||
this.buttons = this.element.find( this.options.items )
|
||||
.filter( ":ui-button" )
|
||||
@ -393,10 +393,10 @@ $.widget( "ui.buttonset", {
|
||||
})
|
||||
.removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
|
||||
.filter( ":first" )
|
||||
.addClass( ltr ? "ui-corner-left" : "ui-corner-right" )
|
||||
.addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
|
||||
.end()
|
||||
.filter( ":last" )
|
||||
.addClass( ltr ? "ui-corner-right" : "ui-corner-left" )
|
||||
.addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
|
||||
.end()
|
||||
.end();
|
||||
},
|
||||
|
29
ui/jquery.ui.datepicker.js
vendored
29
ui/jquery.ui.datepicker.js
vendored
@ -636,10 +636,10 @@ $.extend(Datepicker.prototype, {
|
||||
return;
|
||||
var inst = $.datepicker._getInst(input);
|
||||
if ($.datepicker._curInst && $.datepicker._curInst != inst) {
|
||||
if ( $.datepicker._datepickerShowing ) {
|
||||
$.datepicker._triggerOnClose($.datepicker._curInst);
|
||||
}
|
||||
$.datepicker._curInst.dpDiv.stop(true, true);
|
||||
if ( inst && $.datepicker._datepickerShowing ) {
|
||||
$.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
|
||||
}
|
||||
}
|
||||
var beforeShow = $.datepicker._get(inst, 'beforeShow');
|
||||
var beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
|
||||
@ -790,14 +790,6 @@ $.extend(Datepicker.prototype, {
|
||||
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.
|
||||
@param input element - the input field attached to the date picker */
|
||||
_hideDatepicker: function(input) {
|
||||
@ -820,8 +812,11 @@ $.extend(Datepicker.prototype, {
|
||||
(showAnim == 'fadeIn' ? 'fadeOut' : 'hide'))]((showAnim ? duration : null), postProcess);
|
||||
if (!showAnim)
|
||||
postProcess();
|
||||
$.datepicker._triggerOnClose(inst);
|
||||
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;
|
||||
if (this._inDialog) {
|
||||
this._dialogInput.css({ position: 'absolute', left: '0', top: '-100px' });
|
||||
@ -843,12 +838,16 @@ $.extend(Datepicker.prototype, {
|
||||
_checkExternalClick: function(event) {
|
||||
if (!$.datepicker._curInst)
|
||||
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.hasClass($.datepicker.markerClassName) &&
|
||||
!$target.hasClass($.datepicker._triggerClass) &&
|
||||
$.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI))
|
||||
$.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
|
||||
( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst != inst ) )
|
||||
$.datepicker._hideDatepicker();
|
||||
},
|
||||
|
||||
|
2
ui/jquery.ui.dialog.js
vendored
2
ui/jquery.ui.dialog.js
vendored
@ -293,7 +293,7 @@ $.widget("ui.dialog", {
|
||||
|
||||
// prevent tabbing out of modal dialogs
|
||||
if ( options.modal ) {
|
||||
uiDialog.bind( "keypress.ui-dialog", function( event ) {
|
||||
uiDialog.bind( "keydown.ui-dialog", function( event ) {
|
||||
if ( event.keyCode !== $.ui.keyCode.TAB ) {
|
||||
return;
|
||||
}
|
||||
|
166
ui/jquery.ui.menu.js
vendored
166
ui/jquery.ui.menu.js
vendored
@ -20,13 +20,13 @@ $.widget( "ui.menu", {
|
||||
defaultElement: "<ul>",
|
||||
delay: 150,
|
||||
options: {
|
||||
items: "ul",
|
||||
position: {
|
||||
my: "left top",
|
||||
at: "right top"
|
||||
}
|
||||
},
|
||||
_create: function() {
|
||||
var self = this;
|
||||
this.activeMenu = this.element;
|
||||
this.menuId = this.element.attr( "id" ) || "ui-menu-" + idIncrement++;
|
||||
if ( this.element.find( ".ui-icon" ).length ) {
|
||||
@ -40,11 +40,11 @@ $.widget( "ui.menu", {
|
||||
})
|
||||
// need to catch all clicks on disabled menu
|
||||
// not possible through _bind
|
||||
.bind( "click.menu", function( event ) {
|
||||
if ( self.options.disabled ) {
|
||||
.bind( "click.menu", $.proxy( function( event ) {
|
||||
if ( this.options.disabled ) {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
}, this));
|
||||
this._bind({
|
||||
"click .ui-menu-item:has(a)": function( event ) {
|
||||
event.stopImmediatePropagation();
|
||||
@ -62,85 +62,92 @@ $.widget( "ui.menu", {
|
||||
target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
|
||||
this.focus( event, target );
|
||||
},
|
||||
"mouseleave": "collapseAll",
|
||||
"mouseleave .ui-menu": "collapseAll",
|
||||
"mouseout .ui-menu-item": "blur",
|
||||
"focus": function( event ) {
|
||||
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.element.attr( "tabIndex", 0 ).bind( "keydown.menu", function( event ) {
|
||||
if ( self.options.disabled ) {
|
||||
return;
|
||||
}
|
||||
this.element.attr( "tabIndex", 0 );
|
||||
this._bind({
|
||||
"keydown": function( event ) {
|
||||
switch ( event.keyCode ) {
|
||||
case $.ui.keyCode.PAGE_UP:
|
||||
self.previousPage( event );
|
||||
this.previousPage( event );
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
break;
|
||||
case $.ui.keyCode.PAGE_DOWN:
|
||||
self.nextPage( event );
|
||||
this.nextPage( event );
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
break;
|
||||
case $.ui.keyCode.HOME:
|
||||
self._move( "first", "first", event );
|
||||
this._move( "first", "first", event );
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
break;
|
||||
case $.ui.keyCode.END:
|
||||
self._move( "last", "last", event );
|
||||
this._move( "last", "last", event );
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
break;
|
||||
case $.ui.keyCode.UP:
|
||||
self.previous( event );
|
||||
this.previous( event );
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
break;
|
||||
case $.ui.keyCode.DOWN:
|
||||
self.next( event );
|
||||
this.next( event );
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
break;
|
||||
case $.ui.keyCode.LEFT:
|
||||
if (self.collapse( event )) {
|
||||
if (this.collapse( event )) {
|
||||
event.stopImmediatePropagation();
|
||||
}
|
||||
event.preventDefault();
|
||||
break;
|
||||
case $.ui.keyCode.RIGHT:
|
||||
if (self.expand( event )) {
|
||||
if (this.expand( event )) {
|
||||
event.stopImmediatePropagation();
|
||||
}
|
||||
event.preventDefault();
|
||||
break;
|
||||
case $.ui.keyCode.ENTER:
|
||||
if ( self.active.children( "a[aria-haspopup='true']" ).length ) {
|
||||
if ( self.expand( event ) ) {
|
||||
if ( this.active.children( "a[aria-haspopup='true']" ).length ) {
|
||||
if ( this.expand( event ) ) {
|
||||
event.stopImmediatePropagation();
|
||||
}
|
||||
}
|
||||
else {
|
||||
self.select( event );
|
||||
this.select( event );
|
||||
event.stopImmediatePropagation();
|
||||
}
|
||||
event.preventDefault();
|
||||
break;
|
||||
case $.ui.keyCode.ESCAPE:
|
||||
if ( self.collapse( event ) ) {
|
||||
if ( this.collapse( event ) ) {
|
||||
event.stopImmediatePropagation();
|
||||
}
|
||||
event.preventDefault();
|
||||
break;
|
||||
default:
|
||||
event.stopPropagation();
|
||||
clearTimeout( self.filterTimer );
|
||||
clearTimeout( this.filterTimer );
|
||||
var match,
|
||||
prev = self.previousFilter || "",
|
||||
prev = this.previousFilter || "",
|
||||
character = String.fromCharCode( event.keyCode ),
|
||||
skip = false;
|
||||
|
||||
@ -152,30 +159,31 @@ $.widget( "ui.menu", {
|
||||
function escape( value ) {
|
||||
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")
|
||||
.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 ) {
|
||||
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")
|
||||
.test( $( this ).children( "a" ).text() );
|
||||
});
|
||||
}
|
||||
if ( match.length ) {
|
||||
self.focus( event, match );
|
||||
this.focus( event, match );
|
||||
if (match.length > 1) {
|
||||
self.previousFilter = character;
|
||||
self.filterTimer = setTimeout( function() {
|
||||
delete self.previousFilter;
|
||||
this.previousFilter = character;
|
||||
this.filterTimer = this._delay( function() {
|
||||
delete this.previousFilter;
|
||||
}, 1000 );
|
||||
} else {
|
||||
delete self.previousFilter;
|
||||
delete this.previousFilter;
|
||||
}
|
||||
} else {
|
||||
delete self.previousFilter;
|
||||
delete this.previousFilter;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -193,7 +201,7 @@ $.widget( "ui.menu", {
|
||||
//destroy (sub)menus
|
||||
this.element
|
||||
.removeAttr( "aria-activedescendant" )
|
||||
.find( "ul" )
|
||||
.find( ".ui-menu" )
|
||||
.andSelf()
|
||||
.removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
|
||||
.removeAttr( "role" )
|
||||
@ -219,27 +227,25 @@ $.widget( "ui.menu", {
|
||||
},
|
||||
|
||||
refresh: function() {
|
||||
var self = this,
|
||||
|
||||
// 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" )
|
||||
.attr( "role", "menu" )
|
||||
.hide()
|
||||
.attr( "aria-hidden", "true" )
|
||||
.attr( "aria-expanded", "false" ),
|
||||
.attr( "aria-expanded", "false" );
|
||||
|
||||
// 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" )
|
||||
.attr( "role", "presentation" );
|
||||
|
||||
items.children( "a" )
|
||||
.attr( "role", "presentation" )
|
||||
.children( "a" )
|
||||
.addClass( "ui-corner-all" )
|
||||
.attr( "tabIndex", -1 )
|
||||
.attr( "role", "menuitem" )
|
||||
.attr( "id", function( i ) {
|
||||
return self.element.attr( "id" ) + "-" + i;
|
||||
return menuId + "-" + i;
|
||||
});
|
||||
|
||||
submenus.each( function() {
|
||||
@ -253,9 +259,6 @@ $.widget( "ui.menu", {
|
||||
},
|
||||
|
||||
focus: function( event, item ) {
|
||||
var nested,
|
||||
self = this;
|
||||
|
||||
this.blur( event );
|
||||
|
||||
if ( this._hasScroll() ) {
|
||||
@ -277,18 +280,18 @@ $.widget( "ui.menu", {
|
||||
.children( "a" )
|
||||
.addClass( "ui-state-focus" )
|
||||
.end();
|
||||
self.element.attr( "aria-activedescendant", self.active.children("a").attr("id") );
|
||||
this.element.attr( "aria-activedescendant", this.active.children( "a" ).attr( "id" ) );
|
||||
|
||||
// highlight active parent menu item, if any
|
||||
this.active.parent().closest( ".ui-menu-item" ).children( "a:first" ).addClass( "ui-state-active" );
|
||||
|
||||
self.timer = setTimeout( function() {
|
||||
self._close();
|
||||
}, self.delay );
|
||||
this.timer = this._delay( function() {
|
||||
this._close();
|
||||
}, this.delay );
|
||||
|
||||
nested = $( ">ul", item );
|
||||
var nested = $( "> .ui-menu", item );
|
||||
if ( nested.length && ( /^mouse/.test( event.type ) ) ) {
|
||||
self._startOpening(nested);
|
||||
this._startOpening(nested);
|
||||
}
|
||||
this.activeMenu = item.parent();
|
||||
|
||||
@ -317,11 +320,10 @@ $.widget( "ui.menu", {
|
||||
return;
|
||||
}
|
||||
|
||||
var self = this;
|
||||
self.timer = setTimeout( function() {
|
||||
self._close();
|
||||
self._open( submenu );
|
||||
}, self.delay );
|
||||
this.timer = this._delay( function() {
|
||||
this._close();
|
||||
this._open( submenu );
|
||||
}, this.delay );
|
||||
},
|
||||
|
||||
_open: function( submenu ) {
|
||||
@ -345,23 +347,32 @@ $.widget( "ui.menu", {
|
||||
.position( position );
|
||||
},
|
||||
|
||||
collapseAll: function( event ) {
|
||||
this.element
|
||||
.find( "ul" )
|
||||
.hide()
|
||||
.attr( "aria-hidden", "true" )
|
||||
.attr( "aria-expanded", "false" )
|
||||
.end()
|
||||
.find( "a.ui-state-active" )
|
||||
.removeClass( "ui-state-active" );
|
||||
collapseAll: function( event, all ) {
|
||||
|
||||
// if we were passed an event, look for the submenu that contains the event
|
||||
var currentMenu = all ? this.element :
|
||||
$( event && event.target ).closest( this.element.find( ".ui-menu" ) );
|
||||
|
||||
// if we found no valid submenu ancestor, use the main menu to close all sub menus anyway
|
||||
if ( !currentMenu.length ) {
|
||||
currentMenu = this.element;
|
||||
}
|
||||
|
||||
this._close( currentMenu );
|
||||
|
||||
this.blur( event );
|
||||
this.activeMenu = this.element;
|
||||
this.activeMenu = currentMenu;
|
||||
},
|
||||
|
||||
_close: function() {
|
||||
this.active.parent()
|
||||
.find( "ul" )
|
||||
// With no arguments, closes the currently active menu - if nothing is active
|
||||
// it closes all menus. If passed an argument, it will search for menus BELOW
|
||||
_close: function( startMenu ) {
|
||||
if ( !startMenu ) {
|
||||
startMenu = this.active ? this.active.parent() : this.element;
|
||||
}
|
||||
|
||||
startMenu
|
||||
.find( ".ui-menu" )
|
||||
.hide()
|
||||
.attr( "aria-hidden", "true" )
|
||||
.attr( "aria-expanded", "false" )
|
||||
@ -371,27 +382,23 @@ $.widget( "ui.menu", {
|
||||
},
|
||||
|
||||
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 ) {
|
||||
this.active.parent()
|
||||
.attr("aria-hidden", "true")
|
||||
.attr("aria-expanded", "false")
|
||||
.hide();
|
||||
this._close();
|
||||
this.focus( event, newItem );
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
expand: function( event ) {
|
||||
var self = this,
|
||||
newItem = this.active && this.active.children("ul").children("li").first();
|
||||
var newItem = this.active && this.active.children( ".ui-menu " ).children( ".ui-menu-item" ).first();
|
||||
|
||||
if ( newItem && newItem.length ) {
|
||||
this._open( newItem.parent() );
|
||||
|
||||
//timeout so Firefox will not hide activedescendant change in expanding submenu from AT
|
||||
setTimeout( function() {
|
||||
self.focus( event, newItem );
|
||||
this._delay( function() {
|
||||
this.focus( event, newItem );
|
||||
}, 20 );
|
||||
return true;
|
||||
}
|
||||
@ -487,11 +494,12 @@ $.widget( "ui.menu", {
|
||||
},
|
||||
|
||||
select: function( event ) {
|
||||
|
||||
// save active reference before collapseAll triggers blur
|
||||
var ui = {
|
||||
item: this.active
|
||||
};
|
||||
this.collapseAll( event );
|
||||
this.collapseAll( event, true );
|
||||
this._trigger( "select", event, ui );
|
||||
}
|
||||
});
|
||||
|
46
ui/jquery.ui.popup.js
vendored
46
ui/jquery.ui.popup.js
vendored
@ -22,6 +22,14 @@ $.widget( "ui.popup", {
|
||||
position: {
|
||||
my: "left top",
|
||||
at: "left bottom"
|
||||
},
|
||||
show: {
|
||||
effect: "slideDown",
|
||||
duration: "fast"
|
||||
},
|
||||
hide: {
|
||||
effect: "fadeOut",
|
||||
duration: "fast"
|
||||
}
|
||||
},
|
||||
_create: function() {
|
||||
@ -45,13 +53,14 @@ $.widget( "ui.popup", {
|
||||
.attr( "aria-owns", this.element.attr( "id" ) );
|
||||
|
||||
this.element
|
||||
.addClass( "ui-popup" )
|
||||
this.close();
|
||||
.addClass( "ui-popup" );
|
||||
this._beforeClose();
|
||||
this.element.hide();
|
||||
|
||||
this._bind(this.options.trigger, {
|
||||
keydown: function( event ) {
|
||||
// prevent space-to-open to scroll the page, only happens for anchor ui.button
|
||||
if ( this.options.trigger.is( "a:ui-button" ) && event.keyCode == $.ui.keyCode.SPACE ) {
|
||||
if ( $.ui.button && this.options.trigger.is( "a:ui-button" ) && event.keyCode == $.ui.keyCode.SPACE ) {
|
||||
event.preventDefault();
|
||||
}
|
||||
// TODO handle SPACE to open popup? only when not handled by ui.button
|
||||
@ -72,15 +81,14 @@ $.widget( "ui.popup", {
|
||||
// let it propagate to close
|
||||
return;
|
||||
}
|
||||
var that = this;
|
||||
clearTimeout( this.closeTimer );
|
||||
setTimeout(function() {
|
||||
that.open( event );
|
||||
this._delay(function() {
|
||||
this.open( event );
|
||||
}, 1);
|
||||
}
|
||||
});
|
||||
|
||||
if ( !this.element.is( ":ui-menu" ) ) {
|
||||
if ( !$.ui.menu || !this.element.is( ":ui-menu" ) ) {
|
||||
// default use case, wrap tab order in popup
|
||||
this._bind({ keydown : function( event ) {
|
||||
if ( event.keyCode !== $.ui.keyCode.TAB ) {
|
||||
@ -102,11 +110,10 @@ $.widget( "ui.popup", {
|
||||
|
||||
this._bind({
|
||||
focusout: function( event ) {
|
||||
var that = this;
|
||||
// use a timer to allow click to clear it and letting that
|
||||
// handle the closing instead of opening again
|
||||
that.closeTimer = setTimeout( function() {
|
||||
that.close( event );
|
||||
this.closeTimer = this._delay( function() {
|
||||
this.close( event );
|
||||
}, 100);
|
||||
},
|
||||
focusin: function( event ) {
|
||||
@ -133,7 +140,7 @@ $.widget( "ui.popup", {
|
||||
this.close( event );
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
_destroy: function() {
|
||||
@ -161,13 +168,14 @@ $.widget( "ui.popup", {
|
||||
of: this.options.trigger
|
||||
}, this.options.position );
|
||||
|
||||
this._show( this.element, this.options.show );
|
||||
this.element
|
||||
.show()
|
||||
.attr( "aria-hidden", "false" )
|
||||
.attr( "aria-expanded", "true" )
|
||||
.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.focus();
|
||||
} else {
|
||||
@ -192,10 +200,8 @@ $.widget( "ui.popup", {
|
||||
},
|
||||
|
||||
close: function( event ) {
|
||||
this.element
|
||||
.hide()
|
||||
.attr( "aria-hidden", "true" )
|
||||
.attr( "aria-expanded", "false" );
|
||||
this._beforeClose();
|
||||
this._hide( this.element, this.options.hide );
|
||||
|
||||
this.options.trigger.attr( "tabindex" , 0 );
|
||||
if ( this.removeTabIndex ) {
|
||||
@ -203,6 +209,12 @@ $.widget( "ui.popup", {
|
||||
}
|
||||
this.isOpen = false;
|
||||
this._trigger( "close", event );
|
||||
},
|
||||
|
||||
_beforeClose: function() {
|
||||
this.element
|
||||
.attr( "aria-hidden", "true" )
|
||||
.attr( "aria-expanded", "false" );
|
||||
}
|
||||
});
|
||||
|
||||
|
4
ui/jquery.ui.position.js
vendored
4
ui/jquery.ui.position.js
vendored
@ -376,7 +376,7 @@ $.ui.position = {
|
||||
newOverBottom;
|
||||
if ( overTop < 0 ) {
|
||||
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
|
||||
.addClass( "ui-flipped-bottom" );
|
||||
|
||||
@ -385,7 +385,7 @@ $.ui.position = {
|
||||
}
|
||||
else if ( overBottom > 0 ) {
|
||||
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
|
||||
.addClass( "ui-flipped-top" );
|
||||
|
||||
|
85
ui/jquery.ui.spinner.js
vendored
85
ui/jquery.ui.spinner.js
vendored
@ -10,6 +10,7 @@
|
||||
* Depends:
|
||||
* jquery.ui.core.js
|
||||
* jquery.ui.widget.js
|
||||
* jquery.ui.button.js
|
||||
*/
|
||||
(function( $ ) {
|
||||
|
||||
@ -30,8 +31,8 @@ $.widget( "ui.spinner", {
|
||||
widgetEventPrefix: "spin",
|
||||
options: {
|
||||
incremental: true,
|
||||
max: Number.MAX_VALUE,
|
||||
min: -Number.MAX_VALUE,
|
||||
max: null,
|
||||
min: null,
|
||||
numberFormat: null,
|
||||
page: 10,
|
||||
step: 1,
|
||||
@ -147,6 +148,12 @@ $.widget( "ui.spinner", {
|
||||
.button()
|
||||
.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
|
||||
if ( this.options.disabled ) {
|
||||
this.disable();
|
||||
@ -202,56 +209,78 @@ $.widget( "ui.spinner", {
|
||||
},
|
||||
|
||||
_repeat: function( i, steps, event ) {
|
||||
var that = this;
|
||||
i = i || 500;
|
||||
|
||||
clearTimeout( this.timer );
|
||||
this.timer = setTimeout(function() {
|
||||
that._repeat( 40, steps, event );
|
||||
this.timer = this._delay(function() {
|
||||
this._repeat( 40, steps, event );
|
||||
}, i );
|
||||
|
||||
this._spin( steps * this.options.step, event );
|
||||
},
|
||||
|
||||
_spin: function( step, event ) {
|
||||
var value = this.value() || 0;
|
||||
|
||||
if ( !this.counter ) {
|
||||
this.counter = 1;
|
||||
}
|
||||
|
||||
var value = this.value(),
|
||||
newVal = value + step * this._increment( this.counter ),
|
||||
// fix precision from bad JS floating point math
|
||||
precision = Math.max( this._precision( value ),
|
||||
this._precision( this.options.step ) );
|
||||
// clamp the new value
|
||||
newVal = this._trimValue( newVal.toFixed( precision ) );
|
||||
value = this._adjustValue( value + step * this._increment( this.counter ) );
|
||||
|
||||
if ( !this.spinning || this._trigger( "spin", event, { value: newVal } ) !== false) {
|
||||
this._value( newVal );
|
||||
if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false) {
|
||||
this._value( value );
|
||||
this.counter++;
|
||||
}
|
||||
},
|
||||
|
||||
_increment: function( i ) {
|
||||
return this.options.incremental ?
|
||||
Math.floor( i*i*i/50000 - i*i/500 + 17*i/200 + 1 ) :
|
||||
1;
|
||||
var incremental = this.options.incremental;
|
||||
|
||||
if ( incremental ) {
|
||||
return $.isFunction( incremental ) ?
|
||||
incremental( i ) :
|
||||
Math.floor( i*i*i/50000 - i*i/500 + 17*i/200 + 1 );
|
||||
}
|
||||
|
||||
return 1;
|
||||
},
|
||||
|
||||
_precision: function( num ) {
|
||||
_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(),
|
||||
decimal = str.indexOf( "." );
|
||||
return decimal === -1 ? 0 : str.length - decimal - 1;
|
||||
},
|
||||
|
||||
_trimValue: function( value ) {
|
||||
var options = this.options;
|
||||
_adjustValue: function( value ) {
|
||||
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;
|
||||
}
|
||||
|
||||
if ( value < options.min ) {
|
||||
if ( options.min !== null && value < options.min ) {
|
||||
return options.min;
|
||||
}
|
||||
|
||||
@ -290,10 +319,10 @@ $.widget( "ui.spinner", {
|
||||
}),
|
||||
|
||||
_parse: function( val ) {
|
||||
if ( typeof val === "string" ) {
|
||||
if ( typeof val === "string" && 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 ) {
|
||||
@ -315,13 +344,13 @@ $.widget( "ui.spinner", {
|
||||
},
|
||||
|
||||
// update the value without triggering change
|
||||
_value: function( value, ignoreRange ) {
|
||||
_value: function( value, allowAny ) {
|
||||
var parsed;
|
||||
if ( value !== "" ) {
|
||||
parsed = this._parse( value );
|
||||
if ( parsed !== null ) {
|
||||
if ( !ignoreRange ) {
|
||||
parsed = this._trimValue( parsed );
|
||||
if ( !allowAny ) {
|
||||
parsed = this._adjustValue( parsed );
|
||||
}
|
||||
value = this._format( parsed );
|
||||
}
|
||||
|
9
ui/jquery.ui.tabs.js
vendored
9
ui/jquery.ui.tabs.js
vendored
@ -25,7 +25,7 @@ var isLocal = (function() {
|
||||
return function( anchor ) {
|
||||
// clone the node to work around IE 6 not normalizing the href property
|
||||
// if it's manually set, i.e., a.href = "#foo" kills the normalization
|
||||
anchor = anchor.cloneNode();
|
||||
anchor = anchor.cloneNode( false );
|
||||
return anchor.hash.length > 1 &&
|
||||
anchor.href.replace( rhash, "" ) === currentPage;
|
||||
};
|
||||
@ -792,11 +792,14 @@ if ( $.uiBackCompat !== false ) {
|
||||
index = this._getIndex( index );
|
||||
var options = this.options,
|
||||
tab = this.lis.eq( index ).remove(),
|
||||
panel = this.panels.eq( index ).remove();
|
||||
panel = this._getPanelForTab( tab.find( "a[aria-controls]" ) ).remove();
|
||||
|
||||
// If selected tab was removed focus tab to the right or
|
||||
// in case the last tab was removed the tab to the left.
|
||||
if ( tab.hasClass( "ui-tabs-active" ) && this.anchors.length > 1) {
|
||||
// We check for more than 2 tabs, because if there are only 2,
|
||||
// then when we remove this tab, there will only be one tab left
|
||||
// so we don't need to detect which tab to activate.
|
||||
if ( tab.hasClass( "ui-tabs-active" ) && this.anchors.length > 2 ) {
|
||||
this._activate( index + ( index + 1 < this.anchors.length ? 1 : -1 ) );
|
||||
}
|
||||
|
||||
|
2
ui/jquery.ui.tooltip.js
vendored
2
ui/jquery.ui.tooltip.js
vendored
@ -27,7 +27,7 @@ $.widget( "ui.tooltip", {
|
||||
position: {
|
||||
my: "left+15 center",
|
||||
at: "right center",
|
||||
collision: "flip fit"
|
||||
collision: "flipfit flipfit"
|
||||
},
|
||||
show: true,
|
||||
tooltipClass: null,
|
||||
|
13
ui/jquery.ui.widget.js
vendored
13
ui/jquery.ui.widget.js
vendored
@ -270,9 +270,9 @@ $.Widget.prototype = {
|
||||
return this;
|
||||
},
|
||||
_setOptions: function( options ) {
|
||||
var self = this;
|
||||
var that = this;
|
||||
$.each( options, function( key, value ) {
|
||||
self._setOption( key, value );
|
||||
that._setOption( key, value );
|
||||
});
|
||||
|
||||
return this;
|
||||
@ -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 ) {
|
||||
this.hoverable = this.hoverable.add( element );
|
||||
this._bind( element, {
|
||||
|
Loading…
Reference in New Issue
Block a user