PageSourceSearch

https://montaleparfums.us/cdn/shop/t/24/assets/product-gifts.js?v=152365726274866308371722359046

js montaleparfums.us collected 2026-09-29 23:28:06 UTC 12,029 bytes, 2 lines download raw bytes

1theme.ProductGifts=(function(){var selectors={container:"#ProductGifts",collection:"#Collection",productItem:"[data-product-item]",addToCart:"[data-add-to-cart]",cartItemGift:"[data-cart-item-gift]",cartForm:"[data-cart-form]",checkout:'button[name="checkout"]',checkoutLoader:"[data-checkout-loader]",checkoutText:"[data-checkout-text]",errorMessageWrapper:"[data-error-message-wrapper]",errorMessage:"[data-error-message]",addToCartText:"[data-add-to-cart-text]",loader:"[data-loader]",giftsClose:"[data-gifts-close]",sortBy:"#SortBy",announcementBar:".announcement-bar",siteHeader:".site-header",giftsHeader:"[data-gifts-header]",giftsBody:"[data-gifts-body]"},classes={active:"active",hidden:"hide",loading:"loading",collectionLoading:"product-gifts__collection--loading"},data={illegalItemsChecked:"illegal-items-checked",productHandle:"product-handle",productTier:"product-tier",variantId:"variant-id"},cache={};function ProductGifts(){var $container=this.$container=$(selectors.container);this.settings={collection:$container.data("collection"),initialized:!1,data:{sortBy:{}}},this.open=this._open,this.close=this._close,this.checkIllegalItems=this._checkIllegalItems,this.$errorMessageWrapperTemplate=$(selectors.errorMessageWrapper,this.$container).first().detach(),this.cache={},this._initProductGifts()}return ProductGifts.prototype=Object.assign({},ProductGifts.prototype,{_cacheSelectors:function(){this.cache.$sortBy=$(selectors.sortBy,this.$container),this.cache.$collection=$(selectors.collection,this.$container),this.cache.$addToCart=$(selectors.addToCart,this.$container),this.cache.$addToCartTierZero=this.cache.$addToCart.filter("[data-"+data.productTier+'="0"]'),this.cache.$addToCartTierOne=this.cache.$addToCart.filter("[data-"+data.productTier+'="1"]'),this.cache.$addToCartTierTwo=this.cache.$addToCart.filter("[data-"+data.productTier+'="2"]'),this.cache.$cartItemGift=$(selectors.cartItemGift),this.cache.$giftsHeader=$(selectors.giftsHeader,this.$container),this.cache.$giftsBody=$(selectors.giftsBody,this.$container)},_initProductGifts:function(){var self=this,$collection=$(selectors.collection,this.$container),loadHolder=$("<div></div>");loadHolder.load("/collections/"+this.settings.collection+"?view=product-gifts",function(){$collection.html(loadHolder.html()),$collection.removeClass(classes.collectionLoading),self._cacheSelectors(),self._initEvents(),self.settings.initialized=!0})},_initEvents:function(){this.cache.$sortBy.off().on("change",this._onSortChange.bind(this)),this.$container.on("click",this._close.bind(this)),this.cache.$cartItemGift.on("click",this._handleCartGift.bind(this)),$(selectors.checkout).on("click",this._checkIllegalItems.bind(this))},_adjustSizing:function(){this.cache.$giftsBody.css("max-height","");var paddingBottom=parseFloat(this.cache.$giftsBody.css("padding-bottom")||0),maxHeight=this.$container.outerHeight()-this.cache.$giftsHeader.outerHeight()-paddingBottom;this.cache.$giftsBody.css("max-height",maxHeight+"px")},_open:function(item){this.settings.initialized||setTimeout(function(){this._open(item)}.bind(this),500),this.cache.$addToCart.prop("disabled",!1).find(selectors.addToCartText).text("Add to cart"),this.cache.$addToCart.filter(":not([disabled])").on("click.productGifts",this._addItem.bind(this,item)),this._showGifts(),$(window).on("resize.productGifts",this._adjustSizing.bind(this)),this._adjustSizing()},_addItem:function(mainItem,evt){var $target=$(evt.target),variantId=$target.data("variant-id"),variantTitle=$target.data("variant-title"),giftToken=this._generateToken(),mainItemNewQuantity=--mainItem.quantity;this._hideErrorMessages(),this._handleButtonLoadingState($target,!0),$.ajax({type:"POST",url:"/cart/change.js",data:{id:mainItem.key,quantity:mainItemNewQuantity},dataType:"json"}).done(function(state){var params={type:"POST",url:"/cart/add.js",data:{items:[{id:variantId,quantity:1,properties:{_giftItem:!0,_giftToken:giftToken}},{id:mainItem.id,quantity:1,properties:{Gift:variantTitle,_gift:giftToken}}]},dataType:"json"};$.ajax(params).done(function(data2){var item=data2.items.filter(function(el){return el.id===variantId})[0];this._close(),window.location.pathname.includes("/cart")&&(window.location.href=window.location.href)}.bind(this)).fail(function(response){var errorMessage=response.responseJSON?response.responseJSON.description:"There was an error!";window.alert(errorMessage),this._handleButtonLoadingState($target,!1);var parameters={};mainItemNewQuantity?parameters={type:"POST",url:"/cart/change.js",data:{id:mainItem.key,quantity:++mainItemNewQuantity},dataType:"json"}:parameters={type:"POST",url:"/cart/add.js",data:{id:mainItem.id,quantity:1},dataType:"json"},$.ajax(parameters).done(function(){console.log("Product Gifts: Main item was returned to old quantity. API Endpoint: "+parameters.url),window.location.pathname.includes("/cart")&&(window.location.href=window.location.href)}).fail(function(response2){console.log("Product Gifts: Main item could not be returned to old quantity, check response",response2.responseJSON),window.location.pathname.includes("/cart")&&(window.location.href=window.location.href)})}.bind(this)).always(function(){this._handleButtonLoadingState($target,!1)}.bind(this))}.bind(this)).fail(function(response){var errorMessage="Couldn't find "+mainItem.title+" in the bag";this._handleButtonLoadingState($target,!1),window.alert(errorMessage),setTimeout(function(){this._close()}.bind(this),2e3)}.bind(this))},_showGifts:function(){if(this.$container.prepareTransition().addClass(classe
1s.active),window.innerWidth<768){window.scrollTo(0,0);var announcementBarHeight=$(selectors.announcementBar).length?$(selectors.announcementBar).outerHeight():0,siteHeaderHeight=$(selectors.siteHeader).length?$(selectors.siteHeader).outerHeight():0,offset=announcementBarHeight+siteHeaderHeight;this.$container.css({top:offset+"px",maxHeight:"calc(100% - "+offset+"px)"})}bodyScrollLock.disableBodyScroll()},_handleCartGift:function(evt){var $target=$(evt.target),itemKey=$target.data("cart-item-key");this._handleCartLoadingState(!0),$.getJSON("/cart.js",function(cart){var item=cart.items.filter(function(el){return el.key===itemKey})[0];this._handleCartLoadingState(!1),typeof item=="undefined"?window.location.href=window.location.href:this._open(item)}.bind(this))},_checkIllegalItems:function(evt){var self=this,itemsToRemove=[],itemsToReadd=[],$checkoutBtn=$(selectors.checkout);if(!$checkoutBtn.data(data.illegalItemsChecked)){if(evt){evt.preventDefault();var loading=$checkoutBtn.attr("data-loading")==="true";if(loading)return}self._handleCheckoutButtonLoadingState(!0),$.getJSON("/cart.js",function(cart){if(cart.items.forEach(function(item){if(!(item.properties===null||Object.keys(item.properties).length===0)&&(item.properties.hasOwnProperty("_gift")||item.properties.hasOwnProperty("_giftItem"))){var isGift=item.properties.hasOwnProperty("_giftItem"),tokenKey=isGift?"_giftToken":"_gift",searchKey=isGift?"_gift":"_giftItem",token=item.properties[tokenKey],gift=cart.items.filter(function(el){return el.properties!==null&&Object.keys(el.properties).length!==0&&Object.keys(el.properties).indexOf(searchKey)>-1&&Object.values(el.properties).indexOf(token)>-1})[0];typeof gift=="undefined"&&(itemsToRemove.push(item.key),isGift||itemsToReadd.push(item.id))}}),!itemsToRemove.length&&!itemsToReadd.length){self._handleCheckoutButtonLoadingState(!1),evt&&($checkoutBtn.data(data.illegalItemsChecked,!0),$checkoutBtn.click());return}var postData={};itemsToRemove.forEach(function(elem){postData[elem]=0}),$.ajax({type:"POST",url:"/cart/update.js",data:{updates:postData},dataType:"json"}).done(function(){if(itemsToReadd.length){var itemsToAdd=[];itemsToReadd.forEach(function(elem){itemsToAdd.push({id:elem,quantity:1})}),$.ajax({type:"POST",url:"/cart/add.js",data:{items:itemsToAdd},dataType:"json"}).always(function(){self._handleCheckoutButtonLoadingState(!1),evt?($checkoutBtn.data(data.illegalItemsChecked,!0),$checkoutBtn.click()):setTimeout(function(){window.location.href=window.location.href},200)})}else self._handleCheckoutButtonLoadingState(!1),evt?($checkoutBtn.data(data.illegalItemsChecked,!0),$checkoutBtn.click()):window.location.href=window.location.href}).fail(function(){console.error("Failed to remove illegal items from cart")})})}},_handleCheckoutButtonLoadingState:function(isLoading){var $checkout=$(selectors.checkout),$checkoutText=$checkout.find(selectors.checkoutText),$loader=$checkout.find(selectors.checkoutLoader);if(isLoading){var width=$checkout.css("width");$checkout.css({width:width,pointerEvents:"none"}),$checkout.attr("data-loading",!0),$checkout.attr("aria-disabled",!0),$checkoutText.addClass(classe
1s.hidden),$loader.removeClass(classes.hidden)}else $checkout.css({width:"",pointerEvents:""}),$checkout.attr("data-loading",!1),$checkout.removeAttr("aria-disabled"),$checkoutText.removeClass(classes.hidden),$loader.addClass(classes.hidden)},_handleCartLoadingState:function(isLoading){var isLoading=isLoading||!1;isLoading?$(selectors.cartForm).addClass(classes.loading):$(selectors.cartForm).removeClass(classes.loading)},_onBodyClick:function(evt){var $target=$(evt.target);$target[0]!==this.$container[0]&&!$target.parents(selectors.container).length&&this._close()},_close:function(evt){var transitionDuration=parseFloat(this.$container.css("transition-duration")||0)*1e3;evt!==void 0&&!$(evt.target).is(selectors.container)&&!$(evt.target).is(selectors.giftsClose)||(bodyScrollLock.enableBodyScroll(),this.$container.prepareTransition().removeClass(classes.active),this.cache.$addToCart.off("click.productGifts"),$(window).off("resize.productGifts"),setTimeout(function(){this.$container.css({top:"",maxHeight:""})}.bind(this),transitionDuration),window.ShopifyOnCartUpdate())},_generateToken:function(){for(var a="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890".split(""),b=[],i=0;i<10;i++){var j=(Math.random()*(a.length-1)).toFixed(0);b[i]=a[j]}return b.join("")},_handleButtonLoadingState:function($addToCart,isLoading){var $addToCartText=$addToCart.find(selectors.addToCartText),$addToCartLoader=$addToCart.find(selectors.loader);if(isLoading){this.cache.$addToCart.css("pointer-events","none");var width=$addToCart.css("width");$addToCart.css("width",width),$addToCart.attr("aria-disabled",!0),$addToCartText.addClass(classe
1s.hidden),$addToCartLoader.removeClass(classes.hidden)}else this.cache.$addToCart.css("pointer-events",""),$addToCart.css("width",""),$addToCart.removeAttr("aria-disabled"),$addToCartText.removeClass(classes.hidden),$addToCartLoader.addClass(classes.hidden)},_showErrorMessage:function($addToCart,errorMessage){var $errorMessageWrapper=this.$errorMessageWrapperTemplate.clone();$errorMessageWrapper.find(selectors.errorMessage).html(errorMessage),$addToCart.after($errorMessageWrapper),$errorMessageWrapper.removeClass(classes.hidden).attr("aria-hidden",!0).removeAttr("aria-hidden")},_hideErrorMessages:function(){var $errorMessages=$(selectors.errorMessageWrapper,this.$container);$errorMessages.length&&$errorMessages.remove()},_onSortChange:function(evt){var self=this,$target=$(evt.target),value=$target.val(),order=[],sortingData;this.settings.data.sortBy.hasOwnProperty(value)&&this._sortItems(this.settings.data.sortBy[value]),this.cache.$collection.addClass(classes.loading),$.get("/collections/"+this.settings.collection+"?view=AJAX&sort_by="+value,function(response){order=JSON.parse(response).order,self.settings.data.sortBy[value]=order,self._sortItems(order),self.cache.$collection.removeClass(classes.loading)})},_sortItems:function(order){var $collection=this.cache.$collection,reorderedItems=$.map(order,function(el){return $("[data-"+data.productHandle+'="'+el+'"]',$collection).detach()});$collection.html(reorderedItems)}}),ProductGifts})(),document.addEventListener("DOMContentLoaded",function(){window.Gifts=window.Gifts||new theme.ProductGifts});
2//# sourceMappingURL=/cdn/shop/t/24/assets/product-gifts.js.map?v=152365726274866308371722359046

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.