Commit 63e2da2f authored by Eduardo's avatar Eduardo

Revert "Rename methods hide/show to open/close"

This reverts commit 85f6023f.
parent df326eef
...@@ -206,14 +206,14 @@ export default class Guest extends Delegator { ...@@ -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 // Hide the sidebar in response to a document click or tap, so it doesn't obscure
// the document content. // the document content.
const maybeCloseSidebar = event => { const maybeHideSidebar = 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('closeSidebar'); this.crossframe?.call('hideSidebar');
}; };
addListener('click', event => { addListener('click', event => {
...@@ -222,7 +222,7 @@ export default class Guest extends Delegator { ...@@ -222,7 +222,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 {
maybeCloseSidebar(event); maybeHideSidebar(event);
} }
}); });
...@@ -230,7 +230,7 @@ export default class Guest extends Delegator { ...@@ -230,7 +230,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) {
maybeCloseSidebar(event); maybeHideSidebar(event);
} }
}); });
...@@ -593,7 +593,7 @@ export default class Guest extends Delegator { ...@@ -593,7 +593,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('openSidebar'); this.crossframe?.call('showSidebar');
} }
return annotation; return annotation;
} }
...@@ -617,7 +617,7 @@ export default class Guest extends Delegator { ...@@ -617,7 +617,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('openSidebar'); this.crossframe?.call('showSidebar');
} }
/** /**
......
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.
...@@ -52,13 +51,13 @@ export default class Notebook extends Delegator { ...@@ -52,13 +51,13 @@ export default class Notebook extends Delegator {
*/ */
this.container = null; this.container = null;
this.subscribe('openNotebook', groupId => { this.subscribe('showNotebook', groupId => {
this._groupId = groupId; this._groupId = groupId;
this.open(); this.show();
}); });
this.subscribe('closeNotebook', () => this.close()); this.subscribe('hideNotebook', () => this.hide());
// If the sidebar has opened, get out of the way // If the sidebar has opened, get out of the way
this.subscribe('sidebarOpened', () => this.close()); this.subscribe('sidebarOpened', () => this.hide());
} }
_update() { _update() {
...@@ -77,14 +76,14 @@ export default class Notebook extends Delegator { ...@@ -77,14 +76,14 @@ export default class Notebook extends Delegator {
} }
} }
open() { show() {
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 = '';
} }
close() { hide() {
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';
......
...@@ -127,14 +127,14 @@ export default class Sidebar extends Guest { ...@@ -127,14 +127,14 @@ export default class Sidebar extends Guest {
config.query || config.query ||
config.group config.group
) { ) {
this.subscribe('panelReady', () => this.open()); this.subscribe('panelReady', () => this.show());
} }
// 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.open() : this.close()), setSidebarOpen: open => (open ? this.show() : this.hide()),
setHighlightsVisible: show => this.setAllVisibleHighlights(show), setHighlightsVisible: show => this.setAllVisibleHighlights(show),
}); });
this.toolbar.useMinimalControls = config.theme === 'clean'; this.toolbar.useMinimalControls = config.theme === 'clean';
...@@ -159,7 +159,7 @@ export default class Sidebar extends Guest { ...@@ -159,7 +159,7 @@ export default class Sidebar extends Guest {
final: /** @type {number|null} */ (null), final: /** @type {number|null} */ (null),
}; };
this._setupGestures(); this._setupGestures();
this.close(); this.hide();
// Publisher-provided callback functions // Publisher-provided callback functions
const [serviceConfig] = config.services || []; const [serviceConfig] = config.services || [];
...@@ -205,21 +205,21 @@ export default class Sidebar extends Guest { ...@@ -205,21 +205,21 @@ export default class Sidebar extends Guest {
_setupSidebarEvents() { _setupSidebarEvents() {
annotationCounts(document.body, this.crossframe); annotationCounts(document.body, this.crossframe);
sidebarTrigger(document.body, () => this.open()); sidebarTrigger(document.body, () => this.show());
features.init(this.crossframe); features.init(this.crossframe);
this.crossframe.on('openSidebar', () => this.open()); this.crossframe.on('showSidebar', () => this.show());
this.crossframe.on('closeSidebar', () => this.close()); this.crossframe.on('hideSidebar', () => this.hide());
// 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('openNotebook', groupId => { this.crossframe.on('showNotebook', groupId => {
this.close(); this.hide();
this.publish('openNotebook', [groupId]); this.publish('showNotebook', [groupId]);
}); });
this.crossframe.on('closeNotebook', () => { this.crossframe.on('hideNotebook', () => {
this.open(); this.show();
this.publish('closeNotebook'); this.publish('hideNotebook');
}); });
const eventHandlers = [ const eventHandlers = [
...@@ -345,9 +345,9 @@ export default class Sidebar extends Guest { ...@@ -345,9 +345,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.close(); this.hide();
} else { } else {
this.open(); this.show();
} }
} }
} }
...@@ -384,9 +384,9 @@ export default class Sidebar extends Guest { ...@@ -384,9 +384,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.open(); this.show();
} else { } else {
this.close(); this.hide();
} }
this._resetGestureState(); this._resetGestureState();
break; break;
...@@ -405,7 +405,7 @@ export default class Sidebar extends Guest { ...@@ -405,7 +405,7 @@ export default class Sidebar extends Guest {
} }
} }
open() { show() {
this.crossframe.call('sidebarOpened'); this.crossframe.call('sidebarOpened');
this.publish('sidebarOpened'); this.publish('sidebarOpened');
...@@ -424,7 +424,7 @@ export default class Sidebar extends Guest { ...@@ -424,7 +424,7 @@ export default class Sidebar extends Guest {
this._notifyOfLayoutChange(true); this._notifyOfLayoutChange(true);
} }
close() { hide() {
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, 'closeSidebar'); assert.calledWith(guest.plugins.CrossFrame.call, 'hideSidebar');
} }
}); });
...@@ -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, 'openSidebar'); assert.calledWith(fakeCrossFrame.call, 'showSidebar');
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.open(); notebook.show();
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.close(); notebook.hide();
assert.isNull(notebook.container); assert.isNull(notebook.container);
}); });
it('displays when opened', () => { it('displays when opened', () => {
const notebook = createNotebook(); const notebook = createNotebook();
notebook.open(); notebook.show();
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.open(); notebook.show();
notebook.close(); notebook.hide();
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 opened for the first time', () => { it('creates the iframe when the notebook is shown for the first time', () => {
const notebook = createNotebook(); const notebook = createNotebook();
assert.isNull(notebook.frame); assert.isNull(notebook.frame);
notebook.open(); notebook.show();
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.open(); notebook.show();
// 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 opened again with same group ID', () => { it('does not create a new iframe if shown again with same group ID', () => {
const notebook = createNotebook(); const notebook = createNotebook();
notebook._groupId = 'mygroup'; notebook._groupId = 'mygroup';
// The first opening will create a new iFrame // The first showing will create a new iFrame
notebook.publish('openNotebook', ['myGroup']); notebook.publish('showNotebook', ['myGroup']);
const removeSpy = sinon.spy(notebook.frame, 'remove'); 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 // replaced
notebook.publish('openNotebook', ['myGroup']); notebook.publish('showNotebook', ['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 open: creates an iframe // First show: creates an iframe
notebook.publish('openNotebook', ['myGroup']); notebook.publish('showNotebook', ['myGroup']);
const removeSpy = sinon.spy(notebook.frame, 'remove'); const removeSpy = sinon.spy(notebook.frame, 'remove');
// Open again with another group // Show again with another group
notebook.publish('openNotebook', ['anotherGroup']); notebook.publish('showNotebook', ['anotherGroup']);
// Open again, which will remove the first iframe and create a new one // Show again, which will remove the first iframe and create a new one
notebook.open(); notebook.show();
assert.calledOnce(removeSpy); assert.calledOnce(removeSpy);
}); });
}); });
describe('responding to events', () => { describe('responding to events', () => {
it('opens on `openNotebook`', () => { it('shows on `showNotebook`', () => {
const notebook = createNotebook(); const notebook = createNotebook();
notebook.publish('openNotebook'); notebook.publish('showNotebook');
assert.equal(notebook.container.style.display, ''); assert.equal(notebook.container.style.display, '');
}); });
it('closes on `closeNotebook`', () => { it('hides on `hideNotebook`', () => {
const notebook = createNotebook(); const notebook = createNotebook();
notebook.open(); notebook.show();
notebook.publish('closeNotebook'); notebook.publish('hideNotebook');
assert.equal(notebook.container.style.display, 'none'); assert.equal(notebook.container.style.display, 'none');
}); });
it('closes on "sidebarOpened"', () => { it('hides on "sidebarOpened"', () => {
const notebook = createNotebook(); const notebook = createNotebook();
notebook.open(); notebook.show();
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.open(); notebook.show();
assert.isNotNull(hostDocument.querySelector('hypothesis-notebook')); assert.isNotNull(hostDocument.querySelector('hypothesis-notebook'));
notebook.destroy(); notebook.destroy();
......
...@@ -190,16 +190,16 @@ describe('Sidebar', () => { ...@@ -190,16 +190,16 @@ describe('Sidebar', () => {
}); });
describe('toolbar buttons', () => { describe('toolbar buttons', () => {
it('opens and closes sidebar when toolbar button is clicked', () => { it('shows or hides sidebar when toolbar button is clicked', () => {
const sidebar = createSidebar(); const sidebar = createSidebar();
sinon.stub(sidebar, 'open'); sinon.stub(sidebar, 'show');
sinon.stub(sidebar, 'close'); sinon.stub(sidebar, 'hide');
FakeToolbarController.args[0][1].setSidebarOpen(true); FakeToolbarController.args[0][1].setSidebarOpen(true);
assert.called(sidebar.open); assert.called(sidebar.show);
FakeToolbarController.args[0][1].setSidebarOpen(false); FakeToolbarController.args[0][1].setSidebarOpen(false);
assert.called(sidebar.close); assert.called(sidebar.hide);
}); });
it('shows or hides highlights when toolbar button is clicked', () => { it('shows or hides highlights when toolbar button is clicked', () => {
...@@ -235,45 +235,45 @@ describe('Sidebar', () => { ...@@ -235,45 +235,45 @@ describe('Sidebar', () => {
return result; return result;
}; };
describe('on "open" event', () => describe('on "show" event', () =>
it('opens the frame', () => { it('shows the frame', () => {
const target = sandbox.stub(Sidebar.prototype, 'open'); const target = sandbox.stub(Sidebar.prototype, 'show');
createSidebar(); createSidebar();
emitEvent('openSidebar'); emitEvent('showSidebar');
assert.called(target); assert.called(target);
})); }));
describe('on "close" event', () => describe('on "hide" event', () =>
it('closes the frame', () => { it('hides the frame', () => {
const target = sandbox.stub(Sidebar.prototype, 'close'); const target = sandbox.stub(Sidebar.prototype, 'hide');
createSidebar(); createSidebar();
emitEvent('closeSidebar'); emitEvent('hideSidebar');
assert.called(target); assert.called(target);
})); }));
describe('on "openNotebook" event', () => { describe('on "showNotebook" 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, 'close'); sinon.stub(sidebar, 'hide');
emitEvent('openNotebook', 'mygroup'); emitEvent('showNotebook', 'mygroup');
assert.calledWith( assert.calledWith(
sidebar.publish, sidebar.publish,
'openNotebook', 'showNotebook',
sinon.match(['mygroup']) sinon.match(['mygroup'])
); );
assert.calledOnce(sidebar.close); assert.calledOnce(sidebar.hide);
}); });
}); });
describe('on "closeNotebook" event', () => { describe('on "hideNotebook" event', () => {
it('opens itself and republishes the event', () => { it('shows itself and republishes the event', () => {
const sidebar = createSidebar(); const sidebar = createSidebar();
sinon.stub(sidebar, 'publish'); sinon.stub(sidebar, 'publish');
sinon.stub(sidebar, 'open'); sinon.stub(sidebar, 'show');
emitEvent('closeNotebook'); emitEvent('hideNotebook');
assert.calledWith(sidebar.publish, 'closeNotebook'); assert.calledWith(sidebar.publish, 'hideNotebook');
assert.calledOnce(sidebar.open); assert.calledOnce(sidebar.show);
}); });
}); });
...@@ -421,18 +421,18 @@ describe('Sidebar', () => { ...@@ -421,18 +421,18 @@ describe('Sidebar', () => {
assert.equal(sidebar.frame.style.pointerEvents, ''); 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 }; sidebar._gestureState = { final: -500 };
const open = sandbox.stub(sidebar, 'open'); const show = sandbox.stub(sidebar, 'show');
sidebar._onPan({ type: 'panend' }); sidebar._onPan({ type: 'panend' });
assert.calledOnce(open); assert.calledOnce(show);
}); });
it('calls `close` if the widget is not fully visible', () => { it('calls `hide` if the widget is not fully visible', () => {
sidebar._gestureState = { final: -100 }; sidebar._gestureState = { final: -100 };
const close = sandbox.stub(sidebar, 'close'); const hide = sandbox.stub(sidebar, 'hide');
sidebar._onPan({ type: 'panend' }); sidebar._onPan({ type: 'panend' });
assert.calledOnce(close); assert.calledOnce(hide);
}); });
}); });
...@@ -453,43 +453,43 @@ describe('Sidebar', () => { ...@@ -453,43 +453,43 @@ describe('Sidebar', () => {
const sidebar = createSidebar({ const sidebar = createSidebar({
annotations: 'ann-id', annotations: 'ann-id',
}); });
const open = sandbox.stub(sidebar, 'open'); const show = sandbox.stub(sidebar, 'show');
sidebar.publish('panelReady'); sidebar.publish('panelReady');
assert.calledOnce(open); assert.calledOnce(show);
}); });
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 open = sandbox.stub(sidebar, 'open'); const show = sandbox.stub(sidebar, 'show');
sidebar.publish('panelReady'); sidebar.publish('panelReady');
assert.calledOnce(open); assert.calledOnce(show);
}); });
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 open = sandbox.stub(sidebar, 'open'); const show = sandbox.stub(sidebar, 'show');
sidebar.publish('panelReady'); sidebar.publish('panelReady');
assert.calledOnce(open); assert.calledOnce(show);
}); });
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 open = sandbox.stub(sidebar, 'open'); const show = sandbox.stub(sidebar, 'show');
sidebar.publish('panelReady'); 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 sidebar = createSidebar();
const open = sandbox.stub(sidebar, 'open'); const show = sandbox.stub(sidebar, 'show');
sidebar.publish('panelReady'); sidebar.publish('panelReady');
assert.notCalled(open); assert.notCalled(show);
}); });
}); });
...@@ -513,24 +513,24 @@ describe('Sidebar', () => { ...@@ -513,24 +513,24 @@ describe('Sidebar', () => {
}); });
}); });
describe('#open', () => { describe('#show', () => {
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.open(); sidebar.show();
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.open(); sidebar.show();
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.open(); sidebar.show();
assert.equal(fakeToolbar.sidebarOpen, true); assert.equal(fakeToolbar.sidebarOpen, true);
}); });
}); });
...@@ -539,8 +539,8 @@ describe('Sidebar', () => { ...@@ -539,8 +539,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.open(); sidebar.show();
sidebar.close(); sidebar.hide();
assert.isFalse(sidebar.visibleHighlights); assert.isFalse(sidebar.visibleHighlights);
}); });
...@@ -548,8 +548,8 @@ describe('Sidebar', () => { ...@@ -548,8 +548,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.open(); sidebar.show();
sidebar.close(); sidebar.hide();
assert.equal(fakeToolbar.sidebarOpen, false); assert.equal(fakeToolbar.sidebarOpen, false);
}); });
...@@ -582,21 +582,21 @@ describe('Sidebar', () => { ...@@ -582,21 +582,21 @@ describe('Sidebar', () => {
assert.equal(fakeToolbar.sidebarOpen, false); assert.equal(fakeToolbar.sidebarOpen, false);
}); });
it('invokes the "open" method when window is resized', () => { it('invokes the "show" method when window is resized', () => {
// Calling the 'open' methods adjust the marginLeft at different screen sizes // Calling the 'show' 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, 'open'); sinon.stub(sidebar, 'show');
// 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.open); assert.calledOnce(sidebar.show);
// 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.open); assert.calledTwice(sidebar.show);
}); });
}); });
...@@ -674,7 +674,7 @@ describe('Sidebar', () => { ...@@ -674,7 +674,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.open(); sidebar.show();
assert.calledOnce(layoutChangeHandlerSpy); assert.calledOnce(layoutChangeHandlerSpy);
assert.calledWith( assert.calledWith(
sidebar.publish, sidebar.publish,
...@@ -687,7 +687,7 @@ describe('Sidebar', () => { ...@@ -687,7 +687,7 @@ describe('Sidebar', () => {
expanded: true, expanded: true,
}); });
sidebar.close(); sidebar.hide();
assert.calledTwice(layoutChangeHandlerSpy); assert.calledTwice(layoutChangeHandlerSpy);
assert.calledThrice(sidebar.publish); assert.calledThrice(sidebar.publish);
assertLayoutValues(layoutChangeHandlerSpy.lastCall.args[0], { assertLayoutValues(layoutChangeHandlerSpy.lastCall.args[0], {
...@@ -745,14 +745,14 @@ describe('Sidebar', () => { ...@@ -745,14 +745,14 @@ describe('Sidebar', () => {
}); });
it('notifies when sidebar changes expanded state', () => { it('notifies when sidebar changes expanded state', () => {
sidebar.open(); sidebar.show();
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.close(); sidebar.hide();
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('openNotebook', store.focusedGroupId()); bridge.call('showNotebook', 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, 'openNotebook', 'mygroup'); assert.calledWith(fakeBridge.call, 'showNotebook', '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('openSidebar'); bridge.call('showSidebar');
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('openSidebar', function () { bridge.on('showSidebar', function () {
bridge.call('openSidebar'); bridge.call('showSidebar');
}); });
bridge.on('closeSidebar', function () { bridge.on('hideSidebar', function () {
bridge.call('closeSidebar'); bridge.call('hideSidebar');
}); });
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, 'openSidebar'); assert.calledWith(fakeBridge.call, 'showSidebar');
}); });
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 "openSidebar"', function () { it('calls "showSidebar"', function () {
fakeBridge.emit('openSidebar'); fakeBridge.emit('showSidebar');
assert.calledWith(fakeBridge.call, 'openSidebar'); assert.calledWith(fakeBridge.call, 'showSidebar');
}); });
it('calls "closeSidebar"', function () { it('calls "hideSidebar"', function () {
fakeBridge.emit('closeSidebar'); fakeBridge.emit('hideSidebar');
assert.calledWith(fakeBridge.call, 'closeSidebar'); assert.calledWith(fakeBridge.call, 'hideSidebar');
}); });
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