src/widgets/CreateAnnotation.js
author ymh <ymh.work@gmail.com>
Wed, 04 Sep 2024 17:32:50 +0200
changeset 1072 ac1eacb3aa33
parent 1069 2409cb4cebaf
permissions -rw-r--r--
Migrate source and build to vite.js
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
965
eadb7290c325 Improvements in widget communication
veltr
parents: 957
diff changeset
     1
/* TODO: Add Social Network Sharing */
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
     2
// CreateAnnotation
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
     3
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
     4
import createAnnotationStyles from "./CreateAnnotation.module.css";
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
     5
import Mustache from "mustache";
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
     6
import _ from "lodash";
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
     7
import jQuery from "jquery";
908
f56199193fad CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents: 904
diff changeset
     8
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
     9
const CreateAnnotation = function (ns) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    10
  return class extends ns.Widgets.Widget {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    11
    constructor(player, config) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    12
      super(player, config);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    13
      if (
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    14
        this.editable_storage != "" &&
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    15
        window.localStorage[this.editable_storage]
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    16
      ) {
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
    17
        this.source.onLoad(function () {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    18
          var _export = this.player.sourceManager.newLocalSource({
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    19
            serializer: ns.serializers["ldt_localstorage"],
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    20
          });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    21
          _export.deSerialize(window.localStorage[this.editable_storage]);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    22
          _this.source.merge(_export);
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
    23
        });
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    24
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    25
    }
880
4c7b33bf2795 Started work on CreateAnnotation and Mediafragment
veltr
parents:
diff changeset
    26
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    27
    static defaults = {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    28
      show_title_field: true,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    29
      show_creator_field: true,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    30
      creator_field_readonly: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    31
      start_visible: true,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    32
      always_visible: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    33
      show_slice: true,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    34
      show_arrow: true,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    35
      show_time: true,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    36
      minimize_annotation_widget: true,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    37
      creator_name: "",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    38
      creator_avatar: "",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    39
      tags: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    40
      tag_titles: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    41
      pause_on_write: true,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    42
      max_tags: 8,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    43
      polemics: [
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    44
        {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    45
          keyword: "++",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    46
          background_color: "#00a000",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    47
          text_color: "#ffffff",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    48
        },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    49
        {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    50
          keyword: "--",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    51
          background_color: "#c00000",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    52
          text_color: "#ffffff",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    53
        },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    54
        {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    55
          keyword: "??",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    56
          background_color: "#0000e0",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    57
          text_color: "#ffffff",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    58
        },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    59
        {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    60
          keyword: "==",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    61
          background_color: "#f0e000",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    62
          text_color: "#000000",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    63
        },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    64
      ],
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    65
      slice_annotation_type: "chap",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    66
      annotation_type: "Contributions",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    67
      post_at_segment_time: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    68
      segment_annotation_type: "chap",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    69
      api_serializer: "ldt_annotate",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    70
      api_endpoint_template: "",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    71
      api_method: "POST",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    72
      // Id that will be used as localStorage key
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    73
      editable_storage: "",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    74
      project_id: "",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    75
      after_send_timeout: 0,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    76
      close_after_send: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    77
      tag_prefix: "#",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    78
      pause_when_displaying: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    79
      custom_send_button: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    80
      custom_cancel_button: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    81
      custom_description_placeholder: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    82
      preview_mode: false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    83
    };
880
4c7b33bf2795 Started work on CreateAnnotation and Mediafragment
veltr
parents:
diff changeset
    84
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    85
    static messages =  {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    86
      en: {
882
61c384dda19e Big refactoring
veltr
parents: 881
diff changeset
    87
        from_time: "from",
61c384dda19e Big refactoring
veltr
parents: 881
diff changeset
    88
        to_time: "to",
923
b3ee7d1b472a UI improvements
veltr
parents: 916
diff changeset
    89
        at_time: "at",
882
61c384dda19e Big refactoring
veltr
parents: 881
diff changeset
    90
        submit: "Submit",
1066
5ef7182907c5 added a "preview" mode for CreateAnnotation and Markers that blocks inputs so sending annotations is impossible
durandn
parents: 1061
diff changeset
    91
        preview_submit: "You cannot submit annotations in preview mode",
1047
c3bf174e0ef8 Added a button to cancel Annotation creation and hide the widget on CreateAnnotation
durandn
parents: 1038
diff changeset
    92
        cancel: "Cancel",
904
510ebab76fa3 Work on CreateAnnotation Widget
veltr
parents: 887
diff changeset
    93
        add_keywords_: "Add keywords:",
1021
7253d4d06f0d update widgets after enhance in annotation platform.
cavaliet
parents: 1013
diff changeset
    94
        add_polemic_keywords_: "Add polemic attributes :",
923
b3ee7d1b472a UI improvements
veltr
parents: 916
diff changeset
    95
        your_name_: "Your name:",
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
    96
        annotate_video: "New note",
882
61c384dda19e Big refactoring
veltr
parents: 881
diff changeset
    97
        type_title: "Annotation title",
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
    98
        type_description: "Enter a new note...",
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
    99
        wait_while_processing:
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   100
          "Please wait while your annotation is being processed...",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   101
        error_while_contacting:
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   102
          "An error happened while contacting the server. Your annotation has not been saved.",
882
61c384dda19e Big refactoring
veltr
parents: 881
diff changeset
   103
        annotation_saved: "Thank you, your annotation has been saved.",
61c384dda19e Big refactoring
veltr
parents: 881
diff changeset
   104
        share_annotation: "Would you like to share it on social networks ?",
982
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 979
diff changeset
   105
        close_widget: "Hide the annotation form",
970
b1c3bf6eca78 Cleaning and refactoring
veltr
parents: 966
diff changeset
   106
        "polemic++": "Agree",
b1c3bf6eca78 Cleaning and refactoring
veltr
parents: 966
diff changeset
   107
        "polemic--": "Disagree",
b1c3bf6eca78 Cleaning and refactoring
veltr
parents: 966
diff changeset
   108
        "polemic??": "Question",
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   109
        "polemic==": "Reference",
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   110
        in_tooltip: "Set begin time to current player time",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   111
        out_tooltip: "Set begin time to current player time",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   112
        play_tooltip: "Play the fragment",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   113
      },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   114
      fr: {
904
510ebab76fa3 Work on CreateAnnotation Widget
veltr
parents: 887
diff changeset
   115
        from_time: "de",
882
61c384dda19e Big refactoring
veltr
parents: 881
diff changeset
   116
        to_time: "à",
923
b3ee7d1b472a UI improvements
veltr
parents: 916
diff changeset
   117
        at_time: "à",
882
61c384dda19e Big refactoring
veltr
parents: 881
diff changeset
   118
        submit: "Envoyer",
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   119
        preview_submit:
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   120
          "Vous ne pouvez pas envoyer d'annotation en mode aperçu",
1047
c3bf174e0ef8 Added a button to cancel Annotation creation and hide the widget on CreateAnnotation
durandn
parents: 1038
diff changeset
   121
        cancel: "Annuler",
1002
a86208b60c91 Bugfixes and changes for MDComposer
veltr
parents: 988
diff changeset
   122
        add_keywords_: "Ajouter des mots-clés\u00a0:",
1021
7253d4d06f0d update widgets after enhance in annotation platform.
cavaliet
parents: 1013
diff changeset
   123
        add_polemic_keywords_: "Ajouter des attributs polémiques\u00a0:",
1002
a86208b60c91 Bugfixes and changes for MDComposer
veltr
parents: 988
diff changeset
   124
        your_name_: "Votre nom\u00a0:",
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   125
        annotate_video: "Entrez une nouvelle note...",
882
61c384dda19e Big refactoring
veltr
parents: 881
diff changeset
   126
        type_title: "Titre de l'annotation",
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   127
        type_description: "Prenez vos notes...",
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   128
        wait_while_processing:
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   129
          "Veuillez patienter pendant le traitement de votre annotation...",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   130
        error_while_contacting:
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   131
          "Une erreur s'est produite en contactant le serveur. Votre annotation n'a pas été enregistrée.",
882
61c384dda19e Big refactoring
veltr
parents: 881
diff changeset
   132
        annotation_saved: "Merci, votre annotation a été enregistrée.",
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   133
        share_annotation:
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   134
          "Souhaitez-vous la partager sur les réseaux sociaux ?",
982
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 979
diff changeset
   135
        close_widget: "Cacher le formulaire de création d'annotations",
970
b1c3bf6eca78 Cleaning and refactoring
veltr
parents: 966
diff changeset
   136
        "polemic++": "Accord",
b1c3bf6eca78 Cleaning and refactoring
veltr
parents: 966
diff changeset
   137
        "polemic--": "Désaccord",
b1c3bf6eca78 Cleaning and refactoring
veltr
parents: 966
diff changeset
   138
        "polemic??": "Question",
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   139
        "polemic==": "Référence",
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   140
        in_tooltip: "Utiliser le temps courant comme début",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   141
        out_tooltip: "Utiliser le temps courant comme fin",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   142
        play_tooltip: "Jouer le fragment",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   143
      },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   144
    };
880
4c7b33bf2795 Started work on CreateAnnotation and Mediafragment
veltr
parents:
diff changeset
   145
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   146
    static template =
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   147
      '{{#show_slice}}<div class="Ldt-CreateAnnotation-Slice Ldt-TraceMe"></div>{{/show_slice}}' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   148
      '{{^show_slice}}{{#show_arrow}}<div class="Ldt-CreateAnnotation-Arrow"></div>{{/show_arrow}}{{/show_slice}}' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   149
      '<div class="Ldt-CreateAnnotation"><div class="Ldt-CreateAnnotation-Inner">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   150
      '<form class="Ldt-CreateAnnotation-Screen Ldt-CreateAnnotation-Main">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   151
      '<h3><span class="Ldt-CreateAnnotation-h3Left">{{l10n.annotate_video}}{{#show_title_field}}</span></h3>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   152
      '<h3><span class="Ldt-CreateAnnotation-h3Left"><input class="Ldt-CreateAnnotation-Title empty" placeholder="{{l10n.type_title}}" />{{/show_title_field}}' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   153
      '{{#show_time}}<span class="Ldt-CreateAnnotation-Times"> {{#show_slice}}{{l10n.from_time}} {{/show_slice}}{{^show_slice}}{{l10n.at_time}} {{/show_slice}} <span class="Ldt-CreateAnnotation-Begin">00:00</span>{{/show_time}}' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   154
      '{{#show_slice}} {{l10n.to_time}} <span class="Ldt-CreateAnnotation-End">{{end}}</span>{{/show_slice}}</span></span>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   155
      '{{#show_creator_field}}{{l10n.your_name_}} <input class="Ldt-CreateAnnotation-Creator empty" value="{{creator_name}}" {{#creator_field_readonly}}readonly{{/creator_field_readonly}}/>{{/show_creator_field}}</h3>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   156
      '{{#show_controls}}<div class="Ldt-CreateAnnotation-Controls">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   157
      '<span title="{{l10n.in_tooltip}}" class="Ldt-CreateAnnotation-Control-In">In</span>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   158
      '<span title="{{l10n.out_tooltip}}" class="Ldt-CreateAnnotation-Control-Out">Out</span>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   159
      '<span title="{{l10n.play_tooltip}}" class="Ldt-CreateAnnotation-Control-Play">Play</span>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   160
      "</div>{{/show_controls}}" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   161
      '<textarea class="Ldt-CreateAnnotation-Description Ldt-TraceMe empty" placeholder="{{#custom_description_placeholder}}{{custom_description_placeholder}}{{/custom_description_placeholder}}{{^custom_description_placeholder}}{{l10n.type_description}}{{/custom_description_placeholder}}"></textarea>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   162
      '{{#show_creator_field}}<div class="Ldt-CreateAnnotation-Avatar"><img src="{{creator_avatar}}" title="{{creator_name}}"></img></div>{{/show_creator_field}}' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   163
      '<div class="Ldt-CreateAnnotation-SubmitArea Ldt-TraceMe">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   164
      '{{#preview_mode}}<input type="button" class="Ldt-CreateAnnotation-PreviewSubmit" title="{{l10n.preview_submit}}" value="{{#custom_send_button}}{{custom_send_button}}{{/custom_send_button}}{{^custom_send_button}}{{l10n.submit}}{{/custom_send_button}}" />{{/preview_mode}}' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   165
      '{{^preview_mode}}<input type="submit" class="Ldt-CreateAnnotation-Submit" value="{{#custom_send_button}}{{custom_send_button}}{{/custom_send_button}}{{^custom_send_button}}{{l10n.submit}}{{/custom_send_button}}" />{{/preview_mode}}' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   166
      '<input type="button" class="Ldt-CreateAnnotation-Cancel" value="{{#custom_cancel_button}}{{custom_cancel_button}}{{/custom_cancel_button}}{{^custom_cancel_button}}{{l10n.cancel}}{{/custom_cancel_button}}" />' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   167
      '<div class="Ldt-CreateAnnotation-Begin Ldt-CreateAnnotation-Times">00:00</div>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   168
      "</div>" +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   169
      '{{#tags.length}}<div class="Ldt-CreateAnnotation-Tags"><div class="Ldt-CreateAnnotation-TagTitle">{{l10n.add_keywords_}}</div><ul class="Ldt-CreateAnnotation-TagList">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   170
      '{{#tags}}<li class="Ldt-CreateAnnotation-TagLi" tag-id="{{id}}" data-text="{{tag_prefix}}{{title}}"><span class="Ldt-CreateAnnotation-TagButton">{{title}}</span></li>{{/tags}}</ul></div>{{/tags.length}}' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   171
      '{{#polemics.length}}<div class="Ldt-CreateAnnotation-Polemics"><div class="Ldt-CreateAnnotation-PolemicTitle">{{l10n.add_polemic_keywords_}}</div><ul class="Ldt-CreateAnnotation-PolemicList">' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   172
      '{{#polemics}}<li class="Ldt-CreateAnnotation-PolemicLi" style="background-color: {{background_color}}; color: {{text_color}}" data-text="{{keyword}}">{{keyword}}</li>{{/polemics}}</ul></div>{{/polemics.length}}' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   173
      '<div style="clear: both;"></div></form>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   174
      '<div class="Ldt-CreateAnnotation-Screen Ldt-CreateAnnotation-Wait"><div class="Ldt-CreateAnnotation-InnerBox">{{l10n.wait_while_processing}}</div></div>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   175
      '<div class="Ldt-CreateAnnotation-Screen Ldt-CreateAnnotation-Error">{{^always_visible}}<a title="{{l10n.close_widget}}" class="Ldt-CreateAnnotation-Close" href="#"></a>{{/always_visible}}<div class="Ldt-CreateAnnotation-InnerBox">{{l10n.error_while_contacting}}</div></div>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   176
      '<div class="Ldt-CreateAnnotation-Screen Ldt-CreateAnnotation-Saved">{{^always_visible}}<a title="{{l10n.close_widget}}" class="Ldt-CreateAnnotation-Close" href="#"></a>{{/always_visible}}<div class="Ldt-CreateAnnotation-InnerBox">{{l10n.annotation_saved}}</div></div>' +
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   177
      "</div></div>";
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   178
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   179
    draw() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   180
      var _this = this;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   181
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   182
      this.begin = new ns.Model.Time();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   183
      this.end = this.source.getDuration();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   184
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   185
      this.tag_prefix = this.tag_prefix || "";
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   186
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   187
      if (this.tag_titles && !this.tags) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   188
        if (!(this.tag_titles.length == 1 && this.tag_titles[0] == "")) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   189
          this.tags = _(this.tag_titles).map(function (_tag_title) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   190
            var _tag,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   191
              _tags = _this.source.getTags().searchByTitle(_tag_title, true);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   192
            if (_tags.length) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   193
              _tag = _tags[0];
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   194
            } else {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   195
              _tag = new ns.Model.Tag(false, _this.source);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   196
              _this.source.getTags().push(_tag);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   197
              _tag.title = _tag_title;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   198
            }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   199
            return _tag;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   200
          }).value();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   201
        } else {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   202
          // we forced no tags if this.tag_titles = [''] (and not false)
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   203
          this.tags = true;
1021
7253d4d06f0d update widgets after enhance in annotation platform.
cavaliet
parents: 1013
diff changeset
   204
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   205
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   206
      if (!this.tags) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   207
        this.tags = this.source
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   208
          .getTags()
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   209
          .sortBy(function (_tag) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   210
            return -_tag.getAnnotations().length;
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
          .slice(0, this.max_tags)
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   213
          .map(function (_tag) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   214
            return _tag;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   215
          });
928
5aadbc9f27cd First tests before allowing mashup annotation
veltr
parents: 925
diff changeset
   216
        /* We have to use the map function because Mustache doesn't like our tags object */
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   217
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   218
      this.renderTemplate();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   219
      if (this.show_slice) {
1038
e78b889a75e1 CreateAnnotations new feature: hide/show functionality on signal trigger (tweaks), added config options to customize what is displayed more accurately
durandn
parents: 1033
diff changeset
   220
        this.insertSubwidget(
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   221
          this.$.find(".Ldt-CreateAnnotation-Slice"),
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
            type: "Slice",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   224
            show_arrow: this.show_arrow,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   225
            annotation_type: this.slice_annotation_type,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   226
            onBoundsChanged: function (_from, _to) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   227
              _this.setBeginEnd(_from, _to);
965
eadb7290c325 Improvements in widget communication
veltr
parents: 957
diff changeset
   228
            },
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   229
          },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   230
          "slice"
965
eadb7290c325 Improvements in widget communication
veltr
parents: 957
diff changeset
   231
        );
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   232
      } else {
965
eadb7290c325 Improvements in widget communication
veltr
parents: 957
diff changeset
   233
        if (this.show_arrow) {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   234
          this.insertSubwidget(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   235
            this.$.find(".Ldt-CreateAnnotation-Arrow"),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   236
            { type: "Arrow" },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   237
            "arrow"
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   238
          );
965
eadb7290c325 Improvements in widget communication
veltr
parents: 957
diff changeset
   239
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   240
        this.onMediaEvent("timeupdate", function (_time) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   241
          // Do not update timecode if description is not empty
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   242
          if (
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   243
            _this.$.find(".Ldt-CreateAnnotation-Description").val().trim() == ""
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   244
          ) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   245
            _this.setBeginEnd(_time, _time);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   246
            if (_this.arrow) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   247
              _this.arrow.moveToTime(_time);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   248
            }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   249
          }
965
eadb7290c325 Improvements in widget communication
veltr
parents: 957
diff changeset
   250
        });
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   251
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   252
      this.$.find(".Ldt-CreateAnnotation-Cancel").click(function () {
1047
c3bf174e0ef8 Added a button to cancel Annotation creation and hide the widget on CreateAnnotation
durandn
parents: 1038
diff changeset
   253
        _this.player.trigger("CreateAnnotation.hide");
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   254
      });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   255
      this.$.find(".Ldt-CreateAnnotation-Close").click(function () {
925
28efc97b5d78 Corrected MAJOR bug in search results
veltr
parents: 924
diff changeset
   256
        _this.close_after_send
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   257
          ? _this.player.trigger("CreateAnnotation.hide")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   258
          : _this.showScreen("Main");
908
f56199193fad CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents: 904
diff changeset
   259
        return false;
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   260
      });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   261
      this.$.find(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   262
        ".Ldt-CreateAnnotation-TagLi, .Ldt-CreateAnnotation-PolemicLi"
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   263
      ).click(function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   264
        _this.addKeyword(jQuery(this).attr("data-text"));
904
510ebab76fa3 Work on CreateAnnotation Widget
veltr
parents: 887
diff changeset
   265
        return false;
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   266
      });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   267
      this.$.find(".Ldt-CreateAnnotation-PolemicLi").each(function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   268
        var _el = jQuery(this),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   269
          _kw = _el.attr("data-text"),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   270
          _msg = _this.l10n["polemic" + _kw];
970
b1c3bf6eca78 Cleaning and refactoring
veltr
parents: 966
diff changeset
   271
        if (_msg) {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   272
          _el.attr("title", _msg);
970
b1c3bf6eca78 Cleaning and refactoring
veltr
parents: 966
diff changeset
   273
        }
1072
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
      this.$.find(".Ldt-CreateAnnotation-Description").bind(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   276
        "change keyup input paste",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   277
        this.functionWrapper("onDescriptionChange")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   278
      );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   279
      if (this.show_title_field) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   280
        this.$.find(".Ldt-CreateAnnotation-Title").bind(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   281
          "change keyup input paste",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   282
          this.functionWrapper("onTitleChange")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   283
        );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   284
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   285
      if (this.show_creator_field) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   286
        this.$.find(".Ldt-CreateAnnotation-Creator").bind(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   287
          "change keyup input paste",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   288
          this.functionWrapper("onCreatorChange")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   289
        );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   290
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   291
      this.$.find("[class^='Ldt-CreateAnnotation-Control-']").click(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   292
        function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   293
          var action = this.className.replace(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   294
            "Ldt-CreateAnnotation-Control-",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   295
            ""
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   296
          );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   297
          switch (action) {
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   298
            case "In":
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   299
              // Set In bound to current player time
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   300
              this.setBegin(_this.media.getCurrentTime());
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   301
              break;
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   302
            case "Out":
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   303
              // Set In bound to current player time
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   304
              this.setEnd(_this.media.getCurrentTime() || _this.media.duration);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   305
              break;
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   306
            case "Play":
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   307
              this.media.setCurrentTime(_this.begin);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   308
              this.media.play();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   309
              break;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   310
          }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   311
          return false;
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   312
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   313
      );
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   314
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   315
      if (this.start_visible) {
923
b3ee7d1b472a UI improvements
veltr
parents: 916
diff changeset
   316
        this.show();
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   317
      } else {
923
b3ee7d1b472a UI improvements
veltr
parents: 916
diff changeset
   318
        this.$.hide();
b3ee7d1b472a UI improvements
veltr
parents: 916
diff changeset
   319
        this.hide();
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   320
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   321
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   322
      this.onMdpEvent("CreateAnnotation.toggle", "toggle");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   323
      this.onMdpEvent("CreateAnnotation.hide", "hide");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   324
      this.onMdpEvent("CreateAnnotation.show", "show");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   325
      this.$.find("form").submit(this.functionWrapper("onSubmit"));
923
b3ee7d1b472a UI improvements
veltr
parents: 916
diff changeset
   326
    }
904
510ebab76fa3 Work on CreateAnnotation Widget
veltr
parents: 887
diff changeset
   327
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   328
    setBegin(t) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   329
      this.begin = new ns.Model.Time(t || 0);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   330
      this.$.find(".Ldt-CreateAnnotation-Begin").html(this.begin.toString());
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   331
    }
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   332
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   333
    setEnd(t) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   334
      this.end = new ns.Model.Time(t || 0);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   335
      this.$.find(".Ldt-CreateAnnotation-End").html(this.end.toString());
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   336
    }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   337
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   338
    setBeginEnd(begin, end) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   339
      this.setBegin(begin);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   340
      this.setEnd(end);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   341
    }
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   342
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   343
    showScreen(_screenName) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   344
      this.$.find(".Ldt-CreateAnnotation-" + _screenName)
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   345
        .show()
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   346
        .siblings()
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   347
        .hide();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   348
    }
908
f56199193fad CreateAnnotation widget now posts annotations, Tagcloud can be made segment-dependent
veltr
parents: 904
diff changeset
   349
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   350
    show() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   351
      if (!this.visible) {
1038
e78b889a75e1 CreateAnnotations new feature: hide/show functionality on signal trigger (tweaks), added config options to customize what is displayed more accurately
durandn
parents: 1033
diff changeset
   352
        this.visible = true;
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   353
        if (this.pause_when_displaying) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   354
          this.media.pause();
1047
c3bf174e0ef8 Added a button to cancel Annotation creation and hide the widget on CreateAnnotation
durandn
parents: 1038
diff changeset
   355
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   356
        this.showScreen("Main");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   357
        this.$.find(".Ldt-CreateAnnotation-Description")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   358
          .val("")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   359
          .css("border-color", "#666666")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   360
          .addClass("empty");
1038
e78b889a75e1 CreateAnnotations new feature: hide/show functionality on signal trigger (tweaks), added config options to customize what is displayed more accurately
durandn
parents: 1033
diff changeset
   361
        if (this.show_title_field) {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   362
          this.$.find(".Ldt-CreateAnnotation-Title")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   363
            .val("")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   364
            .css("border-color", "#666666")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   365
            .addClass("empty");
975
35aadec4131b Adapted Metadataplayer to send title and description
veltr
parents: 974
diff changeset
   366
        }
1038
e78b889a75e1 CreateAnnotations new feature: hide/show functionality on signal trigger (tweaks), added config options to customize what is displayed more accurately
durandn
parents: 1033
diff changeset
   367
        if (this.show_creator_field) {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   368
          this.$.find(".Ldt-CreateAnnotation-Creator")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   369
            .val(this.creator_name)
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   370
            .css("border-color", "#666666");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   371
          if (!this.creator_name) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   372
            this.$.find(".Ldt-CreateAnnotation-Creator").addClass("empty");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   373
          }
1038
e78b889a75e1 CreateAnnotations new feature: hide/show functionality on signal trigger (tweaks), added config options to customize what is displayed more accurately
durandn
parents: 1033
diff changeset
   374
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   375
        this.$.find(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   376
          ".Ldt-CreateAnnotation-TagLi, .Ldt-CreateAnnotation-PolemicLi"
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   377
        ).removeClass("selected");
1038
e78b889a75e1 CreateAnnotations new feature: hide/show functionality on signal trigger (tweaks), added config options to customize what is displayed more accurately
durandn
parents: 1033
diff changeset
   378
        this.$.slideDown();
e78b889a75e1 CreateAnnotations new feature: hide/show functionality on signal trigger (tweaks), added config options to customize what is displayed more accurately
durandn
parents: 1033
diff changeset
   379
        if (this.minimize_annotation_widget) {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   380
          this.player.trigger("Annotation.minimize");
1038
e78b889a75e1 CreateAnnotations new feature: hide/show functionality on signal trigger (tweaks), added config options to customize what is displayed more accurately
durandn
parents: 1033
diff changeset
   381
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   382
      }
923
b3ee7d1b472a UI improvements
veltr
parents: 916
diff changeset
   383
    }
