From 199d627066cd83a2a9f639328932e4d3c08c9625 Mon Sep 17 00:00:00 2001 From: jlukic Date: Tue, 30 Dec 2014 13:02:05 -0500 Subject: [PATCH] Adds category selection with sub-menus #1522 --- src/definitions/modules/dropdown.js | 49 +++++++++++++++++++---------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/src/definitions/modules/dropdown.js b/src/definitions/modules/dropdown.js index 43ec09ebf..f72c7ae54 100644 --- a/src/definitions/modules/dropdown.js +++ b/src/definitions/modules/dropdown.js @@ -605,16 +605,22 @@ $.fn.dropdown = function(parameters) { click: function (event) { var - $choice = $(this), - text = module.get.choiceText($choice), - value = module.get.choiceValue($choice, text), + $choice = $(this), + $target = $(event.target), + $subMenu = $choice.find(selector.menu), + text = module.get.choiceText($choice), + value = module.get.choiceValue($choice, text), callback = function() { module.remove.searchTerm(); module.determine.selectAction(text, value); }, - openingSubMenu = ($choice.find(selector.menu).size() > 0) + openingSubMenu = ($subMenu.size() > 0), + isSubItem = ($subMenu.find($target).size() > 0) ; - if( !openingSubMenu ) { + if(isSubItem) { + return false; + } + if(!openingSubMenu || settings.allowCategorySelection) { callback(); } } @@ -738,6 +744,12 @@ $.fn.dropdown = function(parameters) { : settings.preserveHTML ; if($choice !== undefined) { + if($choice.find(selector.menu).size() > 0) { + module.verbose('Retreiving text of element with sub-menu'); + $choice = $choice.clone(); + $choice.find(selector.menu).remove(); + $choice.find(selector.menuIcon).remove(); + } return ($choice.data(metadata.text) !== undefined) ? $choice.data(metadata.text) : (preserveHTML) @@ -1484,17 +1496,19 @@ $.fn.dropdown = function(parameters) { $.fn.dropdown.settings = { - debug : false, - verbose : true, - performance : true, + debug : false, + verbose : true, + performance : true, - on : 'click', - action : 'activate', + on : 'click', + action : 'activate', - allowTab : true, - fullTextSearch : false, - preserveHTML : true, - sortSelect : false, + allowTab : true, + fullTextSearch : false, + preserveHTML : true, + sortSelect : false, + + allowCategorySelection : false, delay : { hide : 300, @@ -1532,11 +1546,12 @@ $.fn.dropdown.settings = { selector : { dropdown : '.ui.dropdown', - text : '> .text:not(.icon)', input : '> input[type="hidden"], > select', - search : '> input.search, .menu > .search > input, .menu > input.search', + item : '.item', menu : '.menu', - item : '.item' + menuIcon : '.dropdown.icon', + search : '> input.search, .menu > .search > input, .menu > input.search', + text : '> .text:not(.icon)' }, className : {