diff --git a/README.md b/README.md index 4b8c9be..36e3871 100644 --- a/README.md +++ b/README.md @@ -182,6 +182,56 @@ Configure contexts at "Administration » Structure » Context". As noted previously, this is just one way to set up the Mirador viewer configurations. If, for example, you wanted to always use the Mirador viewer for pages and paged content, you could remove the "Mirador" condition from the "Node has term" condition in these contexts. +## Theme Variables + +Mirador's appearance and behaviour is configured via settings passed +to the JavaScript application. Mainly in 'window' and 'workspace' configuration +array. + +These can be specified via theme variables or by passing +them as arguments instantiating the Mirador block class. + +To hide the close button via a theme hook: + +```php +function mymodule_preprocess_mirador(&$variables) { + $variables['window_config']['allowClose'] = FALSE; +} +``` + +To make a minimal UI by instantiating the block: + +```php + $block = \Drupal::service('plugin.manager.block')->createInstance($viewer . '_block', [ + 'iiif_manifest_url' => "/node/$manifest_nid/manifest-single", + 'thumbnail_navigation_position' => 'hidden', + 'window_config' => [ + 'allowClose' => FALSE, + 'allowMaximize' => FALSE, + 'allowTopMenuButton' => FALSE, + 'allowWindowSideBar' => FALSE, + 'hideWindowTitle' => TRUE, + 'panels' => [ + 'info' => FALSE, + 'attribution' => FALSE, + ' canvas' => FALSE, + 'annotations' => FALSE, + 'search' => FALSE, + ], + ], + 'workspace_config' => [ + 'allowNewWindows' => FALSE, + 'isWorkspaceAddVisible' => FALSE, + 'workspaceControlPanel' => [ + 'enable' => FALSE, + ], + + ], + ]); + +``` + +See the Mirador FAQ for more options: https://github.com/ProjectMirador/mirador/wiki/M3---Mirador-3-Frequently-Asked-Questions ## Documentation diff --git a/islandora_mirador.module b/islandora_mirador.module index 298c87a..1b4a348 100644 --- a/islandora_mirador.module +++ b/islandora_mirador.module @@ -20,6 +20,9 @@ function islandora_mirador_theme() { 'variables' => [ 'iiif_manifest_url' => NULL, 'mirador_view_id' => NULL, + 'thumbnail_navigation_position' => 'far-bottom', + 'window_config' => [], + 'workspace_config' => [], ], 'template' => 'mirador', ], @@ -46,7 +49,7 @@ function template_preprocess_mirador(&$variables) { $enabled_plugins = $config->get('mirador_enabled_plugins'); $variables['#attached']['drupalSettings']['mirador']['enabled_plugins'] = array_filter(array_values($enabled_plugins)); - $window_config = []; + $window_config = $variables['window_config']; foreach ($mirador_plugins as $plugin_id => $plugin_definition) { if ($enabled_plugins[$plugin_id]) { $plugin_instance = $mirador_plugin_manager->createInstance($plugin_id); @@ -78,9 +81,10 @@ function template_preprocess_mirador(&$variables) { 'windows' => [ [ 'manifestId' => $variables['iiif_manifest_url'], - 'thumbnailNavigationPosition' => 'far-bottom', + 'thumbnailNavigationPosition' => $variables['thumbnail_navigation_position'], ], - ] + ], + 'workspace' => $variables['workspace_config'], ]; } diff --git a/src/Plugin/Block/MiradorBlock.php b/src/Plugin/Block/MiradorBlock.php index 6af44b8..572f2f2 100644 --- a/src/Plugin/Block/MiradorBlock.php +++ b/src/Plugin/Block/MiradorBlock.php @@ -119,6 +119,13 @@ public function build() { ], ]; + if (!empty($this->configuration['thumbnail_navigation_position'])) { + $build['viewer']['#thumbnail_navigation_position'] = $this->configuration['thumbnail_navigation_position']; + } + if (!empty($this->configuration['window_config'])) { + $build['viewer']['#window_config'] = $this->configuration['window_config']; + $build['viewer']['#workspace_config'] = $this->configuration['workspace_config']; + } return $build; }