front_idill/src/player/metadataplayer/Timeline.js
author bastiena
Thu, 05 Jul 2012 16:04:33 +0200
changeset 45 0e29ae4568a0
parent 44 8393d3473b98
child 46 9d7a2aa112fb
permissions -rw-r--r--
Front IDILL: Segment detector created for mouse interactions curves detection
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
     1
/*
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
     2
 The Timeline Widget fits right under the video
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
     3
 */
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
     4
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
     5
IriSP.Widgets.Timeline = function(player, config) {
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
     6
	
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
     7
    IriSP.Widgets.Widget.call(this, player, config);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
     8
	this.bindPopcorn("timeupdate","onTimeupdate");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
     9
	this.bindPopcorn("loadedmetadata","ready");
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
    10
	this.bindPopcorn("markersready","onMarkersReady");
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    11
    //this.bindPopcorn("IriSP.PlayerWidget.MouseOver","onMouseover");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    12
    //this.bindPopcorn("IriSP.PlayerWidget.MouseOut","onMouseout");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    13
	this.timelineSelected = false;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    14
	this.markerShowTime = 200;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    15
	this.markerLastTime = 5000;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    16
	this.markerBigShown = false;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    17
	this.currentMarkerIdx = -1;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    18
	this.previousMarkerIdx = -1;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    19
	this.hideTimeout;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    20
	this.currentMode = "VIDEO";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    21
	this.paused = false
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    22
	this.top_epsilon = 0;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    23
	this.imgDir = "player/img/";
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
    24
	this.markersDir = "pictos/small/";
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
    25
	this.player = player;
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
    26
	this.isCurrentlyInASearchByGesture = false;
45
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    27
	this.mouseInteractions = false;
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    28
	
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
    29
	//Id du marqueur enregistré.
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
    30
	this.currentMarkerId;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
    31
	
45
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    32
	this.gestures = ["fall", "jump", "circle", "screw", "bend", "arc", "knee-up", "right-angle", "wave", "no-motion", "contact"];
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    33
	this.gesturesText = ["chute", "saut", "rotation", "rotation de groupe", "inclinaison", "port de bras", "levé de genou", "angle droit", "ondulation", "immobilité", "contact"];
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    34
	
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    35
	this.annotations = this.annotationsFilter(this.source.getAnnotations(), this.gestures, this.isGesture);
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    36
	
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    37
	// for(var a = 0 ; a < this.annotations.length ; a++)
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    38
		// console.log("A : " + this.annotations[a].annotationType.contents.title);
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    39
};
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    40
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    41
IriSP.Widgets.Timeline.prototype = new IriSP.Widgets.Widget();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    42
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    43
IriSP.Widgets.Timeline.prototype.isGesture = function(element, index, array)
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    44
{
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    45
	return ($.inArray(element.annotationType.contents.title, array) > -1);
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    46
}
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    47
45
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    48
/*
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    49
 * Spécifie si on est en événements souris ou non.
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    50
*/
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    51
IriSP.Widgets.Timeline.prototype.setMouseInteractions = function(mouseInteractions)
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    52
{
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    53
	this.mouseInteractions = mouseInteractions;
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    54
	
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    55
	if(mouseInteractions)
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    56
	{
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    57
		this.markersDir += 'MI/';
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    58
	}
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    59
}
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    60
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
    61
//Fonction associée à l'événement : les marqueurs sont prêts.
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
    62
