You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 satır
2.0KB

  1. /* Notifications */
  2. //Notification.init() ;
  3. /* Tooltip */
  4. $('[data-toggle="tooltip"]').tooltip();
  5. /* Select2 */
  6. if ($('.select2, select.form-control').length) {
  7. $('form .form-widget>select.form-control, .select2').each(function (i, elm) {
  8. if (!$(this).hasClass('disable-select2')) {
  9. setSelect2($(elm));
  10. }
  11. });
  12. $('form select.form-control').each(function (i, elm) {
  13. if (!$(this).hasClass('disable-select2')) {
  14. setSelect2($(elm));
  15. }
  16. });
  17. }
  18. function setSelect2($select) {
  19. if (typeof $select.data('select2-id') === 'undefined') {
  20. $select.data('init', 'set')
  21. var options = {
  22. width: "100%",
  23. theme: "bootstrap4",
  24. dropdownAutoWidth: false,
  25. allowClear: true,
  26. minimumResultsForSearch: 8
  27. };
  28. if ($select.data('allow-clear') == 'false') {
  29. options.allowClear = false;
  30. }
  31. if ($select.data('width')) {
  32. options.width = 'auto'
  33. }
  34. if ($select.find('option[value=""]')) {
  35. options.placeholder = $select.find('option[value=""]').html()
  36. }
  37. /*if($select.is(':required') == false) {
  38. options.allowclear = true
  39. }*/
  40. var myselect = $select.select2(options);
  41. myselect.on('select2:select', function (e) {
  42. var event = new Event('change');
  43. e.target.dispatchEvent(event);
  44. });
  45. myselect.on('select2:unselect', function (e) {
  46. var event = new Event('change');
  47. e.target.dispatchEvent(event);
  48. });
  49. return myselect;
  50. }
  51. }
  52. $('.action-delete').on('click', function (e) {
  53. e.preventDefault();
  54. const formAction = $(this).attr('formaction');
  55. $('#modal-delete').modal({backdrop: true, keyboard: true})
  56. .off('click', '#modal-delete-button')
  57. .on('click', '#modal-delete-button', function () {
  58. let deleteForm = $('#delete-form');
  59. deleteForm.attr('action', formAction);
  60. deleteForm.submit();
  61. });
  62. });