/*-------------------------------------------------------------------------
Theme Name: EGO
For any questions concerning this theme please refer to documention or
our forum at support.udthemes.com.
/*------------------------------------------------------------------------
//GENERAL FUNCTONS ///////////////////////////////////////////////////////
-------------------------------------------------------------------------*/
jQuery(document).ready(function($){
/*vars used throughout*/
var thumb = $('.thumb, .round-thumb-container'),
thumbW,
thumbH,
thumbCaption,
target,
hoverSpeed=500,
hoverEase='easeOutExpo',
targetNetwork =$('ul.socialSmall li a'),
toggleMenu =$('.mobileMenuToggle'),
lightboxTransition = 'fade', //Set lightbox transition type
overlayOpacity =0.8, //Fancybox overlay opacity
overlayColor = '#000', //Fancybox overlay color
videoWidth = 680, //Fancybox video width
videoHeight = 382, //Fancybox video height
hoverScreen;
//MOBILE MENU -----------------------------------------------------------------------/
toggleMenu.on('click', function(event) {
if($(this).parent().find('.menu ul').is(':hidden')) {
$(this).parent().find('.menu ul').slideDown();
$(this).addClass('open');
} else {
$(this).parent().find('.menu ul').slideUp();
$(this).removeClass('open');
}
event.preventDefault();
});
//VIDEO RESIZE -------------------------------------------------------------------------/
var resizeVideos = function() {
$('.video').not('.project-display .video').each(function() {
$(this).height(Math.round($(this).width()/1.775)+'px');
$(this).find('embed, object, iframe').height(Math.round($(this).width()/1.775)+'px').width($(this).width()+'px');
});
};
$(window).bind('resize', function() {
resizeVideos();
});
resizeVideos();
//ROLLOVER SPECIFIC ---------------------------------------------------------------------/
/*general
-------------------*/
thumb.not('.no_overlay').on({
mouseenter: function () {
//check if device is mobile
//or within an inactive filter category
//or if its video content in which case do nothing
if(isMobile === true) {
return false;
}
thumbW = $(this).find('a').find('img').width();
thumbH = $(this).find('a').find('img').height();
//get refrences needed
thumbCaption = $(this).find('a').attr('title');
//add rolloverscreen
if(!$(this).find('a').find('div').hasClass('thumb-rollover')) {
$(this).find('a.lightbox, a.lightbox-iframe, a.lightbox-soundcloud, a.imageWrapperLink, a.linkedImageLink, .round-thumb a').append('
');
}
//set it to the image size and fade in
hoverScreen = $('.thumb-rollover');
hoverScreen.css({width:thumbW,height:thumbH});
//make sure caption is filled out
if (typeof thumbCaption !== 'undefined' && thumbCaption !== false && $(this).find(hoverScreen).is(':empty')) {
//construct rollover & animate
$(this).find(hoverScreen).append('
'+thumbCaption+'
');
target = $(this).find(hoverScreen);
target.stop().animate({opacity:1},hoverSpeed, hoverEase);
}
},
mouseleave: function () {
if(isMobile === true) {
return false;
}
//animate out
$(this).find(hoverScreen).animate({opacity:0},hoverSpeed,hoverEase,function(){
//delete rollover
$(this).remove();
});
}
});
//LIGHTBOX SPECIFIC ---------------------------------------------------------------------/
/*lightbox-img
-------------------------------*/
$('a.lightbox').fancybox({
'transitionIn' : lightboxTransition,
'transitionOut' : lightboxTransition,
'titlePosition' : 'over',
'padding' : '0',
'overlayOpacity' : overlayOpacity,
'overlayColor' : overlayColor,
'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
var obj = currentArray[ currentIndex ]; //get current image
var target = $(obj).parent(); //get its container
//CASE 1: thumb has associated html content
if($(target).next().hasClass('fancybox-html')) {
//check if stack order should be displayed
if ($(target).next().length && $(obj).attr('rel')){
return '