front_idill/src/player/metadataplayer/Timeline.js
author bastiena
Mon, 24 Sep 2012 15:19:49 +0200
changeset 123 57a65edde708
parent 79 9eff85166868
permissions -rw-r--r--
Front IDILL: non tmpl config files removed.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     1
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     2
* This file is part of the TraKERS\Front IDILL package.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     3
*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     4
* (c) IRI <http://www.iri.centrepompidou.fr/>
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     5
*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     6
* For the full copyright and license information, please view the LICENSE
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     7
* file that was distributed with this source code.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     8
*/
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
     9
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    10
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    11
 * Projet : TraKERS
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    12
 * Module : Front IDILL
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    13
 * Fichier : Timeline.js
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    14
 * 
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    15
 * Auteur : alexandre.bastien@iri.centrepompidou.fr
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    16
 * 
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    17
 * Fonctionnalités : Widget de la timeline du player incorporé dans le Front.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    18
 */
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    19
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    20
/*
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    21
 The Timeline Widget fits right under the video
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    22
 * Est appelé dans les fichiers créant les widgets du metadataplayer.
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    23
 */
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    24
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    25
IriSP.Widgets.Timeline = function(player, config) {
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    26
    
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    27
    IriSP.Widgets.Widget.call(this, player, config);
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    28
    this.bindPopcorn("timeupdate","onTimeupdate");
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    29
    this.bindPopcorn("loadedmetadata","ready");
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    30
    this.bindPopcorn("markersready","onMarkersReady");
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    31
    this.timelineSelected = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    32
    this.markerShowTime = 200;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    33
    this.markerLastTime = 5000;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    34
    this.markerBigShown = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    35
    this.currentMarkerIdx = -1;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    36
    this.previousMarkerIdx = -1;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    37
    this.hideTimeout;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    38
    this.currentMode = "VIDEO";
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    39
    this.paused = false
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    40
    this.top_epsilon = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    41
    this.imgDir = "player/img/";
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    42
    this.markersDir = "pictos/small/";
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    43
    this.player = player;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    44
    this.isCurrentlyInASearchByGesture = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    45
    this.mouseInteractions = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    46
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    47
    //Id du marqueur enregistré.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    48
    this.currentMarkerId;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    49
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    50
    //Gestures et noms par défaut.
61
5292b7e88eed Front IDILL :
bastiena
parents: 55
diff changeset
    51
    this.gestures = ["fall", "jump", "circle", "screw", "bend", "arc", "knee-up", "right-angle", "wave", "no-motion", "contact", "up-down"];
77
205409da0f32 Front IDILL:
bastiena
parents: 61
diff changeset
    52
    this.gesturesText = ["chute", "saut", "rotation", "rotation de groupe", "inclinaison", "port de bras", "levé de genou", "angle droit", "ondulation", "immobilité", "contact", "de haut en bas", "grand-jeté"];
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    53
    
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
    54
    var _this = this;
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    55
    this.annotations = this.source.getAnnotations().filter(function(annotation)
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
    56
    {
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
    57
        return _this.isGesture(annotation, null, _this.gestures);
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
    58
    });
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    59
};
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    60
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    61
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    62
 * Constructeur du Widget.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    63
*/
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    64
IriSP.Widgets.Timeline.prototype = new IriSP.Widgets.Widget();
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
    65
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    66
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    67
 * Indique si l'annotation passée en paramètre référence une gesture utilisée dans ce Front.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    68
*/
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    69
IriSP.Widgets.Timeline.prototype.isGesture = function(element, index, array)
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    70
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    71
    return ($.inArray(element.annotationType.contents.title, array) > -1);
32
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    72
}
4003f84cd349 Front IDILL :
bastiena
parents: 31
diff changeset
    73
45
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    74
/*
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    75
 * Spécifie si on est en événements souris ou non.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    76
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    77
 * mosaic > fonction onMarkersReady.
45
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    78
*/
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    79
IriSP.Widgets.Timeline.prototype.setMouseInteractions = function(mouseInteractions)
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    80
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    81
    this.mouseInteractions = mouseInteractions;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    82
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    83
    if(mouseInteractions)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    84
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    85
        this.markersDir += 'MI/';
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    86
    }
45
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    87
}
0e29ae4568a0 Front IDILL:
bastiena
parents: 44
diff changeset
    88
46
9d7a2aa112fb Front IDILL:
bastiena
parents: 45
diff changeset
    89
/*
9d7a2aa112fb Front IDILL:
bastiena
parents: 45
diff changeset
    90
 * Spécifie la langue pour l'affichage des marqueurs.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    91
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    92
 * mosaic > fonction onMarkersReady.
46
9d7a2aa112fb Front IDILL:
bastiena
parents: 45
diff changeset
    93
*/
9d7a2aa112fb Front IDILL:
bastiena
parents: 45
diff changeset
    94
IriSP.Widgets.Timeline.prototype.setLang = function(gesturesText)
9d7a2aa112fb Front IDILL:
bastiena
parents: 45
diff changeset
    95
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    96
    this.gesturesText = gesturesText;
46
9d7a2aa112fb Front IDILL:
bastiena
parents: 45
diff changeset
    97
}
9d7a2aa112fb Front IDILL:
bastiena
parents: 45
diff changeset
    98
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
    99
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   100
 * Fonction associée à l'événement : les marqueurs sont prêts.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   101
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   102
 * mosaic > fonction onPlayerLoad.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   103
*/
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   104
IriSP.Widgets.Timeline.prototype.onMarkersReady = function() {}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   105
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   106
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   107
 * Paramètres par défaut de la timeline.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   108
