193 var finalDivWidth = initialDivWidth * (prezoomPercentage+1), diffWidth = finalDivWidth - initialDivWidth, finalDivHeight = initialDivHeight + diffWidth; |
201 var finalDivWidth = initialDivWidth * (prezoomPercentage+1), diffWidth = finalDivWidth - initialDivWidth, finalDivHeight = initialDivHeight + diffWidth; |
194 var finalDivTop = (initialDivTop - (finalDivHeight - snHeight)/2), finalDivLeft = (initialDivLeft - (finalDivWidth - snWidth)/2); |
202 var finalDivTop = (initialDivTop - (finalDivHeight - snHeight)/2), finalDivLeft = (initialDivLeft - (finalDivWidth - snWidth)/2); |
195 |
203 |
196 //CAS PARTICULIER pour la position du snapshot zoomé : les bordures. |
204 //CAS PARTICULIER pour la position du snapshot zoomé : les bordures. |
197 if(finalDivTop < 0) |
205 if(finalDivTop < 0) |
|
206 { |
198 finalDivTop = -margin; |
207 finalDivTop = -margin; |
|
208 } |
199 if(finalDivTop + finalDivHeight > h) |
209 if(finalDivTop + finalDivHeight > h) |
|
210 { |
200 finalDivTop = h - finalDivHeight; |
211 finalDivTop = h - finalDivHeight; |
|
212 } |
201 if(finalDivLeft < 0) |
213 if(finalDivLeft < 0) |
|
214 { |
202 finalDivLeft = 0; |
215 finalDivLeft = 0; |
|
216 } |
203 if(finalDivLeft + finalDivWidth + margin*2 > w) |
217 if(finalDivLeft + finalDivWidth + margin*2 > w) |
|
218 { |
204 finalDivLeft = w - finalDivWidth - margin*2; |
219 finalDivLeft = w - finalDivWidth - margin*2; |
|
220 } |
205 |
221 |
206 ////Code de debug. |
222 ////Code de debug. |
207 ////CAUTION//// |
223 ////CAUTION//// |
208 /*var red = '<div id="red"></div>'; |
224 /*var red = '<div id="red"></div>'; |
209 if($('#red') != null || $('#red') != undefined) |
225 if($('#red') != null || $('#red') != undefined) |
291 //Dimensions et coordonnées initiales du div sur lequel on zoom. |
313 //Dimensions et coordonnées initiales du div sur lequel on zoom. |
292 var initialDivWidth = this.previousZoomedSN.width(), initialDivHeight = this.previousZoomedSN.height(); |
314 var initialDivWidth = this.previousZoomedSN.width(), initialDivHeight = this.previousZoomedSN.height(); |
293 var initialDivTop = this.previousZoomedSN.position().top, initialDivLeft = this.previousZoomedSN.position().left; |
315 var initialDivTop = this.previousZoomedSN.position().top, initialDivLeft = this.previousZoomedSN.position().left; |
294 //Dimensions et coordonnées finales du div. |
316 //Dimensions et coordonnées finales du div. |
295 var finalDivWidth = initialDivWidth * (this.zoomPercentage+1), finalDivHeight = initialDivHeight * (this.zoomPercentage+1); |
317 var finalDivWidth = initialDivWidth * (this.zoomPercentage+1), finalDivHeight = initialDivHeight * (this.zoomPercentage+1); |
296 var newZoomTop = -this.previousZoomedSN.position().top*(newPreMPHeight/initMPHeight) - this.zoomedMargin/2 + (initMPHeight - initMPHeight * this.zoomPercentage)/2 + 'px', newZoomLeft = -this.previousZoomedSN.position().left*(newPreMPWidth/initMPWidth) - this.zoomedMargin/2 + (initMPWidth - initMPWidth * this.zoomPercentage)/2 + 'px'; |
318 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; |
297 var newSnWidth = initMPWidth * this.zoomPercentage, newSnHeight = initMPHeight * this.zoomPercentage; |
319 var newSnWidth = initMPWidth * this.zoomPercentage, newSnHeight = initMPHeight * this.zoomPercentage; |
298 |
320 |
299 this.preUnzoom(this); |
321 this.preUnzoom(this); |
300 /*SINGULARITE*/ |
322 /*SINGULARITE*/ |
301 this.fullscreen = true; |
323 this.fullscreen = true; |
334 { |
356 { |
335 //On charge les interactions avec les voisins. |
357 //On charge les interactions avec les voisins. |
336 mos.centerId = zoomedImgId; |
358 mos.centerId = zoomedImgId; |
337 mos.listenToNeighbours(); |
359 mos.listenToNeighbours(); |
338 mos.currentMode = 'VIDEO'; |
360 mos.currentMode = 'VIDEO'; |
|
361 |
|
362 console.log('h : ' + -newZoomLeft + " " + zoomedImg.position().left); |
|
363 |
|
364 mos.loadPlayer((zoomedImg.position().top + newZoomTop + mos.MPTop_margin), (zoomedImg.position().left + newZoomLeft), newSnWidth + 1, newSnHeight + 1); |
|
365 |
339 /*mos.unload(); |
366 /*mos.unload(); |
340 mos.localMos.loadLocalMosaic(newZoomTop, newZoomLeft, newSnWidth, newSnHeight, mos.imgs, tab[1]);*/ |
367 mos.localMos.loadLocalMosaic(newZoomTop, newZoomLeft, newSnWidth, newSnHeight, mos.imgs, tab[1]);*/ |
341 }); |
368 }); |
342 } |
369 } |
343 |
370 |
344 /* |
371 /* |
|
372 * Chargement du player basé sur le metadataplayer. |
|
373 */ |
|
374 mosaic.prototype.loadPlayer = function(newZoomTop, newZoomLeft, newSnWidth, newSnHeight) |
|
375 { |
|
376 //On configure les options de lancement. |
|
377 IriSP.libFiles.defaultDir = "../lib/"; |
|
378 IriSP.widgetsDir = "./player/metadataplayer/" |
|
379 |
|
380 console.log(newZoomTop + " " + newZoomLeft); |
|
381 |
|
382 var _metadata = { |
|
383 url: 'http://ldt.iri.centrepompidou.fr/ldtplatform/ldt/cljson/id/7c912bce-66b8-11e1-80f6-00145ea4a2be?callback=?', |
|
384 format: 'ldt' |
|
385 }; |
|
386 var _config = { |
|
387 gui: { |
|
388 width: newSnWidth, |
|
389 height: newSnHeight, |
|
390 container: 'LdtPlayer', |
|
391 default_options: { |
|
392 metadata: _metadata |
|
393 }, |
|
394 css:'./player/metadataplayer/LdtPlayer-core.css', |
|
395 widgets: [ |
|
396 { |
|
397 type: "Timeline" |
|
398 } |
|
399 ] |
|
400 }, |
|
401 player:{ |
|
402 type: 'html5', // player type |
|
403 video: 'http://media.iri.centrepompidou.fr/video/ldtplatform/body_trail_cctv.mp4', |
|
404 live: true, |
|
405 height: newSnHeight, |
|
406 width: newSnWidth, |
|
407 autostart: true |
|
408 } |
|
409 }; |
|
410 |
|
411 //On positionne le player. |
|
412 $('.LdtPlayer').css( |
|
413 { |
|
414 //display: 'none', |
|
415 position: 'absolute', |
|
416 'background-color': '#000000', |
|
417 top: newZoomTop, |
|
418 left: newZoomLeft |
|
419 }); |
|
420 |
|
421 //On démarre le player. |
|
422 var _myPlayer = new IriSP.Metadataplayer(_config, _metadata); |
|
423 console.log(_myPlayer); |
|
424 } |
|
425 |
|
426 /* |
345 * Retour à la taille normale de la mosaïque. |
427 * Retour à la taille normale de la mosaïque. |
346 */ |
428 */ |
347 mosaic.prototype.unzoom = function() |
429 mosaic.prototype.unzoom = function() |
348 { |
430 { |
349 //Si on n'est pas en plein écran, on quitte. |
431 //Si on n'est pas en plein écran, on quitte. |
350 if(!this.fullscreen) |
432 if(!this.fullscreen) |
|
433 { |
351 return; |
434 return; |
|
435 } |
352 |
436 |
353 //On charge les attributs nécessaires aux calculs. |
437 //On charge les attributs nécessaires aux calculs. |
354 var sWidth = this.snapshotWidth, sHeight = this.snapshotHeight; |
438 var sWidth = this.snapshotWidth, sHeight = this.snapshotHeight; |
355 var mpWidth = this.width, mpHeight = this.height; |
439 var mpWidth = this.width, mpHeight = this.height; |
356 var mos = this; |
440 var mos = this; |
357 |
441 |
358 //On passe le snapshot sur lequel on a zoomé en LD. |
442 //On passe le snapshot sur lequel on a zoomé en SD. |
359 var zoomedImg = $('img', this.previousZoomedSN); |
443 var zoomedImg = $('img', this.previousZoomedSN); |
360 var src = zoomedImg.attr('src'); |
444 var src = zoomedImg.attr('src'); |
361 zoomedImg.attr('src', src.replace('snapshots/', 'snapshots-little/')); |
445 zoomedImg.attr('src', src.replace('snapshots/', 'snapshots-little/')); |
|
446 |
|
447 $('div').remove('.LdtPlayer'); |
|
448 $('body').append('<div class="LdtPlayer" id="LdtPlayer"></div>'); |
362 |
449 |
363 //On rend leur opacité aux snapshots. Qui ne sont alors plus grisés. |
450 //On rend leur opacité aux snapshots. Qui ne sont alors plus grisés. |
364 $('.snapshotDivs').animate( |
451 $('.snapshotDivs').animate( |
365 { |
452 { |
366 width: sWidth, |
453 width: sWidth, |
407 //Si le voisin du haut est sur la même colonne, on n'est pas sur la bordure du haut. |
494 //Si le voisin du haut est sur la même colonne, on n'est pas sur la bordure du haut. |
408 this.neighboursIds[2] = (currentLine > 0) ? (this.centerId - this.length) : -1; |
495 this.neighboursIds[2] = (currentLine > 0) ? (this.centerId - this.length) : -1; |
409 //Si le voisin du bas est sur la même colonne, on n'est pas sur la bordure du bas. |
496 //Si le voisin du bas est sur la même colonne, on n'est pas sur la bordure du bas. |
410 this.neighboursIds[3] = (currentLine < (this.imagesToShow / this.length)) ? (+this.centerId + this.length) : -1; |
497 this.neighboursIds[3] = (currentLine < (this.imagesToShow / this.length)) ? (+this.centerId + this.length) : -1; |
411 |
498 |
|
499 //ID du cadre voisin. |
|
500 var preId; |
|
501 |
412 for(var i = 0 ; i < this.neighboursIds.length ; i++) |
502 for(var i = 0 ; i < this.neighboursIds.length ; i++) |
413 { |
503 { |
414 if(this.neighboursIds[i] != -1) |
504 if(this.neighboursIds[i] != -1) |
415 { |
505 { |
|
506 preId = '#neighbourFrameBorder-' + this.neighboursIds[i]; |
416 //On permet le déplacement vers les voisins. |
507 //On permet le déplacement vers les voisins. |
417 $('#snapshotDiv-' + this.neighboursIds[i]).mouseenter(mos.changeNeighbourColor); |
508 // $('#snapshotDiv-' + this.neighboursIds[i] + ', ' + preId + '-left,' + preId + '-right,' + preId + '-up,' + preId + '-down').mouseenter(mos.selectNeighbour); |
|
509 $('#snapshotDiv-' + this.neighboursIds[i]).mouseenter(mos.selectNeighbour); |
418 } |
510 } |
419 } |
511 } |
420 } |
512 } |
421 |
513 |
422 /* |
514 /* |
423 * Change la coloration d'une bordure où on se positionne lors d'une vue en plein écran. |
515 * Change la coloration d'une bordure où on se positionne lors d'une vue en plein écran. |
424 */ |
516 */ |
425 mosaic.prototype.changeNeighbourColor = function() |
517 mosaic.prototype.selectNeighbour = function() |
426 { |
518 { |
427 ////TEST |
519 ////TEST |
428 //$('.test').append(mos.currentMode + " " + $(this).attr('id') + " " + 'snapshotDiv-' + mos.centerId + ','); |
520 //$('.test').append(mos.currentMode + " " + $(this).attr('id') + " " + 'snapshotDiv-' + mos.centerId + ','); |
429 |
521 |
430 //Si on est en mode VIDEO (plein écran) ET si le snapshot pointé est un voisin. |
522 //Si on est en mode VIDEO (plein écran) ET si le snapshot pointé est un voisin. |
431 if((mos.currentMode == 'VIDEO') && ($(this).attr('id') != 'snapshotDiv-' + mos.centerId)) |
523 if((mos.currentMode == 'VIDEO') && ($(this).attr('id') != 'snapshotDiv-' + mos.centerId)) |
432 { |
524 { |
433 //On crée le div cyan qui va être superposé au voisin. |
525 //On crée le cadre qui va être superposé au voisin. |
434 var cyanDiv = '<div class="cyan" id="cyan-' + $(this).attr('id') + '"></div>'; |
|
435 //On le colle au voisin. |
526 //On le colle au voisin. |
436 $('#mainPanel').append(cyanDiv); |
527 var tab = $(this).attr('id').split('-'); |
437 $('#cyan-' + $(this).attr('id')).css('top', $(this).position().top).css('left', $(this).position().left).css('width', $(this).width()).css('height', $(this).height()).css('margin', $(this).css('margin')).animate( |
528 var snapshotId = tab[1]; |
|
529 var neighbourFrame = ''; |
|
530 var marginValue = parseFloat($(this).css('margin')); |
|
531 |
|
532 neighbourFrame += '<div class="neighbourFrame" id="neighbourFrame-' + snapshotId + '"><div class="neighbourImgBg" id="neighbourImgBg-' + snapshotId + '"><div class="neighbourImg" id="neighbourImg-' + snapshotId + '"></div></div></div>'; |
|
533 |
|
534 $('#mainPanel').append(neighbourFrame); |
|
535 |
|
536 //On positionne le div de background juste au niveau du voisin. |
|
537 $('#neighbourFrame-' + snapshotId).css( |
|
538 { |
|
539 'top': (+$(this).position().top + marginValue), |
|
540 'left': (+$(this).position().left + marginValue), |
|
541 'width': $(this).width(), |
|
542 'height': $(this).height() |
|
543 }); |
|
544 //On positionne le div de background noir juste au niveau de l'image du voisin. |
|
545 $('#neighbourImgBg-' + snapshotId).css( |
|
546 { |
|
547 'top': marginValue, |
|
548 'left': marginValue, |
|
549 'width': $(this).width() - marginValue*2, |
|
550 'height': $(this).height() - marginValue*2, |
|
551 }); |
|
552 //On met par dessus le div de l'image clonée du voisin. |
|
553 $('#neighbourImg-' + snapshotId).css( |
|
554 { |
|
555 'top': 0, |
|
556 'left': 0, |
|
557 'width': $(this).width() - marginValue*2, |
|
558 'height': $(this).height() - marginValue*2, |
|
559 'background-image': 'url(' + $('img', $(this)).attr('src') + ')', |
|
560 'background-size': $(this).width() + 'px ' + $(this).height() + 'px', |
|
561 'background-position': -marginValue + 'px ' + -marginValue + 'px', |
|
562 'opacity': '0.4' |
|
563 }); |
|
564 |
|
565 var fId = '#neighbourFrame-' + snapshotId; |
|
566 |
|
567 $(fId).animate( |
438 { |
568 { |
439 //On le fait apparaître. |
569 //On le fait apparaître. |
440 opacity: '0.4' |
570 opacity: '1' |
441 }, timeNeighbourUnglowing, function() |
571 }, timeNeighbourGlowing, function() |
442 { |
572 { |
443 //On peut désormais se déplacer vers ce voisin. |
573 //On peut désormais se déplacer vers ce voisin. |
444 mos.canMoveToNeighbour = true; |
574 mos.canMoveToNeighbour = true; |
445 }).mouseleave(mos.unchangeNeighbourColor).click(mos.moveToNeighbour); |
575 }); |
|
576 //Lorsqu'on quitte un des snapshots (bien entendu le voisin en question), on retire le cadre. |
|
577 $(fId).mouseleave(mos.deselectNeighbour) |
|
578 //Si on clique sur le voisin ou son cadre, on passe au voisin suivant. |
|
579 $(fId).click(mos.moveToNeighbour); |
446 } |
580 } |
447 } |
581 } |
448 |
582 |
449 /* |
583 /* |
450 * Change la coloration d'une bordure quittée lors d'une vue en plein écran. |
584 * Change la coloration d'une bordure quittée lors d'une vue en plein écran. |
451 */ |
585 */ |
452 mosaic.prototype.unchangeNeighbourColor = function() |
586 mosaic.prototype.deselectNeighbour = function() |
453 { |
587 { |
454 ////TEST |
588 ////TEST |
455 //$('.test').append('un,'); |
589 //$('.test').append('un,'); |
456 |
590 |
457 //On ne peut plus se déplacer vers les voisins. |
591 //On ne peut plus se déplacer vers les voisins. |
458 mos.canMoveToNeighbour = false; |
592 mos.canMoveToNeighbour = false; |
459 |
593 |
|
594 //On récupère le voisin. |
|
595 var neighbourFrame = $(this); |
|
596 |
460 //Si on est en mode VIDEO. |
597 //Si on est en mode VIDEO. |
461 if(mos.currentMode == 'VIDEO') |
598 if(mos.currentMode == 'VIDEO') |
462 { |
599 { |
463 //On obtient le div de coloration superposé au voisin. |
|
464 var cyanDiv = $(this); |
|
465 |
|
466 //On le fait disparaître progressivement. |
600 //On le fait disparaître progressivement. |
467 $(this).animate( |
601 neighbourFrame.animate( |
468 { |
602 { |
469 opacity: '0' |
603 opacity: '0' |
470 }, timeNeighbourGlowing, function() |
604 }, timeNeighbourUnglowing, function() |
471 { |
605 { |
472 //Une fois invisible, on le supprime. |
606 //Une fois invisible, on le supprime. |
473 cyanDiv.remove(); |
607 neighbourFrame.remove(); |
474 }); |
608 }); |
475 } |
609 } |
476 } |
610 } |
477 |
611 |
478 /* |
612 /* |
480 */ |
614 */ |
481 mosaic.prototype.moveToNeighbour = function() |
615 mosaic.prototype.moveToNeighbour = function() |
482 { |
616 { |
483 //Si on ne peut pas se déplacer vers les voisins, on quitte. |
617 //Si on ne peut pas se déplacer vers les voisins, on quitte. |
484 if(!mos.canMoveToNeighbour) |
618 if(!mos.canMoveToNeighbour) |
|
619 { |
485 return; |
620 return; |
|
621 } |
486 |
622 |
487 //On obtient l'ID de destination. |
623 //On obtient l'ID de destination. |
488 var tab = $(this).attr('id').split('-'); |
624 var tab = $(this).attr('id').split('-'); |
489 var destinationId = tab[2]; |
625 var destinationId = tab[1]; |
490 |
626 |
491 //On charge les attributs nécessaires aux calculs. |
627 //On charge les attributs nécessaires aux calculs. |
492 var MPCurrentTop = $('#mainPanel').position().top, MPCurrentLeft = $('#mainPanel').position().left; |
628 var MPCurrentTop = $('#mainPanel').position().top, MPCurrentLeft = $('#mainPanel').position().left; |
493 var divideCoeffTop = Math.floor(destinationId / mos.length) == 0 ? 1 : Math.floor(destinationId / mos.length); |
629 var divideCoeffTop = Math.floor(destinationId / mos.length) == 0 ? 1 : Math.floor(destinationId / mos.length); |
494 var divideCoeffLeft = destinationId % mos.length == 0 ? 1 : destinationId % mos.length; |
630 var divideCoeffLeft = destinationId % mos.length == 0 ? 1 : destinationId % mos.length; |
495 var cyanTop = $(this).position().top, cyanLeft = $(this).position().left; |
631 var neighbourFrameTop = $('#snapshotDiv-' + destinationId).position().top, neighbourFrameLeft = $('#snapshotDiv-' + destinationId).position().left; |
496 |
632 |
497 //On définit pour le déplacement vertical s'il est nécessaire de se déplacer en haut ou en bas. |
633 //On définit pour le déplacement vertical s'il est nécessaire de se déplacer en haut ou en bas. |
498 if(mos.previousZoomedSN.position().top > cyanTop) |
634 if(mos.previousZoomedSN.position().top > neighbourFrameTop) |
499 MPCurrentTop += Math.abs(cyanTop - mos.previousZoomedSN.position().top); |
635 MPCurrentTop += Math.abs(neighbourFrameTop - mos.previousZoomedSN.position().top); |
500 else if(mos.previousZoomedSN.position().top < cyanTop) |
636 else if(mos.previousZoomedSN.position().top < neighbourFrameTop) |
501 MPCurrentTop -= Math.abs(cyanTop - mos.previousZoomedSN.position().top); |
637 MPCurrentTop -= Math.abs(neighbourFrameTop - mos.previousZoomedSN.position().top); |
502 //On définit pour le déplacement horizontal s'il est nécessaire de se déplacer à gauche ou à droite. |
638 //On définit pour le déplacement horizontal s'il est nécessaire de se déplacer à gauche ou à droite. |
503 if(mos.previousZoomedSN.position().left > cyanLeft) |
639 if(mos.previousZoomedSN.position().left > neighbourFrameLeft) |
504 MPCurrentLeft += Math.abs(cyanLeft - mos.previousZoomedSN.position().left); |
640 MPCurrentLeft += Math.abs(neighbourFrameLeft - mos.previousZoomedSN.position().left); |
505 else if(mos.previousZoomedSN.position().left < cyanLeft) |
641 else if(mos.previousZoomedSN.position().left < neighbourFrameLeft) |
506 MPCurrentLeft -= Math.abs(cyanLeft - mos.previousZoomedSN.position().left); |
642 MPCurrentLeft -= Math.abs(neighbourFrameLeft - mos.previousZoomedSN.position().left); |
507 |
643 |
508 //On passe le snapshot de destination en HD. |
644 //On passe le snapshot de destination en HD. |
509 var destinationImg = $('#snapshot-' + destinationId); |
645 var destinationImg = $('#snapshot-' + destinationId); |
510 var destinationImgSrc = destinationImg.attr('src'); |
646 var destinationImgSrc = destinationImg.attr('src'); |
511 destinationImg.attr('src', destinationImgSrc.replace('snapshots-little/', 'snapshots/')); |
647 destinationImg.attr('src', destinationImgSrc.replace('snapshots-little/', 'snapshots/')); |
512 |
648 |
513 //On passe l'ancien snapshot en LD. |
649 //On passe l'ancien snapshot en SD. |
514 var currentImgSrc = $('img', mos.previousZoomedSN).attr('src'); |
650 var currentImgSrc = $('img', mos.previousZoomedSN).attr('src'); |
515 $('img', mos.previousZoomedSN).attr('src', currentImgSrc.replace('snapshots/', 'snapshots-little/')); |
651 $('img', mos.previousZoomedSN).attr('src', currentImgSrc.replace('snapshots/', 'snapshots-little/')); |
516 |
652 |
517 //On obtient l'ID du div de coloration du snapshot vers lequel on se déplace afin de le supprimer. |
653 //On obtient l'ID du div de coloration du snapshot vers lequel on se déplace afin de le supprimer. |
518 var cyan = $(this); |
654 var neighbourFrame = $(this); |
519 var tab = cyan.attr('id').split('-'); |
655 var tab = neighbourFrame.attr('id').split('-'); |
520 mos.centerId = tab[2]; |
656 mos.centerId = tab[1]; |
521 $(this).css('opacity', '0'); |
657 $(this).css('opacity', '0'); |
522 cyan.remove(); |
658 neighbourFrame.remove(); |
523 |
659 |
|
660 $('div').remove('.LdtPlayer'); |
|
661 $('body').append('<div class="LdtPlayer" id="LdtPlayer"></div>'); |
|
662 |
524 //On grise le snapshot qu'on vient de quitter. |
663 //On grise le snapshot qu'on vient de quitter. |
525 mos.previousZoomedSN.animate( |
664 mos.previousZoomedSN.animate( |
526 { |
665 { |
527 opacity: '0.4' |
666 opacity: '0.4' |
528 }); |
667 }); |