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
085ec139
Commit
085ec139
authored
Mar 28, 2014
by
Kristof Csillag
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1100 from hypothesis/1091-scope-cleanup-1
Scope cleanup part 1 Fixes #1099
parents
56401850
bfbad4ad
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
28 deletions
+79
-28
controllers.coffee
h/js/controllers.coffee
+24
-13
guest.coffee
h/js/guest.coffee
+33
-5
heatmap.coffee
h/js/plugin/heatmap.coffee
+12
-3
services.coffee
h/js/services.coffee
+10
-7
No files found.
h/js/controllers.coffee
View file @
085ec139
...
...
@@ -674,11 +674,13 @@ class Viewer
annotator
)
->
{
providers
,
threading
}
=
annotator
$
s
cope
.
view
=
'Screen'
$
rootS
cope
.
view
=
'Screen'
$scope
.
sort
=
'Newest'
$scope
.
views
=
[
{
view
:
'Screen'
}
{
view
:
'Document'
}]
{
view
:
'Document'
}
{
view
:
"Comments"
}
]
$scope
.
sorts
=
[
{
sort
:
'Newest'
}
{
sort
:
'Oldest'
}
...
...
@@ -704,20 +706,29 @@ class Viewer
method
:
'scrollTo'
params
:
annotation
.
$
$tag
$scope
.
applyview
=
(
view
)
->
$scope
.
view
=
view
if
$scope
.
view
==
'Screen'
annotator
.
updateViewer
(
$rootScope
.
annotations
)
$scope
.
applyView
=
(
view
)
->
switch
view
when
'Screen'
# Go over all providers, and switch them to dynamic mode
# They will, in turn, call back updateView
# with the right set of annotations
for
p
in
providers
p
.
channel
.
notify
method
:
'setDynamicBucketMode'
,
params
:
true
break
if
$scope
.
view
==
'Document'
annotator
.
updateViewer
(
annotator
.
plugins
.
Store
.
annotations
)
when
'Document'
for
p
in
providers
p
.
channel
.
notify
method
:
'showAll'
break
for
p
in
providers
p
.
channel
.
notify
method
:
'setDynamicBucketMode'
params
:
$scope
.
view
==
'Screen'
when
'Comments'
for
p
in
providers
p
.
channel
.
notify
method
:
'showComments'
else
throw
new
Error
"Unknown view requested: "
+
view
$scope
.
apply
s
ort
=
(
sort
)
->
$scope
.
apply
S
ort
=
(
sort
)
->
$scope
.
sort
=
sort
if
$scope
.
sort
==
'Newest'
$scope
.
predicate
=
'updated'
...
...
h/js/guest.coffee
View file @
085ec139
...
...
@@ -132,6 +132,24 @@ class Annotator.Guest extends Annotator
}
)
.
bind
(
'showComments'
,
=>
@
plugins
.
Heatmap
.
commentClick
())
.
bind
(
'showAll'
,
=>
# Switch off dynamic mode on the heatmap
if
@
plugins
.
Heatmap
@
plugins
.
Heatmap
.
dynamicBucket
=
false
# Collect all successfully attached annotations
annotations
=
[]
for
page
,
anchors
of
@
anchors
for
anchor
in
anchors
unless
anchor
.
annotation
in
annotations
annotations
.
push
anchor
.
annotation
# Show all the annotations
@
showViewer
"Document"
,
annotations
)
.
bind
(
'setTool'
,
(
ctx
,
name
)
=>
this
.
setTool
name
this
.
publish
'setTool'
,
name
...
...
@@ -164,11 +182,21 @@ class Annotator.Guest extends Annotator
_setupViewer
:
->
this
_setupEditor
:
->
this
showViewer
:
(
annotations
)
=>
@
panel
?
.
notify
method
:
"showViewer"
,
params
:
(
a
.
id
for
a
in
annotations
)
showViewer
:
(
viewName
,
annotations
)
=>
@
panel
?
.
notify
method
:
"showViewer"
params
:
[
viewName
(
a
.
id
for
a
in
annotations
)
]
updateViewer
:
(
annotations
)
=>
@
panel
?
.
notify
method
:
"updateViewer"
,
params
:
(
a
.
id
for
a
in
annotations
)
updateViewer
:
(
viewName
,
annotations
)
=>
@
panel
?
.
notify
method
:
"updateViewer"
params
:
[
viewName
(
a
.
id
for
a
in
annotations
)
]
showEditor
:
(
annotation
)
=>
@
plugins
.
Bridge
.
showEditor
annotation
...
...
@@ -254,7 +282,7 @@ class Annotator.Guest extends Annotator
return
unless
(
@
tool
is
'highlight'
)
or
@
visibleHighlights
and
@
noBack
# Tell sidebar to show the viewer for these annotations
this
.
showViewer
annotations
this
.
showViewer
"Selection"
,
annotations
# We have already prevented closing the sidebar, now reset this flag
@
noBack
=
false
...
...
h/js/plugin/heatmap.coffee
View file @
085ec139
...
...
@@ -463,10 +463,12 @@ class Annotator.Plugin.Heatmap extends Annotator.Plugin
else
if
(
@
isLower
bucket
)
@
dynamicBucket
=
true
@
_jumpMinMax
@
buckets
[
bucket
],
"down"
else
if
(
@
isComment
bucket
)
@
commentClick
()
else
d3
.
event
.
stopPropagation
()
@
dynamicBucket
=
false
annotator
.
showViewer
@
buckets
[
bucket
]
annotator
.
showViewer
"Tab"
,
@
buckets
[
bucket
]
tabs
.
exit
().
remove
()
...
...
@@ -498,8 +500,15 @@ class Annotator.Plugin.Heatmap extends Annotator.Plugin
acc
,
[]
# $.merge visible, @annotator.comments
@
annotator
.
updateViewer
visible
@
annotator
.
updateViewer
"Screen"
,
visible
_getCommentBucket
:
=>
@
index
.
length
-
2
isUpper
:
(
i
)
=>
i
==
1
isLower
:
(
i
)
=>
i
==
@
index
.
length
-
3
isComment
:
(
i
)
=>
i
==
@
index
.
length
-
2
isComment
:
(
i
)
=>
i
is
@
_getCommentBucket
()
# Simulate clicking on the comments tab
commentClick
:
=>
@
dynamicBucket
=
false
annotator
.
showViewer
"Comments"
,
@
buckets
[
@
_getCommentBucket
()]
h/js/services.coffee
View file @
085ec139
...
...
@@ -216,13 +216,15 @@ class Hypothesis extends Annotator
$rootScope
.
$apply
=>
this
.
show
()
)
.
bind
(
'showViewer'
,
(
ctx
,
ids
=
[])
=>
.
bind
(
'showViewer'
,
(
ctx
,
[
viewName
,
ids
])
=>
ids
?=
[]
return
unless
this
.
discardDrafts
()
$rootScope
.
$apply
=>
this
.
showViewer
this
.
_getAnnotationsFromIDs
ids
$rootScope
.
$apply
=>
this
.
showViewer
viewName
,
this
.
_getAnnotationsFromIDs
ids
)
.
bind
(
'updateViewer'
,
(
ctx
,
ids
=
[])
=>
$rootScope
.
$apply
=>
this
.
updateViewer
this
.
_getAnnotationsFromIDs
ids
.
bind
(
'updateViewer'
,
(
ctx
,
[
viewName
,
ids
])
=>
ids
?=
[]
$rootScope
.
$apply
=>
this
.
updateViewer
viewName
,
this
.
_getAnnotationsFromIDs
ids
)
.
bind
(
'setTool'
,
(
ctx
,
name
)
=>
...
...
@@ -313,24 +315,25 @@ class Hypothesis extends Annotator
annotation
.
reply_list
=
children
.
sort
(
@
sortAnnotations
).
reverse
()
@
buildReplyList
children
updateViewer
:
(
annotations
=
[])
=>
updateViewer
:
(
viewName
,
annotations
=
[])
=>
annotations
=
annotations
.
filter
(
a
)
->
a
?
@
element
.
injector
().
invoke
[
'$rootScope'
,
(
$rootScope
)
=>
@
buildReplyList
annotations
$rootScope
.
annotations
=
annotations
$rootScope
.
view
=
viewName
]
this
showViewer
:
(
annotations
=
[])
=>
showViewer
:
(
viewName
,
annotations
=
[])
=>
this
.
show
()
@
element
.
injector
().
invoke
[
'$location'
,
(
$location
)
=>
$location
.
path
(
'/viewer'
).
replace
()
]
this
.
updateViewer
annotations
this
.
updateViewer
viewName
,
annotations
addEmphasis
:
(
annotations
=
[])
=>
annotations
=
annotations
.
filter
(
a
)
->
a
?
# Filter out null annotations
...
...
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