| Current Path : /home/juvelize/martine/tmp/install_61b0f5c54c150/media/js/vue/ |
| Current File : /home/juvelize/martine/tmp/install_61b0f5c54c150/media/js/vue/forms_edit.min.js |
jQuery(document).ready(function(e){let t;new Vue({el:"#acym__forms",data:()=>({form:acym_helper.parseJson(e("#acym__form__structure").val()),menuActive:"settings",loading:!0,noReloading:["name","pages","active","delay","redirection_options.after_subscription","redirection_options.confirmation_message"],oldForm:{}}),mounted(){this.oldForm=JSON.parse(JSON.stringify(this.form)),e("#acym__forms__preview__content").on("load",()=>{this.getFormRender(),this.disableClickIframe()}),acym_helperSwitch.setSwitchFieldsGlobal(),acym_helperTooltip.setTooltip()},computed:{isMenuSettingsActive(){return"settings"===this.menuActive},imageText(){return ACYM_JS_TXT[""===this.form.image_options.url?"ACYM_SELECT":"ACYM_CHANGE"]}},methods:{changeMenuActive(e){this.menuActive=e},selectPosition(e){this.form.style_options.position=e},save(t){if(""===this.form.name)return void alert(ACYM_JS_TXT.ACYM_PLEASE_FILL_FORM_NAME);this.loading=!0,this.form.active=e('[name="form[active]"]').val();let i=ACYM_AJAX_URL+"&ctrl=forms&task=saveAjax";return e.ajax({type:"POST",url:i,dataType:"json",data:{form:this.form}}).then(i=>{if(this.loading=!1,i.error)return acym_helperNotification.addNotification(i.message,"error"),!1;t?window.location.href=e("#acym_form").attr("action")+"&task=listing":(acym_helperNotification.addNotification(i.message,"info",!0),this.form.id=i.data.id,e("#acym__form__structure").val(i.data.id))})},disableClickIframe(){let t=e("#acym__forms__preview__content");t.contents().find("#acym__forms__edit_live__preview").remove(),t.contents().find("body").prepend("<style>\n * {pointer-events: none !important;}\n </style>")},fillIframe(t){let i=e("#acym__forms__preview__content");t=`<div id="acym__forms__edit_live__preview">${t}</div>`,i.contents().find("#acym__forms__edit_live__preview").remove(),i.contents().find("body").prepend(t)},getFormRender(){this.loading=!0;let t=ACYM_AJAX_URL+"&ctrl=forms&task=updateFormPreview";return e.ajax({type:"POST",url:t,dataType:"json",data:{form:this.form}}).then(e=>{if(this.loading=!1,e.error)return acym_helperNotification.addNotification(e.message,"error"),!1;this.fillIframe(e.data.html)})}},watch:{form:{handler(){e(".acym__forms__menu__container").off("scroll"),clearTimeout(t);let i=!1;for(let e=0;e<this.noReloading.length;e++)if(-1===this.noReloading[e].indexOf("."))"pages"===this.noReloading[e]?acym_helper.sameArrays(this.form[this.noReloading[e]],this.oldForm[this.noReloading[e]])||(i=!0):this.form[this.noReloading[e]]!==this.oldForm[this.noReloading[e]]&&(i=!0);else{let t=this.noReloading[e].split(".");this.form[t[0]][t[1]]!==this.oldForm[t[0]][t[1]]&&(i=!0)}this.oldForm=JSON.parse(JSON.stringify(this.form)),i||(this.loading=!0,t=setTimeout(()=>{this.getFormRender()},1e3))},deep:!0}}})});