front_idill/src/mosaic/js/zoomInteractions.js
author bastiena
Fri, 21 Sep 2012 16:12:59 +0200
changeset 109 ace8f4b644f1
parent 89 b6a115568b52
permissions -rw-r--r--
Front IDILL: help details shown text usage repaired
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 : zoomInteractions.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 de zoom/dezoom prezoom/preunzoom.
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
 * Zoom sur la position d'une image, 1ère partie. Durant le laps de temps de time ms, l'utilisateur a le choix de zoomer sur une autre image.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    22
 * Après ce laps de temps, l'image zoom complétement et il n'est plus possible de sélectionner une autre image par pointage.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    23
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    24
 * pointers > fonction pointersMosaicInteractions.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    25
 */
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    26
Mosaic.prototype.preZoom = function(snapshot)
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    27
{
89
b6a115568b52 Front IDILL:
bastiena
parents: 79
diff changeset
    28
    if(this.currentMode == "NO-USER" || this.currentMode.indexOf("INCOMING") > -1 || snapshot == null || this.helpDisplayed || this.creditsDisplayed || this.isMosaicFiltering || this.isSearchByCurvesOn || this.gestureDelRequested)
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    29
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    30
        return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    31
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    32
    
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    33
    if(this.fullscreen)
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    34
    {
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    35
        return;
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    36
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    37
	this.isPrezooming = true;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    38
    this.preUnzoom();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    39
    //On enlève les notifications initiales si elles existent.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    40
    this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    41
    
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    42
    //Mosaïque.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    43
    var _this = this;
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    44
    //Dimensions de la mosaïque.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    45
    var h = this.height, w = this.width;
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    46
    //Longueur en images, nombre d'images et taille de bordure de la mosaïque.
55
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
    47
    var len = this.config.imagesByLine, imgs = this.config.imagesToShow, margin = this.marginWidth;
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    48
    //Dimensions et position d'un snapshot dans la mosaïque.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    49
    var snHeight = this.snapshotHeight, snWidth = this.snapshotWidth;
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    50
    var sTop = snapshot.position().top, sLeft = snapshot.position().left;
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    51
    var prezoomPercentage = this.config.prezoomPercentage;
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    52
    
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    53
    //ID de l'image actuelle.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    54
    var currentId = $('img', snapshot).attr('id');
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    55
    
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    56
    //Si un zoom est déjà en cours, on ne zoom sur rien d'autre en attendant que ce snapshot ai dézoomé en cas de mouseleave.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    57
    if(this.zoomed)
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    58
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    59
        this.preUnzoom();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    60
    }
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    61
    
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    62
    //On indique qu'on a zoomé et on spécifie le snapshot sur lequel on a zoomé.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    63
    this.zoomed = true;
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    64
    this.previousZoomedSN = snapshot;
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    65
    this.previousId = currentId;
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    66
    
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    67
    //On récupère les attributs de l'image.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    68
    var fakeImg = $('img', snapshot);
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    69
    //On forme la balise de la fausse image et on passe son url pour les grands snapshots.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    70
    fakeImg = '<img id="fake-' + currentId + '" class="snapshots" src="' + fakeImg.attr('src').replace('-little/', '/') + '" />';
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    71
    //On génère un faux snapshot identique au précédent et qu'on va coller dessus.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    72
    var fakeSnapshot = '<div id="prezoomContainer-' + currentId + '" class="prezoomContainers"><div id="prezoomSnapshot-' + currentId + '" class="snapshotDivs">' + fakeImg + '</div></div>';
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    73
    
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    74
    //On l'ajoute à la mosaïque.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    75
    $('#mainPanel').append(fakeSnapshot);
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    76
    //On modifie ses attributs.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    77
    // console.log('cid : ' + currentId, $('#fake-' + currentId).length);
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    78
    $('#fake-' + currentId).load(function()
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    79
    {
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    80
    // snapshot.fadeTo(400, '0.5').delay(200).fadeTo(400, '1');
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    81
        $('#prezoomContainer-' + currentId).css('top', sTop).css('left', sLeft).css('width', (snWidth + margin)).css('height', (snHeight + margin));
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    82
        $('#prezoomSnapshot-' + currentId).css('width', (snWidth)).css('height', (snHeight));
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    83
        $('#prezoomContainer-' + currentId).css('display', 'block');
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    84
        
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    85
        //Dimensions et coordonnées initiales du div sur lequel on zoom.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    86
        var initialDivWidth = $('#prezoomContainer-' + currentId).width(), initialDivHeight = $('#prezoomContainer-' + currentId).height();
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    87
        var initialDivTop = $('#prezoomContainer-' + currentId).position().top, initialDivLeft = $('#prezoomContainer-' + currentId).position().left;
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    88
        //Dimensions et coordonnées finales du div.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    89
        var finalDivWidth = initialDivWidth * (prezoomPercentage+1), diffWidth = finalDivWidth - initialDivWidth, finalDivHeight = initialDivHeight + diffWidth;
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    90
        var finalDivTop = (initialDivTop - (finalDivHeight - snHeight)/2), finalDivLeft = (initialDivLeft - (finalDivWidth - snWidth)/2);
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    91
        
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    92
        //CAS PARTICULIER pour la position du snapshot zoomé : les bordures.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    93
        if(finalDivTop < 0)
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    94
        {
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    95
            finalDivTop = -margin;
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    96
        }
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    97
        if(finalDivTop + finalDivHeight > h)
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    98
        {
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
    99
            finalDivTop = h - finalDivHeight;
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   100
        }
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   101
        if(finalDivLeft < 0)
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   102
        {
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   103
            finalDivLeft = 0;
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   104
        }
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   105
        if(finalDivLeft + finalDivWidth + margin*2 > w)
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   106
        {
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   107
            finalDivLeft = w - finalDivWidth - margin*2;
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   108
        }
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   109
        
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   110
        //On prézoom le div en le centrant sur le milieu du snapshot pointé.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   111
        $('#prezoomSnapshot-' + currentId).animate(
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   112
        {
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   113
            width: finalDivWidth + margin,
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   114
            height: finalDivHeight - margin*2,
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   115
            top: finalDivTop + margin,
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   116
            left: finalDivLeft + margin
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   117
        }, _this.config.timePrezoom);
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   118
        $('#prezoomContainer-' + currentId).animate(
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   119
        {
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   120
            width: finalDivWidth + margin*2,
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   121
            height: finalDivHeight - margin,
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   122
            top: finalDivTop + margin,
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   123
            left: finalDivLeft
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   124
        }, _this.config.timePrezoom, function()
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   125
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   126
			//On a fini de prézoomer.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   127
			_this.isPrezooming = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   128
            //Si on est en mode Kinect.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   129
            if(!_this.config.mouseInteractions)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   130
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   131
                //On met le spinner gif sur le pointeur, s'il n'existe pas déjà.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   132
                if($('#spinner').length == 0)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   133
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   134
                    //On repère le pointeur ayant provoqué le prezoom.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   135
                    var prezoomPointer;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   136
                    if(!_this.isMainPointerDisplayed)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   137
                    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   138
                        prezoomPointer = $('#secondPointer');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   139
                    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   140
                    if(!_this.isSecondPointerDisplayed)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   141
                    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   142
                        prezoomPointer = $('#mainPointer');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   143
                    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   144
                    
58
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   145
                    //On crée le spinner s'il y a un pointeur qui indique le temps restant avant le zoom.
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   146
					if(prezoomPointer != null && prezoomPointer.length > 0)
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   147
					{
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   148
						var spinner = "<img id='spinner'></div>";
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   149
						$('body').append(spinner);
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   150
						$('#spinner').css(
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   151
						{
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   152
							position: 'absolute',
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   153
							top: prezoomPointer.position().top,
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   154
							left: prezoomPointer.position().left,
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   155
							width: 85,
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   156
							height: 85,
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   157
							'z-index': 600
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   158
						});
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   159
						$('#spinner').attr('src', './img/cursors/selector_anim_2.gif');
a28488078053 Front IDILL:
bastiena
parents: 55
diff changeset
   160
					}
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   161
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   162
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   163
            //Si on est en mode d'interaction souris, on indique juste qu'on est en prezoom.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   164
            else
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   165
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   166
                _this.isOnAPrezoomSN = true;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   167
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   168
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   169
            //Si on est en mode mosaic, on indique juste qu'on effectue une selection.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   170
            if(_this.currentMode == 'MOSAIC')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   171
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   172
                _this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   173
                _this.mosaicSelection();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   174
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   175
            //Si on est en filtrage, mais qu'on n'a pas encore de gesture de filtrage, on indique qu'on est en filtrage et en selection.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   176
            else if(_this.currentMode == 'FILTER' && !_this.filterSearchedType && _this.curvesGesturesFound)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   177
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   178
                _this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   179
                _this.filterSearchAndSelection();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   180
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   181
            //Si on est en filtrage avec une gesture de recherche, on indique la gesture et la selection.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   182
            else if(_this.currentMode == 'FILTER' && _this.filterSearchedType)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   183
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   184
                _this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   185
                _this.filterGestureAndSelection(_this.filterSearchedType, 'valid');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   186
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   187
        });
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   188
    });
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   189
    
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   190
    //Si on est en mode Kinect, on zoom après un certain temps.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   191
    if(!this.config.mouseInteractions)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   192
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   193
        this.zoomTimeout = setTimeout(function()
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   194
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   195
            _this.zoom();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   196
        }, this.config.timeoutZoom);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   197
    }
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   198
}
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   199
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   200
/*
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   201
 * Dézoome sur la position de l'image. Il est à noter que ce dézoome diffère du dézoom global dans la mesure où celui-ci ne concerne que l'image sur laquelle on a zoomé.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   202
 * Est appelé dans les fichiers :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   203
 * pointers > fonction pointersMosaicInteractions.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   204
 * zoomInteractions > fonctions preZoom et zoom.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   205
 * mosaic > fonction onMouseMove.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   206
 * client > fonction processMsg.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   207
 */
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   208
Mosaic.prototype.preUnzoom = function()
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   209
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   210
    $('#spinner').remove();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   211
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   212
    var _this = this;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   213
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   214
    //On indique qu'on n'est plus en prezoom.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   215
    this.isOnAPrezoomSN = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   216
    clearTimeout(this.zoomTimeout);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   217
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   218
    //Si on est en mode mosaic, on indique qu'on peut pointer ou bien rechercher.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   219
    if(this.currentMode == 'MOSAIC')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   220
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   221
        this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   222
        this.mosaicSelectionAndSearch();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   223
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   224
    //Si on est en filtrage sans gesture, on indique qu'on est juste en filtrage.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   225
    else if(_this.currentMode == 'FILTER' && !this.filterSearchedType && !this.curvesGesturesFound)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   226
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   227
        this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   228
        this.filterSearch();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   229
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   230
    //Si on est en filtrage avec gesture, on indique la gesture de filtrage.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   231
    else if(_this.currentMode == 'FILTER' && this.filterSearchedType && !this.curvesGesturesFound)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   232
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   233
        this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   234
        this.filterGesture(this.filterSearchedType, 'valid');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   235
    }
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   236
    
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   237
    //On spécifie la marge afin de centrer le prédézoom.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   238
    var margin = this.marginWidth;
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   239
    //ID du snapshot précédemment pointé.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   240
    var id = this.previousId;
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   241
    //On rétrécit le snapshot de prézoom, puis on le supprime en donnant l'illusion qu'il s'agissait du véritable snapshot, alors qu'en fait c'était un clone.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   242
    for(var i = 0 ; i < this.config.imagesToShow ; i++)
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   243
    {
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   244
        if($('#prezoomContainer-snapshot-' + i).length > 0)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   245
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   246
            $('#prezoomContainer-snapshot-' + i).animate(
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   247
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   248
                width: this.snapshotWidth + margin,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   249
                height: this.snapshotHeight + margin,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   250
                top: $('#snapshotDiv-' + i).position().top,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   251
                left: $('#snapshotDiv-' + i).position().left
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   252
            }, this.config.preUnzoomTime, function(){ $(this).remove(); _this.zoomed = false; });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   253
            $('#prezoomSnapshot-snapshot-' + i).animate(
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   254
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   255
                width: this.snapshotWidth,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   256
                height: this.snapshotHeight,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   257
                top: $('#snapshotDiv-' + i).position().top,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   258
                left: $('#snapshotDiv-' + i).position().left
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   259
            }, this.config.preUnzoomTime);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   260
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   261
    }
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   262
}
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   263
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   264
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   265
/*
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   266
 * Zoom d'un snapshot en plein écran.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   267
 * Est appelé dans les fichiers :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   268
 * zoomInteractions > fonction preZoom.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   269
 * mosaic > fonctions onMouseUp et init.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   270
 */
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   271
Mosaic.prototype.zoom = function()
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   272
{
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   273
    var _this = this;
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   274
    
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   275
    //Si la mosaïque est en pleine écran, pas la peine de zoomer.
89
b6a115568b52 Front IDILL:
bastiena
parents: 79
diff changeset
   276
    if(this.currentMode == "VIDEO" || this.currentMode == "SEARCH" || this.currentMode.indexOf("INCOMING") > -1 || this.helpDisplayed || this.creditsDisplayed || this.isMosaicFiltering)
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   277
    {
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   278
        return;
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   279
    }
55
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   280
	
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   281
	//Si on est en mode d'interaction souris, on enlève la bordure d'aide.
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   282
	if(this.config.mouseInteractions)
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   283
	{
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   284
		this.removeHelpIcon();
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   285
	}
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   286
    
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   287
    //On prend les attributs nécessaires au calculs.
55
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   288
    var margin = this.marginWidth, len = this.config.imagesByLine, imgs = this.config.imagesToShow, zoomedMargin = this.config.zoomedMargin;
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   289
    var zoomPercentage = this.config.zoomPercentage;
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   290
    var initMPWidth = this.previousZoomedSN.width() * len + margin*len, initMPHeight = this.previousZoomedSN.height() * (imgs / len) + margin*(imgs / len);
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   291
    var newMPWidth = initMPWidth * len + zoomedMargin * (len), newMPHeight = initMPHeight * (imgs / len) + zoomedMargin * ((imgs / len));
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   292
    var newPreMPWidth = initMPWidth * len * zoomPercentage + zoomedMargin * (len), newPreMPHeight = initMPHeight * (imgs / len) * zoomPercentage + zoomedMargin * ((imgs / len));
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   293
    
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   294
    //Dimensions et coordonnées initiales du div sur lequel on zoom.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   295
    var initialDivWidth = this.previousZoomedSN.width(), initialDivHeight = this.previousZoomedSN.height();
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   296
    var initialDivTop = this.previousZoomedSN.position().top, initialDivLeft = this.previousZoomedSN.position().left;
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   297
    //Dimensions et coordonnées finales du div.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   298
    var finalDivWidth = initialDivWidth * (zoomPercentage+1), finalDivHeight = initialDivHeight * (zoomPercentage+1);
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   299
    var newZoomTop = -this.previousZoomedSN.position().top*(newPreMPHeight/initMPHeight) - zoomedMargin/2 + (initMPHeight - initMPHeight * zoomPercentage)/2, newZoomLeft = -this.previousZoomedSN.position().left*(newPreMPWidth/initMPWidth) - zoomedMargin/2 + (initMPWidth - initMPWidth * zoomPercentage)/2;
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   300
    var newSnWidth = initMPWidth * zoomPercentage, newSnHeight = initMPHeight * zoomPercentage;
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   301
    
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   302
    this.preUnzoom();
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   303
    /*SINGULARITE*/
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   304
    this.fullscreen = true;
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   305
    
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   306
    //On passe l'image du snapshot pointé en HD.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   307
    var zoomedImg = $('img', this.previousZoomedSN);
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   308
    var src = zoomedImg.attr('src');
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   309
    zoomedImg.attr('src', src.replace('-little/', '/'));
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   310
    
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   311
    //On récupère son ID.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   312
    var tab, zoomedImgId;
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   313
    tab = _this.previousId.split('-');
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   314
    zoomedImgId = tab[1];
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   315
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   316
    //On donne les dimensions des snapshots.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   317
    $('.snapshotDivs').animate(
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   318
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   319
        width: newSnWidth,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   320
        height: newSnHeight,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   321
        margin: zoomedMargin/2 + 'px',
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   322
    }, this.config.zoomTime);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   323
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   324
    if(this.currentMode != 'NO-USER')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   325
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   326
        //Les snapshots baissent alors en opacité, donnant l'impression qu'ils sont grisés.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   327
        $('.snapshotDivs').animate(
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   328
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   329
            opacity: '0.4'
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   330
        }, this.config.zoomTime);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   331
        //Le snapshot du milieu revient à une opacité optimale, ce qui attire l'attention de l'utilisateur.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   332
        $(this.previousZoomedSN).animate(
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   333
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   334
            opacity: '1'
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   335
        }, this.config.zoomTime);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   336
    }
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   337
    //On zoome sur la mosaïque.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   338
    $('#mainPanel').animate(
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   339
    {
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   340
        width: newPreMPWidth,
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   341
        height: newPreMPHeight,
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   342
        top: newZoomTop,
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   343
        left: newZoomLeft
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   344
    }, this.config.zoomTime, function()
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   345
    {
55
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   346
		//Si on est en mode d'interaction souris, on affiche la bordure d'aide.
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   347
		if(_this.config.mouseInteractions)
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   348
		{
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   349
			_this.helpIcon();
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   350
		}
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   351
		
77
205409da0f32 Front IDILL:
bastiena
parents: 61
diff changeset
   352
		//Si on est sur une tablette, on affiche l'icone de retour.
205409da0f32 Front IDILL:
bastiena
parents: 61
diff changeset
   353
		if(_this.isTablet)
205409da0f32 Front IDILL:
bastiena
parents: 61
diff changeset
   354
		{
205409da0f32 Front IDILL:
bastiena
parents: 61
diff changeset
   355
			_this.homeIcon();
205409da0f32 Front IDILL:
bastiena
parents: 61
diff changeset
   356
		}
205409da0f32 Front IDILL:
bastiena
parents: 61
diff changeset
   357
		
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   358
        _this.snTop = (zoomedImg.position().top + newZoomTop + _this.MPTop_margin), _this.snLeft = (zoomedImg.position().left + newZoomLeft);
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   359
        _this.snWidth = newSnWidth + 1, _this.snHeight = newSnHeight + 1;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   360
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   361
        _this.notifyTopVideo = newZoomTop;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   362
        _this.notifyLeftVideo = newZoomLeft;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   363
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   364
        //On charge les interactions avec les voisins.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   365
        _this.centerId = zoomedImgId;
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   366
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   367
        //Si on n'est pas en mode sans utilisateur, on passe en mode video et on regarde les voisins.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   368
        if(_this.currentMode != "NO-USER")
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   369
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   370
            _this.currentMode = 'VIDEO';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   371
            _this.listenToNeighbours();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   372
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   373
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   374
        //Si on a une recherche dans cette video.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   375
        if(_this.currentSearchGesture[_this.centerId] != '')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   376
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   377
            //On passe en recherche en indiquant la gesture de recherche.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   378
            _this.currentMode = 'SEARCH';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   379
            _this.isCurrentlyInASearchByGesture = true;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   380
            _this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   381
            _this.searchGesture(_this.currentSearchGesture[_this.centerId], 'valid');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   382
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   383
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   384
        //On enlève le spinner et on redonne les apparences par défaut aux pointeurs.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   385
        $('#spinner').remove();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   386
        $('#mainPointer').css('background-image', 'url(./img/cursors/pointer.png)');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   387
        $('#secondPointer').css('background-image', 'url(./img/cursors/pointer2.png)');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   388
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   389
        //On charge le player.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   390
        _this.loadPlayer(_this.snTop, _this.snLeft, _this.snWidth, _this.snHeight, newZoomTop, newZoomLeft, _this.timeToGoAt[_this.centerId]);
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   391
    });
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   392
}
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   393
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   394
/*
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   395
 * Retour à la taille normale de la mosaïque.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   396
 * Est appelé dans les fichiers :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   397
 * neighbours > fonction checkForDezoom.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   398
 * zoomInteractions > fonction zoom.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   399
 * mosaic > fonctions showNImages et onPlayerLoad.
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   400
 */
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   401
Mosaic.prototype.unzoom = function()
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   402
{
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   403
    //Si on n'est pas en plein écran, on quitte.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   404
    if(this.currentMode != "SEARCH" && this.currentMode != "VIDEO" && this.currentMode != "NO-USER" && this.currentMode.indexOf("INCOMING") == -1)
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   405
    {
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   406
        return;
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   407
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   408
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   409
    var _this = this;
55
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   410
	
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   411
	//Si on est en mode d'interaction souris, on enlève la bordure d'aide.
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   412
	if(this.config.mouseInteractions)
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   413
	{
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   414
		this.removeHelpIcon();
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   415
	}
77
205409da0f32 Front IDILL:
bastiena
parents: 61
diff changeset
   416
	
205409da0f32 Front IDILL:
bastiena
parents: 61
diff changeset
   417
	//Si on est sur une tablette, on enlève l'icone de retour.
205409da0f32 Front IDILL:
bastiena
parents: 61
diff changeset
   418
	if(this.isTablet)
205409da0f32 Front IDILL:
bastiena
parents: 61
diff changeset
   419
	{
205409da0f32 Front IDILL:
bastiena
parents: 61
diff changeset
   420
		this.removeHomeIcon();
205409da0f32 Front IDILL:
bastiena
parents: 61
diff changeset
   421
	}
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   422
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   423
    //Il n'est plus possible de swiper.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   424
    this.canSwipe = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   425
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   426
    //Si la TL avait été sélectionnée, on la déselectionne.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   427
    if(this.currentMode == 'TIMELINE')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   428
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   429
        this.exitTimeline('unzoom');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   430
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   431
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   432
    //On indique qu'on est en train de dezoomer.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   433
    this.currentlyUnzooming = true;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   434
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   435
    //On supprime les voisins additionnels et on déselectionne les voisins.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   436
    this.removeAdditionalNeighbours();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   437
    this.deselectAllNeighbours();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   438
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   439
    this.snTop = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   440
    this.snLeft = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   441
    this.Width = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   442
    this.snHeight = 0;
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   443
    
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   444
    //On charge les attributs nécessaires aux calculs.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   445
    var sWidth = this.snapshotWidth, sHeight = this.snapshotHeight;
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   446
    var mpWidth = this.width, mpHeight = this.height;
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   447
    var _this = this;
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   448
    
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   449
    //On passe le snapshot sur lequel on a zoomé en SD.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   450
    var zoomedImg = $('img', this.previousZoomedSN);
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   451
    var src = zoomedImg.attr('src');
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   452
    zoomedImg.attr('src', src.replace('snapshots/', 'snapshots-little/'));
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   453
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   454
    //On libère le player.
77
205409da0f32 Front IDILL:
bastiena
parents: 61
diff changeset
   455
    if(_this.player && _this.player.widgets && _this.player.widgets[0])
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   456
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   457
        _this.timeToGoAt[_this.centerId] = Math.floor(_this.player.popcorn.currentTime());
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   458
        _this.player.widgets[0].freePlayer();
61
5292b7e88eed Front IDILL :
bastiena
parents: 58
diff changeset
   459
		_this.player = null;
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   460
		_this.isVideoReading = false;
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   461
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   462
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   463
    //On indique que le player n'est pas prêt et on le supprime.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   464
    _this.playerIsReady = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   465
    $('.LdtPlayer').remove();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   466
    $('body').append('<div class="LdtPlayer" id="LdtPlayer"></div>');
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   467
    
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   468
    //On rend leur opacité aux snapshots. Qui ne sont alors plus grisés.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   469
    $('.snapshotDivs').animate(
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   470
    {
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   471
        width: sWidth,
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   472
        height: sHeight,
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   473
        margin: this.marginWidth/2 + 'px'
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   474
    }, this.config.unzoomTime, function()
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   475
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   476
        //Après le dezoom, on indique qu'on a finit de dezoomer.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   477
        _this.neighboursIds.length = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   478
        _this.currentlyUnzooming = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   479
    });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   480
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   481
    //Si l'utilisateur est là.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   482
    if(this.currentMode != 'NO-USER')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   483
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   484
        //Si l'utilisateur est déjà au moins d'interaction maximal et que la mosaique n'est pas filtrée, on rend visibles tous les snapshots.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   485
        if(this.currentMode.indexOf("INCOMING") == -1 && !this.isMosaicFiltered)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   486
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   487
            $('.snapshotDivs').animate(
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   488
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   489
                opacity: '1'
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   490
            }, this.config.unzoomTime);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   491
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   492
        //Si l'utilisateur est déjà au moins d'interaction maximal et que la mosaique est filtrée, on réapplique le filtre sur la mosaique.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   493
        else if(this.currentMode.indexOf("INCOMING") == -1 && this.isMosaicFiltered)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   494
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   495
            for(var i = 0 ; i < this.config.imagesToShow ; i++)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   496
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   497
                $('#snapshotDiv-' + i).animate(
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   498
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   499
                    opacity: this.opacities[i]
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   500
                }, this.config.unzoomTime);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   501
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   502
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   503
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   504
    //Si on est en mode sans utilisateur.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   505
    else
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   506
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   507
        //On sélectionne un autre snapshot pour le jouer dans le player.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   508
        this.previousZoomedSN.fadeTo(this.config.unzoomTime, 0, function()
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   509
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   510
            _this.init();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   511
        });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   512
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   513
    
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   514
    //On dézoom sur la mosaïque.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   515
    $('#mainPanel').animate(
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   516
    {
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   517
        width: mpWidth,
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   518
        height: mpHeight,
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   519
        top: '0px',
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   520
        left: '0px'
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   521
    }, this.config.unzoomTime, function()
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   522
    {
77
205409da0f32 Front IDILL:
bastiena
parents: 61
diff changeset
   523
		//Si on est en mode d'interaction souris, on affiche l'icone d'aide.
55
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   524
		if(_this.config.mouseInteractions)
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   525
		{
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   526
			_this.helpIcon();
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   527
		}
afd60399a7b5 Front IDILL :
bastiena
parents: 52
diff changeset
   528
		
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   529
        //On n'est plus en plein écran, et on ne peut plus se déplacer vers le prochain voisin.
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   530
        _this.fullscreen = false;
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   531
        _this.canMoveToNeighbour = false;
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   532
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   533
        //Si on est au point d'interaction maximal.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   534
        if(_this.currentMode != 'NO-USER' && _this.currentMode.indexOf('INCOMING-') == -1)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   535
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   536
            //Si la mosaique est filtrée, on revient en mode de filtrage, sinon en mode mosaic.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   537
            if(_this.isMosaicFiltered)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   538
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   539
                _this.currentMode = 'FILTER';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   540
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   541
            else
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   542
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   543
                _this.currentMode = 'MOSAIC';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   544
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   545
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   546
            //On remet les notifications initiales si on n'est pas dans une recherche par filtrage.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   547
            if(_this.currentMode == 'MOSAIC' && !_this.filterSearchedType)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   548
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   549
                _this.removeNotifications();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   550
                _this.mosaicSelectionAndSearch();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   551
            }
77
205409da0f32 Front IDILL:
bastiena
parents: 61
diff changeset
   552
			//Sinon on met la gesture en cours.
205409da0f32 Front IDILL:
bastiena
parents: 61
diff changeset
   553
			else if(_this.currentMode == 'FILTER' && _this.filterSearchedType != '')
205409da0f32 Front IDILL:
bastiena
parents: 61
diff changeset
   554
			{
205409da0f32 Front IDILL:
bastiena
parents: 61
diff changeset
   555
				//On notifie.
205409da0f32 Front IDILL:
bastiena
parents: 61
diff changeset
   556
				_this.removeNotifications();
205409da0f32 Front IDILL:
bastiena
parents: 61
diff changeset
   557
				_this.filterGesture(_this.filterSearchedType, 'valid');
205409da0f32 Front IDILL:
bastiena
parents: 61
diff changeset
   558
			}
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   559
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   560
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   561
        //On indique qu'on est plus en dezoom.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   562
        this.currentlyUnzooming = false;
44
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   563
    });
8393d3473b98 Front IDILL:
bastiena
parents:
diff changeset
   564
}