Skip to content

Commit

Permalink
support multiple openseadragon viewer windows (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
seth-shaw-unlv authored Aug 26, 2020
1 parent 7376978 commit f99e4a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions js/openseadragon_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
*/
Drupal.behaviors.openSeadragon = {
attach: function(context, settings) {
// Use custom element #id if set.
base = '#' + settings.openseadragon.options.id;
$(base, context).once('openSeadragonViewer').each(function () {
Drupal.openSeadragonViewer[base] = new Drupal.openSeadragonViewer(base, settings.openseadragon);
Object.keys(settings.openseadragon).forEach(function(osdViewerId) {
// Use custom element #id if set.
base = '#' + osdViewerId;
$(base, context).once('openSeadragonViewer').each(function () {
Drupal.openSeadragonViewer[base] = new Drupal.openSeadragonViewer(base, settings.openseadragon[osdViewerId]);
});
});
},
detach: function() {
Expand Down
4 changes: 2 additions & 2 deletions openseadragon.module
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function template_preprocess_openseadragon_formatter(&$variables) {

$viewer_settings['sequenceMode'] = count($tile_sources) > 1 && !$viewer_settings['collectionMode'];

$variables['#attached']['drupalSettings']['openseadragon'] = [
$variables['#attached']['drupalSettings']['openseadragon'][$openseadragon_viewer_id] = [
'basePath' => Url::fromUri($iiif_address),
'fitToAspectRatio' => $viewer_settings['fit_to_aspect_ratio'],
'options' => [
Expand Down Expand Up @@ -146,7 +146,7 @@ function template_preprocess_openseadragon_iiif_manifest_block(&$variables) {

// Attach the viewer, using the image urls obtained from the manifest.
if (!is_null($iiif_address) && !empty($iiif_address) && !empty($tile_sources)) {
$variables['#attached']['drupalSettings']['openseadragon'] = [
$variables['#attached']['drupalSettings']['openseadragon'][$openseadragon_viewer_id] = [
'basePath' => Url::fromUri($iiif_address),
'fitToAspectRatio' => $viewer_settings['fit_to_aspect_ratio'],
'options' => [
Expand Down

0 comments on commit f99e4a2

Please sign in to comment.