src/widgets/Markers.js
author durandn
Fri, 18 Sep 2015 14:41:51 +0200
changeset 1051 3820cf5fe29e
parent 1045 b06345320ffb
child 1059 8158421193e3
permissions -rw-r--r--
Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
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,
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
    34
};
b06345320ffb Altered ldt_annotate serializer 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
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
    37
    '<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
    38
    +     '<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
    39
    +     '<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
    40
    + '</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 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
    42
    +     '<div class="Ldt-Markers-Screen Ldt-Markers-ScreenMain">'
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
    43
    +         '<div class="Ldt-Markers-RoundButton Ldt-Markers-CannotCreate" title="{{l10n.cannot_create}}">+</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
    44
    +         '<div class="Ldt-Markers-RoundButton Ldt-Markers-Create">+</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
    45
    +         '<div class="Ldt-Markers-RoundButton Ldt-Markers-Delete">&#10006;</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
    46
    +         '<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
    47
    +     '</div>'
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    48
    +     '<div 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
    49
    +         '<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
    50
    +     '</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
    51
    +     '<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
    52
    +         '<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
    53
    +         '<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
    54
    +     '</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
    55
    +     '<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
    56
    +         '<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
    57
    +         '<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
    58
    +     '</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
    59
    +     '<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
    60
    +         '<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
    61
    +         '<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
    62
    +     '</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
    63
    +     '<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
    64
    +         '<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
    65
    +         '<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
    66
    +           '{{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
    67
    +           '<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
    68
    +           '<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
    69
    +         '</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
    70
    +     '</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
    71
    + '</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
    72
b06345320ffb Altered ldt_annotate serializer 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
b06345320ffb Altered ldt_annotate serializer 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
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
    75
    '<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
    76
        '<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
    77
    '</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
    78
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" 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
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
    80
    '<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
    81
        '<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
    82
    '</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
    83
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    84
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
    85
    '{{^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
    86
    '{{#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
    87
        '<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
    88
        '<div class="Ldt-Markers-Buttons">' +
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    89
            '<div class="Ldt-Markers-MarkerSend">{{send}}</div>' +
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    90
            '<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
    91
        '</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
    92
    '</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
    93
b06345320ffb Altered ldt_annotate serializer 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
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
    95
    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
    96
        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
    97
        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
    98
        cancel : "Cancel",
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
    99
        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
   100
        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
   101
        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
   102
        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
   103
        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
   104
        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
   105
        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
   106
    },
b06345320ffb Altered ldt_annotate serializer 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
    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
   108
        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
   109
        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
   110
        cancel : "Annuler",
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   111
        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
   112
        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
   113
        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
   114
        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
   115
        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
   116
        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
   117
        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
   118
    }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   119
}
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   120
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   121
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
   122
    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
   123
    
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   124
    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
   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
    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
   127
        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
   128
    });
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   129
    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
   130
    
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
   131
    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
   132
    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
   133
    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
   134
    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
   135
    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
   136
    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
   137
        _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
   138
        _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
   139
    })
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   140
    this.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
   141
    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
   142
        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
   143
        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
   144
        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
   145
    });
b06345320ffb Altered ldt_annotate serializer 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
    
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
   147
    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
   148
    
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
   149
    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
   150
    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
   151
    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
   152
    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
   153
   
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" 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.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
   155
    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
   156
}
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   157
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   158
b06345320ffb Altered ldt_annotate serializer 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
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
   160
    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
   161
    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
   162
        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
   163
    });
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
   164
}
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
   165
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
   166
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
   167
    _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
   168
    var can_create = this.markers.every(function(_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
   169
        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
   170
    });
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" 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
    if (can_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
   172
        if ((this.$.find(".Ldt-Markers-Create").is(":hidden"))&&(this.$.find(".Ldt-Markers-Delete").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
   173
            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
   174
            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
   175
        }
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" 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
    }
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" 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
    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
   178
        if ((this.$.find(".Ldt-Markers-CannotCreate").is(":hidden"))&&(this.$.find(".Ldt-Markers-Delete").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
   179
            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
   180
            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
   181
        }
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" 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
}
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
   184
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
   185
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
   186
    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
   187
    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
   188
        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
   189
        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
   190
        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
   191
    }
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" 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
}
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" 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
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" 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
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
   195
    _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
   196
    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
   197
    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
   198
        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
   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
    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
   201
        // Clic sur - sans marqueur sélectionné = retour à l'état initial
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" 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.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
   203
    }
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" 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
}
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" 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
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" 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
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
   207
    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
   208
        _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
   209
            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
   210
            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
   211
            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
   212
            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
   213
        })
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
   214
    }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   215
    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
   216
        _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
   217
            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
   218
            marker_info: "",
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" 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
            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
   220
            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
   221
        })
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" 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
    }
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   223
    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
   224
    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
   225
    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
   226
    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
   227
    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
   228
    this.$.find(".Ldt-Markers-Delete").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
   229
    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
   230
}
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" 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
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" 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
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
   233
    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
   234
        // Clic sur "cancel" pendant édition d'un marqueur = retour à l'état visualisation
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" 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
        _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
   236
            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
   237
            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
   238
        })
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   239
        this.$.find(".Ldt-Markers-Info").html(_divHtml);
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
   240
        this.$.find(".Ldt-Markers-MarkerDescription").click(this.functionWrapper("startEdit"));
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
   241
    }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   242
    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
   243
        // Clic sur "cancel" pendant la création d'un marqueur = retour à l'état initial
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   244
        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
   245
        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
   246
        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
   247
        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
   248
        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
   249
    }
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
   250
    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
   251
}
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
   252
b06345320ffb Altered ldt_annotate serializer 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
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
   254
    // 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
   255
    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
   256
        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
   257
            _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
   258
        _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
   259
        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
   260
            _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
   261
        } 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
   262
            _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
   263
        }
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" 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.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
   265
        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
   266
    }
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
   267
    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
   268
        // 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
   269
        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
   270
    }
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
   271
};
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   272
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   273
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
   274
    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
   275
        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
   276
    }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   277
};
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   278
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   279
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
   280
    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
   281
        .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
   282
}
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" 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
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   284
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
   285
    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
   286
        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
   287
        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
   288
        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
   289
            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
   290
            this.$.find(".Ldt-Markers-Delete").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
   291
        }
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   292
        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
   293
            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
   294
            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
   295
            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
   296
        }
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   297
    }
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   298
}
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   299
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" 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
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
   301
    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
   302
}
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" 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
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" 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
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
   305
    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
   306
        _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
   307
        _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
   308
            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
   309
            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
   310
            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
   311
            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
   312
            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
   313
            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
   314
            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
   315
        },
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" 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
        _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
   317
        _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
   318
        
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" 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
    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
   320
    _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
   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.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
   324
    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
   325
        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
   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
        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
   328
        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
   329
        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
   330
        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
   331
        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
   332
        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
   333
    }
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
   334
}
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   335
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   336
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
   337
    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
   338
        _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
   339
        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
   340
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" 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
    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
   342
    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
   343
    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
   344
        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
   345
            _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
   346
                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
   347
                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
   348
                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
   349
                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
   350
                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
   351
                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
   352
                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
   353
            },
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" 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
            _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
   355
            _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
   356
        
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   357
        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
   358
            _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
   359
        }
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
   360
        
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
   361
        _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
   362
                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
   363
                    _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
   364
                };
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   365
            })
b06345320ffb Altered ldt_annotate serializer 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
           .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
   367
              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
   368
                  _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
   369
              };
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   370
           })
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   371
           .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
   372
               _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
   373
               _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
   374
               _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
   375
               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
   376
                  // 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
   377
                  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
   378
                  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
   379
                  _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
   380
                  _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
   381
                  _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
   382
                  
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
   383
                  _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
   384
                      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
   385
                      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
   386
                  })
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   387
                  
b06345320ffb Altered ldt_annotate serializer 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
                  _this.$.find(".Ldt-Markers-Info").html(_divHtml);
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
   389
                  _this.$.find(".Ldt-Markers-MarkerDescription").click(_this.functionWrapper("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
   390
                  _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
   391
                  _this.$.find(".Ldt-Markers-Delete").show();
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
   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
               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
   395
                   // 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
   396
                   _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
   397
                   _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
   398
               }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   399
               
b06345320ffb Altered ldt_annotate serializer 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
               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
   401
                   // 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
   402
                   _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
   403
                   _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
   404
               }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   405
           })
b06345320ffb Altered ldt_annotate serializer 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
           .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
   407
    })
b06345320ffb Altered ldt_annotate serializer 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
}
b06345320ffb Altered ldt_annotate serializer 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
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
   410
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
   411
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
   412
    
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   413
    /* Si les champs obligatoires sont vides, on annule l'envoi */
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
   414
    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
   415
        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
   416
    }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   417
    
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   418
    /* On pause la vidéo si elle est encore en train de tourner */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   419
    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
   420
        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
   421
    }
b06345320ffb Altered ldt_annotate serializer 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
    var _this = this,
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
   424
        _exportedAnnotations = new IriSP.Model.List(this.player.sourceManager); /* Création d'une liste d'annotations contenant une annotation afin de l'envoyer au serveur */        
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
   425
    if (this.selectedMarker){
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   426
        var _export = this.player.sourceManager.newLocalSource({serializer: IriSP.serializers[this.api_serializer]})
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
            _annotation = 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
   428
            _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
   429
        _annotation.source = _export
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   430
        _annotation.description = this.$.find(".Ldt-Markers-MarkerTextArea").val(), /* Champ description */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   431
        _annotationTypes = this.source.getAnnotationTypes().searchByTitle(this.annotation_type, true), /* Récupération du type d'annotation dans lequel l'annotation doit être ajoutée */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   432
        _annotationType = (_annotationTypes.length ? _annotationTypes[0] : new IriSP.Model.AnnotationType(false, _export)); /* Si le Type d'Annotation n'existe pas, il est créé à la volée */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   433
    }
