@internetarchive/ia-item-navigator 0.0.0-a7 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +29 -19
- package/demo/app-root.ts +70 -41
- package/demo/index.html +1 -2
- package/dist/demo/app-root.d.ts +20 -9
- package/dist/demo/app-root.js +61 -36
- package/dist/demo/app-root.js.map +1 -1
- package/dist/src/interfaces/custom-theater-interface.d.ts +20 -0
- package/dist/src/interfaces/custom-theater-interface.js +2 -0
- package/dist/src/interfaces/custom-theater-interface.js.map +1 -0
- package/dist/src/interfaces/event-interfaces.d.ts +11 -21
- package/dist/src/interfaces/event-interfaces.js.map +1 -1
- package/dist/src/interfaces/menu-interfaces.d.ts +6 -7
- package/dist/src/interfaces/menu-interfaces.js.map +1 -1
- package/dist/src/interfaces/nav-controller-interface.d.ts +11 -6
- package/dist/src/interfaces/nav-controller-interface.js.map +1 -1
- package/dist/src/item-inspector/item-inspector.d.ts +0 -41
- package/dist/src/item-inspector/item-inspector.js +253 -222
- package/dist/src/item-inspector/item-inspector.js.map +1 -1
- package/dist/src/item-inspector/visual-mod-provider.d.ts +2 -0
- package/dist/src/item-inspector/visual-mod-provider.js +3 -0
- package/dist/src/item-inspector/visual-mod-provider.js.map +1 -1
- package/dist/src/item-navigator.d.ts +45 -30
- package/dist/src/item-navigator.js +113 -120
- package/dist/src/item-navigator.js.map +1 -1
- package/dist/src/loader.d.ts +5 -0
- package/dist/src/loader.js +8 -2
- package/dist/src/loader.js.map +1 -1
- package/dist/src/no-theater-available.d.ts +9 -0
- package/dist/src/no-theater-available.js +79 -0
- package/dist/src/no-theater-available.js.map +1 -0
- package/dist/test/book-nav-stub.d.ts +22 -0
- package/dist/test/book-nav-stub.js +49 -0
- package/dist/test/book-nav-stub.js.map +1 -0
- package/dist/test/ia-item-navigator.test.d.ts +2 -0
- package/dist/test/ia-item-navigator.test.js +317 -0
- package/dist/test/ia-item-navigator.test.js.map +1 -0
- package/dist/test/ia-stub-goody.d.ts +210 -0
- package/dist/test/ia-stub-goody.js +276 -0
- package/dist/test/ia-stub-goody.js.map +1 -0
- package/dist/test/ia-stub.d.ts +22 -0
- package/dist/test/ia-stub.js +35 -0
- package/dist/test/ia-stub.js.map +1 -0
- package/dist/test/no-theater-available.test.d.ts +1 -0
- package/dist/test/no-theater-available.test.js +27 -0
- package/dist/test/no-theater-available.test.js.map +1 -0
- package/package.json +4 -3
- package/src/interfaces/custom-theater-interface.ts +28 -0
- package/src/interfaces/event-interfaces.ts +15 -22
- package/src/interfaces/menu-interfaces.ts +9 -10
- package/src/item-navigator.ts +154 -151
- package/src/loader.ts +9 -2
- package/src/no-theater-available.ts +85 -0
- package/test/book-nav-stub.ts +47 -0
- package/test/ia-item-navigator.test.ts +438 -0
- package/test/ia-stub.ts +79 -0
- package/test/no-theater-available.test.ts +32 -0
- package/demo/demo-book-manifest.json +0 -1163
- package/src/interfaces/nav-controller-interface.ts +0 -18
- package/src/item-inspector/files-by-type/files-by-type-provider.ts +0 -43
- package/src/item-inspector/files-by-type/ia-files-by-type.ts +0 -100
- package/src/item-inspector/item-inspector.ts +0 -242
- package/src/item-inspector/share-provider.ts +0 -51
- package/src/item-inspector/visual-mod-provider.ts +0 -60
- package/src/item-navigator-js.js +0 -372
- package/test/your-webcomponent.test.ts +0 -40
@@ -1,18 +0,0 @@
|
|
1
|
-
import { LitElement } from 'lit-element';
|
2
|
-
import { MetadataResponse } from '@internetarchive/search-service';
|
3
|
-
import { IntMenuShortcut } from './menu-interfaces';
|
4
|
-
|
5
|
-
export interface IntNavController extends LitElement {
|
6
|
-
baseHost: string;
|
7
|
-
itemMD: MetadataResponse;
|
8
|
-
menuProviders: object;
|
9
|
-
menuShortcuts: IntMenuShortcut[];
|
10
|
-
sideMenuOpen: boolean;
|
11
|
-
|
12
|
-
emitLoadingStatusUpdate: (loaded: boolean) => void;
|
13
|
-
|
14
|
-
addMenuShortcut: (menuId: string) => void;
|
15
|
-
removeMenuShortcut: (menuId: string) => void;
|
16
|
-
sortMenuShortcuts: () => void;
|
17
|
-
emitMenuShortcutsUpdated: () => void;
|
18
|
-
}
|
@@ -1,43 +0,0 @@
|
|
1
|
-
import { html, TemplateResult } from 'lit-element';
|
2
|
-
|
3
|
-
import './ia-files-by-type';
|
4
|
-
import '@internetarchive/icon-share/icon-share';
|
5
|
-
import {
|
6
|
-
IntMenuProvider,
|
7
|
-
IntProviderArgs,
|
8
|
-
} from '../../interfaces/menu-interfaces';
|
9
|
-
|
10
|
-
export class FilesByTypeProvider implements IntMenuProvider {
|
11
|
-
item: any = null;
|
12
|
-
|
13
|
-
baseHost: string = 'https://archive.org';
|
14
|
-
|
15
|
-
icon: TemplateResult = html`<p
|
16
|
-
style="color: #fff; font-size: var(--iconHeight);"
|
17
|
-
>
|
18
|
-
F
|
19
|
-
</p>`;
|
20
|
-
|
21
|
-
id: string = 'filesByType';
|
22
|
-
|
23
|
-
label: string = 'Files by type';
|
24
|
-
|
25
|
-
component: TemplateResult | null = null;
|
26
|
-
|
27
|
-
subPrefix: string = '';
|
28
|
-
|
29
|
-
constructor(shareArgs: IntProviderArgs) {
|
30
|
-
const { item, baseHost, subPrefix = '' } = shareArgs;
|
31
|
-
const { title = '' } = item.metadata;
|
32
|
-
|
33
|
-
this.item = item;
|
34
|
-
this.baseHost = baseHost;
|
35
|
-
this.subPrefix = subPrefix;
|
36
|
-
|
37
|
-
this.component = html`<ia-files-by-type
|
38
|
-
.item=${this.item}
|
39
|
-
.description="${title}"
|
40
|
-
.baseHost="${this.baseHost}"
|
41
|
-
></ia-files-by-type>`;
|
42
|
-
}
|
43
|
-
}
|
@@ -1,100 +0,0 @@
|
|
1
|
-
import { MetadataResponse, File } from '@internetarchive/search-service';
|
2
|
-
import { html, customElement, LitElement, property } from 'lit-element';
|
3
|
-
|
4
|
-
interface CollapsedFileInt extends File {
|
5
|
-
[menuId: string]: any;
|
6
|
-
derivatives: [];
|
7
|
-
}
|
8
|
-
|
9
|
-
@customElement('ia-files-by-type')
|
10
|
-
export default class IaFilesByType extends LitElement {
|
11
|
-
@property({ type: Object }) item: MetadataResponse = {} as MetadataResponse;
|
12
|
-
|
13
|
-
@property({ type: Array }) archivalArtifacts: File[] = [];
|
14
|
-
|
15
|
-
@property({ type: Array }) collapsedFiles: CollapsedFileInt[] = [];
|
16
|
-
|
17
|
-
firstUpdated() {
|
18
|
-
this.collapseFiles();
|
19
|
-
}
|
20
|
-
|
21
|
-
render() {
|
22
|
-
return html`
|
23
|
-
<div>
|
24
|
-
<p>there are ${this.collapsedFiles.length} original files</p>
|
25
|
-
|
26
|
-
<p>there are ${this.archivalArtifacts.length} archival artifacts</p>
|
27
|
-
|
28
|
-
<p></p>
|
29
|
-
</div>
|
30
|
-
`;
|
31
|
-
}
|
32
|
-
|
33
|
-
sortByViewer() {
|
34
|
-
// const images = [];
|
35
|
-
// const books = [];
|
36
|
-
// const radio = [];
|
37
|
-
// const audio = [];
|
38
|
-
// const video = [];
|
39
|
-
// const albums = [];
|
40
|
-
// const software = [];
|
41
|
-
// this.collapsedFiles.forEach((fi) => {
|
42
|
-
// // if image
|
43
|
-
// // sort by various viewers
|
44
|
-
// })
|
45
|
-
|
46
|
-
return true;
|
47
|
-
}
|
48
|
-
|
49
|
-
collapseFiles() {
|
50
|
-
const { files = [] } = this?.item as MetadataResponse;
|
51
|
-
|
52
|
-
const archivalArtifacts: File[] = [];
|
53
|
-
const origDir: any = {};
|
54
|
-
|
55
|
-
files.forEach(fi => {
|
56
|
-
const { format, source, name, original = '' } = fi as File;
|
57
|
-
if (
|
58
|
-
format.toLowerCase() === 'metadata' ||
|
59
|
-
format.toLowerCase() === 'item tile'
|
60
|
-
) {
|
61
|
-
archivalArtifacts.push(fi);
|
62
|
-
return;
|
63
|
-
}
|
64
|
-
|
65
|
-
let origEntry: any = {};
|
66
|
-
if (source === 'original') {
|
67
|
-
origEntry = origDir[name];
|
68
|
-
if (!origEntry) {
|
69
|
-
// add new
|
70
|
-
origDir[name] = { ...fi, derivatives: [] } as CollapsedFileInt;
|
71
|
-
origEntry = origDir[name];
|
72
|
-
} else {
|
73
|
-
// update
|
74
|
-
const merged = { ...origEntry, ...fi };
|
75
|
-
origDir[name] = merged;
|
76
|
-
}
|
77
|
-
return;
|
78
|
-
}
|
79
|
-
|
80
|
-
if (source === 'derivative') {
|
81
|
-
const keyToFile = original || '';
|
82
|
-
origEntry = origDir[keyToFile];
|
83
|
-
if (!origEntry && original) {
|
84
|
-
// add new
|
85
|
-
const fileFrame = { derivatives: [] } as CollapsedFileInt;
|
86
|
-
origEntry = fileFrame;
|
87
|
-
origEntry?.derivatives.push(fi);
|
88
|
-
origDir[keyToFile] = origEntry;
|
89
|
-
origEntry = origDir[keyToFile];
|
90
|
-
}
|
91
|
-
origEntry?.derivatives.push(fi);
|
92
|
-
}
|
93
|
-
});
|
94
|
-
|
95
|
-
this.archivalArtifacts = archivalArtifacts;
|
96
|
-
this.collapsedFiles = Object.keys(origDir).map(
|
97
|
-
(fileName: string) => origDir[fileName]
|
98
|
-
);
|
99
|
-
}
|
100
|
-
}
|
@@ -1,242 +0,0 @@
|
|
1
|
-
/* eslint-disable no-console */
|
2
|
-
import {
|
3
|
-
css,
|
4
|
-
html,
|
5
|
-
LitElement,
|
6
|
-
customElement,
|
7
|
-
property,
|
8
|
-
state,
|
9
|
-
} from 'lit-element';
|
10
|
-
import { MetadataResponse } from '@internetarchive/search-service';
|
11
|
-
|
12
|
-
import { IntNavController } from '../interfaces/nav-controller-interface';
|
13
|
-
import {
|
14
|
-
IntMenuProvider,
|
15
|
-
IntMenuShortcut,
|
16
|
-
} from '../interfaces/menu-interfaces';
|
17
|
-
import { IntManageFullscreenEvent } from '../interfaces/event-interfaces';
|
18
|
-
|
19
|
-
import { ShareProvider } from './share-provider';
|
20
|
-
import { FilesByTypeProvider } from './files-by-type/files-by-type-provider';
|
21
|
-
import { VisualModsProvider } from './visual-mod-provider';
|
22
|
-
|
23
|
-
// eslint-disable-next-line no-shadow
|
24
|
-
enum ItemInspectorEvents {
|
25
|
-
menuUpdated = 'menuUpdated',
|
26
|
-
updateSideMenu = 'updateSideMenu',
|
27
|
-
PostInit = 'PostInit',
|
28
|
-
ViewportInFullScreen = 'ViewportInFullScreen',
|
29
|
-
}
|
30
|
-
|
31
|
-
interface menuProvidersInt {
|
32
|
-
[menuId: string]: IntMenuProvider;
|
33
|
-
}
|
34
|
-
|
35
|
-
@customElement('ia-item-inspector')
|
36
|
-
export class IaItemInspector extends LitElement implements IntNavController {
|
37
|
-
@property({ type: Object }) itemMD: MetadataResponse = {
|
38
|
-
metadata: {},
|
39
|
-
} as MetadataResponse;
|
40
|
-
|
41
|
-
@property({ type: String }) baseHost = 'https://archive.org';
|
42
|
-
|
43
|
-
@property({ type: Object }) menuProviders: menuProvidersInt = {};
|
44
|
-
|
45
|
-
@property({ type: Array }) menuShortcuts: IntMenuShortcut[] = [];
|
46
|
-
|
47
|
-
@property({ type: Boolean }) sideMenuOpen = false;
|
48
|
-
|
49
|
-
@property({ type: Boolean }) fullscreenState = false;
|
50
|
-
|
51
|
-
@state() fileCount: number = 0;
|
52
|
-
|
53
|
-
@state() loaded: boolean = false;
|
54
|
-
|
55
|
-
@state() private shortcutOrder = ['visualMods'];
|
56
|
-
|
57
|
-
firstUpdated() {
|
58
|
-
this.loaded = true;
|
59
|
-
}
|
60
|
-
|
61
|
-
updated(changed: any) {
|
62
|
-
if (changed.has('loaded')) {
|
63
|
-
setTimeout(() => this.emitLoadingStatusUpdate(this.loaded), 1000);
|
64
|
-
}
|
65
|
-
|
66
|
-
if (changed.has('itemMD') && this.itemMD) {
|
67
|
-
this.parseItemInfo();
|
68
|
-
this.setMenu();
|
69
|
-
}
|
70
|
-
|
71
|
-
if (changed.has('menuProviders') || changed.has('menuShortcuts')) {
|
72
|
-
this.updateMenuContents();
|
73
|
-
}
|
74
|
-
}
|
75
|
-
|
76
|
-
render() {
|
77
|
-
const { identifier = '' } = this.itemMD?.metadata;
|
78
|
-
return html`
|
79
|
-
<section>
|
80
|
-
<div>
|
81
|
-
<h2>${identifier}</h2>
|
82
|
-
</div>
|
83
|
-
<img src=${this.imageUrl} alt=${`${identifier} thumbnail`} />
|
84
|
-
<p style="font-size: 20px;">
|
85
|
-
Bacon ipsum dolor amet flank chicken leberkas sausage, meatball pork belly jowl. Chislic bacon salami frankfurter shankle drumstick andouille ball tip alcatra. Fatback beef ribs chicken, jerky ground round hamburger pork chop biltong. Shoulder short loin rump jerky kielbasa pork porchetta fatback ribeye pork belly sirloin chislic turducken corned beef tri-tip. Chuck pancetta meatball tail, spare ribs ham hock capicola pig. Ham hock hamburger chicken tri-tip venison swine burgdoggen boudin meatloaf pastrami chuck. Tri-tip spare ribs drumstick, tail rump hamburger burgdoggen swine t-bone tongue andouille chislic alcatra.
|
86
|
-
|
87
|
-
Pork loin jowl frankfurter, doner meatball short loin ham hock filet mignon hamburger rump turkey bresaola shoulder sirloin flank. Ribeye sausage pig t-bone bacon frankfurter cupim capicola fatback pastrami ball tip pork belly. Picanha pancetta andouille flank shankle venison tri-tip tail, kevin turkey turducken chicken. Bacon picanha swine frankfurter, prosciutto chislic doner alcatra pork loin corned beef jowl biltong meatball chuck. Bacon burgdoggen pig fatback cupim t-bone. Cow pork loin bresaola brisket shoulder filet mignon chicken. Sirloin bresaola porchetta beef capicola meatloaf brisket shankle jerky turkey pork tri-tip swine kevin salami.
|
88
|
-
|
89
|
-
Meatball t-bone doner venison. Pig tri-tip chuck, shank chicken pork chop landjaeger spare ribs jerky swine ham hock buffalo sirloin. Leberkas pancetta tenderloin, meatloaf buffalo rump pastrami chuck. Jerky cupim porchetta, tenderloin chuck andouille venison pork salami. Chuck strip steak cupim, turducken ham hock kielbasa shoulder porchetta chislic short loin tri-tip biltong cow corned beef.
|
90
|
-
</p>
|
91
|
-
</section>
|
92
|
-
`;
|
93
|
-
}
|
94
|
-
|
95
|
-
addMenuShortcut(menuId: keyof menuProvidersInt) {
|
96
|
-
if (this.menuShortcuts.find(m => m.id === menuId)) {
|
97
|
-
return;
|
98
|
-
}
|
99
|
-
|
100
|
-
const shortcut = this.menuProviders[menuId];
|
101
|
-
this.menuShortcuts.push(shortcut);
|
102
|
-
this.sortMenuShortcuts();
|
103
|
-
this.emitMenuShortcutsUpdated();
|
104
|
-
}
|
105
|
-
|
106
|
-
/**
|
107
|
-
* Removes a provider object from the menuShortcuts array and emits a
|
108
|
-
* menuShortcutsUpdated event.
|
109
|
-
*/
|
110
|
-
removeMenuShortcut(menuId: string) {
|
111
|
-
this.menuShortcuts = this.menuShortcuts.filter(m => m.id !== menuId);
|
112
|
-
this.emitMenuShortcutsUpdated();
|
113
|
-
}
|
114
|
-
|
115
|
-
/**
|
116
|
-
* Sorts the menuShortcuts property by comparing each provider's id to
|
117
|
-
* the id in each iteration over the shortcutOrder array.
|
118
|
-
*/
|
119
|
-
sortMenuShortcuts() {
|
120
|
-
this.menuShortcuts = this.shortcutOrder.reduce(
|
121
|
-
(shortcuts: IntMenuShortcut[], id) => {
|
122
|
-
const menu = this.menuShortcuts.find(m => m.id === id);
|
123
|
-
|
124
|
-
// eslint-disable-next-line no-param-reassign
|
125
|
-
if (menu) {
|
126
|
-
const newShortcuts = [...shortcuts, menu];
|
127
|
-
// eslint-disable-next-line no-param-reassign
|
128
|
-
shortcuts = newShortcuts;
|
129
|
-
}
|
130
|
-
return shortcuts;
|
131
|
-
},
|
132
|
-
[]
|
133
|
-
);
|
134
|
-
}
|
135
|
-
|
136
|
-
emitMenuShortcutsUpdated() {
|
137
|
-
const event = new CustomEvent('menuShortcutsUpdated', {
|
138
|
-
detail: this.menuShortcuts,
|
139
|
-
});
|
140
|
-
this.dispatchEvent(event);
|
141
|
-
}
|
142
|
-
|
143
|
-
setMenu() {
|
144
|
-
const menuProviders = {
|
145
|
-
share: new ShareProvider({
|
146
|
-
item: this.itemMD,
|
147
|
-
baseHost: this.baseHost,
|
148
|
-
subPrefix: '',
|
149
|
-
}),
|
150
|
-
filesByType: new FilesByTypeProvider({
|
151
|
-
item: this.itemMD,
|
152
|
-
baseHost: this.baseHost,
|
153
|
-
subPrefix: '',
|
154
|
-
}),
|
155
|
-
visualMods: new VisualModsProvider({
|
156
|
-
updated: (modType: string) => {
|
157
|
-
if (modType === 'toggleFullscreen') {
|
158
|
-
this.updateFullscreenState();
|
159
|
-
}
|
160
|
-
},
|
161
|
-
item: this.itemMD,
|
162
|
-
baseHost: this.baseHost,
|
163
|
-
subPrefix: '',
|
164
|
-
// maybe DOM root for class configs?
|
165
|
-
}),
|
166
|
-
};
|
167
|
-
|
168
|
-
this.menuProviders = menuProviders;
|
169
|
-
this.addMenuShortcut('visualMods');
|
170
|
-
}
|
171
|
-
|
172
|
-
updateFullscreenState() {
|
173
|
-
const isFullScreen = !this.fullscreenState;
|
174
|
-
this.fullscreenState = isFullScreen;
|
175
|
-
|
176
|
-
const event = new CustomEvent('ViewportInFullScreen', {
|
177
|
-
detail: { isFullScreen },
|
178
|
-
} as IntManageFullscreenEvent);
|
179
|
-
this.dispatchEvent(event);
|
180
|
-
}
|
181
|
-
|
182
|
-
updateMenuContents() {
|
183
|
-
const { share, filesByType, visualMods } = this.menuProviders;
|
184
|
-
const availableMenus = [filesByType, share, visualMods].filter(
|
185
|
-
menu => !!menu
|
186
|
-
);
|
187
|
-
|
188
|
-
const event = new CustomEvent(ItemInspectorEvents.menuUpdated, {
|
189
|
-
detail: availableMenus,
|
190
|
-
});
|
191
|
-
|
192
|
-
this.dispatchEvent(event);
|
193
|
-
}
|
194
|
-
|
195
|
-
emitLoadingStatusUpdate(loaded: boolean) {
|
196
|
-
const event = new CustomEvent('loadingStateUpdated', {
|
197
|
-
detail: { loaded },
|
198
|
-
});
|
199
|
-
this.dispatchEvent(event);
|
200
|
-
}
|
201
|
-
|
202
|
-
parseItemInfo() {
|
203
|
-
this.fileCount = this.itemMD?.files?.length || 0;
|
204
|
-
}
|
205
|
-
|
206
|
-
get imageUrl() {
|
207
|
-
const { metadata = {} } = this.itemMD;
|
208
|
-
const url = `${this.baseHost}/download/${metadata?.identifier}/__ia_thumb.jpg`;
|
209
|
-
return url;
|
210
|
-
}
|
211
|
-
|
212
|
-
static get styles() {
|
213
|
-
const main = css`
|
214
|
-
:host {
|
215
|
-
display: block;
|
216
|
-
width: 100%;
|
217
|
-
margin: 0 auto;
|
218
|
-
position: relative;
|
219
|
-
overflow: auto;
|
220
|
-
background-color: black;
|
221
|
-
color: var(--primaryTextColor, #fff);
|
222
|
-
}
|
223
|
-
|
224
|
-
:host,
|
225
|
-
section {
|
226
|
-
min-height: inherit;
|
227
|
-
height: inherit;
|
228
|
-
}
|
229
|
-
|
230
|
-
section {
|
231
|
-
margin: auto;
|
232
|
-
width: 100%;
|
233
|
-
text-align: center;
|
234
|
-
}
|
235
|
-
|
236
|
-
img {
|
237
|
-
border: 1px solid var(--primaryTextColor, #fff);
|
238
|
-
}
|
239
|
-
`;
|
240
|
-
return [main];
|
241
|
-
}
|
242
|
-
}
|
@@ -1,51 +0,0 @@
|
|
1
|
-
import { html, TemplateResult } from 'lit-element';
|
2
|
-
|
3
|
-
import '@internetarchive/ia-sharing-options';
|
4
|
-
import '@internetarchive/icon-share/icon-share';
|
5
|
-
import {
|
6
|
-
IntMenuProvider,
|
7
|
-
IntProviderArgs,
|
8
|
-
} from '../interfaces/menu-interfaces';
|
9
|
-
|
10
|
-
export class ShareProvider implements IntMenuProvider {
|
11
|
-
item: any = null;
|
12
|
-
|
13
|
-
baseHost: string = 'https://archive.org';
|
14
|
-
|
15
|
-
icon: TemplateResult = html`<ia-icon-share
|
16
|
-
style="width: var(--iconWidth); height: var(--iconHeight);"
|
17
|
-
></ia-icon-share>`;
|
18
|
-
|
19
|
-
id: string = 'share';
|
20
|
-
|
21
|
-
label: string = 'Share this item';
|
22
|
-
|
23
|
-
component: TemplateResult | null = null;
|
24
|
-
|
25
|
-
subPrefix: string = '';
|
26
|
-
|
27
|
-
encodedSubPrefix: string = '';
|
28
|
-
|
29
|
-
constructor(shareArgs: IntProviderArgs) {
|
30
|
-
const { item, baseHost, subPrefix = '' } = shareArgs;
|
31
|
-
const { identifier = '', creator = '', title = '' } = item.metadata || {};
|
32
|
-
const encodedSubPrefix = encodeURIComponent(subPrefix);
|
33
|
-
const urlIdentifier =
|
34
|
-
subPrefix && subPrefix !== identifier
|
35
|
-
? `${identifier}/${encodedSubPrefix}`
|
36
|
-
: identifier;
|
37
|
-
|
38
|
-
this.item = item;
|
39
|
-
this.baseHost = baseHost;
|
40
|
-
this.subPrefix = subPrefix;
|
41
|
-
this.encodedSubPrefix = encodedSubPrefix;
|
42
|
-
|
43
|
-
this.component = html`<ia-sharing-options
|
44
|
-
identifier=${urlIdentifier}
|
45
|
-
type="item"
|
46
|
-
creator="${creator}"
|
47
|
-
description="${title}"
|
48
|
-
baseHost="${this.baseHost}"
|
49
|
-
></ia-sharing-options>`;
|
50
|
-
}
|
51
|
-
}
|
@@ -1,60 +0,0 @@
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
2
|
-
/* eslint-disable max-classes-per-file */
|
3
|
-
|
4
|
-
import { html, TemplateResult, customElement, LitElement } from 'lit-element';
|
5
|
-
|
6
|
-
import '@internetarchive/ia-sharing-options';
|
7
|
-
import '@internetarchive/icon-visual-adjustment/icon-visual-adjustment';
|
8
|
-
import {
|
9
|
-
IntMenuProvider,
|
10
|
-
IntProviderArgs,
|
11
|
-
} from '../interfaces/menu-interfaces';
|
12
|
-
|
13
|
-
@customElement('ia-visual-mods')
|
14
|
-
class VisualMods extends LitElement {
|
15
|
-
toggleFullscreen() {
|
16
|
-
this.dispatchEvent(new Event('fullscreenToggle'));
|
17
|
-
}
|
18
|
-
|
19
|
-
render() {
|
20
|
-
return html`<section>
|
21
|
-
<button @click=${this.toggleFullscreen}>Toggle Fullscreen</button>
|
22
|
-
</section>`;
|
23
|
-
}
|
24
|
-
}
|
25
|
-
|
26
|
-
export class VisualModsProvider implements IntMenuProvider {
|
27
|
-
item: any = null;
|
28
|
-
|
29
|
-
baseHost: string = 'https://archive.org';
|
30
|
-
|
31
|
-
icon: TemplateResult = html`<ia-icon-visual-adjustment
|
32
|
-
style="width: var(--iconWidth); height: var(--iconHeight);"
|
33
|
-
></ia-icon-visual-adjustment>`;
|
34
|
-
|
35
|
-
id: string = 'visualMods';
|
36
|
-
|
37
|
-
label: string = 'Visual Modifications';
|
38
|
-
|
39
|
-
component: TemplateResult | null = null;
|
40
|
-
|
41
|
-
subPrefix: string = '';
|
42
|
-
|
43
|
-
encodedSubPrefix: string = '';
|
44
|
-
|
45
|
-
updated: any = () => {};
|
46
|
-
|
47
|
-
constructor(providerArgs: IntProviderArgs) {
|
48
|
-
const { item, baseHost, subPrefix = '', updated } = providerArgs;
|
49
|
-
|
50
|
-
this.updated = updated;
|
51
|
-
|
52
|
-
this.component = html`<ia-visual-mods
|
53
|
-
@fullscreenToggle=${() => this?.updated('toggleFullscreen')}
|
54
|
-
></ia-visual-mods>`;
|
55
|
-
}
|
56
|
-
|
57
|
-
toggleFullscreen() {
|
58
|
-
this.updated('toggleFullscreen');
|
59
|
-
}
|
60
|
-
}
|