@pushword/js-helper 0.0.59 → 0.0.63

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushword/js-helper",
3
- "version": "0.0.59",
3
+ "version": "0.0.63",
4
4
  "description": "Pushword front end helpers. ",
5
5
  "author": "Robin@PiedWeb <contact@piedweb.com>",
6
6
  "license": "MIT",
package/src/app.css ADDED
@@ -0,0 +1,4 @@
1
+ @import "tailwindcss/base";
2
+ @import "tailwindcss/components";
3
+ @import "tailwindcss/utilities";
4
+ @import "@pushword/js-helper/src/tailwind.prose.scss";
package/src/app.js ADDED
@@ -0,0 +1,27 @@
1
+ require("fslightbox");
2
+ import {
3
+ uncloakLinks,
4
+ readableEmail,
5
+ convertImageLinkToWebPLink,
6
+ replaceOn,
7
+ liveBlock,
8
+ } from "@pushword/js-helper/src/helpers.js";
9
+ import { allClickable } from "@pushword/js-helper/src/clickable.js";
10
+
11
+ function onDomChanged() {
12
+ liveBlock();
13
+ convertImageLinkToWebPLink();
14
+ uncloakLinks();
15
+ readableEmail(".cea");
16
+ replaceOn();
17
+ refreshFsLightbox();
18
+ allClickable(".clickable");
19
+ }
20
+
21
+ function onPageLoaded() {
22
+ onDomChanged();
23
+ new FsLightbox();
24
+ }
25
+
26
+ document.addEventListener("DOMContentLoaded", onPageLoaded());
27
+ document.addEventListener("DOMChanged", onDomChanged);
package/src/encore.js CHANGED
@@ -29,24 +29,9 @@ module.exports = {
29
29
  outputPath = "./../public/assets/",
30
30
  publicPath = "/assets",
31
31
  manifestKeyPrefix = null,
32
- filesToCopy = [
33
- {
34
- from: "./media/", // todo explain
35
- to: "[name].[ext]",
36
- pattern: /svg$/,
37
- },
38
- {
39
- from: "./img/",
40
- to: "[name].[ext]",
41
- pattern: /header.jpg$/,
42
- },
43
- {
44
- from: "./favicons",
45
- to: "[name].[ext]",
46
- },
47
- ],
48
- entries = [{ name: "app", file: "./app.js" }],
49
- styleEntries = [{ name: "style", file: "./app.css" }]
32
+ filesToCopy = null,
33
+ entries = null,
34
+ styleEntries = null
50
35
  ) {
51
36
  if (watchFiles === null) {
52
37
  watchFiles = getFilesToWatch();
@@ -56,6 +41,27 @@ module.exports = {
56
41
  tailwindConfig = getTailwindConfig(watchFiles);
57
42
  }
58
43
 
44
+ if (filesToCopy === null) {
45
+ filesToCopy = [
46
+ {
47
+ from: "./favicons",
48
+ to: "[name].[ext]",
49
+ },
50
+ ];
51
+ }
52
+
53
+ if (entries === null) {
54
+ entries = [{ name: "app", file: __dirname + "/app.js" }];
55
+ } else if (typeof entries === "string") {
56
+ entries = [{ name: "app", file: entries }];
57
+ }
58
+
59
+ if (styleEntries === null) {
60
+ styleEntries = [{ name: "style", file: __dirname + "/app.css" }];
61
+ } else if (typeof styleEntries === "string") {
62
+ styleEntries = [{ name: "style", file: styleEntries }];
63
+ }
64
+
59
65
  Encore.setOutputPath(outputPath)
60
66
  .setPublicPath(publicPath)
61
67
  .cleanupOutputBeforeBuild()
package/src/helpers.js CHANGED
@@ -28,7 +28,9 @@ export function liveBlock(liveBlockAttribute = "data-live", liveFormSelector = "
28
28
  };
29
29
 
30
30
  var getLiveBlock = function (item) {
31
- fetch(item.getAttribute(liveBlockAttribute), {
31
+ var url = item.getAttribute(liveBlockAttribute);
32
+ url = url.startsWith("e:") ? convertShortchutForLink(rot13ToText(url.substring(2))) : url;
33
+ fetch(url, {
32
34
  //headers: { "Content-Type": "application/json", Accept: "text/plain" },
33
35
  method: "POST",
34
36
  credentials: "include",
@@ -45,13 +47,14 @@ export function liveBlock(liveBlockAttribute = "data-live", liveFormSelector = "
45
47
  });
46
48
  };
47
49
 
48
- var htmlLoader =
49
- '<div style="width:1em;height:1em;border: 2px solid #222;border-top-color: #fff;border-radius: 50%; animation: 1s spin linear infinite;"></div><style>@keyframes spin {from{transform:rotate(0deg)}to{transform:rotate(360deg)}}</style>';
50
+ const spinner =
51
+ '<span class="border-top-color: transparent;" class="inline-block w-5 h-5 border-4 border-gray-50 border-solid rounded-full animate-spin"></span>';
52
+ const htmlLoader = "<div>" + spinner + "</div>";
50
53
 
51
54
  var setLoader = function (form) {
52
55
  var $submitButton = getSubmitButton(form);
53
56
  if ($submitButton !== undefined) {
54
- var initialButton = $submitButton.outerHTML;
57
+ //var initialButton = $submitButton.outerHTML;
55
58
  $submitButton.innerHTML = "";
56
59
  $submitButton.outerHTML = htmlLoader;
57
60
  }
@@ -95,6 +98,10 @@ export function liveBlock(liveBlockAttribute = "data-live", liveFormSelector = "
95
98
  // Listen button src-data-live
96
99
  document.querySelectorAll("[src-" + liveBlockAttribute + "]").forEach((item) => {
97
100
  item.addEventListener("click", (event) => {
101
+ if (item.tagName == "BUTTON") {
102
+ item.innerHTML = spinner;
103
+ item.setAttribute("disabled", true);
104
+ }
98
105
  btnToBlock(event, item);
99
106
  });
100
107
  });