var md = new MobileDetect(window.navigator.userAgent); (function getPerspective(){ var element = document.createElement('p'), html = document.getElementsByTagName('html')[0], body = document.getElementsByTagName('body')[0], propertys = { 'webkitTransformStyle':'-webkit-transform-style', 'MozTransformStyle':'-moz-transform-style', 'msTransformStyle':'-ms-transform-style', 'transformStyle':'transform-style' }; body.insertBefore(element, null); for (var i in propertys) { if (element.style[i] !== undefined) { element.style[i] = "preserve-3d"; } } var st = window.getComputedStyle(element, null), transform = st.getPropertyValue("-webkit-transform-style") || st.getPropertyValue("-moz-transform-style") || st.getPropertyValue("-ms-transform-style") || st.getPropertyValue("transform-style"); if(transform!=='preserve-3d'){ html.className += ' no-preserve-3d'; } else { html.className += ' preserve-3d'; } document.body.removeChild(element); })(); /* function scrollTo(to) { var $obj = jQuery('html, body'); var top = 0; var speed = 500; var offsetX = 50; if (typeof to == 'object') { top = to.offset().top; } else if (typeof to == 'string') { top = jQuery(to).offset().top; } else if (typeof to == 'number') { top = to; } if (arguments.length > 1) { if (typeof arguments[0] == 'number' && typeof arguments[1] == 'number') { speed = arguments[1]; } else if (typeof arguments[1] == 'string' || typeof arguments[1] == 'object') { if (typeof arguments[1] == 'object') { $obj = arguments[1]; } else if (typeof arguments[1] == 'string') { $obj = jQuery(arguments[1]); } } if (typeof arguments[2] == 'number') { speed = arguments[2]; } } if (jQuery(window).width() < 1000) { offsetX = 130; } if (speed == 0) { speed = 1; } $obj.animate( { scrollTop: top - offsetX }, speed ); } */ !function ($) { $('.swiper-slide').on("mouseenter", function () { $('.swiper-slide div.w-slide__tabs li').toggleClass("active"); $('.swiper-slide .w-slide__data li').toggleClass("active"); }); $('.swiper-slide').on("mouseleave", function () { $('.swiper-slide div.w-slide__tabs li').toggleClass("active"); $('.swiper-slide .w-slide__data li').toggleClass("active"); }); var $win = $(window); var $doc = $(document); $(function () { var $html = $('html'); var $body = $('body'); var $pageWrap = $body.children('div.page-wrap'); var $header = $('header.main-header'); var $menu = $('nav.header-menu'); var $info = $body.find('div.top-info'); var screenWidth = $win.width(); var player; if (md.mobile()) { $html.addClass('mobile'); if (md.is('iPhone')) { $html.addClass('iPhone'); } if (md.is('iPad')) { $html.addClass('iPad'); } $html.addClass(md.os()); } else { $html.addClass('desktop'); } $('a.footer-on-top').on('click', function () { scrollTo(0); return false; }); function openMobileMenu() { var $scrollObj = $menu.children('div.main-menu'); var $menuCover = $menu.children('div.header-menu__cover'); var scrollY = $body.scrollTop(); var topInfoHeight = (($info.length && $info.is(':visible'))) ? $info.outerHeight() : 0; $body.data('top', scrollY); $html.addClass('no-scroll'); $menuCover.fadeIn(500); var offset = $win.width() - 60; $pageWrap .css({ top: -scrollY }) .animate({ left: offset }); scrollTo(0, $scrollObj, 0); $menu .css({ display: 'block', width: $win.width(), height: $win.height() - topInfoHeight }) .addClass('js-opened'); $header .animate({ left: offset }); } function closeMobileMenu() { var $menuCover = $menu.children('div.header-menu__cover'); var $smOpened = $menu.find('ul.sub-menu:visible'); var $smContainer = $smOpened.closest('li'); $menu .removeClass('js-opened'); $smContainer.removeClass('m-active'); $header .animate({ left: 0 }, 300, function () { $menu.removeAttr('style'); //$header.removeAttr('style'); }); $pageWrap .animate({ left: 0 }, 300, function () { $html.removeClass('no-scroll'); $pageWrap.removeAttr('style'); $body.scrollTop($body.data('top')); $smOpened.removeAttr('style'); }); $menuCover.fadeOut(500); } $win.on('resize', function () { if ($menu.hasClass('js-opened')) { if (screenWidth != $win.width()) { screenWidth = $win.width(); closeMobileMenu(); } else { $menu .css({ height: $win.height() }); } } if (!$html.hasClass('iOS')) { if ($win.width() >= 1000) { var infoHeight = ($info.length > 0 && $info.is(':visible')) ? $info.height() : 0; var margins = infoHeight + 60; $header.css({ height: $win.height() - margins }); } else { $header.removeAttr('style'); } } }).trigger('resize'); $('a.menu-switcher').on('click', function () { var $el = $(this); if ($el.hasClass('js-close-menu')) { closeMobileMenu(); } else { openMobileMenu(); } return false; }); $('a.close-mobile-menu').on({ click: function () { closeMobileMenu(); } }); $('div.main-menu').each(function () { var $menu = $(this); var $linkSM = $menu.find('a.show-sm'); $linkSM.on({ click: function () { var $el = $(this); var $parent = $el.closest('li'); var $menu = $parent.closest('ul.main-menu__menu'); var $mItems = $menu.children('li'); var $active = $mItems.filter('.active'); var $popup = $($el.data('popup')); var $list = $popup.find('ul.s-menu'); var $items = $list.children('li'); var iNum = $items.length; var time = 150; var i = 0; function drawList() { var iTime = 0; if (i != 0) { iTime = time; } setTimeout(function () { $items.eq(i).addClass('done'); $items.eq(i+1).addClass('done'); i += 2; if (i < iNum) { // if the counter < 10, call the loop function drawList(); // .. again which will trigger another } }, iTime); } if ($win.width() >= 1000) { if ($popup.length) { $mItems.removeClass('m-active'); if ($active.length) { $menu.data('activeItem', $mItems.index($active)); } $active.removeClass('active'); $parent.addClass('m-active'); openPopupSM($popup, drawList); return false; } } else { var $subMenu = $parent.children('ul.sub-menu'); $mItems.removeClass('m-active'); if ($subMenu.is(':visible')) { $subMenu.animate({ height: 'hide', opacity: 'hide' },300); $parent.removeClass('m-active'); } else { $subMenu.animate({ height: 'show', opacity: 'show' }, 300); $parent.addClass('m-active'); } return false; } } }); }); function openPopupSM($obj) { var $popup = null; if (typeof $obj == 'object') { $popup = $obj; } else if (typeof $obj == 'string') { $popup = $($obj); } if (arguments.length > 1) { var funcCallback = (typeof arguments[1] == 'function') ? arguments[1] : null; } var $sMenu = $popup.find('ul.s-menu'); var $smItems = $sMenu.children('li'); if ($sMenu.length) { $smItems.removeClass('done'); } var $openedPopup = $pageWrap.children('.popup-sm:visible'); $html.addClass('sm-visible no-scroll'); if ($openedPopup.attr('id') != $popup.attr('id')) { $openedPopup.fadeOut(300); } $popup.fadeIn(300, funcCallback); } function closePopup($obj) { var $popup = null; if (typeof $obj == 'object') { $popup = $obj; } else if (typeof $obj == 'string') { $popup = $($obj); } $popup.fadeOut(300); $html.removeClass('sm-visible no-scroll'); } $('a.show-popup').on({ click: function (event) { var $el = $(this); var $popup = $($el.data('popup')); openPopupSM($popup); return false; } }); $('a.js-close-sm').on({ click: function () { var $el = $(this); var $popup = $el.closest('.popup-sm'); var $menu = $('nav.header-menu').find('ul.main-menu__menu'); var $mItems = $menu.children('li'); var $menuItemLinks = $menu.children('li').children('a'); if ($menu.data('activeItem') != undefined) { $mItems.eq($menu.data('activeItem')).addClass('active'); } $mItems.removeClass('m-active'); closePopup($popup); return false; } }); $('.image-gallery').each(function () { var $swiper = $(this); var $wrap = $swiper.children('.swiper-wrapper'); var $slides = $wrap.children('.swiper-slide'); var $controls = $swiper.children('.swiper-controls'); var $controlLinks = $controls.find('a'); var $prev = $controlLinks.filter('.swipe-prev'); var $next = $controlLinks.filter('.swipe-next'); var $currPage = $controls.find('span.current-page'); var $totalPage = $controls.find('span.total-pages'); $slides.each(function () { var slide = $(this); var $img = slide.children('img'); var src = $img.attr('src'); slide.css({ backgroundImage: 'url(' + src + ')' }); }); function initSlider(swiper) { $currPage.html(swiper.activeIndex + 1); $totalPage.html(swiper.slides.length); if (swiper.activeIndex == 0) { $prev.addClass('disabled'); } else { $prev.removeClass('disabled'); } if (swiper.activeIndex == swiper.slides.length - 1) { $next.addClass('disabled'); } else { $next.removeClass('disabled'); } } function changeSlide(swiper, direction) { $currPage.html(swiper.activeIndex + 1); if (swiper.activeIndex == 0) { $prev.addClass('disabled'); } else { $prev.removeClass('disabled'); } if (swiper.activeIndex == swiper.slides.length - 1) { $next.addClass('disabled'); } else { $next.removeClass('disabled'); } } var igSwiper = $swiper.swiper({ mode:'horizontal', roundLengths: true, simulateTouch: false, onInit: initSlider, onSlideChangeStart: changeSlide, autoplay: 3000, autoplayDisableOnInteraction: true, autoplayStopOnLast: false, loop: true }); $controlLinks.on({ click: function () { var $el = $(this); if ($el.hasClass('swipe-prev')) { igSwiper.swipePrev(); } else { igSwiper.swipeNext(); } $el.blur(); return false; }, touchstart: function () { var $el = $(this); $el.addClass('touched'); }, touchend: function () { var $el = $(this); $el.removeClass('touched'); } }); }); $('.js-over-scroll').each(function () { var $swiper = $(this); var $wrap = $swiper.children('.swiper-wrapper'); var $slides = $wrap.children('.swiper-slide'); var osSwiper = null; var $controls = $swiper.children('.swiper-controls'); var $controlLinks = $controls.find('a'); var $prev = $controlLinks.filter('.swipe-prev'); var $next = $controlLinks.filter('.swipe-next'); var offsetPx = $prev.width(); var time = 800; var overTimer = null; function initSlider(swiper) { if (swiper.activeIndex == 0) { $prev.addClass('disabled'); } else { $prev.removeClass('disabled'); } if (swiper.activeIndex == swiper.slides.length - 1) { $next.addClass('disabled'); } else { $next.removeClass('disabled'); } } function changeSlider(swiper, direction) { if (swiper.activeIndex == 0) { $prev.addClass('disabled'); } else { $prev.removeClass('disabled'); } if ((swiper.activeIndex == swiper.previousIndex) || (swiper.activeIndex == swiper.slides.length - 1)) { $next.addClass('disabled'); } else { $next.removeClass('disabled'); } } var SwiperOptions = { mode:'horizontal', roundLengths: true, slidesPerView: 'auto', loopedSlides: 1, cssWidthAndHeight: 'height', visibilityFullFit: true, offsetPxBefore: offsetPx, watchActiveIndex: true, onInit: initSlider, onSlideChangeStart: changeSlider }; if ($win.width() >= 768) { osSwiper = $swiper.swiper(SwiperOptions); } $win.on('resize', function () { if (screenWidth != $win.width()) { screenWidth = $win.width(); if (osSwiper) { osSwiper.destroy(true); } if ($win.width() >= 768) { osSwiper = $swiper.swiper($.extend(SwiperOptions, { offsetPxBefore: $prev.width() })); } else { osSwiper=null; } } }); function changeSlide($control) { if ($control.hasClass('swipe-prev')) { //osSwiper.swipePrev(); osSwiper.swipeTo(osSwiper.activeIndex-1, time) } else { //osSwiper.swipeNext(); osSwiper.swipeTo(osSwiper.activeIndex+1, time) } } $controlLinks.on({ mouseenter: function () { var $el = $(this); $wrap.css({ transitionTimingFunction: 'linear' }); osSwiper.params.freeMode = true; changeSlide($el); overTimer = setInterval(function () { changeSlide($el); }, time + 1); }, mouseleave: function () { osSwiper.params.freeMode = false; clearInterval(overTimer); $wrap.css({ transitionTimingFunction: 'ease' }); } }); /*$slides.on({ mouseover: function () { var $el = $(this); if (!$el.hasClass('swiper-slide-visible')) { if ($el.prev('.swiper-slide-visible').length) { osSwiper.swipeNext(); } else if ($el.next('.swiper-slide-visible').length) { osSwiper.swipePrev(); } } } });*/ }); $('div.sub-section__header').on({ click: function () { var $header = $(this); var $sect = $header.closest('.sub-section'); var $body = $header.siblings('div.sub-section__body'); var topX = $header.offset().top + 70; if ($win.width() < 768) { if ($sect.hasClass('sub-section--opened')) { var $video = $body.find('div.video-placeholder'); if ($video.length && player) { player.stopVideo(); } scrollTo($sect.offset().top + 70, 300); $sect.removeClass('sub-section--active'); $body .animate( { height: 'hide', opacity: 'hide' }, 300, function () { $sect.removeClass('sub-section--opened'); $body.removeAttr('style'); $header.trigger("sticky_kit:detach"); } ); } else { scrollTo(topX); $sect.addClass('sub-section--active'); $body.animate({ height: 'show', opacity: 'show' }, 500, function () { $sect.addClass('sub-section--opened'); if ($sect.hasClass('sub-sect-works') || $sect.hasClass('sub-sect-comments')) { $body.find('div.swiper-container').data().swiper.reInit(); } $header .stick_in_parent({ offset_top: 60 }); }); } } $win.on({ resize: function () { if ($win.width() >= 768) { $header.trigger("sticky_kit:detach"); } else if ($sect.hasClass('sub-section--opened')) { $header .stick_in_parent({ offset_top: 60 }); } } }); } }); $('div.works-gallery').each(function () { var $galleryCont = $(this); var $galleryPicts = $galleryCont.find('div.works-gallery__picts'); var $swiper = $galleryPicts.children('.swiper-container'); var $wSlidesCont = $galleryPicts.find('div.w-slide'); var $wsDataImgs = $wSlidesCont.find('img'); var $controls = $galleryCont.find('div.works-gallery__controls'); var $controlLinks = $controls.find('a'); var $prev = $controlLinks.filter('.swipe-prev'); var $next = $controlLinks.filter('.swipe-next'); var $currPage = $controls.find('span.current-page'); var $totalPage = $controls.find('span.total-pages'); var $wgDescr = $galleryCont.find('div.works-gallery__descr'); var $wgText = $galleryCont.next('div.works-gallery-descr'); $wsDataImgs.each(function () { var $img = $(this); var pictUrl = $img.attr('src'); var $imgWrap = $img.closest('li'); $imgWrap.css({ backgroundImage: 'url(' + pictUrl + ')' }); }); function initSlider(swiper) { var $slideText = $wSlidesCont.eq(swiper.activeIndex).find('div.w-slide__text'); $currPage.html(swiper.activeIndex + 1); $totalPage.html(swiper.slides.length); if (swiper.activeIndex == 0) { $prev.addClass('disabled'); } else { $prev.removeClass('disabled'); } if (swiper.activeIndex == swiper.slides.length - 1) { $next.addClass('disabled'); } else { $next.removeClass('disabled'); } $wgDescr.html($slideText.html()); $wgText.html($slideText.html()); } function changeSlide(swiper, direction) { var $slideText = $wSlidesCont.eq(swiper.activeIndex).find('div.w-slide__text'); $currPage.html(swiper.activeIndex + 1); if (swiper.activeIndex == 0) { $prev.addClass('disabled'); } else { $prev.removeClass('disabled'); } if (swiper.activeIndex == swiper.slides.length - 1) { $next.addClass('disabled'); } else { $next.removeClass('disabled'); } $wgDescr.html($slideText.html()); $wgText.html($slideText.html()); } var wgSwiper = $swiper.swiper({ mode:'horizontal', roundLengths: true, simulateTouch: false, cssWidthAndHeight: 'height', onInit: initSlider, onSlideChangeStart: changeSlide, autoplay: 3000, autoplayDisableOnInteraction: true, autoplayStopOnLast: false, }); $controlLinks.on({ click: function () { var $el = $(this); if ($el.hasClass('swipe-prev')) { wgSwiper.swipePrev(); } else { wgSwiper.swipeNext(); } $el.blur(); return false; }, touchstart: function () { var $el = $(this); $el.addClass('touched'); }, touchend: function () { var $el = $(this); $el.removeClass('touched'); } }); $wSlidesCont.each(function () { var slide = $(this); var $wsTabs = slide.children('div.w-slide__tabs'); var $wsData = slide.children('ul.w-slide__data'); var $tabs = $wsTabs.find('li'); var $datas = $wsData.children('li'); $tabs.on({ click: function () { var $tab = $(this); var index = $tabs.index($tab); if (!$tab.hasClass('active')) { $tabs.removeClass('active'); $tab.addClass('active'); $datas.removeClass('active'); $datas.eq(index).addClass('active'); } } }); }); }); $('div.comments-gallery').each(function () { var $cg = $(this); var $swiper = $cg.find('div.swiper-container'); var $controls = $cg.find('div.swiper-controls-pager'); var $controlLinks = $controls.find('a'); var $prev = $controlLinks.filter('.swipe-prev'); var $next = $controlLinks.filter('.swipe-next'); var $currPage = $controls.find('span.current-page'); var $totalPage = $controls.find('span.total-pages'); function initSlider(swiper) { $currPage.html(swiper.activeIndex + 1); $totalPage.html(swiper.slides.length); if (swiper.activeIndex == 0) { $prev.addClass('disabled'); } else { $prev.removeClass('disabled'); } if (swiper.activeIndex == swiper.slides.length - 1) { $next.addClass('disabled'); } else { $next.removeClass('disabled'); } } function changeSlide(swiper, direction) { $currPage.html(swiper.activeIndex + 1); if (swiper.activeIndex == 0) { $prev.addClass('disabled'); } else { $prev.removeClass('disabled'); } if (swiper.activeIndex == swiper.slides.length - 1) { $next.addClass('disabled'); } else { $next.removeClass('disabled'); } } var cgSwiper = $swiper.swiper({ mode:'horizontal', roundLengths: true, //simulateTouch: false, cssWidthAndHeight: 'height', onSwiperCreated: initSlider, onInit: initSlider, onSlideChangeStart: changeSlide }); $controlLinks.on({ click: function () { var $el = $(this); if ($el.hasClass('swipe-prev')) { cgSwiper.swipePrev(); } else { cgSwiper.swipeNext(); } $el.blur(); return false; }, touchstart: function () { var $el = $(this); $el.addClass('touched'); }, touchend: function () { var $el = $(this); $el.removeClass('touched'); } }); }); $('dl.wsp').each(function () { var $link = $(this).children('dt').find('a'); $link.on({ click: function () { var $a = $(this); var $dl = $a.closest('dl'); var $siblingsDl = $dl.siblings('dl'); if (!$dl.hasClass('active')) { $siblingsDl.removeClass('active'); $dl.addClass('active'); } return false; } }); }); $('div.ws-slide').each(function () { var slide = $(this); var $wsTabs = slide.children('div.ws-slide__tabs'); var $wsData = slide.children('ul.ws-slide__data'); var $tabs = $wsTabs.find('li'); var $datas = $wsData.children('li'); $tabs.on({ click: function () { var $tab = $(this); var index = $tabs.index($tab); if (!$tab.hasClass('active')) { $tabs.removeClass('active'); $tab.addClass('active'); $datas.removeClass('active'); $datas.eq(index).addClass('active'); } } }); }); $('.price-item__body').css("display","block"); $('main.page-price-list').each(function () { var $main = $(this); var $piTitle = $main.find('div.price-item__title'); var $title = $(this); /* $piTitle.on({ click: function () { var $title = $(this); var $pi = $title.closest('.price-item'); var $piBody = $pi.children('.price-item__body'); var topX = $pi.offset().top + 51; if ($pi.hasClass('price-item--opened')) { $pi.removeClass('price-item--opened'); $piBody.animate({ height: 'hide', opacity: 'hide' }, 800); } else { if ($win.width() < 768) { scrollTo(topX); } $pi.addClass('price-item--opened'); $piBody.animate({ height: 'show', opacity: 'show' }, 800); } } });*/ }); $('.overflow-ellipsis').each(function () { $(this).dotdotdot({ watch: 'window' }); }); $('input[type="file"], input[type="checkbox"]').styler(); function setTransform() { // } $body.each(function () { var $main = $(this).find('main'); var $smileSect = $main.children('div.smile-sect'); var $sectsWrap = $main.children('div.ip-sects-wrap'); var $subSects = $sectsWrap.children('div.ip-sect'); var $subSectBackgrounds = $subSects.children('div.ip-sect__bg'); scrollTo(0, 0); if ($info.length) { var $closeInfo = $info.find('a.top-info__close'); $body.addClass('has-info'); $closeInfo.on({ click: function () { var height = $win.height(); var width = $win.width(); var c = $.cookie('vazhno'); if(!c || c.length == 0) c = $(this).attr('rel'); else c = c + "|" + $(this).attr('rel'); $.cookie('vazhno', c, { expires: 10 }); $body.removeClass('has-info'); if (width >= 1000) { $main.css({ minHeight: (height) }); $subSects .css({ height: (height) / 2 }); } $win.trigger('resize'); return false; } }); } $subSectBackgrounds.each(function () { var $el = $(this); var src = $el.find('img').attr('src'); $el.css({ backgroundImage: 'url(' + src + ')' }); }); $win .on({ resize: function () { var height = $win.height(); var width = $win.width(); var infoHeight = ($info.length > 0 && $info.is(':visible')) ? $info.height() : 0; if ($body.hasClass('index-page')) { if (width >= 1000) { $main.css({ minHeight: (height - infoHeight) }); $smileSect.css({ height: (height - infoHeight) }); $subSects .css({ height: (height - infoHeight) / 2 }); } else { if ($subSects.attr('style')) { $subSects.removeAttr('style'); } } } if ($body.hasClass('has-info')) { $body.css({ paddingTop: infoHeight }); } else { if ($body.attr('style')) { $body.removeAttr('style'); } } if (width < 1000) { $header.css({ top: infoHeight }); } else { $header.css({ top: infoHeight + 30 }); } } }) .trigger('resize'); }); $('#smile').each(function () { var $smile = $(this); var $main = $smile.closest('main'); var $sectsWrap = $main.children('div.ip-sects-wrap'); var $container = $smile.closest('.smile-sect__bg'); var smileWidth = parseInt($smile.data('width')); var smileHeight = parseInt($smile.data('height')); var $imgs = $smile.find('div.smile__img'); var center = { x: smileWidth/2, y: smileHeight/2 }; var halfWindowH = $win.height()*0.5; var halfWindowW = $win.width()*0.5; var maxRotationY = 5; var maxRotationX = 3; function moveBackground(event) { var rotateY = -((-event.pageX+halfWindowW)/halfWindowW)*maxRotationY; var rotateX = -((event.pageY-halfWindowH)/halfWindowH)*maxRotationX; if( rotateY > maxRotationY) rotateY = maxRotationY; if( rotateY < -maxRotationY ) rotateY = -maxRotationY; if( rotateX > maxRotationX) rotateX = maxRotationX; if( rotateX < -maxRotationX ) rotateX = -maxRotationX; var strTransform = 'rotateX(' + rotateX + 'deg' + ') rotateY(' + rotateY + 'deg' + ') translateZ(0)'; $smile.css({ '-moz-transform': strTransform, '-webkit-transform': strTransform, '-ms-transform': strTransform, '-o-transform': strTransform, 'transform': strTransform }); setTimeout(function () { $body.addClass('no-transition'); }, 800); } function gyroBackground(event) { var acceleration=(event.accelerationIncludingGravity); var rotateY = -((-acceleration.x+halfWindowW)/halfWindowW)*maxRotationY; var rotateX = -((acceleration.x-halfWindowH)/halfWindowH)*maxRotationX; if( rotateY > maxRotationY) rotateY = maxRotationY; if( rotateY < -maxRotationY ) rotateY = -maxRotationY; if( rotateX > maxRotationX) rotateX = maxRotationX; if( rotateX < -maxRotationX ) rotateX = -maxRotationX; var strTransform = 'rotateX(' + rotateX + 'deg' + ') rotateY(' + rotateY + 'deg' + ') translateZ(0)'; $smile.css({ '-moz-transform': strTransform, '-webkit-transform': strTransform, '-ms-transform': strTransform, '-o-transform': strTransform, 'transform': strTransform }); setTimeout(function () { $body.addClass('no-transition'); }); } function listenGyroscope (event) { var orientation = window.orientation; var beta = Math.round(event.beta); var gamma = Math.round(event.gamma); var angle = 0; if(beta!=null || gamma!=null) { if (orientation == 0 || orientation == 180) { angle = (orientation == 0) ? gamma : -gamma; } else { angle = (orientation == 90) ? beta : -beta; } } } $win.on({ mousemove: function(event){ if( $html.hasClass('preserve-3d') ) { window.requestAnimationFrame(function(){ moveBackground(event); }); } }, load: function () { if(window.DeviceOrientationEvent) { //window.addEventListener('deviceorientation', listenGyroscope, false); } } }); function resizeMedia(jObj, mWidth, mHeight, jContainer) { var cWidth = Math.round(jContainer.width()); var cHeight = Math.round(jContainer.height()); var width = mWidth; var height = mHeight; var ratio = height / width; width = cWidth; height = Math.round(cWidth * ratio); if(height > cHeight){ height = cHeight; width = Math.round(height / ratio); } center.x = width/2; center.y = height/2; jObj.css({ position: 'absolute', left: '50%', top: '50%', width: width, height: height, margin: "" + (-center.y) + "px 0 0 " + (-center.x) + "px" }); } $win.on({ resize: function () { halfWindowH = $win.height(); halfWindowW = $win.width(); resizeMedia($smile, smileWidth, smileHeight, $container); } }).trigger('resize'); $imgs.each(function (i) { var $el = $(this); var timeOut = 20; var centerX = $el.width()/2; var centerY = $el.height()/2; var originX = ($el.offset().left + centerX) - center.x; var originY = ($el.offset().top + centerY) - center.y; var strTransformOrigin = '' + (-originX) + 'px ' + (-originY) + 'px'; $el.css({ webkitTransformOrigin: strTransformOrigin, MozTransformOrigin: strTransformOrigin, MsTransformOrigin: strTransformOrigin, msTransformOrigin: strTransformOrigin, transformOrigin: strTransformOrigin }); $win.on({ load: function () { $body.addClass('loaded'); setTimeout(function () { $el.addClass('loaded'); }, timeOut * i); setTimeout(function () { $header.addClass('opacity-1'); $sectsWrap.addClass('opacity-1'); }, 2000); } }); }); }); $('a.hint__link').on({ mouseover: function () { var $hint = $(this); var $container = $hint.closest('.hint'); var $info = $container.find('div.hint__info'); var $hintsWrap = $container.closest('.pict-hinting__hints'); var width = $hintsWrap.width(); var left = $container.position().left; if ($win.width() < 640) { $info.css({ width: width, left: -left }); } else { $info.removeAttr('style'); } $info.stop().fadeIn(500); $container.addClass('hint--opened'); }, mouseout: function () { var $hint = $(this); var $container = $hint.closest('.hint'); var $info = $container.find('div.hint__info'); $info.stop().fadeOut(500); $container.removeClass('hint--opened'); }, click: function () { return false; } }); function resizeYouTube(jObj, mWidth, mHeight, jContainer) { var cWidth = Math.round(jContainer.width()); var cHeight = Math.round(jContainer.height()); var width = mWidth; var height = mHeight; var ratio = height / width; width = cWidth; height = Math.round(cWidth * ratio); jObj.css({ width: width, height: height }); } $('a.video-replace').on({ click: function () { var $link = $(this); var $placeholder = $link.closest('.video-placeholder'); var width = $placeholder.width(); var height = $placeholder.height(); var videpId = $placeholder.data('video'); $placeholder.html(''); var $youTube = $placeholder.find('iframe'); player = new YT.Player($youTube.get(0)); $win.on({ resize: function () { resizeYouTube($youTube, width, height, $placeholder); } }); return false; } }); $('input.input-tel').inputmask({ mask: '8 (999) 999-99-99', showMaskOnFocus: true, showMaskOnHover: false, placeholder: "_", //removeMaskOnSubmit: true, oncomplete: function () { $(this).removeClass('empty'); }, onincomplete: function () { $(this).addClass('empty'); }, onKeyValidation: function () { $(this).addClass('empty'); } }); $('form').each(function () { var $form = $(this); var $msgSuccess = $('div.pw-success'); var $msgError = $('div.pw-error'); $form.validate({ debug: false /*submitHandler: function() { openMsg($msgSuccess); /!*$.ajax({ data: $(this).serialize(), url: this.action, type: this.method, error: function() { openMsg($msgError); }, success: function(results) { openMsg($msgSuccess); } });*!/ }*/ }); }); $('form.opinion-form').each(function () { var $form = $(this); var $button = $form.find('button'); var $aWin = $('#pw-authorize'); var $sWin = $(".pw-success"); var $eWin = $(".pw-error"); $button.on({ click: function () { if ($form.valid()) { if($form.hasClass('need-auth')) { openMsg($aWin); } else { $.post($form.attr('action'), $form.serialize(), function(data){ if(data == 'OK') { closeMsg($("#psm-opinion")); openMsg($sWin); } else { openMsg($eWin); } }); } } } }); }); function openMsg($obj) { $obj.fadeIn(500); } function closeMsg($obj) { $obj.fadeOut(500); $html.removeClass('sm-visible no-scroll'); } $('a.close-pw').on({ click: function () { var $wnd = $(this).closest('.popup-window'); closeMsg($wnd); $("div.sign-up, .popup-sm").fadeOut(); return false; } }); $('div.popup-window').on({ click: function (event) { var $wnd = $(this); if ($(event.target).hasClass('popup-window__body') ) { closeMsg($wnd); } } }); $('div.bg-video').each(function () { var $video = $(this); $video.YTPlayer(); }); if ($.fn.fancybox) { $('a.show-big').fancybox({ helpers: { overlay: { locked: false, css : { 'background' : 'rgba(255, 255, 255, 0.9)' } } } }); } }); }(jQuery);