enter to add annotation
This commit is contained in:
parent
8ab9ac9588
commit
fedd0c7e80
4 changed files with 68 additions and 20 deletions
|
|
@ -15,7 +15,6 @@ oml.ui.annotation = function(annotation, $iframe) {
|
|||
note.editable = !note.user
|
||||
return note
|
||||
}) : []
|
||||
console.log(annotation.notes)
|
||||
var $notes = Ox.ArrayEditable({
|
||||
editing: true,
|
||||
items: notes,
|
||||
|
|
@ -25,17 +24,7 @@ oml.ui.annotation = function(annotation, $iframe) {
|
|||
margin: '2px',
|
||||
minHeight: '12px'
|
||||
}).bindEvent({
|
||||
doubleclick: function(data) {
|
||||
if (!$notes.options('items').length) {
|
||||
$notes.addItem(0, {
|
||||
id: 'A',
|
||||
value: '',
|
||||
editable: true
|
||||
}).options({
|
||||
selected: 'A'
|
||||
}).editItem()
|
||||
}
|
||||
},
|
||||
doubleclick: addNote,
|
||||
submit: function(data) {
|
||||
var note = Ox.getObjectById(annotation.notes, data.id)
|
||||
if (note) {
|
||||
|
|
@ -67,9 +56,24 @@ oml.ui.annotation = function(annotation, $iframe) {
|
|||
}
|
||||
}).append($quote).append($notes);
|
||||
|
||||
|
||||
function addNote() {
|
||||
if (!$notes.options('items').length) {
|
||||
that.select()
|
||||
$notes.addItem(0, {
|
||||
id: 'A',
|
||||
value: '',
|
||||
editable: true
|
||||
}).options({
|
||||
selected: 'A'
|
||||
}).editItem()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
that.annotate = function() {
|
||||
var item = {
|
||||
id: 'note', value: '', editable: true
|
||||
if (oml.user.ui.showAnnotations) {
|
||||
addNote()
|
||||
}
|
||||
}
|
||||
that.deselect = function() {
|
||||
|
|
@ -77,6 +81,9 @@ oml.ui.annotation = function(annotation, $iframe) {
|
|||
that.loseFocus()
|
||||
}
|
||||
that.select = function () {
|
||||
$iframe.postMessage('selectAnnotation', {
|
||||
id: annotation.id
|
||||
})
|
||||
let selected = document.querySelector('.OMLAnnotation.selected')
|
||||
selected && selected.classList.remove('selected')
|
||||
that.addClass('selected')
|
||||
|
|
|
|||
|
|
@ -95,7 +95,6 @@ oml.ui.viewer = function() {
|
|||
height: '100%',
|
||||
border: 0
|
||||
}).onMessage(function(data, event) {
|
||||
console.log('got', event, data)
|
||||
if (event == 'addAnnotation') {
|
||||
console.log('adding', data.id)
|
||||
saveAnnotations(data);
|
||||
|
|
@ -107,11 +106,12 @@ oml.ui.viewer = function() {
|
|||
removeAnnotation(data.id)
|
||||
} else if (event == 'selectAnnotation') {
|
||||
var $annotation = oml.$ui.annotationFolder.find('#a-' + data.id)
|
||||
$annotation.select()
|
||||
$annotation && $annotation.select()
|
||||
} else if (event == 'deselectAnnotation') {
|
||||
var $annotation = oml.$ui.annotationFolder.find('#a-' + data.id)
|
||||
$annotation.deselect()
|
||||
var $annotation = oml.$ui.annotationFolder.find('#a-' + data.id)[0]
|
||||
$annotation && $annotation.deselect()
|
||||
} else {
|
||||
console.log('got', event, data)
|
||||
that.triggerEvent(event, data);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue