Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue-1572: Support multiple openseadragon viewer windows #28

Merged
merged 1 commit into from
Aug 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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