From 8bb7503675437b6f0daa8493b7fc87d3df13ca5b Mon Sep 17 00:00:00 2001 From: j Date: Thu, 31 Jan 2019 23:02:17 +0530 Subject: [PATCH] add Add note placeholder --- static/js/annotation.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/static/js/annotation.js b/static/js/annotation.js index bf69252..64d42de 100644 --- a/static/js/annotation.js +++ b/static/js/annotation.js @@ -14,21 +14,28 @@ oml.ui.annotation = function(annotation, $iframe) { var notes = annotation.notes.length ? annotation.notes.map(function(note) { note.editable = !note.user return note - }) : [{ - id: 'A', - placeholder: 'Add Note', - value: '', - editable: true - }]; + }) : [] console.log(annotation.notes) - var $note = Ox.ArrayEditable({ + var $notes = Ox.ArrayEditable({ editing: true, items: notes, + placeholder: 'Add note', type: 'textarea' }).css({ 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() + } + }, submit: function(data) { var note = Ox.getObjectById(annotation.notes, data.id) if (note) { @@ -58,7 +65,7 @@ oml.ui.annotation = function(annotation, $iframe) { id: annotation.id }) } - }).append($quote).append($note); + }).append($quote).append($notes); that.annotate = function() { var item = {