front_idill/src/mosaic/js/mouseInteractions.js
author bastiena
Tue, 18 Sep 2012 23:45:16 +0200
changeset 97 be87091be54e
parent 89 b6a115568b52
child 100 db42ef1faa7a
permissions -rw-r--r--
Front IDILL: credits & gestures files added
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
77
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
     1
/*
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
     2
* This file is part of the TraKERS\Front IDILL package.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
     3
*
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
     4
* (c) IRI <http://www.iri.centrepompidou.fr/>
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
     5
*
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
     6
* For the full copyright and license information, please view the LICENSE
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
     7
* file that was distributed with this source code.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
     8
*/
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
     9
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    10
/*
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    11
 * Projet : TraKERS
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    12
 * Module : Front IDILL
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    13
 * Fichier : mouseInteractions.js
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    14
 * 
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    15
 * Auteur : alexandre.bastien@iri.centrepompidou.fr
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    16
 * 
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    17
 * Fonctionnalités : Définit les fonctions d'intéraction souris.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    18
 */
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    19
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    20
/*
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    21
 * Fonction appelée lors d'un mouse down en mode d'interaction souris.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    22
 * Est appelé dans le fichier :
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    23
 * mosaic > fonction loadMosaic, attachée à l'événement jQuery mousedown.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    24
*/
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    25
Mosaic.prototype.onMouseDown = function(e)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    26
{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    27
	this.isMouseDown = true;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    28
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    29
	//Si on se trouve sur l'icone d'aide et qu'elle est zoomée.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    30
	if(this.isHelpIconZoomed)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    31
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    32
		//On affiche différentes aides en fonction de si on se trouve dans une vidéo ou non.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    33
		if(this.currentMode == 'SEARCH' || this.currentMode == 'VIDEO' || this.currentMode == 'TIMELINE')
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    34
		{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    35
			this.notifyHelp(false);
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    36
		}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    37
		else if(this.currentMode == 'FILTER' || this.currentMode == 'MOSAIC')
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    38
		{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    39
			this.notifyHelp(true);
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    40
		}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    41
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    42
	
85
b244a7bc0844 Front IDILL:
bastiena
parents: 79
diff changeset
    43
	//Si on se trouve sur l'icone des crédits et qu'elle est zoomée.
89
b6a115568b52 Front IDILL:
bastiena
parents: 85
diff changeset
    44
	if(this.isCreditsIconZoomed)
85
b244a7bc0844 Front IDILL:
bastiena
parents: 79
diff changeset
    45
	{
b244a7bc0844 Front IDILL:
bastiena
parents: 79
diff changeset
    46
		//On affiche les crédits.
b244a7bc0844 Front IDILL:
bastiena
parents: 79
diff changeset
    47
		this.notifyCredits();
b244a7bc0844 Front IDILL:
bastiena
parents: 79
diff changeset
    48
	}
b244a7bc0844 Front IDILL:
bastiena
parents: 79
diff changeset
    49
	
77
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    50
	//On met à jour les coordonnées de la souris au dernier mouse down.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    51
	this.mouseDownPosX = e.pageX;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    52
	this.mouseDownPosY = e.pageY;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    53
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    54
	//Si on est sur une notification de gesture de recherche.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    55
	this.removeSearchNotificationIfOnIt(e.pageX, e.pageY);
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    56
	this.isUserInSearchZone = true;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    57
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    58
	//Si on est en mode de tracé de courbes, on indique qu'on a commencé à tracer au canvas.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    59
	if(this.isSearchByCurvesOn)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    60
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    61
		this.searchCanvas.onPointerIn(this.mousePosX, this.mousePosY, null, null);
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    62
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    63
}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    64
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    65
/*
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    66
 * Fonction appelée lors d'un mouse move en mode d'interaction souris.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    67
 * Est appelé dans le fichier :
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    68
 * mosaic > fonction loadMosaic, attachée à l'événement jQuery mousemove.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    69
*/
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    70
Mosaic.prototype.onMouseMove = function(e)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    71
{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    72
	//On vérifie si la souris n'est pas sur l'icone d'aide.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    73
	if(this.isOnHelpIcon(this.mousePosX, this.mousePosY))
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    74
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    75
		//On agrandit l'icone d'aide.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    76
		this.showBigHelp();
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    77
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    78
	else
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    79
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    80
		//On la rétrecit sinon.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    81
		this.showSmallHelp();
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    82
	}
