From 4a3e4ec4275c73595c3dec0aeb0fd03fae12e80c Mon Sep 17 00:00:00 2001 From: scottjehl Date: Thu, 14 Oct 2010 09:24:51 -0400 Subject: [PATCH] added option trackTheme, which uses the btn-down state and defaults either a data-tracktheme attr, finding a themed parent, or 'd'. Button "theme" option defaults to "b", and can be set through the data-theme attr. Fixes #168 --- js/jquery.mobile.forms.slider.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/js/jquery.mobile.forms.slider.js b/js/jquery.mobile.forms.slider.js index 93f01bf6..4269e5f0 100644 --- a/js/jquery.mobile.forms.slider.js +++ b/js/jquery.mobile.forms.slider.js @@ -8,9 +8,13 @@ $.fn.slider = function(options){ return this.each(function(){ var control = $(this), + themedParent = control.closest('[class*=ui-bar-],[class*=ui-body-]'), + o = $.extend({ - theme: control.data("theme") || 'c' + trackTheme: control.data("tracktheme") || (themedParent.length ? themedParent.attr('class').match(/ui-(bar|body)-([a-z])/)[2] : 'd'), + theme: control.data("theme") || 'b' },options), + cType = control[0].nodeName.toLowerCase(), selectClass = (cType == 'select') ? 'ui-slider-switch' : '', controlID = control.attr('id'), @@ -21,7 +25,7 @@ $.fn.slider = function(options){ max = (cType == 'input') ? parseFloat(control.attr('max')) : control.find('option').length-1, percent = val / (max - min) * 100, snappedPercent = percent, - slider = $('
'), + slider = $('
'), handle = $('') .appendTo(slider) .buttonMarkup({corners: true, theme: o.theme, shadow: true}) @@ -43,9 +47,9 @@ $.fn.slider = function(options){ control.find('option').each(function(i){ var side = (i==0) ?'b':'a', corners = (i==0) ? 'right' :'left', - theme = (i==0) ? o.theme :'b'; - $('
').prependTo(slider); - $(''+$(this).text()+'').prependTo(handle); + theme = (i==0) ? ' ui-btn-down-' + o.trackTheme :' ui-btn-active'; + $('
').prependTo(slider); + $(''+$(this).text()+'').prependTo(handle); }); }