@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 CHANGED
@@ -1,12 +1,36 @@
1
1
  {
2
2
  "name": "@pushword/js-helper",
3
- "version": "0.0.44",
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
- if (!element.querySelector('a')) return false;
8
- var link = element.querySelectorAll('a')[0];
9
- if (
10
- window.location.pathname.replace(/^\//, '') ==
11
- link.pathname.replace(/^\//, '') &&
12
- window.location.hostname == link.hostname
13
- ) {
14
- if (typeof smoothScroll === 'function') {
15
- smoothScroll(link);
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
- document.querySelectorAll(selector).forEach(function (item) {
31
- item.addEventListener('click', function () {
32
- clickable(item);
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
- if (
45
- location.pathname.replace(/^\//, '') == link.pathname.replace(/^\//, '') &&
46
- location.hostname == link.hostname &&
47
- link.hash != ''
48
- ) {
49
- var target = document.querySelector(link.hash);
50
- target =
51
- target !== null
52
- ? target
53
- : document.querySelector('[name=' + link.hash.slice(1) + ']');
54
- if (target !== null) {
55
- if (event !== null) event.preventDefault();
56
- window.scrollTo({
57
- behavior: 'smooth',
58
- left: 0,
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 'core-js/stable';
2
- import 'regenerator-runtime/runtime';
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
- liveBlockAttribute = 'data-live',
26
- liveFormSelector = '.live-form'
27
- ) {
28
- var btnToBlock = function (event, btn) {
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
- var getLiveBlock = function (item) {
37
- fetch(item.getAttribute(liveBlockAttribute), {
38
- //headers: { "Content-Type": "application/json", Accept: "text/plain" },
39
- method: 'POST',
40
- credentials: 'include',
41
- })
42
- .then(function (response) {
43
- return response.text();
44
- })
45
- .then(function (body) {
46
- item.removeAttribute(liveBlockAttribute);
47
- item.outerHTML = body;
48
- })
49
- .then(function () {
50
- document.dispatchEvent(new Event('DOMChanged'));
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
- var htmlLoader =
55
- '<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>';
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
- var setLoader = function (form) {
58
- var $submitButton = getSubmitButton(form);
59
- if ($submitButton !== undefined) {
60
- var initialButton = $submitButton.outerHTML;
61
- $submitButton.innerHTML = '';
62
- $submitButton.outerHTML = htmlLoader;
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
- var sendForm = function (form, liveFormBlock) {
67
- setLoader(form);
60
+ var sendForm = function (form, liveFormBlock) {
61
+ setLoader(form);
68
62
 
69
- var formData = new FormData(form.srcElement);
70
- fetch(form.srcElement.action, {
71
- method: 'POST',
72
- body: formData,
73
- credentials: 'include',
74
- })
75
- .then(function (response) {
76
- return response.text();
77
- })
78
- .then(function (body) {
79
- liveFormBlock.outerHTML = body;
80
- })
81
- .then(function () {
82
- document.dispatchEvent(new Event('DOMChanged'));
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
- var getSubmitButton = function (form) {
87
- if (form.srcElement.querySelector('[type=submit]') !== null) {
88
- return form.srcElement.querySelector('[type=submit]');
89
- }
90
- if (form.srcElement.getElementsByTagName('button') !== null) {
91
- return form.srcElement.getElementsByTagName('button')[0];
92
- }
93
- return null;
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
- // Listen data-live
97
- document.querySelectorAll('[' + liveBlockAttribute + ']').forEach((item) => {
98
- getLiveBlock(item);
99
- });
90
+ // Listen data-live
91
+ document.querySelectorAll("[" + liveBlockAttribute + "]").forEach((item) => {
92
+ getLiveBlock(item);
93
+ });
100
94
 
101
- // Listen button src-data-live
102
- document
103
- .querySelectorAll('[src-' + liveBlockAttribute + ']')
104
- .forEach((item) => {
105
- item.addEventListener('click', (event) => {
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
- // Listen live-form
111
- document.querySelectorAll(liveFormSelector).forEach((item) => {
112
- if (item.querySelector('form') !== null) {
113
- item.querySelector('form').addEventListener('submit', (e) => {
114
- e.preventDefault();
115
- sendForm(e, item);
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 = 'replaceBy', eventName = 'click') {
126
- var loadVideo = function (element) {
127
- var content = element.getAttribute(attribute);
128
- if (
129
- element.classList.contains('hero-banner-overlay-lg') &&
130
- element.querySelector('picture') &&
131
- window.innerWidth < 992
132
- ) {
133
- element.querySelector('picture').outerHTML = content;
134
- element.querySelector('.btn-play').outerHTML = ' ';
135
- } else {
136
- element.innerHTML = content;
137
- }
138
- if (element.classList.contains('hero-banner-overlay-lg')) {
139
- element.style.zIndex = '2000';
140
- }
141
- element.removeAttribute(attribute);
142
- document.dispatchEvent(new Event('DOMChanged'));
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
- document
146
- .querySelectorAll('[' + attribute + ']:not([listen])')
147
- .forEach(function (element) {
148
- element.setAttribute('listen', '');
149
- element.addEventListener(
150
- eventName,
151
- function (event) {
152
- loadVideo(event.currentTarget); //event.currentTarget;
153
- element.removeAttribute('listen');
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
- document.querySelectorAll('[x-hash]').forEach(function (element) {
166
- if (window.location.hash) {
167
- if (element.getAttribute('x-hash') == window.location.hash.substring(1)) {
168
- element.parentNode.parentNode
169
- .querySelectorAll('img')
170
- .forEach(function (img) {
171
- img.style = 'display:none';
172
- });
173
- element.style = 'display:block';
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
- var screenWidth = window.innerWidth;
186
- if (screenWidth <= 576) {
187
- src = src.replace('/default/', '/xs/');
188
- } else if (screenWidth <= 768) {
189
- src = src.replace('/default/', '/sm/');
190
- } else if (screenWidth <= 992) {
191
- src = src.replace('/default/', '/md/');
192
- } else if (screenWidth <= 1200) {
193
- src = src.replace('/default/', '/lg/');
194
- } else {
195
- // 1200+
196
- src = src.replace('/default/', '/xl/');
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
- return src;
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 = 'data-rot') {
209
- var convertLink = function (element) {
210
- // fix "bug" with img
211
- if (element.getAttribute(attribute) === null) {
212
- var element = element.closest('[' + attribute + ']');
213
- }
214
- if (element.getAttribute(attribute) === null) return;
215
- var link = document.createElement('a');
216
- var href = element.getAttribute(attribute);
217
- element.removeAttribute(attribute);
218
- for (var i = 0, n = element.attributes.length; i < n; i++) {
219
- link.setAttribute(
220
- element.attributes[i].nodeName,
221
- element.attributes[i].nodeValue
222
- );
223
- }
224
- link.innerHTML = element.innerHTML;
225
- link.setAttribute(
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
- var convertThemAll = function (attribute) {
234
- [].forEach.call(
235
- document.querySelectorAll('[' + attribute + ']'),
236
- function (element) {
237
- convertLink(element);
238
- }
239
- );
240
- };
215
+ var convertThemAll = function (attribute) {
216
+ [].forEach.call(document.querySelectorAll("[" + attribute + "]"), function (element) {
217
+ convertLink(element);
218
+ });
219
+ };
241
220
 
242
- var fireEventLinksBuilt = async function (element, event) {
243
- await document.dispatchEvent(new Event('DOMChanged'));
221
+ var fireEventLinksBuilt = async function (element, event) {
222
+ await document.dispatchEvent(new Event("DOMChanged"));
244
223
 
245
- var clickEvent = new Event(event.type);
246
- element.dispatchEvent(clickEvent);
247
- };
224
+ var clickEvent = new Event(event.type);
225
+ element.dispatchEvent(clickEvent);
226
+ };
248
227
 
249
- var convertLinkOnEvent = async function (event) {
250
- // convert them all if it's an image (thanks this bug), permit to use gallery (baguetteBox)
251
- if (event.target.tagName == 'IMG') {
252
- await convertThemAll(attribute);
253
- var element = event.target;
254
- } else {
255
- var element = convertLink(event.target);
256
- }
257
- fireEventLinksBuilt(element, event);
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
- [].forEach.call(
261
- document.querySelectorAll('[' + attribute + ']'),
262
- function (element) {
263
- element.addEventListener(
264
- 'touchstart',
265
- function (e) {
266
- convertLinkOnEvent(e);
267
- },
268
- { once: true, passive: true }
269
- );
270
- element.addEventListener(
271
- 'click',
272
- function (e) {
273
- convertLinkOnEvent(e);
274
- },
275
- { once: true }
276
- );
277
- element.addEventListener(
278
- 'mouseover',
279
- function (e) {
280
- convertLinkOnEvent(e);
281
- },
282
- { once: true }
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 = 'data-frot') {
294
- [].forEach.call(
295
- document.querySelectorAll('[' + attribute + ']'),
296
- function (element) {
297
- var action = element.getAttribute(attribute);
298
- element.removeAttribute(attribute);
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
- if (str.charAt(0) == '-') {
309
- return str.replace('-', 'http://');
310
- }
311
- if (str.charAt(0) == '_') {
312
- return str.replace('_', 'https://');
313
- }
314
- if (str.charAt(0) == '@') {
315
- return str.replace('@', 'mailto:');
316
- }
317
- return str;
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
- document.querySelectorAll(selector).forEach(function (item) {
327
- var mail = rot13ToText(item.textContent);
328
- item.classList.remove('hidden');
329
- item.innerHTML = '<a href="mailto:' + mail + '">' + mail + '</a>';
330
- if (selector.charAt(0) == '.') {
331
- item.classList.remove(selector.substring(1));
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
- return str.replace(/[a-zA-Z]/g, function (c) {
343
- return String.fromCharCode(
344
- (c <= 'Z' ? 90 : 122) >= (c = c.charCodeAt(0) + 13) ? c : c - 26
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
- var elem = document.createElement('canvas');
320
+ var elem = document.createElement("canvas");
351
321
 
352
- if (elem.getContext && elem.getContext('2d')) {
353
- return elem.toDataURL('image/webp').indexOf('data:image/webp') == 0;
354
- }
322
+ if (elem.getContext && elem.getContext("2d")) {
323
+ return elem.toDataURL("image/webp").indexOf("data:image/webp") == 0;
324
+ }
355
325
 
356
- return false;
326
+ return false;
357
327
  }
358
328
 
359
329
  /**
360
330
  * Used in ThemeComponent
361
331
  */
362
332
  export function convertImageLinkToWebPLink() {
363
- var switchToWebP = function () {
364
- [].forEach.call(document.querySelectorAll('a[dwl]'), function (element) {
365
- var href = responsiveImage(element.getAttribute('dwl'));
366
- element.setAttribute('href', href);
367
- element.removeAttribute('dwl');
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
- if (testWebPSupport()) switchToWebP();
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 = 'data-img') {
391
- [].forEach.call(
392
- document.querySelectorAll('[' + attribute + ']'),
393
- function (img) {
394
- var newDomImg = document.createElement('img');
395
- var src = img.getAttribute(attribute);
396
- img.removeAttribute(attribute);
397
- for (var i = 0, n = img.attributes.length; i < n; i++) {
398
- newDomImg.setAttribute(
399
- img.attributes[i].nodeName,
400
- img.attributes[i].nodeValue
401
- );
402
- }
403
- if (newDomImg.getAttribute('alt') === null && img.textContent != '') {
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
  }
@@ -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: #3c8dbc;
25
- border-color: #367fa9;
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
- display: block !important;
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
+ */