1; 2jQuery(document).ready(function() { 3 function input_delay(callback, ms) { 4 var timer = 0; 5 return function () { 6 var context = this, args = arguments; 7 clearTimeout(timer); 8 timer = setTimeout(function () { callback.apply(context, args); }, ms || 0); 9 }; 10 } 11 function matchCase(text, pattern) { 12 var result = ''; 13 for (var i = 0; i < text.length; i++) { 14 var c = text.charAt(i); 15 var p = pattern.charCodeAt(i); 16 result += (p >= 65 && p < 91) ? c.toUpperCase() : c.toLowerCase(); 17 } 18 return result; 19 } 20 function toBold(text) { 21 return text.replace(/\*(.*?)\*/gm, '<strong>$1</strong>'); 22 } 23 var window_loc_hash = window.location.hash; 24 25$("#newsletter_email").focus(function() { 26 $("#newsletter_recaptcha").slideDown(); 27 }); 28 29 if($('.gateway_wrapper .colorbox').length) { 30 var colorbox = $('.colorbox'); 31 var href = colorbox.attr('href'); 32 var title = colorbox.attr('title'); 33 34 colorbox.attr('href', '#').attr('data-reveal-id', 'colorbox'); 35 36 $('.colorbox').after( 37 $('<div>').attr('id', 'colorbox').addClass('reveal-modal').addClass('tiny').attr('data-reveal','').attr('aria-labelledby',title).attr('aria-hidden','true').attr('role', 'dialog').html('<h3>'+title+'</h3><img src="'+href+'"><a class="close-reveal-modal">×</a>') 38 ); 39 $(".gateway_wrapper .colorbox").click(function() { 40 $('#colorbox').foundation('reveal', 'open'); 41 }); 42 } 43 $("#eu_cookie_button").click(function() { 44 $('#eu_cookie_dialogue').slideUp(); 45 $.cookie('accept_cookies', 1, { 46 expires: 730 47 }); 48 return false; 49 }); 50 51 $(".top-bar label").click(function() { 52 var link = $(this).attr('rel'); 53 if (typeof link !== typeof undefined && link !== false) { 54 document.location.href = link; 55 } 56 }); 57 58 $(".autosubmit select").not('.nosubmit').change(function() { 59 $(this).parents(".autosubmit").submit(); 60 }); 61 $('svg.icon-submit').each(function() { 62 $(this).parents('form').submit(); 63 }); 64 $(".category-nav li").each(function(index) { 65 if (!$(this).has("ul").length) { 66 $(this).removeClass('has-dropdown'); 67 } 68 }); 69 $(".review_hide").click(function() { 70 $('#review_read').show(); 71 $('#review_write').slideUp(); 72 return false; 73 }); 74 $(".review_show").click(function() { 75 $('#review_read').hide(); 76 $('#review_write').slideDown(); 77 return false; 78 }); 79 $(".show-small-search").click(function() { 80 $('#small-search').slideToggle(); 81 return; 82 }); 83 $(".hide_skin_selector").click(function(e) { 84 e.preventDefault(); 85 $('.skin_selector').fadeOut(); 86 return; 87 }); 88 $(".image-gallery").hover(function() { 89 var src = $(this).attr("data-image-swap"); 90 $('#img-preview').attr("src", src); 91 }); 92 $('.open-clearing').on('click', function(e) { 93 e.preventDefault(); 94 $('[data-clearing] li img').eq($(this).data('thumb-index')).trigger('click'); 95 }); 96 $('input[type=radio].rating').rating({ 97 required: true 98 }); 99 $('body').on('click', '#basket-summary', function() { 100 mini_basket_action(); 101 }); 102 $('a.quan').click(function() { 103 var rel = $(this).attr('rel'); 104 var sign; 105 if ($(this).hasClass('add')) { 106 sign = '+'; 107 } else if ($(this).hasClass('subtract')) { 108 sign = '-'; 109 } else { 110 alert('No \'add\' or \'subtract\' class defined.'); 111 } 112 return update_quantity(rel, sign); 113 }); 114 $('#checkout_proceed').click(function() { 115 $('<input>').attr({ 116 type: 'hidden', 117 name: 'proceed', 118 value: '1' 119 }).appendTo('form#checkout_form'); 120 }); 121 /* Initial setup of country/state menu */ 122 $('select#country-list, select.country-list').each(function() { 123 if (typeof(county_list) == 'object') { 124 var counties = county_list[$(this).val()]; 125 var target = ($(this).attr('rel') && $(this).attr('id') != 'country-list') ? '#' + $(this).attr('rel') : '#state-list'; 126 if (typeof(counties) == 'object') { 127 var setting = $(target).val(); 128 var select = document.createElement('select'); 129 $(target).replaceWith($(select).attr({ 130 'name': $(target).attr('name'), 131 'id': $(target).attr('id'), 132 'class': $(target).attr('class'), 133 'required': $(target).attr('required') 134 })); 135 if ($(this).attr('title')) { 136 var option = document.createElement('option'); 137 $('select' + target).append($(option).text($(this).attr('title'))); 138 } 139 for (i in counties) { 140 var option = document.createElement('option'); 141 if (setting == counties[i].name || setting == counties[i].id) { 142 $('select' + target).append($(option).val(counties[i].id).text(counties[i].name).attr('selected', 'selected')); 143 } else { 144 if(counties[i].id>0) { 145 $('select' + target).append($(option).val(counties[i].id).text(counties[i].name)); 146 } else { 147 $('select' + target).append($(option).val('').text(counties[i].name)); 148 } 149 } 150 } 151 } else { 152 if ($(this).hasClass('no-custom-zone')) $(target).attr({ 153 'disabled': 'disabled' 154 }).val($(this).attr('title')); 155 } 156 } 157 }).change(function() { 158 if (typeof(county_list) == 'object') { 159 var list = county_list[$(this).val()]; 160 var target = ($(this).attr('rel') && $(this).attr('id') != 'country-list') ? '#' + $(this).attr('rel') : '#state-list'; 161 if (typeof(list) == 'object' && typeof(county_list[$(this).val()]) != 'undefined' && county_list[$(this).val()].length >= 1) { 162 var setting = $(target).val(); 163 var select = document.createElement('select'); 164 $(target).replaceWith($(select).attr({ 165 'name': $(target).attr('name'), 166 'id': $(target).attr('id'), 167 'class': $(target).attr('class'), 168 'required': $(target).attr('required') 169 })); 170 if ($(this).attr('title')) { 171 var option = document.createElement('option'); 172 $('select' + target).append($(option).text($(this).attr('title'))); 173 } 174 for (var i = 0; i < list.length; i++) { 175 var option = document.createElement('option'); 176 if(list[i].id > 0) { 177 $('select' + target).append($(option).val(list[i].id).text(list[i].name)); 178 } else { 179 $('select' + target).append($(option).val('').text(list[i].name)); 180 } 181 } 182 if(setting>0) { 183 $('select' + target + ' > option[value=' + setting + ']').attr('selected', 'selected'); 184 } 185 } else { 186 var input = document.createElement('input'); 187 var placeholder = $('label[for="' + $(this).attr('rel') + '"]').text() + ' ' + $('#validate_required').text(); 188 var replacement = $(input).attr({ 189 'type': 'text', 190 'placeholder': placeholder, 191 'id': $(target).attr('id'), 192 'name': $(target).attr('name'), 193 'class': $(target).attr('class'), 194 'required': $(target).attr('required') 195 }); 196 if ($(this).hasClass('no-custom-zone')) $(replacement).attr('disabled', 'disabled').val($(this).attr('title')); 197 $(target).replaceWith($(replacement)); 198 } 199 } 200 }); 201 202 $('.show_address_form').click(function() { 203 show_address_form(); 204 }); 205 206 if($('div.alert').length) { 207 show_address_form(); 208 } 209 210 if($('#delivery_is_billing:checkbox').length) { 211 if($('#delivery_is_billing:checkbox').prop('checked') == true) { 212 $('#address_delivery').hide(); 213 } else { 214 $('#address_delivery').show(); 215 } 216 } 217 $('#delivery_is_billing:checkbox').change(function() { 218 if ($(this).is(':checked')) { 219 $('#address_delivery').hide(); 220 } else { 221 $('#address_delivery').show(); 222 } 223 });
224 if ($('input#show-reg:checkbox').is(':checked') == false) $('#account-reg').hide(); 225 $('input#show-reg:checkbox').change(function() { 226 if ($(this).is(':checked')) { 227 $('#account-reg').show(); 228 $('input#reg_password').addClass('required'); 229 $('input#reg_passconf').addClass('required'); 230 } else { 231 $('#account-reg').hide(); 232 $('input#reg_password').removeClass('required'); 233 $('input#reg_passconf').removeClass('required'); 234 } 235 }); 236 237 $('.grid_view').click(function(event) { 238 grid_view(200, event); 239 }); 240 $('.list_view').click(function(event) { 241 list_view(200, event); 242 }); 243 244 set_product_view(0); 245 246 $('.url_select').bind('change', function() { 247 var url = $(this).val(); // get selected value 248 if (url) { // require a URL 249 window.location = url; // redirect 250 } 251 return false; 252 }); 253 254 // ------------------------------- 255 // SAYT (search as you type) 256 // ------------------------------- 257 var selector = ($(window).width() < 640) ? '#small-search .search_input' : '.search_input'; 258 var sayt = $(selector); 259 sayt.on('click', function () { $.removeCookie('ccScroll', null); }); 260 var keyDelay = sayt.hasClass("es") ? 0 : 500; 261 sayt.on('keyup', input_delay(function () { saytGo(); }, keyDelay)); 262 263 $(document).on('keyup', function (e) { 264 if (e.key === "Escape") { 265 sayt.val(''); 266 $('#sayt_results li').remove(); 267 } 268 }); 269 270 function saytGo() { 271 if (!sayt.hasClass("es")) return false; 272 var search_term = sayt.val(); 273 console.log(search_term); 274 if (!$('#sayt_results').length) $('<ul id="sayt_results">').insertAfter(sayt); 275 if (search_term.length === 0) { 276 $('#sayt_results li').remove(); 277 return; 278 } 279 var amount = sayt.attr("data-amount"); 280 var url = '?_e=es&q=' + search_term + '&a=' + amount; 281 $.ajax({ 282 async: true, 283 url: url, 284 cache: true, 285 complete: function (response) { 286 $('#sayt_results li').remove(); 287 var products = $.parseJSON(response.responseText); 288 if (Array.isArray(products)) { 289 search_term.replace('*', ''); 290 var splitted = search_term.split(' '); 291 for (var k in products) { 292 var product_name = products[k]['name']; 293 for (var s = 0; s < splitted.length; s++) { 294 var split = splitted[s]; 295 if (!split || split === '*') continue; 296 var regexp = new RegExp('(' + split + ')', 'ig'); 297 product_name = product_name.replace(regexp, function (match) { return '*' + matchCase(split, match) + '*'; }); 298 } 299 var image = (sayt.attr("data-image") == 'true' && products[k]['thumbnail'] !== '') 300 ? "<span><img src=\"" + products[k]['thumbnail'] + "\" title=\"" + products[k]['name'] + "\"></span>" 301 : "<span> </span>"; 302 console.log(image, products[k]); 303 $("#sayt_results").append("<li><a href='?_a=product&product_id=" + products[k]['product_id'] + "'>" + image + toBold(product_name) + "</a></li>"); 304 } 305 } else { 306 $('#sayt_results').append('<li class="status">No results found</li>'); 307 } 308 } 309 }); 310 } 311 312 $("#ccScroll").on( "click", ".ccScroll-next", function(event) { 313 event.preventDefault(); 314 $(this).hide(); 315 window.location.hash = $(this).attr("data-next-page"); 316 317 var loc = $(window).scrollTop(); 318 var cat = parseInt($(this).attr("data-cat")); 319 var page = parseInt($(this).attr("data-next-page")); 320 var product_list = $('.product_list'); 321 var next_link = $('a.ccScroll-next'); 322 var loadingHtml = '<p class="text-center" id="loading"><svg class="icon"><use xlink:href="#icon-spinner"></use></svg> ' + $('#lang_loading').text() + '…<p>'; 323 324 // Keep history to load on back button 325 if ($.cookie('ccScroll')){ 326 var ccScrollHistory = $.parseJSON($.cookie("ccScroll")); 327 ccScrollHistory[cat] = page; 328 } else { 329 ccScrollHistory = {}; 330 ccScrollHistory[cat] = page; 331 } 332 333 if(loc>0) { 334 ccScrollHistory['loc'] = loc; 335 } 336 // Set cookie for 10 mins 337 var date = new Date(); 338 date.setTime(date.getTime() + (10 * 60 * 1000)); 339 $.cookie("ccScroll", JSON.stringify(ccScrollHistory), {expires: date}); 340 341 $(this).after(function() { 342 return loadingHtml; 343 }); 344 345 $.ajax({ 346 async: false, 347 url: $(this).attr('href'), 348 cache: true, 349 complete: function(returned) { 350 351 $('p#loading').hide(); 352 353 var page = returned.responseText; 354 var list = $('.product_list li', page); 355 var next = $('a.ccScroll-next', page); 356 357 product_list.append(list); 358 set_product_view(0) 359 $(next_link).replaceWith(next); 360 init_add_to_basket(); 361 } 362 }); 363 }); 364 365 if($('#ccScrollCat').length > 0) { 366 var cat_pages = parseInt($('#ccScrollCat').text()); 367 if ($.cookie('ccScroll')) { 368 var ccScrollHistory = $.parseJSON($.cookie("ccScroll")); 369 console.log(ccScrollHistory['loc']); 370 if(cat_pages in ccScrollHistory) { 371 for (i = 1; i < ccScrollHistory[cat_pages]; i++) { 372 $('.ccScroll-next:last').trigger("click"); 373 } 374 $('html, body').animate({ scrollTop: ccScrollHistory['loc'] }, 'slow'); 375 } 376 } 377 } 378 379 var duration = 500; 380 $(window).scroll(function() { 381 if ($(this).scrollTop() > 400) { 382 $('.back-to-top').fadeIn(duration); 383 } else { 384 $('.back-to-top').fadeOut(duration); 385 } 386 }); 387 388 $('.back-to-top').click(function(event) { 389 event.preventDefault(); 390 $('html, body').animate({ 391 scrollTop: 0 392 }, duration); 393 return false;
394 }); 395 $('#show-small-search').click(function() { 396 $("#small-search").slideDown(); 397 }); 398 399 if ($("#checkout_form")[0]) { 400 if (window_loc_hash == '#login') { 401 checkout_form_toggle(false); 402 } else if (window_loc_hash == '#register') { 403 checkout_form_toggle(true); 404 } 405 406 $('#checkout_login').click(function() { 407 checkout_form_toggle(false); 408 }); 409 $('#checkout_register').click(function() { 410 checkout_form_toggle(true); 411 }); 412 } 413 414 if($('#ptp').length > 0 && $('[name^=productOptions]').length > 0) { 415 price_inc_options(); 416 $("[name^=productOptions]").change(function() { 417 price_inc_options(); 418 }); 419 } 420 421 /* We must only show grid view with 1 grid column for medium */ 422 if(Foundation.utils.is_small_only()) { 423 grid_view(0); 424 $('#content_checkout_medium_up').remove(); 425 } 426 if(Foundation.utils.is_medium_up()) { 427 $('#content_checkout_small').remove(); 428 } 429}); 430 431function init_add_to_basket() { 432 $("form.add_to_basket").each(function(index, el) { 433 $(el).validate({ 434 submitHandler: function(form) { 435 add_to_basket(form); 436 } 437 }); 438 }); 439} 440 441function price_inc_options() { 442 var action = $('form.add_to_basket').attr('action'); 443 var absolute = false; 444 var total = 0; 445 var ptp = parseFloat($('#ptp').attr("data-price")); 446 var fbp = parseFloat($('#fbp').attr("data-price")); 447 var ptp_original = ptp; 448 var fbp_original = fbp; 449 var parts = action.split("?"); 450 451 if (parts.length > 1) { 452 action += "&"; 453 } else { 454 action += "?"; 455 } 456 action += '_g=ajax_price_format&price[0]='; 457 458 $("[name^=productOptions]").each(function () { 459 460 if($(this).is('input:radio') && $(this).is(':checked')) { 461 if($(this).hasClass('absolute')) { total = ptp = 0; absolute = true; } 462 total += parseFloat($(this).attr("data-price")); 463 } else if ($(this).is('select') && $(this).val()) { 464 if($("option:selected", this).hasClass('absolute')) { total = ptp = 0; absolute = true; } 465 total += parseFloat($(this).find("option:selected").attr("data-price")); 466 } else if (($(this).is('textarea') || $(this).is('input:text')) && $(this).val() !== '') { 467 if($(this).hasClass('absolute')) { total = ptp = 0; absolute = true; } 468 total += parseFloat($(this).attr("data-price")); 469 } 470 }); 471 ptp = (absolute ? total : ptp + total); 472 473 if($('#fbp').length > 0) { 474 fbp = (absolute ? total : fbp + total); 475 $.ajax({ 476 url: action + ptp + '&price[1]='+ fbp, 477 cache: true, 478 complete: function(returned) { 479 var prices = $.parseJSON(returned.responseText); 480 $('#ptp').html(prices[0]); 481 $('#fbp').html(prices[1]); 482 if (absolute && prices[0] <= prices[1]) { 483 $('#fbp').hide(); 484 $('#ptp').removeClass('sale_price'); 485 } else { 486 $('#fbp').show(); 487 $('#ptp').addClass('sale_price'); 488 } 489 } 490 }); 491 } else { 492 $.ajax({ 493 url: action + ptp, 494 cache: true, 495 complete: function(returned) { 496 var prices = $.parseJSON(returned.responseText); 497 $('#ptp').html(prices[0]); 498 } 499 }); 500 } 501} 502 503function add_to_basket(form) { 504 var add = $(form).serialize(); 505 var action = $(form).attr('action').replace(/\?.*/, ''); 506 var on_canvas_basket_content = ''; 507 var parts = action.split("?"); 508 if (parts.length > 1) { 509 action += "&"; 510 } else { 511 action += "?"; 512 } 513 $.ajax({ 514 url: action + '_g=ajaxadd', 515 type: 'POST', 516 cache: false, 517 data: add, 518 complete: function(returned) { 519 if (returned.responseText.match("Redir:")) { 520 var redir = returned.responseText.split('Redir:'); 521 window.location = redir[1]; 522 } else { 523 $('#mini-basket').replaceWith(returned.responseText); 524 on_canvas_basket_content = $('#mini-basket .box-basket-content').html(); 525 $(".right-off-canvas-menu .box-basket-content").html(on_canvas_basket_content);
526 $(".alert-box").slideUp(); 527 mini_basket_action(); 528 } 529 } 530 }); 531 return false; 532} 533 534function checkout_form_toggle(register) { 535 if (register) { 536 $("#checkout_login_form").hide(); 537 $("#checkout_register_form").slideDown(); 538 $("#payment_method").slideDown(); 539 $("#reg_password").prop('disabled', false); 540 $("#login-username").prop('disabled', true); 541 $("#login-password").prop('disabled', true); 542 //$("#login-remember").prop('disabled', true); 543 //$("#login-submit").prop('disabled', true); 544 $('#checkout_form').removeAttr("action").attr("action", '#register'); 545 } else { 546 $("#checkout_login_form").slideDown(); 547 $("#checkout_register_form").hide(); 548 $("#payment_method").hide(); 549 $("#reg_password").prop('disabled', true); 550 $("#login-username").prop('disabled', false); 551 $("#login-password").prop('disabled', false); 552 //$("#login-remember").prop('disabled', false); 553 //$("#login-submit").prop('disabled', false); 554 $('#checkout_form').removeAttr("action").attr("action", '#login'); 555 } 556} 557 558function set_product_view(delay) { 559 if ($.cookie('product_view') == 'grid') { 560 grid_view(delay, null); 561 } 562} 563 564function show_address_form() { 565 $('#register_false_address').hide(); 566 $('#checkout_register_form').show(); 567} 568 569function mini_basket_action() { 570 $('#basket-detail, #small-basket-detail').fadeIn('fast', function() { 571 $(this).delay(4000).fadeOut('slow'); 572 }); 573} 574 575function grid_view(duration, event) { 576 if (event != null) { 577 event.preventDefault(); 578 } 579 $.when($('.product_list').fadeOut(duration, function() { 580 if(Foundation.utils.is_medium_up()) { 581 $('.product_list').removeClass('small-block-grid-1'); 582 $('.product_list').addClass('small-block-grid-3'); 583 } 584 $('.grid_view').parent('dd').addClass('active'); 585 $('.list_view').parent('dd').removeClass('active'); 586 $('.product_list_view').addClass('hide'); 587 $('.product_grid_view').removeClass('hide'); 588 $('.product_grid_view .quantity').prop('disabled', false); 589 $('.product_list_view .quantity').prop('disabled', true); 590 $('.product_list_view .quantity').val('1'); 591 $('.product_list').fadeIn(duration, function() { 592 $.cookie('product_view', 'grid', {expires: 730}); 593 }); 594 })).done(function() { 595 $(document).foundation('equalizer','reflow'); 596 }); 597 return false; 598} 599 600function list_view(duration, event) { 601 if (event != null) { 602 event.preventDefault(); 603 } 604 $.when($('.product_list').fadeOut(duration, function() { 605 $('.product_list').removeClass('small-block-grid-3'); 606 $('.product_list').addClass('small-block-grid-1'); 607 $('.list_view').parent('dd').addClass('active'); 608 $('.grid_view').parent('dd').removeClass('active'); 609 $('.product_grid_view').addClass('hide'); 610 $('.product_list_view').removeClass('hide'); 611 $('.product_grid_view .quantity').prop('disabled', true); 612 $('.product_list_view .quantity').prop('disabled', false); 613 $('.product_grid_view .quantity').val('1'); 614 $('.product_list').fadeIn(duration, function() { 615 $.cookie('product_view', 'list', {expires: 730}); 616 }); 617 })).done(function() { 618 $(document).foundation('equalizer','reflow'); 619 }); 620 return false; 621} 622 623function update_quantity(rel, sign) { 624 var target = $('input[name="quantity"], input[name="quan[' + rel + ']"]'); 625 var quick_update = $('#quick_update_' + rel); 626 var original_val = $('#original_val_' + rel).text(); 627 var old_val = $(target).val(); 628 var new_val = 0; 629 630 if (sign == '+') { 631 if (old_val < 999) { 632 var new_val = +old_val + +1; 633 } else { 634 return false; 635 } 636 } else if (sign == '-') { 637 if (old_val < 1) { 638 return false; 639 } 640 var new_val = (old_val - 1); 641 } 642 $(target).val(new_val); 643 $('span.disp_quan_' + rel).text(new_val); 644 if (original_val == new_val) { 645 quick_update.slideUp(); 646 } else { 647 quick_update.slideDown(); 648 } 649 650 if (!$("#checkout_login_form")[0]) { // disable jump for basket page 651 $('#checkout_form').removeAttr("action").attr("action", '#basket_item_' + rel); 652 } 653 return false;
vendor: 1 bytes, line 654
654}
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.