No more Zepto #168

Merged
NetOpWibby merged 1 commit from zepto-removal into master 2018-10-02 20:54:07 +02:00
6 changed files with 17 additions and 40 deletions
Showing only changes of commit 7d1728daaa - Show all commits

View file

@ -1,26 +1,11 @@
/* global $, document */ "use strict";
/* global document */ "use strict";
/**
* Add page-specific styling
*/
// Add page-specific styling
document.querySelector("body").classList.add("glossary");
document.getElementsByTagName("body")[0].classList.add("glossary");
/**
* Toggle sidebar
*/
$("[data-action='toggle glossary sidebar']").on("click", () => {
$("body").toggleClass("sidebar-closed");
});
/**
* Add hash to URL bar when sidebar links are clicked
*/
$(".component--glossary-toc li a").on("click", event => {
const hash = event.currentTarget.href.split("#")[1];
history.replaceState({}, "", `#${hash}`);
});
// Toggle sidebar
document.querySelector("[data-action='toggle glossary sidebar']").onclick = () => {
document.querySelector("body").classList.toggle("sidebar-closed");
};

View file

@ -1,4 +1,4 @@
/* global $, send */ "use strict";
/* global send */ "use strict";
@ -80,11 +80,12 @@ function clearCanvas(canvas) {
function detectLanguageAndUpdate() { // eslint-disable-line
const compare = (array1, array2) => array2.filter(value => array2.indexOf(value)); // compare two arrays and get match(es)
const memeLocaleObject = $("#meme-language").children();
const memeLocaleObject = document.getElementById("meme-language").children;
const memeLocales = [];
const userLocales = [];
for (const language of navigator.languages) userLocales.push(language);
for (const language of navigator.languages)
userLocales.push(language);
for (const key in memeLocaleObject) {
if (memeLocaleObject[key] && memeLocaleObject[key].value)
@ -95,7 +96,7 @@ function detectLanguageAndUpdate() { // eslint-disable-line
memeLocales.length &&
userLocales.length &&
compare(memeLocales, userLocales).length
) $("#meme-language").children(`option[value="${compare(memeLocales, userLocales)[0]}"]`).attr("selected", true);
) document.querySelector(`option[value="${compare(memeLocales, userLocales)[0]}"]`).setAttribute("selected", true);
}
function debounce(func, wait, immediate) {
@ -212,7 +213,7 @@ curl --header <span class="token string">"Content-Type: application/json"</span>
}
function getMemeInfo() { // TODO: Error handling
const info = {
return {
description: document.getElementById("meme-description").value,
file_path: document.getElementById("meme-canvas").toDataURL("image/jpeg", 0.6),
language: document.getElementById("meme-language").value,
@ -221,8 +222,6 @@ function getMemeInfo() { // TODO: Error handling
nsfw: document.getElementById("meme-nsfw-flag").checked,
title: document.getElementById("meme-title").value
};
return info;
}
const handleExamples = debounce(event => {
@ -375,11 +374,9 @@ function updateCanvas(imageSource) {
if (imageSource) {
ctx.drawImage(imageSource, 0, 0, canvasWidth, 600 * imageSource.height / imageSource.width);
// ctx.drawImage(imageSource, 0, 0, canvasWidth, canvasHeight, 0, 0, canvasWidth, canvasHeight);
img.src = imageSource.src;
} else {
ctx.drawImage(imageSource, 0, 0, canvasWidth, 600 * imageSource.height / imageSource.width);
// ctx.drawImage(img, 0, 0, canvasWidth, canvasHeight, 0, 0, canvasWidth, canvasHeight);
}
positionCanvasText(ctx, canvasHeight, canvasWidth);

View file

@ -69,7 +69,6 @@ module.exports = exports = (state, emit) => {
<link rel="shortcut icon" href="/assets/favicon.ico"/>
<link rel="stylesheet" href="/assets/bundle.css"/>
<script src="/assets/scripts/vendor/zepto.js"></script>
<script src="/assets/scripts/sockets.js"></script>
`;
};

View file

@ -3,18 +3,15 @@
// Initiate search functionality
let jets = new Jets({
contentTag: "#toc",
searchTag: "#input-search"
});
// Reset search on page load
document.getElementById("input-search").value = "";
// Activate search
document.getElementById("input-search").addEventListener("keyup", () => {
if (document.getElementById("input-search").value)
document.querySelector(".api__toc__search__clear").classList.add("active");
@ -24,7 +21,6 @@ document.getElementById("input-search").addEventListener("keyup", () => {
});
// Cancel search
document.querySelector(".api__toc__search__clear").addEventListener("click", () => {
document.getElementById("input-search").value = "";
document.querySelector(".api__toc__search__clear").classList.remove("active");

View file

@ -48,8 +48,10 @@ document.querySelectorAll("a[href^='#']").forEach(anchor => {
}
// Add hash to URL bar when sidebar links are clicked
if (event.target.parentElement.className === "api__toc__item")
history.replaceState({}, "", `#${element}`);
if (
event.target.parentElement.className === "api__toc__item" ||
event.target.parentElement.parentElement.className === "component--glossary-toc"
) history.replaceState({}, "", `#${element}`);
});
});

File diff suppressed because one or more lines are too long