src/widgets/LatestAnnotation.js
author durandn
Fri, 18 Sep 2015 14:48:13 +0200
changeset 1054 cfea8c04c8c7
parent 1046 eb77616c245f
child 1055 b45522b1b2af
permissions -rw-r--r--
Added support for displaying user name using additional user informations
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1041
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
     1
/* Widget that displays the last annotation that was posted, optionally for current segment, optionally for a given username */
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
     2
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
     3
IriSP.Widgets.LatestAnnotation = function(player, config){
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
     4
    IriSP.Widgets.Widget.call(this, player, config);
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
     5
};
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
     6
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
     7
IriSP.Widgets.LatestAnnotation.prototype = new IriSP.Widgets.Widget();
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
     8
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
     9
IriSP.Widgets.LatestAnnotation.prototype.defaults = {
1054
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    10
    pre_draw_callback: function(){
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    11
        return this.importUsers();
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    12
    },
1041
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
    13
    from_user: false,
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
    14
    filter_by_segment: false,
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
    15
    segments_annotation_type: "chap",
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
    16
    hide_without_segment: false,
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
    17
    annotation_type: "contribution",
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
    18
    /*
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
    19
     * Set to a username if you only want to display annotations from a given user
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
    20
     */
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
    21
    show_only_annotation_from_user: 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: 1041
diff changeset
    22
    /*
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: 1041
diff changeset
    23
     * Displays a button that copy currently displayed annotation into CreateAnnotation input field
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: 1041
diff changeset
    24
     */
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: 1041
diff changeset
    25
    copy_and_edit_button: 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: 1041
diff changeset
    26
    /*
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: 1041
diff changeset
    27
     * Allows clicks on an annotation from Annotations to display the annotation content into this widget
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: 1041
diff changeset
    28
     */
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: 1041
diff changeset
    29
    selectable_annotations: false,
1041
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
    30
    empty_message: false,
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
    31
    starts_hidden: 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: 1041
diff changeset
    32
    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: 1041
diff changeset
    33
    custom_header: false,
1054
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    34
    make_name_string_function: function(params){
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    35
        return params.username ? params.username : "Anonymous";
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    36
    }, 
1041
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
    37
};
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
    38
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: 1041
diff changeset
    39
IriSP.Widgets.LatestAnnotation.prototype.messages = {
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: 1041
diff changeset
    40
    fr : {
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: 1041
diff changeset
    41
        copy_and_edit: "Copier et Editer",
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: 1041
diff changeset
    42
        empty : "Aucune annotation à afficher",
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: 1041
diff changeset
    43
        header: "Dernière annotation"
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: 1041
diff changeset
    44
    },
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: 1041
diff changeset
    45
    en: {
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: 1041
diff changeset
    46
        copy_and_edit: "Copy and Edit",
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: 1041
diff changeset
    47
        empty: "No annotation to display",
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: 1041
diff changeset
    48
        header: "Last annotation"
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: 1041
diff changeset
    49
    }
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: 1041
diff changeset
    50
}
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: 1041
diff changeset
    51
1041
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
    52
IriSP.Widgets.LatestAnnotation.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: 1041
diff changeset
    53
    "{{#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: 1041
diff changeset
    54
    + "<p class='Ldt-LatestAnnotation-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: 1041
diff changeset
    55
    +     "{{#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: 1041
diff changeset
    56
    +     "{{^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: 1041
diff changeset
    57
    + "</p>"
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: 1041
diff changeset
    58
    + "{{/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: 1041
diff changeset
    59
    + "<div class='Ldt-LatestAnnotation'>"
1041
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
    60
    + "</div>";
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
    61
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
    62
IriSP.Widgets.LatestAnnotation.prototype.annotationTemplate =
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
    63
    "<div class='Ldt-LatestAnnotation-Box'>"
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: 1041
diff changeset
    64
    +     "<div class='Ldt-LatestAnnotation-Element Ldt-LatestAnnotation-CreationDate'>{{{annotation_created}}}</div>" 
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: 1041
diff changeset
    65
    +     "<div class='Ldt-LatestAnnotation-Element Ldt-LatestAnnotation-Title'>{{{annotation_creator}}}{{#annotation_title}}: {{{annotation_title}}}{{/annotation_title}}</div>" 
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: 1041
diff changeset
    66
    +     "<div class='Ldt-LatestAnnotation-Element Ldt-LatestAnnotation-Content'>"
