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/* 152 * wmS3Menu v1.0.0 153 * K.I. 433 154 */ 155;(function ($, window, document, undefined ) { 156 var pluginName = 'wmS3Menu', 157 defaults = { 158 screenButton: false, 159 responsiveTl: false, 160 responsiveTp: false, 161 responsiveMl: false, 162 moreText: '...', 163 childIcons: false, 164 childIconsClass: 'has-child-icon' 165 }; 166 // ÐÑовеÑка на каÑание 167 var isTouchable = ('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch; 168 var $win = $(window); 169 var winWidth = $win.width(); 170 var $doc = $(document); 171 172 var pluginObj = { 173 _events: { 174 hover: function(menuWrap, item, settings){ 175 var link = item.find('> a'); 176 var linkIcon = link.find('.' + settings.childIconsClass); 177 var iconLen = linkIcon.length; 178 var subMenu = item.find('> ul'); 179 var showTimeout; 180 // ÐÑобÑажение 181 function menuShow() { 182 clearTimeout(showTimeout); 183 item.siblings().find('> ul').css('display', ''); 184 // ÐпÑеделение Ð¿Ð¾Ð»Ð¾Ð¶ÐµÐ½Ð¸Ñ Ð²ÑпадаÑки ÑÑÐ¾Ð±Ñ Ð½Ðµ вÑводилоÑÑ Ð·Ð° пÑÐµÐ´ÐµÐ»Ñ Ð¾ÐºÐ½Ð° 185 pluginObj._menuPosition(subMenu); 186 187 link.addClass('hover'); 188 if (iconLen) { 189 linkIcon.addClass('hover'); 190 } 191 } 192 // СкÑÑÑие 193 function menuHide() { 194 showTimeout = setTimeout(function(){ 195 link.removeClass('hover'); 196 subMenu.css('display', ''); 197 if (iconLen) { 198 linkIcon.removeClass('hover'); 199 } 200 }, 500); 201 } 202 // ÐÑклÑÑение и подклÑÑение ÑобÑÑий 203 item.off({ 204 'mouseenter.wmS3Menu': menuShow,
205 'mouseleave.wmS3Menu': menuHide 206 }); 207 item.on({ 208 'mouseenter.wmS3Menu': menuShow, 209 'mouseleave.wmS3Menu': menuHide 210 }); 211 }, 212 click: function(menuWrap, item, settings){ 213 var link = item.find('> a'); 214 var linkIcon = link.find('.' + settings.childIconsClass); 215 var iconLen = linkIcon.length; 216 var subMenu = item.find('> ul'); 217 // ÐеÑеклÑÑение оÑобÑÐ°Ð¶ÐµÐ½Ð¸Ñ 218 function menuToggle() { 219 if (subMenu.is(':visible')) { 220 if (isTouchable) { 221 document.location = link.attr('href'); 222 } 223 link.removeClass('hover'); 224 subMenu.css('display', ''); 225 item.removeClass('submenu-opened'); 226 if (iconLen) { 227 linkIcon.removeClass('hover'); 228 } 229 } else { 230 item.siblings().find('> ul').css('display', ''); 231 item.siblings().find('> a').removeClass('hover'); 232 item.siblings().find('> a .' + settings.childIconsClass).removeClass('hover'); 233 // ÐпÑеделение Ð¿Ð¾Ð»Ð¾Ð¶ÐµÐ½Ð¸Ñ Ð²ÑпадаÑки ÑÑÐ¾Ð±Ñ Ð½Ðµ вÑводилоÑÑ Ð·Ð° пÑÐµÐ´ÐµÐ»Ñ Ð¾ÐºÐ½Ð° 234 pluginObj._menuPosition(subMenu); 235 236 link.addClass('hover'); 237 item.addClass('submenu-opened'); 238 if (iconLen) { 239 linkIcon.addClass('hover'); 240 } 241 } 242 return false; 243 } 244 // ÐÑклÑÑение и подклÑÑение ÑобÑÑий 245 link.off('click.wmS3Menu'); 246 link.on('click.wmS3Menu', menuToggle); 247 }, 248 click_tree: function(menuWrap, item, settings){ 249 var link = item.find('> a'); 250 var linkIcon = link.find('.' + settings.childIconsClass); 251 var subMenu = item.find('> ul'); 252 // ÐеÑеклÑÑение оÑобÑÐ°Ð¶ÐµÐ½Ð¸Ñ 253 function menuToggle(event) { 254 var targ = $(event.target); 255 256 if (targ.closest(linkIcon).length) { 257 if (subMenu.is(':visible')) { 258 link.removeClass('hover'); 259 subMenu.css('display', ''); 260 item.removeClass('submenu-opened'); 261 linkIcon.removeClass('hover'); 262 } else { 263 // ÐпÑеделение Ð¿Ð¾Ð»Ð¾Ð¶ÐµÐ½Ð¸Ñ Ð²ÑпадаÑки ÑÑÐ¾Ð±Ñ Ð½Ðµ вÑводилоÑÑ Ð·Ð° пÑÐµÐ´ÐµÐ»Ñ Ð¾ÐºÐ½Ð° 264 pluginObj._menuPosition(subMenu); 265 266 link.addClass('hover'); 267 item.addClass('submenu-opened'); 268 linkIcon.addClass('hover'); 269 } 270 return false; 271 } 272 } 273 // ÐÑклÑÑение и подклÑÑение ÑобÑÑий 274 link.off('click.wmS3Menu'); 275 link.on('click.wmS3Menu', menuToggle); 276 } 277 }, 278 _menuPosition: function(subMenu) { 279 // ÐпÑеделение Ð¿Ð¾Ð»Ð¾Ð¶ÐµÐ½Ð¸Ñ Ð²ÑпадаÑки ÑÑÐ¾Ð±Ñ Ð½Ðµ вÑводилоÑÑ Ð·Ð° пÑÐµÐ´ÐµÐ»Ñ Ð¾ÐºÐ½Ð° 280 winWidth = $win.width(); 281 282 subMenu.css('display', 'block'); 283 284 if (subMenu.parent().hasClass('first-level') === false) { 285 subMenu.css({ 286 'visibility': 'hidden', 287 'opacity': 0 288 }); 289 290 var menuRect = subMenu[0].getBoundingClientRect(); 291 var marginR = parseInt(subMenu.css('margin-right')); 292 var parentWidth = subMenu.parent().width(); 293 294 if (marginR > parentWidth) { 295 subMenu.css('margin-right', parentWidth); 296 } 297 298 if (menuRect.right >= winWidth) { 299 subMenu.css({ 300 'left': '-100%', 301 'margin-left': 0 302 }); 303 } 304 subMenu.css({ 305 'visibility': '', 306 'opacity': '' 307 }); 308 } 309 } 310 }; 311 function Plugin(element, options) { 312 this.element = element; 313 314 this.options = $.extend({}, defaults, options, $(this.element).data()) ; 315 316 this._defaults = defaults; 317 this._name = pluginName; 318 319 this.init(); 320 } 321 Plugin.prototype = { 322 init: function () { 323 var settings = this.options; 324 // ÐпÑеделение ÑиÑÐ¸Ð½Ñ Ð¼ÐµÐ´Ð¸Ð° 325 var moreButFlag = false; 326 if (window.matchMedia('all and (max-width: 480px)').matches) { 327 moreButFlag = settings.responsiveMl; 328 } else if (window.matchMedia('all and (max-width: 640px)').matches) { 329 //moreButFlag = settings.responsiveTp; 330 } else if (window.matchMedia('all and (max-width: 768px)').matches) { 331 moreButFlag = settings.responsiveTl; 332 } else { 333 moreButFlag = settings.screenButton; 334 } 335 // ÐбеÑÑка Ð¼ÐµÐ½Ñ 336 var menuWrap = $(this.element); 337 var menuClass = menuWrap.attr('class'); 338 var menuMainUl = $(this.element.querySelector('ul')); 339 var widgetClass = menuClass.match(/widget-\d+/)[0]; 340 // ÐÑовеÑка на налиÑие Ð¼ÐµÐ½Ñ Ð² Side panel 341 if (window.side_panel_controller && side_panel_controller.inPanel(widgetClass)) { 342 moreButFlag = false;
343 } 344 345 menuMainUl.children().addClass('first-level'); 346 // ÐаÑÑÑойки Ð´Ð»Ñ Ð³Ð¾ÑизонÑалÑного Ð¼ÐµÐ½Ñ 347 if (!!menuClass.match(/horizontal/i)) { 348 var menuWidth = menuMainUl.width(); 349 var itemsWidth = 0, hideArr = [], hideLength; 350 // Ðнопка More 351 var moreBut = menuMainUl.find('.more-button'); 352 if (!moreBut.length) { 353 moreBut = $('<li class="more-button"><a href="#"><span>' + settings.moreText + '</span></a></li>');// data-trigger="click" 354 menuMainUl.append(moreBut); 355 } 356 // ÐÐµÐ½Ñ More 357 var moreMenu = moreBut.find('> ul'); 358 if (!moreMenu.length) { 359 moreMenu = $('<ul></ul>'); 360 moreBut.append(moreMenu); 361 } 362 363 moreBut.removeClass('removed').attr('data-trigger', 'hover'); 364 menuMainUl.children().css('display', ''); 365 366 var firstLevelItems = menuMainUl.children(':visible').not('.more-button'); 367 moreMenu.html(''); 368 369 if (moreButFlag === 'more' || moreButFlag === 'button') { 370 moreBut.removeClass('disabled'); 371 372 menuWidth -= moreBut.outerWidth(); 373 374 firstLevelItems.each(function(){ 375 var thisItem = $(this); 376 itemsWidth += thisItem.outerWidth(true); 377 if (itemsWidth >= menuWidth) { 378 hideArr.push(thisItem.clone()); 379 thisItem.hide(); 380 } 381 }); 382 383 hideLength = hideArr.length; 384 if (hideLength) { 385 for (var ind = 0; ind < hideLength; ind++) { 386 moreMenu.append(hideArr[ind]); 387 } 388 moreBut.removeClass('disabled'); 389 } else { 390 moreBut.addClass('disabled'); 391 } 392 } else { 393 moreBut.addClass('disabled'); 394 } 395 } 396 // ÐложеннÑе подÑÑовни Ð¼ÐµÐ½Ñ 397 var menuInner = menuMainUl.find('ul'); 398 var menuItems = menuInner.parent(); 399 var menuLinks = menuItems.find('> a'); 400 // СÑÑелоÑки Ð´Ð»Ñ Ð¿Ð¾Ð´ÑÑовней 401 var menuLinksIcons = menuLinks.find('.' + settings.childIconsClass); 402 var childIconLen = menuLinksIcons.length; 403 // Тип оÑобÑÐ°Ð¶ÐµÐ½Ð¸Ñ Ð¼ÐµÐ½Ñ 404 var mShow = 'popup'; 405 if (!!menuClass.match(/dropdown/i)) { 406 mShow = 'dropdown'; 407 } else if (!!menuClass.match(/treemenu/i)) { 408 mShow = 'treemenu'; 409 } 410 if (mShow === 'popup') { 411 menuInner.hide(); 412 } 413 if (childIconLen) { 414 menuLinksIcons.remove(); 415 } 416 if (!!settings.childIcons) { 417 // Ðобавление ÑÑÑелоÑек Ð´Ð»Ñ Ð¿Ð¾Ð´ÑÑовней 418 var childIconHTML = '<em class="' + settings.childIconsClass + '"></em>'; 419 420 if (mShow === 'treemenu') { 421 childIconHTML = '<em class="' + settings.childIconsClass + '"><b style="position: absolute; top: 50%; left: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px;"></b></em>'; 422 } 423 424 var childIconTag = $(childIconHTML); 425 menuLinks.append(childIconTag.clone()); 426 427 menuLinksIcons = menuLinks.find('.' + settings.childIconsClass); 428 childIconLen = menuLinksIcons.length; 429 } 430 // Удаление вÑÐµÑ ÑобÑÑий на ÑÑÑÐ»ÐºÐ°Ñ 431 menuLinks.removeClass('hover').off('click.wmS3Menu'); 432 menuInner.css('display', ''); 433 if (childIconLen) { 434 menuLinksIcons.removeClass('hover'); 435 } 436 437 menuItems.each(function() { 438 var thisItem = $(this); 439 var trigger = thisItem.data('trigger') || 'hover'; 440 441 if (mShow === 'dropdown' || isTouchable) { 442 trigger = 'click'; 443 } else if (mShow === 'treemenu') { 444 trigger = 'click_tree'; 445 } 446 pluginObj._events[trigger](menuWrap, thisItem, settings); 447 }); 448 // Ðлик по докÑменÑÑ 449 if (isTouchable) { 450 function docClick(e) { 451 var target = $(e.target); 452 if (target.closest(menuWrap).length === 0) { 453 menuLinks.removeClass('hover'); 454 menuInner.css('display', ''); 455 menuItems.removeClass('submenu-opened'); 456 457 if (childIconLen) { 458 menuLinksIcons.removeClass('hover'); 459 } 460 } 461 } 462 $doc.off('touchstart.wmS3Menu', docClick); 463 $doc.on('touchstart.wmS3Menu', docClick); 464 } 465 }, 466 update: function () { 467 this.init(); 468 } 469 }; 470 if (!$.fn[pluginName]) { 471 $.fn[pluginName] = function (options) { 472 var args = arguments; 473 if (options === undefined || typeof options === 'object') { 474 return this.each(function () { 475 if (!$.data(this, 'plugin_' + pluginName)) { 476 $.data(this, 'plugin_' + pluginName, new Plugin(this, options)); 477 } 478 }); 479 } else if (typeof options === 'string' && options[0] !== '_' && options !== 'init') { 480 var returns; 481 this.each(function () { 482 var instance = $.data(this, 'plugin_' + pluginName); 483 if (instance instanceof Plugin && typeof instance[options] === 'function') { 484 returns = instance[options].apply(instance, Array.prototype.slice.call(args, 1)); 485 } 486 if (options === 'destroy') { 487 $.data(this, 'plugin_' + pluginName, null); 488 } 489 }); 490 return returns !== undefined ? returns : this; 491 } 492 }; 493 } 494 $(function () { 495 var wmMenuWrap = $('.wm-widget-menu.horizontal'); 496 wmMenuWrap[pluginName](); 497
498 $win.on('resize.wmS3Menu', function(){ 499 wmMenuWrap[pluginName]('update'); 500 }); 501 }); 502 503 setTimeout(function(){ 504 $win.trigger('resize'); 505 }, 500); 506}(jQuery, window, document)); 507$(function() { 508 $('.up_button').click(function () { 509 var up_speed = $(this).data('speed') 510 $('body, html').animate({ 511 scrollTop: 0 512 }, up_speed); 513 }); 514}); 515$(function () { 516 $(document).click(function (event) { 517 $('.contacts-block').each(function() { 518 if ($(event.target).closest($(this)).length) { 519 return; 520 } else { 521 $(this).find('.tgl-but').prop("checked", false); 522 $(this).find('.icon').removeClass('active'); 523 } 524 }); 525 }); 526 527 function setMargin($block) { 528 if (Math.max(document.documentElement.clientWidth, window.innerWidth || 0) > 960) { 529 $block.find(".block-body-drop").css({ 530 "margin-left": "0px" 531 }); 532 } else { 533 var left = $block.offset().left * -1; 534 $block.find(".block-body-drop").css({ 535 "margin-left": left + "px" 536 }); 537 } 538 } 539 540 $('.contacts-block').each(function() { 541 var $block = $(this), 542 allClasses = $block.attr("class").split(" "), 543 mainClass = allClasses[0], 544 mainSelector = ".side-panel ."+mainClass+" .block-body-drop", 545 styles = document.styleSheets; 546 547 for(var i = 0; i < styles.length; i++) { 548 if (styles[i].href && styles[i].href.indexOf("styles.css") !== -1) { 549 for(var j = 0; j < styles[i].cssRules.length; j++) { 550 if (styles[i].cssRules[j].selectorText == mainSelector && styles[i].cssRules[j].style.width == "100vw") { 551 $block.data("fullwidth", 1); 552 setMargin($block); 553 break; 554 } 555 } 556 break; 557 } 558 } 559 }); 560 561 $(window).resize(function() { 562 $('.contacts-block').each(function() { 563 var $block = $(this); 564 if ($block.data("fullwidth") == 1) { 565 setMargin($block); 566 } 567 }); 568 }); 569 570 $('.contacts-block').each(function() { 571 var $block = $(this); 572 $block.find('.icon').click(function() { 573 if ($block.data("fullwidth") == 1) { 574 setMargin($block); 575 } 576 if ($block.find('.tgl-but').prop("checked")) { 577 $(this).removeClass('active'); 578 } else { 579 $(this).addClass('active'); 580 } 581 }); 582 }); 583}); 584$(function() { 585 if (window.ymaps) { 586 ymaps.ready(function () { 587 $('.widget-type-map[data-center]').each(function () { 588 var self = $(this); 589 var id = self.attr('id'); 590 var data = false; 591 if (self.find('[type=hidden]').val()) { 592 data = typeof JSON.parse == 'function' ? JSON.parse(self.find('[type=hidden]').val()) : eval(self.find('[type=hidden]').val()); 593 } 594 var params = { 595 type: self.data('type') || 'yandex#map', 596 center: self.data('center').split(',').map(function (e) { 597 return $.trim(e) 598 }), 599 zoom: self.data('zoom') || 9, 600 controls: self.data('controls') ? self.data('controls').split(',').map(function (e) { 601 return $.trim(e) 602 }) : [] 603 }; 604 var myMap = new ymaps.Map(id, params); 605 myMap.behaviors.disable('scrollZoom'); 606 if (data) { 607 for (var i in data) { 608 var myPlacemark = new ymaps.Placemark(data[i].point.split(',').map(function (e) { 609 return $.trim(e); 610 }), { 611 iconContent: $('<div>').html(data[i].iconContent).text(), 612 balloonContent: $('<div>').html(data[i].balloonContent).html() 613 }, { 614 preset: data[i].preset 615 }); 616 myMap.geoObjects.add(myPlacemark); 617 } 618 } 619 }); 620 }); 621 } 622}); 623$(function () { 624 $(document).click(function (event) { 625 $('.contacts-block').each(function() { 626 if ($(event.target).closest($(this)).length) { 627 return; 628 } else { 629 $(this).find('.tgl-but').prop("checked", false); 630 $(this).find('.icon').removeClass('active'); 631 } 632 }); 633 }); 634 635 function setMargin($block) { 636 if (Math.max(document.documentElement.clientWidth, window.innerWidth || 0) > 960) { 637 $block.find(".block-body-drop").css({ 638 "margin-left": "0px" 639 }); 640 } else { 641 var left = $block.offset().left * -1; 642 $block.find(".block-body-drop").css({ 643 "margin-left": left + "px" 644 }); 645 } 646 } 647 648 $('.contacts-block').each(function() { 649 var $block = $(this), 650 allClasses = $block.attr("class").split(" "), 651 mainClass = allClasses[0], 652 mainSelector = ".side-panel ."+mainClass+" .block-body-drop", 653 styles = document.styleSheets; 654 655 for(var i = 0; i < styles.length; i++) { 656 if (styles[i].href && styles[i].href.indexOf("styles.css") !== -1) { 657 for(var j = 0; j < styles[i].cssRules.length; j++) { 658 if (styles[i].cssRules[j].selectorText == mainSelector && styles[i].cssRules[j].style.width == "100vw") { 659 $block.data("fullwidth", 1); 660 setMargin($block); 661 break; 662 } 663 } 664 break; 665 } 666 } 667 }); 668 669 $(window).resize(function() { 670 $('.contacts-block').each(function() { 671 var $block = $(this); 672 if ($block.data("fullwidth") == 1) { 673 setMargin($block); 674 } 675 }); 676 }); 677 678 $('.contacts-block').each(function() { 679 var $block = $(this); 680 $block.find('.icon').click(function() { 681 if ($block.data("fullwidth") == 1) { 682 setMargin($block); 683 } 684 if ($block.find('.tgl-but').prop("checked")) { 685 $(this).removeClass('active'); 686 } else { 687 $(this).addClass('active'); 688 } 689 }); 690 }); 691}); 692document.addEventListener('DOMContentLoaded', function() { 693 var bodyScrollBarWidth = (function () { 694 var widthHidden, widthScroll, currentValue, currentPriority; 695 currentValue = document.body.style.getPropertyValue('overflow'); 696 currentPriority = document.body.style.getPropertyPriority('overflow'); 697 document.body.style.setProperty('overflow', 'hidden', 'important'); 698 widthHidden = document.body.clientWidth; 699 document.body.style.setProperty('overflow', 'scroll', 'important'); 700 widthScroll = document.body.clientWidth; 701 document.body.style.setProperty('overflow', currentValue ? currentValue : '', currentPriority); 702 return widthHidden - widthScroll; 703 }()); 704 var media = { 705 'tablet-landscape': 960, 706 'tablet-portrait': 768, 707 'mobile-landscape': 640, 708 'mobile-portrait': 480 709 }; 710 var side_panel = document.querySelector('.side-panel'); 711 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; 712 var layers, content_width, flip, full_width, elements = {}, comments = {}; 713 714 if (!side_panel || side_panel.classList.contains('removed')) { 715 return; 716 } 717 718 flip = side_panel.getAttribute('data-position') === 'right'; 719 720 try { 721 layers = side_panel.getAttribute('data-layers'); 722 if (layers !== "") { 723 layers = JSON.parse(layers.replace(/\[/g, '{').replace(/\]/g, '}').replace(/\'/g, '"')); 724 } 725 } catch(e) { 726 console.error(e); 727 } 728 729 if (typeof layers !== 'object' || Object.keys(layers).length === 0) { 730 return; 731 } 732
733 Object.keys(layers).forEach(function(clss) { 734 elements[clss] = document.querySelector('.' + clss); 735 comments[clss] = document.createComment(clss); 736 if (elements[clss]) { 737 elements[clss].parentNode.insertBefore(comments[clss], elements[clss]); 738 } else { 739 delete layers[clss]; 740 } 741 }); 742 743 side_panel_button = side_panel.querySelector('.side-panel-button'); 744 side_panel_close = side_panel.querySelector('.side-panel-close'); 745 side_panel_content = side_panel.querySelector('.side-panel-content'); 746 side_panel_content_inner = side_panel.querySelector('.side-panel-content-inner') || side_panel_content; 747 side_panel_mask = side_panel.querySelector('.side-panel-mask'); 748 side_panel_top = side_panel.querySelector('.side-panel-top-inner'); 749 750 side_panel.classList.remove('hidden'); 751 side_panel_button.classList.remove('hidden'); 752 side_panel_button.style.display = 'none'; 753 side_panel_content.classList.remove('hidden'); 754 side_panel_content.style.display = 'none'; 755 side_panel_mask.classList.remove('hidden'); 756 side_panel_mask.style.display = 'none'; 757 758 content_width = getComputedStyle(side_panel_content, null).width; 759 760 leftEdge = 0; 761 rightEdge = parseInt(content_width) + 50; 762 763 if (content_width === 'auto') { 764 rightEdge = Math.max(document.documentElement.clientWidth, window.innerWidth || 0); 765 full_width = true; 766 } 767 768 isPhantom = !!parseInt($(side_panel).attr("data-phantom")); 769 770 if (isPhantom) { 771 $(side_panel).css({"pointer-events": "none"}); 772 } else { 773 $(side_panel).css({"pointer-events": "auto"}); 774 } 775 776 if (flip) { 777 side_panel_content.style.left = 'auto'; 778 side_panel_content.style.right = '0'; 779 } 780 781 if (full_width) { 782 side_panel_content.style.left = '0'; 783 side_panel_content.style.right = '0'; 784 } 785 786 window.side_panel_controller = side_panel_controller = new DrawerController({ 787 target: side_panel, 788 full_width: full_width, 789 left: leftEdge, 790 right: rightEdge, 791 position: 0, 792 flip: flip, 793 curve: 'ease-in-out', 794 willOpen: function() { 795 side_panel_mask.style.display = 'block'; 796 side_panel_content.style.display = 'block'; 797 document.body.classList.add('noscroll'); 798 if (bodyScrollBarWidth && document.documentElement.scrollHeight > document.documentElement.clientHeight) { 799 document.body.style.borderRight = bodyScrollBarWidth + 'px solid transparent' 800 } 801 }, 802 didClose: function() { 803 side_panel_mask.style.display = 'none'; 804 side_panel_content.style.display = 'none'; 805 document.body.classList.remove('noscroll'); 806 if (bodyScrollBarWidth && document.documentElement.scrollHeight > document.documentElement.clientHeight) { 807 document.body.style.borderRight = '' 808 } 809 }, 810 onAnimate: function(position) { 811 side_panel_mask.style.opacity = position / rightEdge; 812 side_panel_content.style.transform = 'translate3d(' + (flip ? rightEdge - position : position - rightEdge) + 'px,0,0)'; 813 } 814 }); 815 816 side_panel_controller.inPanel = function(clss) { 817 var viewportWidth; 818 var current_media; 819 820 if (typeof clss !== 'string') { 821 return false; 822 } 823 824 if (clss.charAt(0) === '.') { 825 clss = clss.slice(1); 826 } 827 828 viewportWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0); 829 830 Object.keys(media).forEach(function(key) { 831 if (viewportWidth <= media[key]) { 832 current_media = key; 833 } 834 }); 835 836 if (typeof current_media === 'undefined') { 837 current_media = 'screen'; 838 } 839 840 return layers[clss] && layers[clss][current_media]; 841 }; 842 843 side_panel_button.addEventListener('click', function(e) { 844 e.preventDefault();
845 side_panel_controller.toggle(); 846 return false; 847 }); 848 849 if (side_panel_close) { 850 side_panel_close.addEventListener('click', function(e) { 851 e.preventDefault(); 852 side_panel_controller.close(); 853 return false; 854 }); 855 } 856 857 side_panel_mask.addEventListener('click', function() { 858 side_panel_controller.close(); 859 return false; 860 }); 861 862 document.addEventListener('keyup', function(e) { 863 if (e.keyCode === 27) { 864 side_panel_controller.close(); 865 return false; 866 } 867 }); 868 869 var debounce = (function () { 870 return function (fn, time) { 871 var timer, func; 872 if (window.requestAnimationFrame) { 873 func = function() { 874 timer && cancelAnimationFrame(timer); 875 timer = requestAnimationFrame(fn); 876 } 877 } else { 878 func = function() { 879 window.clearTimeout(timer); 880 timer = window.setTimeout(function () { 881 fn(); 882 }, time) 883 }; 884 } 885 return func; 886 } 887 }()); 888 889 function checkSidePanel() { 890 var viewportWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0); 891 var current_media; 892 var emptySide = true; 893 var emptyTop = true; 894 895 if (checkSidePanel.viewportWidth === viewportWidth) { 896 return; 897 } 898 899 checkSidePanel.viewportWidth = viewportWidth; 900 901 Object.keys(media).forEach(function(key) { 902 if (viewportWidth <= media[key]) { 903 current_media = key; 904 } 905 }); 906 907 if (typeof current_media === 'undefined') { 908 current_media = 'screen'; 909 } 910 911 Object.keys(layers).forEach(function(clss){ 912 var element, comment; 913 914 element = elements[clss]; 915 comment = comments[clss]; 916 917 if (current_media in layers[clss]) { 918 if (layers[clss][current_media] === 'onTop') { 919 side_panel_top.appendChild(element); 920 emptyTop = false; 921 } else { 922 side_panel_content_inner.appendChild(element); 923 emptySide = false;
924 } 925 } else { 926 if (comment) { 927 comment.parentNode.insertBefore(element, comment); 928 } 929 } 930 }); 931 932 if (emptySide) { 933 side_panel_button.style.display = 'none'; 934 } else { 935 side_panel_button.style.display = 'block'; 936 } 937 938 if (!emptyTop || !emptySide) { 939 side_panel.style.display = 'block'; 940 } else { 941 side_panel.style.display = 'none'; 942 side_panel_controller.close(); 943 } 944 } 945 946 checkSidePanel = debounce(checkSidePanel, 40); 947 948 checkSidePanel(); 949 window.addEventListener('resize', checkSidePanel); 950}); 951/* 952 * @license 953 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. 954 * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 955 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 956 * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 957 * Code distributed by Google as part of the polymer project is also 958 * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 959 */ 960 961"use strict"; 962 963(function (exports) { 964 965 function sign(number) { 966 if (number < 0) 967 return -1; 968 if (number > 0) 969 return 1; 970 return 0; 971 } 972 973 function Animator(delegate) { 974 this.delegate = delegate; 975 this.startTimeStamp = 0; 976 this.request_ = null; 977 }; 978 979 Animator.prototype.scheduleAnimation = function () { 980 if (this.request_) 981 return; 982 this.request_ = requestAnimationFrame(this.onAnimation_.bind(this)); 983 }; 984 985 Animator.prototype.startAnimation = function () { 986 this.startTimeStamp = 0; 987 this.scheduleAnimation(); 988 }; 989 990 Animator.prototype.stopAnimation = function () { 991 cancelAnimationFrame(this.request_); 992 this.startTimeStamp = 0; 993 this.request_ = null; 994 }; 995 996 Animator.prototype.onAnimation_ = function (timeStamp) { 997 this.request_ = null; 998 if (!this.startTimeStamp) 999 this.startTimeStamp = timeStamp; 1000 if (this.delegate.onAnimation(timeStamp)) 1001 this.scheduleAnimation(); 1002 }; 1003 1004 function VelocityTracker() { 1005 this.recentTouchMoves_ = []; 1006 this.velocityX = 0; 1007 this.velocityY = 0; 1008 } 1009 1010 VelocityTracker.kTimeWindow = 50; 1011 1012 VelocityTracker.prototype.pruneHistory_ = function (timeStamp) { 1013 for (var i = 0; i < this.recentTouchMoves_.length; ++i) { 1014 if (this.recentTouchMoves_[i].timeStamp > timeStamp - VelocityTracker.kTimeWindow) { 1015 this.recentTouchMoves_ = this.recentTouchMoves_.slice(i); 1016 return; 1017 } 1018 } 1019 // All touchmoves are old. 1020 this.recentTouchMoves_ = []; 1021 }; 1022 1023 VelocityTracker.prototype.update_ = function (e) { 1024 this.pruneHistory_(e.timeStamp); 1025 this.recentTouchMoves_.push(e); 1026 1027 var oldestTouchMove = this.recentTouchMoves_[0]; 1028 1029 var deltaX = e.changedTouches[0].clientX - oldestTouchMove.changedTouches[0].clientX; 1030 var deltaY = e.changedTouches[0].clientY - oldestTouchMove.changedTouches[0].clientY; 1031 var deltaT = e.timeStamp - oldestTouchMove.timeStamp; 1032 1033 if (deltaT > 0) { 1034 this.velocityX = deltaX / deltaT; 1035 this.velocityY = deltaY / deltaT; 1036 } else { 1037 this.velocityX = 0; 1038 this.velocityY = 0; 1039 } 1040 }; 1041 1042 VelocityTracker.prototype.onTouchStart = function (e) { 1043 this.recentTouchMoves_.push(e); 1044 this.velocityX = 0; 1045 this.velocityY = 0; 1046 }; 1047 1048 VelocityTracker.prototype.onTouchMove = function (e) { 1049 this.update_(e); 1050 }; 1051 1052 VelocityTracker.prototype.onTouchEnd = function (e) { 1053 this.update_(e); 1054 this.recentTouchMoves_ = []; 1055 }; 1056 1057 function LinearTimingFunction() { 1058 }; 1059 1060 LinearTimingFunction.prototype.scaleTime = function (fraction) { 1061 return fraction; 1062 }; 1063 1064 function CubicBezierTimingFunction(spec) { 1065 this.map = []; 1066 for (var ii = 0; ii <= 100; ii += 1) { 1067 var i = ii / 100; 1068 this.map.push([ 1069 3 * i * (1 - i) * (1 - i) * spec[0] + 1070 3 * i * i * (1 - i) * spec[2] + i * i * i, 1071 3 * i * (1 - i) * (1 - i) * spec[1] + 1072 3 * i * i * (1 - i) * spec[3] + i * i * i 1073 ]); 1074 } 1075 }; 1076 1077 CubicBezierTimingFunction.prototype.scaleTime = function (fraction) { 1078 var fst = 0; 1079 while (fst !== 100 && fraction > this.map[fst][0]) { 1080 fst += 1; 1081 } 1082 if (fraction === this.map[fst][0] || fst === 0) { 1083 return this.map[fst][1]; 1084 } 1085 var yDiff = this.map[fst][1] - this.map[fst - 1][1]; 1086 var xDiff = this.map[fst][0] - this.map[fst - 1][0]; 1087 var p = (fraction - this.map[fst - 1][0]) / xDiff; 1088 return this.map[fst - 1][1] + p * yDiff; 1089 }; 1090 1091 var presetTimingFunctions = { 1092 'linear': new LinearTimingFunction(), 1093 'ease': new CubicBezierTimingFunction([0.25, 0.1, 0.25, 1.0]), 1094 'ease-in': new CubicBezierTimingFunction([0.42, 0, 1.0, 1.0]), 1095 'ease-out': new CubicBezierTimingFunction([0, 0, 0.58, 1.0]), 1096 'ease-in-out': new CubicBezierTimingFunction([0.42, 0, 0.58, 1.0]), 1097 }; 1098 1099 function DrawerController(options) { 1100 this.velocityTracker = new VelocityTracker(); 1101 this.animator = new Animator(this); 1102 1103 this.target = options.target; 1104 this.left = options.left; 1105 this.right = options.right; 1106 this.position = options.position; 1107 this.flip = options.flip; 1108 this.full_width = options.full_width; 1109 1110 this.width = this.right - this.left; 1111 this.curve = presetTimingFunctions[options.curve || 'linear']; 1112 1113 this.willOpenCallback = options.willOpen; 1114 this.didCloseCallback = options.didClose; 1115 this.animateCallback = options.onAnimate; 1116 1117 this.state = DrawerController.kClosed; 1118 1119 this.defaultAnimationSpeed = (this.right - this.left) / DrawerController.kBaseSettleDurationMS; 1120 1121 this.onTouchMove = this.onTouchMove.bind(this); 1122 this.onTouchEnd = this.onTouchEnd.bind(this); 1123 1124 if (!this.full_width) { 1125 this.target.addEventListener('touchstart', this.onTouchStart.bind(this)); 1126 } 1127 } 1128 1129 DrawerController.kOpened = 'opened'; 1130 DrawerController.kClosed = 'closed'; 1131 DrawerController.kOpening = 'opening'; 1132 DrawerController.kClosing = 'closing'; 1133 DrawerController.kDragging = 'dragging'; 1134 DrawerController.kFlinging = 'flinging'; 1135 1136 DrawerController.kBaseSettleDurationMS = 246; 1137 DrawerController.kMaxSettleDurationMS = 600; 1138 1139 DrawerController.kMinFlingVelocity = 0.4; // Matches Android framework. 1140 DrawerController.kTouchSlop = 5; // Matches Android framework. 1141 DrawerController.kTouchSlopSquare = DrawerController.kTouchSlop * DrawerController.kTouchSlop; 1142 1143 DrawerController.prototype.restrictToCurrent = function (offset) { 1144 return Math.max(this.left, Math.min(this.position, offset)); 1145 }; 1146 1147 DrawerController.prototype.restrictToBounds = function (offset) { 1148 return Math.max(this.left, Math.min(this.right, offset)); 1149 }; 1150 1151 DrawerController.prototype.onTouchStart = function (e) { 1152 this.velocityTracker.onTouchStart(e); 1153 1154 var touchX; 1155 if (this.flip) { 1156 touchX = document.documentElement.clientWidth - e.changedTouches[0].clientX; 1157 } else { 1158 touchX = e.changedTouches[0].clientX; 1159 } 1160 var touchY = e.changedTouches[0].clientY; 1161 1162 if (this.state != DrawerController.kOpened) { 1163 if (touchX != this.restrictToCurrent(touchX)) 1164 return; 1165 this.state = DrawerController.kDragging; 1166 } 1167 1168 this.animator.stopAnimation(); 1169 this.target.addEventListener('touchmove', this.onTouchMove); 1170 this.target.addEventListener('touchend', this.onTouchEnd); 1171 // TODO(abarth): Handle touchcancel. 1172 1173 this.startX = touchX; 1174 this.startY = touchY; 1175 this.startPosition = this.position; 1176 this.touchBaseX = Math.min(touchX, this.startPosition); 1177 }; 1178 1179 DrawerController.prototype.onTouchMove = function (e) { 1180 this.velocityTracker.onTouchMove(e); 1181 1182 if (this.state == DrawerController.kOpened) { 1183 var deltaX; 1184 if (this.flip) { 1185 deltaX = document.documentElement.clientWidth - e.changedTouches[0].clientX - this.startX; 1186 } else { 1187 deltaX = e.changedTouches[0].clientX - this.startX; 1188 } 1189 var deltaY = e.changedTouches[0].clientY - this.startY; 1190 1191 if (deltaX * deltaX + deltaY * deltaY < DrawerController.kTouchSlopSquare) { 1192 e.preventDefault(); 1193 return; 1194 } 1195 1196 if (Math.abs(deltaY) > Math.abs(deltaX)) { 1197 this.target.removeEventListener('touchmove', this.onTouchMove); 1198 this.target.removeEventListener('touchend', this.onTouchEnd); 1199 return; 1200 } 1201 1202 this.state = DrawerController.kDragging; 1203 } 1204 1205 e.preventDefault(); 1206 var touchDeltaX; 1207 if (this.flip) { 1208 touchDeltaX = document.documentElement.clientWidth - e.changedTouches[0].clientX - this.touchBaseX; 1209 } else { 1210 touchDeltaX = e.changedTouches[0].clientX - this.touchBaseX; 1211 } 1212 this.position = this.restrictToBounds(this.startPosition + touchDeltaX); 1213 this.animator.scheduleAnimation(); 1214 }; 1215 1216 DrawerController.prototype.onTouchEnd = function (e) { 1217 this.velocityTracker.onTouchEnd(e); 1218 this.target.removeEventListener('touchmove', this.onTouchMove); 1219 this.target.removeEventListener('touchend', this.onTouchEnd); 1220 1221 var velocityX = this.velocityTracker.velocityX; 1222 1223 if (this.flip) { 1224 velocityX *= -1; 1225 } 1226 1227 if (Math.abs(velocityX) > DrawerController.kMinFlingVelocity) { 1228 this.fling(velocityX); 1229 } else if (this.isOpen()) { 1230 this.open(); 1231 } else { 1232 this.close(); 1233 } 1234 }; 1235 1236 DrawerController.prototype.openFraction = function () { 1237 var width = this.right - this.left; 1238 var offset = this.position - this.left; 1239 return offset / width; 1240 }; 1241 1242 DrawerController.prototype.isOpen = function () { 1243 return this.openFraction() >= 0.5; 1244 }; 1245 1246 DrawerController.prototype.isOpening = function () { 1247 return this.state == DrawerController.kOpening || 1248 (this.state == DrawerController.kFlinging && this.animationVelocityX > 0); 1249 } 1250 1251 DrawerController.prototype.isClosing = function () { 1252 return this.state == DrawerController.kClosing || 1253 (this.state == DrawerController.kFlinging && this.animationVelocityX < 0); 1254 } 1255 1256 DrawerController.prototype.toggle = function () { 1257 if (this.isOpen()) 1258 this.close(); 1259 else 1260 this.open(); 1261 }; 1262 1263 DrawerController.prototype.open = function () { 1264 if (this.full_width) { 1265 this.willOpenCallback.call(this.target); 1266 return; 1267 } 1268 if (!this.position) 1269 this.willOpenCallback.call(this.target); 1270 1271 this.animator.stopAnimation(); 1272 this.animationDuration = 400; 1273 this.state = DrawerController.kOpening; 1274 this.animate(); 1275 }; 1276 1277 DrawerController.prototype.close = function () { 1278 if (this.full_width) { 1279 this.didCloseCallback.call(this.target); 1280 return; 1281 } 1282 this.animator.stopAnimation(); 1283 this.animationDuration = 400; 1284 this.state = DrawerController.kClosing; 1285 this.animate(); 1286 }; 1287 1288 DrawerController.prototype.fling = function (velocityX) { 1289 this.animator.stopAnimation(); 1290 this.animationVelocityX = velocityX; 1291 this.state = DrawerController.kFlinging; 1292 this.animate(); 1293 }; 1294 1295 DrawerController.prototype.animate = function () { 1296 this.positionAnimationBase = this.position; 1297 this.animator.startAnimation(); 1298 }; 1299 1300 DrawerController.prototype.targetPosition = function (deltaT) { 1301 if (this.state == DrawerController.kFlinging) 1302 return this.positionAnimationBase + this.animationVelocityX * deltaT; 1303 var targetFraction = this.curve.scaleTime(deltaT / this.animationDuration); 1304 var animationWidth = this.state == DrawerController.kOpening ? 1305 this.width - this.positionAnimationBase : -this.positionAnimationBase; 1306 return this.positionAnimationBase + targetFraction * animationWidth; 1307 }; 1308 1309 DrawerController.prototype.onAnimation = function (timeStamp) { 1310 if (this.state == DrawerController.kDragging) { 1311 this.animateCallback.call(this.target, this.position); 1312 return false;
1313 } 1314 1315 var deltaT = timeStamp - this.animator.startTimeStamp; 1316 var targetPosition = this.targetPosition(deltaT); 1317 this.position = this.restrictToBounds(targetPosition); 1318 1319 this.animateCallback.call(this.target, this.position); 1320 1321 if (targetPosition <= this.left && this.isClosing()) { 1322 this.state = DrawerController.kClosed; 1323 this.didCloseCallback.call(this.target); 1324 return false; 1325 } 1326 if (targetPosition >= this.right && this.isOpening()) { 1327 this.state = DrawerController.kOpened; 1328 return false; 1329 } 1330 1331 return true; 1332 }; 1333 1334 1335 exports.DrawerController = DrawerController; 1336 1337})(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.