@pushword/js-helper 0.0.60 → 0.0.64

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.60",
3
+ "version": "0.0.64",
4
4
  "description": "Pushword front end helpers. ",
5
5
  "author": "Robin@PiedWeb <contact@piedweb.com>",
6
6
  "license": "MIT",
package/src/encore.js CHANGED
@@ -29,12 +29,7 @@ module.exports = {
29
29
  outputPath = "./../public/assets/",
30
30
  publicPath = "/assets",
31
31
  manifestKeyPrefix = null,
32
- filesToCopy = [
33
- {
34
- from: "./favicons",
35
- to: "[name].[ext]",
36
- },
37
- ],
32
+ filesToCopy = null,
38
33
  entries = null,
39
34
  styleEntries = null
40
35
  ) {
@@ -46,6 +41,15 @@ module.exports = {
46
41
  tailwindConfig = getTailwindConfig(watchFiles);
47
42
  }
48
43
 
44
+ if (filesToCopy === null) {
45
+ filesToCopy = [
46
+ {
47
+ from: "./favicons",
48
+ to: "[name].[ext]",
49
+ },
50
+ ];
51
+ }
52
+
49
53
  if (entries === null) {
50
54
  entries = [{ name: "app", file: __dirname + "/app.js" }];
51
55
  } else if (typeof entries === "string") {
package/src/helpers.js CHANGED
@@ -28,7 +28,12 @@ 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
+ console.log(url);
33
+ console.log(url.startsWith("e:"));
34
+ url = url.startsWith("e:") ? convertShortchutForLink(rot13ToText(url.substring(2))) : url;
35
+ console.log(url);
36
+ fetch(url, {
32
37
  //headers: { "Content-Type": "application/json", Accept: "text/plain" },
33
38
  method: "POST",
34
39
  credentials: "include",
@@ -45,13 +50,14 @@ export function liveBlock(liveBlockAttribute = "data-live", liveFormSelector = "
45
50
  });
46
51
  };
47
52
 
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>';
53
+ const spinner =
54
+ '<span style="border-top-color: transparent" class="inline-block w-5 h-5 border-4 border-gray-50 border-solid rounded-full animate-spin"></span>';
55
+ const htmlLoader = "<div class=btn-link>" + spinner + "</div>";
50
56
 
51
57
  var setLoader = function (form) {
52
58
  var $submitButton = getSubmitButton(form);
53
59
  if ($submitButton !== undefined) {
54
- var initialButton = $submitButton.outerHTML;
60
+ //var initialButton = $submitButton.outerHTML;
55
61
  $submitButton.innerHTML = "";
56
62
  $submitButton.outerHTML = htmlLoader;
57
63
  }
@@ -95,6 +101,10 @@ export function liveBlock(liveBlockAttribute = "data-live", liveFormSelector = "
95
101
  // Listen button src-data-live
96
102
  document.querySelectorAll("[src-" + liveBlockAttribute + "]").forEach((item) => {
97
103
  item.addEventListener("click", (event) => {
104
+ if (item.tagName == "BUTTON") {
105
+ item.innerHTML = spinner;
106
+ item.setAttribute("disabled", true);
107
+ }
98
108
  btnToBlock(event, item);
99
109
  });
100
110
  });
@@ -278,13 +288,13 @@ export function convertFormFromRot13(attribute = "data-frot") {
278
288
 
279
289
  export function convertShortchutForLink(str) {
280
290
  if (str.charAt(0) == "-") {
281
- return str.replace("-", "http://");
291
+ return "http://" + str.substring(1);
282
292
  }
283
293
  if (str.charAt(0) == "_") {
284
- return str.replace("_", "https://");
294
+ return "https://" + str.substring(1);
285
295
  }
286
296
  if (str.charAt(0) == "@") {
287
- return str.replace("@", "mailto:");
297
+ return "mailto:" + str.substring(1);
288
298
  }
289
299
  return str;
290
300
  }