/*global jQuery:false, TweenMax, Back, TweenLite, Quad, google, mapObject, marker, _bw_theme, InfoBox, Quint, Sine*/ window.jQuery = window.$ = jQuery; /*! blank new page* $('body').on('click', 'a[target^=_blank], a[rel^=external], area[target^=_blank]', function(e) { window.open($(this).attr('href')); return false; });*/ var App = { start: function() { App.slider(); App.images(); App.popularWidget(); App.magnificPopup(); if(jQuery('body').hasClass('djax-active')) { App.djax(); } if(jQuery('body').hasClass('image-copyright')) { App.image_copyright(); } App.bind(); App.onLoad(); App.headerNavigation(); App.sidebarScrollBar(); App.alsoLikeCenterText(); }, magnificPopup: function() { $('.mp-item').magnificPopup({ type: 'image', gallery: {enabled: true, preload: true} }); }, images: function() { $('.box').each(function() { var $this = $(this); if($('img', $this).length > 0) { var totalPercent = ( $this.outerHeight() / $this.outerWidth() ) * 100; var marginPix = ( $this.outerHeight() - $('.thumb', $this).outerHeight() ) * 0.5; var absolutePercent = marginPix / $this.outerHeight(); $('.thumb', $this).css('margin-top', (absolutePercent * totalPercent) + '%'); } }); }, slider: function() { var $slider = $('.post-gallery'); if($slider.length > 0) { $slider.each(function() { $(this).owlCarousel({ autoPlay: ($slider.hasClass('auto-play')) ? 3000 : false, stopOnHover:true, paginationSpeed:1000, goToFirstSpeed:2000, singleItem:true, autoHeight: ($slider.hasClass('auto-height')) ? true : false, transitionStyle: ($slider.attr('data-effect') ? $slider.attr('data-effect') : false), lazyLoad:true, navigation: ($slider.hasClass('hide-nav')) ? false : true, navigationText:['',''], }); }); } var $widgetSlider = $('.bw-widget-slider'); if($widgetSlider.length > 0) { $widgetSlider.each(function() { $(this).owlCarousel({ autoPlay: true, stopOnHover:true, navigation:true, pagination:false, paginationSpeed:1000, goToFirstSpeed:2000, singleItem:true, autoHeight: true, transitionStyle: false, navigationText:['',''], }); }); } }, popularWidget: function() { var $tab = jQuery('.bw-polular-widget-holder .bw-sidebar-posts'); var $holder = jQuery('.bw-polular-widget-holder'); var $popularNav = jQuery('.bw-popular-widget-nav a'); $tab.hide(); jQuery('.bw-sidebar-posts:first', $holder).show(0); $popularNav.bind('click', function() { var $this = jQuery(this); var $popularHolder = jQuery(this).closest('.bw-polular-widget-holder'); jQuery('.bw-popular-widget-nav a', $popularHolder).removeClass('active'); $this.addClass('active'); jQuery('.bw-sidebar-posts', $popularHolder).hide(); jQuery('.bw-sidebar-posts.' + $this.attr('data-parent'), $popularHolder).fadeIn(300); }); }, image_copyright: function() { var copyTimer; jQuery(document).on('contextmenu', '#categorizr .nav-holder, #pattern-full, #gallery, .isotope-holder a, #rail a, #journal-list .item img', function(e) { clearTimeout(copyTimer); jQuery('#image-copyright').show().css('top', e.screenY - 90).css('left', e.screenX + 10); copyTimer = setTimeout(function() { jQuery('#image-copyright').fadeOut(150); }, 2000); return false; }); }, onLoad: function() { if(jQuery('#preloader .animation-holder').length) { App.preloaderAction(); var preloaderAnimation = setInterval(function() { App.preloaderAction(); }, 3500); jQuery(window).load(function() { jQuery('#preloader .animation-holder').fadeOut(300, function() { clearInterval(preloaderAnimation); App.preloader(); }); }); }else{ App.preloader(); } }, preloaderAction: function() { jQuery('#preloader span').removeAttr('style'); TweenMax.to(jQuery('#preloader .right'), 0.1, {bottom:0, ease:Linear.easeNone, onComplete:function() { TweenMax.to(jQuery('#preloader .bottom'), 0.1, {delay:0.3, left:0, ease:Linear.easeNone, onComplete: function() { TweenMax.to(jQuery('#preloader .left'), 0.15, {delay:0.3, top:0, ease:Linear.easeNone, onComplete: function() { TweenMax.to(jQuery('#preloader .top'), 0.15, {delay:0.3, right:0, ease:Linear.easeNone}); }}); }}); }}); TweenMax.to(jQuery('#preloader .right'), 0.1, {delay:1.8,top:'100%', ease:Linear.easeNone, onComplete:function() { TweenMax.to(jQuery('#preloader .bottom'), 0.1, {delay:0.3, right:'100%', ease:Linear.easeNone, onComplete: function() { TweenMax.to(jQuery('#preloader .left'), 0.15, {delay:0.3, bottom:'100%', ease:Linear.easeNone, onComplete: function() { TweenMax.to(jQuery('#preloader .top'), 0.15, {delay:0.3, left:'100%', ease:Linear.easeNone}); }}); }}); }}); }, preloader: function() { jQuery('#preloader').css({ 'top' : 65, 'bottom' : 65, 'left' : 65, 'right' : 65, }); setTimeout(function() { App.playAnimations('in'); jQuery('#preloader').addClass('ghost').fadeOut(1000, function() { jQuery(this).remove(); }); setTimeout(function() { jQuery('body').removeClass('init'); }, 450); }, 300); }, bind: function() { // disable empty url\'s jQuery(document).on('click', 'a[href="#"]', function(e) { e.preventDefault(); }); jQuery('#navigation-mobile ul a').bind('click', function() { jQuery('#navigation-mobile').toggleClass('open'); }); // toggle mobile navigation jQuery(document).on('click', '#toggle-nav, #navigation-mobile .mobile-close', function() { jQuery('#navigation-mobile').toggleClass('open'); }); // toggle sidebar jQuery(document).on('click', '#toggle-sidebar', function() { jQuery('#sidebar').toggleClass('open'); jQuery('#toggle-sidebar').toggleClass('open'); }); // journal hover effects jQuery(document).on('mouseover', '.bw-also-like .image', function() { var $element = jQuery(this),$img = $element.find('img'); TweenLite.to($img, 0.4, {scale: 1.13, ease:Back.easeOut}); TweenLite.to(jQuery('.pluss', $element), 0.3, {alpha: 1}); TweenLite.to(jQuery('.horr', $element), 0.3, {width: 32, marginLeft:-15, ease:Back.easeOut}); TweenLite.to(jQuery('.verr', $element), 0.3, {height: 32, marginTop:-15, ease:Back.easeOut}); }).on('mouseout', '.bw-also-like .like-item', function() { var $element = jQuery(this),$img = $element.find('img'); TweenLite.to($img, 0.4, {scale: 1, ease:Quad.easeOut}); TweenLite.to(jQuery('.pluss', $element), 0.3, {alpha: 0}); TweenLite.to(jQuery('.horr', $element), 0.3, {width: 0, marginLeft:0}); TweenLite.to(jQuery('.verr', $element), 0.3, {height: 0, marginTop:0}); }); // quick view hover jQuery(document).on('mouseenter', '#categorizr .quick-view-gallery a', function() { var $element = jQuery(this); TweenLite.to(jQuery('.img', $element), 0.4, {scale: 1.13, ease:Back.easeOut}); TweenLite.to(jQuery('.overr', $element), 0.3, {alpha: 0.6}); TweenLite.to(jQuery('.pluss', $element), 0.3, {alpha: 1}); TweenLite.to(jQuery('.horr', $element), 0.3, {width: 22, marginLeft:-10, ease:Back.easeOut}); TweenLite.to(jQuery('.verr', $element), 0.3, {height: 22, marginTop:-10, ease:Back.easeOut}); }).on('mouseout', '#categorizr .quick-view-gallery a', function() { var $element = jQuery(this); TweenLite.to(jQuery('.img', $element), 0.4, {scale: 1, ease:Quad.easeOut}); TweenLite.to(jQuery('.overr', $element), 0.3, {alpha: 0}); TweenLite.to(jQuery('.pluss', $element), 0.3, {alpha: 0}); TweenLite.to(jQuery('.horr', $element), 0.3, {width: 0, marginLeft:0}); TweenLite.to(jQuery('.verr', $element), 0.3, {height: 0, marginTop:0}); }); // isotope element hover jQuery(document).on('mouseenter', '.isotope .isotope-item .element, .rail-content .item > a', function() { var $element = jQuery(this), $elementParent = $element.closest('.isotope-item, .item'); $elementParent.addClass('overflow'); TweenLite.to($element, 0.4, {scale: 1.13, ease:Back.easeOut}); TweenLite.to(jQuery('.over', $element), 0.3, {alpha: 0.6}); TweenLite.to(jQuery('.plus', $elementParent), 0.3, {alpha: 1}); TweenLite.to(jQuery('.hor', $elementParent), 0.3, {width: 52, marginLeft:-25, ease:Back.easeOut}); TweenLite.to(jQuery('.ver', $elementParent), 0.3, {height: 52, marginTop:-25, ease:Back.easeOut}); }).on('mouseout', '.isotope .isotope-item .element, .rail-content .item > a', function() { var $elementParent = jQuery(this).closest('.isotope-item, .item'); TweenLite.to(jQuery(this), 0.4, {scale: 1, ease:Quad.easeOut}); TweenLite.to(jQuery('.over', this), 0.3, {alpha: 0}); TweenLite.to(jQuery('.plus', $elementParent), 0.3, {alpha: 0}); TweenLite.to(jQuery('.hor', $elementParent), 0.3, {width: 0, marginLeft:0}); TweenLite.to(jQuery('.ver', $elementParent), 0.3, {height: 0, marginTop:0}); }); // disable empty url\'s jQuery(document).on('click', 'a[href*="#"]', function(e) { e.preventDefault(); }); // full background toggle jQuery(document).on('click', '.full-toggle.expand', function() { if(!jQuery(this).hasClass('animate')) { jQuery(this).addClass('animate'); jQuery('i', this).toggleClass('fa-arrows-alt fa-compress'); jQuery('#gallery .full-overlay').toggleClass('black'); setTimeout(function() { jQuery('body').toggleClass('cover'); //jQuery('#header, #footer').toggleClass('hidden'); }, 300); setTimeout(function() { jQuery('#gallery .full').resizeToParent({parent: '#gallery'}); jQuery('#gallery .full-overlay').toggleClass('black'); jQuery('#gallery .full-toggle').removeClass('animate'); }, 700); } }); // share addthis buttons jQuery(document).on('mouseenter', '.share-bottom', function() { jQuery('#bw-share').addClass('show'); }).on('mouseleave', '.share-bottom', function() { jQuery('#bw-share').removeClass('show'); }); // info section jQuery(document).on('click', '.full-toggle.info-toggle', function() { jQuery('#gallery').toggleClass('info'); if(jQuery('#gallery').hasClass('info')) { jQuery('#image-buttons').css('bottom', jQuery('.info-content').outerHeight()); }else{ jQuery('#image-buttons').css('bottom', 0); } }); // categorizr menu item mouse enter var mouseHold; jQuery(document).on('mouseenter', '#categorizr .nav a', function() { var $this = jQuery(this); mouseHold = setTimeout(function() { if(!jQuery('#categorizr').hasClass('expanded')) { jQuery('#categorizr .nav a').removeClass('active'); $this.addClass('active'); App.categorizr.change($this); } }, 600); }) .on('mouseleave', '#categorizr .nav a', function() { clearTimeout(mouseHold); }) .on('click', function() { clearTimeout(mouseHold); }); // categorizr quick view jQuery(document).on('click', '#categorizr #quick-view', function(e) { e.preventDefault(); jQuery('#categorizr').toggleClass('expanded'); App.categorizr.show(); }); jQuery('#searchform').submit(function(e) { e.preventDefault(); var searchUrl = jQuery('#searchform').attr('action') + '?s=' + encodeURIComponent(jQuery('#search').val()); jQuery('#search-submit').attr('href', searchUrl).trigger('click'); }); // On djax request jQuery(window).bind('djaxClick', function(e) { e.preventDefault(); App.playAnimations('out'); jQuery('html, body').animate({scrollTop: 0}, 300); }); // djax click jQuery(window).bind('djaxClick', function() { TweenMax.to(jQuery('#header .header-part-right h1'), 0.3, {top:-100, alpha:0, ease:Quad.easeIn}); }); // djax loading jQuery(window).bind('djaxLoading', function() { }); // djax finished jQuery(window).bind('djaxLoad', function() { TweenMax.from(jQuery('#header .header-part-right h1'), 0.3, {top:'auto', bottom:-100, alpha:0, ease:Quad.easeOut}); }); }, alsoLikeCenterText: function() { jQuery('.like-item').each(function() { $e = jQuery('.title', this); $e.css('margin-top', '-' + ($e.height()*0.5) + 'px'); }); }, cleanUpAfterDjax: function() { if(!jQuery('.djax-dynamic > div').hasClass('bw--gallery')) { jQuery('body').removeClass('cover'); } }, sidebarScrollBar: function() { jQuery("#sidebar").mCustomScrollbar({ theme: "dark", scrollInertia:300, autoHideScrollbar: true }); }, headerNavigation: function() { // desktop jQuery('#navigation li').hover(function() { jQuery('ul:first', jQuery(this)).stop(true,true).fadeIn(); }, function() { jQuery('ul', jQuery(this)).stop(true,true).fadeOut(0); }); }, map: function() { var mapContainer = document.getElementById('map'); if (mapContainer !== null) { var btn_zoom_in = document.getElementById('zoomin'); if (btn_zoom_in !== null) { google.maps.event.addDomListener(btn_zoom_in, 'click', function() { mapObject.setZoom(mapObject.getZoom() + 1 ); }); } var btn_zoom_out = document.getElementById('zoomout'); if (btn_zoom_out !== null) { google.maps.event.addDomListener(btn_zoom_out, 'click', function() { mapObject.setZoom(mapObject.getZoom() - 1 ); }); } App.createMap(mapContainer); App.createMarker(); App.createLabel(); } }, createMap: function(mapContainer) { var centerPin; if(jQuery('#map').attr('data-center') !== '') { var pinCenter = jQuery('#map').attr('data-center').split(","); centerPin = new google.maps.LatLng(parseFloat(pinCenter[0]),parseFloat(pinCenter[1])); }else{ centerPin = new google.maps.LatLng(44.53793,13.62262); } var mapOptions = { center: centerPin, zoom: parseFloat(jQuery('#map').attr('data-zoom')), navigationControl: false, mapTypeControl: false, scrollwheel: false, disableDefaultUI: true, disableDoubleClickZoom: true }; mapObject = new google.maps.Map(mapContainer, mapOptions); var mapStyle = [ // map style 1 [{"featureType":"water","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":17}]},{"featureType":"landscape","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":20}]},{"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":"poi","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":21}]},{"elementType":"labels.text.stroke","stylers":[{"visibility":"on"},{"color":"#000000"},{"lightness":16}]},{"elementType":"labels.text.fill","stylers":[{"saturation":36},{"color":"#000000"},{"lightness":40}]},{"elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"transit","elementType":"geometry","stylers":[{"color":"#000000"},{"lightness":19}]},{"featureType":"administrative","elementType":"geometry.fill","stylers":[{"color":"#000000"},{"lightness":20}]},{"featureType":"administrative","elementType":"geometry.stroke","stylers":[{"color":"#000000"},{"lightness":17},{"weight":1.2}]}], // map style 2 [{"featureType":"water","elementType":"all","stylers":[{"hue":"#e9ebed"},{"saturation":-78},{"lightness":67},{"visibility":"simplified"}]},{"featureType":"landscape","elementType":"all","stylers":[{"hue":"#ffffff"},{"saturation":-100},{"lightness":100},{"visibility":"simplified"}]},{"featureType":"road","elementType":"geometry","stylers":[{"hue":"#bbc0c4"},{"saturation":-93},{"lightness":31},{"visibility":"simplified"}]},{"featureType":"poi","elementType":"all","stylers":[{"hue":"#ffffff"},{"saturation":-100},{"lightness":100},{"visibility":"off"}]},{"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":"administrative.locality","elementType":"all","stylers":[{"hue":"#2c2e33"},{"saturation":7},{"lightness":19},{"visibility":"on"}]},{"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"}]}] ]; mapObject.setOptions({styles: mapStyle[0]}); google.maps.event.addListener(mapObject, 'tilesloaded', function() { App.mapLoaded(); }); }, createMarker: function() { var pinImg = jQuery('#map').attr('data-pin-image'), myPin; if(jQuery('#map').attr('data-coordinates') !== '') { var pinCoordinates = jQuery('#map').attr('data-coordinates').split(","); myPin = new google.maps.LatLng(parseFloat(pinCoordinates[0]),parseFloat(pinCoordinates[1])); }else{ myPin = new google.maps.LatLng(44.42752,12.22787); } marker = new google.maps.Marker({ position: myPin, map: mapObject, title: 'Hello World!', icon: new google.maps.MarkerImage((pinImg !== '') ? pinImg : _bw_theme + 'img/pins/pin-1.png') }); }, createLabel: function() { var boxText = document.createElement("div"); boxText.style.cssText = "color:#fff;"; /*jshint multistr: true*/ boxText.innerHTML = "