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
This commit is contained in:
2
assets/js/tax-rates.min.js
vendored
2
assets/js/tax-rates.min.js
vendored
@ -1 +1 @@
|
||||
!function(t){t(document).ready((function(){t("#wu-tax-rates").length&&(Vue.component("selectizer",{props:["value","id","name","model","country","state","selected","options","placeholder"],template:'<input v-bind="$props">',updated(){this.$nextTick((function(){const t=jQuery(this.$el).data("__options");t.data.country!==this.country&&(t.data.country=this.country,jQuery(this.$el).data("__options",t),this.$el.selectize.clear(),this.$el.selectize.clearOptions()),t.data.state!==this.state&&(t.data.state=this.state,jQuery(this.$el).data("__options",t))}))},mounted(){const t=this,e=this.$el;window.wu_selector({el:e,maxItems:1e3,options:this.options,valueField:"slug",labelField:"name",searchField:["slug","name"],create:!0,templateName:"checkout_form",data:{action:"wu_search",model:this.model,country:this.country,state:this.state,number:10}}),this.$el.selectize.on("change",(function(e){t.$emit("input",e)}))}}),window.wu_tax_rates=new Vue({el:"#wu-tax-rates",components:{vuedraggable:vuedraggable},data:()=>({dragging:!1,tax_category:"default",switching:!1,creating:!1,create_name:"",toggle:!1,loading:!0,saving:!1,initialLoading:!0,error:!1,changed:!1,data:{default:{name:"Default",rates:[]}},delete:[],saveMessage:"",errorMessage:"",rate_type:"standard_rate",editing:0,item:{title:wu_tax_ratesl10n.name,country:"",state:"",tax_rate:"",type:"regular",compound:!1}}),watch:{loading(t){!0===t?window.wu_blocked_table=wu_block_ui("table.wp-list-table"):void 0!==window.wu_blocked_table&&window.wu_blocked_table.unblock()}},mounted(){this.loading=!0,this.pull_data(!0),t(".wu-tooltip-vue").tipTip();const e=this;this.$watch("data",(function(){e.initialLoading?e.initialLoading=!1:e.changed=!0}),{deep:!0})},created(){const t=document.createEvent("Event");t.initEvent("vue_loaded",!0,!0),t.vue=this,window.dispatchEvent(t)},computed:{selected(){return t(this.data[this.tax_category].rates).filter((function(t,e){return e.selected}))}},methods:{refresh(t){t.preventDefault(),this.loading=!0,this.pull_data()},select_all(e){const a=t(e.target).is(":checked");this.data[this.tax_category].rates=t.map(this.data[this.tax_category].rates,(function(t){return t.selected=a,t}))},pull_data(){const t=this;jQuery.getJSON(ajaxurl+"?action=wu_get_tax_rates").done((function(e){t.loading=!1,t.data=e.data})).fail((function(e){t.loading=!1,t.error=!0,t.errorMessage=e.statusText}))},add_tax_category(){this.data[this.create_name]={name:this.create_name,rates:[]},this.creating=!1,this.tax_category=this.create_name},add_row(){Vue.set(this.data[this.tax_category],"rates",this.data[this.tax_category].rates.concat([{title:wu_tax_ratesl10n.name,country:"",state:"",tax_rate:"",type:"regular",compound:!1}])),this.$forceUpdate()},delete_tax_category(){const t=confirm(wu_tax_ratesl10n.confirm_delete_tax_category_message),e=this;if(t){const t=_.filter(this.data,(function(t,a){return a!==e.tax_category}));e.data=t.length?t:{default:{name:"Default",rates:[]}},e.tax_category=Object.keys(e.data).shift()}},delete_rows(){this.delete=this.delete.concat(this.selected.get());if(confirm(wu_tax_ratesl10n.confirm_message)){const e=t(this.data[this.tax_category].rates).filter((function(t,e){return!e.selected}));Vue.set(this.data[this.tax_category],"rates",e.get()),this.$forceUpdate()}},save(){const e=this;e.saving=!0,void 0!==e.data[e.tax_category].rates&&_.map(e.data[e.tax_category].rates,(t,e)=>(t.priority=10*e,t)),t.post({url:ajaxurl+"?action=wu_save_tax_rates&"+t("#nonce_form").serialize(),data:JSON.stringify({tax_rates:e.data,tax_category:e.tax_category}),dataType:"json",contentType:"application/json; charset=utf-8"}).success((function(t){e.saving=!1,e.changed=!1,e.delete=[],e.saveMessage=t.message,"success"===t.code&&(e.loading=!0,e.initialLoading=!0,e.pull_data(),e.tax_category=t.tax_category),setInterval((function(){e.saveMessage=""}),6e3)}))}}}))}))}(jQuery);
|
||||
(a=>{a(document).ready(function(){a("#wu-tax-rates").length&&(Vue.component("selectizer",{props:["value","id","name","model","country","state","selected","options","placeholder"],template:'<input v-bind="$props">',updated(){this.$nextTick(function(){var t=jQuery(this.$el).data("__options");t.data.country!==this.country&&(t.data.country=this.country,jQuery(this.$el).data("__options",t),this.$el.selectize.clear(),this.$el.selectize.clearOptions()),t.data.state!==this.state&&(t.data.state=this.state,jQuery(this.$el).data("__options",t))})},mounted(){let e=this;var t=this.$el;window.wu_selector({el:t,maxItems:1e3,options:this.options,valueField:"slug",labelField:"name",searchField:["slug","name"],create:!0,templateName:"checkout_form",data:{action:"wu_search",model:this.model,country:this.country,state:this.state,number:10}}),this.$el.selectize.on("change",function(t){e.$emit("input",t)})}}),window.wu_tax_rates=new Vue({el:"#wu-tax-rates",components:{vuedraggable:vuedraggable},data(){return{dragging:!1,tax_category:"default",switching:!1,creating:!1,create_name:"",toggle:!1,loading:!0,saving:!1,initialLoading:!0,error:!1,changed:!1,data:{default:{name:"Default",rates:[]}},delete:[],saveMessage:"",errorMessage:"",rate_type:"standard_rate",editing:0,item:{title:wu_tax_ratesl10n.name,country:"",state:"",tax_rate:"",type:"regular",compound:!1}}},watch:{loading(t){!0===t?window.wu_blocked_table=wu_block_ui("table.wp-list-table"):void 0!==window.wu_blocked_table&&window.wu_blocked_table.unblock()}},mounted(){this.loading=!0,this.pull_data(!0),a(".wu-tooltip-vue").tipTip();let t=this;this.$watch("data",function(){t.initialLoading?t.initialLoading=!1:t.changed=!0},{deep:!0})},created(){var t=document.createEvent("Event");t.initEvent("vue_loaded",!0,!0),t.vue=this,window.dispatchEvent(t)},computed:{selected(){return a(this.data[this.tax_category].rates).filter(function(t,e){return e.selected})}},methods:{refresh(t){t.preventDefault(),this.loading=!0,this.pull_data()},select_all(t){let e=a(t.target).is(":checked");this.data[this.tax_category].rates=a.map(this.data[this.tax_category].rates,function(t){return t.selected=e,t})},pull_data(){let e=this;jQuery.getJSON(ajaxurl+"?action=wu_get_tax_rates").done(function(t){e.loading=!1,e.data=t.data}).fail(function(t){e.loading=!1,e.error=!0,e.errorMessage=t.statusText})},add_tax_category(){this.data[this.create_name]={name:this.create_name,rates:[]},this.creating=!1,this.tax_category=this.create_name},add_row(){Vue.set(this.data[this.tax_category],"rates",this.data[this.tax_category].rates.concat([{title:wu_tax_ratesl10n.name,country:"",state:"",tax_rate:"",type:"regular",compound:!1}])),this.$forceUpdate()},delete_tax_category(){var t=confirm(wu_tax_ratesl10n.confirm_delete_tax_category_message);let a=this;t&&(t=_.filter(this.data,function(t,e){return e!==a.tax_category}),a.data=t.length?t:{default:{name:"Default",rates:[]}},a.tax_category=Object.keys(a.data).shift())},delete_rows(){var t;this.delete=this.delete.concat(this.selected.get()),confirm(wu_tax_ratesl10n.confirm_message)&&(t=a(this.data[this.tax_category].rates).filter(function(t,e){return!e.selected}),Vue.set(this.data[this.tax_category],"rates",t.get()),this.$forceUpdate())},save(){let e=this;e.saving=!0,void 0!==e.data[e.tax_category].rates&&_.map(e.data[e.tax_category].rates,(t,e)=>(t.priority=10*e,t)),a.post({url:ajaxurl+"?action=wu_save_tax_rates&"+a("#nonce_form").serialize(),data:JSON.stringify({tax_rates:e.data,tax_category:e.tax_category}),dataType:"json",contentType:"application/json; charset=utf-8"}).success(function(t){e.saving=!1,e.changed=!1,e.delete=[],e.saveMessage=t.message,"success"===t.code&&(e.loading=!0,e.initialLoading=!0,e.pull_data(),e.tax_category=t.tax_category),setInterval(function(){e.saveMessage=""},6e3)})}}}))})})(jQuery);
|
||||
|
Reference in New Issue
Block a user