demarches-normaliennes/app/javascript/new_design/select2.js
clemkeirua 4373cb22cb Revert "Merge pull request #4552 from tchak/champ-communes"
This reverts commit 4cec26f73a, reversing
changes made to 0ef25ef36c.
2020-01-13 16:26:27 +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>'
);
}
});
});