openlayers.behaviors.js 1.1 KB

123456789101112131415161718192021222324252627282930
  1. (function ($, Drupal) {
  2. "use strict";
  3. Drupal.behaviors.openlayers = {
  4. attach: function (context, settings) {
  5. Drupal.openlayers.pluginManager.attach(context, settings);
  6. $('.openlayers-map:not(.asynchronous)', context).once('openlayers-map', function () {
  7. var map_id = $(this).attr('id');
  8. if (Drupal.settings.openlayers.maps[map_id] !== undefined) {
  9. Drupal.openlayers.processMap(map_id, context);
  10. }
  11. });
  12. // Create dynamic callback functions for asynchronous maps.
  13. $('.openlayers-map.asynchronous', context).once('openlayers-map.asynchronous', function () {
  14. var map_id = $(this).attr('id');
  15. if (Drupal.settings.openlayers.maps[map_id] !== undefined) {
  16. Drupal.openlayers.asyncIsReadyCallbacks[map_id.replace(/[^0-9a-z]/gi, '_')] = function () {
  17. Drupal.openlayers.asyncIsReady(map_id);
  18. };
  19. }
  20. });
  21. },
  22. detach: function (context, settings) {
  23. Drupal.openlayers.pluginManager.detach(context, settings);
  24. }
  25. };
  26. }(jQuery, Drupal));