@internetarchive/ia-item-navigator 0.0.0-a8 → 0.0.2-a1
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 +50 -50
- package/demo/index.html +1 -0
- package/dist/demo/app-root.d.ts +19 -15
- package/dist/demo/app-root.js +36 -39
- 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 -11
- 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 -47
- package/dist/src/item-inspector/item-inspector.js +253 -270
- package/dist/src/item-inspector/item-inspector.js.map +1 -1
- package/dist/src/item-navigator.d.ts +45 -28
- package/dist/src/item-navigator.js +122 -115
- 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 -11
- package/src/interfaces/menu-interfaces.ts +9 -10
- package/src/item-navigator.ts +165 -145
- 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 -295
- package/src/item-inspector/share-provider.ts +0 -51
- package/src/item-inspector/visual-mod-provider.ts +0 -65
- package/src/item-navigator-js.js +0 -372
- package/test/your-webcomponent.test.ts +0 -40
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"item-inspector.js","sourceRoot":"","sources":["../../../src/item-inspector/item-inspector.ts"],"names":[],"mappings":";AAAA,+BAA+B;AAC/B,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,EACV,aAAa,EACb,QAAQ,EACR,KAAK,GACN,MAAM,aAAa,CAAC;AAGrB,OAAO,EAEL,WAAW,GACZ,MAAM,gCAAgC,CAAC;AASxC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,qCAAqC;AACrC,IAAK,mBAKJ;AALD,WAAK,mBAAmB;IACtB,kDAA2B,CAAA;IAC3B,wDAAiC,CAAA;IACjC,4CAAqB,CAAA;IACrB,oEAA6C,CAAA;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AQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,UAAU,iBAAiB,CAAC;QAC/E,OAAO,GAAG,CAAC;IACb,CAAC;IAED,MAAM,KAAK,MAAM;QACf,MAAM,IAAI,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;KA0Bf,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC;CACF,CAAA;AA7P6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CAEL;AAEM;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDAAkC;AAEjC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sDAAsC;AAEtC;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;sDAAuC;AAEpC;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;qDAAsB;AAErB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wDAAyB;AAErB;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;8CAA+B;AAE9B;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;iDAA0C;AAEhE;IAAR,KAAK,EAAE;kDAAuB;AAEtB;IAAR,KAAK,EAAE;+CAAyB;AAExB;IAAR,KAAK,EAAE;sDAAwC;AAvBrC,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CA8P3B;SA9PY,eAAe","sourcesContent":["/* eslint-disable no-console */\nimport {\n css,\n html,\n LitElement,\n customElement,\n property,\n state,\n} from 'lit-element';\nimport { MetadataResponse } from '@internetarchive/search-service';\n\nimport {\n ModalManagerInterface,\n ModalConfig,\n} from '@internetarchive/modal-manager';\nimport { SharedResizeObserverInterface } from '@internetarchive/shared-resize-observer';\nimport { IntNavController } from '../interfaces/nav-controller-interface';\nimport {\n IntMenuProvider,\n IntMenuShortcut,\n} from '../interfaces/menu-interfaces';\nimport { IntManageFullscreenEvent } from '../interfaces/event-interfaces';\n\nimport { ShareProvider } from './share-provider';\nimport { FilesByTypeProvider } from './files-by-type/files-by-type-provider';\nimport { VisualModsProvider } from './visual-mod-provider';\n\n// eslint-disable-next-line no-shadow\nenum ItemInspectorEvents {\n menuUpdated = 'menuUpdated',\n updateSideMenu = 'updateSideMenu',\n PostInit = 'PostInit',\n ViewportInFullScreen = 'ViewportInFullScreen',\n}\n\ninterface menuProvidersInt {\n [menuId: string]: IntMenuProvider;\n}\n\n@customElement('ia-item-inspector')\nexport class IaItemInspector extends LitElement implements IntNavController {\n @property({ type: Object }) itemMD: MetadataResponse = {\n metadata: {},\n } as MetadataResponse;\n\n @property({ type: String }) baseHost = 'https://archive.org';\n\n @property({ type: Object }) menuProviders: menuProvidersInt = {};\n\n @property({ type: Array }) menuShortcuts: IntMenuShortcut[] = [];\n\n @property({ type: Boolean }) sideMenuOpen = false;\n\n @property({ type: Boolean }) fullscreenState = false;\n\n @property({ attribute: false }) modal!: ModalManagerInterface;\n\n @property({ attribute: false }) sharedRO!: SharedResizeObserverInterface;\n\n @state() fileCount: number = 0;\n\n @state() loaded: boolean = false;\n\n @state() private shortcutOrder = ['visualMods'];\n\n firstUpdated() {\n this.loaded = true;\n console.log('modal', this.modal);\n }\n\n updated(changed: any) {\n if (changed.has('loaded')) {\n setTimeout(() => this.emitLoadingStatusUpdate(this.loaded), 1000);\n }\n\n if (changed.has('itemMD') && this.itemMD) {\n this.parseItemInfo();\n this.setMenu();\n }\n\n if (changed.has('menuProviders') || changed.has('menuShortcuts')) {\n this.updateMenuContents();\n }\n }\n\n modalClosedCallback() {\n console.log('item-inspector, modal closed');\n }\n\n openModal() {\n const config = new ModalConfig();\n const customModalContent = html`\n Can contain any markup, including web components. Event listeners also\n work. Try clicking on the picture.\n <div style=\"text-align: center\">\n <a href=\"https://fillmurray.com\" style=\"display: block\">Fill Murray</a>\n <img src=\"100x100.jpg\" alt=\"foo\" />\n </div>\n `;\n\n this.modal.showModal({\n config,\n customModalContent,\n userClosedModalCallback: this.modalClosedCallback,\n });\n }\n\n render() {\n const { identifier = '' } = this.itemMD?.metadata;\n return html`\n <section>\n <div>\n <h2>${identifier}</h2>\n </div>\n <img src=${this.imageUrl} alt=${`${identifier} thumbnail`} />\n <button @click=${() => this.openModal()}>open modal</button>\n <p style=\"font-size: 20px;\">\n Bacon ipsum dolor amet flank chicken leberkas sausage, meatball pork\n belly jowl. Chislic bacon salami frankfurter shankle drumstick\n andouille ball tip alcatra. Fatback beef ribs chicken, jerky ground\n round hamburger pork chop biltong. Shoulder short loin rump jerky\n kielbasa pork porchetta fatback ribeye pork belly sirloin chislic\n turducken corned beef tri-tip. Chuck pancetta meatball tail, spare\n ribs ham hock capicola pig. Ham hock hamburger chicken tri-tip venison\n swine burgdoggen boudin meatloaf pastrami chuck. Tri-tip spare ribs\n drumstick, tail rump hamburger burgdoggen swine t-bone tongue\n andouille chislic alcatra. Pork loin jowl frankfurter, doner meatball\n short loin ham hock filet mignon hamburger rump turkey bresaola\n shoulder sirloin flank. Ribeye sausage pig t-bone bacon frankfurter\n cupim capicola fatback pastrami ball tip pork belly. Picanha pancetta\n andouille flank shankle venison tri-tip tail, kevin turkey turducken\n chicken. Bacon picanha swine frankfurter, prosciutto chislic doner\n alcatra pork loin corned beef jowl biltong meatball chuck. Bacon\n burgdoggen pig fatback cupim t-bone. Cow pork loin bresaola brisket\n shoulder filet mignon chicken. Sirloin bresaola porchetta beef\n capicola meatloaf brisket shankle jerky turkey pork tri-tip swine\n kevin salami. Meatball t-bone doner venison. Pig tri-tip chuck, shank\n chicken pork chop landjaeger spare ribs jerky swine ham hock buffalo\n sirloin. Leberkas pancetta tenderloin, meatloaf buffalo rump pastrami\n chuck. Jerky cupim porchetta, tenderloin chuck andouille venison pork\n salami. Chuck strip steak cupim, turducken ham hock kielbasa shoulder\n porchetta chislic short loin tri-tip biltong cow corned beef.\n </p>\n </section>\n `;\n }\n\n addMenuShortcut(menuId: keyof menuProvidersInt) {\n if (this.menuShortcuts.find(m => m.id === menuId)) {\n return;\n }\n\n const shortcut = this.menuProviders[menuId];\n this.menuShortcuts.push(shortcut);\n this.sortMenuShortcuts();\n this.emitMenuShortcutsUpdated();\n }\n\n /**\n * Removes a provider object from the menuShortcuts array and emits a\n * menuShortcutsUpdated event.\n */\n removeMenuShortcut(menuId: string) {\n this.menuShortcuts = this.menuShortcuts.filter(m => m.id !== menuId);\n this.emitMenuShortcutsUpdated();\n }\n\n /**\n * Sorts the menuShortcuts property by comparing each provider's id to\n * the id in each iteration over the shortcutOrder array.\n */\n sortMenuShortcuts() {\n this.menuShortcuts = this.shortcutOrder.reduce(\n (shortcuts: IntMenuShortcut[], id) => {\n const menu = this.menuShortcuts.find(m => m.id === id);\n\n // eslint-disable-next-line no-param-reassign\n if (menu) {\n const newShortcuts = [...shortcuts, menu];\n // eslint-disable-next-line no-param-reassign\n shortcuts = newShortcuts;\n }\n return shortcuts;\n },\n []\n );\n }\n\n emitMenuShortcutsUpdated() {\n const event = new CustomEvent('menuShortcutsUpdated', {\n detail: this.menuShortcuts,\n });\n this.dispatchEvent(event);\n }\n\n setMenu() {\n const menuProviders = {\n share: new ShareProvider({\n item: this.itemMD,\n baseHost: this.baseHost,\n subPrefix: '',\n }),\n filesByType: new FilesByTypeProvider({\n item: this.itemMD,\n baseHost: this.baseHost,\n subPrefix: '',\n }),\n visualMods: new VisualModsProvider({\n updated: (modType: string) => {\n if (modType === 'toggleFullscreen') {\n this.updateFullscreenState();\n }\n },\n item: this.itemMD,\n baseHost: this.baseHost,\n subPrefix: '',\n // maybe DOM root for class configs?\n }),\n };\n\n this.menuProviders = menuProviders;\n this.addMenuShortcut('visualMods');\n }\n\n updateFullscreenState() {\n const isFullScreen = !this.fullscreenState;\n this.fullscreenState = isFullScreen;\n\n const event = new CustomEvent('ViewportInFullScreen', {\n detail: { isFullScreen },\n } as IntManageFullscreenEvent);\n this.dispatchEvent(event);\n }\n\n updateMenuContents() {\n const { share, filesByType, visualMods } = this.menuProviders;\n const availableMenus = [filesByType, share, visualMods].filter(\n menu => !!menu\n );\n\n const event = new CustomEvent(ItemInspectorEvents.menuUpdated, {\n detail: availableMenus,\n });\n\n this.dispatchEvent(event);\n }\n\n emitLoadingStatusUpdate(loaded: boolean) {\n const event = new CustomEvent('loadingStateUpdated', {\n detail: { loaded },\n });\n this.dispatchEvent(event);\n }\n\n parseItemInfo() {\n this.fileCount = this.itemMD?.files?.length || 0;\n }\n\n get imageUrl() {\n const { metadata = {} } = this.itemMD;\n const url = `${this.baseHost}/download/${metadata?.identifier}/__ia_thumb.jpg`;\n return url;\n }\n\n static get styles() {\n const main = css`\n :host {\n display: block;\n width: 100%;\n margin: 0 auto;\n position: relative;\n overflow: auto;\n background-color: black;\n color: var(--primaryTextColor, #fff);\n }\n\n :host,\n section {\n min-height: inherit;\n height: inherit;\n }\n\n section {\n margin: auto;\n width: 100%;\n text-align: center;\n }\n\n img {\n border: 1px solid var(--primaryTextColor, #fff);\n }\n `;\n return [main];\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"item-inspector.js","sourceRoot":"","sources":["../../../src/item-inspector/item-inspector.ts"],"names":[],"mappings":";AAAA,kCAAkC;AAClC,WAAW;AACX,SAAS;AACT,UAAU;AACV,gBAAgB;AAChB,mBAAmB;AACnB,cAAc;AACd,WAAW;AACX,wBAAwB;AACxB,sEAAsE;AAEtE,WAAW;AACX,2BAA2B;AAC3B,iBAAiB;AACjB,2CAA2C;AAC3C,2FAA2F;AAC3F,6EAA6E;AAC7E,WAAW;AACX,qBAAqB;AACrB,qBAAqB;AACrB,0CAA0C;AAC1C,6EAA6E;AAE7E,oDAAoD;AACpD,gFAAgF;AAChF,8DAA8D;AAE9D,wCAAwC;AACxC,6BAA6B;AAC7B,iCAAiC;AACjC,uCAAuC;AACvC,2BAA2B;AAC3B,mDAAmD;AACnD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uBAAuB;AACvB,SAAS;AAET,uEAAuE;AACvE,gCAAgC;AAChC,UAAU;AAEV,iCAAiC;AACjC,MAAM;AAEN,+CAA+C;AAC/C,6DAA6D;AAC7D,4BAA4B;AAC5B,UAAU;AACV,iCAAiC;AACjC,MAAM;AAEN,sBAAsB;AACtB,wDAAwD;AACxD,MAAM;AAEN,qBAAqB;AACrB,6CAA6C;AAC7C,sFAAsF;AACtF,kBAAkB;AAClB,MAAM;AAEN,0BAA0B;AAC1B,wBAAwB;AACxB,gBAAgB;AAChB,0BAA0B;AAC1B,uBAAuB;AACvB,0BAA0B;AAC1B,8BAA8B;AAC9B,0BAA0B;AAC1B,mCAAmC;AACnC,gDAAgD;AAChD,UAAU;AAEV,eAAe;AACf,kBAAkB;AAClB,+BAA+B;AAC/B,2BAA2B;AAC3B,UAAU;AAEV,kBAAkB;AAClB,wBAAwB;AACxB,uBAAuB;AACvB,8BAA8B;AAC9B,UAAU;AAEV,cAAc;AACd,2DAA2D;AAC3D,UAAU;AACV,SAAS;AACT,qBAAqB;AACrB,MAAM;AACN,IAAI","sourcesContent":["// /* eslint-disable no-console */\n// import {\n// css,\n// html,\n// LitElement,\n// customElement,\n// property,\n// state,\n// } from 'lit-element';\n// import { MetadataResponse } from '@internetarchive/search-service';\n\n// import {\n// ModalManagerInterface,\n// ModalConfig,\n// } from '@internetarchive/modal-manager';\n// import { SharedResizeObserverInterface } from '@internetarchive/shared-resize-observer';\n// import { IntNavController } from '../interfaces/nav-controller-interface';\n// import {\n// IntMenuProvider,\n// IntMenuShortcut,\n// } from '../interfaces/menu-interfaces';\n// import { IntManageFullscreenEvent } from '../interfaces/event-interfaces';\n\n// import { ShareProvider } from './share-provider';\n// import { FilesByTypeProvider } from './files-by-type/files-by-type-provider';\n// import { VisualModsProvider } from './visual-mod-provider';\n\n// // eslint-disable-next-line no-shadow\n// enum ItemInspectorEvents {\n// menuUpdated = 'menuUpdated',\n// updateSideMenu = 'updateSideMenu',\n// PostInit = 'PostInit',\n// ViewportInFullScreen = 'ViewportInFullScreen',\n// }\n\n// interface menuProvidersInt {\n// [menuId: string]: IntMenuProvider;\n// }\n\n// @customElement('ia-item-inspector')\n// export class IaItemInspector extends LitElement implements IntNavController {\n// @property({ type: Object }) itemMD: MetadataResponse = {\n// metadata: {},\n// } as MetadataResponse;\n\n// @property({ type: String }) baseHost = 'https://archive.org';\n\n// @property({ type: Object }) menuProviders: menuProvidersInt = {};\n\n// @property({ type: Array }) menuShortcuts: IntMenuShortcut[] = [];\n\n// @property({ type: Boolean }) sideMenuOpen = false;\n\n// @property({ type: Boolean }) fullscreenState = false;\n\n// @property({ attribute: false }) modal!: ModalManagerInterface;\n\n// @property({ attribute: false }) sharedRO!: SharedResizeObserverInterface;\n\n// @state() fileCount: number = 0;\n\n// @state() loaded: boolean = false;\n\n// @state() private shortcutOrder = ['visualMods'];\n\n// firstUpdated() {\n// this.loaded = true;\n// console.log('modal', this.modal);\n// }\n\n// updated(changed: any) {\n// if (changed.has('loaded')) {\n// setTimeout(() => this.emitLoadingStatusUpdate(this.loaded), 1000);\n// }\n\n// if (changed.has('itemMD') && this.itemMD) {\n// this.parseItemInfo();\n// this.setMenu();\n// }\n\n// if (changed.has('menuProviders') || changed.has('menuShortcuts')) {\n// this.updateMenuContents();\n// }\n// }\n\n// modalClosedCallback() {\n// console.log('item-inspector, modal closed');\n// }\n\n// openModal() {\n// const config = new ModalConfig();\n// const customModalContent = html`\n// Can contain any markup, including web components. Event listeners also\n// work. Try clicking on the picture.\n// <div style=\"text-align: center\">\n// <a href=\"https://fillmurray.com\" style=\"display: block\">Fill Murray</a>\n// <img src=\"100x100.jpg\" alt=\"foo\" />\n// </div>\n// `;\n\n// this.modal.showModal({\n// config,\n// customModalContent,\n// userClosedModalCallback: this.modalClosedCallback,\n// });\n// }\n\n// render() {\n// const { identifier = '' } = this.itemMD?.metadata;\n// return html`\n// <section>\n// <div>\n// <h2>${identifier}</h2>\n// </div>\n// <img src=${this.imageUrl} alt=${`${identifier} thumbnail`} />\n// <button @click=${() => this.openModal()}>open modal</button>\n// <p style=\"font-size: 20px;\">\n// Bacon ipsum dolor amet flank chicken leberkas sausage, meatball pork\n// belly jowl. Chislic bacon salami frankfurter shankle drumstick\n// andouille ball tip alcatra. Fatback beef ribs chicken, jerky ground\n// round hamburger pork chop biltong. Shoulder short loin rump jerky\n// kielbasa pork porchetta fatback ribeye pork belly sirloin chislic\n// turducken corned beef tri-tip. Chuck pancetta meatball tail, spare\n// ribs ham hock capicola pig. Ham hock hamburger chicken tri-tip venison\n// swine burgdoggen boudin meatloaf pastrami chuck. Tri-tip spare ribs\n// drumstick, tail rump hamburger burgdoggen swine t-bone tongue\n// andouille chislic alcatra. Pork loin jowl frankfurter, doner meatball\n// short loin ham hock filet mignon hamburger rump turkey bresaola\n// shoulder sirloin flank. Ribeye sausage pig t-bone bacon frankfurter\n// cupim capicola fatback pastrami ball tip pork belly. Picanha pancetta\n// andouille flank shankle venison tri-tip tail, kevin turkey turducken\n// chicken. Bacon picanha swine frankfurter, prosciutto chislic doner\n// alcatra pork loin corned beef jowl biltong meatball chuck. Bacon\n// burgdoggen pig fatback cupim t-bone. Cow pork loin bresaola brisket\n// shoulder filet mignon chicken. Sirloin bresaola porchetta beef\n// capicola meatloaf brisket shankle jerky turkey pork tri-tip swine\n// kevin salami. Meatball t-bone doner venison. Pig tri-tip chuck, shank\n// chicken pork chop landjaeger spare ribs jerky swine ham hock buffalo\n// sirloin. Leberkas pancetta tenderloin, meatloaf buffalo rump pastrami\n// chuck. Jerky cupim porchetta, tenderloin chuck andouille venison pork\n// salami. Chuck strip steak cupim, turducken ham hock kielbasa shoulder\n// porchetta chislic short loin tri-tip biltong cow corned beef.\n// </p>\n// </section>\n// `;\n// }\n\n// addMenuShortcut(menuId: keyof menuProvidersInt) {\n// if (this.menuShortcuts.find(m => m.id === menuId)) {\n// return;\n// }\n\n// const shortcut = this.menuProviders[menuId];\n// this.menuShortcuts.push(shortcut);\n// this.sortMenuShortcuts();\n// this.emitMenuShortcutsUpdated();\n// }\n\n// /**\n// * Removes a provider object from the menuShortcuts array and emits a\n// * menuShortcutsUpdated event.\n// */\n// removeMenuShortcut(menuId: string) {\n// this.menuShortcuts = this.menuShortcuts.filter(m => m.id !== menuId);\n// this.emitMenuShortcutsUpdated();\n// }\n\n// /**\n// * Sorts the menuShortcuts property by comparing each provider's id to\n// * the id in each iteration over the shortcutOrder array.\n// */\n// sortMenuShortcuts() {\n// this.menuShortcuts = this.shortcutOrder.reduce(\n// (shortcuts: IntMenuShortcut[], id) => {\n// const menu = this.menuShortcuts.find(m => m.id === id);\n\n// // eslint-disable-next-line no-param-reassign\n// if (menu) {\n// const newShortcuts = [...shortcuts, menu];\n// // eslint-disable-next-line no-param-reassign\n// shortcuts = newShortcuts;\n// }\n// return shortcuts;\n// },\n// []\n// );\n// }\n\n// emitMenuShortcutsUpdated() {\n// const event = new CustomEvent('menuShortcutsUpdated', {\n// detail: this.menuShortcuts,\n// });\n// this.dispatchEvent(event);\n// }\n\n// setMenu() {\n// const menuProviders = {\n// share: new ShareProvider({\n// item: this.itemMD,\n// baseHost: this.baseHost,\n// subPrefix: '',\n// }),\n// filesByType: new FilesByTypeProvider({\n// item: this.itemMD,\n// baseHost: this.baseHost,\n// subPrefix: '',\n// }),\n// visualMods: new VisualModsProvider({\n// updated: (modType: string) => {\n// if (modType === 'toggleFullscreen') {\n// this.updateFullscreenState();\n// }\n// },\n// item: this.itemMD,\n// baseHost: this.baseHost,\n// subPrefix: '',\n// // maybe DOM root for class configs?\n// }),\n// };\n\n// this.menuProviders = menuProviders;\n// this.addMenuShortcut('visualMods');\n// }\n\n// updateFullscreenState() {\n// const isFullScreen = !this.fullscreenState;\n// this.fullscreenState = isFullScreen;\n\n// const event = new CustomEvent('ViewportInFullScreen', {\n// detail: { isFullScreen },\n// } as IntManageFullscreenEvent);\n// this.dispatchEvent(event);\n// }\n\n// updateMenuContents() {\n// const { share, filesByType, visualMods } = this.menuProviders;\n// const availableMenus = [filesByType, share, visualMods].filter(\n// menu => !!menu\n// );\n\n// const event = new CustomEvent(ItemInspectorEvents.menuUpdated, {\n// detail: availableMenus,\n// });\n\n// this.dispatchEvent(event);\n// }\n\n// emitLoadingStatusUpdate(loaded: boolean) {\n// const event = new CustomEvent('loadingStateUpdated', {\n// detail: { loaded },\n// });\n// this.dispatchEvent(event);\n// }\n\n// parseItemInfo() {\n// this.fileCount = this.itemMD?.files?.length || 0;\n// }\n\n// get imageUrl() {\n// const { metadata = {} } = this.itemMD;\n// const url = `${this.baseHost}/download/${metadata?.identifier}/__ia_thumb.jpg`;\n// return url;\n// }\n\n// static get styles() {\n// const main = css`\n// :host {\n// display: block;\n// width: 100%;\n// margin: 0 auto;\n// position: relative;\n// overflow: auto;\n// background-color: black;\n// color: var(--primaryTextColor, #fff);\n// }\n\n// :host,\n// section {\n// min-height: inherit;\n// height: inherit;\n// }\n\n// section {\n// margin: auto;\n// width: 100%;\n// text-align: center;\n// }\n\n// img {\n// border: 1px solid var(--primaryTextColor, #fff);\n// }\n// `;\n// return [main];\n// }\n// }\n"]}
|
@@ -1,57 +1,74 @@
|
|
1
|
-
import { LitElement } from 'lit-element';
|
1
|
+
import { LitElement, PropertyValues, CSSResult } from 'lit-element';
|
2
2
|
import { nothing, TemplateResult } from 'lit-html';
|
3
3
|
import { MetadataResponse } from '@internetarchive/search-service';
|
4
|
-
import { SharedResizeObserverResizeHandlerInterface } from '@internetarchive/shared-resize-observer';
|
5
|
-
import
|
4
|
+
import { SharedResizeObserver, SharedResizeObserverResizeHandlerInterface } from '@internetarchive/shared-resize-observer';
|
5
|
+
import '@internetarchive/ia-menu-slider';
|
6
|
+
import { ModalManager } from '@internetarchive/modal-manager';
|
6
7
|
import '@internetarchive/icon-ellipses/icon-ellipses';
|
7
8
|
import './loader';
|
8
|
-
import {
|
9
|
-
import {
|
9
|
+
import { ToggleSideMenuOpenEvent, ToggleSidePanelOpenEvent, SetSideMenuContentsEvent, SetSideMenuShortcutsEvent, loadingStateUpdatedEvent, ManageFullscreenEvent } from './interfaces/event-interfaces';
|
10
|
+
import { MenuProviderInterface, MenuShortcutInterface, MenuId } from './interfaces/menu-interfaces';
|
11
|
+
import './no-theater-available';
|
12
|
+
export declare enum ItemType {
|
13
|
+
BOOK = "bookreader"
|
14
|
+
}
|
10
15
|
export declare class ItemNavigator extends LitElement implements SharedResizeObserverResizeHandlerInterface {
|
11
|
-
item
|
12
|
-
itemType
|
16
|
+
item?: MetadataResponse;
|
17
|
+
itemType?: ItemType;
|
13
18
|
baseHost: string;
|
14
19
|
signedIn: boolean;
|
15
|
-
menuContents:
|
16
|
-
menuShortcuts:
|
17
|
-
viewportInFullscreen: boolean;
|
20
|
+
menuContents: MenuProviderInterface[];
|
21
|
+
menuShortcuts: MenuShortcutInterface[];
|
22
|
+
viewportInFullscreen: boolean | null;
|
18
23
|
menuOpened: boolean;
|
19
|
-
openMenu
|
20
|
-
modal?:
|
21
|
-
sharedObserver?:
|
22
|
-
|
23
|
-
|
24
|
+
openMenu?: MenuId;
|
25
|
+
modal?: ModalManager;
|
26
|
+
sharedObserver?: SharedResizeObserver;
|
27
|
+
loaded: true | null;
|
28
|
+
openMenuState: 'overlay' | 'shift';
|
24
29
|
private frame;
|
30
|
+
private headerSlot;
|
25
31
|
disconnectedCallback(): void;
|
26
|
-
|
32
|
+
updated(changed: PropertyValues): void;
|
33
|
+
/** Shared observer */
|
27
34
|
handleResize(entry: ResizeObserverEntry): void;
|
28
|
-
private
|
35
|
+
private setResizeObserver;
|
36
|
+
private removeResizeObserver;
|
37
|
+
get resizeObserverConfig(): {
|
38
|
+
handler: SharedResizeObserverResizeHandlerInterface;
|
39
|
+
target: Element;
|
40
|
+
};
|
41
|
+
/** End shared observer */
|
42
|
+
get loaderTitle(): "" | "Internet Archive";
|
43
|
+
get readerHeightStyle(): string;
|
44
|
+
get loadingArea(): TemplateResult;
|
29
45
|
render(): TemplateResult;
|
30
|
-
get
|
46
|
+
get noTheaterView(): TemplateResult;
|
47
|
+
get theaterSlot(): TemplateResult;
|
48
|
+
get booksViewer(): TemplateResult;
|
31
49
|
get renderViewport(): TemplateResult | typeof nothing;
|
32
|
-
loadingStateUpdated(e:
|
33
|
-
/** Creates modal DOM & attaches to `<body>` */
|
34
|
-
private createModal;
|
50
|
+
loadingStateUpdated(e: loadingStateUpdatedEvent): void;
|
35
51
|
/** Fullscreen Management */
|
36
|
-
manageViewportFullscreen(e:
|
52
|
+
manageViewportFullscreen(e: ManageFullscreenEvent): void;
|
37
53
|
/** End Fullscreen Management */
|
38
54
|
/** Side menu */
|
39
55
|
get shouldRenderMenu(): boolean;
|
40
56
|
toggleMenu(): void;
|
41
57
|
closeMenu(): void;
|
42
|
-
setOpenMenu(e:
|
43
|
-
setMenuContents(e:
|
44
|
-
setMenuShortcuts(e:
|
58
|
+
setOpenMenu(e: ToggleSidePanelOpenEvent): void;
|
59
|
+
setMenuContents(e: SetSideMenuContentsEvent): void;
|
60
|
+
setMenuShortcuts(e: SetSideMenuShortcutsEvent): void;
|
45
61
|
/** Toggles Side Menu & Sets viewable subpanel */
|
46
|
-
manageSideMenuEvents(e:
|
62
|
+
manageSideMenuEvents(e: ToggleSideMenuOpenEvent): void;
|
47
63
|
get menuToggleButton(): TemplateResult;
|
64
|
+
get selectedMenuId(): MenuId | '';
|
48
65
|
get renderSideMenu(): TemplateResult;
|
49
66
|
/** End Side menu */
|
50
67
|
/** Menu Shortcuts */
|
51
|
-
openShortcut(selectedMenuId?:
|
68
|
+
openShortcut(selectedMenuId?: MenuId): void;
|
52
69
|
get shortcuts(): TemplateResult;
|
53
70
|
/** End Menu Shortcuts */
|
54
71
|
/** Misc Render */
|
55
72
|
get menuClass(): string;
|
56
|
-
static get styles():
|
73
|
+
static get styles(): CSSResult;
|
57
74
|
}
|
@@ -2,41 +2,37 @@ import { __decorate } from "tslib";
|
|
2
2
|
import { css, html, LitElement, customElement, property, state, query, } from 'lit-element';
|
3
3
|
import { nothing } from 'lit-html';
|
4
4
|
import { MetadataResponse } from '@internetarchive/search-service';
|
5
|
-
import
|
6
|
-
import { SharedResizeObserver, } from '@internetarchive/shared-resize-observer';
|
7
|
-
// @ts-ignore
|
8
|
-
import { IAMenuSlider } from '@internetarchive/ia-menu-slider';
|
5
|
+
import '@internetarchive/ia-menu-slider';
|
9
6
|
import '@internetarchive/icon-ellipses/icon-ellipses';
|
10
7
|
import './loader';
|
8
|
+
import './no-theater-available';
|
9
|
+
export var ItemType;
|
10
|
+
(function (ItemType) {
|
11
|
+
ItemType["BOOK"] = "bookreader";
|
12
|
+
})(ItemType || (ItemType = {}));
|
11
13
|
let ItemNavigator = class ItemNavigator extends LitElement {
|
12
14
|
constructor() {
|
13
15
|
super(...arguments);
|
14
|
-
this.item = undefined;
|
15
|
-
this.itemType = '';
|
16
16
|
this.baseHost = 'archive.org';
|
17
17
|
this.signedIn = false;
|
18
18
|
this.menuContents = [];
|
19
19
|
this.menuShortcuts = [];
|
20
|
-
this.viewportInFullscreen =
|
20
|
+
this.viewportInFullscreen = null;
|
21
21
|
this.menuOpened = false;
|
22
|
-
this.
|
23
|
-
this.loaded = false;
|
22
|
+
this.loaded = null;
|
24
23
|
this.openMenuState = 'shift';
|
25
24
|
}
|
26
25
|
disconnectedCallback() {
|
27
|
-
|
28
|
-
(_a = this.sharedObserver) === null || _a === void 0 ? void 0 : _a.removeObserver({
|
29
|
-
handler: this,
|
30
|
-
target: this.frame,
|
31
|
-
});
|
26
|
+
this.removeResizeObserver();
|
32
27
|
}
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
this.
|
28
|
+
updated(changed) {
|
29
|
+
if (changed.has('sharedObserver')) {
|
30
|
+
const oldObserver = changed.get('sharedObserver');
|
31
|
+
oldObserver === null || oldObserver === void 0 ? void 0 : oldObserver.removeObserver(this.resizeObserverConfig);
|
32
|
+
this.setResizeObserver();
|
37
33
|
}
|
38
|
-
this.startResizeObserver();
|
39
34
|
}
|
35
|
+
/** Shared observer */
|
40
36
|
handleResize(entry) {
|
41
37
|
const { width } = entry.contentRect;
|
42
38
|
if (width <= 600) {
|
@@ -45,51 +41,76 @@ let ItemNavigator = class ItemNavigator extends LitElement {
|
|
45
41
|
}
|
46
42
|
this.openMenuState = 'shift';
|
47
43
|
}
|
48
|
-
|
44
|
+
setResizeObserver() {
|
49
45
|
var _a;
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
46
|
+
(_a = this.sharedObserver) === null || _a === void 0 ? void 0 : _a.addObserver(this.resizeObserverConfig);
|
47
|
+
}
|
48
|
+
removeResizeObserver() {
|
49
|
+
var _a;
|
50
|
+
(_a = this.sharedObserver) === null || _a === void 0 ? void 0 : _a.removeObserver(this.resizeObserverConfig);
|
51
|
+
}
|
52
|
+
get resizeObserverConfig() {
|
53
|
+
return {
|
57
54
|
handler: this,
|
58
55
|
target: this.frame,
|
59
|
-
}
|
56
|
+
};
|
57
|
+
}
|
58
|
+
/** End shared observer */
|
59
|
+
get loaderTitle() {
|
60
|
+
return this.viewportInFullscreen ? 'Internet Archive' : '';
|
61
|
+
}
|
62
|
+
get readerHeightStyle() {
|
63
|
+
var _a;
|
64
|
+
const calcFSHeight = `calc(100vh - ${(_a = this.headerSlot) === null || _a === void 0 ? void 0 : _a.offsetHeight}px)`;
|
65
|
+
return this.viewportInFullscreen ? `height: ${calcFSHeight}` : '';
|
66
|
+
}
|
67
|
+
get loadingArea() {
|
68
|
+
return html `
|
69
|
+
<div class="loading-area">
|
70
|
+
<div class="loading-view">
|
71
|
+
<ia-itemnav-loader .title=${this.loaderTitle}></ia-itemnav-loader>
|
72
|
+
</div>
|
73
|
+
</div>
|
74
|
+
`;
|
60
75
|
}
|
61
76
|
render() {
|
62
|
-
const displayReaderClass = this.loaded ? '' : '
|
77
|
+
const displayReaderClass = this.loaded ? '' : 'hidden';
|
63
78
|
return html `
|
64
|
-
<div id="frame" class=${this.menuClass}>
|
65
|
-
<slot name="item-nav-header"></slot>
|
79
|
+
<div id="frame" class=${`${this.menuClass}`}>
|
66
80
|
<div class="menu-and-reader">
|
67
81
|
${this.shouldRenderMenu ? this.renderSideMenu : nothing}
|
68
|
-
<
|
82
|
+
<slot name="theater-header"></slot>
|
83
|
+
<div
|
84
|
+
id="reader"
|
85
|
+
class=${displayReaderClass}
|
86
|
+
style=${this.readerHeightStyle}
|
87
|
+
>
|
69
88
|
${this.renderViewport}
|
70
89
|
</div>
|
71
|
-
|
72
|
-
<div class="loading-view">
|
73
|
-
<ia-itemnav-loader></ia-itemnav-loader>
|
74
|
-
</div>
|
75
|
-
</div>
|
90
|
+
${!this.loaded ? this.loadingArea : nothing}
|
76
91
|
</div>
|
77
|
-
${!this.loaded
|
78
|
-
? html ` <div class="loading-area">
|
79
|
-
<div class="loading-view">
|
80
|
-
<ia-itemnav-loader></ia-itemnav-loader>
|
81
|
-
</div>
|
82
|
-
</div>`
|
83
|
-
: nothing}
|
84
92
|
</div>
|
85
93
|
`;
|
86
94
|
}
|
87
|
-
get
|
95
|
+
get noTheaterView() {
|
96
|
+
var _a, _b;
|
97
|
+
return html `<ia-no-theater-available
|
98
|
+
.identifier=${(_b = (_a = this.item) === null || _a === void 0 ? void 0 : _a.metadata) === null || _b === void 0 ? void 0 : _b.identifier}
|
99
|
+
@loadingStateUpdated=${this.loadingStateUpdated}
|
100
|
+
></ia-no-theater-available>`;
|
101
|
+
}
|
102
|
+
get theaterSlot() {
|
103
|
+
return html `
|
104
|
+
<slot name="theater-main" style=${this.readerHeightStyle}></slot>
|
105
|
+
`;
|
106
|
+
}
|
107
|
+
get booksViewer() {
|
108
|
+
const slotVisibility = !this.loaded ? 'opacity: 0;' : 'opacity: 1;';
|
88
109
|
return html `
|
89
110
|
<book-navigator
|
90
111
|
.modal=${this.modal}
|
91
112
|
.baseHost=${this.baseHost}
|
92
|
-
.
|
113
|
+
.itemMD=${this.item}
|
93
114
|
?signedIn=${this.signedIn}
|
94
115
|
?sideMenuOpen=${this.menuOpened}
|
95
116
|
.sharedObserver=${this.sharedObserver}
|
@@ -99,8 +120,8 @@ let ItemNavigator = class ItemNavigator extends LitElement {
|
|
99
120
|
@menuUpdated=${this.setMenuContents}
|
100
121
|
@menuShortcutsUpdated=${this.setMenuShortcuts}
|
101
122
|
>
|
102
|
-
<div slot="
|
103
|
-
|
123
|
+
<div slot="theater-main" style=${slotVisibility}>
|
124
|
+
${this.theaterSlot}
|
104
125
|
</div>
|
105
126
|
</book-navigator>
|
106
127
|
`;
|
@@ -109,35 +130,23 @@ let ItemNavigator = class ItemNavigator extends LitElement {
|
|
109
130
|
if (!this.item) {
|
110
131
|
return nothing;
|
111
132
|
}
|
112
|
-
if (this.itemType ===
|
113
|
-
return this.
|
133
|
+
if (this.itemType === ItemType.BOOK) {
|
134
|
+
return this.booksViewer;
|
114
135
|
}
|
115
|
-
return
|
116
|
-
.itemMD=${this.item}
|
117
|
-
.modal=${this.modal}
|
118
|
-
@updateSideMenu=${this.manageSideMenuEvents}
|
119
|
-
@menuUpdated=${this.setMenuContents}
|
120
|
-
@ViewportInFullScreen=${this.manageViewportFullscreen}
|
121
|
-
@menuShortcutsUpdated=${this.setMenuShortcuts}
|
122
|
-
@loadingStateUpdated=${this.loadingStateUpdated}
|
123
|
-
></ia-item-inspector>`;
|
136
|
+
return this.noTheaterView;
|
124
137
|
}
|
125
138
|
loadingStateUpdated(e) {
|
126
139
|
const { loaded } = e.detail;
|
127
|
-
this.loaded =
|
140
|
+
this.loaded = loaded || null;
|
128
141
|
}
|
129
|
-
/** Creates modal DOM & attaches to `<body>` */
|
130
|
-
createModal() {
|
131
|
-
this.modal = document.createElement('modal-manager');
|
132
|
-
document.body.appendChild(this.modal);
|
133
|
-
}
|
134
|
-
/* End Modal management */
|
135
142
|
/** Fullscreen Management */
|
136
143
|
manageViewportFullscreen(e) {
|
137
|
-
|
138
|
-
this.
|
144
|
+
const fullscreenStatus = !!e.detail.isFullScreen;
|
145
|
+
this.viewportInFullscreen = !fullscreenStatus ? null : fullscreenStatus;
|
146
|
+
const event = new CustomEvent('fullscreenToggled', {
|
139
147
|
detail: e.detail,
|
140
|
-
})
|
148
|
+
});
|
149
|
+
this.dispatchEvent(event);
|
141
150
|
}
|
142
151
|
/** End Fullscreen Management */
|
143
152
|
/** Side menu */
|
@@ -152,7 +161,7 @@ let ItemNavigator = class ItemNavigator extends LitElement {
|
|
152
161
|
}
|
153
162
|
setOpenMenu(e) {
|
154
163
|
const { id } = e.detail;
|
155
|
-
this.openMenu = id
|
164
|
+
this.openMenu = id !== this.openMenu ? id : undefined;
|
156
165
|
}
|
157
166
|
setMenuContents(e) {
|
158
167
|
const updatedContents = [...e.detail];
|
@@ -164,18 +173,18 @@ let ItemNavigator = class ItemNavigator extends LitElement {
|
|
164
173
|
/** Toggles Side Menu & Sets viewable subpanel */
|
165
174
|
manageSideMenuEvents(e) {
|
166
175
|
const { menuId, action } = e.detail;
|
167
|
-
if (menuId) {
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
176
|
+
if (!menuId) {
|
177
|
+
return;
|
178
|
+
}
|
179
|
+
if (action === 'open') {
|
180
|
+
this.openShortcut(menuId);
|
181
|
+
}
|
182
|
+
else if (action === 'toggle') {
|
183
|
+
this.openMenu = menuId;
|
184
|
+
this.toggleMenu();
|
175
185
|
}
|
176
186
|
}
|
177
187
|
get menuToggleButton() {
|
178
|
-
// <ia-icon icon="ellipses" style="width: var(--iconWidth); height: var(--iconHeight);"></ia-icon>
|
179
188
|
return html `
|
180
189
|
<button
|
181
190
|
class="toggle-menu"
|
@@ -190,6 +199,9 @@ let ItemNavigator = class ItemNavigator extends LitElement {
|
|
190
199
|
</button>
|
191
200
|
`;
|
192
201
|
}
|
202
|
+
get selectedMenuId() {
|
203
|
+
return this.openMenu || '';
|
204
|
+
}
|
193
205
|
get renderSideMenu() {
|
194
206
|
const drawerState = this.menuOpened ? '' : 'hidden';
|
195
207
|
return html `
|
@@ -198,7 +210,7 @@ let ItemNavigator = class ItemNavigator extends LitElement {
|
|
198
210
|
<div id="menu" class=${drawerState}>
|
199
211
|
<ia-menu-slider
|
200
212
|
.menus=${this.menuContents}
|
201
|
-
.selectedMenu=${this.
|
213
|
+
.selectedMenu=${this.selectedMenuId}
|
202
214
|
@menuTypeSelected=${this.setOpenMenu}
|
203
215
|
@menuSliderClosed=${this.closeMenu}
|
204
216
|
manuallyHandleClose
|
@@ -215,11 +227,16 @@ let ItemNavigator = class ItemNavigator extends LitElement {
|
|
215
227
|
this.menuOpened = true;
|
216
228
|
}
|
217
229
|
get shortcuts() {
|
218
|
-
const shortcuts = this.menuShortcuts.map(({ icon, id }) =>
|
230
|
+
const shortcuts = this.menuShortcuts.map(({ icon, id }) => {
|
231
|
+
if (id === 'fullscreen') {
|
232
|
+
return html `${icon}`;
|
233
|
+
}
|
234
|
+
return html `
|
219
235
|
<button class="shortcut ${id}" @click="${() => this.openShortcut(id)}">
|
220
236
|
${icon}
|
221
237
|
</button>
|
222
|
-
|
238
|
+
`;
|
239
|
+
});
|
223
240
|
return html `<div class="shortcuts">${shortcuts}</div>`;
|
224
241
|
}
|
225
242
|
/** End Menu Shortcuts */
|
@@ -238,7 +255,6 @@ let ItemNavigator = class ItemNavigator extends LitElement {
|
|
238
255
|
return css `
|
239
256
|
:host,
|
240
257
|
#frame,
|
241
|
-
#reader,
|
242
258
|
.menu-and-reader {
|
243
259
|
min-height: inherit;
|
244
260
|
height: inherit;
|
@@ -247,8 +263,23 @@ let ItemNavigator = class ItemNavigator extends LitElement {
|
|
247
263
|
display: block;
|
248
264
|
}
|
249
265
|
|
266
|
+
:host,
|
267
|
+
#frame,
|
268
|
+
.menu-and-reader,
|
269
|
+
.loading-area,
|
270
|
+
.loading-view {
|
271
|
+
min-height: inherit;
|
272
|
+
height: inherit;
|
273
|
+
}
|
274
|
+
|
275
|
+
slot {
|
276
|
+
display: block;
|
277
|
+
overflow: hidden;
|
278
|
+
}
|
279
|
+
|
250
280
|
#frame {
|
251
281
|
background-color: ${theaterBg};
|
282
|
+
color-scheme: dark;
|
252
283
|
}
|
253
284
|
|
254
285
|
#frame.fullscreen {
|
@@ -260,27 +291,10 @@ let ItemNavigator = class ItemNavigator extends LitElement {
|
|
260
291
|
z-index: 9;
|
261
292
|
}
|
262
293
|
|
263
|
-
#frame.fullscreen,
|
264
|
-
#frame.fullscreen #reader {
|
265
|
-
height: 100vh;
|
266
|
-
}
|
267
|
-
|
268
|
-
.loading-area {
|
269
|
-
position: absolute;
|
270
|
-
top: 0;
|
271
|
-
left: 0;
|
272
|
-
right: 0;
|
273
|
-
bottom: 0;
|
274
|
-
height: inherit;
|
275
|
-
min-height: inherit;
|
276
|
-
}
|
277
|
-
|
278
294
|
.loading-view {
|
279
295
|
display: flex;
|
280
296
|
align-items: center;
|
281
297
|
justify-content: center;
|
282
|
-
min-height: inherit;
|
283
|
-
height: inherit;
|
284
298
|
}
|
285
299
|
|
286
300
|
ia-itemnav-loader {
|
@@ -289,8 +303,7 @@ let ItemNavigator = class ItemNavigator extends LitElement {
|
|
289
303
|
}
|
290
304
|
|
291
305
|
.hidden {
|
292
|
-
|
293
|
-
width: 1px;
|
306
|
+
display: none;
|
294
307
|
}
|
295
308
|
|
296
309
|
button {
|
@@ -381,6 +394,7 @@ let ItemNavigator = class ItemNavigator extends LitElement {
|
|
381
394
|
transition: ${transitionEffect};
|
382
395
|
}
|
383
396
|
|
397
|
+
.open.shift slot[name='theater-header'],
|
384
398
|
.open.shift #reader {
|
385
399
|
width: calc(100% - var(--menuWidth));
|
386
400
|
float: right;
|
@@ -417,22 +431,13 @@ __decorate([
|
|
417
431
|
})
|
418
432
|
], ItemNavigator.prototype, "signedIn", void 0);
|
419
433
|
__decorate([
|
420
|
-
property({
|
421
|
-
type: Array,
|
422
|
-
hasChanged: (newVal, oldVal) => {
|
423
|
-
if (newVal !== oldVal) {
|
424
|
-
return true;
|
425
|
-
}
|
426
|
-
return false;
|
427
|
-
},
|
428
|
-
}),
|
429
434
|
property({ type: Array })
|
430
435
|
], ItemNavigator.prototype, "menuContents", void 0);
|
431
436
|
__decorate([
|
432
437
|
property({ type: Array })
|
433
438
|
], ItemNavigator.prototype, "menuShortcuts", void 0);
|
434
439
|
__decorate([
|
435
|
-
property({ type: Boolean, reflect: true })
|
440
|
+
property({ type: Boolean, reflect: true, attribute: true })
|
436
441
|
], ItemNavigator.prototype, "viewportInFullscreen", void 0);
|
437
442
|
__decorate([
|
438
443
|
property({ type: Boolean })
|
@@ -447,7 +452,7 @@ __decorate([
|
|
447
452
|
property({ attribute: false })
|
448
453
|
], ItemNavigator.prototype, "sharedObserver", void 0);
|
449
454
|
__decorate([
|
450
|
-
|
455
|
+
property({ type: Boolean, reflect: true, attribute: true })
|
451
456
|
], ItemNavigator.prototype, "loaded", void 0);
|
452
457
|
__decorate([
|
453
458
|
state()
|
@@ -455,9 +460,11 @@ __decorate([
|
|
455
460
|
__decorate([
|
456
461
|
query('#frame')
|
457
462
|
], ItemNavigator.prototype, "frame", void 0);
|
463
|
+
__decorate([
|
464
|
+
query('slot[name="theater-header"]')
|
465
|
+
], ItemNavigator.prototype, "headerSlot", void 0);
|
458
466
|
ItemNavigator = __decorate([
|
459
|
-
customElement('item-navigator')
|
467
|
+
customElement('ia-item-navigator')
|
460
468
|
], ItemNavigator);
|
461
469
|
export { ItemNavigator };
|
462
|
-
customElements.define('ia-menu-slider', IAMenuSlider);
|
463
470
|
//# sourceMappingURL=item-navigator.js.map
|