MCPcopy Index your code
hub / github.com/EmulatorJS/EmulatorJS / createSettingParent

Method createSettingParent

data/src/emulator.js:4542–4619  ·  view source on GitHub ↗
(child, title, parentElement)

Source from the content-addressed store, hash-verified

4540 let parentMenuCt = 0;
4541
4542 const createSettingParent = (child, title, parentElement) => {
4543 const rv = this.createElement("div");
4544 rv.classList.add("ejs_setting_menu");
4545
4546 if (child) {
4547 const menuOption = this.createElement("div");
4548 menuOption.classList.add("ejs_settings_main_bar");
4549 const span = this.createElement("span");
4550 span.innerText = title;
4551
4552 menuOption.appendChild(span);
4553 parentElement.appendChild(menuOption);
4554
4555 const menu = this.createElement("div");
4556 const menuChild = this.createElement("div");
4557 menus.push(menu);
4558 parentMenuCt++;
4559 menu.setAttribute("hidden", "");
4560 menuChild.classList.add("ejs_parent_option_div");
4561 const button = this.createElement("button");
4562 const goToHome = () => {
4563 const homeSize = this.getElementSize(parentElement);
4564 nested.style.width = (homeSize.width + 20) + "px";
4565 nested.style.height = homeSize.height + "px";
4566 menu.setAttribute("hidden", "");
4567 parentElement.removeAttribute("hidden");
4568 }
4569 this.addEventListener(menuOption, "click", (e) => {
4570 const targetSize = this.getElementSize(menu);
4571 nested.style.width = (targetSize.width + 20) + "px";
4572 nested.style.height = targetSize.height + "px";
4573 menu.removeAttribute("hidden");
4574 rv.scrollTo(0, 0);
4575 parentElement.setAttribute("hidden", "");
4576 })
4577 const observer = new MutationObserver((list) => {
4578 for (const k of list) {
4579 for (const removed of k.removedNodes) {
4580 if (removed === menu) {
4581 menuOption.remove();
4582 observer.disconnect();
4583 const index = menus.indexOf(menu);
4584 if (index !== -1) menus.splice(index, 1);
4585 this.settingsMenu.style.display = "";
4586 const homeSize = this.getElementSize(parentElement);
4587 nested.style.width = (homeSize.width + 20) + "px";
4588 nested.style.height = homeSize.height + "px";
4589 // This SHOULD always be called before the game started - this SHOULD never be an issue
4590 this.settingsMenu.style.display = "none";
4591 }
4592 }
4593 }
4594 });
4595 this.addEventListener(button, "click", goToHome);
4596
4597 button.type = "button";
4598 button.classList.add("ejs_back_button");
4599 menuChild.appendChild(button);

Callers

nothing calls this directly

Calls 4

createElementMethod · 0.95
addEventListenerMethod · 0.95
getElementSizeMethod · 0.95
removeMethod · 0.45

Tested by

no test coverage detected