From 26a06a7a6917607ee10d4c2831bc84f157636044 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Thu, 24 Mar 2016 11:34:00 +0000 Subject: [PATCH] Tweak check to use indexof --- assets/js/admin/settings-views-html-settings-tax.js | 2 +- assets/js/admin/settings-views-html-settings-tax.min.js | 2 +- assets/js/frontend/password-strength-meter.min.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/js/admin/settings-views-html-settings-tax.js b/assets/js/admin/settings-views-html-settings-tax.js index 8cb1f4db7e1..9519cf155bc 100644 --- a/assets/js/admin/settings-views-html-settings-tax.js +++ b/assets/js/admin/settings-views-html-settings-tax.js @@ -84,7 +84,7 @@ Backbone.ajax({ method: 'POST', dataType: 'json', - url: ajaxurl + ajaxurl.split('?')[1] ? '&':'?' + 'action=woocommerce_tax_rates_save_changes', + url: ajaxurl + ( ajaxurl.indexOf( '?' ) > 0 ? '&' : '?' ) + 'action=woocommerce_tax_rates_save_changes', data: { current_class: data.current_class, wc_tax_nonce: data.wc_tax_nonce, diff --git a/assets/js/admin/settings-views-html-settings-tax.min.js b/assets/js/admin/settings-views-html-settings-tax.min.js index f7c2cd20625..7c4e185bcd1 100644 --- a/assets/js/admin/settings-views-html-settings-tax.min.js +++ b/assets/js/admin/settings-views-html-settings-tax.min.js @@ -1 +1 @@ -!function(a,b,c,d){a(function(){String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")});var e=c.template("wc-tax-table-row"),f=c.template("wc-tax-table-row-empty"),g=c.template("wc-tax-table-pagination"),h=a(".wc_tax_rates"),i=a("#rates"),j=a('input[name="save"]'),k=a("#rates-pagination"),l=a("#rates-search .wc-tax-rates-search-field"),m=a(".submit .button-primary[type=submit]"),n=Backbone.Model.extend({changes:{},setRateAttribute:function(a,b,c){var d=_.indexBy(this.get("rates"),"tax_rate_id"),e={};d[a][b]!==c&&(e[a]={},e[a][b]=c,d[a][b]=c),this.logChanges(e)},logChanges:function(a){var b=this.changes||{};_.each(a,function(a,c){b[c]=_.extend(b[c]||{tax_rate_id:c},a)}),this.changes=b,this.trigger("change:rates")},getFilteredRates:function(){var a=this.get("rates"),b=l.val().toLowerCase();return b.length&&(a=_.filter(a,function(a){var c=_.toArray(a).join(" ").toLowerCase();return-1!==c.indexOf(b)})),a=_.sortBy(a,function(a){return parseInt(a.tax_rate_order,10)})},block:function(){a(".wc_tax_rates").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},unblock:function(){a(".wc_tax_rates").unblock()},save:function(){var a=this;a.block(),Backbone.ajax({method:"POST",dataType:"json",url:d+d.split("?")[1]?"&":"?action=woocommerce_tax_rates_save_changes",data:{current_class:b.current_class,wc_tax_nonce:b.wc_tax_nonce,changes:a.changes},success:function(b,c){"success"===c&&(p.set("rates",b.data.rates),p.trigger("change:rates"),p.changes={},p.trigger("saved:rates"),q.render()),a.unblock()}})}}),o=Backbone.View.extend({rowTemplate:e,per_page:b.limit,page:b.page,initialize:function(){var c=Math.ceil(_.toArray(this.model.get("rates")).length/this.per_page);this.qty_pages=0===c?1:c,this.page=this.sanitizePage(b.page),this.listenTo(this.model,"change:rates",this.setUnloadConfirmation),this.listenTo(this.model,"saved:rates",this.clearUnloadConfirmation),i.on("change autocompletechange",":input",{view:this},this.updateModelOnChange),i.on("sortupdate",{view:this},this.updateModelOnSort),l.on("keyup search",{view:this},this.onSearchField),k.on("click","a",{view:this},this.onPageChange),k.on("change","input",{view:this},this.onPageChange),a(window).on("beforeunload",{view:this},this.unloadConfirmation),m.on("click",{view:this},this.onSubmit),j.attr("disabled","disabled"),h.find(".insert").on("click",{view:this},this.onAddNewRow),h.find(".remove_tax_rates").on("click",{view:this},this.onDeleteRow),h.find(".export").on("click",{view:this},this.onExport)},render:function(){var c=this.model.getFilteredRates(),d=_.size(c),e=Math.ceil(d/this.per_page),h=0===d?0:this.per_page*(this.page-1),j=this.per_page*this.page,m=_.toArray(c).slice(h,j),n=this;this.$el.empty(),m.length?a.each(m,function(a,b){n.$el.append(n.rowTemplate(b))}):n.$el.append(f()),this.$el.find("td.country input").autocomplete({source:b.countries,minLength:2}),this.$el.find("td.state input").autocomplete({source:b.states,minLength:3}),this.$el.find("td.postcode input, td.city input").change(function(){a(this).attr("name",a(this).data("name"))}),e>1?k.html(g({qty_rates:d,current_page:this.page,qty_pages:e})):(k.empty(),n.page=1),l.val()?i.sortable("disable"):i.sortable("enable")},updateUrl:function(){if(window.history.replaceState){var a=b.base_url,c=l.val();1e}),g=_.map(f,function(a){return a.tax_rate_order++,l[a.tax_rate_id]=_.extend(l[a.tax_rate_id]||{},{tax_rate_order:a.tax_rate_order}),a})):(n.tax_rate_order=1+_.max(_.pluck(k,"tax_rate_order"),function(a){return parseInt(a,10)}),h.page=h.qty_pages),k[n.tax_rate_id]=n,l[n.tax_rate_id]=n,j.set("rates",k),j.logChanges(l),h.render()},onDeleteRow:function(c){var d,e,f=c.data.view,g=f.model,h=_.indexBy(g.get("rates"),"tax_rate_id"),j={};c.preventDefault(),(d=i.children(".current"))?(d.each(function(){e=a(this).data("id"),delete h[e],j[e]=_.extend(j[e]||{},{deleted:"deleted"})}),g.set("rates",h),g.logChanges(j),f.render()):window.alert(b.strings.no_rows_selected)},onSearchField:function(a){a.data.view.updateUrl(),a.data.view.render()},onPageChange:function(b){var c=a(b.currentTarget);b.preventDefault(),b.data.view.page=c.data("goto")?c.data("goto"):c.val(),b.data.view.render(),b.data.view.updateUrl()},onExport:function(c){var d="data:application/csv;charset=utf-8,"+b.strings.csv_data_cols.join(",")+"\n";return a.each(c.data.view.model.getFilteredRates(),function(a,c){var e="";e+=c.tax_rate_country+",",e+=c.tax_rate_state+",",e+=(c.postcode?c.postcode.join("; "):"")+",",e+=(c.city?c.city.join("; "):"")+",",e+=c.tax_rate+",",e+=c.tax_rate_name+",",e+=c.tax_rate_priority+",",e+=c.tax_rate_compound+",",e+=c.tax_rate_shipping+",",e+=b.current_class,d+=e+"\n"}),a(this).attr("href",encodeURI(d)),!0},setUnloadConfirmation:function(){this.needsUnloadConfirm=!0,j.removeAttr("disabled")},clearUnloadConfirmation:function(){this.needsUnloadConfirm=!1,j.attr("disabled","disabled")},unloadConfirmation:function(a){return a.data.view.needsUnloadConfirm?(a.returnValue=b.strings.unload_confirmation_msg,window.event.returnValue=b.strings.unload_confirmation_msg,b.strings.unload_confirmation_msg):void 0},updateModelOnChange:function(b){var c=b.data.view.model,d=a(b.target),e=d.closest("tr").data("id"),f=d.data("attribute"),g=d.val();"city"!==f&&"postcode"!==f||(g=g.split(";"),g=a.map(g,function(a){return a.trim()})),"tax_rate_compound"!==f&&"tax_rate_shipping"!==f||(g=d.is(":checked")?1:0),c.setRateAttribute(e,f,g)},updateModelOnSort:function(a){var b=a.data.view,c=b.model,d=_.indexBy(c.get("rates"),"tax_rate_id"),e={};_.each(d,function(a){var c=0,d=parseInt(a.tax_rate_order,10);c=h.find('tr[data-id="'+a.tax_rate_id+'"]').length?parseInt(h.find('tr[data-id="'+a.tax_rate_id+'"]').index(),10)+parseInt((b.page-1)*b.per_page,10):d,d!==c&&(e[a.tax_rate_id]=_.extend(e[a.tax_rate_id]||{},{tax_rate_order:c}))}),_.size(e)&&c.logChanges(e)},sanitizePage:function(a){return a=parseInt(a,10),1>a?a=1:a>this.qty_pages&&(a=this.qty_pages),a}}),p=new n({rates:b.rates}),q=new o({model:p,el:"#rates"});q.render()})}(jQuery,htmlSettingsTaxLocalizeScript,wp,ajaxurl); \ No newline at end of file +!function(a,b,c,d){a(function(){String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")});var e=c.template("wc-tax-table-row"),f=c.template("wc-tax-table-row-empty"),g=c.template("wc-tax-table-pagination"),h=a(".wc_tax_rates"),i=a("#rates"),j=a('input[name="save"]'),k=a("#rates-pagination"),l=a("#rates-search .wc-tax-rates-search-field"),m=a(".submit .button-primary[type=submit]"),n=Backbone.Model.extend({changes:{},setRateAttribute:function(a,b,c){var d=_.indexBy(this.get("rates"),"tax_rate_id"),e={};d[a][b]!==c&&(e[a]={},e[a][b]=c,d[a][b]=c),this.logChanges(e)},logChanges:function(a){var b=this.changes||{};_.each(a,function(a,c){b[c]=_.extend(b[c]||{tax_rate_id:c},a)}),this.changes=b,this.trigger("change:rates")},getFilteredRates:function(){var a=this.get("rates"),b=l.val().toLowerCase();return b.length&&(a=_.filter(a,function(a){var c=_.toArray(a).join(" ").toLowerCase();return-1!==c.indexOf(b)})),a=_.sortBy(a,function(a){return parseInt(a.tax_rate_order,10)})},block:function(){a(".wc_tax_rates").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},unblock:function(){a(".wc_tax_rates").unblock()},save:function(){var a=this;a.block(),Backbone.ajax({method:"POST",dataType:"json",url:d+(d.indexOf("?")>0?"&":"?")+"action=woocommerce_tax_rates_save_changes",data:{current_class:b.current_class,wc_tax_nonce:b.wc_tax_nonce,changes:a.changes},success:function(b,c){"success"===c&&(p.set("rates",b.data.rates),p.trigger("change:rates"),p.changes={},p.trigger("saved:rates"),q.render()),a.unblock()}})}}),o=Backbone.View.extend({rowTemplate:e,per_page:b.limit,page:b.page,initialize:function(){var c=Math.ceil(_.toArray(this.model.get("rates")).length/this.per_page);this.qty_pages=0===c?1:c,this.page=this.sanitizePage(b.page),this.listenTo(this.model,"change:rates",this.setUnloadConfirmation),this.listenTo(this.model,"saved:rates",this.clearUnloadConfirmation),i.on("change autocompletechange",":input",{view:this},this.updateModelOnChange),i.on("sortupdate",{view:this},this.updateModelOnSort),l.on("keyup search",{view:this},this.onSearchField),k.on("click","a",{view:this},this.onPageChange),k.on("change","input",{view:this},this.onPageChange),a(window).on("beforeunload",{view:this},this.unloadConfirmation),m.on("click",{view:this},this.onSubmit),j.attr("disabled","disabled"),h.find(".insert").on("click",{view:this},this.onAddNewRow),h.find(".remove_tax_rates").on("click",{view:this},this.onDeleteRow),h.find(".export").on("click",{view:this},this.onExport)},render:function(){var c=this.model.getFilteredRates(),d=_.size(c),e=Math.ceil(d/this.per_page),h=0===d?0:this.per_page*(this.page-1),j=this.per_page*this.page,m=_.toArray(c).slice(h,j),n=this;this.$el.empty(),m.length?a.each(m,function(a,b){n.$el.append(n.rowTemplate(b))}):n.$el.append(f()),this.$el.find("td.country input").autocomplete({source:b.countries,minLength:2}),this.$el.find("td.state input").autocomplete({source:b.states,minLength:3}),this.$el.find("td.postcode input, td.city input").change(function(){a(this).attr("name",a(this).data("name"))}),e>1?k.html(g({qty_rates:d,current_page:this.page,qty_pages:e})):(k.empty(),n.page=1),l.val()?i.sortable("disable"):i.sortable("enable")},updateUrl:function(){if(window.history.replaceState){var a=b.base_url,c=l.val();1e}),g=_.map(f,function(a){return a.tax_rate_order++,l[a.tax_rate_id]=_.extend(l[a.tax_rate_id]||{},{tax_rate_order:a.tax_rate_order}),a})):(n.tax_rate_order=1+_.max(_.pluck(k,"tax_rate_order"),function(a){return parseInt(a,10)}),h.page=h.qty_pages),k[n.tax_rate_id]=n,l[n.tax_rate_id]=n,j.set("rates",k),j.logChanges(l),h.render()},onDeleteRow:function(c){var d,e,f=c.data.view,g=f.model,h=_.indexBy(g.get("rates"),"tax_rate_id"),j={};c.preventDefault(),(d=i.children(".current"))?(d.each(function(){e=a(this).data("id"),delete h[e],j[e]=_.extend(j[e]||{},{deleted:"deleted"})}),g.set("rates",h),g.logChanges(j),f.render()):window.alert(b.strings.no_rows_selected)},onSearchField:function(a){a.data.view.updateUrl(),a.data.view.render()},onPageChange:function(b){var c=a(b.currentTarget);b.preventDefault(),b.data.view.page=c.data("goto")?c.data("goto"):c.val(),b.data.view.render(),b.data.view.updateUrl()},onExport:function(c){var d="data:application/csv;charset=utf-8,"+b.strings.csv_data_cols.join(",")+"\n";return a.each(c.data.view.model.getFilteredRates(),function(a,c){var e="";e+=c.tax_rate_country+",",e+=c.tax_rate_state+",",e+=(c.postcode?c.postcode.join("; "):"")+",",e+=(c.city?c.city.join("; "):"")+",",e+=c.tax_rate+",",e+=c.tax_rate_name+",",e+=c.tax_rate_priority+",",e+=c.tax_rate_compound+",",e+=c.tax_rate_shipping+",",e+=b.current_class,d+=e+"\n"}),a(this).attr("href",encodeURI(d)),!0},setUnloadConfirmation:function(){this.needsUnloadConfirm=!0,j.removeAttr("disabled")},clearUnloadConfirmation:function(){this.needsUnloadConfirm=!1,j.attr("disabled","disabled")},unloadConfirmation:function(a){return a.data.view.needsUnloadConfirm?(a.returnValue=b.strings.unload_confirmation_msg,window.event.returnValue=b.strings.unload_confirmation_msg,b.strings.unload_confirmation_msg):void 0},updateModelOnChange:function(b){var c=b.data.view.model,d=a(b.target),e=d.closest("tr").data("id"),f=d.data("attribute"),g=d.val();"city"!==f&&"postcode"!==f||(g=g.split(";"),g=a.map(g,function(a){return a.trim()})),"tax_rate_compound"!==f&&"tax_rate_shipping"!==f||(g=d.is(":checked")?1:0),c.setRateAttribute(e,f,g)},updateModelOnSort:function(a){var b=a.data.view,c=b.model,d=_.indexBy(c.get("rates"),"tax_rate_id"),e={};_.each(d,function(a){var c=0,d=parseInt(a.tax_rate_order,10);c=h.find('tr[data-id="'+a.tax_rate_id+'"]').length?parseInt(h.find('tr[data-id="'+a.tax_rate_id+'"]').index(),10)+parseInt((b.page-1)*b.per_page,10):d,d!==c&&(e[a.tax_rate_id]=_.extend(e[a.tax_rate_id]||{},{tax_rate_order:c}))}),_.size(e)&&c.logChanges(e)},sanitizePage:function(a){return a=parseInt(a,10),1>a?a=1:a>this.qty_pages&&(a=this.qty_pages),a}}),p=new n({rates:b.rates}),q=new o({model:p,el:"#rates"});q.render()})}(jQuery,htmlSettingsTaxLocalizeScript,wp,ajaxurl); \ No newline at end of file diff --git a/assets/js/frontend/password-strength-meter.min.js b/assets/js/frontend/password-strength-meter.min.js index d0f00266cee..912ccbbd2a3 100644 --- a/assets/js/frontend/password-strength-meter.min.js +++ b/assets/js/frontend/password-strength-meter.min.js @@ -1 +1 @@ -jQuery(function(a){var b={init:function(){a(document.body).on("keyup change","form.register #reg_password, form.checkout #account_password, form.edit-account #password_1, form.lost_reset_password #password_1",this.strengthMeter),a("form.checkout #createaccount").change()},strengthMeter:function(){var c=a("form.register, form.checkout, form.edit-account, form.lost_reset_password"),d=a('input[type="submit"]',c),e=a("#reg_password, #account_password, #password_1",c),f=1;b.includeMeter(c,e),f=b.checkPasswordStrength(e),f'),a(document.body).trigger("wc-password-strength-added"))},checkPasswordStrength:function(b){var c=a(".woocommerce-password-strength"),d=a(".woocommerce-password-hint"),e=''+wc_password_strength_meter_params.i18n_password_hint+"",f=wp.passwordStrength.meter(b.val(),wp.passwordStrength.userInputBlacklist()),g="";switch(c.removeClass("short bad good strong"),d.remove(),f'),a(document.body).trigger("wc-password-strength-added"))},checkPasswordStrength:function(a,b){var c=a.find(".woocommerce-password-strength"),d=a.find(".woocommerce-password-hint"),e=''+wc_password_strength_meter_params.i18n_password_hint+"",f=wp.passwordStrength.meter(b.val(),wp.passwordStrength.userInputBlacklist()),g="";switch(c.removeClass("short bad good strong"),d.remove(),f