PageSourceSearch

https://vraagdevroedvrouw.nl/wp-content/plugins/woocommerce-smart-…/product-page-gift-form.min.js?ver=9.65.0

js vraagdevroedvrouw.nl collected 2026-10-02 15:14:27 UTC 11,518 bytes, 9 lines download raw bytes

1/**
2 * Product Page Gift Form Minified JavaScript
3 *
4 * Handles the gift certificate receiver form on product pages.
5 * Requires wp_localize_script with object 'wcScProductPageGiftForm'.
6 *
7 * @package woocommerce-smart-coupons
8 */
9!function(){"use strict";function e(){const e=document.querySelector(".wc-sc-product-page-gift-form");if(!e)return;const t="undefined"!=typeof wcScProductPageGiftForm?wcScProductPageGiftForm:{},n=t.ajaxUrl||"",c=t.ajaxNonce||"",i=t.datepickerOptions||{},s=t.i18n||{},r=JSON.parse(e.getAttribute("data-coupons")||"[]"),a="yes"===e.getAttribute("data-schedule-enabled"),o=e.querySelector("#wc_sc_product_gift_form_accordions"),d=e.getAttribute("data-accordion-state")||"collapsed",l=JSON.parse(e.getAttribute("data-session-data")||"{}"),u=parseInt(e.getAttribute("data-product-id"),10)||0,_=e.getAttribute("data-currency-symbol")||"$",g=e.getAttribute("data-currency-position")||"left",f=parseInt(e.getAttribute("data-price-decimals"),10)||2,m=e.getAttribute("data-price-decimal-sep")||".",p=e.getAttribute("data-price-thousand-sep")||",";let h=null;const v=function(){const e=["input.qty",'input[name="quantity"]','form.cart input[type="number"][name*="quantity"]',"form.cart .quantity input",'.quantity input[type="number"]'];for(const t of e){const e=document.querySelector(t);if(e)return e}return null};h=v();let y=h&&h.value&&parseInt(h.value,10)||1;const w=()=>{const t={wc_sc_schedule_gift_sending:Array.from(e.querySelectorAll(".wc-sc-person-schedule-toggle")).some((e=>e.checked))?"yes":"no",gift_receiver_email:{},gift_receiver_message:{},gift_sending_date_time:{}};return["gift_receiver_email","gift_receiver_message","gift_sending_date_time"].forEach((n=>{e.querySelectorAll("."+n).forEach((e=>{const c=(e=>{const t=e.match(/\[(\d+)\]\[(\d+)\]/);return t?{couponId:parseInt(t[1],10),personIndex:parseInt(t[2],10)}:null})(e.name);c&&(t[n][c.couponId]||(t[n][c.couponId]={}),t[n][c.couponId][c.personIndex]=e.value?e.value.trim():"")}))})),t};function S(){return new Promise(((e,t)=>{const i=w(),r=new URLSearchParams;r.append("wc_sc_schedule_gift_sending",i.wc_sc_schedule_gift_sending||"no");new Set([...Object.keys(i.gift_receiver_email),...Object.keys(i.gift_receiver_message),...Object.keys(i.gift_sending_date_time)]).forEach((e=>{const t=parseInt(e,10);if(isNaN(t))return;const n=new Set;["gift_receiver_email","gift_receiver_message","gift_sending_date_time"].forEach((t=>{i[t][e]&&Object.keys(i[t][e]).forEach((e=>n.add(parseInt(e,10))))})),n.forEach((n=>{if(isNaN(n))return;const c=(i.gift_receiver_email[e]&&i.gift_receiver_email[e][n]||"").trim(),s=(i.gift_receiver_message[e]&&i.gift_receiver_message[e][n]||"").trim(),a=(i.gift_sending_date_time[e]&&i.gift_sending_date_time[e][n]||"").trim();c&&(r.append(`gift_receiver_email[${t}][${n}]`,c),r.append(`gift_receiver_message[${t}][${n}]`,s),r.append(`gift_sending_date_time[${t}][${n}]`,a))}))}));const a=new URLSearchParams;a.append("action","wc_sc_save_product_page_coupon_receiver_details"),a.append("security",c),a.append("product_id",u),a.append("data",r.toString()),fetch(n,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:a.toString()}).then((e=>{if(!e.ok)throw new Error("HTTP error: "+e.status);return e.json()})).then((n=>{"yes"===n.success?(["gift_receiver_email","gift_receiver_message","gift_sending_date_time"].forEach((e=>{l[e]||(l[e]={}),Object.keys(i[e]).forEach((t=>{l[e][t]||(l[e][t]={}),Object.assign(l[e][t],i[e][t])}))})),i.wc_sc_schedule_gift_sending&&(l.wc_sc_schedule_gift_sending=i.wc_sc_schedule_gift_sending),e(n)):t(new Error((s.sessionSaveFailed||"Session save failed")+": "+(n.message||s.unknownError||"Unknown error")))})).catch(t)}))}const E=e=>e?document.createElement("div").appendChild(document.createTextNode(e)).parentNode.innerHTML:"";function b(e){if(!e||isNaN(e)||e<=0)return"";const t=parseFloat(e).toFixed(f).split(".");t[0]=t[0].replace(/\B(?=(\d{3})+(?!\d))/g,p);const n=t.join(m),c={left:_+n,right:n+_,left_space:_+" "+n,right_space:n+" "+_};return'<span class="woocommerce-Price-amount amount"><bdi>'+E(c[g]||c.left)+"</bdi></span>"}const q=()=>{const e=document.querySelector("#credit_called")?.value,t=parseFloat(e);return!isNaN(t)&&t>0?t:0};function $(){const t=q();e.querySelectorAll(".wc-sc-gift-item").forEach((e=>{const n=e.getAttribute("data-coupon-id");if(!n)return;const c=r.find((e=>String(e.id)===String(n)));if(!c)return;if(!c.uses_credit_called)return;let i=e.querySelector(".amount");const a=e.querySelector(".email_amount");if(a)if(t>0){const e=b(t);if(e){const t=(s.send||"Send")+" "+E(c.formatted_text)+" "+(s.of||"of")+" "+e;if(!i){i=document.createElement("div"),i.className="amount";const e=a.querySelector(".email");e?a.insertBefore(i,e):a.appendChild(i)}i.innerHTML=t,i.style.display=""}}else i&&(i.innerHTML="",i.style.display="none")}))}function T(e,t={}){if(!o||!r||0===r.length)return null;const n=document.createElement("div");n.className="wc-sc-gift-accordion",n.setAttribute("data-person-index",e);const c=document.createElement("div");c.className="wc-sc-gift-accordion-header";let i="";const l="yes"===t.wc_sc_schedule_gift_sending;a&&(i=`<div class="wc-sc-schedule-toggle-wrapper">\n\t\t\t\t<label class="wc-sc-toggle-check">\n\t\t\t\t\t<input type="checkbox" class="wc-sc-toggle-check-input wc-sc-person-schedule-toggle" data-person-index="${e}" ${l?"checked":""} />\n\t\t\t\t\t<span class="wc-sc-toggle-check-text"></span>\n\t\t\t\t</label>\n\t\t\t</div>`),c.innerHTML=`<span class="wc-sc-accordion-title">${s.giftToPerson||"GIFT to person"} ${e+1}</span>${i}<span class="accordion-toggle">${"expanded"===d?"−":"+"}</span>`;const u=document.createElement("div");return u.className="wc-sc-gift-accordion-content","expanded"===d&&u.classList.add("expanded"),r.forEach((n=>{const c=function(e,t,n={},c=!1){const i=document.createElement("div");i.className="wc-sc-gift-item",i.setAttribute("data-coupon-id",e.id),i.setAttribute("data-person-index",t);const r=`gift_receiver_email[${e.id}][${t}]`,o=`gift_receiver_message[${e.id}][${t}]`,d=`gift_sending_date_time[${e.id}][${t}]`,l=c=>
9n[c]?.[e.id]?.[t]?E(String(n[c][e.id][t])):"",u=l("gift_receiver_email"),_=l("gift_receiver_message"),g=l("gift_sending_date_time");let f="";if(e.uses_credit_called){const t=q();if(t>0){const n=b(t);n&&(f=(s.send||"Send")+" "+E(e.formatted_text)+" "+(s.of||"of")+" "+n)}}else f=(s.send||"Send")+" "+E(e.formatted_text)+" "+(s.of||"of")+" "+e.formatted_amount;const m=`<div class="email_amount">\n\t\t\t\t${f?`<div class="amount">${f}</div>`:""}\n\t\t\t\t<div class="email"><input class="gift_receiver_email" type="text" placeholder="${s.enterRecipientEmail||"Enter recipient e-mail address"}..." name="${r}" value="${u}" /></div>\n\t\t\t</div>`,p=`<div class="message_row">\n\t\t\t\t<div class="sc_message"><textarea placeholder="${s.writeMessage||"Write a message"}..." class="gift_receiver_message" name="${o}" cols="50" rows="5">${_}</textarea></div>\n\t\t\t</div>`;let h="";a&&(h=`<div class="email_sending_date_time_wrapper" style="${c?"":"display:none;"}">\n\t\t\t\t\t<input class="gift_sending_date_time" type="text" placeholder="${s.pickDeliveryDateTime||"Pick a delivery date & time"}..." name="${d}" value="${g}" autocomplete="off" style="position: relative; z-index: 99997;"/>\n\t\t\t\t</div>`);return i.innerHTML=`<div class="form_table">${m}${h}${p}</div>`,i}(n,e,t,l);c&&u.appendChild(c)})),n.appendChild(c),n.appendChild(u),o.appendChild(n),setTimeout((()=>{const e=n.querySelector(".wc-sc-person-schedule-toggle");if(e){n.querySelectorAll(".email_sending_date_time_wrapper").forEach((t=>{t.style.display=e.checked?"block":"none"}))}}),0),n}const k=(e,t)=>{const n=e.querySelector(".wc-sc-gift-accordion-content"),c=e.querySelector(".accordion-toggle");n&&n.classList.toggle("expanded",t),c&&(c.textContent=t?"−":"+")};function L(){if(o&&!(y<=0)){o.innerHTML="";for(let e=0;e<y;e++)T(e,l);!function(){const t=()=>{if("undefined"==typeof jQuery||!jQuery.fn.datetimepicker)return void setTimeout(t,100);const n=Object.assign({},i);n.isRTL=!("undefined"==typeof wp||!wp.i18n||!wp.i18n.isRTL)&&wp.i18n.isRTL(),e.querySelectorAll(".gift_sending_date_time:not(.hasDatepicker)").forEach((e=>{jQuery(e).datetimepicker(n)}))};setTimeout(t,300)}(),setTimeout($,100)}}h||(h=v()),function(){const t=document.querySelector("#credit_called");if(t){let e;const n=()=>{clearTimeout(e),e=setTimeout($,300)};t.addEventListener("input",n),t.addEventListener("change",n),setTimeout($,500)}let i;const s=e=>{(e=parseInt(e,10)||0)<0||e===y||S().then((()=>{const t=y;y=e,h&&h.value!=e&&(h.value=e),L();if(o.querySelectorAll(".wc-sc-gift-accordion").forEach((e=>k(e,!1))),e>t){const t=o.querySelector(`.wc-sc-gift-accordion[data-person-index="${e-1}"]`);t&&k(t,!0)}setTimeout((()=>S().catch((()=>{}))),100)})).catch((()=>{y=e,L()}))},r=()=>{if(h||(h=v()),!h)return;const e=function(){clearTimeout(i),i=setTimeout((()=>s(this.value)),300)};h.addEventListener("change",e),h.addEventListener("input",e),document.querySelectorAll(".quantity .plus, .quantity .minus, .qty-button").forEach((e=>{e.addEventListener("click",(()=>{setTimeout((()=>{const e=v();e&&e.value&&(h=e,s(e.value))}),100)}))}))};let a;h?r():setTimeout(r,500),o.addEventListener("change",(t=>{if(!t.target.classList.contains("wc-sc-person-schedule-toggle"))return;const n=t.target.checked;l.wc_sc_schedule_gift_sending=Array.from(e.querySelectorAll(".wc-sc-person-schedule-toggle")).some((e=>e.checked))?"yes":"no";const c=t.target.closest(".wc-sc-gift-accordion");c&&c.querySelectorAll(".email_sending_date_time_wrapper").forEach((e=>{e.style.display=n?"block":"none"})),S().catch((()=>{}))})),o.addEventListener("click",(e=>{if(e.target.closest(".wc-sc-schedule-toggle-wrapper")||e.target.closest(".wc-sc-toggle-check"))return;const t=e.target.closest(".wc-sc-gift-accordion-header");if(t){const e=t.parentElement,n=e.querySelector(".wc-sc-gift-accordion-content").classList.contains("expanded");k(e,!n)}}));const d=()=>{clearTimeout(a),a=setTimeout((()=>S().catch((()=>{}))),500)};e.addEventListener("blur",(e=>{e.target.matches(".gift_receiver_email, .gift_receiver_message, .gift_sending_date_time")&&d()}),!0),e.addEventListener("input",(e=>{e.target.matches(".gift_receiver_email, .gift_receiver_message, .gift_sending_date_time")&&d()}),!0);const _=e.closest("form.cart");if(_){_.addEventListener("submit",(()=>{const e=w();let t="wc_sc_schedule_gift_sending="+encodeURIComponent(e.wc_sc_schedule_gift_sending||"no");["gift_receiver_email","gift_receiver_message","gift_sending_date_time"].forEach((n=>
9{Object.keys(e[n]).forEach((c=>{Object.keys(e[n][c]).forEach((i=>{const s=e[n][c][i];s&&s.trim()&&(t+="&"+n+"["+c+"]["+i+"]="+encodeURIComponent(s.trim()))}))}))}));const i=new XMLHttpRequest;i.open("POST",n,!1),i.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),i.send("action=wc_sc_save_product_page_coupon_receiver_details&security="+c+"&product_id="+u+"&data="+encodeURIComponent(t))}),!0);let t=!1;const i=()=>{t||(e.querySelectorAll(".gift_receiver_email, .gift_receiver_message, .gift_sending_date_time").forEach((e=>e.value="")),e.querySelectorAll(".wc-sc-person-schedule-toggle").forEach((e=>e.checked=!1)),e.querySelectorAll(".email_sending_date_time_wrapper").forEach((e=>e.style.display="none")),t=!0)};document.body.addEventListener("added_to_cart",i),"undefined"!=typeof jQuery&&jQuery(document.body).on("added_to_cart",i)}}(),L()}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()}();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.