src/widgets/Markers.js
author durandn
Fri, 25 Sep 2015 14:45:38 +0200
changeset 1067 539c9bee5372
parent 1066 5ef7182907c5
child 1069 2409cb4cebaf
permissions -rw-r--r--
Translating comments into English
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",
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
    13
    placeholder_color: "#ffffff",
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
    14
    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
    15
    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
    16
    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
    17
    pause_on_write: true,
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
    18
    play_on_submit: true,
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
    19
    api_serializer: "ldt_annotate",
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
    20
    api_endpoint_template_create: "",
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
    21
    api_endpoint_template_edit: "",
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
    22
    api_endpoint_template_delete: "",
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
    23
    api_method_create: "POST",
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
    24
    api_method_edit: "PUT",
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
    25
    api_method_delete: "DELETE",
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
    26
    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
    27
    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
    28
    after_send_timeout: 0,
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
    29
    markers_gap: 2000,
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
    30
    allow_empty_markers: false,
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
    31
    close_after_send: false,
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
    32
    custom_send_button: false,
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
    33
    custom_cancel_button: false,
1066
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
    34
    preview_mode: false,
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
    35
};
b06345320ffb Altered ldt_annotate serializer 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
b06345320ffb Altered ldt_annotate serializer 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
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
    38
    '<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
    39
    +     '<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
    40
    +     '<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
    41
    + '</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
    42
    + '<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
    43
    +     '<div class="Ldt-Markers-Screen Ldt-Markers-ScreenMain">'
1066
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
    44
    +         '<div class="Ldt-Markers-RoundButton Ldt-Markers-CannotCreate" title="{{#preview_mode}}{{l10n.preview_mode_submit}}{{/preview_mode}}{{^preview_mode}}{{l10n.cannot_create}}{{/preview_mode}}">+</div>'
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
    45
    +         '<div class="Ldt-Markers-RoundButton Ldt-Markers-Create">+</div>'
1066
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
    46
    +         '{{^preview_mode}}<div class="Ldt-Markers-RoundButton Ldt-Markers-Delete">&#10006;</div>{{/preview_mode}}'
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
    47
    +         '{{#preview_mode}}<div class="Ldt-Markers-RoundButton Ldt-Markers-PreviewDelete" title="{{l10n.preview_mode_delete}}">&#10006;</div>{{/preview_mode}}'
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
    48
    +         '<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
    49
    +     '</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
    50
    +     '<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
    51
    +         '<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
    52
    +     '</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
    53
    +     '<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
    54
    +         '<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
    55
    +         '<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
    56
    +     '</div>'
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
    57
    +     '<div class="Ldt-Markers-Screen Ldt-Markers-ScreenDeleteSuccess">'
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
    58
    +         '<a title="{{l10n.close_widget}}" class="Ldt-Markers-Close" href="#"></a>'    
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
    59
    +         '<div class="Ldt-Markers-Screen-InnerBox">{{l10n.delete_saved}}</div>'
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
    60
    +     '</div>'
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
    61
    +     '<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
    62
    +         '<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
    63
    +         '<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
    64
    +     '</div>'
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
    65
    +     '<div class="Ldt-Markers-Screen Ldt-Markers-ScreenConfirmDelete">'
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
    66
    +         '<a title="{{l10n.close_widget}}" class="Ldt-Markers-Close" href="#"></a>'
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
    67
    +         '<div class="Ldt-Markers-Screen-InnerBox">'
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
    68
    +           '{{l10n.delete_text}} '
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
    69
    +           '<a class="Ldt-Markers-Screen-SubmitDelete">{{l10n.submit_delete}}</a> '
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
    70
    +           '<a class="Ldt-Markers-Screen-CancelDelete">{{l10n.cancel}}</a>'
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
    71
    +         '</div>'
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
    72
    +     '</div>'
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
    73
    + '</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
    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
b06345320ffb Altered ldt_annotate serializer 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
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
    77
    '<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
    78
        '<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>' + 
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
    79
    '</div>';
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
    80
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
    81
