From ab1cf3520a9330a2c49832ba7bf5f942ce02cde3 Mon Sep 17 00:00:00 2001 From: jlukic Date: Mon, 6 Jan 2014 18:39:38 -0500 Subject: [PATCH] Dropdown: Fixes #498, dropdown item links not clickable from touch events. Fixes issue with touchmove event not being cremoved after menu hide --- src/modules/dropdown.js | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/modules/dropdown.js b/src/modules/dropdown.js index a8b242204..92ab688ca 100755 --- a/src/modules/dropdown.js +++ b/src/modules/dropdown.js @@ -67,7 +67,6 @@ $.fn.dropdown = function(parameters) { if(hasTouch) { module.bind.touchEvents(); } - // no use detecting mouse events because touch devices emulate them module.bind.mouseEvents(); module.instantiate(); }, @@ -146,6 +145,7 @@ $.fn.dropdown = function(parameters) { if(hasTouch) { $document .off('touchstart' + eventNamespace) + .off('touchmove' + eventNamespace) ; } $document @@ -216,11 +216,19 @@ $.fn.dropdown = function(parameters) { : $choice.text(), value = ( $choice.data(metadata.value) !== undefined) ? $choice.data(metadata.value) - : text.toLowerCase() + : text.toLowerCase(), + callback = function() { + module.determine.selectAction(text, value); + $.proxy(settings.onChange, element)(value, text); + } ; if( $choice.find(selector.menu).size() === 0 ) { - module.determine.selectAction(text, value); - $.proxy(settings.onChange, element)(value, text); + if(event.type == 'touchstart') { + $choice.one('click', callback); + } + else { + callback(); + } } } @@ -546,12 +554,14 @@ $.fn.dropdown = function(parameters) { if(module.is.visible($currentMenu) ) { module.verbose('Doing menu hide animation', $currentMenu); if($.fn.transition !== undefined && $module.transition('is supported')) { - $currentMenu.transition({ - animation : settings.transition + ' out', - duration : settings.duration, - complete : callback, - queue : false - }); + $currentMenu + .transition({ + animation : settings.transition + ' out', + duration : settings.duration, + complete : callback, + queue : false + }) + ; } else if(settings.transition == 'none') { callback();