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