Skip to content

Commit 59eeee2

Browse files
feat(dropdown): (vertical) descriptions to menu item template
Adds additional options to remoteData to allow a description to be created and also allows to specify if using/wanting a vertical description
1 parent 04559bc commit 59eeee2

File tree

1 file changed

+62
-47
lines changed

1 file changed

+62
-47
lines changed

src/definitions/modules/dropdown.js

Lines changed: 62 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4088,19 +4088,22 @@ $.fn.dropdown.settings = {
40884088

40894089
// property names for remote query
40904090
fields: {
4091-
remoteValues : 'results', // grouping for api results
4092-
values : 'values', // grouping for all dropdown values
4093-
disabled : 'disabled', // whether value should be disabled
4094-
name : 'name', // displayed dropdown text
4095-
value : 'value', // actual dropdown value
4096-
text : 'text', // displayed text when selected
4097-
type : 'type', // type of dropdown element
4098-
image : 'image', // optional image path
4099-
imageClass : 'imageClass', // optional individual class for image
4100-
icon : 'icon', // optional icon name
4101-
iconClass : 'iconClass', // optional individual class for icon (for example to use flag instead)
4102-
class : 'class', // optional individual class for item/header
4103-
divider : 'divider' // optional divider append for group headers
4091+
remoteValues : 'results', // grouping for api results
4092+
values : 'values', // grouping for all dropdown values
4093+
disabled : 'disabled', // whether value should be disabled
4094+
name : 'name', // displayed dropdown text
4095+
description : 'description', // displayed dropdown description
4096+
descriptionVertical : 'descriptionVertical', // whether description should be vertical
4097+
name : 'name', // displayed dropdown text
4098+
value : 'value', // actual dropdown value
4099+
text : 'text', // displayed text when selected
4100+
type : 'type', // type of dropdown element
4101+
image : 'image', // optional image path
4102+
imageClass : 'imageClass', // optional individual class for image
4103+
icon : 'icon', // optional icon name
4104+
iconClass : 'iconClass', // optional individual class for icon (for example to use flag instead)
4105+
class : 'class', // optional individual class for item/header
4106+
divider : 'divider' // optional divider append for group headers
41044107
},
41054108

41064109
keys : {
@@ -4139,38 +4142,40 @@ $.fn.dropdown.settings = {
41394142
},
41404143

41414144
className : {
4142-
active : 'active',
4143-
addition : 'addition',
4144-
animating : 'animating',
4145-
disabled : 'disabled',
4146-
empty : 'empty',
4147-
dropdown : 'ui dropdown',
4148-
filtered : 'filtered',
4149-
hidden : 'hidden transition',
4150-
icon : 'icon',
4151-
image : 'image',
4152-
item : 'item',
4153-
label : 'ui label',
4154-
loading : 'loading',
4155-
menu : 'menu',
4156-
message : 'message',
4157-
multiple : 'multiple',
4158-
placeholder : 'default',
4159-
sizer : 'sizer',
4160-
search : 'search',
4161-
selected : 'selected',
4162-
selection : 'selection',
4163-
text : 'text',
4164-
upward : 'upward',
4165-
leftward : 'left',
4166-
visible : 'visible',
4167-
clearable : 'clearable',
4168-
noselection : 'noselection',
4169-
delete : 'delete',
4170-
header : 'header',
4171-
divider : 'divider',
4172-
groupIcon : '',
4173-
unfilterable : 'unfilterable'
4145+
active : 'active',
4146+
addition : 'addition',
4147+
animating : 'animating',
4148+
description : 'description',
4149+
descriptionVertical : 'vertical',
4150+
disabled : 'disabled',
4151+
empty : 'empty',
4152+
dropdown : 'ui dropdown',
4153+
filtered : 'filtered',
4154+
hidden : 'hidden transition',
4155+
icon : 'icon',
4156+
image : 'image',
4157+
item : 'item',
4158+
label : 'ui label',
4159+
loading : 'loading',
4160+
menu : 'menu',
4161+
message : 'message',
4162+
multiple : 'multiple',
4163+
placeholder : 'default',
4164+
sizer : 'sizer',
4165+
search : 'search',
4166+
selected : 'selected',
4167+
selection : 'selection',
4168+
text : 'text',
4169+
upward : 'upward',
4170+
leftward : 'left',
4171+
visible : 'visible',
4172+
clearable : 'clearable',
4173+
noselection : 'noselection',
4174+
delete : 'delete',
4175+
header : 'header',
4176+
divider : 'divider',
4177+
groupIcon : '',
4178+
unfilterable : 'unfilterable'
41744179
}
41754180

41764181
};
@@ -4247,9 +4252,13 @@ $.fn.dropdown.settings.templates = {
42474252
: '',
42484253
maybeDisabled = (option[fields.disabled])
42494254
? className.disabled+' '
4250-
: ''
4255+
: '',
4256+
maybeDescriptionVertical = (option[fields.descriptionVertical])
4257+
? className.descriptionVertical+' '
4258+
: '',
4259+
hasDescription = (escape(option[fields.description] || '', preserveHTML) != '')
42514260
;
4252-
html += '<div class="'+ maybeDisabled + (option[fields.class] ? deQuote(option[fields.class]) : className.item)+'" data-value="' + deQuote(option[fields.value],true) + '"' + maybeText + '>';
4261+
html += '<div class="'+ maybeDisabled + maybeDescriptionVertical + (option[fields.class] ? deQuote(option[fields.class]) : className.item)+'" data-value="' + deQuote(option[fields.value],true) + '"' + maybeText + '>';
42534262
if (isMenu) {
42544263
html += '<i class="'+ (itemType.indexOf('left') !== -1 ? 'left' : '') + ' dropdown icon"></i>';
42554264
}
@@ -4259,6 +4268,10 @@ $.fn.dropdown.settings.templates = {
42594268
if(option[fields.icon]) {
42604269
html += '<i class="'+deQuote(option[fields.icon])+' '+(option[fields.iconClass] ? deQuote(option[fields.iconClass]) : className.icon)+'"></i>';
42614270
}
4271+
if(hasDescription){
4272+
html += '<span class="'+ className.description +'">'+ escape(option[fields.description] || '', preserveHTML) + '</span>';
4273+
html += (!isMenu) ? '<span class="'+ className.text + '">' : '';
4274+
}
42624275
if (isMenu) {
42634276
html += '<span class="' + className.text + '">';
42644277
}
@@ -4268,6 +4281,8 @@ $.fn.dropdown.settings.templates = {
42684281
html += '<div class="' + itemType + '">';
42694282
html += $.fn.dropdown.settings.templates.menu(option, fields, preserveHTML, className);
42704283
html += '</div>';
4284+
} else if(hasDescription){
4285+
html += '</span>';
42714286
}
42724287
html += '</div>';
42734288
} else if (itemType === 'header') {

0 commit comments

Comments
 (0)