IriSP.Widgets.Markers.prototype.markerPlaceholderTemplate = 
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
    82
    '<div class="Ldt-Markers-Marker Ldt-Markers-PlaceholderMarker" style="height:{{height}}px; left:{{left}}px; width: 2px; background-color: black;">' +
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
    83
        '<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>' + 
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
    84
    '</div>'; 
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
    85
b06345320ffb Altered ldt_annotate serializer 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
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
    87
    '{{^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
    88
    '{{#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
    89
        '<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
    90
        '<div class="Ldt-Markers-Buttons">' +
1066
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
    91
            '{{^preview_mode}}<div class="Ldt-Markers-MarkerSend">{{send}}</div>{{/preview_mode}}' +
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
    92
            '{{#preview_mode}}<div class="Ldt-Markers-MarkerPreviewSend" title="{{preview_mode_text}}">{{send}}</div>{{/preview_mode}}' +
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
    93
            '<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
    94
        '</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
    95
    '</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
    96
b06345320ffb Altered ldt_annotate serializer 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
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
    98
    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
    99
        send : "Send",
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   100
        submit_delete: "Delete",
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
   101
        cancel : "Cancel",
1066
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   102
        preview_mode_submit: "You cannot submit a marker in preview mode.",
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   103
        preview_mode_delete: "You cannot delete a marker in preview mode",
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
   104
        wait_while_processing: "Please wait while your annotation is being processed...",
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   105
        delete_text: "The selected marker will be deleted. Continue?",
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
   106
        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
   107
        annotation_saved: "Thank you, your annotation has been saved.",
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   108
        delete_saved: "Thank you, your annotation has been deleted",
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
   109
        close_widget: "Close",
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   110
        cannot_create: "Cannot create marker on this timecode"
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
   111
    },
b06345320ffb Altered ldt_annotate serializer 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
    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
   113
        send : "Envoyer",
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   114
        submit_delete: "Supprimer",
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
   115
        cancel : "Annuler",
1066
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   116
        preview_mode_submit: "Vous ne pouvez pas créer ou éditer de marqueur en mode aperçu",
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   117
        preview_mode_delete: "Vous ne pouvez pas supprimer de marqueur en mode aperçu",
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
   118
        wait_while_processing: "Veuillez patienter pendant le traitement de votre annotation...",
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   119
        delete_text: "Le marqueur sélectionné sera supprimé. Continuer?",
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
   120
        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
   121
        annotation_saved: "Merci, votre annotation a été enregistrée.",
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   122
        delete_saved: "Merci, votre annotation a été supprimée",
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
   123
        close_widget: "Fermer",
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   124
        cannot_create: "Impossible de créer un marqueur sur ce timecode"
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
   125
    }
b06345320ffb Altered ldt_annotate serializer 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
}
b06345320ffb Altered ldt_annotate serializer 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
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
   129
    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
   130
    
b06345320ffb Altered ldt_annotate serializer 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
    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
   132
    
b06345320ffb Altered ldt_annotate serializer 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
    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
   134
        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
   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
    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
   137
    
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   138
    this.$.find(".Ldt-Markers-Create").click(this.functionWrapper("onCreateClick"));
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   139
    this.$.find(".Ldt-Markers-Delete").click(this.functionWrapper("onDeleteClick"));
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   140
    this.$.find(".Ldt-Markers-RoundButton").hide()
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   141
    this.updateCreateButtonState(this.media.getCurrentTime())
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   142
    this.$.find(".Ldt-Markers-Screen-SubmitDelete").click(this.functionWrapper("sendDelete"));
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   143
    this.$.find(".Ldt-Markers-Screen-CancelDelete").click(function(){
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   144
        _this.showScreen("Main");
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   145
        _this.cancelEdit();
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
   146
    })
