@internetarchive/ia-book-actions 0.0.29-alpha26 → 0.0.29-alpha27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/demo/index.html +3 -3
- package/package.json +1 -1
- package/src/ia-book-actions.js +11 -9
package/demo/index.html
CHANGED
|
@@ -128,8 +128,8 @@
|
|
|
128
128
|
iaBookActions.localCache = localCache;
|
|
129
129
|
iaBookActions.loanRenewConfig = {
|
|
130
130
|
totalTime: 20, // 60 second = 1 min
|
|
131
|
-
autoCheckAt:
|
|
132
|
-
pageChangedInLast:
|
|
131
|
+
autoCheckAt: 12, // totalTime - 10th minute
|
|
132
|
+
pageChangedInLast: 5, // within last 15 second/minute
|
|
133
133
|
env: 'dev', // dev/prod
|
|
134
134
|
};
|
|
135
135
|
|
|
@@ -285,7 +285,7 @@
|
|
|
285
285
|
// dispatch event to say book page has flipped
|
|
286
286
|
document.querySelector('ia-book-actions').dispatchEvent(
|
|
287
287
|
new CustomEvent('BookReader:pageChanged', {
|
|
288
|
-
detail: { hasPageChanged: true },
|
|
288
|
+
detail: { props: { hasPageChanged: true }},
|
|
289
289
|
bubbles: true,
|
|
290
290
|
composed: true,
|
|
291
291
|
})
|
package/package.json
CHANGED
package/src/ia-book-actions.js
CHANGED
|
@@ -84,7 +84,7 @@ export default class IABookActions extends LitElement {
|
|
|
84
84
|
this.loanRenewResult = {
|
|
85
85
|
texts: null,
|
|
86
86
|
renewNow: false,
|
|
87
|
-
timeLeft: 0
|
|
87
|
+
timeLeft: 0,
|
|
88
88
|
};
|
|
89
89
|
|
|
90
90
|
this._shadowRoot = this.attachShadow({ mode: 'open' });
|
|
@@ -234,9 +234,10 @@ export default class IABookActions extends LitElement {
|
|
|
234
234
|
* 2. IABookActions:loanRenew - dispatched from timer-countdown component
|
|
235
235
|
*/
|
|
236
236
|
bindLoanRenewEvents() {
|
|
237
|
-
|
|
237
|
+
/**
|
|
238
|
+
* dispatched this event from bookreader page changed
|
|
239
|
+
*/
|
|
238
240
|
window.addEventListener('BookReader:pageChanged', event => {
|
|
239
|
-
console.log(event.detail.props);
|
|
240
241
|
if (this.borrowType === 'browsed' && event.detail.props.hasPageChanged) {
|
|
241
242
|
console.log('actual page changed executed!')
|
|
242
243
|
this.autoLoanRenewChecker(true);
|
|
@@ -245,8 +246,12 @@ export default class IABookActions extends LitElement {
|
|
|
245
246
|
return nothing;
|
|
246
247
|
});
|
|
247
248
|
|
|
249
|
+
/**
|
|
250
|
+
* Detech click-event on document to close toast-template
|
|
251
|
+
*/
|
|
248
252
|
document.addEventListener('click', () => {
|
|
249
|
-
if (this.loanRenewHelper && this.
|
|
253
|
+
if (this.loanRenewHelper && this.loanRenewResult.timeLeft > 0) {
|
|
254
|
+
console.log('1');
|
|
250
255
|
this.suppressToast = true;
|
|
251
256
|
}
|
|
252
257
|
});
|
|
@@ -257,13 +262,11 @@ export default class IABookActions extends LitElement {
|
|
|
257
262
|
* 2. show warning message having remaining time
|
|
258
263
|
*/
|
|
259
264
|
this.addEventListener('IABookActions:loanRenew', async event => {
|
|
260
|
-
const eventDetails = event.detail;
|
|
261
|
-
|
|
262
265
|
await this.autoLoanRenewChecker(false);
|
|
263
266
|
|
|
264
267
|
// show warning message with remaining time to auto returned it.
|
|
265
|
-
if (this.
|
|
266
|
-
this.loanRenewResult.timeLeft =
|
|
268
|
+
if (this.loanRenewResult.renewNow === false) {
|
|
269
|
+
this.loanRenewResult.timeLeft = event.detail.timeLeft;
|
|
267
270
|
this.showToastMessage();
|
|
268
271
|
}
|
|
269
272
|
});
|
|
@@ -285,7 +288,6 @@ export default class IABookActions extends LitElement {
|
|
|
285
288
|
async showToastMessage() {
|
|
286
289
|
if (this.suppressToast) return false;
|
|
287
290
|
|
|
288
|
-
// this.result = this.loanRenewHelper.result;
|
|
289
291
|
const iaBookActions = document.querySelector('ia-book-actions').shadowRoot;
|
|
290
292
|
let toastTemplate = iaBookActions.querySelector('toast-template');
|
|
291
293
|
if (!toastTemplate) {
|