Browse Source

Adds category selection with sub-menus #1522

pull/1550/head
jlukic 10 years ago
parent
commit
199d627066
1 changed files with 32 additions and 17 deletions
  1. 49
      src/definitions/modules/dropdown.js

49
src/definitions/modules/dropdown.js

@ -605,16 +605,22 @@ $.fn.dropdown = function(parameters) {
click: function (event) { click: function (event) {
var 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() { callback = function() {
module.remove.searchTerm(); module.remove.searchTerm();
module.determine.selectAction(text, value); 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(); callback();
} }
} }
@ -738,6 +744,12 @@ $.fn.dropdown = function(parameters) {
: settings.preserveHTML : settings.preserveHTML
; ;
if($choice !== undefined) { 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) return ($choice.data(metadata.text) !== undefined)
? $choice.data(metadata.text) ? $choice.data(metadata.text)
: (preserveHTML) : (preserveHTML)
@ -1484,17 +1496,19 @@ $.fn.dropdown = function(parameters) {
$.fn.dropdown.settings = { $.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 : { delay : {
hide : 300, hide : 300,
@ -1532,11 +1546,12 @@ $.fn.dropdown.settings = {
selector : { selector : {
dropdown : '.ui.dropdown', dropdown : '.ui.dropdown',
text : '> .text:not(.icon)',
input : '> input[type="hidden"], > select', input : '> input[type="hidden"], > select',
search : '> input.search, .menu > .search > input, .menu > input.search',
item : '.item',
menu : '.menu', menu : '.menu',
item : '.item'
menuIcon : '.dropdown.icon',
search : '> input.search, .menu > .search > input, .menu > input.search',
text : '> .text:not(.icon)'
}, },
className : { className : {

Loading…
Cancel
Save