patrick@17: // $Id$ patrick@17: // balade_nature patrick@17: Patrick@125: /*global jQuery: true */ Patrick@124: patrick@17: Patrick@125: jQuery(document).ready(function($) { Patrick@125: // Hotspots Patrick@125: var delay = 5000; Patrick@125: $('.pdocHotspot').each(function() { Patrick@125: var $hotspot = $(this); Patrick@125: var $spot = $('#' + $hotspot.attr('id') + 's'); Patrick@125: var scenario = $hotspot.children('span').length; Patrick@125: if ($spot.length && scenario) { Patrick@125: $hotspot.css('opacity', 1); Patrick@125: $hotspot.click(function() { Patrick@125: if ($hotspot.css('opacity') == 1) { Patrick@125: $hotspot.animate({opacity: 0}) Patrick@125: .delay(delay) Patrick@125: .animate({opacity: 1}); Patrick@125: $spot.css({opacity: 0, display: 'block'}) Patrick@125: .animate({opacity: 1}) Patrick@125: .delay(delay) Patrick@125: .animate({opacity: 0}, function() { Patrick@125: $spot.css({opacity: '', display: ''}); Patrick@125: }); Patrick@125: } else { Patrick@125: $spot.click(); Patrick@125: } Patrick@125: }); patrick@17: Patrick@125: $spot.click(function() { Patrick@125: $spot.stop().animate({opacity: 0}, function() { Patrick@125: $spot.css({opacity: '', display: ''}); Patrick@74: }); Patrick@125: $hotspot.stop().animate({opacity: 1}); Patrick@125: }); Patrick@125: } Patrick@125: }); patrick@17: patrick@17: // Effect: glow Patrick@125: var boxProperty = ''; Patrick@125: var $text = null; Patrick@125: var $spot = null; Patrick@125: var $box = null; Patrick@125: var $effectGlow = $('#effectGlow'); Patrick@125: if ($effectGlow.length) { Patrick@125: $text = $('#effectGlowText'); Patrick@125: $spot = $('#effectGlowSpot'); Patrick@125: $box = $('#effectGlowBox'); Patrick@125: if (typeof $box.css('webkitBoxShadow') == 'string') { patrick@17: boxProperty = 'webkitBoxShadow'; Patrick@125: } else if (typeof $box.css('MozBoxShadow') == 'string') { patrick@17: boxProperty = 'MozBoxShadow'; Patrick@125: } else if (typeof $box.css('boxShadow') == 'string') { patrick@17: boxProperty = 'boxShadow'; patrick@17: } Patrick@125: $effectGlow.on('mousemove touchmove', onMouseMove); Patrick@125: } patrick@17: Patrick@125: function onMouseMove(e) { Patrick@125: if (typeof e === 'undefined' || typeof e.clientX === 'undefined') { Patrick@125: return; patrick@17: } Patrick@125: Patrick@125: var xm = (e.clientX - Math.floor(window.innerWidth / 2)) * 0.4; Patrick@125: var ym = (e.clientY - Math.floor(window.innerHeight / 3)) * 0.4; Patrick@125: var d = Math.round(Math.sqrt(xm*xm + ym*ym) / 5); Patrick@125: $text.css('textShadow', -xm + 'px ' + -ym + 'px ' + (d + 10) + 'px black'); Patrick@125: Patrick@125: if (boxProperty) { Patrick@125: $box.css(boxProperty, '0 ' + -ym + 'px ' + (d + 30) + 'px black'); Patrick@125: } Patrick@125: Patrick@125: xm = e.clientX - Math.floor(window.innerWidth / 2); Patrick@125: ym = e.clientY - Math.floor(window.innerHeight / 2); Patrick@125: $spot.css('backgroundPosition', xm + 'px ' + ym + 'px'); patrick@17: } patrick@17: });