toolbar: don't show the "saved revision" button in timeslider

The saved revision "star" button appeared in the timeslider toolbar too.

This change introduces a second flag "page" in toolbar.menu(), which controls
whether the toolbar is being drawn for a pad or in the timeslider page.

Fixes #3767.
pull/3885/head
John McLear 2020-03-27 20:29:24 +00:00 committed by muxator
parent 0d2854571d
commit 8b2fe75867
3 changed files with 11 additions and 9 deletions

View File

@ -253,8 +253,9 @@ module.exports = {
/*
* Valid values for whichMenu: 'left' | 'right' | 'timeslider-right'
* Valid values for page: 'pad' | 'timeslider'
*/
menu: function (buttons, isReadOnly, whichMenu) {
menu: function (buttons, isReadOnly, whichMenu, page) {
if (isReadOnly) {
// The best way to detect if it's the left editbar is to check for a bold button
if (buttons[0].indexOf("bold") !== -1) {
@ -269,13 +270,14 @@ module.exports = {
* This pad is not read only
*
* Add back the savedrevision button (the "star") if is not already there,
* but only on the right toolbar.
* but only on the right toolbar, and only if we are showing a pad (dont't
* do it in the timeslider).
*
* 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
* pads.
* This is a quick fix for #3702 (and subsequent issue #3767): it was
* sufficient to visit a single read only pad to cause the disappearence
* of the star button from all the pads.
*/
if ((buttons[0].indexOf("savedrevision") === -1) && (whichMenu === "right")) {
if ((buttons[0].indexOf("savedrevision") === -1) && (whichMenu === "right") && (page === "pad")) {
buttons[0].push("savedrevision");
}
}

View File

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

View File

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