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
46ecdc53
Commit
46ecdc53
authored
Apr 12, 2021
by
Robert Knight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename `Guest#_connectAnnotationUISync`
Give this method a name that more obviously explains what it does.
parent
425f1fe3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
7 deletions
+14
-7
guest.js
src/annotator/guest.js
+14
-7
No files found.
src/annotator/guest.js
View file @
46ecdc53
...
...
@@ -155,16 +155,19 @@ export default class Guest {
// The "top" guest instance will have this as null since it's in a top frame not a sub frame
this
.
_frameIdentifier
=
config
.
subFrameIdentifier
||
null
;
// Setup connection to sidebar.
this
.
crossframe
=
new
CrossFrame
(
this
.
element
,
{
config
,
on
:
(
event
,
handler
)
=>
this
.
_emitter
.
subscribe
(
event
,
handler
),
emit
:
(
event
,
...
args
)
=>
this
.
_emitter
.
publish
(
event
,
...
args
),
});
this
.
crossframe
.
onConnect
(()
=>
this
.
_setupInitialState
(
config
));
this
.
_connectSidebarEvents
();
this
.
_sideBySideActive
=
false
;
// Listen for annotations being loaded or unloaded.
this
.
_connectAnnotationSync
();
this
.
_connectAnnotationUISync
(
this
.
crossframe
);
// Setup event handlers on the root element
this
.
_listeners
=
new
ListenerCollection
();
...
...
@@ -269,8 +272,10 @@ export default class Guest {
});
}
_connectAnnotationUISync
(
crossframe
)
{
crossframe
.
on
(
'focusAnnotations'
,
(
tags
=
[])
=>
{
_connectSidebarEvents
()
{
// Handlers for events sent when user hovers or clicks on an annotation card
// in the sidebar.
this
.
crossframe
.
on
(
'focusAnnotations'
,
(
tags
=
[])
=>
{
for
(
let
anchor
of
this
.
anchors
)
{
if
(
anchor
.
highlights
)
{
const
toggle
=
tags
.
includes
(
anchor
.
annotation
.
$tag
);
...
...
@@ -279,7 +284,7 @@ export default class Guest {
}
});
crossframe
.
on
(
'scrollToAnnotation'
,
tag
=>
{
this
.
crossframe
.
on
(
'scrollToAnnotation'
,
tag
=>
{
for
(
let
anchor
of
this
.
anchors
)
{
if
(
anchor
.
highlights
)
{
if
(
anchor
.
annotation
.
$tag
===
tag
)
{
...
...
@@ -302,14 +307,16 @@ export default class Guest {
}
});
crossframe
.
on
(
'getDocumentInfo'
,
cb
=>
{
// Handler for when sidebar requests metadata for the current document
this
.
crossframe
.
on
(
'getDocumentInfo'
,
cb
=>
{
this
.
getDocumentInfo
()
.
then
(
info
=>
cb
(
null
,
info
))
.
catch
(
reason
=>
cb
(
reason
));
});
crossframe
.
on
(
'setVisibleHighlights'
,
state
=>
{
this
.
setVisibleHighlights
(
state
);
// Handler for controls on the sidebar
this
.
crossframe
.
on
(
'setVisibleHighlights'
,
showHighlights
=>
{
this
.
setVisibleHighlights
(
showHighlights
);
});
}
...
...
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