904
510ebab76fa3 Work on CreateAnnotation Widget
veltr
parents: 887
diff changeset
   384
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   385
    hide() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   386
      if (this.visible) {
1038
e78b889a75e1 CreateAnnotations new feature: hide/show functionality on signal trigger (tweaks), added config options to customize what is displayed more accurately
durandn
parents: 1033
diff changeset
   387
        if (!this.always_visible) {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   388
          this.visible = false;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   389
          this.$.slideUp();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   390
          if (this.minimize_annotation_widget) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   391
            this.player.trigger("Annotation.maximize");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   392
          }
923
b3ee7d1b472a UI improvements
veltr
parents: 916
diff changeset
   393
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   394
      }
923
b3ee7d1b472a UI improvements
veltr
parents: 916
diff changeset
   395
    }
904
510ebab76fa3 Work on CreateAnnotation Widget
veltr
parents: 887
diff changeset
   396
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   397
    toggle() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   398
      if (!this.always_visible) {
923
b3ee7d1b472a UI improvements
veltr
parents: 916
diff changeset
   399
        if (this.visible) {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   400
          this.hide();
923
b3ee7d1b472a UI improvements
veltr
parents: 916
diff changeset
   401
        } else {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   402
          var t = this.media.getCurrentTime() || 0;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   403
          this.setBeginEnd(t, t);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   404
          if (this.slice_widget) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   405
            this.slice_widget.setBounds(this.begin, this.end);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   406
          }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   407
          this.show();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   408
          // Set focus on textarea
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   409
          this.$.find(".Ldt-CreateAnnotation-Description").focus();
923
b3ee7d1b472a UI improvements
veltr
parents: 916
diff changeset
   410
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   411
      }
904
510ebab76fa3 Work on CreateAnnotation Widget
veltr
parents: 887
diff changeset
   412
    }
510ebab76fa3 Work on CreateAnnotation Widget
veltr
parents: 887
diff changeset
   413
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   414
    addKeyword(_keyword) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   415
      var _field = this.$.find(".Ldt-CreateAnnotation-Description"),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   416
        _rx = ns.Model.regexpFromTextOrArray(_keyword),
904
510ebab76fa3 Work on CreateAnnotation Widget
veltr
parents: 887
diff changeset
   417
        _contents = _field.val();
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   418
      _contents = !!_contents.match(_rx)
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   419
        ? _contents.replace(_rx, "")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   420
        : _contents + " " + _keyword;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   421
      _field.val(_contents.replace(/\s{2,}/g, " ").replace(/(^\s+|\s+$)/g, ""));
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   422
      this.onDescriptionChange();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   423
    }
904
510ebab76fa3 Work on CreateAnnotation Widget
veltr
parents: 887
diff changeset
   424
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   425
    pauseOnWrite() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   426
      if (this.pause_on_write && !this.media.getPaused()) {
957
4da0a5740b6c Starting 'players-as-widgets' branch
veltr
parents: 931
diff changeset
   427
        this.media.pause();
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   428
      }
923
b3ee7d1b472a UI improvements
veltr
parents: 916
diff changeset
   429
    }
b3ee7d1b472a UI improvements
veltr
parents: 916
diff changeset
   430
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   431
    onDescriptionChange(e) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   432
      if (e !== undefined && e.keyCode == 13 && !e.shiftKey) {
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   433
        // Return: submit. Use shift-Return to insert a LF
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   434
        this.onSubmit();
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   435
        return true;
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   436
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   437
      var _field = this.$.find(".Ldt-CreateAnnotation-Description"),
904
510ebab76fa3 Work on CreateAnnotation Widget
veltr
parents: 887
diff changeset
   438
        _contents = _field.val();
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   439
      _field.css("border-color", !!_contents ? "#666666" : "#ff0000");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   440
      if (!!_contents) {
975
35aadec4131b Adapted Metadataplayer to send title and description
veltr
parents: 974
diff changeset
   441
        _field.removeClass("empty");
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   442
      } else {
975
35aadec4131b Adapted Metadataplayer to send title and description
veltr
parents: 974
diff changeset
   443
        _field.addClass("empty");
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   444
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   445
      this.$.find(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   446
        ".Ldt-CreateAnnotation-TagLi, .Ldt-CreateAnnotation-PolemicLi"
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   447
      ).each(function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   448
        var _rx = ns.Model.regexpFromTextOrArray(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   449
          jQuery(this).attr("data-text")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   450
        );
925
28efc97b5d78 Corrected MAJOR bug in search results
veltr
parents: 924
diff changeset
   451
        if (_contents.match(_rx)) {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   452
          jQuery(this).addClass("selected");
904
510ebab76fa3 Work on CreateAnnotation Widget
veltr
parents: 887
diff changeset
   453
        } else {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   454
          jQuery(this).removeClass("selected");
904
510ebab76fa3 Work on CreateAnnotation Widget
veltr
parents: 887
diff changeset
   455
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   456
      });
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   457
      this.pauseOnWrite();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   458
      return !!_contents;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   459
    }
904
510ebab76fa3 Work on CreateAnnotation Widget
veltr
parents: 887
diff changeset
   460
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   461
    onTitleChange() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   462
      var _field = this.$.find(".Ldt-CreateAnnotation-Title"),
904
510ebab76fa3 Work on CreateAnnotation Widget
veltr
parents: 887
diff changeset
   463
        _contents = _field.val();
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   464
      _field.css("border-color", !!_contents ? "#666666" : "#ff0000");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   465
      if (!!_contents) {
975
35aadec4131b Adapted Metadataplayer to send title and description
veltr
parents: 974
diff changeset
   466
        _field.removeClass("empty");
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   467
      } else {
975
35aadec4131b Adapted Metadataplayer to send title and description
veltr
parents: 974
diff changeset
   468
        _field.addClass("empty");
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   469
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   470
      this.pauseOnWrite();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   471
      return !!_contents;
975
35aadec4131b Adapted Metadataplayer to send title and description
veltr
parents: 974
diff changeset
   472
    }
923
b3ee7d1b472a UI improvements
veltr
parents: 916
diff changeset
   473
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   474
    onCreatorChange() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   475
      var _field = this.$.find(".Ldt-CreateAnnotation-Creator"),
923
b3ee7d1b472a UI improvements
veltr
parents: 916
diff changeset
   476
        _contents = _field.val();
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   477
      _field.css("border-color", !!_contents ? "#666666" : "#ff0000");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   478
      if (!!_contents) {
975
35aadec4131b Adapted Metadataplayer to send title and description
veltr
parents: 974
diff changeset
   479
        _field.removeClass("empty");
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   480
      } else {
975
35aadec4131b Adapted Metadataplayer to send title and description
veltr
parents: 974
diff changeset
   481
        _field.addClass("empty");
1072
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
      this.pauseOnWrite();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   484
      return !!_contents;
975
35aadec4131b Adapted Metadataplayer to send title and description
veltr
parents: 974
diff changeset
   485
    }
904
510ebab76fa3 Work on CreateAnnotation Widget
veltr
parents: 887
diff changeset
   486
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   487
    onSubmit() {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   488
      /* 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
   489
      if (
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   490
        !this.onDescriptionChange() ||
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   491
        (this.show_title_field && !this.onTitleChange()) ||
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   492
        (this.show_creator_field && !this.onCreatorChange())
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   493
      ) {
970
b1c3bf6eca78 Cleaning and refactoring
veltr
parents: 966
diff changeset
   494
        return false;
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   495
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   496
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   497
      var _this = this,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   498
        _exportedAnnotations = new ns.Model.List(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   499
          this.player.sourceManager
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   500
        ) /* 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
   501
        _export = this.player.sourceManager.newLocalSource({
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   502
          serializer: ns.serializers[this.api_serializer],
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   503
        }) /* 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
   504
        _local_export = this.player.sourceManager.newLocalSource({
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   505
          serializer: ns.serializers["ldt_localstorage"],
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   506
        }) /* Source object using a specific serializer for local export */,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   507
        _annotation = new ns.Model.Annotation(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   508
          false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   509
          _export
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   510
        ) /* We create an annotation in the source with a generated ID (param. false) */,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   511
        _annotationTypes = this.source
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   512
          .getAnnotationTypes()
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   513
          .searchByTitle(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   514
            this.annotation_type,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   515
            true
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   516
          ) /* 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
   517
        _annotationType = _annotationTypes.length
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   518
          ? _annotationTypes[0]
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   519
          : new ns.Model.AnnotationType(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   520
              false,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   521
              _export
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   522
            ) /* 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
   523
        _url = Mustache.render(this.api_endpoint_template, {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   524
          id: this.source.projectId,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   525
        }); /* We make the url to send the request to, must include project id */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   526
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   527
      /* If we created an AnnotationType on the spot ... */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   528
      if (!_annotationTypes.length) {
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   529
        /* ... We must not send its id to the server ... */
915
ba7aab923d08 corrections
veltr
parents: 909
diff changeset
   530
        _annotationType.dont_send_id = true;
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   531
        /* ... And we must include its title. */
928
5aadbc9f27cd First tests before allowing mashup annotation
veltr
parents: 925
diff changeset
   532
        _annotationType.title = this.annotation_type;
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   533
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   534
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   535
      /*
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   536
       * Will fill the generated annotation object's data
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   537
       * WARNING: If we're on a MASHUP, these datas must refer the ORIGINAL MEDIA
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   538
       * */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   539
      _annotation.setMedia(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   540
        this.source.currentMedia.id
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   541
      ); /* Annotated media ID */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   542
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   543
      if (this.post_at_segment_time) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   544
        var _currentTime = this.media.getCurrentTime();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   545
        var _segmentsAnnotations = this.source.getAnnotationsByTypeTitle(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   546
          this.segments_annotation_type
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   547
        );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   548
        var _currentSegments = _segmentsAnnotations.filter(function (_segment) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   549
          return _currentTime >= _segment.begin && _currentTime <= _segment.end;
1038
e78b889a75e1 CreateAnnotations new feature: hide/show functionality on signal trigger (tweaks), added config options to customize what is displayed more accurately
durandn
parents: 1033
diff changeset
   550
        });
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   551
        if (_currentSegments.length == 0) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   552
          _annotation.setBegin(this.begin); /* Widget starting timecode */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   553
          _annotation.setEnd(this.end); /* Widget end timecode */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   554
        } else {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   555
          _annotation.setBegin(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   556
            _currentSegments[0].begin
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   557
          ); /* Segment starting timecode */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   558
          _annotation.setEnd(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   559
            _currentSegments[0].end
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   560
          ); /* Segment end timecode */
1038
e78b889a75e1 CreateAnnotations new feature: hide/show functionality on signal trigger (tweaks), added config options to customize what is displayed more accurately
durandn
parents: 1033
diff changeset
   561
        }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   562
      } else {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   563
        _annotation.setBeginEnd(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   564
          this.begin,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   565
          this.end
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   566
        ); /* Widget end/start timecodes */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   567
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   568
      _annotation.setAnnotationType(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   569
        _annotationType.id
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   570
      ); /* Annotation type ID */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   571
      if (this.show_title_field) {
1067
539c9bee5372 Translating comments into English
durandn
parents: 1066
diff changeset
   572
        /* Title field, only if it's visible */
923
b3ee7d1b472a UI improvements
veltr
parents: 916
diff changeset
   573
        _annotation.title = this.$.find(".Ldt-CreateAnnotation-Title").val();
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   574
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   575
      if (this.project_id != "") {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   576
        /* 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
   577
        _annotation.project_id = this.project_id;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   578
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   579
      _annotation.created = new Date(); /* Annotation creation date */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   580
      _annotation.description = this.$.find(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   581
        ".Ldt-CreateAnnotation-Description"
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   582
      ).val(); /* Description field */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   583
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   584
      var tagIds = Array.prototype.map.call(
1003
a4dc93a91a95 Hashtags fix
veltr
parents: 1002
diff changeset
   585
        this.$.find(".Ldt-CreateAnnotation-TagLi.selected"),
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   586
        function (el) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   587
          return jQuery(el).attr("tag-id");
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
      );
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   590
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   591
      _(_annotation.description.match(/#[^\s#.,;]+/g)).each(function (_tt) {
988
eefd336335f9 Some improvements: Hashtags can be used, links are now clickable, ....
veltr
parents: 986
diff changeset
   592
        var _tag,
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   593
          _tag_title = _tt.replace(/^#/, ""),
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   594
          _tags = _this.source.getTags().searchByTitle(_tag_title, true);
988
eefd336335f9 Some improvements: Hashtags can be used, links are now clickable, ....
veltr
parents: 986
diff changeset
   595
        if (_tags.length) {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   596
          _tag = _tags[0];
988
eefd336335f9 Some improvements: Hashtags can be used, links are now clickable, ....
veltr
parents: 986
diff changeset
   597
        } else {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   598
          _tag = new ns.Model.Tag(false, _this.source);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   599
          _this.source.getTags().push(_tag);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   600
          _tag.title = _tag_title;
988
eefd336335f9 Some improvements: Hashtags can be used, links are now clickable, ....
veltr
parents: 986
diff changeset
   601
        }
1003
a4dc93a91a95 Hashtags fix
veltr
parents: 1002
diff changeset
   602
        if (tagIds.indexOf(_tag.id) === -1) {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   603
          tagIds.push(_tag.id);
1003
a4dc93a91a95 Hashtags fix
veltr
parents: 1002
diff changeset
   604
        }
1072
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
      _annotation.setTags(_(tagIds).uniq()); /* Tag ids list */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   607
      if (this.audio_url) {
966
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   608
        _annotation.audio = {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   609
          src: "mic",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   610
          mimetype: "audio/mp3",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   611
          href: this.audio_url,
966
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   612
        };
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   613
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   614
      if (this.show_creator_field) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   615
        _annotation.creator = this.$.find(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   616
          ".Ldt-CreateAnnotation-Creator"
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   617
        ).val();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   618
      } else {
974
560afb14296d Annotations now fit the new rest api
veltr
parents: 970
diff changeset
   619
        _annotation.creator = this.creator_name;
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
      _exportedAnnotations.push(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   622
        _annotation
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   623
      ); /* Ajout de l'annotation à la liste à exporter */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   624
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   625
      if (this.editable_storage != "") {
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   626
        // Append to localStorage annotations
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   627
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   628
        // FIXME: handle movie ids
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   629
        _local_export.addList(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   630
          "annotation",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   631
          _exportedAnnotations
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   632
        ); /* Ajout de la liste à exporter à l'objet Source */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   633
        _this.source.merge(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   634
          _local_export
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   635
        ); /* On ajoute la nouvelle annotation au recueil original */
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   636
        // Import previously saved local annotations
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   637
        if (window.localStorage[this.editable_storage]) {
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   638
          _local_export.deSerialize(window.localStorage[this.editable_storage]);
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   639
        }
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   640
        // Save everything back
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   641
        window.localStorage[_this.editable_storage] = _local_export.serialize();
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   642
        _this.player.trigger(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   643
          "AnnotationsList.refresh"
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   644
        ); /* On force le rafraîchissement du widget AnnotationsList */
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   645
        _this.player.trigger("Annotation.create", _annotation);
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   646
        _this.$.find(".Ldt-CreateAnnotation-Description").val("");
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   647
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   648
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   649
      if (_url !== "") {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   650
        _exportedAnnotations.push(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   651
          _annotation
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   652
        ); /* 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
   653
        _export.addList(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   654
          "annotation",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   655
          _exportedAnnotations
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   656
        ); /* We add the list to the source object */
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   657
        var _this = this;
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   658
        /* We send the AJAX request to the server ! */
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   659
        jQuery.ajax({
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   660
          url: _url,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   661
          type: this.api_method,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   662
          contentType: "application/json",
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   663
          data: _export.serialize() /* Source is serialized */,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   664
          success: function (_data) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   665
            _this.showScreen("Saved");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   666
            if (_this.after_send_timeout) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   667
              window.setTimeout(function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   668
                _this.close_after_send
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   669
                  ? _this.player.trigger("CreateAnnotation.hide")
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   670
                  : _this.player.trigger("CreateAnnotation.show");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   671
              }, _this.after_send_timeout);
1038
e78b889a75e1 CreateAnnotations new feature: hide/show functionality on signal trigger (tweaks), added config options to customize what is displayed more accurately
durandn
parents: 1033
diff changeset
   672
            }
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   673
            _export
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   674
              .getAnnotations()
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   675
              .removeElement(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   676
                _annotation,
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   677
                true
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   678
              ); /* 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
   679
            _export.deSerialize(_data); /* Data deserialization */
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   680
            _this.source.merge(
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   681
              _export
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   682
            ); /* 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
   683
            if (_this.pause_on_write && _this.media.getPaused()) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   684
              _this.media.play();
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   685
            }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   686
            _this.player.trigger("AnnotationsList.refresh");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   687
          },
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   688
          error: function (_xhr, _error, _thrown) {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   689
            ns.log("Error when sending annotation", _thrown);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   690
            _export.getAnnotations().removeElement(_annotation, true);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   691
            _this.showScreen("Error");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   692
            window.setTimeout(function () {
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   693
              _this.showScreen("Main");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   694
            }, _this.after_send_timeout || 5000);
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   695
          },
1068
7623f9af9272 merge pull request #3 from O. Auber
ymh <ymh.work@gmail.com>
parents: 1067
diff changeset
   696
        });
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   697
        this.showScreen("Wait");
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   698
      }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   699
      return false;
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   700
    }
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   701
  };
1013
392ddcd212d7 Throwed in a bunch of semicolons
veltr
parents: 1003
diff changeset
   702
};
1038
e78b889a75e1 CreateAnnotations new feature: hide/show functionality on signal trigger (tweaks), added config options to customize what is displayed more accurately
durandn
parents: 1033
diff changeset
   703
1072
ac1eacb3aa33 Migrate source and build to vite.js
ymh <ymh.work@gmail.com>
parents: 1069
diff changeset
   704
export { CreateAnnotation, createAnnotationStyles };