front_idill/src/mosaic/js/touchInteractions.js
author bastiena
Sun, 09 Sep 2012 15:11:32 +0200
changeset 89 b6a115568b52
parent 79 9eff85166868
permissions -rw-r--r--
Front IDILL: credits for mouse interactions
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 : touchInteractions.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 pour tablettes.
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 touch start en mode d'interaction touch.
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 ontouchstart.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    24
*/
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    25
Mosaic.prototype.onTouchStart = function(e)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    26
{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    27
	this.isTouchStart = true;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    28
	this.isTouchMove = false;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    29
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    30
	//Si on est sur l'icone de sortie.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    31
	if(this.isOnExitIcon(e.pageX, e.pageY) && this.helpDisplayed)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    32
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    33
		//On ferme l'aide.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    34
		this.removeExitIcon();
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    35
		this.removeHelp();
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    36
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    37
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    38
	//Si on est sur l'icone de retour à la mosaïque.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    39
	if(this.isOnHomeIcon(e.pageX, e.pageY) && !this.helpDisplayed)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    40
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    41
		//On dézoom.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    42
		this.unzoom();
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    43
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    44
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    45
	//Si on se trouve sur l'icone d'aide et qu'elle est zoomée.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    46
	if(this.isOnHelpIcon(e.pageX, e.pageY) && !this.helpDisplayed)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    47
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    48
		//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
    49
		if(this.currentMode == 'SEARCH' || this.currentMode == 'VIDEO' || this.currentMode == 'TIMELINE')
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    50
		{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    51
			this.notifyHelp(false);
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    52
		}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    53
		else if(this.currentMode == 'FILTER' || this.currentMode == 'MOSAIC')
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    54
		{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    55
			this.notifyHelp(true);
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    56
		}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    57
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    58
	
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
    59
	//Si on est sur le bouton de lecture de vidéo.
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
    60
	if(this.isOnPlayButton(e.pageX, e.pageY) && this.player && this.player.widgets && this.player.widgets[1])
77
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    61
	{
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
    62
		this.player.widgets[1].onPlayButtonTouchStart();
77
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    63
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    64
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    65
	//On met à jour les coordonnées de la souris au dernier mouse down.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    66
	this.mouseDownPosX = e.pageX;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    67
	this.mouseDownPosY = e.pageY;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    68
	this.mousePosX = e.pageX;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    69
	this.mousePosY = e.pageY;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    70
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    71
	this.isUserInSearchZone = true;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    72
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    73
	//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
    74
	if(this.isSearchByCurvesOn)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    75
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    76
		this.searchCanvas.onPointerIn(this.mousePosX, this.mousePosY, null, null);
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    77
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    78
}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    79
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    80
/*
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    81
 * Fonction appelée lors d'un touch move en mode d'interaction touch.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    82
 * Est appelé dans le fichier :
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    83
 * mosaic > fonction loadMosaic, attachée à l'événement jQuery ontouchmove.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    84
*/
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    85
Mosaic.prototype.onTouchMove = function(e)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    86
{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    87
	//Si on n'a pas appuyé sur la souris avant, on part.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    88
	if(!this.isTouchStart)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    89
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    90
		return;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    91
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    92
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    93
	var _this = this;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    94
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    95
	//Si on est en mode de tracé de courbes, on met à jour la courbe.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    96
	if(this.isSearchByCurvesOn)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
    97
	{
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
    98
		// this.searchCanvas.onPointerMove(this.mousePosX, this.mousePosY - this.MPTop_margin, null, null);
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
    99
		this.searchCanvas.onPointerMove(this.mousePosX, this.mousePosY, null, null);
77
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   100
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   101
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   102
	//On met à jour l'ancienne position du doigt si elle est nulle.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   103
	if(!this.mousePosLastX && this.mousePosLastX != 0)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   104
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   105
		this.mousePosLastX = this.mousePosX;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   106
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   107
	if(!this.mousePosLastY && this.mousePosLastY != 0)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   108
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   109
		this.mousePosLastY = this.mousePosY;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   110
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   111
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   112
	//Le delta s'accroît si le doigt bouge.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   113
	this.touchUpDownDelta += 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
   114
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   115
	//On met à jour l'ancienne position du doigt.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   116
	if(this.mousePosLastX != this.mousePosX)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   117
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   118
		this.mousePosLastX = this.mousePosX;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   119
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   120
	if(this.mousePosLastY != this.mousePosY)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   121
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   122
		this.mousePosLastY = this.mousePosY;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   123
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   124
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   125
	//Si le doigt a parcouru une trop grande distance, on entre en recherche.
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   126
	if(this.touchUpDownDelta > this.config.touchUpDownDeltaTreshold && !this.isTLSelected(true, null))
77
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   127
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   128
		this.isTouchMove = true;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   129
		//Si on est en mosaique, on entre en filtrage.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   130
		if(this.currentMode == "MOSAIC")
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   131
		{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   132
			this.currentMode = "FILTER";
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   133
			this.isMosaicFiltered = true;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   134
		}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   135
		//Si on est dans une vidéo, on entre en recherche.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   136
		else if(this.currentMode == "VIDEO" || this.currentMode == "TIMELINE")
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   137
		{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   138
			this.currentMode = "SEARCH";
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   139
		}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   140
		
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   141
		if(!this.isSearchByCurvesOn)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   142
		{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   143
			this.isSearchByCurvesOn = true;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   144
			this.startSearch();
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   145
			// this.searchCanvas.onPointerIn(this.mousePosX, this.mousePosY - this.MPTop_margin, null, null);
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   146
			this.searchCanvas.onPointerIn(this.mousePosX, this.mousePosY, null, null);
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   147
		}
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   148
		
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   149
		//Si on est dans une vidéo et qu'on glisse le doigt sur la timeline, ça place le curseur à cet endroit.
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   150
		if(this.playerIsReady && (this.currentMode == 'VIDEO' || this.currentMode == 'SEARCH' || this.currentMode == 'TIMELINE') && this.isTLSelected(true, null))
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   151
		{
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   152
			this.goToTimeline();
77
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   153
		}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   154
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   155
}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   156
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   157
/*
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   158
 * Fonction appelée lors d'un touch end en mode d'interaction touch.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   159
 * Est appelé dans le fichier :
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   160
 * mosaic > fonction loadMosaic, attachée à l'événement jQuery ontouchend.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   161
*/
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   162
Mosaic.prototype.onTouchEnd = function(e)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   163
{
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   164
	//Coordonnées du doigt.
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   165
	var posX = this.mousePosX, posY = this.mousePosY;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   166
	
77
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   167
	// alert(this.mousePosX + ' ' + this.mousePosY);
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   168
	//Si on est dans la mosaïque.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   169
	if(this.currentMode == 'MOSAIC' || this.currentMode == 'FILTER')
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   170
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   171
		//On regarde si on a touché un snapshot.
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   172
		var snapshot = this.positionToSN(posX, posY);
77
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   173
		// alert(snapshot);
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   174
		// alert(this.isTouchMove);
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   175
		if(snapshot && !this.isTouchMove)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   176
		{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   177
			this.previousZoomedSN = snapshot;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   178
			this.previousId = snapshot.attr('id');
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   179
			this.zoom();
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   180
		}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   181
	}
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   182
	//Sinon si on est dans une vidéo.
77
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   183
	else if(this.currentMode == 'VIDEO' || this.currentMode == 'SEARCH' || this.currentMode == 'TIMELINE')
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   184
	{
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   185
		//Si on relache le doigt sur la timeline, ça place le curseur à cet endroit.
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   186
		if(this.playerIsReady && this.isTLSelected(true, null))
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   187
		{
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   188
			this.goToTimeline();
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   189
		}
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   190
		this.exitTimeline('');
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   191
		
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   192
		posX = this.mousePosX - this.notifyLeftVideo;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   193
		posY = this.mousePosY - this.notifyTopVideo;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   194
		
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   195
		//On regarde si on a touché un snapshot.
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   196
		var snapshot = this.positionToSN(posX, posY);
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   197
		
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   198
		if(snapshot && !this.isOnSearchNotification(this.mousePosX, this.mousePosY) && !this.isOnSearchExitIcon(this.mousePosX, this.mousePosY))
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   199
		{
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   200
			this.canMoveToNeighbour = true;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   201
			var id = snapshot.attr('id').replace('snapshotDiv-', '');
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   202
			this.correctMoveToNeighbour(id, posX, posY);
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   203
			this.canMoveToNeighbour = false;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   204
		}
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   205
	}
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   206
	
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   207
	//Si on est sur l'icone de sortie de recherche.
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   208
	if(this.isOnSearchExitIcon(this.mousePosX, this.mousePosY) && !this.helpDisplayed)
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   209
	{
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   210
		//On ferme l'aide.
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   211
		this.removeSearchExitIcon();
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   212
		
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   213
		this.removeNotifications();
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   214
		if(this.currentMode == 'SEARCH')
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   215
		{
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   216
			this.player.widgets[0].removeSearchByGesture();
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   217
			this.currentMode = 'VIDEO';
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   218
			this.currentSearchGesture[this.centerId] = '';
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   219
		}
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   220
		else if(this.currentMode == 'TIMELINE')
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   221
		{
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   222
			this.player.widgets[0].removeSearchByGesture();
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   223
			this.currentMode = 'TIMELINE';
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   224
			this.currentSearchGesture[this.centerId] = '';
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   225
		}
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   226
		else if(this.currentMode == 'FILTER')
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   227
		{
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   228
			this.removeFilter();
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   229
		}
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   230
		
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   231
		this.alreadyOnNotification = false;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   232
		this.isCurrentlyInASearchByGesture = false;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   233
		this.curvesGesturesFound = false;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   234
		this.canDrawNextCurve = false;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   235
		this.isSearchByCurvesOn = false;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   236
		this.canNotifyHelp = false;
77
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   237
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   238
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   239
	this.isTouchStart = false;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   240
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   241
	//Si on était en train de tracer une courbe.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   242
	if(this.isSearchByCurvesOn)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   243
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   244
		//On dit au module de recherche qu'on arrête de tracer des courbes.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   245
		this.searchCanvas.onPointerOut();
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   246
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   247
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   248
	this.mousePosLastX = null;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   249
	this.mousePosLastY = null;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   250
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   251
	//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
   252
	if(this.touchUpDownDelta <= this.config.touchUpDownDeltaTreshold)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   253
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   254
		//Si on est sur un snapshot prézoomé.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   255
		if(this.isOnAPrezoomSN && this.previousZoomedSN != '' && (this.currentMode == 'MOSAIC' || this.currentMode == 'FILTER') && !this.isPrezooming)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   256
		{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   257
			this.zoom();
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   258
		}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   259
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   260
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   261
	//On réinitialise le delta, on quitte la recherche par courbes.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   262
	this.touchUpDownDelta = 0;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   263
	this.isSearchByCurvesOn = false;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   264
	this.leaveSearch();
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   265
	
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   266
	//Si on est en mode de filtrage et qu'on a une gesture de filtrage trouvée.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   267
	if(this.currentMode == 'FILTER' && this.filterSearchedType != '')
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   268
	{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   269
		//On notifie.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   270
		this.removeNotifications();
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   271
		this.filterGesture(this.filterSearchedType, 'valid');
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   272
	}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   273
	this.isTouchMove = false;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   274
}
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   275
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   276
/*
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   277
 * Donne éventuellement un snapshot d'après les coordonnées passées en paramètres.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   278
 * Renvoie null sinon.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   279
*/
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   280
Mosaic.prototype.positionToSN = function(x, y)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   281
{
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   282
    if(this.helpDisplayed)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   283
    {
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   284
        return;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   285
    }
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   286
    
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   287
    //Taille de la marge des snapshots.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   288
    var m = parseInt($('.snapshotDivs').css('margin-left'));
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   289
    
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   290
    //Dimensions d'un snapshot de la mosaïque.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   291
    var W = $('.snapshotDivs').width() + m * 2, H = $('.snapshotDivs').height() + m * 2;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   292
    
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   293
    //Position supposée du snapshot dans la mosaïque.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   294
    //Au départ on ne sélectionne rien.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   295
    var i = -1, j = -1;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   296
    
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   297
    //Espace de centrage vertical de la mosaïque.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   298
    var top_margin = parseInt(this.MPTop_margin);
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   299
    //Dimensions de la mosaïque en nombre de snapshots.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   300
    var mosW = this.config.imagesByLine, mosH = this.config.imagesToShow / mosW;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   301
    
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   302
    //Si le pointeur se trouve au niveau de la mosaïque.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   303
    if(x < W * mosW && y >= top_margin && y < H * mosH + top_margin)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   304
    {
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   305
        //Si le pointeur est sur une des bordures.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   306
        var xb = x % W;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   307
        var yb = y - top_margin;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   308
        yb %= H;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   309
        
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   310
        if(xb < m || xb > W - m || yb < m || yb > H - m)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   311
        {
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   312
            //On renvoie null.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   313
            return null;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   314
        }
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   315
        //Sinon il est forcément sur un des snapshots.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   316
        else
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   317
        {
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   318
            i = Math.floor(x / W);
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   319
            j = Math.floor((y - top_margin) / H);
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   320
        }
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   321
        
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   322
        //On passe des coordonnées 2D en 1D.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   323
        var snapshot = $('#snapshotDiv-' + (j * mosW + i));
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   324
        
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   325
        //Si le snapshot a été filtré, on renvoie null si on se trouve dans la mosaïque.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   326
        if(this.isMosaicFiltered && (this.currentMode == "MOSAIC" || this.currentMode == "FILTER") && snapshot.css('opacity') == 0)
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   327
        {
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   328
            return null;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   329
        }
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   330
        
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   331
        //On renvoie le snapshot.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   332
        return snapshot;
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   333
    }
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   334
    
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   335
    //Si on est arrivé là, c'est que le pointeur n'est pas dans la mosaïque.
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   336
    return null;
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   337
}
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   338
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   339
/*
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   340
 * Se déplace dans la timeline lorsque le doigt est dessus.
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   341
*/
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   342
Mosaic.prototype.goToTimeline = function()
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   343
{
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   344
	var time, TL = $('.Ldt-Timeline'), P = $('.LdtPlayer');
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   345
		
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   346
	//Si le pointeur est trop à gauche, on met le curseur de lecture à 0.
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   347
	if(this.mousePosX < P.position().left)
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   348
	{
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   349
		time = 0;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   350
	}
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   351
	//S'il est trop à droite, on le place à la fin.
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   352
	else if(this.mousePosX > (+P.position().left + TL.width()))
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   353
	{
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   354
		time = this.player.widgets[0].source.getDuration().getSeconds();
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   355
	}
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   356
	//Sinon, on le met à la position du pointeur.
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   357
	else
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   358
	{
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   359
		time = this.player.widgets[0].scaleIntervals(P.position().left, (+P.position().left + TL.width()), 0, this.player.widgets[0].source.getDuration().getSeconds(), this.mousePosX);
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   360
	}
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   361
	
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   362
	this.player.popcorn.currentTime(time);
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   363
	this.player.popcorn.play();
77
205409da0f32 Front IDILL:
bastiena
parents:
diff changeset
   364
}