store comments
This commit is contained in:
parent
2dcf358eb5
commit
57692665a4
2 changed files with 35 additions and 6 deletions
|
|
@ -46,6 +46,7 @@ oml.ui.viewer = function() {
|
|||
function saveAnnotations(data) {
|
||||
if (data) {
|
||||
data.created = data.created || (new Date).toISOString();
|
||||
data.comments = data.comments || [];
|
||||
annotations.push(data);
|
||||
}
|
||||
localStorage[item + '.annotations'] = JSON.stringify(annotations)
|
||||
|
|
@ -57,6 +58,14 @@ oml.ui.viewer = function() {
|
|||
saveAnnotations()
|
||||
}
|
||||
|
||||
var annotationEvents = {
|
||||
change: function() {
|
||||
console.log('change...')
|
||||
console.log(annotations)
|
||||
saveAnnotations()
|
||||
}
|
||||
}
|
||||
|
||||
that.updateElement = function() {
|
||||
item = ui.item;
|
||||
if (item && item.length) {
|
||||
|
|
@ -75,7 +84,7 @@ oml.ui.viewer = function() {
|
|||
if (event == 'addAnnotation') {
|
||||
console.log('adding', data.id)
|
||||
saveAnnotations(data);
|
||||
var $annotation = oml.ui.annotation(data, $iframe)
|
||||
var $annotation = oml.ui.annotation(data, $iframe).bindEvent(annotationEvents)
|
||||
oml.$ui.annotationFolder.append($annotation);
|
||||
$annotation.annotate();
|
||||
} else if (event == 'removeAnnotation') {
|
||||
|
|
@ -93,7 +102,7 @@ oml.ui.viewer = function() {
|
|||
init: function() {
|
||||
loadAnnotations(function(annotations) {
|
||||
annotations.forEach(function(data) {
|
||||
var $annotation = oml.ui.annotation(data, $iframe)
|
||||
var $annotation = oml.ui.annotation(data, $iframe).bindEvent(annotationEvents)
|
||||
oml.$ui.annotationFolder.append($annotation);
|
||||
})
|
||||
// fixme: trigger loaded event from reader instead?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue