PageSourceSearch

https://littlebirdelectronics.com.au/assets/controllers/ecommerce/calculator_frame_controller-1f0f89a7.js

js littlebirdelectronics.com.au collected 2026-09-25 14:09:42 UTC 1,062 bytes, 30 lines download raw bytes

1import { Controller } from "@hotwired/stimulus"
2
3// Auto-sizes embedded calculator iframes. Each calculator posts
4// { type: "lb-calc-resize", height } to its parent after layout / on input;
5// we match the message to the iframe that sent it and set its height, so the
6// sandboxed widget never scrolls inside a fixed box.
7export default class extends Controller {
8  static targets = ["frame"]
9
10  connect() {
11    this.onMessage = this.onMessage.bind(this)
12    window.addEventListener("message", this.onMessage)
13  }
14
15  disconnect() {
16    window.removeEventListener("message", this.onMessage)
17  }
18
19  onMessage(event) {
20    const data = event.data
21    if (!data || data.type !== "lb-calc-resize") return
22    const height = parseInt(data.height, 10)
23    if (!Number.isFinite(height) || height <= 0) return
24
25    const frame = this.frameTargets.find((f) => f.contentWindow === event.source)
26    if (!frame) return
27    // Clamp to a sane range so a misbehaving widget can't blow out the page.
28    frame.style.height = `${Math.min(Math.max(height, 200), 2000)}px`
29  }
30}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.