*/
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   109
IriSP.Widgets.Timeline.prototype.defaults = {
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   110
    minimized_height : 114,//44,
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   111
    maximized_height : 114,
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   112
    middle_height: 10,//4,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   113
    timelineBorderLength : 6,
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   114
    minimize_timeout : 1500 // time before minimizing timeline after mouseout
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   115
};
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   116
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   117
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   118
 * Fonction appelée pour dessiner la timeline.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   119
*/
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   120
IriSP.Widgets.Timeline.prototype.draw = function() {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   121
    this.$timeline = IriSP.jQuery('<div>')
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   122
        .addClass("Ldt-Timeline")
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   123
        .css(this.calculateTimelineCss(this.minimized_height));
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   124
    this.$timelineMiddle = IriSP.jQuery('<div>')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   125
        .addClass("Ldt-TimelineMiddle")
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   126
        .css(this.calculateTimelineMiddleCss(this.minimized_height, this.middle_height));
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   127
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   128
    //On l'ajoute au widget.
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   129
    this.$.append(this.$timeline);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   130
    this.$.append(this.$timelineMiddle);
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   131
    var _this = this;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   132
    
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   133
    //On définit le slider.
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   134
    this.$timeline.slider({
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   135
        range: "min",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   136
        value: 0,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   137
        min: 0,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   138
        max: this.source.getDuration().milliseconds,
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   139
        slide: function(event, ui) {
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   140
            if(_this.player.popcorn)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   141
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   142
                _this.player.popcorn.currentTime(Math.floor(ui.value/1000));
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   143
                _this.player.popcorn.trigger("IriSP.Mediafragment.setHashToTime");
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   144
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   145
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   146
            //On supprime le marqueur précédemment affiché.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   147
            if(_this.previousMarkerIdx > -1)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   148
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   149
                var previousMarker = IriSP.jQuery("#" + _this.annotations[_this.previousMarkerIdx].id.replace(":", "_"));
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   150
                _this.hideMarkerBig(previousMarker);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   151
            }
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   152
        }
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   153
    });
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   154
    
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   155
    this.$handle = this.$timeline.find('.ui-slider-handle');
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   156
    
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   157
    this.$handle.css(this.calculateHandleCss(this.minimized_height));
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   158
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   159
    //On wrapp mouseover et mouse out.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   160
    this.$.mouseover(this.functionWrapper("onMouseover")).mouseout(this.functionWrapper("onMouseout"));
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   161
    //On bind keypress.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   162
    IriSP.jQuery('body').keypress(function(evt) {_this.keyPress(evt)});
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   163
    
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   164
    this.maximized = false;
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   165
    this.timeoutId = false;
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   166
    
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   167
    this.processMarkers();
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   168
};
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   169
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   170
/*
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   171
 * Starts playing the video when it's ready.
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   172
*/
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   173
IriSP.Widgets.Timeline.prototype.ready = function() {
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   174
    this.player.popcorn.play();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   175
    this.player.popcorn.mute();
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   176
    // this.processMarkers();
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   177
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   178
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   179
/*
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   180
 * Met à l'échelle une valeur de [A, B] vers [C, D].
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   181
 * Est appelé dans les fichiers :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   182
 * pointers > fonction pointersTimelineSelection.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   183
 * search > fonction searchFilter.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   184
 * Timeline > fonctions processMarkers, onTimeupdate et timeDisplayUpdater.
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   185
*/
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   186
IriSP.Widgets.Timeline.prototype.scaleIntervals = function(A, B, C, D, val) {
61
5292b7e88eed Front IDILL :
bastiena
parents: 55
diff changeset
   187
    if(A == B)
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   188
    {
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   189
        return (D - C) / 2;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   190
    }
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   191
    else
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   192
    {
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   193
        return (D - C) * (val - A) / (B - A) + C;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   194
    }
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   195
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   196
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   197
/*
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   198
 * On calcule les marqueurs.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   199
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   200
 * Timeline > fonction ready.
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   201
*/
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   202
IriSP.Widgets.Timeline.prototype.processMarkers = function() {
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   203
    var _this = this;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   204
    var markers = "";
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   205
    //On calcule la position en Y de la timeline.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   206
    var timelineMiddleTop = this.$timelineMiddle.position().top;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   207
    
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   208
    var TLHeight = this.$timeline.height()/2;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   209
    
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   210
    //Pour toutes les annotations, on crée les marqueurs.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   211
    for(var i = 0 ; i < this.annotations.length ; i++)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   212
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   213
        markers += "<div class='Ldt-Marker' id='" + this.annotations[i].id.replace(":", "_") + "'></div>";
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   214
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   215
    //On les ajoute.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   216
    this.$.append(markers);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   217
    var markerHeight = IriSP.jQuery(".Ldt-Marker").height();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   218
    IriSP.jQuery(".Ldt-Marker").css("z-align", "150");
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   219
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   220
    //Pour toutes les annotations.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   221
    for(var i = 0 ; i < this.annotations.length ; i++)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   222
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   223
        //On les place sur la timeline.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   224
        IriSP.jQuery("#" + this.annotations[i].id.replace(":", "_")).css(
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   225
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   226
            top: timelineMiddleTop + "px",
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   227
            left: Math.floor(+this.scaleIntervals(0, this.source.getDuration().getSeconds(), 0, this.$timeline.width(), this.annotations[i].begin/1000) + this.$timeline.position().left) + "px",
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   228
            "margin-top": (-TLHeight - markerHeight/2) - this.top_epsilon + "px"
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   229
        });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   230
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   231
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   232
    //On lance l'événement pour dire à popcorn que les marqueurs sont utilisables.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   233
    this.player.popcorn.trigger("markersready");
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   234
}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   235
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   236
/*
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   237
 * Fonction de recherche par gestures.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   238
 * Est appelé dans les fichiers :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   239
 * mosaic > fonctions onMouseUp, manageControlEvents et onMarkersReady.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   240
 * curvesDetector > fonction updateDists.
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   241
*/
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   242
IriSP.Widgets.Timeline.prototype.searchByGesture = function(typeName)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   243
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   244
    //Si le type existe.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   245
    if(typeName != '' || typeName != undefined)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   246
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   247
        if(_.include(this.gestures, typeName))
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   248
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   249
            //On entre en mode recherche et on affiche les marqueurs sélectionnés.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   250
            this.currentMode = "SEARCH";
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   251
            this.hideMarkersSearch(typeName);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   252
            this.isCurrentlyInASearchByGesture = true;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   253
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   254
    }
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   255
}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   256
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   257
/*
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   258
 * Fonction de suppression de recherche par gesures.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   259
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   260
 * pointers > checkIfPointerIsOnSearchNotification et removeSearchNotificationIfOnIt.
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   261
*/
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   262
IriSP.Widgets.Timeline.prototype.removeSearchByGesture = function()
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   263
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   264
    this.hideMarkersSearch();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   265
    this.isCurrentlyInASearchByGesture = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   266
}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   267
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   268
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   269
 * Place le curseur sur la timeline en fonction de la touche pressée.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   270
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   271
*/
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   272
IriSP.Widgets.Timeline.prototype.keyPress = function(e) {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   273
    var key = this.whichKey(e.which);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   274
    var time = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   275
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   276
    //Entre 0 et 10, on met à jour la position du curseur dans la video.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   277
    if(key > -1 && key < 11)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   278
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   279
        time = this.source.getDuration().getSeconds()/10*key;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   280
        this.$timeline.slider("value",time);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   281
        this.player.popcorn.currentTime(time);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   282
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   283
        //On supprime le marqueur précédemment affiché.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   284
        if(this.previousMarkerIdx > -1)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   285
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   286
            var previousMarker = IriSP.jQuery("#" + this.annotations[this.previousMarkerIdx].id.replace(":", "_"));
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   287
            this.hideMarkerBig(previousMarker);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   288
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   289
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   290
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   291
    //p ou P pour mettre en pause.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   292
    if(key == 21)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   293
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   294
        if(!this.paused)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   295
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   296
            this.paused = true;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   297
            this.player.popcorn.pause();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   298
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   299
        else
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   300
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   301
            this.paused = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   302
            this.player.popcorn.play();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   303
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   304
    }
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   305
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   306
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   307
/*
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   308
 * Donne une clé correspondante à une touche donnée.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   309
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   310
 * Timeline > fonction keyPress.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   311
*/
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   312
IriSP.Widgets.Timeline.prototype.whichKey = function(code) {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   313
    var key;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   314
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   315
    if(code > 47 && code < 58)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   316
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   317
        return (code - 48);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   318
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   319
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   320
    if(code == 115 || code == 83)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   321
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   322
        return 11;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   323
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   324
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   325
    //p ou P pour mettre la vidéo en pause.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   326
    if(code == 112 || code == 80)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   327
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   328
        return 21;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   329
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   330
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   331
    switch(code)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   332
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   333
        case 224:
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   334
            key = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   335
        break;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   336
        case 38:
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   337
            key = 1;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   338
        break;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   339
        case 233:
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   340
            key = 2;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   341
        break;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   342
        case 34:
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   343
            key = 3;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   344
        break;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   345
        case 39:
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   346
            key = 4;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   347
        break;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   348
        case 40:
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   349
            key = 5;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   350
        break;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   351
        case 45:
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   352
            key = 6;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   353
        break;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   354
        case 232:
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   355
            key = 7;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   356
        break;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   357
        case 95:
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   358
            key = 8;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   359
        break;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   360
        case 231:
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   361
            key = 9;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   362
        break;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   363
        default:
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   364
            key = -1;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   365
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   366
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   367
    return key;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   368
}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   369
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   370
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   371
 * Fonction de sélection de la timeline.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   372
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   373
 * pointers > fonction pointersTimelineSelection.
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   374
*/
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   375
IriSP.Widgets.Timeline.prototype.selectTimeline = function() {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   376
    //On crée les bordures.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   377
    this.timelineSelected = true;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   378
    this.$timelineBorderUp = "<div class='TL_Borders' id='TL_BorderUp'></div>";
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   379
    this.$timelineBorderDown = "<div class='TL_Borders' id='TL_BorderDown'></div>";
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   380
    this.$timelineBorderLeft = "<div class='TL_Borders' id='TL_BorderLeft'></div>";
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   381
    this.$timelineBorderRight = "<div class='TL_Borders' id='TL_BorderRight'></div>";
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   382
    //Les flèches verticales aussi.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   383
    this.$arrowUp = "<div class='TL_Arrows' id='TL_ArrowUp'></div>";
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   384
    this.$arrowDown = "<div class='TL_Arrows' id='TL_ArrowDown'></div>";
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   385
    //On les ajoute.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   386
    this.$.append(this.$timelineBorderUp + this.$timelineBorderDown + this.$timelineBorderLeft + this.$timelineBorderRight + this.$arrowUp + this.$arrowDown);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   387
    //On calcule la position en Y de la timeline.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   388
    var timelineTop = IriSP.jQuery("#LdtPlayer").position().top + IriSP.jQuery("#LdtPlayer").height();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   389
    //On met les styles à jour.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   390
    IriSP.jQuery("#TL_BorderUp").css(
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   391
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   392
        "margin-top": -this.$timeline.height() - this.top_epsilon,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   393
        left: this.$timeline.position().left,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   394
        width: this.$timeline.width(),
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   395
        height: this.timelineBorderLength
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   396
    });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   397
    IriSP.jQuery("#TL_BorderDown").css(
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   398
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   399
        "margin-top": -this.timelineBorderLength - 2 - this.top_epsilon,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   400
        left: this.$timeline.position().left,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   401
        width: this.$timeline.width(),
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   402
        height: this.timelineBorderLength
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   403
    });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   404
    IriSP.jQuery("#TL_BorderLeft").css(
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   405
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   406
        "margin-top": -this.$timeline.height() - this.top_epsilon,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   407
        left: this.$timeline.position().left,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   408
        width: this.timelineBorderLength,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   409
        height: this.$timeline.height()
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   410
    });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   411
    IriSP.jQuery("#TL_BorderRight").css(
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   412
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   413
        "margin-top": -this.$timeline.height() - this.top_epsilon,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   414
        left: +this.$timeline.position().left + this.$timeline.width() - this.timelineBorderLength - 2,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   415
        width: this.timelineBorderLength,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   416
        height: this.$timeline.height()
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   417
    });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   418
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   419
    IriSP.jQuery("#TL_ArrowUp").css(
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   420
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   421
        "background-image": "url(" + this.imgDir + "arrow_up.png)",
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   422
        "margin-top": -this.$timeline.height() - IriSP.jQuery("#TL_ArrowUp").height() - this.top_epsilon,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   423
        left: this.$timeline.position().left - IriSP.jQuery("#TL_ArrowUp").width()/2,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   424
    });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   425
    IriSP.jQuery("#TL_ArrowDown").css(
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   426
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   427
        "background-image": "url(" + this.imgDir + "arrow_down.png)",
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   428
        "margin-top": -this.timelineBorderLength + this.timelineBorderLength - this.top_epsilon,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   429
        left: this.$timeline.position().left - IriSP.jQuery("#TL_ArrowUp").width()/2,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   430
    });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   431
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   432
    IriSP.jQuery(".Ldt-Timeline .ui-slider-range").css("background-image", "url(" + this.imgDir + "past_timeline.png)");
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   433
}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   434
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   435
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   436
 * Déselectionne la timeline.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   437
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   438
 * playerControl > fonction exitTimeline.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   439
