src/widgets/Markers.js
author ymh <ymh.work@gmail.com>
Tue, 22 Oct 2024 07:03:54 +0200
changeset 1076 510fd2a482f4
parent 1072 ac1eacb3aa33
permissions -rw-r--r--
Add Dailymotion Tech and remove unused libs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
     1
import Mustache from "mustache";
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
     2
import jQuery from "jquery";
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
     3
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
     4
import markersStyles from "./Markers.module.css";
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
     5
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
     6
const Markers = function (ns) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
     7
  return class extends ns.Widgets.Widget {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
     8
    constructor(player, config) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
     9
      super(player, config);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    10
    }
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
    11
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    12
    static defaults = {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    13
      pre_draw_callback: function () {
1069
2409cb4cebaf getting various changes from github
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
    14
        return this.importUsers();
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    15
      },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    16
      annotation_type: "markers",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    17
      line_height: 8,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    18
      background: "#e0e0e0",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    19
      marker_color: "#ff80fc",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    20
      placeholder_color: "#ffffff",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    21
      hover_color: "#e15581",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    22
      selected_color: "#74d600",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    23
      ball_radius: 4,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    24
      pause_on_write: true,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    25
      play_on_submit: true,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    26
      api_serializer: "ldt_annotate",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    27
      api_endpoint_template_create: "",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    28
      api_endpoint_template_edit: "",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    29
      api_endpoint_template_delete: "",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    30
      api_method_create: "POST",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    31
      api_method_edit: "PUT",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    32
      api_method_delete: "DELETE",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    33
      project_id: "",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    34
      creator_name: "",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    35
      after_send_timeout: 0,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    36
      markers_gap: 2000,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    37
      allow_empty_markers: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    38
      close_after_send: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    39
      custom_send_button: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    40
      custom_cancel_button: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    41
      preview_mode: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    42
      filter_per_user: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    43
      api_users_endpoint: "",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    44
      make_username_string_function: function (params) {
1069
2409cb4cebaf getting various changes from github
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
    45
        return params.username ? params.username : "Anonymous";
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    46
      },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    47
      hide_if_empty: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    48
    };
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
    49
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    50
    static template =
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    51
      '<div class="Ldt-Markers-Display" style="height:{{line_height}}px;">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    52
      '<div class="Ldt-Markers-List" style="height:{{line_height}}px; position: relative;"></div>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    53
      '<div class="Ldt-Markers-Position" style="height: {{line_height}}px; top: -{{line_height}};"></div>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    54
      "</div>" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    55
      '<div class="Ldt-Markers-Inputs">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    56
      '<div class="Ldt-Markers-Screen Ldt-Markers-ScreenMain">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    57
      '<div class="Ldt-Markers-RoundButton Ldt-Markers-CannotCreate" title="{{#preview_mode}}{{l10n.preview_mode_submit}}{{/preview_mode}}{{^preview_mode}}{{l10n.cannot_create}}{{/preview_mode}}">+</div>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    58
      '<div class="Ldt-Markers-RoundButton Ldt-Markers-Create">+</div>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    59
      '{{^preview_mode}}<div class="Ldt-Markers-RoundButton Ldt-Markers-Delete">&#10006;</div>{{/preview_mode}}' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    60
      '{{#preview_mode}}<div class="Ldt-Markers-RoundButton Ldt-Markers-PreviewDelete" title="{{l10n.preview_mode_delete}}">&#10006;</div>{{/preview_mode}}' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    61
      '{{#filter_per_user}}{{#preview_mode}}<select class="Ldt-Markers-userFilter-dropdown" id="Ldt-Markers-userFilter"></select>{{/preview_mode}}{{/filter_per_user}}' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    62
      '<div class="Ldt-Markers-Info"></div>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    63
      "</div>" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    64
      '<div class="Ldt-Markers-Screen Ldt-Markers-ScreenSending">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    65
      '<div class="Ldt-Markers-Screen-InnerBox">{{l10n.wait_while_processing}}</div>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    66
      "</div>" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    67
      '<div class="Ldt-Markers-Screen Ldt-Markers-ScreenSuccess">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    68
      '<a title="{{l10n.close_widget}}" class="Ldt-Markers-Close" href="#"></a>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    69
      '<div class="Ldt-Markers-Screen-InnerBox">{{l10n.annotation_saved}}</div>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    70
      "</div>" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    71
      '<div class="Ldt-Markers-Screen Ldt-Markers-ScreenDeleteSuccess">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    72
      '<a title="{{l10n.close_widget}}" class="Ldt-Markers-Close" href="#"></a>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    73
      '<div class="Ldt-Markers-Screen-InnerBox">{{l10n.delete_saved}}</div>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    74
      "</div>" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    75
      '<div class="Ldt-Markers-Screen Ldt-Markers-ScreenFailure">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    76
      '<a title="{{l10n.close_widget}}" class="Ldt-Markers-Close" href="#"></a>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    77
      '<div class="Ldt-Markers-Screen-InnerBox">{{l10n.error_while_contacting}}</div>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    78
      "</div>" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    79
      '<div class="Ldt-Markers-Screen Ldt-Markers-ScreenConfirmDelete">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    80
      '<a title="{{l10n.close_widget}}" class="Ldt-Markers-Close" href="#"></a>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    81
      '<div class="Ldt-Markers-Screen-InnerBox">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    82
      "{{l10n.delete_text}} " +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    83
      '<a class="Ldt-Markers-Screen-SubmitDelete">{{l10n.submit_delete}}</a> ' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    84
      '<a class="Ldt-Markers-Screen-CancelDelete">{{l10n.cancel}}</a>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    85
      "</div>" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    86
      "</div>" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    87
      "</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
    88
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    89
    static markerTemplate =
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    90
      '<div class="Ldt-Markers-Marker" style="height:{{height}}px; left:{{left}}px; width: 2px; background-color: black;">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    91
      '<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>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    92
      "</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
    93
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    94
    static markerPlaceholderTemplate =
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    95
      '<div class="Ldt-Markers-Marker Ldt-Markers-PlaceholderMarker" style="height:{{height}}px; left:{{left}}px; width: 2px; background-color: black;">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    96
      '<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>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    97
      "</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
    98
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    99
    static infoTemplate =
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   100
      '{{^edit}}<div class="Ldt-Markers-MarkerDescription">{{marker_info}}</div>{{/edit}}' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   101
      '{{#edit}}<div class="Ldt-Markers-MarkerEdit">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   102
      '<textarea class="Ldt-Markers-MarkerTextArea" cols="60" rows="4">{{marker_info}}</textarea>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   103
      '<div class="Ldt-Markers-Buttons">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   104
      '{{^preview_mode}}<div class="Ldt-Markers-MarkerSend">{{send}}</div>{{/preview_mode}}' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   105
      '{{#preview_mode}}<div class="Ldt-Markers-MarkerPreviewSend" title="{{preview_mode_text}}">{{send}}</div>{{/preview_mode}}' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   106
      '<div class="Ldt-Markers-MarkerCancel">{{cancel}}</div>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   107
      "</div>" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   108
      "</div>{{/edit}}";
1045
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   109
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   110
    static messages =  {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   111
      en: {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   112
        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
   113
        submit_delete: "Delete",
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   114
        cancel: "Cancel",
1066
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   115
        preview_mode_submit: "You cannot submit a marker in preview mode.",
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   116
        preview_mode_delete: "You cannot delete a marker in preview mode",
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   117
        wait_while_processing:
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   118
          "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
   119
        delete_text: "The selected marker will be deleted. Continue?",
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   120
        error_while_contacting:
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   121
          "An error happened while contacting the server. Your annotation has not been saved.",
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
   122
        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
   123
        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
   124
        close_widget: "Close",
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   125
        cannot_create: "Cannot create marker on this timecode",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   126
      },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   127
      fr: {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   128
        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
   129
        submit_delete: "Supprimer",
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   130
        cancel: "Annuler",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   131
        preview_mode_submit:
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   132
          "Vous ne pouvez pas créer ou éditer de marqueur en mode aperçu",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   133
        preview_mode_delete:
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   134
          "Vous ne pouvez pas supprimer de marqueur en mode aperçu",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   135
        wait_while_processing:
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   136
          "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
   137
        delete_text: "Le marqueur sélectionné sera supprimé. Continuer?",
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   138
        error_while_contacting:
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   139
          "Une erreur s'est produite en contactant le serveur. Votre annotation n'a pas été enregistré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
   140
        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
   141
        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
   142
        close_widget: "Fermer",
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   143
        cannot_create: "Impossible de créer un marqueur sur ce timecode",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   144
      },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   145
    };
1045
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   146
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   147
    importUsers() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   148
      if (this.filter_per_user && this.preview_mode) {
1069
2409cb4cebaf getting various changes from github
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   149
        this.usernames = Array();
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   150
        if (!this.source.users_data && this.api_users_endpoint) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   151
          var _this = this,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   152
            _list = this.getWidgetAnnotations(),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   153
            usernames_list_string = "";
1069
2409cb4cebaf getting various changes from github
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   154
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   155
          _list.forEach(function (_annotation) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   156
            if (_this.usernames.indexOf(_annotation.creator) == -1) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   157
              _this.usernames.push(_annotation.creator);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   158
            }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   159
          });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   160
          this.usernames.forEach(function (_username) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   161
            usernames_list_string += _username + ",";
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   162
          });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   163
          usernames_list_string = usernames_list_string.substring(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   164
            0,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   165
            usernames_list_string.length - 1
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   166
          );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   167
          _url = Mustache.render(this.api_users_endpoint, {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   168
            usernames_list_string: encodeURIComponent(usernames_list_string),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   169
            usernames_list_length: this.usernames.length,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   170
          });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   171
          return jQuery.ajax({
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   172
            async: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   173
            url: _url,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   174
            type: "GET",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   175
            success: function (_data) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   176
              _this.source.users_data = _data.objects;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   177
            },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   178
            error: function (_xhr, _error, _thrown) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   179
              console.log(_xhr);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   180
              console.log(_error);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   181
              console.log(_thrown);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   182
            },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   183
          });
1069
2409cb4cebaf getting various changes from github
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   184
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   185
      }
1069
2409cb4cebaf getting various changes from github
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   186
    }
2409cb4cebaf getting various changes from github
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   187
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   188
    draw() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   189
      var _this = this;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   190
      this.renderTemplate();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   191
      if (
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   192
        !this.filter_per_user ||
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   193
        !this.preview_mode ||
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   194
        this.usernames.length <= 1
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   195
      ) {
1069
2409cb4cebaf getting various changes from github
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   196
        this.$.find(".Ldt-Markers-userFilter-dropdown").hide();
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   197
      } else {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   198
        this.usernames.forEach(function (_user) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   199
          var _users = _this.source.users_data.filter(function (_user_data) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   200
              return _user_data.username == _user;
1069
2409cb4cebaf getting various changes from github
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   201
            }),
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   202
            _user_data = {};
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   203
          if (_users.length == 0) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   204
            _user_data.username = _user;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   205
          } else {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   206
            _user_data = _users[0];
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   207
          }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   208
          _this.$.find(".Ldt-Markers-userFilter-dropdown").append(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   209
            "<option value='" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   210
              _user +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   211
              "'>" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   212
              _this.make_name_string_function(_user_data) +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   213
              "</option>"
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   214
          );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   215
        });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   216
        this.$.find(".Ldt-Markers-userFilter-dropdown").change(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   217
          this.functionWrapper("drawMarkers")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   218
        );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   219
        this.$.find(".Ldt-Markers-userFilter-dropdown").change(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   220
          this.functionWrapper("clearSelectedMarker")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   221
        );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   222
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   223
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   224
      this.markers = this.getWidgetAnnotations().filter(function (_ann) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   225
        return _ann.getDuration() == 0 || _ann.begin == _ann.end;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   226
      });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   227
      if (this.hide_if_empty && this.markers.length <= 0) {
1069
2409cb4cebaf getting various changes from github
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   228
        this.$.hide();
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   229
      } else {
1069
2409cb4cebaf getting various changes from github
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   230
        this.drawMarkers();
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   231
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   232
        this.$.find(".Ldt-Markers-Create").click(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   233
          this.functionWrapper("onCreateClick")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   234
        );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   235
        this.$.find(".Ldt-Markers-Delete").click(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   236
          this.functionWrapper("onDeleteClick")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   237
        );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   238
        this.$.find(".Ldt-Markers-RoundButton").hide();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   239
        this.updateCreateButtonState(this.media.getCurrentTime());
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   240
        this.$.find(".Ldt-Markers-Screen-SubmitDelete").click(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   241
          this.functionWrapper("sendDelete")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   242
        );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   243
        this.$.find(".Ldt-Markers-Screen-CancelDelete").click(function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   244
          _this.showScreen("Main");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   245
          _this.cancelEdit();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   246
        });
1069
2409cb4cebaf getting various changes from github
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   247
        this.showScreen("Main");