b06345320ffb Altered ldt_annotate serializer 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
    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
   148
    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
   149
        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
   150
        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
   151
        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
   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
    
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   154
    this.$.find(".Ldt-Markers-Close").click(this.functionWrapper("revertToMainScreen"));
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
   155
    
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   156
    this.onMediaEvent("timeupdate", this.functionWrapper("updatePosition"));
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   157
    this.onMediaEvent("timeupdate", this.functionWrapper("updateCreateButtonState"));
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   158
    this.onMediaEvent("play", this.functionWrapper("clearSelectedMarker"));
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
   159
    this.onMdpEvent("Markers.refresh", this.functionWrapper("drawMarkers"));
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   160
   
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   161
    this.newMarkerTimeCode = 0;
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
   162
    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
   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
b06345320ffb Altered ldt_annotate serializer 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
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
   167
    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
   168
    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
   169
        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
   170
    });
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   171
}
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
   172
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   173
IriSP.Widgets.Markers.prototype.updateCreateButtonState = function(_time){
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   174
    _this = this
1066
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   175
    var can_create = this.preview_mode? false : this.markers.every(function(_marker){   
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   176
        return ((_time < (_marker.begin-_this.markers_gap))||(_time > (_marker.begin+_this.markers_gap)))
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   177
    });
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   178
    if (can_create){
1066
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   179
        if ((this.$.find(".Ldt-Markers-Create").is(":hidden"))&&(this.$.find(".Ldt-Markers-Delete").is(":hidden")||this.$.find(".Ldt-Markers-PreviewDelete").is(":hidden"))){
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   180
            this.$.find(".Ldt-Markers-RoundButton").hide();
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   181
            this.$.find(".Ldt-Markers-Create").show();
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   182
        }
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   183
    }
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   184
    else {
1066
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   185
        if ((this.$.find(".Ldt-Markers-CannotCreate").is(":hidden"))&&(this.$.find(".Ldt-Markers-Delete").is(":hidden")||this.$.find(".Ldt-Markers-PreviewDelete").is(":hidden"))){
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   186
            this.$.find(".Ldt-Markers-RoundButton").hide();
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   187
            this.$.find(".Ldt-Markers-CannotCreate").show();
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   188
        }
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   189
    }
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   190
}
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
   191
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   192
IriSP.Widgets.Markers.prototype.onCreateClick = function(){
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   193
    this.pauseOnWrite();
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   194
    if (!this.selectedMarker){
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   195
        this.newMarkerCurrentTime = this.media.getCurrentTime();
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   196
        this.showPlaceholder(this.media.getCurrentTime());
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   197
        this.startEdit();
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   198
    }
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   199
}
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   200
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   201
IriSP.Widgets.Markers.prototype.onDeleteClick = function(){
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   202
    _this = this;
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   203
    this.pauseOnWrite();
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   204
    if(this.selectedMarker){
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   205
        this.showScreen("ConfirmDelete");
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   206
    }
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   207
    else {
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   208
        // Click on "x" without a selected marker: back to initial state
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   209
        this.cancelEdit();
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   210
    }
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   211
}
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   212
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   213
IriSP.Widgets.Markers.prototype.startEdit = function(){
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   214
    if (this.selectedMarker){
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   215
        _divHtml = Mustache.to_html(this.infoTemplate, {
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   216
            edit: true,
1066
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   217
            preview_mode: this.preview_mode,
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   218
            preview_mode_text: this.l10n.preview_mode_submit,
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   219
            marker_info: this.selectedMarker.description,
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   220
            send: this.custom_send_button? this.custom_send_button : this.l10n.send,
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   221
            cancel: this.custom_cancel_button? this.custom_cancel_button :this.l10n.cancel
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   222
        })
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
   223
    }
b06345320ffb Altered ldt_annotate serializer 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
    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
   225
        _divHtml = Mustache.to_html(this.infoTemplate, {
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   226
            edit: true,
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   227
            marker_info: "",
1066
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   228
            preview_mode: this.preview_mode,
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   229
            preview_mode_text: this.l10n.preview_mode_submit,
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   230
            send: this.custom_send_button? this.custom_send_button : this.l10n.send,
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   231
            cancel: this.custom_cancel_button? this.custom_cancel_button :this.l10n.cancel
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   232
        })
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   233
    }
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   234
    this.$.find(".Ldt-Markers-Info").html(_divHtml);
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   235
    this.$.find(".Ldt-Markers-MarkerSend").click(this.functionWrapper("onSubmit"));
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   236
    this.$.find(".Ldt-Markers-MarkerCancel").click(this.functionWrapper("cancelEdit"));
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   237
    this.$.find(".Ldt-Markers-MarkerTextArea").bind("change keyup input paste", this.functionWrapper("onDescriptionChange"));
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   238
    this.$.find(".Ldt-Markers-RoundButton").hide();
