Commit f29cd223 authored by Juan Corona's avatar Juan Corona

Fix issues found after removing annotator.js

Failing tests and what was fixed:
1. Sidebar was not closing when the user taps or clicks in the page.
	- Function that set up event handlers used to be called by the `Annotator` base class, now called directly in `Sidebar`
2. Config params used in the passed options to the sidebar iframe leaked a new property (`pluginClasses`) used by the refactoring
	- Filter that property in `Host`
3. `Guest` was missing `deleteAnnotation` function implementation that used to be in `Annotator`

Now only 2 tests should be failing
parent 376da9f8
...@@ -356,6 +356,20 @@ module.exports = class Guest extends Delegator ...@@ -356,6 +356,20 @@ module.exports = class Guest extends Delegator
annotation annotation
# Public: Deletes the annotation by removing the highlight from the DOM.
# Publishes the 'annotationDeleted' event on completion.
#
# annotation - An annotation Object to delete.
#
# Returns deleted annotation.
deleteAnnotation: (annotation) ->
if annotation.highlights?
for h in annotation.highlights when h.parentNode?
$(h).replaceWith(h.childNodes)
this.publish('annotationDeleted', [annotation])
annotation
showAnnotations: (annotations) -> showAnnotations: (annotations) ->
tags = (a.$tag for a in annotations) tags = (a.$tag for a in annotations)
@crossframe?.call('showAnnotations', tags) @crossframe?.call('showAnnotations', tags)
......
...@@ -4,9 +4,9 @@ Guest = require('./guest') ...@@ -4,9 +4,9 @@ Guest = require('./guest')
module.exports = class Host extends Guest module.exports = class Host extends Guest
constructor: (element, options) -> constructor: (element, options) ->
# Make a copy of all options except `options.app`, the app base URL. # Make a copy of all options except `options.app`, the app base URL, and `options.pluginClasses`
configParam = 'config=' + encodeURIComponent( configParam = 'config=' + encodeURIComponent(
JSON.stringify(Object.assign({}, options, {app:undefined})) JSON.stringify(Object.assign({}, options, {app:undefined, pluginClasses: undefined }))
) )
if options.app and '?' in options.app if options.app and '?' in options.app
options.app += '&' + configParam options.app += '&' + configParam
......
...@@ -40,6 +40,7 @@ module.exports = class Sidebar extends Host ...@@ -40,6 +40,7 @@ module.exports = class Sidebar extends Host
@onLoginRequest = options.services?[0]?.onLoginRequest @onLoginRequest = options.services?[0]?.onLoginRequest
this._setupSidebarEvents() this._setupSidebarEvents()
this._setupDocumentEvents()
_setupDocumentEvents: -> _setupDocumentEvents: ->
sidebarTrigger(document.body, => this.show()) sidebarTrigger(document.body, => this.show())
......
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