1 From d91978cf6366c05780ed223264f65869387bc4a4 Mon Sep 17 00:00:00 2001
2 From: Jun Jinhyuk <jinhyuk.jun@samsung.com>
3 Date: Fri, 7 Dec 2012 10:33:32 +0900
4 Subject: [PATCH] JQM: add tizen toggle switch
6 Signed-off-by: Jun Jinhyuk <jinhyuk.jun@samsung.com>
8 .../jquery-mobile-1.2.0/js/widgets/forms/slider.js | 44 +++++++++++++++-----
9 1 files changed, 33 insertions(+), 11 deletions(-)
11 diff --git a/libs/js/jquery-mobile-1.2.0/js/widgets/forms/slider.js b/libs/js/jquery-mobile-1.2.0/js/widgets/forms/slider.js
12 index e7f5df0..2e682db 100644
13 --- a/libs/js/jquery-mobile-1.2.0/js/widgets/forms/slider.js
14 +++ b/libs/js/jquery-mobile-1.2.0/js/widgets/forms/slider.js
15 @@ -81,6 +81,10 @@ $.widget( "mobile.slider", $.mobile.widget, {
16 domHandle.className = 'ui-slider-handle';
17 domSlider.appendChild( domHandle );
19 + if ( $( control ).find( "option" ).length && $( control ).find( "option" ).text() === "" ) {
20 + $( domSlider ).addClass( "ui-toggle-switch" );
23 handle.buttonMarkup({ corners: true, theme: theme, shadow: true })
26 @@ -324,7 +328,12 @@ $.widget( "mobile.slider", $.mobile.widget, {
29 refresh: function( val, isfromControl, preventInputUpdate ) {
30 + var imgToggle = false,
33 + if ( $( this.handle ).parents().is( ".ui-toggle-switch" ) ) {
36 // NOTE: we don't return here because we want to support programmatic
37 // alteration of the input value, which should still update the slider
38 if ( this.options.disabled || this.element.attr('disabled')) {
39 @@ -397,20 +406,33 @@ $.widget( "mobile.slider", $.mobile.widget, {
40 title: cType === "input" ? newval : control.find( "option" ).eq( newval ).getEncodedText()
43 - if ( this.valuebg ) {
44 - this.valuebg.css( "width", percent + "%" );
46 + if ( this.valuebg ) {
47 + this.valuebg.css( "width", percent + "%" );
51 // drag the label widths
52 - if ( this._labels ) {
53 - var handlePercent = this.handle.width() / this.slider.width() * 100,
54 - aPercent = percent && handlePercent + ( 100 - handlePercent ) * percent / 100,
55 - bPercent = percent === 100 ? 0 : Math.min( handlePercent + 100 - aPercent, 100 );
57 - this._labels.each(function() {
58 - var ab = $( this ).is( ".ui-slider-label-a" );
59 - $( this ).width( ( ab ? aPercent : bPercent ) + "%" );
62 + appHandle = $( this.handle ).parents( ".ui-slider" );
63 + if ( $( this.handle ).attr("aria-valuenow") === "on" ) {
64 + appHandle.children( "span.ui-slider-label-a" ).show();
65 + appHandle.children( "span.ui-slider-label-b" ).hide();
67 + appHandle.children( "span.ui-slider-label-b" ).show();
68 + appHandle.children( "span.ui-slider-label-a" ).hide();
71 + if ( this._labels ) {
72 + var handlePercent = this.handle.width() / this.slider.width() * 100,
73 + aPercent = percent && handlePercent + ( 100 - handlePercent ) * percent / 100,
74 + bPercent = percent === 100 ? 0 : Math.min( handlePercent + 100 - aPercent, 100 );
76 + this._labels.each(function() {
77 + var ab = $( this ).is( ".ui-slider-label-a" );
78 + $( this ).width( ( ab ? aPercent : bPercent ) + "%" );
83 if ( !preventInputUpdate ) {