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
ab7ceae1
Commit
ab7ceae1
authored
Sep 25, 2015
by
Nick Stenning
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2542 from hypothesis/2525-new-annotations-disappearing
Change $anchored -> $orphan
parents
530466ae
4102d301
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
27 deletions
+45
-27
guest.coffee
h/static/scripts/annotator/guest.coffee
+2
-2
guest-test.coffee
h/static/scripts/annotator/test/guest-test.coffee
+6
-6
cross-frame.coffee
h/static/scripts/cross-frame.coffee
+1
-1
widget-controller-test.coffee
h/static/scripts/test/widget-controller-test.coffee
+31
-0
widget-controller.coffee
h/static/scripts/widget-controller.coffee
+4
-17
thread.html
h/templates/client/thread.html
+1
-1
No files found.
h/static/scripts/annotator/guest.coffee
View file @
ab7ceae1
...
...
@@ -197,10 +197,10 @@ module.exports = class Guest extends Annotator
sync
=
(
anchors
)
->
# Store the results of anchoring.
annotation
.
$
anchored
=
anchors
.
length
is
0
annotation
.
$
orphan
=
anchors
.
length
>
0
for
anchor
in
anchors
if
anchor
.
range
?
annotation
.
$
anchored
=
tru
e
annotation
.
$
orphan
=
fals
e
break
# Add the anchors for this annotation to instance storage.
...
...
h/static/scripts/annotator/test/guest-test.coffee
View file @
ab7ceae1
...
...
@@ -249,27 +249,27 @@ describe 'Guest', ->
afterEach
->
document
.
body
.
removeChild
(
el
)
it
"d
eclares annotations without targets as anchored
"
,
(
done
)
->
it
"d
oesn't declare annotations without targets as orphans
"
,
(
done
)
->
guest
=
createGuest
()
annotation
=
target
:
[]
guest
.
anchor
(
annotation
).
then
->
assert
.
is
True
(
annotation
.
$anchored
)
assert
.
is
False
(
annotation
.
$orphan
)
.
then
(
done
,
done
)
it
"d
eclares annotations with a working target anchored
"
,
(
done
)
->
it
"d
oesn't declare annotations with a working target orphans
"
,
(
done
)
->
guest
=
createGuest
()
annotation
=
target
:
[{
selector
:
"test"
}]
sandbox
.
stub
(
anchoring
,
'anchor'
).
returns
(
Promise
.
resolve
(
range
))
guest
.
anchor
(
annotation
).
then
->
assert
.
is
True
(
annotation
.
$anchored
)
assert
.
is
False
(
annotation
.
$orphan
)
.
then
(
done
,
done
)
it
"declares annotations with broken targets
not anchored
"
,
(
done
)
->
it
"declares annotations with broken targets
as orphans
"
,
(
done
)
->
guest
=
createGuest
()
annotation
=
target
:
[{
selector
:
'broken selector'
}]
sandbox
.
stub
(
anchoring
,
'anchor'
).
returns
(
Promise
.
reject
())
guest
.
anchor
(
annotation
).
then
->
assert
.
is
False
(
annotation
.
$anchored
)
assert
.
is
True
(
annotation
.
$orphan
)
.
then
(
done
,
done
)
it
'updates the cross frame and bucket bar plugins'
,
(
done
)
->
...
...
h/static/scripts/cross-frame.coffee
View file @
ab7ceae1
...
...
@@ -18,7 +18,7 @@ module.exports = class CrossFrame
new
Discovery
(
$window
,
options
)
createAnnotationSync
=
->
whitelist
=
[
'$
anchored
'
,
'$highlight'
,
'target'
,
'document'
,
'uri'
]
whitelist
=
[
'$
orphan
'
,
'$highlight'
,
'target'
,
'document'
,
'uri'
]
options
=
formatter
:
(
annotation
)
->
formatted
=
{}
...
...
h/static/scripts/test/widget-controller-test.coffee
View file @
ab7ceae1
...
...
@@ -86,3 +86,34 @@ describe 'WidgetController', ->
assert
.
calledWith
(
loadSpy
,
[
40
..
59
])
assert
.
calledWith
(
loadSpy
,
[
60
..
79
])
assert
.
calledWith
(
loadSpy
,
[
80
..
99
])
describe
'shouldShowThread()'
,
->
it
'returns false for orphan annotations'
,
->
# Turn the 'show_unanchored_annotations' feature off.
$scope
.
feature
=
->
false
container
=
message
:
$orphan
:
true
assert
(
$scope
.
shouldShowThread
(
container
)
is
false
)
it
'returns true for non-orphan annotations'
,
->
# Turn the 'show_unanchored_annotations' feature off.
$scope
.
feature
=
->
false
container
=
message
:
$orphan
:
false
assert
(
$scope
.
shouldShowThread
(
container
)
is
true
)
it
'returns true for orphan annotations if show_unanchored_annotations is on'
,
->
# Turn the 'show_unanchored_annotations' feature on.
$scope
.
feature
=
->
true
container
=
message
:
$orphan
:
true
assert
(
$scope
.
shouldShowThread
(
container
)
is
true
)
h/static/scripts/widget-controller.coffee
View file @
ab7ceae1
...
...
@@ -58,27 +58,14 @@ module.exports = class WidgetController
crossframe
.
call
(
'scrollToAnnotation'
,
annotation
.
$
$tag
)
$scope
.
shouldShowThread
=
(
container
)
->
# Show stubs
if
not
container
?
.
message
?
return
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
# Show regardless of $orphan if that feature is turned on
if
$scope
.
feature
(
'show_unanchored_annotations'
)
return
true
# Show anchored threads
if
container
.
message
.
$anchored
return
true
if
container
?
.
message
?
.
$orphan
==
true
return
false
return
fals
e
return
tru
e
$scope
.
hasFocus
=
(
annotation
)
->
!!
(
$scope
.
focusedAnnotations
?
{})[
annotation
?
.
$
$tag
]
h/templates/client/thread.html
View file @
ab7ceae1
...
...
@@ -47,6 +47,6 @@
</ul>
<footer
class=
"thread-anchor-notice"
ng-if=
"feature('show_unanchored_annotations') && isSidebar &&
!vm.container.message.$anchored
"
>
ng-if=
"feature('show_unanchored_annotations') && isSidebar &&
vm.container.message.$orphan
"
>
<em>
We can't find the exact position of this annotation.
</em>
</footer>
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