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
...
@@ -674,11 +674,13 @@ class Viewer
annotator
annotator
)
->
)
->
{
providers
,
threading
}
=
annotator
{
providers
,
threading
}
=
annotator
$
s
cope
.
view
=
'Screen'
$
rootS
cope
.
view
=
'Screen'
$scope
.
sort
=
'Newest'
$scope
.
sort
=
'Newest'
$scope
.
views
=
[
$scope
.
views
=
[
{
view
:
'Screen'
}
{
view
:
'Screen'
}
{
view
:
'Document'
}]
{
view
:
'Document'
}
{
view
:
"Comments"
}
]
$scope
.
sorts
=
[
$scope
.
sorts
=
[
{
sort
:
'Newest'
}
{
sort
:
'Newest'
}
{
sort
:
'Oldest'
}
{
sort
:
'Oldest'
}
...
@@ -704,20 +706,29 @@ class Viewer
...
@@ -704,20 +706,29 @@ class Viewer
method
:
'scrollTo'
method
:
'scrollTo'
params
:
annotation
.
$
$tag
params
:
annotation
.
$
$tag
$scope
.
applyview
=
(
view
)
->
$scope
.
applyView
=
(
view
)
->
$scope
.
view
=
view
switch
view
if
$scope
.
view
==
'Screen'
when
'Screen'
annotator
.
updateViewer
(
$rootScope
.
annotations
)
# 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'
when
'Document'
annotator
.
updateViewer
(
annotator
.
plugins
.
Store
.
annotations
)
for
p
in
providers
p
.
channel
.
notify
method
:
'showAll'
break
for
p
in
providers
when
'Comments'
p
.
channel
.
notify
for
p
in
providers
method
:
'setDynamicBucketMode'
p
.
channel
.
notify
method
:
'showComments'
params
:
$scope
.
view
==
'Screen'
else
throw
new
Error
"Unknown view requested: "
+
view
$scope
.
apply
s
ort
=
(
sort
)
->
$scope
.
apply
S
ort
=
(
sort
)
->
$scope
.
sort
=
sort
$scope
.
sort
=
sort
if
$scope
.
sort
==
'Newest'
if
$scope
.
sort
==
'Newest'
$scope
.
predicate
=
'updated'
$scope
.
predicate
=
'updated'
...
...
h/js/guest.coffee
View file @
085ec139
...
@@ -132,6 +132,24 @@ class Annotator.Guest extends Annotator
...
@@ -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
)
=>
.
bind
(
'setTool'
,
(
ctx
,
name
)
=>
this
.
setTool
name
this
.
setTool
name
this
.
publish
'setTool'
,
name
this
.
publish
'setTool'
,
name
...
@@ -164,11 +182,21 @@ class Annotator.Guest extends Annotator
...
@@ -164,11 +182,21 @@ class Annotator.Guest extends Annotator
_setupViewer
:
->
this
_setupViewer
:
->
this
_setupEditor
:
->
this
_setupEditor
:
->
this
showViewer
:
(
annotations
)
=>
showViewer
:
(
viewName
,
annotations
)
=>
@
panel
?
.
notify
method
:
"showViewer"
,
params
:
(
a
.
id
for
a
in
annotations
)
@
panel
?
.
notify
method
:
"showViewer"
params
:
[
viewName
(
a
.
id
for
a
in
annotations
)
]
updateViewer
:
(
annotations
)
=>
updateViewer
:
(
viewName
,
annotations
)
=>
@
panel
?
.
notify
method
:
"updateViewer"
,
params
:
(
a
.
id
for
a
in
annotations
)
@
panel
?
.
notify
method
:
"updateViewer"
params
:
[
viewName
(
a
.
id
for
a
in
annotations
)
]
showEditor
:
(
annotation
)
=>
@
plugins
.
Bridge
.
showEditor
annotation
showEditor
:
(
annotation
)
=>
@
plugins
.
Bridge
.
showEditor
annotation
...
@@ -254,7 +282,7 @@ class Annotator.Guest extends Annotator
...
@@ -254,7 +282,7 @@ class Annotator.Guest extends Annotator
return
unless
(
@
tool
is
'highlight'
)
or
@
visibleHighlights
and
@
noBack
return
unless
(
@
tool
is
'highlight'
)
or
@
visibleHighlights
and
@
noBack
# Tell sidebar to show the viewer for these annotations
# 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
# We have already prevented closing the sidebar, now reset this flag
@
noBack
=
false
@
noBack
=
false
...
...
h/js/plugin/heatmap.coffee
View file @
085ec139
...
@@ -463,10 +463,12 @@ class Annotator.Plugin.Heatmap extends Annotator.Plugin
...
@@ -463,10 +463,12 @@ class Annotator.Plugin.Heatmap extends Annotator.Plugin
else
if
(
@
isLower
bucket
)
else
if
(
@
isLower
bucket
)
@
dynamicBucket
=
true
@
dynamicBucket
=
true
@
_jumpMinMax
@
buckets
[
bucket
],
"down"
@
_jumpMinMax
@
buckets
[
bucket
],
"down"
else
if
(
@
isComment
bucket
)
@
commentClick
()
else
else
d3
.
event
.
stopPropagation
()
d3
.
event
.
stopPropagation
()
@
dynamicBucket
=
false
@
dynamicBucket
=
false
annotator
.
showViewer
@
buckets
[
bucket
]
annotator
.
showViewer
"Tab"
,
@
buckets
[
bucket
]
tabs
.
exit
().
remove
()
tabs
.
exit
().
remove
()
...
@@ -498,8 +500,15 @@ class Annotator.Plugin.Heatmap extends Annotator.Plugin
...
@@ -498,8 +500,15 @@ class Annotator.Plugin.Heatmap extends Annotator.Plugin
acc
acc
,
[]
,
[]
# $.merge visible, @annotator.comments
# $.merge visible, @annotator.comments
@
annotator
.
updateViewer
visible
@
annotator
.
updateViewer
"Screen"
,
visible
_getCommentBucket
:
=>
@
index
.
length
-
2
isUpper
:
(
i
)
=>
i
==
1
isUpper
:
(
i
)
=>
i
==
1
isLower
:
(
i
)
=>
i
==
@
index
.
length
-
3
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
...
@@ -216,13 +216,15 @@ class Hypothesis extends Annotator
$rootScope
.
$apply
=>
this
.
show
()
$rootScope
.
$apply
=>
this
.
show
()
)
)
.
bind
(
'showViewer'
,
(
ctx
,
ids
=
[])
=>
.
bind
(
'showViewer'
,
(
ctx
,
[
viewName
,
ids
])
=>
ids
?=
[]
return
unless
this
.
discardDrafts
()
return
unless
this
.
discardDrafts
()
$rootScope
.
$apply
=>
this
.
showViewer
this
.
_getAnnotationsFromIDs
ids
$rootScope
.
$apply
=>
this
.
showViewer
viewName
,
this
.
_getAnnotationsFromIDs
ids
)
)
.
bind
(
'updateViewer'
,
(
ctx
,
ids
=
[])
=>
.
bind
(
'updateViewer'
,
(
ctx
,
[
viewName
,
ids
])
=>
$rootScope
.
$apply
=>
this
.
updateViewer
this
.
_getAnnotationsFromIDs
ids
ids
?=
[]
$rootScope
.
$apply
=>
this
.
updateViewer
viewName
,
this
.
_getAnnotationsFromIDs
ids
)
)
.
bind
(
'setTool'
,
(
ctx
,
name
)
=>
.
bind
(
'setTool'
,
(
ctx
,
name
)
=>
...
@@ -313,24 +315,25 @@ class Hypothesis extends Annotator
...
@@ -313,24 +315,25 @@ class Hypothesis extends Annotator
annotation
.
reply_list
=
children
.
sort
(
@
sortAnnotations
).
reverse
()
annotation
.
reply_list
=
children
.
sort
(
@
sortAnnotations
).
reverse
()
@
buildReplyList
children
@
buildReplyList
children
updateViewer
:
(
annotations
=
[])
=>
updateViewer
:
(
viewName
,
annotations
=
[])
=>
annotations
=
annotations
.
filter
(
a
)
->
a
?
annotations
=
annotations
.
filter
(
a
)
->
a
?
@
element
.
injector
().
invoke
[
@
element
.
injector
().
invoke
[
'$rootScope'
,
'$rootScope'
,
(
$rootScope
)
=>
(
$rootScope
)
=>
@
buildReplyList
annotations
@
buildReplyList
annotations
$rootScope
.
annotations
=
annotations
$rootScope
.
annotations
=
annotations
$rootScope
.
view
=
viewName
]
]
this
this
showViewer
:
(
annotations
=
[])
=>
showViewer
:
(
viewName
,
annotations
=
[])
=>
this
.
show
()
this
.
show
()
@
element
.
injector
().
invoke
[
@
element
.
injector
().
invoke
[
'$location'
,
'$location'
,
(
$location
)
=>
(
$location
)
=>
$location
.
path
(
'/viewer'
).
replace
()
$location
.
path
(
'/viewer'
).
replace
()
]
]
this
.
updateViewer
annotations
this
.
updateViewer
viewName
,
annotations
addEmphasis
:
(
annotations
=
[])
=>
addEmphasis
:
(
annotations
=
[])
=>
annotations
=
annotations
.
filter
(
a
)
->
a
?
# Filter out null 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