#66 Add openseadragon-bookmark url plugin#77
Conversation
| <?php | ||
|
|
||
| /** | ||
| * @file | ||
| * Attach bookmark-url.js. | ||
| */ | ||
|
|
||
| /** | ||
| * Attach openseadragon-bookmark-url.js to all pages. | ||
| * | ||
| * @todo It would be good to target this better, e.g. load only when OSD is loaded. | ||
| * | ||
| * {@inheritDoc} | ||
| */ | ||
| function openseadragon_bookmark_url_page_attachments(array &$page) { | ||
| $page['#attached']['library'][] = 'openseadragon_bookmark_url/openseadragon_bookmark_url'; | ||
| } |
There was a problem hiding this comment.
| <?php | |
| /** | |
| * @file | |
| * Attach bookmark-url.js. | |
| */ | |
| /** | |
| * Attach openseadragon-bookmark-url.js to all pages. | |
| * | |
| * @todo It would be good to target this better, e.g. load only when OSD is loaded. | |
| * | |
| * {@inheritDoc} | |
| */ | |
| function openseadragon_bookmark_url_page_attachments(array &$page) { | |
| $page['#attached']['library'][] = 'openseadragon_bookmark_url/openseadragon_bookmark_url'; | |
| } |
Can we just use libraries-extend on openseadragon/openseadragon in this module's libraries file?
There was a problem hiding this comment.
AFAICT library-extends is only available for themes, not modules https://www.drupal.org/docs/develop/theming-drupal/adding-assets-css-js-to-a-drupal-theme-via-librariesyml#s-libraries-extend. I tried using openseadragon_bookmark_url_library_info_alter() to declare a dependency of openseadragon on openseadragon_bookmark_url but that causes a circular dependency.
For now, I've used openseadragon_bookmark_url_preprocess_field() to check if a field withopenseadragon_formatter is being used.
There was a problem hiding this comment.
Ah - I guess modules have to use hook_library_info_alter and can't leverage library-extends.
…rmatter is used
|
@joecorall I've added the ability to specify a media type and (string) field to obtain a bookmark URL from, so that it can be shared into javascript via settings, and thus set the zoom, x&y coordinates for an OSD image. That code has been pushed. I have other code that attempted to form alter the openseadragon settings form to allow the media type and field to be selected but it's broken (when submitted, the original openseadragon settings form loses its injected variables, e.g. http client. I don't need the UI, so that can be addressed as a distinct issue/PR later. |
| @@ -0,0 +1,5 @@ | |||
| services: | |||
| openseadragon_bookmark_url.config: | |||
There was a problem hiding this comment.
I don't think this is used? If so can we drop this services file and modules/openseadragon_bookmark_url/src/BookmarkUrlConfig.php
joecorall
left a comment
There was a problem hiding this comment.
I tested this PR and the bookmark functionality works. Very nice!
I think we should consider using hook_library_info_alter to add the bookmark JS to OSD when this module is enabled instead of openseadragon_bookmark_url_preprocess_field
| } | ||
| }; | ||
|
|
||
| })($, Drupal, drupalSettings, once); |
There was a problem hiding this comment.
Not sure that referencing what I assume is supposed to be jQuery as $ here is safe. On the other hand, it doesn't seem to be used, so it probably shouldn't be here in the first place? drupalSettings doesn't appear to be used directly, either.
There was a problem hiding this comment.
Actually, yeah, the attempt to use $ globally should cause warnings about unresolvable symbols, given Drupal loads jQuery with .noConflict() by default.
Somewhat related: If the aliasing of jQuery to $ isn't necessary (because jQuery isn't actually being used), then the function wrapping the behavior definition as a whole isn't necessary.
GitHub Issue: #66
Release pull requests, etc.)
What does this Pull Request do?
Adds local copy of openseadragon-bookmark-url and calls
bookmarkUrl(). This allows a URL fragment to track x, y, and zoom so that a tiled image can be presented already zoomed in to a feature of interest, e.g. a face in a group photograph.How should this be tested?
drush en openseadragon_bookmark_url.Interested parties
Tag (@ mention) interested parties or, if unsure, @Islandora/committers