From 863e14d0b389ba67ca4a4f35c841c7318346fd2b Mon Sep 17 00:00:00 2001 From: jlukic Date: Fri, 21 Nov 2014 18:46:27 -0500 Subject: [PATCH] Add set/remove tabbable behaviors --- src/definitions/modules/dropdown.js | 68 +++++++++++++++++++---------- 1 file changed, 46 insertions(+), 22 deletions(-) diff --git a/src/definitions/modules/dropdown.js b/src/definitions/modules/dropdown.js index 61de64824..319a3723e 100644 --- a/src/definitions/modules/dropdown.js +++ b/src/definitions/modules/dropdown.js @@ -95,6 +95,7 @@ $.fn.dropdown = function(parameters) { destroy: function() { module.verbose('Destroying previous dropdown for', $module); + module.remove.tabbable(); $module .off(eventNamespace) .removeData(moduleNamespace) @@ -128,27 +129,7 @@ $.fn.dropdown = function(parameters) { ; } if(settings.allowTab) { - if( module.is.searchable() ) { - module.debug('Searchable dropdown initialized'); - $search - .val('') - .attr('tabindex', 0) - ; - $menu - .attr('tabindex', '-1') - ; - } - else { - module.debug('Simple selection dropdown initialized'); - if(!$module.attr('tabindex') ) { - $module - .attr('tabindex', 0) - ; - $menu - .attr('tabindex', '-1') - ; - } - } + module.set.tabbable(); } }, select: function() { @@ -407,7 +388,7 @@ $.fn.dropdown = function(parameters) { activated = false; }, focus: function() { - if(!activated) { + if(!activated && module.is.hidden()) { module.show(); } }, @@ -835,6 +816,29 @@ $.fn.dropdown = function(parameters) { }, set: { + tabbable: function() { + if( module.is.searchable() ) { + module.debug('Searchable dropdown initialized'); + $search + .val('') + .attr('tabindex', 0) + ; + $menu + .attr('tabindex', '-1') + ; + } + else { + module.debug('Simple selection dropdown initialized'); + if(!$module.attr('tabindex') ) { + $module + .attr('tabindex', 0) + ; + $menu + .attr('tabindex', '-1') + ; + } + } + }, scrollPosition: function($item) { var $item = $item || module.get.item(), @@ -949,6 +953,26 @@ $.fn.dropdown = function(parameters) { }, selectedItem: function() { $item.removeClass(className.selected); + }, + tabbable: function() { + if( module.is.searchable() ) { + module.debug('Searchable dropdown initialized'); + $search + .attr('tabindex', '-1') + ; + $menu + .attr('tabindex', '-1') + ; + } + else { + module.debug('Simple selection dropdown initialized'); + $module + .attr('tabindex', '-1') + ; + $menu + .attr('tabindex', '-1') + ; + } } },