|
52
|
1 |
/* |
|
|
2 |
* This file is part of the TraKERS\Front IDILL package. |
|
|
3 |
* |
|
|
4 |
* (c) IRI <http://www.iri.centrepompidou.fr/> |
|
|
5 |
* |
|
|
6 |
* For the full copyright and license information, please view the LICENSE |
|
|
7 |
* file that was distributed with this source code. |
|
|
8 |
*/ |
|
|
9 |
|
|
|
10 |
/* |
|
|
11 |
* Projet : TraKERS |
|
|
12 |
* Module : Front IDILL |
|
|
13 |
* Fichier : neighbours.js |
|
|
14 |
* |
|
|
15 |
* Auteur : alexandre.bastien@iri.centrepompidou.fr |
|
|
16 |
* |
|
|
17 |
* Fonctionnalités : Définit les fonctions d'intéraction avec les voisins lors d'un zoom. |
|
|
18 |
*/ |
|
|
19 |
|
|
44
|
20 |
/* |
|
|
21 |
* Affecte les listeners mouseenter aux voisins lors d'une vue en plein écran. |
|
52
|
22 |
* Est appelé : dans les fichiers neighbours > fonction moveToNeighbour et zoomInteractions > fonction zoom. |
|
44
|
23 |
*/ |
|
52
|
24 |
Mosaic.prototype.listenToNeighbours = function() |
|
44
|
25 |
{ |
|
52
|
26 |
//Si on n'est pas en mode recherche, on enlève les notifications. |
|
|
27 |
if(this.currentMode != 'SEARCH') |
|
|
28 |
{ |
|
|
29 |
this.removeNotifications(); |
|
|
30 |
} |
|
|
31 |
|
|
|
32 |
//Si on est en mode sans utilisateur ou en mode utilisateur approche, on part. |
|
|
33 |
if(this.currentMode == "NO-USER" || this.currentMode.indexOf("INCOMING") != -1) |
|
|
34 |
{ |
|
|
35 |
return; |
|
|
36 |
} |
|
|
37 |
|
|
|
38 |
//Si ils n'y a pas de voisins répertoriés, on part. |
|
|
39 |
if(this.neighboursIds == null || this.neighboursIds != null && this.neighboursIds.length > 0) |
|
|
40 |
{ |
|
|
41 |
return; |
|
|
42 |
} |
|
|
43 |
|
|
44
|
44 |
var _this = this; |
|
|
45 |
|
|
52
|
46 |
//On ne peut actuellement pas se déplacer vers un voisin. |
|
|
47 |
this.canMoveToNeighbour = false; |
|
|
48 |
//On calcule la ligne et colonne du snapshot du milieu. |
|
55
|
49 |
var currentLine = Math.floor(this.centerId / this.config.imagesByLine), currentColumn = this.centerId % this.config.imagesByLine; |
|
44
|
50 |
var zoomedImg = $('img', this.previousZoomedSN); |
|
52
|
51 |
|
|
44
|
52 |
//On cherche l'ID des voisins. |
|
|
53 |
//Si le voisin de gauche est sur la même ligne, on n'est pas sur la bordure de gauche. |
|
|
54 |
this.neighboursIds[0] = (currentColumn > 0) ? (this.centerId - 1) : -1; |
|
|
55 |
//Si le voisin de droite est sur la même ligne, on n'est pas sur la bordure de droite. |
|
55
|
56 |
this.neighboursIds[1] = (currentColumn < this.config.imagesByLine - 1) ? (+this.centerId + 1) : -1; |
|
44
|
57 |
//Si le voisin du haut est sur la même colonne, on n'est pas sur la bordure du haut. |
|
55
|
58 |
this.neighboursIds[2] = (currentLine > 0) ? (this.centerId - this.config.imagesByLine) : -1; |
|
44
|
59 |
//Si le voisin du bas est sur la même colonne, on n'est pas sur la bordure du bas. |
|
55
|
60 |
this.neighboursIds[3] = (currentLine < (this.config.imagesToShow / this.config.imagesByLine)) ? (+this.centerId + this.config.imagesByLine) : -1; |
|
44
|
61 |
|
|
52
|
62 |
//ID du cadre voisin. |
|
|
63 |
var preId; |
|
|
64 |
|
|
|
65 |
//Si les voisins ont un id supérieur au maximum, on les met à -1. |
|
44
|
66 |
for(var i = 0 ; i < this.neighboursIds.length ; i++) |
|
|
67 |
{ |
|
52
|
68 |
if(this.neighboursIds[i] >= this.config.imagesToShow) |
|
|
69 |
{ |
|
|
70 |
this.neighboursIds[i] = -1; |
|
|
71 |
} |
|
44
|
72 |
} |
|
52
|
73 |
|
|
|
74 |
//Si on est sur une bordure. |
|
|
75 |
//On crée des voisins supplémentaires. |
|
|
76 |
if(_.include(this.neighboursIds, -1)) |
|
|
77 |
{ |
|
|
78 |
this.createAdditionalNeighbours(); |
|
|
79 |
} |
|
44
|
80 |
} |
|
|
81 |
|
|
|
82 |
/* |
|
|
83 |
* Crée des voisins supplémentaires pour garantir le déplacement / dézoom quand on arrive sur le bord de la mosaïque. |
|
52
|
84 |
* Est appelé : dans le fichier neighbours > fonction listenToNeighbours. |
|
44
|
85 |
*/ |
|
52
|
86 |
Mosaic.prototype.createAdditionalNeighbours = function() |
|
44
|
87 |
{ |
|
52
|
88 |
//Si on est en mode sans utilisateur, on part. |
|
|
89 |
if(this.currentMode == "NO-USER") |
|
|
90 |
{ |
|
|
91 |
return; |
|
|
92 |
} |
|
55
|
93 |
|
|
52
|
94 |
//Pour tous les voisins. |
|
|
95 |
var additionalNeighbours = ''; |
|
|
96 |
for(var i = 0 ; i < this.neighboursIds.length ; i++) |
|
|
97 |
{ |
|
|
98 |
//Snapshot du milieu. |
|
|
99 |
var sn = $('#snapshotDiv-' + this.centerId); |
|
|
100 |
//Marge de celui-ci. |
|
|
101 |
var m = parseInt(sn.css('margin')); |
|
|
102 |
//Ses coordonnées. |
|
|
103 |
var centerTop = sn.position().top + this.notifyTopVideo + this.MPTop_margin, centerLeft = sn.position().left + this.notifyLeftVideo; |
|
|
104 |
//Ses dimensions. |
|
|
105 |
var centerWidth = sn.width(), centerHeight = sn.height(); |
|
|
106 |
|
|
|
107 |
var top, left; |
|
|
108 |
|
|
|
109 |
//Si on est sur une bordure, on calcule les coordonnées du voisin à l'extérieur de la bordure en fonction de sa position dans le tableau des voisins. |
|
|
110 |
if(this.neighboursIds[i] == -1) |
|
|
111 |
{ |
|
|
112 |
if(i == 0) |
|
|
113 |
{ |
|
|
114 |
top = centerTop + m / 2; |
|
|
115 |
left = centerLeft - centerWidth - 2 * m; |
|
|
116 |
} |
|
|
117 |
else if(i == 1) |
|
|
118 |
{ |
|
|
119 |
top = centerTop + m / 2; |
|
|
120 |
left = centerLeft + centerWidth + 3 * m; |
|
|
121 |
} |
|
|
122 |
else if(i == 2) |
|
|
123 |
{ |
|
|
124 |
top = centerTop - centerHeight - 2 * m; |
|
|
125 |
left = centerLeft + m / 2; |
|
|
126 |
} |
|
|
127 |
else if(i == 3) |
|
|
128 |
{ |
|
|
129 |
top = centerTop + centerHeight + 3 * m; |
|
|
130 |
left = centerLeft + m / 2; |
|
|
131 |
} |
|
|
132 |
|
|
|
133 |
//On place le voisin additionnel. |
|
|
134 |
additionalNeighbours += '<div id="borderNeighbour-' + i + '" class="borderNeighbours" style="opacity: 0; width: ' + centerWidth + 'px; height: ' + centerHeight + 'px; top: ' + top + 'px; left: ' + left + 'px;"></div>'; |
|
|
135 |
} |
|
|
136 |
} |
|
|
137 |
|
|
|
138 |
$('body').append(additionalNeighbours); |
|
|
139 |
//On le fait apparaître. |
|
|
140 |
$('.borderNeighbours').fadeTo(this.config.timeANFade, '1'); |
|
44
|
141 |
} |
|
|
142 |
|
|
|
143 |
/* |
|
|
144 |
* Supprime les voisins supplémentaires. |
|
52
|
145 |
* Est appelé : dans les fichiers neighbours > fonction moveToNeighbour et zoomInteractions > fonction unzoom. |
|
44
|
146 |
*/ |
|
52
|
147 |
Mosaic.prototype.removeAdditionalNeighbours = function() |
|
44
|
148 |
{ |
|
52
|
149 |
$('.borderNeighbours').fadeTo(this.config.timeANFade, '0', function() |
|
|
150 |
{ |
|
|
151 |
$('.borderNeighbours').remove(); |
|
|
152 |
}); |
|
|
153 |
this.deselectAllNeighbours(); |
|
44
|
154 |
} |
|
|
155 |
|
|
|
156 |
/* |
|
|
157 |
* Déselectionne tous les voisins, même les additionnels. |
|
52
|
158 |
* Est appelé : dans les fichier neighbours > fonction removeAdditionalNeighbours. |
|
44
|
159 |
*/ |
|
52
|
160 |
Mosaic.prototype.deselectAllNeighbours = function() |
|
44
|
161 |
{ |
|
52
|
162 |
$('.neighbourFrame').fadeTo(this.config.timeANFade, '0', function() |
|
|
163 |
{ |
|
|
164 |
$('.neighbourFrame').remove(); |
|
|
165 |
}); |
|
44
|
166 |
} |
|
|
167 |
|
|
|
168 |
/* |
|
|
169 |
* Change la coloration d'une bordure où on se positionne lors d'une vue en plein écran. |
|
52
|
170 |
* Est appelé : dans le fichier pointers > fonction pointersVideoInteractions. |
|
44
|
171 |
*/ |
|
52
|
172 |
Mosaic.prototype.selectNeighbour = function(neighbour, pointer) |
|
44
|
173 |
{ |
|
52
|
174 |
//Si on est en train de se déplacer vers un voisin ou dézoomer ou si l'aide est affichée, on part. |
|
|
175 |
if(this.currentlyMoving || this.currentlyUnzooming || this.helpDisplayed) |
|
|
176 |
{ |
|
|
177 |
return; |
|
|
178 |
} |
|
|
179 |
|
|
|
180 |
//Si on est sur une notification de gesture de recherche. |
|
|
181 |
if(this.gestureDelRequested) |
|
|
182 |
{ |
|
|
183 |
//On récupère l'id du voisin. |
|
|
184 |
var tab = neighbour.attr('id').split('-'); |
|
|
185 |
var snapshotId = tab[1]; |
|
|
186 |
//On le déselectionne. |
|
|
187 |
this.deselectNeighbour(snapshotId); |
|
|
188 |
//On part. |
|
|
189 |
return; |
|
|
190 |
} |
|
|
191 |
|
|
|
192 |
//On ne peut pas faire de swipes. |
|
|
193 |
this.canSwipe = false; |
|
|
194 |
|
|
|
195 |
var _this = this; |
|
|
196 |
|
|
44
|
197 |
//Si on est en mode VIDEO (plein écran) ET si le snapshot pointé est un voisin. |
|
52
|
198 |
if((this.currentMode == 'VIDEO' || this.currentMode == 'SEARCH') && (neighbour.attr('id') != 'snapshotDiv-' + this.centerId)) |
|
44
|
199 |
{ |
|
|
200 |
//On crée le cadre qui va être superposé au voisin. |
|
|
201 |
//On le colle au voisin. |
|
52
|
202 |
var tab = neighbour.attr('id').split('-'); |
|
|
203 |
var snapshotId = tab[1]; |
|
44
|
204 |
var neighbourFrame = ''; |
|
52
|
205 |
var marginValue = parseFloat(neighbour.css('margin')); |
|
|
206 |
|
|
|
207 |
//Si la frame existe déjà, on quitte. |
|
|
208 |
if($('#neighbourFrame-' + snapshotId).length > 0) |
|
|
209 |
{ |
|
|
210 |
return; |
|
|
211 |
} |
|
|
212 |
|
|
|
213 |
//Si c'est un voisin additionnel. |
|
|
214 |
if(neighbour.attr('id').indexOf('borderNeighbour') != -1) |
|
|
215 |
{ |
|
|
216 |
//On le sélectionne quand même. |
|
|
217 |
snapshotId = +snapshotId + this.config.imagesToShow; |
|
|
218 |
neighbourFrame += '<div class="neighbourFrame" id="neighbourFrame-' + snapshotId + '"></div>'; |
|
|
219 |
if($('#neighbourFrame-' + snapshotId).length > 0) |
|
|
220 |
{ |
|
|
221 |
return; |
|
|
222 |
} |
|
|
223 |
$('body').append(neighbourFrame); |
|
|
224 |
} |
|
|
225 |
//Si c'est un voisin normal. |
|
|
226 |
else |
|
|
227 |
{ |
|
|
228 |
//On le sélectionne. |
|
|
229 |
neighbourFrame += '<div class="neighbourFrame" id="neighbourFrame-' + snapshotId + '"><div class="neighbourImgBg" id="neighbourImgBg-' + snapshotId + '"><div class="neighbourImg" id="neighbourImg-' + snapshotId + '"></div></div></div>'; |
|
|
230 |
if($('#neighbourFrame-' + snapshotId).length > 0) |
|
|
231 |
{ |
|
|
232 |
return; |
|
|
233 |
} |
|
|
234 |
$('#mainPanel').append(neighbourFrame); |
|
|
235 |
} |
|
|
236 |
|
|
|
237 |
//On positionne le div de background juste au niveau du voisin. |
|
44
|
238 |
$('#neighbourFrame-' + snapshotId).css( |
|
52
|
239 |
{ |
|
|
240 |
'top': (+neighbour.position().top + marginValue), |
|
|
241 |
'left': (+neighbour.position().left + marginValue), |
|
|
242 |
'width': neighbour.width(), |
|
|
243 |
'height': neighbour.height() |
|
|
244 |
}); |
|
|
245 |
//On positionne le div de background noir juste au niveau de l'image du voisin. |
|
44
|
246 |
$('#neighbourImgBg-' + snapshotId).css( |
|
52
|
247 |
{ |
|
|
248 |
'top': marginValue, |
|
|
249 |
'left': marginValue, |
|
|
250 |
'width': neighbour.width() - marginValue*2, |
|
|
251 |
'height': neighbour.height() - marginValue*2, |
|
|
252 |
}); |
|
|
253 |
//On met par dessus le div de l'image clonée du voisin. |
|
|
254 |
$('#neighbourImg-' + snapshotId).css( |
|
|
255 |
{ |
|
|
256 |
'top': 0, |
|
|
257 |
'left': 0, |
|
|
258 |
'width': neighbour.width() - marginValue*2, |
|
|
259 |
'height': neighbour.height() - marginValue*2, |
|
|
260 |
'background-image': 'url("' + $('img', neighbour).attr('src') + '")', |
|
|
261 |
'background-size': neighbour.width() + 'px ' + neighbour.height() + 'px', |
|
|
262 |
'background-position': -marginValue + 'px ' + -marginValue + 'px', |
|
|
263 |
'opacity': '0.4' |
|
|
264 |
}); |
|
|
265 |
|
|
|
266 |
var fId = '#neighbourFrame-' + snapshotId; |
|
|
267 |
|
|
|
268 |
$(fId).animate( |
|
44
|
269 |
{ |
|
|
270 |
//On le fait apparaître. |
|
|
271 |
opacity: '1' |
|
52
|
272 |
}, _this.config.timeNeighbourGlowing, function() |
|
|
273 |
{ |
|
|
274 |
//Si on est en mode d'intéraction souris. |
|
|
275 |
if(_this.config.mouseInteractions) |
|
|
276 |
{ |
|
|
277 |
//Si on est en mode video. |
|
|
278 |
if(_this.currentMode == 'VIDEO') |
|
|
279 |
{ |
|
|
280 |
//On notifie. |
|
|
281 |
_this.removeNotifications(); |
|
|
282 |
_this.videoMove(snapshotId); |
|
|
283 |
} |
|
|
284 |
//Si on est en mode de recherche mais sans gesture encore. |
|
|
285 |
else if(_this.currentMode == 'SEARCH' && _this.currentSearchGesture[_this.centerId] == '') |
|
|
286 |
{ |
|
|
287 |
//On notifie. |
|
|
288 |
_this.removeNotifications(); |
|
|
289 |
_this.searchSearchAndMove(snapshotId); |
|
|
290 |
} |
|
|
291 |
//Si on est en mode de recherche avec une gesture. |
|
|
292 |
else if(_this.currentMode == 'SEARCH' && _this.currentSearchGesture[_this.centerId] != '') |
|
|
293 |
{ |
|
|
294 |
//On notifie. |
|
|
295 |
_this.removeNotifications(); |
|
|
296 |
_this.searchGestureAndMove(_this.currentSearchGesture[_this.centerId], 'valid', snapshotId); |
|
|
297 |
} |
|
|
298 |
|
|
|
299 |
//On peut bouger vers un voisin. |
|
|
300 |
_this.canMoveToNeighbour = true; |
|
|
301 |
} |
|
|
302 |
//Si on est en mode d'intéractions Kinect. |
|
|
303 |
else |
|
|
304 |
{ |
|
|
305 |
//Si on est en mode video, on notifie mais avec un dézoom possible. |
|
|
306 |
if(_this.currentMode == 'VIDEO') |
|
|
307 |
{ |
|
|
308 |
_this.removeNotifications(); |
|
|
309 |
_this.videoMoveAndUnzoom(snapshotId); |
|
|
310 |
} |
|
|
311 |
//Si on est en mode de recherche mais sans gesture encore, on notifie mais avec un dézoom possible. |
|
|
312 |
else if(_this.currentMode == 'SEARCH' && !_this.currentSearchGesture[_this.centerId]) |
|
|
313 |
{ |
|
|
314 |
_this.removeNotifications(); |
|
|
315 |
_this.searchSearchAndMoveAndUnzoom(snapshotId); |
|
|
316 |
} |
|
|
317 |
//Si on est en mode de recherche avec une gesture, on notifie mais avec un dézoom possible. |
|
|
318 |
else if(_this.currentMode == 'SEARCH' && _this.currentSearchGesture[_this.centerId]) |
|
|
319 |
{ |
|
|
320 |
_this.removeNotifications(); |
|
|
321 |
_this.searchGestureAndMoveAndUnzoom(_this.currentSearchGesture[_this.centerId], 'valid', snapshotId); |
|
|
322 |
} |
|
|
323 |
} |
|
|
324 |
}); |
|
|
325 |
|
|
|
326 |
//On repère de quel côté le voisin se trouve en fonction du centre. |
|
|
327 |
var side = $.inArray(parseInt(snapshotId), this.neighboursIds); |
|
|
328 |
|
|
|
329 |
//S'il n'est nulle part on part. |
|
|
330 |
if(side == -1) |
|
|
331 |
{ |
|
|
332 |
return; |
|
|
333 |
} |
|
|
334 |
|
|
|
335 |
//On affecte l'image de la notification en fonction du côté. |
|
|
336 |
var sides = ['left', 'right', 'down', 'up']; |
|
|
337 |
pointer.css('background-image', 'url(./img/cursors/' + sides[side] + '_gray.png)'); |
|
44
|
338 |
} |
|
|
339 |
} |
|
|
340 |
|
|
|
341 |
/* |
|
|
342 |
* Change la coloration d'une bordure quittée lors d'une vue en plein écran. |
|
52
|
343 |
* Est appelé : dans les fichiers neighbours > fonction selectNeighbour et pointers > fonction pointersVideoInteractions. |
|
44
|
344 |
*/ |
|
52
|
345 |
Mosaic.prototype.deselectNeighbour = function(neighbourId) |
|
44
|
346 |
{ |
|
52
|
347 |
if($('#neighbourFrame-' + neighbourId).length <= 0) |
|
|
348 |
{ |
|
|
349 |
return; |
|
|
350 |
} |
|
|
351 |
|
|
|
352 |
var _this = this; |
|
|
353 |
|
|
44
|
354 |
//On ne peut plus se déplacer vers les voisins. |
|
|
355 |
this.canMoveToNeighbour = true; |
|
|
356 |
|
|
52
|
357 |
//On récupère le voisin. |
|
|
358 |
var neighbourFrame = $('#neighbourFrame-' + neighbourId); |
|
|
359 |
|
|
44
|
360 |
//Si on est en mode VIDEO. |
|
|
361 |
if(this.currentMode == 'VIDEO' || this.currentMode == 'SEARCH') |
|
|
362 |
{ |
|
|
363 |
//On le fait disparaître progressivement. |
|
|
364 |
neighbourFrame.animate( |
|
|
365 |
{ |
|
|
366 |
opacity: '0' |
|
52
|
367 |
}, this.config.timeNeighbourUnglowing, function() |
|
44
|
368 |
{ |
|
|
369 |
//Une fois invisible, on le supprime. |
|
|
370 |
neighbourFrame.remove(); |
|
52
|
371 |
_this.removeNotifications(); |
|
|
372 |
|
|
|
373 |
if(_this.currentMode == 'SEARCH' && _this.currentSearchGesture[_this.centerId] == '') |
|
|
374 |
{ |
|
|
375 |
_this.searchSearch(); |
|
|
376 |
} |
|
|
377 |
else if(_this.currentMode == 'SEARCH' && _this.currentSearchGesture[_this.centerId] != '') |
|
|
378 |
{ |
|
|
379 |
_this.searchGesture(_this.currentSearchGesture[_this.centerId], 'valid'); |
|
|
380 |
} |
|
|
381 |
|
|
|
382 |
_this.canSwipe = true; |
|
44
|
383 |
}); |
|
|
384 |
} |
|
|
385 |
} |
|
|
386 |
|
|
|
387 |
/* |
|
|
388 |
* Permet de savoir si un déplacement est possible en fonction de l'id de snapshot entré. |
|
|
389 |
* x et y sont les positions du pointeur. |
|
|
390 |
* Déplace vers le voisin si possible. |
|
52
|
391 |
* Est appelé : dans le fichier pointers > fonction pointersVideoInteractions. |
|
44
|
392 |
*/ |
|
52
|
393 |
Mosaic.prototype.correctMoveToNeighbour = function(id, x, y) |
|
44
|
394 |
{ |
|
52
|
395 |
var _this = this; |
|
|
396 |
|
|
|
397 |
if(this.neighboursIds != null && this.neighboursIds.length > 0 && this.canMoveToNeighbour) |
|
|
398 |
{ |
|
|
399 |
var idx = $.inArray(id, this.neighboursIds); |
|
|
400 |
//Si l'id du snapshot qu'on vient de quitter fait partie des voisins. |
|
|
401 |
if(idx > -1) |
|
|
402 |
{ |
|
|
403 |
//Correspondance indices : position par rapport au snapshot du milieu. |
|
|
404 |
//0 : gauche. |
|
|
405 |
//1 : droite. |
|
|
406 |
//2 : haut. |
|
|
407 |
//3 : bas. |
|
|
408 |
|
|
|
409 |
//On cherche le symétrique de l'id du voisin quitté. |
|
|
410 |
//Astuce : S'il est pair, cela signifie qu'on doit faire +1, sinon c'est -1. |
|
|
411 |
//var sym = (idx % 2 == 0) ? (+idx + 1) : (idx - 1); |
|
|
412 |
|
|
|
413 |
//S'il est > -1 alors forcément il existe. |
|
|
414 |
//Si on peut se déplacer vers un voisin, on le fait. |
|
|
415 |
if(this.neighboursIds[idx] > -1) |
|
|
416 |
{ |
|
|
417 |
var centerWidth = -this.notifyLeftVideo + $(window).width() / 2, centerHeight = -this.notifyTopVideo + $(window).height() / 2; |
|
|
418 |
|
|
|
419 |
//Si l'id du tableau est pair, alors forcément le pointeur doit être plus à droite/plus en bas que le milieu de l'écran pour se déplacer vers le voisin. |
|
|
420 |
//Sinon c'est l'inverse. |
|
|
421 |
//(sym et idx on été échangés). |
|
|
422 |
if(idx == 0 && x > centerWidth || idx == 2 && y > centerHeight || idx == 1 && x < centerWidth || idx == 3 && y < centerHeight) |
|
|
423 |
{ |
|
|
424 |
this.moveToNeighbour($('#snapshotDiv-' + this.neighboursIds[idx])); |
|
|
425 |
} |
|
|
426 |
} |
|
|
427 |
} |
|
|
428 |
else if(id >= this.config.imagesToShow) |
|
|
429 |
{ |
|
|
430 |
//On otbient le vrai ID du voisin additionnel. |
|
|
431 |
var additionalNeighbourId = id - this.config.imagesToShow; |
|
|
432 |
var sym = (additionalNeighbourId % 2 == 0) ? (+additionalNeighbourId + 1) : (additionalNeighbourId - 1); |
|
|
433 |
} |
|
|
434 |
} |
|
44
|
435 |
} |
|
|
436 |
|
|
|
437 |
/* |
|
|
438 |
* Lors d'une vue en plein écran, on se déplace vers le voisin dont l'id a été spécifié dans la fonction appelante. |
|
52
|
439 |
* Est appelé : dans les fichiers neighbours > fonction correctMoveToNeighbour, playerControl > fonction playNextVideo et zoomInteractions > zoom. |
|
44
|
440 |
*/ |
|
52
|
441 |
Mosaic.prototype.moveToNeighbour = function(neighbour) |
|
44
|
442 |
{ |
|
52
|
443 |
var _this = this; |
|
|
444 |
|
|
44
|
445 |
//Si on ne peut pas se déplacer vers les voisins, on quitte. |
|
|
446 |
if((!this.canMoveToNeighbour || neighbour.length <= 0 || this.currentlyMoving) && !this.autoMove) |
|
52
|
447 |
{ |
|
44
|
448 |
return; |
|
52
|
449 |
} |
|
|
450 |
|
|
|
451 |
this.canMoveToNeighbour = false; |
|
|
452 |
this.currentlyMoving = true; |
|
|
453 |
this.removeAdditionalNeighbours(); |
|
44
|
454 |
|
|
|
455 |
//On obtient l'ID de destination. |
|
|
456 |
var tab = neighbour.attr('id').split('-'); |
|
|
457 |
var destinationId = tab[1]; |
|
52
|
458 |
|
|
|
459 |
var startId = this.previousZoomedSN.attr('id').replace('snapshotDiv-', ''); |
|
44
|
460 |
|
|
|
461 |
//On charge les attributs nécessaires aux calculs. |
|
55
|
462 |
var length = _this.config.imagesByLine; |
|
44
|
463 |
var MPCurrentTop = $('#mainPanel').position().top, MPCurrentLeft = $('#mainPanel').position().left; |
|
|
464 |
var divideCoeffTop = Math.floor(destinationId / length) == 0 ? 1 : Math.floor(destinationId / length); |
|
|
465 |
var divideCoeffLeft = destinationId % length == 0 ? 1 : destinationId % length; |
|
|
466 |
var neighbourFrameTop = $('#snapshotDiv-' + destinationId).position().top, neighbourFrameLeft = $('#snapshotDiv-' + destinationId).position().left; |
|
|
467 |
|
|
52
|
468 |
_this.previousZoomedSN = $('#snapshotDiv-' + this.centerId); |
|
|
469 |
|
|
|
470 |
//On définit pour le déplacement vertical s'il est nécessaire de se déplacer en haut ou en bas. |
|
|
471 |
if(_this.previousZoomedSN.position().top > neighbourFrameTop) |
|
|
472 |
MPCurrentTop += Math.abs(neighbourFrameTop - _this.previousZoomedSN.position().top); |
|
|
473 |
else if(_this.previousZoomedSN.position().top < neighbourFrameTop) |
|
|
474 |
MPCurrentTop -= Math.abs(neighbourFrameTop - _this.previousZoomedSN.position().top); |
|
|
475 |
//On définit pour le déplacement horizontal s'il est nécessaire de se déplacer à gauche ou à droite. |
|
|
476 |
if(_this.previousZoomedSN.position().left > neighbourFrameLeft) |
|
|
477 |
MPCurrentLeft += Math.abs(neighbourFrameLeft - _this.previousZoomedSN.position().left); |
|
|
478 |
else if(_this.previousZoomedSN.position().left < neighbourFrameLeft) |
|
|
479 |
MPCurrentLeft -= Math.abs(neighbourFrameLeft - _this.previousZoomedSN.position().left); |
|
44
|
480 |
|
|
|
481 |
//On passe le snapshot de destination en HD. |
|
|
482 |
var destinationImg = $('#snapshot-' + destinationId); |
|
|
483 |
var destinationImgSrc = destinationImg.attr('src'); |
|
|
484 |
destinationImg.attr('src', destinationImgSrc.replace('snapshots-little/', 'snapshots/')); |
|
|
485 |
|
|
|
486 |
//On passe l'ancien snapshot en SD. |
|
|
487 |
var currentImgSrc = $('img', _this.previousZoomedSN).attr('src'); |
|
|
488 |
$('img', _this.previousZoomedSN).attr('src', currentImgSrc.replace('snapshots/', 'snapshots-little/')); |
|
|
489 |
|
|
|
490 |
$('#snapshotDiv-' + destinationId).css('opacity', '1'); |
|
|
491 |
|
|
52
|
492 |
//Si le player est prêt. |
|
|
493 |
if(_this.playerIsReady) |
|
|
494 |
{ |
|
|
495 |
//Si on est en mode timeline on la quitte. |
|
|
496 |
if(_this.currentMode == 'TIMELINE') |
|
|
497 |
{ |
|
|
498 |
_this.exitTimeline('move'); |
|
|
499 |
} |
|
|
500 |
|
|
|
501 |
//Si le move est automatique (fin de vidéo). |
|
|
502 |
if(_this.autoMove) |
|
|
503 |
{ |
|
|
504 |
//On remet à jour la position du curseur de la vidéo. |
|
|
505 |
_this.timeToGoAt[_this.centerId] = 0; |
|
|
506 |
_this.autoMove = false; |
|
|
507 |
} |
|
|
508 |
//Sinon on revient là où on était la dernière fois que la video a été jouée. |
|
|
509 |
else |
|
|
510 |
{ |
|
|
511 |
_this.timeToGoAt[_this.centerId] = Math.floor(_this.player.popcorn.currentTime()); |
|
|
512 |
} |
|
|
513 |
//On libère le player. |
|
|
514 |
_this.player.widgets[0].freePlayer(); |
|
|
515 |
_this.playerIsReady = false; |
|
|
516 |
$('.LdtPlayer').remove(); |
|
|
517 |
$('body').append('<div class="LdtPlayer" id="LdtPlayer"></div>'); |
|
|
518 |
} |
|
|
519 |
|
|
|
520 |
//On obtient l'ID du div de coloration du snapshot vers lequel on se déplace afin de le supprimer. |
|
44
|
521 |
_this.centerId = destinationId; |
|
52
|
522 |
|
|
44
|
523 |
//On grise le snapshot qu'on vient de quitter. |
|
52
|
524 |
_this.previousZoomedSN.fadeTo(_this.config.zoomTime, '0.4'); |
|
44
|
525 |
|
|
52
|
526 |
//console.log(MPCurrentLeft); |
|
|
527 |
|
|
44
|
528 |
//On se déplace. |
|
|
529 |
$('#mainPanel').animate( |
|
|
530 |
{ |
|
|
531 |
top: MPCurrentTop, |
|
|
532 |
left: MPCurrentLeft |
|
52
|
533 |
}, _this.config.timeMovingToNeighbour, function() |
|
44
|
534 |
{ |
|
52
|
535 |
//On passe en mode recherche et on recherche dans la vidéo en fonction de la gesture de recherche enregistrée dans la nouvelle vidéo. |
|
|
536 |
if(_this.currentSearchGesture[_this.centerId] != '') |
|
|
537 |
{ |
|
|
538 |
_this.currentMode = 'SEARCH'; |
|
|
539 |
_this.isCurrentlyInASearchByGesture = true; |
|
|
540 |
_this.removeNotifications(); |
|
|
541 |
_this.searchGesture(_this.currentSearchGesture[_this.centerId], 'valid'); |
|
|
542 |
} |
|
|
543 |
|
|
44
|
544 |
//On fait apparaître le snapshot vers lequel on s'est déplacé. |
|
52
|
545 |
$('#snapshotDiv-' + destinationId).fadeTo(_this.config.zoomTime, '1', function() |
|
44
|
546 |
{ |
|
|
547 |
//On recharge les voisins. |
|
|
548 |
_this.previousZoomedSN = $('#snapshotDiv-' + _this.centerId); |
|
|
549 |
|
|
52
|
550 |
_this.notifyTopVideo = MPCurrentTop; |
|
|
551 |
_this.notifyLeftVideo = MPCurrentLeft; |
|
|
552 |
_this.neighboursIds.length = 0; |
|
|
553 |
_this.currentlyMoving = false; |
|
|
554 |
_this.listenToNeighbours(); |
|
|
555 |
|
|
|
556 |
//On charge le player. |
|
|
557 |
_this.loadPlayer((destinationImg.position().top + MPCurrentTop + _this.MPTop_margin), (destinationImg.position().left + MPCurrentLeft), destinationImg.width(), destinationImg.height(), MPCurrentTop, MPCurrentLeft, _this.timeToGoAt[_this.centerId]); |
|
44
|
558 |
}); |
|
|
559 |
}); |
|
|
560 |
} |
|
|
561 |
|
|
|
562 |
/* |
|
|
563 |
* Donne éventuellement un snapshot d'après les coordonnées du pointeur sur l'écran. |
|
|
564 |
* Renvoie null sinon. |
|
52
|
565 |
* Est appelé : dans les fichiers pointers > fonction pointersMosaicInteractions et pointersVideoInteractions et zoomInteractions > zoom. |
|
44
|
566 |
*/ |
|
52
|
567 |
Mosaic.prototype.pointerPositionToSN = function(x, y, isMainPointer) |
|
44
|
568 |
{ |
|
52
|
569 |
if(this.helpDisplayed) |
|
|
570 |
{ |
|
|
571 |
return; |
|
|
572 |
} |
|
|
573 |
|
|
|
574 |
x += $('#mainPointer').width() / 2; |
|
|
575 |
y += $('#mainPointer').height() / 2; |
|
|
576 |
|
|
|
577 |
//Taille de la marge des snapshots. |
|
|
578 |
var m = parseInt($('.snapshotDivs').css('margin')); |
|
|
579 |
|
|
|
580 |
//Dimensions d'un snapshot de la mosaïque. |
|
|
581 |
var W = $('.snapshotDivs').width() + m * 2, H = $('.snapshotDivs').height() + m * 2; |
|
|
582 |
|
|
|
583 |
//Position supposée du snapshot dans la mosaïque. |
|
|
584 |
//Au départ on ne sélectionne rien. |
|
|
585 |
var i = -1, j = -1; |
|
|
586 |
|
|
|
587 |
//Espace de centrage vertical de la mosaïque. |
|
|
588 |
var top_margin = parseInt(this.MPTop_margin); |
|
|
589 |
//Dimensions de la mosaïque en nombre de snapshots. |
|
55
|
590 |
var mosW = this.config.imagesByLine, mosH = this.config.imagesToShow / mosW; |
|
52
|
591 |
|
|
|
592 |
//Si le pointeur se trouve au niveau de la mosaïque. |
|
|
593 |
if(x < W * mosW && y >= top_margin && y < H * mosH + top_margin) |
|
|
594 |
{ |
|
|
595 |
//Si le pointeur est sur une des bordures. |
|
|
596 |
var xb = x % W; |
|
|
597 |
var yb = y - top_margin; |
|
|
598 |
yb %= H; |
|
|
599 |
|
|
|
600 |
if(xb < m || xb > W - m || yb < m || yb > H - m) |
|
|
601 |
{ |
|
|
602 |
//On renvoie null. |
|
|
603 |
return null; |
|
|
604 |
} |
|
|
605 |
//Sinon il est forcément sur un des snapshots. |
|
|
606 |
else |
|
|
607 |
{ |
|
|
608 |
i = Math.floor(x / W); |
|
|
609 |
j = Math.floor((y - top_margin) / H); |
|
|
610 |
} |
|
|
611 |
|
|
|
612 |
//On passe des coordonnées 2D en 1D. |
|
|
613 |
var snapshot = $('#snapshotDiv-' + (j * mosW + i)); |
|
|
614 |
|
|
|
615 |
//Si le snapshot a été filtré, on renvoie null si on se trouve dans la mosaïque. |
|
|
616 |
if(this.isMosaicFiltered && (this.currentMode == "MOSAIC" || this.currentMode == "FILTER") && snapshot.css('opacity') == 0) |
|
|
617 |
{ |
|
|
618 |
return null; |
|
|
619 |
} |
|
|
620 |
|
|
|
621 |
//On renvoie le snapshot. |
|
|
622 |
return snapshot; |
|
|
623 |
} |
|
|
624 |
|
|
|
625 |
//Si on est arrivé là, c'est que le pointeur n'est pas dans la mosaïque. |
|
|
626 |
return null; |
|
44
|
627 |
} |
|
|
628 |
|
|
|
629 |
/* |
|
|
630 |
* Donne éventuellement un voisin additionnel d'après les coordonnées du pointeur sur l'écran. |
|
|
631 |
* Renvoie null sinon. |
|
52
|
632 |
* Est appelé : dans le fichier pointers > fonction pointersVideoInteractions. |
|
44
|
633 |
*/ |
|
52
|
634 |
Mosaic.prototype.pointerPositionToAN = function(x, y, isMainPointer) |
|
44
|
635 |
{ |
|
52
|
636 |
//Si l'aide est affichée, on part. |
|
|
637 |
if(this.helpDisplayed) |
|
|
638 |
{ |
|
|
639 |
return; |
|
|
640 |
} |
|
|
641 |
|
|
|
642 |
x += $('#mainPointer').width() / 2; |
|
|
643 |
y += $('#mainPointer').height() / 2; |
|
|
644 |
|
|
|
645 |
//Pour tous les voisins. |
|
|
646 |
for(var i = 0 ; i < this.neighboursIds.length ; i++) |
|
|
647 |
{ |
|
|
648 |
//Si on est sur un bord. |
|
|
649 |
if(this.neighboursIds[i] == -1) |
|
|
650 |
{ |
|
|
651 |
//On récupère un voisin au delà du bord. |
|
|
652 |
var neighbour = $('#borderNeighbour-' + i); |
|
|
653 |
|
|
|
654 |
if(neighbour == null || neighbour == undefined || neighbour.position() == null) |
|
|
655 |
{ |
|
|
656 |
return; |
|
|
657 |
} |
|
|
658 |
|
|
|
659 |
//Si le pointeur est sur le voisin, on le retourne. |
|
|
660 |
if(x > neighbour.position().left && x < +neighbour.position().left + neighbour.width() && y > neighbour.position().top && y < +neighbour.position().top + neighbour.height()) |
|
|
661 |
{ |
|
|
662 |
return neighbour; |
|
|
663 |
} |
|
|
664 |
} |
|
|
665 |
} |
|
|
666 |
return null; |
|
44
|
667 |
} |
|
|
668 |
|
|
|
669 |
/* |
|
|
670 |
* Vérifie l'intéraction dézoom. |
|
52
|
671 |
* Est appelé : dans le fichier pointers > fonction pointersVideoInteractions. |
|
44
|
672 |
*/ |
|
52
|
673 |
Mosaic.prototype.checkForDezoom = function() |
|
44
|
674 |
{ |
|
52
|
675 |
//Si on se trouve en mode VIDEO ou SEARCH. |
|
|
676 |
if(this.currentMode == "VIDEO" || this.currentMode == "SEARCH") |
|
|
677 |
{ |
|
|
678 |
//Si les deux pointeurs sont allés puis ont quitté une bordure. |
|
|
679 |
if(this.mainPointerExitBorder && this.secondPointerExitBorder) |
|
|
680 |
{ |
|
|
681 |
//Si les voisins existent. |
|
|
682 |
if(this.neighboursIds != null && this.neighboursIds.length > 0) |
|
|
683 |
{ |
|
|
684 |
var localIdMainPointerNeighbour = $.inArray(this.mainPointerNeighbourSelectedId, this.neighboursIds); |
|
|
685 |
var localIdSecondPointerNeighbour = $.inArray(this.secondPointerNeighbourSelectedId, this.neighboursIds); |
|
|
686 |
|
|
|
687 |
//Cas où on a des voisins additionnels. |
|
|
688 |
if(this.mainPointerNeighbourSelectedId >= this.config.imagesToShow) |
|
|
689 |
{ |
|
|
690 |
localIdMainPointerNeighbour = this.mainPointerNeighbourSelectedId - this.config.imagesToShow; |
|
|
691 |
} |
|
|
692 |
if(this.secondPointerNeighbourSelectedId >= this.config.imagesToShow) |
|
|
693 |
{ |
|
|
694 |
localIdSecondPointerNeighbour = this.secondPointerNeighbourSelectedId - this.config.imagesToShow; |
|
|
695 |
} |
|
|
696 |
|
|
|
697 |
if(localIdMainPointerNeighbour > -1 && localIdMainPointerNeighbour < 4 && localIdSecondPointerNeighbour > -1 && localIdSecondPointerNeighbour < 4) |
|
|
698 |
{ |
|
|
699 |
var sym = (localIdMainPointerNeighbour % 2 == 0) ? (+localIdMainPointerNeighbour + 1) : (localIdMainPointerNeighbour - 1); |
|
|
700 |
|
|
|
701 |
//Si les voisins sélectionnés sont opposés. |
|
|
702 |
if(sym == localIdSecondPointerNeighbour) |
|
|
703 |
{ |
|
|
704 |
//Positions des pointeurs. |
|
|
705 |
var xMain = $('#mainPointer').position().left - $('#mainPointer').width() / 2; |
|
|
706 |
var yMain = $('#mainPointer').position().top - $('#mainPointer').height() / 2; |
|
|
707 |
var xSecond = $('#secondPointer').position().left - $('#secondPointer').width() / 2; |
|
|
708 |
var ySecond = $('#secondPointer').position().top - $('#secondPointer').height() / 2; |
|
|
709 |
|
|
|
710 |
//Snapshot central. |
|
|
711 |
var centerSN = $('#snapshotDiv-' + this.centerId); |
|
|
712 |
|
|
|
713 |
//Quarts du snapshot central. |
|
|
714 |
var center1QuartWidth = centerSN.position().left + this.notifyLeftVideo + centerSN.width() / 4; |
|
|
715 |
var center3QuartsWidth = centerSN.position().left + this.notifyLeftVideo + centerSN.width() * 3 / 4; |
|
|
716 |
var center1QuartHeight = centerSN.position().top + this.notifyTopVideo + centerSN.height() / 4; |
|
|
717 |
var center3QuartsHeight = centerSN.position().top + this.notifyTopVideo + centerSN.height() * 3 / 4; |
|
|
718 |
|
|
|
719 |
//Pour activer le dézoom, il suffit que les pointeurs soient dans un rectangle délimité au centre de l'écran. |
|
|
720 |
//Si les voisins sélectionnés sont de disposition horizontale. |
|
|
721 |
if(sym == 0 || sym == 1) |
|
|
722 |
{ |
|
|
723 |
if(xMain > center1QuartWidth && xSecond > center1QuartWidth && xMain < center3QuartsWidth && xSecond < center3QuartsWidth) |
|
|
724 |
{ |
|
|
725 |
this.unzoom(); |
|
|
726 |
} |
|
|
727 |
} |
|
|
728 |
//Sinon s'ils sont de disposition verticale. |
|
|
729 |
else if(sym == 2 || sym == 3) |
|
|
730 |
{ |
|
|
731 |
if(yMain > center1QuartHeight && ySecond > center1QuartHeight && yMain < center3QuartsHeight && ySecond < center3QuartsHeight) |
|
|
732 |
{ |
|
|
733 |
this.unzoom(); |
|
|
734 |
} |
|
|
735 |
} |
|
|
736 |
} |
|
|
737 |
} |
|
|
738 |
} |
|
|
739 |
} |
|
|
740 |
} |
|
44
|
741 |
} |