Tizen 2.1 base
[platform/framework/web/web-ui-fw.git] / libs / patch / 0007-JQM-checkbox-pressed-no-lable-support.patch
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
5
6 ---
7  .../js/jquery.mobile.forms.checkboxradio.js        |   60 ++++++++++++++++++--
8  1 files changed, 55 insertions(+), 5 deletions(-)
9
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";
22  
23                 if ( inputtype !== "checkbox" && inputtype !== "radio" ) {
24                         return;
25                 }
26 +               // Support fake label
27 +               if ( label.length == 0 ) {
28 +                       //fake label
29 +                       label = $( "<label for='" + input[ 0 ].id  + "' style='display:block;width:1px;height:1px;'></label>" );
30 +               }
31 +
32 +               // Wrap the input + label in a div
33 +               input.add( label )
34 +                       .wrapAll( "<div class='ui-" + inputtype + "'></div>" );
35  
36                 // Expose for other methods
37                 $.extend( this, {
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
46                 });
47  
48                 // If there's no selected theme...
49 @@ -50,11 +63,20 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, {
50                         shadow: false
51                 });
52  
53 -               // Wrap the input + label in a div
54 -               input.add( label )
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();
59 +               }
60  
61                 label.bind({
62 +                       vmousedown: function() {
63 +                               self.press();
64 +                       },
65 +                       vmouseup: function() {
66 +                               self.unpress();
67 +                       },
68 +
69 +
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" );
75         },
76  
77 +       press: function() {
78 +               var input = this.element,
79 +                       label = this.label,
80 +                       icon = label.find( ".ui-icon" );
81 +
82 +               if ( !$( input[ 0 ] ).is( ":disabled" ) ) {
83 +                       if ( $( input[ 0 ] ).prop( "checked" ) ) {
84 +                               icon.addClass( this.uncheckedpressedicon ).removeClass( this.checkedicon );
85 +                       } else {
86 +                               icon.removeClass( this.uncheckedicon ).addClass( this.checkedpressedicon );
87 +                       }
88 +               }
89 +       },
90 +
91 +       unpress: function() {
92 +               var input = this.element,
93 +                       label = this.label,
94 +                       icon = label.find( ".ui-icon" );
95 +
96 +               if ( !$( input[ 0 ] ).is( ":disabled" ) ) {
97 +                       if ( $( input[ 0 ] ).prop( "checked" ) ) {
98 +                               icon.removeClass( this.uncheckedpressedicon ).addClass( this.uncheckedicon );
99 +                       } else {
100 +                               icon.addClass( this.checkedicon ).removeClass( this.checkedpressedicon );
101 +                       }
102 +               }
103 +       },
104 +
105         refresh: function() {
106                 var input = this.element,
107                         label = this.label,
108 -- 
109 1.7.0.4
110