85
b244a7bc0844 Front IDILL:
bastiena
parents: 79
diff changeset
    83
b244a7bc0844 Front IDILL:
bastiena
parents: 79
diff changeset
    84
	//On vérifie si la souris n'est pas sur l'icone des crédits.
b244a7bc0844 Front IDILL:
bastiena
parents: 79
diff changeset
    85
	if(this.isOnCreditsIcon(this.mousePosX, this.mousePosY))
b244a7bc0844 Front IDILL:
bastiena
parents: 79
diff changeset
    86
	{
b244a7bc0844 Front IDILL:
bastiena
parents: 79
diff changeset
    87
		//On agrandit l'icone des crédits.
b244a7bc0844 Front IDILL:
bastiena
parents: 79
diff changeset
    88
		this.showBigCredits();
b244a7bc0844 Front IDILL:
bastiena
parents: 79
diff changeset
    89
	}
b244a7bc0844 Front IDILL:
bastiena
parents: 79
diff changeset
    90
	else
b244a7bc0844 Front IDILL:
bastiena
parents: 79
diff changeset
    91
	{
b244a7bc0844 Front IDILL:
bastiena
parents: 79
diff changeset
    92
		//On la rétrecit sinon.
b244a7bc0844 Front IDILL:
bastiena
parents: 79
diff changeset
    93
		this.showSmallCredits();
b244a7bc0844 Front IDILL:
bastiena
parents: 79
diff changeset
    94
	}
