src/widgets/AnnotationsList.js
author durandn
Fri, 03 Jul 2015 16:57:10 +0200
changeset 1037 5c0416e8bba1
parent 1033 c20df1c080e6
child 1046 eb77616c245f
permissions -rw-r--r--
AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
     1
IriSP.Widgets.AnnotationsList = function(player, config) {
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
     2
    IriSP.Widgets.Widget.call(this, player, config);
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
     3
    this.lastIds = [];
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
     4
    var _this = this;
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
     5
    this.throttledRefresh = IriSP._.throttle(function() {
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
     6
        _this.refresh(false);
983
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
     7
    }, 800);
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
     8
    this.searchString = false;
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
     9
    this.lastSearch = false;
585
44a4a4a179c1 first version of the AnnotationListWidget.
hamidouk
parents:
diff changeset
    10
};
44a4a4a179c1 first version of the AnnotationListWidget.
hamidouk
parents:
diff changeset
    11
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    12
IriSP.Widgets.AnnotationsList.prototype = new IriSP.Widgets.Widget();
585
44a4a4a179c1 first version of the AnnotationListWidget.
hamidouk
parents:
diff changeset
    13
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    14
IriSP.Widgets.AnnotationsList.prototype.defaults = {
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    15
    /*
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    16
     * URL when the annotations are to be reloaded from an LDT-like segment API
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    17
     * e.g.
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    18
     * http://ldt.iri.centrepompidou.fr/ldtplatform/api/ldt/segments/{{media}}/{{begin}}/{{end}}?callback=?
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    19
     */
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    20
    ajax_url : false,
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    21
    /*
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    22
     * number of milliseconds before/after the current timecode when calling the
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    23
     * segment API
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    24
     */
967
b4c6e64acb2d Added a dual mode HTML/Flash player
veltr
parents: 966
diff changeset
    25
    ajax_granularity : 600000, 
925
28efc97b5d78 Corrected MAJOR bug in search results
veltr
parents: 924
diff changeset
    26
    default_thumbnail : "",
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    27
    /*
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    28
     * URL when the annotation is not in the current project, e.g.
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    29
     * http://ldt.iri.centrepompidou.fr/ldtplatform/ldt/front/player/{{media}}/{{project}}/{{annotationType}}#id={{annotation}}
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    30
     */
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    31
    foreign_url : "",
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    32
    annotation_type : false,
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    33
    refresh_interval : 0,
966
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
    34
    limit_count : 20,
924
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents: 923
diff changeset
    35
    newest_first : false,
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    36
    always_visible : false,
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    37
    start_visible: true,
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    38
    show_audio : true,
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    39
    show_filters : false,
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    40
    show_creation_date : false,
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    41
    show_timecode : true, 
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    42
    /*
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    43
     * Only annotation in the current segment will be displayed. Designed to work with the Segments Widget.
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    44
     */
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    45
    filter_by_segments: false,
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    46
    segments_annotation_type: "chap",
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    47
    /*
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    48
     * Set to a username if you only want to display annotations from a given user
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    49
     */
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    50
    show_only_annotation_from_user: false,
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    51
    /*
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    52
     * Show a text field that filter annotations by username
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    53
     */
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    54
    filter_by_user: false,
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    55
    tags : true,
924
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents: 923
diff changeset
    56
    polemics : [{
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents: 923
diff changeset
    57
        keyword: "++",
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents: 923
diff changeset
    58
        background_color: "#c9ecc6"
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents: 923
diff changeset
    59
    },{
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents: 923
diff changeset
    60
        keyword: "--",
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents: 923
diff changeset
    61
        background_color: "#f9c5c6"
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents: 923
diff changeset
    62
    },{
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents: 923
diff changeset
    63
        keyword: "??",
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents: 923
diff changeset
    64
        background_color: "#cec5f9"
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents: 923
diff changeset
    65
    },{
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents: 923
diff changeset
    66
        keyword: "==",
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents: 923
diff changeset
    67
        background_color: "#f9f4c6"
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents: 923
diff changeset
    68
    }]
585
44a4a4a179c1 first version of the AnnotationListWidget.
hamidouk
parents:
diff changeset
    69
};
44a4a4a179c1 first version of the AnnotationListWidget.
hamidouk
parents:
diff changeset
    70
