Commit 9b87cd8e authored by Randall Leeds's avatar Randall Leeds

Code clarity through local variables

parent 529b5f53
...@@ -199,7 +199,7 @@ class App ...@@ -199,7 +199,7 @@ class App
when 'Comments' when 'Comments'
for p in providers for p in providers
p.channel.notify method: 'setDynamicBucketMode', params: false p.channel.notify method: 'setDynamicBucketMode', params: false
annotations = annotator.plugins.Store.annotations annotations = plugins.Store?.annotations
comments = annotations.filter (a) -> annotator.isComment(a) comments = annotations.filter (a) -> annotator.isComment(a)
$rootScope.annotations = comments $rootScope.annotations = comments
...@@ -273,12 +273,12 @@ class App ...@@ -273,12 +273,12 @@ class App
$scope.reloadAnnotations = -> $scope.reloadAnnotations = ->
$rootScope.applyView "Document" $rootScope.applyView "Document"
return unless annotator.plugins.Store return unless plugins.Store
$scope.$root.annotations = [] $scope.$root.annotations = []
annotator.threading.thread [] annotator.threading.thread []
annotator.threading.idTable = {} annotator.threading.idTable = {}
Store = annotator.plugins.Store Store = plugins.Store
annotations = Store.annotations.slice() annotations = Store.annotations.slice()
# XXX: Hacky hacky stuff to ensure that any search requests in-flight # XXX: Hacky hacky stuff to ensure that any search requests in-flight
...@@ -297,7 +297,7 @@ class App ...@@ -297,7 +297,7 @@ class App
# * Make the update function into a noop. # * Make the update function into a noop.
Store.updateAnnotation = angular.noop Store.updateAnnotation = angular.noop
# * Remove the plugin and re-add it to the annotator. # * Remove the plugin and re-add it to the annotator.
delete annotator.plugins.Store delete plugins.Store
annotator.addPlugin 'Store', annotator.options.Store annotator.addPlugin 'Store', annotator.options.Store
# Even though most operations on the old Store are now noops the Annotator # Even though most operations on the old Store are now noops the Annotator
...@@ -321,7 +321,7 @@ class App ...@@ -321,7 +321,7 @@ class App
annotator.deleteAnnotation(l) annotator.deleteAnnotation(l)
deleted.push l deleted.push l
if existing if existing
annotator.plugins.Threading.thread existing plugins.Threading.thread existing
annotations = (a for a in annotations when a not in deleted) annotations = (a for a in annotations when a not in deleted)
if annotations.length is 0 if annotations.length is 0
annotator.unsubscribe 'annotationsLoaded', cleanup annotator.unsubscribe 'annotationsLoaded', cleanup
...@@ -342,7 +342,7 @@ class App ...@@ -342,7 +342,7 @@ class App
streamfilter streamfilter
.setPastDataNone() .setPastDataNone()
.setMatchPolicyIncludeAny() .setMatchPolicyIncludeAny()
.addClause('/uri', 'one_of', Object.keys(annotator.plugins.Store.entities)) .addClause('/uri', 'one_of', Object.keys(plugins.Store.entities))
.getFilter() .getFilter()
$scope.updater = socket() $scope.updater = socket()
...@@ -379,8 +379,8 @@ class App ...@@ -379,8 +379,8 @@ class App
if container?.message? if container?.message?
container.message._updatedAnnotation = true container.message._updatedAnnotation = true
# Temporary workarund to force publish changes # Temporary workarund to force publish changes
if annotator.plugins.Store? if plugins.Store?
annotator.plugins.Store._onLoadAnnotations [container.message] plugins.Store._onLoadAnnotations [container.message]
else else
annotation._updatedAnnotation = true annotation._updatedAnnotation = true
...@@ -390,13 +390,13 @@ class App ...@@ -390,13 +390,13 @@ class App
# XXX: Temporary workaround until solving the race condition for annotationsLoaded event # XXX: Temporary workaround until solving the race condition for annotationsLoaded event
# Between threading and bridge plugins # Between threading and bridge plugins
for annotation in data for annotation in data
annotator.plugins.Threading.thread annotation plugins.Threading.thread annotation
$scope.markAnnotationUpdate data $scope.markAnnotationUpdate data
$scope.$apply => $scope.$apply =>
if annotator.plugins.Store? if plugins.Store?
annotator.plugins.Store._onLoadAnnotations data plugins.Store._onLoadAnnotations data
# XXX: Ugly workaround to update the scope content # XXX: Ugly workaround to update the scope content
switch $rootScope.viewState.view switch $rootScope.viewState.view
when 'Document' when 'Document'
...@@ -407,7 +407,7 @@ class App ...@@ -407,7 +407,7 @@ class App
$rootScope.annotations.push annotation $rootScope.annotations.push annotation
when 'update' when 'update'
$scope.markAnnotationUpdate data $scope.markAnnotationUpdate data
annotator.plugins.Store._onLoadAnnotations data plugins.Store._onLoadAnnotations data
when 'delete' when 'delete'
$scope.markAnnotationUpdate data $scope.markAnnotationUpdate data
for annotation in data for annotation in data
...@@ -415,8 +415,8 @@ class App ...@@ -415,8 +415,8 @@ class App
if container.message if container.message
# XXX: This is a temporary workaround until real client-side only # XXX: This is a temporary workaround until real client-side only
# XXX: delete will be introduced # XXX: delete will be introduced
index = annotator.plugins.Store.annotations.indexOf container.message index = plugins.Store.annotations.indexOf container.message
annotator.plugins.Store.annotations[index..index] = [] if index > -1 plugins.Store.annotations[index..index] = [] if index > -1
annotator.deleteAnnotation container.message annotator.deleteAnnotation container.message
# Finally blink the changed tabs # Finally blink the changed tabs
...@@ -445,7 +445,7 @@ class Annotation ...@@ -445,7 +445,7 @@ class Annotation
$window, $window,
annotator, baseURI, drafts annotator, baseURI, drafts
) -> ) ->
threading = annotator.threading {plugins, threading} = annotator
$scope.action = 'create' $scope.action = 'create'
$scope.editing = false $scope.editing = false
...@@ -509,7 +509,7 @@ class Annotation ...@@ -509,7 +509,7 @@ class Annotation
$scope.reply = ($event) -> $scope.reply = ($event) ->
$event?.stopPropagation() $event?.stopPropagation()
unless annotator.plugins.Auth? and annotator.plugins.Auth.haveValidToken() unless plugins.Auth? and plugins.Auth.haveValidToken()
$window.alert "In order to reply, you need to sign in." $window.alert "In order to reply, you need to sign in."
return return
...@@ -548,8 +548,7 @@ class Annotation ...@@ -548,8 +548,7 @@ class Annotation
if $scope.form.privacy.$viewValue is 'Private' and replies if $scope.form.privacy.$viewValue is 'Private' and replies
#Cascade delete its children #Cascade delete its children
for reply in $scope.thread.flattenChildren() for reply in $scope.thread.flattenChildren()
if annotator.plugins?.Permissions? and if plugins?.Permissions?.authorize 'delete', reply
annotator.plugins.Permissions.authorize 'delete', reply
annotator.deleteAnnotation reply annotator.deleteAnnotation reply
annotator.deleteAnnotation $scope.model annotator.deleteAnnotation $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