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
63e2da2f
Commit
63e2da2f
authored
Feb 25, 2021
by
Eduardo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Rename methods hide/show to open/close"
This reverts commit
85f6023f
.
parent
df326eef
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
131 additions
and
132 deletions
+131
-132
guest.js
src/annotator/guest.js
+6
-6
notebook.js
src/annotator/notebook.js
+6
-7
sidebar.js
src/annotator/sidebar.js
+18
-18
guest-test.js
src/annotator/test/guest-test.js
+2
-2
notebook-test.js
src/annotator/test/notebook-test.js
+27
-27
sidebar-test.js
src/annotator/test/sidebar-test.js
+58
-58
UserMenu.js
src/sidebar/components/UserMenu.js
+1
-1
UserMenu-test.js
src/sidebar/components/test/UserMenu-test.js
+1
-1
frame-sync.js
src/sidebar/services/frame-sync.js
+5
-5
frame-sync-test.js
src/sidebar/services/test/frame-sync-test.js
+7
-7
No files found.
src/annotator/guest.js
View file @
63e2da2f
...
...
@@ -206,14 +206,14 @@ export default class Guest extends Delegator {
// Hide the sidebar in response to a document click or tap, so it doesn't obscure
// the document content.
const
maybe
Clos
eSidebar
=
event
=>
{
const
maybe
Hid
eSidebar
=
event
=>
{
if
(
!
this
.
closeSidebarOnDocumentClick
||
this
.
isEventInAnnotator
(
event
))
{
// Don't hide the sidebar if event occurred inside Hypothesis UI, or
// the user is making a selection, or the behavior was disabled because
// the sidebar doesn't overlap the content.
return
;
}
this
.
crossframe
?.
call
(
'
clos
eSidebar'
);
this
.
crossframe
?.
call
(
'
hid
eSidebar'
);
};
addListener
(
'click'
,
event
=>
{
...
...
@@ -222,7 +222,7 @@ export default class Guest extends Delegator {
const
toggle
=
event
.
metaKey
||
event
.
ctrlKey
;
this
.
selectAnnotations
(
annotations
,
toggle
);
}
else
{
maybe
Clos
eSidebar
(
event
);
maybe
Hid
eSidebar
(
event
);
}
});
...
...
@@ -230,7 +230,7 @@ export default class Guest extends Delegator {
// on touch-input devices, not all elements will generate a "click" event.
addListener
(
'touchstart'
,
event
=>
{
if
(
!
annotationsAt
(
event
.
target
).
length
)
{
maybe
Clos
eSidebar
(
event
);
maybe
Hid
eSidebar
(
event
);
}
});
...
...
@@ -593,7 +593,7 @@ export default class Guest extends Delegator {
targets
.
then
(()
=>
this
.
anchor
(
/** @type {AnnotationData} */
(
annotation
)));
if
(
!
annotation
.
$highlight
)
{
this
.
crossframe
?.
call
(
'
open
Sidebar'
);
this
.
crossframe
?.
call
(
'
show
Sidebar'
);
}
return
annotation
;
}
...
...
@@ -617,7 +617,7 @@ export default class Guest extends Delegator {
showAnnotations
(
annotations
)
{
const
tags
=
annotations
.
map
(
a
=>
a
.
$tag
);
this
.
crossframe
?.
call
(
'showAnnotations'
,
tags
);
this
.
crossframe
?.
call
(
'
open
Sidebar'
);
this
.
crossframe
?.
call
(
'
show
Sidebar'
);
}
/**
...
...
src/annotator/notebook.js
View file @
63e2da2f
import
Delegator
from
'./delegator'
;
import
{
createSidebarConfig
}
from
'./config/sidebar'
;
import
{
createShadowRoot
}
from
'./util/shadow-root'
;
import
{
render
}
from
'preact'
;
/**
* Create the iframe that will load the notebook application.
...
...
@@ -52,13 +51,13 @@ export default class Notebook extends Delegator {
*/
this
.
container
=
null
;
this
.
subscribe
(
'
open
Notebook'
,
groupId
=>
{
this
.
subscribe
(
'
show
Notebook'
,
groupId
=>
{
this
.
_groupId
=
groupId
;
this
.
open
();
this
.
show
();
});
this
.
subscribe
(
'
closeNotebook'
,
()
=>
this
.
clos
e
());
this
.
subscribe
(
'
hideNotebook'
,
()
=>
this
.
hid
e
());
// If the sidebar has opened, get out of the way
this
.
subscribe
(
'sidebarOpened'
,
()
=>
this
.
clos
e
());
this
.
subscribe
(
'sidebarOpened'
,
()
=>
this
.
hid
e
());
}
_update
()
{
...
...
@@ -77,14 +76,14 @@ export default class Notebook extends Delegator {
}
}
open
()
{
show
()
{
const
container
=
this
.
_initContainer
();
this
.
_update
();
container
.
classList
.
add
(
'is-open'
);
container
.
style
.
display
=
''
;
}
clos
e
()
{
hid
e
()
{
if
(
this
.
container
)
{
this
.
container
.
classList
.
remove
(
'is-open'
);
this
.
container
.
style
.
display
=
'none'
;
...
...
src/annotator/sidebar.js
View file @
63e2da2f
...
...
@@ -127,14 +127,14 @@ export default class Sidebar extends Guest {
config
.
query
||
config
.
group
)
{
this
.
subscribe
(
'panelReady'
,
()
=>
this
.
open
());
this
.
subscribe
(
'panelReady'
,
()
=>
this
.
show
());
}
// Set up the toolbar on the left edge of the sidebar.
const
toolbarContainer
=
document
.
createElement
(
'div'
);
this
.
toolbar
=
new
ToolbarController
(
toolbarContainer
,
{
createAnnotation
:
()
=>
this
.
createAnnotation
(),
setSidebarOpen
:
open
=>
(
open
?
this
.
open
()
:
this
.
clos
e
()),
setSidebarOpen
:
open
=>
(
open
?
this
.
show
()
:
this
.
hid
e
()),
setHighlightsVisible
:
show
=>
this
.
setAllVisibleHighlights
(
show
),
});
this
.
toolbar
.
useMinimalControls
=
config
.
theme
===
'clean'
;
...
...
@@ -159,7 +159,7 @@ export default class Sidebar extends Guest {
final
:
/** @type {number|null} */
(
null
),
};
this
.
_setupGestures
();
this
.
clos
e
();
this
.
hid
e
();
// Publisher-provided callback functions
const
[
serviceConfig
]
=
config
.
services
||
[];
...
...
@@ -205,21 +205,21 @@ export default class Sidebar extends Guest {
_setupSidebarEvents
()
{
annotationCounts
(
document
.
body
,
this
.
crossframe
);
sidebarTrigger
(
document
.
body
,
()
=>
this
.
open
());
sidebarTrigger
(
document
.
body
,
()
=>
this
.
show
());
features
.
init
(
this
.
crossframe
);
this
.
crossframe
.
on
(
'
openSidebar'
,
()
=>
this
.
open
());
this
.
crossframe
.
on
(
'
closeSidebar'
,
()
=>
this
.
clos
e
());
this
.
crossframe
.
on
(
'
showSidebar'
,
()
=>
this
.
show
());
this
.
crossframe
.
on
(
'
hideSidebar'
,
()
=>
this
.
hid
e
());
// Re-publish the crossframe event so that anything extending Delegator
// can subscribe to it (without need for crossframe)
this
.
crossframe
.
on
(
'
open
Notebook'
,
groupId
=>
{
this
.
clos
e
();
this
.
publish
(
'
open
Notebook'
,
[
groupId
]);
this
.
crossframe
.
on
(
'
show
Notebook'
,
groupId
=>
{
this
.
hid
e
();
this
.
publish
(
'
show
Notebook'
,
[
groupId
]);
});
this
.
crossframe
.
on
(
'
clos
eNotebook'
,
()
=>
{
this
.
open
();
this
.
publish
(
'
clos
eNotebook'
);
this
.
crossframe
.
on
(
'
hid
eNotebook'
,
()
=>
{
this
.
show
();
this
.
publish
(
'
hid
eNotebook'
);
});
const
eventHandlers
=
[
...
...
@@ -345,9 +345,9 @@ export default class Sidebar extends Guest {
_onResize
()
{
if
(
this
.
toolbar
.
sidebarOpen
===
true
)
{
if
(
window
.
innerWidth
<
MIN_RESIZE
)
{
this
.
clos
e
();
this
.
hid
e
();
}
else
{
this
.
open
();
this
.
show
();
}
}
}
...
...
@@ -384,9 +384,9 @@ export default class Sidebar extends Guest {
this
.
_gestureState
.
final
===
null
||
this
.
_gestureState
.
final
<=
-
MIN_RESIZE
)
{
this
.
open
();
this
.
show
();
}
else
{
this
.
clos
e
();
this
.
hid
e
();
}
this
.
_resetGestureState
();
break
;
...
...
@@ -405,7 +405,7 @@ export default class Sidebar extends Guest {
}
}
open
()
{
show
()
{
this
.
crossframe
.
call
(
'sidebarOpened'
);
this
.
publish
(
'sidebarOpened'
);
...
...
@@ -424,7 +424,7 @@ export default class Sidebar extends Guest {
this
.
_notifyOfLayoutChange
(
true
);
}
clos
e
()
{
hid
e
()
{
if
(
this
.
frame
)
{
this
.
frame
.
style
.
marginLeft
=
''
;
this
.
frame
.
classList
.
add
(
'annotator-collapsed'
);
...
...
src/annotator/test/guest-test.js
View file @
63e2da2f
...
...
@@ -450,7 +450,7 @@ describe('Guest', () => {
it
(
'hides sidebar when the user taps or clicks in the page'
,
()
=>
{
for
(
let
event
of
[
'click'
,
'touchstart'
])
{
rootElement
.
dispatchEvent
(
new
Event
(
event
));
assert
.
calledWith
(
guest
.
plugins
.
CrossFrame
.
call
,
'
clos
eSidebar'
);
assert
.
calledWith
(
guest
.
plugins
.
CrossFrame
.
call
,
'
hid
eSidebar'
);
}
});
...
...
@@ -563,7 +563,7 @@ describe('Guest', () => {
FakeAdder
.
instance
.
options
.
onShowAnnotations
([{
$tag
:
'ann1'
}]);
assert
.
calledWith
(
fakeCrossFrame
.
call
,
'
open
Sidebar'
);
assert
.
calledWith
(
fakeCrossFrame
.
call
,
'
show
Sidebar'
);
assert
.
calledWith
(
fakeCrossFrame
.
call
,
'showAnnotations'
,
[
'ann1'
]);
}));
...
...
src/annotator/test/notebook-test.js
View file @
63e2da2f
...
...
@@ -27,20 +27,20 @@ describe('Notebook', () => {
const
notebook
=
createNotebook
();
assert
.
isNull
(
notebook
.
container
);
notebook
.
open
();
notebook
.
show
();
assert
.
isNotNull
(
notebook
.
container
);
});
it
(
'is not created if `hide` is called before notebook is first shown'
,
()
=>
{
const
notebook
=
createNotebook
();
notebook
.
clos
e
();
notebook
.
hid
e
();
assert
.
isNull
(
notebook
.
container
);
});
it
(
'displays when opened'
,
()
=>
{
const
notebook
=
createNotebook
();
notebook
.
open
();
notebook
.
show
();
assert
.
equal
(
notebook
.
container
.
style
.
display
,
''
);
assert
.
isTrue
(
notebook
.
container
.
classList
.
contains
(
'is-open'
));
...
...
@@ -49,8 +49,8 @@ describe('Notebook', () => {
it
(
'hides when closed'
,
()
=>
{
const
notebook
=
createNotebook
();
notebook
.
open
();
notebook
.
clos
e
();
notebook
.
show
();
notebook
.
hid
e
();
assert
.
equal
(
notebook
.
container
.
style
.
display
,
'none'
);
assert
.
isFalse
(
notebook
.
container
.
classList
.
contains
(
'is-open'
));
...
...
@@ -58,12 +58,12 @@ describe('Notebook', () => {
});
describe
(
'creating the notebook iframe'
,
()
=>
{
it
(
'creates the iframe when the notebook is
opened
for the first time'
,
()
=>
{
it
(
'creates the iframe when the notebook is
shown
for the first time'
,
()
=>
{
const
notebook
=
createNotebook
();
assert
.
isNull
(
notebook
.
frame
);
notebook
.
open
();
notebook
.
show
();
assert
.
isTrue
(
notebook
.
frame
instanceof
Element
);
});
...
...
@@ -73,7 +73,7 @@ describe('Notebook', () => {
notebookAppUrl
:
'http://www.example.com/foo/bar'
,
});
notebook
.
open
();
notebook
.
show
();
// The rest of the config gets added as a hash to the end of the src,
// so split that off and look at the string before it
...
...
@@ -83,16 +83,16 @@ describe('Notebook', () => {
);
});
it
(
'does not create a new iframe if
opened
again with same group ID'
,
()
=>
{
it
(
'does not create a new iframe if
shown
again with same group ID'
,
()
=>
{
const
notebook
=
createNotebook
();
notebook
.
_groupId
=
'mygroup'
;
// The first
open
ing will create a new iFrame
notebook
.
publish
(
'
open
Notebook'
,
[
'myGroup'
]);
// The first
show
ing will create a new iFrame
notebook
.
publish
(
'
show
Notebook'
,
[
'myGroup'
]);
const
removeSpy
=
sinon
.
spy
(
notebook
.
frame
,
'remove'
);
//
Open
it again — the group hasn't changed so the iframe won't be
//
Show
it again — the group hasn't changed so the iframe won't be
// replaced
notebook
.
publish
(
'
open
Notebook'
,
[
'myGroup'
]);
notebook
.
publish
(
'
show
Notebook'
,
[
'myGroup'
]);
assert
.
notCalled
(
removeSpy
);
});
...
...
@@ -101,41 +101,41 @@ describe('Notebook', () => {
const
notebook
=
createNotebook
();
notebook
.
_groupId
=
'mygroup'
;
// First
open
: creates an iframe
notebook
.
publish
(
'
open
Notebook'
,
[
'myGroup'
]);
// First
show
: creates an iframe
notebook
.
publish
(
'
show
Notebook'
,
[
'myGroup'
]);
const
removeSpy
=
sinon
.
spy
(
notebook
.
frame
,
'remove'
);
//
Open
again with another group
notebook
.
publish
(
'
open
Notebook'
,
[
'anotherGroup'
]);
//
Show
again with another group
notebook
.
publish
(
'
show
Notebook'
,
[
'anotherGroup'
]);
//
Open
again, which will remove the first iframe and create a new one
notebook
.
open
();
//
Show
again, which will remove the first iframe and create a new one
notebook
.
show
();
assert
.
calledOnce
(
removeSpy
);
});
});
describe
(
'responding to events'
,
()
=>
{
it
(
'
opens on `open
Notebook`'
,
()
=>
{
it
(
'
shows on `show
Notebook`'
,
()
=>
{
const
notebook
=
createNotebook
();
notebook
.
publish
(
'
open
Notebook'
);
notebook
.
publish
(
'
show
Notebook'
);
assert
.
equal
(
notebook
.
container
.
style
.
display
,
''
);
});
it
(
'
closes on `clos
eNotebook`'
,
()
=>
{
it
(
'
hides on `hid
eNotebook`'
,
()
=>
{
const
notebook
=
createNotebook
();
notebook
.
open
();
notebook
.
publish
(
'
clos
eNotebook'
);
notebook
.
show
();
notebook
.
publish
(
'
hid
eNotebook'
);
assert
.
equal
(
notebook
.
container
.
style
.
display
,
'none'
);
});
it
(
'
clos
es on "sidebarOpened"'
,
()
=>
{
it
(
'
hid
es on "sidebarOpened"'
,
()
=>
{
const
notebook
=
createNotebook
();
notebook
.
open
();
notebook
.
show
();
notebook
.
publish
(
'sidebarOpened'
);
assert
.
equal
(
notebook
.
container
.
style
.
display
,
'none'
);
...
...
@@ -148,7 +148,7 @@ describe('Notebook', () => {
const
hostDocument
=
notebook
.
element
;
// Make sure the frame is created
notebook
.
open
();
notebook
.
show
();
assert
.
isNotNull
(
hostDocument
.
querySelector
(
'hypothesis-notebook'
));
notebook
.
destroy
();
...
...
src/annotator/test/sidebar-test.js
View file @
63e2da2f
...
...
@@ -190,16 +190,16 @@ describe('Sidebar', () => {
});
describe
(
'toolbar buttons'
,
()
=>
{
it
(
'
opens and clos
es sidebar when toolbar button is clicked'
,
()
=>
{
it
(
'
shows or hid
es sidebar when toolbar button is clicked'
,
()
=>
{
const
sidebar
=
createSidebar
();
sinon
.
stub
(
sidebar
,
'
open
'
);
sinon
.
stub
(
sidebar
,
'
clos
e'
);
sinon
.
stub
(
sidebar
,
'
show
'
);
sinon
.
stub
(
sidebar
,
'
hid
e'
);
FakeToolbarController
.
args
[
0
][
1
].
setSidebarOpen
(
true
);
assert
.
called
(
sidebar
.
open
);
assert
.
called
(
sidebar
.
show
);
FakeToolbarController
.
args
[
0
][
1
].
setSidebarOpen
(
false
);
assert
.
called
(
sidebar
.
clos
e
);
assert
.
called
(
sidebar
.
hid
e
);
});
it
(
'shows or hides highlights when toolbar button is clicked'
,
()
=>
{
...
...
@@ -235,45 +235,45 @@ describe('Sidebar', () => {
return
result
;
};
describe
(
'on "
open
" event'
,
()
=>
it
(
'
open
s the frame'
,
()
=>
{
const
target
=
sandbox
.
stub
(
Sidebar
.
prototype
,
'
open
'
);
describe
(
'on "
show
" event'
,
()
=>
it
(
'
show
s the frame'
,
()
=>
{
const
target
=
sandbox
.
stub
(
Sidebar
.
prototype
,
'
show
'
);
createSidebar
();
emitEvent
(
'
open
Sidebar'
);
emitEvent
(
'
show
Sidebar'
);
assert
.
called
(
target
);
}));
describe
(
'on "
clos
e" event'
,
()
=>
it
(
'
clos
es the frame'
,
()
=>
{
const
target
=
sandbox
.
stub
(
Sidebar
.
prototype
,
'
clos
e'
);
describe
(
'on "
hid
e" event'
,
()
=>
it
(
'
hid
es the frame'
,
()
=>
{
const
target
=
sandbox
.
stub
(
Sidebar
.
prototype
,
'
hid
e'
);
createSidebar
();
emitEvent
(
'
clos
eSidebar'
);
emitEvent
(
'
hid
eSidebar'
);
assert
.
called
(
target
);
}));
describe
(
'on "
open
Notebook" event'
,
()
=>
{
describe
(
'on "
show
Notebook" event'
,
()
=>
{
it
(
'hides itself and republishes the event'
,
()
=>
{
const
sidebar
=
createSidebar
();
sinon
.
stub
(
sidebar
,
'publish'
);
sinon
.
stub
(
sidebar
,
'
clos
e'
);
emitEvent
(
'
open
Notebook'
,
'mygroup'
);
sinon
.
stub
(
sidebar
,
'
hid
e'
);
emitEvent
(
'
show
Notebook'
,
'mygroup'
);
assert
.
calledWith
(
sidebar
.
publish
,
'
open
Notebook'
,
'
show
Notebook'
,
sinon
.
match
([
'mygroup'
])
);
assert
.
calledOnce
(
sidebar
.
clos
e
);
assert
.
calledOnce
(
sidebar
.
hid
e
);
});
});
describe
(
'on "
clos
eNotebook" event'
,
()
=>
{
it
(
'
open
s itself and republishes the event'
,
()
=>
{
describe
(
'on "
hid
eNotebook" event'
,
()
=>
{
it
(
'
show
s itself and republishes the event'
,
()
=>
{
const
sidebar
=
createSidebar
();
sinon
.
stub
(
sidebar
,
'publish'
);
sinon
.
stub
(
sidebar
,
'
open
'
);
emitEvent
(
'
clos
eNotebook'
);
assert
.
calledWith
(
sidebar
.
publish
,
'
clos
eNotebook'
);
assert
.
calledOnce
(
sidebar
.
open
);
sinon
.
stub
(
sidebar
,
'
show
'
);
emitEvent
(
'
hid
eNotebook'
);
assert
.
calledWith
(
sidebar
.
publish
,
'
hid
eNotebook'
);
assert
.
calledOnce
(
sidebar
.
show
);
});
});
...
...
@@ -421,18 +421,18 @@ describe('Sidebar', () => {
assert
.
equal
(
sidebar
.
frame
.
style
.
pointerEvents
,
''
);
});
it
(
'calls `
open
` if the widget is fully visible'
,
()
=>
{
it
(
'calls `
show
` if the widget is fully visible'
,
()
=>
{
sidebar
.
_gestureState
=
{
final
:
-
500
};
const
open
=
sandbox
.
stub
(
sidebar
,
'open
'
);
const
show
=
sandbox
.
stub
(
sidebar
,
'show
'
);
sidebar
.
_onPan
({
type
:
'panend'
});
assert
.
calledOnce
(
open
);
assert
.
calledOnce
(
show
);
});
it
(
'calls `
clos
e` if the widget is not fully visible'
,
()
=>
{
it
(
'calls `
hid
e` if the widget is not fully visible'
,
()
=>
{
sidebar
.
_gestureState
=
{
final
:
-
100
};
const
close
=
sandbox
.
stub
(
sidebar
,
'clos
e'
);
const
hide
=
sandbox
.
stub
(
sidebar
,
'hid
e'
);
sidebar
.
_onPan
({
type
:
'panend'
});
assert
.
calledOnce
(
clos
e
);
assert
.
calledOnce
(
hid
e
);
});
});
...
...
@@ -453,43 +453,43 @@ describe('Sidebar', () => {
const
sidebar
=
createSidebar
({
annotations
:
'ann-id'
,
});
const
open
=
sandbox
.
stub
(
sidebar
,
'open
'
);
const
show
=
sandbox
.
stub
(
sidebar
,
'show
'
);
sidebar
.
publish
(
'panelReady'
);
assert
.
calledOnce
(
open
);
assert
.
calledOnce
(
show
);
});
it
(
'opens the sidebar when a direct-linked group is present.'
,
()
=>
{
const
sidebar
=
createSidebar
({
group
:
'group-id'
,
});
const
open
=
sandbox
.
stub
(
sidebar
,
'open
'
);
const
show
=
sandbox
.
stub
(
sidebar
,
'show
'
);
sidebar
.
publish
(
'panelReady'
);
assert
.
calledOnce
(
open
);
assert
.
calledOnce
(
show
);
});
it
(
'opens the sidebar when a direct-linked query is present.'
,
()
=>
{
const
sidebar
=
createSidebar
({
query
:
'tag:foo'
,
});
const
open
=
sandbox
.
stub
(
sidebar
,
'open
'
);
const
show
=
sandbox
.
stub
(
sidebar
,
'show
'
);
sidebar
.
publish
(
'panelReady'
);
assert
.
calledOnce
(
open
);
assert
.
calledOnce
(
show
);
});
it
(
'opens the sidebar when openSidebar is set to true.'
,
()
=>
{
const
sidebar
=
createSidebar
({
openSidebar
:
true
,
});
const
open
=
sandbox
.
stub
(
sidebar
,
'open
'
);
const
show
=
sandbox
.
stub
(
sidebar
,
'show
'
);
sidebar
.
publish
(
'panelReady'
);
assert
.
calledOnce
(
open
);
assert
.
calledOnce
(
show
);
});
it
(
'does not
open
the sidebar if not configured to.'
,
()
=>
{
it
(
'does not
show
the sidebar if not configured to.'
,
()
=>
{
const
sidebar
=
createSidebar
();
const
open
=
sandbox
.
stub
(
sidebar
,
'open
'
);
const
show
=
sandbox
.
stub
(
sidebar
,
'show
'
);
sidebar
.
publish
(
'panelReady'
);
assert
.
notCalled
(
open
);
assert
.
notCalled
(
show
);
});
});
...
...
@@ -513,24 +513,24 @@ describe('Sidebar', () => {
});
});
describe
(
'#
open
'
,
()
=>
{
describe
(
'#
show
'
,
()
=>
{
it
(
'shows highlights if "showHighlights" is set to "whenSidebarOpen"'
,
()
=>
{
const
sidebar
=
createSidebar
({
showHighlights
:
'whenSidebarOpen'
});
assert
.
isFalse
(
sidebar
.
visibleHighlights
);
sidebar
.
open
();
sidebar
.
show
();
assert
.
isTrue
(
sidebar
.
visibleHighlights
);
});
it
(
'does not show highlights otherwise'
,
()
=>
{
const
sidebar
=
createSidebar
({
showHighlights
:
'never'
});
assert
.
isFalse
(
sidebar
.
visibleHighlights
);
sidebar
.
open
();
sidebar
.
show
();
assert
.
isFalse
(
sidebar
.
visibleHighlights
);
});
it
(
'updates the `sidebarOpen` property of the toolbar'
,
()
=>
{
const
sidebar
=
createSidebar
();
sidebar
.
open
();
sidebar
.
show
();
assert
.
equal
(
fakeToolbar
.
sidebarOpen
,
true
);
});
});
...
...
@@ -539,8 +539,8 @@ describe('Sidebar', () => {
it
(
'hides highlights if "showHighlights" is set to "whenSidebarOpen"'
,
()
=>
{
const
sidebar
=
createSidebar
({
showHighlights
:
'whenSidebarOpen'
});
sidebar
.
open
();
sidebar
.
clos
e
();
sidebar
.
show
();
sidebar
.
hid
e
();
assert
.
isFalse
(
sidebar
.
visibleHighlights
);
});
...
...
@@ -548,8 +548,8 @@ describe('Sidebar', () => {
it
(
'updates the `sidebarOpen` property of the toolbar'
,
()
=>
{
const
sidebar
=
createSidebar
();
sidebar
.
open
();
sidebar
.
clos
e
();
sidebar
.
show
();
sidebar
.
hid
e
();
assert
.
equal
(
fakeToolbar
.
sidebarOpen
,
false
);
});
...
...
@@ -582,21 +582,21 @@ describe('Sidebar', () => {
assert
.
equal
(
fakeToolbar
.
sidebarOpen
,
false
);
});
it
(
'invokes the "
open
" method when window is resized'
,
()
=>
{
// Calling the '
open
' methods adjust the marginLeft at different screen sizes
it
(
'invokes the "
show
" method when window is resized'
,
()
=>
{
// Calling the '
show
' methods adjust the marginLeft at different screen sizes
const
sidebar
=
createSidebar
({
openSidebar
:
true
});
sidebar
.
publish
(
'panelReady'
);
sinon
.
stub
(
sidebar
,
'
open
'
);
sinon
.
stub
(
sidebar
,
'
show
'
);
// Make the window very small
window
.
innerWidth
=
MIN_RESIZE
;
window
.
dispatchEvent
(
new
Event
(
'resize'
));
assert
.
calledOnce
(
sidebar
.
open
);
assert
.
calledOnce
(
sidebar
.
show
);
// Make the window very large
window
.
innerWidth
=
MIN_RESIZE
*
10
;
window
.
dispatchEvent
(
new
Event
(
'resize'
));
assert
.
calledTwice
(
sidebar
.
open
);
assert
.
calledTwice
(
sidebar
.
show
);
});
});
...
...
@@ -674,7 +674,7 @@ describe('Sidebar', () => {
it
(
'notifies when sidebar changes expanded state'
,
()
=>
{
sinon
.
stub
(
sidebar
,
'publish'
);
sidebar
.
open
();
sidebar
.
show
();
assert
.
calledOnce
(
layoutChangeHandlerSpy
);
assert
.
calledWith
(
sidebar
.
publish
,
...
...
@@ -687,7 +687,7 @@ describe('Sidebar', () => {
expanded
:
true
,
});
sidebar
.
clos
e
();
sidebar
.
hid
e
();
assert
.
calledTwice
(
layoutChangeHandlerSpy
);
assert
.
calledThrice
(
sidebar
.
publish
);
assertLayoutValues
(
layoutChangeHandlerSpy
.
lastCall
.
args
[
0
],
{
...
...
@@ -745,14 +745,14 @@ describe('Sidebar', () => {
});
it
(
'notifies when sidebar changes expanded state'
,
()
=>
{
sidebar
.
open
();
sidebar
.
show
();
assert
.
calledOnce
(
layoutChangeHandlerSpy
);
assertLayoutValues
(
layoutChangeHandlerSpy
.
lastCall
.
args
[
0
],
{
expanded
:
true
,
width
:
DEFAULT_WIDTH
,
});
sidebar
.
clos
e
();
sidebar
.
hid
e
();
assert
.
calledTwice
(
layoutChangeHandlerSpy
);
assertLayoutValues
(
layoutChangeHandlerSpy
.
lastCall
.
args
[
0
],
{
expanded
:
false
,
...
...
src/sidebar/components/UserMenu.js
View file @
63e2da2f
...
...
@@ -54,7 +54,7 @@ function UserMenu({ auth, bridge, onLogout, serviceUrl, settings }) {
!
isThirdParty
||
serviceSupports
(
'onLogoutRequestProvided'
);
const
onSelectNotebook
=
()
=>
{
bridge
.
call
(
'
open
Notebook'
,
store
.
focusedGroupId
());
bridge
.
call
(
'
show
Notebook'
,
store
.
focusedGroupId
());
};
const
onProfileSelected
=
()
=>
...
...
src/sidebar/components/test/UserMenu-test.js
View file @
63e2da2f
...
...
@@ -204,7 +204,7 @@ describe('UserMenu', () => {
const
openNotebookItem
=
findMenuItem
(
wrapper
,
'Open notebook'
);
openNotebookItem
.
props
().
onClick
();
assert
.
calledOnce
(
fakeBridge
.
call
);
assert
.
calledWith
(
fakeBridge
.
call
,
'
open
Notebook'
,
'mygroup'
);
assert
.
calledWith
(
fakeBridge
.
call
,
'
show
Notebook'
,
'mygroup'
);
});
});
...
...
src/sidebar/services/frame-sync.js
View file @
63e2da2f
...
...
@@ -114,7 +114,7 @@ export default function FrameSync(annotationsService, bridge, store) {
// and delete the (unsaved) annotation so it gets un-selected in the
// target document
if
(
!
store
.
isLoggedIn
())
{
bridge
.
call
(
'
open
Sidebar'
);
bridge
.
call
(
'
show
Sidebar'
);
store
.
openSidebarPanel
(
'loginPrompt'
);
bridge
.
call
(
'deleteAnnotation'
,
formatAnnot
(
annot
));
return
;
...
...
@@ -167,11 +167,11 @@ export default function FrameSync(annotationsService, bridge, store) {
});
// These invoke the matching methods by name on the Guests
bridge
.
on
(
'
open
Sidebar'
,
function
()
{
bridge
.
call
(
'
open
Sidebar'
);
bridge
.
on
(
'
show
Sidebar'
,
function
()
{
bridge
.
call
(
'
show
Sidebar'
);
});
bridge
.
on
(
'
clos
eSidebar'
,
function
()
{
bridge
.
call
(
'
clos
eSidebar'
);
bridge
.
on
(
'
hid
eSidebar'
,
function
()
{
bridge
.
call
(
'
hid
eSidebar'
);
});
bridge
.
on
(
'setVisibleHighlights'
,
function
(
state
)
{
bridge
.
call
(
'setVisibleHighlights'
,
state
);
...
...
src/sidebar/services/test/frame-sync-test.js
View file @
63e2da2f
...
...
@@ -243,7 +243,7 @@ describe('sidebar/services/frame-sync', function () {
const
ann
=
{
target
:
[]
};
fakeBridge
.
emit
(
'beforeCreateAnnotation'
,
{
tag
:
't1'
,
msg
:
ann
});
assert
.
calledWith
(
fakeBridge
.
call
,
'
open
Sidebar'
);
assert
.
calledWith
(
fakeBridge
.
call
,
'
show
Sidebar'
);
});
it
(
'should open the login prompt panel'
,
()
=>
{
...
...
@@ -369,16 +369,16 @@ describe('sidebar/services/frame-sync', function () {
});
describe
(
'on a relayed bridge call'
,
function
()
{
it
(
'calls "
open
Sidebar"'
,
function
()
{
fakeBridge
.
emit
(
'
open
Sidebar'
);
it
(
'calls "
show
Sidebar"'
,
function
()
{
fakeBridge
.
emit
(
'
show
Sidebar'
);
assert
.
calledWith
(
fakeBridge
.
call
,
'
open
Sidebar'
);
assert
.
calledWith
(
fakeBridge
.
call
,
'
show
Sidebar'
);
});
it
(
'calls "
clos
eSidebar"'
,
function
()
{
fakeBridge
.
emit
(
'
clos
eSidebar'
);
it
(
'calls "
hid
eSidebar"'
,
function
()
{
fakeBridge
.
emit
(
'
hid
eSidebar'
);
assert
.
calledWith
(
fakeBridge
.
call
,
'
clos
eSidebar'
);
assert
.
calledWith
(
fakeBridge
.
call
,
'
hid
eSidebar'
);
});
it
(
'calls "setVisibleHighlights"'
,
function
()
{
...
...
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