@pushword/js-helper 0.0.62 → 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/helpers.js +9 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushword/js-helper",
3
- "version": "0.0.62",
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/helpers.js CHANGED
@@ -29,7 +29,7 @@ export function liveBlock(liveBlockAttribute = "data-live", liveFormSelector = "
29
29
 
30
30
  var getLiveBlock = function (item) {
31
31
  var url = item.getAttribute(liveBlockAttribute);
32
- url = (url.startsWith("http") ? "" : "https://") + url;
32
+ url = url.startsWith("e:") ? convertShortchutForLink(rot13ToText(url.substring(2))) : url;
33
33
  fetch(url, {
34
34
  //headers: { "Content-Type": "application/json", Accept: "text/plain" },
35
35
  method: "POST",
@@ -47,13 +47,14 @@ export function liveBlock(liveBlockAttribute = "data-live", liveFormSelector = "
47
47
  });
48
48
  };
49
49
 
50
- var htmlLoader =
51
- '<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>";
52
53
 
53
54
  var setLoader = function (form) {
54
55
  var $submitButton = getSubmitButton(form);
55
56
  if ($submitButton !== undefined) {
56
- var initialButton = $submitButton.outerHTML;
57
+ //var initialButton = $submitButton.outerHTML;
57
58
  $submitButton.innerHTML = "";
58
59
  $submitButton.outerHTML = htmlLoader;
59
60
  }
@@ -97,6 +98,10 @@ export function liveBlock(liveBlockAttribute = "data-live", liveFormSelector = "
97
98
  // Listen button src-data-live
98
99
  document.querySelectorAll("[src-" + liveBlockAttribute + "]").forEach((item) => {
99
100
  item.addEventListener("click", (event) => {
101
+ if (item.tagName == "BUTTON") {
102
+ item.innerHTML = spinner;
103
+ item.setAttribute("disabled", true);
104
+ }
100
105
  btnToBlock(event, item);
101
106
  });
102
107
  });