Merged in feature/280-dev-dev01 (pull request #21)
auto-patch 280-dev-dev01-2024-01-19T16_41_58 * auto-patch 280-dev-dev01-2024-01-19T16_41_58
This commit is contained in:
@@ -54,6 +54,7 @@
|
||||
events: {
|
||||
'click .modal-close': 'closeButton',
|
||||
'click #btn-ok' : 'addButton',
|
||||
'click #btn-back' : 'backButton',
|
||||
'click #btn-next' : 'nextButton',
|
||||
'touchstart #btn-ok': 'addButton',
|
||||
'keydown' : 'keyboardActions',
|
||||
@@ -111,6 +112,10 @@
|
||||
$( document.body ).trigger( 'wc_backbone_modal_response', [ this._target, this.getFormData() ] );
|
||||
this.closeButton( e, true );
|
||||
},
|
||||
backButton: function( e ) {
|
||||
$( document.body ).trigger( 'wc_backbone_modal_back_response', [ this._target, this.getFormData() ] );
|
||||
this.closeButton( e, false );
|
||||
},
|
||||
nextButton: function( e ) {
|
||||
var context = this;
|
||||
function closeModal() {
|
||||
|
||||
@@ -1 +1 @@
|
||||
!function(t,e,n){"use strict";t.fn.WCBackboneModal=function(e){return this.each(function(){new t.WCBackboneModal(t(this),e)})},t.WCBackboneModal=function(e,n){var o=t.extend({},t.WCBackboneModal.defaultOptions,n);o.template&&new t.WCBackboneModal.View({target:o.template,string:o.variable})},t.WCBackboneModal.defaultOptions={template:"",variable:{}},t.WCBackboneModal.View=e.View.extend({tagName:"div",id:"wc-backbone-modal-dialog",_target:undefined,_string:undefined,events:{"click .modal-close":"closeButton","click #btn-ok":"addButton","click #btn-next":"nextButton","touchstart #btn-ok":"addButton",keydown:"keyboardActions",input:"handleInputValidation"},resizeContent:function(){var e=t(".wc-backbone-modal-content").find("article"),n=.75*t(window).height();e.css({"max-height":n+"px"})},initialize:function(e){var o=this;this._target=e.target,this._string=e.string,n.bindAll(this,"render"),this.render(),t(window).on("resize",function(){o.resizeContent()})},render:function(){var e=wp.template(this._target);this.$el.append(e(this._string)),t(document.body).css({overflow:"hidden"}).append(this.$el),this.resizeContent(),this.$(".wc-backbone-modal-content").attr("tabindex","0").trigger("focus"),t(document.body).trigger("init_tooltips"),t(document.body).trigger("wc_backbone_modal_loaded",this._target)},closeButton:function(e,n){e.preventDefault(),t(document.body).trigger("wc_backbone_modal_before_remove",[this._target,this.getFormData(),!!n]),this.undelegateEvents(),t(document).off("focusin"),t(document.body).css({overflow:"auto"}),this.remove(),t(document.body).trigger("wc_backbone_modal_removed",this._target)},addButton:function(e){t(document.body).trigger("wc_backbone_modal_response",[this._target,this.getFormData()]),this.closeButton(e,!0)},nextButton:function(e){var n=this;t(document.body).trigger("wc_backbone_modal_next_response",[this._target,this.getFormData(),function(){n.closeButton(e)}])},getFormData:function(e=!0){var n={};return e&&t(document.body).trigger("wc_backbone_modal_before_update",this._target),t.each(t("form",this.$el).serializeArray(),function(e,o){-1!==o.name.indexOf("[]")?(o.name=o.name.replace("[]",""),n[o.name]=t.makeArray(n[o.name]),n[o.name].push(o.value)):n[o.name]=o.value}),n},handleInputValidation:function(){t(document.body).trigger("wc_backbone_modal_validation",[this._target,this.getFormData(!1)])},keyboardActions:function(e){var n=e.keyCode||e.which;13!==n||e.target.tagName&&("input"===e.target.tagName.toLowerCase()||"textarea"===e.target.tagName.toLowerCase())||(t("#btn-ok").length?this.addButton(e):t("#btn-next").length&&this.nextButton(e)),27===n&&this.closeButton(e)}})}(jQuery,Backbone,_);
|
||||
!function(t,e,n){"use strict";t.fn.WCBackboneModal=function(e){return this.each(function(){new t.WCBackboneModal(t(this),e)})},t.WCBackboneModal=function(e,n){var o=t.extend({},t.WCBackboneModal.defaultOptions,n);o.template&&new t.WCBackboneModal.View({target:o.template,string:o.variable})},t.WCBackboneModal.defaultOptions={template:"",variable:{}},t.WCBackboneModal.View=e.View.extend({tagName:"div",id:"wc-backbone-modal-dialog",_target:undefined,_string:undefined,events:{"click .modal-close":"closeButton","click #btn-ok":"addButton","click #btn-back":"backButton","click #btn-next":"nextButton","touchstart #btn-ok":"addButton",keydown:"keyboardActions",input:"handleInputValidation"},resizeContent:function(){var e=t(".wc-backbone-modal-content").find("article"),n=.75*t(window).height();e.css({"max-height":n+"px"})},initialize:function(e){var o=this;this._target=e.target,this._string=e.string,n.bindAll(this,"render"),this.render(),t(window).on("resize",function(){o.resizeContent()})},render:function(){var e=wp.template(this._target);this.$el.append(e(this._string)),t(document.body).css({overflow:"hidden"}).append(this.$el),this.resizeContent(),this.$(".wc-backbone-modal-content").attr("tabindex","0").trigger("focus"),t(document.body).trigger("init_tooltips"),t(document.body).trigger("wc_backbone_modal_loaded",this._target)},closeButton:function(e,n){e.preventDefault(),t(document.body).trigger("wc_backbone_modal_before_remove",[this._target,this.getFormData(),!!n]),this.undelegateEvents(),t(document).off("focusin"),t(document.body).css({overflow:"auto"}),this.remove(),t(document.body).trigger("wc_backbone_modal_removed",this._target)},addButton:function(e){t(document.body).trigger("wc_backbone_modal_response",[this._target,this.getFormData()]),this.closeButton(e,!0)},backButton:function(e){t(document.body).trigger("wc_backbone_modal_back_response",[this._target,this.getFormData()]),this.closeButton(e,!1)},nextButton:function(e){var n=this;t(document.body).trigger("wc_backbone_modal_next_response",[this._target,this.getFormData(),function(){n.closeButton(e)}])},getFormData:function(e=!0){var n={};return e&&t(document.body).trigger("wc_backbone_modal_before_update",this._target),t.each(t("form",this.$el).serializeArray(),function(e,o){-1!==o.name.indexOf("[]")?(o.name=o.name.replace("[]",""),n[o.name]=t.makeArray(n[o.name]),n[o.name].push(o.value)):n[o.name]=o.value}),n},handleInputValidation:function(){t(document.body).trigger("wc_backbone_modal_validation",[this._target,this.getFormData(!1)])},keyboardActions:function(e){var n=e.keyCode||e.which;13!==n||e.target.tagName&&("input"===e.target.tagName.toLowerCase()||"textarea"===e.target.tagName.toLowerCase())||(t("#btn-ok").length?this.addButton(e):t("#btn-next").length&&this.nextButton(e)),27===n&&this.closeButton(e)}})}(jQuery,Backbone,_);
|
||||
@@ -1440,7 +1440,7 @@ jQuery( function ( $ ) {
|
||||
grant_access: function() {
|
||||
var products = $( '#grant_access_id' ).val();
|
||||
|
||||
if ( ! products ) {
|
||||
if ( ! products || 0 === products.length ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1462,7 +1462,7 @@ jQuery( function ( $ ) {
|
||||
|
||||
$.post( woocommerce_admin_meta_boxes.ajax_url, data, function( response ) {
|
||||
|
||||
if ( response ) {
|
||||
if ( response && -1 !== parseInt( response ) ) {
|
||||
$( '.order_download_permissions .wc-metaboxes' ).append( response );
|
||||
} else {
|
||||
window.alert( woocommerce_admin_meta_boxes.i18n_download_permission_fail );
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -176,7 +176,10 @@ jQuery( function ( $ ) {
|
||||
function change_product_type_tip( content ) {
|
||||
$( '#tiptip_holder' ).removeAttr( 'style' );
|
||||
$( '#tiptip_arrow' ).removeAttr( 'style' );
|
||||
$( '.woocommerce-product-type-tip' ).tipTip( {
|
||||
$( '.woocommerce-product-type-tip' )
|
||||
.attr( 'tabindex', '0' )
|
||||
.attr( 'aria-label', $( '<div />' ).html( content ).text() ) // Remove HTML tags.
|
||||
.tipTip( {
|
||||
attribute: 'data-tip',
|
||||
content: content,
|
||||
fadeIn: 50,
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,35 @@
|
||||
/*global woocommerce_admin_meta_boxes, wcTracks */
|
||||
jQuery( document ).ready( ( $ ) => {
|
||||
'use strict';
|
||||
|
||||
// Stand-in wcTracks.recordEvent in case Tracks is not available (for any reason).
|
||||
window.wcTracks = window.wcTracks || {};
|
||||
window.wcTracks.recordEvent = window.wcTracks.recordEvent || ( () => {} );
|
||||
|
||||
// Handle the "Details" container toggle.
|
||||
$( '.woocommerce-order-attribution-details-toggle' )
|
||||
.on( 'click', ( e ) => {
|
||||
const $this = $( e.target ).closest( '.woocommerce-order-attribution-details-toggle');
|
||||
const $container = $this.closest( '.order-attribution-metabox' )
|
||||
.find( '.woocommerce-order-attribution-details-container' );
|
||||
let toggle = '';
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
$container.fadeToggle( 250 );
|
||||
$this.find( '.toggle-text' ).toggle();
|
||||
if ( $container.hasClass( 'closed' ) ) {
|
||||
$this.attr( 'aria-expanded', 'true' );
|
||||
toggle = 'opened';
|
||||
} else {
|
||||
$this.attr( 'aria-expanded', 'false' );
|
||||
toggle = 'closed';
|
||||
}
|
||||
$container.toggleClass( 'closed' );
|
||||
|
||||
window.wcTracks.recordEvent( 'order_attribution_details_toggle', {
|
||||
order_id: window.woocommerce_admin_meta_boxes.order_id,
|
||||
details: toggle
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
1
wp/wp-content/plugins/woocommerce/assets/js/admin/order-attribution-admin.min.js
vendored
Normal file
1
wp/wp-content/plugins/woocommerce/assets/js/admin/order-attribution-admin.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
jQuery(document).ready(e=>{"use strict";window.wcTracks=window.wcTracks||{},window.wcTracks.recordEvent=window.wcTracks.recordEvent||(()=>{}),e(".woocommerce-order-attribution-details-toggle").on("click",o=>{const t=e(o.target).closest(".woocommerce-order-attribution-details-toggle"),r=t.closest(".order-attribution-metabox").find(".woocommerce-order-attribution-details-container");let d="";o.preventDefault(),r.fadeToggle(250),t.find(".toggle-text").toggle(),r.hasClass("closed")?(t.attr("aria-expanded","true"),d="opened"):(t.attr("aria-expanded","false"),d="closed"),r.toggleClass("closed"),window.wcTracks.recordEvent("order_attribution_details_toggle",{order_id:window.woocommerce_admin_meta_boxes.order_id,details:d})})});
|
||||
@@ -103,6 +103,7 @@
|
||||
$( document.body ).on( 'wc_region_picker_update', this.onUpdateZoneRegionPicker );
|
||||
$( document.body ).on( 'wc_backbone_modal_next_response', this.onAddShippingMethodSubmitted );
|
||||
$( document.body ).on( 'wc_backbone_modal_before_remove', this.onCloseConfigureShippingMethod );
|
||||
$( document.body ).on( 'wc_backbone_modal_back_response', this.onConfigureShippingMethodBack );
|
||||
$( document.body ).on( 'change', '.wc-shipping-zone-method-selector select', this.onChangeShippingMethodSelector );
|
||||
$( document.body ).on( 'click', '.wc-shipping-zone-postcodes-toggle', this.onTogglePostcodes );
|
||||
$( document.body ).on( 'wc_backbone_modal_validation', { view: this }, this.validateFormArguments );
|
||||
@@ -344,6 +345,8 @@
|
||||
}
|
||||
});
|
||||
|
||||
shippingMethodView.highlightOnFocus( '.wc-shipping-modal-price' );
|
||||
|
||||
$( document.body ).trigger( 'init_tooltips' );
|
||||
},
|
||||
onConfigureShippingMethodSubmitted: function( event, target, posted_data ) {
|
||||
@@ -382,6 +385,11 @@
|
||||
);
|
||||
}
|
||||
},
|
||||
onConfigureShippingMethodBack: function( event, target ) {
|
||||
if ( 'wc-modal-shipping-method-settings' === target ) {
|
||||
shippingMethodView.onAddShippingMethod( event );
|
||||
}
|
||||
},
|
||||
showErrors: function( errors ) {
|
||||
var error_html = '<div id="woocommerce_errors" class="error notice is-dismissible">';
|
||||
|
||||
@@ -392,6 +400,12 @@
|
||||
|
||||
$( 'table.wc-shipping-zone-methods' ).before( error_html );
|
||||
},
|
||||
highlightOnFocus: function( query ) {
|
||||
const inputs = $( query );
|
||||
inputs.focus( function() {
|
||||
$( this ).select();
|
||||
} );
|
||||
},
|
||||
onAddShippingMethod: function( event ) {
|
||||
event.preventDefault();
|
||||
|
||||
@@ -403,6 +417,15 @@
|
||||
});
|
||||
|
||||
$( '.wc-shipping-zone-method-selector select' ).trigger( 'change' );
|
||||
|
||||
$('.wc-shipping-zone-method-input input').change( function() {
|
||||
const selected = $('.wc-shipping-zone-method-input input:checked');
|
||||
const id = selected.attr( 'id' );
|
||||
const description = $( `#${ id }-description` );
|
||||
const descriptions = $( '.wc-shipping-zone-method-input-help-text' );
|
||||
descriptions.css( 'display', 'none' );
|
||||
description.css( 'display', 'block' );
|
||||
});
|
||||
},
|
||||
/**
|
||||
* The settings HTML is controlled and built by the settings api, so in order to refactor the
|
||||
@@ -501,14 +524,15 @@
|
||||
return htmlContent.prop( 'outerHTML' );
|
||||
},
|
||||
replaceHTMLTables: function ( html ) {
|
||||
// Wrap the html content in a div
|
||||
const htmlContent = $( '<div>' + html + '</div>' );
|
||||
|
||||
// `<table class="form-table" />` elements added by the Settings API need to be removed.
|
||||
// Modern browsers won't interpret other table elements like `td` not in a `table`, so
|
||||
// Removing the `table` is sufficient.
|
||||
const htmlContent = $( html );
|
||||
const tables = htmlContent.find( 'table.form-table' );
|
||||
|
||||
tables.each( ( i ) => {
|
||||
const table = $( tables[ i ] );
|
||||
const innerTables = htmlContent.find( 'table.form-table' );
|
||||
innerTables.each( ( i ) => {
|
||||
const table = $( innerTables[ i ] );
|
||||
const div = $( '<div class="wc-shipping-zone-method-fields" />' );
|
||||
div.html( table.html() );
|
||||
table.replaceWith( div );
|
||||
@@ -520,7 +544,7 @@
|
||||
if ( 'wc-modal-add-shipping-method' === target ) {
|
||||
shippingMethodView.block();
|
||||
|
||||
$('#btn-next').html('<img alt="processing" src="images/wpspin_light.gif" class="waiting" />');
|
||||
$('#btn-next').addClass( 'is-busy' );
|
||||
|
||||
// Add method to zone via ajax call
|
||||
$.post( ajaxurl + ( ajaxurl.indexOf( '?' ) > 0 ? '&' : '?' ) + 'action=woocommerce_shipping_zone_add_method', {
|
||||
@@ -569,6 +593,8 @@
|
||||
status : 'new'
|
||||
}
|
||||
});
|
||||
|
||||
shippingMethodView.highlightOnFocus( '.wc-shipping-modal-price' );
|
||||
} else {
|
||||
shippingMethodView.model.trigger( 'change:methods' );
|
||||
shippingMethodView.model.trigger( 'saved:methods' );
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -136,11 +136,14 @@
|
||||
$tr.find( '.wc-shipping-zone-delete' ).on( 'click', { view: this }, this.onDeleteRow );
|
||||
},
|
||||
initRows: function() {
|
||||
const isEven = 0 !== ( $( 'tbody.wc-shipping-zone-rows tr' ).length % 2 );
|
||||
const tfoot = $( 'tfoot.wc-shipping-zone-rows-tfoot' );
|
||||
|
||||
// Stripe
|
||||
if ( 0 === ( $( 'tbody.wc-shipping-zone-rows tr' ).length % 2 ) ) {
|
||||
$table.find( 'tbody.wc-shipping-zone-rows' ).next( 'tbody' ).find( 'tr' ).addClass( 'odd' );
|
||||
if ( isEven ) {
|
||||
tfoot.find( 'tr' ).addClass( 'even' );
|
||||
} else {
|
||||
$table.find( 'tbody.wc-shipping-zone-rows' ).next( 'tbody' ).find( 'tr' ).removeClass( 'odd' );
|
||||
tfoot.find( 'tr' ).removeClass( 'even' );
|
||||
}
|
||||
// Tooltips
|
||||
$( '#tiptip_holder' ).removeAttr( 'style' );
|
||||
|
||||
@@ -1 +1 @@
|
||||
!function(e,n,i,o){e(function(){var t=e(".wc-shipping-zones"),s=e(".wc-shipping-zone-rows"),d=e(".wc-shipping-zone-save"),a=i.template("wc-shipping-zone-row"),r=i.template("wc-shipping-zone-row-blank"),l=Backbone.Model.extend({changes:{},logChanges:function(e){var n=this.changes||{};_.each(e,function(e,i){n[i]=_.extend(n[i]||{zone_id:i},e)}),this.changes=n,this.trigger("change:zones")},discardChanges:function(e){var n=this.changes||{},i=null,o=_.indexBy(this.get("zones"),"zone_id");n[e]&&n[e].zone_order!==undefined&&(i=n[e].zone_order),delete n[e],null!==i&&o[e]&&o[e].zone_order!==i&&(n[e]=_.extend(n[e]||{},{zone_id:e,zone_order:i})),this.changes=n,0===_.size(this.changes)&&p.clearUnloadConfirmation()},save:function(){_.size(this.changes)?e.post(o+(o.indexOf("?")>0?"&":"?")+"action=woocommerce_shipping_zones_save_changes",{wc_shipping_zones_nonce:n.wc_shipping_zones_nonce,changes:this.changes},this.onSaveResponse,"json"):h.trigger("saved:zones")},onSaveResponse:function(e,i){"success"===i&&(e.success?(h.set("zones",e.data.zones),h.trigger("change:zones"),h.changes={},h.trigger("saved:zones")):window.alert(n.strings.save_failed))}}),c=Backbone.View.extend({rowTemplate:a,initialize:function(){this.listenTo(this.model,"change:zones",this.setUnloadConfirmation),this.listenTo(this.model,"saved:zones",this.clearUnloadConfirmation),this.listenTo(this.model,"saved:zones",this.render),s.on("change",{view:this},this.updateModelOnChange),s.on("sortupdate",{view:this},this.updateModelOnSort),e(window).on("beforeunload",{view:this},this.unloadConfirmation),e(document.body).on("click",".wc-shipping-zone-add",{view:this},this.onAddNewRow)},onAddNewRow:function(){var n=e(this);window.location.href=n.attr("href")},block:function(){e(this.el).block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},unblock:function(){e(this.el).unblock()},render:function(){var n=_.indexBy(this.model.get("zones"),"zone_id"),i=this;i.$el.empty(),i.unblock(),_.size(n)?(n=_(n).chain().sortBy(function(e){return parseInt(e.zone_id,10)}).sortBy(function(e){return parseInt(e.zone_order,10)}).value(),e.each(n,function(e,n){i.renderRow(n)})):i.$el.append(r),i.initRows()},renderRow:function(e){this.$el.append(this.rowTemplate(e)),this.initRow(e)},initRow:function(e){var n=this.$el.find('tr[data-id="'+e.zone_id+'"]');this.renderShippingMethods(e.zone_id,e.shipping_methods),n.find(".wc-shipping-zone-delete").on("click",{view:this},this.onDeleteRow)},initRows:function(){0==e("tbody.wc-shipping-zone-rows tr").length%2?t.find("tbody.wc-shipping-zone-rows").next("tbody").find("tr").addClass("odd"):t.find("tbody.wc-shipping-zone-rows").next("tbody").find("tr").removeClass("odd"),e("#tiptip_holder").removeAttr("style"),e("#tiptip_arrow").removeAttr("style"),e(".tips").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:50})},renderShippingMethods:function(i,o){var t=e('.wc-shipping-zones tr[data-id="'+i+'"]').find(".wc-shipping-zone-methods ul");t.find(".wc-shipping-zone-method").remove(),_.size(o)?(o=_.sortBy(o,function(e){return parseInt(e.method_order,10)}),_.each(o,function(e){var n="method_disabled";"yes"===e.enabled&&(n="method_enabled"),t.append('<li class="wc-shipping-zone-method '+n+'">'+e.title+"</li>")})):t.append('<li class="wc-shipping-zone-method">'+n.strings.no_shipping_methods_offered+"</li>")},onDeleteRow:function(i){var o=i.data.view.model,t=_.indexBy(o.get("zones"),"zone_id"),s={},d=e(this).closest("tr").data("id");i.preventDefault(),window.confirm(n.strings.delete_confirmation_msg)&&t[d]&&(delete t[d],s[d]=_.extend(s[d]||{},{deleted:"deleted"}),o.set("zones",t),o.logChanges(s),i.data.view.block(),i.data.view.model.save())},setUnloadConfirmation:function(){this.needsUnloadConfirm=!0,d.prop("disabled",!1)},clearUnloadConfirmation:function(){this.needsUnloadConfirm=!1,d.prop("disabled",!0)},unloadConfirmation:function(e){if(e.data.view.needsUnloadConfirm)return e.returnValue=n.strings.unload_confirmation_msg,window.event.returnValue=n.strings.unload_confirmation_msg,n.strings.unload_confirmation_msg},updateModelOnChange:function(n){var i=n.data.view.model,o=e(n.target),t=o.closest("tr").data("id"),s=o.data("attribute"),d=o.val(),a=_.indexBy(i.get("zones"),"zone_id"),r={};a[t]&&a[t][s]===d||(r[t]={},r[t][s]=d),i.logChanges(r)},updateModelOnSort:function(n){var i=n.data.view.model,o=_.indexBy(i.get("zones"),"zone_id"),t=e("tbody.wc-shipping-zone-rows tr"),s={};_.each(t,function(n){var i=e(n).data("id"),t=null,d=parseInt(e(n).index(),10);o[i]&&(t=parseInt(o[i].zone_order,10)),t!==d&&(s[i]=_.extend(s[i]||{},{zone_order:d}))}),_.size(s)&&(i.logChanges(s),n.data.view.block(),n.data.view.model.save())}}),h=new l({zones:n.zones}),p=new c({model:h,el:s});p.render(),s.sortable({items:"tr",cursor:"move",axis:"y",handle:"td.wc-shipping-zone-sort",scrollSensitivity:40})})}(jQuery,shippingZonesLocalizeScript,wp,ajaxurl);
|
||||
!function(e,n,i,o){e(function(){e(".wc-shipping-zones");var t=e(".wc-shipping-zone-rows"),s=e(".wc-shipping-zone-save"),a=i.template("wc-shipping-zone-row"),d=i.template("wc-shipping-zone-row-blank"),r=Backbone.Model.extend({changes:{},logChanges:function(e){var n=this.changes||{};_.each(e,function(e,i){n[i]=_.extend(n[i]||{zone_id:i},e)}),this.changes=n,this.trigger("change:zones")},discardChanges:function(e){var n=this.changes||{},i=null,o=_.indexBy(this.get("zones"),"zone_id");n[e]&&n[e].zone_order!==undefined&&(i=n[e].zone_order),delete n[e],null!==i&&o[e]&&o[e].zone_order!==i&&(n[e]=_.extend(n[e]||{},{zone_id:e,zone_order:i})),this.changes=n,0===_.size(this.changes)&&h.clearUnloadConfirmation()},save:function(){_.size(this.changes)?e.post(o+(o.indexOf("?")>0?"&":"?")+"action=woocommerce_shipping_zones_save_changes",{wc_shipping_zones_nonce:n.wc_shipping_zones_nonce,changes:this.changes},this.onSaveResponse,"json"):c.trigger("saved:zones")},onSaveResponse:function(e,i){"success"===i&&(e.success?(c.set("zones",e.data.zones),c.trigger("change:zones"),c.changes={},c.trigger("saved:zones")):window.alert(n.strings.save_failed))}}),l=Backbone.View.extend({rowTemplate:a,initialize:function(){this.listenTo(this.model,"change:zones",this.setUnloadConfirmation),this.listenTo(this.model,"saved:zones",this.clearUnloadConfirmation),this.listenTo(this.model,"saved:zones",this.render),t.on("change",{view:this},this.updateModelOnChange),t.on("sortupdate",{view:this},this.updateModelOnSort),e(window).on("beforeunload",{view:this},this.unloadConfirmation),e(document.body).on("click",".wc-shipping-zone-add",{view:this},this.onAddNewRow)},onAddNewRow:function(){var n=e(this);window.location.href=n.attr("href")},block:function(){e(this.el).block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},unblock:function(){e(this.el).unblock()},render:function(){var n=_.indexBy(this.model.get("zones"),"zone_id"),i=this;i.$el.empty(),i.unblock(),_.size(n)?(n=_(n).chain().sortBy(function(e){return parseInt(e.zone_id,10)}).sortBy(function(e){return parseInt(e.zone_order,10)}).value(),e.each(n,function(e,n){i.renderRow(n)})):i.$el.append(d),i.initRows()},renderRow:function(e){this.$el.append(this.rowTemplate(e)),this.initRow(e)},initRow:function(e){var n=this.$el.find('tr[data-id="'+e.zone_id+'"]');this.renderShippingMethods(e.zone_id,e.shipping_methods),n.find(".wc-shipping-zone-delete").on("click",{view:this},this.onDeleteRow)},initRows:function(){const n=0!=e("tbody.wc-shipping-zone-rows tr").length%2,i=e("tfoot.wc-shipping-zone-rows-tfoot");n?i.find("tr").addClass("even"):i.find("tr").removeClass("even"),e("#tiptip_holder").removeAttr("style"),e("#tiptip_arrow").removeAttr("style"),e(".tips").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:50})},renderShippingMethods:function(i,o){var t=e('.wc-shipping-zones tr[data-id="'+i+'"]').find(".wc-shipping-zone-methods ul");t.find(".wc-shipping-zone-method").remove(),_.size(o)?(o=_.sortBy(o,function(e){return parseInt(e.method_order,10)}),_.each(o,function(e){var n="method_disabled";"yes"===e.enabled&&(n="method_enabled"),t.append('<li class="wc-shipping-zone-method '+n+'">'+e.title+"</li>")})):t.append('<li class="wc-shipping-zone-method">'+n.strings.no_shipping_methods_offered+"</li>")},onDeleteRow:function(i){var o=i.data.view.model,t=_.indexBy(o.get("zones"),"zone_id"),s={},a=e(this).closest("tr").data("id");i.preventDefault(),window.confirm(n.strings.delete_confirmation_msg)&&t[a]&&(delete t[a],s[a]=_.extend(s[a]||{},{deleted:"deleted"}),o.set("zones",t),o.logChanges(s),i.data.view.block(),i.data.view.model.save())},setUnloadConfirmation:function(){this.needsUnloadConfirm=!0,s.prop("disabled",!1)},clearUnloadConfirmation:function(){this.needsUnloadConfirm=!1,s.prop("disabled",!0)},unloadConfirmation:function(e){if(e.data.view.needsUnloadConfirm)return e.returnValue=n.strings.unload_confirmation_msg,window.event.returnValue=n.strings.unload_confirmation_msg,n.strings.unload_confirmation_msg},updateModelOnChange:function(n){var i=n.data.view.model,o=e(n.target),t=o.closest("tr").data("id"),s=o.data("attribute"),a=o.val(),d=_.indexBy(i.get("zones"),"zone_id"),r={};d[t]&&d[t][s]===a||(r[t]={},r[t][s]=a),i.logChanges(r)},updateModelOnSort:function(n){var i=n.data.view.model,o=_.indexBy(i.get("zones"),"zone_id"),t=e("tbody.wc-shipping-zone-rows tr"),s={};_.each(t,function(n){var i=e(n).data("id"),t=null,a=parseInt(e(n).index(),10);o[i]&&(t=parseInt(o[i].zone_order,10)),t!==a&&(s[i]=_.extend(s[i]||{},{zone_order:a}))}),_.size(s)&&(i.logChanges(s),n.data.view.block(),n.data.view.model.save())}}),c=new r({zones:n.zones}),h=new l({model:c,el:t});h.render(),t.sortable({items:"tr",cursor:"move",axis:"y",handle:"td.wc-shipping-zone-sort",scrollSensitivity:40})})}(jQuery,shippingZonesLocalizeScript,wp,ajaxurl);
|
||||
@@ -720,12 +720,16 @@
|
||||
});
|
||||
}
|
||||
} else { // FADE:
|
||||
// if (!touch) calls slider.wrapup() on fade animation end; if (touch) calls slider.wrapup() immediately
|
||||
if (!touch) {
|
||||
slider.slides.eq(slider.currentSlide).css({"zIndex": 1}).animate({"opacity": 0}, slider.vars.animationSpeed, slider.vars.easing);
|
||||
slider.slides.eq(target).css({"zIndex": 2}).animate({"opacity": 1}, slider.vars.animationSpeed, slider.vars.easing, slider.wrapup);
|
||||
} else {
|
||||
slider.slides.eq(slider.currentSlide).css({ "opacity": 0, "zIndex": 1 });
|
||||
slider.slides.eq(target).css({ "opacity": 1, "zIndex": 2 });
|
||||
slider.slides.eq(slider.currentSlide).off("transitionend");
|
||||
slider.slides.eq(target).off("transitionend").on("transitionend", slider.wrapup);
|
||||
}
|
||||
|
||||
slider.slides.eq(slider.currentSlide).css({ "opacity": 0, "zIndex": 1 });
|
||||
slider.slides.eq(target).css({ "opacity": 1, "zIndex": 2 });
|
||||
|
||||
if (touch) {
|
||||
slider.wrapup(dimension);
|
||||
}
|
||||
}
|
||||
@@ -896,12 +900,15 @@
|
||||
}
|
||||
if (type === "init") {
|
||||
if (!touch) {
|
||||
//slider.slides.eq(slider.currentSlide).fadeIn(slider.vars.animationSpeed, slider.vars.easing);
|
||||
// Every "opacity" change before outerWidth() does NOT get animated; every "opacity" change after outerWidth() becomes a fadeIn
|
||||
if (slider.vars.fadeFirstSlide == false) {
|
||||
slider.slides.css({ "opacity": 0, "display": "block", "zIndex": 1 }).eq(slider.currentSlide).css({"zIndex": 2}).css({"opacity": 1});
|
||||
slider.slides.outerWidth();
|
||||
} else {
|
||||
slider.slides.css({ "opacity": 0, "display": "block", "zIndex": 1 }).eq(slider.currentSlide).css({"zIndex": 2}).animate({"opacity": 1},slider.vars.animationSpeed,slider.vars.easing);
|
||||
slider.slides.css({ "opacity": 0, "display": "block", "zIndex": 1 }).outerWidth();
|
||||
slider.slides.eq(slider.currentSlide).css({"zIndex": 2}).css({"opacity": 1});
|
||||
}
|
||||
slider.slides.css({ "transition": "opacity " + slider.vars.animationSpeed / 1000 + "s " + easing });
|
||||
} else {
|
||||
slider.slides.css({ "opacity": 0, "display": "block", "transition": "opacity " + slider.vars.animationSpeed / 1000 + "s ease", "zIndex": 1 }).eq(slider.currentSlide).css({ "opacity": 1, "zIndex": 2});
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,6 +1,5 @@
|
||||
/* global wc_cart_params */
|
||||
jQuery( function( $ ) {
|
||||
|
||||
jQuery( function ( $ ) {
|
||||
// wc_cart_params is required to continue, ensure the object exists
|
||||
if ( typeof wc_cart_params === 'undefined' ) {
|
||||
return false;
|
||||
@@ -14,11 +13,10 @@ jQuery( function( $ ) {
|
||||
* @param {String} endpoint The AJAX Endpoint
|
||||
* @return {String} The URL to use for the request
|
||||
*/
|
||||
var get_url = function( endpoint ) {
|
||||
return wc_cart_params.wc_ajax_url.toString().replace(
|
||||
'%%endpoint%%',
|
||||
endpoint
|
||||
);
|
||||
var get_url = function ( endpoint ) {
|
||||
return wc_cart_params.wc_ajax_url
|
||||
.toString()
|
||||
.replace( '%%endpoint%%', endpoint );
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -27,8 +25,10 @@ jQuery( function( $ ) {
|
||||
* @param {JQuery Object} $node
|
||||
* @return {bool} True if the DOM Element is UI Blocked, false if not.
|
||||
*/
|
||||
var is_blocked = function( $node ) {
|
||||
return $node.is( '.processing' ) || $node.parents( '.processing' ).length;
|
||||
var is_blocked = function ( $node ) {
|
||||
return (
|
||||
$node.is( '.processing' ) || $node.parents( '.processing' ).length
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -36,14 +36,14 @@ jQuery( function( $ ) {
|
||||
*
|
||||
* @param {JQuery Object} $node
|
||||
*/
|
||||
var block = function( $node ) {
|
||||
var block = function ( $node ) {
|
||||
if ( ! is_blocked( $node ) ) {
|
||||
$node.addClass( 'processing' ).block( {
|
||||
message: null,
|
||||
overlayCSS: {
|
||||
background: '#fff',
|
||||
opacity: 0.6
|
||||
}
|
||||
opacity: 0.6,
|
||||
},
|
||||
} );
|
||||
}
|
||||
};
|
||||
@@ -53,7 +53,7 @@ jQuery( function( $ ) {
|
||||
*
|
||||
* @param {JQuery Object} $node
|
||||
*/
|
||||
var unblock = function( $node ) {
|
||||
var unblock = function ( $node ) {
|
||||
$node.removeClass( 'processing' ).unblock();
|
||||
};
|
||||
|
||||
@@ -62,11 +62,11 @@ jQuery( function( $ ) {
|
||||
*
|
||||
* @param {JQuery Object} $notices
|
||||
*/
|
||||
var remove_duplicate_notices = function( $notices ) {
|
||||
var seen = new Set();
|
||||
var remove_duplicate_notices = function ( $notices ) {
|
||||
var seen = new Set();
|
||||
var deduplicated_notices = [];
|
||||
|
||||
$notices.each( function() {
|
||||
$notices.each( function () {
|
||||
const text = $( this ).text();
|
||||
|
||||
if ( ! seen.has( text ) ) {
|
||||
@@ -84,11 +84,16 @@ jQuery( function( $ ) {
|
||||
* @param {String} html_str The HTML string with which to replace the div.
|
||||
* @param {bool} preserve_notices Should notices be kept? False by default.
|
||||
*/
|
||||
var update_wc_div = function( html_str, preserve_notices ) {
|
||||
var $html = $.parseHTML( html_str );
|
||||
var $new_form = $( '.woocommerce-cart-form', $html );
|
||||
var update_wc_div = function ( html_str, preserve_notices ) {
|
||||
var $html = $.parseHTML( html_str );
|
||||
var $new_form = $( '.woocommerce-cart-form', $html );
|
||||
var $new_totals = $( '.cart_totals', $html );
|
||||
var $notices = remove_duplicate_notices( $( '.woocommerce-error, .woocommerce-message, .woocommerce-info', $html ) );
|
||||
var $notices = remove_duplicate_notices(
|
||||
$(
|
||||
'.woocommerce-error, .woocommerce-message, .woocommerce-info, .is-error, .is-info, .is-success',
|
||||
$html
|
||||
)
|
||||
);
|
||||
|
||||
// No form, cannot do this.
|
||||
if ( $( '.woocommerce-cart-form' ).length === 0 ) {
|
||||
@@ -98,7 +103,9 @@ jQuery( function( $ ) {
|
||||
|
||||
// Remove errors
|
||||
if ( ! preserve_notices ) {
|
||||
$( '.woocommerce-error, .woocommerce-message, .woocommerce-info' ).remove();
|
||||
$(
|
||||
'.woocommerce-error, .woocommerce-message, .woocommerce-info, .is-error, .is-info, .is-success'
|
||||
).remove();
|
||||
}
|
||||
|
||||
if ( $new_form.length === 0 ) {
|
||||
@@ -109,8 +116,12 @@ jQuery( function( $ ) {
|
||||
}
|
||||
|
||||
// No items to display now! Replace all cart content.
|
||||
var $cart_html = $( '.wc-empty-cart-message', $html ).closest( '.woocommerce' );
|
||||
$( '.woocommerce-cart-form__contents' ).closest( '.woocommerce' ).replaceWith( $cart_html );
|
||||
var $cart_html = $( '.wc-empty-cart-message', $html ).closest(
|
||||
'.woocommerce'
|
||||
);
|
||||
$( '.woocommerce-cart-form__contents' )
|
||||
.closest( '.woocommerce' )
|
||||
.replaceWith( $cart_html );
|
||||
|
||||
// Display errors
|
||||
if ( $notices.length > 0 ) {
|
||||
@@ -126,7 +137,9 @@ jQuery( function( $ ) {
|
||||
}
|
||||
|
||||
$( '.woocommerce-cart-form' ).replaceWith( $new_form );
|
||||
$( '.woocommerce-cart-form' ).find( ':input[name="update_cart"]' ).prop( 'disabled', true );
|
||||
$( '.woocommerce-cart-form' )
|
||||
.find( ':input[name="update_cart"]' )
|
||||
.prop( 'disabled', true );
|
||||
|
||||
if ( $notices.length > 0 ) {
|
||||
show_notice( $notices );
|
||||
@@ -143,7 +156,7 @@ jQuery( function( $ ) {
|
||||
*
|
||||
* @param {String} html_str The HTML string with which to replace the div.
|
||||
*/
|
||||
var update_cart_totals_div = function( html_str ) {
|
||||
var update_cart_totals_div = function ( html_str ) {
|
||||
$( '.cart_totals' ).replaceWith( html_str );
|
||||
$( document.body ).trigger( 'updated_cart_totals' );
|
||||
};
|
||||
@@ -153,29 +166,30 @@ jQuery( function( $ ) {
|
||||
*
|
||||
* @param {Object} The Notice HTML Element in string or object form.
|
||||
*/
|
||||
var show_notice = function( html_element, $target ) {
|
||||
var show_notice = function ( html_element, $target ) {
|
||||
if ( ! $target ) {
|
||||
$target = $( '.woocommerce-notices-wrapper:first' ) ||
|
||||
$target =
|
||||
$( '.woocommerce-notices-wrapper:first' ) ||
|
||||
$( '.wc-empty-cart-message' ).closest( '.woocommerce' ) ||
|
||||
$( '.woocommerce-cart-form' );
|
||||
}
|
||||
$target.prepend( html_element );
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Object to handle AJAX calls for cart shipping changes.
|
||||
*/
|
||||
var cart_shipping = {
|
||||
|
||||
/**
|
||||
* Initialize event handlers and UI state.
|
||||
*/
|
||||
init: function( cart ) {
|
||||
this.cart = cart;
|
||||
this.toggle_shipping = this.toggle_shipping.bind( this );
|
||||
this.shipping_method_selected = this.shipping_method_selected.bind( this );
|
||||
this.shipping_calculator_submit = this.shipping_calculator_submit.bind( this );
|
||||
init: function ( cart ) {
|
||||
this.cart = cart;
|
||||
this.toggle_shipping = this.toggle_shipping.bind( this );
|
||||
this.shipping_method_selected =
|
||||
this.shipping_method_selected.bind( this );
|
||||
this.shipping_calculator_submit =
|
||||
this.shipping_calculator_submit.bind( this );
|
||||
|
||||
$( document ).on(
|
||||
'click',
|
||||
@@ -199,9 +213,11 @@ jQuery( function( $ ) {
|
||||
/**
|
||||
* Toggle Shipping Calculator panel
|
||||
*/
|
||||
toggle_shipping: function() {
|
||||
toggle_shipping: function () {
|
||||
$( '.shipping-calculator-form' ).slideToggle( 'slow' );
|
||||
$( 'select.country_to_state, input.country_to_state' ).trigger( 'change' );
|
||||
$( 'select.country_to_state, input.country_to_state' ).trigger(
|
||||
'change'
|
||||
);
|
||||
$( document.body ).trigger( 'country_to_state_changed' ); // Trigger select2 to load.
|
||||
return false;
|
||||
},
|
||||
@@ -209,11 +225,13 @@ jQuery( function( $ ) {
|
||||
/**
|
||||
* Handles when a shipping method is selected.
|
||||
*/
|
||||
shipping_method_selected: function() {
|
||||
shipping_method_selected: function () {
|
||||
var shipping_methods = {};
|
||||
|
||||
// eslint-disable-next-line max-len
|
||||
$( 'select.shipping_method, :input[name^=shipping_method][type=radio]:checked, :input[name^=shipping_method][type=hidden]' ).each( function() {
|
||||
$(
|
||||
'select.shipping_method, :input[name^=shipping_method][type=radio]:checked, :input[name^=shipping_method][type=hidden]'
|
||||
).each( function () {
|
||||
shipping_methods[ $( this ).data( 'index' ) ] = $( this ).val();
|
||||
} );
|
||||
|
||||
@@ -221,21 +239,21 @@ jQuery( function( $ ) {
|
||||
|
||||
var data = {
|
||||
security: wc_cart_params.update_shipping_method_nonce,
|
||||
shipping_method: shipping_methods
|
||||
shipping_method: shipping_methods,
|
||||
};
|
||||
|
||||
$.ajax( {
|
||||
type: 'post',
|
||||
url: get_url( 'update_shipping_method' ),
|
||||
data: data,
|
||||
type: 'post',
|
||||
url: get_url( 'update_shipping_method' ),
|
||||
data: data,
|
||||
dataType: 'html',
|
||||
success: function( response ) {
|
||||
success: function ( response ) {
|
||||
update_cart_totals_div( response );
|
||||
},
|
||||
complete: function() {
|
||||
complete: function () {
|
||||
unblock( $( 'div.cart_totals' ) );
|
||||
$( document.body ).trigger( 'updated_shipping_method' );
|
||||
}
|
||||
},
|
||||
} );
|
||||
},
|
||||
|
||||
@@ -244,7 +262,7 @@ jQuery( function( $ ) {
|
||||
*
|
||||
* @param {Object} evt The JQuery event.
|
||||
*/
|
||||
shipping_calculator_submit: function( evt ) {
|
||||
shipping_calculator_submit: function ( evt ) {
|
||||
evt.preventDefault();
|
||||
|
||||
var $form = $( evt.currentTarget );
|
||||
@@ -253,26 +271,27 @@ jQuery( function( $ ) {
|
||||
block( $form );
|
||||
|
||||
// Provide the submit button value because wc-form-handler expects it.
|
||||
$( '<input />' ).attr( 'type', 'hidden' )
|
||||
.attr( 'name', 'calc_shipping' )
|
||||
.attr( 'value', 'x' )
|
||||
.appendTo( $form );
|
||||
$( '<input />' )
|
||||
.attr( 'type', 'hidden' )
|
||||
.attr( 'name', 'calc_shipping' )
|
||||
.attr( 'value', 'x' )
|
||||
.appendTo( $form );
|
||||
|
||||
// Make call to actual form post URL.
|
||||
$.ajax( {
|
||||
type: $form.attr( 'method' ),
|
||||
url: $form.attr( 'action' ),
|
||||
data: $form.serialize(),
|
||||
type: $form.attr( 'method' ),
|
||||
url: $form.attr( 'action' ),
|
||||
data: $form.serialize(),
|
||||
dataType: 'html',
|
||||
success: function( response ) {
|
||||
success: function ( response ) {
|
||||
update_wc_div( response );
|
||||
},
|
||||
complete: function() {
|
||||
complete: function () {
|
||||
unblock( $form );
|
||||
unblock( $( 'div.cart_totals' ) );
|
||||
}
|
||||
},
|
||||
} );
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -282,64 +301,78 @@ jQuery( function( $ ) {
|
||||
/**
|
||||
* Initialize cart UI events.
|
||||
*/
|
||||
init: function() {
|
||||
this.update_cart_totals = this.update_cart_totals.bind( this );
|
||||
this.input_keypress = this.input_keypress.bind( this );
|
||||
this.cart_submit = this.cart_submit.bind( this );
|
||||
this.submit_click = this.submit_click.bind( this );
|
||||
this.apply_coupon = this.apply_coupon.bind( this );
|
||||
this.remove_coupon_clicked = this.remove_coupon_clicked.bind( this );
|
||||
this.quantity_update = this.quantity_update.bind( this );
|
||||
this.item_remove_clicked = this.item_remove_clicked.bind( this );
|
||||
this.item_restore_clicked = this.item_restore_clicked.bind( this );
|
||||
this.update_cart = this.update_cart.bind( this );
|
||||
init: function () {
|
||||
this.update_cart_totals = this.update_cart_totals.bind( this );
|
||||
this.input_keypress = this.input_keypress.bind( this );
|
||||
this.cart_submit = this.cart_submit.bind( this );
|
||||
this.submit_click = this.submit_click.bind( this );
|
||||
this.apply_coupon = this.apply_coupon.bind( this );
|
||||
this.remove_coupon_clicked =
|
||||
this.remove_coupon_clicked.bind( this );
|
||||
this.quantity_update = this.quantity_update.bind( this );
|
||||
this.item_remove_clicked = this.item_remove_clicked.bind( this );
|
||||
this.item_restore_clicked = this.item_restore_clicked.bind( this );
|
||||
this.update_cart = this.update_cart.bind( this );
|
||||
|
||||
$( document ).on(
|
||||
'wc_update_cart added_to_cart',
|
||||
function() { cart.update_cart.apply( cart, [].slice.call( arguments, 1 ) ); } );
|
||||
$( document ).on( 'wc_update_cart added_to_cart', function () {
|
||||
cart.update_cart.apply( cart, [].slice.call( arguments, 1 ) );
|
||||
} );
|
||||
$( document ).on(
|
||||
'click',
|
||||
'.woocommerce-cart-form :input[type=submit]',
|
||||
this.submit_click );
|
||||
this.submit_click
|
||||
);
|
||||
$( document ).on(
|
||||
'keypress',
|
||||
'.woocommerce-cart-form :input[type=number]',
|
||||
this.input_keypress );
|
||||
this.input_keypress
|
||||
);
|
||||
$( document ).on(
|
||||
'submit',
|
||||
'.woocommerce-cart-form',
|
||||
this.cart_submit );
|
||||
this.cart_submit
|
||||
);
|
||||
$( document ).on(
|
||||
'click',
|
||||
'a.woocommerce-remove-coupon',
|
||||
this.remove_coupon_clicked );
|
||||
this.remove_coupon_clicked
|
||||
);
|
||||
$( document ).on(
|
||||
'click',
|
||||
'.woocommerce-cart-form .product-remove > a',
|
||||
this.item_remove_clicked );
|
||||
this.item_remove_clicked
|
||||
);
|
||||
$( document ).on(
|
||||
'click',
|
||||
'.woocommerce-cart .restore-item',
|
||||
this.item_restore_clicked );
|
||||
this.item_restore_clicked
|
||||
);
|
||||
$( document ).on(
|
||||
'change input',
|
||||
'.woocommerce-cart-form .cart_item :input',
|
||||
this.input_changed );
|
||||
this.input_changed
|
||||
);
|
||||
|
||||
$( '.woocommerce-cart-form :input[name="update_cart"]' ).prop( 'disabled', true );
|
||||
$( '.woocommerce-cart-form :input[name="update_cart"]' ).prop(
|
||||
'disabled',
|
||||
true
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* After an input is changed, enable the update cart button.
|
||||
*/
|
||||
input_changed: function() {
|
||||
$( '.woocommerce-cart-form :input[name="update_cart"]' ).prop( 'disabled', false );
|
||||
input_changed: function () {
|
||||
$( '.woocommerce-cart-form :input[name="update_cart"]' ).prop(
|
||||
'disabled',
|
||||
false
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Update entire cart via ajax.
|
||||
*/
|
||||
update_cart: function( preserve_notices ) {
|
||||
update_cart: function ( preserve_notices ) {
|
||||
var $form = $( '.woocommerce-cart-form' );
|
||||
|
||||
block( $form );
|
||||
@@ -347,36 +380,36 @@ jQuery( function( $ ) {
|
||||
|
||||
// Make call to actual form post URL.
|
||||
$.ajax( {
|
||||
type: $form.attr( 'method' ),
|
||||
url: $form.attr( 'action' ),
|
||||
data: $form.serialize(),
|
||||
type: $form.attr( 'method' ),
|
||||
url: $form.attr( 'action' ),
|
||||
data: $form.serialize(),
|
||||
dataType: 'html',
|
||||
success: function( response ) {
|
||||
success: function ( response ) {
|
||||
update_wc_div( response, preserve_notices );
|
||||
},
|
||||
complete: function() {
|
||||
complete: function () {
|
||||
unblock( $form );
|
||||
unblock( $( 'div.cart_totals' ) );
|
||||
$.scroll_to_notices( $( '[role="alert"]' ) );
|
||||
}
|
||||
},
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Update the cart after something has changed.
|
||||
*/
|
||||
update_cart_totals: function() {
|
||||
update_cart_totals: function () {
|
||||
block( $( 'div.cart_totals' ) );
|
||||
|
||||
$.ajax( {
|
||||
url: get_url( 'get_cart_totals' ),
|
||||
url: get_url( 'get_cart_totals' ),
|
||||
dataType: 'html',
|
||||
success: function( response ) {
|
||||
success: function ( response ) {
|
||||
update_cart_totals_div( response );
|
||||
},
|
||||
complete: function() {
|
||||
complete: function () {
|
||||
unblock( $( 'div.cart_totals' ) );
|
||||
}
|
||||
},
|
||||
} );
|
||||
},
|
||||
|
||||
@@ -390,19 +423,18 @@ jQuery( function( $ ) {
|
||||
* For us, that is the Apply Coupon button. This is required
|
||||
* to catch the event before that happens.
|
||||
*/
|
||||
input_keypress: function( evt ) {
|
||||
|
||||
input_keypress: function ( evt ) {
|
||||
// Catch the enter key and don't let it submit the form.
|
||||
if ( 13 === evt.keyCode ) {
|
||||
var $form = $( evt.currentTarget ).parents( 'form' );
|
||||
|
||||
try {
|
||||
// If there are no validation errors, handle the submit.
|
||||
if ( $form[0].checkValidity() ) {
|
||||
if ( $form[ 0 ].checkValidity() ) {
|
||||
evt.preventDefault();
|
||||
this.cart_submit( evt );
|
||||
}
|
||||
} catch( err ) {
|
||||
} catch ( err ) {
|
||||
evt.preventDefault();
|
||||
this.cart_submit( evt );
|
||||
}
|
||||
@@ -414,10 +446,10 @@ jQuery( function( $ ) {
|
||||
*
|
||||
* @param {Object} evt The JQuery event
|
||||
*/
|
||||
cart_submit: function( evt ) {
|
||||
var $submit = $( document.activeElement ),
|
||||
cart_submit: function ( evt ) {
|
||||
var $submit = $( document.activeElement ),
|
||||
$clicked = $( ':input[type=submit][clicked=true]' ),
|
||||
$form = $( evt.currentTarget );
|
||||
$form = $( evt.currentTarget );
|
||||
|
||||
// For submit events, currentTarget is form.
|
||||
// For keypress events, currentTarget is input.
|
||||
@@ -425,7 +457,9 @@ jQuery( function( $ ) {
|
||||
$form = $( evt.currentTarget ).parents( 'form' );
|
||||
}
|
||||
|
||||
if ( 0 === $form.find( '.woocommerce-cart-form__contents' ).length ) {
|
||||
if (
|
||||
0 === $form.find( '.woocommerce-cart-form__contents' ).length
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -433,11 +467,16 @@ jQuery( function( $ ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $clicked.is( ':input[name="update_cart"]' ) || $submit.is( 'input.qty' ) ) {
|
||||
if (
|
||||
$clicked.is( ':input[name="update_cart"]' ) ||
|
||||
$submit.is( 'input.qty' )
|
||||
) {
|
||||
evt.preventDefault();
|
||||
this.quantity_update( $form );
|
||||
|
||||
} else if ( $clicked.is( ':input[name="apply_coupon"]' ) || $submit.is( '#coupon_code' ) ) {
|
||||
} else if (
|
||||
$clicked.is( ':input[name="apply_coupon"]' ) ||
|
||||
$submit.is( '#coupon_code' )
|
||||
) {
|
||||
evt.preventDefault();
|
||||
this.apply_coupon( $form );
|
||||
}
|
||||
@@ -448,8 +487,11 @@ jQuery( function( $ ) {
|
||||
*
|
||||
* @param {Object} evt The JQuery event
|
||||
*/
|
||||
submit_click: function( evt ) {
|
||||
$( ':input[type=submit]', $( evt.target ).parents( 'form' ) ).removeAttr( 'clicked' );
|
||||
submit_click: function ( evt ) {
|
||||
$(
|
||||
':input[type=submit]',
|
||||
$( evt.target ).parents( 'form' )
|
||||
).removeAttr( 'clicked' );
|
||||
$( evt.target ).attr( 'clicked', 'true' );
|
||||
},
|
||||
|
||||
@@ -458,7 +500,7 @@ jQuery( function( $ ) {
|
||||
*
|
||||
* @param {JQuery Object} $form The cart form.
|
||||
*/
|
||||
apply_coupon: function( $form ) {
|
||||
apply_coupon: function ( $form ) {
|
||||
block( $form );
|
||||
|
||||
var cart = this;
|
||||
@@ -467,24 +509,28 @@ jQuery( function( $ ) {
|
||||
|
||||
var data = {
|
||||
security: wc_cart_params.apply_coupon_nonce,
|
||||
coupon_code: coupon_code
|
||||
coupon_code: coupon_code,
|
||||
};
|
||||
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
url: get_url( 'apply_coupon' ),
|
||||
data: data,
|
||||
type: 'POST',
|
||||
url: get_url( 'apply_coupon' ),
|
||||
data: data,
|
||||
dataType: 'html',
|
||||
success: function( response ) {
|
||||
$( '.woocommerce-error, .woocommerce-message, .woocommerce-info' ).remove();
|
||||
success: function ( response ) {
|
||||
$(
|
||||
'.woocommerce-error, .woocommerce-message, .woocommerce-info, .is-error, .is-info, .is-success'
|
||||
).remove();
|
||||
show_notice( response );
|
||||
$( document.body ).trigger( 'applied_coupon', [ coupon_code ] );
|
||||
$( document.body ).trigger( 'applied_coupon', [
|
||||
coupon_code,
|
||||
] );
|
||||
},
|
||||
complete: function() {
|
||||
complete: function () {
|
||||
unblock( $form );
|
||||
$text_field.val( '' );
|
||||
cart.update_cart( true );
|
||||
}
|
||||
},
|
||||
} );
|
||||
},
|
||||
|
||||
@@ -493,34 +539,36 @@ jQuery( function( $ ) {
|
||||
*
|
||||
* @param {Object} evt The JQuery event
|
||||
*/
|
||||
remove_coupon_clicked: function( evt ) {
|
||||
remove_coupon_clicked: function ( evt ) {
|
||||
evt.preventDefault();
|
||||
|
||||
var cart = this;
|
||||
var cart = this;
|
||||
var $wrapper = $( evt.currentTarget ).closest( '.cart_totals' );
|
||||
var coupon = $( evt.currentTarget ).attr( 'data-coupon' );
|
||||
var coupon = $( evt.currentTarget ).attr( 'data-coupon' );
|
||||
|
||||
block( $wrapper );
|
||||
|
||||
var data = {
|
||||
security: wc_cart_params.remove_coupon_nonce,
|
||||
coupon: coupon
|
||||
coupon: coupon,
|
||||
};
|
||||
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
url: get_url( 'remove_coupon' ),
|
||||
data: data,
|
||||
type: 'POST',
|
||||
url: get_url( 'remove_coupon' ),
|
||||
data: data,
|
||||
dataType: 'html',
|
||||
success: function( response ) {
|
||||
$( '.woocommerce-error, .woocommerce-message, .woocommerce-info' ).remove();
|
||||
success: function ( response ) {
|
||||
$(
|
||||
'.woocommerce-error, .woocommerce-message, .woocommerce-info, .is-error, .is-info, .is-success'
|
||||
).remove();
|
||||
show_notice( response );
|
||||
$( document.body ).trigger( 'removed_coupon', [ coupon ] );
|
||||
unblock( $wrapper );
|
||||
},
|
||||
complete: function() {
|
||||
complete: function () {
|
||||
cart.update_cart( true );
|
||||
}
|
||||
},
|
||||
} );
|
||||
},
|
||||
|
||||
@@ -529,30 +577,31 @@ jQuery( function( $ ) {
|
||||
*
|
||||
* @param {JQuery Object} $form The cart form.
|
||||
*/
|
||||
quantity_update: function( $form ) {
|
||||
quantity_update: function ( $form ) {
|
||||
block( $form );
|
||||
block( $( 'div.cart_totals' ) );
|
||||
|
||||
// Provide the submit button value because wc-form-handler expects it.
|
||||
$( '<input />' ).attr( 'type', 'hidden' )
|
||||
.attr( 'name', 'update_cart' )
|
||||
.attr( 'value', 'Update Cart' )
|
||||
.appendTo( $form );
|
||||
$( '<input />' )
|
||||
.attr( 'type', 'hidden' )
|
||||
.attr( 'name', 'update_cart' )
|
||||
.attr( 'value', 'Update Cart' )
|
||||
.appendTo( $form );
|
||||
|
||||
// Make call to actual form post URL.
|
||||
$.ajax( {
|
||||
type: $form.attr( 'method' ),
|
||||
url: $form.attr( 'action' ),
|
||||
data: $form.serialize(),
|
||||
type: $form.attr( 'method' ),
|
||||
url: $form.attr( 'action' ),
|
||||
data: $form.serialize(),
|
||||
dataType: 'html',
|
||||
success: function( response ) {
|
||||
success: function ( response ) {
|
||||
update_wc_div( response );
|
||||
},
|
||||
complete: function() {
|
||||
complete: function () {
|
||||
unblock( $form );
|
||||
unblock( $( 'div.cart_totals' ) );
|
||||
$.scroll_to_notices( $( '[role="alert"]' ) );
|
||||
}
|
||||
},
|
||||
} );
|
||||
},
|
||||
|
||||
@@ -561,7 +610,7 @@ jQuery( function( $ ) {
|
||||
*
|
||||
* @param {Object} evt The JQuery event
|
||||
*/
|
||||
item_remove_clicked: function( evt ) {
|
||||
item_remove_clicked: function ( evt ) {
|
||||
evt.preventDefault();
|
||||
|
||||
var $a = $( evt.currentTarget );
|
||||
@@ -571,17 +620,17 @@ jQuery( function( $ ) {
|
||||
block( $( 'div.cart_totals' ) );
|
||||
|
||||
$.ajax( {
|
||||
type: 'GET',
|
||||
url: $a.attr( 'href' ),
|
||||
type: 'GET',
|
||||
url: $a.attr( 'href' ),
|
||||
dataType: 'html',
|
||||
success: function( response ) {
|
||||
success: function ( response ) {
|
||||
update_wc_div( response );
|
||||
},
|
||||
complete: function() {
|
||||
complete: function () {
|
||||
unblock( $form );
|
||||
unblock( $( 'div.cart_totals' ) );
|
||||
$.scroll_to_notices( $( '[role="alert"]' ) );
|
||||
}
|
||||
},
|
||||
} );
|
||||
},
|
||||
|
||||
@@ -590,7 +639,7 @@ jQuery( function( $ ) {
|
||||
*
|
||||
* @param {Object} evt The JQuery event
|
||||
*/
|
||||
item_restore_clicked: function( evt ) {
|
||||
item_restore_clicked: function ( evt ) {
|
||||
evt.preventDefault();
|
||||
|
||||
var $a = $( evt.currentTarget );
|
||||
@@ -600,18 +649,18 @@ jQuery( function( $ ) {
|
||||
block( $( 'div.cart_totals' ) );
|
||||
|
||||
$.ajax( {
|
||||
type: 'GET',
|
||||
url: $a.attr( 'href' ),
|
||||
type: 'GET',
|
||||
url: $a.attr( 'href' ),
|
||||
dataType: 'html',
|
||||
success: function( response ) {
|
||||
success: function ( response ) {
|
||||
update_wc_div( response );
|
||||
},
|
||||
complete: function() {
|
||||
complete: function () {
|
||||
unblock( $form );
|
||||
unblock( $( 'div.cart_totals' ) );
|
||||
}
|
||||
},
|
||||
} );
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
cart_shipping.init( cart );
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,5 @@
|
||||
// Extend checkout block's request data with order attribution data.
|
||||
window.wp.data.dispatch( window.wc.wcBlocksData.CHECKOUT_STORE_KEY ).__internalSetExtensionData(
|
||||
'woocommerce/order-attribution',
|
||||
window.wc_order_attribution.sbjsDataToSchema( window.sbjs.get )
|
||||
);
|
||||
1
wp/wp-content/plugins/woocommerce/assets/js/frontend/order-attribution-blocks.min.js
vendored
Normal file
1
wp/wp-content/plugins/woocommerce/assets/js/frontend/order-attribution-blocks.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
window.wp.data.dispatch(window.wc.wcBlocksData.CHECKOUT_STORE_KEY).__internalSetExtensionData("woocommerce/order-attribution",window.wc_order_attribution.sbjsDataToSchema(window.sbjs.get));
|
||||
@@ -0,0 +1,123 @@
|
||||
( function ( wc_order_attribution ) {
|
||||
'use strict';
|
||||
// Cache params reference for shorter reusability.
|
||||
const params = wc_order_attribution.params;
|
||||
|
||||
// Helper functions.
|
||||
const $ = document.querySelector.bind( document );
|
||||
|
||||
/**
|
||||
* Flattens the sbjs.get object into a schema compatible object.
|
||||
*
|
||||
* @param {Object} obj Sourcebuster data object, `sbjs.get`.
|
||||
* @returns
|
||||
*/
|
||||
wc_order_attribution.sbjsDataToSchema = ( obj ) => ( {
|
||||
type: obj.current.typ,
|
||||
url: obj.current_add.rf,
|
||||
|
||||
utm_campaign: obj.current.cmp,
|
||||
utm_source: obj.current.src,
|
||||
utm_medium: obj.current.mdm,
|
||||
utm_content: obj.current.cnt,
|
||||
utm_id: obj.current.id,
|
||||
utm_term: obj.current.trm,
|
||||
|
||||
session_entry: obj.current_add.ep,
|
||||
session_start_time: obj.current_add.fd,
|
||||
session_pages: obj.session.pgs,
|
||||
session_count: obj.udata.vst,
|
||||
|
||||
user_agent: obj.udata.uag,
|
||||
} );
|
||||
|
||||
/**
|
||||
* Initialize the module.
|
||||
*/
|
||||
function initOrderTracking() {
|
||||
if ( params.allowTracking === 'no' ) {
|
||||
removeTrackingCookies();
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize sourcebuster.js.
|
||||
*/
|
||||
sbjs.init( {
|
||||
lifetime: Number( params.lifetime ),
|
||||
session_length: Number( params.session ),
|
||||
timezone_offset: '0', // utc
|
||||
} );
|
||||
|
||||
/**
|
||||
* Callback to set visitor source values in the checkout
|
||||
* and register forms using sourcebuster object values.
|
||||
* More info at https://sbjs.rocks/#/usage.
|
||||
*/
|
||||
const setFields = () => {
|
||||
|
||||
if ( sbjs.get ) {
|
||||
for( const [ key, value ] of Object.entries( wc_order_attribution.sbjsDataToSchema( sbjs.get ) ) ) {
|
||||
$( `input[name="${params.prefix}${key}"]` ).value = value;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Add source values to the classic checkout form.
|
||||
*/
|
||||
if ( $( 'form.woocommerce-checkout' ) !== null ) {
|
||||
const previousInitCheckout = document.body.oninit_checkout;
|
||||
document.body.oninit_checkout = () => {
|
||||
setFields();
|
||||
previousInitCheckout && previousInitCheckout();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Add source values to register form.
|
||||
*/
|
||||
if ( $( '.woocommerce form.register' ) !== null ) {
|
||||
setFields();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable order tracking analytics and marketing consent init and change.
|
||||
*/
|
||||
wc_order_attribution.setAllowTrackingConsent = ( allow ) => {
|
||||
if ( ! allow ) {
|
||||
return;
|
||||
}
|
||||
|
||||
params.allowTracking = 'yes';
|
||||
initOrderTracking();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove sourcebuster.js cookies.
|
||||
* To be called whenever tracking is disabled or consent is revoked.
|
||||
*/
|
||||
function removeTrackingCookies() {
|
||||
const domain = window.location.hostname;
|
||||
const sbCookies = [
|
||||
'sbjs_current',
|
||||
'sbjs_current_add',
|
||||
'sbjs_first',
|
||||
'sbjs_first_add',
|
||||
'sbjs_session',
|
||||
'sbjs_udata',
|
||||
'sbjs_migrations',
|
||||
'sbjs_promo'
|
||||
];
|
||||
|
||||
// Remove cookies
|
||||
sbCookies.forEach( ( name ) => {
|
||||
document.cookie = `${name}=; path=/; max-age=-999; domain=.${domain};`;
|
||||
} );
|
||||
}
|
||||
|
||||
// Run init.
|
||||
initOrderTracking();
|
||||
|
||||
}( window.wc_order_attribution ) );
|
||||
1
wp/wp-content/plugins/woocommerce/assets/js/frontend/order-attribution.min.js
vendored
Normal file
1
wp/wp-content/plugins/woocommerce/assets/js/frontend/order-attribution.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(t){"use strict";const e=t.params,s=document.querySelector.bind(document);function n(){if("no"===e.allowTracking)return void function(){const t=window.location.hostname;["sbjs_current","sbjs_current_add","sbjs_first","sbjs_first_add","sbjs_session","sbjs_udata","sbjs_migrations","sbjs_promo"].forEach(e=>{document.cookie=`${e}=; path=/; max-age=-999; domain=.${t};`})}();sbjs.init({lifetime:Number(e.lifetime),session_length:Number(e.session),timezone_offset:"0"});const n=()=>{if(sbjs.get)for(const[n,o]of Object.entries(t.sbjsDataToSchema(sbjs.get)))s(`input[name="${e.prefix}${n}"]`).value=o};if(null!==s("form.woocommerce-checkout")){const t=document.body.oninit_checkout;document.body.oninit_checkout=(()=>{n(),t&&t()})}null!==s(".woocommerce form.register")&&n()}t.sbjsDataToSchema=(t=>({type:t.current.typ,url:t.current_add.rf,utm_campaign:t.current.cmp,utm_source:t.current.src,utm_medium:t.current.mdm,utm_content:t.current.cnt,utm_id:t.current.id,utm_term:t.current.trm,session_entry:t.current_add.ep,session_start_time:t.current_add.fd,session_pages:t.session.pgs,session_count:t.udata.vst,user_agent:t.udata.uag})),t.setAllowTrackingConsent=(t=>{t&&(e.allowTracking="yes",n())}),n()}(window.wc_order_attribution);
|
||||
@@ -1,5 +1,5 @@
|
||||
/* global wp, pwsL10n, wc_password_strength_meter_params */
|
||||
( function( $ ) {
|
||||
jQuery( function( $ ) {
|
||||
'use strict';
|
||||
/**
|
||||
* Password Strength Meter class.
|
||||
@@ -129,4 +129,4 @@
|
||||
};
|
||||
|
||||
wc_password_strength_meter.init();
|
||||
})( jQuery );
|
||||
} );
|
||||
|
||||
@@ -1 +1 @@
|
||||
!function(s){"use strict";var r={init:function(){s(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),s("form.checkout #createaccount").trigger("change")},strengthMeter:function(){var e,t=s("form.register, form.checkout, form.edit-account, form.lost_reset_password"),o=s('button[type="submit"]',t),a=s("#reg_password, #account_password, #password_1",t),d=a.val(),n=!t.is("form.checkout");r.includeMeter(t,a),e=r.checkPasswordStrength(t,a),wc_password_strength_meter_params.stop_checkout&&(n=!0),d.length>0&&e<wc_password_strength_meter_params.min_password_strength&&-1!==e&&n?o.attr("disabled","disabled").addClass("disabled"):o.prop("disabled",!1).removeClass("disabled")},includeMeter:function(r,e){var t=r.find(".woocommerce-password-strength");""===e.val()?(t.hide(),s(document.body).trigger("wc-password-strength-hide")):0===t.length?(e.after('<div class="woocommerce-password-strength" aria-live="polite"></div>'),s(document.body).trigger("wc-password-strength-added")):(t.show(),s(document.body).trigger("wc-password-strength-show"))},checkPasswordStrength:function(s,r){var e=s.find(".woocommerce-password-strength"),t=s.find(".woocommerce-password-hint"),o='<small class="woocommerce-password-hint">'+wc_password_strength_meter_params.i18n_password_hint+"</small>",a=wp.passwordStrength.meter(r.val(),wp.passwordStrength.userInputDisallowedList()),d="";if(e.removeClass("short bad good strong"),t.remove(),e.is(":hidden"))return a;switch(a<wc_password_strength_meter_params.min_password_strength&&(d=" - "+wc_password_strength_meter_params.i18n_password_error),a){case 0:e.addClass("short").html(pwsL10n.short+d),e.after(o);break;case 1:case 2:e.addClass("bad").html(pwsL10n.bad+d),e.after(o);break;case 3:e.addClass("good").html(pwsL10n.good+d);break;case 4:e.addClass("strong").html(pwsL10n.strong+d);break;case 5:e.addClass("short").html(pwsL10n.mismatch)}return a}};r.init()}(jQuery);
|
||||
jQuery(function(s){"use strict";var r={init:function(){s(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),s("form.checkout #createaccount").trigger("change")},strengthMeter:function(){var e,t=s("form.register, form.checkout, form.edit-account, form.lost_reset_password"),o=s('button[type="submit"]',t),a=s("#reg_password, #account_password, #password_1",t),d=a.val(),n=!t.is("form.checkout");r.includeMeter(t,a),e=r.checkPasswordStrength(t,a),wc_password_strength_meter_params.stop_checkout&&(n=!0),d.length>0&&e<wc_password_strength_meter_params.min_password_strength&&-1!==e&&n?o.attr("disabled","disabled").addClass("disabled"):o.prop("disabled",!1).removeClass("disabled")},includeMeter:function(r,e){var t=r.find(".woocommerce-password-strength");""===e.val()?(t.hide(),s(document.body).trigger("wc-password-strength-hide")):0===t.length?(e.after('<div class="woocommerce-password-strength" aria-live="polite"></div>'),s(document.body).trigger("wc-password-strength-added")):(t.show(),s(document.body).trigger("wc-password-strength-show"))},checkPasswordStrength:function(s,r){var e=s.find(".woocommerce-password-strength"),t=s.find(".woocommerce-password-hint"),o='<small class="woocommerce-password-hint">'+wc_password_strength_meter_params.i18n_password_hint+"</small>",a=wp.passwordStrength.meter(r.val(),wp.passwordStrength.userInputDisallowedList()),d="";if(e.removeClass("short bad good strong"),t.remove(),e.is(":hidden"))return a;switch(a<wc_password_strength_meter_params.min_password_strength&&(d=" - "+wc_password_strength_meter_params.i18n_password_error),a){case 0:e.addClass("short").html(pwsL10n.short+d),e.after(o);break;case 1:case 2:e.addClass("bad").html(pwsL10n.bad+d),e.after(o);break;case 3:e.addClass("good").html(pwsL10n.good+d);break;case 4:e.addClass("strong").html(pwsL10n.strong+d);break;case 5:e.addClass("short").html(pwsL10n.mismatch)}return a}};r.init()});
|
||||
@@ -0,0 +1,24 @@
|
||||
( function ( $ ) {
|
||||
'use strict';
|
||||
|
||||
// Check init order attribution on consent change.
|
||||
const CONSENT_CATEGORY_MARKING = 'marketing';
|
||||
document.addEventListener( 'wp_listen_for_consent_change', ( e ) => {
|
||||
const changedConsentCategory = e.detail;
|
||||
for ( const key in changedConsentCategory ) {
|
||||
if ( changedConsentCategory.hasOwnProperty( key ) ) {
|
||||
if ( key === CONSENT_CATEGORY_MARKING && changedConsentCategory[ key ] === 'allow' ) {
|
||||
window.wc_order_attribution.setAllowTrackingConsent( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
// Init order attribution as soon as consent type is defined.
|
||||
$( document ).on( 'wp_consent_type_defined', () => {
|
||||
if ( wp_has_consent( CONSENT_CATEGORY_MARKING ) ) {
|
||||
window.wc_order_attribution.setAllowTrackingConsent( true );
|
||||
}
|
||||
} );
|
||||
}( jQuery ) );
|
||||
|
||||
1
wp/wp-content/plugins/woocommerce/assets/js/frontend/wp-consent-api-integration.min.js
vendored
Normal file
1
wp/wp-content/plugins/woocommerce/assets/js/frontend/wp-consent-api-integration.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(n){"use strict";document.addEventListener("wp_listen_for_consent_change",n=>{const t=n.detail;for(const n in t)t.hasOwnProperty(n)&&"marketing"===n&&"allow"===t[n]&&window.wc_order_attribution.setAllowTrackingConsent(!0)}),n(document).on("wp_consent_type_defined",()=>{wp_has_consent("marketing")&&window.wc_order_attribution.setAllowTrackingConsent(!0)})}(jQuery);
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Alex Fedoseev
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,878 @@
|
||||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.sbjs=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
|
||||
"use strict";
|
||||
|
||||
var init = _dereq_('./init');
|
||||
|
||||
var sbjs = {
|
||||
init: function(prefs) {
|
||||
this.get = init(prefs);
|
||||
if (prefs && prefs.callback && typeof prefs.callback === 'function') {
|
||||
prefs.callback(this.get);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = sbjs;
|
||||
},{"./init":6}],2:[function(_dereq_,module,exports){
|
||||
"use strict";
|
||||
|
||||
var terms = _dereq_('./terms'),
|
||||
utils = _dereq_('./helpers/utils');
|
||||
|
||||
var data = {
|
||||
|
||||
containers: {
|
||||
current: 'sbjs_current',
|
||||
current_extra: 'sbjs_current_add',
|
||||
first: 'sbjs_first',
|
||||
first_extra: 'sbjs_first_add',
|
||||
session: 'sbjs_session',
|
||||
udata: 'sbjs_udata',
|
||||
promocode: 'sbjs_promo'
|
||||
},
|
||||
|
||||
service: {
|
||||
migrations: 'sbjs_migrations'
|
||||
},
|
||||
|
||||
delimiter: '|||',
|
||||
|
||||
aliases: {
|
||||
|
||||
main: {
|
||||
type: 'typ',
|
||||
source: 'src',
|
||||
medium: 'mdm',
|
||||
campaign: 'cmp',
|
||||
content: 'cnt',
|
||||
term: 'trm',
|
||||
id: 'id'
|
||||
},
|
||||
|
||||
extra: {
|
||||
fire_date: 'fd',
|
||||
entrance_point: 'ep',
|
||||
referer: 'rf'
|
||||
},
|
||||
|
||||
session: {
|
||||
pages_seen: 'pgs',
|
||||
current_page: 'cpg'
|
||||
},
|
||||
|
||||
udata: {
|
||||
visits: 'vst',
|
||||
ip: 'uip',
|
||||
agent: 'uag'
|
||||
},
|
||||
|
||||
promo: 'code'
|
||||
|
||||
},
|
||||
|
||||
pack: {
|
||||
|
||||
main: function(sbjs) {
|
||||
return (
|
||||
data.aliases.main.type + '=' + sbjs.type + data.delimiter +
|
||||
data.aliases.main.source + '=' + sbjs.source + data.delimiter +
|
||||
data.aliases.main.medium + '=' + sbjs.medium + data.delimiter +
|
||||
data.aliases.main.campaign + '=' + sbjs.campaign + data.delimiter +
|
||||
data.aliases.main.content + '=' + sbjs.content + data.delimiter +
|
||||
data.aliases.main.term + '=' + sbjs.term + data.delimiter +
|
||||
data.aliases.main.id + '=' + sbjs.id
|
||||
);
|
||||
},
|
||||
|
||||
extra: function(timezone_offset) {
|
||||
return (
|
||||
data.aliases.extra.fire_date + '=' + utils.setDate(new Date, timezone_offset) + data.delimiter +
|
||||
data.aliases.extra.entrance_point + '=' + document.location.href + data.delimiter +
|
||||
data.aliases.extra.referer + '=' + (document.referrer || terms.none)
|
||||
);
|
||||
},
|
||||
|
||||
user: function(visits, user_ip) {
|
||||
return (
|
||||
data.aliases.udata.visits + '=' + visits + data.delimiter +
|
||||
data.aliases.udata.ip + '=' + user_ip + data.delimiter +
|
||||
data.aliases.udata.agent + '=' + navigator.userAgent
|
||||
);
|
||||
},
|
||||
|
||||
session: function(pages) {
|
||||
return (
|
||||
data.aliases.session.pages_seen + '=' + pages + data.delimiter +
|
||||
data.aliases.session.current_page + '=' + document.location.href
|
||||
);
|
||||
},
|
||||
|
||||
promo: function(promo) {
|
||||
return (
|
||||
data.aliases.promo + '=' + utils.setLeadingZeroToInt(utils.randomInt(promo.min, promo.max), promo.max.toString().length)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = data;
|
||||
|
||||
},{"./helpers/utils":5,"./terms":9}],3:[function(_dereq_,module,exports){
|
||||
"use strict";
|
||||
|
||||
var delimiter = _dereq_('../data').delimiter;
|
||||
|
||||
module.exports = {
|
||||
|
||||
encodeData: function(s) {
|
||||
return encodeURIComponent(s).replace(/\!/g, '%21')
|
||||
.replace(/\~/g, '%7E')
|
||||
.replace(/\*/g, '%2A')
|
||||
.replace(/\'/g, '%27')
|
||||
.replace(/\(/g, '%28')
|
||||
.replace(/\)/g, '%29');
|
||||
},
|
||||
|
||||
decodeData: function(s) {
|
||||
try {
|
||||
return decodeURIComponent(s).replace(/\%21/g, '!')
|
||||
.replace(/\%7E/g, '~')
|
||||
.replace(/\%2A/g, '*')
|
||||
.replace(/\%27/g, "'")
|
||||
.replace(/\%28/g, '(')
|
||||
.replace(/\%29/g, ')');
|
||||
} catch(err1) {
|
||||
// try unescape for backward compatibility
|
||||
try { return unescape(s); } catch(err2) { return ''; }
|
||||
}
|
||||
},
|
||||
|
||||
set: function(name, value, minutes, domain, excl_subdomains) {
|
||||
var expires, basehost;
|
||||
|
||||
if (minutes) {
|
||||
var date = new Date();
|
||||
date.setTime(date.getTime() + (minutes * 60 * 1000));
|
||||
expires = '; expires=' + date.toGMTString();
|
||||
} else {
|
||||
expires = '';
|
||||
}
|
||||
if (domain && !excl_subdomains) {
|
||||
basehost = ';domain=.' + domain;
|
||||
} else {
|
||||
basehost = '';
|
||||
}
|
||||
document.cookie = this.encodeData(name) + '=' + this.encodeData(value) + expires + basehost + '; path=/';
|
||||
},
|
||||
|
||||
get: function(name) {
|
||||
var nameEQ = this.encodeData(name) + '=',
|
||||
ca = document.cookie.split(';');
|
||||
|
||||
for (var i = 0; i < ca.length; i++) {
|
||||
var c = ca[i];
|
||||
while (c.charAt(0) === ' ') { c = c.substring(1, c.length); }
|
||||
if (c.indexOf(nameEQ) === 0) {
|
||||
return this.decodeData(c.substring(nameEQ.length, c.length));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
destroy: function(name, domain, excl_subdomains) {
|
||||
this.set(name, '', -1, domain, excl_subdomains);
|
||||
},
|
||||
|
||||
parse: function(yummy) {
|
||||
|
||||
var cookies = [],
|
||||
data = {};
|
||||
|
||||
if (typeof yummy === 'string') {
|
||||
cookies.push(yummy);
|
||||
} else {
|
||||
for (var prop in yummy) {
|
||||
if (yummy.hasOwnProperty(prop)) {
|
||||
cookies.push(yummy[prop]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var i1 = 0; i1 < cookies.length; i1++) {
|
||||
var cookie_array;
|
||||
data[this.unsbjs(cookies[i1])] = {};
|
||||
if (this.get(cookies[i1])) {
|
||||
cookie_array = this.get(cookies[i1]).split(delimiter);
|
||||
} else {
|
||||
cookie_array = [];
|
||||
}
|
||||
for (var i2 = 0; i2 < cookie_array.length; i2++) {
|
||||
var tmp_array = cookie_array[i2].split('='),
|
||||
result_array = tmp_array.splice(0, 1);
|
||||
result_array.push(tmp_array.join('='));
|
||||
data[this.unsbjs(cookies[i1])][result_array[0]] = this.decodeData(result_array[1]);
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
},
|
||||
|
||||
unsbjs: function (string) {
|
||||
return string.replace('sbjs_', '');
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
},{"../data":2}],4:[function(_dereq_,module,exports){
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
|
||||
parse: function(str) {
|
||||
var o = this.parseOptions,
|
||||
m = o.parser[o.strictMode ? 'strict' : 'loose'].exec(str),
|
||||
uri = {},
|
||||
i = 14;
|
||||
|
||||
while (i--) { uri[o.key[i]] = m[i] || ''; }
|
||||
|
||||
uri[o.q.name] = {};
|
||||
uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
|
||||
if ($1) { uri[o.q.name][$1] = $2; }
|
||||
});
|
||||
|
||||
return uri;
|
||||
},
|
||||
|
||||
parseOptions: {
|
||||
strictMode: false,
|
||||
key: ['source','protocol','authority','userInfo','user','password','host','port','relative','path','directory','file','query','anchor'],
|
||||
q: {
|
||||
name: 'queryKey',
|
||||
parser: /(?:^|&)([^&=]*)=?([^&]*)/g
|
||||
},
|
||||
parser: {
|
||||
strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
|
||||
loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
|
||||
}
|
||||
},
|
||||
|
||||
getParam: function(custom_params) {
|
||||
var query_string = {},
|
||||
query = custom_params ? custom_params : window.location.search.substring(1),
|
||||
vars = query.split('&');
|
||||
|
||||
for (var i = 0; i < vars.length; i++) {
|
||||
var pair = vars[i].split('=');
|
||||
if (typeof query_string[pair[0]] === 'undefined') {
|
||||
query_string[pair[0]] = pair[1];
|
||||
} else if (typeof query_string[pair[0]] === 'string') {
|
||||
var arr = [ query_string[pair[0]], pair[1] ];
|
||||
query_string[pair[0]] = arr;
|
||||
} else {
|
||||
query_string[pair[0]].push(pair[1]);
|
||||
}
|
||||
}
|
||||
return query_string;
|
||||
},
|
||||
|
||||
getHost: function(request) {
|
||||
return this.parse(request).host.replace('www.', '');
|
||||
}
|
||||
|
||||
};
|
||||
},{}],5:[function(_dereq_,module,exports){
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
|
||||
escapeRegexp: function(string) {
|
||||
return string.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
||||
},
|
||||
|
||||
setDate: function(date, offset) {
|
||||
var utc_offset = date.getTimezoneOffset() / 60,
|
||||
now_hours = date.getHours(),
|
||||
custom_offset = offset || offset === 0 ? offset : -utc_offset;
|
||||
|
||||
date.setHours(now_hours + utc_offset + custom_offset);
|
||||
|
||||
var year = date.getFullYear(),
|
||||
month = this.setLeadingZeroToInt(date.getMonth() + 1, 2),
|
||||
day = this.setLeadingZeroToInt(date.getDate(), 2),
|
||||
hour = this.setLeadingZeroToInt(date.getHours(), 2),
|
||||
minute = this.setLeadingZeroToInt(date.getMinutes(), 2),
|
||||
second = this.setLeadingZeroToInt(date.getSeconds(), 2);
|
||||
|
||||
return (year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second);
|
||||
},
|
||||
|
||||
setLeadingZeroToInt: function(num, size) {
|
||||
var s = num + '';
|
||||
while (s.length < size) { s = '0' + s; }
|
||||
return s;
|
||||
},
|
||||
|
||||
randomInt: function(min, max) {
|
||||
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
},{}],6:[function(_dereq_,module,exports){
|
||||
"use strict";
|
||||
|
||||
var data = _dereq_('./data'),
|
||||
terms = _dereq_('./terms'),
|
||||
cookies = _dereq_('./helpers/cookies'),
|
||||
uri = _dereq_('./helpers/uri'),
|
||||
utils = _dereq_('./helpers/utils'),
|
||||
params = _dereq_('./params'),
|
||||
migrations = _dereq_('./migrations');
|
||||
|
||||
module.exports = function(prefs) {
|
||||
|
||||
var p = params.fetch(prefs);
|
||||
var get_param = uri.getParam();
|
||||
var domain = p.domain.host,
|
||||
isolate = p.domain.isolate,
|
||||
lifetime = p.lifetime;
|
||||
|
||||
migrations.go(lifetime, domain, isolate);
|
||||
|
||||
var __sbjs_type,
|
||||
__sbjs_source,
|
||||
__sbjs_medium,
|
||||
__sbjs_campaign,
|
||||
__sbjs_content,
|
||||
__sbjs_term,
|
||||
__sbjs_id;
|
||||
|
||||
function mainData() {
|
||||
var sbjs_data;
|
||||
if (
|
||||
typeof get_param.utm_source !== 'undefined' ||
|
||||
typeof get_param.utm_medium !== 'undefined' ||
|
||||
typeof get_param.utm_campaign !== 'undefined' ||
|
||||
typeof get_param.utm_content !== 'undefined' ||
|
||||
typeof get_param.utm_term !== 'undefined' ||
|
||||
typeof get_param.utm_id !== 'undefined' ||
|
||||
typeof get_param.gclid !== 'undefined' ||
|
||||
typeof get_param.yclid !== 'undefined' ||
|
||||
typeof get_param[p.campaign_param] !== 'undefined' ||
|
||||
typeof get_param[p.term_param] !== 'undefined' ||
|
||||
typeof get_param[p.content_param] !== 'undefined'
|
||||
) {
|
||||
setFirstAndCurrentExtraData();
|
||||
sbjs_data = getData(terms.traffic.utm);
|
||||
} else if (checkReferer(terms.traffic.organic)) {
|
||||
setFirstAndCurrentExtraData();
|
||||
sbjs_data = getData(terms.traffic.organic);
|
||||
} else if (!cookies.get(data.containers.session) && checkReferer(terms.traffic.referral)) {
|
||||
setFirstAndCurrentExtraData();
|
||||
sbjs_data = getData(terms.traffic.referral);
|
||||
} else if (!cookies.get(data.containers.first) && !cookies.get(data.containers.current)) {
|
||||
setFirstAndCurrentExtraData();
|
||||
sbjs_data = getData(terms.traffic.typein);
|
||||
} else {
|
||||
return cookies.get(data.containers.current);
|
||||
}
|
||||
|
||||
return sbjs_data;
|
||||
}
|
||||
|
||||
function getData(type) {
|
||||
|
||||
switch (type) {
|
||||
|
||||
case terms.traffic.utm:
|
||||
|
||||
__sbjs_type = terms.traffic.utm;
|
||||
|
||||
if (typeof get_param.utm_source !== 'undefined') {
|
||||
__sbjs_source = get_param.utm_source;
|
||||
} else if (typeof get_param.gclid !== 'undefined') {
|
||||
__sbjs_source = 'google';
|
||||
} else if (typeof get_param.yclid !== 'undefined') {
|
||||
__sbjs_source = 'yandex';
|
||||
} else {
|
||||
__sbjs_source = terms.none;
|
||||
}
|
||||
|
||||
if (typeof get_param.utm_medium !== 'undefined') {
|
||||
__sbjs_medium = get_param.utm_medium;
|
||||
} else if (typeof get_param.gclid !== 'undefined') {
|
||||
__sbjs_medium = 'cpc';
|
||||
} else if (typeof get_param.yclid !== 'undefined') {
|
||||
__sbjs_medium = 'cpc';
|
||||
} else {
|
||||
__sbjs_medium = terms.none;
|
||||
}
|
||||
|
||||
if (typeof get_param.utm_campaign !== 'undefined') {
|
||||
__sbjs_campaign = get_param.utm_campaign;
|
||||
} else if (typeof get_param[p.campaign_param] !== 'undefined') {
|
||||
__sbjs_campaign = get_param[p.campaign_param];
|
||||
} else if (typeof get_param.gclid !== 'undefined') {
|
||||
__sbjs_campaign = 'google_cpc';
|
||||
} else if (typeof get_param.yclid !== 'undefined') {
|
||||
__sbjs_campaign = 'yandex_cpc';
|
||||
} else {
|
||||
__sbjs_campaign = terms.none;
|
||||
}
|
||||
|
||||
if (typeof get_param.utm_content !== 'undefined') {
|
||||
__sbjs_content = get_param.utm_content;
|
||||
} else if (typeof get_param[p.content_param] !== 'undefined') {
|
||||
__sbjs_content = get_param[p.content_param];
|
||||
} else {
|
||||
__sbjs_content = terms.none;
|
||||
}
|
||||
|
||||
__sbjs_id = get_param.utm_id || terms.none;
|
||||
|
||||
if (typeof get_param.utm_term !== 'undefined') {
|
||||
__sbjs_term = get_param.utm_term;
|
||||
} else if (typeof get_param[p.term_param] !== 'undefined') {
|
||||
__sbjs_term = get_param[p.term_param];
|
||||
} else {
|
||||
__sbjs_term = getUtmTerm() || terms.none;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case terms.traffic.organic:
|
||||
__sbjs_type = terms.traffic.organic;
|
||||
__sbjs_source = __sbjs_source || uri.getHost(document.referrer);
|
||||
__sbjs_medium = terms.referer.organic;
|
||||
__sbjs_campaign = terms.none;
|
||||
__sbjs_content = terms.none;
|
||||
__sbjs_term = terms.none;
|
||||
__sbjs_id = terms.none;
|
||||
break;
|
||||
|
||||
case terms.traffic.referral:
|
||||
__sbjs_type = terms.traffic.referral;
|
||||
__sbjs_source = __sbjs_source || uri.getHost(document.referrer);
|
||||
__sbjs_medium = __sbjs_medium || terms.referer.referral;
|
||||
__sbjs_campaign = terms.none;
|
||||
__sbjs_content = uri.parse(document.referrer).path;
|
||||
__sbjs_term = terms.none;
|
||||
__sbjs_id = terms.none;
|
||||
break;
|
||||
|
||||
case terms.traffic.typein:
|
||||
__sbjs_type = terms.traffic.typein;
|
||||
__sbjs_source = p.typein_attributes.source;
|
||||
__sbjs_medium = p.typein_attributes.medium;
|
||||
__sbjs_campaign = terms.none;
|
||||
__sbjs_content = terms.none;
|
||||
__sbjs_term = terms.none;
|
||||
__sbjs_id = terms.none;
|
||||
break;
|
||||
|
||||
default:
|
||||
__sbjs_type = terms.oops;
|
||||
__sbjs_source = terms.oops;
|
||||
__sbjs_medium = terms.oops;
|
||||
__sbjs_campaign = terms.oops;
|
||||
__sbjs_content = terms.oops;
|
||||
__sbjs_term = terms.oops;
|
||||
__sbjs_id = terms.oops;
|
||||
}
|
||||
var sbjs_data = {
|
||||
type: __sbjs_type,
|
||||
source: __sbjs_source,
|
||||
medium: __sbjs_medium,
|
||||
campaign: __sbjs_campaign,
|
||||
content: __sbjs_content,
|
||||
term: __sbjs_term,
|
||||
id: __sbjs_id
|
||||
};
|
||||
|
||||
return data.pack.main(sbjs_data);
|
||||
|
||||
}
|
||||
|
||||
function getUtmTerm() {
|
||||
var referer = document.referrer;
|
||||
if (get_param.utm_term) {
|
||||
return get_param.utm_term;
|
||||
} else if (referer && uri.parse(referer).host && uri.parse(referer).host.match(/^(?:.*\.)?yandex\..{2,9}$/i)) {
|
||||
try {
|
||||
return uri.getParam(uri.parse(document.referrer).query).text;
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function checkReferer(type) {
|
||||
var referer = document.referrer;
|
||||
switch(type) {
|
||||
case terms.traffic.organic:
|
||||
return (!!referer && checkRefererHost(referer) && isOrganic(referer));
|
||||
case terms.traffic.referral:
|
||||
return (!!referer && checkRefererHost(referer) && isReferral(referer));
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function checkRefererHost(referer) {
|
||||
if (p.domain) {
|
||||
if (!isolate) {
|
||||
var host_regex = new RegExp('^(?:.*\\.)?' + utils.escapeRegexp(domain) + '$', 'i');
|
||||
return !(uri.getHost(referer).match(host_regex));
|
||||
} else {
|
||||
return (uri.getHost(referer) !== uri.getHost(domain));
|
||||
}
|
||||
} else {
|
||||
return (uri.getHost(referer) !== uri.getHost(document.location.href));
|
||||
}
|
||||
}
|
||||
|
||||
function isOrganic(referer) {
|
||||
|
||||
var y_host = 'yandex',
|
||||
y_param = 'text',
|
||||
g_host = 'google';
|
||||
|
||||
var y_host_regex = new RegExp('^(?:.*\\.)?' + utils.escapeRegexp(y_host) + '\\..{2,9}$'),
|
||||
y_param_regex = new RegExp('.*' + utils.escapeRegexp(y_param) + '=.*'),
|
||||
g_host_regex = new RegExp('^(?:www\\.)?' + utils.escapeRegexp(g_host) + '\\..{2,9}$');
|
||||
|
||||
if (
|
||||
!!uri.parse(referer).query &&
|
||||
!!uri.parse(referer).host.match(y_host_regex) &&
|
||||
!!uri.parse(referer).query.match(y_param_regex)
|
||||
) {
|
||||
__sbjs_source = y_host;
|
||||
return true;
|
||||
} else if (!!uri.parse(referer).host.match(g_host_regex)) {
|
||||
__sbjs_source = g_host;
|
||||
return true;
|
||||
} else if (!!uri.parse(referer).query) {
|
||||
for (var i = 0; i < p.organics.length; i++) {
|
||||
if (
|
||||
uri.parse(referer).host.match(new RegExp('^(?:.*\\.)?' + utils.escapeRegexp(p.organics[i].host) + '$', 'i')) &&
|
||||
uri.parse(referer).query.match(new RegExp('.*' + utils.escapeRegexp(p.organics[i].param) + '=.*', 'i'))
|
||||
) {
|
||||
__sbjs_source = p.organics[i].display || p.organics[i].host;
|
||||
return true;
|
||||
}
|
||||
if (i + 1 === p.organics.length) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function isReferral(referer) {
|
||||
if (p.referrals.length > 0) {
|
||||
for (var i = 0; i < p.referrals.length; i++) {
|
||||
if (uri.parse(referer).host.match(new RegExp('^(?:.*\\.)?' + utils.escapeRegexp(p.referrals[i].host) + '$', 'i'))) {
|
||||
__sbjs_source = p.referrals[i].display || p.referrals[i].host;
|
||||
__sbjs_medium = p.referrals[i].medium || terms.referer.referral;
|
||||
return true;
|
||||
}
|
||||
if (i + 1 === p.referrals.length) {
|
||||
__sbjs_source = uri.getHost(referer);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
__sbjs_source = uri.getHost(referer);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function setFirstAndCurrentExtraData() {
|
||||
cookies.set(data.containers.current_extra, data.pack.extra(p.timezone_offset), lifetime, domain, isolate);
|
||||
if (!cookies.get(data.containers.first_extra)) {
|
||||
cookies.set(data.containers.first_extra, data.pack.extra(p.timezone_offset), lifetime, domain, isolate);
|
||||
}
|
||||
}
|
||||
|
||||
(function setData() {
|
||||
|
||||
// Main data
|
||||
cookies.set(data.containers.current, mainData(), lifetime, domain, isolate);
|
||||
if (!cookies.get(data.containers.first)) {
|
||||
cookies.set(data.containers.first, cookies.get(data.containers.current), lifetime, domain, isolate);
|
||||
}
|
||||
|
||||
// User data
|
||||
var visits, udata;
|
||||
if (!cookies.get(data.containers.udata)) {
|
||||
visits = 1;
|
||||
udata = data.pack.user(visits, p.user_ip);
|
||||
} else {
|
||||
visits = parseInt(cookies.parse(data.containers.udata)[cookies.unsbjs(data.containers.udata)][data.aliases.udata.visits]) || 1;
|
||||
visits = cookies.get(data.containers.session) ? visits : visits + 1;
|
||||
udata = data.pack.user(visits, p.user_ip);
|
||||
}
|
||||
cookies.set(data.containers.udata, udata, lifetime, domain, isolate);
|
||||
|
||||
// Session
|
||||
var pages_count;
|
||||
if (!cookies.get(data.containers.session)) {
|
||||
pages_count = 1;
|
||||
} else {
|
||||
pages_count = parseInt(cookies.parse(data.containers.session)[cookies.unsbjs(data.containers.session)][data.aliases.session.pages_seen]) || 1;
|
||||
pages_count += 1;
|
||||
}
|
||||
cookies.set(data.containers.session, data.pack.session(pages_count), p.session_length, domain, isolate);
|
||||
|
||||
// Promocode
|
||||
if (p.promocode && !cookies.get(data.containers.promocode)) {
|
||||
cookies.set(data.containers.promocode, data.pack.promo(p.promocode), lifetime, domain, isolate);
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
return cookies.parse(data.containers);
|
||||
|
||||
};
|
||||
|
||||
},{"./data":2,"./helpers/cookies":3,"./helpers/uri":4,"./helpers/utils":5,"./migrations":7,"./params":8,"./terms":9}],7:[function(_dereq_,module,exports){
|
||||
"use strict";
|
||||
|
||||
var data = _dereq_('./data'),
|
||||
cookies = _dereq_('./helpers/cookies');
|
||||
|
||||
module.exports = {
|
||||
|
||||
go: function(lifetime, domain, isolate) {
|
||||
|
||||
var migrate = this.migrations,
|
||||
_with = { l: lifetime, d: domain, i: isolate };
|
||||
|
||||
var i;
|
||||
|
||||
if (!cookies.get(data.containers.first) && !cookies.get(data.service.migrations)) {
|
||||
|
||||
var mids = [];
|
||||
for (i = 0; i < migrate.length; i++) { mids.push(migrate[i].id); }
|
||||
|
||||
var advance = '';
|
||||
for (i = 0; i < mids.length; i++) {
|
||||
advance += mids[i] + '=1';
|
||||
if (i < mids.length - 1) { advance += data.delimiter; }
|
||||
}
|
||||
cookies.set(data.service.migrations, advance, _with.l, _with.d, _with.i);
|
||||
|
||||
} else if (!cookies.get(data.service.migrations)) {
|
||||
|
||||
// We have only one migration for now, so just
|
||||
for (i = 0; i < migrate.length; i++) {
|
||||
migrate[i].go(migrate[i].id, _with);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
migrations: [
|
||||
|
||||
{
|
||||
id: '1418474375998',
|
||||
version: '1.0.0-beta',
|
||||
go: function(mid, _with) {
|
||||
|
||||
var success = mid + '=1',
|
||||
fail = mid + '=0';
|
||||
|
||||
var safeReplace = function($0, $1, $2) {
|
||||
return ($1 || $2 ? $0 : data.delimiter);
|
||||
};
|
||||
|
||||
try {
|
||||
|
||||
// Switch delimiter and renew cookies
|
||||
var _in = [];
|
||||
for (var prop in data.containers) {
|
||||
if (data.containers.hasOwnProperty(prop)) {
|
||||
_in.push(data.containers[prop]);
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < _in.length; i++) {
|
||||
if (cookies.get(_in[i])) {
|
||||
var buffer = cookies.get(_in[i]).replace(/(\|)?\|(\|)?/g, safeReplace);
|
||||
cookies.destroy(_in[i], _with.d, _with.i);
|
||||
cookies.destroy(_in[i], _with.d, !_with.i);
|
||||
cookies.set(_in[i], buffer, _with.l, _with.d, _with.i);
|
||||
}
|
||||
}
|
||||
|
||||
// Update `session`
|
||||
if (cookies.get(data.containers.session)) {
|
||||
cookies.set(data.containers.session, data.pack.session(0), _with.l, _with.d, _with.i);
|
||||
}
|
||||
|
||||
// Yay!
|
||||
cookies.set(data.service.migrations, success, _with.l, _with.d, _with.i);
|
||||
|
||||
} catch (err) {
|
||||
// Oops
|
||||
cookies.set(data.service.migrations, fail, _with.l, _with.d, _with.i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
]
|
||||
|
||||
};
|
||||
},{"./data":2,"./helpers/cookies":3}],8:[function(_dereq_,module,exports){
|
||||
"use strict";
|
||||
|
||||
var terms = _dereq_('./terms'),
|
||||
uri = _dereq_('./helpers/uri');
|
||||
|
||||
module.exports = {
|
||||
|
||||
fetch: function(prefs) {
|
||||
|
||||
var user = prefs || {},
|
||||
params = {};
|
||||
|
||||
// Set `lifetime of the cookie` in months
|
||||
params.lifetime = this.validate.checkFloat(user.lifetime) || 6;
|
||||
params.lifetime = parseInt(params.lifetime * 30 * 24 * 60);
|
||||
|
||||
// Set `session length` in minutes
|
||||
params.session_length = this.validate.checkInt(user.session_length) || 30;
|
||||
|
||||
// Set `timezone offset` in hours
|
||||
params.timezone_offset = this.validate.checkInt(user.timezone_offset);
|
||||
|
||||
// Set `campaign param` for AdWords links
|
||||
params.campaign_param = user.campaign_param || false;
|
||||
|
||||
// Set `term param` and `content param` for AdWords links
|
||||
params.term_param = user.term_param || false;
|
||||
params.content_param = user.content_param || false;
|
||||
|
||||
// Set `user ip`
|
||||
params.user_ip = user.user_ip || terms.none;
|
||||
|
||||
// Set `promocode`
|
||||
if (user.promocode) {
|
||||
params.promocode = {};
|
||||
params.promocode.min = parseInt(user.promocode.min) || 100000;
|
||||
params.promocode.max = parseInt(user.promocode.max) || 999999;
|
||||
} else {
|
||||
params.promocode = false;
|
||||
}
|
||||
|
||||
// Set `typein attributes`
|
||||
if (user.typein_attributes && user.typein_attributes.source && user.typein_attributes.medium) {
|
||||
params.typein_attributes = {};
|
||||
params.typein_attributes.source = user.typein_attributes.source;
|
||||
params.typein_attributes.medium = user.typein_attributes.medium;
|
||||
} else {
|
||||
params.typein_attributes = { source: '(direct)', medium: '(none)' };
|
||||
}
|
||||
|
||||
// Set `domain`
|
||||
if (user.domain && this.validate.isString(user.domain)) {
|
||||
params.domain = { host: user.domain, isolate: false };
|
||||
} else if (user.domain && user.domain.host) {
|
||||
params.domain = user.domain;
|
||||
} else {
|
||||
params.domain = { host: uri.getHost(document.location.hostname), isolate: false };
|
||||
}
|
||||
|
||||
// Set `referral sources`
|
||||
params.referrals = [];
|
||||
|
||||
if (user.referrals && user.referrals.length > 0) {
|
||||
for (var ir = 0; ir < user.referrals.length; ir++) {
|
||||
if (user.referrals[ir].host) {
|
||||
params.referrals.push(user.referrals[ir]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set `organic sources`
|
||||
params.organics = [];
|
||||
|
||||
if (user.organics && user.organics.length > 0) {
|
||||
for (var io = 0; io < user.organics.length; io++) {
|
||||
if (user.organics[io].host && user.organics[io].param) {
|
||||
params.organics.push(user.organics[io]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
params.organics.push({ host: 'bing.com', param: 'q', display: 'bing' });
|
||||
params.organics.push({ host: 'yahoo.com', param: 'p', display: 'yahoo' });
|
||||
params.organics.push({ host: 'about.com', param: 'q', display: 'about' });
|
||||
params.organics.push({ host: 'aol.com', param: 'q', display: 'aol' });
|
||||
params.organics.push({ host: 'ask.com', param: 'q', display: 'ask' });
|
||||
params.organics.push({ host: 'globososo.com', param: 'q', display: 'globo' });
|
||||
params.organics.push({ host: 'go.mail.ru', param: 'q', display: 'go.mail.ru' });
|
||||
params.organics.push({ host: 'rambler.ru', param: 'query', display: 'rambler' });
|
||||
params.organics.push({ host: 'tut.by', param: 'query', display: 'tut.by' });
|
||||
|
||||
params.referrals.push({ host: 't.co', display: 'twitter.com' });
|
||||
params.referrals.push({ host: 'plus.url.google.com', display: 'plus.google.com' });
|
||||
|
||||
|
||||
return params;
|
||||
|
||||
},
|
||||
|
||||
validate: {
|
||||
|
||||
checkFloat: function(v) {
|
||||
return v && this.isNumeric(parseFloat(v)) ? parseFloat(v) : false;
|
||||
},
|
||||
|
||||
checkInt: function(v) {
|
||||
return v && this.isNumeric(parseInt(v)) ? parseInt(v) : false;
|
||||
},
|
||||
|
||||
isNumeric: function(v){
|
||||
return !isNaN(v);
|
||||
},
|
||||
|
||||
isString: function(v) {
|
||||
return Object.prototype.toString.call(v) === '[object String]';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
},{"./helpers/uri":4,"./terms":9}],9:[function(_dereq_,module,exports){
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
|
||||
traffic: {
|
||||
utm: 'utm',
|
||||
organic: 'organic',
|
||||
referral: 'referral',
|
||||
typein: 'typein'
|
||||
},
|
||||
|
||||
referer: {
|
||||
referral: 'referral',
|
||||
organic: 'organic',
|
||||
social: 'social'
|
||||
},
|
||||
|
||||
none: '(none)',
|
||||
oops: '(Houston, we have a problem)'
|
||||
|
||||
};
|
||||
|
||||
},{}]},{},[1])(1)
|
||||
});
|
||||
1
wp/wp-content/plugins/woocommerce/assets/js/sourcebuster/sourcebuster.min.js
vendored
Normal file
1
wp/wp-content/plugins/woocommerce/assets/js/sourcebuster/sourcebuster.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user