1
0
mirror of https://github.com/til-schneider/slim-wiki.git synced 2025-08-09 18:16:38 +02:00

Added menu button which toggles TOC for small screens

This commit is contained in:
til-schneider
2016-05-26 11:14:34 +02:00
parent 0292f11d81
commit 7db1d8df73
5 changed files with 41 additions and 9 deletions

View File

@@ -30,6 +30,10 @@
headingsOffset = 80, headingsOffset = 80,
headings; headings;
document.getElementById('button-menu').addEventListener('click', function() {
document.body.classList.toggle('is-toc-visible');
});
// tocbot needs ID attributes at the headings in order to function // tocbot needs ID attributes at the headings in order to function
headings = document.getElementById('content').querySelectorAll(headingSelector); headings = document.getElementById('content').querySelectorAll(headingSelector);
Array.prototype.forEach.call(headings, function (headingElem) { Array.prototype.forEach.call(headings, function (headingElem) {

View File

@@ -11,6 +11,7 @@ $i18n = array(
'button.cancel' => 'Abbrechen', 'button.cancel' => 'Abbrechen',
'button.back' => 'Zurück', 'button.back' => 'Zurück',
'button.edit' => 'Bearbeiten', 'button.edit' => 'Bearbeiten',
'button.menu' => 'Menü',
'button.createUser' => 'Benutzer erstellen', 'button.createUser' => 'Benutzer erstellen',
'button.createArticle' => 'Artikel anlegen', 'button.createArticle' => 'Artikel anlegen',
'demoAlert.title' => 'Dies ist eine Demo.', 'demoAlert.title' => 'Dies ist eine Demo.',

View File

@@ -11,6 +11,7 @@ $i18n = array(
'button.cancel' => 'Cancel', 'button.cancel' => 'Cancel',
'button.back' => 'Back', 'button.back' => 'Back',
'button.edit' => 'Edit', 'button.edit' => 'Edit',
'button.menu' => 'Menu',
'button.createUser' => 'Create user', 'button.createUser' => 'Create user',
'button.createArticle' => 'Create article', 'button.createArticle' => 'Create article',
'demoAlert.title' => 'This is a demo.', 'demoAlert.title' => 'This is a demo.',

View File

@@ -53,14 +53,27 @@
.mode-edit & { .mode-edit & {
width: 50%; width: 50%;
} }
#button-menu {
display: none;
.is-toc-enabled & {
@media (max-width: @screen-size-small-max) {
display: block;
}
}
}
} }
.toc-wrapper { .toc-wrapper {
position: fixed; position: fixed;
top: 0;
left: 50%; left: 50%;
right: 10px; right: 0;
top: 70px; height: 100%;
padding: 70px 10px 0 0;
margin-left: @contentMaxWidth / 2 + @tocMarginLeft; margin-left: @contentMaxWidth / 2 + @tocMarginLeft;
background-color: rgba(255, 255, 255, 0.9);
.mode-edit & { .mode-edit & {
display: none; display: none;
@@ -75,7 +88,15 @@
margin-left: 0; margin-left: 0;
} }
@media (max-width: @screen-size-small-max) { @media (max-width: @screen-size-small-max) {
display: none; transform: translateX(100%);
left: auto;
width: @tocMinWidth;
bottom: 0;
transition: all 300ms ease-in-out;
.is-toc-visible & {
transform: translateX(0);
}
} }
} }

View File

@@ -1,4 +1,14 @@
<nav class="breadcrumbs"><div class="main-column"><?php <?php
if ($data['showToc']) {
?><nav class="toc-wrapper"></nav><?php
}
?><nav class="breadcrumbs"><div class="main-column"><?php
// NOTE: We add buttons in reberse order because they float right
if ($mode == 'view' && $data['showToc']) {
?><div id="button-menu" class="btn btn-default btn-xs pull-right"><?php echo $i18n['button.menu']; ?></div><?php
}
if ($data['showCreateUserButton']) { if ($data['showCreateUserButton']) {
?><a class="btn btn-default btn-xs pull-right" href="<?php echo $data['requestPath']; ?>?createUser"><?php echo $i18n['button.createUser']; ?></a><?php ?><a class="btn btn-default btn-xs pull-right" href="<?php echo $data['requestPath']; ?>?createUser"><?php echo $i18n['button.createUser']; ?></a><?php
} }
@@ -19,8 +29,3 @@ foreach ($data['breadcrumbs'] as $item) {
$isFirst = false; $isFirst = false;
} }
?></div></nav> ?></div></nav>
<?php
if ($data['showToc']) {
?><nav class="toc-wrapper"></nav><?php
}
?>