demarches-normaliennes/app/javascript/new_design/select2.js
2019-11-18 17:08:51 +01:00

46 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import $ from 'jquery';
import 'select2';
const optionTemplate = email =>
$(
'<span class="custom-select2-option"><span class="icon person"></span>' +
email.text +
'</span>'
);
addEventListener('ds:page:update', () => {
$('select.select2').select2({
language: 'fr',
width: '100%'
});
$('.columns-form select.select2-limited').select2({
language: 'fr',
placeholder: 'Sélectionnez des colonnes',
maximumSelectionLength: '5',
width: '300px'
});
$('.recipients-form select.select2-limited').select2({
language: 'fr',
placeholder: 'Sélectionnez des instructeurs',
maximumSelectionLength: '30',
width: '300px'
});
$('select.select2-limited.select-instructeurs').select2({
language: 'fr',
dropdownParent: $('.instructeur-wrapper'),
placeholder: 'Saisir ladresse email de linstructeur',
tags: true,
tokenSeparators: [',', ' '],
templateResult: optionTemplate,
templateSelection: function(email) {
return $(
'<span class="custom-select2-option"><span class="icon person"></span>' +
email.text +
'</span>'
);
}
});
});