From 4dc2560895fa002766415bd707abfe6efcb2ec5d Mon Sep 17 00:00:00 2001 From: Martin Kou Date: Wed, 6 Apr 2011 09:04:47 +0800 Subject: [PATCH 01/11] Fixed yet another duplicate tap event bug. --- js/jquery.mobile.event.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/jquery.mobile.event.js b/js/jquery.mobile.event.js index 74fc73b0..592bc35d 100644 --- a/js/jquery.mobile.event.js +++ b/js/jquery.mobile.event.js @@ -81,7 +81,7 @@ $.event.special.tap = { function clearTapHandlers() { touching = false; clearTimeout(timer); - $(this).unbind("vclick", clickHandler).unbind("vmousecancel", clearTapHandlers); + $this.unbind("vclick", clickHandler).unbind("vmousecancel", clearTapHandlers); } function clickHandler(event) { From ceed56fb2a6b279964126de9fa221769da60676b Mon Sep 17 00:00:00 2001 From: John Bender Date: Wed, 6 Apr 2011 13:30:55 -0700 Subject: [PATCH 02/11] test added for checkbox check and uncheck firing change --- .../unit/checkboxradio/checkboxradio_core.js | 22 +++++++++++++++ tests/unit/checkboxradio/index.html | 28 ++++++++++++------- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/tests/unit/checkboxradio/checkboxradio_core.js b/tests/unit/checkboxradio/checkboxradio_core.js index 56e5f110..9ddc7818 100644 --- a/tests/unit/checkboxradio/checkboxradio_core.js +++ b/tests/unit/checkboxradio/checkboxradio_core.js @@ -26,4 +26,26 @@ ok(!input.attr("checked"), "not checked after click"); ok(!button.hasClass("ui-btn-active"), "no active styles after click"); }); + + asyncTest( "change events fired on checkbox for both check and uncheck", function(){ + var $checkbox = $("#checkbox-2"), + $checkboxLabel = $("[for=checkbox-2]"); + + $checkbox.unbind("change"); + + expect( 2 ); + + $checkbox.change(function(){ + ok(true, "change fired on click to check the box"); + }); + + $checkboxLabel.trigger("click"); + + //test above will be triggered twice as will the start here + $checkbox.change(function(){ + start(); + }); + + $checkboxLabel.trigger("click"); + }); })(jQuery); diff --git a/tests/unit/checkboxradio/index.html b/tests/unit/checkboxradio/index.html index 74d31a21..6f324ba0 100644 --- a/tests/unit/checkboxradio/index.html +++ b/tests/unit/checkboxradio/index.html @@ -23,17 +23,25 @@
-
-
-
-
-
- Agree to the terms: - - -
-
+
+
+
+
+ Agree to the terms: + + +
+
+ +
+
+ Agree to the terms: + + +
+
+ From 5158c6f7cbe582b94b7982501a6f1b3f68a466b6 Mon Sep 17 00:00:00 2001 From: John Bender Date: Wed, 6 Apr 2011 13:33:32 -0700 Subject: [PATCH 03/11] comment correction in test --- tests/unit/checkboxradio/checkboxradio_core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/checkboxradio/checkboxradio_core.js b/tests/unit/checkboxradio/checkboxradio_core.js index 9ddc7818..235fe9d9 100644 --- a/tests/unit/checkboxradio/checkboxradio_core.js +++ b/tests/unit/checkboxradio/checkboxradio_core.js @@ -41,7 +41,7 @@ $checkboxLabel.trigger("click"); - //test above will be triggered twice as will the start here + //test above will be triggered twice, and the start here once $checkbox.change(function(){ start(); }); From 9a1b2dcb3ce40a2b4e4e1241c6e18c73add7bf00 Mon Sep 17 00:00:00 2001 From: scottjehl Date: Thu, 7 Apr 2011 11:33:04 -0400 Subject: [PATCH 04/11] changed name of interal function loadComplete to pageChangeComplete --- js/jquery.mobile.navigation.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/jquery.mobile.navigation.js b/js/jquery.mobile.navigation.js index eaa81405..dda49493 100644 --- a/js/jquery.mobile.navigation.js +++ b/js/jquery.mobile.navigation.js @@ -402,7 +402,7 @@ } to.data( "page" )._trigger( "beforeshow", null, { prevPage: from || $("") } ); - function loadComplete(){ + function pageChangeComplete(){ if( changeHash !== false && url ){ //disable hash listening temporarily @@ -486,7 +486,7 @@ if( from ){ from.removeClass( $.mobile.activePageClass ); } - loadComplete(); + pageChangeComplete(); removeContainerClasses(); }); } @@ -496,7 +496,7 @@ from.removeClass( $.mobile.activePageClass ); } to.addClass( $.mobile.activePageClass ); - loadComplete(); + pageChangeComplete(); } } From 982b7d4b15f241561ecfbb2eb481573e4208e926 Mon Sep 17 00:00:00 2001 From: scottjehl Date: Thu, 7 Apr 2011 14:41:45 -0400 Subject: [PATCH 05/11] Make navigation feel more responsive through feedback, even though it actually uses the click event again for actual page changes. - set active state on all button vclick events - cancelled vclick on slider switch handles so it's not too sticky. - removed addClass in navigation.js as the first change handles it there. --- js/jquery.mobile.buttonMarkup.js | 3 +++ js/jquery.mobile.forms.slider.js | 3 ++- js/jquery.mobile.navigation.js | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/js/jquery.mobile.buttonMarkup.js b/js/jquery.mobile.buttonMarkup.js index 4bf4e369..408360d8 100644 --- a/js/jquery.mobile.buttonMarkup.js +++ b/js/jquery.mobile.buttonMarkup.js @@ -98,6 +98,9 @@ var attachEvents = function() { "vmouseout blur": function() { var theme = $(this).attr( "data-" + $.mobile.ns + "theme" ); $(this).removeClass( "ui-btn-hover-" + theme ).addClass( "ui-btn-up-" + theme ); + }, + "vclick": function() { + $(this).addClass( $.mobile.activeBtnClass ); } }); diff --git a/js/jquery.mobile.forms.slider.js b/js/jquery.mobile.forms.slider.js index 39f38af5..689a0ba9 100644 --- a/js/jquery.mobile.forms.slider.js +++ b/js/jquery.mobile.forms.slider.js @@ -132,7 +132,8 @@ $.widget( "mobile.slider", $.mobile.widget, { this.handle .bind( "vmousedown", function(){ $(this).focus(); - }); + }) + .bind( "vclick", false ); this.handle .bind( "keydown", function( event ) { diff --git a/js/jquery.mobile.navigation.js b/js/jquery.mobile.navigation.js index dda49493..02faf2f6 100644 --- a/js/jquery.mobile.navigation.js +++ b/js/jquery.mobile.navigation.js @@ -747,7 +747,7 @@ return; } - $activeClickedLink = $this.closest( ".ui-btn" ).addClass( $.mobile.activeBtnClass ); + $activeClickedLink = $this.closest( ".ui-btn" ); if( isExternal || hasAjaxDisabled || hasTarget || !$.mobile.ajaxEnabled || // TODO: deprecated - remove at 1.0 From 784f5974e5a62f3dcc7e468770d617219a275a52 Mon Sep 17 00:00:00 2001 From: scottjehl Date: Thu, 7 Apr 2011 15:03:29 -0400 Subject: [PATCH 06/11] make sure collapsibles don't have a sticky on-state. --- js/jquery.mobile.collapsible.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/js/jquery.mobile.collapsible.js b/js/jquery.mobile.collapsible.js index 9bc70c35..cc60e79b 100644 --- a/js/jquery.mobile.collapsible.js +++ b/js/jquery.mobile.collapsible.js @@ -133,15 +133,16 @@ $.widget( "mobile.collapsible", $.mobile.widget, { } collapsibleHeading - .bind("vclick", function(e){ - if( collapsibleHeading.is('.ui-collapsible-heading-collapsed') ){ - collapsibleContain.trigger('expand'); - } - else { - collapsibleContain.trigger('collapse'); - } - e.preventDefault(); - }); + .bind("vmouseup", function(e){ + if( collapsibleHeading.is('.ui-collapsible-heading-collapsed') ){ + collapsibleContain.trigger('expand'); + } + else { + collapsibleContain.trigger('collapse'); + } + e.preventDefault(); + }) + .bind("vclick",false ); } }); })( jQuery ); \ No newline at end of file From cd0ad522ba7e129449583de5fc89e471ad6c8cd4 Mon Sep 17 00:00:00 2001 From: scottjehl Date: Thu, 7 Apr 2011 15:28:52 -0400 Subject: [PATCH 07/11] moved the active state vclick to navigation --- js/jquery.mobile.buttonMarkup.js | 3 --- js/jquery.mobile.navigation.js | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/js/jquery.mobile.buttonMarkup.js b/js/jquery.mobile.buttonMarkup.js index 408360d8..4bf4e369 100644 --- a/js/jquery.mobile.buttonMarkup.js +++ b/js/jquery.mobile.buttonMarkup.js @@ -98,9 +98,6 @@ var attachEvents = function() { "vmouseout blur": function() { var theme = $(this).attr( "data-" + $.mobile.ns + "theme" ); $(this).removeClass( "ui-btn-hover-" + theme ).addClass( "ui-btn-up-" + theme ); - }, - "vclick": function() { - $(this).addClass( $.mobile.activeBtnClass ); } }); diff --git a/js/jquery.mobile.navigation.js b/js/jquery.mobile.navigation.js index 02faf2f6..3f8b152d 100644 --- a/js/jquery.mobile.navigation.js +++ b/js/jquery.mobile.navigation.js @@ -685,6 +685,11 @@ ); event.preventDefault(); }); + + //add active state on vclick + $( "a" ).live( "vclick", function(){ + $(this).closest( ".ui-btn" ).addClass( $.mobile.activeBtnClass ); + }); //click routing - direct to HTTP or Ajax, accordingly From b4088b942224dee9925502a37ab6d88b82a19084 Mon Sep 17 00:00:00 2001 From: scottjehl Date: Thu, 7 Apr 2011 15:34:17 -0400 Subject: [PATCH 08/11] don't add the class to a disabled button. Fixes the checkbox test --- js/jquery.mobile.navigation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/jquery.mobile.navigation.js b/js/jquery.mobile.navigation.js index 3f8b152d..29e2e1b2 100644 --- a/js/jquery.mobile.navigation.js +++ b/js/jquery.mobile.navigation.js @@ -688,7 +688,7 @@ //add active state on vclick $( "a" ).live( "vclick", function(){ - $(this).closest( ".ui-btn" ).addClass( $.mobile.activeBtnClass ); + $(this).closest( ".ui-btn" ).not( ".ui-disabled" ).addClass( $.mobile.activeBtnClass ); }); From 97f5a9565f31df7d15181bf27a328f86160e0ed9 Mon Sep 17 00:00:00 2001 From: scottjehl Date: Thu, 7 Apr 2011 16:27:32 -0400 Subject: [PATCH 09/11] To ensure focus and scrollTo don't conflict (when possible), I set the focus order on page show to 1) previously clicked item if revisiting that page 2) page title 3) first focusable item in the page. Fixes #1342 --- js/jquery.mobile.navigation.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/js/jquery.mobile.navigation.js b/js/jquery.mobile.navigation.js index 29e2e1b2..fb756f41 100644 --- a/js/jquery.mobile.navigation.js +++ b/js/jquery.mobile.navigation.js @@ -237,8 +237,13 @@ //direct focus to the page title, or otherwise first focusable element function reFocus( page ){ - var pageTitle = page.find( ".ui-title:eq(0)" ); - if( pageTitle.length ){ + var pageTitle = page.find( ".ui-title:eq(0)" ), + lastClicked = page.jqmData( "lastClicked" ); + + if( lastClicked && lastClicked.length ){ + lastClicked.focus(); + } + else if( pageTitle.length ){ pageTitle.focus(); } else{ @@ -396,7 +401,9 @@ if( from ){ //set as data for returning to that spot - from.jqmData( "lastScroll", currScroll); + from + .jqmData( "lastScroll", currScroll) + .jqmData( "lastClicked", $activeClickedLink); //trigger before show/hide events from.data( "page" )._trigger( "beforehide", null, { nextPage: to } ); } From 3da5f05f7516dc5fe72de1b8fec76c6a54031b99 Mon Sep 17 00:00:00 2001 From: scottjehl Date: Thu, 7 Apr 2011 16:50:10 -0400 Subject: [PATCH 10/11] wrapped the else if/else in an else to prevent an unnecessary dom walk until we have to make it. --- js/jquery.mobile.navigation.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/js/jquery.mobile.navigation.js b/js/jquery.mobile.navigation.js index fb756f41..2cf58ff8 100644 --- a/js/jquery.mobile.navigation.js +++ b/js/jquery.mobile.navigation.js @@ -237,17 +237,20 @@ //direct focus to the page title, or otherwise first focusable element function reFocus( page ){ - var pageTitle = page.find( ".ui-title:eq(0)" ), - lastClicked = page.jqmData( "lastClicked" ); + var lastClicked = page.jqmData( "lastClicked" ); if( lastClicked && lastClicked.length ){ lastClicked.focus(); } - else if( pageTitle.length ){ - pageTitle.focus(); - } - else{ - page.find( focusable ).eq(0).focus(); + else { + var pageTitle = page.find( ".ui-title:eq(0)" ); + + if( pageTitle.length ){ + pageTitle.focus(); + } + else{ + page.find( focusable ).eq(0).focus(); + } } } From 5c1953f5cdf93fda0dca87342088c8933f57a918 Mon Sep 17 00:00:00 2001 From: scottjehl Date: Thu, 7 Apr 2011 16:55:05 -0400 Subject: [PATCH 11/11] set version to 1.0a4.1 --- docs/pages/docs-pages.html | 8 ++++---- version.txt | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/pages/docs-pages.html b/docs/pages/docs-pages.html index e23b5191..c05807fe 100755 --- a/docs/pages/docs-pages.html +++ b/docs/pages/docs-pages.html @@ -33,9 +33,9 @@ <html> <head> <title>Page Title</title> - <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a4/jquery.mobile-1.0a4.min.css" /> + <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.css" /> <script type="text/javascript" src="http://code.jquery.com/jquery-1.5.2.min.js"></script> - <script type="text/javascript" src="http://code.jquery.com/mobile/1.0a4/jquery.mobile-1.0a4.min.js"></script> + <script type="text/javascript" src="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.js"></script> </head> <body> @@ -75,9 +75,9 @@ <html> <head> <title>Page Title</title> - <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a4/jquery.mobile-1.0a4.min.css" /> + <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.css" /> <script type="text/javascript" src="http://code.jquery.com/jquery-1.5.2.min.js"></script> - <script type="text/javascript" src="http://code.jquery.com/mobile/1.0a4/jquery.mobile-1.0a4.min.js"></script> + <script type="text/javascript" src="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.js"></script> </head> <body> diff --git a/version.txt b/version.txt index a17355a9..26e1dae0 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.0beta-pre \ No newline at end of file +1.0a4.1 \ No newline at end of file