src/widgets/AnnotationsList.js
author durandn
Mon, 21 Sep 2015 18:24:32 +0200
changeset 1059 8158421193e3
parent 1055 b45522b1b2af
child 1068 7623f9af9272
permissions -rw-r--r--
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
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;
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
     5
    this.throttledRefresh = IriSP._.throttle(function() {
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
     6
        _this.refresh(false);
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;
585
44a4a4a179c1 first version of the AnnotationListWidget.
hamidouk
parents:
diff changeset
    10
};
44a4a4a179c1 first version of the AnnotationListWidget.
hamidouk
parents:
diff changeset
    11
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    12
IriSP.Widgets.AnnotationsList.prototype = new IriSP.Widgets.Widget();
585
44a4a4a179c1 first version of the AnnotationListWidget.
hamidouk
parents:
diff changeset
    13
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    14
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
    15
    pre_draw_callback: function(){
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
    16
        return this.importUsers();
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
    17
    },
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
    18
    /*
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
     * 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
    20
     * 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
    21
     * 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
    22
     */
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    23
    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
    24
    /*
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
     * 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
    26
     * segment API
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    27
     */
967
b4c6e64acb2d Added a dual mode HTML/Flash player
veltr
parents: 966
diff changeset
    28
    ajax_granularity : 600000, 
925
28efc97b5d78 Corrected MAJOR bug in search results
veltr
parents: 924
diff changeset
    29
    default_thumbnail : "",
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
    30
    /*
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    31
     * 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
    32
     * 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
    33
     */
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    34
    foreign_url : "",
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    35
    annotation_type : false,
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    36
    refresh_interval : 0,
966
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
    37
    limit_count : 20,
924
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents: 923
diff changeset
    38
    newest_first : 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
    39
    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
    40
    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
    41
    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
    42
    show_filters : false,
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
    43
    keyword_filter: true,
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
    44
    date_filter: true,
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
    45
    user_filter: true,
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
    46
    segment_filter: true,
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
    47
    latest_contributions_filter: false,
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
    48
    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
    49
    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
    50
    custom_header : false,
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
    51
    annotations_count_header : 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
    52
    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
    53
    show_timecode : 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
    54
    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
    55
    /*
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    56
     * 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
    57
     */
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
    58
    allow_annotations_deletion: false,
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
    59
    /*
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
    60
     * 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
    61
     */
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
    62
    api_delete_endpoint : "",
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
    63
    api_delete_method: "DELETE",
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
    64
    api_users_endpoint: "",
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
    65
    api_users_method: "GET",
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
    66
    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
    67
        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
    68
    },
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
    69
    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
    70
    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
    71
    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
    72
    /*
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    73
     * 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
    74
     */
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    75
    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
    76
    /*
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    77
     * 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
    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
    tags : true,
924
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents: 923
diff changeset
    80
    polemics : [{
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents: 923
diff changeset
    81
        keyword: "++",
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents: 923
diff changeset
    82
        background_color: "#c9ecc6"
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents: 923
diff changeset
    83
    },{
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents: 923
diff changeset
    84
        keyword: "--",
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents: 923
diff changeset
    85
        background_color: "#f9c5c6"
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents: 923
diff changeset
    86
    },{
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents: 923
diff changeset
    87
        keyword: "??",
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents: 923
diff changeset
    88
        background_color: "#cec5f9"
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents: 923
diff changeset
    89
    },{
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents: 923
diff changeset
    90
        keyword: "==",
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents: 923
diff changeset
    91
        background_color: "#f9f4c6"
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents: 923
diff changeset
    92
    }]
585
44a4a4a179c1 first version of the AnnotationListWidget.
hamidouk
parents:
diff changeset
    93
};
44a4a4a179c1 first version of the AnnotationListWidget.
hamidouk
parents:
diff changeset
    94
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
    95
IriSP.Widgets.AnnotationsList.prototype.importUsers = function(){
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
    96
    if (!this.source.users_data){
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
    97
        this.usernames = Array();
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
    98
        var _this = this,
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
    99
            _list = this.getWidgetAnnotations(),
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   100
            usernames_list_string = "";
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   101
        
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   102
        _list.forEach(function(_annotation){
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   103
            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
   104
                _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
   105
            }
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   106
        });
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   107
        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
   108
            usernames_list_string+=_username+","
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   109
        })
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   110
        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
   111
        _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
   112
        return IriSP.jQuery.ajax({
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   113
            async: false,
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   114
            url: _url,
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   115
            type: "GET",
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   116
            success: function(_data) {
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   117
                _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
   118
            },
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   119
            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
   120
                console.log(_xhr)
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   121
                console.log(_error)
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   122
                console.log(_thrown)
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   123
            }
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   124
        })
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   125
    }
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   126
}
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   127
966
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   128
IriSP.Widgets.AnnotationsList.prototype.messages = {
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   129
    en: {
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   130
        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
   131
        now_playing: "Now playing...",
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
   132
        everyone: "Everyone",
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   133
        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
   134
        segment_filter: "All cuttings",
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   135
        latest_contributions: "Latest contributions",
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   136
        close_widget: "Close",
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   137
        confirm: "Confirm",
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   138
        cancel: "Cancel",
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   139
        annotation_deletion_delete: "You will delete this annotation : ",
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   140
        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
   141
        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
   142
        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
   143
    },
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   144
    fr: {
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   145
        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
   146
        now_playing: "Lecture en cours...",
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
   147
        everyone: "Tous",
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   148
        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
   149
        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
   150
        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
   151
        close_widget: "Fermer",
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   152
        confirm: "Confirmer",
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   153
        cancel: "Annuler",
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   154
        annotation_deletion_delete: "Vous allez supprimer cette annotation: ",
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   155
        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
   156
        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
   157
        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
   158
    }
1013
392ddcd212d7 Throwed in a bunch of semicolons
veltr
parents: 1011
diff changeset
   159
};
966
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   160
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   161
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
   162
    '{{#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
   163
    +     '{{#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
   164
    +     '{{^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
   165
    + '</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
   166
    + '<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
   167
    +     '<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
   168
    +         '{{#show_filters}}'
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   169
    +         '<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
   170
    +             '{{#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
   171
    +             '{{#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
   172
    +             '{{#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
   173
    +             '{{#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
   174
    +             '{{#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
   175
    +         '</div>'
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   176
    +         '{{/show_filters}}'
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   177
    +         '{{#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
   178
    +         '<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
   179
    +         '</ul>'
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   180
    +     '</div>'    
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   181
    +     '{{#allow_annotations_deletion}}'
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   182
    +     '<div id="{{id}}" class="Ldt-AnnotationsList-Screen Ldt-AnnotationsList-ScreenDelete">'
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   183
    +         '<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
   184
    +         '<ul class="Ldt-AnnotationsList-ul-ToDelete"></ul>'
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   185
    +         '{{l10n.annotation_deletion_delete}} <a class="Ldt-AnnotationsList-ConfirmDelete">{{l10n.confirm}}</a> <a class="Ldt-AnnotationsList-CancelDelete">{{l10n.cancel}}</a>'
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   186
    +     '</div>'
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   187
    +     '<div id="{{id}}" class="Ldt-AnnotationsList-Screen Ldt-AnnotationsList-ScreenSending">'
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   188
    +         '<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
   189
    +         '{{l10n.annotation_deletion_sending}}'
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   190
    +     '</div>'
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   191
    +     '<div id="{{id}}" class="Ldt-AnnotationsList-Screen Ldt-AnnotationsList-ScreenSuccess">'
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   192
    +         '<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
   193
    +         '{{l10n.annotation_deletion_success}}'
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   194
    +     '</div>'
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   195
    +     '<div id="{{id}}" class="Ldt-AnnotationsList-Screen Ldt-AnnotationsList-ScreenError">'
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   196
    +         '<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
   197
    +         '{{l10n.annotation_deletion_error}}'
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   198
    +     '</div>'
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   199
    +     '{{/allow_annotations_deletion}}'
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   200
    + '</div>';
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   201
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   202
IriSP.Widgets.AnnotationsList.prototype.annotationTemplate = 
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
   203
    '<li class="Ldt-AnnotationsList-li Ldt-TraceMe" trace-info="annotation-id:{{id}}, media-id:{{media_id}}" style="{{specific_style}}">'
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   204
    + '<div id="{{id}}" class="Ldt-AnnotationsList-ThumbContainer Ldt-AnnotationsList-Annotation-Screen Ldt-AnnotationsList-Annotation-ScreenMain">'
993
a7efd386872a Drag-and-drop support for Renkan
raph
parents: 988
diff changeset
   205
    + '<a href="{{url}}" draggable="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
   206
    + '<img class="Ldt-AnnotationsList-Thumbnail" src="{{thumbnail}}" />'
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   207
    + '</a>'
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   208
    + '</div>'
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   209
    + '{{#allow_annotations_deletion}}'
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   210
    + '<div id={{id}} class="Ldt-AnnotationsList-DeleteButton">&#10006;</div>'
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   211
    + '{{/allow_annotations_deletion}}'
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
   212
    + '{{#show_timecode}}<div class="Ldt-AnnotationsList-Duration">{{begin}} - {{end}}</div>{{/show_timecode}}'
993
a7efd386872a Drag-and-drop support for Renkan
raph
parents: 988
diff changeset
   213
    + '<h3 class="Ldt-AnnotationsList-Title" draggable="true">'
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   214
    + '<a {{#url}} href="{{url}}" {{/url}}>{{{htitle}}}</a>'
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   215
    + '</h3>'
993
a7efd386872a Drag-and-drop support for Renkan
raph
parents: 988
diff changeset
   216
    + '<p class="Ldt-AnnotationsList-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
   217
    + '{{#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
   218
    + '<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
   219
    + '{{/created}}'
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   220
    + '{{#tags.length}}'
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   221
    + '<ul class="Ldt-AnnotationsList-Tags">'
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   222
    + '{{#tags}}'
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   223
    + '{{#.}}'
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   224
    + '<li class="Ldt-AnnotationsList-Tag-Li">'
902
14022f1d49ab Added MediaList widget for mashup
veltr
parents: 876
diff changeset
   225
    + '<span>{{.}}</span>'
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   226
    + '</li>'
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   227
    + '{{/.}}'
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   228
    + '{{/tags}}'
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   229
    + '</ul>'
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   230
    + '{{/tags.length}}'
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   231
    + '{{#audio}}<div class="Ldt-AnnotationsList-Play" data-annotation-id="{{id}}">{{l10n.voice_annotation}}</div>{{/audio}}'    
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   232
    + '</li>';
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   233
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
   234
// 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
   235
// + "/" + annotations[i].meta["id-ref"] + '#id=' + annotations[i].id;
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   236
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   237
IriSP.Widgets.AnnotationsList.prototype.ajaxSource = function() {
957
4da0a5740b6c Starting 'players-as-widgets' branch
veltr
parents: 944
diff changeset
   238
    var _currentTime = this.media.getCurrentTime(),
4da0a5740b6c Starting 'players-as-widgets' branch
veltr
parents: 944
diff changeset
   239
        _duration = this.media.duration;
872
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   240
    this.lastAjaxQuery = _currentTime;
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   241
    var _url = Mustache.to_html(this.ajax_url, {
916
ec6849bbbdcc Removed Namespacing before rewrite
veltr
parents: 909
diff changeset
   242
        media : this.source.currentMedia.id,
872
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   243
        begin : Math.max(0, _currentTime - this.ajax_granularity),
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   244
        end : Math.min(_duration.milliseconds, _currentTime + this.ajax_granularity)
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   245
    });
872
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   246
    this.currentSource = this.player.loadMetadata(IriSP._.defaults({
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   247
        "url" : _url
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   248
    }, this.metadata));
1013
392ddcd212d7 Throwed in a bunch of semicolons
veltr
parents: 1011
diff changeset
   249
};
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   250
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   251
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
   252
    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
   253
        .siblings().hide();
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   254
}
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   255
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   256
IriSP.Widgets.AnnotationsList.prototype.ajaxMashup = function() {
957
4da0a5740b6c Starting 'players-as-widgets' branch
veltr
parents: 944
diff changeset
   257
    var _currentTime = this.media.getCurrentTime();
4da0a5740b6c Starting 'players-as-widgets' branch
veltr
parents: 944
diff changeset
   258
    var _currentAnnotation = this.source.currentMedia.getAnnotationAtTime(_currentTime);
916
ec6849bbbdcc Removed Namespacing before rewrite
veltr
parents: 909
diff changeset
   259
    if (typeof _currentAnnotation !== "undefined" && _currentAnnotation.id !== this.lastMashupAnnotation) {
ec6849bbbdcc Removed Namespacing before rewrite
veltr
parents: 909
diff changeset
   260
        this.lastMashupAnnotation = _currentAnnotation.id;
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   261
        var _currentMedia = _currentAnnotation.getMedia(),
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   262
            _url = Mustache.to_html(this.ajax_url, {
916
ec6849bbbdcc Removed Namespacing before rewrite
veltr
parents: 909
diff changeset
   263
                media : _currentMedia.id,
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   264
                begin : Math.max(0, _currentAnnotation.annotation.begin.milliseconds - this.ajax_granularity),
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   265
                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
   266
            });
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   267
        this.currentSource = this.player.loadMetadata(IriSP._.defaults({
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   268
            "url" : _url
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   269
        }, this.metadata));
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   270
    }
1013
392ddcd212d7 Throwed in a bunch of semicolons
veltr
parents: 1011
diff changeset
   271
};
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   272
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   273
IriSP.Widgets.AnnotationsList.prototype.refresh = function(_forceRedraw) {
872
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   274
    _forceRedraw = (typeof _forceRedraw !== "undefined" && _forceRedraw);
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   275
    if (this.currentSource.status !== IriSP.Model._SOURCE_STATUS_READY) {
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   276
        return 0;
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   277
    }
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   278
    var _this = this,
957
4da0a5740b6c Starting 'players-as-widgets' branch
veltr
parents: 944
diff changeset
   279
        _currentTime = this.media.getCurrentTime();
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   280
    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
   281
    if (this.mashupMode) {
957
4da0a5740b6c Starting 'players-as-widgets' branch
veltr
parents: 944
diff changeset
   282
        var _currentAnnotation = this.source.currentMedia.getAnnotationAtTime(_currentTime);
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   283
        if (typeof _currentAnnotation !== "undefined") {
965
eadb7290c325 Improvements in widget communication
veltr
parents: 963
diff changeset
   284
            _currentTime = _currentTime - _currentAnnotation.begin + _currentAnnotation.annotation.begin;
916
ec6849bbbdcc Removed Namespacing before rewrite
veltr
parents: 909
diff changeset
   285
            var _mediaId = _currentAnnotation.getMedia().id;
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   286
            _list = _list.filter(function(_annotation) {
916
ec6849bbbdcc Removed Namespacing before rewrite
veltr
parents: 909
diff changeset
   287
                return _annotation.getMedia().id === _mediaId;
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   288
            });
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   289
        }
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   290
    }
983
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   291
    _list = _list.filter(function(_annotation) {
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   292
        return _annotation.found !== false;
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   293
    });
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
   294
    
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   295
    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
   296
        /*
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   297
         *  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
   298
         *  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
   299
         */
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   300
        _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
   301
        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
   302
            _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
   303
                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
   304
            });
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
   305
        }
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
   306
        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
   307
            _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
   308
                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
   309
            });
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
   310
        }
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
   311
        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
   312
            _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
   313
                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
   314
            });
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   315
        }
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   316
        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
   317
            _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
   318
                _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
   319
                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
   320
            });
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   321
        }
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   322
        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
   323
            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
   324
            this.refreshHeader();
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   325
        }
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
   326
    }
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   327
    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
   328
        _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
   329
           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
   330
        });
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   331
    }
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   332
    if (this.limit_count) {
965
eadb7290c325 Improvements in widget communication
veltr
parents: 963
diff changeset
   333
        /* Get the n annotations closest to current timecode */
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   334
        _list = _list.sortBy(function(_annotation) {
965
eadb7290c325 Improvements in widget communication
veltr
parents: 963
diff changeset
   335
            return Math.abs((_annotation.begin + _annotation.end) / 2 - _currentTime);
1013
392ddcd212d7 Throwed in a bunch of semicolons
veltr
parents: 1011
diff changeset
   336
        }).slice(0, this.limit_count);
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   337
    }
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
   338
    
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   339
    if (this.newest_first) {
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   340
        _list = _list.sortBy(function(_annotation) {
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   341
            return -_annotation.created.valueOf();
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   342
        });
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   343
    } else {
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   344
        _list = _list.sortBy(function(_annotation) {
872
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   345
            return _annotation.begin;
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   346
        });
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   347
    }
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   348
    
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
   349
    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
   350
        if (this.user_filter){
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   351
            _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
   352
            if (_username != "false")
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   353
            {
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   354
                _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
   355
                    return _annotation.creator == _username
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   356
                })
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   357
            }
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
   358
        }
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   359
        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
   360
        _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
   361
            if (_keyword != ""){
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   362
                _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
   363
                   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
   364
                });
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   365
            }
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
   366
        }
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   367
        if (this.date_filter){
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   368
            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
   369
                _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
   370
                _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
   371
                    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
   372
                });
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   373
            }
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   374
        }
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   375
        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
   376
            _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
   377
                return -_annotation.created.valueOf();
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   378
            });
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   379
            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
   380
                
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   381
                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
   382
                    return _annotation.creator == _user;
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   383
                })[0];
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   384
                _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
   385
                    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
   386
                });
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
   387
            });
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
   388
        }
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
   389
        
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
   390
    }
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
   391
    
872
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   392
    var _ids = _list.idIndex;
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   393
    
983
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   394
    if (_forceRedraw || !IriSP._.isEqual(_ids, this.lastIds) || this.searchString !== this.lastSearch) {
872
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   395
        /* This part only gets executed if the list needs updating */
983
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   396
        this.lastSearch = this.searchString;
872
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   397
        this.lastIds = _ids;
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   398
        this.list_$.html("");
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   399
        _list.forEach(function(_annotation) {
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   400
            var _url = (
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   401
                ( typeof _annotation.url !== "undefined" && _annotation.url)
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   402
                ? _annotation.url
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   403
                : (
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   404
                    ( 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
   405
                    ? Mustache.to_html(
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   406
                        _this.foreign_url,
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   407
                        {
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   408
                            project : _annotation.project,
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   409
                            media : _annotation.media.id,
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   410
                            annotation : _annotation.id,
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   411
                            annotationType : _annotation.annotationType.id
924
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents: 923
diff changeset
   412
                        }
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   413
                    )
993
a7efd386872a Drag-and-drop support for Renkan
raph
parents: 988
diff changeset
   414
                    : document.location.href.replace(/#.*$/,'') + '#id=' + _annotation.id
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   415
                    )
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   416
            );
1021
7253d4d06f0d update widgets after enhance in annotation platform.
cavaliet
parents: 1013
diff changeset
   417
            var _title = "",
993
a7efd386872a Drag-and-drop support for Renkan
raph
parents: 988
diff changeset
   418
                _description = _annotation.description,
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
   419
                _thumbnail = (typeof _annotation.thumbnail !== "undefined" && _annotation.thumbnail ? _annotation.thumbnail : _this.default_thumbnail)
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
   420
            
1021
7253d4d06f0d update widgets after enhance in annotation platform.
cavaliet
parents: 1013
diff changeset
   421
            // Update : display creator
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
   422
            if (_annotation.creator) {
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   423
                var _users = _this.source.users_data.filter(function(_user_data){
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   424
                    return _user_data.username == _annotation.creator
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   425
                }),
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   426
                    _user = {};
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   427
                if (_users.length == 0){
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   428
                    _user.username = _annotation.creator
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   429
                }
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   430
                else{
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   431
                    _user = _users[0]
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   432
                }
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   433
                _title = _this.make_name_string_function(_user);
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   434
            }
1021
7253d4d06f0d update widgets after enhance in annotation platform.
cavaliet
parents: 1013
diff changeset
   435
            if (_annotation.title) {
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
   436
                var tempTitle = _annotation.title;
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   437
                if( tempTitle.substr(0, _title.length + 1) == (_title + ":") ){
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   438
                    _title = "";
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
                }
1021
7253d4d06f0d update widgets after enhance in annotation platform.
cavaliet
parents: 1013
diff changeset
   440
                _title = _title + ( (_title=="") ? "" : ": ") + _annotation.title;
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   441
            }
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   442
            var _bgcolor;
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   443
            IriSP._(_this.polemics).each(function(_polemic) {
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   444
                var _rgxp = IriSP.Model.regexpFromTextOrArray(_polemic.keyword, true);
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   445
                if (_rgxp.test(_title + " " + _description)) {
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   446
                    _bgcolor = _polemic.background_color;
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   447
                }
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   448
            });
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
   449
            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
   450
            if (_this.show_creation_date) {
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   451
                _created = _annotation.created.toLocaleDateString()+", "+_annotation.created.toLocaleTimeString();
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   452
            }
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   453
            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
   454
                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
   455
            }
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
            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
   457
                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
   458
            }
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   459
            var _data = {
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   460
                id : _annotation.id,
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   461
                media_id : _annotation.getMedia().id,
993
a7efd386872a Drag-and-drop support for Renkan
raph
parents: 988
diff changeset
   462
                htitle : IriSP.textFieldHtml(_title),
a7efd386872a Drag-and-drop support for Renkan
raph
parents: 988
diff changeset
   463
                hdescription : IriSP.textFieldHtml(_description),
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   464
                begin : _annotation.begin.toString(),
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   465
                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
   466
                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
   467
                show_timecode : _this.show_timecode,
993
a7efd386872a Drag-and-drop support for Renkan
raph
parents: 988
diff changeset
   468
                thumbnail : _thumbnail,
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   469
                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
   470
                tags : _tags,
966
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   471
                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
   472
                l10n: _this.l10n,
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   473
                allow_annotations_deletion: _this.allow_annotations_deletion
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   474
            };
1010
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   475
            if (_this.show_audio && _annotation.audio && _annotation.audio.href && _annotation.audio.href != "null") {
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   476
                _data.audio = true;
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   477
                if (!_this.jwplayers[_annotation.id]) {
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   478
                    var _audiofile = _annotation.audio.href;
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   479
                    if (_this.audio_url_transform) {
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   480
                        _audiofile = _this.audio_url_transform(_annotation.audio.href);
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   481
                    }
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   482
                    var _tmpId = "jwplayer-" + IriSP.Model.getUID();
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   483
                    _this.jwplayers[_annotation.id] = _tmpId;
1011
7396abb7e251 Corrections on AnnotationsList
veltr
parents: 1010
diff changeset
   484
                    _this.$.find(".Ldt-AnnotationsList-Audio").append(IriSP.jQuery("<div>").attr("id", _tmpId));
1010
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   485
                    jwplayer(_tmpId).setup({
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   486
                        flashplayer: IriSP.getLib("jwPlayerSWF"),
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   487
                        file: _audiofile,
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   488
                        fallback: false,
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   489
                        primary: "flash",
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   490
                        controls: false,
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   491
                        width: 1,
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   492
                        height: 1,
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   493
                        events: {
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   494
                            onPause: function() {
1013
392ddcd212d7 Throwed in a bunch of semicolons
veltr
parents: 1011
diff changeset
   495
                                _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
   496
                            },
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   497
                            onPlay: function() {
1013
392ddcd212d7 Throwed in a bunch of semicolons
veltr
parents: 1011
diff changeset
   498
                                _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
   499
                            }
1010
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   500
                        }
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   501
                    });
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   502
                }
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   503
            }
969
353b0881a0b9 Added On-the-fly (file-less) metadata generation test
veltr
parents: 967
diff changeset
   504
            var _html = Mustache.to_html(_this.annotationTemplate, _data),
353b0881a0b9 Added On-the-fly (file-less) metadata generation test
veltr
parents: 967
diff changeset
   505
                _el = IriSP.jQuery(_html),
353b0881a0b9 Added On-the-fly (file-less) metadata generation test
veltr
parents: 967
diff changeset
   506
                _onselect = function() {
1011
7396abb7e251 Corrections on AnnotationsList
veltr
parents: 1010
diff changeset
   507
                    _this.$.find('.Ldt-AnnotationsList-li').removeClass("selected");
969
353b0881a0b9 Added On-the-fly (file-less) metadata generation test
veltr
parents: 967
diff changeset
   508
                    _el.addClass("selected");
353b0881a0b9 Added On-the-fly (file-less) metadata generation test
veltr
parents: 967
diff changeset
   509
                },
353b0881a0b9 Added On-the-fly (file-less) metadata generation test
veltr
parents: 967
diff changeset
   510
                _onunselect = function() {
1011
7396abb7e251 Corrections on AnnotationsList
veltr
parents: 1010
diff changeset
   511
                    _this.$.find('.Ldt-AnnotationsList-li').removeClass("selected");
969
353b0881a0b9 Added On-the-fly (file-less) metadata generation test
veltr
parents: 967
diff changeset
   512
                };
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   513
            _el.mouseover(function() {
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   514
                    _annotation.trigger("select");
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   515
                })
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   516
                .mouseout(function() {
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   517
                    _annotation.trigger("unselect");
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   518
                })
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
   519
                .click(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
   520
                    _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
   521
                })
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   522
                .appendTo(_this.list_$);
996
c472984db275 refactored drag-and-drop interface (IE Compatibility)
veltr
parents: 994
diff changeset
   523
            IriSP.attachDndData(_el.find("[draggable]"), {
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
   524
                title: _title,
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   525
                description: _description,
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   526
                uri: _url,
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   527
                image: _annotation.thumbnail
996
c472984db275 refactored drag-and-drop interface (IE Compatibility)
veltr
parents: 994
diff changeset
   528
            });
969
353b0881a0b9 Added On-the-fly (file-less) metadata generation test
veltr
parents: 967
diff changeset
   529
            _el.on("remove", function() {
353b0881a0b9 Added On-the-fly (file-less) metadata generation test
veltr
parents: 967
diff changeset
   530
                _annotation.off("select", _onselect);
353b0881a0b9 Added On-the-fly (file-less) metadata generation test
veltr
parents: 967
diff changeset
   531
                _annotation.off("unselect", _onunselect);
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   532
            });
969
353b0881a0b9 Added On-the-fly (file-less) metadata generation test
veltr
parents: 967
diff changeset
   533
            _annotation.on("select", _onselect);
353b0881a0b9 Added On-the-fly (file-less) metadata generation test
veltr
parents: 967
diff changeset
   534
            _annotation.on("unselect", _onunselect);
937
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
        
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   537
        /* Correct the empty tag bug */
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   538
        this.$.find('.Ldt-AnnotationsList-Tag-Li').each(function() {
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   539
            var _el = IriSP.jQuery(this);
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   540
            if (!_el.text().replace(/(^\s+|\s+$)/g,'')) {
969
353b0881a0b9 Added On-the-fly (file-less) metadata generation test
veltr
parents: 967
diff changeset
   541
                _el.remove();
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   542
            }
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   543
        });
872
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   544
    
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   545
        this.$.find('.Ldt-AnnotationsList-Tag-Li').click(function() {
983
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   546
            _this.source.getAnnotations().search(IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,''));
966
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   547
        });
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   548
        
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   549
        this.$.find(".Ldt-AnnotationsList-Play").click(function() {
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   550
            var _el = IriSP.jQuery(this),
1010
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   551
                _annid = _el.attr("data-annotation-id");
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   552
            if (_this.jwplayers[_annid]) {
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   553
                jwplayer(_this.jwplayers[_annid]).play();
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   554
            }
966
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   555
            _this.media.pause();
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   556
        });
872
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   557
        
983
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   558
        if (this.source.getAnnotations().searching) {
988
eefd336335f9 Some improvements: Hashtags can be used, links are now clickable, ....
veltr
parents: 983
diff changeset
   559
            var rx = _this.source.getAnnotations().regexp || false;
872
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   560
            this.$.find(".Ldt-AnnotationsList-Title a, .Ldt-AnnotationsList-Description").each(function() {
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   561
                var _$ = IriSP.jQuery(this);
988
eefd336335f9 Some improvements: Hashtags can be used, links are now clickable, ....
veltr
parents: 983
diff changeset
   562
                _$.html(IriSP.textFieldHtml(_$.text(), rx));
eefd336335f9 Some improvements: Hashtags can be used, links are now clickable, ....
veltr
parents: 983
diff changeset
   563
            });
872
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   564
        }
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   565
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   566
        this.$.find(".Ldt-AnnotationsList-DeleteButton").click(_this.functionWrapper("onDeleteClick"))
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   567
    }
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   568
    
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   569
    if (this.ajax_url) {
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   570
        if (this.mashupMode) {
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   571
            this.ajaxMashup();
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   572
        } else {
963
d58d0dcdb640 Bugfixes
veltr
parents: 959
diff changeset
   573
            if (Math.abs(_currentTime - this.lastAjaxQuery) > (this.ajax_granularity)) {
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   574
                this.ajaxSource();
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   575
            }
872
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   576
        }
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
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
    
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   579
    return _list.length;
1013
392ddcd212d7 Throwed in a bunch of semicolons
veltr
parents: 1011
diff changeset
   580
};
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   581
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   582
IriSP.Widgets.AnnotationsList.prototype.onDeleteClick = function(event){
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   583
    
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   584
    ann_id = event.target.id;
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   585
    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
   586
    delete_preview_$.html("");
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   587
    _list = this.getWidgetAnnotations()
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   588
    _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
   589
        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
   590
    })
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   591
    var _annotation = _list[0],
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   592
        _title = "",
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   593
        _this = this;
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   594
    if (_annotation.creator) {
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   595
        var _users = _this.source.users_data.filter(function(_user_data){
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   596
            return _user_data.username == _annotation.creator
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   597
        }),
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   598
            _user = {};
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   599
        if (_users.length == 0){
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   600
            _user.username = _annotation.creator
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   601
        }
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   602
        else{
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   603
            _user = _users[0]
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   604
        }
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   605
        _title = _this.make_name_string_function(_user);
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   606
    }
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   607
    if (_annotation.title) {
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   608
        var tempTitle = _annotation.title;
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   609
        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
   610
            _title = "";
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   611
        }
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   612
        _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
   613
    }
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   614
    var _created = false;
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   615
    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
   616
        _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
   617
    }
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   618
    var _data = {
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   619
            id : _annotation.id,
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   620
            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
   621
            htitle : IriSP.textFieldHtml(_title),
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   622
            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
   623
            begin : _annotation.begin.toString(),
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   624
            end : _annotation.end.toString(),
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   625
            created : _created,
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   626
            show_timecode : this.show_timecode,
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   627
            tags : false,
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   628
            l10n: this.l10n,
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   629
            allow_annotations_deletion: false
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   630
    }
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   631
    _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
   632
    delete_preview_$.html(_html)
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   633
    
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   634
    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
   635
        _this.sendDelete(ann_id);
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   636
    });
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   637
    
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   638
    this.showScreen("Delete");    
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   639
}
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   640
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   641
IriSP.Widgets.AnnotationsList.prototype.refreshHeader = function() {
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   642
    var annotation_count_string = " (" + this.annotations_count +" annotations)";
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   643
    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
   644
    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
   645
        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
   646
    );
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   647
}
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   648
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
   649
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
   650
    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
   651
    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
   652
        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
   653
        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
   654
            _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
   655
        });
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   656
        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
   657
    }
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   658
}
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   659
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   660
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
   661
    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
   662
        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
   663
        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
   664
        this.widget_$.slideDown();
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   665
        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
   666
    }
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   667
}
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   668
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   669
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   670
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
   671
    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
   672
        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
   673
            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
   674
        } 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
   675
            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
   676
        }
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   677
    }
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   678
};
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   679
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   680
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
   681
    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
   682
        this.showScreen("Main");
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   683
    }
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   684
}
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   685
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   686
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
   687
    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
   688
        _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
   689
    
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   690
    IriSP.jQuery.ajax({
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   691
        url: _url,
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   692
        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
   693
        contentType: 'application/json',
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   694
        success: function(_data) {
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   695
            _this.showScreen('Success');
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   696
            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
   697
            _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
   698
            _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
   699
        },
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   700
        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
   701
            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
   702
            _this.showScreen('Error');
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   703
            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
   704
        }
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   705
    });
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   706
    this.showScreen('Sending');
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   707
}
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   708
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   709
IriSP.Widgets.AnnotationsList.prototype.draw = function() {
1010
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   710
    this.jwplayers = {};
959
ee11ed1b739e Mashup Player and Dailymotion are now widgets
veltr
parents: 957
diff changeset
   711
    this.mashupMode = (this.media.elementType === "mashup");
ee11ed1b739e Mashup Player and Dailymotion are now widgets
veltr
parents: 957
diff changeset
   712
    
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   713
    this.renderTemplate();
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   714
    
966
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   715
    var _this = this;
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   716
    
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   717
    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
   718
    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
   719
    
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   720
    if (this.show_filters){
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   721
        if (this.user_filter){
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   722
            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
   723
            this.userselect_$.change(function(){
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   724
                _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
   725
            });
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   726
            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
   727
            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
   728
                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
   729
                    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
   730
                }),
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
   731
                    _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
   732
                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
   733
                    _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
   734
                }
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
   735
                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
   736
                    _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
   737
                }
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
   738
                _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
   739
            });
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   740
        }
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   741
        if (this.keyword_filter){
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   742
            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
   743
            this.keywordinput_$.keyup(function(){
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   744
                _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
   745
            });
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   746
            
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   747
        }
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   748
        if (this.segment_filter){
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   749
            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
   750
            this.ignoresegmentcheckbox_$.click(function(){
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   751
                _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
   752
            });
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   753
        }
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   754
        if(this.date_filter){
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   755
            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
   756
            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
   757
            this.datefilterinput_$.change(function(){
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   758
                _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
   759
            })
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   760
            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
   761
                currentDate = new Date();
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   762
                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
   763
            }
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   764
        }
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   765
        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
   766
            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
   767
            this.latestcontributionscheckbox_$.click(function(){
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   768
                _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
   769
            });
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   770
        }
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   771
    }
