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
89d47c21
Commit
89d47c21
authored
Feb 04, 2015
by
Aron Carroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename CrossFrameBridge to Bridge
parent
72a07437
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
34 additions
and
34 deletions
+34
-34
annotation-ui-sync.coffee
h/static/scripts/annotation-ui-sync.coffee
+1
-1
bridge.coffee
h/static/scripts/annotator/plugin/bridge.coffee
+1
-1
bridge.coffee
h/static/scripts/bridge.coffee
+4
-4
cross-frame-service.coffee
h/static/scripts/cross-frame-service.coffee
+3
-3
bridge-test.coffee
tests/js/annotator/plugins/bridge-test.coffee
+13
-13
bridge-test.coffee
tests/js/bridge-test.coffee
+3
-3
cross-frame-service-test.coffee
tests/js/cross-frame-service-test.coffee
+9
-9
No files found.
h/static/scripts/annotation-ui-sync.coffee
View file @
89d47c21
...
...
@@ -4,7 +4,7 @@ class AnnotationUISync
###*
# @name AnnotationUISync
# @param {$window} $window An Angular window service.
# @param {
CrossFrame
Bridge} bridge
# @param {Bridge} bridge
# @param {AnnotationSync} annotationSync
# @param {AnnotationUI} annotationUI An instance of the AnnotatonUI service
# @description
...
...
h/static/scripts/annotator/plugin/bridge.coffee
View file @
89d47c21
...
...
@@ -14,7 +14,7 @@ Bridge = class Annotator.Plugin.Bridge extends Annotator.Plugin
discovery
=
new
Bridge
.
CrossFrameDiscovery
(
window
,
opts
)
opts
=
extract
(
options
,
'scope'
)
bridge
=
new
Bridge
.
CrossFrame
Bridge
(
opts
)
bridge
=
new
Bridge
.
Bridge
(
opts
)
opts
=
extract
(
options
,
'on'
,
'emit'
,
'formatter'
,
'parser'
)
annotationSync
=
new
Bridge
.
AnnotationSync
(
bridge
,
opts
)
...
...
h/static/scripts/
cross-frame-
bridge.coffee
→
h/static/scripts/bridge.coffee
View file @
89d47c21
class
CrossFrame
Bridge
class
Bridge
options
:
# Scope identifier to distinguish this channel from any others
scope
:
'crossFrameBridge'
...
...
@@ -89,7 +89,7 @@ class CrossFrameBridge
on
:
(
method
,
callback
)
->
if
@
channelListeners
[
method
]
throw
new
Error
(
"Listener '
#{
method
}
' already bound in
CrossFrame
Bridge"
)
throw
new
Error
(
"Listener '
#{
method
}
' already bound in Bridge"
)
@
channelListeners
[
method
]
=
callback
for
l
in
@
links
...
...
@@ -116,6 +116,6 @@ class CrossFrameBridge
channel
=
Channel
.
build
(
options
)
if
angular
?
angular
.
module
(
'h'
).
value
(
'
CrossFrameBridge'
,
CrossFrame
Bridge
)
angular
.
module
(
'h'
).
value
(
'
Bridge'
,
Bridge
)
else
Annotator
.
Plugin
.
Bridge
.
CrossFrameBridge
=
CrossFrame
Bridge
Annotator
.
Plugin
.
Bridge
.
Bridge
=
Bridge
h/static/scripts/cross-frame-service.coffee
View file @
89d47c21
...
...
@@ -4,12 +4,12 @@ class CrossFrameService
this
.
inject
=
[
'$rootScope'
,
'$document'
,
'$window'
,
'store'
,
'annotationUI'
'CrossFrameDiscovery'
,
'
CrossFrame
Bridge'
,
'CrossFrameDiscovery'
,
'Bridge'
,
'AnnotationSync'
,
'AnnotationUISync'
]
constructor
:
(
$rootScope
,
$document
,
$window
,
store
,
annotationUI
CrossFrameDiscovery
,
CrossFrame
Bridge
,
CrossFrameDiscovery
,
Bridge
,
AnnotationSync
,
AnnotationUISync
)
->
@
providers
=
[]
...
...
@@ -24,7 +24,7 @@ class CrossFrameService
createBridge
=
->
options
=
scope
:
'annotator:bridge'
new
CrossFrame
Bridge
(
options
)
new
Bridge
(
options
)
createAnnotationSync
=
(
bridge
)
->
whitelist
=
[
'target'
,
'document'
,
'uri'
]
...
...
tests/js/annotator/plugins/bridge-test.coffee
View file @
89d47c21
...
...
@@ -4,7 +4,7 @@ sinon.assert.expose(assert, prefix: '')
describe
'Annotator.Plugin.Bridge'
,
->
Bridge
=
null
fakeCFDiscovery
=
null
fake
CF
Bridge
=
null
fakeBridge
=
null
fakeAnnotationSync
=
null
sandbox
=
sinon
.
sandbox
.
create
()
...
...
@@ -20,7 +20,7 @@ describe 'Annotator.Plugin.Bridge', ->
startDiscovery
:
sandbox
.
stub
()
stopDiscovery
:
sandbox
.
stub
()
fake
CF
Bridge
=
fakeBridge
=
createChannel
:
sandbox
.
stub
()
onConnect
:
sandbox
.
stub
()
notify
:
sandbox
.
stub
()
...
...
@@ -32,7 +32,7 @@ describe 'Annotator.Plugin.Bridge', ->
Bridge
=
Annotator
.
Plugin
.
Bridge
sandbox
.
stub
(
Bridge
,
'AnnotationSync'
).
returns
(
fakeAnnotationSync
)
sandbox
.
stub
(
Bridge
,
'CrossFrameDiscovery'
).
returns
(
fakeCFDiscovery
)
sandbox
.
stub
(
Bridge
,
'
CrossFrameBridge'
).
returns
(
fakeCF
Bridge
)
sandbox
.
stub
(
Bridge
,
'
Bridge'
).
returns
(
fake
Bridge
)
afterEach
->
sandbox
.
restore
()
...
...
@@ -48,15 +48,15 @@ describe 'Annotator.Plugin.Bridge', ->
assert
.
called
(
Bridge
.
CrossFrameDiscovery
)
assert
.
calledWith
(
Bridge
.
CrossFrameDiscovery
,
window
,
server
:
true
)
it
'instantiates the
CrossFrame
Bridge component'
,
->
it
'instantiates the Bridge component'
,
->
createBridge
()
assert
.
called
(
Bridge
.
CrossFrame
Bridge
)
assert
.
called
(
Bridge
.
Bridge
)
assert
.
calledWith
(
Bridge
.
CrossFrameDiscovery
)
it
'passes the options along to the bridge'
,
->
createBridge
(
scope
:
'myscope'
)
assert
.
called
(
Bridge
.
CrossFrame
Bridge
)
assert
.
calledWith
(
Bridge
.
CrossFrame
Bridge
,
scope
:
'myscope'
)
assert
.
called
(
Bridge
.
Bridge
)
assert
.
calledWith
(
Bridge
.
Bridge
,
scope
:
'myscope'
)
it
'instantiates the AnnotationSync component'
,
->
createBridge
()
...
...
@@ -66,7 +66,7 @@ describe 'Annotator.Plugin.Bridge', ->
formatter
=
(
x
)
->
x
createBridge
(
formatter
:
formatter
)
assert
.
called
(
Bridge
.
AnnotationSync
)
assert
.
calledWith
(
Bridge
.
AnnotationSync
,
fake
CF
Bridge
,
{
assert
.
calledWith
(
Bridge
.
AnnotationSync
,
fakeBridge
,
{
on
:
sinon
.
match
.
func
emit
:
sinon
.
match
.
func
formatter
:
formatter
...
...
@@ -82,8 +82,8 @@ describe 'Annotator.Plugin.Bridge', ->
bridge
=
createBridge
()
bridge
.
pluginInit
()
fakeCFDiscovery
.
startDiscovery
.
yield
(
'SOURCE'
,
'ORIGIN'
,
'TOKEN'
)
assert
.
called
(
fake
CF
Bridge
.
createChannel
)
assert
.
calledWith
(
fake
CF
Bridge
.
createChannel
,
'SOURCE'
,
'ORIGIN'
,
'TOKEN'
)
assert
.
called
(
fakeBridge
.
createChannel
)
assert
.
calledWith
(
fakeBridge
.
createChannel
,
'SOURCE'
,
'ORIGIN'
,
'TOKEN'
)
describe
'.destroy'
,
->
it
'stops the discovery of new frames'
,
->
...
...
@@ -101,17 +101,17 @@ describe 'Annotator.Plugin.Bridge', ->
it
'proxies the call to the bridge'
,
->
bridge
=
createBridge
()
bridge
.
on
(
'event'
,
'arg'
)
assert
.
calledWith
(
fake
CF
Bridge
.
on
,
'event'
,
'arg'
)
assert
.
calledWith
(
fakeBridge
.
on
,
'event'
,
'arg'
)
describe
'.notify'
,
->
it
'proxies the call to the bridge'
,
->
bridge
=
createBridge
()
bridge
.
notify
(
method
:
'method'
)
assert
.
calledWith
(
fake
CF
Bridge
.
notify
,
method
:
'method'
)
assert
.
calledWith
(
fakeBridge
.
notify
,
method
:
'method'
)
describe
'.onConnect'
,
->
it
'proxies the call to the bridge'
,
->
bridge
=
createBridge
()
fn
=
->
bridge
.
onConnect
(
fn
)
assert
.
calledWith
(
fake
CF
Bridge
.
onConnect
,
fn
)
assert
.
calledWith
(
fakeBridge
.
onConnect
,
fn
)
tests/js/
cross-frame-
bridge-test.coffee
→
tests/js/bridge-test.coffee
View file @
89d47c21
assert
=
chai
.
assert
sinon
.
assert
.
expose
assert
,
prefix
:
null
describe
'
CrossFrame
Bridge'
,
->
describe
'Bridge'
,
->
sandbox
=
sinon
.
sandbox
.
create
()
createBridge
=
null
createChannel
=
null
beforeEach
module
(
'h'
)
beforeEach
inject
(
CrossFrame
Bridge
)
->
beforeEach
inject
(
Bridge
)
->
createBridge
=
(
options
)
->
new
CrossFrame
Bridge
(
options
)
new
Bridge
(
options
)
createChannel
=
->
call
:
sandbox
.
stub
()
...
...
tests/js/cross-frame-service-test.coffee
View file @
89d47c21
...
...
@@ -10,7 +10,7 @@ describe 'CrossFrameService', ->
fakeStore
=
null
fakeAnnotationUI
=
null
fakeCrossFrameDiscovery
=
null
fake
CrossFrame
Bridge
=
null
fakeBridge
=
null
fakeAnnotationSync
=
null
fakeAnnotationUISync
=
null
...
...
@@ -22,7 +22,7 @@ describe 'CrossFrameService', ->
fakeAnnotationUI
=
{}
fakeCrossFrameDiscovery
=
startDiscovery
:
sandbox
.
stub
()
fake
CrossFrame
Bridge
=
fakeBridge
=
notify
:
sandbox
.
stub
()
createChannel
:
sandbox
.
stub
()
onConnect
:
sandbox
.
stub
()
...
...
@@ -35,8 +35,8 @@ describe 'CrossFrameService', ->
$provide
.
value
(
'annotationUI'
,
fakeAnnotationUI
)
$provide
.
value
(
'CrossFrameDiscovery'
,
sandbox
.
stub
().
returns
(
fakeCrossFrameDiscovery
))
$provide
.
value
(
'
CrossFrame
Bridge'
,
sandbox
.
stub
().
returns
(
fake
CrossFrame
Bridge
))
$provide
.
value
(
'Bridge'
,
sandbox
.
stub
().
returns
(
fakeBridge
))
$provide
.
value
(
'AnnotationSync'
,
sandbox
.
stub
().
returns
(
fakeAnnotationSync
))
$provide
.
value
(
'AnnotationUISync'
,
...
...
@@ -54,13 +54,13 @@ describe 'CrossFrameService', ->
it
'creates a new channel when the discovery module finds a frame'
,
->
fakeCrossFrameDiscovery
.
startDiscovery
.
yields
(
'source'
,
'origin'
,
'token'
)
crossframe
.
connect
()
assert
.
calledWith
(
fake
CrossFrame
Bridge
.
createChannel
,
assert
.
calledWith
(
fakeBridge
.
createChannel
,
'source'
,
'origin'
,
'token'
)
it
'queries discovered frames for metadata'
,
->
info
=
{
metadata
:
link
:
[{
href
:
'http://example.com'
}]}
channel
=
{
call
:
sandbox
.
stub
().
yieldsTo
(
'success'
,
info
)}
fake
CrossFrame
Bridge
.
onConnect
.
yields
(
channel
)
fakeBridge
.
onConnect
.
yields
(
channel
)
crossframe
.
connect
()
assert
.
calledWith
(
channel
.
call
,
{
method
:
'getDocumentInfo'
...
...
@@ -70,7 +70,7 @@ describe 'CrossFrameService', ->
it
'updates the providers array'
,
->
info
=
{
metadata
:
link
:
[{
href
:
'http://example.com'
}]}
channel
=
{
call
:
sandbox
.
stub
().
yieldsTo
(
'success'
,
info
)}
fake
CrossFrame
Bridge
.
onConnect
.
yields
(
channel
)
fakeBridge
.
onConnect
.
yields
(
channel
)
crossframe
.
connect
()
assert
.
deepEqual
(
crossframe
.
providers
,
[
{
channel
:
channel
,
entities
:
[
'http://example.com'
]}
...
...
@@ -82,5 +82,5 @@ describe 'CrossFrameService', ->
message
=
{
method
:
'foo'
,
params
:
'bar'
}
crossframe
.
connect
()
# create the bridge.
crossframe
.
notify
(
message
)
assert
.
calledOn
(
fake
CrossFrameBridge
.
notify
,
fakeCrossFram
eBridge
)
assert
.
calledWith
(
fake
CrossFrame
Bridge
.
notify
,
message
)
assert
.
calledOn
(
fake
Bridge
.
notify
,
fak
eBridge
)
assert
.
calledWith
(
fakeBridge
.
notify
,
message
)
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