Skip to content
Browse files

Slider: Made the slider and input together fill full width. Changed c…

…lass ui-slider-mini to ui-mini for consistency. Fixes #5045
  • Loading branch information...
1 parent e55f0f2 commit aca653ec5f1ea2ae2c11ae2b7a6dfa3961d94149 @jaspermdegroot jaspermdegroot committed Dec 20, 2012
Showing with 45 additions and 27 deletions.
  1. +34 −24 css/structure/jquery.mobile.forms.slider.css
  2. +11 −3 js/widgets/forms/slider.js
View
58 css/structure/jquery.mobile.forms.slider.css
@@ -1,40 +1,50 @@
label.ui-slider { font-size: 16px; line-height: 1.4; font-weight: normal; margin: 0 0 .3em; display: block; }
-/* Slider input is always mini sized */
-input.ui-slider-input.ui-mini,
-.ui-field-contain input.ui-slider-input.ui-mini { display: inline-block; width: 45px; background-image: none; padding: .4em; margin: .5em 0; line-height: 1.4; font-size: 14px; outline: 0; }
-.ui-field-contain input.ui-slider-input { margin: 0; }
-input.ui-slider-input, .ui-field-contain input.ui-slider-input { -webkit-box-sizing: content-box; -moz-box-sizing: content-box; -ms-box-sizing: content-box; box-sizing: content-box; }
+
+div.ui-slider { margin: .5em 0; zoom: 1; }
+div.ui-slider.ui-mini { margin: .25em 0; }
+.ui-field-contain div.ui-slider, .ui-field-contain div.ui-slider.ui-mini { margin: 0; }
+div.ui-slider:before, div.ui-slider:after { content: ""; display: table; }
+div.ui-slider:after { clear: both; }
+
+/* Slider input is always mini sized. High level of specificity to override textinput CSS. */
+input.ui-input-text.ui-slider-input.ui-mini { display: block; float: left; width: 45px; background-image: none; padding: .4em; margin: 0; line-height: 1.4; font-size: 14px; outline: 0; }
+input.ui-input-text.ui-slider-input.ui-mini { -webkit-box-sizing: content-box; -moz-box-sizing: content-box; -ms-box-sizing: content-box; box-sizing: content-box; }
/* Fixes input fields being to small on Safari/Mac because of the up and down arrows. */
.ui-slider-input::-webkit-outer-spin-button { margin: 0; }
-select.ui-slider-switch { display: none; }
-div.ui-slider { position: relative; display: inline-block; overflow: visible; height: 15px; padding: 0; margin: 0 2% 0 20px; top: 4px; width: 65%; }
-div.ui-slider-mini { height: 12px; margin-left: 10px; top: 2px; }
+
+.ui-slider-app { position: relative; overflow: visible; height: 15px; margin: 7px 15px 8px 88px; }
+.ui-slider-app.ui-mini { height: 12px; margin: 9px 8px 9px 74px; }
+
div.ui-slider-bg { border: none; height: 100%; padding-right: 8px; }
-.ui-controlgroup a.ui-slider-handle, a.ui-btn.ui-slider-handle { position: absolute; z-index: 1; top: 50%; width: 28px; height: 28px; margin: -15px 0 0 -15px; outline: 0; }
-a.ui-btn.ui-slider-handle .ui-btn-inner { padding: 0; height: 100%; }
-div.ui-slider-mini a.ui-slider-handle { height: 14px; width: 14px; margin: -8px 0 0 -7px; }
-div.ui-slider-mini a.ui-slider-handle .ui-btn-inner { height: 30px; width: 30px; padding: 0; margin: -9px 0 0 -9px; border-top: none; }
-@media all and (min-width: 28em){
- .ui-field-contain label.ui-slider { vertical-align: top; display: inline-block; width: 20%; margin: 0 2% 0 0; }
- .ui-field-contain div.ui-slider { width: 43%; }
- .ui-field-contain div.ui-slider-switch { width: 5.5em; }
-}
+a.ui-btn.ui-slider-handle { position: absolute; z-index: 1; top: 50%; width: 28px; height: 28px; margin: -15px 0 0 -15px; outline: 0; }
+.ui-slider-app.ui-mini a.ui-slider-handle { height: 14px; width: 14px; margin: -8px 0 0 -7px; }
+
+a.ui-btn.ui-slider-handle .ui-btn-inner { padding: 0; height: 100%; }
+div.ui-slider.ui-mini a.ui-slider-handle .ui-btn-inner { height: 30px; width: 30px; padding: 0; margin: -9px 0 0 -9px; border-top: none; }
-div.ui-slider-switch { height: 32px; margin-left: 0; width: 5.8em; }
+select.ui-slider-switch { display: none; }
+div.ui-slider-switch { position: relative; display: inline-block; overflow: visible; height: 32px; width: 5.8em; margin: .5em 0; }
a.ui-slider-handle-snapping { -webkit-transition: left 70ms linear; -moz-transition: left 70ms linear; }
div.ui-slider-switch .ui-slider-handle { margin: 1px 0 0 -15px; }
.ui-slider-inneroffset { margin: 0 16px; position: relative; z-index: 1; }
-div.ui-slider-switch.ui-slider-mini { width: 5em; height: 29px; }
-div.ui-slider-switch.ui-slider-mini .ui-slider-inneroffset { margin: 0 15px 0 14px; }
-div.ui-slider-switch.ui-slider-mini .ui-slider-handle { width: 25px; height: 25px; margin: 1px 0 0 -13px; }
-div.ui-slider-switch.ui-slider-mini a.ui-slider-handle .ui-btn-inner { height: 30px; width: 30px; padding: 0; margin: 0; }
+div.ui-slider-switch.ui-mini { width: 5em; height: 29px; margin: .25em 0; }
+div.ui-slider-switch.ui-mini .ui-slider-inneroffset { margin: 0 15px 0 14px; }
+div.ui-slider-switch.ui-mini .ui-slider-handle { width: 25px; height: 25px; margin: 1px 0 0 -13px; }
+div.ui-slider-switch.ui-mini a.ui-slider-handle .ui-btn-inner { height: 30px; width: 30px; padding: 0; margin: 0; }
-span.ui-slider-label { position: absolute; text-align: center; width: 100%; overflow: hidden; font-size: 16px; top: 0; line-height: 2; min-height: 100%; border-width: 0; white-space: nowrap; cursor:pointer; }
-.ui-slider-mini span.ui-slider-label { font-size: 14px; }
+.ui-slider-switch span.ui-slider-label { position: absolute; text-align: center; width: 100%; overflow: hidden; font-size: 16px; top: 0; line-height: 2; min-height: 100%; border-width: 0; white-space: nowrap; cursor:pointer; }
+.ui-slider-switch.ui-mini span.ui-slider-label { font-size: 14px; }
span.ui-slider-label-a { z-index: 1; left: 0; text-indent: -1.5em; }
span.ui-slider-label-b { z-index: 0; right: 0; text-indent: 1.5em;}
.ui-slider-inline { width: 120px; display: inline-block; }
+
+@media all and (min-width: 28em){
+ .ui-field-contain label.ui-slider { vertical-align: top; display: inline-block; width: 20%; margin: 0 2% 0 0; }
+ .ui-field-contain div.ui-slider { display: inline-block; width: 78%; }
+ .ui-field-contain div.ui-slider-switch { width: 5.5em; margin: 0; }
+ .ui-field-contain.ui-hide-label div.ui-slider { display: block; width: auto; }
+}
View
14 js/widgets/forms/slider.js
@@ -31,6 +31,7 @@ $.widget( "mobile.slider", $.mobile.widget, {
trackTheme = this.options.trackTheme || parentTheme,
cType = control[ 0 ].nodeName.toLowerCase(),
isSelect = this.isToggleSwitch = cType === "select",
+ isRangeslider = control.parent().is( ":jqmData(role='rangeslider')" ),
selectClass = ( this.isToggleSwitch ) ? "ui-slider-switch" : "",
controlID = control.attr( "id" ),
$label = $( "[for='" + controlID + "']" ),
@@ -40,7 +41,7 @@ $.widget( "mobile.slider", $.mobile.widget, {
max = !this.isToggleSwitch ? parseFloat( control.attr( "max" ) ) : control.find( "option" ).length-1,
step = window.parseFloat( control.attr( "step" ) || 1 ),
inlineClass = ( this.options.inline || control.jqmData( "inline" ) === true ) ? " ui-slider-inline" : "",
- miniClass = ( this.options.mini || control.jqmData( "mini" ) ) ? " ui-slider-mini" : "",
+ miniClass = ( this.options.mini || control.jqmData( "mini" ) ) ? " ui-mini" : "",
domHandle = document.createElement( "a" ),
handle = $( domHandle ),
domSlider = document.createElement( "div" ),
@@ -55,7 +56,7 @@ $.widget( "mobile.slider", $.mobile.widget, {
this.element.addClass("ui-mini");
domHandle.setAttribute( "href", "#" );
domSlider.setAttribute( "role", "application" );
- domSlider.className = ["ui-slider ",selectClass," ui-btn-down-",trackTheme," ui-btn-corner-all", inlineClass, miniClass].join( "" );
+ domSlider.className = ["ui-slider-app ",selectClass," ui-btn-down-",trackTheme," ui-btn-corner-all", inlineClass, miniClass].join( "" );
domHandle.className = "ui-slider-handle";
domSlider.appendChild( domHandle );
@@ -118,6 +119,13 @@ $.widget( "mobile.slider", $.mobile.widget, {
}
label.addClass( "ui-slider" );
+
+ // wrap the slider in a div for styling purposes
+ if ( !this.isToggleSwitch && !isRangeslider ) {
+ var wrapper = this.options.mini ? "<div class='ui-slider ui-mini'>" : "<div class='ui-slider'>";
+
+ control.wrap( wrapper );
+ }
// monitor the input for updated values
control.addClass( this.isToggleSwitch ? "ui-slider-switch" : "ui-slider-input" );
@@ -350,7 +358,7 @@ $.widget( "mobile.slider", $.mobile.widget, {
theme = this.options.theme || parentTheme,
trackTheme = this.options.trackTheme || parentTheme;
- self.slider[0].className = ['ui-slider ', ( this.isToggleSwitch ) ? "ui-slider-switch" : ""," ui-btn-down-" + trackTheme,' ui-btn-corner-all', ( this.options.inline ) ? " ui-slider-inline" : "", ( this.options.mini ) ? " ui-slider-mini":""].join( "" );
+ self.slider[0].className = ['ui-slider-app ', ( this.isToggleSwitch ) ? "ui-slider-switch" : ""," ui-btn-down-" + trackTheme,' ui-btn-corner-all', ( this.options.inline ) ? " ui-slider-inline" : "", ( this.options.mini ) ? " ui-mini":""].join( "" );
if ( this.options.disabled || this.element.attr( "disabled" ) ) {
this.disable();
}

0 comments on commit aca653e

Please sign in to comment.
Something went wrong with that request. Please try again.