From 23859fbbfadcc6d9bd6aa4562effddfebf897413 Mon Sep 17 00:00:00 2001 From: Neeraj Sharma Date: Wed, 1 Feb 2023 18:21:09 +0530 Subject: [PATCH 1/3] Specific page changed event for auto loan renew feature --- src/BookReader.js | 3 ++- src/BookReader/events.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/BookReader.js b/src/BookReader.js index 9577803ff..8a6ba2749 100644 --- a/src/BookReader.js +++ b/src/BookReader.js @@ -1279,7 +1279,8 @@ BookReader.prototype.updateFirstIndex = function( if (this.options.initialSearchTerm && !suppressFragmentChange) { this.suppressFragmentChange = false; } - this.trigger('pageChanged'); + + this.trigger(BookReader.eventNames.pageChanged, { hasPageChanged: true }); this._components.navbar.updateNavIndexThrottled(index); }; diff --git a/src/BookReader/events.js b/src/BookReader/events.js index 8f0cd9853..3a7b7ad09 100644 --- a/src/BookReader/events.js +++ b/src/BookReader/events.js @@ -3,6 +3,7 @@ export const EVENTS = { /** Indicates that the fragment (a serialization of the reader * state) has changed. */ fragmentChange: 'fragmentChange', + pageChanged: 'pageChanged', PostInit: 'PostInit', stop: 'stop', resize: 'resize', From f6b7ba82d15da284ad99e9efd8845aba61dd840c Mon Sep 17 00:00:00 2001 From: Neeraj Sharma Date: Wed, 8 Feb 2023 16:53:33 +0530 Subject: [PATCH 2/3] Added bookreader controls to catch page-change event --- package.json | 2 +- src/BookReader.js | 10 +++++++++- src/BookReader/events.js | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f2378ab67..16b47a999 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@internetarchive/bookreader", - "version": "5.0.0-53", + "version": "5.0.0-53-alpha2", "description": "The Internet Archive BookReader.", "repository": { "type": "git", diff --git a/src/BookReader.js b/src/BookReader.js index 8a6ba2749..29ffb0f3e 100644 --- a/src/BookReader.js +++ b/src/BookReader.js @@ -1280,7 +1280,10 @@ BookReader.prototype.updateFirstIndex = function( this.suppressFragmentChange = false; } - this.trigger(BookReader.eventNames.pageChanged, { hasPageChanged: true }); + this.trigger(BookReader.eventNames.pageChanged); + + // - specific event to know if user is reading book + this.trigger(BookReader.eventNames.userAction) this._components.navbar.updateNavIndexThrottled(index); }; @@ -1541,6 +1544,11 @@ BookReader.prototype.bindNavigationHandlers = function() { }, }; + // custom event for auto-loan-renew in ia-book-actions to know if user is active + this.$('nav.BRcontrols li button').on('click', () => { + this.trigger(BookReader.eventNames.userAction); + }); + jIcons.filter('.fit').bind('fit', function() { // XXXmang implement autofit zoom }); diff --git a/src/BookReader/events.js b/src/BookReader/events.js index 3a7b7ad09..c0a0ae168 100644 --- a/src/BookReader/events.js +++ b/src/BookReader/events.js @@ -7,6 +7,7 @@ export const EVENTS = { PostInit: 'PostInit', stop: 'stop', resize: 'resize', + userAction: 'userAction', // nav events: navToggled: 'navToggled', // menu click events From 0deed543658b4766c64de3e8bf9039c348b324fb Mon Sep 17 00:00:00 2001 From: Neeraj Sharma Date: Mon, 13 Feb 2023 17:30:57 +0530 Subject: [PATCH 3/3] Removed npm version --- package.json | 2 +- src/BookReader.js | 7 ++++--- src/BookReader/events.js | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 16b47a999..f2378ab67 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@internetarchive/bookreader", - "version": "5.0.0-53-alpha2", + "version": "5.0.0-53", "description": "The Internet Archive BookReader.", "repository": { "type": "git", diff --git a/src/BookReader.js b/src/BookReader.js index 29ffb0f3e..3f0c62042 100644 --- a/src/BookReader.js +++ b/src/BookReader.js @@ -1282,8 +1282,8 @@ BookReader.prototype.updateFirstIndex = function( this.trigger(BookReader.eventNames.pageChanged); - // - specific event to know if user is reading book - this.trigger(BookReader.eventNames.userAction) + // event to know if user is actively reading + this.trigger(BookReader.eventNames.userAction); this._components.navbar.updateNavIndexThrottled(index); }; @@ -1544,7 +1544,8 @@ BookReader.prototype.bindNavigationHandlers = function() { }, }; - // custom event for auto-loan-renew in ia-book-actions to know if user is active + // custom event for auto-loan-renew in ia-book-actions + // - to know if user is actively reading this.$('nav.BRcontrols li button').on('click', () => { this.trigger(BookReader.eventNames.userAction); }); diff --git a/src/BookReader/events.js b/src/BookReader/events.js index c0a0ae168..147306583 100644 --- a/src/BookReader/events.js +++ b/src/BookReader/events.js @@ -7,7 +7,7 @@ export const EVENTS = { PostInit: 'PostInit', stop: 'stop', resize: 'resize', - userAction: 'userAction', + userAction: 'userAction', // event to know if user is actively reading // nav events: navToggled: 'navToggled', // menu click events