Skip to content

Commit aafd5dd

Browse files
committed
- PDF: WIP
- Activated Discord chat - CSS: Added image tooltip preview - CSS: Fixed tooltips position - Docsify Plugins: Added custom attributes plugin
1 parent 7acfb7d commit aafd5dd

14 files changed

+132
-86
lines changed

docs/content/css/shared.css

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ blockquote.siema div {
5555
}
5656

5757
dfn {
58+
display: inline-block;
59+
display: static;
5860
border-bottom: 1px dashed;
5961
text-decoration: none;
6062
}
@@ -64,18 +66,19 @@ dfn:hover {
6466
}
6567

6668
dfn[aria-label]:hover:after {
69+
display: block;
6770
content: attr(aria-label);
6871
line-height: 1.2rem;
6972
position: absolute;
7073
background-color: #C5F7CA;
7174
border: #c0c0c0 1px dotted;
7275
padding: 4px 8px 4px 8px;
73-
-webkit-transform: translate(-60%, 60%);
76+
/*-webkit-transform: translate(-60%, 60%);
7477
-moz-transform: translate(-60%, 60%);
7578
-ms-transform: translate(-60%, 60%);
7679
-o-transform: translate(-60%, 60%);
77-
transform: translate(-60%, 60%);
78-
width: 300px;
80+
transform: translate(-60%, 60%);*/
81+
max-width: 300px;
7982
z-index: 100;
8083
text-transform: none;
8184
font-style: normal;
@@ -86,19 +89,32 @@ dfn a {
8689
/*cursor: help;*/
8790
}
8891

89-
img.tooltip-preview:hover:after {
90-
content: url(attr(src));
92+
a[tooltip-preview] {
93+
display: inline-block;
94+
display: static;
95+
}
96+
97+
a[tooltip-preview] img {
98+
display: none;
99+
}
100+
101+
a[tooltip-preview]:hover img {
102+
display: block;
91103
position: absolute;
92104
background-color: #C5F7CA;
93-
border: #c0c0c0 1px dotted;
94-
padding: 4px 8px 4px 8px;
95-
-webkit-transform: translate(-60%, 60%);
96-
-moz-transform: translate(-60%, 60%);
97-
-ms-transform: translate(-60%, 60%);
98-
-o-transform: translate(-60%, 60%);
99-
transform: translate(-60%, 60%);
100-
width: 300px;
105+
box-shadow: 0 2px 4px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
106+
padding: 0;
107+
/*-webkit-transform: translate(-60%, 20%);
108+
-moz-transform: translate(-60%, 20%);
109+
-ms-transform: translate(-60%, 20%);
110+
-o-transform: translate(-60%, 20%);
111+
transform: translate(-60%, 20%);*/
112+
max-width: 300px;
113+
max-height: 300px;
101114
z-index: 100;
115+
/*bottom: 125%;
116+
left: 50%;
117+
margin-left: -150px;*/
102118
}
103119

104120
video {
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
function install(hook) {
2+
hook.doneEach(_ => {
3+
let elms = [].slice.call(document.querySelectorAll('.markdown-section img:not(.emoji), a'));
4+
5+
elms.forEach(elm => {
6+
let { str, config } = getAndRemoveConfig(elm.title);
7+
8+
for (key in config)
9+
elm.setAttribute(key, config[key]);
10+
11+
if (config.hasOwnProperty('title') == false)
12+
elm.title = str;
13+
});
14+
})
15+
}
16+
17+
function getAndRemoveConfig(str = '') {
18+
const config = {}
19+
20+
if (str) {
21+
str = str
22+
.replace(/^'/, '')
23+
.replace(/'$/, '')
24+
.replace(/(?:^|\s)@([\w-]+)(?:="([^"]+)")?/g, (m, key, value) => {
25+
config[key] = (value && value.replace(/"/g, '')) || true
26+
return ''
27+
})
28+
.trim()
29+
}
30+
31+
return { str, config }
32+
}
33+
34+
$docsify.plugins = [].concat(install, $docsify.plugins);

docs/docsify-plugins/zoom-to-video/zoom-to-video.js

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//import { getAndRemoveConfig, showVideo } from './core'
2-
31
const matchesSelector = Element.prototype.matches || Element.prototype.webkitMatchesSelector || Element.prototype.msMatchesSelector;
42

53
const defaultOptions = {
@@ -10,19 +8,24 @@ const defaultOptions = {
108

119
function install(hook) {
1210
hook.doneEach(_ => {
13-
let elms = [].slice.call(document.querySelectorAll('.markdown-section img:not(.emoji)'))
14-
.filter(elm => elm.title.includes("@z2v") && matchesSelector.call(elm, 'a img') === false);
11+
let imgElms = [].slice.call(document.querySelectorAll('.markdown-section img[z2v]:not(.emoji)'))
12+
.filter(elm => matchesSelector.call(elm, 'a img') === false);
1513

16-
elms.forEach(elm => {
17-
let { str, config } = getAndRemoveConfig(elm.title);
18-
19-
elm.title = str;
14+
imgElms.forEach(elm => {
2015
elm.classList.add('z2v-img');
2116

22-
let imgContainer = addVideoInfo(elm);
17+
let imgContainer = addVideoInfo(elm);
2318

2419
imgContainer.onclick = function() {
25-
showVideo(imgContainer, config['z2v']);
20+
showVideo(elm.getAttribute('z2v'));
21+
};
22+
});
23+
24+
let aElms = [].slice.call(document.querySelectorAll('.markdown-section a[z2v]'));
25+
26+
aElms.forEach(elm => {
27+
elm.onclick = function() {
28+
showVideo(elm.getAttribute('z2v'));
2629
};
2730
});
2831
})
@@ -71,7 +74,7 @@ function onImageLoaded(elm, imgContainer, imgSubtitle) {
7174
imgContainer.insertBefore(elm, imgContainer.firstChild);
7275
}
7376

74-
function showVideo(elm, baseLink) {
77+
function showVideo(baseLink) {
7578
var overlay = document.createElement('div');
7679
overlay.className = 'z2v-overlay';
7780

@@ -122,21 +125,4 @@ function showVideo(elm, baseLink) {
122125
overlay.style.backgroundColor = "rgba(0, 0, 0, 0.7)";
123126
};
124127

125-
function getAndRemoveConfig(str = '') {
126-
const config = {}
127-
128-
if (str) {
129-
str = str
130-
.replace(/^'/, '')
131-
.replace(/'$/, '')
132-
.replace(/(?:^|\s)@([\w-]+)=?([\w-./]+)?/g, (m, key, value) => {
133-
config[key] = (value && value.replace(/"/g, '')) || true
134-
return ''
135-
})
136-
.trim()
137-
}
138-
139-
return { str, config }
140-
}
141-
142128
$docsify.plugins = [].concat(install, $docsify.plugins);
-310 Bytes
Binary file not shown.
268 Bytes
Loading
Loading
Loading
Binary file not shown.

0 commit comments

Comments
 (0)