966
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   772
    
983
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   773
    this.source.getAnnotations().on("search", function(_text) {
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   774
        _this.searchString = _text;
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   775
        if (_this.source !== _this.currentSource) {
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   776
            _this.currentSource.getAnnotations().search(_text);
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   777
            _this.throttledRefresh();
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   778
        }
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   779
    });
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   780
    this.source.getAnnotations().on("found", function() {
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   781
        _this.throttledRefresh();
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   782
    });
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   783
    this.source.getAnnotations().on("not-found", function() {
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   784
        _this.throttledRefresh();
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   785
    });
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   786
    this.source.getAnnotations().on("clear-search", function() {
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   787
        _this.searchString = false;
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   788
        if (_this.source !== _this.currentSource) {
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   789
            _this.currentSource.getAnnotations().trigger("clear-search");
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   790
        }
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   791
    });
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   792
    
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   793
    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
   794
        _this.showScreen("Main");
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   795
    })
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   796
    
983
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   797
    this.source.getAnnotations().on("search-cleared", function() {
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   798
        _this.throttledRefresh();
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   799
    });
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   800
    
966
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   801
    this.onMdpEvent("AnnotationsList.refresh", function() {
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   802
        if (_this.ajax_url) {
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   803
            if (_this.mashupMode) {
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   804
                _this.ajaxMashup();
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   805
            } else {
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   806
                _this.ajaxSource();
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   807
            }
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   808
        }
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   809
        _this.throttledRefresh();
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   810
    });
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   811
    
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   812
    if (this.ajax_url) {
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   813
        if (this.mashupMode) {
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   814
            this.ajaxMashup();
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   815
        } else {
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   816
            this.ajaxSource();
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   817
        }
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   818
    } else {
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   819
        this.currentSource = this.source;
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   820
    }
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   821
    
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   822
    if (this.refresh_interval) {
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   823
        window.setInterval(function() {
1013
392ddcd212d7 Throwed in a bunch of semicolons
veltr
parents: 1011
diff changeset
   824
            _this.currentSource.get();
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   825
        }, this.refresh_interval);
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   826
    }
674
835f5f454595 WIP - working on ajax autoupdate of the widget.
hamidouk
parents: 642
diff changeset
   827
    
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   828
    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
   829
        this.annotations_count = false;
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   830
    }
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   831
    
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
   832
    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
   833
    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
   834
    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
   835
    
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
   836
    this.onMdpEvent("createAnnotationWidget.addedAnnotation", this.throttledRefresh);
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   837
    var _events = [
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   838
        "timeupdate",
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   839
        "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
   840
        "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
   841
        "settimerange"
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   842
    ];
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   843
    for (var _i = 0; _i < _events.length; _i++) {
957
4da0a5740b6c Starting 'players-as-widgets' branch
veltr
parents: 944
diff changeset
   844
        this.onMediaEvent(_events[_i], this.throttledRefresh);
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   845
    }
730
357fc047503b redraw the widget after that an annotation has been added.
hamidouk
parents: 729
diff changeset
   846
    
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   847
    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
   848
    
1053
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   849
    this.showScreen("Main");
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   850
    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
   851
        _this.showScreen("Main")
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   852
    });
149a4ea20ea7 Added support for deleting annotations + Added support for displaying user names under another format
durandn
parents: 1046
diff changeset
   853
    
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
   854
    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
   855
    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
   856
        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
   857
    }
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   858
};