/**
* jQuery.browser.mobile (http://detectmobilebrowser.com/)
* jQuery.browser.mobile will be true if the browser is a mobile device
**/
(function ( jQuery ) {
jQuery.fn.ultimate_video_bg = function(option) {
jQuery(this).each(function(){
var selector =jQuery(this);
var vdo = selector.data('ultimate-video');
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')
if( overlay_color != ''){
overlay_color = '
';
}
else{
//console.warn("Overlay color not selected");
}
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-upb_br_animation',anim_style);
if(vdo){
if(vdo.indexOf('youtube.com')!=-1){
option='youtube';
}
else if (vdo.indexOf('vimeo.com')!=-1){
option='vimeo'
}
}
if(option=='youtube' || option=='vimeo'){
selector.html(' ');
}else{
selector.html(' ');
}
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;
//alert(loop+' '+muted+' '+vdo);
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);
//content.html('')
}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('')
//.controls-wrapper
//.controls
/*jQuery(window).load(function(){
setTimeout(function() {
var if_co = jQuery('iframe.upb_vimeo_iframe').contents().find("#player");
if_co.find(".controls-wrapper").css("display","none");
}, 5000);
})
*/
}
else{
var content = selector.find('.upb_video-src');
content.attr({'src':vdo});
if(autoplay=='autoplay'){ content.attr({'autoplay':autoplay}); }
if(muted=='muted'){ content.attr({'muted':muted}); }
if(loop=='loop'){ content.attr({'loop':loop}); }
if(poster){ content.attr({'poster':poster}); }
}
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';
}
selector.prev().prepend(''+overlay_color+'
');
var parent = selector.prev();
selector.remove();
selector = parent;
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.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';
}
parent.prepend(''+overlay_color+'
');
selector.remove();
selector = parent;
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);
})
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 update(){
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', update).resize(update);
update();
}
}( jQuery ));
// Auto Initialization
jQuery(document).ready(function(){
//if(!jQuery.browser.mobile){
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_no_bg').prev().css('background-image','').css('background-repeat','');
jQuery('.upb_content_iframe').ultimate_video_bg();
jQuery('.upb_grad').ultimate_grad_shift();
//jQuery('.upb_row_bg').ultimate_parallax_animation('parent');
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');
}
//if ( isNaN( ride ) ) { return; }
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') )
//console.log(al+' '+ar);
var w = al+ar + ancenstor.width();
var bl = - ( parent.offset().left - ancenstor.offset().left );
//console.log(bl);
if ( bl > 0 ) { left = 0; }
jQuery(this).css({'width': w,'left': bl })
if(ride=='browser_size'){
parent.css('min-height',jQuery(window).height()+'px');
}
});
jQuery('.upb_video-bg').each(function() {
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');
}
//if ( isNaN( ride ) ) { return; }
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;
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, 'height':pHeight});
if(ride=='browser_size'){
parent.css('min-height',jQuery(window).height()+'px');
}
});
/*jQuery('.upb_bg_size_automatic.vcpb-vz-jquery').each(function(){
var vh = jQuery(window).outerHeight();
var bh = jQuery(this).parent().outerHeight();
var speed = jQuery(this).data('parallax_sense');
var ih = (((vh+bh)/100)*speed)+bh;
jQuery(this).css('background-size','auto '+ih+'px')
})
jQuery('.upb_bg_size_automatic.vcpb-hz-jquery').each(function(){
var vh = jQuery(window).outerHeight();
var bh = jQuery(this).parent().outerHeight();
var speed = jQuery(this).data('parallax_sense');
var bw = jQuery(this).outerWidth()
var ih = (((vh+bh)/100)*speed)+bw;
jQuery(this).css('background-size',ih+'px auto');
})
jQuery('.upb_bg_size_automatic.vcpb-hz-jquery').each(function(){
})*/
};
resizees();
//jQuery('.upb_video-bg').parents('.upb_video_class').css('overflow','visible');
jQuery(window).resize(function(){
resizees();
})
//jQuery('.upb_video_class').ultimate_parallax_animation('self');
//}
})