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