Commit 1a15838c authored by Robert Knight's avatar Robert Knight

Implement side-by-side mode for VitalSource EPUB books

In the VitalSource integration, enable the side-by-side mode in the
underlying HTML document integration.
parent d81b73af
...@@ -67,7 +67,9 @@ describe('annotator/integrations/vitalsource', () => { ...@@ -67,7 +67,9 @@ describe('annotator/integrations/vitalsource', () => {
contentContainer: sinon.stub(), contentContainer: sinon.stub(),
describe: sinon.stub(), describe: sinon.stub(),
destroy: sinon.stub(), destroy: sinon.stub(),
fitSideBySide: sinon.stub().returns(false),
scrollToAnchor: sinon.stub(), scrollToAnchor: sinon.stub(),
sideBySideEnabled: false,
}; };
FakeHTMLIntegration = sinon.stub().returns(fakeHTMLIntegration); FakeHTMLIntegration = sinon.stub().returns(fakeHTMLIntegration);
...@@ -189,9 +191,16 @@ describe('annotator/integrations/vitalsource', () => { ...@@ -189,9 +191,16 @@ describe('annotator/integrations/vitalsource', () => {
assert.equal(integration.canAnnotate(), true); assert.equal(integration.canAnnotate(), true);
}); });
it('does not support side-by-side mode', () => { it('delegates to HTMLIntegration for side-by-side mode', () => {
const integration = createIntegration(); const integration = createIntegration();
assert.equal(integration.fitSideBySide(), false); fakeHTMLIntegration.fitSideBySide.returns(true);
assert.isTrue(fakeHTMLIntegration.sideBySideEnabled);
const layout = { expanded: true, width: 150 };
const isActive = integration.fitSideBySide(layout);
assert.isTrue(isActive);
assert.calledWith(fakeHTMLIntegration.fitSideBySide, layout);
}); });
it('stops mouse events from propagating to parent frame', () => { it('stops mouse events from propagating to parent frame', () => {
......
...@@ -8,6 +8,7 @@ import { injectClient } from '../hypothesis-injector'; ...@@ -8,6 +8,7 @@ import { injectClient } from '../hypothesis-injector';
* @typedef {import('../../types/annotator').Annotator} Annotator * @typedef {import('../../types/annotator').Annotator} Annotator
* @typedef {import('../../types/annotator').Integration} Integration * @typedef {import('../../types/annotator').Integration} Integration
* @typedef {import('../../types/annotator').Selector} Selector * @typedef {import('../../types/annotator').Selector} Selector
* @typedef {import('../../types/annotator').SidebarLayout} SidebarLayout
*/ */
/** /**
...@@ -146,6 +147,7 @@ export class VitalSourceContentIntegration { ...@@ -146,6 +147,7 @@ export class VitalSourceContentIntegration {
*/ */
constructor(container = document.body) { constructor(container = document.body) {
this._htmlIntegration = new HTMLIntegration(container); this._htmlIntegration = new HTMLIntegration(container);
this._htmlIntegration.sideBySideEnabled = true;
this._listeners = new ListenerCollection(); this._listeners = new ListenerCollection();
...@@ -223,9 +225,11 @@ export class VitalSourceContentIntegration { ...@@ -223,9 +225,11 @@ export class VitalSourceContentIntegration {
return this._htmlIntegration.contentContainer(); return this._htmlIntegration.contentContainer();
} }
fitSideBySide() { /**
// Not yet implemented * @param {SidebarLayout} layout
return false; */
fitSideBySide(layout) {
return this._htmlIntegration.fitSideBySide(layout);
} }
async getMetadata() { async getMetadata() {
......
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