From aa7a04b4ec4dddcc0ee060ca65df6fc95e8bcb91 Mon Sep 17 00:00:00 2001 From: Gabriel Schulhof Date: Fri, 16 Nov 2012 00:13:33 +0200 Subject: [PATCH] [controlgroup] Reinstate <= 1.2.0 functionality whereby running .controlgroup() on an already-enhanced controlgroup is the same as running .controlgroup( "refresh" ) --- js/widgets/controlgroup.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/js/widgets/controlgroup.js b/js/widgets/controlgroup.js index 27793ffafa0..e86b78e2b79 100644 --- a/js/widgets/controlgroup.js +++ b/js/widgets/controlgroup.js @@ -38,14 +38,20 @@ define( [ "jquery", } $el.addClass( "ui-corner-all ui-controlgroup" ); + $.extend( this, { + _initialRefresh: true + }); + $.each( this.options, function( key, value ) { // Cause initial options to be applied by their handler by temporarily setting the option to undefined // - the handler then sets it to the initial value self.options[ key ] = undefined; self._setOption( key, value, true ); }); + }, - this._refresh( true ); + _init: function() { + this.refresh(); }, _setOption: function( key, value ) { @@ -63,7 +69,7 @@ define( [ "jquery", this.element .removeClass( "ui-controlgroup-horizontal ui-controlgroup-vertical" ) .addClass( "ui-controlgroup-" + value ); - this._refresh( false ); + this.refresh(); }, _setCorners: function( value ) { @@ -82,16 +88,14 @@ define( [ "jquery", return this.element.children( ".ui-controlgroup-controls" ); }, - _refresh: function( create ) { - var els = this.element.find( ".ui-btn" ).not( ".ui-slider-handle" ); + refresh: function() { + var els = this.element.find( ".ui-btn" ).not( ".ui-slider-handle" ), + create = this._initialRefresh; if ( $.mobile.checkboxradio ) { this.element.find( ":mobile-checkboxradio" ).checkboxradio( "refresh" ); } this._addFirstLastClasses( els, this.options.excludeInvisible ? this._getVisibles( els, create ) : els, create ); - }, - - refresh: function() { - this._refresh( false ); + this._initialRefresh = false; } });