Commit 4cd394a7 authored by gergely-ujvari's avatar gergely-ujvari

Merge pull request #1642 from hypothesis/1621-strategy-failover

Support document access strategy failover
parents 6281c877 5b0ae871
// Generated by CoffeeScript 1.6.3
/*
** Annotator 1.2.6-dev-48d2dd2
** Annotator 1.2.6-dev-7c915a8
** 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: 2014-10-28 02:52:53Z
** Built at: 2014-11-11 13:09:11Z
*/
......@@ -1188,12 +1188,34 @@
}
};
Annotator.prototype._removeCurrentAccessPolicy = function() {
var index, list, _base;
if (this.domMapper == null) {
return;
}
list = this.documentAccessStrategies;
index = list.indexOf(this.documentAccessStrategy);
if (index !== -1) {
list.splice(index, 1);
}
if (typeof (_base = this.domMapper).destroy === "function") {
_base.destroy();
}
return delete this.domMapper;
};
Annotator.prototype._scan = function() {
var _this = this;
if (!this.domMapper) {
this._chooseAccessPolicy();
}
this.pendingScan = this.domMapper.scan();
try {
this.pendingScan = this.domMapper.scan();
} catch (_error) {
this._removeCurrentAccessPolicy();
this._scan();
return;
}
if (this.pendingScan != null) {
return this.pendingScan.then(function() {
return _this.enableAnnotating();
......@@ -2414,4 +2436,3 @@
});
}).call(this);
// Generated by CoffeeScript 1.6.3
/*
** Annotator 1.2.6-dev-9e0eff3
** Annotator 1.2.6-dev-62d3d3f
** 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: 2014-09-25 22:41:01Z
** Built at: 2014-11-06 15:35:12Z
*/
......@@ -107,7 +107,7 @@
};
TextPosition.prototype.createFromPositionSelector = function(annotation, target) {
var content, currentQuote, savedQuote, selector, _base;
var content, corpus, currentQuote, savedQuote, selector, _base, _base1;
selector = this.annotator.findSelector(target.selector, "TextPositionSelector");
if (selector == null) {
return;
......@@ -120,9 +120,13 @@
console.log("Warning: 'end' field is missing from TextPositionSelector. Skipping.");
return null;
}
content = this.annotator.domMapper.getCorpus().slice(selector.start, +(selector.end - 1) + 1 || 9e9).trim();
corpus = typeof (_base = this.annotator.domMapper).getCorpus === "function" ? _base.getCorpus() : void 0;
if (!corpus) {
return null;
}
content = corpus.slice(selector.start, selector.end).trim();
currentQuote = this.annotator.normalizeString(content);
savedQuote = typeof (_base = this.annotator).getQuoteForTarget === "function" ? _base.getQuoteForTarget(target) : void 0;
savedQuote = typeof (_base1 = this.annotator).getQuoteForTarget === "function" ? _base1.getQuoteForTarget(target) : void 0;
if ((savedQuote != null) && currentQuote !== savedQuote) {
return null;
}
......@@ -134,3 +138,4 @@
})(Annotator.Plugin);
}).call(this);
......@@ -23,6 +23,7 @@
function DomTextMapper(id) {
this.id = id;
this.destroy = __bind(this.destroy, this);
this._onChange = __bind(this._onChange, this);
this.setRealRoot();
DomTextMapper.instances += 1;
......@@ -530,8 +531,7 @@
this.log("Collected info about path " + path);
}
if (invisible) {
this.log("Something seems to be wrong. I see visible content @ " + path + ", while some of the ancestor nodes reported empty contents. Probably a new selection API bug....");
this.log("Anyway, text is '" + cont + "'.");
throw new Error("Failed to scan document: got inconsistent data from selection API.");
}
} else {
if (verbose) {
......@@ -811,6 +811,17 @@
return null;
};
DomTextMapper.prototype.destroy = function() {
var sel;
if (this.savedSelection) {
this.restoreSelection();
} else {
sel = this.rootWin.getSelection();
sel.removeAllRanges();
}
return delete this.path;
};
DomTextMapper.prototype.getPageIndex = function() {
return 0;
};
......
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