@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) • 10.4 kB
JavaScript
import{a as H}from"./chunk-VQAXEBVY.js";import{a as A}from"./chunk-YXN24ANC.js";import{c as I,f as y,h as S,i as R,k as T,l as F,m as k}from"./chunk-BIWUBEGG.js";import{c as J}from"./chunk-UYLDA6E6.js";import{b as P,n as C,p as n}from"./chunk-2YE6NNA6.js";import{b as r,g as p}from"./chunk-R6HAKAEO.js";import{c as W}from"./chunk-YAXTLTJC.js";var L=W(J());var h=window.$,c=class extends I{constructor(e){super(e)}create(){this.setConfig("fileLinkCenterPanel"),super.create(),this.extensionHost.subscribe(n.OPEN_EXTERNAL_RESOURCE,e=>{this.openMedia(e)}),this.$scroll=h('<div class="scroll"></div>'),this.$content.append(this.$scroll),this.$downloadItems=h("<ol></ol>"),this.$scroll.append(this.$downloadItems),this.$downloadItemTemplate=h('<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(e){await this.extension.getExternalResources(e);let i=this.extension.helper.getCurrentCanvas().getContent(),t;for(let l=0;l<i.length;l++){let s=i[l];if(!s.getBody().length)continue;t=this.$downloadItemTemplate.clone();let b=t.find(".filename"),M=t.find(".label"),E=t.find("img"),v=t.find(".description"),u=s.getBody()[0],o=u.getProperty("id");o&&(b.prop("href",o),b.text(o.substr(o.lastIndexOf("/")+1)));let w=L.LanguageMap.getValue(u.getLabel());w&&M.text(r(w));let x=s.getProperty("thumbnail");x?E.prop("src",x):E.hide();let D=u.getProperty("description");D&&(v.text(r(D)),o&&v.prop("href",o)),this.$downloadItems.append(t)}this.extensionHost.publish(p.EXTERNAL_RESOURCE_OPENED),this.extensionHost.publish(p.LOAD)}resize(){super.resize(),this.title&&this.$title.text(r(this.title)),this.$scroll.height(this.$content.height()-this.$scroll.verticalMargins())}};var g=class extends F{constructor(e){super(e)}create(){this.setConfig("settingsDialogue"),super.create()}};var m=class extends k{constructor(e){super(e)}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 N={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},U={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,embedTemplate:'<iframe src="{0}" width="{1}" height="{2}" allowfullscreen frameborder="0"></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"}},centerPanel:{options:{titleEnabled:!0,subtitleEnabled:!0,mostSpecificRequiredStatement:!0,requiredStatementEnabled:!0},content:{attribution:"$attribution"}},fileLinkCenterPanel:{options:{titleEnabled:!0,subtitleEnabled:!0,mostSpecificRequiredStatement:!0,requiredStatementEnabled:!0},content:{attribution:"$attribution"}},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"}},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",license:"$license",logo:"$logo",manifestHeader:"$aboutTheItem",more:"$more",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"}},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",pagingEnabled:"$twoPageView",reducedMotion:"$reducedMotion",preserveViewport:"$preserveViewport",title:"$settings",website:"$uvWebsite"}}},Q={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"}]},V={authCORSError:"$authCORSError",authorisationFailedMessage:"$authorisationFailedMessage",canvasIndexOutOfRange:"$canvasIndexOutOfRange",fallbackDegradedLabel:"$fallbackDegradedLabel",fallbackDegradedMessage:"$fallbackDegradedMessage",forbiddenResourceMessage:"$forbiddenResourceMessage",termsOfUse:"$termsOfUse",mediaViewer:"$mediaViewer",skipToDownload:"$skipToDownload"},B={options:N,modules:U,localisation:Q,content:V};var O=class extends y{constructor(){super(...arguments);this.defaultConfig=B}create(){super.create(),this.extensionHost.subscribe(n.CANVAS_INDEX_CHANGE,e=>{this.viewCanvas(e)}),this.extensionHost.subscribe(n.THUMB_SELECTED,e=>{this.extensionHost.publish(n.CANVAS_INDEX_CHANGE,e)})}createModules(){super.createModules(),this.isHeaderPanelEnabled()?this.headerPanel=new R(this.shell.$headerPanel):this.shell.$headerPanel.hide(),this.isLeftPanelEnabled()&&(this.leftPanel=new H(this.shell.$leftPanel)),this.centerPanel=new c(this.shell.$centerPanel),this.isRightPanelEnabled()&&(this.rightPanel=new T(this.shell.$rightPanel)),this.isFooterPanelEnabled()?this.footerPanel=new S(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 A(this.$helpDialogue),this.$shareDialogue=$('<div class="overlay share" aria-hidden="true"></div>'),this.shell.$overlays.append(this.$shareDialogue),this.shareDialogue=new m(this.$shareDialogue),this.$settingsDialogue=$('<div class="overlay settings" aria-hidden="true"></div>'),this.shell.$overlays.append(this.$settingsDialogue),this.settingsDialogue=new g(this.$settingsDialogue),this.isLeftPanelEnabled()&&this.leftPanel.init(),this.isRightPanelEnabled()&&this.rightPanel.init()}render(){super.render()}isLeftPanelEnabled(){return P.getBool(this.data.config.options.leftPanelEnabled,!0)&&(this.helper.isMultiCanvas()||this.helper.isMultiSequence()||this.helper.hasResources())}getEmbedScript(e,f,i){let l=`${this.getAppUri()}#?manifest=${this.helper.manifestUri}&c=${this.helper.collectionIndex}&m=${this.helper.manifestIndex}&cv=${this.helper.canvasIndex}`;return C.format(e,l,f.toString(),i.toString())}};export{O as default};