@@ -18,21 +18,31 @@ declare var JSDialog: any;
18
18
19
19
type ToolbarItem = any ;
20
20
21
- class Toolbar {
22
- protected map : any ;
21
+ class Toolbar extends JSDialogComponent {
23
22
protected docType : string ;
24
- protected builder : JSBuilder ;
25
23
protected callback : JSDialogCallback ;
26
24
protected toolbarElementId : string ;
27
- protected parentContainer : Element ;
25
+ protected parentContainer : Element ; // FIXME: can we drop as we have container in base?
28
26
protected customItems : Array < ToolbarItem > ;
29
27
30
- constructor ( map : any , toolbarElementId : string ) {
31
- this . map = map ;
28
+ constructor ( map : any , name : string , toolbarElementId : string ) {
29
+ super ( map , name , 'toolbar' ) ;
30
+
32
31
this . docType = map . getDocType ( ) ;
33
32
this . customItems = [ ] ;
34
33
this . toolbarElementId = toolbarElementId ;
35
34
35
+ this . createBuilder ( ) ;
36
+ this . reset ( ) ;
37
+ this . create ( ) ;
38
+ this . updateVisibilityForToolbar ( '' ) ;
39
+ }
40
+
41
+ getToolItems ( ) : Array < ToolbarItem > {
42
+ return [ ] ;
43
+ }
44
+
45
+ protected createBuilder ( ) {
36
46
this . builder = new window . L . control . jsDialogBuilder ( {
37
47
mobileWizard : this ,
38
48
map : this . map ,
@@ -41,25 +51,23 @@ class Toolbar {
41
51
callback : this . callback ? this . callback . bind ( this ) : undefined ,
42
52
suffix : 'toolbar' ,
43
53
} ) ;
44
-
45
- this . reset ( ) ;
46
- this . create ( ) ;
47
- this . updateVisibilityForToolbar ( '' ) ;
48
- }
49
-
50
- getToolItems ( ) : Array < ToolbarItem > {
51
- return [ ] ;
52
54
}
53
55
54
- reset ( ) {
55
- this . parentContainer = window . L . DomUtil . get ( this . toolbarElementId ) ;
56
+ protected setupContainer ( parentContainer ?: HTMLElement /* ignored */ ) {
57
+ this . container = this . parentContainer = window . L . DomUtil . get (
58
+ this . toolbarElementId ,
59
+ ) ;
56
60
57
61
// In case it contains garbage
58
62
if ( this . parentContainer ) this . parentContainer . replaceChildren ( ) ;
59
63
60
64
window . L . DomUtil . addClass ( this . parentContainer , 'ui-toolbar' ) ;
61
65
}
62
66
67
+ reset ( ) {
68
+ this . setupContainer ( undefined ) ;
69
+ }
70
+
63
71
create ( ) {
64
72
this . reset ( ) ;
65
73
0 commit comments