diff --git a/src/002-config/mousetrapConfig.js b/src/002-config/mousetrapConfig.js index 17135f873a43dacc974e17ddd0cde7d49d3b61a7..d0bc8f6dba111d63aa12ea390554a666ac2b7d7c 100644 --- a/src/002-config/mousetrapConfig.js +++ b/src/002-config/mousetrapConfig.js @@ -266,12 +266,12 @@ App.UI.Hotkeys = (function() { // add hotkeys App.UI.Hotkeys.add("endWeek", { callback: function() { - $("#story-caption #endWeekButton a.macro-link").trigger("click"); + $("#story-caption #endWeekButton").trigger("click"); }, combinations: ["enter"], uiName: "Next Week" }); App.UI.Hotkeys.add("nextLink", { callback: function() { - $("#story-caption #nextButton a.macro-link").trigger("click"); + $("#story-caption #nextButton").trigger("click"); }, combinations: ["space"], uiName: "Continue/Back" }); App.UI.Hotkeys.add("prev-slave", { diff --git a/src/gui/storyCaption.tw b/src/gui/storyCaption.tw index 3b76ccb2d5f93bcde51dde4ef0a6017274580c86..85d5e5f4667a2ae9070406f4e3e423c9fc7c2e09 100644 --- a/src/gui/storyCaption.tw +++ b/src/gui/storyCaption.tw @@ -2,7 +2,7 @@ <<set _Pass = passage()>> -<<if $ui != "start">><p><<includeDOM userButton()>></p><</if>> +<<if $ui != "start">><p><<includeDOM App.Utils.userButton()>></p><</if>> <<if $ui != "start">> <<if $cheatMode || $debugMode>> diff --git a/src/gui/userButton.js b/src/gui/userButton.js index b173ef506a4cf70322e4f6fadcd605d6887aa164..0c8cf11d416de2f83b950d4cc7650cd3bb5bcfad 100644 --- a/src/gui/userButton.js +++ b/src/gui/userButton.js @@ -1,42 +1,40 @@ -globalThis.userButton = function(nextButton = V.nextButton, nextLink = V.nextLink) { - const el = new DocumentFragment(); - const _Pass = passage(); - let div = document.createElement("div"); - div.style.fontWeight = "bold"; - // We must always have a named element so we have something to refresh even if the button is hidden for a scene - if (_Pass !== "End Week") { - if (_Pass === "Main") { - div.id = "endWeekButton"; - div.append( - App.UI.DOM.link( - "END WEEK", - () => endWeek() - ) +App.Utils.userButton = function(nextButton = V.nextButton, nextLink = V.nextLink) { + const el = document.createElement("span"); + el.id = "next-button-wrapper"; // We must always have a named element so we have something to refresh even if the button is hidden for a scene + const pass = passage(); + let link; + + if (pass !== "End Week") { + if (pass === "Main") { + link = App.UI.DOM.link( + "END WEEK", + () => endWeek() ); - div.append(" "); - App.UI.DOM.appendNewElement("span", div, App.UI.Hotkeys.hotkeys("endWeek"), "hotkey"); - el.append(div); + link.style.fontWeight = "bold"; + link.id = "endWeekButton"; + el.append(link); + el.append(" "); + App.UI.DOM.appendNewElement("span", el, App.UI.Hotkeys.hotkeys("endWeek"), "hotkey"); if (V.rulesAssistantAuto === 1 && DefaultRulesError()) { App.UI.DOM.appendNewElement("div", el, `WARNING: Rules Assistant has rules with errors!`, "yellow"); } } else { - div.id = "nextButton"; if (nextButton !== " ") { - div.append( - App.UI.DOM.passageLink( - nextButton, - nextLink - ) + link = App.UI.DOM.passageLink( + nextButton, + nextLink ); - div.append(" "); - App.UI.DOM.appendNewElement("span", div, App.UI.Hotkeys.hotkeys("nextLink"), "hotkey"); + link.style.fontWeight = "bold"; + link.id = "nextButton"; + el.append(link); + el.append(" "); + App.UI.DOM.appendNewElement("span", el, App.UI.Hotkeys.hotkeys("nextLink"), "hotkey"); } - el.append(div); } } return el; }; -globalThis.updateUserButton = function() { - return jQuery("#nextButton").empty().append(userButton()); +App.Utils.updateUserButton = function() { + return jQuery("#next-button-wrapper").empty().append(App.Utils.userButton()); }; diff --git a/src/utility/miscWidgets.tw b/src/utility/miscWidgets.tw index 9d0a63faeb61734ae5cf69a273f653cd7dbdedba..dccc305675c48392122a7d9c3f06f8c4e5181ca4 100644 --- a/src/utility/miscWidgets.tw +++ b/src/utility/miscWidgets.tw @@ -7,7 +7,7 @@ Call as <<UpdateNextButton>> Allows for dynamic updating of the next button in the storyCaption (left side-bar) for events that disable the button until user makes a selection %/ <<widget "UpdateNextButton">> - <<run updateUserButton()>> + <<run App.Utils.updateUserButton()>> <</widget>> <<widget "Master">><<if def $args[0]>><<run Enunciate($args[0])>><<elseif ndef $enunciate>><<run Enunciate($activeSlave)>><</if>>$enunciate.title<</widget>>