@pushword/js-helper 0.0.44 → 0.0.49
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 +25 -1
- package/src/clickable.js +34 -36
- package/src/helpers.js +249 -288
- package/src/tailwind.prose.scss +20 -17
package/package.json
CHANGED
|
@@ -1,12 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pushword/js-helper",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.49",
|
|
4
4
|
"description": "Pushword front end helpers. ",
|
|
5
5
|
"author": "Robin@PiedWeb <contact@piedweb.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"prettier": "prettier ./src/*.{js,scss} --write"
|
|
9
9
|
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"140.css": "^1.0.1",
|
|
12
|
+
"@symfony/webpack-encore": "^1.7",
|
|
13
|
+
"@tailwindcss/aspect-ratio": "^0.2",
|
|
14
|
+
"@tailwindcss/forms": "^0.4",
|
|
15
|
+
"@tailwindcss/typography": "^0.5",
|
|
16
|
+
"ace-builds": "^1.4.12",
|
|
17
|
+
"autoprefixer": "^10.1.0",
|
|
18
|
+
"babel-preset-stage-2": "^6.24.1",
|
|
19
|
+
"codemirror": "^5.59.0",
|
|
20
|
+
"core-js": "^3.8.1",
|
|
21
|
+
"easymde": "^2.13.0",
|
|
22
|
+
"fslightbox": "^3.2.2",
|
|
23
|
+
"file-loader": "^6.0",
|
|
24
|
+
"node-sass": "^5.0.0",
|
|
25
|
+
"postcss": "^8.2.1",
|
|
26
|
+
"postcss-import": "^14.0.0",
|
|
27
|
+
"postcss-loader": "^4.1",
|
|
28
|
+
"sass-loader": "^10.1.0",
|
|
29
|
+
"simple-jekyll-search": "^1.9.1",
|
|
30
|
+
"tailwindcss": "^3",
|
|
31
|
+
"tailwindcss-hero-patterns": "^0.0.1",
|
|
32
|
+
"webpack-watch-files-plugin": "^1.1.0"
|
|
33
|
+
},
|
|
10
34
|
"repository": {
|
|
11
35
|
"type": "git",
|
|
12
36
|
"url": "git+https://github.com/Pushword/js-helper.git"
|
package/src/clickable.js
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
|
+
import { uncloakLinks } from "./helpers";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* transform an element containing a link (a href) in a clickable element
|
|
3
5
|
*
|
|
4
6
|
* @param {Object} element
|
|
5
7
|
*/
|
|
6
|
-
export function clickable(element) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
export async function clickable(element) {
|
|
9
|
+
if (!element.querySelector("a") && !element.querySelector("span[data-rot]")) return false;
|
|
10
|
+
if (element.querySelector("span[data-rot]")) await uncloakLinks("data-rot", "now");
|
|
11
|
+
var link = element.querySelectorAll("a")[0];
|
|
12
|
+
if (
|
|
13
|
+
window.location.pathname.replace(/^\//, "") == link.pathname.replace(/^\//, "") &&
|
|
14
|
+
window.location.hostname == link.hostname
|
|
15
|
+
) {
|
|
16
|
+
if (typeof smoothScroll === "function") {
|
|
17
|
+
smoothScroll(link);
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
16
20
|
}
|
|
21
|
+
window.location = link.getAttribute("href") === null ? "" : link.getAttribute("href");
|
|
17
22
|
return false;
|
|
18
|
-
}
|
|
19
|
-
window.location =
|
|
20
|
-
link.getAttribute('href') === null ? '' : link.getAttribute('href');
|
|
21
|
-
return false;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
/**
|
|
@@ -27,11 +28,11 @@ export function clickable(element) {
|
|
|
27
28
|
* @param {string} selector
|
|
28
29
|
*/
|
|
29
30
|
export function allClickable(selector) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
document.querySelectorAll(selector).forEach(function (item) {
|
|
32
|
+
item.addEventListener("click", function () {
|
|
33
|
+
clickable(item);
|
|
34
|
+
});
|
|
33
35
|
});
|
|
34
|
-
});
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
/**
|
|
@@ -41,23 +42,20 @@ export function allClickable(selector) {
|
|
|
41
42
|
* @param {Object} link
|
|
42
43
|
*/
|
|
43
44
|
export function smoothScroll(link, event = null) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
top: target.offsetTop,
|
|
60
|
-
});
|
|
45
|
+
if (
|
|
46
|
+
location.pathname.replace(/^\//, "") == link.pathname.replace(/^\//, "") &&
|
|
47
|
+
location.hostname == link.hostname &&
|
|
48
|
+
link.hash != ""
|
|
49
|
+
) {
|
|
50
|
+
var target = document.querySelector(link.hash);
|
|
51
|
+
target = target !== null ? target : document.querySelector("[name=" + link.hash.slice(1) + "]");
|
|
52
|
+
if (target !== null) {
|
|
53
|
+
if (event !== null) event.preventDefault();
|
|
54
|
+
window.scrollTo({
|
|
55
|
+
behavior: "smooth",
|
|
56
|
+
left: 0,
|
|
57
|
+
top: target.offsetTop,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
61
60
|
}
|
|
62
|
-
}
|
|
63
61
|
}
|
package/src/helpers.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import "core-js/stable";
|
|
2
|
+
import "regenerator-runtime/runtime";
|
|
3
3
|
/**
|
|
4
4
|
* List of all functions
|
|
5
5
|
*
|
|
@@ -21,139 +21,129 @@ import 'regenerator-runtime/runtime';
|
|
|
21
21
|
*
|
|
22
22
|
* @param {string} attribute
|
|
23
23
|
*/
|
|
24
|
-
export function liveBlock(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
btn.setAttribute(
|
|
30
|
-
liveBlockAttribute,
|
|
31
|
-
btn.getAttribute('src-' + liveBlockAttribute)
|
|
32
|
-
);
|
|
33
|
-
getLiveBlock(btn);
|
|
34
|
-
};
|
|
24
|
+
export function liveBlock(liveBlockAttribute = "data-live", liveFormSelector = ".live-form") {
|
|
25
|
+
var btnToBlock = function (event, btn) {
|
|
26
|
+
btn.setAttribute(liveBlockAttribute, btn.getAttribute("src-" + liveBlockAttribute));
|
|
27
|
+
getLiveBlock(btn);
|
|
28
|
+
};
|
|
35
29
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
30
|
+
var getLiveBlock = function (item) {
|
|
31
|
+
fetch(item.getAttribute(liveBlockAttribute), {
|
|
32
|
+
//headers: { "Content-Type": "application/json", Accept: "text/plain" },
|
|
33
|
+
method: "POST",
|
|
34
|
+
credentials: "include",
|
|
35
|
+
})
|
|
36
|
+
.then(function (response) {
|
|
37
|
+
return response.text();
|
|
38
|
+
})
|
|
39
|
+
.then(function (body) {
|
|
40
|
+
item.removeAttribute(liveBlockAttribute);
|
|
41
|
+
item.outerHTML = body;
|
|
42
|
+
})
|
|
43
|
+
.then(function () {
|
|
44
|
+
document.dispatchEvent(new Event("DOMChanged"));
|
|
45
|
+
});
|
|
46
|
+
};
|
|
53
47
|
|
|
54
|
-
|
|
55
|
-
|
|
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>';
|
|
56
50
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
51
|
+
var setLoader = function (form) {
|
|
52
|
+
var $submitButton = getSubmitButton(form);
|
|
53
|
+
if ($submitButton !== undefined) {
|
|
54
|
+
var initialButton = $submitButton.outerHTML;
|
|
55
|
+
$submitButton.innerHTML = "";
|
|
56
|
+
$submitButton.outerHTML = htmlLoader;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
65
59
|
|
|
66
|
-
|
|
67
|
-
|
|
60
|
+
var sendForm = function (form, liveFormBlock) {
|
|
61
|
+
setLoader(form);
|
|
68
62
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
63
|
+
var formData = new FormData(form.srcElement);
|
|
64
|
+
fetch(form.srcElement.action, {
|
|
65
|
+
method: "POST",
|
|
66
|
+
body: formData,
|
|
67
|
+
credentials: "include",
|
|
68
|
+
})
|
|
69
|
+
.then(function (response) {
|
|
70
|
+
return response.text();
|
|
71
|
+
})
|
|
72
|
+
.then(function (body) {
|
|
73
|
+
liveFormBlock.outerHTML = body;
|
|
74
|
+
})
|
|
75
|
+
.then(function () {
|
|
76
|
+
document.dispatchEvent(new Event("DOMChanged"));
|
|
77
|
+
});
|
|
78
|
+
};
|
|
85
79
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
80
|
+
var getSubmitButton = function (form) {
|
|
81
|
+
if (form.srcElement.querySelector("[type=submit]") !== null) {
|
|
82
|
+
return form.srcElement.querySelector("[type=submit]");
|
|
83
|
+
}
|
|
84
|
+
if (form.srcElement.getElementsByTagName("button") !== null) {
|
|
85
|
+
return form.srcElement.getElementsByTagName("button")[0];
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
};
|
|
95
89
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
90
|
+
// Listen data-live
|
|
91
|
+
document.querySelectorAll("[" + liveBlockAttribute + "]").forEach((item) => {
|
|
92
|
+
getLiveBlock(item);
|
|
93
|
+
});
|
|
100
94
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
btnToBlock(event, item);
|
|
107
|
-
});
|
|
95
|
+
// Listen button src-data-live
|
|
96
|
+
document.querySelectorAll("[src-" + liveBlockAttribute + "]").forEach((item) => {
|
|
97
|
+
item.addEventListener("click", (event) => {
|
|
98
|
+
btnToBlock(event, item);
|
|
99
|
+
});
|
|
108
100
|
});
|
|
109
101
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
102
|
+
// Listen live-form
|
|
103
|
+
document.querySelectorAll(liveFormSelector).forEach((item) => {
|
|
104
|
+
if (item.querySelector("form") !== null) {
|
|
105
|
+
item.querySelector("form").addEventListener("submit", (e) => {
|
|
106
|
+
e.preventDefault();
|
|
107
|
+
sendForm(e, item);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
});
|
|
119
111
|
}
|
|
120
112
|
|
|
121
113
|
/**
|
|
122
114
|
* Block to replace Watcher
|
|
123
115
|
* On $event on element find via $attribute, set attribute's content in element.innerHTML
|
|
124
116
|
*/
|
|
125
|
-
export function replaceOn(attribute =
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
117
|
+
export function replaceOn(attribute = "replaceBy", eventName = "click") {
|
|
118
|
+
var loadVideo = function (element) {
|
|
119
|
+
var content = element.getAttribute(attribute);
|
|
120
|
+
if (
|
|
121
|
+
element.classList.contains("hero-banner-overlay-lg") &&
|
|
122
|
+
element.querySelector("picture") &&
|
|
123
|
+
window.innerWidth < 992
|
|
124
|
+
) {
|
|
125
|
+
element.querySelector("picture").outerHTML = content;
|
|
126
|
+
element.querySelector(".btn-play").outerHTML = " ";
|
|
127
|
+
} else {
|
|
128
|
+
element.innerHTML = content;
|
|
129
|
+
}
|
|
130
|
+
if (element.classList.contains("hero-banner-overlay-lg")) {
|
|
131
|
+
element.style.zIndex = "2000";
|
|
132
|
+
}
|
|
133
|
+
element.removeAttribute(attribute);
|
|
134
|
+
document.dispatchEvent(new Event("DOMChanged"));
|
|
135
|
+
};
|
|
144
136
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
{ once: true }
|
|
156
|
-
);
|
|
137
|
+
document.querySelectorAll("[" + attribute + "]:not([listen])").forEach(function (element) {
|
|
138
|
+
element.setAttribute("listen", "");
|
|
139
|
+
element.addEventListener(
|
|
140
|
+
eventName,
|
|
141
|
+
function (event) {
|
|
142
|
+
loadVideo(event.currentTarget); //event.currentTarget;
|
|
143
|
+
element.removeAttribute("listen");
|
|
144
|
+
},
|
|
145
|
+
{ once: true }
|
|
146
|
+
);
|
|
157
147
|
});
|
|
158
148
|
}
|
|
159
149
|
|
|
@@ -162,18 +152,16 @@ export function replaceOn(attribute = 'replaceBy', eventName = 'click') {
|
|
|
162
152
|
*
|
|
163
153
|
*/
|
|
164
154
|
export function seasonedBackground() {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
});
|
|
155
|
+
document.querySelectorAll("[x-hash]").forEach(function (element) {
|
|
156
|
+
if (window.location.hash) {
|
|
157
|
+
if (element.getAttribute("x-hash") == window.location.hash.substring(1)) {
|
|
158
|
+
element.parentNode.parentNode.querySelectorAll("img").forEach(function (img) {
|
|
159
|
+
img.style = "display:none";
|
|
160
|
+
});
|
|
161
|
+
element.style = "display:block";
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
});
|
|
177
165
|
}
|
|
178
166
|
|
|
179
167
|
/**
|
|
@@ -182,21 +170,21 @@ export function seasonedBackground() {
|
|
|
182
170
|
* @param {string} src
|
|
183
171
|
*/
|
|
184
172
|
export function responsiveImage(src) {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
173
|
+
var screenWidth = window.innerWidth;
|
|
174
|
+
if (screenWidth <= 576) {
|
|
175
|
+
src = src.replace("/default/", "/xs/");
|
|
176
|
+
} else if (screenWidth <= 768) {
|
|
177
|
+
src = src.replace("/default/", "/sm/");
|
|
178
|
+
} else if (screenWidth <= 992) {
|
|
179
|
+
src = src.replace("/default/", "/md/");
|
|
180
|
+
} else if (screenWidth <= 1200) {
|
|
181
|
+
src = src.replace("/default/", "/lg/");
|
|
182
|
+
} else {
|
|
183
|
+
// 1200+
|
|
184
|
+
src = src.replace("/default/", "/xl/");
|
|
185
|
+
}
|
|
198
186
|
|
|
199
|
-
|
|
187
|
+
return src;
|
|
200
188
|
}
|
|
201
189
|
|
|
202
190
|
/**
|
|
@@ -205,84 +193,74 @@ export function responsiveImage(src) {
|
|
|
205
193
|
*
|
|
206
194
|
* @param {string} attribute
|
|
207
195
|
*/
|
|
208
|
-
export async function uncloakLinks(attribute =
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
element.
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
'href',
|
|
227
|
-
responsiveImage(convertShortchutForLink(rot13ToText(href)))
|
|
228
|
-
);
|
|
229
|
-
element.parentNode.replaceChild(link, element);
|
|
230
|
-
return link;
|
|
231
|
-
};
|
|
196
|
+
export async function uncloakLinks(attribute = "data-rot", when = "onEvent") {
|
|
197
|
+
var convertLink = function (element) {
|
|
198
|
+
// fix "bug" with img
|
|
199
|
+
if (element.getAttribute(attribute) === null) {
|
|
200
|
+
var element = element.closest("[" + attribute + "]");
|
|
201
|
+
}
|
|
202
|
+
if (element.getAttribute(attribute) === null) return;
|
|
203
|
+
var link = document.createElement("a");
|
|
204
|
+
var href = element.getAttribute(attribute);
|
|
205
|
+
element.removeAttribute(attribute);
|
|
206
|
+
for (var i = 0, n = element.attributes.length; i < n; i++) {
|
|
207
|
+
link.setAttribute(element.attributes[i].nodeName, element.attributes[i].nodeValue);
|
|
208
|
+
}
|
|
209
|
+
link.innerHTML = element.innerHTML;
|
|
210
|
+
link.setAttribute("href", responsiveImage(convertShortchutForLink(rot13ToText(href))));
|
|
211
|
+
element.parentNode.replaceChild(link, element);
|
|
212
|
+
return link;
|
|
213
|
+
};
|
|
232
214
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
);
|
|
240
|
-
};
|
|
215
|
+
var convertThemAll = function (attribute) {
|
|
216
|
+
[].forEach.call(document.querySelectorAll("[" + attribute + "]"), function (element) {
|
|
217
|
+
convertLink(element);
|
|
218
|
+
});
|
|
219
|
+
};
|
|
241
220
|
|
|
242
|
-
|
|
243
|
-
|
|
221
|
+
var fireEventLinksBuilt = async function (element, event) {
|
|
222
|
+
await document.dispatchEvent(new Event("DOMChanged"));
|
|
244
223
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
224
|
+
var clickEvent = new Event(event.type);
|
|
225
|
+
element.dispatchEvent(clickEvent);
|
|
226
|
+
};
|
|
248
227
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
228
|
+
var convertLinkOnEvent = async function (event) {
|
|
229
|
+
// convert them all if it's an image (thanks this bug), permit to use gallery (baguetteBox)
|
|
230
|
+
if (event.target.tagName == "IMG") {
|
|
231
|
+
await convertThemAll(attribute);
|
|
232
|
+
var element = event.target;
|
|
233
|
+
} else {
|
|
234
|
+
var element = convertLink(event.target);
|
|
235
|
+
}
|
|
236
|
+
fireEventLinksBuilt(element, event);
|
|
237
|
+
};
|
|
259
238
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
}
|
|
285
|
-
);
|
|
239
|
+
if (when == "onEvent") {
|
|
240
|
+
[].forEach.call(document.querySelectorAll("[" + attribute + "]"), function (element) {
|
|
241
|
+
element.addEventListener(
|
|
242
|
+
"touchstart",
|
|
243
|
+
function (e) {
|
|
244
|
+
convertLinkOnEvent(e);
|
|
245
|
+
},
|
|
246
|
+
{ once: true, passive: true }
|
|
247
|
+
);
|
|
248
|
+
element.addEventListener(
|
|
249
|
+
"click",
|
|
250
|
+
function (e) {
|
|
251
|
+
convertLinkOnEvent(e);
|
|
252
|
+
},
|
|
253
|
+
{ once: true }
|
|
254
|
+
);
|
|
255
|
+
element.addEventListener(
|
|
256
|
+
"mouseover",
|
|
257
|
+
function (e) {
|
|
258
|
+
convertLinkOnEvent(e);
|
|
259
|
+
},
|
|
260
|
+
{ once: true }
|
|
261
|
+
);
|
|
262
|
+
});
|
|
263
|
+
} else convertThemAll(attribute);
|
|
286
264
|
}
|
|
287
265
|
|
|
288
266
|
/**
|
|
@@ -290,31 +268,25 @@ export async function uncloakLinks(attribute = 'data-rot') {
|
|
|
290
268
|
*
|
|
291
269
|
* @param {string} attribute
|
|
292
270
|
*/
|
|
293
|
-
export function convertFormFromRot13(attribute =
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
element.setAttribute(
|
|
300
|
-
'action',
|
|
301
|
-
convertShortchutForLink(rot13ToText(action))
|
|
302
|
-
);
|
|
303
|
-
}
|
|
304
|
-
);
|
|
271
|
+
export function convertFormFromRot13(attribute = "data-frot") {
|
|
272
|
+
[].forEach.call(document.querySelectorAll("[" + attribute + "]"), function (element) {
|
|
273
|
+
var action = element.getAttribute(attribute);
|
|
274
|
+
element.removeAttribute(attribute);
|
|
275
|
+
element.setAttribute("action", convertShortchutForLink(rot13ToText(action)));
|
|
276
|
+
});
|
|
305
277
|
}
|
|
306
278
|
|
|
307
279
|
export function convertShortchutForLink(str) {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
280
|
+
if (str.charAt(0) == "-") {
|
|
281
|
+
return str.replace("-", "http://");
|
|
282
|
+
}
|
|
283
|
+
if (str.charAt(0) == "_") {
|
|
284
|
+
return str.replace("_", "https://");
|
|
285
|
+
}
|
|
286
|
+
if (str.charAt(0) == "@") {
|
|
287
|
+
return str.replace("@", "mailto:");
|
|
288
|
+
}
|
|
289
|
+
return str;
|
|
318
290
|
}
|
|
319
291
|
|
|
320
292
|
/**
|
|
@@ -323,14 +295,14 @@ export function convertShortchutForLink(str) {
|
|
|
323
295
|
* @param {string} text
|
|
324
296
|
*/
|
|
325
297
|
export function readableEmail(selector) {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
298
|
+
document.querySelectorAll(selector).forEach(function (item) {
|
|
299
|
+
var mail = rot13ToText(item.textContent);
|
|
300
|
+
item.classList.remove("hidden");
|
|
301
|
+
item.innerHTML = '<a href="mailto:' + mail + '">' + mail + "</a>";
|
|
302
|
+
if (selector.charAt(0) == ".") {
|
|
303
|
+
item.classList.remove(selector.substring(1));
|
|
304
|
+
}
|
|
305
|
+
});
|
|
334
306
|
}
|
|
335
307
|
|
|
336
308
|
/**
|
|
@@ -339,36 +311,34 @@ export function readableEmail(selector) {
|
|
|
339
311
|
* @param {string} str
|
|
340
312
|
*/
|
|
341
313
|
export function rot13ToText(str) {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
);
|
|
346
|
-
});
|
|
314
|
+
return str.replace(/[a-zA-Z]/g, function (c) {
|
|
315
|
+
return String.fromCharCode((c <= "Z" ? 90 : 122) >= (c = c.charCodeAt(0) + 13) ? c : c - 26);
|
|
316
|
+
});
|
|
347
317
|
}
|
|
348
318
|
|
|
349
319
|
export function testWebPSupport() {
|
|
350
|
-
|
|
320
|
+
var elem = document.createElement("canvas");
|
|
351
321
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
322
|
+
if (elem.getContext && elem.getContext("2d")) {
|
|
323
|
+
return elem.toDataURL("image/webp").indexOf("data:image/webp") == 0;
|
|
324
|
+
}
|
|
355
325
|
|
|
356
|
-
|
|
326
|
+
return false;
|
|
357
327
|
}
|
|
358
328
|
|
|
359
329
|
/**
|
|
360
330
|
* Used in ThemeComponent
|
|
361
331
|
*/
|
|
362
332
|
export function convertImageLinkToWebPLink() {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
333
|
+
var switchToWebP = function () {
|
|
334
|
+
[].forEach.call(document.querySelectorAll("a[dwl]"), function (element) {
|
|
335
|
+
var href = responsiveImage(element.getAttribute("dwl"));
|
|
336
|
+
element.setAttribute("href", href);
|
|
337
|
+
element.removeAttribute("dwl");
|
|
338
|
+
});
|
|
339
|
+
};
|
|
370
340
|
|
|
371
|
-
|
|
341
|
+
if (testWebPSupport()) switchToWebP();
|
|
372
342
|
}
|
|
373
343
|
|
|
374
344
|
/**
|
|
@@ -387,27 +357,18 @@ export function convertImageLinkToWebPLink() {
|
|
|
387
357
|
*
|
|
388
358
|
* still used in piedvert. To remove ?!
|
|
389
359
|
*/
|
|
390
|
-
export function imgLazyLoad(attribute =
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
newDomImg.
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
);
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
newDomImg.setAttribute('alt', img.textContent);
|
|
405
|
-
}
|
|
406
|
-
newDomImg.setAttribute(
|
|
407
|
-
'src',
|
|
408
|
-
typeof responsiveImage === 'function' ? responsiveImage(src) : src
|
|
409
|
-
);
|
|
410
|
-
img.outerHTML = newDomImg.outerHTML;
|
|
411
|
-
}
|
|
412
|
-
);
|
|
360
|
+
export function imgLazyLoad(attribute = "data-img") {
|
|
361
|
+
[].forEach.call(document.querySelectorAll("[" + attribute + "]"), function (img) {
|
|
362
|
+
var newDomImg = document.createElement("img");
|
|
363
|
+
var src = img.getAttribute(attribute);
|
|
364
|
+
img.removeAttribute(attribute);
|
|
365
|
+
for (var i = 0, n = img.attributes.length; i < n; i++) {
|
|
366
|
+
newDomImg.setAttribute(img.attributes[i].nodeName, img.attributes[i].nodeValue);
|
|
367
|
+
}
|
|
368
|
+
if (newDomImg.getAttribute("alt") === null && img.textContent != "") {
|
|
369
|
+
newDomImg.setAttribute("alt", img.textContent);
|
|
370
|
+
}
|
|
371
|
+
newDomImg.setAttribute("src", typeof responsiveImage === "function" ? responsiveImage(src) : src);
|
|
372
|
+
img.outerHTML = newDomImg.outerHTML;
|
|
373
|
+
});
|
|
413
374
|
}
|
package/src/tailwind.prose.scss
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Override tailwind prose
|
|
3
|
+
*/
|
|
4
|
+
.prose {
|
|
5
|
+
width: 100%;
|
|
6
|
+
margin: 0 auto;
|
|
7
|
+
}
|
|
8
|
+
|
|
1
9
|
/**
|
|
2
10
|
* Relative to link
|
|
3
11
|
*/
|
|
@@ -20,9 +28,9 @@
|
|
|
20
28
|
border-radius: 3px;
|
|
21
29
|
border: 1px solid transparent;
|
|
22
30
|
cursor: pointer;
|
|
23
|
-
color: #fff;
|
|
24
|
-
background-color:
|
|
25
|
-
border-color:
|
|
31
|
+
color: #fff !important;
|
|
32
|
+
background-color: var(--primary);
|
|
33
|
+
border-color: var(--primary);
|
|
26
34
|
outline: none;
|
|
27
35
|
text-decoration: none !important;
|
|
28
36
|
font-size: 120%;
|
|
@@ -45,19 +53,14 @@ html {
|
|
|
45
53
|
* Pure css hamburger menu
|
|
46
54
|
*/
|
|
47
55
|
|
|
48
|
-
.show-hide-input:checked ~ div
|
|
49
|
-
|
|
56
|
+
.show-hide-input:checked ~ div,
|
|
57
|
+
.show-hide-input:checked ~ ul,
|
|
58
|
+
.show-hide-input:checked ~ nav {
|
|
59
|
+
max-height: 100vh;
|
|
60
|
+
padding-top: 1rem;
|
|
50
61
|
}
|
|
51
62
|
|
|
52
|
-
|
|
53
|
-
* Special full-width from everywhere
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
.w-full-vw {
|
|
57
|
-
width: 100vw;
|
|
58
|
-
position: relative;
|
|
59
|
-
left: 50%;
|
|
60
|
-
right: 50%;
|
|
61
|
-
margin-left: -50vw;
|
|
62
|
-
margin-right: -50vw;
|
|
63
|
-
}
|
|
63
|
+
/*
|
|
64
|
+
* Special full-width from everywhere alias .w-full-vw:
|
|
65
|
+
w-screen relative left-[49%] ml-[-50vw] my-6
|
|
66
|
+
*/
|