1function getURLVar(key) { 2 var value = []; 3 4 var query = String(document.location).split('?'); 5 6 if (query[1]) { 7 var part = query[1].split('&'); 8 9 for (i = 0; i < part.length; i++) { 10 var data = part[i].split('='); 11 12 if (data[0] && data[1]) { 13 value[data[0]] = data[1]; 14 } 15 } 16 17 if (value[key]) { 18 return value[key]; 19 } else { 20 return ''; 21 } 22 } 23} 24 25 26 27 28 29$(document).ready(function() { 30 var w = $(window).width(); // Ïîëó÷àåì øèðèíó îêíà 31 if (w > 990) { 32 var header_height = $('body .header-container2').height(); 33 $(window).scroll(function(){ 34 if($(this).scrollTop()>header_height){ 35 $('body').addClass('').css('', header_height); 36 var header_height2 = $('').height(); 37 $('#column-left').css('top', header_height2); 38 } 39 else if ($(this).scrollTop()<header_height){ 40 $('body').removeClass('fixed').css('margin-top', 0); 41 $('#column-left').css('top2', 0); 42 } 43 }); 44 }else{ 45 $(window).scroll(function(){ 46 if($(this).scrollTop()>190){ 47 $('body').addClass(''); 48 } 49 else if ($(this).scrollTop()<190){ 50 $('body').removeClass(''); 51 } 52 }); 53 } 54 55 56 57 58 59 60 61 62 63 64 65 jQuery('.category_description_button').click(function(){ 66 jQuery(this).closest('.category_description').find('.category_description_wrapper').css('height', 'auto').addClass('open'); 67 jQuery(this).hide(); 68 }); 69 // Highlight any found errors 70 $('.text-danger').each(function() { 71 var element = $(this).parent().parent(); 72 73 if (element.hasClass('form-group')) { 74 element.addClass('has-error'); 75 } 76 }); 77 78 // Currency 79 $('#form-currency .currency-select').on('click', function(e) { 80 e.preventDefault(); 81 82 $('#form-currency input[name=\'code\']').val($(this).attr('name')); 83 84 $('#form-currency').submit(); 85 }); 86 87 // Language 88 $('#form-language .language-select').on('click', function(e) { 89 e.preventDefault(); 90 91 $('#form-language input[name=\'code\']').val($(this).attr('name')); 92 93 $('#form-language').submit(); 94 }); 95 96 /* Search */ 97 $('#search input[name=\'search\']').parent().find('button').on('click', function() { 98 var url = $('base').attr('href') + 'index.php?route=product/search'; 99 100 var value = $('#search input[name=\'search\']').val(); 101 102 if (value) { 103 url += '&search=' + encodeURIComponent(value); 104 } 105 106 location = url; 107 }); 108 109 $('#search input[name=\'search\']').on('keydown', function(e) { 110 if (e.keyCode == 13) { 111 $('#search input[name=\'search\']').parent().find('button').trigger('click'); 112 } 113 }); 114 115 // Menu 116 $('#menu .dropdown-menu').each(function() { 117 var menu = $('#menu').offset(); 118 var dropdown = $(this).parent().offset(); 119 120 var i = (dropdown.left + $(this).outerWidth()) - (menu.left + $('#menu').outerWidth()); 121 122 if (i > 0) { 123 $(this).css('margin-left', '-' + (i + 10) + 'px'); 124 } 125 }); 126 127 // Product List 128 $('#list-view').click(function() { 129 $('#content .product-grid > .clearfix').remove(); 130 131 //$('#content .product-layout').attr('class', 'product-layout product-list col-xs-12'); 132 $('#content .row > .product-grid').attr('class', 'product-layout product-list col-xs-12'); 133 $('#grid-view').removeClass('active'); 134 $('#list-view').addClass('active'); 135 136 $('.product-grid').css('height','auto'); 137 138 localStorage.setItem('display', 'list'); 139 }); 140 141 // Product Grid 142 $('#grid-view').click(function() { 143 // What a shame bootstrap does not take into account dynamically loaded columns 144 var cols = $('#column-right, #column-left').length; 145 146 if (cols == 2) { 147 $('#content .product-list').attr('class', 'product-layout product-grid col-lg-3 col-md-6 col-sm-12 col-xs-12'); 148 $('#content .product-list:nth-child(3n+1)').addClass('first-item'); 149 $('#content .product-list:nth-child(3n+3)').addClass('last-item'); 150 } else if (cols == 1) { 151 $('#content .product-list').attr('class', 'product-layout product-grid col-lg-3 col-md-4 col-sm-4 col-xs-6'); 152 $('#content .product-list:nth-child(4n+1)').addClass('first-item'); 153 $('#content .product-list:nth-child(4n+4)').addClass('last-item'); 154 if (document.documentElement.clientWidth < 1200 && document.documentElement.clientWidth > 991) { 155 $('#content .product-list').attr('class', 'product-layout product-grid col-lg-3 col-md-4 col-sm-4 col-xs-12'); 156 $('#content .product-list:nth-child(3n+1)').addClass('first-item'); 157 $('#content .product-list:nth-child(3n+3)').addClass('last-item'); 158 } 159 if (document.documentElement.clientWidth < 992 && document.documentElement.clientWidth > 767) { 160 $('#content .product-list').attr('class', 'product-layout product-grid col-lg-3 col-md-4 col-sm-4 col-xs-12'); 161 $('#content .product-list:nth-child(2n+1)').addClass('first-item'); 162 $('#content .product-list:nth-child(2n+2)').addClass('last-item'); 163 } 164 if (document.documentElement.clientWidth < 768) { 165 $('#content .product-list').attr('class', 'product-layout product-grid col-lg-3 col-md-4 col-sm-6 col-xs-6'); 166 $('#content .product-list:nth-child(2n+1)').addClass('first-item'); 167 $('#content .product-list:nth-child(2n+2)').addClass('last-item'); 168 } 169 if (document.documentElement.clientWidth < 479) { 170 $('#content .product-list').attr('class', 'product-layout product-grid col-lg-3 col-md-6 col-sm-12 col-xs-12 last-item'); 171 $('#content .product-list').attr('class', 'product-layout product-grid col-lg-3 col-md-6 col-sm-12 col-xs-12 last-item'); 172 } 173 } else { 174 $('#content .product-list').attr('class', 'product-layout product-grid col-lg-3 col-md-3 col-sm-6 col-xs-12'); 175 $('#content .product-list:nth-child(3n+1)').addClass('first-item'); 176 $('#content .product-list:nth-child(3n+3)').addClass('last-item'); 177 } 178 179 $('#list-view').removeClass('active'); 180 $('#grid-view').addClass('active'); 181 182 localStorage.setItem('display', 'grid'); 183 }); 184 185 if (localStorage.getItem('display') == 'list') { 186 $('#list-view').addClass('active'); 187 } else { 188 $('#grid-view').trigger('click'); 189 $('#grid-view').addClass('active'); 190 } 191 192 // Checkout 193 $(document).on('keydown', '#collapse-checkout-option input[name=\'email\'], #collapse-checkout-option input[name=\'password\']', function(e) { 194 if (e.keyCode == 13) { 195 $('#collapse-checkout-option #button-login').trigger('click'); 196 } 197 }); 198 199 // tooltips on hover 200 $('[data-toggle=\'tooltip\']').tooltip({container: 'body'}); 201 202 // Makes tooltips work on ajax generated content 203 $(document).ajaxStop(function() { 204 $('[data-toggle=\'tooltip\']').tooltip({container: 'body'}); 205 }); 206}); 207 208// Cart add remove functions 209var cart = { 210 'add': function(product_id, quantity) { 211 $.ajax({
212 url: 'index.php?route=checkout/cart/add', 213 type: 'post', 214 data: 'product_id=' + product_id + '&quantity=' + (typeof(quantity) != 'undefined' ? quantity : 1), 215 dataType: 'json', 216 success: function(json) { 217 if (json['redirect']) { 218 location = json['redirect']; 219 } 220 221 if (json['success']) { 222 $.notify({ 223 message: json['success'], 224 target: '_blank' 225 },{ 226 // settings 227 element: 'body', 228 position: null, 229 type: "info", 230 allow_dismiss: true, 231 newest_on_top: false, 232 placement: { 233 from: "top", 234 align: "center" 235 }, 236 offset: 0, 237 spacing: 10, 238 z_index: 9999999, 239 delay: 5000, 240 timer: 1000, 241 url_target: '_blank', 242 mouse_over: null, 243 animate: { 244 enter: 'animated fadeInDown' 245 //exit: 'animated fadeOutUp' 246 }, 247 onShow: null, 248 onShown: null, 249 onClose: null, 250 onClosed: null, 251 icon_type: 'class', 252 template: '<div data-notify="container" class="col-xs-11 col-sm-3 alert alert-success" role="alert">' + 253 '<button type="button" aria-hidden="true" class="close" data-notify="dismiss"> ×</button>' + 254 '<span data-notify="message"><i class="fa fa-check-circle"></i> {2}</span>' + 255 '<div class="progress" data-notify="progressbar">' + 256 '<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;"></div>' + 257 '</div>' + 258 '<a href="{3}" target="{4}" data-notify="url"></a>' + 259 '</div>' 260 }); 261 262 $('#cart > ul').load('index.php?route=common/cart/info ul li'); 263 $('#cart > button').html('<span id="cart-total"> ' + json['total'] + '</span>'); 264 } 265 }/*, 266 error: function(xhr, ajaxOptions, thrownError) { 267 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 268 }*/ 269 }); 270 }, 271 'update': function(key, quantity) { 272 $.ajax({ 273 url: 'index.php?route=checkout/cart/edit', 274 type: 'post', 275 data: 'key=' + key + '&quantity=' + (typeof(quantity) != 'undefined' ? quantity : 1), 276 dataType: 'json', 277 beforeSend: function() { 278 $('#cart > button').button('loading'); 279 }, 280 complete: function() { 281 $('#cart > button').button('reset'); 282 }, 283 success: function(json) { 284 // Need to set timeout otherwise it wont update the total 285 setTimeout(function () { 286 $('#cart > button').html('<span id="cart-total"> ' + json['total'] + '</span>'); 287 }, 100); 288 289 if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') { 290 location = 'index.php?route=checkout/cart'; 291 } else { 292 $('#cart > ul').load('index.php?route=common/cart/info ul li'); 293 } 294 }, 295 error: function(xhr, ajaxOptions, thrownError) { 296 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 297 } 298 }); 299 }, 300 'remove': function(key) { 301 $.ajax({ 302 url: 'index.php?route=checkout/cart/remove', 303 type: 'post', 304 data: 'key=' + key, 305 dataType: 'json', 306 beforeSend: function() { 307 $('#cart > button').button('loading'); 308 }, 309 complete: function() { 310 $('#cart > button').button('reset'); 311 }, 312 success: function(json) { 313 // Need to set timeout otherwise it wont update the total 314 setTimeout(function () { 315 $('#cart > button').html('<span id="cart-total">' + json['total'] + '</span>'); 316 }, 100); 317 318 if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') { 319 location = 'index.php?route=checkout/cart'; 320 } else { 321 $('#cart > ul').load('index.php?route=common/cart/info ul li'); 322 } 323 }, 324 error: function(xhr, ajaxOptions, thrownError) { 325 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 326 } 327 }); 328 } 329} 330 331var voucher = { 332 'add': function() { 333 334 }, 335 'remove': function(key) { 336 $.ajax({
337 url: 'index.php?route=checkout/cart/remove', 338 type: 'post', 339 data: 'key=' + key, 340 dataType: 'json', 341 beforeSend: function() { 342 $('#cart > button').button('loading'); 343 }, 344 complete: function() { 345 $('#cart > button').button('reset'); 346 }, 347 success: function(json) { 348 $('#cart-total').html(json['total']); 349 350 if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') { 351 location = 'index.php?route=checkout/cart'; 352 } else { 353 $('#cart > ul').load('index.php?route=common/cart/info ul li'); 354 $('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>'); 355 } 356 } 357 }); 358 } 359} 360 361var wishlist = { 362 'add': function(product_id) { 363 $.ajax({ 364 url: 'index.php?route=account/wishlist/add', 365 type: 'post', 366 data: 'product_id=' + product_id, 367 dataType: 'json', 368 success: function(json) { 369 if (json['success']) { 370 $.notify({ 371 message: json['success'], 372 target: '_blank' 373 },{ 374 // settings 375 element: 'body', 376 position: null, 377 type: "info", 378 allow_dismiss: true, 379 newest_on_top: false, 380 placement: { 381 from: "top", 382 align: "center" 383 }, 384 offset: 0, 385 spacing: 10, 386 z_index: 2031, 387 delay: 5000, 388 timer: 1000, 389 url_target: '_blank', 390 mouse_over: null, 391 animate: { 392 enter: 'animated fadeInDown', 393 exit: 'animated fadeOutUp' 394 }, 395 onShow: null, 396 onShown: null, 397 onClose: null, 398 onClosed: null, 399 icon_type: 'class', 400 template: '<div data-notify="container" class="col-xs-11 col-sm-3 alert alert-success" role="alert">' + 401 '<button type="button" aria-hidden="true" class="close" data-notify="dismiss"> ×</button>' + 402 '<span data-notify="message"><i class="fa fa-check-circle"></i> {2}</span>' + 403 '<div class="progress" data-notify="progressbar">' + 404 '<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;"></div>' + 405 '</div>' + 406 '<a href="{3}" target="{4}" data-notify="url"></a>' + 407 '</div>' 408 }); 409 } 410 411 if (json['info']) { 412 $.notify({ 413 message: json['info'], 414 target: '_blank' 415 },{ 416 // settings 417 element: 'body', 418 position: null, 419 type: "info", 420 allow_dismiss: true, 421 newest_on_top: false, 422 placement: { 423 from: "top", 424 align: "center" 425 }, 426 offset: 0, 427 spacing: 10, 428 z_index: 2031, 429 delay: 5000, 430 timer: 1000, 431 url_target: '_blank', 432 mouse_over: null, 433 animate: { 434 enter: 'animated fadeInDown', 435 exit: 'animated fadeOutUp' 436 }, 437 onShow: null, 438 onShown: null, 439 onClose: null, 440 onClosed: null, 441 icon_type: 'class', 442 template: '<div data-notify="container" class="col-xs-11 col-sm-3 alert alert-info" role="alert">' + 443 '<button type="button" aria-hidden="true" class="close" data-notify="dismiss"> ×</button>' + 444 '<span data-notify="message"><i class="fa fa-info"></i> {2}</span>' + 445 '<div class="progress" data-notify="progressbar">' + 446 '<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;"></div>' + 447 '</div>' + 448 '<a href="{3}" target="{4}" data-notify="url"></a>' + 449 '</div>' 450 }); 451 } 452 453 $('#wishlist-total').html(json['total']); 454 } 455 }); 456 }, 457 'remove': function() { 458 459 } 460} 461 462var compare = { 463 'add': function(product_id) { 464 $.ajax({ 465 url: 'index.php?route=product/compare/add', 466 type: 'post', 467 data: 'product_id=' + product_id, 468 dataType: 'json', 469 success: function(json) { 470 if (json['success']) { 471 $.notify({ 472 message: json['success'], 473 target: '_blank' 474 },{ 475 // settings 476 element: 'body', 477 position: null, 478 type: "info", 479 allow_dismiss: true, 480 newest_on_top: false, 481 placement: { 482 from: "top", 483 align: "center" 484 }, 485 offset: 0, 486 spacing: 10, 487 z_index: 2031, 488 delay: 5000, 489 timer: 1000, 490 url_target: '_blank', 491 mouse_over: null, 492 animate: { 493 enter: 'animated fadeInDown', 494 exit: 'animated fadeOutUp' 495 }, 496 onShow: null, 497 onShown: null, 498 onClose: null, 499 onClosed: null, 500 icon_type: 'class', 501 template: '<div data-notify="container" class="col-xs-11 col-sm-3 alert alert-success" role="alert">
501' + 502 '<button type="button" aria-hidden="true" class="close" data-notify="dismiss"> ×</button>' + 503 '<span data-notify="message"><i class="fa fa-check-circle"></i> {2}</span>' + 504 '<div class="progress" data-notify="progressbar">' + 505 '<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;"></div>' + 506 '</div>' + 507 '<a href="{3}" target="{4}" data-notify="url"></a>' + 508 '</div>' 509 }); 510 511 $('#compare-total').html(json['total']); 512 } 513 } 514 }); 515 }, 516 'remove': function() { 517 518 } 519} 520 521/* Agree to Terms */ 522$(document).delegate('.agree', 'click', function(e) { 523 e.preventDefault(); 524 525 $('#modal-agree').remove(); 526 527 var element = this; 528 529 $.ajax({ 530 url: $(element).attr('href'), 531 type: 'get', 532 dataType: 'html', 533 success: function(data) { 534 html = '<div id="modal-agree" class="modal">'; 535 html += ' <div class="modal-dialog">'; 536 html += ' <div class="modal-content">'; 537 html += ' <div class="modal-header">'; 538 html += ' <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>'; 539 html += ' <h4 class="modal-title">' + $(element).text() + '</h4>'; 540 html += ' </div>'; 541 html += ' <div class="modal-body">' + data + '</div>'; 542 html += ' </div'; 543 html += ' </div>'; 544 html += '</div>'; 545 546 $('body').append(html); 547
548 $('#modal-agree').modal('show'); 549 } 550 }); 551}); 552 553// Autocomplete */ 554(function($) { 555 $.fn.autocomplete = function(option) { 556 return this.each(function() { 557 this.timer = null; 558 this.items = new Array(); 559 560 $.extend(this, option); 561 562 $(this).attr('autocomplete', 'off'); 563 564 // Focus 565 $(this).on('focus', function() { 566 this.request(); 567 }); 568 569 // Blur 570 $(this).on('blur', function() { 571 setTimeout(function(object) { 572 object.hide(); 573 }, 200, this); 574 }); 575 576 // Keydown 577 $(this).on('keydown', function(event) { 578 switch(event.keyCode) { 579 case 27: // escape 580 this.hide(); 581 break; 582 default: 583 this.request(); 584 break; 585 } 586 }); 587 588 // Click 589 this.click = function(event) { 590 event.preventDefault(); 591 592 value = $(event.target).parent().attr('data-value'); 593 594 if (value && this.items[value]) { 595 this.select(this.items[value]); 596 } 597 } 598 599 // Show 600 this.show = function() { 601 var pos = $(this).position(); 602 603 $(this).siblings('ul.dropdown-menu').css({ 604 top: pos.top + $(this).outerHeight(), 605 left: pos.left 606 }); 607 608 $(this).siblings('ul.dropdown-menu').show(); 609 } 610 611 // Hide 612 this.hide = function() { 613 $(this).siblings('ul.dropdown-menu').hide(); 614 } 615 616 // Request 617 this.request = function() { 618 clearTimeout(this.timer); 619 620 this.timer = setTimeout(function(object) { 621 object.source($(object).val(), $.proxy(object.response, object)); 622 }, 200, this); 623 } 624 625 // Response 626 this.response = function(json) { 627 html = ''; 628 629 if (json.length) { 630 for (i = 0; i < json.length; i++) { 631 this.items[json[i]['value']] = json[i]; 632 } 633 634 for (i = 0; i < json.length; i++) { 635 if (!json[i]['category']) { 636 html += '<li data-value="' + json[i]['value'] + '"><a href="#">' + json[i]['label'] + '</a></li>'; 637 } 638 } 639 640 // Get all the ones with a categories 641 var category = new Array(); 642 643 for (i = 0; i < json.length; i++) { 644 if (json[i]['category']) { 645 if (!category[json[i]['category']]) { 646 category[json[i]['category']] = new Array(); 647 category[json[i]['category']]['name'] = json[i]['category']; 648 category[json[i]['category']]['item'] = new Array(); 649 } 650 651 category[json[i]['category']]['item'].push(json[i]); 652 } 653 } 654 655 for (i in category) { 656 html += '<li class="dropdown-header">' + category[i]['name'] + '</li>'; 657 658 for (j = 0; j < category[i]['item'].length; j++) { 659 html += '<li data-value="' + category[i]['item'][j]['value'] + '"><a href="#"> ' + category[i]['item'][j]['label'] + '</a></li>'; 660 } 661 } 662 } 663 664 if (html) { 665 this.show(); 666 } else { 667 this.hide(); 668 } 669 670 $(this).siblings('ul.dropdown-menu').html(html); 671 } 672 673 $(this).after('<ul class="dropdown-menu"></ul>'); 674 $(this).siblings('ul.dropdown-menu').delegate('a', 'click', $.proxy(this.click, this)); 675 676 }); 677 } 678})(window.jQuery);
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.