forked from jgthms/bulma
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
84 lines (68 loc) · 2.54 KB
/
Copy pathindex.js
File metadata and controls
84 lines (68 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
document.addEventListener('DOMContentLoaded', () => {
// Intro
const introVideo = document.getElementById('introVideo');
const introIframe = document.getElementById('introIframe');
const npmClipboard = new Clipboard('#npmCopy');
if (window.Vimeo) {
const introPlayer = new Vimeo.Player(introIframe);
introPlayer.ready().then(function() {
introVideo.classList.add('has-loaded');
});
}
npmClipboard.on('success', function(e) {
e.trigger.innerText = 'copied!';
e.trigger.classList.add('is-success');
setTimeout(() => {
e.trigger.innerText = 'copy';
e.trigger.classList.remove('is-success');
}, 500);
e.clearSelection();
});
npmClipboard.on('error', function(e) {
e.trigger.innerText = 'error!';
e.trigger.classList.add('is-error');
setTimeout(() => {
e.trigger.innerText = 'copy';
e.trigger.classList.remove('is-error');
}, 500);
});
// Grid
const $grid = document.getElementById('grid');
const $columns = Array.prototype.slice.call(document.querySelectorAll('#grid > .column'), 0);
const $markup = document.querySelector('#markup code');
const $message = document.getElementById('message');
const $add = document.getElementById('add');
const $remove = document.getElementById('remove');
let showing = 5;
function showColumns() {
if (showing === 13) {
$message.style.display = 'block';
} else {
$message.style.display = 'none';
}
showing = Math.min(Math.max(parseInt(showing), 1), 12);
$columns.forEach($el => {
$el.style.display = 'none';
});
$columns.slice(0, showing).forEach($el => {
$el.style.display = 'block';
});
$markup.innerHTML = '<span class="nt"><div</span> <span class="na">class=</span><span class="s">"columns"</span><span class="nt">></span>';
$markup.insertAdjacentHTML('beforeend', '\n');
for(let i = 0; i < showing; i++) {
$markup.insertAdjacentHTML('beforeend', ' <span class="nt"><div</span> <span class="na">class=</span><span class="s">"column"</span><span class="nt">></span>');
$markup.insertAdjacentHTML('beforeend', i + 1);
$markup.insertAdjacentHTML('beforeend', '<span class="nt"></div></span>');
$markup.insertAdjacentHTML('beforeend', '\n');
}
$markup.insertAdjacentHTML('beforeend', '<span class="nt"></div></span>');
}
$add.addEventListener('click', () => {
showing++;
showColumns();
});
$remove.addEventListener('click', () => {
showing--;
showColumns();
});
});