front_idill/src/mosaic/js/mosaic.js
changeset 47 4e1ee94d70b1
parent 46 9d7a2aa112fb
child 52 277c94533395
--- a/front_idill/src/mosaic/js/mosaic.js	Fri Jul 06 13:44:25 2012 +0200
+++ b/front_idill/src/mosaic/js/mosaic.js	Mon Jul 09 14:24:42 2012 +0200
@@ -197,8 +197,8 @@
 	this.MPTop_margin;
 	this.top_margin;
 	
-	//Gesture actuellement cherchée.
-	this.currentSearchGesture = '';
+	//Gestures actuellement cherchées dans les vidéos.
+	this.currentSearchGesture = [];
 	
 	//Mosaïque locale.
 	this.localMos;
@@ -274,6 +274,8 @@
 			{
 				//On charge les images de petite taille pour ne pas surcharger la mosaïque lors de l'affichage global.
 				str += '<div id="snapshotDiv-' + i + '" class="snapshotDivs" style="opacity: 0;"><img id="snapshot-' + i + '" class="snapshots" src="snapshots-little/' + this.imgs[i] + '" /></div>';
+				//Au départ aucune vidéo n'a de gesture de recherche.
+				this.currentSearchGesture[i] = '';
 			}
 		}
 		
@@ -398,10 +400,6 @@
 				// console.log('CANVAS READY');
 				// /!\ //
 				
-				/*_this.currentSearchGesture = 'bend';
-				_this.currentMode = 'FILTER';
-				_this.searchFilter('bend');*/
-				
 				_this.previousZoomedSN = $('#snapshotDiv-' + _this.fillingIds[0]);
 			}
 		});
@@ -470,7 +468,7 @@
 						
 						/*if(!_this.curvesGesturesFound)
 						{
-							$('.notifications').remove();
+							this.removeNotifications();
 							_this.filterSearch();
 						}*/
 						
@@ -496,7 +494,7 @@
 						
 						/*if(!_this.curvesGesturesFound)
 						{
-							$('.notifications').remove();
+							this.removeNotifications();
 							_this.searchSearch();
 						}*/
 						
@@ -539,7 +537,13 @@
 							_this.player.widgets[0].searchByGesture(gesture_match);
 							_this.isCurrentlyInASearchByGesture = _this.player.widgets[0].isCurrentlyInASearchByGesture;
 							
-							$('.notifications').remove();
+							if(_this.player && _this.player.widgets[0] && _this.timeToGoAt[_this.centerId] === 0 && _this.player.widgets[0].atLeastOneSearchMarker(_this.currentSearchGesture[_this.centerId]))
+							{
+								_this.player.widgets[0].goToFirstSearchedMarker(_this.currentSearchGesture[_this.centerId]);
+							}
+							
+							_this.removeNotifications();
+							_this.currentSearchGesture[_this.centerId] = gesture_match;
 							_this.searchGesture(gesture_match, 'valid');
 							_this.curvesGesturesFound = false;
 						}
@@ -547,7 +551,7 @@
 						{
 							if(_this.isMosaicFiltered)
 							{
-								$('.notifications').remove();
+								_this.removeNotifications();
 								_this.filterSearchedType = gesture_match;
 								_this.filterGesture(gesture_match, 'valid');
 								_this.searchFilter(gesture_match);
@@ -587,12 +591,11 @@
 				_this.isSearchByCurvesOn = false;
 				_this.leaveSearch();
 				
-				if(_this.currentMode == 'FILTER' && _this.filterSearchedType != '')//if(_this.currentSearchGesture != '')
+				if(_this.currentMode == 'FILTER' && _this.filterSearchedType != '')
 				{
-					$('.notifications').remove();
-					_this.filterGesture(_this.currentSearchGesture, 'valid');
+					_this.removeNotifications();
+					_this.filterGesture(_this.filterSearchedType, 'valid');
 				}
-				
 			});
 		});
 	}
