|
30
|
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 : mosaic.js |
|
|
14 |
* |
|
|
15 |
* Auteur : alexandre.bastien@iri.centrepompidou.fr |
|
|
16 |
* |
|
|
17 |
* Fonctionnalités : Définit la "classe" mosaïque et définit des fonctions d'intéractions. |
|
|
18 |
*/ |
|
|
19 |
|
|
|
20 |
/* |
|
|
21 |
* Classe définissant la mosaïque. |
|
|
22 |
* Elle contient sa longueur, le nombre d'images total, une liste d'urls pour les vidéos, leurs snapshots principaux et leur position. |
|
|
23 |
* Contient également les dimensions en px de la mosaïque. |
|
|
24 |
*/ |
|
33
|
25 |
function mosaic(len, imgToShow, imgTotal, zoomPercentage, prezoomPercentage, zoomedMargin) |
|
30
|
26 |
{ |
|
|
27 |
//S'il s'agit d'un rectangle. |
|
|
28 |
if(imgToShow % len == 0) |
|
|
29 |
{ |
|
|
30 |
//Longueur horizontale. |
|
|
31 |
this.length = len; |
|
|
32 |
//Nombre d'images dans la mosaïque. |
|
33
|
33 |
this.imagesToShow = imgToShow; |
|
|
34 |
this.imagesTotal = imgTotal; |
|
30
|
35 |
//Tableaux des urls des vidéos, des snapshots et de leur position dans la mosaïque. |
|
32
|
36 |
this.videos = []; |
|
30
|
37 |
this.urls = []; |
|
|
38 |
this.imgs = []; |
|
33
|
39 |
this.ids = []; |
|
|
40 |
//On remplit le tableau d'ids. |
|
|
41 |
for(var i = 0 ; i < this.imagesTotal ; i++) |
|
|
42 |
this.ids.push(i); |
|
|
43 |
//On les mélange. |
|
|
44 |
this.ids.sort(function() |
|
|
45 |
{ |
|
|
46 |
return 0.5 - Math.random() |
|
|
47 |
}); |
|
|
48 |
|
|
|
49 |
console.log(this.ids); |
|
|
50 |
|
|
30
|
51 |
//Dimensions de la mosaïque en pixels. |
|
|
52 |
this.width; |
|
|
53 |
this.height; |
|
|
54 |
//Dimensions d'un snapshot en pixels. |
|
|
55 |
this.snapshotWidth; |
|
|
56 |
this.snapshotHeight; |
|
|
57 |
//Espacement entre les snapshots en pixels. |
|
|
58 |
this.marginWidth; |
|
|
59 |
|
|
|
60 |
//Temps d'intéractions/d'animations. |
|
|
61 |
this.preZoomTime; |
|
|
62 |
this.preUnzoomTime; |
|
|
63 |
this.zoomTime; |
|
|
64 |
this.unzoomTime; |
|
|
65 |
this.timeNeighbourGlowing; |
|
|
66 |
this.timeNeighbourUnglowing; |
|
|
67 |
this.timeMovingToNeighbour; |
|
33
|
68 |
this.timeSearchFade; |
|
|
69 |
this.timeNotifyFade; |
|
30
|
70 |
|
|
|
71 |
//Booléens permettant ou non certaines intéractions selon le contexte. |
|
|
72 |
this.zoomed; |
|
|
73 |
this.fullscreen; |
|
|
74 |
this.canMoveToNeighbour; |
|
33
|
75 |
this.helpDisplayed; |
|
30
|
76 |
|
|
|
77 |
//Mode actuel. |
|
|
78 |
this.currentMode; |
|
|
79 |
//Snapshot sur lequel on a zoomé. |
|
|
80 |
this.previousZoomedSN; |
|
|
81 |
//Son ID. |
|
|
82 |
this.previousId; |
|
|
83 |
//Largeur de la marge pour le centrage vertical de la mosaïque. |
|
|
84 |
this.MPTop_margin; |
|
|
85 |
this.top_margin; |
|
|
86 |
//Pourcentage d'agrandissement lors d'un prézoom et d'un zoom. |
|
|
87 |
this.prezoomPercentage = prezoomPercentage; |
|
|
88 |
this.zoomPercentage = zoomPercentage; |
|
|
89 |
//Espacement des snapshots après un zoom. |
|
|
90 |
this.zoomedMargin = zoomedMargin; |
|
|
91 |
//Mosaïque locale. |
|
|
92 |
this.localMos; |
|
|
93 |
//Position des voisins lors d'un zoom. |
|
|
94 |
this.neighboursIds = []; |
|
|
95 |
//ID du snapshot du milieu lors d'un zoom. |
|
|
96 |
this.centerId; |
|
32
|
97 |
|
|
33
|
98 |
//Lecteur. |
|
32
|
99 |
this.player; |
|
|
100 |
|
|
33
|
101 |
//Coordonnées et dimensions d'un snapshot zoomé. |
|
|
102 |
this.snTop = 0; |
|
|
103 |
this.snLeft = 0; |
|
|
104 |
this.snWidth = 0; |
|
|
105 |
this.snHeight = 0; |
|
|
106 |
|
|
|
107 |
this.searchCanvas; |
|
|
108 |
|
|
32
|
109 |
this.loadFromJson('./player/json/videos.json'); |
|
30
|
110 |
} |
|
|
111 |
else |
|
|
112 |
{ |
|
|
113 |
//Affiche un message d'erreur. |
|
|
114 |
} |
|
|
115 |
} |
|
|
116 |
|
|
|
117 |
/* |
|
|
118 |
* Méthode d'affichage de la mosaïque. |
|
|
119 |
* Génère une matrice de imgs. |
|
|
120 |
*/ |
|
|
121 |
mosaic.prototype.createMosaic = function() |
|
|
122 |
{ |
|
|
123 |
this.previousZoomedSN = ''; |
|
|
124 |
this.previousPrezoomDiv = ''; |
|
|
125 |
this.fullscreen = false; |
|
|
126 |
this.canMoveToNeighbour = false; |
|
33
|
127 |
this.helpDisplayed = false; |
|
30
|
128 |
var str = ''; |
|
|
129 |
|
|
|
130 |
if(this.imgs.length >= this.imagesToShow) |
|
|
131 |
{ |
|
|
132 |
for(var i = 0 ; i < this.imagesToShow ; i++) |
|
|
133 |
{ |
|
|
134 |
//On charge les images de petite taille pour ne pas surcharger la mosaïque lors de l'affichage global. |
|
|
135 |
str += '<div id="snapshotDiv-' + i + '" class="snapshotDivs"><img id="snapshot-' + i + '" class="snapshots" src="snapshots-little/' + this.imgs[i] + '" /></div>'; |
|
|
136 |
} |
|
|
137 |
} |
|
|
138 |
|
|
32
|
139 |
console.log(this.imagesToShow); |
|
|
140 |
|
|
30
|
141 |
return str; |
|
|
142 |
} |
|
|
143 |
|
|
|
144 |
/* |
|
|
145 |
* Permet de raffraichir la mosaïque. |
|
|
146 |
*/ |
|
32
|
147 |
mosaic.prototype.loadMosaic = function() |
|
30
|
148 |
{ |
|
32
|
149 |
var createMosaic = this.createMosaic(); |
|
|
150 |
|
|
|
151 |
if(createMosaic == '') |
|
|
152 |
{ |
|
|
153 |
return; |
|
|
154 |
} |
|
|
155 |
|
|
|
156 |
var _this = this; |
|
|
157 |
|
|
30
|
158 |
//On affecte les chemins vers les images à la mosaïque. |
|
|
159 |
this.previousZoomedSN; |
|
|
160 |
//this.width = |
|
|
161 |
//On met à jour la mosaïque. |
|
32
|
162 |
$('#mainPanel').html(createMosaic); |
|
30
|
163 |
//On récupère la taille des bordures. |
|
|
164 |
this.marginWidth = $('.snapshotDivs').css('margin-bottom'); |
|
|
165 |
this.marginWidth = parseFloat(mos.marginWidth)*2; |
|
|
166 |
//On calcule la taille des divs contenant les snapshots. |
|
|
167 |
this.width = $('#mainPanel').innerWidth(); |
|
|
168 |
//On ne calculera pas tout de suite la hauteur de la mosaique étant donnée qu'elle est calculée par la suite dynamiquement. |
|
|
169 |
this.snapshotWidth = this.width / this.length - this.marginWidth; |
|
|
170 |
this.snapshotHeight = this.snapshotWidth*9/16; |
|
|
171 |
$('.snapshotDivs').css('width', this.snapshotWidth).css('height', this.snapshotHeight).css('margin', this.marginWidth/2); |
|
|
172 |
|
|
|
173 |
this.height = $('#mainPanel').innerHeight(); |
|
|
174 |
//On centre verticalement la mosaïque. |
|
|
175 |
this.MPTop_margin = ($(document).height() - $('#mainPanel').height())/2; |
|
|
176 |
$('#mainPanel').css('margin-top', this.MPTop_margin).css('margin-bottom', this.MPTop_margin); |
|
32
|
177 |
|
|
33
|
178 |
//On affiche les notifications. |
|
|
179 |
this.notifySelectionSearchMosaicFull(); |
|
|
180 |
|
|
32
|
181 |
$('.snapshotDivs').mouseenter(function () |
|
|
182 |
{ |
|
|
183 |
//On effectue un prézoom dès qu'on va sur une image. |
|
|
184 |
_this.preZoom($(this)); |
|
|
185 |
}); |
|
|
186 |
$('body').keypress(function (event) |
|
|
187 |
{ |
|
|
188 |
//Si on a appuié sur la touche 'q' ou 'Q'; |
|
|
189 |
if(event.which == 113 || event.which == 81) |
|
|
190 |
{ |
|
|
191 |
_this.unzoom(); |
|
|
192 |
} |
|
|
193 |
}); |
|
30
|
194 |
} |
|
|
195 |
|
|
|
196 |
/* |
|
|
197 |
* Zoom sur la position d'une image, 1ère partie. Durant le laps de temps de time ms, l'utilisateur a le choix de zoomer sur une autre image. |
|
|
198 |
* Après ce laps de temps, l'image zoom complétement et il n'est plus possible de sélectionner une autre image par pointage. |
|
|
199 |
*/ |
|
|
200 |
mosaic.prototype.preZoom = function(snapshot) |
|
|
201 |
{ |
|
|
202 |
if(this.fullscreen) |
|
31
|
203 |
{ |
|
30
|
204 |
return; |
|
31
|
205 |
} |
|
33
|
206 |
|
|
|
207 |
//On enlève les notifications initiales si elles existent. |
|
|
208 |
this.removeSelectionSearchMosaicFull(); |
|
|
209 |
|
|
30
|
210 |
//Mosaïque. |
|
|
211 |
var mosaic = this; |
|
|
212 |
//Dimensions de la mosaïque. |
|
|
213 |
var h = this.height, w = this.width; |
|
|
214 |
//Longueur en images, nombre d'images et taille de bordure de la mosaïque. |
|
|
215 |
var len = this.length, imgs = this.imagesToShow, margin = this.marginWidth; |
|
|
216 |
//Dimensions et position d'un snapshot dans la mosaïque. |
|
|
217 |
var snHeight = this.snapshotHeight, snWidth = this.snapshotWidth; |
|
|
218 |
var sTop = snapshot.position().top, sLeft = snapshot.position().left; |
|
|
219 |
var prezoomPercentage = this.prezoomPercentage; |
|
|
220 |
|
|
|
221 |
//ID de l'image actuelle. |
|
|
222 |
var currentId = $('img', snapshot).attr('id'); |
|
|
223 |
|
|
|
224 |
//Si un zoom est déjà en cours, on ne zoom sur rien d'autre en attendant que ce snapshot ai dézoomé en cas de mouseleave. |
|
|
225 |
if(this.zoomed) |
|
31
|
226 |
{ |
|
30
|
227 |
if($('#preZoomContainer-' + currentId) != $(this) && this.previousZoomedSN != '' && this.previousId != '') |
|
31
|
228 |
{ |
|
30
|
229 |
this.preUnzoom(); |
|
31
|
230 |
} |
|
30
|
231 |
else |
|
31
|
232 |
{ |
|
30
|
233 |
return; |
|
31
|
234 |
} |
|
|
235 |
} |
|
30
|
236 |
|
|
|
237 |
//On indique qu'on a zoomé et on spécifie le snapshot sur lequel on a zoomé. |
|
|
238 |
this.zoomed = true; |
|
|
239 |
this.previousZoomedSN = snapshot; |
|
|
240 |
this.previousId = currentId; |
|
|
241 |
|
|
|
242 |
//On récupère les attributs de l'image. |
|
|
243 |
var fakeImg = $('img', snapshot); |
|
|
244 |
//On forme la balise de la fausse image et on passe son url pour les grands snapshots. |
|
|
245 |
fakeImg = '<img id="fake-' + currentId + '" class="snapshots" src="' + fakeImg.attr('src').replace('-little/', '/') + '" />'; |
|
|
246 |
//On génère un faux snapshot identique au précédent et qu'on va coller dessus. |
|
|
247 |
var fakeSnapshot = '<div id="prezoomContainer-' + currentId + '" class="prezoomContainers"><div id="prezoomSnapshot-' + currentId + '" class="snapshotDivs">' + fakeImg + '</div></div>'; |
|
|
248 |
|
|
|
249 |
//On l'ajoute à la mosaïque. |
|
|
250 |
$('#mainPanel').append(fakeSnapshot); |
|
|
251 |
//On modifie ses attributs. |
|
|
252 |
$('#fake-' + currentId).load(function() |
|
|
253 |
{ |
|
|
254 |
$('#prezoomContainer-' + currentId).css('display', 'block'); |
|
|
255 |
$('#prezoomContainer-' + currentId).css('top', sTop).css('left', sLeft).css('width', (snWidth + margin)).css('height', (snHeight + margin)); |
|
|
256 |
$('#prezoomSnapshot-' + currentId).css('width', (snWidth)).css('height', (snHeight)); |
|
|
257 |
|
|
|
258 |
//Dimensions et coordonnées initiales du div sur lequel on zoom. |
|
|
259 |
var initialDivWidth = $('#prezoomContainer-' + currentId).width(), initialDivHeight = $('#prezoomContainer-' + currentId).height(); |
|
|
260 |
var initialDivTop = $('#prezoomContainer-' + currentId).position().top, initialDivLeft = $('#prezoomContainer-' + currentId).position().left; |
|
|
261 |
//Dimensions et coordonnées finales du div. |
|
|
262 |
var finalDivWidth = initialDivWidth * (prezoomPercentage+1), diffWidth = finalDivWidth - initialDivWidth, finalDivHeight = initialDivHeight + diffWidth; |
|
|
263 |
var finalDivTop = (initialDivTop - (finalDivHeight - snHeight)/2), finalDivLeft = (initialDivLeft - (finalDivWidth - snWidth)/2); |
|
|
264 |
|
|
|
265 |
//CAS PARTICULIER pour la position du snapshot zoomé : les bordures. |
|
|
266 |
if(finalDivTop < 0) |
|
31
|
267 |
{ |
|
30
|
268 |
finalDivTop = -margin; |
|
31
|
269 |
} |
|
30
|
270 |
if(finalDivTop + finalDivHeight > h) |
|
31
|
271 |
{ |
|
30
|
272 |
finalDivTop = h - finalDivHeight; |
|
31
|
273 |
} |
|
30
|
274 |
if(finalDivLeft < 0) |
|
31
|
275 |
{ |
|
30
|
276 |
finalDivLeft = 0; |
|
31
|
277 |
} |
|
30
|
278 |
if(finalDivLeft + finalDivWidth + margin*2 > w) |
|
31
|
279 |
{ |
|
30
|
280 |
finalDivLeft = w - finalDivWidth - margin*2; |
|
31
|
281 |
} |
|
30
|
282 |
|
|
|
283 |
////Code de debug. |
|
|
284 |
////CAUTION//// |
|
|
285 |
/*var red = '<div id="red"></div>'; |
|
|
286 |
if($('#red') != null || $('#red') != undefined) |
|
|
287 |
$('body').append(red); |
|
|
288 |
$('#red').css('background-color', '#FF0000').css('position', 'absolute').css('top', '0px').css('left', '0px').css('width', '100px').css('height', '100px'); |
|
|
289 |
$('#red').css('top', finalDivTop).css('left', finalDivLeft).css('width', finalDivWidth).css('height', finalDivHeight);*/ |
|
|
290 |
//alert("initial : " + initialDivWidth + " " + initialDivHeight + " ; final : " + finalDivWidth + " " + finalDivHeight); |
|
|
291 |
////CAUTION//// |
|
|
292 |
|
|
|
293 |
//On prézoom le div en le centrant sur le milieu du snapshot pointé. |
|
|
294 |
$('#prezoomSnapshot-' + currentId).animate( |
|
|
295 |
{ |
|
|
296 |
width: finalDivWidth + margin, |
|
|
297 |
height: finalDivHeight - margin*2, |
|
|
298 |
top: finalDivTop + margin, |
|
|
299 |
left: finalDivLeft + margin |
|
|
300 |
}, this.preZoomTime); |
|
|
301 |
$('#prezoomContainer-' + currentId).animate( |
|
|
302 |
{ |
|
|
303 |
width: finalDivWidth + margin*2, |
|
|
304 |
height: finalDivHeight - margin, |
|
|
305 |
top: finalDivTop + margin, |
|
|
306 |
left: finalDivLeft |
|
33
|
307 |
}, this.preZoomTime, function() |
|
|
308 |
{ |
|
|
309 |
mosaic.notifyPointMosaicPrezoom(); |
|
|
310 |
}); |
|
30
|
311 |
}); |
|
|
312 |
|
|
|
313 |
//Si on clique sur le snapshot prézoomé, on enclenche un zoom total sur ce snapshot. |
|
|
314 |
$('#prezoomContainer-' + currentId).click(function () |
|
|
315 |
{ |
|
|
316 |
if(this.previousZoomedSN != '') |
|
31
|
317 |
{ |
|
30
|
318 |
mosaic.zoom(); |
|
31
|
319 |
} |
|
30
|
320 |
}); |
|
|
321 |
} |
|
|
322 |
|
|
|
323 |
/* |
|
|
324 |
* Dézoome sur la position de l'image. Il est à noter que ce dézoome diffère du dézoom global dans la mesure où celui-ci ne concerne que l'image sur laquelle on a zoomé. |
|
|
325 |
*/ |
|
|
326 |
mosaic.prototype.preUnzoom = function() |
|
|
327 |
{ |
|
|
328 |
//Si on n'a pas zoomé, on quitte la fonction. |
|
|
329 |
if(!this.zoomed) |
|
31
|
330 |
{ |
|
30
|
331 |
return; |
|
31
|
332 |
} |
|
33
|
333 |
|
|
|
334 |
this.removePointMosaicPrezoom(); |
|
30
|
335 |
|
|
|
336 |
//On spécifie la marge afin de centrer le prédézoom. |
|
|
337 |
var margin = this.marginWidth; |
|
|
338 |
//ID du snapshot précédemment pointé. |
|
|
339 |
var id = this.previousId; |
|
|
340 |
//On ne zoom plus. |
|
|
341 |
this.zoomed = false; |
|
|
342 |
//On rétrécit le snapshot de prézoom, puis on le supprime en donnant l'illusion qu'il s'agissait du véritable snapshot, alors qu'en fait c'était un clone. |
|
|
343 |
$('#prezoomSnapshot-' + id).animate( |
|
|
344 |
{ |
|
|
345 |
width: this.snapshotWidth, |
|
|
346 |
height: this.snapshotHeight, |
|
|
347 |
top: this.previousZoomedSN.position().top, |
|
|
348 |
left: this.previousZoomedSN.position().left |
|
|
349 |
}, this.preUnzoomTime); |
|
|
350 |
$('#prezoomContainer-' + id).animate( |
|
|
351 |
{ |
|
|
352 |
width: this.snapshotWidth + margin, |
|
|
353 |
height: this.snapshotHeight + margin, |
|
|
354 |
top: this.previousZoomedSN.position().top, |
|
|
355 |
left: this.previousZoomedSN.position().left |
|
|
356 |
}, this.preUnzoomTime, function(){ $(this).remove(); this.zoomed = false; }); |
|
|
357 |
} |
|
|
358 |
|
|
|
359 |
|
|
|
360 |
/* |
|
|
361 |
* Zoom d'un snapshot en plein écran. |
|
|
362 |
*/ |
|
|
363 |
mosaic.prototype.zoom = function() |
|
|
364 |
{ |
|
|
365 |
var mos = this; |
|
|
366 |
|
|
|
367 |
//Si la mosaïque est en pleine écran, pas la peine de zoomer. |
|
|
368 |
if(this.fullscreen) |
|
31
|
369 |
{ |
|
30
|
370 |
return; |
|
31
|
371 |
} |
|
33
|
372 |
|
|
|
373 |
this.removePointMosaicPrezoom(); |
|
30
|
374 |
|
|
|
375 |
//On prend les attributs nécessaires au calculs. |
|
|
376 |
var margin = this.marginWidth, len = this.length, imgs = this.imagesToShow; |
|
|
377 |
var initMPWidth = this.previousZoomedSN.width() * len + margin*len, initMPHeight = this.previousZoomedSN.height() * (imgs / len) + margin*(imgs / len); |
|
|
378 |
var newMPWidth = initMPWidth * len + this.zoomedMargin * (len), newMPHeight = initMPHeight * (imgs / len) + this.zoomedMargin * ((imgs / len)); |
|
|
379 |
var newPreMPWidth = initMPWidth * len * this.zoomPercentage + this.zoomedMargin * (len), newPreMPHeight = initMPHeight * (imgs / len) * this.zoomPercentage + this.zoomedMargin * ((imgs / len)); |
|
|
380 |
|
|
|
381 |
//Dimensions et coordonnées initiales du div sur lequel on zoom. |
|
|
382 |
var initialDivWidth = this.previousZoomedSN.width(), initialDivHeight = this.previousZoomedSN.height(); |
|
|
383 |
var initialDivTop = this.previousZoomedSN.position().top, initialDivLeft = this.previousZoomedSN.position().left; |
|
|
384 |
//Dimensions et coordonnées finales du div. |
|
|
385 |
var finalDivWidth = initialDivWidth * (this.zoomPercentage+1), finalDivHeight = initialDivHeight * (this.zoomPercentage+1); |
|
31
|
386 |
var newZoomTop = -this.previousZoomedSN.position().top*(newPreMPHeight/initMPHeight) - this.zoomedMargin/2 + (initMPHeight - initMPHeight * this.zoomPercentage)/2, newZoomLeft = -this.previousZoomedSN.position().left*(newPreMPWidth/initMPWidth) - this.zoomedMargin/2 + (initMPWidth - initMPWidth * this.zoomPercentage)/2; |
|
30
|
387 |
var newSnWidth = initMPWidth * this.zoomPercentage, newSnHeight = initMPHeight * this.zoomPercentage; |
|
|
388 |
|
|
|
389 |
this.preUnzoom(this); |
|
|
390 |
/*SINGULARITE*/ |
|
|
391 |
this.fullscreen = true; |
|
|
392 |
|
|
|
393 |
//On passe l'image du snapshot pointé en HD. |
|
|
394 |
var zoomedImg = $('img', this.previousZoomedSN); |
|
|
395 |
var src = zoomedImg.attr('src'); |
|
|
396 |
zoomedImg.attr('src', src.replace('-little/', '/')); |
|
|
397 |
|
|
|
398 |
//On récupère son ID. |
|
|
399 |
var tab, zoomedImgId; |
|
|
400 |
tab = mos.previousId.split('-'); |
|
|
401 |
zoomedImgId = tab[1]; |
|
|
402 |
|
|
|
403 |
//Les snapshots baissent alors en opacité, donnant l'impression qu'ils sont grisés. |
|
|
404 |
$('.snapshotDivs').animate( |
|
|
405 |
{ |
|
|
406 |
width: newSnWidth, |
|
|
407 |
height: newSnHeight, |
|
|
408 |
margin: this.zoomedMargin/2 + 'px', |
|
|
409 |
opacity: '0.4' |
|
|
410 |
}, this.zoomTime); |
|
|
411 |
//Le snapshot du milieu revient à une opacité optimale, ce qui attire l'attention de l'utilisateur. |
|
|
412 |
$(this.previousZoomedSN).animate( |
|
|
413 |
{ |
|
|
414 |
opacity: '1' |
|
|
415 |
}, this.zoomTime); |
|
|
416 |
//On zoome sur la mosaïque. |
|
|
417 |
$('#mainPanel').animate( |
|
|
418 |
{ |
|
|
419 |
width: newPreMPWidth, |
|
|
420 |
height: newPreMPHeight, |
|
|
421 |
top: newZoomTop, |
|
|
422 |
left: newZoomLeft |
|
|
423 |
}, this.zoomTime, function() |
|
|
424 |
{ |
|
|
425 |
//On charge les interactions avec les voisins. |
|
|
426 |
mos.centerId = zoomedImgId; |
|
|
427 |
mos.listenToNeighbours(); |
|
|
428 |
mos.currentMode = 'VIDEO'; |
|
31
|
429 |
|
|
|
430 |
console.log('h : ' + -newZoomLeft + " " + zoomedImg.position().left); |
|
33
|
431 |
|
|
|
432 |
mos.snTop = (zoomedImg.position().top + newZoomTop + mos.MPTop_margin), mos.snLeft = (zoomedImg.position().left + newZoomLeft); |
|
|
433 |
mos.snWidth = newSnWidth + 1, mos.snHeight = newSnHeight + 1; |
|
31
|
434 |
|
|
33
|
435 |
mos.loadPlayer(mos.snTop, mos.snLeft, mos.snWidth, mos.snHeight, newZoomTop, newZoomLeft); |
|
31
|
436 |
|
|
30
|
437 |
/*mos.unload(); |
|
|
438 |
mos.localMos.loadLocalMosaic(newZoomTop, newZoomLeft, newSnWidth, newSnHeight, mos.imgs, tab[1]);*/ |
|
|
439 |
}); |
|
|
440 |
} |
|
|
441 |
|
|
|
442 |
/* |
|
31
|
443 |
* Chargement du player basé sur le metadataplayer. |
|
|
444 |
*/ |
|
33
|
445 |
mosaic.prototype.loadPlayer = function(newZoomTop, newZoomLeft, newSnWidth, newSnHeight, zoomTop, zoomLeft) |
|
31
|
446 |
{ |
|
|
447 |
//On configure les options de lancement. |
|
|
448 |
IriSP.libFiles.defaultDir = "../lib/"; |
|
|
449 |
IriSP.widgetsDir = "./player/metadataplayer/" |
|
|
450 |
|
|
32
|
451 |
var videoToPlay = this.videos[this.centerId]; |
|
|
452 |
var currentMetadata = this.urls[this.centerId]; |
|
|
453 |
console.log('VIDEO[' + this.centerId + '] : ' + videoToPlay); |
|
|
454 |
console.log('MD[' + this.centerId + '] : ' + currentMetadata); |
|
|
455 |
|
|
31
|
456 |
var _metadata = { |
|
32
|
457 |
url: currentMetadata, |
|
31
|
458 |
format: 'ldt' |
|
|
459 |
}; |
|
33
|
460 |
console.log(zoomTop + " m" + this.marginWidth); |
|
31
|
461 |
var _config = { |
|
|
462 |
gui: { |
|
33
|
463 |
zoomTop: zoomTop - this.marginWidth*2, |
|
|
464 |
zoomLeft: zoomLeft, |
|
31
|
465 |
width: newSnWidth, |
|
|
466 |
height: newSnHeight, |
|
|
467 |
container: 'LdtPlayer', |
|
|
468 |
default_options: { |
|
|
469 |
metadata: _metadata |
|
|
470 |
}, |
|
|
471 |
css:'./player/metadataplayer/LdtPlayer-core.css', |
|
|
472 |
widgets: [ |
|
|
473 |
{ |
|
|
474 |
type: "Timeline" |
|
|
475 |
} |
|
|
476 |
] |
|
|
477 |
}, |
|
|
478 |
player:{ |
|
|
479 |
type: 'html5', // player type |
|
32
|
480 |
video: videoToPlay, |
|
31
|
481 |
live: true, |
|
|
482 |
height: newSnHeight, |
|
|
483 |
width: newSnWidth, |
|
|
484 |
autostart: true |
|
|
485 |
} |
|
|
486 |
}; |
|
|
487 |
|
|
|
488 |
//On positionne le player. |
|
|
489 |
$('.LdtPlayer').css( |
|
|
490 |
{ |
|
|
491 |
//display: 'none', |
|
|
492 |
position: 'absolute', |
|
|
493 |
'background-color': '#000000', |
|
|
494 |
top: newZoomTop, |
|
|
495 |
left: newZoomLeft |
|
|
496 |
}); |
|
|
497 |
|
|
|
498 |
//On démarre le player. |
|
32
|
499 |
this.player = null; |
|
|
500 |
this.player = new IriSP.Metadataplayer(_config, _metadata); |
|
31
|
501 |
} |
|
|
502 |
|
|
|
503 |
/* |
|
30
|
504 |
* Retour à la taille normale de la mosaïque. |
|
|
505 |
*/ |
|
|
506 |
mosaic.prototype.unzoom = function() |
|
|
507 |
{ |
|
|
508 |
//Si on n'est pas en plein écran, on quitte. |
|
|
509 |
if(!this.fullscreen) |
|
31
|
510 |
{ |
|
30
|
511 |
return; |
|
31
|
512 |
} |
|
33
|
513 |
|
|
|
514 |
this.snTop = 0; |
|
|
515 |
this.snLeft = 0; |
|
|
516 |
this.Width = 0; |
|
|
517 |
this.snHeight = 0; |
|
30
|
518 |
|
|
|
519 |
//On charge les attributs nécessaires aux calculs. |
|
|
520 |
var sWidth = this.snapshotWidth, sHeight = this.snapshotHeight; |
|
|
521 |
var mpWidth = this.width, mpHeight = this.height; |
|
|
522 |
var mos = this; |
|
|
523 |
|
|
31
|
524 |
//On passe le snapshot sur lequel on a zoomé en SD. |
|
30
|
525 |
var zoomedImg = $('img', this.previousZoomedSN); |
|
|
526 |
var src = zoomedImg.attr('src'); |
|
|
527 |
zoomedImg.attr('src', src.replace('snapshots/', 'snapshots-little/')); |
|
31
|
528 |
|
|
33
|
529 |
mos.player.widgets[0].freePlayer(); |
|
|
530 |
$('.LdtPlayer').remove(); |
|
31
|
531 |
$('body').append('<div class="LdtPlayer" id="LdtPlayer"></div>'); |
|
30
|
532 |
|
|
|
533 |
//On rend leur opacité aux snapshots. Qui ne sont alors plus grisés. |
|
|
534 |
$('.snapshotDivs').animate( |
|
|
535 |
{ |
|
|
536 |
width: sWidth, |
|
|
537 |
height: sHeight, |
|
|
538 |
margin: this.marginWidth/2 + 'px', |
|
|
539 |
opacity: '1' |
|
|
540 |
}, this.unzoomTime); |
|
|
541 |
//On dézoom sur la mosaïque. |
|
|
542 |
$('#mainPanel').animate( |
|
|
543 |
{ |
|
|
544 |
width: mpWidth, |
|
|
545 |
height: mpHeight, |
|
|
546 |
top: '0px', |
|
|
547 |
left: '0px' |
|
|
548 |
}, this.unzoomTime, function() |
|
|
549 |
{ |
|
|
550 |
//On n'est plus en plein écran, et on ne peut plus se déplacer vers le prochain voisin. |
|
|
551 |
mos.fullscreen = false; |
|
|
552 |
mos.canMoveToNeighbour = false; |
|
|
553 |
//On revient en mode MOSAIC. |
|
|
554 |
mos.currentMode = 'MOSAIC'; |
|
|
555 |
//On ne permet plus le déplacement vers les voisins. |
|
31
|
556 |
$('.snapshotDivs').unbind('mouseenter', mos.selectNeighbour); |
|
33
|
557 |
//On remet les notifications initiales. |
|
|
558 |
mos.notifySelectionSearchMosaicFull(); |
|
30
|
559 |
}); |
|
|
560 |
} |
|
|
561 |
|
|
|
562 |
/* |
|
|
563 |
* Affecte les listeners mouseenter aux voisins lors d'une vue en plein écran. |
|
|
564 |
*/ |
|
|
565 |
mosaic.prototype.listenToNeighbours = function() |
|
|
566 |
{ |
|
|
567 |
////TEST |
|
|
568 |
//$('.test').empty(); |
|
|
569 |
this.canMoveToNeighbour = false; |
|
|
570 |
var currentLine = Math.floor(this.centerId / this.length), currentColumn = this.centerId % this.length; |
|
|
571 |
var zoomedImg = $('img', this.previousZoomedSN); |
|
|
572 |
var mos = this; |
|
|
573 |
|
|
|
574 |
//On cherche l'ID des voisins. |
|
|
575 |
//Si le voisin de gauche est sur la même ligne, on n'est pas sur la bordure de gauche. |
|
|
576 |
this.neighboursIds[0] = (currentColumn > 0) ? (this.centerId - 1) : -1; |
|
|
577 |
//Si le voisin de droite est sur la même ligne, on n'est pas sur la bordure de droite. |
|
|
578 |
this.neighboursIds[1] = (currentColumn < this.length) ? (+this.centerId + 1) : -1; |
|
|
579 |
//Si le voisin du haut est sur la même colonne, on n'est pas sur la bordure du haut. |
|
|
580 |
this.neighboursIds[2] = (currentLine > 0) ? (this.centerId - this.length) : -1; |
|
|
581 |
//Si le voisin du bas est sur la même colonne, on n'est pas sur la bordure du bas. |
|
|
582 |
this.neighboursIds[3] = (currentLine < (this.imagesToShow / this.length)) ? (+this.centerId + this.length) : -1; |
|
|
583 |
|
|
31
|
584 |
//ID du cadre voisin. |
|
|
585 |
var preId; |
|
|
586 |
|
|
30
|
587 |
for(var i = 0 ; i < this.neighboursIds.length ; i++) |
|
|
588 |
{ |
|
|
589 |
if(this.neighboursIds[i] != -1) |
|
31
|
590 |
{ |
|
|
591 |
preId = '#neighbourFrameBorder-' + this.neighboursIds[i]; |
|
30
|
592 |
//On permet le déplacement vers les voisins. |
|
31
|
593 |
// $('#snapshotDiv-' + this.neighboursIds[i] + ', ' + preId + '-left,' + preId + '-right,' + preId + '-up,' + preId + '-down').mouseenter(mos.selectNeighbour); |
|
|
594 |
$('#snapshotDiv-' + this.neighboursIds[i]).mouseenter(mos.selectNeighbour); |
|
30
|
595 |
} |
|
|
596 |
} |
|
|
597 |
} |
|
|
598 |
|
|
|
599 |
/* |
|
|
600 |
* Change la coloration d'une bordure où on se positionne lors d'une vue en plein écran. |
|
|
601 |
*/ |
|
31
|
602 |
mosaic.prototype.selectNeighbour = function() |
|
30
|
603 |
{ |
|
|
604 |
////TEST |
|
|
605 |
//$('.test').append(mos.currentMode + " " + $(this).attr('id') + " " + 'snapshotDiv-' + mos.centerId + ','); |
|
|
606 |
|
|
|
607 |
//Si on est en mode VIDEO (plein écran) ET si le snapshot pointé est un voisin. |
|
|
608 |
if((mos.currentMode == 'VIDEO') && ($(this).attr('id') != 'snapshotDiv-' + mos.centerId)) |
|
|
609 |
{ |
|
31
|
610 |
//On crée le cadre qui va être superposé au voisin. |
|
30
|
611 |
//On le colle au voisin. |
|
31
|
612 |
var tab = $(this).attr('id').split('-'); |
|
|
613 |
var snapshotId = tab[1]; |
|
|
614 |
var neighbourFrame = ''; |
|
|
615 |
var marginValue = parseFloat($(this).css('margin')); |
|
|
616 |
|
|
|
617 |
neighbourFrame += '<div class="neighbourFrame" id="neighbourFrame-' + snapshotId + '"><div class="neighbourImgBg" id="neighbourImgBg-' + snapshotId + '"><div class="neighbourImg" id="neighbourImg-' + snapshotId + '"></div></div></div>'; |
|
|
618 |
|
|
|
619 |
$('#mainPanel').append(neighbourFrame); |
|
|
620 |
|
|
|
621 |
//On positionne le div de background juste au niveau du voisin. |
|
|
622 |
$('#neighbourFrame-' + snapshotId).css( |
|
|
623 |
{ |
|
|
624 |
'top': (+$(this).position().top + marginValue), |
|
|
625 |
'left': (+$(this).position().left + marginValue), |
|
|
626 |
'width': $(this).width(), |
|
|
627 |
'height': $(this).height() |
|
|
628 |
}); |
|
|
629 |
//On positionne le div de background noir juste au niveau de l'image du voisin. |
|
|
630 |
$('#neighbourImgBg-' + snapshotId).css( |
|
|
631 |
{ |
|
|
632 |
'top': marginValue, |
|
|
633 |
'left': marginValue, |
|
|
634 |
'width': $(this).width() - marginValue*2, |
|
|
635 |
'height': $(this).height() - marginValue*2, |
|
|
636 |
}); |
|
|
637 |
//On met par dessus le div de l'image clonée du voisin. |
|
|
638 |
$('#neighbourImg-' + snapshotId).css( |
|
|
639 |
{ |
|
|
640 |
'top': 0, |
|
|
641 |
'left': 0, |
|
|
642 |
'width': $(this).width() - marginValue*2, |
|
|
643 |
'height': $(this).height() - marginValue*2, |
|
32
|
644 |
'background-image': 'url("' + $('img', $(this)).attr('src') + '")', |
|
31
|
645 |
'background-size': $(this).width() + 'px ' + $(this).height() + 'px', |
|
|
646 |
'background-position': -marginValue + 'px ' + -marginValue + 'px', |
|
|
647 |
'opacity': '0.4' |
|
|
648 |
}); |
|
|
649 |
|
|
|
650 |
var fId = '#neighbourFrame-' + snapshotId; |
|
|
651 |
|
|
|
652 |
$(fId).animate( |
|
30
|
653 |
{ |
|
|
654 |
//On le fait apparaître. |
|
31
|
655 |
opacity: '1' |
|
|
656 |
}, timeNeighbourGlowing, function() |
|
30
|
657 |
{ |
|
|
658 |
//On peut désormais se déplacer vers ce voisin. |
|
|
659 |
mos.canMoveToNeighbour = true; |
|
31
|
660 |
}); |
|
|
661 |
//Lorsqu'on quitte un des snapshots (bien entendu le voisin en question), on retire le cadre. |
|
|
662 |
$(fId).mouseleave(mos.deselectNeighbour) |
|
|
663 |
//Si on clique sur le voisin ou son cadre, on passe au voisin suivant. |
|
|
664 |
$(fId).click(mos.moveToNeighbour); |
|
30
|
665 |
} |
|
|
666 |
} |
|
|
667 |
|
|
|
668 |
/* |
|
|
669 |
* Change la coloration d'une bordure quittée lors d'une vue en plein écran. |
|
|
670 |
*/ |
|
31
|
671 |
mosaic.prototype.deselectNeighbour = function() |
|
30
|
672 |
{ |
|
|
673 |
////TEST |
|
|
674 |
//$('.test').append('un,'); |
|
31
|
675 |
|
|
30
|
676 |
//On ne peut plus se déplacer vers les voisins. |
|
|
677 |
mos.canMoveToNeighbour = false; |
|
31
|
678 |
|
|
|
679 |
//On récupère le voisin. |
|
|
680 |
var neighbourFrame = $(this); |
|
|
681 |
|
|
30
|
682 |
//Si on est en mode VIDEO. |
|
|
683 |
if(mos.currentMode == 'VIDEO') |
|
|
684 |
{ |
|
|
685 |
//On le fait disparaître progressivement. |
|
31
|
686 |
neighbourFrame.animate( |
|
30
|
687 |
{ |
|
|
688 |
opacity: '0' |
|
31
|
689 |
}, timeNeighbourUnglowing, function() |
|
30
|
690 |
{ |
|
|
691 |
//Une fois invisible, on le supprime. |
|
31
|
692 |
neighbourFrame.remove(); |
|
30
|
693 |
}); |
|
|
694 |
} |
|
|
695 |
} |
|
|
696 |
|
|
|
697 |
/* |
|
|
698 |
* 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. |
|
|
699 |
*/ |
|
|
700 |
mosaic.prototype.moveToNeighbour = function() |
|
|
701 |
{ |
|
|
702 |
//Si on ne peut pas se déplacer vers les voisins, on quitte. |
|
|
703 |
if(!mos.canMoveToNeighbour) |
|
31
|
704 |
{ |
|
30
|
705 |
return; |
|
31
|
706 |
} |
|
30
|
707 |
|
|
|
708 |
//On obtient l'ID de destination. |
|
|
709 |
var tab = $(this).attr('id').split('-'); |
|
31
|
710 |
var destinationId = tab[1]; |
|
30
|
711 |
|
|
|
712 |
//On charge les attributs nécessaires aux calculs. |
|
|
713 |
var MPCurrentTop = $('#mainPanel').position().top, MPCurrentLeft = $('#mainPanel').position().left; |
|
|
714 |
var divideCoeffTop = Math.floor(destinationId / mos.length) == 0 ? 1 : Math.floor(destinationId / mos.length); |
|
|
715 |
var divideCoeffLeft = destinationId % mos.length == 0 ? 1 : destinationId % mos.length; |
|
31
|
716 |
var neighbourFrameTop = $('#snapshotDiv-' + destinationId).position().top, neighbourFrameLeft = $('#snapshotDiv-' + destinationId).position().left; |
|
30
|
717 |
|
|
|
718 |
//On définit pour le déplacement vertical s'il est nécessaire de se déplacer en haut ou en bas. |
|
31
|
719 |
if(mos.previousZoomedSN.position().top > neighbourFrameTop) |
|
|
720 |
MPCurrentTop += Math.abs(neighbourFrameTop - mos.previousZoomedSN.position().top); |
|
|
721 |
else if(mos.previousZoomedSN.position().top < neighbourFrameTop) |
|
|
722 |
MPCurrentTop -= Math.abs(neighbourFrameTop - mos.previousZoomedSN.position().top); |
|
30
|
723 |
//On définit pour le déplacement horizontal s'il est nécessaire de se déplacer à gauche ou à droite. |
|
31
|
724 |
if(mos.previousZoomedSN.position().left > neighbourFrameLeft) |
|
|
725 |
MPCurrentLeft += Math.abs(neighbourFrameLeft - mos.previousZoomedSN.position().left); |
|
|
726 |
else if(mos.previousZoomedSN.position().left < neighbourFrameLeft) |
|
|
727 |
MPCurrentLeft -= Math.abs(neighbourFrameLeft - mos.previousZoomedSN.position().left); |
|
30
|
728 |
|
|
|
729 |
//On passe le snapshot de destination en HD. |
|
|
730 |
var destinationImg = $('#snapshot-' + destinationId); |
|
|
731 |
var destinationImgSrc = destinationImg.attr('src'); |
|
|
732 |
destinationImg.attr('src', destinationImgSrc.replace('snapshots-little/', 'snapshots/')); |
|
|
733 |
|
|
31
|
734 |
//On passe l'ancien snapshot en SD. |
|
30
|
735 |
var currentImgSrc = $('img', mos.previousZoomedSN).attr('src'); |
|
|
736 |
$('img', mos.previousZoomedSN).attr('src', currentImgSrc.replace('snapshots/', 'snapshots-little/')); |
|
|
737 |
|
|
|
738 |
//On obtient l'ID du div de coloration du snapshot vers lequel on se déplace afin de le supprimer. |
|
31
|
739 |
var neighbourFrame = $(this); |
|
|
740 |
var tab = neighbourFrame.attr('id').split('-'); |
|
|
741 |
mos.centerId = tab[1]; |
|
30
|
742 |
$(this).css('opacity', '0'); |
|
31
|
743 |
neighbourFrame.remove(); |
|
|
744 |
|
|
33
|
745 |
mos.player.widgets[0].freePlayer(); |
|
|
746 |
$('.LdtPlayer').remove(); |
|
31
|
747 |
$('body').append('<div class="LdtPlayer" id="LdtPlayer"></div>'); |
|
|
748 |
|
|
30
|
749 |
//On grise le snapshot qu'on vient de quitter. |
|
|
750 |
mos.previousZoomedSN.animate( |
|
|
751 |
{ |
|
|
752 |
opacity: '0.4' |
|
|
753 |
}); |
|
|
754 |
|
|
|
755 |
//On se déplace. |
|
|
756 |
$('#mainPanel').animate( |
|
|
757 |
{ |
|
|
758 |
top: MPCurrentTop, |
|
|
759 |
left: MPCurrentLeft |
|
|
760 |
}, timeMovingToNeighbour, function() |
|
|
761 |
{ |
|
|
762 |
//On fait apparaître le snapshot vers lequel on s'est déplacé. |
|
|
763 |
$('#snapshotDiv-' + destinationId).animate( |
|
|
764 |
{ |
|
|
765 |
opacity: '1' |
|
|
766 |
}, mos.zoomTime, function() |
|
|
767 |
{ |
|
|
768 |
//On recharge les voisins. |
|
31
|
769 |
$('.snapshotDivs').unbind('mouseenter', mos.selectNeighbour); |
|
30
|
770 |
mos.previousZoomedSN = $('#snapshotDiv-' + mos.centerId); |
|
|
771 |
mos.listenToNeighbours(); |
|
31
|
772 |
|
|
33
|
773 |
mos.loadPlayer((destinationImg.position().top + MPCurrentTop + mos.MPTop_margin), (destinationImg.position().left + MPCurrentLeft), destinationImg.width(), destinationImg.height(), MPCurrentTop, MPCurrentLeft); |
|
30
|
774 |
}); |
|
|
775 |
}); |
|
|
776 |
} |
|
|
777 |
|
|
|
778 |
/* |
|
|
779 |
* Déchargement du contenu de la mosaïque pour le chargement de la mosaïque locale. |
|
|
780 |
*/ |
|
|
781 |
mosaic.prototype.unload = function() |
|
|
782 |
{ |
|
|
783 |
//On supprime les event listeners des objets de la mosaïque. |
|
|
784 |
$('.snapshotDivs').unbind(); |
|
|
785 |
$('.snapshots').unbind(); |
|
|
786 |
$('.prezoomContainers').unbind(); |
|
|
787 |
//On supprime physiquement les objets. |
|
|
788 |
$('#mainPanel').empty(); |
|
|
789 |
} |
|
|
790 |
|
|
|
791 |
/* |
|
|
792 |
* Centre verticalement un snapshot. |
|
|
793 |
*/ |
|
|
794 |
/*function verticalCenterImg(mosaic, img) |
|
|
795 |
{ |
|
|
796 |
//On récupère sa hauteur. |
|
|
797 |
var image_height = img.height(); |
|
|
798 |
//Calcule la marge du haut de chaque div pour le centrage. |
|
|
799 |
if(mosaic.top_margin == undefined) |
|
|
800 |
mosaic.top_margin = (mosaic.snapshotHeight > image_height) ? (mosaic.snapshotHeight - image_height)/2 : (image_height - mosaic.snapshotHeight)/2; |
|
|
801 |
//On centre le snapshot. |
|
|
802 |
img.css('margin-top', mosaic.top_margin).css('margin-bottom', mosaic.top_margin); |
|
|
803 |
}*/ |
|
|
804 |
|
|
|
805 |
/* |
|
|
806 |
* Permet de tester l'égalité des éléments de deux objets. |
|
|
807 |
* Pour ce faire on compare les éléments définissant ces objets. |
|
|
808 |
*/ |
|
|
809 |
$.fn.equals = function(compareTo) |
|
|
810 |
{ |
|
|
811 |
if (!compareTo || !compareTo.length || this.length!=compareTo.length) |
|
|
812 |
{ |
|
|
813 |
return false; |
|
|
814 |
} |
|
|
815 |
for (var i=0; i<this .length; i++) |
|
|
816 |
{ |
|
|
817 |
if (this[i]!==compareTo[i]) |
|
|
818 |
{ |
|
|
819 |
return false; |
|
|
820 |
} |
|
|
821 |
} |
|
|
822 |
return true; |
|
32
|
823 |
} |
|
|
824 |
|
|
|
825 |
/* |
|
|
826 |
* Charge les vidéos, les snapshots et les annotations depuis un fichier json. |
|
|
827 |
*/ |
|
|
828 |
mosaic.prototype.loadFromJson = function(path) |
|
|
829 |
{ |
|
|
830 |
var _this = this; |
|
33
|
831 |
var i = 0; |
|
32
|
832 |
|
|
|
833 |
$.getJSON(path, function(data) |
|
|
834 |
{ |
|
|
835 |
$.each(data, function(key, val) |
|
|
836 |
{ |
|
|
837 |
// console.log(val); |
|
|
838 |
$.each(val, function(key_video, val_video) |
|
|
839 |
{ |
|
|
840 |
$.getJSON(val_video.metadata, function(meta) |
|
|
841 |
{ |
|
33
|
842 |
_this.affectVideoById(val_video.metadata, meta.medias[0].url.replace('rtmp://', 'http://').replace('/ddc_player/', '/').replace('mp4:', '').replace('.m4v', '.mp4')); |
|
32
|
843 |
//console.log(meta.medias[0].url.replace('rtmp://', 'http://').replace('/ddc_player/', '/')); |
|
|
844 |
}); |
|
|
845 |
|
|
33
|
846 |
// _this.imgs.push(val_video.snapshot); |
|
|
847 |
// _this.urls.push(val_video.metadata); |
|
|
848 |
_this.imgs[_this.ids[i]] = val_video.snapshot; |
|
|
849 |
_this.urls[_this.ids[i]] = val_video.metadata; |
|
|
850 |
i++; |
|
32
|
851 |
}); |
|
|
852 |
}); |
|
|
853 |
console.log('rdy'); |
|
|
854 |
_this.loadMosaic(); |
|
|
855 |
}); |
|
|
856 |
} |
|
|
857 |
|
|
|
858 |
/* |
|
|
859 |
* Affecte une vidéo au tableau des vidéos selon son id |
|
|
860 |
*/ |
|
|
861 |
mosaic.prototype.affectVideoById = function(metadata_id, video) |
|
|
862 |
{ |
|
|
863 |
for (i = 0 ; i < this.urls.length ; i++) |
|
|
864 |
{ |
|
|
865 |
if(this.urls[i] == metadata_id) |
|
|
866 |
{ |
|
|
867 |
this.videos[i] = video; |
|
|
868 |
break; |
|
|
869 |
} |
|
|
870 |
} |
|
33
|
871 |
} |
|
|
872 |
|
|
|
873 |
/* |
|
|
874 |
* Lance une recherche par courbes. |
|
|
875 |
*/ |
|
|
876 |
mosaic.prototype.startSearch = function() |
|
|
877 |
{ |
|
|
878 |
var top, left, width, height, margin_top, inMosaic; |
|
|
879 |
//Si on est dans le cas d'un filtrage de mosaïque. |
|
|
880 |
if(this.currentMode == "FILTER") |
|
|
881 |
{ |
|
|
882 |
var mainPanel = $('#mainPanel'); |
|
|
883 |
top = mainPanel.position().top; |
|
|
884 |
left = mainPanel.position().left; |
|
|
885 |
width = mainPanel.width(); |
|
|
886 |
height = mainPanel.height(); |
|
|
887 |
margin_top = this.MPTop_margin; |
|
|
888 |
inMosaic = true; |
|
|
889 |
} |
|
|
890 |
//Sinon si c'est une recherche dans la vidéo. |
|
|
891 |
else if(this.currentMode == "SEARCH") |
|
|
892 |
{ |
|
|
893 |
top = this.snTop; |
|
|
894 |
left = this.snLeft; |
|
|
895 |
width = this.snWidth; |
|
|
896 |
height = this.snHeight; |
|
|
897 |
margin_top = '0px'; |
|
|
898 |
inMosaic = false; |
|
|
899 |
} |
|
|
900 |
|
|
|
901 |
this.searchCanvas = new searchCanvas(top, left, width, height, margin_top, this.timeSearchFade, inMosaic); |
|
|
902 |
this.searchCanvas.create(); |
|
|
903 |
} |
|
|
904 |
|
|
|
905 |
/* |
|
|
906 |
* Quitte une recherche par courbes. |
|
|
907 |
*/ |
|
|
908 |
mosaic.prototype.leaveSearch = function() |
|
|
909 |
{ |
|
|
910 |
this.searchCanvas.leaveSearch(); |
|
|
911 |
} |
|
|
912 |
|
|
|
913 |
/* =============================================== |
|
|
914 |
* * |
|
|
915 |
* ZONE DES NOTIFICATIONS * |
|
|
916 |
* * |
|
|
917 |
=============================================== */ |
|
|
918 |
|
|
|
919 |
/* |
|
|
920 |
* Affiche la notification de sélection/recherche lorsque la mosaique est complète. |
|
|
921 |
*/ |
|
|
922 |
mosaic.prototype.notifySelectionSearchMosaicFull = function() |
|
|
923 |
{ |
|
|
924 |
//On spécifie les notifications en div. |
|
|
925 |
var notification_selection = "<div id='notify_selection' class='notifications'></div>"; |
|
|
926 |
var notification_search = "<div id='notify_search' class='notifications'></div>"; |
|
|
927 |
|
|
|
928 |
//On les ajoute à la mosaïque. |
|
|
929 |
$('#mainPanel').append(notification_selection + notification_search); |
|
|
930 |
|
|
|
931 |
//On calcule leurs coordonnées et dimensions. |
|
|
932 |
var notify_width = $('.notifications').width(), notify_height = $('.notifications').height(); |
|
|
933 |
var notify_margin = parseInt($('.notifications').css('margin')); |
|
|
934 |
var selection_left = $(window).width() / 2 - (notify_width * 2 + notify_margin * 3) / 2; |
|
|
935 |
var search_left = selection_left + notify_width + notify_margin; |
|
|
936 |
|
|
|
937 |
//On les positionne. |
|
|
938 |
$('#notify_selection').css( |
|
|
939 |
{ |
|
|
940 |
left: selection_left |
|
|
941 |
}); |
|
|
942 |
$('#notify_search').css( |
|
|
943 |
{ |
|
|
944 |
left: search_left |
|
|
945 |
}); |
|
|
946 |
|
|
|
947 |
//On les fait apparaître. |
|
|
948 |
$('.notifications').css( |
|
|
949 |
{ |
|
|
950 |
opacity: "0.9" |
|
|
951 |
}); |
|
|
952 |
} |
|
|
953 |
|
|
|
954 |
/* |
|
|
955 |
* Supprime la notification de sélection/recherche lorsque la mosaique est complète. |
|
|
956 |
*/ |
|
|
957 |
mosaic.prototype.removeSelectionSearchMosaicFull = function() |
|
|
958 |
{ |
|
|
959 |
$('#notify_selection, #notify_search').remove(); |
|
|
960 |
} |
|
|
961 |
|
|
|
962 |
/* |
|
|
963 |
* Affiche la notification de maintient du pointage lors d'une phase de prézoom. |
|
|
964 |
*/ |
|
|
965 |
mosaic.prototype.notifyPointMosaicPrezoom = function() |
|
|
966 |
{ |
|
|
967 |
if($('#notify_point').length > 0) |
|
|
968 |
{ |
|
|
969 |
return; |
|
|
970 |
} |
|
|
971 |
|
|
|
972 |
//On spécifie les notifications en div. |
|
|
973 |
var notification_point = "<div id='notify_point' class='notifications'></div>"; |
|
|
974 |
|
|
|
975 |
//On les ajoute à la mosaïque. |
|
|
976 |
$('#mainPanel').append(notification_point); |
|
|
977 |
console.log('Append'); |
|
|
978 |
//On calcule leurs coordonnées et dimensions. |
|
|
979 |
var notify_width = $('.notifications').width(), notify_height = $('.notifications').height(); |
|
|
980 |
var notify_margin = parseInt($('.notifications').css('margin')); |
|
|
981 |
var point_left = $(window).width() / 2 - (notify_width) / 2 - notify_margin; |
|
|
982 |
|
|
|
983 |
//On les positionne. |
|
|
984 |
$('#notify_point').css( |
|
|
985 |
{ |
|
|
986 |
left: point_left |
|
|
987 |
}); |
|
|
988 |
|
|
|
989 |
//On les fait apparaître. |
|
|
990 |
$('.notifications').css( |
|
|
991 |
{ |
|
|
992 |
opacity: "0.9" |
|
|
993 |
}); |
|
|
994 |
} |
|
|
995 |
|
|
|
996 |
/* |
|
|
997 |
* Supprime la notification de maintient du pointage. |
|
|
998 |
*/ |
|
|
999 |
mosaic.prototype.removePointMosaicPrezoom = function() |
|
|
1000 |
{ |
|
|
1001 |
$('#notify_point').remove(); |
|
|
1002 |
} |
|
|
1003 |
|
|
|
1004 |
/* |
|
|
1005 |
* Affiche l'aide. |
|
|
1006 |
*/ |
|
|
1007 |
mosaic.prototype.notifyHelp = function() |
|
|
1008 |
{ |
|
|
1009 |
if(this.helpDisplayed) |
|
|
1010 |
{ |
|
|
1011 |
return; |
|
|
1012 |
} |
|
|
1013 |
|
|
|
1014 |
this.removeSelectionSearchMosaicFull(); |
|
|
1015 |
this.removePointMosaicPrezoom(); |
|
|
1016 |
|
|
|
1017 |
this.helpDisplayed = true; |
|
|
1018 |
|
|
|
1019 |
var search_2hands_tab = ['no_motion', 'right_angle', 'contact', 'grand_jete', 'circle', 'screw', 'arc', 'rythme', 'slow', 'up_down', 'wave', 'wheel']; |
|
|
1020 |
var search_body_tab = ['bend', 'fall', 'jump', 'hello', 'knee_up']; |
|
|
1021 |
var controls_1hand_tab = ['selection']; |
|
|
1022 |
|
|
|
1023 |
//On spécifie les notifications en div. |
|
|
1024 |
var search_title = "<div id='search_title'></div>"; |
|
|
1025 |
var search_img = "<div id='search_img' class='notify_imgs'></div>"; |
|
|
1026 |
var search_2hands_text = "<div id='search_2hands_text'></div>"; |
|
|
1027 |
var search_2hands_imgs = "<div id='search_2hands_imgs' class='notify_imgs_big'>"; |
|
|
1028 |
|
|
|
1029 |
for(var i = 0 ; i < search_2hands_tab.length ; i++) |
|
|
1030 |
{ |
|
|
1031 |
search_2hands_imgs += "<div id='2hands_" + search_2hands_tab[i] + "' class='notify_imgs_small'></div>"; |
|
|
1032 |
} |
|
|
1033 |
search_2hands_imgs += "</div>"; |
|
|
1034 |
|
|
|
1035 |
var search_body_text = "<div id='search_body_text'></div>"; |
|
|
1036 |
var search_body_imgs = "<div id='search_2hands_imgs' class='notify_imgs'>" |
|
|
1037 |
|
|
|
1038 |
for(var i = 0 ; i < search_body_tab.length ; i++) |
|
|
1039 |
{ |
|
|
1040 |
search_body_imgs += "<div id='body_" + search_body_tab[i] + "' class='notify_imgs_small'></div>"; |
|
|
1041 |
} |
|
|
1042 |
search_body_imgs += "</div>"; |
|
|
1043 |
|
|
|
1044 |
var controls_title = "<div id='controls_title'></div>"; |
|
|
1045 |
var controls_img = "<div id='controls_img' class='notify_imgs'></div>"; |
|
|
1046 |
var controls_1hand_text = "<div id='controls_1hand_text'></div>"; |
|
|
1047 |
var controls_1hand_imgs = "<div id='controls_1hand_imgs' class='notify_imgs'>"; |
|
|
1048 |
|
|
|
1049 |
for(var i = 0 ; i < controls_1hand_tab.length ; i++) |
|
|
1050 |
{ |
|
|
1051 |
controls_1hand_imgs += "<div id='1hand_" + controls_1hand_tab[i] + "' class='notify_imgs_small'></div>"; |
|
|
1052 |
} |
|
|
1053 |
controls_1hand_imgs += "</div>"; |
|
|
1054 |
|
|
|
1055 |
var help_search = "<div id='help_search'>" + search_title + search_img + search_2hands_text + search_2hands_imgs + search_body_text + search_body_imgs + "</div>"; |
|
|
1056 |
var help_controls = "<div id='help_controls'>" + controls_title + controls_img + controls_1hand_text + controls_1hand_imgs + "</div>"; |
|
|
1057 |
|
|
|
1058 |
var notification_help = "<div id='notify_help'>" + help_search + "<div id='help_sep'></div>" + help_controls + "</div>"; |
|
|
1059 |
|
|
|
1060 |
//On les ajoute à la mosaïque. |
|
|
1061 |
$('body').append(notification_help); |
|
|
1062 |
|
|
|
1063 |
//On calcule leurs coordonnées et dimensions. |
|
|
1064 |
var notify_width = $(window).width(), notify_height = $(window).height(); |
|
|
1065 |
var notify_margin = parseInt($('#notify_help').css('margin')); |
|
|
1066 |
var notify_ = 10; |
|
|
1067 |
|
|
|
1068 |
//On les positionne. |
|
|
1069 |
$('#notify_help').css( |
|
|
1070 |
{ |
|
|
1071 |
left: "0px", |
|
|
1072 |
top: "0px", |
|
|
1073 |
width: notify_width - notify_margin * 2, |
|
|
1074 |
height: notify_height - notify_margin * 2, |
|
|
1075 |
"margin-top": notify_margin_top |
|
|
1076 |
}); |
|
|
1077 |
|
|
|
1078 |
var search_width = $('#help_search').width(); |
|
|
1079 |
|
|
|
1080 |
$('#search_title').html('Recherche'); |
|
|
1081 |
$('#search_2hands_text').html('Gestes à effectuer avec les deux mains'); |
|
|
1082 |
$('#search_body_text').html('Gestes à effectuer avec le corps entier'); |
|
|
1083 |
|
|
|
1084 |
for(var i = 0 ; i < search_2hands_tab.length ; i++) |
|
|
1085 |
{ |
|
|
1086 |
$("#2hands_" + search_2hands_tab[i]).css("background-image", "url('./pictos/help/" + search_2hands_tab[i] + ".png')"); |
|
|
1087 |
//console.log("url('../../pictos/help/" + search_2hands_tab[i] + ".png')"); |
|
|
1088 |
} |
|
|
1089 |
|
|
|
1090 |
for(var i = 0 ; i < search_body_tab.length ; i++) |
|
|
1091 |
{ |
|
|
1092 |
$("#body_" + search_body_tab[i]).css("background-image", "url('./pictos/help/" + search_body_tab[i] + ".png')"); |
|
|
1093 |
//console.log("url('../../pictos/help/" + search_2hands_tab[i] + ".png')"); |
|
|
1094 |
} |
|
|
1095 |
|
|
|
1096 |
$('#controls_title').html('Contrôles'); |
|
|
1097 |
$('#controls_1hand_text').html('Gestes à effectuer avec une seule main'); |
|
|
1098 |
|
|
|
1099 |
for(var i = 0 ; i < controls_1hand_tab.length ; i++) |
|
|
1100 |
{ |
|
|
1101 |
$("#1hand_" + controls_1hand_tab[i]).css("background-image", "url('./pictos/help/" + controls_1hand_tab[i] + ".png')"); |
|
|
1102 |
//console.log("url('../../pictos/help/" + search_2hands_tab[i] + ".png')"); |
|
|
1103 |
} |
|
|
1104 |
|
|
|
1105 |
//On les fait apparaître. |
|
|
1106 |
$('#notify_help').css( |
|
|
1107 |
{ |
|
|
1108 |
opacity: "1" |
|
|
1109 |
}); |
|
|
1110 |
|
|
|
1111 |
$('.notify_imgs_big').css( |
|
|
1112 |
{ |
|
|
1113 |
opacity: "1" |
|
|
1114 |
}); |
|
|
1115 |
} |
|
|
1116 |
|
|
|
1117 |
/* |
|
|
1118 |
* Supprime l'aide. |
|
|
1119 |
*/ |
|
|
1120 |
mosaic.prototype.removeHelp = function() |
|
|
1121 |
{ |
|
|
1122 |
if(!this.helpDisplayed) |
|
|
1123 |
{ |
|
|
1124 |
return; |
|
|
1125 |
} |
|
|
1126 |
|
|
|
1127 |
var _this = this; |
|
|
1128 |
|
|
|
1129 |
$('#notify_help').fadeOut(this.timeNotifyFade, function() |
|
|
1130 |
{ |
|
|
1131 |
_this.helpDisplayed = false; |
|
|
1132 |
$('#notify_help').remove(); |
|
|
1133 |
}); |
|
30
|
1134 |
} |