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
298ea35d
Commit
298ea35d
authored
Mar 27, 2015
by
Randall Leeds
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2080 from hypothesis/1612-hide-orphans
Hide orphan annotations in the sidebar
parents
5b861c1f
15607e16
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
3 deletions
+34
-3
monkey.coffee
h/static/scripts/annotator/monkey.coffee
+3
-1
guest-test.coffee
h/static/scripts/annotator/test/guest-test.coffee
+27
-0
cross-frame.coffee
h/static/scripts/cross-frame.coffee
+1
-1
widget-controller.coffee
h/static/scripts/widget-controller.coffee
+2
-0
viewer.html
h/templates/client/viewer.html
+1
-1
No files found.
h/static/scripts/annotator/monkey.coffee
View file @
298ea35d
...
...
@@ -32,8 +32,10 @@ Annotator.prototype.setupAnnotation = (annotation) ->
console
.
log
"Error in setupAnnotation for"
,
annotation
.
id
,
":"
,
exception
.
stack
?
exception
annotation
if
annotation
.
target
?
.
length
and
not
annotation
.
anchors
?
.
length
annotation
.
$orphan
=
true
annotation
# Override deleteAnnotation to deal with anchors, not highlights.
Annotator
.
prototype
.
deleteAnnotation
=
(
annotation
)
->
...
...
h/static/scripts/annotator/test/guest-test.coffee
View file @
298ea35d
Annotator
=
require
(
'annotator'
)
require
(
'../monkey'
)
Guest
=
require
(
'../guest'
)
assert
=
chai
.
assert
...
...
@@ -31,6 +32,11 @@ describe 'Guest', ->
getHighlights
:
sandbox
.
stub
().
returns
([])
getAnchors
:
sandbox
.
stub
().
returns
([])
createAnchor
:
sandbox
.
spy
(
annotation
,
target
)
->
anchor
=
"anchor for "
+
target
annotation
.
anchors
.
push
anchor
result
:
anchor
}
Annotator
.
Plugin
.
CrossFrame
=
->
fakeCrossFrame
...
...
@@ -291,3 +297,24 @@ describe 'Guest', ->
guest
=
createGuest
()
guest
.
setupAnnotation
({
ranges
:
[]})
assert
.
called
(
fakeCrossFrame
.
sync
)
describe
'Annotator monkey patch'
,
->
describe
'setupAnnotation()'
,
->
it
"doesn't declare annotation without targets as orphans"
,
->
guest
=
createGuest
()
annotation
=
target
:
[]
guest
.
setupAnnotation
(
annotation
)
assert
.
isFalse
!!
annotation
.
$orphan
it
"doesn't declare annotations with a working target as orphans"
,
->
guest
=
createGuest
()
annotation
=
target
:
[
"test target"
]
guest
.
setupAnnotation
(
annotation
)
assert
.
isFalse
!!
annotation
.
$orphan
it
"declares annotations with broken targets as orphans"
,
->
guest
=
createGuest
()
guest
.
anchoring
.
createAnchor
=
->
result
:
null
annotation
=
target
:
[
"broken target"
]
guest
.
setupAnnotation
(
annotation
)
assert
!!
annotation
.
$orphan
h/static/scripts/cross-frame.coffee
View file @
298ea35d
...
...
@@ -20,7 +20,7 @@ module.exports = class CrossFrame
new
Discovery
(
$window
,
options
)
createAnnotationSync
=
->
whitelist
=
[
'$highlight'
,
'target'
,
'document'
,
'uri'
]
whitelist
=
[
'$highlight'
,
'
$orphan'
,
'
target'
,
'document'
,
'uri'
]
options
=
formatter
:
(
annotation
)
->
formatted
=
{}
...
...
h/static/scripts/widget-controller.coffee
View file @
298ea35d
...
...
@@ -70,3 +70,5 @@ module.exports = class WidgetController
$scope
.
hasFocus
=
(
annotation
)
->
!!
(
$scope
.
focusedAnnotations
?
{})[
annotation
?
.
$
$tag
]
$scope
.
notOrphan
=
(
container
)
->
!
container
?
.
message
?
.
$orphan
h/templates/client/viewer.html
View file @
298ea35d
...
...
@@ -40,7 +40,7 @@
ng-mouseenter=
"focus(child.message)"
ng-click=
"scrollTo(child.message)"
ng-mouseleave=
"focus()"
ng-repeat=
"child in threadRoot.children | orderBy : sort.predicate"
ng-repeat=
"child in threadRoot.children |
filter:notOrphan |
orderBy : sort.predicate"
ng-show=
"shouldShowThread(child) && (count('edit') || count('match') || !threadFilter.active())"
>
</li>
</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