Files
wp-multisite-waas/assets/js/checkout-forms-editor.min.js
David Stone d88e50df38 Prep Plugin for release on WordPress.org (#23)
* Update translation text domain
* Escape everything that should be escaped.
* Add nonce checks where needed.
* Sanitize all inputs.
* Apply Code style changes across the codebase.
* Correct many deprecation notices.
* Optimize load order of many filters.
* Add Proper Build script
* Use emojii flags
* Fix i18n deprecation  notice for translating too early
* Put all scripts in footer and load async
2025-04-14 11:36:46 -06:00

2 lines
2.7 KiB
JavaScript

(t=>{t(document).ready(function(){var e={components:{vuedraggable:vuedraggable},template:"#wu-table",props:["list","headers","step_name"],name:"wu-draggable-table",data(){return{delete_field_id:""}},methods:{remove_field(e){wu_checkout_forms_editor_app.remove_field(this.step_name,e),this.delete_field_id=""}}};wu_checkout_forms_editor_app=new Vue({el:"#wu-checkout-editor-app",name:"CheckoutEditor",data(){return Object.assign({},{dragging:!1,search:"",delete_step_id:"",preview_error:!1,preview:!1,loading_preview:!1,preview_content:"",iframe_preview_url:""},wu_checkout_form)},components:{vuedraggable:vuedraggable,"wu-draggable-table":e},computed:{field_count(){return _.reduce(this.steps,function(e,i){return e+i.fields.length},0)}},watch:{steps:{handler(){this.update_session()},deep:!0}},mounted(){this.update_session()},methods:{get_preview(i=null){if(null===i&&(this.preview=!this.preview),this.preview){this.loading_preview=!0;let e=this;e.iframe_preview_url=e.register_page+"?action=wu_generate_checkout_form_preview&form_id="+e.form_id+"&type="+i+"&uniq="+1e3*Math.random(),t("#wp-ultimo-checkout-preview").on("load",function(){e.loading_preview=!1,setTimeout(()=>{var e=document.getElementById("wp-ultimo-checkout-preview").contentWindow.document.body.scrollHeight;t("#wp-ultimo-checkout-preview").animate({height:e})},1e3)})}console.log("no preview")},add_step(e,i=null){var t,s=e.original_id?this.find_step(e.original_id):this.find_step(e.id);delete e.original_id,void 0!==s?(t=_.indexOf(this.steps,s),(e=Object.assign({},s,e)).fields=s.fields,Vue.set(this.steps,t,e)):this.steps.push(e),this.$nextTick(function(){"function"==typeof i&&(i(),this.scroll_to("wp-ultimo-list-table-"+e.id))})},add_field(e,i=null){var t,s=_.findWhere(this.steps,{id:e.step});let d=this.find_field(e.step,e.id);void 0===d&&(d=this.find_field(e.step,e.original_id),delete e.original_id),void 0!==d?(t=_.indexOf(s.fields,d),Vue.set(s.fields,t,e)):s.fields.push(e),this.$nextTick(function(){"function"==typeof i&&(i(),this.scroll_to("wp-ultimo-field-"+e.id))})},scroll_to(e){this.$nextTick(function(){setTimeout(()=>{document.getElementById(e).scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})},500)})},find_step(e){return _.findWhere(this.steps,{id:e})},find_field(e,i){e=_.findWhere(this.steps,{id:e});return _.findWhere(e.fields,{id:i})},remove_step(i){this.steps=_.reject(this.steps,function(e){return e.id===i}),this.delete_step_id=""},remove_field(e,i){e=_.findWhere(this.steps,{id:e});e.fields=_.reject(e.fields,function(e){return e.id===i})},update_session(){wu_initialize_tooltip();t.ajax({method:"post",url:ajaxurl,data:{action:"wu_save_editor_session",settings:this.steps,form_id:this.form_id},success(){}})}}})})})(jQuery);