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()
|
addNote()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
that.delete = function() {
|
||||||
|
that.triggerEvent('delete', {
|
||||||
|
id: annotation.id
|
||||||
|
})
|
||||||
|
}
|
||||||
that.deselect = function() {
|
that.deselect = function() {
|
||||||
that.removeClass('selected')
|
that.removeClass('selected')
|
||||||
that.loseFocus()
|
that.loseFocus()
|
||||||
|
@ -94,7 +99,8 @@ oml.ui.annotation = function(annotation, $iframe) {
|
||||||
selected && selected.classList.remove('selected')
|
selected && selected.classList.remove('selected')
|
||||||
that.addClass('selected')
|
that.addClass('selected')
|
||||||
that.gainFocus()
|
that.gainFocus()
|
||||||
that[0].scrollIntoViewIfNeeded()
|
oml.$ui.annotationPanel.updateSelection(false)
|
||||||
|
that[0].scrollIntoViewIfNeeded && that[0].scrollIntoViewIfNeeded()
|
||||||
}
|
}
|
||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,7 @@ oml.ui.annotationPanel = function() {
|
||||||
|
|
||||||
var $bar = Ox.Bar({size: 16});
|
var $bar = Ox.Bar({size: 16});
|
||||||
|
|
||||||
var $button = Ox.Button({
|
var $addQuote = Ox.Button({
|
||||||
disabled: true,
|
disabled: true,
|
||||||
style: 'symbol',
|
style: 'symbol',
|
||||||
title: 'add',
|
title: 'add',
|
||||||
|
@ -18,6 +18,19 @@ oml.ui.annotationPanel = function() {
|
||||||
}
|
}
|
||||||
}).appendTo($bar);
|
}).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({
|
var $menuButton = Ox.MenuButton({
|
||||||
items: [
|
items: [
|
||||||
{id: 'addAnnotation', title: 'Add Annotation', disabled: true},
|
{id: 'addAnnotation', title: 'Add Annotation', disabled: true},
|
||||||
|
@ -86,9 +99,13 @@ oml.ui.annotationPanel = function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
that.updateSelection = function(selection) {
|
that.updateSelection = function(selection) {
|
||||||
$button.options({
|
$addQuote.options({
|
||||||
disabled: !selection
|
disabled: !selection
|
||||||
})
|
})
|
||||||
|
var $annotation = oml.$ui.annotationFolder.find('.OMLAnnotation.selected')
|
||||||
|
$deleteQuote.options({
|
||||||
|
disabled: !$annotation.length
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
|
|
|
@ -98,6 +98,7 @@ oml.ui.viewer = function() {
|
||||||
var $annotation = oml.ui.annotation(data, $iframe).bindEvent(annotationEvents)
|
var $annotation = oml.ui.annotation(data, $iframe).bindEvent(annotationEvents)
|
||||||
oml.$ui.annotationFolder.append($annotation);
|
oml.$ui.annotationFolder.append($annotation);
|
||||||
$annotation.annotate();
|
$annotation.annotate();
|
||||||
|
oml.$ui.annotationPanel.updateSelection(false)
|
||||||
} else if (event == 'removeAnnotation') {
|
} else if (event == 'removeAnnotation') {
|
||||||
oml.$ui.annotationFolder.find('#a-' + data.id).remove()
|
oml.$ui.annotationFolder.find('#a-' + data.id).remove()
|
||||||
removeAnnotation(data.id)
|
removeAnnotation(data.id)
|
||||||
|
@ -109,6 +110,7 @@ oml.ui.viewer = function() {
|
||||||
var $annotation = oml.$ui.annotationFolder.find('.OMLAnnotation.selected')
|
var $annotation = oml.$ui.annotationFolder.find('.OMLAnnotation.selected')
|
||||||
$annotation.length && $annotation.deselect()
|
$annotation.length && $annotation.deselect()
|
||||||
}
|
}
|
||||||
|
oml.$ui.annotationPanel.updateSelection(false)
|
||||||
} else if (event == 'selectText') {
|
} else if (event == 'selectText') {
|
||||||
oml.$ui.annotationPanel.updateSelection(data)
|
oml.$ui.annotationPanel.updateSelection(data)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -172,6 +172,7 @@ document.onreadystatechange = function () {
|
||||||
}
|
}
|
||||||
}).on('mouseup', function(event) {
|
}).on('mouseup', function(event) {
|
||||||
if (currentSelection) {
|
if (currentSelection) {
|
||||||
|
deselectAllAnnotations()
|
||||||
var selection = window.getSelection()
|
var selection = window.getSelection()
|
||||||
if (selection.isCollapsed) {
|
if (selection.isCollapsed) {
|
||||||
currentSelection = null
|
currentSelection = null
|
||||||
|
|
Loading…
Reference in a new issue