bulma/docs/lib/index.js

119 lines
3.6 KiB
JavaScript
Raw Permalink Normal View History

2024-01-11 03:58:20 +00:00
"use strict";
2017-07-01 17:30:39 +00:00
2024-01-11 03:58:20 +00:00
document.addEventListener("DOMContentLoaded", function () {
2017-10-10 16:48:01 +00:00
// Intro
2024-01-11 03:58:20 +00:00
var introVideo = document.getElementById("introVideo");
var introIframe = document.getElementById("introIframe");
var npmClipboard = new Clipboard("#npmCopy");
2017-10-10 16:48:01 +00:00
if (window.Vimeo) {
2018-08-01 10:28:08 +00:00
var introPlayer = new Vimeo.Player(introIframe);
introPlayer.ready().then(function () {
2024-01-11 03:58:20 +00:00
introVideo.classList.add("has-loaded");
2018-08-01 10:28:08 +00:00
});
}
2017-10-10 16:48:01 +00:00
2024-01-11 03:58:20 +00:00
npmClipboard.on("success", function (e) {
e.trigger.innerText = "copied!";
e.trigger.classList.add("is-success");
2017-10-10 16:48:01 +00:00
setTimeout(function () {
2024-01-11 03:58:20 +00:00
e.trigger.innerText = "copy";
e.trigger.classList.remove("is-success");
2017-10-10 16:48:01 +00:00
}, 500);
e.clearSelection();
});
2024-01-11 03:58:20 +00:00
npmClipboard.on("error", function (e) {
e.trigger.innerText = "error!";
e.trigger.classList.add("is-error");
2017-10-10 16:48:01 +00:00
setTimeout(function () {
2024-01-11 03:58:20 +00:00
e.trigger.innerText = "copy";
e.trigger.classList.remove("is-error");
2017-10-10 16:48:01 +00:00
}, 500);
});
// Grid
2024-01-11 03:58:20 +00:00
var $grid = document.getElementById("grid");
var $columns = Array.prototype.slice.call(document.querySelectorAll("#grid > .column"), 0);
var $markup = document.querySelector("#markup code");
var $message = document.getElementById("message");
var $add = document.getElementById("add");
var $remove = document.getElementById("remove");
2017-07-01 17:30:39 +00:00
var showing = 5;
function showColumns() {
if (showing === 13) {
2024-01-11 03:58:20 +00:00
$message.style.display = "block";
2017-07-01 17:30:39 +00:00
} else {
2024-01-11 03:58:20 +00:00
$message.style.display = "none";
2017-07-01 17:30:39 +00:00
}
2018-04-10 11:26:37 +00:00
showing = Math.min(Math.max(parseInt(showing), 1), 12);
2017-07-01 17:30:39 +00:00
$columns.forEach(function ($el) {
2024-01-11 03:58:20 +00:00
$el.style.display = "none";
2017-07-01 17:30:39 +00:00
});
$columns.slice(0, showing).forEach(function ($el) {
2024-01-11 03:58:20 +00:00
$el.style.display = "block";
2017-07-01 17:30:39 +00:00
});
$markup.innerHTML = '<span class="nt">&lt;div</span> <span class="na">class=</span><span class="s">&quot;columns&quot;</span><span class="nt">&gt;</span>';
2024-01-11 03:58:20 +00:00
$markup.insertAdjacentHTML("beforeend", "\n");
2017-07-01 17:30:39 +00:00
for (var i = 0; i < showing; i++) {
2024-01-11 03:58:20 +00:00
$markup.insertAdjacentHTML("beforeend", ' <span class="nt">&lt;div</span> <span class="na">class=</span><span class="s">&quot;column&quot;</span><span class="nt">&gt;</span>');
$markup.insertAdjacentHTML("beforeend", i + 1);
$markup.insertAdjacentHTML("beforeend", '<span class="nt">&lt;/div&gt;</span>');
$markup.insertAdjacentHTML("beforeend", "\n");
2017-07-01 17:30:39 +00:00
}
2024-01-11 03:58:20 +00:00
$markup.insertAdjacentHTML("beforeend", '<span class="nt">&lt;/div&gt;</span>');
2017-07-01 17:30:39 +00:00
}
2024-01-11 03:58:20 +00:00
$add.addEventListener("click", function () {
2017-07-01 17:30:39 +00:00
showing++;
showColumns();
});
2024-01-11 03:58:20 +00:00
$remove.addEventListener("click", function () {
2017-07-01 17:30:39 +00:00
showing--;
showColumns();
});
2024-01-11 03:58:20 +00:00
// Amis
var $amis = document.getElementById("amis");
2024-01-19 13:39:17 +00:00
var $pied = document.getElementById("pied");
2024-01-11 03:58:20 +00:00
2024-01-11 21:17:22 +00:00
if ($amis) {
fetch("https://jgthms.com/amis/new.json").then(function (response) {
if (!response.ok) {
throw new Error("HTTP error! Status: " + response.status);
}
return response.json();
}).then(function (response) {
response.forEach(function (item) {
var el = document.createElement("a");
el.className = "bd-sponsor-item bd-partner-sponsor";
2024-01-12 12:45:08 +00:00
el.href = item.url;
2024-01-11 21:17:22 +00:00
el.target = "_blank";
el.title = item.title || item.id;
var extension = item.svg ? ".svg" : ".png";
var img = document.createElement("img");
img.src = "https://jgthms.com/amis/images/" + item.id + extension;
el.appendChild(img);
$amis.appendChild(el);
2024-01-19 13:39:17 +00:00
if (item.pied && $pied) {
el.className = "bd-sponsor-item bd-footer-sponsor";
$pied.appendChild(el);
}
2024-01-11 21:17:22 +00:00
});
2024-01-11 03:58:20 +00:00
});
2024-01-11 12:57:09 +00:00
}
2024-01-19 13:39:17 +00:00
});