front_idill/src/player/metadataplayer/Timeline.js
author bastiena
Thu, 24 May 2012 10:30:05 +0200
changeset 33 2d9b15f99b4e
parent 32 4003f84cd349
child 35 4267d6d27a7d
permissions -rw-r--r--
Front IDILL : search by curves added search by type added notifications added timeline improved
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
	
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   203
	console.log($(this));
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
			{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   267
				alert("Unknown gesture type. Operation aborted.");
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   268
			}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   269
		}
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
	if(key == 21)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   273
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   274
		// console.log(this);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   275
		if(!this.paused)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   276
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   277
			this.paused = true;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   278
			this.player.popcorn.pause();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   279
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   280
		else
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   281
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   282
			this.paused = false;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   283
			this.player.popcorn.play();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   284
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   285
	}
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
 * Find the key corresponding to a given code.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   290
*/
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   291
IriSP.Widgets.Timeline.prototype.whichKey = function(code) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   292
	var key;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   293
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   294
	console.log(code);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   295
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   296
	if(code > 47 && code < 58)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   297
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   298
		return (code - 48);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   299
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   300
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   301
	if(code == 115 || code == 83)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   302
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   303
		return 11;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   304
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   305
	
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   306
	//m ou M pour quitter une recherche.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   307
	if(code == 109 || code == 77)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   308
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   309
		return 12;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   310
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   311
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   312
	//p ou P pour mettre la vidéo en pause.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   313
	if(code == 112 || code == 80)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   314
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   315
		return 21;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   316
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   317
	
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   318
	//n ou N pour une recherche par type.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   319
	if(code == 110 || code == 78)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   320
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   321
		return 13;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   322
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   323
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   324
	switch(code)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   325
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   326
		case 224:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   327
			key = 0;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   328
		break;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   329
		case 38:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   330
			key = 1;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   331
		break;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   332
		case 233:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   333
			key = 2;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   334
		break;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   335
		case 34:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   336
			key = 3;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   337
		break;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   338
		case 39:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   339
			key = 4;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   340
		break;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   341
		case 40:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   342
			key = 5;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   343
		break;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   344
		case 45:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   345
			key = 6;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   346
		break;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   347
		case 232:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   348
			key = 7;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   349
		break;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   350
		case 95:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   351
			key = 8;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   352
		break;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   353
		case 231:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   354
			key = 9;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   355
		break;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   356
		default:
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   357
			key = -1;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   358
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   359
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   360
	return key;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   361
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   362
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   363
IriSP.Widgets.Timeline.prototype.selectTimeline = function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   364
	this.timelineSelected = true;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   365
	this.$timelineBorderUp = "<div class='TL_Borders' id='TL_BorderUp'></div>";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   366
	this.$timelineBorderDown = "<div class='TL_Borders' id='TL_BorderDown'></div>";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   367
	this.$timelineBorderLeft = "<div class='TL_Borders' id='TL_BorderLeft'></div>";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   368
	this.$timelineBorderRight = "<div class='TL_Borders' id='TL_BorderRight'></div>";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   369
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   370
	this.$arrowUp = "<div class='TL_Arrows' id='TL_ArrowUp'></div>";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   371
	this.$arrowDown = "<div class='TL_Arrows' id='TL_ArrowDown'></div>";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   372
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   373
	this.$.append(this.$timelineBorderUp + this.$timelineBorderDown + this.$timelineBorderLeft + this.$timelineBorderRight + this.$arrowUp + this.$arrowDown);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   374
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   375
	var timelineTop = IriSP.jQuery("#LdtPlayer").position().top + IriSP.jQuery("#LdtPlayer").height();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   376
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   377
	IriSP.jQuery("#TL_BorderUp").css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   378
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   379
		"margin-top": -this.$timeline.height() - this.top_epsilon,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   380
		left: this.$timeline.position().left,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   381
		width: this.$timeline.width(),
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   382
		height: this.timelineBorderLength
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   383
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   384
	IriSP.jQuery("#TL_BorderDown").css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   385
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   386
		"margin-top": -this.timelineBorderLength - 2 - this.top_epsilon,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   387
		left: this.$timeline.position().left,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   388
		width: this.$timeline.width(),
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   389
		height: this.timelineBorderLength
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   390
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   391
	IriSP.jQuery("#TL_BorderLeft").css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   392
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   393
		"margin-top": -this.$timeline.height() - this.top_epsilon,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   394
		left: this.$timeline.position().left,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   395
		width: this.timelineBorderLength,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   396
		height: this.$timeline.height()
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   397
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   398
	IriSP.jQuery("#TL_BorderRight").css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   399
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   400
		"margin-top": -this.$timeline.height() - this.top_epsilon,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   401
		left: +this.$timeline.position().left + this.$timeline.width() - this.timelineBorderLength - 2,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   402
		width: this.timelineBorderLength,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   403
		height: this.$timeline.height()
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   404
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   405
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   406
	IriSP.jQuery("#TL_ArrowUp").css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   407
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   408
		"background-image": "url(" + this.imgDir + "arrow_up.png)",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   409
		"margin-top": -this.$timeline.height() - IriSP.jQuery("#TL_ArrowUp").height() - this.top_epsilon,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   410
		left: this.$timeline.position().left - IriSP.jQuery("#TL_ArrowUp").width()/2,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   411
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   412
	IriSP.jQuery("#TL_ArrowDown").css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   413
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   414
		"background-image": "url(" + this.imgDir + "arrow_down.png)",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   415
		"margin-top": -this.timelineBorderLength + this.timelineBorderLength - this.top_epsilon,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   416
		left: this.$timeline.position().left - IriSP.jQuery("#TL_ArrowUp").width()/2,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   417
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   418
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   419
	IriSP.jQuery(".Ldt-Timeline .ui-slider-range").css("background-image", "url(" + this.imgDir + "past_timeline.png)");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   420
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   421
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   422
IriSP.Widgets.Timeline.prototype.deselectTimeline = function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   423
	this.timelineSelected = false;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   424
	IriSP.jQuery(".TL_Borders").remove();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   425
	IriSP.jQuery(".TL_Arrows").remove();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   426
	IriSP.jQuery(".Ldt-Timeline .ui-slider-range").css("background-image", "url(" + this.imgDir + "selected_timeline.png)");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   427
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   428
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   429
IriSP.Widgets.Timeline.prototype.onTimeupdate = function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   430
    var _time = this.player.popcorn.currentTime();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   431
	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
   432
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   433
    this.$timeline.slider("value",_time*1000);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   434
	IriSP.jQuery(".TL_Arrows").css("display", "block");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   435
	IriSP.jQuery("#TL_ArrowUp").css("left", arrowLeft);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   436
	IriSP.jQuery("#TL_ArrowDown").css("left", arrowLeft);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   437
	// this.player.popcorn.trigger("IriSP.Arrow.updatePosition",{widget: this.type, time: 1000 * _time});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   438
	//Si on a une distance de 500 ms à un marqueur, on l'affiche.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   439
	var nearestMarkerIdx = 0;
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   440
	for(var i = 0 ; i < this.annotations.length ; i++)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   441
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   442
		//S'il existe des marqueurs dans l'intervalle de temps actuel (ici 500ms).
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   443
		if(Math.abs(_time*1000 - this.annotations[i].begin.milliseconds) <= 250)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   444
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   445
			// console.log("1) i = " + i + " " + Math.abs(_time*1000 - annotations[i].begin.milliseconds));
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   446
			
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   447
			//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
   448
			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
   449
			{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   450
				// 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
   451
				//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
   452
				if(_time*1000 < this.annotations[i].begin.milliseconds)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   453
				{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   454
					// console.log("3) " + _time*1000 + " < " + annotations[i].begin.milliseconds);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   455
					// console.log("4) " + "nearest = " + i);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   456
					nearestMarkerIdx = i;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   457
					// console.log("5a0) before");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   458
					//S'il y a un changement de marqueur (marqueur actuel différent du précédent).
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   459
					if(nearestMarkerIdx != this.previousMarkerIdx)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   460
					{
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   461
						var currentMarker = IriSP.jQuery("#" + this.annotations[nearestMarkerIdx].id.replace(":", "_"));
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   462
						//S'il existe un marqueur précédent, on le cache.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   463
						if(this.previousMarkerIdx > -1)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   464
						{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   465
							// console.log("hide idx " + this.previousMarkerIdx);
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   466
							var previousMarker = IriSP.jQuery("#" + this.annotations[this.previousMarkerIdx].id.replace(":", "_"));
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   467
							this.hideMarkerBig(previousMarker);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   468
							// console.log("5a) hide " + this.previousMarkerIdx);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   469
						}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   470
						
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   471
						// console.log("5b) show " + nearestMarkerIdx);
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   472
						this.showMarkerBig(currentMarker, this.annotations[nearestMarkerIdx].annotationType.contents.title);
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   473
						//Mise à jour du marqueur précédent s'il y a un changement.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   474
						this.previousMarkerIdx = nearestMarkerIdx;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   475
						// console.log("MAJ : " + this.previousMarkerIdx);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   476
					}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   477
				}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   478
			}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   479
			// 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
   480
			this.currentMarkerIdx = nearestMarkerIdx;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   481
			// this.showMarkerBig(IriSP.jQuery("#" + annotations[i].id.replace(":", "_")), annotations[i].annotationType.contents.title);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   482
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   483
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   484
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   485
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   486
IriSP.Widgets.Timeline.prototype.timeDisplayUpdater = function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   487
    var _time = this.player.popcorn.currentTime();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   488
	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
   489
    this.$timeline.slider("value",_time*1000);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   490
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   491
	IriSP.jQuery(".TL_Arrows").css("display", "block");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   492
	IriSP.jQuery("#TL_ArrowUp").css("left", arrowLeft);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   493
	IriSP.jQuery("#TL_ArrowDown").css("left", arrowLeft);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   494
    // this.player.popcorn.trigger("IriSP.Arrow.updatePosition",{widget: this.type, time: 1000 * _time});
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.Widgets.Timeline.prototype.onMouseover = function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   498
    /*if (this.timeoutId) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   499
        window.clearTimeout(this.timeoutId);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   500
        this.timeoutId = false;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   501
    }
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   502
    if (!this.maximized) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   503
       this.animateToHeight(this.maximized_height);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   504
       this.maximized = true;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   505
    }*/
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   506
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   507
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   508
IriSP.Widgets.Timeline.prototype.onMouseout = function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   509
    /*if (this.timeoutId) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   510
        window.clearTimeout(this.timeoutId);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   511
        this.timeoutId = false;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   512
    }
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   513
    var _this = this;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   514
    this.timeoutId = window.setTimeout(function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   515
        if (_this.maximized) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   516
            _this.animateToHeight(_this.minimized_height);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   517
            _this.maximized = false;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   518
        }
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   519
        _this.timeoutId = false;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   520
    }, this.minimize_timeout);*/
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   521
    
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   522
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   523
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   524
IriSP.Widgets.Timeline.prototype.animateToHeight = function(_height) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   525
    /*this.$timeline.stop().animate(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   526
        this.calculateTimelineCss(_height),
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   527
        500,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   528
        function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   529
            IriSP.jQuery(this).css("overflow","visible");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   530
        });
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   531
    this.$handle.stop().animate(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   532
        this.calculateHandleCss(_height),
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   533
        500,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   534
        function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   535
            IriSP.jQuery(this).css("overflow","visible");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   536
        });*/
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   537
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   538
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   539
IriSP.Widgets.Timeline.prototype.calculateTimelineCss = function(_size) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   540
	var middleWidth = this.player.config.gui.width;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   541
    return {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   542
		position: "absolute",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   543
		top: "0px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   544
		left: "0px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   545
		width: middleWidth + "px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   546
        height: _size + "px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   547
        "margin-top": (-this.minimized_height - this.top_epsilon) + "px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   548
		"z-align": "50"
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   549
    };
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   550
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   551
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   552
IriSP.Widgets.Timeline.prototype.calculateTimelineMiddleCss = function(_size, _middleSize) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   553
	var middleWidth = this.player.config.gui.width;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   554
    return {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   555
		position: "absolute",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   556
		top: "0px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   557
		left: "0px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   558
		width: middleWidth + "px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   559
        height: _middleSize + "px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   560
        "margin-top": (-this.minimized_height/2 - _middleSize/2 - this.top_epsilon) + "px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   561
		"z-align": "100"
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   562
    };
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   563
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   564
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   565
IriSP.Widgets.Timeline.prototype.calculateHandleCss = function(_size) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   566
    return {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   567
		position: "absolute",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   568
		top: "0px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   569
		left: "0px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   570
        height: (2 + _size) + "px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   571
        width: (2 + _size) + "px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   572
        "margin-left": -Math.ceil(2 + _size / 2) + "px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   573
		"z-align": "60"
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   574
    }
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   575
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   576
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   577
IriSP.Widgets.Timeline.prototype.showMarkerBig = function(marker, type) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   578
	// console.log("avant");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   579
	if(this.markerBigShown)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   580
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   581
		return;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   582
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   583
	// console.log("apres");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   584
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   585
	clearTimeout(this.hideTimeout);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   586
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   587
	var _this = this;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   588
	
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   589
	var markerTop, markerLeft;
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   590
	
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   591
	if(marker.position() == null)
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   592
	{
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   593
		markerTop = 0;
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   594
		markerLeft = 0;
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   595
	}
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   596
	else
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   597
	{
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   598
		markerTop = marker.position().top;
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   599
		markerLeft = marker.position().left;
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   600
	}
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   601
	
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   602
	var markerWidth = marker.width(), markerHeight = marker.height();
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   603
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   604
	this.markerBigShown = true;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   605
	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
   606
	this.$.append(markerBig);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   607
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   608
	var markerBigText = IriSP.jQuery("#MB_Text");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   609
	var markerBigSpike = IriSP.jQuery("#MB_Spike");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   610
	var markerBigPic = IriSP.jQuery("#MB_Pic");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   611
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   612
	var markerBigTextWidth = markerBigText.outerWidth(), markerBigTextHeight = markerBigText.outerHeight();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   613
	var markerBigSpikeWidth = markerBigSpike.width(), markerBigSpikeHeight = markerBigSpike.height();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   614
	var markerBigPicWidth = markerBigPic.width(), markerBigPicHeight = markerBigPic.height();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   615
	var markerBigPicTop = +parseFloat(marker.css("margin-top")) + markerHeight, markerBigPicLeft = (markerLeft - markerBigPicWidth/2 + markerWidth/2);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   616
	var markerBigTextTop = (parseFloat(marker.css("margin-top")) - markerBigTextHeight - markerBigSpikeHeight), markerBigTextLeft = (markerLeft - (markerBigTextWidth - markerBigSpikeWidth)/2);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   617
	var markerBigSpikeLeft = ((markerBigTextWidth - markerBigSpikeWidth)/2);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   618
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   619
	marker.css("background-image", "url(" + this.imgDir + "selected_marker.png)");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   620
	IriSP.jQuery("#MB_Text").css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   621
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   622
		top: markerBigTextTop,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   623
		left: markerBigTextLeft
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   624
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   625
	IriSP.jQuery("#MB_Spike").css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   626
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   627
		left: markerBigSpikeLeft
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   628
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   629
	IriSP.jQuery("#MB_Pic").css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   630
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   631
		"background-image": "url(" + this.markersDir + type + ".png)",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   632
		top: markerBigPicTop,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   633
		left: markerBigPicLeft
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   634
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   635
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   636
	IriSP.jQuery(".TL_MarkersBig").fadeTo(this.markerShowTime, "1");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   637
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   638
	//On rajoute un timeout pour supprimer le marqueur après un certain temps.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   639
	this.hideTimeout = setTimeout(function()
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   640
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   641
		_this.hideMarkerBig(marker);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   642
	}, this.markerLastTime);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   643
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   644
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   645
IriSP.Widgets.Timeline.prototype.hideMarkerBig = function(marker) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   646
	if(!this.markerBigShown)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   647
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   648
		return;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   649
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   650
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   651
	this.currentMarker = -1;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   652
	this.markerBigShown = false;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   653
	marker.css("background-image", "url(" + this.imgDir + "marker.png)");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   654
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   655
	IriSP.jQuery(".TL_MarkersBig").fadeOut(this.markerShowTime).remove();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   656
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   657
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   658
/*
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   659
 * Affiche le bas des marqueurs correspondants à la recherche.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   660
*/
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   661
IriSP.Widgets.Timeline.prototype.showMarkersSearchByType = function(type) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   662
	//Si on est en mode SEARCH.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   663
	if(this.currentMode != "SEARCH")
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   664
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   665
		return;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   666
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   667
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   668
	var _this = this;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   669
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   670
	//On récupère les annotations.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   671
	var markersSearch = "", markersPicSearch = "";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   672
	//Pour chaque annotation, on ajoute un double.
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   673
	for(var i = 0 ; i < this.annotations.length ; i++)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   674
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   675
		//Si elle correspond à la recherche.
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   676
		if(this.annotations[i].annotationType.contents.title == type)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   677
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   678
			//On récupère le marqueur associé à l'annotation.
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   679
			var markerId = this.annotations[i].id.replace(":", "_");
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   680
			
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   681
			markersSearch += "<div class='search_Marker' id='search_Marker_" + markerId + "'></div>";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   682
			markersPicSearch += "<div class='search_MBPic' id='search_Pic_" + markerId + "'></div>";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   683
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   684
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   685
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   686
	this.$.append(markersSearch + markersPicSearch);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   687
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   688
	//On place chaque double.
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   689
	for(var i = 0 ; i < this.annotations.length ; i++)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   690
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   691
		//Si elle correspond à la recherche.
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   692
		if(this.annotations[i].annotationType.contents.title == type)
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   693
		{
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
   694
			var markerId = this.annotations[i].id.replace(":", "_"), marker = IriSP.jQuery("#" + markerId);
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   695
			var markerTop = marker.position().top, markerLeft = marker.position().left, markerWidth = marker.width(), markerHeight = marker.height();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   696
			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
   697
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   698
			// console.log(markerLeft + " - " + IriSP.jQuery(".search_MBPic").css("width") + " " + markerBigPicWidth + "/2 " + markerWidth + "/2");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   699
			
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   700
			IriSP.jQuery("#search_Pic_" + markerId).css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   701
			{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   702
				position: "absolute",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   703
				"background-image": "url(" + this.markersDir + type + ".png)",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   704
				top: markerBigPicTop,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   705
				left: markerBigPicLeft,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   706
				"z-index": "300"
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   707
			}).fadeTo(this.markerShowTime, "1");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   708
			
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   709
			IriSP.jQuery("#search_Marker_" + markerId).css(
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   710
			{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   711
				position: "absolute",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   712
				top: _this.$timelineMiddle.position().top - _this.top_epsilon,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   713
				"margin-top": (-_this.$timeline.height()/2 - markerHeight/2),
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   714
				"background-image": "url(" + this.imgDir + "selected_marker.png)",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   715
				//top: markerTop,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   716
				left: markerLeft,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   717
				"z-index": "300"
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   718
			}).fadeTo(this.markerShowTime, "1");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   719
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   720
	}
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
 * Enlever une recherche faite précédemment.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   725
*/
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   726
IriSP.Widgets.Timeline.prototype.hideMarkersSearch = function(type) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   727
	//Si on est en mode SEARCH.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   728
	if(this.currentMode != "SEARCH")
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   729
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   730
		return;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   731
	}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   732
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   733
	var _this = this;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   734
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   735
	IriSP.jQuery(".search_MBPic").fadeOut(this.markerShowTime, function()
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   736
	{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   737
		IriSP.jQuery("div").remove(".search_MBPic");
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   738
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   739
	IriSP.jQuery(".search_Marker").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_Marker");
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   742
		_this.removeSearch1Gesture();
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   743
		
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   744
		if(type == undefined)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   745
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   746
			_this.currentMode = "VIDEO";
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   747
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   748
		else
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   749
		{
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   750
			// console.log(_this.currentMode);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   751
			_this.showMarkersSearchByType(type);
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   752
			_this.notifySearch1Gesture(type, "valid");
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   753
			return;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   754
		}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   755
	});
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   756
	
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   757
	if(IriSP.jQuery(".search_Marker").length == 0 && type != undefined)
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   758
	{
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   759
		if(type == undefined || !_.include(this.gestures, type))
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   760
		{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   761
			this.notifySearch1Gesture(type, "none");
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   762
		}
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   763
		// console.log(this.currentMode);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   764
		this.showMarkersSearchByType(type);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   765
	}
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   766
}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   767
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   768
IriSP.Widgets.Timeline.prototype.freePlayer = function()
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   769
{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   770
	IriSP.jQuery('body').unbind();
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   771
	IriSP.jQuery('.notifications').remove();
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   772
}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   773
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   774
/*
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   775
 * Affiche la notification de validation/survol de gesture de recherche.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   776
 * Mode prend pour valeurs : "valid" ou "hover".
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   777
*/
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   778
IriSP.Widgets.Timeline.prototype.notifySearch1Gesture = function(gestureName, mode)
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   779
{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   780
	console.log('C');
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   781
	if(IriSP.jQuery('#notify_search_1gesture').length > 0)
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   782
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   783
		return;
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
	var _this = this;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   787
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   788
	//On spécifie les notifications en div.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   789
	var notification_search_1gesture = "<div id='notify_search_1gesture' class='notifications'></div>";
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   790
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   791
	//On les ajoute à la mosaïque.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   792
	$('#mainPanel').append(notification_search_1gesture);
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   793
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   794
	console.log(this.player.config.gui.zoomTop + " " + this.player.config.gui.zoomLeft);
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   795
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   796
	//On calcule leurs coordonnées et dimensions.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   797
	var notify_width = $('.notifications').width(), notify_height = $('.notifications').height();
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   798
	var notify_margin = parseInt($('.notifications').css('margin'));
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   799
	var point_left = $(window).width() / 2 - (notify_width) / 2 - notify_margin;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   800
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   801
	if(_.include(this.gestures, gestureName))
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   802
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   803
		IriSP.jQuery('#notify_search_1gesture').css('background-image', 'url("./pictos/big/' + mode + '/' + gestureName.replace('-', '_') + '.png")');
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   804
	}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   805
	else if(mode == 'none')
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   806
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   807
		IriSP.jQuery('#notify_search_1gesture').css('background-image', 'url("./pictos/big/normal/inconnu.png")');
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   808
	}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   809
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   810
	if(mode != 'none')
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   811
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   812
		IriSP.jQuery('#notify_search_1gesture').mouseover(function()
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   813
		{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   814
			IriSP.jQuery(this).css('background-image', 'url("./pictos/big/hover/' + gestureName + '.png")');
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   815
		}).mouseout(function()
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   816
		{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   817
			IriSP.jQuery(this).css('background-image', 'url("./pictos/big/valid/' + gestureName + '.png")');
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   818
		}).click(function()
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   819
		{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   820
			_this.removeSearch1Gesture();
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   821
			_this.hideMarkersSearch();
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   822
		});
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   823
	}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   824
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   825
	var notifyTop = this.player.config.gui.zoomTop, notifyLeft = this.player.config.gui.zoomLeft;
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   826
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   827
	//On les positionne.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   828
	$('#notify_search_1gesture').css(
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   829
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   830
		top: -notifyTop,
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   831
		left: -notifyLeft + (IriSP.jQuery(window).width() - notify_width) / 2
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   832
	});
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   833
	
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   834
	//On les fait apparaître.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   835
	$('.notifications').css(
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   836
	{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   837
		opacity: "0.9"
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   838
	});
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   839
}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   840
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   841
/*
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   842
 * Supprime la notification de recherche de gesture.
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   843
*/
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   844
IriSP.Widgets.Timeline.prototype.removeSearch1Gesture = function()
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   845
{
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   846
	console.log('R');
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   847
	console.trace();
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   848
	IriSP.jQuery('#notify_search_1gesture').remove();
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   849
}