(function ( jQuery ) {
function vc_viewport_video()
{
jQuery('.enable-on-viewport').each(function(index, element) {
var is_on_viewport = jQuery(this).isVdoOnScreen();
if(jQuery(this).hasClass('hosted-video') && (!jQuery(this).hasClass('override-controls')))
{
if(is_on_viewport)
{
jQuery(this)[0].play();
jQuery(this).parent().parent().parent().find('.video-controls').attr('data-action','play');
jQuery(this).parent().parent().parent().find('.video-controls').html('');
}
else
{
jQuery(this)[0].pause();
jQuery(this).parent().parent().parent().find('.video-controls').attr('data-action','pause');
jQuery(this).parent().parent().parent().find('.video-controls').html('');
}
}
});
}
jQuery(window).scroll(function(){
vc_viewport_video();
});
jQuery.fn.isVdoOnScreen = function(){
var win =jQuery(window);
var viewport = {
top : win.scrollTop(),
left : win.scrollLeft()
};
viewport.right = viewport.left + win.width();
viewport.bottom = viewport.top + win.height()-200;
var bounds = this.offset();
bounds.right = bounds.left + this.outerWidth();
bounds.bottom = bounds.top + this.outerHeight()-300;
return (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom));
};
jQuery.fn.ultimate_video_bg = function(option) {
jQuery(this).each(function(){
var selector =jQuery(this);
var vdo = selector.data('ultimate-video');
var vdo2 = selector.data('ultimate-video2');
var muted =selector.data('ultimate-video-muted');
var loop =selector.data('ultimate-video-loop');
var autoplay =selector.data('ultimate-video-autoplay');
var poster =selector.data('ultimate-video-poster');
var ride = selector.data('bg-override');
var start = selector.data('start-time');
var stop = selector.data('stop-time');
var anim_style= selector.data('upb-bg-animation');
var overlay_color = selector.data('upb-overlay-color');
var viewport_vdo = selector.data('viewport-video');
var controls = selector.data('controls');
var controls_color = selector.data('controls-color');
var fadeout = selector.data('fadeout');
var fadeout_percentage = selector.data('fadeout-percentage');
var parallax_content = selector.data('parallax-content');
var parallax_content_sense = selector.data('parallax-content-sense');
var disble_mobile = selector.data('row-effect-mobile-disable');
if( overlay_color != ''){
overlay_color = '
';
}
if(stop!=0){
stop = stop;
}else{
stop ='';
}
var parent = selector.prev();
selector.remove();
selector = parent;
var vd_html = selector.html();
selector.addClass('upb_video_class');
selector.attr('data-row-effect-mobile-disable',disble_mobile);
if(fadeout == 'fadeout_row_value')
{
selector.addClass('vc-row-fade');
selector.data('fadeout-percentage',fadeout_percentage);
}
if(parallax_content == 'parallax_content_value')
{
selector.addClass('vc-row-translate');
selector.attr('data-parallax-content-sense', parallax_content_sense);
}
selector.attr('data-upb_br_animation',anim_style);
if(vdo){
if(vdo.indexOf('youtube.com')!=-1){
option='youtube';
}
else if (vdo.indexOf('vimeo.com')!=-1){
option='vimeo'
}
}
var control_html = '';
if(controls == 'display_control'){
control_html = '';
}
if(option=='youtube' || option=='vimeo'){
selector.html('');
}else{
selector.html(' '+control_html+overlay_color+'
');
}
selector.find('.upb_video-text').html(vd_html);
if(option=='youtube'){
vdo = vdo.substring((vdo.indexOf('watch?v='))+8,(vdo.indexOf('watch?v='))+19);
var content = selector.find('.upb_video-bg');
if(loop=='loop') loop=true;
if(muted=='muted') muted=true;
content.attr('data-vdo',vdo);content.attr('data-loop',loop);content.attr('data-poster',poster);
content.attr('data-muted',muted);content.attr('data-start',start);content.attr('data-stop',stop);
if(viewport_vdo === true)
{
content.addClass('enable-on-viewport');
content.addClass('youtube-video');
vc_viewport_video();
}
}else if(option=='vimeo'){
vdo = vdo.substring((vdo.indexOf('vimeo.com/'))+10,(vdo.indexOf('vimeo.com/'))+18);
var content = selector.find('.upb_video-bg');
content.html('')
}
else{
var content = selector.find('.upb_video-src');
if(! /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) )
{
jQuery('', {
type: 'video/mp4',
src: vdo
}).appendTo(content);
if(vdo2 != '')
{
var vdo2_type = '';
if(vdo2.match(/.ogg/i))
vdo2_type = 'video/ogg';
else if(vdo2.match(/.webm/i))
vdo2_type = 'video/webm';
if(vdo2_type != '')
{
jQuery('', {
type: vdo2_type,
src: vdo2
}).appendTo(content);
}
}
if(muted=='muted'){ content.attr({'muted':muted}); }
if(loop=='loop'){ content.attr({'loop':loop}); }
if(poster){ content.attr({'poster':poster}); }
content.attr({'preload':'auto'});
if(viewport_vdo === true)
{
content.addClass('enable-on-viewport');
content.addClass('hosted-video');
vc_viewport_video();
}
else
{
if(autoplay=='autoplay'){ content.attr({'autoplay':autoplay}); }
}
}
else
{
if(poster != '')
content.parent().css({'background-image':'url('+poster+')'});
content.remove();
}
}
var resizee = function(){
var w,h,ancenstor,al='',bl='';
ancenstor = selector;
selector = selector.find('.upb_video-bg');
if(ride=='full'){
ancenstor= jQuery('body');
}
if(ride=='ex-full'){
ancenstor= jQuery('html');
}
if( ! isNaN(ride)){
for(var i=0;i';
}
var parent = selector.prev();
var last_html = parent.html();
if(ride == "browser_size")
{
parent.html('');
var brw_text_wrapper = '';
}
else
var brw_text_wrapper = '';
parent.prepend(''+overlay_color+'
'+brw_text_wrapper);
selector.remove();
selector = parent;
if(ride == "browser_size")
{
selector.find('.upb-background-text').html(last_html);
selector.addClass('full-browser-size');
}
selector.attr('data-row-effect-mobile-disable',disble_mobile);
selector.attr('data-img-parallax-mobile-disable',disble_mobile_img_parallax);
if(fadeout == 'fadeout_row_value')
{
selector.addClass('vc-row-fade');
selector.data('fadeout-percentage',fadeout_percentage);
}
if(parallax_content == 'parallax_content_value')
{
selector.addClass('vc-row-translate');
selector.attr('data-parallax-content-sense', parallax_content_sense);
}
selector.css('background-image','');
selector = selector.find('.upb_row_bg');
selector.attr('data-upb_br_animation',anim_style);
if(size!='automatic'){
selector.css({'background-size':size});
}
else{
selector.addClass('upb_bg_size_automatic');
}
selector.css({'background-repeat':rep,'background-position':pos,'background-color':bg_color});
if(style=='vcpb-fs-jquery' || style=='vcpb-mlvp-jquery'){
selector.attr('data-img-array',bg);
}
else{
selector.css({'background-image':bg,'background-attachment':attach});
}
selector.attr('data-parallax_sense',sense);
selector.attr('data-bg-override',ride);
selector.attr('data-bg-animation',animation);
selector.attr('data-bg-animation-type',animation_type);
selector.attr('data-animation-repeat',animation_repeat);
selector.addClass(style);
var resize = function(){
var w,h,ancenstor,al,bl;
ancenstor = selector.parent();
if(ride=='full'){
ancenstor= jQuery('body');
al=0;
}
if(ride=='ex-full'){
ancenstor= jQuery('html');
al=0;
}
if( ! isNaN(ride)){
for(var i=0;i';
}
if(ride == "browser_size")
{
parent.html('');
var brw_text_wrapper = '';
}
else
var brw_text_wrapper = '';
parent.prepend(''+overlay_color+'
'+brw_text_wrapper);
selector.remove();
selector = parent;
selector.attr('data-row-effect-mobile-disable',disble_mobile);
if(fadeout == 'fadeout_row_value')
{
selector.addClass('vc-row-fade');
selector.data('fadeout-percentage',fadeout_percentage);
}
if(parallax_content == 'parallax_content_value')
{
selector.addClass('vc-row-translate');
selector.attr('data-parallax-content-sense', parallax_content_sense);
}
if(ride == "browser_size")
{
selector.find('.upb-background-text').html(last_html);
selector.addClass('full-browser-size');
}
selector.css('background-image','');
selector = selector.find('.upb_row_bg');
selector.attr('data-upb_br_animation',anim_style);
grad = grad.replace('url(data:image/svg+xml;base64,','');
var e_pos = grad.indexOf(';');
grad = grad.substring(e_pos+1);
selector.attr('style',grad);
selector.attr('data-bg-override',ride);
if(ride == 'browser_size')
selector.parent().find('.upb-background-text-wrapper').addClass('full-browser-size');
})
return this;
}
jQuery.fn.ultimate_bg_color_shift = function() {
jQuery(this).each(function(){
var selector = jQuery(this);
var parent = selector.prev();
var last_html = parent.html();
var ride = jQuery(this).data('bg-override');
var bg_color = jQuery(this).data('bg-color');
var fadeout = selector.data('fadeout');
var fadeout_percentage = selector.data('fadeout-percentage');
var parallax_content = selector.data('parallax-content');
var parallax_content_sense = selector.data('parallax-content-sense');
var disble_mobile = selector.data('row-effect-mobile-disable');
if(ride == "browser_size")
{
parent.html('');
var brw_text_wrapper = '';
}
else
var brw_text_wrapper = '';
parent.prepend(''+brw_text_wrapper);
selector.remove();
selector = parent;
selector.attr('data-row-effect-mobile-disable',disble_mobile);
if(fadeout == 'fadeout_row_value')
{
selector.addClass('vc-row-fade');
selector.data('fadeout-percentage',fadeout_percentage);
}
if(parallax_content == 'parallax_content_value')
{
selector.addClass('vc-row-translate');
selector.attr('data-parallax-content-sense', parallax_content_sense);
}
if(ride == "browser_size")
selector.find('.upb-background-text').html(last_html);
selector.css('background-image','');
selector = selector.find('.upb_row_bg');
selector.css({'background':bg_color});
selector.attr('data-bg-override',ride);
if(ride == 'browser_size')
selector.parent().find('.upb-background-text-wrapper').addClass('full-browser-size');
})
return this;
}
jQuery.fn.ultimate_parallax_animation = function(applyTo) {
var windowHeight = jQuery(window).height();
var getHeight = function(obj) {
return obj.height();
};
var $this = jQuery(this);
var prev_pos = jQuery(window).scrollTop();
function updata(){
var firstTop;
var paddingTop = 0;
var pos = jQuery(window).scrollTop();
$this.each(function(){
if(jQuery(this).data('upb_br_animation')=='upb_fade_animation'){
firstTop = jQuery(this).offset().top;
var $element = jQuery(this);
var top = $element.offset().top;
var height = getHeight($element);
if (top + height < pos || top > pos + windowHeight-100) {
return;
}
var pos_change = prev_pos-pos;
if ((top+height)-windowHeight < pos) {
var op_c = (pos_change/windowHeight);
if(applyTo=='parent'){
var op = parseInt(jQuery(this).css('opacity'));
op += op_c/2.3;
jQuery(this).parents('.wpb_row').css({opacity :op})
}
if(applyTo=='self'){
var op = parseInt(jQuery(this).css('opacity'));
op += op_c/2.3;
jQuery(this).css({opacity :op})
}
}
prev_pos = pos;
}
});
}
jQuery(window).bind('scroll', updata).resize(updata);
updata();
}
}( jQuery ));
// Auto Initialization
jQuery(document).ready(function(){
var temp_vdo_pos = 0;
jQuery('.upb_content_video, .upb_content_iframe').prev().css('background-image','').css('background-repeat','');
jQuery('.upb_content_video').ultimate_video_bg();
jQuery('.upb_bg_img').ultimate_bg_shift();
jQuery('.upb_content_iframe').ultimate_video_bg();
jQuery('.upb_grad').ultimate_grad_shift();
jQuery('.upb_color').ultimate_bg_color_shift();
jQuery('.upb_no_bg').each(function(index, nobg) {
var no_bg_fadeout = jQuery(nobg).attr('data-fadeout');
var fadeout_percentage = jQuery(nobg).data('fadeout-percentage');
var parallax_content = jQuery(nobg).data('parallax-content');
var parallax_content_sense = jQuery(nobg).data('parallax-content-sense');
var disble_mobile = jQuery(nobg).data('row-effect-mobile-disable');
jQuery(nobg).prev().attr('row-effect-mobile-disable',disble_mobile);
if(no_bg_fadeout == 'fadeout_row_value')
{
jQuery(nobg).prev().addClass('vc-row-fade');
jQuery(nobg).prev().data('fadeout-percentage',fadeout_percentage);
}
if(parallax_content == 'parallax_content_value')
{
jQuery(nobg).prev().addClass('vc-row-translate');
jQuery(nobg).prev().attr('data-parallax-content-sense', parallax_content_sense);
}
});
jQuery('.upb_no_bg').remove();
var resizees = function(){
jQuery('.upb_row_bg').each(function() {
var ride = jQuery(this).data('bg-override');
var ancenstor,parent;
parent = jQuery(this).parent();
if(ride=='browser_size'){
ancenstor=jQuery('html');
}
if(ride == 'ex-full'){
ancenstor = jQuery('html');
}
else if(ride == 'full'){
ancenstor = jQuery('body');
}
else if(! isNaN(ride)){
ancenstor = parent;
for ( var i = 0; i < ride; i++ ) {
if ( ancenstor.is('html') ) {
break;
}
ancenstor = ancenstor.parent();
}
}
var al= parseInt( ancenstor.css('paddingLeft') );
var ar= parseInt( ancenstor.css('paddingRight') )
var w = al+ar + ancenstor.width();
var bl = - ( parent.offset().left - ancenstor.offset().left );
if ( bl > 0 ) { left = 0; }
jQuery(this).css({'width': w,'left': bl })
if(ride=='browser_size'){
parent.css('min-height',jQuery(window).height()+'px');
var rheight = jQuery(this);
//console.log(jQuery(this).find('.upb-background-text-wrapper'));
if(parent.find('.upb-background-text-wrapper').length > 0)
{
parent.find('.upb-background-text-wrapper').css('min-height',jQuery(window).height()+'px');
}
}
});
jQuery(window).load(function(){
jQuery('.upb_video-bg').each(function(index,ele) {
var ride = jQuery(this).data('bg-override');
var ancenstor,parent;
parent = jQuery(this).parents('.wpb_row');
if(ride=='browser_size'){
ancenstor=jQuery('html');
}
if(ride == 'ex-full'){
ancenstor = jQuery('html');
jQuery(this).parents('.upb_video_class').css('overflow','visible');
}
else if(ride == 'full'){
ancenstor = jQuery('body');
jQuery(this).parents('.upb_video_class').css('overflow','visible');
}
else if(! isNaN(ride)){
ancenstor = parent;
for ( var i = 1; i < ride; i++ ) {
if ( ancenstor.is('html') ) {
break;
}
ancenstor = ancenstor.parent();
}
}
var al= parseInt( ancenstor.css('paddingLeft') );
var ar= parseInt( ancenstor.css('paddingRight') );
var vc_margin = parseInt( ancenstor.css('marginLeft') ); //vc row margin
var w = ancenstor.outerWidth();
var vdo_left = jQuery(this).offset().left;
var vdo_left_pos = jQuery(this).position().left;
var div_left = ancenstor.offset().left;
var cal_left = div_left - vdo_left;
if(vdo_left_pos < 0)
cal_left = vdo_left_pos + cal_left;
if(index == 0)
temp_vdo_pos = vdo_left_pos;
if(temp_vdo_pos > 0)
cal_left = temp_vdo_pos;
jQuery(this).css({'width': w,'min-width':w,'left': cal_left });
var ratio =(16/9);
pHeight = Math.ceil(w / ratio);
children = jQuery(this).children();
children.css({'width': w,'min-width':w});
var is_poster = jQuery(this).css('background-image');
if(!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) )
{
children.css({'height':pHeight});
if(ride=='browser_size'){
parent.addClass('video-browser-size');
parent.css('min-height',jQuery(window).height()+'px');
if(parent.find('.upb_video-text-wrapper').length > 0)
{
parent.find('.upb_video-text-wrapper').addClass('full-browser-size');
parent.find('.upb_video-text-wrapper').css('min-height',jQuery(window).height()+'px');
}
}
}
else
{
if(typeof is_poster === 'undefined' || is_poster == 'none')
{
children.css({'max-height':'auto','height':'auto'});
parent.css('min-height','auto');
}
}
});
});
};
resizees();
//jQuery('.upb_video-bg').parents('.upb_video_class').css('overflow','visible');
jQuery(window).load(function(){
resizees();
});
jQuery(window).resize(function(){
resizees();
});
jQuery('.video-controls').click(function(e) {
var current_action = jQuery(this).attr('data-action');
var vdo = jQuery(this).parent().find('.upb_video-src');
if(current_action == 'pause')
{
jQuery(this).attr('data-action','play');
vdo[0].play();
jQuery(this).html('');
}
else
{
jQuery(this).attr('data-action','pause');
vdo[0].pause();
jQuery(this).html('');
}
if(vdo.hasClass('enable-on-viewport'))
{
vdo.addClass('override-controls');
}
});
//row animation execution
jQuery('.vcpb-animated').each(function(index, element) {
var repeat = jQuery(element).data('animation-repeat');
jQuery(this).css({'background-repeat':repeat});
var mobile_disable = jQuery(element).parent().attr('data-img-parallax-mobile-disable');
if(typeof mobile_disable == "undefined")
mobile_disable = 'false';
else
mobile_disable = mobile_disable.toString();
if(! /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) )
var is_mobile = 'false';
else
var is_mobile = 'true';
if(is_mobile == 'true' && mobile_disable == 'true')
var disable_row_effect = 'true';
else
var disable_row_effect = 'false';
if(disable_row_effect == 'false')
{
var scrollSpeed = 10;
if(jQuery(this).attr('data-parallax_sense') != '')
scrollSpeed = jQuery(this).attr('data-parallax_sense');
scrollSpeed = 100 - scrollSpeed;
var animation_type = jQuery(this).attr('data-bg-animation-type');
var animation = jQuery(this).attr('data-bg-animation');
// set the default position
var current = 0;
// set the direction
var direction = animation_type;
//Calls the scrolling function repeatedly
setInterval(function(e){
if(animation == 'right-animation' || animation == 'bottom-animation')
current -= 1;
else
current += 1;
jQuery(element).css("backgroundPosition", (direction == 'h') ? current+"px 0" : "0 " + current+"px");
}, scrollSpeed);
}
});
});