|
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 |
*/ |
|
35
|
25 |
function mosaic(config, default_conf) |
|
30
|
26 |
{ |
|
35
|
27 |
//Chemin du fichier de configuration. |
|
|
28 |
this.config_path = config; |
|
|
29 |
//Configuration par défaut en cas de valeur erronnée. |
|
|
30 |
this.default_config = default_conf; |
|
|
31 |
this.config = new Object(); |
|
|
32 |
//Tableaux des urls des vidéos, des snapshots et de leur position dans la mosaïque. |
|
|
33 |
this.videos = []; |
|
|
34 |
this.urls = []; |
|
|
35 |
this.imgs = []; |
|
|
36 |
this.ids = []; |
|
|
37 |
this.fillingIds = []; |
|
|
38 |
this.currentRandomVideoIdx = 0; |
|
|
39 |
|
|
|
40 |
//Dimensions de la mosaïque en pixels. |
|
|
41 |
this.width; |
|
|
42 |
this.height; |
|
|
43 |
//Dimensions d'un snapshot en pixels. |
|
|
44 |
this.snapshotWidth; |
|
|
45 |
this.snapshotHeight; |
|
|
46 |
//Espacement entre les snapshots en pixels. |
|
|
47 |
this.marginWidth; |
|
|
48 |
|
|
|
49 |
//Booléens permettant ou non certaines intéractions selon le contexte. |
|
|
50 |
this.zoomed; |
|
|
51 |
this.fullscreen; |
|
|
52 |
this.canMoveToNeighbour; |
|
|
53 |
this.helpDisplayed; |
|
|
54 |
|
|
|
55 |
//Type de marqueur recherché dans la mosaïque (en mode filter). |
|
|
56 |
this.filterSearchedType = ""; |
|
|
57 |
|
|
|
58 |
//Mode actuel. |
|
|
59 |
this.currentMode = "MOSAIC"; |
|
|
60 |
//Snapshot sur lequel on a zoomé. |
|
|
61 |
this.previousZoomedSN; |
|
|
62 |
//Son ID. |
|
|
63 |
this.previousId; |
|
|
64 |
//Largeur de la marge pour le centrage vertical de la mosaïque. |
|
|
65 |
this.MPTop_margin; |
|
|
66 |
this.top_margin; |
|
|
67 |
|
|
|
68 |
//Mosaïque locale. |
|
|
69 |
this.localMos; |
|
|
70 |
//Position des voisins lors d'un zoom. |
|
|
71 |
this.neighboursIds = []; |
|
|
72 |
//ID du snapshot du milieu lors d'un zoom. |
|
|
73 |
this.centerId; |
|
|
74 |
|
|
|
75 |
//Snapshots a afficher. |
|
|
76 |
this.snapshotsToShow = 1; |
|
|
77 |
|
|
|
78 |
//Lecteur. |
|
|
79 |
this.player; |
|
|
80 |
//Annotations (pour les marqueurs los d'un filtrage). |
|
|
81 |
this.annotations = []; |
|
|
82 |
|
|
|
83 |
//Coordonnées et dimensions d'un snapshot zoomé. |
|
|
84 |
this.snTop = 0; |
|
|
85 |
this.snLeft = 0; |
|
|
86 |
this.snWidth = 0; |
|
|
87 |
this.snHeight = 0; |
|
|
88 |
|
|
|
89 |
this.searchCanvas; |
|
|
90 |
//Position actuelle de la vidéo zoomée. |
|
|
91 |
this.notifyTopVideo; |
|
|
92 |
this.notifyLeftVideo; |
|
|
93 |
this.loadParameters(this.config_path); |
|
30
|
94 |
} |
|
|
95 |
|
|
|
96 |
/* |
|
|
97 |
* Méthode d'affichage de la mosaïque. |
|
|
98 |
* Génère une matrice de imgs. |
|
|
99 |
*/ |
|
|
100 |
mosaic.prototype.createMosaic = function() |
|
|
101 |
{ |
|
35
|
102 |
console.log('CREATE'); |
|
|
103 |
this.currentMode = "NO-USER"; |
|
|
104 |
var initPanel = '<div id="initPanel"></div>'; |
|
|
105 |
var mp = $('#mainPanel'); |
|
|
106 |
mp.append(initPanel); |
|
|
107 |
$('#initPanel').css( |
|
|
108 |
{ |
|
|
109 |
background: 'transparent', |
|
|
110 |
width: mp.width(), |
|
|
111 |
height: mp.height(), |
|
|
112 |
top: mp.position().top, |
|
|
113 |
left: mp.position().left, |
|
|
114 |
'margin-top': this.MPTop_margin |
|
|
115 |
}); |
|
|
116 |
|
|
|
117 |
var len = this.config['length'], imgs = this.config['imagesToShow'], imgsTotal = this.config['imagesTotal']; |
|
|
118 |
|
|
|
119 |
//S'il s'agit d'un rectangle. |
|
|
120 |
if(imgs % len == 0) |
|
30
|
121 |
{ |
|
35
|
122 |
this.previousZoomedSN = ''; |
|
|
123 |
this.previousPrezoomDiv = ''; |
|
|
124 |
this.fullscreen = false; |
|
|
125 |
this.canMoveToNeighbour = false; |
|
|
126 |
this.helpDisplayed = false; |
|
|
127 |
var str = ''; |
|
|
128 |
|
|
|
129 |
if(this.imgs.length >= imgs) |
|
|
130 |
{ |
|
|
131 |
for(var i = 0 ; i < imgs ; i++) |
|
|
132 |
{ |
|
|
133 |
//On charge les images de petite taille pour ne pas surcharger la mosaïque lors de l'affichage global. |
|
|
134 |
str += '<div id="snapshotDiv-' + i + '" class="snapshotDivs" style="opacity: 0;"><img id="snapshot-' + i + '" class="snapshots" src="snapshots-little/' + this.imgs[i] + '" /></div>'; |
|
|
135 |
} |
|
|
136 |
} |
|
|
137 |
|
|
|
138 |
return str; |
|
|
139 |
} |
|
|
140 |
else |
|
|
141 |
{ |
|
|
142 |
alert("Le nombre d'images a afficher doit être divisible par la longueur de la mosaïque !"); |
|
|
143 |
} |
|
30
|
144 |
} |
|
|
145 |
|
|
|
146 |
/* |
|
|
147 |
* Permet de raffraichir la mosaïque. |
|
|
148 |
*/ |
|
32
|
149 |
mosaic.prototype.loadMosaic = function() |
|
30
|
150 |
{ |
|
35
|
151 |
console.log('LOAD'); |
|
32
|
152 |
var createMosaic = this.createMosaic(); |
|
|
153 |
|
|
|
154 |
if(createMosaic == '') |
|
|
155 |
{ |
|
|
156 |
return; |
|
|
157 |
} |
|
|
158 |
|
|
|
159 |
var _this = this; |
|
|
160 |
|
|
30
|
161 |
//On affecte les chemins vers les images à la mosaïque. |
|
|
162 |
this.previousZoomedSN; |
|
|
163 |
//this.width = |
|
|
164 |
//On met à jour la mosaïque. |
|
32
|
165 |
$('#mainPanel').html(createMosaic); |
|
30
|
166 |
//On récupère la taille des bordures. |
|
|
167 |
this.marginWidth = $('.snapshotDivs').css('margin-bottom'); |
|
35
|
168 |
this.marginWidth = parseFloat(this.marginWidth)*2; |
|
30
|
169 |
//On calcule la taille des divs contenant les snapshots. |
|
|
170 |
this.width = $('#mainPanel').innerWidth(); |
|
|
171 |
//On ne calculera pas tout de suite la hauteur de la mosaique étant donnée qu'elle est calculée par la suite dynamiquement. |
|
35
|
172 |
this.snapshotWidth = this.width / this.config['length'] - this.marginWidth; |
|
30
|
173 |
this.snapshotHeight = this.snapshotWidth*9/16; |
|
|
174 |
$('.snapshotDivs').css('width', this.snapshotWidth).css('height', this.snapshotHeight).css('margin', this.marginWidth/2); |
|
|
175 |
|
|
|
176 |
this.height = $('#mainPanel').innerHeight(); |
|
|
177 |
//On centre verticalement la mosaïque. |
|
|
178 |
this.MPTop_margin = ($(document).height() - $('#mainPanel').height())/2; |
|
|
179 |
$('#mainPanel').css('margin-top', this.MPTop_margin).css('margin-bottom', this.MPTop_margin); |
|
32
|
180 |
|
|
33
|
181 |
//On affiche les notifications. |
|
|
182 |
this.notifySelectionSearchMosaicFull(); |
|
|
183 |
|
|
32
|
184 |
$('.snapshotDivs').mouseenter(function () |
|
|
185 |
{ |
|
|
186 |
//On effectue un prézoom dès qu'on va sur une image. |
|
|
187 |
_this.preZoom($(this)); |
|
|
188 |
}); |
|
35
|
189 |
|
|
|
190 |
this.addPointers(); |
|
|
191 |
|
|
|
192 |
//Si dans le metadata player _ n'est pas déclaré, on le déclare. |
|
|
193 |
if(typeof _ !== "undefined" && typeof IriSP._ === "undefined") |
|
|
194 |
{ |
|
|
195 |
IriSP._ = _; |
|
|
196 |
} |
|
|
197 |
|
|
|
198 |
if(typeof $ !== "undefined" && typeof IriSP.jQuery === "undefined") |
|
|
199 |
{ |
|
|
200 |
IriSP.jQuery = $; |
|
|
201 |
} |
|
|
202 |
|
|
|
203 |
//On charge les marqueurs. |
|
|
204 |
var sourceManager = new IriSP.Model.Directory(), |
|
|
205 |
globalAnnotations = new IriSP.Model.List(sourceManager), |
|
|
206 |
nbFichiers = _this.urls.length, |
|
|
207 |
fichiersCharges = 0; |
|
|
208 |
|
|
|
209 |
for (var i = 0; i < nbFichiers; i++) |
|
|
210 |
{ |
|
|
211 |
console.log('url : ' + _this.urls[i]); |
|
|
212 |
var source = sourceManager.remoteSource({url: _this.urls[i], serializer: IriSP.serializers.ldt}); |
|
|
213 |
source.onLoad(function() |
|
|
214 |
{ |
|
|
215 |
globalAnnotations.addElements(source.getAnnotations()); |
|
|
216 |
fichiersCharges++; |
|
|
217 |
if (fichiersCharges == nbFichiers) |
|
|
218 |
{ |
|
|
219 |
// instructions à exécuter quand tout est chargé |
|
|
220 |
_this.annotations = globalAnnotations; |
|
|
221 |
console.log('annotations loaded'); |
|
|
222 |
_this.init(); |
|
|
223 |
} |
|
|
224 |
}); |
|
|
225 |
} |
|
|
226 |
} |
|
|
227 |
|
|
|
228 |
/* |
|
|
229 |
* Charge les paramètres du Front. Local (true/false) est le mode de chargement des données. |
|
|
230 |
*/ |
|
|
231 |
mosaic.prototype.loadParameters = function(file_path) |
|
|
232 |
{ |
|
|
233 |
var _this = this; |
|
|
234 |
|
|
|
235 |
var supposedToBeInt = ['length', 'imagesToShow', 'totalImages', 'timePrezoom', 'timePreUnzoom', 'timeZoom', 'timeUnzoom', 'timeNeighbourGlowing', 'timeNeighbourUnglowing', 'timeMovingToNeighbour', 'timeSearchFade', 'timeNotifyFade', 'timeFilterFade', 'timeFilling', 'zoomedMargin']; |
|
|
236 |
var supposedToBeFloat = ['zoomPercentage', 'prezoomPercentage']; |
|
|
237 |
|
|
|
238 |
$.getJSON(file_path, function(data) |
|
32
|
239 |
{ |
|
35
|
240 |
for(key in data) |
|
32
|
241 |
{ |
|
35
|
242 |
var val = data[key]; |
|
|
243 |
|
|
|
244 |
if(_.include(supposedToBeInt, key)) |
|
|
245 |
{ |
|
|
246 |
var intVal = parseInt(val); |
|
|
247 |
if(isNaN(intVal)) |
|
|
248 |
{ |
|
|
249 |
console.log(_this.default_config); |
|
|
250 |
_this.config[key] = _this.default_config[key]; |
|
|
251 |
console.log("param[" + key + "] : Valeur " + val + " incorrecte (non Int). Valeur par défaut " + _this.default_config[key] + " chargée à la place."); |
|
|
252 |
} |
|
|
253 |
else |
|
|
254 |
{ |
|
|
255 |
_this.config[key] = intVal; |
|
|
256 |
} |
|
|
257 |
} |
|
|
258 |
else if(_.include(supposedToBeFloat, key)) |
|
|
259 |
{ |
|
|
260 |
var floatVal = parseFloat(val); |
|
|
261 |
if(isNaN(floatVal)) |
|
|
262 |
{ |
|
|
263 |
_this.config[key] = _this.default_config[key]; |
|
|
264 |
console.log("param[" + key + "] : Valeur " + val + " incorrecte (non Float). Valeur par défaut " + _this.default_config[key] + " chargée à la place."); |
|
|
265 |
} |
|
|
266 |
else |
|
|
267 |
{ |
|
|
268 |
_this.config[key] = floatVal; |
|
|
269 |
} |
|
|
270 |
} |
|
|
271 |
else |
|
|
272 |
{ |
|
|
273 |
_this.config[key] = val; |
|
|
274 |
} |
|
|
275 |
} |
|
|
276 |
|
|
|
277 |
//On remplit le tableau d'ids. |
|
|
278 |
for(var i = 0 ; i < _this.config['totalImages'] ; i++) |
|
|
279 |
_this.ids.push(i); |
|
|
280 |
//On les mélange. |
|
|
281 |
_this.ids.sort(function() |
|
|
282 |
{ |
|
|
283 |
return 0.5 - Math.random() |
|
|
284 |
}); |
|
|
285 |
|
|
|
286 |
//On remplit le tableau d'ids destiné à afficher les snapshots au fur et à mesure. |
|
|
287 |
for(var i = 0 ; i < _this.config['imagesToShow'] ; i++) |
|
|
288 |
_this.fillingIds.push(i); |
|
|
289 |
//On les mélange. |
|
|
290 |
_this.fillingIds.sort(function() |
|
|
291 |
{ |
|
|
292 |
return 0.5 - Math.random() |
|
|
293 |
}); |
|
|
294 |
|
|
|
295 |
if(_this.config['local'] == 'true') |
|
|
296 |
{ |
|
|
297 |
console.log("Loading local metadata."); |
|
|
298 |
_this.loadFromJson('./player/json/local_videos.json'); |
|
|
299 |
} |
|
|
300 |
else |
|
|
301 |
{ |
|
|
302 |
console.log("Loading online metadata."); |
|
|
303 |
_this.loadFromJson('./player/json/online_videos.json'); |
|
32
|
304 |
} |
|
|
305 |
}); |
|
30
|
306 |
} |
|
|
307 |
|
|
|
308 |
/* |
|
35
|
309 |
* Phase principale (utilisateur non détecté). Une vidéo se lance aléatoirement. |
|
|
310 |
* L'interface est identique à celle du zoom, mais sans interaction possible avec les voisins, ni les controles timeline. |
|
|
311 |
* Lors de la fin d'une lecture, on dézoome vers la mosaïque, puis on rezoome vers un autre snapshot (aléatoire). |
|
|
312 |
*/ |
|
|
313 |
mosaic.prototype.init = function() |
|
|
314 |
{ |
|
|
315 |
var _this = this; |
|
|
316 |
|
|
|
317 |
if(this.currentRandomVideoIdx > this.config['imagesToShow']) |
|
|
318 |
{ |
|
|
319 |
this.currentRandomVideoIdx = 0; |
|
|
320 |
} |
|
|
321 |
|
|
|
322 |
this.previousZoomedSN = $('#snapshotDiv-' + this.fillingIds[this.currentRandomVideoIdx]); |
|
|
323 |
this.previousId = $('img', this.previousZoomedSN).attr('id'); |
|
|
324 |
|
|
|
325 |
console.log('ids', this.fillingIds[this.currentRandomVideoIdx]); |
|
|
326 |
|
|
|
327 |
this.previousZoomedSN.fadeTo(this.config['timePrezoom'], 1, function() |
|
|
328 |
{ |
|
|
329 |
_this.zoom(); |
|
|
330 |
_this.currentRandomVideoIdx++; |
|
|
331 |
}); |
|
|
332 |
} |
|
|
333 |
|
|
|
334 |
/* |
|
|
335 |
* Remplissage de la mosaïque en fonction du nombre d'images à afficher. |
|
|
336 |
*/ |
|
|
337 |
mosaic.prototype.showNImages = function(n) |
|
|
338 |
{ |
|
|
339 |
if(n > 1) |
|
|
340 |
{ |
|
|
341 |
this.currentMode = "INCOMING-" + n; |
|
|
342 |
this.unzoom(); |
|
|
343 |
} |
|
|
344 |
|
|
|
345 |
for(var i = 0 ; i < n ; i++) |
|
|
346 |
{ |
|
|
347 |
if($('#snapshotDiv-' + i).css('opacity') < 1) |
|
|
348 |
{ |
|
|
349 |
$('#snapshotDiv-' + i).fadeTo(this.config['timeFilling'], 1); |
|
|
350 |
} |
|
|
351 |
} |
|
|
352 |
} |
|
|
353 |
|
|
|
354 |
/* |
|
|
355 |
* Affiche les pointeurs. |
|
|
356 |
*/ |
|
|
357 |
mosaic.prototype.addPointers = function() |
|
|
358 |
{ |
|
|
359 |
var _this = this; |
|
|
360 |
|
|
|
361 |
var mainPointer = '<div id="mainPointer" class="pointers"></div>'; |
|
|
362 |
$('body').append(mainPointer); |
|
|
363 |
$('body').mousemove(function(evt) |
|
|
364 |
{ |
|
|
365 |
$('#mainPointer').css( |
|
|
366 |
{ |
|
|
367 |
top: evt.pageY - $('#mainPointer').height()/2, |
|
|
368 |
left: evt.pageX - $('#mainPointer').width()/2 |
|
|
369 |
}); |
|
|
370 |
}); |
|
|
371 |
} |
|
|
372 |
|
|
|
373 |
/* |
|
|
374 |
* Gère les événements de contrôle dans la mosaïque. |
|
|
375 |
*/ |
|
|
376 |
mosaic.prototype.manageControlEvents = function(event) |
|
|
377 |
{ |
|
|
378 |
console.log('manage'); |
|
|
379 |
//Sinon si on a appuyé sur 'g' ou 'G'. |
|
|
380 |
if(event.which == 103 || event.which == 71) |
|
|
381 |
{ |
|
|
382 |
//Si on est déjà en recherche par courbes. |
|
|
383 |
if(this.currentMode == "SEARCH" || this.currentMode == "FILTER") |
|
|
384 |
{ |
|
|
385 |
//On quitte cette recherche. |
|
|
386 |
this.leaveSearch(); |
|
|
387 |
//Si on était en mode recherche. |
|
|
388 |
if(this.currentMode == "SEARCH") |
|
|
389 |
{ |
|
|
390 |
//On revient dans la vidéo. |
|
|
391 |
this.currentMode = "VIDEO"; |
|
|
392 |
} |
|
|
393 |
else |
|
|
394 |
{ |
|
|
395 |
//Sinon c'est qu'on était dans la mosaïque. |
|
|
396 |
this.currentMode = "MOSAIC"; |
|
|
397 |
} |
|
|
398 |
} |
|
|
399 |
else |
|
|
400 |
{ |
|
|
401 |
//Si on est en plein écran. |
|
|
402 |
if(this.fullscreen) |
|
|
403 |
{ |
|
|
404 |
//On entre en mode recherche. |
|
|
405 |
this.currentMode = "SEARCH"; |
|
|
406 |
} |
|
|
407 |
//Sinon. |
|
|
408 |
else |
|
|
409 |
{ |
|
|
410 |
//On entre en mode filtrage. |
|
|
411 |
this.currentMode = "FILTER"; |
|
|
412 |
} |
|
|
413 |
|
|
|
414 |
this.startSearch(); |
|
|
415 |
} |
|
|
416 |
} |
|
|
417 |
//Si c'est a ou A. |
|
|
418 |
else if(event.which == 65 || event.which == 97) |
|
|
419 |
{ |
|
|
420 |
if(!this.helpDisplayed) |
|
|
421 |
{ |
|
|
422 |
this.notifyHelp(); |
|
|
423 |
} |
|
|
424 |
else |
|
|
425 |
{ |
|
|
426 |
this.removeHelp(); |
|
|
427 |
} |
|
|
428 |
} |
|
|
429 |
//Si c'est v ou V. |
|
|
430 |
else if(event.which == 86 || event.which == 118) |
|
|
431 |
{ |
|
|
432 |
this.notifySearchMarkers('run;jump;fall'); |
|
|
433 |
} |
|
|
434 |
//Si c'est b ou B. |
|
|
435 |
else if(event.which == 66 || event.which == 98) |
|
|
436 |
{ |
|
|
437 |
this.removeSearchMarkers(); |
|
|
438 |
} |
|
|
439 |
//Si c'est k ou K. |
|
|
440 |
else if(event.which == 75 || event.which == 107) |
|
|
441 |
{ |
|
|
442 |
this.searchFilter('circle'); |
|
|
443 |
} |
|
|
444 |
//Si c'est l ou L. |
|
|
445 |
else if(event.which == 76 || event.which == 108) |
|
|
446 |
{ |
|
|
447 |
this.removeFilter(); |
|
|
448 |
} |
|
|
449 |
//Si on a appuié sur la touche 'q' ou 'Q'; |
|
|
450 |
else if(event.which == 113 || event.which == 81) |
|
|
451 |
{ |
|
|
452 |
this.unzoom(); |
|
|
453 |
} |
|
|
454 |
else if(event.which == 111 || event.which == 79) |
|
|
455 |
{ |
|
|
456 |
if(this.snapshotsToShow > this.imagesToShow) |
|
|
457 |
{ |
|
|
458 |
this.snapshotsToShow = this.imagesToShow; |
|
|
459 |
} |
|
|
460 |
else |
|
|
461 |
{ |
|
|
462 |
this.snapshotsToShow += 5; |
|
|
463 |
} |
|
|
464 |
|
|
|
465 |
this.showNImages(this.snapshotsToShow); |
|
|
466 |
} |
|
|
467 |
} |
|
|
468 |
|
|
|
469 |
/* |
|
30
|
470 |
* 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. |
|
|
471 |
* 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. |
|
|
472 |
*/ |
|
|
473 |
mosaic.prototype.preZoom = function(snapshot) |
|
|
474 |
{ |
|
|
475 |
if(this.fullscreen) |
|
31
|
476 |
{ |
|
30
|
477 |
return; |
|
31
|
478 |
} |
|
33
|
479 |
|
|
|
480 |
//On enlève les notifications initiales si elles existent. |
|
|
481 |
this.removeSelectionSearchMosaicFull(); |
|
|
482 |
|
|
30
|
483 |
//Mosaïque. |
|
35
|
484 |
var _this = this; |
|
30
|
485 |
//Dimensions de la mosaïque. |
|
|
486 |
var h = this.height, w = this.width; |
|
|
487 |
//Longueur en images, nombre d'images et taille de bordure de la mosaïque. |
|
35
|
488 |
var len = this.config['length'], imgs = this.config['imagesToShow'], margin = this.marginWidth; |
|
30
|
489 |
//Dimensions et position d'un snapshot dans la mosaïque. |
|
|
490 |
var snHeight = this.snapshotHeight, snWidth = this.snapshotWidth; |
|
|
491 |
var sTop = snapshot.position().top, sLeft = snapshot.position().left; |
|
35
|
492 |
var prezoomPercentage = this.config['prezoomPercentage']; |
|
30
|
493 |
|
|
|
494 |
//ID de l'image actuelle. |
|
|
495 |
var currentId = $('img', snapshot).attr('id'); |
|
|
496 |
|
|
|
497 |
//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. |
|
|
498 |
if(this.zoomed) |
|
31
|
499 |
{ |
|
30
|
500 |
if($('#preZoomContainer-' + currentId) != $(this) && this.previousZoomedSN != '' && this.previousId != '') |
|
31
|
501 |
{ |
|
30
|
502 |
this.preUnzoom(); |
|
31
|
503 |
} |
|
30
|
504 |
else |
|
31
|
505 |
{ |
|
30
|
506 |
return; |
|
31
|
507 |
} |
|
|
508 |
} |
|
30
|
509 |
|
|
|
510 |
//On indique qu'on a zoomé et on spécifie le snapshot sur lequel on a zoomé. |
|
|
511 |
this.zoomed = true; |
|
|
512 |
this.previousZoomedSN = snapshot; |
|
|
513 |
this.previousId = currentId; |
|
|
514 |
|
|
|
515 |
//On récupère les attributs de l'image. |
|
|
516 |
var fakeImg = $('img', snapshot); |
|
|
517 |
//On forme la balise de la fausse image et on passe son url pour les grands snapshots. |
|
|
518 |
fakeImg = '<img id="fake-' + currentId + '" class="snapshots" src="' + fakeImg.attr('src').replace('-little/', '/') + '" />'; |
|
|
519 |
//On génère un faux snapshot identique au précédent et qu'on va coller dessus. |
|
|
520 |
var fakeSnapshot = '<div id="prezoomContainer-' + currentId + '" class="prezoomContainers"><div id="prezoomSnapshot-' + currentId + '" class="snapshotDivs">' + fakeImg + '</div></div>'; |
|
|
521 |
|
|
|
522 |
//On l'ajoute à la mosaïque. |
|
|
523 |
$('#mainPanel').append(fakeSnapshot); |
|
|
524 |
//On modifie ses attributs. |
|
|
525 |
$('#fake-' + currentId).load(function() |
|
|
526 |
{ |
|
|
527 |
$('#prezoomContainer-' + currentId).css('display', 'block'); |
|
|
528 |
$('#prezoomContainer-' + currentId).css('top', sTop).css('left', sLeft).css('width', (snWidth + margin)).css('height', (snHeight + margin)); |
|
|
529 |
$('#prezoomSnapshot-' + currentId).css('width', (snWidth)).css('height', (snHeight)); |
|
|
530 |
|
|
|
531 |
//Dimensions et coordonnées initiales du div sur lequel on zoom. |
|
|
532 |
var initialDivWidth = $('#prezoomContainer-' + currentId).width(), initialDivHeight = $('#prezoomContainer-' + currentId).height(); |
|
|
533 |
var initialDivTop = $('#prezoomContainer-' + currentId).position().top, initialDivLeft = $('#prezoomContainer-' + currentId).position().left; |
|
|
534 |
//Dimensions et coordonnées finales du div. |
|
|
535 |
var finalDivWidth = initialDivWidth * (prezoomPercentage+1), diffWidth = finalDivWidth - initialDivWidth, finalDivHeight = initialDivHeight + diffWidth; |
|
|
536 |
var finalDivTop = (initialDivTop - (finalDivHeight - snHeight)/2), finalDivLeft = (initialDivLeft - (finalDivWidth - snWidth)/2); |
|
|
537 |
|
|
|
538 |
//CAS PARTICULIER pour la position du snapshot zoomé : les bordures. |
|
|
539 |
if(finalDivTop < 0) |
|
31
|
540 |
{ |
|
30
|
541 |
finalDivTop = -margin; |
|
31
|
542 |
} |
|
30
|
543 |
if(finalDivTop + finalDivHeight > h) |
|
31
|
544 |
{ |
|
30
|
545 |
finalDivTop = h - finalDivHeight; |
|
31
|
546 |
} |
|
30
|
547 |
if(finalDivLeft < 0) |
|
31
|
548 |
{ |
|
30
|
549 |
finalDivLeft = 0; |
|
31
|
550 |
} |
|
30
|
551 |
if(finalDivLeft + finalDivWidth + margin*2 > w) |
|
31
|
552 |
{ |
|
30
|
553 |
finalDivLeft = w - finalDivWidth - margin*2; |
|
31
|
554 |
} |
|
30
|
555 |
|
|
|
556 |
////Code de debug. |
|
|
557 |
////CAUTION//// |
|
|
558 |
/*var red = '<div id="red"></div>'; |
|
|
559 |
if($('#red') != null || $('#red') != undefined) |
|
|
560 |
$('body').append(red); |
|
|
561 |
$('#red').css('background-color', '#FF0000').css('position', 'absolute').css('top', '0px').css('left', '0px').css('width', '100px').css('height', '100px'); |
|
|
562 |
$('#red').css('top', finalDivTop).css('left', finalDivLeft).css('width', finalDivWidth).css('height', finalDivHeight);*/ |
|
|
563 |
//alert("initial : " + initialDivWidth + " " + initialDivHeight + " ; final : " + finalDivWidth + " " + finalDivHeight); |
|
|
564 |
////CAUTION//// |
|
|
565 |
|
|
|
566 |
//On prézoom le div en le centrant sur le milieu du snapshot pointé. |
|
|
567 |
$('#prezoomSnapshot-' + currentId).animate( |
|
|
568 |
{ |
|
|
569 |
width: finalDivWidth + margin, |
|
|
570 |
height: finalDivHeight - margin*2, |
|
|
571 |
top: finalDivTop + margin, |
|
|
572 |
left: finalDivLeft + margin |
|
35
|
573 |
}, _this.config['timePrezoom']); |
|
30
|
574 |
$('#prezoomContainer-' + currentId).animate( |
|
|
575 |
{ |
|
|
576 |
width: finalDivWidth + margin*2, |
|
|
577 |
height: finalDivHeight - margin, |
|
|
578 |
top: finalDivTop + margin, |
|
|
579 |
left: finalDivLeft |
|
35
|
580 |
}, _this.config['timePrezoom'], function() |
|
33
|
581 |
{ |
|
35
|
582 |
_this.notifyPointMosaicPrezoom(); |
|
33
|
583 |
}); |
|
30
|
584 |
}); |
|
|
585 |
|
|
|
586 |
//Si on clique sur le snapshot prézoomé, on enclenche un zoom total sur ce snapshot. |
|
|
587 |
$('#prezoomContainer-' + currentId).click(function () |
|
|
588 |
{ |
|
|
589 |
if(this.previousZoomedSN != '') |
|
31
|
590 |
{ |
|
35
|
591 |
_this.zoom(); |
|
31
|
592 |
} |
|
30
|
593 |
}); |
|
|
594 |
} |
|
|
595 |
|
|
|
596 |
/* |
|
|
597 |
* 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é. |
|
|
598 |
*/ |
|
|
599 |
mosaic.prototype.preUnzoom = function() |
|
|
600 |
{ |
|
|
601 |
//Si on n'a pas zoomé, on quitte la fonction. |
|
|
602 |
if(!this.zoomed) |
|
31
|
603 |
{ |
|
30
|
604 |
return; |
|
31
|
605 |
} |
|
33
|
606 |
|
|
|
607 |
this.removePointMosaicPrezoom(); |
|
30
|
608 |
|
|
|
609 |
//On spécifie la marge afin de centrer le prédézoom. |
|
|
610 |
var margin = this.marginWidth; |
|
|
611 |
//ID du snapshot précédemment pointé. |
|
|
612 |
var id = this.previousId; |
|
|
613 |
//On ne zoom plus. |
|
|
614 |
this.zoomed = false; |
|
|
615 |
//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. |
|
|
616 |
$('#prezoomSnapshot-' + id).animate( |
|
|
617 |
{ |
|
|
618 |
width: this.snapshotWidth, |
|
|
619 |
height: this.snapshotHeight, |
|
|
620 |
top: this.previousZoomedSN.position().top, |
|
|
621 |
left: this.previousZoomedSN.position().left |
|
35
|
622 |
}, this.config['preUnzoomTime']); |
|
30
|
623 |
$('#prezoomContainer-' + id).animate( |
|
|
624 |
{ |
|
|
625 |
width: this.snapshotWidth + margin, |
|
|
626 |
height: this.snapshotHeight + margin, |
|
|
627 |
top: this.previousZoomedSN.position().top, |
|
|
628 |
left: this.previousZoomedSN.position().left |
|
35
|
629 |
}, this.config['preUnzoomTime'], function(){ $(this).remove(); this.zoomed = false; }); |
|
30
|
630 |
} |
|
|
631 |
|
|
|
632 |
|
|
|
633 |
/* |
|
|
634 |
* Zoom d'un snapshot en plein écran. |
|
|
635 |
*/ |
|
|
636 |
mosaic.prototype.zoom = function() |
|
|
637 |
{ |
|
35
|
638 |
var _this = this; |
|
30
|
639 |
|
|
|
640 |
//Si la mosaïque est en pleine écran, pas la peine de zoomer. |
|
35
|
641 |
if(this.currentMode == "VIDEO" || this.currentMode == "SEARCH") |
|
31
|
642 |
{ |
|
30
|
643 |
return; |
|
31
|
644 |
} |
|
33
|
645 |
|
|
|
646 |
this.removePointMosaicPrezoom(); |
|
30
|
647 |
|
|
|
648 |
//On prend les attributs nécessaires au calculs. |
|
35
|
649 |
var margin = this.marginWidth, len = this.config['length'], imgs = this.config['imagesToShow'], zoomedMargin = this.config['zoomedMargin']; |
|
|
650 |
var zoomPercentage = this.config['zoomPercentage']; |
|
30
|
651 |
var initMPWidth = this.previousZoomedSN.width() * len + margin*len, initMPHeight = this.previousZoomedSN.height() * (imgs / len) + margin*(imgs / len); |
|
35
|
652 |
var newMPWidth = initMPWidth * len + zoomedMargin * (len), newMPHeight = initMPHeight * (imgs / len) + zoomedMargin * ((imgs / len)); |
|
|
653 |
var newPreMPWidth = initMPWidth * len * zoomPercentage + zoomedMargin * (len), newPreMPHeight = initMPHeight * (imgs / len) * zoomPercentage + zoomedMargin * ((imgs / len)); |
|
30
|
654 |
|
|
|
655 |
//Dimensions et coordonnées initiales du div sur lequel on zoom. |
|
|
656 |
var initialDivWidth = this.previousZoomedSN.width(), initialDivHeight = this.previousZoomedSN.height(); |
|
|
657 |
var initialDivTop = this.previousZoomedSN.position().top, initialDivLeft = this.previousZoomedSN.position().left; |
|
|
658 |
//Dimensions et coordonnées finales du div. |
|
35
|
659 |
var finalDivWidth = initialDivWidth * (zoomPercentage+1), finalDivHeight = initialDivHeight * (zoomPercentage+1); |
|
|
660 |
var newZoomTop = -this.previousZoomedSN.position().top*(newPreMPHeight/initMPHeight) - zoomedMargin/2 + (initMPHeight - initMPHeight * zoomPercentage)/2, newZoomLeft = -this.previousZoomedSN.position().left*(newPreMPWidth/initMPWidth) - zoomedMargin/2 + (initMPWidth - initMPWidth * zoomPercentage)/2; |
|
|
661 |
var newSnWidth = initMPWidth * zoomPercentage, newSnHeight = initMPHeight * zoomPercentage; |
|
30
|
662 |
|
|
|
663 |
this.preUnzoom(this); |
|
|
664 |
/*SINGULARITE*/ |
|
|
665 |
this.fullscreen = true; |
|
|
666 |
|
|
|
667 |
//On passe l'image du snapshot pointé en HD. |
|
|
668 |
var zoomedImg = $('img', this.previousZoomedSN); |
|
|
669 |
var src = zoomedImg.attr('src'); |
|
|
670 |
zoomedImg.attr('src', src.replace('-little/', '/')); |
|
|
671 |
|
|
|
672 |
//On récupère son ID. |
|
|
673 |
var tab, zoomedImgId; |
|
35
|
674 |
tab = _this.previousId.split('-'); |
|
30
|
675 |
zoomedImgId = tab[1]; |
|
35
|
676 |
|
|
|
677 |
//On donne les dimensions des snapshots. |
|
|
678 |
$('.snapshotDivs').animate( |
|
|
679 |
{ |
|
|
680 |
width: newSnWidth, |
|
|
681 |
height: newSnHeight, |
|
|
682 |
margin: zoomedMargin/2 + 'px', |
|
|
683 |
}, this.config['zoomTime']); |
|
|
684 |
|
|
|
685 |
if(this.currentMode != 'NO-USER') |
|
|
686 |
{ |
|
|
687 |
//Les snapshots baissent alors en opacité, donnant l'impression qu'ils sont grisés. |
|
|
688 |
$('.snapshotDivs').animate( |
|
|
689 |
{ |
|
|
690 |
opacity: '0.4' |
|
|
691 |
}, this.config['zoomTime']); |
|
|
692 |
//Le snapshot du milieu revient à une opacité optimale, ce qui attire l'attention de l'utilisateur. |
|
|
693 |
$(this.previousZoomedSN).animate( |
|
|
694 |
{ |
|
|
695 |
opacity: '1' |
|
|
696 |
}, this.config['zoomTime']); |
|
|
697 |
} |
|
|
698 |
|
|
30
|
699 |
//On zoome sur la mosaïque. |
|
|
700 |
$('#mainPanel').animate( |
|
|
701 |
{ |
|
|
702 |
width: newPreMPWidth, |
|
|
703 |
height: newPreMPHeight, |
|
|
704 |
top: newZoomTop, |
|
|
705 |
left: newZoomLeft |
|
35
|
706 |
}, this.config['zoomTime'], function() |
|
30
|
707 |
{ |
|
|
708 |
//On charge les interactions avec les voisins. |
|
35
|
709 |
_this.centerId = zoomedImgId; |
|
|
710 |
|
|
|
711 |
if(_this.currentMode != "NO-USER") |
|
|
712 |
{ |
|
|
713 |
_this.currentMode = 'VIDEO'; |
|
|
714 |
_this.listenToNeighbours(); |
|
|
715 |
} |
|
31
|
716 |
|
|
35
|
717 |
_this.snTop = (zoomedImg.position().top + newZoomTop + _this.MPTop_margin), _this.snLeft = (zoomedImg.position().left + newZoomLeft); |
|
|
718 |
_this.snWidth = newSnWidth + 1, _this.snHeight = newSnHeight + 1; |
|
31
|
719 |
|
|
35
|
720 |
_this.notifyTopVideo = newZoomTop; |
|
|
721 |
_this.notifyLeftVideo = newZoomLeft; |
|
31
|
722 |
|
|
35
|
723 |
_this.loadPlayer(_this.snTop, _this.snLeft, _this.snWidth, _this.snHeight, newZoomTop, newZoomLeft); |
|
30
|
724 |
}); |
|
|
725 |
} |
|
|
726 |
|
|
|
727 |
/* |
|
31
|
728 |
* Chargement du player basé sur le metadataplayer. |
|
|
729 |
*/ |
|
33
|
730 |
mosaic.prototype.loadPlayer = function(newZoomTop, newZoomLeft, newSnWidth, newSnHeight, zoomTop, zoomLeft) |
|
31
|
731 |
{ |
|
35
|
732 |
var _this = this; |
|
|
733 |
|
|
31
|
734 |
//On configure les options de lancement. |
|
|
735 |
IriSP.libFiles.defaultDir = "../lib/"; |
|
|
736 |
IriSP.widgetsDir = "./player/metadataplayer/" |
|
|
737 |
|
|
32
|
738 |
var videoToPlay = this.videos[this.centerId]; |
|
|
739 |
var currentMetadata = this.urls[this.centerId]; |
|
|
740 |
|
|
31
|
741 |
var _metadata = { |
|
32
|
742 |
url: currentMetadata, |
|
31
|
743 |
format: 'ldt' |
|
|
744 |
}; |
|
35
|
745 |
|
|
31
|
746 |
var _config = { |
|
|
747 |
gui: { |
|
33
|
748 |
zoomTop: zoomTop - this.marginWidth*2, |
|
|
749 |
zoomLeft: zoomLeft, |
|
31
|
750 |
width: newSnWidth, |
|
|
751 |
height: newSnHeight, |
|
|
752 |
container: 'LdtPlayer', |
|
|
753 |
default_options: { |
|
|
754 |
metadata: _metadata |
|
|
755 |
}, |
|
|
756 |
css:'./player/metadataplayer/LdtPlayer-core.css', |
|
|
757 |
widgets: [ |
|
|
758 |
{ |
|
|
759 |
type: "Timeline" |
|
|
760 |
} |
|
|
761 |
] |
|
|
762 |
}, |
|
|
763 |
player:{ |
|
|
764 |
type: 'html5', // player type |
|
32
|
765 |
video: videoToPlay, |
|
31
|
766 |
live: true, |
|
|
767 |
height: newSnHeight, |
|
|
768 |
width: newSnWidth, |
|
|
769 |
autostart: true |
|
|
770 |
} |
|
|
771 |
}; |
|
|
772 |
|
|
|
773 |
//On positionne le player. |
|
|
774 |
$('.LdtPlayer').css( |
|
|
775 |
{ |
|
|
776 |
//display: 'none', |
|
|
777 |
position: 'absolute', |
|
|
778 |
'background-color': '#000000', |
|
|
779 |
top: newZoomTop, |
|
|
780 |
left: newZoomLeft |
|
|
781 |
}); |
|
|
782 |
|
|
|
783 |
//On démarre le player. |
|
32
|
784 |
this.player = null; |
|
|
785 |
this.player = new IriSP.Metadataplayer(_config, _metadata); |
|
35
|
786 |
|
|
|
787 |
if(this.currentMode == 'NO-USER') |
|
|
788 |
{ |
|
|
789 |
this.player.onLoad(function() |
|
|
790 |
{ |
|
|
791 |
console.log(_this.player); |
|
|
792 |
console.log(_this.player.popcorn); |
|
|
793 |
//Lorsque le player est en pause (par exemple lorsque le curseur arrive à la fin de la timeline). |
|
|
794 |
if(_this.player.popcorn != undefined) |
|
|
795 |
{ |
|
|
796 |
_this.player.popcorn.listen('pause', function() |
|
|
797 |
{ |
|
|
798 |
_this.unzoom(); |
|
|
799 |
}); |
|
|
800 |
} |
|
|
801 |
}); |
|
|
802 |
} |
|
31
|
803 |
} |
|
|
804 |
|
|
|
805 |
/* |
|
30
|
806 |
* Retour à la taille normale de la mosaïque. |
|
|
807 |
*/ |
|
|
808 |
mosaic.prototype.unzoom = function() |
|
|
809 |
{ |
|
|
810 |
//Si on n'est pas en plein écran, on quitte. |
|
35
|
811 |
console.log("'" + this.currentMode + "'"); |
|
|
812 |
if(this.currentMode != "SEARCH" && this.currentMode != "VIDEO" && this.currentMode != "NO-USER" && this.currentMode.indexOf("INCOMING") == -1) |
|
31
|
813 |
{ |
|
30
|
814 |
return; |
|
31
|
815 |
} |
|
33
|
816 |
|
|
|
817 |
this.snTop = 0; |
|
|
818 |
this.snLeft = 0; |
|
|
819 |
this.Width = 0; |
|
|
820 |
this.snHeight = 0; |
|
30
|
821 |
|
|
|
822 |
//On charge les attributs nécessaires aux calculs. |
|
|
823 |
var sWidth = this.snapshotWidth, sHeight = this.snapshotHeight; |
|
|
824 |
var mpWidth = this.width, mpHeight = this.height; |
|
35
|
825 |
var _this = this; |
|
30
|
826 |
|
|
31
|
827 |
//On passe le snapshot sur lequel on a zoomé en SD. |
|
30
|
828 |
var zoomedImg = $('img', this.previousZoomedSN); |
|
|
829 |
var src = zoomedImg.attr('src'); |
|
|
830 |
zoomedImg.attr('src', src.replace('snapshots/', 'snapshots-little/')); |
|
31
|
831 |
|
|
35
|
832 |
_this.player.widgets[0].freePlayer(); |
|
33
|
833 |
$('.LdtPlayer').remove(); |
|
31
|
834 |
$('body').append('<div class="LdtPlayer" id="LdtPlayer"></div>'); |
|
35
|
835 |
_this.reaffectKeyPress(); |
|
30
|
836 |
|
|
|
837 |
//On rend leur opacité aux snapshots. Qui ne sont alors plus grisés. |
|
|
838 |
$('.snapshotDivs').animate( |
|
|
839 |
{ |
|
|
840 |
width: sWidth, |
|
|
841 |
height: sHeight, |
|
35
|
842 |
margin: this.marginWidth/2 + 'px' |
|
|
843 |
}, this.config['unzoomTime']); |
|
|
844 |
|
|
|
845 |
if(this.currentMode != 'NO-USER') |
|
|
846 |
{ |
|
|
847 |
if(this.currentMode.indexOf("INCOMING") == -1) |
|
|
848 |
{ |
|
|
849 |
$('.snapshotDivs').animate( |
|
|
850 |
{ |
|
|
851 |
opacity: '1' |
|
|
852 |
}, this.config['unzoomTime']); |
|
|
853 |
} |
|
|
854 |
} |
|
|
855 |
else |
|
|
856 |
{ |
|
|
857 |
console.log('init'); |
|
|
858 |
this.previousZoomedSN.fadeTo(this.config['unzoomTime'], 0, function() |
|
|
859 |
{ |
|
|
860 |
_this.init(); |
|
|
861 |
}); |
|
|
862 |
} |
|
|
863 |
|
|
30
|
864 |
//On dézoom sur la mosaïque. |
|
|
865 |
$('#mainPanel').animate( |
|
|
866 |
{ |
|
|
867 |
width: mpWidth, |
|
|
868 |
height: mpHeight, |
|
|
869 |
top: '0px', |
|
|
870 |
left: '0px' |
|
35
|
871 |
}, this.config['unzoomTime'], function() |
|
30
|
872 |
{ |
|
|
873 |
//On n'est plus en plein écran, et on ne peut plus se déplacer vers le prochain voisin. |
|
35
|
874 |
_this.fullscreen = false; |
|
|
875 |
_this.canMoveToNeighbour = false; |
|
|
876 |
|
|
|
877 |
if(_this.currentMode != 'NO-USER') |
|
|
878 |
{ |
|
|
879 |
//On revient en mode MOSAIC. |
|
|
880 |
_this.currentMode = 'MOSAIC'; |
|
|
881 |
//On ne permet plus le déplacement vers les voisins. |
|
|
882 |
$('.snapshotDivs').unbind('mouseover', function() |
|
|
883 |
{ |
|
|
884 |
_this.selectNeighbour(); |
|
|
885 |
}); |
|
|
886 |
//On remet les notifications initiales. |
|
|
887 |
_this.notifySelectionSearchMosaicFull(); |
|
|
888 |
} |
|
30
|
889 |
}); |
|
|
890 |
} |
|
|
891 |
|
|
|
892 |
/* |
|
|
893 |
* Affecte les listeners mouseenter aux voisins lors d'une vue en plein écran. |
|
|
894 |
*/ |
|
|
895 |
mosaic.prototype.listenToNeighbours = function() |
|
|
896 |
{ |
|
|
897 |
////TEST |
|
|
898 |
//$('.test').empty(); |
|
35
|
899 |
var _this = this; |
|
|
900 |
|
|
|
901 |
this.canMoveToNeighbour = false; |
|
|
902 |
var currentLine = Math.floor(this.centerId / this.config['length']), currentColumn = this.centerId % this.config['length']; |
|
30
|
903 |
var zoomedImg = $('img', this.previousZoomedSN); |
|
|
904 |
|
|
|
905 |
//On cherche l'ID des voisins. |
|
|
906 |
//Si le voisin de gauche est sur la même ligne, on n'est pas sur la bordure de gauche. |
|
|
907 |
this.neighboursIds[0] = (currentColumn > 0) ? (this.centerId - 1) : -1; |
|
|
908 |
//Si le voisin de droite est sur la même ligne, on n'est pas sur la bordure de droite. |
|
35
|
909 |
this.neighboursIds[1] = (currentColumn < this.config['length']) ? (+this.centerId + 1) : -1; |
|
30
|
910 |
//Si le voisin du haut est sur la même colonne, on n'est pas sur la bordure du haut. |
|
35
|
911 |
this.neighboursIds[2] = (currentLine > 0) ? (this.centerId - this.config['length']) : -1; |
|
30
|
912 |
//Si le voisin du bas est sur la même colonne, on n'est pas sur la bordure du bas. |
|
35
|
913 |
this.neighboursIds[3] = (currentLine < (this.config['imagesToShow'] / this.config['length'])) ? (+this.centerId + this.config['length']) : -1; |
|
30
|
914 |
|
|
31
|
915 |
//ID du cadre voisin. |
|
|
916 |
var preId; |
|
|
917 |
|
|
30
|
918 |
for(var i = 0 ; i < this.neighboursIds.length ; i++) |
|
|
919 |
{ |
|
|
920 |
if(this.neighboursIds[i] != -1) |
|
31
|
921 |
{ |
|
|
922 |
preId = '#neighbourFrameBorder-' + this.neighboursIds[i]; |
|
30
|
923 |
//On permet le déplacement vers les voisins. |
|
31
|
924 |
// $('#snapshotDiv-' + this.neighboursIds[i] + ', ' + preId + '-left,' + preId + '-right,' + preId + '-up,' + preId + '-down').mouseenter(mos.selectNeighbour); |
|
35
|
925 |
|
|
|
926 |
$('#snapshotDiv-' + this.neighboursIds[i]).mouseover(function() |
|
|
927 |
{ |
|
|
928 |
_this.selectNeighbour($(this)); |
|
|
929 |
}); |
|
30
|
930 |
} |
|
|
931 |
} |
|
|
932 |
} |
|
|
933 |
|
|
|
934 |
/* |
|
|
935 |
* Change la coloration d'une bordure où on se positionne lors d'une vue en plein écran. |
|
|
936 |
*/ |
|
35
|
937 |
mosaic.prototype.selectNeighbour = function(neighbour) |
|
30
|
938 |
{ |
|
|
939 |
////TEST |
|
|
940 |
//$('.test').append(mos.currentMode + " " + $(this).attr('id') + " " + 'snapshotDiv-' + mos.centerId + ','); |
|
35
|
941 |
var _this = this; |
|
|
942 |
|
|
30
|
943 |
//Si on est en mode VIDEO (plein écran) ET si le snapshot pointé est un voisin. |
|
35
|
944 |
|
|
|
945 |
if((this.currentMode == 'VIDEO') && (neighbour.attr('id') != 'snapshotDiv-' + this.centerId)) |
|
|
946 |
{ |
|
31
|
947 |
//On crée le cadre qui va être superposé au voisin. |
|
30
|
948 |
//On le colle au voisin. |
|
35
|
949 |
var tab = neighbour.attr('id').split('-'); |
|
31
|
950 |
var snapshotId = tab[1]; |
|
|
951 |
var neighbourFrame = ''; |
|
35
|
952 |
var marginValue = parseFloat(neighbour.css('margin')); |
|
31
|
953 |
|
|
|
954 |
neighbourFrame += '<div class="neighbourFrame" id="neighbourFrame-' + snapshotId + '"><div class="neighbourImgBg" id="neighbourImgBg-' + snapshotId + '"><div class="neighbourImg" id="neighbourImg-' + snapshotId + '"></div></div></div>'; |
|
|
955 |
|
|
|
956 |
$('#mainPanel').append(neighbourFrame); |
|
|
957 |
|
|
|
958 |
//On positionne le div de background juste au niveau du voisin. |
|
|
959 |
$('#neighbourFrame-' + snapshotId).css( |
|
|
960 |
{ |
|
35
|
961 |
'top': (+neighbour.position().top + marginValue), |
|
|
962 |
'left': (+neighbour.position().left + marginValue), |
|
|
963 |
'width': neighbour.width(), |
|
|
964 |
'height': neighbour.height() |
|
31
|
965 |
}); |
|
|
966 |
//On positionne le div de background noir juste au niveau de l'image du voisin. |
|
|
967 |
$('#neighbourImgBg-' + snapshotId).css( |
|
|
968 |
{ |
|
|
969 |
'top': marginValue, |
|
|
970 |
'left': marginValue, |
|
35
|
971 |
'width': neighbour.width() - marginValue*2, |
|
|
972 |
'height': neighbour.height() - marginValue*2, |
|
31
|
973 |
}); |
|
|
974 |
//On met par dessus le div de l'image clonée du voisin. |
|
|
975 |
$('#neighbourImg-' + snapshotId).css( |
|
|
976 |
{ |
|
|
977 |
'top': 0, |
|
|
978 |
'left': 0, |
|
35
|
979 |
'width': neighbour.width() - marginValue*2, |
|
|
980 |
'height': neighbour.height() - marginValue*2, |
|
|
981 |
'background-image': 'url("' + $('img', neighbour).attr('src') + '")', |
|
|
982 |
'background-size': neighbour.width() + 'px ' + neighbour.height() + 'px', |
|
31
|
983 |
'background-position': -marginValue + 'px ' + -marginValue + 'px', |
|
|
984 |
'opacity': '0.4' |
|
|
985 |
}); |
|
|
986 |
|
|
|
987 |
var fId = '#neighbourFrame-' + snapshotId; |
|
|
988 |
|
|
|
989 |
$(fId).animate( |
|
30
|
990 |
{ |
|
|
991 |
//On le fait apparaître. |
|
31
|
992 |
opacity: '1' |
|
35
|
993 |
}, _this.config['timeNeighbourGlowing'], function() |
|
30
|
994 |
{ |
|
|
995 |
//On peut désormais se déplacer vers ce voisin. |
|
35
|
996 |
_this.canMoveToNeighbour = true; |
|
31
|
997 |
}); |
|
|
998 |
//Lorsqu'on quitte un des snapshots (bien entendu le voisin en question), on retire le cadre. |
|
|
999 |
//Si on clique sur le voisin ou son cadre, on passe au voisin suivant. |
|
35
|
1000 |
$(fId).mouseout(function() |
|
|
1001 |
{ |
|
|
1002 |
_this.deselectNeighbour($(this)) |
|
|
1003 |
}).click(function() |
|
|
1004 |
{ |
|
|
1005 |
_this.moveToNeighbour($(this)) |
|
|
1006 |
}); |
|
30
|
1007 |
} |
|
|
1008 |
} |
|
|
1009 |
|
|
|
1010 |
/* |
|
|
1011 |
* Change la coloration d'une bordure quittée lors d'une vue en plein écran. |
|
|
1012 |
*/ |
|
35
|
1013 |
mosaic.prototype.deselectNeighbour = function(neighbour) |
|
30
|
1014 |
{ |
|
|
1015 |
////TEST |
|
|
1016 |
//$('.test').append('un,'); |
|
31
|
1017 |
|
|
30
|
1018 |
//On ne peut plus se déplacer vers les voisins. |
|
35
|
1019 |
this.canMoveToNeighbour = false; |
|
31
|
1020 |
|
|
|
1021 |
//On récupère le voisin. |
|
35
|
1022 |
var neighbourFrame = neighbour; |
|
31
|
1023 |
|
|
30
|
1024 |
//Si on est en mode VIDEO. |
|
35
|
1025 |
if(this.currentMode == 'VIDEO') |
|
30
|
1026 |
{ |
|
|
1027 |
//On le fait disparaître progressivement. |
|
31
|
1028 |
neighbourFrame.animate( |
|
30
|
1029 |
{ |
|
|
1030 |
opacity: '0' |
|
35
|
1031 |
}, this.config['timeNeighbourUnglowing'], function() |
|
30
|
1032 |
{ |
|
|
1033 |
//Une fois invisible, on le supprime. |
|
31
|
1034 |
neighbourFrame.remove(); |
|
30
|
1035 |
}); |
|
|
1036 |
} |
|
|
1037 |
} |
|
|
1038 |
|
|
|
1039 |
/* |
|
|
1040 |
* 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. |
|
|
1041 |
*/ |
|
35
|
1042 |
mosaic.prototype.moveToNeighbour = function(neighbour) |
|
|
1043 |
{ |
|
|
1044 |
var _this = this; |
|
30
|
1045 |
//Si on ne peut pas se déplacer vers les voisins, on quitte. |
|
35
|
1046 |
if(!_this.canMoveToNeighbour) |
|
31
|
1047 |
{ |
|
30
|
1048 |
return; |
|
31
|
1049 |
} |
|
30
|
1050 |
|
|
|
1051 |
//On obtient l'ID de destination. |
|
35
|
1052 |
var tab = neighbour.attr('id').split('-'); |
|
31
|
1053 |
var destinationId = tab[1]; |
|
30
|
1054 |
|
|
|
1055 |
//On charge les attributs nécessaires aux calculs. |
|
35
|
1056 |
var length = _this.config['length']; |
|
30
|
1057 |
var MPCurrentTop = $('#mainPanel').position().top, MPCurrentLeft = $('#mainPanel').position().left; |
|
35
|
1058 |
var divideCoeffTop = Math.floor(destinationId / length) == 0 ? 1 : Math.floor(destinationId / length); |
|
|
1059 |
var divideCoeffLeft = destinationId % length == 0 ? 1 : destinationId % length; |
|
31
|
1060 |
var neighbourFrameTop = $('#snapshotDiv-' + destinationId).position().top, neighbourFrameLeft = $('#snapshotDiv-' + destinationId).position().left; |
|
30
|
1061 |
|
|
|
1062 |
//On définit pour le déplacement vertical s'il est nécessaire de se déplacer en haut ou en bas. |
|
35
|
1063 |
if(_this.previousZoomedSN.position().top > neighbourFrameTop) |
|
|
1064 |
MPCurrentTop += Math.abs(neighbourFrameTop - _this.previousZoomedSN.position().top); |
|
|
1065 |
else if(_this.previousZoomedSN.position().top < neighbourFrameTop) |
|
|
1066 |
MPCurrentTop -= Math.abs(neighbourFrameTop - _this.previousZoomedSN.position().top); |
|
30
|
1067 |
//On définit pour le déplacement horizontal s'il est nécessaire de se déplacer à gauche ou à droite. |
|
35
|
1068 |
if(_this.previousZoomedSN.position().left > neighbourFrameLeft) |
|
|
1069 |
MPCurrentLeft += Math.abs(neighbourFrameLeft - _this.previousZoomedSN.position().left); |
|
|
1070 |
else if(_this.previousZoomedSN.position().left < neighbourFrameLeft) |
|
|
1071 |
MPCurrentLeft -= Math.abs(neighbourFrameLeft - _this.previousZoomedSN.position().left); |
|
30
|
1072 |
|
|
|
1073 |
//On passe le snapshot de destination en HD. |
|
|
1074 |
var destinationImg = $('#snapshot-' + destinationId); |
|
|
1075 |
var destinationImgSrc = destinationImg.attr('src'); |
|
|
1076 |
destinationImg.attr('src', destinationImgSrc.replace('snapshots-little/', 'snapshots/')); |
|
|
1077 |
|
|
31
|
1078 |
//On passe l'ancien snapshot en SD. |
|
35
|
1079 |
var currentImgSrc = $('img', _this.previousZoomedSN).attr('src'); |
|
|
1080 |
$('img', _this.previousZoomedSN).attr('src', currentImgSrc.replace('snapshots/', 'snapshots-little/')); |
|
30
|
1081 |
|
|
|
1082 |
//On obtient l'ID du div de coloration du snapshot vers lequel on se déplace afin de le supprimer. |
|
35
|
1083 |
var neighbourFrame = neighbour; |
|
31
|
1084 |
var tab = neighbourFrame.attr('id').split('-'); |
|
35
|
1085 |
_this.centerId = tab[1]; |
|
30
|
1086 |
$(this).css('opacity', '0'); |
|
31
|
1087 |
neighbourFrame.remove(); |
|
|
1088 |
|
|
35
|
1089 |
_this.player.widgets[0].freePlayer(); |
|
33
|
1090 |
$('.LdtPlayer').remove(); |
|
31
|
1091 |
$('body').append('<div class="LdtPlayer" id="LdtPlayer"></div>'); |
|
35
|
1092 |
_this.reaffectKeyPress(); |
|
31
|
1093 |
|
|
30
|
1094 |
//On grise le snapshot qu'on vient de quitter. |
|
35
|
1095 |
_this.previousZoomedSN.animate( |
|
30
|
1096 |
{ |
|
|
1097 |
opacity: '0.4' |
|
|
1098 |
}); |
|
|
1099 |
|
|
|
1100 |
//On se déplace. |
|
|
1101 |
$('#mainPanel').animate( |
|
|
1102 |
{ |
|
|
1103 |
top: MPCurrentTop, |
|
|
1104 |
left: MPCurrentLeft |
|
35
|
1105 |
}, _this.config['timeMovingToNeighbour'], function() |
|
30
|
1106 |
{ |
|
|
1107 |
//On fait apparaître le snapshot vers lequel on s'est déplacé. |
|
|
1108 |
$('#snapshotDiv-' + destinationId).animate( |
|
|
1109 |
{ |
|
|
1110 |
opacity: '1' |
|
35
|
1111 |
}, _this.config['zoomTime'], function() |
|
30
|
1112 |
{ |
|
|
1113 |
//On recharge les voisins. |
|
35
|
1114 |
$('.snapshotDivs').unbind('mouseenter', _this.selectNeighbour); |
|
|
1115 |
_this.previousZoomedSN = $('#snapshotDiv-' + _this.centerId); |
|
|
1116 |
_this.listenToNeighbours(); |
|
31
|
1117 |
|
|
35
|
1118 |
_this.notifyTopVideo = MPCurrentTop; |
|
|
1119 |
_this.notifyLeftVideo = MPCurrentLeft; |
|
|
1120 |
|
|
|
1121 |
_this.loadPlayer((destinationImg.position().top + MPCurrentTop + _this.MPTop_margin), (destinationImg.position().left + MPCurrentLeft), destinationImg.width(), destinationImg.height(), MPCurrentTop, MPCurrentLeft); |
|
30
|
1122 |
}); |
|
|
1123 |
}); |
|
|
1124 |
} |
|
|
1125 |
|
|
|
1126 |
/* |
|
|
1127 |
* Déchargement du contenu de la mosaïque pour le chargement de la mosaïque locale. |
|
|
1128 |
*/ |
|
|
1129 |
mosaic.prototype.unload = function() |
|
|
1130 |
{ |
|
|
1131 |
//On supprime les event listeners des objets de la mosaïque. |
|
|
1132 |
$('.snapshotDivs').unbind(); |
|
|
1133 |
$('.snapshots').unbind(); |
|
|
1134 |
$('.prezoomContainers').unbind(); |
|
|
1135 |
//On supprime physiquement les objets. |
|
|
1136 |
$('#mainPanel').empty(); |
|
|
1137 |
} |
|
|
1138 |
|
|
|
1139 |
/* |
|
|
1140 |
* Centre verticalement un snapshot. |
|
|
1141 |
*/ |
|
|
1142 |
/*function verticalCenterImg(mosaic, img) |
|
|
1143 |
{ |
|
|
1144 |
//On récupère sa hauteur. |
|
|
1145 |
var image_height = img.height(); |
|
|
1146 |
//Calcule la marge du haut de chaque div pour le centrage. |
|
|
1147 |
if(mosaic.top_margin == undefined) |
|
|
1148 |
mosaic.top_margin = (mosaic.snapshotHeight > image_height) ? (mosaic.snapshotHeight - image_height)/2 : (image_height - mosaic.snapshotHeight)/2; |
|
|
1149 |
//On centre le snapshot. |
|
|
1150 |
img.css('margin-top', mosaic.top_margin).css('margin-bottom', mosaic.top_margin); |
|
|
1151 |
}*/ |
|
|
1152 |
|
|
|
1153 |
/* |
|
|
1154 |
* Permet de tester l'égalité des éléments de deux objets. |
|
|
1155 |
* Pour ce faire on compare les éléments définissant ces objets. |
|
|
1156 |
*/ |
|
|
1157 |
$.fn.equals = function(compareTo) |
|
|
1158 |
{ |
|
|
1159 |
if (!compareTo || !compareTo.length || this.length!=compareTo.length) |
|
|
1160 |
{ |
|
|
1161 |
return false; |
|
|
1162 |
} |
|
|
1163 |
for (var i=0; i<this .length; i++) |
|
|
1164 |
{ |
|
|
1165 |
if (this[i]!==compareTo[i]) |
|
|
1166 |
{ |
|
|
1167 |
return false; |
|
|
1168 |
} |
|
|
1169 |
} |
|
|
1170 |
return true; |
|
32
|
1171 |
} |
|
|
1172 |
|
|
|
1173 |
/* |
|
|
1174 |
* Charge les vidéos, les snapshots et les annotations depuis un fichier json. |
|
|
1175 |
*/ |
|
|
1176 |
mosaic.prototype.loadFromJson = function(path) |
|
|
1177 |
{ |
|
|
1178 |
var _this = this; |
|
33
|
1179 |
var i = 0; |
|
32
|
1180 |
|
|
|
1181 |
$.getJSON(path, function(data) |
|
|
1182 |
{ |
|
|
1183 |
$.each(data, function(key, val) |
|
|
1184 |
{ |
|
|
1185 |
$.each(val, function(key_video, val_video) |
|
|
1186 |
{ |
|
|
1187 |
$.getJSON(val_video.metadata, function(meta) |
|
|
1188 |
{ |
|
35
|
1189 |
if(_this.config['local'] == 'true') |
|
|
1190 |
{ |
|
|
1191 |
_this.affectVideoById(val_video.metadata, meta.medias[0].url.replace('rtmp://media.iri.centrepompidou.fr/ddc_player/', './player/videos/').replace('mp4:', '').replace('video/', '').replace('ldtplatform/', '').replace('.m4v', '.mp4')); |
|
|
1192 |
console.log(meta.medias[0].url.replace('rtmp://media.iri.centrepompidou.fr/ddc_player/', './player/videos/').replace('mp4:', '').replace('video/', '').replace('ldtplatform/', '').replace('.m4v', '.mp4')); |
|
|
1193 |
} |
|
|
1194 |
else |
|
|
1195 |
{ |
|
|
1196 |
_this.affectVideoById(val_video.metadata, meta.medias[0].url.replace('rtmp://', 'http://').replace('/ddc_player/', '/').replace('mp4:', '').replace('.m4v', '.mp4')); |
|
|
1197 |
console.log(meta.medias[0].url.replace('rtmp://', 'http://').replace('/ddc_player/', '/').replace('mp4:', '').replace('.m4v', '.mp4')); |
|
|
1198 |
} |
|
32
|
1199 |
}); |
|
33
|
1200 |
_this.imgs[_this.ids[i]] = val_video.snapshot; |
|
|
1201 |
_this.urls[_this.ids[i]] = val_video.metadata; |
|
35
|
1202 |
console.log('ids : ' + _this.ids[i]); |
|
33
|
1203 |
i++; |
|
32
|
1204 |
}); |
|
|
1205 |
}); |
|
|
1206 |
console.log('rdy'); |
|
|
1207 |
_this.loadMosaic(); |
|
|
1208 |
}); |
|
|
1209 |
} |
|
|
1210 |
|
|
|
1211 |
/* |
|
|
1212 |
* Affecte une vidéo au tableau des vidéos selon son id |
|
|
1213 |
*/ |
|
|
1214 |
mosaic.prototype.affectVideoById = function(metadata_id, video) |
|
|
1215 |
{ |
|
|
1216 |
for (i = 0 ; i < this.urls.length ; i++) |
|
|
1217 |
{ |
|
|
1218 |
if(this.urls[i] == metadata_id) |
|
|
1219 |
{ |
|
|
1220 |
this.videos[i] = video; |
|
|
1221 |
break; |
|
|
1222 |
} |
|
|
1223 |
} |
|
33
|
1224 |
} |
|
|
1225 |
|
|
|
1226 |
/* |
|
|
1227 |
* Lance une recherche par courbes. |
|
|
1228 |
*/ |
|
|
1229 |
mosaic.prototype.startSearch = function() |
|
|
1230 |
{ |
|
|
1231 |
var top, left, width, height, margin_top, inMosaic; |
|
|
1232 |
//Si on est dans le cas d'un filtrage de mosaïque. |
|
|
1233 |
if(this.currentMode == "FILTER") |
|
|
1234 |
{ |
|
|
1235 |
var mainPanel = $('#mainPanel'); |
|
|
1236 |
top = mainPanel.position().top; |
|
|
1237 |
left = mainPanel.position().left; |
|
|
1238 |
width = mainPanel.width(); |
|
|
1239 |
height = mainPanel.height(); |
|
|
1240 |
margin_top = this.MPTop_margin; |
|
|
1241 |
inMosaic = true; |
|
|
1242 |
} |
|
|
1243 |
//Sinon si c'est une recherche dans la vidéo. |
|
|
1244 |
else if(this.currentMode == "SEARCH") |
|
|
1245 |
{ |
|
|
1246 |
top = this.snTop; |
|
|
1247 |
left = this.snLeft; |
|
|
1248 |
width = this.snWidth; |
|
|
1249 |
height = this.snHeight; |
|
|
1250 |
margin_top = '0px'; |
|
|
1251 |
inMosaic = false; |
|
|
1252 |
} |
|
|
1253 |
|
|
|
1254 |
this.searchCanvas = new searchCanvas(top, left, width, height, margin_top, this.timeSearchFade, inMosaic); |
|
|
1255 |
this.searchCanvas.create(); |
|
|
1256 |
} |
|
|
1257 |
|
|
|
1258 |
/* |
|
|
1259 |
* Quitte une recherche par courbes. |
|
|
1260 |
*/ |
|
|
1261 |
mosaic.prototype.leaveSearch = function() |
|
|
1262 |
{ |
|
|
1263 |
this.searchCanvas.leaveSearch(); |
|
|
1264 |
} |
|
|
1265 |
|
|
|
1266 |
/* =============================================== |
|
|
1267 |
* * |
|
|
1268 |
* ZONE DES NOTIFICATIONS * |
|
|
1269 |
* * |
|
|
1270 |
=============================================== */ |
|
|
1271 |
|
|
|
1272 |
/* |
|
|
1273 |
* Affiche la notification de sélection/recherche lorsque la mosaique est complète. |
|
|
1274 |
*/ |
|
|
1275 |
mosaic.prototype.notifySelectionSearchMosaicFull = function() |
|
|
1276 |
{ |
|
35
|
1277 |
if(this.currentMode == "NO-USER" || this.currentMode.indexOf("INCOMING") == -1) |
|
|
1278 |
{ |
|
|
1279 |
return; |
|
|
1280 |
} |
|
|
1281 |
|
|
33
|
1282 |
//On spécifie les notifications en div. |
|
|
1283 |
var notification_selection = "<div id='notify_selection' class='notifications'></div>"; |
|
|
1284 |
var notification_search = "<div id='notify_search' class='notifications'></div>"; |
|
|
1285 |
|
|
|
1286 |
//On les ajoute à la mosaïque. |
|
|
1287 |
$('#mainPanel').append(notification_selection + notification_search); |
|
|
1288 |
|
|
|
1289 |
//On calcule leurs coordonnées et dimensions. |
|
|
1290 |
var notify_width = $('.notifications').width(), notify_height = $('.notifications').height(); |
|
|
1291 |
var notify_margin = parseInt($('.notifications').css('margin')); |
|
|
1292 |
var selection_left = $(window).width() / 2 - (notify_width * 2 + notify_margin * 3) / 2; |
|
|
1293 |
var search_left = selection_left + notify_width + notify_margin; |
|
|
1294 |
|
|
|
1295 |
//On les positionne. |
|
|
1296 |
$('#notify_selection').css( |
|
|
1297 |
{ |
|
|
1298 |
left: selection_left |
|
|
1299 |
}); |
|
|
1300 |
$('#notify_search').css( |
|
|
1301 |
{ |
|
|
1302 |
left: search_left |
|
|
1303 |
}); |
|
|
1304 |
|
|
|
1305 |
//On les fait apparaître. |
|
|
1306 |
$('.notifications').css( |
|
|
1307 |
{ |
|
|
1308 |
opacity: "0.9" |
|
|
1309 |
}); |
|
|
1310 |
} |
|
|
1311 |
|
|
|
1312 |
/* |
|
|
1313 |
* Supprime la notification de sélection/recherche lorsque la mosaique est complète. |
|
|
1314 |
*/ |
|
|
1315 |
mosaic.prototype.removeSelectionSearchMosaicFull = function() |
|
|
1316 |
{ |
|
|
1317 |
$('#notify_selection, #notify_search').remove(); |
|
|
1318 |
} |
|
|
1319 |
|
|
|
1320 |
/* |
|
|
1321 |
* Affiche la notification de maintient du pointage lors d'une phase de prézoom. |
|
|
1322 |
*/ |
|
|
1323 |
mosaic.prototype.notifyPointMosaicPrezoom = function() |
|
|
1324 |
{ |
|
35
|
1325 |
if($('#notify_point').length > 0 || this.currentMode == "NO-USER" || this.currentMode.indexOf("INCOMING") == -1) |
|
33
|
1326 |
{ |
|
|
1327 |
return; |
|
|
1328 |
} |
|
|
1329 |
|
|
|
1330 |
//On spécifie les notifications en div. |
|
|
1331 |
var notification_point = "<div id='notify_point' class='notifications'></div>"; |
|
|
1332 |
|
|
|
1333 |
//On les ajoute à la mosaïque. |
|
|
1334 |
$('#mainPanel').append(notification_point); |
|
35
|
1335 |
|
|
33
|
1336 |
//On calcule leurs coordonnées et dimensions. |
|
|
1337 |
var notify_width = $('.notifications').width(), notify_height = $('.notifications').height(); |
|
|
1338 |
var notify_margin = parseInt($('.notifications').css('margin')); |
|
|
1339 |
var point_left = $(window).width() / 2 - (notify_width) / 2 - notify_margin; |
|
|
1340 |
|
|
|
1341 |
//On les positionne. |
|
|
1342 |
$('#notify_point').css( |
|
|
1343 |
{ |
|
|
1344 |
left: point_left |
|
|
1345 |
}); |
|
|
1346 |
|
|
|
1347 |
//On les fait apparaître. |
|
|
1348 |
$('.notifications').css( |
|
|
1349 |
{ |
|
|
1350 |
opacity: "0.9" |
|
|
1351 |
}); |
|
|
1352 |
} |
|
|
1353 |
|
|
|
1354 |
/* |
|
|
1355 |
* Supprime la notification de maintient du pointage. |
|
|
1356 |
*/ |
|
|
1357 |
mosaic.prototype.removePointMosaicPrezoom = function() |
|
|
1358 |
{ |
|
|
1359 |
$('#notify_point').remove(); |
|
|
1360 |
} |
|
|
1361 |
|
|
|
1362 |
/* |
|
|
1363 |
* Affiche l'aide. |
|
|
1364 |
*/ |
|
|
1365 |
mosaic.prototype.notifyHelp = function() |
|
|
1366 |
{ |
|
|
1367 |
if(this.helpDisplayed) |
|
|
1368 |
{ |
|
|
1369 |
return; |
|
|
1370 |
} |
|
|
1371 |
|
|
|
1372 |
this.removeSelectionSearchMosaicFull(); |
|
|
1373 |
this.removePointMosaicPrezoom(); |
|
|
1374 |
|
|
|
1375 |
this.helpDisplayed = true; |
|
|
1376 |
|
|
|
1377 |
var search_2hands_tab = ['no_motion', 'right_angle', 'contact', 'grand_jete', 'circle', 'screw', 'arc', 'rythme', 'slow', 'up_down', 'wave', 'wheel']; |
|
|
1378 |
var search_body_tab = ['bend', 'fall', 'jump', 'hello', 'knee_up']; |
|
|
1379 |
var controls_1hand_tab = ['selection']; |
|
|
1380 |
|
|
|
1381 |
//On spécifie les notifications en div. |
|
|
1382 |
var search_title = "<div id='search_title'></div>"; |
|
|
1383 |
var search_img = "<div id='search_img' class='notify_imgs'></div>"; |
|
|
1384 |
var search_2hands_text = "<div id='search_2hands_text'></div>"; |
|
|
1385 |
var search_2hands_imgs = "<div id='search_2hands_imgs' class='notify_imgs_big'>"; |
|
|
1386 |
|
|
|
1387 |
for(var i = 0 ; i < search_2hands_tab.length ; i++) |
|
|
1388 |
{ |
|
|
1389 |
search_2hands_imgs += "<div id='2hands_" + search_2hands_tab[i] + "' class='notify_imgs_small'></div>"; |
|
|
1390 |
} |
|
|
1391 |
search_2hands_imgs += "</div>"; |
|
|
1392 |
|
|
|
1393 |
var search_body_text = "<div id='search_body_text'></div>"; |
|
|
1394 |
var search_body_imgs = "<div id='search_2hands_imgs' class='notify_imgs'>" |
|
|
1395 |
|
|
|
1396 |
for(var i = 0 ; i < search_body_tab.length ; i++) |
|
|
1397 |
{ |
|
|
1398 |
search_body_imgs += "<div id='body_" + search_body_tab[i] + "' class='notify_imgs_small'></div>"; |
|
|
1399 |
} |
|
|
1400 |
search_body_imgs += "</div>"; |
|
|
1401 |
|
|
|
1402 |
var controls_title = "<div id='controls_title'></div>"; |
|
|
1403 |
var controls_img = "<div id='controls_img' class='notify_imgs'></div>"; |
|
|
1404 |
var controls_1hand_text = "<div id='controls_1hand_text'></div>"; |
|
|
1405 |
var controls_1hand_imgs = "<div id='controls_1hand_imgs' class='notify_imgs'>"; |
|
|
1406 |
|
|
|
1407 |
for(var i = 0 ; i < controls_1hand_tab.length ; i++) |
|
|
1408 |
{ |
|
|
1409 |
controls_1hand_imgs += "<div id='1hand_" + controls_1hand_tab[i] + "' class='notify_imgs_small'></div>"; |
|
|
1410 |
} |
|
|
1411 |
controls_1hand_imgs += "</div>"; |
|
|
1412 |
|
|
|
1413 |
var help_search = "<div id='help_search'>" + search_title + search_img + search_2hands_text + search_2hands_imgs + search_body_text + search_body_imgs + "</div>"; |
|
|
1414 |
var help_controls = "<div id='help_controls'>" + controls_title + controls_img + controls_1hand_text + controls_1hand_imgs + "</div>"; |
|
|
1415 |
|
|
|
1416 |
var notification_help = "<div id='notify_help'>" + help_search + "<div id='help_sep'></div>" + help_controls + "</div>"; |
|
|
1417 |
|
|
|
1418 |
//On les ajoute à la mosaïque. |
|
|
1419 |
$('body').append(notification_help); |
|
|
1420 |
|
|
|
1421 |
//On calcule leurs coordonnées et dimensions. |
|
|
1422 |
var notify_width = $(window).width(), notify_height = $(window).height(); |
|
|
1423 |
var notify_margin = parseInt($('#notify_help').css('margin')); |
|
|
1424 |
var notify_ = 10; |
|
|
1425 |
|
|
|
1426 |
//On les positionne. |
|
|
1427 |
$('#notify_help').css( |
|
|
1428 |
{ |
|
|
1429 |
left: "0px", |
|
|
1430 |
top: "0px", |
|
|
1431 |
width: notify_width - notify_margin * 2, |
|
35
|
1432 |
height: notify_height - notify_margin * 2 |
|
33
|
1433 |
}); |
|
|
1434 |
|
|
|
1435 |
var search_width = $('#help_search').width(); |
|
|
1436 |
|
|
|
1437 |
$('#search_title').html('Recherche'); |
|
|
1438 |
$('#search_2hands_text').html('Gestes à effectuer avec les deux mains'); |
|
|
1439 |
$('#search_body_text').html('Gestes à effectuer avec le corps entier'); |
|
|
1440 |
|
|
|
1441 |
for(var i = 0 ; i < search_2hands_tab.length ; i++) |
|
|
1442 |
{ |
|
|
1443 |
$("#2hands_" + search_2hands_tab[i]).css("background-image", "url('./pictos/help/" + search_2hands_tab[i] + ".png')"); |
|
|
1444 |
//console.log("url('../../pictos/help/" + search_2hands_tab[i] + ".png')"); |
|
|
1445 |
} |
|
|
1446 |
|
|
|
1447 |
for(var i = 0 ; i < search_body_tab.length ; i++) |
|
|
1448 |
{ |
|
|
1449 |
$("#body_" + search_body_tab[i]).css("background-image", "url('./pictos/help/" + search_body_tab[i] + ".png')"); |
|
|
1450 |
//console.log("url('../../pictos/help/" + search_2hands_tab[i] + ".png')"); |
|
|
1451 |
} |
|
|
1452 |
|
|
|
1453 |
$('#controls_title').html('Contrôles'); |
|
|
1454 |
$('#controls_1hand_text').html('Gestes à effectuer avec une seule main'); |
|
|
1455 |
|
|
|
1456 |
for(var i = 0 ; i < controls_1hand_tab.length ; i++) |
|
|
1457 |
{ |
|
|
1458 |
$("#1hand_" + controls_1hand_tab[i]).css("background-image", "url('./pictos/help/" + controls_1hand_tab[i] + ".png')"); |
|
|
1459 |
//console.log("url('../../pictos/help/" + search_2hands_tab[i] + ".png')"); |
|
|
1460 |
} |
|
|
1461 |
|
|
|
1462 |
//On les fait apparaître. |
|
|
1463 |
$('#notify_help').css( |
|
|
1464 |
{ |
|
|
1465 |
opacity: "1" |
|
|
1466 |
}); |
|
|
1467 |
|
|
|
1468 |
$('.notify_imgs_big').css( |
|
|
1469 |
{ |
|
|
1470 |
opacity: "1" |
|
|
1471 |
}); |
|
|
1472 |
} |
|
|
1473 |
|
|
|
1474 |
/* |
|
|
1475 |
* Supprime l'aide. |
|
|
1476 |
*/ |
|
|
1477 |
mosaic.prototype.removeHelp = function() |
|
|
1478 |
{ |
|
|
1479 |
if(!this.helpDisplayed) |
|
|
1480 |
{ |
|
|
1481 |
return; |
|
|
1482 |
} |
|
|
1483 |
|
|
|
1484 |
var _this = this; |
|
|
1485 |
|
|
|
1486 |
$('#notify_help').fadeOut(this.timeNotifyFade, function() |
|
|
1487 |
{ |
|
|
1488 |
_this.helpDisplayed = false; |
|
|
1489 |
$('#notify_help').remove(); |
|
|
1490 |
}); |
|
35
|
1491 |
} |
|
|
1492 |
|
|
|
1493 |
/* |
|
|
1494 |
* Affiche les types de marqueurs correspondants à ce qu'on a commencé à tracer lors d'une recherche. |
|
|
1495 |
*/ |
|
|
1496 |
mosaic.prototype.notifySearchMarkers = function(markersStr) |
|
|
1497 |
{ |
|
|
1498 |
if($('.notifications_inSearch_container').length > 0) |
|
|
1499 |
{ |
|
|
1500 |
return; |
|
|
1501 |
} |
|
|
1502 |
|
|
|
1503 |
console.log(markersStr); |
|
|
1504 |
|
|
|
1505 |
var markersList = markersStr.split(new RegExp(';')); |
|
|
1506 |
|
|
|
1507 |
var notification_search_markers = "<div class='notifications_inSearch_container'>"; |
|
|
1508 |
|
|
|
1509 |
//On spécifie les notifications en div. |
|
|
1510 |
for(var i = 0 ; i < markersList.length ; i++) |
|
|
1511 |
{ |
|
|
1512 |
notification_search_markers += "<div class='notifications_inSearch' style='background-image: url(./pictos/big/normal/" + markersList[i] + ".png);'></div>"; |
|
|
1513 |
} |
|
|
1514 |
|
|
|
1515 |
notification_search_markers += "</div>"; |
|
|
1516 |
|
|
|
1517 |
//On les ajoute à la mosaïque. |
|
|
1518 |
$('#mainPanel').append(notification_search_markers); |
|
|
1519 |
|
|
|
1520 |
//On calcule leurs coordonnées et dimensions. |
|
|
1521 |
var notify_width = $('.notifications_inSearch_container').width(), notify_height = $('.notifications_inSearch_container').height(); |
|
|
1522 |
var notify_margin = parseInt($('.notifications_inSearch').css('margin')); |
|
|
1523 |
var point_left = $(window).width() / 2 - (notify_width) / 2 - notify_margin; |
|
|
1524 |
var point_top = 0; |
|
|
1525 |
|
|
|
1526 |
if(this.currentMode == "VIDEO" || this.currentMode == "SEARCH") |
|
|
1527 |
{ |
|
|
1528 |
point_top = -this.notifyTopVideo, |
|
|
1529 |
point_left = -this.notifyLeftVideo + ($(window).width() - notify_width) / 2 |
|
|
1530 |
} |
|
|
1531 |
|
|
|
1532 |
//On les positionne. |
|
|
1533 |
$('.notifications_inSearch_container').css( |
|
|
1534 |
{ |
|
|
1535 |
left: point_left, |
|
|
1536 |
top: point_top |
|
|
1537 |
}); |
|
|
1538 |
|
|
|
1539 |
//On les fait apparaître. |
|
|
1540 |
$('.notifications_inSearch').css( |
|
|
1541 |
{ |
|
|
1542 |
opacity: "0.9" |
|
|
1543 |
}); |
|
|
1544 |
} |
|
|
1545 |
|
|
|
1546 |
/* |
|
|
1547 |
* Supprime la notification de maintient du pointage. |
|
|
1548 |
*/ |
|
|
1549 |
mosaic.prototype.removeSearchMarkers = function() |
|
|
1550 |
{ |
|
|
1551 |
$('.notifications_inSearch_container').remove(); |
|
|
1552 |
} |
|
|
1553 |
|
|
|
1554 |
/* |
|
|
1555 |
* Effectuer un filtrage de la mosaïque par rapport à un type de marqueurs. |
|
|
1556 |
*/ |
|
|
1557 |
mosaic.prototype.searchFilter = function(type) |
|
|
1558 |
{ |
|
|
1559 |
var _this = this; |
|
|
1560 |
|
|
|
1561 |
if(this.currentMode == "MOSAIC") |
|
|
1562 |
{ |
|
|
1563 |
this.currentMode = "FILTER"; |
|
|
1564 |
|
|
|
1565 |
if(this.annotations.length > 0) |
|
|
1566 |
{ |
|
|
1567 |
var gestureNumberByVideo = new Object(); |
|
|
1568 |
var maxAnnotationNumber = 0; |
|
|
1569 |
// for(var i = 0 ; i < this.config['imagesToShow'] ; i++) |
|
|
1570 |
for(var i = 0 ; i < this.annotations.length ; i++) |
|
|
1571 |
{ |
|
|
1572 |
var current = this.annotations[i]; |
|
|
1573 |
if(current.annotationType.contents.title == type) |
|
|
1574 |
{ |
|
|
1575 |
if(gestureNumberByVideo[current.source.url] == undefined || gestureNumberByVideo[current.source.url] == '') |
|
|
1576 |
{ |
|
|
1577 |
gestureNumberByVideo[current.source.url] = 0; |
|
|
1578 |
} |
|
|
1579 |
|
|
|
1580 |
gestureNumberByVideo[current.source.url]++; |
|
|
1581 |
} |
|
|
1582 |
} |
|
|
1583 |
|
|
|
1584 |
for(var i = 0 ; i < this.urls.length ; i++) |
|
|
1585 |
{ |
|
|
1586 |
if(gestureNumberByVideo[this.urls[i]] == undefined || gestureNumberByVideo[this.urls[i]] == '') |
|
|
1587 |
{ |
|
|
1588 |
gestureNumberByVideo[this.urls[i]] = 0; |
|
|
1589 |
} |
|
|
1590 |
} |
|
|
1591 |
|
|
|
1592 |
//On récupère la vidéo qui score le nombre d'occurences de la gesture le plus haut. |
|
|
1593 |
for(i in gestureNumberByVideo) |
|
|
1594 |
{ |
|
|
1595 |
// console.log(i + " " + gestureNumberByVideo[i]); |
|
|
1596 |
if(maxAnnotationNumber < gestureNumberByVideo[i]) |
|
|
1597 |
{ |
|
|
1598 |
maxAnnotationNumber = gestureNumberByVideo[i]; |
|
|
1599 |
} |
|
|
1600 |
} |
|
|
1601 |
|
|
|
1602 |
var snMargin = parseInt($('.snapshotDivs').css('margin')); |
|
|
1603 |
|
|
|
1604 |
//On affiche l'opacité résultante pour chaque vidéo. |
|
|
1605 |
for(i in gestureNumberByVideo) |
|
|
1606 |
{ |
|
|
1607 |
//Opacité conventionelle. |
|
|
1608 |
var opacity = gestureNumberByVideo[i] / maxAnnotationNumber; |
|
|
1609 |
// console.log('opacity b : ' + opacity + ' for ' + gestureNumberByVideo[i]); |
|
|
1610 |
//Ce qui est à zéro le restera (par conséquent le snapshot associé sera invisible). |
|
|
1611 |
if(opacity > 0) |
|
|
1612 |
{ |
|
|
1613 |
//On réhausse l'opacité de 50%. |
|
|
1614 |
opacity = this.scaleIntervals(0., 1., 0.5, 1., opacity); |
|
|
1615 |
} |
|
|
1616 |
|
|
|
1617 |
var filterIndex = this.getIdxFromMetadata(i); |
|
|
1618 |
|
|
|
1619 |
if(filterIndex >= 0) |
|
|
1620 |
{ |
|
|
1621 |
console.log('#snapshotDiv-' + filterIndex + " " + _this.config['timeFilterFade'] + " " + opacity); |
|
|
1622 |
$('#snapshotDiv-' + filterIndex).fadeTo(_this.config['timeFilterFade'], opacity); |
|
|
1623 |
|
|
|
1624 |
if(opacity == 0) |
|
|
1625 |
{ |
|
|
1626 |
var filteredSnapshot = $('#snapshotDiv-' + filterIndex); |
|
|
1627 |
|
|
|
1628 |
if(filteredSnapshot.length > 0) |
|
|
1629 |
{ |
|
|
1630 |
var hider = '<div id="filterHider-' + filterIndex + '" class="filterHiders"></div>'; |
|
|
1631 |
$('#mainPanel').append(hider); |
|
|
1632 |
|
|
|
1633 |
$('#filterHider-' + filterIndex).css( |
|
|
1634 |
{ |
|
|
1635 |
width: +filteredSnapshot.width() + 4 * snMargin, |
|
|
1636 |
height: +filteredSnapshot.height() + 4 * snMargin, |
|
|
1637 |
top: filteredSnapshot.position().top - snMargin, |
|
|
1638 |
left: filteredSnapshot.position().left - snMargin |
|
|
1639 |
}); |
|
|
1640 |
} |
|
|
1641 |
} |
|
|
1642 |
} |
|
|
1643 |
} |
|
|
1644 |
} |
|
|
1645 |
} |
|
|
1646 |
} |
|
|
1647 |
|
|
|
1648 |
/* |
|
|
1649 |
* Passe une valeur de l'intervalle [A, B] à l'intervalle [C, D]. |
|
|
1650 |
*/ |
|
|
1651 |
mosaic.prototype.scaleIntervals = function(A, B, C, D, val) |
|
|
1652 |
{ |
|
|
1653 |
return (D - C + A) * val + (C - A); |
|
|
1654 |
} |
|
|
1655 |
|
|
|
1656 |
/* |
|
|
1657 |
* Retourne l'index d'un snapshot en fonction de ses metadonnées. |
|
|
1658 |
*/ |
|
|
1659 |
mosaic.prototype.getIdxFromMetadata = function(metadata) |
|
|
1660 |
{ |
|
|
1661 |
var _this = this; |
|
|
1662 |
|
|
|
1663 |
for(idx in this.urls) |
|
|
1664 |
{ |
|
|
1665 |
if(this.urls[idx] == metadata) |
|
|
1666 |
{ |
|
|
1667 |
for(id in this.ids) |
|
|
1668 |
{ |
|
|
1669 |
if(this.ids[id] == idx) |
|
|
1670 |
{ |
|
|
1671 |
return id; |
|
|
1672 |
} |
|
|
1673 |
} |
|
|
1674 |
} |
|
|
1675 |
} |
|
|
1676 |
|
|
|
1677 |
return -1; |
|
|
1678 |
} |
|
|
1679 |
|
|
|
1680 |
/* |
|
|
1681 |
* Enlève une recherche par filtre. |
|
|
1682 |
*/ |
|
|
1683 |
mosaic.prototype.removeFilter = function() |
|
|
1684 |
{ |
|
|
1685 |
if(this.currentMode == "FILTER") |
|
|
1686 |
{ |
|
|
1687 |
this.currentMode = "MOSAIC"; |
|
|
1688 |
|
|
|
1689 |
var _this = this; |
|
|
1690 |
|
|
|
1691 |
$('.filterHiders').remove(); |
|
|
1692 |
$('.snapshotDivs').fadeTo(_this.config['timeFilterFade'], 1); |
|
|
1693 |
} |
|
|
1694 |
} |
|
|
1695 |
|
|
|
1696 |
/* |
|
|
1697 |
* Rebind keypress pour body. |
|
|
1698 |
*/ |
|
|
1699 |
mosaic.prototype.reaffectKeyPress = function() |
|
|
1700 |
{ |
|
|
1701 |
var _this = this; |
|
|
1702 |
|
|
|
1703 |
$('body').keypress(function (event) |
|
|
1704 |
{ |
|
|
1705 |
_this.manageControlEvents(event); |
|
|
1706 |
}); |
|
30
|
1707 |
} |