1// Resize reCAPTCHA to fit width of container 2// Since it has a fixed width, we're scaling 3// using CSS3 transforms 4// ------------------------------------------ 5// captchaScale = containerWidth / elementWidth 6 7function scaleCaptcha(elementWidth) { 8 // Width of the reCAPTCHA element, in pixels 9 var reCaptchaWidth = 304; 10 // Get the containing element's width 11 var containerWidth = jQuery('#google_recaptcha').width(); 12 13 // Only scale the reCAPTCHA if it won't fit 14 // inside the container 15 if(reCaptchaWidth > containerWidth) { 16 // Calculate the scale 17 var captchaScale = containerWidth / reCaptchaWidth; 18 // Apply the transformation 19 jQuery('.g-recaptcha').css({ 20 'transform':'scale('+captchaScale+')' 21 }); 22 } 23} 24 25jQuery(function() { 26 27 // Initialize scaling 28 jQuery(window).load(function(){ 29 scaleCaptcha(); 30 }); 31 32 // Update scaling on window resize 33 // Uses jQuery throttle plugin to limit strain on the browser 34 jQuery(window).resize( jQuery.throttle( 100, scaleCaptcha ) ); 35 36}); 37 38/* 39* jQuery throttle / debounce - v1.1 - 3/7/2010 40* http://benalman.com/projects/jquery-throttle-debounce-plugin/ 41* 42* Copyright (c) 2010 "Cowboy" Ben Alman 43* Dual licensed under the MIT and GPL licenses. 44* http://benalman.com/about/license/ 45*/ 46(function(b,c){var $=b.jQuery||b.Cowboy||(b.Cowboy={}),a;$.throttle=a=function(e,f,j,i){var h,d=0;if(typeof f!=="boolean"){i=j;j=f;f=c}function g(){var o=this,m=+new Date()-d,n=arguments;function l(){d=+new Date();j.apply(o,n)}function k(){h=c}if(i&&!h){l()}h&&clearTimeout(h);if(i===c&&m>e){l()}else{if(f!==true){h=setTimeout(i?k:l,i===c?e-m:e)}}}if($.guid){g.guid=j.guid=j.guid||$.guid++}return g};$.debounce=function(d,e,f){return f===c?a(d,e,false):a(d,f,e!==false)}})(this); 47 48 49 50var loading = { 51 timeout_period : 300000, 52 timeoutObj : null, 53 start : function(msg) { 54 $( "body" ).addClass ( "loading" ); 55 if(this.timeoutObj){ 56 clearTimeout(this.timeoutObj); 57 this.timeoutObj = null; 58 } 59 this.timeoutObj = setTimeout(function () { 60 alert("This action took too long to respond. You may want to refresh the page and try again."); 61 }, this.timeout_period); 62 }, 63 64 end : function() { 65 clearTimeout ( this.timeoutObj ); 66 this.timeoutObj = null; 67 $( "body" ).removeClass ( "loading" ); 68 } 69}; 70 71function getURLVar(key) { 72 var value = []; 73 74 var query = String(document.location).split('?'); 75 76 if (query[1]) { 77 var part = query[1].split('&'); 78 79 for (i = 0; i < part.length; i++) { 80 var data = part[i].split('='); 81 82 if (data[0] && data[1]) { 83 value[data[0]] = data[1]; 84 } 85 } 86 87 if (value[key]) { 88 return value[key]; 89 } else { 90 return ''; 91 } 92 } 93} 94 95$(document).ready(function() { 96 $('.dropdown-submenu a[href=\'#\']').on('click', function(e){ 97 e.preventDefault(); 98 }); 99 100 // Highlight any found errors 101 $('.text-danger').each(function() { 102 var element = $(this).parent().parent(); 103 104 if (element.hasClass('form-group')) { 105 element.addClass('has-error'); 106 } 107 }); 108 109 // Currency 110 $('#form-currency .currency-select').on('click', function(e) { 111 e.preventDefault(); 112 113 $('#form-currency input[name=\'code\']').val($(this).attr('name')); 114 115 $('#form-currency').submit(); 116 }); 117 118 // Language 119 $('#form-language .language-select').on('click', function(e) { 120 e.preventDefault(); 121 122 $('#form-language input[name=\'code\']').val($(this).attr('name')); 123 124 $('#form-language').submit(); 125 }); 126 127 /* Search */ 128 var url = $('base').attr('href'); 129 $('.search-custom button').on('click', function(){ 130 var value = $(this).prev().val(); 131 if ($('body').hasClass('short_hand')) { 132 url += 'search'; 133 } 134 else { 135 url += 'index.php?route=product/search'; 136 } 137 138 if (value) { 139 url += '&search=' + encodeURIComponent(value); 140 } 141 142 location = url; 143 }); 144 145 $('.search-custom input[name=\'search\']').on('keydown', function (e) { 146 if (e.keyCode == 13) { 147 $(this).next().trigger('click'); 148 } 149 }); 150 151 // Checkout 152 $(document).on('keydown', '#collapse-checkout-option input[name=\'email\'], #collapse-checkout-option input[name=\'password\']', function(e) { 153 if (e.keyCode == 13) { 154 $('#collapse-checkout-option #button-login').trigger('click'); 155 } 156 }); 157 158 // tooltips on hover 159 $('.desktop [data-toggle=\'tooltip\']').tooltip({container: 'body'}); 160 161 // Makes tooltips work on ajax generated content 162 $(document).ajaxStop(function() { 163 $('.desktop [data-toggle=\'tooltip\']').tooltip({container: 'body'}); 164 }); 165 166}); 167 168// Cart add remove functions 169var clicked = 0; 170var cart = { 171 'add': function(product_id, quantity) { 172 $.ajax({
173 url: 'index.php?route=checkout/cart/add', 174 type: 'post', 175 data: 'product_id=' + product_id + '&quantity=' + (typeof(quantity) != 'undefined' ? quantity : 1), 176 dataType: 'json', 177 beforeSend: function() { 178 $('#cart > button').button('loading'); 179 }, 180 complete: function() { 181 $('#cart > button').button('reset'); 182 fbq('track', 'AddToCart'); 183 }, 184 success: function(json) { 185 $('.alert, .text-danger').remove(); 186 187 if (json['redirect']) { 188 // comment below to prevent issue like footer alignment gone when adding product to cart in product listing 189 // $('body').removeAttr('style'); 190 setTimeout(function(){ 191 location = json['redirect']; 192 }, 1000); 193 } 194 195 if (json['success']) { 196 // Need to set timeout otherwise it wont update the total 197 setTimeout(function () { 198 $('#cart-quantity-total').text(json['total_quantity']); 199 $('#cart-total').text(json['total']); 200 }, 100); 201 202 swal({ 203 title: json['success_title'], 204 html: json['success'], 205 type: "success" 206 }); 207 208 $('#cart > ul').load('index.php?route=common/cart/info ul > *'); 209 } 210 }, 211 error: function(xhr, ajaxOptions, thrownError) { 212 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 213 } 214 }); 215 }, 216 'remove': function(key) { 217 $.ajax({ 218 url: 'index.php?route=checkout/cart/remove', 219 type: 'post', 220 data: 'key=' + key, 221 dataType: 'json', 222 beforeSend: function() { 223 $('#cart > button').button('loading'); 224 }, 225 complete: function() { 226 $('#cart > button').button('reset'); 227 }, 228 success: function(json) { 229 // Need to set timeout otherwise it wont update the total 230 setTimeout(function () { 231 $('#cart-quantity-total').text(json['total_quantity']); 232 $('#cart-total').text(json['total']); 233 }, 100); 234 235 if ($('body.short_hand').length ){ 236 if (location.toString().indexOf('cart') > 1 || location.toString().indexOf('checkout') > 1 ){ 237 location.reload(); 238 } 239 else{ 240 $('#cart > ul').load('index.php?route=common/cart/info ul > *'); 241 242 swal({ 243 title: json['success_remove_title'], 244 html: json['success'], 245 type: "success" 246 }); 247 } 248 } 249 else{ 250 if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout' || getURLVar('route') == 'quickcheckout/checkout') { 251 location = 'index.php?route=checkout/cart'; 252 } else { 253 $('#cart > ul').load('index.php?route=common/cart/info ul > *'); 254 255 swal({ 256 title: json['success_remove_title'], 257 html: json['success'], 258 type: "success" 259 }); 260 } 261 } 262 }, 263 error: function(xhr, ajaxOptions, thrownError) { 264 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 265 } 266 }); 267 } 268} 269 270var voucher = { 271 'add': function() { 272 273 }, 274 'remove': function(key) { 275 $.ajax({ 276 url: 'index.php?route=checkout/cart/remove', 277 type: 'post', 278 data: 'key=' + key, 279 dataType: 'json', 280 beforeSend: function() { 281 $('#cart > button').button('loading'); 282 }, 283 complete: function() { 284 $('#cart > button').button('reset'); 285 }, 286 success: function(json) { 287 // Need to set timeout otherwise it wont update the total 288 setTimeout(function () { 289 $('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>'); 290 }, 100); 291 292 if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') { 293 location = 'index.php?route=checkout/cart'; 294 } else { 295 $('#cart > ul').load('index.php?route=common/cart/info ul > *'); 296 } 297 }, 298 error: function(xhr, ajaxOptions, thrownError) { 299 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 300 } 301 }); 302 } 303} 304 305var wishlist = { 306 'add': function(product_id) { 307 $.ajax({ 308 url: 'index.php?route=account/wishlist/add', 309 type: 'post', 310 data: 'product_id=' + product_id, 311 dataType: 'json', 312 success: function(json) { 313 $('.alert').remove(); 314 315 if (json['redirect']) { 316 location = json['redirect']; 317 } 318 319 if (json['success']) { 320 // $('#content').parent().before('<div class="alert alert-success"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 321 swal({ 322 title: json['success_title'], 323 html: json['success'], 324 type: "success" 325 });
326 } 327 328 $('#wishlist-total span').html(json['total']); 329 $('#wishlist-total').attr('title', json['total']); 330 331 fbq('track', 'AddToWishlist'); 332 333 //$('html, body').animate({ scrollTop: 0 }, 'slow'); 334 }, 335 error: function(xhr, ajaxOptions, thrownError) { 336 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 337 } 338 }); 339 }, 340 'remove': function() { 341 342 } 343} 344 345var compare = { 346 'add': function(product_id) { 347 $.ajax({ 348 url: 'index.php?route=product/compare/add', 349 type: 'post', 350 data: 'product_id=' + product_id, 351 dataType: 'json', 352 success: function(json) { 353 $('.alert').remove(); 354 355 if (json['success']) { 356 // $('#content').parent().before('<div class="alert alert-success"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 357 358 $('#compare-total').html(json['total']); 359 360 swal({ 361 title: json['success_title'], 362 html: json['success'], 363 type: "success" 364 }); 365 366 //$('html, body').animate({ scrollTop: 0 }, 'slow'); 367 } 368 }, 369 error: function(xhr, ajaxOptions, thrownError) { 370 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 371 } 372 }); 373 }, 374 'remove': function() { 375 376 } 377} 378 379/* Agree to Terms */ 380$(document).delegate('.agree', 'click', function(e) { 381 e.preventDefault(); 382 383 $('#modal-agree').remove(); 384 385 var element = this; 386 387 $.ajax({ 388 url: $(element).attr('href'), 389 type: 'get', 390 dataType: 'html', 391 success: function(data) { 392 html = '<div id="modal-agree" class="modal">'; 393 html += ' <div class="modal-dialog">'; 394 html += ' <div class="modal-content">'; 395 html += ' <div class="modal-header">'; 396 html += ' <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>'; 397 html += ' <h4 class="modal-title">' + $(element).text() + '</h4>'; 398 html += ' </div>'; 399 html += ' <div class="modal-body">' + data + '</div>'; 400 html += ' </div'; 401 html += ' </div>'; 402 html += '</div>'; 403 404 $('body').append(html); 405
406 $('#modal-agree').modal('show'); 407 } 408 }); 409}); 410 411// Autocomplete */ 412(function($) { 413 $.fn.autocomplete = function(option) { 414 return this.each(function() { 415 this.timer = null; 416 this.items = new Array(); 417 418 $.extend(this, option); 419 420 $(this).attr('autocomplete', 'off'); 421 422 // Focus 423 $(this).on('focus', function() { 424 this.request(); 425 }); 426 427 // Blur 428 $(this).on('blur', function() { 429 setTimeout(function(object) { 430 object.hide(); 431 }, 200, this); 432 }); 433 434 // Keydown 435 $(this).on('keydown', function(event) { 436 switch(event.keyCode) { 437 case 27: // escape 438 this.hide(); 439 break; 440 default: 441 this.request(); 442 break; 443 } 444 }); 445 446 // Click 447 this.click = function(event) { 448 event.preventDefault(); 449 450 value = $(event.target).parent().attr('data-value'); 451 452 if (value && this.items[value]) { 453 this.select(this.items[value]); 454 } 455 } 456 457 // Show 458 this.show = function() { 459 var pos = $(this).position(); 460 461 $(this).siblings('ul.dropdown-menu').css({ 462 top: pos.top + $(this).outerHeight(), 463 left: pos.left 464 }); 465 466 $(this).siblings('ul.dropdown-menu').show(); 467 } 468 469 // Hide 470 this.hide = function() { 471 $(this).siblings('ul.dropdown-menu').hide(); 472 } 473 474 // Request 475 this.request = function() { 476 clearTimeout(this.timer); 477 478 this.timer = setTimeout(function(object) { 479 object.source($(object).val(), $.proxy(object.response, object)); 480 }, 200, this); 481 } 482 483 // Response 484 this.response = function(json) { 485 html = ''; 486 487 if (json.length) { 488 for (i = 0; i < json.length; i++) { 489 this.items[json[i]['value']] = json[i]; 490 } 491 492 for (i = 0; i < json.length; i++) { 493 if (!json[i]['category']) { 494 html += '<li data-value="' + json[i]['value'] + '"><a href="#">' + json[i]['label'] + '</a></li>'; 495 } 496 } 497 498 // Get all the ones with a categories 499 var category = new Array(); 500 501 for (i = 0; i < json.length; i++) { 502 if (json[i]['category']) { 503 if (!category[json[i]['category']]) { 504 category[json[i]['category']] = new Array(); 505 category[json[i]['category']]['name'] = json[i]['category']; 506 category[json[i]['category']]['item'] = new Array(); 507 } 508 509 category[json[i]['category']]['item'].push(json[i]); 510 } 511 } 512 513 for (i in category) { 514 html += '<li class="dropdown-header">' + category[i]['name'] + '</li>'; 515 516 for (j = 0; j < category[i]['item'].length; j++) { 517 html += '<li data-value="' + category[i]['item'][j]['value'] + '"><a href="#"> ' + category[i]['item'][j]['label'] + '</a></li>'; 518 } 519 } 520 } 521 522 if (html) { 523 this.show(); 524 } else { 525 this.hide(); 526 } 527 528 $(this).siblings('ul.dropdown-menu').html(html); 529 } 530 531 $(this).after('<ul class="dropdown-menu"></ul>'); 532 $(this).siblings('ul.dropdown-menu').delegate('a', 'click', $.proxy(this.click, this)); 533 534 }); 535 } 536})(window.jQuery); 537 538// product change image when hover - product/category 539$(document).ready(function() { 540 $('.product-block') 541 .mouseout(function() { 542 if ($(this).find('.img2').length > 0) { 543 $(this).find('.img2').hide(); 544 $(this).find('.img1').show(); 545 } 546 }) 547 .mouseover(function() { 548 if ($(this).find('.img2').length > 0) { 549 $(this).find('.img1').hide(); 550 $(this).find('.img2').show(); 551 } 552 }); 553}); 554// product change image when hover - product/category 555 556// options in product list 557$(document).ready(function() { 558 $('.btn-cart').on('click', function() { 559 var product_id = $(this).data('product-id'); 560 if($('#input-quantity-' + product_id).val() > 0) { 561 $.ajax({ 562 url: 'index.php?route=checkout/cart/add', 563 type: 'post', 564 data: $('#product-' + product_id + ' input[type=\'text\'], #product-' + product_id + ' input[type=\'hidden\'], #product-' + product_id + ' input[type=\'radio\']:checked, #product-' + product_id + ' input[type=\'checkbox\']:checked, #product-' + product_id + ' select, #product-' + product_id + ' textarea'), 565 dataType: 'json', 566 success: function (json) { 567 568 $('.alert, .text-danger').remove(); 569 $('.form-group').removeClass('has-error'); 570 571 if (json['redirect']) { 572 // comment below to prevent issue like footer alignment gone when adding product to cart in product listing 573 // $('body').removeAttr('style'); 574 setTimeout(function(){ 575 location = json['redirect']; 576 }, 1000); 577 } 578 579 580 if (json['error']) { 581 if (json['error']['option']) { 582 for (i in json['error']['option']) {
583 var element = $('#input-option' + i.replace('_', '-')); 584 585 if (element.parent().hasClass('input-group')) { 586 element.parent().after('<div class="text-danger">' + json['error']['option'][i] + '</div>'); 587 } else { 588 element.after('<div class="text-danger">' + json['error']['option'][i] + '</div>'); 589 } 590 } 591 } 592 593 if (json['error']['recurring']) { 594 $('select[name=\'recurring_id\']').after('<div class="text-danger">' + json['error']['recurring'] + '</div>'); 595 } 596 597 // Highlight any found errors 598 $('.text-danger').parent().addClass('has-error'); 599 } 600 601 if (json['success']) { 602 //$('.breadcrumb').after('<div class="alert alert-success">' + json['success'] + '<button type="button" class="close" data-dismiss="alert">×</button></div>'); 603 604 swal({ 605 title: json['success_title'], 606 html: json['success'], 607 type: "success" 608 }); 609 610 setTimeout(function () { 611 $('#cart-quantity-total').text(json['total_quantity']); 612 $('#cart-total').text(json['total']); 613 }, 100); 614 615 $('#cart > ul').load('index.php?route=common/cart/info ul > *'); 616 } 617 618 if(json['error_stock_add']){ 619 swal({ 620 title: json['error_stock_add_title'], 621 html: json['error_stock_add'], 622 type: "error" 623 }); 624 } 625 626 if(json['error_outofstock']){ 627 swal({
628 title: json['error_outofstock_title'], 629 html: json['error_outofstock'], 630 type: "error" 631 }); 632 } 633 }, 634 error: function (xhr, ajaxOptions, thrownError) { 635 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 636 } 637 }); 638 } 639 }); 640 $('.btn-enquiry').on('click', function () { 641 var product_id = $(this).data('product-id'); 642 if($('#input-quantity-' + product_id).val() > 0) { 643 $.ajax({ 644 url: 'index.php?route=enquiry/cart/add', 645 type: 'post', 646 data: $('#product-' + product_id + ' input[type=\'text\'], #product-' + product_id + ' input[type=\'hidden\'], #product-' + product_id + ' input[type=\'radio\']:checked, #product-' + product_id + ' input[type=\'checkbox\']:checked, #product-' + product_id + ' select, #product-' + product_id + ' textarea'), 647 dataType: 'json', 648 beforeSend: function () { 649 $('.btn-enquiry').button('loading'); 650 }, 651 complete: function () { 652 $('.btn-enquiry').button('reset'); 653 }, 654 success: function (json) { 655 $('.alert, .text-danger').remove(); 656 $('.form-group').removeClass('has-error'); 657 658 if (json['redirect']) { 659 // comment below to prevent issue like footer alignment gone when adding product to cart in product listing 660 // $('body').removeAttr('style'); 661 setTimeout(function(){ 662 location = json['redirect']; 663 }, 1000); 664 } 665 666 if (json['error']) { 667 if (json['error']['option']) { 668 for (i in json['error']['option']) { 669 var element = $('#input-option' + i.replace('_', '-')); 670 671 if (element.parent().hasClass('input-group')) { 672 element.parent().after('<div class="text-danger">' + json['error']['option'][i] + '</div>'); 673 } else { 674 element.after('<div class="text-danger">' + json['error']['option'][i] + '</div>'); 675 } 676 } 677 } 678 679 if (json['error']['recurring']) { 680 $('select[name=\'recurring_id\']').after('<div class="text-danger">' + json['error']['recurring'] + '</div>'); 681 } 682 683 // Highlight any found errors 684 $('.text-danger').parent().addClass('has-error'); 685 } 686 687 if (json['success']) { 688 //$('.breadcrumb').after('<div class="alert alert-success">' + json['success'] + '<button type="button" class="close" data-dismiss="alert">×</button></div>'); 689 690 swal({ 691 title: json['success_title'], 692 html: json['success'], 693 type: "success" 694 }); 695 696 setTimeout(function () { 697 $('#enquiry-quantity-total').text(json['total_quantity']); 698 $('#enquiry-total').text(json['total']); 699 }, 100); 700 701 $('#enquiry > ul').load('index.php?route=common/enquiry/info ul > *'); 702 } 703 }, 704 error: function (xhr, ajaxOptions, thrownError) { 705 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 706 } 707 }); 708 } 709 }); 710}); 711// options in product list
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.