1function moveQuantityForMobileCart() { 2 3 var windowWidth = $(window).width(); 4 if (windowWidth < 769) { 5 if ($('td.quantity').html() !== '') { 6 $('span.mobile_quantity').html($('td.quantity').html()); 7 $('td.quantity').html(''); 8 } 9 } else { 10 if ($('span.mobile_quantity').html() !== '') { 11 $('td.quantity').html($('span.mobile_quantity').html()); 12 $('span.mobile_quantity').html(''); 13 } 14 } 15 16} 17 18 19function addDividerToCategories() { 20 21 var windowWidth = $(window).width(); 22 if (windowWidth < 1171) { 23 $(".box-category3 > div:nth-child(2n)").after("<div class=\"break\"></div>"); 24 } else { 25 $(".box-category3 > div:nth-child(3n)").after("<div class=\"break\"></div>"); 26 } 27 $(".box-category3").after("<div class=\"break\"></div>"); 28 29} 30 31function initMenu() { 32 $('#menu ul').hide(); 33 $('.active').next('ul').show(); 34// $('#menu ul.active').show(); 35 $('#menu > li > a').click( 36 function() { 37 38 39 40 $('.nav_li a').removeClass('active'); 41 42 $(this).addClass('active'); 43 44 var checkElement = $(this).next(); 45 if((checkElement.is('ul')) && (checkElement.is(':visible'))) { 46 return false; 47 } 48 if((checkElement.is('ul')) && (!checkElement.is(':visible'))) { 49 $('#menu ul:visible').slideUp('normal'); 50 $('#menu ul:visible').slideUp('normal'); 51 checkElement.slideDown('normal'); 52 return false; 53 } 54 } 55 ); 56} 57 58function closePopup() { 59 60 $('.success').remove(); 61 $('.popup_bg_full').fadeOut('slow'); 62 63} 64 65 66function openReviewsTab() { 67 68 var windowWidth = $(window).width(); 69 if (windowWidth < 769) { 70 $('a.open-mobile-review').trigger('click'); 71 $('html,body').animate({ 72 scrollTop: $('.nav.nav-tabs.for-mobile').offset().top 73 }, 'fast'); 74 } else { 75 $('a[href=\'#tab-review\']').trigger('click'); 76 $('html,body').animate({ 77 scrollTop: $('.nav.nav-tabs.for-desktop').offset().top 78 }, 'fast'); 79 } 80 81} 82 83function scrollToTopBtn() { 84 85 var windowWidth = $(window).width(); 86 var windowHeight = $(window).height(); 87 var containerWidth = $('#container').width(); 88 var footerHeight = $('#container_footer_wrapper').height(); 89 var final_point_left = (windowWidth/2)+(containerWidth/2); 90 var final_point_bottom = windowHeight-footerHeight; 91 if (windowWidth < 1171) { 92 $('.scrollToTop').css('left', windowWidth - 100 + 'px'); 93 $('.scrollToTop').css('bottom', footerHeight + 50 + 'px'); 94 } else { 95 $('.scrollToTop').css('left', final_point_left + 30 + 'px'); 96 $('.scrollToTop').css('bottom', footerHeight + 60 + 'px'); 97 } 98 $(window).scroll(function(){ 99 if ($(this).scrollTop() > 1000) { 100 $('.scrollToTop').fadeIn(); 101 } else { 102 $('.scrollToTop').fadeOut(); 103 } 104 }); 105 $('.scrollToTop').click(function(){ 106 $('html, body').animate({scrollTop : 0},800); 107 return false; 108 }); 109 110} 111 112 113function getURLVar(key) { 114 var value = []; 115 116 var query = String(document.location).split('?'); 117 118 if (query[1]) { 119 var part = query[1].split('&'); 120 121 for (i = 0; i < part.length; i++) { 122 var data = part[i].split('='); 123 124 if (data[0] && data[1]) { 125 value[data[0]] = data[1]; 126 } 127 } 128 129 if (value[key]) { 130 return value[key]; 131 } else { 132 return ''; 133 } 134 } 135} 136 137$(document).ready(function() { 138 139 initMenu(); 140 141 var isiPhone = navigator.userAgent.toLowerCase().indexOf("iphone"); 142 var isiPad = navigator.userAgent.toLowerCase().indexOf("ipad"); 143 var isiPod = navigator.userAgent.toLowerCase().indexOf("ipod"); 144 145 if (isiPhone > -1 || isiPad > -1 || isiPod > -1) { 146 $('select:not(.option-choice)').selectbox(); 147 } else { 148 $('select').selectbox(); 149 } 150 151 152 /*$('input[type=radio]').iCheck({ 153 labelHover: false, 154 cursor: true 155 }); 156 if(typeof simplecheckout_reload == 'function'){ 157 $('input[type=radio]').on('ifChecked', function(event){ 158 simplecheckout_reload('autocomplete_changed'); 159 }); 160 };*/ 161 162 /** reload mobile cart**/ 163 var qty = $('.cart_qty:first').text(); 164 var iNum = parseInt(qty); 165 if (iNum > 0) { 166 $('.mobile_cart_qty').show(); 167 $('.mobile_cart_qty').text(qty); 168 } 169 170 moveQuantityForMobileCart(); 171 addDividerToCategories(); 172 173 /* MOBILE MENU */ 174 $('.mobile_menu').bind('click', function() { 175 if ($($('.main_search')).is(":visible")) { 176 $('.main_search').hide(); 177 $('.popup_bg').hide(); 178 } 179 $('ul#menu').slideToggle(); 180 $('.popup_bg').toggle(); 181 }); 182 $('.mobile_search').bind('click', function() { 183 if ($($('ul#menu')).is(":visible")) { 184 $('ul#menu').hide(); 185 $('.popup_bg').hide(); 186 } 187 $('.main_search').slideToggle(); 188 $('.popup_bg').toggle(); 189 }); 190 191 192 // scroll to top 193 scrollToTopBtn(); 194
195 // Highlight any found errors 196 $('.text-danger').each(function() { 197 var element = $(this).parent().parent(); 198 199 if (element.hasClass('form-group')) { 200 element.addClass('has-error'); 201 } 202 }); 203 204 // Currency 205 $('#currency .currency-select').on('click', function(e) { 206 e.preventDefault(); 207 208 $('#currency input[name=\'code\']').attr('value', $(this).attr('name')); 209 210 $('#currency').submit(); 211 }); 212 213 // Language 214 $('#language a').on('click', function(e) { 215 e.preventDefault(); 216 217 $('#language input[name=\'code\']').attr('value', $(this).attr('href')); 218 219 $('#language').submit(); 220 }); 221 222 /* Search #1 */ 223 $('.main_search .button-search').bind('click', function() { 224 url = $('base').attr('href') + 'index.php?route=product/search'; 225 226 var filter_name = $("input.filter_name").val(); 227 228 if (filter_name) { 229 url += '&search=' + encodeURIComponent(filter_name); 230 } 231 232 location = url; 233 }); 234 235 /* Search #1 */ 236 $('.main_search.desktop .button-search').bind('click', function() { 237 url = $('base').attr('href') + 'index.php?route=product/search'; 238 239 var filter_name = $(".main_search.desktop input.filter_name").val(); 240 241 if (filter_name) { 242 url += '&search=' + encodeURIComponent(filter_name); 243 } 244 245 location = url; 246 }); 247 248 $('.main_search.desktop input.filter_name').on('keydown', function(e) { 249 if (e.keyCode == 13) { 250 $('.main_search.desktop .button-search').trigger('click'); 251 } 252 }); 253 254 /* Search #2 */ 255 $('.main_search.tablet .button-search').bind('click', function() { 256 url = $('base').attr('href') + 'index.php?route=product/search'; 257 258 var filter_name = $(".main_search.tablet input.filter_name").val(); 259 260 if (filter_name) { 261 url += '&search=' + encodeURIComponent(filter_name); 262 } 263 264 location = url; 265 }); 266 267 $('.main_search.tablet input.filter_name').on('keydown', function(e) { 268 if (e.keyCode == 13) { 269 $('.main_search.tablet .button-search').trigger('click'); 270 } 271 }); 272 273 /* Search #2 */ 274 $('.main_search.mobile .button-search').bind('click', function() { 275 url = $('base').attr('href') + 'index.php?route=product/search'; 276 277 var filter_name = $(".main_search.mobile input.filter_name").val(); 278 279 if (filter_name) { 280 url += '&search=' + encodeURIComponent(filter_name); 281 } 282 283 location = url; 284 }); 285 286 $('.main_search.mobile input.filter_name').on('keydown', function(e) { 287 if (e.keyCode == 13) { 288 $('.main_search.mobile .button-search').trigger('click'); 289 } 290 }); 291 292 // popup cart announcer 293 $('.success img, .warning img, .attention img, .information img').on('click', function() { 294 $(this).parent().fadeOut('slow', function() { 295 $(this).remove(); 296 }); 297 $('.popup_bg_full').fadeOut('slow'); 298 }); 299 300 $('.success a.go_back').on('click', function(e) { 301 e.preventDefault(); 302 $(this).parent().parent().fadeOut('slow', function() { 303 $(this).remove(); 304 }); 305 $('.popup_bg_full').fadeOut('slow'); 306 }); 307 308 309 // Menu 310 $('#menu .dropdown-menu').each(function() { 311 var menu = $('#menu').offset(); 312 var dropdown = $(this).parent().offset(); 313 314 var i = (dropdown.left + $(this).outerWidth()) - (menu.left + $('#menu').outerWidth()); 315 316 if (i > 0) { 317 $(this).css('margin-left', '-' + (i + 5) + 'px'); 318 } 319 }); 320 321 // Product List 322 $('#list-view').click(function() { 323 $('#content .product-grid > .clearfix').remove(); 324 325 //$('#content .product-layout').attr('class', 'product-layout product-list col-xs-12'); 326 $('#content .row > .product-grid').attr('class', 'product-layout product-list col-xs-12'); 327 328 localStorage.setItem('display', 'list'); 329 }); 330 331 // Product Grid 332 $('#grid-view').click(function() { 333 // What a shame bootstrap does not take into account dynamically loaded columns 334 cols = $('#column-right, #column-left').length; 335 336 if (cols == 2) { 337 $('#content .product-list').attr('class', 'product-layout product-grid col-lg-6 col-md-6 col-sm-12 col-xs-12'); 338 } else if (cols == 1) { 339 $('#content .product-list').attr('class', 'product-layout product-grid col-lg-4 col-md-4 col-sm-6 col-xs-12'); 340 } else { 341 $('#content .product-list').attr('class', 'product-layout product-grid col-lg-3 col-md-3 col-sm-6 col-xs-12'); 342 } 343 344 localStorage.setItem('display', 'grid'); 345 }); 346 347 if (localStorage.getItem('display') == 'list') { 348 $('#list-view').trigger('click'); 349 } else { 350 $('#grid-view').trigger('click'); 351 } 352 353 // Checkout 354 $(document).on('keydown', '#collapse-checkout-option input[name=\'email\'], #collapse-checkout-option input[name=\'password\']', function(e) { 355 if (e.keyCode == 13) { 356 $('#collapse-checkout-option #button-login').trigger('click'); 357 } 358 }); 359 360 // tooltips on hover 361 $('[data-toggle=\'tooltip\']').tooltip({container: 'body'}); 362 363 // Makes tooltips work on ajax generated content 364 $(document).ajaxStop(function() { 365 $('[data-toggle=\'tooltip\']').tooltip({container: 'body'}); 366 }); 367 368 // remove TITLE on hover 369 $('ul#menu ul.children li.drop-link a').hover(function(e){ 370 //$(this).attr('data-title', $(this).attr('title')); 371 $(this).removeAttr('title'); 372 }); 373 374 // insert dash 375 $("ul#menu li.nav_li > a").text(function (_, ctx) { 376 return ctx.replace("ШаÑовой кÑан Ñ ÑлекÑÑопÑиводом", "ШаÑовой кÑан Ñ ÑлекÑÑо-пÑиводом"); 377 }); 378 379 // Product tabs for mobile 380 $('a.open-mobile-desc').on('click', function(e) { 381 e.preventDefault(); 382 $('div.tab-for-inside').hide(); 383 $('div#mobile-desc').show(); 384 $('div#tab-description-mobile').show(); 385 }); 386 $('a.open-mobile-attrib').on('click', function(e) { 387 e.preventDefault(); 388 $('div.tab-for-inside').slideUp(); 389 $('div#mobile-attrib').show(); 390 $('div#tab-specification-mobile').show(); 391 }); 392 $('a.open-mobile-related').on('click', function(e) { 393 e.preventDefault(); 394 $('div.tab-for-inside').hide(); 395 $('div#mobile-related').show(); 396 $('div#tab-related-mobile').show(); 397 }); 398 $('a.open-mobile-similar').on('click', function(e) { 399 e.preventDefault(); 400 $('div.tab-for-inside').hide(); 401 $('div#mobile-similar').show(); 402 $('div#tab-similar-mobile').show(); 403 }); 404 $('a.open-mobile-review').on('click', function(e) { 405 e.preventDefault(); 406 $('div.tab-for-inside').hide(); 407 $('div#mobile-review').show(); 408 $('div#tab-review-mobile').show(); 409 }); 410 411}); 412 413 414$(window).resize(function() { 415 scrollToTopBtn(); 416}); 417 418 419// Cart add remove functions 420var cart = { 421 'add': function(product_id, quantity) { 422 $.ajax({ 423 url: 'index.php?route=checkout/cart/add', 424 type: 'post', 425 data: 'product_id=' + product_id + '&quantity=' + (typeof(quantity) != 'undefined' ? quantity : 1), 426 dataType: 'json', 427 beforeSend: function() { 428 $('#cart > button').button('loading'); 429 },
430 complete: function() { 431 $('#cart > button').button('reset'); 432 }, 433 success: function(json) { 434 $('.alert, .text-danger').remove(); 435 436 if (json['redirect']) { 437 location = json['redirect']; 438 } 439 440 if (json['success']) { 441 $('.popup_bg_full').fadeIn('slow'); 442 443 $('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<p class="bottom_line"><a href="javascript:void(0);" onclick="closePopup();" class="go_back"><< ÐÑодолжиÑÑ Ð¿Ð¾ÐºÑпки</a><a href="/simplecheckout" class="go_to_cart">ÐеÑейÑи в коÑÐ·Ð¸Ð½Ñ >></a></p><img onclick="closePopup();" src="catalog/view/theme/valvesale/image/popup_close.png" alt="" class="close" /></div>'); 444 445 $('.success').fadeIn('slow'); 446 447 $('#cart-total').html(json['total']); 448 449 $('html, body').animate({ scrollTop: 0 }, 'slow'); 450 451 /** reload mobile cart**/ 452 var qty = $('.cart_qty:first').text(); 453 var iNum = parseInt(qty); 454 if (iNum > 0) { 455 $('.mobile_cart_qty').show(); 456 $('.mobile_cart_qty').text(qty); 457 } 458 } 459 }, 460 error: function(xhr, ajaxOptions, thrownError) { 461 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 462 } 463 }); 464 }, 465 'update': function(key, quantity) { 466 $.ajax({ 467 url: 'index.php?route=checkout/cart/edit', 468 type: 'post', 469 data: 'key=' + key + '&quantity=' + (typeof(quantity) != 'undefined' ? quantity : 1), 470 dataType: 'json', 471 beforeSend: function() { 472 $('#cart > button').button('loading'); 473 }, 474 complete: function() { 475 $('#cart > button').button('reset'); 476 }, 477 success: function(json) { 478 // Need to set timeout otherwise it wont update the total 479 setTimeout(function () { 480 $('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>'); 481 }, 100); 482 483 if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') { 484 location = 'index.php?route=checkout/cart'; 485 } else { 486 $('#cart > ul').load('index.php?route=common/cart/info ul li'); 487 } 488 }, 489 error: function(xhr, ajaxOptions, thrownError) { 490 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 491 } 492 }); 493 }, 494 'remove': function(key) { 495 $.ajax({ 496 url: 'index.php?route=checkout/cart/remove', 497 type: 'post', 498 data: 'key=' + key, 499 dataType: 'json', 500 beforeSend: function() { 501 $('#cart > button').button('loading'); 502 }, 503 complete: function() { 504 $('#cart > button').button('reset'); 505 }, 506 success: function(json) { 507 // Need to set timeout otherwise it wont update the total 508 setTimeout(function () { 509 $('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>'); 510 }, 100); 511 512 if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') { 513 location = 'index.php?route=checkout/cart'; 514 } else { 515 $('#cart > ul').load('index.php?route=common/cart/info ul li'); 516 } 517 }, 518 error: function(xhr, ajaxOptions, thrownError) { 519 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 520 } 521 }); 522 } 523} 524 525var voucher = { 526 'add': function() { 527 528 }, 529 'remove': function(key) { 530 $.ajax({ 531 url: 'index.php?route=checkout/cart/remove', 532 type: 'post', 533 data: 'key=' + key, 534 dataType: 'json', 535 beforeSend: function() { 536 $('#cart > button').button('loading'); 537 }, 538 complete: function() { 539 $('#cart > button').button('reset'); 540 }, 541 success: function(json) { 542 // Need to set timeout otherwise it wont update the total 543 setTimeout(function () { 544 $('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>'); 545 }, 100); 546 547 if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') { 548 location = 'index.php?route=checkout/cart'; 549 } else { 550 $('#cart > ul').load('index.php?route=common/cart/info ul li'); 551 } 552 }, 553 error: function(xhr, ajaxOptions, thrownError) { 554 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 555 } 556 }); 557 } 558} 559 560var wishlist = { 561 'add': function(product_id) { 562 $.ajax({ 563 url: 'index.php?route=account/wishlist/add', 564 type: 'post', 565 data: 'product_id=' + product_id, 566 dataType: 'json', 567 success: function(json) { 568 $('.alert').remove(); 569 570 if (json['redirect']) { 571 location = json['redirect']; 572 } 573 574 if (json['success']) { 575 $('#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>'); 576 } 577 578 $('#wishlist-total span').html(json['total']); 579 $('#wishlist-total').attr('title', json['total']); 580 581 $('html, body').animate({ scrollTop: 0 }, 'slow'); 582 }, 583 error: function(xhr, ajaxOptions, thrownError) { 584 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 585 } 586 }); 587 }, 588 'remove': function() { 589 590 } 591} 592 593var compare = { 594 'add': function(product_id) { 595 $.ajax({ 596 url: 'index.php?route=product/compare/add', 597 type: 'post', 598 data: 'product_id=' + product_id, 599 dataType: 'json', 600 success: function(json) { 601 $('.alert').remove(); 602 603 if (json['success']) { 604 $('#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>'); 605 606 $('#compare-total').html(json['total']); 607 608 $('html, body').animate({ scrollTop: 0 }, 'slow'); 609 } 610 }, 611 error: function(xhr, ajaxOptions, thrownError) { 612 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 613 } 614 }); 615 }, 616 'remove': function() { 617 618 } 619} 620 621/* Agree to Terms */ 622$(document).delegate('.agree', 'click', function(e) { 623 e.preventDefault(); 624
625 $('#modal-agree').remove(); 626 627 var element = this; 628 629 $.ajax({ 630 url: $(element).attr('href'), 631 type: 'get', 632 dataType: 'html', 633 success: function(data) { 634 html = '<div id="modal-agree" class="modal">'; 635 html += ' <div class="modal-dialog">'; 636 html += ' <div class="modal-content">'; 637 html += ' <div class="modal-header">'; 638 html += ' <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>'; 639 html += ' <h4 class="modal-title">' + $(element).text() + '</h4>'; 640 html += ' </div>'; 641 html += ' <div class="modal-body">' + data + '</div>'; 642 html += ' </div'; 643 html += ' </div>'; 644 html += '</div>'; 645 646 $('body').append(html); 647 648 $('#modal-agree').modal('show'); 649 } 650 }); 651}); 652 653// Autocomplete */ 654(function($) { 655 $.fn.autocomplete = function(option) { 656 return this.each(function() { 657 this.timer = null; 658 this.items = new Array(); 659 660 $.extend(this, option); 661 662 $(this).attr('autocomplete', 'off'); 663 664 // Focus 665 $(this).on('focus', function() { 666 this.request(); 667 }); 668 669 // Blur 670 $(this).on('blur', function() { 671 setTimeout(function(object) { 672 object.hide(); 673 }, 200, this); 674 }); 675 676 // Keydown 677 $(this).on('keydown', function(event) { 678 switch(event.keyCode) { 679 case 27: // escape 680 this.hide(); 681 break; 682 default: 683 this.request(); 684 break; 685 } 686 }); 687 688 // Click 689 this.click = function(event) { 690 event.preventDefault(); 691 692 value = $(event.target).parent().attr('data-value'); 693 694 if (value && this.items[value]) { 695 this.select(this.items[value]); 696 } 697 } 698 699 // Show 700 this.show = function() { 701 var pos = $(this).position(); 702 703 $(this).siblings('ul.dropdown-menu').css({ 704 top: pos.top + $(this).outerHeight(), 705 left: pos.left 706 }); 707 708 $(this).siblings('ul.dropdown-menu').show(); 709 } 710 711 // Hide 712 this.hide = function() { 713 $(this).siblings('ul.dropdown-menu').hide(); 714 } 715 716 // Request 717 this.request = function() { 718 clearTimeout(this.timer); 719 720 this.timer = setTimeout(function(object) { 721 object.source($(object).val(), $.proxy(object.response, object)); 722 }, 200, this); 723 } 724 725 // Response 726 this.response = function(json) { 727 html = ''; 728 729 if (json.length) { 730 for (i = 0; i < json.length; i++) { 731 this.items[json[i]['value']] = json[i]; 732 } 733 734 for (i = 0; i < json.length; i++) { 735 if (!json[i]['category']) { 736 html += '<li data-value="' + json[i]['value'] + '"><a href="#">' + json[i]['label'] + '</a></li>'; 737 } 738 } 739 740 // Get all the ones with a categories 741 var category = new Array(); 742 743 for (i = 0; i < json.length; i++) { 744 if (json[i]['category']) { 745 if (!category[json[i]['category']]) { 746 category[json[i]['category']] = new Array(); 747 category[json[i]['category']]['name'] = json[i]['category']; 748 category[json[i]['category']]['item'] = new Array(); 749 } 750 751 category[json[i]['category']]['item'].push(json[i]); 752 } 753 } 754 755 for (i in category) { 756 html += '<li class="dropdown-header">' + category[i]['name'] + '</li>'; 757 758 for (j = 0; j < category[i]['item'].length; j++) { 759 html += '<li data-value="' + category[i]['item'][j]['value'] + '"><a href="#"> ' + category[i]['item'][j]['label'] + '</a></li>'; 760 } 761 } 762 } 763 764 if (html) { 765 this.show(); 766 } else { 767 this.hide(); 768 } 769 770 $(this).siblings('ul.dropdown-menu').html(html); 771 } 772 773 $(this).after('<ul class="dropdown-menu"></ul>'); 774 $(this).siblings('ul.dropdown-menu').delegate('a', 'click', $.proxy(this.click, this)); 775 776 }); 777 } 778})(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.