add seperate function to instantiate the extras
Can be done automatically under design()
This commit is contained in:
parent
b3b6522f52
commit
f59e1d304c
2 changed files with 43 additions and 11 deletions
9
scripts/GUI/builder/windowman.extras.js
Normal file
9
scripts/GUI/builder/windowman.extras.js
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
|
||||||
|
import {Search} from "./windowman.search.js";
|
||||||
|
import {Tabs} from "./windowman.tabs.js";
|
||||||
|
|
||||||
|
class UI {}
|
||||||
|
UI.search = Search;
|
||||||
|
UI.tabs = Tabs;
|
||||||
|
|
||||||
|
export {UI as default};
|
|
@ -6,7 +6,7 @@ import Tabs from "/scripts/GUI/tabs.js";
|
||||||
import {global, observe} from "/scripts/secretariat.js";
|
import {global, observe} from "/scripts/secretariat.js";
|
||||||
import {URLs} from "/scripts/utils/URLs.js";
|
import {URLs} from "/scripts/utils/URLs.js";
|
||||||
import wait from "/scripts/utils/wait.js";
|
import wait from "/scripts/utils/wait.js";
|
||||||
import UI from "/scripts/GUI/builder/windowman.search.js";
|
import UI from "/scripts/GUI/builder/windowman.extras.js";
|
||||||
|
|
||||||
export default class windowman {
|
export default class windowman {
|
||||||
elements = {};
|
elements = {};
|
||||||
|
@ -308,10 +308,43 @@ export default class windowman {
|
||||||
actions();
|
actions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Instantiate the extras.
|
||||||
|
*/
|
||||||
|
const extras = () => {
|
||||||
|
// Add the search interface.
|
||||||
|
(Object.keys(UI)).forEach((FEATURE) => {
|
||||||
|
this.extra(FEATURE, (this[`options`] && (typeof this[`options`]).includes(`obj`)) ? this[`options`][FEATURE] : null);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the elements.
|
||||||
this[`elements`] = appearance();
|
this[`elements`] = appearance();
|
||||||
events();
|
events();
|
||||||
|
|
||||||
|
// Add the extras.
|
||||||
|
(((this[`options`] && (typeof this[`options`]).includes(`obj`)) ? Object.hasOwn(this[`options`], `automatic`) : false) ? this[`options`][`automatic`] : true)
|
||||||
|
? extras()
|
||||||
|
: false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Instantiate the extras.
|
||||||
|
|
||||||
|
@param {string} name The name of the extra UI feature
|
||||||
|
@param {object} options The options for the extra UI feature
|
||||||
|
*/
|
||||||
|
extra(name, options) {
|
||||||
|
(Object.keys(UI)).includes(name)
|
||||||
|
?
|
||||||
|
// De-instantiate the feature if a cancel option is passed.
|
||||||
|
(((options && (typeof options).includes(`obj`)) ? options[`cancel`] : false)
|
||||||
|
? delete this[name]
|
||||||
|
: (this[name] = (this[name]) ? this[name] : new UI[name](options))
|
||||||
|
)
|
||||||
|
: false;
|
||||||
|
};
|
||||||
|
|
||||||
/* Run this function if you would like to synchronize with data. */
|
/* Run this function if you would like to synchronize with data. */
|
||||||
async sync() {
|
async sync() {
|
||||||
// Prepare flags.
|
// Prepare flags.
|
||||||
|
@ -487,16 +520,6 @@ export default class windowman {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
Instantiate the extras.
|
|
||||||
*/
|
|
||||||
const extras = () => {
|
|
||||||
// Add the search interface.
|
|
||||||
(Object.keys(UI)).forEach((FEATURE) => {
|
|
||||||
this[FEATURE] = new UI[FEATURE]();
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fill();
|
fill();
|
||||||
write();
|
write();
|
||||||
extras();
|
extras();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue