@pushword/js-helper 0.0.61 → 0.0.65
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 +1 -1
- package/src/helpers.js +14 -7
package/package.json
CHANGED
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
|
-
|
|
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
|
-
|
|
49
|
-
'<
|
|
50
|
+
const spinner =
|
|
51
|
+
'<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>';
|
|
52
|
+
const htmlLoader = "<div class=btn-link>" + 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
|
});
|
|
@@ -278,13 +285,13 @@ export function convertFormFromRot13(attribute = "data-frot") {
|
|
|
278
285
|
|
|
279
286
|
export function convertShortchutForLink(str) {
|
|
280
287
|
if (str.charAt(0) == "-") {
|
|
281
|
-
return
|
|
288
|
+
return "http://" + str.substring(1);
|
|
282
289
|
}
|
|
283
290
|
if (str.charAt(0) == "_") {
|
|
284
|
-
return
|
|
291
|
+
return "https://" + str.substring(1);
|
|
285
292
|
}
|
|
286
293
|
if (str.charAt(0) == "@") {
|
|
287
|
-
return
|
|
294
|
+
return "mailto:" + str.substring(1);
|
|
288
295
|
}
|
|
289
296
|
return str;
|
|
290
297
|
}
|