toolbar: show the "save revision" button only on the right toolbar.

Revision b480416375 fixed a bug, but introduced a regression, and the "save
revision" "star" button started to appear both on the left and the right
toolbar.

This change introduces a flag "whichMenu" in toolbar.menu(), that controls
whether the left, the right or the timeslider toolbar is being drawn.
This commit is contained in:
John McLear 2020-03-27 11:22:21 +00:00 committed by muxator
parent 463d7fb163
commit 0d2854571d
3 changed files with 10 additions and 6 deletions

View file

@ -251,7 +251,10 @@ module.exports = {
return new SelectButton(attributes); return new SelectButton(attributes);
}, },
menu: function (buttons, isReadOnly) { /*
* Valid values for whichMenu: 'left' | 'right' | 'timeslider-right'
*/
menu: function (buttons, isReadOnly, whichMenu) {
if (isReadOnly) { if (isReadOnly) {
// The best way to detect if it's the left editbar is to check for a bold button // The best way to detect if it's the left editbar is to check for a bold button
if (buttons[0].indexOf("bold") !== -1) { if (buttons[0].indexOf("bold") !== -1) {
@ -265,13 +268,14 @@ module.exports = {
/* /*
* This pad is not read only * This pad is not read only
* *
* Add back the savedrevision button (the "star") if is not already there. * Add back the savedrevision button (the "star") if is not already there,
* but only on the right toolbar.
* *
* This is a quick fix for #3702: it was sufficient to visit a single read * This is a quick fix for #3702: it was sufficient to visit a single read
* only pad to cause the disappearence of the star button from all the * only pad to cause the disappearence of the star button from all the
* pads. * pads.
*/ */
if ((buttons[0].indexOf("savedrevision") === -1)) { if ((buttons[0].indexOf("savedrevision") === -1) && (whichMenu === "right")) {
buttons[0].push("savedrevision"); buttons[0].push("savedrevision");
} }
} }

View file

@ -64,12 +64,12 @@
<ul class="menu_left" role="toolbar"> <ul class="menu_left" role="toolbar">
<% e.begin_block("editbarMenuLeft"); %> <% e.begin_block("editbarMenuLeft"); %>
<%- toolbar.menu(settings.toolbar.left, isReadOnly) %> <%- toolbar.menu(settings.toolbar.left, isReadOnly, 'left') %>
<% e.end_block(); %> <% e.end_block(); %>
</ul> </ul>
<ul class="menu_right" role="toolbar"> <ul class="menu_right" role="toolbar">
<% e.begin_block("editbarMenuRight"); %> <% e.begin_block("editbarMenuRight"); %>
<%- toolbar.menu(settings.toolbar.right, isReadOnly) %> <%- toolbar.menu(settings.toolbar.right, isReadOnly, 'right') %>
<% e.end_block(); %> <% e.end_block(); %>
</ul> </ul>
</div> </div>

View file

@ -82,7 +82,7 @@
<div class="editbarright toolbar" id="editbar"> <div class="editbarright toolbar" id="editbar">
<% e.begin_block("timesliderEditbarRight"); %> <% e.begin_block("timesliderEditbarRight"); %>
<ul> <ul>
<%- toolbar.menu(settings.toolbar.timeslider, true) %> <%- toolbar.menu(settings.toolbar.timeslider, true, 'timeslider-right') %>
</ul> </ul>
<% e.end_block(); %> <% e.end_block(); %>
</div> </div>