front_idill/src/mosaic/js/neighbours.js
author bastiena
Thu, 26 Jul 2012 14:34:02 +0200
changeset 55 afd60399a7b5
parent 52 277c94533395
child 58 a28488078053
permissions -rw-r--r--
Front IDILL : help icon added
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     1
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     2
* This file is part of the TraKERS\Front IDILL package.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     3
*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     4
* (c) IRI <http://www.iri.centrepompidou.fr/>
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     5
*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     6
* For the full copyright and license information, please view the LICENSE
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     7
* file that was distributed with this source code.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     8
*/
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     9
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    10
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    11
 * Projet : TraKERS
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    12
 * Module : Front IDILL
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    13
 * Fichier : neighbours.js
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    14
 * 
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    15
 * Auteur : alexandre.bastien@iri.centrepompidou.fr
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    16
 * 
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    17
 * Fonctionnalités : Définit les fonctions d'intéraction avec les voisins lors d'un zoom.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    18
 */
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    19
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    20
/*
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    21
 * Affecte les listeners mouseenter aux voisins lors d'une vue en plein écran.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    22
 * Est appelé : dans les fichiers neighbours > fonction moveToNeighbour et zoomInteractions > fonction zoom.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    23
 */
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    24
Mosaic.prototype.listenToNeighbours = function()
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    25
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    26
    //Si on n'est pas en mode recherche, on enlève les notifications.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    27
    if(this.currentMode != 'SEARCH')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    28
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    29
        this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    30
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    31
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    32
    //Si on est en mode sans utilisateur ou en mode utilisateur approche, on part.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    33
    if(this.currentMode == "NO-USER" || this.currentMode.indexOf("INCOMING") != -1)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    34
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    35
        return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    36
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    37
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    38
    //Si ils n'y a pas de voisins répertoriés, on part.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    39
    if(this.neighboursIds == null || this.neighboursIds != null && this.neighboursIds.length > 0)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    40
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    41
        return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    42
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    43
    
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    44
    var _this = this;
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    45
    
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    46
    //On ne peut actuellement pas se déplacer vers un voisin.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    47
    this.canMoveToNeighbour = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    48
    //On calcule la ligne et colonne du snapshot du milieu.
55
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    49
    var currentLine = Math.floor(this.centerId / this.config.imagesByLine), currentColumn = this.centerId % this.config.imagesByLine;
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    50
    var zoomedImg = $('img', this.previousZoomedSN);
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    51
    
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    52
    //On cherche l'ID des voisins.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    53
    //Si le voisin de gauche est sur la même ligne, on n'est pas sur la bordure de gauche.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    54
    this.neighboursIds[0] = (currentColumn > 0) ? (this.centerId - 1) : -1;
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    55
    //Si le voisin de droite est sur la même ligne, on n'est pas sur la bordure de droite.
55
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    56
    this.neighboursIds[1] = (currentColumn < this.config.imagesByLine - 1) ? (+this.centerId + 1) : -1;
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    57
    //Si le voisin du haut est sur la même colonne, on n'est pas sur la bordure du haut.
55
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    58
    this.neighboursIds[2] = (currentLine > 0) ? (this.centerId - this.config.imagesByLine) : -1;
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    59
    //Si le voisin du bas est sur la même colonne, on n'est pas sur la bordure du bas.
55
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    60
    this.neighboursIds[3] = (currentLine < (this.config.imagesToShow / this.config.imagesByLine)) ? (+this.centerId + this.config.imagesByLine) : -1;
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    61
    
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    62
    //ID du cadre voisin.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    63
    var preId;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    64
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    65
    //Si les voisins ont un id supérieur au maximum, on les met à -1.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    66
    for(var i = 0 ; i < this.neighboursIds.length ; i++)
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    67
    {
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    68
        if(this.neighboursIds[i] >= this.config.imagesToShow)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    69
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    70
            this.neighboursIds[i] = -1;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    71
        }
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    72
    }
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    73
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    74
    //Si on est sur une bordure.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    75
    //On crée des voisins supplémentaires.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    76
    if(_.include(this.neighboursIds, -1))
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    77
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    78
        this.createAdditionalNeighbours();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    79
    }
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    80
}
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    81
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    82
/*
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    83
 * Crée des voisins supplémentaires pour garantir le déplacement / dézoom quand on arrive sur le bord de la mosaïque.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    84
 * Est appelé : dans le fichier neighbours > fonction listenToNeighbours.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    85
*/
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    86
Mosaic.prototype.createAdditionalNeighbours = function()
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    87
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    88
    //Si on est en mode sans utilisateur, on part.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    89
    if(this.currentMode == "NO-USER")
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    90
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    91
        return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    92
    }
55
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    93
	
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    94
    //Pour tous les voisins.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    95
    var additionalNeighbours = '';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    96
    for(var i = 0 ; i < this.neighboursIds.length ; i++)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    97
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    98
        //Snapshot du milieu.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    99
        var sn = $('#snapshotDiv-' + this.centerId);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   100
        //Marge de celui-ci.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   101
        var m = parseInt(sn.css('margin'));
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   102
        //Ses coordonnées.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   103
        var centerTop = sn.position().top + this.notifyTopVideo + this.MPTop_margin, centerLeft = sn.position().left + this.notifyLeftVideo;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   104
        //Ses dimensions.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   105
        var centerWidth = sn.width(), centerHeight = sn.height();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   106
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   107
        var top, left;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   108
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   109
        //Si on est sur une bordure, on calcule les coordonnées du voisin à l'extérieur de la bordure en fonction de sa position dans le tableau des voisins.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   110
        if(this.neighboursIds[i] == -1)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   111
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   112
            if(i == 0)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   113
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   114
                top = centerTop + m / 2;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   115
                left = centerLeft - centerWidth - 2 * m;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   116
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   117
            else if(i == 1)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   118
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   119
                top = centerTop + m / 2;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   120
                left = centerLeft + centerWidth + 3 * m;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   121
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   122
            else if(i == 2)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   123
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   124
                top = centerTop - centerHeight - 2 * m;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   125
                left = centerLeft + m / 2;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   126
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   127
            else if(i == 3)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   128
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   129
                top = centerTop + centerHeight + 3 * m;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   130
                left = centerLeft + m / 2;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   131
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   132
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   133
            //On place le voisin additionnel.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   134
            additionalNeighbours += '<div id="borderNeighbour-' + i + '" class="borderNeighbours" style="opacity: 0; width: ' + centerWidth + 'px; height: ' + centerHeight + 'px; top: ' + top + 'px; left: ' + left + 'px;"></div>';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   135
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   136
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   137
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   138
    $('body').append(additionalNeighbours);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   139
    //On le fait apparaître.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   140
    $('.borderNeighbours').fadeTo(this.config.timeANFade, '1');
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   141
}
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   142
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   143
/*
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   144
 * Supprime les voisins supplémentaires.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   145
 * Est appelé : dans les fichiers neighbours > fonction moveToNeighbour et zoomInteractions > fonction unzoom.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   146
*/
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   147
Mosaic.prototype.removeAdditionalNeighbours = function()
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   148
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   149
    $('.borderNeighbours').fadeTo(this.config.timeANFade, '0', function()
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   150
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   151
        $('.borderNeighbours').remove();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   152
    });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   153
    this.deselectAllNeighbours();
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   154
}
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   155
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   156
/*
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   157
 * Déselectionne tous les voisins, même les additionnels.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   158
 * Est appelé : dans les fichier neighbours > fonction removeAdditionalNeighbours.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   159
*/
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   160
Mosaic.prototype.deselectAllNeighbours = function()
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   161
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   162
    $('.neighbourFrame').fadeTo(this.config.timeANFade, '0', function()
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   163
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   164
        $('.neighbourFrame').remove();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   165
    });
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   166
}
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   167
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   168
/*
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   169
 * Change la coloration d'une bordure où on se positionne lors d'une vue en plein écran.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   170
 * Est appelé : dans le fichier pointers > fonction pointersVideoInteractions.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   171
 */
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   172
Mosaic.prototype.selectNeighbour = function(neighbour, pointer)
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   173
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   174
    //Si on est en train de se déplacer vers un voisin ou dézoomer ou si l'aide est affichée, on part.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   175
    if(this.currentlyMoving || this.currentlyUnzooming || this.helpDisplayed)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   176
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   177
        return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   178
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   179
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   180
    //Si on est sur une notification de gesture de recherche.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   181
    if(this.gestureDelRequested)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   182
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   183
        //On récupère l'id du voisin.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   184
        var tab = neighbour.attr('id').split('-');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   185
        var snapshotId = tab[1];
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   186
        //On le déselectionne.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   187
        this.deselectNeighbour(snapshotId);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   188
        //On part.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   189
        return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   190
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   191
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   192
    //On ne peut pas faire de swipes.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   193
    this.canSwipe = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   194
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   195
    var _this = this;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   196
    
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   197
    //Si on est en mode VIDEO (plein écran) ET si le snapshot pointé est un voisin.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   198
	if((this.currentMode == 'VIDEO' || this.currentMode == 'SEARCH') && (neighbour.attr('id') != 'snapshotDiv-' + this.centerId))
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   199
    {
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   200
        //On crée le cadre qui va être superposé au voisin.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   201
        //On le colle au voisin.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   202
        var tab = neighbour.attr('id').split('-');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   203
        var snapshotId = tab[1];
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   204
        var neighbourFrame = '';
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   205
        var marginValue = parseFloat(neighbour.css('margin'));
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   206
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   207
        //Si la frame existe déjà, on quitte.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   208
        if($('#neighbourFrame-' + snapshotId).length > 0)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   209
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   210
            return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   211
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   212
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   213
        //Si c'est un voisin additionnel.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   214
        if(neighbour.attr('id').indexOf('borderNeighbour') != -1)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   215
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   216
            //On le sélectionne quand même.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   217
            snapshotId = +snapshotId + this.config.imagesToShow;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   218
            neighbourFrame += '<div class="neighbourFrame" id="neighbourFrame-' + snapshotId + '"></div>';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   219
            if($('#neighbourFrame-' + snapshotId).length > 0)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   220
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   221
                return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   222
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   223
            $('body').append(neighbourFrame);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   224
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   225
        //Si c'est un voisin normal.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   226
        else
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   227
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   228
            //On le sélectionne.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   229
            neighbourFrame += '<div class="neighbourFrame" id="neighbourFrame-' + snapshotId + '"><div class="neighbourImgBg" id="neighbourImgBg-' + snapshotId + '"><div class="neighbourImg" id="neighbourImg-' + snapshotId + '"></div></div></div>';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   230
            if($('#neighbourFrame-' + snapshotId).length > 0)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   231
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   232
                return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   233
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   234
            $('#mainPanel').append(neighbourFrame);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   235
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   236
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   237
        //On positionne le div de background juste au niveau du voisin.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   238
        $('#neighbourFrame-' + snapshotId).css(
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   239
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   240
            'top': (+neighbour.position().top + marginValue),
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   241
            'left': (+neighbour.position().left + marginValue),
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   242
            'width': neighbour.width(),
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   243
            'height': neighbour.height()
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   244
        });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   245
        //On positionne le div de background noir juste au niveau de l'image du voisin.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   246
        $('#neighbourImgBg-' + snapshotId).css(
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   247
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   248
            'top': marginValue,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   249
            'left': marginValue,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   250
            'width': neighbour.width() - marginValue*2,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   251
            'height': neighbour.height() - marginValue*2,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   252
        });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   253
        //On met par dessus le div de l'image clonée du voisin.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   254
        $('#neighbourImg-' + snapshotId).css(
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   255
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   256
            'top': 0,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   257
            'left': 0,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   258
            'width': neighbour.width() - marginValue*2,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   259
            'height': neighbour.height() - marginValue*2,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   260
            'background-image': 'url("' + $('img', neighbour).attr('src') + '")',
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   261
            'background-size': neighbour.width() + 'px ' + neighbour.height() + 'px',
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   262
            'background-position': -marginValue + 'px ' + -marginValue + 'px',
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   263
            'opacity': '0.4'
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   264
        });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   265
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   266
        var fId = '#neighbourFrame-' + snapshotId;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   267
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   268
        $(fId).animate(
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   269
        {
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   270
            //On le fait apparaître.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   271
            opacity: '1'
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   272
        }, _this.config.timeNeighbourGlowing, function()
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   273
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   274
            //Si on est en mode d'intéraction souris.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   275
            if(_this.config.mouseInteractions)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   276
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   277
                //Si on est en mode video.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   278
                if(_this.currentMode == 'VIDEO')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   279
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   280
                    //On notifie.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   281
                    _this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   282
                    _this.videoMove(snapshotId);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   283
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   284
                //Si on est en mode de recherche mais sans gesture encore.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   285
                else if(_this.currentMode == 'SEARCH' && _this.currentSearchGesture[_this.centerId] == '')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   286
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   287
                    //On notifie.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   288
                    _this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   289
                    _this.searchSearchAndMove(snapshotId);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   290
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   291
                //Si on est en mode de recherche avec une gesture.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   292
                else if(_this.currentMode == 'SEARCH' && _this.currentSearchGesture[_this.centerId] != '')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   293
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   294
                    //On notifie.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   295
                    _this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   296
                    _this.searchGestureAndMove(_this.currentSearchGesture[_this.centerId], 'valid', snapshotId);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   297
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   298
                
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   299
                //On peut bouger vers un voisin.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   300
                _this.canMoveToNeighbour = true;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   301
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   302
            //Si on est en mode d'intéractions Kinect.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   303
            else
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   304
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   305
                //Si on est en mode video, on notifie mais avec un dézoom possible.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   306
                if(_this.currentMode == 'VIDEO')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   307
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   308
                    _this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   309
                    _this.videoMoveAndUnzoom(snapshotId);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   310
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   311
                //Si on est en mode de recherche mais sans gesture encore, on notifie mais avec un dézoom possible.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   312
                else if(_this.currentMode == 'SEARCH' && !_this.currentSearchGesture[_this.centerId])
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   313
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   314
                    _this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   315
                    _this.searchSearchAndMoveAndUnzoom(snapshotId);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   316
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   317
                //Si on est en mode de recherche avec une gesture, on notifie mais avec un dézoom possible.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   318
                else if(_this.currentMode == 'SEARCH' && _this.currentSearchGesture[_this.centerId])
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   319
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   320
                    _this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   321
                    _this.searchGestureAndMoveAndUnzoom(_this.currentSearchGesture[_this.centerId], 'valid', snapshotId);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   322
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   323
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   324
        });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   325
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   326
        //On repère de quel côté le voisin se trouve en fonction du centre.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   327
        var side = $.inArray(parseInt(snapshotId), this.neighboursIds);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   328
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   329
        //S'il n'est nulle part on part.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   330
        if(side == -1)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   331
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   332
            return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   333
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   334
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   335
        //On affecte l'image de la notification en fonction du côté.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   336
        var sides = ['left', 'right', 'down', 'up'];
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   337
        pointer.css('background-image', 'url(./img/cursors/' + sides[side] + '_gray.png)');
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   338
    }
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   339
}
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   340
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   341
/*
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   342
 * Change la coloration d'une bordure quittée lors d'une vue en plein écran.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   343
 * Est appelé : dans les fichiers neighbours > fonction selectNeighbour et pointers > fonction pointersVideoInteractions.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   344
 */
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   345
Mosaic.prototype.deselectNeighbour = function(neighbourId)
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   346
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   347
    if($('#neighbourFrame-' + neighbourId).length <= 0)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   348
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   349
        return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   350
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   351
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   352
    var _this = this;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   353
    
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   354
    //On ne peut plus se déplacer vers les voisins.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   355
    this.canMoveToNeighbour = true;
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   356
    
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   357
    //On récupère le voisin.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   358
    var neighbourFrame = $('#neighbourFrame-' + neighbourId);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   359
    
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   360
    //Si on est en mode VIDEO.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   361
    if(this.currentMode == 'VIDEO' || this.currentMode == 'SEARCH')
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   362
    {
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   363
        //On le fait disparaître progressivement.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   364
        neighbourFrame.animate(
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   365
        {
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   366
            opacity: '0'
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   367
        }, this.config.timeNeighbourUnglowing, function()
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   368
        {
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   369
            //Une fois invisible, on le supprime.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   370
            neighbourFrame.remove();
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   371
            _this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   372
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   373
            if(_this.currentMode == 'SEARCH' && _this.currentSearchGesture[_this.centerId] == '')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   374
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   375
                _this.searchSearch();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   376
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   377
            else if(_this.currentMode == 'SEARCH' && _this.currentSearchGesture[_this.centerId] != '')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   378
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   379
                _this.searchGesture(_this.currentSearchGesture[_this.centerId], 'valid');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   380
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   381
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   382
            _this.canSwipe = true;
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   383
        });
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   384
    }
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   385
}
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   386
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   387
/*
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   388
 * Permet de savoir si un déplacement est possible en fonction de l'id de snapshot entré.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   389
 * x et y sont les positions du pointeur.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   390
 * Déplace vers le voisin si possible.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   391
 * Est appelé : dans le fichier pointers > fonction pointersVideoInteractions.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   392
*/
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   393
Mosaic.prototype.correctMoveToNeighbour = function(id, x, y)
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   394
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   395
    var _this = this;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   396
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   397
    if(this.neighboursIds != null && this.neighboursIds.length > 0 && this.canMoveToNeighbour)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   398
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   399
        var idx = $.inArray(id, this.neighboursIds);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   400
        //Si l'id du snapshot qu'on vient de quitter fait partie des voisins.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   401
        if(idx > -1)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   402
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   403
            //Correspondance indices : position par rapport au snapshot du milieu.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   404
            //0 : gauche.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   405
            //1 : droite.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   406
            //2 : haut.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   407
            //3 : bas.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   408
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   409
            //On cherche le symétrique de l'id du voisin quitté.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   410
            //Astuce : S'il est pair, cela signifie qu'on doit faire +1, sinon c'est -1.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   411
            //var sym = (idx % 2 == 0) ? (+idx + 1) : (idx - 1);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   412
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   413
            //S'il est > -1 alors forcément il existe.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   414
            //Si on peut se déplacer vers un voisin, on le fait.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   415
            if(this.neighboursIds[idx] > -1)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   416
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   417
                var centerWidth = -this.notifyLeftVideo + $(window).width() / 2, centerHeight = -this.notifyTopVideo + $(window).height() / 2;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   418
                
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   419
                //Si l'id du tableau est pair, alors forcément le pointeur doit être plus à droite/plus en bas que le milieu de l'écran pour se déplacer vers le voisin.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   420
                //Sinon c'est l'inverse.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   421
                //(sym et idx on été échangés).
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   422
                if(idx == 0 && x > centerWidth || idx == 2 && y > centerHeight || idx == 1 && x < centerWidth || idx == 3 && y < centerHeight)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   423
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   424
                    this.moveToNeighbour($('#snapshotDiv-' + this.neighboursIds[idx]));
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   425
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   426
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   427
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   428
        else if(id >= this.config.imagesToShow)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   429
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   430
            //On otbient le vrai ID du voisin additionnel.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   431
            var additionalNeighbourId = id - this.config.imagesToShow;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   432
            var sym = (additionalNeighbourId % 2 == 0) ? (+additionalNeighbourId + 1) : (additionalNeighbourId - 1);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   433
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   434
    }
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   435
}
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   436
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   437
/*
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   438
 * 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.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   439
 * Est appelé : dans les fichiers neighbours > fonction correctMoveToNeighbour, playerControl > fonction playNextVideo et zoomInteractions > zoom.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   440
 */
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   441
Mosaic.prototype.moveToNeighbour = function(neighbour)
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   442
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   443
    var _this = this;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   444
    
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   445
    //Si on ne peut pas se déplacer vers les voisins, on quitte.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   446
    if((!this.canMoveToNeighbour || neighbour.length <= 0 || this.currentlyMoving) && !this.autoMove)
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   447
    {
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   448
        return;
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   449
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   450
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   451
    this.canMoveToNeighbour = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   452
    this.currentlyMoving = true;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   453
    this.removeAdditionalNeighbours();
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   454
    
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   455
    //On obtient l'ID de destination.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   456
    var tab = neighbour.attr('id').split('-');
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   457
    var destinationId = tab[1];
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   458
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   459
    var startId = this.previousZoomedSN.attr('id').replace('snapshotDiv-', '');
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   460
    
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   461
    //On charge les attributs nécessaires aux calculs.
55
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   462
    var length = _this.config.imagesByLine;
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   463
    var MPCurrentTop = $('#mainPanel').position().top, MPCurrentLeft = $('#mainPanel').position().left;
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   464
    var divideCoeffTop = Math.floor(destinationId / length) == 0 ? 1 : Math.floor(destinationId / length);
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   465
    var divideCoeffLeft = destinationId % length == 0 ? 1 : destinationId % length;
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   466
    var neighbourFrameTop = $('#snapshotDiv-' + destinationId).position().top, neighbourFrameLeft = $('#snapshotDiv-' + destinationId).position().left;
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   467
    
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   468
    _this.previousZoomedSN = $('#snapshotDiv-' + this.centerId);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   469
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   470
    //On définit pour le déplacement vertical s'il est nécessaire de se déplacer en haut ou en bas.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   471
    if(_this.previousZoomedSN.position().top > neighbourFrameTop)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   472
        MPCurrentTop += Math.abs(neighbourFrameTop - _this.previousZoomedSN.position().top);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   473
    else if(_this.previousZoomedSN.position().top < neighbourFrameTop)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   474
        MPCurrentTop -= Math.abs(neighbourFrameTop - _this.previousZoomedSN.position().top);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   475
    //On définit pour le déplacement horizontal s'il est nécessaire de se déplacer à gauche ou à droite.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   476
    if(_this.previousZoomedSN.position().left > neighbourFrameLeft)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   477
        MPCurrentLeft += Math.abs(neighbourFrameLeft - _this.previousZoomedSN.position().left);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   478
    else if(_this.previousZoomedSN.position().left < neighbourFrameLeft)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   479
        MPCurrentLeft -= Math.abs(neighbourFrameLeft - _this.previousZoomedSN.position().left);
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   480
    
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   481
    //On passe le snapshot de destination en HD.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   482
    var destinationImg = $('#snapshot-' + destinationId);
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   483
    var destinationImgSrc = destinationImg.attr('src');
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   484
    destinationImg.attr('src', destinationImgSrc.replace('snapshots-little/', 'snapshots/'));
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   485
    
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   486
    //On passe l'ancien snapshot en SD.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   487
    var currentImgSrc = $('img', _this.previousZoomedSN).attr('src');
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   488
    $('img', _this.previousZoomedSN).attr('src', currentImgSrc.replace('snapshots/', 'snapshots-little/'));
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   489
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   490
    $('#snapshotDiv-' + destinationId).css('opacity', '1');
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   491
    
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   492
    //Si le player est prêt.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   493
    if(_this.playerIsReady)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   494
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   495
        //Si on est en mode timeline on la quitte.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   496
        if(_this.currentMode == 'TIMELINE')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   497
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   498
            _this.exitTimeline('move');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   499
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   500
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   501
        //Si le move est automatique (fin de vidéo).
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   502
        if(_this.autoMove)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   503
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   504
            //On remet à jour la position du curseur de la vidéo.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   505
            _this.timeToGoAt[_this.centerId] = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   506
            _this.autoMove = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   507
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   508
        //Sinon on revient là où on était la dernière fois que la video a été jouée.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   509
        else
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   510
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   511
            _this.timeToGoAt[_this.centerId] = Math.floor(_this.player.popcorn.currentTime());
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   512
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   513
        //On libère le player.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   514
        _this.player.widgets[0].freePlayer();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   515
        _this.playerIsReady = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   516
        $('.LdtPlayer').remove();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   517
        $('body').append('<div class="LdtPlayer" id="LdtPlayer"></div>');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   518
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   519
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   520
    //On obtient l'ID du div de coloration du snapshot vers lequel on se déplace afin de le supprimer.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   521
    _this.centerId = destinationId;
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   522
    
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   523
    //On grise le snapshot qu'on vient de quitter.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   524
    _this.previousZoomedSN.fadeTo(_this.config.zoomTime, '0.4');
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   525
    
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   526
    //console.log(MPCurrentLeft);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   527
    
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   528
    //On se déplace.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   529
    $('#mainPanel').animate(
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   530
    {
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   531
        top: MPCurrentTop,
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   532
        left: MPCurrentLeft
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   533
    }, _this.config.timeMovingToNeighbour, function()
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   534
    {
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   535
        //On passe en mode recherche et on recherche dans la vidéo en fonction de la gesture de recherche enregistrée dans la nouvelle vidéo.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   536
        if(_this.currentSearchGesture[_this.centerId] != '')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   537
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   538
            _this.currentMode = 'SEARCH';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   539
            _this.isCurrentlyInASearchByGesture = true;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   540
            _this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   541
            _this.searchGesture(_this.currentSearchGesture[_this.centerId], 'valid');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   542
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   543
        
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   544
        //On fait apparaître le snapshot vers lequel on s'est déplacé.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   545
        $('#snapshotDiv-' + destinationId).fadeTo(_this.config.zoomTime, '1', function()
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   546
        {
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   547
            //On recharge les voisins.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   548
            _this.previousZoomedSN = $('#snapshotDiv-' + _this.centerId);
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   549
            
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   550
            _this.notifyTopVideo = MPCurrentTop;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   551
            _this.notifyLeftVideo = MPCurrentLeft;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   552
            _this.neighboursIds.length = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   553
            _this.currentlyMoving = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   554
            _this.listenToNeighbours();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   555
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   556
            //On charge le player.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   557
            _this.loadPlayer((destinationImg.position().top + MPCurrentTop + _this.MPTop_margin), (destinationImg.position().left + MPCurrentLeft), destinationImg.width(), destinationImg.height(), MPCurrentTop, MPCurrentLeft, _this.timeToGoAt[_this.centerId]);
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   558
        });
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   559
    });
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   560
}
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   561
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   562
/*
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   563
 * Donne éventuellement un snapshot d'après les coordonnées du pointeur sur l'écran.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   564
 * Renvoie null sinon.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   565
 * Est appelé : dans les fichiers pointers > fonction pointersMosaicInteractions et pointersVideoInteractions et zoomInteractions > zoom.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   566
*/
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   567
Mosaic.prototype.pointerPositionToSN = function(x, y, isMainPointer)
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   568
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   569
    if(this.helpDisplayed)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   570
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   571
        return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   572
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   573
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   574
    x += $('#mainPointer').width() / 2;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   575
    y += $('#mainPointer').height() / 2;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   576
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   577
    //Taille de la marge des snapshots.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   578
    var m = parseInt($('.snapshotDivs').css('margin'));
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   579
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   580
    //Dimensions d'un snapshot de la mosaïque.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   581
    var W = $('.snapshotDivs').width() + m * 2, H = $('.snapshotDivs').height() + m * 2;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   582
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   583
    //Position supposée du snapshot dans la mosaïque.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   584
    //Au départ on ne sélectionne rien.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   585
    var i = -1, j = -1;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   586
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   587
    //Espace de centrage vertical de la mosaïque.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   588
    var top_margin = parseInt(this.MPTop_margin);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   589
    //Dimensions de la mosaïque en nombre de snapshots.
55
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   590
    var mosW = this.config.imagesByLine, mosH = this.config.imagesToShow / mosW;
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   591
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   592
    //Si le pointeur se trouve au niveau de la mosaïque.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   593
    if(x < W * mosW && y >= top_margin && y < H * mosH + top_margin)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   594
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   595
        //Si le pointeur est sur une des bordures.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   596
        var xb = x % W;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   597
        var yb = y - top_margin;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   598
        yb %= H;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   599
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   600
        if(xb < m || xb > W - m || yb < m || yb > H - m)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   601
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   602
            //On renvoie null.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   603
            return null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   604
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   605
        //Sinon il est forcément sur un des snapshots.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   606
        else
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   607
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   608
            i = Math.floor(x / W);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   609
            j = Math.floor((y - top_margin) / H);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   610
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   611
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   612
        //On passe des coordonnées 2D en 1D.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   613
        var snapshot = $('#snapshotDiv-' + (j * mosW + i));
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   614
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   615
        //Si le snapshot a été filtré, on renvoie null si on se trouve dans la mosaïque.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   616
        if(this.isMosaicFiltered && (this.currentMode == "MOSAIC" || this.currentMode == "FILTER") && snapshot.css('opacity') == 0)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   617
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   618
            return null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   619
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   620
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   621
        //On renvoie le snapshot.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   622
        return snapshot;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   623
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   624
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   625
    //Si on est arrivé là, c'est que le pointeur n'est pas dans la mosaïque.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   626
    return null;
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   627
}
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   628
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   629
/*
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   630
 * Donne éventuellement un voisin additionnel d'après les coordonnées du pointeur sur l'écran.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   631
 * Renvoie null sinon.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   632
 * Est appelé : dans le fichier pointers > fonction pointersVideoInteractions.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   633
*/
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   634
Mosaic.prototype.pointerPositionToAN = function(x, y, isMainPointer)
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   635
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   636
    //Si l'aide est affichée, on part.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   637
    if(this.helpDisplayed)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   638
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   639
        return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   640
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   641
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   642
    x += $('#mainPointer').width() / 2;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   643
    y += $('#mainPointer').height() / 2;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   644
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   645
    //Pour tous les voisins.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   646
    for(var i = 0 ; i < this.neighboursIds.length ; i++)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   647
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   648
        //Si on est sur un bord.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   649
        if(this.neighboursIds[i] == -1)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   650
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   651
            //On récupère un voisin au delà du bord.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   652
            var neighbour = $('#borderNeighbour-' + i);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   653
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   654
            if(neighbour == null || neighbour == undefined || neighbour.position() == null)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   655
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   656
                return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   657
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   658
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   659
            //Si le pointeur est sur le voisin, on le retourne.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   660
            if(x > neighbour.position().left && x < +neighbour.position().left + neighbour.width() && y > neighbour.position().top && y < +neighbour.position().top + neighbour.height())
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   661
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   662
                return neighbour;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   663
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   664
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   665
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   666
    return null;
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   667
}
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   668
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   669
/*
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   670
 * Vérifie l'intéraction dézoom.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   671
 * Est appelé : dans le fichier pointers > fonction pointersVideoInteractions.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   672
*/
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   673
Mosaic.prototype.checkForDezoom = function()
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   674
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   675
    //Si on se trouve en mode VIDEO ou SEARCH.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   676
    if(this.currentMode == "VIDEO" || this.currentMode == "SEARCH")
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   677
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   678
        //Si les deux pointeurs sont allés puis ont quitté une bordure.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   679
        if(this.mainPointerExitBorder && this.secondPointerExitBorder)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   680
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   681
            //Si les voisins existent.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   682
            if(this.neighboursIds != null && this.neighboursIds.length > 0)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   683
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   684
                var localIdMainPointerNeighbour = $.inArray(this.mainPointerNeighbourSelectedId, this.neighboursIds);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   685
                var localIdSecondPointerNeighbour = $.inArray(this.secondPointerNeighbourSelectedId, this.neighboursIds);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   686
                
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   687
                //Cas où on a des voisins additionnels.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   688
                if(this.mainPointerNeighbourSelectedId >= this.config.imagesToShow)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   689
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   690
                    localIdMainPointerNeighbour = this.mainPointerNeighbourSelectedId - this.config.imagesToShow;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   691
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   692
                if(this.secondPointerNeighbourSelectedId >= this.config.imagesToShow)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   693
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   694
                    localIdSecondPointerNeighbour = this.secondPointerNeighbourSelectedId - this.config.imagesToShow;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   695
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   696
                
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   697
                if(localIdMainPointerNeighbour > -1 && localIdMainPointerNeighbour < 4 && localIdSecondPointerNeighbour > -1 && localIdSecondPointerNeighbour < 4)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   698
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   699
                    var sym = (localIdMainPointerNeighbour % 2 == 0) ? (+localIdMainPointerNeighbour + 1) : (localIdMainPointerNeighbour - 1);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   700
                    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   701
                    //Si les voisins sélectionnés sont opposés.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   702
                    if(sym == localIdSecondPointerNeighbour)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   703
                    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   704
                        //Positions des pointeurs.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   705
                        var xMain = $('#mainPointer').position().left - $('#mainPointer').width() / 2;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   706
                        var yMain = $('#mainPointer').position().top - $('#mainPointer').height() / 2;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   707
                        var xSecond = $('#secondPointer').position().left - $('#secondPointer').width() / 2;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   708
                        var ySecond = $('#secondPointer').position().top - $('#secondPointer').height() / 2;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   709
                        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   710
                        //Snapshot central.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   711
                        var centerSN = $('#snapshotDiv-' + this.centerId);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   712
                        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   713
                        //Quarts du snapshot central.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   714
                        var center1QuartWidth = centerSN.position().left + this.notifyLeftVideo + centerSN.width() / 4;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   715
                        var center3QuartsWidth = centerSN.position().left + this.notifyLeftVideo + centerSN.width() * 3 / 4;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   716
                        var center1QuartHeight = centerSN.position().top + this.notifyTopVideo + centerSN.height() / 4;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   717
                        var center3QuartsHeight = centerSN.position().top + this.notifyTopVideo + centerSN.height() * 3 / 4;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   718
                        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   719
                        //Pour activer le dézoom, il suffit que les pointeurs soient dans un rectangle délimité au centre de l'écran.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   720
                        //Si les voisins sélectionnés sont de disposition horizontale.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   721
                        if(sym == 0 || sym == 1)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   722
                        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   723
                            if(xMain > center1QuartWidth && xSecond > center1QuartWidth && xMain < center3QuartsWidth && xSecond < center3QuartsWidth)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   724
                            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   725
                                this.unzoom();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   726
                            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   727
                        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   728
                        //Sinon s'ils sont de disposition verticale.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   729
                        else if(sym == 2 || sym == 3)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   730
                        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   731
                            if(yMain > center1QuartHeight && ySecond > center1QuartHeight && yMain < center3QuartsHeight && ySecond < center3QuartsHeight)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   732
                            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   733
                                this.unzoom();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   734
                            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   735
                        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   736
                    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   737
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   738
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   739
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   740
    }
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   741
}