966
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
    71
IriSP.Widgets.AnnotationsList.prototype.messages = {
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
    72
    en: {
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
    73
        voice_annotation: "Voice Annotation",
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
    74
        now_playing: "Now playing..."
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
    75
    },
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
    76
    fr: {
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
    77
        voice_annotation: "Annotation Vocale",
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
    78
        now_playing: "Lecture en cours..."
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
    79
    }
1013
392ddcd212d7 Throwed in a bunch of semicolons
veltr
parents: 1011
diff changeset
    80
};
966
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
    81
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    82
IriSP.Widgets.AnnotationsList.prototype.template =
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    83
    '<div class="Ldt-AnnotationsListWidget">'
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    84
    + '{{#show_filters}}'
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    85
    + '<div class="Ldt-AnnotationsList-Filters">'
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    86
    +    '<input class="Ldt-AnnotationsList-filter-text" type="text" value="Mot-clés"></input>'
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    87
    +    '<select class="Ldt-AnnotationsList-filter-dropdown"></select>'
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    88
    +    '<label class="Ldt-AnnotationsList-filter-checkbox"><input type="checkbox">Toutes annotations</label>'
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    89
    + '</div>'
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    90
    + '{{/show_filters}}'
966
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
    91
    + '{{#show_audio}}<div class="Ldt-AnnotationsList-Audio"></div>{{/show_audio}}'
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    92
    + '<ul class="Ldt-AnnotationsList-ul">'
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
    93
    + '</ul>'
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
    94
    + '</div>';
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
    95
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
    96
IriSP.Widgets.AnnotationsList.prototype.annotationTemplate = 
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
    97
    '<li class="Ldt-AnnotationsList-li Ldt-TraceMe" trace-info="annotation-id:{{id}}, media-id:{{media_id}}" style="{{specific_style}}">'
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
    98
    + '<div class="Ldt-AnnotationsList-ThumbContainer">'
993
a7efd386872a Drag-and-drop support for Renkan
raph
parents: 988
diff changeset
    99
    + '<a href="{{url}}" draggable="true">'
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   100
    + '<img class="Ldt-AnnotationsList-Thumbnail" src="{{thumbnail}}" />'
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   101
    + '</a>'
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   102
    + '</div>'
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   103
    + '{{#show_timecode}}<div class="Ldt-AnnotationsList-Duration">{{begin}} - {{end}}</div>{{/show_timecode}}'
993
a7efd386872a Drag-and-drop support for Renkan
raph
parents: 988
diff changeset
   104
    + '<h3 class="Ldt-AnnotationsList-Title" draggable="true">'
a7efd386872a Drag-and-drop support for Renkan
raph
parents: 988
diff changeset
   105
    + '<a href="{{url}}">{{{htitle}}}</a>'
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   106
    + '</h3>'
993
a7efd386872a Drag-and-drop support for Renkan
raph
parents: 988
diff changeset
   107
    + '<p class="Ldt-AnnotationsList-Description">{{{hdescription}}}</p>'
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   108
    + '{{#created}}'
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   109
    + '<div class="Ldt-AnnotationsList-CreationDate">{{{created}}}</div>'
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   110
    + '{{/created}}'
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   111
    + '{{#tags.length}}'
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   112
    + '<ul class="Ldt-AnnotationsList-Tags">'
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   113
    + '{{#tags}}'
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   114
    + '{{#.}}'
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   115
    + '<li class="Ldt-AnnotationsList-Tag-Li">'
902
14022f1d49ab Added MediaList widget for mashup
veltr
parents: 876
diff changeset
   116
    + '<span>{{.}}</span>'
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   117
    + '</li>'
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   118
    + '{{/.}}'
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   119
    + '{{/tags}}'
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   120
    + '</ul>'
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   121
    + '{{/tags.length}}'
