|
-
- /* Notifications */
- //Notification.init() ;
-
- /* Tooltip */
- $('[data-toggle="tooltip"]').tooltip();
-
- /* Select2 */
- if ($('.select2, select.form-control').length) {
-
- $('form .form-widget>select.form-control, .select2').each(function (i, elm) {
- if (!$(this).hasClass('disable-select2')) {
- setSelect2($(elm));
- }
- });
-
- $('form select.form-control').each(function (i, elm) {
- if (!$(this).hasClass('disable-select2')) {
- setSelect2($(elm));
- }
- });
- }
-
- function setSelect2($select) {
- if (typeof $select.data('select2-id') === 'undefined') {
-
- $select.data('init', 'set')
- var options = {
- width: "100%",
- theme: "bootstrap4",
- dropdownAutoWidth: false,
- allowClear: true,
- minimumResultsForSearch: 8
- };
-
- if ($select.data('allow-clear') == 'false') {
- options.allowClear = false;
- }
- if ($select.data('width')) {
- options.width = 'auto'
- }
- if ($select.find('option[value=""]')) {
- options.placeholder = $select.find('option[value=""]').html()
- }
- /*if($select.is(':required') == false) {
- options.allowclear = true
- }*/
- var myselect = $select.select2(options);
-
- myselect.on('select2:select', function (e) {
- var event = new Event('change');
- e.target.dispatchEvent(event);
- });
- myselect.on('select2:unselect', function (e) {
- var event = new Event('change');
- e.target.dispatchEvent(event);
- });
-
- return myselect;
- }
- }
-
-
- $('.action-delete').on('click', function (e) {
- e.preventDefault();
- const formAction = $(this).attr('formaction');
-
- $('#modal-delete').modal({backdrop: true, keyboard: true})
- .off('click', '#modal-delete-button')
- .on('click', '#modal-delete-button', function () {
- let deleteForm = $('#delete-form');
- deleteForm.attr('action', formAction);
- deleteForm.submit();
- });
- });
|