diff -r 539c9bee5372 -r 7623f9af9272 src/widgets/AnnotationsList.js --- a/src/widgets/AnnotationsList.js Fri Sep 25 14:45:38 2015 +0200 +++ b/src/widgets/AnnotationsList.js Fri Oct 02 11:27:17 2015 +0200 @@ -2,11 +2,12 @@ IriSP.Widgets.Widget.call(this, player, config); this.lastIds = []; var _this = this; - this.throttledRefresh = IriSP._.throttle(function() { - _this.refresh(false); + this.throttledRefresh = IriSP._.throttle(function(full) { + _this.refresh(full); }, 800); this.searchString = false; this.lastSearch = false; + this.localSource = undefined; }; IriSP.Widgets.AnnotationsList.prototype = new IriSP.Widgets.Widget(); @@ -25,7 +26,7 @@ * number of milliseconds before/after the current timecode when calling the * segment API */ - ajax_granularity : 600000, + ajax_granularity : 600000, default_thumbnail : "", /* * URL when the annotation is not in the current project, e.g. @@ -36,6 +37,25 @@ refresh_interval : 0, limit_count : 20, newest_first : false, + + show_audio: true, + show_creator: false, + show_controls: false, + show_end_time: true, + show_publish: false, + show_twitter: false, + twitter_hashtag: '', + // Callback for Edit action. Leave undefined for default action. + on_edit: undefined, + publish_type: "PublicContribution", + // Used to publish annotations + api_endpoint_template: "", + api_serializer: "ldt_annotate", + api_method: "POST", + editable: false, + // Id that will be used as localStorage key + editable_storage: "", + always_visible : false, start_visible: true, show_audio : true, @@ -77,6 +97,7 @@ * Show a text field that filter annotations by username */ tags : true, + polemics : [{ keyword: "++", background_color: "#c9ecc6" @@ -93,12 +114,12 @@ }; IriSP.Widgets.AnnotationsList.prototype.importUsers = function(){ - if (!this.source.users_data){ + if (!this.source.users_data && this.api_users_endpoint){ this.usernames = Array(); var _this = this, _list = this.getWidgetAnnotations(), usernames_list_string = ""; - + _list.forEach(function(_annotation){ if(_this.usernames.indexOf(_annotation.creator) == -1){ _this.usernames.push(_annotation.creator); @@ -129,6 +150,16 @@ en: { voice_annotation: "Voice Annotation", now_playing: "Now playing...", + previous: "Previous", + next: "Next", + set_time: "Double-click to update to current player time", + edit_annotation: "Edit note", + delete_annotation: "Delete note", + publish_annotation: "Make note public", + import_annotations: "Paste or load notes in this field and press Import.", + confirm_delete_message: "You are about to delete {{ annotation.title }}. Are you sure you want to delete it?", + confirm_publish_message: "You are about to publish {{ annotation.title }}. Are you sure you want to make it public?", + tweet_annotation: "Tweet annotation", everyone: "Everyone", header: "Annotations for this content", segment_filter: "All cuttings", @@ -144,6 +175,16 @@ fr: { voice_annotation: "Annotation Vocale", now_playing: "Lecture en cours...", + previous: "Précédent", + next: "Suivant", + set_time: "Double-cliquer pour fixer au temps du lecteur", + edit_annotation: "Éditer la note", + delete_annotation: "Supprimer la note", + publish_annotation: "Rendre la note publique", + import_annotations: "Copiez ou chargez des notes dans ce champ et appuyez sur Import", + confirm_delete_message: "Vous allez supprimer {{ annotation.title }}. Êtes-vous certain(e) ?", + confirm_publish_message: "Vous allez publier {{ annotation.title }}. Êtes-vous certain(e) ?", + tweet_annotation: "Tweeter l'annotation", everyone: "Tous", header: "Annotations sur ce contenu", segment_filter: "Tous les segments", @@ -174,61 +215,69 @@ + '{{#latest_contributions_filter}}{{/latest_contributions_filter}}' + '' + '{{/show_filters}}' + + '{{#show_controls}}
{{ l10n.previous }} | {{ l10n.next }}
{{/show_controls}}' + '{{#show_audio}}
{{/show_audio}}' + '' + '' + '{{#allow_annotations_deletion}}' - + '
' + + '
' + '' + '' + '{{l10n.annotation_deletion_delete}} {{l10n.confirm}} {{l10n.cancel}}' + '
' - + '
' + + '
' + '' + '{{l10n.annotation_deletion_sending}}' + '
' - + '
' + + '
' + '' + '{{l10n.annotation_deletion_success}}' + '
' - + '
' + + '
' + '' + '{{l10n.annotation_deletion_error}}' + '
' + '{{/allow_annotations_deletion}}' + '
'; -IriSP.Widgets.AnnotationsList.prototype.annotationTemplate = - '
  • ' - + '
    ' - + '' - + '' - + '' +IriSP.Widgets.AnnotationsList.prototype.annotationTemplate = + '
  • ' + + '
    ' + + '' + + '' + + '' + '
    ' + '{{#allow_annotations_deletion}}' - + '
    ' + + '
    ' + '{{/allow_annotations_deletion}}' - + '{{#show_timecode}}
    {{begin}} - {{end}}
    {{/show_timecode}}' - + '

    ' - + '{{{htitle}}}' + + '{{#show_timecode}}
    {{begin}}{{#show_end_time}} - {{end}}{{/show_end_time}}
    {{/show_timecode}}' + + '

    ' + + '{{{htitle}}}' + + '{{#show_creator}}{{ creator }}{{/show_creator}}' + '

    ' - + '

    {{{hdescription}}}

    ' + + '

    {{{hdescription}}}

    ' + '{{#created}}' + '
    {{{created}}}
    ' + '{{/created}}' + '{{#tags.length}}' + '
      ' - + '{{#tags}}' - + '{{#.}}' - + '
    • ' - + '{{.}}' - + '
    • ' - + '{{/.}}' - + '{{/tags}}' + + '{{#tags}}' + + '{{#.}}' + + '
    • ' + + '{{.}}' + + '
    • ' + + '{{/.}}' + + '{{/tags}}' + '
    ' + '{{/tags.length}}' - + '{{#audio}}
    {{l10n.voice_annotation}}
    {{/audio}}' + + '{{#audio}}
    {{l10n.voice_annotation}}
    {{/audio}}' + + '
    ' + + '{{#show_twitter}}{{/show_twitter}}' + + '{{#show_publish}}
    {{/show_publish}}' + + '{{#editable}}
    ' + + '
    {{/editable}}' + + '
    ' + '
  • '; // obj.url = this.project_url + "/" + media + "/" + annotations[i].meta.project @@ -270,6 +319,78 @@ } }; +/* + * Import annotations + */ +IriSP.Widgets.AnnotationsList.prototype.importAnnotations = function () { + var widget = this; + var $ = IriSP.jQuery; + var textarea = $("