1var BOXFOX=angular.module("BOXFOX",["ngSanitize"]);BOXFOX.config(["$interpolateProvider",function(e){e.startSymbol("[{").endSymbol("}]")}]),BOXFOX.filter("range",function(){return function(e,t,o){t=parseInt(t),o=parseInt(o);for(var a=t;a<=o;a++)e.push(a);return e}}),BOXFOX.service("NotificationService",["$rootScope","$compile","$timeout",function(e,t,o){var a=null,s=[],i={alert:"#app-notification-alert",confirm:"#app-notification-confirmation",miniPage:"#app-notification-mini-page"},n=this;return n.show=function(){if(null!=a)return!1;if(0==s.length)return!1;var c=s.shift();"alert"==c.type&&(c.confirmCallback=function(e){n.hide(),c.callback(!0)},$(document).on("keydown.app-modal",function(e){13==e.which&&c.confirmCallback(e)})),"confirm"==c.type&&(c.confirmCallback=function(){0!=c.callback(!0)&&n.hide()},c.cancelCallback=function(){n.hide(),c.callback(!1)},$(document).on("keydown.app-modal",function(e){13==e.which&&c.confirmCallback(e),27==e.which&&c.cancelCallback(e)})),"miniPage"==c.type&&(c.backCallback=function(){n.hide()},$(document).on("keydown.app-modal",function(e){27==e.which&&c.backCallback(e)}));var r=e.$new();angular.extend(r,c);var p=$(i[c.type]).html(),l=t(p)(r);return $("html").addClass("has-modal"),c.appendTarget?c.appendTarget.append(l):$("body").append(l),c.html=l,o(function(){l.addClass("visible")},0),a=c,c.controller&&o(function(){$(c.controller.target).append(c.controller.html)},0),c.onload&&c.onload(),c},n.hide=function(){if(!a)return!1;var e,t;return e=500,t=$(a.html),$("html").removeClass("has-modal"),$(document).off(".app-modal"),t.removeClass("visible"),o(function(){t.remove(),a=null,n.show()},e),t},n.alert=function(e,t){var o={},a={title:"Alert!",message:"This is an alert message",confirmButton:"Okay"};t=t||function(){},$.extend(o,a,e),o.type="alert",o.callback=t,s.push(o),n.show()},n.confirm=function(e,t){var o={},a={title:"Confirmation!",message:"This is a confirmation message",confirmButton:"Okay",cancelButton:"Cancel",style:""};t=t||function(){},$.extend(o,a,e),o.type="confirm",o.callback=t,s.push(o),n.show()},n.miniPage=function(e){var t={},o={content:"",backButton:"Back",onload:function(){}};$.extend(t,o,e),t.type="miniPage",s.push(t),n.show()},n}]),BOXFOX.controller("GiftBoxController",["$scope","$window","$http","$q","$timeout","DataService",function($scope,$window,$http,$q,$timeout,$data){$scope.data=$data,$scope.settings=$data.settings,$scope.model={},$scope.model.packaging={},$scope.model.packaging_complete=!1,$scope.model.items=[],$scope.model.items_complete=!1,$scope.model.card={},$scope.model.card_message="",$scope.model.card_blank=!1,$scope.model.card_complete=!1,$scope.model.current_step=1,$scope.model.status="incomplete",$scope.model.favorites=[],$scope.packaging_map={},$scope.modal_favorites=!1,$scope.modal_product=null,$scope.navigation={slider:$(".giftbox-pages"),track:$(".giftbox-page-track"),pages:$(".giftbox-page"),current_page:1,track_width:0,track_height:0},$scope.filter_by={},$scope.getParameter=function(e,t){t||(t=window.location.href),e=e.replace(/[\[\]]/g,"\\$&");var o=new RegExp("[?&]"+e+"(=([^&#]*)|&|#|$)"),a=o.exec(t);return a?a[2]?decodeURIComponent(a[2].replace(/\+/g," ")):"":null},$scope.init=function(){$scope.getProducts().then(function(){if($scope.getParameterByName("reset")&&$scope.resetBox(),$scope.getParameterByName("shopify_product_id"))$scope.loadBox($scope.getParameterByName("shopify_product_id"));else{var e=$scope.getSavedData();e&&("complete"==e.status?$scope.removeSavedData():$scope.restoreSavedData(e)),$timeout(function(){var e=$scope.getParameter("filter_by");if(e){e=e.split("|"),console.log("filters",e);for(var t=0;t<e.length;t++)$scope.autoApplyFilter(e[t]);$scope.applyFilters()}var o=$scope.getParameter("product");if(o){if(isNaN(o))var a=$scope.getItemByHandle(o);else var a=$scope.getItemByID(o);$scope.showItemInfo(a)}},0)}})},$scope.autoApplyFilter=function(e){var t,o,a;o=$('option[value="'+e+'"]'),t=o.closest("select"),a=t.data("group"),console.log(e),console.log(o),console.log(t),$scope.filter_by[a]=e},$scope.getProducts=function(){for(var defer=$q.defer(),promises=[],i=0;i<$scope.data.collection_pages.length;i++){var page,page_number,offset,url,promise;page=$scope.data.collection_pages.shift(),page_number=parseInt(page.title),offset=page_number>1?250*(page_number-1):0,url="/collections/"+$scope.data.collection.handle,url+="?view=build_json",url+="&page="+page_number,promise=$http({method:"GET",url:url}).then(function(response){for(var data=eval(response.data),i=0;i<data.items.length;i++)$scope.data.items.push(data.items[i])}),promises.push(promise)}return $q.all(promises).then(function(){defer.resolve()}),defer.promise},$scope.getSavedData=function(){return JSON.parse(localStorage.getItem("giftbox"))},$scope.setSavedData=function(){localStorage.setItem("giftbox",JSON.stringify($scope.model))},$scope.removeSavedData=function(){localStorage.removeItem("giftbox")},$scope.restoreSavedData=function(e){$scope.updateDataWithSavedData(e),$timeout(function(){$scope.goToPage(e.current_step)},10),4==e.current_step&&$timeout(function(){$scope.createGiftBox()},10)},$scope.updateDataWithSavedData=function(e){$scope.model=e,$scope.selectPackaging(e.packaging.id);for(var t=0;t<e.items.length;t++)for(var o=0;o<$scope.data.items.length;o++)e.items[t].id==$scope.data.items[o].id&&($scope.data.items[o].quantity=e.items[t].quantity,$scope.model.items.splice(t,1),$scope.model.items.push($scope.data.items[o]));for(var t=0;t<e.favorites.length;t++)for(var o=0;o<$scope.data.items.length;o++)e.favorites[t].id===$scope.data.items[o].id&&($scope.data.items[o].favorite=e.favorites[t].favorite)},$scope.resetBox=function(){$scope.removeSavedData(),window.history.replaceState({},document.title,location.pathname)},$scope.loadBox=function(e){if(e&&""!=e){var t={shop:$scope.data.shop,product_id:e};$.ajax({url:"https://build.boxfox.com/giftbox/product",method:"GET",data:t,dataType:"jsonp",crossDomain:!0,jsonpCallback:"callback"}).done(function(e){if(""==e)return void $timeout($scope.resetBox,0);var t,o,a,s,i;o=$scope.decodeEntities($scope.getParameterByName("card")),a=$scope.decodeEntities($scope.getParameterByName("card_message")),s=$scope.decodeEntities($scope.getParameterByName("card_blank")),i=$scope.getParameterByName("ignore").split(","),$scope.model.status="reviewing",$scope.model.shopify_product_id=e.id,$scope.model.shopify_variant_id=e.variants[0].id;for(var n,c=0;c<$scope.data.box.variants.length;c++)if(n=$scope.data.box.variants[c],n.option1==e.variants[0].option1&&n.option2==e.variants[0].option2){$scope.model.packaging=n,$scope.model.packaging_complete=!0,$scope.generatePackagingMap(n);break}for(var r,c=0;c<e.metafields.length;c++)"box-contents"==e.metafields[c].key&&(r=e.metafields[c].value.split(","));for(var c=0;c<r.length;c++){var p,l,m,d,$,g;p=r[c].split(":"),l=parseInt(p[0]),m=parseInt(p[1]),d=$scope.getItemByVariantID(l),$=d.id.toString(),g=-1!=i.indexOf($),d&&!g&&(d.quantity=m,$scope.model.items.push(d))}$scope.model.items_complete=!0,t=$scope.getCardByTitle(o),$scope.model.card=t,"true"==s?($scope.model.card_blank=!0,$scope.model.card_message="",$scope.model.card_complete=!0):($scope.model.card_blank=!1,$scope.model.card_message=a,$scope.model.card_complete=!0),$scope.$apply(),$scope.setSavedData(),$scope.toggleItemAvailability(),$timeout(function(){$scope.goToPage(2),window.history.replaceState({},document.title,location.pathname)},0)})}else $scope.resetBox()},$scope.getParameterByName=function(e){var t,o;return e=e.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]"),t=new RegExp("[\\?&]"+e+"=([^&#]*)"),o=t.exec(location.search),null===o?"":decodeURIComponent(o[1].replace(/\+/g," "))},$scope.decodeEntities=function(e){var t=document.createElement("div");return e&&"string"==typeof e&&(e=e.replace(/<script[^>]*>([\S\s]*?)<\/script>/gim,""),e=e.replace(/<\/?\w(?:[^"'>]|"[^"]*"|'[^']*')*>/gim,""),t.innerHTML=e,e=t.textContent,t.textContent=""),e},$scope.initPages=function(){$scope.layout(),$(window).on("resize",$scope.layout)},$scope.layout=function(){$scope.navigation.track.width("auto"),$scope.navigation.track_width=$scope.navigation.track.width(),$scope.navigation.pages.width($scope.navigation.track_width),$scope.navigation.track.width($scope.navigation.track_width*$scope.navigation.pages.length),$scope.navigation.track.height("auto"),$scope.navigation.track_height=$(window).height(),$scope.navigation.track.css({transition:"none",transform:"translate3d(-"+($scope.navigation.current_page-1)*$scope.navigation.track_width+"px, 0, 0)"})},$scope.goToPage=function(e,t){if(t){if($(t.currentTarget).hasClass("disabled"))return}$scope.navigation.current_page=e,$scope.model.current_step=e,$scope.navigation.track.css({transition:"transform 500ms ease",transform:"translate3d(-"+(e-1)*$scope.navigation.track_width+"px, 0, 0)"});var o=$("#giftbox-progress-bar").offset().top;$(document).scrollTop()>o&&$timeout(function(){$("html, body").animate({scrollTop:o},500)},500)},$scope.nextPage=function(){var e=Math.min($scope.navigation.pages.length,$scope.navigation.current_page+1);
1$scope.goToPage(e)},$scope.prevPage=function(){var e=Math.max(0,$scope.navigation.current_page-1);$scope.goToPage(e)},$scope.pageClass=function(e){var t="";return 1==e&&(t=1==$scope.navigation.current_page?"active":$scope.model.packaging_complete?"completed":"disabled"),2==e&&(t=2==$scope.navigation.current_page?"active":$scope.model.items_complete?"completed":$scope.model.packaging_complete?"accessible":"disabled"),3==e&&(t=3==$scope.navigation.current_page?"active":$scope.model.card_complete?"completed":$scope.model.items_complete?"accessible":"disabled"),4==e&&(t=4==$scope.navigation.current_page?"active":"complete"==$scope.model.status?"completed":"disabled"),t},$scope.containsAny=function(e,t){e=e.toLowerCase();for(var o=0;o!=t.length;o++){var a=t[o].toLowerCase();if(-1!=e.indexOf(a))return!0}return!1},$scope.visibleItemsCount=function(){for(var e=0,t=0;t<$scope.data.items.length;t++)e+=$scope.data.items[t].visible?1:0;return e},$scope.filterItems=function(){var e=[],t=$(".custom-box-no-items");for(filter in $scope.filter_by)""!=$scope.filter_by[filter]&&e.push($scope.filter_by[filter]);if(0===e.length){for(var o=0;o<$scope.data.items.length;o++)$scope.data.items[o].visible=!0;t.hide()}else{for(var o=0;o<$scope.data.items.length;o++){var a=$scope.data.items[o];a.visible=!0;for(var s=0;s<e.length;s++)$scope.containsAny(e[s],a.tags)||(a.visible=!1)}0==$scope.visibleItemsCount()?t.show():t.hide()}},$scope.searchItems=function(){for(var e=$("#search-items").val().toLowerCase().split(" "),t=$(".custom-box-no-items"),o=0;o<$scope.data.items.length;o++){var a=$scope.data.items[o];if(a.visible){var s,i,n,c,r;s=!1,i=$scope.containsAny(a.vendor,e),n=$scope.containsAny(a.title,e),c=$scope.containsAny(a.description,e),r=$scope.containsAny(a.tags.toString(),e),(i||n||c||r)&&(s=!0),a.visible=!!s}}0==$scope.visibleItemsCount()?t.show():t.hide()},$scope.applyFilters=function(){$scope.filterItems(),$scope.searchItems()},$scope.sortByIndex=function(e,t){var o=Number(e.index),a=Number(t.index);return o<a?-1:o>a?1:0},$scope.sortByPrice=function(e,t){var o=Number(e.price),a=Number(t.price);return o<a?-1:o>a?1:0},$scope.sortBySize=function(e,t){var o=Number(e.size_constraint),a=Number(t.size_constraint);return o<a?-1:o>a?1:0}
1,$scope.sortItems=function(){var e=$("select.sort-by").val();"featured"==e?$data.items.sort($scope.sortByIndex):"price-ascending"==e?$data.items.sort($scope.sortByPrice):"price-descending"==e?($data.items.sort($scope.sortByPrice),$data.items.reverse()):"size-ascending"==e?$data.items.sort($scope.sortBySize):"size-descending"==e&&($data.items.sort($scope.sortBySize),$data.items.reverse())},$scope.selectPackaging=function(e,t){for(var o,a,s=0;s<$scope.data.box.variants.length;s++)if($scope.data.box.variants[s].id==e){o=$scope.data.box.variants[s];break}if((a=$scope.totalSize())>0&&o&&($scope.generatePackagingMap(o),a>$scope.packaging_map.matching.largest.size_constraint))return alert("You have too many items to fit this packaging type. Please remove some items before switching to a "+$scope.packaging_map.matching.largest.title),$scope.generatePackagingMap($scope.model.packaging),void $scope.goToPage(2);o&&($scope.model.packaging=o,$scope.model.packaging_complete=!0,$scope.generatePackagingMap(o),$scope.toggleItemAvailability()),o&&t&&$scope.goToPage(2)},$scope.optionIndexByTitle=function(e,t){var o=e.options.indexOf(t);return o>-1?o+1:o},$scope.generatePackagingMap=function(e){var t,o,a;t={},t.all={},t.all.packaging=[],t.matching={},t.matching.packaging=[],o=$scope.optionIndexByTitle($scope.data.box,"Box Color"),a=e["option"+o];for(var s,i=0;i<$scope.data.box.variants.length;i++)s=$scope.data.box.variants[i],t.all.packaging.push(s),(!t.all.smallest||s.size_constraint<t.all.smallest.size_constraint)&&(t.all.smallest=s),(!t.all.largest||s.size_constraint>t.all.largest.size_constraint)&&(t.all.largest=s),s["option"+o]==a&&(t.matching.packaging.push(s),(!t.matching.smallest||s.size_constraint<t.matching.smallest.size_constraint)&&(t.matching.smallest=s),(!t.matching.largest||s.size_constraint>t.matching.largest.size_constraint)&&(t.matching.largest=s));t.all.current=$scope.model.packaging,t.matching.current=$scope.model.packaging,t.all.packaging.sort($scope.sortBySize),t.matching.packaging.sort($scope.sortBySize),t.all.previous=null,t.all.next=null;for(var s,i=0;i<t.all.packaging.length;i++)if(s=t.all.packaging[i],s.size_constraint<e.size_constraint&&(t.all.previous=s),s.size_constraint>e.size_constraint){t.all.next=s;break}t.matching.previous=null,t.matching.next=null;for(var s,i=0;i<t.matching.packaging.length;i++)if(s=t.matching.packaging[i],s.size_constraint<e.size_constraint&&(t.matching.previous=s),s.size_constraint>e.size_constraint){t.matching.next=s;break}$scope.packaging_map=t},$scope.inArray=function(e,t,o){if(e)for(var a=0;a<e.length;a++)if(e[a][t]==o)return!0;return!1},$scope.optionValueByTitle=function(e){var t;return t=$scope.optionIndexByTitle($scope.data.box,e),$scope.model.packaging["option"+t]},$scope.explainBoxSizes=function(){Boxfox.Modal.alert({title:"Box Sizes",message:"We want your gifts to look perfect, that's why we have three different box sizes. Never too much or too little space, and perfectly packed everytime!",confirmButton:"Got It!"})},$scope.sizeImage=function(e,t){if(e){var o=e.split(".").pop();return t=void 0===t?"":"_"+t,e.replace("."+o,t+"."+o)}},$scope.getItemByID=function(e){for(var t=0;t<$scope.data.items.length;t++)if($scope.data.items[t].id==e)return $scope.data.items[t]},$scope.getItemByHandle=function(e){for(var t=0;t<$scope.data.items.length;t++)if($scope.data.items[t].handle==e)return $scope.data.items[t]},$scope.formatMoney=function(e){return isNaN(e)?"":"$"+(e/100).toFixed(2)},$scope.getItemByProductID=function(e){for(var t=null,o=0;o<$scope.data.items.length;o++)if($scope.data.items[o].id==e){t=$scope.data.items[o];break}return t},$scope.getItemByVariantID=function(e){for(var t=null,o=0;o<$scope.data.items.length;o++)if($scope.data.items[o].variants[0].id==e){t=$scope.data.items[o];break}return t},$scope.subtotal=function(){var e=0;$scope.model.packaging.price&&(e+=$scope.model.packaging.price);for(var t=0;t<$scope.model.items.length;t++)e+=$scope.model.items[t].price*$scope.model.items[t].quantity;return $scope.formatMoney(e)},$scope.totalSize=function(){for(var e=0,t=0;t<$scope.model.items.length;t++)e+=$scope.model.items[t].size_constraint*$scope.model.items[t].quantity;return e},$scope.containsRegularBoxMinimums=function(){for(var e=!1,t=0;t<$scope.model.items.length;t++)if($scope.inArray($scope.data.min_box_regular_items,"id",$scope.model.items[t].id)){e=!0;break}return e},$scope.containsBigBoxMinimums=function(){for(var e=!1,t=0;t<$scope.model.items.length;t++)if($scope.inArray($scope.data.min_box_big_items,"id",$scope.model.items[t].id)){e=!0;break}return e},$scope.minimumBoxSize=function(){var e=$scope.totalSize();return $scope.containsRegularBoxMinimums()&&(e=$scope.data.min_box_regular_constraint),$scope.containsBigBoxMinimums()&&(e=$scope.data.min_box_big_c
1onstraint),e},$scope.sizeRemaining=function(){var e,t,o,a;e=$scope.packaging_map,t=$scope.totalSize(),e.matching.current.size_constraint,o=e.matching.largest.size_constraint-t,a=$scope.minimumBoxSize(),e.matching.previous&&t<=e.matching.previous.size_constraint&&e.matching.current.size_constraint>a?$scope.selectPackaging(e.matching.previous.id):e.matching.next&&t>e.matching.current.size_constraint?$scope.selectPackaging(e.matching.next.id):e.matching.next&&e.matching.current.size_constraint<a?$scope.selectPackaging(e.matching.next.id):!e.matching.next&&e.all.next&&t==e.matching.current.size_constraint&&t<e.all.next.size_constraint&&$timeout(function(){answer=confirm("Your "+$scope.model.packaging.title+" is currently full and cannot fit any more items. Do you want to switch to a "+e.all.next.title+" instead? You will be able to fit more items!"),answer&&($scope.selectPackaging(e.all.next.id),o=e.all.largest.size_constraint-t)},0),$scope.checkDisabledPackaging();var s=a/e.all.largest.size_constraint*100;return 0===s?s="2px":s+="%",$(".size-meter-mask").css({left:s}),o},$scope.checkDisabledPackaging=function(){if("Black / Regular"==$scope.model.packaging.title){for(var e,t,o=0;o<$scope.data.box.variants.length;o++)if(t=$scope.data.box.variants[o],"Nude / Regular"==t.title){e=t.id;break}$scope.notified||($scope.notified=!0,Boxfox.Modal.alert({title:"Regular, Black Boxes Unavailable",message:"We apologize about the inconvenience but we're currently sold out of Regular Black Boxes. We'll switch you to a Nude box so all your items fit. Alternatively, you can remove items and switch back to a Black Box.",confirmButton:"Okay, Switch to Nude"},function(t){t&&($scope.selectPackaging(e),$scope.$apply(),$scope.notified=!1)}))}},$scope.itemAvailable=function(e){var t=e.available;return $scope.itemCurrentInventory(e)<=GiftBoxSettings.step2.inventory_minimum&&(t=!1),t},$scope.itemOnSale=function(e){var t=!1;return e.compare_at_price&&e.compare_at_price>e.price&&(t=!0),t},$scope.itemCurrentInventory=function(e){var t=0,o=e.variants[0];return o.inventory_management&&"deny"==o.inventory_policy&&o.inventory_quantity>0&&(t=o.inventory_quantity),t},$scope.increaseQuantity=function(e){e.disabled||(e.quantity+=1,1==e.quantity&&$scope.model.items.push(e),Boxfox.flashNotice({message:e.title+" added to your box"}),$scope.toggleItemAvailability())},$scope.decreaseQuantity=function(e){if(e.quantity-=1,0==e.quantity)for(var t=0;t<$scope.model.items.length;t++)if($scope.model.items[t].id==e.id){$scope.model.items.splice(t,1);break}Boxfox.flashNotice({message:e.title+" removed to your box"}),$scope.toggleItemAvailability()},$scope.toggleItemAvailability=function(){for(var e,t=$scope.sizeRemaining(),o=0;o<$scope.data.items.length;o++)e=$scope.data.items[o],e.size_constraint>t?e.disabled=!0:e.disabled=!1},$scope.showItemInfo=function(e){$timeout.cancel($scope.modalItemPromise),$scope.modal_product=e,$timeout($scope.initPhotoSlider,0),$("html,body").addClass("no-scroll")},$scope.hideItemInfo=function(){$("html,body").removeClass("no-scroll"),$("#modal-product").removeClass("visible"),$timeout($scope.destroyPhotoSlider,0),$scope.modalItemPromise=$timeout(function(){$scope.modal_product=null},100)}
1,$scope.initPhotoSlider=function(){var e=$("#modal-product .modal-product-images .product-slideshow");e.slick({adaptiveHeight:!0,dots:!0,swipe:!0,appendDots:$(".modal-product-images .product-thumbnails"),customPaging:function(e,t){return'<img src="'+$(e.$slides[t]).data("thumbnail")+'">'}}),$(".modal-product-images img").imagesLoaded(function(){e.slick("setPosition")})},$scope.destroyPhotoSlider=function(){$("#modal-product .modal-product-images .product-slideshow").slick("unslick")},$scope.toggleFavorite=function(e){e.favorite?($scope.removeFromFavorites(e),Boxfox.flashNotice({message:"Removed from your favorites"})):($scope.addToFavorites(e),Boxfox.flashNotice({message:"Added to your favorites"}))},$scope.addToFavorites=function(e){e.favorite=!0,$scope.model.favorites.push(e)},$scope.removeFromFavorites=function(e){e.favorite=!1;for(var t=0;t<$scope.model.favorites.length;t++)if($scope.model.favorites[t].id==e.id){$scope.model.favorites.splice(t,1);break}},$scope.showFavorites=function(){$scope.modal_favorites=!0,$("html,body").addClass("no-scroll")},$scope.hideFavorites=function(){$("html,body").removeClass("no-scroll"),$("#modal-favorites").removeClass("visible"),$timeout(function(){$scope.modal_favorites=null},500)},$scope.completeItems=function(){$scope.model.items.length?($scope.model.items_complete=!0,$scope.goToPage(3)):Boxfox.Modal.alert({title:"Your Box is Empty",message:"It looks like you haven't added anything to your box. Please add at least one item before proceeding.",confirmButton:"Okay"})},$scope.getCardByTitle=function(e){for(var t=null,o=0;o<$scope.data.cards.length;o++)if($scope.data.cards[o].title==e){t=$scope.data.cards[o];break}return t},$scope.selectCard=function(e){$scope.model.card=e,$("#message").focus()},$scope.removeCard=function(){$scope.model.card={}},$scope.maxLength=function(){var e=524288;return $scope.settings.step3.message["max-characters"]>0&&(e=$scope.settings.step3.message["max-characters"]),e},$scope.updateCharacterCount=function(){return $scope.settings.step3.message["max-characters"]-$scope.model.card_message.length},$scope.completeCard=function(){$scope.model.card.title?0!=$scope.model.card_message.length||$scope.model.card_blank?($scope.model.card_complete=!0,$scope.goToPage(4),$scope.createGiftBox()):Boxfox.Modal.confirm({title:"No Message on Card?",message:"Are you sure you don't want to write a message?",confirmButton:"Write a Message",cancelButton:"Leave Card Blank"},function(e){e?$("#message").focus():($scope.model.card_blank=!0,$scope.model.card_complete=!0,$scope.goToPage(4),$scope.createGiftBox())}):Boxfox.Modal.alert({title:"Select a Card",message:"Please select a card to complete your box.",confirmButton:"Okay"})},$scope.createGiftBox=function(){for(var e={shop:$scope.data.shop,product_id:$scope.data.box.id,variant_id:$scope.model.packaging.id,items:[]},t=0;t<$scope.model.items.length;t++)e.items.push({title:$scope.model.items[t].title,product_id:$scope.model.items[t].id,variant_id:$scope.model.items[t].variants[0].id,quantity:$scope.model.items[t].quantity});$.ajax({url:"https://build.boxfox.com/giftbox/create",method:"POST",data:e,crossDomain:!0,cache:!1,success:function(e){$scope.addToCart(e)},error:function(e){$scope.displayErrors(e)}})},$scope.addToCart=function(e){var t,o;t={},t.Card=$scope.model.card.title,$scope.model.card_blank?t["Card Blank"]="Leave on Outside":t.Message=$scope.model.card_message,t["Gift Box Contents"]="";for(var a,s=0;s<$scope.model.items.length;s++)a=$scope.model.items[s],""!=t["Gift Box Contents"]&&(t["Gift Box Contents"]+=", \n"),t["Gift Box Contents"]+=a.quantity+" x "+a.title;if($scope.model.card.properties)for(var i in $scope.model.card.properties)t[i]=$scope.model.card.properties[i];o={id:e.product.variants[0].id,quantity:1,properties:t},$.ajax({url:"/cart/add.js",dataType:"json",type:"post",data:o,success:$scope.finish,error:function(e){console.log("XMLHttpRequest"),console.log(e)}})},$scope.displayErrors=function(e){var t,o,a;if(t="It looks like there was an issue while attempting to process your request.",o=e.responseJSON.errors&&e.responseJSON.errors.length,a=e.responseJSON.shopify_errors&&e.responseJSON.shopify_errors.length,(o||a)&&(t+="<ul>"),o)for(var s=e.responseJSON.errors,i=0;i<s.length;i++)t+="<li>"+s[i].message+"</li>";if(a)for(var s=e.responseJSON.shopify_errors,i=0,n="";i<s.length;i++){for(var c in s[i].errors)n+=c+" "+s[i].errors[c];t+="<li>"+s[i].message+" - "+n+"</li>"}(o||a)&&(t+="</ul>"),Boxfox.Modal.alert({title:"Whoops!",message:t,confirmButton:"Try Again"},function(){location.reload(!0)})},$scope.finish=function(){$timeout(function(){$scope.model.status="complete"}),$timeout(function(){$window.location.href="/cart"},1e3)},$scope.$watch(function(){return $scope.model},$scope.setSavedData,!0)}]),BOXFOX.controller("slickSlider",["$timeout",function(e){return{restrict:"A",link:function(t,o,a){e(function(){$(o).slick(t.$eval(a.slickSlider))})}}}]);
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.