Commit 00d98163 authored by Randall Leeds's avatar Randall Leeds

Refactor the reset event slightly

Refactor the reset scope event for quicker app startup and stop
using the reserved prefix that angular uses.

- Rename $reset to reset
- At the App controller, invoke the initialization code immediately
  rather than broadcasting an event. Every component should start
  by initializing itself rather than waiting for an event to be
  broadcast.
parent baf9906d
......@@ -42,6 +42,15 @@ class App
) ->
{plugins, host, providers} = annotator
_reset = =>
delete annotator.ongoing_edit
base = angular.copy @scope
angular.extend $scope, base,
frame: $scope.frame or @scope.frame
socialView: annotator.socialView
_reset()
session.$promise.then (data) ->
angular.extend $scope.model, data
......@@ -88,7 +97,7 @@ class App
$scope.reloadAnnotations()
else if oldValue?
session.$logout =>
$scope.$broadcast '$reset'
$scope.$broadcast 'reset'
if annotator.tool isnt 'comment'
annotator.setTool 'comment'
......@@ -122,7 +131,7 @@ class App
$timeout.cancel authTimeout
unless $scope.model.persona
authTimeout = $timeout (-> $scope.$broadcast '$reset'), 60000
authTimeout = $timeout (-> $scope.$broadcast 'reset'), 60000
unless tab
$scope.ongoingHighlightSwitch = false
delete annotator.ongoing_edit
......@@ -147,12 +156,7 @@ class App
$scope.$on 'showAuth', (event, show=true) ->
$scope.sheet.collapsed = !show
$scope.$on '$reset', =>
delete annotator.ongoing_edit
base = angular.copy @scope
angular.extend $scope, base,
frame: $scope.frame or @scope.frame
socialView: annotator.socialView
$scope.$on 'reset', _reset
$scope.$on 'success', (event, action) ->
angular.extend $scope.model, session.model
......@@ -161,8 +165,6 @@ class App
else
$scope.sheet.collapsed = true
$scope.$broadcast '$reset'
$rootScope.viewState =
sort: ''
view: 'Document'
......@@ -637,7 +639,7 @@ class Auth
console.log(field, error)
flash('error', error)
$scope.$on '$reset', _reset
$scope.$on 'reset', _reset
$scope.submit = (form) ->
angular.extend session, $scope.model
......
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