*/
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   440
IriSP.Widgets.Timeline.prototype.deselectTimeline = function() {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   441
    //On supprime les éléments qui faisaient que la timeline était sélectionnée.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   442
    this.timelineSelected = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   443
    IriSP.jQuery(".TL_Borders").remove();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   444
    IriSP.jQuery(".TL_Arrows").remove();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   445
    IriSP.jQuery(".Ldt-Timeline .ui-slider-range").css("background-image", "url(" + this.imgDir + "selected_timeline.png)");
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   446
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   447
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   448
/*
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   449
 * Se met à jour durant la lecture d'une video.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   450
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   451
 * Timeline
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   452
*/
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   453
IriSP.Widgets.Timeline.prototype.onTimeupdate = function() {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   454
    //On récupère la position du curseur en secondes.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   455
    var _time = this.player.popcorn.currentTime();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   456
    //Position des flèches au cas où la timeline serait sélectionnée.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   457
    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";
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   458
    //On met à jour la position du slider en ms.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   459
    this.$timeline.slider("value",_time*1000);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   460
    //On affiche les flèches si la timeline est sélectionnée.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   461
    IriSP.jQuery(".TL_Arrows").css("display", "block");
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   462
    IriSP.jQuery("#TL_ArrowUp").css("left", arrowLeft);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   463
    IriSP.jQuery("#TL_ArrowDown").css("left", arrowLeft);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   464
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   465
    //Si on a une distance de 500 ms à un marqueur, on l'affiche.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   466
    var nearestMarkerIdx = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   467
    for(var i = 0 ; i < this.annotations.length ; i++)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   468
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   469
        //S'il existe des marqueurs dans l'intervalle de temps actuel (ici 500ms).
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   470
        if(Math.abs(_time*1000 - this.annotations[i].begin.milliseconds) <= 250)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   471
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   472
            //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.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   473
            if(Math.abs(_time*1000 - this.annotations[i].begin.milliseconds) < Math.abs(_time*1000 - this.annotations[nearestMarkerIdx].begin.milliseconds) || i == nearestMarkerIdx)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   474
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   475
                //Si le prochain marqueur se situe après le curseur de lecture, on passe donc au marqueur le plus proche.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   476
                if(_time*1000 < this.annotations[i].begin.milliseconds)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   477
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   478
                    nearestMarkerIdx = i;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   479
                    //S'il y a un changement de marqueur (marqueur actuel différent du précédent).
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   480
                    if(nearestMarkerIdx != this.previousMarkerIdx)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   481
                    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   482
                        var currentMarker = IriSP.jQuery("#" + this.annotations[nearestMarkerIdx].id.replace(":", "_"));
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   483
                        
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   484
                        //S'il existe un marqueur précédent, on le cache.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   485
                        if(this.previousMarkerIdx > -1)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   486
                        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   487
                            var previousMarker = IriSP.jQuery("#" + this.annotations[this.previousMarkerIdx].id.replace(":", "_"));
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   488
                            this.hideMarkerBig(previousMarker);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   489
                        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   490
                        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   491
                        this.showMarkerBig(currentMarker, this.annotations[nearestMarkerIdx].annotationType.contents.title);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   492
                        //Mise à jour du marqueur précédent s'il y a un changement.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   493
                        this.previousMarkerIdx = nearestMarkerIdx;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   494
                    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   495
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   496
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   497
            this.currentMarkerIdx = nearestMarkerIdx;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   498
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   499
    }
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   500
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   501
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   502
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   503
 * Met à jour l'affichage régulièrement.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   504
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   505
 * Timeline
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   506
*/
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   507
IriSP.Widgets.Timeline.prototype.timeDisplayUpdater = function() {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   508
    //On récupère la position du curseur en secondes.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   509
    var _time = this.player.popcorn.currentTime();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   510
    //Position des flèches au cas où la timeline serait sélectionnée.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   511
    var arrowLeft = Math.floor(+this.scaleIntervals(0, this.source.getDuration().getSeconds(), 0, this.$timeline.width(), _time) + this.$timeline.position().left) -
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   512
    this.$timeline.slider("value",_time*1000);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   513
    //On affiche les flèches si la timeline est sélectionnée.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   514
    IriSP.jQuery(".TL_Arrows").css("display", "block");
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   515
    IriSP.jQuery("#TL_ArrowUp").css("left", arrowLeft);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   516
    IriSP.jQuery("#TL_ArrowDown").css("left", arrowLeft);
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   517
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   518
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   519
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   520
 * Fonction appelée quand la souris est au dessus de la timeline.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   521
*/
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   522
IriSP.Widgets.Timeline.prototype.onMouseover = function() {}
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   523
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   524
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   525
 * Fonction appelée quand la souris est hors de la timeline.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   526
*/
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   527
IriSP.Widgets.Timeline.prototype.onMouseout = function() {}
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   528
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   529
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   530
 * Fonction appelée pour modifier la hauteur de la timeline.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   531
*/
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   532
IriSP.Widgets.Timeline.prototype.animateToHeight = function(_height) {}
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   533
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   534
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   535
 * Calcule le css de la timeline.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   536
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   537
 * Timeline > fonction draw.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   538
*/
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   539
IriSP.Widgets.Timeline.prototype.calculateTimelineCss = function(_size) {
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   540
    //Longueur du player.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   541
    var middleWidth = this.player.config.gui.width;
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   542
    var TLHeight = _size;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   543
    
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   544
    //On met à jour la marge, les coordonnées et positions de la timeline.
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   545
    return {
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   546
        position: "absolute",
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   547
        top: "0px",
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   548
        left: "0px",
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   549
        width: middleWidth + "px",
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   550
        height: TLHeight + "px",
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   551
        "margin-top": (-this.minimized_height - this.top_epsilon) + "px",
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   552
        "z-align": "50"
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   553
    };
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   554
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   555
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   556
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   557
 * Calcule le css de la barre grise de milieu de la timeline.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   558
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   559
 * Timeline > fonction draw.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   560
*/
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   561
IriSP.Widgets.Timeline.prototype.calculateTimelineMiddleCss = function(_size, _middleSize) {
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   562
    //Longueur du player.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   563
    var middleWidth = this.player.config.gui.width;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   564
    //On met à jour la marge, les coordonnées et positions de la barre grise de milieu de la timeline.
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   565
    return {
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   566
        position: "absolute",
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   567
        top: "0px",
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   568
        left: "0px",
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   569
        width: middleWidth + "px",
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   570
        height: _middleSize + "px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   571
        "margin-top": (-this.minimized_height/2 - _middleSize/2 - this.top_epsilon) + "px",
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   572
        "z-align": "100"
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   573
    };
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   574
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   575
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   576
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   577
 * Calcule le css de la portion de la timeline qui a déjà été lue.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   578
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   579
 * Timeline > fonction draw.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   580
*/
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   581
IriSP.Widgets.Timeline.prototype.calculateHandleCss = function(_size) {
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   582
    return {
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   583
        position: "absolute",
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   584
        top: "0px",
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   585
        left: "0px",
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   586
        height: (2 + _size) + "px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   587
        width: (2 + _size) + "px",
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   588
        "margin-left": -Math.ceil(2 + _size / 2) + "px",
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   589
        "z-align": "60"
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   590
    }
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   591
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   592
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   593
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   594
 * Affiche les marqueurs lorsqu'ils sont affichés au passage du curseur.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   595
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   596
 * Timeline > fonction onTimeupdate.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   597
*/
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   598
IriSP.Widgets.Timeline.prototype.showMarkerBig = function(marker, type) {
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   599
    //Si le marqueur est déjà affiché, on part.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   600
    if(this.markerBigShown)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   601
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   602
        return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   603
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   604
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   605
    //On annule le masquage du pointeur.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   606
    clearTimeout(this.hideTimeout);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   607
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   608
    var _this = this;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   609
    //On met à jour la position du marqueur.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   610
    var markerTop, markerLeft;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   611
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   612
    if(marker.position() == null)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   613
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   614
        markerTop = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   615
        markerLeft = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   616
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   617
    else
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   618
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   619
        markerTop = marker.position().top;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   620
        markerLeft = marker.position().left;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   621
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   622
    //Ses dimensions aussi.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   623
    var markerWidth = marker.width(), markerHeight = marker.height();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   624
    //On spécifie qu'il est affiché.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   625
    this.markerBigShown = true;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   626
    //On le crée.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   627
    var markerBig = "<div class='TL_MarkersBig' id='MB_Text'>" + this.gesturesText[IriSP.jQuery.inArray(type, this.gestures)] + "<div class='TL_MarkersBig' id='MB_Spike'></div></div><div class='TL_MarkersBig' id='MB_Pic'></div>";
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   628
    //On l'ajoute.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   629
    this.$.append(markerBig);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   630
    //On forme ses éléments.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   631
    var markerBigText = IriSP.jQuery("#MB_Text");
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   632
    var markerBigSpike = IriSP.jQuery("#MB_Spike");
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   633
    var markerBigPic = IriSP.jQuery("#MB_Pic");
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   634
    //On spécifie leurs coordonnées et dimensions.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   635
    var markerBigTextWidth = markerBigText.outerWidth(), markerBigTextHeight = markerBigText.outerHeight();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   636
    var markerBigSpikeWidth = markerBigSpike.width(), markerBigSpikeHeight = markerBigSpike.height();
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   637
    var markerBigPicWidth = markerBigPic.width(), markerBigPicHeight = markerBigPic.height();
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   638
    var markerBigPicTop = +parseInt(marker.css("margin-top")) + markerHeight, markerBigPicLeft = (markerLeft - markerBigPicWidth/2 + markerWidth/2);
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   639
    var markerBigTextTop = (parseInt(marker.css("margin-top")) - markerBigTextHeight - markerBigSpikeHeight), markerBigTextLeft = (markerLeft - (markerBigTextWidth - markerBigSpikeWidth)/2);
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   640
    var markerBigSpikeLeft = ((markerBigTextWidth - markerBigSpikeWidth)/2);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   641
    //On va chercher les images correspondantes.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   642
    marker.css("background-image", "url(" + this.imgDir + "selected_marker.png)");
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   643
    //On met à jour leur apparence.
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   644
    
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   645
    IriSP.jQuery("#MB_Text").css(
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   646
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   647
        top: markerBigTextTop,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   648
        left: markerBigTextLeft
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   649
    });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   650
    IriSP.jQuery("#MB_Spike").css(
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   651
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   652
        left: markerBigSpikeLeft
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   653
    });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   654
    IriSP.jQuery("#MB_Pic").css(
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   655
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   656
        "background-image": "url(" + this.markersDir + type + ".png)",
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   657
        top: markerBigPicTop,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   658
        left: markerBigPicLeft,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   659
        "z-index": "400"
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   660
    });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   661
    //On l'affiche.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   662
    IriSP.jQuery(".TL_MarkersBig").fadeTo(this.markerShowTime, "1");
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   663
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   664
    //On rajoute un timeout pour supprimer le marqueur après un certain temps.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   665
    this.hideTimeout = setTimeout(function()
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   666
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   667
        _this.hideMarkerBig(marker);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   668
    }, this.markerLastTime);
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   669
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   670
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   671
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   672
 * Cache un marqueur.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   673
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   674
 * Timeline > fonctions draw, keyPress, onTimeupdate et showMarkerBig.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   675
*/
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   676
IriSP.Widgets.Timeline.prototype.hideMarkerBig = function(marker) {
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   677
    //S'il n'est pas affiché, on part.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   678
    if(!this.markerBigShown)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   679
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   680
        return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   681
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   682
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   683
    //On lui remet son apparence initiale.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   684
    this.currentMarker = -1;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   685
    this.markerBigShown = false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   686
    marker.css("background-image", "url(" + this.imgDir + "marker.png)");
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   687
    //On efface ce qui était affiché du marqueur.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   688
    IriSP.jQuery(".TL_MarkersBig").fadeOut(this.markerShowTime).remove();
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   689
}
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   690
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   691
/*
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   692
 * Affiche le bas des marqueurs correspondants à la recherche.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   693
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   694
 * Timeline > fonction hideMarkersSearch.
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   695
*/
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   696
IriSP.Widgets.Timeline.prototype.showMarkersSearchByType = function(type) {
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   697
    //Si on est en mode SEARCH.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   698
    if(this.currentMode != "SEARCH")
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   699
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   700
        return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   701
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   702
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   703
    var _this = this;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   704
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   705
    //On récupère les annotations.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   706
    var markersSearch = "", markersPicSearch = "";
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   707
    //Pour chaque annotation, on ajoute un double.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   708
    for(var i = 0 ; i < this.annotations.length ; i++)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   709
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   710
        //Si elle correspond à la recherche.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   711
        if(this.annotations[i].annotationType.contents.title == type)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   712
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   713
            //On récupère le marqueur associé à l'annotation.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   714
            var markerId = this.annotations[i].id.replace(":", "_");
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   715
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   716
            markersSearch += "<div class='search_Marker' id='search_Marker_" + markerId + "'></div>";
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   717
            markersPicSearch += "<div class='search_MBPic' id='search_Pic_" + markerId + "'></div>";
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   718
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   719
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   720
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   721
    this.$.append(markersSearch + markersPicSearch);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   722
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   723
    //On place chaque double.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   724
    for(var i = 0 ; i < this.annotations.length ; i++)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   725
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   726
        //Si elle correspond à la recherche.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   727
        if(this.annotations[i].annotationType.contents.title == type)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   728
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   729
            //On calcule les coordonnées et dimensions du marqueur.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   730
            var markerId = this.annotations[i].id.replace(":", "_"), marker = IriSP.jQuery("#" + markerId);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   731
            var markerTop = marker.position().top, markerLeft = marker.position().left, markerWidth = marker.width(), markerHeight = marker.height();
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   732
            var markerBigPicWidth = parseInt(IriSP.jQuery(".search_MBPic").css("width")), markerBigPicHeight = parseInt(IriSP.jQuery(".search_MBPic").css("height")), markerBigPicTop = +parseInt(marker.css("margin-top")) + markerHeight, markerBigPicLeft = (markerLeft - markerBigPicWidth/2 + markerWidth/2);
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   733
            //On calcule son apparence et on le fait apparaître.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   734
            IriSP.jQuery("#search_Pic_" + markerId).css(
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   735
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   736
                position: "absolute",
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   737
                "background-image": "url(" + this.markersDir + type + ".png)",
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   738
                top: markerBigPicTop,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   739
                left: markerBigPicLeft,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   740
                "z-index": "300"
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   741
            }).fadeTo(this.markerShowTime, "1");
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   742
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   743
            IriSP.jQuery("#search_Marker_" + markerId).css(
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   744
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   745
                position: "absolute",
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   746
                top: _this.$timelineMiddle.position().top - _this.top_epsilon,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   747
                "margin-top": (-_this.$timeline.height()/2 - markerHeight/2),
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   748
                "background-image": "url(" + this.imgDir + "selected_marker.png)",
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   749
                left: markerLeft,
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   750
                "z-index": "300"
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   751
            }).fadeTo(this.markerShowTime, "1");
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   752
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   753
    }
