@internetarchive/ia-item-navigator 2.1.1-alpha3 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- package/demo/app-root.ts +2 -2
- package/dist/demo/app-root.js +2 -2
- package/dist/demo/app-root.js.map +1 -1
- package/dist/src/iaux-item-navigator.js.map +1 -1
- package/dist/src/loader.d.ts +4 -4
- package/dist/src/menu-slider/ia-menu-slider.d.ts +4 -4
- package/dist/src/menu-slider/ia-menu-slider.js.map +1 -1
- package/dist/src/menu-slider/menu-button.d.ts +4 -4
- package/dist/src/menus/share-panel.d.ts +14 -7
- package/dist/src/menus/share-panel.js +113 -89
- package/dist/src/menus/share-panel.js.map +1 -1
- package/dist/src/menus/viewable-files.js +5 -1
- package/dist/src/menus/viewable-files.js.map +1 -1
- package/dist/src/no-theater-available.js.map +1 -1
- package/dist/test/iaux-sharing-options.test.js +5 -13
- package/dist/test/iaux-sharing-options.test.js.map +1 -1
- package/package.json +1 -1
- package/src/menus/share-panel.ts +126 -99
- package/src/menus/viewable-files.ts +5 -1
- package/test/iaux-sharing-options.test.ts +4 -21
- package/dist/src/menus/share-providers/email.d.ts +0 -11
- package/dist/src/menus/share-providers/email.js +0 -15
- package/dist/src/menus/share-providers/email.js.map +0 -1
- package/dist/src/menus/share-providers/facebook.d.ts +0 -11
- package/dist/src/menus/share-providers/facebook.js +0 -15
- package/dist/src/menus/share-providers/facebook.js.map +0 -1
- package/dist/src/menus/share-providers/pinterest.d.ts +0 -11
- package/dist/src/menus/share-providers/pinterest.js +0 -15
- package/dist/src/menus/share-providers/pinterest.js.map +0 -1
- package/dist/src/menus/share-providers/provider.d.ts +0 -20
- package/dist/src/menus/share-providers/provider.js +0 -37
- package/dist/src/menus/share-providers/provider.js.map +0 -1
- package/dist/src/menus/share-providers/share-provider-interface.d.ts +0 -13
- package/dist/src/menus/share-providers/share-provider-interface.js +0 -2
- package/dist/src/menus/share-providers/share-provider-interface.js.map +0 -1
- package/dist/src/menus/share-providers/tumblr.d.ts +0 -11
- package/dist/src/menus/share-providers/tumblr.js +0 -15
- package/dist/src/menus/share-providers/tumblr.js.map +0 -1
- package/dist/src/menus/share-providers/twitter.d.ts +0 -11
- package/dist/src/menus/share-providers/twitter.js +0 -15
- package/dist/src/menus/share-providers/twitter.js.map +0 -1
- package/src/menus/share-providers/email.ts +0 -23
- package/src/menus/share-providers/facebook.ts +0 -23
- package/src/menus/share-providers/pinterest.ts +0 -23
- package/src/menus/share-providers/provider.ts +0 -63
- package/src/menus/share-providers/share-provider-interface.ts +0 -17
- package/src/menus/share-providers/tumblr.ts +0 -23
- package/src/menus/share-providers/twitter.ts +0 -23
- package/test/ia-sharing-options.test.js +0 -78
@@ -1,23 +0,0 @@
|
|
1
|
-
import '@internetarchive/icon-facebook/icon-facebook';
|
2
|
-
import { TemplateResult, html } from 'lit';
|
3
|
-
import Provider from './provider';
|
4
|
-
import type { ProviderParams } from './share-provider-interface';
|
5
|
-
|
6
|
-
export default class extends Provider {
|
7
|
-
name: string;
|
8
|
-
|
9
|
-
icon: TemplateResult;
|
10
|
-
|
11
|
-
class: string;
|
12
|
-
|
13
|
-
constructor(params: ProviderParams) {
|
14
|
-
super(params);
|
15
|
-
this.name = 'Facebook';
|
16
|
-
this.icon = html`<ia-icon-facebook></ia-icon-facebook>`;
|
17
|
-
this.class = 'facebook';
|
18
|
-
}
|
19
|
-
|
20
|
-
override get url(): string {
|
21
|
-
return `https://www.facebook.com/sharer/sharer.php?u=https://${this.baseHost}/details/${this.itemPath}`;
|
22
|
-
}
|
23
|
-
}
|
@@ -1,23 +0,0 @@
|
|
1
|
-
import '@internetarchive/icon-pinterest/icon-pinterest';
|
2
|
-
import { TemplateResult, html } from 'lit';
|
3
|
-
import Provider from './provider';
|
4
|
-
import { ProviderParams } from './share-provider-interface';
|
5
|
-
|
6
|
-
export default class extends Provider {
|
7
|
-
name: string;
|
8
|
-
|
9
|
-
icon: TemplateResult;
|
10
|
-
|
11
|
-
class: string;
|
12
|
-
|
13
|
-
constructor(params: ProviderParams) {
|
14
|
-
super(params);
|
15
|
-
this.name = 'Pinterest';
|
16
|
-
this.icon = html`<ia-icon-pinterest></ia-icon-pinterest>`;
|
17
|
-
this.class = 'pinterest';
|
18
|
-
}
|
19
|
-
|
20
|
-
override get url(): string {
|
21
|
-
return `http://www.pinterest.com/pin/create/button/?url=https://${this.baseHost}/details/${this.itemPath}&description=${this.encodedDescription}+%3A+${this.encodedCreator}${this.encodedPromoCopy}`;
|
22
|
-
}
|
23
|
-
}
|
@@ -1,63 +0,0 @@
|
|
1
|
-
import { TemplateResult } from 'lit';
|
2
|
-
import { ProviderParams } from './share-provider-interface';
|
3
|
-
|
4
|
-
export default class Provider {
|
5
|
-
promoCopy: string;
|
6
|
-
|
7
|
-
description: string;
|
8
|
-
|
9
|
-
creator: string;
|
10
|
-
|
11
|
-
fileSubPrefix: string;
|
12
|
-
|
13
|
-
identifier: string;
|
14
|
-
|
15
|
-
baseHost: string;
|
16
|
-
|
17
|
-
name: string | undefined;
|
18
|
-
|
19
|
-
icon: TemplateResult | string | undefined;
|
20
|
-
|
21
|
-
class: string | undefined;
|
22
|
-
|
23
|
-
constructor(params: ProviderParams) {
|
24
|
-
this.promoCopy =
|
25
|
-
' : Free Download, Borrow, and Streaming : Internet Archive';
|
26
|
-
|
27
|
-
this.description = params?.description || '';
|
28
|
-
this.creator = params?.creator || '';
|
29
|
-
this.fileSubPrefix = params?.fileSubPrefix || '';
|
30
|
-
this.identifier = params?.identifier || '';
|
31
|
-
this.baseHost = params?.baseHost || '';
|
32
|
-
}
|
33
|
-
|
34
|
-
get encodedDescription(): string {
|
35
|
-
return this.encodeString(this.description);
|
36
|
-
}
|
37
|
-
|
38
|
-
get encodedCreator(): string {
|
39
|
-
return this.encodeString(this.creator);
|
40
|
-
}
|
41
|
-
|
42
|
-
get encodedPromoCopy(): string {
|
43
|
-
return this.encodeString(this.promoCopy);
|
44
|
-
}
|
45
|
-
|
46
|
-
get itemPath(): string {
|
47
|
-
const encodedFileSubPrefix = this.fileSubPrefix
|
48
|
-
? encodeURIComponent(this.fileSubPrefix)
|
49
|
-
: '';
|
50
|
-
return encodedFileSubPrefix
|
51
|
-
? `${this.identifier}/${encodedFileSubPrefix}`
|
52
|
-
: this.identifier;
|
53
|
-
}
|
54
|
-
|
55
|
-
get url(): string {
|
56
|
-
return `https://${this.baseHost}/details/${this.itemPath}`;
|
57
|
-
}
|
58
|
-
|
59
|
-
encodeString(str: string): string {
|
60
|
-
if (!str) return '';
|
61
|
-
return encodeURIComponent(str.replace(/\s/g, '+')).replace(/%2B/g, '+');
|
62
|
-
}
|
63
|
-
}
|
@@ -1,17 +0,0 @@
|
|
1
|
-
import { TemplateResult } from 'lit';
|
2
|
-
|
3
|
-
export type ProviderParams = {
|
4
|
-
class: string;
|
5
|
-
icon: TemplateResult | string;
|
6
|
-
name: string;
|
7
|
-
|
8
|
-
promoCopy: string;
|
9
|
-
description: string;
|
10
|
-
creator: string;
|
11
|
-
|
12
|
-
// ia item
|
13
|
-
fileSubPrefix: string;
|
14
|
-
identifier: string;
|
15
|
-
baseHost: string;
|
16
|
-
itemPath: string;
|
17
|
-
};
|
@@ -1,23 +0,0 @@
|
|
1
|
-
import '@internetarchive/icon-tumblr/icon-tumblr';
|
2
|
-
import { TemplateResult, html } from 'lit';
|
3
|
-
import Provider from './provider';
|
4
|
-
import { ProviderParams } from './share-provider-interface';
|
5
|
-
|
6
|
-
export default class extends Provider {
|
7
|
-
name: string;
|
8
|
-
|
9
|
-
icon: TemplateResult;
|
10
|
-
|
11
|
-
class: string;
|
12
|
-
|
13
|
-
constructor(params: ProviderParams) {
|
14
|
-
super(params);
|
15
|
-
this.name = 'Tumblr';
|
16
|
-
this.icon = html`<ia-icon-tumblr></ia-icon-tumblr>`;
|
17
|
-
this.class = 'tumblr';
|
18
|
-
}
|
19
|
-
|
20
|
-
override get url(): string {
|
21
|
-
return `https://www.tumblr.com/share/video?embed=%3Ciframe+width%3D%22640%22+height%3D%22480%22+frameborder%3D%220%22+allowfullscreen+src%3D%22https%3A%2F%2F${this.baseHost}%2Fembed%2F%22+webkitallowfullscreen%3D%22true%22+mozallowfullscreen%3D%22true%22%26gt%3B%26lt%3B%2Fiframe%3E&name=${this.encodedDescription}+%3A+${this.encodedCreator}${this.encodedPromoCopy}`;
|
22
|
-
}
|
23
|
-
}
|
@@ -1,23 +0,0 @@
|
|
1
|
-
import '@internetarchive/icon-twitter/icon-twitter';
|
2
|
-
import { TemplateResult, html } from 'lit';
|
3
|
-
import Provider from './provider';
|
4
|
-
import { ProviderParams } from './share-provider-interface';
|
5
|
-
|
6
|
-
export default class TwitterProvider extends Provider {
|
7
|
-
name: string;
|
8
|
-
|
9
|
-
icon: TemplateResult;
|
10
|
-
|
11
|
-
class: string;
|
12
|
-
|
13
|
-
constructor(params: ProviderParams) {
|
14
|
-
super(params);
|
15
|
-
this.name = 'Twitter';
|
16
|
-
this.icon = html`<ia-icon-twitter></ia-icon-twitter>`;
|
17
|
-
this.class = 'twitter';
|
18
|
-
}
|
19
|
-
|
20
|
-
override get url(): string {
|
21
|
-
return `https://twitter.com/intent/tweet?url=https://${this.baseHost}/details/${this.itemPath}&via=internetarchive&text=${this.encodedDescription}+%3A+${this.encodedCreator}${this.encodedPromoCopy}`;
|
22
|
-
}
|
23
|
-
}
|
@@ -1,78 +0,0 @@
|
|
1
|
-
import { html, fixture, expect } from '@open-wc/testing';
|
2
|
-
import sinon from 'sinon';
|
3
|
-
import '../src/ia-sharing-options.js';
|
4
|
-
|
5
|
-
const identifier = 'goody';
|
6
|
-
const itemType = 'book';
|
7
|
-
const creator = 'Welsh, Charles';
|
8
|
-
const description = 'The history of Little Goody Two-Shoes : otherwise called Mrs. Margery Two-Shoes ... [1766 edition]';
|
9
|
-
|
10
|
-
const container = (optionalFileSubprefix = '') => (
|
11
|
-
html`<ia-sharing-options
|
12
|
-
identifier="${identifier}"
|
13
|
-
type="${itemType}"
|
14
|
-
creator="${creator}"
|
15
|
-
description="${description}"
|
16
|
-
baseHost="archive.org"
|
17
|
-
fileSubPrefix="${optionalFileSubprefix}"
|
18
|
-
></ia-sharing-options>`
|
19
|
-
);
|
20
|
-
|
21
|
-
describe('<ia-sharing-options>', () => {
|
22
|
-
afterEach(() => {
|
23
|
-
sinon.restore();
|
24
|
-
});
|
25
|
-
|
26
|
-
it('sets default properties', async () => {
|
27
|
-
const el = await fixture(container());
|
28
|
-
|
29
|
-
expect(el.identifier).to.equal(identifier);
|
30
|
-
expect(el.type).to.equal(itemType);
|
31
|
-
expect(el.creator).to.equal(creator);
|
32
|
-
expect(el.description).to.equal(description);
|
33
|
-
});
|
34
|
-
|
35
|
-
it('renders buttons for each sharing method', async () => {
|
36
|
-
const el = await fixture(container());
|
37
|
-
|
38
|
-
await el.updateComplete;
|
39
|
-
|
40
|
-
el.sharingOptions.forEach((option) => {
|
41
|
-
const button = el.shadowRoot.querySelector(`a.${option.class}`);
|
42
|
-
expect(button).to.exist;
|
43
|
-
expect(button.getAttribute('href')).to.equal(option.url);
|
44
|
-
});
|
45
|
-
});
|
46
|
-
|
47
|
-
it('toggles visibility of embed options', async () => {
|
48
|
-
const el = await fixture(container());
|
49
|
-
|
50
|
-
el.toggleEmbedOptions(new Event('click'));
|
51
|
-
await el.updateComplete;
|
52
|
-
|
53
|
-
expect(el.embedOptionsVisible).to.equal(true);
|
54
|
-
});
|
55
|
-
|
56
|
-
it('does not show internal header by default', async () => {
|
57
|
-
const el = await fixture(container());
|
58
|
-
expect(el.shadowRoot.querySelector('header')).to.be.null;
|
59
|
-
});
|
60
|
-
|
61
|
-
it('does shows internal header when requested', async () => {
|
62
|
-
const el = await fixture(container());
|
63
|
-
el.renderHeader = true;
|
64
|
-
await el.updateComplete;
|
65
|
-
expect(el.shadowRoot.querySelector('header')).to.not.be.null;
|
66
|
-
});
|
67
|
-
|
68
|
-
it('sets file subprefix to end of share URLs if present', async () => {
|
69
|
-
const optionalFileSubprefix = 'foo- bar - 123-';
|
70
|
-
const el = await fixture(container(optionalFileSubprefix));
|
71
|
-
|
72
|
-
el.sharingOptions.forEach((option) => {
|
73
|
-
if (option.name !== 'Tumblr') {
|
74
|
-
expect(option.url).to.contain(encodeURIComponent(optionalFileSubprefix));
|
75
|
-
}
|
76
|
-
});
|
77
|
-
});
|
78
|
-
});
|