front_idill/src/mosaic/js/mosaic.js
changeset 31 2c7fc855eba8
parent 30 45c889eae324
child 32 4003f84cd349
equal deleted inserted replaced
30:45c889eae324 31:2c7fc855eba8
   141  * 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.
   141  * 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.
   142  */
   142  */
   143 mosaic.prototype.preZoom = function(snapshot)
   143 mosaic.prototype.preZoom = function(snapshot)
   144 {
   144 {
   145     if(this.fullscreen)
   145     if(this.fullscreen)
       
   146 	{
   146         return;
   147         return;
       
   148 	}
   147     //Mosaïque.
   149     //Mosaïque.
   148     var mosaic = this;
   150     var mosaic = this;
   149     //Dimensions de la mosaïque.
   151     //Dimensions de la mosaïque.
   150     var h = this.height, w = this.width;
   152     var h = this.height, w = this.width;
   151     //Longueur en images, nombre d'images et taille de bordure de la mosaïque.
   153     //Longueur en images, nombre d'images et taille de bordure de la mosaïque.
   158     //ID de l'image actuelle.
   160     //ID de l'image actuelle.
   159     var currentId = $('img', snapshot).attr('id');
   161     var currentId = $('img', snapshot).attr('id');
   160     
   162     
   161     //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.
   163     //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.
   162     if(this.zoomed)
   164     if(this.zoomed)
       
   165 	{
   163         if($('#preZoomContainer-' + currentId) != $(this) && this.previousZoomedSN != '' && this.previousId != '')
   166         if($('#preZoomContainer-' + currentId) != $(this) && this.previousZoomedSN != '' && this.previousId != '')
       
   167 		{
   164             this.preUnzoom();
   168             this.preUnzoom();
       
   169 		}
   165         else
   170         else
       
   171 		{
   166             return;
   172             return;
       
   173 		}
       
   174 	}
   167     
   175     
   168     //On indique qu'on a zoomé et on spécifie le snapshot sur lequel on a zoomé.
   176     //On indique qu'on a zoomé et on spécifie le snapshot sur lequel on a zoomé.
   169     this.zoomed = true;
   177     this.zoomed = true;
   170     this.previousZoomedSN = snapshot;
   178     this.previousZoomedSN = snapshot;
   171     this.previousId = currentId;
   179     this.previousId = currentId;
   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)
   232     
   248     
   233     //Si on clique sur le snapshot prézoomé, on enclenche un zoom total sur ce snapshot.
   249     //Si on clique sur le snapshot prézoomé, on enclenche un zoom total sur ce snapshot.
   234     $('#prezoomContainer-' + currentId).click(function ()
   250     $('#prezoomContainer-' + currentId).click(function ()
   235     {
   251     {
   236         if(this.previousZoomedSN != '')
   252         if(this.previousZoomedSN != '')
       
   253 		{
   237             mosaic.zoom();
   254             mosaic.zoom();
       
   255 		}
   238     });
   256     });
   239 }
   257 }
   240 
   258 
   241 /*
   259 /*
   242  * 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é.
   260  * 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é.
   243  */
   261  */
   244 mosaic.prototype.preUnzoom = function()
   262 mosaic.prototype.preUnzoom = function()
   245 {
   263 {
   246     //Si on n'a pas zoomé, on quitte la fonction.
   264     //Si on n'a pas zoomé, on quitte la fonction.
   247     if(!this.zoomed)
   265     if(!this.zoomed)
       
   266 	{
   248         return;
   267         return;
       
   268 	}
   249     
   269     
   250     //On spécifie la marge afin de centrer le prédézoom.
   270     //On spécifie la marge afin de centrer le prédézoom.
   251     var margin = this.marginWidth;
   271     var margin = this.marginWidth;
   252     //ID du snapshot précédemment pointé.
   272     //ID du snapshot précédemment pointé.
   253     var id = this.previousId;
   273     var id = this.previousId;
   278 {
   298 {
   279     var mos = this;
   299     var mos = this;
   280     
   300     
   281     //Si la mosaïque est en pleine écran, pas la peine de zoomer.
   301     //Si la mosaïque est en pleine écran, pas la peine de zoomer.
   282     if(this.fullscreen)
   302     if(this.fullscreen)
       
   303 	{
   283         return;
   304         return;
       
   305 	}
   284     
   306     
   285     //On prend les attributs nécessaires au calculs.
   307     //On prend les attributs nécessaires au calculs.
   286     var margin = this.marginWidth, len = this.length, imgs = this.imagesToShow;
   308     var margin = this.marginWidth, len = this.length, imgs = this.imagesToShow;
   287     var initMPWidth = this.previousZoomedSN.width() * len + margin*len, initMPHeight = this.previousZoomedSN.height() * (imgs / len) + margin*(imgs / len);
   309     var initMPWidth = this.previousZoomedSN.width() * len + margin*len, initMPHeight = this.previousZoomedSN.height() * (imgs / len) + margin*(imgs / len);
   288     var newMPWidth = initMPWidth * len + this.zoomedMargin * (len), newMPHeight = initMPHeight * (imgs / len) + this.zoomedMargin * ((imgs / len));
   310     var newMPWidth = initMPWidth * len + this.zoomedMargin * (len), newMPHeight = initMPHeight * (imgs / len) + this.zoomedMargin * ((imgs / len));
   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,
   381         mos.fullscreen = false;
   468         mos.fullscreen = false;
   382         mos.canMoveToNeighbour = false;
   469         mos.canMoveToNeighbour = false;
   383         //On revient en mode MOSAIC.
   470         //On revient en mode MOSAIC.
   384         mos.currentMode = 'MOSAIC';
   471         mos.currentMode = 'MOSAIC';
   385         //On ne permet plus le déplacement vers les voisins.
   472         //On ne permet plus le déplacement vers les voisins.
   386         $('.snapshotDivs').unbind('mouseenter', mos.changeNeighbourColor);
   473         $('.snapshotDivs').unbind('mouseenter', mos.selectNeighbour);
   387     });
   474     });
   388 }
   475 }
   389 
   476 
   390 /*
   477 /*
   391  * Affecte les listeners mouseenter aux voisins lors d'une vue en plein écran.
   478  * Affecte les listeners mouseenter aux voisins lors d'une vue en plein écran.
   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     });
   539         {
   678         {
   540             opacity: '1'
   679             opacity: '1'
   541         }, mos.zoomTime, function()
   680         }, mos.zoomTime, function()
   542         {
   681         {
   543             //On recharge les voisins.
   682             //On recharge les voisins.
   544             $('.snapshotDivs').unbind('mouseenter', mos.changeNeighbourColor);
   683             $('.snapshotDivs').unbind('mouseenter', mos.selectNeighbour);
   545             mos.previousZoomedSN = $('#snapshotDiv-' + mos.centerId);
   684             mos.previousZoomedSN = $('#snapshotDiv-' + mos.centerId);
   546             mos.listenToNeighbours();
   685             mos.listenToNeighbours();
       
   686 			
       
   687 			mos.loadPlayer((destinationImg.position().top + MPCurrentTop + mos.MPTop_margin), (destinationImg.position().left + MPCurrentLeft), destinationImg.width(), destinationImg.height());
   547         });
   688         });
   548     });
   689     });
   549 }
   690 }
   550 
   691 
   551 /*
   692 /*