$(document).ready(function() { $('body').append('
'); $('#top .menu').on('click', function() { fitCacheToWindow(); fitExpo(); toggleMenu(); }); $('#cache').on('click', function() { hideMenu(); hideExpo(); }); $( window ).on( "orientationchange", function( event ) { fitCacheToWindow(); hideMenu(); hideExpo(); }); $('.home #bottom a, .home #top .menu').on('click', function(e) { e.stopPropagation(); }); $('.home, .home #cache').on('click', toggleMenu); $('#bottom .credits, #bottom .credits_over a, #bottom .credits_over').on('mouseover', function() { $('#bottom .credits_over').css('left', $('#bottom .credits').position().left + 'px').show(); }); $('#site').on('click', function() { $('#bottom .credits_over').hide(); hideMenu(); }); $('#bottom .credits_over').on('mouseout', function() { $(this).hide(); }); fitCacheToWindow(); $('#homebackground').load(function() { redimensionnement(); //onload $('#loader').hide(); $(this).show(); }); $('#exposition_over .inner').html($('#exposition .over').html()); $('#exposition_over .texte2').html($('#exposition .texte2').html()); if( !$('#exposition .over').hasClass('withcontent') ) { $('.special_header .more').hide(); } if( $('.special_header .previous').attr('href') == '' ) { $('.special_header .previous').css('opacity', '0.2').click(function() {return false;}); } if( $('.special_header .next').attr('href') == '' ) { $('.special_header .next').css('opacity', '0.2').click(function() {return false;}); } $('.special_header .more').click(function() { if( $('#exposition_over').is(':visible') ) { hideExpo(); } else { showExpo(); } }); $('.special_header .close').click(function() { hideExpo(); }); fitExpo(); $(window).resize(function() { hideMenu(); redimensionnement(); //fitExpo(); hideExpo(); }); var idx = 0; $('#cv .toggle').each(function() { $(this).attr('save', $(this).height()).css('height', '0').attr('idx', idx); idx ++; }); $('#cv .action, #cv label').on('click', function() { var toggle = $(this).parent().find('.toggle'); if( $(this).parent().find('.action').hasClass('open') ) { $(this).parent().find('.action').removeClass('open'); toggle.animate( { 'height' : '0px'}, 800); } else { $('.toggle').each(function() { if( toggle.attr('idx') != $(this).attr('idx') ) { $(this).parent().find('.action').removeClass('open'); $(this).animate( { 'height' : '0px'}, 800); } }); $(this).parent().find('.action').addClass('open'); toggle.animate( { 'height' : toggle.attr('save')+'px'}, 800); } }); $('#cv .action:first').trigger('click'); $('#site').click(function() { hideExpo(); });; // alert($('body').width()); }); function showExpo() { fitCacheToWindow(); $('#cache').show(); fitExpo(); $('#exposition_over').show(); $('#exposition_mask').show(); } function toggleMenu() { fitCacheToWindow(); if( $('#top .menu_content:visible').length > 0 ) { hideMenu(); } else { showMenu(); } } function hideExpo() { $('#cache').hide(); fitExpo(); $('#exposition_over').hide(); $('#exposition_mask').hide(); } function fitExpo() { var mask = $('#exposition_mask'); var left = parseInt(mask.css('left')) > 0 ? parseInt(mask.css('left')) : 0; mask.css('right', '-' + parseInt($('.wrapper:first').css('padding-right')) +'px'); var border = $(window).width() >= 1280 ? ( $(window).width()- $('.wrapper').width() )/2 : 0 ; var widthInSite = left + border - 5; var width = $(window).width() - border - left - 10; var height = $(document).height() - $('#top').height() - 25; var windowheight = $(window).height() - 255 - $('.special_header .texte2').height(); $('#exposition_over .inner').css('height', windowheight + 'px'); if( $(window).width() >= 1280 ) { mask.css('width', width + 'px'); } mask.css('height', height + 'px'); } function showMenu() { $('#cache').show(); $('#top .menu_content').show(); } function hideMenu() { $('#cache').hide(); $('#top .menu_content').hide(); } /* background resizable */ function redimensionnement() { fitCacheToWindow(); var image_width = $('#homebackground').width(); var image_height = $('#homebackground').height(); var over = image_width / image_height; var under = image_height / image_width; var body_width = $(window).width(); var body_height = $(window).height(); if (body_width / body_height >= over) { $('#homebackground').css({ 'width': body_width + 'px', 'height': Math.ceil(under * body_width) + 'px', 'left': '0px', 'top': Math.abs((under * body_width) - body_height) / -2 + 'px' }); } else { $('#homebackground').css({ 'width': Math.ceil(over * body_height) + 'px', 'height': body_height + 'px', 'top': '0px', 'left': Math.abs((over * body_height) - body_width) / -2 + 'px' }); } $('body.home #site').css({ 'height': body_height + 'px', }); } function fitCacheToWindow() { $('#cache,#loader').css('width', $(window).width() + 'px'); $('#cache,#loader').css('height', $(document).height() + 'px'); }