1010
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   122
    + '{{#audio}}<div class="Ldt-AnnotationsList-Play" data-annotation-id="{{id}}">{{l10n.voice_annotation}}</div>{{/audio}}'
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   123
    + '</li>';
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   124
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   125
// obj.url = this.project_url + "/" + media + "/" + annotations[i].meta.project
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   126
// + "/" + annotations[i].meta["id-ref"] + '#id=' + annotations[i].id;
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   127
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   128
IriSP.Widgets.AnnotationsList.prototype.ajaxSource = function() {
957
4da0a5740b6c Starting 'players-as-widgets' branch
veltr
parents: 944
diff changeset
   129
    var _currentTime = this.media.getCurrentTime(),
4da0a5740b6c Starting 'players-as-widgets' branch
veltr
parents: 944
diff changeset
   130
        _duration = this.media.duration;
872
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   131
    this.lastAjaxQuery = _currentTime;
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   132
    var _url = Mustache.to_html(this.ajax_url, {
916
ec6849bbbdcc Removed Namespacing before rewrite
veltr
parents: 909
diff changeset
   133
        media : this.source.currentMedia.id,
872
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   134
        begin : Math.max(0, _currentTime - this.ajax_granularity),
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   135
        end : Math.min(_duration.milliseconds, _currentTime + this.ajax_granularity)
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   136
    });
872
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   137
    this.currentSource = this.player.loadMetadata(IriSP._.defaults({
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   138
        "url" : _url
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   139
    }, this.metadata));
1013
392ddcd212d7 Throwed in a bunch of semicolons
veltr
parents: 1011
diff changeset
   140
};
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   141
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   142
IriSP.Widgets.AnnotationsList.prototype.ajaxMashup = function() {
957
4da0a5740b6c Starting 'players-as-widgets' branch
veltr
parents: 944
diff changeset
   143
    var _currentTime = this.media.getCurrentTime();
4da0a5740b6c Starting 'players-as-widgets' branch
veltr
parents: 944
diff changeset
   144
    var _currentAnnotation = this.source.currentMedia.getAnnotationAtTime(_currentTime);
916
ec6849bbbdcc Removed Namespacing before rewrite
veltr
parents: 909
diff changeset
   145
    if (typeof _currentAnnotation !== "undefined" && _currentAnnotation.id !== this.lastMashupAnnotation) {
ec6849bbbdcc Removed Namespacing before rewrite
veltr
parents: 909
diff changeset
   146
        this.lastMashupAnnotation = _currentAnnotation.id;
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   147
        var _currentMedia = _currentAnnotation.getMedia(),
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   148
            _url = Mustache.to_html(this.ajax_url, {
916
ec6849bbbdcc Removed Namespacing before rewrite
veltr
parents: 909
diff changeset
   149
                media : _currentMedia.id,
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   150
                begin : Math.max(0, _currentAnnotation.annotation.begin.milliseconds - this.ajax_granularity),
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   151
                end : Math.min(_currentMedia.duration.milliseconds, _currentAnnotation.annotation.end.milliseconds + this.ajax_granularity)
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   152
            });
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   153
        this.currentSource = this.player.loadMetadata(IriSP._.defaults({
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   154
            "url" : _url
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   155
        }, this.metadata));
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   156
    }
1013
392ddcd212d7 Throwed in a bunch of semicolons
veltr
parents: 1011
diff changeset
   157
};
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   158
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   159
IriSP.Widgets.AnnotationsList.prototype.refresh = function(_forceRedraw) {
872
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   160
    _forceRedraw = (typeof _forceRedraw !== "undefined" && _forceRedraw);
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   161
    if (this.currentSource.status !== IriSP.Model._SOURCE_STATUS_READY) {
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   162
        return 0;
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   163
    }
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   164
    var _this = this,
957
4da0a5740b6c Starting 'players-as-widgets' branch
veltr
parents: 944
diff changeset
   165
        _currentTime = this.media.getCurrentTime();
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   166
    var _list = this.annotation_type ? this.currentSource.getAnnotationsByTypeTitle(this.annotation_type) : this.currentSource.getAnnotations();
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   167
    if (this.mashupMode) {
957
4da0a5740b6c Starting 'players-as-widgets' branch
veltr
parents: 944
diff changeset
   168
        var _currentAnnotation = this.source.currentMedia.getAnnotationAtTime(_currentTime);
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   169
        if (typeof _currentAnnotation !== "undefined") {
965
eadb7290c325 Improvements in widget communication
veltr
parents: 963
diff changeset
   170
            _currentTime = _currentTime - _currentAnnotation.begin + _currentAnnotation.annotation.begin;
916
ec6849bbbdcc Removed Namespacing before rewrite
veltr
parents: 909
diff changeset
   171
            var _mediaId = _currentAnnotation.getMedia().id;
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   172
            _list = _list.filter(function(_annotation) {
916
ec6849bbbdcc Removed Namespacing before rewrite
veltr
parents: 909
diff changeset
   173
                return _annotation.getMedia().id === _mediaId;
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   174
            });
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   175
        }
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   176
    }
983
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   177
    _list = _list.filter(function(_annotation) {
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   178
        return _annotation.found !== false;
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   179
    });
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   180
    if (this.filter_by_segments) {
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   181
        /*
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   182
         *  A given annotation is considered "in" segment if the middle of it is between the segment beginning and the segment end. 
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   183
         *  Note this is meant to be used for "markings" annotations (not segments)
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   184
         */
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   185
        _segmentsAnnotation = this.currentSource.getAnnotationsByTypeTitle(this.segments_annotation_type)
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   186
        _currentSegments = _segmentsAnnotation.filter(function(_segment){
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   187
            return (_currentTime >= _segment.begin && _currentTime <= _segment.end)
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   188
        });
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   189
        if (_currentSegments.length == 0) {
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   190
            _list = _list.filter(function(_annotation){
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   191
                return false;
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   192
            });
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   193
        }
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   194
        else {
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   195
            _list = _list.filter(function(_annotation){
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   196
                _annotation_time = (_annotation.begin+_annotation.end)/2;
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   197
                return (_currentSegments[0].begin <= _annotation_time && _currentSegments[0].end >= _annotation_time)
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   198
            });
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   199
        }
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   200
    }
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   201
    if (this.show_only_annotation_from_user){
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   202
        _list = _list.filter(function(_annotation){
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   203
           return _annotation.creator == _this.show_only_annotation_from_user;
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   204
        });
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   205
    }
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   206
    if (this.limit_count) {
965
eadb7290c325 Improvements in widget communication
veltr
parents: 963
diff changeset
   207
        /* Get the n annotations closest to current timecode */
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   208
        _list = _list.sortBy(function(_annotation) {
965
eadb7290c325 Improvements in widget communication
veltr
parents: 963
diff changeset
   209
            return Math.abs((_annotation.begin + _annotation.end) / 2 - _currentTime);
1013
392ddcd212d7 Throwed in a bunch of semicolons
veltr
parents: 1011
diff changeset
   210
        }).slice(0, this.limit_count);
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   211
    }
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   212
    if (this.newest_first) {
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   213
        _list = _list.sortBy(function(_annotation) {
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   214
            return -_annotation.created.valueOf();
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   215
        });
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   216
    } else {
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   217
        _list = _list.sortBy(function(_annotation) {
872
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   218
            return _annotation.begin;
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   219
        });
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   220
    }
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   221
    
872
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   222
    var _ids = _list.idIndex;
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   223
    
983
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   224
    if (_forceRedraw || !IriSP._.isEqual(_ids, this.lastIds) || this.searchString !== this.lastSearch) {
872
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   225
        /* This part only gets executed if the list needs updating */
983
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   226
        this.lastSearch = this.searchString;
872
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   227
        this.lastIds = _ids;
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   228
        this.list_$.html("");
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   229
        _list.forEach(function(_annotation) {
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   230
            var _url = (
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   231
                ( typeof _annotation.url !== "undefined" && _annotation.url)
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   232
                ? _annotation.url
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   233
                : (
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   234
                    ( typeof _this.source.projectId !== "undefined" && typeof _annotation.project !== "undefined" && _annotation.project && _this.source.projectId !== _annotation.project )
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   235
                    ? Mustache.to_html(
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   236
                        _this.foreign_url,
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   237
                        {
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   238
                            project : _annotation.project,
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   239
                            media : _annotation.media.id,
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   240
                            annotation : _annotation.id,
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   241
                            annotationType : _annotation.annotationType.id
924
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents: 923
diff changeset
   242
                        }
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   243
                    )
993
a7efd386872a Drag-and-drop support for Renkan
raph
parents: 988
diff changeset
   244
                    : document.location.href.replace(/#.*$/,'') + '#id=' + _annotation.id
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   245
                    )
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   246
            );
1021
7253d4d06f0d update widgets after enhance in annotation platform.
cavaliet
parents: 1013
diff changeset
   247
            var _title = "",
993
a7efd386872a Drag-and-drop support for Renkan
raph
parents: 988
diff changeset
   248
                _description = _annotation.description,
a7efd386872a Drag-and-drop support for Renkan
raph
parents: 988
diff changeset
   249
                _thumbnail = (typeof _annotation.thumbnail !== "undefined" && _annotation.thumbnail ? _annotation.thumbnail : _this.default_thumbnail);
1021
7253d4d06f0d update widgets after enhance in annotation platform.
cavaliet
parents: 1013
diff changeset
   250
            // Update : display creator
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   251
            if (_annotation.creator) {
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   252
                _title = _annotation.creator;
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   253
            }
1021
7253d4d06f0d update widgets after enhance in annotation platform.
cavaliet
parents: 1013
diff changeset
   254
            if (_annotation.title) {
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   255
                var tempTitle = _annotation.title;
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   256
                if( tempTitle.substr(0, _title.length + 1) == (_title + ":") ){
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   257
                    _title = "";
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   258
                }
1021
7253d4d06f0d update widgets after enhance in annotation platform.
cavaliet
parents: 1013
diff changeset
   259
                _title = _title + ( (_title=="") ? "" : ": ") + _annotation.title;
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   260
            }
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   261
            var _bgcolor;
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   262
            IriSP._(_this.polemics).each(function(_polemic) {
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   263
                var _rgxp = IriSP.Model.regexpFromTextOrArray(_polemic.keyword, true);
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   264
                if (_rgxp.test(_title + " " + _description)) {
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   265
                    _bgcolor = _polemic.background_color;
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   266
                }
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   267
            });
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   268
            var _created = false;
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   269
            if (_this.show_creation_date) {
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   270
                _created = _annotation.created.toLocaleDateString()+", "+_annotation.created.toLocaleTimeString();
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   271
            }
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   272
            if(this.tags == true){
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   273
                var _tags = _annotation.getTagTexts();
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   274
            }
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   275
            else {
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   276
                var _tags = false;
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   277
            }
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   278
            var _data = {
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   279
                id : _annotation.id,
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   280
                media_id : _annotation.getMedia().id,
993
a7efd386872a Drag-and-drop support for Renkan
raph
parents: 988
diff changeset
   281
                htitle : IriSP.textFieldHtml(_title),
a7efd386872a Drag-and-drop support for Renkan
raph
parents: 988
diff changeset
   282
                hdescription : IriSP.textFieldHtml(_description),
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   283
                begin : _annotation.begin.toString(),
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   284
                end : _annotation.end.toString(),
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   285
                created : _created,
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   286
                show_timecode : _this.show_timecode,
993
a7efd386872a Drag-and-drop support for Renkan
raph
parents: 988
diff changeset
   287
                thumbnail : _thumbnail,
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   288
                url : _url,
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   289
                tags : _tags,
966
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   290
                specific_style : (typeof _bgcolor !== "undefined" ? "background-color: " + _bgcolor : ""),
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   291
                l10n: _this.l10n
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   292
            };
1010
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   293
            if (_this.show_audio && _annotation.audio && _annotation.audio.href && _annotation.audio.href != "null") {
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   294
                _data.audio = true;
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   295
                if (!_this.jwplayers[_annotation.id]) {
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   296
                    var _audiofile = _annotation.audio.href;
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   297
                    if (_this.audio_url_transform) {
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   298
                        _audiofile = _this.audio_url_transform(_annotation.audio.href);
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   299
                    }
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   300
                    var _tmpId = "jwplayer-" + IriSP.Model.getUID();
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   301
                    _this.jwplayers[_annotation.id] = _tmpId;
1011
7396abb7e251 Corrections on AnnotationsList
veltr
parents: 1010
diff changeset
   302
                    _this.$.find(".Ldt-AnnotationsList-Audio").append(IriSP.jQuery("<div>").attr("id", _tmpId));
1010
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   303
                    jwplayer(_tmpId).setup({
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   304
                        flashplayer: IriSP.getLib("jwPlayerSWF"),
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   305
                        file: _audiofile,
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   306
                        fallback: false,
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   307
                        primary: "flash",
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   308
                        controls: false,
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   309
                        width: 1,
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   310
                        height: 1,
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   311
                        events: {
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   312
                            onPause: function() {
1013
392ddcd212d7 Throwed in a bunch of semicolons
veltr
parents: 1011
diff changeset
   313
                                _this.$.find(".Ldt-AnnotationsList-Play[data-annotation-id=" + _annotation.id + "]").text(_this.l10n.voice_annotation);
1010
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   314
                            },
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   315
                            onPlay: function() {
1013
392ddcd212d7 Throwed in a bunch of semicolons
veltr
parents: 1011
diff changeset
   316
                                _this.$.find(".Ldt-AnnotationsList-Play[data-annotation-id=" + _annotation.id + "]").text(_this.l10n.now_playing);
1011
7396abb7e251 Corrections on AnnotationsList
veltr
parents: 1010
diff changeset
   317
                            }
1010
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   318
                        }
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   319
                    });
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   320
                }
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   321
            }
969
353b0881a0b9 Added On-the-fly (file-less) metadata generation test
veltr
parents: 967
diff changeset
   322
            var _html = Mustache.to_html(_this.annotationTemplate, _data),
353b0881a0b9 Added On-the-fly (file-less) metadata generation test
veltr
parents: 967
diff changeset
   323
                _el = IriSP.jQuery(_html),
353b0881a0b9 Added On-the-fly (file-less) metadata generation test
veltr
parents: 967
diff changeset
   324
                _onselect = function() {
1011
7396abb7e251 Corrections on AnnotationsList
veltr
parents: 1010
diff changeset
   325
                    _this.$.find('.Ldt-AnnotationsList-li').removeClass("selected");
969
353b0881a0b9 Added On-the-fly (file-less) metadata generation test
veltr
parents: 967
diff changeset
   326
                    _el.addClass("selected");
353b0881a0b9 Added On-the-fly (file-less) metadata generation test
veltr
parents: 967
diff changeset
   327
                },
353b0881a0b9 Added On-the-fly (file-less) metadata generation test
veltr
parents: 967
diff changeset
   328
                _onunselect = function() {
1011
7396abb7e251 Corrections on AnnotationsList
veltr
parents: 1010
diff changeset
   329
                    _this.$.find('.Ldt-AnnotationsList-li').removeClass("selected");
969
353b0881a0b9 Added On-the-fly (file-less) metadata generation test
veltr
parents: 967
diff changeset
   330
                };
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   331
            _el.mouseover(function() {
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   332
                    _annotation.trigger("select");
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   333
                })
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   334
                .mouseout(function() {
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   335
                    _annotation.trigger("unselect");
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   336
                })
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   337
                .appendTo(_this.list_$);
996
c472984db275 refactored drag-and-drop interface (IE Compatibility)
veltr
parents: 994
diff changeset
   338
            IriSP.attachDndData(_el.find("[draggable]"), {
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   339
                title: _title,
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   340
                description: _description,
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   341
                uri: _url,
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   342
                image: _annotation.thumbnail
996
c472984db275 refactored drag-and-drop interface (IE Compatibility)
veltr
parents: 994
diff changeset
   343
            });
969
353b0881a0b9 Added On-the-fly (file-less) metadata generation test
veltr
parents: 967
diff changeset
   344
            _el.on("remove", function() {
353b0881a0b9 Added On-the-fly (file-less) metadata generation test
veltr
parents: 967
diff changeset
   345
                _annotation.off("select", _onselect);
353b0881a0b9 Added On-the-fly (file-less) metadata generation test
veltr
parents: 967
diff changeset
   346
                _annotation.off("unselect", _onunselect);
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   347
            });
969
353b0881a0b9 Added On-the-fly (file-less) metadata generation test
veltr
parents: 967
diff changeset
   348
            _annotation.on("select", _onselect);
353b0881a0b9 Added On-the-fly (file-less) metadata generation test
veltr
parents: 967
diff changeset
   349
            _annotation.on("unselect", _onunselect);
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   350
        });
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   351
        
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   352
        /* Correct the empty tag bug */
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   353
        this.$.find('.Ldt-AnnotationsList-Tag-Li').each(function() {
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   354
            var _el = IriSP.jQuery(this);
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   355
            if (!_el.text().replace(/(^\s+|\s+$)/g,'')) {
969
353b0881a0b9 Added On-the-fly (file-less) metadata generation test
veltr
parents: 967
diff changeset
   356
                _el.remove();
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   357
            }
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   358
        });
872
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   359
    
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   360
        this.$.find('.Ldt-AnnotationsList-Tag-Li').click(function() {
983
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   361
            _this.source.getAnnotations().search(IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,''));
966
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   362
        });
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   363
        
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   364
        this.$.find(".Ldt-AnnotationsList-Play").click(function() {
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   365
            var _el = IriSP.jQuery(this),
1010
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   366
                _annid = _el.attr("data-annotation-id");
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   367
            if (_this.jwplayers[_annid]) {
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   368
                jwplayer(_this.jwplayers[_annid]).play();
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   369
            }
966
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   370
            _this.media.pause();
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   371
        });
872
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   372
        
983
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   373
        if (this.source.getAnnotations().searching) {
988
eefd336335f9 Some improvements: Hashtags can be used, links are now clickable, ....
veltr
parents: 983
diff changeset
   374
            var rx = _this.source.getAnnotations().regexp || false;
872
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   375
            this.$.find(".Ldt-AnnotationsList-Title a, .Ldt-AnnotationsList-Description").each(function() {
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   376
                var _$ = IriSP.jQuery(this);
988
eefd336335f9 Some improvements: Hashtags can be used, links are now clickable, ....
veltr
parents: 983
diff changeset
   377
                _$.html(IriSP.textFieldHtml(_$.text(), rx));
eefd336335f9 Some improvements: Hashtags can be used, links are now clickable, ....
veltr
parents: 983
diff changeset
   378
            });
872
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   379
        }
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   380
    }
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   381
    
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   382
    if (this.ajax_url) {
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   383
        if (this.mashupMode) {
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   384
            this.ajaxMashup();
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   385
        } else {
963
d58d0dcdb640 Bugfixes
veltr
parents: 959
diff changeset
   386
            if (Math.abs(_currentTime - this.lastAjaxQuery) > (this.ajax_granularity)) {
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   387
                this.ajaxSource();
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   388
            }
872
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   389
        }
d777d05a16e4 finished AnnotationsList and started New PolemicWidget
veltr
parents: 870
diff changeset
   390
    }
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   391
    
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   392
    return _list.length;
1013
392ddcd212d7 Throwed in a bunch of semicolons
veltr
parents: 1011
diff changeset
   393
};
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   394
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   395
IriSP.Widgets.AnnotationsList.prototype.hide = function() {
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   396
    if (this.visible){
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   397
        this.visible = false;
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   398
        this.widget_$.slideUp()
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   399
    }
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   400
}
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   401
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   402
IriSP.Widgets.AnnotationsList.prototype.show = function() {
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   403
    if(!this.visible){
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   404
        this.visible = true;
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   405
        this.widget_$.slideDown()
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   406
    }
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   407
}
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   408
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   409
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   410
IriSP.Widgets.AnnotationsList.prototype.toggle = function() {
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   411
    if (!this.always_visible) {
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   412
        if (this.visible) {
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   413
            this.hide();
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   414
        } else {
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   415
            this.show();
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   416
        }
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   417
    }
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   418
};
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   419
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 874
diff changeset
   420
IriSP.Widgets.AnnotationsList.prototype.draw = function() {
876
03967b6ada7c ArrowWidget, AnnotationWidget
veltr
parents: 875
diff changeset
   421
    
1010
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   422
    this.jwplayers = {};
959
ee11ed1b739e Mashup Player and Dailymotion are now widgets
veltr
parents: 957
diff changeset
   423
    this.mashupMode = (this.media.elementType === "mashup");
ee11ed1b739e Mashup Player and Dailymotion are now widgets
veltr
parents: 957
diff changeset
   424
    
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   425
    this.renderTemplate();
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   426
    
966
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   427
    var _this = this;
1010
5566738cb829 Updated AnnotationsList for new jwplayer
veltr
parents: 1005
diff changeset
   428
        
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   429
    this.list_$ = this.$.find(".Ldt-AnnotationsList-ul");
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   430
    this.widget_$ = this.$.find(".Ldt-AnnotationsListWidget");
937
eb3c442cec50 Added events on annotation for inter widget communication
veltr
parents: 930
diff changeset
   431
    
966
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   432
    
983
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   433
    this.source.getAnnotations().on("search", function(_text) {
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   434
        _this.searchString = _text;
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   435
        if (_this.source !== _this.currentSource) {
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   436
            _this.currentSource.getAnnotations().search(_text);
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   437
            _this.throttledRefresh();
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   438
        }
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   439
    });
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   440
    this.source.getAnnotations().on("found", function() {
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   441
        _this.throttledRefresh();
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   442
    });
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   443
    this.source.getAnnotations().on("not-found", function() {
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   444
        _this.throttledRefresh();
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   445
    });
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   446
    this.source.getAnnotations().on("clear-search", function() {
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   447
        _this.searchString = false;
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   448
        if (_this.source !== _this.currentSource) {
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   449
            _this.currentSource.getAnnotations().trigger("clear-search");
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   450
        }
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   451
    });
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   452
    this.source.getAnnotations().on("search-cleared", function() {
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   453
        _this.throttledRefresh();
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   454
    });
97fef7a4b189 updated search
veltr
parents: 969
diff changeset
   455
    
966
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   456
    this.onMdpEvent("AnnotationsList.refresh", function() {
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   457
        if (_this.ajax_url) {
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   458
            if (_this.mashupMode) {
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   459
                _this.ajaxMashup();
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   460
            } else {
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   461
                _this.ajaxSource();
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   462
            }
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   463
        }
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   464
        _this.throttledRefresh();
c1c762ad1697 Added Voice Annotation Support
veltr
parents: 965
diff changeset
   465
    });
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   466
    
903
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   467
    if (this.ajax_url) {
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   468
        if (this.mashupMode) {
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   469
            this.ajaxMashup();
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   470
        } else {
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   471
            this.ajaxSource();
d9da52e20f7f AnnotationsList now updated to work with mashups
veltr
parents: 902
diff changeset
   472
        }
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   473
    } else {
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   474
        this.currentSource = this.source;
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   475
    }
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   476
    
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   477
    if (this.refresh_interval) {
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   478
        window.setInterval(function() {
1013
392ddcd212d7 Throwed in a bunch of semicolons
veltr
parents: 1011
diff changeset
   479
            _this.currentSource.get();
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   480
        }, this.refresh_interval);
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   481
    }
674
835f5f454595 WIP - working on ajax autoupdate of the widget.
hamidouk
parents: 642
diff changeset
   482
    
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   483
    this.onMdpEvent("AnnotationsList.toggle","toggle");
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   484
    this.onMdpEvent("AnnotationsList.hide", "hide");
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   485
    this.onMdpEvent("AnnotationsList.show", "show");
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   486
    
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   487
    this.onMdpEvent("createAnnotationWidget.addedAnnotation", "refresh");
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   488
    var _events = [
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   489
        "timeupdate",
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   490
        "seeked",
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   491
        "loadedmetadata"
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   492
    ];
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   493
    for (var _i = 0; _i < _events.length; _i++) {
957
4da0a5740b6c Starting 'players-as-widgets' branch
veltr
parents: 944
diff changeset
   494
        this.onMediaEvent(_events[_i], this.throttledRefresh);
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   495
    }
730
357fc047503b redraw the widget after that an annotation has been added.
hamidouk
parents: 729
diff changeset
   496
    
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   497
    this.throttledRefresh();
1037
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   498
    
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   499
    this.visible = true;
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   500
    if (!this.start_visible){
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   501
        this.hide();
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   502
    }
5c0416e8bba1 AnnotationsList widget new features: show creation date for annotations, hide/show feature on signal trigger, filter by username
durandn
parents: 1033
diff changeset
   503
    
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 852
diff changeset
   504
};