Commit 876b07f3 authored by Randall Leeds's avatar Randall Leeds

Start to factor out cross-cutting drafts concerns

parent 6ec8baae
......@@ -13,12 +13,29 @@ imports = [
configure = [
'$locationProvider', '$routeProvider', '$sceDelegateProvider',
'$locationProvider', '$provide', '$routeProvider', '$sceDelegateProvider',
(
$locationProvider, $routeProvider, $sceDelegateProvider,
$locationProvider, $provide, $routeProvider, $sceDelegateProvider
) ->
$locationProvider.html5Mode(true)
# Disable annotating while drafting
$provide.decorator 'drafts', [
'annotator', '$delegate',
(annotator, $delegate) ->
{add, remove} = $delegate
$delegate.add = (draft) ->
add.call $delegate, draft
annotator.disableAnnotating $delegate.isEmpty()
$delegate.remove = (draft) ->
remove.call $delegate, draft
annotator.enableAnnotating $delegate.isEmpty()
$delegate
]
$routeProvider.when '/editor',
controller: 'EditorController'
templateUrl: 'editor.html'
......
......@@ -533,7 +533,6 @@ class Annotation
$event?.stopPropagation()
$scope.editing = false
drafts.remove $scope.model
annotator.enableAnnotating drafts.isEmpty()
switch $scope.action
when 'create'
......@@ -564,7 +563,6 @@ class Annotation
$scope.editing = false
drafts.remove annotation
annotator.enableAnnotating drafts.isEmpty()
switch $scope.action
when 'create'
......@@ -596,7 +594,6 @@ class Annotation
annotator.publish 'beforeAnnotationCreated', [reply]
drafts.add reply
annotator.disableAnnotating()
$scope.edit = ($event) ->
$event?.stopPropagation()
......@@ -605,7 +602,6 @@ class Annotation
$scope.origText = $scope.model.text
$scope.origTags = $scope.model.tags
drafts.add $scope.model, -> $scope.cancel()
annotator.disableAnnotating()
$scope.delete = ($event) ->
$event?.stopPropagation()
......
......@@ -56,11 +56,11 @@ class Hypothesis extends Annotator
this.$inject = [
'$document', '$location', '$rootScope', '$route', '$window',
'authentication', 'drafts'
'authentication'
]
constructor: (
$document, $location, $rootScope, $route, $window,
authentication, drafts
authentication
) ->
Gettext.prototype.parse_locale_data annotator_locale_data
super ($document.find 'body')
......
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