/* |-------------------------------------------------------------------------- | apola.fullpage.js |-------------------------------------------------------------------------- | Defines Fullpage module. */ ;(function($){ 'use strict'; if(!('Apola' in $)) { throw new Error('apola.core.js file must be included.'); }; if( !$.fn || !$.fn.fullpage ) { throw new Error('fullpage.js is required for the apola.fullpage.js module.') } var _config = { sectionSelector: '.fp-section', navigation: true, navigationPosition: $.Apola.RTL ? 'left' : 'right', scrollingSpeed: 1500, easingcss3: 'cubic-bezier(0.23, 1, 0.32, 1)', scrollOverflow: true }; function _prepareCallbacks( config ) { var afterRender = config.afterRender || function(){}, onLeave = config.onLeave || function(){}; config.afterRender = function() { var $container = $(this); $(document).trigger('render.apola.fullpage', { $container: $container }); afterRender.apply(this, Array.prototype.slice.call(arguments)); }; config.onLeave = function(index, nextIndex, direction) { var _self = this; $(document).trigger('leave.apola.fullpage', { index: index, nextIndex: nextIndex, direction: direction, $element: $(_self) }); onLeave.apply(this, Array.prototype.slice.call(arguments)); }; return config; }; $.Apola.modules.fullpage = function( collection, config ) { if( !collection || !collection.length ) return; var fullPageTimeOutId, _self = this; config = $.isPlainObject(config) ? $.extend(true, {}, _config, config, collection.data()) : $.extend(true, {}, _config, collection.data()); if( $(window).width() > 767 ) { collection.fullpage( _prepareCallbacks( config ) ); $.fn.fullpage.apoIsInit = true; } $(window).on('resize.fullPage', function(e) { if( fullPageTimeOutId ) clearTimeout( fullPageTimeOutId ); fullPageTimeOutId = setTimeout( function(){ if( collection.data('destroy-on-mobile') ) { if( $(window).width() < 768 && $.fn.fullpage.apoIsInit ) { $.fn.fullpage.destroy('all'); $.fn.fullpage.apoIsInit = false; } else if ( $(window).width() > 767 && $.fn.fullpage.apoIsInit ) { $.fn.fullpage.reBuild(); } else if( $(window).width() > 767 ) { $.fn.fullpage.apoIsInit = true; collection.fullpage( _prepareCallbacks( config ) ); } } else { $.fn.fullpage.reBuild(); $.fn.fullpage.setResponsive( $(window).width() < 768 ); } removeScrollLabels(collection, config.sectionSelector); appendScrollLabels(collection, config.sectionSelector); $(document).trigger('resize.apola.fullpage'); }, 200 ); } ).trigger('resize.fullPage'); }; function removeScrollLabels($container, sectionSelector) { if(!$container || !$container.length || !sectionSelector) return; }; function appendScrollLabels($container, sectionSelector) { if(!$container || !$container.length || !sectionSelector) return; var $sections = $container.find(sectionSelector), scrollDownState = $container.data('show-scrolldown-label'), labelText = $container.data('scrolldown-label') ? $container.data('scrolldown-label') : 'Scroll Down', labelIconClass = $container.data('scrolldown-label-icon-class') ? $container.data('scrolldown-label-icon-class') : 'icon-arrow-down', $scrollLabel, $scrollLabelIcon, $wrappers; if(!$sections.length || !scrollDownState) return; $scrollLabel = $('
', { text: labelText, class: 'apo-scroll-down-label' }); $scrollLabelIcon = $('', { class: labelIconClass }); $scrollLabel.append($scrollLabelIcon); $wrappers = $sections.not(':last').find('.wpb_wrapper:first'); if($wrappers.length) { $wrappers.each(function(i, el){ var $el = $(el); if(!$el.find('.apo-scroll-down-label').length) { $el.append($scrollLabel.clone()); } }); } }; })(jQuery);