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
806d3390
Commit
806d3390
authored
Dec 19, 2012
by
Randall Leeds
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up event lifecycles around editing
... to arrive at parity with h/develop.
parent
c76449a3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
48 deletions
+56
-48
controllers.coffee
h/js/controllers.coffee
+54
-47
services.coffee
h/js/services.coffee
+2
-1
No files found.
h/js/controllers.coffee
View file @
806d3390
...
...
@@ -11,24 +11,18 @@ class App
heatmap
=
annotator
.
plugins
.
Heatmap
heatmap
.
element
.
appendTo
$element
# Update the heatmap when certain events are pubished
events
=
[
'annotationCreated'
'annotationDeleted'
'annotationsLoaded'
'hostUpdated'
]
# Update the heatmap when the host is updated or annotations are loaded
events
=
[
'hostUpdated'
,
'annotationsLoaded'
]
for
event
in
events
annotator
.
subscribe
event
,
=
>
provider
.
getHighlights
({
highlights
,
offset
})
=
>
heatmap
.
updateHeatmap
h
ighlights
:
highlights
.
map
(
hl
)
=>
thread
=
(
threading
.
getContainer
hl
.
data
.
id
)
hl
.
data
=
thread
.
message
?
.
annotation
hl
offset
:
offset
$scope
.
$apply
->
$scope
.
$broadcast
'$routeUpdate'
annotator
.
subscribe
event
,
-
>
provider
.
getHighlights
({
highlights
,
offset
})
-
>
$scope
.
$apply
->
h
eatmap
.
updateHeatmap
highlights
:
highlights
.
map
(
hl
)
->
thread
=
(
threading
.
getContainer
hl
.
data
.
id
)
hl
.
data
=
thread
.
message
?
.
annotation
hl
offset
:
offset
heatmap
.
subscribe
'updated'
,
=>
tabs
=
d3
.
select
(
annotator
.
element
[
0
])
...
...
@@ -223,8 +217,14 @@ class App
class
Annotation
this
.
$inject
=
[
'$scope'
,
'$rootScope'
,
'annotator'
,
'threading'
]
constructor
:
(
$scope
,
$rootScope
,
annotator
,
threading
)
->
this
.
$inject
=
[
'$element'
,
'$scope'
,
'$rootScope'
,
'$timeout'
,
'annotator'
,
'threading'
]
constructor
:
(
$element
,
$scope
,
$rootScope
,
$timeout
annotator
,
threading
)
->
$scope
.
cancel
=
->
$scope
.
editing
=
false
if
$scope
.
$modelValue
.
draft
...
...
@@ -267,22 +267,20 @@ class Editor
$location
,
$routeParams
,
$scope
,
annotator
,
threading
)
->
done
=
->
$location
.
path
(
'/app'
).
search
(
null
).
replace
()
annotator
.
provider
.
onEditorHide
()
annotator
.
hide
()
annotator
.
subscribe
'annotationCreated'
,
annotator
.
provider
.
onEditorSubmit
annotator
.
subscribe
'annotationCreated'
,
annotator
.
provider
.
onEditorHid
e
annotator
.
subscribe
'annotationDeleted'
,
annotator
.
provider
.
onEditorHid
e
annotator
.
subscribe
'annotationCreated'
,
don
e
annotator
.
subscribe
'annotationDeleted'
,
don
e
$scope
.
$on
'$destroy'
,
->
annotator
.
unsubscribe
'annotationCreated'
,
annotator
.
provider
.
onEditorSubmit
annotator
.
unsubscribe
'annotationCreated'
,
annotator
.
provider
.
onEditorHide
annotator
.
unsubscribe
'annotationDeleted'
,
annotator
.
provider
.
onEditorHide
$scope
.
$watch
'annotation.draft'
,
(
newValue
,
oldValue
)
->
if
oldValue
and
not
newValue
$location
.
absUrl
(
'/app'
)
annotator
.
hide
()
annotator
.
unsubscribe
'annotationCreated'
,
done
annotator
.
unsubscribe
'annotationDeleted'
,
done
thread
=
(
threading
.
getContainer
$routeParams
.
id
)
annotation
=
thread
.
message
?
.
annotation
...
...
@@ -300,7 +298,9 @@ class Viewer
$location
,
$routeParams
,
$scope
,
annotator
,
threading
)
->
refresh
=
=>
this
.
refresh
$scope
,
$routeParams
,
annotator
,
threading
{
plugins
,
provider
}
=
annotator
refresh
=
=>
this
.
refresh
$scope
,
$routeParams
,
threading
,
plugins
.
Heatmap
update
=
->
$scope
.
$apply
refresh
$scope
.
annotations
=
[]
$scope
.
thread
=
null
...
...
@@ -322,18 +322,33 @@ class Viewer
highlights
=
[
annotation
.
id
]
else
highlights
=
[]
annotator
.
provider
.
setActiveHighlights
highlights
provider
.
setActiveHighlights
highlights
$scope
.
$on
'$destroy'
,
->
plugins
.
Heatmap
.
unsubscribe
'updated'
,
refresh
$scope
.
$on
'$routeUpdate'
,
->
refresh
()
if
$routeParams
.
bucket
?
plugins
.
Heatmap
.
unsubscribe
'updated'
,
refresh
else
plugins
.
Heatmap
.
subscribe
'updated'
,
refresh
$scope
.
$on
'$routeUpdate'
,
refresh
refresh
()
$scope
.
$evalAsync
->
$scope
.
$emit
'$routeUpdate'
refresh
:
(
$scope
,
$routeParams
,
threading
,
heatmap
)
=>
if
$routeParams
.
id
?
$scope
.
detail
=
true
$scope
.
thread
=
threading
.
getContainer
$routeParams
.
id
$scope
.
focus
$scope
.
thread
.
message
.
annotation
else
$scope
.
detail
=
false
$scope
.
focus
$scope
.
annotations
refresh
:
(
$scope
,
$routeParams
,
annotator
,
threading
)
=>
if
$routeParams
.
bucket
?
buckets
=
annotator
.
plugins
.
Heatmap
.
buckets
$scope
.
annotations
=
buckets
[
$routeParams
.
bucket
]
$scope
.
annotations
=
heatmap
.
buckets
[
$routeParams
.
bucket
]
else
unless
$routeParams
.
id
?
heatmap
=
annotator
.
plugins
.
Heatmap
unless
$scope
.
detail
datum
=
(
d3
.
select
heatmap
.
element
[
0
]).
datum
()
if
datum
?
{
highlights
,
offset
}
=
datum
...
...
@@ -347,14 +362,6 @@ class Viewer
else
$scope
.
annotations
=
[]
if
$routeParams
.
id
?
$scope
.
detail
=
true
$scope
.
thread
=
threading
.
getContainer
$routeParams
.
id
$scope
.
focus
$scope
.
thread
.
message
.
annotation
else
$scope
.
detail
=
false
$scope
.
focus
$scope
.
annotations
angular
.
module
(
'h.controllers'
,
[])
.
controller
(
'AppController'
,
App
)
...
...
h/js/services.coffee
View file @
806d3390
...
...
@@ -41,7 +41,6 @@ class Hypothesis extends Annotator
# Update threads when annotations are deleted
this
.
subscribe
'annotationDeleted'
,
(
annotation
)
->
debugger
thread
=
threading
.
getContainer
annotation
.
id
thread
.
message
=
null
if
thread
.
parent
then
threading
.
pruneEmpties
thread
.
parent
...
...
@@ -123,6 +122,8 @@ class Hypothesis extends Annotator
# Update the annotation with the new data
annotation
=
angular
.
extend
annotation
,
data
this
.
publish
'hostUpdated'
# Dodge toolbars [DISABLE]
#@provider.getMaxBottom (max) =>
# @element.find('#toolbar').css("top", "#{max}px")
...
...
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