Spinner: Remove core event/alias and deprecated module dependencies

This commit is contained in:
Alexander Schmitz 2015-05-13 22:01:44 -04:00
parent d157b59a51
commit 89bf0d057b
8 changed files with 26 additions and 26 deletions

View File

@ -16,7 +16,7 @@
<link rel="stylesheet" href="../demos.css">
<script>
$(function() {
$( "#currency" ).change(function() {
$( "#currency" ).on( "change", function() {
$( "#spinner" ).spinner( "option", "culture", $( this ).val() );
});

View File

@ -21,7 +21,7 @@
numberFormat: "n"
});
$( "#culture" ).change(function() {
$( "#culture" ).on( "change", function() {
var current = $( "#spinner" ).spinner( "value" );
Globalize.culture( $(this).val() );
$( "#spinner" ).spinner( "value", current );

View File

@ -15,24 +15,24 @@
$(function() {
var spinner = $( "#spinner" ).spinner();
$( "#disable" ).click(function() {
$( "#disable" ).on( "click", function() {
if ( spinner.spinner( "option", "disabled" ) ) {
spinner.spinner( "enable" );
} else {
spinner.spinner( "disable" );
}
});
$( "#destroy" ).click(function() {
$( "#destroy" ).on( "click", function() {
if ( spinner.spinner( "instance" ) ) {
spinner.spinner( "destroy" );
} else {
spinner.spinner();
}
});
$( "#getvalue" ).click(function() {
$( "#getvalue" ).on( "click", function() {
alert( spinner.spinner( "value" ) );
});
$( "#setvalue" ).click(function() {
$( "#setvalue" ).on( "click", function() {
spinner.spinner( "value", 5 );
});

View File

@ -41,7 +41,7 @@
$(function() {
$( "#spinner" ).timespinner();
$( "#culture" ).change(function() {
$( "#culture" ).on( "change", function() {
var current = $( "#spinner" ).timespinner( "value" );
Globalize.culture( $(this).val() );
$( "#spinner" ).timespinner( "value", current );

View File

@ -114,7 +114,7 @@ asyncTest( "blur input while spinning with UP", function() {
value = element.val();
ok( value > 11, "repeating while key is down" );
element.bind( "blur", function() {
element.on( "blur", function() {
value = element.val();
setTimeout( step3, 750 );
})[ 0 ].blur();
@ -225,16 +225,16 @@ test( "ARIA attributes", function() {
test( "focus text field when pressing button", function() {
expect( 2 );
var element = $( "#spin" ).spinner();
$( "body" ).focus();
$( "body" ).trigger( "focus" );
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" );
});
test( "don't clear invalid value on blur", function() {
expect( 1 );
var element = $( "#spin" ).spinner();
element.focus().val( "a" ).blur();
element.trigger( "focus" ).val( "a" ).trigger( "blur" );
equal( element.val(), "a" );
});

View File

@ -29,9 +29,9 @@ test( "start", function() {
simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
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" );
element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
element.spinner( "widget" ).find( ".ui-spinner-down" ).trigger( "mousedown" ).trigger( "mouseup" );
shouldStart( true, "stepUp" );
element.spinner( "stepUp" );
@ -68,9 +68,9 @@ test( "spin", function() {
simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
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" );
element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
element.spinner( "widget" ).find( ".ui-spinner-down" ).trigger( "mousedown" ).trigger( "mouseup" );
shouldSpin( true, "stepUp" );
element.spinner( "stepUp" );
@ -107,9 +107,9 @@ test( "stop", function() {
simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
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" );
element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
element.spinner( "widget" ).find( ".ui-spinner-down" ).trigger( "mousedown" ).trigger( "mouseup" );
shouldStop( true, "stepUp" );
element.spinner( "stepUp" );
@ -200,7 +200,7 @@ asyncTest( "change", function() {
shouldChange( false, "blur after many keys, same final value" );
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" );
}, step7 );
}
@ -208,7 +208,7 @@ asyncTest( "change", function() {
function step7() {
focusWrap(function() {
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" );
}, step8 );
}
@ -216,10 +216,10 @@ asyncTest( "change", function() {
function step8() {
focusWrap(function() {
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" ).mousedown().mouseup();
element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
element.spinner( "widget" ).find( ".ui-spinner-down" ).mousedown().mouseup();
element.spinner( "widget" ).find( ".ui-spinner-up" ).trigger( "mousedown" ).trigger( "mouseup" );
element.spinner( "widget" ).find( ".ui-spinner-up" ).trigger( "mousedown" ).trigger( "mouseup" );
element.spinner( "widget" ).find( ".ui-spinner-down" ).trigger( "mousedown" ).trigger( "mouseup" );
element.spinner( "widget" ).find( ".ui-spinner-down" ).trigger( "mousedown" ).trigger( "mouseup" );
shouldChange( false, "blur after many buttons, same final value" );
}, step9 );
}

View File

@ -181,7 +181,7 @@ test( "max", function() {
element.spinner( "value", 1000 );
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" );
});
@ -209,7 +209,7 @@ test( "min", function() {
element.spinner( "value", -1000 );
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" );
});

View File

@ -165,7 +165,7 @@ return $.widget( "ui.spinner", {
function checkFocus() {
var isActive = this.element[ 0 ] === $.ui.safeActiveElement( this.document[ 0 ] );
if ( !isActive ) {
this.element.focus();
this.element.trigger( "focus" );
this.previous = previous;
// support: IE
// IE sets focus asynchronously, so we need to check if focus