From 178237d58235098982bb1fb957ae871da3c65174 Mon Sep 17 00:00:00 2001 From: "D. Elmo Peele" Date: Wed, 5 Jan 2011 06:42:16 -0500 Subject: [PATCH 1/5] Avoid triggering a 'tap' event if the event target on touchStop differs from the original touchStart target. --- js/jquery.mobile.event.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/js/jquery.mobile.event.js b/js/jquery.mobile.event.js index 8475ac73a03..7dc8eb433ae 100644 --- a/js/jquery.mobile.event.js +++ b/js/jquery.mobile.event.js @@ -70,6 +70,10 @@ $.event.special.tap = { var moved = false, touching = true, + /* :XXX: Needed to avoid triggering a 'tap' when the + * start target differs from the stop target. + */ + origTarget = event.target, origPos = [ event.pageX, event.pageY ], originalType, timer; @@ -97,7 +101,10 @@ $.event.special.tap = { clearTimeout( timer ); touching = false; - if ( !moved ) { + /* :XXX: ONLY trigger a 'tap' event if the start target + * is the same as the stop target. + */ + if ( !moved && (origTarget == event.target)) { originalType = event.type; event.type = "tap"; $.event.handle.call( thisObject, event ); From 1ad72ac7ddf087500f58c9f1cc160d279940db4f Mon Sep 17 00:00:00 2001 From: "D. Elmo Peele" Date: Wed, 5 Jan 2011 06:44:50 -0500 Subject: [PATCH 2/5] When a selectmenu is re-built via refresh, the new options are no longer available to the list items click delegate closure via the cached 'options' variable. Need to do a full find to ensure access to the current set of options. --- js/jquery.mobile.forms.select.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/js/jquery.mobile.forms.select.js b/js/jquery.mobile.forms.select.js index 6ee10c4fe39..713cc5869d6 100644 --- a/js/jquery.mobile.forms.select.js +++ b/js/jquery.mobile.forms.select.js @@ -172,8 +172,12 @@ $.widget( "mobile.selectmenu", $.mobile.widget, { if( !$(event.target).is("a") ){ return; } // index of option tag to be selected + /* :XXX: If we use 'options' from the current closure, then when + * the list is re-built, we won't have access to the new set + * of options. + */ var newIndex = list.find( "li:not(.ui-li-divider)" ).index( this ), - option = options.eq( newIndex )[0]; + option = select.find('option').eq( newIndex )[0]; // toggle selected status on the tag for multi selects option.selected = isMultiple ? !option.selected : true; From e53aae73b67322fe0f3953fb6111f6ee48736ee8 Mon Sep 17 00:00:00 2001 From: "D. Elmo Peele" Date: Wed, 5 Jan 2011 06:53:30 -0500 Subject: [PATCH 3/5] In changePage(), window.document.activeElement MAY be unavailable. If so, the code to "kill the keyboard" should NOT cause changePage() to fail completely. The quick solution is to surround it with a try/catch. --- js/jquery.mobile.navigation.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/js/jquery.mobile.navigation.js b/js/jquery.mobile.navigation.js index 81c711ed081..7ce3e3977d9 100644 --- a/js/jquery.mobile.navigation.js +++ b/js/jquery.mobile.navigation.js @@ -170,8 +170,14 @@ //reset base to pathname for new request if(base){ base.reset(); } - //kill the keyboard - $( window.document.activeElement ).add(':focus').blur(); + /* kill the keyboard + * + * :XXX: This CAN fail, and when it does, the failure shouldn't + * terminate changePage(). + */ + try { + $( window.document.activeElement ).add(':focus').blur(); + } catch(e) {}; function defaultTransition(){ if(transition === undefined){ @@ -495,4 +501,4 @@ } } }); -})( jQuery ); \ No newline at end of file +})( jQuery ); From b66ed36439307c6647fb4708f1325959b3241c9b Mon Sep 17 00:00:00 2001 From: "D. Elmo Peele" Date: Wed, 5 Jan 2011 07:06:57 -0500 Subject: [PATCH 4/5] $.mobile.changePage() should only update the urlStack if a destination URL was identified AND changeHash is not explicitly 'false'. --- js/jquery.mobile.navigation.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/js/jquery.mobile.navigation.js b/js/jquery.mobile.navigation.js index 7ce3e3977d9..97b381b74c5 100644 --- a/js/jquery.mobile.navigation.js +++ b/js/jquery.mobile.navigation.js @@ -196,7 +196,12 @@ // ensure a transition has been set where pop is undefined defaultTransition(); - } else { + /* :XXX: Only push the url/transition onto the urlStack if a + * destination URL was identified AND 'changeHash' is not + * explicitly false. Otherwise, the urlStack could become + * cluttered with empty urls, causing history navigation issues. + */ + } else if( changeHash !== false && url ) { // If no transition has been passed defaultTransition(); From 2502eb10079b2c181071eabd0115e11dcd95fab7 Mon Sep 17 00:00:00 2001 From: "D. Elmo Peele" Date: Tue, 11 Jan 2011 17:16:51 -0500 Subject: [PATCH 5/5] Avoid triggering a 'tap' event if the event target on touchStop differs from the original touchStart target (updated comments to remove :XXX:). --- js/jquery.mobile.event.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/js/jquery.mobile.event.js b/js/jquery.mobile.event.js index 7dc8eb433ae..c1bdc90d050 100644 --- a/js/jquery.mobile.event.js +++ b/js/jquery.mobile.event.js @@ -70,9 +70,6 @@ $.event.special.tap = { var moved = false, touching = true, - /* :XXX: Needed to avoid triggering a 'tap' when the - * start target differs from the stop target. - */ origTarget = event.target, origPos = [ event.pageX, event.pageY ], originalType, @@ -101,8 +98,8 @@ $.event.special.tap = { clearTimeout( timer ); touching = false; - /* :XXX: ONLY trigger a 'tap' event if the start target - * is the same as the stop target. + /* ONLY trigger a 'tap' event if the start target is + * the same as the stop target. */ if ( !moved && (origTarget == event.target)) { originalType = event.type;