Sha256: 742fe729f8e1cd3ba7cced3378dd918c3e3222d7a862c181831f5a78c078ca8f

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

/* eslint-disable no-alert */

import PolygonViewer from "src/decidim/participatory_documents/pdf/polygon_viewer";
import "src/decidim/participatory_documents/pdf_notifications";
import "src/decidim/participatory_documents/global";

const openLogin = (evt) => {
  evt.stopPropagation();
  if (!window.parent) {
    // This shouldn't appear because is in a iframe, but just in case (or for developing)
    alert("Login required");
  }

  // add the rediret_to otherwise is going to be the iframe url and the user will lose the context
  const loginForm = window.parent.document.getElementById("login_new_user");
  let parts = loginForm.action.split("?")
  let params = new URLSearchParams(parts[1]);
  params.append("redirect_url", window.parent.location.href);
  loginForm.action = `${parts[0]}?${params.toString()}`;

  window.parent.$("#loginModal").foundation("open")
};

window.InitDocumentManagers = (options) => {
  options.globalSuggestionsButton.addEventListener("click", openLogin);

  options.exportButton.addEventListener("click", openLogin);
};

// Call this on an annotation layer to initialize the polygon viewer (public side)
window.InitPolygonViewer = (layer, boxes, options) => {
  let viewer = new PolygonViewer(layer, boxes, { i18n: options.i18n});

  viewer.onBoxClick = (box, evt) => {
    openLogin(evt);
  }

  return viewer;
};

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
decidim-participatory_documents-0.2.2 app/packs/src/decidim/participatory_documents/pdf_off.js
decidim-participatory_documents-0.2.1 app/packs/src/decidim/participatory_documents/pdf_off.js