mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Spinner: Remove core event/alias and deprecated module dependencies
This commit is contained in:
parent
d157b59a51
commit
89bf0d057b
@ -16,7 +16,7 @@
|
|||||||
<link rel="stylesheet" href="../demos.css">
|
<link rel="stylesheet" href="../demos.css">
|
||||||
<script>
|
<script>
|
||||||
$(function() {
|
$(function() {
|
||||||
$( "#currency" ).change(function() {
|
$( "#currency" ).on( "change", function() {
|
||||||
$( "#spinner" ).spinner( "option", "culture", $( this ).val() );
|
$( "#spinner" ).spinner( "option", "culture", $( this ).val() );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
numberFormat: "n"
|
numberFormat: "n"
|
||||||
});
|
});
|
||||||
|
|
||||||
$( "#culture" ).change(function() {
|
$( "#culture" ).on( "change", function() {
|
||||||
var current = $( "#spinner" ).spinner( "value" );
|
var current = $( "#spinner" ).spinner( "value" );
|
||||||
Globalize.culture( $(this).val() );
|
Globalize.culture( $(this).val() );
|
||||||
$( "#spinner" ).spinner( "value", current );
|
$( "#spinner" ).spinner( "value", current );
|
||||||
|
@ -15,24 +15,24 @@
|
|||||||
$(function() {
|
$(function() {
|
||||||
var spinner = $( "#spinner" ).spinner();
|
var spinner = $( "#spinner" ).spinner();
|
||||||
|
|
||||||
$( "#disable" ).click(function() {
|
$( "#disable" ).on( "click", function() {
|
||||||
if ( spinner.spinner( "option", "disabled" ) ) {
|
if ( spinner.spinner( "option", "disabled" ) ) {
|
||||||
spinner.spinner( "enable" );
|
spinner.spinner( "enable" );
|
||||||
} else {
|
} else {
|
||||||
spinner.spinner( "disable" );
|
spinner.spinner( "disable" );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$( "#destroy" ).click(function() {
|
$( "#destroy" ).on( "click", function() {
|
||||||
if ( spinner.spinner( "instance" ) ) {
|
if ( spinner.spinner( "instance" ) ) {
|
||||||
spinner.spinner( "destroy" );
|
spinner.spinner( "destroy" );
|
||||||
} else {
|
} else {
|
||||||
spinner.spinner();
|
spinner.spinner();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$( "#getvalue" ).click(function() {
|
$( "#getvalue" ).on( "click", function() {
|
||||||
alert( spinner.spinner( "value" ) );
|
alert( spinner.spinner( "value" ) );
|
||||||
});
|
});
|
||||||
$( "#setvalue" ).click(function() {
|
$( "#setvalue" ).on( "click", function() {
|
||||||
spinner.spinner( "value", 5 );
|
spinner.spinner( "value", 5 );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
$(function() {
|
$(function() {
|
||||||
$( "#spinner" ).timespinner();
|
$( "#spinner" ).timespinner();
|
||||||
|
|
||||||
$( "#culture" ).change(function() {
|
$( "#culture" ).on( "change", function() {
|
||||||
var current = $( "#spinner" ).timespinner( "value" );
|
var current = $( "#spinner" ).timespinner( "value" );
|
||||||
Globalize.culture( $(this).val() );
|
Globalize.culture( $(this).val() );
|
||||||
$( "#spinner" ).timespinner( "value", current );
|
$( "#spinner" ).timespinner( "value", current );
|
||||||
|
@ -114,7 +114,7 @@ asyncTest( "blur input while spinning with UP", function() {
|
|||||||
value = element.val();
|
value = element.val();
|
||||||
ok( value > 11, "repeating while key is down" );
|
ok( value > 11, "repeating while key is down" );
|
||||||
|
|
||||||
element.bind( "blur", function() {
|
element.on( "blur", function() {
|
||||||
value = element.val();
|
value = element.val();
|
||||||
setTimeout( step3, 750 );
|
setTimeout( step3, 750 );
|
||||||
})[ 0 ].blur();
|
})[ 0 ].blur();
|
||||||
@ -225,16 +225,16 @@ test( "ARIA attributes", function() {
|
|||||||
test( "focus text field when pressing button", function() {
|
test( "focus text field when pressing button", function() {
|
||||||
expect( 2 );
|
expect( 2 );
|
||||||
var element = $( "#spin" ).spinner();
|
var element = $( "#spin" ).spinner();
|
||||||
$( "body" ).focus();
|
$( "body" ).trigger( "focus" );
|
||||||
ok( element[ 0 ] !== document.activeElement, "not focused before" );
|
ok( element[ 0 ] !== document.activeElement, "not focused before" );
|
||||||
element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown();
|
element.spinner( "widget" ).find( ".ui-spinner-up" ).trigger( "mousedown" );
|
||||||
ok( element[ 0 ] === document.activeElement, "focused after" );
|
ok( element[ 0 ] === document.activeElement, "focused after" );
|
||||||
});
|
});
|
||||||
|
|
||||||
test( "don't clear invalid value on blur", function() {
|
test( "don't clear invalid value on blur", function() {
|
||||||
expect( 1 );
|
expect( 1 );
|
||||||
var element = $( "#spin" ).spinner();
|
var element = $( "#spin" ).spinner();
|
||||||
element.focus().val( "a" ).blur();
|
element.trigger( "focus" ).val( "a" ).trigger( "blur" );
|
||||||
equal( element.val(), "a" );
|
equal( element.val(), "a" );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -29,9 +29,9 @@ test( "start", function() {
|
|||||||
simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
|
simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
|
||||||
|
|
||||||
shouldStart( true, "button up" );
|
shouldStart( true, "button up" );
|
||||||
element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup();
|
element.spinner( "widget" ).find( ".ui-spinner-up" ).trigger( "mousedown" ).trigger( "mouseup" );
|
||||||
shouldStart( true, "button down" );
|
shouldStart( true, "button down" );
|
||||||
element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
|
element.spinner( "widget" ).find( ".ui-spinner-down" ).trigger( "mousedown" ).trigger( "mouseup" );
|
||||||
|
|
||||||
shouldStart( true, "stepUp" );
|
shouldStart( true, "stepUp" );
|
||||||
element.spinner( "stepUp" );
|
element.spinner( "stepUp" );
|
||||||
@ -68,9 +68,9 @@ test( "spin", function() {
|
|||||||
simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
|
simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
|
||||||
|
|
||||||
shouldSpin( true, "button up" );
|
shouldSpin( true, "button up" );
|
||||||
element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup();
|
element.spinner( "widget" ).find( ".ui-spinner-up" ).trigger( "mousedown" ).trigger( "mouseup" );
|
||||||
shouldSpin( true, "button down" );
|
shouldSpin( true, "button down" );
|
||||||
element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
|
element.spinner( "widget" ).find( ".ui-spinner-down" ).trigger( "mousedown" ).trigger( "mouseup" );
|
||||||
|
|
||||||
shouldSpin( true, "stepUp" );
|
shouldSpin( true, "stepUp" );
|
||||||
element.spinner( "stepUp" );
|
element.spinner( "stepUp" );
|
||||||
@ -107,9 +107,9 @@ test( "stop", function() {
|
|||||||
simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
|
simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
|
||||||
|
|
||||||
shouldStop( true, "button up" );
|
shouldStop( true, "button up" );
|
||||||
element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup();
|
element.spinner( "widget" ).find( ".ui-spinner-up" ).trigger( "mousedown" ).trigger( "mouseup" );
|
||||||
shouldStop( true, "button down" );
|
shouldStop( true, "button down" );
|
||||||
element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
|
element.spinner( "widget" ).find( ".ui-spinner-down" ).trigger( "mousedown" ).trigger( "mouseup" );
|
||||||
|
|
||||||
shouldStop( true, "stepUp" );
|
shouldStop( true, "stepUp" );
|
||||||
element.spinner( "stepUp" );
|
element.spinner( "stepUp" );
|
||||||
@ -200,7 +200,7 @@ asyncTest( "change", function() {
|
|||||||
shouldChange( false, "blur after many keys, same final value" );
|
shouldChange( false, "blur after many keys, same final value" );
|
||||||
|
|
||||||
shouldChange( false, "button up, before blur" );
|
shouldChange( false, "button up, before blur" );
|
||||||
element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup();
|
element.spinner( "widget" ).find( ".ui-spinner-up" ).trigger( "mousedown" ).trigger( "mouseup" );
|
||||||
shouldChange( true, "blur after button up" );
|
shouldChange( true, "blur after button up" );
|
||||||
}, step7 );
|
}, step7 );
|
||||||
}
|
}
|
||||||
@ -208,7 +208,7 @@ asyncTest( "change", function() {
|
|||||||
function step7() {
|
function step7() {
|
||||||
focusWrap(function() {
|
focusWrap(function() {
|
||||||
shouldChange( false, "button down, before blur" );
|
shouldChange( false, "button down, before blur" );
|
||||||
element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
|
element.spinner( "widget" ).find( ".ui-spinner-down" ).trigger( "mousedown" ).trigger( "mouseup" );
|
||||||
shouldChange( true, "blur after button down" );
|
shouldChange( true, "blur after button down" );
|
||||||
}, step8 );
|
}, step8 );
|
||||||
}
|
}
|
||||||
@ -216,10 +216,10 @@ asyncTest( "change", function() {
|
|||||||
function step8() {
|
function step8() {
|
||||||
focusWrap(function() {
|
focusWrap(function() {
|
||||||
shouldChange( false, "many buttons, same final value, before blur" );
|
shouldChange( false, "many buttons, same final value, before blur" );
|
||||||
element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup();
|
element.spinner( "widget" ).find( ".ui-spinner-up" ).trigger( "mousedown" ).trigger( "mouseup" );
|
||||||
element.spinner( "widget" ).find( ".ui-spinner-up" ).mousedown().mouseup();
|
element.spinner( "widget" ).find( ".ui-spinner-up" ).trigger( "mousedown" ).trigger( "mouseup" );
|
||||||
element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
|
element.spinner( "widget" ).find( ".ui-spinner-down" ).trigger( "mousedown" ).trigger( "mouseup" );
|
||||||
element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
|
element.spinner( "widget" ).find( ".ui-spinner-down" ).trigger( "mousedown" ).trigger( "mouseup" );
|
||||||
shouldChange( false, "blur after many buttons, same final value" );
|
shouldChange( false, "blur after many buttons, same final value" );
|
||||||
}, step9 );
|
}, step9 );
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,7 @@ test( "max", function() {
|
|||||||
element.spinner( "value", 1000 );
|
element.spinner( "value", 1000 );
|
||||||
equal( element.val(), 100, "max constrained in value method" );
|
equal( element.val(), 100, "max constrained in value method" );
|
||||||
|
|
||||||
element.val( 1000 ).blur();
|
element.val( 1000 ).trigger( "blur" );
|
||||||
equal( element.val(), 1000, "max not constrained if manual entry" );
|
equal( element.val(), 1000, "max not constrained if manual entry" );
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -209,7 +209,7 @@ test( "min", function() {
|
|||||||
element.spinner( "value", -1000 );
|
element.spinner( "value", -1000 );
|
||||||
equal( element.val(), -100, "min constrained in value method" );
|
equal( element.val(), -100, "min constrained in value method" );
|
||||||
|
|
||||||
element.val( -1000 ).blur();
|
element.val( -1000 ).trigger( "blur" );
|
||||||
equal( element.val(), -1000, "min not constrained if manual entry" );
|
equal( element.val(), -1000, "min not constrained if manual entry" );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ return $.widget( "ui.spinner", {
|
|||||||
function checkFocus() {
|
function checkFocus() {
|
||||||
var isActive = this.element[ 0 ] === $.ui.safeActiveElement( this.document[ 0 ] );
|
var isActive = this.element[ 0 ] === $.ui.safeActiveElement( this.document[ 0 ] );
|
||||||
if ( !isActive ) {
|
if ( !isActive ) {
|
||||||
this.element.focus();
|
this.element.trigger( "focus" );
|
||||||
this.previous = previous;
|
this.previous = previous;
|
||||||
// support: IE
|
// support: IE
|
||||||
// IE sets focus asynchronously, so we need to check if focus
|
// IE sets focus asynchronously, so we need to check if focus
|
||||||
|
Loading…
Reference in New Issue
Block a user