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
a57ff80a
Commit
a57ff80a
authored
May 29, 2017
by
Robert Hodan
Committed by
Juan Corona
Jun 27, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for destroying connected frames
parent
eb093f7e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
1 deletion
+31
-1
cross-frame.coffee
src/annotator/plugin/cross-frame.coffee
+0
-1
frame-sync.js
src/sidebar/frame-sync.js
+17
-0
frames.js
src/sidebar/reducers/frames.js
+14
-0
No files found.
src/annotator/plugin/cross-frame.coffee
View file @
a57ff80a
...
...
@@ -64,5 +64,4 @@ module.exports = class CrossFrame extends Plugin
FrameUtil
.
injectHypothesis
(
frame
,
options
.
embedScriptUrl
)
_iframeUnloaded
=
(
frame
)
->
# TODO: Bridge call here not yet implemented, placeholder for now
bridge
.
call
(
'destroyFrame'
,
frame
.
src
);
src/sidebar/frame-sync.js
View file @
a57ff80a
...
...
@@ -124,6 +124,10 @@ function FrameSync($rootScope, $window, Discovery, annotationUI, bridge) {
$rootScope
.
$broadcast
(
events
.
BEFORE_ANNOTATION_CREATED
,
annot
);
});
bridge
.
on
(
'destroyFrame'
,
function
(
uri
)
{
destroyFrame
(
uri
);
});
// Anchoring an annotation in the frame completed
bridge
.
on
(
'sync'
,
function
(
events_
)
{
events_
.
forEach
(
function
(
event
)
{
...
...
@@ -181,6 +185,19 @@ function FrameSync($rootScope, $window, Discovery, annotationUI, bridge) {
});
}
function
destroyFrame
(
uri
)
{
var
frames
=
annotationUI
.
frames
();
var
frameToDestroy
;
for
(
var
i
=
0
;
i
<
frames
.
length
;
i
++
)
{
var
frame
=
frames
[
i
];
if
(
frame
.
uri
===
uri
)
{
frameToDestroy
=
frame
;
break
;
}
}
if
(
frameToDestroy
)
annotationUI
.
destroyFrame
(
frameToDestroy
);
}
/**
* Find and connect to Hypothesis clients in the current window.
*/
...
...
src/sidebar/reducers/frames.js
View file @
a57ff80a
...
...
@@ -17,6 +17,12 @@ var update = {
return
{
frames
:
state
.
frames
.
concat
(
action
.
frame
)};
},
DESTROY_FRAME
:
function
(
state
,
action
)
{
var
index
=
state
.
frames
.
indexOf
(
action
.
frame
);
if
(
index
>=
0
)
state
.
frames
.
splice
(
index
,
1
);
return
{
frames
:
state
.
frames
};
},
UPDATE_FRAME_ANNOTATION_FETCH_STATUS
:
function
(
state
,
action
)
{
var
frames
=
state
.
frames
.
map
(
function
(
frame
)
{
var
match
=
(
frame
.
uri
&&
frame
.
uri
===
action
.
uri
);
...
...
@@ -43,6 +49,13 @@ function connectFrame(frame) {
return
{
type
:
actions
.
CONNECT_FRAME
,
frame
:
frame
};
}
/**
* Remove a frame from the list of frames currently connected to the sidebar app.
*/
function
destroyFrame
(
frame
)
{
return
{
type
:
actions
.
DESTROY_FRAME
,
frame
:
frame
};
}
/**
* Update the `isAnnotationFetchComplete` flag of the frame.
*/
...
...
@@ -100,6 +113,7 @@ module.exports = {
actions
:
{
connectFrame
:
connectFrame
,
destroyFrame
:
destroyFrame
,
updateFrameAnnotationFetchStatus
:
updateFrameAnnotationFetchStatus
,
},
...
...
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