@@ -732,8 +735,13 @@
 	{
 		this.currentMode = "INCOMING-" + n;
 		this.unzoom();
-		this.currentSearchGesture = '';
-		$('.notifications').remove();
+		
+		for(var i = 0 ; i < this.config['imagesToShow'] ; i++)
+		{
+			this.currentSearchGesture[i] = '';
+		}
+		
+		this.removeNotifications();
 		this.isMosaicFiltered = false;
 		this.isCurrentlyInASearchByGesture = false;
 		$('#mainPointer').fadeTo(this.config['timePrezoom'], 0);
@@ -755,7 +763,7 @@
 			}
 			
 			this.currentMode = "MOSAIC";
-			$('.notifications').remove();
+			this.removeNotifications();
 			this.mosaicSelectionAndSearch();
 			clearTimeout(this.nouserTimeout);
 			console.log('OK');
@@ -869,7 +877,7 @@
 		{
 			this.isSwipe = true;
 			
-			if(this.currentMode == 'SEARCH' && this.isMosaicFiltered && !this.player.widgets[0].isAMarkerAhead(this.currentSearchGesture))
+			if(this.currentMode == 'SEARCH' && this.isMosaicFiltered && !this.player.widgets[0].isAMarkerAhead(this.currentSearchGesture[this.centerId]))
 			{
 				this.playNextVideo();
 			}
@@ -877,41 +885,41 @@
 			//L'utilisateur a fait un swipe left.
 			if(event.indexOf("LEFT") != -1)
 			{
-				this.player.widgets[0].switchToMarker(true, this.currentSearchGesture);
+				this.player.widgets[0].switchToMarker(true, this.currentSearchGesture[this.centerId]);
 				if(this.currentMode == 'VIDEO')
 				{
-					$('.notifications').remove();
+					this.removeNotifications();
 					this.videoSwipe('left');
 				}
-				else if(this.currentMode == 'SEARCH' && !this.currentSearchGesture)
+				else if(this.currentMode == 'SEARCH' && !this.currentSearchGesture[this.centerId])
 				{
-					$('.notifications').remove();
+					this.removeNotifications();
 					this.searchSearchAndSwipe('left');
 				}
-				else if(this.currentMode == 'SEARCH' && this.currentSearchGesture)
+				else if(this.currentMode == 'SEARCH' && this.currentSearchGesture[this.centerId])
 				{
-					$('.notifications').remove();
-					this.searchGestureAndSwipe(this.currentSearchGesture, 'valid', 'left');
+					this.removeNotifications();
+					this.searchGestureAndSwipe(this.currentSearchGesture[this.centerId], 'valid', 'left');
 				}
 			}
 			//L'utilisateur a fait un swipe right.
 			else if(event.indexOf("RIGHT") != -1)
 			{
-				this.player.widgets[0].switchToMarker(false, this.currentSearchGesture);
+				this.player.widgets[0].switchToMarker(false, this.currentSearchGesture[this.centerId]);
 				if(this.currentMode == 'VIDEO')
 				{
-					$('.notifications').remove();
+					this.removeNotifications();
 					this.videoSwipe('right');
 				}
-				else if(this.currentMode == 'SEARCH' && !this.currentSearchGesture)
+				else if(this.currentMode == 'SEARCH' && !this.currentSearchGesture[this.centerId])
 				{
-					$('.notifications').remove();
+					this.removeNotifications();
 					this.searchSearchAndSwipe('right');
 				}
-				else if(this.currentMode == 'SEARCH' && this.currentSearchGesture)
+				else if(this.currentMode == 'SEARCH' && this.currentSearchGesture[this.centerId])
 				{
-					$('.notifications').remove();
-					this.searchGestureAndSwipe(this.currentSearchGesture, 'valid', 'right');
+					this.removeNotifications();
+					this.searchGestureAndSwipe(this.currentSearchGesture[this.centerId], 'valid', 'right');
 				}
 			}
 			
@@ -921,15 +929,15 @@
 				_this.isSwipe = false;
 				
 				// /!\ //
-				$('.notifications').remove();
+				_this.removeNotifications();
 				
-				if(_this.currentMode == 'SEARCH' && !_this.currentSearchGesture)
+				if(_this.currentMode == 'SEARCH' && !_this.currentSearchGesture[_this.centerId])
 				{
 					_this.searchSearch();
 				}
-				else if(_this.currentMode == 'SEARCH' && _this.currentSearchGesture)
+				else if(_this.currentMode == 'SEARCH' && _this.currentSearchGesture[_this.centerId])
 				{
-					_this.searchGesture(_this.currentSearchGesture, 'valid');
+					_this.searchGesture(_this.currentSearchGesture[_this.centerId], 'valid');
 				}
 				
 			}, this.config['timeoutNotifySwipe']);
@@ -939,7 +947,7 @@
 	{
 		gestureReceived = event.toLowerCase();
 		gestureReceived = gestureReceived.replace('wave', 'hello');
-		this.currentSearchGesture = gestureReceived;
+		this.currentSearchGesture[centerId] = gestureReceived;
 	}
 	else if(event.indexOf("HELLO") != -1 && this.canNotifyHelp && !this.areBothPointersHere)
 	{
@@ -960,7 +968,7 @@
 			this.player.widgets[0].searchByGesture(gestureReceived);
 			this.isCurrentlyInASearchByGesture = this.player.widgets[0].isCurrentlyInASearchByGesture;
 			
-			$('.notifications').remove();
+			this.removeNotifications();
 			this.searchGesture(gestureReceived, 'valid');
 		}
 		else if(this.currentMode == "FILTER")
@@ -969,7 +977,7 @@
 			{
 				// console.log('FILTER !!!');
 				// this.notifySearch1Gesture(gestureReceived, 'valid');
-				$('.notifications').remove();
+				this.removeNotifications();
 				this.filterGesture(gestureReceived, 'valid');
 				this.searchFilter(gestureReceived);
 			}
@@ -1119,9 +1127,9 @@
 				
 				console.log('TIME TO GO AT : ' + _this.timeToGoAt[_this.centerId], _this.centerId, _this.imgs[_this.centerId]);
 				
-				if(_this.isMosaicFiltered)
-				{
-					if(_this.currentSearchGesture == '')
+				// if(_this.isMosaicFiltered)
+				// {
+					if(_this.currentSearchGesture[_this.centerId] == '')
 					{
 						_this.removeFilter();
 					}
@@ -1129,27 +1137,27 @@
 					{
 						_this.currentMode = 'SEARCH';
 						// console.log(_this.currentSearchGesture);
-						_this.player.widgets[0].searchByGesture(_this.currentSearchGesture);
+						_this.player.widgets[0].searchByGesture(_this.currentSearchGesture[_this.centerId]);
 						_this.isCurrentlyInASearchByGesture = _this.player.widgets[0].isCurrentlyInASearchByGesture;
 						
-						if(_this.timeToGoAt[_this.centerId] === 0 && _this.player.widgets[0].atLeastOneSearchMarker(_this.currentSearchGesture))
+						if(_this.timeToGoAt[_this.centerId] === 0 && _this.player.widgets[0].atLeastOneSearchMarker(_this.currentSearchGesture[_this.centerId]))
 						{
-							_this.player.widgets[0].goToFirstSearchedMarker(_this.currentSearchGesture);
+							_this.player.widgets[0].goToFirstSearchedMarker(_this.currentSearchGesture[_this.centerId]);
 						}
 						else
 						{
 							_this.player.popcorn.currentTime(_this.timeToGoAt[_this.centerId]);
 						}
 					}
-				}
+				// }
 				// /!\ //
-				else
+				/*else
 				{
 					if(_this.player.popcorn)
 					{
 						_this.player.popcorn.currentTime(_this.timeToGoAt[_this.centerId]);
 					}
-				}
+				}*/
 			});
 		}
 	});