1066
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   239
    if (this.preview_mode){
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   240
        this.$.find(".Ldt-Markers-PreviewDelete").show(); 
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   241
    }
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   242
    else {
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   243
        this.$.find(".Ldt-Markers-Delete").show();
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   244
    }
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   245
    this.editing = true;
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   246
}
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   247
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   248
IriSP.Widgets.Markers.prototype.cancelEdit = function(){
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   249
    if (this.selectedMarker){
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   250
        // Click on "cancel" while editing a marker: back to visualization state
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   251
        _divHtml = Mustache.to_html(this.infoTemplate, {
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   252
            edit: false,
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
   253
            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
   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
        this.$.find(".Ldt-Markers-Info").html(_divHtml);
1066
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   256
        if (!this.preview_mode){
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   257
            this.$.find(".Ldt-Markers-MarkerDescription").click(this.functionWrapper("startEdit"));
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   258
        }
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
   259
    }
b06345320ffb Altered ldt_annotate serializer 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
    else {
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   261
        // Click on "cancel" while editing a marker: back to initial state
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   262
        this.hidePlaceholder();
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   263
        this.$.find(".Ldt-Markers-Info").html("");
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   264
        this.$.find(".Ldt-Markers-RoundButton").hide()
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   265
        this.$.find(".Ldt-Markers-Create").show()
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   266
        this.updateCreateButtonState(this.media.getCurrentTime())
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
   267
    }
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   268
    this.editing = false;
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   269
}
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
   270
b06345320ffb Altered ldt_annotate serializer 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
IriSP.Widgets.Markers.prototype.onDescriptionChange = function(){
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   272
    // Returns false if the textarea is empty, true if there is text in it
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   273
    if(!this.allow_empty_markers){
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   274
        var _field = this.$.find(".Ldt-Markers-MarkerTextArea"),
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   275
            _contents = _field.val();
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   276
        _field.css("border-color", !!_contents ? "#e87d9f" : "#ff0000");
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   277
        if (!!_contents) {
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   278
            _field.removeClass("empty");
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   279
        } else {
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   280
            _field.addClass("empty");
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   281
        }
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   282
        this.pauseOnWrite();
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   283
        return !!_contents;
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
   284
    }
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   285
    else {
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   286
        // If the widget is configured to allow to post empty markers, it returns true
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   287
        return true
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   288
    }
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
   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
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
   292
    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
   293
        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
   294
    }
b06345320ffb Altered ldt_annotate serializer 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
};
b06345320ffb Altered ldt_annotate serializer 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
b06345320ffb Altered ldt_annotate serializer 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
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
   298
    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
   299
        .siblings().hide();
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   300
}
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   301
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   302
IriSP.Widgets.Markers.prototype.revertToMainScreen = function(){
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   303
    if (this.$.find(".Ldt-Markers-ScreenMain").is(":hidden")){
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   304
        this.showScreen("Main");
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   305
        this.cancelEdit();
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   306
        if (this.selectedMarker){
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   307
            this.$.find(".Ldt-Markers-RoundButton").hide();
1066
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   308
            if (this.preview_mode){
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   309
                this.$.find(".Ldt-Markers-PreviewDelete").show(); 
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   310
            }
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   311
            else {
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   312
                this.$.find(".Ldt-Markers-Delete").show();
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   313
            }
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   314
        }
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   315
        else {
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   316
            this.$.find(".Ldt-Markers-RoundButton").hide();
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   317
            this.$.find(".Ldt-Markers-Create").show();
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   318
            this.updateCreateButtonState();
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   319
        }
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   320
    }
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   321
}
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   322
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   323
IriSP.Widgets.Markers.prototype.hidePlaceholder = function(){
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   324
    this.$.find(".Ldt-Markers-PlaceholderMarker").remove();
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   325
}
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   326
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   327
IriSP.Widgets.Markers.prototype.showPlaceholder = function(_time){   
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   328
    var _scale = this.width / this.source.getDuration(),
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   329
        _left = _time * _scale -1,
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   330
        _data = {
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   331
            left: _left,
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   332
            height: this.line_height-1,
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   333
            ball_top: (this.ball_radius*2 > this.line_height) ? 0 : ((this.line_height - this.ball_radius*2)/2)-1,
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   334
            ball_radius: (this.ball_radius*2 > this.line_height) ? this.line_height/2 : this.ball_radius,
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   335
            ball_diameter: (this.ball_radius*2 > this.line_height) ? this.line_height/2 : this.ball_radius*2,
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   336
            ball_left: -this.ball_radius,
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   337
            marker_color: this.placeholder_color
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   338
        },
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   339
        _html = Mustache.to_html(this.markerPlaceholderTemplate, _data),
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   340
        _el = IriSP.jQuery(_html);
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   341
        
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   342
    list_$ = this.$.find(".Ldt-Markers-List");
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   343
    _el.appendTo(list_$);
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   344
}
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   345
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   346
IriSP.Widgets.Markers.prototype.clearSelectedMarker = function(){
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   347
    if (this.selectedMarker){
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   348
        var _divHtml = "";
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   349
        
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   350
        this.selectedMarker = false;
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   351
        this.$.find(".Ldt-Markers-Info").html(_divHtml);
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   352
        this.$.find(".Ldt-Markers-RoundButton").hide();
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   353
        this.$.find(".Ldt-Markers-Create").show();
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   354
        this.$.find(".Ldt-Markers-MarkerBall").toggleClass("selected", false);
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   355
        this.updateCreateButtonState(this.media.getCurrentTime())
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   356
    }
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
   357
}
b06345320ffb Altered ldt_annotate serializer 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
b06345320ffb Altered ldt_annotate serializer 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
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
   360
    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
   361
        _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
   362
        list_$ = this.$.find('.Ldt-Markers-List');
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   363
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   364
    this.$.remove("Ldt-Markers-Marker");
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   365
    list_$.html("");
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
   366
    this.markers.forEach(function(_marker){
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   367
        var _left = _marker.begin * _scale -1,
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   368
            _data = {
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   369
                left: _left,
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   370
                height: _this.line_height-1,
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   371
                ball_top: (_this.ball_radius*2 > _this.line_height) ? 0 : ((_this.line_height - _this.ball_radius*2)/2)-1,
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   372
                ball_radius: (_this.ball_radius*2 > _this.line_height) ? _this.line_height/2 : _this.ball_radius,
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   373
                ball_diameter: (_this.ball_radius*2 > _this.line_height) ? _this.line_height/2 : _this.ball_radius*2,
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   374
                ball_left: -_this.ball_radius,
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   375
                marker_color: ((_this.selectedMarker)&&(_this.selectedMarker.id == _marker.id))? _this.selected_color : _this.marker_color
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   376
            },
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   377
            _html = Mustache.to_html(_this.markerTemplate, _data),
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   378
            _el = IriSP.jQuery(_html);
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   379
        
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   380
        if ((_this.selectedMarker)&&(_this.selectedMarker.id == _marker.id)){
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   381
            _el.children().toggleClass("selected", true);
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
   382
        }
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   383
        
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
   384
        _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
   385
                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
   386
                    _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
   387
                };
b06345320ffb Altered ldt_annotate serializer 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
            })
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   389
           .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
   390
              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
   391
                  _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
   392
              };
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   393
           })
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   394
           .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
   395
               _this.showScreen("Main");
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   396
               _this.cancelEdit();
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   397
               _this.hidePlaceholder();
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
   398
               if (!((_this.selectedMarker)&&(_this.selectedMarker.id == _marker.id))){
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   399
                  // if there either is no marker selected or we click a different marker
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
   400
                  list_$.find(".Ldt-Markers-MarkerBall").css("background-color", _this.marker_color)
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   401
                  list_$.find(".Ldt-Markers-MarkerBall").toggleClass("selected", false);
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   402
                  _el.children().toggleClass("selected", true);
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
   403
                  _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
   404
                  _this.selectedMarker = _marker;
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   405
                  
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
   406
                  _divHtml = Mustache.to_html(_this.infoTemplate, {
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   407
                      edit: false,
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
   408
                      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
   409
                  })
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   410
                  
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   411
                  _this.$.find(".Ldt-Markers-Info").html(_divHtml);
1066
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   412
                  if (!_this.preview_mode){
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   413
                      _this.$.find(".Ldt-Markers-MarkerDescription").click(_this.functionWrapper("startEdit"));
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   414
                  }
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   415
                  _this.$.find(".Ldt-Markers-RoundButton").hide();
1066
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   416
                  if (_this.preview_mode){
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   417
                      _this.$.find(".Ldt-Markers-PreviewDelete").show(); 
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   418
                  }
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   419
                  else {
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   420
                      _this.$.find(".Ldt-Markers-Delete").show();
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   421
                  }
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
   422
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   423
               }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   424
               else {
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   425
                   // if we click the currently selected marker, we unselect it
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
   426
                   _el.children().css("background-color", _this.hover_color);
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   427
                   _this.clearSelectedMarker();
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
   428
               }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   429
               
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   430
               if (_this.selectedMarker) {
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   431
                   // Only if we select a new marker do we pause video and time jump
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
   432
                   _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
   433
                   _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
   434
               }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   435
           })
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   436
           .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
   437
    })
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   438
}
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   439
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   440
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
   441
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
   442
    
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   443
    /* If mandatory fields are empty, we cancel the sending */
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   444
    if (!this.allow_empty_markers && !this.onDescriptionChange()){
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
   445
        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
   446
    }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   447
    
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   448
    /* We pause the video if it's still playing */
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
   449
    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
   450
        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
   451
    }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   452
    
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   453
    var _this = this,
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   454
        _exportedAnnotations = new IriSP.Model.List(this.player.sourceManager), /* We create a List to send to the server that will contains the annotation */
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   455
        _export = this.player.sourceManager.newLocalSource({serializer: IriSP.serializers[this.api_serializer]}), /* We create a source object using a specific serializer for export */
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   456
        _annotationTypes = this.source.getAnnotationTypes().searchByTitle(this.annotation_type, true), /* We get the AnnotationType in which the annotation will be added */
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   457
        _annotationType = (_annotationTypes.length ? _annotationTypes[0] : new IriSP.Model.AnnotationType(false, _export)); /* If it doesn't already exists, we create it */
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
   458
    if (this.selectedMarker){
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   459
        var _annotation = this.selectedMarker,
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   460
            _url = Mustache.to_html(this.api_endpoint_template_edit, {annotation_id: this.selectedMarker ? this.selectedMarker.id : ""});
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
   461
        _annotation.source = _export
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   462
        _annotation.description = this.$.find(".Ldt-Markers-MarkerTextArea").val(), /* Description field */
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
   463
    }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   464
    else {
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   465
        var _annotation = new IriSP.Model.Annotation(false, _export),
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   466
            _url = Mustache.to_html(this.api_endpoint_template_create);
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   467
        
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   468
        /* If we created an AnnotationType on the spot ... */
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
   469
        if (!_annotationTypes.length) {
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   470
            /* ... We must not send its id to the server ... */
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
   471
            _annotationType.dont_send_id = true;
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   472
            /* ... And we must include its title. */
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
   473
            _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
   474
        }
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   475
        
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   476
        _annotation.setMedia(this.source.currentMedia.id); /* Annotated media ID */
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   477
        if (!this.selectedMarker){
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   478
            _annotation.setBegin(this.newMarkerCurrentTime);
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   479
            _annotation.setEnd(this.newMarkerCurrentTime);
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   480
        }
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   481
        _annotation.setAnnotationType(_annotationType.id); /* AnnotationType ID */
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
   482
        if (this.project_id != ""){
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   483
            /* Project id, only if it's been specifiec in the config */
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
   484
            _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
   485
        }
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   486
        _annotation.created = new Date(); /* Creation date */
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   487
        _annotation.description = this.$.find(".Ldt-Markers-MarkerTextArea").val(); /* Description field */
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
   488
        _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
   489
    }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   490
    _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
   491
    
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   492
    _exportedAnnotations.push(_annotation); /* We add the annotation in the list to export */
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   493
    _export.addList("annotation",_exportedAnnotations); /* We add the list to the source object */ 
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
   494
    
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   495
    /* We send the AJAX request to the server ! */
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
   496
    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
   497
        url: _url,
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   498
        type: this.selectedMarker ? this.api_method_edit : this.api_method_create,
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
   499
        contentType: 'application/json',
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   500
        data: _export.serialize(),
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
   501
        success: function(_data) {
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   502
            _this.showScreen('Success');
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   503
            window.setTimeout(_this.functionWrapper("revertToMainScreen"),(_this.after_send_timeout || 5000));
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   504
            _export.getAnnotations().removeElement(_annotation, true); /* We delete the sent annotation to avoid redundancy */
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   505
            _export.deSerialize(_data); /* Data deserialization */
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   506
            _annotation.id = _data.id;
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   507
            _this.source.merge(_export); /* We merge the deserialized data with the current source data */
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   508
            if (_this.pause_on_write && _this.media.getPaused() && _this.play_on_submit) {
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
   509
                _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
   510
            }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   511
            _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
   512
            _this.selectedMarker = _annotation;
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   513
            _this.drawMarkers();
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   514
            _this.player.trigger("AnnotationsList.refresh");
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
   515
            _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
   516
        },
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   517
        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
   518
            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
   519
            _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
   520
            _this.showScreen('Failure');
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   521
            window.setTimeout(_this.functionWrapper("revertToMainScreen"),(_this.after_send_timeout || 5000));
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
   522
        }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   523
    });
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   524
    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
   525
    
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   526
    return false;
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   527
};
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   528
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   529
IriSP.Widgets.Markers.prototype.sendDelete = function(){
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   530
    _this = this;
1059
8158421193e3 Fixed user filter on AnnotationList to not display username in the dropdown but what is displayed in the list + Added project_id to api templates for delete in case the target API understands it
durandn
parents: 1051
diff changeset
   531
    _url = Mustache.to_html(this.api_endpoint_template_delete, {annotation_id: this.selectedMarker ? this.selectedMarker.id : "", project_id: this.selectedMarker.project_id? this.selectedMarker.project_id : this.project_id});
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   532
    IriSP.jQuery.ajax({
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   533
        url: _url,
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   534
        type: this.api_method_delete,
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   535
        contentType: 'application/json',
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   536
        success: function(_data) {
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   537
            _this.showScreen('DeleteSuccess');
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   538
            window.setTimeout(_this.functionWrapper("revertToMainScreen"),(_this.after_send_timeout || 5000));
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   539
            if (_this.pause_on_write && _this.media.getPaused() && _this.play_on_submit) {
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   540
                _this.media.play();
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   541
            }
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   542
            _this.markers.removeElement(_this.selectedMarker);
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   543
            _this.selectedMarker = false
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   544
            _this.player.trigger("AnnotationsList.refresh");
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   545
            _this.player.trigger("Markers.refresh");
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   546
        },
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   547
        error: function(_xhr, _error, _thrown) {
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   548
            IriSP.log("Error when sending annotation", _thrown);
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   549
            _this.showScreen('Failure');
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   550
            window.setTimeout(_this.functionWrapper("revertToMainScreen"),(_this.after_send_timeout || 5000));
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   551
        }
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   552
    });
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   553
    this.showScreen("Sending")
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   554
}