Plugin Directory

Changeset 3192288


Ignore:
Timestamp:
11/19/2024 01:06:33 PM (16 months ago)
Author:
pluginsandsnippets
Message:

trunk 2.0.22

Location:
psupsellmaster/trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • psupsellmaster/trunk/assets/css/admin/campaigns/edit.css

    r3060205 r3192288  
    112112-------------------------------------------------------------- */
    113113
    114 .psupsellmaster-section-products .psupsellmaster-subsection-assign-tags .psupsellmaster-notices {
     114.psupsellmaster-section-products .psupsellmaster-subsection-update-tags .psupsellmaster-notices {
    115115    margin-top: 15px;
    116116}
     
    389389
    390390
     391/* Forms & Buttons.
     392-------------------------------------------------------------- */
     393
     394.psupsellmaster-subsection-update-tags .psupsellmaster-form-actions {
     395    align-items: center;
     396    display: flex;
     397}
     398
     399
    391400/* WP Editor.
    392401-------------------------------------------------------------- */
  • psupsellmaster/trunk/assets/css/admin/campaigns/edit.min.css

    r3060205 r3192288  
    1 .psupsellmaster-notice,.psupsellmaster-section{background:#fff;padding:15px;box-sizing:border-box;width:100%}.psupsellmaster-wrap .page-title-action{display:inline-block}.psupsellmaster-wrap .psupsellmaster-warning{color:red}.psupsellmaster-sections{display:flex;flex-wrap:wrap;gap:15px;margin-top:15px}.psupsellmaster-section{border:1px solid #ddd;border-radius:5px;flex-grow:1}.psupsellmaster-section .psupsellmaster-section-title{margin:0 0 5px}.psupsellmaster-section .psupsellmaster-section-subtitle{margin:0 0 15px}.psupsellmaster-section .psupsellmaster-separator{margin:15px 0}.psupsellmaster-subsections{display:flex;flex-direction:column;gap:30px}.psupsellmaster-notices{display:flex;flex-direction:column;gap:10px;margin:0;width:100%}.psupsellmaster-notice{border:1px solid #ddd;border-radius:5px;margin:0}.psupsellmaster-form-edit-campaign>.psupsellmaster-notices,.psupsellmaster-section .psupsellmaster-tabs,.psupsellmaster-section-products .psupsellmaster-subsection-assign-tags .psupsellmaster-notices{margin-top:15px}.psupsellmaster-tab-section .psupsellmaster-notices:first-child{margin-bottom:15px}.psupsellmaster-section-general .psupsellmaster-form-group{align-items:flex-start;display:flex;gap:15px;width:100%}.psupsellmaster-section-general .psupsellmaster-form-group>.psupsellmaster-form-field{padding-top:1.4em}.psupsellmaster-banner-actions .button,.psupsellmaster-form-field-synced-tags,.psupsellmaster-repeater-row-actions,.psupsellmaster-repeater-row-content,.psupsellmaster-section-general .psupsellmaster-form-options{width:100%}.psupsellmaster-section-products .psupsellmaster-subsection-products-selection .psupsellmaster-tabs .psupsellmaster-tabs,.psupsellmaster-section-promotion-conditions .psupsellmaster-subsection .psupsellmaster-tabs .psupsellmaster-tabs{margin-top:0}.psupsellmaster-section-actions{display:flex;flex-wrap:wrap;gap:15px;justify-content:space-between;width:100%}.psupsellmaster-section-actions .psupsellmaster-action-save-campaign{margin-left:auto;width:100%}.psupsellmaster-section-actions .psupsellmaster-action-delete-campaign{align-items:center;display:flex;flex-wrap:wrap;gap:15px;width:100%}.psupsellmaster-section-actions .psupsellmaster-btn-delete-campaign,.psupsellmaster-section-actions .psupsellmaster-btn-save-campaign{margin:0;width:100%}.psupsellmaster-section-actions .psupsellmaster-btn-save-campaign{padding:10px 50px}.button.psupsellmaster-btn-danger{background-color:#d33;border-color:#9d1616;color:#fff}.button.psupsellmaster-btn-danger:hover{background-color:#c31d1d;border-color:#770a0a;color:#fff}.button.psupsellmaster-btn-danger:active,.button.psupsellmaster-btn-danger:focus{background:#b11414;border-color:#ee4a4a;box-shadow:0 0 0 1px #ee4a4a;color:#fff}.psupsellmaster-tab-section.ui-tabs-panel{padding:10px}.psupsellmaster-tabs .psupsellmaster-link{color:#2271b1}.psupsellmaster-tabs .psupsellmaster-tab-reset{background-color:red;text-align:center}.psupsellmaster-tabs .psupsellmaster-tab-reset .psupsellmaster-btn-reset{color:#fff}.psupsellmaster-tabs-vertical{display:flex;flex-direction:column;padding:0}.psupsellmaster-tabs-vertical>.psupsellmaster-tabs-header{background-color:#fafafa;border:none;display:flex;flex-direction:column;padding:0}.psupsellmaster-tabs-vertical>.psupsellmaster-tab-section{flex-grow:1}.psupsellmaster-tabs-vertical>.psupsellmaster-tabs-header .psupsellmaster-tab{border:none;border-bottom:1px solid #eee;border-radius:0;box-sizing:border-box;margin:0}.psupsellmaster-tabs-vertical>.psupsellmaster-tabs-header .psupsellmaster-tab:first-child{border-top-left-radius:3px;border-top-right-radius:3px}.psupsellmaster-tabs-vertical>.psupsellmaster-tabs-header .psupsellmaster-tab .ui-tabs-anchor{box-sizing:border-box;padding:10px 20px;width:100%}.psupsellmaster-tabs-vertical .psupsellmaster-tabs-header .psupsellmaster-tab.ui-state-disabled .ui-tabs-anchor,.psupsellmaster-tabs-vertical .psupsellmaster-tabs-header .psupsellmaster-tab.ui-tabs-active .ui-tabs-anchor,.psupsellmaster-tabs-vertical .psupsellmaster-tabs-header .psupsellmaster-tab.ui-tabs-loading .ui-tabs-anchor{cursor:pointer}.psupsellmaster-tabs:not(.psupsellmaster-tabs-vertical) .ui-widget-header{background:0 0;border-radius:0;border-width:0 0 1px;padding:0}.psupsellmaster-repeater-rows{border:0 solid #eee;border-width:1px 0;margin:10px 0}.psupsellmaster-repeater-row{align-items:flex-end;display:flex;flex-wrap:wrap;gap:15px;padding:10px 0}.psupsellmaster-repeater-row:not(:last-child){border-bottom:1px solid #eee}.psupsellmaster-repeater-btn.button{padding:0 15px;width:100%}.psupsellmaster-banner-image{display:block;height:auto;max-width:100%}.psupsellmaster-banner-actions{display:flex;flex-wrap:wrap;gap:5px;margin-top:5px}.psupsellmaster-form-container,.psupsellmaster-form-rows{display:flex;flex-direction:column;gap:15px}.psupsellmaster-form-row{align-items:flex-end;display:flex;flex-wrap:wrap;gap:15px}.psupsellmaster-form-col{display:flex;flex:1;flex-direction:column;gap:5px;justify-content:space-between}.psupsellmaster-form-field{display:flex;flex-basis:100%;flex-direction:column}.psupsellmaster-form-field-radio{align-items:center;display:flex;gap:15px;min-height:30px}.psupsellmaster-form-field-coupons-flag{display:flex;flex-direction:column}.psupsellmaster-form-field-locations-flag,.psupsellmaster-form-field-products-flag{flex-direction:row;gap:15px}.psupsellmaster-form-field-description .mce-edit-area>iframe{min-height:150px}select.psupsellmaster-field{max-width:100%}.psupsellmaster-form-warning{flex-basis:100%}.psupsellmaster-sections .wp-editor-tabs{float:left}.psupsellmaster-sections .wp-switch-editor{margin:5px 5px 0 0}.psupsellmaster-datatable-wrapper .psupsellmaster-list .psupsellmaster-item-action.psupsellmaster-unassign-post-term{color:#b32d2e}@media (min-width:768px){input.psupsellmaster-field:not([type=checkbox]):not([type=radio]),select.psupsellmaster-field{min-height:30px}}@media (min-width:992px){.psupsellmaster-banner-actions .button,.psupsellmaster-section-actions .psupsellmaster-action-delete-campaign,.psupsellmaster-section-actions .psupsellmaster-action-save-campaign,.psupsellmaster-section-actions .psupsellmaster-btn-delete-campaign,.psupsellmaster-section-actions .psupsellmaster-btn-save-campaign{width:auto}.psupsellmaster-tabs-vertical{flex-direction:row}.psupsellmaster-tabs-vertical>.psupsellmaster-tabs-header{border-right:1px solid #eee}.psupsellmaster-tabs-vertical>.psupsellmaster-tabs-header .psupsellmaster-tab:first-child{border-top-right-radius:0}.psupsellmaster-tabs-vertical>.psupsellmaster-tabs-header .psupsellmaster-tab:last-child{border-bottom-left-radius:3px}.psupsellmaster-tabs-vertical>.psupsellmaster-tabs-header .psupsellmaster-tab-reset{margin-top:auto}.psupsellmaster-repeater-row-content{width:calc(100% - 115px)}.psupsellmaster-repeater-row-actions{width:100px}.psupsellmaster-section-general .psupsellmaster-form-field,.psupsellmaster-section-locations .psupsellmaster-form-field,.psupsellmaster-section-product-page .psupsellmaster-form-field,.psupsellmaster-subsection-products-selection .psupsellmaster-form-field{flex-grow:1}.psupsellmaster-subsection-products-selection .psupsellmaster-form-field-prices-max,.psupsellmaster-subsection-products-selection .psupsellmaster-form-field-prices-min,.psupsellmaster-subsection-products-selection .psupsellmaster-form-field-products-type{flex-grow:0}.psupsellmaster-section-general .psupsellmaster-form-field-title{flex-grow:3;min-width:200px}.psupsellmaster-section-general .psupsellmaster-form-field-end-date,.psupsellmaster-section-general .psupsellmaster-form-field-start-date,.psupsellmaster-section-general .psupsellmaster-form-field-status{flex-grow:2;min-width:100px}.psupsellmaster-section-general .psupsellmaster-form-field-priority{min-width:80px}.psupsellmaster-section-general .psupsellmaster-form-field-weekdays{flex-grow:4;min-width:200px}.psupsellmaster-subsection-coupons .psupsellmaster-form-field-coupon-code,.psupsellmaster-subsection-coupons .psupsellmaster-form-field-standard-coupon-id{min-width:300px}.psupsellmaster-form-field{flex-basis:auto}}
     1.psupsellmaster-notice,.psupsellmaster-section{background:#fff;padding:15px;box-sizing:border-box;width:100%}.psupsellmaster-wrap .page-title-action{display:inline-block}.psupsellmaster-wrap .psupsellmaster-warning{color:red}.psupsellmaster-sections{display:flex;flex-wrap:wrap;gap:15px;margin-top:15px}.psupsellmaster-section{border:1px solid #ddd;border-radius:5px;flex-grow:1}.psupsellmaster-section .psupsellmaster-section-title{margin:0 0 5px}.psupsellmaster-section .psupsellmaster-section-subtitle{margin:0 0 15px}.psupsellmaster-section .psupsellmaster-separator{margin:15px 0}.psupsellmaster-subsections{display:flex;flex-direction:column;gap:30px}.psupsellmaster-notices{display:flex;flex-direction:column;gap:10px;margin:0;width:100%}.psupsellmaster-notice{border:1px solid #ddd;border-radius:5px;margin:0}.psupsellmaster-form-edit-campaign>.psupsellmaster-notices,.psupsellmaster-section .psupsellmaster-tabs,.psupsellmaster-section-products .psupsellmaster-subsection-update-tags .psupsellmaster-notices{margin-top:15px}.psupsellmaster-tab-section .psupsellmaster-notices:first-child{margin-bottom:15px}.psupsellmaster-section-general .psupsellmaster-form-group{align-items:flex-start;display:flex;gap:15px;width:100%}.psupsellmaster-section-general .psupsellmaster-form-group>.psupsellmaster-form-field{padding-top:1.4em}.psupsellmaster-banner-actions .button,.psupsellmaster-form-field-synced-tags,.psupsellmaster-repeater-row-actions,.psupsellmaster-repeater-row-content,.psupsellmaster-section-general .psupsellmaster-form-options{width:100%}.psupsellmaster-section-products .psupsellmaster-subsection-products-selection .psupsellmaster-tabs .psupsellmaster-tabs,.psupsellmaster-section-promotion-conditions .psupsellmaster-subsection .psupsellmaster-tabs .psupsellmaster-tabs{margin-top:0}.psupsellmaster-section-actions{display:flex;flex-wrap:wrap;gap:15px;justify-content:space-between;width:100%}.psupsellmaster-section-actions .psupsellmaster-action-save-campaign{margin-left:auto;width:100%}.psupsellmaster-section-actions .psupsellmaster-action-delete-campaign{align-items:center;display:flex;flex-wrap:wrap;gap:15px;width:100%}.psupsellmaster-section-actions .psupsellmaster-btn-delete-campaign,.psupsellmaster-section-actions .psupsellmaster-btn-save-campaign{margin:0;width:100%}.psupsellmaster-section-actions .psupsellmaster-btn-save-campaign{padding:10px 50px}.button.psupsellmaster-btn-danger{background-color:#d33;border-color:#9d1616;color:#fff}.button.psupsellmaster-btn-danger:hover{background-color:#c31d1d;border-color:#770a0a;color:#fff}.button.psupsellmaster-btn-danger:active,.button.psupsellmaster-btn-danger:focus{background:#b11414;border-color:#ee4a4a;box-shadow:0 0 0 1px #ee4a4a;color:#fff}.psupsellmaster-tab-section.ui-tabs-panel{padding:10px}.psupsellmaster-tabs .psupsellmaster-link{color:#2271b1}.psupsellmaster-tabs .psupsellmaster-tab-reset{background-color:red;text-align:center}.psupsellmaster-tabs .psupsellmaster-tab-reset .psupsellmaster-btn-reset{color:#fff}.psupsellmaster-tabs-vertical{display:flex;flex-direction:column;padding:0}.psupsellmaster-tabs-vertical>.psupsellmaster-tabs-header{background-color:#fafafa;border:none;display:flex;flex-direction:column;padding:0}.psupsellmaster-tabs-vertical>.psupsellmaster-tab-section{flex-grow:1}.psupsellmaster-tabs-vertical>.psupsellmaster-tabs-header .psupsellmaster-tab{border:none;border-bottom:1px solid #eee;border-radius:0;box-sizing:border-box;margin:0}.psupsellmaster-tabs-vertical>.psupsellmaster-tabs-header .psupsellmaster-tab:first-child{border-top-left-radius:3px;border-top-right-radius:3px}.psupsellmaster-tabs-vertical>.psupsellmaster-tabs-header .psupsellmaster-tab .ui-tabs-anchor{box-sizing:border-box;padding:10px 20px;width:100%}.psupsellmaster-tabs-vertical .psupsellmaster-tabs-header .psupsellmaster-tab.ui-state-disabled .ui-tabs-anchor,.psupsellmaster-tabs-vertical .psupsellmaster-tabs-header .psupsellmaster-tab.ui-tabs-active .ui-tabs-anchor,.psupsellmaster-tabs-vertical .psupsellmaster-tabs-header .psupsellmaster-tab.ui-tabs-loading .ui-tabs-anchor{cursor:pointer}.psupsellmaster-tabs:not(.psupsellmaster-tabs-vertical) .ui-widget-header{background:0 0;border-radius:0;border-width:0 0 1px;padding:0}.psupsellmaster-repeater-rows{border:0 solid #eee;border-width:1px 0;margin:10px 0}.psupsellmaster-repeater-row{align-items:flex-end;display:flex;flex-wrap:wrap;gap:15px;padding:10px 0}.psupsellmaster-repeater-row:not(:last-child){border-bottom:1px solid #eee}.psupsellmaster-repeater-btn.button{padding:0 15px;width:100%}.psupsellmaster-banner-image{display:block;height:auto;max-width:100%}.psupsellmaster-banner-actions{display:flex;flex-wrap:wrap;gap:5px;margin-top:5px}.psupsellmaster-form-container,.psupsellmaster-form-rows{display:flex;flex-direction:column;gap:15px}.psupsellmaster-form-row{align-items:flex-end;display:flex;flex-wrap:wrap;gap:15px}.psupsellmaster-form-col{display:flex;flex:1;flex-direction:column;gap:5px;justify-content:space-between}.psupsellmaster-form-field{display:flex;flex-basis:100%;flex-direction:column}.psupsellmaster-form-field-radio{align-items:center;display:flex;gap:15px;min-height:30px}.psupsellmaster-form-field-coupons-flag{display:flex;flex-direction:column}.psupsellmaster-form-field-locations-flag,.psupsellmaster-form-field-products-flag{flex-direction:row;gap:15px}.psupsellmaster-form-field-description .mce-edit-area>iframe{min-height:150px}select.psupsellmaster-field{max-width:100%}.psupsellmaster-form-warning{flex-basis:100%}.psupsellmaster-subsection-update-tags .psupsellmaster-form-actions{align-items:center;display:flex}.psupsellmaster-sections .wp-editor-tabs{float:left}.psupsellmaster-sections .wp-switch-editor{margin:5px 5px 0 0}.psupsellmaster-datatable-wrapper .psupsellmaster-list .psupsellmaster-item-action.psupsellmaster-unassign-post-term{color:#b32d2e}@media (min-width:768px){input.psupsellmaster-field:not([type=checkbox]):not([type=radio]),select.psupsellmaster-field{min-height:30px}}@media (min-width:992px){.psupsellmaster-banner-actions .button,.psupsellmaster-section-actions .psupsellmaster-action-delete-campaign,.psupsellmaster-section-actions .psupsellmaster-action-save-campaign,.psupsellmaster-section-actions .psupsellmaster-btn-delete-campaign,.psupsellmaster-section-actions .psupsellmaster-btn-save-campaign{width:auto}.psupsellmaster-tabs-vertical{flex-direction:row}.psupsellmaster-tabs-vertical>.psupsellmaster-tabs-header{border-right:1px solid #eee}.psupsellmaster-tabs-vertical>.psupsellmaster-tabs-header .psupsellmaster-tab:first-child{border-top-right-radius:0}.psupsellmaster-tabs-vertical>.psupsellmaster-tabs-header .psupsellmaster-tab:last-child{border-bottom-left-radius:3px}.psupsellmaster-tabs-vertical>.psupsellmaster-tabs-header .psupsellmaster-tab-reset{margin-top:auto}.psupsellmaster-repeater-row-content{width:calc(100% - 115px)}.psupsellmaster-repeater-row-actions{width:100px}.psupsellmaster-section-general .psupsellmaster-form-field,.psupsellmaster-section-locations .psupsellmaster-form-field,.psupsellmaster-section-product-page .psupsellmaster-form-field,.psupsellmaster-subsection-products-selection .psupsellmaster-form-field{flex-grow:1}.psupsellmaster-subsection-products-selection .psupsellmaster-form-field-prices-max,.psupsellmaster-subsection-products-selection .psupsellmaster-form-field-prices-min,.psupsellmaster-subsection-products-selection .psupsellmaster-form-field-products-type{flex-grow:0}.psupsellmaster-section-general .psupsellmaster-form-field-title{flex-grow:3;min-width:200px}.psupsellmaster-section-general .psupsellmaster-form-field-end-date,.psupsellmaster-section-general .psupsellmaster-form-field-start-date,.psupsellmaster-section-general .psupsellmaster-form-field-status{flex-grow:2;min-width:100px}.psupsellmaster-section-general .psupsellmaster-form-field-priority{min-width:80px}.psupsellmaster-section-general .psupsellmaster-form-field-weekdays{flex-grow:4;min-width:200px}.psupsellmaster-subsection-coupons .psupsellmaster-form-field-coupon-code,.psupsellmaster-subsection-coupons .psupsellmaster-form-field-standard-coupon-id{min-width:300px}.psupsellmaster-form-field{flex-basis:auto}}
  • psupsellmaster/trunk/assets/css/admin/datatables.css

    r3060205 r3192288  
    172172.psupsellmaster-datatable-wrapper .psupsellmaster-list .psupsellmaster-item:hover .psupsellmaster-item-actions {
    173173    display: flex;
     174    gap: 2px;
    174175}
    175176
  • psupsellmaster/trunk/assets/css/admin/datatables.min.css

    r3060205 r3192288  
    1 .psupsellmaster-datatable-wrapper .dt-container{align-items:flex-start;display:flex;flex-wrap:wrap;row-gap:10px}.psupsellmaster-datatable-wrapper .psupsellmaster-bulk-actions{display:flex;flex-basis:100%;flex-wrap:wrap;gap:10px}.psupsellmaster-datatable-wrapper .psupsellmaster-btn-apply-bulk-action,.psupsellmaster-datatable-wrapper .psupsellmaster-field-bulk-actions{display:block;flex-basis:calc(50% - 2.5px);flex-grow:1;margin:0}.psupsellmaster-datatable-wrapper .dt-buttons,.psupsellmaster-datatable-wrapper .dt-info,.psupsellmaster-datatable-wrapper .dt-length,.psupsellmaster-datatable-wrapper .dt-paging,.psupsellmaster-datatable-wrapper .dt-search{flex:1 1 100%}.psupsellmaster-datatable-wrapper .dt-buttons{display:flex;flex-wrap:wrap;gap:10px}.psupsellmaster-datatable-wrapper .dt-buttons .dt-button{flex-basis:calc(50% - 5px);margin:0}.psupsellmaster-datatable-wrapper .dt-buttons .psupsellmaster-extra-buttons{display:flex;flex-basis:100%;flex-grow:1}.psupsellmaster-datatable-wrapper .dt-buttons .psupsellmaster-extra-buttons .dt-button{flex-grow:1}.psupsellmaster-datatable-wrapper .dt-search{align-items:center;display:flex;flex-basis:100%;gap:5px;margin:0}.psupsellmaster-datatable-wrapper .dt-search .dt-input{margin:0;padding:0 8px;width:300px}.psupsellmaster-datatable-wrapper .dt-length{align-items:center;display:flex;flex-basis:100%;gap:5px;text-align:right}.psupsellmaster-datatable-wrapper .dt-length .dt-input{flex-grow:1;margin:0;min-width:80px;padding:0 24px 0 8px}.psupsellmaster-datatable-wrapper .dt-info{text-align:center}.psupsellmaster-datatable-wrapper .dt-paging{display:flex;flex-grow:1;justify-content:center;text-align:right}.psupsellmaster-datatable-wrapper .dataTable{flex-basis:100%}.psupsellmaster-datatable-wrapper .psupsellmaster-datatable-row:nth-child(odd){background:#f9f9f9}.psupsellmaster-datatable-wrapper .psupsellmaster-datatable-row:hover{background:#f6f6f6}.psupsellmaster-datatable-wrapper .psupsellmaster-datatable-col{vertical-align:top}.psupsellmaster-datatable-wrapper .psupsellmaster-row-actions{color:#999;display:flex;left:0;position:relative}.psupsellmaster-datatable-wrapper .psupsellmaster-link,.psupsellmaster-datatable-wrapper .psupsellmaster-list .psupsellmaster-item-action,.psupsellmaster-datatable-wrapper .psupsellmaster-row-action,.psupsellmaster-datatable-wrapper .psupsellmaster-toggle-details{text-decoration:none}.psupsellmaster-datatable-wrapper .psupsellmaster-row-details{margin-top:5px}.psupsellmaster-datatable-wrapper tr.child ul.dtr-details{width:100%}.psupsellmaster-datatable-wrapper .psupsellmaster-list .psupsellmaster-item:hover .psupsellmaster-item-actions,.psupsellmaster-datatable-wrapper tr.child ul.dtr-details li{display:flex}.psupsellmaster-datatable-wrapper tr.child ul.dtr-details li .dtr-title{flex-shrink:1;width:40%}.psupsellmaster-datatable-wrapper .psupsellmaster-list{margin:0}.psupsellmaster-datatable-wrapper .psupsellmaster-list .psupsellmaster-item .psupsellmaster-item-actions{color:#999;display:none}@media (min-width:992px){.psupsellmaster-datatable-wrapper .psupsellmaster-bulk-actions{flex-basis:auto;flex-wrap:nowrap}.psupsellmaster-datatable-wrapper .dt-buttons .psupsellmaster-extra-buttons,.psupsellmaster-datatable-wrapper .psupsellmaster-btn-apply-bulk-action,.psupsellmaster-datatable-wrapper .psupsellmaster-field-bulk-actions{flex-basis:auto;flex-grow:0}.psupsellmaster-datatable-wrapper .dt-buttons,.psupsellmaster-datatable-wrapper .dt-info,.psupsellmaster-datatable-wrapper .dt-length,.psupsellmaster-datatable-wrapper .dt-paging,.psupsellmaster-datatable-wrapper .dt-search{flex:1 1 50%}.psupsellmaster-datatable-wrapper .dt-buttons~.dt-search,.psupsellmaster-datatable-wrapper .dt-search~.dt-length{flex:1 1 1px}.psupsellmaster-datatable-wrapper .dt-buttons,.psupsellmaster-datatable-wrapper .dt-info{justify-content:flex-start}.psupsellmaster-datatable-wrapper .dt-length,.psupsellmaster-datatable-wrapper .dt-paging,.psupsellmaster-datatable-wrapper .dt-search{justify-content:flex-end}.psupsellmaster-datatable-wrapper .dt-buttons{gap:5px}.psupsellmaster-datatable-wrapper .dt-buttons .dt-button{flex-basis:auto}.psupsellmaster-datatable-wrapper .dt-length,.psupsellmaster-datatable-wrapper .dt-length .dt-input{flex-grow:0}.psupsellmaster-datatable-wrapper .dt-info{text-align:left}.psupsellmaster-datatable-wrapper .psupsellmaster-datatable-row .psupsellmaster-on-hover,.psupsellmaster-datatable-wrapper .psupsellmaster-row-details{display:none}.psupsellmaster-datatable-wrapper .psupsellmaster-datatable-row:hover .psupsellmaster-on-hover{display:block}.psupsellmaster-datatable-wrapper .psupsellmaster-datatable-row .psupsellmaster-row-actions{left:-9999rem}.psupsellmaster-datatable-wrapper .psupsellmaster-datatable-row:hover .psupsellmaster-row-actions{left:0}}
     1.psupsellmaster-datatable-wrapper .dt-container{align-items:flex-start;display:flex;flex-wrap:wrap;row-gap:10px}.psupsellmaster-datatable-wrapper .psupsellmaster-bulk-actions{display:flex;flex-basis:100%;flex-wrap:wrap;gap:10px}.psupsellmaster-datatable-wrapper .psupsellmaster-btn-apply-bulk-action,.psupsellmaster-datatable-wrapper .psupsellmaster-field-bulk-actions{display:block;flex-basis:calc(50% - 2.5px);flex-grow:1;margin:0}.psupsellmaster-datatable-wrapper .dt-buttons,.psupsellmaster-datatable-wrapper .dt-info,.psupsellmaster-datatable-wrapper .dt-length,.psupsellmaster-datatable-wrapper .dt-paging,.psupsellmaster-datatable-wrapper .dt-search{flex:1 1 100%}.psupsellmaster-datatable-wrapper .dt-buttons{display:flex;flex-wrap:wrap;gap:10px}.psupsellmaster-datatable-wrapper .dt-buttons .dt-button{flex-basis:calc(50% - 5px);margin:0}.psupsellmaster-datatable-wrapper .dt-buttons .psupsellmaster-extra-buttons{display:flex;flex-basis:100%;flex-grow:1}.psupsellmaster-datatable-wrapper .dt-buttons .psupsellmaster-extra-buttons .dt-button{flex-grow:1}.psupsellmaster-datatable-wrapper .dt-search{align-items:center;display:flex;flex-basis:100%;gap:5px;margin:0}.psupsellmaster-datatable-wrapper .dt-search .dt-input{margin:0;padding:0 8px;width:300px}.psupsellmaster-datatable-wrapper .dt-length{align-items:center;display:flex;flex-basis:100%;gap:5px;text-align:right}.psupsellmaster-datatable-wrapper .dt-length .dt-input{flex-grow:1;margin:0;min-width:80px;padding:0 24px 0 8px}.psupsellmaster-datatable-wrapper .dt-info{text-align:center}.psupsellmaster-datatable-wrapper .dt-paging{display:flex;flex-grow:1;justify-content:center;text-align:right}.psupsellmaster-datatable-wrapper .dataTable{flex-basis:100%}.psupsellmaster-datatable-wrapper .psupsellmaster-datatable-row:nth-child(odd){background:#f9f9f9}.psupsellmaster-datatable-wrapper .psupsellmaster-datatable-row:hover{background:#f6f6f6}.psupsellmaster-datatable-wrapper .psupsellmaster-datatable-col{vertical-align:top}.psupsellmaster-datatable-wrapper .psupsellmaster-row-actions{color:#999;display:flex;left:0;position:relative}.psupsellmaster-datatable-wrapper .psupsellmaster-link,.psupsellmaster-datatable-wrapper .psupsellmaster-list .psupsellmaster-item-action,.psupsellmaster-datatable-wrapper .psupsellmaster-row-action,.psupsellmaster-datatable-wrapper .psupsellmaster-toggle-details{text-decoration:none}.psupsellmaster-datatable-wrapper .psupsellmaster-row-details{margin-top:5px}.psupsellmaster-datatable-wrapper tr.child ul.dtr-details{width:100%}.psupsellmaster-datatable-wrapper tr.child ul.dtr-details li{display:flex}.psupsellmaster-datatable-wrapper tr.child ul.dtr-details li .dtr-title{flex-shrink:1;width:40%}.psupsellmaster-datatable-wrapper .psupsellmaster-list{margin:0}.psupsellmaster-datatable-wrapper .psupsellmaster-list .psupsellmaster-item .psupsellmaster-item-actions{color:#999;display:none}.psupsellmaster-datatable-wrapper .psupsellmaster-list .psupsellmaster-item:hover .psupsellmaster-item-actions{display:flex;gap:2px}@media (min-width:992px){.psupsellmaster-datatable-wrapper .psupsellmaster-bulk-actions{flex-basis:auto;flex-wrap:nowrap}.psupsellmaster-datatable-wrapper .dt-buttons .psupsellmaster-extra-buttons,.psupsellmaster-datatable-wrapper .psupsellmaster-btn-apply-bulk-action,.psupsellmaster-datatable-wrapper .psupsellmaster-field-bulk-actions{flex-basis:auto;flex-grow:0}.psupsellmaster-datatable-wrapper .dt-buttons,.psupsellmaster-datatable-wrapper .dt-info,.psupsellmaster-datatable-wrapper .dt-length,.psupsellmaster-datatable-wrapper .dt-paging,.psupsellmaster-datatable-wrapper .dt-search{flex:1 1 50%}.psupsellmaster-datatable-wrapper .dt-buttons~.dt-search,.psupsellmaster-datatable-wrapper .dt-search~.dt-length{flex:1 1 1px}.psupsellmaster-datatable-wrapper .dt-buttons,.psupsellmaster-datatable-wrapper .dt-info{justify-content:flex-start}.psupsellmaster-datatable-wrapper .dt-length,.psupsellmaster-datatable-wrapper .dt-paging,.psupsellmaster-datatable-wrapper .dt-search{justify-content:flex-end}.psupsellmaster-datatable-wrapper .dt-buttons{gap:5px}.psupsellmaster-datatable-wrapper .dt-buttons .dt-button{flex-basis:auto}.psupsellmaster-datatable-wrapper .dt-length,.psupsellmaster-datatable-wrapper .dt-length .dt-input{flex-grow:0}.psupsellmaster-datatable-wrapper .dt-info{text-align:left}.psupsellmaster-datatable-wrapper .psupsellmaster-datatable-row .psupsellmaster-on-hover,.psupsellmaster-datatable-wrapper .psupsellmaster-row-details{display:none}.psupsellmaster-datatable-wrapper .psupsellmaster-datatable-row:hover .psupsellmaster-on-hover{display:block}.psupsellmaster-datatable-wrapper .psupsellmaster-datatable-row .psupsellmaster-row-actions{left:-9999rem}.psupsellmaster-datatable-wrapper .psupsellmaster-datatable-row:hover .psupsellmaster-row-actions{left:0}}
  • psupsellmaster/trunk/assets/js/admin/campaigns/edit.js

    r3174351 r3192288  
    101101                    2500
    102102                );
    103             },
    104             onClickBtnAssignTags: function onClickBtnAssignTags( event ) {
    105                 // Get the button.
    106                 var button = $( this );
    107 
    108                 // Get the spinner.
    109                 var spinner = button.closest( '.psupsellmaster-form-btn' ).find( '.spinner' );
    110 
    111                 // Set the args.
    112                 var args = {
    113                     callbacks: {
    114                         beforeSend: function () {
    115                             // Disable the button.
    116                             button.prop( 'disabled', true );
    117 
    118                             // Add the class.
    119                             spinner.addClass( 'is-active' );
    120                         },
    121                         complete: function () {
    122                             // Reload the datatable.
    123                             PsUpsellmasterAdminCampaignsEdit.functions.reloadDataTable();
    124 
    125                             // Enable the button.
    126                             button.prop( 'disabled', false );
    127 
    128                             // Remove the class.
    129                             spinner.removeClass( 'is-active' );
    130                         },
    131                     },
    132                 };
    133 
    134                 // Assign the tags.
    135                 PsUpsellmasterAdminCampaignsEdit.functions.assignTags( args );
    136103            },
    137104            onClickBtnConfirmDeleteCampaign: function onClickBtnConfirmDeleteCampaign( event ) {
     
    311278                // Unassign the post term.
    312279                PsUpsellmasterAdminCampaignsEdit.functions.unassignPostTerms( args );
     280            },
     281            onClickBtnUpdateTags: function onClickBtnUpdateTags( event ) {
     282                // Get the button.
     283                var button = $( this );
     284
     285                // Get the spinner.
     286                var spinner = button.closest( '.psupsellmaster-form-btn' ).find( '.spinner' );
     287
     288                // Get the action.
     289                var action = button.attr( 'data-action' );
     290
     291                // Set the args.
     292                var args = {
     293                    callbacks: {
     294                        beforeSend: function () {
     295                            // Disable the button.
     296                            button.prop( 'disabled', true );
     297
     298                            // Add the class.
     299                            spinner.addClass( 'is-active' ).show();
     300                        },
     301                        complete: function () {
     302                            // Reload the datatable.
     303                            PsUpsellmasterAdminCampaignsEdit.functions.reloadDataTable();
     304
     305                            // Enable the button.
     306                            button.prop( 'disabled', false );
     307
     308                            // Remove the class.
     309                            spinner.removeClass( 'is-active' ).hide();
     310                        },
     311                    },
     312                    context: action,
     313                };
     314
     315                // Update the tags.
     316                PsUpsellmasterAdminCampaignsEdit.functions.updateTags( args );
    313317            },
    314318            onClickRepeaterBtnAdd: function onClickRepeaterBtnAdd( event ) {
     
    763767                // Refresh the select2.
    764768                PsUpsellmaster.select2.functions.refreshAll( { container: clone } );
    765             },
    766             assignTags: function assignTags( args ) {
    767                 // Get the section.
    768                 var productSelector = $( '.psupsellmaster-product-selector' );
    769 
    770                 // Get the options.
    771                 var options = PsUpsellmasterAdminCampaignsEdit.functions.getProductSelectorOptions( productSelector );
    772 
    773                 // Check the options.
    774                 if ( ! options ) {
    775                     return;
    776                 }
    777 
    778                 // Set the taxonomies.
    779                 var taxonomies = new Object();
    780 
    781                 // Loop through the fields.
    782                 $( '.psupsellmaster-subsection-assign-tags .psupsellmaster-field' ).each(
    783                     function () {
    784                         // Get the field.
    785                         var field = $( this );
    786 
    787                         // Get the value.
    788                         var value = field.val();
    789 
    790                         // Check the value.
    791                         if ( ! value ) {
    792                                 return;
    793                         }
    794 
    795                         // Get the taxonomy.
    796                         var taxonomy = field.attr( 'data-taxonomy' );
    797 
    798                         // Add the value to the list.
    799                         taxonomies[ taxonomy ] = value;
    800                     }
    801                 );
    802 
    803                 // Check the taxonomies.
    804                 if ( ! taxonomies ) {
    805                     return;
    806                 }
    807 
    808                 // Set the data.
    809                 var data = {
    810                     action: 'psupsellmaster_ajax_assign_multiple_product_terms',
    811                     nonce: PsUpsellmaster.attributes.ajax.nonce,
    812                     selectors: options,
    813                     taxonomies: taxonomies,
    814                 };
    815 
    816                 // Make the ajax request.
    817                 $.ajax(
    818                     {
    819                         type: 'post',
    820                         url: PsUpsellmaster.attributes.ajax.url,
    821                         data: data,
    822                         beforeSend: function ( xhr ) {
    823                             if ( args.callbacks && args.callbacks.beforeSend ) {
    824                                 args.callbacks.beforeSend( xhr );
    825                             }
    826                         },
    827                         success: function ( response ) {
    828                             if ( args.callbacks && args.callbacks.success ) {
    829                                 args.callbacks.success( response );
    830                             }
    831                         },
    832                         error: function ( xhr, status, error ) {
    833                             if ( args.callbacks && args.callbacks.error ) {
    834                                 args.callbacks.error( xhr, status, error );
    835                             }
    836                         },
    837                         complete: function ( xhr, status ) {
    838                             if ( args.callbacks && args.callbacks.complete ) {
    839                                 args.callbacks.complete( xhr, status );
    840                             }
    841                         },
    842                     }
    843                 );
    844769            },
    845770            deleteCampaigns: function deleteCampaigns( ids ) {
     
    12501175                $( document ).on( 'click', '.psupsellmaster-section-promotion-conditions .psupsellmaster-repeater-btn-remove', PsUpsellmasterAdminCampaignsEdit.events.onClickConditionRepeaterBtnRemove );
    12511176                $( document ).on( 'click', '.psupsellmaster-subsection-products-selection .psupsellmaster-repeater-btn-remove', PsUpsellmasterAdminCampaignsEdit.events.onClickProductRepeaterBtnRemove );
    1252                 $( document ).on( 'click', '.psupsellmaster-subsection-assign-tags .psupsellmaster-btn-assign-tags', PsUpsellmasterAdminCampaignsEdit.events.onClickBtnAssignTags );
     1177                $( document ).on( 'click', '.psupsellmaster-subsection-update-tags .psupsellmaster-btn-update-tags', PsUpsellmasterAdminCampaignsEdit.events.onClickBtnUpdateTags );
    12531178                $( document ).on( 'change', '.psupsellmaster-field-coupons-flag', PsUpsellmasterAdminCampaignsEdit.events.onChangeFieldCouponsFlag );
    12541179                $( document ).on( 'change', '.psupsellmaster-field-products-flag', PsUpsellmasterAdminCampaignsEdit.events.onChangeFieldProductsFlag );
     
    16321557                }
    16331558            },
    1634             run: function run() {
    1635                 // Focus on the title field.
    1636                 $( '.psupsellmaster-section-general .psupsellmaster-form-field-title .psupsellmaster-field' ).trigger( 'focus' );
    1637             },
    1638             setDataTableSource: function setDataTableSource( source ) {
    1639                 // Get the wrapper.
    1640                 var wrapper = $( '.psupsellmaster-datatable-wrapper' );
    1641 
    1642                 // Set the source.
    1643                 wrapper.attr( 'data-source', source );
    1644             },
    1645             startDataTables: function startDataTables() {
    1646                 // Start new datatable.
    1647                 PsUpsellmasterAdminCampaignsEdit.instances.datatables.main = $( '#psupsellmaster-datatable-eligible-products' ).DataTable( PsUpsellmasterAdminCampaignsEdit.settings.datatables.custom.main );
    1648             },
    1649             startPikadayFields: function startPikadayField() {
    1650                 // Get the fields.
    1651                 var fields = $( '.psupsellmaster-field-pikaday' );
     1559            updateTags: function updateTags( args ) {
     1560                // Get the section.
     1561                var productSelector = $( '.psupsellmaster-product-selector' );
     1562
     1563                // Get the options.
     1564                var options = PsUpsellmasterAdminCampaignsEdit.functions.getProductSelectorOptions( productSelector );
     1565
     1566                // Check the options.
     1567                if ( ! options ) {
     1568                    return;
     1569                }
     1570
     1571                // Set the taxonomies.
     1572                var taxonomies = new Object();
    16521573
    16531574                // Loop through the fields.
    1654                 fields.each(
     1575                $( '.psupsellmaster-subsection-update-tags .psupsellmaster-field' ).each(
    16551576                    function () {
    1656                         var field;
    1657 
    16581577                        // Get the field.
    1659                         field = $( this );
    1660 
    1661                         // Start the pikaday for this field.
    1662                         PsUpsellmasterAdminCampaignsEdit.functions.startPikadayField( field );
    1663                     }
    1664                 );
    1665             },
    1666             startPikadayField: function startPikadayField( field ) {
    1667                 var settings;
    1668 
    1669                 // Set the settings.
    1670                 settings = {
    1671                     field: field.get( 0 ),
    1672                     format: 'YYYY/MM/DD',
    1673                 };
    1674 
    1675                 // Start the pikaday.
    1676                 new Pikaday( settings );
    1677             },
    1678             startTabs: function startTabs() {
    1679                 // Start the tabs.
    1680                 $( '.psupsellmaster-tabs' ).tabs(
    1681                     {
    1682                         beforeActivate: PsUpsellmasterAdminCampaignsEdit.events.onTabsBeforeActivate,
    1683                     }
    1684                 );
    1685 
    1686                 // Show the tabs.
    1687                 $( '.psupsellmaster-tabs' ).show();
    1688             },
    1689             unassignPostTerms: function unassignPostTerms( args ) {
     1578                        var field = $( this );
     1579
     1580                        // Get the value.
     1581                        var value = field.val();
     1582
     1583                        // Check the value.
     1584                        if ( ! value ) {
     1585                            return;
     1586                        }
     1587
     1588                        // Get the taxonomy.
     1589                        var taxonomy = field.attr( 'data-taxonomy' );
     1590
     1591                        // Add the value to the list.
     1592                        taxonomies[ taxonomy ] = value;
     1593                    }
     1594                );
     1595
     1596                // Check the taxonomies.
     1597                if ( ! taxonomies ) {
     1598                    return;
     1599                }
     1600
    16901601                // Set the data.
    16911602                var data = {
    1692                     action: 'psupsellmaster_ajax_unassign_post_terms',
     1603                    action: 'psupsellmaster_ajax_update_multiple_product_terms',
    16931604                    nonce: PsUpsellmaster.attributes.ajax.nonce,
    1694                     post_id: args.postId,
    1695                     taxonomy: args.taxonomy,
    1696                     term_ids: args.termIds,
     1605                    context: args.context,
     1606                    selectors: options,
     1607                    taxonomies: taxonomies,
    16971608                };
    16981609
     
    17261637                );
    17271638            },
     1639            run: function run() {
     1640                // Focus on the title field.
     1641                $( '.psupsellmaster-section-general .psupsellmaster-form-field-title .psupsellmaster-field' ).trigger( 'focus' );
     1642            },
     1643            setDataTableSource: function setDataTableSource( source ) {
     1644                // Get the wrapper.
     1645                var wrapper = $( '.psupsellmaster-datatable-wrapper' );
     1646
     1647                // Set the source.
     1648                wrapper.attr( 'data-source', source );
     1649            },
     1650            startDataTables: function startDataTables() {
     1651                // Start new datatable.
     1652                PsUpsellmasterAdminCampaignsEdit.instances.datatables.main = $( '#psupsellmaster-datatable-eligible-products' ).DataTable( PsUpsellmasterAdminCampaignsEdit.settings.datatables.custom.main );
     1653            },
     1654            startPikadayFields: function startPikadayField() {
     1655                // Get the fields.
     1656                var fields = $( '.psupsellmaster-field-pikaday' );
     1657
     1658                // Loop through the fields.
     1659                fields.each(
     1660                    function () {
     1661                        var field;
     1662
     1663                        // Get the field.
     1664                        field = $( this );
     1665
     1666                        // Start the pikaday for this field.
     1667                        PsUpsellmasterAdminCampaignsEdit.functions.startPikadayField( field );
     1668                    }
     1669                );
     1670            },
     1671            startPikadayField: function startPikadayField( field ) {
     1672                var settings;
     1673
     1674                // Set the settings.
     1675                settings = {
     1676                    field: field.get( 0 ),
     1677                    format: 'YYYY/MM/DD',
     1678                };
     1679
     1680                // Start the pikaday.
     1681                new Pikaday( settings );
     1682            },
     1683            startTabs: function startTabs() {
     1684                // Start the tabs.
     1685                $( '.psupsellmaster-tabs' ).tabs(
     1686                    {
     1687                        beforeActivate: PsUpsellmasterAdminCampaignsEdit.events.onTabsBeforeActivate,
     1688                    }
     1689                );
     1690
     1691                // Show the tabs.
     1692                $( '.psupsellmaster-tabs' ).show();
     1693            },
     1694            unassignPostTerms: function unassignPostTerms( args ) {
     1695                // Set the data.
     1696                var data = {
     1697                    action: 'psupsellmaster_ajax_unassign_post_terms',
     1698                    nonce: PsUpsellmaster.attributes.ajax.nonce,
     1699                    post_id: args.postId,
     1700                    taxonomy: args.taxonomy,
     1701                    term_ids: args.termIds,
     1702                };
     1703
     1704                // Make the ajax request.
     1705                $.ajax(
     1706                    {
     1707                        type: 'post',
     1708                        url: PsUpsellmaster.attributes.ajax.url,
     1709                        data: data,
     1710                        beforeSend: function ( xhr ) {
     1711                            if ( args.callbacks && args.callbacks.beforeSend ) {
     1712                                args.callbacks.beforeSend( xhr );
     1713                            }
     1714                        },
     1715                        success: function ( response ) {
     1716                            if ( args.callbacks && args.callbacks.success ) {
     1717                                args.callbacks.success( response );
     1718                            }
     1719                        },
     1720                        error: function ( xhr, status, error ) {
     1721                            if ( args.callbacks && args.callbacks.error ) {
     1722                                args.callbacks.error( xhr, status, error );
     1723                            }
     1724                        },
     1725                        complete: function ( xhr, status ) {
     1726                            if ( args.callbacks && args.callbacks.complete ) {
     1727                                args.callbacks.complete( xhr, status );
     1728                            }
     1729                        },
     1730                    }
     1731                );
     1732            },
    17281733        },
    17291734    };
  • psupsellmaster/trunk/assets/js/admin/campaigns/edit.min.js

    r3174351 r3192288  
    1 !function(e){var t;(t={attributes:{},events:{onChangeAnyLocationsSectionField:function e(a){t.functions.updateLocationTabsCount()},onChangeAnyProductField:function t(a){e(document).trigger("change.psupsellmaster.section-products")},onChangeAnyProductFieldSelect2:function e(a){t.functions.updateProductTabsCount()},onChangeAnyConditionFieldSelect2:function e(a){t.functions.updateConditionTabsCount()},onChangeFieldCouponsFlag:function t(a){var s=e(this),n=s.val(),l=s.closest(".psupsellmaster-form-rows").find(".psupsellmaster-form-warning"),i=s.closest(".psupsellmaster-subsection-coupons"),r=i.find(".psupsellmaster-form-field-coupon-code"),o=i.find(".psupsellmaster-form-field-standard-coupon-id");"campaign"===n?(l.hide(),o.hide(),r.show()):(l.show(),r.hide(),o.show())},onChangeFieldLocations:function e(a){t.functions.updateLocationTabsDisplay()},onChangeFieldLocationsFlag:function e(a){t.functions.maybeToggleLocationOptions(),t.functions.updateLocationTabsDisplay()},onChangeFieldProductsFlag:function e(a){t.functions.maybeToggleProductOptions()},onChangeSectionProducts:function e(a){clearTimeout(t.timers.datatables.main),t.functions.setDataTableSource("preview"),t.timers.datatables.main=setTimeout(function(){t.functions.reloadDataTable()},2500)},onClickBtnAssignTags:function a(s){var n=e(this),l=n.closest(".psupsellmaster-form-btn").find(".spinner");t.functions.assignTags({callbacks:{beforeSend:function(){n.prop("disabled",!0),l.addClass("is-active")},complete:function(){t.functions.reloadDataTable(),n.prop("disabled",!1),l.removeClass("is-active")}}})},onClickBtnConfirmDeleteCampaign:function t(a){var s=e(this),n=s.closest(".psupsellmaster-action").find(".psupsellmaster-btn-delete-campaign");s.is(":checked")?n.prop("disabled",!1):n.prop("disabled",!0)},onClickBtnCopyBannerURL:function t(a){a.preventDefault();var s=e(this).closest(".psupsellmaster-form-field").find(".psupsellmaster-field-banner-url");PsUpsellmaster.functions.copyToClipboard(s.val())},onClickBtnDataTableRefresh:function e(a){a.preventDefault(),t.functions.setDataTableSource("preview"),t.functions.reloadDataTable()},onClickBtnDeleteCampaign:function a(s){s.preventDefault();var n=e(this).attr("data-campaign-id");t.functions.deleteCampaigns(Array(n))},onClickBtnDuplicateCampaign:function a(s){s.preventDefault();var n=e(this).attr("data-campaign-id");t.functions.duplicateCampaigns(Array(n))},onClickBtnSelectBanner:function a(s){s.preventDefault();var n=e(this),l={button:{title:t.data.texts.wp_media_btn_title},multiple:!1,title:t.data.texts.wp_media_frame_title},i=wp.media(l);i.on("select",function(){t.events.onSelectBanner(i,n)}),i.open()},onClickBtnRemoveBanner:function a(s){s.preventDefault();var n=e(this),l=n.closest(".psupsellmaster-form-field");l.find(".psupsellmaster-field-banner-id").val(""),l.find(".psupsellmaster-field-banner-url").val("");var i=l.attr("data-banner-type"),r=n.closest(".psupsellmaster-form-edit-campaign").find(".psupsellmaster-defaults"),o=r.find(".psupsellmaster-default-"+i+"-banner-url").val(),p=r.find(".psupsellmaster-default-banner-title").val(),c=r.find(".psupsellmaster-default-"+i+"-banner-height").val(),u=r.find(".psupsellmaster-default-"+i+"-banner-width").val();l.find(".psupsellmaster-banner-image").attr("src",o),l.find(".psupsellmaster-banner-image").attr("alt",p),l.find(".psupsellmaster-banner-image").attr("height",c),l.find(".psupsellmaster-banner-image").attr("width",u),t.functions.updateLocationTabsCount()},onClickBtnUnassignPostTerm:function a(s){s.preventDefault();var n,l=e(this),i=l.attr("data-post-id"),r={postId:i,taxonomy:l.attr("data-taxonomy"),termIds:Array(l.attr("data-term-id")),callbacks:{success:function(e){l.closest(".psupsellmaster-item").remove()}}};t.functions.unassignPostTerms(r)},onClickRepeaterBtnAdd:function a(s){s.preventDefault();var n=e(this).closest(".psupsellmaster-repeater");t.functions.addRepeaterRow(n)},onClickConditionRepeaterBtnRemove:function a(s){s.preventDefault();var n=e(this).closest(".psupsellmaster-repeater-row");t.functions.removeRepeaterRow(n),t.functions.updateConditionTabsCount()},onClickProductRepeaterBtnRemove:function a(s){s.preventDefault();var n=e(this).closest(".psupsellmaster-repeater-row");t.functions.removeRepeaterRow(n),t.functions.updateProductTabsCount(),e(document).trigger("change.psupsellmaster.section-products")},onClickRowActionExclude:function a(s){s.preventDefault();var n=e(this).closest(".psupsellmaster-col"),l=n.find(".psupsellmaster-field-product-id").val(),i=n.find(".psupsellmaster-field-product-title").val(),r=e('.psupsellmaster-tab-section[data-entity="products"]').find('.psupsellmaster-tab-section[data-type="exclude"]').find(".psupsellmaster-repeater"),o=r.find(".psupsellmaster-repeater-row"),p=!1;if(o.each(function(){0!==e(this).find(".psupsellmaster-field").find('option[value="'+l+'"]:selected').length&&(p=!0)}),!p){var c=r.find(".psupsellmaster-repeater-row").last(),u=c.find(".psupsellmaster-field");u.val()&&(t.functions.addRepeaterRow(r),u=(c=r.find(".psupsellmaster-repeater-row").last()).find(".psupsellmaster-field"));var d=e('.psupsellmaster-field-products-flag[value="selected"]');d.prop("checked")||d.prop("checked",!0).trigger("change");var f=e("<option>",{value:l,text:i});u.append(f),u.val(l).trigger("change")}},onDataTableAjaxData:function a(s,n){var l=e(".psupsellmaster-product-selector");return s=e.extend(!0,s,{action:"psupsellmaster_ajax_get_campaign_eligible_products",nonce:PsUpsellmaster.attributes.ajax.nonce,campaign_id:e("#psupsellmaster-field-campaign-id").val(),options:t.functions.getProductSelectorOptions(l),source:e(".psupsellmaster-datatable-wrapper").attr("data-source")})},onDataTableAjaxDataSrc:function e(t){return t.datatables&&t.datatables.main?(t.draw=t.datatables.main.draw||0,t.recordsTotal=t.datatables.main.total||0,t.recordsFiltered=t.datatables.main.filtered||0,t.datatables.main.data||t.datatables.main):t},onDataTableCreatedCell:function t(a){e(a).addClass("psupsellmaster-datatable-col")},onDataTableCreatedRow:function t(a){e(a).addClass("psupsellmaster-datatable-row")},onDataTableExportFormatBody:function t(a,s,n,l){var i=e("<div>").html(a);i.find(".psupsellmaster-ignore-on-export").remove();var r=i.text();return(r=r.replace(/^\s*\n/gm,"")).trim()},onDataTableInitComplete:function a(s){e(".psupsellmaster-datatable-wrapper .buttons-copy").html('<i class="fa fa-copy"></i>&nbsp;'+t.data.texts.datatable_btn_copy),e(".psupsellmaster-datatable-wrapper .buttons-csv").html('<i class="fa fa-file-csv"></i>&nbsp;'+t.data.texts.datatable_btn_csv),e(".psupsellmaster-datatable-wrapper .buttons-excel").html('<i class="fa fa-file-excel"></i>&nbsp;'+t.data.texts.datatable_btn_excel),e(".psupsellmaster-datatable-wrapper .buttons-print").html('<i class="fa fa-print"></i>&nbsp;'+t.data.texts.datatable_btn_print);var n=e(".psupsellmaster-datatable").closest(".psupsellmaster-datatable-wrapper"),l=n.find(".psupsellmaster-extra-buttons").detach();n.find(".dt-buttons").prepend(l),l.show(),e(document).trigger("psupsellmaster-datatable-init-complete")},onDocumentReady:function e(){t.functions.registerDynamicEvents(),t.functions.startPikadayFields(),t.functions.startDataTables(),t.functions.startTabs(),setTimeout(function(){t.functions.updateProductTabsCount(),t.functions.updateConditionTabsCount(),t.functions.updateLocationTabsCount(),t.functions.updateLocationTabsDisplay()},2e3)},onInputIntegerMaxAmount:function t(a){var s=e(a.target);if(!(!s.is('[type="number"]')||s.is('[max="*"]'))&&"number"==typeof(max=parseInt(s.attr("max")))){var n=parseInt(s.val());"number"==typeof n&&n>max&&s.val(max)}},onInputIntegerMinAmount:function t(a){var s=e(a.target);if(!(!s.is('[type="number"]')||s.is('[min="*"]'))&&"number"==typeof(min=parseInt(s.attr("min")))){var n=parseInt(s.val());"number"==typeof n&&n<min&&s.val(min)}},onKeypressIntegerAmount:function e(t){return -1<["0","1","2","3","4","5","6","7","8","9"].indexOf(t.key)},onSelectBanner:function e(a,s){var n=a.state().get("selection").first().toJSON(),l=s.closest(".psupsellmaster-form-field");l.find(".psupsellmaster-field-banner-id").val(n.id),l.find(".psupsellmaster-field-banner-url").val(n.url),l.find(".psupsellmaster-banner-image").attr("src",n.url);var i=n.alt||n.title||n.filename;l.find(".psupsellmaster-banner-image").attr("alt",i),l.find(".psupsellmaster-banner-image").attr("height",n.height),l.find(".psupsellmaster-banner-image").attr("width",n.width),t.functions.updateLocationTabsCount()},onTabsBeforeActivate:function a(s,n){if("reset"===n.newTab.attr("data-action")){s.preventDefault();var l=e(this).closest(".psupsellmaster-tabs"),i=l.attr("data-key");l.children(".psupsellmaster-tab-section").each(function(){var a=e(this);["conditions","products"].includes(i)?(t.functions.resetRepeaters(a),t.functions.resetFields(a)):"locations"===i&&t.functions.resetFields(a),t.functions.updateTabsMeta(i)})}}},functions:{addRepeaterRow:function e(a){var s=a.find(".psupsellmaster-repeater-row").last();PsUpsellmaster.select2.functions.destroyAll({container:s});var n=s.clone();t.functions.resetFields(n);var l=t.functions.getHighestRepeaterIndex(a);t.functions.updateRowIndex(n,l+1),a.find(".psupsellmaster-repeater-rows").append(n),PsUpsellmaster.select2.functions.refreshAll({container:s}),PsUpsellmaster.select2.functions.refreshAll({container:n})},assignTags:function a(s){var n=e(".psupsellmaster-product-selector"),l=t.functions.getProductSelectorOptions(n);if(l){var i={};if(e(".psupsellmaster-subsection-assign-tags .psupsellmaster-field").each(function(){var t=e(this),a=t.val();a&&(i[t.attr("data-taxonomy")]=a)}),i){var r={action:"psupsellmaster_ajax_assign_multiple_product_terms",nonce:PsUpsellmaster.attributes.ajax.nonce,selectors:l,taxonomies:i};e.ajax({type:"post",url:PsUpsellmaster.attributes.ajax.url,data:r,beforeSend:function(e){s.callbacks&&s.callbacks.beforeSend&&s.callbacks.beforeSend(e)},success:function(e){s.callbacks&&s.callbacks.success&&s.callbacks.success(e)},error:function(e,t,a){s.callbacks&&s.callbacks.error&&s.callbacks.error(e,t,a)},complete:function(e,t){s.callbacks&&s.callbacks.complete&&s.callbacks.complete(e,t)}})}}},deleteCampaigns:function t(a){var s={action:"psupsellmaster_ajax_delete_campaigns",nonce:PsUpsellmaster.attributes.ajax.nonce,ids:a};e.ajax({type:"post",url:PsUpsellmaster.attributes.ajax.url,data:s,beforeSend:function(e){},success:function(e){e.redirect&&1===a.length&&(window.location=e.redirect)},error:function(e,t,a){},complete:function(e,t){}})},duplicateCampaigns:function t(a){var s={action:"psupsellmaster_ajax_duplicate_campaigns",nonce:PsUpsellmaster.attributes.ajax.nonce,ids:a};e.ajax({type:"post",url:PsUpsellmaster.attributes.ajax.url,data:s,beforeSend:function(e){},success:function(e){e.redirect&&1===a.length&&window.open(e.redirect,"_blank")},error:function(e,t,a){},complete:function(e,t){}})},getHighestRepeaterIndex:function t(a){var s=0;return a.find(".psupsellmaster-repeater-row").each(function(){var t=parseInt(e(this).attr("data-index"));t>s&&(s=t)}),s},getProductSelectorOptions:function t(a){var s={authors:{},prices:{},products:{},products_flag:!1,products_type:!1,taxonomies:{}},n=a.find(".psupsellmaster-field-products-flag:checked");s.products_flag=n.val().trim();var l=a.find(".psupsellmaster-form-options"),i=l.find(".psupsellmaster-field-products-type");s.products_type=!!i.is(":checked")&&i.val().trim();var r=l.find('.psupsellmaster-tab-section[data-entity="authors"]'),o=r.find('.psupsellmaster-tab-section[data-type="include"]'),p=r.find('.psupsellmaster-tab-section[data-type="exclude"]');s.authors={include:o.find(".psupsellmaster-select2").map(function(){return parseInt((e(this).val()||"").trim())}).get().filter(Number),exclude:p.find(".psupsellmaster-select2").map(function(){return parseInt((e(this).val()||"").trim())}).get().filter(Number)};var c=l.find(".psupsellmaster-field-prices-min"),u=l.find(".psupsellmaster-field-prices-max");s.prices={min:parseFloat(c.val().trim())||"",max:parseFloat(u.val().trim())||""};var d=l.find('.psupsellmaster-tab-section[data-entity="products"]'),f=d.find('.psupsellmaster-tab-section[data-type="include"]'),m=d.find('.psupsellmaster-tab-section[data-type="exclude"]');return s.products={include:f.find(".psupsellmaster-select2").map(function(){return parseInt((e(this).val()||"").trim())}).get().filter(Number),exclude:m.find(".psupsellmaster-select2").map(function(){return parseInt((e(this).val()||"").trim())}).get().filter(Number)},l.find('.psupsellmaster-tab-section[data-entity="taxonomies"]').each(function(){var t=e(this),a=t.attr("data-taxonomy"),n=t.find('.psupsellmaster-tab-section[data-type="include"]'),l=t.find('.psupsellmaster-tab-section[data-type="exclude"]');s.taxonomies[a]={include:n.find(".psupsellmaster-select2").map(function(){return parseInt((e(this).val()||"").trim())}).get().filter(Number),exclude:l.find(".psupsellmaster-select2").map(function(){return parseInt((e(this).val()||"").trim())}).get().filter(Number)}}),s},init:function e(){t.functions.registerAttributes(),t.functions.registerEvents(),t.functions.run()},maybeToggleLocationOptions:function t(){var a=e(".psupsellmaster-section-locations").find(".psupsellmaster-field-locations-flag:checked"),s=a.val(),n=a.closest(".psupsellmaster-form-group").find(".psupsellmaster-form-options");if("all"===s){n.hide();return}n.show()},maybeToggleProductOptions:function t(){var a=e(".psupsellmaster-subsection-products-selection"),s=a.find(".psupsellmaster-field-products-flag:checked").val(),n=a.find(".psupsellmaster-form-options");if("all"===s){n.hide();return}n.show()},registerAttributes:function a(){"undefined"!=typeof psupsellmaster_admin_data_campaigns_edit&&(t.data=psupsellmaster_admin_data_campaigns_edit),t.timers={datatables:{main:{}}},t.settings={datatables:{default:{},custom:{main:{}}}},t.settings.datatables.default={ajax:{data:t.events.onDataTableAjaxData,dataSrc:t.events.onDataTableAjaxDataSrc,type:"POST",url:PsUpsellmaster.attributes.ajax.url},buttons:[{className:"button",extend:"copyHtml5",exportOptions:{format:{body:t.events.onDataTableExportFormatBody}}},{className:"button",extend:"print",exportOptions:{format:{body:t.events.onDataTableExportFormatBody}}},{className:"button",extend:"csvHtml5",exportOptions:{format:{body:t.events.onDataTableExportFormatBody}}},{className:"button",extend:"excelHtml5",exportOptions:{format:{body:t.events.onDataTableExportFormatBody}}},],columnDefs:[{className:"dt-body-left",targets:[0,1,2]},{orderable:!1,targets:[2]},{createdCell:t.events.onDataTableCreatedCell,targets:"_all"},],createdRow:t.events.onDataTableCreatedRow,displayLength:10,dom:"Bfliptip",filter:!0,initComplete:t.events.onDataTableInitComplete,oLanguage:{sLengthMenu:t.data.texts.datatable_length},order:[[0,"asc"]],pageLength:10,lengthMenu:[[10,25,50,100,250,1e3],[10,25,50,100,250,1e3],],paginate:!0,pagingType:"full_numbers",serverSide:!0,responsive:{details:{target:".psupsellmaster-toggle-details",type:"column"}}},t.settings.datatables.custom.main=e.extend(!0,{},t.settings.datatables.default),t.instances={datatables:{main:null}}},registerDynamicEvents:function a(){e(".psupsellmaster-section-locations .psupsellmaster-field-description").each(function(){var a=e(this),s=tinymce.get(a.attr("id"));if(!s)return!0;s.on("change",t.events.onChangeAnyLocationsSectionField)})},registerEvents:function a(){e(t.events.onDocumentReady),e(document).on("click",".psupsellmaster-section-promotion-conditions .psupsellmaster-repeater-btn-add",t.events.onClickRepeaterBtnAdd),e(document).on("click",".psupsellmaster-subsection-products-selection .psupsellmaster-repeater-btn-add",t.events.onClickRepeaterBtnAdd),e(document).on("click",".psupsellmaster-section-promotion-conditions .psupsellmaster-repeater-btn-remove",t.events.onClickConditionRepeaterBtnRemove),e(document).on("click",".psupsellmaster-subsection-products-selection .psupsellmaster-repeater-btn-remove",t.events.onClickProductRepeaterBtnRemove),e(document).on("click",".psupsellmaster-subsection-assign-tags .psupsellmaster-btn-assign-tags",t.events.onClickBtnAssignTags),e(document).on("change",".psupsellmaster-field-coupons-flag",t.events.onChangeFieldCouponsFlag),e(document).on("change",".psupsellmaster-field-products-flag",t.events.onChangeFieldProductsFlag),e(document).on("change",".psupsellmaster-subsection-products-selection .psupsellmaster-select2",t.events.onChangeAnyProductFieldSelect2),e(document).on("change",".psupsellmaster-subsection-products-selection .psupsellmaster-field",t.events.onChangeAnyProductField),e(document).on("change",".psupsellmaster-section-locations .psupsellmaster-field",t.events.onChangeAnyLocationsSectionField),e(document).on("change",".psupsellmaster-section-promotion-conditions .psupsellmaster-select2",t.events.onChangeAnyConditionFieldSelect2),e(document).on("change",".psupsellmaster-field-locations-flag",t.events.onChangeFieldLocationsFlag),e(document).on("change",".psupsellmaster-field-locations",t.events.onChangeFieldLocations),e(document).on("click",".psupsellmaster-btn-select-banner",t.events.onClickBtnSelectBanner),e(document).on("click",".psupsellmaster-btn-copy-banner-url",t.events.onClickBtnCopyBannerURL),e(document).on("click",".psupsellmaster-btn-remove-banner",t.events.onClickBtnRemoveBanner),e(document).on("click",".psupsellmaster-btn-duplicate-campaign",t.events.onClickBtnDuplicateCampaign),e(document).on("click",".psupsellmaster-field-confirm-delete-campaign",t.events.onClickBtnConfirmDeleteCampaign),e(document).on("click",".psupsellmaster-btn-delete-campaign",t.events.onClickBtnDeleteCampaign),e(document).on("click",".psupsellmaster-datatable-wrapper .psupsellmaster-btn-refresh",t.events.onClickBtnDataTableRefresh),e(document).on("change.psupsellmaster.section-products",t.events.onChangeSectionProducts),e(document).on("input",".psupsellmaster-field-priority",t.events.onInputIntegerMaxAmount),e(document).on("input",".psupsellmaster-field-priority",t.events.onInputIntegerMinAmount),e(document).on("keypress",".psupsellmaster-field-priority",t.events.onKeypressIntegerAmount),e(document).on("click",".psupsellmaster-unassign-post-term",t.events.onClickBtnUnassignPostTerm),e(document).on("click",".psupsellmaster-row-actions .psupsellmaster-exclude",t.events.onClickRowActionExclude)},reloadDataTable:function e(){t.instances.datatables.main.ajax.reload()},removeRepeaterRow:function e(a){if(1===a.closest(".psupsellmaster-repeater").find(".psupsellmaster-repeater-row").length){t.functions.resetFields(a),t.functions.updateRowIndex(a),PsUpsellmaster.select2.functions.refreshAll({container:a});return}a.remove()},resetFields:function t(a){var s=a.find("input:not(:checkbox,:radio), select, textarea");s.val(""),s.trigger("change"),(s=a.find("input:checkbox, input:radio")).each(function(){var t=e(this);t.prop("checked","true"===t.attr("data-default-checked"))}),s.trigger("change")},resetRepeater:function e(a){a.find(".psupsellmaster-repeater-row").not(":first").remove();var s=a.find(".psupsellmaster-repeater-row");t.functions.resetFields(s),t.functions.updateRowIndex(s),PsUpsellmaster.select2.functions.refreshAll({container:s})},resetRepeaters:function a(s){s.find(".psupsellmaster-repeater").each(function(){t.functions.resetRepeater(e(this))})},updateConditionTabsCount:function t(){var a=e(".psupsellmaster-section-promotion-conditions");a.find(".psupsellmaster-tabs").first().find(".psupsellmaster-tabs-header").first().find(".psupsellmaster-tab").each(function(){var t=e(this),s=t.find("a").attr("href"),n=a.find(s),l=n.find(".psupsellmaster-tabs-header").first(),i=0;l.find(".psupsellmaster-tab").each(function(){var t=e(this),a=t.find("a").attr("href"),s=n.find(a).find(".psupsellmaster-select2 option:selected:not(:empty)").length;t.find(".psupsellmaster-count").text("("+s+")"),i+=s}),t.find(".psupsellmaster-count").text("("+i+")")})},updateLocationTabsDisplay:function t(){var a=e(".psupsellmaster-section-locations"),s=a.find(".psupsellmaster-field-locations-flag:checked").val(),n=a.find(".psupsellmaster-field-locations").val(),l=a.find(".psupsellmaster-tabs").first(),i=l.find(".psupsellmaster-tabs-header").first();if(i.find(".psupsellmaster-tab").each(function(){var t=e(this),a=t.attr("data-location"),l=!0;"all"===s||0===n.length||"all"===a||n.includes(a)||(l=!1),l?t.show():t.hide()}),i.find(".psupsellmaster-tab.ui-tabs-active").is(":hidden")){var r=i.find(".psupsellmaster-tab:visible").first();l.tabs("option","active",r.index())}},updateLocationTabsCount:function t(){var a=e(".psupsellmaster-section-locations");a.find(".psupsellmaster-tabs-header").first().find(".psupsellmaster-tab").each(function(){var t=e(this),s=t.find("a").attr("href"),n=a.find(s),l=n.find(".psupsellmaster-form-field-description .psupsellmaster-field-description"),i=n.find(".psupsellmaster-form-field-desktop-banner .psupsellmaster-field"),r=n.find(".psupsellmaster-form-field-mobile-banner .psupsellmaster-field"),o=n.find(".psupsellmaster-form-field-desktop-banner-link-url .psupsellmaster-field"),p=n.find(".psupsellmaster-form-field-mobile-banner-link-url .psupsellmaster-field"),c=!1;(c=(c=(c=(c=(c=c||!!tinymce.get(l.attr("id")).getContent().trim())||!!parseInt(i.val()))||!!parseInt(r.val()))||!!o.val().trim())||!!p.val().trim())?t.find(".psupsellmaster-count").text("(+)"):t.find(".psupsellmaster-count").text("")})},updateProductTabsCount:function t(){var a=e(".psupsellmaster-subsection-products-selection");a.find(".psupsellmaster-form-options").find(".psupsellmaster-tabs-header").first().find(".psupsellmaster-tab").each(function(){var t=e(this),s=t.find("a").attr("href"),n=a.find(s),l=n.find(".psupsellmaster-tabs-header").first(),i=0;l.find(".psupsellmaster-tab").each(function(){var t=e(this),a=t.find("a").attr("href"),s=n.find(a).find(".psupsellmaster-select2 option:selected:not(:empty)").length;t.find(".psupsellmaster-count").text("("+s+")"),i+=s}),t.find(".psupsellmaster-count").text("("+i+")")})},updateRowIndex:function t(a,s=0){a.attr("data-index",s),a.find("input, select, textarea").each(function(){var t=e(this),a=t.attr("id");a&&(a=a.replace(/(\d+)/,s),t.attr("id",a));var n=t.attr("name");n&&(n=n.replace(/\[(\d+)\]/,"["+s+"]"),t.attr("name",n))})},updateTabsMeta:function e(a){"conditions"===a?t.functions.updateConditionTabsCount():"locations"===a?(t.functions.updateLocationTabsCount(),t.functions.updateLocationTabsDisplay()):"products"===a&&t.functions.updateProductTabsCount()},run:function t(){e(".psupsellmaster-section-general .psupsellmaster-form-field-title .psupsellmaster-field").trigger("focus")},setDataTableSource:function t(a){e(".psupsellmaster-datatable-wrapper").attr("data-source",a)},startDataTables:function a(){t.instances.datatables.main=e("#psupsellmaster-datatable-eligible-products").DataTable(t.settings.datatables.custom.main)},startPikadayFields:function a(){e(".psupsellmaster-field-pikaday").each(function(){var a;a=e(this),t.functions.startPikadayField(a)})},startPikadayField:function e(t){var a;a={field:t.get(0),format:"YYYY/MM/DD"},new Pikaday(a)},startTabs:function a(){e(".psupsellmaster-tabs").tabs({beforeActivate:t.events.onTabsBeforeActivate}),e(".psupsellmaster-tabs").show()},unassignPostTerms:function t(a){var s={action:"psupsellmaster_ajax_unassign_post_terms",nonce:PsUpsellmaster.attributes.ajax.nonce,post_id:a.postId,taxonomy:a.taxonomy,term_ids:a.termIds};e.ajax({type:"post",url:PsUpsellmaster.attributes.ajax.url,data:s,beforeSend:function(e){a.callbacks&&a.callbacks.beforeSend&&a.callbacks.beforeSend(e)},success:function(e){a.callbacks&&a.callbacks.success&&a.callbacks.success(e)},error:function(e,t,s){a.callbacks&&a.callbacks.error&&a.callbacks.error(e,t,s)},complete:function(e,t){a.callbacks&&a.callbacks.complete&&a.callbacks.complete(e,t)}})}}}).functions.init()}(jQuery);
     1!function(e){var t;(t={attributes:{},events:{onChangeAnyLocationsSectionField:function e(a){t.functions.updateLocationTabsCount()},onChangeAnyProductField:function t(a){e(document).trigger("change.psupsellmaster.section-products")},onChangeAnyProductFieldSelect2:function e(a){t.functions.updateProductTabsCount()},onChangeAnyConditionFieldSelect2:function e(a){t.functions.updateConditionTabsCount()},onChangeFieldCouponsFlag:function t(a){var s=e(this),n=s.val(),l=s.closest(".psupsellmaster-form-rows").find(".psupsellmaster-form-warning"),i=s.closest(".psupsellmaster-subsection-coupons"),r=i.find(".psupsellmaster-form-field-coupon-code"),o=i.find(".psupsellmaster-form-field-standard-coupon-id");"campaign"===n?(l.hide(),o.hide(),r.show()):(l.show(),r.hide(),o.show())},onChangeFieldLocations:function e(a){t.functions.updateLocationTabsDisplay()},onChangeFieldLocationsFlag:function e(a){t.functions.maybeToggleLocationOptions(),t.functions.updateLocationTabsDisplay()},onChangeFieldProductsFlag:function e(a){t.functions.maybeToggleProductOptions()},onChangeSectionProducts:function e(a){clearTimeout(t.timers.datatables.main),t.functions.setDataTableSource("preview"),t.timers.datatables.main=setTimeout(function(){t.functions.reloadDataTable()},2500)},onClickBtnConfirmDeleteCampaign:function t(a){var s=e(this),n=s.closest(".psupsellmaster-action").find(".psupsellmaster-btn-delete-campaign");s.is(":checked")?n.prop("disabled",!1):n.prop("disabled",!0)},onClickBtnCopyBannerURL:function t(a){a.preventDefault();var s=e(this).closest(".psupsellmaster-form-field").find(".psupsellmaster-field-banner-url");PsUpsellmaster.functions.copyToClipboard(s.val())},onClickBtnDataTableRefresh:function e(a){a.preventDefault(),t.functions.setDataTableSource("preview"),t.functions.reloadDataTable()},onClickBtnDeleteCampaign:function a(s){s.preventDefault();var n=e(this).attr("data-campaign-id");t.functions.deleteCampaigns(Array(n))},onClickBtnDuplicateCampaign:function a(s){s.preventDefault();var n=e(this).attr("data-campaign-id");t.functions.duplicateCampaigns(Array(n))},onClickBtnSelectBanner:function a(s){s.preventDefault();var n=e(this),l={button:{title:t.data.texts.wp_media_btn_title},multiple:!1,title:t.data.texts.wp_media_frame_title},i=wp.media(l);i.on("select",function(){t.events.onSelectBanner(i,n)}),i.open()},onClickBtnRemoveBanner:function a(s){s.preventDefault();var n=e(this),l=n.closest(".psupsellmaster-form-field");l.find(".psupsellmaster-field-banner-id").val(""),l.find(".psupsellmaster-field-banner-url").val("");var i=l.attr("data-banner-type"),r=n.closest(".psupsellmaster-form-edit-campaign").find(".psupsellmaster-defaults"),o=r.find(".psupsellmaster-default-"+i+"-banner-url").val(),p=r.find(".psupsellmaster-default-banner-title").val(),c=r.find(".psupsellmaster-default-"+i+"-banner-height").val(),u=r.find(".psupsellmaster-default-"+i+"-banner-width").val();l.find(".psupsellmaster-banner-image").attr("src",o),l.find(".psupsellmaster-banner-image").attr("alt",p),l.find(".psupsellmaster-banner-image").attr("height",c),l.find(".psupsellmaster-banner-image").attr("width",u),t.functions.updateLocationTabsCount()},onClickBtnUnassignPostTerm:function a(s){s.preventDefault();var n,l=e(this),i=l.attr("data-post-id"),r={postId:i,taxonomy:l.attr("data-taxonomy"),termIds:Array(l.attr("data-term-id")),callbacks:{success:function(e){l.closest(".psupsellmaster-item").remove()}}};t.functions.unassignPostTerms(r)},onClickBtnUpdateTags:function a(s){var n=e(this),l=n.closest(".psupsellmaster-form-btn").find(".spinner"),i=n.attr("data-action");t.functions.updateTags({callbacks:{beforeSend:function(){n.prop("disabled",!0),l.addClass("is-active").show()},complete:function(){t.functions.reloadDataTable(),n.prop("disabled",!1),l.removeClass("is-active").hide()}},context:i})},onClickRepeaterBtnAdd:function a(s){s.preventDefault();var n=e(this).closest(".psupsellmaster-repeater");t.functions.addRepeaterRow(n)},onClickConditionRepeaterBtnRemove:function a(s){s.preventDefault();var n=e(this).closest(".psupsellmaster-repeater-row");t.functions.removeRepeaterRow(n),t.functions.updateConditionTabsCount()},onClickProductRepeaterBtnRemove:function a(s){s.preventDefault();var n=e(this).closest(".psupsellmaster-repeater-row");t.functions.removeRepeaterRow(n),t.functions.updateProductTabsCount(),e(document).trigger("change.psupsellmaster.section-products")},onClickRowActionExclude:function a(s){s.preventDefault();var n=e(this).closest(".psupsellmaster-col"),l=n.find(".psupsellmaster-field-product-id").val(),i=n.find(".psupsellmaster-field-product-title").val(),r=e('.psupsellmaster-tab-section[data-entity="products"]').find('.psupsellmaster-tab-section[data-type="exclude"]').find(".psupsellmaster-repeater"),o=r.find(".psupsellmaster-repeater-row"),p=!1;if(o.each(function(){0!==e(this).find(".psupsellmaster-field").find('option[value="'+l+'"]:selected').length&&(p=!0)}),!p){var c=r.find(".psupsellmaster-repeater-row").last(),u=c.find(".psupsellmaster-field");u.val()&&(t.functions.addRepeaterRow(r),u=(c=r.find(".psupsellmaster-repeater-row").last()).find(".psupsellmaster-field"));var d=e('.psupsellmaster-field-products-flag[value="selected"]');d.prop("checked")||d.prop("checked",!0).trigger("change");var f=e("<option>",{value:l,text:i});u.append(f),u.val(l).trigger("change")}},onDataTableAjaxData:function a(s,n){var l=e(".psupsellmaster-product-selector");return s=e.extend(!0,s,{action:"psupsellmaster_ajax_get_campaign_eligible_products",nonce:PsUpsellmaster.attributes.ajax.nonce,campaign_id:e("#psupsellmaster-field-campaign-id").val(),options:t.functions.getProductSelectorOptions(l),source:e(".psupsellmaster-datatable-wrapper").attr("data-source")})},onDataTableAjaxDataSrc:function e(t){return t.datatables&&t.datatables.main?(t.draw=t.datatables.main.draw||0,t.recordsTotal=t.datatables.main.total||0,t.recordsFiltered=t.datatables.main.filtered||0,t.datatables.main.data||t.datatables.main):t},onDataTableCreatedCell:function t(a){e(a).addClass("psupsellmaster-datatable-col")},onDataTableCreatedRow:function t(a){e(a).addClass("psupsellmaster-datatable-row")},onDataTableExportFormatBody:function t(a,s,n,l){var i=e("<div>").html(a);i.find(".psupsellmaster-ignore-on-export").remove();var r=i.text();return(r=r.replace(/^\s*\n/gm,"")).trim()},onDataTableInitComplete:function a(s){e(".psupsellmaster-datatable-wrapper .buttons-copy").html('<i class="fa fa-copy"></i>&nbsp;'+t.data.texts.datatable_btn_copy),e(".psupsellmaster-datatable-wrapper .buttons-csv").html('<i class="fa fa-file-csv"></i>&nbsp;'+t.data.texts.datatable_btn_csv),e(".psupsellmaster-datatable-wrapper .buttons-excel").html('<i class="fa fa-file-excel"></i>&nbsp;'+t.data.texts.datatable_btn_excel),e(".psupsellmaster-datatable-wrapper .buttons-print").html('<i class="fa fa-print"></i>&nbsp;'+t.data.texts.datatable_btn_print);var n=e(".psupsellmaster-datatable").closest(".psupsellmaster-datatable-wrapper"),l=n.find(".psupsellmaster-extra-buttons").detach();n.find(".dt-buttons").prepend(l),l.show(),e(document).trigger("psupsellmaster-datatable-init-complete")},onDocumentReady:function e(){t.functions.registerDynamicEvents(),t.functions.startPikadayFields(),t.functions.startDataTables(),t.functions.startTabs(),setTimeout(function(){t.functions.updateProductTabsCount(),t.functions.updateConditionTabsCount(),t.functions.updateLocationTabsCount(),t.functions.updateLocationTabsDisplay()},2e3)},onInputIntegerMaxAmount:function t(a){var s=e(a.target);if(!(!s.is('[type="number"]')||s.is('[max="*"]'))&&"number"==typeof(max=parseInt(s.attr("max")))){var n=parseInt(s.val());"number"==typeof n&&n>max&&s.val(max)}},onInputIntegerMinAmount:function t(a){var s=e(a.target);if(!(!s.is('[type="number"]')||s.is('[min="*"]'))&&"number"==typeof(min=parseInt(s.attr("min")))){var n=parseInt(s.val());"number"==typeof n&&n<min&&s.val(min)}},onKeypressIntegerAmount:function e(t){return -1<["0","1","2","3","4","5","6","7","8","9"].indexOf(t.key)},onSelectBanner:function e(a,s){var n=a.state().get("selection").first().toJSON(),l=s.closest(".psupsellmaster-form-field");l.find(".psupsellmaster-field-banner-id").val(n.id),l.find(".psupsellmaster-field-banner-url").val(n.url),l.find(".psupsellmaster-banner-image").attr("src",n.url);var i=n.alt||n.title||n.filename;l.find(".psupsellmaster-banner-image").attr("alt",i),l.find(".psupsellmaster-banner-image").attr("height",n.height),l.find(".psupsellmaster-banner-image").attr("width",n.width),t.functions.updateLocationTabsCount()},onTabsBeforeActivate:function a(s,n){if("reset"===n.newTab.attr("data-action")){s.preventDefault();var l=e(this).closest(".psupsellmaster-tabs"),i=l.attr("data-key");l.children(".psupsellmaster-tab-section").each(function(){var a=e(this);["conditions","products"].includes(i)?(t.functions.resetRepeaters(a),t.functions.resetFields(a)):"locations"===i&&t.functions.resetFields(a),t.functions.updateTabsMeta(i)})}}},functions:{addRepeaterRow:function e(a){var s=a.find(".psupsellmaster-repeater-row").last();PsUpsellmaster.select2.functions.destroyAll({container:s});var n=s.clone();t.functions.resetFields(n);var l=t.functions.getHighestRepeaterIndex(a);t.functions.updateRowIndex(n,l+1),a.find(".psupsellmaster-repeater-rows").append(n),PsUpsellmaster.select2.functions.refreshAll({container:s}),PsUpsellmaster.select2.functions.refreshAll({container:n})},deleteCampaigns:function t(a){var s={action:"psupsellmaster_ajax_delete_campaigns",nonce:PsUpsellmaster.attributes.ajax.nonce,ids:a};e.ajax({type:"post",url:PsUpsellmaster.attributes.ajax.url,data:s,beforeSend:function(e){},success:function(e){e.redirect&&1===a.length&&(window.location=e.redirect)},error:function(e,t,a){},complete:function(e,t){}})},duplicateCampaigns:function t(a){var s={action:"psupsellmaster_ajax_duplicate_campaigns",nonce:PsUpsellmaster.attributes.ajax.nonce,ids:a};e.ajax({type:"post",url:PsUpsellmaster.attributes.ajax.url,data:s,beforeSend:function(e){},success:function(e){e.redirect&&1===a.length&&window.open(e.redirect,"_blank")},error:function(e,t,a){},complete:function(e,t){}})},getHighestRepeaterIndex:function t(a){var s=0;return a.find(".psupsellmaster-repeater-row").each(function(){var t=parseInt(e(this).attr("data-index"));t>s&&(s=t)}),s},getProductSelectorOptions:function t(a){var s={authors:{},prices:{},products:{},products_flag:!1,products_type:!1,taxonomies:{}},n=a.find(".psupsellmaster-field-products-flag:checked");s.products_flag=n.val().trim();var l=a.find(".psupsellmaster-form-options"),i=l.find(".psupsellmaster-field-products-type");s.products_type=!!i.is(":checked")&&i.val().trim();var r=l.find('.psupsellmaster-tab-section[data-entity="authors"]'),o=r.find('.psupsellmaster-tab-section[data-type="include"]'),p=r.find('.psupsellmaster-tab-section[data-type="exclude"]');s.authors={include:o.find(".psupsellmaster-select2").map(function(){return parseInt((e(this).val()||"").trim())}).get().filter(Number),exclude:p.find(".psupsellmaster-select2").map(function(){return parseInt((e(this).val()||"").trim())}).get().filter(Number)};var c=l.find(".psupsellmaster-field-prices-min"),u=l.find(".psupsellmaster-field-prices-max");s.prices={min:parseFloat(c.val().trim())||"",max:parseFloat(u.val().trim())||""};var d=l.find('.psupsellmaster-tab-section[data-entity="products"]'),f=d.find('.psupsellmaster-tab-section[data-type="include"]'),m=d.find('.psupsellmaster-tab-section[data-type="exclude"]');return s.products={include:f.find(".psupsellmaster-select2").map(function(){return parseInt((e(this).val()||"").trim())}).get().filter(Number),exclude:m.find(".psupsellmaster-select2").map(function(){return parseInt((e(this).val()||"").trim())}).get().filter(Number)},l.find('.psupsellmaster-tab-section[data-entity="taxonomies"]').each(function(){var t=e(this),a=t.attr("data-taxonomy"),n=t.find('.psupsellmaster-tab-section[data-type="include"]'),l=t.find('.psupsellmaster-tab-section[data-type="exclude"]');s.taxonomies[a]={include:n.find(".psupsellmaster-select2").map(function(){return parseInt((e(this).val()||"").trim())}).get().filter(Number),exclude:l.find(".psupsellmaster-select2").map(function(){return parseInt((e(this).val()||"").trim())}).get().filter(Number)}}),s},init:function e(){t.functions.registerAttributes(),t.functions.registerEvents(),t.functions.run()},maybeToggleLocationOptions:function t(){var a=e(".psupsellmaster-section-locations").find(".psupsellmaster-field-locations-flag:checked"),s=a.val(),n=a.closest(".psupsellmaster-form-group").find(".psupsellmaster-form-options");if("all"===s){n.hide();return}n.show()},maybeToggleProductOptions:function t(){var a=e(".psupsellmaster-subsection-products-selection"),s=a.find(".psupsellmaster-field-products-flag:checked").val(),n=a.find(".psupsellmaster-form-options");if("all"===s){n.hide();return}n.show()},registerAttributes:function a(){"undefined"!=typeof psupsellmaster_admin_data_campaigns_edit&&(t.data=psupsellmaster_admin_data_campaigns_edit),t.timers={datatables:{main:{}}},t.settings={datatables:{default:{},custom:{main:{}}}},t.settings.datatables.default={ajax:{data:t.events.onDataTableAjaxData,dataSrc:t.events.onDataTableAjaxDataSrc,type:"POST",url:PsUpsellmaster.attributes.ajax.url},buttons:[{className:"button",extend:"copyHtml5",exportOptions:{format:{body:t.events.onDataTableExportFormatBody}}},{className:"button",extend:"print",exportOptions:{format:{body:t.events.onDataTableExportFormatBody}}},{className:"button",extend:"csvHtml5",exportOptions:{format:{body:t.events.onDataTableExportFormatBody}}},{className:"button",extend:"excelHtml5",exportOptions:{format:{body:t.events.onDataTableExportFormatBody}}},],columnDefs:[{className:"dt-body-left",targets:[0,1,2]},{orderable:!1,targets:[2]},{createdCell:t.events.onDataTableCreatedCell,targets:"_all"},],createdRow:t.events.onDataTableCreatedRow,displayLength:10,dom:"Bfliptip",filter:!0,initComplete:t.events.onDataTableInitComplete,oLanguage:{sLengthMenu:t.data.texts.datatable_length},order:[[0,"asc"]],pageLength:10,lengthMenu:[[10,25,50,100,250,1e3],[10,25,50,100,250,1e3],],paginate:!0,pagingType:"full_numbers",serverSide:!0,responsive:{details:{target:".psupsellmaster-toggle-details",type:"column"}}},t.settings.datatables.custom.main=e.extend(!0,{},t.settings.datatables.default),t.instances={datatables:{main:null}}},registerDynamicEvents:function a(){e(".psupsellmaster-section-locations .psupsellmaster-field-description").each(function(){var a=e(this),s=tinymce.get(a.attr("id"));if(!s)return!0;s.on("change",t.events.onChangeAnyLocationsSectionField)})},registerEvents:function a(){e(t.events.onDocumentReady),e(document).on("click",".psupsellmaster-section-promotion-conditions .psupsellmaster-repeater-btn-add",t.events.onClickRepeaterBtnAdd),e(document).on("click",".psupsellmaster-subsection-products-selection .psupsellmaster-repeater-btn-add",t.events.onClickRepeaterBtnAdd),e(document).on("click",".psupsellmaster-section-promotion-conditions .psupsellmaster-repeater-btn-remove",t.events.onClickConditionRepeaterBtnRemove),e(document).on("click",".psupsellmaster-subsection-products-selection .psupsellmaster-repeater-btn-remove",t.events.onClickProductRepeaterBtnRemove),e(document).on("click",".psupsellmaster-subsection-update-tags .psupsellmaster-btn-update-tags",t.events.onClickBtnUpdateTags),e(document).on("change",".psupsellmaster-field-coupons-flag",t.events.onChangeFieldCouponsFlag),e(document).on("change",".psupsellmaster-field-products-flag",t.events.onChangeFieldProductsFlag),e(document).on("change",".psupsellmaster-subsection-products-selection .psupsellmaster-select2",t.events.onChangeAnyProductFieldSelect2),e(document).on("change",".psupsellmaster-subsection-products-selection .psupsellmaster-field",t.events.onChangeAnyProductField),e(document).on("change",".psupsellmaster-section-locations .psupsellmaster-field",t.events.onChangeAnyLocationsSectionField),e(document).on("change",".psupsellmaster-section-promotion-conditions .psupsellmaster-select2",t.events.onChangeAnyConditionFieldSelect2),e(document).on("change",".psupsellmaster-field-locations-flag",t.events.onChangeFieldLocationsFlag),e(document).on("change",".psupsellmaster-field-locations",t.events.onChangeFieldLocations),e(document).on("click",".psupsellmaster-btn-select-banner",t.events.onClickBtnSelectBanner),e(document).on("click",".psupsellmaster-btn-copy-banner-url",t.events.onClickBtnCopyBannerURL),e(document).on("click",".psupsellmaster-btn-remove-banner",t.events.onClickBtnRemoveBanner),e(document).on("click",".psupsellmaster-btn-duplicate-campaign",t.events.onClickBtnDuplicateCampaign),e(document).on("click",".psupsellmaster-field-confirm-delete-campaign",t.events.onClickBtnConfirmDeleteCampaign),e(document).on("click",".psupsellmaster-btn-delete-campaign",t.events.onClickBtnDeleteCampaign),e(document).on("click",".psupsellmaster-datatable-wrapper .psupsellmaster-btn-refresh",t.events.onClickBtnDataTableRefresh),e(document).on("change.psupsellmaster.section-products",t.events.onChangeSectionProducts),e(document).on("input",".psupsellmaster-field-priority",t.events.onInputIntegerMaxAmount),e(document).on("input",".psupsellmaster-field-priority",t.events.onInputIntegerMinAmount),e(document).on("keypress",".psupsellmaster-field-priority",t.events.onKeypressIntegerAmount),e(document).on("click",".psupsellmaster-unassign-post-term",t.events.onClickBtnUnassignPostTerm),e(document).on("click",".psupsellmaster-row-actions .psupsellmaster-exclude",t.events.onClickRowActionExclude)},reloadDataTable:function e(){t.instances.datatables.main.ajax.reload()},removeRepeaterRow:function e(a){if(1===a.closest(".psupsellmaster-repeater").find(".psupsellmaster-repeater-row").length){t.functions.resetFields(a),t.functions.updateRowIndex(a),PsUpsellmaster.select2.functions.refreshAll({container:a});return}a.remove()},resetFields:function t(a){var s=a.find("input:not(:checkbox,:radio), select, textarea");s.val(""),s.trigger("change"),(s=a.find("input:checkbox, input:radio")).each(function(){var t=e(this);t.prop("checked","true"===t.attr("data-default-checked"))}),s.trigger("change")},resetRepeater:function e(a){a.find(".psupsellmaster-repeater-row").not(":first").remove();var s=a.find(".psupsellmaster-repeater-row");t.functions.resetFields(s),t.functions.updateRowIndex(s),PsUpsellmaster.select2.functions.refreshAll({container:s})},resetRepeaters:function a(s){s.find(".psupsellmaster-repeater").each(function(){t.functions.resetRepeater(e(this))})},updateConditionTabsCount:function t(){var a=e(".psupsellmaster-section-promotion-conditions");a.find(".psupsellmaster-tabs").first().find(".psupsellmaster-tabs-header").first().find(".psupsellmaster-tab").each(function(){var t=e(this),s=t.find("a").attr("href"),n=a.find(s),l=n.find(".psupsellmaster-tabs-header").first(),i=0;l.find(".psupsellmaster-tab").each(function(){var t=e(this),a=t.find("a").attr("href"),s=n.find(a).find(".psupsellmaster-select2 option:selected:not(:empty)").length;t.find(".psupsellmaster-count").text("("+s+")"),i+=s}),t.find(".psupsellmaster-count").text("("+i+")")})},updateLocationTabsDisplay:function t(){var a=e(".psupsellmaster-section-locations"),s=a.find(".psupsellmaster-field-locations-flag:checked").val(),n=a.find(".psupsellmaster-field-locations").val(),l=a.find(".psupsellmaster-tabs").first(),i=l.find(".psupsellmaster-tabs-header").first();if(i.find(".psupsellmaster-tab").each(function(){var t=e(this),a=t.attr("data-location"),l=!0;"all"===s||0===n.length||"all"===a||n.includes(a)||(l=!1),l?t.show():t.hide()}),i.find(".psupsellmaster-tab.ui-tabs-active").is(":hidden")){var r=i.find(".psupsellmaster-tab:visible").first();l.tabs("option","active",r.index())}},updateLocationTabsCount:function t(){var a=e(".psupsellmaster-section-locations");a.find(".psupsellmaster-tabs-header").first().find(".psupsellmaster-tab").each(function(){var t=e(this),s=t.find("a").attr("href"),n=a.find(s),l=n.find(".psupsellmaster-form-field-description .psupsellmaster-field-description"),i=n.find(".psupsellmaster-form-field-desktop-banner .psupsellmaster-field"),r=n.find(".psupsellmaster-form-field-mobile-banner .psupsellmaster-field"),o=n.find(".psupsellmaster-form-field-desktop-banner-link-url .psupsellmaster-field"),p=n.find(".psupsellmaster-form-field-mobile-banner-link-url .psupsellmaster-field"),c=!1;(c=(c=(c=(c=(c=c||!!tinymce.get(l.attr("id")).getContent().trim())||!!parseInt(i.val()))||!!parseInt(r.val()))||!!o.val().trim())||!!p.val().trim())?t.find(".psupsellmaster-count").text("(+)"):t.find(".psupsellmaster-count").text("")})},updateProductTabsCount:function t(){var a=e(".psupsellmaster-subsection-products-selection");a.find(".psupsellmaster-form-options").find(".psupsellmaster-tabs-header").first().find(".psupsellmaster-tab").each(function(){var t=e(this),s=t.find("a").attr("href"),n=a.find(s),l=n.find(".psupsellmaster-tabs-header").first(),i=0;l.find(".psupsellmaster-tab").each(function(){var t=e(this),a=t.find("a").attr("href"),s=n.find(a).find(".psupsellmaster-select2 option:selected:not(:empty)").length;t.find(".psupsellmaster-count").text("("+s+")"),i+=s}),t.find(".psupsellmaster-count").text("("+i+")")})},updateRowIndex:function t(a,s=0){a.attr("data-index",s),a.find("input, select, textarea").each(function(){var t=e(this),a=t.attr("id");a&&(a=a.replace(/(\d+)/,s),t.attr("id",a));var n=t.attr("name");n&&(n=n.replace(/\[(\d+)\]/,"["+s+"]"),t.attr("name",n))})},updateTabsMeta:function e(a){"conditions"===a?t.functions.updateConditionTabsCount():"locations"===a?(t.functions.updateLocationTabsCount(),t.functions.updateLocationTabsDisplay()):"products"===a&&t.functions.updateProductTabsCount()},updateTags:function a(s){var n=e(".psupsellmaster-product-selector"),l=t.functions.getProductSelectorOptions(n);if(l){var i={};if(e(".psupsellmaster-subsection-update-tags .psupsellmaster-field").each(function(){var t=e(this),a=t.val();a&&(i[t.attr("data-taxonomy")]=a)}),i){var r={action:"psupsellmaster_ajax_update_multiple_product_terms",nonce:PsUpsellmaster.attributes.ajax.nonce,context:s.context,selectors:l,taxonomies:i};e.ajax({type:"post",url:PsUpsellmaster.attributes.ajax.url,data:r,beforeSend:function(e){s.callbacks&&s.callbacks.beforeSend&&s.callbacks.beforeSend(e)},success:function(e){s.callbacks&&s.callbacks.success&&s.callbacks.success(e)},error:function(e,t,a){s.callbacks&&s.callbacks.error&&s.callbacks.error(e,t,a)},complete:function(e,t){s.callbacks&&s.callbacks.complete&&s.callbacks.complete(e,t)}})}}},run:function t(){e(".psupsellmaster-section-general .psupsellmaster-form-field-title .psupsellmaster-field").trigger("focus")},setDataTableSource:function t(a){e(".psupsellmaster-datatable-wrapper").attr("data-source",a)},startDataTables:function a(){t.instances.datatables.main=e("#psupsellmaster-datatable-eligible-products").DataTable(t.settings.datatables.custom.main)},startPikadayFields:function a(){e(".psupsellmaster-field-pikaday").each(function(){var a;a=e(this),t.functions.startPikadayField(a)})},startPikadayField:function e(t){var a;a={field:t.get(0),format:"YYYY/MM/DD"},new Pikaday(a)},startTabs:function a(){e(".psupsellmaster-tabs").tabs({beforeActivate:t.events.onTabsBeforeActivate}),e(".psupsellmaster-tabs").show()},unassignPostTerms:function t(a){var s={action:"psupsellmaster_ajax_unassign_post_terms",nonce:PsUpsellmaster.attributes.ajax.nonce,post_id:a.postId,taxonomy:a.taxonomy,term_ids:a.termIds};e.ajax({type:"post",url:PsUpsellmaster.attributes.ajax.url,data:s,beforeSend:function(e){a.callbacks&&a.callbacks.beforeSend&&a.callbacks.beforeSend(e)},success:function(e){a.callbacks&&a.callbacks.success&&a.callbacks.success(e)},error:function(e,t,s){a.callbacks&&a.callbacks.error&&a.callbacks.error(e,t,s)},complete:function(e,t){a.callbacks&&a.callbacks.complete&&a.callbacks.complete(e,t)}})}}}).functions.init()}(jQuery);
  • psupsellmaster/trunk/includes/admin/functions-ajax.php

    r3174351 r3192288  
    627627
    628628/**
    629  * Assign multiple terms to multiple products.
     629 * Update (assign or unassign) multiple terms to multiple products.
    630630 */
    631 function psupsellmaster_ajax_assign_multiple_product_terms() {
     631function psupsellmaster_ajax_update_multiple_product_terms() {
    632632    // Check the nonce.
    633633    check_ajax_referer( 'psupsellmaster-ajax-nonce', 'nonce' );
     
    644644    }
    645645
     646    // Get the context.
     647    $context = isset( $_POST['context'] ) ? sanitize_text_field( $_POST['context'] ) : '';
     648
     649    // Check if the context is empty.
     650    if ( empty( $context ) ) {
     651        // Send the output.
     652        wp_send_json( $output );
     653    }
     654
    646655    // Get the selectors.
    647656    $selectors = isset( $_POST['selectors'] ) ? map_deep( wp_unslash( $_POST['selectors'] ), 'sanitize_text_field' ) : array();
     
    676685    }
    677686
     687    // Set the term args.
     688    $term_args = array( 'taxonomies' => $taxonomies );
     689
     690    // Check the context.
     691    if ( 'assign' === $context ) {
     692        // Set the term args.
     693        $term_args['should_insert'] = true;
     694    }
     695
    678696    // Get the sanitized taxonomies.
    679     $taxonomies = psupsellmaster_insert_mixed_taxonomy_terms( array( 'taxonomies' => $taxonomies ) );
     697    $taxonomies = psupsellmaster_sanitize_mixed_taxonomy_terms( $term_args );
    680698
    681699    // Check if the taxonomies is empty.
     
    691709    );
    692710
    693     // Assign the terms to the products.
    694     psupsellmaster_assign_object_taxonomy_terms( $args );
     711    // Check the context.
     712    if ( 'assign' === $context ) {
     713        // Assign the terms to the products.
     714        psupsellmaster_assign_object_taxonomy_terms( $args );
     715
     716        // Check the context.
     717    } elseif ( 'unassign' === $context ) {
     718        // Assign the terms to the products.
     719        psupsellmaster_unassign_object_taxonomy_terms( $args );
     720    }
    695721
    696722    // Set the output: success.
     
    700726    wp_send_json( $output );
    701727}
    702 add_action( 'wp_ajax_psupsellmaster_ajax_assign_multiple_product_terms', 'psupsellmaster_ajax_assign_multiple_product_terms' );
     728add_action( 'wp_ajax_psupsellmaster_ajax_update_multiple_product_terms', 'psupsellmaster_ajax_update_multiple_product_terms' );
    703729
    704730/**
  • psupsellmaster/trunk/includes/admin/functions-campaigns.php

    r3111914 r3192288  
    889889            case 'taxonomies':
    890890                // Set the sanitized synced.
    891                 $sanitized_synced[ $synced_key ] = psupsellmaster_insert_mixed_taxonomy_terms( $synced );
     891                $sanitized_synced[ $synced_key ] = psupsellmaster_sanitize_mixed_taxonomy_terms(
     892                    array(
     893                        ...$synced,
     894                        'should_insert' => true,
     895                    )
     896                );
    892897        }
    893898    }
  • psupsellmaster/trunk/includes/admin/templates/campaigns/edit.php

    r3174351 r3192288  
    860860                    </section>
    861861                    <?php if ( psupsellmaster_is_pro() ) : ?>
    862                         <section class="psupsellmaster-subsection psupsellmaster-subsection-assign-tags">
     862                        <section class="psupsellmaster-subsection psupsellmaster-subsection-update-tags">
    863863                            <h3 class="psupsellmaster-section-title"><?php esc_html_e( 'UpsellMaster Tags', 'psupsellmaster' ); ?></h3>
    864864                            <p class="psupsellmaster-section-subtitle">
    865865                                <span>
    866                                     <?php esc_html_e( 'Easily assign UpsellMaster Tags to the selected products.', 'psupsellmaster' ); ?>
     866                                    <?php esc_html_e( 'Easily assign and unassign UpsellMaster Tags to the selected products.', 'psupsellmaster' ); ?>
    867867                                </span>
    868868                            </p>
     
    892892                                        }
    893893                                        ?>
    894                                         <label><strong><?php esc_html_e( 'Assign UpsellMaster Tags', 'psupsellmaster' ); ?></strong></label>
     894                                        <label><strong><?php esc_html_e( 'UpsellMaster Tags', 'psupsellmaster' ); ?></strong></label>
    895895                                        <select class="psupsellmaster-select2 psupsellmaster-field psupsellmaster-field-synced-tags" data-ajax-action="psupsellmaster_get_taxonomy_terms" data-ajax-nonce="<?php echo esc_attr( wp_create_nonce( 'psupsellmaster-ajax-get-taxonomy-terms' ) ); ?>" data-ajax-url="<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>" data-clear="true" data-custom="true" data-multiple="true" data-placeholder="<?php esc_attr_e( 'Choose...', 'psupsellmaster' ); ?>" data-taxonomy="<?php echo esc_attr( $taxonomy_name ); ?>" id="synced[taxonomies][<?php echo esc_attr( $taxonomy_name ); ?>][]" multiple="multiple" name="synced[taxonomies][<?php echo esc_attr( $taxonomy_name ); ?>][]">
    896896                                            <?php foreach ( $options as $option ) : ?>
     
    900900                                    </div>
    901901                                </div>
    902                                 <div class="psupsellmaster-form-row">
     902                                <div class="psupsellmaster-form-row psupsellmaster-form-actions">
    903903                                    <div class="psupsellmaster-form-btn">
    904                                         <button class="button psupsellmaster-btn-assign-tags" type="button"><?php esc_html_e( 'Assign', 'psupsellmaster' ); ?></button>
    905                                         <span class="spinner"></span>
     904                                        <button class="button psupsellmaster-btn-update-tags" data-action="assign" type="button">
     905                                            <span><?php esc_html_e( 'Assign', 'psupsellmaster' ); ?></span>
     906                                            <span class="spinner" style="display: none;"></span>
     907                                        </button>
     908                                    </div>
     909                                    <div>
     910                                        <span><?php esc_html_e( 'or', 'psupsellmaster' ); ?></span>
     911                                    </div>
     912                                    <div class="psupsellmaster-form-btn">
     913                                        <button class="button psupsellmaster-btn-update-tags" data-action="unassign" type="button">
     914                                            <span><?php esc_html_e( 'Unassign', 'psupsellmaster' ); ?></span>
     915                                            <span class="spinner" style="display: none;"></span>
     916                                        </button>
    906917                                    </div>
    907918                                </div>
  • psupsellmaster/trunk/includes/functions.php

    r3174351 r3192288  
    60826082
    60836083/**
     6084 * Unassign multiple terms from multiple taxonomies to multiple objects.
     6085 *
     6086 * @param array $args The arguments.
     6087 */
     6088function psupsellmaster_unassign_object_taxonomy_terms( $args ) {
     6089    // Get the objects.
     6090    $objects = isset( $args['objects'] ) ? $args['objects'] : false;
     6091    $objects = is_array( $objects ) ? $objects : array();
     6092
     6093    // Check if the objects is empty.
     6094    if ( empty( $objects ) ) {
     6095        return;
     6096    }
     6097
     6098    // Get the taxonomies.
     6099    $taxonomies = isset( $args['taxonomies'] ) ? $args['taxonomies'] : false;
     6100    $taxonomies = is_array( $taxonomies ) ? $taxonomies : array();
     6101
     6102    // Check if the taxonomies is empty.
     6103    if ( empty( $taxonomies ) ) {
     6104        return;
     6105    }
     6106
     6107    // Loop through the objects.
     6108    foreach ( $objects as $object_id ) {
     6109        // Loop through the taxonomies.
     6110        foreach ( $taxonomies as $taxonomy => $terms ) {
     6111            // Get the current terms.
     6112            $current_terms = wp_get_object_terms( $object_id, $taxonomy, array( 'fields' => 'ids' ) );
     6113
     6114            // Set the updated terms.
     6115            $updated_terms = array_diff( $current_terms, $terms );
     6116
     6117            // Add the terms to the product.
     6118            wp_set_object_terms( $object_id, $updated_terms, $taxonomy, false );
     6119        }
     6120    }
     6121}
     6122
     6123/**
    60846124 * Handles multiple taxonomies and terms, both string and int types.
    60856125 * It checks each term type. If it is numeric, it will check if its a valid term ID.
     
    60916131 * @return array The terms.
    60926132 */
    6093 function psupsellmaster_insert_mixed_taxonomy_terms( $args ) {
     6133function psupsellmaster_sanitize_mixed_taxonomy_terms( $args ) {
     6134    // Set the defaults.
     6135    $defaults = array(
     6136        'taxonomies'    => array(),
     6137        'should_insert' => false,
     6138    );
     6139
     6140    // Parse the args.
     6141    $parsed_args = wp_parse_args( $args, $defaults );
     6142
    60946143    // Set the sanitized.
    60956144    $sanitized = array();
    60966145
    60976146    // Get the taxonomies.
    6098     $taxonomies = isset( $args['taxonomies'] ) ? $args['taxonomies'] : array();
     6147    $taxonomies = isset( $parsed_args['taxonomies'] ) ? $parsed_args['taxonomies'] : array();
    60996148
    61006149    // Check the taxonomies.
     
    61326181                // Otherwise...
    61336182            } else {
    6134                 // Set the term.
    6135                 $term = wp_insert_term( $value, $taxonomy );
     6183                // Get the term.
     6184                $term = get_term_by( 'name', $value, $taxonomy, ARRAY_A );
     6185
     6186                // Check if the term is empty.
     6187                if ( empty( $term ) ) {
     6188                    // Check if the term should NOT be inserted.
     6189                    if ( ! $parsed_args['should_insert'] ) {
     6190                        continue;
     6191                    }
     6192
     6193                    // Set the term.
     6194                    $term = wp_insert_term( $value, $taxonomy );
     6195                }
    61366196
    61376197                // Check if the term couldn't be inserted.
  • psupsellmaster/trunk/includes/integrations/easy-digital-downloads/functions-sessions.php

    r3107510 r3192288  
    2121    $value = null;
    2222
    23     // Get the data.
    24     $data = EDD()->session->get( 'psupsellmaster' );
    25     $data = is_array( $data ) ? $data : array();
    26 
    27     // Check if the key exists.
    28     if ( array_key_exists( $key, $data ) ) {
    29         // Set the value.
    30         $value = $data[ $key ];
     23    // Check the session.
     24    if ( isset( EDD()->session ) ) {
     25        // Get the data.
     26        $data = EDD()->session->get( 'psupsellmaster' );
     27        $data = is_array( $data ) ? $data : array();
     28   
     29        // Check if the key exists.
     30        if ( array_key_exists( $key, $data ) ) {
     31            // Set the value.
     32            $value = $data[ $key ];
     33        }
    3134    }
    3235
     
    4245 */
    4346function psupsellmaster_edd_session_set( $key, $value ) {
     47    // Check the session.
     48    if ( ! isset( EDD()->session ) ) {
     49        return;
     50    }
     51
    4452    // Set the slug.
    4553    $slug = 'psupsellmaster';
  • psupsellmaster/trunk/includes/integrations/woocommerce/functions-sessions.php

    r3107510 r3192288  
    2121    $value = null;
    2222
    23     // Get the data.
    24     $data = WC()->session->get( 'psupsellmaster' );
    25     $data = is_array( $data ) ? $data : array();
    26 
    27     // Check if the key exists.
    28     if ( array_key_exists( $key, $data ) ) {
    29         // Set the value.
    30         $value = $data[ $key ];
     23    // Check the session.
     24    if ( isset( WC()->session ) ) {
     25        // Get the data.
     26        $data = WC()->session->get( 'psupsellmaster' );
     27        $data = is_array( $data ) ? $data : array();
     28
     29        // Check if the key exists.
     30        if ( array_key_exists( $key, $data ) ) {
     31            // Set the value.
     32            $value = $data[ $key ];
     33        }
    3134    }
    3235
     
    4245 */
    4346function psupsellmaster_woo_session_set( $key, $value ) {
     47    // Check the session.
     48    if ( ! isset( WC()->session ) ) {
     49        return;
     50    }
     51
    4452    // Set the slug.
    4553    $slug = 'psupsellmaster';
  • psupsellmaster/trunk/psupsellmaster.php

    r3174351 r3192288  
    44 * Plugin URI:        https://www.pluginsandsnippets.com/downloads/upsellmaster/
    55 * Description:       UpsellMaster increases website conversion by adding tailored upsell suggestions for WooCommerce and Easy Digital Downloads webshops. Choose between displaying upsells (selected automatically), time-limited discount campaigns or recently viewed products and systematically see an increase in order values.
    6  * Version:           2.0.21
     6 * Version:           2.0.22
    77 * Author:            Plugins & Snippets
    88 * Author URI:        https://pluginsandsnippets.com/
     
    9393
    9494        // Set the base constants.
    95         define( 'PSUPSELLMASTER_VER', '2.0.21' );
     95        define( 'PSUPSELLMASTER_VER', '2.0.22' );
    9696        define( 'PSUPSELLMASTER_NAME', 'UpsellMaster' );
    9797        define( 'PSUPSELLMASTER_FILE', __FILE__ );
  • psupsellmaster/trunk/readme.txt

    r3174351 r3192288  
    88Tested up to: 6.5
    99Requires PHP: 5.6
    10 Stable Tag: 2.0.21
     10Stable Tag: 2.0.22
    1111License: GPL v2 or later
    1212License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    168168
    169169== Changelog ==
     170
     171= Version 2.0.22 - November 13, 2024 =
     172New: Button to bulk-unassign tags from products on Campaigns Edit and Tags pages
     173Fix: General bugs
    170174
    171175= Version 2.0.21 - October 22, 2024 =
Note: See TracChangeset for help on using the changeset viewer.