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
f1e316c9
Commit
f1e316c9
authored
Jul 29, 2015
by
Randall Leeds
Committed by
Sean Hammond
Sep 21, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show orphans and sort by text position selector
The positions of the anchors are no longer needed.
parent
66d7b2cf
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
52 additions
and
24 deletions
+52
-24
guest.coffee
h/static/scripts/annotator/guest.coffee
+3
-2
guest-test.coffee
h/static/scripts/annotator/test/guest-test.coffee
+14
-14
cross-frame.coffee
h/static/scripts/cross-frame.coffee
+1
-1
widget-controller.coffee
h/static/scripts/widget-controller.coffee
+21
-6
threads.scss
h/static/styles/threads.scss
+8
-0
thread.html
h/templates/client/thread.html
+4
-0
viewer.html
h/templates/client/viewer.html
+1
-1
No files found.
h/static/scripts/annotator/guest.coffee
View file @
f1e316c9
...
@@ -197,10 +197,11 @@ module.exports = class Guest extends Annotator
...
@@ -197,10 +197,11 @@ module.exports = class Guest extends Annotator
sync
=
(
anchors
)
->
sync
=
(
anchors
)
->
# Store the results of anchoring.
# Store the results of anchoring.
annotation
.
$
orphan
=
anchors
.
length
>
0
annotation
.
$
anchored
=
anchors
.
length
is
0
for
anchor
in
anchors
for
anchor
in
anchors
if
anchor
.
range
?
if
anchor
.
range
?
annotation
.
$orphan
=
false
annotation
.
$anchored
=
true
break
# Add the anchors for this annotation to instance storage.
# Add the anchors for this annotation to instance storage.
self
.
anchors
=
self
.
anchors
.
concat
(
anchors
)
self
.
anchors
=
self
.
anchors
.
concat
(
anchors
)
...
...
h/static/scripts/annotator/test/guest-test.coffee
View file @
f1e316c9
...
@@ -249,28 +249,28 @@ describe 'Guest', ->
...
@@ -249,28 +249,28 @@ describe 'Guest', ->
afterEach
->
afterEach
->
document
.
body
.
removeChild
(
el
)
document
.
body
.
removeChild
(
el
)
it
"d
oesn't declare annotation without targets as orphans
"
,
(
done
)
->
it
"d
eclares annotations without targets as anchored
"
,
(
done
)
->
guest
=
createGuest
()
guest
=
createGuest
()
annotation
=
target
:
[]
annotation
=
target
:
[]
guest
.
anchor
(
annotation
).
then
->
guest
.
anchor
(
annotation
).
then
->
assert
.
is
False
(
annotation
.
$orphan
)
assert
.
is
True
(
annotation
.
$anchored
)
done
(
)
.
then
(
done
,
done
)
it
"d
oesn't declare annotations with a working target as orphans
"
,
(
done
)
->
it
"d
eclares annotations with a working target anchored
"
,
(
done
)
->
guest
=
createGuest
()
guest
=
createGuest
()
annotation
=
target
:
[{
selector
:
"test"
}]
annotation
=
target
:
[{
selector
:
"test"
}]
sandbox
.
stub
(
anchoring
,
'anchor'
).
returns
(
Promise
.
resolve
(
range
))
sandbox
.
stub
(
anchoring
,
'anchor'
).
returns
(
Promise
.
resolve
(
range
))
guest
.
anchor
(
annotation
).
then
->
guest
.
anchor
(
annotation
).
then
->
assert
.
is
False
(
annotation
.
$orphan
)
assert
.
is
True
(
annotation
.
$anchored
)
done
(
)
.
then
(
done
,
done
)
it
"declares annotations with broken targets
as orphans
"
,
(
done
)
->
it
"declares annotations with broken targets
not anchored
"
,
(
done
)
->
guest
=
createGuest
()
guest
=
createGuest
()
annotation
=
target
:
[{
selector
:
'broken selector'
}]
annotation
=
target
:
[{
selector
:
'broken selector'
}]
sandbox
.
stub
(
anchoring
,
'anchor'
).
returns
(
Promise
.
reject
())
sandbox
.
stub
(
anchoring
,
'anchor'
).
returns
(
Promise
.
reject
())
guest
.
anchor
(
annotation
).
then
->
guest
.
anchor
(
annotation
).
then
->
assert
.
is
True
(
annotation
.
$orphan
)
assert
.
is
False
(
annotation
.
$anchored
)
done
(
)
.
then
(
done
,
done
)
it
'updates the cross frame and bucket bar plugins'
,
(
done
)
->
it
'updates the cross frame and bucket bar plugins'
,
(
done
)
->
guest
=
createGuest
()
guest
=
createGuest
()
...
@@ -282,7 +282,7 @@ describe 'Guest', ->
...
@@ -282,7 +282,7 @@ describe 'Guest', ->
guest
.
anchor
(
annotation
).
then
->
guest
.
anchor
(
annotation
).
then
->
assert
.
called
(
guest
.
plugins
.
BucketBar
.
update
)
assert
.
called
(
guest
.
plugins
.
BucketBar
.
update
)
assert
.
called
(
guest
.
plugins
.
CrossFrame
.
sync
)
assert
.
called
(
guest
.
plugins
.
CrossFrame
.
sync
)
done
(
)
.
then
(
done
,
done
)
it
'returns a promise of the anchors for the annotation'
,
(
done
)
->
it
'returns a promise of the anchors for the annotation'
,
(
done
)
->
guest
=
createGuest
()
guest
=
createGuest
()
...
@@ -292,7 +292,7 @@ describe 'Guest', ->
...
@@ -292,7 +292,7 @@ describe 'Guest', ->
target
=
[{
selector
:
[]}]
target
=
[{
selector
:
[]}]
guest
.
anchor
({
target
:
[
target
]}).
then
(
anchors
)
->
guest
.
anchor
({
target
:
[
target
]}).
then
(
anchors
)
->
assert
.
equal
(
anchors
.
length
,
1
)
assert
.
equal
(
anchors
.
length
,
1
)
done
(
)
.
then
(
done
,
done
)
it
'adds the anchor to the "anchors" instance property"'
,
(
done
)
->
it
'adds the anchor to the "anchors" instance property"'
,
(
done
)
->
guest
=
createGuest
()
guest
=
createGuest
()
...
@@ -307,7 +307,7 @@ describe 'Guest', ->
...
@@ -307,7 +307,7 @@ describe 'Guest', ->
assert
.
strictEqual
(
guest
.
anchors
[
0
].
target
,
target
)
assert
.
strictEqual
(
guest
.
anchors
[
0
].
target
,
target
)
assert
.
strictEqual
(
guest
.
anchors
[
0
].
range
,
range
)
assert
.
strictEqual
(
guest
.
anchors
[
0
].
range
,
range
)
assert
.
strictEqual
(
guest
.
anchors
[
0
].
highlights
,
highlights
)
assert
.
strictEqual
(
guest
.
anchors
[
0
].
highlights
,
highlights
)
done
(
)
.
then
(
done
,
done
)
it
'destroys targets that have been removed from the annotation'
,
(
done
)
->
it
'destroys targets that have been removed from the annotation'
,
(
done
)
->
annotation
=
{}
annotation
=
{}
...
@@ -321,7 +321,7 @@ describe 'Guest', ->
...
@@ -321,7 +321,7 @@ describe 'Guest', ->
assert
.
equal
(
guest
.
anchors
.
length
,
0
)
assert
.
equal
(
guest
.
anchors
.
length
,
0
)
assert
.
calledOnce
(
removeHighlights
,
highlights
)
assert
.
calledOnce
(
removeHighlights
,
highlights
)
assert
.
calledWith
(
removeHighlights
,
highlights
)
assert
.
calledWith
(
removeHighlights
,
highlights
)
done
(
)
.
then
(
done
,
done
)
it
'does not reanchor targets that are already anchored'
,
(
done
)
->
it
'does not reanchor targets that are already anchored'
,
(
done
)
->
guest
=
createGuest
()
guest
=
createGuest
()
...
@@ -331,7 +331,7 @@ describe 'Guest', ->
...
@@ -331,7 +331,7 @@ describe 'Guest', ->
guest
.
anchor
(
annotation
).
then
->
guest
.
anchor
(
annotation
).
then
->
assert
.
equal
(
guest
.
anchors
.
length
,
1
)
assert
.
equal
(
guest
.
anchors
.
length
,
1
)
assert
.
calledOnce
(
stub
)
assert
.
calledOnce
(
stub
)
done
(
)
.
then
(
done
,
done
)
describe
'detach()'
,
->
describe
'detach()'
,
->
it
'removes the anchors from the "anchors" instance variable'
,
->
it
'removes the anchors from the "anchors" instance variable'
,
->
...
...
h/static/scripts/cross-frame.coffee
View file @
f1e316c9
...
@@ -18,7 +18,7 @@ module.exports = class CrossFrame
...
@@ -18,7 +18,7 @@ module.exports = class CrossFrame
new
Discovery
(
$window
,
options
)
new
Discovery
(
$window
,
options
)
createAnnotationSync
=
->
createAnnotationSync
=
->
whitelist
=
[
'$
highlight'
,
'$orphan'
,
'target'
,
'document'
,
'uri'
]
whitelist
=
[
'$
anchored'
,
'$highlight'
,
'target'
,
'document'
,
'uri'
]
options
=
options
=
formatter
:
(
annotation
)
->
formatter
:
(
annotation
)
->
formatted
=
{}
formatted
=
{}
...
...
h/static/scripts/widget-controller.coffee
View file @
f1e316c9
...
@@ -57,12 +57,27 @@ module.exports = class WidgetController
...
@@ -57,12 +57,27 @@ module.exports = class WidgetController
crossframe
.
call
(
'scrollToAnnotation'
,
annotation
.
$
$tag
)
crossframe
.
call
(
'scrollToAnnotation'
,
annotation
.
$
$tag
)
$scope
.
shouldShowThread
=
(
container
)
->
$scope
.
shouldShowThread
=
(
container
)
->
if
annotationUI
.
hasSelectedAnnotations
()
and
not
container
.
parent
.
parent
# Show stubs
annotationUI
.
isAnnotationSelected
(
container
.
message
?
.
id
)
if
not
container
?
.
message
?
else
return
true
true
# Show replies
if
container
.
message
.
references
?
.
length
return
true
# Show selected threads
if
annotationUI
.
hasSelectedAnnotations
()
return
annotationUI
.
isAnnotationSelected
(
container
.
message
.
id
)
# Show regardless of $anchored if that feature is turned on
if
$scope
.
feature
(
'show_unanchored_annotations'
)
return
true
# Show anchored threads
if
container
.
message
.
$anchored
return
true
return
false
$scope
.
hasFocus
=
(
annotation
)
->
$scope
.
hasFocus
=
(
annotation
)
->
!!
(
$scope
.
focusedAnnotations
?
{})[
annotation
?
.
$
$tag
]
!!
(
$scope
.
focusedAnnotations
?
{})[
annotation
?
.
$
$tag
]
$scope
.
notOrphan
=
(
container
)
->
!
container
?
.
message
?
.
$orphan
h/static/styles/threads.scss
View file @
f1e316c9
...
@@ -71,3 +71,11 @@ $thread-padding: 1em;
...
@@ -71,3 +71,11 @@ $thread-padding: 1em;
.thread-load-more
{
.thread-load-more
{
clear
:
both
;
clear
:
both
;
}
}
.thread-anchor-notice
{
// XXX: negative margins here make me sad; maybe refactor container
background-color
:
lighten
(
$gray-light
,
38%
);
border-top
:
solid
1px
$gray-lighter
;
margin
:
0
-1em
-1em
-1em
;
padding
:
1em
;
}
h/templates/client/thread.html
View file @
f1e316c9
...
@@ -45,3 +45,7 @@
...
@@ -45,3 +45,7 @@
ng-show=
"vm.shouldShowAsReply()"
>
ng-show=
"vm.shouldShowAsReply()"
>
</li>
</li>
</ul>
</ul>
<footer
class=
"thread-anchor-notice"
ng-if=
"!vm.container.message.$anchored"
>
<em>
We can't find the exact position of this annotation.
</em>
</footer>
h/templates/client/viewer.html
View file @
f1e316c9
...
@@ -43,7 +43,7 @@
...
@@ -43,7 +43,7 @@
ng-mouseenter=
"focus(child.message)"
ng-mouseenter=
"focus(child.message)"
ng-click=
"scrollTo(child.message)"
ng-click=
"scrollTo(child.message)"
ng-mouseleave=
"focus()"
ng-mouseleave=
"focus()"
ng-repeat=
"child in threadRoot.children |
filter:notOrphan |
orderBy : sort.predicate"
ng-repeat=
"child in threadRoot.children | orderBy : sort.predicate"
ng-show=
"shouldShowThread(child) && (count('edit') || count('match') || !threadFilter.active()) || vm.isNew()"
>
ng-show=
"shouldShowThread(child) && (count('edit') || count('match') || !threadFilter.active()) || vm.isNew()"
>
</li>
</li>
</ul>
</ul>
...
...
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