1var _3dThemeType = "core"; 2jQuery(function () { 3 coreInit(); //please do not remove this as a sub-function, it is necessary and has no impact on core 3dCart functionality, and is need by FusionBot to call once Ajax content is loaded, to re-initialzie this binding function once our content has been injected AFTER document ready 4}); 5 6function coreInit() { 7//jQuery(function () { 8 jQuery('.ajax-mailinglist form').submit(function () { 9 mailing_list(this); 10 return false; 11 }); 12 13 jQuery('.product-item .quickview').click(function (e) { 14 e.preventDefault(); 15 var productDiv = jQuery(this).parents('.product-item'); 16 var catalogId = jQuery(productDiv).data('catalogid'); 17 var categoryId = jQuery(productDiv).data('categoryid'); 18 quickview("/product.asp?lt_c=1&itemid=" + catalogId + "&qv=1"); 19 }); 20 21 jQuery('.product-item[data-ajaxcart="1"] .add-to-cart').click(function (e) { 22 e.preventDefault(); 23 jQuery(this).blur(); 24 var productDiv = jQuery(this).parents('.product-item'); 25 26 if (jQuery(productDiv).hasClass('ajaxcart-loading')) return; 27 28 jQuery(productDiv).addClass('ajaxcart-loading'); 29 30 var catalogId = jQuery(productDiv).data('catalogid'); 31 var categoryId = jQuery(productDiv).data('categoryid'); 32 33 var product = get_product(catalogId, categoryId); 34 35 var stock = parseInt(product.Stock); 36 var inventoryControl = parseInt(product.InventoryControl); 37 var inventoryControlGlobal = parseInt(product.InventoryControlGlobal); 38 39 if(stock <= 0) { 40 41 //ISSUE-7894 fix 42 43 if(inventoryControl != -1) { 44 if(inventoryControl == 3) { 45 window.location.href = product.ProductLink; 46 } 47 } 48 else { 49 if(inventoryControlGlobal == 3) { 50 window.location.href = product.ProductLink; 51 } 52 } 53 window.location.href = product.ProductLink; 54 return; 55 } 56 57 58 var hasOptions = false; 59 if (product.OptionSetList) { 60 var product_options = JSON.parse(product.OptionSetList); 61 if (product_options.length > 0) hasOptions = true; 62 } 63 64 if (isQuickviewEnabled() && (hasOptions || product.IsOptionRequiredForCategory)) { 65 //quickview(product); 66 quickview("/product.asp?lt_c=1&itemid=" + catalogId + "&qv=1"); 67 jQuery(productDiv).removeClass('ajaxcart-loading'); 68 } 69 else if (!isQuickviewEnabled() && (hasOptions || product.IsOptionRequiredForCategory)) { 70 //window.location.href = "/" + product.ProductLink; 71 window.location.href = product.ProductLink; //URL returned via Ajax post is absolute (fixed here by FusionBot) 72 } 73 else { 74 add_to_cart(product.CatalogID, product.SKU, 0, product.Price, 1, [], false, productDiv); 75 } 76 }); 77 78 jQuery('#qv-modal .qv-addcart[data-ajaxcart="1"]').click(function (e) { 79 e.preventDefault(); 80 jQuery(this).blur(); 81 82 if (jQuery(productDiv).hasClass('ajaxcart-loading')) return; 83 84 var productDiv = jQuery('#qv-modal .product-item'); 85 jQuery(productDiv).addClass('ajaxcart-loading'); 86 87 var catalogId = jQuery('#qv-modal [name="item_id"]').val(); 88 var sku = jQuery('#qv-modal [name="itemid"]').val(); 89 var price = jQuery('#qv-modal [name="std_price"]').val(); 90 var qty = jQuery('#qv-modal [name="qty-0"]').val(); 91 var JsonOptions = get_qv_options(); 92 93 //Options Validation 94 var qvOptionsValid = true; 95 jQuery('.qv-option.required-option').each(function (index, element) { 96 var optiontype = jQuery(element).data('optiontype'); 97 98 switch (optiontype) { 99 case 'radio': 100 var radios = jQuery(element).find('input[type="radio"]'); 101 if (radios.filter(":checked").length <= 0) { 102 qvOptionsValid = false; 103 } 104 break; 105 case 'checkbox': 106 var radios = jQuery(element).find('input[type="checkbox"]'); 107 if (radios.filter(":checked").length <= 0) { 108 qvOptionsValid = false; 109 } 110 break; 111 case 'select': 112 var select = jQuery(element).find('select'); 113 if (!jQuery(select).val() || jQuery(select).val() == "") { 114 qvOptionsValid = false; 115 } 116 console.log(jQuery(select).val()); 117 break; 118 } 119 120 }); 121 122 if (qvOptionsValid) { 123 jQuery('#qvOptionsError').slideUp(); 124 add_to_cart(catalogId, sku, 0, price, qty, JsonOptions, false, productDiv); 125 } 126 else { 127 jQuery(productDiv).removeClass('ajaxcart-loading'); 128 jQuery('#qvOptionsError').slideDown(); 129 } 130 }); 131 132 // //Adjust height of grid items 133 // var maxHeightItem = 0; 134 // jQuery('div.product-items').each(function (index, element) { 135 // var maxHeightItem = 0; 136 // jQuery('.product-item', this).each(function (index, element) { 137 // var height = jQuery(element).height(); 138 // if (height > maxHeightItem) { 139 // maxHeightItem = height; 140 // } 141 // }); 142 // jQuery(this).attr('data-itemsHeight', maxHeightItem); 143 // }); 144 // jQuery('div.product-items').each(function (index, element) { 145 // var height = jQuery(element).attr('data-itemsHeight'); 146 // if (height != undefined && height + "" != "") { 147 // jQuery(element).find('.product-item').height(height); 148 // } 149 // }); 150//}); 151} 152 153//Quickview status 154function isQuickviewEnabled() { 155 if (jQuery('body').hasClass('qv-enabled')) return true; 156 else return false;
157} 158 159//Email validation 160function validate_email(email) { 161 var email_reg = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; 162 return email_reg.test(email); 163} 164//Mailing list API 165function mailing_list(form) { 166 var formDiv = jQuery(form).parent('.ajax-mailinglist'); 167 var callback = jQuery(formDiv).data('callback'); 168 var callfront = jQuery(formDiv).data('callfront'); 169 window[callfront](form); 170 var email = jQuery.trim(jQuery(form).find('input[name="email"]').val()); 171 var action = jQuery(form).find('input[name="subscribe"]:checked').val(); 172 173 if (!validate_email(email)) { 174 window[callback](form, 2); // 2: when email is invalid 175 return; 176 } 177 178 jQuery.ajax({ 179 method: "POST", 180 url: _cart_secure_url + '/mailing_list.asp?ajax=1', 181 data: { 182 email: email, 183 action: action 184 }, 185 success: function (data) { 186 window[callback](form, data); 187 }, 188 error: function () { 189 window[callback](form, 0); 190 return; 191 } 192 }); 193} 194 195//Get product via API 196function get_product(catalogId, categoryId) { 197 198 var product = false; 199 200 jQuery.ajax({ 201 method: "POST", 202 url: '/frontapi.asp', 203 dataType: 'json', 204 type: 'GET', 205 cache: false, 206 async: false, 207 data: { 208 productid: catalogId, 209 categoryid: categoryId, 210 limit: 1, 211 module: 'products', 212 offset: 1 213 }, 214 success: function (data) { 215 product = data; 216 }, 217 error: function (objResponse) { 218 console.log(objResponse); 219 jQuery('.product-item').removeClass('ajaxcart-loading'); 220 alert(GetErrorMessage("error.asp?error=902") +' (902)'); 221 } 222 }); 223 return product; 224} 225// 226function changeDropImage(select) { 227 var img = jQuery(select).find(":selected").data('img'); 228 var target = jQuery(select).attr('name'); 229 jQuery('#' + target).attr('src', img); 230} 231//Quickview 232function quickview(producturl) { 233 234 jQuery('#qv-modal .product-item').css({ 'opacity': 0, 'min-height': 600 }); 235 jQuery('#qv-modal .qv-loader').show(); 236 jQuery('#qv-modal .qv-close').hide(); 237 jQuery('#qv-modal').modal('show'); 238 jQuery('#qvOptionsError').slideUp(); 239 240 hasFileOption = false; 241 242 jQuery('#qv-modal iframe').attr('src', producturl); 243 document.getElementById('qvIframe').style.height = 0; 244 245 jQuery('#qv-modal iframe').on("load" ,function () { 246 jQuery('#qv-modal .qv-loader').fadeOut(100); 247 jQuery('#qv-modal .qv-close').show(); 248 setTimeout(function () { 249 document.getElementById('qvIframe').style.height = (document.getElementById('qvIframe').contentWindow.document.body.scrollHeight + 20) + 'px'; 250 var qvmxheight = document.getElementById('qvIframe').contentWindow.document.body.scrollHeight + 'px'; 251 jQuery('#qv-modal .product-item').css({ 'opacity': 1, 'min-height': 0, 'max-height': qvmxheight }); 252 jQuery('#qv-modal').css({'max-height': qvmxheight }); 253 }, 300); 254 255 }); 256} 257 258function add_to_cart(intCatalogID, strSKU, intCategoryID, intPrice, intQuantity, JsonOptions, qv, productDiv) { 259 260 var formData = new FormData(); 261 formData.append('item_id', intCatalogID); 262 formData.append('itemid', strSKU); 263 formData.append('category_id', intCategoryID); 264 formData.append('std_price', intPrice); 265 formData.append('qty-0', intQuantity); 266 for (var i = 0; i < JsonOptions.length; i++) 267 formData.append(JsonOptions[i].name, JsonOptions[i].id); 268 269 var qryStr = '?module=addcartajax&ajaxadd=1'; 270 jQuery.ajax({ 271 url: '/frontapi.asp' + qryStr, 272 dataType: 'json', 273 type: 'POST', 274 cache: false, 275 contentType: false, 276 processData: false, 277 data: formData, 278 success: function (data) { 279 jQuery(productDiv).removeClass('ajaxcart-loading'); 280 281 if (data.AddedToCart == 1) { 282 if (data.redirecturl.indexOf('view_cart.asp') >= 0 || data.redirecturl.indexOf('checkout.asp') >= 0) { 283 //If the add cart action is "view cart" or "checkout", it should take precedence over any other callback function. 284 window.location.href = data.redirecturl; 285 return; 286 } 287 288 289 //Show quick cart if enabled 290 if (jQuery('body').hasClass('qc-enabled')) { 291 launch_qcart(); 292 } 293 294 //addcart_callback 295 var callback = jQuery(productDiv).data('addcart-callback'); 296 window[callback](productDiv, data); 297 } 298 else { 299 if (data.errorurl != undefined) { 300 //window.location.href = data.errorurl; 301 window.location.href = '/product.asp?itemid=' + intCatalogID; 302 } 303 else { 304 window.location.href = '/error.asp?error=901'; 305 } 306 } 307 }, 308 error: function (objResponse) { 309 jQuery(productDiv).removeClass('ajaxcart-loading'); 310 window.location.href = '/error.asp?error=901'; 311 } 312 }); 313} 314 315function launch_qcart() { 316 if (jQuery('#qcart-modal').length <= 0) { 317 var modal = jQuery('<aside id="qcart-modal" class="qcart qcart-modal modal" tabindex="-1" role="dialog" data-backdrop="true"></aside>'); 318 jQuery(modal).append('<button type="button" class="qv-close close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button><div class="modal-dialog" role="document"><div class="modal-vcenter"><div class="qv-loader"><span class="mailing-btn-load icon-spin2 animate-spin"></span></div><div class="modal-content"><iframe src="view_cart_quick.asp" id="qcart-Iframe" frameborder="0"></iframe></div></div></div>'); 319 jQuery(modal).appendTo('body'); 320 321 jQuery('#qcart-modal .modal-content').css({'opacity': 0, 'min-height': 600}); 322 jQuery('#qcart-modal .qv-loader').show(); 323 jQuery('#qcart-modal .qv-close').hide(); 324 jQuery('#qcart-modal').modal('show'); 325 326 jQuery('#qcart-modal iframe').on("load", function () { 327 jQuery('#qcart-modal .qv-loader').fadeOut(100); 328 jQuery('#qcart-modal .qv-close').show(); 329 setTimeout(function () { 330 document.getElementById('qcart-Iframe').style.height = document.getElementById('qcart-Iframe').contentWindow.document.body.scrollHeight + 'px'; 331 var mxheight = document.getElementById('qcart-Iframe').contentWindow.document.body.scrollHeight + 'px'; 332 jQuery('#qcart-modal .modal-content').css({ 'opacity': 1, 'min-height': 0, 'max-height': mxheight }); 333 jQuery('#qcart-modal').css({'max-height': mxheight }); 334 }, 300); 335 }); 336 } 337 else { 338 339 jQuery('#qcart-modal .modal-content').css({'opacity': 0, 'min-height': 600}); 340 jQuery('#qcart-modal .qv-loader').show(); 341 jQuery('#qcart-modal .qv-close').hide(); 342 jQuery('#qcart-modal').modal('show'); 343 344 document.getElementById('qcart-Iframe').src = document.getElementById('qcart-Iframe').src; 345 346 jQuery('#qcart-modal iframe').on("load" ,function () { 347 jQuery('#qcart-modal .qv-loader').fadeOut(100); 348 jQuery('#qcart-modal .qv-close').show(); 349 document.getElementById('qvIframe').style.height = 0; 350 351 setTimeout(function () { 352 document.getElementById('qcart-Iframe').style.height = document.getElementById('qcart-Iframe').contentWindow.document.body.scrollHeight + 'px'; 353 jQuery('#qcart-modal .modal-content').css({ 'opacity': 1, 'min-height': 0 }); 354 }, 300); 355 }); 356 } 357} 358 359function get_qv_options() { 360 var JsonOptions =[]; 361 362 jQuery('#qv-modal .options :checked, #qv-modal .options :selected').each(function () { 363 364 if (jQuery(this).is("option")) { 365 JsonOptions.push({ 366 "name": jQuery(this).parent().attr('name'), 367 "id": jQuery(this).val() 368 }); 369 } 370 else { 371 JsonOptions.push({ 372 "name": jQuery(this).attr('name'), 373 "id": jQuery(this).val() 374 }); 375 } 376 377 }); 378 379 return JsonOptions; 380} 381 382/** 383* Quick Cart 384***********************/ 385jQuery(function () { 386 if (window.location.search.indexOf("quickcart") != -1 || window.location.search.indexOf("quick") != -1) {
387 launch_qcart(); 388 } 389}); 390function closeQuickCartModal() { 391 jQuery('#qcart-modal').modal('hide'); 392} 393 394 395window.closeRewardWidgetModal = function(){ 396 jQuery('#divRewardWidgetModal').modal('hide'); 397}; 398 399/** 400* Helper Functions 401***********************/ 402function validateEmail(email) { 403 var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 404 return re.test(email); 405} 406function setCookie(cname, cvalue, exdays) { 407 var d = new Date(); 408 d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); 409 var expires = "expires=" + d.toUTCString(); 410 document.cookie = cname + "=" + cvalue + "; " + expires; 411} 412 413function getCookie(cname) { 414 var name = cname + "="; 415 var ca = document.cookie.split(';'); 416 for (var i = 0; i < ca.length; i++) { 417 var c = ca[i]; 418 while (c.charAt(0) == ' ') { 419 c = c.substring(1); 420 } 421 if (c.indexOf(name) == 0) { 422 return c.substring(name.length, c.length); 423 } 424 } 425 return ""; 426} 427 428function getVariableVal(varName) { 429 return jQuery('#variablesVals').data(varName); 430} 431 432function removeMarkupTags(strString) { 433 var strInputCode = strString; 434 strInputCode = strInputCode.replace(/&(lt|gt);/g, function (strMatch, p1) { 435 return (p1 == "lt") ? "<" : ">"; 436 }); 437 var strTagStrippedText = strInputCode.replace(/<\/?[^>]+(>|$)/g, ""); 438 strTagStrippedText = strTagStrippedText.replace(/\u00a0/g, ''); 439 strTagStrippedText = strTagStrippedText.replace(/ /gi, ''); 440 return strTagStrippedText; 441} 442 443function GetErrorMessage(errorUrl) { 444 var errorMsg = ""; 445 jQuery.ajax({ 446 url: errorUrl + '&ajax=1&hdnSecurityToken=[securityToken]', 447 type: 'POST', 448 dataType: 'json', 449 cache: false, 450 async: false, 451 success: function (objResponse) { 452 errorMsg = removeMarkupTags(objResponse.message); 453 }, 454 error: function (objResponse) { 455 console.log(objResponse); 456 errorMsg = "Something went wrong. Please try again."; 457 } 458 }); 459 return errorMsg; 460} 461function GetLanguagItem(itemName) { 462 var languageItem = ""; 463 jQuery.ajax({ 464 url: 'error.asp?msgType=2&itemName=' + itemName, 465 type: 'POST', 466 dataType: 'json', 467 cache: false, 468 async: false, 469 success: function (objResponse) { 470 languageItem = objResponse.message; 471 }, 472 error: function (objResponse) { 473 console.log(objResponse); 474 languageItem = "Something went wrong. Please try again."; 475 } 476 }); 477 return languageItem; 478}
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.