1 line
4.7 KiB
JavaScript
1 line
4.7 KiB
JavaScript
(c=>{c(document).ready(function(){function e(o){fetch(oc_home_ajax_obj.ajax_url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({action:"oc_update_consent_status",consent_status:o})}).then(e=>e.json()).then(e=>{e.success?(c(".oc-consent-toast-container").show(),c("#oc-consent-toast-success .gv-toast").addClass("gv-visible"),setTimeout(function(){c("#oc-consent-toast-success .gv-toast").removeClass("gv-visible")},5e3),c("#oc-data-consent-banner").hide(),1===o&&c("#oc-data-consent-toggle").prop("checked",!0),localStorage.setItem("onecom_data_consent_status",e.data.consent_status?"1":"0"),e=new CustomEvent("onConsentStatusChanged",{detail:{data_consent_status:e.data.consent_status}}),window.dispatchEvent(e)):(c(".oc-consent-toast-container").show(),c("#oc-consent-toast-failure .gv-toast").addClass("gv-visible"),setTimeout(function(){c("#oc-consent-toast-failure .gv-toast").removeClass("gv-visible")},5e3))}).catch(e=>{c(".oc-consent-toast-container").show(),c("#oc-consent-toast-failure .gv-toast").addClass("gv-visible"),setTimeout(function(){c("#oc-consent-toast-failure .gv-toast").removeClass("gv-visible")},5e3)})}c("#oc-restart-tour").click(function(){console.info("Restart tour")}),c(".gv-notice-close.restart-tour").click(function(){let o=c(this);c.post(oc_home_ajax_obj.ajax_url,{_ajax_nonce:oc_home_ajax_obj.nonce,action:"oc_home_silence_tour",title:this.value},function(e){"success"===e.status&&o.parents(".gv-notice").fadeOut()})}),c("#oc-start-tour, #oc_login_masking_overlay_wrap .oc_welcome_modal_close").on("click",function(e){e.preventDefault(),c("#oc_login_masking_overlay").hide(),c(".loading-overlay.fullscreen-loader").removeClass("show");let o=!0;console.log(c(this)),c(this).hasClass("oc_welcome_modal_close")&&(o=!1);c.post(oc_home_ajax_obj.ajax_url,{action:"oc_close_welcome_modal",nonce:"asdsadsad"}).done(function(e){e&&o?window.location.href=oc_home_ajax_obj.home_url:console.log("modal closed")}).fail(function(){console.error("Failed to close the welcome modal.")})}),c(".oc_consent_modal_show").on("click",function(e){e.preventDefault(),c("#oc_data_consent_overlay").show()}),c("#oc-consent-modal-close, #oc_data_consent_overlay .oc_welcome_modal_close").on("click",function(e){e.preventDefault(),c("#oc_data_consent_overlay").hide(),c(".loading-overlay.fullscreen-loader").removeClass("show")}),c("#oc-consent-settings input[type='checkbox']").on("click",function(){e(c(this).is(":checked")?1:0)}),c(".oc-data-consent-decline").on("click",function(){e(0)}),c(".oc-data-consent-accept").on("click",function(){e(1)}),c(".oc-consent-toast-container .gv-toast-close").on("click",function(){c(".oc-consent-toast-container .gv-toast").removeClass("gv-visible")}),c(".oc_premium_care_modal_show").on("click",function(e){e.preventDefault(),c("#oc_premium_care_overlay").show()});var o=new URLSearchParams(window.location.search);"onecom-home"===o.get("page")&&"1"===o.get("request-premium-wp-care")&&(c("#oc_premium_care_overlay").show(),history.replaceState(null,null,window.location.pathname+"?page=onecom-home")),c("#oc-premium-care-modal-close, #oc_premium_care_overlay .oc_welcome_modal_close").on("click",function(e){e.preventDefault(),c("#oc_premium_care_overlay").hide(),c(".loading-overlay.fullscreen-loader").removeClass("show"),c("#premium-care-request-error").hide()}),c(".oc-premium-care-box .gv-notice-close").on("click",function(e){c.post(oc_home_ajax_obj.ajax_url,{_ajax_nonce:oc_home_ajax_obj.nonce,action:"oc_home_premium_care_dismiss"},function(e){"success"===e.status?c(".oc-premium-care-box").hide():console.error("Error: Failed to dismiss premium wp care tile.")})}),c("#oc-premium-care-request-notice .gv-notice-close").on("click",function(e){c("#oc-premium-care-request-notice").hide()}),c("#oc-premium-care-request-action").on("click",function(){{let e=c("#oc-premium-care-description").val(),o={action:"oc_request_premium_care",premium_wp_request:1,text:e};c("#modal-loader-overlay").css("display","flex"),fetch(oc_home_ajax_obj.ajax_url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(o)}).then(e=>e.json()).then(e=>{c("#modal-loader-overlay").hide(),e.success?(c(".gv-notice-premium-care").hide(),c(".gv-notice-premium-care-requested").removeClass("gv-hidden"),c("#oc-premium-care-request-notice").removeClass("gv-hidden"),c("#oc_premium_care_overlay").hide(),c(".loading-overlay.fullscreen-loader").removeClass("show"),c("html, body").animate({scrollTop:c(".inner-wrapper").offset().top},500)):(c("#modal-loader-overlay").hide(),c("#premium-care-request-error").css("display","flex"))}).catch(e=>{c("#modal-loader-overlay").hide(),c("#premium-care-request-error").css("display","flex")})}})})})(jQuery); |