Commit 85f6023f authored by Eduardo Sanz García's avatar Eduardo Sanz García Committed by Eduardo

Rename methods hide/show to open/close

Because I am planning to introduce another method to hide the controls,
I renamed the hide/show methods in the sidebar and notebook components
to open/close. I also feel it describes better the visual outcome.

For consistency, I renamed the show/hideNotebook to open/closeNotebook.
parent ed2c4307
...@@ -203,14 +203,14 @@ export default class Guest extends Delegator { ...@@ -203,14 +203,14 @@ export default class Guest extends Delegator {
// Hide the sidebar in response to a document click or tap, so it doesn't obscure // Hide the sidebar in response to a document click or tap, so it doesn't obscure
// the document content. // the document content.
const maybeHideSidebar = event => { const maybeCloseSidebar = event => {
if (!this.closeSidebarOnDocumentClick || this.isEventInAnnotator(event)) { if (!this.closeSidebarOnDocumentClick || this.isEventInAnnotator(event)) {
// Don't hide the sidebar if event occurred inside Hypothesis UI, or // 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 user is making a selection, or the behavior was disabled because
// the sidebar doesn't overlap the content. // the sidebar doesn't overlap the content.
return; return;
} }
this.crossframe?.call('hideSidebar'); this.crossframe?.call('closeSidebar');
}; };
addListener('click', event => { addListener('click', event => {
...@@ -219,7 +219,7 @@ export default class Guest extends Delegator { ...@@ -219,7 +219,7 @@ export default class Guest extends Delegator {
const toggle = event.metaKey || event.ctrlKey; const toggle = event.metaKey || event.ctrlKey;
this.selectAnnotations(annotations, toggle); this.selectAnnotations(annotations, toggle);
} else { } else {
maybeHideSidebar(event); maybeCloseSidebar(event);
} }
}); });
...@@ -227,7 +227,7 @@ export default class Guest extends Delegator { ...@@ -227,7 +227,7 @@ export default class Guest extends Delegator {
// on touch-input devices, not all elements will generate a "click" event. // on touch-input devices, not all elements will generate a "click" event.
addListener('touchstart', event => { addListener('touchstart', event => {
if (!annotationsAt(event.target).length) { if (!annotationsAt(event.target).length) {
maybeHideSidebar(event); maybeCloseSidebar(event);
} }
}); });
...@@ -590,7 +590,7 @@ export default class Guest extends Delegator { ...@@ -590,7 +590,7 @@ export default class Guest extends Delegator {
targets.then(() => this.anchor(/** @type {AnnotationData} */ (annotation))); targets.then(() => this.anchor(/** @type {AnnotationData} */ (annotation)));
if (!annotation.$highlight) { if (!annotation.$highlight) {
this.crossframe?.call('showSidebar'); this.crossframe?.call('openSidebar');
} }
return annotation; return annotation;
} }
...@@ -614,7 +614,7 @@ export default class Guest extends Delegator { ...@@ -614,7 +614,7 @@ export default class Guest extends Delegator {
showAnnotations(annotations) { showAnnotations(annotations) {
const tags = annotations.map(a => a.$tag); const tags = annotations.map(a => a.$tag);
this.crossframe?.call('showAnnotations', tags); this.crossframe?.call('showAnnotations', tags);
this.crossframe?.call('showSidebar'); this.crossframe?.call('openSidebar');
} }
/** /**
......
import Delegator from './delegator'; import Delegator from './delegator';
import { createSidebarConfig } from './config/sidebar'; import { createSidebarConfig } from './config/sidebar';
import { createShadowRoot } from './util/shadow-root'; import { createShadowRoot } from './util/shadow-root';
import { render } from 'preact';
/** /**
* Create the iframe that will load the notebook application. * Create the iframe that will load the notebook application.
...@@ -51,13 +52,13 @@ export default class Notebook extends Delegator { ...@@ -51,13 +52,13 @@ export default class Notebook extends Delegator {
*/ */
this.container = null; this.container = null;
this.subscribe('showNotebook', groupId => { this.subscribe('openNotebook', groupId => {
this._groupId = groupId; this._groupId = groupId;
this.show(); this.open();
}); });
this.subscribe('hideNotebook', () => this.hide()); this.subscribe('closeNotebook', () => this.close());
// If the sidebar has opened, get out of the way // If the sidebar has opened, get out of the way
this.subscribe('sidebarOpened', () => this.hide()); this.subscribe('sidebarOpened', () => this.close());
} }
_update() { _update() {
...@@ -76,14 +77,14 @@ export default class Notebook extends Delegator { ...@@ -76,14 +77,14 @@ export default class Notebook extends Delegator {
} }
} }
show() { open() {
const container = this._initContainer(); const container = this._initContainer();
this._update(); this._update();
container.classList.add('is-open'); container.classList.add('is-open');
container.style.display = ''; container.style.display = '';
} }
hide() { close() {
if (this.container) { if (this.container) {
this.container.classList.remove('is-open'); this.container.classList.remove('is-open');
this.container.style.display = 'none'; this.container.style.display = 'none';
......
...@@ -129,14 +129,14 @@ export default class Sidebar extends Guest { ...@@ -129,14 +129,14 @@ export default class Sidebar extends Guest {
config.query || config.query ||
config.group config.group
) { ) {
this.subscribe('panelReady', () => this.show()); this.subscribe('panelReady', () => this.open());
} }
// Set up the toolbar on the left edge of the sidebar. // Set up the toolbar on the left edge of the sidebar.
const toolbarContainer = document.createElement('div'); const toolbarContainer = document.createElement('div');
this.toolbar = new ToolbarController(toolbarContainer, { this.toolbar = new ToolbarController(toolbarContainer, {
createAnnotation: () => this.createAnnotation(), createAnnotation: () => this.createAnnotation(),
setSidebarOpen: open => (open ? this.show() : this.hide()), setSidebarOpen: open => (open ? this.open() : this.close()),
setHighlightsVisible: show => this.setAllVisibleHighlights(show), setHighlightsVisible: show => this.setAllVisibleHighlights(show),
}); });
this.toolbar.useMinimalControls = config.theme === 'clean'; this.toolbar.useMinimalControls = config.theme === 'clean';
...@@ -161,7 +161,7 @@ export default class Sidebar extends Guest { ...@@ -161,7 +161,7 @@ export default class Sidebar extends Guest {
final: /** @type {number|null} */ (null), final: /** @type {number|null} */ (null),
}; };
this._setupGestures(); this._setupGestures();
this.hide(); this.close();
// Publisher-provided callback functions // Publisher-provided callback functions
const [serviceConfig] = config.services || []; const [serviceConfig] = config.services || [];
...@@ -207,21 +207,21 @@ export default class Sidebar extends Guest { ...@@ -207,21 +207,21 @@ export default class Sidebar extends Guest {
_setupSidebarEvents() { _setupSidebarEvents() {
annotationCounts(document.body, this.crossframe); annotationCounts(document.body, this.crossframe);
sidebarTrigger(document.body, () => this.show()); sidebarTrigger(document.body, () => this.open());
features.init(this.crossframe); features.init(this.crossframe);
this.crossframe.on('showSidebar', () => this.show()); this.crossframe.on('openSidebar', () => this.open());
this.crossframe.on('hideSidebar', () => this.hide()); this.crossframe.on('closeSidebar', () => this.close());
// Re-publish the crossframe event so that anything extending Delegator // Re-publish the crossframe event so that anything extending Delegator
// can subscribe to it (without need for crossframe) // can subscribe to it (without need for crossframe)
this.crossframe.on('showNotebook', groupId => { this.crossframe.on('openNotebook', groupId => {
this.hide(); this.close();
this.publish('showNotebook', [groupId]); this.publish('openNotebook', [groupId]);
}); });
this.crossframe.on('hideNotebook', () => { this.crossframe.on('closeNotebook', () => {
this.show(); this.open();
this.publish('hideNotebook'); this.publish('closeNotebook');
}); });
const eventHandlers = [ const eventHandlers = [
...@@ -347,9 +347,9 @@ export default class Sidebar extends Guest { ...@@ -347,9 +347,9 @@ export default class Sidebar extends Guest {
_onResize() { _onResize() {
if (this.toolbar.sidebarOpen === true) { if (this.toolbar.sidebarOpen === true) {
if (window.innerWidth < MIN_RESIZE) { if (window.innerWidth < MIN_RESIZE) {
this.hide(); this.close();
} else { } else {
this.show(); this.open();
} }
} }
} }
...@@ -386,9 +386,9 @@ export default class Sidebar extends Guest { ...@@ -386,9 +386,9 @@ export default class Sidebar extends Guest {
this._gestureState.final === null || this._gestureState.final === null ||
this._gestureState.final <= -MIN_RESIZE this._gestureState.final <= -MIN_RESIZE
) { ) {
this.show(); this.open();
} else { } else {
this.hide(); this.close();
} }
this._resetGestureState(); this._resetGestureState();
break; break;
...@@ -407,7 +407,7 @@ export default class Sidebar extends Guest { ...@@ -407,7 +407,7 @@ export default class Sidebar extends Guest {
} }
} }
show() { open() {
this.crossframe.call('sidebarOpened'); this.crossframe.call('sidebarOpened');
this.publish('sidebarOpened'); this.publish('sidebarOpened');
...@@ -426,7 +426,7 @@ export default class Sidebar extends Guest { ...@@ -426,7 +426,7 @@ export default class Sidebar extends Guest {
this._notifyOfLayoutChange(true); this._notifyOfLayoutChange(true);
} }
hide() { close() {
if (this.frame) { if (this.frame) {
this.frame.style.marginLeft = ''; this.frame.style.marginLeft = '';
this.frame.classList.add('annotator-collapsed'); this.frame.classList.add('annotator-collapsed');
......
...@@ -450,7 +450,7 @@ describe('Guest', () => { ...@@ -450,7 +450,7 @@ describe('Guest', () => {
it('hides sidebar when the user taps or clicks in the page', () => { it('hides sidebar when the user taps or clicks in the page', () => {
for (let event of ['click', 'touchstart']) { for (let event of ['click', 'touchstart']) {
rootElement.dispatchEvent(new Event(event)); rootElement.dispatchEvent(new Event(event));
assert.calledWith(guest.plugins.CrossFrame.call, 'hideSidebar'); assert.calledWith(guest.plugins.CrossFrame.call, 'closeSidebar');
} }
}); });
...@@ -563,7 +563,7 @@ describe('Guest', () => { ...@@ -563,7 +563,7 @@ describe('Guest', () => {
FakeAdder.instance.options.onShowAnnotations([{ $tag: 'ann1' }]); FakeAdder.instance.options.onShowAnnotations([{ $tag: 'ann1' }]);
assert.calledWith(fakeCrossFrame.call, 'showSidebar'); assert.calledWith(fakeCrossFrame.call, 'openSidebar');
assert.calledWith(fakeCrossFrame.call, 'showAnnotations', ['ann1']); assert.calledWith(fakeCrossFrame.call, 'showAnnotations', ['ann1']);
})); }));
......
...@@ -27,20 +27,20 @@ describe('Notebook', () => { ...@@ -27,20 +27,20 @@ describe('Notebook', () => {
const notebook = createNotebook(); const notebook = createNotebook();
assert.isNull(notebook.container); assert.isNull(notebook.container);
notebook.show(); notebook.open();
assert.isNotNull(notebook.container); assert.isNotNull(notebook.container);
}); });
it('is not created if `hide` is called before notebook is first shown', () => { it('is not created if `hide` is called before notebook is first shown', () => {
const notebook = createNotebook(); const notebook = createNotebook();
notebook.hide(); notebook.close();
assert.isNull(notebook.container); assert.isNull(notebook.container);
}); });
it('displays when opened', () => { it('displays when opened', () => {
const notebook = createNotebook(); const notebook = createNotebook();
notebook.show(); notebook.open();
assert.equal(notebook.container.style.display, ''); assert.equal(notebook.container.style.display, '');
assert.isTrue(notebook.container.classList.contains('is-open')); assert.isTrue(notebook.container.classList.contains('is-open'));
...@@ -49,8 +49,8 @@ describe('Notebook', () => { ...@@ -49,8 +49,8 @@ describe('Notebook', () => {
it('hides when closed', () => { it('hides when closed', () => {
const notebook = createNotebook(); const notebook = createNotebook();
notebook.show(); notebook.open();
notebook.hide(); notebook.close();
assert.equal(notebook.container.style.display, 'none'); assert.equal(notebook.container.style.display, 'none');
assert.isFalse(notebook.container.classList.contains('is-open')); assert.isFalse(notebook.container.classList.contains('is-open'));
...@@ -58,12 +58,12 @@ describe('Notebook', () => { ...@@ -58,12 +58,12 @@ describe('Notebook', () => {
}); });
describe('creating the notebook iframe', () => { describe('creating the notebook iframe', () => {
it('creates the iframe when the notebook is shown for the first time', () => { it('creates the iframe when the notebook is opened for the first time', () => {
const notebook = createNotebook(); const notebook = createNotebook();
assert.isNull(notebook.frame); assert.isNull(notebook.frame);
notebook.show(); notebook.open();
assert.isTrue(notebook.frame instanceof Element); assert.isTrue(notebook.frame instanceof Element);
}); });
...@@ -73,7 +73,7 @@ describe('Notebook', () => { ...@@ -73,7 +73,7 @@ describe('Notebook', () => {
notebookAppUrl: 'http://www.example.com/foo/bar', notebookAppUrl: 'http://www.example.com/foo/bar',
}); });
notebook.show(); notebook.open();
// The rest of the config gets added as a hash to the end of the src, // 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 // so split that off and look at the string before it
...@@ -83,16 +83,16 @@ describe('Notebook', () => { ...@@ -83,16 +83,16 @@ describe('Notebook', () => {
); );
}); });
it('does not create a new iframe if shown again with same group ID', () => { it('does not create a new iframe if opened again with same group ID', () => {
const notebook = createNotebook(); const notebook = createNotebook();
notebook._groupId = 'mygroup'; notebook._groupId = 'mygroup';
// The first showing will create a new iFrame // The first opening will create a new iFrame
notebook.publish('showNotebook', ['myGroup']); notebook.publish('openNotebook', ['myGroup']);
const removeSpy = sinon.spy(notebook.frame, 'remove'); const removeSpy = sinon.spy(notebook.frame, 'remove');
// Show it again — the group hasn't changed so the iframe won't be // Open it again — the group hasn't changed so the iframe won't be
// replaced // replaced
notebook.publish('showNotebook', ['myGroup']); notebook.publish('openNotebook', ['myGroup']);
assert.notCalled(removeSpy); assert.notCalled(removeSpy);
}); });
...@@ -101,41 +101,41 @@ describe('Notebook', () => { ...@@ -101,41 +101,41 @@ describe('Notebook', () => {
const notebook = createNotebook(); const notebook = createNotebook();
notebook._groupId = 'mygroup'; notebook._groupId = 'mygroup';
// First show: creates an iframe // First open: creates an iframe
notebook.publish('showNotebook', ['myGroup']); notebook.publish('openNotebook', ['myGroup']);
const removeSpy = sinon.spy(notebook.frame, 'remove'); const removeSpy = sinon.spy(notebook.frame, 'remove');
// Show again with another group // Open again with another group
notebook.publish('showNotebook', ['anotherGroup']); notebook.publish('openNotebook', ['anotherGroup']);
// Show again, which will remove the first iframe and create a new one // Open again, which will remove the first iframe and create a new one
notebook.show(); notebook.open();
assert.calledOnce(removeSpy); assert.calledOnce(removeSpy);
}); });
}); });
describe('responding to events', () => { describe('responding to events', () => {
it('shows on `showNotebook`', () => { it('opens on `openNotebook`', () => {
const notebook = createNotebook(); const notebook = createNotebook();
notebook.publish('showNotebook'); notebook.publish('openNotebook');
assert.equal(notebook.container.style.display, ''); assert.equal(notebook.container.style.display, '');
}); });
it('hides on `hideNotebook`', () => { it('closes on `closeNotebook`', () => {
const notebook = createNotebook(); const notebook = createNotebook();
notebook.show(); notebook.open();
notebook.publish('hideNotebook'); notebook.publish('closeNotebook');
assert.equal(notebook.container.style.display, 'none'); assert.equal(notebook.container.style.display, 'none');
}); });
it('hides on "sidebarOpened"', () => { it('closes on "sidebarOpened"', () => {
const notebook = createNotebook(); const notebook = createNotebook();
notebook.show(); notebook.open();
notebook.publish('sidebarOpened'); notebook.publish('sidebarOpened');
assert.equal(notebook.container.style.display, 'none'); assert.equal(notebook.container.style.display, 'none');
...@@ -148,7 +148,7 @@ describe('Notebook', () => { ...@@ -148,7 +148,7 @@ describe('Notebook', () => {
const hostDocument = notebook.element; const hostDocument = notebook.element;
// Make sure the frame is created // Make sure the frame is created
notebook.show(); notebook.open();
assert.isNotNull(hostDocument.querySelector('hypothesis-notebook')); assert.isNotNull(hostDocument.querySelector('hypothesis-notebook'));
notebook.destroy(); notebook.destroy();
......
...@@ -191,16 +191,16 @@ describe('Sidebar', () => { ...@@ -191,16 +191,16 @@ describe('Sidebar', () => {
}); });
describe('toolbar buttons', () => { describe('toolbar buttons', () => {
it('shows or hides sidebar when toolbar button is clicked', () => { it('opens and closes sidebar when toolbar button is clicked', () => {
const sidebar = createSidebar(); const sidebar = createSidebar();
sinon.stub(sidebar, 'show'); sinon.stub(sidebar, 'open');
sinon.stub(sidebar, 'hide'); sinon.stub(sidebar, 'close');
FakeToolbarController.args[0][1].setSidebarOpen(true); FakeToolbarController.args[0][1].setSidebarOpen(true);
assert.called(sidebar.show); assert.called(sidebar.open);
FakeToolbarController.args[0][1].setSidebarOpen(false); FakeToolbarController.args[0][1].setSidebarOpen(false);
assert.called(sidebar.hide); assert.called(sidebar.close);
}); });
it('shows or hides highlights when toolbar button is clicked', () => { it('shows or hides highlights when toolbar button is clicked', () => {
...@@ -236,45 +236,45 @@ describe('Sidebar', () => { ...@@ -236,45 +236,45 @@ describe('Sidebar', () => {
return result; return result;
}; };
describe('on "show" event', () => describe('on "open" event', () =>
it('shows the frame', () => { it('opens the frame', () => {
const target = sandbox.stub(Sidebar.prototype, 'show'); const target = sandbox.stub(Sidebar.prototype, 'open');
createSidebar(); createSidebar();
emitEvent('showSidebar'); emitEvent('openSidebar');
assert.called(target); assert.called(target);
})); }));
describe('on "hide" event', () => describe('on "close" event', () =>
it('hides the frame', () => { it('closes the frame', () => {
const target = sandbox.stub(Sidebar.prototype, 'hide'); const target = sandbox.stub(Sidebar.prototype, 'close');
createSidebar(); createSidebar();
emitEvent('hideSidebar'); emitEvent('closeSidebar');
assert.called(target); assert.called(target);
})); }));
describe('on "showNotebook" event', () => { describe('on "openNotebook" event', () => {
it('hides itself and republishes the event', () => { it('hides itself and republishes the event', () => {
const sidebar = createSidebar(); const sidebar = createSidebar();
sinon.stub(sidebar, 'publish'); sinon.stub(sidebar, 'publish');
sinon.stub(sidebar, 'hide'); sinon.stub(sidebar, 'close');
emitEvent('showNotebook', 'mygroup'); emitEvent('openNotebook', 'mygroup');
assert.calledWith( assert.calledWith(
sidebar.publish, sidebar.publish,
'showNotebook', 'openNotebook',
sinon.match(['mygroup']) sinon.match(['mygroup'])
); );
assert.calledOnce(sidebar.hide); assert.calledOnce(sidebar.close);
}); });
}); });
describe('on "hideNotebook" event', () => { describe('on "closeNotebook" event', () => {
it('shows itself and republishes the event', () => { it('opens itself and republishes the event', () => {
const sidebar = createSidebar(); const sidebar = createSidebar();
sinon.stub(sidebar, 'publish'); sinon.stub(sidebar, 'publish');
sinon.stub(sidebar, 'show'); sinon.stub(sidebar, 'open');
emitEvent('hideNotebook'); emitEvent('closeNotebook');
assert.calledWith(sidebar.publish, 'hideNotebook'); assert.calledWith(sidebar.publish, 'closeNotebook');
assert.calledOnce(sidebar.show); assert.calledOnce(sidebar.open);
}); });
}); });
...@@ -422,18 +422,18 @@ describe('Sidebar', () => { ...@@ -422,18 +422,18 @@ describe('Sidebar', () => {
assert.equal(sidebar.frame.style.pointerEvents, ''); assert.equal(sidebar.frame.style.pointerEvents, '');
}); });
it('calls `show` if the widget is fully visible', () => { it('calls `open` if the widget is fully visible', () => {
sidebar._gestureState = { final: -500 }; sidebar._gestureState = { final: -500 };
const show = sandbox.stub(sidebar, 'show'); const open = sandbox.stub(sidebar, 'open');
sidebar._onPan({ type: 'panend' }); sidebar._onPan({ type: 'panend' });
assert.calledOnce(show); assert.calledOnce(open);
}); });
it('calls `hide` if the widget is not fully visible', () => { it('calls `close` if the widget is not fully visible', () => {
sidebar._gestureState = { final: -100 }; sidebar._gestureState = { final: -100 };
const hide = sandbox.stub(sidebar, 'hide'); const close = sandbox.stub(sidebar, 'close');
sidebar._onPan({ type: 'panend' }); sidebar._onPan({ type: 'panend' });
assert.calledOnce(hide); assert.calledOnce(close);
}); });
}); });
...@@ -454,43 +454,43 @@ describe('Sidebar', () => { ...@@ -454,43 +454,43 @@ describe('Sidebar', () => {
const sidebar = createSidebar({ const sidebar = createSidebar({
annotations: 'ann-id', annotations: 'ann-id',
}); });
const show = sandbox.stub(sidebar, 'show'); const open = sandbox.stub(sidebar, 'open');
sidebar.publish('panelReady'); sidebar.publish('panelReady');
assert.calledOnce(show); assert.calledOnce(open);
}); });
it('opens the sidebar when a direct-linked group is present.', () => { it('opens the sidebar when a direct-linked group is present.', () => {
const sidebar = createSidebar({ const sidebar = createSidebar({
group: 'group-id', group: 'group-id',
}); });
const show = sandbox.stub(sidebar, 'show'); const open = sandbox.stub(sidebar, 'open');
sidebar.publish('panelReady'); sidebar.publish('panelReady');
assert.calledOnce(show); assert.calledOnce(open);
}); });
it('opens the sidebar when a direct-linked query is present.', () => { it('opens the sidebar when a direct-linked query is present.', () => {
const sidebar = createSidebar({ const sidebar = createSidebar({
query: 'tag:foo', query: 'tag:foo',
}); });
const show = sandbox.stub(sidebar, 'show'); const open = sandbox.stub(sidebar, 'open');
sidebar.publish('panelReady'); sidebar.publish('panelReady');
assert.calledOnce(show); assert.calledOnce(open);
}); });
it('opens the sidebar when openSidebar is set to true.', () => { it('opens the sidebar when openSidebar is set to true.', () => {
const sidebar = createSidebar({ const sidebar = createSidebar({
openSidebar: true, openSidebar: true,
}); });
const show = sandbox.stub(sidebar, 'show'); const open = sandbox.stub(sidebar, 'open');
sidebar.publish('panelReady'); sidebar.publish('panelReady');
assert.calledOnce(show); assert.calledOnce(open);
}); });
it('does not show the sidebar if not configured to.', () => { it('does not open the sidebar if not configured to.', () => {
const sidebar = createSidebar(); const sidebar = createSidebar();
const show = sandbox.stub(sidebar, 'show'); const open = sandbox.stub(sidebar, 'open');
sidebar.publish('panelReady'); sidebar.publish('panelReady');
assert.notCalled(show); assert.notCalled(open);
}); });
}); });
...@@ -514,24 +514,24 @@ describe('Sidebar', () => { ...@@ -514,24 +514,24 @@ describe('Sidebar', () => {
}); });
}); });
describe('#show', () => { describe('#open', () => {
it('shows highlights if "showHighlights" is set to "whenSidebarOpen"', () => { it('shows highlights if "showHighlights" is set to "whenSidebarOpen"', () => {
const sidebar = createSidebar({ showHighlights: 'whenSidebarOpen' }); const sidebar = createSidebar({ showHighlights: 'whenSidebarOpen' });
assert.isFalse(sidebar.visibleHighlights); assert.isFalse(sidebar.visibleHighlights);
sidebar.show(); sidebar.open();
assert.isTrue(sidebar.visibleHighlights); assert.isTrue(sidebar.visibleHighlights);
}); });
it('does not show highlights otherwise', () => { it('does not show highlights otherwise', () => {
const sidebar = createSidebar({ showHighlights: 'never' }); const sidebar = createSidebar({ showHighlights: 'never' });
assert.isFalse(sidebar.visibleHighlights); assert.isFalse(sidebar.visibleHighlights);
sidebar.show(); sidebar.open();
assert.isFalse(sidebar.visibleHighlights); assert.isFalse(sidebar.visibleHighlights);
}); });
it('updates the `sidebarOpen` property of the toolbar', () => { it('updates the `sidebarOpen` property of the toolbar', () => {
const sidebar = createSidebar(); const sidebar = createSidebar();
sidebar.show(); sidebar.open();
assert.equal(fakeToolbar.sidebarOpen, true); assert.equal(fakeToolbar.sidebarOpen, true);
}); });
}); });
...@@ -540,8 +540,8 @@ describe('Sidebar', () => { ...@@ -540,8 +540,8 @@ describe('Sidebar', () => {
it('hides highlights if "showHighlights" is set to "whenSidebarOpen"', () => { it('hides highlights if "showHighlights" is set to "whenSidebarOpen"', () => {
const sidebar = createSidebar({ showHighlights: 'whenSidebarOpen' }); const sidebar = createSidebar({ showHighlights: 'whenSidebarOpen' });
sidebar.show(); sidebar.open();
sidebar.hide(); sidebar.close();
assert.isFalse(sidebar.visibleHighlights); assert.isFalse(sidebar.visibleHighlights);
}); });
...@@ -549,8 +549,8 @@ describe('Sidebar', () => { ...@@ -549,8 +549,8 @@ describe('Sidebar', () => {
it('updates the `sidebarOpen` property of the toolbar', () => { it('updates the `sidebarOpen` property of the toolbar', () => {
const sidebar = createSidebar(); const sidebar = createSidebar();
sidebar.show(); sidebar.open();
sidebar.hide(); sidebar.close();
assert.equal(fakeToolbar.sidebarOpen, false); assert.equal(fakeToolbar.sidebarOpen, false);
}); });
...@@ -583,21 +583,21 @@ describe('Sidebar', () => { ...@@ -583,21 +583,21 @@ describe('Sidebar', () => {
assert.equal(fakeToolbar.sidebarOpen, false); assert.equal(fakeToolbar.sidebarOpen, false);
}); });
it('invokes the "show" method when window is resized', () => { it('invokes the "open" method when window is resized', () => {
// Calling the 'show' methods adjust the marginLeft at different screen sizes // Calling the 'open' methods adjust the marginLeft at different screen sizes
const sidebar = createSidebar({ openSidebar: true }); const sidebar = createSidebar({ openSidebar: true });
sidebar.publish('panelReady'); sidebar.publish('panelReady');
sinon.stub(sidebar, 'show'); sinon.stub(sidebar, 'open');
// Make the window very small // Make the window very small
window.innerWidth = MIN_RESIZE; window.innerWidth = MIN_RESIZE;
window.dispatchEvent(new Event('resize')); window.dispatchEvent(new Event('resize'));
assert.calledOnce(sidebar.show); assert.calledOnce(sidebar.open);
// Make the window very large // Make the window very large
window.innerWidth = MIN_RESIZE * 10; window.innerWidth = MIN_RESIZE * 10;
window.dispatchEvent(new Event('resize')); window.dispatchEvent(new Event('resize'));
assert.calledTwice(sidebar.show); assert.calledTwice(sidebar.open);
}); });
}); });
...@@ -675,7 +675,7 @@ describe('Sidebar', () => { ...@@ -675,7 +675,7 @@ describe('Sidebar', () => {
it('notifies when sidebar changes expanded state', () => { it('notifies when sidebar changes expanded state', () => {
sinon.stub(sidebar, 'publish'); sinon.stub(sidebar, 'publish');
sidebar.show(); sidebar.open();
assert.calledOnce(layoutChangeHandlerSpy); assert.calledOnce(layoutChangeHandlerSpy);
assert.calledWith( assert.calledWith(
sidebar.publish, sidebar.publish,
...@@ -688,7 +688,7 @@ describe('Sidebar', () => { ...@@ -688,7 +688,7 @@ describe('Sidebar', () => {
expanded: true, expanded: true,
}); });
sidebar.hide(); sidebar.close();
assert.calledTwice(layoutChangeHandlerSpy); assert.calledTwice(layoutChangeHandlerSpy);
assert.calledThrice(sidebar.publish); assert.calledThrice(sidebar.publish);
assertLayoutValues(layoutChangeHandlerSpy.lastCall.args[0], { assertLayoutValues(layoutChangeHandlerSpy.lastCall.args[0], {
...@@ -746,14 +746,14 @@ describe('Sidebar', () => { ...@@ -746,14 +746,14 @@ describe('Sidebar', () => {
}); });
it('notifies when sidebar changes expanded state', () => { it('notifies when sidebar changes expanded state', () => {
sidebar.show(); sidebar.open();
assert.calledOnce(layoutChangeHandlerSpy); assert.calledOnce(layoutChangeHandlerSpy);
assertLayoutValues(layoutChangeHandlerSpy.lastCall.args[0], { assertLayoutValues(layoutChangeHandlerSpy.lastCall.args[0], {
expanded: true, expanded: true,
width: DEFAULT_WIDTH, width: DEFAULT_WIDTH,
}); });
sidebar.hide(); sidebar.close();
assert.calledTwice(layoutChangeHandlerSpy); assert.calledTwice(layoutChangeHandlerSpy);
assertLayoutValues(layoutChangeHandlerSpy.lastCall.args[0], { assertLayoutValues(layoutChangeHandlerSpy.lastCall.args[0], {
expanded: false, expanded: false,
......
...@@ -54,7 +54,7 @@ function UserMenu({ auth, bridge, onLogout, serviceUrl, settings }) { ...@@ -54,7 +54,7 @@ function UserMenu({ auth, bridge, onLogout, serviceUrl, settings }) {
!isThirdParty || serviceSupports('onLogoutRequestProvided'); !isThirdParty || serviceSupports('onLogoutRequestProvided');
const onSelectNotebook = () => { const onSelectNotebook = () => {
bridge.call('showNotebook', store.focusedGroupId()); bridge.call('openNotebook', store.focusedGroupId());
}; };
const onProfileSelected = () => const onProfileSelected = () =>
......
...@@ -204,7 +204,7 @@ describe('UserMenu', () => { ...@@ -204,7 +204,7 @@ describe('UserMenu', () => {
const openNotebookItem = findMenuItem(wrapper, 'Open notebook'); const openNotebookItem = findMenuItem(wrapper, 'Open notebook');
openNotebookItem.props().onClick(); openNotebookItem.props().onClick();
assert.calledOnce(fakeBridge.call); assert.calledOnce(fakeBridge.call);
assert.calledWith(fakeBridge.call, 'showNotebook', 'mygroup'); assert.calledWith(fakeBridge.call, 'openNotebook', 'mygroup');
}); });
}); });
......
...@@ -114,7 +114,7 @@ export default function FrameSync(annotationsService, bridge, store) { ...@@ -114,7 +114,7 @@ export default function FrameSync(annotationsService, bridge, store) {
// and delete the (unsaved) annotation so it gets un-selected in the // and delete the (unsaved) annotation so it gets un-selected in the
// target document // target document
if (!store.isLoggedIn()) { if (!store.isLoggedIn()) {
bridge.call('showSidebar'); bridge.call('openSidebar');
store.openSidebarPanel('loginPrompt'); store.openSidebarPanel('loginPrompt');
bridge.call('deleteAnnotation', formatAnnot(annot)); bridge.call('deleteAnnotation', formatAnnot(annot));
return; return;
...@@ -167,11 +167,11 @@ export default function FrameSync(annotationsService, bridge, store) { ...@@ -167,11 +167,11 @@ export default function FrameSync(annotationsService, bridge, store) {
}); });
// These invoke the matching methods by name on the Guests // These invoke the matching methods by name on the Guests
bridge.on('showSidebar', function () { bridge.on('openSidebar', function () {
bridge.call('showSidebar'); bridge.call('openSidebar');
}); });
bridge.on('hideSidebar', function () { bridge.on('closeSidebar', function () {
bridge.call('hideSidebar'); bridge.call('closeSidebar');
}); });
bridge.on('setVisibleHighlights', function (state) { bridge.on('setVisibleHighlights', function (state) {
bridge.call('setVisibleHighlights', state); bridge.call('setVisibleHighlights', state);
......
...@@ -243,7 +243,7 @@ describe('sidebar/services/frame-sync', function () { ...@@ -243,7 +243,7 @@ describe('sidebar/services/frame-sync', function () {
const ann = { target: [] }; const ann = { target: [] };
fakeBridge.emit('beforeCreateAnnotation', { tag: 't1', msg: ann }); fakeBridge.emit('beforeCreateAnnotation', { tag: 't1', msg: ann });
assert.calledWith(fakeBridge.call, 'showSidebar'); assert.calledWith(fakeBridge.call, 'openSidebar');
}); });
it('should open the login prompt panel', () => { it('should open the login prompt panel', () => {
...@@ -369,16 +369,16 @@ describe('sidebar/services/frame-sync', function () { ...@@ -369,16 +369,16 @@ describe('sidebar/services/frame-sync', function () {
}); });
describe('on a relayed bridge call', function () { describe('on a relayed bridge call', function () {
it('calls "showSidebar"', function () { it('calls "openSidebar"', function () {
fakeBridge.emit('showSidebar'); fakeBridge.emit('openSidebar');
assert.calledWith(fakeBridge.call, 'showSidebar'); assert.calledWith(fakeBridge.call, 'openSidebar');
}); });
it('calls "hideSidebar"', function () { it('calls "closeSidebar"', function () {
fakeBridge.emit('hideSidebar'); fakeBridge.emit('closeSidebar');
assert.calledWith(fakeBridge.call, 'hideSidebar'); assert.calledWith(fakeBridge.call, 'closeSidebar');
}); });
it('calls "setVisibleHighlights"', function () { it('calls "setVisibleHighlights"', function () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment