1var quickSearchRequest = $.ajax({ 2 url: 'blank.txt', 3 async: true, 4 method: 'get', 5 dataType: 'script' 6}); 7var filterRequest = $.ajax({ 8 url: 'blank.txt', 9 async: true, 10 method: 'get', 11 dataType: 'script' 12}); 13var hideCart = setTimeout(function () { 14 var a = 1; 15}, 0); 16var iChars = ""; 17var test; 18var Cart = { 19 DownloadFile2: function(productId){ 20 var url = "index.cfm?action=gdcdata.CartActions.ActAjaxDonwloadFile2"; 21 $.ajax({ 22 url: url, 23 data: {productId: productId}, 24 async: true, 25 success: function () {} 26 }); 27 }, 28 CreateContactMessage: function () { 29 if ($("#contactName").length > 0 && !$("#contactName").val().length) { 30 Cart.HighlightAndFocus("#contactName"); 31 return false; 32 } 33 34 if ($("#contactPhone").length > 0 && !$("#contactPhone").val().length) { 35 Cart.HighlightAndFocus("#contactPhone"); 36 return false; 37 } 38 39 if ($("#contactEmail").length > 0 && !$("#contactEmail").val().length) { 40 Cart.HighlightAndFocus("#contactEmail"); 41 return false; 42 } 43 44 if ($("#contactEnquiry").length > 0 && !$("#contactEnquiry").val().length) { 45 Cart.HighlightAndFocus("#contactEnquiry"); 46 return false; 47 } 48 49 $("#contactForm").submit(); 50 }, 51 HomePageWidget: { 52 Start: function (argSlideSpeed, argSlideFadeSpeed, argIndex) { 53 if ($("#bannerSlides div.bannerPhoto").length > 1) { 54 $('#bannerSlides').slick({ 55 infinite: true, 56 slidesToShow: 1, 57 slidesToScroll: 1, 58 speed: argSlideSpeed, 59 fade: true, 60 cssEase: 'linear', 61 dots: true, 62 arrows: true, 63 prevArrow: '<div class="bgPrev"><a href="javascript:;">Previous</a></div>', 64 nextArrow: '<div class="bgNext"><a href="javascript:;">Next</a></div>', 65 appendArrows: $('#banner-arrows') 66 }); 67 } 68 } 69 }, 70 InnerPageWidget: { 71 //not used 72 Start: function (argSlideSpeed, argSlideFadeSpeed, argIndex) { 73 if ($(".bannerSlimSlider").length > 1) { 74 $('.bannerSlimSlider').slick({ 75 infinite: true, 76 slidesToShow: 1, 77 slidesToScroll: 1, 78 speed: argSlideSpeed, 79 fade: true, 80 cssEase: 'linear' 81 }); 82 } 83 } 84 }, 85 CloseFreeShippingMessage: function () { 86 var url = "index.cfm?action=gdcdata.CartActions.ActAjaxCloseFreeShipping"; 87 $.ajax({
88 url: url, 89 async: true, 90 success: function () {} 91 }); 92 return false; 93 }, 94 Featured: function () { 95 if ($("#featuredStrip").length > 1) { 96 $('#featuredStrip').slick({ 97 //autoplay: true, 98 //autoplaySpeed: 1000, 99 infinite: true, 100 slidesToShow: 5, 101 slidesToScroll: 1, 102 speed: 1000 103 }); 104 } 105 }, 106 ShowDonateAddress: function () { 107 if ($("#showAddress").prop('checked')) { 108 $(".addressFields").show(); 109 } else { 110 $(".addressFields").hide(); 111 } 112 }, 113 FeedbackTab: function (tab, a) { 114 $("#feedbackBox form").each(function (i, el) { 115 $(el).css('display', "none"); 116 }); 117 $("#feedbackBox .tabs a").each(function (i, el) { 118 $(el).attr('class', "null"); 119 }); 120 $(a).attr('class', "sel"); 121 $("#feedbackBox form").eq(tab - 1).css('display', "block"); 122 }, 123 DropdownOpen: function (el) { 124 //not used 125 if ($(el).closest("div").find("ul").css("max-height") > 0) { 126 $(el).closest("div").find("ul").css("max-height", "0px"); 127 } else { 128 $(el).closest("div").find("ul").css("max-height", $(el).closest("div").find("ul").prop('scrollHeight')); 129 $(el).focus(); 130 } 131 }, 132 DropdownSelect: function (el) { 133 //not used 134 $(el).closest("div").find(".ddVal").val($(el).attr("data-value")); 135 $(el).closest("div").find(".currentVal").html($(el).html()); 136 $(el).closest("ul").find("a").each(function (i, e) { 137 $(e).attr("class", ""); 138 }); 139 $(el).attr("class", "sel"); 140 $(el).closest("ul").css('max-height', "0px"); 141 }, 142 OpenFeedback: function () { 143 //not used 144 $("#feedbackContainer").show(); 145 }, 146 CloseFeedback: function () { 147 //not used 148 $("#feedbackContainer").hide(); 149 }, 150 ValidateFeedback: function () { 151 if ($("#feedbackEmail").val().isEmpty() || $("#feedbackEmail").val().indexOf("@") == -1 || $("#feedbackEmail").val().indexOf(".") == -1) { 152 Cart.HighlightAndFocus("#feedbackEmail"); 153 return false; 154 } else { 155 return true; 156 } 157 }, 158 ValidateProblem: function () { 159 if ($("#problemEmail").val().isEmpty() || $("#problemEmail").val().indexOf("@") == -1 || $("#problemEmail").val().indexOf(".") == -1) { 160 Cart.HighlightAndFocus("#problemEmail"); 161 return false; 162 } else { 163 return true; 164 } 165 }, 166 ToggleMainNav: function () { 167 Site.ToggleMainNav(); 168 }, 169 ToggleCurrency: function () { 170 Site.ToggleCurrency(); 171 }, 172 Tabs: { 173 ToggleProductTab: function (id) { 174 $('li.selectProductTab').each(function (i, s) { 175 liTabId = $(s).attr('id'); 176 i = liTabId.substring(3); 177 $("#tab" + i).removeClass("sel"); 178 $("#productTab" + i + "Content").removeClass("productTabOn"); 179 $("#productTab" + i + "Content").addClass("productTabOff"); 180 }); 181 $("#tab" + id).addClass("sel"); 182 $("#productTab" + id + "Content").removeClass("productTabOff"); 183 $("#productTab" + id + "Content").addClass("productTabOn"); 184 } 185 }, 186 ProductPhotos: { 187 Start: function (argSlideSpeed, argSlideFadeSpeed, argIndex) { 188 $('#productSlides').slick({ 189 infinite: true, 190 slidesToShow: 3, 191 slidesToScroll: 1, 192 speed: argSlideSpeed, 193 fade: true, 194 cssEase: 'linear' 195 }); 196 } 197 }, 198 SelectProductImage: function (productId) { 199 $('#productSmallImage-' + productId).click(); 200 }, 201 Products: { 202 //not used 203 Previous: function (index, count) { 204 var caseIndex = index - 1; 205 206 if (caseIndex == 0) { 207 caseIndex = count; 208 } 209 210 $("#Product" + index).hide(); 211 $("#Product" + caseIndex).show(); 212 }, 213 Next: function (index, count) { 214 var caseIndex = index + 1; 215 216 if (caseIndex > count) { 217 caseIndex = 1; 218 } 219 220 $("#Product" + index).hide(); 221 $("#Product" + caseIndex).show(); 222 } 223 }, 224 QuickSearchResults: function (el) { 225 if (window.event.keyCode == 27) { 226 $(".search .toggleSearch").click(); 227 return false; 228 } 229 230 $('#QuickSearch').css("display", 'block'); // url="index.cfm?action=cart_ajax_quicksearch&q=" + escape($(el).val()); 231 232 url = "index.cfm?action=gdcdata.CartActions.ActAjaxQuickSearch&q=" + escape($(el).val()); 233 quickSearchRequest = $.ajax({
234 url: url, 235 async: true, 236 success: function (r) { 237 $("#QuickSearch").html(r); 238 } 239 }); 240 }, 241 QuickSearchAlgoliaResults: function () { 242 if (window.event.keyCode == 27) { 243 $(".search .toggleSearch").click(); 244 return false; 245 } 246 247 $('#QuickSearch').css("display", 'block'); 248 index = client.initIndex(algoliaIndex); // Callback example 249 250 index.search($('#searchBoxSearch').val(), { 251 typoTolerance: 'min', 252 hitsPerPage: 50 253 }, function searchDone(err, content) { 254 // err is either `null` or an `Error` object, with a `message` property 255 // content is either the result of the command or `undefined` 256 if (err) { 257 console.error(err); 258 return; 259 } 260 261 htmlContent = '<div class="inner">'; 262 productCount = 0; 263 pageCount = 0; 264 productHtmlContent = '<div class="col span10"><h2>Products</h2>'; 265 pageHtmlContent = '<div class="col span2"><h2>Pages</h2><ul>'; 266 console.log(content); 267 268 for (product in content.hits) { 269 var productStruct = content.hits[product]; 270 271 if (!("productUrl" in productStruct)) { 272 if (pageCount < 20) { 273 var pageUrl = productStruct.pageCode; 274 var pageName = productStruct.pageName; 275 var pageSummary = productStruct.pageSummary; 276 277 if ("_highlightResult" in productStruct) { 278 if ("pageName" in productStruct._highlightResult) { 279 pageName = productStruct._highlightResult.pageName.value; 280 } 281 282 if ("pageSummary" in productStruct._highlightResult) { 283 pageSummary = productStruct._highlightResult.pageSummary.value; 284 } 285 } 286 287 pageHtmlContent += '<li><a href="' + pageUrl + '"><h3>' + pageName + '</h3>'; 288 289 if (pageSummary.length > 0) { 290 pageHtmlContent += '<p>' + pageSummary + '</p>'; 291 } 292 293 pageHtmlContent += '</li>'; 294 pageCount += 1; 295 } 296 } else { 297 if (productCount < 12) { 298 var productUrl = productStruct.productUrl; 299 var productImageFileName = productStruct.productImageFileName; 300 var productName = productStruct.productName; 301 var productDescription = productStruct.productDescription; 302 303 if ("_highlightResult" in productStruct) { 304 if ("productName" in productStruct._highlightResult) { 305 productName = productStruct._highlightResult.productName.value; 306 } 307 308 if ("productDescription" in productStruct._highlightResult) { 309 productDescription = productStruct._highlightResult.productDescription.value; 310 } 311 } 312 313 productHtmlContent += '<div class="col span2"><div class="box"><a href="' + productUrl + '"><img src="' + productImageFileName + '" alt="' + productName + '"><span class="title">' + productName + '</span><span class="description">' + productDescription + '</span></a></div></div>'; 314 productCount += 1; 315 } 316 } 317 } 318 319 htmlContent += productHtmlContent + '</div>'; 320 htmlContent += pageHtmlContent + '</ul></div>'; 321 htmlContent += '<a class="btn block" href="' + siteUrl + 'search/q/' + $('#searchBoxSearch').val() + '/">See all results <i class="fa fa-angle-right"></i></a></div>'; 322 htmlContent = htmlContent.replace(/\/Small\//g, '\/Large\/'); 323 $("#QuickSearch").html(htmlContent); 324 }); 325 }, 326 SearchPageAlgoliaResults: function (id) { 327 if (window.event.keyCode == 27) { 328 $(".search .toggleSearch").click(); 329 return false; 330 } 331 332 $('#QuickSearch').css("display", 'block'); 333 index = client.initIndex(algoliaIndex); // Callback example 334 335 index.search($('#searchPageSearch').val(), { 336 hitsPerPage: 100 337 }, function searchDone(err, content) { 338 // err is either `null` or an `Error` object, with a `message` property 339 // content is either the result of the command or `undefined` 340 if (err) { 341 console.error(err); 342 return; 343 } 344 345 if (content.hits.length > 0) { 346 pageHtmlContent = ''; 347 productHtmlContent = '';
348 productCount = 0; 349 pageCount = 0; 350 351 for (product in content.hits) { 352 var productStruct = content.hits[product]; 353 354 if (!("productUrl" in productStruct)) { 355 var pageUrl = productStruct.pageCode; 356 var pageName = productStruct.pageName; 357 var pageSummary = productStruct.pageSummary; 358 359 if ("_highlightResult" in productStruct) { 360 if ("pageName" in productStruct._highlightResult) { 361 pageName = productStruct._highlightResult.pageName.value; 362 } 363 364 if ("pageSummary" in productStruct._highlightResult) { 365 pageSummary = productStruct._highlightResult.pageSummary.value; 366 } 367 } 368 369 pageHtmlContent += '<li><a href="' + pageUrl + '"><h3>' + pageName + '</h3>'; 370 371 if (pageSummary.length > 0) { 372 pageHtmlContent += '<p>' + pageSummary + '</p>'; 373 } 374 375 pageHtmlContent += '</li>'; 376 pageCount += 1; 377 } else { 378 if (productCount < 20) { 379 var productUrl = productStruct.productUrl; 380 var productImageFileName = productStruct.productImageFileName; 381 var productImageFileName = productStruct.productImageFileName; 382 var productName = productStruct.productName; 383 var productDescription = productStruct.productDescription; 384 385 if ("_highlightResult" in productStruct) { 386 if ("productName" in productStruct._highlightResult) { 387 productName = productStruct._highlightResult.productName.value; 388 } 389 390 if ("productDescription" in productStruct._highlightResult) { 391 productDescription = productStruct._highlightResult.productDescription.value; 392 } 393 } 394 395 productDescription = ''; 396 productHtmlContent += '<div class="col span3"><div class="box"><a href="' + productUrl + '"><img src="' + productImageFileName + '" alt="' + productName + '"><span class="title">' + productName + '</span><span class="description">' + productDescription + '</span></a></div></div>'; 397 productCount += 1; 398 } 399 } 400 } 401 402 htmlContent = '<div class="inner">'; 403 htmlContent += '<ul class="etabs">'; 404 htmlContent += '<li class="tab" id="productsLink"><a href="javascript:;">' + productCount + ' Products</a></li>'; 405 htmlContent += '<li class="tab" id="pagesLink"><a href="javascript:;">' + pageCount + ' Pages</a></li>'; 406 htmlContent += '</ul>'; 407 productHtmlContent = '<div class="row grid productsListing productResults " id="productsContainer" >' + productHtmlContent + '</div>'; 408 pageHtmlContent = '<div class="row grid productsListing pageResults " id="pagesContainer" >' + pageHtmlContent + '</div>'; 409 htmlContent += productHtmlContent + pageHtmlContent + '</div>'; 410 htmlContent = htmlContent.replace(/\/Small\//g, '\/Large\/'); 411 $("#QuickSearchPage").html(htmlContent); 412 413 if (productCount > 0) { 414 $('#productsLink').addClass('active'); 415 $('#pagesContainer').hide(); 416 417 if (pageCount == 0) { 418 $('#pagesLink').hide(); 419 } 420 } else if (pageCount > 0) { 421 $('#pagesLink').addClass('active'); 422 $('#productsLink').hide(); 423 $('#productsContainer').hide(); 424 } 425 426 $('#productsLink').click(function () { 427 if ($('#productsLink').hasClass('active')) { 428 $('#productsContainer').hide(); 429 $('#productsLink').removeClass('active'); 430 } else { 431 $('#productsContainer').show(); 432 $('#pagesContainer').hide(); 433 $('#pagesLink').removeClass('active'); 434 $('#productsLink').addClass('active'); 435 } 436 437 return false; 438 }); 439 $('#pagesLink').click(function () { 440 if ($('#pagesLink').hasClass('active')) { 441 $('#pagesContainer').hide(); 442 $('#pagesLink').removeClass('active'); 443 } else { 444 $('#pagesContainer').show(); 445 $('#productsContainer').hide(); 446 $('#productsLink').removeClass('active'); 447 $('#pagesLink').addClass('active'); 448 } 449 450 return false; 451 }); 452 $("#noSearchResults").hide(); 453 } else { 454 $("#QuickSearchPage").html(''); 455 $("#noSearchResults").html($("#noSearchResults").html().replace(/{searchText}/g, $('#searchPageSearch').val())); 456 $("#noSearchResults").show(); 457 } 458 });
459 }, 460 ViewAsThumbs: function () { 461 $("#productsListing").attr("class", "productList"); 462 $("a.view.list").eq(0).css("opacity", "0.5"); 463 $("a.view.list").eq(0).css("cursor", "pointer"); 464 465 if ($("a.view.list").eq(1)) { 466 $("a.view.list").eq(1).css("opacity", "0.5"); 467 $("a.view.list").eq(1).css("cursor", "pointer"); 468 } 469 470 $("a.view.thumbnails").eq(0).css("opacity", "1"); 471 $("a.view.thumbnails").eq(0).css("cursor", "default"); 472 473 if ($("a.view.thumbnails").eq(1)) { 474 $("a.view.thumbnails").eq(1).css("opacity", "1"); 475 $("a.view.thumbnails").eq(1).css("cursor", "default"); 476 } // var url = "index.cfm?action=Cart_Ajax_SetListMode&listMode=thumbs"; 477 478 479 var url = "index.cfm?action=gdcdata.CartActions.ActAjaxSetListMode&listMode=thumbs"; 480 $.ajax({ 481 url: url, 482 async: true 483 }); 484 }, 485 ViewAsList: function () { 486 $("#productsListing").attr("class", "productList list"); 487 $("a.view.list").eq(0).css("opacity", "1"); 488 $("a.view.list").eq(0).css("cursor", "default"); 489 490 if ($("a.view.list").eq(1)) { 491 $("a.view.list").eq(1).css("opacity", "1"); 492 $("a.view.list").eq(1).css("cursor", "default"); 493 } 494 495 $("a.view.thumbnails").eq(0).css("opacity", "0.5"); 496 $("a.view.thumbnails").eq(0).css("cursor", "pointer"); 497 498 if ($("a.view.thumbnails").eq(1)) { 499 $("a.view.thumbnails").eq(1).css("opacity", "0.5"); 500 $("a.view.thumbnails").eq(1).css("cursor", "pointer"); 501 } // var url = "index.cfm?action=Cart_Ajax_SetListMode&listMode=list"; 502 503 504 var url = "index.cfm?action=gdcdata.CartActions.ActAjaxSetListMode&listMode=list"; 505 $.ajax({
506 url: url, 507 async: true 508 }); 509 }, 510 ViewProducts: function (direction) { 511 var productsPerPage = Number($("#productsPerPage").val()); 512 var currentPage = Number($("#currentPage").val()); 513 var pageCount = Number($("#pageCount").val()); 514 var totalProduct = Number($("#totalProduct").val()); 515 var startProduct = Number($("#startProduct").val()); 516 var endProduct = Number($("#endProduct").val()); 517 var viewAllProducts = Number($("#viewAllProducts").val()); 518 519 if (direction == 'prev') { 520 if (viewAllProducts == 1) { 521 currentPage = 1; 522 startProduct = 1; 523 endProduct = productsPerPage; 524 viewAllProducts = 0; 525 } else { 526 currentPage = currentPage - 1; 527 528 if (currentPage < 1) { 529 currentPage = 1; 530 } else { 531 startProduct = startProduct - productsPerPage; 532 endProduct = endProduct - productsPerPage; 533 } 534 } 535 } 536 537 if (direction == 'next') { 538 if (viewAllProducts == 1) { 539 currentPage = 1; 540 startProduct = 1; 541 endProduct = productsPerPage; 542 viewAllProducts = 0; 543 } else { 544 currentPage = currentPage + 1; 545 546 if (currentPage > pageCount) { 547 currentPage = pageCount; 548 } else { 549 startProduct = startProduct + productsPerPage; 550 endProduct = endProduct + productsPerPage; 551 } 552 } 553 } 554 555 if (direction == 'all') { 556 currentPage = 1; 557 startProduct = 1; 558 pageCount = 1; 559 endProduct = totalProduct; 560 viewAllProducts = 1; 561 } 562 563 if (totalProduct <= endProduct) { 564 endProduct = totalProduct; 565 } 566 567 if ($("#startProductVal-Top")) { 568 $("#startProductVal-Top").html(startProduct); 569 $("#startProductVal-Bottom").html(startProduct); 570 $("#startProduct").val(startProduct); 571 $("#endProductVal-Top").html(endProduct); 572 $("#endProductVal-Bottom").html(endProduct); 573 $("#endProduct").val(endProduct); 574 $("#currentPageVal-Top").html(currentPage); 575 $("#currentPageVal-Bottom").html(currentPage); 576 $("#currentPage").val(currentPage); 577 $("#pageCountVal-Top").html(pageCount); 578 $("#pageCountVal-Bottom").html(pageCount); 579 $("#pageCount").val(pageCount); 580 $("#viewAllProducts").val(viewAllProducts); 581 } 582 583 Cart.FilterProducts('', 1); 584 $('html,body').animate({ 585 scrollTop: $(".container").offset().top 586 }, 'slow'); 587 }, 588 SelectShippingAddress: function () { 589 if ($("#userShippingId").val() == -1) { 590 $("#newDeliveryDetails").show(); 591 } else { 592 $("#newDeliveryDetails").hide(); 593 } 594 595 if ($("#userShippingId").val() > 0) { 596 $("#userShippingInformation").html($("#userShippingId").find('option:selected').html()); 597 $("#shippingDetailsConfirmationContainer").html($("#userShippingId").find('option:selected').attr('data-usershippinghtmladdress')); 598 599 if ($("#billingDetailsContainer").html().trim().length < 5) { 600 Cart.CopyShippingToBilling(); 601 } 602 } 603 604 if ($("#userShippingId").find('option:selected').attr('data-usershippingisclickandcollect') == 'Yes') { 605 $("#orderShipToBillingAddress").prop('checked', false); // Cart.ClearShippingAddress(); 606 607 $("#billingDetailsLegend1").html('Billing/Collection Details'); 608 $("#billingDetailsLegend2").html('Billing/Collection Details'); 609 } else { 610 $("#orderShipToBillingAddress").prop('checked', true); // Cart.CopyBillingAddress(); 611 612 $("#billingDetailsLegend1").html('Billing Details'); 613 $("#billingDetailsLegend2").html('Billing Details'); 614 } 615 616 var shippingMethodIdParam = ""; 617 $('input.shippingMethodIds').each(function (i, s) { 618 if ($(s).prop('checked')) { 619 shippingMethodIdParam = "&shippingMethodId=" + $(s).val(); 620 } 621 }); // var url = "index.cfm?action=Cart_Ajax_GetShippingOptions&ajax&userShippingId=" + $("#userShippingId").val() + shippingMethodIdParam; 622 623 var url = "index.cfm?action=gdcdata.CartActions.ActAjaxGetShippingOptions&ajax=Yes&userShippingId=" + $("#userShippingId").val() + shippingMethodIdParam; 624 $.ajax({
625 url: url, 626 async: true, 627 success: function (r) { 628 $("#shippingMethods").html(r); 629 $("#shippingMethodsContainer").show(); 630 Cart.RenderOrderSummary(); 631 $('html,body').animate({ 632 scrollTop: $("#wrap").offset().top 633 }, 'slow'); 634 } 635 }); 636 }, 637 CopyBillingAddress: function () { 638 $("#userShippingFirstName").val($("#userFirstName").val()); 639 $("#userShippingLastName").val($("#userLastName").val()); 640 $("#userShippingAddress1").val($("#userAddress1").val()); 641 $("#userShippingAddress2").val($("#userAddress2").val()); 642 $("#userShippingAddress3").val($("#userAddress3").val()); 643 $("#userShippingCity").val($("#userCity").val()); 644 $("#userShippingState").val($("#userState").val()); 645 $("#userShippingPostalCode").val($("#userPostalCode").val()); 646 $("#userShippingTelephone").val($("#userPhone").val()); 647 $("#userShippingCountryId").val($("#userCountryId").val()); 648 }, 649 ClearShippingAddress: function () { 650 $("#orderShipToBillingAddress").prop('checked', false); 651 $("#existingBillingDetails").hide(); 652 $("#newBillingDetails").show(); 653 $("#userBillingFirstName").val(''); 654 $("#userBillingLastName").val(''); 655 $("#userBillingAddressLine1").val(''); 656 $("#userBillingAddressLine2").val(''); 657 $("#userBillingAddressLine3").val(''); 658 $("#userBillingCity").val(''); 659 $("#userBillingState").val(''); 660 $("#userBillingPostalCode").val(''); 661 $("#userBillingCountryId").val('-1'); 662 $("#userBillingPhone").val(''); 663 return false; // $("#userBillingEmail").val(''); 664 }, 665 EditShippingAddress: function (userShippingId) { 666 // var url = "index.cfm?action=cart_ajax_copyShippingAddress&userShippingId="+userShippingId; 667 var url = "index.cfm?action=gdcdata.CartActions.ActAjaxCopyShippingAddress&userShippingId=" + userShippingId; 668 $("#newDeliveryDetails").show(); 669 $("#validateShippingAddressBtn").val("Update Address"); 670 $.ajax({
671 url: url, 672 async: true, 673 success: function (r) { 674 j = $.parseJSON(r.replace(/\\'/g, "'")); 675 $("#userShippingFirstName").val(j.firstName); 676 $("#userShippingLastName").val(j.lastName); 677 $("#userShippingAddress1").val(j.address1); 678 $("#userShippingAddress2").val(j.address2); 679 $("#userShippingAddress3").val(j.address3); 680 $("#userShippingCity").val(j.city); 681 $("#userShippingState").val(j.state); 682 $("#userShippingPostalCode").val(j.zip); 683 $("#userShippingCountryId").val(j.country); 684 $("#userShippingTelephone").val(j.phone); 685 $("#useruserShippingId").val(userShippingId); 686 687 if ($("#userShippingState").val().isEmpty()) { 688 $("#userBillingState").val(""); 689 } 690 } 691 }); 692 }, 693 CopyShippingToBilling: function () { 694 // var url = "index.cfm?action=cart_ajax_copyShippingAddress"; 695 $("#orderShipToBillingAddressCheck").prop('checked', true); 696 var url = "index.cfm?action=gdcdata.CartActions.ActAjaxCopyShippingAddress"; 697 $.ajax({
698 url: url, 699 async: false, 700 success: function (r) { 701 j = $.parseJSON(r.replace(/\\'/g, "'")); //console.log(j); 702 703 $("#userBillingFirstName").val(j.firstName); 704 $("#userBillingLastName").val(j.lastName); 705 $("#userBillingAddressLine1").val(j.address1); 706 $("#userBillingAddressLine2").val(j.address2); 707 $("#userBillingAddressLine3").val(j.address3); 708 $("#userBillingCity").val(j.city); 709 $("#userBillingState").val(j.state); 710 $("#userBillingPostalCode").val(j.zip); 711 $("#userBillingCountryId").val(j.country); 712 $("#userBillingPhone").val(j.phone); // $("#userBillingEmail").val(j.email); 713 714 $("#billingDetailsContainer").html(j.fullhtmladdress); 715 $("#billingDetailsConfirmationContainer").html(j.fullhtmladdress); 716 717 if ($("#userBillingState").val().isEmpty()) { 718 $("#userBillingState").val("N/A"); 719 } 720 721 $("#existingBillingDetails").show(); 722 $("#newBillingDetails").hide(); 723 return false; 724 } 725 }); 726 }, 727 UpdateCounty: function () { 728 var countyId = $('#countyId').val(); 729 window.location = siteUrl + 'locations/countyId/' + countyId + '/'; 730 return false; 731 }, 732 UpdateProductSearch: function (updateType) { 733 var typeId = $('#typeId').val(); 734 735 if (updateType == 'county') { 736 typeId = 0; 737 locationId = 0; 738 } 739 740 if (typeId == 0) { 741 $.ajax({
742 // url: 'index.cfm?action=cart_ajax_GetProductTypes&countyId=' + countyId + '&locationId=' + locationId, 743 url: 'index.cfm?action=gdcdata.CartActions.ActAjaxGetProductTypes&countyId=' + countyId + '&locationId=' + locationId, 744 method: 'get', 745 success: function (transport) { 746 var array = $.parseJSON(transport); 747 $('#typeId').html(""); 748 $('#typeId').append('<option value="0">Select Type...</option>'); 749 750 for (e in array.DATA) { 751 if (array.DATA.hasOwnProperty(e)) { 752 $('#typeId').append('<option value="' + array.DATA[e][0] + '">' + array.DATA[e][1] + '</option>'); 753 $('#typeId option').each(function (i, ele) { 754 $(ele).prop("selected", false); 755 }); 756 } 757 } 758 /* $('typeId').value = 1; */ 759 //Event.fire($("typeId"), "liszt:updated"); 760 761 } 762 }); 763 } 764 765 ; // var url = "index.cfm?action=cart_ajax_GetProducts&countyId=" + countyId + "&locationId=" + locationId + "&typeId=" + typeId; 766 767 var url = "index.cfm?action=gdcdata.CartActions.ActAjaxGetProducts&countyId=" + countyId + "&locationId=" + locationId + "&typeId=" + typeId; 768 $.ajax({
769 url: url, 770 async: true, 771 success: Cart.UpdateProductSearch_onSuccess 772 }); 773 return false; 774 }, 775 UpdateProductSearch_onSuccess: function (t) { 776 z = $.parseJSON(t.replace(/\\'/g, "'")); 777 $("#quickBook").html(z.formHTML); 778 return false; 779 }, 780 IncreaseProductQuantity: function (productId) { 781 $('#orderItemQuantity-' + productId).val(parseInt($('#orderItemQuantity-' + productId).val()) + 1); 782 return false; 783 }, 784 DecreaseProductQuantity: function (el) { 785 $('#orderItemQuantity-' + productId).val(parseInt($('#orderItemQuantity-' + productId).val()) - 1); 786 return false; 787 }, 788 ChangeCurrency: function (code) { 789 // var url = "index.cfm?action=Cart_Ajax_SetCurrency" 790 var url = "index.cfm?action=gdcdata.CartActions.ActAjaxSetCurrency" + "&code=" + escape(code); 791 var refreshUrl = document.location.href; 792 793 if (refreshUrl.indexOf("?") != -1) { 794 refreshUrl = refreshUrl + "&rand=" + Math.floor(Math.random() * 11); 795 } else { 796 refreshUrl = refreshUrl + "?rand=" + Math.floor(Math.random() * 11); 797 } 798 799 $.ajax({
800 url: url, 801 async: true, 802 success: function () { 803 window.location = refreshUrl; 804 } 805 }); 806 return false; 807 }, 808 RefreshProduct: function () { 809 if ($("#selectSizeList") && $("#selectColoursList")) { 810 if ($("#selectSizeList").find("li").length == 1) { 811 eval($("#selectSizeList").find("a").eq(0).attr("onclick").replace("return false", "")); 812 } else if ($("#selectColoursList").find("li").length == 1) { 813 eval($("#selectColoursList").find("a").eq(0).attr("onclick").replace("return false", "")); 814 } 815 } 816 }, 817 SelectNewSize: function (productId, sizeCode) { 818 // var url = "index.cfm?action=cart_ajax_selectcolour" 819 var url = "index.cfm?action=gdcdata.CartActions.ActAjaxSelectColour" + "&newSelect=" + 1 + "&productId=" + escape(productId) + "&subProductColourCode=" + "" + "&subProductSizeCode=" + escape(sizeCode); 820 $('#subProductColourCode').val(''); 821 $.ajax({ 822 url: url, 823 async: true, 824 success: Cart.SelectNewSize_onSuccess 825 }); 826 return false; 827 }, 828 SelectNewSize_onSuccess: function (t) { 829 z = $.parseJSON(t.replace(/\\'/g, "'")); 830 var outputRow = z.outputRow; 831 var productId = z.productId; 832 var sizeCode = z.subProductSizeCode; 833 var colourCode = z.subProductColourCode; 834 $('#selectSizeList').html(outputRow); 835 Cart.SelectSize(productId, sizeCode, colourCode); 836 return false; 837 }, 838 SelectProductTag: function (productId, productTagTypeId, productTagId, productTagAdditionalPrice) { 839 $('li.productTagTypeId-' + productTagTypeId).each(function (i, s) { 840 $(s).removeClass("sel"); 841 }); 842 $('#productTagId_' + productTagId).addClass("sel"); 843 $('#productTagTypeId-' + productTagTypeId).val(productTagId); 844 $('#productTagTypeAdditionalPrice-' + productTagTypeId).val(productTagAdditionalPrice); 845 $('#productTagTypeIdList-' + productTagTypeId).css("max-height", "0px"); 846 $('#productTagTypeNameValue-' + productTagTypeId).html($('#productTagIdUrl_' + productTagId).html()); 847 return false; 848 }, 849 SelectSize: function (productId, sizeCode, colourCode) { 850 $('li.subProductSizes').each(function (i, s) { 851 $(s).removeClass("sel"); 852 }); 853 $('#subProductSize_' + sizeCode).addClass("sel"); 854 $('#subProductSizeCode').val(sizeCode); // var url = "index.cfm?action=cart_ajax_selectsize" 855 856 var url = "index.cfm?action=gdcdata.CartActions.ActAjaxSelectSize" + "&productId=" + escape(productId) + "&subProductSizeCode=" + escape(sizeCode) + "&subProductColourCode=" + escape(colourCode); 857 $.ajax({
858 url: url, 859 async: true, 860 success: Cart.SelectSize_onSuccess 861 }); 862 return false; 863 }, 864 SelectSize_onSuccess: function (t) { 865 z = $.parseJSON(t.replace(/\\'/g, "'")); 866 var outputRow = z.outputRow; 867 $('#selectColoursList').html(outputRow); 868 return false; 869 }, 870 SelectVoucher: function (productId, productPosCode) { 871 $('li.voucherListElement').each(function (i, s) { 872 $(s).removeClass("sel"); 873 }); 874 $('#voucher_' + productPosCode).addClass("sel"); 875 $('#voucherPosCode').val(productPosCode); 876 return false; 877 }, 878 SelectQuickBuy: function (productId, productPosCode) { 879 $('li.quickbuyListElement').each(function (i, s) { 880 $(s).removeClass("sel"); 881 }); 882 $('#quickbuy_' + productPosCode).addClass("sel"); 883 $('#quickBuyPosCode').val(productPosCode); 884 return false; 885 }, 886 SelectNewColour: function (productId, colourCode, sizeCode) { 887 // var url = "index.cfm?action=cart_ajax_selectsize" 888 var url = "index.cfm?action=gdcdata.CartActions.ActAjaxSelectSize" + "&newSelect=" + 1 + "&productId=" + escape(productId) + "&subProductColourCode=" + escape(colourCode) + "&subProductSizeCode=" + escape(sizeCode); 889 $('#subProductSizeCode').val(''); 890 $.ajax({
891 url: url, 892 async: true, 893 success: Cart.SelectNewColour_onSuccess 894 }); 895 return false; 896 }, 897 SelectNewColour_onSuccess: function (t) { 898 z = $.parseJSON(t.replace(/\\'/g, "'")); 899 var outputRow = z.outputRow; 900 var productId = z.productId; 901 var colourCode = z.subProductColourCode; 902 var sizeCode = z.subProductSizeCode; 903 $('#selectColourList').html(outputRow); 904 Cart.SelectColour(productId, colourCode, sizeCode); 905 return false; 906 }, 907 SelectColour: function (productId, colourCode, sizeCode) { 908 $('li.subProductColours').each(function (i, s) { 909 $(s).removeClass("sel"); 910 }); 911 $('#subProductColour_' + colourCode).addClass("sel"); 912 $('#subProductColourCode').val(colourCode); //$('subProductColourCodeDisplay').innerHTML = colourCode; 913 // var url = "index.cfm?action=cart_ajax_selectcolour" 914 915 var url = "index.cfm?action=gdcdata.CartActions.ActAjaxSelectColour" + "&productId=" + escape(productId) + "&subProductColourCode=" + escape(colourCode) + "&subProductSizeCode=" + escape(sizeCode); 916 $.ajax({
917 url: url, 918 async: true, 919 success: Cart.SelectColour_onSuccess 920 }); 921 return false; 922 }, 923 SelectColour_onSuccess: function (t) { 924 z = $.parseJSON(t.replace(/\\'/g, "'")); 925 var outputRow = z.outputRow; 926 $('#selectSizeList').html(outputRow); 927 return false; 928 }, 929 SuideGuidePopup: function (productSizeGuideId) { 930 // var url = "pages/actions/act_cart_lightbox_sizeguide.cfm?productSizeGuideId="+productSizeGuideId; 931 var url = "index.cfm?action=gdcdata.CartActions.ActLightboxSizeguide&productSizeGuideId=" + productSizeGuideId; 932 $.fancybox({ 933 href: url, 934 type: 'ajax' 935 }); 936 }, 937 CheckInStore: function (productId) { 938 if ($("#subProductSizeCode").length > 0 && !$("#subProductSizeCode").val().length && $("#selectSizeList").find("li").length > 1 && $("#subProductColourCode").length > 0 && !$("#subProductColourCode").val().length && $("#selectColoursList").find("li").length > 1) { 939 nodalAlert("Please select a size and colour", 'warning'); 940 return false; 941 } else if ($("#subProductSizeCode").length > 0 && !$("#subProductSizeCode").val().length && $("#selectSizeList").find("li").length > 1) { 942 nodalAlert("Please select a size", 'warning'); 943 return false; 944 } else if ($("#subProductColourCode").length > 0 && !$("#subProductColourCode").val().length && $("#selectColoursList").find("li").length > 1) { 945 nodalAlert("Please select a colour", 'warning'); 946 return false; 947 } else if ($("#voucherPosCode").length > 0 && !$("#voucherPosCode").val().length && $("#selectVoucherList").find("li").length > 1) { 948 nodalAlert("Please select a gift amount", 'warning'); 949 return false; 950 } else if ($("#quickBuyPosCode").length > 0 && !$("#quickBuyPosCode").val().length && $("#selectQuickBuyList").find("li").length > 1) { 951 nodalAlert("Please select an amount", 'warning'); 952 return false; 953 } else if ($("#storeId").length > 0 && $("#storeId").val() == 0) { 954 nodalAlert("Please select a store", 'warning'); 955 return false; 956 } else { 957 var url = "index.cfm?action=gdcdata.CartActions.ActLightboxCheckInStore"; 958 url += "&pid=" + escape(productId); 959 960 if ($("#storeId").length > 0 && $("#storeId").val().length > 0) { 961 url += "&storeId=" + $("#storeId").val(); 962 } 963 964 if ($("#voucherPosCode").length > 0 && $("#voucherPosCode").val().length > 0) { 965 url += "&voucherPosCode=" + $("#voucherPosCode").val(); 966 } 967 968 if ($("#quickBuyPosCode").length > 0 && $("#quickBuyPosCode").val().length > 0) { 969 url += "&quickBuyPosCode=" + $("#quickBuyPosCode").val(); 970 } 971 972 if ($("div.multiples").length > 0) { 973 url += "&groupedProducts="; 974 var itemSelected = false; 975 var delimiter = ""; 976 $(".multiples input.quantity.enabled").parent().parent().find("input.productId").each(function (i, s) { 977 url += escape(delimiter + $(s).val()); 978 delimiter = ","; 979 }); 980 } 981 982 if ($("#subProductSizeCode").length > 0 && $("#subProductSizeCode").val().length) { 983 url += "&sizeCode=" + $("#subProductSizeCode").val(); 984 } 985 986 if ($("#subProductColourCode").length > 0 && $("#subProductColourCode").val().length) { 987 url += "&colourCode=" + $("subProductColourCode").val(); 988 } 989 990 $.fancybox({ 991 href: url, 992 type: 'ajax' 993 }); 994 } 995 }, 996 AddToCart: function (productId, orderItemQuantity) { 997 var discountId = ''; 998 var freeProductId = ''; 999 var productTagIds = ''; 1000 var productTagAdditionalPrices = ''; 1001 var productTagSelected = 1; 1002 var delimiter = ''; 1003 var productTagTypeAlert = 'Please select'; 1004 1005 if ($("#productTypeId")) { 1006 var productTypeId = $("#productTypeId").val(); 1007 } else { 1008 var productTypeId = 1; 1009 } 1010 1011 $('ul.productTagTypeIdLists').each(function (i, s) { 1012 var productTagTypeId = $(s).attr('id').replace('productTagTypeIdList-', ''); 1013 var productTagTypeName = $("#productTagTypeName-" + productTagTypeId).val(); 1014 1015 if (!$("#productTagTypeId-" + productTagTypeId).val().length) { 1016 if (delimiter == ',') { 1017 productTagTypeAlert = productTagTypeAlert + " and a " + productTagTypeName; 1018 } else { 1019 productTagTypeAlert = productTagTypeAlert + " a " + productTagTypeName; 1020 } 1021 1022 productTagSelected = 0; 1023 } else { 1024 productTagIds = productTagIds + delimiter + $("#productTagTypeId-" + productTagTypeId).val(); 1025 productTagAdditionalPrices = productTagAdditionalPrices + delimiter + $("#productTagTypeAdditionalPrice-" + productTagTypeId).val(); 1026 } 1027 1028 delimiter = ','; 1029 });
1030 1031 if (orderItemQuantity == undefined) { 1032 if ($("#orderItemQuantity-" + productId).length > 0) { 1033 var orderItemQuantity = $("#orderItemQuantity-" + productId).val(); 1034 } else { 1035 var orderItemQuantity = 1; 1036 } 1037 } // var url = "index.cfm?action=cart_ajax_addtocart"; 1038 1039 1040 var url = "index.cfm?action=gdcdata.cartactions.ActAjaxAddToCart"; 1041 url += "&pid=" + escape(productId); 1042 url += "&productTypeId=" + escape(productTypeId); 1043 url += "&orderItemQuantity=" + escape(orderItemQuantity); 1044 1045 if ($("#additionalJSFunction").length > 0) { 1046 eval($("#additionalJSFunction").val()); 1047 return false; 1048 } else { 1049 if (productTypeId == 2) { 1050 if ($("#subProductSizeCode").length > 0 && !$("#subProductSizeCode").val().length && $("#selectSizeList").find("li").length > 1 && $("#subProductColourCode").length > 0 && !$("#subProductColourCode").val().length && $("#selectColoursList").find("li").length > 1) { 1051 nodalAlert("Please select a size and colour", 'warning'); 1052 return false; 1053 } else if ($("#subProductSizeCode").length > 0 && !$("#subProductSizeCode").val().length && $("#selectSizeList").find("li").length > 1) { 1054 nodalAlert("Please select a size", 'warning'); 1055 return false; 1056 } else if ($("#subProductColourCode").length > 0 && !$("#subProductColourCode").val().length && $("#selectColoursList").find("li").length > 1) { 1057 nodalAlert("Please select a colour", 'warning'); 1058 return false; 1059 } 1060 } 1061 1062 if (productTypeId == 5 || productTypeId == 6) { 1063 if ($("#voucherPosCode").length > 0 && !$("#voucherPosCode").val().length && $("#selectVoucherList").find("li").length > 1) { 1064 nodalAlert("Please select a gift amount", 'warning'); 1065 return false; 1066 } 1067 } 1068 1069 if (productTypeId == 7) { 1070 if ($("#quickBuyPosCode").length > 0 && !$("#quickBuyPosCode").val().length && $("#selectQuickBuyList").find("li").length > 1) { 1071 nodalAlert("Please select an amount", 'warning'); 1072 return false; 1073 } 1074 } 1075 1076 if (productTypeId == 8) { 1077 if ($("#productPrice").length > 0 && !$("#productPrice").val().length) { 1078 nodalAlert("Please enter an amount", 'warning'); 1079 return false; 1080 } 1081 } 1082 1083 if (productTagSelected == 0) { 1084 nodalAlert(productTagTypeAlert, 'warning'); 1085 return false; 1086 } 1087 1088 if ($("#addToCartButton-" + productId).length > 0) { 1089 $("#addToCartButton-" + productId).css("disabled", "true"); 1090 } 1091 1092 if (productTypeId == 5 || productTypeId == 6) { 1093 if ($("#voucherPosCode").length > 0 && $("#voucherPosCode").val().length > 0) { 1094 url += "&voucherPosCode=" + $("#voucherPosCode").val(); 1095 1096 if ($("#voucherSendersName").length > 0 && !$("#voucherSendersName").val().length) { 1097 Cart.HighlightAndFocus("#voucherSendersName"); 1098 return false; 1099 } else { 1100 url += "&voucherSendersName=" + $("#voucherSendersName").val(); 1101 } 1102 1103 if ($("#voucherRecipientsName").length > 0 && !$("#voucherRecipientsName").val().length) { 1104 Cart.HighlightAndFocus("#voucherRecipientsName"); 1105 return false; 1106 } else { 1107 url += "&voucherRecipientsName=" + $("#voucherRecipientsName").val(); 1108 } 1109 1110 if ($("#voucherSendersEmail").val().isEmpty() || $("#voucherSendersEmail").val().indexOf("@") == -1 || $("#voucherSendersEmail").val().indexOf(".") == -1) { 1111 Cart.HighlightAndFocus("#voucherSendersEmail"); 1112 return false; 1113 } else { 1114 url += "&voucherSendersEmail=" + $("#voucherSendersEmail").val(); 1115 } 1116 1117 if ($("#voucherRecipientsEmail").val().isEmpty() || $("#voucherRecipientsEmail").val().indexOf("@") == -1 || $("#voucherRecipientsEmail").val().indexOf(".") == -1) { 1118 Cart.HighlightAndFocus("#voucherRecipientsEmail"); 1119 return false; 1120 } else { 1121 url += "&voucherRecipientsEmail=" + $("#voucherRecipientsEmail").val(); 1122 } 1123 1124 if ($("#voucherNote").length > 0 && $("#voucherNote").val().length) { 1125 url += "&voucherNote=" + $("#voucherNote").val(); 1126 } 1127 } 1128 } 1129 1130 if (productTypeId == 7) { 1131 if ($("#quickBuyPosCode").length > 0 && $("#quickBuyPosCode").val().length > 0) { 1132 url += "&quickBuyPosCode=" + $("#quickBuyPosCode").val(); 1133 } 1134 } 1135 1136 if (productTypeId == 8) { 1137 if ($("#productPrice").length > 0 && $("#productPrice").val().length > 0) {
1138 url += "&productPrice=" + $("#productPrice").val(); 1139 } 1140 } 1141 1142 if (productTypeId == 2) { 1143 if ($("#subProductSizeCode").length > 0 && $("#subProductSizeCode").val().length) { 1144 url += "&sizeCode=" + $("#subProductSizeCode").val(); 1145 } 1146 1147 if ($("#subProductColourCode").length > 0 && $("#subProductColourCode").val().length) { 1148 url += "&colourCode=" + $("#subProductColourCode").val(); 1149 } 1150 } 1151 1152 if (productTypeId == 3) { 1153 if ($("div.multiples").length > 0) { 1154 url += "&groupedProducts="; 1155 var itemSelected = false; 1156 var delimiter = ""; 1157 1158 for (i = 0; i < $(".multiples input.quantity.enabled").length; i++) { 1159 if (parseInt($(".multiples input.quantity.enabled").eq(i).val()) > 0) { 1160 itemSelected = true; 1161 url += escape(delimiter + $(".multiples input.quantity.enabled").eq(i).val() + "-" + $(".multiples input.quantity.enabled:eq(" + i + ")").parents(".item").find("input.productId").eq(0).val()); 1162 delimiter = ","; 1163 } 1164 } 1165 1166 if (!itemSelected) { 1167 nodalAlert("Please select an item.", 'warning'); 1168 return false; 1169 } 1170 } 1171 } 1172 1173 if ($("#productPersonalizedName").length > 0) { 1174 url += "&personalisedText=" + escape($("#productPersonalizedName").val()); 1175 1176 if ($("#productPersonalizedName").val() == "") { 1177 nodalAlert("Please enter your personalised text for this item", 'warning'); 1178 return false; 1179 } 1180 } 1181 1182 if (productTagIds.length) { 1183 url += "&productTagIds=" + productTagIds; 1184 } 1185 1186 if ($("#discountId").length > 0 && $("#discountId").val() > 0) { 1187 url += "&discountId=" + $("#discountId").val(); 1188 } 1189 1190 if ($("#freeProductId").length > 0 && $("#freeProductId").val() > 0) { 1191 url += "&freeProductId=" + $("#freeProductId").val(); 1192 } 1193 1194 if (productTagAdditionalPrices.length) { 1195 url += "&productTagAdditionalPrices=" + productTagAdditionalPrices; 1196 } //Change Display 1197 1198 1199 $.ajax({
1200 url: url, 1201 async: true, 1202 success: function (t) { 1203 if (isNaN(parseInt(t))) { 1204 nodalAlert(t, 'warning'); 1205 } 1206 1207 Cart.RefreshMiniCart(t.trim()); 1208 return false; 1209 } 1210 }); 1211 } 1212 }, 1213 AddToWishlist: function (productId, userId, el) { 1214 if (userId == 0) { 1215 nodalAlert("You must log in to add an item to your Wishlist", 'warning'); 1216 } else { 1217 // var url="index.cfm?action=cart_ajax_addtowishlist&pid=" + productId; 1218 var url = "index.cfm?action=gdcdata.CartActions.ActAjaxAddToWishlist&pid=" + productId; 1219 $.ajax({ 1220 url: url, 1221 async: true, 1222 success: function () { 1223 $(el).html("Added to Wishlist"); 1224 $(el).removeClass("notAdded"); 1225 $(el).addClass("added"); 1226 $(el).removeAttr("onclick"); 1227 $(el).attr("href", "index.cfm/page/cart_myWishlist"); 1228 } 1229 }); 1230 } 1231 }, 1232 RemoveFromWishlist: function (el, productId, userId) { 1233 if (confirm("Are you sure you want to remove this item from your wish list?")) { 1234 // var url="index.cfm?action=cart_ajax_removefromwishlist&pid=" + productId; 1235 var url = "index.cfm?action=gdcdata.CartActions.ActAjaxRemoveFromWishlist&pid=" + productId; 1236 $.ajax({
1237 url: url, 1238 async: true, 1239 success: function () { 1240 if ($("#productsListing").attr("class") == "list") { 1241 $(el).parent().css('height', "0px"); 1242 } else { 1243 $(el).parent().css('opacity', "0"); 1244 } 1245 1246 setTimeout(function () { 1247 $(el).parent().remove(); 1248 1249 if ($("#productsListing li").length == 0) { 1250 $(".copy:eq(0)").html("<p>Your Wishlist is currently empty.</p>"); 1251 } 1252 }, 250); 1253 } 1254 }); 1255 } 1256 }, 1257 RefreshMiniCart: function (shoppingCartItemId) { 1258 // var url="index.cfm?action=Cart_miniCart&ajax"; 1259 var currentDate = new Date().getTime(); 1260 var url = "index.cfm?action=gdcdata.CartActions.ActMinicart&ajax=Yes&time=" + currentDate; 1261 var noShow = noShow; 1262 $.ajax({ 1263 url: url, 1264 async: true, 1265 error: function (t) {}, 1266 success: function (t) { 1267 z = $.parseJSON(t.replace(/\\'/g, "'")); 1268 $("#miniCart").html(z.outputHtml); 1269 $("#cartSize").html(z.cartSize); 1270 $("#cartSize").fadeOut(); 1271 $("#cartSize").css('margin-top', '-100px'); 1272 $("#cartSize").fadeIn(); 1273 $("#cartSize").animate({ 1274 'marginTop': '0' 1275 }, 1000); 1276 1277 if (!isNaN(parseFloat(shoppingCartItemId))) { 1278 $(".navcart").toggleClass("open"); 1279 $("#summaryProduct-" + shoppingCartItemId).effect("highlight", { 1280 color: "#C6EC6A" 1281 }, 2000); 1282 setTimeout(function () { 1283 $(".navcart").toggleClass("open"); 1284 }, 5000); 1285 } 1286 } 1287 }); 1288 }, 1289 FilterProducts: function (el, noRefresh) { 1290 if (el != 'undefined') { 1291 console.log(el); 1292 1293 if ($(el).parent().attr('class') == "sel") { 1294 $(el).parent().attr('class', ""); 1295 $(el).find('i').attr('class', "fa fa-square-o"); 1296 } else { 1297 //unselect all others 1298 $(el).parent().parent().find('li').attr('class', ""); 1299 $(el).parent().parent().find('li a i').attr('class', "fa fa-square-o"); //select current 1300 1301 $(el).parent().attr('class', "sel"); 1302 $(el).find('i').attr('class', "fa fa-square"); 1303 } 1304 } 1305 1306 var productTagFilterCount = 0; 1307 var productTagIdList = sizesList = coloursList = ""; 1308 var pageCount = Number($("#pageCount").val()); 1309 var totalProduct = Number($("#totalProduct").val()); 1310 var productTagDivName = ''; 1311 var delimiter = ""; 1312 $('div.productTagFilter').each(function (i, s) { 1313 productTagFilterCount = productTagFilterCount + 1; 1314 productTagDivName = $(s).attr('id'); 1315 $("#" + productTagDivName + " li.sel a").each(function (j, t) { 1316 productTagIdList += delimiter + $(t).attr("data-id"); 1317 delimiter = ","; 1318 }); 1319 }); 1320 1321 if ($("#sizesFilter")) { 1322 var selectedSizes = $("#sizesFilter li.sel a"); 1323 delimiter = ""; 1324 1325 for (i = 0; i < selectedSizes.length; i++) { 1326 sizesList += delimiter + selectedSizes[i].getAttribute("data-subProductSizeId"); 1327 delimiter = ","; 1328 } 1329 } 1330 1331 if ($("#coloursFilter")) { 1332 var selectedColours = $("#coloursFilter li.sel a"); 1333 delimiter = ""; 1334 1335 for (i = 0; i < selectedColours.length; i++) { 1336 coloursList += delimiter + selectedColours[i].getAttribute("data-subProductColour"); 1337 delimiter = ","; 1338 } 1339 } 1340 1341 if (noRefresh && noRefresh == 1) {} else { 1342 Cart.ResetProducts(); 1343 } 1344 1345 $("#filterLoading").css('display', "block"); 1346 minPriceVar = ""; 1347 maxPriceVar = ""; 1348 startProductVar = ""; 1349 endProductVar = ""; 1350 if ($("#minPrice")) minPriceVar = $("#minPrice").val(); 1351 if ($("#maxPrice")) maxPriceVar = $("#maxPrice").val(); 1352 if ($("#startProduct")) startProductVar = $("#startProduct").val(); 1353 if ($("#endProduct")) endProductVar = $("#endProduct").val(); // var url="index.cfm?action=cart_ajax_filterproducts"; 1354 1355 var query = $("#searchBoxSearch").val().trim(); 1356 1357 var url = "index.cfm?action=gdcdata.CartActions.ActAjaxFilterProducts"; //filterRequest.abort(); 1358 1359 filterRequest = $.ajax({
1360 url: url, 1361 async: true, 1362 method: "post", 1363 error: function (t, u, v) { 1364 console.log('filterproducts', t, u, v); 1365 }, 1366 success: function (r) { 1367 z = $.parseJSON(r.replace(/\\'/g, "'")); 1368 1369 if ($("#totalProductVal-Top").length > 0) { 1370 $("#pageCountVal-Top").html(z.pageCount); 1371 $("#pageCountVal-Bottom").html(z.pageCount); 1372 $("#pageCount").val(z.pageCount); 1373 $("#totalProductVal-Top").html(z.totalProduct); 1374 $("#totalProductVal-Bottom").html(z.totalProduct); 1375 $("#totalProduct").val(z.totalProduct); 1376 } //$("#productsListing").html(z.outputRows); 1377 1378 1379 $(".product-list").html(z.outputRows); 1380 $("#filterLoading").css('display', "none"); 1381 $("img.lazy").show().lazyload(); 1382 1383 if ($(".productFilter.notSort a.sel").length > 0 || $("#maxPrice").length > 0 && ($("#minPrice").val() != $("#originalMinPrice").val() || $("#maxPrice").val() != $("#originalMaxPrice").val())) { 1384 $("#clearFilters").css('display', "block"); 1385 } else { 1386 $("#clearFilters").css('display', "none"); 1387 } 1388 1389 defaultSortArray = []; 1390 1391 initListeners(); 1392 }, 1393 data: { 1394 productIdList: $("#productIdList").val(), 1395 sizes: sizesList, 1396 productTagIdList: productTagIdList, 1397 colours: coloursList, 1398 minPrice: minPriceVar, 1399 maxPrice: maxPriceVar, 1400 startProduct: startProductVar, 1401 endProduct: endProductVar, 1402 sortBy: $("#sortBy").val(), 1403 sortDir: $("#sortDir").val(), 1404 query: query 1405 } 1406 }); 1407 }, 1408 ResetProducts: function () { 1409 var productsPerPage = Number($("#productsPerPage").val()); 1410 var currentPage = Number($("#currentPage").val()); 1411 var pageCount = Number($("#pageCount").val()); 1412 var totalProduct = Number($("#totalProduct").val()); 1413 var startProduct = Number($("#startProduct").val()); 1414 var endProduct = Number($("#endProduct").val()); 1415 1416 if (totalProduct < productsPerPage) { 1417 endProduct = totalProduct; 1418 } else { 1419 endProduct = productsPerPage; 1420 } 1421 1422 if ($("#startProductVal-Top").length > 0) { 1423 $("#startProductVal-Top").html(1); 1424 $("#startProductVal-Bottom").html(1); 1425 $("#startProduct").val(1); 1426 $("#endProductVal-Top").html(endProduct); 1427 $("#endProductVal-Bottom").html(endProduct); 1428 $("#endProduct").val(endProduct); 1429 $("#currentPageVal-Top").html(1); 1430 $("#currentPageVal-Bottom").html(1); 1431 $("#currentPage").val(1); 1432 } 1433 }, 1434 SortProducts: function (sortBy, dir, el, refresh) { 1435 if (!dir) dir = 1; 1436 $("#sortFilter").find("li").each(function (i, t) { 1437 $(t).removeAttr("class"); 1438 $(t).find('i').attr('class', "fa fa-circle-o"); 1439 }); 1440 $("#sortFilter a").eq(el).parent().attr("class", "sel"); 1441 $("#sortFilter a").eq(el).find('i').attr('class', "fa fa-circle"); 1442 $(el).find('i').attr('class', "fa fa-circle"); 1443 $("#sortBy").val(sortBy); 1444 $("#sortDir").val(dir); 1445 $("#sortEl").val(el); 1446 $.ajax({
1447 // url:"index.cfm?action=Cart_Ajax_setProductSorting", 1448 url: "index.cfm?action=gdcdata.CartActions.ActAjaxSetProductSorting", 1449 method: "post", 1450 data: { 1451 sortBy: $("#sortBy").val(), 1452 sortDir: $("#sortDir").val(), 1453 sortEl: $("#sortEl").val() 1454 } 1455 }); 1456 Cart.FilterProducts('', 1); 1457 }, 1458 ClearFilters: function () { 1459 $(".productFilter a.sel").each(function (i, el) { 1460 $(el).attr('class', ""); 1461 }); //Unselect all filter options 1462 1463 $('div.productTagFilter').each(function (i, s) { 1464 productTagDivName = $(s).attr('id'); 1465 $("#" + productTagDivName + " li").each(function (j, t) { 1466 $(t).attr('class', ""); 1467 $(t).find('i').attr('class', "fa fa-square-o"); 1468 }); 1469 }); 1470 1471 if ($("#minPrice").length > 0) { 1472 $("#minPrice").val($("#originalMinPrice").val()); 1473 $("#maxPrice").val($("#originalMaxPrice").val()); 1474 $("#minPriceSlider").css('margin-left', "0px"); 1475 $("#maxPriceSlider").css('margin-left', priceSliderWidth + "px"); 1476 $("#minPriceIndicator").html($("#currencySymbol").val() + $("#originalMinPrice").val()); 1477 $("#maxPriceIndicator").html($("#currencySymbol").val() + $("#originalMaxPrice").val()); 1478 } 1479 1480 Cart.FilterProducts('', 1); 1481 }, 1482 UpdateShipping: function (shippingGroupId, countryId) { 1483 // var url = "index.cfm?action=Cart_UpdateShippingFromCart&shippingGroupId="+shippingGroupId+"&countryId="+countryId; 1484 var url = "index.cfm?action=Cart_UpdateShippingFromCart&shippingGroupId=" + shippingGroupId + "&countryId=" + countryId; 1485 $.ajax({
1486 url: url, 1487 async: true, 1488 success: Cart.UpdateShipping_onSuccess 1489 }); 1490 }, 1491 UpdateStateCode: function () { 1492 if ($("#userShippingCountryId option:selected").attr('data-countryisstaterequired') == 0) { 1493 $("#userShippingState").val('N/A'); 1494 } else { 1495 $("#userShippingState").val(''); 1496 } 1497 }, 1498 UpdateShipping_onSuccess: function (t) { 1499 z = $.parseJSON(t.replace(/\\'/g, "'")); 1500 Cart.RenderShoppingCart(z.mainContentHtml, z.rightSideContent); 1501 }, 1502 ChangeShippingAddress: function () { 1503 if ($("#shippingChooser").prop('checked')) { 1504 // var url = "index.cfm?action=Cart_ChangeShippingAddress"; 1505 var url = "index.cfm?action=gdcdata.CartActions.ActChangeShippingAddress"; 1506 $.ajax({ 1507 url: url, 1508 async: true, 1509 success: Cart.ChangeShippingAddress_onSuccess 1510 }); 1511 } else { 1512 $("#shippingAddressHolder").html(" "); 1513 $("#pp1").html(cShippingGroup); 1514 $("#pp2").html(cShippingCountry); 1515 $("#shippingCost").html(cShippingGroupPrice); 1516 Cart.AddGiftWrap(cTotal, cShippingGroupPrice, gwPrice); 1517 } 1518 }, 1519 ChangeShippingAddress_onSuccess: function (t) { 1520 z = $.parseJSON(t.replace(/\\'/g, "'")); 1521 $("#shippingAddressHolder").html(z.shippingAddressHTML); 1522 }, 1523 RemoveItem: function (shoppingCartItemId) { 1524 if (!confirm("Are you sure you want to remove this item from your bag?")) { 1525 return false; 1526 } else { 1527 var url = "index.cfm?action=gdcdata.CartActions.ActUpdateQTY&shoppingCartItemId=" + shoppingCartItemId + "&orderItemCount=0"; 1528 $.ajax({
1529 url: url, 1530 async: true, 1531 success: function (t) { 1532 z = $.parseJSON(t.replace(/\\'/g, "'")); 1533 Cart.RenderShoppingCart(z.mainContentHtml, z.rightSideContent); 1534 } 1535 }); 1536 } 1537 }, 1538 AddDiscount: function () { 1539 var discountCode = $("#discountCode").val(); 1540 $("#discountCode").val(''); 1541 1542 if (discountCode == '') { 1543 Cart.HighlightAndFocus("#discountCode"); 1544 return false; 1545 } 1546 1547 var url = "index.cfm?action=Cart_Ajax_AddDiscount&discountCode=" + escape(discountCode); 1548 $.ajax({ 1549 url: url, 1550 async: true, 1551 success: function (t) { 1552 z = $.parseJSON(t.replace(/\\'/g, "'")); 1553 1554 if (z.discountAddResult > 0) { 1555 nodalAlert('Discount code added!'); 1556 Cart.RenderShoppingCart(z.shoppingProductCartHTML, ''); 1557 } else if (z.discountAddResult == -1) { 1558 nodalAlert('That discount code does not exist.', 'warning'); 1559 } else if (z.discountAddResult == -2) { 1560 nodalAlert('That discount code has expired.', 'warning'); 1561 } else if (z.discountAddResult == -3) { 1562 nodalAlert('That discount code has been used up.', 'warning'); 1563 } else if (z.discountAddResult == -4) { 1564 nodalAlert('You have already added that discount code.', 'warning'); 1565 } else if (z.discountAddResult == -5) { 1566 nodalAlert('You have previously redeemed this discount code.', 'warning'); 1567 } else { 1568 nodalAlert('That discount code was not added.', 'warning'); 1569 } 1570 1571 return false; 1572 } 1573 }); 1574 }, 1575 UpdateCartQuantity: function (shoppingCartItemId, sign) { 1576 if (sign == "+") { 1577 var orderItemCount = parseInt($("#productStockLevel-" + shoppingCartItemId).val()) + 1; 1578 } else if (sign == "-") { 1579 var orderItemCount = parseInt($("#productStockLevel-" + shoppingCartItemId).val()) - 1; 1580 } else { 1581 var orderItemCount = $("#productStockLevel-" + shoppingCartItemId).val(); 1582 } 1583 1584 $("#productStockLevel-" + shoppingCartItemId).val(orderItemCount); 1585 var orderItemQuantity = $("#productStockLevel-" + shoppingCartItemId).find('option:selected').attr("data-orderitemquantity"); 1586 var updateQty = false; 1587 1588 if (orderItemCount == 0) { 1589 if (confirm("Are you sure you wish to remove this item from your shopping basket?")) { 1590 updateQty = true; 1591 } else { 1592 $("#productStockLevel-" + shoppingCartItemId).val(orderItemQuantity); 1593 } 1594 } else { 1595 updateQty = true; 1596 } 1597 1598 if (updateQty) { 1599 var url = "index.cfm?action=gdcdata.CartActions.ActUpdateQTY&shoppingCartItemId=" + shoppingCartItemId + "&orderItemCount=" + orderItemCount; 1600 $.ajax({
1601 url: url, 1602 async: true, 1603 success: function (t) { 1604 z = $.parseJSON(t.replace(/\\'/g, "'")); 1605 Cart.RenderShoppingCart(z.mainContentHtml, z.rightSideContent); 1606 } 1607 }); 1608 } 1609 }, 1610 EmptyCart: function () { 1611 var confirmation = confirm("Are you sure you wish to remove all items from your shopping basket?"); 1612 1613 if (confirmation) { 1614 // var url = "index.cfm?action=Cart_Empty"; 1615 var url = "index.cfm?action=gdcdata.CartActions.ActEmpty"; 1616 $.ajax({ 1617 url: url, 1618 async: true, 1619 success: function (t) { 1620 z = $.parseJSON(t.replace(/\\'/g, "'")); 1621 nodalAlert('Your bag has now been emptied and you can continue to use the system.'); 1622 Cart.RefreshMiniCart(); 1623 } 1624 }); 1625 } 1626 1627 return false; 1628 }, 1629 RenderShoppingCart: function (mainContentHtml, rightSideContent) { 1630 if (mainContentHtml.length > 0) { 1631 $("#shoppingProductCartHolder").html(mainContentHtml); 1632 } 1633 1634 if (rightSideContent.length > 0) { 1635 $("#shoppingTotalCartHolder").html(rightSideContent); 1636 } 1637 1638 Cart.RefreshMiniCart(); //myLightbox = new Lightbox(); 1639 }, 1640 Checkout: function (baseHref) { 1641 if ($("#isDeliverable").val() == 1 && $("#shippingGroupId").val() == -1) { 1642 nodalAlert("Please choose a delivery option first", 'warning'); 1643 } else { 1644 document.location = baseHref + "index.cfm?page=cart_checkout"; 1645 } 1646 }, 1647 ProcessCustomCheckout: function () { 1648 if ($("#customOrderUserFirstName").val().isEmpty()) { 1649 Cart.HighlightAndFocus("#customOrderUserFirstName"); 1650 return false; 1651 } 1652 1653 ; 1654 1655 if ($("#customOrderUserLastName").val().isEmpty()) { 1656 Cart.HighlightAndFocus("#customOrderUserLastName"); 1657 return false; 1658 } 1659 1660 ; 1661 1662 if ($("#customOrderUserEmail").val().isEmpty() || !$("#customOrderUserEmail").val().isEmail()) { 1663 nodalAlert("That is not a valid email address.", 'warning'); 1664 Cart.HighlightAndFocus("#customOrderUserEmail"); 1665 return false; 1666 } 1667 1668 ; 1669 1670 if ($("#customOrderUserAddress1").val().isEmpty()) { 1671 Cart.HighlightAndFocus("#customOrderUserAddress1"); 1672 return false; 1673 } 1674 1675 ; 1676 1677 if ($("#customOrderUserCity").val().isEmpty()) { 1678 Cart.HighlightAndFocus("#customOrderUserCity"); 1679 return false; 1680 } 1681 1682 ; 1683 1684 if ($("#customOrderUserPhone").val().isEmpty()) { 1685 Cart.HighlightAndFocus("#customOrderUserPhone"); 1686 return false; 1687 } 1688 1689 ; 1690 1691 if ($("#customOrderUserPhone").val().isEmpty()) { 1692 Cart.HighlightAndFocus("#customOrderUserPhone"); 1693 return false; 1694 } 1695 1696 ; 1697 $("#ccNumber").val($("#ccNumber").val().replace(/ /g, '')); 1698 cCardValidated = Cart.CheckCardNumber(true); 1699 cCardExpired = Cart.CheckCardExpiry(); 1700 1701 if (!cCardValidated || cCardExpired) { 1702 nodalAlert("You must enter valid credit card details.", 'warning'); 1703 return false; 1704 } 1705 1706 if ($("#CVVNumber").val().replace(/ /g, "") == "") { 1707 Cart.HighlightAndFocus("#CVVNumber"); 1708 return false; 1709 } 1710 1711 if ($("#cardholderName").val().replace(/ /g, "") == "") { 1712 Cart.HighlightAndFocus("#cardholderName"); 1713 return false; 1714 } 1715 1716 if (!$("#termsAndConditions").prop('checked')) { 1717 nodalAlert("You must agree to the terms and conditions to continue.", 'warning'); 1718 } else if (confirm("Are you absolutely sure you want to confirm this order?")) { 1719 $("#confirmOrder").css("display", "none"); 1720 $("#orderProcessing").css("display", "inline-block"); 1721 $("#clickGuard").css("display", "block"); 1722 $("body").css("pointer-events", "none"); // url = "index.cfm?action=Cart_CreateCustomOrder"; 1723 1724 url = "index.cfm?action=gdcdata.CartActions.ActCreateCustomOrder"; 1725 $.ajax({
1726 url: url, 1727 success: function (r) { 1728 $("#clickGuard").css("display", "none"); 1729 $("body").css("pointer-events", "auto"); 1730 1731 if (parseInt(r) == 12345) { 1732 iframeUrl = r.split("|")[1]; 1733 $.fancybox({ 1734 href: iframeUrl, 1735 type: 'iframe', 1736 closeBtn: false, 1737 closeClick: false, 1738 helpers: { 1739 overlay: { 1740 closeClick: false 1741 } // prevents closing when clicking OUTSIDE fancybox 1742 1743 }, 1744 keys: { 1745 close: null 1746 } // prevents close when clicking escape button 1747 1748 }); // $("#threeDSecure").css("display","block"); 1749 // $("#threeDSecure").find("iframe").eq(0).src = iframeUrl; 1750 } else if (parseInt(r) == 2) { 1751 window.location = siteUrl + "cart_customorderthanks"; 1752 } else if (parseInt(r) == 1) { 1753 window.location = siteUrl + "cart_customorderthanks"; 1754 } else if (parseInt(r) == -1) { 1755 window.location = siteUrl + "cart_shoppingCart"; 1756 } else { 1757 nodalAlert(r, 'warning', "Something went wrong"); 1758 $("#confirmOrder").css("display", "inline-block"); 1759 $("#orderProcessing").css("display", "none"); 1760 } 1761 }, 1762 data: $("#paymentForm").serialize(), 1763 method: "post" 1764 }); 1765 } 1766 1767 return false; 1768 }, 1769 HighlightAndFocus: function (id, divname, message) { 1770 $(id).effect("highlight", { 1771 color: "#FFB8B8" 1772 }, 2000); 1773 $(id).focus(); 1774 1775 if (divname != undefined) { 1776 if ($(divname).length == 0) { 1777 $(id).parent().append("<div class='errorMessage' id='" + divname.replace('#', '') + "'></div>"); 1778 } 1779 1780 $(divname).show(); 1781 if (message != undefined) $(divname).html(message); 1782 } 1783 }, 1784 ClearHighlighted: function (divname, removeDiv) { 1785 if ($(divname).length > 0) { 1786 $(divname).hide(); 1787 1788 if (removeDiv != undefined && removeDiv == true) { 1789 $(divname).remove(); 1790 } 1791 } 1792 }, 1793 scorePassword: function (pass) { 1794 var score = 0; 1795 if (!pass) return score; // award every unique letter until 5 repetitions 1796 1797 var letters = new Object(); 1798 1799 for (var i = 0; i < pass.length; i++) { 1800 letters[pass[i]] = (letters[pass[i]] || 0) + 1; 1801 score += 5.0 / letters[pass[i]]; 1802 } // bonus points for mixing it up 1803 1804 1805 var variations = { 1806 digits: /\d/.test(pass), 1807 lower: /[a-z]/.test(pass), 1808 upper: /[A-Z]/.test(pass), 1809 nonWords: /\W/.test(pass) 1810 }; 1811 variationCount = 0; 1812 1813 for (var check in variations) { 1814 variationCount += variations[check] == true ? 1 : 0; 1815 } 1816 1817 score += (variationCount - 1) * 10; 1818 return parseInt(score); 1819 }, 1820 checkPassStrength: function (pass) { 1821 var returnObj = { 1822 message: "", 1823 messageClass: "" 1824 }; 1825 var score = Cart.scorePassword(pass); 1826 1827 if (score > 80) { 1828 returnObj.message = "Strong"; 1829 returnObj.messageClass = "strong"; 1830 } else if (score > 60) { 1831 returnObj.message = "Good"; 1832 returnObj.messageClass = "good"; 1833 } else if (score <= 60 && score > 0) { 1834 returnObj.message = "Weak"; 1835 returnObj.messageClass = "weak"; 1836 } 1837 1838 return returnObj; 1839 }, 1840 ValidateAccountForm: function () { 1841 if ($("#userCountryId").val().isEmpty()) { 1842 nodalAlert('This is a required field.'); 1843 Cart.HighlightAndFocus("#userCountryId"); 1844 return false; 1845 } 1846 1847 if ($("#userFirstName").val().isEmpty()) { 1848 nodalAlert('This is a required field.'); 1849 Cart.HighlightAndFocus("#userFirstName"); 1850 return false; 1851 } 1852 1853 if ($("#userLastName").val().isEmpty()) { 1854 nodalAlert('This is a required field.'); 1855 Cart.HighlightAndFocus("#userLastName"); 1856 return false; 1857 } 1858 1859 if ($("#userPhone").val().isEmpty()) { 1860 nodalAlert('This is a required field.'); 1861 Cart.HighlightAndFocus("#userPhone"); 1862 return false; 1863 } 1864 1865 if ($("#userAddress1").val().isEmpty()) { 1866 nodalAlert('This is a required field.'); 1867 Cart.HighlightAndFocus("#userAddress1"); 1868 return false; 1869 } 1870 1871 if ($("#userCity").val().isEmpty()) { 1872 nodalAlert('This is a required field.'); 1873 Cart.HighlightAndFocus("#userCity"); 1874 return false; 1875 } 1876 1877 if ($("#userState").val().isEmpty()) { 1878 Cart.HighlightAndFocus("#userState"); 1879 return false; 1880 } 1881 1882 if ($("#userPostalCode").val().isEmpty() && $("#userCountryId").find('option:selected').attr('data-countryIsZipRequired') == 1) { 1883 Cart.HighlightAndFocus("#userPostalCode"); 1884 return false; 1885 } 1886 1887 if ($("#changePassword").prop('checked')) { 1888 if ($("#userPassword").val().isEmpty()) { 1889 Cart.HighlightAndFocus("#userPassword"); 1890 return false; 1891 } 1892 1893 if ($("#userPassword2").val().isEmpty()) { 1894 Cart.HighlightAndFocus("#userPassword2"); 1895 return false; 1896 } 1897 1898 if ($("#userPassword2").value != $("#userPassword").value) { 1899 Cart.HighlightAndFocus("#userPassword"); 1900 nodalAlert("Passwords do not match."); 1901 return false; 1902 } 1903 } 1904 1905 return true; 1906 }, 1907 ActivateClickAndCollect: function () { 1908 var url = "index.cfm?action=gdcdata.CartActions.ActAjaxActivateClickAndCollect"; 1909 $.ajax({
1910 url: url, 1911 method: "post", 1912 async: true, 1913 data: $("#ShippingAddressForm").serialize(), 1914 success: function (r) { 1915 if (parseInt(r) != 0) { 1916 $("#shippingDetails").html(r); 1917 $("#newDeliveryDetails").hide(); 1918 $("#DeliveryBtn").show(); 1919 $("#DeliveryBtn").removeClass('sel'); 1920 $("#ClickAndCollectBtn").addClass('sel'); 1921 $("#billingDetailsLegend1").html('Billing/Collection Details'); 1922 $("#billingDetailsLegend2").html('Billing/Collection Details'); 1923 $(".orderShipToBillingAddressLabel").hide(); 1924 $("#orderShipToBillingAddressCheck").prop('checked', false); 1925 Cart.ClearShippingAddress(); 1926 Cart.SelectShippingAddress(); 1927 } 1928 } 1929 }); 1930 return false; 1931 }, 1932 DeactivateClickAndCollect: function () { 1933 var url = "index.cfm?action=gdcdata.CartActions.ActAjaxDeactivateClickAndCollect"; 1934 $.ajax({ 1935 url: url, 1936 method: "post", 1937 async: true, 1938 data: $("#ShippingAddressForm").serialize(), 1939 success: function (r) { 1940 if (parseInt(r) != 0) { 1941 $("#shippingDetails").html(r); 1942 $("#newDeliveryDetails").show(); 1943 $("#DeliveryBtn").addClass('sel'); 1944 $("#ClickAndCollectBtn").removeClass('sel'); 1945 $("#billingDetailsLegend1").html('Billing Details'); 1946 $("#billingDetailsLegend2").html('Billing Details'); 1947 $(".orderShipToBillingAddressLabel").show(); 1948 $("#orderShipToBillingAddress").prop('checked', true); 1949 Cart.CopyShippingToBilling(); 1950 Cart.SelectShippingAddress(); 1951 } 1952 } 1953 }); 1954 return false; 1955 }, 1956 ValidateShippingAddress: function () { 1957 var check = 1; 1958 1959 if ($("#userShippingCountryId").val().isEmpty()) { 1960 Cart.HighlightAndFocus("#userShippingCountryId", "#errorMessage-userShippingCountryId", "This is a required field."); 1961 check = 0; 1962 } else if ($("#userShippingCountryId").val().isNotAddressSafe()) { 1963 Cart.HighlightAndFocus("#userShippingCountryId", "#errorMessage-userShippingCountryId", "This field can only contain alphanumerics and the following _-.()[],\"'&/#@+."); 1964 check = 0; 1965 } else { 1966 Cart.ClearHighlighted("#errorMessage-userShippingCountryId"); 1967 } 1968 1969 if ($("#userShippingFirstName").val().isEmpty()) { 1970 Cart.HighlightAndFocus("#userShippingFirstName", "#errorMessage-userShippingFirstName", "This is a required field."); 1971 check = 0; 1972 } else if ($("#userShippingFirstName").val().isNotAddressSafe()) { 1973 Cart.HighlightAndFocus("#userShippingFirstName", "#errorMessage-userShippingFirstName", "This field can only contain alphanumerics and the following _-.()[],\"'&/#@+."); 1974 check = 0; 1975 } else { 1976 Cart.ClearHighlighted("#errorMessage-userShippingFirstName"); 1977 } 1978 1979 if ($("#userShippingLastName").val().isEmpty()) { 1980 Cart.HighlightAndFocus("#userShippingLastName", "#errorMessage-userShippingLastName", "This is a required field."); 1981 check = 0; 1982 } else if ($("#userShippingLastName").val().isNotAddressSafe()) { 1983 Cart.HighlightAndFocus("#userShippingLastName", "#errorMessage-userShippingLastName", "This field can only contain alphanumerics and the following _-.()[],\"'&/#@+."); 1984 check = 0; 1985 } else { 1986 Cart.ClearHighlighted("#errorMessage-userShippingLastName"); 1987 } 1988 1989 if ($("#userShippingAddress1").val().isEmpty()) { 1990 Cart.HighlightAndFocus("#userShippingAddress1", "#errorMessage-userShippingAddress1", "This is a required field."); 1991 check = 0; 1992 } else if ($("#userShippingAddress1").val().isNotAddressSafe()) { 1993 Cart.HighlightAndFocus("#userShippingAddress1", "#errorMessage-userShippingAddress1", "This field can only contain alphanumerics and the following _-.()[],\"'&/#@+."); 1994 check = 0; 1995 } else { 1996 Cart.ClearHighlighted("#errorMessage-userShippingAddress1"); 1997 } 1998 1999 if (!$("#userShippingAddress2").val().isEmpty() && $("#userShippingAddress2").val().isNotAddressSafe()) { 2000 Cart.HighlightAndFocus("#userShippingAddress2", "#errorMessage-userShippingAddress2", "This field can only contain alphanumerics and the following _-.()[],\"'&/#@+."); 2001 check = 0; 2002 } else { 2003 Cart.ClearHighlighted("#errorMessage-userShippingAddress2"); 2004 } 2005 2006 if (!$("#userShippingAddress3").val().isEmpty() && $("#userShippingAddress3").val().isNotAddressSafe()) { 2007 Cart.HighlightAndFocus("#userShippingAddress3", "#errorMessage-userShippingAddress3", "This field can only contain alphanumerics and the following _-.()[],\"'&/#@+."); 2008 check = 0; 2009 } else { 2010 Cart.ClearHighlighted("#errorMessage-userShippingAddress3"); 2011 } 2012 2013 if ($("#userShippingCity").val().isEmpty()) { 2014 Cart.HighlightAndFocus("#userShippingCity", "#errorMessage-userShippingCity", "This is a required field."); 2015 check = 0; 2016 } else if ($("#userShippingCity").val().isNotAddressSafe()) { 2017 Cart.HighlightAndFocus("#userShippingCity", "#errorMessage-userShippingCity", "This field can only contain alphanumerics and the following _-.()[],\"'&/#@+."); 2018 check = 0; 2019 } else { 2020 Cart.ClearHighlighted("#errorMessage-userShippingCity"); 2021 } // if ($("#userShippingState").val().isEmpty()) { 2022 // Cart.HighlightAndFocus("#userShippingState", "#errorMessage-userShippingState", "This is a required field."); 2023 // check = 0; 2024 // } else if ($("#userShippingState").val().isNotAddressSafe()) { 2025 // Cart.HighlightAndFocus("#userShippingState", "#errorMessage-userShippingState", "This field can only contain alphanumerics and the following _-.()[],\"'&/#@+."); 2026 // check = 0; 2027 // } else { 2028 // Cart.ClearHighlighted("#errorMessage-userShippingState"); 2029 // } 2030 // if ( $("#userShippingPostalCode").val().isEmpty() && $("#userShippingCountryId").find('option:selected').attr('data-countryIsZipRequired') == 1 ) { 2031 // Cart.HighlightAndFocus("#userShippingPostalCode", "#errorMessage-userShippingPostalCode", "Please insert a valid Postal Code."); 2032 // check = 0; 2033 // } else if ( !$("#userShippingPostalCode").val().isEmpty() && $("#userShippingPostalCode").val().isNotAddressSafe()) { 2034 // Cart.HighlightAndFocus("#userShippingPostalCode", "#errorMessage-userShippingPostalCode", "This field can only contain alphanumerics and the following _-.()[],\"'&/#@+."); 2035 // check = 0; 2036 // } else { 2037 // Cart.ClearHighlighted("#errorMessage-userShippingPostalCode"); 2038 // } 2039 2040 2041 if ($("#userShippingTelephone").val().isEmpty()) { 2042 Cart.HighlightAndFocus("#userShippingTelephone", "#errorMessage-userShippingTelephone", "This is a required field."); 2043 check = 0; 2044 } else if (!isNumeric($("#userShippingTelephone").val())) { 2045 Cart.HighlightAndFocus("#userShippingTelephone", "#errorMessage-userShippingTelephone", "Please enter a valid Phone Number."); 2046 check = 0; 2047 } else if ($("#userShippingTelephone").val().isNotAddressSafe()) { 2048 Cart.HighlightAndFocus("#userShippingTelephone", "#errorMessage-userShippingTelephone", "This field can only contain alphanumerics and the following _-.()[],\"'&/#@+."); 2049 check = 0; 2050 } else { 2051 Cart.ClearHighlighted("#errorMessage-userShippingTelephone"); 2052 } 2053 2054 if (check == 1) { 2055 // var url = "index.cfm?action=cart_ajax_saveshippingdetails"; 2056 var url = "index.cfm?action=gdcdata.CartActions.ActAjaxSaveShippingDetails"; 2057 $.ajax({
2058 url: url, 2059 method: "post", 2060 async: true, 2061 data: $("#ShippingAddressForm").serialize(), 2062 success: function (r) { 2063 if (parseInt(r) != 0) { 2064 $("#shippingDetails").html(r); 2065 $("#newDeliveryDetails").hide(); 2066 Cart.SelectShippingAddress(); 2067 } 2068 } 2069 }); 2070 } 2071 2072 return false; 2073 }, 2074 GetShippingAddresses: function () { 2075 // var url="index.cfm?action=cart_ajax_getshippingaddresses"; 2076 var url = "index.cfm?action=gdcdata.CartActions.ActAjaxGetShippingDetails"; 2077 $.ajax({ 2078 url: url, 2079 async: true, 2080 success: function (r) { 2081 if (parseInt(r) != 0) { 2082 $("#shippingDetails").html(r); 2083 Cart.SelectShippingAddress(); 2084 } 2085 } 2086 }); 2087 }, 2088 ValidateShippingDetails: function () { 2089 var paymentMethodId = 0; 2090 $('input.paymentMethodIds').each(function (i, s) { 2091 if ($(s).prop('checked') == true) { 2092 paymentMethodId = $(s).val(); 2093 } 2094 }); 2095 2096 if (parseInt($("#userShippingId").val()) > 0) { 2097 var ShippingAddressFormVars = $("#ShippingAddressForm").serialize(); // $.ajax({ url:"index.cfm?action=cart_ajax_saveDeliveryNotes", type:"post", data:ajaxParams}); 2098 2099 $.ajax({
2100 url: "index.cfm?action=gdcdata.CartActions.ActAjaxSaveDeliveryNotes", 2101 type: "post", 2102 data: ShippingAddressFormVars 2103 }); 2104 2105 if (paymentMethodId == 6) { 2106 $('#userBillingPhone').val('000000000'); 2107 } 2108 2109 Cart.UpdateCheckoutStep(2); 2110 } else { 2111 nodalAlert("Please select a shipping address", 'warning'); 2112 } 2113 2114 return false; 2115 }, 2116 ValidateBillingDetails: function () {}, 2117 ValidatePaymentDetails: function () { 2118 var cCardExpired = false; 2119 var cCardValidated = true; 2120 var creditCardPayment = true; 2121 var paymentMethodId = 1; 2122 var paymentType = ''; 2123 var orderIsDeliverable = $('#paymentForm').find('input[name="orderIsDeliverable"]').val(); 2124 var orderIsTrade = $('#paymentForm').find('input[name="orderIsTrade"]').val(); 2125 var orderTotalAmount = parseFloat($('#orderTotalAmount').val()); 2126 var paymentMethodIdSelected = false; 2127 $('input.paymentMethodIds').each(function (i, s) { 2128 if ($(s).prop('checked') == true) { 2129 paymentMethodIdSelected = true; 2130 paymentMethodId = $(s).val(); 2131 paymentType = $(s).attr('data-cardtype'); 2132 } 2133 }); 2134 2135 if (!paymentMethodIdSelected) { 2136 Cart.HighlightAndFocus("#paymentMethodId-1"); 2137 return false; 2138 } 2139 2140 if (orderIsDeliverable == 'Yes') { 2141 if ($("#userBillingCountryId").val() < 1) { 2142 Cart.HighlightAndFocus("#userBillingCountryId"); 2143 Cart.UpdateCheckoutStep(2); 2144 $("#existingBillingDetails").hide(); 2145 $("#newBillingDetails").show(); 2146 return false; 2147 } 2148 2149 if ($("#userBillingFirstName").val().isEmpty()) { 2150 Cart.HighlightAndFocus("#userBillingFirstName"); 2151 Cart.UpdateCheckoutStep(2); 2152 $("#existingBillingDetails").hide(); 2153 $("#newBillingDetails").show(); 2154 return false; 2155 } else if ($("#userBillingFirstName").val().isNotAddressSafe()) { 2156 Cart.HighlightAndFocus("#userBillingFirstName"); 2157 Cart.UpdateCheckoutStep(2); 2158 $("#existingBillingDetails").hide(); 2159 $("#newBillingDetails").show(); 2160 return false; 2161 } 2162 2163 if ($("#userBillingLastName").val().isEmpty()) { 2164 Cart.HighlightAndFocus("#userBillingLastName"); 2165 Cart.UpdateCheckoutStep(2); 2166 $("#existingBillingDetails").hide(); 2167 $("#newBillingDetails").show(); 2168 return false; 2169 } else if ($("#userBillingFirstName").val().isNotAddressSafe()) { 2170 Cart.HighlightAndFocus("#userBillingFirstName"); 2171 Cart.UpdateCheckoutStep(2); 2172 $("#existingBillingDetails").hide(); 2173 $("#newBillingDetails").show(); 2174 return false; 2175 } 2176 2177 if ($("#userBillingAddressLine1").val().isEmpty()) { 2178 Cart.HighlightAndFocus("#userBillingAddressLine1"); 2179 Cart.UpdateCheckoutStep(2); 2180 $("#existingBillingDetails").hide(); 2181 $("#newBillingDetails").show(); 2182 return false; 2183 } else if ($("#userBillingAddressLine1").val().isNotAddressSafe()) { 2184 Cart.HighlightAndFocus("#userBillingAddressLine1"); 2185 Cart.UpdateCheckoutStep(2); 2186 $("#existingBillingDetails").hide(); 2187 $("#newBillingDetails").show(); 2188 return false; 2189 } 2190 2191 if (!$("#userBillingAddressLine2").val().isEmpty() && $("#userBillingAddressLine2").val().isNotAddressSafe()) { 2192 Cart.HighlightAndFocus("#userBillingAddressLine2"); 2193 Cart.UpdateCheckoutStep(2); 2194 $("#existingBillingDetails").hide(); 2195 $("#newBillingDetails").show(); 2196 return false; 2197 } 2198 2199 if (!$("#userBillingAddressLine3").val().isEmpty() && $("#userBillingAddressLine3").val().isNotAddressSafe()) { 2200 Cart.HighlightAndFocus("#userBillingAddressLine3"); 2201 Cart.UpdateCheckoutStep(2); 2202 $("#existingBillingDetails").hide(); 2203 $("#newBillingDetails").show(); 2204 return false; 2205 } 2206 2207 if ($("#userBillingCity").val().isEmpty()) { 2208 Cart.HighlightAndFocus("#userBillingCity"); 2209 Cart.UpdateCheckoutStep(2); 2210 $("#existingBillingDetails").hide(); 2211 $("#newBillingDetails").show(); 2212 return false; 2213 } else if ($("#userBillingCity").val().isNotAddressSafe()) { 2214 Cart.HighlightAndFocus("#userBillingCity"); 2215 Cart.UpdateCheckoutStep(2); 2216 $("#existingBillingDetails").hide(); 2217 $("#newBillingDetails").show(); 2218 return false; 2219 } 2220 2221 if ($("#userBillingState").val().isEmpty()) { 2222 Cart.HighlightAndFocus("#userBillingState"); 2223 Cart.UpdateCheckoutStep(2); 2224 $("#existingBillingDetails").hide(); 2225 $("#newBillingDetails").show(); 2226 return false; 2227 } else if ($("#userBillingState").val().isNotAddressSafe()) { 2228 Cart.HighlightAndFocus("#userBillingState"); 2229 Cart.UpdateCheckoutStep(2); 2230 $("#existingBillingDetails").hide(); 2231 $("#newBillingDetails").show(); 2232 return false; 2233 } 2234 2235 if ($("#userBillingPostalCode").val().isEmpty() && $("#userBillingCountryId").find('option:selected').attr('data-countryIsZipRequired') == 1) { 2236 Cart.HighlightAndFocus("#userBillingPostalCode"); 2237 Cart.UpdateCheckoutStep(2); 2238 $("#existingBillingDetails").hide(); 2239 $("#newBillingDetails").show(); 2240 return false; 2241 } else if (!$("#userBillingPostalCode").val().isEmpty() && $("#userBillingPostalCode").val().isNotAddressSafe()) { 2242 Cart.HighlightAndFocus("#userBillingPostalCode"); 2243 Cart.UpdateCheckoutStep(2); 2244 $("#existingBillingDetails").hide(); 2245 $("#newBillingDetails").show(); 2246 return false; 2247 } 2248 2249 if ($("#userBillingCountryId").val() == "-1") { 2250 Cart.HighlightAndFocus("#userBillingCountryId"); 2251 Cart.UpdateCheckoutStep(2); 2252 $("#existingBillingDetails").hide(); 2253 $("#newBillingDetails").show(); 2254 return false; 2255 } 2256 2257 if ($("#userBillingPhone").val().isEmpty()) { 2258 Cart.HighlightAndFocus("#userBillingPhone"); 2259 Cart.UpdateCheckoutStep(2); 2260 $("#existingBillingDetails").hide(); 2261 $("#newBillingDetails").show(); 2262 return false; 2263 } else if ($("#userBillingPhone").val().isNotAddressSafe()) { 2264 Cart.HighlightAndFocus("#userBillingPhone"); 2265 Cart.UpdateCheckoutStep(2); 2266 $("#existingBillingDetails").hide(); 2267 $("#newBillingDetails").show(); 2268 return false; 2269 } // if ($("#userBillingEmail").val().isEmpty() || !$("#userBillingEmail").val().isEmail()) { 2270 // Cart.HighlightAndFocus("#userBillingEmail"); 2271 // Cart.UpdateCheckoutStep(2); 2272 // $("#existingBillingDetails").hide(); 2273 // $("#newBillingDetails").show(); 2274 // return false; 2275 // } 2276 2277 } 2278 2279 url = "index.cfm?action=gdcdata.CartActions.ActAjaxSaveBillingDetails"; 2280 $.ajax({
2281 url: url, 2282 method: "post", 2283 success: function (r) { 2284 z = $.parseJSON(r.replace(/\\'/g, "'")); 2285 $("#billingDetailsContainer").html(z.billingAddressHtml); 2286 $("#billingDetailsConfirmationContainer").html(z.billingAddressHtml); 2287 }, 2288 data: $("#paymentForm").serialize() 2289 }); 2290 $("#ccNumber").val($("#ccNumber").val().replace(/ /g, '')); 2291 2292 if (orderTotalAmount > 0 && (paymentMethodId == 1 || paymentMethodId == 3 || paymentMethodId == 4)) { 2293 cCardValidated = Cart.CheckCardNumber(true); 2294 2295 if (!cCardValidated) { 2296 Cart.HighlightAndFocus("#ccNumber"); 2297 return false; 2298 } 2299 2300 cCardExpired = Cart.CheckCardExpiry(); 2301 2302 if (cCardExpired) { 2303 Cart.HighlightAndFocus("#expirationMonth"); 2304 Cart.HighlightAndFocus("#expirationYear"); 2305 return false; 2306 } 2307 2308 if ($("#cardholderName").val().replace(/ /g, "") == "") { 2309 Cart.HighlightAndFocus("#cardholderName"); 2310 return false; 2311 } 2312 2313 if ($("#CVVNumber").val().replace(/ /g, "") == "") { 2314 Cart.HighlightAndFocus("#CVVNumber"); 2315 return false; 2316 } 2317 } 2318 2319 $("#paymentDetailsConfirmationContainer").html('<p class="name">' + $("#cardholderName").val() + '</p><p class="creditcard"><span>' + paymentType.charAt(0).toUpperCase() + paymentType.slice(1) + '</span> xxxx xxxx xxxx ' + $("#ccNumber").val().slice(-4) + '</p>'); 2320 Cart.UpdateCheckoutStep(3); 2321 return false; 2322 }, 2323 ValidateDonateDetails: function () { 2324 var cCardExpired = false; 2325 var cCardValidated = true; 2326 var formValid = true; 2327 2328 if (isNaN(parseFloat($('#donationAmount').val())) || parseFloat($('#donationAmount').val()) < 1) { 2329 $("#donationAmount").effect("highlight", { 2330 color: "#C6EC6A" 2331 }, 2000); 2332 formValid = false; 2333 } 2334 2335 if ($('#donationName').val().length == 0) { 2336 $("#donationName").effect("highlight", { 2337 color: "#C6EC6A" 2338 }, 2000); 2339 formValid = false; 2340 } 2341 2342 if ($('#donationPhoneNumber').val().length == 0) { 2343 $("#donationPhoneNumber").effect("highlight", { 2344 color: "#C6EC6A" 2345 }, 2000); 2346 formValid = false; 2347 } 2348 2349 if ($('#donationFeedbackNote').val().length == 0) { 2350 $("#donationFeedbackNote").effect("highlight", { 2351 color: "#C6EC6A" 2352 }, 2000); 2353 formValid = false; 2354 } 2355 2356 if ($("#donationEmailAddress").val().isEmpty() || !$("#donationEmailAddress").val().isEmail()) { 2357 $("#donationEmailAddress").effect("highlight", { 2358 color: "#C6EC6A" 2359 }, 2000); 2360 formValid = false; 2361 } 2362 2363 $("#ccNumber").val($("#ccNumber").val().replace(/ /g, '')); 2364 cCardValidated = Cart.CheckCardNumber(false); 2365 2366 if (!cCardValidated) { 2367 $("#ccNumber").effect("highlight", { 2368 color: "#C6EC6A" 2369 }, 2000); 2370 formValid = false; 2371 } 2372 2373 cCardExpired = Cart.CheckCardExpiry(); 2374 2375 if (cCardExpired) { 2376 $("#expirationMonth").effect("highlight", { 2377 color: "#C6EC6A" 2378 }, 2000); 2379 $("#expirationYear").effect("highlight", { 2380 color: "#C6EC6A" 2381 }, 2000); 2382 formValid = false; 2383 } 2384 2385 if ($("#cardholderName").val().replace(/ /g, "") == "") { 2386 $("#cardholderName").effect("highlight", { 2387 color: "#C6EC6A" 2388 }, 2000); 2389 formValid = false; 2390 } 2391 2392 if ($("#CVVNumber").val().replace(/ /g, "") == "") { 2393 $("#CVVNumber").effect("highlight", { 2394 color: "#C6EC6A" 2395 }, 2000); 2396 formValid = false; 2397 } 2398 2399 if (formValid) { 2400 return true; 2401 } else { 2402 return false; 2403 } 2404 }, 2405 ProcessCheckout: function () { 2406 var paymentMethodId = 1; 2407 $('input.paymentMethodIds').each(function (i, s) { 2408 if ($(s).prop('checked') == true) { 2409 paymentMethodId = $(s).val(); 2410 } 2411 }); 2412 Cart.ValidatePaymentDetails(); 2413 $("#confirmOrder").html("Processing, please wait <i class='fa fa-spinner fa-spin'></i>"); 2414 $("#clickGuard").css("display", "block"); 2415 $("body").css("pointer-events", "none"); 2416 2417 if (paymentMethodId == 1 || paymentMethodId == 3 || paymentMethodId == 4 || paymentMethodId == 5 || paymentMethodId == 6) { 2418 url = "index.cfm?action=gdcdata.CartActions.ActCreateOrder"; 2419 2420 if (paymentMethodId == 5) { 2421 url = "index.cfm?action=gdcdata.CartActions.ActCreateInvoiceOrder"; 2422 } 2423 2424 $.ajax({
2425 url: url, 2426 data: $("#paymentForm").serialize(), 2427 method: "post", 2428 success: function (r) { 2429 $("#clickGuard").css("display", "none"); 2430 $("body").css("pointer-events", "auto"); 2431 2432 if (parseInt(r) == 12345) { 2433 iframeUrl = r.split("|")[1]; 2434 $.fancybox({ 2435 href: iframeUrl, 2436 type: 'iframe', 2437 closeBtn: false, 2438 closeClick: false, 2439 helpers: { 2440 overlay: { 2441 closeClick: false 2442 } // prevents closing when clicking OUTSIDE fancybox 2443 2444 }, 2445 keys: { 2446 close: null 2447 } // prevents close when clicking escape button 2448 2449 }); // $("#threeDSecure").css("display","block"); 2450 // $("#threeDSecure").find("iframe").eq(0).src = iframeUrl; 2451 } else if (parseInt(r) == 2) { 2452 window.location = siteUrl + "cart_orderthanks"; 2453 } else if (parseInt(r) == 1) { 2454 window.location = siteUrl + "cart_orderthanks"; 2455 } else if (parseInt(r) == -1) { 2456 window.location = siteUrl + "cart_shoppingCart"; 2457 } else { 2458 nodalAlert(r, 'warning', "Something went wrong"); 2459 $("#confirmOrder").html('Confirm Order Now <i class="fa fa-angle-right fa-1x"></i>'); 2460 } 2461 2462 return false; 2463 } 2464 }); 2465 } else { 2466 return true; 2467 } 2468 2469 return false; 2470 }, 2471 ShowPassword: function () { 2472 if ($("#changePassword").prop('checked')) { 2473 if ($("#passwordContent").css('display') == 'none') { 2474 $("#passwordContent").slideDown("slow"); 2475 } 2476 } else { 2477 $("#passwordContent").hide(); 2478 } 2479 }, 2480 ShowRegisterInterest: function () { 2481 if ($("#registerInterest").prop('checked')) { 2482 if ($("#registerInterestContent").css('display') == 'none') { 2483 $('input.userLocations').each(function (i, s) { 2484 userLocationId = $(s).attr('id'); //$(userLocationId).prop('checked', true); 2485 }); 2486 $("#registerInterestContent").slideDown("slow"); 2487 } 2488 } else { 2489 $("#registerInterestContent").hide(); 2490 } 2491 }, 2492 GenerateMessage: function (m) { 2493 if (!$("#message")) { 2494 $("div.copy").eq(0).prepend("<div onclick='Cart.HideMessage()' id='message' style='display:none'> </div>"); 2495 } 2496 2497 $("#message").html(m); 2498 $("#message").show(); 2499 }, 2500 HideMessage: function () { 2501 if ($("#message")) { 2502 $("#message").hide("puff", {}, 2000); 2503 } 2504 }, 2505 TogglePostCode: function (obj, list) { 2506 var cRequired = true; 2507 var nArray = list.split(","); 2508 var val = obj.options[obj.selectedIndex].val(); 2509 2510 for (i = 0; i < nArray.length; i++) { 2511 if (nArray[i] == val) { 2512 cRequired = false; 2513 break; 2514 } 2515 } 2516 2517 if (!cRequired) { 2518 $("#postCodeHolder").hide(); 2519 } else { 2520 $("#postCodeHolder").show(); 2521 } 2522 }, 2523 CloseLightBox: function () { 2524 $.fancybox.close(); 2525 }, 2526 ValidateCheckoutForm: function () { 2527 var validated = true; 2528 var cCardExpired = false; 2529 var cCardValidated = true; 2530 2531 if ($("#shippingFirstName").val().isEmpty()) { 2532 Cart.HighlightAndFocus("#shippingFirstName"); 2533 return false; 2534 } else if ($("#shippingLastName").val().isEmpty()) { 2535 Cart.HighlightAndFocus("#shippingLastName"); 2536 return false; 2537 } else if ($("#shippingAddress1").val().isEmpty()) { 2538 Cart.HighlightAndFocus("#shippingAddress1"); 2539 return false; 2540 } else if ($("#shippingAddress2").val().isEmpty()) { 2541 Cart.HighlightAndFocus("#shippingAddress2"); 2542 return false; 2543 } else if ($("#shippingCity").val().isEmpty()) { 2544 Cart.HighlightAndFocus("#shippingCity"); 2545 return false; 2546 } 2547 2548 if ($("#rb2").length > 0 && !$("#rb2").prop('checked')) { 2549 //This is an account checkout 2550 return true; 2551 } else { 2552 // This is a credit card checkout 2553 cCardValidated = Cart.CheckCardNumber(true); 2554 cCardExpired = Cart.CheckCardExpiry(); 2555 2556 if (cCardValidated && !cCardExpired) { 2557 return true; 2558 } else { 2559 return false; 2560 } 2561 } 2562 }, 2563 SelectPaymentMethod: function (paymentMethodId) { 2564 if (paymentMethodId == 1 || paymentMethodId == 3 || paymentMethodId == 4) { 2565 $("#creditcardContainer").show(); 2566 } else { 2567 $("#creditcardContainer").hide(); 2568 } 2569 }, 2570 CheckCardNumber: function (focusElement) {
2571 var validated = true; 2572 var ccNumber = $("#ccNumber").val(); 2573 var userCurrencyCode = $("#userCurrencyCode").val(); 2574 var ccType = ''; 2575 var paymentMethodId = 0; 2576 var billingDetails = $("#paymentForm").serialize(); 2577 2578 var repopulateBillingForm = function () { 2579 for (var key in billingDetails) { 2580 if (key != 'paymentMethodId' && key != 'userCurrencyCode') { 2581 $(key).val(billingDetails[key]); 2582 } 2583 } 2584 }; 2585 2586 if (CreditCard.IsLaser(ccNumber)) { 2587 ccType = "laser"; 2588 paymentMethodId = 2; 2589 } 2590 2591 if (CreditCard.IsVisa(ccNumber)) { 2592 ccType = "visa"; 2593 paymentMethodId = 1; 2594 } 2595 2596 if (CreditCard.IsMasterCard(ccNumber)) { 2597 ccType = "mastercard"; 2598 paymentMethodId = 3; 2599 } 2600 2601 if (CreditCard.IsAmericanExpress(ccNumber)) { 2602 ccType = "amex"; 2603 paymentMethodId = 4; 2604 } 2605 2606 if (ccType.length == 0) { 2607 if (focusElement) { 2608 Cart.HighlightAndFocus("#ccNumber"); 2609 } else { 2610 $("#ccNumber").effect("highlight", { 2611 color: "#C6EC6A" 2612 }, 1000); 2613 } 2614 2615 $("#ccError").html("Not a valid Credit Card number"); 2616 $("#ccError").show(); 2617 validated = false; 2618 } else { 2619 $(".paymentMethodIds[data-cardtype=" + ccType + "]").prop("checked", true); 2620 } 2621 2622 switch (ccType) { 2623 case "laser": 2624 if (!CreditCard.IsLaser(ccNumber)) { 2625 if (focusElement) { 2626 Cart.HighlightAndFocus("#ccNumber"); 2627 } else { 2628 $("#ccNumber").effect("highlight", { 2629 color: "#C6EC6A" 2630 }, 1000); 2631 } 2632 2633 $("#ccError").html("Not a valid Laser Card number"); 2634 $("#ccError").show(); 2635 validated = false; 2636 } else { 2637 $("#ccError").html(" "); 2638 $("#ccError").hide(); 2639 } 2640 2641 break; 2642 2643 case "visa": 2644 if (!CreditCard.IsVisa(ccNumber)) { 2645 if (focusElement) { 2646 Cart.HighlightAndFocus("#ccNumber"); 2647 } else { 2648 $("#ccNumber").effect("highlight", { 2649 color: "#C6EC6A" 2650 }, 1000); 2651 } 2652 2653 $("#ccError").html("Not a valid Visa Card number"); 2654 $("#ccError").show(); 2655 validated = false; 2656 } else { 2657 $("#ccError").html(" "); 2658 $("#ccError").hide(); 2659 } 2660 2661 break; 2662 2663 case "mastercard": 2664 if (!CreditCard.IsMasterCard(ccNumber)) { 2665 if (focusElement) { 2666 Cart.HighlightAndFocus("#ccNumber"); 2667 } else { 2668 $("#ccNumber").effect("highlight", { 2669 color: "#C6EC6A" 2670 }, 1000); 2671 } 2672 2673 $("#ccError").html("Not a valid Mastercard number"); 2674 $("#ccError").show(); 2675 validated = false; 2676 } else { 2677 $("#ccError").html(" "); 2678 $("#ccError").hide(); 2679 } 2680 2681 break; 2682 2683 case "amex": 2684 if (userCurrencyCode != 'EUR') { 2685 //Cart.ChangeCurrency('EUR'); 2686 // I've commented this out because we were loosing the paymentMethod selection and card number on page refresh 2687 var url = "index.cfm?action=gdcdata.CartActions.ActAjaxSetCurrency&code=EUR"; 2688 $.ajax({
2689 url: url, 2690 async: true 2691 }); 2692 Cart.RenderOrderSummary(); 2693 $(".currencyCodeDisplay").html('EUR <i class="fa fa-eur"></i>'); 2694 $("li.currency").removeClass().addClass("lev1 currency haschildren EUR"); 2695 } 2696 2697 if (!CreditCard.IsAmericanExpress(ccNumber)) { 2698 if (focusElement) { 2699 Cart.HighlightAndFocus("#ccNumber"); 2700 } else { 2701 $("#ccNumber").effect("highlight", { 2702 color: "#C6EC6A" 2703 }, 1000); 2704 } 2705 2706 $("#ccError").html("Invalid American Express number"); 2707 $("#ccError").show(); 2708 validated = false; 2709 } else { 2710 $("#ccError").html(" "); 2711 $("#ccError").hide(); 2712 } 2713 2714 break; 2715 } 2716 2717 return validated; 2718 }, 2719 CheckCardExpiry: function () { 2720 var cCardExpired = false; 2721 var now = new Date(); 2722 var expiryMonth = parseInt($("#expirationMonth").val()); 2723 var expiryYear = parseInt($("#expirationYear").val()); 2724 2725 if (expiryYear < now.getFullYear()) { 2726 cCardExpired = true; 2727 } else { 2728 if (expiryYear == now.getFullYear() && expiryMonth < now.getMonth()) { 2729 cCardExpired = true; 2730 } else { 2731 cCardExpired = false; 2732 } 2733 } 2734 2735 if (cCardExpired) { 2736 $("#edError").html("Your card has expired"); 2737 $("#edError").show(); 2738 validated = false; 2739 } else { 2740 validated = true; 2741 $("#edError").html(" "); 2742 $("#edError").hide(); 2743 } 2744 2745 return cCardExpired; 2746 }, 2747 ValidatePersonalisedForm: function (type) { 2748 if (type == "BIRTHDAY") { 2749 if ($("#pname").val().isEmpty()) { 2750 Cart.HighlightAndFocus("#pname"); 2751 return false; 2752 } 2753 2754 if ($("#pname2").val().isEmpty()) { 2755 Cart.HighlightAndFocus("#pname2"); 2756 return false; 2757 } 2758 2759 if ($("#pname2").val() != $("#pname").val()) { 2760 nodalAlert("Please make sure the Name field matches the Name Confirmation field", 'warning'); 2761 return false; 2762 } 2763 2764 if ($("#pdob").val().isEmpty()) { 2765 Cart.HighlightAndFocus("#pdob"); 2766 return false; 2767 } 2768 } else { 2769 if ($("#pname").val().isEmpty()) { 2770 Cart.HighlightAndFocus("#pname"); 2771 return false; 2772 } 2773 2774 if ($("#pname2").val().isEmpty()) { 2775 Cart.HighlightAndFocus("#pname2"); 2776 return false; 2777 } 2778 2779 if ($("#pname2").val() != $("#pname").val()) { 2780 nodalAlert("Please make sure the Name field matches the Name Confirmation field", 'warning'); 2781 return false; 2782 } 2783 2784 if ($("#pdate").val().isEmpty()) { 2785 Cart.HighlightAndFocus("#pdate"); 2786 return false; 2787 } 2788 2789 if ($("#pOccasion").val().isEmpty()) { 2790 Cart.HighlightAndFocus("#pOccasion"); 2791 return false; 2792 } 2793 } 2794 2795 $.ajax({
2796 url: 'index.cfm', 2797 method: "post", 2798 async: true, 2799 success: Cart.ValidatePersonalisedForm_onSuccess, 2800 data: $("#PersonalizeForm").serialize() 2801 }); 2802 return false; 2803 }, 2804 ValidatePersonalisedForm_onSuccess: function (t) { 2805 z = $.parseJSON(t.replace(/\\'/g, "'")); 2806 document.location = "index.cfm?page=" + z.targetPage; 2807 }, 2808 ShowChurchForm: function (targetURL) { 2809 var url = "index.cfm?action=Cart_ShowChurchForm&targetURL=" + targetURL; 2810 $.ajax({ 2811 url: url, 2812 async: true, 2813 success: Cart.ShowChurchForm_onSuccess 2814 }); 2815 }, 2816 ShowChurchForm_onSuccess: function (t) { 2817 z = $.parseJSON(t.replace(/\\'/g, "'")); 2818 $("#name").focus(); 2819 return false; 2820 }, 2821 ValidateChurchForm: function () { 2822 if ($("#name").val().isEmpty()) { 2823 Cart.HighlightAndFocus("#name"); 2824 return false; 2825 } else if ($("#confirmName").val().isEmpty()) { 2826 Cart.HighlightAndFocus("#confirmName"); 2827 return false; 2828 } else if ($("#name").val() != $("#confirmName").val()) { 2829 Cart.HighlightAndFocus("#name"); 2830 Cart.HighlightAndFocus("#confirmName"); 2831 return false; 2832 } else if ($("#occasion").val().isEmpty()) { 2833 Cart.HighlightAndFocus("#occasion"); 2834 return false; 2835 } else if ($("#date").val().isEmpty()) { 2836 Cart.HighlightAndFocus("#date"); 2837 return false; 2838 } else if ($("#confirmDate").val().isEmpty()) { 2839 Cart.HighlightAndFocus("#confirmDate"); 2840 return false; 2841 } else if ($("#date").val() != $("#confirmDate").val()) { 2842 Cart.HighlightAndFocus("#date"); 2843 Cart.HighlightAndFocus("#confirmDate"); 2844 return false; 2845 } 2846 2847 $.ajax({
2848 url: 'index.cfm', 2849 method: "post", 2850 async: true, 2851 success: Cart.ValidateChurchForm_onSuccess, 2852 data: $("#churchForm").serialize() 2853 }); 2854 return false; 2855 }, 2856 ValidateChurchForm_onSuccess: function (t) { 2857 z = $.parseJSON(t.replace(/\\'/g, "'")); 2858 document.location = "index.cfm?page=" + z.targetPage; 2859 }, 2860 UpdateCheckoutStep: function (step) { 2861 if (typeof _veroq != 'undefined') _veroq.push(['track', 'Checkout Step ' + step]); // $.ajax({ url:"index.cfm?action=cart_updatecheckoutstep&checkoutStep=" + step, async:true}); 2862 2863 var proceed = true; 2864 var paymentMethodId = 0; 2865 $('input.paymentMethodIds').each(function (i, s) { 2866 if ($(s).prop('checked') == true) { 2867 paymentMethodId = $(s).val(); 2868 } 2869 }); 2870 2871 if (step == 3) { 2872 if ($("#shippingDetailsConfirmationContainer").html().trim().length < 5 || $("#ccNumber").val().trim().length < 5 && paymentMethodId != 6 && paymentMethodId != 5) { 2873 nodalAlert('You must complete the first two sections.', 'warning'); 2874 proceed = false; 2875 } 2876 } 2877 2878 if (step == 2) { 2879 if ($("#shippingDetailsConfirmationContainer").html().trim().length < 5) { 2880 nodalAlert('You must complete the first section.', 'warning'); 2881 proceed = false; 2882 } 2883 } 2884 2885 if (proceed) { 2886 $("#checkoutStep" + step).addClass("active"); 2887 $("#checkoutStep" + step).siblings().removeClass("active"); 2888 $(".tab_content").not("#Step" + step).css("display", "none"); 2889 $("#Step" + step).fadeIn(); 2890 $.ajax({
2891 url: "index.cfm?action=gdcdata.CartActions.ActUpdateCheckoutStep&checkoutStep=" + step, 2892 async: true 2893 }); 2894 } 2895 2896 $('html,body').animate({ 2897 scrollTop: $(".container").offset().top 2898 }, 'slow'); 2899 }, 2900 ApplyPromoCode: function () { 2901 if ($("#promoCodeInput").val() != "") { 2902 $("#promoCodeFormButton").html("<i class='fa fa-spinner fa-spin'></i>"); 2903 promoCode = escape($("#promoCodeInput").val()); // url = "index.cfm?action=Cart_Ajax_ApplyPromoCode&code=" + promoCode; 2904 2905 url = "index.cfm?action=gdcdata.CartActions.ActAjaxApplyPromoCode&code=" + promoCode; 2906 $.ajax({ 2907 url: url, 2908 async: true, 2909 success: function (r) { 2910 j = $.parseJSON(r.replace(/\\'/g, "'")); 2911 2912 if (parseInt(j.returnVar) < 0) { 2913 nodalAlert(j.returnString, 'warning'); 2914 } else if (parseInt(j.returnVar) == 1) { 2915 Cart.RenderOrderSummary(); 2916 } 2917 2918 $("#promoCodeInput").val(''); 2919 $("#promoCodeFormButton").html('<i class="fa fa-check"></i> Apply'); 2920 } 2921 }); 2922 } 2923 }, 2924 ApplyVoucherCode: function () { 2925 if ($("#voucherCodeInput").val() == "") { 2926 Cart.HighlightAndFocus("#voucherCodeInput"); 2927 return false; 2928 } 2929 2930 if ($("#voucherCodePin").val() == "") { 2931 Cart.HighlightAndFocus("#voucherCodePin"); 2932 return false; 2933 } 2934 2935 $("#voucherCodeFormButton").html("<i class='fa fa-spinner fa-spin'></i>"); 2936 voucherCode = escape($("#voucherCodeInput").val()); 2937 voucherPin = escape($("#voucherCodePin").val()); // url = "index.cfm?action=Cart_Ajax_ApplyVoucherCode" 2938 2939 url = "index.cfm?action=gdcdata.CartActions.ActAjaxApplyVoucherCode" + "&voucherCode=" + voucherCode + "&voucherPin=" + voucherPin; 2940 $.ajax({
2941 url: url, 2942 async: true, 2943 success: function (r) { 2944 j = $.parseJSON(r.replace(/\\'/g, "'")); 2945 2946 if (parseInt(j.returnVar) < 0) { 2947 nodalAlert(j.returnString, 'warning'); 2948 $("#voucherCodeFormButton").html('<i class="fa fa-check"></i> Reedem'); 2949 } else if (parseInt(j.returnVar) == 1) { 2950 $("#voucherCodeFormButton").html('<i class="fa fa-check"></i> Reedem'); 2951 Cart.RenderOrderSummary(); 2952 } 2953 } 2954 }); 2955 }, 2956 CloseStickyFooter: function () { 2957 // url = "index.cfm?action=Cart_Ajax_RemoveStickyFooter"; 2958 url = "index.cfm?action=gdcdata.CartActions.ActAjaxRemoveStickyFooter"; 2959 $.ajax({ 2960 url: url, 2961 async: true, 2962 success: function (r) { 2963 $("#stickySignUp").fadeOut("slow"); 2964 } 2965 }); 2966 }, 2967 CloseCookieHeader: function () { 2968 // url = "index.cfm?action=Cart_Ajax_RemoveStickyFooter"; 2969 url = "index.cfm?action=gdcdata.CartActions.ActAjaxRemoveCookieHeader"; 2970 $.ajax({ 2971 url: url, 2972 async: true, 2973 success: function (r) { 2974 $("#cookiePolicy").fadeOut("slow"); 2975 } 2976 }); 2977 }, 2978 RenderOrderSummary: function () { 2979 var url = "index.cfm?action=gdcdata.CartActions.ActAjaxGetOrderSummary&ajax=Yes"; 2980 $.ajax({
2981 url: url, 2982 async: true, 2983 success: function (r) { 2984 j = $.parseJSON(r.replace(/\\'/g, "'")); 2985 $("#orderSummaryContainer").html(j.outputText); 2986 } 2987 }); 2988 }, 2989 RemoveDiscount: function (code) { 2990 // url = "index.cfm?action=Cart_Ajax_RemoveDiscount&code=" + code; 2991 url = "index.cfm?action=gdcdata.CartActions.ActAjaxRemoveDiscount&code=" + code; 2992 $.ajax({ 2993 url: url, 2994 async: true, 2995 success: function (r) { 2996 Cart.RenderOrderSummary(); 2997 } 2998 }); 2999 }, 3000 RemoveVoucher: function (voucherSubmitId) { 3001 // url = "index.cfm?action=Cart_Ajax_RemoveVoucher&voucherSubmitId=" + voucherSubmitId; 3002 url = "index.cfm?action=gdcdata.CartActions.ActAjaxRemoveVoucher&voucherSubmitId=" + voucherSubmitId; 3003 $.ajax({ 3004 url: url, 3005 async: true, 3006 success: function (r) { 3007 Cart.RenderOrderSummary(); 3008 } 3009 }); 3010 }, 3011 SetRating: function (num, clicked) { 3012 $("form#reviewForm ul.stars").find("li").each(function (index, el) { 3013 $(el).html('<i class="fa fa-star-o"></i>'); 3014 }); 3015 3016 for (i = 0; i < num; i++) { 3017 $("form#reviewForm ul.stars li:eq(" + i + ")").html('<i class="fa fa-star"></i>'); 3018 } 3019 3020 if (clicked) { 3021 console.log(num); 3022 } 3023 3024 if (clicked) $("#rating").val(num); 3025 }, 3026 StarOut: function () { 3027 $("form#reviewForm ul.stars").find("li").each(function (i, el) { 3028 $(el).html('<i class="fa fa-star-o"></i>'); 3029 }); 3030 3031 for (i = 0; i < parseInt($("#rating").val()); i++) { 3032 $("form#reviewForm ul.stars").find("li").eq(i).html('<i class="fa fa-star"></i>'); 3033 } 3034 }, 3035 OpenReviewBox: function () { 3036 Custombox.open({ 3037 target: '#reviewBox', 3038 effect: 'slide', 3039 overlayOpacity: 0.1 3040 }); 3041 }, 3042 CancelReview: function () { 3043 $("#reviewBox").css('display', "none"); 3044 $("#reviewText").val(""); 3045 $("#reviewerName").val(""); 3046 Cart.SetRating(5, true); 3047 }, 3048 SubmitReview: function () { 3049 if ($("#reviewerName").val().replace(/ /g, "") == "") { 3050 Cart.HighlightAndFocus("#reviewerName"); 3051 } else if ($("#reviewText").val().replace(/ /g, "") == "") { 3052 Cart.HighlightAndFocus("#reviewText"); 3053 } else { 3054 // var url = "index.cfm?action=Cart_Ajax_SubmitReview"; 3055 var url = "index.cfm?action=gdcdata.CartActions.ActAjaxSubmitReview"; 3056 $.ajax({
3057 url: url, 3058 async: true, 3059 method: "post", 3060 success: function (r) { 3061 Cart.CancelReview(); 3062 nodalAlert("Thank you! Your review is awaiting moderator approval and will show up on the site soon!"); 3063 }, 3064 data: $("#reviewForm").serialize() 3065 }); 3066 } 3067 }, 3068 CharsLeft: function (el) { 3069 $("#" + $(el).attr('id') + "Chars").html(250 - $(el).val().length + " characters left"); 3070 }, 3071 ApplyGiftWrap: function (elem) { 3072 if (elem.checked) { 3073 var url = "index.cfm?action=gdcdata.CartActions.ActAjaxUpdateGiftWrapping&subaction=add"; 3074 } else { 3075 var url = "index.cfm?action=gdcdata.CartActions.ActAjaxUpdateGiftWrapping&subaction=remove"; 3076 } 3077 3078 $.ajax({ 3079 url: url, 3080 async: true, 3081 success: function (r) { 3082 Cart.RenderOrderSummary(); 3083 } 3084 }); 3085 }, 3086 submitFileRequest: function (form) { 3087 if ($(form).find("#name").val().length == 0) { 3088 Cart.HighlightAndFocus("#name", "#errorMessage-name", "This is a required field."); 3089 return false; 3090 } else { 3091 Cart.ClearHighlighted("#errorMessage-name"); 3092 } 3093 3094 if ($(form).find("#company").val().length == 0) { 3095 Cart.HighlightAndFocus("#company", "#errorMessage-company", "This is a required field."); 3096 return false; 3097 } else { 3098 Cart.ClearHighlighted("#errorMessage-company"); 3099 } 3100 3101 if ($(form).find("#companyEmail").val().length == 0) { 3102 Cart.HighlightAndFocus("#companyEmail", "#errorMessage-companyEmail", "This is a required field."); 3103 return false; 3104 } else { 3105 Cart.ClearHighlighted("#errorMessage-companyEmail"); 3106 } // if ( $(form).find("#country").length > 0 && $(form).find("#country").val().length == 0 ){ 3107 // Cart.HighlightAndFocus("#country", "#errorMessage-phone", "This is a required field."); 3108 // return false; 3109 // }else{ 3110 // Cart.ClearHighlighted("#errorMessage-country"); 3111 // } 3112 3113 3114 if ($(form).find("#phone").val().length == 0) { 3115 Cart.HighlightAndFocus("#phone", "#errorMessage-phone", "This is a required field."); 3116 return false; 3117 } else { 3118 Cart.ClearHighlighted("#errorMessage-phone"); 3119 } 3120 3121 if ($(form).find("#message").val().length == 0) { 3122 Cart.HighlightAndFocus("#message", "#errorMessage-message", "This is a required field."); 3123 return false; 3124 } else { 3125 Cart.ClearHighlighted("#errorMessage-message"); 3126 } 3127 3128 var response = grecaptcha.getResponse(); 3129 3130 if (response.length == 0) { 3131 alert('The captcha is required and can\'t be empty'); 3132 return false; 3133 } 3134 3135 $.ajax({
3136 type: 'POST', 3137 url: "index.cfm?action=gdcdata.CartActions.ActAjaxSubmitFileRequest", 3138 data: $(form).serialize(), 3139 dataType: 'json', 3140 success: function (result) { 3141 console.log(result); 3142 $('.requestFilesContainer').html(result.MESSAGE); 3143 }, 3144 error: function (xhr, textStatus) { 3145 console.log(xhr); 3146 console.log(textStatus); 3147 } 3148 }); 3149 } 3150}; 3151var testGlobalVar; 3152var CreditCard = { 3153 IsVisa: function (cc) { 3154 if ((cc.length == 16 || cc.length == 13) && cc.substring(0, 1) == 4) { 3155 return CreditCard.IsCreditCard(cc); 3156 } else { 3157 return false; 3158 } 3159 }, 3160 IsMasterCard: function (cc) { 3161 var firstdig = cc.substring(0, 1); 3162 var seconddig = cc.substring(1, 2); 3163 3164 if (cc.length == 16 && firstdig == 5 && seconddig >= 1 && seconddig <= 5) { 3165 return CreditCard.IsCreditCard(cc); 3166 } else { 3167 return false; 3168 } 3169 }, 3170 IsAmericanExpress: function (cc) { 3171 var firstdig = cc.substring(0, 1); 3172 var seconddig = cc.substring(1, 2); 3173 3174 if (cc.length == 15 && firstdig == 3 && (seconddig == 4 || seconddig == 7)) { 3175 return CreditCard.IsCreditCard(cc); 3176 } else { 3177 return false; 3178 } 3179 }, 3180 IsLaser: function (cc) { 3181 if (cc.length == 19 && isNumeric(cc)) { 3182 return true; 3183 } else { 3184 return false; 3185 } 3186 }, 3187 IsCreditCard: function (st) { 3188 if (st.length > 19) { 3189 return false; 3190 } else { 3191 return true; 3192 } // var sum = 0; 3193 // var mul = 1; 3194 // var l = st.length; 3195 // for (i = 0;i<l;i++) { 3196 // digit = st.substring(l-i-1,l-i); 3197 // tproduct = parseInt(digit ,10)*mul; 3198 // if (tproduct >= 10) { 3199 // sum += (tproduct % 10) + 1; 3200 // } else { 3201 // sum += tproduct; 3202 // } 3203 // if(mul == 1) { 3204 // mul++; 3205 // } else { 3206 // mul--; 3207 // } 3208 // } 3209 // if((sum % 10) == 0) { 3210 // return true; 3211 // } else { 3212 // return false; 3213 // } 3214 3215 } 3216}; 3217 3218var supports = function () { 3219 var div = document.createElement('div'), 3220 vendors = 'Khtml Ms O Moz Webkit'.split(' '), 3221 len = vendors.length; 3222 return function (prop) { 3223 if (prop in div.style) return true; 3224 prop = prop.replace(/^[a-z]/, function (val) { 3225 return val.toUpperCase(); 3226 }); 3227 3228 while (len--) { 3229 if (vendors[len] + prop in div.style) { 3230 return true; 3231 } 3232 } 3233 3234 return false; 3235 }; 3236}(); 3237 3238$(window).resize(function () { 3239 mediaQueries(); 3240}); 3241$(document).ready(function () { 3242 mediaQueries(); 3243 3244 if ($('body').attr('id') == 'trade-products') { 3245 if (!localStorage.tradelogin) { 3246 localStorage.tradelogin = true; 3247 } else { 3248 $('#messageBg').css('display', 'none'); 3249 } 3250 } 3251 3252 var width = $(document).width(); 3253 3254 if (width >= 1023) { 3255 $("figure.zoom").each(function (i, el) { 3256 $(el).zoom({ 3257 url: $(el).find('img').attr('data-zoom') 3258 }); 3259 }); 3260 } //banner slider 3261 // $('.bannerSlider').slick({ 3262 // autoplay: true, 3263 // slidesToShow: 1, 3264 // slide: "li", 3265 // infinite: true, 3266 // speed: 500, 3267 // fade: true, 3268 // cssEase: 'linear', 3269 // arrows: false, 3270 // dots: true 3271 // }); 3272 //product image carousel 3273 3274 3275 $('.productImageSlider').slick({ 3276 slidesToShow: 1, 3277 slidesToScroll: 1, 3278 autoplay: true, 3279 infinite: true, 3280 speed: 500, 3281 fade: false, 3282 cssEase: 'linear', 3283 arrows: false, 3284 dots: false 3285 }); 3286 /* //product thumb carousel 3287 $('.productThumbSlider').slick({ 3288 slidesToShow: 8, 3289 mobileFirst: true, 3290 vertical: true, 3291 verticalSwiping: true, 3292 focusOnSelect: true, 3293 arrows: false, 3294 asNavFor: '.productImageSlider' 3295 }); */ 3296 //scrolls smoothly to next section 3297 3298 $('a[href*=#]:not([href=#])').click(function () { 3299 if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) { 3300 var target = $(this.hash); 3301 target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); 3302 3303 if (target.length) { 3304 $('html,body').animate({ 3305 scrollTop: target.offset().top 3306 }, 1000); 3307 return false; 3308 } 3309 } 3310 }); //show/hide main nav 3311 3312 $(".toggleSlideOutMenu").click(function () { 3313 $("body").toggleClass("menuOpen"); 3314 $(".toggleSlideOutMenu").toggleClass("open"); 3315 }); 3316 $(".slideOutMenu .close").click(function () { 3317 $("body").toggleClass("menuOpen"); 3318 $(".toggleSlideOutMenu").toggleClass("open"); 3319 }); //show/hide Chef Page nav 3320 3321 $("#showHorizontalNav").click(function () { 3322 $("#horizontalNavList").toggleClass("open"); 3323 }); //show/hide sub navs 3324 3325 /*$( ".haschildren a" ).click(function() { 3326 $this = $(this); 3327 $this.parent().toggleClass('open'); 3328 });*/ 3329 //show/hide sub navs 3330 3331 $(".showSubNav").click(function () { 3332 $this = $(this); 3333 $this.parent().toggleClass('open'); 3334 }); //show/hide login forms 3335 3336 $(".gdLogin_top h3").click(function () { 3337 $this = $(this); 3338 $this.parents(".gdLogin_wrap").toggleClass('open'); 3339 }); //show/hide mini cart 3340 3341 $(".navcart").click(function () { 3342 $(".navcart").toggleClass("open"); 3343 }); //show/hide search 3344 3345 $(".toggleSearch").click(function () { 3346 $(".search").toggleClass("open"); 3347 $(".header").toggleClass("searchOpen"); 3348 $(".search input.text").focus(); 3349 }); //show/hide search 3350 3351 $(".search .toggleSearch").click(function () { 3352 $(".search input.text").blur(); 3353 }); //hide flash (green shipping message) 3354 3355 $(".flash .close").click(function () { 3356 $(".flash").addClass("hide"); 3357 }); //show/hide tabs 3358 3359 $(".toggleTabs").click(function () { 3360 $(".tab-container").toggleClass("open"); 3361 }); 3362 $(".etabs a").click(function () { 3363 $(".tab-container").toggleClass("open"); 3364 }); //change appearange of sticky top nav bar 3365 3366 /* 3367 var shrinkHeader = 50; 3368 $(window).scroll(function() { 3369 var scroll = getCurrentScroll(); 3370 if ( scroll >= shrinkHeader ) { 3371 $('.header.container').addClass('sticky'); 3372 $('.flash').addClass('sticky'); 3373 } 3374 else { 3375 $('.header.container').removeClass('sticky'); 3376 $('.flash').removeClass('sticky'); 3377 } 3378 });*/ 3379 //easy tabs 3380 3381 $('.tab-container').easytabs(); //accordion 3382 3383 /* 3384 var allPanels = $('.accordion > div').hide(); 3385 $('.accordion > h3 > a').click(function() { 3386 $this = $(this); 3387 if(!$this.parent().hasClass('noaccordion')){ 3388 $target = $this.parent().next().slideToggle(); 3389 $target.toggleClass('open'); 3390 $this.parent().toggleClass('open'); 3391 return false; 3392 } 3393 });*/ 3394 //lightbox 3395 3396 $("a[rel^='lightbox']").fancybox({ 3397 // slideshow: false, 3398 autoplay: false 3399 }); 3400 3401 if ($('#saleStrip li').length > 1) { 3402 $('#saleStrip').slick({ 3403 infinite: true, 3404 slidesToShow: 5, 3405 slidesToScroll: 1, 3406 speed: 1000, 3407 arrows: true, 3408 prevArrow: '<div class="bgPrev">
3408<a href="javascript:" class="sale-carousel-control" rel="prev" >Previous</a></div>', 3409 nextArrow: '<div class="bgNext"><a href="javascript:" class="sale-carousel-control" rel="next" >Next</a></div>', 3410 appendArrows: $('#salecarousel-arrows') 3411 }); 3412 } 3413 3414 Cart.Featured(); // Site.Carousel(); 3415 3416 if (supports("backgroundSize")) $("html").addClass("background-size"); 3417 $("div#productFilters h3").each(function (i, el) { 3418 $(el).click(function () { 3419 $(el).next().slideToggle(); // var list = $(el).closest("ul"); 3420 // if (!$(el).attr("data-open") || $(el).attr("data-open") == "") { 3421 // $(el).attr("data-open", "open"); 3422 // $(list).css("height", $(list).prop('scroll-height') + "px"); 3423 // } else if ($(el).attr("data-open") == "open") { 3424 // $(el).attr("data-open", ""); 3425 // $(list).css("height","0"); 3426 // } 3427 }); 3428 }); // $("div.productFilter h4").each(function(i, el){ 3429 // $(el).click(function(){ 3430 // var list = $(el).closest("ul"); 3431 // if (!$(el).attr("data-open") || $(el).attr("data-open") == "") { 3432 // $(el).attr("data-open", "open"); 3433 // $(list).css("height", $(list).prop('scroll-height') + "px"); 3434 // } else if ($(el).attr("data-open") == "open") { 3435 // $(el).attr("data-open", ""); 3436 // $(list).css("height","0"); 3437 // } 3438 // }); 3439 // }); 3440 3441 if ($("#priceFilter").length > 0) { 3442 $("#minPriceIndicator").html($("#currencySymbol").val() + $("#minPrice").val()); 3443 $("#maxPriceIndicator").html($("#currencySymbol").val() + $("#maxPrice").val()); 3444 $("#slider-range").slider({ 3445 range: true, 3446 step: 5, 3447 min: parseFloat($("#originalMinPrice").val()), 3448 max: parseFloat($("#originalMaxPrice").val()), 3449 values: [parseFloat($("#minPrice").val()), parseFloat($("#maxPrice").val())], 3450 slide: function (event, ui) { 3451 //console.log( ui.values[0]+";"+ui.values[1]); 3452 $("#minPriceIndicator").html($("#currencySymbol").val() + ui.values[0]); 3453 $("#maxPriceIndicator").html($("#currencySymbol").val() + ui.values[1]); 3454 $("#minPrice").val(ui.values[0]); 3455 $("#maxPrice").val(ui.values[1]); 3456 Cart.FilterProducts('', 1); 3457 } 3458 }); 3459 } 3460 3461 if ($("body").attr("onload") != null) { 3462 eval($("body").attr("onload")); 3463 $('body').attr('onload', ''); 3464 } 3465 3466 if ($("#selectSizeList").length > 0 && $("#selectSizeList").find("li").length == 1) { 3467 $("#selectSizeListContainer").hide(); 3468 } 3469 3470 if ($("#selectColoursList").length > 0 && $("#selectColoursList").find("li").length == 1) { 3471 $("#selectColoursListContainer").hide(); 3472 } // if ($("#sortFilter").length > 0){ 3473 // defaultSortArray = []; 3474 // Cart.SortProducts($("#sortBy").val(), $("#sortDir").val(), $("#sortEl").val()); 3475 // } 3476 3477 /*Password Strength*/ 3478 3479 3480 if ($('#userPassword').length > 0) { 3481 $('#userPassword').keyup(function () { 3482 var pass = $(this).val(); 3483 var strength = Cart.checkPassStrength(pass); 3484 /*remove all previous classes*/ 3485 3486 removeAllClasses($("#password-strength")); 3487 $("#password-strength").addClass(strength.messageClass); 3488 $("#password-strength").html(strength.message); 3489 }); 3490 } 3491 3492 Cart.RefreshProduct(); 3493 $("ul#mainNavList li.haschildren").each(function (i, el) { 3494 var toggle = $("<a href='javascript:;' class='toggle'><span class='plus'>+</span><span class='minus'>-</span></a>"); 3495 $(el).append(toggle); 3496 toggle.click(function () { 3497 var list = this.closest("li"); 3498 3499 if (list.attr('class') == "open") { 3500 list.removeClass("open"); 3501 } else { 3502 $("ul#mainNavList li.haschildren").each(function (i, el) { 3503 $(el).removeClass("open"); 3504 }); 3505 list.addClass("open"); 3506 } 3507 }); 3508 }); 3509 3510 if ($(".starsContainer")) { 3511 $(".starsContainer .stars li").mouseover(function (e) { 3512 var i = $(this).index(); 3513 Cart.SetRating(parseInt(i + 1), false, ".starsContainer .stars"); 3514 }); 3515 $(".starsContainer .stars li").mouseout(function (e) { 3516 Cart.StarOut(".starsContainer .stars"); 3517 });
3518 $(".starsContainer .stars li").click(function (e) { 3519 var i = $(this).index(); 3520 Cart.SetRating(parseInt(i + 1), true, ".starsContainer .stars"); 3521 }); 3522 } 3523 3524 if ($(".thumbList li").length > 0) { 3525 var options = { 3526 zoomType: 'standard', 3527 lens: true, 3528 preloadImages: true, 3529 alwaysOn: false, 3530 zoomWidth: 400, 3531 zoomHeight: 500, 3532 xOffset: 10, 3533 yOffset: 10, 3534 position: 'right' //...MORE OPTIONS 3535 3536 }; 3537 $(".thumbList li a").click(function (e) { 3538 e.stopPropagation(); 3539 var i = $(this).parent("li").index(); //console.log(i); 3540 3541 $("#productSlides div.productPhoto").hide(); 3542 $("#productSlides div.productPhoto a").removeClass('zoomclass'); 3543 $("#productSlides div.productPhoto").eq(i).show(); 3544 $("#productSlides div.productPhoto").eq(i).find("a").addClass('zoomclass'); 3545 $(".thumbList li").attr("class", ""); 3546 $(".thumbList li").eq(i).attr("class", "sel"); 3547 $('.zoomclass').jqzoom(options); 3548 }); 3549 $('.zoomclass').jqzoom(options); 3550 } 3551 3552 if ($("#productsListing").length > 0) { 3553 if ($("#wrap").width() <= 480) { 3554 var itemsShowing = 0; 3555 3556 showMore = function () { 3557 itemsShowing += 10; 3558 var itemCount = 0; 3559 $("#productsListing li").each(function (i, el) { 3560 itemCount++; 3561 $(el).css('display', ""); 3562 3563 if (itemCount > itemsShowing) { 3564 el.css('display', "none"); 3565 } 3566 }); 3567 3568 if (itemsShowing >= itemCount) { 3569 $("#viewMoreProducts").css('display', "none"); 3570 } 3571 }; 3572 3573 showMore(); 3574 } 3575 } //checkout tabs 3576 3577 3578 $(".checkout_header .tab").click(function (event) { 3579 event.preventDefault(); 3580 var step = $(this).attr("data-step"); 3581 Cart.UpdateCheckoutStep(step); 3582 }); 3583 $("img.lazy").show().lazyload(); 3584}); 3585 3586function getCurrentScroll() { 3587 return window.pageYOffset; 3588} 3589 3590function isIE() { 3591 var myNav = navigator.userAgent.toLowerCase(); 3592 return myNav.indexOf('msie') != -1 ? parseInt(myNav.split('msie')[1]) : false; 3593} 3594 3595function removeAllClasses(elem) { 3596 var classes = $(elem).attr("class").split(" "); 3597 3598 for (var i = 0; i < classes.length; i++) { 3599 $(elem).removeClass(classes[i]); 3600 } 3601} 3602 3603function mediaQueries() { 3604 var width = $(document).width(); 3605 var url = "index.cfm?action=gdcdata.CartActions.ActAjaxSetBrowserWidth"; 3606 $.ajax({ 3607 url: url, 3608 async: true, 3609 data: { 3610 width: width 3611 } 3612 }); 3613 3614 if (width >= 1200) { 3615 webViewProduct(); 3616 webViewCheckout(); 3617 $(".responsiveimg img").each(function (i, el) { 3618 $(el).attr('src', $(el).attr('data-3x')); 3619 }); 3620 } 3621 3622 if (width >= 1023 && width < 1200) { 3623 webViewProduct(); 3624 webViewCheckout(); 3625 $(".responsiveimg img").each(function (i, el) { 3626 $(el).attr('src', $(el).attr('data-2x')); 3627 }); 3628 } 3629 3630 if (width >= 767 && width < 1023) { 3631 mobileViewProduct(); 3632 mobileViewCheckout(); 3633 $(".responsiveimg img").each(function (i, el) { 3634 $(el).attr('src', $(el).attr('data-1x')); 3635 }); 3636 } 3637 3638 if (width < 767) { 3639 mobileViewProduct(); 3640 mobileViewCheckout(); 3641 $(".responsiveimg img").each(function (i, el) { 3642 $(el).attr('src', $(el).attr('data-0x')); 3643 }); 3644 } 3645} 3646 3647function mobileViewCheckout() {// if($(".span3").find("#shoppingTotalCartHolder").length>0){ 3648 // $($(".span3").find("#shoppingTotalCartHolder")[0].outerHTML).insertAfter(".cart_grid"); 3649 // $(".span3").find("#shoppingTotalCartHolder").remove(); 3650 // } 3651} 3652 3653function webViewCheckout() {// if($(".span9").find("#shoppingTotalCartHolder").length>0){ 3654 // $(".span3").html($(".span9").find("#shoppingTotalCartHolder")[0].outerHTML); 3655 // $(".span9").find("#shoppingTotalCartHolder").remove(); 3656 // } 3657} 3658 3659function mobileViewProduct() {// if($(".productDetail .span3").find(".productInfo").length>0){ 3660 // $(".productDetail .span8").prepend($(".productDetail .span3").find(".productInfo")[0].outerHTML); 3661 // $(".productDetail .span3").find(".productInfo").remove(); 3662 // $(".productDetail .span8 .productImageSlider").after($(".productDetail .span3").find(".productPurchase")[0].outerHTML); 3663 // $(".productDetail .span3").find(".productPurchase").remove(); 3664 // $(".productDetail .span8 .productImageSlider").after($(".productDetail .span3").find(".productInfoWishlist")[0].outerHTML); 3665 // $(".productDetail .span3").find(".productInfoWishlist").remove(); 3666 // } 3667 // if($(".productDetail .span5").find(".productInfo").length>0){ 3668 // $(".productDetail .span7").prepend($(".productDetail .span5").find(".productInfo")[0].outerHTML); 3669 // $(".productDetail .span5").find(".productInfo").remove(); 3670 // $(".productDetail .span7 .productImageSlider").after($(".productDetail .span5").find(".productPurchase")[0].outerHTML); 3671 // $(".productDetail .span5").find(".productPurchase").remove(); 3672 // } 3673} 3674 3675function webViewProduct() {// if($(".productDetail .span5").length>0){ 3676 // if($(".productDetail .span7").find(".productInfo").length>0){ 3677 // $(".productDetail .span5").prepend($(".productDetail .span7").find(".productInfo")[0].outerHTML); 3678 // $(".productDetail .span7").find(".productInfo").remove(); 3679 // $(".productDetail .span5 .productInfo").after($(".productDetail .span7").find(".productPurchase")[0].outerHTML); 3680 // $(".productDetail .span7").find(".productPurchase").remove(); 3681 // } 3682 // }else{ 3683 // if($(".productDetail .span8").find(".productInfo").length>0){ 3684 // $(".productDetail .span3").prepend($(".productDetail .span8").find(".productInfo")[0].outerHTML); 3685 // $(".productDetail .span8").find(".productInfo").remove(); 3686 // $(".productDetail .span3 .productInfo").after($(".productDetail .span8").find(".productPurchase")[0].outerHTML); 3687 // $(".productDetail .span8").find(".productPurchase").remove(); 3688 // $(".productDetail .span3 .productInfo").after($(".productDetail .span8").find(".productInfoWishlist")[0].outerHTML); 3689 // $(".productDetail .span8").find(".productInfoWishlist").remove(); 3690 // } 3691 // } 3692} 3693/* 3694.value.blank() = .val().isEmpty() 3695 3696el.up = $(el).closest 3697 3698select( = find( 3699 3700removeClassName 3701removeClass 3702
3703addClassName 3704addClass 3705 3706setAttribute 3707attr 3708 3709style. 3710css( 3711 3712Cart.Forms.HAL 3713Site.HAL 3714 3715ajax 3716$.ajax({ url:url, async:true, success:Cart.UpdateProductSearch_onSuccess}); 3717 3718parentNode 3719parent() 3720 3721z = parseJSON( t.responseText ); 3722z = $.parseJSON(t.replace(/\\'/g, "'")); 3723 3724Form.serialize( $( "tellAFriendForm" ) ) 3725$("#tellAFriendForm").serialize() 3726 3727$("#finalTotal").effect( "highlight", {color:"#C6EC6A"}, 2000 ); 3728 3729AjaxOrderSummary:function(url){ 3730 $.ajax({ 3731 url:url, 3732 async:true, 3733 success:function(r){ 3734 var url = "index.cfm?action=Cart_Ajax_GetOrderSummary&ajax"; 3735 $.ajax({ url:url, async:true, success:function(r){ 3736 j = $.parseJSON(r.replace(/\\'/g, "'")); 3737 $("div.orderSummary").eq(0).html(j.outputText); 3738 }}); 3739 } 3740 }); 3741 }, 3742 3743cautare dupa script 3744Cart. 3745$( 3746onclick 3747onfocus 3748onblur 3749*/
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.