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