@acdh-oeaw/universalviewer
Version:
The Universal Viewer is a community-developed open source project on a mission to help you share your 📚📜📰📽️📻🗿 with the 🌎
2 lines (1 loc) • 15.3 kB
JavaScript
import{b as U,d as F}from"./chunk-BPUF5FUE.js";import{a as G}from"./chunk-BSMW7565.js";import{a as M}from"./chunk-ZFYDSYRU.js";import"./chunk-BYXBJQAS.js";import{b as Q,e as B,f as C,g as s,h as y,j as k,k as R,l as D}from"./chunk-UGKRI7YJ.js";import"./chunk-FEXGFX4C.js";import{a}from"./chunk-Z6KGRKDP.js";import{a as L,b as r,o as x}from"./chunk-LLTGMZMR.js";import{g as f}from"./chunk-5XPHF4E5.js";import"./chunk-L67DAW3A.js";var n=class n{};n.namespace="ebookExtension.",n.CFI_FRAGMENT_CHANGE=n.namespace+"cfiFragmentChange",n.ITEM_CLICKED=n.namespace+"itemClicked",n.LOADED_NAVIGATION=n.namespace+"loadedNavigation",n.RELOCATED=n.namespace+"relocated",n.RENDITION_ATTACHED=n.namespace+"renditionAttached",n.TOC_READY=n.namespace+"tocReady";var i=n;function u(){var e=window,A=[];(!e.customElements||e.Element&&(!e.Element.prototype.closest||!e.Element.prototype.matches||!e.Element.prototype.remove))&&A.push(import("./dom-Q2LG6LKA.js"));function t(){try{var o=new URL("b","http://a");return o.pathname="c%20d",o.href==="http://a/c%20d"&&o.searchParams}catch{return!1}}return(typeof Object.assign!="function"||!Object.entries||!Array.prototype.find||!Array.prototype.includes||!String.prototype.startsWith||!String.prototype.endsWith||e.NodeList&&!e.NodeList.prototype.forEach||!e.fetch||!t()||typeof WeakMap>"u")&&A.push(import("./core-js-DYXRFGE7.js")),Promise.all(A)}var p=function(e,A){return U().then(function(){F([["uv-ebook-reader_2",[[0,"uv-ebook-reader",{width:[1],height:[1],mobileWidth:[2,"mobile-width"],minSpreadWidth:[2,"min-spread-width"],_bookPath:[32],_bookReady:[32],_prevEnabled:[32],_mobile:[32],_nextEnabled:[32],_showDivider:[32],load:[64],resize:[64],display:[64],getBook:[64]},[[8,"keydown","handleKeyDown"]]],[0,"uv-ebook-toc",{toc:[16],selected:[1025],disabled:[4]}]]]],A)})};(function(){if(!(window.Reflect===void 0||window.customElements===void 0)){var e=HTMLElement;window.HTMLElement=function(){return Reflect.construct(e,[],this.constructor)},HTMLElement.prototype=e.prototype,HTMLElement.prototype.constructor=HTMLElement,Object.setPrototypeOf(HTMLElement,e)}})();var N=L(),c=class extends C{constructor(A){super(A)}async create(){this.setConfig("ebookLeftPanel"),super.create(),this._$container=N('<div class="container"></div>'),await u(),p(window),this._ebookTOC=document.createElement("uv-ebook-toc"),this._$ebookTOC=N(this._ebookTOC),this.$main.addClass("disabled"),this.$main.append(this._$container),this._$container.append(this._$ebookTOC),this.setTitle(this.content.title),this.extensionHost.subscribe(i.LOADED_NAVIGATION,A=>{this.$main.removeClass("disabled"),this._ebookTOC.toc=A.toc}),this.extensionHost.subscribe(i.RELOCATED,A=>{this._ebookTOC.selected=A.start.href}),this._ebookTOC.addEventListener("itemClicked",A=>{this.extensionHost.publish(i.ITEM_CLICKED,A.detail)},!1),r.waitFor(()=>window.customElements!==void 0,()=>{customElements.whenDefined("uv-ebook-toc").then(()=>{this.extensionHost.publish(i.TOC_READY)})})}expandFullStart(){super.expandFullStart(),this.extensionHost.publish(a.LEFTPANEL_EXPAND_FULL_START)}expandFullFinish(){super.expandFullFinish(),this.extensionHost.publish(a.LEFTPANEL_EXPAND_FULL_FINISH)}collapseFullStart(){super.collapseFullStart(),this.extensionHost.publish(a.LEFTPANEL_COLLAPSE_FULL_START)}collapseFullFinish(){super.collapseFullFinish(),this.extensionHost.publish(a.LEFTPANEL_COLLAPSE_FULL_FINISH)}resize(){super.resize(),this._$container.height(this.$main.height()-this._$container.verticalPadding())}};var b=class extends M{constructor(A){super(A)}create(){this.setConfig("downloadDialogue"),super.create()}open(A){super.open(A),this.addEntireFileDownloadOptions(),this.updateNoneAvailable(),this.resize()}isDownloadOptionAvailable(A){return super.isDownloadOptionAvailable(A)}};var g=class extends Q{constructor(t){super(t);this._ebookReaderReady=!1;this._state={};this._prevState={};this.attributionPosition=8}async create(){this.setConfig("ebookCenterPanel"),super.create(),await u(),p(window),this._ebookReader=document.createElement("uv-ebook-reader"),this.$content.prepend(this._ebookReader),this._ebookReader.setAttribute("width","100%"),this._ebookReader.setAttribute("height","100%"),this._ebookReader.addEventListener("loadedNavigation",o=>{this.extensionHost.publish(i.LOADED_NAVIGATION,o.detail)},!1),this._ebookReader.addEventListener("relocated",o=>{this.extensionHost.publish(i.RELOCATED,o.detail),this._cfi=o.detail.start.cfi,this.extensionHost.publish(i.CFI_FRAGMENT_CHANGE,this._cfi)},!1),r.waitFor(()=>window.customElements!==void 0,()=>{customElements.whenDefined("uv-ebook-reader").then(()=>{this._ebookReaderReady=!0})});let t=this;this.extensionHost.subscribe(a.OPEN_EXTERNAL_RESOURCE,o=>{t.openMedia(o)}),this.extensionHost.subscribe(i.ITEM_CLICKED,o=>{this._nextState({cfi:o})}),this.extensionHost.subscribe(i.CFI_FRAGMENT_CHANGE,o=>{r.waitFor(()=>this._ebookReaderReady,()=>{o!==this._cfi&&this._nextState({cfi:o})})})}openMedia(t){this.extension.getExternalResources(t).then(()=>{let l=this.extension.helper.getCurrentCanvas().getContent();if(l.length){let d=l[0].getBody();if(d.length){let w=d[0];this._nextState({bookPath:w.id})}}this.extensionHost.publish(f.EXTERNAL_RESOURCE_OPENED),this.extensionHost.publish(f.LOAD)})}_nextState(t){this._state=Object.assign({},this._state,t),r.waitFor(()=>this._ebookReaderReady,()=>{this._state.bookPath&&this._state.bookPath!==this._prevState.bookPath&&this._ebookReader.load(this._state.bookPath),this._state.cfi&&this._state.cfi!==this._prevState.cfi&&this._ebookReader.display(this._state.cfi),this._prevState=Object.assign({},this._state)})}resize(){super.resize(),this._ebookReaderReady&&setTimeout(()=>{this._ebookReader.resize()},10)}};var v=class extends s{constructor(A){super(A)}create(){this.setConfig("mobileFooterPanel"),super.create()}resize(){super.resize(),this.$options.css("left",Math.floor(this.$element.width()/2-this.$options.width()/2))}};var h=class extends R{constructor(A){super(A)}create(){this.setConfig("settingsDialogue"),super.create()}};var m=class extends D{constructor(A){super(A)}create(){this.setConfig("shareDialogue"),super.create()}update(){super.update(),this.code=this.extension.getEmbedScript(this.options.embedTemplate,this.currentWidth,this.currentHeight),this.$code.val(this.code)}resize(){super.resize()}};var z={options:{allowStealFocus:!1,authAPIVersion:1,bookmarkThumbHeight:150,bookmarkThumbWidth:90,dropEnabled:!0,footerPanelEnabled:!0,headerPanelEnabled:!0,leftPanelEnabled:!0,limitLocales:!1,metrics:[{type:"sm",minWidth:0},{type:"md",minWidth:768},{type:"lg",minWidth:1024},{type:"xl",minWidth:1280}],multiSelectionMimeType:"application/zip",navigatorEnabled:!0,openTemplate:"http://universalviewer.io?manifest={0}",overrideFullScreen:!1,pagingEnabled:!0,pagingOptionEnabled:!0,pessimisticAccessControl:!1,preserveViewport:!1,rightPanelEnabled:!0,saveUserSettings:!1,clickToZoomEnabled:!0,searchWithinEnabled:!0,termsOfUseEnabled:!1,theme:"uv-en-GB-theme",tokenStorage:"session",useArrowKeysToNavigate:!1,zoomToSearchResultEnabled:!0},modules:{leftPanel:{options:{expandFullEnabled:!1,panelAnimationDuration:250,panelCollapsedWidth:30,panelExpandedWidth:255,panelOpen:!1},content:{collapse:"$collapse",collapseFull:"$collapseFull",expand:"$expandContents",expandFull:"$expandGallery"}},ebookLeftPanel:{options:{expandFullEnabled:!1,panelAnimationDuration:250,panelCollapsedWidth:30,panelExpandedWidth:255,panelOpen:!1},content:{title:"$contents",collapse:"$collapse",collapseFull:"$collapseFull",expand:"$expandContents",expandFull:"$expandGallery"}},dialogue:{options:{topCloseButtonEnabled:!1},content:{close:"$close"}},footerPanel:{options:{bookmarkEnabled:!1,downloadEnabled:!0,embedEnabled:!1,feedbackEnabled:!1,fullscreenEnabled:!0,minimiseButtons:!0,moreInfoEnabled:!0,openEnabled:!1,printEnabled:!1,shareEnabled:!0},content:{bookmark:"$add_to_bookmarks",download:"$download",embed:"$embed",exitFullScreen:"$exitFullScreen",feedback:"$feedback",fullScreen:"$fullScreen",moreInfo:"$moreInfo",open:"$open",share:"$share"}},genericDialogue:{options:{topCloseButtonEnabled:!1},content:{close:"$close",emptyValue:"$emptyValue",invalidNumber:"$invalidNumber",noMatches:"$noMatches",ok:"$ok",pageNotFound:"$pageNotFound",refresh:"$refresh"}},headerPanel:{options:{centerOptionsEnabled:!0,localeToggleEnabled:!1,settingsButtonEnabled:!0},content:{close:"$close",settings:"$settings"}},helpDialogue:{options:{topCloseButtonEnabled:!1},content:{close:"$close",text:"$placeholder_text",title:"$help"}},moreInfoRightPanel:{options:{canvasDisplayOrder:"",canvasExclude:"",copyToClipboardEnabled:!1,expandFullEnabled:!1,limitToRange:!1,manifestDisplayOrder:"",manifestExclude:"",panelAnimationDuration:250,panelCollapsedWidth:30,panelExpandedWidth:255,panelOpen:!1,rtlLanguageCodes:"ar, ara, dv, div, he, heb, ur, urd",showAllLanguages:!1,textLimit:4,textLimitType:"lines",topCloseButtonEnabled:!1},content:{attribution:"$attribution",canvasHeader:"$aboutTheImage",close:"$close",collapse:"$collapseInformation",collapseFull:"$collapseGallery",copiedToClipboard:"$copiedToClipboard",copyToClipboard:"$copyToClipboard",description:"$description",expand:"$expandInformation",expandFull:"$expandGallery",holdingText:"$moduleGoesHere",less:"$less",lessAriaLabelTemplate:"$lessAriaLabelTemplate",license:"$license",logo:"$logo",manifestHeader:"$aboutTheItem",more:"$more",moreAriaLabelTemplate:"$moreAriaLabelTemplate",noData:"$noDataToDisplay",page:"$page",rangeHeader:"$aboutThisSection",title:"$moreInformation"}},centerPanel:{options:{titleEnabled:!0,subtitleEnabled:!0,mostSpecificRequiredStatement:!0,requiredStatementEnabled:!0},content:{attribution:"$attribution",close:"$close",closeAttribution:"$closeAttribution"}},ebookCenterPanel:{options:{titleEnabled:!0,subtitleEnabled:!0,mostSpecificRequiredStatement:!0,requiredStatementEnabled:!0},content:{attribution:"$attribution",close:"$close",closeAttribution:"$closeAttribution"}},settingsDialogue:{options:{topCloseButtonEnabled:!1},content:{close:"$close",locale:"$locale",navigatorEnabled:"$navigatorEnabled",clickToZoomEnabled:"$clickToZoomEnabled",pagingEnabled:"$twoPageView",reducedMotion:"$reducedMotion",truncateThumbnailLabels:"$truncateThumbnailLabels",preserveViewport:"$preserveViewport",title:"$settings",website:"$uvWebsite"}},shareDialogue:{options:{embedEnabled:!0,shareEnabled:!0,embedTemplate:'<iframe src="{0}" width="{1}" height="{2}" allowfullscreen frameborder="0" title="{3}"></iframe>',instructionsEnabled:!1,shareFrameEnabled:!0,shareManifestsEnabled:!0,topCloseButtonEnabled:!1},content:{close:"$close",customSize:"custom",embed:"Embed",embedInstructions:"To embed this item in your own website, copy and paste the code below.",height:"Height",iiif:"IIIF Manifest",share:"Share",shareInstructions:"To share this item, copy the URL below.",size:"Size:",width:"Width",shareUrl:"$shareUrl"}},authDialogue:{options:{topCloseButtonEnabled:!1},content:{cancel:"$cancel",close:"$close",confirm:"$confirm"}},adjustImageDialogue:{options:{topCloseButtonEnabled:!1},content:{title:"$adjustImage",brightness:"$brightness",contrast:"$contrast",saturation:"$saturation",close:"$close",reset:"$reset",remember:"$remember"}},clickThroughDialogue:{options:{topCloseButtonEnabled:!1},content:{close:"$close",viewTerms:"$viewTerms"}},downloadDialogue:{options:{topCloseButtonEnabled:!1},content:{allPages:"$allPages",close:"$close",currentViewAsJpg:"$currentViewAsJpg",currentViewAsJpgExplanation:"$openNewWindow",download:"$download",downloadSelection:"$downloadSelection",downloadSelectionExplanation:"$downloadSelectionExplanation",editSettings:"$editSettings",entireDocument:"$entireDocument",entireFileAsOriginal:"$entireFile",entireFileAsOriginalWithFormat:"$entireFileAsOriginalWithFormat",individualPages:"$individualPages",noneAvailable:"$noDownloadOptionsAvailable",pagingNote:"$pagingNote",preview:"$preview",selection:"$selection",termsOfUse:"$termsOfUse",title:"$download",wholeImageHighRes:"$wholeImageHighRes",wholeImageHighResExplanation:"$openNewWindow",wholeImageLowResAsJpg:"$wholeImageLowResAsJpg",wholeImageLowResAsJpgExplanation:"$openNewWindow",wholeImagesHighRes:"$wholeImagesHighRes",wholeImagesHighResExplanation:"$wholeImagesHighResExplanation"}},loginDialogue:{options:{topCloseButtonEnabled:!1},content:{login:"$login",logout:"$logout",cancel:"$cancel",close:"$close"}},restrictedDialogue:{options:{topCloseButtonEnabled:!1},content:{cancel:"$cancel",close:"$close"}}},localisation:{label:"English (GB)",locales:[{name:"cy-GB",label:"Cymraeg"},{name:"en-GB",label:"English (GB)"},{name:"fr-FR",label:"Fran\xE7ais (FR)"},{name:"pl-PL",label:"Polski"},{name:"sv-SE",label:"Svenska"}]},content:{authCORSError:"$authCORSError",authorisationFailedMessage:"$authorisationFailedMessage",canvasIndexOutOfRange:"$canvasIndexOutOfRange",fallbackDegradedLabel:"$fallbackDegradedLabel",fallbackDegradedMessage:"$fallbackDegradedMessage",forbiddenResourceMessage:"$forbiddenResourceMessage",termsOfUse:"$termsOfUse",mediaViewer:"$mediaViewer",skipToDownload:"$skipToDownload"}};var I=class extends B{constructor(){super(...arguments);this.defaultConfig=z}create(){super.create(),this.extensionHost.subscribe(a.CANVAS_INDEX_CHANGE,t=>{this.viewCanvas(t)}),this.extensionHost.subscribe(i.CFI_FRAGMENT_CHANGE,t=>{this.cfiFragement=t,this.fire(i.CFI_FRAGMENT_CHANGE,this.cfiFragement)})}createModules(){super.createModules(),this.isHeaderPanelEnabled()?this.headerPanel=new y(this.shell.$headerPanel):this.shell.$headerPanel.hide(),this.isLeftPanelEnabled()?this.leftPanel=new c(this.shell.$leftPanel):this.shell.$leftPanel.hide(),this.centerPanel=new g(this.shell.$centerPanel),this.isRightPanelEnabled()?this.rightPanel=new k(this.shell.$rightPanel):this.shell.$rightPanel.hide(),this.isFooterPanelEnabled()?(this.footerPanel=new s(this.shell.$footerPanel),this.mobileFooterPanel=new v(this.shell.$mobileFooterPanel)):this.shell.$footerPanel.hide(),this.$moreInfoDialogue=$('<div class="overlay moreInfo" aria-hidden="true"></div>'),this.shell.$overlays.append(this.$moreInfoDialogue),this.moreInfoDialogue=new G(this.$moreInfoDialogue),this.$shareDialogue=$('<div class="overlay share" aria-hidden="true"></div>'),this.shell.$overlays.append(this.$shareDialogue),this.shareDialogue=new m(this.$shareDialogue),this.$downloadDialogue=$('<div class="overlay download" aria-hidden="true" role="region"></div>'),this.shell.$overlays.append(this.$downloadDialogue),this.downloadDialogue=new b(this.$downloadDialogue),this.$settingsDialogue=$('<div class="overlay settings" aria-hidden="true"></div>'),this.shell.$overlays.append(this.$settingsDialogue),this.settingsDialogue=new h(this.$settingsDialogue),this.isHeaderPanelEnabled()&&this.headerPanel.init(),this.isLeftPanelEnabled()&&this.leftPanel.init(),this.isRightPanelEnabled()&&this.rightPanel.init(),this.isFooterPanelEnabled()&&this.footerPanel.init()}isLeftPanelEnabled(){return!0}render(){super.render(),this.checkForCFIParam()}getEmbedScript(t,o,l){let E=this.getAppUri(),d=this.helper.getLabel()||"",w=`${E}#?manifest=${this.helper.manifestUri}&cfi=${this.cfiFragement}`;return x.format(t,w,o.toString(),l.toString(),d)}checkForCFIParam(){let t=this.data.cfi;t&&this.extensionHost.publish(i.CFI_FRAGMENT_CHANGE,t)}};export{I as default};