mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Merge branch 'selectmenu' of github.com:jquery/jquery-ui into selectmenu
This commit is contained in:
commit
de4e863552
@ -226,7 +226,7 @@ Anika Henke <anika@selfthinker.org>
|
||||
Samuel Bovée <samycookie2000@yahoo.fr>
|
||||
Fabrício Matté <ult_combo@hotmail.com>
|
||||
Viktor Kojouharov <vkojouharov@gmail.com>
|
||||
Pawel Maruszczyk <lord_t@o2.pl>
|
||||
Pawel Maruszczyk (http://hrabstwo.net)
|
||||
Pavel Selitskas <p.selitskas@gmail.com>
|
||||
Bjørn Johansen <bjorn.johansen@metronet.no>
|
||||
Matthieu Penant <thieum22@hotmail.com>
|
||||
|
@ -73,6 +73,38 @@ test( "enable", function() {
|
||||
equal( 2, element.val(), "keyboard - value changes on key UP" );
|
||||
});
|
||||
|
||||
test( "isValid", function() {
|
||||
expect( 8 );
|
||||
var element = $( "#spin" ).spinner({
|
||||
min: 0,
|
||||
max: 10,
|
||||
step: 2
|
||||
}),
|
||||
spinner = element.spinner( "instance" );
|
||||
ok( !spinner.isValid(), "initial state is invalid" );
|
||||
|
||||
element.val( "this is not a number" );
|
||||
ok( !spinner.isValid(), "text string is not valid" );
|
||||
|
||||
element.val( "0" );
|
||||
ok( spinner.isValid(), "min value is valid" );
|
||||
|
||||
element.val( "10" );
|
||||
ok( spinner.isValid(), "max value is valid" );
|
||||
|
||||
element.val( "4" );
|
||||
ok( spinner.isValid(), "inbetween step is valid" );
|
||||
|
||||
element.val( "-1" );
|
||||
ok( !spinner.isValid(), "below min is invalid" );
|
||||
|
||||
element.val( "11" );
|
||||
ok( !spinner.isValid(), "above max is invalid" );
|
||||
|
||||
element.val( "1" );
|
||||
ok( !spinner.isValid(), "step mismatch is invalid" );
|
||||
});
|
||||
|
||||
test( "pageDown", function() {
|
||||
expect( 4 );
|
||||
var element = $( "#spin" ).val( -12 ).spinner({
|
||||
|
@ -1409,7 +1409,7 @@ asyncTest( "_delay", function() {
|
||||
});
|
||||
|
||||
test( "$.widget.bridge()", function() {
|
||||
expect( 10 );
|
||||
expect( 14 );
|
||||
|
||||
var instance, ret,
|
||||
elem = $( "<div>" );
|
||||
@ -1427,6 +1427,9 @@ test( "$.widget.bridge()", function() {
|
||||
},
|
||||
getter: function() {
|
||||
return "qux";
|
||||
},
|
||||
option: function( options ) {
|
||||
deepEqual( options, {} );
|
||||
}
|
||||
});
|
||||
|
||||
@ -1444,6 +1447,14 @@ test( "$.widget.bridge()", function() {
|
||||
|
||||
ret = elem.testWidget( "getter" );
|
||||
equal( ret, "qux", "getter returns value" );
|
||||
|
||||
elem.testWidget();
|
||||
ok( true, "_init is optional" );
|
||||
|
||||
TestWidget.prototype._init = function() {
|
||||
ok( "_init", "_init now exists, so its called" );
|
||||
};
|
||||
elem.testWidget();
|
||||
});
|
||||
|
||||
test( "$.widget.bridge() - widgetFullName", function() {
|
||||
|
12
ui/jquery.ui.spinner.js
vendored
12
ui/jquery.ui.spinner.js
vendored
@ -418,6 +418,18 @@ $.widget( "ui.spinner", {
|
||||
});
|
||||
},
|
||||
|
||||
isValid: function() {
|
||||
var value = this.value();
|
||||
|
||||
// null is invalid
|
||||
if ( value === null ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// if value gets adjusted, it's invalid
|
||||
return value === this._adjustValue( value );
|
||||
},
|
||||
|
||||
// update the value without triggering change
|
||||
_value: function( value, allowAny ) {
|
||||
var parsed;
|
||||
|
9
ui/jquery.ui.widget.js
vendored
9
ui/jquery.ui.widget.js
vendored
@ -203,7 +203,10 @@ $.widget.bridge = function( name, object ) {
|
||||
this.each(function() {
|
||||
var instance = $.data( this, fullName );
|
||||
if ( instance ) {
|
||||
instance.option( options || {} )._init();
|
||||
instance.option( options || {} );
|
||||
if ( instance._init ) {
|
||||
instance._init();
|
||||
}
|
||||
} else {
|
||||
$.data( this, fullName, new object( options, this ) );
|
||||
}
|
||||
@ -349,9 +352,13 @@ $.Widget.prototype = {
|
||||
if ( key === "disabled" ) {
|
||||
this.widget()
|
||||
.toggleClass( this.widgetFullName + "-disabled", !!value );
|
||||
|
||||
// If the widget is becoming disabled, then nothing is interactive
|
||||
if ( value ) {
|
||||
this.hoverable.removeClass( "ui-state-hover" );
|
||||
this.focusable.removeClass( "ui-state-focus" );
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user