Skip to content

Commit

Permalink
Clear search and selection when creating a new annotation.
Browse files Browse the repository at this point in the history
  • Loading branch information
gergely-ujvari committed Mar 16, 2015
1 parent b83ce1f commit 1d5662e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions h/static/scripts/annotation-ui-sync.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class AnnotationUISync
show()
annotations = getAnnotationsByTags(tags)
annotationUI.selectAnnotations(annotations)
clearSelection: (ctx) ->
$rootScope.$broadcast('clearSelection')
focusAnnotations: (ctx, tags=[]) ->
annotations = getAnnotationsByTags(tags)
annotationUI.focusAnnotations(annotations)
Expand Down
3 changes: 3 additions & 0 deletions h/static/scripts/controllers.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ class AppController
# Reload the view.
$route.reload()

$scope.$on 'clearSelection', ->
$scope.clearSelection()

$scope.login = ->
$scope.dialog.visible = true
identity.request {oncancel}
Expand Down
5 changes: 5 additions & 0 deletions h/static/scripts/guest.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ module.exports = class Annotator.Guest extends Annotator
method: "showAnnotations"
params: (a.$$tag for a in annotations)

clearSelection: =>
@crossframe?.notify
method: "clearSelection"

toggleAnnotationSelection: (annotations) =>
@crossframe?.notify
method: "toggleAnnotationSelection"
Expand Down Expand Up @@ -407,6 +411,7 @@ module.exports = class Annotator.Guest extends Annotator
event.preventDefault()
event.stopPropagation()
@adder.hide()
this.clearSelection()
annotation = this.setupAnnotation(this.createAnnotation())
Annotator.Util.getGlobal().getSelection().removeAllRanges()
this.showEditor(annotation)
Expand Down

0 comments on commit 1d5662e

Please sign in to comment.