1//'use strict'; 2 3window.dataLayer = window.dataLayer || []; 4 5var uni_touch_support; 6 7if ('ontouchstart' in document.documentElement) uni_touch_support = true; 8 9$(function() { 10 if(uni_touch_support) $('body').addClass('touch-support'); 11 12 uniMenuAim(); 13 uniMenuDropdownHeight(); 14 uniMenuMobile(); 15 uniSearch.init(); 16 uniChangeBtn.init(); 17 18 $('#language li a').on('click', function(e) { 19 e.preventDefault(); 20 $('#language input[name="code"]').val($(this).data('code')); 21 $('#language').submit(); 22 }); 23 24 $('#currency li a').on('click', function(e) { 25 e.preventDefault(); 26 $('#currency input[name="code"]').val($(this).data('code')); 27 $('#currency').submit(); 28 }); 29 30 $('.header-phones__additional').on('click', function() { 31 $('.header-phones__additional').addClass('selected').not($(this)).removeClass('selected'); 32 33 if($('.header-phones__main').text() == $(this).data('phone') && $(this).data('href')) { 34 location = $(this).data('href'); 35 } else { 36 $('.header-phones__main').text($(this).data('phone')).attr('href', $(this).data('href')); 37 } 38 }); 39 40 $('[data-toggle=\'tooltip\']').tooltip({container:'body', trigger:'hover'}); 41 42 $('body').on('hide.bs.modal', '.modal.animated', function() { 43 $(this).removeClass(uniJsVars.popup_effect_in).addClass(uniJsVars.popup_effect_out); 44 $('body').css({'padding': ''}); 45 }); 46 47 $('body').on('hidden.bs.modal', '.modal.animated', (e) => { 48 setTimeout(() => { 49 e.target.remove(); 50 }, 200); 51 52 $('body').removeClass('scroll-disabled'); 53 54 if($('body > .modal.fade.in').length) $('body').addClass('modal-open'); 55 }); 56 57 $('.add_to_cart.disabled:not(.fly-menu__product-btn)').each(function() { 58 $(this).attr('disabled', true); 59 }); 60 61 $(document).ajaxStop(() => { 62 $('[data-toggle=\'tooltip\']').tooltip({container:'body', trigger:'hover'}); 63 64 $('.add_to_cart.disabled:not(.fly-menu__product-btn)').each(function(){ 65 $(this).attr('disabled', true); 66 }); 67 }); 68 69 $('body').on('blur click keyup', '.qty-switch__input, .qty-switch__btn', function(e) { 70 let $elem = $(this); 71 72 if($(this).hasClass('qty-switch__btn')) $elem = $(this).closest('.qty-switch').find('input'); 73 74 if($(this).hasClass('qty-switch__input') && (e.type == 'click' || e.keyCode == 8)) return; 75 76 let qty = parseFloat($elem.val()), 77 min = $elem.data('minimum') ? parseFloat($elem.data('minimum')) : 1, 78 max = $elem.data('maximum') ? parseFloat($elem.data('maximum')) : 100000, 79 step = uniJsVars.qty_switch.step ? min : 1, 80 decimal = 0, 81 show_alert, 82 new_qty; 83 84 if(max != 100000) { 85 let main_block = $elem.closest('.product-thumb'); 86
87 if(!main_block.length) main_block = $elem.closest('.product-block'); 88 89 if(main_block.find('.option').length) { 90 main_block.find('input:checked, option:selected').each(function() { 91 const this_max = $(this).data('maximum'); 92 93 if(this_max < max) { 94 max = this_max; 95 } 96 }); 97 } 98 } 99 100 if(qty >= max) show_alert = true; 101 102 if($(this).hasClass('qty-switch__input')) { 103 if(step > 1) qty = Math.round(qty/min)*min; 104 105 new_qty = (qty > min) && (qty < max) ? qty : ((qty >= max) ? max : min); 106 } else { 107 new_qty = $(this).hasClass('fa-plus') ? ((qty < max) ? qty+step : qty) : ((qty > min) ? qty-step : qty); 108 } 109 110 new_qty = new_qty.toFixed(decimal); 111 112 $elem.val(new_qty).change(); 113 114 if(new_qty < max) show_alert = false; 115 116 if(show_alert) uniFlyAlert('warning', uniJsVars.qty_switch.stock_warning) 117 118 if($(this).closest('.checkout-cart__quantity, .header-cart__quantity').length) { 119 cart.update($elem.data('cid'), new_qty); 120 } 121 }); 122 123 $('body').on('change', '.option input[type="checkbox"], .option input[type="radio"], .option select', function() { 124 let $elem = $(this), main_block = $elem.closest('.product-thumb'), max = $elem.data('maximum'); 125 126 if(!main_block.length) main_block = $elem.closest('.product-block'); 127 128 const qty_input = main_block.find('.qty-switch__input'); 129 130 qty_input.val(qty_input.data('minimum')); 131 }); 132 133 $('body').on('touchstart mouseenter', '.option__item', function(e) { 134 let elem = $(this).find('img'); 135 136 if(!elem.length) return; 137 138 let block = $('<div class="option__popup '+elem.data('type')+'"><img src="'+elem.data('thumb')+'" class="option__popup-img img-responsive" />'+elem.attr('alt')+'</div>'), 139 imgSrc = elem.data('thumb'), 140 elemTop = elem.offset().top, 141 elemLeft = elem.offset().left+(elem.outerWidth()/2); 142 143 $('.option__popup').remove() 144 145 $('body').append(block); 146 147 if(elemLeft < block.outerWidth()/2) { 148 elemLeft = elem.offset().left; 149 } else if(elemLeft + (block.outerWidth()/2) > $(window).width()) { 150 elemLeft = elem.offset().left + elem.outerWidth() - block.outerWidth(); 151 } else { 152 elemLeft = elemLeft - (block.outerWidth()/2); 153 } 154 155 setTimeout(() => { 156 block.css({top: elemTop-block.outerHeight()-10, left: elemLeft}).addClass('show'); 157 }, 170); 158 159 $(this).on('mouseleave', () => { 160 block.remove(); 161 }); 162 163 $('body').on('touchstart', () => { 164 block.remove(); 165 }); 166 }); 167 168 $('body').on('click', '.uni-href', function() { 169 if(typeof($(this).data('href')) != 'undefined' && $(this).data('href') != '') { 170 if(($(this).attr('target') || $(this).data('target')) == '_blank') { 171 window.open($(this).data('href'), '_blank'); 172 } else { 173 location = $(this).data('href'); 174 } 175 } 176 }); 177 178 $('.breadcrumb').scrollLeft(1000); 179 180 if(uniJsVars.unregisterSW && ('serviceWorker' in navigator)) { 181 navigator.serviceWorker.getRegistrations().then(function(registrations) { 182 for(let registration of registrations) { 183 registration.unregister(); 184 } 185 }); 186 187 typeof(uniDelPageCache) === 'function' && uniDelPageCache(); 188 } 189}); 190 191function uniMenuAim() { 192 if(window.innerWidth > 991) { 193 let blur_blocks = $('main, footer'), items = '.menu__level-2', timer = '', delay = 0, delay2 = 150; 194 195 $('.menu.menu2 li.has-children').on('mouseenter', function() { 196 timer = setTimeout(() => { 197 changeState($(this), 1); 198 }, delay); 199 }).on('mouseleave', function() { 200 clearTimeout(timer); 201 changeState($(this), 0); 202 }); 203 204 $('.menu.menu1 .menu__collapse').menuAim({ 205 rowSelector:'.menu__level-1-li', 206 submenuSelector:'*', 207 activate:function(data) { 208 changeState($(data), 1); 209 }, 210 deactivate:function(data) { 211 changeState($(data), 0); 212 }, 213 exitMenu:function(data) { 214 if(!$(data).parent().hasClass('new')) { 215 return true; 216 } 217 } 218 }); 219 220 const changeState = (elem, state) => { 221 const child = elem.children(items); 222 223 if(child.css('display') == 'none') child.css('opacity', 0); 224 225 $('.menu__level-1-li:first, .menu__level-1-li:first .menu__level-2').removeClass('open'); 226 227 if(state) { 228 elem.addClass('open'); 229 child.addClass('open').animate({opacity: 1}, delay2); 230 } else { 231 elem.removeClass('open'); 232 child.removeClass('open'); 233 } 234 }; 235 236 const menuBlur = () => { 237 if(typeof(uniJsVars) == 'undefined' || !uniJsVars.menu_blur) return; 238 239 let blur_delay = 110, blur_timer = ''; 240 241 $('.menu1:not(.new), .menu2').on('mouseenter', () => { 242 blur_timer = setTimeout(() => { 243 blur_blocks.addClass('blur'); 244 }, blur_delay); 245 }).on('mouseleave', () => { 246 clearTimeout(blur_timer); 247 blur_blocks.removeClass('blur'); 248 }); 249 250 if($('.menu-wrapper.new').hasClass('show')) { 251 blur_blocks.addClass('blur'); 252 } else { 253 blur_blocks.removeClass('blur'); 254 } 255 }; 256 257 menuBlur(); 258 259 $('.header-menu__btn').unbind('click').on('click', function() { 260 const elem = $(this).hasClass('fly-menu__menu-btn') ? '.fly-menu' : 'header', wrapper = elem+' .menu-wrapper.new', li = elem+' .menu1.new .menu__level-1-li'; 261 262 $(this).toggleClass('show'); 263 264 changeState($(li).not(':first-child'), 0); 265 changeState($(li).first(), 1); 266 267 $(wrapper).toggleClass('show'); 268 269 menuBlur(); 270 }); 271 272 $('main, footer').unbind('click').on('click touchstart', () => { 273 $(items).removeClass('open'); 274 $('.menu__chevron').removeClass('open'); 275 $('.menu .collapse').collapse('hide'); 276 277 $('body').removeClass('scroll-disabled'); 278 $('.menu-wrapper, .header-menu__btn').removeClass('show'); 279 280 blur_blocks.removeClass('blur'); 281 }); 282 283 //setTimeout(() => { 284 uniMenuDropdownPos(); 285 //}, 100); 286 } 287 288 $('.menu__chevron').unbind('click').on('click', function() { 289 $(this).toggleClass('open'); 290 $(this).next().collapse('toggle'); 291 }); 292 293 $('.menu-open, .menu-close').unbind('click').on('click', () => { 294 $('body').toggleClass('scroll-disabled'); 295 $('.menu-wrapper').toggleClass('show'); 296 $('.fly-menu__block').removeClass('show'); 297 }); 298}; 299 300function uniMenuUpd(block) { 301 302 if(!$(block).length) return; 303 304 const init = () => { 305 let menu_block = $(block), menu_items = menu_block.children('.menu__level-1-li:not
305(.menu__additional)'); 306 307 menu_items.css('display', ''); 308 309 if(window.innerWidth > 991) { 310 311 menu_block.find('.menu__additional').remove(); 312 313 let coord = menu_block.offset().left + menu_block.width(), flag = false, new_items = ''; 314 315 if(!menu_items.length || Math.floor(menu_items.last().offset().left + menu_items.last().width()) <= coord) return; 316 317 menu_items.each(function() { 318 if($(this).offset().left + $(this).width() > coord - 60) { 319 let item = $(this).find('> a'), item_child = $(this).find('.menu__level-2-a'), new_child_items = ''; 320 321 if(item_child.length) { 322 new_child_items = '<div class="menu__level-3"><ul class="menu__level-3-ul">'; 323 324 item_child.each(function() { 325 new_child_items += '<li class="menu__level-3-li"><a class="menu__level-3-a'; 326 327 if(!$(this).attr('href').length) new_child_items += 'disabled'; 328 329 new_child_items += '" href="'+$(this).attr('href')+'">'+$(this).text()+'</a></li>'; 330 }); 331 332 new_child_items += '</ul></div>'; 333 } 334 335 new_items += '<div class="menu__level-2-ul col-md-12"><a class="menu__level-2-a'; 336 337 if(new_child_items) new_items += ' has-children'; 338 339 if(!item.attr('href').length) new_items += ' disabled'; 340 341 new_items += '" href="'+item.attr('href')+'">'+item.text()+'</a>'+new_child_items+'</div>'; 342 343 $(this).hide(); 344 345 flag = true; 346 } else { 347 $(this).show(); 348 } 349 }); 350 351 if (flag) { 352 if (!menu_block.find('.menu__additional').length) { 353 let html = '<li class="menu__level-1-li menu__additional has-children">'; 354 html += '<a class="menu__level-1-a additional" href="#" onclick="return false"><i class="fa fa-ellipsis-h"></i></a>'; 355 html += '<div class="menu__level-2 column-1"></div>'; 356 html += '</li>'; 357 358 menu_block.append(html); 359 360 uniMenuAim(); 361 } 362 363 menu_block.find('.menu__additional .menu__level-2').html(new_items); 364 } 365 } 366 } 367 368 init(); 369 370 setTimeout(() => { 371 init(); 372 }, 200); 373 374 $(window).resize(init); 375}; 376 377function uniMenuDropdownHeight() { 378 const menu_block = $('header .menu1:not(.new) .menu__level-2, header .menu2 .menu__level-2'); 379 380 if(menu_block.length) { 381 const init = () => { 382 if(window.innerWidth > 991) { 383 menu_block.css('max-height', ($(window).height() - $('header .menu').offset().top - 100)); 384 } else { 385 menu_block.css('max-height', ''); 386 } 387 } 388 389 init(); 390 391 $(window).resize(init); 392 } 393}; 394 395function uniMenuDropdownPos() { 396 const menu_block = $('header .menu2'); 397 398 if(menu_block.length) { 399 const init = () => { 400 if(window.innerWidth > 991) { 401 menu_block.find('.menu__level-2').each(function() { 402 const child_pos = ($(this).parent().offset().left + $(this).outerWidth()) - (menu_block.offset().left + menu_block.outerWidth()); 403 404 $(this).css('margin-left', '-'+(child_pos > 0 ? child_pos : 0)+'px'); 405 }); 406 } 407 } 408 409 init(); 410 411 $(window).resize(init); 412 } 413}; 414 415function uniMenuMobile() { 416 const menu1 = $('.menu1 .menu__collapse'), menu2 = $('.menu-right .menu__collapse'); 417 418 if(menu1.length && menu2.length) { 419 const init = () => { 420 if(window.innerWidth < 991) { 421 let item = menu1.find('.menu__level-1-a'), arr = []; 422 423 item.each(function() { 424 arr.push($(this).text().trim()); 425 }); 426 427 menu2.find('.menu__level-1-a').each(function() { 428 if(arr.indexOf($(this).text().trim()) <= 0) { 429 $(this).parent().addClass('new-items').appendTo(menu1); 430 } 431 }); 432 } else { 433 menu1.find('.new-items').removeClass('new-items').appendTo(menu2); 434 } 435 } 436 437 init(); 438 439 $(window).resize(init); 440 } 441} 442 443function uniBannerLink(url) { 444 $.ajax({ 445 url: url, 446 type: 'get', 447 dataType: 'html', 448 success: function(data) { 449 var data = $(data), title, text; 450 451 title = data.find('h1').text(), 452 data.find('h1').remove(); 453 text = data.find('#content').html(); 454 455 uniModalWindow('modal-banner', 'lg', title, text); 456 } 457 }); 458} 459 460function form_error(form, input, text) { 461 let element = $(form+' input[name="'+input+'"], '+form+' textarea[name="'+input+'"], '+form+' select[name="'+input+'"]').addClass('input-warning'), time = 15; 462
463 if(typeof(uniJsVars) != 'undefined') time = uniJsVars.alert_time; 464 465 setTimeout(() => { 466 $(form+' .input-warning').removeClass('input-warning'); 467 }, time*1000); 468 469 $(form+' .input-warning').click(function() { 470 $(this).removeClass('input-warning'); 471 }); 472} 473 474function uniScrollTo(target, time = 200) { 475 let top = 20; 476 477 if(window.innerWidth > 991) { 478 if(uniJsVars.fly_menu.fixed_header) top += $('header').height(); 479 if(uniJsVars.fly_menu.topmenu_hide) top -= $('.top-menu').height(); 480 if($('.fly-menu').length) top += $('.fly-menu').height(); 481 } 482 483 $('html, body').animate({scrollTop: $(target).offset().top - top}, time); 484} 485 486function uniModalWindow(id, type, title, data) { 487 488 /* id = id modal form; type = sm, lg, or empty; title = title modal form; data = text or other data modal form; */ 489 490 $('#'+id).remove(); 491 492 let html = '<div id="'+id+'" class="modal '+uniJsVars.popup_effect_in+'">'; 493 html += '<div class="modal-dialog modal-'+type+'">'; 494 html += '<div class="modal-content">'; 495 html += '<div class="modal-header">'; 496 html += '<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>'; 497 html += '<h4 class="modal-title">'+title+'</h4>'; 498 html += '</div>'; 499 html += '<div class="modal-body">'+data+'</div>'; 500 html += '</div>'; 501 html += '</div>'; 502 html += '</div>'; 503 504 $('html body').append(html); 505 $('#'+id).modal('show'); 506} 507 508function uniFlyAlert(type, data) { 509 let time = 15, effectIn = 'animated bounceInRight', effectOut = 'animated bounceOutRight'; 510 511 if(typeof(uniJsVars) != 'undefined') { 512 time = uniJsVars.alert_time; 513 effectIn = uniJsVars.alert_effect_in; 514 effectOut = uniJsVars.alert_effect_out; 515 } 516 517 let time1 = time*1000, 518 time2 = time1+1000, 519 time3 = 100, 520 top_offset = 50, 521 top_margin = 15, 522 icon; 523 524 if(type == 'success') icon = 'fa-check-circle'; 525 if(type == 'danger') icon = 'fa-exclamation-circle'; 526 if(type == 'warning') icon = 'fa-exclamation-circle'; 527 528 $('.uni-alert').remove(); 529 530 let createAlert = (data) => { 531 if($('.uni-alert').length) { 532 top_offset = $('.uni-alert:last').position().top + $('.uni-alert:last').outerHeight() + top_margin; 533 } 534 535 const block = $('<div class="uni-alert alert-'+type+' '+effectIn+'" style="top:'+top_offset+'px"><i class="uni-alert__icon fa '+icon+'"></i><div>'+data+'</div><i class="uni-alert__icon fas fa-times" onclick="$(this).parent().remove()"></i></div>'); 536 537 $('html body').append(block); 538 539 setTimeout(() => { 540 block.removeClass(effectIn).addClass(effectOut); 541 }, time1); 542 543 setTimeout(() => { 544 block.remove(); 545 }, time2); 546 } 547 548 if(typeof(data) == 'object') { 549 let arr = []; 550 551 for (i in data) { 552 arr.push(data[i]); 553 } 554 555 let index = -1, 556 timer = setInterval(() => { 557 if (++index == arr.length) { 558 clearInterval(timer); 559 } else { 560 createAlert(arr[index]); 561 } 562 }, time3); 563 } else { 564 createAlert(data); 565 } 566} 567 568//add css and js from script 569var cssUrls = [], jsUrls = []; 570 571function uniAddCss(url) { 572 if(cssUrls.indexOf(url) == -1) { 573 cssUrls.push(url); 574 $('html head').append('<link href="'+url+'" type="text/css" rel="stylesheet" media="screen" />') 575 } 576} 577 578function uniAddJs(url) { 579 if(jsUrls.indexOf(url) == -1) { 580 jsUrls.push(url); 581 $.getScript(url); 582 } 583} 584 585(function($){ 586 var Modules = { 587 init:function(options, el) { 588 var base = this; 589 590 base.$elem = $(el); 591 base.$elem2 = $(el).children(); 592 base.options = $.extend({}, $.fn.uniModules.options, options); 593 594 base.load(); 595 }, 596 load:function() { 597 var base = this; 598 599 base.wrapper = (base.$elem2.closest('.tab-content').length) ? base.$elem2.closest('.tab-content') : base.$elem; 600 601 if((base.options.type == 'grid' && module_on_mobile == 'carousel' && base.wrapper.width()+20 < 768) || base.wrapper.closest('#column-left, #column-right').length) { 602 base.options.type = 'carousel'; 603 } 604 605 if(base.wrapper.closest('#column-left, #column-right').length) { 606 base.options.items = {0: {items: 1}}; 607 } 608 609 if (base.options.type == 'grid') { 610 base.$elem2.children().wrap('<div class="uni-module__item" style="width:'+base.items()+'"></div>'); 611 } else { 612 base.$elem2.addClass('owl-carousel').owlCarousel({ 613 responsive: base.options.items, 614 responsiveBaseElement: base.wrapper, 615 dots: base.options.dots, 616 mouseDrag: false, 617 rewind: base.options.loop, 618 autoplay: base.options.autoplay, 619 nav: true 620 }); 621 622 if(base.$elem2.width() == 0) { 623 const item = base.$elem2.find('.owl-item'), item_width = base.items(); 624 625 item.css({width: item_width}); 626 base.$elem2.find('.owl-stage').css({width:item.length * item_width}); 627 } 628 } 629 630 base.$elem2.addClass('load-complete'); 631 base.responsive(); 632 }, 633 items:function() { 634 var base = this, match = -1, width = base.wrapper.width(); 635 636 width += (base.wrapper.attr('class') == 'tab-content' && width < 520) ? 10 : 20; 637 638 $.each(base.options.items, (breakpoint) => { 639 if (breakpoint <= width && breakpoint > match) { 640 match = Number(breakpoint); 641 } 642 }); 643 644 const items = base.options.items[match]['items'] 645 646 return (base.options.type == 'carousel') ? width/items : 100/items+'%'; 647 }, 648 responsive:function() { 649 var base = this, lastWindowWidth = window.innerWidth; 650 651 base.resizer = () => { 652 if (window.innerWidth != lastWindowWidth || uni_touch_support) { 653 if (base.options.type == 'grid') { 654 base.$elem2.children().css('width', base.items()); 655 } 656 } 657 }; 658 659 $(window).resize(base.resizer); 660 } 661 }; 662 663 $.fn.uniModules = function(options) { 664 return this.each(function() { 665 if ($(this).data('uni-modules-init') === true) { 666 return false;
667 } 668 669 $(this).data('uni-modules-init', true); 670 671 var module = Object.create(Modules); 672 module.init(options, this); 673 }); 674 }; 675 676 if(typeof(items_on_mobile) == 'undefined') items_on_mobile = 2; 677 678 $.fn.uniModules.options = { 679 type :'carousel', 680 items :{0:{items:items_on_mobile},700:{items:3},992:{items:4},1400:{items:5}}, 681 autoheight :[], 682 dots :true, 683 loop :false, 684 autoplay :false 685 }; 686})(jQuery); 687 688const uniSearch = { 689 init: function() { 690 let base = this, phrase_arr = uniJsVars.search.phrase_arr, cleaning = uniJsVars.search.cleaning_status; 691 692 $('body').on('click', '.header-search__category-li', function() { 693 const elem = $(this), parent = elem.closest('.header-search'), btn = parent.find('.header-search__category-btn'), span = btn.find('.header-search__category-span'); 694 695 btn.attr('title', elem.data('title')); 696 697 if(elem.is(':first-child')) { 698 span.text('').removeClass('v'); 699 } else { 700 span.text(elem.text()).addClass('v'); 701 } 702 703 parent.find('input[name="filter_category_id"]').val(elem.data('id')); 704 }); 705 706 $('body').on('click', '.header-search__btn', function() { 707 let url = $('base').attr('href') + 'index.php?route=product/search', 708 elem = $(this).closest('.header-search'), 709 elemInput = elem.find('input[name="search"]'), 710 value = elem.find('input[name="search"]').val(), 711 filter_category_id = elem.find('input[name="filter_category_id"]').val(); 712 713 if (!value && phrase_arr.length) value = elemInput.attr('placeholder'); 714 if (value && cleaning) value = value.replace(/[^a-zA-Zа-ÑÐ-ЯÑÐ0-9 -]/ig, ''); 715 if (value) url += '&search='+encodeURIComponent(value); 716 if (filter_category_id > 0) url += '&category_id='+encodeURIComponent(filter_category_id)+'&sub_category=true'; 717 if (uniJsVars.search.in_description) url += '&description=true'; 718 if (value) window.location = url; 719 }); 720 721 $('body').on('keydown', '.header-search__input', function(e) { 722 if (e.keyCode == 13) $(this).parent().find('.header-search__btn').click(); 723 }); 724 725 if($(window).width() > 575 && phrase_arr.length > 1) { 726 new Typed('.header-search__input', { 727 strings: phrase_arr, 728 startDelay: 3000, 729 typeSpeed: 80, 730 backDelay: 1500, 731 backSpeed: 45, 732 attr: 'placeholder', 733 bindInputFocusEvents: true, 734 loop: true 735 }); 736 } 737 738 base.clearBtn(); 739 }, 740 clearBtn: function() { 741 const input = 'input[name="search"]', btn = '.search-btn-clear'; 742 743 $(input).each(function() { 744 $(this).on('input', () => { 745 $(input).not($(this)).val($(this).val()); 746 747 if($(this).val() != '') { 748 $(btn).addClass('show'); 749 } else { 750 $(btn).removeClass('show'); 751 } 752 }); 753 }); 754 755 $('body').on('click', btn, () => { 756 $(input).val(''); 757 $(btn).removeClass('show'); 758 if (typeof(uniLiveSearch.hide) === 'function') uniLiveSearch.hide(); 759 }); 760 } 761}; 762 763const uniSelectView = { 764 init:function(viewtype){ 765 var base = this; 766 767 base.display = default_view; 768 769 if(typeof(viewtype) != 'undefined') { 770 base.display = viewtype; 771 } else if(typeof(MegaFilter) === 'function') { 772 base.display = localStorage.getItem('displayMFP'); 773 } else { 774 base.display = localStorage.getItem('display'); 775 } 776 777 base.bind(); 778 base.switcher(); 779 }, 780 switcher:function() { 781 var base = this, lastWindowWidth = window.innerWidth, breakpoint = 991; 782 783 base.switcher2 = (new_width) => { 784 base.displayMobile = localStorage.getItem('displayMobile') ? localStorage.getItem('displayMobile') : default_mobile_view; 785 786 if(!$('.products-block').length) return; 787 788 let disp = (new_width <= breakpoint) ? base.displayMobile : base.display; 789 790 if (disp == 'list') { 791 base.list(); 792 } else if (disp == 'grid') { 793 base.grid(); 794 } else { 795 base.compact(); 796 } 797 } 798 799 base.switcher2(lastWindowWidth); 800 801 $(window).resize(function(){ 802 if($(this).width() != lastWindowWidth && $(this).width() >= breakpoint) { 803 base.switcher2($(this).width()); 804 } 805 }); 806 }, 807 list:function() { 808 var base = this, breakpoint = 992, product_layout = $('.product-layout'), new_class = 'product-layout product-list list-view col-sm-12';
809 810 if(!product_layout.first().attr('class').includes('list-view')) { 811 $('.list-view, .grid-view, .compact-view, .product-grid, .product-list, .product-compact').attr('class', new_class); 812 813 $.post('index.php?route=extension/module/uni_new_data/setDefaultView', {view: 'list'}); 814 } 815 816 $('.sorts-block__btn').addClass('selected').not('#list-view').removeClass('selected'); 817 818 localStorage.setItem('display', 'list'); 819 localStorage.setItem('displayMFP', 'list'); 820 if($(window).width() <= breakpoint) localStorage.setItem('displayMobile', 'list'); 821 }, 822 grid:function() { 823 var base = this, breakpoint = 992, col_left = $('#column-left').length, col_right = $('#column-right').length, product_layout = $('.product-layout'), new_class = 'product-layout product-grid grid-view col-sm-6 col-md-3 col-lg-3 col-xxl-4'; 824 825 if (col_left && col_right) { 826 new_class = 'product-layout product-grid grid-view col-sm-12 col-md-6 col-lg-6 col-xxl-6-1'; 827 } else if (col_left || col_right) { 828 new_class = 'product-layout product-grid grid-view col-sm-6 col-md-4 col-lg-4 col-xxl-5'; 829 } 830 831 if(!product_layout.first().attr('class').includes('grid-view')) { 832 $.post('index.php?route=extension/module/uni_new_data/setDefaultView', {view: 'grid'}); 833 } 834 835 $('.list-view, .grid-view, .compact-view, .product-grid, .product-list, .product-compact').attr('class', new_class); 836 837 $('.sorts-block__btn').addClass('selected').not('#grid-view').removeClass('selected'); 838 839 localStorage.setItem('display', 'grid'); 840 localStorage.setItem('displayMFP', 'grid'); 841 if($(window).width() <= breakpoint) localStorage.setItem('displayMobile', 'grid'); 842 }, 843 compact:function() { 844 var base = this, product_layout = $('.product-layout'), new_class = 'product-layout product-price compact-view col-sm-12'; 845 846 if(!product_layout.first().attr('class').includes('compact-view')) { 847 $('.list-view, .grid-view, .compact-view, .product-grid, .product-list, .product-compact').attr('class', new_class); 848 849 $.post('index.php?route=extension/module/uni_new_data/setDefaultView', {view: 'compact'}); 850 } 851 852 $('.sorts-block__btn').addClass('selected').not('#compact-view').removeClass('selected'); 853 854 if(!product_layout.find('.product-thumb__option').children().length) { 855 product_layout.find('.product-thumb__option').remove() 856 } 857 858 product_layout.find('.product-thumb__cart.disabled').css('min-width', product_layout.find('.product-thumb__cart').first().outerWidth()); 859 860 localStorage.setItem('display', 'compact'); 861 localStorage.setItem('displayMFP', 'compact'); 862 }, 863 bind:function() { 864 var base = this; 865 $('#list-view').on('click', base.list); 866 $('#grid-view').on('click', base.grid); 867 $('#compact-view').on('click', base.compact); 868 } 869}; 870 871const uniChangeBtn = { 872 'init': function() { 873 var base = this; 874 875 base.cart(); 876 base.compare(); 877 base.wishlist(); 878 879 $(document).ajaxStop(() => { 880 base.cart(); 881 base.compare(); 882 base.wishlist(); 883 }); 884 }, 885 'productsInCart': function() { 886 const products = $('.header-cart__wrapper').data('products'), products2 = String(products).split(', '), p1 = products2; 887 888 let p2 = products2.map((elem) => { 889 return Number(elem.split('_', 1)); 890 }); 891 892 p2 = p2.filter((value, index, array) => array.indexOf(value) === index); 893 894 return [p1, p2]; 895 }, 896 'cart': function(b, f) { 897 var base = this; 898 899 const products = base.productsInCart(); 900 901 const changeBtnText = (btn, flag) => { 902 if(btn.hasClass('disabled')) return; 903 904 if(flag == 'normal') { 905 btn.removeClass('in_cart'); 906 btn.children('i').attr('class', uniJsVars.cart_btn.icon); 907 btn.children('span').text(uniJsVars.cart_btn.text); 908 } 909 910 if(flag == 'incart') { 911 btn.addClass('in_cart'); 912 btn.children('i').attr('class', uniJsVars.cart_btn.icon_incart); 913 btn.children('span').text(uniJsVars.cart_btn.text_incart); 914 } 915 916 if(flag == 'disabled') { 917 btn.removeClass('in_cart'); 918 btn.children('i').attr('class', uniJsVars.cart_btn.icon_disabled); 919 btn.text(uniJsVars.cart_btn.text_disabled); 920 } 921 }; 922 923 if(typeof(b) != 'undefined' && typeof(f) != 'undefined') { 924 changeBtnText(b, f); 925 return; 926 } 927 928 if(products[1] != 'undefined') { 929 $('.product-thumb__add-to-cart, .product-page__add-to-cart, .compare-page__cart').each(function() { 930 if(products[1].indexOf($(this).data('pid')) !== -1) { 931 changeBtnText($(this), 'incart') 932 } 933 }); 934 } 935 936 if(products[0] != 'undefined') { 937 $('body').on('change', '.product-page .option input[type="checkbox"], .product-page .option input[type="radio"], .product-page .option select', () => { 938 checkedOptions() 939 }); 940 941 const checkedOptions = () => { 942
943 const options = $('.product-page').find('input:checked, option:selected'); 944 let stat = 0; 945 946 options.each(function() { 947 if(products[0].includes($(this).data('hash'))) { 948 stat++; 949 } else { 950 stat--; 951 } 952 }); 953 954 if(options.length) { 955 changeBtnText($('.product-page__add-to-cart'), (options.length == stat ? 'incart' : 'normal')); 956 } 957 }; 958 959 checkedOptions(); 960 } 961 }, 962 'compare': function() { 963 let products = $('.top-menu__compare').data('products'); 964 965 if(!products) return; 966 967 products = String(products).split(',').map(Number); 968 969 $('.product-thumb__compare, .product-page__compare-btn').each(function() { 970 const pid = Number($(this).attr('onclick').replace(/\D+/g,'')); 971 972 if(products.indexOf(pid) !== -1) { 973 $(this).attr('onclick', $(this).attr('onclick').replace('compare.add', 'compare.remove')).attr('title', uniJsVars.compare_btn.text_remove).addClass('active').find('span').text(uniJsVars.compare_btn.text_remove); 974 } 975 }); 976 }, 977 'wishlist': function() { 978 let products = $('.top-menu__wishlist').data('products'); 979 980 if(!products) return; 981 982 products = String(products).split(',').map(Number); 983 984 $('.product-thumb__wishlist, .product-page__wishlist-btn').each(function() { 985 const pid = Number($(this).attr('onclick').replace(/\D+/g,'')); 986 987 if(products.indexOf(pid) !== -1) { 988 $(this).attr('onclick', $(this).attr('onclick').replace('wishlist.add', 'wishlist.remove')).attr('title', uniJsVars.wishlist_btn.text_remove).addClass('active').find('span').text(uniJsVars.wishlist_btn.text_remove); 989 } 990 }); 991 } 992}; 993 994const cart = { 995 'add': function(product_id, elem, several) { 996 997 var $elem = $(elem).closest('.product-thumb, .product-thumb-related'), 998 product_qty = $elem.find('input[name="quantity"]').val(), 999 product_options = $elem.find('.option input[type="text"], .option input[type="hidden"], .option input:checked, .option select, .option textarea'), 1000 data = 'product_id='+product_id+'&quantity='+(typeof(product_qty) != 'undefined' ? product_qty : 1); 1001 1002 if (product_options.length) { 1003 data += '&'+product_options.serialize(); 1004 } 1005 1006 $.ajax({ 1007 url: $('base').attr('href')+'index.php?route=checkout/cart/add', 1008 type: 'post', 1009 data: data, 1010 dataType: 'json', 1011 success: function(json) { 1012 $('.text-danger').remove(); 1013 1014 if (json['redirect'] && !json['error']['stock'] && (!$elem.find('.option [name^=\'option\']').length || $elem.find('.option').css('display') == 'none')) { 1015 window.location = json['redirect']; 1016 1017 return; 1018 } 1019 1020 $('.form-group').removeClass('has-error'); 1021 1022 if (json['error']) { 1023 if (json['error']['option']) { 1024 for (i in json['error']['option']) { 1025 var elem = $('.option .input-option' + i.replace('_', '-')), elem2 = (elem.parent().hasClass('input-group')) ? elem.parent() : elem; 1026 1027 elem2.after('<div class="text-danger">'+json['error']['option'][i]+'</div>'); 1028 $('.option .text-danger').delay(5000).fadeOut(); 1029 1030 uniFlyAlert('danger', json['error']['option'][i]) 1031 } 1032 } 1033 1034 if (json['error']['stock']) { 1035 uniFlyAlert('danger', json['error']['stock']); 1036 } 1037 } 1038 1039 if (json['success']) { 1040 cart.uniCartUpd(); 1041 1042 cart.uniCartActionAfter(several); 1043 1044 dataLayer.push({ 1045 'event': 'addToCart', 1046 'ecommerce':{ 1047 'currencyCode':uniJsVars.currency.code, 1048 'add':{ 1049 'products':[json['products']['products']] 1050 } 1051 } 1052 }); 1053 1054 if (typeof(gtag) === 'function') { 1055 dataLayer.push({ 1056 'event': "add_to_cart", 1057 'ecommerce': { 1058 'currency': uniJsVars.currency.code, 1059 'items': [json['products']['items']] 1060 } 1061 }); 1062 1063 //gtag('event', 'add_to_cart', {'currency': uniJsVars.currency.code, 'items': json['success']['products']}); 1064 } 1065 1066 if(uniJsVars.cart_btn.metric_id && uniJsVars.cart_btn.metric_target) { 1067 if (typeof(ym) === 'function') { 1068 ym(uniJsVars.cart_btn.metric_id, 'reachGoal', uniJsVars.cart_btn.metric_target); 1069 } else { 1070 new Function('yaCounter'+uniJsVars.cart_btn.metric_id+'.reachGoal(\''+uniJsVars.cart_btn.metric_target+'\')')(); 1071 } 1072 } 1073 1074 if(uniJsVars.cart_btn.analytic_category && uniJsVars.cart_btn.analytic_action) { 1075 if (typeof(gtag) === 'function') { 1076 gtag('event', uniJsVars.cart_btn.analytic_action, {'event_category': uniJsVars.cart_btn.analytic_category}); 1077 } else if (typeof(ga) === 'function') { 1078 ga('send', 'event', uniJsVars.cart_btn.analytic_category, uniJsVars.cart_btn.analytic_action); 1079 } 1080 } 1081 } 1082 }, 1083 error: function(xhr, ajaxOptions, thrownError) { 1084 console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 1085 } 1086 }); 1087 }, 1088 'update': function(key, quantity, product_id) { 1089 $.ajax({ 1090 url: $('base').attr('href')+'index.php?route=checkout/cart/edit', 1091 type: 'post', 1092 data: 'quantity['+key+']='+quantity, 1093 dataType: 'html', 1094 beforeSend: function() { 1095 if(!$('#unicheckout').length) { 1096 $('.header-cart__wrapper, .checkout-cart__wrap').append('<div class="preloader"></div>'); 1097 } 1098 }, 1099 success: function() { 1100 cart.uniCartUpd(key); 1101 }, 1102 error: function(xhr, ajaxOptions, thrownError) { 1103 console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 1104 } 1105 }); 1106 }, 1107 'remove': function(key, product_id) { 1108 $.ajax({ 1109 url: $('base').attr('href')+'index.php?route=checkout/cart/remove', 1110 type: 'post', 1111 data: 'key='+key, 1112 dataType: 'json', 1113 beforeSend: function() { 1114 if(!$('#unicheckout').length) { 1115 $('.header-cart__wrapper, .checkout-cart__wrap').append('<div class="preloader"></div>'); 1116 } 1117 }, 1118 success: function(json) { 1119 cart.uniCartUpd(); 1120 1121 $('.product-thumb__add-to-cart, .product-page__add-to-cart').each(function(){ 1122 if(product_id == $(this).data('pid')) {
1123 if($(this).hasClass('qty-0')) { 1124 uniChangeBtn.cart($(this), 'disabled'); 1125 } else { 1126 uniChangeBtn.cart($(this), 'normal'); 1127 } 1128 } 1129 }); 1130 }, 1131 error: function(xhr, ajaxOptions, thrownError) { 1132 console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 1133 } 1134 }); 1135 }, 1136 'uniCartUpd': function(key) { 1137 $.get('index.php?route=common/cart/info', (data) => { 1138 $('.header-cart__dropdown').html($(data).find('.header-cart__dropdown').html()); 1139 1140 const items = '.header-cart__total-items, .fly-menu__cart-total', total = $(data).find('.header-cart__total-items').text(); 1141 1142 if(total > 0) { 1143 $(items).removeClass('hidden').text(total); 1144 } else { 1145 $(items).addClass('hidden'); 1146 } 1147 1148 if($('#modal-cart').length) { 1149 const wrapper = '#modal-cart .header-cart__wrapper', scroll_top = $(wrapper).scrollTop(); 1150 1151 $('#modal-cart .modal-body').html($(data).find('.header-cart__dropdown').html()); 1152 1153 $(wrapper).scrollTop(scroll_top); 1154 1155 if($('#modal-cart .header-cart__empty').length) { 1156 setTimeout(() => { 1157 $('#modal-cart').modal('hide'); 1158 }, 1500); 1159 } 1160 } 1161 1162 if($('#checkout-cart').length || $('#checkout-checkout').length) { 1163 window.location = 'index.php?route=checkout/cart'; 1164 } 1165 }); 1166 1167 typeof(uniDelPageCache) === 'function' && uniDelPageCache(); 1168 1169 $('#unicheckout').length && uniCheckoutUpdate(); 1170 }, 1171 'uniCartActionAfter': function(action) { 1172 if(action != 'several') { 1173 action = uniJsVars.cart_add_after; 1174 } 1175 1176 if(!$('#unicheckout').length) { 1177 if(action == 'popup') { 1178 uniModalWindow('modal-cart', '', uniJsVars.modal_cart.text_heading, $('header').find('.header-cart__dropdown').html()); 1179 1180 if(uniJsVars.modal_cart.autohide) { 1181 setTimeout(() => { 1182 $('#modal-cart').modal('hide'); 1183 }, uniJsVars.modal_cart.autohide_time * 1000); 1184 } 1185 } else if (action == 'redirect') { 1186 window.location = $('base').attr('href')+'index.php?route=checkout/cart'; 1187 } 1188 } 1189 } 1190}; 1191 1192var voucher = { 1193 'add': function() { 1194 1195 }, 1196 'remove': function(key) { 1197 $.ajax({ 1198 url: $('base').attr('href')+'index.php?route=checkout/cart/remove', 1199 type: 'post', 1200 data: 'key=' + key, 1201 dataType: 'json', 1202 beforeSend: function() { 1203 if(!$('#unicheckout').length) { 1204 $('.header-cart__wrapper, .checkout-cart__wrap').append('<div class="preloader"></div>'); 1205 } 1206 }, 1207 success: function(json) { 1208 cart.uniCartUpd(); 1209 }, 1210 error: function(xhr, ajaxOptions, thrownError) { 1211 console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 1212 } 1213 }); 1214 } 1215} 1216 1217var wishlist = { 1218 'add': function(product_id) { 1219 $.ajax({ 1220 url: $('base').attr('href')+'index.php?route=account/wishlist/add', 1221 type: 'post', 1222 data: 'product_id=' + product_id, 1223 dataType: 'json', 1224 success: function(json) { 1225 if (json['redirect']) { 1226 window.location = json['redirect']; 1227 } 1228 1229 if (json['success']) { 1230 if(json['success'].indexOf('account/login') !== -1) { 1231 uniFlyAlert('warning', json['success']); 1232 } else { 1233 uniFlyAlert('success', json['success']); 1234 } 1235 1236 let wishlist_total = (json['success'].indexOf('account/login') == -1) ? json['total'].replace(/\s+/g, '').match(/(\d+)/g) : 0; 1237 1238 wishlist.uniWishlistUpd(wishlist_total); 1239 } 1240 } 1241 }); 1242 }, 1243 'remove': function(product_id) { 1244 $.ajax({ 1245 url: 'index.php?route=extension/module/uni_new_data/wishlistRemove', 1246 type: 'post', 1247 data: 'product_id='+product_id, 1248 dataType: 'json', 1249 success: function(json) { 1250 if (json['success']) { 1251 uniFlyAlert('warning', json['success']); 1252 1253 wishlist.uniWishlistUpd(json['total']); 1254 1255 $('.product-thumb__wishlist, .product-page__wishlist-btn').each(function() { 1256 let pid = Number($(this).attr('onclick').replace(/\D+/g,'')); 1257 1258 if(product_id == pid) { 1259 $(this).attr('onclick', $(this).attr('onclick').replace('wishlist.remove', 'wishlist.add')).attr('title', uniJsVars.wishlist_btn.text).removeClass('active').find('span').text(uniJsVars.wishlist_btn.text); 1260 } 1261 }); 1262 } 1263 } 1264 }); 1265 }, 1266 'uniWishlistUpd': function(total){ 1267 const items = '.fly-block__wishlist-total, .fly-menu__wishlist-total, .top-menu__wishlist-total, .header-wishlist__total-items'; 1268 1269 if(total > 0) { 1270 $(items).removeClass('hidden').text(total); 1271 } else { 1272 $(items).addClass('hidden'); 1273 } 1274 1275 typeof(uniDelPageCache) === 'function' && uniDelPageCache(); 1276 1277 $.get('index.php?route=account/wishlist', (data) => { 1278 $('.top-menu__wishlist').data('products', $(data).find('.top-menu__wishlist').data('products')); 1279 }); 1280 } 1281} 1282 1283var compare = { 1284 'add': function(product_id) { 1285 $.ajax({ 1286 url: 'index.php?route=product/compare/add', 1287 type: 'post', 1288 data: 'product_id=' + product_id, 1289 dataType: 'json', 1290 success: function(json) { 1291 if (json['success']) { 1292 uniFlyAlert('success', json['success']); 1293 1294 $('#compare-total').html('<i class="compare-block__icon fas fa-align-right"></i>'+json['total']); 1295
1296 let compare_total = json['total'].replace(/\s+/g, '').match(/(\d+)/g); 1297 1298 compare.uniCompareUpd(compare_total); 1299 } 1300 } 1301 }); 1302 }, 1303 'remove': function(product_id) { 1304 $.ajax({ 1305 url: 'index.php?route=extension/module/uni_new_data/compareRemove', 1306 type: 'post', 1307 data: 'product_id='+product_id, 1308 dataType: 'json', 1309 success: function(json) { 1310 if (json['success']) { 1311 uniFlyAlert('warning', json['success']); 1312 1313 compare.uniCompareUpd(json['total']); 1314 1315 $('.product-thumb__compare, .product-page__compare-btn').each(function() { 1316 let pid = Number($(this).attr('onclick').replace(/\D+/g,'')); 1317 1318 if(product_id == pid) { 1319 $(this).attr('onclick', $(this).attr('onclick').replace('compare.remove', 'compare.add')).attr('title', uniJsVars.compare_btn.text).removeClass('active').find('span').text(uniJsVars.compare_btn.text); 1320 } 1321 }); 1322 } 1323 } 1324 }); 1325 }, 1326 'uniCompareUpd': function(total){ 1327 const items = '.fly-block__compare-total, .fly-menu__compare-total, .top-menu__compare-total, .header-compare__total-items'; 1328 1329 if(total > 0) { 1330 $(items).removeClass('hidden').text(total); 1331 } else { 1332 $(items).addClass('hidden'); 1333 } 1334 1335 typeof(uniDelPageCache) === 'function' && uniDelPageCache(); 1336 1337 $.get('index.php?route=product/compare', (data) => { 1338 $('.top-menu__compare').data('products', $(data).find('.top-menu__compare').data('products')); 1339 }); 1340 } 1341} 1342 1343$(document).on('click', '.agree', function(e) { 1344 e.preventDefault(); 1345 1346 var element = this; 1347 1348 $.ajax({ 1349 url: $(element).attr('href'), 1350 type: 'get', 1351 dataType: 'html', 1352 success: function(data) { 1353 uniModalWindow('modal-agree', 'lg', $(element).text(), data); 1354 } 1355 }); 1356}); 1357 1358(function($) { 1359 $.fn.autocomplete = function(option) { 1360 return this.each(function() { 1361 this.timer = null; 1362 this.items = new Array(); 1363 1364 $.extend(this, option); 1365 1366 $(this).attr('autocomplete', 'off'); 1367 1368 $(this).on('focus', function() { 1369 this.request(); 1370 }); 1371 1372 $(this).on('blur', function() { 1373 setTimeout(function(object) { 1374 object.hide(); 1375 }, 200, this); 1376 }); 1377 1378 $(this).on('keydown', function(event) { 1379 switch(event.keyCode) { 1380 case 27: // escape 1381 this.hide(); 1382 break; 1383 default: 1384 this.request(); 1385 break; 1386 } 1387 }); 1388 1389 this.click = function(event) { 1390 event.preventDefault(); 1391 1392 value = $(event.target).parent().attr('data-value'); 1393 1394 if (value && this.items[value]) { 1395 this.select(this.items[value]); 1396 } 1397 } 1398 1399 this.show = function() { 1400 var pos = $(this).position(); 1401 1402 $(this).siblings('ul.dropdown-menu').css({ 1403 top: pos.top + $(this).outerHeight(), 1404 left: pos.left 1405 }); 1406 1407 $(this).siblings('ul.dropdown-menu').show(); 1408 } 1409 1410 this.hide = function() { 1411 $(this).siblings('ul.dropdown-menu').hide(); 1412 } 1413 1414 this.request = function() { 1415 clearTimeout(this.timer); 1416 1417 this.timer = setTimeout(function(object) { 1418 object.source($(object).val(), $.proxy(object.response, object)); 1419 }, 200, this); 1420 } 1421 1422 this.response = function(json) { 1423 html = ''; 1424 1425 if (json.length) { 1426 for (i = 0; i < json.length; i++) { 1427 this.items[json[i]['value']] = json[i]; 1428 } 1429 1430 for (i = 0; i < json.length; i++) { 1431 if (!json[i]['category']) { 1432 html += '<li data-value="' + json[i]['value'] + '"><a href="#">' + json[i]['label'] + '</a></li>'; 1433 } 1434 } 1435 1436 var category = new Array(); 1437 1438 for (i = 0; i < json.length; i++) { 1439 if (json[i]['category']) { 1440 if (!category[json[i]['category']]) { 1441 category[json[i]['category']] = new Array(); 1442 category[json[i]['category']]['name'] = json[i]['category']; 1443 category[json[i]['category']]['item'] = new Array(); 1444 } 1445 1446 category[json[i]['category']]['item'].push(json[i]); 1447 } 1448 } 1449 1450 for (i in category) { 1451 html += '<li class="dropdown-header">' + category[i]['name'] + '</li>'; 1452 1453 for (j = 0; j < category[i]['item'].length; j++) { 1454 html += '<li data-value="' + category[i]['item'][j]['value'] + '"><a href="#"> ' + category[i]['item'][j]['label'] + '</a></li>'; 1455 } 1456 } 1457 } 1458 1459 if (html) { 1460 this.show(); 1461 } else { 1462 this.hide(); 1463 } 1464 1465 $(this).siblings('ul.dropdown-menu').html(html); 1466 } 1467 1468 $(this).after('<ul class="dropdown-menu"></ul>'); 1469 $(this).siblings('ul.dropdown-menu').delegate('a', 'click', $.proxy(this.click, this)); 1470 1471 }); 1472 } 1473})(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.