Commit 5c7bd169 authored by csillag's avatar csillag

Show the adder button when deployed with an existing selection

To achieve this, updated Annotator's TextAnchors plugin to 989382f5
(typed-packaging branch).

Closes #422
parent 9d2d1942
......@@ -110,6 +110,9 @@ class Annotator.Plugin.TextAnchors extends Annotator.Plugin
@annotator.TextPositionAnchor = TextPositionAnchor
@annotator.TextRangeAnchor = TextRangeAnchor
# Trigger an annotation if we have a currently valid selection
setTimeout (=> @checkForEndSelection({})), 1000
null
......@@ -189,6 +192,18 @@ class Annotator.Plugin.TextAnchors extends Annotator.Plugin
if selectedRanges.length
event.targets = (@getTargetFromRange(r) for r in selectedRanges)
# Do we have valid page coordinates inside the event
# which has triggered this function?
unless event.pageX
# No, we don't. Adding fake coordinates
node = selectedRanges[0].end
while not node.getBoundingClientRect?
node = node.parentNode
pos = node.getBoundingClientRect()
event.pageX = pos.right
event.pageY = pos.bottom
@annotator.onSuccessfulSelection event
else
@annotator.onFailedSelection event
......
// Generated by CoffeeScript 1.6.3
/*
** Annotator 1.2.6-dev-2c4dc62
** Annotator 1.2.6-dev-e2e98dd
** https://github.com/okfn/annotator/
**
** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning.
** Dual licensed under the MIT and GPLv3 licenses.
** https://github.com/okfn/annotator/blob/master/LICENSE
**
** Built at: 2013-11-25 18:28:53Z
** Built at: 2013-11-26 13:26:27Z
*/
......@@ -93,6 +93,7 @@
};
TextAnchors.prototype.pluginInit = function() {
var _this = this;
if (!this.annotator.plugins.TextHighlights) {
throw "The TextAnchors Annotator plugin requires the TextHighlights plugin.";
}
......@@ -111,6 +112,9 @@
});
this.annotator.TextPositionAnchor = TextPositionAnchor;
this.annotator.TextRangeAnchor = TextRangeAnchor;
setTimeout((function() {
return _this.checkForEndSelection({});
}), 1000);
return null;
};
......@@ -149,7 +153,7 @@
};
TextAnchors.prototype.checkForEndSelection = function(event) {
var container, r, range, selectedRanges, _i, _len;
var container, node, pos, r, range, selectedRanges, _i, _len;
this.annotator.mouseIsDown = false;
if (this.annotator.ignoreMouseup) {
return;
......@@ -175,6 +179,15 @@
}
return _results;
}).call(this);
if (!event.pageX) {
node = selectedRanges[0].end;
while (node.getBoundingClientRect == null) {
node = node.parentNode;
}
pos = node.getBoundingClientRect();
event.pageX = pos.right;
event.pageY = pos.bottom;
}
return this.annotator.onSuccessfulSelection(event);
} else {
return this.annotator.onFailedSelection(event);
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment