src/ldt/ldt/static/ldt/metadataplayer/AnnotationsList.js
author durandn
Fri, 02 Oct 2015 10:24:05 +0200
changeset 1447 470130d647cb
parent 1445 b4c525005cde
child 1452 9b5efbd99a14
permissions -rw-r--r--
import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
     1
IriSP.Widgets.AnnotationsList = function(player, config) {
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
     2
    IriSP.Widgets.Widget.call(this, player, config);
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
     3
    this.lastIds = [];
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
     4
    var _this = this;
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
     5
    this.throttledRefresh = IriSP._.throttle(function(full) {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
     6
        _this.refresh(full);
962
d600fa967511 New Search in Metadataplayer
veltr
parents: 875
diff changeset
     7
    }, 800);
d600fa967511 New Search in Metadataplayer
veltr
parents: 875
diff changeset
     8
    this.searchString = false;
d600fa967511 New Search in Metadataplayer
veltr
parents: 875
diff changeset
     9
    this.lastSearch = false;
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
    10
    this.localSource = undefined;
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
    11
};
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
    12
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
    13
IriSP.Widgets.AnnotationsList.prototype = new IriSP.Widgets.Widget();
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
    14
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
    15
IriSP.Widgets.AnnotationsList.prototype.defaults = {
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
    16
    pre_draw_callback: function(){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
    17
        return this.importUsers();
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
    18
    },
1387
82d256129376 Small tweaks to Annotation API and json project API and mdplayer widgets CreateAnnotation and AnnotationList to allow CreateAnnotation to create annotations on a specific project and AnnotationList to display different annotation types as well as filtering annotations based on current segment
durandn
parents: 1270
diff changeset
    19
    /*
82d256129376 Small tweaks to Annotation API and json project API and mdplayer widgets CreateAnnotation and AnnotationList to allow CreateAnnotation to create annotations on a specific project and AnnotationList to display different annotation types as well as filtering annotations based on current segment
durandn
parents: 1270
diff changeset
    20
     * URL when the annotations are to be reloaded from an LDT-like segment API
82d256129376 Small tweaks to Annotation API and json project API and mdplayer widgets CreateAnnotation and AnnotationList to allow CreateAnnotation to create annotations on a specific project and AnnotationList to display different annotation types as well as filtering annotations based on current segment
durandn
parents: 1270
diff changeset
    21
     * e.g.
82d256129376 Small tweaks to Annotation API and json project API and mdplayer widgets CreateAnnotation and AnnotationList to allow CreateAnnotation to create annotations on a specific project and AnnotationList to display different annotation types as well as filtering annotations based on current segment
durandn
parents: 1270
diff changeset
    22
     * http://ldt.iri.centrepompidou.fr/ldtplatform/api/ldt/segments/{{media}}/{{begin}}/{{end}}?callback=?
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
    23
     */
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
    24
    ajax_url : false,
1387
82d256129376 Small tweaks to Annotation API and json project API and mdplayer widgets CreateAnnotation and AnnotationList to allow CreateAnnotation to create annotations on a specific project and AnnotationList to display different annotation types as well as filtering annotations based on current segment
durandn
parents: 1270
diff changeset
    25
    /*
82d256129376 Small tweaks to Annotation API and json project API and mdplayer widgets CreateAnnotation and AnnotationList to allow CreateAnnotation to create annotations on a specific project and AnnotationList to display different annotation types as well as filtering annotations based on current segment
durandn
parents: 1270
diff changeset
    26
     * number of milliseconds before/after the current timecode when calling the
82d256129376 Small tweaks to Annotation API and json project API and mdplayer widgets CreateAnnotation and AnnotationList to allow CreateAnnotation to create annotations on a specific project and AnnotationList to display different annotation types as well as filtering annotations based on current segment
durandn
parents: 1270
diff changeset
    27
     * segment API
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
    28
     */
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
    29
    ajax_granularity : 600000,
697
062376213732 Added MDPlayer configuration options
veltr
parents: 696
diff changeset
    30
    default_thumbnail : "",
1387
82d256129376 Small tweaks to Annotation API and json project API and mdplayer widgets CreateAnnotation and AnnotationList to allow CreateAnnotation to create annotations on a specific project and AnnotationList to display different annotation types as well as filtering annotations based on current segment
durandn
parents: 1270
diff changeset
    31
    /*
82d256129376 Small tweaks to Annotation API and json project API and mdplayer widgets CreateAnnotation and AnnotationList to allow CreateAnnotation to create annotations on a specific project and AnnotationList to display different annotation types as well as filtering annotations based on current segment
durandn
parents: 1270
diff changeset
    32
     * URL when the annotation is not in the current project, e.g.
82d256129376 Small tweaks to Annotation API and json project API and mdplayer widgets CreateAnnotation and AnnotationList to allow CreateAnnotation to create annotations on a specific project and AnnotationList to display different annotation types as well as filtering annotations based on current segment
durandn
parents: 1270
diff changeset
    33
     * http://ldt.iri.centrepompidou.fr/ldtplatform/ldt/front/player/{{media}}/{{project}}/{{annotationType}}#id={{annotation}}
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
    34
     */
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
    35
    foreign_url : "",
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
    36
    annotation_type : false,
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
    37
    refresh_interval : 0,
806
37bad74c2520 Added Voice Annotation Support in MDP
veltr
parents: 794
diff changeset
    38
    limit_count : 20,
696
b431fb1fd480 Corrections on the new Metadataplayer
veltr
parents: 695
diff changeset
    39
    newest_first : false,
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
    40
    show_title: true,
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
    41
    show_audio: true,
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
    42
    show_creator: true,
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
    43
    show_controls: false,
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
    44
    show_end_time: true,
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
    45
    show_publish: false,
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
    46
    show_twitter: false,
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
    47
    twitter_hashtag: '',
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
    48
    // Callback for Edit action. Leave undefined for default action.
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
    49
    on_edit: undefined,
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
    50
    publish_type: "PublicContribution",
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
    51
    // Used to publish annotations
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
    52
    api_endpoint_template: "",
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
    53
    api_serializer: "ldt_annotate",
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
    54
    api_method: "POST",
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
    55
    editable: false,
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
    56
    // Id that will be used as localStorage key
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
    57
    editable_storage: "",
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
    58
1390
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
    59
    always_visible : false,
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
    60
    start_visible: true,
1394
5eecb7d31547 Tweaks to hide/show elements for several widgets to adjust for remie scenarii + More work on new widgets
durandn
parents: 1390
diff changeset
    61
    show_audio : true,
5eecb7d31547 Tweaks to hide/show elements for several widgets to adjust for remie scenarii + More work on new widgets
durandn
parents: 1390
diff changeset
    62
    show_filters : false,
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
    63
    keyword_filter: true,
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
    64
    date_filter: true,
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
    65
    user_filter: true,
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
    66
    segment_filter: true,
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
    67
    latest_contributions_filter: false,
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
    68
    current_day_filter: true,
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
    69
    show_header : false,
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
    70
    custom_header : false,
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
    71
    annotations_count_header : true,
1394
5eecb7d31547 Tweaks to hide/show elements for several widgets to adjust for remie scenarii + More work on new widgets
durandn
parents: 1390
diff changeset
    72
    show_creation_date : false,
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
    73
    show_timecode : true,
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
    74
    project_id: "",
1389
a2316b574499 Added a filter based on annotation user name for AnnotationList metadataplayer widget + Added a way to make the creator field readonly for CreateAnnotation widget (so you can define a given annotation creator name for the widget that the user can't change)
durandn
parents: 1388
diff changeset
    75
    /*
a2316b574499 Added a filter based on annotation user name for AnnotationList metadataplayer widget + Added a way to make the creator field readonly for CreateAnnotation widget (so you can define a given annotation creator name for the widget that the user can't change)
durandn
parents: 1388
diff changeset
    76
     * Only annotation in the current segment will be displayed. Designed to work with the Segments Widget.
a2316b574499 Added a filter based on annotation user name for AnnotationList metadataplayer widget + Added a way to make the creator field readonly for CreateAnnotation widget (so you can define a given annotation creator name for the widget that the user can't change)
durandn
parents: 1388
diff changeset
    77
     */
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
    78
    allow_annotations_deletion: false,
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
    79
    /*
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
    80
     * URL to call when deleting annotation. Expects a mustache template with {{annotation_id}}, ex /api/anotations/{{annotation_id}}/
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
    81
     */
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
    82
    api_delete_endpoint : "",
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
    83
    api_delete_method: "DELETE",
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
    84
    api_users_endpoint: "",
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
    85
    api_users_method: "GET",
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
    86
    make_name_string_function: function(params){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
    87
        return params.username ? params.username : "Anonymous";
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
    88
    },
1387
82d256129376 Small tweaks to Annotation API and json project API and mdplayer widgets CreateAnnotation and AnnotationList to allow CreateAnnotation to create annotations on a specific project and AnnotationList to display different annotation types as well as filtering annotations based on current segment
durandn
parents: 1270
diff changeset
    89
    filter_by_segments: false,
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
    90
    segment_filter: true,
1387
82d256129376 Small tweaks to Annotation API and json project API and mdplayer widgets CreateAnnotation and AnnotationList to allow CreateAnnotation to create annotations on a specific project and AnnotationList to display different annotation types as well as filtering annotations based on current segment
durandn
parents: 1270
diff changeset
    91
    segments_annotation_type: "chap",
1389
a2316b574499 Added a filter based on annotation user name for AnnotationList metadataplayer widget + Added a way to make the creator field readonly for CreateAnnotation widget (so you can define a given annotation creator name for the widget that the user can't change)
durandn
parents: 1388
diff changeset
    92
    /*
a2316b574499 Added a filter based on annotation user name for AnnotationList metadataplayer widget + Added a way to make the creator field readonly for CreateAnnotation widget (so you can define a given annotation creator name for the widget that the user can't change)
durandn
parents: 1388
diff changeset
    93
     * Set to a username if you only want to display annotations from a given user
a2316b574499 Added a filter based on annotation user name for AnnotationList metadataplayer widget + Added a way to make the creator field readonly for CreateAnnotation widget (so you can define a given annotation creator name for the widget that the user can't change)
durandn
parents: 1388
diff changeset
    94
     */
a2316b574499 Added a filter based on annotation user name for AnnotationList metadataplayer widget + Added a way to make the creator field readonly for CreateAnnotation widget (so you can define a given annotation creator name for the widget that the user can't change)
durandn
parents: 1388
diff changeset
    95
    show_only_annotation_from_user: false,
1390
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
    96
    /*
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
    97
     * Show a text field that filter annotations by username
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
    98
     */
1394
5eecb7d31547 Tweaks to hide/show elements for several widgets to adjust for remie scenarii + More work on new widgets
durandn
parents: 1390
diff changeset
    99
    tags : true,
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   100
696
b431fb1fd480 Corrections on the new Metadataplayer
veltr
parents: 695
diff changeset
   101
    polemics : [{
b431fb1fd480 Corrections on the new Metadataplayer
veltr
parents: 695
diff changeset
   102
        keyword: "++",
b431fb1fd480 Corrections on the new Metadataplayer
veltr
parents: 695
diff changeset
   103
        background_color: "#c9ecc6"
b431fb1fd480 Corrections on the new Metadataplayer
veltr
parents: 695
diff changeset
   104
    },{
b431fb1fd480 Corrections on the new Metadataplayer
veltr
parents: 695
diff changeset
   105
        keyword: "--",
b431fb1fd480 Corrections on the new Metadataplayer
veltr
parents: 695
diff changeset
   106
        background_color: "#f9c5c6"
b431fb1fd480 Corrections on the new Metadataplayer
veltr
parents: 695
diff changeset
   107
    },{
b431fb1fd480 Corrections on the new Metadataplayer
veltr
parents: 695
diff changeset
   108
        keyword: "??",
b431fb1fd480 Corrections on the new Metadataplayer
veltr
parents: 695
diff changeset
   109
        background_color: "#cec5f9"
b431fb1fd480 Corrections on the new Metadataplayer
veltr
parents: 695
diff changeset
   110
    },{
b431fb1fd480 Corrections on the new Metadataplayer
veltr
parents: 695
diff changeset
   111
        keyword: "==",
b431fb1fd480 Corrections on the new Metadataplayer
veltr
parents: 695
diff changeset
   112
        background_color: "#f9f4c6"
b431fb1fd480 Corrections on the new Metadataplayer
veltr
parents: 695
diff changeset
   113
    }]
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   114
};
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   115
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   116
IriSP.Widgets.AnnotationsList.prototype.importUsers = function(){
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   117
    if (!this.source.users_data && this.api_users_endpoint){
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   118
        this.usernames = Array();
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   119
        var _this = this,
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   120
            _list = this.getWidgetAnnotations(),
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   121
            usernames_list_string = "";
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   122
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   123
        _list.forEach(function(_annotation){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   124
            if(_this.usernames.indexOf(_annotation.creator) == -1){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   125
                _this.usernames.push(_annotation.creator);
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   126
            }
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   127
        });
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   128
        this.usernames.forEach(function(_username){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   129
            usernames_list_string+=_username+","
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   130
        })
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   131
        usernames_list_string = usernames_list_string.substring(0, usernames_list_string.length - 1);
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   132
        _url = Mustache.to_html(this.api_users_endpoint, {usernames_list_string: encodeURIComponent(usernames_list_string), usernames_list_length: this.usernames.length});
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   133
        return IriSP.jQuery.ajax({
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   134
            async: false,
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   135
            url: _url,
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   136
            type: "GET",
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   137
            success: function(_data) {
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   138
                _this.source.users_data = _data.objects
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   139
            },
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   140
            error: function(_xhr, _error, _thrown) {
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   141
                console.log(_xhr)
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   142
                console.log(_error)
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   143
                console.log(_thrown)
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   144
            }
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   145
        })
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   146
    }
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   147
}
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   148
806
37bad74c2520 Added Voice Annotation Support in MDP
veltr
parents: 794
diff changeset
   149
IriSP.Widgets.AnnotationsList.prototype.messages = {
37bad74c2520 Added Voice Annotation Support in MDP
veltr
parents: 794
diff changeset
   150
    en: {
37bad74c2520 Added Voice Annotation Support in MDP
veltr
parents: 794
diff changeset
   151
        voice_annotation: "Voice Annotation",
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   152
        now_playing: "Now playing...",
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   153
        previous: "Previous",
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   154
        next: "Next",
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   155
        set_time: "Double-click to update to current player time",
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   156
        edit_annotation: "Edit note",
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   157
        delete_annotation: "Delete note",
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   158
        publish_annotation: "Make note public",
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   159
        import_annotations: "Paste or load notes in this field and press Import.",
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   160
        confirm_delete_message: "You are about to delete {{ annotation.title }}. Are you sure you want to delete it?",
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   161
        confirm_publish_message: "You are about to publish {{ annotation.title }}. Are you sure you want to make it public?",
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   162
        tweet_annotation: "Tweet annotation",
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   163
        everyone: "Everyone",
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   164
        header: "Annotations for this content",
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   165
        segment_filter: "All cuttings",
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   166
        latest_contributions: "Latest contributions",
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   167
        close_widget: "Close",
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   168
        confirm: "Confirm",
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   169
        cancel: "Cancel",
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   170
        annotation_deletion_delete: "You will delete this annotation : ",
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   171
        annotation_deletion_sending: "Your deletion request is being sent ... ",
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   172
        annotation_deletion_success: "The annotation has been deleted.",
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   173
        annotation_deletion_error: "There was an error contacting the server. The annotation has not been deleted."
806
37bad74c2520 Added Voice Annotation Support in MDP
veltr
parents: 794
diff changeset
   174
    },
37bad74c2520 Added Voice Annotation Support in MDP
veltr
parents: 794
diff changeset
   175
    fr: {
37bad74c2520 Added Voice Annotation Support in MDP
veltr
parents: 794
diff changeset
   176
        voice_annotation: "Annotation Vocale",
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   177
        now_playing: "Lecture en cours...",
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   178
        previous: "Précédent",
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   179
        next: "Suivant",
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   180
        set_time: "Double-cliquer pour fixer au temps du lecteur",
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   181
        edit_annotation: "Éditer la note",
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   182
        delete_annotation: "Supprimer la note",
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   183
        publish_annotation: "Rendre la note publique",
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   184
        import_annotations: "Copiez ou chargez des notes dans ce champ et appuyez sur Import",
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   185
        confirm_delete_message: "Vous allez supprimer {{ annotation.title }}. Êtes-vous certain(e) ?",
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   186
        confirm_publish_message: "Vous allez publier {{ annotation.title }}. Êtes-vous certain(e) ?",
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   187
        tweet_annotation: "Tweeter l'annotation",
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   188
        everyone: "Tous",
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   189
        header: "Annotations sur ce contenu",
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   190
        segment_filter: "Tous les segments",
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   191
        latest_contributions: "Dernières contributions",
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   192
        close_widget: "Fermer",
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   193
        confirm: "Confirmer",
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   194
        cancel: "Annuler",
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   195
        annotation_deletion_delete: "Vous allez supprimer cette annotation: ",
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   196
        annotation_deletion_sending: "Votre demande de suppression est en cours d'envoi ... ",
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   197
        annotation_deletion_success: "L'annotation a été supprimée.",
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   198
        annotation_deletion_error: "Une erreur s'est produite en contactant le serveur. L'annotation n'a pas été supprimée."
806
37bad74c2520 Added Voice Annotation Support in MDP
veltr
parents: 794
diff changeset
   199
    }
1235
9eee31426156 Upgrade metadataplayer
veltr
parents: 1230
diff changeset
   200
};
806
37bad74c2520 Added Voice Annotation Support in MDP
veltr
parents: 794
diff changeset
   201
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   202
IriSP.Widgets.AnnotationsList.prototype.template =
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   203
    '{{#show_header}}<p class="Ldt-AnnotationsList-header">'
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   204
    +     '{{#custom_header}}{{custom_header}}{{/custom_header}}'
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   205
    +     '{{^custom_header}}{{l10n.header}}{{/custom_header}}'
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   206
    + '</p>{{/show_header}}'
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   207
    + '<div class="Ldt-AnnotationsListWidget">'
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   208
    +     '<div class="Ldt-AnnotationsList-ScreenMain">'
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   209
    +         '{{#show_filters}}'
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   210
    +         '<div class="Ldt-AnnotationsList-Filters">'
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   211
    +             '{{#keyword_filter}}<input class="Ldt-AnnotationsList-filter-text" id="Ldt-AnnotationsList-keywordsFilter" type="text" value=""></input>{{/keyword_filter}}'
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   212
    +             '{{#user_filter}}<select class="Ldt-AnnotationsList-filter-dropdown" id="Ldt-AnnotationsList-userFilter"><option selected value="">{{l10n.everyone}}</option></select>{{/user_filter}}'
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   213
    +             '{{#date_filter}}<label class="Ldt-AnnotationsList-filter-date">Date: <input id="Ldt-AnnotationsList-dateFilter" type="text"></input></label>{{/date_filter}}'
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   214
    +             '{{#segment_filter}}<label class="Ldt-AnnotationsList-filter-checkbox"><input type="checkbox" id="Ldt-AnnotationsList-ignoreSegmentsFilter">{{l10n.segment_filter}}</label>{{/segment_filter}}'
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   215
    +             '{{#latest_contributions_filter}}<label class="Ldt-AnnotationsList-filter-checkbox"><input type="checkbox" id="Ldt-AnnotationsList-latestContributionsFilter">{{l10n.latest_contributions}}</label>{{/latest_contributions_filter}}'
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   216
    +         '</div>'
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   217
    +         '{{/show_filters}}'
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   218
    +         '{{#show_controls}}<div class="Ldt-AnnotationsList-Controls"><span class="Ldt-AnnotationsList-Control-Prev">{{ l10n.previous }}</span> | <span class="Ldt-AnnotationsList-Control-Next">{{ l10n.next }}</span></div>{{/show_controls}}'
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   219
    +         '{{#show_audio}}<div class="Ldt-AnnotationsList-Audio"></div>{{/show_audio}}'
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   220
    +         '<ul class="Ldt-AnnotationsList-ul">'
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   221
    +         '</ul>'
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   222
    +     '</div>'    
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   223
    +     '{{#allow_annotations_deletion}}'
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   224
    +     '<div data-annotation="{{id}}" class="Ldt-AnnotationsList-Screen Ldt-AnnotationsList-ScreenDelete">'
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   225
    +         '<a title="{{l10n.close_widget}}" class="Ldt-AnnotationsList-Close" href="#"></a>' 
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   226
    +         '<ul class="Ldt-AnnotationsList-ul-ToDelete"></ul>'
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   227
    +         '{{l10n.annotation_deletion_delete}} <a class="Ldt-AnnotationsList-ConfirmDelete">{{l10n.confirm}}</a> <a class="Ldt-AnnotationsList-CancelDelete">{{l10n.cancel}}</a>'
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   228
    +     '</div>'
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   229
    +     '<div data-annotation="{{id}}" class="Ldt-AnnotationsList-Screen Ldt-AnnotationsList-ScreenSending">'
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   230
    +         '<a title="{{l10n.close_widget}}" class="Ldt-AnnotationsList-Close" href="#"></a>'  
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   231
    +         '{{l10n.annotation_deletion_sending}}'
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   232
    +     '</div>'
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   233
    +     '<div data-annotation="{{id}}" class="Ldt-AnnotationsList-Screen Ldt-AnnotationsList-ScreenSuccess">'
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   234
    +         '<a title="{{l10n.close_widget}}" class="Ldt-AnnotationsList-Close" href="#"></a>'  
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   235
    +         '{{l10n.annotation_deletion_success}}'
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   236
    +     '</div>'
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   237
    +     '<div data.annotation="{{id}}" class="Ldt-AnnotationsList-Screen Ldt-AnnotationsList-ScreenError">'
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   238
    +         '<a title="{{l10n.close_widget}}" class="Ldt-AnnotationsList-Close" href="#"></a>'  
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   239
    +         '{{l10n.annotation_deletion_error}}'
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   240
    +     '</div>'
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   241
    +     '{{/allow_annotations_deletion}}'
764
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   242
    + '</div>';
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   243
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   244
IriSP.Widgets.AnnotationsList.prototype.annotationTemplate =
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   245
    '<li class="Ldt-AnnotationsList-li Ldt-Highlighter-Annotation Ldt-TraceMe" data-annotation="{{ id }}" data-begin="{{ begin_ms }}" data-end="{{ end_ms }}" trace-info="annotation-id:{{id}}, media-id:{{media_id}}" style="{{specific_style}}">'
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   246
    + '<div data-annotation="{{ id }}" class="Ldt-AnnotationsList-ThumbContainer Ldt-AnnotationsList-Annotation-Screen Ldt-AnnotationsList-Annotation-ScreenMain">'
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   247
    +   '<a href="{{url}}" draggable="true">'
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   248
    +     '<img title="{{ begin }} - {{ title }}" class="Ldt-AnnotationsList-Thumbnail" src="{{thumbnail}}" />'
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   249
    +   '</a>'
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   250
    + '</div>'
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   251
    + '{{#allow_annotations_deletion}}'
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   252
    + '<div data-annotation="{{ id }}" class="Ldt-AnnotationsList-DeleteButton">&#10006;</div>'
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   253
    + '{{/allow_annotations_deletion}}'
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   254
    + '{{#show_timecode}}<div title="{{l10n.set_time}}" class="Ldt-AnnotationsList-Duration"><span class="Ldt-AnnotationsList-Begin Ldt-live-editable Ldt-AnnotationsList-TimeEdit" data-editable_value="{{begin}}" data-editable_id="{{id}}" data-editable_field="begin" data-editable_type="timestamp">{{begin}}</span>{{#show_end_time}} - <span class="Ldt-AnnotationsList-End Ldt-live-editable" data-editable_value="{{end}}" data-editable_id="{{id}}" data-editable_field="end" data-editable_type="timestamp">{{end}}</span>{{/show_end_time}}</div>{{/show_timecode}}'
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   255
    + '<h3 class="Ldt-AnnotationsList-Title Ldt-Annotation-Timecode" data-timecode="{{ begin_ms }}" draggable="true">'
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   256
    + '{{#show_title}}<span class="Ldt-AnnotationsList-TitleContent Ldt-live-editable" data-editable_value="{{title}}" data-editable_type="multiline" data-editable_id="{{id}}" data-editable_field="title">{{{htitle}}}</span>{{/show_title}}'
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   257
    + '{{#show_creator}}<span class="Ldt-AnnotationsList-Creator">{{ creator }}</span>{{/show_creator}}'
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   258
    + '</h3>'
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   259
    + '<p class="Ldt-AnnotationsList-Description Ldt-live-editable" data-editable_type="multiline" data-editable_value="{{description}}" data-editable_id="{{id}}" data-editable_field="description">{{{hdescription}}}</p>'
1388
cc17e3d211cd Added option to display creation date of annotations in AnnotationList metadataplayer widget
durandn
parents: 1387
diff changeset
   260
    + '{{#created}}'
cc17e3d211cd Added option to display creation date of annotations in AnnotationList metadataplayer widget
durandn
parents: 1387
diff changeset
   261
    + '<div class="Ldt-AnnotationsList-CreationDate">{{{created}}}</div>'
cc17e3d211cd Added option to display creation date of annotations in AnnotationList metadataplayer widget
durandn
parents: 1387
diff changeset
   262
    + '{{/created}}'
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   263
    + '{{#tags.length}}'
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   264
    + '<ul class="Ldt-AnnotationsList-Tags">'
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   265
    +   '{{#tags}}'
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   266
    +   '{{#.}}'
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   267
    +   '<li class="Ldt-AnnotationsList-Tag-Li">'
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   268
    +     '<span>{{.}}</span>'
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   269
    +   '</li>'
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   270
    +   '{{/.}}'
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   271
    +   '{{/tags}}'
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   272
    + '</ul>'
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   273
    + '{{/tags.length}}'
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   274
    + '{{#audio}}<div class="Ldt-AnnotationsList-Play" data-annotation-id="{{id}}">{{l10n.voice_annotation}}</div>{{/audio}}'
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   275
    + '<div class="Ldt-AnnotationsList-EditControls">'
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   276
    +    '{{#show_twitter}}<a title="{{l10n.tweet_annotation}}" target="_blank" href="https://twitter.com/intent/tweet?{{twitter_param}}"><img width="16" height="16" src="metadataplayer/img/twitter.svg"></a>{{/show_twitter}}'
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   277
    +    '{{#show_publish}}<div title="{{l10n.publish_annotation}}" class="Ldt-AnnotationsList-PublishAnnotation" data-editable_id="{{id}}"></div>{{/show_publish}}'
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   278
    +    '{{#editable}}<div title="{{l10n.edit_annotation}}" class="Ldt-AnnotationsList-Edit" data-editable_id="{{id}}"></div>'
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   279
    +    '<div title="{{l10n.delete_annotation}}" class="Ldt-AnnotationsList-Delete" data-editable_id="{{id}}"></div>{{/editable}}'
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   280
    + '</div>'
764
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   281
    + '</li>';
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   282
1387
82d256129376 Small tweaks to Annotation API and json project API and mdplayer widgets CreateAnnotation and AnnotationList to allow CreateAnnotation to create annotations on a specific project and AnnotationList to display different annotation types as well as filtering annotations based on current segment
durandn
parents: 1270
diff changeset
   283
// obj.url = this.project_url + "/" + media + "/" + annotations[i].meta.project
82d256129376 Small tweaks to Annotation API and json project API and mdplayer widgets CreateAnnotation and AnnotationList to allow CreateAnnotation to create annotations on a specific project and AnnotationList to display different annotation types as well as filtering annotations based on current segment
durandn
parents: 1270
diff changeset
   284
// + "/" + annotations[i].meta["id-ref"] + '#id=' + annotations[i].id;
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   285
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   286
IriSP.Widgets.AnnotationsList.prototype.ajaxSource = function() {
784
18dfa62b411a Update of the Metadataplayer
veltr
parents: 764
diff changeset
   287
    var _currentTime = this.media.getCurrentTime(),
18dfa62b411a Update of the Metadataplayer
veltr
parents: 764
diff changeset
   288
        _duration = this.media.duration;
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   289
    this.lastAjaxQuery = _currentTime;
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   290
    var _url = Mustache.to_html(this.ajax_url, {
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   291
        media : this.source.currentMedia.id,
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   292
        begin : Math.max(0, _currentTime - this.ajax_granularity),
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   293
        end : Math.min(_duration.milliseconds, _currentTime + this.ajax_granularity)
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   294
    });
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   295
    this.currentSource = this.player.loadMetadata(IriSP._.defaults({
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   296
        "url" : _url
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   297
    }, this.metadata));
1235
9eee31426156 Upgrade metadataplayer
veltr
parents: 1230
diff changeset
   298
};
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   299
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   300
IriSP.Widgets.AnnotationsList.prototype.showScreen = function(_screenName) {
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   301
    this.$.find('.Ldt-AnnotationsList-Screen' + _screenName).show()
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   302
        .siblings().hide();
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   303
}
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   304
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   305
IriSP.Widgets.AnnotationsList.prototype.ajaxMashup = function() {
784
18dfa62b411a Update of the Metadataplayer
veltr
parents: 764
diff changeset
   306
    var _currentTime = this.media.getCurrentTime();
18dfa62b411a Update of the Metadataplayer
veltr
parents: 764
diff changeset
   307
    var _currentAnnotation = this.source.currentMedia.getAnnotationAtTime(_currentTime);
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   308
    if (typeof _currentAnnotation !== "undefined" && _currentAnnotation.id !== this.lastMashupAnnotation) {
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   309
        this.lastMashupAnnotation = _currentAnnotation.id;
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   310
        var _currentMedia = _currentAnnotation.getMedia(),
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   311
            _url = Mustache.to_html(this.ajax_url, {
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   312
                media : _currentMedia.id,
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   313
                begin : Math.max(0, _currentAnnotation.annotation.begin.milliseconds - this.ajax_granularity),
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   314
                end : Math.min(_currentMedia.duration.milliseconds, _currentAnnotation.annotation.end.milliseconds + this.ajax_granularity)
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   315
            });
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   316
        this.currentSource = this.player.loadMetadata(IriSP._.defaults({
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   317
            "url" : _url
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   318
        }, this.metadata));
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   319
    }
1235
9eee31426156 Upgrade metadataplayer
veltr
parents: 1230
diff changeset
   320
};
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   321
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   322
/*
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   323
 * Import annotations
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   324
 */
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   325
IriSP.Widgets.AnnotationsList.prototype.importAnnotations = function () {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   326
    var widget = this;
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   327
    var $ = IriSP.jQuery;
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   328
    var textarea = $("<textarea>");
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   329
    var el = $("<div>")
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   330
            .append($("<span>")
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   331
                    .addClass("importAnnotationsLabel")
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   332
                    .text(widget.messages.import_annotations))
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   333
            .addClass("importContainer")
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   334
            .dialog({
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   335
                title: "Annotation import",
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   336
                autoOpen: true,
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   337
                width: '80%',
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   338
                minHeight: '400',
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   339
                height: 400,
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   340
                buttons: [ { text: "Close", click: function() { $( this ).dialog( "close" ); } },
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   341
                           // { text: "Load", click: function () {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   342
                           //     // TODO
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   343
                           //     // http://www.html5rocks.com/en/tutorials/file/dndfiles/?redirect_from_locale=fr
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   344
                           //     console.log("Load from a file");
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   345
                           // } },
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   346
                           { text: "Import", click: function () {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   347
                               // FIXME: this should be a model.Source method
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   348
                               var time_regexp = /(\[[\d:]+\])/;
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   349
                               console.log("Import data");
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   350
                               // widget.localSource
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   351
                               // Dummy parsing for the moment
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   352
                               var data = textarea[0].value
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   353
                                       .split(time_regexp)
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   354
                                       .filter( function (s) { return ! s.match(/^\s*$/)});
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   355
                               var begin = null,
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   356
                                   end = null,
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   357
                                   content = null,
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   358
                                   // Previous is either null, timestamp or text
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   359
                                   previous = null;
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   360
                               for (var i = 0; i < data.length; i++) {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   361
                                   var el = data[i];
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   362
                                   if (el.match(time_regexp)) {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   363
                                       if (previous == 'text') {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   364
                                           // Timestamp following text. Let's make it an annotation
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   365
                                           end = IriSP.timestamp2ms(el.slice(1, -1));
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   366
                                           TODO.createAnnotation(begin, end, content);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   367
                                           // Preserve the end value, which may be the begin value of the next annotation.
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   368
                                           begin = end;
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   369
                                           end = null;
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   370
                                           content = null;
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   371
                                       } else {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   372
                                           //  (previous == 'timestamp' || previous == null)
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   373
                                           // 2 consecutive timestamps. Let's start a new annotation
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   374
                                           content = null;
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   375
                                           begin = IriSP.timestamp2ms(el.slice(1, -1));
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   376
                                           end = null;
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   377
                                       };
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   378
                                       previous = 'timestamp';
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   379
                                   } else {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   380
                                       // Text content
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   381
                                       content = el;
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   382
                                       previous = 'text';
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   383
                                   }
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   384
                                   // Last textual value
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   385
                                   if (previous == 'text' && begin !== null) {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   386
                                       TODO.createAnnotation(begin, begin, content);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   387
                                   }
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   388
                               }
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   389
                           } } ]
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   390
            });
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   391
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   392
}
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   393
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   394
IriSP.Widgets.AnnotationsList.prototype.refresh = function(_forceRedraw) {
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   395
    _forceRedraw = (typeof _forceRedraw !== "undefined" && _forceRedraw);
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   396
    if (this.currentSource.status !== IriSP.Model._SOURCE_STATUS_READY) {
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   397
        return 0;
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   398
    }
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   399
    var _this = this,
784
18dfa62b411a Update of the Metadataplayer
veltr
parents: 764
diff changeset
   400
        _currentTime = this.media.getCurrentTime();
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   401
    var _list = this.annotation_type ? this.currentSource.getAnnotationsByTypeTitle(this.annotation_type) : this.currentSource.getAnnotations();
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   402
    if (this.mashupMode) {
784
18dfa62b411a Update of the Metadataplayer
veltr
parents: 764
diff changeset
   403
        var _currentAnnotation = this.source.currentMedia.getAnnotationAtTime(_currentTime);
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   404
        if (typeof _currentAnnotation !== "undefined") {
794
8d62f45fe393 Updated Metadataplayer
veltr
parents: 784
diff changeset
   405
            _currentTime = _currentTime - _currentAnnotation.begin + _currentAnnotation.annotation.begin;
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   406
            var _mediaId = _currentAnnotation.getMedia().id;
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   407
            _list = _list.filter(function(_annotation) {
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   408
                return _annotation.getMedia().id === _mediaId;
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   409
            });
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   410
        }
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   411
    }
962
d600fa967511 New Search in Metadataplayer
veltr
parents: 875
diff changeset
   412
    _list = _list.filter(function(_annotation) {
d600fa967511 New Search in Metadataplayer
veltr
parents: 875
diff changeset
   413
        return _annotation.found !== false;
d600fa967511 New Search in Metadataplayer
veltr
parents: 875
diff changeset
   414
    });
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   415
    
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   416
    if ((this.filter_by_segments)&&(!(this.show_filters && this.segment_filter && this.ignoresegmentcheckbox_$[0].checked))) {
1387
82d256129376 Small tweaks to Annotation API and json project API and mdplayer widgets CreateAnnotation and AnnotationList to allow CreateAnnotation to create annotations on a specific project and AnnotationList to display different annotation types as well as filtering annotations based on current segment
durandn
parents: 1270
diff changeset
   417
        /*
82d256129376 Small tweaks to Annotation API and json project API and mdplayer widgets CreateAnnotation and AnnotationList to allow CreateAnnotation to create annotations on a specific project and AnnotationList to display different annotation types as well as filtering annotations based on current segment
durandn
parents: 1270
diff changeset
   418
         *  A given annotation is considered "in" segment if the middle of it is between the segment beginning and the segment end. 
82d256129376 Small tweaks to Annotation API and json project API and mdplayer widgets CreateAnnotation and AnnotationList to allow CreateAnnotation to create annotations on a specific project and AnnotationList to display different annotation types as well as filtering annotations based on current segment
durandn
parents: 1270
diff changeset
   419
         *  Note this is meant to be used for "markings" annotations (not segments)
82d256129376 Small tweaks to Annotation API and json project API and mdplayer widgets CreateAnnotation and AnnotationList to allow CreateAnnotation to create annotations on a specific project and AnnotationList to display different annotation types as well as filtering annotations based on current segment
durandn
parents: 1270
diff changeset
   420
         */
1394
5eecb7d31547 Tweaks to hide/show elements for several widgets to adjust for remie scenarii + More work on new widgets
durandn
parents: 1390
diff changeset
   421
        _segmentsAnnotation = this.currentSource.getAnnotationsByTypeTitle(this.segments_annotation_type)
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   422
        if (this.media.getTimeRange()){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   423
            _currentSegments = _segmentsAnnotation.filter(function(_segment){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   424
                return (_this.media.getTimeRange()[0] == _segment.begin && _this.media.getTimeRange()[1] == _segment.end)
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   425
            });
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   426
        }
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   427
        else {
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   428
            _currentSegments = _segmentsAnnotation.filter(function(_segment){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   429
                return (_currentTime >= _segment.begin && _currentTime <= _segment.end)
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   430
            });
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   431
        }
1394
5eecb7d31547 Tweaks to hide/show elements for several widgets to adjust for remie scenarii + More work on new widgets
durandn
parents: 1390
diff changeset
   432
        if (_currentSegments.length == 0) {
1390
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
   433
            _list = _list.filter(function(_annotation){
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
   434
                return false;
1394
5eecb7d31547 Tweaks to hide/show elements for several widgets to adjust for remie scenarii + More work on new widgets
durandn
parents: 1390
diff changeset
   435
            });
1387
82d256129376 Small tweaks to Annotation API and json project API and mdplayer widgets CreateAnnotation and AnnotationList to allow CreateAnnotation to create annotations on a specific project and AnnotationList to display different annotation types as well as filtering annotations based on current segment
durandn
parents: 1270
diff changeset
   436
        }
82d256129376 Small tweaks to Annotation API and json project API and mdplayer widgets CreateAnnotation and AnnotationList to allow CreateAnnotation to create annotations on a specific project and AnnotationList to display different annotation types as well as filtering annotations based on current segment
durandn
parents: 1270
diff changeset
   437
        else {
82d256129376 Small tweaks to Annotation API and json project API and mdplayer widgets CreateAnnotation and AnnotationList to allow CreateAnnotation to create annotations on a specific project and AnnotationList to display different annotation types as well as filtering annotations based on current segment
durandn
parents: 1270
diff changeset
   438
            _list = _list.filter(function(_annotation){
82d256129376 Small tweaks to Annotation API and json project API and mdplayer widgets CreateAnnotation and AnnotationList to allow CreateAnnotation to create annotations on a specific project and AnnotationList to display different annotation types as well as filtering annotations based on current segment
durandn
parents: 1270
diff changeset
   439
                _annotation_time = (_annotation.begin+_annotation.end)/2;
1394
5eecb7d31547 Tweaks to hide/show elements for several widgets to adjust for remie scenarii + More work on new widgets
durandn
parents: 1390
diff changeset
   440
                return (_currentSegments[0].begin <= _annotation_time && _currentSegments[0].end >= _annotation_time)
1387
82d256129376 Small tweaks to Annotation API and json project API and mdplayer widgets CreateAnnotation and AnnotationList to allow CreateAnnotation to create annotations on a specific project and AnnotationList to display different annotation types as well as filtering annotations based on current segment
durandn
parents: 1270
diff changeset
   441
            });
82d256129376 Small tweaks to Annotation API and json project API and mdplayer widgets CreateAnnotation and AnnotationList to allow CreateAnnotation to create annotations on a specific project and AnnotationList to display different annotation types as well as filtering annotations based on current segment
durandn
parents: 1270
diff changeset
   442
        }
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   443
        if(this.annotations_count_header && this.annotations_count != _list.length){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   444
            this.annotations_count = _list.length;
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   445
            this.refreshHeader();
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   446
        }
1389
a2316b574499 Added a filter based on annotation user name for AnnotationList metadataplayer widget + Added a way to make the creator field readonly for CreateAnnotation widget (so you can define a given annotation creator name for the widget that the user can't change)
durandn
parents: 1388
diff changeset
   447
    }
a2316b574499 Added a filter based on annotation user name for AnnotationList metadataplayer widget + Added a way to make the creator field readonly for CreateAnnotation widget (so you can define a given annotation creator name for the widget that the user can't change)
durandn
parents: 1388
diff changeset
   448
    if (this.show_only_annotation_from_user){
a2316b574499 Added a filter based on annotation user name for AnnotationList metadataplayer widget + Added a way to make the creator field readonly for CreateAnnotation widget (so you can define a given annotation creator name for the widget that the user can't change)
durandn
parents: 1388
diff changeset
   449
        _list = _list.filter(function(_annotation){
a2316b574499 Added a filter based on annotation user name for AnnotationList metadataplayer widget + Added a way to make the creator field readonly for CreateAnnotation widget (so you can define a given annotation creator name for the widget that the user can't change)
durandn
parents: 1388
diff changeset
   450
           return _annotation.creator == _this.show_only_annotation_from_user;
a2316b574499 Added a filter based on annotation user name for AnnotationList metadataplayer widget + Added a way to make the creator field readonly for CreateAnnotation widget (so you can define a given annotation creator name for the widget that the user can't change)
durandn
parents: 1388
diff changeset
   451
        });
1387
82d256129376 Small tweaks to Annotation API and json project API and mdplayer widgets CreateAnnotation and AnnotationList to allow CreateAnnotation to create annotations on a specific project and AnnotationList to display different annotation types as well as filtering annotations based on current segment
durandn
parents: 1270
diff changeset
   452
    }
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   453
    if (this.limit_count) {
794
8d62f45fe393 Updated Metadataplayer
veltr
parents: 784
diff changeset
   454
        /* Get the n annotations closest to current timecode */
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   455
        _list = _list.sortBy(function(_annotation) {
794
8d62f45fe393 Updated Metadataplayer
veltr
parents: 784
diff changeset
   456
            return Math.abs((_annotation.begin + _annotation.end) / 2 - _currentTime);
1235
9eee31426156 Upgrade metadataplayer
veltr
parents: 1230
diff changeset
   457
        }).slice(0, this.limit_count);
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   458
    }
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   459
    
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   460
    if (this.newest_first) {
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   461
        _list = _list.sortBy(function(_annotation) {
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   462
            return -_annotation.created.valueOf();
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   463
        });
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   464
    } else {
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   465
        _list = _list.sortBy(function(_annotation) {
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   466
            return _annotation.begin;
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   467
        });
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   468
    }
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   469
    
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   470
    if (this.show_filters){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   471
        if (this.user_filter){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   472
            _username = this.userselect_$[0].options[this.userselect_$[0].selectedIndex].value;
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   473
            if (_username != "false")
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   474
            {
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   475
                _list = _list.filter(function(_annotation){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   476
                    return _annotation.creator == _username
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   477
                })
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   478
            }
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   479
        }
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   480
        if (this.keyword_filter){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   481
        _keyword = this.keywordinput_$[0].value;
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   482
            if (_keyword != ""){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   483
                _list = _list.filter(function(_annotation){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   484
                   return _annotation.description.toLowerCase().match(_keyword.toLowerCase());
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   485
                });
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   486
            }
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   487
        }
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   488
        if (this.date_filter){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   489
            if(this.datefilterinput_$[0].value != ""){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   490
                _date = this.datefilterinput_$.datepicker("getDate");
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   491
                _list = _list.filter(function(_annotation){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   492
                    return ((_annotation.created.getDate() == _date.getDate())&&(_annotation.created.getMonth() == _date.getMonth())&&(_annotation.created.getFullYear() == _date.getFullYear()));
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   493
                });
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   494
            }
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   495
        }
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   496
        if (this.latest_contributions_filter && this.latestcontributionscheckbox_$[0].checked){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   497
            _list = _list.sortBy(function(_annotation) {
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   498
                return -_annotation.created.valueOf();
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   499
            });
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   500
            this.usernames.forEach(function(_user){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   501
                
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   502
                latest_ann = _list.filter(function(_annotation){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   503
                    return _annotation.creator == _user;
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   504
                })[0];
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   505
                _list = _list.filter(function(_annotation){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   506
                    return _annotation.id == (latest_ann ? latest_ann.id : false) || _annotation.creator != _user;
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   507
                });
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   508
            });
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   509
        }
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   510
        
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   511
    }
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   512
    
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   513
    var _ids = _list.idIndex;
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   514
962
d600fa967511 New Search in Metadataplayer
veltr
parents: 875
diff changeset
   515
    if (_forceRedraw || !IriSP._.isEqual(_ids, this.lastIds) || this.searchString !== this.lastSearch) {
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   516
        /* This part only gets executed if the list needs updating */
962
d600fa967511 New Search in Metadataplayer
veltr
parents: 875
diff changeset
   517
        this.lastSearch = this.searchString;
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   518
        this.lastIds = _ids;
764
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   519
        this.list_$.html("");
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   520
        _list.forEach(function(_annotation) {
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   521
            var _url = (
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   522
                ( typeof _annotation.url !== "undefined" && _annotation.url)
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   523
                ? _annotation.url
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   524
                : (
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   525
                    ( typeof _this.source.projectId !== "undefined" && typeof _annotation.project !== "undefined" && _annotation.project && _this.source.projectId !== _annotation.project )
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   526
                    ? Mustache.to_html(
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   527
                        _this.foreign_url,
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   528
                        {
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   529
                            project : _annotation.project,
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   530
                            media : _annotation.media.id,
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   531
                            annotation : _annotation.id,
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   532
                            annotationType : _annotation.annotationType.id
696
b431fb1fd480 Corrections on the new Metadataplayer
veltr
parents: 695
diff changeset
   533
                        }
764
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   534
                    )
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   535
                    : document.location.href.replace(/#.*$/,'') + '#id=' + _annotation.id + '&t=' + (_annotation.begin / 1000.0)
764
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   536
                    )
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   537
            );
1268
10b80515b46a v1.51.18 : display name in annotation list
cavaliet
parents: 1235
diff changeset
   538
            var _title = "",
1121
d56201bf1446 New metadataplayer + default "Multi segments" widget
veltr
parents: 962
diff changeset
   539
                _description = _annotation.description,
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   540
                _thumbnail = (typeof _annotation.thumbnail !== "undefined" && _annotation.thumbnail ? _annotation.thumbnail : _this.default_thumbnail);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   541
            if (_this.show_creator){
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   542
                if (_annotation.creator) {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   543
                    var _users = [],
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   544
                        _user = {},
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   545
                        _creator = "";
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   546
                    if (_this.source.users_data) {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   547
                        _users = _this.source.users_data.filter(function(_user_data){
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   548
                            return _user_data.username == _annotation.creator;
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   549
                        });
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   550
                    }
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   551
                    if (_users.length == 0){
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   552
                        _user.username = _annotation.creator
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   553
                    }
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   554
                    else{
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   555
                        _user = _users[0]
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   556
                    }
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   557
                    _creator = _this.make_name_string_function(_user);
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   558
                }
764
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   559
            }
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   560
            if (_this.show_title && _annotation.title){
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   561
                    var _title = _annotation.title;
764
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   562
            }
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   563
            var _bgcolor;
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   564
            IriSP._(_this.polemics).each(function(_polemic) {
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   565
                var _rgxp = IriSP.Model.regexpFromTextOrArray(_polemic.keyword, true);
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   566
                if (_rgxp.test(_title + " " + _description)) {
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   567
                    _bgcolor = _polemic.background_color;
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   568
                }
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   569
            });
1388
cc17e3d211cd Added option to display creation date of annotations in AnnotationList metadataplayer widget
durandn
parents: 1387
diff changeset
   570
            var _created = false;
cc17e3d211cd Added option to display creation date of annotations in AnnotationList metadataplayer widget
durandn
parents: 1387
diff changeset
   571
            if (_this.show_creation_date) {
cc17e3d211cd Added option to display creation date of annotations in AnnotationList metadataplayer widget
durandn
parents: 1387
diff changeset
   572
                _created = _annotation.created.toLocaleDateString()+", "+_annotation.created.toLocaleTimeString();
cc17e3d211cd Added option to display creation date of annotations in AnnotationList metadataplayer widget
durandn
parents: 1387
diff changeset
   573
            }
1394
5eecb7d31547 Tweaks to hide/show elements for several widgets to adjust for remie scenarii + More work on new widgets
durandn
parents: 1390
diff changeset
   574
            if(this.tags == true){
5eecb7d31547 Tweaks to hide/show elements for several widgets to adjust for remie scenarii + More work on new widgets
durandn
parents: 1390
diff changeset
   575
                var _tags = _annotation.getTagTexts();
5eecb7d31547 Tweaks to hide/show elements for several widgets to adjust for remie scenarii + More work on new widgets
durandn
parents: 1390
diff changeset
   576
            }
5eecb7d31547 Tweaks to hide/show elements for several widgets to adjust for remie scenarii + More work on new widgets
durandn
parents: 1390
diff changeset
   577
            else {
5eecb7d31547 Tweaks to hide/show elements for several widgets to adjust for remie scenarii + More work on new widgets
durandn
parents: 1390
diff changeset
   578
                var _tags = false;
5eecb7d31547 Tweaks to hide/show elements for several widgets to adjust for remie scenarii + More work on new widgets
durandn
parents: 1390
diff changeset
   579
            }
764
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   580
            var _data = {
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   581
                id : _annotation.id,
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   582
                media_id : _annotation.getMedia().id,
1121
d56201bf1446 New metadataplayer + default "Multi segments" widget
veltr
parents: 962
diff changeset
   583
                htitle : IriSP.textFieldHtml(_title),
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   584
                title: _title,
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   585
                creator: _creator,
1121
d56201bf1446 New metadataplayer + default "Multi segments" widget
veltr
parents: 962
diff changeset
   586
                hdescription : IriSP.textFieldHtml(_description),
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   587
                description: _description,
764
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   588
                begin : _annotation.begin.toString(),
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   589
                end : _annotation.end.toString(),
1388
cc17e3d211cd Added option to display creation date of annotations in AnnotationList metadataplayer widget
durandn
parents: 1387
diff changeset
   590
                created : _created,
1394
5eecb7d31547 Tweaks to hide/show elements for several widgets to adjust for remie scenarii + More work on new widgets
durandn
parents: 1390
diff changeset
   591
                show_timecode : _this.show_timecode,
1121
d56201bf1446 New metadataplayer + default "Multi segments" widget
veltr
parents: 962
diff changeset
   592
                thumbnail : _thumbnail,
764
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   593
                url : _url,
1394
5eecb7d31547 Tweaks to hide/show elements for several widgets to adjust for remie scenarii + More work on new widgets
durandn
parents: 1390
diff changeset
   594
                tags : _tags,
806
37bad74c2520 Added Voice Annotation Support in MDP
veltr
parents: 794
diff changeset
   595
                specific_style : (typeof _bgcolor !== "undefined" ? "background-color: " + _bgcolor : ""),
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   596
                l10n: _this.l10n,
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   597
                editable: _this.editable,
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   598
                show_publish: _this.show_publish,
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   599
                show_creator: _this.show_creator,
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   600
                show_twitter: _this.show_twitter,
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   601
                twitter_param: IriSP.jQuery.param({ url: _url, text: IriSP.textFieldHtml(_title) + (_this.twitter_hashtag ? ' #' + _this.twitter_hashtag : "") }),
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   602
                allow_annotations_deletion: _this.allow_annotations_deletion
764
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   603
            };
1230
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   604
            if (_this.show_audio && _annotation.audio && _annotation.audio.href && _annotation.audio.href != "null") {
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   605
                _data.audio = true;
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   606
                if (!_this.jwplayers[_annotation.id]) {
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   607
                    var _audiofile = _annotation.audio.href;
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   608
                    if (_this.audio_url_transform) {
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   609
                        _audiofile = _this.audio_url_transform(_annotation.audio.href);
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   610
                    }
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   611
                    var _tmpId = "jwplayer-" + IriSP.Model.getUID();
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   612
                    _this.jwplayers[_annotation.id] = _tmpId;
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   613
                    _this.$.find(".Ldt-AnnotationsList-Audio").append(IriSP.jQuery("<div>").attr("id", _tmpId));
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   614
                    jwplayer(_tmpId).setup({
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   615
                        flashplayer: IriSP.getLib("jwPlayerSWF"),
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   616
                        file: _audiofile,
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   617
                        fallback: false,
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   618
                        primary: "flash",
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   619
                        controls: false,
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   620
                        width: 1,
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   621
                        height: 1,
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   622
                        events: {
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   623
                            onPause: function() {
1235
9eee31426156 Upgrade metadataplayer
veltr
parents: 1230
diff changeset
   624
                                _this.$.find(".Ldt-AnnotationsList-Play[data-annotation-id=" + _annotation.id + "]").text(_this.l10n.voice_annotation);
1230
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   625
                            },
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   626
                            onPlay: function() {
1235
9eee31426156 Upgrade metadataplayer
veltr
parents: 1230
diff changeset
   627
                                _this.$.find(".Ldt-AnnotationsList-Play[data-annotation-id=" + _annotation.id + "]").text(_this.l10n.now_playing);
1230
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   628
                            }
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   629
                        }
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   630
                    });
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   631
                }
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   632
            }
875
509a27622632 Metadataplayer upgraded for rest api
veltr
parents: 806
diff changeset
   633
            var _html = Mustache.to_html(_this.annotationTemplate, _data),
509a27622632 Metadataplayer upgraded for rest api
veltr
parents: 806
diff changeset
   634
                _el = IriSP.jQuery(_html),
509a27622632 Metadataplayer upgraded for rest api
veltr
parents: 806
diff changeset
   635
                _onselect = function() {
1230
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   636
                    _this.$.find('.Ldt-AnnotationsList-li').removeClass("selected");
875
509a27622632 Metadataplayer upgraded for rest api
veltr
parents: 806
diff changeset
   637
                    _el.addClass("selected");
509a27622632 Metadataplayer upgraded for rest api
veltr
parents: 806
diff changeset
   638
                },
509a27622632 Metadataplayer upgraded for rest api
veltr
parents: 806
diff changeset
   639
                _onunselect = function() {
1230
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   640
                    _this.$.find('.Ldt-AnnotationsList-li').removeClass("selected");
875
509a27622632 Metadataplayer upgraded for rest api
veltr
parents: 806
diff changeset
   641
                };
764
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   642
            _el.mouseover(function() {
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   643
                    _annotation.trigger("select");
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   644
                })
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   645
                .mouseout(function() {
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   646
                    _annotation.trigger("unselect");
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   647
                })
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   648
                .click(function() {
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   649
                    _annotation.trigger("click");
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   650
                })
764
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   651
                .appendTo(_this.list_$);
1205
0050fa1e687c Updated Metadataplayer and fixed URL bug
veltr
parents: 1180
diff changeset
   652
            IriSP.attachDndData(_el.find("[draggable]"), {
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   653
            	title: _title,
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   654
            	description: _description,
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   655
            	uri: _url,
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   656
                image: _annotation.thumbnail,
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   657
                text: '[' + _annotation.begin.toString() + '] ' + _title
1205
0050fa1e687c Updated Metadataplayer and fixed URL bug
veltr
parents: 1180
diff changeset
   658
            });
875
509a27622632 Metadataplayer upgraded for rest api
veltr
parents: 806
diff changeset
   659
            _el.on("remove", function() {
509a27622632 Metadataplayer upgraded for rest api
veltr
parents: 806
diff changeset
   660
                _annotation.off("select", _onselect);
509a27622632 Metadataplayer upgraded for rest api
veltr
parents: 806
diff changeset
   661
                _annotation.off("unselect", _onunselect);
764
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   662
            });
875
509a27622632 Metadataplayer upgraded for rest api
veltr
parents: 806
diff changeset
   663
            _annotation.on("select", _onselect);
509a27622632 Metadataplayer upgraded for rest api
veltr
parents: 806
diff changeset
   664
            _annotation.on("unselect", _onunselect);
764
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
   665
        });
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   666
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   667
        /* Correct the empty tag bug */
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   668
        this.$.find('.Ldt-AnnotationsList-Tag-Li').each(function() {
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   669
            var _el = IriSP.jQuery(this);
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   670
            if (!_el.text().replace(/(^\s+|\s+$)/g,'')) {
875
509a27622632 Metadataplayer upgraded for rest api
veltr
parents: 806
diff changeset
   671
                _el.remove();
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   672
            }
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   673
        });
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   674
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   675
        if (this.editable) {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   676
            var widget = _this;
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   677
            var $ = IriSP.jQuery;
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   678
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   679
            var edit_element = function (_this, insertion_point) {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   680
                var feedback_wrong = "#FF9999";
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   681
                var feedback_ok = "#99FF99";
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   682
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   683
                // insertion_point can be used to specify where to
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   684
                // insert the input field.  Firefox is buggy wrt input
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   685
                // fields inside <a> or <h?> tags, it does not
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   686
                // propagate mouse clicks. If _this is a <a> then we
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   687
                // have to specify the ancestor before which we can
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   688
                // insert the input widget.
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   689
                if (insertion_point === undefined)
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   690
                    insertion_point = _this;
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   691
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   692
                // Insert input element
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   693
                var input_element = $(_this.dataset.editable_type === 'multiline' ? "<textarea>" : "<input>")
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   694
                        .addClass("editableInput")
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   695
                        .insertBefore($(insertion_point));
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   696
                input_element[0].value = _this.dataset.editable_value;
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   697
                $(input_element).show().focus();
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   698
                $(_this).addClass("editing");
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   699
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   700
                function feedback(color) {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   701
                    // Give some feedback
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   702
                    $(_this).removeClass("editing");
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   703
                    input_element.remove();
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   704
                    var previous_color = $(_this).css("background-color");
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   705
                    $(_this).stop().css("background-color", color)
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   706
                        .animate({ backgroundColor: previous_color}, 1000);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   707
                }
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   708
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   709
                function cancelChanges(s) {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   710
                    feedback(feedback_wrong);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   711
                }
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   712
                function validateChanges() {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   713
                    var n = input_element[0].value;
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   714
                    if (n == _this.dataset.editable_value) {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   715
                        // No change
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   716
                        feedback(feedback_ok);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   717
                        return;
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   718
                    }
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   719
                    if (n == '') {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   720
                        // Delete annotation
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   721
                        delete_local_annotation(_this.dataset.editable_id);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   722
                        widget.player.trigger("Annotation.delete", _this.dataset.editable_id);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   723
                        return;
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   724
                    } else {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   725
                        // Convert value if necessary.
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   726
                        var val = n;
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   727
                        if (_this.dataset.editable_type == 'timestamp') {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   728
                            val = IriSP.timestamp2ms(n);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   729
                            if (Number.isNaN(val)) {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   730
                                // Invalid value. Cancel changes
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   731
                                cancelChanges();
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   732
                                return;
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   733
                            }
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   734
                        }
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   735
                        _this.dataset.editable_value = n;
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   736
                        n = val;
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   737
                        $(_this).text(val);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   738
                    }
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   739
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   740
                    // We cannot use .getElement since it fetches
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   741
                    // elements from the global Directory
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   742
                    var an = get_local_annotation(_this.dataset.editable_id);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   743
                    if (an === undefined) {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   744
                        console.log("Strange error: cannot find edited annotation");
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   745
                        feedback(feedback_wrong);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   746
                    } else {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   747
                        _this.dataset.editable_value = n;
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   748
                        // Update annotation for storage
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   749
                        if (_this.dataset.editable_field == 'begin')
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   750
                            an.setBegin(n);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   751
                        else if (_this.dataset.editable_field == 'end')
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   752
                            an.setEnd(n);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   753
                        else
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   754
                            an[_this.dataset.editable_field] = n;
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   755
                        an.modified = new Date();
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   756
                        // FIXME: use user name, when available
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   757
                        an.contributor = widget.player.config.username || "COCo User";
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   758
                        widget.player.addLocalAnnotation(an);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   759
                        widget.player.trigger("Annotation.update", an);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   760
                        feedback(feedback_ok);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   761
                    }
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   762
                }
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   763
                $(input_element).bind('keydown', function(e) {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   764
                    if (e.which == 13) {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   765
                        e.preventDefault();
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   766
                        validateChanges();
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   767
                    } else if (e.which == 27) {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   768
                        e.preventDefault();
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   769
                        cancelChanges();
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   770
                    }
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   771
                }).bind("blur", function (e) {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   772
                    validateChanges();
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   773
                });
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   774
            };
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   775
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   776
            var get_local_annotation = function (ident) {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   777
                return widget.player.getLocalAnnotation(ident);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   778
            };
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   779
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   780
            var save_local_annotations = function() {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   781
                widget.player.saveLocalAnnotations();
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   782
                // Merge modifications into widget source
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   783
                widget.source.merge(widget.player.localSource);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   784
            };
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   785
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   786
            var delete_local_annotation = function(ident) {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   787
                widget.source.getAnnotations().removeId(ident, true);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   788
                widget.player.deleteLocalAnnotation(ident);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   789
                widget.refresh(true);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   790
            };
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   791
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   792
            this.$.find('.Ldt-AnnotationsList-Delete').click(function(e) {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   793
                // Delete annotation
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   794
                var _annotation = get_local_annotation(this.dataset.editable_id);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   795
                if (confirm(Mustache.to_html(widget.l10n.confirm_delete_message, { annotation: _annotation })))
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   796
                    delete_local_annotation(this.dataset.editable_id);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   797
                widget.refresh(true);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   798
            });
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   799
            this.$.find('.Ldt-AnnotationsList-Edit').click(function(e) {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   800
                if (widget.on_edit) {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   801
                    var _annotation = get_local_annotation(this.dataset.editable_id);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   802
                    widget.on_edit(_annotation);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   803
                } else {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   804
                    // Edit annotation title. We have to specify the insertion point.
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   805
                    var element = $(this).parents(".Ldt-AnnotationsList-li").find(".Ldt-AnnotationsList-TitleContent.Ldt-live-editable");
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   806
                    edit_element(element[0]);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   807
                }
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   808
            });
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   809
            this.$.find('.Ldt-AnnotationsList-PublishAnnotation').click(function(e) {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   810
                var _annotation = get_local_annotation(this.dataset.editable_id);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   811
                // Publish annotation to the server
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   812
                if (!confirm(Mustache.to_html(widget.l10n.confirm_publish_message, { annotation: _annotation })))
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   813
                    return;
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   814
                var _url = Mustache.to_html(widget.api_endpoint_template, {id: widget.source.projectId});
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   815
                if (_url !== "") {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   816
                    var _export = widget.player.sourceManager.newLocalSource({serializer: IriSP.serializers[widget.api_serializer]});
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   817
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   818
                    if (widget.publish_type) {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   819
                        // If publish_type is specified, try to set the annotation type of the exported annotation
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   820
                        var at = widget.source.getAnnotationTypes().filter(function(at) { return at.title == widget.publish_type; });
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   821
                        if (at.length == 1) {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   822
                            _annotation.setAnnotationType(at[0].id);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   823
                        }
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   824
                    }
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   825
                    var _exportedAnnotations = new IriSP.Model.List(widget.player.sourceManager);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   826
                    _exportedAnnotations.push(_annotation);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   827
                    _export.addList("annotation", _exportedAnnotations);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   828
                    IriSP.jQuery.ajax({
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   829
                        url: _url,
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   830
                        type: widget.api_method,
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   831
                        contentType: 'application/json',
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   832
                        data: _export.serialize(),
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   833
                        success: function(_data) {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   834
                            $(this).addClass("published");
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   835
                            // Save the published information
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   836
                            var an = get_local_annotation(_annotation.id);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   837
                            // FIXME: handle "published" tag
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   838
                            an.setTags( [ "published" ]);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   839
                            save_local_annotations();
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   840
                            widget.player.trigger("Annotation.publish", _annotation);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   841
                        },
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   842
                        error: function(_xhr, _error, _thrown) {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   843
                            IriSP.log("Error when sending annotation", _thrown);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   844
                        }
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   845
                    });
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   846
                }
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   847
            });
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   848
            this.$.find('.Ldt-AnnotationsList-TimeEdit').dblclick(function(e) {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   849
                var _this = this;
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   850
                // Use current player time
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   851
                var an = get_local_annotation(_this.dataset.editable_id);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   852
                if (an !== undefined) {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   853
                    // FIXME: implement Undo feature
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   854
                    an.setBegin(widget.media.getCurrentTime().milliseconds);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   855
                    save_local_annotations();
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   856
                    widget.player.trigger("Annotation.update", an);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   857
                    widget.refresh(true);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   858
                }
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   859
            });
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   860
        };
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   861
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   862
        this.$.find('.Ldt-AnnotationsList-Tag-Li').click(function() {
962
d600fa967511 New Search in Metadataplayer
veltr
parents: 875
diff changeset
   863
            _this.source.getAnnotations().search(IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,''));
806
37bad74c2520 Added Voice Annotation Support in MDP
veltr
parents: 794
diff changeset
   864
        });
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   865
        this.$.find('.Ldt-Annotation-Timecode').click(function () {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   866
            _this.media.setCurrentTime(Number(this.dataset.timecode));
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   867
        });
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   868
806
37bad74c2520 Added Voice Annotation Support in MDP
veltr
parents: 794
diff changeset
   869
        this.$.find(".Ldt-AnnotationsList-Play").click(function() {
37bad74c2520 Added Voice Annotation Support in MDP
veltr
parents: 794
diff changeset
   870
            var _el = IriSP.jQuery(this),
1230
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   871
                _annid = _el.attr("data-annotation-id");
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   872
            if (_this.jwplayers[_annid]) {
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   873
                jwplayer(_this.jwplayers[_annid]).play();
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
   874
            }
806
37bad74c2520 Added Voice Annotation Support in MDP
veltr
parents: 794
diff changeset
   875
            _this.media.pause();
37bad74c2520 Added Voice Annotation Support in MDP
veltr
parents: 794
diff changeset
   876
        });
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   877
962
d600fa967511 New Search in Metadataplayer
veltr
parents: 875
diff changeset
   878
        if (this.source.getAnnotations().searching) {
1121
d56201bf1446 New metadataplayer + default "Multi segments" widget
veltr
parents: 962
diff changeset
   879
            var rx = _this.source.getAnnotations().regexp || false;
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   880
            this.$.find(".Ldt-AnnotationsList-Title a, .Ldt-AnnotationsList-Description").each(function() {
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   881
                var _$ = IriSP.jQuery(this);
1121
d56201bf1446 New metadataplayer + default "Multi segments" widget
veltr
parents: 962
diff changeset
   882
                _$.html(IriSP.textFieldHtml(_$.text(), rx));
d56201bf1446 New metadataplayer + default "Multi segments" widget
veltr
parents: 962
diff changeset
   883
            });
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   884
        }
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   885
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   886
        this.$.find(".Ldt-AnnotationsList-DeleteButton").click(_this.functionWrapper("onDeleteClick"))
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   887
    }
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   888
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   889
    if (this.ajax_url) {
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   890
        if (this.mashupMode) {
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   891
            this.ajaxMashup();
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   892
        } else {
784
18dfa62b411a Update of the Metadataplayer
veltr
parents: 764
diff changeset
   893
            if (Math.abs(_currentTime - this.lastAjaxQuery) > (this.ajax_granularity)) {
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   894
                this.ajaxSource();
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   895
            }
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   896
        }
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   897
    }
1390
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
   898
    
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   899
    return _list.length;
1235
9eee31426156 Upgrade metadataplayer
veltr
parents: 1230
diff changeset
   900
};
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
   901
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   902
IriSP.Widgets.AnnotationsList.prototype.onDeleteClick = function(event){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   903
    
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   904
    ann_id = event.target.dataset.annotation;
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   905
    delete_preview_$ = this.$.find(".Ldt-AnnotationsList-ul-ToDelete");
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   906
    delete_preview_$.html("");
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   907
    _list = this.getWidgetAnnotations()
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   908
    _list = _list.filter(function(_annotation){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   909
        return _annotation.id == ann_id
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   910
    })
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   911
    var _annotation = _list[0],
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   912
        _title = "",
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   913
        _this = this;
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   914
    if (_annotation.creator) {
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   915
        var _users = [],
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   916
            _user = {};
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   917
        if (_this.source.users_data) {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   918
            _users = _this.source.users_data.filter(function(_user_data){
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   919
                return _user_data.username == _annotation.creator;
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   920
            });
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
   921
        }
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   922
        if (_users.length == 0){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   923
            _user.username = _annotation.creator
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   924
        }
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   925
        else{
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   926
            _user = _users[0]
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   927
        }
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   928
        _title = _this.make_name_string_function(_user);
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   929
    }
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   930
    if (_annotation.title) {
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   931
        var tempTitle = _annotation.title;
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   932
        if( tempTitle.substr(0, _title.length + 1) == (_title + ":") ){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   933
            _title = "";
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   934
        }
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   935
        _title = _title + ( (_title=="") ? "" : ": ") + _annotation.title;
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   936
    }
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   937
    var _created = false;
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   938
    if (this.show_creation_date) {
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   939
        _created = _annotation.created.toLocaleDateString()+", "+_annotation.created.toLocaleTimeString();
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   940
    }
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   941
    var _data = {
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   942
            id : _annotation.id,
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   943
            media_id : _annotation.getMedia().id,
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   944
            htitle : IriSP.textFieldHtml(_title),
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   945
            hdescription : IriSP.textFieldHtml(_annotation.description),
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   946
            begin : _annotation.begin.toString(),
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   947
            end : _annotation.end.toString(),
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   948
            created : _created,
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   949
            show_timecode : this.show_timecode,
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   950
            tags : false,
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   951
            l10n: this.l10n,
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   952
            allow_annotations_deletion: false
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   953
    }
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   954
    _html = Mustache.to_html(this.annotationTemplate, _data)
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   955
    delete_preview_$.html(_html)
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   956
    
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   957
    this.$.find(".Ldt-AnnotationsList-ConfirmDelete").click(function(){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   958
        _this.sendDelete(ann_id);
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   959
    });
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   960
    
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   961
    this.showScreen("Delete");    
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   962
}
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   963
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   964
IriSP.Widgets.AnnotationsList.prototype.refreshHeader = function() {
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   965
    var annotation_count_string = " (" + this.annotations_count +" annotations)";
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   966
    this.$.find('.Ldt-AnnotationsList-header').html("");
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   967
    this.$.find('.Ldt-AnnotationsList-header').html(
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   968
        this.custom_header && typeof this.custom_header == "string"? this.custom_header + annotation_count_string : this.l10n.header + annotation_count_string
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   969
    );
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   970
}
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   971
1390
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
   972
IriSP.Widgets.AnnotationsList.prototype.hide = function() {
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   973
    var _this = this;
1390
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
   974
    if (this.visible){
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
   975
        this.visible = false;
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   976
        this.widget_$.slideUp(function(){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   977
            _this.$.find('.Ldt-AnnotationsList-header').hide();            
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   978
        });
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   979
        this.showScreen("Main")
1390
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
   980
    }
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
   981
}
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
   982
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
   983
IriSP.Widgets.AnnotationsList.prototype.show = function() {
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
   984
    if(!this.visible){
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
   985
        this.visible = true;
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   986
        this.$.find('.Ldt-AnnotationsList-header').show();
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   987
        this.widget_$.slideDown();
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
   988
        this.showScreen("Main")
1390
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
   989
    }
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
   990
}
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
   991
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
   992
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
   993
IriSP.Widgets.AnnotationsList.prototype.toggle = function() {
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
   994
    if (!this.always_visible) {
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
   995
        if (this.visible) {
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
   996
            this.hide();
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
   997
        } else {
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
   998
            this.show();
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
   999
        }
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
  1000
    }
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
  1001
};
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
  1002
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1003
IriSP.Widgets.AnnotationsList.prototype.revertToMainScreen = function(){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1004
    if (this.$.find(".Ldt-AnnotationsList-ScreenMain").is(":hidden")){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1005
        this.showScreen("Main");
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1006
    }
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1007
}
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1008
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1009
IriSP.Widgets.AnnotationsList.prototype.sendDelete = function(id){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1010
    var _this = this,
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
  1011
        _url = Mustache.to_html(this.api_delete_endpoint, {annotation_id: id, project_id: this.project_id})
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1012
    
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1013
    IriSP.jQuery.ajax({
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1014
        url: _url,
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1015
        type: this.api_delete_method,
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1016
        contentType: 'application/json',
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1017
        success: function(_data) {
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1018
            _this.showScreen('Success');
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1019
            window.setTimeout(_this.functionWrapper("revertToMainScreen"),(_this.after_send_timeout || 2000));
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1020
            _this.currentSource.getAnnotations().removeId(id);
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1021
            _this.player.trigger("AnnotationsList.refresh");
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1022
        },
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1023
        error: function(_xhr, _error, _thrown) {
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1024
            IriSP.log("Error when sending annotation", _thrown);
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1025
            _this.showScreen('Error');
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1026
            window.setTimeout(_this.functionWrapper("revertToMainScreen"),(_this.after_send_timeout || 2000));
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1027
        }
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1028
    });
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1029
    this.showScreen('Sending');
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1030
}
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1031
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
  1032
IriSP.Widgets.AnnotationsList.prototype.draw = function() {
1230
085e10f168ad updated metadataplayer
veltr
parents: 1205
diff changeset
  1033
    this.jwplayers = {};
784
18dfa62b411a Update of the Metadataplayer
veltr
parents: 764
diff changeset
  1034
    this.mashupMode = (this.media.elementType === "mashup");
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
  1035
764
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
  1036
    this.renderTemplate();
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
  1037
806
37bad74c2520 Added Voice Annotation Support in MDP
veltr
parents: 794
diff changeset
  1038
    var _this = this;
764
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
  1039
    this.list_$ = this.$.find(".Ldt-AnnotationsList-ul");
1394
5eecb7d31547 Tweaks to hide/show elements for several widgets to adjust for remie scenarii + More work on new widgets
durandn
parents: 1390
diff changeset
  1040
    this.widget_$ = this.$.find(".Ldt-AnnotationsListWidget");
764
b059300340aa Upgraded Metadataplayer to add Vimeo support
veltr
parents: 698
diff changeset
  1041
    
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1042
    if (this.show_filters){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1043
        if (this.user_filter){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1044
            this.userselect_$ = this.$.find("#Ldt-AnnotationsList-userFilter");
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1045
            this.userselect_$.change(function(){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1046
                _this.player.trigger("AnnotationsList.refresh");
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1047
            });
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1048
            this.userselect_$.html("<option selected value='false'>"+this.l10n.everyone+"</option>");
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1049
            this.usernames.forEach(function(_user){
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
  1050
                var _users = _this.source.users_data.filter(function(_user_data){
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
  1051
                    return _user_data.username == _user;
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
  1052
                }),
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
  1053
                    _user_data = {};
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
  1054
                if (_users.length == 0){
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
  1055
                    _user_data.username = _user;
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
  1056
                }
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
  1057
                else{
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
  1058
                    _user_data = _users[0];
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
  1059
                }
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
  1060
                _this.userselect_$.append("<option value='"+_user+"'>"+_this.make_name_string_function(_user_data)+"</option>");
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1061
            });
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1062
        }
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1063
        if (this.keyword_filter){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1064
            this.keywordinput_$ = this.$.find("#Ldt-AnnotationsList-keywordsFilter");
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1065
            this.keywordinput_$.keyup(function(){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1066
                _this.player.trigger("AnnotationsList.refresh");
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1067
            });
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1068
            
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1069
        }
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1070
        if (this.segment_filter){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1071
            this.ignoresegmentcheckbox_$ = this.$.find("#Ldt-AnnotationsList-ignoreSegmentsFilter");
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1072
            this.ignoresegmentcheckbox_$.click(function(){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1073
                _this.player.trigger("AnnotationsList.refresh");
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1074
            });
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1075
        }
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1076
        if(this.date_filter){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1077
            this.datefilterinput_$ = this.$.find("#Ldt-AnnotationsList-dateFilter");
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1078
            this.datefilterinput_$.datepicker({ dateFormat: 'dd/mm/yy' });
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1079
            this.datefilterinput_$.change(function(){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1080
                _this.player.trigger("AnnotationsList.refresh")
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1081
            })
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1082
            if (this.current_day_filter){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1083
                currentDate = new Date();
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1084
                this.datefilterinput_$.datepicker("setDate",currentDate);
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1085
            }
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1086
        }
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1087
        if(this.latest_contributions_filter){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1088
            this.latestcontributionscheckbox_$ = this.$.find("#Ldt-AnnotationsList-latestContributionsFilter");
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1089
            this.latestcontributionscheckbox_$.click(function(){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1090
                _this.player.trigger("AnnotationsList.refresh");
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1091
            });
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1092
        }
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1093
    }
806
37bad74c2520 Added Voice Annotation Support in MDP
veltr
parents: 794
diff changeset
  1094
    
962
d600fa967511 New Search in Metadataplayer
veltr
parents: 875
diff changeset
  1095
    this.source.getAnnotations().on("search", function(_text) {
d600fa967511 New Search in Metadataplayer
veltr
parents: 875
diff changeset
  1096
        _this.searchString = _text;
d600fa967511 New Search in Metadataplayer
veltr
parents: 875
diff changeset
  1097
        if (_this.source !== _this.currentSource) {
d600fa967511 New Search in Metadataplayer
veltr
parents: 875
diff changeset
  1098
            _this.currentSource.getAnnotations().search(_text);
d600fa967511 New Search in Metadataplayer
veltr
parents: 875
diff changeset
  1099
            _this.throttledRefresh();
d600fa967511 New Search in Metadataplayer
veltr
parents: 875
diff changeset
  1100
        }
d600fa967511 New Search in Metadataplayer
veltr
parents: 875
diff changeset
  1101
    });
d600fa967511 New Search in Metadataplayer
veltr
parents: 875
diff changeset
  1102
    this.source.getAnnotations().on("found", function() {
d600fa967511 New Search in Metadataplayer
veltr
parents: 875
diff changeset
  1103
        _this.throttledRefresh();
d600fa967511 New Search in Metadataplayer
veltr
parents: 875
diff changeset
  1104
    });
d600fa967511 New Search in Metadataplayer
veltr
parents: 875
diff changeset
  1105
    this.source.getAnnotations().on("not-found", function() {
d600fa967511 New Search in Metadataplayer
veltr
parents: 875
diff changeset
  1106
        _this.throttledRefresh();
d600fa967511 New Search in Metadataplayer
veltr
parents: 875
diff changeset
  1107
    });
d600fa967511 New Search in Metadataplayer
veltr
parents: 875
diff changeset
  1108
    this.source.getAnnotations().on("clear-search", function() {
d600fa967511 New Search in Metadataplayer
veltr
parents: 875
diff changeset
  1109
        _this.searchString = false;
d600fa967511 New Search in Metadataplayer
veltr
parents: 875
diff changeset
  1110
        if (_this.source !== _this.currentSource) {
d600fa967511 New Search in Metadataplayer
veltr
parents: 875
diff changeset
  1111
            _this.currentSource.getAnnotations().trigger("clear-search");
d600fa967511 New Search in Metadataplayer
veltr
parents: 875
diff changeset
  1112
        }
d600fa967511 New Search in Metadataplayer
veltr
parents: 875
diff changeset
  1113
    });
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1114
    
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1115
    this.$.find(".Ldt-AnnotationsList-Close").click(function(){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1116
        _this.showScreen("Main");
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1117
    })
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1118
    
962
d600fa967511 New Search in Metadataplayer
veltr
parents: 875
diff changeset
  1119
    this.source.getAnnotations().on("search-cleared", function() {
d600fa967511 New Search in Metadataplayer
veltr
parents: 875
diff changeset
  1120
        _this.throttledRefresh();
d600fa967511 New Search in Metadataplayer
veltr
parents: 875
diff changeset
  1121
    });
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
  1122
806
37bad74c2520 Added Voice Annotation Support in MDP
veltr
parents: 794
diff changeset
  1123
    this.onMdpEvent("AnnotationsList.refresh", function() {
37bad74c2520 Added Voice Annotation Support in MDP
veltr
parents: 794
diff changeset
  1124
        if (_this.ajax_url) {
37bad74c2520 Added Voice Annotation Support in MDP
veltr
parents: 794
diff changeset
  1125
            if (_this.mashupMode) {
37bad74c2520 Added Voice Annotation Support in MDP
veltr
parents: 794
diff changeset
  1126
                _this.ajaxMashup();
37bad74c2520 Added Voice Annotation Support in MDP
veltr
parents: 794
diff changeset
  1127
            } else {
37bad74c2520 Added Voice Annotation Support in MDP
veltr
parents: 794
diff changeset
  1128
                _this.ajaxSource();
37bad74c2520 Added Voice Annotation Support in MDP
veltr
parents: 794
diff changeset
  1129
            }
37bad74c2520 Added Voice Annotation Support in MDP
veltr
parents: 794
diff changeset
  1130
        }
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
  1131
        _this.throttledRefresh(false);
806
37bad74c2520 Added Voice Annotation Support in MDP
veltr
parents: 794
diff changeset
  1132
    });
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
  1133
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
  1134
    this.onMdpEvent("AnnotationsList.update", function() {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
  1135
        if (_this.ajax_url) {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
  1136
            if (_this.mashupMode) {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
  1137
                _this.ajaxMashup();
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
  1138
            } else {
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
  1139
                _this.ajaxSource();
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
  1140
            }
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
  1141
        }
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
  1142
        _this.throttledRefresh(true);
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
  1143
    });
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
  1144
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
  1145
    if (this.ajax_url) {
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
  1146
        if (this.mashupMode) {
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
  1147
            this.ajaxMashup();
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
  1148
        } else {
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
  1149
            this.ajaxSource();
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
  1150
        }
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
  1151
    } else {
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
  1152
        this.currentSource = this.source;
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
  1153
    }
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
  1154
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
  1155
    if (this.refresh_interval) {
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
  1156
        window.setInterval(function() {
1235
9eee31426156 Upgrade metadataplayer
veltr
parents: 1230
diff changeset
  1157
            _this.currentSource.get();
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
  1158
        }, this.refresh_interval);
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
  1159
    }
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
  1160
    
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1161
    if (this.annotations_count_header){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1162
        this.annotations_count = false;
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1163
    }
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1164
    
1390
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
  1165
    this.onMdpEvent("AnnotationsList.toggle","toggle");
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
  1166
    this.onMdpEvent("AnnotationsList.hide", "hide");
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
  1167
    this.onMdpEvent("AnnotationsList.show", "show");
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
  1168
    
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1169
    this.onMdpEvent("createAnnotationWidget.addedAnnotation", this.throttledRefresh);
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
  1170
    var _events = [
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
  1171
        "timeupdate",
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
  1172
        "seeked",
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1173
        "loadedmetadata",
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1174
        "settimerange"
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
  1175
    ];
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
  1176
    for (var _i = 0; _i < _events.length; _i++) {
784
18dfa62b411a Update of the Metadataplayer
veltr
parents: 764
diff changeset
  1177
        this.onMediaEvent(_events[_i], this.throttledRefresh);
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
  1178
    }
1447
470130d647cb import updates to mdplayer into the platform + added a script to easily build mdplayer from repository + fix the mdplayer config page
durandn
parents: 1445
diff changeset
  1179
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
  1180
    this.throttledRefresh();
1390
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
  1181
    
1445
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1182
    this.showScreen("Main");
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1183
    this.$.find(".Ldt-AnnotationsList-CancelDelete").click(function(){
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1184
        _this.showScreen("Main")
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1185
    });
b4c525005cde upgrade metadataplayer
ymh <ymh.work@gmail.com>
parents: 1394
diff changeset
  1186
    
1390
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
  1187
    this.visible = true;
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
  1188
    if (!this.start_visible){
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
  1189
        this.hide();
e165d0d979e9 Tweaks to CreateAnnotation and AnnotationList to allow them to be hidden or shown on trigger + Tweaks to AnnotationList css for creation date
durandn
parents: 1389
diff changeset
  1190
    }
695
e45166859f96 Tests nouveau metadataplayer
veltr
parents:
diff changeset
  1191
};