front_idill/src/mosaic/js/mosaic.js
author bastiena
Fri, 11 May 2012 11:04:06 +0200
changeset 31 2c7fc855eba8
parent 30 45c889eae324
child 32 4003f84cd349
permissions -rw-r--r--
FRONT IDILL : Player implemented in the mosaic.
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
 */
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    25
function mosaic(len, imgToShow, zoomPercentage, prezoomPercentage, zoomedMargin)
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.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    33
        this.imagesToShow = imgToShow;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    34
        //Tableaux des urls des vidéos, des snapshots et de leur position dans la mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    35
        this.urls = [];
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    36
        this.imgs = [];
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    37
        this.ids = [];
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    38
        //Dimensions de la mosaïque en pixels.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    39
        this.width;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    40
        this.height;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    41
        //Dimensions d'un snapshot en pixels.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    42
        this.snapshotWidth;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    43
        this.snapshotHeight;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    44
        //Espacement entre les snapshots en pixels.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    45
        this.marginWidth;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    46
        
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    47
        //Temps d'intéractions/d'animations.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    48
        this.preZoomTime;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    49
        this.preUnzoomTime;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    50
        this.zoomTime;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    51
        this.unzoomTime;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    52
        this.timeNeighbourGlowing;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    53
        this.timeNeighbourUnglowing;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    54
        this.timeMovingToNeighbour;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    55
        
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    56
        //Booléens permettant ou non certaines intéractions selon le contexte.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    57
        this.zoomed;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    58
        this.fullscreen;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    59
        this.canMoveToNeighbour;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    60
        
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    61
        //Mode actuel.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    62
        this.currentMode;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    63
        //Snapshot sur lequel on a zoomé.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    64
        this.previousZoomedSN;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    65
        //Son ID.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    66
        this.previousId;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    67
        //Largeur de la marge pour le centrage vertical de la mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    68
        this.MPTop_margin;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    69
        this.top_margin;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    70
        //Pourcentage d'agrandissement lors d'un prézoom et d'un zoom.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    71
        this.prezoomPercentage = prezoomPercentage;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    72
        this.zoomPercentage = zoomPercentage;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    73
        //Espacement des snapshots après un zoom.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    74
        this.zoomedMargin = zoomedMargin;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    75
        //Mosaïque locale.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    76
        this.localMos;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    77
        //Position des voisins lors d'un zoom.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    78
        this.neighboursIds = [];
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    79
        //ID du snapshot du milieu lors d'un zoom.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    80
        this.centerId;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    81
    }
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    82
    else
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    83
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    84
        //Affiche un message d'erreur.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    85
    }
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    86
}
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    87
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    88
/*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    89
 * Méthode d'affichage de la mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    90
 * Génère une matrice de imgs.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    91
 */
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    92
mosaic.prototype.createMosaic = function()
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    93
{
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    94
    this.previousZoomedSN = '';
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    95
    this.previousPrezoomDiv = '';
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    96
    this.fullscreen = false;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    97
    this.canMoveToNeighbour = false;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    98
    var str = '';
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    99
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   100
    if(this.imgs.length >= this.imagesToShow)
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   101
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   102
        for(var i = 0 ; i < this.imagesToShow ; i++)
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   103
        {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   104
            //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
   105
            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
   106
        }
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   107
    }
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   108
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   109
    return str;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   110
}
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   111
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   112
/*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   113
 * Permet de raffraichir la mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   114
 */
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   115
mosaic.prototype.loadMosaic = function(imgsTab)
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   116
{
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   117
    //On affecte les chemins vers les images à la mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   118
    this.imgs = imgsTab;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   119
    this.previousZoomedSN;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   120
    //this.width = 
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   121
    //On met à jour la mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   122
    $('#mainPanel').html(this.createMosaic());
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   123
    //On récupère la taille des bordures.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   124
    this.marginWidth = $('.snapshotDivs').css('margin-bottom');
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   125
    this.marginWidth = parseFloat(mos.marginWidth)*2;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   126
    //On calcule la taille des divs contenant les snapshots.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   127
    this.width = $('#mainPanel').innerWidth();
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   128
    //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
   129
    this.snapshotWidth = this.width / this.length - this.marginWidth;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   130
    this.snapshotHeight = this.snapshotWidth*9/16;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   131
    $('.snapshotDivs').css('width', this.snapshotWidth).css('height', this.snapshotHeight).css('margin', this.marginWidth/2);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   132
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   133
    this.height = $('#mainPanel').innerHeight();
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   134
    //On centre verticalement la mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   135
    this.MPTop_margin = ($(document).height() - $('#mainPanel').height())/2;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   136
    $('#mainPanel').css('margin-top', this.MPTop_margin).css('margin-bottom', this.MPTop_margin);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   137
}
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   138
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   139
/*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   140
 * 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
   141
 * Après ce laps de temps, l'image zoom complétement et il n'est plus possible de sélectionner une autre image par pointage.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   142
 */
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   143
mosaic.prototype.preZoom = function(snapshot)
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   144
{
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   145
    if(this.fullscreen)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   146
	{
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   147
        return;
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   148
	}
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   149
    //Mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   150
    var mosaic = this;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   151
    //Dimensions de la mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   152
    var h = this.height, w = this.width;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   153
    //Longueur en images, nombre d'images et taille de bordure de la mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   154
    var len = this.length, imgs = this.imagesToShow, margin = this.marginWidth;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   155
    //Dimensions et position d'un snapshot dans la mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   156
    var snHeight = this.snapshotHeight, snWidth = this.snapshotWidth;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   157
    var sTop = snapshot.position().top, sLeft = snapshot.position().left;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   158
    var prezoomPercentage = this.prezoomPercentage;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   159
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   160
    //ID de l'image actuelle.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   161
    var currentId = $('img', snapshot).attr('id');
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   162
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   163
    //Si un zoom est déjà en cours, on ne zoom sur rien d'autre en attendant que ce snapshot ai dézoomé en cas de mouseleave.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   164
    if(this.zoomed)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   165
	{
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   166
        if($('#preZoomContainer-' + currentId) != $(this) && this.previousZoomedSN != '' && this.previousId != '')
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   167
		{
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   168
            this.preUnzoom();
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   169
		}
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   170
        else
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   171
		{
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   172
            return;
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   173
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   174
	}
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   175
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   176
    //On indique qu'on a zoomé et on spécifie le snapshot sur lequel on a zoomé.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   177
    this.zoomed = true;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   178
    this.previousZoomedSN = snapshot;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   179
    this.previousId = currentId;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   180
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   181
    //On récupère les attributs de l'image.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   182
    var fakeImg = $('img', snapshot);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   183
    //On forme la balise de la fausse image et on passe son url pour les grands snapshots.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   184
    fakeImg = '<img id="fake-' + currentId + '" class="snapshots" src="' + fakeImg.attr('src').replace('-little/', '/') + '" />';
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   185
    //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
   186
    var fakeSnapshot = '<div id="prezoomContainer-' + currentId + '" class="prezoomContainers"><div id="prezoomSnapshot-' + currentId + '" class="snapshotDivs">' + fakeImg + '</div></div>';
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   187
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   188
    //On l'ajoute à la mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   189
    $('#mainPanel').append(fakeSnapshot);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   190
    //On modifie ses attributs.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   191
    $('#fake-' + currentId).load(function()
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   192
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   193
        $('#prezoomContainer-' + currentId).css('display', 'block');
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   194
        $('#prezoomContainer-' + currentId).css('top', sTop).css('left', sLeft).css('width', (snWidth + margin)).css('height', (snHeight + margin));
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   195
        $('#prezoomSnapshot-' + currentId).css('width', (snWidth)).css('height', (snHeight));
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   196
        
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   197
        //Dimensions et coordonnées initiales du div sur lequel on zoom.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   198
        var initialDivWidth = $('#prezoomContainer-' + currentId).width(), initialDivHeight = $('#prezoomContainer-' + currentId).height();
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   199
        var initialDivTop = $('#prezoomContainer-' + currentId).position().top, initialDivLeft = $('#prezoomContainer-' + currentId).position().left;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   200
        //Dimensions et coordonnées finales du div.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   201
        var finalDivWidth = initialDivWidth * (prezoomPercentage+1), diffWidth = finalDivWidth - initialDivWidth, finalDivHeight = initialDivHeight + diffWidth;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   202
        var finalDivTop = (initialDivTop - (finalDivHeight - snHeight)/2), finalDivLeft = (initialDivLeft - (finalDivWidth - snWidth)/2);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   203
        
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   204
        //CAS PARTICULIER pour la position du snapshot zoomé : les bordures.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   205
        if(finalDivTop < 0)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   206
		{
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   207
            finalDivTop = -margin;
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   208
		}
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   209
        if(finalDivTop + finalDivHeight > h)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   210
		{
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   211
            finalDivTop = h - finalDivHeight;
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   212
		}
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   213
        if(finalDivLeft < 0)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   214
		{
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   215
            finalDivLeft = 0;
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   216
		}
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   217
        if(finalDivLeft + finalDivWidth + margin*2 > w)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   218
		{
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   219
            finalDivLeft = w - finalDivWidth - margin*2;
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   220
		}
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   221
        
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   222
        ////Code de debug.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   223
        ////CAUTION////
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   224
        /*var red = '<div id="red"></div>';
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   225
        if($('#red') != null || $('#red') != undefined)
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   226
            $('body').append(red);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   227
        $('#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
   228
        $('#red').css('top', finalDivTop).css('left', finalDivLeft).css('width', finalDivWidth).css('height', finalDivHeight);*/
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   229
        //alert("initial : " + initialDivWidth + " " + initialDivHeight + " ; final : " + finalDivWidth + " " + finalDivHeight);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   230
        ////CAUTION////
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   231
        
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   232
        //On prézoom le div en le centrant sur le milieu du snapshot pointé.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   233
        $('#prezoomSnapshot-' + currentId).animate(
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   234
        {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   235
            width: finalDivWidth + margin,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   236
            height: finalDivHeight - margin*2,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   237
            top: finalDivTop + margin,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   238
            left: finalDivLeft + margin
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   239
        }, this.preZoomTime);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   240
        $('#prezoomContainer-' + currentId).animate(
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   241
        {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   242
            width: finalDivWidth + margin*2,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   243
            height: finalDivHeight - margin,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   244
            top: finalDivTop + margin,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   245
            left: finalDivLeft
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   246
        }, this.preZoomTime);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   247
    });
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   248
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   249
    //Si on clique sur le snapshot prézoomé, on enclenche un zoom total sur ce snapshot.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   250
    $('#prezoomContainer-' + currentId).click(function ()
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   251
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   252
        if(this.previousZoomedSN != '')
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   253
		{
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   254
            mosaic.zoom();
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   255
		}
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   256
    });
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   257
}
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   258
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   259
/*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   260
 * Dézoome sur la position de l'image. Il est à noter que ce dézoome diffère du dézoom global dans la mesure où celui-ci ne concerne que l'image sur laquelle on a zoomé.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   261
 */
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   262
mosaic.prototype.preUnzoom = function()
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   263
{
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   264
    //Si on n'a pas zoomé, on quitte la fonction.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   265
    if(!this.zoomed)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   266
	{
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   267
        return;
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   268
	}
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   269
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   270
    //On spécifie la marge afin de centrer le prédézoom.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   271
    var margin = this.marginWidth;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   272
    //ID du snapshot précédemment pointé.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   273
    var id = this.previousId;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   274
    //On ne zoom plus.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   275
    this.zoomed = false;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   276
    //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
   277
    $('#prezoomSnapshot-' + id).animate(
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   278
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   279
        width: this.snapshotWidth,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   280
        height: this.snapshotHeight,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   281
        top: this.previousZoomedSN.position().top,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   282
        left: this.previousZoomedSN.position().left
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   283
    }, this.preUnzoomTime);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   284
    $('#prezoomContainer-' + id).animate(
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   285
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   286
        width: this.snapshotWidth + margin,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   287
        height: this.snapshotHeight + margin,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   288
        top: this.previousZoomedSN.position().top,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   289
        left: this.previousZoomedSN.position().left
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   290
    }, this.preUnzoomTime, function(){ $(this).remove(); this.zoomed = false; });
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   291
}
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   292
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   293
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   294
/*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   295
 * Zoom d'un snapshot en plein écran.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   296
 */
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   297
mosaic.prototype.zoom = function()
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   298
{
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   299
    var mos = this;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   300
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   301
    //Si la mosaïque est en pleine écran, pas la peine de zoomer.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   302
    if(this.fullscreen)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   303
	{
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   304
        return;
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   305
	}
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   306
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   307
    //On prend les attributs nécessaires au calculs.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   308
    var margin = this.marginWidth, len = this.length, imgs = this.imagesToShow;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   309
    var initMPWidth = this.previousZoomedSN.width() * len + margin*len, initMPHeight = this.previousZoomedSN.height() * (imgs / len) + margin*(imgs / len);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   310
    var newMPWidth = initMPWidth * len + this.zoomedMargin * (len), newMPHeight = initMPHeight * (imgs / len) + this.zoomedMargin * ((imgs / len));
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   311
    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
   312
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   313
    //Dimensions et coordonnées initiales du div sur lequel on zoom.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   314
    var initialDivWidth = this.previousZoomedSN.width(), initialDivHeight = this.previousZoomedSN.height();
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   315
    var initialDivTop = this.previousZoomedSN.position().top, initialDivLeft = this.previousZoomedSN.position().left;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   316
    //Dimensions et coordonnées finales du div.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   317
    var finalDivWidth = initialDivWidth * (this.zoomPercentage+1), finalDivHeight = initialDivHeight * (this.zoomPercentage+1);
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   318
    var newZoomTop = -this.previousZoomedSN.position().top*(newPreMPHeight/initMPHeight) - this.zoomedMargin/2 + (initMPHeight - initMPHeight * this.zoomPercentage)/2, newZoomLeft = -this.previousZoomedSN.position().left*(newPreMPWidth/initMPWidth) - this.zoomedMargin/2 + (initMPWidth - initMPWidth * this.zoomPercentage)/2;
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   319
    var newSnWidth = initMPWidth * this.zoomPercentage, newSnHeight = initMPHeight * this.zoomPercentage;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   320
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   321
    this.preUnzoom(this);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   322
    /*SINGULARITE*/
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   323
    this.fullscreen = true;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   324
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   325
    //On passe l'image du snapshot pointé en HD.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   326
    var zoomedImg = $('img', this.previousZoomedSN);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   327
    var src = zoomedImg.attr('src');
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   328
    zoomedImg.attr('src', src.replace('-little/', '/'));
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   329
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   330
    //On récupère son ID.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   331
    var tab, zoomedImgId;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   332
    tab = mos.previousId.split('-');
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   333
    zoomedImgId = tab[1];
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   334
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   335
    //Les snapshots baissent alors en opacité, donnant l'impression qu'ils sont grisés.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   336
    $('.snapshotDivs').animate(
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   337
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   338
        width: newSnWidth,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   339
        height: newSnHeight,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   340
        margin: this.zoomedMargin/2 + 'px',
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   341
        opacity: '0.4'
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   342
    }, this.zoomTime);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   343
    //Le snapshot du milieu revient à une opacité optimale, ce qui attire l'attention de l'utilisateur.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   344
    $(this.previousZoomedSN).animate(
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   345
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   346
        opacity: '1'
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   347
    }, this.zoomTime);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   348
    //On zoome sur la mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   349
    $('#mainPanel').animate(
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   350
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   351
        width: newPreMPWidth,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   352
        height: newPreMPHeight,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   353
        top: newZoomTop,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   354
        left: newZoomLeft
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   355
    }, this.zoomTime, function()
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   356
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   357
        //On charge les interactions avec les voisins.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   358
        mos.centerId = zoomedImgId;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   359
        mos.listenToNeighbours();
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   360
        mos.currentMode = 'VIDEO';
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   361
		
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   362
		console.log('h : ' + -newZoomLeft + " " + zoomedImg.position().left);
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   363
		
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   364
		mos.loadPlayer((zoomedImg.position().top + newZoomTop + mos.MPTop_margin), (zoomedImg.position().left + newZoomLeft), newSnWidth + 1, newSnHeight + 1);
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   365
		
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   366
        /*mos.unload();
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   367
        mos.localMos.loadLocalMosaic(newZoomTop, newZoomLeft, newSnWidth, newSnHeight, mos.imgs, tab[1]);*/
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   368
    });
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   369
}
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   370
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   371
/*
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   372
 * Chargement du player basé sur le metadataplayer.
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   373
*/
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   374
mosaic.prototype.loadPlayer = function(newZoomTop, newZoomLeft, newSnWidth, newSnHeight)
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   375
{
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   376
	//On configure les options de lancement.
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   377
	IriSP.libFiles.defaultDir = "../lib/";
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   378
	IriSP.widgetsDir = "./player/metadataplayer/"
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   379
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   380
	console.log(newZoomTop + " " + newZoomLeft);
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   381
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   382
	var _metadata = {
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   383
		url: 'http://ldt.iri.centrepompidou.fr/ldtplatform/ldt/cljson/id/7c912bce-66b8-11e1-80f6-00145ea4a2be?callback=?',
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   384
		format: 'ldt'
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   385
	};
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   386
	var _config = {
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   387
		gui: {
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   388
			width: newSnWidth,
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   389
			height: newSnHeight,
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   390
			container: 'LdtPlayer',
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   391
			default_options: {
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   392
				metadata: _metadata
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   393
			},
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   394
			css:'./player/metadataplayer/LdtPlayer-core.css',
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   395
			widgets: [
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   396
				{
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   397
					type: "Timeline"
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   398
				}
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   399
			]
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   400
		},
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   401
		player:{
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   402
			type: 'html5', // player type
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   403
			video: 'http://media.iri.centrepompidou.fr/video/ldtplatform/body_trail_cctv.mp4',
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   404
			live: true,
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   405
			height: newSnHeight,
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   406
			width: newSnWidth,
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   407
			autostart: true
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   408
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   409
	};
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   410
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   411
	//On positionne le player.
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   412
	$('.LdtPlayer').css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   413
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   414
		//display: 'none',
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   415
		position: 'absolute',
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   416
		'background-color': '#000000',
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   417
		top: newZoomTop,
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   418
		left: newZoomLeft
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   419
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   420
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   421
	//On démarre le player.
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   422
	var _myPlayer = new IriSP.Metadataplayer(_config, _metadata);
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   423
	console.log(_myPlayer);
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   424
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   425
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   426
/*
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   427
 * Retour à la taille normale de la mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   428
 */
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   429
mosaic.prototype.unzoom = function()
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   430
{
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   431
    //Si on n'est pas en plein écran, on quitte.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   432
    if(!this.fullscreen)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   433
	{
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   434
        return;
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   435
	}
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   436
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   437
    //On charge les attributs nécessaires aux calculs.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   438
    var sWidth = this.snapshotWidth, sHeight = this.snapshotHeight;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   439
    var mpWidth = this.width, mpHeight = this.height;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   440
    var mos = this;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   441
    
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   442
    //On passe le snapshot sur lequel on a zoomé en SD.
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   443
    var zoomedImg = $('img', this.previousZoomedSN);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   444
    var src = zoomedImg.attr('src');
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   445
    zoomedImg.attr('src', src.replace('snapshots/', 'snapshots-little/'));
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   446
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   447
	$('div').remove('.LdtPlayer');
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   448
	$('body').append('<div class="LdtPlayer" id="LdtPlayer"></div>');
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   449
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   450
    //On rend leur opacité aux snapshots. Qui ne sont alors plus grisés.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   451
    $('.snapshotDivs').animate(
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   452
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   453
        width: sWidth,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   454
        height: sHeight,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   455
        margin: this.marginWidth/2 + 'px',
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   456
        opacity: '1'
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   457
    }, this.unzoomTime);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   458
    //On dézoom sur la mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   459
    $('#mainPanel').animate(
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   460
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   461
        width: mpWidth,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   462
        height: mpHeight,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   463
        top: '0px',
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   464
        left: '0px'
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   465
    }, this.unzoomTime, function()
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   466
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   467
        //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
   468
        mos.fullscreen = false;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   469
        mos.canMoveToNeighbour = false;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   470
        //On revient en mode MOSAIC.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   471
        mos.currentMode = 'MOSAIC';
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   472
        //On ne permet plus le déplacement vers les voisins.
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   473
        $('.snapshotDivs').unbind('mouseenter', mos.selectNeighbour);
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   474
    });
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   475
}
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   476
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   477
/*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   478
 * Affecte les listeners mouseenter aux voisins lors d'une vue en plein écran.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   479
 */
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   480
mosaic.prototype.listenToNeighbours = function()
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   481
{
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   482
    ////TEST
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   483
    //$('.test').empty();
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   484
    this.canMoveToNeighbour = false;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   485
    var currentLine = Math.floor(this.centerId / this.length), currentColumn = this.centerId % this.length;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   486
    var zoomedImg = $('img', this.previousZoomedSN);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   487
    var mos = this;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   488
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   489
    //On cherche l'ID des voisins.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   490
    //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
   491
    this.neighboursIds[0] = (currentColumn > 0) ? (this.centerId - 1) : -1;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   492
    //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
   493
    this.neighboursIds[1] = (currentColumn < this.length) ? (+this.centerId + 1) : -1;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   494
    //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
   495
    this.neighboursIds[2] = (currentLine > 0) ? (this.centerId - this.length) : -1;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   496
    //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
   497
    this.neighboursIds[3] = (currentLine < (this.imagesToShow / this.length)) ? (+this.centerId + this.length) : -1;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   498
    
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   499
	//ID du cadre voisin.
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   500
	var preId;
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   501
	
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   502
    for(var i = 0 ; i < this.neighboursIds.length ; i++)
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   503
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   504
        if(this.neighboursIds[i] != -1)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   505
        {
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   506
			preId = '#neighbourFrameBorder-' + this.neighboursIds[i];
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   507
            //On permet le déplacement vers les voisins.
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   508
            // $('#snapshotDiv-' + this.neighboursIds[i] + ', ' + preId + '-left,' + preId + '-right,' + preId + '-up,' + preId + '-down').mouseenter(mos.selectNeighbour);
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   509
            $('#snapshotDiv-' + this.neighboursIds[i]).mouseenter(mos.selectNeighbour);
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   510
        }
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   511
    }
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   512
}
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   513
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   514
/*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   515
 * Change la coloration d'une bordure où on se positionne lors d'une vue en plein écran.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   516
 */
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   517
mosaic.prototype.selectNeighbour = function()
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   518
{
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   519
    ////TEST
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   520
    //$('.test').append(mos.currentMode + " " + $(this).attr('id') + " " + 'snapshotDiv-' + mos.centerId + ',');
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   521
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   522
    //Si on est en mode VIDEO (plein écran) ET si le snapshot pointé est un voisin.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   523
    if((mos.currentMode == 'VIDEO') && ($(this).attr('id') != 'snapshotDiv-' + mos.centerId))
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   524
    {
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   525
        //On crée le cadre qui va être superposé au voisin.
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   526
        //On le colle au voisin.
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   527
		var tab = $(this).attr('id').split('-');
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   528
		var snapshotId = tab[1];
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   529
        var neighbourFrame = '';
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   530
		var marginValue = parseFloat($(this).css('margin'));
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   531
		
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   532
		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
   533
		
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   534
        $('#mainPanel').append(neighbourFrame);
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   535
		
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   536
		//On positionne le div de background juste au niveau du voisin.
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   537
        $('#neighbourFrame-' + snapshotId).css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   538
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   539
			'top': (+$(this).position().top + marginValue),
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   540
			'left': (+$(this).position().left + marginValue),
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   541
			'width': $(this).width(),
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   542
			'height': $(this).height()
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   543
		});
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   544
		//On positionne le div de background noir juste au niveau de l'image du voisin.
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   545
        $('#neighbourImgBg-' + snapshotId).css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   546
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   547
			'top': marginValue,
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   548
			'left': marginValue,
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   549
			'width': $(this).width() - marginValue*2,
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   550
			'height': $(this).height() - marginValue*2,
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   551
		});
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   552
		//On met par dessus le div de l'image clonée du voisin.
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   553
		$('#neighbourImg-' + snapshotId).css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   554
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   555
			'top': 0,
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   556
			'left': 0,
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   557
			'width': $(this).width() - marginValue*2,
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   558
			'height': $(this).height() - marginValue*2,
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   559
			'background-image': 'url(' + $('img', $(this)).attr('src') + ')',
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   560
			'background-size': $(this).width() + 'px ' + $(this).height() + 'px',
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   561
			'background-position': -marginValue + 'px ' + -marginValue + 'px',
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   562
			'opacity': '0.4'
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   563
		});
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   564
		
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   565
		var fId = '#neighbourFrame-' + snapshotId;
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   566
		
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   567
		$(fId).animate(
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   568
        {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   569
            //On le fait apparaître.
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   570
            opacity: '1'
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   571
        }, timeNeighbourGlowing, function()
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   572
        {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   573
            //On peut désormais se déplacer vers ce voisin.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   574
            mos.canMoveToNeighbour = true;
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   575
        });
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   576
		//Lorsqu'on quitte un des snapshots (bien entendu le voisin en question), on retire le cadre.
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   577
		$(fId).mouseleave(mos.deselectNeighbour)
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   578
		//Si on clique sur le voisin ou son cadre, on passe au voisin suivant.
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   579
		$(fId).click(mos.moveToNeighbour);
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   580
    }
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   581
}
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   582
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   583
/*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   584
 * Change la coloration d'une bordure quittée lors d'une vue en plein écran.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   585
 */
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   586
mosaic.prototype.deselectNeighbour = function()
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   587
{
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   588
    ////TEST
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   589
    //$('.test').append('un,');
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   590
	
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   591
    //On ne peut plus se déplacer vers les voisins.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   592
    mos.canMoveToNeighbour = false;
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   593
    
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   594
	//On récupère le voisin.
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   595
	var neighbourFrame = $(this);
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   596
	
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   597
    //Si on est en mode VIDEO.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   598
    if(mos.currentMode == 'VIDEO')
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   599
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   600
        //On le fait disparaître progressivement.
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   601
        neighbourFrame.animate(
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   602
        {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   603
            opacity: '0'
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   604
        }, timeNeighbourUnglowing, function()
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   605
        {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   606
            //Une fois invisible, on le supprime.
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   607
            neighbourFrame.remove();
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   608
        });
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   609
    }
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   610
}
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   611
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   612
/*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   613
 * 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
   614
 */
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   615
mosaic.prototype.moveToNeighbour = function()
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   616
{
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   617
    //Si on ne peut pas se déplacer vers les voisins, on quitte.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   618
    if(!mos.canMoveToNeighbour)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   619
	{
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   620
        return;
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   621
	}
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   622
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   623
    //On obtient l'ID de destination.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   624
    var tab = $(this).attr('id').split('-');
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   625
    var destinationId = tab[1];
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   626
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   627
    //On charge les attributs nécessaires aux calculs.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   628
    var MPCurrentTop = $('#mainPanel').position().top, MPCurrentLeft = $('#mainPanel').position().left;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   629
    var divideCoeffTop = Math.floor(destinationId / mos.length) == 0 ? 1 : Math.floor(destinationId / mos.length);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   630
    var divideCoeffLeft = destinationId % mos.length == 0 ? 1 : destinationId % mos.length;
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   631
    var neighbourFrameTop = $('#snapshotDiv-' + destinationId).position().top, neighbourFrameLeft = $('#snapshotDiv-' + destinationId).position().left;
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   632
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   633
    //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
   634
    if(mos.previousZoomedSN.position().top > neighbourFrameTop)
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   635
        MPCurrentTop += Math.abs(neighbourFrameTop - mos.previousZoomedSN.position().top);
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   636
    else if(mos.previousZoomedSN.position().top < neighbourFrameTop)
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   637
        MPCurrentTop -= Math.abs(neighbourFrameTop - mos.previousZoomedSN.position().top);
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   638
    //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
   639
    if(mos.previousZoomedSN.position().left > neighbourFrameLeft)
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   640
        MPCurrentLeft += Math.abs(neighbourFrameLeft - mos.previousZoomedSN.position().left);
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   641
    else if(mos.previousZoomedSN.position().left < neighbourFrameLeft)
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   642
        MPCurrentLeft -= Math.abs(neighbourFrameLeft - mos.previousZoomedSN.position().left);
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   643
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   644
    //On passe le snapshot de destination en HD.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   645
    var destinationImg = $('#snapshot-' + destinationId);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   646
    var destinationImgSrc = destinationImg.attr('src');
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   647
    destinationImg.attr('src', destinationImgSrc.replace('snapshots-little/', 'snapshots/'));
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   648
    
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   649
    //On passe l'ancien snapshot en SD.
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   650
    var currentImgSrc = $('img', mos.previousZoomedSN).attr('src');
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   651
    $('img', mos.previousZoomedSN).attr('src', currentImgSrc.replace('snapshots/', 'snapshots-little/'));
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   652
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   653
    //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
   654
    var neighbourFrame = $(this);
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   655
    var tab = neighbourFrame.attr('id').split('-');
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   656
    mos.centerId = tab[1];
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   657
    $(this).css('opacity', '0');
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   658
    neighbourFrame.remove();
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   659
    
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   660
	$('div').remove('.LdtPlayer');
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   661
	$('body').append('<div class="LdtPlayer" id="LdtPlayer"></div>');
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   662
	
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   663
    //On grise le snapshot qu'on vient de quitter.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   664
    mos.previousZoomedSN.animate(
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   665
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   666
        opacity: '0.4'
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   667
    });
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   668
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   669
    //On se déplace.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   670
    $('#mainPanel').animate(
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   671
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   672
        top: MPCurrentTop,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   673
        left: MPCurrentLeft
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   674
    }, timeMovingToNeighbour, function()
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   675
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   676
        //On fait apparaître le snapshot vers lequel on s'est déplacé.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   677
        $('#snapshotDiv-' + destinationId).animate(
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   678
        {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   679
            opacity: '1'
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   680
        }, mos.zoomTime, function()
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   681
        {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   682
            //On recharge les voisins.
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   683
            $('.snapshotDivs').unbind('mouseenter', mos.selectNeighbour);
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   684
            mos.previousZoomedSN = $('#snapshotDiv-' + mos.centerId);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   685
            mos.listenToNeighbours();
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   686
			
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   687
			mos.loadPlayer((destinationImg.position().top + MPCurrentTop + mos.MPTop_margin), (destinationImg.position().left + MPCurrentLeft), destinationImg.width(), destinationImg.height());
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   688
        });
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   689
    });
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   690
}
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   691
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   692
/*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   693
 * Déchargement du contenu de la mosaïque pour le chargement de la mosaïque locale.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   694
 */
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   695
mosaic.prototype.unload = function()
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   696
{
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   697
    //On supprime les event listeners des objets de la mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   698
    $('.snapshotDivs').unbind();
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   699
    $('.snapshots').unbind();
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   700
    $('.prezoomContainers').unbind();
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   701
    //On supprime physiquement les objets.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   702
    $('#mainPanel').empty();
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   703
}
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   704
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   705
/*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   706
 * Centre verticalement un snapshot.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   707
 */
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   708
/*function verticalCenterImg(mosaic, img)
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   709
{
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   710
    //On récupère sa hauteur.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   711
    var image_height = img.height();
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   712
    //Calcule la marge du haut de chaque div pour le centrage.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   713
    if(mosaic.top_margin == undefined)
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   714
        mosaic.top_margin = (mosaic.snapshotHeight > image_height) ? (mosaic.snapshotHeight - image_height)/2 : (image_height - mosaic.snapshotHeight)/2;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   715
    //On centre le snapshot.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   716
    img.css('margin-top', mosaic.top_margin).css('margin-bottom', mosaic.top_margin);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   717
}*/
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   718
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   719
/*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   720
 * Permet de tester l'égalité des éléments de deux objets.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   721
 * Pour ce faire on compare les éléments définissant ces objets.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   722
 */
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   723
$.fn.equals = function(compareTo)
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   724
{
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   725
    if (!compareTo || !compareTo.length || this.length!=compareTo.length)
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   726
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   727
        return false;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   728
    }
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   729
    for (var i=0; i<this .length; i++)
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   730
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   731
        if (this[i]!==compareTo[i])
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   732
        {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   733
            return false;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   734
        }
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   735
    }
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   736
    return true;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   737
}