( function( $ ) { "use strict"; var CL_FRONT = window.CL_FRONT || {}; window.CL_FRONT = CL_FRONT; CL_FRONT.components = CL_FRONT.components || {}; CL_FRONT.helpers = CL_FRONT.helpers || {}; /** * Main Site Init * * @since 1.0.0 */ CL_FRONT.siteInit = function() { "use strict"; this.defaultConfig(); this.bindEvents(); }; /** * Init Default Variables * * @since 1.0.0 */ CL_FRONT.defaultConfig = function() { "use strict"; this.config = { // Load dynamic scripts _loadedDependencies: [], _inQueue: {}, // Default Config $window: $( window ), $document: $( document ), $windowWidth: $( window ).width(), $windowHeight: $( window ).height(), $windowTop: typeof window.pageYOffset != 'undefined' ? window.pageYOffset: document.documentElement.scrollTop? document.documentElement.scrollTop: document.body.scrollTop? document.body.scrollTop:0, $containerWidth: 0, $containerOffsetLeft: 0, $html: $( 'html' ), $body: $( 'body' ), $viewport: $( '#viewport' ), $header: $( '.cl-header' ), $headerTools: $('.cl-header__tools'), $initSliders : {}, $navigation: $( '#navigation' ), $responsiveMenu: null, $content: $( '#content' ), $aside: $( '#secondary' ), $main: $( '#main' ), $pageLayout: 'fullwidth', $headerHeight: 0, $layoutModern: false, $asideTop: 0, $asideHeight: 0, $asideArray: {}, $asideStickyOffset: 0, $isMobileScreen: false, $isTabletScreen: false, $isDesktopScreen: false, $isMobileDevice: false, $isMobileOrTabletDevice: false, $isSmoothScroll: false, $isCustomizer: false, $headerToolsInit: false, $headerToolsList: [], $ilightboxes: {}, $cssInQueue: {}, } }; /** * Bind Events of site * * @since 1.0.0 * @version 1.0.2 */ CL_FRONT.bindEvents = function() { "use strict"; var self = this; // Document Ready self.config.$document.ready( function() { self.updateConfig(); self.loadAsyncIcons(); // Menu self.initMenuDropdown(); self.initToolsDropdown(); self.initMenuResponsive(); self.initToolsResponsive(); self.initHeaderStyles(); self.initHeaderSticky(); // Initialize Post Functionalities self.postInit(); self.animations(); self.isotopeBlogGrid(); self.isotopePortfolioGrid(); self.itemILightBox(); self.nextPrevAjax(); self.filtersAjax(); // Various sizes and positions fixes self.fixModernLayoutWidth(); self.fixCompatibilities(); self.fixMegaMenuPosition(); self.init_cl_page_header(); if( ! self.config.$isCustomizer ) self.codelessSlider(); self.rowParallax(); self.progressBar(); self.mediaElement(); self.codelessGMap(); self.contactForm(); self.codelessToggles(); self.shopBtnClasses(); self.instaFeed(); self.codelessTabs(); self.creativeSearch(); //self.partialRefreshRendered(); self.footerReveal(); self.pageTransition(); self.countdownElement(); self.sideNav(); self.loadOtherLazyload(); self.onePageScroll(); self.scrollToTopButton(); self.scrollableSections(); self.videoPostGallery(); self.paginationInfiniteInitBlocks(); } ); // Window load self.config.$window.on( 'load', function() { self.postInstagram(); self.livePhoto(); self.convertSVGAnimated(); self.rowParallax(); self.shopBtnClasses(); } ); // Window Resize self.config.$window.resize( function() { self.updateDimensions(); self.initMenuResponsive(); self.initToolsResponsive(); self.fixModernLayoutWidth(); self.stickySidebar(); //self.stickyColumn(); self.fixPageHeaderCenter(); self.initHeaderSticky(); } ); // Window Scroll self.config.$window.scroll( function() { self.config.$windowTop = typeof window.pageYOffset != 'undefined' ? window.pageYOffset: document.documentElement.scrollTop? document.documentElement.scrollTop: document.body.scrollTop? document.body.scrollTop:0;; self.stickySidebar(); //self.stickyColumn(); } ); // Window on Orientation Change Tablets self.config.$window.on( 'orientationchange', function() { self.updateDimensions(); self.initMenuResponsive(); self.initToolsResponsive(); self.fixPageHeaderCenter(); self.footerReveal(); } ); self.config.$window.on( 'click', function() { // Close Shares on outside click self.postCloseShares() } ); }; /** * Update Config Dom * * @since 1.0.0 */ CL_FRONT.updateConfig = function() { this.config.$html = $( 'html' ); this.config.$body = $( 'body' ); this.config.$viewport = $( '#viewport' ); this.config.$header = $( '.cl-header' ); this.config.$navigation = $( '.cl-header__navigation' ); this.config.$headerTools = $('.cl-header__tools'); this.config.$content = $( '#content' ); this.config.$aside = $( '#secondary' ); this.config.$asideArray = {}; this.config.$main = $( '#main' ); this.config.$pageLayout = this.config.$content.hasClass( 'cl-layout-left_sidebar' ) ? 'left_sidebar' : this.config.$content.hasClass( 'cl-layout-right_sidebar' ) ? 'right_sidebar' : this.config.$content.hasClass( 'cl-layout-dual' ) ? 'dual_sidebar' : 'fullwidth'; if ( this.config.$content.hasClass( 'cl-layout-modern' ) ) this.config.$layoutModern = true; this.config.$isMobileDevice = this.mobileDeviceCheck(); this.config.$isMobileOrTabletDevice = this.mobileOrTabletDeviceCheck(); this.config.$isSmoothScroll = this.config.$body.hasClass( 'cl-smoothscroll' ) ? true : false; if( $('.cl_counter').length > 0 ) this.preloadOdometer(); this.updateDimensions(); }; /** * Check if page is loaded from mobile * * @since 1.0.0 */ CL_FRONT.mobileDeviceCheck = function() { var check = false; ( function( a ) { if ( /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test( a ) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test( a.substr( 0, 4 ) ) ) check = true; } )( navigator.userAgent || navigator.vendor || window.opera ); return check; } /** * Check if page is loaded from mobile or tablet * * @since 1.0.0 */ CL_FRONT.mobileOrTabletDeviceCheck = function() { var check = false; ( function( a ) { if ( /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test( a ) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test( a.substr( 0, 4 ) ) ) check = true; } )( navigator.userAgent || navigator.vendor || window.opera ); return check; } /** * Update Dimension of page, used on screen resize * * @since 1.0.0 */ CL_FRONT.updateDimensions = function() { this.config.$windowWidth = $( window ).width(); this.config.$windowHeight = $( window ).height(); if ( window.matchMedia ) { this.config.$isMobileScreen = window.matchMedia( '( max-width: 767px )' ).matches; this.config.$isTabletScreen = window.matchMedia( '( min-width: 768px ) and (max-width: 991px)' ).matches; this.config.$isDesktopScreen = window.matchMedia( '( min-width: 992px )' ).matches; } else { this.config.$isMobileScreen = this.config.$windowWidth <= 768; this.config.$isTabletScreen = this.config.$windowWidth > 768 && this.config.$windowWidth <= 991; this.config.$isDesktopScreen = this.config.$windowWidth > 992; } this.config.$containerWidth = this.config.$header.hasClass('header-top') ? this.config.$header.find( '.header-row-inner' ).width() : this.config.$content.find( '.container' ).width(); if( this.config.$header.hasClass('header-top') ){ this.config.$containerOffsetLeft = this.config.$header.find( '.c-left.header-col' ).length > 0 ? this.config.$header.find( '.c-left.header-col' ).offset().left : this.config.$content.find( '.container' ).offset().left - 15; }else this.config.$containerOffsetLeft = 0; var container_offset = this.config.$content.find( '.container' ).length > 0 ? this.config.$content.find( '.container' ).offset().left : 0 this.config.$containerOffsetLeft = this.config.$header.hasClass('header-top') ? this.config.$header.find( '.c-left.header-col' ).offset().left : container_offset - 15; this.config.$headerHeight = this.config.$header.height(); } CL_FRONT.fixCompatibilities = function(){ if( bowser.msie && bowser.version <= 9 ){ CL_FRONT.components.loadDependencies( [ codeless_global.FRONT_LIB_JS + 'jquery.requestAnimationFrame.js'], function(){ }); CL_FRONT.config.$html.addClass('no-cssanimations'); } } /** * Initialize Menu in Responsive * * @since 1.0.0 */ CL_FRONT.initMenuResponsive = function() { "use strict"; var self = this; if( this.config.$windowWidth <= 991 && this.config.$responsiveMenu === null ){ if( this.config.$navigation.closest('.cl-fullscreen-overlay-menu').length == 0 ) this.config.$navigation.addClass('cl-hide-on-mobile'); else{ this.config.$navigation.addClass('cl-header__navigation--vertical').addClass('cl-mobile-menu'); return; } this.config.$responsiveMenu = this.config.$navigation.clone().appendTo(this.config.$header); this.config.$responsiveMenu.removeClass( 'cl-hide-on-mobile' ).addClass( 'cl-mobile-menu' ); if( this.config.$body.hasClass('cl-header-incontainer') ) this.config.$responsiveMenu.addClass('container'); $( '.cl-header__mobile-button' ).on( 'click', function( ){ var button = $(this); button.toggleClass( 'open' ); self.config.$responsiveMenu.slideToggle('200'); CL_FRONT.animations( self.config.$responsiveMenu , true ); } ); $( '.cl-header__menu li.has-submenu > a', this.config.$responsiveMenu ).on( 'click', function( e ){ var li = $(this).parent(); e.preventDefault(); li.toggleClass('open'); li.parent().find('li').not(li).removeClass('open'); li.children( '.sub-menu, .cl-header__menu__megamenu' ).slideToggle('300'); } ); $( '.cl-header__menu .cl-header__menu__megamenu > ul > li.has-submenu', this.config.$responsiveMenu ).on( 'click', function( e ){ var li = $(this), element = e.target || e.srcElement; if( element.nodeName != 'A' ){ li.toggleClass('open'); li.parent().find('li').not(li).removeClass('open'); li.children( '.sub-menu' ).slideToggle('300'); } } ); }else{ if( this.config.$responsiveMenu != null ) this.config.$responsiveMenu.addClass('cl-hide-not-mobile'); } if( this.config.$windowWidth > 991 ) this.config.$header.removeClass('cl-responsive-header'); else this.config.$header.addClass('cl-responsive-header'); } CL_FRONT.scrollToTopButton = function(){ "use strict"; $(window).scroll(function(){ if ($(this).scrollTop() > 100) { $('.scrollToTop').fadeIn(); } else { $('.scrollToTop').fadeOut(); } }); //Click event to scroll to top $('.scrollToTop').on( 'click', function(){ $('html, body').animate({scrollTop : 0},800); return false; }); } /** * This function init all related functions of a specific header or menu style * * @since 1.0.0 */ CL_FRONT.initHeaderStyles = CL_FRONT.init_cl_header_menu = function(){ "use strict"; // Hamburger - overlay if( $('.cl-fullscreen-overlay').length > 0 ){ CL_FRONT.fullscreenOverlayMenu(); }else if( this.config.$header.hasClass('header-left') || this.config.$header.hasClass('header-right') ) { CL_FRONT.initHeaderSide(); } }, CL_FRONT.scrollableSections = function(){ "use strict"; if( $( '.cl-scrollable' ).length == 0 ) return; $( '.cl-scrollable' ).nanoScroller({ paneClass: 'cl-scrollable__pane', sliderClass: 'cl-scrollable__slider', contentClass: 'cl-scrollable__content' }); }, /** * Init Header Sticky * * @since 1.0.0 * @version 1.0.8 */ CL_FRONT.initHeaderSticky = function(){ "use strict"; if( ! this.config.$header.hasClass( 'cl-header--sticky' ) ) return; var is_active = false; if( !CL_FRONT.config.$header.hasClass('cl-header--transparent') && CL_FRONT.config.$isDesktopScreen ){ var header_height = CL_FRONT.config.$header.height(); }else{ CL_FRONT.config.$main.css({ marginTop: '0px', }); } var breakpoint = $( '.cl-header__row--main' ).outerHeight(); if( $( '.cl-header__row--top' ).length > 0 ) breakpoint += $( '.cl-header__row--top' ).outerHeight(); if( $( '.cl-header__row--extra' ).length > 0 ) breakpoint += $( '.cl-header__row--extra' ).outerHeight(); $('.cl-header__padding').css( {paddingTop: breakpoint} ); var onScroll = function(){ if( ! CL_FRONT.config.$header.hasClass( 'cl-header--sticky' ) ) return; var stickyContentColor = CL_FRONT.helpers.parseData( CL_FRONT.config.$header.attr('data-sticky-content-color'), 'dark' ); var site_header = CL_FRONT.config.$body.hasClass('cl-header-light') ? 'light' : 'dark'; if( CL_FRONT.config.$windowTop > breakpoint+200 && !is_active ){ CL_FRONT.config.$header.addClass('cl-header--sticky-prepare'); if( stickyContentColor == 'dark' ) CL_FRONT.config.$header.removeClass('cl-header--light'); if( stickyContentColor == 'light' && site_header == 'dark' ) CL_FRONT.config.$header.addClass('cl-header--light'); setTimeout( function(){ CL_FRONT.config.$header.addClass('cl-header--sticky-active'); is_active = true; }, 100); }else if( CL_FRONT.config.$windowTop <= breakpoint+200 && is_active ) { CL_FRONT.config.$header.removeClass('cl-header--sticky-prepare'); if( site_header == 'dark' ){ CL_FRONT.config.$header.removeClass('cl-header--light'); } else if( site_header == 'light' && ! CL_FRONT.config.$header.hasClass('cl-header--light') ) CL_FRONT.config.$header.addClass('cl-header--light'); setTimeout( function(){ CL_FRONT.config.$header.removeClass('cl-header--sticky-active'); CL_FRONT.config.$header.removeClass('cl-header--sticky-prepare'); is_active = false; }, 100); } } window.addEventListener('scroll', onScroll, false); }, /** * Bind hamburger click and open overlay * * @since 1.0.0 * @version 1.0.6 */ CL_FRONT.fullscreenOverlayMenu = function(){ "use strict"; CL_FRONT.subMenuOnClick( $('.cl-fullscreen-overlay__menu') ); $('.cl-fullscreen-overlay__close').on('click', function(e){ e.preventDefault(); var $overlay = $(this).closest( '.cl-fullscreen-overlay' ); $overlay.removeClass('cl-fullscreen-overlay--open'); setTimeout(function(){ $overlay.css('display', 'none'); }, 350); }); $('.cl-header__hamburger-button').on('click', function(){ $('.cl-fullscreen-overlay').css('display', 'block'); setTimeout(function(){ $('.cl-fullscreen-overlay').addClass('cl-fullscreen-overlay--open'); }, 50); setTimeout(function(){ CL_FRONT.animations( $('.cl-header__menu', $( '.cl-fullscreen-overlay' )), true ); }, 300); }); }, CL_FRONT.subMenuOnClick = function( $menu ){ $('.menu-item-has-children > a', $menu).on( 'click', function(e){ e.preventDefault(); var $li = $(this).parent(); var $submenu = $li.find( '> .sub-menu' ); var $all_li = $menu.find('.menu-item-has-children'); if( $li.hasClass('open') ){ $submenu.slideUp(300); $li.removeClass('open'); }else{ $all_li.removeClass('open'); $all_li.find( '> .sub-menu' ).slideUp(300); $submenu.slideDown(300); $li.addClass('open'); } } ); }, CL_FRONT.sideNav = function(){ $('.cl-header__tool--side-menu .cl-header__tool__link').on( 'click', function(e){ e.preventDefault(); var $open_button = $(this); if( !$( '.cl-sidenav' ).hasClass('cl-sidenav--open') ){ $( '.cl-sidenav' ).addClass('cl-sidenav--open'); } }) $('.cl-sidenav__close').on( 'click', function(e){ e.preventDefault(); var $close_button = $(this); if( $( '.cl-sidenav' ).hasClass('cl-sidenav--open') ){ $( '.cl-sidenav' ).removeClass('cl-sidenav--open'); } }) } /** * Page transition Effects * * @since 1.0.0 */ CL_FRONT.pageTransition = function(){ "use scrict"; if( ! this.config.$viewport.hasClass( 'animsition' ) ) return; $(".animsition").animsition({ inClass : $(this).data('animsition-in'), outClass : $(this).data('animsition-out'), inDuration : $(this).data('animsition-in-duration'), outDuration : $(this).data('animsition-out-duration'), linkElement : 'a:not([target="_blank"]):not([href^="#"]):not(.lightbox-gallery):not(.entry-link.lightbox):not([class^="ilightbox-"]):not(.zoom):not(.prettyphoto):not(.anchorSubmenu)' }); } /** * Initialize Post * * @since 1.0.0 */ CL_FRONT.postInit = function( $el ) { "use strict"; this.postSwiper(); this.postShareButtons( $el ); this.postHideShowShare(); this.postLike(); }; CL_FRONT.postHideShowShare = function( ){ if( $('.cl-single-share-buttons').length == 0 || $( '#content.cl-layout-fullwidth' ).length == 0 ) return; var $element = $('.cl-single-share-buttons'), height = $element.find('.cl-single-share-buttons__wrapper').height(), total_size = height - 200, breakpoints = {}; $('.alignwide, .alignfull').each(function(index, t){ breakpoints[index] = { top: $(this).offset().top, height: $(this).height() }; }); $(window).on( 'scroll', function(){ var actualTop = $(this).scrollTop(); var show = true; $.each( breakpoints, function(index, value){ if( actualTop >= (value.top - height) && actualTop <= ( value.top + value.height ) ) show = false; }); if( show ){ if( $element.hasClass('cl-hide') ) $element.removeClass('cl-hide'); }else{ if( ! $element.hasClass('cl-hide') ) $element.addClass('cl-hide'); } }); }; CL_FRONT.livePhoto = function(){ "use strict"; if($('#live_photo').length > 0){ var myNewPlayer = LivePhotosKit.Player(); // A Player built from a pre-existing element: LivePhotosKit.Player(document.getElementById('live_photo')); } } CL_FRONT.postInstagram = function() { $( '.entry-video .instagram-media' ).contents().find( '.EmbedCaption' ).remove(); $( '.entry-video .instagram-media' ).contents().find( '.EmbedFooter' ).remove(); } /** * Fix sidebar background Width * * @since 1.0.0 */ CL_FRONT.fixModernLayoutWidth = function() { "use strict"; if ( this.config.$layoutModern ) { if ( this.config.$pageLayout == 'right_sidebar' ) { var distance = this.config.$windowWidth - ( this.config.$aside.offset().left ); $( '.cl-layout-modern-bg' ).width( ( distance + 10 ) + 'px' ); } if ( this.config.$pageLayout == 'left_sidebar' ) { var distance = this.config.$aside.offset().left + this.config.$aside.width(); $( '.cl-layout-modern-bg' ).width( ( distance + 35 ) + 'px' ); } } } /** * Fix Height of custom Masonry Size * * @since 1.0.0 */ CL_FRONT.fixPostMasonryHeight = function( $element ){ "use strict"; if( $( $element ).length > 0 ){ var $wide = $( '.cl-msn-size-wide', $element ), $height = $( '.cl-msn-size-small', $element ).height() - 20; $wide.css( { height: $height + 'px' } ); $( 'img', $wide ).css( { height: $height + 'px' } ); } } /** * Fix Height of custom Masonry Size * * @since 1.0.0 */ CL_FRONT.fixPortfolioMasonryHeight = function( $element ){ "use strict"; if( $( $element ).length > 0 ){ var $wide = $( '.cl-msn-size-wide', $element), $height = $( '.grid-holder', $wide ).height(), padd = typeof $wide.css('padding') !== 'undefined' ? $wide.css('padding') : '0px', padding = parseInt(padd.replace("px", "")) * 2; $wide.css( { height: $height + padding + 'px' } ); } } /** * Close Share Buttons Div * * @since 1.0.0 */ CL_FRONT.postCloseShares = function() { "use strict"; if ( $( '.share-buttons' ).length ) { $( '.share-buttons' ).removeClass( 'show' ); $( '.share-buttons' ).addClass( 'hidden' ); } }; /** * Post Like Button * * @since 1.0.0 */ CL_FRONT.postLike = function() { "use strict"; $( '.cl-entry__tool--likes .like' ).on( 'click', function( e ) { e.preventDefault(); var $this = $( this ), $id = $this.attr( 'id' ); if ( $this.hasClass( 'item-liked' ) ) return false; if ( $this.hasClass( 'item-inactive' ) ) return false; $.post( codeless_global.ajax_url, { action: 'codeless_post_like', post_id: $id }, function( data ) { $this.find( '.cl-entry__tool-count' ).html( data ); $this.addClass( 'item-liked' ); } ); $this.addClass( 'item-inactive' ); return false; } ); }; /** * Post Share Buttons SHOW/HIDE * * @since 1.0.0 */ CL_FRONT.postShareButtons = function( $el ) { "use strict"; var $elements = $( '.cl-entry__tool--share' ); if ( typeof $el !== "undefined" ) $elements = $( '.cl-entry__tool--share', $el ); if ( $elements.length ) { // Open share-buttons on button click $elements.each( function( i ) { var $element = $( this ); $( '.cl-entry__share-open', $element ).on( 'click', function( e ) { e.stopPropagation(); e.preventDefault(); if ( $( '.cl-entry__share-container', $element ).hasClass( 'hidden' ) ) { $( '.cl-entry__share-container', $element ).removeClass( 'hidden' ); setTimeout( function() { $( '.cl-entry__share-container', $element ).addClass( 'show' ); }, 150 ); } else { $( '.cl-entry__share-container', $element ).removeClass( 'show' ); setTimeout( function() { $( '.cl-entry__share-container', $element ).addClass( 'hidden' ); }, 150 ); } } ); } ); } }; CL_FRONT.videoPostGallery = function(){ "use strict"; $( '.cl-video-gallery__featured .cl-video-play' ).on('click', function(e){ e.preventDefault(); var $button = $(this), src = $button.attr('href'), $article = $button.closest('article') $article.addClass('cl-prepare-video'); $article.find('.cl-entry__media').prepend('