diff --git a/devTools/types/FC/facilities.d.ts b/devTools/types/FC/facilities.d.ts index c33c4f173ecbf44b74dbb1309eea611d75bbbc98..74976994de21b44095450afd2743925c86ccffe8 100644 --- a/devTools/types/FC/facilities.d.ts +++ b/devTools/types/FC/facilities.d.ts @@ -64,6 +64,13 @@ declare namespace FC { note?: string; /** Any prerequisites that must be met for the option to be displayed. */ prereqs?: Array<() => boolean> + /** Any dialog to display upon setting the value. */ + dialog?: { + /** The content displayed in the dialog. */ + content: string|HTMLElement|DocumentFragment; + /** The name of the dialog to display. */ + name: string; + }; }> /** Any additional nodes to attach. */ nodes?: Array<string|HTMLElement|DocumentFragment> diff --git a/src/004-base/facilityFramework.js b/src/004-base/facilityFramework.js index f500d2c1400d3c46e558c0a47e50114ad5b7970f..b9c10720b1302d78209854e251af8a859617b752 100644 --- a/src/004-base/facilityFramework.js +++ b/src/004-base/facilityFramework.js @@ -229,6 +229,10 @@ App.Facilities.Facility = class Facility { _.isEqual(V[rule.property], o.value)) { App.UI.DOM.appendNewElement("div", div, o.text); } + + if (o.dialog) { + options.addDialog(o.dialog.content, o.dialog.name); + } } }); diff --git a/src/facilities/club/club.js b/src/facilities/club/club.js index 1687f646ada61e01e965a19bb696ebe480ac361c..70e31a416e45818b39342f4c409e10fdcbfc0380 100644 --- a/src/facilities/club/club.js +++ b/src/facilities/club/club.js @@ -354,7 +354,7 @@ App.Facilities.Club.club = class Club extends App.Facilities.Facility { App.UI.DOM.appendNewElement("div", div, App.UI.DOM.passageLink(`Manage club advertisements`, "Club Advertisement", () => { V.nextLink = passage(); V.nextButton = "Back"; - })); + }), ["indent"]); return div; } diff --git a/src/gui/options/optionsGroup.js b/src/gui/options/optionsGroup.js index c49892ec2149452801e93eb75c9acdc3e5275a03..647169b5a86882316acd92b38d333883decaec11 100644 --- a/src/gui/options/optionsGroup.js +++ b/src/gui/options/optionsGroup.js @@ -487,6 +487,7 @@ App.UI.OptionsGroup = (function() { this.rows = []; this.doubleColumn = false; this.refresh = App.UI.reload; + this.dialog = null; } /** @@ -558,6 +559,19 @@ App.UI.OptionsGroup = (function() { return this._addRow(new CustomRow(element)); } + /** + * Opens the given element as a dialog upon selecting the option + * + * @param {HTMLElement|string|DocumentFragment} element + * @param {string} name + * @returns {this} + */ + addDialog(element, name) { + this.dialog = {element, name}; + + return this; + } + /** * @returns {HTMLDivElement} */ @@ -568,6 +582,19 @@ App.UI.OptionsGroup = (function() { container.classList.add("double"); } + if (this.dialog) { + container.onclick = () => { + if (Dialog.isOpen()) { + Dialog.close(); + } + Dialog.setup(this.dialog.name); + const frag = new DocumentFragment(); + frag.append(this.dialog.element); + $(Dialog.body()).empty().append(frag); + Dialog.open(); + } + } + for (const row of this.rows) { row.render(container, this.refresh); }