jQuery(function($) { 'use strict'; /* Table of contents */ /* # Headers # Bar # Navigation # Footer # Shortcodes ## Accordion box ## Banner box ## Chart box ## Counter box ## Contact form ## Countdown box ## Cover box ## Gallery ## Google maps ## Onepage ## Parallax ## Progress bar ## Pricing table ## Social bar ## Split box ## Sliders ## Split screen ## Tab box ## Video Background # Portfolio ## Portfolio gallery ## Scroll content # Lazy load # Other */ window.Nor = { init: function(){ // Header this.header = $('#masthead'); this.headerIsFifth = Nor.header.hasClass('header-5'); this.headerIsSixth = Nor.header.hasClass('header-6'); this.headerFixed = { initialOffset: parseInt( this.header.attr('data-fixed-initial-offset') ) || 150, enabled: $('[data-header-fixed]').length, value: false, mobileEnabled: $('[data-mobile-header-fixed]').length, mobileValue: false }; this.headerSearch = $('.header-search'); this.subheader = $('.subheader'); // Logos this.siteBranding = this.header.find('.site-branding'); this.siteTitle = this.header.find('.site-title'); this.logo = this.header.find('.logo'); this.fixedLogo = this.header.find('.fixed-logo'); this.mobileLogo = this.header.find('.mobile-logo'); this.fixedMobileLogo = this.header.find('.fixed-mobile-logo'); this.logoForOnepage = this.header.find('.for-onepage'); this.logoForOnepageDark = this.logoForOnepage.find('.dark'); this.logoForOnepageLight = this.logoForOnepage.find('.light'); // Menus this.megaMenu = this.header.find('#mega-menu-wrap'); // Page this.page = $('#page'); this.adminBar = $('#wpadminbar'); this.resize(); }, resize: function(){ this.isMobile = $(window).width() <= 768; this.isPad = $(window).width() <= 1024; } }; /* # Headers */ function handleHeaders(){ // Search open $('[data-nav-search]').click( function(e) { e.preventDefault(); Nor.headerSearch.addClass('opened'); setTimeout(function(){ Nor.headerSearch.find('form input').focus(); }, 100); }); // Search close Nor.headerSearch.click( function(e) { Nor.headerSearch.removeClass('opened'); }); // Remove close from form Nor.headerSearch.find('form').click( function(e) { e.stopPropagation(); }); if( Nor.headerIsFifth ){ handleHeaderFifth(); // Show logo after first calculate Nor.siteTitle.css( 'opacity', '1' ); // If menu hidden or empty then set logo relative if( $('.main-nav.hidden').length == 0 ){ Nor.siteTitle.css( 'position', 'relative' ); } } handleMobileHeader(); handleHeaderSize(); handleFixedHeader(); } function handleMobileHeader() { if( Nor.header && Nor.header.length ){ if( Nor.isMobile ){ //$(window).width() <= 768; Nor.header.addClass('mobile-header'); } else { Nor.header.removeClass('mobile-header'); } } } function handleHeaderSize(){ if( Nor.headerIsFifth ){ handleHeaderFifth(); } handleFixedHeader(); if( !Nor.headerIsSixth ){ Nor.header.css( 'width', Nor.page.outerWidth() + 'px' ); } // Reset mega menu css properties for mobile phone if( Nor.isMobile ){ Nor.megaMenu.find( 'ul' ).css({ 'left': '', 'width': '', 'max-width': '', 'min-width': '' }); } } function handleFixedHeader() { var fixed = Nor.headerFixed; if( $(document).scrollTop() > fixed.initialOffset ){ if( (!Nor.isMobile && fixed.enabled && !fixed.value) || (Nor.isMobile && fixed.mobileEnabled && !fixed.mobileValue) ){ if( Nor.isMobile ){ fixed.mobileValue = true; } else { fixed.value = true; } Nor.header.addClass( 'header-fixed no-transition' ) .css({ 'width': Nor.page.outerWidth() + 'px' }); // Add admin bar offset // if( Nor.adminBar.length && !Nor.isMobile ) { // Nor.header.css( 'top', Nor.adminBar.outerHeight() + 'px' ); // } // Hide non fixed logos Nor.logo.css( 'display', 'none' ); Nor.mobileLogo.css( 'display', 'none' ); // Show fixed logo if( Nor.isMobile && Nor.fixedMobileLogo.length ) { Nor.fixedMobileLogo.css( 'display', 'inline' ); } else { Nor.fixedLogo.css( 'display', 'inline' ); } } } else if( fixed.value || fixed.mobileValue ) { fixed.value = false; fixed.mobileValue = false; Nor.header.removeClass( 'header-fixed' ); Nor.header.css({ 'transition-duration': '.2s', 'top': '', 'width': '', 'margin-top': '', }); // Hide fixed logos Nor.fixedLogo.css( 'display', '' ); Nor.fixedMobileLogo.css( 'display', '' ); // Show non fixed logo if( Nor.isMobile && Nor.mobileLogo.length ) { Nor.logo.css( 'display', 'none' ); Nor.mobileLogo.css( 'display', 'inline' ); } else { Nor.logo.css( 'display', 'inline' ); Nor.mobileLogo.css( 'display', 'none' ); } } // Effect appearance if ( $(document).scrollTop() > fixed.initialOffset + 50 ) { Nor.header.removeClass('no-transition').addClass('showed'); } else { Nor.header.removeClass('showed').addClass('no-transition'); } } // Five header cetered logo function handleHeaderFifth(){ var nav = Nor.megaMenu.find('> ul > li'); Nor.megaMenu.css( 'margin-left', '' ); if( !Nor.isPad ){ // If navigation hidden or empty then set logo on center if( $('.main-nav.hidden').length ){ Nor.siteTitle.css( 'left', '' ); var containerCenter = Nor.page.outerWidth()/2 + Nor.page.offset().left, siteTitleCenter = containerCenter - Nor.siteTitle.offset().left - (Nor.siteTitle.outerWidth() / 2); Nor.siteTitle.css( 'left', siteTitleCenter + 'px' ); } else { // Hidden logo for repeat calculate Nor.siteTitle.css( 'display', 'none' ); // Insert logo in center if ( Nor.megaMenu.length ) { var centerMenu = $('#primary-menu').width() / 2; var centerLi = 0, countWidth = 0; centerLi = nav.length / 2; if(centerLi % 2 !== 0) { centerLi = Math.round(centerLi); centerLi = centerLi - 1; } if ( nav.length > 4 ) { // Remove devider from center li $(nav[centerLi]).addClass( 'without-divider' ); // Append logo after center li Nor.siteTitle.insertAfter( $(nav[centerLi]) ); } else { // Remove devider from center li $(nav[centerLi - 1]).addClass( 'without-divider' ); // Append logo after center li Nor.siteTitle.insertBefore( $(nav[centerLi]) ); } } else { Nor.megaMenu.append( Nor.siteTitle ); } // Restore hidden logo Nor.siteTitle.css( 'display', 'block' ); // Centered menu var containerLeft = Nor.page.offset().left, containerWidth = Nor.page.outerWidth(), logoLeft = Nor.siteTitle.offset().left, logoWidth = Nor.siteTitle.outerWidth(); var left = (containerLeft + containerWidth / 2) - logoLeft - (logoWidth / 2); Nor.megaMenu.css( 'margin-left', (left * 2) + 'px' ); } } else { Nor.siteTitle.css( 'left', '0' ); } } function handleHeaderTitle() { // Ttitle Parallax if ( $('.header-title .page-title').hasClass('no-transition') ){ if ( $('.header-title h1').length ) { var scroll = $(document).scrollTop() / 3; if ( scroll > 200 ) { scroll = 200; } else { scroll = scroll; } $('.header-title h1, .header-title p.subtitle, .header-title .tags').css({ 'transform': 'translate3d(0,' + (scroll) + 'px, 0)', 'opacity': 1 - ( scroll / 200) }); } } } function showHeaderTitle(){ $('.header-title').addClass('show'); setTimeout(function(){ $('.header-title .page-title, .header-title .subtitle, .header-title .tags').addClass('no-transition'); }, 1000); } /* # Bar */ function handleBarScroll(){ var bar = $('.bar'); if( bar.length ){ var hamburger = $('.bar-hamburger .hamburger'); if ( $(document).scrollTop() > 100 ) { hamburger.css('margin-top', '25px'); } else { hamburger.css('margin-top', ''); } } } /* # Navigation */ window.openFullscreenMenu = function(){ $('#fullscreen-mega-menu').addClass( 'open' ).find('#secondary-menu > li').each(function(i){ var link = $(this); setTimeout(function(){ link.addClass('showed'); }, 150 + i * 40); }); }; function handleNavigations() { // Mobile menu var menuNow = 0; $('#hamburger-menu').click( function(){ $('#site-navigation').addClass( 'active' ); $('.close-menu').css( 'right', '0' ); $(this).addClass('hidden'); $('#masthead .search').addClass('visible'); }); $('#site-navigation .close, .close-menu, .mobile-header #site-navigation a[href^="#"]').click( function(){ if ( menuNow != 0 ) { $('#mega-menu-sub-' + menuNow).removeClass( 'active' ); $('#mega-menu-sub-' + menuNow).removeAttr( 'id' ); menuNow--; } else { $('#site-navigation').removeClass( 'active' ); $('.close-menu').css( 'right', '-100%' ); $('#hamburger-menu').removeClass('hidden'); $('#masthead .search').removeClass('visible'); } }); $('a.menu-link').on('click', function(){ if( $(this).attr('href')[0] == '#' ){ menuNow = 0; $('[id^="mega-menu-sub-"]').removeClass( 'active' ); $('[id^="mega-menu-sub-"]').removeAttr( 'id' ); $('#site-navigation').removeClass( 'active' ); $('.close-menu').css( 'right', '-100%' ); $('#hamburger-menu').removeClass('hidden'); $('#masthead .search').removeClass('visible'); } }); $('.has-submenu > a').on( 'click touchstart', function(e) { if( Nor.isPad ){ //Nor.isMobile var menu = $(this).parent().find('.sub-nav > ul.sub-menu, > .sub-sub-nav > ul.sub-sub-menu, .submenu'); menuNow++; menu.addClass('active').attr('id', 'mega-menu-sub-' + menuNow); e.preventDefault(); } else { window.location.href = $(this).attr('href'); } }); if ( $('#masthead nav > .mobile-wpml-select').length ) { $('#masthead nav > .mobile-wpml-select').insertAfter( $('#mega-menu-wrap > ul > li').last() ); } // Mega Menu if ( $('#mega-menu-wrap').length ) { $('#mega-menu-wrap').accessibleMegaMenu({ uuidPrefix: 'accessible-megamenu', menuClass: 'menu', topNavItemClass: 'nav-item', panelClass: 'sub-nav', panelGroupClass: 'sub-sub-menu', hoverClass: 'hover', focusClass: 'focus', openClass: 'open' }).on( 'megamenu:open', function(e, el) { var $menu = $(this), $el = $(el), $subNav; if( Nor.isMobile ){ return false; } if ( $el.is( '.main-menu-link.open' ) && $el.siblings( 'div.sub-nav' ).length>0) { $subNav = $el.siblings( 'div.sub-nav' ); } else if ( $el.is( 'div.sub-nav' ) ) { $subNav = $el; $el = $subNav.siblings( '.main-menu-link' ); } else { return true; } //$subNav.removeAttr( 'style' ).removeClass( 'sub-nav-onecol' ); var ul = $subNav.find('ul.sub-menu-wide'); ul.each( function() { var $ul = $(this); var total_width = 1; $ul.find('> .sub-nav-item').each( function() { total_width += $(this).outerWidth(); }); $ul.innerWidth( total_width ); }); var headerLeft = 0; if ( $('#masthead.header-3').length ) { var headerWrap = $('#masthead.header-3 .header-wrap'); headerLeft = $(window).width() - headerWrap.outerWidth() - headerWrap.offset().left; } var windowWidth = $(window).width(); var subNavWidth = $subNav.find('> ul').width(); var subNavMargin = 0; $subNav.css({'max-width': windowWidth}); if ( subNavWidth > windowWidth) { $subNav.addClass( 'sub-nav-onecol' ); subNavWidth = $subNav.width(); } var elWidth = $el.outerWidth(); var elOffsetLeft = $el.offset().left; var elOffsetRight = windowWidth - $el.offset().left - elWidth; if ( elOffsetLeft < 0 ) { subNavMargin = -(elOffsetLeft -subNavWidth/2 + elWidth/2) - headerLeft; } if ( elOffsetRight < ( subNavWidth - elWidth) ) { subNavMargin = -( subNavWidth - elWidth - elOffsetRight) - headerLeft; } if ( ul.outerWidth() >= windowWidth ){ $subNav.css('left', ''); ul.innerWidth( windowWidth ); subNavMargin = -$subNav.offset().left; } $subNav.css( 'left', subNavMargin ); }); $('#mega-menu-wrap .sub-sub-nav').each( function(){ if ( $(this).offset().left + $(this).outerWidth() > $(window).width() ) { $(this).addClass('menu-left'); } }); } // Fullscreen Mega Menu $('#hamburger-fullscreen-menu').on( 'click', function(){ openFullscreenMenu(); }); var fullscreenMenu = $('#fullscreen-mega-menu-wrap'); if ( fullscreenMenu.length ) { var closeMenu = function(){ $('#fullscreen-mega-menu').removeClass( 'open' ).find('#secondary-menu > li').each(function(i){ $(this).removeClass('showed'); }); }; $('#fullscreen-menu-close, #fullscreen-mega-menu-wrap a[href^="#"]').on( 'click', closeMenu ); fullscreenMenu.accessibleMegaMenu({ uuidPrefix: 'accessible-megamenu', menuClass: 'menu', topNavItemClass: 'nav-item', panelClass: 'sub-nav', panelGroupClass: 'sub-sub-menu', hoverClass: 'hover', focusClass: 'focus', openClass: 'open' }).on( 'megamenu:open', function(e, el) { $(this).find('.sub-nav:not(.open) > ul > li, .sub-nav .mega-menu-item:not(:hover) > .sub-sub-nav > .sub-sub-menu > li').removeClass('showed'); $(this).find('.sub-nav.open > ul > li, .sub-nav .mega-menu-item:hover > .sub-sub-nav > .sub-sub-menu > li').each(function(i){ var self = $(this); setTimeout(function(){ if(self.parent().parent().parent().is(':hover')){ self.addClass('showed'); } }, i * 40); }); }); $('#fullscreen-mega-menu-wrap .sub-nav').on('mouseleave', function(){ $(this).find('li').removeClass('showed'); }); } } /* # Footer */ function handleFooter() { // Sticky var stickyFooter = $('.site-footer.sticky'); if( stickyFooter.length && !Nor.isMobile ) { $('.site-content').css({ 'margin-bottom': stickyFooter.outerHeight() + 'px', 'position': 'relative', 'z-index': '3' }); stickyFooter.addClass('visible'); } }; function handleFooterSize() { var stickyFooter = $('.site-footer.sticky'); if( stickyFooter.length ){ if( !Nor.isPad ){ stickyFooter.css({ 'width': stickyFooter.parent().outerWidth() + 'px', 'left': stickyFooter.parent().offset().left + 'px', }); $('.site-content').css({ 'margin-bottom': stickyFooter.outerHeight() + 'px', 'position': 'relative', 'z-index': '3' }); } else { $('.site-content').css({ 'margin-bottom': '', 'position': '', 'z-index': '' }); stickyFooter.css({ 'width': '', 'left': '', }); } } } /* # Shortcodes */ /* ## Accordion box */ function handleAccordionBox(){ $('[data-norebro-accordion]').each(function(){ var accordion = $(this); var titles = $(this).find('div.title'); var items = $(this).find('.item'); var contents = $(this).find('.content'); var iconOpened = 'ion-minus', iconClosed = 'ion-plus'; var isOutline = $(this).hasClass('outline'); var toggle = function( num ){ var opened = accordion.find('.open'); var content = contents.eq( num ); // If not active if( !items.eq( num ).hasClass('active') ){ // Activate this item items.removeClass('active'); items.eq( num ).addClass('active'); setTimeout(function(){ content.css('height', '').addClass('no-transition open'); // Open new content var height = content.outerHeight() + 'px'; // Save heights content.removeClass('no-transition open').css( 'height', (isOutline) ? '0px' : '6px' ); // Close new content setTimeout(function(){ opened.removeClass('open no-transition').css( 'height', (isOutline) ? '0px' : '6px' ); // Close old content content.addClass('open').css( 'height', height ); // Open new content // Change titles titles.find('.control span').removeClass( iconOpened ).addClass( iconClosed ); titles.eq(num).find('.control span').removeClass( iconClosed ).addClass( iconOpened ); }, 30); }, 30); } else { items.removeClass('active'); opened.removeClass('open no-transition').css( 'height', (isOutline) ? '0px' : '6px' ); titles.find('.control span').removeClass( iconOpened ).addClass( iconClosed ); }; }; titles.each(function(i){ $(this).on('click', function(){ toggle( i ); }); }); toggle( $(this).attr('data-norebro-accordion') || 0 ); this.accordionToggle = toggle; }); }; function handleAccordionBoxSize(){ $('[data-norebro-accordion]').each(function(){ var content = $(this).find('.content.open'); var wrap = content.find('.wrap'); content.css('height', wrap.outerHeight() + 'px'); }); }; /* ## Banner box */ function handleBannerBox(){ $('.banner-box.overlay-title.hover').each(function(){ $(this).hover(function(){ var self = $(this); var content = $(this).find('.title-wrap'); var description = $(this).find('.description-wrap'); description.css('margin-top', -content.outerHeight() + 'px'); }, function(){ var self = $(this), newHeight = 0, oldHeight = 0; self.find('.description-wrap').css('margin-top', ''); }); }); } function handleBannerBoxSize(){ $('.banner-box.overlay-title.hover').each(function(){ var newHeight = 0, titles = $(this).find('.title-wrap'); $(this).css('height', ''); $(this).css('height', ($(this).outerHeight() - titles.outerHeight()) + 'px'); }); } /* ## Clients logo */ function handleClientsLogo(){ $('.clients-logo .overlay').each(function(){ $(this).css('top', '-' + $(this).find('h4').outerHeight() + 'px'); }); }; /* ## Chart box */ function handleChartBox(){ var scrollTop = $(document).scrollTop() + $(window).height(); var settings = { size: 128, trackColor: "#e0e0e0", scaleColor: false, lineWidth: 4, trackWidth: 4, lineCap: "square", onStep: function(from, to, percent){ if( $(this.el).length ){ $(this.el).parent().find(".percent").html( Math.round(percent) ); } } }; $("[data-chart-box]").each(function(){ if( scrollTop > $(this).offset().top + $(this).height() ){ var color = $(this).attr("data-color") if( color != undefined && color != 'brand' ){ settings.barColor = color; } else { var tmp = $(document.createElement('div')).addClass('brand-color'); $(document.body).append(tmp); var color = $('.brand-color').eq(0).css('color'); tmp.remove(); settings.barColor = color; } $(this).easyPieChart( settings ); } }); }; /* ## Counter box */ function handleCounterBox(){ $('[data-counter]').each(function(){ var counter = $(this); var scrollTop = $(document).scrollTop() + $(window).height(); if( scrollTop > counter.offset().top + counter.height() ){ var countEnd = parseInt( counter.attr('data-counter').replace(/\s/g, '') ); counter.removeAttr('data-counter'); for(var j = 0; j <= 20; j++){ (function(count){ setTimeout(function(){ var number = Math.round((countEnd / 20) * count); counter.find('.count').html(number); }, 50 * count); })(j); } } }); }; /* ## Contact form */ function handleContactForm(){ // Button $('.contact-form').each(function(){ var submit = $(this).find('[type="submit"]'); var button = $(this).find('[data-contact-btn] button'); if( submit.length ){ button.find('.text').html( submit.val() ); submit.replaceWith( button ); $(this).find('.ajax-loader').remove(); } // For focus if( $(this).hasClass('without-label-offset') ){ $(this).find('.wpcf7-form-control-wrap').after('
'); $(this).find('input, textarea, select').on('focus', function(){ $(this).parent().parent().find('.focus').addClass('active'); }).on('blur', function(){ $(this).parent().parent().find('.focus').removeClass('active'); }); } }); // Loader $('.contact-form form').on('submit', function(){ $(this).find('.btn-load').css({ 'width': '21px', 'margin-right': '6px' }); }); $(document).on('spam.wpcf7 invalid.wpcf7 spam.wpcf7 mailsent.wpcf7 mailfailed.wpcf7', function(e){ var form = e.target; $(form).find('.btn-load').css({ 'width': '0px', 'margin-right': '0px' }); }); } /* ## Countdown box */ function handleCountdownBox(){ $("[data-countdown-box]").each(function(){ var countdownBox = $(this); var labels = countdownBox.attr('data-countdown-labels').split(','), parser = /([0-9]{2})/gi; // Return the time components that diffs var diff = function(obj1, obj2) { var diff = []; labels.forEach(function(key) { if (obj1[key] !== obj2[key]) { diff.push(key); } }); return diff; } // Parse countdown string to an object var strfobj = function(str) { var parsed = str.match(parser), obj = {}; labels.forEach(function(label, i) { obj[label] = parsed[i] }); return obj; } var template = _.template($("#"+countdownBox.attr("data-countdown-box")).html()), currentDate = '00:00:00:00:00', nextDate = '00:00:00:00:00'; // Build the layout var initData = strfobj(currentDate); labels.forEach(function(label, i) { countdownBox.append(template({ current: initData[label], next: initData[label], label: label })); }); // Starts the countdown countdownBox.countdown(new Date($(this).attr("data-countdown-time")), function(event) { window.c = event; var newDate = event.strftime('%m:%n:%H:%M:%S'), data; if (newDate !== nextDate) { currentDate = nextDate; nextDate = newDate; // Setup the data data = { 'current': strfobj(currentDate), 'next': strfobj(nextDate) }; // Apply the new values to each node that changed diff(data.current, data.next).forEach(function(label) { var selector = '.%s'.replace(/%s/, label), node = countdownBox.find(selector); // Update the node node.removeClass('flip'); node.find('.box-current .number').text(data.current[label]); node.find('.box-next .number').text(data.next[label]); // Wait for a repaint to then flip _.delay(function(node) { node.addClass('flip'); }, 50, node); }); } }); }); } /* ## Cover box */ function handleCoverBox(){ $('[data-norebro-cover-box]').each(function(){ var box = $(this), items = $(this).find('[data-item]'), triggers = $(this).find('[data-trigger]'); var selected = -1; var openItem = function(num){ var item = items.eq(num); if( selected != num && !Nor.isMobile ){ selected = num; item.addClass('no-transition'); item.css('width', ''); var width = item.outerWidth(); item.css('width', '0'); setTimeout(function(){ item.removeClass('no-transition'); items.css('width', '0'); item.css('width', (width - 2) + 'px'); }, 30); } }; triggers.on('mouseenter', function(){ openItem( triggers.index( $(this) ) ); }); openItem(0); }); } function handleCoverBoxSize(){ $('[data-norebro-cover-box]').each(function(){ var box = $(this); box.find('[data-item]').each(function(i){ if( !Nor.isMobile ){ $(this).css('height', box.find('[data-trigger]').eq(i).outerHeight() + 'px'); $(this).find(' > * ').css('width', box.find('[data-trigger]').eq(i).outerWidth() + 'px'); } else { $(this).css({ 'height': '', 'width': '' }); } }); }); } /* ## Gallery */ function handleGallery(){ $('[data-gallery]').each(function(){ var gallery = $(this); // Move galleries popup to footer var oldPopup = $('#' + $(this).attr('data-gallery')); var popup = oldPopup.clone(); $('body').append( popup ); oldPopup.remove(); var popup = popup[0]; popup.options = JSON.parse( $(popup).attr('data-options') ); popup.expanded = false; popup.opened = false; popup.currentItem = 0; var expand = function(){ if( popup.expanded ){ document.webkitCancelFullScreen(); $(this).find('span').addClass('ion-android-expand').removeClass('ion-android-contract'); popup.expanded = false; } else { popup.expanded = true; popup.webkitRequestFullscreen(); $(this).find('span').removeClass('ion-android-expand').addClass('ion-android-contract'); } }; var close = function(){ if( popup.opened ){ popup.opened = false; $(popup).removeClass('open'); var oldImage = $(popup).find('img.gimg').eq( popup.currentItem ); var img = oldImage.clone().addClass('gallery-tmpimage active').css({ 'margin-left': '-' + oldImage.width()/2 + 'px', 'height': oldImage.height() + 'px', 'top': (oldImage.offset().top - $(popup).offset().top) + 'px' }); $(document.body).append(img); setTimeout(function(){ var newImage = gallery.find('img.gimg').eq( popup.currentItem ); img.css({ 'left': newImage.offset().left + 'px', 'margin-left': '', 'height': newImage.height() + 'px', 'top': newImage.offset().top - $(window).scrollTop() + 'px', }); }, 50); setTimeout(function(){ $(popup).find('.slider').remove(); img.remove(); }, 400); if( popup.expanded ){ expand.call( $(popup).find('.expand') ); } } }; $(popup).find('.expand').on('click', expand); $(popup).find('.close').on('click', close); $(window).on('keydown', function(e){ var key = e.which || e.keyCode || e.keyChar; if( key == 27 ){ close(); } if( key == 37 ){ $(popup).find('.slider').trigger('prev.owl.carousel'); } if( key == 39 ){ $(popup).find('.slider').trigger('next.owl.carousel'); } }); }); // Open popup $('body').on('click', '[data-gallery-item]', function(){ var gallery = $(this).closest('[data-gallery]'), popup = $('#' + gallery.attr('data-gallery') ), images = gallery.find('.gallery-image'), options = popup[0].options; var _this = $(this); var image = $(this).find('img.gimg').eq(0); // Create slider var slider = $(document.createElement('div')).addClass('slider'); popup[0].currentItem = 0; popup.append(slider); // Clone image for move var cloneImg = image.clone().css({ 'height': image.outerHeight()+'px', 'top': image.offset().top - $(window).scrollTop(), 'left': image.offset().left, }).addClass('gallery-tmpimage'); $(document.body).append(cloneImg); popup[0].opened = true; popup.addClass('open'); // Generated slider images.each(function(){ var div = $(document.createElement('div')); div.append( $(document.createElement('div')).addClass('image-wrap').append($(this).find('img.gimg').eq(0).clone()) ); if($(this).find('.gallery-description').length){ var description = $(this).find('.gallery-description').clone(); div.append( description ).addClass('with-description'); if( $(window).width() > 787 ){ setTimeout(function(){ div.find('.image-wrap').css('height', 'calc(100% - ' + (description.outerHeight() - 5) + 'px)') }, 10); } } slider.append(div); }); slider.owlCarousel({ items: 1, autoHeight: true, slideBy: 1, nav: true, navText: [ '', '' ], navContainerClass: 'owl-nav slider-nav', navClass: ['owl-prev ' + options.navClass, 'owl-next ' + options.navClass], dots: false, loop: false, autoplay: false, navSpeed: 600, }).on('changed.owl.carousel', function(event) { popup[0].currentItem = event.item.index; slider.find('.thumbs img').removeClass('active'); slider.find('.thumbs img').eq( popup[0].currentItem ).addClass('active'); }); slider.trigger('to.owl.carousel', [parseInt($(this).attr('data-gallery-item')), 50, true]); // Generate thumbnails slider.find('.owl-nav').after(''); var thumbnails = slider.find('.thumbs'); images.each(function(index){ thumbnails.append($(this).find('img.gimg').eq(0).clone().on('click', function(){ $(this).parent().find('img').removeClass('active'); $(this).addClass('active'); slider.trigger('to.owl.carousel', [index, 300, true]); })); }); slider.find('.thumbs img').eq(parseInt($(this).attr('data-gallery-item'))).addClass('active'); // Move tmp image setTimeout(function(){ var sliderImg = slider.find('img.gimg').eq(parseInt(_this.attr('data-gallery-item'))); cloneImg.css({ 'height': sliderImg.outerHeight() + 'px', 'top': (sliderImg.offset().top - popup.offset().top) + 'px', 'left': '', 'margin-left': '-' + (sliderImg.outerWidth() / 2) + 'px' }).addClass('active'); // Open slider, remove tmp image setTimeout(function(){ slider.css('visibility', 'visible'); slider.find('.thumbs img').each(function(i){ var img = $(this); setTimeout(function(){ img.addClass('showed'); }, 50 * i ); }); setTimeout(function(){ cloneImg.remove(); }, 250); }, 300); }, 50); }); } /* ## Google Maps */ function handleGoogleMaps() { if ( typeof google != 'undefined' && google.maps != undefined ) { var googleMapStyles = { default: [{'featureType':'water','elementType':'geometry','stylers':[{'color':'#e9e9e9'},{'lightness':17}]},{'featureType':'landscape','elementType':'geometry','stylers':[{'color':'#f5f5f5'},{'lightness':20}]},{'featureType':'road.highway','elementType':'geometry.fill','stylers':[{'color':'#ffffff'},{'lightness':17}]},{'featureType':'road.highway','elementType':'geometry.stroke','stylers':[{'color':'#ffffff'},{'lightness':29},{'weight':0.2}]},{'featureType':'road.arterial','elementType':'geometry','stylers':[{'color':'#ffffff'},{'lightness':18}]},{'featureType':'road.local','elementType':'geometry','stylers':[{'color':'#ffffff'},{'lightness':16}]},{'featureType':'poi','elementType':'geometry','stylers':[{'color':'#f5f5f5'},{'lightness':21}]},{'featureType':'poi.park','elementType':'geometry','stylers':[{'color':'#dedede'},{'lightness':21}]},{'elementType':'labels.text.stroke','stylers':[{'visibility':'on'},{'color':'#ffffff'},{'lightness':16}]},{'elementType':'labels.text.fill','stylers':[{'saturation':36},{'color':'#333333'},{'lightness':40}]},{'elementType':'labels.icon','stylers':[{'visibility':'off'}]},{'featureType':'transit','elementType':'geometry','stylers':[{'color':'#f2f2f2'},{'lightness':19}]},{'featureType':'administrative','elementType':'geometry.fill','stylers':[{'color':'#fefefe'},{'lightness':20}]},{'featureType':'administrative','elementType':'geometry.stroke','stylers':[{'color':'#fefefe'},{'lightness':17},{'weight':1.2}]}], light_dream: [{"featureType":"landscape","stylers":[{"hue":"#FFBB00"},{"saturation":43.400000000000006},{"lightness":37.599999999999994},{"gamma":1}]},{"featureType":"road.highway","stylers":[{"hue":"#FFC200"},{"saturation":-61.8},{"lightness":45.599999999999994},{"gamma":1}]},{"featureType":"road.arterial","stylers":[{"hue":"#FF0300"},{"saturation":-100},{"lightness":51.19999999999999},{"gamma":1}]},{"featureType":"road.local","stylers":[{"hue":"#FF0300"},{"saturation":-100},{"lightness":52},{"gamma":1}]},{"featureType":"water","stylers":[{"hue":"#0078FF"},{"saturation":-13.200000000000003},{"lightness":2.4000000000000057},{"gamma":1}]},{"featureType":"poi","stylers":[{"hue":"#00FF6A"},{"saturation":-1.0989010989011234},{"lightness":11.200000000000017},{"gamma":1}]}], shades_of_grey: [{"featureType":"all","elementType":"labels.text.fill","stylers":[{"saturation":36},{"color":"#000000"},{"lightness":40}]},{"featureType":"all","elementType":"labels.text.stroke","stylers":[{"visibility":"on"},{"color":"#000000"},{"lightness":16}]},{"featureType":"all","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"administrative","elementType":"geometry.fill","stylers":[{"color":"#000000"},{"lightness":20}]},{"featureType":"administrative","elementType":"geometry.stroke","stylers":[{"color":"#000000"},{"lightness":17},{"weight":1.2}]},{"featureType":"landscape","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":20}]},{"featureType":"poi","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":21}]},{"featureType":"road.highway","elementType":"geometry.fill","stylers":[{"color":"#000000"},{"lightness":17}]},{"featureType":"road.highway","elementType":"geometry.stroke","stylers":[{"color":"#000000"},{"lightness":29},{"weight":0.2}]},{"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":18}]},{"featureType":"road.local","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":16}]},{"featureType":"transit","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":19}]},{"featureType":"water","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":17}]}], paper: [{"featureType":"administrative","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"landscape","elementType":"all","stylers":[{"visibility":"simplified"},{"hue":"#0066ff"},{"saturation":74},{"lightness":100}]},{"featureType":"poi","elementType":"all","stylers":[{"visibility":"simplified"}]},{"featureType":"road","elementType":"all","stylers":[{"visibility":"simplified"}]},{"featureType":"road.highway","elementType":"all","stylers":[{"visibility":"off"},{"weight":0.6},{"saturation":-85},{"lightness":61}]},{"featureType":"road.highway","elementType":"geometry","stylers":[{"visibility":"on"}]},{"featureType":"road.arterial","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"road.local","elementType":"all","stylers":[{"visibility":"on"}]},{"featureType":"transit","elementType":"all","stylers":[{"visibility":"simplified"}]},{"featureType":"water","elementType":"all","stylers":[{"visibility":"simplified"},{"color":"#5f94ff"},{"lightness":26},{"gamma":5.86}]}], light_monochrome: [{"featureType":"administrative.locality","elementType":"all","stylers":[{"hue":"#2c2e33"},{"saturation":7},{"lightness":19},{"visibility":"on"}]},{"featureType":"landscape","elementType":"all","stylers":[{"hue":"#ffffff"},{"saturation":-100},{"lightness":100},{"visibility":"simplified"}]},{"featureType":"poi","elementType":"all","stylers":[{"hue":"#ffffff"},{"saturation":-100},{"lightness":100},{"visibility":"off"}]},{"featureType":"road","elementType":"geometry","stylers":[{"hue":"#bbc0c4"},{"saturation":-93},{"lightness":31},{"visibility":"simplified"}]},{"featureType":"road","elementType":"labels","stylers":[{"hue":"#bbc0c4"},{"saturation":-93},{"lightness":31},{"visibility":"on"}]},{"featureType":"road.arterial","elementType":"labels","stylers":[{"hue":"#bbc0c4"},{"saturation":-93},{"lightness":-2},{"visibility":"simplified"}]},{"featureType":"road.local","elementType":"geometry","stylers":[{"hue":"#e9ebed"},{"saturation":-90},{"lightness":-8},{"visibility":"simplified"}]},{"featureType":"transit","elementType":"all","stylers":[{"hue":"#e9ebed"},{"saturation":10},{"lightness":69},{"visibility":"on"}]},{"featureType":"water","elementType":"all","stylers":[{"hue":"#e9ebed"},{"saturation":-78},{"lightness":67},{"visibility":"simplified"}]}], lunar_landscape: [{"stylers":[{"hue":"#ff1a00"},{"invert_lightness":true},{"saturation":-100},{"lightness":33},{"gamma":0.5}]},{"featureType":"water","elementType":"geometry","stylers":[{"color":"#2D333C"}]}], routexl: [{"featureType":"administrative","elementType":"all","stylers":[{"visibility":"on"},{"saturation":-100},{"lightness":20}]},{"featureType":"road","elementType":"all","stylers":[{"visibility":"on"},{"saturation":-100},{"lightness":40}]},{"featureType":"water","elementType":"all","stylers":[{"visibility":"on"},{"saturation":-10},{"lightness":30}]},{"featureType":"landscape.man_made","elementType":"all","stylers":[{"visibility":"simplified"},{"saturation":-60},{"lightness":10}]},{"featureType":"landscape.natural","elementType":"all","stylers":[{"visibility":"simplified"},{"saturation":-60},{"lightness":60}]},{"featureType":"poi","elementType":"all","stylers":[{"visibility":"off"},{"saturation":-100},{"lightness":60}]},{"featureType":"transit","elementType":"all","stylers":[{"visibility":"off"},{"saturation":-100},{"lightness":60}]}], flat_pale: [{"featureType":"administrative","elementType":"labels.text.fill","stylers":[{"color":"#6195a0"}]},{"featureType":"administrative.province","elementType":"geometry.stroke","stylers":[{"visibility":"off"}]},{"featureType":"landscape","elementType":"geometry","stylers":[{"lightness":"0"},{"saturation":"0"},{"color":"#f5f5f2"},{"gamma":"1"}]},{"featureType":"landscape.man_made","elementType":"all","stylers":[{"lightness":"-3"},{"gamma":"1.00"}]},{"featureType":"landscape.natural.terrain","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"poi","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"poi.park","elementType":"geometry.fill","stylers":[{"color":"#bae5ce"},{"visibility":"on"}]},{"featureType":"road","elementType":"all","stylers":[{"saturation":-100},{"lightness":45},{"visibility":"simplified"}]},{"featureType":"road.highway","elementType":"all","stylers":[{"visibility":"simplified"}]},{"featureType":"road.highway","elementType":"geometry.fill","stylers":[{"color":"#fac9a9"},{"visibility":"simplified"}]},{"featureType":"road.highway","elementType":"labels.text","stylers":[{"color":"#4e4e4e"}]},{"featureType":"road.arterial","elementType":"labels.text.fill","stylers":[{"color":"#787878"}]},{"featureType":"road.arterial","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"transit","elementType":"all","stylers":[{"visibility":"simplified"}]},{"featureType":"transit.station.airport","elementType":"labels.icon","stylers":[{"hue":"#0a00ff"},{"saturation":"-77"},{"gamma":"0.57"},{"lightness":"0"}]},{"featureType":"transit.station.rail","elementType":"labels.text.fill","stylers":[{"color":"#43321e"}]},{"featureType":"transit.station.rail","elementType":"labels.icon","stylers":[{"hue":"#ff6c00"},{"lightness":"4"},{"gamma":"0.75"},{"saturation":"-68"}]},{"featureType":"water","elementType":"all","stylers":[{"color":"#eaf6f8"},{"visibility":"on"}]},{"featureType":"water","elementType":"geometry.fill","stylers":[{"color":"#c7eced"}]},{"featureType":"water","elementType":"labels.text.fill","stylers":[{"lightness":"-49"},{"saturation":"-53"},{"gamma":"0.79"}]}], flat_design: [{"featureType":"all","elementType":"labels","stylers":[{"visibility":"off"}]},{"featureType":"administrative","elementType":"all","stylers":[{"visibility":"simplified"},{"color":"#5b6571"},{"lightness":"35"}]},{"featureType":"administrative.neighborhood","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"landscape","elementType":"all","stylers":[{"visibility":"on"},{"color":"#f3f4f4"}]},{"featureType":"landscape.man_made","elementType":"geometry","stylers":[{"weight":0.9},{"visibility":"off"}]},{"featureType":"poi.park","elementType":"geometry.fill","stylers":[{"visibility":"on"},{"color":"#83cead"}]},{"featureType":"road","elementType":"all","stylers":[{"visibility":"on"},{"color":"#ffffff"}]},{"featureType":"road","elementType":"labels","stylers":[{"visibility":"off"}]},{"featureType":"road.highway","elementType":"all","stylers":[{"visibility":"on"},{"color":"#fee379"}]},{"featureType":"road.highway","elementType":"geometry","stylers":[{"visibility":"on"}]},{"featureType":"road.highway","elementType":"labels","stylers":[{"visibility":"off"}]},{"featureType":"road.highway","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"road.highway.controlled_access","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"road.arterial","elementType":"all","stylers":[{"visibility":"simplified"},{"color":"#ffffff"}]},{"featureType":"road.arterial","elementType":"labels","stylers":[{"visibility":"off"}]},{"featureType":"road.arterial","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"water","elementType":"all","stylers":[{"visibility":"on"},{"color":"#7fc8ed"}]}] }; var geocoder = new google.maps.Geocoder(); var googleMapCreateMarker = function( map, addr, icon ) { geocoder.geocode( { 'address': addr }, function(result, status) { map.setCenter(result[0].geometry.location ); var marker = new google.maps.Marker({ map: map, icon: icon, position: result[0].geometry.location }); }); }; $('[data-google-map]').each( function(){ var markerLocations = $(this).find('[data-google-map-markers]').html().replace(/<.+?\/>/g, '').split( '\n' ); var zoomEnable = false; if ( $(this).attr( 'data-google-map-zoom-enable' ) != undefined ) { zoomEnable = true; } var map_style = googleMapStyles['default']; if ( $(this).attr( 'data-google-map-custom-style') != undefined ){ try { map_style = JSON.parse( $(this).attr('data-google-map-custom-style') ); window.kek = map_style; } catch(e) { console.log('Error: parse json in custom google maps styles.'); map_style = googleMapStyles['default']; } } else if ( $(this).attr( 'data-google-map-style' ) != undefined ) { map_style = googleMapStyles[ $(this).attr( 'data-google-map-style' ) ]; } var map = new google.maps.Map( $(this).find('.google-maps-wrap')[0], { scrollwheel: false, zoom: parseInt( $(this).attr( 'data-google-map-zoom' ) ), zoomControl: zoomEnable, styles: map_style, }); if ( markerLocations == '' || markerLocations == 'true' ) { markerLocations = ['New York']; } for(var i = 0; i < markerLocations.length; i++) { googleMapCreateMarker( map, markerLocations[i], $(this).attr( 'data-google-map-marker' ) ); } }); } } /* ## Onepage */ function handleOnepage(){ $.fn.norebroOnepage = function(options){ var onepage = $(this), stage = onepage.find(' > .onepage-stage'), items = $(this).find('.onepage-section'), isHorizontal = onepage.hasClass('horizontal'), anchors = null, // Dots itemNow = 0, scrollEnabled = true, // For pause during animation speed = options.speed || 500, disableOnMobile = onepage.hasClass('disable-on-mobile'); stage.css('transition', 'transform ' + (speed/1000) + 's ease-in-out'); items.eq(0).addClass('active'); var divNav = $('#mega-menu-wrap ul li, #masthead .menu-other > li > a'); // Transitions to section var moveTo = function(i){ if( Nor.isMobile && disableOnMobile ){ return false; } itemNow = i; if( i < 0 ){ itemNow = 0; } if( i > items.length - 1 ){ itemNow = items.length - 1; } if( anchors ){ anchors.removeClass('active'); anchors.eq(itemNow).addClass('active'); } var isPrev = items.eq(itemNow).hasClass('prev'); items.removeClass('active active-prev prev'); items.eq(itemNow).addClass('active'); items.eq(itemNow-1).addClass('prev'); if( isPrev ){ items.eq(itemNow).addClass('active-prev'); } scrollEnabled = false; if( options.vertical ){ stage.css('transform', 'translate3d(-' + (onepage.outerWidth() * itemNow) + 'px, 0, 0)'); } else { stage.css('transform', 'translate3d(0, -' + (onepage.outerHeight() * itemNow) + 'px, 0)'); } var paginationColor = items.eq( itemNow ).attr('data-pagination-color'); var menuColor = items.eq( itemNow ).attr('data-header-nav-color'); var logoType = items.eq( itemNow ).attr('data-header-logo-type'); var top = onepage.offset().top - ( $(window).height() - onepage.outerHeight() ) / 2; var scrollTop = $(document).scrollTop(); if( top != 0 ) { var correctPosition = ( top + top > scrollTop && top - top * 2 < scrollTop ); } else { var correctPosition = ( top + 10 > scrollTop && top - 10 < scrollTop ); } onepage.find('.onepage-dots li').css( 'color', ( paginationColor ) ? paginationColor : '' ); if( correctPosition ){ divNav.css( 'color', menuColor ? menuColor : '' ); Nor.logoForOnepageLight.addClass('hidden'); Nor.logoForOnepageDark.addClass('hidden'); if( logoType ){ $([Nor.logo[0], Nor.fixedLogo[0]]).css({ 'position': 'absolute', 'width': '0px', 'height': '0px', 'overflow': 'hidden' }); if( logoType == 'dark' ){ Nor.logoForOnepageDark.removeClass('hidden'); } if( logoType == 'light' ){ Nor.logoForOnepageLight.removeClass('hidden'); } } else { $([Nor.logo[0], Nor.fixedLogo[0]]).css({ 'position': '', 'width': '', 'height': '', 'overflow': '' }); } } setTimeout(function(){ scrollEnabled = true; }, 1000); }; var moveUp = function(){ moveTo( itemNow - 1 ); } var moveDown = function(){ moveTo( itemNow + 1 ); } // Transition by y var move = function(y, e){ if( !( Nor.isMobile && disableOnMobile ) ){ var top = onepage.offset().top - ( $(window).height() - onepage.outerHeight() ) / 2; var scrollTop = $(document).scrollTop(); var correctPosition = ( top + 100 > scrollTop && top - 100 < scrollTop ); if( ( y > 0 && itemNow < items.length - 1) || (y < 0 && itemNow > 0) ){ if( !correctPosition ){ setTimeout(function(){ $('html, body').animate({ scrollTop: top }, 400); }, 100); var menuColor = items.eq( itemNow ).attr('data-header-nav-color'); divNav.css( 'color', menuColor ? menuColor : '' ); } } if( y > 0 && itemNow < items.length - 1 ){ if( scrollEnabled && correctPosition ) moveDown(); e.preventDefault(); } else if( y < 0 && itemNow > 0 ){ if( scrollEnabled && correctPosition ) moveUp(); e.preventDefault(); } else if( !scrollEnabled || (y < 1 && y > -1) ){ e.preventDefault(); } else { $('html, body').stop(true, true).finish(); divNav.css('color', ''); $([Nor.logo[0], Nor.fixedLogo[0]]).css({ 'position': '', 'width': '', 'height': '', 'overflow': '' }); Nor.logoForOnepageLight.addClass('hidden'); Nor.logoForOnepageDark.addClass('hidden'); } if( AOS ){ setTimeout( AOS.refresh, 400 ); } } }; // Mouse events if( options.mousewheel ){ onepage.on('wheel mousewheel', function(e){ var y = e.originalEvent.deltaY; move( y, e ); }); } // Keyboard events onepage.on('keydown', function(e){ var key = e.which || e.keyCode; if( key == 38 ){ move( -1, e ); } else if( key == 40 ){ move( 1, e ); } }); // Tach events var oldTachY = 0; onepage.on('touchstart', function(e){ var y = e.originalEvent.touches[0].clientY, x = e.originalEvent.touches[0].clientX; if( isHorizontal ){ oldTachY = x; } else { oldTachY = y; } }); onepage.on('touchmove', function(e){ var y = e.originalEvent.touches[0].clientY, x = e.originalEvent.touches[0].clientX; var moveS; if( isHorizontal ){ moveS = oldTachY - x; oldTachY = x; } else { moveS = oldTachY - y; oldTachY = y; } move( moveS, e ); }); onepage[0].resize = function(){ if( Nor.isMobile && disableOnMobile ){ items.css({ 'width': '', 'height': '' }); stage.css('transform', 'none'); } else { items.each(function(){ if( options.vertical ){ $(this).css('width', onepage.outerWidth() + 'px'); if ( $(this).offset().top != 0 ) { $(this).css('height', onepage.outerHeight() - $(this).offset().top + 1 + 'px').addClass('not-full'); } else { $(this).css('height', onepage.outerHeight() + 'px'); } } else { $(this).css('height', onepage.outerHeight() + 'px'); } }); } moveTo( itemNow ); }; /*# Create navigations #*/ // Append dots if( options.dots ){ var ul = $(document.createElement('ul')).addClass('onepage-dots'); if( options.dotsClass ){ ul.addClass( options.dotsClass ); } items.each(function(i){ var li = $(document.createElement('li')); if( options.dotClass ){ li.addClass( options.dotClass ); } li.on('click', function(){ moveTo( i ); }); ul.append( li ); $(this).css('height', onepage.outerHeight() + 'px'); }); onepage.append( ul ); anchors = ul.find('li'); anchors.eq(0).addClass('active'); } // Append nav button if( options.nav ){ var nav = $(document.createElement('div')).addClass('onepage-nav'); if( options.navContainerClass ){ nav.addClass( options.navContainerClass ); } var up = $(document.createElement('div')).addClass('move-up'); var down = $(document.createElement('div')).addClass('move-down'); var icon = $(document.createElement('span')); if( options.navClass ){ up.addClass( options.navClass[0] ); down.addClass( options.navClass[1] ); } up.append( icon.clone().addClass( (options.navIcons) ? options.navIcons[0] : 'ion-ios-arrow-thin-up' ) ); down.append( icon.clone().addClass( (options.navIcons) ? options.navIcons[1] : 'ion-ios-arrow-thin-down' ) ); up.on('click', function(){ moveUp(); }); down.on('click', function(){ moveDown(); }); nav.append( up, down ); onepage.append( nav ); } var countSlides = items.length; if( countSlides < 10 ){ countSlides = '0' + countSlides; } onepage.find('[data-onepage-counter]').each(function(i){ var num = i + 1; if( num < 10 ) { num = '0' + num; } $(this).html( num +'/' + countSlides ); }); }; $('[data-norebro-onepage]').each(function(){ var data = $(this).attr('data-options'); var options = ( data ) ? JSON.parse( data ) : {}; $(this).norebroOnepage( options ); }); } function handleOnepageSize(){ $('[data-norebro-onepage]').each(function(){ this.resize(); }); } /* ## Parallax */ function initParallax(){ $('[data-parallax-bg]').each( function(){ var bg = $(this).find('.parallax-bg'); var speed = $(this).attr( 'data-parallax-speed' ); if( $(this).attr('data-parallax-bg') == 'vertical' ){ $(this).find('.parallax-bg').css( { height: ( $(this).outerHeight() + speed * 200 ) + 'px' }); } else { $(this).find('.parallax-bg').css( { width: ( $(this).outerWidth() + speed * 200 ) + 'px' }); } bg.addClass( ( $(this).attr('data-parallax-bg') == 'vertical' ) ? '' : 'horizontal' ); }); }; function handleParallax() { var contentScroll = $(document).scrollTop(); var wndHeight = $(window).height(); $('[data-parallax-bg]').each( function(){ var parallaxTop = $(this).offset().top; var parallaxHeight = $(this).outerHeight(); var parallaxWidth = $(this).outerWidth(); // If parallax block on screen if( parallaxTop <= contentScroll + wndHeight && parallaxTop + parallaxHeight >= contentScroll ){ var speed = parseFloat( $(this).attr( 'data-parallax-speed' ) ) * 100; var bg = $(this).find('.parallax-bg'); var percent = (-parallaxTop + contentScroll + wndHeight) / (parallaxHeight + wndHeight); var offset = -(percent * 2) * speed; if( $(this).attr('data-parallax-bg') == 'vertical' ){ bg.css( 'transform', 'translate3d(0, ' + offset + 'px, 0)' ); } else { bg.css( 'transform', 'translate3d(' + offset + 'px, 0, 0)' ); } } }); }; /* ## Progress bar */ function handleProgressBar(){ $("[data-norebro-progress-bar]:not([data-processed])").each(function(){ var percent, bar = $(this), line = bar.find('.line'), progressEnd = parseInt( bar.attr("data-norebro-progress-bar") ), withTooltip = bar.find('[data-tooltip]').length; var scrollTop = $(document).scrollTop() + $(window).height(); if( line.length == 0 && bar.hasClass('split') ){ var div = $(document.createElement('div')).addClass('line-split'); div.append( $(document.createElement('div')).addClass('line brand-bg-color') ); for( var i = 0; i < 8; i++ ){ var div = div.clone(); bar.find('.line-wrap').append( div ); div.find('.line').css({ 'left': -(div.offset().left - bar.offset().left) + 'px' }); } if( withTooltip ) { bar.find('.line-wrap').append('