export annotations
This commit is contained in:
parent
9c765bf863
commit
fbcbc2ab7b
4 changed files with 82 additions and 2 deletions
62
static/js/exportAnnotationsDialog.js
Normal file
62
static/js/exportAnnotationsDialog.js
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
'use strict';
|
||||
|
||||
oml.ui.exportAnnotationsDialog = function(data) {
|
||||
|
||||
var ui = oml.user.ui,
|
||||
|
||||
$text = Ox.Input({
|
||||
type: 'textarea',
|
||||
style: 'squared',
|
||||
value: getAnnotationsText(),
|
||||
width: 640,
|
||||
height: 480
|
||||
})
|
||||
.css({margin: '16px'}),
|
||||
|
||||
that = Ox.Dialog({
|
||||
buttons: [
|
||||
Ox.Button({
|
||||
id: 'done',
|
||||
style: 'squared',
|
||||
title: Ox._('Done')
|
||||
})
|
||||
.bindEvent({
|
||||
click: function() {
|
||||
that.close();
|
||||
}
|
||||
})
|
||||
],
|
||||
closeButton: true,
|
||||
content: $text,
|
||||
height: 480 + 2 * 16,
|
||||
keys: {enter: 'done'},
|
||||
removeOnClose: true,
|
||||
title: Ox._('Export Annotations'),
|
||||
width: 640 + 2* 16
|
||||
})
|
||||
.bindEvent({
|
||||
close: function() {
|
||||
that.close();
|
||||
},
|
||||
open: function() {
|
||||
// ..
|
||||
}
|
||||
});
|
||||
|
||||
function getAnnotationsText() {
|
||||
var annotations = oml.$ui.viewer.getAnnotations()
|
||||
var text = 'Annotations for ' + data.title + ' (' + data.author.join(', ') + ')\n\n\n\n'
|
||||
text += annotations.map(function(annotation) {
|
||||
var text = 'Quote:\n\n' + annotation.text
|
||||
if (annotation.notes.length) {
|
||||
text += '\n\nNotes:\n' + annotation.notes.map(function(note) {
|
||||
return note.value
|
||||
}).join('\n\n')
|
||||
}
|
||||
return text
|
||||
}).join('\n\n\n\n')
|
||||
return text
|
||||
}
|
||||
return that;
|
||||
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue