Skip to content

Commit

Permalink
Move show button to UIManager
Browse files Browse the repository at this point in the history
Change-Id: I1c8c45dabf4cf8611ee8a3e9c7f36611775891aa
Signed-off-by: Szymon Kłos <[email protected]>
  • Loading branch information
eszkadev committed Mar 1, 2021
1 parent f671ed1 commit 3bf19f0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
25 changes: 25 additions & 0 deletions loleaflet/src/control/Control.UIManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,31 @@ L.Control.UIManager = L.Control.extend({
this.notebookbar.insertButtonToShortcuts(button);
},

showButtonInClassicToolbar: function(buttonId, show) {
var toolbars = [w2ui['toolbar-up'], w2ui['actionbar'], w2ui['editbar']];
var found = false;

toolbars.forEach(function(toolbar) {
if (toolbar && toolbar.get(buttonId)) {
found = true;
if (show) {
toolbar.show(buttonId);
} else {
toolbar.hide(buttonId);
}
}
});

if (!found) {
console.error('Toolbar button with id "' + buttonId + '" not found.');
return;
}
},

showButton: function(buttonId, show) {
this.showButtonInClassicToolbar(buttonId, show);
},

// Menubar

showMenubar: function() {
Expand Down
21 changes: 2 additions & 19 deletions loleaflet/src/map/handler/Map.WOPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,25 +247,8 @@ L.Map.WOPI = L.Handler.extend({
console.error('Property "Values.id" not set');
return;
}

var toolbars = [w2ui['toolbar-up'], w2ui['actionbar'], w2ui['editbar']];
var found = false;

toolbars.forEach(function(toolbar) {
if (toolbar && toolbar.get(msg.Values.id)) {
found = true;
if (msg.MessageId === 'Show_Button') {
toolbar.show(msg.Values.id);
} else {
toolbar.hide(msg.Values.id);
}
}
});

if (!found) {
console.error('Toolbar button with id "' + msg.Values.id + '" not found.');
return;
}
var show = msg.MessageId === 'Show_Button';
this._map.uiManager.showButton(msg.Values.id, show);
}
else if (msg.MessageId === 'Remove_Statusbar_Element') {
if (!msg.Values) {
Expand Down

0 comments on commit 3bf19f0

Please sign in to comment.