@internetarchive/ia-book-actions 0.0.29-beta1 → 0.0.29-beta2
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
|
@@ -134,6 +134,25 @@
|
|
|
134
134
|
});
|
|
135
135
|
});
|
|
136
136
|
|
|
137
|
+
document.querySelectorAll('.searchParam input[type=checkbox]').forEach((item) => {
|
|
138
|
+
item.addEventListener('click', (e) => {
|
|
139
|
+
var searchParams = new URLSearchParams(window.location.search);
|
|
140
|
+
var separate = '';
|
|
141
|
+
if (e.target.checked) {
|
|
142
|
+
separate = '?';
|
|
143
|
+
searchParams.set('q', 'test');
|
|
144
|
+
} else {
|
|
145
|
+
separate = '';
|
|
146
|
+
searchParams.delete('q');
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (history.pushState) {
|
|
150
|
+
var newurl = window.location.protocol + "//" + window.location.host + window.location.pathname + separate + searchParams;
|
|
151
|
+
window.history.pushState({path:newurl},'',newurl);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
|
|
137
156
|
document.querySelectorAll('.errorEnable input[type=checkbox]').forEach((item) => {
|
|
138
157
|
if (window.location.href.indexOf('?error=true') !== -1) {
|
|
139
158
|
item.checked = true;
|
|
@@ -263,6 +282,9 @@
|
|
|
263
282
|
<td class="titleBar">
|
|
264
283
|
<label><input type="checkbox" name="title" value="title" />Title Bar</label>
|
|
265
284
|
</td>
|
|
285
|
+
<td class="searchParam">
|
|
286
|
+
<label><input type="checkbox" name="search" value="Search Param" />Search Param</label>
|
|
287
|
+
</td>
|
|
266
288
|
</tr>
|
|
267
289
|
</table>
|
|
268
290
|
</fieldset>
|
package/package.json
CHANGED
|
@@ -147,7 +147,7 @@ export class CollapsibleActionGroup extends ActionsHandler {
|
|
|
147
147
|
get renderSecondaryActions() {
|
|
148
148
|
if (!this.secondaryActions.length) return nothing;
|
|
149
149
|
|
|
150
|
-
return this.secondaryActions.map(action => this.
|
|
150
|
+
return this.secondaryActions.map(action => this.renderActionButton(action));
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
/**
|
|
@@ -202,16 +202,10 @@ export default class ActionsConfig {
|
|
|
202
202
|
if (this.lendingStatus.user_has_borrowed || !this.lendingStatus.isAdmin)
|
|
203
203
|
return null;
|
|
204
204
|
|
|
205
|
-
// keep existing params and add new one
|
|
206
|
-
const url = new URL(window.location.href);
|
|
207
|
-
url.searchParams.append('admin', 1);
|
|
208
|
-
|
|
209
205
|
return {
|
|
210
206
|
id: 'adminAccess',
|
|
211
207
|
text: 'Admin Access',
|
|
212
208
|
title: 'You have administrative privileges to read this book',
|
|
213
|
-
url: url.search,
|
|
214
|
-
target: '_self',
|
|
215
209
|
className: 'danger',
|
|
216
210
|
analyticsEvent: {
|
|
217
211
|
category: this.analyticsCategories.adminAccess,
|
|
@@ -82,6 +82,11 @@ export default class ActionsHandler extends LitElement {
|
|
|
82
82
|
this.addEventListener('adminAccess', ({ detail }) => {
|
|
83
83
|
const { category, action } = detail.event;
|
|
84
84
|
this.sendEvent(category, action);
|
|
85
|
+
|
|
86
|
+
// keep existing params and add new one
|
|
87
|
+
const url = new URL(window.location.href);
|
|
88
|
+
url.searchParams.append('admin', 1);
|
|
89
|
+
window.location.search = url.search;
|
|
85
90
|
});
|
|
86
91
|
|
|
87
92
|
this.addEventListener('exitAdminAccess', ({ detail }) => {
|