2409cb4cebaf getting various changes from github
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   248
        this.$.css({
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   249
          margin: "1px 0",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   250
          background: this.background,
1069
2409cb4cebaf getting various changes from github
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   251
        });
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   252
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   253
        this.$.find(".Ldt-Markers-Close").click(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   254
          this.functionWrapper("revertToMainScreen")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   255
        );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   256
1069
2409cb4cebaf getting various changes from github
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   257
        this.onMediaEvent("timeupdate", this.functionWrapper("updatePosition"));
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   258
        this.onMediaEvent(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   259
          "timeupdate",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   260
          this.functionWrapper("updateCreateButtonState")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   261
        );
1069
2409cb4cebaf getting various changes from github
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   262
        this.onMediaEvent("play", this.functionWrapper("clearSelectedMarker"));
2409cb4cebaf getting various changes from github
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   263
        this.onMdpEvent("Markers.refresh", this.functionWrapper("drawMarkers"));
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   264
1069
2409cb4cebaf getting various changes from github
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   265
        this.newMarkerTimeCode = 0;
2409cb4cebaf getting various changes from github
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   266
        this.selectedMarker = false;
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   267
      }
1069
2409cb4cebaf getting various changes from github
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   268
    }
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
   269
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   270
    updatePosition(_time) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   271
      var _x = Math.floor((this.width * _time) / this.media.duration);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   272
      this.$.find(".Ldt-Markers-Position").css({
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   273
        left: _x + "px",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   274
      });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   275
    }
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
   276
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   277
    updateCreateButtonState(_time) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   278
      _this = this;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   279
      var can_create = this.preview_mode
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   280
        ? false
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   281
        : this.markers.every(function (_marker) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   282
            return (
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   283
              _time < _marker.begin - _this.markers_gap ||
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   284
              _time > _marker.begin + _this.markers_gap
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   285
            );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   286
          });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   287
      if (can_create) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   288
        if (
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   289
          this.$.find(".Ldt-Markers-Create").is(":hidden") &&
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   290
          (this.$.find(".Ldt-Markers-Delete").is(":hidden") ||
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   291
            this.$.find(".Ldt-Markers-PreviewDelete").is(":hidden"))
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   292
        ) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   293
          this.$.find(".Ldt-Markers-RoundButton").hide();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   294
          this.$.find(".Ldt-Markers-Create").show();
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
   295
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   296
      } else {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   297
        if (
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   298
          this.$.find(".Ldt-Markers-CannotCreate").is(":hidden") &&
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   299
          (this.$.find(".Ldt-Markers-Delete").is(":hidden") ||
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   300
            this.$.find(".Ldt-Markers-PreviewDelete").is(":hidden"))
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   301
        ) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   302
          this.$.find(".Ldt-Markers-RoundButton").hide();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   303
          this.$.find(".Ldt-Markers-CannotCreate").show();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   304
        }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   305
      }
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
   306
    }
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
   307
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   308
    onCreateClick() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   309
      this.pauseOnWrite();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   310
      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
   311
        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
   312
        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
   313
        this.startEdit();
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   314
      }
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
   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
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   317
    onDeleteClick() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   318
      _this = this;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   319
      this.pauseOnWrite();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   320
      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
   321
        this.showScreen("ConfirmDelete");
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   322
      } else {
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   323
        // Click on "x" without a selected marker: back to initial state
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   324
        this.cancelEdit();
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   325
      }
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
   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
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   328
    startEdit() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   329
      if (this.selectedMarker) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   330
        _divHtml = Mustache.render(this.infoTemplate, {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   331
          edit: true,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   332
          preview_mode: this.preview_mode,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   333
          preview_mode_text: this.l10n.preview_mode_submit,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   334
          marker_info: this.selectedMarker.description,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   335
          send: this.custom_send_button
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   336
            ? this.custom_send_button
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   337
            : this.l10n.send,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   338
          cancel: this.custom_cancel_button
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   339
            ? this.custom_cancel_button
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   340
            : this.l10n.cancel,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   341
        });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   342
      } else {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   343
        _divHtml = Mustache.render(this.infoTemplate, {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   344
          edit: true,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   345
          marker_info: "",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   346
          preview_mode: this.preview_mode,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   347
          preview_mode_text: this.l10n.preview_mode_submit,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   348
          send: this.custom_send_button
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   349
            ? this.custom_send_button
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   350
            : this.l10n.send,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   351
          cancel: this.custom_cancel_button
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   352
            ? this.custom_cancel_button
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   353
            : this.l10n.cancel,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   354
        });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   355
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   356
      this.$.find(".Ldt-Markers-Info").html(_divHtml);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   357
      this.$.find(".Ldt-Markers-MarkerSend").click(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   358
        this.functionWrapper("onSubmit")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   359
      );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   360
      this.$.find(".Ldt-Markers-MarkerCancel").click(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   361
        this.functionWrapper("cancelEdit")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   362
      );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   363
      this.$.find(".Ldt-Markers-MarkerTextArea").bind(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   364
        "change keyup input paste",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   365
        this.functionWrapper("onDescriptionChange")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   366
      );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   367
      this.$.find(".Ldt-Markers-RoundButton").hide();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   368
      if (this.preview_mode) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   369
        this.$.find(".Ldt-Markers-PreviewDelete").show();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   370
      } else {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   371
        this.$.find(".Ldt-Markers-Delete").show();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   372
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   373
      this.editing = true;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   374
    }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   375
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   376
    cancelEdit() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   377
      if (this.selectedMarker) {
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   378
        // Click on "cancel" while editing a marker: back to visualization state
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   379
        _divHtml = Mustache.render(this.infoTemplate, {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   380
          edit: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   381
          marker_info: this.selectedMarker.description,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
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
        this.$.find(".Ldt-Markers-Info").html(_divHtml);
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   384
        if (!this.preview_mode) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   385
          this.$.find(".Ldt-Markers-MarkerDescription").click(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   386
            this.functionWrapper("startEdit")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   387
          );
1066
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1059
diff changeset
   388
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   389
      } else {
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   390
        // Click on "cancel" while editing a marker: back to initial state
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   391
        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
   392
        this.$.find(".Ldt-Markers-Info").html("");
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   393
        this.$.find(".Ldt-Markers-RoundButton").hide();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   394
        this.$.find(".Ldt-Markers-Create").show();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   395
        this.updateCreateButtonState(this.media.getCurrentTime());
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   396
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   397
      this.editing = 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
   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
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   400
    onDescriptionChange() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   401
      // Returns false if the textarea is empty, true if there is text in it
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   402
      if (!this.allow_empty_markers) {
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
   403
        var _field = this.$.find(".Ldt-Markers-MarkerTextArea"),
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   404
          _contents = _field.val();
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   405
        _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
   406
        if (!!_contents) {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   407
          _field.removeClass("empty");
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
   408
        } else {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   409
          _field.addClass("empty");
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
        }
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   411
        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
   412
        return !!_contents;
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   413
      } 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
   414
        // If the widget is configured to allow to post empty markers, it returns true
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   415
        return true;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   416
      }
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
   417
    }
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
   418
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   419
    pauseOnWrite() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   420
      if (this.pause_on_write && !this.media.getPaused()) {
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
   421
        this.media.pause();
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   422
      }
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
   423
    }
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   424
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   425
    showScreen(_screenName) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   426
      this.$.find(".Ldt-Markers-Screen" + _screenName)
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   427
        .show()
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   428
        .siblings()
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   429
        .hide();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   430
    }
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   431
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   432
    revertToMainScreen() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   433
      if (this.$.find(".Ldt-Markers-ScreenMain").is(":hidden")) {
1051
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   434
        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
   435
        this.cancelEdit();
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   436
        if (this.selectedMarker) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   437
          this.$.find(".Ldt-Markers-RoundButton").hide();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   438
          if (this.preview_mode) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   439
            this.$.find(".Ldt-Markers-PreviewDelete").show();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   440
          } else {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   441
            this.$.find(".Ldt-Markers-Delete").show();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   442
          }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   443
        } else {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   444
          this.$.find(".Ldt-Markers-RoundButton").hide();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   445
          this.$.find(".Ldt-Markers-Create").show();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   446
          this.updateCreateButtonState();
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
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   448
      }
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
    }
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" 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
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   451
    hidePlaceholder() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   452
      this.$.find(".Ldt-Markers-PlaceholderMarker").remove();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   453
    }
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
   454
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   455
    showPlaceholder(_time) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   456
      var _scale = this.width / this.source.getDuration(),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   457
        _left = _time * _scale - 1,
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
   458
        _data = {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   459
          left: _left,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   460
          height: this.line_height - 1,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   461
          ball_top:
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   462
            this.ball_radius * 2 > this.line_height
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   463
              ? 0
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   464
              : (this.line_height - this.ball_radius * 2) / 2 - 1,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   465
          ball_radius:
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   466
            this.ball_radius * 2 > this.line_height
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   467
              ? this.line_height / 2
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   468
              : this.ball_radius,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   469
          ball_diameter:
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   470
            this.ball_radius * 2 > this.line_height
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   471
              ? this.line_height / 2
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   472
              : this.ball_radius * 2,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   473
          ball_left: -this.ball_radius,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   474
          marker_color: this.placeholder_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
   475
        },
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   476
        _html = Mustache.render(this.markerPlaceholderTemplate, _data),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   477
        _el = jQuery(_html);
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
   478
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   479
      list_$ = this.$.find(".Ldt-Markers-List");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   480
      _el.appendTo(list_$);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   481
    }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   482
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   483
    clearSelectedMarker() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   484
      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
   485
        var _divHtml = "";
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   486
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
   487
        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
   488
        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
   489
        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
   490
        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
   491
        this.$.find(".Ldt-Markers-MarkerBall").toggleClass("selected", false);
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   492
        this.updateCreateButtonState(this.media.getCurrentTime());
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   493
      }
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
   494
    }
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
   495
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   496
    drawMarkers() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   497
      var _this = this,
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
   498
        _scale = this.width / this.source.getDuration(),
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   499
        list_$ = this.$.find(".Ldt-Markers-List"),
1069
2409cb4cebaf getting various changes from github
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   500
        _displayed_markers = this.markers;
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
   501
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   502
      this.$.remove("Ldt-Markers-Marker");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   503
      list_$.html("");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   504
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   505
      if (this.filter_per_user && this.usernames.length > 1) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   506
        var _username = this.$.find(".Ldt-Markers-userFilter-dropdown")[0]
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   507
          .options[
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   508
          this.$.find(".Ldt-Markers-userFilter-dropdown")[0].selectedIndex
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   509
        ].value;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   510
        _displayed_markers = _displayed_markers.filter(function (_marker) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   511
          return _marker.creator == _username;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   512
        });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   513
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   514
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   515
      _displayed_markers.forEach(function (_marker) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   516
        var _left = _marker.begin * _scale - 1,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   517
          _data = {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   518
            left: _left,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   519
            height: _this.line_height - 1,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   520
            ball_top:
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   521
              _this.ball_radius * 2 > _this.line_height
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   522
                ? 0
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   523
                : (_this.line_height - _this.ball_radius * 2) / 2 - 1,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   524
            ball_radius:
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   525
              _this.ball_radius * 2 > _this.line_height
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   526
                ? _this.line_height / 2
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   527
                : _this.ball_radius,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   528
            ball_diameter:
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   529
              _this.ball_radius * 2 > _this.line_height
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   530
                ? _this.line_height / 2
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   531
                : _this.ball_radius * 2,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   532
            ball_left: -_this.ball_radius,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   533
            marker_color:
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   534
              _this.selectedMarker && _this.selectedMarker.id == _marker.id
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   535
                ? _this.selected_color
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   536
                : _this.marker_color,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   537
          },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   538
          _html = Mustache.render(_this.markerTemplate, _data),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   539
          _el = jQuery(_html);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   540
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   541
        if (_this.selectedMarker && _this.selectedMarker.id == _marker.id) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   542
          _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
   543
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   544
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   545
        _el
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   546
          .mouseover(function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   547
            if (
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   548
              !(_this.selectedMarker && _this.selectedMarker.id == _marker.id)
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   549
            ) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   550
              _el.children().css("background-color", _this.hover_color);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   551
            }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   552
          })
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   553
          .mouseout(function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   554
            if (
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   555
              !(_this.selectedMarker && _this.selectedMarker.id == _marker.id)
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   556
            ) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   557
              _el.children().css("background-color", _this.marker_color);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   558
            }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   559
          })
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   560
          .click(function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   561
            _this.showScreen("Main");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   562
            _this.cancelEdit();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   563
            _this.hidePlaceholder();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   564
            if (
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   565
              !(_this.selectedMarker && _this.selectedMarker.id == _marker.id)
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   566
            ) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   567
              // if there either is no marker selected or we click a different marker
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   568
              list_$
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   569
                .find(".Ldt-Markers-MarkerBall")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   570
                .css("background-color", _this.marker_color);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   571
              list_$
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   572
                .find(".Ldt-Markers-MarkerBall")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   573
                .toggleClass("selected", false);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   574
              _el.children().toggleClass("selected", true);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   575
              _el.children().css("background-color", _this.selected_color);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   576
              _this.selectedMarker = _marker;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   577
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   578
              _divHtml = Mustache.render(_this.infoTemplate, {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   579
                edit: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   580
                marker_info: _marker.description,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   581
              });
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
   582
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   583
              _this.$.find(".Ldt-Markers-Info").html(_divHtml);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   584
              if (!_this.preview_mode) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   585
                _this.$.find(".Ldt-Markers-MarkerDescription").click(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   586
                  _this.functionWrapper("startEdit")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   587
                );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   588
              }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   589
              _this.$.find(".Ldt-Markers-RoundButton").hide();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   590
              if (_this.preview_mode) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   591
                _this.$.find(".Ldt-Markers-PreviewDelete").show();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   592
              } else {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   593
                _this.$.find(".Ldt-Markers-Delete").show();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   594
              }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   595
            } else {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   596
              // if we click the currently selected marker, we unselect it
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   597
              _el.children().css("background-color", _this.hover_color);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   598
              _this.clearSelectedMarker();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   599
            }
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
   600
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   601
            if (_this.selectedMarker) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   602
              // Only if we select a new marker do we pause video and time jump
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   603
              _this.media.pause();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   604
              _marker.trigger("click");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   605
            }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   606
          })
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   607
          .appendTo(list_$);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   608
      });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   609
    }
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
   610
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   611
    onSubmit() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   612
      /* If mandatory fields are empty, we cancel the sending */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   613
      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
   614
        return false;
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   615
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   616
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   617
      /* We pause the video if it's still playing */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   618
      if (!this.media.getPaused()) {
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
   619
        this.media.pause();
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   620
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   621
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   622
      var _this = this,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   623
        _exportedAnnotations = new ns.Model.List(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   624
          this.player.sourceManager
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   625
        ) /* We create a List to send to the server that will contains the annotation */,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   626
        _export = this.player.sourceManager.newLocalSource({
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   627
          serializer: ns.serializers[this.api_serializer],
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   628
        }) /* We create a source object using a specific serializer for export */,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   629
        _annotationTypes = this.source
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   630
          .getAnnotationTypes()
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   631
          .searchByTitle(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   632
            this.annotation_type,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   633
            true
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   634
          ) /* We get the AnnotationType in which the annotation will be added */,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   635
        _annotationType = _annotationTypes.length
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   636
          ? _annotationTypes[0]
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   637
          : new ns.Model.AnnotationType(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   638
              false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   639
              _export
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   640
            ); /* If it doesn't already exists, we create it */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   641
      if (this.selectedMarker) {
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   642
        var _annotation = this.selectedMarker,
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   643
          _url = Mustache.render(this.api_endpoint_template_edit, {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   644
            annotation_id: this.selectedMarker ? this.selectedMarker.id : "",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   645
          });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   646
        _annotation.source = _export;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   647
        _annotation.description = this.$.find(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   648
          ".Ldt-Markers-MarkerTextArea"
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   649
        ).val(); /* Description field */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   650
      } else {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   651
        var _annotation = new ns.Model.Annotation(false, _export),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   652
          _url = Mustache.render(this.api_endpoint_template_create);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   653
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   654
        /* If we created an AnnotationType on the spot ... */
1045
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   655
        if (!_annotationTypes.length) {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   656
          /* ... We must not send its id to the server ... */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   657
          _annotationType.dont_send_id = true;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   658
          /* ... And we must include its title. */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   659
          _annotationType.title = this.annotation_type;
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
   660
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   661
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   662
        _annotation.setMedia(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   663
          this.source.currentMedia.id
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   664
        ); /* Annotated media ID */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   665
        if (!this.selectedMarker) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   666
          _annotation.setBegin(this.newMarkerCurrentTime);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   667
          _annotation.setEnd(this.newMarkerCurrentTime);
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
   668
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   669
        _annotation.setAnnotationType(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   670
          _annotationType.id
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   671
        ); /* AnnotationType ID */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   672
        if (this.project_id != "") {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   673
          /* Project id, only if it's been specifiec in the config */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   674
          _annotation.project_id = this.project_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
   675
        }
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   676
        _annotation.created = new Date(); /* Creation date */
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   677
        _annotation.description = this.$.find(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   678
          ".Ldt-Markers-MarkerTextArea"
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   679
        ).val(); /* Description field */
1045
b06345320ffb Altered ldt_annotate serializer to allow for serializing id for editing annotation + Added Markers widget that allows to make and edit 0 duration annotations.
durandn
parents:
diff changeset
   680
        _annotation.creator = this.creator_name;
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   681
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   682
      _annotation.project_id = this.project_id;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   683
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   684
      _exportedAnnotations.push(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   685
        _annotation
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   686
      ); /* We add the annotation in the list to export */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   687
      _export.addList(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   688
        "annotation",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   689
        _exportedAnnotations
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   690
      ); /* We add the list to the source object */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   691
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   692
      /* We send the AJAX request to the server ! */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   693
      jQuery.ajax({
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
   694
        url: _url,
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   695
        type: this.selectedMarker
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   696
          ? this.api_method_edit
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   697
          : this.api_method_create,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   698
        contentType: "application/json",
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   699
        data: _export.serialize(),
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   700
        success: function (_data) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   701
          _this.showScreen("Success");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   702
          window.setTimeout(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   703
            _this.functionWrapper("revertToMainScreen"),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   704
            _this.after_send_timeout || 5000
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   705
          );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   706
          _export
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   707
            .getAnnotations()
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   708
            .removeElement(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   709
              _annotation,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   710
              true
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   711
            ); /* We delete the sent annotation to avoid redundancy */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   712
          _export.deSerialize(_data); /* Data deserialization */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   713
          _annotation.id = _data.id;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   714
          _this.source.merge(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   715
            _export
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   716
          ); /* We merge the deserialized data with the current source data */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   717
          if (
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   718
            _this.pause_on_write &&
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   719
            _this.media.getPaused() &&
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   720
            _this.play_on_submit
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   721
          ) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   722
            _this.media.play();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   723
          }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   724
          _this.markers.push(_annotation);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   725
          _this.selectedMarker = _annotation;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   726
          _this.drawMarkers();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   727
          _this.player.trigger("AnnotationsList.refresh");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   728
          _this.player.trigger("Markers.refresh");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   729
        },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   730
        error: function (_xhr, _error, _thrown) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   731
          ns.log("Error when sending annotation", _thrown);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   732
          _export.getAnnotations().removeElement(_annotation, true);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   733
          _this.showScreen("Failure");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   734
          window.setTimeout(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   735
            _this.functionWrapper("revertToMainScreen"),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   736
            _this.after_send_timeout || 5000
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   737
          );
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
   738
        },
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   739
      });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   740
      this.showScreen("Sending");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   741
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   742
      return false;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   743
    }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   744
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   745
    sendDelete() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   746
      _this = this;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   747
      _url = Mustache.render(this.api_endpoint_template_delete, {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   748
        annotation_id: this.selectedMarker ? this.selectedMarker.id : "",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   749
        project_id: this.selectedMarker.project_id
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   750
          ? this.selectedMarker.project_id
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   751
          : this.project_id,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   752
      });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   753
      jQuery.ajax({
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   754
        url: _url,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   755
        type: this.api_method_delete,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   756
        contentType: "application/json",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   757
        success: function (_data) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   758
          _this.showScreen("DeleteSuccess");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   759
          window.setTimeout(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   760
            _this.functionWrapper("revertToMainScreen"),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   761
            _this.after_send_timeout || 5000
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   762
          );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   763
          if (
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   764
            _this.pause_on_write &&
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   765
            _this.media.getPaused() &&
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   766
            _this.play_on_submit
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   767
          ) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   768
            _this.media.play();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   769
          }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   770
          _this.markers.removeElement(_this.selectedMarker);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   771
          _this.selectedMarker = false;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   772
          _this.player.trigger("AnnotationsList.refresh");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   773
          _this.player.trigger("Markers.refresh");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   774
        },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   775
        error: function (_xhr, _error, _thrown) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   776
          ns.log("Error when sending annotation", _thrown);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   777
          _this.showScreen("Failure");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   778
          window.setTimeout(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   779
            _this.functionWrapper("revertToMainScreen"),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   780
            _this.after_send_timeout || 5000
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   781
          );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   782
        },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   783
      });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   784
      this.showScreen("Sending");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   785
    }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   786
  };
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
   787
};
3820cf5fe29e Added support for custom button texts + Added support for deleting markers + reworked the way the "+" and "-" buttons work + Added a "placeholder" marker when clicking "+" to show where in the timeline the marker will be posted
durandn
parents: 1045
diff changeset
   788
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   789
export { Markers, markersStyles };