Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions assets/js/shared-ui/select2.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,27 @@

};

SUI.select.formatSearchOptions = ( data, container ) => {

let markup;

const label = SUI.select.escapeJS( data.text );
const url = $( data.element ).attr( 'data-url' );

if ( ! data.id ) {
return label; // optgroup.
}

if ( 'undefined' !== typeof url ) {
markup = '<span class="sui-search-name">' + label + '</span><span class="sui-search-url">' + url + '</span> ';
} else {
markup = label;
}

return markup;

};

SUI.select.formatVarsSelection = ( data, container ) => {

let markup;
Expand Down Expand Up @@ -235,6 +256,10 @@
dropdownParent: selectParent,
minimumInputLength: 2,
maximumSelectionLength: 1,
templateResult: SUI.select.formatSearchOptions,
escapeMarkup: function( markup ) {
return markup;
},
dropdownCssClass: isSmall
});
};
Expand Down