front_idill/src/mosaic/js/mosaic.js
author bastiena
Wed, 30 May 2012 10:21:36 +0200
changeset 35 4267d6d27a7d
parent 33 2d9b15f99b4e
child 44 8393d3473b98
permissions -rw-r--r--
Front IDILL : Config file added dor the Front Random play at the beginning (when no user is detected) Pointers added Curves added (search and filter modes) Mosaic completion added (depletion to come later) State of the Front : just before the communication module creation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
     1
/*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
     2
* This file is part of the TraKERS\Front IDILL package.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
     3
*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
     4
* (c) IRI <http://www.iri.centrepompidou.fr/>
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
     5
*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
     6
* For the full copyright and license information, please view the LICENSE
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
     7
* file that was distributed with this source code.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
     8
*/
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
     9
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    10
/*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    11
 * Projet : TraKERS
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    12
 * Module : Front IDILL
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    13
 * Fichier : mosaic.js
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    14
 * 
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    15
 * Auteur : alexandre.bastien@iri.centrepompidou.fr
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    16
 * 
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    17
 * Fonctionnalités : Définit la "classe" mosaïque et définit des fonctions d'intéractions.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    18
 */
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    19
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    20
/*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    21
 * Classe définissant la mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    22
 * Elle contient sa longueur, le nombre d'images total, une liste d'urls pour les vidéos, leurs snapshots principaux et leur position.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    23
 * Contient également les dimensions en px de la mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    24
 */
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    25
function mosaic(config, default_conf)
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    26
{
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    27
	//Chemin du fichier de configuration.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    28
	this.config_path = config;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    29
	//Configuration par défaut en cas de valeur erronnée.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    30
	this.default_config = default_conf;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    31
	this.config = new Object();
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    32
	//Tableaux des urls des vidéos, des snapshots et de leur position dans la mosaïque.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    33
	this.videos = [];
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    34
	this.urls = [];
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    35
	this.imgs = [];
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    36
	this.ids = [];
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    37
	this.fillingIds = [];
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    38
	this.currentRandomVideoIdx = 0;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    39
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    40
	//Dimensions de la mosaïque en pixels.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    41
	this.width;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    42
	this.height;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    43
	//Dimensions d'un snapshot en pixels.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    44
	this.snapshotWidth;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    45
	this.snapshotHeight;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    46
	//Espacement entre les snapshots en pixels.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    47
	this.marginWidth;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    48
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    49
	//Booléens permettant ou non certaines intéractions selon le contexte.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    50
	this.zoomed;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    51
	this.fullscreen;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    52
	this.canMoveToNeighbour;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    53
	this.helpDisplayed;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    54
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    55
	//Type de marqueur recherché dans la mosaïque (en mode filter).
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    56
	this.filterSearchedType = "";
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    57
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    58
	//Mode actuel.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    59
	this.currentMode = "MOSAIC";
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    60
	//Snapshot sur lequel on a zoomé.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    61
	this.previousZoomedSN;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    62
	//Son ID.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    63
	this.previousId;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    64
	//Largeur de la marge pour le centrage vertical de la mosaïque.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    65
	this.MPTop_margin;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    66
	this.top_margin;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    67
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    68
	//Mosaïque locale.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    69
	this.localMos;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    70
	//Position des voisins lors d'un zoom.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    71
	this.neighboursIds = [];
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    72
	//ID du snapshot du milieu lors d'un zoom.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    73
	this.centerId;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    74
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    75
	//Snapshots a afficher.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    76
	this.snapshotsToShow = 1;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    77
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    78
	//Lecteur.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    79
	this.player;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    80
	//Annotations (pour les marqueurs los d'un filtrage).
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    81
	this.annotations = [];
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    82
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    83
	//Coordonnées et dimensions d'un snapshot zoomé.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    84
	this.snTop = 0;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    85
	this.snLeft = 0;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    86
	this.snWidth = 0;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    87
	this.snHeight = 0;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    88
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    89
	this.searchCanvas;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    90
	//Position actuelle de la vidéo zoomée.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    91
	this.notifyTopVideo;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    92
	this.notifyLeftVideo;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
    93
	this.loadParameters(this.config_path);
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    94
}
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    95
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    96
/*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    97
 * Méthode d'affichage de la mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    98
 * Génère une matrice de imgs.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
    99
 */
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   100
mosaic.prototype.createMosaic = function()
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   101
{
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   102
	console.log('CREATE');
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   103
	this.currentMode = "NO-USER";
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   104
	var initPanel = '<div id="initPanel"></div>';
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   105
	var mp = $('#mainPanel');
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   106
	mp.append(initPanel);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   107
	$('#initPanel').css(
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   108
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   109
		background: 'transparent',
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   110
		width: mp.width(),
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   111
		height: mp.height(),
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   112
		top: mp.position().top,
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   113
		left: mp.position().left,
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   114
		'margin-top': this.MPTop_margin
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   115
	});
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   116
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   117
	var len = this.config['length'], imgs = this.config['imagesToShow'], imgsTotal = this.config['imagesTotal'];
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   118
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   119
	//S'il s'agit d'un rectangle.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   120
    if(imgs % len == 0)
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   121
    {
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   122
		this.previousZoomedSN = '';
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   123
		this.previousPrezoomDiv = '';
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   124
		this.fullscreen = false;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   125
		this.canMoveToNeighbour = false;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   126
		this.helpDisplayed = false;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   127
		var str = '';
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   128
		
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   129
		if(this.imgs.length >= imgs)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   130
		{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   131
			for(var i = 0 ; i < imgs ; i++)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   132
			{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   133
				//On charge les images de petite taille pour ne pas surcharger la mosaïque lors de l'affichage global.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   134
				str += '<div id="snapshotDiv-' + i + '" class="snapshotDivs" style="opacity: 0;"><img id="snapshot-' + i + '" class="snapshots" src="snapshots-little/' + this.imgs[i] + '" /></div>';
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   135
			}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   136
		}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   137
		
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   138
		return str;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   139
	}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   140
	else
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   141
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   142
		alert("Le nombre d'images a afficher doit être divisible par la longueur de la mosaïque !");
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   143
	}
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   144
}
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   145
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   146
/*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   147
 * Permet de raffraichir la mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   148
 */
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   149
mosaic.prototype.loadMosaic = function()
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   150
{
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   151
	console.log('LOAD');
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   152
	var createMosaic = this.createMosaic();
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   153
	
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   154
	if(createMosaic == '')
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   155
	{
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   156
		return;
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   157
	}
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   158
	
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   159
	var _this = this;
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   160
	
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   161
    //On affecte les chemins vers les images à la mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   162
    this.previousZoomedSN;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   163
    //this.width = 
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   164
    //On met à jour la mosaïque.
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   165
    $('#mainPanel').html(createMosaic);
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   166
    //On récupère la taille des bordures.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   167
    this.marginWidth = $('.snapshotDivs').css('margin-bottom');
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   168
    this.marginWidth = parseFloat(this.marginWidth)*2;
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   169
    //On calcule la taille des divs contenant les snapshots.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   170
    this.width = $('#mainPanel').innerWidth();
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   171
    //On ne calculera pas tout de suite la hauteur de la mosaique étant donnée qu'elle est calculée par la suite dynamiquement.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   172
    this.snapshotWidth = this.width / this.config['length'] - this.marginWidth;
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   173
    this.snapshotHeight = this.snapshotWidth*9/16;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   174
    $('.snapshotDivs').css('width', this.snapshotWidth).css('height', this.snapshotHeight).css('margin', this.marginWidth/2);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   175
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   176
    this.height = $('#mainPanel').innerHeight();
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   177
    //On centre verticalement la mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   178
    this.MPTop_margin = ($(document).height() - $('#mainPanel').height())/2;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   179
    $('#mainPanel').css('margin-top', this.MPTop_margin).css('margin-bottom', this.MPTop_margin);
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   180
	
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   181
	//On affiche les notifications.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   182
	this.notifySelectionSearchMosaicFull();
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   183
	
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   184
	$('.snapshotDivs').mouseenter(function ()
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   185
	{
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   186
		//On effectue un prézoom dès qu'on va sur une image.
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   187
		_this.preZoom($(this));
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   188
	});
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   189
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   190
	this.addPointers();
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   191
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   192
	//Si dans le metadata player _ n'est pas déclaré, on le déclare.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   193
	if(typeof _ !== "undefined" && typeof IriSP._ === "undefined")
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   194
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   195
		IriSP._ = _;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   196
	}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   197
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   198
	if(typeof $ !== "undefined" && typeof IriSP.jQuery === "undefined")
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   199
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   200
		IriSP.jQuery = $;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   201
	}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   202
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   203
	//On charge les marqueurs.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   204
	var sourceManager = new IriSP.Model.Directory(),
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   205
	globalAnnotations = new IriSP.Model.List(sourceManager),
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   206
	nbFichiers = _this.urls.length,
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   207
	fichiersCharges = 0;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   208
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   209
	for (var i = 0; i < nbFichiers; i++)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   210
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   211
		console.log('url : ' + _this.urls[i]);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   212
		var source = sourceManager.remoteSource({url: _this.urls[i], serializer: IriSP.serializers.ldt});
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   213
		source.onLoad(function()
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   214
		{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   215
			globalAnnotations.addElements(source.getAnnotations());
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   216
			fichiersCharges++;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   217
			if (fichiersCharges == nbFichiers)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   218
			{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   219
				// instructions à exécuter quand tout est chargé
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   220
				_this.annotations = globalAnnotations;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   221
				console.log('annotations loaded');
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   222
				_this.init();
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   223
			}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   224
		});
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   225
	}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   226
}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   227
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   228
/*
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   229
 * Charge les paramètres du Front. Local (true/false) est le mode de chargement des données.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   230
*/
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   231
mosaic.prototype.loadParameters = function(file_path)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   232
{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   233
	var _this = this;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   234
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   235
	var supposedToBeInt = ['length', 'imagesToShow', 'totalImages', 'timePrezoom', 'timePreUnzoom', 'timeZoom', 'timeUnzoom', 'timeNeighbourGlowing', 'timeNeighbourUnglowing', 'timeMovingToNeighbour', 'timeSearchFade', 'timeNotifyFade', 'timeFilterFade', 'timeFilling', 'zoomedMargin'];
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   236
	var supposedToBeFloat = ['zoomPercentage', 'prezoomPercentage'];
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   237
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   238
	$.getJSON(file_path, function(data)
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   239
	{
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   240
		for(key in data)
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   241
		{
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   242
			var val = data[key];
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   243
			
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   244
			if(_.include(supposedToBeInt, key))
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   245
			{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   246
				var intVal = parseInt(val);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   247
				if(isNaN(intVal))
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   248
				{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   249
					console.log(_this.default_config);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   250
					_this.config[key] = _this.default_config[key];
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   251
					console.log("param[" + key + "] : Valeur " + val + " incorrecte (non Int). Valeur par défaut " + _this.default_config[key] + " chargée à la place.");
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   252
				}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   253
				else
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   254
				{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   255
					_this.config[key] = intVal;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   256
				}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   257
			}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   258
			else if(_.include(supposedToBeFloat, key))
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   259
			{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   260
				var floatVal = parseFloat(val);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   261
				if(isNaN(floatVal))
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   262
				{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   263
					_this.config[key] = _this.default_config[key];
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   264
					console.log("param[" + key + "] : Valeur " + val + " incorrecte (non Float). Valeur par défaut " + _this.default_config[key] + " chargée à la place.");
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   265
				}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   266
				else
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   267
				{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   268
					_this.config[key] = floatVal;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   269
				}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   270
			}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   271
			else
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   272
			{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   273
				_this.config[key] = val;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   274
			}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   275
		}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   276
		
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   277
		//On remplit le tableau d'ids.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   278
		for(var i = 0 ; i < _this.config['totalImages'] ; i++)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   279
			_this.ids.push(i);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   280
		//On les mélange.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   281
		_this.ids.sort(function()
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   282
		{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   283
			return 0.5 - Math.random()
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   284
		});
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   285
		
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   286
		//On remplit le tableau d'ids destiné à afficher les snapshots au fur et à mesure.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   287
		for(var i = 0 ; i < _this.config['imagesToShow'] ; i++)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   288
			_this.fillingIds.push(i);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   289
		//On les mélange.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   290
		_this.fillingIds.sort(function()
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   291
		{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   292
			return 0.5 - Math.random()
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   293
		});
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   294
		
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   295
		if(_this.config['local'] == 'true')
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   296
		{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   297
			console.log("Loading local metadata.");
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   298
			_this.loadFromJson('./player/json/local_videos.json');
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   299
		}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   300
		else
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   301
		{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   302
			console.log("Loading online metadata.");
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   303
			_this.loadFromJson('./player/json/online_videos.json');
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   304
		}
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   305
	});
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   306
}
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   307
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   308
/*
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   309
 * Phase principale (utilisateur non détecté). Une vidéo se lance aléatoirement.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   310
 * L'interface est identique à celle du zoom, mais sans interaction possible avec les voisins, ni les controles timeline.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   311
 * Lors de la fin d'une lecture, on dézoome vers la mosaïque, puis on rezoome vers un autre snapshot (aléatoire).
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   312
*/
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   313
mosaic.prototype.init = function()
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   314
{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   315
	var _this = this;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   316
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   317
	if(this.currentRandomVideoIdx > this.config['imagesToShow'])
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   318
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   319
		this.currentRandomVideoIdx = 0;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   320
	}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   321
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   322
	this.previousZoomedSN = $('#snapshotDiv-' + this.fillingIds[this.currentRandomVideoIdx]);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   323
	this.previousId = $('img', this.previousZoomedSN).attr('id');
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   324
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   325
	console.log('ids', this.fillingIds[this.currentRandomVideoIdx]);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   326
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   327
	this.previousZoomedSN.fadeTo(this.config['timePrezoom'], 1, function()
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   328
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   329
		_this.zoom();
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   330
		_this.currentRandomVideoIdx++;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   331
	});
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   332
}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   333
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   334
/*
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   335
 * Remplissage de la mosaïque en fonction du nombre d'images à afficher.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   336
*/
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   337
mosaic.prototype.showNImages = function(n)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   338
{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   339
	if(n > 1)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   340
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   341
		this.currentMode = "INCOMING-" + n;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   342
		this.unzoom();
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   343
	}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   344
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   345
	for(var i = 0 ; i < n ; i++)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   346
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   347
		if($('#snapshotDiv-' + i).css('opacity') < 1)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   348
		{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   349
			$('#snapshotDiv-' + i).fadeTo(this.config['timeFilling'], 1);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   350
		}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   351
	}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   352
}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   353
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   354
/*
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   355
 * Affiche les pointeurs.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   356
*/
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   357
mosaic.prototype.addPointers = function()
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   358
{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   359
	var _this = this;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   360
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   361
	var mainPointer = '<div id="mainPointer" class="pointers"></div>';
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   362
	$('body').append(mainPointer);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   363
	$('body').mousemove(function(evt)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   364
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   365
		$('#mainPointer').css(
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   366
		{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   367
			top: evt.pageY - $('#mainPointer').height()/2,
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   368
			left: evt.pageX - $('#mainPointer').width()/2
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   369
		});
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   370
	});
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   371
}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   372
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   373
/*
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   374
 * Gère les événements de contrôle dans la mosaïque.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   375
*/
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   376
mosaic.prototype.manageControlEvents = function(event)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   377
{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   378
	console.log('manage');
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   379
	//Sinon si on a appuyé sur 'g' ou 'G'.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   380
	if(event.which == 103 || event.which == 71)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   381
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   382
		//Si on est déjà en recherche par courbes.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   383
		if(this.currentMode == "SEARCH" || this.currentMode == "FILTER")
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   384
		{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   385
			//On quitte cette recherche.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   386
			this.leaveSearch();
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   387
			//Si on était en mode recherche.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   388
			if(this.currentMode == "SEARCH")
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   389
			{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   390
				//On revient dans la vidéo.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   391
				this.currentMode = "VIDEO";
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   392
			}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   393
			else
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   394
			{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   395
				//Sinon c'est qu'on était dans la mosaïque.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   396
				this.currentMode = "MOSAIC";
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   397
			}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   398
		}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   399
		else
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   400
		{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   401
			//Si on est en plein écran.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   402
			if(this.fullscreen)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   403
			{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   404
				//On entre en mode recherche.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   405
				this.currentMode = "SEARCH";
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   406
			}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   407
			//Sinon.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   408
			else
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   409
			{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   410
				//On entre en mode filtrage.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   411
				this.currentMode = "FILTER";
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   412
			}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   413
			
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   414
			this.startSearch();
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   415
		}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   416
	}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   417
	//Si c'est a ou A.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   418
	else if(event.which == 65 || event.which == 97)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   419
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   420
		if(!this.helpDisplayed)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   421
		{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   422
			this.notifyHelp();
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   423
		}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   424
		else
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   425
		{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   426
			this.removeHelp();
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   427
		}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   428
	}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   429
	//Si c'est v ou V.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   430
	else if(event.which == 86 || event.which == 118)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   431
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   432
		this.notifySearchMarkers('run;jump;fall');
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   433
	}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   434
	//Si c'est b ou B.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   435
	else if(event.which == 66 || event.which == 98)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   436
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   437
		this.removeSearchMarkers();
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   438
	}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   439
	//Si c'est k ou K.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   440
	else if(event.which == 75 || event.which == 107)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   441
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   442
		this.searchFilter('circle');
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   443
	}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   444
	//Si c'est l ou L.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   445
	else if(event.which == 76 || event.which == 108)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   446
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   447
		this.removeFilter();
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   448
	}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   449
	//Si on a appuié sur la touche 'q' ou 'Q';
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   450
	else if(event.which == 113 || event.which == 81)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   451
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   452
		this.unzoom();
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   453
	}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   454
	else if(event.which == 111 || event.which == 79)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   455
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   456
		if(this.snapshotsToShow > this.imagesToShow)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   457
		{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   458
			this.snapshotsToShow = this.imagesToShow;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   459
		}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   460
		else
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   461
		{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   462
			this.snapshotsToShow += 5;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   463
		}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   464
		
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   465
		this.showNImages(this.snapshotsToShow);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   466
	}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   467
}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   468
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   469
/*
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   470
 * Zoom sur la position d'une image, 1ère partie. Durant le laps de temps de time ms, l'utilisateur a le choix de zoomer sur une autre image.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   471
 * Après ce laps de temps, l'image zoom complétement et il n'est plus possible de sélectionner une autre image par pointage.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   472
 */
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   473
mosaic.prototype.preZoom = function(snapshot)
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   474
{
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   475
    if(this.fullscreen)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   476
	{
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   477
        return;
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   478
	}
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   479
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   480
	//On enlève les notifications initiales si elles existent.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   481
	this.removeSelectionSearchMosaicFull();
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   482
	
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   483
    //Mosaïque.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   484
    var _this = this;
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   485
    //Dimensions de la mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   486
    var h = this.height, w = this.width;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   487
    //Longueur en images, nombre d'images et taille de bordure de la mosaïque.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   488
    var len = this.config['length'], imgs = this.config['imagesToShow'], margin = this.marginWidth;
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   489
    //Dimensions et position d'un snapshot dans la mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   490
    var snHeight = this.snapshotHeight, snWidth = this.snapshotWidth;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   491
    var sTop = snapshot.position().top, sLeft = snapshot.position().left;
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   492
    var prezoomPercentage = this.config['prezoomPercentage'];
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   493
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   494
    //ID de l'image actuelle.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   495
    var currentId = $('img', snapshot).attr('id');
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   496
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   497
    //Si un zoom est déjà en cours, on ne zoom sur rien d'autre en attendant que ce snapshot ai dézoomé en cas de mouseleave.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   498
    if(this.zoomed)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   499
	{
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   500
        if($('#preZoomContainer-' + currentId) != $(this) && this.previousZoomedSN != '' && this.previousId != '')
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   501
		{
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   502
            this.preUnzoom();
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   503
		}
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   504
        else
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   505
		{
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   506
            return;
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   507
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   508
	}
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   509
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   510
    //On indique qu'on a zoomé et on spécifie le snapshot sur lequel on a zoomé.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   511
    this.zoomed = true;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   512
    this.previousZoomedSN = snapshot;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   513
    this.previousId = currentId;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   514
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   515
    //On récupère les attributs de l'image.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   516
    var fakeImg = $('img', snapshot);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   517
    //On forme la balise de la fausse image et on passe son url pour les grands snapshots.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   518
    fakeImg = '<img id="fake-' + currentId + '" class="snapshots" src="' + fakeImg.attr('src').replace('-little/', '/') + '" />';
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   519
    //On génère un faux snapshot identique au précédent et qu'on va coller dessus.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   520
    var fakeSnapshot = '<div id="prezoomContainer-' + currentId + '" class="prezoomContainers"><div id="prezoomSnapshot-' + currentId + '" class="snapshotDivs">' + fakeImg + '</div></div>';
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   521
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   522
    //On l'ajoute à la mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   523
    $('#mainPanel').append(fakeSnapshot);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   524
    //On modifie ses attributs.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   525
    $('#fake-' + currentId).load(function()
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   526
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   527
        $('#prezoomContainer-' + currentId).css('display', 'block');
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   528
        $('#prezoomContainer-' + currentId).css('top', sTop).css('left', sLeft).css('width', (snWidth + margin)).css('height', (snHeight + margin));
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   529
        $('#prezoomSnapshot-' + currentId).css('width', (snWidth)).css('height', (snHeight));
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   530
        
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   531
        //Dimensions et coordonnées initiales du div sur lequel on zoom.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   532
        var initialDivWidth = $('#prezoomContainer-' + currentId).width(), initialDivHeight = $('#prezoomContainer-' + currentId).height();
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   533
        var initialDivTop = $('#prezoomContainer-' + currentId).position().top, initialDivLeft = $('#prezoomContainer-' + currentId).position().left;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   534
        //Dimensions et coordonnées finales du div.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   535
        var finalDivWidth = initialDivWidth * (prezoomPercentage+1), diffWidth = finalDivWidth - initialDivWidth, finalDivHeight = initialDivHeight + diffWidth;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   536
        var finalDivTop = (initialDivTop - (finalDivHeight - snHeight)/2), finalDivLeft = (initialDivLeft - (finalDivWidth - snWidth)/2);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   537
        
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   538
        //CAS PARTICULIER pour la position du snapshot zoomé : les bordures.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   539
        if(finalDivTop < 0)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   540
		{
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   541
            finalDivTop = -margin;
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   542
		}
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   543
        if(finalDivTop + finalDivHeight > h)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   544
		{
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   545
            finalDivTop = h - finalDivHeight;
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   546
		}
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   547
        if(finalDivLeft < 0)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   548
		{
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   549
            finalDivLeft = 0;
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   550
		}
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   551
        if(finalDivLeft + finalDivWidth + margin*2 > w)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   552
		{
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   553
            finalDivLeft = w - finalDivWidth - margin*2;
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   554
		}
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   555
        
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   556
        ////Code de debug.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   557
        ////CAUTION////
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   558
        /*var red = '<div id="red"></div>';
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   559
        if($('#red') != null || $('#red') != undefined)
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   560
            $('body').append(red);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   561
        $('#red').css('background-color', '#FF0000').css('position', 'absolute').css('top', '0px').css('left', '0px').css('width', '100px').css('height', '100px');
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   562
        $('#red').css('top', finalDivTop).css('left', finalDivLeft).css('width', finalDivWidth).css('height', finalDivHeight);*/
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   563
        //alert("initial : " + initialDivWidth + " " + initialDivHeight + " ; final : " + finalDivWidth + " " + finalDivHeight);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   564
        ////CAUTION////
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   565
        
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   566
        //On prézoom le div en le centrant sur le milieu du snapshot pointé.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   567
        $('#prezoomSnapshot-' + currentId).animate(
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   568
        {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   569
            width: finalDivWidth + margin,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   570
            height: finalDivHeight - margin*2,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   571
            top: finalDivTop + margin,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   572
            left: finalDivLeft + margin
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   573
        }, _this.config['timePrezoom']);
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   574
        $('#prezoomContainer-' + currentId).animate(
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   575
        {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   576
            width: finalDivWidth + margin*2,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   577
            height: finalDivHeight - margin,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   578
            top: finalDivTop + margin,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   579
            left: finalDivLeft
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   580
        }, _this.config['timePrezoom'], function()
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   581
		{
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   582
			_this.notifyPointMosaicPrezoom();
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   583
		});
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   584
    });
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   585
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   586
    //Si on clique sur le snapshot prézoomé, on enclenche un zoom total sur ce snapshot.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   587
    $('#prezoomContainer-' + currentId).click(function ()
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   588
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   589
        if(this.previousZoomedSN != '')
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   590
		{
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   591
            _this.zoom();
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   592
		}
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   593
    });
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   594
}
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   595
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   596
/*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   597
 * Dézoome sur la position de l'image. Il est à noter que ce dézoome diffère du dézoom global dans la mesure où celui-ci ne concerne que l'image sur laquelle on a zoomé.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   598
 */
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   599
mosaic.prototype.preUnzoom = function()
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   600
{
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   601
    //Si on n'a pas zoomé, on quitte la fonction.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   602
    if(!this.zoomed)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   603
	{
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   604
        return;
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   605
	}
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   606
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   607
	this.removePointMosaicPrezoom();
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   608
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   609
    //On spécifie la marge afin de centrer le prédézoom.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   610
    var margin = this.marginWidth;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   611
    //ID du snapshot précédemment pointé.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   612
    var id = this.previousId;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   613
    //On ne zoom plus.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   614
    this.zoomed = false;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   615
    //On rétrécit le snapshot de prézoom, puis on le supprime en donnant l'illusion qu'il s'agissait du véritable snapshot, alors qu'en fait c'était un clone.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   616
    $('#prezoomSnapshot-' + id).animate(
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   617
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   618
        width: this.snapshotWidth,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   619
        height: this.snapshotHeight,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   620
        top: this.previousZoomedSN.position().top,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   621
        left: this.previousZoomedSN.position().left
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   622
    }, this.config['preUnzoomTime']);
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   623
    $('#prezoomContainer-' + id).animate(
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   624
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   625
        width: this.snapshotWidth + margin,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   626
        height: this.snapshotHeight + margin,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   627
        top: this.previousZoomedSN.position().top,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   628
        left: this.previousZoomedSN.position().left
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   629
    }, this.config['preUnzoomTime'], function(){ $(this).remove(); this.zoomed = false; });
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   630
}
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   631
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   632
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   633
/*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   634
 * Zoom d'un snapshot en plein écran.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   635
 */
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   636
mosaic.prototype.zoom = function()
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   637
{
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   638
    var _this = this;
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   639
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   640
    //Si la mosaïque est en pleine écran, pas la peine de zoomer.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   641
    if(this.currentMode == "VIDEO" || this.currentMode == "SEARCH")
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   642
	{
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   643
        return;
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   644
	}
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   645
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   646
	this.removePointMosaicPrezoom();
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   647
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   648
    //On prend les attributs nécessaires au calculs.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   649
    var margin = this.marginWidth, len = this.config['length'], imgs = this.config['imagesToShow'], zoomedMargin = this.config['zoomedMargin'];
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   650
	var zoomPercentage = this.config['zoomPercentage'];
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   651
    var initMPWidth = this.previousZoomedSN.width() * len + margin*len, initMPHeight = this.previousZoomedSN.height() * (imgs / len) + margin*(imgs / len);
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   652
    var newMPWidth = initMPWidth * len + zoomedMargin * (len), newMPHeight = initMPHeight * (imgs / len) + zoomedMargin * ((imgs / len));
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   653
    var newPreMPWidth = initMPWidth * len * zoomPercentage + zoomedMargin * (len), newPreMPHeight = initMPHeight * (imgs / len) * zoomPercentage + zoomedMargin * ((imgs / len));
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   654
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   655
    //Dimensions et coordonnées initiales du div sur lequel on zoom.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   656
    var initialDivWidth = this.previousZoomedSN.width(), initialDivHeight = this.previousZoomedSN.height();
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   657
    var initialDivTop = this.previousZoomedSN.position().top, initialDivLeft = this.previousZoomedSN.position().left;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   658
    //Dimensions et coordonnées finales du div.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   659
    var finalDivWidth = initialDivWidth * (zoomPercentage+1), finalDivHeight = initialDivHeight * (zoomPercentage+1);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   660
    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;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   661
    var newSnWidth = initMPWidth * zoomPercentage, newSnHeight = initMPHeight * zoomPercentage;
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   662
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   663
    this.preUnzoom(this);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   664
    /*SINGULARITE*/
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   665
    this.fullscreen = true;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   666
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   667
    //On passe l'image du snapshot pointé en HD.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   668
    var zoomedImg = $('img', this.previousZoomedSN);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   669
    var src = zoomedImg.attr('src');
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   670
    zoomedImg.attr('src', src.replace('-little/', '/'));
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   671
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   672
    //On récupère son ID.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   673
    var tab, zoomedImgId;
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   674
    tab = _this.previousId.split('-');
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   675
    zoomedImgId = tab[1];
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   676
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   677
	//On donne les dimensions des snapshots.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   678
	$('.snapshotDivs').animate(
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   679
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   680
		width: newSnWidth,
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   681
		height: newSnHeight,
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   682
		margin: zoomedMargin/2 + 'px',
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   683
	}, this.config['zoomTime']);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   684
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   685
	if(this.currentMode != 'NO-USER')
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   686
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   687
		//Les snapshots baissent alors en opacité, donnant l'impression qu'ils sont grisés.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   688
		$('.snapshotDivs').animate(
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   689
		{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   690
			opacity: '0.4'
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   691
		}, this.config['zoomTime']);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   692
		//Le snapshot du milieu revient à une opacité optimale, ce qui attire l'attention de l'utilisateur.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   693
		$(this.previousZoomedSN).animate(
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   694
		{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   695
			opacity: '1'
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   696
		}, this.config['zoomTime']);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   697
	}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   698
	
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   699
    //On zoome sur la mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   700
    $('#mainPanel').animate(
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   701
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   702
        width: newPreMPWidth,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   703
        height: newPreMPHeight,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   704
        top: newZoomTop,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   705
        left: newZoomLeft
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   706
    }, this.config['zoomTime'], function()
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   707
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   708
        //On charge les interactions avec les voisins.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   709
        _this.centerId = zoomedImgId;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   710
		
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   711
		if(_this.currentMode != "NO-USER")
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   712
		{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   713
			_this.currentMode = 'VIDEO';
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   714
			_this.listenToNeighbours();
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   715
		}
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   716
		
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   717
		_this.snTop = (zoomedImg.position().top + newZoomTop + _this.MPTop_margin), _this.snLeft = (zoomedImg.position().left + newZoomLeft);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   718
		_this.snWidth = newSnWidth + 1, _this.snHeight = newSnHeight + 1;
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   719
		
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   720
		_this.notifyTopVideo = newZoomTop;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   721
		_this.notifyLeftVideo = newZoomLeft;
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   722
		
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   723
		_this.loadPlayer(_this.snTop, _this.snLeft, _this.snWidth, _this.snHeight, newZoomTop, newZoomLeft);
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   724
    });
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   725
}
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   726
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   727
/*
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   728
 * Chargement du player basé sur le metadataplayer.
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   729
*/
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   730
mosaic.prototype.loadPlayer = function(newZoomTop, newZoomLeft, newSnWidth, newSnHeight, zoomTop, zoomLeft)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   731
{
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   732
	var _this = this;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   733
	
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   734
	//On configure les options de lancement.
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   735
	IriSP.libFiles.defaultDir = "../lib/";
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   736
	IriSP.widgetsDir = "./player/metadataplayer/"
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   737
	
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   738
	var videoToPlay = this.videos[this.centerId];
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   739
	var currentMetadata = this.urls[this.centerId];
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   740
	
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   741
	var _metadata = {
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   742
		url: currentMetadata,
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   743
		format: 'ldt'
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   744
	};
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   745
	
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   746
	var _config = {
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   747
		gui: {
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   748
			zoomTop: zoomTop - this.marginWidth*2,
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   749
			zoomLeft: zoomLeft,
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   750
			width: newSnWidth,
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   751
			height: newSnHeight,
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   752
			container: 'LdtPlayer',
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   753
			default_options: {
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   754
				metadata: _metadata
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   755
			},
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   756
			css:'./player/metadataplayer/LdtPlayer-core.css',
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   757
			widgets: [
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   758
				{
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   759
					type: "Timeline"
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   760
				}
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   761
			]
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   762
		},
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   763
		player:{
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   764
			type: 'html5', // player type
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   765
			video: videoToPlay,
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   766
			live: true,
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   767
			height: newSnHeight,
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   768
			width: newSnWidth,
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   769
			autostart: true
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   770
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   771
	};
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   772
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   773
	//On positionne le player.
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   774
	$('.LdtPlayer').css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   775
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   776
		//display: 'none',
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   777
		position: 'absolute',
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   778
		'background-color': '#000000',
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   779
		top: newZoomTop,
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   780
		left: newZoomLeft
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   781
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   782
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   783
	//On démarre le player.
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   784
	this.player = null;
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   785
	this.player = new IriSP.Metadataplayer(_config, _metadata);
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   786
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   787
	if(this.currentMode == 'NO-USER')
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   788
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   789
		this.player.onLoad(function()
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   790
		{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   791
			console.log(_this.player);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   792
			console.log(_this.player.popcorn);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   793
			//Lorsque le player est en pause (par exemple lorsque le curseur arrive à la fin de la timeline).
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   794
			if(_this.player.popcorn != undefined)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   795
			{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   796
				_this.player.popcorn.listen('pause', function()
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   797
				{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   798
					_this.unzoom();
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   799
				});
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   800
			}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   801
		});
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   802
	}
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   803
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   804
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   805
/*
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   806
 * Retour à la taille normale de la mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   807
 */
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   808
mosaic.prototype.unzoom = function()
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   809
{
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   810
    //Si on n'est pas en plein écran, on quitte.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   811
	console.log("'" + this.currentMode + "'");
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   812
    if(this.currentMode != "SEARCH" && this.currentMode != "VIDEO" && this.currentMode != "NO-USER" && this.currentMode.indexOf("INCOMING") == -1)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   813
	{
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   814
        return;
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   815
	}
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   816
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   817
	this.snTop = 0;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   818
	this.snLeft = 0;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   819
	this.Width = 0;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   820
	this.snHeight = 0;
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   821
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   822
    //On charge les attributs nécessaires aux calculs.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   823
    var sWidth = this.snapshotWidth, sHeight = this.snapshotHeight;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   824
    var mpWidth = this.width, mpHeight = this.height;
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   825
    var _this = this;
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   826
    
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   827
    //On passe le snapshot sur lequel on a zoomé en SD.
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   828
    var zoomedImg = $('img', this.previousZoomedSN);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   829
    var src = zoomedImg.attr('src');
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   830
    zoomedImg.attr('src', src.replace('snapshots/', 'snapshots-little/'));
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   831
	
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   832
	_this.player.widgets[0].freePlayer();
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   833
	$('.LdtPlayer').remove();
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   834
	$('body').append('<div class="LdtPlayer" id="LdtPlayer"></div>');
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   835
	_this.reaffectKeyPress();
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   836
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   837
    //On rend leur opacité aux snapshots. Qui ne sont alors plus grisés.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   838
    $('.snapshotDivs').animate(
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   839
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   840
        width: sWidth,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   841
        height: sHeight,
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   842
        margin: this.marginWidth/2 + 'px'
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   843
    }, this.config['unzoomTime']);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   844
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   845
	if(this.currentMode != 'NO-USER')
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   846
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   847
		if(this.currentMode.indexOf("INCOMING") == -1)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   848
		{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   849
			$('.snapshotDivs').animate(
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   850
			{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   851
				opacity: '1'
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   852
			}, this.config['unzoomTime']);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   853
		}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   854
	}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   855
	else
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   856
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   857
		console.log('init');
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   858
		this.previousZoomedSN.fadeTo(this.config['unzoomTime'], 0, function()
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   859
		{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   860
			_this.init();
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   861
		});
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   862
	}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   863
	
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   864
    //On dézoom sur la mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   865
    $('#mainPanel').animate(
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   866
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   867
        width: mpWidth,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   868
        height: mpHeight,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   869
        top: '0px',
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   870
        left: '0px'
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   871
    }, this.config['unzoomTime'], function()
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   872
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   873
        //On n'est plus en plein écran, et on ne peut plus se déplacer vers le prochain voisin.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   874
        _this.fullscreen = false;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   875
        _this.canMoveToNeighbour = false;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   876
		
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   877
		if(_this.currentMode != 'NO-USER')
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   878
		{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   879
			//On revient en mode MOSAIC.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   880
			_this.currentMode = 'MOSAIC';
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   881
			//On ne permet plus le déplacement vers les voisins.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   882
			$('.snapshotDivs').unbind('mouseover', function()
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   883
			{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   884
				_this.selectNeighbour();
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   885
			});
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   886
			//On remet les notifications initiales.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   887
			_this.notifySelectionSearchMosaicFull();
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   888
		}
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   889
    });
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   890
}
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   891
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   892
/*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   893
 * Affecte les listeners mouseenter aux voisins lors d'une vue en plein écran.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   894
 */
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   895
mosaic.prototype.listenToNeighbours = function()
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   896
{
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   897
    ////TEST
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   898
    //$('.test').empty();
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   899
    var _this = this;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   900
    
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   901
	this.canMoveToNeighbour = false;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   902
    var currentLine = Math.floor(this.centerId / this.config['length']), currentColumn = this.centerId % this.config['length'];
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   903
    var zoomedImg = $('img', this.previousZoomedSN);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   904
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   905
    //On cherche l'ID des voisins.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   906
    //Si le voisin de gauche est sur la même ligne, on n'est pas sur la bordure de gauche.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   907
    this.neighboursIds[0] = (currentColumn > 0) ? (this.centerId - 1) : -1;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   908
    //Si le voisin de droite est sur la même ligne, on n'est pas sur la bordure de droite.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   909
    this.neighboursIds[1] = (currentColumn < this.config['length']) ? (+this.centerId + 1) : -1;
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   910
    //Si le voisin du haut est sur la même colonne, on n'est pas sur la bordure du haut.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   911
    this.neighboursIds[2] = (currentLine > 0) ? (this.centerId - this.config['length']) : -1;
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   912
    //Si le voisin du bas est sur la même colonne, on n'est pas sur la bordure du bas.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   913
    this.neighboursIds[3] = (currentLine < (this.config['imagesToShow'] / this.config['length'])) ? (+this.centerId + this.config['length']) : -1;
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   914
    
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   915
	//ID du cadre voisin.
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   916
	var preId;
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   917
	
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   918
    for(var i = 0 ; i < this.neighboursIds.length ; i++)
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   919
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   920
        if(this.neighboursIds[i] != -1)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   921
        {
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   922
			preId = '#neighbourFrameBorder-' + this.neighboursIds[i];
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   923
            //On permet le déplacement vers les voisins.
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   924
            // $('#snapshotDiv-' + this.neighboursIds[i] + ', ' + preId + '-left,' + preId + '-right,' + preId + '-up,' + preId + '-down').mouseenter(mos.selectNeighbour);
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   925
			
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   926
            $('#snapshotDiv-' + this.neighboursIds[i]).mouseover(function()
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   927
			{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   928
				_this.selectNeighbour($(this));
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   929
			});
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   930
        }
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   931
    }
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   932
}
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   933
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   934
/*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   935
 * Change la coloration d'une bordure où on se positionne lors d'une vue en plein écran.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   936
 */
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   937
mosaic.prototype.selectNeighbour = function(neighbour)
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   938
{
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   939
    ////TEST
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   940
    //$('.test').append(mos.currentMode + " " + $(this).attr('id') + " " + 'snapshotDiv-' + mos.centerId + ',');
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   941
	var _this = this;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   942
	
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   943
    //Si on est en mode VIDEO (plein écran) ET si le snapshot pointé est un voisin.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   944
    
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   945
    if((this.currentMode == 'VIDEO') && (neighbour.attr('id') != 'snapshotDiv-' + this.centerId))
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   946
    {
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   947
        //On crée le cadre qui va être superposé au voisin.
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   948
        //On le colle au voisin.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   949
		var tab = neighbour.attr('id').split('-');
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   950
		var snapshotId = tab[1];
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   951
        var neighbourFrame = '';
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   952
		var marginValue = parseFloat(neighbour.css('margin'));
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   953
		
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   954
		neighbourFrame += '<div class="neighbourFrame" id="neighbourFrame-' + snapshotId + '"><div class="neighbourImgBg" id="neighbourImgBg-' + snapshotId + '"><div class="neighbourImg" id="neighbourImg-' + snapshotId + '"></div></div></div>';
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   955
		
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   956
        $('#mainPanel').append(neighbourFrame);
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   957
		
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   958
		//On positionne le div de background juste au niveau du voisin.
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   959
        $('#neighbourFrame-' + snapshotId).css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   960
		{
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   961
			'top': (+neighbour.position().top + marginValue),
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   962
			'left': (+neighbour.position().left + marginValue),
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   963
			'width': neighbour.width(),
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   964
			'height': neighbour.height()
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   965
		});
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   966
		//On positionne le div de background noir juste au niveau de l'image du voisin.
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   967
        $('#neighbourImgBg-' + snapshotId).css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   968
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   969
			'top': marginValue,
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   970
			'left': marginValue,
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   971
			'width': neighbour.width() - marginValue*2,
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   972
			'height': neighbour.height() - marginValue*2,
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   973
		});
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   974
		//On met par dessus le div de l'image clonée du voisin.
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   975
		$('#neighbourImg-' + snapshotId).css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   976
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   977
			'top': 0,
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   978
			'left': 0,
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   979
			'width': neighbour.width() - marginValue*2,
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   980
			'height': neighbour.height() - marginValue*2,
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   981
			'background-image': 'url("' + $('img', neighbour).attr('src') + '")',
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   982
			'background-size': neighbour.width() + 'px ' + neighbour.height() + 'px',
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   983
			'background-position': -marginValue + 'px ' + -marginValue + 'px',
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   984
			'opacity': '0.4'
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   985
		});
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   986
		
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   987
		var fId = '#neighbourFrame-' + snapshotId;
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   988
		
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   989
		$(fId).animate(
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   990
        {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   991
            //On le fait apparaître.
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   992
            opacity: '1'
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   993
        }, _this.config['timeNeighbourGlowing'], function()
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   994
        {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
   995
            //On peut désormais se déplacer vers ce voisin.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   996
            _this.canMoveToNeighbour = true;
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   997
        });
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   998
		//Lorsqu'on quitte un des snapshots (bien entendu le voisin en question), on retire le cadre.
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
   999
		//Si on clique sur le voisin ou son cadre, on passe au voisin suivant.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1000
		$(fId).mouseout(function()
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1001
		{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1002
			_this.deselectNeighbour($(this))
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1003
		}).click(function()
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1004
		{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1005
			_this.moveToNeighbour($(this))
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1006
		});
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1007
    }
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1008
}
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1009
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1010
/*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1011
 * Change la coloration d'une bordure quittée lors d'une vue en plein écran.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1012
 */
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1013
mosaic.prototype.deselectNeighbour = function(neighbour)
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1014
{
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1015
    ////TEST
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1016
    //$('.test').append('un,');
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
  1017
	
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1018
    //On ne peut plus se déplacer vers les voisins.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1019
    this.canMoveToNeighbour = false;
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
  1020
    
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
  1021
	//On récupère le voisin.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1022
	var neighbourFrame = neighbour;
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
  1023
	
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1024
    //Si on est en mode VIDEO.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1025
    if(this.currentMode == 'VIDEO')
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1026
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1027
        //On le fait disparaître progressivement.
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
  1028
        neighbourFrame.animate(
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1029
        {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1030
            opacity: '0'
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1031
        }, this.config['timeNeighbourUnglowing'], function()
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1032
        {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1033
            //Une fois invisible, on le supprime.
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
  1034
            neighbourFrame.remove();
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1035
        });
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1036
    }
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1037
}
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1038
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1039
/*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1040
 * Lors d'une vue en plein écran, on se déplace vers le voisin dont l'id a été spécifié dans la fonction appelante.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1041
 */
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1042
mosaic.prototype.moveToNeighbour = function(neighbour)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1043
{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1044
	var _this = this;
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1045
    //Si on ne peut pas se déplacer vers les voisins, on quitte.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1046
    if(!_this.canMoveToNeighbour)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
  1047
	{
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1048
        return;
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
  1049
	}
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1050
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1051
    //On obtient l'ID de destination.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1052
    var tab = neighbour.attr('id').split('-');
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
  1053
    var destinationId = tab[1];
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1054
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1055
    //On charge les attributs nécessaires aux calculs.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1056
	var length = _this.config['length'];
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1057
    var MPCurrentTop = $('#mainPanel').position().top, MPCurrentLeft = $('#mainPanel').position().left;
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1058
    var divideCoeffTop = Math.floor(destinationId / length) == 0 ? 1 : Math.floor(destinationId / length);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1059
    var divideCoeffLeft = destinationId % length == 0 ? 1 : destinationId % length;
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
  1060
    var neighbourFrameTop = $('#snapshotDiv-' + destinationId).position().top, neighbourFrameLeft = $('#snapshotDiv-' + destinationId).position().left;
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1061
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1062
    //On définit pour le déplacement vertical s'il est nécessaire de se déplacer en haut ou en bas.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1063
    if(_this.previousZoomedSN.position().top > neighbourFrameTop)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1064
        MPCurrentTop += Math.abs(neighbourFrameTop - _this.previousZoomedSN.position().top);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1065
    else if(_this.previousZoomedSN.position().top < neighbourFrameTop)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1066
        MPCurrentTop -= Math.abs(neighbourFrameTop - _this.previousZoomedSN.position().top);
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1067
    //On définit pour le déplacement horizontal s'il est nécessaire de se déplacer à gauche ou à droite.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1068
    if(_this.previousZoomedSN.position().left > neighbourFrameLeft)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1069
        MPCurrentLeft += Math.abs(neighbourFrameLeft - _this.previousZoomedSN.position().left);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1070
    else if(_this.previousZoomedSN.position().left < neighbourFrameLeft)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1071
        MPCurrentLeft -= Math.abs(neighbourFrameLeft - _this.previousZoomedSN.position().left);
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1072
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1073
    //On passe le snapshot de destination en HD.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1074
    var destinationImg = $('#snapshot-' + destinationId);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1075
    var destinationImgSrc = destinationImg.attr('src');
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1076
    destinationImg.attr('src', destinationImgSrc.replace('snapshots-little/', 'snapshots/'));
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1077
    
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
  1078
    //On passe l'ancien snapshot en SD.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1079
    var currentImgSrc = $('img', _this.previousZoomedSN).attr('src');
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1080
    $('img', _this.previousZoomedSN).attr('src', currentImgSrc.replace('snapshots/', 'snapshots-little/'));
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1081
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1082
    //On obtient l'ID du div de coloration du snapshot vers lequel on se déplace afin de le supprimer.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1083
    var neighbourFrame = neighbour;
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
  1084
    var tab = neighbourFrame.attr('id').split('-');
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1085
    _this.centerId = tab[1];
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1086
    $(this).css('opacity', '0');
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
  1087
    neighbourFrame.remove();
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
  1088
    
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1089
	_this.player.widgets[0].freePlayer();
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1090
	$('.LdtPlayer').remove();
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
  1091
	$('body').append('<div class="LdtPlayer" id="LdtPlayer"></div>');
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1092
	_this.reaffectKeyPress();
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
  1093
	
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1094
    //On grise le snapshot qu'on vient de quitter.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1095
    _this.previousZoomedSN.animate(
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1096
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1097
        opacity: '0.4'
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1098
    });
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1099
    
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1100
    //On se déplace.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1101
    $('#mainPanel').animate(
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1102
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1103
        top: MPCurrentTop,
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1104
        left: MPCurrentLeft
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1105
    }, _this.config['timeMovingToNeighbour'], function()
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1106
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1107
        //On fait apparaître le snapshot vers lequel on s'est déplacé.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1108
        $('#snapshotDiv-' + destinationId).animate(
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1109
        {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1110
            opacity: '1'
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1111
        }, _this.config['zoomTime'], function()
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1112
        {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1113
            //On recharge les voisins.
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1114
            $('.snapshotDivs').unbind('mouseenter', _this.selectNeighbour);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1115
            _this.previousZoomedSN = $('#snapshotDiv-' + _this.centerId);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1116
            _this.listenToNeighbours();
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents: 30
diff changeset
  1117
			
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1118
			_this.notifyTopVideo = MPCurrentTop;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1119
			_this.notifyLeftVideo = MPCurrentLeft;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1120
			
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1121
			_this.loadPlayer((destinationImg.position().top + MPCurrentTop + _this.MPTop_margin), (destinationImg.position().left + MPCurrentLeft), destinationImg.width(), destinationImg.height(), MPCurrentTop, MPCurrentLeft);
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1122
        });
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1123
    });
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1124
}
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1125
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1126
/*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1127
 * Déchargement du contenu de la mosaïque pour le chargement de la mosaïque locale.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1128
 */
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1129
mosaic.prototype.unload = function()
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1130
{
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1131
    //On supprime les event listeners des objets de la mosaïque.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1132
    $('.snapshotDivs').unbind();
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1133
    $('.snapshots').unbind();
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1134
    $('.prezoomContainers').unbind();
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1135
    //On supprime physiquement les objets.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1136
    $('#mainPanel').empty();
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1137
}
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1138
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1139
/*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1140
 * Centre verticalement un snapshot.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1141
 */
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1142
/*function verticalCenterImg(mosaic, img)
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1143
{
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1144
    //On récupère sa hauteur.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1145
    var image_height = img.height();
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1146
    //Calcule la marge du haut de chaque div pour le centrage.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1147
    if(mosaic.top_margin == undefined)
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1148
        mosaic.top_margin = (mosaic.snapshotHeight > image_height) ? (mosaic.snapshotHeight - image_height)/2 : (image_height - mosaic.snapshotHeight)/2;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1149
    //On centre le snapshot.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1150
    img.css('margin-top', mosaic.top_margin).css('margin-bottom', mosaic.top_margin);
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1151
}*/
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1152
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1153
/*
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1154
 * Permet de tester l'égalité des éléments de deux objets.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1155
 * Pour ce faire on compare les éléments définissant ces objets.
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1156
 */
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1157
$.fn.equals = function(compareTo)
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1158
{
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1159
    if (!compareTo || !compareTo.length || this.length!=compareTo.length)
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1160
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1161
        return false;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1162
    }
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1163
    for (var i=0; i<this .length; i++)
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1164
    {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1165
        if (this[i]!==compareTo[i])
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1166
        {
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1167
            return false;
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1168
        }
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1169
    }
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1170
    return true;
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1171
}
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1172
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1173
/*
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1174
 * Charge les vidéos, les snapshots et les annotations depuis un fichier json.
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1175
*/
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1176
mosaic.prototype.loadFromJson = function(path)
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1177
{
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1178
	var _this = this;
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1179
	var i = 0;
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1180
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1181
	$.getJSON(path, function(data)
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1182
	{
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1183
		$.each(data, function(key, val)
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1184
		{
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1185
			$.each(val, function(key_video, val_video)
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1186
			{
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1187
				$.getJSON(val_video.metadata, function(meta)
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1188
				{
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1189
					if(_this.config['local'] == 'true')
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1190
					{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1191
						_this.affectVideoById(val_video.metadata, meta.medias[0].url.replace('rtmp://media.iri.centrepompidou.fr/ddc_player/', './player/videos/').replace('mp4:', '').replace('video/', '').replace('ldtplatform/', '').replace('.m4v', '.mp4'));
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1192
						console.log(meta.medias[0].url.replace('rtmp://media.iri.centrepompidou.fr/ddc_player/', './player/videos/').replace('mp4:', '').replace('video/', '').replace('ldtplatform/', '').replace('.m4v', '.mp4'));
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1193
					}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1194
					else
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1195
					{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1196
						_this.affectVideoById(val_video.metadata, meta.medias[0].url.replace('rtmp://', 'http://').replace('/ddc_player/', '/').replace('mp4:', '').replace('.m4v', '.mp4'));
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1197
						console.log(meta.medias[0].url.replace('rtmp://', 'http://').replace('/ddc_player/', '/').replace('mp4:', '').replace('.m4v', '.mp4'));
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1198
					}
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1199
				});
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1200
				_this.imgs[_this.ids[i]] = val_video.snapshot;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1201
				_this.urls[_this.ids[i]] = val_video.metadata;
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1202
				console.log('ids : ' + _this.ids[i]);
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1203
				i++;
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1204
			});
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1205
		});
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1206
		console.log('rdy');
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1207
		_this.loadMosaic();
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1208
	});
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1209
}
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1210
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1211
/*
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1212
 * Affecte une vidéo au tableau des vidéos selon son id
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1213
*/
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1214
mosaic.prototype.affectVideoById = function(metadata_id, video)
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1215
{
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1216
	for (i = 0 ; i < this.urls.length ; i++)
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1217
	{
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1218
		if(this.urls[i] == metadata_id)
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1219
		{
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1220
			this.videos[i] = video;
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1221
			break;
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1222
		}
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
  1223
	}
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1224
}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1225
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1226
/*
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1227
 * Lance une recherche par courbes.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1228
 */
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1229
mosaic.prototype.startSearch = function()
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1230
{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1231
	var top, left, width, height, margin_top, inMosaic;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1232
	//Si on est dans le cas d'un filtrage de mosaïque.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1233
	if(this.currentMode == "FILTER")
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1234
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1235
		var mainPanel = $('#mainPanel');
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1236
		top = mainPanel.position().top;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1237
		left = mainPanel.position().left;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1238
		width = mainPanel.width();
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1239
		height = mainPanel.height();
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1240
		margin_top = this.MPTop_margin;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1241
		inMosaic = true;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1242
	}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1243
	//Sinon si c'est une recherche dans la vidéo.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1244
	else if(this.currentMode == "SEARCH")
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1245
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1246
		top = this.snTop;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1247
		left = this.snLeft;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1248
		width = this.snWidth;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1249
		height = this.snHeight;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1250
		margin_top = '0px';
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1251
		inMosaic = false;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1252
	}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1253
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1254
	this.searchCanvas = new searchCanvas(top, left, width, height, margin_top, this.timeSearchFade, inMosaic);
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1255
	this.searchCanvas.create();
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1256
}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1257
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1258
/*
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1259
 * Quitte une recherche par courbes.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1260
 */
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1261
mosaic.prototype.leaveSearch = function()
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1262
{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1263
	this.searchCanvas.leaveSearch();
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1264
}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1265
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1266
/* ===============================================
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1267
 *												   *
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1268
 *		      ZONE DES NOTIFICATIONS			   *
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1269
 *												   *
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1270
   =============================================== */
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1271
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1272
/*
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1273
 * Affiche la notification de sélection/recherche lorsque la mosaique est complète.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1274
*/
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1275
mosaic.prototype.notifySelectionSearchMosaicFull = function()
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1276
{
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1277
	if(this.currentMode == "NO-USER" || this.currentMode.indexOf("INCOMING") == -1)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1278
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1279
		return;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1280
	}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1281
	
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1282
	//On spécifie les notifications en div.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1283
	var notification_selection = "<div id='notify_selection' class='notifications'></div>";
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1284
	var notification_search = "<div id='notify_search' class='notifications'></div>";
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1285
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1286
	//On les ajoute à la mosaïque.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1287
	$('#mainPanel').append(notification_selection + notification_search);
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1288
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1289
	//On calcule leurs coordonnées et dimensions.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1290
	var notify_width = $('.notifications').width(), notify_height = $('.notifications').height();
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1291
	var notify_margin = parseInt($('.notifications').css('margin'));
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1292
	var selection_left = $(window).width() / 2 - (notify_width * 2 + notify_margin * 3) / 2;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1293
	var search_left = selection_left + notify_width + notify_margin;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1294
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1295
	//On les positionne.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1296
	$('#notify_selection').css(
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1297
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1298
		left: selection_left
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1299
	});
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1300
	$('#notify_search').css(
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1301
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1302
		left: search_left
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1303
	});
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1304
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1305
	//On les fait apparaître.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1306
	$('.notifications').css(
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1307
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1308
		opacity: "0.9"
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1309
	});
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1310
}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1311
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1312
/*
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1313
 * Supprime la notification de sélection/recherche lorsque la mosaique est complète.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1314
*/
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1315
mosaic.prototype.removeSelectionSearchMosaicFull = function()
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1316
{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1317
	$('#notify_selection, #notify_search').remove();
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1318
}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1319
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1320
/*
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1321
 * Affiche la notification de maintient du pointage lors d'une phase de prézoom.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1322
*/
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1323
mosaic.prototype.notifyPointMosaicPrezoom = function()
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1324
{
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1325
	if($('#notify_point').length > 0 || this.currentMode == "NO-USER" || this.currentMode.indexOf("INCOMING") == -1)
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1326
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1327
		return;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1328
	}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1329
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1330
	//On spécifie les notifications en div.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1331
	var notification_point = "<div id='notify_point' class='notifications'></div>";
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1332
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1333
	//On les ajoute à la mosaïque.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1334
	$('#mainPanel').append(notification_point);
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1335
	
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1336
	//On calcule leurs coordonnées et dimensions.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1337
	var notify_width = $('.notifications').width(), notify_height = $('.notifications').height();
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1338
	var notify_margin = parseInt($('.notifications').css('margin'));
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1339
	var point_left = $(window).width() / 2 - (notify_width) / 2 - notify_margin;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1340
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1341
	//On les positionne.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1342
	$('#notify_point').css(
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1343
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1344
		left: point_left
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1345
	});
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1346
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1347
	//On les fait apparaître.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1348
	$('.notifications').css(
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1349
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1350
		opacity: "0.9"
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1351
	});
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1352
}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1353
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1354
/*
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1355
 * Supprime la notification de maintient du pointage.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1356
*/
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1357
mosaic.prototype.removePointMosaicPrezoom = function()
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1358
{	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1359
	$('#notify_point').remove();
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1360
}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1361
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1362
/*
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1363
 * Affiche l'aide.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1364
*/
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1365
mosaic.prototype.notifyHelp = function()
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1366
{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1367
	if(this.helpDisplayed)
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1368
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1369
		return;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1370
	}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1371
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1372
	this.removeSelectionSearchMosaicFull();
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1373
	this.removePointMosaicPrezoom();
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1374
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1375
	this.helpDisplayed = true;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1376
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1377
	var search_2hands_tab = ['no_motion', 'right_angle', 'contact', 'grand_jete', 'circle', 'screw', 'arc', 'rythme', 'slow', 'up_down', 'wave', 'wheel'];
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1378
	var search_body_tab = ['bend', 'fall', 'jump', 'hello', 'knee_up'];
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1379
	var controls_1hand_tab = ['selection'];
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1380
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1381
	//On spécifie les notifications en div.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1382
	var search_title = "<div id='search_title'></div>";
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1383
	var search_img = "<div id='search_img' class='notify_imgs'></div>";
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1384
	var search_2hands_text = "<div id='search_2hands_text'></div>";
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1385
	var search_2hands_imgs = "<div id='search_2hands_imgs' class='notify_imgs_big'>";
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1386
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1387
	for(var i = 0 ; i < search_2hands_tab.length ; i++)
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1388
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1389
		search_2hands_imgs += "<div id='2hands_" + search_2hands_tab[i] + "' class='notify_imgs_small'></div>";
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1390
	}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1391
	search_2hands_imgs += "</div>";
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1392
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1393
	var search_body_text = "<div id='search_body_text'></div>";
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1394
	var search_body_imgs = "<div id='search_2hands_imgs' class='notify_imgs'>"
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1395
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1396
	for(var i = 0 ; i < search_body_tab.length ; i++)
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1397
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1398
		search_body_imgs += "<div id='body_" + search_body_tab[i] + "' class='notify_imgs_small'></div>";
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1399
	}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1400
	search_body_imgs += "</div>";
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1401
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1402
	var controls_title = "<div id='controls_title'></div>";
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1403
	var controls_img = "<div id='controls_img' class='notify_imgs'></div>";
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1404
	var controls_1hand_text = "<div id='controls_1hand_text'></div>";
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1405
	var controls_1hand_imgs = "<div id='controls_1hand_imgs' class='notify_imgs'>";
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1406
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1407
	for(var i = 0 ; i < controls_1hand_tab.length ; i++)
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1408
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1409
		controls_1hand_imgs += "<div id='1hand_" + controls_1hand_tab[i] + "' class='notify_imgs_small'></div>";
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1410
	}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1411
	controls_1hand_imgs += "</div>";
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1412
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1413
	var help_search = "<div id='help_search'>" + search_title + search_img + search_2hands_text + search_2hands_imgs + search_body_text + search_body_imgs + "</div>";
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1414
	var help_controls = "<div id='help_controls'>" + controls_title + controls_img + controls_1hand_text + controls_1hand_imgs + "</div>";
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1415
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1416
	var notification_help = "<div id='notify_help'>" + help_search + "<div id='help_sep'></div>" + help_controls + "</div>";
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1417
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1418
	//On les ajoute à la mosaïque.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1419
	$('body').append(notification_help);
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1420
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1421
	//On calcule leurs coordonnées et dimensions.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1422
	var notify_width = $(window).width(), notify_height = $(window).height();
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1423
	var notify_margin = parseInt($('#notify_help').css('margin'));
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1424
	var notify_ = 10;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1425
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1426
	//On les positionne.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1427
	$('#notify_help').css(
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1428
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1429
		left: "0px",
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1430
		top: "0px",
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1431
		width: notify_width - notify_margin * 2,
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1432
		height: notify_height - notify_margin * 2
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1433
	});
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1434
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1435
	var search_width = $('#help_search').width();
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1436
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1437
	$('#search_title').html('Recherche');
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1438
	$('#search_2hands_text').html('Gestes à effectuer avec les deux mains');
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1439
	$('#search_body_text').html('Gestes à effectuer avec le corps entier');
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1440
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1441
	for(var i = 0 ; i < search_2hands_tab.length ; i++)
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1442
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1443
		$("#2hands_" + search_2hands_tab[i]).css("background-image", "url('./pictos/help/" + search_2hands_tab[i] + ".png')");
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1444
		//console.log("url('../../pictos/help/" + search_2hands_tab[i] + ".png')");
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1445
	}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1446
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1447
	for(var i = 0 ; i < search_body_tab.length ; i++)
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1448
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1449
		$("#body_" + search_body_tab[i]).css("background-image", "url('./pictos/help/" + search_body_tab[i] + ".png')");
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1450
		//console.log("url('../../pictos/help/" + search_2hands_tab[i] + ".png')");
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1451
	}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1452
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1453
	$('#controls_title').html('Contrôles');
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1454
	$('#controls_1hand_text').html('Gestes à effectuer avec une seule main');
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1455
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1456
	for(var i = 0 ; i < controls_1hand_tab.length ; i++)
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1457
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1458
		$("#1hand_" + controls_1hand_tab[i]).css("background-image", "url('./pictos/help/" + controls_1hand_tab[i] + ".png')");
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1459
		//console.log("url('../../pictos/help/" + search_2hands_tab[i] + ".png')");
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1460
	}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1461
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1462
	//On les fait apparaître.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1463
	$('#notify_help').css(
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1464
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1465
		opacity: "1"
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1466
	});
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1467
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1468
	$('.notify_imgs_big').css(
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1469
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1470
		opacity: "1"
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1471
	});
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1472
}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1473
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1474
/*
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1475
 * Supprime l'aide.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1476
*/
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1477
mosaic.prototype.removeHelp = function()
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1478
{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1479
	if(!this.helpDisplayed)
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1480
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1481
		return;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1482
	}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1483
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1484
	var _this = this;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1485
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1486
	$('#notify_help').fadeOut(this.timeNotifyFade, function()
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1487
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1488
		_this.helpDisplayed = false;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1489
		$('#notify_help').remove();
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
  1490
	});
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1491
}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1492
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1493
/*
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1494
 * Affiche les types de marqueurs correspondants à ce qu'on a commencé à tracer lors d'une recherche.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1495
*/
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1496
 mosaic.prototype.notifySearchMarkers = function(markersStr)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1497
{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1498
	if($('.notifications_inSearch_container').length > 0)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1499
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1500
		return;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1501
	}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1502
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1503
	console.log(markersStr);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1504
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1505
	var markersList = markersStr.split(new RegExp(';'));
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1506
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1507
	var notification_search_markers = "<div class='notifications_inSearch_container'>";
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1508
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1509
	//On spécifie les notifications en div.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1510
	for(var i = 0 ; i < markersList.length ; i++)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1511
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1512
		notification_search_markers += "<div class='notifications_inSearch' style='background-image: url(./pictos/big/normal/" + markersList[i] + ".png);'></div>";
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1513
	}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1514
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1515
	notification_search_markers += "</div>";
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1516
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1517
	//On les ajoute à la mosaïque.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1518
	$('#mainPanel').append(notification_search_markers);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1519
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1520
	//On calcule leurs coordonnées et dimensions.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1521
	var notify_width = $('.notifications_inSearch_container').width(), notify_height = $('.notifications_inSearch_container').height();
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1522
	var notify_margin = parseInt($('.notifications_inSearch').css('margin'));
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1523
	var point_left = $(window).width() / 2 - (notify_width) / 2 - notify_margin;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1524
	var point_top = 0;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1525
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1526
	if(this.currentMode == "VIDEO" || this.currentMode == "SEARCH")
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1527
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1528
		point_top = -this.notifyTopVideo,
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1529
		point_left = -this.notifyLeftVideo + ($(window).width() - notify_width) / 2
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1530
	}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1531
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1532
	//On les positionne.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1533
	$('.notifications_inSearch_container').css(
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1534
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1535
		left: point_left,
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1536
		top: point_top
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1537
	});
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1538
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1539
	//On les fait apparaître.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1540
	$('.notifications_inSearch').css(
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1541
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1542
		opacity: "0.9"
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1543
	});
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1544
}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1545
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1546
/*
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1547
 * Supprime la notification de maintient du pointage.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1548
*/
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1549
mosaic.prototype.removeSearchMarkers = function()
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1550
{	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1551
	$('.notifications_inSearch_container').remove();
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1552
}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1553
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1554
/*
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1555
 * Effectuer un filtrage de la mosaïque par rapport à un type de marqueurs.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1556
*/
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1557
mosaic.prototype.searchFilter = function(type)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1558
{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1559
	var _this = this;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1560
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1561
	if(this.currentMode == "MOSAIC")
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1562
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1563
		this.currentMode = "FILTER";
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1564
		
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1565
		if(this.annotations.length > 0)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1566
		{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1567
			var gestureNumberByVideo = new Object();
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1568
			var maxAnnotationNumber = 0;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1569
			// for(var i = 0 ; i < this.config['imagesToShow'] ; i++)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1570
			for(var i = 0 ; i < this.annotations.length ; i++)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1571
			{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1572
				var current = this.annotations[i];
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1573
				if(current.annotationType.contents.title == type)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1574
				{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1575
					if(gestureNumberByVideo[current.source.url] == undefined || gestureNumberByVideo[current.source.url] == '')
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1576
					{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1577
						gestureNumberByVideo[current.source.url] = 0;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1578
					}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1579
					
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1580
					gestureNumberByVideo[current.source.url]++;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1581
				}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1582
			}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1583
			
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1584
			for(var i = 0 ; i < this.urls.length ; i++)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1585
			{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1586
				if(gestureNumberByVideo[this.urls[i]] == undefined || gestureNumberByVideo[this.urls[i]] == '')
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1587
				{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1588
					gestureNumberByVideo[this.urls[i]] = 0;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1589
				}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1590
			}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1591
			
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1592
			//On récupère la vidéo qui score le nombre d'occurences de la gesture le plus haut.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1593
			for(i in gestureNumberByVideo)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1594
			{	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1595
				// console.log(i + " " + gestureNumberByVideo[i]);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1596
				if(maxAnnotationNumber < gestureNumberByVideo[i])
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1597
				{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1598
					maxAnnotationNumber = gestureNumberByVideo[i];
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1599
				}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1600
			}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1601
			
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1602
			var snMargin = parseInt($('.snapshotDivs').css('margin'));
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1603
			
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1604
			//On affiche l'opacité résultante pour chaque vidéo.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1605
			for(i in gestureNumberByVideo)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1606
			{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1607
				//Opacité conventionelle.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1608
				var opacity = gestureNumberByVideo[i] / maxAnnotationNumber;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1609
				// console.log('opacity b : ' + opacity + ' for ' + gestureNumberByVideo[i]);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1610
				//Ce qui est à zéro le restera (par conséquent le snapshot associé sera invisible).
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1611
				if(opacity > 0)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1612
				{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1613
					//On réhausse l'opacité de 50%.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1614
					opacity = this.scaleIntervals(0., 1., 0.5, 1., opacity);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1615
				}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1616
				
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1617
				var filterIndex = this.getIdxFromMetadata(i);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1618
				
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1619
				if(filterIndex >= 0)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1620
				{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1621
					console.log('#snapshotDiv-' + filterIndex + " " + _this.config['timeFilterFade'] + " " + opacity);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1622
					$('#snapshotDiv-' + filterIndex).fadeTo(_this.config['timeFilterFade'], opacity);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1623
					
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1624
					if(opacity == 0)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1625
					{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1626
						var filteredSnapshot = $('#snapshotDiv-' + filterIndex);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1627
						
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1628
						if(filteredSnapshot.length > 0)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1629
						{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1630
							var hider = '<div id="filterHider-' + filterIndex + '" class="filterHiders"></div>';
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1631
							$('#mainPanel').append(hider);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1632
							
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1633
							$('#filterHider-' + filterIndex).css(
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1634
							{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1635
								width: +filteredSnapshot.width() + 4 * snMargin,
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1636
								height: +filteredSnapshot.height() + 4 * snMargin,
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1637
								top: filteredSnapshot.position().top - snMargin,
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1638
								left: filteredSnapshot.position().left - snMargin
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1639
							});
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1640
						}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1641
					}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1642
				}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1643
			}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1644
		}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1645
	}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1646
}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1647
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1648
/*
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1649
 * Passe une valeur de l'intervalle [A, B] à l'intervalle [C, D].
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1650
*/
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1651
mosaic.prototype.scaleIntervals = function(A, B, C, D, val)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1652
{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1653
	return (D - C + A) * val + (C - A);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1654
}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1655
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1656
/*
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1657
 * Retourne l'index d'un snapshot en fonction de ses metadonnées.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1658
*/
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1659
mosaic.prototype.getIdxFromMetadata = function(metadata)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1660
{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1661
	var _this = this;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1662
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1663
	for(idx in this.urls)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1664
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1665
		if(this.urls[idx] == metadata)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1666
		{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1667
			for(id in this.ids)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1668
			{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1669
				if(this.ids[id] == idx)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1670
				{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1671
					return id;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1672
				}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1673
			}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1674
		}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1675
	}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1676
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1677
	return -1;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1678
}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1679
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1680
/*
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1681
 * Enlève une recherche par filtre.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1682
*/
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1683
mosaic.prototype.removeFilter = function()
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1684
{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1685
	if(this.currentMode == "FILTER")
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1686
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1687
		this.currentMode = "MOSAIC";
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1688
		
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1689
		var _this = this;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1690
		
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1691
		$('.filterHiders').remove();
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1692
		$('.snapshotDivs').fadeTo(_this.config['timeFilterFade'], 1);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1693
	}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1694
}
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1695
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1696
/*
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1697
 * Rebind keypress pour body.
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1698
*/
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1699
mosaic.prototype.reaffectKeyPress = function()
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1700
{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1701
	var _this = this;
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1702
	
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1703
	$('body').keypress(function (event)
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1704
	{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1705
		_this.manageControlEvents(event);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
  1706
	});
30
45c889eae324 Front IDILL :
bastiena
parents:
diff changeset
  1707
}