diff --git a/js/openseadragon_viewer.js b/js/openseadragon_viewer.js index cec89d8..f6d6fb0 100644 --- a/js/openseadragon_viewer.js +++ b/js/openseadragon_viewer.js @@ -4,7 +4,7 @@ * @file * Displays OpenSeadragon viewer. */ -(function($) { +(function(once) { 'use strict'; /** @@ -21,16 +21,19 @@ Object.keys(settings.openseadragon).forEach(function(osdViewerId) { // Use custom element #id if set. base = '#' + osdViewerId; - $(base, context).once('openSeadragonViewer').each(function () { + once('openSeadragonViewer', base, context).forEach(function () { Drupal.openSeadragonViewer[base] = new Drupal.openSeadragonViewer(base, settings.openseadragon[osdViewerId]); }); }); }, - detach: function() { - $(base).removeClass('openSeadragonViewer-processed'); - $(base).removeData(); - $(base).off(); - delete Drupal.openSeadragonViewer[base]; + detach: function(context, settings, trigger) { + Object.keys(settings.openseadragon).forEach(function(osdViewerId) { + // Use custom element #id if set. + base = '#' + osdViewerId; + once.remove('openSeadragonViewer', base, context).forEach(function () { + delete Drupal.openSeadragonViewer[base]; + }); + }); } }; @@ -122,4 +125,4 @@ } }; -})(jQuery); +})(once); diff --git a/openseadragon.libraries.yml b/openseadragon.libraries.yml index 8192c01..cb55057 100644 --- a/openseadragon.libraries.yml +++ b/openseadragon.libraries.yml @@ -6,9 +6,8 @@ init: component: css/openseadragon.css: {} dependencies: - - core/jquery - - core/jquery.once - core/drupal + - core/once - core/drupalSettings - openseadragon/openseadragon openseadragon: