Commit dde25e80 authored by Aron Carroll's avatar Aron Carroll

Clean up cross frame binding

parent 8b4b6876
...@@ -47,6 +47,7 @@ class Hypothesis extends Annotator ...@@ -47,6 +47,7 @@ class Hypothesis extends Annotator
this.$inject = ['$document', '$rootScope', '$window', 'store'] this.$inject = ['$document', '$rootScope', '$window', 'store']
constructor: ( $document, $rootScope, $window, store ) -> constructor: ( $document, $rootScope, $window, store ) ->
super ($document.find 'body') super ($document.find 'body')
return
@providers = [] @providers = []
@store = store @store = store
......
...@@ -15,6 +15,9 @@ class CrossFrameUI ...@@ -15,6 +15,9 @@ class CrossFrameUI
@providers = [] @providers = []
@store = store @store = store
this._emit = (event, args...) ->
$rootScope.$emit(event, args...)
# Set up the bridge plugin, which bridges the main annotation methods # Set up the bridge plugin, which bridges the main annotation methods
# between the host page and the panel widget. # between the host page and the panel widget.
whitelist = ['target', 'document', 'uri'] whitelist = ['target', 'document', 'uri']
...@@ -44,7 +47,7 @@ class CrossFrameUI ...@@ -44,7 +47,7 @@ class CrossFrameUI
success: (info) => success: (info) =>
provider.entities = (link.href for link in info.metadata.link) provider.entities = (link.href for link in info.metadata.link)
@providers.push(provider) @providers.push(provider)
$rootScope.$emit('getDocumentInfo') this._emit('getDocumentInfo')
# Allow the host to define it's own state # Allow the host to define it's own state
unless source is $window.parent unless source is $window.parent
...@@ -63,40 +66,30 @@ class CrossFrameUI ...@@ -63,40 +66,30 @@ class CrossFrameUI
options.origin = '*' options.origin = '*'
provider = Channel.build options provider = Channel.build options
provider.bind 'back', =>
.bind('back', =>
# Navigate "back" out of the interface. # Navigate "back" out of the interface.
this.hide() this.hide()
) provider.bind 'open', =>
.bind('open', =>
this.show() this.show()
)
.bind('showEditor', (ctx, tag) => provider.bind 'showEditor', (ctx, tag) =>
this.show() this.show()
)
.bind('showAnnotations', (ctx, tags=[]) => provider.bind 'showAnnotations', (ctx, tags=[]) =>
this.show() this.show()
$rootScope.$emit('showAnnotations', tags) this._emit('showAnnotations', tags)
)
.bind('focusAnnotations', (ctx, tags=[]) => provider.bind 'focusAnnotations', (ctx, tags=[]) =>
$rootScope.$emit('focusAnnotations', tags) this._emit('focusAnnotations', tags)
)
.bind('toggleAnnotationSelection', (ctx, tags=[]) => provider.bind 'toggleAnnotationSelection', (ctx, tags=[]) =>
$rootScope.$emit('toggleViewerSelection', tags) this._emit('toggleViewerSelection', tags)
)
.bind('setTool', (ctx, name) => provider.bind 'setTool', (ctx, name) =>
this.setTool(name) this.setTool(name)
)
.bind('setVisibleHighlights', (ctx, state) => provider.bind 'setVisibleHighlights', (ctx, state) =>
this.setVisibleHighlights(state) this.setVisibleHighlights(state)
)
_setupDocumentEvents: -> _setupDocumentEvents: ->
$document.addEventListener 'dragover', (event) => $document.addEventListener 'dragover', (event) =>
......
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