17
17
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18
18
*/
19
19
20
+ import Placeholder from '../../util/Placeholder.js' ;
20
21
import UIWindow from '../UIWindow.js'
21
22
22
23
async function UIWindowSettings ( options ) {
@@ -26,6 +27,7 @@ async function UIWindowSettings(options){
26
27
const svc_settings = globalThis . services . get ( 'settings' ) ;
27
28
28
29
const tabs = svc_settings . get_tabs ( ) ;
30
+ const tab_placeholders = [ ] ;
29
31
30
32
let h = '' ;
31
33
@@ -42,9 +44,14 @@ async function UIWindowSettings(options){
42
44
h += `<div class="settings-content-container">` ;
43
45
44
46
tabs . forEach ( ( tab , i ) => {
45
- h += `<div class="settings-content ${ i === 0 ? 'active' : '' } " data-settings="${ tab . id } ">
46
- ${ tab . html ( ) }
47
- </div>` ;
47
+ h += `<div class="settings-content ${ i === 0 ? 'active' : '' } " data-settings="${ tab . id } ">` ;
48
+ if ( tab . factory ) {
49
+ tab_placeholders [ i ] = Placeholder ( ) ;
50
+ h += tab_placeholders [ i ] . html ;
51
+ } else {
52
+ h += tab . html ( ) ;
53
+ }
54
+ h += `</div>` ;
48
55
} ) ;
49
56
50
57
h += `</div>` ;
@@ -85,7 +92,13 @@ async function UIWindowSettings(options){
85
92
}
86
93
} ) ;
87
94
const $el_window = $ ( el_window ) ;
88
- tabs . forEach ( tab => tab . init ( $el_window ) ) ;
95
+ tabs . forEach ( ( tab , i ) => {
96
+ tab . init && tab . init ( $el_window ) ;
97
+ if ( tab . factory ) {
98
+ const component = tab . factory ( ) ;
99
+ component . attach ( tab_placeholders [ i ] ) ;
100
+ }
101
+ } ) ;
89
102
90
103
$ ( el_window ) . on ( 'click' , '.settings-sidebar-item' , function ( ) {
91
104
const $this = $ ( this ) ;
0 commit comments