Sha256: c3680e67500a059355bff4da5822d7da474b1464b818b74b7e20b7396f9d6bc8

Contents?: true

Size: 1.34 KB

Versions: 14

Compression:

Stored size: 1.34 KB

Contents

// = require decidim/map/factory
// = require_self

((exports) => {
  const $ = exports.$; // eslint-disable-line

  exports.Decidim = exports.Decidim || {};

  $(() => {
    // Load the map controller factory method in the document.ready handler to
    // allow overriding it by any script that is loaded before the document is
    // ready.
    const createMapController = exports.Decidim.createMapController;

    let $mapElements = $("[data-decidim-map]");
    if ($mapElements.length < 1 && $("#map").length > 0) {
      throw new Error(
        "DEPRECATION: Please update your maps customizations or include 'decidim/map/legacy.js' for legacy support!"
      );
    }

    $mapElements.each((_i, el) => {
      const $map = $(el);
      let mapId = $map.attr("id");
      if (!mapId) {
        mapId = `map-${Math.random().toString(36).substr(2, 9)}`;
        $map.attr("id", mapId);
      }

      const mapConfig = $map.data("decidim-map");
      const ctrl = createMapController(mapId, mapConfig);
      const map = ctrl.load();

      $map.data("map", map);
      $map.data("map-controller", ctrl);

      $map.trigger("configure.decidim", [map, mapConfig]);

      ctrl.start();

      // Indicates the map is loaded with the map objects initialized and ready
      // to be used.
      $map.trigger("ready.decidim", [map, mapConfig]);
    });
  });
})(window);

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
decidim-core-0.24.3 app/assets/javascripts/decidim/map.js.es6
decidim-core-0.23.6 app/assets/javascripts/decidim/map.js.es6
decidim-core-0.24.2 app/assets/javascripts/decidim/map.js.es6
decidim-core-0.23.5 app/assets/javascripts/decidim/map.js.es6
decidim-core-0.24.1 app/assets/javascripts/decidim/map.js.es6
decidim-core-0.24.0 app/assets/javascripts/decidim/map.js.es6
decidim-core-0.24.0.rc2 app/assets/javascripts/decidim/map.js.es6
decidim-core-0.23.4 app/assets/javascripts/decidim/map.js.es6
decidim-core-0.24.0.rc1 app/assets/javascripts/decidim/map.js.es6
decidim-core-0.23.3 app/assets/javascripts/decidim/map.js.es6
decidim-core-0.23.2 app/assets/javascripts/decidim/map.js.es6
decidim-core-0.23.1 app/assets/javascripts/decidim/map.js.es6
decidim-core-0.23.1.rc1 app/assets/javascripts/decidim/map.js.es6
decidim-core-0.23.0 app/assets/javascripts/decidim/map.js.es6