src/widgets/Markers.js
author durandn
Tue, 01 Sep 2015 15:57:54 +0200
changeset 1047 c3bf174e0ef8
parent 1045 b06345320ffb
child 1051 3820cf5fe29e
permissions -rw-r--r--
Added a button to cancel Annotation creation and hide the widget on CreateAnnotation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1045
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
     1
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
     2
IriSP.Widgets.Markers = function(player, config) {
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
     3
    IriSP.Widgets.Widget.call(this, player, config);
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
     4
};
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
     5
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
     6
IriSP.Widgets.Markers.prototype = new IriSP.Widgets.Widget();
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
     7
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
     8
IriSP.Widgets.Markers.prototype.defaults = {
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
     9
    annotation_type: "markers",
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    10
    line_height: 8,
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    11
    background: "#e0e0e0",
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    12
    marker_color: "#ff80fc",
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    13
    hover_color: "#e15581",
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    14
    selected_color: "#74d600",
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    15
    ball_radius: 4,
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    16
    pause_on_write: true,
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    17
    api_serializer: "ldt_annotate",
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    18
    api_endpoint_template: "",
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    19
    api_method_create: "POST",
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    20
    api_method_editing: "PUT",
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    21
    project_id: "",
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    22
    creator_name: "",
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    23
    after_send_timeout: 0,
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    24
    close_after_send: false,
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    25
};
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    26
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    27
IriSP.Widgets.Markers.prototype.template = 
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    28
    '<div class="Ldt-Markers-Display" style="height:{{line_height}}px;">'
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    29
    +     '<div class="Ldt-Markers-List" style="height:{{line_height}}px; position: relative;"></div>'
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    30
    +     '<div class="Ldt-Markers-Position"></div>'
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    31
    + '</div>'
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    32
    + '<div class="Ldt-Markers-Inputs">'
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    33
    +     '<div class="Ldt-Markers-Screen Ldt-Markers-ScreenMain">'
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    34
    +         '<div class="Ldt-Markers-Create">+</div>'
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    35
    +         '<div class="Ldt-Markers-Info"></div>'
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    36
    +     '</div>'
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    37
    +     '<div class="Ldt-Markers-Screen Ldt-Markers-ScreenSending">'  
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    38
    +         '<div class="Ldt-Markers-Screen-InnerBox">{{l10n.wait_while_processing}}</div>'
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    39
    +     '</div>'
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    40
    +     '<div class="Ldt-Markers-Screen Ldt-Markers-ScreenSuccess">'
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    41
    +         '<a title="{{l10n.close_widget}}" class="Ldt-Markers-Close" href="#"></a>'    
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    42
    +         '<div class="Ldt-Markers-Screen-InnerBox">{{l10n.annotation_saved}}</div>'
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    43
    +     '</div>'
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    44
    +     '<div class="Ldt-Markers-Screen Ldt-Markers-ScreenFailure">'
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    45
    +         '<a title="{{l10n.close_widget}}" class="Ldt-Markers-Close" href="#"></a>'
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    46
    +         '<div class="Ldt-Markers-Screen-InnerBox">{{l10n.error_while_contacting}}</div>'
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    47
    +     '</div>'
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    48
    + '</div>';
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    49
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    50
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    51
IriSP.Widgets.Markers.prototype.markerTemplate = 
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    52
    '<div class="Ldt-Markers-Marker" style="height:{{height}}px; left:{{left}}px; width: 2px; background-color: black;">' +
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    53
        '<div class="Ldt-Markers-MarkerBall" style="background-color: {{marker_color}}; position: relative; width: {{ball_diameter}}px; height: {{ball_diameter}}px; left: {{ball_left}}px; top: {{ball_top}}px; border: 1px solid; border-radius: {{ball_radius}}px"></div>' + 
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    54
    '</div>';   
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    55
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    56
IriSP.Widgets.Markers.prototype.infoTemplate = 
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    57
    '{{^edit}}<div class="Ldt-Markers-MarkerDescription">{{marker_info}}</div>{{/edit}}' +
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    58
    '{{#edit}}<div class="Ldt-Markers-MarkerEdit">' + 
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    59
        '<textarea class="Ldt-Markers-MarkerTextArea" cols="60" rows="4">{{marker_info}}</textarea>' +
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    60
        '<div class="Ldt-Markers-Buttons">' +
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    61
            '<div class="Ldt-Markers-MarkerSend">{{send}}</div>' +
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    62
            '<div class="Ldt-Markers-MarkerCancel">{{cancel}}</div>' +
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    63
        '</div>' +
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    64
    '</div>{{/edit}}'
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    65
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    66
IriSP.Widgets.Markers.prototype.messages = {
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    67
    en : {
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    68
        send : "Send",
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    69
        cancel : "Cancel",
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    70
        wait_while_processing: "Please wait while your annotation is being processed...",
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    71
        error_while_contacting: "An error happened while contacting the server. Your annotation has not been saved.",
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    72
        annotation_saved: "Thank you, your annotation has been saved.",
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    73
        close_widget: "Close",
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    74
    },
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    75
    fr : {
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    76
        send : "Envoyer",
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    77
        cancel : "Annuler",
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    78
        wait_while_processing: "Veuillez patienter pendant le traitement de votre annotation...",
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    79
        error_while_contacting: "Une erreur s'est produite en contactant le serveur. Votre annotation n'a pas été enregistrée.",
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    80
        annotation_saved: "Merci, votre annotation a été enregistrée.",
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    81
        close_widget: "Fermer",
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    82
    }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    83
}
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    84
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    85
IriSP.Widgets.Markers.prototype.draw = function(){
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    86
    var _this = this;
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    87
    
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    88
    this.renderTemplate();
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    89
    
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    90
    this.markers = this.getWidgetAnnotations().filter(function(_ann) {
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    91
        return ((_ann.getDuration() == 0) || (_ann.begin == _ann.end));
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    92
    });
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    93
    this.drawMarkers();
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    94
    
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    95
    this.$.find(".Ldt-Markers-Create").click(function(){
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    96
        if (!_this.selectedMarker){
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    97
            _this.toggleCreateMarker();
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    98
        }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    99
        else {
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   100
            _this.selectedMarker = false;
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   101
            _this.$.find(".Ldt-Markers-Info").html("");
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   102
            _this.$.find(".Ldt-Markers-MarkerBall").css("background-color", _this.marker_color)
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   103
            _this.$.find(".Ldt-Markers-Create").html("+");
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   104
        }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   105
    })
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   106
    this.$.find(".Ldt-Markers-Info").click(function(){
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   107
        if (_this.selectedMarker&&!_this.editing){
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   108
            _this.toggleCreateMarker();
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   109
        }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   110
    })
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   111
    this.showScreen("Main");
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   112
    this.$.css({
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   113
        margin: "1px 0",
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   114
        height: this.line_height,
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   115
        background: this.background
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   116
    });
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   117
    
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   118
    this.$.find(".Ldt-Markers-Close").click(function() {
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   119
        _this.showScreen("Main");
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   120
    });
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   121
    
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   122
    this.onMediaEvent("timeupdate", "updatePosition");
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   123
    this.onMdpEvent("Markers.refresh", this.functionWrapper("drawMarkers"));
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   124
    
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   125
    this.editing = false;
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   126
    this.selectedMarker = false;
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   127
}
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   128
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   129
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   130
IriSP.Widgets.Markers.prototype.updatePosition = function(_time) {    
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   131
    var _x = Math.floor( this.width * _time / this.media.duration);
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   132
    this.$.find('.Ldt-Markers-Position').css({
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   133
        left: _x + "px"
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   134
    });
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   135
};
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   136
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   137
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   138
IriSP.Widgets.Markers.prototype.toggleCreateMarker = function(){
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   139
    if(!this.editing){
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   140
        this.editing = true
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   141
    }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   142
    else {
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   143
        this.editing = false
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   144
    }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   145
    var _divHtml = "";
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   146
    if (this.selectedMarker){       
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   147
        _divHtml = Mustache.to_html(this.infoTemplate, {
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   148
            edit: this.editing,
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   149
            marker_info: this.selectedMarker.description,
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   150
            send: this.l10n.send,
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   151
            cancel: this.l10n.cancel
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   152
        })
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   153
        
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   154
        this.$.find(".Ldt-Markers-Info").html(_divHtml);
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   155
     }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   156
     else {
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   157
         if (this.editing) {
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   158
             _divHtml = Mustache.to_html(this.infoTemplate, {
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   159
                 edit: this.editing,
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   160
                 marker_info: "",
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   161
                 send: this.l10n.send,
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   162
                 cancel: this.l10n.cancel,
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   163
             })
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   164
         }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   165
         this.$.find(".Ldt-Markers-Info").html(_divHtml);
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   166
     }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   167
    
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   168
    if(this.editing){
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   169
        this.$.find(".Ldt-Markers-MarkerSend").click(this.functionWrapper("onSubmit"));
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   170
        this.$.find(".Ldt-Markers-MarkerCancel").click(this.functionWrapper("toggleCreateMarker"));
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   171
        this.$.find(".Ldt-Markers-MarkerTextArea").bind("change keyup input paste", this.functionWrapper("onDescriptionChange"));
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   172
        this.$.find(".Ldt-Markers-Create").html("-");
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   173
    }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   174
    else {
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   175
        this.$.find(".Ldt-Markers-Create").html("+");
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   176
    }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   177
};
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   178
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   179
IriSP.Widgets.Markers.prototype.onDescriptionChange = function(){
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   180
    var _field = this.$.find(".Ldt-Markers-MarkerTextArea"),
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   181
        _contents = _field.val();
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   182
    _field.css("border-color", !!_contents ? "#e87d9f" : "#ff0000");
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   183
    if (!!_contents) {
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   184
        _field.removeClass("empty");
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   185
    } else {
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   186
        _field.addClass("empty");
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   187
    }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   188
    this.pauseOnWrite();
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   189
    return !!_contents;
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   190
};
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   191
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   192
IriSP.Widgets.Markers.prototype.pauseOnWrite = function(){
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   193
    if (this.pause_on_write && !this.media.getPaused()) {
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   194
        this.media.pause();
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   195
    }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   196
};
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   197
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   198
IriSP.Widgets.Markers.prototype.showScreen = function(_screenName) {
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   199
    this.$.find('.Ldt-Markers-Screen' + _screenName).show()
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   200
        .siblings().hide();
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   201
    if ((_screenName=="Main")&&(this.editing)){
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   202
        this.toggleCreateMarker();
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   203
    };
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   204
}
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   205
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   206
IriSP.Widgets.Markers.prototype.drawMarkers = function(){
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   207
    this.$.remove("Ldt-Markers-Marker");
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   208
    var _this = this,
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   209
        _scale = this.width / this.source.getDuration(),
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   210
        list_$ = this.$.find('.Ldt-Markers-List');
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   211
    
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   212
    this.markers.forEach(function(_marker){
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   213
        var _left = _marker.begin * _scale -1;
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   214
        _data = {
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   215
            left: _left,
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   216
            height: _this.line_height-1,
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   217
            ball_top: (_this.ball_radius*2 > _this.line_height) ? 0 : ((_this.line_height - _this.ball_radius*2)/2)-1,
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   218
            ball_radius: (_this.ball_radius*2 > _this.line_height) ? _this.line_height/2 : _this.ball_radius,
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   219
            ball_diameter: (_this.ball_radius*2 > _this.line_height) ? _this.line_height/2 : _this.ball_radius*2,
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   220
            ball_left: -_this.ball_radius,
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   221
            marker_color: ((_this.selectedMarker)&&(_this.selectedMarker.id == _marker.id))? _this.selected_color : _this.marker_color
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   222
        }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   223
        var _html = Mustache.to_html(_this.markerTemplate, _data),
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   224
            _el = IriSP.jQuery(_html);
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   225
        _el.mouseover(function(){
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   226
                if (!((_this.selectedMarker)&&(_this.selectedMarker.id == _marker.id))){
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   227
                    _el.children().css("background-color", _this.hover_color);
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   228
                };
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   229
            })
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   230
           .mouseout(function(){
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   231
              if (!((_this.selectedMarker)&&(_this.selectedMarker.id == _marker.id))){
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   232
                  _el.children().css("background-color", _this.marker_color);
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   233
              };
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   234
           })
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   235
           .click(function(){
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   236
               _this.showScreen("Main");
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   237
               if (!((_this.selectedMarker)&&(_this.selectedMarker.id == _marker.id))){
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   238
                  list_$.find(".Ldt-Markers-MarkerBall").css("background-color", _this.marker_color)
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   239
                  _el.children().css("background-color", _this.selected_color)
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   240
                  _this.selectedMarker = _marker;
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   241
                  _divHtml = Mustache.to_html(_this.infoTemplate, {
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   242
                      edit: _this.editing,
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   243
                      marker_info: _marker.description,
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   244
                      send: _this.l10n.send,
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   245
                      cancel: _this.l10n.cancel
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   246
                  })
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   247
                  
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   248
                  _this.$.find(".Ldt-Markers-Info").html(_divHtml);
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   249
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   250
                  if(_this.editing){
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   251
                      _this.$.find(".Ldt-Markers-MarkerSend").click(_this.functionWrapper("onSubmit"));
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   252
                      _this.$.find(".Ldt-Markers-MarkerCancel").click(_this.functionWrapper("toggleCreateMarker"));
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   253
                  }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   254
               }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   255
               else {
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   256
                   var _divHtml = ""
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   257
                   if (_this.editing){
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   258
                       _divHtml = Mustache.to_html(_this.infoTemplate, {
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   259
                           edit: _this.editing,
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   260
                           marker_info: "",
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   261
                           send: _this.l10n.send,
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   262
                           cancel: _this.l10n.cancel
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   263
                       });
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   264
                   }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   265
                   _el.children().css("background-color", _this.hover_color);
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   266
                   _this.selectedMarker = false;
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   267
                   _this.$.find(".Ldt-Markers-Info").html(_divHtml);
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   268
                   
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   269
                   if(_this.editing){
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   270
                       _this.$.find(".Ldt-Markers-MarkerSend").click(_this.functionWrapper("onSubmit"));
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   271
                       _this.$.find(".Ldt-Markers-MarkerCancel").click(_this.functionWrapper("toggleCreateMarker"));
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   272
                   }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   273
               }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   274
               
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   275
               if (_this.selectedMarker){
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   276
                   _this.$.find(".Ldt-Markers-Create").html("-")
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   277
               }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   278
               else {
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   279
                   _this.$.find(".Ldt-Markers-Create").html("+")
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   280
               }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   281
               
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   282
               if (_this.selectedMarker) {
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   283
                   // If we unselect a marker we shouldn't trigger pause or time jump
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   284
                   _this.media.pause();
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   285
                   _marker.trigger("click");
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   286
               }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   287
           })
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   288
           .appendTo(list_$);
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   289
    })
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   290
}
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   291
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   292
IriSP.Widgets.Markers.prototype.onSubmit = function(){
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   293
    
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   294
    /* Si les champs obligatoires sont vides, on annule l'envoi */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   295
    if (!this.onDescriptionChange()) {
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   296
        return false;
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   297
    }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   298
    
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   299
    /* On pause la vidéo si elle est encore en train de tourner */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   300
    if (!this.media.getPaused()){
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   301
        this.media.pause();
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   302
    }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   303
    
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   304
    var _this = this,
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   305
        _exportedAnnotations = new IriSP.Model.List(this.player.sourceManager), /* Création d'une liste d'annotations contenant une annotation afin de l'envoyer au serveur */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   306
        _url = Mustache.to_html(this.api_endpoint_template, {annotation_id: this.selectedMarker ? this.selectedMarker.id : ""});
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   307
    if (this.selectedMarker){
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   308
        var _export = this.player.sourceManager.newLocalSource({serializer: IriSP.serializers[this.api_serializer]})
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   309
            _annotation = this.selectedMarker;
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   310
        _annotation.source = _export
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   311
        _annotation.description = this.$.find(".Ldt-Markers-MarkerTextArea").val(), /* Champ description */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   312
        _annotationTypes = this.source.getAnnotationTypes().searchByTitle(this.annotation_type, true), /* Récupération du type d'annotation dans lequel l'annotation doit être ajoutée */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   313
        _annotationType = (_annotationTypes.length ? _annotationTypes[0] : new IriSP.Model.AnnotationType(false, _export)); /* Si le Type d'Annotation n'existe pas, il est créé à la volée */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   314
    }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   315
    else {
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   316
        var _export = this.player.sourceManager.newLocalSource({serializer: IriSP.serializers[this.api_serializer]}), /* Création d'un objet source utilisant un sérialiseur spécifique pour l'export */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   317
            _annotation = new IriSP.Model.Annotation(false, _export); /* Création d'une annotation dans cette source avec un ID généré à la volée (param. false) */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   318
            _annotationTypes = this.source.getAnnotationTypes().searchByTitle(this.annotation_type, true), /* Récupération du type d'annotation dans lequel l'annotation doit être ajoutée */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   319
            _annotationType = (_annotationTypes.length ? _annotationTypes[0] : new IriSP.Model.AnnotationType(false, _export)); /* Si le Type d'Annotation n'existe pas, il est créé à la volée */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   320
        /* Si nous avons dû générer un ID d'annotationType à la volée... */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   321
        if (!_annotationTypes.length) {
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   322
            /* Il ne faudra pas envoyer l'ID généré au serveur */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   323
            _annotationType.dont_send_id = true;
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   324
            /* Il faut inclure le titre dans le type d'annotation */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   325
            _annotationType.title = this.annotation_type;
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   326
        }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   327
    
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   328
        _annotation.setMedia(this.source.currentMedia.id); /* Id du média annoté */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   329
        _currentTime = this.media.getCurrentTime();
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   330
        _annotation.setBegin(_currentTime); /* Timecode de la lecture de la video */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   331
        _annotation.setEnd(_currentTime); /* Timecode de fin du widget */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   332
        _annotation.setAnnotationType(_annotationType.id); /* Id du type d'annotation */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   333
        if (this.project_id != ""){
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   334
            /* Champ id projet, seulement si on l'a renseigné dans la config */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   335
            _annotation.project_id = this.project_id;
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   336
        }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   337
        _annotation.created = new Date(); /* Date de création de l'annotation */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   338
        _annotation.description = this.$.find(".Ldt-Markers-MarkerTextArea").val(); /* Champ description */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   339
        _annotation.creator = this.creator_name;
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   340
    }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   341
    _annotation.project_id = this.project_id;
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   342
    
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   343
    /*
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   344
     * Nous remplissons les données de l'annotation générée à la volée
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   345
     * ATTENTION: Si nous sommes sur un MASHUP, ces éléments doivent se référer AU MEDIA D'ORIGINE
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   346
     * */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   347
    
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   348
    _exportedAnnotations.push(_annotation); /* Ajout de l'annotation à la liste à exporter */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   349
    _export.addList("annotation",_exportedAnnotations); /* Ajout de la liste à exporter à l'objet Source */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   350
    
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   351
    /* Envoi de l'annotation via AJAX au serveur ! */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   352
    IriSP.jQuery.ajax({
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   353
        url: _url,
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   354
        type: this.selectedMarker ? this.api_method_editing : this.api_method_create,
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   355
        contentType: 'application/json',
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   356
        data: _export.serialize(), /* L'objet Source est sérialisé */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   357
        success: function(_data) {
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   358
            _this.showScreen('Success'); /* Si l'appel a fonctionné, on affiche l'écran "Annotation enregistrée" */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   359
            window.setTimeout(function(){
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   360
                _this.showScreen("Main")
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   361
            },
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   362
            (_this.after_send_timeout || 5000));
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   363
            _export.getAnnotations().removeElement(_annotation, true); /* Pour éviter les doublons, on supprime l'annotation qui a été envoyée */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   364
            _export.deSerialize(_data); /* On désérialise les données reçues pour les réinjecter */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   365
            _this.source.merge(_export); /* On récupère les données réimportées dans l'espace global des données */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   366
            if (_this.pause_on_write && _this.media.getPaused()) {
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   367
                _this.media.play();
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   368
            }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   369
            _this.markers.push(_annotation);
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   370
            _this.selectedMarker = _annotation;
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   371
            _this.player.trigger("AnnotationsList.refresh"); /* On force le rafraîchissement du widget AnnotationsList */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   372
            _this.player.trigger("Markers.refresh");
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   373
            _this.$.find(".Ldt-Markers-MarkerTextArea").val("")
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   374
        },
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   375
        error: function(_xhr, _error, _thrown) {
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   376
            IriSP.log("Error when sending annotation", _thrown);
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   377
            _export.getAnnotations().removeElement(_annotation, true);
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   378
            _this.showScreen('Failure');
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   379
            window.setTimeout(function(){
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   380
                _this.showScreen("Main");
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   381
            },
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   382
            (_this.after_send_timeout || 5000));
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   383
        }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   384
    });
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   385
    this.showScreen('Sending');
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   386
    
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   387
    return false;
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   388
};