Commit 1f31cbd5 authored by Randall Leeds's avatar Randall Leeds

consolidate more old stuff into app controller

- Don't track frame visible state in annotator service; do it in
  the app scope instead.
- Move the "back" logic into the controller
parent 130ee778
......@@ -113,15 +113,6 @@ class App
if data.flash? then flash q, msgs for q, msgs of data.flash
if data.status is 'failure' then flash 'error', data.reason
$scope.toggleShow = ->
if annotator.visible
$location.path('').replace()
annotator.hide()
else
if $location.path()?.match '^/?$'
$location.path('/viewer').replace()
annotator.show()
$scope.$watch 'personas', (newValue, oldValue) =>
if newValue?.length
annotator.element.find('#persona')
......@@ -158,6 +149,16 @@ class App
plugins.HypothesisPermissions.setUser(null)
delete plugins.Auth
$scope.$watch 'visible', (newValue) ->
if newValue then annotator.show() else annotator.hide()
$scope.$on 'back', ->
return unless drafts.discard()
if $location.path() == '/viewer' and $location.search()?.id?
$location.search('id', null).replace()
else
$scope.visible = false
$scope.$on 'showAuth', (event, show=true) ->
angular.extend $scope.sheet,
collapsed: !show
......
......@@ -10,10 +10,6 @@ class Hypothesis extends Annotator
showViewPermissionsCheckbox: false,
userString: (user) -> user.replace(/^acct:(.+)@(.+)$/, '$1 on $2')
# Internal state
visible: false # * Whether the sidebar is visible
unsaved_drafts: [] # * Unsaved drafts currenty open
this.$inject = [
'$document', '$location', '$rootScope',
'threading'
......@@ -81,7 +77,6 @@ class Hypothesis extends Annotator
_setupXDM: ->
$scope = @element.scope()
$location = @element.injector().get '$location'
drafts = @element.injector().get 'drafts'
threading = @element.injector().get 'threading'
@provider = new easyXDM.Rpc
......@@ -198,14 +193,7 @@ class Hypothesis extends Annotator
thread.message?.annotation or a
$scope.$apply => this.showViewer annotations
this.show()
# This guy does stuff when you "back out" of the interface.
# (Currently triggered by a click on the source page.)
back: =>
return unless drafts.discard()
if $location.path() == '/viewer' and $location.search()?.id?
$scope.$apply => $location.search('id', null).replace()
else
this.hide()
back: => $scope.$apply => $scope.$broadcast 'back'
update: => this.publish 'hostUpdated'
remote:
publish: {}
......@@ -339,14 +327,12 @@ class Hypothesis extends Annotator
]
show: =>
@visible = true
@provider.showFrame()
@element.find('#toolbar').addClass('shown')
.find('.tri').attr('draggable', true)
hide: =>
@lastWidth = window.innerWidth
@visible = false
@provider.setActiveHighlights []
@provider.hideFrame()
@element.find('#toolbar').removeClass('shown')
......
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