1041
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
    67
    +         "{{{annotation_content}}}"
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: 1041
diff changeset
    68
    +     "</div>"
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: 1041
diff changeset
    69
    + "{{#copy_and_edit_button}}<div class='Ldt-LatestAnnotation-CopyEditButton'>{{button_text}}</div>{{/copy_and_edit_button}}"
1041
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
    70
    + "</div>"
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
    71
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: 1041
diff changeset
    72
1054
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    73
IriSP.Widgets.LatestAnnotation.prototype.importUsers = function(){
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    74
    if (!this.source.users_data){
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    75
        this.usernames = Array();
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    76
        var _this = this,
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    77
            _list = this.getWidgetAnnotations(),
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    78
            usernames_list_string = "";
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    79
        
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    80
        _list.forEach(function(_annotation){
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    81
            if(_this.usernames.indexOf(_annotation.creator) == -1){
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    82
                _this.usernames.push(_annotation.creator);
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    83
            }
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    84
        });
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    85
        this.usernames.forEach(function(_username){
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    86
            usernames_list_string+=_username+","
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    87
        })
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    88
        usernames_list_string = usernames_list_string.substring(0, usernames_list_string.length - 1);
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    89
        _url = Mustache.to_html(this.api_users_endpoint, {usernames_list_string: encodeURIComponent(usernames_list_string), usernames_list_length: this.usernames.length});
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    90
        return IriSP.jQuery.ajax({
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    91
            async: false,
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    92
            url: _url,
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    93
            type: "GET",
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    94
            success: function(_data) {
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    95
                _this.source.users_data = _data.objects
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    96
            },
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    97
            error: function(_xhr, _error, _thrown) {
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    98
                console.log(_xhr)
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
    99
                console.log(_error)
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   100
                console.log(_thrown)
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   101
            }
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   102
        })
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   103
    }
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   104
    console.log(this.source.users_data)
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   105
}
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   106
    
1041
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   107
IriSP.Widgets.LatestAnnotation.prototype.draw = function(){
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   108
    var _this = this;
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   109
    this.renderTemplate();
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   110
    
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   111
    this.annotationContainer_$ = this.$.find('.Ldt-LatestAnnotation');
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   112
    
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: 1041
diff changeset
   113
    if (this.selectable_annotations){
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: 1041
diff changeset
   114
        this.onMdpEvent("AnnotationsList.refresh", 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: 1041
diff changeset
   115
            _this.getWidgetAnnotations().forEach(function(_annotation){
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: 1041
diff changeset
   116
                _annotation.off("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: 1041
diff changeset
   117
                _annotation.on("click", function(){
1054
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   118
                    _users = this.source.users_data.filter(function(_user_data){
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   119
                        return _user_data.username == _annotation.creator
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   120
                    })
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   121
                    if (_users.length == 0){
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   122
                        _user.username = _annotation.creator;
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   123
                    }
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   124
                    else {
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   125
                        _user = _users[0];
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   126
                    }
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   127
                    _user_display_string = _this.make_name_string_function(_user)
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: 1041
diff changeset
   128
                    _html = Mustache.to_html(_this.annotationTemplate, {
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: 1041
diff changeset
   129
                        annotation_created: _annotation.created.toLocaleDateString()+", "+_annotation.created.toLocaleTimeString(),
1054
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   130
                        annotation_creator: _user_display_string,
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: 1041
diff changeset
   131
                        annotation_title: _annotation.title,
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: 1041
diff changeset
   132
                        annotation_content: _annotation.description,
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: 1041
diff changeset
   133
                        copy_and_edit_button: _this.copy_and_edit_button,
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: 1041
diff changeset
   134
                        button_text: _this.l10n.copy_and_edit,
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: 1041
diff changeset
   135
                    });
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: 1041
diff changeset
   136
                    _this.annotationContainer_$.html(_html);
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: 1041
diff changeset
   137
                    _this.selectedAnnotation = true;
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: 1041
diff changeset
   138
                });
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: 1041
diff changeset
   139
            }); 
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: 1041
diff changeset
   140
        });
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: 1041
diff changeset
   141
        
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: 1041
diff changeset
   142
        this.segments = _this.source.getAnnotationsByTypeTitle(this.segments_annotation_type)
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: 1041
diff changeset
   143
        this.segments.forEach(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: 1041
diff changeset
   144
            _segment.on("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: 1041
diff changeset
   145
                _this.selectedAnnotation = 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: 1041
diff changeset
   146
            })
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: 1041
diff changeset
   147
        })
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: 1041
diff changeset
   148
        this.currentSegment = 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: 1041
