1 From 6734ec723c053c9c81949c146a5f3ea5a0fbfdc5 Mon Sep 17 00:00:00 2001
2 From: Minkyu Kang <mk7.kang@samsung.com>
3 Date: Tue, 28 Feb 2012 14:19:23 +0900
4 Subject: [PATCH] JQM: button event bug fixed
6 Signed-off-by: Koeun Choi <koeun.choi@samsung.com>
7 Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
9 .../js/jquery.mobile.buttonMarkup.js | 74 +++++++++++++-------
10 1 files changed, 49 insertions(+), 25 deletions(-)
12 diff --git a/libs/js/jquery-mobile-1.0.1pre/js/jquery.mobile.buttonMarkup.js b/libs/js/jquery-mobile-1.0.1pre/js/jquery.mobile.buttonMarkup.js
13 index a08e611..d192e37 100644
14 --- a/libs/js/jquery-mobile-1.0.1pre/js/jquery.mobile.buttonMarkup.js
15 +++ b/libs/js/jquery-mobile-1.0.1pre/js/jquery.mobile.buttonMarkup.js
16 @@ -130,47 +130,71 @@ function closestEnabledButton( element ) {
20 +// Bug fix: When moving finger out of button after touching down button, button color MUST be returned.
21 +// button click event comes this order : vmouseover -> vmousedown -> vmouseup -> vmouseout
23 +var selectedButton = null;
24 +var useScrollview = false;
26 var attachEvents = function() {
28 - "vmousedown": function( event ) {
29 - var btn = closestEnabledButton( event.target ),
31 + "vmouseover focus": function( event ) {
36 + // check if there is selected button... if so, make it to "btn-up" state.
37 + if ( selectedButton ) {
38 + $btn = $( selectedButton );
39 theme = $btn.attr( "data-" + $.mobile.ns + "theme" );
40 - $btn.removeClass( "ui-btn-up-" + theme ).addClass( "ui-btn-down-" + theme );
41 + $btn.removeClass( "ui-btn-down-" + theme ).removeClass( "ui-btn-hover-" + theme )
42 + .addClass( "ui-btn-up-" + theme );
45 - "vmousecancel vmouseup": function( event ) {
46 - var btn = closestEnabledButton( event.target ),
51 + selectedButton = closestEnabledButton( event.target );
52 + if ( selectedButton ) {
53 + $btn = $( selectedButton );
54 theme = $btn.attr( "data-" + $.mobile.ns + "theme" );
55 - $btn.removeClass( "ui-btn-down-" + theme ).addClass( "ui-btn-up-" + theme );
56 + $btn.removeClass( "ui-btn-up-" + theme ).addClass( "ui-btn-hover-" + theme );
59 - "vmouseover focus": function( event ) {
60 - var btn = closestEnabledButton( event.target ),
62 + "vmouseout blur": function( event ) {
67 + if ( selectedButton ) {
68 + $btn = $( selectedButton );
69 theme = $btn.attr( "data-" + $.mobile.ns + "theme" );
70 - $btn.removeClass( "ui-btn-up-" + theme ).addClass( "ui-btn-hover-" + theme );
71 + $btn.removeClass( "ui-btn-hover-" + theme ).removeClass( "ui-btn-down-" + theme ).addClass( "ui-btn-up-" + theme );
74 - "vmouseout blur": function( event ) {
75 - var btn = closestEnabledButton( event.target ),
77 + "vmousedown": function( event ) {
80 + if ( !selectedButton ) {
81 + selectedButton = closestEnabledButton( event.target );
86 + $btn = $( selectedButton );
87 + theme = $btn.attr( "data-" + $.mobile.ns + "theme" );
88 + $btn.removeClass( "ui-btn-up-" + theme ).addClass( "ui-btn-down-" + theme );
90 + "vmousecancel vmouseup": function( event ) {
93 + if ( selectedButton ) {
94 + $btn = $( selectedButton );
95 theme = $btn.attr( "data-" + $.mobile.ns + "theme" );
96 - $btn.removeClass( "ui-btn-hover-" + theme + " ui-btn-down-" + theme ).addClass( "ui-btn-up-" + theme );
97 + $btn.removeClass( "ui-btn-down-" + theme ).addClass( "ui-btn-up-" + theme );
99 + if ( event.type === "vmousecancel" && useScrollview ) {
100 + event.preventDefault();
102 + selectedButton = null;
105 + "scrollstart scrollview_scroll": function( event ) {
106 + if ( event.type === "scrollview_scroll" ) {
107 + useScrollview = true;
109 + $( this ).trigger("vmousecancel");