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
cdfbf804
Commit
cdfbf804
authored
Jan 17, 2015
by
csillag
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adapt to Annotator changes
parent
7faa6cec
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
13 deletions
+16
-13
bucket-bar.coffee
h/static/scripts/annotator/plugin/bucket-bar.coffee
+8
-8
guest.coffee
h/static/scripts/guest.coffee
+5
-4
host.coffee
h/static/scripts/host.coffee
+1
-1
karma.config.js
karma.config.js
+2
-0
No files found.
h/static/scripts/annotator/plugin/bucket-bar.coffee
View file @
cdfbf804
...
...
@@ -113,7 +113,7 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin
_collectVirtualAnnotations
:
(
startPage
,
endPage
)
->
results
=
[]
for
page
in
[
startPage
..
endPage
]
anchors
=
@
annotator
.
anchors
[
page
]
anchors
=
@
annotator
.
anchor
ing
.
anchor
s
[
page
]
if
anchors
?
$
.
merge
results
,
(
anchor
.
annotation
for
anchor
in
anchors
when
not
anchor
.
fullyRealized
)
results
...
...
@@ -128,7 +128,7 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin
dir
=
if
direction
is
"up"
then
+
1
else
-
1
{
next
}
=
annotations
.
reduce
(
acc
,
ann
)
->
{
start
,
next
}
=
acc
anchor
=
ann
.
anchors
[
0
]
anchor
=
ann
.
anchor
ing
.
anchor
s
[
0
]
if
not
next
?
or
start
.
page
*
dir
<
anchor
.
startPage
*
dir
# This one is obviously better
start
:
...
...
@@ -164,7 +164,7 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin
startPage
=
anchor
.
startPage
# Is this rendered?
if
@
annotator
.
domMapper
.
isPageMapped
startPage
if
@
annotator
.
anchoring
.
document
.
isPageMapped
startPage
# If it was rendered, then we only have one result. Go there.
hl
=
anchor
.
highlight
[
startPage
]
hl
.
paddedScrollTo
direction
...
...
@@ -175,11 +175,11 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin
count
:
next
.
length
page
:
startPage
direction
:
direction
@
annotator
.
domMapper
.
setPageIndex
startPage
@
annotator
.
anchoring
.
document
.
setPageIndex
startPage
_update
:
=>
wrapper
=
@
annotator
.
wrapper
highlights
=
@
annotator
.
getHighlights
()
highlights
=
@
annotator
.
anchoring
.
getHighlights
()
defaultView
=
wrapper
[
0
].
ownerDocument
.
defaultView
# Keep track of buckets of annotations above and below the viewport
...
...
@@ -187,7 +187,7 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin
below
=
[]
# Get the page numbers
mapper
=
@
annotator
.
domMapper
mapper
=
@
annotator
.
anchoring
.
document
return
unless
mapper
?
# Maybe it's too soon to do this
firstPage
=
0
currentPage
=
mapper
.
getPageIndex
()
...
...
@@ -315,7 +315,7 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin
# TODO: This should use event delegation on the container.
.
on
'mousemove'
,
(
event
)
=>
bucket
=
@
tabs
.
index
(
event
.
currentTarget
)
for
hl
in
@
annotator
.
getHighlights
()
for
hl
in
@
annotator
.
anchoring
.
getHighlights
()
if
hl
.
annotation
in
@
buckets
[
bucket
]
hl
.
setFocused
true
else
...
...
@@ -323,7 +323,7 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin
# Gets rid of them after
.
on
'mouseout'
,
=>
for
hl
in
@
annotator
.
getHighlights
()
for
hl
in
@
annotator
.
anchoring
.
getHighlights
()
hl
.
setFocused
false
# Does one of a few things when a tab is clicked depending on type
...
...
h/static/scripts/guest.coffee
View file @
cdfbf804
...
...
@@ -16,8 +16,9 @@ class Annotator.Guest extends Annotator
# Plugin configuration
options
:
TextHighlights
:
{}
EnhancedAnchoring
:
{}
DomTextMapper
:
{}
Text
Anchors
:
{}
Text
Selection
:
{}
TextRange
:
{}
TextPosition
:
{}
TextQuote
:
{}
...
...
@@ -76,7 +77,7 @@ class Annotator.Guest extends Annotator
unless
config
.
dontScan
# Scan the document text with the DOM Text libraries
this
.
_scan
()
this
.
anchoring
.
_scan
()
# Watch for newly rendered highlights, and update positions in sidebar
this
.
subscribe
"highlightsCreated"
,
(
highlights
)
=>
...
...
@@ -136,7 +137,7 @@ class Annotator.Guest extends Annotator
.
bind
(
'onEditorSubmit'
,
this
.
onEditorSubmit
)
.
bind
(
'focusAnnotations'
,
(
ctx
,
tags
=
[])
=>
for
hl
in
@
getHighlights
()
for
hl
in
@
anchoring
.
getHighlights
()
if
hl
.
annotation
.
$
$tag
in
tags
hl
.
setFocused
true
else
...
...
@@ -144,7 +145,7 @@ class Annotator.Guest extends Annotator
)
.
bind
(
'scrollToAnnotation'
,
(
ctx
,
tag
)
=>
for
hl
in
@
getHighlights
()
for
hl
in
@
anchoring
.
getHighlights
()
if
hl
.
annotation
.
$
$tag
is
tag
hl
.
scrollTo
()
return
...
...
h/static/scripts/host.coffee
View file @
cdfbf804
...
...
@@ -40,7 +40,7 @@ class Annotator.Host extends Annotator.Guest
# Host frame dictates the toolbar options.
this
.
on
'panelReady'
,
=>
this
.
setTool
(
'comment'
)
this
.
_scan
()
# Scan the document
this
.
anchoring
.
_scan
()
# Scan the document
this
.
setVisibleHighlights
(
!!
options
.
showHighlights
)
if
@
plugins
.
BucketBar
?
...
...
karma.config.js
View file @
cdfbf804
...
...
@@ -38,6 +38,8 @@ module.exports = function(config) {
'h/static/scripts/annotator/plugin/bridge.js'
,
'h/static/scripts/annotator/plugin/bucket-bar.js'
,
'h/static/scripts/annotator/plugin/threading.js'
,
'h/static/scripts/vendor/dom_text_mapper.js'
,
'h/static/scripts/annotator/annotator.anchoring.js'
,
'h/static/scripts/app.js'
,
'h/static/scripts/account.js'
,
'h/static/scripts/helpers.js'
,
...
...
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