Sha256: 8893e5b5bc7d949467678d14748ecbcaf66f72013580d6bf40b46020bf20032a

Contents?: true

Size: 1.74 KB

Versions: 1

Compression:

Stored size: 1.74 KB

Contents

//= require jquery.truncate

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

  const sanitizeCenter = (string) => {
    if(string) {
      const parts = string.split(",")
      if (parts.length >= 2) {
        const lat = parseFloat(parts[0]);
        const lng = parseFloat(parts[1]);
        if(lat && lng) {
          return [lat, lng];
        }
      }
    }
    return null
  };
  const options = () => {
    return {
      length: $("#awesome-map").data("truncate") || 255,
      center: sanitizeCenter($("#awesome-map").data("map-center")),
      zoom: $("#awesome-map").data("map-zoom"),
      menu: {
        amendments: $("#awesome-map").data("menu-amendments"),
        meetings: $("#awesome-map").data("menu-meetings"),
        hashtags: $("#awesome-map").data("menu-hashtags")
      }
    }
  };

  const truncate = (string) => {
    return $.truncate(string, options());
  };

  const show = () => {
    return {
      withdrawn: $("#awesome-map").data("show-withdrawn"),
      accepted: $("#awesome-map").data("show-accepted"),
      evaluating: $("#awesome-map").data("show-evaluating"),
      notAnswered: $("#awesome-map").data("show-not-answered"),
      rejected: $("#awesome-map").data("show-rejected")
    }
  };

  const hideControls = () => $("#awesome-map").data("hide-controls");
  const collapsedMenu = () => $("#awesome-map").data("collapsed");
  const components = () => $("#awesome-map").data("components");

  exports.AwesomeMap = exports.AwesomeMap || {};
  exports.AwesomeMap.truncate = truncate;
  exports.AwesomeMap.options = options;
  exports.AwesomeMap.show = show;
  exports.AwesomeMap.collapsedMenu = collapsedMenu;
  exports.AwesomeMap.hideControls = hideControls;
  exports.AwesomeMap.components = components;
})(window);

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
decidim-decidim_awesome-0.7.2 app/assets/javascripts/decidim/decidim_awesome/awesome_map/utilities.js.es6