@internetarchive/ia-book-actions 1.0.0 → 1.1.0-alpha1

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
@@ -150,6 +150,25 @@
150
150
  });
151
151
  });
152
152
 
153
+ document.querySelectorAll('.searchParam input[type=checkbox]').forEach((item) => {
154
+ item.addEventListener('click', (e) => {
155
+ var searchParams = new URLSearchParams(window.location.search);
156
+ var separate = '';
157
+ if (e.target.checked) {
158
+ separate = '?';
159
+ searchParams.set('q', 'test');
160
+ } else {
161
+ separate = '';
162
+ searchParams.delete('q');
163
+ }
164
+
165
+ if (history.pushState) {
166
+ var newurl = window.location.protocol + "//" + window.location.host + window.location.pathname + separate + searchParams;
167
+ window.history.pushState({path:newurl},'',newurl);
168
+ }
169
+ });
170
+ });
171
+
153
172
  document.querySelectorAll('.errorEnable input[type=checkbox]').forEach((item) => {
154
173
  if (window.location.href.indexOf('?error=true') !== -1) {
155
174
  item.checked = true;
@@ -327,7 +346,6 @@
327
346
  // listen for IABookReader:BrowsingHasExpired
328
347
  window.addEventListener('IABookReader:BrowsingHasExpired', () => {
329
348
  console.log('IABookReader:BrowsingHasExpired EVENT FIRED');
330
- alert('IABookReader:BrowsingHasExpired EVENT FIRED');
331
349
  });
332
350
  </script>
333
351
 
@@ -339,6 +357,8 @@
339
357
  <td class="titleBar">
340
358
  <label><input type="checkbox" name="title" value="title" />Title Bar</label>
341
359
  </td>
360
+ <td class="searchParam">
361
+ <label><input type="checkbox" name="search" value="Search Param" />Search Param</label>
342
362
  <td>
343
363
  <button class="pageChangedEvent">Page Change Event</button>
344
364
  </td>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetarchive/ia-book-actions",
3
- "version": "1.0.0",
3
+ "version": "1.1.0-alpha1",
4
4
  "description": "Bookreader actions for borrowable book",
5
5
  "author": "Internet Archive",
6
6
  "license": "AGPL-3.0-only",
@@ -23,7 +23,9 @@
23
23
  "@internetarchive/modal-manager": "^0.2.12",
24
24
  "@internetarchive/shared-resize-observer": "^0.2.0",
25
25
  "@internetarchive/toast-manager": "0.1.0",
26
- "lit": "^2.5.0"
26
+ "install-deps": "^1.1.0",
27
+ "lit": "^2.5.0",
28
+ "playwright": "^1.43.1"
27
29
  },
28
30
  "devDependencies": {
29
31
  "@open-wc/eslint-config": "^4.2.0",
@@ -178,7 +178,7 @@ export class CollapsibleActionGroup extends ActionsHandler {
178
178
  get renderSecondaryActions() {
179
179
  if (!this.secondaryActions.length) return nothing;
180
180
 
181
- return this.secondaryActions.map(action => this.renderActionLink(action));
181
+ return this.secondaryActions.map(action => this.renderActionButton(action));
182
182
  }
183
183
 
184
184
  /**
@@ -207,8 +207,6 @@ export default class ActionsConfig {
207
207
  id: 'adminAccess',
208
208
  text: 'Admin Access',
209
209
  title: 'You have administrative privileges to read this book',
210
- url: '?admin=1',
211
- target: '_self',
212
210
  className: 'danger',
213
211
  analyticsEvent: {
214
212
  category: this.analyticsCategories.adminAccess,
@@ -115,6 +115,11 @@ export default class ActionsHandler extends LitElement {
115
115
  this.addEventListener('adminAccess', ({ detail }) => {
116
116
  const { category, action } = detail.event;
117
117
  this.loanAnanlytics?.sendEvent(category, action, this.identifier);
118
+
119
+ // keep existing params and add new one
120
+ const url = new URL(window.location.href);
121
+ url.searchParams.append('admin', 1);
122
+ window.location.search = url.search;
118
123
  });
119
124
 
120
125
  this.addEventListener('exitAdminAccess', ({ detail }) => {
@@ -403,10 +403,7 @@ export default class IABookActions extends LitElement {
403
403
  ></ia-activity-indicator>`
404
404
  : 'Keep reading'}
405
405
  </button>
406
- <span
407
- style="position: absolute; visibility: none; height: 1px; width: 1px; overflow: hidden;"
408
- >Renewing loan, one moment please.</span
409
- >
406
+ <span class="sr-only">Renewing loan, one moment please.</span>
410
407
  <button
411
408
  disabled
412
409
  style="${modalButtonStyle.iaButton} ${modalButtonStyle.return}"
@@ -506,7 +503,7 @@ export default class IABookActions extends LitElement {
506
503
  }
507
504
 
508
505
  const config = new ToastConfig();
509
- config.dismisOnClick = true;
506
+ config.dismissOnClick = true;
510
507
  config.texts = this.loanRenewHelper?.getMessageTexts(
511
508
  this.loanRenewResult.texts,
512
509
  secondsLeft
@@ -988,6 +985,17 @@ export default class IABookActions extends LitElement {
988
985
  --toastBGColor: #333;
989
986
  --toastFontColor: #fff;
990
987
  }
988
+
989
+ .sr-only {
990
+ position: absolute;
991
+ left: -9999px;
992
+ width: 1px;
993
+ height: 1px;
994
+ margin: 0;
995
+ padding: 0;
996
+ border: none;
997
+ overflow: hidden;
998
+ }
991
999
  `;
992
1000
  }
993
1001
  }
@@ -421,7 +421,7 @@ describe('Auto renew one hour loan', () => {
421
421
  // timer-countdown reflects decreased loan time
422
422
  expect(el.timerCountdownEl.secondsLeftOnLoan).to.equal(8);
423
423
 
424
- expect(el.postInitComplete).to.equal(33);
424
+ expect(el.postInitComplete).to.equal(false);
425
425
 
426
426
  // dispatch loanAutoRenewed event - test 200 callback
427
427
  const collapsibleActionGroupEl = el.shadowRoot.querySelector(
@@ -445,7 +445,7 @@ describe('Auto renew one hour loan', () => {
445
445
  expect(el.loanRenewResult.renewNow).to.equal(true);
446
446
  expect(el.loanRenewResult.secondsLeft).to.equal(10);
447
447
  expect(el.timerCountdownEl).to.exist;
448
- expect(el.timerCountdownEl.secondsLeftOnLoan).to.equal(loanTime);
448
+ expect(el.timerCountdownEl.secondsLeftOnLoan).to.equal(8);
449
449
  });
450
450
  });
451
451