1
- import ArchivalIIIFViewer from "@archival-iiif/viewer-react" ;
1
+ import Mirador from '@columbia-libraries/mirador/dist/es/src' ;
2
+ import miradorDownloadPlugins from '@columbia-libraries/mirador/dist/es/src/culPlugins/mirador-downloaddialog' ;
3
+ import canvasRelatedLinksPlugin from '@columbia-libraries/mirador/dist/es/src/culPlugins/mirador-canvasRelatedLinks'
4
+ import citationSidebar from '@columbia-libraries/mirador/dist/es/src/culPlugins/mirador-citations' ;
5
+ import hintingSidebar from '@columbia-libraries/mirador/dist/es/src/culPlugins/mirador-hinting-sidebar' ;
6
+ import videoJSPlugin from '@columbia-libraries/mirador/dist/es/src/culPlugins/mirador-videojs' ;
7
+ import viewerNavigation from '@columbia-libraries/mirador/dist/es/src/culPlugins/mirador-pageIconViewerNavigation' ;
8
+ import viewXmlPlugin from '@columbia-libraries/mirador/dist/es/src/culPlugins/mirador-viewXml' ;
9
+ import collectionFoldersPlugin from '@columbia-libraries/mirador/dist/es/src/culPlugins/mirador-selectCollectionFolders' ;
10
+ const flattenPluginConfigs = ( ...plugins ) => plugins . reduce (
11
+ ( acc , curr ) => {
12
+ return acc . concat ( [ ...curr ] )
13
+ } , [ ]
14
+ ) ;
15
+
2
16
$ ( document ) . ready ( function ( ) {
3
- var manifestUrl = $ ( '#aiiif' ) . data ( 'manifest' ) ;
17
+ const manifestUrl = $ ( '#aiiif' ) . data ( 'manifest' ) ;
4
18
if ( manifestUrl ) {
5
- new ArchivalIIIFViewer ( { id : 'aiiif' , manifest : manifestUrl } ) ;
19
+ const numChildren = $ ( '#aiiif' ) . data ( 'num-children' ) ;
20
+ const startCanvas = function ( queryParams ) {
21
+ if ( queryParams . get ( "canvas" ) ) {
22
+ const canvases = queryParams . get ( "canvas" ) . split ( ',' ) ;
23
+ const canvas = canvases [ 0 ] ;
24
+ return canvas . startsWith ( '../' ) ? manifestUrl . replace ( '/manifest' , canvas . slice ( 2 ) ) : canvas ;
25
+ } else return null ;
26
+ } ( new URL ( document . location ) . searchParams ) ;
27
+ const viewConfig = { } ;
28
+ if ( numChildren && numChildren === 1 ) {
29
+ viewConfig . views = [
30
+ { key : 'single' }
31
+ ] ;
32
+ viewConfig . defaultView = 'single' ;
33
+ }
34
+ Mirador . viewer (
35
+ {
36
+ id : 'aiiif' ,
37
+ window : {
38
+ allowClose : false ,
39
+ allowFullscreen : true ,
40
+ allowMaximize : false ,
41
+ panels : {
42
+ info : true ,
43
+ canvas : true
44
+ } ,
45
+ canvasLink : {
46
+ active : true ,
47
+ enabled : true ,
48
+ singleCanvasOnly : false ,
49
+ providers : [ ] ,
50
+ getCanvasLink : ( manifestId , canvases ) => {
51
+ const baseUri = window . location . href . replace ( window . location . search , '' ) ;
52
+ const canvasIndices = canvases . map (
53
+ ( canvas ) => canvas . id . startsWith ( manifestId . replace ( '/manifest' , '' ) ) ? '../canvas/' + canvas . id . split ( "/" ) . slice ( - 2 ) . join ( '/' ) : canvas . id ,
54
+ ) ;
55
+ return `${ baseUri } ?canvas=${ canvasIndices . join ( "," , ) } ` ;
56
+ }
57
+ } ,
58
+ ...viewConfig ,
59
+ } ,
60
+ windows : [
61
+ {
62
+ manifestId : manifestUrl ,
63
+ canvasId : startCanvas ,
64
+ }
65
+ ] ,
66
+ workspace : {
67
+ showZoomControls : true ,
68
+ } ,
69
+ workspaceControlPanel : {
70
+ enabled : false
71
+ } ,
72
+ miradorDownloadPlugin : {
73
+ restrictDownloadOnSizeDefinition : true ,
74
+ } ,
75
+ translations : {
76
+ en : { openCompanionWindow_citation : "Citation" } ,
77
+ } ,
78
+ } ,
79
+ flattenPluginConfigs ( canvasRelatedLinksPlugin , citationSidebar , collectionFoldersPlugin , hintingSidebar , miradorDownloadPlugins , videoJSPlugin , viewerNavigation , viewXmlPlugin ) ,
80
+ ) ;
6
81
}
7
82
} ) ;
0 commit comments