1( function( $ ) { 2 "use strict"; 3 4 var CL_FRONT = window.CL_FRONT || {}; 5 window.CL_FRONT = CL_FRONT; 6 7 8 CL_FRONT.components = CL_FRONT.components || {}; 9 CL_FRONT.helpers = CL_FRONT.helpers || {}; 10 11 /** 12 * Main Site Init 13 * 14 * @since 1.0.0 15 */ 16 CL_FRONT.siteInit = function() { 17 "use strict"; 18 19 this.defaultConfig(); 20 this.bindEvents(); 21 }; 22 23 /** 24 * Init Default Variables 25 * 26 * @since 1.0.0 27 */ 28 CL_FRONT.defaultConfig = function() { 29 "use strict"; 30 31 this.config = { 32 33 // Load dynamic scripts 34 _loadedDependencies: [], 35 _inQueue: {}, 36 37 // Default Config 38 $window: $( window ), 39 $document: $( document ), 40 $windowWidth: $( window ).width(), 41 $windowHeight: $( window ).height(), 42 $windowTop: typeof window.pageYOffset != 'undefined' ? window.pageYOffset: document.documentElement.scrollTop? document.documentElement.scrollTop: document.body.scrollTop? document.body.scrollTop:0, 43 $containerWidth: 0, 44 $containerOffsetLeft: 0, 45 46 $html: $( 'html' ), 47 $body: $( 'body' ), 48 $viewport: $( '#viewport' ), 49 $header: $( '.cl-header' ), 50 $headerTools: $('.cl-header__tools'), 51 $initSliders : {}, 52 $navigation: $( '#navigation' ), 53 $responsiveMenu: null, 54 $content: $( '#content' ), 55 $aside: $( '#secondary' ), 56 $main: $( '#main' ), 57 58 $pageLayout: 'fullwidth', 59 $headerHeight: 0, 60 $layoutModern: false, 61 $asideTop: 0, 62 $asideHeight: 0, 63 $asideArray: {}, 64 $asideStickyOffset: 0, 65 66 $isMobileScreen: false, 67 $isTabletScreen: false, 68 $isDesktopScreen: false, 69 70 $isMobileDevice: false, 71 $isMobileOrTabletDevice: false, 72 73 $isSmoothScroll: false, 74 $isCustomizer: false, 75 76 $headerToolsInit: false, 77 $headerToolsList: [], 78 $ilightboxes: {}, 79 80 $cssInQueue: {}, 81 } 82 83 84 }; 85 86 /** 87 * Bind Events of site 88 * 89 * @since 1.0.0 90 * @version 1.0.2 91 */ 92 CL_FRONT.bindEvents = function() { 93 "use strict"; 94 95 var self = this; 96 97 // Document Ready 98 self.config.$document.ready( function() { 99 self.updateConfig(); 100 self.loadAsyncIcons(); 101 // Menu 102 self.initMenuDropdown(); 103 self.initToolsDropdown(); 104 self.initMenuResponsive(); 105 self.initToolsResponsive(); 106 self.initHeaderStyles(); 107 self.initHeaderSticky(); 108 109 // Initialize Post Functionalities 110 self.postInit(); 111 112 self.animations(); 113 114 115 self.isotopeBlogGrid(); 116 self.isotopePortfolioGrid(); 117 self.itemILightBox(); 118 119 self.nextPrevAjax(); 120 self.filtersAjax(); 121 122 // Various sizes and positions fixes 123 self.fixModernLayoutWidth(); 124 self.fixCompatibilities(); 125 self.fixMegaMenuPosition(); 126 self.init_cl_page_header(); 127 128 if( ! self.config.$isCustomizer ) 129 self.codelessSlider(); 130 131 132 self.rowParallax(); 133 134 self.progressBar(); 135 self.mediaElement(); 136 self.codelessGMap(); 137 self.contactForm(); 138 self.codelessToggles(); 139 self.shopBtnClasses(); 140 self.instaFeed(); 141 142 self.codelessTabs(); 143 self.creativeSearch(); 144 //self.partialRefreshRendered(); 145 146 self.footerReveal(); 147 self.pageTransition(); 148 self.countdownElement(); 149 150 self.sideNav(); 151 152 self.loadOtherLazyload(); 153 154 self.onePageScroll(); 155 156 self.scrollToTopButton(); 157 self.scrollableSections(); 158 self.videoPostGallery(); 159 160 self.paginationInfiniteInitBlocks(); 161 162 } ); 163
164 // Window load 165 self.config.$window.on( 'load', function() { 166 self.postInstagram(); 167 self.livePhoto(); 168 self.convertSVGAnimated(); 169 self.rowParallax(); 170 self.shopBtnClasses(); 171 } ); 172 173 // Window Resize 174 self.config.$window.resize( function() { 175 self.updateDimensions(); 176 self.initMenuResponsive(); 177 self.initToolsResponsive(); 178 self.fixModernLayoutWidth(); 179 self.stickySidebar(); 180 //self.stickyColumn(); 181 self.fixPageHeaderCenter(); 182 self.initHeaderSticky(); 183 184 } ); 185 186 // Window Scroll 187 self.config.$window.scroll( function() { 188 self.config.$windowTop = typeof window.pageYOffset != 'undefined' ? window.pageYOffset: document.documentElement.scrollTop? document.documentElement.scrollTop: document.body.scrollTop? document.body.scrollTop:0;; 189 self.stickySidebar(); 190 //self.stickyColumn(); 191 } ); 192 193 // Window on Orientation Change Tablets 194 self.config.$window.on( 'orientationchange', function() { 195 self.updateDimensions(); 196 self.initMenuResponsive(); 197 self.initToolsResponsive(); 198 self.fixPageHeaderCenter(); 199 self.footerReveal(); 200 } ); 201 202 self.config.$window.on( 'click', function() { 203 // Close Shares on outside click 204 self.postCloseShares() 205 } ); 206 207 208 }; 209 210 /** 211 * Update Config Dom 212 * 213 * @since 1.0.0 214 */ 215 CL_FRONT.updateConfig = function() { 216 this.config.$html = $( 'html' ); 217 this.config.$body = $( 'body' ); 218 this.config.$viewport = $( '#viewport' ); 219 this.config.$header = $( '.cl-header' ); 220 this.config.$navigation = $( '.cl-header__navigation' ); 221 this.config.$headerTools = $('.cl-header__tools'); 222 this.config.$content = $( '#content' ); 223 this.config.$aside = $( '#secondary' ); 224 this.config.$asideArray = {}; 225 this.config.$main = $( '#main' ); 226 227 this.config.$pageLayout = this.config.$content.hasClass( 'cl-layout-left_sidebar' ) ? 'left_sidebar' : 228 this.config.$content.hasClass( 'cl-layout-right_sidebar' ) ? 'right_sidebar' : 229 this.config.$content.hasClass( 'cl-layout-dual' ) ? 'dual_sidebar' : 'fullwidth'; 230 231 if ( this.config.$content.hasClass( 'cl-layout-modern' ) ) 232 this.config.$layoutModern = true; 233 234 this.config.$isMobileDevice = this.mobileDeviceCheck(); 235 this.config.$isMobileOrTabletDevice = this.mobileOrTabletDeviceCheck(); 236 237 this.config.$isSmoothScroll = this.config.$body.hasClass( 'cl-smoothscroll' ) ? true : false; 238 239 if( $('.cl_counter').length > 0 ) 240 this.preloadOdometer(); 241 242 this.updateDimensions(); 243 }; 244 245 /** 246 * Check if page is loaded from mobile 247 * 248 * @since 1.0.0 249 */ 250 CL_FRONT.mobileDeviceCheck = function() { 251 var check = false; 252 ( function( a ) { 253 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 )|
253sy(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; 254 } )( navigator.userAgent || navigator.vendor || window.opera ); 255 return check; 256 } 257 258 259 /** 260 * Check if page is loaded from mobile or tablet 261 * 262 * @since 1.0.0 263 */ 264 CL_FRONT.mobileOrTabletDeviceCheck = function() { 265 var check = false; 266 ( function( a ) { 267 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; 268 } )( navigator.userAgent || navigator.vendor || window.opera ); 269 return check; 270 } 271 272 273 /** 274 * Update Dimension of page, used on screen resize 275 * 276 * @since 1.0.0 277 */ 278 CL_FRONT.updateDimensions = function() { 279 this.config.$windowWidth = $( window ).width(); 280 this.config.$windowHeight = $( window ).height(); 281 282 if ( window.matchMedia ) { 283 this.config.$isMobileScreen = window.matchMedia( '( max-width: 767px )' ).matches; 284 this.config.$isTabletScreen = window.matchMedia( '( min-width: 768px ) and (max-width: 991px)' ).matches; 285 this.config.$isDesktopScreen = window.matchMedia( '( min-width: 992px )' ).matches; 286 } else { 287 this.config.$isMobileScreen = this.config.$windowWidth <= 768; 288 this.config.$isTabletScreen = this.config.$windowWidth > 768 && this.config.$windowWidth <= 991; 289 this.config.$isDesktopScreen = this.config.$windowWidth > 992; 290 } 291 292 this.config.$containerWidth = this.config.$header.hasClass('header-top') ? this.config.$header.find( '.header-row-inner' ).width() : this.config.$content.find( '.container' ).width(); 293 if( this.config.$header.hasClass('header-top') ){ 294 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; 295 }else 296 this.config.$containerOffsetLeft = 0; 297 298 299 var container_offset = this.config.$content.find( '.container' ).length > 0 ? this.config.$content.find( '.container' ).offset().left : 0 300 this.config.$containerOffsetLeft = this.config.$header.hasClass('header-top') ? this.config.$header.find( '.c-left.header-col' ).offset().left : container_offset - 15; 301 this.config.$headerHeight = this.config.$header.height(); 302 303 304 305 } 306 307 308 CL_FRONT.fixCompatibilities = function(){ 309 if( bowser.msie && bowser.version <= 9 ){ 310 CL_FRONT.components.loadDependencies( [ codeless_global.FRONT_LIB_JS + 'jquery.requestAnimationFrame.js'], function(){ 311 312 }); 313 314 CL_FRONT.config.$html.addClass('no-cssanimations'); 315 } 316 } 317 318 /** 319 * Initialize Menu in Responsive 320 * 321 * @since 1.0.0 322 */ 323 324 CL_FRONT.initMenuResponsive = function() { 325 "use strict"; 326 var self = this; 327 328 if( this.config.$windowWidth <= 991 && this.config.$responsiveMenu === null ){ 329 330 331 332 if( this.config.$navigation.closest('.cl-fullscreen-overlay-menu').length == 0 ) 333 this.config.$navigation.addClass('cl-hide-on-mobile'); 334 else{ 335 this.config.$navigation.addClass('cl-header__navigation--vertical').addClass('cl-mobile-menu'); 336 return; 337 } 338 339 this.config.$responsiveMenu = this.config.$navigation.clone().appendTo(this.config.$header); 340 this.config.$responsiveMenu.removeClass( 'cl-hide-on-mobile' ).addClass( 'cl-mobile-menu' ); 341 342 if( this.config.$body.hasClass('cl-header-incontainer') ) 343 this.config.$responsiveMenu.addClass('container'); 344 345 $( '.cl-header__mobile-button' ).on( 'click', function( ){ 346 var button = $(this); 347 button.toggleClass( 'open' ); 348 self.config.$responsiveMenu.slideToggle('200'); 349 CL_FRONT.animations( self.config.$responsiveMenu , true ); 350 351 } ); 352 353 $( '.cl-header__menu li.has-submenu > a', this.config.$responsiveMenu ).on( 'click', function( e ){ 354 var li = $(this).parent(); 355 e.preventDefault(); 356 357 li.toggleClass('open'); 358 li.parent().find('li').not(li).removeClass('open'); 359 li.children( '.sub-menu, .cl-header__menu__megamenu' ).slideToggle('300'); 360 361 } ); 362 363 $( '.cl-header__menu .cl-header__menu__megamenu > ul > li.has-submenu', this.config.$responsiveMenu ).on( 'click', function( e ){ 364 var li = $(this), 365 element = e.target || e.srcElement; 366 367 if( element.nodeName != 'A' ){ 368 li.toggleClass('open'); 369 li.parent().find('li').not(li).removeClass('open'); 370 371 li.children( '.sub-menu' ).slideToggle('300'); 372 } 373 374 375 } ); 376 377 }else{ 378 379 if( this.config.$responsiveMenu != null ) 380 this.config.$responsiveMenu.addClass('cl-hide-not-mobile'); 381 382 } 383 384 if( this.config.$windowWidth > 991 ) 385 this.config.$header.removeClass('cl-responsive-header'); 386 else 387 this.config.$header.addClass('cl-responsive-header'); 388 } 389 390 391 CL_FRONT.scrollToTopButton = function(){ 392 "use strict"; 393 394 $(window).scroll(function(){ 395 if ($(this).scrollTop() > 100) { 396 $('.scrollToTop').fadeIn(); 397 } else { 398 $('.scrollToTop').fadeOut(); 399 } 400 }); 401 402 //Click event to scroll to top 403 $('.scrollToTop').on( 'click', function(){ 404 $('html, body').animate({scrollTop : 0},800); 405 return false;
406 }); 407 } 408 409 410 /** 411 * This function init all related functions of a specific header or menu style 412 * 413 * @since 1.0.0 414 */ 415 CL_FRONT.initHeaderStyles = CL_FRONT.init_cl_header_menu = function(){ 416 "use strict"; 417 418 // Hamburger - overlay 419 if( $('.cl-fullscreen-overlay').length > 0 ){ 420 CL_FRONT.fullscreenOverlayMenu(); 421 }else if( this.config.$header.hasClass('header-left') || this.config.$header.hasClass('header-right') ) { 422 CL_FRONT.initHeaderSide(); 423 } 424 425 426 }, 427 428 429 CL_FRONT.scrollableSections = function(){ 430 "use strict"; 431 if( $( '.cl-scrollable' ).length == 0 ) 432 return; 433 434 $( '.cl-scrollable' ).nanoScroller({ 435 paneClass: 'cl-scrollable__pane', 436 sliderClass: 'cl-scrollable__slider', 437 contentClass: 'cl-scrollable__content' 438 }); 439 }, 440 441 442 443 444 /** 445 * Init Header Sticky 446 * 447 * @since 1.0.0 448 * @version 1.0.8 449 */ 450 CL_FRONT.initHeaderSticky = function(){ 451 "use strict"; 452 453 if( ! this.config.$header.hasClass( 'cl-header--sticky' ) ) 454 return; 455 456 var is_active = false; 457 458 459 if( !CL_FRONT.config.$header.hasClass('cl-header--transparent') && CL_FRONT.config.$isDesktopScreen ){ 460 461 var header_height = CL_FRONT.config.$header.height(); 462 463 464 }else{ 465 466 CL_FRONT.config.$main.css({ 467 468 marginTop: '0px', 469 470 }); 471 } 472 473 var breakpoint = $( '.cl-header__row--main' ).outerHeight(); 474 if( $( '.cl-header__row--top' ).length > 0 ) 475 breakpoint += $( '.cl-header__row--top' ).outerHeight(); 476 477 if( $( '.cl-header__row--extra' ).length > 0 ) 478 breakpoint += $( '.cl-header__row--extra' ).outerHeight(); 479 480 $('.cl-header__padding').css( {paddingTop: breakpoint} ); 481 482 var onScroll = function(){ 483 484 if( ! CL_FRONT.config.$header.hasClass( 'cl-header--sticky' ) ) 485 return; 486 487 var stickyContentColor = CL_FRONT.helpers.parseData( CL_FRONT.config.$header.attr('data-sticky-content-color'), 'dark' ); 488 var site_header = CL_FRONT.config.$body.hasClass('cl-header-light') ? 'light' : 'dark'; 489 490 if( CL_FRONT.config.$windowTop > breakpoint+200 && !is_active ){ 491 492 CL_FRONT.config.$header.addClass('cl-header--sticky-prepare'); 493 494 if( stickyContentColor == 'dark' ) 495 CL_FRONT.config.$header.removeClass('cl-header--light'); 496 if( stickyContentColor == 'light' && site_header == 'dark' ) 497 CL_FRONT.config.$header.addClass('cl-header--light'); 498 499 500 setTimeout( function(){ 501 CL_FRONT.config.$header.addClass('cl-header--sticky-active'); 502 is_active = true; 503 }, 100); 504 505 506 }else if( CL_FRONT.config.$windowTop <= breakpoint+200 && is_active ) { 507 508 CL_FRONT.config.$header.removeClass('cl-header--sticky-prepare'); 509 510 511 if( site_header == 'dark' ){ 512 CL_FRONT.config.$header.removeClass('cl-header--light'); 513 514 } 515 else if( site_header == 'light' && ! CL_FRONT.config.$header.hasClass('cl-header--light') ) 516 CL_FRONT.config.$header.addClass('cl-header--light'); 517 518 519 setTimeout( function(){ 520 CL_FRONT.config.$header.removeClass('cl-header--sticky-active'); 521 CL_FRONT.config.$header.removeClass('cl-header--sticky-prepare'); 522 is_active = false; 523 }, 100); 524 } 525 } 526 527 window.addEventListener('scroll', onScroll, false); 528 }, 529 530 531 /** 532 * Bind hamburger click and open overlay 533 * 534 * @since 1.0.0 535 * @version 1.0.6 536 */ 537 CL_FRONT.fullscreenOverlayMenu = function(){ 538 "use strict"; 539 540 CL_FRONT.subMenuOnClick( $('.cl-fullscreen-overlay__menu') ); 541 542 $('.cl-fullscreen-overlay__close').on('click', function(e){ 543 e.preventDefault();
544 var $overlay = $(this).closest( '.cl-fullscreen-overlay' ); 545 $overlay.removeClass('cl-fullscreen-overlay--open'); 546 547 setTimeout(function(){ 548 $overlay.css('display', 'none'); 549 }, 350); 550 }); 551 552 $('.cl-header__hamburger-button').on('click', function(){ 553 $('.cl-fullscreen-overlay').css('display', 'block'); 554 setTimeout(function(){ 555 $('.cl-fullscreen-overlay').addClass('cl-fullscreen-overlay--open'); 556 }, 50); 557 558 setTimeout(function(){ 559 CL_FRONT.animations( $('.cl-header__menu', $( '.cl-fullscreen-overlay' )), true ); 560 }, 300); 561 562 }); 563 564 565 566 }, 567 568 569 CL_FRONT.subMenuOnClick = function( $menu ){ 570 $('.menu-item-has-children > a', $menu).on( 'click', function(e){ 571 e.preventDefault(); 572 573 var $li = $(this).parent(); 574 var $submenu = $li.find( '> .sub-menu' ); 575 var $all_li = $menu.find('.menu-item-has-children'); 576 577 if( $li.hasClass('open') ){ 578 $submenu.slideUp(300); 579 $li.removeClass('open'); 580 }else{ 581 $all_li.removeClass('open'); 582 $all_li.find( '> .sub-menu' ).slideUp(300); 583 584 $submenu.slideDown(300); 585 $li.addClass('open'); 586 } 587 588 } ); 589 }, 590 591 592 593 594 595 CL_FRONT.sideNav = function(){ 596 $('.cl-header__tool--side-menu .cl-header__tool__link').on( 'click', function(e){ 597 e.preventDefault(); 598 var $open_button = $(this); 599 600 if( !$( '.cl-sidenav' ).hasClass('cl-sidenav--open') ){ 601 $( '.cl-sidenav' ).addClass('cl-sidenav--open'); 602 } 603 }) 604 605 $('.cl-sidenav__close').on( 'click', function(e){ 606 e.preventDefault(); 607 var $close_button = $(this); 608 609 if( $( '.cl-sidenav' ).hasClass('cl-sidenav--open') ){ 610 $( '.cl-sidenav' ).removeClass('cl-sidenav--open'); 611 } 612 }) 613 } 614 615 /** 616 * Page transition Effects 617 * 618 * @since 1.0.0 619 */ 620 621 CL_FRONT.pageTransition = function(){ 622 "use scrict"; 623 624 if( ! this.config.$viewport.hasClass( 'animsition' ) ) 625 return; 626 627 $(".animsition").animsition({ 628 629 inClass : $(this).data('animsition-in'), 630 outClass : $(this).data('animsition-out'), 631 inDuration : $(this).data('animsition-in-duration'), 632 outDuration : $(this).data('animsition-out-duration'), 633 linkElement : 'a:not([target="_blank"]):not([href^="#"]):not(.lightbox-gallery):not(.entry-link.lightbox):not([class^="ilightbox-"]):not(.zoom):not(.prettyphoto):not(.anchorSubmenu)' 634 635 }); 636 637 } 638 639 640 /** 641 * Initialize Post 642 * 643 * @since 1.0.0 644 */ 645 CL_FRONT.postInit = function( $el ) { 646 "use strict"; 647 648 this.postSwiper(); 649 this.postShareButtons( $el ); 650 this.postHideShowShare(); 651 this.postLike(); 652 }; 653 654 CL_FRONT.postHideShowShare = function( ){ 655 if( $('.cl-single-share-buttons').length == 0 || $( '#content.cl-layout-fullwidth' ).length == 0 ) 656 return; 657 658 var $element = $('.cl-single-share-buttons'), 659 height = $element.find('.cl-single-share-buttons__wrapper').height(), 660 total_size = height - 200, 661 breakpoints = {}; 662 663 $('.alignwide, .alignfull').each(function(index, t){ 664 breakpoints[index] = { top: $(this).offset().top, height: $(this).height() }; 665 }); 666 667 $(window).on( 'scroll', function(){ 668 var actualTop = $(this).scrollTop(); 669 var show = true; 670 671 $.each( breakpoints, function(index, value){ 672 if( actualTop >= (value.top - height) && actualTop <= ( value.top + value.height ) ) 673 show = false; 674 }); 675 676 if( show ){ 677 if( $element.hasClass('cl-hide') ) 678 $element.removeClass('cl-hide'); 679 }else{ 680 if( ! $element.hasClass('cl-hide') ) 681 $element.addClass('cl-hide'); 682 } 683 684 }); 685 686 687 }; 688 689 CL_FRONT.livePhoto = function(){ 690 "use strict"; 691 if($('#live_photo').length > 0){ 692 693 var myNewPlayer = LivePhotosKit.Player(); 694 // A Player built from a pre-existing element: 695 LivePhotosKit.Player(document.getElementById('live_photo')); 696 697 } 698 } 699 700 CL_FRONT.postInstagram = function() { 701 $( '.entry-video .instagram-media' ).contents().find( '.EmbedCaption' ).remove(); 702 $( '.entry-video .instagram-media' ).contents().find( '.EmbedFooter' ).remove(); 703 } 704 705 /** 706 * Fix sidebar background Width 707 * 708 * @since 1.0.0 709 */ 710 CL_FRONT.fixModernLayoutWidth = function() { 711 "use strict"; 712 713 if ( this.config.$layoutModern ) { 714 715 if ( this.config.$pageLayout == 'right_sidebar' ) { 716 var distance = this.config.$windowWidth - ( this.config.$aside.offset().left ); 717 $( '.cl-layout-modern-bg' ).width( ( distance + 10 ) + 'px' ); 718 } 719 720 if ( this.config.$pageLayout == 'left_sidebar' ) { 721 var distance = this.config.$aside.offset().left + this.config.$aside.width(); 722 $( '.cl-layout-modern-bg' ).width( ( distance + 35 ) + 'px' ); 723 } 724 } 725 } 726 727 728 /**
729 * Fix Height of custom Masonry Size 730 * 731 * @since 1.0.0 732 */ 733 CL_FRONT.fixPostMasonryHeight = function( $element ){ 734 "use strict"; 735 736 if( $( $element ).length > 0 ){ 737 var $wide = $( '.cl-msn-size-wide', $element ), 738 $height = $( '.cl-msn-size-small', $element ).height() - 20; 739 740 $wide.css( { height: $height + 'px' } ); 741 $( 'img', $wide ).css( { height: $height + 'px' } ); 742 743 } 744 } 745 746 /** 747 * Fix Height of custom Masonry Size 748 * 749 * @since 1.0.0 750 */ 751 CL_FRONT.fixPortfolioMasonryHeight = function( $element ){ 752 "use strict"; 753 754 if( $( $element ).length > 0 ){ 755 756 var $wide = $( '.cl-msn-size-wide', $element), 757 $height = $( '.grid-holder', $wide ).height(), 758 padd = typeof $wide.css('padding') !== 'undefined' ? $wide.css('padding') : '0px', 759 760 padding = parseInt(padd.replace("px", "")) * 2; 761 762 $wide.css( { height: $height + padding + 'px' } ); 763 764 } 765 } 766 767 /** 768 * Close Share Buttons Div 769 * 770 * @since 1.0.0 771 */ 772 CL_FRONT.postCloseShares = function() { 773 "use strict"; 774 775 if ( $( '.share-buttons' ).length ) { 776 $( '.share-buttons' ).removeClass( 'show' ); 777 $( '.share-buttons' ).addClass( 'hidden' ); 778 } 779 }; 780 781 782 /** 783 * Post Like Button 784 * 785 * @since 1.0.0 786 */ 787 CL_FRONT.postLike = function() { 788 "use strict"; 789 790 $( '.cl-entry__tool--likes .like' ).on( 'click', function( e ) { 791 e.preventDefault(); 792 793 var $this = $( this ), 794 $id = $this.attr( 'id' ); 795 796 if ( $this.hasClass( 'item-liked' ) ) return false; 797 798 if ( $this.hasClass( 'item-inactive' ) ) return false; 799 800 801 $.post( codeless_global.ajax_url, { 802 action: 'codeless_post_like', 803 post_id: $id 804 }, function( data ) { 805 $this.find( '.cl-entry__tool-count' ).html( data ); 806 $this.addClass( 'item-liked' ); 807 } ); 808 809 $this.addClass( 'item-inactive' ); 810 return false; 811 } ); 812 }; 813 814 /** 815 * Post Share Buttons SHOW/HIDE 816 * 817 * @since 1.0.0 818 */ 819 CL_FRONT.postShareButtons = function( $el ) { 820 "use strict"; 821 822 var $elements = $( '.cl-entry__tool--share' ); 823 824 if ( typeof $el !== "undefined" ) 825 $elements = $( '.cl-entry__tool--share', $el ); 826 827 if ( $elements.length ) { 828 829 // Open share-buttons on button click 830 $elements.each( function( i ) { 831 var $element = $( this ); 832 $( '.cl-entry__share-open', $element ).on( 'click', function( e ) { 833 834 e.stopPropagation(); 835 e.preventDefault(); 836 837 if ( $( '.cl-entry__share-container', $element ).hasClass( 'hidden' ) ) { 838 $( '.cl-entry__share-container', $element ).removeClass( 'hidden' ); 839 setTimeout( function() { 840 $( '.cl-entry__share-container', $element ).addClass( 'show' ); 841 }, 150 ); 842 } else { 843 $( '.cl-entry__share-container', $element ).removeClass( 'show' ); 844 setTimeout( function() { 845 $( '.cl-entry__share-container', $element ).addClass( 'hidden' ); 846 }, 150 ); 847 } 848 849 } ); 850 } ); 851 } 852 }; 853 854 855 856 CL_FRONT.videoPostGallery = function(){ 857 "use strict"; 858 859 $( '.cl-video-gallery__featured .cl-video-play' ).on('click', function(e){ 860 e.preventDefault(); 861 var $button = $(this), 862 src = $button.attr('href'), 863 $article = $button.closest('article') 864 865 $article.addClass('cl-prepare-video'); 866 $article.find('.cl-entry__media').prepend('<div class="cl-md-loading"><div class="md-preloader"><svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="48" width="48" viewbox="0 0 75 75"><circle cx="37.5" cy="37.5" r="33.5" stroke-width="6"/></svg></div></div>'); 867 868 setTimeout( function(){ 869 $article.find('.cl-iframe-wrap').html($('<iframe>', { 870 src: src, 871 id: 'video-wrap', 872 frameborder: 0, 873 scrolling: 'no' 874 })); 875 876 $article.find( '.cl-entry__media .cl-md-loading' ).remove(); 877 }, 100 ); 878 879 }); 880 881 $( '.cl-video-gallery__more .cl-video-play' ).on('click', function(e){ 882 e.preventDefault(); 883 var $button = $(this), 884 src = $button.attr('href'), 885 $article = $button.closest('.cl-video-gallery').find('.cl-video-gallery__featured article'); 886 887 $button.closest( '.cl-video-gallery__more' ).find('article').removeClass('cl-video-playing'); 888 $button.closest( 'article' ).addClass('cl-video-playing'); 889 $article.addClass('cl-prepare-video'); 890 $article.find('.cl-entry__media').prepend('<div class="cl-md-loading"><div class="md-preloader"><svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="48" width="48" viewbox="0 0 75 75"><circle cx="37.5" cy="37.5" r="33.5" stroke-width="6"/></svg></div></div>'); 891 892 setTimeout( function(){ 893 $article.find('.cl-iframe-wrap').html($('<iframe>', { 894 src: src, 895 id: 'video-wrap', 896 frameborder: 0, 897 scrolling: 'no' 898 })); 899 $article.find( '.cl-entry__media .cl-md-loading' ).remove(); 900 901 902 }, 100 ); 903 904 }); 905 906 } 907 908 909 910 /** 911 * Post Slider Configuration and load 912 * Used only for post slider 913 * 914 * @since 1.0.0 915 */ 916 CL_FRONT.postSwiper = function( $el ) { 917 "use strict"; 918 919 var $elements = $el || $( '.cl-entry__gallery .cl-carousel' ); 920 if ( $elements.length ) { 921 $elements.each( function( i ) { 922 923 CL_FRONT.components.Carousel( $( this ), { 924 items:1, 925 margin:0, 926 autoHeight:true 927 }); 928 929 } ); 930 } 931 932 }; 933 934 935 CL_FRONT.loadAsyncIcons = function(){ 936 CL_FRONT.helpers.loadCSS(codeless_global.FRONT_LIB_CSS + 'codeless-icons.css'); 937 }; 938 939 /** 940 * Slider Configuration and load 941 * 942 * 943 * @since 1.0.0 944 */
945 CL_FRONT.codelessSlider = function( $el ) { 946 "use strict"; 947 948 var $elements = $el || $( '.cl_slider' ); 949 if ( $elements.length ) { 950 $elements.each( function( i ) { 951 952 var $element = $( this ); 953 var name = 'swiper.min.js'; 954 if( bowser.msie && bowser.version <= 9 ) 955 name = 'swiper.old.min.js'; 956 957 CL_FRONT.components.loadDependencies( [ codeless_global.FRONT_LIB_JS + name ], function() { 958 959 var animateSlide = function( $slide ){ 960 961 if( $slide.hasClass('cl-slide-animation') && ! $slide.hasClass('animation--none') ) 962 $slide.addClass('start_animation'); 963 }; 964 965 var opts = { 966 967 onSlideChangeStart: function(swiper){ 968 969 970 $(swiper.slides[swiper.activeIndex]).removeClass('start_animation'); 971 $(swiper.slides[swiper.activeIndex]).find('.start_animation:not(.bg-layer)').removeClass('start_animation'); 972 973 }, 974 975 onTransitionStart: function(swiper){ 976 setTimeout(function(){ 977 if( CL_FRONT.config.$header.hasClass('cl-transparent') ){ 978 979 CL_FRONT.helpers.changeHeaderColor( $(swiper.slides[swiper.activeIndex]) ); 980 981 setTimeout(function(){ 982 if( ! CL_FRONT.config.$header.hasClass('cl-header-light') ){ 983 $('.cl-slider-nav', $element).removeClass('swiper-button-white'); 984 $('.swiper-pagination', $element).addClass('cl-dark-pagination'); 985 } 986 else{ 987 $('.swiper-pagination', $element).removeClass('cl-dark-pagination'); 988 $('.cl-slider-nav', $element).addClass('swiper-button-white'); 989 } 990 }, 50 ); 991 992 } 993 animateSlide($(swiper.slides[swiper.activeIndex])); 994 CL_FRONT.animations($(swiper.slides[swiper.activeIndex]), true); 995 996 }, 300); 997 998 999 }, 1000 onInit: function(swiper){ 1001 if( CL_FRONT.config.$header.hasClass('cl-transparent') ){ 1002 if( ! CL_FRONT.config.$header.hasClass('cl-header-light') ){ 1003 $('.cl-slider-nav', $element).removeClass('swiper-button-white'); 1004 $('.swiper-pagination', $element).addClass('cl-dark-pagination'); 1005 } 1006 else{ 1007 $('.swiper-pagination', $element).removeClass('cl-dark-pagination'); 1008 $('.cl-slider-nav', $element).addClass('swiper-button-white'); 1009 } 1010 } 1011 1012 animateSlide($(swiper.slides[swiper.activeIndex])); 1013 CL_FRONT.animations($(swiper.slides[swiper.activeIndex]), true); 1014 1015 }, 1016 1017 1018 parallax: true, 1019 1020 speed: parseInt(CL_FRONT.helpers.parseData( $element.data('speed'), 300 )), 1021 direction: CL_FRONT.helpers.parseData( $element.data('direction'), 'horizontal' ), 1022 autoplay: parseInt(CL_FRONT.helpers.parseData( $element.data('clautoplay'), 0 )), 1023 loop: parseInt( CL_FRONT.helpers.parseData( $element.data('loop'), false ) ), 1024 mousewheelControl: parseInt( CL_FRONT.helpers.parseData( $element.data('mousewheel'), false ) ), 1025 1026 }; 1027 1028 1029 1030 var cl_effect = { 1031 1032 effect: CL_FRONT.helpers.parseData( $element.data('effect'), 'fade' ) 1033 1034 }; 1035 1036 if( CL_FRONT.helpers.parseData( $element.data('effect'), 'fade' ) == 'interleave' && CL_FRONT.config.$windowWidth > 992 ){ 1037 var interleaveOffset = -.5; 1038 1039 if( CL_FRONT.helpers.parseData( $element.data('direction'), 'horizontal' ) == 'horizontal' ){ 1040 1041 cl_effect = { 1042 1043 onProgress: function(swiper, progress){ 1044 1045 for (var i = 0; i < swiper.slides.length; i++){ 1046 1047 var slide = swiper.slides[i]; 1048 var translate, innerTranslate; 1049 progress = slide.progress; 1050 1051 if (progress > 0) { 1052 translate = progress * swiper.width; 1053 innerTranslate = translate * interleaveOffset; 1054 } 1055 else { 1056 innerTranslate = Math.abs( progress * swiper.width ) * interleaveOffset; 1057 translate = 0; 1058 } 1059 1060 1061 $(slide).css({ 1062 transform: 'translate3d(' + translate + 'px,0,0)' 1063 }); 1064 1065 $(slide).find('.cl-row > .bg-layer').css({ 1066 transform: 'translate3d(' + innerTranslate + 'px,0,0)' 1067 }); 1068 } 1069 }, 1070 1071 onTouchStart: function(swiper){ 1072 for (var i = 0; i < swiper.slides.length; i++){ 1073 $(swiper.slides[i]).css({ transition: '' }); 1074 } 1075 }, 1076 1077 onSetTransition: function(swiper, speed) { 1078 for (var i = 0; i < swiper.slides.length; i++){ 1079 $(swiper.slides[i]) 1080 .find('.cl-row > .bg-layer') 1081 .andSelf() 1082 .css({ transition: speed + 'ms' }); 1083 } 1084 } 1085 1086 }; 1087 1088 }else{ 1089 1090 cl_effect = { 1091 1092 onProgress: function(swiper, progress){ 1093 1094 for (var i = 0; i < swiper.slides.length; i++){ 1095 1096 var slide = swiper.slides[i]; 1097 var translate, innerTranslate; 1098 progress = slide.progress; 1099 1100 if (progress > 0) { 1101 translate = progress * swiper.height; 1102 innerTranslate = translate * interleaveOffset; 1103 } 1104 else { 1105 innerTranslate = Math.abs( progress * swiper.height ) * interleaveOffset; 1106 translate = 0; 1107 } 1108 1109 1110 $(slide).css({ 1111 transform: 'translate3d(0,' + translate + 'px, 0)' 1112 }); 1113 1114 1115 1116 1117 $(slide).find('.cl-row').css({ 1118 transform: 'translate3d(0,' + innerTranslate + 'px, 0)' 1119 }); 1120 1121 } 1122 }, 1123 1124 onTouchStart: function(swiper){ 1125 for (var i = 0; i < swiper.slides.length; i++){ 1126 $(swiper.slides[i]).css({ transition: '' }); 1127 } 1128 }, 1129 1130 onSetTransition: function(swiper, speed) { 1131 for (var i = 0; i < swiper.slides.length; i++){ 1132 1133 $(swiper.slides[i]) 1134 .find('.cl-row') 1135 .andSelf() 1136 .css({ transition: speed + 'ms' }); 1137 } 1138 } 1139 1140 }; 1141 1142 } 1143 1144 } 1145 1146 1147 if( CL_FRONT.helpers.parseData( $element.data('effect'), 'fade' ) == 'softscale'){ 1148 cl_effect = { 1149 1150 1151 onSetTransition: function (s, duration) { 1152 s.slides.transition(duration); 1153 if (s.params.virtualTranslate && duration !== 0) { 1154 var eventTriggered = false;
1155 s.slides.transitionEnd(function () { 1156 if (eventTriggered) return; 1157 if (!s) return; 1158 eventTriggered = true; 1159 s.animating = false; 1160 var triggerEvents = ['webkitTransitionEnd', 'transitionend', 'oTransitionEnd', 'MSTransitionEnd', 'msTransitionEnd']; 1161 for (var i = 0; i < triggerEvents.length; i++) { 1162 s.wrapper.trigger(triggerEvents[i]); 1163 } 1164 }); 1165 } 1166 }, 1167 1168 onSlideChangeStart: function(swiper){ 1169 var active = swiper.activeIndex, 1170 prev = swiper.previousIndex; 1171 1172 if( ! $( swiper.slides[prev] ).find('.cl-row').hasClass('navOutNext') ) 1173 $( swiper.slides[prev] ).find('.cl-row').addClass('navOutNext'); 1174 1175 if( $( swiper.slides[active] ).find('.cl-row').hasClass('navInNext') ) 1176 $( swiper.slides[active] ).find('.cl-row').removeClass('navInNext'); 1177 1178 $( swiper.slides[active] ).find('.cl-row').addClass('navInNext'); 1179 1180 setTimeout(function(){ 1181 $( swiper.slides[prev] ).find('.cl-row').removeClass('navOutNext'); 1182 $( swiper.slides[active] ).find('.cl-row').removeClass('navInNext'); 1183 }, 1500); 1184 }, 1185 1186 1187 effect: 'softscale', 1188 virtualTranslate: true, 1189 slidesPerView : 1, 1190 watchSlidesProgress : true, 1191 loop:false, 1192 parallax: false, 1193 spaceBetween : 0, 1194 1195 }; 1196 } 1197 1198 opts = $.extend(opts, cl_effect); 1199 1200 1201 1202 if( parseInt(CL_FRONT.helpers.parseData( $element.data('pagination'), 1 ) ) ){ 1203 opts['pagination'] = '.swiper-pagination'; 1204 opts['paginationClickable'] = true; 1205 } 1206 1207 if( parseInt(CL_FRONT.helpers.parseData( $element.data('navigation'), 1 ) ) ){ 1208 opts['nextButton'] = '.swiper-button-next'; 1209 opts['prevButton'] = '.swiper-button-prev'; 1210 } 1211 1212 if( parseInt(CL_FRONT.helpers.parseData( $element.data('anchors'), 0 ) ) ){ 1213 opts['paginationBulletRender'] = function (swiper, index, className) { 1214 var anchor = $(swiper.slides[index]).find('[data-anchor]').data('anchor'); 1215 return '<span class="' + className + '" data-label="'+ anchor +'"></span>'; 1216 } 1217 } 1218 1219 1220 1221 var actualInstance = new Swiper( '.cl_slider', opts ); 1222 CL_FRONT.config.$initSliders[$element.attr('id')] = actualInstance; 1223 1224 1225 var animateOnScroll = function(){ 1226 var startPoint = $element.offset().top + ( $element.height() * 0.44 ); 1227 1228 if( CL_FRONT.config.$windowTop >= startPoint && ! $element.hasClass('cl-animateScroll') ) 1229 $element.addClass('cl-animateScroll'); 1230 else if( $element.hasClass('cl-animateScroll') && CL_FRONT.config.$windowTop < startPoint) 1231 $element.removeClass('cl-animateScroll') 1232 1233 }; 1234 setTimeout(function(){ 1235 $(window).on('scroll', function(){ 1236 1237 if( CL_FRONT.helpers.parseData( $element.data('direction'), 'horizontal' ) == 'vertical' && CL_FRONT.config.$windowWidth < 992 ) 1238 return;
1239 animateOnScroll(); 1240 }); 1241 1242 }, 100); 1243 1244 var destroyed = false; 1245 1246 var verticalSliderResponsive = function(){ 1247 if( CL_FRONT.helpers.parseData( $element.data('direction'), 'horizontal' ) != 'vertical' || ! $element.hasClass('cl_slider-responsive-plain') ) 1248 return; 1249 if( CL_FRONT.config.$windowWidth > 992 ){ 1250 1251 if( destroyed ){ 1252 actualInstance = new Swiper( '.cl_slider', opts ); 1253 CL_FRONT.config.$initSliders[$element.attr('id')] = actualInstance; 1254 } 1255 1256 return; 1257 } 1258 1259 if( ! destroyed ){ 1260 actualInstance.destroy(false); 1261 destroyed = true; 1262 CL_FRONT.animations($element, true); 1263 } 1264 1265 } 1266 1267 1268 1269 verticalSliderResponsive(); 1270 1271 $(window).resize(function(){ 1272 verticalSliderResponsive(); 1273 }) 1274 1275 } ); 1276 1277 } ); 1278 } 1279 1280 }; 1281 1282 1283 1284 /** 1285 * Load More Button and Infinite Scroll 1286 * 1287 * @since 1.0.0 1288 */ 1289 CL_FRONT.paginationInfinite = function( $el ) { 1290 "use strict"; 1291 1292 var $elements = $el || $( '.cl-pagination-infinite' ); 1293 if ( $elements.length ) { 1294 $elements.each( function( i ) { 1295 1296 var $element = $( this ); 1297 CL_FRONT.components.loadDependencies( [ codeless_global.FRONT_LIB_JS + 'infinitescroll.js' ], function() { 1298 1299 var $container = $('#' + $element.parent().data( 'containerId' )).find('.cl-items-container'); 1300 var iso = $container.data('isotope'); 1301 console.log(iso); 1302 1303 if( $element.hasClass('loadmore') ){ 1304 1305 // Init Load more button 1306 var infiniteData = { 1307 1308 path: '#' + $element.parent().data( 'containerId' ) + ' .cl-pagination-infinite .older-posts a', 1309 append: '#' + $element.parent().data( 'containerId' ) + ' .cl-entry', 1310 loadOnScroll: false, 1311 button: '#' + $element.parent().data( 'containerId' ) + ' #cl_load_more_btn', 1312 status: '#' + $element.parent().data( 'containerId' ) + ' .page-load-status', 1313 debug: true 1314 }; 1315 $container.infiniteScroll( infiniteData ); 1316 1317 }else{ 1318 1319 // Init Infinite Scroll 1320 $container.infiniteScroll({ 1321 path: '#' + $element.parent().data( 'containerId' ) + ' .cl-pagination-infinite .older-posts a', 1322 append: '#' + $element.parent().data( 'containerId' ) + ' .cl-entry', 1323 loadOnScroll: true, 1324 outlayer: iso, 1325 status: '#' + $element.parent().data( 'containerId' ) + ' .page-load-status' 1326 }); 1327 1328 1329 } 1330 1331 $container.on( 'append.infiniteScroll', function( event, response, path, items ) { 1332 CL_FRONT.postSwiper( $(items).find('.cl-entry__gallery .cl-carousel') ); 1333 1334 1335 setTimeout(function(){ 1336 $container.isotope('arrange'); 1337 CL_FRONT.animations( $('#' + $element.parent().data( 'containerId' ) ) ); 1338 }, 50); 1339 1340 }); 1341 1342 1343 1344 } ); 1345 1346 } ); 1347 } 1348 1349 }; 1350 1351 CL_FRONT.paginationInfiniteInitBlocks = function(){ 1352 "use strict"; 1353 1354 if( $('.cl-blog--module-grid-blocks').length > 0 ){ 1355 $('.cl-blog--module-grid-blocks').each(function(){ 1356 if( $(this).find( '.cl-pagination-infinite' ).length > 0 ) 1357 CL_FRONT.paginationInfinite( $(this).find( '.cl-pagination-infinite' ) ); 1358 }); 1359 } 1360 }; 1361 1362 1363 CL_FRONT.nextPrevAjax = function(){ 1364 "use strict"; 1365 1366 if( $('.cl-pagination-jump.ajax').length == 0 ) 1367 return; 1368 1369 var $next = $('.cl-pagination-jump.ajax').find('.older-posts a'); 1370 var $prev = $('.cl-pagination-jump.ajax').find('.newer-posts a'); 1371 1372 var container_id = $('.cl-pagination-jump.ajax').parent().data('containerId'); 1373 var $container = $('#'+container_id); 1374 var $items_container = $('#'+container_id).find('.cl-items-container'); 1375 1376 $next.on('click', nextFunc); 1377 $prev.on('click', prevFunc); 1378 1379 function nextFunc(e){ 1380 e.preventDefault(); 1381 1382 var height = $items_container.height(); 1383 $items_container.find( 'article' ).remove(); 1384 $items_container.height(height + 'px'); 1385 $items_container.prepend('<div class="cl-md-loading"><div class="md-preloader"><svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="48" width="48" viewbox="0 0 75 75"><circle cx="37.5" cy="37.5" r="33.5" stroke-width="6"/></svg></div></div>'); 1386 1387 $.get( $next.attr('href'), handleAjax, 'html' ); 1388 } 1389 1390 function prevFunc(e){ 1391 e.preventDefault(); 1392 1393 var height = $items_container.height(); 1394 $items_container.find( 'article' ).remove(); 1395 $items_container.height(height + 'px'); 1396 $items_container.prepend('<div class="cl-md-loading"><div class="md-preloader"><svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="48" width="48" viewbox="0 0 75 75"><circle cx="37.5" cy="37.5" r="33.5" stroke-width="6"/></svg></div></div>'); 1397 1398 $.get( $prev.attr('href'), handleAjax, 'html' ); 1399 } 1400 1401 function handleAjax(data){ 1402 1403 $items_container.find('md-preloader').remove(); 1404 $items_container.html( $(data).find('#'+container_id).find('.cl-items-container').html() ); 1405 $items_container.css('height', ''); 1406 1407 if( $container.hasClass('cl-blog--module-isotope') ){ 1408 $('#'+container_id).find('.cl-items-container').isotope('destroy'); 1409 setTimeout(function(){ 1410 CL_FRONT.isotopeBlogGrid( $('#'+container_id) ); 1411 }, 10); 1412 }else{ 1413 CL_FRONT.animations(); 1414 } 1415 1416 1417 $('#'+container_id + ' .cl-blog-pagination').html( $(data).find( '#'+container_id + ' .cl-blog-pagination' ).html() ); 1418 1419 $next = $('.cl-pagination-jump.ajax').find('.older-posts a'); 1420 $prev = $('.cl-pagination-jump.ajax').find('.newer-posts a'); 1421 $next.on('click', nextFunc); 1422 $prev.on('click', prevFunc); 1423 CL_FRONT.postInit(); 1424 } 1425 }; 1426 1427 1428 CL_FRONT.filtersAjax = function(){ 1429 "use strict"; 1430 1431 if( $('.cl-filter--ajax').length == 0 ) 1432 return; 1433 1434 var $buttons = $('.cl-filter--ajax a'); 1435 1436 1437 $buttons.on( 'click', handleClick ); 1438 1439 function handleClick( e ){ 1440 e.preventDefault(); 1441 var $items_container = $(this).closest('.cl-blog').find('.cl-items-container'); 1442 1443 var container_id = $items_container.parent().attr('id'); 1444 1445 $buttons.removeClass('active'); 1446 var height = $items_container.height(); 1447 $items_container.find( 'article' ).remove(); 1448 $items_container.height(height + 'px'); 1449 $items_container.prepend('<div class="cl-md-loading"><div class="md-preloader"><svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="48" width="48" viewbox="0 0 75 75"><circle cx="37.5" cy="37.5" r="33.5" stroke-width="6"/></svg></div></div>'); 1450 1451 1452 1453 $.get( $(this).attr('href'), function(data){ 1454 1455 1456 $items_container.find('md-preloader').remove(); 1457 $items_container.html( $(data).find('#'+container_id + ' .cl-items-container').html() ); 1458 $items_container.css('height', ''); 1459 if( $items_container.parent().hasClass('cl-blog--module-isotope') ){ 1460 1461 1462 $('#'+container_id + ' .cl-items-container').isotope('destroy'); 1463 1464 setTimeout(function(){ 1465 CL_FRONT.isotopeBlogGrid( $('#'+container_id) ); 1466 }, 10); 1467 }else{ 1468 CL_FRONT.animations(); 1469 } 1470 1471 1472 1473 $('[data-container-id="'+container_id + '"].cl-blog-pagination').html( $(data).find( '[data-container-id="'+container_id + '"].cl-blog-pagination' ).html() ); 1474 1475 setTimeout( function(){ 1476 1477 CL_FRONT.isotopeBlogGrid( $('#'+container_id) ); 1478 CL_FRONT.nextPrevAjax(); 1479 }, 100); 1480 1481 }, 'html' ); 1482 1483 $(this).addClass('active'); 1484 } 1485 } 1486 1487 1488 /** 1489 * Blog Grid and Masonry Isotope 1490 * Use the Isotope component 1491 * 1492 * @since 1.0.0 1493 */ 1494 CL_FRONT.isotopeBlogGrid = function( $el ) { 1495 "use strict"; 1496 var $blog = $el; 1497 if( typeof $el === 'undefined' ) 1498 $blog = $('.cl-blog'); 1499 1500 1501 1502 $blog.each(function(){ 1503 var $blog_items_list = $(this).find( '.cl-items-container' ); 1504 if( $(this).hasClass('cl-blog--module-carousel') ){ 1505 1506 CL_FRONT.components.Carousel( $blog_items_list , false, function(owl, el){ 1507 CL_FRONT.postSwiper(el); 1508 owl.on('resized.owl.carousel', function(event){ 1509 CL_FRONT.animations( el.find( '.owl-item.active' ), true ); 1510 }); 1511 }); 1512 1513 1514 1515 }else if( $(this).hasClass('cl-blog--module-isotope') ){ 1516 CL_FRONT.components.Isotope( $blog_items_list , function(){ 1517 1518 } ); 1519 } 1520 1521 1522 }); 1523 1524 }; 1525 1526 /** 1527 * Isotope Portfolio Init 1528 * used on Customizer too 1529 * 1530 * @since 1.0.0 1531 */ 1532 CL_FRONT.isotopePortfolioGrid = CL_FRONT.init_cl_portfolio = function( $el ) { 1533 "use strict"; 1534 $( '.cl-portfolio .cl-portfolio__items' ).each(function(){ 1535 if( $(this).hasClass('cl-carousel') ) 1536 CL_FRONT.components.Carousel( $( this ) ); 1537 else if( $(this).hasClass('cl-justify-gallery') ) 1538 CL_FRONT.components.JustifyGallery( $( this ) ); 1539 else 1540 CL_FRONT.components.Isotope( $( this ) ); 1541 1542 }); 1543 1544 if( CL_FRONT.config.$isMobileScreen ){ 1545 $('.portfolio_item .entry-link').attr('onClick', 'return false'); 1546 $('.portfolio_item').each(function(){ 1547 $(this).on('mousemove', function(){ 1548 if( parseInt( $(this).find( '.entry-overlay' ).css('opacity') ) == 1 ){ 1549 1550 $(this).find('.entry-link').attr('onClick', ''); 1551 } 1552 else 1553 $(this).find('.entry-link').attr('onClick', 'return false'); 1554 }) 1555 }) 1556 } 1557 1558 1559 }; 1560 1561 1562 1563 CL_FRONT.codelessToggles = CL_FRONT.init_cl_toggles = function(){ 1564 "use strict"; 1565 $('.cl_toggles').each(function(){ 1566 var $toggles = $(this); 1567 CL_FRONT.components.loadDependencies( [ codeless_global.FRONT_LIB_JS + 'jquery.collapse.js' ], function() { 1568 1569 $toggles.collapse({ 1570 open: function() { 1571 // The context of 'this' is applied to 1572 // the collapsed details in a jQuery wrapper 1573 this.slideDown(200); 1574 }, 1575 close: function() { 1576 this.slideUp(200); 1577 }, 1578 accordion: CL_FRONT.helpers.parseData( $toggles.attr('data-accordion'), false ), 1579 query: '.cl_toggle .title' 1580 }); 1581 }); 1582 }); 1583 }; 1584 1585 1586 /** 1587 * Sticky Sidebar Function 1588 * 1589 * @since 1.0.0 1590 */ 1591 CL_FRONT.stickySidebar = function() { 1592 "use strict"; 1593 1594 $('.cl-sticky').each(function(index, e){ 1595 if( !CL_FRONT.config.$isMobileScreen ){ 1596 1597 if( typeof CL_FRONT.config.$asideArray[index] == 'undefined' ) 1598 CL_FRONT.config.$asideArray[index] = { height: 0, top: 0, stickyOffset: 0, current_window: 0 }; 1599 1600 if( CL_FRONT.config.$asideArray[index].height == 0 ) 1601 CL_FRONT.config.$asideArray[index].height = $(this).data( 'stickyOffset' ) != 0 ? $(this).height() + $(this).offset().top - $(this).find( '.widget:nth-last-child(' + parseInt( $(this).data( 'stickyOffset' ) ) + ')' ).offset().top : $(this).height(); 1602 1603 if( CL_FRONT.config.$asideArray[index].top == 0 ) 1604 CL_FRONT.config.$asideArray[index].top = $(this).offset().top; 1605 1606 if( CL_FRONT.config.$asideArray[index].stickyOffset == 0 ) 1607 CL_FRONT.config.$asideArray[index].stickyOffset = $(this).data( 'stickyOffset' ) != 0 ? $(this).find( '.widget:nth-last-child(' + parseInt( $(this).data( 'stickyOffset' ) ) + ')' ).offset().top : 0; 1608 1609 var cl_distace = 80, 1610 cl_point = 0; 1611 1612 if ( CL_FRONT.config.$asideArray[index].stickyOffset != 0 ) 1613 cl_point = CL_FRONT.config.$asideArray[index].stickyOffset; 1614 else 1615 cl_point = CL_FRONT.config.$asideArray[index].top - cl_distace; 1616 1617 1618 $(this).find( '.cl-sticky-wrapper' ).width( $(this).width() + 'px' ); 1619 1620 var $content_container = $('.content-col'); 1621 if( $(this).closest( '.wpb_row' ).length > 0 ) 1622 $content_container = $(this).closest( '.wpb_row' ); 1623 var content_offset = $content_container.offset().top + $content_container.height(); 1624 1625 1626 if( content_offset > ( CL_FRONT.config.$windowTop + CL_FRONT.config.$asideArray[index].height ) ){ 1627 if ( CL_FRONT.config.$windowTop >= cl_point ) { 1628 $(this).addClass( 'cl-sticky-active' ); 1629 $(this).find( '.cl-sticky-wrapper' ).css( 'to
1629p', '-' + ( cl_point - CL_FRONT.config.$asideArray[index].top ) + 'px' ); 1630 CL_FRONT.config.$asideArray[index].current_top = ( cl_point - CL_FRONT.config.$asideArray[index].top ); 1631 1632 } else { 1633 $(this).find( '.cl-sticky-wrapper' ).css( 'top', cl_distace + 'px' ); 1634 $(this).removeClass( 'cl-sticky-active' ); 1635 } 1636 }else{ 1637 if( CL_FRONT.config.$asideArray[index].current_window == 0 ) 1638 CL_FRONT.config.$asideArray[index].current_window = CL_FRONT.config.$windowTop; 1639 1640 var plus_offset = CL_FRONT.config.$windowTop - CL_FRONT.config.$asideArray[index].current_window; 1641 if( plus_offset < 0 ) 1642 plus_offset = 0; 1643 1644 $(this).find( '.cl-sticky-wrapper' ).css('top',-(CL_FRONT.config.$asideArray[index].current_top + plus_offset) ); 1645 } 1646 } 1647 }); 1648 } 1649 1650 1651 /** 1652 * Sticky Column Function 1653 * 1654 * @since 1.0.0 1655 * 1656 */ 1657 1658 1659 CL_FRONT.stickyColumn = function() { 1660 "use strict"; 1661 1662 if(!this.config.$isMobileScreen && $('.cl-sticky.cl_column').length > 0){ 1663 1664 $('.cl-sticky.cl_column').each( function(){ 1665 var $sticky = $(this), 1666 stickyTop = 0, 1667 stickyHeight = 0; 1668 1669 1670 stickyHeight = $sticky.height(); 1671 1672 stickyTop = $sticky.offset().top; 1673 1674 1675 var cl_distace = 0, 1676 cl_point = 0; 1677 1678 cl_point = stickyTop - cl_distace; 1679 1680 $sticky.find( '.cl_col_wrapper ' ).width( $sticky.width() + 'px' ); 1681 1682 if ( CL_FRONT.config.$windowTop >= cl_point ) { 1683 $sticky.addClass( 'cl-sticky-active' ); 1684 $sticky.find( '.cl_col_wrapper' ).css( 'top', '-' + ( cl_point - stickyTop ) + 'px' ); 1685 1686 } else { 1687 $sticky.find( '.cl_col_wrapper' ).css( 'top', cl_distace + 'px' ); 1688 $sticky.removeClass( 'cl-sticky-active' ); 1689 } 1690 1691 1692 }); 1693 } 1694 } 1695 1696 1697 /** 1698 * Progress Bar Function 1699 * 1700 * @since 1.0.0 1701 * 1702 */ 1703 1704 CL_FRONT.progressBar = function($el){ 1705 "use strict"; 1706 1707 var from_start = $el == null ? true : false; 1708 var $elements = CL_FRONT.helpers.parseData( $el, $( '.cl_progress_bar' ) ); 1709 1710 if( $elements.length > 0 ){ 1711 $elements.each(function(){ 1712 1713 var $element = $(this), 1714 percentage = $element.attr('data-percentage'); 1715 1716 if( from_start && $element.hasClass('cl-animate-on-visible') ) 1717 return; 1718 1719 $element.find('.percentage').html(percentage+'%'); 1720 $element.find('.bar').css('width', percentage+'%'); 1721 }); 1722 } 1723 }; 1724 1725 1726 CL_FRONT.mediaElement = CL_FRONT.init_cl_media = function(){ 1727 "use strict"; 1728 1729 if( $('.cl_media.type-video').length > 0 ){ 1730 $('.cl_media.type-video').each(function(){ 1731 1732 var $element = $(this), 1733 $play = $element.find( '.play-button' ), 1734 $isPlay = ($play.length > 0) ? true : false; 1735 1736 if( $isPlay ){ 1737 1738 $element.addClass('hide-video'); 1739 1740 setTimeout(function(){ 1741 var height = $element.find( 'iframe, video' ).height(); 1742 $element.height(height); 1743 }, 50); 1744 1745 $play.on('click', function(e){ 1746 e.preventDefault(); 1747 1748 $element.find( 'source, iframe' ).each(function(){ 1749 var src = $(this).attr('data-src'); 1750 $(this).attr('src', src); 1751 }); 1752 1753 setTimeout(function(){ 1754 $element.addClass('show-video'); 1755 }, 100); 1756 1757 1758 }); 1759 }else{ 1760 $element.find( 'source, iframe' ).each(function(){ 1761 var src = $(this).attr('data-src'); 1762 $(this).attr('src', src); 1763 }); 1764 } 1765 1766 1767 1768 }); 1769 } 1770 1771 1772 1773 1774 }; 1775 1776 1777 /** 1778 * Init Page Header Element 1779 * Used on Codeless Builder Too 1780 * @since 1.0.0 1781 */ 1782 CL_FRONT.init_cl_page_header = function(){ 1783 1784 this.fixPageHeaderCenter(); 1785 CL_FRONT.components.loadAnimation( $( '.cl_page_header' ), function(){ 1786 CL_FRONT.pageHeaderParallax(); 1787 } ); 1788 1789 }; 1790 1791 /** 1792 * Page Header Parallax 1793 * Loads the Parallax component 1794 * @since 1.0.0 1795 */ 1796 1797 CL_FRONT.pageHeaderParallax = function() { 1798 "use strict"; 1799 1800 if ( $( '.cl_page_header.cl-parallax .bg-layer' ).length > 0 ) 1801 CL_FRONT.components.Parallax( $( '.cl_page_header.cl-parallax .bg-layer' ) ).init(); 1802 }; 1803 1804 1805 CL_FRONT.fixPageHeaderCenter = function(){ 1806 if( this.config.$header.hasClass('cl-transparent') && $( '.cl_page_header' ).length > 0 ){ 1807 var $pageHeader = $( '.cl_page_header' ); 1808 1809 if( $pageHeader.hasClass('modern') ) 1810 $pageHeader.css( { paddingTop: (this.config.$headerHeight / 2) + 'px' } ); 1811 } 1812 } 1813 1814 1815 /** 1816 * Fix Megamenu Position when is out from container 1817 * @since 1.0.0 1818 */ 1819 CL_FRONT.fixMegaMenuPosition = function( menu ){ 1820 "use strict"; 1821 1822 var fixMegaMenu = function(megamenu){ 1823 var width = $( megamenu ).find('> .sub-menu').width(), 1824 liParent = $( megamenu ).parent( 'li' ), 1825 1826 mega_columns = $( megamenu ).children('ul').children('li'), 1827 columns = mega_columns.length, 1828 column_width = width / columns, 1829 mega_menu_layout = 'boxed', 1830 bg_image = liParent.data('bg'), 1831 bg_type = $( megamenu ).hasClass('cl-header__menu__megamenu--background') ? 'background' : 'column', 1832 offsetFromLi = liParent.offset().left - CL_FRONT.config.$containerOffsetLeft; 1833 1834 1835 1836 if( mega_menu_layout == 'boxed' ){ 1837 width = $( megamenu ).width() - 40; 1838 column_width = width / columns; 1839 if( width == CL_FRONT.config.$containerWidth ) 1840 $( megamenu ).css( { left: '-' + offsetFromLi + 'px' } ); 1841 else { 1842 setTimeout(function(){ 1843 1844 var offsetOutFromContainer = Math.abs( (CL_FRONT.config.$containerOffsetLeft + CL_FRONT.config.$containerWidth) - ( liParent.offset().left + width ) ); 1845 1846 if( offsetOutFromContainer > offsetFromLi ) 1847 offsetOutFromContainer = 0; 1848 1849 $( megamenu ).css( { left: '-' + (offsetOutFromContainer + 20) + 'px' } ); 1850 }, 1); 1851 } 1852 }else{ 1853 $( megamenu ).css( { left: '-' + liParent.offset().left + 'px', width: CL_FRONT.config.$windowWidth + 'px'} ); 1854 $( megamenu ).find('> .sub-menu').css({width:'1170px', margin: '0 auto'}); 1855 1856 } 1857 1858 if( bg_image != '' && bg_type == 'background' ){ 1859 $( megamenu ).css({"background-image": 'url("'+bg_image+'")'}); 1860 } 1861 1862 mega_columns.css( { width: column_width + 'px'} ); 1863 }; 1864 1865 if( ! menu ){ 1866 this.config.$navigation.find( '.cl-header__menu__megamenu' ).each( function( index, megamenu ){ 1867 1868 fixMegaMenu( megamenu ); 1869 1870 } ); 1871 }else{ 1872 fixMegaMenu( menu ); 1873 } 1874 }; 1875 1876 1877 /** 1878 * Initialize Tools Dropdown in Responsive 1879 * 1880 * @since 1.0.0 1881 */ 1882 1883 CL_FRONT.initToolsResponsive = function() { 1884 "use strict"; 1885 var self = this; 1886 1887 1888 if( this.config.$windowWidth <= 991 ){ 1889 1890 if( this.config.$headerToolsInit ) 1891 return; 1892 1893 this.config.$headerTools.find( '.cl-header__tool .cl-submenu' ).each(function(){ 1894 var submenu = $(this); 1895 submenu.addClass('cl-hide-on-mobile'); 1896 1897 var responsiveMenu = submenu.clone().appendTo(CL_FRONT.config.$header); 1898 responsiveMenu.removeClass( 'cl-hide-on-mobile' ).addClass( 'cl-mobile-menu' ); 1899 1900 1901 CL_FRONT.config.$headerToolsList.push(submenu); 1902 submenu.closest('.cl-header__tool').find(' > i, > .cl-header__tool__link').on( 'click', function( e ){ 1903 e.preventDefault(); 1904 1905 var button = $(this); 1906 responsiveMenu.slideToggle('200'); 1907 1908 } ); 1909 }); 1910 1911 this.config.$headerToolsInit = true; 1912 1913 }else{ 1914 this.config.$header.find('.cl-mobile-menu').addClass('cl-hide-not-mobile'); 1915 1916 if( CL_FRONT.config.$headerToolsList.length > 0 ){ 1917 CL_FRONT.config.$headerToolsList.forEach( function(menu){ 1918 menu.closest('.cl-header__tool').find(' > i, > .cl-header__tool__link').off('click'); 1919 menu.closest('.cl-header__tool').find(' > i, > .cl-header__tool__link').on('click', function(e){ 1920 return true; 1921 }); 1922 } ); 1923 } 1924 } 1925 1926 } 1927 1928 /** 1929 * Tools Dropdown init 1930 * @since 1.0.0 1931 */ 1932 1933 CL_FRONT.initToolsDropdown = function() { 1934 "use strict"; 1935 1936 var toOpen = null, 1937 isOpen = false, 1938 mainNode = null; 1939 1940 1941 this.config.$headerTools.find( '.cl-header__tool' ).each( function( index, submenu ) { 1942 1943 if ( $( submenu ).find( '.cl-submenu' ).length > 0 ) { 1944 $( submenu ).addClass( 'has-submenu' ); 1945 } 1946 1947 } ); 1948 1949 mainNode = this.config.$headerTools[0]; 1950 1951 this.config.$headerTools.mouseover( function( e ) { 1952 1953 var item = e.target || e.srcElement; 1954 1955 while ( ! $(item).hasClass('cl-header__tool') && item != mainNode ) { 1956 item = item.parentNode; 1957 } 1958 1959 if ( $(item).hasClass('cl-header__tool') ) { 1960 toOpen = item; 1961 open(); 1962 } 1963 1964 } ).mouseleave( function() { 1965 close(toOpen); 1966 } ); 1967 1968 var open = function() { 1969 isOpen = true; 1970 1971 // Get other items with same parent 1972 var items = $( toOpen ).parent().children( '.cl-header__tool' ); 1973 1974 $( items ).each( function( index, item ) { 1975 $( item ).find( ".cl-submenu" ).each( function( index, submenu ) { 1976 if ( item != toOpen ) { 1977 $( item ).removeClass( "show-dropdown" ); 1978 close( item ); 1979 1980 } else 1981 if ( !$( item ).hasClass( 'show-dropdown' ) ) { 1982 1983 1984 1985 $( item ).addClass( "show-dropdown" ); 1986 1987 1988 var left = 0; 1989 var node = submenu; 1990 while ( node ) { 1991 1992 left += Math.abs( node.offsetLeft ); 1993 node = node.offsetParent; 1994 } 1995 var right = left + submenu.offsetWidth; 1996 1997 1998 //We should refactor this code to execute only when menu is vertical 1999 var menuHeight = $( submenu ).outerHeight(); 2000 var parentTop = $( submenu ).offset().top - $( window ).scrollTop(); 2001 var totalHeight = menuHeight + parentTop; 2002 var windowHeight = window.innerHeight; 2003 2004 2005 2006 $( item ).removeClass( 'show-dropdown--right-to-left' ); 2007 2008 if ( left < 0 ) $( item ).addClass( 'show-dropdown--left-to-left' ); 2009 2010 if ( right > CL_FRONT.config.$containerOffsetLeft + CL_FRONT.config.$containerWidth ) { 2011 $( item ).addClass( 'show-dropdown--right-to-left' ); 2012 } 2013 2014 if( $( item ).parents( '.show-dropdown' ).length > 0 ){ 2015 var width = $( item ).parents( '.show-dropdown' ).first().children('.cl-submenu').width(); 2016 2017 if( $( item ).hasClass( 'show-dropdown--left-to-right' ) || ( ! $( item ).hasClass( 'show-dropdown--left-to-right' ) && ! $( item ).hasClass( 'show-dropdown--right-to-left' ) ) ) 2018 $( item ).find( ".cl-submenu" ).css( { left: (width+16)+'px' } ); 2019 if( $( item ).hasClass( 'show-dropdown--right-to-left' ) ) 2020 $( item ).find( "cl-submenu" ).css( { right: (width+16)+'px' } ); 2021 } 2022 2023 } 2024 } ); 2025 } ); 2026 }; 2027 2028 var close = function( node ) { 2029 if (!node) { 2030 isOpen = false;
2031 node = mainNode; 2032 } 2033 2034 // loop over the items, closing their submenus 2035 $(node).find('.cl-header__tool').each(function(index, item) { 2036 $(item).removeClass('show-dropdown'); 2037 }); 2038 2039 if( $(node).hasClass('cl-header__tool') ) 2040 $(node).removeClass('show-dropdown'); 2041 } 2042 2043 }; 2044 2045 2046 /** 2047 * Menu Dropdown init 2048 * @since 1.0.0 2049 */ 2050 2051 CL_FRONT.initMenuDropdown = function() { 2052 "use strict"; 2053 2054 var toOpen = null, 2055 isOpen = false, 2056 mainNode = null, 2057 subHeights = []; 2058 2059 2060 this.config.$navigation.find( 'ul > li' ).each( function( index, submenu ) { 2061 2062 if ( $( submenu ).find( 'ul' ).length > 0 ) { 2063 $( submenu ).addClass( 'has-submenu' ); 2064 $( submenu ).find( '> a' ).addClass('anchor-submenu'); 2065 if( $( submenu ).parents('.cl-dropdown-inline').length > 0 ){ 2066 //$( submenu ).find('ul').slideUp(); 2067 } 2068 } 2069 2070 } ); 2071 2072 mainNode = this.config.$navigation[0]; 2073 2074 this.config.$navigation.mouseover( function( e ) { 2075 2076 var item = e.target || e.srcElement; 2077 2078 while ( item.nodeName != 'LI' && item != mainNode ) { 2079 item = item.parentNode; 2080 } 2081 2082 if ( item.nodeName == 'LI' ) { 2083 toOpen = item; 2084 open(); 2085 } 2086 2087 } ).mouseleave( function() { 2088 close(); 2089 } ); 2090 2091 var open = function() { 2092 isOpen = true; 2093 2094 // Get other items with same parent 2095 var items = $( toOpen ).parent().children( 'li' ); 2096 2097 $( items ).each( function( index, item ) { 2098 $( item ).find( "ul" ).each( function( index, submenu ) { 2099 2100 if ( item != toOpen ) { 2101 if( $( item ).parents('.cl-dropdown-inline').length > 0 ){ 2102 2103 $( submenu ).animate( {height: '0px' }, 20); 2104 } 2105 $( item ).removeClass( "show-dropdown" ); 2106 2107 close( item ); 2108 2109 } else if ( !$( item ).hasClass( 'show-dropdown' ) ) { 2110 2111 if( $( item ).children( '.cl-header__menu__megamenu' ).length > 0 ){ 2112 CL_FRONT.fixMegaMenuPosition( $( item ).children( '.cl-header__menu__megamenu' )[0] ); 2113 } 2114 2115 $( item ).addClass( "show-dropdown" ); 2116 2117 2118 var left = 0; 2119 var node = submenu; 2120 while ( node ) { 2121 2122 left += Math.abs( node.offsetLeft ); 2123 node = node.offsetParent; 2124 } 2125 var right = left + submenu.offsetWidth; 2126 2127 var menuHeight = $( submenu ).outerHeight(); 2128 var innerHeight = $( submenu ).innerHeight(); 2129 var parentTop = $( submenu ).offset().top - $( window ).scrollTop(); 2130 var totalHeight = menuHeight + parentTop; 2131 var windowHeight = window.innerHeight; 2132 2133 /* Vetical Inline submenu */ 2134 if( $( item ).parents('.cl-dropdown-inline').length > 0 ){ 2135 $( submenu ).css('display', 'none').css('height', 'auto'); 2136 var h = $( submenu ).outerHeight(); 2137 2138 $( submenu ).css('height', 0).css('display', 'block'); 2139 $( submenu ).animate( {height: h + 'px' }, 100); 2140 } 2141 2142 $( item ).removeClass( 'show-dropdown--right-to-left' ); 2143 2144 if ( left < 0 ) $( item ).addClass( 'show-dropdown--left-to-right' ); 2145 2146 if ( right > document.body.clientWidth ) { 2147 $( item ).addClass( 'show-dropdown--right-to-left' ); 2148 } 2149 2150 if( $( item ).parents( '.show-dropdown' ).length > 0 && $( item ).parents( '.cl-header__menu__megamenu' ).length == 0 ){ 2151 var width = $( item ).parents( '.show-dropdown' ).first().children('ul').width(); 2152 2153 if( $( item ).hasClass( 'show-dropdown--left-to-right' ) || ( ! $( item ).hasClass( 'show-dropdown--left-to-right' ) && ! $( item ).hasClass( 'show-dropdown--right-to-left' ) ) ) 2154 $( item ).find( "ul" ).css( { left: (width+16)+'px' } ); 2155 if( $( item ).hasClass( 'show-dropdown--right-to-left' ) ) 2156 $( item ).find( "ul" ).css( { right: (width+16)+'px' } ); 2157 } 2158 2159 } 2160 } ); 2161 } ); 2162 }; 2163 2164 var close = function( node ) { 2165 if (!node) { 2166 isOpen = false;
2167 node = mainNode; 2168 } 2169 2170 // loop over the items, closing their submenus 2171 $(node).find('li').each(function(index, item) { 2172 if( $( item ).parents('.cl-dropdown-inline').length > 0 ) 2173 $(item).find('.sub-menu').css('height', 0); 2174 2175 $(item).removeClass('show-dropdown'); 2176 }); 2177 } 2178 2179 } 2180 2181 /** 2182 * Initialize Lightbox Elements 2183 * @since 1.0.0 2184 */ 2185 CL_FRONT.itemILightBox = function(){ 2186 "use strict"; 2187 var el = $( '.cl-lightbox' ); 2188 2189 if( el.length > 0 ){ 2190 CL_FRONT.components.LightBox( el ); 2191 } 2192 } 2193 2194 /** 2195 * Convert SVG to Animated Items 2196 * @since 1.0.0 2197 */ 2198 CL_FRONT.convertSVGAnimated = function(){ 2199 "use strict"; 2200 2201 if( $('svg.animated').length > 0 && ! CL_FRONT.config.$isCustomizer ){ 2202 2203 CL_FRONT.components.loadDependencies( [ codeless_global.FRONT_LIB_JS + 'svg4everybody.js' ], function() { 2204 2205 svg4everybody({polyfill: true}); 2206 var id = 0; 2207 2208 $('svg').each(function(index, item){ 2209 if( $(item).hasClass('animated') ){ 2210 CL_FRONT.components.loadDependencies( [ codeless_global.FRONT_LIB_JS + 'vivus.min.js' ], function() { 2211 id = 'svg_animated_' + index; 2212 $(item).attr('id', id); 2213 new Vivus( id, {duration: 200} ); 2214 }); 2215 } 2216 }); 2217 2218 }); 2219 } 2220 2221 } 2222 2223 /** 2224 * Initialize Google Map 2225 * @since 1.0.0 2226 */ 2227 CL_FRONT.codelessGMap = CL_FRONT.init_cl_map = function(){ 2228 "use strict"; 2229 2230 if( $('.cl_map').length > 0 ){ 2231 $('.cl_map').each(function(){ 2232 var $el = $(this); 2233 2234 var map = $el.find('.cl-map-element').first()[0]; 2235 2236 var data = {}; 2237 2238 data.style = CL_FRONT.helpers.parseData( $el.attr('data-style'), '' ), 2239 data.latitude = $el.attr('data-lat'), 2240 data.longitude = $el.attr('data-lon'), 2241 data.map_zoom = CL_FRONT.helpers.parseData( $el.attr('data-zoom'), '4' ); 2242 2243 2244 CL_FRONT.components.loadDependencies( [ codeless_global.FRONT_LIB_JS + 'codeless-gmaps.js' ], function() { 2245 2246 CL_FRONT.codelessInitMap( map, data ); 2247 2248 }); 2249 2250 }); 2251 } 2252 } 2253 2254 2255 2256 /** 2257 * Contact Form Submit Button add neccessary classes 2258 * @since 1.0.0 2259 */ 2260 CL_FRONT.contactForm = function(){ 2261 if( $('.wpcf7-form').length > 0 ){ 2262 $('.wpcf7-form').each(function(){ 2263 var $form = $(this); 2264 2265 $form.find('.wpcf7-submit').addClass(codeless_global.cl_btn_classes); 2266 }); 2267 } 2268 2269 } 2270 2271 2272 /** 2273 * Add appropiate btn classes to shop widgets 2274 * @since 1.0.0 2275 */ 2276 CL_FRONT.shopBtnClasses = function(){ 2277 2278 var $btn = $('.widget_shopping_cart_content .button'), 2279 $btn2 = $('.price_slider_amount .button'); 2280 2281 if( $btn.length > 0 ) 2282 $btn.addClass(codeless_global.cl_btn_classes).removeClass("btn-layout-large").addClass('btn-layout-small').removeClass('btn-font-medium').addClass('btn-font-small'); 2283 if( $btn2.length > 0 ) 2284 $btn2.addClass(codeless_global.cl_btn_classes).removeClass("btn-layout-large").addClass('btn-layout-small').removeClass('btn-font-medium').addClass('btn-font-small'); 2285 2286 CL_FRONT.config.$body.on('added_to_cart', function(){ 2287 CL_FRONT.shopBtnClasses(); 2288 }); 2289 } 2290 2291 2292 /** 2293 * Row Parallax Initialize 2294 * @since 1.0.0 2295 */ 2296 CL_FRONT.rowParallax = function() { 2297 "use strict"; 2298 if ( $( '.cl-row.cl-parallax > .bg-layer' ).length > 0 ){ 2299 $( '.cl-row.cl-parallax > .bg-layer' ).each(function(){ 2300 CL_FRONT.components.Parallax( $( this ) ).init(); 2301 }) 2302 2303 } 2304 }; 2305 2306 2307 /** 2308 * Creative Search 2309 * @since 1.0.0 2310 */ 2311 CL_FRONT.creativeSearch = function(){ 2312 'use strict'; 2313 2314 if( $('.search-style-creative').length == 0 ) 2315 return; 2316 2317 2318 var mainContainer = document.querySelector('#wrapper'), 2319 openCtrl = document.getElementById('header_search_btn'), 2320 closeCtrl = document.getElementById('btn-search-close'), 2321 searchContainer = document.querySelector('.creative-search'); 2322 2323 if( searchContainer === null ) 2324 return; 2325 2326 var inputSearch = searchContainer.querySelector('.search__input'); 2327 2328 var init = function() { 2329 2330 initEvents(); 2331 } 2332 2333 var initEvents = function() { 2334 2335 openCtrl.addEventListener('click', openSearch); 2336 closeCtrl.addEventListener('click', closeSearch); 2337 document.addEventListener('keyup', function(ev) { 2338 // escape key. 2339 if( ev.keyCode == 27 ) { 2340 closeSearch(); 2341 } 2342 }); 2343 } 2344 2345 var openSearch = function(e) { 2346 e.preventDefault(); 2347 2348 mainContainer.classList.add('main-wrap--hide'); 2349 searchContainer.classList.add('search--open'); 2350 setTimeout(function() { 2351 inputSearch.focus(); 2352 }, 500); 2353 } 2354 2355 var closeSearch = function() { 2356 mainContainer.classList.remove('main-wrap--hide'); 2357 searchContainer.classList.remove('search--open'); 2358 inputSearch.blur(); 2359 inputSearch.value = ''; 2360 } 2361 2362 init(); 2363 2364 }; 2365 2366 2367 CL_FRONT.preloadOdometer = CL_FRONT.init_cl_counter = function(){ 2368 "use strict"; 2369 if( $('.cl_counter') ){ 2370 CL_FRONT.components.loadDependencies( [ codeless_global.FRONT_LIB_JS + 'odometer.min.js' ], function() { 2371 2372 }); 2373 } 2374 }; 2375 2376 2377 /** 2378 * initialize Countdown 2379 * @since 1.0.2 2380 */ 2381 CL_FRONT.countdownElement = CL_FRONT.init_cl_countdown = function(){ 2382 "use strict"; 2383 if( $('.cl_countdown').length > 0 ){ 2384 CL_FRONT.components.loadDependencies( [ codeless_global.FRONT_LIB_JS + 'jquery.countdown.min.js' ], function() { 2385 $('.cl_countdown').each(function(){ 2386 var dt = $(this).data('dt'); 2387 $(this).countdown(dt, function(event) { 2388 var $this = $(this).html(event.strftime('' 2389 + '<span class="group"><span class="value">%w</span> <span class="type">weeks</span></span>' 2390 + '<span class="group"><span class="value">%d</span> <span class="type">days</span></span>' 2391 + '<span class="group"><span class="value">%H</span> <span class="type">hours</span></span>' 2392 + '<span class="group"><span class="value">%M</span> <span class="type">min</span></span>' 2393 + '<span class="group"><span class="value">%S</span> <span class="type">sec</span></span>')); 2394 }); 2395 }); 2396 }); 2397 } 2398 }; 2399 2400 /** 2401 * Initialize Odometer counter 2402 * @since 1.0.0 2403 */ 2404 CL_FRONT.codelessCounter = function(el){ 2405 "use strict"; 2406 var element = el; 2407 CL_FRONT.preloadOdometer(); 2408 setTimeout(function(el){ 2409 2410 var odometer = element.find('.odometer').first(); 2411 var number = odometer.data('number'); 2412 var duration = odometer.data('duration'); 2413 2414 var el = odometer[0]; 2415 2416 var od = new Odometer({ 2417 el: el, 2418 value: 0, 2419 duration: duration, 2420 2421 // Any option (other than auto and selector) can be passed in here 2422 format: '', 2423 theme: 'minimal' 2424 }); 2425 2426 od.update(parseInt(number)); 2427 }, 50); 2428 2429 }; 2430 2431 2432 /** 2433 * Initialize Single Product Slider with Carousel
2434 * @since 1.0.0 2435 */ 2436 /*CL_FRONT.shopProductSlider = function(){ 2437 if( $( '.cl-images .cl-carousel' ).length > 0 ) 2438 CL_FRONT.components.Carousel( $( '.cl-images .cl-carousel' ), { 2439 items:1, 2440 loop:false, 2441 center:true, 2442 URLhashListener:true, 2443 autoplayHoverPause:true, 2444 startPosition: 'URLHash', 2445 animateIn: 'alpha-in', 2446 animateOut: 'fadeOut' 2447 }, function( owl, el ){ 2448 2449 2450 var onChangefunc = function(event){ 2451 var index = event.item.index; 2452 var actived_id = $( event.currentTarget ).find('.active .cl-image-item').attr('data-hash'); 2453 2454 var thumbnails = $(event.currentTarget).closest('.images').find('.thumbnails'); 2455 2456 thumbnails.find('a').removeClass('active'); 2457 thumbnails.find('[href="#'+actived_id+'"]').addClass('active'); 2458 }; 2459 2460 owl.on('translated.owl.carousel', onChangefunc ); 2461 owl.on('initialize.owl.carousel', onChangefunc ); 2462 } ); 2463 };*/ 2464 2465 2466 /*CL_FRONT.shopEasyZoom = function(){ 2467 "use strict"; 2468 var $elements = $( '.easyzoom' ); 2469 if ( $elements.length ) { 2470 $elements.each( function( i ) { 2471 2472 var $element = $( this ); 2473 CL_FRONT.components.loadDependencies( [ codeless_global.FRONT_LIB_JS + 'easyzoom.js' ], function() { 2474 var $easyzoom = $element.easyZoom(); 2475 }); 2476 }); 2477 } 2478 };*/ 2479 2480 2481 2482 CL_FRONT.loadOtherLazyload = function(){ 2483 "use strict"; 2484 2485 $('.lazyload').closest( '.cl-blog' ).each(function(){ 2486 if( $(this).hasClass('cl-blog--module-grid-blocks') ) 2487 CL_FRONT.components.LazyLoad( $(this)[0] ); 2488 }); 2489 }; 2490 2491 2492 /** 2493 * Manage Customize Partial Refresh 2494 * 2495 * @since 1.0.0 2496 */ 2497 CL_FRONT.partialRefreshRendered = function(){ 2498 "use strict"; 2499 if( typeof wp.customize === 'undefined' || typeof wp.customize.selectiveRefresh === 'undefined' ) 2500 return false; 2501 2502 wp.customize.selectiveRefresh.on( 'partial-content-rendered', function( placement ) { 2503 var postType = ''; 2504 2505 if( typeof placement.partial.params.post_type !== 'undefined' ) 2506 postType = placement.partial.params.post_type; 2507 2508 if( postType == 'portfolio' ) 2509 CL_FRONT.init_cl_portfolio(); 2510 2511 } ); 2512 }; 2513 2514 2515 /** 2516 * Active Tabs 2517 * 2518 * @since 1.1.0 2519 */ 2520 CL_FRONT.codelessTabs = CL_FRONT.init_cl_tabs = function(){ 2521 $('.cl_tabs').each(function(){ 2522 var $tabs = $(this); 2523 CL_FRONT.components.loadDependencies( [ codeless_global.FRONT_LIB_JS + 'bootstrap-tabs.min.js' ], function() { 2524 2525 $tabs.find('.tab-content > .tab-pane').first().addClass('active in'); 2526 $tabs.find('.tab-content .cl_cl_tab').first().addClass('activeBuilder'); 2527 2528 2529 $('.cl-nav-tabs li:first-child', $tabs).addClass('active'); 2530 // Builder 2531 $tabs.find('.tab-content .cl_element').first().find('.tab-pane').addClass('active in'); 2532 2533 $('.cl-nav-tabs a', $tabs).on( 'click', function(e){ 2534 2535 if( !CL_FRONT.config.$isCustomizer ) 2536 e.preventDefault() 2537 $(this).tab('show'); 2538 }); 2539 }); 2540 }); 2541 }; 2542 2543 2544 CL_FRONT.footerReveal = function(){ 2545 if( $('#footer-wrapper.reveal').length == 0 ) 2546 return false; 2547 2548 var footerHeight = $('#footer-wrapper').height(); 2549 2550 if( this.config.$viewport.hasClass('cl-layout-bordered') ){ 2551 $('#footer-wrapper').width( this.config.$main.width() ); 2552 } 2553 2554 this.config.$main.css( 'margin-bottom', footerHeight ).css( 'background-color', '#ffffff' ).css('position', 'relative').css('z-index', 1); 2555 }; 2556 2557 2558 CL_FRONT.restartAnimations = function( $el, force ){ 2559 if( $el.length == 0 ) 2560 return; 2561 2562 $el.find( ' > .start_animation' ).removeClass('start_animation').addClass('cl-animate-on-visible'); 2563 setTimeout(function(){ 2564 CL_FRONT.animations( $el, force ); 2565 }, 20); 2566 } 2567 2568 /**
2569 * Manage Customize Partial Refresh 2570 * 2571 * @since 1.0.0 2572 * @version 1.0.7 2573 */ 2574 CL_FRONT.onePageScroll = function(){ 2575 "use strict"; 2576 if( CL_FRONT.config.$body.hasClass('cl-one-page') ){ 2577 2578 2579 2580 CL_FRONT.components.loadDependencies( [ codeless_global.FRONT_LIB_JS + 'jquery.onepage.js' ], function() { 2581 $('#navigation nav .menu').onePageNav({ 2582 currentClass: 'current-menu-item-onepage', 2583 changeHash: false, 2584 scrollSpeed: 750, 2585 scrollThreshold: 0.5, 2586 offset: CL_FRONT.config.$headerHeight 2587 }); 2588 }); 2589 2590 2591 } 2592 2593 } 2594 2595 2596 /* -------------------------------------------------------- */ 2597 /* ----------------- COMPONENTS TO REUSE ------------------ */ 2598 2599 2600 CL_FRONT.components.JustifyGallery = function( container ){ 2601 var $elements = container; 2602 2603 if ( $elements.length ) { 2604 $elements.each( function( i ) { 2605 2606 var $element = $( this ); 2607 CL_FRONT.components.loadDependencies( [ codeless_global.FRONT_LIB_JS + 'jquery.justifiedGallery.min.js' ], function() { 2608 2609 var $data = $element.data(), 2610 $rowHeight = parseInt( CL_FRONT.helpers.parseData( $element.attr('data-rowheight'), 200 ) ), 2611 $maxRowHeight = parseInt( CL_FRONT.helpers.parseData( $element.attr('data-maxheight'), 0 ) ), 2612 $lastRow = CL_FRONT.helpers.parseData( $element.attr('data-lastrow'), 'nojustify' ), 2613 $margins = parseInt( CL_FRONT.helpers.parseData( $element.attr('data-margins'), 15 ) ); 2614 2615 $element.css( {opacity: 0} ); 2616 // Load justifyGallery after images loaded 2617 2618 2619 $element.imagesLoaded( function() { 2620 2621 $element.css( {opacity: 1} ); 2622 2623 $element.justifiedGallery({ 2624 lastRow: $lastRow, 2625 rowHeight: $rowHeight, 2626 maxRowHeight: $maxRowHeight, 2627 2628 margins: $margins 2629 }); 2630 2631 if( typeof CL_FRONT['animations'] !== 'undefined' ) 2632 CL_FRONT.animations(); 2633 2634 CL_FRONT.rowParallax(); 2635 } ); 2636 2637 if( $element.hasClass( 'filterable-entries' ) ){ 2638 $( '.cl-filter--isotope' ).on( 'click', 'a', function(e) { 2639 e.preventDefault(); 2640 var filterValue = $(this).attr('data-filter'); 2641 if( filterValue != '*' ) 2642 $element.justifiedGallery({ 2643 filter: filterValue 2644 }); 2645 else 2646 $element.justifiedGallery({ 2647 filter: false 2648 }); 2649 2650 CL_FRONT.restartAnimations( $element ); 2651 2652 $(this).parent().find('a.active').removeClass('active'); 2653 $(this).addClass('active'); 2654 2655 }); 2656 } 2657 2658 } ); 2659 } ); 2660 } 2661 } 2662 2663 2664 CL_FRONT.components.Isotope = function( container, onArrange ){ 2665 var $elements = container; 2666 2667 if ( $elements.length ) { 2668 $elements.each( function( i ) { 2669 2670 var $element = $( this ); 2671 CL_FRONT.components.loadDependencies( [ codeless_global.FRONT_LIB_JS + 'isotope.js' ], function() { 2672 2673 var $data = $element.data(), 2674 $transitionDuration = CL_FRONT.helpers.parseData( $data.transitionDuration, '0.4' ), 2675 $layoutMode = CL_FRONT.helpers.parseData( $data.isotopeType, 'masonry' ); 2676 2677 2678 $element.css( {opacity: 0} ); 2679 // Load isotope after images loaded 2680 2681 2682 $element.imagesLoaded( function() { 2683 2684 $element.css( {opacity: 1} ); 2685 2686 var isotope_options = { 2687 itemSelector: '.cl-isotope-item', 2688 transformsEnabled: true, 2689 filter: '*', 2690 percentPosition: true, 2691 transitionDuration: '0.0s', 2692 layoutMode: $layoutMode 2693 }; 2694 2695 if( $layoutMode == 'masonry' ){ 2696 isotope_options['masonry'] = { 2697 columnWidth: '.cl-msn-size-small' 2698 }; 2699 } 2700 2701 if( $layoutMode == 'vertical' ){ 2702 isotope_options['vertical'] = { 2703 horizontalAlignment: 0.5 2704 } 2705 } 2706 2707 2708 2709 var $iso = $element.isotope( isotope_options ); 2710 2711 if( typeof CL_FRONT['animations'] !== 'undefined' ) 2712 CL_FRONT.restartAnimations( $element ); 2713 2714 $element.on('arrangeComplete', function(){ 2715 setTimeout(function(){ 2716 CL_FRONT.components.LazyLoad($element[0]); 2717 }, 100); 2718 }); 2719 2720 $element.isotope('arrange'); 2721 2722 2723 2724 CL_FRONT.rowParallax(); 2725 CL_FRONT.paginationInfinite(); 2726 2727 2728 2729 2730 } ); 2731 2732 var $parent_element = $element.closest( '.cl-blog' ); 2733 2734 2735 if( $('.cl-filter--isotope', $parent_element).length > 0 ){ 2736 $( '.cl-filter--isotope a', $parent_element).on( 'click', function(e) { 2737 e.preventDefault(); 2738 var filterValue = $(this).attr('data-filter'); 2739 if( filterValue != '*' ) 2740 $element.isotope({ 2741 filter: filterValue, 2742 sortBy: 'random' 2743 }); 2744 else 2745 $element.isotope({ 2746 filter: filterValue, 2747 sortBy: 'original-order' 2748 }); 2749 2750 CL_FRONT.restartAnimations( $element ); 2751 $element.isotope('arrange'); 2752 2753 $(this).parent().find('a.active').removeClass('active'); 2754 $(this).addClass('active'); 2755 2756 }); 2757 } 2758 2759 } ); 2760 } ); 2761 } 2762 } 2763 2764 2765 /** 2766 * Carousel Component to be used over pages 2767 * @since 1.0.0 2768 */ 2769 2770 CL_FRONT.components.Carousel = function( el, data_obj, callback ){ 2771 if( el != null ){ 2772 CL_FRONT.components.loadDependencies( [ codeless_global.FRONT_LIB_JS + 'owl.carousel.min.js'], function() { 2773 2774 var $data = el.data(); 2775 console.log($data); 2776 if( data_obj != null && data_obj != false ) 2777 $data = data_obj; 2778 2779 if( typeof $data.autoHeight === "undefined" ) 2780 $data['autoHeight'] = true; 2781 if( typeof $data.navContainerClass === "undefined" ) 2782 $data['navContainerClass'] = 'cl-owl-nav'; 2783 if( typeof $data.navText === "undefined" ) 2784 $data['navText'] = ["←","→"] 2785 2786 if( typeof $data.dots === 'undefined' ) 2787 $data['dots'] = false;
2788 2789 console.log( $data ); 2790 el.imagesLoaded( function() { 2791 var owl = el.owlCarousel($data); 2792 CL_FRONT.animations( el.find( '.owl-item.active'), true ); 2793 CL_FRONT.components.LazyLoad( el[0] ); 2794 2795 owl.on('translated.owl.carousel', function(event) { 2796 CL_FRONT.animations( el.find( '.owl-item.active' ), true ); 2797 }); 2798 2799 if( callback != null ) 2800 callback(owl, el); 2801 2802 }); 2803 2804 2805 2806 }); 2807 } 2808 }; 2809 2810 2811 CL_FRONT.instaFeed = function(){ 2812 "use strict"; 2813 $('.cl-instafeed.cl-carousel').each(function(){ 2814 var $instafeed = $(this); 2815 CL_FRONT.components.loadDependencies( [ codeless_global.FRONT_LIB_JS + 'instafeed.min.js' ], function() { 2816 2817 var $token = $instafeed.data('token'), 2818 $userid = $instafeed.data('userid'); 2819 2820 var userFeed = new Instafeed({ 2821 get: 'user', 2822 userId: $userid, 2823 accessToken: $token, 2824 limit: 8, 2825 target: $instafeed[0], 2826 template: '<a href="{{link}}" target="_blank"><img src="{{image}}" /></a>', 2827 after: function() { 2828 var $data = { 2829 2830 responsive: { 2831 0: { 2832 items: 3 2833 }, 2834 480: { 2835 items: 3 2836 }, 2837 768: { 2838 items: 3 2839 }, 2840 992: { 2841 items: $instafeed.data('items') 2842 } 2843 }, 2844 2845 loop:true, 2846 smartSpeed: 600, 2847 center: $instafeed.data('center'), 2848 margin:$instafeed.data('margin'), 2849 nav: false, 2850 dots: false 2851 2852 }; 2853 2854 CL_FRONT.components.Carousel( $instafeed, $data, function(owl, el){ 2855 owl.on('resized.owl.carousel', function(event){ 2856 CL_FRONT.animations( el.find( '.owl-item.active' ), true ); 2857 }); 2858 }); 2859 } 2860 }); 2861 userFeed.run(); 2862 2863 2864 2865 }); 2866 }); 2867 2868 2869 $('.widget .cl-instafeed').each(function(){ 2870 var $instafeed = $(this); 2871 2872 CL_FRONT.components.loadDependencies( [ codeless_global.FRONT_LIB_JS + 'instafeed.min.js' ], function() { 2873 2874 var $token = $instafeed.data('token'), 2875 $userid = $instafeed.data('userid'); 2876 2877 var userFeed = new Instafeed({ 2878 get: 'user', 2879 userId: $userid, 2880 accessToken: $token, 2881 limit: 6, 2882 target: $instafeed[0], 2883 template: '<a href="{{link}}" target="_blank"><img src="{{image}}" /></a>', 2884 resolution: 'low_resolution', 2885 2886 }); 2887 2888 userFeed.run(); 2889 2890 }); 2891 }); 2892 }; 2893 2894 2895 2896 /** 2897 * iLightbox Component 2898 * @since 1.0.0 2899 * @version 2.1 2900 */ 2901 CL_FRONT.components.LightBox = function( el ){ 2902 "use strict"; 2903 var initialized = false; 2904 if( el != null ){ 2905 CL_FRONT.components.loadDependencies( [ codeless_global.FRONT_LIB_JS + 'jquery.requestAnimationFrame.js', 2906 codeless_global.FRONT_LIB_JS + 'jquery.mousewheel.js', 2907 codeless_global.FRONT_LIB_JS + 'ilightbox.packed.js' ], function() { 2908 2909 2910 2911 2912 setTimeout(function(){ 2913 if( !initialized ){ 2914 var connection = el.first().data('lboxid'); 2915 2916 CL_FRONT.config.$ilightboxes['item_5'] = el.iLightBox({ 2917 skin: codeless_global.lightbox.skin, 2918 linkId: connection || false, 2919 path: codeless_global.lightbox.path, 2920 mousewheel: codeless_global.lightbox.mousewheel, 2921 controls: { 2922 toolbar: codeless_global.lightbox.toolbar, 2923 arrows: codeless_global.lightbox.arrows, 2924 slideshow: codeless_global.lightbox.slideshow, 2925 fullscreen:codeless_global.lightbox.fullscreen, 2926 thumbnail:codeless_global.lightbox.thumbnail, 2927 mousewheel:codeless_global.lightbox.mousewheel, 2928 swipe: codeless_global.lightbox.swipe, 2929 2930 } 2931 2932 }); 2933 initialized = true; 2934 } 2935 }, 100); 2936 2937
2938 if( ! codeless_global.lightbox.contextmenu ) 2939 $(document).on('contextmenu', el, function(e) { 2940 return false; 2941 }); 2942 2943 }); 2944 } 2945 }; 2946 2947 2948 /** 2949 * lazyload Component 2950 * @since 1.0.0 2951 */ 2952 CL_FRONT.components.LazyLoad = function( container ){ 2953 "use strict"; 2954 2955 if( container == null ){ 2956 container = window; 2957 } 2958 CL_FRONT.components.loadDependencies( [ codeless_global.FRONT_LIB_JS + 'lazyload.min.js' ], function() { 2959 2960 var myLazyLoad = new LazyLoad({ 2961 container: container, 2962 elements_selector: '.lazyload', 2963 failure_limit: Math.max($('.lazyload').length - 1, 0) 2964 }); 2965 2966 }); 2967 }; 2968 2969 2970 /** 2971 * Parallax Effect Used on various parts of site 2972 * @since 1.0.0 2973 */ 2974 2975 CL_FRONT.components.Parallax = function( el ) { 2976 "use strict"; 2977 2978 2979 2980 var self = this, 2981 $this = el , 2982 obj = $this[ 0 ], 2983 2984 config = $this.data( 'parallax-config' ), 2985 headerHeight = null, 2986 offset = null, 2987 elHeight = null, 2988 ticking = false, 2989 isMobile = null; 2990 2991 var clientRect = null; 2992 2993 if( config == null ) 2994 config = { speed: 0.3 }; 2995 2996 var update = function() { 2997 // Update Positions 2998 obj.style.transform = null; 2999 obj.style.top = null; 3000 obj.style.bottom = null; 3001 if ( CL_FRONT.config.$isMobileScreen ) { 3002 $this.css( 'height', '' ); 3003 return; 3004 } 3005 3006 clientRect = $this[ 0 ].getBoundingClientRect(); 3007 3008 offset = clientRect.top; 3009 3010 elHeight = clientRect.height; 3011 headerHeight = 0; 3012 3013 offset = offset - headerHeight + CL_FRONT.config.$windowTop; 3014 3015 setPosition(); 3016 setSize(); 3017 }; 3018 3019 3020 var h = 0, 3021 winH = 0, 3022 proportion = 0, 3023 height = 0; 3024 3025 3026 var setSize = function() { 3027 3028 $this.css( 'height', '' ); 3029 winH = CL_FRONT.config.$window.height() - headerHeight; 3030 h = obj.getBoundingClientRect().height; 3031 3032 if ( config.speed <= 1 && config.speed > 0 ) { 3033 if ( offset === 0 ) { 3034 $this.css( { 3035 backgroundAttachment: 'scroll', 3036 'will-change': 'transform' 3037 } ); 3038 } else { 3039 $this.css( { 3040 height: h + ( ( winH - h ) * config.speed ), 3041 backgroundAttachment: 'scroll', 3042 'will-change': 'transform' 3043 } ); 3044 } 3045 3046 } else if ( config.speed > 1 && h <= winH ) { 3047 $this.css( { 3048 // good for full heights - 2 because it's viewable by 2 screen heights 3049 height: ( winH + ( ( winH * config.speed ) - winH ) * 2 ), 3050 top: -( ( winH * config.speed ) - winH ), 3051 backgroundAttachment: 'scroll', 3052 'will-change': 'transform' 3053 } ); 3054 3055 } else if ( config.speed > 1 && h > winH ) { 3056 proportion = h / winH; 3057 height = ( winH + ( ( winH * config.speed ) - winH ) * ( 1 + proportion ) ); 3058 3059 $this.css( { 3060 height: height, 3061 top: -( height - ( winH * config.speed ) ), 3062 backgroundAttachment: 'scroll', 3063 'will-change': 'transform' 3064 } ); 3065 3066 } else if ( config.speed < 0 && h >= winH ) { 3067 height = h * ( 1 - config.speed ); 3068 $this.css( { 3069 height: height + ( height - h ), 3070 top: h - height, 3071 backgroundAttachment: 'scroll', 3072 'will-change': 'transform' 3073 } ); 3074 3075 } else if ( config.speed < 0 && h < winH ) { 3076 // candidate to change 3077 var display = ( winH + h ) / winH; 3078 height = h * -config.speed * display; 3079 $this.css( {
3080 height: h + ( height * 2 ), 3081 top: -height, 3082 backgroundAttachment: 'scroll', 3083 'will-change': 'transform' 3084 } ); 3085 } 3086 }; 3087 3088 3089 var currentPoint = null, 3090 progressVal = null, 3091 startPoint = null, 3092 endPoint = null, 3093 3094 scrollY = null; 3095 3096 var setPosition = function() { 3097 ticking = false; 3098 3099 if( scrollY == null ) 3100 scrollY = window.scrollY; 3101 3102 var currentScrollY = scrollY; 3103 if (!CL_FRONT.config.$isMobileScreen){ 3104 3105 startPoint = offset - winH; 3106 3107 endPoint = offset + elHeight + winH - headerHeight; 3108 3109 if ( currentScrollY < startPoint || currentScrollY > endPoint ) { 3110 ticking = false; 3111 return; 3112 } 3113 3114 currentPoint = ( ( -offset + currentScrollY ) * config.speed ); 3115 3116 $this.css( { 3117 '-webkit-transform': 'translateY(' + currentPoint + 'px) translateZ(0)', 3118 '-moz-transform': 'translateY(' + currentPoint + 'px) translateZ(0)', 3119 '-ms-transform': 'translateY(' + currentPoint + 'px) translateZ(0)', 3120 '-o-transform': 'translateY(' + currentPoint + 'px) translateZ(0)', 3121 'transform': 'translateY(' + currentPoint + 'px) translateZ(0)' 3122 } ); 3123 3124 3125 } 3126 }; 3127 3128 3129 var requestTick = function() { 3130 3131 if ( !ticking ) { 3132 window.requestAnimationFrame( setPosition ); 3133 } 3134 ticking = true; 3135 3136 }; 3137 3138 var onScroll = function(){ 3139 scrollY = window.scrollY; 3140 requestTick(); 3141 } 3142 3143 3144 var init = function() { 3145 3146 // Disable scroll effects when smooth scroll is disabled 3147 if ( !CL_FRONT.config.$isSmoothScroll || CL_FRONT.config.$isCustomizer ) { 3148 return; 3149 } 3150 3151 update(); 3152 setTimeout( update, 300 ); 3153 3154 CL_FRONT.config.$window.on( 'load', update ); 3155 CL_FRONT.config.$window.on( 'resize', update ); 3156 window.addEventListener('scroll', onScroll, false); 3157 3158 }; 3159 3160 3161 return { 3162 init: init 3163 }; 3164 3165 }; 3166 3167 3168 CL_FRONT.components.loadAnimation = function( content, callback ){ 3169 3170 content.imagesLoaded( { background: true }, function(list){ 3171 3172 callback(); 3173 content.addClass( 'cl-loaded-component' ); 3174 }); 3175 3176 }; 3177 3178 3179 /** 3180 * Core function for loading dinamically JS 3181 * 3182 * @since 1.0.0 3183 */ 3184 CL_FRONT.components.loadDependencies = function( dependencies, callback ) { 3185 "use strict"; 3186 3187 var _callback = callback || function() {}; 3188 if ( !dependencies ) 3189 return void _callback(); 3190 3191 var newDeps = dependencies.map( function( dep ) { 3192 return -1 === CL_FRONT.config._loadedDependencies.indexOf( dep ) ? "undefined" == typeof CL_FRONT.config._inQueue[ dep ] ? dep : ( CL_FRONT.config._inQueue[ dep ].push( _callback ), !0 ) : !1 3193 } ); 3194 3195 if ( newDeps[ 0 ] !== !0 ) { 3196 if ( newDeps[ 0 ] === !1 ) 3197 return void _callback(); 3198 var queue = newDeps.map( function( script ) { 3199 CL_FRONT.config._inQueue[ script ] = [ _callback ]; 3200 return $.getCachedScript( script ); 3201 } ); 3202 3203 var onLoad = function() { 3204 newDeps.map( function( loaded ) { 3205 CL_FRONT.config._inQueue[ loaded ].forEach( function( callback ) { 3206 callback() 3207 } ); 3208 delete CL_FRONT.config._inQueue[ loaded ]; 3209 CL_FRONT.config._loadedDependencies.push( loaded ) 3210 } ); 3211 }; 3212 3213 $.when.apply( null, queue ).done( onLoad ) 3214 } 3215 3216 3217 }; 3218 3219 3220 3221 3222 3223 /* ---------------------------------------------------*/ 3224 /* ------------------ HELPERS FUNCTIONS --------------*/ 3225 3226 3227 CL_FRONT.helpers.changeHeaderColor = function(element){ 3228 3229 var color = 'dark'; 3230 if( CL_FRONT.config.$header.hasClass('cl-header-sticky-active') ) 3231 return; 3232 3233 3234 if( element.find('.cl-row').hasClass('light-text') ) 3235 color = 'light'; 3236 3237 3238 if( color == 'light' && ! CL_FRONT.config.$header.hasClass('cl-header-light') ){ 3239 CL_FRONT.config.$header.addClass('cl-header-light'); 3240 CL_FRONT.config.$body.addClass('cl-header-light'); 3241 } 3242 3243 if( color == 'dark' && CL_FRONT.config.$header.hasClass('cl-header-light') ){ 3244 CL_FRONT.config.$header.removeClass('cl-header-light'); 3245 CL_FRONT.config.$body.removeClass('cl-header-light'); 3246 } 3247 3248 3249 3250 }; 3251 3252 CL_FRONT.helpers.recognizeColor = function(color){ 3253 var rgb = ''; 3254 if( CL_FRONT.helpers.includes(color, 'rgb') ){ 3255 var match = color.match(/rgba?\((\d{1,3}), ?(\d{1,3}), ?(\d{1,3})\)?(?:, ?(\d(?:\.\d?))\))?/); 3256 rgb = match ? { 3257 0: match[1], 3258 1: match[2], 3259 2: match[3] 3260 } : {}; 3261 3262 3263 }else{ 3264 var isOk = /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(color); 3265 if( ! isOk ) 3266 return 'none'; 3267 rgb = CL_FRONT.helpers.hexToRgb(color); 3268 3269 } 3270 3271 3272 var o = Math.round(((parseInt(rgb[0]) * 299) + (parseInt(rgb[1]) * 587) + (parseInt(rgb[2]) * 114)) /1000); 3273 if(o > 125) { 3274 return 'light'; 3275 }else{ 3276 return 'black'; 3277 } 3278 3279 }; 3280 3281 CL_FRONT.helpers.hexToRgb = function(hex){ 3282 var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); 3283 return result ? { 3284 r: parseInt(result[1], 16), 3285 g: parseInt(result[2], 16), 3286 b: parseInt(result[3], 16) 3287 } : null; 3288 }; 3289 3290 CL_FRONT.helpers.includes = function(container, value){ 3291 var returnValue = false;
3292 var pos = container.indexOf(value); 3293 if (pos >= 0) { 3294 returnValue = true; 3295 } 3296 return returnValue; 3297 }; 3298 3299 CL_FRONT.helpers.loadCSS = function(href){ 3300 var ss = document.styleSheets; 3301 for (var i = 0, max = ss.length; i < max; i++) { 3302 if (ss[i].href == href) 3303 return; 3304 } 3305 var link = document.createElement("link"); 3306 link.rel = "stylesheet"; 3307 link.href = href; 3308 3309 document.getElementsByTagName("head")[0].appendChild(link); 3310 } 3311 3312 /** 3313 * Core function for loading dinamically JS 3314 * 3315 * @since 1.0.0 3316 */ 3317 $.getCachedScript = function( url, callback ) { 3318 "use strict"; 3319 3320 url = url.replace( /.*?:\/\//g, "" ); 3321 3322 if ( location.protocol === 'https:' ) 3323 url = 'https://' + url; 3324 else 3325 url = 'http://' + url; 3326 3327 var options = { 3328 dataType: "script", 3329 cache: false, 3330 url: url 3331 }; 3332 3333 return $.ajax( options ).done( callback ); 3334 }; 3335 3336 3337 /** 3338 * parse and sanitize value 3339 * 3340 * @since 1.0.0 3341 */ 3342 CL_FRONT.helpers.parseData = function( val, fallback ) { 3343 "use strict"; 3344 return ( typeof val !== 'undefined' ) ? val : fallback; 3345 }; 3346 3347 CL_FRONT.helpers.scroll = function() { 3348 "use strict"; 3349 var offset = 0, 3350 $window = $(window), 3351 hasPageYOffset = (window.pageYOffset !== undefined), 3352 body = (document.documentElement || document.body.parentNode || document.body); 3353 3354 var update = function() { 3355 offset = hasPageYOffset ? window.pageYOffset : body.scrollTop; 3356 }; 3357 3358 var rAF = function() { 3359 window.requestAnimationFrame(update); 3360 }; 3361 3362 update(); 3363 $window.on('load', update); 3364 $window.on('resize', update); 3365 $window.on('scroll', rAF); 3366 3367 3368 return offset; 3369 3370 }; 3371 3372 3373 function initGMAP(){ 3374 CL_FRONT.codelessGMap(); 3375 } 3376 3377 CL_FRONT.siteInit(); 3378 3379 3380 if( typeof CL_FRONT.animations == 'undefined' ){ 3381 3382 CL_FRONT.animations = function( el, force ) { 3383 if (!window.waypoint_animation) { 3384 window.waypoint_animation = function(el, force) { 3385 3386 var notEl = (el == null) ? true : false; 3387 if( el == null ) 3388 el = $('.cl-animate-on-visible:not(.start_animation)'); 3389 else{ 3390 if( el.hasClass('.cl-animate-on-visible') ) 3391 el = el.find('.cl-animate-on-visible:not(.start_animation)').andSelf(); 3392 else 3393 el = el.find('.cl-animate-on-visible:not(.start_animation)') 3394 } 3395 3396 3397 3398 $.each(el, function(index, val) { 3399 var run = true; 3400 if ($(val).closest('.cl-slide').length > 0) run = false; 3401 3402 if ($(val).closest('.cl-carousel').length > 0) run = false; 3403 3404 if ($(val).closest('.cl-header__menu').length > 0 ) run = false; 3405 3406 if( force ) 3407 run = true; 3408 if (run) { 3409 3410 CL_FRONT.components.loadDependencies([codeless_global.FRONT_LIB_JS + "waypoints.min.js"], function(){ 3411 3412 new Waypoint({ 3413 element: val, 3414 handler: function() { 3415 var element = $(this.element), 3416 index = element.index(), 3417 delayAttr = element.attr('data-delay'); 3418 3419 if (delayAttr == undefined) delayAttr = 0; 3420 setTimeout(function() { 3421 element.addClass('start_animation'); 3422 3423 if( element.hasClass('cl_counter') ) 3424 CL_FRONT.codelessCounter(element); 3425 3426 if( element.hasClass('cl_progress_bar') ) 3427 CL_FRONT.progressBar( element ); 3428 3429 }, delayAttr); 3430 this.destroy(); 3431 }, 3432 offset: '90%' 3433 }); 3434 }); 3435 3436 } 3437 }); 3438 } 3439 } 3440 setTimeout(function() { 3441 window.waypoint_animation(el, force); 3442 }, 1); 3443 }; 3444 } 3445 3446 3447 3448 3449} )( jQuery );
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.