Compare commits

..

No commits in common. "48e451572b0c583b50159beaebfe13a41667de28" and "aaa9a4a5386a48b76b8f3ccd5ac457fa8f748a40" have entirely different histories.

10 changed files with 29 additions and 72 deletions

View file

@ -361,9 +361,7 @@
"showAnnotations": false,
"showBrowser": true,
"showDebugMenu": false,
"showFolder": {
"": true
},
"showFolder": {},
"showFilters": true,
"showIconInfo": true,
"showInfo": true,

View file

@ -1,9 +1,5 @@
.OMLQuote {
color: rgb(0, 0, 0);
background-color: rgb(255, 255, 255);
font-family: Georgia, Palatino, DejaVu Serif, Book Antiqua, Palatino Linotype, Times New Roman, serif;
font-size: 14px;
line-height: 21px;
}
.OMLAnnotation.selected .OMLQuote {

View file

@ -4,6 +4,7 @@
<title>Open Media Library</title>
<meta charset="UTF-8"/>
<link href="/static/png/oml.png" rel="icon" type="image/png">
<link href="/static/css/oml.css" rel="stylesheet" type="text/css">
<script src="/static/js/oml.js?1" type="text/javascript"></script>
<meta name="google" value="notranslate"/>
</head>

View file

@ -17,8 +17,7 @@ oml.UI = (function() {
var ui = oml.user.ui;
function reload() {
Ox.Request.clearCache()
oml.user.ui = ui = oml.config.user.ui;
ui = oml.config.user.ui;
ui._list = oml.getListState(ui.find);
ui._filterState = oml.getFilterState(ui.find);
ui._findState = oml.getFindState(ui.find);

View file

@ -2,6 +2,11 @@
oml.ui.annotation = function(annotation, $iframe) {
var $quote = Ox.Element().addClass('OxSelectable OMLQuote').css({
backgroundColor: 'white',
color: 'black',
fontFamily: 'Georgia, Palatino, DejaVu Serif, Book Antiqua, Palatino Linotype, Times New Roman, serif',
fontSize: '14px',
lineHeight: '21px',
padding: '8px'
}).html(Ox.encodeHTMLEntities(annotation.text).replace(/\n/g, '<br/>')).on({
click: function(event) {
@ -11,35 +16,27 @@ 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({
editing: true,
items: notes,
items: (annotation.comments || []).map(function(comment) {
comment.editable = true
return comment
}),
type: 'textarea'
}).css({
margin: '2px',
minHeight: '12px'
}).bindEvent({
submit: function(data) {
var note = Ox.getObjectById(annotation.notes, data.id)
if (note) {
note.value = data.value
note.modified = (new Date).toISOString()
var comment = Ox.getObjectById(annotation.comments, data.id)
if (comment) {
comment.value = data.value
comment.modified = (new Date).toISOString()
} else {
annotation.notes.push({
annotation.comments.push({
created: data.created || (new Date).toISOString(),
modified: (new Date).toISOString(),
id: data.id,
user: '',
value: data.value
})
}
@ -52,12 +49,6 @@ oml.ui.annotation = function(annotation, $iframe) {
'OxSelectable OMLAnnotation'
).css({
borderBottom: '1px solid rgb(208, 208, 208)',
}).bindEvent({
key_delete: function() {
that.triggerEvent('delete', {
id: annotation.id
})
}
}).append($quote).append($note);
that.annotate = function() {
@ -67,13 +58,11 @@ oml.ui.annotation = function(annotation, $iframe) {
}
that.deselect = function() {
that.removeClass('selected')
that.loseFocus()
}
that.select = function () {
let selected = document.querySelector('.OMLAnnotation.selected')
selected && selected.classList.remove('selected')
that.addClass('selected')
that.gainFocus()
}
return that;
};

View file

@ -226,9 +226,7 @@
data.browserSupported = browserSupported;
oml.ui = {};
loadOMLFiles(function() {
Ox.getFile('/static/css/oml.css', function() {
initOML(data);
})
});
},
updatestatus: function(data) {

View file

@ -988,7 +988,7 @@ oml.resizeListFolders = function() {
// FIXME: does this have to be here?
var width = oml.getListFoldersWidth(),
columnWidth = width - 16 - 48;
oml.$ui.librariesList && oml.$ui.librariesList
oml.$ui.librariesList
.css({width: width + 'px'})
.resizeColumn('name', columnWidth);
Ox.forEach(oml.$ui.folder, function($folder, index) {

View file

@ -41,23 +41,12 @@ oml.ui.viewer = function() {
function loadAnnotations(callback) {
annotations = JSON.parse(localStorage[item + '.annotations'] || '[]')
annotations.forEach(function(data) {
if (data.comments && !data.notes) {
data.notes = data.comments
delete data.comments
}
data.notes = data.notes || [];
})
callback && callback(annotations)
}
function saveAnnotations(data) {
if (data) {
data.created = data.created || (new Date).toISOString();
if (data.comments && !data.notes) {
data.notes = data.comments
delete data.comments
}
data.notes = data.notes || [];
data.comments = data.comments || [];
annotations.push(data);
}
localStorage[item + '.annotations'] = JSON.stringify(annotations)
@ -74,10 +63,6 @@ oml.ui.viewer = function() {
console.log('change...')
console.log(annotations)
saveAnnotations()
},
'delete': function(data) {
oml.$ui.annotationFolder.find('#a-' + data.id).remove()
that.postMessage('removeAnnotation', data)
}
}
@ -106,11 +91,9 @@ oml.ui.viewer = function() {
oml.$ui.annotationFolder.find('#a-' + data.id).remove()
removeAnnotation(data.id)
} else if (event == 'selectAnnotation') {
var $annotation = oml.$ui.annotationFolder.find('#a-' + data.id)
$annotation.select()
console.log('select', data)
} else if (event == 'deselectAnnotation') {
var $annotation = oml.$ui.annotationFolder.find('#a-' + data.id)
$annotation.deselect()
console.log('deselect', data)
} else {
that.triggerEvent(event, data);
}

View file

@ -23,8 +23,6 @@ Ox.load({
annotations.push(annotation)
renderAnnotation(annotation)
})
} else if (event == 'removeAnnotation') {
removeAnnotation(data.id)
}
})
})
@ -49,15 +47,12 @@ function deselectAnnotation(id) {
})
}
function removeAnnotation(id) {
var a = annotations.filter(function(a) { return a.id == id })[0]
if (a) {
function removeAnnotation(a) {
annotations = annotations.filter(function(annotation) {
return annotation.id != id
return annotation.cfiRange != a.dataset.epubcfi
})
reader.rendition.annotations.remove(a.cfiRange)
}
Ox.$parent.postMessage('removeAnnotation', {id: id})
reader.rendition.annotations.remove(a.dataset.epubcfi)
Ox.$parent.postMessage('removeAnnotation', {id: a.dataset.id})
}
function renderAnnotation(annotation) {
@ -103,7 +98,7 @@ document.onreadystatechange = function () {
reader.rendition.on('keydown', function(event) {
if (event.key == 'Delete') {
document.querySelectorAll('.epubjs-hl.selected').forEach(function(a) {
removeAnnotation(a.dataset.id)
removeAnnotation(a)
})
}
if (event.key == 'n') {

View file

@ -32,8 +32,6 @@ Ox.load({
annotations.push(annotation)
renderAnnotation(annotation)
})
} else if (event == 'removeAnnotation') {
removeAnnotation(data.id)
}
})
})