IriSP.Widgets.Timeline.prototype.onMarkersReady = function() {}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
    63
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    64
//Fonction de filtrage de tableaux
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    65
IriSP.Widgets.Timeline.prototype.annotationsFilter = function(annotations, gestures, fun /*, thisp*/)
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    66
{
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    67
	var len = annotations.length;
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    68
	if (typeof fun != "function")
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    69
		throw new TypeError();
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    70
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    71
	var res = new Array();
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    72
	var thisp = arguments[1];
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    73
	for (var i = 0; i < len; i++)
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    74
	{
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    75
		if (i in annotations)
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    76
		{
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    77
			var val = annotations[i]; // in case fun mutates this
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    78
			if (fun.call(thisp, val, i, gestures))
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    79
			{
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    80
				res.push(val);
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    81
			}
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    82
		}
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    83
	}
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    84
	return res;
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    85
};
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    86
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    87
IriSP.Widgets.Timeline.prototype.defaults = {
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
    88
    minimized_height : 114,//44,
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
    89
    maximized_height : 114,
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
    90
	middle_height: 10,//4,
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    91
	timelineBorderLength : 6,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    92
    minimize_timeout : 1500 // time before minimizing timeline after mouseout
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    93
};
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    94
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    95
IriSP.Widgets.Timeline.prototype.draw = function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    96
    this.$timeline = IriSP.jQuery('<div>')
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    97
        .addClass("Ldt-Timeline")
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    98
        .css(this.calculateTimelineCss(this.minimized_height));
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    99
	this.$timelineMiddle = IriSP.jQuery('<div>')
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   100
		.addClass("Ldt-TimelineMiddle")
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   101
        .css(this.calculateTimelineMiddleCss(this.minimized_height, this.middle_height));
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   102
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   103
	/*this.$timelineContainer = IriSP.jQuery('<div>')
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   104
        .addClass("Ldt-TimelineContainer");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   105
	this.$timelineContainer.append(this.$timeline);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   106
	this.$timelineContainer.append(this.$timelineMiddle);*/
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   107
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   108
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   109
    this.$.append(this.$timeline);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   110
    this.$.append(this.$timelineMiddle);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   111
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   112
    var _this = this;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   113
    
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   114
    this.$timeline.slider({
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   115
        range: "min",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   116
        value: 0,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   117
        min: 0,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   118
        max: this.source.getDuration().milliseconds,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   119
        slide: function(event, ui) {
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   120
			if(_this.player.popcorn)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   121
			{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   122
				_this.player.popcorn.currentTime(Math.floor(ui.value/1000));
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   123
				_this.player.popcorn.trigger("IriSP.Mediafragment.setHashToTime");
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   124
			}
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   125
			
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   126
			// console.log("manual " + _this.previousMarkerIdx);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   127
			//On supprime le marqueur précédemment affiché si c'est le cas.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   128
			if(_this.previousMarkerIdx > -1)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   129
			{
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   130
				// /!\ var annotations = _this.source.getAnnotations();
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   131
				
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   132
				// console.log("EXT hide idx " + _this.previousMarkerIdx);
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   133
				// /!\ var previousMarker = IriSP.jQuery("#" + annotations[_this.previousMarkerIdx].id.replace(":", "_"));
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   134
				var previousMarker = IriSP.jQuery("#" + _this.annotations[_this.previousMarkerIdx].id.replace(":", "_"));
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   135
				_this.hideMarkerBig(previousMarker);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   136
				// console.log("EXT hide " + _this.previousMarkerIdx);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   137
			}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   138
        }
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   139
    });
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   140
	
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   141
    this.$handle = this.$timeline.find('.ui-slider-handle');
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   142
    
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   143
    this.$handle.css(this.calculateHandleCss(this.minimized_height));
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   144
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   145
    this.$
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   146
        .mouseover(this.functionWrapper("onMouseover"))
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   147
        .mouseout(this.functionWrapper("onMouseout"));
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   148
		IriSP.jQuery('body').keypress(function(evt) {_this.keyPress(evt)});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   149
    
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   150
    this.maximized = false;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   151
    this.timeoutId = false;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   152
};
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   153
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   154
/*
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   155
 * Starts playing the video when it's ready.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   156
*/
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   157
IriSP.Widgets.Timeline.prototype.ready = function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   158
	this.player.popcorn.play();
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   159
	this.player.popcorn.mute();
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   160
	this.processMarkers();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   161
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   162
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   163
/*
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   164
 * Scale a value from [A, B] to [C, D].
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   165
*/
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   166
IriSP.Widgets.Timeline.prototype.scaleIntervals = function(A, B, C, D, val) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   167
	if(C == D)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   168
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   169
		return C;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   170
	}	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   171
	if(B != A)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   172
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   173
		return D / (B - A) * (val - A);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   174
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   175
	else
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   176
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   177
		//If A and B have the same sign.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   178
		if(A * B > 0)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   179
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   180
			//If they are positive.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   181
			if(A > 0)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   182
			{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   183
				return (D - C)/2;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   184
			}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   185
			else
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   186
			{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   187
				return (C - D)/2;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   188
			}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   189
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   190
		else
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   191
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   192
			return (C + D)/2;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   193
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   194
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   195
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   196
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   197
/*
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   198
 * Process the markers.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   199
*/
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   200
IriSP.Widgets.Timeline.prototype.processMarkers = function() {
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   201
	console.trace();
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   202
	console.log('PROCESSING MARKERS');
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   203
	
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   204
	var _this = this;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   205
	var markers = "";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   206
	var timelineMiddleTop = this.$timelineMiddle.position().top;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   207
	
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   208
	for(var i = 0 ; i < this.annotations.length ; i++)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   209
	{
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   210
		markers += "<div class='Ldt-Marker' id='" + this.annotations[i].id.replace(":", "_") + "'></div>";
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   211
		// console.log(annotations[i].begin.milliseconds);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   212
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   213
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   214
	this.$.append(markers);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   215
	var markerHeight = IriSP.jQuery(".Ldt-Marker").height();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   216
	IriSP.jQuery(".Ldt-Marker").css("z-align", "150");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   217
	
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   218
	console.log('IN PROCESSING');
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   219
	
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   220
	for(var i = 0 ; i < this.annotations.length ; i++)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   221
	{
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   222
		IriSP.jQuery("#" + this.annotations[i].id.replace(":", "_")).css(
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   223
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   224
			top: timelineMiddleTop + "px",
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   225
			left: Math.floor(+this.scaleIntervals(0, this.source.getDuration().getSeconds(), 0, this.$timeline.width(), this.annotations[i].begin/1000) + this.$timeline.position().left) + "px",
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   226
			"margin-top": (-_this.$timeline.height()/2 - markerHeight/2) - this.top_epsilon + "px"
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   227
		});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   228
	}
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   229
	
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   230
	console.log('MARKERS PROCESSED');
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   231
	
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   232
	//On lance l'événement pour dire à popcorn que les marqueurs sont utilisables.
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   233
	// this.player.popcorn.trigger(IriSP.Widgets.Timeline.onMarkersReady);
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   234
	this.player.popcorn.trigger("markersready");
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   235
	//console.log('markers processed');
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   236
}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   237
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   238
/*
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   239
 * Fonction de recherche par gesures.
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   240
*/
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   241
IriSP.Widgets.Timeline.prototype.searchByGesture = function(typeName)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   242
{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   243
	this.notifySearch1Gesture(typeName, "valid");
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   244
		
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   245
	if(typeName != '' || typeName != undefined)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   246
	{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   247
		if(_.include(this.gestures, typeName))
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   248
		{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   249
			this.currentMode = "SEARCH";
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   250
			this.hideMarkersSearch(typeName);
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   251
			this.isCurrentlyInASearchByGesture = true;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   252
		}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   253
		else
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   254
		{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   255
			// alert("Unknown gesture type. Operation aborted.");
45
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
   256
			// this.removeSearch1Gesture();
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
   257
			// this.notifySearch1Gesture(typeName, "none");
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   258
		}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   259
	}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   260
}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   261
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   262
/*
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   263
 * Fonction de suppression de recherche par gesures.
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   264
*/
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   265
IriSP.Widgets.Timeline.prototype.removeSearchByGesture = function()
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   266
{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   267
	this.removeSearch1Gesture();
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   268
	this.hideMarkersSearch();
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   269
	this.isCurrentlyInASearchByGesture = false;
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   270
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   271
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   272
/*
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   273
 * Place the cursor on the timeline depending on the keytyped.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   274
*/
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   275
IriSP.Widgets.Timeline.prototype.keyPress = function(e) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   276
	var key = this.whichKey(e.which);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   277
	var time = 0;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   278
	
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   279
	// console.log($(this));
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   280
	
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   281
	if(key > -1 && key < 11)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   282
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   283
		time = this.source.getDuration().getSeconds()/10*key;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   284
		this.$timeline.slider("value",time);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   285
		this.player.popcorn.currentTime(time);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   286
		
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   287
		//On supprime le marqueur précédemment affiché si c'est le cas.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   288
		if(this.previousMarkerIdx > -1)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   289
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   290
			// console.log("EXT hide idx " + this.previousMarkerIdx);
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   291
			var previousMarker = IriSP.jQuery("#" + this.annotations[this.previousMarkerIdx].id.replace(":", "_"));
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   292
			this.hideMarkerBig(previousMarker);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   293
			// console.log("EXT hide " + this.previousMarkerIdx);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   294
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   295
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   296
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   297
	if(key == 11)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   298
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   299
		if(!this.timelineSelected)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   300
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   301
			this.currentMode = "TIMELINE";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   302
			this.selectTimeline();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   303
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   304
		else
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   305
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   306
			this.currentMode = "VIDEO";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   307
			this.deselectTimeline();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   308
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   309
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   310
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   311
	if(key == 12)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   312
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   313
		this.hideMarkersSearch();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   314
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   315
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   316
	if(key == 13)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   317
	{
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   318
		var gesturesStr = '';
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   319
		for(var i = 0 ; i < this.gestures.length ; i++)
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   320
		{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   321
			gesturesStr += this.gestures[i] + ", ";
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   322
		}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   323
		gesturesStr = gesturesStr.substr(0, gesturesStr.length - 2);
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   324
		
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   325
		/*if(IriSP.jQuery('#notify_search_1gesture').length > 0)
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   326
		{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   327
			this.removeSearch1Gesture();
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   328
		}*/
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   329
		
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   330
		var typeName = prompt("Please enter a type name among (" + gesturesStr + ").", "");
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   331
		
45
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
   332
		// this.notifySearch1Gesture(typeName, "valid");
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   333
		
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   334
		if(typeName != '' || typeName != undefined)
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   335
		{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   336
			if(_.include(this.gestures, typeName))
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   337
			{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   338
				this.currentMode = "SEARCH";
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   339
				this.hideMarkersSearch(typeName);
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   340
			}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   341
			else
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   342
			{
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   343
				// alert("Unknown gesture type. Operation aborted.");
45
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
   344
				// this.removeSearch1Gesture();
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
   345
				// this.notifySearch1Gesture(typeName, "none");
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   346
			}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   347
		}
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   348
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   349
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   350
	if(key == 21)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   351
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   352
		// console.log(this);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   353
		if(!this.paused)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   354
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   355
			this.paused = true;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   356
			this.player.popcorn.pause();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   357
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   358
		else
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   359
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   360
			this.paused = false;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   361
			this.player.popcorn.play();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   362
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   363
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   364
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   365
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   366
/*
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   367
 * Find the key corresponding to a given code.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   368
*/
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   369
IriSP.Widgets.Timeline.prototype.whichKey = function(code) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   370
	var key;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   371
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   372
	console.log(code);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   373
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   374
	if(code > 47 && code < 58)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   375
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   376
		return (code - 48);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   377
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   378
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   379
	if(code == 115 || code == 83)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   380
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   381
		return 11;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   382
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   383
	
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   384
	//m ou M pour quitter une recherche.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   385
	if(code == 109 || code == 77)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   386
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   387
		return 12;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   388
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   389
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   390
	//p ou P pour mettre la vidéo en pause.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   391
	if(code == 112 || code == 80)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   392
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   393
		return 21;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   394
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   395
	
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   396
	//n ou N pour une recherche par type.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   397
	if(code == 110 || code == 78)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   398
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   399
		return 13;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   400
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   401
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   402
	switch(code)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   403
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   404
		case 224:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   405
			key = 0;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   406
		break;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   407
		case 38:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   408
			key = 1;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   409
		break;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   410
		case 233:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   411
			key = 2;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   412
		break;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   413
		case 34:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   414
			key = 3;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   415
		break;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   416
		case 39:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   417
			key = 4;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   418
		break;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   419
		case 40:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   420
			key = 5;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   421
		break;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   422
		case 45:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   423
			key = 6;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   424
		break;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   425
		case 232:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   426
			key = 7;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   427
		break;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   428
		case 95:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   429
			key = 8;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   430
		break;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   431
		case 231:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   432
			key = 9;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   433
		break;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   434
		default:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   435
			key = -1;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   436
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   437
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   438
	return key;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   439
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   440
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   441
IriSP.Widgets.Timeline.prototype.selectTimeline = function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   442
	this.timelineSelected = true;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   443
	this.$timelineBorderUp = "<div class='TL_Borders' id='TL_BorderUp'></div>";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   444
	this.$timelineBorderDown = "<div class='TL_Borders' id='TL_BorderDown'></div>";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   445
	this.$timelineBorderLeft = "<div class='TL_Borders' id='TL_BorderLeft'></div>";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   446
	this.$timelineBorderRight = "<div class='TL_Borders' id='TL_BorderRight'></div>";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   447
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   448
	this.$arrowUp = "<div class='TL_Arrows' id='TL_ArrowUp'></div>";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   449
	this.$arrowDown = "<div class='TL_Arrows' id='TL_ArrowDown'></div>";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   450
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   451
	this.$.append(this.$timelineBorderUp + this.$timelineBorderDown + this.$timelineBorderLeft + this.$timelineBorderRight + this.$arrowUp + this.$arrowDown);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   452
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   453
	var timelineTop = IriSP.jQuery("#LdtPlayer").position().top + IriSP.jQuery("#LdtPlayer").height();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   454
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   455
	IriSP.jQuery("#TL_BorderUp").css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   456
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   457
		"margin-top": -this.$timeline.height() - this.top_epsilon,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   458
		left: this.$timeline.position().left,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   459
		width: this.$timeline.width(),
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   460
		height: this.timelineBorderLength
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   461
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   462
	IriSP.jQuery("#TL_BorderDown").css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   463
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   464
		"margin-top": -this.timelineBorderLength - 2 - this.top_epsilon,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   465
		left: this.$timeline.position().left,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   466
		width: this.$timeline.width(),
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   467
		height: this.timelineBorderLength
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   468
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   469
	IriSP.jQuery("#TL_BorderLeft").css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   470
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   471
		"margin-top": -this.$timeline.height() - this.top_epsilon,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   472
		left: this.$timeline.position().left,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   473
		width: this.timelineBorderLength,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   474
		height: this.$timeline.height()
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   475
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   476
	IriSP.jQuery("#TL_BorderRight").css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   477
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   478
		"margin-top": -this.$timeline.height() - this.top_epsilon,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   479
		left: +this.$timeline.position().left + this.$timeline.width() - this.timelineBorderLength - 2,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   480
		width: this.timelineBorderLength,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   481
		height: this.$timeline.height()
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   482
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   483
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   484
	IriSP.jQuery("#TL_ArrowUp").css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   485
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   486
		"background-image": "url(" + this.imgDir + "arrow_up.png)",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   487
		"margin-top": -this.$timeline.height() - IriSP.jQuery("#TL_ArrowUp").height() - this.top_epsilon,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   488
		left: this.$timeline.position().left - IriSP.jQuery("#TL_ArrowUp").width()/2,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   489
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   490
	IriSP.jQuery("#TL_ArrowDown").css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   491
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   492
		"background-image": "url(" + this.imgDir + "arrow_down.png)",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   493
		"margin-top": -this.timelineBorderLength + this.timelineBorderLength - this.top_epsilon,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   494
		left: this.$timeline.position().left - IriSP.jQuery("#TL_ArrowUp").width()/2,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   495
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   496
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   497
	IriSP.jQuery(".Ldt-Timeline .ui-slider-range").css("background-image", "url(" + this.imgDir + "past_timeline.png)");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   498
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   499
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   500
IriSP.Widgets.Timeline.prototype.deselectTimeline = function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   501
	this.timelineSelected = false;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   502
	IriSP.jQuery(".TL_Borders").remove();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   503
	IriSP.jQuery(".TL_Arrows").remove();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   504
	IriSP.jQuery(".Ldt-Timeline .ui-slider-range").css("background-image", "url(" + this.imgDir + "selected_timeline.png)");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   505
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   506
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   507
IriSP.Widgets.Timeline.prototype.onTimeupdate = function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   508
    var _time = this.player.popcorn.currentTime();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   509
	var arrowLeft = Math.floor(+this.scaleIntervals(0, this.source.getDuration().getSeconds(), 0, this.$timeline.width(), _time) + this.$timeline.position().left) - IriSP.jQuery("#TL_ArrowUp").width()/2 + "px";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   510
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   511
    this.$timeline.slider("value",_time*1000);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   512
	IriSP.jQuery(".TL_Arrows").css("display", "block");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   513
	IriSP.jQuery("#TL_ArrowUp").css("left", arrowLeft);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   514
	IriSP.jQuery("#TL_ArrowDown").css("left", arrowLeft);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   515
	// this.player.popcorn.trigger("IriSP.Arrow.updatePosition",{widget: this.type, time: 1000 * _time});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   516
	//Si on a une distance de 500 ms à un marqueur, on l'affiche.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   517
	var nearestMarkerIdx = 0;
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   518
	for(var i = 0 ; i < this.annotations.length ; i++)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   519
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   520
		//S'il existe des marqueurs dans l'intervalle de temps actuel (ici 500ms).
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   521
		if(Math.abs(_time*1000 - this.annotations[i].begin.milliseconds) <= 250)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   522
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   523
			// console.log("1) i = " + i + " " + Math.abs(_time*1000 - annotations[i].begin.milliseconds));
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   524
			
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   525
			//On sélectionne le plus proche marqueur (dans les cas où il en existe plusieurs dans l'intervalle des 1s) ou bien le premier marqueur.
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   526
			if(Math.abs(_time*1000 - this.annotations[i].begin.milliseconds) < Math.abs(_time*1000 - this.annotations[nearestMarkerIdx].begin.milliseconds) || i == nearestMarkerIdx)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   527
			{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   528
				// console.log("2) " + Math.abs(_time*1000 - annotations[i].begin.milliseconds) + " < " + Math.abs(_time*1000 - annotations[nearestMarkerIdx].begin.milliseconds));
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   529
				//Si le prochain marqueur se situe après le curseur de lecture, on passe donc au marqueur le plus proche.
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   530
				if(_time*1000 < this.annotations[i].begin.milliseconds)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   531
				{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   532
					// console.log("3) " + _time*1000 + " < " + annotations[i].begin.milliseconds);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   533
					// console.log("4) " + "nearest = " + i);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   534
					nearestMarkerIdx = i;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   535
					// console.log("5a0) before");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   536
					//S'il y a un changement de marqueur (marqueur actuel différent du précédent).
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   537
					if(nearestMarkerIdx != this.previousMarkerIdx)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   538
					{
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   539
						var currentMarker = IriSP.jQuery("#" + this.annotations[nearestMarkerIdx].id.replace(":", "_"));
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   540
						//S'il existe un marqueur précédent, on le cache.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   541
						if(this.previousMarkerIdx > -1)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   542
						{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   543
							// console.log("hide idx " + this.previousMarkerIdx);
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   544
							var previousMarker = IriSP.jQuery("#" + this.annotations[this.previousMarkerIdx].id.replace(":", "_"));
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   545
							this.hideMarkerBig(previousMarker);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   546
							// console.log("5a) hide " + this.previousMarkerIdx);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   547
						}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   548
						
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   549
						// console.log("5b) show " + nearestMarkerIdx);
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   550
						this.showMarkerBig(currentMarker, this.annotations[nearestMarkerIdx].annotationType.contents.title);
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   551
						//Mise à jour du marqueur précédent s'il y a un changement.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   552
						this.previousMarkerIdx = nearestMarkerIdx;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   553
						// console.log("MAJ : " + this.previousMarkerIdx);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   554
					}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   555
				}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   556
			}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   557
			// nearestMarker = (Math.abs(_time*1000 - annotations[i].begin.milliseconds) < Math.abs(_time*1000 - annotations[nearestMarker].begin.milliseconds) && annotations[i].begin.milliseconds >= annotations[nearestMarker].begin.milliseconds && annotations[i].begin.milliseconds >= _time*1000) ? i : nearestMarker;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   558
			this.currentMarkerIdx = nearestMarkerIdx;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   559
			// this.showMarkerBig(IriSP.jQuery("#" + annotations[i].id.replace(":", "_")), annotations[i].annotationType.contents.title);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   560
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   561
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   562
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   563
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   564
IriSP.Widgets.Timeline.prototype.timeDisplayUpdater = function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   565
    var _time = this.player.popcorn.currentTime();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   566
	var arrowLeft = Math.floor(+this.scaleIntervals(0, this.source.getDuration().getSeconds(), 0, this.$timeline.width(), _time) + this.$timeline.position().left) -
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   567
    this.$timeline.slider("value",_time*1000);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   568
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   569
	IriSP.jQuery(".TL_Arrows").css("display", "block");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   570
	IriSP.jQuery("#TL_ArrowUp").css("left", arrowLeft);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   571
	IriSP.jQuery("#TL_ArrowDown").css("left", arrowLeft);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   572
    // this.player.popcorn.trigger("IriSP.Arrow.updatePosition",{widget: this.type, time: 1000 * _time});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   573
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   574
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   575
IriSP.Widgets.Timeline.prototype.onMouseover = function() {}
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   576
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   577
IriSP.Widgets.Timeline.prototype.onMouseout = function() {}
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   578
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   579
IriSP.Widgets.Timeline.prototype.animateToHeight = function(_height) {}
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   580
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   581
IriSP.Widgets.Timeline.prototype.calculateTimelineCss = function(_size) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   582
	var middleWidth = this.player.config.gui.width;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   583
    return {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   584
		position: "absolute",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   585
		top: "0px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   586
		left: "0px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   587
		width: middleWidth + "px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   588
        height: _size + "px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   589
        "margin-top": (-this.minimized_height - this.top_epsilon) + "px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   590
		"z-align": "50"
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   591
    };
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   592
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   593
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   594
IriSP.Widgets.Timeline.prototype.calculateTimelineMiddleCss = function(_size, _middleSize) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   595
	var middleWidth = this.player.config.gui.width;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   596
    return {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   597
		position: "absolute",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   598
		top: "0px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   599
		left: "0px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   600
		width: middleWidth + "px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   601
        height: _middleSize + "px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   602
        "margin-top": (-this.minimized_height/2 - _middleSize/2 - this.top_epsilon) + "px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   603
		"z-align": "100"
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   604
    };
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   605
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   606
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   607
IriSP.Widgets.Timeline.prototype.calculateHandleCss = function(_size) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   608
    return {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   609
		position: "absolute",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   610
		top: "0px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   611
		left: "0px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   612
        height: (2 + _size) + "px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   613
        width: (2 + _size) + "px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   614
        "margin-left": -Math.ceil(2 + _size / 2) + "px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   615
		"z-align": "60"
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   616
    }
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   617
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   618
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   619
IriSP.Widgets.Timeline.prototype.showMarkerBig = function(marker, type) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   620
	// console.log("avant");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   621
	if(this.markerBigShown)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   622
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   623
		return;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   624
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   625
	// console.log("apres");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   626
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   627
	clearTimeout(this.hideTimeout);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   628
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   629
	var _this = this;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   630
	
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   631
	var markerTop, markerLeft;
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   632
	
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   633
	if(marker.position() == null)
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   634
	{
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   635
		markerTop = 0;
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   636
		markerLeft = 0;
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   637
	}
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   638
	else
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   639
	{
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   640
		markerTop = marker.position().top;
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   641
		markerLeft = marker.position().left;
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   642
	}
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   643
	
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   644
	var markerWidth = marker.width(), markerHeight = marker.height();
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   645
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   646
	this.markerBigShown = true;
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   647
	var markerBig = "<div class='TL_MarkersBig' id='MB_Text'>" + this.gesturesText[IriSP.jQuery.inArray(type, this.gestures)] + "<div class='TL_MarkersBig' id='MB_Spike'></div></div><div class='TL_MarkersBig' id='MB_Pic'></div>";
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   648
	this.$.append(markerBig);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   649
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   650
	var markerBigText = IriSP.jQuery("#MB_Text");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   651
	var markerBigSpike = IriSP.jQuery("#MB_Spike");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   652
	var markerBigPic = IriSP.jQuery("#MB_Pic");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   653
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   654
	var markerBigTextWidth = markerBigText.outerWidth(), markerBigTextHeight = markerBigText.outerHeight();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   655
	var markerBigSpikeWidth = markerBigSpike.width(), markerBigSpikeHeight = markerBigSpike.height();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   656
	var markerBigPicWidth = markerBigPic.width(), markerBigPicHeight = markerBigPic.height();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   657
	var markerBigPicTop = +parseFloat(marker.css("margin-top")) + markerHeight, markerBigPicLeft = (markerLeft - markerBigPicWidth/2 + markerWidth/2);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   658
	var markerBigTextTop = (parseFloat(marker.css("margin-top")) - markerBigTextHeight - markerBigSpikeHeight), markerBigTextLeft = (markerLeft - (markerBigTextWidth - markerBigSpikeWidth)/2);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   659
	var markerBigSpikeLeft = ((markerBigTextWidth - markerBigSpikeWidth)/2);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   660
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   661
	marker.css("background-image", "url(" + this.imgDir + "selected_marker.png)");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   662
	IriSP.jQuery("#MB_Text").css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   663
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   664
		top: markerBigTextTop,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   665
		left: markerBigTextLeft
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   666
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   667
	IriSP.jQuery("#MB_Spike").css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   668
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   669
		left: markerBigSpikeLeft
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   670
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   671
	IriSP.jQuery("#MB_Pic").css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   672
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   673
		"background-image": "url(" + this.markersDir + type + ".png)",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   674
		top: markerBigPicTop,
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   675
		left: markerBigPicLeft,
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   676
		"z-index": "400"
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   677
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   678
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   679
	IriSP.jQuery(".TL_MarkersBig").fadeTo(this.markerShowTime, "1");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   680
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   681
	//On rajoute un timeout pour supprimer le marqueur après un certain temps.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   682
	this.hideTimeout = setTimeout(function()
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   683
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   684
		_this.hideMarkerBig(marker);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   685
	}, this.markerLastTime);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   686
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   687
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   688
IriSP.Widgets.Timeline.prototype.hideMarkerBig = function(marker) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   689
	if(!this.markerBigShown)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   690
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   691
		return;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   692
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   693
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   694
	this.currentMarker = -1;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   695
	this.markerBigShown = false;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   696
	marker.css("background-image", "url(" + this.imgDir + "marker.png)");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   697
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   698
	IriSP.jQuery(".TL_MarkersBig").fadeOut(this.markerShowTime).remove();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   699
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   700
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   701
/*
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   702
 * Affiche le bas des marqueurs correspondants à la recherche.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   703
*/
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   704
IriSP.Widgets.Timeline.prototype.showMarkersSearchByType = function(type) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   705
	//Si on est en mode SEARCH.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   706
	if(this.currentMode != "SEARCH")
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   707
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   708
		return;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   709
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   710
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   711
	var _this = this;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   712
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   713
	//On récupère les annotations.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   714
	var markersSearch = "", markersPicSearch = "";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   715
	//Pour chaque annotation, on ajoute un double.
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   716
	for(var i = 0 ; i < this.annotations.length ; i++)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   717
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   718
		//Si elle correspond à la recherche.
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   719
		if(this.annotations[i].annotationType.contents.title == type)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   720
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   721
			//On récupère le marqueur associé à l'annotation.
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   722
			var markerId = this.annotations[i].id.replace(":", "_");
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   723
			
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   724
			markersSearch += "<div class='search_Marker' id='search_Marker_" + markerId + "'></div>";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   725
			markersPicSearch += "<div class='search_MBPic' id='search_Pic_" + markerId + "'></div>";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   726
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   727
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   728
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   729
	this.$.append(markersSearch + markersPicSearch);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   730
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   731
	//On place chaque double.
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   732
	for(var i = 0 ; i < this.annotations.length ; i++)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   733
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   734
		//Si elle correspond à la recherche.
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   735
		if(this.annotations[i].annotationType.contents.title == type)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   736
		{
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   737
			var markerId = this.annotations[i].id.replace(":", "_"), marker = IriSP.jQuery("#" + markerId);
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   738
			var markerTop = marker.position().top, markerLeft = marker.position().left, markerWidth = marker.width(), markerHeight = marker.height();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   739
			var markerBigPicWidth = parseFloat(IriSP.jQuery(".search_MBPic").css("width")), markerBigPicHeight = parseFloat(IriSP.jQuery(".search_MBPic").css("height")), markerBigPicTop = +parseFloat(marker.css("margin-top")) + markerHeight, markerBigPicLeft = (markerLeft - markerBigPicWidth/2 + markerWidth/2);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   740
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   741
			// console.log(markerLeft + " - " + IriSP.jQuery(".search_MBPic").css("width") + " " + markerBigPicWidth + "/2 " + markerWidth + "/2");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   742
			
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   743
			IriSP.jQuery("#search_Pic_" + markerId).css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   744
			{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   745
				position: "absolute",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   746
				"background-image": "url(" + this.markersDir + type + ".png)",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   747
				top: markerBigPicTop,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   748
				left: markerBigPicLeft,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   749
				"z-index": "300"
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   750
			}).fadeTo(this.markerShowTime, "1");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   751
			
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   752
			IriSP.jQuery("#search_Marker_" + markerId).css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   753
			{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   754
				position: "absolute",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   755
				top: _this.$timelineMiddle.position().top - _this.top_epsilon,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   756
				"margin-top": (-_this.$timeline.height()/2 - markerHeight/2),
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   757
				"background-image": "url(" + this.imgDir + "selected_marker.png)",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   758
				//top: markerTop,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   759
				left: markerLeft,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   760
				"z-index": "300"
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   761
			}).fadeTo(this.markerShowTime, "1");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   762
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   763
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   764
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   765
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   766
/*
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   767
 * Enlever une recherche faite précédemment.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   768
*/
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   769
IriSP.Widgets.Timeline.prototype.hideMarkersSearch = function(type) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   770
	//Si on est en mode SEARCH.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   771
	if(this.currentMode != "SEARCH")
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   772
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   773
		return;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   774
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   775
	
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   776
	// console.log('(0)');
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   777
	
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   778
	var _this = this;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   779
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   780
	IriSP.jQuery(".search_MBPic").fadeOut(this.markerShowTime, function()
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   781
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   782
		IriSP.jQuery("div").remove(".search_MBPic");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   783
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   784
	IriSP.jQuery(".search_Marker").fadeOut(this.markerShowTime, function()
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   785
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   786
		IriSP.jQuery("div").remove(".search_Marker");
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   787
		_this.removeSearch1Gesture();
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   788
		
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   789
		if(type == undefined)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   790
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   791
			_this.currentMode = "VIDEO";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   792
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   793
		else
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   794
		{
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   795
			// console.log('(1)');
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   796
			// console.log(_this.currentMode);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   797
			_this.showMarkersSearchByType(type);
45
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
   798
			// _this.notifySearch1Gesture(type, "valid");
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   799
			return;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   800
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   801
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   802
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   803
	if(IriSP.jQuery(".search_Marker").length == 0 && type != undefined)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   804
	{
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   805
		// console.log('(2)');
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   806
		this.showMarkersSearchByType(type);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   807
		_this.removeSearch1Gesture();
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   808
		
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   809
		if(!_.include(this.gestures, type))
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   810
		{
45
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
   811
			// this.notifySearch1Gesture(type, "none");
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   812
		}
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   813
		else
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   814
		{
45
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
   815
			// _this.notifySearch1Gesture(type, "valid");
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   816
		}
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   817
		// console.log(this.currentMode);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   818
	}
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   819
}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   820
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   821
IriSP.Widgets.Timeline.prototype.freePlayer = function()
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   822
{
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   823
	IriSP.jQuery('body').unbind('keypress');
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   824
	IriSP.jQuery('.notifications').remove();
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   825
}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   826
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   827
/*
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   828
 * Affiche la notification de validation/survol de gesture de recherche.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   829
 * Mode prend pour valeurs : "valid" ou "hover".
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   830
*/
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   831
IriSP.Widgets.Timeline.prototype.notifySearch1Gesture = function(gestureName, mode)
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   832
{
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   833
	// console.log('C');
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   834
	if(IriSP.jQuery('#notify_search_1gesture').length > 0)
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   835
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   836
		return;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   837
	}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   838
	
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   839
	//Si on a effectué une demande de recherche auparavant, on supprime la notification de demande de recherche.
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   840
	if(IriSP.jQuery('#notify_search').length > 0)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   841
	{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   842
		$('.notifications').remove();
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   843
	}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   844
	
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   845
	var _this = this;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   846
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   847
	//On spécifie les notifications en div.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   848
	var notification_search_1gesture = "<div id='notify_search_1gesture' class='notifications'></div>";
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   849
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   850
	//On les ajoute à la mosaïque.
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   851
	$('body').append(notification_search_1gesture);
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   852
	
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   853
	// console.log(this.player.config.gui.zoomTop + " " + this.player.config.gui.zoomLeft);
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   854
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   855
	//On calcule leurs coordonnées et dimensions.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   856
	var notify_width = $('.notifications').width(), notify_height = $('.notifications').height();
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   857
	var notify_margin = parseInt($('.notifications').css('margin'));
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   858
	var point_left = $(window).width() / 2 - (notify_width) / 2 - notify_margin;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   859
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   860
	if(_.include(this.gestures, gestureName))
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   861
	{
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   862
		IriSP.jQuery('#notify_search_1gesture').css('background-image', 'url("./pictos/big/' + mode + '/' + gestureName + '.png")');
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   863
	}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   864
	else if(mode == 'none')
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   865
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   866
		IriSP.jQuery('#notify_search_1gesture').css('background-image', 'url("./pictos/big/normal/inconnu.png")');
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   867
	}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   868
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   869
	if(mode != 'none')
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   870
	{
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   871
		/*IriSP.jQuery('#notify_search_1gesture').mouseover(function()
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   872
		{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   873
			IriSP.jQuery(this).css('background-image', 'url("./pictos/big/hover/' + gestureName + '.png")');
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   874
		}).mouseout(function()
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   875
		{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   876
			IriSP.jQuery(this).css('background-image', 'url("./pictos/big/valid/' + gestureName + '.png")');
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   877
		}).click(function()
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   878
		{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   879
			_this.removeSearch1Gesture();
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   880
			_this.hideMarkersSearch();
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   881
		});*/
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   882
	}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   883
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   884
	var notifyTop = this.player.config.gui.zoomTop, notifyLeft = this.player.config.gui.zoomLeft;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   885
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   886
	//On les positionne.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   887
	$('#notify_search_1gesture').css(
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   888
	{
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   889
		// top: -notifyTop,
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   890
		top: 0,//-notifyTop,
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   891
		// left: -notifyLeft + (IriSP.jQuery(window).width() - notify_width) / 2
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   892
		left: (IriSP.jQuery(window).width() - notify_width) / 2
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   893
	});
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   894
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   895
	//On les fait apparaître.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   896
	$('.notifications').css(
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   897
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   898
		opacity: "0.9"
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   899
	});
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   900
}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   901
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   902
/*
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   903
 * Supprime la notification de recherche de gesture.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   904
*/
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   905
IriSP.Widgets.Timeline.prototype.removeSearch1Gesture = function()
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   906
{
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   907
	// console.log('R');
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   908
	// console.trace();
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   909
	IriSP.jQuery('#notify_search_1gesture').remove();
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   910
}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   911
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   912
/*
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   913
 * Va au marqueur suivant/précédant lors d'un swipe right/left dans une lecture simple.
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   914
 * Prend comme argument le fait qu'il s'agisse d'un swipe left ou non (en prenant en condition toujours vraie 
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   915
 * que la fonction est appelée si et seulement si il y a swipe et que l'utilisateur ne tente pas d'aller vers un voisin.
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   916
*/
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   917
IriSP.Widgets.Timeline.prototype.switchToMarker = function(isSwipeLeft, searchedGesture)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   918
{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   919
	console.log((isSwipeLeft == true) ? 'SWIPE LEFT' : 'SWIPE RIGHT');
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   920
	
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   921
	//On prend le temps actuel du curseur en ms.
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   922
	var currentCursorPosition = this.player.popcorn.currentTime() * 1000;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   923
	//Position visée.
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   924
	var targetCursorPosition = currentCursorPosition;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   925
	//Distance minimum de l'annotation par rapport au curseur et son index, ainsi que l'index - 1 pour le cas du swipe right.
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   926
	var minDistance = this.source.getDuration().milliseconds, minIdx = 0, mindIdx_1 = 0;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   927
	
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   928
	//Si il y a au moins 1 annotation.
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   929
	if(this.annotations && this.annotations.length > 0)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   930
	{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   931
		if(isSwipeLeft)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   932
		{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   933
			//Pour toutes les annotations, on prend celle qui est la plus proche et supérieure à la position.
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   934
			for(var i = 0 ; i < this.annotations.length ; i++)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   935
			{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   936
				// console.log('curr : ' + currentCursorPosition + ' ann : ' + this.annotations[i].begin);
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   937
				if(currentCursorPosition < this.annotations[i].begin && minDistance > Math.abs(currentCursorPosition - this.annotations[i].begin))
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   938
				{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   939
					if(searchedGesture != '')
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   940
					{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   941
						if(this.annotations[i].annotationType.contents.title != searchedGesture)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   942
						{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   943
							continue;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   944
						}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   945
					}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   946
					
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   947
					minDistance = (currentCursorPosition - this.annotations[i].begin);
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   948
					minIdx = i;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   949
				}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   950
			}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   951
		}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   952
		else
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   953
		{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   954
			//Pour toutes les annotations, on prend celle qui est la plus proche et inférieure à la position.
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   955
			for(var i = 0 ; i < this.annotations.length ; i++)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   956
			{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   957
				if(currentCursorPosition > this.annotations[i].begin && minDistance > Math.abs(currentCursorPosition - this.annotations[i].begin))
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   958
				{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   959
					if(searchedGesture != '')
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   960
					{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   961
						if(this.annotations[i].annotationType.contents.title != searchedGesture)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   962
						{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   963
							continue;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   964
						}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   965
					}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   966
					
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   967
					minDistance = (currentCursorPosition - this.annotations[i].begin);
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   968
					minIdx = i;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   969
				}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   970
			}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   971
		}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   972
		
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   973
		targetCursorPosition = this.annotations[minIdx].begin;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   974
		
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   975
		if(this.annotations[minIdx].begin > 1000)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   976
		{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   977
			targetCursorPosition -= 1000;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   978
		}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   979
	}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   980
	
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   981
	this.player.popcorn.currentTime(targetCursorPosition / 1000);
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   982
}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   983
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   984
/*
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   985
 * Indique s'il y a des marqueurs devant le curseur (pour une recherche)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   986
*/
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   987
IriSP.Widgets.Timeline.prototype.isAMarkerAhead = function(searchedGesture)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   988
{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   989
	if(searchedGesture == '')
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   990
	{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   991
		return true;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   992
	}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   993
	
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   994
	//On prend le temps actuel du curseur en ms.
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   995
	var currentCursorPosition = this.player.popcorn.currentTime() * 1000;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   996
	//Position visée.
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   997
	var targetCursorPosition = currentCursorPosition;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   998
	//Distance minimum de l'annotation par rapport au curseur et son index, ainsi que l'index - 1 pour le cas du swipe right.
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   999
	var minDistance = this.source.getDuration().milliseconds, minIdx = 0, mindIdx_1 = 0;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1000
	
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1001
	//Si il y a au moins 1 annotation.
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1002
	if(this.annotations && this.annotations.length > 0)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1003
	{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1004
		//Pour toutes les annotations, on prend celle qui est la plus proche et supérieure à la position.
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1005
		for(var i = 0 ; i < this.annotations.length ; i++)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1006
		{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1007
			// console.log('curr : ' + currentCursorPosition + ' ann : ' + this.annotations[i].begin);
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1008
			if(this.annotations[i].annotationType.contents.title == searchedGesture && currentCursorPosition < this.annotations[i].begin)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1009
			{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1010
				return true;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1011
			}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1012
		}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1013
	}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1014
		
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1015
		return false;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1016
}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1017
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1018
/*
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1019
 * Indique, après un swipe, si on est au dernier marqueur d'un type recherché dans la vidéo.
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1020
*/
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1021
IriSP.Widgets.Timeline.prototype.switchToMarker2 = function(isSwipeLeft, searchedGesture)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1022
{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1023
	/*if(isSwipeLeft)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1024
	{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1025
		//Pour toutes les annotations, on prend celle qui est la plus proche et supérieure à la position.
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1026
		for(var i = 0 ; i < this.annotations.length ; i++)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1027
		{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1028
			// console.log('curr : ' + currentCursorPosition + ' ann : ' + this.annotations[i].begin);
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1029
			if(currentCursorPosition < this.annotations[i].begin && minDistance > Math.abs(currentCursorPosition - this.annotations[i].begin))
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1030
			{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1031
				if(searchedGesture != '')
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1032
				{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1033
					if(this.annotations[i].annotationType.contents.title != searchedGesture)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1034
					{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1035
						continue;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1036
					}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1037
				}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1038
				
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1039
				minDistance = (currentCursorPosition - this.annotations[i].begin);
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1040
				minIdx = i;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1041
			}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1042
		}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1043
	}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1044
	else
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1045
	{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1046
		//Pour toutes les annotations, on prend celle qui est la plus proche et inférieure à la position.
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1047
		for(var i = 0 ; i < this.annotations.length ; i++)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1048
		{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1049
			if(currentCursorPosition > this.annotations[i].begin && minDistance > Math.abs(currentCursorPosition - this.annotations[i].begin))
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1050
			{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1051
				if(searchedGesture != '')
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1052
				{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1053
					if(this.annotations[i].annotationType.contents.title != searchedGesture)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1054
					{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1055
						continue;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1056
					}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1057
				}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1058
				
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1059
				minDistance = (currentCursorPosition - this.annotations[i].begin);
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1060
				minIdx = i;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1061
			}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1062
		}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1063
	}*/
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1064
}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1065
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1066
/*
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1067
 * Quand on entre dans la vidéo après un filtrage, on va au premier marqueur correspondant à la recherche (à l'exception d'une recherche infructueuse).
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1068
*/
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1069
IriSP.Widgets.Timeline.prototype.goToFirstSearchedMarker = function(gesture)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1070
{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1071
	if(_.include(this.gestures, gesture))
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1072
	{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1073
		if(this.annotations && this.annotations.length > 0)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1074
		{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1075
			var minIdx = 0, minPosition = this.source.getDuration().milliseconds, targetCursorPosition = 0;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1076
			
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1077
			//On parcourt les annotations, pour chaque correspondant à la gesture recherchée, on trouve celle qui se trouve à la position minimum.
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1078
			for(var i = 0 ; i < this.annotations.length ; i++)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1079
			{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1080
				//Si le marker n'est pas du type recherché, on passe.
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1081
				if(this.annotations[i].annotationType.contents.title != gesture)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1082
				{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1083
					continue;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1084
				}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1085
				else if(minPosition > this.annotations[i].begin)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1086
				{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1087
					minPosition = this.annotations[i].begin;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1088
					minIdx = i;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1089
				}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1090
			}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1091
			
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1092
			targetCursorPosition = this.annotations[minIdx].begin;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1093
			
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1094
			console.log('pos : ' + targetCursorPosition);
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1095
			
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1096
			if(this.annotations[minIdx].begin > 1000)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1097
			{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1098
				targetCursorPosition -= 1000;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1099
			}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1100
			
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1101
			this.player.popcorn.currentTime(targetCursorPosition / 1000);
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1102
		}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1103
	}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1104
}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1105
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1106
/*
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1107
 * Renvoie vrai si il y a au moins une gesture de notre recherche dans les marqueurs de la video.
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1108
*/
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1109
IriSP.Widgets.Timeline.prototype.atLeastOneSearchMarker = function(gesture)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1110
{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1111
	if(_.include(this.gestures, gesture))
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1112
	{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1113
		if(this.annotations && this.annotations.length > 0)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1114
		{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1115
			//On parcourt les annotations, pour chaque correspondant à la gesture recherchée, on trouve celle qui se trouve à la position minimum.
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1116
			for(var i = 0 ; i < this.annotations.length ; i++)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1117
			{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1118
				//Si le marker est reconnu, c'est bon.
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1119
				if(this.annotations[i].annotationType.contents.title == gesture)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1120
				{
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1121
					return true;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1122
				}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1123
			}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1124
			
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1125
			return false;
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1126
		}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
  1127
	}
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
  1128
}