This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vue from "vue"; | |
// Create the event bus by creating a new Vue instance and | |
// binding it somehwere accessible. If you bind it to the | |
// Vue prototype, you can access it within your components | |
// like this: | |
// | |
// Emit an event | |
// this.$bus.$emit('myEvent', {data: true}) | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const IEdgeMatches = /(Edge|Trident)\/(\d.)/i.exec(navigator.userAgent); | |
export default IEdgeMatches && parseInt(IEdgeMatches[2], 10) < 17; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function serialize(form) { | |
const inputs = form.querySelectorAll("input"); | |
const fields = {}; | |
for (const input of inputs) { | |
if (input.name && !input.disabled && input.type !== "file" && input.type !== "reset" && input.type !== "submit" && input.type !== "button") { | |
if ((input.type !== "checkbox" && input.type !== "radio") || input.checked) { | |
fields[input.name] = input.value; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function applyBeforeExit(doBefore) { | |
document.addEventListener("click", async (event) => { | |
// Test for left click. | |
if (event.button !== 0) { | |
return; | |
} | |
let element = event.target; | |
// Go up through the DOM tree to search for a link |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pageLoaded() { | |
return new Promise(resolve => { | |
if (document.readyState === "complete") { | |
resolve(); | |
} else { | |
window.addEventListener("load", () => { | |
resolve(); | |
}); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ext = url.slice(((url.lastIndexOf(".") - 1) >>> 0) + 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function $(strings, ...expressions) { | |
let selector = [strings[0]]; | |
expressions.forEach((expr, i) => selector.push(expr, strings[i + 1])); | |
return document.querySelector(selector.join("")); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Cross-editor coding style settings. | |
# See http://editorconfig.org/ for details. | |
root = true | |
[*] | |
charset = utf-8 | |
indent_style = space | |
indent_size = 4 | |
end_of_line = lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const def = ["en", "fr", "de"]; | |
let locale = navigator.language.indexOf("-") === -1 | |
? navigator.language | |
: navigator.language.split("-")[0]; | |
locale = def.indexOf(locale) === -1 ? def[0] : locale; | |
document.documentElement.lang = locale; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var image = document.getElementById("image-${content.@id}"); | |
var imageTop = (function() { | |
var element = image, top = element.offsetTop; | |
while ((element = element.offsetParent) !== null && element !== document.body) { top += element.offsetTop; } | |
return top; | |
}()); | |
image.style.height = (window.innerHeight - imageTop) + "px"; | |
}()); |