@internetarchive/ia-book-actions 0.0.29-alpha17 → 0.0.29-alpha19
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 +1 -1
- package/package.json +2 -2
- package/src/ia-book-actions.js +19 -13
package/demo/index.html
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@internetarchive/ia-book-actions",
|
|
3
|
-
"version": "0.0.29-
|
|
3
|
+
"version": "0.0.29-alpha19",
|
|
4
4
|
"description": "Bookreader actions for borrowable book",
|
|
5
5
|
"author": "Internet Archive",
|
|
6
6
|
"license": "AGPL-3.0-only",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"@internetarchive/local-cache": "^0.2.0",
|
|
23
23
|
"@internetarchive/modal-manager": "^0.2.1",
|
|
24
24
|
"@internetarchive/shared-resize-observer": "^0.2.0",
|
|
25
|
-
"@internetarchive/toast-manager": "0.0.1-
|
|
25
|
+
"@internetarchive/toast-manager": "0.0.1-alpha3",
|
|
26
26
|
"lit": "^2.2.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
package/src/ia-book-actions.js
CHANGED
|
@@ -3,6 +3,7 @@ import { html, css, LitElement, nothing } from 'lit';
|
|
|
3
3
|
|
|
4
4
|
import { SharedResizeObserver } from '@internetarchive/shared-resize-observer';
|
|
5
5
|
import { ModalConfig } from '@internetarchive/modal-manager';
|
|
6
|
+
import '@internetarchive/toast-manager';
|
|
6
7
|
import { ToastConfig } from '@internetarchive/toast-manager';
|
|
7
8
|
import { LocalCache } from '@internetarchive/local-cache';
|
|
8
9
|
|
|
@@ -83,6 +84,7 @@ export default class IABookActions extends LitElement {
|
|
|
83
84
|
this.consecutiveLoanCounts = 1; // consecutive loan count
|
|
84
85
|
this.browserTimer = undefined;
|
|
85
86
|
|
|
87
|
+
this._shadowRoot = this.attachShadow({ mode: "open" });
|
|
86
88
|
this.bindLoanRenewEvents();
|
|
87
89
|
}
|
|
88
90
|
|
|
@@ -109,10 +111,6 @@ export default class IABookActions extends LitElement {
|
|
|
109
111
|
this.disconnectResizeObserver();
|
|
110
112
|
this.setupResizeObserver();
|
|
111
113
|
}
|
|
112
|
-
|
|
113
|
-
if (changed.has('loanRenewResult')) {
|
|
114
|
-
this.showToastMessage();
|
|
115
|
-
}
|
|
116
114
|
}
|
|
117
115
|
|
|
118
116
|
bindLoanRenewEvents() {
|
|
@@ -144,6 +142,8 @@ export default class IABookActions extends LitElement {
|
|
|
144
142
|
|
|
145
143
|
console.log(this.loanRenewResult);
|
|
146
144
|
|
|
145
|
+
this.showToastMessage();
|
|
146
|
+
|
|
147
147
|
if (this.loanRenewResult.renewNow) {
|
|
148
148
|
this.tokenPoller.disconnectedInterval();
|
|
149
149
|
await this.browseHasRenew();
|
|
@@ -152,12 +152,15 @@ export default class IABookActions extends LitElement {
|
|
|
152
152
|
return nothing;
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
showToastMessage() {
|
|
156
|
-
let toastManager =
|
|
155
|
+
async showToastMessage() {
|
|
156
|
+
let toastManager = this.shadowRoot.querySelector('toast-template');
|
|
157
157
|
if (!toastManager) {
|
|
158
158
|
toastManager = document.createElement('toast-template');
|
|
159
159
|
}
|
|
160
|
-
|
|
160
|
+
this.shadowRoot.appendChild(toastManager)
|
|
161
|
+
|
|
162
|
+
// await this.shadowRoot.appendChild(toastManager)
|
|
163
|
+
// await document.body.appendChild(toastManager);
|
|
161
164
|
|
|
162
165
|
toastManager.config = new ToastConfig(this.loanRenewResult);
|
|
163
166
|
}
|
|
@@ -165,16 +168,17 @@ export default class IABookActions extends LitElement {
|
|
|
165
168
|
async browseHasExpired() {
|
|
166
169
|
const currStatus = { ...this.lendingStatus, browsingExpired: true };
|
|
167
170
|
this.lendingStatus = currStatus;
|
|
168
|
-
this.loanRenewResult.renewNow = false;
|
|
169
171
|
|
|
170
172
|
// remove respected key:value
|
|
171
173
|
await this.localCache.delete(`${this.identifier}-loanTime`);
|
|
172
174
|
await this.localCache.delete(`${this.identifier}-pageChangedTime`);
|
|
173
175
|
|
|
174
176
|
// show message after browsed book is expired.
|
|
177
|
+
this.loanRenewResult.renewNow = false;
|
|
175
178
|
this.loanRenewResult.texts =
|
|
176
179
|
'This book has been auto-returned due to inactivity.';
|
|
177
|
-
|
|
180
|
+
|
|
181
|
+
this.showToastMessage();
|
|
178
182
|
}
|
|
179
183
|
|
|
180
184
|
async browseHasRenew() {
|
|
@@ -502,7 +506,7 @@ export default class IABookActions extends LitElement {
|
|
|
502
506
|
get textGroupTemplate() {
|
|
503
507
|
return html`<text-group
|
|
504
508
|
textClass=${this.textClass}
|
|
505
|
-
texts=${this.primaryTitle}
|
|
509
|
+
.texts=${this.primaryTitle}
|
|
506
510
|
>
|
|
507
511
|
</text-group>`;
|
|
508
512
|
}
|
|
@@ -515,12 +519,13 @@ export default class IABookActions extends LitElement {
|
|
|
515
519
|
return css`
|
|
516
520
|
:host {
|
|
517
521
|
display: block;
|
|
518
|
-
background: var(--primaryBGColor, #000);
|
|
519
|
-
color: var(--primaryTextColor, #fff);
|
|
520
522
|
}
|
|
523
|
+
|
|
521
524
|
.lending-wrapper {
|
|
522
525
|
width: 100%;
|
|
523
526
|
margin: 0 auto;
|
|
527
|
+
background: var(--primaryBGColor, #000);
|
|
528
|
+
color: var(--primaryTextColor, #fff);
|
|
524
529
|
display: inline-flex;
|
|
525
530
|
align-items: center;
|
|
526
531
|
justify-content: center;
|
|
@@ -528,9 +533,10 @@ export default class IABookActions extends LitElement {
|
|
|
528
533
|
}
|
|
529
534
|
|
|
530
535
|
toast-template {
|
|
531
|
-
--toastHeightFromTop:
|
|
536
|
+
--toastHeightFromTop: 22%;
|
|
532
537
|
--toastBGColor: #333333;
|
|
533
538
|
--toastFontColor: #ffffff;
|
|
539
|
+
--toastTopMargin: 80px;
|
|
534
540
|
}
|
|
535
541
|
`;
|
|
536
542
|
}
|