fix sidebar
This commit is contained in:
parent
fe41352afd
commit
9d23ad1150
1 changed files with 409 additions and 316 deletions
|
@ -21,7 +21,7 @@ export default class windowman {
|
|||
function headers() {
|
||||
let LOAD_STATE = true;
|
||||
let UI = {
|
||||
"CSS": [
|
||||
CSS: [
|
||||
chrome.runtime.getURL(
|
||||
"gui/styles/external/fonts/materialdesignicons.min.css",
|
||||
),
|
||||
|
@ -32,7 +32,6 @@ export default class windowman {
|
|||
],
|
||||
};
|
||||
|
||||
|
||||
for (let index = 0; index < UI[`CSS`].length; index++) {
|
||||
const source = UI.CSS[index];
|
||||
|
||||
|
@ -42,7 +41,7 @@ export default class windowman {
|
|||
let resource = false;
|
||||
try {
|
||||
resource = await net.download(source, `text`, true);
|
||||
} catch(err) {};
|
||||
} catch (err) {}
|
||||
|
||||
if (resource) {
|
||||
let metadata_element = document.createElement(`link`);
|
||||
|
@ -51,13 +50,21 @@ export default class windowman {
|
|||
metadata_element.setAttribute(`href`, source);
|
||||
document.querySelector(`head`).appendChild(metadata_element);
|
||||
} else {
|
||||
const alerts = (await import(chrome.runtime.getURL(`/gui/scripts/alerts.js`))).default;
|
||||
const reader = (await import(chrome.runtime.getURL(`/gui/scripts/read.js`))).default;
|
||||
const alerts = (
|
||||
await import(chrome.runtime.getURL(`/gui/scripts/alerts.js`))
|
||||
).default;
|
||||
const reader = (
|
||||
await import(chrome.runtime.getURL(`/gui/scripts/read.js`))
|
||||
).default;
|
||||
|
||||
alerts.error(-1, reader.localized(`error_msg_fileNotFound`), true, [source]);
|
||||
alerts.error(-1, reader.localized(`error_msg_fileNotFound`), true, [
|
||||
source,
|
||||
]);
|
||||
|
||||
// Stop loading the page when an error has occured; it's not going to work!
|
||||
if (!DEBUG) {window.close()};
|
||||
if (!DEBUG) {
|
||||
window.close();
|
||||
}
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
@ -86,22 +93,39 @@ export default class windowman {
|
|||
if (!button.classList.contains(`btn`)) {
|
||||
button.classList.add(`btn`);
|
||||
}
|
||||
if (!button.classList.contains(`waves-effect`)) {
|
||||
});
|
||||
|
||||
[]
|
||||
.concat(
|
||||
document.querySelectorAll(`a`)
|
||||
? document.querySelectorAll(`a`)
|
||||
: [],
|
||||
document.querySelectorAll(`button`)
|
||||
? document.querySelectorAll(`button`)
|
||||
: [],
|
||||
document.querySelectorAll(
|
||||
`input:not([type="checkbox"]):not([type="radio"]):not([type="range"])`,
|
||||
)
|
||||
? document.querySelectorAll(
|
||||
`input:not([type="checkbox"]):not([type="radio"]):not([type="range"])`,
|
||||
)
|
||||
: [],
|
||||
)
|
||||
.forEach((ELEMENT_TYPE) => {
|
||||
ELEMENT_TYPE.forEach((button) => {
|
||||
if (
|
||||
button.classList
|
||||
? !button.classList.contains(`waves-effect`)
|
||||
: true
|
||||
) {
|
||||
button.classList.add(`waves-effect`);
|
||||
}
|
||||
})
|
||||
document.querySelectorAll(`a`).forEach((button) => {
|
||||
if (!button.classList.contains(`waves-effect`)) {
|
||||
button.classList.add(`waves-effect`);
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
buttons();
|
||||
}
|
||||
|
||||
|
||||
function icons() {
|
||||
let target_elements = document.querySelectorAll(`[data-icon]`);
|
||||
|
||||
|
@ -318,6 +342,62 @@ export default class windowman {
|
|||
}
|
||||
}
|
||||
|
||||
/* Enable the searching interface. */
|
||||
function search() {}
|
||||
|
||||
// Responsiveness to different screen sizes.
|
||||
function resize() {
|
||||
function sidebar() {
|
||||
if (document.querySelector(`.sidebar`)) {
|
||||
if (window.innerWidth < 600) {
|
||||
document
|
||||
.querySelector(`.sidebar`)
|
||||
.style.setProperty(`display`, `none`);
|
||||
document
|
||||
.querySelector(`.sidebar`)
|
||||
.style.setProperty(`position`, `fixed`);
|
||||
} else {
|
||||
document
|
||||
.querySelector(`.sidebar`)
|
||||
.style.removeProperty(`display`);
|
||||
document
|
||||
.querySelector(`.sidebar`)
|
||||
.style.removeProperty(`position`);
|
||||
}
|
||||
if (document.querySelector(`[data-action="ui,close,navbar"]`)) {
|
||||
document
|
||||
.querySelector(`[data-action="ui,close,navbar"]`)
|
||||
.addEventListener(`click`, function () {
|
||||
if (document.querySelector(`.sidebar`)) {
|
||||
document
|
||||
.querySelector(`.sidebar`)
|
||||
.style.removeProperty("display");
|
||||
document
|
||||
.querySelector(`.sidebar`)
|
||||
.style.removeProperty("position");
|
||||
}
|
||||
});
|
||||
}
|
||||
if (document.querySelector(`[data-action="ui,open,navbar"]`)) {
|
||||
document
|
||||
.querySelector(`[data-action="ui,open,navbar"]`)
|
||||
.addEventListener(`click`, function () {
|
||||
document
|
||||
.querySelector(`.sidebar`)
|
||||
.style.setProperty("display", "block");
|
||||
document
|
||||
.querySelector(`.sidebar`)
|
||||
.style.setProperty("position", "fixed");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sidebar();
|
||||
}
|
||||
|
||||
window.addEventListener("resize", resize);
|
||||
resize();
|
||||
links();
|
||||
}
|
||||
|
||||
|
@ -340,12 +420,25 @@ export default class windowman {
|
|||
input_elements.forEach((input_element) => {
|
||||
if (input_element.getAttribute("data-enable")) {
|
||||
(async () => {
|
||||
input_element.disabled =
|
||||
!(((await secretariat.read(input_element.getAttribute("data-enable"))) != null)
|
||||
? ((typeof (await secretariat.read(input_element.getAttribute("data-enable")))).includes(`Object`)
|
||||
? ((await secretariat.read(input_element.getAttribute("data-enable"))).length > 0)
|
||||
: !!(await secretariat.read(input_element.getAttribute("data-enable")))
|
||||
console.log(
|
||||
await secretariat.read(
|
||||
input_element.getAttribute("data-enable"),
|
||||
),
|
||||
);
|
||||
input_element.disabled = !((await secretariat.read(
|
||||
input_element.getAttribute("data-enable"),
|
||||
)) != null
|
||||
? (typeof (await secretariat.read(
|
||||
input_element.getAttribute("data-enable"),
|
||||
))).includes(`obj`)
|
||||
? (
|
||||
await secretariat.read(
|
||||
input_element.getAttribute("data-enable"),
|
||||
)
|
||||
).length > 0
|
||||
: !!(await secretariat.read(
|
||||
input_element.getAttribute("data-enable"),
|
||||
))
|
||||
: false);
|
||||
})();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue