function getAuthorName(userId) {
// insert your userId to author name mapping code here
return '[[' + userId + ']]';
}
var isDownloading = false;
var $document = $(document);
$document.on('noteCreated', function(e, annotation, $noteContainer) {
var authorName = getAuthorName(annotation.Author);
$noteContainer.find('.noteAuthor').text(authorName);
});
$document.on('annotationLineCreated', function(e, annotation, lineElement) {
var i18nOptions = lineElement.data('i18n-options');
i18nOptions.author = getAuthorName(annotation.Author);
lineElement.data('i18n-options', i18nOptions);
lineElement.i18n();
});
var superSerialize = Annotations.Annotation.prototype.serialize;
Annotations.Annotation.prototype.serialize = function(element, pageMatrix, isExport) {
var el = superSerialize.call(this, element, pageMatrix);
var $el = $(el);
if (isDownloading) {
var authorName = getAuthorName($el.attr("title"));
$el.attr("title", authorName);
}
return el;
};
$document.on('documentLoaded', function() {
$('#downloadButton').parent().off().on('click', function() {
isDownloading = true;
readerControl.activeButtonID = '#downloadButton';
readerControl.activeButtonClass = 'disk_save';
readerControl.downloadFile({ downloadType: 'pdf' });
isDownloading = false;
});
});