77
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    95
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    96
	//Si on n'a pas appuyé sur la souris avant, on part.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    97
	if(!this.isMouseDown)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    98
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    99
		return;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   100
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   101
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   102
	var _this = this;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   103
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   104
	//Si on est en mode de tracé de courbes, on met à jour la courbe.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   105
	if(this.isSearchByCurvesOn)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   106
	{
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   107
		// this.searchCanvas.onPointerMove(this.mousePosX, this.mousePosY - this.MPTop_margin, null, null);
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   108
		this.searchCanvas.onPointerMove(this.mousePosX, this.mousePosY, null, null);
77
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   109
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   110
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   111
	//On met à jour l'ancienne position de la souris si elle est nulle.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   112
	if(!this.mousePosLastX && this.mousePosLastX != 0)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   113
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   114
		this.mousePosLastX = this.mousePosX;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   115
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   116
	if(!this.mousePosLastY && this.mousePosLastY != 0)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   117
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   118
		this.mousePosLastY = this.mousePosY;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   119
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   120
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   121
	//Le delta s'accroît si la souris bouge.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   122
	this.mouseUpDownDelta += Math.floor(Math.sqrt((this.mousePosLastX - e.pageX) * (this.mousePosLastX - e.pageX) + (this.mousePosLastY - e.pageY) * (this.mousePosLastY - e.pageY)));
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   123
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   124
	//On met à jour l'ancienne position de la souris.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   125
	if(this.mousePosLastX != this.mousePosX)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   126
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   127
		this.mousePosLastX = this.mousePosX;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   128
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   129
	if(this.mousePosLastY != this.mousePosY)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   130
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   131
		this.mousePosLastY = this.mousePosY;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   132
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   133
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   134
	//Si la souris a parcouru une trop grande distance, on entre en recherche.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   135
	if(this.mouseUpDownDelta > this.config.mouseUpDownDeltaTreshold)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   136
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   137
		//Si on est en mosaique, on entre en filtrage.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   138
		if(this.currentMode == "MOSAIC")
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   139
		{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   140
			this.preUnzoom();
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   141
			this.currentMode = "FILTER";
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   142
			this.isMosaicFiltered = true;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   143
		}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   144
		//Si on est en mode de filtrage, mais qu'on n'est pas en tracé de courbes.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   145
		else if(this.currentMode == "FILTER" && !this.isSearchByCurvesOn && this.isUserInSearchZone)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   146
		{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   147
			//On lance une nouvelle recherche pas courbes.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   148
			this.preUnzoom();
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   149
		}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   150
		//Si on est dans une vidéo, on entre en recherche.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   151
		else if(this.currentMode == "VIDEO" || this.currentMode == "TIMELINE")
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   152
		{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   153
			this.currentMode = "SEARCH";
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   154
		}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   155
		//Si on est en mode recherche dans une vidéo, mais qu'on n'est pas en tracé de courbes.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   156
		/*else if(this.currentMode == "SEARCH" && !this.isSearchByCurvesOn)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   157
		{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   158
			//On lance une nouvelle recherche pas courbes.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   159
		}*/
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   160
		
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   161
		if(this.currentMode != "NO-USER" && this.currentMode.indexOf("INCOMING") == -1 && !this.isSearchByCurvesOn)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   162
		{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   163
			this.isSearchByCurvesOn = true;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   164
			this.startSearch();
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   165
			this.searchCanvas.onPointerIn(this.mousePosX, this.mousePosY - this.MPTop_margin, null, null);
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   166
		}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   167
		
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   168
		//S'il n'est pas possible d'afficher l'aide.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   169
		if(!this.canNotifyHelp)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   170
		{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   171
			//On rend son affichage possible après un certain délai.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   172
			this.canNotifyHelpTimeout = setTimeout(function()
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   173
			{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   174
				_this.canNotifyHelp = true;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   175
			}, this.config.timeoutCanNotifyHelp);
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   176
		}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   177
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   178
}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   179
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   180
/*
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   181
 * Fonction appelée lors d'un mouse up en mode d'interaction souris.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   182
 * Est appelé dans le fichier :
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   183
 * mosaic > fonction loadMosaic, attachée à l'événement jQuery mousemove.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   184
*/
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   185
Mosaic.prototype.onMouseUp = function()
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   186
{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   187
	this.isMouseDown = false;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   188
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   189
	//Si on était en train de tracer une courbe.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   190
	if(this.isSearchByCurvesOn)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   191
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   192
		//On quitte la zone de recherche.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   193
		/*this.isUserInSearchZone = false;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   194
		
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   195
		//On regarde si ce qu'on a tracé correspond à une courbe en particulier.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   196
		var gesture_match = this.gestureWithSameCode(this.actualCode);
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   197
		this.actualCode = '';
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   198
		
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   199
		//Si oui.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   200
		if(gesture_match.length > 0)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   201
		{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   202
			//Si on est en mode recherche dans une vidéo et que le player est prêt.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   203
			if(this.currentMode == "SEARCH" && this.playerIsReady)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   204
			{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   205
				//On effectue une recherche dans cette vidéo.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   206
				this.player.widgets[0].searchByGesture(gesture_match);
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   207
				this.isCurrentlyInASearchByGesture = this.player.widgets[0].isCurrentlyInASearchByGesture;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   208
				
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   209
				//On va au premier marqueur trouvé.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   210
				if(this.player && this.player.widgets[0] && this.timeToGoAt[this.centerId] === 0 && this.player.widgets[0].atLeastOneSearchMarker(this.currentSearchGesture[this.centerId]))
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   211
				{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   212
					this.player.widgets[0].goToFirstSearchedMarker(this.currentSearchGesture[this.centerId]);
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   213
				}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   214
				
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   215
				//On affiche la notification de gesture de recherche.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   216
				this.removeNotifications();
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   217
				this.currentSearchGesture[this.centerId] = gesture_match;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   218
				this.searchGesture(gesture_match, 'valid');
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   219
				this.curvesGesturesFound = false;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   220
			}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   221
			//Si on est en mode de filtrage de mosaique.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   222
			else if(this.currentMode == "FILTER")
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   223
			{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   224
				if(this.isMosaicFiltered)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   225
				{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   226
					//On notifie la recherche par filtrage.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   227
					this.removeNotifications();
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   228
					this.filterSearchedType = gesture_match;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   229
					this.filterGesture(gesture_match, 'valid');
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   230
					//On filtre la mosaique.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   231
					this.searchFilter(gesture_match);
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   232
					this.curvesGesturesFound = false;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   233
				}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   234
			}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   235
		}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   236
		//Si aucune gesture ne matche dans le dictionnaire.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   237
		else
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   238
		{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   239
			//Si on était en mode filtrage de la mosaïque et qu'aucune gesture de filtrage n'avait été détectée avant ca, on revient en mode mosaïque.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   240
			if(this.currentMode == "FILTER" && this.filterSearchedType == "")
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   241
			{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   242
				this.currentMode = "MOSAIC";
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   243
				this.isMosaicFiltered = false;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   244
			}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   245
			//Sinon si on était en mode recherche dans une video et qu'aucune gesture n'avait été détectée avant ca, on revient en mode video.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   246
			if(this.currentMode == "SEARCH" && this.currentSearchGesture[this.centerId] == "")
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   247
			{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   248
				this.currentMode = "VIDEO";
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   249
			}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   250
		}*/
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   251
		//On dit au module de recherche qu'on arrête de tracer des courbes.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   252
		this.searchCanvas.onPointerOut();
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   253
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   254
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   255
	this.mousePosLastX = null;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   256
	this.mousePosLastY = null;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   257
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   258
	//Si la distance parcourue par la souris entre le mouse down et le mouse up est inférieure ou égale au seuil.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   259
	if(this.mouseUpDownDelta <= this.config.mouseUpDownDeltaTreshold)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   260
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   261
		//Si on est sur un snapshot prézoomé.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   262
		if(this.isOnAPrezoomSN && this.previousZoomedSN != '' && (this.currentMode == 'MOSAIC' || this.currentMode == 'FILTER') && !this.isPrezooming)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   263
		{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   264
			this.zoom();
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   265
		}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   266
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   267
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   268
	//On réinitialise le delta, on quitte la recherche par courbes.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   269
	this.mouseUpDownDelta = 0;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   270
	this.isSearchByCurvesOn = false;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   271
	this.leaveSearch();
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   272
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   273
	//Si on est en mode de filtrage et qu'on a une gesture de filtrage trouvée.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   274
	if(this.currentMode == 'FILTER' && this.filterSearchedType != '')
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   275
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   276
		//On notifie.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   277
		this.removeNotifications();
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   278
		this.filterGesture(this.filterSearchedType, 'valid');
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   279
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   280
}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   281
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   282
/*
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   283
 * Fonction appelée lors d'un clic en mode d'interaction souris.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   284
 * Est appelé dans le fichier :
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   285
 * mosaic > fonction loadMosaic.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   286
*/
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   287
Mosaic.prototype.onClick = function(x, y)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   288
{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   289
	//Si la position de la souris entre le mouse down et le mouse up change de plus de 10px, on part.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   290
	if(!this.mouseDownPosX || !this.mouseDownPosY || Math.sqrt((this.mouseDownPosX - x) * (this.mouseDownPosX - x) + (this.mouseDownPosY - y) * (this.mouseDownPosY - y)) > 10)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   291
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   292
		return;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   293
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   294
	
89
b6a115568b52 Front IDILL:
bastiena
parents: 85
diff changeset
   295
	//Si on est dans un mode autre qu'un mode zoomé et qu'on n'affiche pas l'aide ou les crédits, on part.
b6a115568b52 Front IDILL:
bastiena
parents: 85
diff changeset
   296
	if(this.currentMode != "VIDEO" && this.currentMode != "SEARCH" && this.currentMode != "TIMELINE" && !this.helpDisplayed && !this.creditsDisplayed)
77
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   297
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   298
		return;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   299
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   300
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   301
	//Si on clique en dehors de la video centrale, alors on dézoome.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   302
	var TL = $('.Ldt-Timeline');
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   303
	var TLwidth = TL.width(), TLheight = TL.height();
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   304
	var Ptop = $('.LdtPlayer').position().top, Pleft = $('.LdtPlayer').position().left;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   305
	var Pheight = $('.LdtPlayer').height();
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   306
	var MPx = this.mousePosX, MPy = this.mousePosY;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   307
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   308
	//On regarde si on a cliqué sur un snapshot.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   309
	var SN = this.pointerPositionToSN(MPx - this.notifyLeftVideo, MPy - this.notifyTopVideo, true);
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   310
	var SNId;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   311
	if(SN)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   312
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   313
		SNId = parseInt(SN.attr('id').replace('snapshotDiv-', ''));
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   314
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   315
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   316
	//Si on n'a pas demandé à supprimé la notification de gesture.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   317
	if(!this.gestureDelRequested && !this.helpDisplayed)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   318
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   319
		//Si non, ou s'il ne fait pas partie des voisins.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   320
		if(!SNId || !_.include(this.neighboursIds, SNId))
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   321
		{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   322
			//Si le clic a lieu en dehors du player et que l'aide n'est pas affichée, on dezoom.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   323
			if(MPx < Pleft || MPx > (+Pleft + TLwidth) || MPy < Ptop || MPy > (+Ptop + Pheight - TLheight))
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   324
			{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   325
				this.unzoom();
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   326
			}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   327
		}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   328
		//Si on se trouve sur un voisin, on bouge.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   329
		else if(SNId && _.include(this.neighboursIds, SNId) && this.canMoveToNeighbour)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   330
		{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   331
			this.moveToNeighbour($('#snapshotDiv-' + SNId));
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   332
		}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   333
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   334
	//Si on l'a demandé, on enlève la demande de suppression.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   335
	else
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   336
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   337
		this.gestureDelRequested = false;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   338
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   339
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   340
	//Si l'aide est affichée, un clic la ferme.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   341
	if(this.helpDisplayed && !this.isHelpIconZoomed && !this.isHelpIconZooming)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   342
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   343
		this.removeHelp();
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   344
	}
