Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
9b87cd8e
Commit
9b87cd8e
authored
Jul 01, 2014
by
Randall Leeds
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code clarity through local variables
parent
529b5f53
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
18 deletions
+17
-18
controllers.coffee
h/js/controllers.coffee
+17
-18
No files found.
h/js/controllers.coffee
View file @
9b87cd8e
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment