Skip to content

Commit

Permalink
feat(dropdown): support submenu values
Browse files Browse the repository at this point in the history
When a dropdown was initialized by providing its values via settings parameter, it was not possible to define a submenu structure, which will also simplify such tasks when working with remote data.
This was only possible by using existing DOM structure before.

This PR now allows for a value type menu, left menu, right menu.
  • Loading branch information
lubber-de authored Jan 1, 2021
1 parent ef3d810 commit cfc5a74
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/definitions/modules/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -4157,6 +4157,7 @@ $.fn.dropdown.settings = {
search : 'search',
selected : 'selected',
selection : 'selection',
text : 'text',
upward : 'upward',
leftward : 'left',
visible : 'visible',
Expand Down Expand Up @@ -4232,10 +4233,11 @@ $.fn.dropdown.settings.templates = {
var
itemType = (option[fields.type])
? option[fields.type]
: 'item'
: 'item',
isMenu = itemType.indexOf('menu') !== -1
;

if( itemType === 'item' ) {
if( itemType === 'item' || isMenu) {
var
maybeText = (option[fields.text])
? ' data-text="' + deQuote(option[fields.text],true) + '"'
Expand All @@ -4245,13 +4247,25 @@ $.fn.dropdown.settings.templates = {
: ''
;
html += '<div class="'+ maybeDisabled + (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>';
}
if(option[fields.image]) {
html += '<img class="'+(option[fields.imageClass] ? deQuote(option[fields.imageClass]) : className.image)+'" src="' + deQuote(option[fields.image]) + '">';
}
if(option[fields.icon]) {
html += '<i class="'+deQuote(option[fields.icon])+' '+(option[fields.iconClass] ? deQuote(option[fields.iconClass]) : className.icon)+'"></i>';
}
if (isMenu) {
html += '<span class="' + className.text + '">';
}
html += escape(option[fields.name] || '', preserveHTML);
if (isMenu) {
html += '</span>';
html += '<div class="' + itemType + '">';
html += $.fn.dropdown.settings.templates.menu(option, fields, preserveHTML, className);
html += '</div>';
}
html += '</div>';
} else if (itemType === 'header') {
var groupName = escape(option[fields.name] || '', preserveHTML),
Expand Down

0 comments on commit cfc5a74

Please sign in to comment.