{"version":3,"file":"mail_operation_templates.ts-DA7aDZrN.js","sources":["../../../../../app/javascript/entries/controllers/mail_operation_templates.ts"],"sourcesContent":["// @ts-nocheck\nimport { t } from \"i18next\";\nimport jquery from \"jquery\";\nwindow.$ = jquery;\n\n$(function () {\n $(document).on(\"click\", \"#js-mail_operation_templates_send_test\", function () {\n loadingStart();\n sendTest();\n });\n\n function loadingStart() {\n $(\"#js-mail_operation_templates_send_test\").css(\"pointer-events\", \"none\");\n $(\".js-mail_operation_templates-success-message\").css(\"display\", \"none\");\n $(\".js-mail_operation_templates-err-message\").css(\"display\", \"none\");\n $(\".js-mail_operation_templates_output_display_area\").css(\"display\", \"none\");\n $(\".js-mail_operation_templates_send_test-text\").css(\"display\", \"none\");\n $(\".js-mail_operation_templates_send_test-loading\").css(\"display\", \"block\");\n }\n\n function loadingEnd() {\n $(\"#js-mail_operation_templates_send_test\").css(\"pointer-events\", \"auto\");\n $(\".js-mail_operation_templates_send_test-text\").text(t(\"MailOperationTemplates.再テスト\"));\n $(\".js-mail_operation_templates_send_test-text\").css(\"display\", \"block\");\n $(\".js-mail_operation_templates_send_test-loading\").css(\"display\", \"none\");\n }\n function sendTest() {\n return $.ajax({\n type: \"post\",\n url: `${window.location.pathname}/ajax_send_test`,\n })\n .done((data, textStatus, jqXHR) => {\n $(\".js-mail_operation_templates-success-message\").css(\"display\", \"flex\");\n $(\".js-mail_operation_templates-err-message\").css(\"display\", \"none\");\n $(\".js-mail_operation_templates_output_display_area\").css(\"display\", \"block\");\n loadingEnd();\n })\n .fail((jqXHR, textStatus, errorThrown) => {\n $(\".js-mail_operation_templates-success-message\").css(\"display\", \"none\");\n $(\".js-mail_operation_templates-err-message\").css(\"display\", \"flex\");\n $(\".js-mail_operation_templates_output_display_area\").css(\"display\", \"block\");\n loadingEnd();\n if (jqXHR.responseJSON !== undefined) {\n const alert_msg = jqXHR.responseJSON[\"body\"];\n $(\".js-mail_operation_templates-err-message-note\").text(alert_msg);\n }\n });\n }\n\n // ファイル名をフォームに表示\n $(\".js-mail_operation_attachment_templates_attachment_filename\").each(function () {\n attach_file_name_to_form(this);\n });\n $(document).on(\"change\", \".js-mail_operation_attachment_templates_attachment\", function () {\n attach_file_name_to_form(this);\n });\n\n function attach_file_name_to_form(object) {\n const fileLabel = $(object)\n .parent()\n .find(\".js-mail_operation_attachment_templates_attachment\")\n .parent()\n .find(\"label.custom-file-label\");\n\n if (object.files[0]) {\n fileLabel.text(object.files[0].name || t(\"MailOperationTemplates.ファイルを追加\"));\n }\n if (fileLabel[0].innerText !== t(\"MailOperationTemplates.ファイルを追加\")) {\n fileLabel.addClass(\"attached\");\n }\n }\n $(\".bootstrap-tagsinput\").each(function () {\n const isInvalid = this.nextElementSibling.nextElementSibling !== null;\n if (isInvalid) {\n this.classList.add(\"form-control\", \"is-invalid\");\n }\n });\n});\n\ndocument.addEventListener(\"DOMContentLoaded\", function () {\n $(document).on(\"change\", \".js-mail_operation_attachment_templates_attach_from\", function () {\n const attach_from = $(this).val();\n if (attach_from === \"upload\") {\n $(this).parent().parent().parent().find(\".js-mail_operation_attachment_templates_output-wrap\").hide();\n $(this).parent().parent().parent().find(\".js-mail_operation_attachment_templates_upload-wrap\").show();\n } else {\n $(this).parent().parent().parent().find(\".js-mail_operation_attachment_templates_output-wrap\").show();\n $(this).parent().parent().parent().find(\".js-mail_operation_attachment_templates_upload-wrap\").hide();\n }\n });\n});\n"],"names":["jquery","loadingStart","sendTest","loadingEnd","t","data","textStatus","jqXHR","errorThrown","alert_msg","attach_file_name_to_form","object","fileLabel"],"mappings":"oKAGA,OAAO,EAAIA,EAEX,EAAE,UAAY,CACZ,EAAE,QAAQ,EAAE,GAAG,QAAS,yCAA0C,UAAY,CAC/DC,EAAA,EACJC,EAAA,CAAA,CACV,EAED,SAASD,GAAe,CACtB,EAAE,wCAAwC,EAAE,IAAI,iBAAkB,MAAM,EACxE,EAAE,8CAA8C,EAAE,IAAI,UAAW,MAAM,EACvE,EAAE,0CAA0C,EAAE,IAA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