patrick@17
|
1 |
// $Id$
|
patrick@17
|
2 |
// balade_nature
|
patrick@17
|
3 |
|
patrick@17
|
4 |
var text = null;
|
patrick@17
|
5 |
var spot = null;
|
patrick@17
|
6 |
var box = null;
|
patrick@17
|
7 |
var boxProperty = '';
|
patrick@17
|
8 |
|
patrick@17
|
9 |
|
patrick@17
|
10 |
window.addEvent('domready', function(){
|
patrick@17
|
11 |
// Tooltips
|
patrick@17
|
12 |
(function initialize() {
|
patrick@17
|
13 |
$$(".pdocImagePulse").each(function(pulse) {
|
patrick@17
|
14 |
var mainImg = pulse.getParent().getElement("img");
|
patrick@17
|
15 |
var pulseImg = pulse.getElement("img");
|
patrick@17
|
16 |
var tooltip = $(pulse.get('id')+"t");
|
patrick@17
|
17 |
mainImg.setStyle("max-width", "none");
|
patrick@17
|
18 |
var pulseWidth = 100 * pulseImg.getSize().x / mainImg.getSize().x;
|
patrick@17
|
19 |
var pulseHeight = 100 * pulseImg.getSize().y / mainImg.getSize().y;
|
patrick@17
|
20 |
var mainImgRealWidth = mainImg.getSize().x;
|
patrick@17
|
21 |
|
patrick@17
|
22 |
pulse.setStyles({
|
patrick@17
|
23 |
"width": pulseWidth + "%", "height": pulseHeight + "%",
|
patrick@17
|
24 |
"left": (pulse.getStyle("left").toFloat() - pulseWidth/2) + "%",
|
patrick@17
|
25 |
"top": (pulse.getStyle("top").toFloat() - pulseHeight/2) + "%"
|
patrick@17
|
26 |
});
|
patrick@17
|
27 |
pulseImg.setStyle("width", "100%");
|
patrick@17
|
28 |
mainImg.setStyle("max-width", "100%");
|
patrick@17
|
29 |
mainImg.getParent().setStyle("max-width", "100%");
|
patrick@17
|
30 |
|
patrick@17
|
31 |
var fontSize = tooltip.getStyle("font-size").toFloat();
|
patrick@17
|
32 |
tooltip.setStyles({
|
patrick@17
|
33 |
"opacity": 0, "display": "block",
|
patrick@17
|
34 |
"font-size": (fontSize * mainImg.getSize().x / mainImgRealWidth)
|
patrick@17
|
35 |
+ tooltip.getStyle("font-size").replace(fontSize, "")
|
patrick@17
|
36 |
});
|
patrick@17
|
37 |
|
patrick@17
|
38 |
var tooltipImg = tooltip.getElement("img");
|
patrick@17
|
39 |
if (tooltipImg) {
|
patrick@17
|
40 |
tooltip.setStyle(
|
patrick@17
|
41 |
"width", (100 * tooltipImg.getSize().x / mainImgRealWidth) + "%");
|
patrick@17
|
42 |
tooltipImg.setStyle("width", "100%");
|
patrick@17
|
43 |
}
|
patrick@17
|
44 |
});
|
patrick@17
|
45 |
|
patrick@17
|
46 |
$$(".pdocImagePulse").addEvent("click", function() {
|
patrick@17
|
47 |
var pulse = this;
|
patrick@17
|
48 |
var tooltip = $(this.get('id')+"t");
|
patrick@17
|
49 |
pulse.setStyle("display", "none");
|
patrick@17
|
50 |
tooltip.tween("opacity", 1);
|
patrick@17
|
51 |
(function() {
|
patrick@17
|
52 |
tooltip.tween("opacity", 0);
|
patrick@17
|
53 |
pulse.setStyle("display", "block");
|
patrick@17
|
54 |
}).delay(12000);
|
patrick@17
|
55 |
});
|
patrick@17
|
56 |
|
patrick@17
|
57 |
$$(".pdocImageTooltip").addEvent("click", function() {
|
patrick@17
|
58 |
this.tween("opacity", 0);
|
patrick@17
|
59 |
$(this.get('id').substr(0, this.get('id').length-1))
|
patrick@17
|
60 |
.setStyle("display", "block");
|
patrick@17
|
61 |
});
|
patrick@17
|
62 |
}).delay(50);
|
patrick@17
|
63 |
|
patrick@17
|
64 |
// Effect: glow
|
patrick@17
|
65 |
var effectGlow = $("effectGlow");
|
patrick@17
|
66 |
if (effectGlow) {
|
patrick@17
|
67 |
text = $("effectGlowText");
|
patrick@17
|
68 |
spot = $("effectGlowSpot");
|
patrick@17
|
69 |
box = $("effectGlowBox")
|
patrick@17
|
70 |
if (typeof box.style.webkitBoxShadow == 'string') {
|
patrick@17
|
71 |
boxProperty = 'webkitBoxShadow';
|
patrick@17
|
72 |
} else if (typeof box.style.MozBoxShadow == 'string') {
|
patrick@17
|
73 |
boxProperty = 'MozBoxShadow';
|
patrick@17
|
74 |
} else if (typeof box.style.boxShadow == 'string') {
|
patrick@17
|
75 |
boxProperty = 'boxShadow';
|
patrick@17
|
76 |
}
|
patrick@17
|
77 |
|
patrick@17
|
78 |
if (text && spot && box) {
|
patrick@17
|
79 |
effectGlow.onmousemove = onMouseMove;
|
patrick@17
|
80 |
effectGlow.ontouchmove = function (e) {
|
patrick@17
|
81 |
e.preventDefault();
|
patrick@17
|
82 |
e.stopPropagation();
|
patrick@17
|
83 |
onMouseMove({clientX: e.touches[0].clientX, clientY: e.touches[0].clientY});
|
patrick@17
|
84 |
}
|
patrick@17
|
85 |
}
|
patrick@17
|
86 |
}
|
patrick@17
|
87 |
});
|
patrick@17
|
88 |
|
patrick@17
|
89 |
|
patrick@17
|
90 |
function onMouseMove(e) {
|
patrick@17
|
91 |
if (typeof e === 'undefined' || typeof e.clientX === 'undefined') {
|
patrick@17
|
92 |
return;
|
patrick@17
|
93 |
}
|
patrick@17
|
94 |
|
patrick@17
|
95 |
var xm = (e.clientX - Math.floor(window.innerWidth / 2)) * 0.4;
|
patrick@17
|
96 |
var ym = (e.clientY - Math.floor(window.innerHeight / 3)) * 0.4;
|
patrick@17
|
97 |
var d = Math.round(Math.sqrt(xm*xm + ym*ym) / 5);
|
patrick@17
|
98 |
text.style.textShadow = -xm + 'px ' + -ym + 'px ' + (d + 10) + 'px black';
|
patrick@17
|
99 |
|
patrick@17
|
100 |
if (boxProperty) {
|
patrick@17
|
101 |
box.style[boxProperty] = '0 ' + -ym + 'px ' + (d + 30) + 'px black';
|
patrick@17
|
102 |
}
|
patrick@17
|
103 |
|
patrick@17
|
104 |
xm = e.clientX - Math.floor(window.innerWidth / 2);
|
patrick@17
|
105 |
ym = e.clientY - Math.floor(window.innerHeight / 2);
|
patrick@17
|
106 |
spot.style.backgroundPosition = xm + 'px ' + ym + 'px';
|
patrick@17
|
107 |
}
|
patrick@17
|
108 |
|