From 6229704e9e4c0f0336d070c69f8a9757a01bd72e Mon Sep 17 00:00:00 2001 From: Drini Cami Date: Mon, 30 Dec 2024 13:26:57 -0500 Subject: [PATCH 1/3] Move `autoflip` url parameter handling to plugin.autoplay.js --- BookReaderDemo/IADemoBr.js | 10 ---------- src/plugins/plugin.autoplay.js | 6 ++++++ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/BookReaderDemo/IADemoBr.js b/BookReaderDemo/IADemoBr.js index 9d3715755..62dfaf6b0 100644 --- a/BookReaderDemo/IADemoBr.js +++ b/BookReaderDemo/IADemoBr.js @@ -16,7 +16,6 @@ function getFromUrl(name, def) { const ocaid = urlParams.get('ocaid'); const openFullImmersionTheater = urlParams.get('view') === 'theater'; const ui = urlParams.get('ui'); -const autoflip = urlParams.get('autoflip'); const searchTerm = urlParams.get('q'); const iaBookReader = document.querySelector('ia-bookreader'); @@ -46,12 +45,6 @@ BookReader.optionOverrides.imagesBaseURL = '/BookReader/images/'; const initializeBookReader = (brManifest) => { console.log('initializeBookReader', brManifest); - const customAutoflipParams = { - autoflip: !!autoflip, - flipSpeed: parseFloat(getFromUrl('flipSpeed', '2000')), - flipDelay: parseFloat(getFromUrl('flipDelay', '5000')), - }; - const options = { el: '#BookReader', /* Url plugin - IA uses History mode for URL */ @@ -90,9 +83,6 @@ const initializeBookReader = (brManifest) => { const isRestricted = brManifest.data.isRestricted; window.dispatchEvent(new CustomEvent('contextmenu', { detail: { isRestricted } })); - if (customAutoflipParams.autoflip) { - window.br.autoToggle(customAutoflipParams); - } }; window.initializeBookReader = initializeBookReader; diff --git a/src/plugins/plugin.autoplay.js b/src/plugins/plugin.autoplay.js index 4e5cd08be..8cabda21f 100644 --- a/src/plugins/plugin.autoplay.js +++ b/src/plugins/plugin.autoplay.js @@ -28,7 +28,13 @@ BookReader.prototype.init = (function(super_) { super_.call(this, options); if (!this.options.enableAutoPlayPlugin) return; + this.bind(BookReader.eventNames.stop, () => this.autoStop()); + + const urlParams = new URLSearchParams(window.location.search); + if (urlParams.get('autoflip') === '1') { + this.autoToggle(); + } }; })(BookReader.prototype.init); From 95cbc637921b3bce48e79f6c17c60dac1a5e2d45 Mon Sep 17 00:00:00 2001 From: Drini Cami Date: Mon, 30 Dec 2024 13:27:47 -0500 Subject: [PATCH 2/3] Remove unused state variable from plugin.autoplay.js --- src/plugins/plugin.autoplay.js | 1 - tests/jest/plugins/plugin.autoplay.test.js | 4 ---- 2 files changed, 5 deletions(-) diff --git a/src/plugins/plugin.autoplay.js b/src/plugins/plugin.autoplay.js index 8cabda21f..4736c825b 100644 --- a/src/plugins/plugin.autoplay.js +++ b/src/plugins/plugin.autoplay.js @@ -14,7 +14,6 @@ BookReader.prototype.setup = (function(super_) { return function (options) { super_.call(this, options); - this.auto = false; this.autoTimer = null; this.flipDelay = 5000; }; diff --git a/tests/jest/plugins/plugin.autoplay.test.js b/tests/jest/plugins/plugin.autoplay.test.js index 4e6b2147a..c861bba8c 100644 --- a/tests/jest/plugins/plugin.autoplay.test.js +++ b/tests/jest/plugins/plugin.autoplay.test.js @@ -18,10 +18,6 @@ describe('Plugin: Menu Toggle', () => { test('has option flag', () => { expect(BookReader.defaultOptions.enableAutoPlayPlugin).toEqual(true); }); - test('has added BR property: auto', () => { - expect(br).toHaveProperty('auto'); - expect(br.auto).toEqual(false); - }); test('has added BR property: autoTimer', () => { expect(br).toHaveProperty('autoTimer'); expect(br.autoTimer).toEqual(null); From 868a6ece8835f9bc0ffdbd1ab37f3121c8d0d25f Mon Sep 17 00:00:00 2001 From: Drini Cami Date: Mon, 30 Dec 2024 13:31:15 -0500 Subject: [PATCH 3/3] Replace demo-autoplay with demo-internetarchive + url param --- BookReaderDemo/BookReaderJSAutoplay.js | 59 -------------------------- BookReaderDemo/demo-autoplay.html | 37 ---------------- index.html | 2 +- tests/e2e/autoplay.test.js | 2 +- 4 files changed, 2 insertions(+), 98 deletions(-) delete mode 100644 BookReaderDemo/BookReaderJSAutoplay.js delete mode 100644 BookReaderDemo/demo-autoplay.html diff --git a/BookReaderDemo/BookReaderJSAutoplay.js b/BookReaderDemo/BookReaderJSAutoplay.js deleted file mode 100644 index a84580df7..000000000 --- a/BookReaderDemo/BookReaderJSAutoplay.js +++ /dev/null @@ -1,59 +0,0 @@ -// -// This file shows the minimum you need to provide to BookReader to display a book -// -// Copyright(c)2008-2009 Internet Archive. Software license AGPL version 3. - -// Create the BookReader object -function instantiateBookReader(selector, extraOptions) { - selector = selector || '#BookReader'; - extraOptions = extraOptions || {}; - var options = { - ppi: 100, - data: [ - [ - { width: 800, height: 1200, - uri: '//archive.org/download/BookReader/img/page001.jpg' }, - ], - [ - { width: 800, height: 1200, - uri: '//archive.org/download/BookReader/img/page002.jpg' }, - { width: 800, height: 1200, - uri: '//archive.org/download/BookReader/img/page003.jpg' }, - ], - [ - { width: 800, height: 1200, - uri: '//archive.org/download/BookReader/img/page004.jpg' }, - { width: 800, height: 1200, - uri: '//archive.org/download/BookReader/img/page005.jpg' }, - ] - ], - - // Book title and the URL used for the book title link - bookTitle: 'BookReader Demo', - bookUrl: '../index.html', - bookUrlText: 'Back to Demos', - bookUrlTitle: 'This is the book URL title', - - // thumbnail is optional, but it is used in the info dialog - thumbnail: '//archive.org/download/BookReader/img/page014.jpg', - // Metadata is optional, but it is used in the info dialog - metadata: [ - {label: 'Title', value: 'Open Library BookReader Presentation'}, - {label: 'Author', value: 'Internet Archive'}, - {label: 'Demo Info', value: 'This demo shows how one could use BookReader with their own content.'}, - ], - - // Override the path used to find UI images - imagesBaseURL: '../BookReader/images/', - - ui: 'full', // embed, full (responsive) - - el: selector, - }; - $.extend(options, extraOptions); - var br = new BookReader(options); - br.init(); - setTimeout(function() { - br.autoToggle(options); - }, 0); -} diff --git a/BookReaderDemo/demo-autoplay.html b/BookReaderDemo/demo-autoplay.html deleted file mode 100644 index cb155511e..000000000 --- a/BookReaderDemo/demo-autoplay.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - BookReader fullscreen demo - - - - - - - - - - - - - - - - - - - - - - -
- - - - diff --git a/index.html b/index.html index c4d1857a9..9b48fd82a 100644 --- a/index.html +++ b/index.html @@ -23,7 +23,7 @@
  • From Internet Archive - a book with CHAPTERS
  • IIIF
  • -
  • Autoplay (kiosk mode)
  • +
  • Autoplay (kiosk mode)
  • Plugin: Full screen menu toggle
  • Start in immersion (fullscreen) mode
  • diff --git a/tests/e2e/autoplay.test.js b/tests/e2e/autoplay.test.js index 7210740b2..8b986ba4d 100644 --- a/tests/e2e/autoplay.test.js +++ b/tests/e2e/autoplay.test.js @@ -5,7 +5,7 @@ const getLocationHref = ClientFunction(() => window.location.href.toString()); const FLIP_SPEED = 1000; const FIRST_PAGE_DELAY = 2000; -fixture `Autoplay plugin`.page `${params.baseUrl}/BookReaderDemo/demo-autoplay.html`; +fixture `Autoplay plugin`.page `${params.baseUrl}/BookReaderDemo/demo-internetarchive.html?ocaid=goody&autoflip=1`; test('page auto-advances after allotted flip speed and delay', async t => { await t.wait(2 * FLIP_SPEED + FIRST_PAGE_DELAY);