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
cb4fc4ab
Commit
cb4fc4ab
authored
May 25, 2017
by
Robert Hodan
Committed by
Juan Corona
Jun 05, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for automatic discovery of newly added/removed iframes
parent
df5b0824
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
cross-frame.coffee
src/annotator/plugin/cross-frame.coffee
+23
-0
No files found.
src/annotator/plugin/cross-frame.coffee
View file @
cb4fc4ab
...
@@ -39,6 +39,12 @@ module.exports = class CrossFrame extends Plugin
...
@@ -39,6 +39,12 @@ module.exports = class CrossFrame extends Plugin
# Find, and inject Hypothesis into Guest's iframes
# Find, and inject Hypothesis into Guest's iframes
# _discoverOwnFrames()
# _discoverOwnFrames()
# Listen for DOM mutations, to know when iframes are added / removed
observer
=
new
MutationObserver
(
_checkForIFrames
)
config
=
{
childList
:
true
,
subtree
:
true
};
# THESIS TODO: Disabled until multi-guest support is fully implemented
# observer.observe(elem, config);
this
.
destroy
=
->
this
.
destroy
=
->
# super doesnt work here :(
# super doesnt work here :(
Plugin
::
destroy
.
apply
(
this
,
arguments
)
Plugin
::
destroy
.
apply
(
this
,
arguments
)
...
@@ -62,6 +68,23 @@ module.exports = class CrossFrame extends Plugin
...
@@ -62,6 +68,23 @@ module.exports = class CrossFrame extends Plugin
iframes
=
frameUtil
.
findIFrames
(
elem
)
iframes
=
frameUtil
.
findIFrames
(
elem
)
_handleIFrames
(
iframes
)
_handleIFrames
(
iframes
)
_checkForIFrames
=
(
mutations
)
->
for
own
key
,
mutation
of
mutations
addedNodes
=
mutation
.
addedNodes
removedNodes
=
mutation
.
removedNodes
# Add iframes
for
own
key
,
node
of
addedNodes
if
(
node
.
tagName
==
'IFRAME'
&&
node
.
className
!=
'h-sidebar-iframe'
)
node
.
addEventListener
'load'
,
->
bridge
.
call
(
'addedIFrame'
)
_handleIFrame
(
node
)
# Remove iframes
for
own
key
,
node
of
removedNodes
if
(
node
.
tagName
==
'IFRAME'
)
bridge
.
call
(
'removedIFrame'
)
_handleIFrame
=
(
iframe
)
->
_handleIFrame
=
(
iframe
)
->
if
!
frameUtil
.
isAccessible
(
iframe
)
then
return
if
!
frameUtil
.
isAccessible
(
iframe
)
then
return
...
...
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