1 From e424c135d1a438cc234107bb45608baa26139ebc Mon Sep 17 00:00:00 2001
2 From: Koeun Choi <koeun.choi@samsung.com>
3 Date: Wed, 15 Feb 2012 19:34:44 +0900
4 Subject: [PATCH] JQM:checkbox pressed, no-lable support
7 .../js/jquery.mobile.forms.checkboxradio.js | 60 ++++++++++++++++++--
8 1 files changed, 55 insertions(+), 5 deletions(-)
10 diff --git a/libs/js/jquery-mobile-1.0.1pre/js/jquery.mobile.forms.checkboxradio.js b/libs/js/jquery-mobile-1.0.1pre/js/jquery.mobile.forms.checkboxradio.js
11 index d09a422..6b2268f 100644
12 --- a/libs/js/jquery-mobile-1.0.1pre/js/jquery.mobile.forms.checkboxradio.js
13 +++ b/libs/js/jquery-mobile-1.0.1pre/js/jquery.mobile.forms.checkboxradio.js
14 @@ -23,11 +23,22 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
15 checkedClass = "ui-" + checkedState + activeBtn,
16 uncheckedClass = "ui-" + uncheckedState,
17 checkedicon = "ui-icon-" + checkedState,
18 - uncheckedicon = "ui-icon-" + uncheckedState;
19 + uncheckedicon = "ui-icon-" + uncheckedState,
20 + checkedpressedicon = checkedicon + "-press",
21 + uncheckedpressedicon = uncheckedicon + "-press";
23 if ( inputtype !== "checkbox" && inputtype !== "radio" ) {
26 + // Support fake label
27 + if ( label.length == 0 ) {
29 + label = $( "<label for='" + input[ 0 ].id + "' style='display:block;width:1px;height:1px;'></label>" );
32 + // Wrap the input + label in a div
34 + .wrapAll( "<div class='ui-" + inputtype + "'></div>" );
36 // Expose for other methods
38 @@ -36,7 +47,9 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
39 checkedClass: checkedClass,
40 uncheckedClass: uncheckedClass,
41 checkedicon: checkedicon,
42 - uncheckedicon: uncheckedicon
43 + uncheckedicon: uncheckedicon,
44 + checkedpressedicon: checkedpressedicon,
45 + uncheckedpressedicon: uncheckedpressedicon
48 // If there's no selected theme...
49 @@ -50,11 +63,20 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
53 - // Wrap the input + label in a div
55 - .wrapAll( "<div class='ui-" + inputtype + "'></div>" );
56 + // TODO : support either data-style or class...
57 + if ( input.hasClass( "favorite" ) ) {
58 + input.parent().addClass( "favorite" ).end();
62 + vmousedown: function() {
65 + vmouseup: function() {
70 vmouseover: function( event ) {
71 if ( $( this ).parent().is( ".ui-disabled" ) ) {
72 event.stopPropagation();
73 @@ -154,6 +176,34 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
74 .checkboxradio( "refresh" );
78 + var input = this.element,
80 + icon = label.find( ".ui-icon" );
82 + if ( !$( input[ 0 ] ).is( ":disabled" ) ) {
83 + if ( $( input[ 0 ] ).prop( "checked" ) ) {
84 + icon.addClass( this.uncheckedpressedicon ).removeClass( this.checkedicon );
86 + icon.removeClass( this.uncheckedicon ).addClass( this.checkedpressedicon );
91 + unpress: function() {
92 + var input = this.element,
94 + icon = label.find( ".ui-icon" );
96 + if ( !$( input[ 0 ] ).is( ":disabled" ) ) {
97 + if ( $( input[ 0 ] ).prop( "checked" ) ) {
98 + icon.removeClass( this.uncheckedpressedicon ).addClass( this.uncheckedicon );
100 + icon.addClass( this.checkedicon ).removeClass( this.checkedpressedicon );
105 refresh: function() {
106 var input = this.element,