Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit 2778325

Browse files
author
Gabriel Schulhof
committed
[slider] Adding new behaviour to widget definition
1 parent ca3c393 commit 2778325

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

js/widgets/forms/slider.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@
55
//>>css.structure: ../css/structure/jquery.mobile.forms.slider.css
66
//>>css.theme: ../css/themes/default/jquery.mobile.theme.css
77

8-
define( [ "jquery", "../../jquery.mobile.core", "../../jquery.mobile.widget", "./textinput", "../../jquery.mobile.buttonMarkup" ], function( $ ) {
8+
define( [ "jquery", "../../jquery.mobile.core", "../../jquery.mobile.widget", "./textinput", "../../jquery.mobile.buttonMarkup", "./reset" ], function( $ ) {
99
//>>excludeEnd("jqmBuildExclude");
1010
(function( $, undefined ) {
1111

1212
$.widget( "mobile.slider", $.mobile.widget, {
13-
widgetEventPrefix: "slide",
14-
1513
options: {
1614
theme: null,
1715
trackTheme: null,
@@ -178,6 +176,10 @@ $.widget( "mobile.slider", $.mobile.widget, {
178176

179177
this.handle.bind( "vclick", false );
180178

179+
if ( this._handleFormReset ) {
180+
this._handleFormReset();
181+
}
182+
181183
this.refresh( undefined, undefined, true );
182184
},
183185

@@ -341,6 +343,11 @@ $.widget( "mobile.slider", $.mobile.widget, {
341343
return this.isToggleSwitch ? this.element[0].selectedIndex : parseFloat( this.element.val() ) ;
342344
},
343345

346+
347+
_reset: function() {
348+
this.refresh( undefined, false, true );
349+
},
350+
344351
refresh: function( val, isfromControl, preventInputUpdate ) {
345352

346353
// NOTE: we don't return here because we want to support programmatic
@@ -468,6 +475,13 @@ $.widget( "mobile.slider", $.mobile.widget, {
468475

469476
});
470477

478+
$.widget( "mobile.slider", $.mobile.slider, $.mobile.behaviors.formReset );
479+
480+
// FIXME: Move the declaration of widgetEventPrefix back to the top of the
481+
// initial declaration of the slider widget once we start using a version of
482+
// the widget factory that includes a fix for http://bugs.jqueryui.com/ticket/8724
483+
$.widget( "mobile.slider", $.mobile.slider, { widgetEventPrefix: "slide" } );
484+
471485
//auto self-init widgets
472486
$( document ).bind( "pagecreate create", function( e ) {
473487
$.mobile.slider.prototype.enhanceWithin( e.target, true );

0 commit comments

Comments
 (0)