From 37bba1eb920298994903e866625bb662f391a1f5 Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 2 Sep 2013 09:25:00 -0400 Subject: Update AUTHORS.txt. --- AUTHORS.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AUTHORS.txt b/AUTHORS.txt index 6817f2308..b39a038c7 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -226,7 +226,7 @@ Anika Henke Samuel Bovée Fabrício Matté Viktor Kojouharov -Pawel Maruszczyk +Pawel Maruszczyk (http://hrabstwo.net) Pavel Selitskas Bjørn Johansen Matthieu Penant -- cgit v1.2.3 From 6e799c39d33be8eee02224d2f754dc42228a4cbb Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Wed, 11 Sep 2013 22:11:58 +0200 Subject: Widget Bridge: Make the _init method optional. Add tests for both states. Fixes #9543 - Widget bridge: Make _init() optional. --- tests/unit/widget/widget_core.js | 13 ++++++++++++- ui/jquery.ui.widget.js | 5 ++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js index 3db79ec06..ec4c85874 100644 --- a/tests/unit/widget/widget_core.js +++ b/tests/unit/widget/widget_core.js @@ -1409,7 +1409,7 @@ asyncTest( "_delay", function() { }); test( "$.widget.bridge()", function() { - expect( 10 ); + expect( 14 ); var instance, ret, elem = $( "
" ); @@ -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() { diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 885e2019f..b4aab5f3e 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -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 ) ); } -- cgit v1.2.3 From 1552fc8a05ad351650b2a56c5c31905c671f1cdf Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Wed, 11 Sep 2013 22:00:27 +0200 Subject: Spinner: Add isValid method. Fixes #9542 - Spinner: Add isValid() method --- tests/unit/spinner/spinner_methods.js | 32 ++++++++++++++++++++++++++++++++ ui/jquery.ui.spinner.js | 12 ++++++++++++ 2 files changed, 44 insertions(+) diff --git a/tests/unit/spinner/spinner_methods.js b/tests/unit/spinner/spinner_methods.js index 4f44a73ae..41c991be3 100644 --- a/tests/unit/spinner/spinner_methods.js +++ b/tests/unit/spinner/spinner_methods.js @@ -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({ diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js index c022413dc..a4912fc7e 100644 --- a/ui/jquery.ui.spinner.js +++ b/ui/jquery.ui.spinner.js @@ -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; -- cgit v1.2.3 From d13df39e39010bb7cf2cec11b5206e85ea5fca2a Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 16 Sep 2013 11:57:35 -0400 Subject: Widget: Only remove hover and focus classes when disabling, not enabling. Fixes #9558 - Widget: .enable() while already enabled kills ui-state-focus and ui-state-hover. --- ui/jquery.ui.widget.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index b4aab5f3e..a46dcaf99 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -352,8 +352,12 @@ $.Widget.prototype = { if ( key === "disabled" ) { this.widget() .toggleClass( this.widgetFullName + "-disabled", !!value ); - this.hoverable.removeClass( "ui-state-hover" ); - this.focusable.removeClass( "ui-state-focus" ); + + // 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; -- cgit v1.2.3