Skip to content

Commit

Permalink
feat(dropdown): (vertical) descriptions to menu item template
Browse files Browse the repository at this point in the history
Adds additional options to remoteData to allow a description to be created and also allows to specify if using/wanting a vertical description
  • Loading branch information
jamessampford authored Jan 25, 2021
1 parent 04559bc commit 59eeee2
Showing 1 changed file with 62 additions and 47 deletions.
109 changes: 62 additions & 47 deletions src/definitions/modules/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -4088,19 +4088,22 @@ $.fn.dropdown.settings = {

// property names for remote query
fields: {
remoteValues : 'results', // grouping for api results
values : 'values', // grouping for all dropdown values
disabled : 'disabled', // whether value should be disabled
name : 'name', // displayed dropdown text
value : 'value', // actual dropdown value
text : 'text', // displayed text when selected
type : 'type', // type of dropdown element
image : 'image', // optional image path
imageClass : 'imageClass', // optional individual class for image
icon : 'icon', // optional icon name
iconClass : 'iconClass', // optional individual class for icon (for example to use flag instead)
class : 'class', // optional individual class for item/header
divider : 'divider' // optional divider append for group headers
remoteValues : 'results', // grouping for api results
values : 'values', // grouping for all dropdown values
disabled : 'disabled', // whether value should be disabled
name : 'name', // displayed dropdown text
description : 'description', // displayed dropdown description
descriptionVertical : 'descriptionVertical', // whether description should be vertical
name : 'name', // displayed dropdown text
value : 'value', // actual dropdown value
text : 'text', // displayed text when selected
type : 'type', // type of dropdown element
image : 'image', // optional image path
imageClass : 'imageClass', // optional individual class for image
icon : 'icon', // optional icon name
iconClass : 'iconClass', // optional individual class for icon (for example to use flag instead)
class : 'class', // optional individual class for item/header
divider : 'divider' // optional divider append for group headers
},

keys : {
Expand Down Expand Up @@ -4139,38 +4142,40 @@ $.fn.dropdown.settings = {
},

className : {
active : 'active',
addition : 'addition',
animating : 'animating',
disabled : 'disabled',
empty : 'empty',
dropdown : 'ui dropdown',
filtered : 'filtered',
hidden : 'hidden transition',
icon : 'icon',
image : 'image',
item : 'item',
label : 'ui label',
loading : 'loading',
menu : 'menu',
message : 'message',
multiple : 'multiple',
placeholder : 'default',
sizer : 'sizer',
search : 'search',
selected : 'selected',
selection : 'selection',
text : 'text',
upward : 'upward',
leftward : 'left',
visible : 'visible',
clearable : 'clearable',
noselection : 'noselection',
delete : 'delete',
header : 'header',
divider : 'divider',
groupIcon : '',
unfilterable : 'unfilterable'
active : 'active',
addition : 'addition',
animating : 'animating',
description : 'description',
descriptionVertical : 'vertical',
disabled : 'disabled',
empty : 'empty',
dropdown : 'ui dropdown',
filtered : 'filtered',
hidden : 'hidden transition',
icon : 'icon',
image : 'image',
item : 'item',
label : 'ui label',
loading : 'loading',
menu : 'menu',
message : 'message',
multiple : 'multiple',
placeholder : 'default',
sizer : 'sizer',
search : 'search',
selected : 'selected',
selection : 'selection',
text : 'text',
upward : 'upward',
leftward : 'left',
visible : 'visible',
clearable : 'clearable',
noselection : 'noselection',
delete : 'delete',
header : 'header',
divider : 'divider',
groupIcon : '',
unfilterable : 'unfilterable'
}

};
Expand Down Expand Up @@ -4247,9 +4252,13 @@ $.fn.dropdown.settings.templates = {
: '',
maybeDisabled = (option[fields.disabled])
? className.disabled+' '
: ''
: '',
maybeDescriptionVertical = (option[fields.descriptionVertical])
? className.descriptionVertical+' '
: '',
hasDescription = (escape(option[fields.description] || '', preserveHTML) != '')
;
html += '<div class="'+ maybeDisabled + (option[fields.class] ? deQuote(option[fields.class]) : className.item)+'" data-value="' + deQuote(option[fields.value],true) + '"' + maybeText + '>';
html += '<div class="'+ maybeDisabled + maybeDescriptionVertical + (option[fields.class] ? deQuote(option[fields.class]) : className.item)+'" data-value="' + deQuote(option[fields.value],true) + '"' + maybeText + '>';
if (isMenu) {
html += '<i class="'+ (itemType.indexOf('left') !== -1 ? 'left' : '') + ' dropdown icon"></i>';
}
Expand All @@ -4259,6 +4268,10 @@ $.fn.dropdown.settings.templates = {
if(option[fields.icon]) {
html += '<i class="'+deQuote(option[fields.icon])+' '+(option[fields.iconClass] ? deQuote(option[fields.iconClass]) : className.icon)+'"></i>';
}
if(hasDescription){
html += '<span class="'+ className.description +'">'+ escape(option[fields.description] || '', preserveHTML) + '</span>';
html += (!isMenu) ? '<span class="'+ className.text + '">' : '';
}
if (isMenu) {
html += '<span class="' + className.text + '">';
}
Expand All @@ -4268,6 +4281,8 @@ $.fn.dropdown.settings.templates = {
html += '<div class="' + itemType + '">';
html += $.fn.dropdown.settings.templates.menu(option, fields, preserveHTML, className);
html += '</div>';
} else if(hasDescription){
html += '</span>';
}
html += '</div>';
} else if (itemType === 'header') {
Expand Down

0 comments on commit 59eeee2

Please sign in to comment.