31
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
 * Enlever une recherche faite précédemment.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   758
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   759
 * Timeline > fonctions searchByGesture et removeSearchByGesture.
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   760
*/
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   761
IriSP.Widgets.Timeline.prototype.hideMarkersSearch = function(type) {
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   762
    //Si on est en mode SEARCH.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   763
    if(this.currentMode != "SEARCH")
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   764
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   765
        return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   766
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   767
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   768
    var _this = this;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   769
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   770
    //On efface tous les marqueurs affichés.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   771
    IriSP.jQuery(".search_MBPic").fadeOut(this.markerShowTime, function()
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   772
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   773
        IriSP.jQuery("div").remove(".search_MBPic");
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   774
    });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   775
    IriSP.jQuery(".search_Marker").fadeOut(this.markerShowTime, function()
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   776
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   777
        IriSP.jQuery("div").remove(".search_Marker");
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   778
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   779
        //Si le type est définit, c'est qu'on souhaite remplacer cette recherche par une autre.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   780
        if(type == undefined)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   781
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   782
            _this.currentMode = "VIDEO";
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   783
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   784
        else
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   785
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   786
            _this.showMarkersSearchByType(type);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   787
            return;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   788
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   789
    });
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   790
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   791
    //Si à la base il n'y avait pas de marqueurs affichés, on crée une nouvelle recherche si le type est définit.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   792
    if(IriSP.jQuery(".search_Marker").length == 0 && type != undefined)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   793
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   794
        this.showMarkersSearchByType(type);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   795
    }
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   796
}
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   797
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   798
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   799
 * Libère le player.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   800
 * Est appelé dans les fichiers :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   801
 * neighbours > fonction moveToNeighbour.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   802
 * zoomInteractions > fonction unzoom.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   803
*/
33
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   804
IriSP.Widgets.Timeline.prototype.freePlayer = function()
2d9b15f99b4e Front IDILL :
bastiena
parents: 32
diff changeset
   805
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   806
    IriSP.jQuery('body').unbind('keypress');
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   807
    IriSP.jQuery('.notifications').remove();
33
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
/*
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   811
 * Va au marqueur suivant/précédant lors d'un swipe right/left dans une lecture simple.
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   812
 * Prend comme argument le fait qu'il s'agisse d'un swipe left ou non (en prenant en condition toujours vraie 
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   813
 * que la fonction est appelée si et seulement si il y a swipe et que l'utilisateur ne tente pas d'aller vers un voisin.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   814
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   815
 * mosaic > fonction manageControlEvents.
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   816
*/
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   817
IriSP.Widgets.Timeline.prototype.switchToMarker = function(isSwipeLeft, searchedGesture)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   818
{
61
5292b7e88eed Front IDILL :
bastiena
parents: 55
diff changeset
   819
   //On prend le temps actuel du curseur en ms.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   820
    var currentCursorPosition = this.player.popcorn.currentTime() * 1000;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   821
    //Position visée.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   822
    var targetCursorPosition = currentCursorPosition;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   823
    //Distance minimum de l'annotation par rapport au curseur et son index, ainsi que l'index - 1 pour le cas du swipe right.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   824
    var minDistance = this.source.getDuration().milliseconds, minIdx = 0, mindIdx_1 = 0;
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   825
    
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   826
    //Condition de sélection du marqueur selon le type de swipe.
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   827
    var swipeCondition;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   828
    
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   829
    //Si il y a au moins 1 annotation.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   830
    if(this.annotations && this.annotations.length > 0)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   831
    {
79
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   832
        //Pour toutes les annotations, on prend celle qui est la plus proche et supérieure à la position.
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   833
        for(var i = 0 ; i < this.annotations.length ; i++)
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   834
        {
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   835
            swipeCondition = (isSwipeLeft ? (currentCursorPosition < this.annotations[i].begin && minDistance > Math.abs(currentCursorPosition - this.annotations[i].begin)) : (currentCursorPosition > this.annotations[i].begin && minDistance > Math.abs(currentCursorPosition - this.annotations[i].begin)));
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   836
            
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   837
            if(swipeCondition)
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   838
            {
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   839
                //Si on recherche une gesture.
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   840
                if(searchedGesture != '')
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   841
                {
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   842
                    //Si l'annotation actuelle ne correspond pas à la gesture recherchée, on passe.
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   843
                    if(this.annotations[i].annotationType.contents.title != searchedGesture)
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   844
                    {
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   845
                        continue;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   846
                    }
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   847
                }
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   848
                
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   849
                //On calcule la plus petite distance entre le marqueur marqueur actuel et les autres.
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   850
                minDistance = (currentCursorPosition - this.annotations[i].begin);
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   851
                minIdx = i;
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   852
            }
9eff85166868 Front IDILL :
bastiena
parents: 77
diff changeset
   853
        }
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   854
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   855
        //On obtient la position du plus proche marqueur.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   856
        targetCursorPosition = this.annotations[minIdx].begin;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   857
        
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   858
        //Si le marqueur est situé minimum à 1s du début de la video, on place la position cible à 1s avant celle du marqueur recherché.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   859
        if(this.annotations[minIdx].begin > 1000)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   860
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   861
            targetCursorPosition -= 1000;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   862
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   863
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   864
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   865
    //On place le marqueur au niveau de la position cible.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   866
    this.player.popcorn.currentTime(targetCursorPosition / 1000);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   867
}
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   868
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   869
/*
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   870
 * Indique s'il y a des marqueurs devant le curseur (pour une recherche).
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   871
 * Est appelé dans le fichier :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   872
 * mosaic > fonction manageControlEvents.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   873
*/
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   874
IriSP.Widgets.Timeline.prototype.isAMarkerAhead = function(searchedGesture)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   875
{
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   876
    if(searchedGesture == '')
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   877
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   878
        return true;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   879
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   880
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   881
    //On prend le temps actuel du curseur en ms.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   882
    var currentCursorPosition = this.player.popcorn.currentTime() * 1000;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   883
    //Position visée.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   884
    var targetCursorPosition = currentCursorPosition;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   885
    //Distance minimum de l'annotation par rapport au curseur et son index, ainsi que l'index - 1 pour le cas du swipe right.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   886
    var minDistance = this.source.getDuration().milliseconds, minIdx = 0, mindIdx_1 = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   887
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   888
    //Si il y a au moins 1 annotation.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   889
    if(this.annotations && this.annotations.length > 0)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   890
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   891
        //Pour toutes les annotations, on prend celle qui est la plus proche et supérieure à la position.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   892
        for(var i = 0 ; i < this.annotations.length ; i++)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   893
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   894
            if(this.annotations[i].annotationType.contents.title == searchedGesture && currentCursorPosition < this.annotations[i].begin)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   895
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   896
                return true;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   897
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   898
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   899
    }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   900
    
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   901
    //Si elle n'a pas été trouvée on renvoie faux.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   902
    return false;
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   903
}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   904
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   905
/*
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   906
 * Quand on entre dans la vidéo après un filtrage, on va au premier marqueur correspondant à la recherche (à l'exception d'une recherche infructueuse).
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   907
 * Est appelé dans les fichiers :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   908
 * mosaic > fonctions onMouseUp et onMarkersReady.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   909
 * curvesDetector > fonction updateDists.
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   910
*/
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   911
IriSP.Widgets.Timeline.prototype.goToFirstSearchedMarker = function(gesture)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   912
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   913
    if(_.include(this.gestures, gesture))
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   914
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   915
        if(this.annotations && this.annotations.length > 0)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   916
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   917
            var minIdx = 0, minPosition = this.source.getDuration().milliseconds, targetCursorPosition = 0;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   918
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   919
            //On parcourt les annotations, pour chaque correspondant à la gesture recherchée, on trouve celle qui se trouve à la position minimum.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   920
            for(var i = 0 ; i < this.annotations.length ; i++)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   921
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   922
                //Si le marker n'est pas du type recherché, on passe.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   923
                if(this.annotations[i].annotationType.contents.title != gesture)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   924
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   925
                    continue;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   926
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   927
                else if(minPosition > this.annotations[i].begin)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   928
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   929
                    minPosition = this.annotations[i].begin;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   930
                    minIdx = i;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   931
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   932
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   933
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   934
            targetCursorPosition = this.annotations[minIdx].begin;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   935
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   936
            //Si le marqueur est situé minimum à 1s du début de la video, on place la position cible à 1s avant celle du marqueur recherché.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   937
            if(this.annotations[minIdx].begin > 1000)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   938
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   939
                targetCursorPosition -= 1000;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   940
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   941
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   942
            //On place le marqueur au niveau de la position cible.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   943
            this.player.popcorn.currentTime(targetCursorPosition / 1000);
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   944
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   945
    }
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   946
}
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   947
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   948
/*
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   949
 * Renvoie vrai si il y a au moins une gesture de notre recherche dans les marqueurs de la video.
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   950
 * Est appelé dans les fichiers :
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   951
 * mosaic > fonctions onMouseUp et onMarkersReady.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   952
 * curvesDetector > fonction updateDists.
44
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   953
*/
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   954
IriSP.Widgets.Timeline.prototype.atLeastOneSearchMarker = function(gesture)
8393d3473b98 Front IDILL:
bastiena
parents: 35
diff changeset
   955
{
52
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   956
    if(_.include(this.gestures, gesture))
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   957
    {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   958
        if(this.annotations && this.annotations.length > 0)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   959
        {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   960
            //On parcourt les annotations, pour chaque correspondant à la gesture recherchée, on trouve celle qui se trouve à la position minimum.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   961
            for(var i = 0 ; i < this.annotations.length ; i++)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   962
            {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   963
                //Si le marker est reconnu, c'est bon.
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   964
                if(this.annotations[i].annotationType.contents.title == gesture)
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   965
                {
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   966
                    return true;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   967
                }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   968
            }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   969
            
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   970
            return false;
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   971
        }
277c94533395 Front IDILL :
bastiena
parents: 47
diff changeset
   972
    }
31
2c7fc855eba8 FRONT IDILL :
bastiena
parents:
diff changeset
   973
}