@internetarchive/ia-book-actions 0.0.27-a1 → 0.0.27
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
CHANGED
|
@@ -174,8 +174,10 @@
|
|
|
174
174
|
document.querySelectorAll('.printDisabled input[type=checkbox]').forEach((item) => {
|
|
175
175
|
item.addEventListener('click', (e) => {
|
|
176
176
|
if (e.target.checked) {
|
|
177
|
+
if (e.target.value === 'is_printdisabled') lendingStatus1.is_printdisabled = true;
|
|
177
178
|
if (e.target.value === 'user_is_printdisabled') lendingStatus1.user_is_printdisabled = true;
|
|
178
179
|
} else {
|
|
180
|
+
if (e.target.value === 'is_printdisabled') lendingStatus1.is_printdisabled = false;
|
|
179
181
|
if (e.target.value === 'user_is_printdisabled') lendingStatus1.user_is_printdisabled = false;
|
|
180
182
|
}
|
|
181
183
|
|
|
@@ -277,6 +279,7 @@
|
|
|
277
279
|
<label><input type="checkbox" name="user" value="isLoggedIn" />isLoggedIn</label>
|
|
278
280
|
</td>
|
|
279
281
|
<td class="printDisabled">
|
|
282
|
+
<label><input type="checkbox" name="is_printdisabled" value="is_printdisabled" />is_printdisabled</label>
|
|
280
283
|
<label><input type="checkbox" name="user_is_printdisabled" value="user_is_printdisabled" />user_is_printdisabled</label>
|
|
281
284
|
</td>
|
|
282
285
|
<td class="availableToBrowse">
|
package/package.json
CHANGED
|
@@ -22,7 +22,7 @@ export default class ActionsHandler extends LitElement {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
sendEvent(eventCategory, eventAction) {
|
|
25
|
-
window?.archive_analytics?.
|
|
25
|
+
window?.archive_analytics?.send_event_no_sampling(
|
|
26
26
|
eventCategory,
|
|
27
27
|
eventAction,
|
|
28
28
|
`identifier=${this.identifier}`
|
|
@@ -146,17 +146,9 @@ export class GetLendingActions {
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
borrowPrintDisabledAction() {
|
|
149
|
-
const lendingStatus = this.lendingStatus || {};
|
|
150
|
-
const browsingHasExpired =
|
|
151
|
-
!lendingStatus.available_to_browse && lendingStatus.browsingExpired;
|
|
152
|
-
|
|
153
|
-
// one hour borrow config
|
|
154
|
-
const oneHrBorrow = browsingHasExpired
|
|
155
|
-
? this.actionsConfig.browseAgainConfig()
|
|
156
|
-
: this.actionsConfig.firstBrowseConfig();
|
|
157
149
|
return {
|
|
158
150
|
primaryTitle: bookTitles.eligible_pd,
|
|
159
|
-
primaryActions: [
|
|
151
|
+
primaryActions: [this.actionsConfig.borrowBookConfig()],
|
|
160
152
|
primaryColor: 'primary',
|
|
161
153
|
secondaryActions: [
|
|
162
154
|
this.actionsConfig.adminAccessConfig(),
|
|
@@ -409,7 +401,8 @@ export class GetLendingActions {
|
|
|
409
401
|
const notBorrowable =
|
|
410
402
|
!lendingStatus.available_to_borrow && !lendingStatus.available_to_browse;
|
|
411
403
|
|
|
412
|
-
const userCanAccessPrintDisabled =
|
|
404
|
+
const userCanAccessPrintDisabled =
|
|
405
|
+
lendingStatus.is_printdisabled && lendingStatus.user_is_printdisabled;
|
|
413
406
|
|
|
414
407
|
const canBorrow =
|
|
415
408
|
(lendingStatus.available_to_browse ||
|
|
@@ -70,7 +70,7 @@ export class LoanTokenPoller {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
sendEvent(eventCategory, eventAction) {
|
|
73
|
-
window?.archive_analytics?.
|
|
73
|
+
window?.archive_analytics?.send_event_no_sampling(
|
|
74
74
|
eventCategory,
|
|
75
75
|
eventAction,
|
|
76
76
|
`identifier=${this.identifier}`
|
|
@@ -83,7 +83,10 @@ export class LoanTokenPoller {
|
|
|
83
83
|
identifier: this.identifier,
|
|
84
84
|
action,
|
|
85
85
|
error: data => {
|
|
86
|
-
window?.Sentry?.captureMessage(
|
|
86
|
+
window?.Sentry?.captureMessage(
|
|
87
|
+
'handleLoanTokenPoller error',
|
|
88
|
+
JSON.stringify(data)
|
|
89
|
+
);
|
|
87
90
|
this.disconnectedInterval(); // stop token fetch api
|
|
88
91
|
this.errorCallback({ detail: { action, data } });
|
|
89
92
|
// send LendingServiceError to GA
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en-GB">
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="utf-8">
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
|
7
|
-
<style>
|
|
8
|
-
html {
|
|
9
|
-
font-size: 10px;
|
|
10
|
-
/* This is to match petabox's base font size */
|
|
11
|
-
}
|
|
12
|
-
body {
|
|
13
|
-
margin: 0;
|
|
14
|
-
text-align: center;
|
|
15
|
-
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
|
16
|
-
}
|
|
17
|
-
#demo {
|
|
18
|
-
height: 50px;
|
|
19
|
-
}
|
|
20
|
-
ia-book-actions {
|
|
21
|
-
--white: #fff;
|
|
22
|
-
--black: #000;
|
|
23
|
-
--primaryBGColor: var(--black);
|
|
24
|
-
--secondaryBGColor: #222;
|
|
25
|
-
--tertiaryBGColor: #333;
|
|
26
|
-
--primaryTextColor: var(--white);
|
|
27
|
-
--primaryCTAFill: #194880;
|
|
28
|
-
--primaryCTABorder: #c5d1df;
|
|
29
|
-
--secondaryCTAFill: #333;
|
|
30
|
-
--secondaryCTABorder: #999;
|
|
31
|
-
--secondaryCTAFillRGB: 51, 51, 51;
|
|
32
|
-
--primaryErrorCTAFill: #e51c26;
|
|
33
|
-
--primaryErrorCTABorder: #f8c6c8;
|
|
34
|
-
--primaryCTAFillRGB: 25, 72, 128;
|
|
35
|
-
--primaryErrorCTAFillRGB: 229, 28, 38;
|
|
36
|
-
--primaryDisableCTAFill: #767676;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
fieldset {
|
|
40
|
-
width: fit-content;
|
|
41
|
-
margin-top: 50px;
|
|
42
|
-
}
|
|
43
|
-
fieldset legend {
|
|
44
|
-
text-align: left;
|
|
45
|
-
font-size: 12px;
|
|
46
|
-
}
|
|
47
|
-
td {
|
|
48
|
-
color: white;
|
|
49
|
-
font-size: 14px;
|
|
50
|
-
border-radius: 5%;
|
|
51
|
-
display: table-cell;
|
|
52
|
-
text-align: initial;
|
|
53
|
-
margin: 5px 0;
|
|
54
|
-
width: max-content;
|
|
55
|
-
display: block;
|
|
56
|
-
}
|
|
57
|
-
label {
|
|
58
|
-
padding: 10px;
|
|
59
|
-
display: block;
|
|
60
|
-
cursor: pointer;
|
|
61
|
-
margin: 2px;
|
|
62
|
-
background: #4e545a;
|
|
63
|
-
border-radius: 10px;
|
|
64
|
-
}
|
|
65
|
-
input[type="radio"], input[type="checkbox"] {
|
|
66
|
-
margin-top: 0;
|
|
67
|
-
vertical-align: middle;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.initial td {
|
|
71
|
-
float: left;
|
|
72
|
-
margin: 2px;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
body.modal-manager-open {
|
|
76
|
-
overflow: hidden;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
modal-manager[mode='closed'] {
|
|
80
|
-
display: none;
|
|
81
|
-
}
|
|
82
|
-
</style>
|
|
83
|
-
</head>
|
|
84
|
-
|
|
85
|
-
<body>
|
|
86
|
-
<ia-bookreader class="focus-on-child-only" signedin="" fullscreen="">
|
|
87
|
-
<div slot="header">
|
|
88
|
-
<ia-book-actions></ia-book-actions>
|
|
89
|
-
</div>
|
|
90
|
-
<div slot="main">
|
|
91
|
-
<div id="BookReader"></div>
|
|
92
|
-
</div>
|
|
93
|
-
</ia-bookreader>
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
<script type="module">
|
|
97
|
-
/* eslint-disable */
|
|
98
|
-
import '@internetarchive/bookreader';
|
|
99
|
-
import '@internetarchive/bookreader/BookReader/jquery-1.10.1.js';
|
|
100
|
-
import '@internetarchive/bookreader/BookReader/BookReader.js';
|
|
101
|
-
import '../src/ia-book-actions.js';
|
|
102
|
-
import {
|
|
103
|
-
defaultLendingStatus,
|
|
104
|
-
canBrowseAndBorrow,
|
|
105
|
-
} from '../src/assets/data/lending-get-status-service.js';
|
|
106
|
-
import { ModalConfig } from '@internetarchive/modal-manager';
|
|
107
|
-
|
|
108
|
-
const userid = '@neeraj-archive';
|
|
109
|
-
const identifier = 'naturalhistoryof00unse_4111';
|
|
110
|
-
let bwbPurchaseUrl = 'https://www.betterworldbooks.com/product/detail/cambridge-ancient-hist-v04-0521044863';
|
|
111
|
-
|
|
112
|
-
let iaBookActions = document.querySelector('ia-book-actions');
|
|
113
|
-
|
|
114
|
-
// for debugging
|
|
115
|
-
window.iaBookActions = iaBookActions;
|
|
116
|
-
|
|
117
|
-
const modalConfig = new ModalConfig();
|
|
118
|
-
modalConfig.headerColor = '#d9534f';
|
|
119
|
-
|
|
120
|
-
let lendingBarPostInit = function lendingBarPostInit() {
|
|
121
|
-
setTimeout(function() {
|
|
122
|
-
console.log('executed', 'br.init()');
|
|
123
|
-
}, 100);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// set defaultLendingStatus for unavailable (without borrowables) book
|
|
127
|
-
iaBookActions.userid = userid;
|
|
128
|
-
iaBookActions.identifier = identifier;
|
|
129
|
-
iaBookActions.bookTitle = 'Contemporary Black biography. Volume 39 : profiles from the interContemporary Black biography. Volume 39';
|
|
130
|
-
iaBookActions.lendingStatus = canBrowseAndBorrow;
|
|
131
|
-
iaBookActions.bwbPurchaseUrl = '';
|
|
132
|
-
iaBookActions.modalConfig = modalConfig;
|
|
133
|
-
iaBookActions.lendingBarPostInit = lendingBarPostInit;
|
|
134
|
-
iaBookActions.tokenDelay = 2000; // 2 seconds
|
|
135
|
-
iaBookActions.returnUrl = 'https://openlibrary.org';
|
|
136
|
-
|
|
137
|
-
let lendingStatus1 = iaBookActions.lendingStatus;
|
|
138
|
-
|
|
139
|
-
const manifest = await fetch('https://ia801302.us.archive.org/BookReader/BookReaderJSIA.php?id=goody&itemPath=/29/items/goody&server=ia801302.us.archive.org&format=jsonp&subPrefix=goody&requestUri=/details/goody/mode/1up%3Fview%3Dtheater%26ui%3Dembed%26wrapper%3Dfalse');
|
|
140
|
-
|
|
141
|
-
console.log('manifest ****', manifest).then(res => res.json());
|
|
142
|
-
</script>
|
|
143
|
-
|
|
144
|
-
</div>
|
|
145
|
-
</body>
|
|
146
|
-
</html>
|