1;(function($) { 2 // wrap tables in content for swipe on mobile devices 3 $(function() { 4 var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/i.test(navigator.userAgent); 5 6 $('article.content').find('table').wrap('<div class="for-mobile-view"></div>'); 7 8 if(isMobile){ 9 $('html').addClass('mobile'); 10 } 11 12 }); 13}(jQuery));$(function() { 14 $('.up_button').click(function () { 15 var up_speed = $(this).data('speed') 16 $('body, html').animate({ 17 scrollTop: 0 18 }, up_speed); 19 }); 20}); 21;(function(window, document) { 22 if (!window.photoSwipeSettings) { 23 window.photoSwipeSettings = {}; 24 } 25 26 var psSettings = window.photoSwipeSettings; 27 28 function initPhotoSwipeFunc(settings) { 29 if (!settings.preloadImages) { 30 settings.preloadImages = false; 31 } 32 33 var settingsKeys = Object.keys(psSettings); 34 35 if (settingsKeys.length) { 36 settingsKeys.forEach(function(key) { 37 if (key !== 'hashData') { 38 psSettings[key].push(settings[key]); 39 } 40 }); 41 } else { 42 Object.keys(settings).forEach(function(key) { 43 psSettings[key] = []; 44 45 psSettings[key].push(settings[key]); 46 }); 47 } 48 49 var galleryIteration = 0; 50 51 psSettings.gallery.forEach(function(str){ 52 if (str === settings.gallery) { 53 galleryIteration++; 54 } 55 var index = psSettings.gallery.indexOf(settings.gallery); 56 57 if (galleryIteration > 1) { 58 settingsKeys.forEach(function(key) { 59 if (key !== 'hashData') { 60 psSettings[key].splice(index, 1); 61 } 62 }); 63 galleryIteration = 0; 64 } 65 }); 66 67 if (!psSettings.hashData) { 68 psSettings.hashData = photoswipeParseHash(); 69 } 70 71 var hashData = psSettings.hashData; 72 var hashDataKeys = Object.keys(hashData); 73 74 if (hashDataKeys.length) { 75 settings.preloadImages = true; 76 } 77 78 var galleryElements = document.querySelectorAll(psSettings.gallery.join(',')); 79 var galleryLength = galleryElements.length; 80 81 var pswpHTML = '<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true"><div class="pswp__bg"></div><div class="pswp__scroll-wrap"><div class="pswp__container"><div class="pswp__item"></div><div class="pswp__item"></div><div class="pswp__item"></div></div><div class="pswp__ui pswp__ui--hidden"><div class="pswp__top-bar"><div class="pswp__counter"></div><button class="pswp__button pswp__button--close" title="Close (Esc)"></button>'; 82 var pswpHTMLEnd = '<div class="pswp__preloader"><div class="pswp__preloader__icn"><div class="pswp__preloader__cut"><div class="pswp__preloader__donut"></div></div></div></div></div><div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap"><div class="pswp__share-tooltip"></div></div><button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)"></button><button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)"></button><div class="pswp__caption"><div class="pswp__caption__center"></div></div></div></div></div>'; 83 var pswpShare = '', pswpFullscreen = '', pswpZoom = '', curGallery; 84 85 for(var i = 0; i < galleryLength; i++) { 86 curGallery = galleryElements[i]; 87 88 if (curGallery.getAttribute('data-popup-share') === '1') { 89 pswpShare = '<button class="pswp__button pswp__button--share" title="Share"></button>' 90 } 91 if (curGallery.getAttribute('data-popup-fullscreen') === '1') { 92 pswpFullscreen = '<button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>'; 93 } 94 if (curGallery.getAttribute('data-popup-zoom') === '1') { 95 pswpZoom = '<button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>'; 96 } 97 98 curGallery.setAttribute('data-pswp-uid', i+1); 99 curGallery.dataGID = i+1; 100 101 if (settings.preloadImages) { 102 parseGalleryImages(curGallery); 103 } else { 104 parseGalleryThumbs(curGallery); 105 106 if (hashData.pid && hashData.gid && hashData.gid === curGallery.dataGID) { 107 openPhotoSwipe(hashData.pid, galleryElements[hashData.gid - 1], true, true); 108 } 109 } 110 } 111 112 var pswpOverlay = document.querySelectorAll('.pswp'); 113 114 if (pswpOverlay.length === 0) { 115 pswpHTML = pswpHTML + pswpShare + pswpFullscreen + psw
115pZoom + pswpHTMLEnd; 116 117 var pswpContainer = document.createElement('div'); 118 pswpContainer.innerHTML = pswpHTML; 119 120 document.body.appendChild(pswpContainer); 121 } 122 123 function parseGalleryImages(gallery){ 124 var images = gallery.querySelectorAll(settings.item + ' img'); 125 var imagesLen = images.length; 126 var loadedArr = []; 127 128 for (var ind = 0; ind < imagesLen; ind++) { 129 setDataSize(images[ind]); 130 } 131 function setDataSize(img) { 132 var tempImg = new Image(); 133 134 var link = closest(img, function(el) { 135 return (el.tagName && el.tagName === 'A'); 136 }); 137 138 if(link){ 139 tempImg.src = link.getAttribute('href'); 140 } 141 142 143 tempImg.addEventListener('load', function() { 144 link.setAttribute('data-size', tempImg.naturalWidth + 'x' + tempImg.naturalHeight); 145 tempImg = null; 146 147 loadedArr.push('loaded'); 148 149 if (loadedArr.length === imagesLen) { 150 parseGalleryThumbs(gallery); 151 152 if (hashData.pid && hashData.gid && hashData.gid === gallery.dataGID) { 153 openPhotoSwipe(hashData.pid, galleryElements[hashData.gid - 1], true, true); 154 } 155 } 156 }); 157 } 158 } 159 function parseGalleryThumbs(gallery) { 160 var thumbs = gallery.querySelectorAll(settings.item); 161 var thumbsLen = thumbs.length; 162 var items = []; 163 var item, link, image, title, desc, size, obj; 164 165 for (var i = 0; i < thumbsLen; i++) { 166 item = thumbs[i]; 167 168 item.dataPSIndex = i; 169 item.addEventListener('click', onThumbsClick); 170 171 image = item.querySelector('img'); 172 link = item.querySelector('a[data-size]'); 173 174 title = link.getAttribute('data-title'); 175 desc = item.querySelector(settings.itemDesc); 176 177 size = link.getAttribute('data-size').split('x'); 178 179 obj = { 180 src: link.getAttribute('href'), 181 w: parseInt(size[0], 10), 182 h: parseInt(size[1], 10) 183 }; 184 185 if (title) { 186 obj.title = title; 187 } 188 189 if (desc && desc.innerHTML) { 190 obj.title += '<br /><small>' + desc.innerHTML + '</small>'; 191 } 192 193 if (link.children.length > 0) { 194 obj.msrc = image.getAttribute('src'); 195 } 196 197 obj.el = item; 198 199 items.push(obj); 200 } 201 202 return items; 203 } 204 function onThumbsClick(e) { 205 e = e || window.event; 206 207 e.preventDefault ? e.preventDefault() : e.returnValue = false; 208 209 var eTarget = e.target || e.srcElement; 210 211 var clickedItem = closest(eTarget, function(el) { 212 return ('dataPSIndex' in el); 213 }); 214 215 var clickedGallery = closest(clickedItem, function(el) { 216 return el.getAttribute('data-pswp-uid'); 217 }); 218 219 var index = clickedItem.dataPSIndex; 220 221 openPhotoSwipe(index, clickedGallery); 222 223 return false; 224 } 225 function closest(el, fn) { 226 return el && (fn(el) ? el : closest(el.parentNode, fn)); 227 } 228 function openPhotoSwipe(index, gallery, disableAnimation, fromURL) { 229 var pswpElement = document.querySelectorAll('.pswp')[0]; 230 if (!gallery) { 231 return false; 232 } 233 var items = parseGalleryThumbs(gallery); 234 var options = { 235 galleryUID: gallery.getAttribute('data-pswp-uid'), 236 getThumbBoundsFn: function(index) { 237 var thumbnail = items[index].el.getElementsByTagName('img')[0]; 238 var pageYScroll = window.pageYOffset || document.documentElement.scrollTop; 239 var rect = thumbnail.getBoundingClientRect(); 240 241 return {x:rect.left, y:rect.top + pageYScroll, w:rect.width}; 242 } 243 }; 244 if (fromURL) { 245 if(options['galleryPIDs']) { 246 for (var j = 0; j < items.length; j++) { 247 if (items[j].pid === index) { 248 options.index = j; 249 break; 250 } 251 } 252 } else { 253 options.index = parseInt(index, 10) - 1; 254 } 255 } else { 256 options.index = parseInt(index, 10); 257 } 258 if (isNaN(options.index) ) { 259 return; 260 } 261 if (disableAnimation) { 262 options.showAnimationDuration = 0; 263 options.hideAnimationDuration = 0; 264 } 265 var pswpGallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options); 266 pswpGallery.init(); 267 pswpGallery.listen('close', function() { 268 setTimeout(function(){ 269 pswpElement.classList.remove('pswp--open'); 270 }, 500); 271 }); 272 } 273 function photoswipeParseHash() { 274 var hash = location.hash.substring(1), params = {}; 275 276 if (hash.length < 5) { 277 return params; 278 } 279 280 var vars = hash.split('&'), varsL = vars.length, pair; 281 282 for (var i = 0; i < varsL; i++) {
283 if (!vars[i]) {continue;} 284 285 pair = vars[i].split('='); 286 287 if (pair.length < 2) {continue;} 288 289 params[pair[0]] = pair[1]; 290 } 291 292 if (params.gid) { 293 params.gid = parseInt(params.gid, 10); 294 } 295 296 return params; 297 } 298 } 299 300 if (!window.initPhotoSwipeFunc) { 301 window.initPhotoSwipeFunc = initPhotoSwipeFunc; 302 } 303}(window, document)); 304 305$(function() { 306 307 var $win = $(window); 308 309 var debounce = (function () { 310 return function (fn, time) { 311 var timer, func; 312 func = function() { 313 var args = [].slice.call(arguments, 0); 314 window.clearTimeout(timer); 315 timer = window.setTimeout(function () { 316 window.requestAnimationFrame && window.requestAnimationFrame(function() { 317 fn.apply(null, args); 318 }) || fn.apply(null, args); 319 }, time) 320 }; 321 return func; 322 } 323 }()); 324 325 var throttle = (function() { 326 return function (fn, threshhold, scope) { 327 threshhold || (threshhold = 250); 328 var last, 329 deferTimer, 330 func; 331 func = function () { 332 var context = scope || this; 333 var now = +new Date, 334 args = arguments; 335 if (last && now < last + threshhold) { 336 // hold on to it 337 clearTimeout(deferTimer); 338 deferTimer = setTimeout(function () { 339 last = now; 340 fn.apply(context, args); 341 }, threshhold); 342 } else { 343 last = now; 344 fn.apply(context, args); 345 } 346 }; 347 return func; 348 } 349 }()); 350 351 var psSettings = { 352 gallery: '.blocklist .body', 353 item: '.image', 354 itemDesc: '.text', 355 preloadImages: true 356 }; 357 358 $('.blocklist').each(function() { 359 var $blocklist = $(this), 360 $items = $blocklist.find('.item-outer'), 361 $list = $blocklist.find('.list'), 362 $body = $blocklist.find('.body'), 363 $controls = $blocklist.find('.controls'), 364 $pagers = $blocklist.find('.bx-pager-wrap'), 365 //$auto_controls = $blocklist.find('.auto_controls'), 366 options = {}, 367 count, 368 col_arr, pager_arr, controls_arr, 369 bxslider, 370 auto_controls_arr, 371 containerWidth, 372 isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent), 373 media_type, 374 //id = $blocklist.attr('data-layer_id') ? $blocklist.attr('data-layer_id') : $blocklist.attr('item_id'), 375 slider_arr = $blocklist.attr('data-slider').split(","), 376 swipe_arr = $blocklist.attr('data-swipe').split(","); 377 378 // Equal height 379 380 var equalizerSelector = $blocklist.attr('data-setting-vertical_aligner'), 381 isItemFlex; 382 383 function columnConform() { 384 var rowDivs = [], 385 currentTallest = 0, 386 currentRowStart = 0; 387 388 isItemFlex = $items.find('.item').css('display') == 'flex'; 389 390 $items.each(function(index) { 391 // Refresh 392 $(this).find(equalizerSelector).css('min-height', ''); 393 $(this).find(equalizerSelector).css('margin-top', ''); 394 395 var $itemOuter = $(this), 396 $item = $itemOuter.find('.item'), 397 itemHeight = sumChildrenHeight($item); 398 399 $item.data("originalHeight", itemHeight); 400 401 if (currentRowStart != $itemOuter.position().top) { 402 if (rowDivs.length > 1) { 403 for (var currentDiv = 0; currentDiv < rowDivs.length; currentDiv++) { 404 setConformingHeight(rowDivs[currentDiv], currentTallest); 405 } 406 } 407 408 // set the variables for the new row 409 rowDivs = []; 410 currentRowStart = $itemOuter.position().top; 411 currentTallest = itemHeight; 412 rowDivs.push($item); 413 414 } else { 415 rowDivs.push($item); 416 417 currentTallest = (currentTallest < itemHeight) ? (itemHeight) : (currentTallest); 418 } 419 420 }); 421 422 // do the last row 423 if (rowDivs.length > 1) { 424 for (var currentDiv = 0; currentDiv < rowDivs.length; currentDiv++) { 425 setConformingHeight(rowDivs[currentDiv], currentTallest); 426 } 427 } 428 } 429 430 function setConformingHeight(el, newHeight) { 431 var $equalizer = el.find(equalizerSelector); 432 433 if (!$equalizer.length) return; 434 435 var $beforeEqualizer = $equalizer.prev(), 436 elHeight = (el.data("originalHeight") == undefined) ? (sumChildrenHeight(el)) : (el.data("originalHeight")), 437 differHeight = newHeight - elHeight; 438 439 if (differHeight == 0) return; 440 441 var equalizerMargin = parseInt(document.defaultView.getComputedStyle($equalizer[0], "").marginTop), 442 beforeEqualizerMargin = !isItemFlex && $beforeEqualizer.length ? parseInt(document.defaultView.getComputedStyle($beforeEqualizer[0], "").marginBottom) : 0, 443 newMargin = equalizerMargin>beforeEqualizerMargin ? equalizerMargin : beforeEqualizerMargin; 444
445 $equalizer.css('margin-top', differHeight+newMargin); 446 } 447 448 function sumChildrenHeight(el) { 449 var sum = 0; 450 el.children().each(function() { 451 sum += $(this).outerHeight(); 452 }); 453 return sum; 454 } 455 456 if (equalizerSelector && equalizerSelector !== "none") { 457 setTimeout(function () { 458 columnConform(); 459 }, 0); 460 461 $win.on('resize', debounce(columnConform, 300)); 462 } 463 464 if (slider_arr.indexOf('1')>-1 && $.fn.bxSlider) { 465 466 options.pagerSelector= $blocklist.attr('data-setting-pager_selector'); 467 options.prevSelector = $blocklist.attr('data-setting-prev_selector'); 468 options.nextSelector = $blocklist.attr('data-setting-next_selector'); 469 options.prevText = $blocklist.attr('data-setting-prev_text') || ''; 470 options.nextText = $blocklist.attr('data-setting-next_text') || ''; 471 options.auto = !!parseInt($blocklist.attr('data-setting-auto')); 472 options.controls = !!parseInt($blocklist.attr('data-setting-controls')); 473 options.pager = !!parseInt($blocklist.attr('data-setting-pager').split(',')[0]); 474 options.pause = parseInt($blocklist.attr('data-setting-pause'), 10) || 4000; 475 options.useCSS = isMobile; 476 options.infiniteLoop = true; 477 options.adaptiveHeight = false; 478 options.mode = $blocklist.attr('data-setting-mode') || 'horizontal'; 479 options.touchEnabled = options.mode === 'horizontal'; 480 options.slideMargin = 0; 481 options.maxSlides = parseInt($blocklist.attr('data-setting-count').split(',')[0], 10) || 1; 482 options.minSlides = options.mode === 'horizontal' ? 1 : options.maxSlides; 483 options.moveSlides = $blocklist.attr('data-setting-move') || 0; 484 options.autoControlsSelector = $blocklist.attr('data-setting-auto_controls_selector'); 485 options.autoControls = !!parseInt($blocklist.attr('data-setting-auto_controls').split(',')[0]); 486 options.autoControlsCombine = !!parseInt($blocklist.attr('data-setting-autoControlsCombine')); 487 options.autoHover = true; 488 489 col_arr = $blocklist.attr('data-setting-columns').split(","); 490 pager_arr = $blocklist.attr('data-setting-pager').split(","); 491 controls_arr = $blocklist.attr('data-setting-controls').split(","); 492 auto_controls_arr = $blocklist.attr('data-setting-auto_controls').split(","); 493 494 if (!options.autoControls && options.auto) { 495 options.onSlideAfter = function() {
496 bxslider.startAuto(); 497 } 498 } 499 500 $items.removeClass('hidden'); 501 if ($list.parent().hasClass('bx-viewport')) { 502 $list.unwrap(); 503 $list.unwrap(); 504 } 505 506 function init(force) { 507 var setting_columns, 508 isJustify, space_between, 509 body_width = $('body').width(), 510 mediaList = ["screen", "tablet_landscape", "tablet_portrait", "mobile_landscape", "mobile_portrait"], 511 slider_arr = $blocklist.attr('data-slider').split(","); 512 513 514 if (body_width >= 961) { 515 media_type = "screen"; 516 } else if (body_width <= 960 && body_width >= 769) { 517 media_type = "tablet_landscape"; 518 } else if (body_width <= 768 && body_width >= 641) { 519 media_type = "tablet_portrait"; 520 } else if (body_width <= 640 && body_width >= 481) { 521 media_type = "mobile_landscape"; 522 } else if (body_width <= 480) { 523 media_type = "mobile_portrait"; 524 } 525 var media_ind = mediaList.indexOf(media_type); 526 var newContainerWidth = $blocklist.width(), itemHeight, viewportHeight; 527 528 if (!$blocklist.is(':visible')) { 529 if (bxslider) { 530 bxslider.destroySlider(); 531 } 532 return; 533 } 534 if (force!='force' && containerWidth && containerWidth === newContainerWidth) { 535 return; 536 } 537 containerWidth = newContainerWidth; 538 539 if (bxslider) {
540 bxslider.destroySlider(); 541 } 542 543 count = parseInt($blocklist.attr('data-setting-count').split(',')[media_ind], 10); 544 isJustify = $body.css('justify-content') == "space-between" ? true : false; 545 546 $controls.css("pointer-events","none"); 547 $controls.find('.prev').css("pointer-events","auto"); 548 $controls.find('.next').css("pointer-events","auto"); 549 550 $list.width('auto'); 551 552 $items 553 .attr('style', '') 554 .slice(1).addClass('hidden').end() 555 .width(options.slideWidth = $items.width()) 556 .removeClass('hidden'); 557 558 if (pager_arr.length > 1) { 559 options.pager = !!parseInt(pager_arr[media_ind]); 560 } 561 if (controls_arr.length > 1) { 562 options.controls = !!parseInt(controls_arr[media_ind]); 563 } 564 if (auto_controls_arr.length > 1) { 565 options.autoControls = !!parseInt(auto_controls_arr[media_ind]); 566 } 567 568 $(options.pagerSelector).css({"display": options.pager == true ? "flex" : "none"}); 569 $blocklist.find(".controls").css({"display": options.controls == true ? "flex" : "none"}); 570 571 if (options.mode === 'vertical') { 572 itemHeight = Math.max.apply(Math, $items.map(function() { 573 return $(this).height() 574 }).get()); 575 $items.css('min-height', itemHeight); 576 viewportHeight = itemHeight * count; 577 options.maxSlides = options.minSlides = count; 578 } else { 579 setting_columns = col_arr[media_ind] == "auto" ? false : parseInt(col_arr[media_ind]); 580 if (setting_columns) { 581 count = setting_columns; 582 } 583 options.maxSlides = Math.min(count, Math.ceil($items.parent().width() / $items.width())); 584 } 585 586 if (isJustify) { 587 if (options.maxSlides > 1) { 588 space_between = Math.floor(($body.width() - $items.width() * options.maxSlides)/ (options.maxSlides-1)); 589 space_between = space_between < 0 ? 0 : space_between; 590 } else { 591 space_between = 0; 592 } 593 options.slideMargin = space_between; 594 } 595 if ($items.length > options.maxSlides && slider_arr[media_ind] == 1) { 596 $list.css({'justify-content': 'flex-start'}); 597 if (bxslider) { 598 bxslider.reloadSlider(options); 599 } else { 600 $list.data('bxslider', (bxslider = $list.bxSlider(options))); 601 } 602 if(options.pager){ 603 $pagers.css('display', 'flex'); 604 } 605 } else { 606 if(swipe_arr[media_ind]!=1){ 607 $list.css({'justify-content': isJustify ? 'space-between' : 'inherit', 'flex-wrap': 'wrap'}); 608 if($list.width()/count < $items.width()) { 609 $items.css('width', $items.width()-1); 610 } else { 611 $items.css('width', $items.width()); 612 } 613 } else { 614 $list.css({'flex-wrap': 'nowrap'}); 615 } 616 $pagers.hide(); 617 $controls.hide(); 618 } 619 620 if (viewportHeight && slider_arr[media_ind] == 1) { 621 $list.parent().css('min-height', viewportHeight); 622 } 623 if (options.mode === 'horizontal') { 624 var align = {}; 625 switch ($body.css('justify-content')) { 626 case 'flex-end': 627 align['margin-left'] = 'auto'; 628 align['margin-right'] = '0px'; 629 break; 630 case 'center': 631 align['margin-left'] = 'auto'; 632 align['margin-right'] = 'auto'; 633 break; 634 default: 635 align['margin-left'] = '0px'; 636 align['margin-right'] = 'auto'; 637 } 638 $blocklist.find('.bx-wrapper').css(align); 639 } 640 641 $blocklist.wm_img_convert(); 642 } 643 644 $win.on('resize', debounce(init, 300)); 645 $win.on('load', function(){ 646 init('force'); 647 $win.trigger('resize'); 648 }); 649 650 init(); 651 } else { 652 $pagers.hide(); 653 $controls.hide(); 654 } 655 656 $win.on('resize', debounce(swipeScrollInit, 300)); 657 swipeScrollInit(); 658 659 function swipeScrollInit() { 660 var $shadowLeft = $blocklist.find(".swipe-shadow-left"); 661 var $shadowRight = $blocklist.find(".swipe-shadow-right"); 662 if ($list.css("overflow-x") == "auto") { 663 var scroll_width = $list.get(0).scrollWidth; 664 var view_width = $list.width(); 665 $shadowLeft.css("pointer-events","none"); 666 $shadowRight.css("pointer-events","none"); 667 668 $list.off('scroll'); 669 $list.on('scroll', throttle(swipeScrollCheack, 200)); 670 671 swipeScrollCheack(); 672 673 function swipeScrollCheack() { 674 var scroll_left = $list.scrollLeft(); 675 676 if (scroll_left > 0) { 677 $shadowLeft.show(); 678 } else { 679 $shadowLeft.hide(); 680 } 681 682 if (scroll_left + view_width >= scroll_width - 1) { 683 $shadowRight.hide(); 684 } else { 685 $shadowRight.show(); 686 } 687 } 688 } else { 689 $shadowLeft.hide(); 690 $shadowRight.hide(); 691 } 692 } 693 if($blocklist.attr('data_photo_swipe') == 1){ 694 //$('.pswp').appendTo('body'); 695 initPhotoSwipeFunc(psSettings); 696 $win.on('resize', function() { 697 initPhotoSwipeFunc(psSettings); 698 }); 699 } 700 701 $(document).on('click', '.shop2-product-btn2', function(e) { 702 703 var $this = $(this), 704 $form = $this.closest('form'), 705 form = $form.get(0), 706 adds = $form.find('.additional-cart-params'), 707 len = adds.length, 708 i, el, 709 a4 = form.amount.value, 710 kind_id = form.kind_id.value; 711 712 e.preventDefault(); 713 714 if (len) { 715 a4 = { 716 amount: a4 717 }; 718 719 for (i = 0; i < len; i += 1) { 720 el = adds[i]; 721 if (el.value) { 722 a4[el.name] = el.value; 723 } 724 } 725 } 726 727 shop2.cart.add(kind_id, a4, function(d) { 728 729 $('#shop2-cart-preview').replaceWith(d.data); 730 731 if (d.errstr) { 732 shop2.msg(d.errstr, $this); 733 } else { 734 shop2.msg(window._s3Lang.JS_ADDED, $this); 735 } 736 737 if (d.panel) { 738 $('#shop2-panel').replaceWith(d.panel); 739 } 740 }); 741 742 }); 743 744 }); 745 746 var blockListBody = document.querySelectorAll('.blocklist .body-outer'); 747 748 s3ContentColumns(blockListBody, { 749 body: '.list', 750 items: '.item-outer' 751 }); 752}); 753// s3ContentColumns v1.0.0 754(function(window, document, undefined) { 755 var vendors = ['ms', 'moz', 'webkit', 'o'], vendorsLength = 4; 756 var docElem = document.documentElement; 757 var winWidth = window.innerWidth || docElem.clientWidth || document.body.clientWidth; 758 var classListFlag = ('classList' in docElem); 759 var defaults = { 760 body: false, 761 items: 'random', 762 columns: '0,0,0,0,0', 763 onBeforeInit: function() {}, 764 onAfterInit: function() {} 765 }; 766 var elementMethods = { 767 sHasClass: function(classN) { 768 var elem = this; 769 if (classListFlag) { 770 return elem.classList.contains(classN); 771 } else { 772 return elem.className && new RegExp('\\b' + classN + '\\b').test(elem.className); 773 } 774 },
775 sAddClass: function(classes) { 776 var elem = this, classArr = classes.split(/\s/g), classLength = classArr.length, clInd; 777 if (classListFlag) { 778 for (clInd = 0; clInd < classLength; clInd++) {elem.classList.add(classArr[clInd]);} 779 } else { 780 for (clInd = 0; clInd < classLength; clInd++) { 781 if (!elem.sHasClass(classArr[clInd])) {elem.className += ' ' + classArr[clInd];} 782 } 783 } 784 return elem; 785 }, 786 sRemoveClass: function(classes) { 787 var elem = this, classArr = classes.split(/\s/g), classLength = classArr.length, clInd; 788 if (classListFlag) { 789 for (clInd = 0; clInd < classLength; clInd++) {elem.classList.remove(classArr[clInd]);} 790 } else { 791 var reg; 792 for (clInd = 0; clInd < classLength; clInd++) { 793 reg = new RegExp('\\b' + classArr[clInd] + '\\b', 'g'); 794 elem.className = elem.className.replace(reg, ' ').replace(/^\s\s*|\s\s*$/, ''); 795 } 796 } 797 return elem; 798 }, 799 sCSS: function(property, value) { 800 var elem = this, css3Reg = new RegExp('perspective|transform|box-sizing|user-select', 'g'); 801 function cssPrefix(prop) { 802 if (prop.match(css3Reg) && !(prop in elem.style)) { 803 for (var v = 0; v < vendorsLength; v++) { 804 if ('-'+vendors[v]+'-'+prop in elem.style) { 805 prop = '-'+vendors[v]+'-'+prop; 806 break; 807 } 808 } 809 } 810 return prop; 811 } 812 if (typeof property === 'string' && value !== undefined) { 813 elem.style[cssPrefix(property)] = value; 814 } else if (typeof property === 'string' && value === undefined) { 815 return getComputedStyle(elem)[property]; 816 } else if (typeof property === 'object') { 817 for (var cssProp in property) { 818 if (property.hasOwnProperty(cssProp)) { 819 elem.style[cssPrefix(cssProp)] = property[cssProp]; 820 } 821 } 822 } 823 return elem; 824 }, 825 sDataset: function(){ 826 var elem = this, tempData = {}; 827 function setValue(val) { 828 var num = parseInt(val), nanVal = NaN; 829 if (val === 'false') { 830 return false; 831 } else if (val === 'true') { 832 return true; 833 } else if (!(/\D/.test(val)) && typeof num === 'number' && num !== nanVal) { 834 return num; 835 } else { 836 return val; 837 } 838 } 839 if (elem.dataset) { 840 for (var propName in elem.dataset) { 841 if (!elem.dataset.hasOwnProperty(propName)) {continue;} 842 tempData[propName] = setValue(elem.dataset[propName]); 843 } 844 } else { 845 var elAttr = elem.attributes, attrLen = elAttr.length; 846 for (var ati = 0; ati < attrLen; ati++) { 847 if (/data-/.test(elAttr[ati].name) === false) {continue;} 848 var dOpt = elAttr[ati].name.replace(/data-|-\w/gi, function(str) { 849 if (str === 'data-') {return '';} 850 return str.replace('-', '').toUpperCase(); 851 }); 852 tempData[dOpt] = setValue(elAttr[ati].value); 853 } 854 } 855 return tempData; 856 }, 857 sClosest: function(fn) { 858 var elem = this, prnt = elem.parentNode; 859 return elem && (fn(elem) ? elem : ('sClosest' in prnt ? prnt.sClosest(fn) : prnt)); 860 } 861 }; 862 for (var method in elementMethods) { 863 if (elementMethods.hasOwnProperty(method) && !Element.prototype[method]) { 864 Object.defineProperty(Element.prototype, method, { 865 enumerable: false, 866 value: elementMethods[method] 867 }); 868 } 869 } 870 var pluginObj = { 871 getDOMEl: function(selector) { 872 if (selector && typeof(selector) === 'string' && /[.\-]\b/g.test(selector)) { 873 return document.querySelector(selector); 874 } else if (selector && typeof(selector) === 'object' && selector.tagName) { 875 return selector; 876 } else { 877 return false; 878 } 879 }, 880 extend: function(out) { 881 out = out || {}; 882 var i = 1, argLen = arguments.length; 883 for (; i < argLen; i++) { 884 if (!arguments[i]) {continue;} 885 for (var key in arguments[i]) { 886 if (arguments[i].hasOwnProperty(key)) {out[key] = arguments[i][key];} 887 } 888 } 889 return out; 890 }, 891 getMedia: function() { 892 var mediaType = 'screen', mediaIndex = 0; 893 if (window.matchMedia('all and (max-width: 480px)').matches) { 894 mediaType = 'mobile_portrait'; 895 mediaIndex = 4; 896 } else if (window.matchMedia('all and (max-width: 640px)').matches) { 897 mediaType = 'mobile_landscape'; 898 mediaIndex = 3; 899 } else if (window.matchMedia('all and (max-width: 768px)').matches) { 900 mediaType = 'tablet_portrait'; 901 mediaIndex = 2; 902 } else if (window.matchMedia('all and (max-width: 960px)').matches) { 903 mediaType = 'tablet_landscape'; 904 mediaIndex = 1; 905 } 906 return [mediaIndex, mediaType]; 907 }, 908 getArray: function(arg) { 909 var arr = [], len, ind, tempArr = []; 910 function setValue(val) { 911 var num = parseInt(val), nanVal = NaN; 912 if (val === 'false') { 913 return false;
914 } else if (val === 'true') { 915 return true; 916 } else if (!(/\D/.test(val)) && typeof num === 'number' && num !== nanVal) { 917 return num; 918 } else { 919 return val; 920 } 921 } 922 if (typeof arg === 'string') { 923 arr = arg.split(','); 924 } 925 len = arr.length; 926 for (ind = 0; ind < len; ind++) { 927 tempArr.push(setValue(arr[ind])); 928 } 929 return tempArr; 930 }, 931 createColumnsTable: function(wrap) { 932 var data = wrap.dataColumns, index; 933 934 data.options.onBeforeInit(wrap, data); 935 936 var columnsAmount = data.columnsArr[data.media[0]]; 937 var columnsTable = wrap.querySelector('.columns-table'); 938 939 if (columnsTable) { 940 var itemsTable = data.items[0].sClosest(function(elem){return elem.sHasClass('columns-table');}); 941 942 if (itemsTable && itemsTable.sHasClass('columns-table')) { 943 for (index = 0; index < data.itemsAmount; index++) { 944 data.body.appendChild(data.items[index]); 945 } 946 } 947 if (columnsAmount) { 948 columnsTable.innerHTML = ''; 949 } else { 950 data.body.removeChild(columnsTable); 951 } 952 } else { 953 if (columnsAmount) { 954 columnsTable = document.createElement('div').sAddClass('columns-table'); 955 data.body.appendChild(columnsTable); 956 } 957 } 958 959 if (columnsAmount) { 960 var cellStr = ''; 961 if (data.itemsAmount < columnsAmount) { 962 columnsAmount = data.itemsAmount; 963 } 964 965 for (index = 0; index < columnsAmount; index++) { 966 cellStr += '<div class="columns-cell"></div>'; 967 } 968 969 columnsTable.innerHTML = cellStr; 970 971 var columnsCells = wrap.querySelectorAll('.columns-cell'); 972 973 if (columnsAmount === 1) { 974 for (index = 0; index < data.itemsAmount; index++) { 975 columnsCells[0].appendChild(data.items[index]); 976 } 977 } else { 978 var cellWidth = columnsCells[0].clientWidth || parseFloat(columnsCells[0].sCSS('width')); 979 980 data.body.sCSS('width', cellWidth + 'px'); 981 982 var totalHeight = data.body.offsetHeight; 983 var avgColumn = Math.ceil(totalHeight / columnsAmount); 984 var heightCounter = 0; 985 var columnArrInd = 0; 986 var remColumn, remItems, newAvgColumn; 987 var currItem, currHeight, nextItem, nextHeight; 988 989 for (var itemInd = 0; itemInd < data.itemsAmount; itemInd++) { 990 currItem = data.items[itemInd]; 991 992 if (currItem === undefined || currItem.sHasClass('columns-table')) {continue;} 993 994 currHeight = currItem.offsetHeight; 995 996 nextItem = data.items[itemInd + 1]; 997 nextHeight = 0; 998 if (nextItem) { 999 nextHeight = nextItem.offsetHeight; 1000 } 1001 if (columnArrInd >= columnsAmount) { 1002 columnArrInd = columnsAmount - 1; 1003 } 1004 columnsCells[columnArrInd].appendChild(currItem); 1005 1006 totalHeight -= currHeight; 1007 heightCounter += currHeight; 1008 1009 if (totalHeight) { 1010 remColumn = columnsAmount - (columnArrInd + 1); 1011 remItems = data.itemsAmount - (itemInd + 1); 1012 newAvgColumn = totalHeight / remColumn; 1013 1014 var surplus = newAvgColumn - heightCounter; 1015 1016 var testA = remItems <= remColumn; 1017 var testB = nextHeight >= newAvgColumn; 1018 var testC = surplus <= nextHeight/2; 1019 var testD = avgColumn >= newAvgColumn && heightCounter >= newAvgColumn; 1020 1021 if (testA || testB || testC || testD) { 1022 heightCounter = 0; 1023 columnArrInd++; 1024 } 1025 } 1026 } 1027 1028 data.body.sCSS('width', ''); 1029 } 1030 } 1031 1032 data.options.onAfterInit(wrap, data); 1033 } 1034 }; 1035 var pluginMethods = { 1036 init: function(element, params) { 1037 var wrap = pluginObj.getDOMEl(element); 1038 1039 if (!wrap) {return false;} 1040 1041 var data = wrap.dataColumns, body, items, itemsAmount; 1042 1043 if (wrap && typeof(params) === 'string') { 1044 if (data && data.status === 'inited') { 1045 return false; 1046 } else if (data && data.options) { 1047 params = pluginObj.extend({}, data.options); 1048 } 1049 } 1050 if (wrap && typeof(params) !== 'string') { 1051 var options = pluginObj.extend({}, defaults, params, wrap.sDataset()); 1052 1053 body = wrap.querySelector(options.body) || wrap; 1054 1055 items = wrap.querySelectorAll(options.items); 1056 if (items && !items.length) { 1057 items = []; 1058 var contentNodes = body.childNodes; 1059 var nodesLength = contentNodes.length; 1060 var tempTag, key, tempArr = []; 1061 for (key = 0; key < nodesLength; key++) { 1062 if (!contentNodes[key].tagName && contentNodes[key].nodeValue && /[\wа-ÑÑ]+/gi.test(contentNodes[key].nodeValue)) { 1063 tempTag = document.createElement('span'); 1064 tempTag.innerHTML = contentNodes[key].nodeValue.replace(/^\s+|\s+$/g, ''); 1065 tempArr.push([contentNodes[key], tempTag]); 1066 } 1067 } 1068 nodesLength = tempArr.length; 1069 for (key = 0; key < nodesLength; key++) { 1070 body.insertBefore(tempArr[key][1], tempArr[key][0].nextSibling); 1071 tempArr[key][0].nodeValue = ''; 1072 } 1073 nodesLength = body.children.length; 1074 for (key = 0; key < nodesLength; key++) { 1075 items.push(body.children[key]); 1076 } 1077 } 1078 itemsAmount = items.length; 1079 1080 data = wrap.dataColumns = { 1081 options: options, 1082 status: 'inited', 1083 media: pluginObj.getMedia(), 1084 body: body, 1085 items: items, 1086 itemsAmount: itemsAmount, 1087 columnsArr: pluginObj.getArray(options.columns), 1088 handlers: { 1089 resizeWindow: function() { 1090 var newWinWidth = window.innerWidth || docElem.clientWidth || document.body.clientWidth; 1091 if (newWinWidth !== winWidth) { 1092 var newMedia = pluginObj.getMedia(); 1093 if (newMedia[1] !== data.media[1]) { 1094 data.media = newMedia; 1095 pluginObj.createColumnsTable(wrap); 1096 } 1097 } 1098 } 1099 } 1100 }; 1101 1102 var contentImages = wrap.querySelectorAll('img'); 1103 var imagesLength = contentImages.length, hasSVG = false;
1104 1105 if (imagesLength) { 1106 var imagesLoadCounter = 0, currentImg, curSrc; 1107 1108 for (var imgInd = 0; imgInd < imagesLength; imgInd++) { 1109 currentImg = contentImages[imgInd]; 1110 if (/image\/svg\+xml|\.svg$/g.test(currentImg.getAttribute('src'))) { 1111 hasSVG = true; 1112 break; 1113 } 1114 if (currentImg.complete || currentImg.complete === undefined){ 1115 curSrc = currentImg.src + '?imgsrc=' + (new Date()).getTime(); 1116 currentImg.src = curSrc; 1117 } 1118 currentImg.addEventListener('load', function() { 1119 imagesLoadCounter++; 1120 if (imagesLoadCounter === imagesLength) { 1121 initPlugin(); 1122 } 1123 }); 1124 } 1125 if (hasSVG) { 1126 initPlugin(); 1127 } 1128 } else { 1129 initPlugin(); 1130 } 1131 } 1132 1133 function initPlugin() { 1134 if (items && itemsAmount) { 1135 pluginObj.createColumnsTable(wrap); 1136 1137 window.addEventListener('resize', data.handlers.resizeWindow); 1138 } 1139 } 1140 1141 return wrap; 1142 } 1143 }; 1144 function s3ContentColumnsPlugin(element, method) { 1145 if (!element) {return false;} 1146 if (pluginMethods[method]) { 1147 return pluginMethods[method].apply(this, arguments); 1148 } else if (typeof method === 'object' || !method) { 1149 if (pluginObj.getDOMEl(element)) { 1150 return pluginMethods.init.apply(this, arguments); 1151 } else if (element.length) { 1152 var elementsLen = element.length; 1153 for (var argInd = 0; argInd < elementsLen; argInd++) { 1154 pluginMethods.init(element[argInd], method); 1155 } 1156 } 1157 } else { 1158 return console.error('ÐеÑод ' + method + ' не найден в плагине s3ContentColumns'); 1159 } 1160 } 1161 if (!window.s3ContentColumns) { 1162 window.s3ContentColumns = s3ContentColumnsPlugin; 1163 } 1164}(window, document)); 1165$(function() { 1166 1167 var debounce = (function () { 1168 return function (fn, time) { 1169 var timer, func; 1170 func = function() { 1171 var args = [].slice.call(arguments, 0); 1172 window.clearTimeout(timer); 1173 timer = window.setTimeout(function () { 1174 window.requestAnimationFrame && window.requestAnimationFrame(function() { 1175 fn.apply(null, args); 1176 }) || fn.apply(null, args); 1177 }, time) 1178 }; 1179 return func; 1180 } 1181 }()); 1182 1183 $('.slider').each(function() { 1184 var $this = $(this), 1185 options = {}, 1186 bxslider, 1187 $slider_item = $this.find('.slider-item'); 1188 options.mode = $this.attr('data-setting-mode'); 1189 options.pagerCustom = $this.attr('data-setting-pager_selector'); 1190 options.prevSelector = $this.attr('data-setting-prev_selector'); 1191 options.nextSelector = $this.attr('data-setting-next_selector'); 1192 options.prevText = $this.attr('data-setting-prev_text') || ''; 1193 options.nextText = $this.attr('data-setting-next_text') || ''; 1194 options.auto = !!parseInt($this.attr('data-setting-auto')); 1195 options.controls = !!parseInt($this.attr('data-setting-controls')); 1196 options.pager = !!parseInt($this.attr('data-setting-pager')); 1197 options.pause = parseInt($this.attr('data-setting-pause'), 10) || 4000; 1198 options.autoControlsSelector = $this.attr('data-setting-auto_controls_selector'); 1199 options.autoControls = !!parseInt($this.attr('data-setting-auto_controls').split(',')[0]); 1200 options.autoControlsCombine = !!parseInt($this.attr('data-setting-autoControlsCombine')); 1201 options.useCSS = false; 1202 options.responsive = false; 1203 options.autoHover = true; 1204 1205 var itemLength = $slider_item.length; 1206 var $pager_wrap = $this.find('.slider-pager-wrap'); 1207 var $pager = '<a href="" data-slide-index=""><span></span></a>'; 1208 var $dotsType = $this.attr('data-type-pager'); 1209 var textPosition = $this.attr('data-text_position'); 1210 var dataTextBlock = $this.attr('data-text-block'); 1211 var $pager_wrap_inner = $('<div class="slider-pager"></div>'); 1212 var force = true; 1213 1214 var $new_pagers_html = ''+ 1215 '<div class="bx-auto_controls">'+ 1216 '<div class="auto_controls">'+ 1217 '<div class="bx-controls-auto">'+ 1218 '<div class="bx-controls-auto-item"><a class="bx-start"></a></div>'+ 1219 '<div class="bx-controls-auto-item"><a class="bx-stop"></a></div>'+ 1220 '</div>'+ 1221 '</div>'+ 1222 '</div>'; 1223 1224 if (!options.autoControls && options.auto) { 1225 options.onSlideAfter = function () { 1226 bxslider.startAuto(); 1227 } 1228 } 1229
1230 function init() { 1231 1232 if (bxslider) { 1233 bxslider.destroySlider(); 1234 } 1235 if (!$this.is(':visible')) { 1236 return; 1237 } 1238 1239 $this.find('.slider-item[data-src]').each(function () { 1240 $(this).css('background-image', 'url("' + $(this).data('src') + '")'); 1241 }); 1242 1243 if ($this.find('.slider-item .overfill').length == 0) { 1244 $this.find('.slider-item').prepend('<div class="overfill"></div>'); 1245 } 1246 1247 var bg_attc = $this.css('background-attachment'); 1248 var bg_cl = $this.css('background-clip'); 1249 var bg_colr = $this.css('background-color'); 1250 var bg_image = $this.css('background-image'); 1251 var bg_org = $this.css('background-origin'); 1252 var bg_rep = $this.css('background-repeat'); 1253 var bg_size = $this.css('background-size'); 1254 1255 1256 $this.find('.overfill').css({ 1257 'background-attachment': bg_attc, 1258 'background-clip': bg_cl, 1259 'background-color': bg_colr, 1260 'background-image': bg_image, 1261 'background-origin': bg_org, 1262 'background-repeat': bg_rep, 1263 'background-size': bg_size 1264 }); 1265 1266 $this.find('>.overfill').remove(); 1267 1268 if(textPosition=='out' && force){ 1269 var $textWrap = $this.find('.text_wrapper'); 1270 var text_options = {}; 1271 var $textInner = $textWrap.find('.text_inner'); 1272 var clone_text = $textInner.find('.text_slider').clone(); 1273 text_options.mode = $this.attr('data-setting-mode'); 1274 text_options.auto = false; 1275 text_options.controls = false; 1276 text_options.pager = false; 1277 text_options.autoControlsSelector = false; 1278 text_options.autoControls = false; 1279 text_options.autoControlsCombine = false; 1280 1281 1282 if($this.find('>.wrap_text_dm').length > 0){ 1283 for (var i = 1; i < itemLength; i++) { 1284 $textInner.append(clone_text.clone()); 1285 } 1286 $this.find('>.wrap_text_dm').remove(); 1287 } 1288 1289 if(text_options.mode=="fade"){ 1290 var itemHeight = Math.max.apply(Math, $textInner.find('.text_slider').map(function() { 1291 return $(this).height() 1292 }).get()); 1293 $textInner.css('min-height', itemHeight); 1294 } 1295 1296 var textSlider = $textInner.bxSlider(text_options); 1297 $textInner.data('bxslider', textSlider); 1298 1299 options.onSlideNext = function(){ 1300 textSlider.goToNextSlide(); 1301 }; 1302 1303 options.onSlidePrev = function(){ 1304 textSlider.goToPrevSlide(); 1305 }; 1306 1307 options.onSlideBefore = function($slideElement, oldIndex, newIndex){ 1308 if(newIndex == 0 && oldIndex == textSlider.getSlideCount() - 1 || newIndex-oldIndex == 1) { 1309 textSlider.goToNextSlide(); 1310 } else if(oldIndex == 0 && newIndex == textSlider.getSlideCount() - 1 || oldIndex-newIndex == 1){ 1311 textSlider.goToPrevSlide(); 1312 } else { 1313 textSlider.goToSlide(newIndex); 1314 } 1315 }; 1316 force = false; 1317 1318 } else if(textPosition=='in' && $this.find('>.wrap_text_dm').length > 0){ 1319 var clone_text = $this.find('.text-slider').clone(); 1320 $this.find('.slider-item .overfill').after(clone_text); 1321 $this.find('>.wrap_text_dm').remove(); 1322 } 1323 1324 1325 if(itemLength>1){ 1326 if (bxslider) { 1327 if (options.pager && $pager_wrap.find('.slider-pager').length==0) { 1328 if($pager_wrap.find('.bx-auto_controls').length==0){ 1329 $pager_wrap.append($new_pagers_html); 1330 } 1331 $pager_wrap.find('.bx-auto_controls').append($pager_wrap_inner); 1332 1333 for (var i = 0; i < itemLength; i++) { 1334 $pager_wrap_inner.append($pager); 1335 } 1336 1337 $pager = $pager_wrap_inner.find('a'); 1338 $pager.each(function () { 1339 var $this = $(this); 1340 var index = $this.index(); 1341 $this.attr('data-slide-index', index); 1342 if ($dotsType == 'figures') { 1343 $this.find('span').html(index + 1); 1344 } 1345 }); 1346 } 1347 1348 bxslider.reloadSlider(options); 1349 1350 } else { 1351 $this.find('.slider-inner').data('bxslider', (bxslider = $this.find('.slider-inner').bxSlider(options))); 1352 } 1353 } 1354 else{ 1355 $this.find('.slider-controls').addClass('hidden'); 1356 $this.find('.slider-pager-wrap').addClass('hidden'); 1357 } 1358 } 1359 1360 $(window).on('resize', debounce(init, 300)); 1361 1362 init(); 1363 }); 1364}); 1365$(function () { 1366 $(document).click(function (event) { 1367 $('.contacts-block').each(function() { 1368 if ($(event.target).closest($(this)).length) { 1369 return; 1370 } else { 1371 $(this).find('.tgl-but').prop("checked", false); 1372 $(this).find('.icon').removeClass('active'); 1373 } 1374 }); 1375 }); 1376 1377 function setMargin($block) { 1378 if (Math.max(document.documentElement.clientWidth, window.innerWidth || 0) > 960) { 1379 $block.find(".block-body-drop").css({ 1380 "margin-left": "0px" 1381 }); 1382 } else { 1383 var left = $block.offset().left * -1; 1384 $block.find(".block-body-drop").css({ 1385 "margin-left": left + "px" 1386 }); 1387 } 1388 } 1389 1390 $('.contacts-block').each(function() { 1391 var $block = $(this), 1392 allClasses = $block.attr("class").split(" "), 1393 mainClass = allClasses[0], 1394 mainSelector = ".side-panel ."+mainClass+" .block-body-drop", 1395 styles = document.styleSheets; 1396 1397 for(var i = 0; i < styles.length; i++) { 1398 if (styles[i].href && styles[i].href.indexOf("styles.css") !== -1) { 1399 for(var j = 0; j < styles[i].cssRules.length; j++) { 1400 if (styles[i].cssRules[j].selectorText == mainSelector && styles[i].cssRules[j].style.width == "100vw") { 1401 $block.data("fullwidth", 1); 1402 setMargin($block); 1403 break; 1404 } 1405 } 1406 break; 1407 } 1408 } 1409 }); 1410 1411 $(window).resize(function() { 1412 $('.contacts-block').each(function() { 1413 var $block = $(this); 1414 if ($block.data("fullwidth") == 1) { 1415 setMargin($block); 1416 } 1417 }); 1418 }); 1419 1420 $('.contacts-block').each(function() { 1421 var $block = $(this); 1422 $block.find('.icon').click(function() { 1423 if ($block.data("fullwidth") == 1) { 1424 setMargin($block); 1425 } 1426 if ($block.find('.tgl-but').prop("checked")) { 1427 $(this).removeClass('active'); 1428 } else { 1429 $(this).addClass('active'); 1430 } 1431 }); 1432 }); 1433}); 1434/* 1435 * wmS3Menu v1.0.0 1436 * K.I. 433 1437 */ 1438;(function ($, window, document, undefined ) {
1439 var pluginName = 'wmS3Menu', 1440 defaults = { 1441 screenButton: false, 1442 responsiveTl: false, 1443 responsiveTp: false, 1444 responsiveMl: false, 1445 moreText: '...', 1446 childIcons: false, 1447 childIconsClass: 'has-child-icon' 1448 }; 1449 // ÐÑовеÑка на каÑание 1450 var isTouchable = ('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch; 1451 var $win = $(window); 1452 var winWidth = $win.width(); 1453 var $doc = $(document); 1454 1455 var pluginObj = { 1456 _events: { 1457 hover: function(menuWrap, item, settings){ 1458 var link = item.find('> a'); 1459 var linkIcon = link.find('.' + settings.childIconsClass); 1460 var iconLen = linkIcon.length; 1461 var subMenu = item.find('> ul'); 1462 var showTimeout; 1463 // ÐÑобÑажение 1464 function menuShow() { 1465 clearTimeout(showTimeout); 1466 item.siblings().find('> ul').css('display', ''); 1467 // ÐпÑеделение Ð¿Ð¾Ð»Ð¾Ð¶ÐµÐ½Ð¸Ñ Ð²ÑпадаÑки ÑÑÐ¾Ð±Ñ Ð½Ðµ вÑводилоÑÑ Ð·Ð° пÑÐµÐ´ÐµÐ»Ñ Ð¾ÐºÐ½Ð° 1468 pluginObj._menuPosition(subMenu); 1469 1470 link.addClass('hover'); 1471 if (iconLen) { 1472 linkIcon.addClass('hover'); 1473 } 1474 } 1475 // СкÑÑÑие 1476 function menuHide() { 1477 showTimeout = setTimeout(function(){ 1478 link.removeClass('hover'); 1479 subMenu.css('display', ''); 1480 if (iconLen) { 1481 linkIcon.removeClass('hover'); 1482 } 1483 }, 500); 1484 } 1485 // ÐÑклÑÑение и подклÑÑение ÑобÑÑий 1486 item.off({ 1487 'mouseenter.wmS3Menu': menuShow, 1488 'mouseleave.wmS3Menu': menuHide 1489 }); 1490 item.on({ 1491 'mouseenter.wmS3Menu': menuShow, 1492 'mouseleave.wmS3Menu': menuHide 1493 }); 1494 }, 1495 click: function(menuWrap, item, settings){ 1496 var link = item.find('> a'); 1497 var linkIcon = link.find('.' + settings.childIconsClass); 1498 var iconLen = linkIcon.length; 1499 var subMenu = item.find('> ul'); 1500 // ÐеÑеклÑÑение оÑобÑÐ°Ð¶ÐµÐ½Ð¸Ñ 1501 function menuToggle() { 1502 if (subMenu.is(':visible')) { 1503 if (isTouchable) { 1504 document.location = link.attr('href'); 1505 } 1506 link.removeClass('hover'); 1507 subMenu.css('display', ''); 1508 item.removeClass('submenu-opened'); 1509 if (iconLen) { 1510 linkIcon.removeClass('hover'); 1511 } 1512 } else { 1513 item.siblings().find('> ul').css('display', ''); 1514 item.siblings().find('> a').removeClass('hover'); 1515 item.siblings().find('> a .' + settings.childIconsClass).removeClass('hover'); 1516 // ÐпÑеделение Ð¿Ð¾Ð»Ð¾Ð¶ÐµÐ½Ð¸Ñ Ð²ÑпадаÑки ÑÑÐ¾Ð±Ñ Ð½Ðµ вÑводилоÑÑ Ð·Ð° пÑÐµÐ´ÐµÐ»Ñ Ð¾ÐºÐ½Ð° 1517 pluginObj._menuPosition(subMenu); 1518 1519 link.addClass('hover'); 1520 item.addClass('submenu-opened'); 1521 if (iconLen) { 1522 linkIcon.addClass('hover'); 1523 } 1524 } 1525 return false; 1526 } 1527 // ÐÑклÑÑение и подклÑÑение ÑобÑÑий 1528 link.off('click.wmS3Menu'); 1529 link.on('click.wmS3Menu', menuToggle); 1530 }, 1531 click_tree: function(menuWrap, item, settings){ 1532 var link = item.find('> a'); 1533 var linkIcon = link.find('.' + settings.childIconsClass); 1534 var subMenu = item.find('> ul'); 1535 // ÐеÑеклÑÑение оÑобÑÐ°Ð¶ÐµÐ½Ð¸Ñ 1536 function menuToggle(event) { 1537 var targ = $(event.target); 1538 1539 if (targ.closest(linkIcon).length) { 1540 if (subMenu.is(':visible')) { 1541 link.removeClass('hover'); 1542 subMenu.css('display', ''); 1543 item.removeClass('submenu-opened'); 1544 linkIcon.removeClass('hover'); 1545 } else { 1546 // ÐпÑеделение Ð¿Ð¾Ð»Ð¾Ð¶ÐµÐ½Ð¸Ñ Ð²ÑпадаÑки ÑÑÐ¾Ð±Ñ Ð½Ðµ вÑводилоÑÑ Ð·Ð° пÑÐµÐ´ÐµÐ»Ñ Ð¾ÐºÐ½Ð° 1547 pluginObj._menuPosition(subMenu); 1548 1549 link.addClass('hover'); 1550 item.addClass('submenu-opened'); 1551 linkIcon.addClass('hover'); 1552 } 1553 return false; 1554 } 1555 } 1556 // ÐÑклÑÑение и подклÑÑение ÑобÑÑий 1557 link.off('click.wmS3Menu'); 1558 link.on('click.wmS3Menu', menuToggle); 1559 } 1560 }, 1561 _menuPosition: function(subMenu) { 1562 // ÐпÑеделение Ð¿Ð¾Ð»Ð¾Ð¶ÐµÐ½Ð¸Ñ Ð²ÑпадаÑки ÑÑÐ¾Ð±Ñ Ð½Ðµ вÑводилоÑÑ Ð·Ð° пÑÐµÐ´ÐµÐ»Ñ Ð¾ÐºÐ½Ð° 1563 winWidth = $win.width(); 1564 1565 subMenu.css('display', 'block'); 1566 1567 if (subMenu.parent().hasClass('first-level') === false) { 1568 subMenu.css({ 1569 'visibility': 'hidden', 1570 'opacity': 0 1571 }); 1572 1573 var menuRect = subMenu[0].getBoundingClientRect(); 1574 var marginR = parseInt(subMenu.css('margin-right')); 1575 var parentWidth = subMenu.parent().width(); 1576 1577 if (marginR > parentWidth) { 1578 subMenu.css('margin-right', parentWidth); 1579 } 1580 1581 if (menuRect.right >= winWidth) { 1582 subMenu.css({ 1583 'left': '-100%', 1584 'margin-left': 0 1585 }); 1586 } 1587 subMenu.css({ 1588 'visibility': '', 1589 'opacity': '' 1590 }); 1591 } 1592 } 1593 }; 1594 function Plugin(element, options) { 1595 this.element = element; 1596 1597 this.options = $.extend({}, defaults, options, $(this.element).data()) ; 1598 1599 this._defaults = defaults; 1600 this._name = pluginName; 1601 1602 this.init(); 1603 } 1604 Plugin.prototype = { 1605 init: function () { 1606 var settings = this.options; 1607 // ÐпÑеделение ÑиÑÐ¸Ð½Ñ Ð¼ÐµÐ´Ð¸Ð° 1608 var moreButFlag = false;
1609 if (window.matchMedia('all and (max-width: 480px)').matches) { 1610 moreButFlag = settings.responsiveMl; 1611 } else if (window.matchMedia('all and (max-width: 640px)').matches) { 1612 //moreButFlag = settings.responsiveTp; 1613 } else if (window.matchMedia('all and (max-width: 768px)').matches) { 1614 moreButFlag = settings.responsiveTl; 1615 } else { 1616 moreButFlag = settings.screenButton; 1617 } 1618 // ÐбеÑÑка Ð¼ÐµÐ½Ñ 1619 var menuWrap = $(this.element); 1620 var menuClass = menuWrap.attr('class'); 1621 var menuMainUl = $(this.element.querySelector('ul')); 1622 var widgetClass = menuClass.match(/widget-\d+/)[0]; 1623 // ÐÑовеÑка на налиÑие Ð¼ÐµÐ½Ñ Ð² Side panel 1624 if (window.side_panel_controller && side_panel_controller.inPanel(widgetClass)) { 1625 moreButFlag = false; 1626 } 1627 1628 menuMainUl.children().addClass('first-level'); 1629 // ÐаÑÑÑойки Ð´Ð»Ñ Ð³Ð¾ÑизонÑалÑного Ð¼ÐµÐ½Ñ 1630 if (!!menuClass.match(/horizontal/i)) { 1631 var menuWidth = menuMainUl.width(); 1632 var itemsWidth = 0, hideArr = [], hideLength; 1633 // Ðнопка More 1634 var moreBut = menuMainUl.find('.more-button'); 1635 if (!moreBut.length) { 1636 moreBut = $('<li class="more-button"><a href="#"><span>' + settings.moreText + '</span></a></li>');// data-trigger="click" 1637 menuMainUl.append(moreBut); 1638 } 1639 // ÐÐµÐ½Ñ More 1640 var moreMenu = moreBut.find('> ul'); 1641 if (!moreMenu.length) { 1642 moreMenu = $('<ul></ul>'); 1643 moreBut.append(moreMenu); 1644 } 1645 1646 moreBut.removeClass('removed').attr('data-trigger', 'hover'); 1647 menuMainUl.children().css('display', ''); 1648 1649 var firstLevelItems = menuMainUl.children(':visible').not('.more-button'); 1650 moreMenu.html(''); 1651 1652 if (moreButFlag === 'more' || moreButFlag === 'button') { 1653 moreBut.removeClass('disabled'); 1654 1655 menuWidth -= moreBut.outerWidth(); 1656 1657 firstLevelItems.each(function(){ 1658 var thisItem = $(this); 1659 itemsWidth += thisItem.outerWidth(true); 1660 if (itemsWidth >= menuWidth) { 1661 hideArr.push(thisItem.clone()); 1662 thisItem.hide(); 1663 } 1664 }); 1665 1666 hideLength = hideArr.length; 1667 if (hideLength) { 1668 for (var ind = 0; ind < hideLength; ind++) { 1669 moreMenu.append(hideArr[ind]); 1670 } 1671 moreBut.removeClass('disabled'); 1672 } else { 1673 moreBut.addClass('disabled'); 1674 } 1675 } else { 1676 moreBut.addClass('disabled'); 1677 } 1678 } 1679 // ÐложеннÑе подÑÑовни Ð¼ÐµÐ½Ñ 1680 var menuInner = menuMainUl.find('ul'); 1681 var menuItems = menuInner.parent(); 1682 var menuLinks = menuItems.find('> a'); 1683 // СÑÑелоÑки Ð´Ð»Ñ Ð¿Ð¾Ð´ÑÑовней 1684 var menuLinksIcons = menuLinks.find('.' + settings.childIconsClass); 1685 var childIconLen = menuLinksIcons.length; 1686 // Тип оÑобÑÐ°Ð¶ÐµÐ½Ð¸Ñ Ð¼ÐµÐ½Ñ 1687 var mShow = 'popup'; 1688 if (!!menuClass.match(/dropdown/i)) { 1689 mShow = 'dropdown'; 1690 } else if (!!menuClass.match(/treemenu/i)) { 1691 mShow = 'treemenu'; 1692 } 1693 if (mShow === 'popup') { 1694 menuInner.hide(); 1695 } 1696 if (childIconLen) { 1697 menuLinksIcons.remove(); 1698 } 1699 if (!!settings.childIcons) { 1700 // Ðобавление ÑÑÑелоÑек Ð´Ð»Ñ Ð¿Ð¾Ð´ÑÑовней 1701 var childIconHTML = '<em class="' + settings.childIconsClass + '"></em>'; 1702 1703 if (mShow === 'treemenu') { 1704 childIconHTML = '<em class="' + settings.childIconsClass + '"><b style="position: absolute; top: 50%; left: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px;"></b></em>'; 1705 } 1706 1707 var childIconTag = $(childIconHTML); 1708 menuLinks.append(childIconTag.clone()); 1709 1710 menuLinksIcons = menuLinks.find('.' + settings.childIconsClass); 1711 childIconLen = menuLinksIcons.length; 1712 } 1713 // Удаление вÑÐµÑ ÑобÑÑий на ÑÑÑÐ»ÐºÐ°Ñ 1714 menuLinks.removeClass('hover').off('click.wmS3Menu'); 1715 menuInner.css('display', ''); 1716 if (childIconLen) { 1717 menuLinksIcons.removeClass('hover'); 1718 } 1719 1720 menuItems.each(function() { 1721 var thisItem = $(this); 1722 var trigger = thisItem.data('trigger') || 'hover'; 1723 1724 if (mShow === 'dropdown' || isTouchable) { 1725 trigger = 'click'; 1726 } else if (mShow === 'treemenu') { 1727 trigger = 'click_tree';
1728 } 1729 pluginObj._events[trigger](menuWrap, thisItem, settings); 1730 }); 1731 // Ðлик по докÑменÑÑ 1732 if (isTouchable) { 1733 function docClick(e) { 1734 var target = $(e.target); 1735 if (target.closest(menuWrap).length === 0) { 1736 menuLinks.removeClass('hover'); 1737 menuInner.css('display', ''); 1738 menuItems.removeClass('submenu-opened'); 1739 1740 if (childIconLen) { 1741 menuLinksIcons.removeClass('hover'); 1742 } 1743 } 1744 } 1745 $doc.off('touchstart.wmS3Menu', docClick); 1746 $doc.on('touchstart.wmS3Menu', docClick); 1747 } 1748 }, 1749 update: function () { 1750 this.init(); 1751 } 1752 }; 1753 if (!$.fn[pluginName]) { 1754 $.fn[pluginName] = function (options) { 1755 var args = arguments; 1756 if (options === undefined || typeof options === 'object') { 1757 return this.each(function () { 1758 if (!$.data(this, 'plugin_' + pluginName)) { 1759 $.data(this, 'plugin_' + pluginName, new Plugin(this, options)); 1760 } 1761 }); 1762 } else if (typeof options === 'string' && options[0] !== '_' && options !== 'init') { 1763 var returns; 1764 this.each(function () { 1765 var instance = $.data(this, 'plugin_' + pluginName); 1766 if (instance instanceof Plugin && typeof instance[options] === 'function') { 1767 returns = instance[options].apply(instance, Array.prototype.slice.call(args, 1)); 1768 } 1769 if (options === 'destroy') { 1770 $.data(this, 'plugin_' + pluginName, null); 1771 } 1772 }); 1773 return returns !== undefined ? returns : this; 1774 } 1775 }; 1776 } 1777 $(function () { 1778 var wmMenuWrap = $('.wm-widget-menu.horizontal'); 1779 wmMenuWrap[pluginName](); 1780 1781 $win.on('resize.wmS3Menu', function(){ 1782 wmMenuWrap[pluginName]('update'); 1783 }); 1784 }); 1785 1786 setTimeout(function(){ 1787 $win.trigger('resize'); 1788 }, 500); 1789}(jQuery, window, document)); 1790$(function () { 1791 $(document).click(function (event) { 1792 $('.contacts-block').each(function() { 1793 if ($(event.target).closest($(this)).length) { 1794 return; 1795 } else { 1796 $(this).find('.tgl-but').prop("checked", false); 1797 $(this).find('.icon').removeClass('active'); 1798 } 1799 }); 1800 }); 1801 1802 function setMargin($block) { 1803 if (Math.max(document.documentElement.clientWidth, window.innerWidth || 0) > 960) { 1804 $block.find(".block-body-drop").css({ 1805 "margin-left": "0px" 1806 }); 1807 } else { 1808 var left = $block.offset().left * -1; 1809 $block.find(".block-body-drop").css({ 1810 "margin-left": left + "px" 1811 }); 1812 } 1813 } 1814 1815 $('.contacts-block').each(function() { 1816 var $block = $(this), 1817 allClasses = $block.attr("class").split(" "), 1818 mainClass = allClasses[0], 1819 mainSelector = ".side-panel ."+mainClass+" .block-body-drop", 1820 styles = document.styleSheets; 1821 1822 for(var i = 0; i < styles.length; i++) { 1823 if (styles[i].href && styles[i].href.indexOf("styles.css") !== -1) { 1824 for(var j = 0; j < styles[i].cssRules.length; j++) { 1825 if (styles[i].cssRules[j].selectorText == mainSelector && styles[i].cssRules[j].style.width == "100vw") { 1826 $block.data("fullwidth", 1); 1827 setMargin($block); 1828 break; 1829 } 1830 } 1831 break; 1832 } 1833 } 1834 }); 1835 1836 $(window).resize(function() { 1837 $('.contacts-block').each(function() { 1838 var $block = $(this); 1839 if ($block.data("fullwidth") == 1) { 1840 setMargin($block); 1841 } 1842 }); 1843 }); 1844 1845 $('.contacts-block').each(function() { 1846 var $block = $(this); 1847 $block.find('.icon').click(function() { 1848 if ($block.data("fullwidth") == 1) { 1849 setMargin($block); 1850 } 1851 if ($block.find('.tgl-but').prop("checked")) { 1852 $(this).removeClass('active'); 1853 } else { 1854 $(this).addClass('active'); 1855 } 1856 }); 1857 }); 1858}); 1859$(function () { 1860 $(document).click(function (event) { 1861 $('.contacts-block').each(function() { 1862 if ($(event.target).closest($(this)).length) { 1863 return; 1864 } else { 1865 $(this).find('.tgl-but').prop("checked", false); 1866 $(this).find('.icon').removeClass('active'); 1867 } 1868 }); 1869 }); 1870 1871 function setMargin($block) { 1872 if (Math.max(document.documentElement.clientWidth, window.innerWidth || 0) > 960) { 1873 $block.find(".block-body-drop").css({ 1874 "margin-left": "0px" 1875 }); 1876 } else { 1877 var left = $block.offset().left * -1; 1878 $block.find(".block-body-drop").css({ 1879 "margin-left": left + "px" 1880 }); 1881 } 1882 } 1883 1884 $('.contacts-block').each(function() { 1885 var $block = $(this), 1886 allClasses = $block.attr("class").split(" "), 1887 mainClass = allClasses[0], 1888 mainSelector = ".side-panel ."+mainClass+" .block-body-drop", 1889 styles = document.styleSheets; 1890 1891 for(var i = 0; i < styles.length; i++) { 1892 if (styles[i].href && styles[i].href.indexOf("styles.css") !== -1) { 1893 for(var j = 0; j < styles[i].cssRules.length; j++) { 1894 if (styles[i].cssRules[j].selectorText == mainSelector && styles[i].cssRules[j].style.width == "100vw") { 1895 $block.data("fullwidth", 1); 1896 setMargin($block); 1897 break; 1898 } 1899 } 1900 break; 1901 } 1902 } 1903 }); 1904 1905 $(window).resize(function() { 1906 $('.contacts-block').each(function() { 1907 var $block = $(this); 1908 if ($block.data("fullwidth") == 1) { 1909 setMargin($block); 1910 } 1911 }); 1912 }); 1913 1914 $('.contacts-block').each(function() { 1915 var $block = $(this); 1916 $block.find('.icon').click(function() { 1917 if ($block.data("fullwidth") == 1) { 1918 setMargin($block); 1919 } 1920 if ($block.find('.tgl-but').prop("checked")) { 1921 $(this).removeClass('active'); 1922 } else { 1923 $(this).addClass('active'); 1924 } 1925 }); 1926 }); 1927}); 1928document.addEventListener('DOMContentLoaded', function() { 1929 var bodyScrollBarWidth = (function () { 1930 var widthHidden, widthScroll, currentValue, currentPriority; 1931 currentValue = document.body.style.getPropertyValue('overflow'); 1932 currentPriority = document.body.style.getPropertyPriority('overflow'); 1933 document.body.style.setProperty('overflow', 'hidden', 'important'); 1934 widthHidden = document.body.clientWidth; 1935 document.body.style.setProperty('overflow', 'scroll', 'important'); 1936 widthScroll = document.body.clientWidth; 1937 document.body.style.setProperty('overflow', currentValue ? currentValue : '', currentPriority); 1938 return widthHidden - widthScroll; 1939 }()); 1940 var media = { 1941 'tablet-landscape': 960, 1942 'tablet-portrait': 768, 1943 'mobile-landscape': 640, 1944 'mobile-portrait': 480 1945 }; 1946 var side_panel = document.querySelector('.side-panel'); 1947 var side_panel_content, side_panel_content_inner, side_panel_top, side_panel_mask, side_panel_button, side_panel_close, side_panel_controller, leftEdge, rightEdge, isPhantom; 1948 var layers, content_width, flip, full_width, elements = {}, comments = {}; 1949 1950 if (!side_panel || side_panel.classList.contains('removed')) { 1951 return; 1952 } 1953 1954 flip = side_panel.getAttribute('data-position') === 'right'; 1955 1956 try { 1957 layers = side_panel.getAttribute('data-layers'); 1958 if (layers !== "") { 1959 layers = JSON.parse(layers.replace(/\[/g, '{').replace(/\]/g, '}').replace(/\'/g, '"')); 1960 } 1961 } catch(e) { 1962 console.error(e); 1963 } 1964 1965 if (typeof layers !== 'object' || Object.keys(layers).length === 0) { 1966 return; 1967 } 1968
1969 Object.keys(layers).forEach(function(clss) { 1970 elements[clss] = document.querySelector('.' + clss); 1971 comments[clss] = document.createComment(clss); 1972 if (elements[clss]) { 1973 elements[clss].parentNode.insertBefore(comments[clss], elements[clss]); 1974 } else { 1975 delete layers[clss]; 1976 } 1977 }); 1978 1979 side_panel_button = side_panel.querySelector('.side-panel-button'); 1980 side_panel_close = side_panel.querySelector('.side-panel-close'); 1981 side_panel_content = side_panel.querySelector('.side-panel-content'); 1982 side_panel_content_inner = side_panel.querySelector('.side-panel-content-inner') || side_panel_content; 1983 side_panel_mask = side_panel.querySelector('.side-panel-mask'); 1984 side_panel_top = side_panel.querySelector('.side-panel-top-inner'); 1985 1986 side_panel.classList.remove('hidden'); 1987 side_panel_button.classList.remove('hidden'); 1988 side_panel_button.style.display = 'none'; 1989 side_panel_content.classList.remove('hidden'); 1990 side_panel_content.style.display = 'none'; 1991 side_panel_mask.classList.remove('hidden'); 1992 side_panel_mask.style.display = 'none'; 1993 1994 content_width = getComputedStyle(side_panel_content, null).width; 1995 1996 leftEdge = 0; 1997 rightEdge = parseInt(content_width) + 50; 1998 1999 if (content_width === 'auto') { 2000 rightEdge = Math.max(document.documentElement.clientWidth, window.innerWidth || 0); 2001 full_width = true; 2002 } 2003 2004 isPhantom = !!parseInt($(side_panel).attr("data-phantom")); 2005 2006 if (isPhantom) { 2007 $(side_panel).css({"pointer-events": "none"}); 2008 } else { 2009 $(side_panel).css({"pointer-events": "auto"}); 2010 } 2011 2012 if (flip) { 2013 side_panel_content.style.left = 'auto'; 2014 side_panel_content.style.right = '0'; 2015 } 2016 2017 if (full_width) { 2018 side_panel_content.style.left = '0'; 2019 side_panel_content.style.right = '0'; 2020 } 2021 2022 window.side_panel_controller = side_panel_controller = new DrawerController({ 2023 target: side_panel, 2024 full_width: full_width, 2025 left: leftEdge, 2026 right: rightEdge, 2027 position: 0, 2028 flip: flip, 2029 curve: 'ease-in-out', 2030 willOpen: function() { 2031 side_panel_mask.style.display = 'block'; 2032 side_panel_content.style.display = 'block'; 2033 document.body.classList.add('noscroll'); 2034 if (bodyScrollBarWidth && document.documentElement.scrollHeight > document.documentElement.clientHeight) { 2035 document.body.style.borderRight = bodyScrollBarWidth + 'px solid transparent' 2036 } 2037 }, 2038 didClose: function() { 2039 side_panel_mask.style.display = 'none'; 2040 side_panel_content.style.display = 'none'; 2041 document.body.classList.remove('noscroll'); 2042 if (bodyScrollBarWidth && document.documentElement.scrollHeight > document.documentElement.clientHeight) { 2043 document.body.style.borderRight = '' 2044 } 2045 }, 2046 onAnimate: function(position) { 2047 side_panel_mask.style.opacity = position / rightEdge; 2048 side_panel_content.style.transform = 'translate3d(' + (flip ? rightEdge - position : position - rightEdge) + 'px,0,0)'; 2049 } 2050 }); 2051 2052 side_panel_controller.inPanel = function(clss) { 2053 var viewportWidth; 2054 var current_media; 2055 2056 if (typeof clss !== 'string') { 2057 return false; 2058 } 2059 2060 if (clss.charAt(0) === '.') { 2061 clss = clss.slice(1); 2062 } 2063 2064 viewportWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0); 2065 2066 Object.keys(media).forEach(function(key) { 2067 if (viewportWidth <= media[key]) { 2068 current_media = key; 2069 } 2070 }); 2071 2072 if (typeof current_media === 'undefined') { 2073 current_media = 'screen'; 2074 } 2075 2076 return layers[clss] && layers[clss][current_media]; 2077 }; 2078 2079 side_panel_button.addEventListener('click', function(e) { 2080 e.preventDefault();
2081 side_panel_controller.toggle(); 2082 return false; 2083 }); 2084 2085 if (side_panel_close) { 2086 side_panel_close.addEventListener('click', function(e) { 2087 e.preventDefault(); 2088 side_panel_controller.close(); 2089 return false; 2090 }); 2091 } 2092 2093 side_panel_mask.addEventListener('click', function() { 2094 side_panel_controller.close(); 2095 return false; 2096 }); 2097 2098 document.addEventListener('keyup', function(e) { 2099 if (e.keyCode === 27) { 2100 side_panel_controller.close(); 2101 return false; 2102 } 2103 }); 2104 2105 var debounce = (function () { 2106 return function (fn, time) { 2107 var timer, func; 2108 if (window.requestAnimationFrame) { 2109 func = function() { 2110 timer && cancelAnimationFrame(timer); 2111 timer = requestAnimationFrame(fn); 2112 } 2113 } else { 2114 func = function() { 2115 window.clearTimeout(timer); 2116 timer = window.setTimeout(function () { 2117 fn(); 2118 }, time) 2119 }; 2120 } 2121 return func; 2122 } 2123 }()); 2124 2125 function checkSidePanel() { 2126 var viewportWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0); 2127 var current_media; 2128 var emptySide = true; 2129 var emptyTop = true; 2130 2131 if (checkSidePanel.viewportWidth === viewportWidth) { 2132 return; 2133 } 2134 2135 checkSidePanel.viewportWidth = viewportWidth; 2136 2137 Object.keys(media).forEach(function(key) { 2138 if (viewportWidth <= media[key]) { 2139 current_media = key; 2140 } 2141 }); 2142 2143 if (typeof current_media === 'undefined') { 2144 current_media = 'screen'; 2145 } 2146 2147 Object.keys(layers).forEach(function(clss){ 2148 var element, comment; 2149 2150 element = elements[clss]; 2151 comment = comments[clss]; 2152 2153 if (current_media in layers[clss]) { 2154 if (layers[clss][current_media] === 'onTop') { 2155 side_panel_top.appendChild(element); 2156 emptyTop = false; 2157 } else { 2158 side_panel_content_inner.appendChild(element); 2159 emptySide = false;
2160 } 2161 } else { 2162 if (comment) { 2163 comment.parentNode.insertBefore(element, comment); 2164 } 2165 } 2166 }); 2167 2168 if (emptySide) { 2169 side_panel_button.style.display = 'none'; 2170 } else { 2171 side_panel_button.style.display = 'block'; 2172 } 2173 2174 if (!emptyTop || !emptySide) { 2175 side_panel.style.display = 'block'; 2176 } else { 2177 side_panel.style.display = 'none'; 2178 side_panel_controller.close(); 2179 } 2180 } 2181 2182 checkSidePanel = debounce(checkSidePanel, 40); 2183 2184 checkSidePanel(); 2185 window.addEventListener('resize', checkSidePanel); 2186}); 2187/* 2188 * @license 2189 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. 2190 * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 2191 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 2192 * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 2193 * Code distributed by Google as part of the polymer project is also 2194 * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 2195 */ 2196 2197"use strict"; 2198 2199(function (exports) { 2200 2201 function sign(number) { 2202 if (number < 0) 2203 return -1; 2204 if (number > 0) 2205 return 1; 2206 return 0; 2207 } 2208 2209 function Animator(delegate) { 2210 this.delegate = delegate; 2211 this.startTimeStamp = 0; 2212 this.request_ = null; 2213 }; 2214 2215 Animator.prototype.scheduleAnimation = function () { 2216 if (this.request_) 2217 return; 2218 this.request_ = requestAnimationFrame(this.onAnimation_.bind(this)); 2219 }; 2220 2221 Animator.prototype.startAnimation = function () { 2222 this.startTimeStamp = 0; 2223 this.scheduleAnimation(); 2224 }; 2225 2226 Animator.prototype.stopAnimation = function () { 2227 cancelAnimationFrame(this.request_); 2228 this.startTimeStamp = 0; 2229 this.request_ = null; 2230 }; 2231 2232 Animator.prototype.onAnimation_ = function (timeStamp) { 2233 this.request_ = null; 2234 if (!this.startTimeStamp) 2235 this.startTimeStamp = timeStamp; 2236 if (this.delegate.onAnimation(timeStamp)) 2237 this.scheduleAnimation(); 2238 }; 2239 2240 function VelocityTracker() { 2241 this.recentTouchMoves_ = []; 2242 this.velocityX = 0; 2243 this.velocityY = 0; 2244 } 2245 2246 VelocityTracker.kTimeWindow = 50; 2247 2248 VelocityTracker.prototype.pruneHistory_ = function (timeStamp) { 2249 for (var i = 0; i < this.recentTouchMoves_.length; ++i) { 2250 if (this.recentTouchMoves_[i].timeStamp > timeStamp - VelocityTracker.kTimeWindow) { 2251 this.recentTouchMoves_ = this.recentTouchMoves_.slice(i); 2252 return; 2253 } 2254 } 2255 // All touchmoves are old. 2256 this.recentTouchMoves_ = []; 2257 }; 2258 2259 VelocityTracker.prototype.update_ = function (e) { 2260 this.pruneHistory_(e.timeStamp); 2261 this.recentTouchMoves_.push(e); 2262 2263 var oldestTouchMove = this.recentTouchMoves_[0]; 2264 2265 var deltaX = e.changedTouches[0].clientX - oldestTouchMove.changedTouches[0].clientX; 2266 var deltaY = e.changedTouches[0].clientY - oldestTouchMove.changedTouches[0].clientY; 2267 var deltaT = e.timeStamp - oldestTouchMove.timeStamp; 2268 2269 if (deltaT > 0) { 2270 this.velocityX = deltaX / deltaT; 2271 this.velocityY = deltaY / deltaT; 2272 } else { 2273 this.velocityX = 0; 2274 this.velocityY = 0; 2275 } 2276 }; 2277 2278 VelocityTracker.prototype.onTouchStart = function (e) { 2279 this.recentTouchMoves_.push(e); 2280 this.velocityX = 0; 2281 this.velocityY = 0; 2282 }; 2283 2284 VelocityTracker.prototype.onTouchMove = function (e) { 2285 this.update_(e); 2286 }; 2287 2288 VelocityTracker.prototype.onTouchEnd = function (e) { 2289 this.update_(e); 2290 this.recentTouchMoves_ = []; 2291 }; 2292 2293 function LinearTimingFunction() { 2294 }; 2295 2296 LinearTimingFunction.prototype.scaleTime = function (fraction) { 2297 return fraction; 2298 }; 2299 2300 function CubicBezierTimingFunction(spec) { 2301 this.map = []; 2302 for (var ii = 0; ii <= 100; ii += 1) { 2303 var i = ii / 100; 2304 this.map.push([ 2305 3 * i * (1 - i) * (1 - i) * spec[0] + 2306 3 * i * i * (1 - i) * spec[2] + i * i * i, 2307 3 * i * (1 - i) * (1 - i) * spec[1] + 2308 3 * i * i * (1 - i) * spec[3] + i * i * i 2309 ]); 2310 } 2311 }; 2312 2313 CubicBezierTimingFunction.prototype.scaleTime = function (fraction) { 2314 var fst = 0; 2315 while (fst !== 100 && fraction > this.map[fst][0]) { 2316 fst += 1; 2317 } 2318 if (fraction === this.map[fst][0] || fst === 0) { 2319 return this.map[fst][1]; 2320 } 2321 var yDiff = this.map[fst][1] - this.map[fst - 1][1]; 2322 var xDiff = this.map[fst][0] - this.map[fst - 1][0]; 2323 var p = (fraction - this.map[fst - 1][0]) / xDiff; 2324 return this.map[fst - 1][1] + p * yDiff; 2325 }; 2326 2327 var presetTimingFunctions = { 2328 'linear': new LinearTimingFunction(), 2329 'ease': new CubicBezierTimingFunction([0.25, 0.1, 0.25, 1.0]), 2330 'ease-in': new CubicBezierTimingFunction([0.42, 0, 1.0, 1.0]), 2331 'ease-out': new CubicBezierTimingFunction([0, 0, 0.58, 1.0]), 2332 'ease-in-out': new CubicBezierTimingFunction([0.42, 0, 0.58, 1.0]), 2333 }; 2334 2335 function DrawerController(options) { 2336 this.velocityTracker = new VelocityTracker(); 2337 this.animator = new Animator(this); 2338 2339 this.target = options.target; 2340 this.left = options.left; 2341 this.right = options.right; 2342 this.position = options.position; 2343 this.flip = options.flip; 2344 this.full_width = options.full_width; 2345 2346 this.width = this.right - this.left; 2347 this.curve = presetTimingFunctions[options.curve || 'linear']; 2348 2349 this.willOpenCallback = options.willOpen; 2350 this.didCloseCallback = options.didClose; 2351 this.animateCallback = options.onAnimate; 2352 2353 this.state = DrawerController.kClosed; 2354 2355 this.defaultAnimationSpeed = (this.right - this.left) / DrawerController.kBaseSettleDurationMS; 2356 2357 this.onTouchMove = this.onTouchMove.bind(this); 2358 this.onTouchEnd = this.onTouchEnd.bind(this); 2359 2360 if (!this.full_width) { 2361 this.target.addEventListener('touchstart', this.onTouchStart.bind(this)); 2362 } 2363 } 2364 2365 DrawerController.kOpened = 'opened'; 2366 DrawerController.kClosed = 'closed'; 2367 DrawerController.kOpening = 'opening'; 2368 DrawerController.kClosing = 'closing'; 2369 DrawerController.kDragging = 'dragging'; 2370 DrawerController.kFlinging = 'flinging'; 2371 2372 DrawerController.kBaseSettleDurationMS = 246; 2373 DrawerController.kMaxSettleDurationMS = 600; 2374 2375 DrawerController.kMinFlingVelocity = 0.4; // Matches Android framework. 2376 DrawerController.kTouchSlop = 5; // Matches Android framework. 2377 DrawerController.kTouchSlopSquare = DrawerController.kTouchSlop * DrawerController.kTouchSlop; 2378 2379 DrawerController.prototype.restrictToCurrent = function (offset) { 2380 return Math.max(this.left, Math.min(this.position, offset)); 2381 }; 2382 2383 DrawerController.prototype.restrictToBounds = function (offset) { 2384 return Math.max(this.left, Math.min(this.right, offset)); 2385 }; 2386 2387 DrawerController.prototype.onTouchStart = function (e) { 2388 this.velocityTracker.onTouchStart(e); 2389 2390 var touchX; 2391 if (this.flip) { 2392 touchX = document.documentElement.clientWidth - e.changedTouches[0].clientX; 2393 } else { 2394 touchX = e.changedTouches[0].clientX; 2395 } 2396 var touchY = e.changedTouches[0].clientY; 2397 2398 if (this.state != DrawerController.kOpened) { 2399 if (touchX != this.restrictToCurrent(touchX)) 2400 return; 2401 this.state = DrawerController.kDragging; 2402 } 2403 2404 this.animator.stopAnimation(); 2405 this.target.addEventListener('touchmove', this.onTouchMove); 2406 this.target.addEventListener('touchend', this.onTouchEnd); 2407 // TODO(abarth): Handle touchcancel. 2408 2409 this.startX = touchX; 2410 this.startY = touchY; 2411 this.startPosition = this.position; 2412 this.touchBaseX = Math.min(touchX, this.startPosition); 2413 }; 2414 2415 DrawerController.prototype.onTouchMove = function (e) { 2416 this.velocityTracker.onTouchMove(e); 2417 2418 if (this.state == DrawerController.kOpened) { 2419 var deltaX; 2420 if (this.flip) { 2421 deltaX = document.documentElement.clientWidth - e.changedTouches[0].clientX - this.startX; 2422 } else { 2423 deltaX = e.changedTouches[0].clientX - this.startX; 2424 } 2425 var deltaY = e.changedTouches[0].clientY - this.startY; 2426 2427 if (deltaX * deltaX + deltaY * deltaY < DrawerController.kTouchSlopSquare) { 2428 e.preventDefault(); 2429 return; 2430 } 2431 2432 if (Math.abs(deltaY) > Math.abs(deltaX)) { 2433 this.target.removeEventListener('touchmove', this.onTouchMove); 2434 this.target.removeEventListener('touchend', this.onTouchEnd); 2435 return; 2436 } 2437 2438 this.state = DrawerController.kDragging; 2439 } 2440 2441 e.preventDefault(); 2442 var touchDeltaX; 2443 if (this.flip) { 2444 touchDeltaX = document.documentElement.clientWidth - e.changedTouches[0].clientX - this.touchBaseX; 2445 } else { 2446 touchDeltaX = e.changedTouches[0].clientX - this.touchBaseX; 2447 } 2448 this.position = this.restrictToBounds(this.startPosition + touchDeltaX); 2449 this.animator.scheduleAnimation(); 2450 }; 2451 2452 DrawerController.prototype.onTouchEnd = function (e) { 2453 this.velocityTracker.onTouchEnd(e); 2454 this.target.removeEventListener('touchmove', this.onTouchMove); 2455 this.target.removeEventListener('touchend', this.onTouchEnd); 2456 2457 var velocityX = this.velocityTracker.velocityX; 2458 2459 if (this.flip) { 2460 velocityX *= -1; 2461 } 2462 2463 if (Math.abs(velocityX) > DrawerController.kMinFlingVelocity) { 2464 this.fling(velocityX); 2465 } else if (this.isOpen()) { 2466 this.open(); 2467 } else { 2468 this.close(); 2469 } 2470 }; 2471 2472 DrawerController.prototype.openFraction = function () { 2473 var width = this.right - this.left; 2474 var offset = this.position - this.left; 2475 return offset / width; 2476 }; 2477 2478 DrawerController.prototype.isOpen = function () { 2479 return this.openFraction() >= 0.5; 2480 }; 2481 2482 DrawerController.prototype.isOpening = function () { 2483 return this.state == DrawerController.kOpening || 2484 (this.state == DrawerController.kFlinging && this.animationVelocityX > 0); 2485 } 2486 2487 DrawerController.prototype.isClosing = function () { 2488 return this.state == DrawerController.kClosing || 2489 (this.state == DrawerController.kFlinging && this.animationVelocityX < 0); 2490 } 2491 2492 DrawerController.prototype.toggle = function () { 2493 if (this.isOpen()) 2494 this.close(); 2495 else 2496 this.open(); 2497 }; 2498 2499 DrawerController.prototype.open = function () { 2500 if (this.full_width) { 2501 this.willOpenCallback.call(this.target); 2502 return; 2503 } 2504 if (!this.position) 2505 this.willOpenCallback.call(this.target); 2506 2507 this.animator.stopAnimation(); 2508 this.animationDuration = 400; 2509 this.state = DrawerController.kOpening; 2510 this.animate(); 2511 }; 2512 2513 DrawerController.prototype.close = function () { 2514 if (this.full_width) { 2515 this.didCloseCallback.call(this.target); 2516 return; 2517 } 2518 this.animator.stopAnimation(); 2519 this.animationDuration = 400; 2520 this.state = DrawerController.kClosing; 2521 this.animate(); 2522 }; 2523 2524 DrawerController.prototype.fling = function (velocityX) { 2525 this.animator.stopAnimation(); 2526 this.animationVelocityX = velocityX; 2527 this.state = DrawerController.kFlinging; 2528 this.animate(); 2529 }; 2530 2531 DrawerController.prototype.animate = function () { 2532 this.positionAnimationBase = this.position; 2533 this.animator.startAnimation(); 2534 }; 2535 2536 DrawerController.prototype.targetPosition = function (deltaT) { 2537 if (this.state == DrawerController.kFlinging) 2538 return this.positionAnimationBase + this.animationVelocityX * deltaT; 2539 var targetFraction = this.curve.scaleTime(deltaT / this.animationDuration); 2540 var animationWidth = this.state == DrawerController.kOpening ? 2541 this.width - this.positionAnimationBase : -this.positionAnimationBase; 2542 return this.positionAnimationBase + targetFraction * animationWidth; 2543 }; 2544 2545 DrawerController.prototype.onAnimation = function (timeStamp) { 2546 if (this.state == DrawerController.kDragging) { 2547 this.animateCallback.call(this.target, this.position); 2548 return false;
2549 } 2550 2551 var deltaT = timeStamp - this.animator.startTimeStamp; 2552 var targetPosition = this.targetPosition(deltaT); 2553 this.position = this.restrictToBounds(targetPosition); 2554 2555 this.animateCallback.call(this.target, this.position); 2556 2557 if (targetPosition <= this.left && this.isClosing()) { 2558 this.state = DrawerController.kClosed; 2559 this.didCloseCallback.call(this.target); 2560 return false; 2561 } 2562 if (targetPosition >= this.right && this.isOpening()) { 2563 this.state = DrawerController.kOpened; 2564 return false; 2565 } 2566 2567 return true; 2568 }; 2569 2570 2571 exports.DrawerController = DrawerController; 2572 2573})(window);
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.