patrick@17: // $Id$ patrick@17: // balade_nature patrick@17: patrick@17: var text = null; patrick@17: var spot = null; patrick@17: var box = null; patrick@17: var boxProperty = ''; patrick@17: patrick@17: patrick@17: window.addEvent('domready', function(){ patrick@17: // Tooltips patrick@17: (function initialize() { patrick@17: $$(".pdocImagePulse").each(function(pulse) { patrick@17: var mainImg = pulse.getParent().getElement("img"); patrick@17: var pulseImg = pulse.getElement("img"); patrick@17: var tooltip = $(pulse.get('id')+"t"); patrick@17: mainImg.setStyle("max-width", "none"); patrick@17: var pulseWidth = 100 * pulseImg.getSize().x / mainImg.getSize().x; patrick@17: var pulseHeight = 100 * pulseImg.getSize().y / mainImg.getSize().y; patrick@17: var mainImgRealWidth = mainImg.getSize().x; patrick@17: patrick@17: pulse.setStyles({ patrick@17: "width": pulseWidth + "%", "height": pulseHeight + "%", patrick@17: "left": (pulse.getStyle("left").toFloat() - pulseWidth/2) + "%", patrick@17: "top": (pulse.getStyle("top").toFloat() - pulseHeight/2) + "%" patrick@17: }); patrick@17: pulseImg.setStyle("width", "100%"); patrick@17: mainImg.setStyle("max-width", "100%"); patrick@17: mainImg.getParent().setStyle("max-width", "100%"); patrick@17: patrick@17: var fontSize = tooltip.getStyle("font-size").toFloat(); patrick@17: tooltip.setStyles({ patrick@17: "opacity": 0, "display": "block", patrick@17: "font-size": (fontSize * mainImg.getSize().x / mainImgRealWidth) patrick@17: + tooltip.getStyle("font-size").replace(fontSize, "") patrick@17: }); patrick@17: patrick@17: var tooltipImg = tooltip.getElement("img"); patrick@17: if (tooltipImg) { patrick@17: tooltip.setStyle( patrick@17: "width", (100 * tooltipImg.getSize().x / mainImgRealWidth) + "%"); patrick@17: tooltipImg.setStyle("width", "100%"); patrick@17: } patrick@17: }); patrick@17: patrick@17: $$(".pdocImagePulse").addEvent("click", function() { patrick@17: var pulse = this; patrick@17: var tooltip = $(this.get('id')+"t"); patrick@17: pulse.setStyle("display", "none"); patrick@17: tooltip.tween("opacity", 1); patrick@17: (function() { patrick@17: tooltip.tween("opacity", 0); patrick@17: pulse.setStyle("display", "block"); patrick@17: }).delay(12000); patrick@17: }); patrick@17: patrick@17: $$(".pdocImageTooltip").addEvent("click", function() { patrick@17: this.tween("opacity", 0); patrick@17: $(this.get('id').substr(0, this.get('id').length-1)) patrick@17: .setStyle("display", "block"); patrick@17: }); patrick@17: }).delay(50); patrick@17: patrick@17: // Effect: glow patrick@17: var effectGlow = $("effectGlow"); patrick@17: if (effectGlow) { patrick@17: text = $("effectGlowText"); patrick@17: spot = $("effectGlowSpot"); patrick@17: box = $("effectGlowBox") patrick@17: if (typeof box.style.webkitBoxShadow == 'string') { patrick@17: boxProperty = 'webkitBoxShadow'; patrick@17: } else if (typeof box.style.MozBoxShadow == 'string') { patrick@17: boxProperty = 'MozBoxShadow'; patrick@17: } else if (typeof box.style.boxShadow == 'string') { patrick@17: boxProperty = 'boxShadow'; patrick@17: } patrick@17: patrick@17: if (text && spot && box) { patrick@17: effectGlow.onmousemove = onMouseMove; patrick@17: effectGlow.ontouchmove = function (e) { patrick@17: e.preventDefault(); patrick@17: e.stopPropagation(); patrick@17: onMouseMove({clientX: e.touches[0].clientX, clientY: e.touches[0].clientY}); patrick@17: } patrick@17: } patrick@17: } patrick@17: }); patrick@17: patrick@17: patrick@17: function onMouseMove(e) { patrick@17: if (typeof e === 'undefined' || typeof e.clientX === 'undefined') { patrick@17: return; patrick@17: } patrick@17: patrick@17: var xm = (e.clientX - Math.floor(window.innerWidth / 2)) * 0.4; patrick@17: var ym = (e.clientY - Math.floor(window.innerHeight / 3)) * 0.4; patrick@17: var d = Math.round(Math.sqrt(xm*xm + ym*ym) / 5); patrick@17: text.style.textShadow = -xm + 'px ' + -ym + 'px ' + (d + 10) + 'px black'; patrick@17: patrick@17: if (boxProperty) { patrick@17: box.style[boxProperty] = '0 ' + -ym + 'px ' + (d + 30) + 'px black'; patrick@17: } patrick@17: patrick@17: xm = e.clientX - Math.floor(window.innerWidth / 2); patrick@17: ym = e.clientY - Math.floor(window.innerHeight / 2); patrick@17: spot.style.backgroundPosition = xm + 'px ' + ym + 'px'; patrick@17: } patrick@17: