front_idill/src/mosaic/js/neighbours.js
author bastiena
Wed, 29 Aug 2012 11:29:14 +0200
changeset 87 34afef0f9e18
parent 79 9eff85166868
permissions -rw-r--r--
Merge of the two differents mosaic files
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.
77
205409da0f32 Front IDILL:
bastiena
parents: 58
diff changeset
    76
    if(_.include(this.neighboursIds, -1) && !this.isTablet)
52
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.
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   175
    if(this.currentlyMoving || this.currentlyUnzooming || this.helpDisplayed || this.isSearchByCurvesOn)
52
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
    
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   180
	if(this.config.mouseInteractions)
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   181
	{
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   182
		this.canMoveToNeighbour = true;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   183
	}
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   184
	
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   185
    //Si on est sur une notification de gesture de recherche.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   186
    if(this.gestureDelRequested)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   187
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   188
        //On récupère l'id du voisin.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   189
        var tab = neighbour.attr('id').split('-');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   190
        var snapshotId = tab[1];
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   191
        //On le déselectionne.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   192
        this.deselectNeighbour(snapshotId);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   193
        //On part.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   194
        return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   195
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   196
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   197
    //On ne peut pas faire de swipes.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   198
    this.canSwipe = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   199
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   200
    var _this = this;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   201
    
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   202
    //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
   203
	if((this.currentMode == 'VIDEO' || this.currentMode == 'SEARCH') && (neighbour.attr('id') != 'snapshotDiv-' + this.centerId))
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   204
    {
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   205
        //On crée le cadre qui va être superposé au voisin.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   206
        //On le colle au voisin.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   207
        var tab = neighbour.attr('id').split('-');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   208
        var snapshotId = tab[1];
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   209
        var neighbourFrame = '';
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   210
        var marginValue = parseFloat(neighbour.css('margin'));
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   211
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   212
        //Si la frame existe déjà, on quitte.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   213
        if($('#neighbourFrame-' + snapshotId).length > 0)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   214
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   215
            return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   216
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   217
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   218
        //Si c'est un voisin additionnel.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   219
        if(neighbour.attr('id').indexOf('borderNeighbour') != -1)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   220
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   221
            //On le sélectionne quand même.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   222
            snapshotId = +snapshotId + this.config.imagesToShow;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   223
            neighbourFrame += '<div class="neighbourFrame" id="neighbourFrame-' + snapshotId + '"></div>';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   224
            if($('#neighbourFrame-' + snapshotId).length > 0)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   225
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   226
                return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   227
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   228
            $('body').append(neighbourFrame);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   229
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   230
        //Si c'est un voisin normal.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   231
        else
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   232
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   233
            //On le sélectionne.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   234
            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
   235
            if($('#neighbourFrame-' + snapshotId).length > 0)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   236
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   237
                return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   238
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   239
            $('#mainPanel').append(neighbourFrame);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   240
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   241
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   242
        //On positionne le div de background juste au niveau du voisin.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   243
        $('#neighbourFrame-' + snapshotId).css(
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   244
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   245
            'top': (+neighbour.position().top + marginValue),
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   246
            'left': (+neighbour.position().left + marginValue),
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   247
            'width': neighbour.width(),
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   248
            'height': neighbour.height()
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   249
        });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   250
        //On positionne le div de background noir juste au niveau de l'image du voisin.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   251
        $('#neighbourImgBg-' + snapshotId).css(
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   252
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   253
            'top': marginValue,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   254
            'left': marginValue,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   255
            'width': neighbour.width() - marginValue*2,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   256
            'height': neighbour.height() - marginValue*2,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   257
        });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   258
        //On met par dessus le div de l'image clonée du voisin.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   259
        $('#neighbourImg-' + snapshotId).css(
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   260
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   261
            'top': 0,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   262
            'left': 0,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   263
            'width': neighbour.width() - marginValue*2,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   264
            'height': neighbour.height() - marginValue*2,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   265
            'background-image': 'url("' + $('img', neighbour).attr('src') + '")',
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   266
            'background-size': neighbour.width() + 'px ' + neighbour.height() + 'px',
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   267
            'background-position': -marginValue + 'px ' + -marginValue + 'px',
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   268
            'opacity': '0.4'
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   269
        });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   270
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   271
        var fId = '#neighbourFrame-' + snapshotId;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   272
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   273
        $(fId).animate(
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   274
        {
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   275
            //On le fait apparaître.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   276
            opacity: '1'
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   277
        }, _this.config.timeNeighbourGlowing, function()
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   278
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   279
            //Si on est en mode d'intéraction souris.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   280
            if(_this.config.mouseInteractions)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   281
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   282
                //Si on est en mode video.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   283
                if(_this.currentMode == 'VIDEO')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   284
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   285
                    //On notifie.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   286
                    _this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   287
                    _this.videoMove(snapshotId);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   288
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   289
                //Si on est en mode de recherche mais sans gesture encore.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   290
                else if(_this.currentMode == 'SEARCH' && _this.currentSearchGesture[_this.centerId] == '')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   291
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   292
                    //On notifie.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   293
                    _this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   294
                    _this.searchSearchAndMove(snapshotId);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   295
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   296
                //Si on est en mode de recherche avec une gesture.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   297
                else if(_this.currentMode == 'SEARCH' && _this.currentSearchGesture[_this.centerId] != '')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   298
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   299
                    //On notifie.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   300
                    _this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   301
                    _this.searchGestureAndMove(_this.currentSearchGesture[_this.centerId], 'valid', snapshotId);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   302
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   303
                
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   304
                //On peut bouger vers un voisin.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   305
                _this.canMoveToNeighbour = true;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   306
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   307
            //Si on est en mode d'intéractions Kinect.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   308
            else
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   309
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   310
                //Si on est en mode video, on notifie mais avec un dézoom possible.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   311
                if(_this.currentMode == 'VIDEO')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   312
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   313
                    _this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   314
                    _this.videoMoveAndUnzoom(snapshotId);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   315
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   316
                //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
   317
                else if(_this.currentMode == 'SEARCH' && !_this.currentSearchGesture[_this.centerId])
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   318
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   319
                    _this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   320
                    _this.searchSearchAndMoveAndUnzoom(snapshotId);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   321
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   322
                //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
   323
                else if(_this.currentMode == 'SEARCH' && _this.currentSearchGesture[_this.centerId])
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   324
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   325
                    _this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   326
                    _this.searchGestureAndMoveAndUnzoom(_this.currentSearchGesture[_this.centerId], 'valid', snapshotId);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   327
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   328
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   329
        });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   330
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   331
        //On repère de quel côté le voisin se trouve en fonction du centre.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   332
        var side = $.inArray(parseInt(snapshotId), this.neighboursIds);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   333
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   334
        //S'il n'est nulle part on part.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   335
        if(side == -1)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   336
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   337
            return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   338
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   339
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   340
        //On affecte l'image de la notification en fonction du côté.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   341
        var sides = ['left', 'right', 'down', 'up'];
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   342
        pointer.css('background-image', 'url(./img/cursors/' + sides[side] + '_gray.png)');
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   343
    }
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   344
}
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   345
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   346
/*
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   347
 * Change la coloration d'une bordure quittée lors d'une vue en plein écran.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   348
 * Est appelé : dans les fichiers neighbours > fonction selectNeighbour et pointers > fonction pointersVideoInteractions.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   349
 */
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   350
Mosaic.prototype.deselectNeighbour = function(neighbourId)
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   351
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   352
    if($('#neighbourFrame-' + neighbourId).length <= 0)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   353
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   354
        return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   355
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   356
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   357
    var _this = this;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   358
    
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   359
    //On ne peut plus se déplacer vers les voisins.
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   360
	if(this.config.mouseInteractions)
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   361
	{
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   362
		this.canMoveToNeighbour = false;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   363
	}
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   364
	else
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   365
	{
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   366
		this.canMoveToNeighbour = true;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   367
	}
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   368
    
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   369
    //On récupère le voisin.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   370
    var neighbourFrame = $('#neighbourFrame-' + neighbourId);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   371
    
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   372
    //Si on est en mode VIDEO.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   373
    if(this.currentMode == 'VIDEO' || this.currentMode == 'SEARCH')
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   374
    {
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   375
        //On le fait disparaître progressivement.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   376
        neighbourFrame.animate(
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   377
        {
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   378
            opacity: '0'
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   379
        }, this.config.timeNeighbourUnglowing, function()
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   380
        {
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   381
            //Une fois invisible, on le supprime.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   382
            neighbourFrame.remove();
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   383
            _this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   384
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   385
            if(_this.currentMode == 'SEARCH' && _this.currentSearchGesture[_this.centerId] == '')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   386
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   387
                _this.searchSearch();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   388
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   389
            else if(_this.currentMode == 'SEARCH' && _this.currentSearchGesture[_this.centerId] != '')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   390
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   391
                _this.searchGesture(_this.currentSearchGesture[_this.centerId], 'valid');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   392
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   393
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   394
            _this.canSwipe = true;
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   395
        });
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   396
    }
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   397
}
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   398
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   399
/*
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   400
 * Permet de savoir si un déplacement est possible en fonction de l'id de snapshot entré.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   401
 * x et y sont les positions du pointeur.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   402
 * Déplace vers le voisin si possible.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   403
 * Est appelé : dans le fichier pointers > fonction pointersVideoInteractions.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   404
*/
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   405
Mosaic.prototype.correctMoveToNeighbour = function(id, x, y)
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   406
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   407
    var _this = this;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   408
    
77
205409da0f32 Front IDILL:
bastiena
parents: 58
diff changeset
   409
	var id = parseInt(id);
205409da0f32 Front IDILL:
bastiena
parents: 58
diff changeset
   410
	
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   411
    if(this.neighboursIds != null && this.neighboursIds.length > 0 && this.canMoveToNeighbour)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   412
    {
77
205409da0f32 Front IDILL:
bastiena
parents: 58
diff changeset
   413
        var idx = this.neighboursIds.indexOf(id);
205409da0f32 Front IDILL:
bastiena
parents: 58
diff changeset
   414
		
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   415
        //Si l'id du snapshot qu'on vient de quitter fait partie des voisins.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   416
        if(idx > -1)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   417
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   418
            //Correspondance indices : position par rapport au snapshot du milieu.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   419
            //0 : gauche.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   420
            //1 : droite.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   421
            //2 : haut.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   422
            //3 : bas.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   423
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   424
            //On cherche le symétrique de l'id du voisin quitté.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   425
            //Astuce : S'il est pair, cela signifie qu'on doit faire +1, sinon c'est -1.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   426
            //var sym = (idx % 2 == 0) ? (+idx + 1) : (idx - 1);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   427
            //S'il est > -1 alors forcément il existe.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   428
            //Si on peut se déplacer vers un voisin, on le fait.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   429
            if(this.neighboursIds[idx] > -1)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   430
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   431
                var centerWidth = -this.notifyLeftVideo + $(window).width() / 2, centerHeight = -this.notifyTopVideo + $(window).height() / 2;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   432
                
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   433
                //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
   434
                //Sinon c'est l'inverse.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   435
                //(sym et idx on été échangés).
77
205409da0f32 Front IDILL:
bastiena
parents: 58
diff changeset
   436
				if(this.isTablet)
205409da0f32 Front IDILL:
bastiena
parents: 58
diff changeset
   437
				{
205409da0f32 Front IDILL:
bastiena
parents: 58
diff changeset
   438
					if(idx > -1 && idx < 4)
205409da0f32 Front IDILL:
bastiena
parents: 58
diff changeset
   439
					{
205409da0f32 Front IDILL:
bastiena
parents: 58
diff changeset
   440
						this.moveToNeighbour($('#snapshotDiv-' + this.neighboursIds[idx]));
205409da0f32 Front IDILL:
bastiena
parents: 58
diff changeset
   441
					}
205409da0f32 Front IDILL:
bastiena
parents: 58
diff changeset
   442
				}
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   443
				else if(this.config.mouseInteractions)
77
205409da0f32 Front IDILL:
bastiena
parents: 58
diff changeset
   444
				{
205409da0f32 Front IDILL:
bastiena
parents: 58
diff changeset
   445
					if(idx == 0 && x > centerWidth || idx == 2 && y > centerHeight || idx == 1 && x < centerWidth || idx == 3 && y < centerHeight)
205409da0f32 Front IDILL:
bastiena
parents: 58
diff changeset
   446
					{
205409da0f32 Front IDILL:
bastiena
parents: 58
diff changeset
   447
						this.moveToNeighbour($('#snapshotDiv-' + this.neighboursIds[idx]));
205409da0f32 Front IDILL:
bastiena
parents: 58
diff changeset
   448
					}
205409da0f32 Front IDILL:
bastiena
parents: 58
diff changeset
   449
				}
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   450
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   451
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   452
        else if(id >= this.config.imagesToShow)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   453
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   454
            //On otbient le vrai ID du voisin additionnel.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   455
            var additionalNeighbourId = id - this.config.imagesToShow;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   456
            var sym = (additionalNeighbourId % 2 == 0) ? (+additionalNeighbourId + 1) : (additionalNeighbourId - 1);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   457
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   458
    }
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   459
}
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   460
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   461
/*
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   462
 * 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
   463
 * Est appelé : dans les fichiers neighbours > fonction correctMoveToNeighbour, playerControl > fonction playNextVideo et zoomInteractions > zoom.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   464
 */
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   465
Mosaic.prototype.moveToNeighbour = function(neighbour)
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   466
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   467
    var _this = this;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   468
    
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   469
    //Si on ne peut pas se déplacer vers les voisins, on quitte.
77
205409da0f32 Front IDILL:
bastiena
parents: 58
diff changeset
   470
    if((!this.canMoveToNeighbour || neighbour.length <= 0 || this.currentlyMoving || this.currentlyUnzooming) && !this.autoMove)
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   471
    {
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   472
        return;
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   473
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   474
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   475
    this.canMoveToNeighbour = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   476
    this.currentlyMoving = true;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   477
    this.removeAdditionalNeighbours();
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   478
    
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   479
    //On obtient l'ID de destination.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   480
    var tab = neighbour.attr('id').split('-');
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   481
    var destinationId = tab[1];
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   482
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   483
    var startId = this.previousZoomedSN.attr('id').replace('snapshotDiv-', '');
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   484
    
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   485
    //On charge les attributs nécessaires aux calculs.
55
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   486
    var length = _this.config.imagesByLine;
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   487
    var MPCurrentTop = $('#mainPanel').position().top, MPCurrentLeft = $('#mainPanel').position().left;
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   488
    var divideCoeffTop = Math.floor(destinationId / length) == 0 ? 1 : Math.floor(destinationId / length);
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   489
    var divideCoeffLeft = destinationId % length == 0 ? 1 : destinationId % length;
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   490
    var neighbourFrameTop = $('#snapshotDiv-' + destinationId).position().top, neighbourFrameLeft = $('#snapshotDiv-' + destinationId).position().left;
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   491
    
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   492
    _this.previousZoomedSN = $('#snapshotDiv-' + this.centerId);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   493
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   494
    //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
   495
    if(_this.previousZoomedSN.position().top > neighbourFrameTop)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   496
        MPCurrentTop += Math.abs(neighbourFrameTop - _this.previousZoomedSN.position().top);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   497
    else if(_this.previousZoomedSN.position().top < neighbourFrameTop)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   498
        MPCurrentTop -= Math.abs(neighbourFrameTop - _this.previousZoomedSN.position().top);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   499
    //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
   500
    if(_this.previousZoomedSN.position().left > neighbourFrameLeft)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   501
        MPCurrentLeft += Math.abs(neighbourFrameLeft - _this.previousZoomedSN.position().left);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   502
    else if(_this.previousZoomedSN.position().left < neighbourFrameLeft)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   503
        MPCurrentLeft -= Math.abs(neighbourFrameLeft - _this.previousZoomedSN.position().left);
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   504
    
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   505
    //On passe le snapshot de destination en HD.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   506
    var destinationImg = $('#snapshot-' + destinationId);
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   507
    var destinationImgSrc = destinationImg.attr('src');
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   508
    destinationImg.attr('src', destinationImgSrc.replace('snapshots-little/', 'snapshots/'));
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   509
    
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   510
    //On passe l'ancien snapshot en SD.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   511
    var currentImgSrc = $('img', _this.previousZoomedSN).attr('src');
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   512
    $('img', _this.previousZoomedSN).attr('src', currentImgSrc.replace('snapshots/', 'snapshots-little/'));
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   513
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   514
    $('#snapshotDiv-' + destinationId).css('opacity', '1');
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   515
    
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   516
    //Si le player est prêt.
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   517
    if(_this.player && _this.player.widgets && _this.player.widgets[0] && _this.playerIsReady)
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   518
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   519
        //Si on est en mode timeline on la quitte.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   520
        if(_this.currentMode == 'TIMELINE')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   521
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   522
            _this.exitTimeline('move');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   523
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   524
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   525
        //Si le move est automatique (fin de vidéo).
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   526
        if(_this.autoMove)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   527
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   528
            //On remet à jour la position du curseur de la vidéo.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   529
            _this.timeToGoAt[_this.centerId] = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   530
            _this.autoMove = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   531
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   532
        //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
   533
        else
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   534
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   535
            _this.timeToGoAt[_this.centerId] = Math.floor(_this.player.popcorn.currentTime());
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   536
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   537
        //On libère le player.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   538
        _this.player.widgets[0].freePlayer();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   539
        _this.playerIsReady = false;
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   540
		_this.isVideoReading = false;
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   541
        $('.LdtPlayer').remove();
77
205409da0f32 Front IDILL:
bastiena
parents: 58
diff changeset
   542
        
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   543
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   544
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   545
    //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
   546
    _this.centerId = destinationId;
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   547
    
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   548
    //On grise le snapshot qu'on vient de quitter.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   549
    _this.previousZoomedSN.fadeTo(_this.config.zoomTime, '0.4');
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   550
    
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   551
    //console.log(MPCurrentLeft);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   552
    
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   553
    //On se déplace.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   554
    $('#mainPanel').animate(
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   555
    {
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   556
        top: MPCurrentTop,
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   557
        left: MPCurrentLeft
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   558
    }, _this.config.timeMovingToNeighbour, function()
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   559
    {
77
205409da0f32 Front IDILL:
bastiena
parents: 58
diff changeset
   560
		$('body').append('<div class="LdtPlayer" id="LdtPlayer"></div>');
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   561
        //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
   562
        if(_this.currentSearchGesture[_this.centerId] != '')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   563
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   564
            _this.currentMode = 'SEARCH';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   565
            _this.isCurrentlyInASearchByGesture = true;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   566
            _this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   567
            _this.searchGesture(_this.currentSearchGesture[_this.centerId], 'valid');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   568
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   569
        
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   570
        //On fait apparaître le snapshot vers lequel on s'est déplacé.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   571
        $('#snapshotDiv-' + destinationId).fadeTo(_this.config.zoomTime, '1', function()
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   572
        {
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   573
            //On recharge les voisins.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   574
            _this.previousZoomedSN = $('#snapshotDiv-' + _this.centerId);
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   575
            
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   576
            _this.notifyTopVideo = MPCurrentTop;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   577
            _this.notifyLeftVideo = MPCurrentLeft;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   578
            _this.neighboursIds.length = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   579
            _this.currentlyMoving = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   580
            _this.listenToNeighbours();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   581
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   582
            //On charge le player.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   583
            _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
   584
        });
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   585
    });
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   586
}
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   587
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   588
/*
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   589
 * Donne éventuellement un snapshot d'après les coordonnées du pointeur sur l'écran.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   590
 * Renvoie null sinon.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   591
 * Est appelé : dans les fichiers pointers > fonction pointersMosaicInteractions et pointersVideoInteractions et zoomInteractions > zoom.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   592
*/
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   593
Mosaic.prototype.pointerPositionToSN = function(x, y, isMainPointer)
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   594
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   595
    if(this.helpDisplayed)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   596
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   597
        return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   598
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   599
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   600
    x += $('#mainPointer').width() / 2;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   601
    y += $('#mainPointer').height() / 2;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   602
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   603
    //Taille de la marge des snapshots.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   604
    var m = parseInt($('.snapshotDivs').css('margin'));
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   605
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   606
    //Dimensions d'un snapshot de la mosaïque.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   607
    var W = $('.snapshotDivs').width() + m * 2, H = $('.snapshotDivs').height() + m * 2;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   608
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   609
    //Position supposée du snapshot dans la mosaïque.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   610
    //Au départ on ne sélectionne rien.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   611
    var i = -1, j = -1;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   612
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   613
    //Espace de centrage vertical de la mosaïque.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   614
    var top_margin = parseInt(this.MPTop_margin);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   615
    //Dimensions de la mosaïque en nombre de snapshots.
55
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   616
    var mosW = this.config.imagesByLine, mosH = this.config.imagesToShow / mosW;
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   617
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   618
    //Si le pointeur se trouve au niveau de la mosaïque.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   619
    if(x < W * mosW && y >= top_margin && y < H * mosH + top_margin)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   620
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   621
        //Si le pointeur est sur une des bordures.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   622
        var xb = x % W;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   623
        var yb = y - top_margin;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   624
        yb %= H;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   625
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   626
        if(xb < m || xb > W - m || yb < m || yb > H - m)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   627
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   628
            //On renvoie null.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   629
            return null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   630
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   631
        //Sinon il est forcément sur un des snapshots.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   632
        else
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   633
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   634
            i = Math.floor(x / W);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   635
            j = Math.floor((y - top_margin) / H);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   636
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   637
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   638
        //On passe des coordonnées 2D en 1D.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   639
        var snapshot = $('#snapshotDiv-' + (j * mosW + i));
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   640
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   641
        //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
   642
        if(this.isMosaicFiltered && (this.currentMode == "MOSAIC" || this.currentMode == "FILTER") && snapshot.css('opacity') == 0)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   643
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   644
            return null;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   645
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   646
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   647
        //On renvoie le snapshot.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   648
        return snapshot;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   649
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   650
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   651
    //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
   652
    return null;
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   653
}
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   654
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   655
/*
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   656
 * Donne éventuellement un voisin additionnel d'après les coordonnées du pointeur sur l'écran.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   657
 * Renvoie null sinon.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   658
 * Est appelé : dans le fichier pointers > fonction pointersVideoInteractions.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   659
*/
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   660
Mosaic.prototype.pointerPositionToAN = function(x, y, isMainPointer)
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   661
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   662
    //Si l'aide est affichée, on part.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   663
    if(this.helpDisplayed)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   664
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   665
        return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   666
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   667
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   668
    x += $('#mainPointer').width() / 2;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   669
    y += $('#mainPointer').height() / 2;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   670
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   671
    //Pour tous les voisins.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   672
    for(var i = 0 ; i < this.neighboursIds.length ; i++)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   673
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   674
        //Si on est sur un bord.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   675
        if(this.neighboursIds[i] == -1)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   676
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   677
            //On récupère un voisin au delà du bord.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   678
            var neighbour = $('#borderNeighbour-' + i);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   679
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   680
            if(neighbour == null || neighbour == undefined || neighbour.position() == null)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   681
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   682
                return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   683
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   684
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   685
            //Si le pointeur est sur le voisin, on le retourne.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   686
            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
   687
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   688
                return neighbour;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   689
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   690
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   691
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   692
    return null;
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   693
}
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   694
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   695
/*
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   696
 * Vérifie l'intéraction dézoom.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   697
 * Est appelé : dans le fichier pointers > fonction pointersVideoInteractions.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   698
*/
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   699
Mosaic.prototype.checkForDezoom = function()
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   700
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   701
    //Si on se trouve en mode VIDEO ou SEARCH.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   702
    if(this.currentMode == "VIDEO" || this.currentMode == "SEARCH")
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   703
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   704
        //Si les deux pointeurs sont allés puis ont quitté une bordure.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   705
        if(this.mainPointerExitBorder && this.secondPointerExitBorder)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   706
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   707
            //Si les voisins existent.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   708
            if(this.neighboursIds != null && this.neighboursIds.length > 0)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   709
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   710
                var localIdMainPointerNeighbour = $.inArray(this.mainPointerNeighbourSelectedId, this.neighboursIds);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   711
                var localIdSecondPointerNeighbour = $.inArray(this.secondPointerNeighbourSelectedId, this.neighboursIds);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   712
                
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   713
                //Cas où on a des voisins additionnels.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   714
                if(this.mainPointerNeighbourSelectedId >= this.config.imagesToShow)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   715
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   716
                    localIdMainPointerNeighbour = this.mainPointerNeighbourSelectedId - this.config.imagesToShow;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   717
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   718
                if(this.secondPointerNeighbourSelectedId >= this.config.imagesToShow)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   719
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   720
                    localIdSecondPointerNeighbour = this.secondPointerNeighbourSelectedId - this.config.imagesToShow;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   721
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   722
                
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   723
                if(localIdMainPointerNeighbour > -1 && localIdMainPointerNeighbour < 4 && localIdSecondPointerNeighbour > -1 && localIdSecondPointerNeighbour < 4)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   724
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   725
                    var sym = (localIdMainPointerNeighbour % 2 == 0) ? (+localIdMainPointerNeighbour + 1) : (localIdMainPointerNeighbour - 1);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   726
                    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   727
                    //Si les voisins sélectionnés sont opposés.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   728
                    if(sym == localIdSecondPointerNeighbour)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   729
                    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   730
                        //Positions des pointeurs.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   731
                        var xMain = $('#mainPointer').position().left - $('#mainPointer').width() / 2;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   732
                        var yMain = $('#mainPointer').position().top - $('#mainPointer').height() / 2;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   733
                        var xSecond = $('#secondPointer').position().left - $('#secondPointer').width() / 2;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   734
                        var ySecond = $('#secondPointer').position().top - $('#secondPointer').height() / 2;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   735
                        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   736
                        //Snapshot central.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   737
                        var centerSN = $('#snapshotDiv-' + this.centerId);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   738
                        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   739
                        //Quarts du snapshot central.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   740
                        var center1QuartWidth = centerSN.position().left + this.notifyLeftVideo + centerSN.width() / 4;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   741
                        var center3QuartsWidth = centerSN.position().left + this.notifyLeftVideo + centerSN.width() * 3 / 4;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   742
                        var center1QuartHeight = centerSN.position().top + this.notifyTopVideo + centerSN.height() / 4;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   743
                        var center3QuartsHeight = centerSN.position().top + this.notifyTopVideo + centerSN.height() * 3 / 4;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   744
                        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   745
                        //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
   746
                        //Si les voisins sélectionnés sont de disposition horizontale.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   747
                        if(sym == 0 || sym == 1)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   748
                        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   749
                            if(xMain > center1QuartWidth && xSecond > center1QuartWidth && xMain < center3QuartsWidth && xSecond < center3QuartsWidth)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   750
                            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   751
                                this.unzoom();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   752
                            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   753
                        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   754
                        //Sinon s'ils sont de disposition verticale.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   755
                        else if(sym == 2 || sym == 3)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   756
                        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   757
                            if(yMain > center1QuartHeight && ySecond > center1QuartHeight && yMain < center3QuartsHeight && ySecond < center3QuartsHeight)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   758
                            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   759
                                this.unzoom();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   760
                            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   761
                        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   762
                    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   763
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   764
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   765
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   766
    }
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   767
}