UNPKG

@tindtechnologies/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) 11.1 kB
import{a as D}from"./chunk-JTCBS63U.js";import{a as U}from"./chunk-7FDKMLDJ.js";import{b as y,e as Q,g as E,h as B,i as C,j as k,k as R}from"./chunk-PYNED64U.js";import{c as z}from"./chunk-J6QTJS4P.js";import{a as o}from"./chunk-M4MN2QTO.js";import{b as M}from"./chunk-IRIM6TPQ.js";import{b as l,g}from"./chunk-5XPHF4E5.js";import{d as F}from"./chunk-L67DAW3A.js";var G=F(z());var b=window.$,r=class extends y{constructor(A){super(A)}create(){this.setConfig("fileLinkCenterPanel"),super.create(),this.extensionHost.subscribe(o.OPEN_EXTERNAL_RESOURCE,A=>{this.openMedia(A)}),this.$scroll=b('<div class="scroll"></div>'),this.$content.append(this.$scroll),this.$downloadItems=b("<ol></ol>"),this.$scroll.append(this.$downloadItems),this.$downloadItemTemplate=b('<li><img/><div class="col2"><a class="filename" target="_blank" download=""></a><span class="label"></span><a class="description" target="_blank" download=""></a></div></li>'),this.title=this.extension.helper.getLabel()}async openMedia(A){await this.extension.getExternalResources(A);let a=this.extension.helper.getCurrentCanvas().getContent(),e;for(let n=0;n<a.length;n++){let c=a[n];if(!c.getBody().length)continue;e=this.$downloadItemTemplate.clone();let h=e.find(".filename"),N=e.find(".label"),m=e.find("img"),w=e.find(".description"),p=c.getBody()[0],t=p.getProperty("id");t&&(h.prop("href",t),h.text(t.substr(t.lastIndexOf("/")+1)));let f=G.LanguageMap.getValue(p.getLabel());f&&N.text(l(f));let I=c.getProperty("thumbnail");I?m.prop("src",I):m.hide();let x=p.getProperty("description");x&&(w.text(l(x)),t&&w.prop("href",t)),this.$downloadItems.append(e)}this.extensionHost.publish(g.EXTERNAL_RESOURCE_OPENED),this.extensionHost.publish(g.LOAD)}resize(){super.resize(),this.title&&this.$title.text(l(this.title)),this.$scroll.height(this.$content.height()-this.$scroll.verticalMargins())}};var d=class extends k{constructor(A){super(A)}create(){this.setConfig("settingsDialogue"),super.create()}};var s=class extends R{constructor(A){super(A)}create(){this.setConfig("shareDialogue"),super.create()}update(){super.update(),this.embedCode=this.extension.getEmbedScript(this.options.embedTemplate,this.currentWidth,this.currentHeight),this.$embedCode.val(this.embedCode)}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,preserveViewport:!1,rightPanelEnabled:!0,saveUserSettings:!1,clickToZoomEnabled:!0,searchWithinEnabled:!0,termsOfUseEnabled:!1,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"}},shareDialogue:{options:{embedEnabled:!0,shareEnabled:!0,embedPath:"/uv.html",embedTemplate:'<iframe src="{0}" width="{1}" height="{2}" allowfullscreen frameborder="0" title="{3}"></iframe>',shareManifestsEnabled:!0,topCloseButtonEnabled:!1,copyToClipboardEnabled:!0},content:{close:"$close",copyBtn:"$copyBtn",copyToClipboard:"$copyToClipboard",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.",shareLink:"$shareLink",size:"Size:",width:"Width",shareUrl:"$shareUrl"}},centerPanel:{options:{titleEnabled:!0,subtitleEnabled:!0,mostSpecificRequiredStatement:!0,requiredStatementEnabled:!0},content:{attribution:"$attribution",close:"$close",closeAttribution:"$closeAttribution"}},fileLinkCenterPanel:{options:{titleEnabled:!0,subtitleEnabled:!0,mostSpecificRequiredStatement:!0,requiredStatementEnabled:!0},content:{attribution:"$attribution",close:"$close",closeAttribution:"$closeAttribution"}},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",openLeftPanel:"$openLeftPanel",closeLeftPanel:"$closeLeftPanel",openRightPanel:"$openRightPanel",closeRightPanel:"$closeRightPanel"}},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,helpEnabled:!1,helpUrl:"https://universalviewer.io"},content:{close:"$close",settings:"$settings",help:"$help"}},helpDialogue:{options:{topCloseButtonEnabled:!1},content:{close:"$close",text:"$placeholder_text",title:"$help"}},restrictedDialogue:{options:{topCloseButtonEnabled:!1},content:{cancel:"$cancel",close:"$close"}},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"}},resourcesLeftPanel:{options:{expandFullEnabled:!1,panelAnimationDuration:250,panelCollapsedWidth:30,panelExpandedWidth:255,panelOpen:!0,oneColThumbHeight:320,oneColThumbWidth:200,twoColThumbHeight:150,twoColThumbWidth:90},content:{title:"$contents",collapse:"$collapse",collapseFull:"$collapseFull",expand:"$expandContents",expandFull:"$expandGallery"}},dialogue:{options:{topCloseButtonEnabled:!1},content:{close:"$close"}},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:"$entireFileWithFormat",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"}},settingsDialogue:{options:{topCloseButtonEnabled:!1},content:{close:"$close",locale:"$locale",navigatorEnabled:"$navigatorEnabled",clickToZoomEnabled:"$clickToZoomEnabled",reducedMotion:"$reducedMotion",truncateThumbnailLabels:"$truncateThumbnailLabels",preserveViewport:"$preserveViewport",title:"$settings",website:"$uvWebsite"}}},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 v=class extends Q{constructor(){super(...arguments);this.defaultConfig=Z}create(){super.create(),this.extensionHost.subscribe(o.CANVAS_INDEX_CHANGE,i=>{this.viewCanvas(i)}),this.extensionHost.subscribe(o.THUMB_SELECTED,i=>{this.extensionHost.publish(o.CANVAS_INDEX_CHANGE,i)})}createModules(){super.createModules(),this.isHeaderPanelEnabled()?this.headerPanel=new B(this.shell.$headerPanel):this.shell.$headerPanel.hide(),this.isLeftPanelEnabled()&&(this.leftPanel=new D(this.shell.$leftPanel)),this.centerPanel=new r(this.shell.$centerPanel),this.isRightPanelEnabled()&&(this.rightPanel=new C(this.shell.$rightPanel)),this.isFooterPanelEnabled()?this.footerPanel=new E(this.shell.$footerPanel):this.shell.$footerPanel.hide(),this.$helpDialogue=$('<div class="overlay help" aria-hidden="true"></div>'),this.shell.$overlays.append(this.$helpDialogue),this.helpDialogue=new U(this.$helpDialogue),this.$shareDialogue=$('<div class="overlay share" aria-hidden="true"></div>'),this.shell.$overlays.append(this.$shareDialogue),this.shareDialogue=new s(this.$shareDialogue),this.$settingsDialogue=$('<div class="overlay settings" aria-hidden="true"></div>'),this.shell.$overlays.append(this.$settingsDialogue),this.settingsDialogue=new d(this.$settingsDialogue),this.isLeftPanelEnabled()&&this.leftPanel.init(),this.isRightPanelEnabled()&&this.rightPanel.init()}render(){super.render()}isLeftPanelEnabled(){return M.getBool(this.data.config.options.leftPanelEnabled,!0)&&(this.helper.isMultiCanvas()||this.helper.isMultiSequence()||this.helper.hasResources())}getEmbedScript(i,a,e){let n=new URLSearchParams({manifest:this.helper.manifestUri,c:this.helper.collectionIndex.toString(),m:this.helper.manifestIndex.toString(),cv:this.helper.canvasIndex.toString()});return super.buildEmbedScript(i,a,e,n)}};export{v as default};