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
c65f8752
Commit
c65f8752
authored
Jun 04, 2015
by
Randall Leeds
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restore the location sort for annotations
parent
80fa1f37
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
18 deletions
+33
-18
guest.coffee
h/static/scripts/annotator/guest.coffee
+7
-1
highlighter.coffee
h/static/scripts/annotator/highlighter.coffee
+14
-0
bucket-bar.coffee
h/static/scripts/annotator/plugin/bucket-bar.coffee
+3
-15
app-controller.coffee
h/static/scripts/app-controller.coffee
+5
-1
cross-frame.coffee
h/static/scripts/cross-frame.coffee
+4
-1
No files found.
h/static/scripts/annotator/guest.coffee
View file @
c65f8752
...
...
@@ -167,11 +167,17 @@ module.exports = class Guest extends Annotator
return
new
Promise
(
raf
).
then
->
range
=
Annotator
.
Range
.
sniff
(
anchor
.
range
)
normedRange
=
range
.
normalize
(
self
.
element
[
0
])
anchor
.
highlights
=
highlighter
.
highlightRange
(
normedRange
)
highlights
=
highlighter
.
highlightRange
(
normedRange
)
rect
=
highlighter
.
getBoundingClientRect
(
highlights
)
anchor
.
highlights
=
highlights
anchor
.
pos
=
left
:
rect
.
left
+
window
.
scrollX
top
:
rect
.
top
+
window
.
scrollY
return
anchor
return
anchor
sync
=
(
anchors
)
->
annotation
.
$anchors
=
({
pos
}
for
{
pos
}
in
anchors
)
annotation
.
$orphan
=
anchors
.
length
>
0
for
anchor
in
anchors
if
anchor
.
range
?
...
...
h/static/scripts/annotator/highlighter.coffee
View file @
c65f8752
...
...
@@ -27,3 +27,17 @@ exports.highlightRange = (normedRange, cssClass='annotator-hl') ->
exports
.
removeHighlights
=
(
highlights
)
->
for
h
in
highlights
when
h
.
parentNode
?
$
(
h
).
replaceWith
(
h
.
childNodes
)
# Get the bounding client rectangle of a collection in viewport coordinates.
# Unfortunately, Chrome has issues[1] with Range.getBoundingClient rect or we
# could just use that.
# [1] https://code.google.com/p/chromium/issues/detail?id=324437
exports
.
getBoundingClientRect
=
(
collection
)
->
# Reduce the client rectangles of the highlights to a bounding box
rects
=
collection
.
map
((
n
)
->
n
.
getBoundingClientRect
())
return
rects
.
reduce
(
acc
,
r
)
->
top
:
Math
.
min
(
acc
.
top
,
r
.
top
)
left
:
Math
.
min
(
acc
.
left
,
r
.
left
)
bottom
:
Math
.
max
(
acc
.
bottom
,
r
.
bottom
)
right
:
Math
.
max
(
acc
.
right
,
r
.
right
)
h/static/scripts/annotator/plugin/bucket-bar.coffee
View file @
c65f8752
...
...
@@ -3,19 +3,7 @@ raf = require('raf')
Annotator
=
require
(
'annotator'
)
$
=
Annotator
.
$
# Get the bounding client rectangle of a collection in viewport coordinates.
# Unfortunately, Chrome has issues[1] with Range.getBoundingClient rect or we
# could just use that.
# [1] https://code.google.com/p/chromium/issues/detail?id=324437
getBoundingClientRect
=
(
collection
)
->
# Reduce the client rectangles of the highlights to a bounding box
rects
=
collection
.
map
((
n
)
->
n
.
getBoundingClientRect
())
return
rects
.
reduce
(
acc
,
r
)
->
top
:
Math
.
min
(
acc
.
top
,
r
.
top
)
left
:
Math
.
min
(
acc
.
left
,
r
.
left
)
bottom
:
Math
.
max
(
acc
.
bottom
,
r
.
bottom
)
right
:
Math
.
max
(
acc
.
right
,
r
.
right
)
highlighter
=
require
(
'../highlighter'
)
# Scroll to the next closest anchor off screen in the given direction.
...
...
@@ -26,7 +14,7 @@ scrollToClosest = (anchors, direction) ->
return
acc
{
start
,
next
}
=
acc
rect
=
getBoundingClientRect
(
anchor
.
highlights
)
rect
=
highlighter
.
getBoundingClientRect
(
anchor
.
highlights
)
# Ignore if it's not in the right direction.
if
(
dir
is
1
and
rect
.
top
>=
0
)
...
...
@@ -123,7 +111,7 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin
unless
anchor
.
highlights
?
.
length
return
points
rect
=
getBoundingClientRect
(
anchor
.
highlights
)
rect
=
highlighter
.
getBoundingClientRect
(
anchor
.
highlights
)
x
=
rect
.
top
h
=
rect
.
bottom
-
rect
.
top
...
...
h/static/scripts/app-controller.coffee
View file @
c65f8752
...
...
@@ -74,7 +74,11 @@ module.exports = class AppController
predicate
=
switch
name
when
'Newest'
then
[
'-!!message'
,
'-message.updated'
]
when
'Oldest'
then
[
'-!!message'
,
'message.updated'
]
when
'Location'
then
[
'-!!message'
,
'message.target[0].pos.top'
]
when
'Location'
then
[
'-!!message'
'message.$anchors[0].pos.top'
'message.$anchors[0].pos.left'
]
$scope
.
sort
=
{
name
,
predicate
}
$scope
.
$watch
(
->
auth
.
user
),
(
newVal
,
oldVal
)
->
...
...
h/static/scripts/cross-frame.coffee
View file @
c65f8752
...
...
@@ -20,7 +20,10 @@ module.exports = class CrossFrame
new
Discovery
(
$window
,
options
)
createAnnotationSync
=
->
whitelist
=
[
'$highlight'
,
'$orphan'
,
'target'
,
'document'
,
'uri'
]
whitelist
=
[
'$anchors'
,
'$highlight'
,
'$orphan'
,
'target'
,
'document'
,
'uri'
]
options
=
formatter
:
(
annotation
)
->
formatted
=
{}
...
...
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