front_idill/src/mosaic/js/zoomInteractions.js
changeset 45 0e29ae4568a0
parent 44 8393d3473b98
child 47 4e1ee94d70b1
--- a/front_idill/src/mosaic/js/zoomInteractions.js	Fri Jun 29 16:16:24 2012 +0200
+++ b/front_idill/src/mosaic/js/zoomInteractions.js	Thu Jul 05 16:04:33 2012 +0200
@@ -4,7 +4,7 @@
  */
 mosaic.prototype.preZoom = function(snapshot)
 {
-	if(this.currentMode == "NO-USER" || this.currentMode.indexOf("INCOMING") > -1 || snapshot == null || this.helpDisplayed || this.isMosaicFiltering)
+	if(this.currentMode == "NO-USER" || this.currentMode.indexOf("INCOMING") > -1 || snapshot == null || this.helpDisplayed || this.isMosaicFiltering || this.isSearchByCurvesOn)
 	{
 		return;
 	}
@@ -15,7 +15,8 @@
 	}
 	this.preUnzoom();
 	//On enlève les notifications initiales si elles existent.
-	this.removeSelectionSearchMosaicFull();
+	// this.removeSelectionSearchMosaicFull();
+	$('.notifications').remove();
 	
     //Mosaïque.
     var _this = this;
@@ -71,9 +72,9 @@
     $('#fake-' + currentId).load(function()
     {
 	// snapshot.fadeTo(400, '0.5').delay(200).fadeTo(400, '1');
-		$('#prezoomContainer-' + currentId).css('display', 'block');
         $('#prezoomContainer-' + currentId).css('top', sTop).css('left', sLeft).css('width', (snWidth + margin)).css('height', (snHeight + margin));
         $('#prezoomSnapshot-' + currentId).css('width', (snWidth)).css('height', (snHeight));
+		$('#prezoomContainer-' + currentId).css('display', 'block');
         
         //Dimensions et coordonnées initiales du div sur lequel on zoom.
         var initialDivWidth = $('#prezoomContainer-' + currentId).width(), initialDivHeight = $('#prezoomContainer-' + currentId).height();
@@ -126,32 +127,39 @@
             left: finalDivLeft
         }, _this.config['timePrezoom'], function()
 		{
-			//On met le spinner gif sur le pointeur, s'il n'existe pas déjà.
-			if($('#spinner').length == 0)
+			if(!_this.mouseInteractions)
 			{
-				//On repère le pointeur ayant provoqué le prezoom.
-				var prezoomPointer;
-				if(!this.isMainPointerDisplayed)
+				//On met le spinner gif sur le pointeur, s'il n'existe pas déjà.
+				if($('#spinner').length == 0)
 				{
-					prezoomPointer = $('#secondPointer');
-				}
-				if(!this.isSecondPointerDisplayed)
-				{
-					prezoomPointer = $('#mainPointer');
+					//On repère le pointeur ayant provoqué le prezoom.
+					var prezoomPointer;
+					if(!_this.isMainPointerDisplayed)
+					{
+						prezoomPointer = $('#secondPointer');
+					}
+					if(!_this.isSecondPointerDisplayed)
+					{
+						prezoomPointer = $('#mainPointer');
+					}
+					
+					var spinner = "<img id='spinner'></div>";
+					$('body').append(spinner);
+					$('#spinner').css(
+					{
+						position: 'absolute',
+						top: prezoomPointer.position().top,
+						left: prezoomPointer.position().left,
+						width: 85,
+						height: 85,
+						'z-index': 600
+					});
+					$('#spinner').attr('src', './img/cursors/selector_anim_2.gif');
 				}
-				
-				var spinner = "<img id='spinner'></div>";
-				$('body').append(spinner);
-				$('#spinner').css(
-				{
-					position: 'absolute',
-					top: prezoomPointer.position().top,
-					left: prezoomPointer.position().left,
-					width: 85,
-					height: 85,
-					'z-index': 600
-				});
-				$('#spinner').attr('src', './img/cursors/selector_anim_2.gif');
+			}
+			else
+			{
+				_this.isOnAPrezoomSN = true;
 			}
 			
 			if(_this.currentMode == 'MOSAIC')
@@ -159,7 +167,7 @@
 				$('.notifications').remove();
 				_this.mosaicSelection();
 			}
-			else if(_this.currentMode == 'FILTER' && !_this.filterSearchedType)
+			else if(_this.currentMode == 'FILTER' && !_this.filterSearchedType && _this.curvesGesturesFound)
 			{
 				$('.notifications').remove();
 				_this.filterSearchAndSelection();
@@ -170,22 +178,15 @@
 				_this.filterGestureAndSelection(_this.filterSearchedType, 'valid');
 			}
 		});
-		
-		
     });
     
-	this.zoomTimeout = setTimeout(function()
+	if(!this.mouseInteractions)
 	{
-		_this.zoom();
-	}, this.config['timeoutZoom']);
-    //Si on clique sur le snapshot prézoomé, on enclenche un zoom total sur ce snapshot.
-    /*$('#prezoomContainer-' + currentId).click(function ()
-    {
-        if(this.previousZoomedSN != '')
+		this.zoomTimeout = setTimeout(function()
 		{
-            _this.zoom();
-		}
-    });*/
+			_this.zoom();
+		}, this.config['timeoutZoom']);
+	}
 }
 
 /*
@@ -208,6 +209,7 @@
 	
 	var _this = this;
 	
+	this.isOnAPrezoomSN = false;
 	clearTimeout(this.zoomTimeout);
 	
 	if(this.currentMode == 'MOSAIC')
@@ -215,12 +217,12 @@
 		$('.notifications').remove();
 		this.mosaicSelectionAndSearch();
 	}
-	else if(_this.currentMode == 'FILTER' && !this.filterSearchedType)
+	else if(_this.currentMode == 'FILTER' && !this.filterSearchedType && !this.curvesGesturesFound)
 	{
 		$('.notifications').remove();
 		this.filterSearch();
 	}
-	else if(_this.currentMode == 'FILTER' && this.filterSearchedType)
+	else if(_this.currentMode == 'FILTER' && this.filterSearchedType && !this.curvesGesturesFound)
 	{
 		$('.notifications').remove();
 		this.filterGesture(this.filterSearchedType, 'valid');
@@ -368,6 +370,54 @@
 		
 		// console.log('BBB3 : ' + _this.currentMode);
 		_this.loadPlayer(_this.snTop, _this.snLeft, _this.snWidth, _this.snHeight, newZoomTop, newZoomLeft, _this.timeToGoAt[_this.centerId]);
+		
+		$('body').click(function()
+		{
+			//Si on clique en dehors de la video centrale, alors on dézoome.
+			var TL = $('.Ldt-Timeline');
+			var TLwidth = TL.width(), TLheight = TL.height();
+			var Ptop = $('.LdtPlayer').position().top, Pleft = $('.LdtPlayer').position().left;
+			var Pheight = $('.LdtPlayer').height();
+			var MPx = _this.mousePosX, MPy = _this.mousePosY;
+			
+			//On regarde si on a cliqué sur un snapshot.
+			var SN = _this.pointerPositionToSN(MPx - _this.notifyLeftVideo, MPy - _this.notifyTopVideo, true);
+			var SNId;
+			if(SN)
+			{
+				SNId = parseInt(SN.attr('id').replace('snapshotDiv-', ''));
+			}
+			
+			if(!_this.gestureDelRequested)
+			{
+				//Si non, ou s'il ne fait pas partie des voisins.
+				if(!SNId || !_.include(_this.neighboursIds, SNId))
+				{
+					if(MPx < Pleft || MPx > (+Pleft + TLwidth) || MPy < Ptop || MPy > (+Ptop + Pheight - TLheight))
+					{
+						_this.unzoom();
+					}
+				}
+				//Si on se trouve sur un voisin, on bouge.
+				else if(SNId && _.include(_this.neighboursIds, SNId) && _this.canMoveToNeighbour)
+				{
+					_this.moveToNeighbour($('#snapshotDiv-' + SNId));
+				}
+			}
+			else
+			{
+				_this.gestureDelRequested = false;
+			}
+		});
+		
+		$('body').on('mousewheel', function(event, delta, deltaX, deltaY)
+		{
+			//Action quand on "tire" la molette vers soi.
+			if (delta < 0)
+			{
+				_this.unzoom();
+			}
+		});
     });
 }
 
@@ -383,12 +433,26 @@
         return;
 	}
 	
+	var _this = this;
+	
+	if(this.mouseInteractions)
+	{
+		$('body').unbind('click');
+		$('body').unbind('mousewheel');
+	
+		//On rebind le clic pour supprimer une recherche.
+		$('body').click(function(e)
+		{
+			_this.removeSearchNotificationIfOnIt(e.pageX, e.pageY);
+		});
+	}
+	
 	this.canSwipe = false;
 	
 	//Si la TL avait été sélectionnée, on la déselectionne.
 	if(this.currentMode == 'TIMELINE')
 	{
-		this.exitTimeline('move');
+		this.exitTimeline('unzoom');
 	}
 	
 	this.currentlyUnzooming = true;