front_idill/src/player/metadataplayer/Timeline.js
author bastiena
Wed, 30 May 2012 10:21:36 +0200
changeset 35 4267d6d27a7d
parent 33 2d9b15f99b4e
child 44 8393d3473b98
permissions -rw-r--r--
Front IDILL : Config file added dor the Front Random play at the beginning (when no user is detected) Pointers added Curves added (search and filter modes) Mosaic completion added (depletion to come later) State of the Front : just before the communication module creation
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) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
     6
    IriSP.Widgets.Widget.call(this, player, config);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
     7
	this.bindPopcorn("timeupdate","onTimeupdate");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
     8
	this.bindPopcorn("loadedmetadata","ready");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
     9
    //this.bindPopcorn("IriSP.PlayerWidget.MouseOver","onMouseover");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    10
    //this.bindPopcorn("IriSP.PlayerWidget.MouseOut","onMouseout");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    11
	this.timelineSelected = false;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    12
	this.markerShowTime = 200;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    13
	this.markerLastTime = 5000;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    14
	this.markerBigShown = false;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    15
	this.currentMarkerIdx = -1;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    16
	this.previousMarkerIdx = -1;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    17
	this.hideTimeout;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    18
	this.currentMode = "VIDEO";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    19
	this.paused = false
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    20
	this.top_epsilon = 0;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    21
	this.imgDir = "player/img/";
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
    22
	this.markersDir = "pictos/small/";
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
    23
	this.player = player;
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    24
	
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
    25
	this.gestures = ["fall", "jump", "circle", "screw", "bend", "arc", "pendulum", "knee-up", "right-angle", "wave", "slow", "hello", "no-motion", "wheel", "contact", "run"];
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    26
	
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    27
	this.annotations = this.annotationsFilter(this.source.getAnnotations(), this.gestures, this.isGesture);
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    28
	
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    29
	// for(var a = 0 ; a < this.annotations.length ; a++)
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    30
		// console.log("A : " + this.annotations[a].annotationType.contents.title);
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    31
};
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    32
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    33
IriSP.Widgets.Timeline.prototype = new IriSP.Widgets.Widget();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    34
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    35
IriSP.Widgets.Timeline.prototype.isGesture = function(element, index, array)
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    36
{
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    37
	return ($.inArray(element.annotationType.contents.title, array) > -1);
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    38
}
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    39
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    40
//Fonction de filtrage de tableaux
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    41
IriSP.Widgets.Timeline.prototype.annotationsFilter = function(annotations, gestures, fun /*, thisp*/)
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    42
{
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    43
	var len = annotations.length;
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    44
	if (typeof fun != "function")
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    45
		throw new TypeError();
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    46
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    47
	var res = new Array();
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    48
	var thisp = arguments[1];
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    49
	for (var i = 0; i < len; i++)
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    50
	{
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    51
		if (i in annotations)
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    52
		{
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    53
			var val = annotations[i]; // in case fun mutates this
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    54
			if (fun.call(thisp, val, i, gestures))
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    55
			{
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    56
				res.push(val);
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    57
			}
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    58
		}
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    59
	}
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    60
	return res;
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    61
};
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    62
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    63
IriSP.Widgets.Timeline.prototype.defaults = {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    64
    minimized_height : 44,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    65
    maximized_height : 44,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    66
	middle_height: 4,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    67
	timelineBorderLength : 6,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    68
    minimize_timeout : 1500 // time before minimizing timeline after mouseout
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    69
};
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    70
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    71
IriSP.Widgets.Timeline.prototype.draw = function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    72
    this.$timeline = IriSP.jQuery('<div>')
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    73
        .addClass("Ldt-Timeline")
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    74
        .css(this.calculateTimelineCss(this.minimized_height));
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    75
	this.$timelineMiddle = IriSP.jQuery('<div>')
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    76
		.addClass("Ldt-TimelineMiddle")
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    77
        .css(this.calculateTimelineMiddleCss(this.minimized_height, this.middle_height));
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    78
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    79
	/*this.$timelineContainer = IriSP.jQuery('<div>')
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    80
        .addClass("Ldt-TimelineContainer");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    81
	this.$timelineContainer.append(this.$timeline);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    82
	this.$timelineContainer.append(this.$timelineMiddle);*/
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    83
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    84
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    85
    this.$.append(this.$timeline);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    86
    this.$.append(this.$timelineMiddle);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    87
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    88
    var _this = this;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    89
    
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    90
    this.$timeline.slider({
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    91
        range: "min",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    92
        value: 0,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    93
        min: 0,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    94
        max: this.source.getDuration().milliseconds,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    95
        slide: function(event, ui) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    96
            _this.player.popcorn.currentTime(Math.floor(ui.value/1000));
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    97
            _this.player.popcorn.trigger("IriSP.Mediafragment.setHashToTime");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    98
			
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    99
			// console.log("manual " + _this.previousMarkerIdx);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   100
			//On supprime le marqueur précédemment affiché si c'est le cas.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   101
			if(_this.previousMarkerIdx > -1)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   102
			{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   103
				var annotations = _this.source.getAnnotations();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   104
				// console.log("EXT hide idx " + _this.previousMarkerIdx);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   105
				var previousMarker = IriSP.jQuery("#" + annotations[_this.previousMarkerIdx].id.replace(":", "_"));
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   106
				_this.hideMarkerBig(previousMarker);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   107
				// console.log("EXT hide " + _this.previousMarkerIdx);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   108
			}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   109
        }
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   110
    });
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   111
    
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   112
    this.$handle = this.$timeline.find('.ui-slider-handle');
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   113
    
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   114
    this.$handle.css(this.calculateHandleCss(this.minimized_height));
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   115
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   116
    this.$
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   117
        .mouseover(this.functionWrapper("onMouseover"))
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   118
        .mouseout(this.functionWrapper("onMouseout"));
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   119
		IriSP.jQuery('body').keypress(function(evt) {_this.keyPress(evt)});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   120
    
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   121
    this.maximized = false;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   122
    this.timeoutId = false;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   123
};
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   124
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   125
/*
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   126
 * Starts playing the video when it's ready.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   127
*/
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   128
IriSP.Widgets.Timeline.prototype.ready = function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   129
	this.player.popcorn.play();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   130
	this.processMarkers();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   131
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   132
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   133
/*
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   134
 * Scale a value from [A, B] to [C, D].
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   135
*/
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   136
IriSP.Widgets.Timeline.prototype.scaleIntervals = function(A, B, C, D, val) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   137
	if(C == D)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   138
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   139
		return C;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   140
	}	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   141
	if(B != A)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   142
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   143
		return D / (B - A) * (val - A);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   144
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   145
	else
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   146
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   147
		//If A and B have the same sign.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   148
		if(A * B > 0)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   149
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   150
			//If they are positive.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   151
			if(A > 0)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   152
			{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   153
				return (D - C)/2;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   154
			}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   155
			else
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   156
			{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   157
				return (C - D)/2;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   158
			}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   159
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   160
		else
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   161
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   162
			return (C + D)/2;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   163
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   164
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   165
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   166
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   167
/*
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   168
 * Process the markers.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   169
*/
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   170
IriSP.Widgets.Timeline.prototype.processMarkers = function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   171
	var _this = this;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   172
	var markers = "";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   173
	var timelineMiddleTop = this.$timelineMiddle.position().top;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   174
	
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   175
	for(var i = 0 ; i < this.annotations.length ; i++)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   176
	{
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   177
		markers += "<div class='Ldt-Marker' id='" + this.annotations[i].id.replace(":", "_") + "'></div>";
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   178
		// console.log(annotations[i].begin.milliseconds);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   179
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   180
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   181
	this.$.append(markers);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   182
	var markerHeight = IriSP.jQuery(".Ldt-Marker").height();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   183
	IriSP.jQuery(".Ldt-Marker").css("z-align", "150");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   184
	
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   185
	for(var i = 0 ; i < this.annotations.length ; i++)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   186
	{
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   187
		IriSP.jQuery("#" + this.annotations[i].id.replace(":", "_")).css(
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   188
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   189
			top: timelineMiddleTop + "px",
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   190
			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
   191
			"margin-top": (-_this.$timeline.height()/2 - markerHeight/2) - this.top_epsilon + "px"
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   192
		});
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
 * Place the cursor on the timeline depending on the keytyped.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   198
*/
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   199
IriSP.Widgets.Timeline.prototype.keyPress = function(e) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   200
	var key = this.whichKey(e.which);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   201
	var time = 0;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   202
	
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   203
	// console.log($(this));
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   204
	
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   205
	if(key > -1 && key < 11)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   206
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   207
		time = this.source.getDuration().getSeconds()/10*key;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   208
		this.$timeline.slider("value",time);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   209
		this.player.popcorn.currentTime(time);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   210
		
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   211
		//On supprime le marqueur précédemment affiché si c'est le cas.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   212
		if(this.previousMarkerIdx > -1)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   213
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   214
			// console.log("EXT hide idx " + this.previousMarkerIdx);
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   215
			var previousMarker = IriSP.jQuery("#" + this.annotations[this.previousMarkerIdx].id.replace(":", "_"));
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   216
			this.hideMarkerBig(previousMarker);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   217
			// console.log("EXT hide " + this.previousMarkerIdx);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   218
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   219
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   220
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   221
	if(key == 11)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   222
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   223
		if(!this.timelineSelected)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   224
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   225
			this.currentMode = "TIMELINE";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   226
			this.selectTimeline();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   227
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   228
		else
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   229
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   230
			this.currentMode = "VIDEO";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   231
			this.deselectTimeline();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   232
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   233
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   234
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   235
	if(key == 12)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   236
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   237
		this.hideMarkersSearch();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   238
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   239
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   240
	if(key == 13)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   241
	{
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   242
		var gesturesStr = '';
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   243
		for(var i = 0 ; i < this.gestures.length ; i++)
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   244
		{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   245
			gesturesStr += this.gestures[i] + ", ";
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   246
		}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   247
		gesturesStr = gesturesStr.substr(0, gesturesStr.length - 2);
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   248
		
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   249
		/*if(IriSP.jQuery('#notify_search_1gesture').length > 0)
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   250
		{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   251
			this.removeSearch1Gesture();
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   252
		}*/
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   253
		
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   254
		var typeName = prompt("Please enter a type name among (" + gesturesStr + ").", "");
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   255
		
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   256
		this.notifySearch1Gesture(typeName, "valid");
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   257
		
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   258
		if(typeName != '' || typeName != undefined)
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   259
		{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   260
			if(_.include(this.gestures, typeName))
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   261
			{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   262
				this.currentMode = "SEARCH";
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   263
				this.hideMarkersSearch(typeName);
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   264
			}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   265
			else
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   266
			{
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   267
				// alert("Unknown gesture type. Operation aborted.");
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   268
				this.removeSearch1Gesture();
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   269
				this.notifySearch1Gesture(typeName, "none");
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   270
			}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   271
		}
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   272
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   273
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   274
	if(key == 21)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   275
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   276
		// console.log(this);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   277
		if(!this.paused)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   278
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   279
			this.paused = true;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   280
			this.player.popcorn.pause();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   281
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   282
		else
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   283
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   284
			this.paused = false;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   285
			this.player.popcorn.play();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   286
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   287
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   288
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   289
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   290
/*
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   291
 * Find the key corresponding to a given code.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   292
*/
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   293
IriSP.Widgets.Timeline.prototype.whichKey = function(code) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   294
	var key;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   295
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   296
	console.log(code);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   297
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   298
	if(code > 47 && code < 58)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   299
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   300
		return (code - 48);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   301
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   302
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   303
	if(code == 115 || code == 83)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   304
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   305
		return 11;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   306
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   307
	
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   308
	//m ou M pour quitter une recherche.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   309
	if(code == 109 || code == 77)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   310
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   311
		return 12;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   312
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   313
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   314
	//p ou P pour mettre la vidéo en pause.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   315
	if(code == 112 || code == 80)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   316
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   317
		return 21;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   318
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   319
	
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   320
	//n ou N pour une recherche par type.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   321
	if(code == 110 || code == 78)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   322
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   323
		return 13;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   324
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   325
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   326
	switch(code)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   327
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   328
		case 224:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   329
			key = 0;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   330
		break;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   331
		case 38:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   332
			key = 1;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   333
		break;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   334
		case 233:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   335
			key = 2;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   336
		break;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   337
		case 34:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   338
			key = 3;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   339
		break;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   340
		case 39:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   341
			key = 4;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   342
		break;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   343
		case 40:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   344
			key = 5;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   345
		break;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   346
		case 45:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   347
			key = 6;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   348
		break;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   349
		case 232:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   350
			key = 7;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   351
		break;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   352
		case 95:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   353
			key = 8;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   354
		break;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   355
		case 231:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   356
			key = 9;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   357
		break;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   358
		default:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   359
			key = -1;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   360
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   361
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   362
	return key;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   363
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   364
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   365
IriSP.Widgets.Timeline.prototype.selectTimeline = function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   366
	this.timelineSelected = true;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   367
	this.$timelineBorderUp = "<div class='TL_Borders' id='TL_BorderUp'></div>";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   368
	this.$timelineBorderDown = "<div class='TL_Borders' id='TL_BorderDown'></div>";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   369
	this.$timelineBorderLeft = "<div class='TL_Borders' id='TL_BorderLeft'></div>";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   370
	this.$timelineBorderRight = "<div class='TL_Borders' id='TL_BorderRight'></div>";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   371
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   372
	this.$arrowUp = "<div class='TL_Arrows' id='TL_ArrowUp'></div>";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   373
	this.$arrowDown = "<div class='TL_Arrows' id='TL_ArrowDown'></div>";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   374
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   375
	this.$.append(this.$timelineBorderUp + this.$timelineBorderDown + this.$timelineBorderLeft + this.$timelineBorderRight + this.$arrowUp + this.$arrowDown);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   376
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   377
	var timelineTop = IriSP.jQuery("#LdtPlayer").position().top + IriSP.jQuery("#LdtPlayer").height();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   378
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   379
	IriSP.jQuery("#TL_BorderUp").css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   380
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   381
		"margin-top": -this.$timeline.height() - this.top_epsilon,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   382
		left: this.$timeline.position().left,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   383
		width: this.$timeline.width(),
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   384
		height: this.timelineBorderLength
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   385
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   386
	IriSP.jQuery("#TL_BorderDown").css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   387
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   388
		"margin-top": -this.timelineBorderLength - 2 - this.top_epsilon,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   389
		left: this.$timeline.position().left,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   390
		width: this.$timeline.width(),
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   391
		height: this.timelineBorderLength
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   392
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   393
	IriSP.jQuery("#TL_BorderLeft").css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   394
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   395
		"margin-top": -this.$timeline.height() - this.top_epsilon,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   396
		left: this.$timeline.position().left,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   397
		width: this.timelineBorderLength,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   398
		height: this.$timeline.height()
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   399
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   400
	IriSP.jQuery("#TL_BorderRight").css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   401
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   402
		"margin-top": -this.$timeline.height() - this.top_epsilon,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   403
		left: +this.$timeline.position().left + this.$timeline.width() - this.timelineBorderLength - 2,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   404
		width: this.timelineBorderLength,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   405
		height: this.$timeline.height()
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   406
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   407
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   408
	IriSP.jQuery("#TL_ArrowUp").css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   409
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   410
		"background-image": "url(" + this.imgDir + "arrow_up.png)",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   411
		"margin-top": -this.$timeline.height() - IriSP.jQuery("#TL_ArrowUp").height() - this.top_epsilon,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   412
		left: this.$timeline.position().left - IriSP.jQuery("#TL_ArrowUp").width()/2,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   413
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   414
	IriSP.jQuery("#TL_ArrowDown").css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   415
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   416
		"background-image": "url(" + this.imgDir + "arrow_down.png)",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   417
		"margin-top": -this.timelineBorderLength + this.timelineBorderLength - this.top_epsilon,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   418
		left: this.$timeline.position().left - IriSP.jQuery("#TL_ArrowUp").width()/2,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   419
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   420
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   421
	IriSP.jQuery(".Ldt-Timeline .ui-slider-range").css("background-image", "url(" + this.imgDir + "past_timeline.png)");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   422
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   423
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   424
IriSP.Widgets.Timeline.prototype.deselectTimeline = function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   425
	this.timelineSelected = false;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   426
	IriSP.jQuery(".TL_Borders").remove();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   427
	IriSP.jQuery(".TL_Arrows").remove();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   428
	IriSP.jQuery(".Ldt-Timeline .ui-slider-range").css("background-image", "url(" + this.imgDir + "selected_timeline.png)");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   429
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   430
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   431
IriSP.Widgets.Timeline.prototype.onTimeupdate = function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   432
    var _time = this.player.popcorn.currentTime();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   433
	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
   434
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   435
    this.$timeline.slider("value",_time*1000);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   436
	IriSP.jQuery(".TL_Arrows").css("display", "block");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   437
	IriSP.jQuery("#TL_ArrowUp").css("left", arrowLeft);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   438
	IriSP.jQuery("#TL_ArrowDown").css("left", arrowLeft);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   439
	// this.player.popcorn.trigger("IriSP.Arrow.updatePosition",{widget: this.type, time: 1000 * _time});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   440
	//Si on a une distance de 500 ms à un marqueur, on l'affiche.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   441
	var nearestMarkerIdx = 0;
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   442
	for(var i = 0 ; i < this.annotations.length ; i++)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   443
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   444
		//S'il existe des marqueurs dans l'intervalle de temps actuel (ici 500ms).
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   445
		if(Math.abs(_time*1000 - this.annotations[i].begin.milliseconds) <= 250)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   446
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   447
			// console.log("1) i = " + i + " " + Math.abs(_time*1000 - annotations[i].begin.milliseconds));
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   448
			
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   449
			//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
   450
			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
   451
			{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   452
				// 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
   453
				//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
   454
				if(_time*1000 < this.annotations[i].begin.milliseconds)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   455
				{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   456
					// console.log("3) " + _time*1000 + " < " + annotations[i].begin.milliseconds);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   457
					// console.log("4) " + "nearest = " + i);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   458
					nearestMarkerIdx = i;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   459
					// console.log("5a0) before");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   460
					//S'il y a un changement de marqueur (marqueur actuel différent du précédent).
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   461
					if(nearestMarkerIdx != this.previousMarkerIdx)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   462
					{
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   463
						var currentMarker = IriSP.jQuery("#" + this.annotations[nearestMarkerIdx].id.replace(":", "_"));
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   464
						//S'il existe un marqueur précédent, on le cache.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   465
						if(this.previousMarkerIdx > -1)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   466
						{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   467
							// console.log("hide idx " + this.previousMarkerIdx);
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   468
							var previousMarker = IriSP.jQuery("#" + this.annotations[this.previousMarkerIdx].id.replace(":", "_"));
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   469
							this.hideMarkerBig(previousMarker);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   470
							// console.log("5a) hide " + this.previousMarkerIdx);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   471
						}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   472
						
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   473
						// console.log("5b) show " + nearestMarkerIdx);
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   474
						this.showMarkerBig(currentMarker, this.annotations[nearestMarkerIdx].annotationType.contents.title);
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   475
						//Mise à jour du marqueur précédent s'il y a un changement.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   476
						this.previousMarkerIdx = nearestMarkerIdx;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   477
						// console.log("MAJ : " + this.previousMarkerIdx);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   478
					}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   479
				}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   480
			}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   481
			// 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
   482
			this.currentMarkerIdx = nearestMarkerIdx;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   483
			// this.showMarkerBig(IriSP.jQuery("#" + annotations[i].id.replace(":", "_")), annotations[i].annotationType.contents.title);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   484
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   485
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   486
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   487
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   488
IriSP.Widgets.Timeline.prototype.timeDisplayUpdater = function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   489
    var _time = this.player.popcorn.currentTime();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   490
	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
   491
    this.$timeline.slider("value",_time*1000);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   492
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   493
	IriSP.jQuery(".TL_Arrows").css("display", "block");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   494
	IriSP.jQuery("#TL_ArrowUp").css("left", arrowLeft);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   495
	IriSP.jQuery("#TL_ArrowDown").css("left", arrowLeft);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   496
    // this.player.popcorn.trigger("IriSP.Arrow.updatePosition",{widget: this.type, time: 1000 * _time});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   497
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   498
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   499
IriSP.Widgets.Timeline.prototype.onMouseover = function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   500
    /*if (this.timeoutId) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   501
        window.clearTimeout(this.timeoutId);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   502
        this.timeoutId = false;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   503
    }
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   504
    if (!this.maximized) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   505
       this.animateToHeight(this.maximized_height);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   506
       this.maximized = true;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   507
    }*/
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   508
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   509
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   510
IriSP.Widgets.Timeline.prototype.onMouseout = function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   511
    /*if (this.timeoutId) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   512
        window.clearTimeout(this.timeoutId);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   513
        this.timeoutId = false;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   514
    }
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   515
    var _this = this;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   516
    this.timeoutId = window.setTimeout(function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   517
        if (_this.maximized) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   518
            _this.animateToHeight(_this.minimized_height);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   519
            _this.maximized = false;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   520
        }
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   521
        _this.timeoutId = false;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   522
    }, this.minimize_timeout);*/
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   523
    
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   524
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   525
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   526
IriSP.Widgets.Timeline.prototype.animateToHeight = function(_height) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   527
    /*this.$timeline.stop().animate(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   528
        this.calculateTimelineCss(_height),
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   529
        500,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   530
        function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   531
            IriSP.jQuery(this).css("overflow","visible");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   532
        });
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   533
    this.$handle.stop().animate(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   534
        this.calculateHandleCss(_height),
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   535
        500,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   536
        function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   537
            IriSP.jQuery(this).css("overflow","visible");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   538
        });*/
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   539
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   540
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   541
IriSP.Widgets.Timeline.prototype.calculateTimelineCss = function(_size) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   542
	var middleWidth = this.player.config.gui.width;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   543
    return {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   544
		position: "absolute",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   545
		top: "0px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   546
		left: "0px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   547
		width: middleWidth + "px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   548
        height: _size + "px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   549
        "margin-top": (-this.minimized_height - this.top_epsilon) + "px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   550
		"z-align": "50"
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   551
    };
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   552
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   553
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   554
IriSP.Widgets.Timeline.prototype.calculateTimelineMiddleCss = function(_size, _middleSize) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   555
	var middleWidth = this.player.config.gui.width;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   556
    return {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   557
		position: "absolute",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   558
		top: "0px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   559
		left: "0px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   560
		width: middleWidth + "px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   561
        height: _middleSize + "px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   562
        "margin-top": (-this.minimized_height/2 - _middleSize/2 - this.top_epsilon) + "px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   563
		"z-align": "100"
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   564
    };
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   565
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   566
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   567
IriSP.Widgets.Timeline.prototype.calculateHandleCss = function(_size) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   568
    return {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   569
		position: "absolute",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   570
		top: "0px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   571
		left: "0px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   572
        height: (2 + _size) + "px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   573
        width: (2 + _size) + "px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   574
        "margin-left": -Math.ceil(2 + _size / 2) + "px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   575
		"z-align": "60"
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   576
    }
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   577
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   578
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   579
IriSP.Widgets.Timeline.prototype.showMarkerBig = function(marker, type) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   580
	// console.log("avant");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   581
	if(this.markerBigShown)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   582
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   583
		return;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   584
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   585
	// console.log("apres");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   586
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   587
	clearTimeout(this.hideTimeout);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   588
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   589
	var _this = this;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   590
	
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   591
	var markerTop, markerLeft;
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   592
	
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   593
	if(marker.position() == null)
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   594
	{
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   595
		markerTop = 0;
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   596
		markerLeft = 0;
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   597
	}
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   598
	else
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   599
	{
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   600
		markerTop = marker.position().top;
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   601
		markerLeft = marker.position().left;
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   602
	}
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   603
	
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   604
	var markerWidth = marker.width(), markerHeight = marker.height();
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   605
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   606
	this.markerBigShown = true;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   607
	var markerBig = "<div class='TL_MarkersBig' id='MB_Text'>" + type + "<div class='TL_MarkersBig' id='MB_Spike'></div></div><div class='TL_MarkersBig' id='MB_Pic'></div>";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   608
	this.$.append(markerBig);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   609
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   610
	var markerBigText = IriSP.jQuery("#MB_Text");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   611
	var markerBigSpike = IriSP.jQuery("#MB_Spike");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   612
	var markerBigPic = IriSP.jQuery("#MB_Pic");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   613
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   614
	var markerBigTextWidth = markerBigText.outerWidth(), markerBigTextHeight = markerBigText.outerHeight();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   615
	var markerBigSpikeWidth = markerBigSpike.width(), markerBigSpikeHeight = markerBigSpike.height();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   616
	var markerBigPicWidth = markerBigPic.width(), markerBigPicHeight = markerBigPic.height();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   617
	var markerBigPicTop = +parseFloat(marker.css("margin-top")) + markerHeight, markerBigPicLeft = (markerLeft - markerBigPicWidth/2 + markerWidth/2);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   618
	var markerBigTextTop = (parseFloat(marker.css("margin-top")) - markerBigTextHeight - markerBigSpikeHeight), markerBigTextLeft = (markerLeft - (markerBigTextWidth - markerBigSpikeWidth)/2);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   619
	var markerBigSpikeLeft = ((markerBigTextWidth - markerBigSpikeWidth)/2);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   620
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   621
	marker.css("background-image", "url(" + this.imgDir + "selected_marker.png)");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   622
	IriSP.jQuery("#MB_Text").css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   623
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   624
		top: markerBigTextTop,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   625
		left: markerBigTextLeft
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   626
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   627
	IriSP.jQuery("#MB_Spike").css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   628
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   629
		left: markerBigSpikeLeft
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   630
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   631
	IriSP.jQuery("#MB_Pic").css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   632
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   633
		"background-image": "url(" + this.markersDir + type + ".png)",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   634
		top: markerBigPicTop,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   635
		left: markerBigPicLeft
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   636
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   637
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   638
	IriSP.jQuery(".TL_MarkersBig").fadeTo(this.markerShowTime, "1");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   639
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   640
	//On rajoute un timeout pour supprimer le marqueur après un certain temps.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   641
	this.hideTimeout = setTimeout(function()
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   642
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   643
		_this.hideMarkerBig(marker);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   644
	}, this.markerLastTime);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   645
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   646
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   647
IriSP.Widgets.Timeline.prototype.hideMarkerBig = function(marker) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   648
	if(!this.markerBigShown)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   649
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   650
		return;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   651
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   652
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   653
	this.currentMarker = -1;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   654
	this.markerBigShown = false;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   655
	marker.css("background-image", "url(" + this.imgDir + "marker.png)");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   656
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   657
	IriSP.jQuery(".TL_MarkersBig").fadeOut(this.markerShowTime).remove();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   658
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   659
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   660
/*
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   661
 * Affiche le bas des marqueurs correspondants à la recherche.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   662
*/
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   663
IriSP.Widgets.Timeline.prototype.showMarkersSearchByType = function(type) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   664
	//Si on est en mode SEARCH.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   665
	if(this.currentMode != "SEARCH")
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   666
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   667
		return;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   668
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   669
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   670
	var _this = this;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   671
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   672
	//On récupère les annotations.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   673
	var markersSearch = "", markersPicSearch = "";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   674
	//Pour chaque annotation, on ajoute un double.
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   675
	for(var i = 0 ; i < this.annotations.length ; i++)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   676
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   677
		//Si elle correspond à la recherche.
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   678
		if(this.annotations[i].annotationType.contents.title == type)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   679
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   680
			//On récupère le marqueur associé à l'annotation.
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   681
			var markerId = this.annotations[i].id.replace(":", "_");
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   682
			
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   683
			markersSearch += "<div class='search_Marker' id='search_Marker_" + markerId + "'></div>";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   684
			markersPicSearch += "<div class='search_MBPic' id='search_Pic_" + markerId + "'></div>";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   685
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   686
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   687
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   688
	this.$.append(markersSearch + markersPicSearch);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   689
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   690
	//On place chaque double.
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   691
	for(var i = 0 ; i < this.annotations.length ; i++)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   692
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   693
		//Si elle correspond à la recherche.
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   694
		if(this.annotations[i].annotationType.contents.title == type)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   695
		{
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   696
			var markerId = this.annotations[i].id.replace(":", "_"), marker = IriSP.jQuery("#" + markerId);
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   697
			var markerTop = marker.position().top, markerLeft = marker.position().left, markerWidth = marker.width(), markerHeight = marker.height();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   698
			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
   699
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   700
			// console.log(markerLeft + " - " + IriSP.jQuery(".search_MBPic").css("width") + " " + markerBigPicWidth + "/2 " + markerWidth + "/2");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   701
			
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   702
			IriSP.jQuery("#search_Pic_" + markerId).css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   703
			{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   704
				position: "absolute",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   705
				"background-image": "url(" + this.markersDir + type + ".png)",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   706
				top: markerBigPicTop,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   707
				left: markerBigPicLeft,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   708
				"z-index": "300"
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   709
			}).fadeTo(this.markerShowTime, "1");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   710
			
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   711
			IriSP.jQuery("#search_Marker_" + markerId).css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   712
			{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   713
				position: "absolute",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   714
				top: _this.$timelineMiddle.position().top - _this.top_epsilon,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   715
				"margin-top": (-_this.$timeline.height()/2 - markerHeight/2),
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   716
				"background-image": "url(" + this.imgDir + "selected_marker.png)",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   717
				//top: markerTop,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   718
				left: markerLeft,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   719
				"z-index": "300"
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   720
			}).fadeTo(this.markerShowTime, "1");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   721
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   722
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   723
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   724
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   725
/*
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   726
 * Enlever une recherche faite précédemment.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   727
*/
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   728
IriSP.Widgets.Timeline.prototype.hideMarkersSearch = function(type) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   729
	//Si on est en mode SEARCH.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   730
	if(this.currentMode != "SEARCH")
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   731
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   732
		return;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   733
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   734
	
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   735
	console.log('(0)');
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   736
	
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   737
	var _this = this;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   738
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   739
	IriSP.jQuery(".search_MBPic").fadeOut(this.markerShowTime, function()
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   740
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   741
		IriSP.jQuery("div").remove(".search_MBPic");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   742
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   743
	IriSP.jQuery(".search_Marker").fadeOut(this.markerShowTime, function()
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   744
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   745
		IriSP.jQuery("div").remove(".search_Marker");
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   746
		_this.removeSearch1Gesture();
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   747
		
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   748
		if(type == undefined)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   749
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   750
			_this.currentMode = "VIDEO";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   751
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   752
		else
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   753
		{
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   754
			console.log('(1)');
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   755
			// console.log(_this.currentMode);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   756
			_this.showMarkersSearchByType(type);
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   757
			_this.notifySearch1Gesture(type, "valid");
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   758
			return;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   759
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   760
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   761
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   762
	if(IriSP.jQuery(".search_Marker").length == 0 && type != undefined)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   763
	{
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   764
		console.log('(2)');
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   765
		this.showMarkersSearchByType(type);
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   766
		_this.removeSearch1Gesture();
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   767
		
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   768
		if(!_.include(this.gestures, type))
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   769
		{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   770
			this.notifySearch1Gesture(type, "none");
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   771
		}
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   772
		else
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   773
		{
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   774
			_this.notifySearch1Gesture(type, "valid");
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   775
		}
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   776
		// console.log(this.currentMode);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   777
	}
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   778
}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   779
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   780
IriSP.Widgets.Timeline.prototype.freePlayer = function()
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   781
{
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   782
	IriSP.jQuery('body').unbind('keypress');
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   783
	IriSP.jQuery('.notifications').remove();
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   784
}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   785
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   786
/*
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   787
 * Affiche la notification de validation/survol de gesture de recherche.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   788
 * Mode prend pour valeurs : "valid" ou "hover".
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   789
*/
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   790
IriSP.Widgets.Timeline.prototype.notifySearch1Gesture = function(gestureName, mode)
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   791
{
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   792
	// console.log('C');
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   793
	if(IriSP.jQuery('#notify_search_1gesture').length > 0)
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   794
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   795
		return;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   796
	}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   797
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   798
	var _this = this;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   799
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   800
	//On spécifie les notifications en div.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   801
	var notification_search_1gesture = "<div id='notify_search_1gesture' class='notifications'></div>";
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   802
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   803
	//On les ajoute à la mosaïque.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   804
	$('#mainPanel').append(notification_search_1gesture);
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   805
	
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   806
	// console.log(this.player.config.gui.zoomTop + " " + this.player.config.gui.zoomLeft);
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   807
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   808
	//On calcule leurs coordonnées et dimensions.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   809
	var notify_width = $('.notifications').width(), notify_height = $('.notifications').height();
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   810
	var notify_margin = parseInt($('.notifications').css('margin'));
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   811
	var point_left = $(window).width() / 2 - (notify_width) / 2 - notify_margin;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   812
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   813
	if(_.include(this.gestures, gestureName))
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   814
	{
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   815
		IriSP.jQuery('#notify_search_1gesture').css('background-image', 'url("./pictos/big/' + mode + '/' + gestureName + '.png")');
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   816
	}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   817
	else if(mode == 'none')
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   818
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   819
		IriSP.jQuery('#notify_search_1gesture').css('background-image', 'url("./pictos/big/normal/inconnu.png")');
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   820
	}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   821
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   822
	if(mode != 'none')
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   823
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   824
		IriSP.jQuery('#notify_search_1gesture').mouseover(function()
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   825
		{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   826
			IriSP.jQuery(this).css('background-image', 'url("./pictos/big/hover/' + gestureName + '.png")');
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   827
		}).mouseout(function()
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   828
		{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   829
			IriSP.jQuery(this).css('background-image', 'url("./pictos/big/valid/' + gestureName + '.png")');
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   830
		}).click(function()
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   831
		{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   832
			_this.removeSearch1Gesture();
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   833
			_this.hideMarkersSearch();
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   834
		});
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   835
	}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   836
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   837
	var notifyTop = this.player.config.gui.zoomTop, notifyLeft = this.player.config.gui.zoomLeft;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   838
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   839
	//On les positionne.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   840
	$('#notify_search_1gesture').css(
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   841
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   842
		top: -notifyTop,
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   843
		left: -notifyLeft + (IriSP.jQuery(window).width() - notify_width) / 2
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   844
	});
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   845
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   846
	//On les fait apparaître.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   847
	$('.notifications').css(
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   848
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   849
		opacity: "0.9"
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   850
	});
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   851
}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   852
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   853
/*
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   854
 * Supprime la notification de recherche de gesture.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   855
*/
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   856
IriSP.Widgets.Timeline.prototype.removeSearch1Gesture = function()
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   857
{
35
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   858
	// console.log('R');
4267d6d27a7d Front IDILL :
bastiena
parents: 33
diff changeset
   859
	// console.trace();
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   860
	IriSP.jQuery('#notify_search_1gesture').remove();
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   861
}