add delete quote button
This commit is contained in:
parent
0c2ad46e71
commit
925967ddf0
4 changed files with 29 additions and 3 deletions
|
@ -82,6 +82,11 @@ oml.ui.annotation = function(annotation, $iframe) {
|
|||
addNote()
|
||||
}
|
||||
}
|
||||
that.delete = function() {
|
||||
that.triggerEvent('delete', {
|
||||
id: annotation.id
|
||||
})
|
||||
}
|
||||
that.deselect = function() {
|
||||
that.removeClass('selected')
|
||||
that.loseFocus()
|
||||
|
@ -94,7 +99,8 @@ oml.ui.annotation = function(annotation, $iframe) {
|
|||
selected && selected.classList.remove('selected')
|
||||
that.addClass('selected')
|
||||
that.gainFocus()
|
||||
that[0].scrollIntoViewIfNeeded()
|
||||
oml.$ui.annotationPanel.updateSelection(false)
|
||||
that[0].scrollIntoViewIfNeeded && that[0].scrollIntoViewIfNeeded()
|
||||
}
|
||||
return that;
|
||||
};
|
||||
|
|
|
@ -6,7 +6,7 @@ oml.ui.annotationPanel = function() {
|
|||
|
||||
var $bar = Ox.Bar({size: 16});
|
||||
|
||||
var $button = Ox.Button({
|
||||
var $addQuote = Ox.Button({
|
||||
disabled: true,
|
||||
style: 'symbol',
|
||||
title: 'add',
|
||||
|
@ -18,6 +18,19 @@ oml.ui.annotationPanel = function() {
|
|||
}
|
||||
}).appendTo($bar);
|
||||
|
||||
var $deleteQuote = Ox.Button({
|
||||
disabled: true,
|
||||
style: 'symbol',
|
||||
title: 'remove',
|
||||
tooltip: Ox._('Delete Quote'),
|
||||
type: 'image'
|
||||
}).bindEvent({
|
||||
click: function() {
|
||||
var $annotation = oml.$ui.annotationFolder.find('.OMLAnnotation.selected')
|
||||
$annotation.length && $annotation.delete()
|
||||
}
|
||||
}).appendTo($bar);
|
||||
|
||||
var $menuButton = Ox.MenuButton({
|
||||
items: [
|
||||
{id: 'addAnnotation', title: 'Add Annotation', disabled: true},
|
||||
|
@ -86,9 +99,13 @@ oml.ui.annotationPanel = function() {
|
|||
});
|
||||
|
||||
that.updateSelection = function(selection) {
|
||||
$button.options({
|
||||
$addQuote.options({
|
||||
disabled: !selection
|
||||
})
|
||||
var $annotation = oml.$ui.annotationFolder.find('.OMLAnnotation.selected')
|
||||
$deleteQuote.options({
|
||||
disabled: !$annotation.length
|
||||
})
|
||||
}
|
||||
|
||||
return that;
|
||||
|
|
|
@ -98,6 +98,7 @@ oml.ui.viewer = function() {
|
|||
var $annotation = oml.ui.annotation(data, $iframe).bindEvent(annotationEvents)
|
||||
oml.$ui.annotationFolder.append($annotation);
|
||||
$annotation.annotate();
|
||||
oml.$ui.annotationPanel.updateSelection(false)
|
||||
} else if (event == 'removeAnnotation') {
|
||||
oml.$ui.annotationFolder.find('#a-' + data.id).remove()
|
||||
removeAnnotation(data.id)
|
||||
|
@ -109,6 +110,7 @@ oml.ui.viewer = function() {
|
|||
var $annotation = oml.$ui.annotationFolder.find('.OMLAnnotation.selected')
|
||||
$annotation.length && $annotation.deselect()
|
||||
}
|
||||
oml.$ui.annotationPanel.updateSelection(false)
|
||||
} else if (event == 'selectText') {
|
||||
oml.$ui.annotationPanel.updateSelection(data)
|
||||
} else {
|
||||
|
|
|
@ -172,6 +172,7 @@ document.onreadystatechange = function () {
|
|||
}
|
||||
}).on('mouseup', function(event) {
|
||||
if (currentSelection) {
|
||||
deselectAllAnnotations()
|
||||
var selection = window.getSelection()
|
||||
if (selection.isCollapsed) {
|
||||
currentSelection = null
|
||||
|
|
Loading…
Reference in a new issue