if (!window.Giftify) { window.Giftify = { checkoutButton: false, init: function() { this.reset(); this.insertStyle(); this.initiateButton(); }, reset: function() { var xhr = new XMLHttpRequest; xhr.open('POST', window.Shopify.routes.root + 'cart/update.js'); xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8'); xhr.send(JSON.stringify({ attributes: { 'Giftify • To': '', 'Giftify • From': '', 'Giftify • Message': '' } })); }, insertStyle: function() { var head = document.head || document.getElementsByTagName('head')[0], style = document.createElement('style'); style.type = 'text/css'; style.appendChild(document.createTextNode(' .giftify-wrapper { width: 100% } .giftify-button { margin: 25px 0px 5px 0px; display: inline-block; transition: all .2s ease; text-decoration: none!important; } .giftify-button span { background: #ffffff; color: #000000; border-radius: 50px; border: 2px solid #ffffff; padding: 5px 5px 5px 5px; display: flex; white-space: nowrap; transition: all .2s ease; align-items: center; justify-content: center; } .giftify-button svg { fill: #000000; display: inline-block; margin-right: 5px; width: 24px; height: 24px; transition: all .2s ease; } .giftify-button:hover span { background: #ffffff; color: #000000; border-color: #000000; } .giftify-button:hover svg { fill: #000000; } .giftify-popup { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 999; opacity: 0; visibility: hidden; pointer-events: none; transition: all .5s ease; } .giftify-popup.giftify-popup--loading { pointer-events: none; } .giftify-popup.giftify-popup--active { opacity: 1; visibility: visible; pointer-events: all; } .giftify-popup.giftify-popup--active .giftify-popup__inside { transition-delay: .3s; opacity: 1; margin-top: 0; } .giftify-popup__bg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,.6); z-index: 1; display: block!important; } .giftify-popup__inside { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: #fff; width: 90%; max-width: 460px; display: flex; align-items: stretch; z-index: 2; transition: margin .5s Cubic-bezier(0.3, 0, 0.3, 1), opacity .3s ease; margin-top: 50px; opacity: 0; } .giftify-popup__close { position: absolute; top: 0; right: 0; width: 48px; height: 48px; z-index: 3; display: flex; align-items: center; justify-content: center; } .giftify-popup__close svg { fill: #191919; width: 24px; } .giftify-popup__grid { display: flex; width: 100%; } .giftify-popup__right { width: 50%; display: block!important; background-size: cover; background-position: center; background-repeat: no-repeat; } .giftify-popup__left { width: 100%; padding: 50px 50px 75px; position: relative; } .giftify-popup__header { text-align: center; } .giftify-popup__header img { max-height: 50px; } .giftify-popup__title { color: #191919; font-size: 32px; margin: 20px 0; } .giftify-popup__steps + div { font-size: 13px; position: absolute; left: 0; width: 100%; bottom: 10px; text-align: center; } .giftify-popup__steps + div a { color: #191919; border-bottom: 1px solid transparent; } .giftify-popup__steps + div a:hover { border-bottom-color: #191919; } .giftify-popup__step { display: none; } .giftify-popup__step--active { display: block; } .giftify-popup__action { margin-top: 20px; display: flex; align-items: center; justify-content: center; } .giftify-popup__button { margin: 5px; display: inline-block; transition: all .2s ease; padding: 0; border: 0; border-radius: 0!important; background: none!important; cursor: pointer; } .giftify-popup__button span { border-radius: 50px; padding: 15px 20px 15px 20px; display: flex; white-space: nowrap; transition: all .2s ease; position: relative; } .giftify-popup__next span { background: #000000; color: #ffffff; border: 2px solid #000000; position: relative; } .giftify-popup__next:hover span { background: #ffffff; color: #000000; border-color: #000000; } .giftify-popup__prev span { background: #000000; color: #ffffff; border: 2px solid #000000; } .giftify-popup__prev:hover span { background: #ffffff; color: #000000; border-color: #000000; } .giftify-popup__next span::after { content: ""; position: absolute; top: 50%; left: 50%; width: 20px; height: 20px; border: 3px solid #ffffff; border-top: 3px solid transparent!important; border-radius: 50%; margin-left: -10px; margin-top: -10px; opacity: 0; -webkit-animation: giftify_spin .7s linear infinite; animation: giftify_spin .7s linear infinite; } @-webkit-keyframes giftify_spin { 100% { -webkit-transform: rotate(360deg); } } @keyframes giftify_spin { 100% { -webkit-transform: rotate(360deg); transform:rotate(360deg); } } .giftify-popup__step ol { counter-reset: giftify; list-style: none; padding: 0; } .giftify-popup__step li { color: #191919; font-size: 16px; counter-increment: giftify; position: relative; padding-left: 30px; display: block; } .giftify-popup__step li + li { margin-top: 5px; } .giftify-popup__step li::before { content: counter(giftify)"."; font-weight: bold; top: 0; left: 0; position: absolute; } .giftify-popup__label { font-weight: bold; text-align: center; } .giftify-popup__field { margin: 5px 0 10px; } .giftify-popup__grid > .giftify-popup__field { width: 50%; padding-right: 2px; } .giftify-popup__grid > .giftify-popup__field + .giftify-popup__field { padding-left: 2px; } .giftify-popup__field > * { width: 100%; } .giftify-popup__field input, .giftify-popup__field textarea { padding: 10px; border: 1px solid #d2d2d2; } .giftify-popup--loading .giftify-popup__next span { color: transparent!important; } .giftify-popup--loading .giftify-popup__next span::after { opacity: 1; } ')); head.appendChild(style); }, initiateButton: function() { var wrappers = document.querySelectorAll('.giftify-wrapper'), checkoutButtons = document.querySelectorAll('[name="checkout"]'); if (wrappers.length) { this.renderButton(); } else if (checkoutButtons.length) { this.checkoutButton = checkoutButtons[0]; checkoutButtons.forEach(function(checkoutButton) { var el = document.createElement('div'); el.classList.add('giftify-wrapper'); checkoutButton.parentNode.insertAfter(el, checkoutButton); }); this.renderButton(); } }, renderButton: function(wrappers = null) { if (!wrappers) { wrappers = document.querySelectorAll('.giftify-wrapper'); } if (wrappers && wrappers.length) { wrappers.forEach(function(wrapper) { if (!wrapper.querySelector('a')) { buttonEl = document.createElement('a'); buttonEl.href = '#'; buttonEl.innerHTML = ` I want to send this as a gift`; buttonEl.classList.add('giftify-button'); buttonEl.addEventListener('click', window.Giftify.openPopup); wrapper.appendChild(buttonEl); } }); if (!document.querySelector('.giftify-popup')) { var saved = { to: { name: '', email: '' }, from: { name: '', email: '' }, message: '' }; if (localStorage.getItem('giftify')) { saved = JSON.parse(localStorage.getItem('giftify')); } var popupHTML = '