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