From 7ae37074793d8baf31698d1b536d3509d0a6b994 Mon Sep 17 00:00:00 2001 From: Moritz Schlarb Date: Fri, 21 Aug 2015 15:50:14 +0200 Subject: [PATCH] Add the stopSelection method to the global anno object This allows the selection process to be stopped from an external actor with anno.hideSelectionWidget(); anno.stopSelection(); --- src/annotorious.js | 13 +++++++++++++ src/mediatypes/module.js | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/annotorious.js b/src/annotorious.js index f54668f..cd02e99 100644 --- a/src/annotorious.js +++ b/src/annotorious.js @@ -253,6 +253,19 @@ annotorious.Annotorious.prototype.hideSelectionWidget = function(opt_item_url) { } } +annotorious.Annotorious.prototype.stopSelection = function(opt_item_url) { + if (opt_item_url) { + var module = this._getModuleForItemSrc(opt_item_url); + if (module) + module.stopSelection(opt_item_url); + } else { + goog.array.forEach(this._modules, function(module) { + module.stopSelection(); + }); + } +} + + /** * Highlights the specified annotation. * @param {annotorious.Annotation} annotation the annotation diff --git a/src/mediatypes/module.js b/src/mediatypes/module.js index 6884b2e..94838cf 100644 --- a/src/mediatypes/module.js +++ b/src/mediatypes/module.js @@ -268,6 +268,18 @@ annotorious.mediatypes.Module.prototype.activateSelector = function(opt_item_url } } +annotorious.mediatypes.Module.prototype.stopSelection = function(opt_item_url) { + if (opt_item_url) { + var annotator = this._annotators.get(opt_item_url); + if (annotator) + annotator.stopSelection(); + } else { + goog.array.forEach(this._annotators.getValues(), function(annotator) { + annotator.stopSelection(); + }); + } +} + /** * Adds an annotation to an item managed by this module. * @param {annotorious.Annotation} annotation the annotation