major: orbit branding

This commit is contained in:
Jean-Baptiste Pasquier
2021-06-15 13:48:49 +02:00
parent 5932d8306c
commit e65def6234
106 changed files with 404 additions and 422 deletions

View File

@ -1,10 +1,10 @@
/*
Geocoord helper using Nominatim
Usage:
const madrid = await hubl.geocoord('Madrid');
const madrid = await orbit.geocoord('Madrid');
madrid == ["-3.7035825", "40.4167047"]
*/
window.hubl.geocoord = async (address = false) => {
window.orbit.geocoord = async (address = false) => {
if (address) {
const nominatim = await fetch('https://nominatim.openstreetmap.org/?format=geocodejson&limit=1&q=' + encodeURI(address));
const response = await nominatim.json();
@ -22,9 +22,9 @@ window.hubl.geocoord = async (address = false) => {
return ["-47.15", "-123.716667"];
}
window.hubl.geocalc = (element) => {
window.orbit.geocalc = (element) => {
const editionForm = element.parentElement.parentElement.parentElement.parentElement;
window.hubl.geocoord(editionForm.querySelector('input[name="address_line1"]').value + " " + editionForm.querySelector('input[name="address_line2"]').value).then(coords => {
window.orbit.geocoord(editionForm.querySelector('input[name="address_line1"]').value + " " + editionForm.querySelector('input[name="address_line2"]').value).then(coords => {
editionForm.querySelector('input[name="lat"]').value = coords[1];
editionForm.querySelector('input[name="lng"]').value = coords[0];
editionForm.querySelector('input[type="submit"]').click();

View File

@ -14,7 +14,7 @@ class JsI18n {
Method for automatically detecting the language, does not work in every browser.
*/
async detectLanguage() {
const customLangs = document.querySelectorAll('hubl-lang');
const customLangs = document.querySelectorAll('orbit-lang');
if (customLangs) {
for (let lang of customLangs) {
let name = lang.getAttribute('lang'),
@ -34,7 +34,7 @@ class JsI18n {
}
resumeDetection() {
const langComponent = document.querySelector('hubl-fallback-lang');
const langComponent = document.querySelector('orbit-fallback-lang');
if (langComponent) {
if (langComponent.hasAttribute('lang')) {
this.defaultLocale = langComponent.getAttribute('lang');
@ -252,20 +252,20 @@ class JsI18n {
}
//Global
window.hubl.intl = new JsI18n;
window.orbit.intl = new JsI18n;
document.addEventListener("DOMContentLoaded", () => {
// Detect the lang & initialize, based on the browser or "language" item from localstorage
window.hubl.intl.detectLanguage();
window.orbit.intl.detectLanguage();
let timer;
(new MutationObserver((mutations) => {
mutations.forEach(mutation => {
if (mutation.target.attributes["data-trans"] != null) {
// Render the target of the mutation instantly
window.hubl.intl.processNode(mutation.target);
window.orbit.intl.processNode(mutation.target);
// Then wait one arbitrary second to re-render the whole document in case a widget re-rendered
clearTimeout(timer);
timer = setTimeout(() => window.hubl.intl.processNode(document.querySelector('body')), 500);
timer = setTimeout(() => window.orbit.intl.processNode(document.querySelector('body')), 500);
}
});
}).observe(document.body, {
@ -273,9 +273,9 @@ document.addEventListener("DOMContentLoaded", () => {
childList: true
}));
document.addEventListener('widgetRendered', event => {
window.hubl.intl.processNode(event.target);
window.orbit.intl.processNode(event.target);
// Then wait one arbitrary second to re-render the whole document in case a widget re-rendered
clearTimeout(timer);
timer = setTimeout(() => window.hubl.intl.processNode(document.querySelector('body')), 500);
timer = setTimeout(() => window.orbit.intl.processNode(document.querySelector('body')), 500);
});
});

View File

@ -40,7 +40,7 @@ window.addEventListener("navigate", e => {
window.dispatchEvent(
new CustomEvent('requestNavigation', {
detail: {
route: window.hubl.getRoute((window.hubl.defaultRoute || "dashboard"), true)
route: window.orbit.getRoute((window.orbit.defaultRoute || "dashboard"), true)
}
}),
);

View File

@ -76,7 +76,7 @@ function openRightMobileMenu() {
}
document.addEventListener("DOMContentLoaded", function () {
const componentSet = new Set(window.hubl.components.map(c => c.type));
const componentSet = new Set(window.orbit.components.map(c => c.type));
// Workaround - No "navigate" event after the login on `/login`
if (window.location.pathname == "/login") {
@ -92,7 +92,7 @@ document.addEventListener("DOMContentLoaded", function () {
window.dispatchEvent(
new CustomEvent('requestNavigation', {
detail: {
route: window.hubl.getRoute((window.hubl.defaultRoute || "dashboard"), true)
route: window.orbit.getRoute((window.orbit.defaultRoute || "dashboard"), true)
}
}),
);
@ -112,7 +112,7 @@ document.addEventListener("DOMContentLoaded", function () {
onlyAdmin.setAttribute('hidden', '');
}
}
for (component of window.hubl.components) {
for (component of window.orbit.components) {
let adminTarget = document.querySelector(`solid-route[name="admin-${component.route}"]`);
let adminTargetTwo = document.querySelector(`.jsRightMenu solid-link[next="admin-${component.route}"]`);
if (e.detail.route.startsWith(`admin-${component.route}`)) {
@ -139,7 +139,7 @@ document.addEventListener("DOMContentLoaded", function () {
window.dispatchEvent(
new CustomEvent('requestNavigation', {
detail: {
route: window.hubl.getRoute((window.hubl.defaultRoute || "dashboard"), true)
route: window.orbit.getRoute((window.orbit.defaultRoute || "dashboard"), true)
}
}),
);