redeyed-jekyll-theme 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +21 -21
- data/README.md +54 -52
- data/_config.yml +25 -18
- data/_data/assets/cross-origin.yml +1 -7
- data/_data/assets/self-host.yml +0 -6
- data/_data/locale/en.yml +63 -58
- data/_data/locale/es-ES.yml +79 -0
- data/_data/locale/fr-FR.yml +79 -0
- data/_data/locale/id-ID.yml +79 -0
- data/_data/locale/ko-KR.yml +79 -0
- data/_data/locale/my-MM.yml +79 -0
- data/_data/locale/pt-BR.yml +79 -0
- data/_data/locale/ru-RU.yml +79 -0
- data/_data/locale/uk-UA.yml +79 -0
- data/_data/locale/vi-VN.yml +77 -0
- data/_data/locale/zh-CN.yml +78 -0
- data/_includes/{breadcrumbs.html → elements/breadcrumbs.html} +0 -0
- data/_includes/{datetime.html → elements/datetime.html} +0 -0
- data/_includes/{favicons.html → elements/favicons.html} +14 -14
- data/_includes/{javascript.html → elements/javascript.html} +2 -2
- data/_includes/{jsdelivr-combine.html → elements/jsdelivr-combine.html} +18 -18
- data/_includes/elements/lang.html +11 -0
- data/_includes/{navbar.html → elements/navbar.html} +5 -5
- data/_includes/{no-linenos.html → elements/no-linenos.html} +0 -0
- data/_includes/{options.html → elements/options.html} +13 -13
- data/_includes/{pagination.html → elements/pagination.html} +0 -0
- data/_includes/{readtime.html → elements/readtime.html} +0 -0
- data/_includes/{related-posts.html → elements/related-posts.html} +0 -0
- data/_includes/{search-loader.html → elements/search-loader.html} +46 -46
- data/_includes/{search-results.html → elements/search-results.html} +0 -0
- data/_includes/{toc.html → elements/toc.html} +0 -0
- data/_includes/{back-to-top.html → extensions/back-to-top.html} +2 -2
- data/_includes/extensions/code-highlight.html +89 -0
- data/_includes/extensions/comments/disqus.html +17 -0
- data/_includes/extensions/comments/giscus.html +56 -0
- data/_includes/extensions/comments/gitment.html +15 -0
- data/_includes/extensions/comments/utterances.html +46 -0
- data/_includes/extensions/geopattern.html +19 -0
- data/_includes/extensions/google-analytics.html +7 -0
- data/_includes/{google-tags-body.html → extensions/google-tags-body.html} +3 -3
- data/_includes/{google-tags-head.html → extensions/google-tags-head.html} +5 -5
- data/_includes/extensions/google-translate.html +108 -0
- data/_includes/extensions/hashlocate.html +44 -0
- data/_includes/extensions/mathjax.html +9 -0
- data/_includes/{mode-toggle.html → extensions/theme-mode.html} +0 -10
- data/_includes/extensions/theme-toggle.html +108 -0
- data/_includes/extensions/trianglify.html +26 -0
- data/_includes/functions/get-article-excerpt.html +33 -0
- data/_includes/functions/get-article-words.html +18 -0
- data/_includes/functions/get-banner.html +67 -0
- data/_includes/functions/get-categories.html +9 -0
- data/_includes/functions/get-datetimes.html +13 -0
- data/_includes/functions/get-reading-time.html +39 -0
- data/_includes/functions/get-tags.html +9 -0
- data/_includes/functions/get-value.html +41 -0
- data/_includes/functions/log.html +17 -0
- data/_includes/head.html +4 -4
- data/_includes/{copyright.html → views/copyright.html} +0 -0
- data/_includes/{footer.html → views/footer.html} +0 -0
- data/_includes/{header-banner.html → views/header-banner.html} +0 -0
- data/_includes/{header-wide.html → views/header-wide.html} +0 -0
- data/_includes/{header.html → views/header.html} +0 -0
- data/_includes/{panel-bottom.html → views/panel-bottom.html} +0 -0
- data/_includes/{panel-foot-2.html → views/panel-foot-2.html} +0 -0
- data/_includes/{panel-foot-3.html → views/panel-foot-3.html} +0 -0
- data/_includes/{panel-foot-4.html → views/panel-foot-4.html} +0 -0
- data/_includes/{panel-foot-full.html → views/panel-foot-full.html} +0 -0
- data/_includes/{panel-top-2.html → views/panel-top-2.html} +0 -0
- data/_includes/{panel-top-3.html → views/panel-top-3.html} +0 -0
- data/_includes/{panel-top-4.html → views/panel-top-4.html} +0 -0
- data/_includes/{panel-top-full.html → views/panel-top-full.html} +0 -0
- data/_includes/{post-nav.html → views/post-nav.html} +0 -0
- data/_includes/{post-share.html → views/post-share.html} +0 -0
- data/_includes/{sidebar.html → views/sidebar.html} +0 -0
- data/_javascript/common/back-to-top.js +20 -20
- data/_javascript/common/mode-toggle.js +13 -13
- data/_javascript/common/scroll-helper.js +36 -36
- data/_javascript/common/search-display.js +129 -129
- data/_javascript/common/sidebar.js +30 -30
- data/_javascript/common/tooltip-loader.js +6 -6
- data/_javascript/common/topbar-switcher.js +90 -90
- data/_javascript/common/topbar-title.js +67 -67
- data/_javascript/utils/category-collapse.js +30 -30
- data/_javascript/utils/checkbox.js +12 -12
- data/_javascript/utils/clipboard.js +133 -133
- data/_javascript/utils/img-extra.js +47 -47
- data/_javascript/utils/locale-datetime.js +45 -45
- data/_javascript/utils/pageviews.js +250 -250
- data/_javascript/utils/smooth-scroll.js +96 -96
- data/_layouts/archive.html +5 -0
- data/_layouts/categories.html +5 -0
- data/_layouts/category.html +5 -0
- data/_layouts/compress.html +10 -10
- data/_layouts/error.html +44 -0
- data/_layouts/errors/404.html +9 -0
- data/_layouts/home.html +5 -0
- data/_layouts/page.html +5 -5
- data/_layouts/panel-both.html +13 -13
- data/_layouts/panel-left.html +13 -13
- data/_layouts/panel-none.html +24 -26
- data/_layouts/panel-right.html +13 -13
- data/_layouts/post.html +5 -5
- data/_layouts/tag.html +5 -0
- data/_layouts/tags.html +5 -0
- data/{_includes/comments.html → _sass/addon/alerts.scss} +0 -0
- data/_sass/addon/common.scss +56 -1494
- data/_sass/addon/mixins.scss +31 -38
- data/_sass/addon/syntax.scss +246 -0
- data/_sass/{layout/page.scss → addon/typography.scss} +0 -0
- data/_sass/layout/_base.scss +16 -0
- data/_sass/redeyed-jekyll-theme.scss +30 -15
- data/_sass/{layout/panel-both.scss → theme/scheme-brew.scss} +0 -0
- data/_sass/theme/scheme-dark.scss +220 -0
- data/_sass/theme/scheme-light.scss +220 -0
- data/_sass/theme/syntax-dark.scss +150 -0
- data/_sass/{colors/light-syntax.scss → theme/syntax-light.scss} +4 -4
- data/_sass/theme/variables.scss +60 -0
- metadata +147 -105
- data/_includes/ga-site-tag.html +0 -8
- data/_includes/lang.html +0 -6
- data/_includes/mermaid.html +0 -1
- data/_sass/addon/variables.scss +0 -31
- data/_sass/colors/brew-scheme.scss +0 -7
- data/_sass/colors/dark-scheme.scss +0 -21
- data/_sass/colors/dark-syntax.scss +0 -88
- data/_sass/colors/light-scheme.scss +0 -7
- data/_sass/layout/panel-left.scss +0 -0
- data/_sass/layout/panel-none.scss +0 -146
- data/_sass/layout/panel-right.scss +0 -0
- data/_sass/layout/post.scss +0 -0
@@ -1,30 +1,30 @@
|
|
1
|
-
/*
|
2
|
-
* Tab 'Categories' expand/close effect.
|
3
|
-
*/
|
4
|
-
|
5
|
-
$(function() {
|
6
|
-
const childPrefix = "l_";
|
7
|
-
const parentPrefix = "h_";
|
8
|
-
const collapse = $(".collapse");
|
9
|
-
|
10
|
-
/* close up top-category */
|
11
|
-
collapse.on("hide.bs.collapse", function () { /* Bootstrap collapse events. */
|
12
|
-
const parentId = parentPrefix + $(this).attr("id").substring(childPrefix.length);
|
13
|
-
if (parentId) {
|
14
|
-
$(`#${parentId} .far.fa-folder-open`).attr("class", "far fa-folder fa-fw");
|
15
|
-
$(`#${parentId} i.fas`).addClass("rotate");
|
16
|
-
$(`#${parentId}`).removeClass("hide-border-bottom");
|
17
|
-
}
|
18
|
-
});
|
19
|
-
|
20
|
-
/* expand the top category */
|
21
|
-
collapse.on("show.bs.collapse", function() {
|
22
|
-
const parentId = parentPrefix + $(this).attr("id").substring(childPrefix.length);
|
23
|
-
if (parentId) {
|
24
|
-
$(`#${parentId} .far.fa-folder`).attr("class", "far fa-folder-open fa-fw");
|
25
|
-
$(`#${parentId} i.fas`).removeClass("rotate");
|
26
|
-
$(`#${parentId}`).addClass("hide-border-bottom");
|
27
|
-
}
|
28
|
-
});
|
29
|
-
|
30
|
-
});
|
1
|
+
/*
|
2
|
+
* Tab 'Categories' expand/close effect.
|
3
|
+
*/
|
4
|
+
|
5
|
+
$(function() {
|
6
|
+
const childPrefix = "l_";
|
7
|
+
const parentPrefix = "h_";
|
8
|
+
const collapse = $(".collapse");
|
9
|
+
|
10
|
+
/* close up top-category */
|
11
|
+
collapse.on("hide.bs.collapse", function () { /* Bootstrap collapse events. */
|
12
|
+
const parentId = parentPrefix + $(this).attr("id").substring(childPrefix.length);
|
13
|
+
if (parentId) {
|
14
|
+
$(`#${parentId} .far.fa-folder-open`).attr("class", "far fa-folder fa-fw");
|
15
|
+
$(`#${parentId} i.fas`).addClass("rotate");
|
16
|
+
$(`#${parentId}`).removeClass("hide-border-bottom");
|
17
|
+
}
|
18
|
+
});
|
19
|
+
|
20
|
+
/* expand the top category */
|
21
|
+
collapse.on("show.bs.collapse", function() {
|
22
|
+
const parentId = parentPrefix + $(this).attr("id").substring(childPrefix.length);
|
23
|
+
if (parentId) {
|
24
|
+
$(`#${parentId} .far.fa-folder`).attr("class", "far fa-folder-open fa-fw");
|
25
|
+
$(`#${parentId} i.fas`).removeClass("rotate");
|
26
|
+
$(`#${parentId}`).addClass("hide-border-bottom");
|
27
|
+
}
|
28
|
+
});
|
29
|
+
|
30
|
+
});
|
@@ -1,12 +1,12 @@
|
|
1
|
-
/*
|
2
|
-
* Create a more beautiful checkbox
|
3
|
-
*/
|
4
|
-
|
5
|
-
$(function() {
|
6
|
-
/* hide browser default checkbox */
|
7
|
-
$("input[type=checkbox]").addClass("unloaded");
|
8
|
-
/* create checked checkbox */
|
9
|
-
$("input[type=checkbox][checked]").before("<i class=\"fas fa-check-circle checked\"></i>");
|
10
|
-
/* create normal checkbox */
|
11
|
-
$("input[type=checkbox]:not([checked])").before("<i class=\"far fa-circle\"></i>");
|
12
|
-
});
|
1
|
+
/*
|
2
|
+
* Create a more beautiful checkbox
|
3
|
+
*/
|
4
|
+
|
5
|
+
$(function() {
|
6
|
+
/* hide browser default checkbox */
|
7
|
+
$("input[type=checkbox]").addClass("unloaded");
|
8
|
+
/* create checked checkbox */
|
9
|
+
$("input[type=checkbox][checked]").before("<i class=\"fas fa-check-circle checked\"></i>");
|
10
|
+
/* create normal checkbox */
|
11
|
+
$("input[type=checkbox]:not([checked])").before("<i class=\"far fa-circle\"></i>");
|
12
|
+
});
|
@@ -1,133 +1,133 @@
|
|
1
|
-
/*
|
2
|
-
* Clipboard functions
|
3
|
-
*
|
4
|
-
* Dependencies:
|
5
|
-
* - popper.js (https://github.com/popperjs/popper-core)
|
6
|
-
* - clipboard.js (https://github.com/zenorocha/clipboard.js)
|
7
|
-
*/
|
8
|
-
|
9
|
-
$(function() {
|
10
|
-
const btnSelector = '.code-header>button';
|
11
|
-
const ICON_SUCCESS = 'fas fa-check';
|
12
|
-
const ATTR_TIMEOUT = 'timeout';
|
13
|
-
const ATTR_TITLE_SUCCEED = 'data-title-succeed';
|
14
|
-
const ATTR_TITLE_ORIGIN = 'data-original-title';
|
15
|
-
const TIMEOUT = 2000; // in milliseconds
|
16
|
-
|
17
|
-
function isLocked(node) {
|
18
|
-
if ($(node)[0].hasAttribute(ATTR_TIMEOUT)) {
|
19
|
-
let timeout = $(node).attr(ATTR_TIMEOUT);
|
20
|
-
if (Number(timeout) > Date.now()) {
|
21
|
-
return true;
|
22
|
-
}
|
23
|
-
}
|
24
|
-
return false;
|
25
|
-
}
|
26
|
-
|
27
|
-
function lock(node) {
|
28
|
-
$(node).attr(ATTR_TIMEOUT, Date.now() + TIMEOUT);
|
29
|
-
}
|
30
|
-
|
31
|
-
function unlock(node) {
|
32
|
-
$(node).removeAttr(ATTR_TIMEOUT);
|
33
|
-
}
|
34
|
-
|
35
|
-
/* --- Copy code block --- */
|
36
|
-
|
37
|
-
// Initial the clipboard.js object
|
38
|
-
const clipboard = new ClipboardJS(btnSelector, {
|
39
|
-
target(trigger) {
|
40
|
-
let codeBlock = trigger.parentNode.nextElementSibling;
|
41
|
-
return codeBlock.querySelector('code .rouge-code');
|
42
|
-
}
|
43
|
-
});
|
44
|
-
|
45
|
-
$(btnSelector).tooltip({
|
46
|
-
trigger: 'hover',
|
47
|
-
placement: 'left'
|
48
|
-
});
|
49
|
-
|
50
|
-
function getIcon(btn) {
|
51
|
-
let iconNode = $(btn).children();
|
52
|
-
return iconNode.attr('class');
|
53
|
-
}
|
54
|
-
|
55
|
-
const ICON_DEFAULT = getIcon(btnSelector);
|
56
|
-
|
57
|
-
function showTooltip(btn) {
|
58
|
-
const succeedTitle = $(btn).attr(ATTR_TITLE_SUCCEED);
|
59
|
-
$(btn).attr(ATTR_TITLE_ORIGIN, succeedTitle).tooltip('show');
|
60
|
-
}
|
61
|
-
|
62
|
-
function hideTooltip(btn) {
|
63
|
-
$(btn).tooltip('hide').removeAttr(ATTR_TITLE_ORIGIN);
|
64
|
-
}
|
65
|
-
|
66
|
-
function setSuccessIcon(btn) {
|
67
|
-
let btnNode = $(btn);
|
68
|
-
let iconNode = btnNode.children();
|
69
|
-
iconNode.attr('class', ICON_SUCCESS);
|
70
|
-
}
|
71
|
-
|
72
|
-
function resumeIcon(btn) {
|
73
|
-
let btnNode = $(btn);
|
74
|
-
let iconNode = btnNode.children();
|
75
|
-
iconNode.attr('class', ICON_DEFAULT);
|
76
|
-
}
|
77
|
-
|
78
|
-
clipboard.on('success', (e) => {
|
79
|
-
e.clearSelection();
|
80
|
-
|
81
|
-
const trigger = e.trigger;
|
82
|
-
if (isLocked(trigger)) {
|
83
|
-
return;
|
84
|
-
}
|
85
|
-
|
86
|
-
setSuccessIcon(trigger);
|
87
|
-
showTooltip(trigger);
|
88
|
-
lock(trigger);
|
89
|
-
|
90
|
-
setTimeout(() => {
|
91
|
-
hideTooltip(trigger);
|
92
|
-
resumeIcon(trigger);
|
93
|
-
unlock(trigger);
|
94
|
-
}, TIMEOUT);
|
95
|
-
|
96
|
-
});
|
97
|
-
|
98
|
-
/* --- Post link sharing --- */
|
99
|
-
|
100
|
-
$('#copy-link').click((e) => {
|
101
|
-
|
102
|
-
let target = $(e.target);
|
103
|
-
|
104
|
-
if (isLocked(target)) {
|
105
|
-
return;
|
106
|
-
}
|
107
|
-
|
108
|
-
// Copy URL to clipboard
|
109
|
-
|
110
|
-
const url = window.location.href;
|
111
|
-
const $temp = $("<input>");
|
112
|
-
|
113
|
-
$("body").append($temp);
|
114
|
-
$temp.val(url).select();
|
115
|
-
document.execCommand("copy");
|
116
|
-
$temp.remove();
|
117
|
-
|
118
|
-
// Switch tooltip title
|
119
|
-
|
120
|
-
const defaultTitle = target.attr(ATTR_TITLE_ORIGIN);
|
121
|
-
const succeedTitle = target.attr(ATTR_TITLE_SUCCEED);
|
122
|
-
|
123
|
-
target.attr(ATTR_TITLE_ORIGIN, succeedTitle).tooltip('show');
|
124
|
-
lock(target);
|
125
|
-
|
126
|
-
setTimeout(() => {
|
127
|
-
target.attr(ATTR_TITLE_ORIGIN, defaultTitle);
|
128
|
-
unlock(target);
|
129
|
-
}, TIMEOUT);
|
130
|
-
|
131
|
-
});
|
132
|
-
|
133
|
-
});
|
1
|
+
/*
|
2
|
+
* Clipboard functions
|
3
|
+
*
|
4
|
+
* Dependencies:
|
5
|
+
* - popper.js (https://github.com/popperjs/popper-core)
|
6
|
+
* - clipboard.js (https://github.com/zenorocha/clipboard.js)
|
7
|
+
*/
|
8
|
+
|
9
|
+
$(function() {
|
10
|
+
const btnSelector = '.code-header>button';
|
11
|
+
const ICON_SUCCESS = 'fas fa-check';
|
12
|
+
const ATTR_TIMEOUT = 'timeout';
|
13
|
+
const ATTR_TITLE_SUCCEED = 'data-title-succeed';
|
14
|
+
const ATTR_TITLE_ORIGIN = 'data-original-title';
|
15
|
+
const TIMEOUT = 2000; // in milliseconds
|
16
|
+
|
17
|
+
function isLocked(node) {
|
18
|
+
if ($(node)[0].hasAttribute(ATTR_TIMEOUT)) {
|
19
|
+
let timeout = $(node).attr(ATTR_TIMEOUT);
|
20
|
+
if (Number(timeout) > Date.now()) {
|
21
|
+
return true;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
return false;
|
25
|
+
}
|
26
|
+
|
27
|
+
function lock(node) {
|
28
|
+
$(node).attr(ATTR_TIMEOUT, Date.now() + TIMEOUT);
|
29
|
+
}
|
30
|
+
|
31
|
+
function unlock(node) {
|
32
|
+
$(node).removeAttr(ATTR_TIMEOUT);
|
33
|
+
}
|
34
|
+
|
35
|
+
/* --- Copy code block --- */
|
36
|
+
|
37
|
+
// Initial the clipboard.js object
|
38
|
+
const clipboard = new ClipboardJS(btnSelector, {
|
39
|
+
target(trigger) {
|
40
|
+
let codeBlock = trigger.parentNode.nextElementSibling;
|
41
|
+
return codeBlock.querySelector('code .rouge-code');
|
42
|
+
}
|
43
|
+
});
|
44
|
+
|
45
|
+
$(btnSelector).tooltip({
|
46
|
+
trigger: 'hover',
|
47
|
+
placement: 'left'
|
48
|
+
});
|
49
|
+
|
50
|
+
function getIcon(btn) {
|
51
|
+
let iconNode = $(btn).children();
|
52
|
+
return iconNode.attr('class');
|
53
|
+
}
|
54
|
+
|
55
|
+
const ICON_DEFAULT = getIcon(btnSelector);
|
56
|
+
|
57
|
+
function showTooltip(btn) {
|
58
|
+
const succeedTitle = $(btn).attr(ATTR_TITLE_SUCCEED);
|
59
|
+
$(btn).attr(ATTR_TITLE_ORIGIN, succeedTitle).tooltip('show');
|
60
|
+
}
|
61
|
+
|
62
|
+
function hideTooltip(btn) {
|
63
|
+
$(btn).tooltip('hide').removeAttr(ATTR_TITLE_ORIGIN);
|
64
|
+
}
|
65
|
+
|
66
|
+
function setSuccessIcon(btn) {
|
67
|
+
let btnNode = $(btn);
|
68
|
+
let iconNode = btnNode.children();
|
69
|
+
iconNode.attr('class', ICON_SUCCESS);
|
70
|
+
}
|
71
|
+
|
72
|
+
function resumeIcon(btn) {
|
73
|
+
let btnNode = $(btn);
|
74
|
+
let iconNode = btnNode.children();
|
75
|
+
iconNode.attr('class', ICON_DEFAULT);
|
76
|
+
}
|
77
|
+
|
78
|
+
clipboard.on('success', (e) => {
|
79
|
+
e.clearSelection();
|
80
|
+
|
81
|
+
const trigger = e.trigger;
|
82
|
+
if (isLocked(trigger)) {
|
83
|
+
return;
|
84
|
+
}
|
85
|
+
|
86
|
+
setSuccessIcon(trigger);
|
87
|
+
showTooltip(trigger);
|
88
|
+
lock(trigger);
|
89
|
+
|
90
|
+
setTimeout(() => {
|
91
|
+
hideTooltip(trigger);
|
92
|
+
resumeIcon(trigger);
|
93
|
+
unlock(trigger);
|
94
|
+
}, TIMEOUT);
|
95
|
+
|
96
|
+
});
|
97
|
+
|
98
|
+
/* --- Post link sharing --- */
|
99
|
+
|
100
|
+
$('#copy-link').click((e) => {
|
101
|
+
|
102
|
+
let target = $(e.target);
|
103
|
+
|
104
|
+
if (isLocked(target)) {
|
105
|
+
return;
|
106
|
+
}
|
107
|
+
|
108
|
+
// Copy URL to clipboard
|
109
|
+
|
110
|
+
const url = window.location.href;
|
111
|
+
const $temp = $("<input>");
|
112
|
+
|
113
|
+
$("body").append($temp);
|
114
|
+
$temp.val(url).select();
|
115
|
+
document.execCommand("copy");
|
116
|
+
$temp.remove();
|
117
|
+
|
118
|
+
// Switch tooltip title
|
119
|
+
|
120
|
+
const defaultTitle = target.attr(ATTR_TITLE_ORIGIN);
|
121
|
+
const succeedTitle = target.attr(ATTR_TITLE_SUCCEED);
|
122
|
+
|
123
|
+
target.attr(ATTR_TITLE_ORIGIN, succeedTitle).tooltip('show');
|
124
|
+
lock(target);
|
125
|
+
|
126
|
+
setTimeout(() => {
|
127
|
+
target.attr(ATTR_TITLE_ORIGIN, defaultTitle);
|
128
|
+
unlock(target);
|
129
|
+
}, TIMEOUT);
|
130
|
+
|
131
|
+
});
|
132
|
+
|
133
|
+
});
|
@@ -1,47 +1,47 @@
|
|
1
|
-
/**
|
2
|
-
Lazy load images (https://github.com/ApoorvSaxena/lozad.js)
|
3
|
-
and popup when clicked (https://github.com/dimsemenov/Magnific-Popup)
|
4
|
-
*/
|
5
|
-
|
6
|
-
$(function() {
|
7
|
-
|
8
|
-
const IMG_SCOPE = '#main > div.row:first-child > div:first-child';
|
9
|
-
|
10
|
-
if ($(`${IMG_SCOPE} img`).length <= 0 ) {
|
11
|
-
return;
|
12
|
-
}
|
13
|
-
|
14
|
-
/* lazy loading */
|
15
|
-
|
16
|
-
const imgList = document.querySelectorAll(`${IMG_SCOPE} img[data-src]`);
|
17
|
-
const observer = lozad(imgList);
|
18
|
-
observer.observe();
|
19
|
-
|
20
|
-
/* popup */
|
21
|
-
|
22
|
-
$(`${IMG_SCOPE} p > img[data-src],${IMG_SCOPE} img[data-src].preview-img`).each(
|
23
|
-
function() {
|
24
|
-
let nextTag = $(this).next();
|
25
|
-
const title = nextTag.prop('tagName') === 'EM' ? nextTag.text() : '';
|
26
|
-
const src = $(this).attr('data-src'); // created by lozad.js
|
27
|
-
|
28
|
-
$(this).wrap(`<a href="${src}" title="${title}" class="popup"></a>`);
|
29
|
-
}
|
30
|
-
);
|
31
|
-
|
32
|
-
$('.popup').magnificPopup({
|
33
|
-
type: 'image',
|
34
|
-
closeOnContentClick: true,
|
35
|
-
showCloseBtn: false,
|
36
|
-
zoom: {
|
37
|
-
enabled: true,
|
38
|
-
duration: 300,
|
39
|
-
easing: 'ease-in-out'
|
40
|
-
}
|
41
|
-
});
|
42
|
-
|
43
|
-
/* markup the image links */
|
44
|
-
|
45
|
-
$(`${IMG_SCOPE} a`).has('img').addClass('img-link');
|
46
|
-
|
47
|
-
});
|
1
|
+
/**
|
2
|
+
Lazy load images (https://github.com/ApoorvSaxena/lozad.js)
|
3
|
+
and popup when clicked (https://github.com/dimsemenov/Magnific-Popup)
|
4
|
+
*/
|
5
|
+
|
6
|
+
$(function() {
|
7
|
+
|
8
|
+
const IMG_SCOPE = '#main > div.row:first-child > div:first-child';
|
9
|
+
|
10
|
+
if ($(`${IMG_SCOPE} img`).length <= 0 ) {
|
11
|
+
return;
|
12
|
+
}
|
13
|
+
|
14
|
+
/* lazy loading */
|
15
|
+
|
16
|
+
const imgList = document.querySelectorAll(`${IMG_SCOPE} img[data-src]`);
|
17
|
+
const observer = lozad(imgList);
|
18
|
+
observer.observe();
|
19
|
+
|
20
|
+
/* popup */
|
21
|
+
|
22
|
+
$(`${IMG_SCOPE} p > img[data-src],${IMG_SCOPE} img[data-src].preview-img`).each(
|
23
|
+
function() {
|
24
|
+
let nextTag = $(this).next();
|
25
|
+
const title = nextTag.prop('tagName') === 'EM' ? nextTag.text() : '';
|
26
|
+
const src = $(this).attr('data-src'); // created by lozad.js
|
27
|
+
|
28
|
+
$(this).wrap(`<a href="${src}" title="${title}" class="popup"></a>`);
|
29
|
+
}
|
30
|
+
);
|
31
|
+
|
32
|
+
$('.popup').magnificPopup({
|
33
|
+
type: 'image',
|
34
|
+
closeOnContentClick: true,
|
35
|
+
showCloseBtn: false,
|
36
|
+
zoom: {
|
37
|
+
enabled: true,
|
38
|
+
duration: 300,
|
39
|
+
easing: 'ease-in-out'
|
40
|
+
}
|
41
|
+
});
|
42
|
+
|
43
|
+
/* markup the image links */
|
44
|
+
|
45
|
+
$(`${IMG_SCOPE} a`).has('img').addClass('img-link');
|
46
|
+
|
47
|
+
});
|
@@ -1,45 +1,45 @@
|
|
1
|
-
/**
|
2
|
-
* Update month/day to locale datetime
|
3
|
-
*
|
4
|
-
* Requirement: <https://github.com/iamkun/dayjs>
|
5
|
-
*/
|
6
|
-
|
7
|
-
/* A tool for locale datetime */
|
8
|
-
const LocaleHelper = (function () {
|
9
|
-
const $preferLocale = $('meta[name="prefer-datetime-locale"]');
|
10
|
-
const locale = $preferLocale.length > 0 ?
|
11
|
-
$preferLocale.attr('content').toLowerCase() : $('html').attr('lang').substr(0, 2);
|
12
|
-
const attrTimestamp = 'data-ts';
|
13
|
-
const attrDateFormat = 'data-df';
|
14
|
-
|
15
|
-
return {
|
16
|
-
locale: () => locale,
|
17
|
-
attrTimestamp: () => attrTimestamp,
|
18
|
-
attrDateFormat: () => attrDateFormat,
|
19
|
-
getTimestamp: ($elem) => Number($elem.attr(attrTimestamp)), // unix timestamp
|
20
|
-
getDateFormat: ($elem) => $elem.attr(attrDateFormat)
|
21
|
-
};
|
22
|
-
|
23
|
-
}());
|
24
|
-
|
25
|
-
$(function() {
|
26
|
-
dayjs.locale(LocaleHelper.locale());
|
27
|
-
dayjs.extend(window.dayjs_plugin_localizedFormat);
|
28
|
-
|
29
|
-
$(`[${LocaleHelper.attrTimestamp()}]`).each(function () {
|
30
|
-
const date = dayjs.unix(LocaleHelper.getTimestamp($(this)));
|
31
|
-
const text = date.format(LocaleHelper.getDateFormat($(this)));
|
32
|
-
$(this).text(text);
|
33
|
-
$(this).removeAttr(LocaleHelper.attrTimestamp());
|
34
|
-
$(this).removeAttr(LocaleHelper.attrDateFormat());
|
35
|
-
|
36
|
-
// setup tooltips
|
37
|
-
const tooltip = $(this).attr('data-toggle');
|
38
|
-
if (typeof tooltip === 'undefined' || tooltip !== 'tooltip') {
|
39
|
-
return;
|
40
|
-
}
|
41
|
-
|
42
|
-
const tooltipText = date.format('llll'); // see: https://day.js.org/docs/en/display/format#list-of-localized-formats
|
43
|
-
$(this).attr('data-original-title', tooltipText);
|
44
|
-
});
|
45
|
-
});
|
1
|
+
/**
|
2
|
+
* Update month/day to locale datetime
|
3
|
+
*
|
4
|
+
* Requirement: <https://github.com/iamkun/dayjs>
|
5
|
+
*/
|
6
|
+
|
7
|
+
/* A tool for locale datetime */
|
8
|
+
const LocaleHelper = (function () {
|
9
|
+
const $preferLocale = $('meta[name="prefer-datetime-locale"]');
|
10
|
+
const locale = $preferLocale.length > 0 ?
|
11
|
+
$preferLocale.attr('content').toLowerCase() : $('html').attr('lang').substr(0, 2);
|
12
|
+
const attrTimestamp = 'data-ts';
|
13
|
+
const attrDateFormat = 'data-df';
|
14
|
+
|
15
|
+
return {
|
16
|
+
locale: () => locale,
|
17
|
+
attrTimestamp: () => attrTimestamp,
|
18
|
+
attrDateFormat: () => attrDateFormat,
|
19
|
+
getTimestamp: ($elem) => Number($elem.attr(attrTimestamp)), // unix timestamp
|
20
|
+
getDateFormat: ($elem) => $elem.attr(attrDateFormat)
|
21
|
+
};
|
22
|
+
|
23
|
+
}());
|
24
|
+
|
25
|
+
$(function() {
|
26
|
+
dayjs.locale(LocaleHelper.locale());
|
27
|
+
dayjs.extend(window.dayjs_plugin_localizedFormat);
|
28
|
+
|
29
|
+
$(`[${LocaleHelper.attrTimestamp()}]`).each(function () {
|
30
|
+
const date = dayjs.unix(LocaleHelper.getTimestamp($(this)));
|
31
|
+
const text = date.format(LocaleHelper.getDateFormat($(this)));
|
32
|
+
$(this).text(text);
|
33
|
+
$(this).removeAttr(LocaleHelper.attrTimestamp());
|
34
|
+
$(this).removeAttr(LocaleHelper.attrDateFormat());
|
35
|
+
|
36
|
+
// setup tooltips
|
37
|
+
const tooltip = $(this).attr('data-toggle');
|
38
|
+
if (typeof tooltip === 'undefined' || tooltip !== 'tooltip') {
|
39
|
+
return;
|
40
|
+
}
|
41
|
+
|
42
|
+
const tooltipText = date.format('llll'); // see: https://day.js.org/docs/en/display/format#list-of-localized-formats
|
43
|
+
$(this).attr('data-original-title', tooltipText);
|
44
|
+
});
|
45
|
+
});
|