85
b244a7bc0844 Front IDILL:
bastiena
parents: 79
diff changeset
   345
	
b244a7bc0844 Front IDILL:
bastiena
parents: 79
diff changeset
   346
	//Si les crédits sont affichés, un clic les ferme.
89
b6a115568b52 Front IDILL:
bastiena
parents: 85
diff changeset
   347
	if(this.creditsDisplayed && !this.isCreditsIconZoomed && !this.isCreditsIconZooming && !this.isOnCreditsArrow(this.mousePosX, this.mousePosY))
85
b244a7bc0844 Front IDILL:
bastiena
parents: 79
diff changeset
   348
	{
b244a7bc0844 Front IDILL:
bastiena
parents: 79
diff changeset
   349
		this.removeCredits();
b244a7bc0844 Front IDILL:
bastiena
parents: 79
diff changeset
   350
	}
89
b6a115568b52 Front IDILL:
bastiena
parents: 85
diff changeset
   351
	
b6a115568b52 Front IDILL:
bastiena
parents: 85
diff changeset
   352
	//Si les crédits sont affichés et qu'on est sur une flèche, on change de page.
b6a115568b52 Front IDILL:
bastiena
parents: 85
diff changeset
   353
	if(this.isOnCreditsUpArrow(this.mousePosX, this.mousePosY))
b6a115568b52 Front IDILL:
bastiena
parents: 85
diff changeset
   354
	{
b6a115568b52 Front IDILL:
bastiena
parents: 85
diff changeset
   355
		this.goToPreviousCreditsPage();
b6a115568b52 Front IDILL:
bastiena
parents: 85
diff changeset
   356
	}
b6a115568b52 Front IDILL:
bastiena
parents: 85
diff changeset
   357
	else if(this.isOnCreditsDownArrow(this.mousePosX, this.mousePosY))
b6a115568b52 Front IDILL:
bastiena
parents: 85
diff changeset
   358
	{
b6a115568b52 Front IDILL:
bastiena
parents: 85
diff changeset
   359
		this.goToNextCreditsPage();
b6a115568b52 Front IDILL:
bastiena
parents: 85
diff changeset
   360
	}
77
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   361
}