@@ -75,43 +75,45 @@ export function supportersNotifications(init?: SupportersInit, update?: Supporte
7575 return
7676 }
7777
78- // extracts notification template from index.html
79- const template = document . getElementById ( 'supporters-notif-template' ) as HTMLTemplateElement
80- const doc = document . importNode ( template . content , true )
81- supportersNotif = doc . getElementById ( 'supporters-notif-container' ) as HTMLElement
82-
8378 // resets closing and stores new month
8479 updateSupportersOption ( {
8580 closed : false ,
8681 month : currentMonth ,
8782 } )
8883
84+ const settingsNotifs = document . getElementById ( 'settings-notifications' )
85+ const template = document . getElementById ( 'supporters-notif-template' ) as HTMLTemplateElement
86+ const doc = document . importNode ( template . content , true )
87+
88+ supportersNotif = doc . getElementById ( 'supporters-notif-container' ) as HTMLElement
89+ settingsNotifs ?. insertAdjacentElement ( 'beforebegin' , supportersNotif )
8990 supportersNotif . classList . add ( 'shown' )
9091 document . documentElement . dataset . supporters = ''
92+ }
9193
92- onSettingsLoad ( ( ) => {
93- const notifClose = doc . getElementById ( 'supporters-notif-close' )
94- const settingsNotifs = document . getElementById ( 'settings-notifications' )
95- const image = monthBackgrounds [ currentMonth - 1 ]
94+ export function initSupportersSettingsNotif ( supporters : Sync [ 'supporters' ] ) {
95+ // extracts notification template from index.html
96+ const template = document . getElementById ( 'supporters-notif-template' ) as HTMLTemplateElement
97+ const doc = document . importNode ( template . content , true )
98+ const notifClose = doc . getElementById ( 'supporters-notif-close' )
99+ const image = monthBackgrounds [ supporters . month - 1 ]
96100
97- supportersNotif . style . setProperty ( '--background' , `url(${ image } )` )
98- settingsNotifs ?. insertAdjacentElement ( 'beforebegin' , supportersNotif )
101+ supportersNotif . style . setProperty ( '--background' , `url(${ image } )` )
99102
100- initSupportersModal ( )
101- translateNotif ( )
103+ initSupportersModal ( )
104+ translateNotif ( )
102105
103- onclickdown ( supportersNotif , ( e ) => {
104- if ( e . target instanceof Element && ! e . target . closest ( '#supporters-notif-close' ) ) {
105- toggleSupportersModal ( true )
106- loadModalData ( )
107- }
108- } )
106+ onclickdown ( supportersNotif , ( e ) => {
107+ if ( e . target instanceof Element && ! e . target . closest ( '#supporters-notif-close' ) ) {
108+ toggleSupportersModal ( true )
109+ loadModalData ( )
110+ }
111+ } )
109112
110- onclickdown ( notifClose , ( ) => {
111- delete document . documentElement . dataset . supporters
112- supportersNotif . classList . remove ( 'shown' )
113- updateSupportersOption ( { closed : true } )
114- } )
113+ onclickdown ( notifClose , ( ) => {
114+ delete document . documentElement . dataset . supporters
115+ supportersNotif . classList . remove ( 'shown' )
116+ updateSupportersOption ( { closed : true } )
115117 } )
116118}
117119
0 commit comments