From e89dc036855acf7d916dc8d4e6f8e0d6a95024c5 Mon Sep 17 00:00:00 2001 From: rlx Date: Thu, 24 Jan 2019 14:50:25 +0530 Subject: [PATCH] add some annotation capability --- static/js/annotation.js | 22 +++++++++++++++------- static/js/viewer.js | 4 +++- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/static/js/annotation.js b/static/js/annotation.js index 1e4a509..3587736 100644 --- a/static/js/annotation.js +++ b/static/js/annotation.js @@ -1,6 +1,12 @@ 'use strict'; oml.ui.annotation = function(data, $iframe) { + var $arrayEditable = Ox.ArrayEditable({ + editing: true, + type: 'textarea' + }).css({ + minHeight: '16px' + }); var that = Ox.Element().attr({ id: 'a-' + data.id }).addClass( @@ -22,12 +28,14 @@ oml.ui.annotation = function(data, $iframe) { }) } }) - ).append( - Ox.ArrayEditable({ - type: 'textarea' - }).css({ - height: 0 - }) - ); + ).append($arrayEditable); + that.annotate = function() { + var item = { + id: 'note', value: '', editable: true + } + $arrayEditable.addItem(0, item) + .options({selected: item.id}) + .editItem(); + } return that; }; diff --git a/static/js/viewer.js b/static/js/viewer.js index f9a039c..dd17822 100644 --- a/static/js/viewer.js +++ b/static/js/viewer.js @@ -55,7 +55,9 @@ oml.ui.viewer = function() { console.log('got', event, data) if (event == 'addAnnotation') { console.log('adding', data.id) - oml.$ui.annotationFolder.append(oml.ui.annotation(data, $iframe)); + var $annotation = oml.ui.annotation(data, $iframe) + oml.$ui.annotationFolder.append($annotation); + $annotation.annotate(); } else if (event == 'removeAnnotation') { console.log('do it ...', data) oml.$ui.annotationFolder.find('#a-' + data.id).remove()