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