diff --git a/static/css/oml.css b/static/css/oml.css index 86a252e..6ab6c64 100644 --- a/static/css/oml.css +++ b/static/css/oml.css @@ -1,6 +1,5 @@ .OMLQuoteBox { position: relative; - background-color: rgb(255, 255, 255); } .OMLQuote { position: relative; diff --git a/static/js/viewer.js b/static/js/viewer.js index 092657a..36ad0d8 100644 --- a/static/js/viewer.js +++ b/static/js/viewer.js @@ -71,6 +71,8 @@ oml.ui.viewer = function() { var annotationEvents = { change: function() { + console.log('change...') + console.log(annotations) saveAnnotations() }, 'delete': function(data) { @@ -94,6 +96,7 @@ oml.ui.viewer = function() { border: 0 }).onMessage(function(data, event) { if (event == 'addAnnotation') { + console.log('adding', data.id) saveAnnotations(data); var $annotation = oml.ui.annotation(data, $iframe).bindEvent(annotationEvents) oml.$ui.annotationFolder.append($annotation); @@ -102,14 +105,12 @@ oml.ui.viewer = function() { oml.$ui.annotationFolder.find('#a-' + data.id).remove() removeAnnotation(data.id) } else if (event == 'selectAnnotation') { - if (data.id) { - var $annotation = oml.$ui.annotationFolder.find('#a-' + data.id) - $annotation.length && $annotation.select() - } else { - var $annotation = oml.$ui.annotationFolder.find('.OMLAnnotation.selected') - $annotation.length && $annotation.deselect() - } - } else if (event == 'selectText') { + var $annotation = oml.$ui.annotationFolder.find('#a-' + data.id) + $annotation && $annotation.select() + } else if (event == 'deselectAnnotation') { + var $annotation = oml.$ui.annotationFolder.find('#a-' + data.id)[0] + $annotation && $annotation.deselect() + } else if (event == 'selection') { oml.$ui.annotationPanel.updateSelection(data) } else { console.log('got', event, data) diff --git a/static/reader/epub.js b/static/reader/epub.js index b4326a3..14a309d 100644 --- a/static/reader/epub.js +++ b/static/reader/epub.js @@ -81,7 +81,7 @@ function deselectAllAnnotations() { g.classList.remove('selected') if (!Ox.contains(ids, id)) { ids.push(id) - Ox.$parent.postMessage('selectAnnotation', {id: null}) + Ox.$parent.postMessage('deselectAnnotation', {id: id}) } }) } @@ -179,7 +179,7 @@ document.onreadystatechange = function () { currentSelection = null } if (!currentSelection) { - Ox.$parent.postMessage('selectText', false) + Ox.$parent.postMessage('selection', false) } } }) @@ -194,7 +194,7 @@ document.onreadystatechange = function () { text: text, contents: contents } - Ox.$parent.postMessage('selectText', text ? true : false) + Ox.$parent.postMessage('selection', text ? true : false) }) }); } diff --git a/static/reader/pdf.js b/static/reader/pdf.js index 44db149..164fba9 100644 --- a/static/reader/pdf.js +++ b/static/reader/pdf.js @@ -60,9 +60,9 @@ window.addEventListener('keydown', function(event) { window.addEventListener('mouseup', function(event) { var selection = window.getSelection() if (selection.isCollapsed) { - Ox.$parent.postMessage('selectText', false) + Ox.$parent.postMessage('selection', false) } else { - Ox.$parent.postMessage('selectText', true) + Ox.$parent.postMessage('selection', true) } }) @@ -136,7 +136,7 @@ function renderAnnotation(annotation) { el.addEventListener('click', function() { if (el.classList.contains('selected')) { deselectAnnotation(annotation.id) - Ox.$parent.postMessage('selectAnnotation', {id: null}) + Ox.$parent.postMessage('deselectAnnotation', {id: annotation.id}) } else { selectAnnotation(annotation.id) Ox.$parent.postMessage('selectAnnotation', {id: annotation.id}) @@ -178,7 +178,7 @@ function deselectAllAnnotations() { console.log('deselect', g, id) if (!Ox.contains(ids, id)) { ids.push(id) - Ox.$parent.postMessage('selectAnnotation', {id: null}) + Ox.$parent.postMessage('deselectAnnotation', {id: id}) } }) }