Skip to content

Commit

Permalink
Temp: Actually use correct whitespace in joiner frames
Browse files Browse the repository at this point in the history
It's been a long, long time coming...
  • Loading branch information
TheBizzle committed Jan 8, 2024
1 parent 3a4c859 commit 51330e8
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 53 deletions.
40 changes: 0 additions & 40 deletions app/assets/javascripts/beak/hnw/common/handle-frame-resize.coffee

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 1 addition & 4 deletions app/assets/javascripts/beak/hnw/host/load-model.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -95,6 +94,4 @@ removeHostWidgets = (nlogo) ->
newWidgets = widgets.replace(regex, "$1")
[code, newWidgets, theRest...].join(delim)

handleFrameResize((-> activeContainer), (-> session))

export { loadInitialModel, loadModel }
6 changes: 6 additions & 0 deletions app/assets/javascripts/beak/hnw/join/init.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
5 changes: 1 addition & 4 deletions app/assets/javascripts/beak/hnw/join/load-model.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -50,6 +49,4 @@ loadHNWModel = (setSession) -> (role, view) ->
Tortoise.loadHubNetWeb(modelContainer, role, view, openSession(setSession), listeners)
return

handleFrameResize((-> activeContainer), (-> session))

export default loadHNWModel
2 changes: 1 addition & 1 deletion app/views/hnwJoin.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@tagBuilder.pathToHTML("stylesheets/hubnetweb.css")
@tagBuilder.pathToHTML("stylesheets/alert.css")
</head>
<body class="flex-column join-page-padding">
<body class="flex-column join-body">
@views.html.spinner()
<div id="alert-container"></div>
<div id="netlogo-model-container" class="netlogo-model-container-join"></div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/infoPane.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@tagBuilder.pathToHTML("stylesheets/hubnetweb.css")
@tagBuilder.pathToHTML("stylesheets/alert.css")
</head>
<body class="flex-column join-page-padding">
<body class="flex-column">
<div id="info-pane-container"></div>
@views.html.spinner()
<div id="alert-container"></div>
Expand Down
5 changes: 2 additions & 3 deletions public/stylesheets/widgets.css
Original file line number Diff line number Diff line change
Expand Up @@ -378,16 +378,15 @@
box-shadow: 3px 3px rgba(0, 0, 0, 0.8);
}

.join-page-padding {
padding: 10px;
.join-body {
margin: 0;
}

.netlogo-model-container-join {
display: flex;
flex-direction: row;
justify-content: center;
min-width: 900px;
width: 60%;
margin: 0 auto;
background-color: var(--light-gray);
}
Expand Down

0 comments on commit 51330e8

Please sign in to comment.