Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #5216 from jquery/fix-5137-3

The extension-based approach -- Fixes #5137
  • Loading branch information...
commit 010ec24cb3c88baab0930c6d264c1aebd8c23440 2 parents 4527be3 + 2778325
@gabrielschulhof gabrielschulhof authored
View
3  js/index.php
@@ -19,7 +19,7 @@
'jquery.hashchange.js',
'widgets/page.js',
'jquery.mobile.core.js',
- 'widgets/loader.js',
+ 'widgets/loader.js',
'jquery.mobile.navigation.js',
'jquery.mobile.navigation.pushstate.js',
'jquery.mobile.transition.js',
@@ -42,6 +42,7 @@
'widgets/listview.filter.js',
'widgets/listview.autodividers.js',
'jquery.mobile.nojs.js',
+ 'widgets/forms/reset.js',
'widgets/forms/checkboxradio.js',
'widgets/forms/button.js',
'widgets/forms/slider.js',
View
3  js/jquery.mobile.core.js
@@ -120,6 +120,9 @@ define( [ "jquery", "text!../version.txt" ], function( $, __version__ ) {
WINDOWS: 91 // COMMAND
},
+ // Place to store various widget extensions
+ behaviors: {},
+
// Scroll page vertically: scroll to 0 to hide iOS address bar, or pass a Y value
silentScroll: function( ypos ) {
if ( $.type( ypos ) !== "number" ) {
View
11 js/widgets/forms/checkboxradio.js
@@ -9,7 +9,7 @@
//>>css.structure: ../css/structure/jquery.mobile.forms.checkboxradio.css
//>>css.theme: ../css/themes/default/jquery.mobile.theme.css
-define( [ "jquery", "../../jquery.mobile.core", "../../jquery.mobile.widget", "../../jquery.mobile.buttonMarkup" ], function( $ ) {
+define( [ "jquery", "../../jquery.mobile.core", "../../jquery.mobile.widget", "../../jquery.mobile.buttonMarkup", "./reset" ], function( $ ) {
//>>excludeEnd("jqmBuildExclude");
(function( $, undefined ) {
@@ -138,6 +138,9 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
}
});
+ if ( this._handleFormReset ) {
+ this._handleFormReset();
+ }
this.refresh();
},
@@ -170,6 +173,10 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
.checkboxradio( "refresh" );
},
+ _reset: function() {
+ this.refresh();
+ },
+
refresh: function() {
var input = this.element[0],
label = this.label,
@@ -199,6 +206,8 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
}
});
+$.widget( "mobile.checkboxradio", $.mobile.checkboxradio, $.mobile.behaviors.formReset );
+
//auto self-init widgets
$( document ).bind( "pagecreate create", function( e ) {
$.mobile.checkboxradio.prototype.enhanceWithin( e.target, true );
View
23 js/widgets/forms/reset.js
@@ -0,0 +1,23 @@
+//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
+//>>description: Make a widget react to a form's reset.
+//>>label: formReset
+//>>group: Forms
+
+define( [ "jquery", "../../jquery.mobile.core" ], function( $ ) {
+//>>excludeEnd("jqmBuildExclude");
+(function( $, undefined ) {
+
+$.mobile.behaviors.formReset = {
+ _handleFormReset: function() {
+ this._on( this.element.closest( "form" ), {
+ reset: function() {
+ this._delay( "_reset" );
+ }
+ });
+ }
+};
+
+})( jQuery );
+//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
+});
+//>>excludeEnd("jqmBuildExclude");
View
11 js/widgets/forms/select.js
@@ -5,7 +5,7 @@
//>>css.structure: ../css/structure/jquery.mobile.forms.select.css
//>>css.theme: ../css/themes/default/jquery.mobile.theme.css
-define( [ "jquery", "../../jquery.mobile.core", "../../jquery.mobile.widget", "../../jquery.mobile.buttonMarkup", "../../jquery.mobile.zoom" ], function( $ ) {
+define( [ "jquery", "../../jquery.mobile.core", "../../jquery.mobile.widget", "../../jquery.mobile.buttonMarkup", "../../jquery.mobile.zoom", "./reset" ], function( $ ) {
//>>excludeEnd("jqmBuildExclude");
(function( $, undefined ) {
@@ -141,6 +141,9 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
self.refresh();
});
+ if ( this._handleFormReset ) {
+ this._handleFormReset();
+ }
this.build();
},
@@ -231,6 +234,10 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
}
},
+ _reset: function() {
+ this.refresh();
+ },
+
refresh: function() {
this.setButtonText();
this.setButtonCount();
@@ -252,6 +259,8 @@ $.widget( "mobile.selectmenu", $.mobile.widget, {
}
});
+$.widget( "mobile.selectmenu", $.mobile.selectmenu, $.mobile.behaviors.formReset );
+
//auto self-init widgets
$( document ).bind( "pagecreate create", function( e ) {
$.mobile.selectmenu.prototype.enhanceWithin( e.target, true );
View
20 js/widgets/forms/slider.js
@@ -5,13 +5,11 @@
//>>css.structure: ../css/structure/jquery.mobile.forms.slider.css
//>>css.theme: ../css/themes/default/jquery.mobile.theme.css
-define( [ "jquery", "../../jquery.mobile.core", "../../jquery.mobile.widget", "./textinput", "../../jquery.mobile.buttonMarkup" ], function( $ ) {
+define( [ "jquery", "../../jquery.mobile.core", "../../jquery.mobile.widget", "./textinput", "../../jquery.mobile.buttonMarkup", "./reset" ], function( $ ) {
//>>excludeEnd("jqmBuildExclude");
(function( $, undefined ) {
$.widget( "mobile.slider", $.mobile.widget, {
- widgetEventPrefix: "slide",
-
options: {
theme: null,
trackTheme: null,
@@ -178,6 +176,10 @@ $.widget( "mobile.slider", $.mobile.widget, {
this.handle.bind( "vclick", false );
+ if ( this._handleFormReset ) {
+ this._handleFormReset();
+ }
+
this.refresh( undefined, undefined, true );
},
@@ -341,6 +343,11 @@ $.widget( "mobile.slider", $.mobile.widget, {
return this.isToggleSwitch ? this.element[0].selectedIndex : parseFloat( this.element.val() ) ;
},
+
+ _reset: function() {
+ this.refresh( undefined, false, true );
+ },
+
refresh: function( val, isfromControl, preventInputUpdate ) {
// NOTE: we don't return here because we want to support programmatic
@@ -468,6 +475,13 @@ $.widget( "mobile.slider", $.mobile.widget, {
});
+$.widget( "mobile.slider", $.mobile.slider, $.mobile.behaviors.formReset );
+
+// FIXME: Move the declaration of widgetEventPrefix back to the top of the
+// initial declaration of the slider widget once we start using a version of
+// the widget factory that includes a fix for http://bugs.jqueryui.com/ticket/8724
+$.widget( "mobile.slider", $.mobile.slider, { widgetEventPrefix: "slide" } );
+
//auto self-init widgets
$( document ).bind( "pagecreate create", function( e ) {
$.mobile.slider.prototype.enhanceWithin( e.target, true );
Please sign in to comment.
Something went wrong with that request. Please try again.