bundles/Bgt/WebBundle/Resources/views/layout/_dynamic-call.html.twig line 1

  1. <div id="web_modal_default" class="modal" tabindex="-1">
  2.     <div class="modal-dialog modal-xl modal-dialog-centered">
  3.         <div class="modal-content">
  4.             <div class="modal-header">
  5.                 <h5 class="modal-title">Modal title</h5>
  6.                 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  7.                     <span aria-hidden="true">&times;</span>
  8.                 </button>
  9.             </div>
  10.             <div class="modal-body">
  11.                 <p>Modal body text goes here.</p>
  12.             </div>
  13.         </div>
  14.     </div>
  15. </div>
  16. <script src="{{ asset('asset/dynamic_call/dynamic_call.js') }}" type="text/javascript"></script>
  17. <script type="text/javascript">
  18.     let loader = $('.preloader');
  19.     let dynamicCall = new DynamicCall({
  20.         toastShow: toastShow,
  21.         modalShow: modalShow,
  22.         modalHide: modalHide,
  23.         loaderShow: loaderShow,
  24.         loaderHide: loaderHide,
  25.     });
  26.     function toastShow(toastData) {
  27.         if (toastData.status === "success") {
  28.             toastr.success(message);
  29.         } else if (toastData.status === "warning") {
  30.             toastr.warning(message);
  31.         } else if (toastData.status === "info") {
  32.             toastr.info(message);
  33.         } else if (toastData.status === "error") {
  34.             toastr.error(message);
  35.         }
  36.     }
  37.     function modalShow(modalData) {
  38.         let modal = $("#web_modal_default");
  39.         modal.find(".modal-header").first().html(modalData.title);
  40.         modal.find(".modal-body").first().html(modalData.content);
  41.         modal.modal('show');
  42.         let button = modal.find(".mdl_submit").first();
  43.         if (modalData.submitText && modalData.submitText.length > 0) {
  44.             button.html(modalData.submitText);
  45.             button.show();
  46.         } else {
  47.             button.hide();
  48.         }
  49.     }
  50.     function modalHide() {
  51.         let modal = $("#web_modal_default");
  52.         modal.modal('hide');
  53.     }
  54.     function loaderShow() {
  55.         loader.show();
  56.     }
  57.     function loaderHide() {
  58.         loader.hide();
  59.     }
  60.     function errorHandle(error) {
  61.         let response = error.response;
  62.         if (response.status === 404) {
  63.             toastr.error('Мэдээлэл олдсонгүй!');
  64.         } else if (response.status === 403) {
  65.             toastr.error('Таны хандах эрх хүрэхгүй байна!');
  66.         } else {
  67.             toastr.error('Уучлаарай дахин оролдоно уу.');
  68.         }
  69.     }
  70. </script>