diff --git a/modules/relay/src/main/ui/RelayFormUi.scala b/modules/relay/src/main/ui/RelayFormUi.scala index f6234357570bc..f33861a676801 100644 --- a/modules/relay/src/main/ui/RelayFormUi.scala +++ b/modules/relay/src/main/ui/RelayFormUi.scala @@ -414,7 +414,7 @@ final class RelayFormUi(helpers: Helpers, ui: RelayUi, tourUi: RelayTourUi): private def page(title: String, menu: Either[String, FormNavigation])(using Context) = Page(title) .css("bits.relay.form") - .js(esmInitBit("relayForm")) + .js(Esm("bits.relayTourForm")) .wrap: body => main(cls := "page page-menu")( menu.fold(tourUi.pageMenu(_), navigationMenu), diff --git a/ui/bits/src/bits.relayTourForm.ts b/ui/bits/src/bits.relayTourForm.ts new file mode 100644 index 0000000000000..ae16c00534de7 --- /dev/null +++ b/ui/bits/src/bits.relayTourForm.ts @@ -0,0 +1,23 @@ +import { wireCropDialog } from './crop'; + +site.load.then(() => { + $('.form3[action="/broadcast/new"] #form3-info_timeZone').each(function (this: HTMLSelectElement) { + if (!$('.is-invalid').length) this.value = Intl.DateTimeFormat().resolvedOptions().timeZone; + }); + + wireCropDialog({ + aspectRatio: 2 / 1, + post: { url: $('.relay-image-edit').attr('data-post-url')!, field: 'image' }, + selectClicks: $('.select-image, .drop-target'), + selectDrags: $('.drop-target'), + }); + + const $source = $('#form3-syncSource'), + showSource = () => + $('.relay-form__sync').each(function (this: HTMLElement) { + this.classList.toggle('none', !this.classList.contains(`relay-form__sync-${$source.val()}`)); + }); + + $source.on('change', showSource); + showSource(); +}); diff --git a/ui/bits/src/bits.ts b/ui/bits/src/bits.ts index 7b92567d3d5cb..47780de1dcb29 100644 --- a/ui/bits/src/bits.ts +++ b/ui/bits/src/bits.ts @@ -28,8 +28,6 @@ export function initModule(args: { fn: string } & any): void { return importer(); case 'pmAll': return pmAll(); - case 'relayForm': - return relayForm(); case 'setAssetInfo': return setAssetInfo(); case 'streamerSubscribe': @@ -186,24 +184,6 @@ function pmAll() { }); } -function relayForm() { - wireCropDialog({ - aspectRatio: 2 / 1, - post: { url: $('.relay-image-edit').attr('data-post-url')!, field: 'image' }, - selectClicks: $('.select-image, .drop-target'), - selectDrags: $('.drop-target'), - }); - - const $source = $('#form3-syncSource'), - showSource = () => - $('.relay-form__sync').each(function (this: HTMLElement) { - this.classList.toggle('none', !this.classList.contains(`relay-form__sync-${$source.val()}`)); - }); - - $source.on('change', showSource); - showSource(); -} - function setAssetInfo() { $('#asset-version-date').text(site.info.date); $('#asset-version-commit')