@saltcorn/mobile-app 1.0.0-beta.17 → 1.0.0-beta.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@saltcorn/mobile-app",
3
3
  "displayName": "Saltcorn mobile app",
4
- "version": "1.0.0-beta.17",
4
+ "version": "1.0.0-beta.18",
5
5
  "description": "Apache Cordova application with @saltcorn/markup",
6
6
  "main": "index.js",
7
7
  "scripts": {
@@ -326,6 +326,23 @@ function handleOpenModal() {
326
326
  return result;
327
327
  }
328
328
 
329
+ function isModalOpen() {
330
+ const iframe = document.getElementById("content-iframe");
331
+ if (!iframe) return false;
332
+ const openModal = iframe.contentWindow.$("#scmodal.modal.show");
333
+ return openModal.length > 0;
334
+ }
335
+
336
+ function replaceModalContent(content) {
337
+ const iframe = document.getElementById("content-iframe");
338
+ if (!iframe) throw new Error("No iframe found");
339
+ const openModal = iframe.contentWindow.$("#scmodal.modal.show");
340
+ if (openModal.length === 0) throw new Error("No modal open");
341
+ const modalBody = openModal.find(".modal-body");
342
+ if (modalBody.length === 0) throw new Error("No modal content");
343
+ modalBody.html(content);
344
+ }
345
+
329
346
  function isHtmlFile() {
330
347
  const iframe = document.getElementById("content-iframe");
331
348
  return iframe.getAttribute("is-html-file") === "true";
@@ -334,8 +351,9 @@ function isHtmlFile() {
334
351
  async function handleRoute(route, query, files, data) {
335
352
  const mobileConfig = saltcorn.data.state.getState().mobileConfig;
336
353
  let routeAdded = false;
354
+ const isModal = isModalOpen();
337
355
  try {
338
- clearContentDiv();
356
+ if (!isModal) clearContentDiv();
339
357
  if (
340
358
  mobileConfig.networkState === "none" &&
341
359
  mobileConfig.allowOfflineMode &&
@@ -377,7 +395,9 @@ async function handleRoute(route, query, files, data) {
377
395
  );
378
396
  }
379
397
  } else if (page.content) {
380
- if (!page.replaceIframe) await replaceIframeInnerContent(page.content);
398
+ if (isModal) replaceModalContent(page.content);
399
+ else if (!page.replaceIframe)
400
+ await replaceIframeInnerContent(page.content);
381
401
  else await replaceIframe(page.content, page.isFile);
382
402
  } else {
383
403
  showAlerts([