Commit f9421db9 authored by Randall Leeds's avatar Randall Leeds

upgrade annotator to 1.2.6-dev-d2ea449

parent 0c3a527d
...@@ -4,6 +4,7 @@ class Hypothesis extends Annotator ...@@ -4,6 +4,7 @@ class Hypothesis extends Annotator
# Plugin configuration # Plugin configuration
options: options:
noMatching: true
Discovery: {} Discovery: {}
Heatmap: {} Heatmap: {}
Permissions: Permissions:
......
/* /*
** Annotator 1.2.6-dev-8daf38c ** Annotator 1.2.6-dev-d2ea449
** https://github.com/okfn/annotator/ ** https://github.com/okfn/annotator/
** **
** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning. ** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning.
** Dual licensed under the MIT and GPLv3 licenses. ** Dual licensed under the MIT and GPLv3 licenses.
** https://github.com/okfn/annotator/blob/master/LICENSE ** https://github.com/okfn/annotator/blob/master/LICENSE
** **
** Built at: 2013-05-17 21:32:30Z ** Built at: 2013-05-24 21:48:00Z
*/ */
......
This diff is collapsed.
/* /*
** Annotator 1.2.6-dev-8daf38c ** Annotator 1.2.6-dev-d2ea449
** https://github.com/okfn/annotator/ ** https://github.com/okfn/annotator/
** **
** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning. ** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning.
** Dual licensed under the MIT and GPLv3 licenses. ** Dual licensed under the MIT and GPLv3 licenses.
** https://github.com/okfn/annotator/blob/master/LICENSE ** https://github.com/okfn/annotator/blob/master/LICENSE
** **
** Built at: 2013-05-17 21:32:32Z ** Built at: 2013-05-24 21:48:00Z
*/ */
......
/* /*
** Annotator 1.2.6-dev-8daf38c ** Annotator 1.2.6-dev-d2ea449
** https://github.com/okfn/annotator/ ** https://github.com/okfn/annotator/
** **
** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning. ** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning.
** Dual licensed under the MIT and GPLv3 licenses. ** Dual licensed under the MIT and GPLv3 licenses.
** https://github.com/okfn/annotator/blob/master/LICENSE ** https://github.com/okfn/annotator/blob/master/LICENSE
** **
** Built at: 2013-05-17 21:32:33Z ** Built at: 2013-05-24 21:48:01Z
*/ */
...@@ -124,11 +124,29 @@ ...@@ -124,11 +124,29 @@
}; };
Store.prototype._onLoadAnnotations = function(data) { Store.prototype._onLoadAnnotations = function(data) {
var a, annotation, annotationMap, newData, _i, _j, _len, _len1, _ref;
if (data == null) { if (data == null) {
data = []; data = [];
} }
this.annotations = this.annotations.concat(data); annotationMap = {};
return this.annotator.loadAnnotations(data.slice()); _ref = this.annotations;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
a = _ref[_i];
annotationMap[a.id] = a;
}
newData = [];
for (_j = 0, _len1 = data.length; _j < _len1; _j++) {
a = data[_j];
if (annotationMap[a.id]) {
annotation = annotationMap[a.id];
this.updateAnnotation(annotation, a);
} else {
newData.push(a);
}
}
this.annotations = this.annotations.concat(newData);
return this.annotator.loadAnnotations(newData.slice());
}; };
Store.prototype.loadAnnotationsFromSearch = function(searchOptions) { Store.prototype.loadAnnotationsFromSearch = function(searchOptions) {
......
...@@ -11,7 +11,7 @@ class window.DomTextMapper ...@@ -11,7 +11,7 @@ class window.DomTextMapper
if @instances.length is 0 then return if @instances.length is 0 then return
# dm = @instances[0] # dm = @instances[0]
# console.log "Node @ " + (dm.getPathTo node) + " has changed: " + reason # console.log "Node @ " + (dm.getPathTo node) + " has changed: " + reason
for instance in @instances for instance in @instances when instance.rootNode.contains(node)
instance.performUpdateOnNode node instance.performUpdateOnNode node
null null
...@@ -42,7 +42,7 @@ class window.DomTextMapper ...@@ -42,7 +42,7 @@ class window.DomTextMapper
throw new Error "Can't find iframe with specified ID!" throw new Error "Can't find iframe with specified ID!"
@rootWin = iframe.contentWindow @rootWin = iframe.contentWindow
unless @rootWin? unless @rootWin?
throw new Error "Can't access contents of the spefified iframe!" throw new Error "Can't access contents of the specified iframe!"
@rootNode = @rootWin.document @rootNode = @rootWin.document
@pathStartNode = @getBody() @pathStartNode = @getBody()
...@@ -87,6 +87,10 @@ class window.DomTextMapper ...@@ -87,6 +87,10 @@ class window.DomTextMapper
# console.log "We have a valid DOM structure cache." # console.log "We have a valid DOM structure cache."
return @path return @path
unless @pathStartNode.ownerDocument.body.contains @pathStartNode
# We cannot map nodes that are not attached.
return @path
# console.log "No valid cache, will have to do a scan." # console.log "No valid cache, will have to do a scan."
startTime = @timestamp() startTime = @timestamp()
@saveSelection() @saveSelection()
...@@ -195,7 +199,10 @@ class window.DomTextMapper ...@@ -195,7 +199,10 @@ class window.DomTextMapper
result result
# Return info for a given node in the DOM # Return info for a given node in the DOM
getInfoForNode: (node) -> @getInfoForPath @getPathTo node getInfoForNode: (node) ->
unless node?
throw new Error "Called getInfoForNode(node) with null node!"
@getInfoForPath @getPathTo node
# Get the matching DOM elements for a given set of charRanges # Get the matching DOM elements for a given set of charRanges
# (Calles getMappingsForCharRange for each element in the givenl ist) # (Calles getMappingsForCharRange for each element in the givenl ist)
...@@ -384,6 +391,8 @@ class window.DomTextMapper ...@@ -384,6 +391,8 @@ class window.DomTextMapper
getPathTo: (node) -> getPathTo: (node) ->
xpath = ''; xpath = '';
while node != @rootNode while node != @rootNode
unless node?
throw new Error "Called getPathTo on a node which was not a descendant of @rootNode. " + @rootNode
xpath = (@getPathSegment node) + '/' + xpath xpath = (@getPathSegment node) + '/' + xpath
node = node.parentNode node = node.parentNode
xpath = (if @rootNode.ownerDocument? then './' else '/') + xpath xpath = (if @rootNode.ownerDocument? then './' else '/') + xpath
...@@ -612,8 +621,7 @@ class window.DomTextMapper ...@@ -612,8 +621,7 @@ class window.DomTextMapper
# Returns: # Returns:
# the first character offset position in the content of this node's # the first character offset position in the content of this node's
# parent node that is not accounted for by this node # parent node that is not accounted for by this node
collectPositions: (node, path, parentContent = null, collectPositions: (node, path, parentContent = null, parentIndex = 0, index = 0) ->
parentIndex = 0, index = 0) ->
# console.log "Scanning path " + path # console.log "Scanning path " + path
# content = @getNodeContent node, false # content = @getNodeContent node, false
......
...@@ -110,8 +110,7 @@ class window.DomTextMatcher ...@@ -110,8 +110,7 @@ class window.DomTextMatcher
# #
# For the details about the returned data structure, # For the details about the returned data structure,
# see the documentation of the search() method. # see the documentation of the search() method.
searchFuzzy: (pattern, pos, searchFuzzy: (pattern, pos, caseSensitive = false, path = null, options = {}) ->
caseSensitive = false, path = null, options = {}) ->
@ensureDMP() @ensureDMP()
@dmp.setMatchDistance options.matchDistance ? 1000 @dmp.setMatchDistance options.matchDistance ? 1000
@dmp.setMatchThreshold options.matchThreshold ? 0.5 @dmp.setMatchThreshold options.matchThreshold ? 0.5
...@@ -122,9 +121,7 @@ class window.DomTextMatcher ...@@ -122,9 +121,7 @@ class window.DomTextMatcher
# Used to even out some browser differences. # Used to even out some browser differences.
normalizeString: (string) -> string.replace /\s{2,}/g, " " normalizeString: (string) -> string.replace /\s{2,}/g, " "
searchFuzzyWithContext: (prefix, suffix, pattern, searchFuzzyWithContext: (prefix, suffix, pattern, expectedStart = null, expectedEnd = null, caseSensitive = false, path = null, options = {}) ->
expectedStart = null, expectedEnd = null, caseSensitive = false,
path = null, options = {}) ->
@ensureDMP() @ensureDMP()
# No context, to joy # No context, to joy
......
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