1saffire.angular.app.directive('sfCartUpsell', ['$rootScope', '$timeout', function ($rootScope, $timeout) { 2 3 4 function link(scope, element, attrs) { 5 6 scope.siteBaseURL = SITEBASEURL; 7 scope.showDetails = false; 8 scope.detailItem; 9 10 scope.getPriceRange = function (item) { 11 if (item.ProductType == 0 || item.ProductType == 50) { 12 return item.DisplayPrice; 13 14 } else if (item.ProductType == 10) { 15 var items = []; 16 17 angular.forEach(item.Children, function (subItemChild) { 18 19 angular.forEach(subItemChild.Children, function (v) { 20 21 var priceTypeItem = $.grep(items, function (c) { 22 return c.seatmapCategoryID == v.SeatmapCategoryID && c.ticketTypeID == v.TicketTypeID; 23 })[0]; 24 25 if (!priceTypeItem) { 26 var priceTypeItem = { 27 seatmapCategoryID: v.SeatmapCategoryID, 28 ticketTypeID: v.TicketTypeID, 29 price: v.DisplayPrice 30 }; 31 32 items.push(priceTypeItem); 33 34 } else { 35 priceTypeItem.price += v.DisplayPrice; 36 } 37 }) 38 }) 39 40 var min = Math.min.apply(Math, items.map(function (i) { return i.price })); 41 var max = Math.max.apply(Math, items.map(function (i) { return i.price })); 42 return [min, max]; 43 44 } else { 45 var priceTypePrices = []; 46 47 angular.forEach(item.Children, function (optionItem) { 48 priceTypePrices.push(optionItem.DisplayPrice); 49 }); 50 var min = Math.min.apply(Math, priceTypePrices); 51 var max = Math.max.apply(Math, priceTypePrices); 52 return [min, max]; 53 } 54 } 55 56 scope.addToCart = function ($event, item) { 57 if ($event.type === 'click' || $event.type === 'touchend' || $event.which === 13) { 58 if ((item.ProductType !== 30) && (item.ProductType !== 50) && (item.ProductType !== 10)) { 59 var addToCartRequest = { itemID: -1, mainProductID: item.ProductID, inCheckout: true, isCartUpsell: true, options: [{ productID: item.ProductID, qty: "1" }] }; 60 scope.addCartItem($(this), addToCartRequest); 61 } else { // if ga product 62 if (scope.showDetails === false) { // if product detail not showing 63 scope.showDetails = true; 64 scope.detailItem = item; 65 66 angular.forEach(item.Children, function (optionItem) { 67 if (!optionItem.selectedQty) { 68 optionItem.selectedQty = "QTY"; 69 } 70 }); 71 72 } else { // if product detail are showing / add to cart button clicked from within product details 73 var totalQtyAdded = 0; 74 var addToCartRequest = { itemID: -1, mainProductID: item.ProductID, inCheckout: true, isCartUpsell: true, options: [] } 75 76 if (item.ProductType == 50) { 77 var qty = "1"; 78 79 addToCartRequest.subProducts = []; 80 addToCartRequest.options.push({ productID: item.ProductID, qty: qty }); 81 82 totalQtyAdded += qty; 83 84 85 angular.forEach(item.Children, function (subProductItem) { 86 87 var subProduct = { productID: subProductItem.ProductID, options: [] }; 88 89 $(subProductItem.Children).each(function (i, ttp) { 90 91 subProduct.options.push({ productID: ttp.ProductID, quantity: ttp.Qty }); 92 }) 93 94 addToCartRequest.subProducts.push(subProduct); 95 }) 96 } else { 97 98 angular.forEach(item.Children, function (optionItem) { 99 var productID = optionItem.ProductID; 100 var qty = 0; 101 102 var ddlQty = optionItem.selectedQty;
103 104 if (ddlQty) { 105 qty = ddlQty; 106 if (qty < 0) { 107 qty = 0; 108 } 109 } 110 111 if (qty > 0) { 112 addToCartRequest.options.push({ productID: productID, qty: qty }); 113 totalQtyAdded = totalQtyAdded + qty; 114 } 115 }) 116 } 117 118 if (totalQtyAdded <= 0) { 119 alert("Quantity is required"); 120 } else if (totalQtyAdded > item.MaxQty) { 121 alert(item.MaxQty + " per order limit."); 122 } else { 123 scope.addCartItem($(this), addToCartRequest); 124 scope.showDetails = false; 125 } 126 } 127 128 } 129 } 130 } 131 132 scope.cancelAddItem = function ($event) { 133 if ($event.type === 'click' || $event.type === 'touchend' || $event.which === 13) { 134 scope.showDetails = false; 135 } 136 } 137 138 scope.$watch('swiperOptions.pluginOptions', function (newVal, oldVal) { 139 140 if (scope.swiperOptions && scope.swiperOptions.pluginOptions) { 141 if (scope.swiper) { 142 scope.swiper.destroy(true, true); 143 } 144 145 $timeout(function () { 146 scope.swiper = new Swiper('.swiper-container-' + scope.swiperOptions.swiperID, scope.swiperOptions.pluginOptions); 147 148 $timeout(function () { 149 if (scope.swiper && scope.swiper.updateAutoHeight) { 150 scope.swiper.updateAutoHeight(); 151 } 152 }, 50); 153 }, 100) 154 155 } 156 }, true); 157 158 159 scope.$watch('isRendered', function (newVal, oldVal) { 160 161 if (scope.isRendered) { 162 163 $timeout(function () { 164 scope.updateSwiper(); 165 166 $timeout(function () { 167 if (scope.swiper && scope.swiper.updateAutoHeight) { 168 scope.swiper.updateAutoHeight(); 169 } 170 }, 50); 171 }, 100) 172 173 } 174 175 }); 176 177 scope.updateSwiper = function () { 178 179 if(scope.swiper) { 180 scope.swiper.update(); 181 } 182 183 $timeout(function () { 184 if (scope.swiper && scope.swiper.updateAutoHeight) { 185 scope.swiper.updateAutoHeight(); 186 } 187 }, 50); 188 189 $timeout(function () { 190 scope.swiper.update(); 191 $('.checkout-upsell__content').css('opacity', 1); 192 }, 300) 193 194 195 } 196 197 scope.$watch('upsellItems', function (newVal, oldVal) { 198 199 $('.checkout-upsell__content').css('opacity', 0); 200 201 }); 202 203 //swiperLastUpdated property can be used to update swiper from outside of cart upsell directive, 204 //one example is Cart Checkout page, which needs to update swiper depends on its opened in Modal OR Inline 205 206 scope.$watch('swiperOptions.swiperLastUpdated', function (newVal, oldVal) { 207 208 if (scope.swiper && scope.swiperOptions.swiperLastUpdated && newVal != oldVal) { 209 $timeout(function () { 210 scope.swiper.activeIndex = 0; 211 scope.updateSwiper(); 212 }, 500) 213 } 214 215 }); 216 217 218 } 219 220 return { 221 scope: { 222 cart: '=', 223 cartItem: '=', 224 upsellItems: '=', 225 addCartItem: '=', 226 isRendered: '=', 227 updateCartItem: '&', 228 swiperOptions: '=' 229 }, 230 templateUrl: SITEBASEURL + 'core/content/angular/cart/cartUpsell/cartUpsell.html?sv=' + SITEVERSION, 231 link: link 232 } 233 234 235}]); 236 237saffire.angular.app.directive('sfCartUpsellItem', ['$timeout', function ($timeout) { 238 239 function link(scope, element, attrs) { 240 241 if (scope.last === true) { 242 $timeout(function () { 243 scope.$evalAsync(function () { 244 245 scope.updateSwiper(); 246 247 }, 1) 248 }) 249 } 250 251 }; 252 253 return { 254 restrict: 'A', 255 scope: { 256 updateSwiper: '=', 257 last: '=', 258 }, 259 link: link 260 }; 261}]); 262 263saffire.angular.app.filter('range', function () { 264 return function (input, min, max) { 265 min = parseInt(min); //Make string input int 266 max = parseInt(max); 267 input.push("QTY"); 268 for (var i = min; i <= max; i++) 269 input.push(i); 270 return input; 271 }; 272}); 273 274
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.