b06345320ffb Altered ldt_annotate serializer 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
    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
   435
        var _export = this.player.sourceManager.newLocalSource({serializer: IriSP.serializers[this.api_serializer]}), /* Création d'un objet source utilisant un sérialiseur spécifique pour l'export */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   436
            _annotation = new IriSP.Model.Annotation(false, _export); /* Création d'une annotation dans cette source avec un ID généré à la volée (param. false) */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   437
            _annotationTypes = this.source.getAnnotationTypes().searchByTitle(this.annotation_type, true), /* Récupération du type d'annotation dans lequel l'annotation doit être ajouté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
   438
            _annotationType = (_annotationTypes.length ? _annotationTypes[0] : new IriSP.Model.AnnotationType(false, _export)), /* Si le Type d'Annotation n'existe pas, il est créé à la volée */
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   439
            _url = Mustache.to_html(this.api_endpoint_template_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
   440
        /* Si nous avons dû générer un ID d'annotationType à la volée... */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   441
        if (!_annotationTypes.length) {
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   442
            /* Il ne faudra pas envoyer l'ID généré au serveur */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   443
            _annotationType.dont_send_id = true;
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   444
            /* Il faut inclure le titre dans le type d'annotation */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   445
            _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
   446
        }
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
   447
        
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
   448
        _annotation.setMedia(this.source.currentMedia.id); /* Id du média annoté */
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
   449
        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
   450
            _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
   451
            _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
   452
        }
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
   453
        _annotation.setAnnotationType(_annotationType.id); /* Id du type d'annotation */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   454
        if (this.project_id != ""){
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   455
            /* Champ id projet, seulement si on l'a renseigné dans la config */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   456
            _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
   457
        }
b06345320ffb Altered ldt_annotate serializer 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
        _annotation.created = new Date(); /* Date de création de l'annotation */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   459
        _annotation.description = this.$.find(".Ldt-Markers-MarkerTextArea").val(); /* Champ description */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   460
        _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
   461
    }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   462
    _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
   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
    /*
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   465
     * Nous remplissons les données de l'annotation générée à la volée
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   466
     * ATTENTION: Si nous sommes sur un MASHUP, ces éléments doivent se référer AU MEDIA D'ORIGINE
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   467
     * */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   468
    
b06345320ffb Altered ldt_annotate serializer 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
    _exportedAnnotations.push(_annotation); /* Ajout de l'annotation à la liste à exporter */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   470
    _export.addList("annotation",_exportedAnnotations); /* Ajout de la liste à exporter à l'objet Source */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   471
    
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   472
    /* Envoi de l'annotation via AJAX au serveur ! */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   473
    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
   474
        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
   475
        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
   476
        contentType: 'application/json',
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   477
        data: _export.serialize(), /* L'objet Source est sérialisé */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   478
        success: function(_data) {
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   479
            _this.showScreen('Success'); /* Si l'appel a fonctionné, on affiche l'écran "Annotation 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
   480
            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
   481
            _export.getAnnotations().removeElement(_annotation, true); /* Pour éviter les doublons, on supprime l'annotation qui a été envoyée */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   482
            _export.deSerialize(_data); /* On désérialise les données reçues pour les réinjecter */
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
   483
            _annotation.id = _data.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
   484
            _this.source.merge(_export); /* On récupère les données réimportées dans l'espace global des données */
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
   485
            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
   486
                _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
   487
            }
b06345320ffb Altered ldt_annotate serializer 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
            _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
   489
            _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
   490
            _this.drawMarkers();
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
   491
            _this.player.trigger("AnnotationsList.refresh"); /* On force le rafraîchissement du widget AnnotationsList */
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   492
            _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
   493
        },
b06345320ffb Altered ldt_annotate serializer 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
        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
   495
            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
   496
            _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
   497
            _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
   498
            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
   499
        }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   500
    });
b06345320ffb Altered ldt_annotate serializer 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
    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
   502
    
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   503
    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
   504
};
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   505
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" 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
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
   507
    _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
   508
    _url = Mustache.to_html(this.api_endpoint_template_delete, {annotation_id: this.selectedMarker ? this.selectedMarker.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
   509
    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
   510
        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
   511
        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
   512
        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
   513
        success: function(_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
   514
            _this.showScreen('DeleteSuccess'); /* Si l'appel a fonctionné, on affiche l'écran "Annotation enregistrée" */
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   515
            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
   516
            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
   517
                _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
   518
            }
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   519
            _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
   520
            _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
   521
            _this.player.trigger("AnnotationsList.refresh"); /* On force le rafraîchissement du widget AnnotationsList */
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   522
            _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
   523
        },
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   524
        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
   525
            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
   526
            _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
   527
            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
   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
    });
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" 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.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
   531
}