No more Zepto #168
6 changed files with 17 additions and 40 deletions
|
@ -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
|
||||||
|
document.querySelector("[data-action='toggle glossary sidebar']").onclick = () => {
|
||||||
/**
|
document.querySelector("body").classList.toggle("sidebar-closed");
|
||||||
* 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}`);
|
|
||||||
});
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* global $, send */ "use strict";
|
/* global send */ "use strict";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,11 +80,12 @@ function clearCanvas(canvas) {
|
||||||
|
|
||||||
function detectLanguageAndUpdate() { // eslint-disable-line
|
function detectLanguageAndUpdate() { // eslint-disable-line
|
||||||
const compare = (array1, array2) => array2.filter(value => array2.indexOf(value)); // compare two arrays and get match(es)
|
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 memeLocales = [];
|
||||||
const userLocales = [];
|
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) {
|
for (const key in memeLocaleObject) {
|
||||||
if (memeLocaleObject[key] && memeLocaleObject[key].value)
|
if (memeLocaleObject[key] && memeLocaleObject[key].value)
|
||||||
|
@ -95,7 +96,7 @@ function detectLanguageAndUpdate() { // eslint-disable-line
|
||||||
memeLocales.length &&
|
memeLocales.length &&
|
||||||
userLocales.length &&
|
userLocales.length &&
|
||||||
compare(memeLocales, 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) {
|
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
|
function getMemeInfo() { // TODO: Error handling
|
||||||
const info = {
|
return {
|
||||||
description: document.getElementById("meme-description").value,
|
description: document.getElementById("meme-description").value,
|
||||||
file_path: document.getElementById("meme-canvas").toDataURL("image/jpeg", 0.6),
|
file_path: document.getElementById("meme-canvas").toDataURL("image/jpeg", 0.6),
|
||||||
language: document.getElementById("meme-language").value,
|
language: document.getElementById("meme-language").value,
|
||||||
|
@ -221,8 +222,6 @@ function getMemeInfo() { // TODO: Error handling
|
||||||
nsfw: document.getElementById("meme-nsfw-flag").checked,
|
nsfw: document.getElementById("meme-nsfw-flag").checked,
|
||||||
title: document.getElementById("meme-title").value
|
title: document.getElementById("meme-title").value
|
||||||
};
|
};
|
||||||
|
|
||||||
return info;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleExamples = debounce(event => {
|
const handleExamples = debounce(event => {
|
||||||
|
@ -375,11 +374,9 @@ function updateCanvas(imageSource) {
|
||||||
|
|
||||||
if (imageSource) {
|
if (imageSource) {
|
||||||
ctx.drawImage(imageSource, 0, 0, canvasWidth, 600 * imageSource.height / imageSource.width);
|
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;
|
img.src = imageSource.src;
|
||||||
} else {
|
} else {
|
||||||
ctx.drawImage(imageSource, 0, 0, canvasWidth, 600 * imageSource.height / imageSource.width);
|
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);
|
positionCanvasText(ctx, canvasHeight, canvasWidth);
|
||||||
|
|
|
@ -69,7 +69,6 @@ module.exports = exports = (state, emit) => {
|
||||||
<link rel="shortcut icon" href="/assets/favicon.ico"/>
|
<link rel="shortcut icon" href="/assets/favicon.ico"/>
|
||||||
<link rel="stylesheet" href="/assets/bundle.css"/>
|
<link rel="stylesheet" href="/assets/bundle.css"/>
|
||||||
|
|
||||||
<script src="/assets/scripts/vendor/zepto.js"></script>
|
|
||||||
<script src="/assets/scripts/sockets.js"></script>
|
<script src="/assets/scripts/sockets.js"></script>
|
||||||
`;
|
`;
|
||||||
};
|
};
|
||||||
|
|
4
app/dist/scripts/api.js
vendored
4
app/dist/scripts/api.js
vendored
|
@ -3,18 +3,15 @@
|
||||||
|
|
||||||
|
|
||||||
// Initiate search functionality
|
// Initiate search functionality
|
||||||
|
|
||||||
let jets = new Jets({
|
let jets = new Jets({
|
||||||
contentTag: "#toc",
|
contentTag: "#toc",
|
||||||
searchTag: "#input-search"
|
searchTag: "#input-search"
|
||||||
});
|
});
|
||||||
|
|
||||||
// Reset search on page load
|
// Reset search on page load
|
||||||
|
|
||||||
document.getElementById("input-search").value = "";
|
document.getElementById("input-search").value = "";
|
||||||
|
|
||||||
// Activate search
|
// Activate search
|
||||||
|
|
||||||
document.getElementById("input-search").addEventListener("keyup", () => {
|
document.getElementById("input-search").addEventListener("keyup", () => {
|
||||||
if (document.getElementById("input-search").value)
|
if (document.getElementById("input-search").value)
|
||||||
document.querySelector(".api__toc__search__clear").classList.add("active");
|
document.querySelector(".api__toc__search__clear").classList.add("active");
|
||||||
|
@ -24,7 +21,6 @@ document.getElementById("input-search").addEventListener("keyup", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Cancel search
|
// Cancel search
|
||||||
|
|
||||||
document.querySelector(".api__toc__search__clear").addEventListener("click", () => {
|
document.querySelector(".api__toc__search__clear").addEventListener("click", () => {
|
||||||
document.getElementById("input-search").value = "";
|
document.getElementById("input-search").value = "";
|
||||||
document.querySelector(".api__toc__search__clear").classList.remove("active");
|
document.querySelector(".api__toc__search__clear").classList.remove("active");
|
||||||
|
|
6
app/dist/scripts/app.js
vendored
6
app/dist/scripts/app.js
vendored
|
@ -48,8 +48,10 @@ document.querySelectorAll("a[href^='#']").forEach(anchor => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add hash to URL bar when sidebar links are clicked
|
// Add hash to URL bar when sidebar links are clicked
|
||||||
if (event.target.parentElement.className === "api__toc__item")
|
if (
|
||||||
history.replaceState({}, "", `#${element}`);
|
event.target.parentElement.className === "api__toc__item" ||
|
||||||
|
event.target.parentElement.parentElement.className === "component--glossary-toc"
|
||||||
|
) history.replaceState({}, "", `#${element}`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
2
app/dist/scripts/vendor/zepto.js
vendored
2
app/dist/scripts/vendor/zepto.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue