diff --git a/app/assets/javascripts/beak/hnw/common/handle-frame-resize.coffee b/app/assets/javascripts/beak/hnw/common/handle-frame-resize.coffee deleted file mode 100644 index 27dbf905a..000000000 --- a/app/assets/javascripts/beak/hnw/common/handle-frame-resize.coffee +++ /dev/null @@ -1,40 +0,0 @@ -import genPageTitle from "./gen-page-title.js" - -# (() => DOMElement, () => Session) => Unit -handleFrameResize = (getActiveContainer, getSession) -> - - if parent isnt window - - width = "" - height = "" - - onInterval = - -> - - activeContainer = getActiveContainer() - session = getSession() - sessionName = session?.modelTitle() ? "" - - if (activeContainer.scrollWidth isnt width or - activeContainer.scrollHeight isnt height or - (session? and document.title isnt genPageTitle(sessionName))) - - if session? - document.title = genPageTitle(sessionName) - - width = activeContainer.scrollWidth - height = activeContainer.scrollHeight - - if session? and session.widgetController.ractive.get("isHNWHost") isnt true - parent.postMessage({ - width: activeContainer.scrollWidth + 330, - height: activeContainer.scrollHeight + 60, - title: document.title, - type: "nlw-resize" - }, "*") - - window.setInterval(onInterval, 200) - - return - -export default handleFrameResize diff --git a/app/assets/javascripts/beak/hnw/host/handle-window-message.coffee b/app/assets/javascripts/beak/hnw/host/handle-window-message.coffee index d6952f2dd..7c47a6119 100644 --- a/app/assets/javascripts/beak/hnw/host/handle-window-message.coffee +++ b/app/assets/javascripts/beak/hnw/host/handle-window-message.coffee @@ -62,6 +62,12 @@ handleWindowMessage = ( onWidgetMessage, onRainCheckMessage, getSession elem.height = height document.title = title + when "resize-joiner" + joiners = document.querySelectorAll("iframe.hnw-join-frame") + container = Array.from(joiners).find((c) -> c.contentWindow is e.source) + container.height = e.data.data.height + container.width = e.data.data.width + else console.warn("Unknown init-host postMessage:", e.data) diff --git a/app/assets/javascripts/beak/hnw/host/load-model.coffee b/app/assets/javascripts/beak/hnw/host/load-model.coffee index 7c02b7903..2826f71f1 100644 --- a/app/assets/javascripts/beak/hnw/host/load-model.coffee +++ b/app/assets/javascripts/beak/hnw/host/load-model.coffee @@ -3,8 +3,7 @@ import AlertDisplay from "/alert-display.js" import Tortoise from "/beak/tortoise.js" import { NewSource, ScriptSource } from "/beak/nlogo-source.js" -import genPageTitle from "../common/gen-page-title.js" -import handleFrameResize from "../common/handle-frame-resize.js" +import genPageTitle from "../common/gen-page-title.js" session = undefined # Session @@ -95,6 +94,4 @@ removeHostWidgets = (nlogo) -> newWidgets = widgets.replace(regex, "$1") [code, newWidgets, theRest...].join(delim) -handleFrameResize((-> activeContainer), (-> session)) - export { loadInitialModel, loadModel } diff --git a/app/assets/javascripts/beak/hnw/join/init.coffee b/app/assets/javascripts/beak/hnw/join/init.coffee index 882c3fc5b..f70c0eef0 100644 --- a/app/assets/javascripts/beak/hnw/join/init.coffee +++ b/app/assets/javascripts/beak/hnw/join/init.coffee @@ -56,3 +56,9 @@ window.addEventListener("message", (e) -> initBabyMonitor(e) ) + +resizer = new ResizeObserver(([{ contentRect: { height, width } }]) -> + parent.postMessage({ type: "resize-joiner", data: { height, width } }, "*") +) + +resizer.observe(document.querySelector(".netlogo-model-container-join")) diff --git a/app/assets/javascripts/beak/hnw/join/load-model.coffee b/app/assets/javascripts/beak/hnw/join/load-model.coffee index f7894be6f..77ad29d65 100644 --- a/app/assets/javascripts/beak/hnw/join/load-model.coffee +++ b/app/assets/javascripts/beak/hnw/join/load-model.coffee @@ -2,8 +2,7 @@ import AlertDisplay from "/alert-display.js" import Tortoise from "/beak/tortoise.js" -import genPageTitle from "../common/gen-page-title.js" -import handleFrameResize from "../common/handle-frame-resize.js" +import genPageTitle from "../common/gen-page-title.js" session = undefined # Session @@ -50,6 +49,4 @@ loadHNWModel = (setSession) -> (role, view) -> Tortoise.loadHubNetWeb(modelContainer, role, view, openSession(setSession), listeners) return -handleFrameResize((-> activeContainer), (-> session)) - export default loadHNWModel diff --git a/app/views/hnwJoin.scala.html b/app/views/hnwJoin.scala.html index 88550f9b3..8f5f07213 100644 --- a/app/views/hnwJoin.scala.html +++ b/app/views/hnwJoin.scala.html @@ -16,7 +16,7 @@ @tagBuilder.pathToHTML("stylesheets/hubnetweb.css") @tagBuilder.pathToHTML("stylesheets/alert.css") - + @views.html.spinner()
diff --git a/app/views/infoPane.scala.html b/app/views/infoPane.scala.html index 94bd104b9..c9910f229 100644 --- a/app/views/infoPane.scala.html +++ b/app/views/infoPane.scala.html @@ -16,7 +16,7 @@ @tagBuilder.pathToHTML("stylesheets/hubnetweb.css") @tagBuilder.pathToHTML("stylesheets/alert.css") - +
@views.html.spinner()
diff --git a/public/stylesheets/widgets.css b/public/stylesheets/widgets.css index 21b2f3125..bea36ced1 100644 --- a/public/stylesheets/widgets.css +++ b/public/stylesheets/widgets.css @@ -378,8 +378,8 @@ box-shadow: 3px 3px rgba(0, 0, 0, 0.8); } -.join-page-padding { - padding: 10px; +.join-body { + margin: 0; } .netlogo-model-container-join { @@ -387,7 +387,6 @@ flex-direction: row; justify-content: center; min-width: 900px; - width: 60%; margin: 0 auto; background-color: var(--light-gray); }