Skip to content

Commit e2812bb

Browse files
committed
jsdialog: inherit from Component in Toolbar
Signed-off-by: Szymon Kłos <[email protected]> Change-Id: Ia2ec3cf3bf5a1e145982ff2548533ef930bd9a6b
1 parent 64bc070 commit e2812bb

File tree

6 files changed

+29
-21
lines changed

6 files changed

+29
-21
lines changed

browser/src/control/Control.MobileBottomBar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/* global app JSDialog _ _UNO */
1616
class MobileBottomBar extends JSDialog.Toolbar {
1717
constructor(map) {
18-
super(map, 'toolbar-down')
18+
super(map, 'MobileBottomBar', 'toolbar-down')
1919

2020
map.on('commandstatechanged', window.onCommandStateChanged);
2121
map.on('updatetoolbarcommandvalues', window.onCommandStateChanged);

browser/src/control/Control.MobileSearchBar.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
/* global _ _UNO */
1717
class MobileSearchBar extends Toolbar {
1818
constructor(map: any) {
19-
super(map, 'toolbar-search');
19+
super(map, 'MobileSearchBar', 'toolbar-search');
2020
}
2121

2222
getToolItems(): Array<ToolbarItem> {

browser/src/control/Control.MobileTopBar.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
class MobileTopBar extends JSDialog.Toolbar {
1616
constructor(map: any) {
17-
super(map, 'toolbar-up');
17+
super(map, 'MobileTopBar', 'toolbar-up');
1818

1919
app.events.on('updatepermission', this.onUpdatePermission.bind(this));
2020
map.on('commandstatechanged', this.onCommandStateChanged, this);

browser/src/control/Control.StatusBar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/* global $ app JSDialog _ _UNO getPermissionModeElements URLPopUpSection */
1616
class StatusBar extends JSDialog.Toolbar {
1717
constructor(map) {
18-
super(map, 'toolbar-down');
18+
super(map, 'Statusbar', 'toolbar-down');
1919

2020
map.on('doclayerinit', this.onDocLayerInit, this);
2121
map.on('languagesupdated', this.onLanguagesUpdated, this);

browser/src/control/Control.TopToolbar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/* global $ JSDialog _ _UNO app */
1616
class TopToolbar extends JSDialog.Toolbar {
1717
constructor(map) {
18-
super(map, 'toolbar-up');
18+
super(map, 'TopToolbar', 'toolbar-up');
1919
this.stylesSelectValue = null;
2020

2121
map.on('doclayerinit', this.onDocLayerInit, this);

browser/src/control/jsdialog/Component.Toolbar.ts

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,31 @@ declare var JSDialog: any;
1818

1919
type ToolbarItem = any;
2020

21-
class Toolbar {
22-
protected map: any;
21+
class Toolbar extends JSDialogComponent {
2322
protected docType: string;
24-
protected builder: JSBuilder;
2523
protected callback: JSDialogCallback;
2624
protected toolbarElementId: string;
27-
protected parentContainer: Element;
25+
protected parentContainer: Element; // FIXME: can we drop as we have container in base?
2826
protected customItems: Array<ToolbarItem>;
2927

30-
constructor(map: any, toolbarElementId: string) {
31-
this.map = map;
28+
constructor(map: any, name: string, toolbarElementId: string) {
29+
super(map, name, 'toolbar');
30+
3231
this.docType = map.getDocType();
3332
this.customItems = [];
3433
this.toolbarElementId = toolbarElementId;
3534

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() {
3646
this.builder = new window.L.control.jsDialogBuilder({
3747
mobileWizard: this,
3848
map: this.map,
@@ -41,25 +51,23 @@ class Toolbar {
4151
callback: this.callback ? this.callback.bind(this) : undefined,
4252
suffix: 'toolbar',
4353
});
44-
45-
this.reset();
46-
this.create();
47-
this.updateVisibilityForToolbar('');
48-
}
49-
50-
getToolItems(): Array<ToolbarItem> {
51-
return [];
5254
}
5355

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+
);
5660

5761
// In case it contains garbage
5862
if (this.parentContainer) this.parentContainer.replaceChildren();
5963

6064
window.L.DomUtil.addClass(this.parentContainer, 'ui-toolbar');
6165
}
6266

67+
reset() {
68+
this.setupContainer(undefined);
69+
}
70+
6371
create() {
6472
this.reset();
6573

0 commit comments

Comments
 (0)