Hide/show TOC in rich text

This commit is contained in:
yflory 2020-08-06 14:42:21 +02:00
parent baa2743663
commit 5da8b97b38
2 changed files with 40 additions and 0 deletions

View File

@ -996,6 +996,9 @@
.cp-toolbar-tools {
order: 7;
}
.cp-toolbar-icon-pad_toc {
order: 8;
}
.cp-toolbar-file {
button {
&.fa-plus { order: 0; }

View File

@ -426,6 +426,42 @@ define([
});
};
var addTOCHideBtn = function(framework, $toc) {
// Expand / collapse the toolbar
var onClick = function(visible) {
framework._.sfCommon.setAttribute(['pad', 'showTOC'], visible);
};
framework._.sfCommon.getAttribute(['pad', 'showTOC'], function(err, data) {
var state = false;
if (($(window).height() >= 800 || $(window).width() >= 800) &&
(typeof(data) === "undefined" || data)) {
state = true;
$toc.show();
} else {
$toc.hide();
}
Messages.pad_tocHide = "TOC"; // XXX
var $tocButton = framework._.sfCommon.createButton('', true, {
drawer: false,
text: Messages.pad_tocHide,
name: 'pad_toc',
icon: 'fa-newspaper-o',
}, function () {
$tocButton.removeClass('cp-toolbar-button-active');
$toc.toggle();
state = $toc.is(':visible');
if (state) {
$tocButton.addClass('cp-toolbar-button-active');
}
onClick(state);
});
framework._.toolbar.$bottomL.append($tocButton);
if (state) {
$tocButton.addClass('cp-toolbar-button-active');
}
});
};
var displayMediaTags = function(framework, dom, mediaTagMap) {
setTimeout(function() { // Just in case
var tags = dom.querySelectorAll('media-tag:empty');
@ -540,6 +576,7 @@ define([
});
var $toc = $('#cp-app-pad-toc');
addTOCHideBtn(framework, $toc);
// My cursor
var cursor = module.cursor = Cursor(inner);