Your IP : 216.73.217.143


Current Path : /home/ereika83/public_html/wp-content/plugins/bbpowerpack/modules/pp-info-banner/js/
Upload File :
Current File : /home/ereika83/public_html/wp-content/plugins/bbpowerpack/modules/pp-info-banner/js/frontend.js

(function($) {

	PPInfoBanner = function( settings ) {
		this.id		 	= settings.id;
		this.settings 	= settings;
		this.nodeClass	= '.fl-node-' + settings.id;
		this.wrapClass	= this.nodeClass + ' .info-banner-wrap',
		this.imgClass	= this.nodeClass + ' .pp-info-banner-img',
		this.nodeOffset = $(this.nodeClass).offset(),
		this.nodeHeight = $(this.nodeClass).height(),
		this.bannerHeight = $(this.nodeClass).find('.pp-info-banner-content').height(),
		this.animateClass = $(this.wrapClass).data('animation-class'),
		this.imgAnimClass = $(this.nodeClass).find('.pp-info-banner-img').data('animation-class'),
		this.winHeight	= $(window).height();

		if ( $(this.nodeClass).length === 0 ) {
			return;
		}

		this._init();
	};

	PPInfoBanner.prototype = {
		_init: function()
		{
			var nodeOffset 		= this.nodeOffset,
				nodeHeight		= this.nodeHeight,
				bannerHeight 	= this.bannerHeight,
				animateClass	= this.animateClass,
				imgAnimClass	= this.imgAnimClass,
				winHeight		= this.winHeight;

			$(this.nodeClass).find('.banner-link').css('height', bannerHeight + 'px');

			$(window).on('scroll', function() {
				var scrollPos = $(window).scrollTop();

				if ( scrollPos >= nodeOffset.top - ( winHeight - nodeHeight ) ) {
					$(this.wrapClass).addClass(animateClass).css('opacity', 1);
					
					if ( $(this.imgClass).length > 0 && 'undefined' !== typeof this.imgAnimClass ) {
						$(this.imgClass).addClass(imgAnimClass);
					}
				}
			}.bind( this ) );

			if ( 0 >= nodeOffset.top - ( winHeight - nodeHeight ) ) {
				$(this.wrapClass).css('opacity', 1);
			}
		}
	};

})(jQuery);