Commit 53ce23ae authored by Aron Carroll's avatar Aron Carroll

Add a temporary UISyncController

This listens to events from the CrossFrameUI service and will update
the sidebar interface accordingly.
parent 3edbff0f
class UISyncController
constructor: (@appScope) ->
listen: ->
@appScope.$on('showAnnotations', this._onShowAnnotations)
@appScope.$on('focusAnnotations', this._onFocusAnnotations)
@appScope.$on('toggleAnnotationSelection', this._onToggleAnnotationSelection)
_getAnnotationsForTags: (tags) ->
# TODO: Should be implemented in the bridge or the threading plugin.
# Properly set the selectedAnnotations- and the Count variables
_setSelectedAnnotations: (selected) ->
count = Object.keys(selected).length
@appScope.selectedAnnotationsCount = count
if count
@appScope.selectedAnnotations = selected
else
@appScope.selectedAnnotations = null
_onToggleAnnotationSelection: (annotations=[]) ->
@appScope.search.query = ''
selected = @appScope.selectedAnnotations or {}
for a in annotations
if selected[a.id]
delete selected[a.id]
else
selected[a.id] = true
@_setSelectedAnnotations(selected)
this
_onFocusAnnotations: (tags) ->
@appScope.focusedAnnotations = tags
_onShowAnnotations: (tags) ->
annotations = _getAnnotationsForTags(tags)
@appScope.search.query = ''
selected = {}
for a in annotations
selected[a.id] = true
@_setSelectedAnnotations selected
_onAnnotationDeleted: (tag) =>
annotation = _getAnnotationForTag(tag)
if scope.selectedAnnotations?[annotation.id]
delete @appScope.selectedAnnotations[annotation.id]
@_setSelectedAnnotations(@appScope.selectedAnnotations)
_onGetDocumentInfo: ->
@appScope.$digest()
class AppController
this.$inject = [
'$document', '$location', '$route', '$scope', '$window',
......
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