diff changeset
   149
    }
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: 1041
diff changeset
   150
    
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: 1041
diff changeset
   151
    this.onMediaEvent("timeupdate", 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: 1041
diff changeset
   152
        _this.refresh();
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: 1041
diff changeset
   153
    });
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: 1041
diff changeset
   154
    this.onMediaEvent("settimerange", function(_timeRange){
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: 1041
diff changeset
   155
        _this.refresh(_timeRange);
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: 1041
diff changeset
   156
    })
1041
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   157
    
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   158
    if (this.starts_hidden){
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   159
        this.visible = true;
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   160
        this.hide();
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   161
    }
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   162
    else{
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   163
        this.visible = false;
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   164
        this.show();
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   165
    }
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   166
    
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: 1041
diff changeset
   167
    this.selectedAnnotation = false; // This flag tells the widget if it must display last annotation (false) or clicked annotation (true)
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: 1041
diff changeset
   168
    this.player.trigger("AnnotationsList.refresh");
1041
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   169
    this.refresh();
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   170
}
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   171
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   172
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: 1041
diff changeset
   173
IriSP.Widgets.LatestAnnotation.prototype.refresh = function(_timeRange){
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: 1041
diff changeset
   174
    _timeRange = typeof _timeRange !== 'undefined' ? _timeRange : 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: 1041
diff changeset
   175
    var _this = this;
1041
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   176
    if (this.hide_without_segment){
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: 1041
diff changeset
   177
        if (!_timeRange && !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: 1041
diff changeset
   178
            var _currentTime = this.media.getCurrentTime();
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: 1041
diff changeset
   179
            var _currentSegments = this.segments.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: 1041
diff changeset
   180
                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: 1041
diff changeset
   181
            });
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: 1041
diff changeset
   182
            if (_currentSegments.length == 0){
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: 1041
diff changeset
   183
                this.currentSegment = 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: 1041
diff changeset
   184
                this.selectedAnnotation = 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: 1041
diff changeset
   185
            }
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: 1041
diff changeset
   186
            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: 1041
diff changeset
   187
                this.currentSegment = _currentSegments[0]
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: 1041
diff changeset
   188
            }
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: 1041
diff changeset
   189
        }
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: 1041
diff changeset
   190
        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: 1041
diff changeset
   191
            var _segmentBegin = _timeRange? _timeRange[0] : this.media.getTimeRange()[0],
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: 1041
diff changeset
   192
                _segmentEnd = _timeRange? _timeRange[1] : this.media.getTimeRange()[1];
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: 1041
diff changeset
   193
            if ((!this.currentSegment)||(this.currentSegment.begin != _segmentBegin || this.currentSegment.end != _segmentEnd)) {
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: 1041
diff changeset
   194
                var _currentSegments = this.segments.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: 1041
diff changeset
   195
                    return _segment.begin == _segmentBegin && _segment.end == _segmentEnd
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: 1041
diff changeset
   196
                });
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: 1041
diff changeset
   197
                if (_currentSegments.length > 0){
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: 1041
diff changeset
   198
                    this.selectedAnnotation = 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: 1041
diff changeset
   199
                    this.currentSegment = _currentSegments[0];
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: 1041
diff changeset
   200
                }
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: 1041
diff changeset
   201
            }
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: 1041
diff changeset
   202
        }
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: 1041
diff changeset
   203
        if (!this.currentSegment){
1041
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   204
            if (this.visible){
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: 1041
diff changeset
   205
                this.hide();
1041
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   206
            }
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   207
        }
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   208
        else {
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   209
            if (!this.visible){
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: 1041
diff changeset
   210
                this.show();
1041
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   211
            }
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   212
        }
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   213
    }
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: 1041
diff changeset
   214
    
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: 1041
diff changeset
   215
    if (this.visible && !this.selectedAnnotation){
1041
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   216
        var _list = this.getWidgetAnnotations();
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: 1041
diff changeset
   217
        
1041
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   218
        if(this.filter_by_segment){
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: 1041
diff changeset
   219
            if (!this.currentSegment) {
1041
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   220
                _list = _list.filter(function(_annotation){
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   221
                    return false;
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   222
                });
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   223
            }
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   224
            else {
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   225
                _list = _list.filter(function(_annotation){
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   226
                    _annotationTime = (_annotation.begin+_annotation.end)/2;
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: 1041
diff changeset
   227
                    return (_this.currentSegment.begin <= _annotationTime && _this.currentSegment.end >= _annotationTime);
1041
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   228
                });
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   229
            }
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: 1041
diff changeset
   230
        }
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: 1041
diff changeset
   231
        _list = _list.sortBy(function(_annotation){
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: 1041
diff changeset
   232
            return _annotation.created;
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: 1041
diff changeset
   233
        });
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: 1041
diff changeset
   234
        
1054
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   235
        var _latestAnnotation = false,
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   236
            _html="",
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   237
            _user_display_string = "",
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   238
            _user = {};
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: 1041
diff changeset
   239
        if (_list.length != 0){
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: 1041
diff changeset
   240
            _latestAnnotation = _list.pop();
1054
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   241
            _users = this.source.users_data.filter(function(_user_data){
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   242
                return _user_data.username == _latestAnnotation.creator
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   243
            })
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   244
            if (_users.length == 0){
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   245
                _user.username = _latestAnnotation.creator;
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   246
            }
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   247
            else {
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   248
                _user = _users[0];
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   249
            }
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   250
            _user_display_string = this.make_name_string_function(_user)
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: 1041
diff changeset
   251
            _html = Mustache.to_html(this.annotationTemplate, {
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: 1041
diff changeset
   252
                annotation_created: _latestAnnotation.created.toLocaleDateString()+", "+_latestAnnotation.created.toLocaleTimeString(),
1054
cfea8c04c8c7 Added support for displaying user name using additional user informations
durandn
parents: 1046
diff changeset
   253
                annotation_creator: _user_display_string,
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: 1041
diff changeset
   254
                annotation_title: _latestAnnotation.title,
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: 1041
diff changeset
   255
                annotation_content: _latestAnnotation.description,
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: 1041
diff changeset
   256
                copy_and_edit_button: this.copy_and_edit_button,
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: 1041
diff changeset
   257
                button_text: this.l10n.copy_and_edit,
1041
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   258
            });
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: 1041
diff changeset
   259
        }
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: 1041
diff changeset
   260
        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: 1041
diff changeset
   261
            var _empty_message = this.l10n.empty
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: 1041
diff changeset
   262
            if (this.empty_message) {
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: 1041
diff changeset
   263
                _empty_message = this.empty_message
1041
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   264
            }
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: 1041
diff changeset
   265
            _html = "<div class='Ldt-LatestAnnotation-Element Ldt-LatestAnnotation-NoAnnotation'>"+_empty_message+"</div>";
1041
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   266
        }
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: 1041
diff changeset
   267
        this.annotationContainer_$.html(_html);    
1041
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   268
    }
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: 1041
diff changeset
   269
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: 1041
diff changeset
   270
    if(this.copy_and_edit_button){
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: 1041
diff changeset
   271
        this.copyAndEditButton_$ = this.$.find('.Ldt-LatestAnnotation-CopyEditButton');
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: 1041
diff changeset
   272
        this.copyAndEditButton_$.click(this.functionWrapper("copy_and_edit"));
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: 1041
diff changeset
   273
    }
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: 1041
diff changeset
   274
}
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: 1041
diff changeset
   275
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: 1041
diff changeset
   276
IriSP.Widgets.LatestAnnotation.prototype.copy_and_edit = 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: 1041
diff changeset
   277
    this.player.trigger("CreateAnnotation.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: 1041
diff changeset
   278
    this.player.trigger("AnnotationsList.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: 1041
diff changeset
   279
    annotationText = $('.Ldt-LatestAnnotation-Content').get(0).innerHTML;
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: 1041
diff changeset
   280
    
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: 1041
diff changeset
   281
    $('.Ldt-CreateAnnotation-Description').removeClass('empty');
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: 1041
diff changeset
   282
    $('.Ldt-CreateAnnotation-Description').val(annotationText);
1041
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   283
}
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   284
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   285
IriSP.Widgets.LatestAnnotation.prototype.hide = function() {
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   286
    if (this.visible){
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   287
        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: 1041
diff changeset
   288
        this.$.find('.Ldt-LatestAnnotation-header').hide();
1041
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   289
        this.annotationContainer_$.hide()
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   290
    }
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   291
}
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   292
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   293
IriSP.Widgets.LatestAnnotation.prototype.show = function() {
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   294
    if(!this.visible){
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   295
        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: 1041
diff changeset
   296
        this.$.find('.Ldt-LatestAnnotation-header').show();
1041
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   297
        this.annotationContainer_$.show()
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   298
    }
423a8c6f9c4d New widget LastAnnotation that currently displays last annotation posted (can be configured to work for currently viewed segment)
durandn
parents:
diff changeset
   299
}